diff options
author | Yusuke Endoh <[email protected]> | 2021-08-27 16:19:56 +0900 |
---|---|---|
committer | Yusuke Endoh <[email protected]> | 2021-12-13 10:29:08 +0900 |
commit | 8613c0c6758b8d560b2461bd540c815d28fcf844 (patch) | |
tree | fb2626dcdfed0ba4a4f77dfa6a5377632f3f9e30 | |
parent | 84cd3964d9a5c6768610a2685ba04237dd79b57a (diff) |
Introduce an option "--dump=insns_without_opt" for debugging purposes
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4784
-rw-r--r-- | iseq.c | 4 | ||||
-rw-r--r-- | ruby.c | 9 | ||||
-rw-r--r-- | vm_core.h | 2 |
3 files changed, 9 insertions, 6 deletions
@@ -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 * @@ -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*); |