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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/ic/stub-cache.h" | 10 #include "src/ic/stub-cache.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::Flags flags, StubCache::Table table, | 26 Code::Flags flags, bool leave_frame, |
27 Register receiver, Register name, Register offset, | 27 StubCache::Table table, Register receiver, Register name, |
28 Register scratch, Register scratch2, Register scratch3) { | 28 Register offset, Register scratch, Register scratch2, |
| 29 Register scratch3) { |
29 // Some code below relies on the fact that the Entry struct contains | 30 // Some code below relies on the fact that the Entry struct contains |
30 // 3 pointers (name, code, map). | 31 // 3 pointers (name, code, map). |
31 STATIC_ASSERT(sizeof(StubCache::Entry) == (3 * kPointerSize)); | 32 STATIC_ASSERT(sizeof(StubCache::Entry) == (3 * kPointerSize)); |
32 | 33 |
33 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); | 34 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); |
34 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); | 35 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); |
35 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); | 36 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); |
36 | 37 |
37 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); | 38 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); |
38 uintptr_t value_off_addr = | 39 uintptr_t value_off_addr = |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 __ B(ne, &miss); | 72 __ B(ne, &miss); |
72 | 73 |
73 #ifdef DEBUG | 74 #ifdef DEBUG |
74 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 75 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
75 __ B(&miss); | 76 __ B(&miss); |
76 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 77 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
77 __ B(&miss); | 78 __ B(&miss); |
78 } | 79 } |
79 #endif | 80 #endif |
80 | 81 |
| 82 if (leave_frame) __ LeaveFrame(StackFrame::INTERNAL); |
| 83 |
81 // Jump to the first instruction in the code stub. | 84 // Jump to the first instruction in the code stub. |
82 __ Add(scratch, scratch, Code::kHeaderSize - kHeapObjectTag); | 85 __ Add(scratch, scratch, Code::kHeaderSize - kHeapObjectTag); |
83 __ Br(scratch); | 86 __ Br(scratch); |
84 | 87 |
85 // Miss: fall through. | 88 // Miss: fall through. |
86 __ Bind(&miss); | 89 __ Bind(&miss); |
87 } | 90 } |
88 | 91 |
89 | 92 |
90 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Flags flags, | 93 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Flags flags, |
91 Register receiver, Register name, | 94 bool leave_frame, Register receiver, |
92 Register scratch, Register extra, Register extra2, | 95 Register name, Register scratch, Register extra, |
93 Register extra3) { | 96 Register extra2, Register extra3) { |
94 Isolate* isolate = masm->isolate(); | 97 Isolate* isolate = masm->isolate(); |
95 Label miss; | 98 Label miss; |
96 | 99 |
97 // Make sure the flags does not name a specific type. | 100 // Make sure the flags does not name a specific type. |
98 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); | 101 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); |
99 | 102 |
100 // Make sure that there are no register conflicts. | 103 // Make sure that there are no register conflicts. |
101 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); | 104 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); |
102 | 105 |
103 // Make sure extra and extra2 registers are valid. | 106 // Make sure extra and extra2 registers are valid. |
(...skipping 11 matching lines...) Expand all Loading... |
115 // Compute the hash for primary table. | 118 // Compute the hash for primary table. |
116 __ Ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); | 119 __ Ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); |
117 __ Ldr(extra, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 120 __ Ldr(extra, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
118 __ Add(scratch, scratch, extra); | 121 __ Add(scratch, scratch, extra); |
119 __ Eor(scratch, scratch, flags); | 122 __ Eor(scratch, scratch, flags); |
120 // We shift out the last two bits because they are not part of the hash. | 123 // We shift out the last two bits because they are not part of the hash. |
121 __ Ubfx(scratch, scratch, kCacheIndexShift, | 124 __ Ubfx(scratch, scratch, kCacheIndexShift, |
122 CountTrailingZeros(kPrimaryTableSize, 64)); | 125 CountTrailingZeros(kPrimaryTableSize, 64)); |
123 | 126 |
124 // Probe the primary table. | 127 // Probe the primary table. |
125 ProbeTable(isolate, masm, flags, kPrimary, receiver, name, scratch, extra, | 128 ProbeTable(isolate, masm, flags, leave_frame, kPrimary, receiver, name, |
126 extra2, extra3); | 129 scratch, extra, extra2, extra3); |
127 | 130 |
128 // Primary miss: Compute hash for secondary table. | 131 // Primary miss: Compute hash for secondary table. |
129 __ Sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift)); | 132 __ Sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift)); |
130 __ Add(scratch, scratch, flags >> kCacheIndexShift); | 133 __ Add(scratch, scratch, flags >> kCacheIndexShift); |
131 __ And(scratch, scratch, kSecondaryTableSize - 1); | 134 __ And(scratch, scratch, kSecondaryTableSize - 1); |
132 | 135 |
133 // Probe the secondary table. | 136 // Probe the secondary table. |
134 ProbeTable(isolate, masm, flags, kSecondary, receiver, name, scratch, extra, | 137 ProbeTable(isolate, masm, flags, leave_frame, kSecondary, receiver, name, |
135 extra2, extra3); | 138 scratch, extra, extra2, extra3); |
136 | 139 |
137 // Cache miss: Fall-through and let caller handle the miss by | 140 // Cache miss: Fall-through and let caller handle the miss by |
138 // entering the runtime system. | 141 // entering the runtime system. |
139 __ Bind(&miss); | 142 __ Bind(&miss); |
140 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 143 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
141 extra3); | 144 extra3); |
142 } | 145 } |
143 } | 146 } |
144 } // namespace v8::internal | 147 } // namespace v8::internal |
145 | 148 |
146 #endif // V8_TARGET_ARCH_ARM64 | 149 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |