OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_ARM | 5 #if V8_TARGET_ARCH_ARM |
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 #define __ ACCESS_MASM(masm) | 15 #define __ ACCESS_MASM(masm) |
16 | 16 |
17 | 17 |
18 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, | 18 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, |
19 Code::Kind ic_kind, Code::Flags flags, bool leave_frame, | 19 Code::Kind ic_kind, Code::Flags flags, |
20 StubCache::Table table, Register receiver, Register name, | 20 StubCache::Table table, Register receiver, Register name, |
21 // Number of the cache entry, not scaled. | 21 // Number of the cache entry, not scaled. |
22 Register offset, Register scratch, Register scratch2, | 22 Register offset, Register scratch, Register scratch2, |
23 Register offset_scratch) { | 23 Register offset_scratch) { |
24 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); | 24 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); |
25 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); | 25 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); |
26 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); | 26 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); |
27 | 27 |
28 uint32_t key_off_addr = reinterpret_cast<uint32_t>(key_offset.address()); | 28 uint32_t key_off_addr = reinterpret_cast<uint32_t>(key_offset.address()); |
29 uint32_t value_off_addr = reinterpret_cast<uint32_t>(value_offset.address()); | 29 uint32_t value_off_addr = reinterpret_cast<uint32_t>(value_offset.address()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 __ b(ne, &miss); | 77 __ b(ne, &miss); |
78 | 78 |
79 #ifdef DEBUG | 79 #ifdef DEBUG |
80 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 80 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
81 __ jmp(&miss); | 81 __ jmp(&miss); |
82 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 82 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
83 __ jmp(&miss); | 83 __ jmp(&miss); |
84 } | 84 } |
85 #endif | 85 #endif |
86 | 86 |
87 if (leave_frame) __ LeaveFrame(StackFrame::INTERNAL); | |
88 | |
89 // Jump to the first instruction in the code stub. | 87 // Jump to the first instruction in the code stub. |
90 __ add(pc, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 88 __ add(pc, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
91 | 89 |
92 // Miss: fall through. | 90 // Miss: fall through. |
93 __ bind(&miss); | 91 __ bind(&miss); |
94 } | 92 } |
95 | 93 |
96 | 94 |
97 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind, | 95 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind, |
98 Code::Flags flags, bool leave_frame, | 96 Code::Flags flags, Register receiver, |
99 Register receiver, Register name, | 97 Register name, Register scratch, Register extra, |
100 Register scratch, Register extra, Register extra2, | 98 Register extra2, Register extra3) { |
101 Register extra3) { | |
102 Isolate* isolate = masm->isolate(); | 99 Isolate* isolate = masm->isolate(); |
103 Label miss; | 100 Label miss; |
104 | 101 |
105 // Make sure that code is valid. The multiplying code relies on the | 102 // Make sure that code is valid. The multiplying code relies on the |
106 // entry size being 12. | 103 // entry size being 12. |
107 DCHECK(sizeof(Entry) == 12); | 104 DCHECK(sizeof(Entry) == 12); |
108 | 105 |
109 // Make sure the flags does not name a specific type. | 106 // Make sure the flags does not name a specific type. |
110 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); | 107 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); |
111 | 108 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // We shift out the last two bits because they are not part of the hash and | 141 // We shift out the last two bits because they are not part of the hash and |
145 // they are always 01 for maps. | 142 // they are always 01 for maps. |
146 __ mov(scratch, Operand(scratch, LSR, kCacheIndexShift)); | 143 __ mov(scratch, Operand(scratch, LSR, kCacheIndexShift)); |
147 // Mask down the eor argument to the minimum to keep the immediate | 144 // Mask down the eor argument to the minimum to keep the immediate |
148 // ARM-encodable. | 145 // ARM-encodable. |
149 __ eor(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask)); | 146 __ eor(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask)); |
150 // Prefer and_ to ubfx here because ubfx takes 2 cycles. | 147 // Prefer and_ to ubfx here because ubfx takes 2 cycles. |
151 __ and_(scratch, scratch, Operand(mask)); | 148 __ and_(scratch, scratch, Operand(mask)); |
152 | 149 |
153 // Probe the primary table. | 150 // Probe the primary table. |
154 ProbeTable(isolate, masm, ic_kind, flags, leave_frame, kPrimary, receiver, | 151 ProbeTable(isolate, masm, ic_kind, flags, kPrimary, receiver, name, scratch, |
155 name, scratch, extra, extra2, extra3); | 152 extra, extra2, extra3); |
156 | 153 |
157 // Primary miss: Compute hash for secondary probe. | 154 // Primary miss: Compute hash for secondary probe. |
158 __ sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift)); | 155 __ sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift)); |
159 uint32_t mask2 = kSecondaryTableSize - 1; | 156 uint32_t mask2 = kSecondaryTableSize - 1; |
160 __ add(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask2)); | 157 __ add(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask2)); |
161 __ and_(scratch, scratch, Operand(mask2)); | 158 __ and_(scratch, scratch, Operand(mask2)); |
162 | 159 |
163 // Probe the secondary table. | 160 // Probe the secondary table. |
164 ProbeTable(isolate, masm, ic_kind, flags, leave_frame, kSecondary, receiver, | 161 ProbeTable(isolate, masm, ic_kind, flags, kSecondary, receiver, name, scratch, |
165 name, scratch, extra, extra2, extra3); | 162 extra, extra2, extra3); |
166 | 163 |
167 // Cache miss: Fall-through and let caller handle the miss by | 164 // Cache miss: Fall-through and let caller handle the miss by |
168 // entering the runtime system. | 165 // entering the runtime system. |
169 __ bind(&miss); | 166 __ bind(&miss); |
170 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 167 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
171 extra3); | 168 extra3); |
172 } | 169 } |
173 | 170 |
174 | 171 |
175 #undef __ | 172 #undef __ |
176 } // namespace internal | 173 } // namespace internal |
177 } // namespace v8 | 174 } // namespace v8 |
178 | 175 |
179 #endif // V8_TARGET_ARCH_ARM | 176 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |