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 static void ProbeTable(StubCache* stub_cache, MacroAssembler* masm, | 17 static void ProbeTable(StubCache* stub_cache, MacroAssembler* masm, |
18 StubCache::Table table, Register receiver, Register name, | 18 Code::Flags flags, StubCache::Table table, |
| 19 Register receiver, Register name, |
19 // Number of the cache entry, not scaled. | 20 // Number of the cache entry, not scaled. |
20 Register offset, Register scratch, Register scratch2, | 21 Register offset, Register scratch, Register scratch2, |
21 Register offset_scratch) { | 22 Register offset_scratch) { |
22 ExternalReference key_offset(stub_cache->key_reference(table)); | 23 ExternalReference key_offset(stub_cache->key_reference(table)); |
23 ExternalReference value_offset(stub_cache->value_reference(table)); | 24 ExternalReference value_offset(stub_cache->value_reference(table)); |
24 ExternalReference map_offset(stub_cache->map_reference(table)); | 25 ExternalReference map_offset(stub_cache->map_reference(table)); |
25 | 26 |
26 uint32_t key_off_addr = reinterpret_cast<uint32_t>(key_offset.address()); | 27 uint32_t key_off_addr = reinterpret_cast<uint32_t>(key_offset.address()); |
27 uint32_t value_off_addr = reinterpret_cast<uint32_t>(value_offset.address()); | 28 uint32_t value_off_addr = reinterpret_cast<uint32_t>(value_offset.address()); |
28 uint32_t map_off_addr = reinterpret_cast<uint32_t>(map_offset.address()); | 29 uint32_t map_off_addr = reinterpret_cast<uint32_t>(map_offset.address()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 Register code = scratch2; | 62 Register code = scratch2; |
62 scratch2 = no_reg; | 63 scratch2 = no_reg; |
63 __ ldr(code, MemOperand(base_addr, value_off_addr - key_off_addr)); | 64 __ ldr(code, MemOperand(base_addr, value_off_addr - key_off_addr)); |
64 | 65 |
65 // Check that the flags match what we're looking for. | 66 // Check that the flags match what we're looking for. |
66 Register flags_reg = base_addr; | 67 Register flags_reg = base_addr; |
67 base_addr = no_reg; | 68 base_addr = no_reg; |
68 __ ldr(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); | 69 __ ldr(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); |
69 // It's a nice optimization if this constant is encodable in the bic insn. | 70 // It's a nice optimization if this constant is encodable in the bic insn. |
70 | 71 |
71 #ifdef DEBUG | |
72 Code::Flags flags = Code::RemoveHolderFromFlags( | |
73 Code::ComputeHandlerFlags(stub_cache->ic_kind())); | |
74 uint32_t mask = Code::kFlagsNotUsedInLookup; | 72 uint32_t mask = Code::kFlagsNotUsedInLookup; |
75 DCHECK(__ ImmediateFitsAddrMode1Instruction(mask)); | 73 DCHECK(__ ImmediateFitsAddrMode1Instruction(mask)); |
76 __ bic(flags_reg, flags_reg, Operand(mask)); | 74 __ bic(flags_reg, flags_reg, Operand(mask)); |
77 __ cmp(flags_reg, Operand(flags)); | 75 __ cmp(flags_reg, Operand(flags)); |
78 __ Check(eq, kUnexpectedValue); | 76 __ b(ne, &miss); |
79 | 77 |
| 78 #ifdef DEBUG |
80 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 79 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
81 __ jmp(&miss); | 80 __ jmp(&miss); |
82 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 81 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
83 __ jmp(&miss); | 82 __ jmp(&miss); |
84 } | 83 } |
85 #endif | 84 #endif |
86 | 85 |
87 // Jump to the first instruction in the code stub. | 86 // Jump to the first instruction in the code stub. |
88 __ add(pc, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 87 __ add(pc, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
89 | 88 |
90 // Miss: fall through. | 89 // Miss: fall through. |
91 __ bind(&miss); | 90 __ bind(&miss); |
92 } | 91 } |
93 | 92 |
94 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, | 93 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, |
95 Register name, Register scratch, Register extra, | 94 Register name, Register scratch, Register extra, |
96 Register extra2, Register extra3) { | 95 Register extra2, Register extra3) { |
| 96 Code::Flags flags = |
| 97 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_)); |
| 98 |
97 Label miss; | 99 Label miss; |
98 | 100 |
99 // Make sure that code is valid. The multiplying code relies on the | 101 // Make sure that code is valid. The multiplying code relies on the |
100 // entry size being 12. | 102 // entry size being 12. |
101 DCHECK(sizeof(Entry) == 12); | 103 DCHECK(sizeof(Entry) == 12); |
102 | 104 |
103 // Make sure that there are no register conflicts. | 105 // Make sure that there are no register conflicts. |
104 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); | 106 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); |
105 | 107 |
106 // Check scratch, extra and extra2 registers are valid. | 108 // Check scratch, extra and extra2 registers are valid. |
(...skipping 28 matching lines...) Expand all Loading... |
135 __ JumpIfSmi(receiver, &miss); | 137 __ JumpIfSmi(receiver, &miss); |
136 | 138 |
137 // Get the map of the receiver and compute the hash. | 139 // Get the map of the receiver and compute the hash. |
138 __ ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); | 140 __ ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); |
139 __ ldr(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 141 __ ldr(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
140 __ add(scratch, scratch, Operand(ip)); | 142 __ add(scratch, scratch, Operand(ip)); |
141 uint32_t mask = kPrimaryTableSize - 1; | 143 uint32_t mask = kPrimaryTableSize - 1; |
142 // We shift out the last two bits because they are not part of the hash and | 144 // We shift out the last two bits because they are not part of the hash and |
143 // they are always 01 for maps. | 145 // they are always 01 for maps. |
144 __ mov(scratch, Operand(scratch, LSR, kCacheIndexShift)); | 146 __ mov(scratch, Operand(scratch, LSR, kCacheIndexShift)); |
| 147 // Mask down the eor argument to the minimum to keep the immediate |
| 148 // ARM-encodable. |
| 149 __ eor(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask)); |
145 // Prefer and_ to ubfx here because ubfx takes 2 cycles. | 150 // Prefer and_ to ubfx here because ubfx takes 2 cycles. |
146 __ and_(scratch, scratch, Operand(mask)); | 151 __ and_(scratch, scratch, Operand(mask)); |
147 | 152 |
148 // Probe the primary table. | 153 // Probe the primary table. |
149 ProbeTable(this, masm, kPrimary, receiver, name, scratch, extra, extra2, | 154 ProbeTable(this, masm, flags, kPrimary, receiver, name, scratch, extra, |
150 extra3); | 155 extra2, extra3); |
151 | 156 |
152 // Primary miss: Compute hash for secondary probe. | 157 // Primary miss: Compute hash for secondary probe. |
153 __ sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift)); | 158 __ sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift)); |
154 uint32_t mask2 = kSecondaryTableSize - 1; | 159 uint32_t mask2 = kSecondaryTableSize - 1; |
| 160 __ add(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask2)); |
155 __ and_(scratch, scratch, Operand(mask2)); | 161 __ and_(scratch, scratch, Operand(mask2)); |
156 | 162 |
157 // Probe the secondary table. | 163 // Probe the secondary table. |
158 ProbeTable(this, masm, kSecondary, receiver, name, scratch, extra, extra2, | 164 ProbeTable(this, masm, flags, kSecondary, receiver, name, scratch, extra, |
159 extra3); | 165 extra2, extra3); |
160 | 166 |
161 // Cache miss: Fall-through and let caller handle the miss by | 167 // Cache miss: Fall-through and let caller handle the miss by |
162 // entering the runtime system. | 168 // entering the runtime system. |
163 __ bind(&miss); | 169 __ bind(&miss); |
164 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 170 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
165 extra3); | 171 extra3); |
166 } | 172 } |
167 | 173 |
168 | 174 |
169 #undef __ | 175 #undef __ |
170 } // namespace internal | 176 } // namespace internal |
171 } // namespace v8 | 177 } // namespace v8 |
172 | 178 |
173 #endif // V8_TARGET_ARCH_ARM | 179 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |