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 Code::Flags flags, StubCache::Table table, | 18 StubCache::Table table, Register receiver, Register name, |
19 Register receiver, Register name, | |
20 // The offset is scaled by 4, based on | 19 // The offset is scaled by 4, based on |
21 // kCacheIndexShift, which is two bits | 20 // kCacheIndexShift, which is two bits |
22 Register offset, Register scratch, Register scratch2, | 21 Register offset, Register scratch, Register scratch2, |
23 Register offset_scratch) { | 22 Register offset_scratch) { |
24 ExternalReference key_offset(stub_cache->key_reference(table)); | 23 ExternalReference key_offset(stub_cache->key_reference(table)); |
25 ExternalReference value_offset(stub_cache->value_reference(table)); | 24 ExternalReference value_offset(stub_cache->value_reference(table)); |
26 ExternalReference map_offset(stub_cache->map_reference(table)); | 25 ExternalReference map_offset(stub_cache->map_reference(table)); |
27 | 26 |
28 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()); |
29 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()); |
(...skipping 26 matching lines...) Expand all Loading... |
56 __ ldr(ip, MemOperand(base_addr, map_off_addr - key_off_addr)); | 55 __ ldr(ip, MemOperand(base_addr, map_off_addr - key_off_addr)); |
57 __ ldr(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 56 __ ldr(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
58 __ cmp(ip, scratch2); | 57 __ cmp(ip, scratch2); |
59 __ b(ne, &miss); | 58 __ b(ne, &miss); |
60 | 59 |
61 // Get the code entry from the cache. | 60 // Get the code entry from the cache. |
62 Register code = scratch2; | 61 Register code = scratch2; |
63 scratch2 = no_reg; | 62 scratch2 = no_reg; |
64 __ ldr(code, MemOperand(base_addr, value_off_addr - key_off_addr)); | 63 __ ldr(code, MemOperand(base_addr, value_off_addr - key_off_addr)); |
65 | 64 |
66 // Check that the flags match what we're looking for. | |
67 Register flags_reg = base_addr; | |
68 base_addr = no_reg; | |
69 __ ldr(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); | |
70 // It's a nice optimization if this constant is encodable in the bic insn. | |
71 | |
72 uint32_t mask = Code::kFlagsNotUsedInLookup; | |
73 DCHECK(__ ImmediateFitsAddrMode1Instruction(mask)); | |
74 __ bic(flags_reg, flags_reg, Operand(mask)); | |
75 __ cmp(flags_reg, Operand(flags)); | |
76 __ b(ne, &miss); | |
77 | |
78 #ifdef DEBUG | 65 #ifdef DEBUG |
79 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 66 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
80 __ jmp(&miss); | 67 __ jmp(&miss); |
81 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 68 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
82 __ jmp(&miss); | 69 __ jmp(&miss); |
83 } | 70 } |
84 #endif | 71 #endif |
85 | 72 |
86 // Jump to the first instruction in the code stub. | 73 // Jump to the first instruction in the code stub. |
87 __ add(pc, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 74 __ add(pc, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
88 | 75 |
89 // Miss: fall through. | 76 // Miss: fall through. |
90 __ bind(&miss); | 77 __ bind(&miss); |
91 } | 78 } |
92 | 79 |
93 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, | 80 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, |
94 Register name, Register scratch, Register extra, | 81 Register name, Register scratch, Register extra, |
95 Register extra2, Register extra3) { | 82 Register extra2, Register extra3) { |
96 Code::Flags flags = | |
97 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_)); | |
98 | |
99 Label miss; | 83 Label miss; |
100 | 84 |
101 // Make sure that code is valid. The multiplying code relies on the | 85 // Make sure that code is valid. The multiplying code relies on the |
102 // entry size being 12. | 86 // entry size being 12. |
103 DCHECK(sizeof(Entry) == 12); | 87 DCHECK(sizeof(Entry) == 12); |
104 | 88 |
105 // Make sure that there are no register conflicts. | 89 // Make sure that there are no register conflicts. |
106 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); | 90 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); |
107 | 91 |
108 // Check scratch, extra and extra2 registers are valid. | 92 // Check scratch, extra and extra2 registers are valid. |
(...skipping 24 matching lines...) Expand all Loading... |
133 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, | 117 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, |
134 extra3); | 118 extra3); |
135 | 119 |
136 // Check that the receiver isn't a smi. | 120 // Check that the receiver isn't a smi. |
137 __ JumpIfSmi(receiver, &miss); | 121 __ JumpIfSmi(receiver, &miss); |
138 | 122 |
139 // Get the map of the receiver and compute the hash. | 123 // Get the map of the receiver and compute the hash. |
140 __ ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); | 124 __ ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); |
141 __ ldr(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 125 __ ldr(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
142 __ add(scratch, scratch, Operand(ip)); | 126 __ add(scratch, scratch, Operand(ip)); |
143 __ eor(scratch, scratch, Operand(flags)); | 127 __ eor(scratch, scratch, Operand(kPrimaryMagic)); |
144 __ mov(ip, Operand(kPrimaryTableSize - 1)); | 128 __ mov(ip, Operand(kPrimaryTableSize - 1)); |
145 __ and_(scratch, scratch, Operand(ip, LSL, kCacheIndexShift)); | 129 __ and_(scratch, scratch, Operand(ip, LSL, kCacheIndexShift)); |
146 | 130 |
147 // Probe the primary table. | 131 // Probe the primary table. |
148 ProbeTable(this, masm, flags, kPrimary, receiver, name, scratch, extra, | 132 ProbeTable(this, masm, kPrimary, receiver, name, scratch, extra, extra2, |
149 extra2, extra3); | 133 extra3); |
150 | 134 |
151 // Primary miss: Compute hash for secondary probe. | 135 // Primary miss: Compute hash for secondary probe. |
152 __ sub(scratch, scratch, Operand(name)); | 136 __ sub(scratch, scratch, Operand(name)); |
153 __ add(scratch, scratch, Operand(flags)); | 137 __ add(scratch, scratch, Operand(kSecondaryMagic)); |
154 __ mov(ip, Operand(kSecondaryTableSize - 1)); | 138 __ mov(ip, Operand(kSecondaryTableSize - 1)); |
155 __ and_(scratch, scratch, Operand(ip, LSL, kCacheIndexShift)); | 139 __ and_(scratch, scratch, Operand(ip, LSL, kCacheIndexShift)); |
156 | 140 |
157 // Probe the secondary table. | 141 // Probe the secondary table. |
158 ProbeTable(this, masm, flags, kSecondary, receiver, name, scratch, extra, | 142 ProbeTable(this, masm, kSecondary, receiver, name, scratch, extra, extra2, |
159 extra2, extra3); | 143 extra3); |
160 | 144 |
161 // Cache miss: Fall-through and let caller handle the miss by | 145 // Cache miss: Fall-through and let caller handle the miss by |
162 // entering the runtime system. | 146 // entering the runtime system. |
163 __ bind(&miss); | 147 __ bind(&miss); |
164 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 148 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
165 extra3); | 149 extra3); |
166 } | 150 } |
167 | 151 |
168 | 152 |
169 #undef __ | 153 #undef __ |
170 } // namespace internal | 154 } // namespace internal |
171 } // namespace v8 | 155 } // namespace v8 |
172 | 156 |
173 #endif // V8_TARGET_ARCH_ARM | 157 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |