summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2020-12-16 06:24:07 -0800
committerGitHub <noreply@github.com>2020-12-16 06:24:07 -0800
commit53babf35ef5b643774636550ea23851e2607e076 (patch)
treea18e660dd7f39718188fb161fd453c6c39097a14 /tool
parentbfb374be2342d7822cd37a1b100cb1715f85ca74 (diff)
Inline getconstant on JIT (#3906)
* Inline getconstant on JIT * Support USE_MJIT=0
Notes
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
Diffstat (limited to 'tool')
-rw-r--r--tool/ruby_vm/views/_mjit_compile_getinlinecache.erb36
-rw-r--r--tool/ruby_vm/views/mjit_compile.inc.erb2
2 files changed, 38 insertions, 0 deletions
diff --git a/tool/ruby_vm/views/_mjit_compile_getinlinecache.erb b/tool/ruby_vm/views/_mjit_compile_getinlinecache.erb
new file mode 100644
index 0000000000..44b7f3286a
--- /dev/null
+++ b/tool/ruby_vm/views/_mjit_compile_getinlinecache.erb
@@ -0,0 +1,36 @@
+% # -*- C -*-
+% # Copyright (c) 2020 Takashi Kokubun. 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.
+%
+% # compiler: Declare dst and ic
+% insn.opes.each_with_index do |ope, i|
+ <%= ope.fetch(:decl) %> = (<%= ope.fetch(:type) %>)operands[<%= i %>];
+% end
+
+% # compiler: Capture IC values, locking getinlinecache
+ rb_mjit_before_vm_ic_update();
+ rb_serial_t ic_serial = ic->ic_serial;
+ const rb_cref_t *ic_cref = ic->ic_cref;
+ VALUE ic_value = ic->value;
+ rb_mjit_after_vm_ic_update();
+
+ if (ic_serial && !status->compile_info->disable_const_cache) {
+% # JIT: Inline everything in IC, and cancel the slow path
+ fprintf(f, " if (vm_ic_hit_p((rb_serial_t)%"PRI_SERIALT_PREFIX"u, (const rb_cref_t *)0x%"PRIxVALUE", reg_cfp->ep)) {", ic_serial, (VALUE)ic_cref);
+ fprintf(f, " stack[%d] = 0x%"PRIxVALUE";\n", b->stack_size, ic_value);
+ fprintf(f, " goto label_%d;\n", pos + insn_len(insn) + (int)dst);
+ fprintf(f, " }");
+ fprintf(f, " else {");
+ fprintf(f, " reg_cfp->sp = vm_base_ptr(reg_cfp) + %d;\n", b->stack_size);
+ fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos);
+ fprintf(f, " goto const_cancel;\n");
+ fprintf(f, " }");
+
+% # compiler: Move JIT compiler's internal stack pointer
+ b->stack_size += <%= insn.call_attribute('sp_inc') %>;
+ break;
+ }
diff --git a/tool/ruby_vm/views/mjit_compile.inc.erb b/tool/ruby_vm/views/mjit_compile.inc.erb
index a7068c8532..f622467538 100644
--- a/tool/ruby_vm/views/mjit_compile.inc.erb
+++ b/tool/ruby_vm/views/mjit_compile.inc.erb
@@ -65,6 +65,8 @@ switch (insn) {
<%= render 'mjit_compile_ivar', locals: { insn: insn } -%>
% when 'invokebuiltin', 'opt_invokebuiltin_delegate'
<%= render 'mjit_compile_invokebuiltin', locals: { insn: insn } -%>
+% when 'opt_getinlinecache'
+<%= render 'mjit_compile_getinlinecache', locals: { insn: insn } -%>
% when 'leave', 'opt_invokebuiltin_delegate_leave'
% # opt_invokebuiltin_delegate_leave also implements leave insn. We need to handle it here for inlining.
% if insn.name == 'opt_invokebuiltin_delegate_leave'