[前][次][番号順一覧][スレッド一覧]

ruby-changes:42007

From: nobu <ko1@a...>
Date: Thu, 10 Mar 2016 17:34:23 +0900 (JST)
Subject: [ruby-changes:42007] nobu:r54081 (trunk): iseq.h: coverage_enabled flag

nobu	2016-03-10 17:34:18 +0900 (Thu, 10 Mar 2016)

  New Revision: 54081

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54081

  Log:
    iseq.h: coverage_enabled flag
    
    * iseq.c (prepare_iseq_build): enable coverage by coverage_enabled
      option, not by parse_in_eval flag in the thread context.
    * iseq.h (rb_compile_option_struct): add coverage_enabled flag.
    * parse.y (yycompile0): set coverage_enabled flag if coverage
      array is made.

  Modified files:
    trunk/ChangeLog
    trunk/iseq.c
    trunk/iseq.h
    trunk/parse.y
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 54080)
+++ ChangeLog	(revision 54081)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Mar 10 17:34:16 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* iseq.c (prepare_iseq_build): enable coverage by coverage_enabled
+	  option, not by parse_in_eval flag in the thread context.
+
+	* iseq.h (rb_compile_option_struct): add coverage_enabled flag.
+
+	* parse.y (yycompile0): set coverage_enabled flag if coverage
+	  array is made.
+
 Thu Mar 10 15:19:54 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* node.c (dump_option): nd_compile_option is a hidden hash object,
Index: iseq.c
===================================================================
--- iseq.c	(revision 54080)
+++ iseq.c	(revision 54081)
@@ -298,7 +298,7 @@ prepare_iseq_build(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/iseq.c#L298
     ISEQ_COMPILE_DATA(iseq)->option = option;
     ISEQ_COMPILE_DATA(iseq)->last_coverable_line = -1;
 
-    if (!GET_THREAD()->parse_in_eval) {
+    if (option->coverage_enabled) {
 	VALUE coverages = rb_get_coverages();
 	if (RTEST(coverages)) {
 	    coverage = rb_hash_lookup(coverages, path);
@@ -336,6 +336,7 @@ static rb_compile_option_t COMPILE_OPTIO https://github.com/ruby/ruby/blob/trunk/iseq.c#L336
     OPT_TRACE_INSTRUCTION, /* int trace_instruction */
     OPT_FROZEN_STRING_LITERAL,
     OPT_DEBUG_FROZEN_STRING_LITERAL,
+    TRUE,			/* coverage_enabled */
 };
 
 static const rb_compile_option_t COMPILE_OPTION_FALSE = {0};
@@ -362,6 +363,7 @@ set_compile_option_from_hash(rb_compile_ https://github.com/ruby/ruby/blob/trunk/iseq.c#L363
     SET_COMPILE_OPTION(option, opt, trace_instruction);
     SET_COMPILE_OPTION(option, opt, frozen_string_literal);
     SET_COMPILE_OPTION(option, opt, debug_frozen_string_literal);
+    SET_COMPILE_OPTION(option, opt, coverage_enabled);
     SET_COMPILE_OPTION_NUM(option, opt, debug_level);
 #undef SET_COMPILE_OPTION
 #undef SET_COMPILE_OPTION_NUM
@@ -416,6 +418,7 @@ make_compile_option_value(rb_compile_opt https://github.com/ruby/ruby/blob/trunk/iseq.c#L418
 	SET_COMPILE_OPTION(option, opt, trace_instruction);
 	SET_COMPILE_OPTION(option, opt, frozen_string_literal);
 	SET_COMPILE_OPTION(option, opt, debug_frozen_string_literal);
+	SET_COMPILE_OPTION(option, opt, coverage_enabled);
 	SET_COMPILE_OPTION_NUM(option, opt, debug_level);
     }
 #undef SET_COMPILE_OPTION
Index: iseq.h
===================================================================
--- iseq.h	(revision 54080)
+++ iseq.h	(revision 54081)
@@ -134,6 +134,7 @@ struct rb_compile_option_struct { https://github.com/ruby/ruby/blob/trunk/iseq.h#L134
     unsigned int trace_instruction: 1;
     unsigned int frozen_string_literal: 1;
     unsigned int debug_frozen_string_literal: 1;
+    unsigned int coverage_enabled: 1;
     int debug_level;
 };
 
Index: parse.y
===================================================================
--- parse.y	(revision 54080)
+++ parse.y	(revision 54081)
@@ -5516,6 +5516,7 @@ yycompile0(VALUE arg) https://github.com/ruby/ruby/blob/trunk/parse.y#L5516
     int n;
     NODE *tree;
     struct parser_params *parser = (struct parser_params *)arg;
+    VALUE cov = Qfalse;
 
     if (!compile_for_eval && rb_safe_level() == 0) {
 	ruby_debug_lines = debug_lines(ruby_sourcefile_string);
@@ -5529,6 +5530,7 @@ yycompile0(VALUE arg) https://github.com/ruby/ruby/blob/trunk/parse.y#L5530
 
 	if (!e_option_supplied(parser)) {
 	    ruby_coverage = coverage(ruby_sourcefile_string, ruby_sourceline);
+	    cov = Qtrue;
 	}
     }
 
@@ -5559,7 +5561,10 @@ yycompile0(VALUE arg) https://github.com/ruby/ruby/blob/trunk/parse.y#L5561
 	tree = NEW_NIL();
     }
     else {
-	tree->nd_body = NEW_PRELUDE(ruby_eval_tree_begin, tree->nd_body, parser->compile_option);
+	VALUE opt = parser->compile_option;
+	if (!opt) opt = rb_obj_hide(rb_ident_hash_new());
+	rb_hash_aset(opt, rb_sym_intern_ascii_cstr("coverage_enabled"), cov);
+	tree->nd_body = NEW_PRELUDE(ruby_eval_tree_begin, tree->nd_body, opt);
     }
     return (VALUE)tree;
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]