OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
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 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); | 27 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); |
29 uintptr_t value_off_addr = | 28 uintptr_t value_off_addr = |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 __ LoadP(ip, MemOperand(base_addr, map_off_addr - key_off_addr)); | 65 __ LoadP(ip, MemOperand(base_addr, map_off_addr - key_off_addr)); |
67 __ LoadP(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 66 __ LoadP(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
68 __ cmp(ip, scratch2); | 67 __ cmp(ip, scratch2); |
69 __ bne(&miss); | 68 __ bne(&miss); |
70 | 69 |
71 // Get the code entry from the cache. | 70 // Get the code entry from the cache. |
72 Register code = scratch2; | 71 Register code = scratch2; |
73 scratch2 = no_reg; | 72 scratch2 = no_reg; |
74 __ LoadP(code, MemOperand(base_addr, value_off_addr - key_off_addr)); | 73 __ LoadP(code, MemOperand(base_addr, value_off_addr - key_off_addr)); |
75 | 74 |
76 // Check that the flags match what we're looking for. | |
77 Register flags_reg = base_addr; | |
78 base_addr = no_reg; | |
79 __ lwz(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); | |
80 | |
81 DCHECK(!r0.is(flags_reg)); | |
82 __ li(r0, Operand(Code::kFlagsNotUsedInLookup)); | |
83 __ andc(flags_reg, flags_reg, r0); | |
84 __ mov(r0, Operand(flags)); | |
85 __ cmpl(flags_reg, r0); | |
86 __ bne(&miss); | |
87 | |
88 #ifdef DEBUG | 75 #ifdef DEBUG |
89 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 76 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
90 __ b(&miss); | 77 __ b(&miss); |
91 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 78 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
92 __ b(&miss); | 79 __ b(&miss); |
93 } | 80 } |
94 #endif | 81 #endif |
95 | 82 |
96 // Jump to the first instruction in the code stub. | 83 // Jump to the first instruction in the code stub. |
97 __ addi(r0, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 84 __ addi(r0, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
98 __ mtctr(r0); | 85 __ mtctr(r0); |
99 __ bctr(); | 86 __ bctr(); |
100 | 87 |
101 // Miss: fall through. | 88 // Miss: fall through. |
102 __ bind(&miss); | 89 __ bind(&miss); |
103 } | 90 } |
104 | 91 |
105 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, | 92 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, |
106 Register name, Register scratch, Register extra, | 93 Register name, Register scratch, Register extra, |
107 Register extra2, Register extra3) { | 94 Register extra2, Register extra3) { |
108 Code::Flags flags = | |
109 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_)); | |
110 | |
111 Label miss; | 95 Label miss; |
112 | 96 |
113 #if V8_TARGET_ARCH_PPC64 | 97 #if V8_TARGET_ARCH_PPC64 |
114 // Make sure that code is valid. The multiplying code relies on the | 98 // Make sure that code is valid. The multiplying code relies on the |
115 // entry size being 24. | 99 // entry size being 24. |
116 DCHECK(sizeof(Entry) == 24); | 100 DCHECK(sizeof(Entry) == 24); |
117 #else | 101 #else |
118 // 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 |
119 // entry size being 12. | 103 // entry size being 12. |
120 DCHECK(sizeof(Entry) == 12); | 104 DCHECK(sizeof(Entry) == 12); |
(...skipping 30 matching lines...) Expand all Loading... |
151 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, | 135 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, |
152 extra3); | 136 extra3); |
153 | 137 |
154 // Check that the receiver isn't a smi. | 138 // Check that the receiver isn't a smi. |
155 __ JumpIfSmi(receiver, &miss); | 139 __ JumpIfSmi(receiver, &miss); |
156 | 140 |
157 // Get the map of the receiver and compute the hash. | 141 // Get the map of the receiver and compute the hash. |
158 __ lwz(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); | 142 __ lwz(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); |
159 __ LoadP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 143 __ LoadP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
160 __ add(scratch, scratch, ip); | 144 __ add(scratch, scratch, ip); |
161 __ xori(scratch, scratch, Operand(flags)); | 145 __ xori(scratch, scratch, Operand(kPrimaryMagic)); |
162 // The mask omits the last two bits because they are not part of the hash. | 146 // The mask omits the last two bits because they are not part of the hash. |
163 __ andi(scratch, scratch, | 147 __ andi(scratch, scratch, |
164 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); | 148 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); |
165 | 149 |
166 // Probe the primary table. | 150 // Probe the primary table. |
167 ProbeTable(this, masm, flags, kPrimary, receiver, name, scratch, extra, | 151 ProbeTable(this, masm, kPrimary, receiver, name, scratch, extra, extra2, |
168 extra2, extra3); | 152 extra3); |
169 | 153 |
170 // Primary miss: Compute hash for secondary probe. | 154 // Primary miss: Compute hash for secondary probe. |
171 __ sub(scratch, scratch, name); | 155 __ sub(scratch, scratch, name); |
172 __ addi(scratch, scratch, Operand(flags)); | 156 __ addi(scratch, scratch, Operand(kSecondaryMagic)); |
173 __ andi(scratch, scratch, | 157 __ andi(scratch, scratch, |
174 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); | 158 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); |
175 | 159 |
176 // Probe the secondary table. | 160 // Probe the secondary table. |
177 ProbeTable(this, masm, flags, kSecondary, receiver, name, scratch, extra, | 161 ProbeTable(this, masm, kSecondary, receiver, name, scratch, extra, extra2, |
178 extra2, extra3); | 162 extra3); |
179 | 163 |
180 // Cache miss: Fall-through and let caller handle the miss by | 164 // Cache miss: Fall-through and let caller handle the miss by |
181 // entering the runtime system. | 165 // entering the runtime system. |
182 __ bind(&miss); | 166 __ bind(&miss); |
183 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 167 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
184 extra3); | 168 extra3); |
185 } | 169 } |
186 | 170 |
187 | 171 |
188 #undef __ | 172 #undef __ |
189 } // namespace internal | 173 } // namespace internal |
190 } // namespace v8 | 174 } // namespace v8 |
191 | 175 |
192 #endif // V8_TARGET_ARCH_PPC | 176 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |