mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
6068da8937
This commit reintroduces finer-grained constant cache invalidation.
After 8008fb7
got merged, it was causing issues on token-threaded
builds (such as on Windows).
The issue was that when you're iterating through instruction sequences
and using the translator functions to get back the instruction structs,
you're either using `rb_vm_insn_null_translator` or
`rb_vm_insn_addr2insn2` depending if it's a direct-threading build.
`rb_vm_insn_addr2insn2` does some normalization to always return to
you the non-trace version of whatever instruction you're looking at.
`rb_vm_insn_null_translator` does not do that normalization.
This means that when you're looping through the instructions if you're
trying to do an opcode comparison, it can change depending on the type
of threading that you're using. This can be very confusing. So, this
commit creates a new translator function
`rb_vm_insn_normalizing_translator` to always return the non-trace
version so that opcode comparisons don't have to worry about different
configurations.
[Feature #18589]
31 lines
1.5 KiB
Text
31 lines
1.5 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 && !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", reg_cfp->ep)) {", ice->flags, ice->value, (VALUE)ice->ic_cref);
|
|
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;
|
|
}
|