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