OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_S390 | 5 #if V8_TARGET_ARCH_S390 |
6 | 6 |
7 #include "src/ic/stub-cache.h" | 7 #include "src/ic/stub-cache.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/ic/ic.h" | 9 #include "src/ic/ic.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 Code::Flags flags, StubCache::Table table, | 18 StubCache::Table table, Register receiver, Register name, |
19 Register receiver, Register name, | |
20 // Number of the cache entry, not scaled. | 19 // Number of the cache entry, not scaled. |
21 Register offset, Register scratch, Register scratch2, | 20 Register offset, Register scratch, Register scratch2, |
22 Register offset_scratch) { | 21 Register offset_scratch) { |
23 ExternalReference key_offset(stub_cache->key_reference(table)); | 22 ExternalReference key_offset(stub_cache->key_reference(table)); |
24 ExternalReference value_offset(stub_cache->value_reference(table)); | 23 ExternalReference value_offset(stub_cache->value_reference(table)); |
25 ExternalReference map_offset(stub_cache->map_reference(table)); | 24 ExternalReference map_offset(stub_cache->map_reference(table)); |
26 | 25 |
27 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); | 26 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); |
28 uintptr_t value_off_addr = | 27 uintptr_t value_off_addr = |
29 reinterpret_cast<uintptr_t>(value_offset.address()); | 28 reinterpret_cast<uintptr_t>(value_offset.address()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // Check the map matches. | 62 // Check the map matches. |
64 __ LoadP(ip, MemOperand(base_addr, map_off_addr - key_off_addr)); | 63 __ LoadP(ip, MemOperand(base_addr, map_off_addr - key_off_addr)); |
65 __ CmpP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 64 __ CmpP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
66 __ bne(&miss, Label::kNear); | 65 __ bne(&miss, Label::kNear); |
67 | 66 |
68 // Get the code entry from the cache. | 67 // Get the code entry from the cache. |
69 Register code = scratch2; | 68 Register code = scratch2; |
70 scratch2 = no_reg; | 69 scratch2 = no_reg; |
71 __ LoadP(code, MemOperand(base_addr, value_off_addr - key_off_addr)); | 70 __ LoadP(code, MemOperand(base_addr, value_off_addr - key_off_addr)); |
72 | 71 |
| 72 #ifdef DEBUG |
73 // Check that the flags match what we're looking for. | 73 // Check that the flags match what we're looking for. |
| 74 Code::Flags flags = Code::RemoveHolderFromFlags( |
| 75 Code::ComputeHandlerFlags(stub_cache->ic_kind())); |
74 Register flags_reg = base_addr; | 76 Register flags_reg = base_addr; |
75 base_addr = no_reg; | 77 base_addr = no_reg; |
76 __ LoadlW(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); | 78 __ LoadlW(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); |
77 | 79 |
78 DCHECK(!r0.is(flags_reg)); | 80 DCHECK(!r0.is(flags_reg)); |
79 __ AndP(flags_reg, flags_reg, Operand(~Code::kFlagsNotUsedInLookup)); | 81 __ AndP(flags_reg, flags_reg, Operand(~Code::kFlagsNotUsedInLookup)); |
80 __ CmpLogicalP(flags_reg, Operand(flags)); | 82 __ CmpLogicalP(flags_reg, Operand(flags)); |
81 __ bne(&miss, Label::kNear); | 83 __ Check(eq, kUnexpectedValue); |
82 | 84 |
83 #ifdef DEBUG | |
84 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 85 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
85 __ b(&miss, Label::kNear); | 86 __ b(&miss, Label::kNear); |
86 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 87 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
87 __ b(&miss, Label::kNear); | 88 __ b(&miss, Label::kNear); |
88 } | 89 } |
89 #endif | 90 #endif |
90 | 91 |
91 // Jump to the first instruction in the code stub. | 92 // Jump to the first instruction in the code stub. |
92 // TODO(joransiu): Combine into indirect branch | 93 // TODO(joransiu): Combine into indirect branch |
93 __ la(code, MemOperand(code, Code::kHeaderSize - kHeapObjectTag)); | 94 __ la(code, MemOperand(code, Code::kHeaderSize - kHeapObjectTag)); |
94 __ b(code); | 95 __ b(code); |
95 | 96 |
96 // Miss: fall through. | 97 // Miss: fall through. |
97 __ bind(&miss); | 98 __ bind(&miss); |
98 } | 99 } |
99 | 100 |
100 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, | 101 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, |
101 Register name, Register scratch, Register extra, | 102 Register name, Register scratch, Register extra, |
102 Register extra2, Register extra3) { | 103 Register extra2, Register extra3) { |
103 Code::Flags flags = | |
104 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_)); | |
105 | |
106 Label miss; | 104 Label miss; |
107 | 105 |
108 #if V8_TARGET_ARCH_S390X | 106 #if V8_TARGET_ARCH_S390X |
109 // Make sure that code is valid. The multiplying code relies on the | 107 // Make sure that code is valid. The multiplying code relies on the |
110 // entry size being 24. | 108 // entry size being 24. |
111 DCHECK(sizeof(Entry) == 24); | 109 DCHECK(sizeof(Entry) == 24); |
112 #else | 110 #else |
113 // Make sure that code is valid. The multiplying code relies on the | 111 // Make sure that code is valid. The multiplying code relies on the |
114 // entry size being 12. | 112 // entry size being 12. |
115 DCHECK(sizeof(Entry) == 12); | 113 DCHECK(sizeof(Entry) == 12); |
(...skipping 30 matching lines...) Expand all Loading... |
146 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, | 144 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, |
147 extra3); | 145 extra3); |
148 | 146 |
149 // Check that the receiver isn't a smi. | 147 // Check that the receiver isn't a smi. |
150 __ JumpIfSmi(receiver, &miss); | 148 __ JumpIfSmi(receiver, &miss); |
151 | 149 |
152 // Get the map of the receiver and compute the hash. | 150 // Get the map of the receiver and compute the hash. |
153 __ LoadlW(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); | 151 __ LoadlW(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); |
154 __ LoadP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 152 __ LoadP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
155 __ AddP(scratch, scratch, ip); | 153 __ AddP(scratch, scratch, ip); |
156 __ XorP(scratch, scratch, Operand(flags)); | |
157 // The mask omits the last two bits because they are not part of the hash. | 154 // The mask omits the last two bits because they are not part of the hash. |
158 __ AndP(scratch, scratch, | 155 __ AndP(scratch, scratch, |
159 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); | 156 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); |
160 | 157 |
161 // Probe the primary table. | 158 // Probe the primary table. |
162 ProbeTable(this, masm, flags, kPrimary, receiver, name, scratch, extra, | 159 ProbeTable(this, masm, kPrimary, receiver, name, scratch, extra, extra2, |
163 extra2, extra3); | 160 extra3); |
164 | 161 |
165 // Primary miss: Compute hash for secondary probe. | 162 // Primary miss: Compute hash for secondary probe. |
166 __ SubP(scratch, scratch, name); | 163 __ SubP(scratch, scratch, name); |
167 __ AddP(scratch, scratch, Operand(flags)); | 164 __ AddP(scratch, scratch, Operand(kSecondaryMagic)); |
168 __ AndP(scratch, scratch, | 165 __ AndP(scratch, scratch, |
169 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); | 166 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); |
170 | 167 |
171 // Probe the secondary table. | 168 // Probe the secondary table. |
172 ProbeTable(this, masm, flags, kSecondary, receiver, name, scratch, extra, | 169 ProbeTable(this, masm, kSecondary, receiver, name, scratch, extra, extra2, |
173 extra2, extra3); | 170 extra3); |
174 | 171 |
175 // Cache miss: Fall-through and let caller handle the miss by | 172 // Cache miss: Fall-through and let caller handle the miss by |
176 // entering the runtime system. | 173 // entering the runtime system. |
177 __ bind(&miss); | 174 __ bind(&miss); |
178 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 175 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
179 extra3); | 176 extra3); |
180 } | 177 } |
181 | 178 |
182 #undef __ | 179 #undef __ |
183 } // namespace internal | 180 } // namespace internal |
184 } // namespace v8 | 181 } // namespace v8 |
185 | 182 |
186 #endif // V8_TARGET_ARCH_S390 | 183 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |