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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_ARM | 7 #if V8_TARGET_ARCH_ARM |
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 #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::Flags flags, StubCache::Table table, | 19 Code::Flags flags, bool leave_frame, |
20 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()); |
30 uint32_t map_off_addr = reinterpret_cast<uint32_t>(map_offset.address()); | 30 uint32_t map_off_addr = reinterpret_cast<uint32_t>(map_offset.address()); |
(...skipping 46 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 |
87 // Jump to the first instruction in the code stub. | 89 // Jump to the first instruction in the code stub. |
88 __ add(pc, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 90 __ add(pc, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
89 | 91 |
90 // Miss: fall through. | 92 // Miss: fall through. |
91 __ bind(&miss); | 93 __ bind(&miss); |
92 } | 94 } |
93 | 95 |
94 | 96 |
95 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Flags flags, | 97 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Flags flags, |
96 Register receiver, Register name, | 98 bool leave_frame, Register receiver, |
97 Register scratch, Register extra, Register extra2, | 99 Register name, Register scratch, Register extra, |
98 Register extra3) { | 100 Register extra2, Register extra3) { |
99 Isolate* isolate = masm->isolate(); | 101 Isolate* isolate = masm->isolate(); |
100 Label miss; | 102 Label miss; |
101 | 103 |
102 // Make sure that code is valid. The multiplying code relies on the | 104 // Make sure that code is valid. The multiplying code relies on the |
103 // entry size being 12. | 105 // entry size being 12. |
104 DCHECK(sizeof(Entry) == 12); | 106 DCHECK(sizeof(Entry) == 12); |
105 | 107 |
106 // Make sure the flags does not name a specific type. | 108 // Make sure the flags does not name a specific type. |
107 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); | 109 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); |
108 | 110 |
(...skipping 29 matching lines...) Expand all Loading... |
138 // We shift out the last two bits because they are not part of the hash and | 140 // We shift out the last two bits because they are not part of the hash and |
139 // they are always 01 for maps. | 141 // they are always 01 for maps. |
140 __ mov(scratch, Operand(scratch, LSR, kCacheIndexShift)); | 142 __ mov(scratch, Operand(scratch, LSR, kCacheIndexShift)); |
141 // Mask down the eor argument to the minimum to keep the immediate | 143 // Mask down the eor argument to the minimum to keep the immediate |
142 // ARM-encodable. | 144 // ARM-encodable. |
143 __ eor(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask)); | 145 __ eor(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask)); |
144 // Prefer and_ to ubfx here because ubfx takes 2 cycles. | 146 // Prefer and_ to ubfx here because ubfx takes 2 cycles. |
145 __ and_(scratch, scratch, Operand(mask)); | 147 __ and_(scratch, scratch, Operand(mask)); |
146 | 148 |
147 // Probe the primary table. | 149 // Probe the primary table. |
148 ProbeTable(isolate, masm, flags, kPrimary, receiver, name, scratch, extra, | 150 ProbeTable(isolate, masm, flags, leave_frame, kPrimary, receiver, name, |
149 extra2, extra3); | 151 scratch, extra, extra2, extra3); |
150 | 152 |
151 // Primary miss: Compute hash for secondary probe. | 153 // Primary miss: Compute hash for secondary probe. |
152 __ sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift)); | 154 __ sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift)); |
153 uint32_t mask2 = kSecondaryTableSize - 1; | 155 uint32_t mask2 = kSecondaryTableSize - 1; |
154 __ add(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask2)); | 156 __ add(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask2)); |
155 __ and_(scratch, scratch, Operand(mask2)); | 157 __ and_(scratch, scratch, Operand(mask2)); |
156 | 158 |
157 // Probe the secondary table. | 159 // Probe the secondary table. |
158 ProbeTable(isolate, masm, flags, kSecondary, receiver, name, scratch, extra, | 160 ProbeTable(isolate, masm, flags, leave_frame, kSecondary, receiver, name, |
159 extra2, extra3); | 161 scratch, extra, extra2, extra3); |
160 | 162 |
161 // Cache miss: Fall-through and let caller handle the miss by | 163 // Cache miss: Fall-through and let caller handle the miss by |
162 // entering the runtime system. | 164 // entering the runtime system. |
163 __ bind(&miss); | 165 __ bind(&miss); |
164 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 166 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
165 extra3); | 167 extra3); |
166 } | 168 } |
167 | 169 |
168 | 170 |
169 #undef __ | 171 #undef __ |
170 } | 172 } |
171 } // namespace v8::internal | 173 } // namespace v8::internal |
172 | 174 |
173 #endif // V8_TARGET_ARCH_ARM | 175 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |