ruby-changes:70167
From: Yusuke <ko1@a...>
Date: Mon, 13 Dec 2021 10:29:20 +0900 (JST)
Subject: [ruby-changes:70167] 8613c0c675 (master): Introduce an option "--dump=insns_without_opt" for debugging purposes
https://git.ruby-lang.org/ruby.git/commit/?id=8613c0c675 From 8613c0c6758b8d560b2461bd540c815d28fcf844 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Fri, 27 Aug 2021 16:19:56 +0900 Subject: Introduce an option "--dump=insns_without_opt" for debugging purposes --- iseq.c | 4 ++-- ruby.c | 9 ++++++--- vm_core.h | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/iseq.c b/iseq.c index e42525cb9fa..21622fa288b 100644 --- a/iseq.c +++ b/iseq.c @@ -866,11 +866,11 @@ rb_iseq_new_top(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath https://github.com/ruby/ruby/blob/trunk/iseq.c#L866 } 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 * diff --git a/ruby.c b/ruby.c index b9ed1ae89c4..09b7c770cf5 100644 --- a/ruby.c +++ b/ruby.c @@ -143,13 +143,15 @@ enum feature_flag_bits { https://github.com/ruby/ruby/blob/trunk/ruby.c#L143 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) https://github.com/ruby/ruby/blob/trunk/ruby.c#L332 }; 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) https://github.com/ruby/ruby/blob/trunk/ruby.c#L2164 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); diff --git a/vm_core.h b/vm_core.h index bcb0255a004..78d06012a14 100644 --- a/vm_core.h +++ b/vm_core.h @@ -1105,7 +1105,7 @@ RUBY_SYMBOL_EXPORT_BEGIN https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1105 /* 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*); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/