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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
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 static void ProbeTable(StubCache* stub_cache, MacroAssembler* masm, | 17 static void ProbeTable(StubCache* stub_cache, MacroAssembler* masm, |
18 StubCache::Table table, Register receiver, Register name, | 18 Code::Flags flags, StubCache::Table table, |
| 19 Register receiver, Register name, |
19 // Number of the cache entry, not scaled. | 20 // Number of the cache entry, not scaled. |
20 Register offset, Register scratch, Register scratch2, | 21 Register offset, Register scratch, Register scratch2, |
21 Register offset_scratch) { | 22 Register offset_scratch) { |
22 ExternalReference key_offset(stub_cache->key_reference(table)); | 23 ExternalReference key_offset(stub_cache->key_reference(table)); |
23 ExternalReference value_offset(stub_cache->value_reference(table)); | 24 ExternalReference value_offset(stub_cache->value_reference(table)); |
24 ExternalReference map_offset(stub_cache->map_reference(table)); | 25 ExternalReference map_offset(stub_cache->map_reference(table)); |
25 | 26 |
26 uint32_t key_off_addr = reinterpret_cast<uint32_t>(key_offset.address()); | 27 uint32_t key_off_addr = reinterpret_cast<uint32_t>(key_offset.address()); |
27 uint32_t value_off_addr = reinterpret_cast<uint32_t>(value_offset.address()); | 28 uint32_t value_off_addr = reinterpret_cast<uint32_t>(value_offset.address()); |
28 uint32_t map_off_addr = reinterpret_cast<uint32_t>(map_offset.address()); | 29 uint32_t map_off_addr = reinterpret_cast<uint32_t>(map_offset.address()); |
(...skipping 24 matching lines...) Expand all Loading... |
53 // Check the map matches. | 54 // Check the map matches. |
54 __ lw(at, MemOperand(base_addr, map_off_addr - key_off_addr)); | 55 __ lw(at, MemOperand(base_addr, map_off_addr - key_off_addr)); |
55 __ lw(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 56 __ lw(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
56 __ Branch(&miss, ne, at, Operand(scratch2)); | 57 __ Branch(&miss, ne, at, Operand(scratch2)); |
57 | 58 |
58 // Get the code entry from the cache. | 59 // Get the code entry from the cache. |
59 Register code = scratch2; | 60 Register code = scratch2; |
60 scratch2 = no_reg; | 61 scratch2 = no_reg; |
61 __ lw(code, MemOperand(base_addr, value_off_addr - key_off_addr)); | 62 __ lw(code, MemOperand(base_addr, value_off_addr - key_off_addr)); |
62 | 63 |
63 #ifdef DEBUG | |
64 // Check that the flags match what we're looking for. | 64 // Check that the flags match what we're looking for. |
65 Code::Flags flags = Code::RemoveHolderFromFlags( | |
66 Code::ComputeHandlerFlags(stub_cache->ic_kind())); | |
67 Register flags_reg = base_addr; | 65 Register flags_reg = base_addr; |
68 base_addr = no_reg; | 66 base_addr = no_reg; |
69 __ lw(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); | 67 __ lw(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); |
70 __ And(flags_reg, flags_reg, Operand(~Code::kFlagsNotUsedInLookup)); | 68 __ And(flags_reg, flags_reg, Operand(~Code::kFlagsNotUsedInLookup)); |
71 __ Check(eq, kUnexpectedValue, flags_reg, Operand(flags)); | 69 __ Branch(&miss, ne, flags_reg, Operand(flags)); |
72 | 70 |
| 71 #ifdef DEBUG |
73 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 72 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
74 __ jmp(&miss); | 73 __ jmp(&miss); |
75 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 74 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
76 __ jmp(&miss); | 75 __ jmp(&miss); |
77 } | 76 } |
78 #endif | 77 #endif |
79 | 78 |
80 // Jump to the first instruction in the code stub. | 79 // Jump to the first instruction in the code stub. |
81 __ Addu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 80 __ Addu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
82 __ Jump(at); | 81 __ Jump(at); |
83 | 82 |
84 // Miss: fall through. | 83 // Miss: fall through. |
85 __ bind(&miss); | 84 __ bind(&miss); |
86 } | 85 } |
87 | 86 |
88 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, | 87 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, |
89 Register name, Register scratch, Register extra, | 88 Register name, Register scratch, Register extra, |
90 Register extra2, Register extra3) { | 89 Register extra2, Register extra3) { |
| 90 Code::Flags flags = |
| 91 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_)); |
| 92 |
91 Label miss; | 93 Label miss; |
92 | 94 |
93 // Make sure that code is valid. The multiplying code relies on the | 95 // Make sure that code is valid. The multiplying code relies on the |
94 // entry size being 12. | 96 // entry size being 12. |
95 DCHECK(sizeof(Entry) == 12); | 97 DCHECK(sizeof(Entry) == 12); |
96 | 98 |
97 // Make sure that there are no register conflicts. | 99 // Make sure that there are no register conflicts. |
98 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); | 100 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); |
99 | 101 |
100 // Check register validity. | 102 // Check register validity. |
(...skipping 28 matching lines...) Expand all Loading... |
129 __ JumpIfSmi(receiver, &miss); | 131 __ JumpIfSmi(receiver, &miss); |
130 | 132 |
131 // Get the map of the receiver and compute the hash. | 133 // Get the map of the receiver and compute the hash. |
132 __ lw(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); | 134 __ lw(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); |
133 __ lw(at, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 135 __ lw(at, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
134 __ Addu(scratch, scratch, at); | 136 __ Addu(scratch, scratch, at); |
135 uint32_t mask = kPrimaryTableSize - 1; | 137 uint32_t mask = kPrimaryTableSize - 1; |
136 // We shift out the last two bits because they are not part of the hash and | 138 // We shift out the last two bits because they are not part of the hash and |
137 // they are always 01 for maps. | 139 // they are always 01 for maps. |
138 __ srl(scratch, scratch, kCacheIndexShift); | 140 __ srl(scratch, scratch, kCacheIndexShift); |
| 141 __ Xor(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask)); |
139 __ And(scratch, scratch, Operand(mask)); | 142 __ And(scratch, scratch, Operand(mask)); |
140 | 143 |
141 // Probe the primary table. | 144 // Probe the primary table. |
142 ProbeTable(this, masm, kPrimary, receiver, name, scratch, extra, extra2, | 145 ProbeTable(this, masm, flags, kPrimary, receiver, name, scratch, extra, |
143 extra3); | 146 extra2, extra3); |
144 | 147 |
145 // Primary miss: Compute hash for secondary probe. | 148 // Primary miss: Compute hash for secondary probe. |
146 __ srl(at, name, kCacheIndexShift); | 149 __ srl(at, name, kCacheIndexShift); |
147 __ Subu(scratch, scratch, at); | 150 __ Subu(scratch, scratch, at); |
148 uint32_t mask2 = kSecondaryTableSize - 1; | 151 uint32_t mask2 = kSecondaryTableSize - 1; |
| 152 __ Addu(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask2)); |
149 __ And(scratch, scratch, Operand(mask2)); | 153 __ And(scratch, scratch, Operand(mask2)); |
150 | 154 |
151 // Probe the secondary table. | 155 // Probe the secondary table. |
152 ProbeTable(this, masm, kSecondary, receiver, name, scratch, extra, extra2, | 156 ProbeTable(this, masm, flags, kSecondary, receiver, name, scratch, extra, |
153 extra3); | 157 extra2, extra3); |
154 | 158 |
155 // Cache miss: Fall-through and let caller handle the miss by | 159 // Cache miss: Fall-through and let caller handle the miss by |
156 // entering the runtime system. | 160 // entering the runtime system. |
157 __ bind(&miss); | 161 __ bind(&miss); |
158 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 162 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
159 extra3); | 163 extra3); |
160 } | 164 } |
161 | 165 |
162 | 166 |
163 #undef __ | 167 #undef __ |
164 } // namespace internal | 168 } // namespace internal |
165 } // namespace v8 | 169 } // namespace v8 |
166 | 170 |
167 #endif // V8_TARGET_ARCH_MIPS | 171 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |