| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_S390 | 5 #if V8_TARGET_ARCH_S390 |
| 6 | 6 |
| 7 #include "src/ic/stub-cache.h" | 7 #include "src/ic/stub-cache.h" |
| 8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
| 9 #include "src/ic/ic.h" | 9 #include "src/ic/ic.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 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()); |
| 27 uintptr_t value_off_addr = | 28 uintptr_t value_off_addr = |
| 28 reinterpret_cast<uintptr_t>(value_offset.address()); | 29 reinterpret_cast<uintptr_t>(value_offset.address()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // Check the map matches. | 63 // Check the map matches. |
| 63 __ LoadP(ip, MemOperand(base_addr, map_off_addr - key_off_addr)); | 64 __ LoadP(ip, MemOperand(base_addr, map_off_addr - key_off_addr)); |
| 64 __ CmpP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 65 __ CmpP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 65 __ bne(&miss, Label::kNear); | 66 __ bne(&miss, Label::kNear); |
| 66 | 67 |
| 67 // Get the code entry from the cache. | 68 // Get the code entry from the cache. |
| 68 Register code = scratch2; | 69 Register code = scratch2; |
| 69 scratch2 = no_reg; | 70 scratch2 = no_reg; |
| 70 __ LoadP(code, MemOperand(base_addr, value_off_addr - key_off_addr)); | 71 __ LoadP(code, MemOperand(base_addr, value_off_addr - key_off_addr)); |
| 71 | 72 |
| 72 #ifdef DEBUG | |
| 73 // Check that the flags match what we're looking for. | 73 // Check that the flags match what we're looking for. |
| 74 Code::Flags flags = Code::RemoveHolderFromFlags( | |
| 75 Code::ComputeHandlerFlags(stub_cache->ic_kind())); | |
| 76 Register flags_reg = base_addr; | 74 Register flags_reg = base_addr; |
| 77 base_addr = no_reg; | 75 base_addr = no_reg; |
| 78 __ LoadlW(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); | 76 __ LoadlW(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); |
| 79 | 77 |
| 80 DCHECK(!r0.is(flags_reg)); | 78 DCHECK(!r0.is(flags_reg)); |
| 81 __ AndP(flags_reg, flags_reg, Operand(~Code::kFlagsNotUsedInLookup)); | 79 __ AndP(flags_reg, flags_reg, Operand(~Code::kFlagsNotUsedInLookup)); |
| 82 __ CmpLogicalP(flags_reg, Operand(flags)); | 80 __ CmpLogicalP(flags_reg, Operand(flags)); |
| 83 __ Check(eq, kUnexpectedValue); | 81 __ bne(&miss, Label::kNear); |
| 84 | 82 |
| 83 #ifdef DEBUG |
| 85 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 84 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
| 86 __ b(&miss, Label::kNear); | 85 __ b(&miss, Label::kNear); |
| 87 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 86 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
| 88 __ b(&miss, Label::kNear); | 87 __ b(&miss, Label::kNear); |
| 89 } | 88 } |
| 90 #endif | 89 #endif |
| 91 | 90 |
| 92 // Jump to the first instruction in the code stub. | 91 // Jump to the first instruction in the code stub. |
| 93 // TODO(joransiu): Combine into indirect branch | 92 // TODO(joransiu): Combine into indirect branch |
| 94 __ la(code, MemOperand(code, Code::kHeaderSize - kHeapObjectTag)); | 93 __ la(code, MemOperand(code, Code::kHeaderSize - kHeapObjectTag)); |
| 95 __ b(code); | 94 __ b(code); |
| 96 | 95 |
| 97 // Miss: fall through. | 96 // Miss: fall through. |
| 98 __ bind(&miss); | 97 __ bind(&miss); |
| 99 } | 98 } |
| 100 | 99 |
| 101 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, | 100 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, |
| 102 Register name, Register scratch, Register extra, | 101 Register name, Register scratch, Register extra, |
| 103 Register extra2, Register extra3) { | 102 Register extra2, Register extra3) { |
| 103 Code::Flags flags = |
| 104 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_)); |
| 105 |
| 104 Label miss; | 106 Label miss; |
| 105 | 107 |
| 106 #if V8_TARGET_ARCH_S390X | 108 #if V8_TARGET_ARCH_S390X |
| 107 // Make sure that code is valid. The multiplying code relies on the | 109 // Make sure that code is valid. The multiplying code relies on the |
| 108 // entry size being 24. | 110 // entry size being 24. |
| 109 DCHECK(sizeof(Entry) == 24); | 111 DCHECK(sizeof(Entry) == 24); |
| 110 #else | 112 #else |
| 111 // Make sure that code is valid. The multiplying code relies on the | 113 // Make sure that code is valid. The multiplying code relies on the |
| 112 // entry size being 12. | 114 // entry size being 12. |
| 113 DCHECK(sizeof(Entry) == 12); | 115 DCHECK(sizeof(Entry) == 12); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 144 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, | 146 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, |
| 145 extra3); | 147 extra3); |
| 146 | 148 |
| 147 // Check that the receiver isn't a smi. | 149 // Check that the receiver isn't a smi. |
| 148 __ JumpIfSmi(receiver, &miss); | 150 __ JumpIfSmi(receiver, &miss); |
| 149 | 151 |
| 150 // Get the map of the receiver and compute the hash. | 152 // Get the map of the receiver and compute the hash. |
| 151 __ LoadlW(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); | 153 __ LoadlW(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); |
| 152 __ LoadP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 154 __ LoadP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 153 __ AddP(scratch, scratch, ip); | 155 __ AddP(scratch, scratch, ip); |
| 156 __ XorP(scratch, scratch, Operand(flags)); |
| 154 // The mask omits the last two bits because they are not part of the hash. | 157 // The mask omits the last two bits because they are not part of the hash. |
| 155 __ AndP(scratch, scratch, | 158 __ AndP(scratch, scratch, |
| 156 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); | 159 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); |
| 157 | 160 |
| 158 // Probe the primary table. | 161 // Probe the primary table. |
| 159 ProbeTable(this, masm, kPrimary, receiver, name, scratch, extra, extra2, | 162 ProbeTable(this, masm, flags, kPrimary, receiver, name, scratch, extra, |
| 160 extra3); | 163 extra2, extra3); |
| 161 | 164 |
| 162 // Primary miss: Compute hash for secondary probe. | 165 // Primary miss: Compute hash for secondary probe. |
| 163 __ SubP(scratch, scratch, name); | 166 __ SubP(scratch, scratch, name); |
| 167 __ AddP(scratch, scratch, Operand(flags)); |
| 164 __ AndP(scratch, scratch, | 168 __ AndP(scratch, scratch, |
| 165 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); | 169 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); |
| 166 | 170 |
| 167 // Probe the secondary table. | 171 // Probe the secondary table. |
| 168 ProbeTable(this, masm, kSecondary, receiver, name, scratch, extra, extra2, | 172 ProbeTable(this, masm, flags, kSecondary, receiver, name, scratch, extra, |
| 169 extra3); | 173 extra2, extra3); |
| 170 | 174 |
| 171 // Cache miss: Fall-through and let caller handle the miss by | 175 // Cache miss: Fall-through and let caller handle the miss by |
| 172 // entering the runtime system. | 176 // entering the runtime system. |
| 173 __ bind(&miss); | 177 __ bind(&miss); |
| 174 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 178 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
| 175 extra3); | 179 extra3); |
| 176 } | 180 } |
| 177 | 181 |
| 178 #undef __ | 182 #undef __ |
| 179 } // namespace internal | 183 } // namespace internal |
| 180 } // namespace v8 | 184 } // namespace v8 |
| 181 | 185 |
| 182 #endif // V8_TARGET_ARCH_S390 | 186 #endif // V8_TARGET_ARCH_S390 |
| OLD | NEW |