| 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 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 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 static void ProbeTable(StubCache* stub_cache, MacroAssembler* masm, |
| 18 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, | |
| 19 Code::Kind ic_kind, Code::Flags flags, | 18 Code::Kind ic_kind, Code::Flags flags, |
| 20 StubCache::Table table, Register name, Register receiver, | 19 StubCache::Table table, Register name, Register receiver, |
| 21 // Number of the cache entry pointer-size scaled. | 20 // Number of the cache entry pointer-size scaled. |
| 22 Register offset, Register extra) { | 21 Register offset, Register extra) { |
| 23 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); | 22 ExternalReference key_offset(stub_cache->key_reference(table)); |
| 24 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); | 23 ExternalReference value_offset(stub_cache->value_reference(table)); |
| 25 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); | 24 ExternalReference map_offset(stub_cache->map_reference(table)); |
| 26 ExternalReference virtual_register = | 25 ExternalReference virtual_register = |
| 27 ExternalReference::virtual_handler_register(masm->isolate()); | 26 ExternalReference::virtual_handler_register(masm->isolate()); |
| 28 | 27 |
| 29 Label miss; | 28 Label miss; |
| 30 bool is_vector_store = | 29 bool is_vector_store = |
| 31 IC::ICUseVector(ic_kind) && | 30 IC::ICUseVector(ic_kind) && |
| 32 (ic_kind == Code::STORE_IC || ic_kind == Code::KEYED_STORE_IC); | 31 (ic_kind == Code::STORE_IC || ic_kind == Code::KEYED_STORE_IC); |
| 33 | 32 |
| 34 // Multiply by 3 because there are 3 fields per entry (name, code, map). | 33 // Multiply by 3 because there are 3 fields per entry (name, code, map). |
| 35 __ lea(offset, Operand(offset, offset, times_2, 0)); | 34 __ lea(offset, Operand(offset, offset, times_2, 0)); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 __ add(offset, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 134 __ add(offset, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
| 136 __ jmp(offset); | 135 __ jmp(offset); |
| 137 } | 136 } |
| 138 | 137 |
| 139 // Pop at miss. | 138 // Pop at miss. |
| 140 __ bind(&miss); | 139 __ bind(&miss); |
| 141 __ pop(offset); | 140 __ pop(offset); |
| 142 } | 141 } |
| 143 } | 142 } |
| 144 | 143 |
| 145 | 144 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, |
| 146 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind, | |
| 147 Code::Flags flags, Register receiver, | |
| 148 Register name, Register scratch, Register extra, | 145 Register name, Register scratch, Register extra, |
| 149 Register extra2, Register extra3) { | 146 Register extra2, Register extra3) { |
| 147 Code::Flags flags = |
| 148 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_)); |
| 149 |
| 150 Label miss; | 150 Label miss; |
| 151 | 151 |
| 152 // Assert that code is valid. The multiplying code relies on the entry size | 152 // Assert that code is valid. The multiplying code relies on the entry size |
| 153 // being 12. | 153 // being 12. |
| 154 DCHECK(sizeof(Entry) == 12); | 154 DCHECK(sizeof(Entry) == 12); |
| 155 | 155 |
| 156 // Assert that there are no register conflicts. | 156 // Assert that there are no register conflicts. |
| 157 DCHECK(!scratch.is(receiver)); | 157 DCHECK(!scratch.is(receiver)); |
| 158 DCHECK(!scratch.is(name)); | 158 DCHECK(!scratch.is(name)); |
| 159 DCHECK(!extra.is(receiver)); | 159 DCHECK(!extra.is(receiver)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 179 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset)); | 179 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset)); |
| 180 __ xor_(offset, flags); | 180 __ xor_(offset, flags); |
| 181 // We mask out the last two bits because they are not part of the hash and | 181 // We mask out the last two bits because they are not part of the hash and |
| 182 // they are always 01 for maps. Also in the two 'and' instructions below. | 182 // they are always 01 for maps. Also in the two 'and' instructions below. |
| 183 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift); | 183 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift); |
| 184 // ProbeTable expects the offset to be pointer scaled, which it is, because | 184 // ProbeTable expects the offset to be pointer scaled, which it is, because |
| 185 // the heap object tag size is 2 and the pointer size log 2 is also 2. | 185 // the heap object tag size is 2 and the pointer size log 2 is also 2. |
| 186 DCHECK(kCacheIndexShift == kPointerSizeLog2); | 186 DCHECK(kCacheIndexShift == kPointerSizeLog2); |
| 187 | 187 |
| 188 // Probe the primary table. | 188 // Probe the primary table. |
| 189 ProbeTable(isolate(), masm, ic_kind, flags, kPrimary, name, receiver, offset, | 189 ProbeTable(this, masm, ic_kind_, flags, kPrimary, name, receiver, offset, |
| 190 extra); | 190 extra); |
| 191 | 191 |
| 192 // Primary miss: Compute hash for secondary probe. | 192 // Primary miss: Compute hash for secondary probe. |
| 193 __ mov(offset, FieldOperand(name, Name::kHashFieldOffset)); | 193 __ mov(offset, FieldOperand(name, Name::kHashFieldOffset)); |
| 194 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset)); | 194 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset)); |
| 195 __ xor_(offset, flags); | 195 __ xor_(offset, flags); |
| 196 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift); | 196 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift); |
| 197 __ sub(offset, name); | 197 __ sub(offset, name); |
| 198 __ add(offset, Immediate(flags)); | 198 __ add(offset, Immediate(flags)); |
| 199 __ and_(offset, (kSecondaryTableSize - 1) << kCacheIndexShift); | 199 __ and_(offset, (kSecondaryTableSize - 1) << kCacheIndexShift); |
| 200 | 200 |
| 201 // Probe the secondary table. | 201 // Probe the secondary table. |
| 202 ProbeTable(isolate(), masm, ic_kind, flags, kSecondary, name, receiver, | 202 ProbeTable(this, masm, ic_kind_, flags, kSecondary, name, receiver, offset, |
| 203 offset, extra); | 203 extra); |
| 204 | 204 |
| 205 // Cache miss: Fall-through and let caller handle the miss by | 205 // Cache miss: Fall-through and let caller handle the miss by |
| 206 // entering the runtime system. | 206 // entering the runtime system. |
| 207 __ bind(&miss); | 207 __ bind(&miss); |
| 208 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); | 208 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); |
| 209 } | 209 } |
| 210 | 210 |
| 211 | 211 |
| 212 #undef __ | 212 #undef __ |
| 213 } // namespace internal | 213 } // namespace internal |
| 214 } // namespace v8 | 214 } // namespace v8 |
| 215 | 215 |
| 216 #endif // V8_TARGET_ARCH_X87 | 216 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |