mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Introduce an option "--dump=insns_without_opt" for debugging purposes
This commit is contained in:
parent
84cd3964d9
commit
8613c0c675
Notes:
git
2021-12-13 10:29:29 +09:00
3 changed files with 9 additions and 6 deletions
4
iseq.c
4
iseq.c
|
@ -866,11 +866,11 @@ rb_iseq_new_top(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath
|
|||
}
|
||||
|
||||
rb_iseq_t *
|
||||
rb_iseq_new_main(const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent)
|
||||
rb_iseq_new_main(const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt)
|
||||
{
|
||||
return rb_iseq_new_with_opt(ast, rb_fstring_lit("<main>"),
|
||||
path, realpath, INT2FIX(0),
|
||||
parent, 0, ISEQ_TYPE_MAIN, &COMPILE_OPTION_DEFAULT);
|
||||
parent, 0, ISEQ_TYPE_MAIN, opt ? &COMPILE_OPTION_DEFAULT : &COMPILE_OPTION_FALSE);
|
||||
}
|
||||
|
||||
rb_iseq_t *
|
||||
|
|
9
ruby.c
9
ruby.c
|
@ -143,13 +143,15 @@ enum feature_flag_bits {
|
|||
X(parsetree_with_comment) \
|
||||
SEP \
|
||||
X(insns) \
|
||||
SEP \
|
||||
X(insns_without_opt) \
|
||||
/* END OF DUMPS */
|
||||
enum dump_flag_bits {
|
||||
dump_version_v,
|
||||
EACH_DUMPS(DEFINE_DUMP, COMMA),
|
||||
dump_exit_bits = (DUMP_BIT(yydebug) | DUMP_BIT(syntax) |
|
||||
DUMP_BIT(parsetree) | DUMP_BIT(parsetree_with_comment) |
|
||||
DUMP_BIT(insns))
|
||||
DUMP_BIT(insns) | DUMP_BIT(insns_without_opt))
|
||||
};
|
||||
|
||||
typedef struct ruby_cmdline_options ruby_cmdline_options_t;
|
||||
|
@ -330,6 +332,7 @@ usage(const char *name, int help, int highlight, int columns)
|
|||
};
|
||||
static const struct message dumps[] = {
|
||||
M("insns", "", "instruction sequences"),
|
||||
M("insns_without_out", "", "instruction sequences compiled with no optimization"),
|
||||
M("yydebug", "", "yydebug of yacc parser generator"),
|
||||
M("parsetree", "", "AST"),
|
||||
M("parsetree_with_comment", "", "AST with comments"),
|
||||
|
@ -2161,11 +2164,11 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
|||
GetBindingPtr(rb_const_get(rb_cObject, rb_intern("TOPLEVEL_BINDING")),
|
||||
toplevel_binding);
|
||||
const struct rb_block *base_block = toplevel_context(toplevel_binding);
|
||||
iseq = rb_iseq_new_main(&ast->body, opt->script_name, path, vm_block_iseq(base_block));
|
||||
iseq = rb_iseq_new_main(&ast->body, opt->script_name, path, vm_block_iseq(base_block), !(dump & DUMP_BIT(insns_without_opt)));
|
||||
rb_ast_dispose(ast);
|
||||
}
|
||||
|
||||
if (dump & DUMP_BIT(insns)) {
|
||||
if (dump & (DUMP_BIT(insns) | DUMP_BIT(insns_without_opt))) {
|
||||
rb_io_write(rb_stdout, rb_iseq_disasm((const rb_iseq_t *)iseq));
|
||||
rb_io_flush(rb_stdout);
|
||||
dump &= ~DUMP_BIT(insns);
|
||||
|
|
|
@ -1105,7 +1105,7 @@ RUBY_SYMBOL_EXPORT_BEGIN
|
|||
/* node -> iseq */
|
||||
rb_iseq_t *rb_iseq_new (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, enum iseq_type);
|
||||
rb_iseq_t *rb_iseq_new_top (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent);
|
||||
rb_iseq_t *rb_iseq_new_main (const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent);
|
||||
rb_iseq_t *rb_iseq_new_main (const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt);
|
||||
rb_iseq_t *rb_iseq_new_eval (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_iseq_t *parent, int isolated_depth);
|
||||
rb_iseq_t *rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_iseq_t *parent, int isolated_depth,
|
||||
enum iseq_type, const rb_compile_option_t*);
|
||||
|
|
Loading…
Add table
Reference in a new issue