summaryrefslogtreecommitdiff
path: root/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-07-09 21:43:42 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-07-13 08:56:18 +0900
commitf66e0212efe4f6572d5e81741e831ab735cc2fee (patch)
tree94b45502a7d483489b697c3966b7d75e9cfd9b40 /tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb
parent5d02c1dd14648d95178ac5ec756f5b03fe00d549 (diff)
precalc invokebuiltin destinations
Noticed that struct rb_builtin_function is a purely compile-time constant. MJIT can eliminate some runtime calculations by statically generate dedicated C code generator for each builtin functions.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3305
Diffstat (limited to 'tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb')
-rw-r--r--tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb23
1 files changed, 23 insertions, 0 deletions
diff --git a/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb b/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb
new file mode 100644
index 0000000000..f935f799cb
--- /dev/null
+++ b/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb
@@ -0,0 +1,23 @@
+% # -*- C -*-
+% # Copyright (c) 2020 Urabe, Shyouhei. All rights reserved.
+% #
+% # This file is a part of the programming language Ruby. Permission is hereby
+% # granted, to either redistribute and/or modify this file, provided that the
+% # conditions mentioned in the file COPYING are met. Consult the file for
+% # details.
+%
+ /* <%= insn.name %> */
+ const struct rb_builtin_function *bf = (const void *)operands[0];
+%
+% if insn.name == 'invokebuiltin' then
+ const rb_num_t index = -1;
+% else
+ const rb_num_t index = (rb_num_t)operands[1];
+% end
+%
+ if (bf->compiler) {
+ bf->compiler(f, index);
+ }
+ else {
+ mjit_invokebuiltin_default_compiler(f, bf, index);
+ }