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_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/ic/stub-cache.h" | 10 #include "src/ic/stub-cache.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::Flags flags, StubCache::Table table, | 19 Code::Flags flags, bool leave_frame, |
20 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; |
30 | 30 |
(...skipping 34 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 |
75 // Jump to the first instruction in the code stub. | 77 // Jump to the first instruction in the code stub. |
76 __ addp(kScratchRegister, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 78 __ addp(kScratchRegister, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
77 __ jmp(kScratchRegister); | 79 __ jmp(kScratchRegister); |
78 | 80 |
79 __ bind(&miss); | 81 __ bind(&miss); |
80 } | 82 } |
81 | 83 |
82 | 84 |
83 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Flags flags, | 85 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Flags flags, |
84 Register receiver, Register name, | 86 bool leave_frame, Register receiver, |
85 Register scratch, Register extra, Register extra2, | 87 Register name, Register scratch, Register extra, |
86 Register extra3) { | 88 Register extra2, Register extra3) { |
87 Isolate* isolate = masm->isolate(); | 89 Isolate* isolate = masm->isolate(); |
88 Label miss; | 90 Label miss; |
89 USE(extra); // The register extra is not used on the X64 platform. | 91 USE(extra); // The register extra is not used on the X64 platform. |
90 USE(extra2); // The register extra2 is not used on the X64 platform. | 92 USE(extra2); // The register extra2 is not used on the X64 platform. |
91 USE(extra3); // The register extra2 is not used on the X64 platform. | 93 USE(extra3); // The register extra2 is not used on the X64 platform. |
92 // Make sure that code is valid. The multiplying code relies on the | 94 // Make sure that code is valid. The multiplying code relies on the |
93 // entry size being 3 * kPointerSize. | 95 // entry size being 3 * kPointerSize. |
94 DCHECK(sizeof(Entry) == 3 * kPointerSize); | 96 DCHECK(sizeof(Entry) == 3 * kPointerSize); |
95 | 97 |
96 // Make sure the flags do not name a specific type. | 98 // Make sure the flags do not name a specific type. |
(...skipping 17 matching lines...) Expand all Loading... |
114 // Get the map of the receiver and compute the hash. | 116 // Get the map of the receiver and compute the hash. |
115 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); | 117 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); |
116 // Use only the low 32 bits of the map pointer. | 118 // Use only the low 32 bits of the map pointer. |
117 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | 119 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); |
118 __ xorp(scratch, Immediate(flags)); | 120 __ xorp(scratch, Immediate(flags)); |
119 // We mask out the last two bits because they are not part of the hash and | 121 // We mask out the last two bits because they are not part of the hash and |
120 // they are always 01 for maps. Also in the two 'and' instructions below. | 122 // they are always 01 for maps. Also in the two 'and' instructions below. |
121 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); | 123 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); |
122 | 124 |
123 // Probe the primary table. | 125 // Probe the primary table. |
124 ProbeTable(isolate, masm, flags, kPrimary, receiver, name, scratch); | 126 ProbeTable(isolate, masm, flags, leave_frame, kPrimary, receiver, name, |
| 127 scratch); |
125 | 128 |
126 // Primary miss: Compute hash for secondary probe. | 129 // Primary miss: Compute hash for secondary probe. |
127 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); | 130 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); |
128 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | 131 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); |
129 __ xorp(scratch, Immediate(flags)); | 132 __ xorp(scratch, Immediate(flags)); |
130 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); | 133 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); |
131 __ subl(scratch, name); | 134 __ subl(scratch, name); |
132 __ addl(scratch, Immediate(flags)); | 135 __ addl(scratch, Immediate(flags)); |
133 __ andp(scratch, Immediate((kSecondaryTableSize - 1) << kCacheIndexShift)); | 136 __ andp(scratch, Immediate((kSecondaryTableSize - 1) << kCacheIndexShift)); |
134 | 137 |
135 // Probe the secondary table. | 138 // Probe the secondary table. |
136 ProbeTable(isolate, masm, flags, kSecondary, receiver, name, scratch); | 139 ProbeTable(isolate, masm, flags, leave_frame, kSecondary, receiver, name, |
| 140 scratch); |
137 | 141 |
138 // Cache miss: Fall-through and let caller handle the miss by | 142 // Cache miss: Fall-through and let caller handle the miss by |
139 // entering the runtime system. | 143 // entering the runtime system. |
140 __ bind(&miss); | 144 __ bind(&miss); |
141 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); | 145 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); |
142 } | 146 } |
143 | 147 |
144 | 148 |
145 #undef __ | 149 #undef __ |
146 } | 150 } |
147 } // namespace v8::internal | 151 } // namespace v8::internal |
148 | 152 |
149 #endif // V8_TARGET_ARCH_X64 | 153 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |