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_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
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 uint32_t key_off_addr = reinterpret_cast<uint32_t>(key_offset.address()); | 28 uint32_t key_off_addr = reinterpret_cast<uint32_t>(key_offset.address()); |
29 uint32_t value_off_addr = reinterpret_cast<uint32_t>(value_offset.address()); | 29 uint32_t value_off_addr = reinterpret_cast<uint32_t>(value_offset.address()); |
30 uint32_t map_off_addr = reinterpret_cast<uint32_t>(map_offset.address()); | 30 uint32_t map_off_addr = reinterpret_cast<uint32_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 __ Addu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 85 __ Addu(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 | 103 |
102 // Make sure the flags does not name a specific type. | 104 // Make sure the flags does not name a specific type. |
103 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); | 105 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); |
104 | 106 |
(...skipping 26 matching lines...) Expand all Loading... |
131 __ lw(at, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 133 __ lw(at, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
132 __ Addu(scratch, scratch, at); | 134 __ Addu(scratch, scratch, at); |
133 uint32_t mask = kPrimaryTableSize - 1; | 135 uint32_t mask = kPrimaryTableSize - 1; |
134 // We shift out the last two bits because they are not part of the hash and | 136 // We shift out the last two bits because they are not part of the hash and |
135 // they are always 01 for maps. | 137 // they are always 01 for maps. |
136 __ srl(scratch, scratch, kCacheIndexShift); | 138 __ srl(scratch, scratch, kCacheIndexShift); |
137 __ Xor(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask)); | 139 __ Xor(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask)); |
138 __ And(scratch, scratch, Operand(mask)); | 140 __ And(scratch, scratch, Operand(mask)); |
139 | 141 |
140 // Probe the primary table. | 142 // Probe the primary table. |
141 ProbeTable(isolate, masm, flags, kPrimary, receiver, name, scratch, extra, | 143 ProbeTable(isolate, masm, flags, leave_frame, kPrimary, receiver, name, |
142 extra2, extra3); | 144 scratch, extra, extra2, extra3); |
143 | 145 |
144 // Primary miss: Compute hash for secondary probe. | 146 // Primary miss: Compute hash for secondary probe. |
145 __ srl(at, name, kCacheIndexShift); | 147 __ srl(at, name, kCacheIndexShift); |
146 __ Subu(scratch, scratch, at); | 148 __ Subu(scratch, scratch, at); |
147 uint32_t mask2 = kSecondaryTableSize - 1; | 149 uint32_t mask2 = kSecondaryTableSize - 1; |
148 __ Addu(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask2)); | 150 __ Addu(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask2)); |
149 __ And(scratch, scratch, Operand(mask2)); | 151 __ And(scratch, scratch, Operand(mask2)); |
150 | 152 |
151 // Probe the secondary table. | 153 // Probe the secondary table. |
152 ProbeTable(isolate, masm, flags, kSecondary, receiver, name, scratch, extra, | 154 ProbeTable(isolate, masm, flags, leave_frame, kSecondary, receiver, name, |
153 extra2, extra3); | 155 scratch, extra, extra2, extra3); |
154 | 156 |
155 // Cache miss: Fall-through and let caller handle the miss by | 157 // Cache miss: Fall-through and let caller handle the miss by |
156 // entering the runtime system. | 158 // entering the runtime system. |
157 __ bind(&miss); | 159 __ bind(&miss); |
158 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 160 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
159 extra3); | 161 extra3); |
160 } | 162 } |
161 | 163 |
162 | 164 |
163 #undef __ | 165 #undef __ |
164 } | 166 } |
165 } // namespace v8::internal | 167 } // namespace v8::internal |
166 | 168 |
167 #endif // V8_TARGET_ARCH_MIPS | 169 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |