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/ic.h" | 7 #include "src/ic/ic.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/ic/ic-compiler.h" | 9 #include "src/ic/ic-compiler.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 // ---------------------------------------------------------------------------- | 15 // ---------------------------------------------------------------------------- |
16 // Static IC stub generators. | 16 // Static IC stub generators. |
17 // | 17 // |
18 | 18 |
19 #define __ ACCESS_MASM(masm) | 19 #define __ ACCESS_MASM(masm) |
20 | 20 |
21 static void GenerateGlobalInstanceTypeCheck(MacroAssembler* masm, Register type, | |
22 Label* global_object) { | |
23 // Register usage: | |
24 // type: holds the receiver instance type on entry. | |
25 __ CmpP(type, Operand(JS_GLOBAL_OBJECT_TYPE)); | |
26 __ beq(global_object); | |
27 __ CmpP(type, Operand(JS_GLOBAL_PROXY_TYPE)); | |
28 __ beq(global_object); | |
29 } | |
30 | |
31 // Helper function used from LoadIC GenerateNormal. | 21 // Helper function used from LoadIC GenerateNormal. |
32 // | 22 // |
33 // elements: Property dictionary. It is not clobbered if a jump to the miss | 23 // elements: Property dictionary. It is not clobbered if a jump to the miss |
34 // label is done. | 24 // label is done. |
35 // name: Property name. It is not clobbered if a jump to the miss label is | 25 // name: Property name. It is not clobbered if a jump to the miss label is |
36 // done | 26 // done |
37 // result: Register for the result. It is only updated if a jump to the miss | 27 // result: Register for the result. It is only updated if a jump to the miss |
38 // label is not done. Can be the same as elements or name clobbering | 28 // label is not done. Can be the same as elements or name clobbering |
39 // one of these in the case of not jumping to the miss label. | 29 // one of these in the case of not jumping to the miss label. |
40 // The two scratch registers need to be different from elements, name and | 30 // The two scratch registers need to be different from elements, name and |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 const int kValueOffset = kElementsStartOffset + kPointerSize; | 110 const int kValueOffset = kElementsStartOffset + kPointerSize; |
121 __ AddP(scratch2, Operand(kValueOffset - kHeapObjectTag)); | 111 __ AddP(scratch2, Operand(kValueOffset - kHeapObjectTag)); |
122 __ StoreP(value, MemOperand(scratch2)); | 112 __ StoreP(value, MemOperand(scratch2)); |
123 | 113 |
124 // Update the write barrier. Make sure not to clobber the value. | 114 // Update the write barrier. Make sure not to clobber the value. |
125 __ LoadRR(scratch1, value); | 115 __ LoadRR(scratch1, value); |
126 __ RecordWrite(elements, scratch2, scratch1, kLRHasNotBeenSaved, | 116 __ RecordWrite(elements, scratch2, scratch1, kLRHasNotBeenSaved, |
127 kDontSaveFPRegs); | 117 kDontSaveFPRegs); |
128 } | 118 } |
129 | 119 |
130 // Checks the receiver for special cases (value type, slow case bits). | |
131 // Falls through for regular JS object. | |
132 static void GenerateKeyedLoadReceiverCheck(MacroAssembler* masm, | |
133 Register receiver, Register map, | |
134 Register scratch, | |
135 int interceptor_bit, Label* slow) { | |
136 // Check that the object isn't a smi. | |
137 __ JumpIfSmi(receiver, slow); | |
138 // Get the map of the receiver. | |
139 __ LoadP(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); | |
140 // Check bit field. | |
141 __ LoadlB(scratch, FieldMemOperand(map, Map::kBitFieldOffset)); | |
142 DCHECK(((1 << Map::kIsAccessCheckNeeded) | (1 << interceptor_bit)) < 0x8000); | |
143 __ mov(r0, | |
144 Operand((1 << Map::kIsAccessCheckNeeded) | (1 << interceptor_bit))); | |
145 __ AndP(r0, scratch); | |
146 __ bne(slow /*, cr0*/); | |
147 // Check that the object is some kind of JS object EXCEPT JS Value type. | |
148 // In the case that the object is a value-wrapper object, | |
149 // we enter the runtime system to make sure that indexing into string | |
150 // objects work as intended. | |
151 DCHECK(JS_OBJECT_TYPE > JS_VALUE_TYPE); | |
152 __ LoadlB(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); | |
153 __ CmpP(scratch, Operand(JS_OBJECT_TYPE)); | |
154 __ blt(slow); | |
155 } | |
156 | |
157 // Loads an indexed element from a fast case array. | |
158 static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver, | |
159 Register key, Register elements, | |
160 Register scratch1, Register scratch2, | |
161 Register result, Label* slow) { | |
162 // Register use: | |
163 // | |
164 // receiver - holds the receiver on entry. | |
165 // Unchanged unless 'result' is the same register. | |
166 // | |
167 // key - holds the smi key on entry. | |
168 // Unchanged unless 'result' is the same register. | |
169 // | |
170 // result - holds the result on exit if the load succeeded. | |
171 // Allowed to be the the same as 'receiver' or 'key'. | |
172 // Unchanged on bailout so 'receiver' and 'key' can be safely | |
173 // used by further computation. | |
174 // | |
175 // Scratch registers: | |
176 // | |
177 // elements - holds the elements of the receiver and its protoypes. | |
178 // | |
179 // scratch1 - used to hold elements length, bit fields, base addresses. | |
180 // | |
181 // scratch2 - used to hold maps, prototypes, and the loaded value. | |
182 Label check_prototypes, check_next_prototype; | |
183 Label done, in_bounds, absent; | |
184 | |
185 __ LoadP(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); | |
186 __ AssertFastElements(elements); | |
187 | |
188 // Check that the key (index) is within bounds. | |
189 __ LoadP(scratch1, FieldMemOperand(elements, FixedArray::kLengthOffset)); | |
190 __ CmpLogicalP(key, scratch1); | |
191 __ blt(&in_bounds, Label::kNear); | |
192 // Out-of-bounds. Check the prototype chain to see if we can just return | |
193 // 'undefined'. | |
194 __ CmpP(key, Operand::Zero()); | |
195 __ blt(slow); // Negative keys can't take the fast OOB path. | |
196 __ bind(&check_prototypes); | |
197 __ LoadP(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset)); | |
198 __ bind(&check_next_prototype); | |
199 __ LoadP(scratch2, FieldMemOperand(scratch2, Map::kPrototypeOffset)); | |
200 // scratch2: current prototype | |
201 __ CompareRoot(scratch2, Heap::kNullValueRootIndex); | |
202 __ beq(&absent, Label::kNear); | |
203 __ LoadP(elements, FieldMemOperand(scratch2, JSObject::kElementsOffset)); | |
204 __ LoadP(scratch2, FieldMemOperand(scratch2, HeapObject::kMapOffset)); | |
205 // elements: elements of current prototype | |
206 // scratch2: map of current prototype | |
207 __ CompareInstanceType(scratch2, scratch1, JS_OBJECT_TYPE); | |
208 __ blt(slow); | |
209 __ LoadlB(scratch1, FieldMemOperand(scratch2, Map::kBitFieldOffset)); | |
210 __ AndP(r0, scratch1, Operand((1 << Map::kIsAccessCheckNeeded) | | |
211 (1 << Map::kHasIndexedInterceptor))); | |
212 __ bne(slow); | |
213 __ CompareRoot(elements, Heap::kEmptyFixedArrayRootIndex); | |
214 __ bne(slow); | |
215 __ jmp(&check_next_prototype); | |
216 | |
217 __ bind(&absent); | |
218 __ LoadRoot(result, Heap::kUndefinedValueRootIndex); | |
219 __ jmp(&done); | |
220 | |
221 __ bind(&in_bounds); | |
222 // Fast case: Do the load. | |
223 __ AddP(scratch1, elements, | |
224 Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | |
225 // The key is a smi. | |
226 __ SmiToPtrArrayOffset(scratch2, key); | |
227 __ LoadP(scratch2, MemOperand(scratch2, scratch1)); | |
228 __ CompareRoot(scratch2, Heap::kTheHoleValueRootIndex); | |
229 // In case the loaded value is the_hole we have to check the prototype chain. | |
230 __ beq(&check_prototypes); | |
231 __ LoadRR(result, scratch2); | |
232 __ bind(&done); | |
233 } | |
234 | |
235 // Checks whether a key is an array index string or a unique name. | |
236 // Falls through if a key is a unique name. | |
237 static void GenerateKeyNameCheck(MacroAssembler* masm, Register key, | |
238 Register map, Register hash, | |
239 Label* index_string, Label* not_unique) { | |
240 // The key is not a smi. | |
241 Label unique; | |
242 // Is it a name? | |
243 __ CompareObjectType(key, map, hash, LAST_UNIQUE_NAME_TYPE); | |
244 __ bgt(not_unique); | |
245 STATIC_ASSERT(LAST_UNIQUE_NAME_TYPE == FIRST_NONSTRING_TYPE); | |
246 __ beq(&unique, Label::kNear); | |
247 | |
248 // Is the string an array index, with cached numeric value? | |
249 __ LoadlW(hash, FieldMemOperand(key, Name::kHashFieldOffset)); | |
250 __ mov(r7, Operand(Name::kContainsCachedArrayIndexMask)); | |
251 __ AndP(r0, hash, r7); | |
252 __ beq(index_string); | |
253 | |
254 // Is the string internalized? We know it's a string, so a single | |
255 // bit test is enough. | |
256 // map: key map | |
257 __ LoadlB(hash, FieldMemOperand(map, Map::kInstanceTypeOffset)); | |
258 STATIC_ASSERT(kInternalizedTag == 0); | |
259 __ tmll(hash, Operand(kIsNotInternalizedMask)); | |
260 __ bne(not_unique); | |
261 | |
262 __ bind(&unique); | |
263 } | |
264 | |
265 void LoadIC::GenerateNormal(MacroAssembler* masm) { | 120 void LoadIC::GenerateNormal(MacroAssembler* masm) { |
266 Register dictionary = r2; | 121 Register dictionary = r2; |
267 DCHECK(!dictionary.is(LoadDescriptor::ReceiverRegister())); | 122 DCHECK(!dictionary.is(LoadDescriptor::ReceiverRegister())); |
268 DCHECK(!dictionary.is(LoadDescriptor::NameRegister())); | 123 DCHECK(!dictionary.is(LoadDescriptor::NameRegister())); |
269 | 124 |
270 Label slow; | 125 Label slow; |
271 | 126 |
272 __ LoadP(dictionary, FieldMemOperand(LoadDescriptor::ReceiverRegister(), | 127 __ LoadP(dictionary, FieldMemOperand(LoadDescriptor::ReceiverRegister(), |
273 JSObject::kPropertiesOffset)); | 128 JSObject::kPropertiesOffset)); |
274 GenerateDictionaryLoad(masm, &slow, dictionary, | 129 GenerateDictionaryLoad(masm, &slow, dictionary, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 | 187 |
333 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { | 188 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { |
334 // The return address is in lr. | 189 // The return address is in lr. |
335 | 190 |
336 __ Push(LoadDescriptor::ReceiverRegister(), LoadDescriptor::NameRegister()); | 191 __ Push(LoadDescriptor::ReceiverRegister(), LoadDescriptor::NameRegister()); |
337 | 192 |
338 // Do tail-call to runtime routine. | 193 // Do tail-call to runtime routine. |
339 __ TailCallRuntime(Runtime::kKeyedGetProperty); | 194 __ TailCallRuntime(Runtime::kKeyedGetProperty); |
340 } | 195 } |
341 | 196 |
342 void KeyedLoadIC::GenerateMegamorphic(MacroAssembler* masm) { | |
343 // The return address is in lr. | |
344 Label slow, check_name, index_smi, index_name, property_array_property; | |
345 Label probe_dictionary, check_number_dictionary; | |
346 | |
347 Register key = LoadDescriptor::NameRegister(); | |
348 Register receiver = LoadDescriptor::ReceiverRegister(); | |
349 DCHECK(key.is(r4)); | |
350 DCHECK(receiver.is(r3)); | |
351 | |
352 Isolate* isolate = masm->isolate(); | |
353 | |
354 // Check that the key is a smi. | |
355 __ JumpIfNotSmi(key, &check_name); | |
356 __ bind(&index_smi); | |
357 // Now the key is known to be a smi. This place is also jumped to from below | |
358 // where a numeric string is converted to a smi. | |
359 | |
360 GenerateKeyedLoadReceiverCheck(masm, receiver, r2, r5, | |
361 Map::kHasIndexedInterceptor, &slow); | |
362 | |
363 // Check the receiver's map to see if it has fast elements. | |
364 __ CheckFastElements(r2, r5, &check_number_dictionary); | |
365 | |
366 GenerateFastArrayLoad(masm, receiver, key, r2, r5, r6, r2, &slow); | |
367 __ IncrementCounter(isolate->counters()->ic_keyed_load_generic_smi(), 1, r6, | |
368 r5); | |
369 __ Ret(); | |
370 | |
371 __ bind(&check_number_dictionary); | |
372 __ LoadP(r6, FieldMemOperand(receiver, JSObject::kElementsOffset)); | |
373 __ LoadP(r5, FieldMemOperand(r6, JSObject::kMapOffset)); | |
374 | |
375 // Check whether the elements is a number dictionary. | |
376 // r5: elements map | |
377 // r6: elements | |
378 __ CompareRoot(r5, Heap::kHashTableMapRootIndex); | |
379 __ bne(&slow, Label::kNear); | |
380 __ SmiUntag(r2, key); | |
381 __ LoadFromNumberDictionary(&slow, r6, key, r2, r2, r5, r7); | |
382 __ Ret(); | |
383 | |
384 // Slow case, key and receiver still in r2 and r3. | |
385 __ bind(&slow); | |
386 __ IncrementCounter(isolate->counters()->ic_keyed_load_generic_slow(), 1, r6, | |
387 r5); | |
388 GenerateRuntimeGetProperty(masm); | |
389 | |
390 __ bind(&check_name); | |
391 GenerateKeyNameCheck(masm, key, r2, r5, &index_name, &slow); | |
392 | |
393 GenerateKeyedLoadReceiverCheck(masm, receiver, r2, r5, | |
394 Map::kHasNamedInterceptor, &slow); | |
395 | |
396 // If the receiver is a fast-case object, check the stub cache. Otherwise | |
397 // probe the dictionary. | |
398 __ LoadP(r5, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); | |
399 __ LoadP(r6, FieldMemOperand(r5, HeapObject::kMapOffset)); | |
400 __ CompareRoot(r6, Heap::kHashTableMapRootIndex); | |
401 __ beq(&probe_dictionary); | |
402 | |
403 // The handlers in the stub cache expect a vector and slot. Since we won't | |
404 // change the IC from any downstream misses, a dummy vector can be used. | |
405 Register vector = LoadWithVectorDescriptor::VectorRegister(); | |
406 Register slot = LoadWithVectorDescriptor::SlotRegister(); | |
407 DCHECK(!AreAliased(vector, slot, r6, r7, r8, r9)); | |
408 Handle<TypeFeedbackVector> dummy_vector = | |
409 TypeFeedbackVector::DummyVector(masm->isolate()); | |
410 int slot_index = dummy_vector->GetIndex( | |
411 FeedbackVectorSlot(TypeFeedbackVector::kDummyKeyedLoadICSlot)); | |
412 __ LoadRoot(vector, Heap::kDummyVectorRootIndex); | |
413 __ LoadSmiLiteral(slot, Smi::FromInt(slot_index)); | |
414 | |
415 masm->isolate()->load_stub_cache()->GenerateProbe(masm, receiver, key, r6, r7, | |
416 r8, r9); | |
417 // Cache miss. | |
418 GenerateMiss(masm); | |
419 | |
420 // Do a quick inline probe of the receiver's dictionary, if it | |
421 // exists. | |
422 __ bind(&probe_dictionary); | |
423 // r5: elements | |
424 __ LoadP(r2, FieldMemOperand(receiver, HeapObject::kMapOffset)); | |
425 __ LoadlB(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset)); | |
426 GenerateGlobalInstanceTypeCheck(masm, r2, &slow); | |
427 // Load the property to r2. | |
428 GenerateDictionaryLoad(masm, &slow, r5, key, r2, r7, r6); | |
429 __ IncrementCounter(isolate->counters()->ic_keyed_load_generic_symbol(), 1, | |
430 r6, r5); | |
431 __ Ret(); | |
432 | |
433 __ bind(&index_name); | |
434 __ IndexFromHash(r5, key); | |
435 // Now jump to the place where smi keys are handled. | |
436 __ b(&index_smi); | |
437 } | |
438 | |
439 static void StoreIC_PushArgs(MacroAssembler* masm) { | 197 static void StoreIC_PushArgs(MacroAssembler* masm) { |
440 __ Push(StoreWithVectorDescriptor::ValueRegister(), | 198 __ Push(StoreWithVectorDescriptor::ValueRegister(), |
441 StoreWithVectorDescriptor::SlotRegister(), | 199 StoreWithVectorDescriptor::SlotRegister(), |
442 StoreWithVectorDescriptor::VectorRegister(), | 200 StoreWithVectorDescriptor::VectorRegister(), |
443 StoreWithVectorDescriptor::ReceiverRegister(), | 201 StoreWithVectorDescriptor::ReceiverRegister(), |
444 StoreWithVectorDescriptor::NameRegister()); | 202 StoreWithVectorDescriptor::NameRegister()); |
445 } | 203 } |
446 | 204 |
447 void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { | 205 void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { |
448 StoreIC_PushArgs(masm); | 206 StoreIC_PushArgs(masm); |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 patcher.masm()->brcl(cc, Operand((branch_instr & 0xffffffff) << 1)); | 633 patcher.masm()->brcl(cc, Operand((branch_instr & 0xffffffff) << 1)); |
876 } else { | 634 } else { |
877 DCHECK(false); | 635 DCHECK(false); |
878 } | 636 } |
879 } | 637 } |
880 | 638 |
881 } // namespace internal | 639 } // namespace internal |
882 } // namespace v8 | 640 } // namespace v8 |
883 | 641 |
884 #endif // V8_TARGET_ARCH_S390 | 642 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |