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 | 17 |
18 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, | 18 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, |
19 Code::Kind ic_kind, Code::Flags flags, bool leave_frame, | 19 Code::Kind ic_kind, Code::Flags flags, |
20 StubCache::Table table, Register receiver, Register name, | 20 StubCache::Table table, Register receiver, Register name, |
21 // The offset is scaled by 4, based on | 21 // The offset is scaled by 4, based on |
22 // kCacheIndexShift, which is two bits | 22 // kCacheIndexShift, which is two bits |
23 Register offset) { | 23 Register offset) { |
24 // We need to scale up the pointer by 2 when the offset is scaled by less | 24 // We need to scale up the pointer by 2 when the offset is scaled by less |
25 // than the pointer size. | 25 // than the pointer size. |
26 DCHECK(kPointerSize == kInt64Size | 26 DCHECK(kPointerSize == kInt64Size |
27 ? kPointerSizeLog2 == StubCache::kCacheIndexShift + 1 | 27 ? kPointerSizeLog2 == StubCache::kCacheIndexShift + 1 |
28 : kPointerSizeLog2 == StubCache::kCacheIndexShift); | 28 : kPointerSizeLog2 == StubCache::kCacheIndexShift); |
29 ScaleFactor scale_factor = kPointerSize == kInt64Size ? times_2 : times_1; | 29 ScaleFactor scale_factor = kPointerSize == kInt64Size ? times_2 : times_1; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 __ j(not_equal, &miss); | 65 __ j(not_equal, &miss); |
66 | 66 |
67 #ifdef DEBUG | 67 #ifdef DEBUG |
68 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 68 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
69 __ jmp(&miss); | 69 __ jmp(&miss); |
70 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 70 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
71 __ jmp(&miss); | 71 __ jmp(&miss); |
72 } | 72 } |
73 #endif | 73 #endif |
74 | 74 |
75 if (leave_frame) __ leave(); | |
76 | |
77 // Jump to the first instruction in the code stub. | 75 // Jump to the first instruction in the code stub. |
78 __ addp(kScratchRegister, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 76 __ addp(kScratchRegister, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
79 __ jmp(kScratchRegister); | 77 __ jmp(kScratchRegister); |
80 | 78 |
81 __ bind(&miss); | 79 __ bind(&miss); |
82 } | 80 } |
83 | 81 |
84 | 82 |
85 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind, | 83 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind, |
86 Code::Flags flags, bool leave_frame, | 84 Code::Flags flags, Register receiver, |
87 Register receiver, Register name, | 85 Register name, Register scratch, Register extra, |
88 Register scratch, Register extra, Register extra2, | 86 Register extra2, Register extra3) { |
89 Register extra3) { | |
90 Isolate* isolate = masm->isolate(); | 87 Isolate* isolate = masm->isolate(); |
91 Label miss; | 88 Label miss; |
92 USE(extra); // The register extra is not used on the X64 platform. | 89 USE(extra); // The register extra is not used on the X64 platform. |
93 USE(extra2); // The register extra2 is not used on the X64 platform. | 90 USE(extra2); // The register extra2 is not used on the X64 platform. |
94 USE(extra3); // The register extra2 is not used on the X64 platform. | 91 USE(extra3); // The register extra2 is not used on the X64 platform. |
95 // Make sure that code is valid. The multiplying code relies on the | 92 // Make sure that code is valid. The multiplying code relies on the |
96 // entry size being 3 * kPointerSize. | 93 // entry size being 3 * kPointerSize. |
97 DCHECK(sizeof(Entry) == 3 * kPointerSize); | 94 DCHECK(sizeof(Entry) == 3 * kPointerSize); |
98 | 95 |
99 // Make sure the flags do not name a specific type. | 96 // Make sure the flags do not name a specific type. |
(...skipping 28 matching lines...) Expand all Loading... |
128 // Get the map of the receiver and compute the hash. | 125 // Get the map of the receiver and compute the hash. |
129 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); | 126 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); |
130 // Use only the low 32 bits of the map pointer. | 127 // Use only the low 32 bits of the map pointer. |
131 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | 128 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); |
132 __ xorp(scratch, Immediate(flags)); | 129 __ xorp(scratch, Immediate(flags)); |
133 // We mask out the last two bits because they are not part of the hash and | 130 // We mask out the last two bits because they are not part of the hash and |
134 // they are always 01 for maps. Also in the two 'and' instructions below. | 131 // they are always 01 for maps. Also in the two 'and' instructions below. |
135 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); | 132 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); |
136 | 133 |
137 // Probe the primary table. | 134 // Probe the primary table. |
138 ProbeTable(isolate, masm, ic_kind, flags, leave_frame, kPrimary, receiver, | 135 ProbeTable(isolate, masm, ic_kind, flags, kPrimary, receiver, name, scratch); |
139 name, scratch); | |
140 | 136 |
141 // Primary miss: Compute hash for secondary probe. | 137 // Primary miss: Compute hash for secondary probe. |
142 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); | 138 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); |
143 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | 139 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); |
144 __ xorp(scratch, Immediate(flags)); | 140 __ xorp(scratch, Immediate(flags)); |
145 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); | 141 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); |
146 __ subl(scratch, name); | 142 __ subl(scratch, name); |
147 __ addl(scratch, Immediate(flags)); | 143 __ addl(scratch, Immediate(flags)); |
148 __ andp(scratch, Immediate((kSecondaryTableSize - 1) << kCacheIndexShift)); | 144 __ andp(scratch, Immediate((kSecondaryTableSize - 1) << kCacheIndexShift)); |
149 | 145 |
150 // Probe the secondary table. | 146 // Probe the secondary table. |
151 ProbeTable(isolate, masm, ic_kind, flags, leave_frame, kSecondary, receiver, | 147 ProbeTable(isolate, masm, ic_kind, flags, kSecondary, receiver, name, |
152 name, scratch); | 148 scratch); |
153 | 149 |
154 // Cache miss: Fall-through and let caller handle the miss by | 150 // Cache miss: Fall-through and let caller handle the miss by |
155 // entering the runtime system. | 151 // entering the runtime system. |
156 __ bind(&miss); | 152 __ bind(&miss); |
157 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); | 153 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); |
158 } | 154 } |
159 | 155 |
160 | 156 |
161 #undef __ | 157 #undef __ |
162 } // namespace internal | 158 } // namespace internal |
163 } // namespace v8 | 159 } // namespace v8 |
164 | 160 |
165 #endif // V8_TARGET_ARCH_X64 | 161 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |