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