| 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 | 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 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); | 28 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); |
| 29 uintptr_t value_off_addr = | 29 uintptr_t value_off_addr = |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 __ bne(&miss); | 86 __ bne(&miss); |
| 87 | 87 |
| 88 #ifdef DEBUG | 88 #ifdef DEBUG |
| 89 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 89 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
| 90 __ b(&miss); | 90 __ b(&miss); |
| 91 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 91 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
| 92 __ b(&miss); | 92 __ b(&miss); |
| 93 } | 93 } |
| 94 #endif | 94 #endif |
| 95 | 95 |
| 96 if (leave_frame) __ LeaveFrame(StackFrame::INTERNAL); | |
| 97 | |
| 98 // Jump to the first instruction in the code stub. | 96 // Jump to the first instruction in the code stub. |
| 99 __ addi(r0, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 97 __ addi(r0, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 100 __ mtctr(r0); | 98 __ mtctr(r0); |
| 101 __ bctr(); | 99 __ bctr(); |
| 102 | 100 |
| 103 // Miss: fall through. | 101 // Miss: fall through. |
| 104 __ bind(&miss); | 102 __ bind(&miss); |
| 105 } | 103 } |
| 106 | 104 |
| 107 | 105 |
| 108 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind, | 106 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind, |
| 109 Code::Flags flags, bool leave_frame, | 107 Code::Flags flags, Register receiver, |
| 110 Register receiver, Register name, | 108 Register name, Register scratch, Register extra, |
| 111 Register scratch, Register extra, Register extra2, | 109 Register extra2, Register extra3) { |
| 112 Register extra3) { | |
| 113 Isolate* isolate = masm->isolate(); | 110 Isolate* isolate = masm->isolate(); |
| 114 Label miss; | 111 Label miss; |
| 115 | 112 |
| 116 #if V8_TARGET_ARCH_PPC64 | 113 #if V8_TARGET_ARCH_PPC64 |
| 117 // Make sure that code is valid. The multiplying code relies on the | 114 // Make sure that code is valid. The multiplying code relies on the |
| 118 // entry size being 24. | 115 // entry size being 24. |
| 119 DCHECK(sizeof(Entry) == 24); | 116 DCHECK(sizeof(Entry) == 24); |
| 120 #else | 117 #else |
| 121 // Make sure that code is valid. The multiplying code relies on the | 118 // Make sure that code is valid. The multiplying code relies on the |
| 122 // entry size being 12. | 119 // entry size being 12. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 // Get the map of the receiver and compute the hash. | 153 // Get the map of the receiver and compute the hash. |
| 157 __ lwz(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); | 154 __ lwz(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); |
| 158 __ LoadP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 155 __ LoadP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 159 __ add(scratch, scratch, ip); | 156 __ add(scratch, scratch, ip); |
| 160 __ xori(scratch, scratch, Operand(flags)); | 157 __ xori(scratch, scratch, Operand(flags)); |
| 161 // The mask omits the last two bits because they are not part of the hash. | 158 // The mask omits the last two bits because they are not part of the hash. |
| 162 __ andi(scratch, scratch, | 159 __ andi(scratch, scratch, |
| 163 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); | 160 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); |
| 164 | 161 |
| 165 // Probe the primary table. | 162 // Probe the primary table. |
| 166 ProbeTable(isolate, masm, ic_kind, flags, leave_frame, kPrimary, receiver, | 163 ProbeTable(isolate, masm, ic_kind, flags, kPrimary, receiver, name, scratch, |
| 167 name, scratch, extra, extra2, extra3); | 164 extra, extra2, extra3); |
| 168 | 165 |
| 169 // Primary miss: Compute hash for secondary probe. | 166 // Primary miss: Compute hash for secondary probe. |
| 170 __ sub(scratch, scratch, name); | 167 __ sub(scratch, scratch, name); |
| 171 __ addi(scratch, scratch, Operand(flags)); | 168 __ addi(scratch, scratch, Operand(flags)); |
| 172 __ andi(scratch, scratch, | 169 __ andi(scratch, scratch, |
| 173 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); | 170 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); |
| 174 | 171 |
| 175 // Probe the secondary table. | 172 // Probe the secondary table. |
| 176 ProbeTable(isolate, masm, ic_kind, flags, leave_frame, kSecondary, receiver, | 173 ProbeTable(isolate, masm, ic_kind, flags, kSecondary, receiver, name, scratch, |
| 177 name, scratch, extra, extra2, extra3); | 174 extra, extra2, extra3); |
| 178 | 175 |
| 179 // Cache miss: Fall-through and let caller handle the miss by | 176 // Cache miss: Fall-through and let caller handle the miss by |
| 180 // entering the runtime system. | 177 // entering the runtime system. |
| 181 __ bind(&miss); | 178 __ bind(&miss); |
| 182 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 179 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
| 183 extra3); | 180 extra3); |
| 184 } | 181 } |
| 185 | 182 |
| 186 | 183 |
| 187 #undef __ | 184 #undef __ |
| 188 } // namespace internal | 185 } // namespace internal |
| 189 } // namespace v8 | 186 } // namespace v8 |
| 190 | 187 |
| 191 #endif // V8_TARGET_ARCH_PPC | 188 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |