aboutsummaryrefslogtreecommitdiffstats
path: root/template
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-12 07:16:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-12 07:16:23 +0000
commit39e5ce2f76a4edac6ea01077594aafcc21f05489 (patch)
treefb8eaa4b774f2135039bd18e5ce2f1f0214485b0 /template
parent974e863d7cc0e4d5a7c064dd14a69934952bbe5c (diff)
downloadruby-39e5ce2f76a4edac6ea01077594aafcc21f05489.tar.gz
prelude.c.tmpl: optimize
* template/prelude.c.tmpl: enable tail call optimization. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'template')
-rw-r--r--template/prelude.c.tmpl23
1 files changed, 20 insertions, 3 deletions
diff --git a/template/prelude.c.tmpl b/template/prelude.c.tmpl
index 39d8887ec2..06fef15e0d 100644
--- a/template/prelude.c.tmpl
+++ b/template/prelude.c.tmpl
@@ -73,6 +73,7 @@ Prelude.new(output && output[/\w+(?=_prelude.c\b)/] || 'prelude', ARGV, vpath).i
#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)
% 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)
default:
return Qfalse;
}
- prelude_eval(code, name, INT2FIX(1));
+ prelude_eval(code, name, 1);
return Qtrue;
}