| 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_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 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 | |
| 18 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, | 17 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, |
| 19 Code::Kind ic_kind, Code::Flags flags, | 18 Code::Flags flags, StubCache::Table table, |
| 20 StubCache::Table table, Register receiver, Register name, | 19 Register receiver, Register name, |
| 21 // The offset is scaled by 4, based on | 20 // The offset is scaled by 4, based on |
| 22 // kCacheIndexShift, which is two bits | 21 // kCacheIndexShift, which is two bits |
| 23 Register offset) { | 22 Register offset) { |
| 24 // We need to scale up the pointer by 2 when the offset is scaled by less | 23 // We need to scale up the pointer by 2 when the offset is scaled by less |
| 25 // than the pointer size. | 24 // than the pointer size. |
| 26 DCHECK(kPointerSize == kInt64Size | 25 DCHECK(kPointerSize == kInt64Size |
| 27 ? kPointerSizeLog2 == StubCache::kCacheIndexShift + 1 | 26 ? kPointerSizeLog2 == StubCache::kCacheIndexShift + 1 |
| 28 : kPointerSizeLog2 == StubCache::kCacheIndexShift); | 27 : kPointerSizeLog2 == StubCache::kCacheIndexShift); |
| 29 ScaleFactor scale_factor = kPointerSize == kInt64Size ? times_2 : times_1; | 28 ScaleFactor scale_factor = kPointerSize == kInt64Size ? times_2 : times_1; |
| 30 | 29 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // Get the map of the receiver and compute the hash. | 128 // Get the map of the receiver and compute the hash. |
| 130 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); | 129 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); |
| 131 // Use only the low 32 bits of the map pointer. | 130 // Use only the low 32 bits of the map pointer. |
| 132 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | 131 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); |
| 133 __ xorp(scratch, Immediate(flags)); | 132 __ xorp(scratch, Immediate(flags)); |
| 134 // We mask out the last two bits because they are not part of the hash and | 133 // We mask out the last two bits because they are not part of the hash and |
| 135 // they are always 01 for maps. Also in the two 'and' instructions below. | 134 // they are always 01 for maps. Also in the two 'and' instructions below. |
| 136 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); | 135 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); |
| 137 | 136 |
| 138 // Probe the primary table. | 137 // Probe the primary table. |
| 139 ProbeTable(isolate, masm, ic_kind, flags, kPrimary, receiver, name, scratch); | 138 ProbeTable(isolate, masm, flags, kPrimary, receiver, name, scratch); |
| 140 | 139 |
| 141 // Primary miss: Compute hash for secondary probe. | 140 // Primary miss: Compute hash for secondary probe. |
| 142 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); | 141 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); |
| 143 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | 142 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); |
| 144 __ xorp(scratch, Immediate(flags)); | 143 __ xorp(scratch, Immediate(flags)); |
| 145 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); | 144 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); |
| 146 __ subl(scratch, name); | 145 __ subl(scratch, name); |
| 147 __ addl(scratch, Immediate(flags)); | 146 __ addl(scratch, Immediate(flags)); |
| 148 __ andp(scratch, Immediate((kSecondaryTableSize - 1) << kCacheIndexShift)); | 147 __ andp(scratch, Immediate((kSecondaryTableSize - 1) << kCacheIndexShift)); |
| 149 | 148 |
| 150 // Probe the secondary table. | 149 // Probe the secondary table. |
| 151 ProbeTable(isolate, masm, ic_kind, flags, kSecondary, receiver, name, | 150 ProbeTable(isolate, masm, flags, kSecondary, receiver, name, scratch); |
| 152 scratch); | |
| 153 | 151 |
| 154 // Cache miss: Fall-through and let caller handle the miss by | 152 // Cache miss: Fall-through and let caller handle the miss by |
| 155 // entering the runtime system. | 153 // entering the runtime system. |
| 156 __ bind(&miss); | 154 __ bind(&miss); |
| 157 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); | 155 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); |
| 158 } | 156 } |
| 159 | 157 |
| 160 | 158 |
| 161 #undef __ | 159 #undef __ |
| 162 } // namespace internal | 160 } // namespace internal |
| 163 } // namespace v8 | 161 } // namespace v8 |
| 164 | 162 |
| 165 #endif // V8_TARGET_ARCH_X64 | 163 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |