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_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
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 // Number of the cache entry, not scaled. | 21 // Number of the cache entry, not scaled. |
22 Register offset, Register scratch, Register scratch2, | 22 Register offset, Register scratch, Register scratch2, |
23 Register offset_scratch) { | 23 Register offset_scratch) { |
24 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); | 24 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); |
25 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); | 25 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); |
26 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); | 26 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); |
27 | 27 |
28 uint64_t key_off_addr = reinterpret_cast<uint64_t>(key_offset.address()); | 28 uint64_t key_off_addr = reinterpret_cast<uint64_t>(key_offset.address()); |
29 uint64_t value_off_addr = reinterpret_cast<uint64_t>(value_offset.address()); | 29 uint64_t value_off_addr = reinterpret_cast<uint64_t>(value_offset.address()); |
30 uint64_t map_off_addr = reinterpret_cast<uint64_t>(map_offset.address()); | 30 uint64_t map_off_addr = reinterpret_cast<uint64_t>(map_offset.address()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 __ Branch(&miss, ne, flags_reg, Operand(flags)); | 72 __ Branch(&miss, ne, flags_reg, Operand(flags)); |
73 | 73 |
74 #ifdef DEBUG | 74 #ifdef DEBUG |
75 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 75 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
76 __ jmp(&miss); | 76 __ jmp(&miss); |
77 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 77 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
78 __ jmp(&miss); | 78 __ jmp(&miss); |
79 } | 79 } |
80 #endif | 80 #endif |
81 | 81 |
| 82 if (leave_frame) __ LeaveFrame(StackFrame::INTERNAL); |
| 83 |
82 // Jump to the first instruction in the code stub. | 84 // Jump to the first instruction in the code stub. |
83 __ Daddu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 85 __ Daddu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
84 __ Jump(at); | 86 __ Jump(at); |
85 | 87 |
86 // Miss: fall through. | 88 // Miss: fall through. |
87 __ bind(&miss); | 89 __ bind(&miss); |
88 } | 90 } |
89 | 91 |
90 | 92 |
91 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Flags flags, | 93 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Flags flags, |
92 Register receiver, Register name, | 94 bool leave_frame, Register receiver, |
93 Register scratch, Register extra, Register extra2, | 95 Register name, Register scratch, Register extra, |
94 Register extra3) { | 96 Register extra2, Register extra3) { |
95 Isolate* isolate = masm->isolate(); | 97 Isolate* isolate = masm->isolate(); |
96 Label miss; | 98 Label miss; |
97 | 99 |
98 // Make sure that code is valid. The multiplying code relies on the | 100 // Make sure that code is valid. The multiplying code relies on the |
99 // entry size being 12. | 101 // entry size being 12. |
100 // DCHECK(sizeof(Entry) == 12); | 102 // DCHECK(sizeof(Entry) == 12); |
101 // DCHECK(sizeof(Entry) == 3 * kPointerSize); | 103 // DCHECK(sizeof(Entry) == 3 * kPointerSize); |
102 | 104 |
103 // Make sure the flags does not name a specific type. | 105 // Make sure the flags does not name a specific type. |
104 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); | 106 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); |
(...skipping 27 matching lines...) Expand all Loading... |
132 __ ld(at, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 134 __ ld(at, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
133 __ Daddu(scratch, scratch, at); | 135 __ Daddu(scratch, scratch, at); |
134 uint64_t mask = kPrimaryTableSize - 1; | 136 uint64_t mask = kPrimaryTableSize - 1; |
135 // We shift out the last two bits because they are not part of the hash and | 137 // We shift out the last two bits because they are not part of the hash and |
136 // they are always 01 for maps. | 138 // they are always 01 for maps. |
137 __ dsrl(scratch, scratch, kCacheIndexShift); | 139 __ dsrl(scratch, scratch, kCacheIndexShift); |
138 __ Xor(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask)); | 140 __ Xor(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask)); |
139 __ And(scratch, scratch, Operand(mask)); | 141 __ And(scratch, scratch, Operand(mask)); |
140 | 142 |
141 // Probe the primary table. | 143 // Probe the primary table. |
142 ProbeTable(isolate, masm, flags, kPrimary, receiver, name, scratch, extra, | 144 ProbeTable(isolate, masm, flags, leave_frame, kPrimary, receiver, name, |
143 extra2, extra3); | 145 scratch, extra, extra2, extra3); |
144 | 146 |
145 // Primary miss: Compute hash for secondary probe. | 147 // Primary miss: Compute hash for secondary probe. |
146 __ dsrl(at, name, kCacheIndexShift); | 148 __ dsrl(at, name, kCacheIndexShift); |
147 __ Dsubu(scratch, scratch, at); | 149 __ Dsubu(scratch, scratch, at); |
148 uint64_t mask2 = kSecondaryTableSize - 1; | 150 uint64_t mask2 = kSecondaryTableSize - 1; |
149 __ Daddu(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask2)); | 151 __ Daddu(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask2)); |
150 __ And(scratch, scratch, Operand(mask2)); | 152 __ And(scratch, scratch, Operand(mask2)); |
151 | 153 |
152 // Probe the secondary table. | 154 // Probe the secondary table. |
153 ProbeTable(isolate, masm, flags, kSecondary, receiver, name, scratch, extra, | 155 ProbeTable(isolate, masm, flags, leave_frame, kSecondary, receiver, name, |
154 extra2, extra3); | 156 scratch, extra, extra2, extra3); |
155 | 157 |
156 // Cache miss: Fall-through and let caller handle the miss by | 158 // Cache miss: Fall-through and let caller handle the miss by |
157 // entering the runtime system. | 159 // entering the runtime system. |
158 __ bind(&miss); | 160 __ bind(&miss); |
159 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 161 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
160 extra3); | 162 extra3); |
161 } | 163 } |
162 | 164 |
163 | 165 |
164 #undef __ | 166 #undef __ |
165 } | 167 } |
166 } // namespace v8::internal | 168 } // namespace v8::internal |
167 | 169 |
168 #endif // V8_TARGET_ARCH_MIPS64 | 170 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |