| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_ARM | 7 #if V8_TARGET_ARCH_ARM |
| 8 | 8 |
| 9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
| 10 #include "src/ic/ic.h" |
| 10 #include "src/ic/stub-cache.h" | 11 #include "src/ic/stub-cache.h" |
| 12 #include "src/interface-descriptors.h" |
| 11 | 13 |
| 12 namespace v8 { | 14 namespace v8 { |
| 13 namespace internal { | 15 namespace internal { |
| 14 | 16 |
| 15 #define __ ACCESS_MASM(masm) | 17 #define __ ACCESS_MASM(masm) |
| 16 | 18 |
| 17 | 19 |
| 18 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, | 20 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, |
| 19 Code::Flags flags, bool leave_frame, | 21 Code::Kind ic_kind, Code::Flags flags, bool leave_frame, |
| 20 StubCache::Table table, Register receiver, Register name, | 22 StubCache::Table table, Register receiver, Register name, |
| 21 // Number of the cache entry, not scaled. | 23 // Number of the cache entry, not scaled. |
| 22 Register offset, Register scratch, Register scratch2, | 24 Register offset, Register scratch, Register scratch2, |
| 23 Register offset_scratch) { | 25 Register offset_scratch) { |
| 24 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); | 26 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); |
| 25 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); | 27 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); |
| 26 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); | 28 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); |
| 27 | 29 |
| 28 uint32_t key_off_addr = reinterpret_cast<uint32_t>(key_offset.address()); | 30 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()); | 31 uint32_t value_off_addr = reinterpret_cast<uint32_t>(value_offset.address()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 if (leave_frame) __ LeaveFrame(StackFrame::INTERNAL); | 89 if (leave_frame) __ LeaveFrame(StackFrame::INTERNAL); |
| 88 | 90 |
| 89 // Jump to the first instruction in the code stub. | 91 // Jump to the first instruction in the code stub. |
| 90 __ add(pc, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 92 __ add(pc, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 91 | 93 |
| 92 // Miss: fall through. | 94 // Miss: fall through. |
| 93 __ bind(&miss); | 95 __ bind(&miss); |
| 94 } | 96 } |
| 95 | 97 |
| 96 | 98 |
| 97 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Flags flags, | 99 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind, |
| 98 bool leave_frame, Register receiver, | 100 Code::Flags flags, bool leave_frame, |
| 99 Register name, Register scratch, Register extra, | 101 Register receiver, Register name, |
| 100 Register extra2, Register extra3) { | 102 Register scratch, Register extra, Register extra2, |
| 103 Register extra3) { |
| 101 Isolate* isolate = masm->isolate(); | 104 Isolate* isolate = masm->isolate(); |
| 102 Label miss; | 105 Label miss; |
| 103 | 106 |
| 104 // Make sure that code is valid. The multiplying code relies on the | 107 // Make sure that code is valid. The multiplying code relies on the |
| 105 // entry size being 12. | 108 // entry size being 12. |
| 106 DCHECK(sizeof(Entry) == 12); | 109 DCHECK(sizeof(Entry) == 12); |
| 107 | 110 |
| 108 // Make sure the flags does not name a specific type. | 111 // Make sure the flags does not name a specific type. |
| 109 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); | 112 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); |
| 110 | 113 |
| 111 // Make sure that there are no register conflicts. | 114 // Make sure that there are no register conflicts. |
| 112 DCHECK(!scratch.is(receiver)); | 115 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); |
| 113 DCHECK(!scratch.is(name)); | |
| 114 DCHECK(!extra.is(receiver)); | |
| 115 DCHECK(!extra.is(name)); | |
| 116 DCHECK(!extra.is(scratch)); | |
| 117 DCHECK(!extra2.is(receiver)); | |
| 118 DCHECK(!extra2.is(name)); | |
| 119 DCHECK(!extra2.is(scratch)); | |
| 120 DCHECK(!extra2.is(extra)); | |
| 121 | 116 |
| 122 // Check scratch, extra and extra2 registers are valid. | 117 // Check scratch, extra and extra2 registers are valid. |
| 123 DCHECK(!scratch.is(no_reg)); | 118 DCHECK(!scratch.is(no_reg)); |
| 124 DCHECK(!extra.is(no_reg)); | 119 DCHECK(!extra.is(no_reg)); |
| 125 DCHECK(!extra2.is(no_reg)); | 120 DCHECK(!extra2.is(no_reg)); |
| 126 DCHECK(!extra3.is(no_reg)); | 121 DCHECK(!extra3.is(no_reg)); |
| 127 | 122 |
| 123 #ifdef DEBUG |
| 124 // If vector-based ics are in use, ensure that scratch, extra, extra2 and |
| 125 // extra3 don't conflict with the vector and slot registers, which need |
| 126 // to be preserved for a handler call or miss. |
| 127 if (IC::ICUseVector(ic_kind)) { |
| 128 Register vector = VectorLoadICDescriptor::VectorRegister(); |
| 129 Register slot = VectorLoadICDescriptor::SlotRegister(); |
| 130 DCHECK(!AreAliased(vector, slot, scratch, extra, extra2, extra3)); |
| 131 } |
| 132 #endif |
| 133 |
| 128 Counters* counters = masm->isolate()->counters(); | 134 Counters* counters = masm->isolate()->counters(); |
| 129 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, | 135 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, |
| 130 extra3); | 136 extra3); |
| 131 | 137 |
| 132 // Check that the receiver isn't a smi. | 138 // Check that the receiver isn't a smi. |
| 133 __ JumpIfSmi(receiver, &miss); | 139 __ JumpIfSmi(receiver, &miss); |
| 134 | 140 |
| 135 // Get the map of the receiver and compute the hash. | 141 // Get the map of the receiver and compute the hash. |
| 136 __ ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); | 142 __ ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); |
| 137 __ ldr(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 143 __ ldr(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 138 __ add(scratch, scratch, Operand(ip)); | 144 __ add(scratch, scratch, Operand(ip)); |
| 139 uint32_t mask = kPrimaryTableSize - 1; | 145 uint32_t mask = kPrimaryTableSize - 1; |
| 140 // We shift out the last two bits because they are not part of the hash and | 146 // We shift out the last two bits because they are not part of the hash and |
| 141 // they are always 01 for maps. | 147 // they are always 01 for maps. |
| 142 __ mov(scratch, Operand(scratch, LSR, kCacheIndexShift)); | 148 __ mov(scratch, Operand(scratch, LSR, kCacheIndexShift)); |
| 143 // Mask down the eor argument to the minimum to keep the immediate | 149 // Mask down the eor argument to the minimum to keep the immediate |
| 144 // ARM-encodable. | 150 // ARM-encodable. |
| 145 __ eor(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask)); | 151 __ eor(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask)); |
| 146 // Prefer and_ to ubfx here because ubfx takes 2 cycles. | 152 // Prefer and_ to ubfx here because ubfx takes 2 cycles. |
| 147 __ and_(scratch, scratch, Operand(mask)); | 153 __ and_(scratch, scratch, Operand(mask)); |
| 148 | 154 |
| 149 // Probe the primary table. | 155 // Probe the primary table. |
| 150 ProbeTable(isolate, masm, flags, leave_frame, kPrimary, receiver, name, | 156 ProbeTable(isolate, masm, ic_kind, flags, leave_frame, kPrimary, receiver, |
| 151 scratch, extra, extra2, extra3); | 157 name, scratch, extra, extra2, extra3); |
| 152 | 158 |
| 153 // Primary miss: Compute hash for secondary probe. | 159 // Primary miss: Compute hash for secondary probe. |
| 154 __ sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift)); | 160 __ sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift)); |
| 155 uint32_t mask2 = kSecondaryTableSize - 1; | 161 uint32_t mask2 = kSecondaryTableSize - 1; |
| 156 __ add(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask2)); | 162 __ add(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask2)); |
| 157 __ and_(scratch, scratch, Operand(mask2)); | 163 __ and_(scratch, scratch, Operand(mask2)); |
| 158 | 164 |
| 159 // Probe the secondary table. | 165 // Probe the secondary table. |
| 160 ProbeTable(isolate, masm, flags, leave_frame, kSecondary, receiver, name, | 166 ProbeTable(isolate, masm, ic_kind, flags, leave_frame, kSecondary, receiver, |
| 161 scratch, extra, extra2, extra3); | 167 name, scratch, extra, extra2, extra3); |
| 162 | 168 |
| 163 // Cache miss: Fall-through and let caller handle the miss by | 169 // Cache miss: Fall-through and let caller handle the miss by |
| 164 // entering the runtime system. | 170 // entering the runtime system. |
| 165 __ bind(&miss); | 171 __ bind(&miss); |
| 166 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 172 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
| 167 extra3); | 173 extra3); |
| 168 } | 174 } |
| 169 | 175 |
| 170 | 176 |
| 171 #undef __ | 177 #undef __ |
| 172 } | 178 } |
| 173 } // namespace v8::internal | 179 } // namespace v8::internal |
| 174 | 180 |
| 175 #endif // V8_TARGET_ARCH_ARM | 181 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |