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

ruby-changes:40468

From: nobu <ko1@a...>
Date: Thu, 12 Nov 2015 16:16:39 +0900 (JST)
Subject: [ruby-changes:40468] nobu:r52549 (trunk): prelude.c.tmpl: optimize

nobu	2015-11-12 16:16:23 +0900 (Thu, 12 Nov 2015)

  New Revision: 52549

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

  Log:
    prelude.c.tmpl: optimize
    
    * template/prelude.c.tmpl: enable tail call optimization.

  Modified files:
    trunk/ChangeLog
    trunk/template/prelude.c.tmpl
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52548)
+++ ChangeLog	(revision 52549)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Nov 12 16:16:20 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* template/prelude.c.tmpl: enable tail call optimization.
+
 Thu Nov 12 14:17:01 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (parser_yylex): ANDDOT at the head of the line denote
Index: template/prelude.c.tmpl
===================================================================
--- template/prelude.c.tmpl	(revision 52548)
+++ template/prelude.c.tmpl	(revision 52549)
@@ -73,6 +73,7 @@ Prelude.new(output && output[/\w+(?=_pre https://github.com/ruby/ruby/blob/trunk/template/prelude.c.tmpl#L73
 #include "ruby/ruby.h"
 #include "internal.h"
 #include "vm_core.h"
+#include "iseq.h"
 
 % preludes = @preludes.values.sort
 % preludes.each {|i, prelude, lines, sub|
@@ -105,9 +106,25 @@ prelude_prefix_path(VALUE self) https://github.com/ruby/ruby/blob/trunk/template/prelude.c.tmpl#L106
 
 % unless preludes.empty?
 static void
-prelude_eval(VALUE code, VALUE name, VALUE line)
+prelude_eval(VALUE code, VALUE name, int line)
 {
-    rb_iseq_eval(rb_iseq_compile_with_option(code, name, Qnil, line, 0, Qtrue));
+    static const rb_compile_option_t optimization = {
+	TRUE, /* int inline_const_cache; */
+	TRUE, /* int peephole_optimization; */
+	TRUE, /* int tailcall_optimization */
+	TRUE, /* int specialized_instruction; */
+	TRUE, /* int operands_unification; */
+	TRUE, /* int instructions_unification; */
+	TRUE, /* int stack_caching; */
+	FALSE, /* int trace_instruction */
+	TRUE,
+	FALSE,
+    };
+
+    NODE *node = rb_parser_compile_string_path(rb_parser_new(), name, code, line);
+    if (!node) rb_exc_raise(rb_errinfo());
+    rb_iseq_eval(rb_iseq_new_with_opt(node, name, name, Qnil, INT2FIX(line),
+				      NULL, ISEQ_TYPE_TOP, &optimization));
 }
 % end
 
@@ -134,7 +151,7 @@ prelude_require(VALUE self, VALUE nth) https://github.com/ruby/ruby/blob/trunk/template/prelude.c.tmpl#L151
       default:
 	return Qfalse;
     }
-    prelude_eval(code, name, INT2FIX(1));
+    prelude_eval(code, name, 1);
     return Qtrue;
 }
 

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

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