summaryrefslogtreecommitdiff
path: root/tool/ruby_vm/views/_mjit_compile_getinlinecache.erb
blob: fa38af4045e4982468138968cf385d8823e83399 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
% # -*- 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;
    }