| 1 |
%def invoke(helper="NterpUnimplemented"): |
| 2 |
call SYMBOL($helper) |
| 3 |
|
| 4 |
%def op_invoke_custom(): |
| 5 |
EXPORT_PC |
| 6 |
movzwl 2(rPC), %edi // call_site index, first argument of runtime call. |
| 7 |
jmp NterpCommonInvokeCustom |
| 8 |
|
| 9 |
%def op_invoke_custom_range(): |
| 10 |
EXPORT_PC |
| 11 |
movzwl 2(rPC), %edi // call_site index, first argument of runtime call. |
| 12 |
jmp NterpCommonInvokeCustomRange |
| 13 |
|
| 14 |
%def invoke_direct_or_super(helper="", range="", is_super=""): |
| 15 |
EXPORT_PC |
| 16 |
// Fast-path which gets the method from thread-local cache. |
| 17 |
% fetch_from_thread_cache("%rdi", miss_label="2f") |
| 18 |
1: |
| 19 |
// Load the first argument (the 'this' pointer). |
| 20 |
movzwl 4(rPC), %r11d // arguments |
| 21 |
.if !$range |
| 22 |
andq $$0xf, %r11 |
| 23 |
.endif |
| 24 |
movl (rFP, %r11, 4), %esi |
| 25 |
// NullPointerException check. |
| 26 |
movl (%esi), %eax |
| 27 |
jmp $helper |
| 28 |
2: |
| 29 |
movq rSELF:THREAD_SELF_OFFSET, %rdi |
| 30 |
movq 0(%rsp), %rsi |
| 31 |
movq rPC, %rdx |
| 32 |
call nterp_get_method |
| 33 |
movq %rax, %rdi |
| 34 |
.if $is_super |
| 35 |
jmp 1b |
| 36 |
.else |
| 37 |
testl MACRO_LITERAL(1), %eax |
| 38 |
je 1b |
| 39 |
andq $$-2, %rdi // Remove the extra bit that marks it's a String.<init> method. |
| 40 |
.if $range |
| 41 |
jmp NterpHandleStringInitRange |
| 42 |
.else |
| 43 |
jmp NterpHandleStringInit |
| 44 |
.endif |
| 45 |
.endif |
| 46 |
|
| 47 |
%def op_invoke_direct(): |
| 48 |
% invoke_direct_or_super(helper="NterpCommonInvokeInstance", range="0", is_super="0") |
| 49 |
|
| 50 |
%def op_invoke_direct_range(): |
| 51 |
% invoke_direct_or_super(helper="NterpCommonInvokeInstanceRange", range="1", is_super="0") |
| 52 |
|
| 53 |
%def op_invoke_polymorphic(): |
| 54 |
EXPORT_PC |
| 55 |
// No need to fetch the target method. |
| 56 |
// Load the first argument (the 'this' pointer). |
| 57 |
movzwl 4(rPC), %r11d // arguments |
| 58 |
andq $$0xf, %r11 |
| 59 |
movl (rFP, %r11, 4), %esi |
| 60 |
// NullPointerException check. |
| 61 |
movl (%esi), %eax |
| 62 |
jmp NterpCommonInvokePolymorphic |
| 63 |
|
| 64 |
%def op_invoke_polymorphic_range(): |
| 65 |
EXPORT_PC |
| 66 |
// No need to fetch the target method. |
| 67 |
// Load the first argument (the 'this' pointer). |
| 68 |
movzwl 4(rPC), %r11d // arguments |
| 69 |
movl (rFP, %r11, 4), %esi |
| 70 |
// NullPointerException check. |
| 71 |
movl (%esi), %eax |
| 72 |
jmp NterpCommonInvokePolymorphicRange |
| 73 |
|
| 74 |
%def invoke_interface(helper="", range=""): |
| 75 |
% slow_path = add_slow_path(op_invoke_interface_slow_path) |
| 76 |
EXPORT_PC |
| 77 |
// Fast-path which gets the interface method from thread-local cache. |
| 78 |
% fetch_from_thread_cache("%rax", miss_label=slow_path) |
| 79 |
.L${opcode}_resume: |
| 80 |
// First argument is the 'this' pointer. |
| 81 |
movzwl 4(rPC), %r11d // arguments |
| 82 |
.if !$range |
| 83 |
andq $$0xf, %r11 |
| 84 |
.endif |
| 85 |
movl (rFP, %r11, 4), %esi |
| 86 |
movl MIRROR_OBJECT_CLASS_OFFSET(%esi), %edx |
| 87 |
// Test the first two bits of the fetched ArtMethod: |
| 88 |
// - If the first bit is set, this is a method on j.l.Object |
| 89 |
// - If the second bit is set, this is a default method. |
| 90 |
testl $$3, %eax |
| 91 |
jne 2f |
| 92 |
movzw ART_METHOD_IMT_INDEX_OFFSET(%rax), %ecx |
| 93 |
1: |
| 94 |
movq MIRROR_CLASS_IMT_PTR_OFFSET_64(%edx), %rdx |
| 95 |
movq (%rdx, %rcx, 8), %rdi |
| 96 |
jmp $helper |
| 97 |
2: |
| 98 |
testl $$1, %eax |
| 99 |
.if $range |
| 100 |
jne NterpHandleInvokeInterfaceOnObjectMethodRange |
| 101 |
.else |
| 102 |
jne NterpHandleInvokeInterfaceOnObjectMethod |
| 103 |
.endif |
| 104 |
// Default method |
| 105 |
andq $$-4, %rax |
| 106 |
movzw ART_METHOD_METHOD_INDEX_OFFSET(%rax), %ecx |
| 107 |
andl $$ART_METHOD_IMT_MASK, %ecx |
| 108 |
jmp 1b |
| 109 |
|
| 110 |
%def op_invoke_interface_slow_path(): |
| 111 |
movq rSELF:THREAD_SELF_OFFSET, %rdi |
| 112 |
movq 0(%rsp), %rsi |
| 113 |
movq rPC, %rdx |
| 114 |
call nterp_get_method |
| 115 |
jmp .L${opcode}_resume |
| 116 |
|
| 117 |
%def op_invoke_interface(): |
| 118 |
% invoke_interface(helper="NterpCommonInvokeInterface", range="0") |
| 119 |
|
| 120 |
%def op_invoke_interface_range(): |
| 121 |
% invoke_interface(helper="NterpCommonInvokeInterfaceRange", range="1") |
| 122 |
|
| 123 |
%def invoke_static(helper=""): |
| 124 |
EXPORT_PC |
| 125 |
// Fast-path which gets the method from thread-local cache. |
| 126 |
% fetch_from_thread_cache("%rdi", miss_label="1f") |
| 127 |
jmp $helper |
| 128 |
1: |
| 129 |
movq rSELF:THREAD_SELF_OFFSET, %rdi |
| 130 |
movq 0(%rsp), %rsi |
| 131 |
movq rPC, %rdx |
| 132 |
call nterp_get_method |
| 133 |
movq %rax, %rdi |
| 134 |
jmp $helper |
| 135 |
|
| 136 |
%def op_invoke_static(): |
| 137 |
% invoke_static(helper="NterpCommonInvokeStatic") |
| 138 |
|
| 139 |
%def op_invoke_static_range(): |
| 140 |
% invoke_static(helper="NterpCommonInvokeStaticRange") |
| 141 |
|
| 142 |
%def op_invoke_super(): |
| 143 |
% invoke_direct_or_super(helper="NterpCommonInvokeInstance", range="0", is_super="1") |
| 144 |
|
| 145 |
%def op_invoke_super_range(): |
| 146 |
% invoke_direct_or_super(helper="NterpCommonInvokeInstanceRange", range="1", is_super="1") |
| 147 |
|
| 148 |
%def invoke_virtual(helper="", range=""): |
| 149 |
EXPORT_PC |
| 150 |
// Fast-path which gets the method from thread-local cache. |
| 151 |
% fetch_from_thread_cache("%rdi", miss_label="2f") |
| 152 |
1: |
| 153 |
// First argument is the 'this' pointer. |
| 154 |
movzwl 4(rPC), %r11d // arguments |
| 155 |
.if !$range |
| 156 |
andq $$0xf, %r11 |
| 157 |
.endif |
| 158 |
movl (rFP, %r11, 4), %esi |
| 159 |
// Note: if esi is null, this will be handled by our SIGSEGV handler. |
| 160 |
movl MIRROR_OBJECT_CLASS_OFFSET(%esi), %edx |
| 161 |
movq MIRROR_CLASS_VTABLE_OFFSET_64(%edx, %edi, 8), %rdi |
| 162 |
jmp $helper |
| 163 |
2: |
| 164 |
movq rSELF:THREAD_SELF_OFFSET, %rdi |
| 165 |
movq 0(%rsp), %rsi |
| 166 |
movq rPC, %rdx |
| 167 |
call nterp_get_method |
| 168 |
movl %eax, %edi |
| 169 |
jmp 1b |
| 170 |
|
| 171 |
%def op_invoke_virtual(): |
| 172 |
% invoke_virtual(helper="NterpCommonInvokeInstance", range="0") |
| 173 |
|
| 174 |
%def op_invoke_virtual_range(): |
| 175 |
% invoke_virtual(helper="NterpCommonInvokeInstanceRange", range="1") |