| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
| 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 | 15 |
| 16 #define __ ACCESS_MASM(masm) | 16 #define __ ACCESS_MASM(masm) |
| 17 | 17 |
| 18 | 18 |
| 19 // Probe primary or secondary table. | 19 // Probe primary or secondary table. |
| 20 // If the entry is found in the cache, the generated code jump to the first | 20 // If the entry is found in the cache, the generated code jump to the first |
| 21 // instruction of the stub in the cache. | 21 // instruction of the stub in the cache. |
| 22 // If there is a miss the code fall trough. | 22 // If there is a miss the code fall trough. |
| 23 // | 23 // |
| 24 // 'receiver', 'name' and 'offset' registers are preserved on miss. | 24 // 'receiver', 'name' and 'offset' registers are preserved on miss. |
| 25 static void ProbeTable(StubCache* stub_cache, MacroAssembler* masm, | 25 static void ProbeTable(StubCache* stub_cache, MacroAssembler* masm, |
| 26 Code::Flags flags, StubCache::Table table, | 26 StubCache::Table table, Register receiver, Register name, |
| 27 Register receiver, Register name, | |
| 28 // The offset is scaled by 4, based on | 27 // The offset is scaled by 4, based on |
| 29 // kCacheIndexShift, which is two bits | 28 // kCacheIndexShift, which is two bits |
| 30 Register offset, Register scratch, Register scratch2, | 29 Register offset, Register scratch, Register scratch2, |
| 31 Register scratch3) { | 30 Register scratch3) { |
| 32 // Some code below relies on the fact that the Entry struct contains | 31 // Some code below relies on the fact that the Entry struct contains |
| 33 // 3 pointers (name, code, map). | 32 // 3 pointers (name, code, map). |
| 34 STATIC_ASSERT(sizeof(StubCache::Entry) == (3 * kPointerSize)); | 33 STATIC_ASSERT(sizeof(StubCache::Entry) == (3 * kPointerSize)); |
| 35 | 34 |
| 36 ExternalReference key_offset(stub_cache->key_reference(table)); | 35 ExternalReference key_offset(stub_cache->key_reference(table)); |
| 37 ExternalReference value_offset(stub_cache->value_reference(table)); | 36 ExternalReference value_offset(stub_cache->value_reference(table)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 62 | 61 |
| 63 // Check the map matches. | 62 // Check the map matches. |
| 64 __ Ldr(scratch2, MemOperand(scratch, map_off_addr - key_off_addr)); | 63 __ Ldr(scratch2, MemOperand(scratch, map_off_addr - key_off_addr)); |
| 65 __ Ldr(scratch3, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 64 __ Ldr(scratch3, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 66 __ Cmp(scratch2, scratch3); | 65 __ Cmp(scratch2, scratch3); |
| 67 __ B(ne, &miss); | 66 __ B(ne, &miss); |
| 68 | 67 |
| 69 // Get the code entry from the cache. | 68 // Get the code entry from the cache. |
| 70 __ Ldr(scratch, MemOperand(scratch, value_off_addr - key_off_addr)); | 69 __ Ldr(scratch, MemOperand(scratch, value_off_addr - key_off_addr)); |
| 71 | 70 |
| 72 // Check that the flags match what we're looking for. | |
| 73 __ Ldr(scratch2.W(), FieldMemOperand(scratch, Code::kFlagsOffset)); | |
| 74 __ Bic(scratch2.W(), scratch2.W(), Code::kFlagsNotUsedInLookup); | |
| 75 __ Cmp(scratch2.W(), flags); | |
| 76 __ B(ne, &miss); | |
| 77 | |
| 78 #ifdef DEBUG | 71 #ifdef DEBUG |
| 79 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 72 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
| 80 __ B(&miss); | 73 __ B(&miss); |
| 81 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 74 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
| 82 __ B(&miss); | 75 __ B(&miss); |
| 83 } | 76 } |
| 84 #endif | 77 #endif |
| 85 | 78 |
| 86 // Jump to the first instruction in the code stub. | 79 // Jump to the first instruction in the code stub. |
| 87 __ Add(scratch, scratch, Code::kHeaderSize - kHeapObjectTag); | 80 __ Add(scratch, scratch, Code::kHeaderSize - kHeapObjectTag); |
| 88 __ Br(scratch); | 81 __ Br(scratch); |
| 89 | 82 |
| 90 // Miss: fall through. | 83 // Miss: fall through. |
| 91 __ Bind(&miss); | 84 __ Bind(&miss); |
| 92 } | 85 } |
| 93 | 86 |
| 94 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, | 87 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, |
| 95 Register name, Register scratch, Register extra, | 88 Register name, Register scratch, Register extra, |
| 96 Register extra2, Register extra3) { | 89 Register extra2, Register extra3) { |
| 97 Code::Flags flags = | |
| 98 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_)); | |
| 99 | |
| 100 Label miss; | 90 Label miss; |
| 101 | 91 |
| 102 // Make sure that there are no register conflicts. | 92 // Make sure that there are no register conflicts. |
| 103 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); | 93 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); |
| 104 | 94 |
| 105 // Make sure extra and extra2 registers are valid. | 95 // Make sure extra and extra2 registers are valid. |
| 106 DCHECK(!extra.is(no_reg)); | 96 DCHECK(!extra.is(no_reg)); |
| 107 DCHECK(!extra2.is(no_reg)); | 97 DCHECK(!extra2.is(no_reg)); |
| 108 DCHECK(!extra3.is(no_reg)); | 98 DCHECK(!extra3.is(no_reg)); |
| 109 | 99 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 129 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, | 119 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, |
| 130 extra3); | 120 extra3); |
| 131 | 121 |
| 132 // Check that the receiver isn't a smi. | 122 // Check that the receiver isn't a smi. |
| 133 __ JumpIfSmi(receiver, &miss); | 123 __ JumpIfSmi(receiver, &miss); |
| 134 | 124 |
| 135 // Compute the hash for primary table. | 125 // Compute the hash for primary table. |
| 136 __ Ldr(scratch.W(), FieldMemOperand(name, Name::kHashFieldOffset)); | 126 __ Ldr(scratch.W(), FieldMemOperand(name, Name::kHashFieldOffset)); |
| 137 __ Ldr(extra, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 127 __ Ldr(extra, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 138 __ Add(scratch, scratch, extra); | 128 __ Add(scratch, scratch, extra); |
| 139 __ Eor(scratch, scratch, flags); | 129 __ Eor(scratch, scratch, kPrimaryMagic); |
| 140 __ And(scratch, scratch, | 130 __ And(scratch, scratch, |
| 141 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); | 131 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); |
| 142 | 132 |
| 143 // Probe the primary table. | 133 // Probe the primary table. |
| 144 ProbeTable(this, masm, flags, kPrimary, receiver, name, scratch, extra, | 134 ProbeTable(this, masm, kPrimary, receiver, name, scratch, extra, extra2, |
| 145 extra2, extra3); | 135 extra3); |
| 146 | 136 |
| 147 // Primary miss: Compute hash for secondary table. | 137 // Primary miss: Compute hash for secondary table. |
| 148 __ Sub(scratch, scratch, Operand(name)); | 138 __ Sub(scratch, scratch, Operand(name)); |
| 149 __ Add(scratch, scratch, Operand(flags)); | 139 __ Add(scratch, scratch, Operand(kSecondaryMagic)); |
| 150 __ And(scratch, scratch, | 140 __ And(scratch, scratch, |
| 151 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); | 141 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); |
| 152 | 142 |
| 153 // Probe the secondary table. | 143 // Probe the secondary table. |
| 154 ProbeTable(this, masm, flags, kSecondary, receiver, name, scratch, extra, | 144 ProbeTable(this, masm, kSecondary, receiver, name, scratch, extra, extra2, |
| 155 extra2, extra3); | 145 extra3); |
| 156 | 146 |
| 157 // Cache miss: Fall-through and let caller handle the miss by | 147 // Cache miss: Fall-through and let caller handle the miss by |
| 158 // entering the runtime system. | 148 // entering the runtime system. |
| 159 __ Bind(&miss); | 149 __ Bind(&miss); |
| 160 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 150 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
| 161 extra3); | 151 extra3); |
| 162 } | 152 } |
| 163 } // namespace internal | 153 } // namespace internal |
| 164 } // namespace v8 | 154 } // namespace v8 |
| 165 | 155 |
| 166 #endif // V8_TARGET_ARCH_ARM64 | 156 #endif // V8_TARGET_ARCH_ARM64 |
| OLD | NEW |