OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/ic/ic.h" | 8 #include "src/ic/ic.h" |
9 #include "src/ic/stub-cache.h" | 9 #include "src/ic/stub-cache.h" |
10 #include "src/interface-descriptors.h" | 10 #include "src/interface-descriptors.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 | 15 |
16 #define __ ACCESS_MASM(masm) | 16 #define __ ACCESS_MASM(masm) |
17 | 17 |
18 | 18 |
19 // Probe primary or secondary table. | 19 // Probe primary or secondary table. |
20 // If the entry is found in the cache, the generated code jump to the first | 20 // If the entry is found in the cache, the generated code jump to the first |
21 // instruction of the stub in the cache. | 21 // instruction of the stub in the cache. |
22 // If there is a miss the code fall trough. | 22 // If there is a miss the code fall trough. |
23 // | 23 // |
24 // 'receiver', 'name' and 'offset' registers are preserved on miss. | 24 // 'receiver', 'name' and 'offset' registers are preserved on miss. |
25 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, | 25 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, |
26 Code::Kind ic_kind, Code::Flags flags, | 26 Code::Flags flags, StubCache::Table table, |
27 StubCache::Table table, Register receiver, Register name, | 27 Register receiver, Register name, Register offset, |
28 Register offset, Register scratch, Register scratch2, | 28 Register scratch, Register scratch2, Register scratch3) { |
29 Register scratch3) { | |
30 // Some code below relies on the fact that the Entry struct contains | 29 // Some code below relies on the fact that the Entry struct contains |
31 // 3 pointers (name, code, map). | 30 // 3 pointers (name, code, map). |
32 STATIC_ASSERT(sizeof(StubCache::Entry) == (3 * kPointerSize)); | 31 STATIC_ASSERT(sizeof(StubCache::Entry) == (3 * kPointerSize)); |
33 | 32 |
34 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); | 33 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); |
35 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); | 34 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); |
36 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); | 35 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); |
37 | 36 |
38 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); | 37 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); |
39 uintptr_t value_off_addr = | 38 uintptr_t value_off_addr = |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // Compute the hash for primary table. | 129 // Compute the hash for primary table. |
131 __ Ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); | 130 __ Ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); |
132 __ Ldr(extra, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 131 __ Ldr(extra, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
133 __ Add(scratch, scratch, extra); | 132 __ Add(scratch, scratch, extra); |
134 __ Eor(scratch, scratch, flags); | 133 __ Eor(scratch, scratch, flags); |
135 // We shift out the last two bits because they are not part of the hash. | 134 // We shift out the last two bits because they are not part of the hash. |
136 __ Ubfx(scratch, scratch, kCacheIndexShift, | 135 __ Ubfx(scratch, scratch, kCacheIndexShift, |
137 CountTrailingZeros(kPrimaryTableSize, 64)); | 136 CountTrailingZeros(kPrimaryTableSize, 64)); |
138 | 137 |
139 // Probe the primary table. | 138 // Probe the primary table. |
140 ProbeTable(isolate, masm, ic_kind, flags, kPrimary, receiver, name, scratch, | 139 ProbeTable(isolate, masm, flags, kPrimary, receiver, name, scratch, extra, |
141 extra, extra2, extra3); | 140 extra2, extra3); |
142 | 141 |
143 // Primary miss: Compute hash for secondary table. | 142 // Primary miss: Compute hash for secondary table. |
144 __ Sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift)); | 143 __ Sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift)); |
145 __ Add(scratch, scratch, flags >> kCacheIndexShift); | 144 __ Add(scratch, scratch, flags >> kCacheIndexShift); |
146 __ And(scratch, scratch, kSecondaryTableSize - 1); | 145 __ And(scratch, scratch, kSecondaryTableSize - 1); |
147 | 146 |
148 // Probe the secondary table. | 147 // Probe the secondary table. |
149 ProbeTable(isolate, masm, ic_kind, flags, kSecondary, receiver, name, scratch, | 148 ProbeTable(isolate, masm, flags, kSecondary, receiver, name, scratch, extra, |
150 extra, extra2, extra3); | 149 extra2, extra3); |
151 | 150 |
152 // Cache miss: Fall-through and let caller handle the miss by | 151 // Cache miss: Fall-through and let caller handle the miss by |
153 // entering the runtime system. | 152 // entering the runtime system. |
154 __ Bind(&miss); | 153 __ Bind(&miss); |
155 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 154 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
156 extra3); | 155 extra3); |
157 } | 156 } |
158 } // namespace internal | 157 } // namespace internal |
159 } // namespace v8 | 158 } // namespace v8 |
160 | 159 |
161 #endif // V8_TARGET_ARCH_ARM64 | 160 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |