ruby/tool/ruby_vm/views/_mjit_compile_getinlinecache.erb
nagachika cc4e602634 merge revision(s) 87c546b5fa97e6e226cce4daf417617a1143f642,7a3322a0fd660d676f1918bd7c4a37676b44e1c2:
Avoid using inconsistent coding style

	Other `_mjit_compile_*.erb` files don't use goto. These files'd better
	be consistent for readability.
	---
	 tool/ruby_vm/views/_mjit_compile_getinlinecache.erb | 14 +++-----------
	 1 file changed, 3 insertions(+), 11 deletions(-)

	Fix broken JIT of getinlinecache

	e7fc353f04 reverted vm_ic_hit_p's signature change made in 53babf35ef,
	which broke JIT compilation of getinlinecache.

	To make sure it doesn't happen again, I separated vm_inlined_ic_hit_p to
	make the intention clear.
	---
	 test/ruby/test_jit.rb                              | 12 +++++++++++
	 .../ruby_vm/views/_mjit_compile_getinlinecache.erb |  2 +-
	 vm_insnhelper.c                                    | 25 ++++++++++++++--------
	 3 files changed, 29 insertions(+), 10 deletions(-)
2021-04-29 17:49:55 +09:00

31 lines
1.6 KiB
Text

% # -*- 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
struct iseq_inline_constant_cache_entry *ice = ic->entry;
if (ice != NULL && ice->ic_serial && !status->compile_info->disable_const_cache) {
% # JIT: Inline everything in IC, and cancel the slow path
fprintf(f, " if (vm_inlined_ic_hit_p(0x%"PRIxVALUE", 0x%"PRIxVALUE", (const rb_cref_t *)0x%"PRIxVALUE", %"PRI_SERIALT_PREFIX"u, reg_cfp->ep)) {", ice->flags, ice->value, (VALUE)ice->ic_cref, ice->ic_serial);
fprintf(f, " stack[%d] = 0x%"PRIxVALUE";\n", b->stack_size, ice->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;
}