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_ARM | 7 #if V8_TARGET_ARCH_ARM |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/ic/ic.h" | 10 #include "src/ic/ic.h" |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { | 316 void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { |
317 // The return address is in lr. | 317 // The return address is in lr. |
318 | 318 |
319 __ mov(LoadIC_TempRegister(), LoadDescriptor::ReceiverRegister()); | 319 __ mov(LoadIC_TempRegister(), LoadDescriptor::ReceiverRegister()); |
320 __ Push(LoadIC_TempRegister(), LoadDescriptor::NameRegister()); | 320 __ Push(LoadIC_TempRegister(), LoadDescriptor::NameRegister()); |
321 | 321 |
322 __ TailCallRuntime(Runtime::kGetProperty, 2, 1); | 322 __ TailCallRuntime(Runtime::kGetProperty, 2, 1); |
323 } | 323 } |
324 | 324 |
325 | 325 |
326 static MemOperand GenerateMappedArgumentsLookup( | |
327 MacroAssembler* masm, Register object, Register key, Register scratch1, | |
328 Register scratch2, Register scratch3, Label* unmapped_case, | |
329 Label* slow_case) { | |
330 Heap* heap = masm->isolate()->heap(); | |
331 | |
332 // Check that the receiver is a JSObject. Because of the map check | |
333 // later, we do not need to check for interceptors or whether it | |
334 // requires access checks. | |
335 __ JumpIfSmi(object, slow_case); | |
336 // Check that the object is some kind of JSObject. | |
337 __ CompareObjectType(object, scratch1, scratch2, FIRST_JS_RECEIVER_TYPE); | |
338 __ b(lt, slow_case); | |
339 | |
340 // Check that the key is a positive smi. | |
341 __ tst(key, Operand(0x80000001)); | |
342 __ b(ne, slow_case); | |
343 | |
344 // Load the elements into scratch1 and check its map. | |
345 Handle<Map> arguments_map(heap->sloppy_arguments_elements_map()); | |
346 __ ldr(scratch1, FieldMemOperand(object, JSObject::kElementsOffset)); | |
347 __ CheckMap(scratch1, scratch2, arguments_map, slow_case, DONT_DO_SMI_CHECK); | |
348 | |
349 // Check if element is in the range of mapped arguments. If not, jump | |
350 // to the unmapped lookup with the parameter map in scratch1. | |
351 __ ldr(scratch2, FieldMemOperand(scratch1, FixedArray::kLengthOffset)); | |
352 __ sub(scratch2, scratch2, Operand(Smi::FromInt(2))); | |
353 __ cmp(key, Operand(scratch2)); | |
354 __ b(cs, unmapped_case); | |
355 | |
356 // Load element index and check whether it is the hole. | |
357 const int kOffset = | |
358 FixedArray::kHeaderSize + 2 * kPointerSize - kHeapObjectTag; | |
359 | |
360 __ mov(scratch3, Operand(kPointerSize >> 1)); | |
361 __ mul(scratch3, key, scratch3); | |
362 __ add(scratch3, scratch3, Operand(kOffset)); | |
363 | |
364 __ ldr(scratch2, MemOperand(scratch1, scratch3)); | |
365 __ LoadRoot(scratch3, Heap::kTheHoleValueRootIndex); | |
366 __ cmp(scratch2, scratch3); | |
367 __ b(eq, unmapped_case); | |
368 | |
369 // Load value from context and return it. We can reuse scratch1 because | |
370 // we do not jump to the unmapped lookup (which requires the parameter | |
371 // map in scratch1). | |
372 __ ldr(scratch1, FieldMemOperand(scratch1, FixedArray::kHeaderSize)); | |
373 __ mov(scratch3, Operand(kPointerSize >> 1)); | |
374 __ mul(scratch3, scratch2, scratch3); | |
375 __ add(scratch3, scratch3, Operand(Context::kHeaderSize - kHeapObjectTag)); | |
376 return MemOperand(scratch1, scratch3); | |
377 } | |
378 | |
379 | |
380 static MemOperand GenerateUnmappedArgumentsLookup(MacroAssembler* masm, | |
381 Register key, | |
382 Register parameter_map, | |
383 Register scratch, | |
384 Label* slow_case) { | |
385 // Element is in arguments backing store, which is referenced by the | |
386 // second element of the parameter_map. The parameter_map register | |
387 // must be loaded with the parameter map of the arguments object and is | |
388 // overwritten. | |
389 const int kBackingStoreOffset = FixedArray::kHeaderSize + kPointerSize; | |
390 Register backing_store = parameter_map; | |
391 __ ldr(backing_store, FieldMemOperand(parameter_map, kBackingStoreOffset)); | |
392 Handle<Map> fixed_array_map(masm->isolate()->heap()->fixed_array_map()); | |
393 __ CheckMap(backing_store, scratch, fixed_array_map, slow_case, | |
394 DONT_DO_SMI_CHECK); | |
395 __ ldr(scratch, FieldMemOperand(backing_store, FixedArray::kLengthOffset)); | |
396 __ cmp(key, Operand(scratch)); | |
397 __ b(cs, slow_case); | |
398 __ mov(scratch, Operand(kPointerSize >> 1)); | |
399 __ mul(scratch, key, scratch); | |
400 __ add(scratch, scratch, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | |
401 return MemOperand(backing_store, scratch); | |
402 } | |
403 | |
404 | |
405 void KeyedStoreIC::GenerateSloppyArguments(MacroAssembler* masm) { | |
406 Register receiver = StoreDescriptor::ReceiverRegister(); | |
407 Register key = StoreDescriptor::NameRegister(); | |
408 Register value = StoreDescriptor::ValueRegister(); | |
409 DCHECK(receiver.is(r1)); | |
410 DCHECK(key.is(r2)); | |
411 DCHECK(value.is(r0)); | |
412 | |
413 Label slow, notin; | |
414 MemOperand mapped_location = GenerateMappedArgumentsLookup( | |
415 masm, receiver, key, r3, r4, r5, ¬in, &slow); | |
416 __ str(value, mapped_location); | |
417 __ add(r6, r3, r5); | |
418 __ mov(r9, value); | |
419 __ RecordWrite(r3, r6, r9, kLRHasNotBeenSaved, kDontSaveFPRegs); | |
420 __ Ret(); | |
421 __ bind(¬in); | |
422 // The unmapped lookup expects that the parameter map is in r3. | |
423 MemOperand unmapped_location = | |
424 GenerateUnmappedArgumentsLookup(masm, key, r3, r4, &slow); | |
425 __ str(value, unmapped_location); | |
426 __ add(r6, r3, r4); | |
427 __ mov(r9, value); | |
428 __ RecordWrite(r3, r6, r9, kLRHasNotBeenSaved, kDontSaveFPRegs); | |
429 __ Ret(); | |
430 __ bind(&slow); | |
431 GenerateMiss(masm); | |
432 } | |
433 | |
434 | |
435 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { | 326 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { |
436 // The return address is in lr. | 327 // The return address is in lr. |
437 Isolate* isolate = masm->isolate(); | 328 Isolate* isolate = masm->isolate(); |
438 | 329 |
439 DCHECK(!AreAliased(r4, r5, LoadWithVectorDescriptor::SlotRegister(), | 330 DCHECK(!AreAliased(r4, r5, LoadWithVectorDescriptor::SlotRegister(), |
440 LoadWithVectorDescriptor::VectorRegister())); | 331 LoadWithVectorDescriptor::VectorRegister())); |
441 __ IncrementCounter(isolate->counters()->keyed_load_miss(), 1, r4, r5); | 332 __ IncrementCounter(isolate->counters()->keyed_load_miss(), 1, r4, r5); |
442 | 333 |
443 LoadIC_PushArgs(masm); | 334 LoadIC_PushArgs(masm); |
444 | 335 |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 patcher.EmitCondition(ne); | 862 patcher.EmitCondition(ne); |
972 } else { | 863 } else { |
973 DCHECK(Assembler::GetCondition(branch_instr) == ne); | 864 DCHECK(Assembler::GetCondition(branch_instr) == ne); |
974 patcher.EmitCondition(eq); | 865 patcher.EmitCondition(eq); |
975 } | 866 } |
976 } | 867 } |
977 } | 868 } |
978 } // namespace v8::internal | 869 } // namespace v8::internal |
979 | 870 |
980 #endif // V8_TARGET_ARCH_ARM | 871 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |