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/arm/assembler-arm.h" | 9 #include "src/arm/assembler-arm.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 __ bind(&unique); | 309 __ bind(&unique); |
310 } | 310 } |
311 | 311 |
312 | 312 |
313 void LoadIC::GenerateMegamorphic(MacroAssembler* masm) { | 313 void LoadIC::GenerateMegamorphic(MacroAssembler* masm) { |
314 // ----------- S t a t e ------------- | 314 // ----------- S t a t e ------------- |
315 // -- r2 : name | 315 // -- r2 : name |
316 // -- lr : return address | 316 // -- lr : return address |
317 // -- r0 : receiver | 317 // -- r0 : receiver |
318 // ----------------------------------- | 318 // ----------------------------------- |
| 319 ASSERT(r0.is(ReceiverRegister())); |
| 320 ASSERT(r2.is(NameRegister())); |
319 | 321 |
320 // Probe the stub cache. | 322 // Probe the stub cache. |
321 Code::Flags flags = Code::ComputeHandlerFlags(Code::LOAD_IC); | 323 Code::Flags flags = Code::ComputeHandlerFlags(Code::LOAD_IC); |
322 masm->isolate()->stub_cache()->GenerateProbe( | 324 masm->isolate()->stub_cache()->GenerateProbe( |
323 masm, flags, r0, r2, r3, r4, r5, r6); | 325 masm, flags, r0, r2, r3, r4, r5, r6); |
324 | 326 |
325 // Cache miss: Jump to runtime. | 327 // Cache miss: Jump to runtime. |
326 GenerateMiss(masm); | 328 GenerateMiss(masm); |
327 } | 329 } |
328 | 330 |
329 | 331 |
330 void LoadIC::GenerateNormal(MacroAssembler* masm) { | 332 void LoadIC::GenerateNormal(MacroAssembler* masm) { |
331 // ----------- S t a t e ------------- | 333 // ----------- S t a t e ------------- |
332 // -- r2 : name | 334 // -- r2 : name |
333 // -- lr : return address | 335 // -- lr : return address |
334 // -- r0 : receiver | 336 // -- r0 : receiver |
335 // ----------------------------------- | 337 // ----------------------------------- |
| 338 ASSERT(r0.is(ReceiverRegister())); |
| 339 ASSERT(r2.is(NameRegister())); |
| 340 |
336 Label miss, slow; | 341 Label miss, slow; |
337 | 342 |
338 GenerateNameDictionaryReceiverCheck(masm, r0, r1, r3, r4, &miss); | 343 GenerateNameDictionaryReceiverCheck(masm, r0, r1, r3, r4, &miss); |
339 | 344 |
340 // r1: elements | 345 // r1: elements |
341 GenerateDictionaryLoad(masm, &slow, r1, r2, r0, r3, r4); | 346 GenerateDictionaryLoad(masm, &slow, r1, r2, r0, r3, r4); |
342 __ Ret(); | 347 __ Ret(); |
343 | 348 |
344 // Dictionary load failed, go slow (but don't miss). | 349 // Dictionary load failed, go slow (but don't miss). |
345 __ bind(&slow); | 350 __ bind(&slow); |
346 GenerateRuntimeGetProperty(masm); | 351 GenerateRuntimeGetProperty(masm); |
347 | 352 |
348 // Cache miss: Jump to runtime. | 353 // Cache miss: Jump to runtime. |
349 __ bind(&miss); | 354 __ bind(&miss); |
350 GenerateMiss(masm); | 355 GenerateMiss(masm); |
351 } | 356 } |
352 | 357 |
353 | 358 |
| 359 // A register that isn't one of the parameters to the load ic. |
| 360 static const Register LoadIC_TempRegister() { return r3; } |
| 361 |
| 362 |
354 void LoadIC::GenerateMiss(MacroAssembler* masm) { | 363 void LoadIC::GenerateMiss(MacroAssembler* masm) { |
355 // ----------- S t a t e ------------- | 364 // The return address is on the stack. |
356 // -- r2 : name | |
357 // -- lr : return address | |
358 // -- r0 : receiver | |
359 // ----------------------------------- | |
360 Isolate* isolate = masm->isolate(); | 365 Isolate* isolate = masm->isolate(); |
361 | 366 |
362 __ IncrementCounter(isolate->counters()->load_miss(), 1, r3, r4); | 367 __ IncrementCounter(isolate->counters()->load_miss(), 1, r3, r4); |
363 | 368 |
364 __ mov(r3, r0); | 369 __ mov(LoadIC_TempRegister(), ReceiverRegister()); |
365 __ Push(r3, r2); | 370 __ Push(LoadIC_TempRegister(), NameRegister()); |
366 | 371 |
367 // Perform tail call to the entry. | 372 // Perform tail call to the entry. |
368 ExternalReference ref = | 373 ExternalReference ref = |
369 ExternalReference(IC_Utility(kLoadIC_Miss), isolate); | 374 ExternalReference(IC_Utility(kLoadIC_Miss), isolate); |
370 __ TailCallExternalReference(ref, 2, 1); | 375 __ TailCallExternalReference(ref, 2, 1); |
371 } | 376 } |
372 | 377 |
373 | 378 |
374 void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { | 379 void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { |
375 // ---------- S t a t e -------------- | 380 // The return address is on the stack. |
376 // -- r2 : name | |
377 // -- lr : return address | |
378 // -- r0 : receiver | |
379 // ----------------------------------- | |
380 | 381 |
381 __ mov(r3, r0); | 382 __ mov(LoadIC_TempRegister(), ReceiverRegister()); |
382 __ Push(r3, r2); | 383 __ Push(LoadIC_TempRegister(), NameRegister()); |
383 | 384 |
384 __ TailCallRuntime(Runtime::kGetProperty, 2, 1); | 385 __ TailCallRuntime(Runtime::kGetProperty, 2, 1); |
385 } | 386 } |
386 | 387 |
387 | 388 |
388 static MemOperand GenerateMappedArgumentsLookup(MacroAssembler* masm, | 389 static MemOperand GenerateMappedArgumentsLookup(MacroAssembler* masm, |
389 Register object, | 390 Register object, |
390 Register key, | 391 Register key, |
391 Register scratch1, | 392 Register scratch1, |
392 Register scratch2, | 393 Register scratch2, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 return MemOperand(backing_store, scratch); | 470 return MemOperand(backing_store, scratch); |
470 } | 471 } |
471 | 472 |
472 | 473 |
473 void KeyedLoadIC::GenerateSloppyArguments(MacroAssembler* masm) { | 474 void KeyedLoadIC::GenerateSloppyArguments(MacroAssembler* masm) { |
474 // ---------- S t a t e -------------- | 475 // ---------- S t a t e -------------- |
475 // -- lr : return address | 476 // -- lr : return address |
476 // -- r0 : key | 477 // -- r0 : key |
477 // -- r1 : receiver | 478 // -- r1 : receiver |
478 // ----------------------------------- | 479 // ----------------------------------- |
| 480 ASSERT(r1.is(ReceiverRegister())); |
| 481 ASSERT(r0.is(NameRegister())); |
479 Label slow, notin; | 482 Label slow, notin; |
480 MemOperand mapped_location = | 483 MemOperand mapped_location = |
481 GenerateMappedArgumentsLookup(masm, r1, r0, r2, r3, r4, ¬in, &slow); | 484 GenerateMappedArgumentsLookup(masm, r1, r0, r2, r3, r4, ¬in, &slow); |
482 __ ldr(r0, mapped_location); | 485 __ ldr(r0, mapped_location); |
483 __ Ret(); | 486 __ Ret(); |
484 __ bind(¬in); | 487 __ bind(¬in); |
485 // The unmapped lookup expects that the parameter map is in r2. | 488 // The unmapped lookup expects that the parameter map is in r2. |
486 MemOperand unmapped_location = | 489 MemOperand unmapped_location = |
487 GenerateUnmappedArgumentsLookup(masm, r0, r2, r3, &slow); | 490 GenerateUnmappedArgumentsLookup(masm, r0, r2, r3, &slow); |
488 __ ldr(r2, unmapped_location); | 491 __ ldr(r2, unmapped_location); |
(...skipping 30 matching lines...) Expand all Loading... |
519 __ add(r6, r3, r4); | 522 __ add(r6, r3, r4); |
520 __ mov(r9, r0); | 523 __ mov(r9, r0); |
521 __ RecordWrite(r3, r6, r9, kLRHasNotBeenSaved, kDontSaveFPRegs); | 524 __ RecordWrite(r3, r6, r9, kLRHasNotBeenSaved, kDontSaveFPRegs); |
522 __ Ret(); | 525 __ Ret(); |
523 __ bind(&slow); | 526 __ bind(&slow); |
524 GenerateMiss(masm); | 527 GenerateMiss(masm); |
525 } | 528 } |
526 | 529 |
527 | 530 |
528 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { | 531 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { |
529 // ---------- S t a t e -------------- | 532 // The return address is on the stack. |
530 // -- lr : return address | |
531 // -- r0 : key | |
532 // -- r1 : receiver | |
533 // ----------------------------------- | |
534 Isolate* isolate = masm->isolate(); | 533 Isolate* isolate = masm->isolate(); |
535 | 534 |
536 __ IncrementCounter(isolate->counters()->keyed_load_miss(), 1, r3, r4); | 535 __ IncrementCounter(isolate->counters()->keyed_load_miss(), 1, r3, r4); |
537 | 536 |
538 __ Push(r1, r0); | 537 __ Push(ReceiverRegister(), NameRegister()); |
539 | 538 |
540 // Perform tail call to the entry. | 539 // Perform tail call to the entry. |
541 ExternalReference ref = | 540 ExternalReference ref = |
542 ExternalReference(IC_Utility(kKeyedLoadIC_Miss), isolate); | 541 ExternalReference(IC_Utility(kKeyedLoadIC_Miss), isolate); |
543 | 542 |
544 __ TailCallExternalReference(ref, 2, 1); | 543 __ TailCallExternalReference(ref, 2, 1); |
545 } | 544 } |
546 | 545 |
547 | 546 |
548 // IC register specifications | 547 // IC register specifications |
549 const Register LoadIC::ReceiverRegister() { return r0; } | 548 const Register LoadIC::ReceiverRegister() { return r0; } |
550 const Register LoadIC::NameRegister() { return r2; } | 549 const Register LoadIC::NameRegister() { return r2; } |
551 const Register KeyedLoadIC::ReceiverRegister() { return r1; } | 550 const Register KeyedLoadIC::ReceiverRegister() { return r1; } |
552 const Register KeyedLoadIC::NameRegister() { return r0; } | 551 const Register KeyedLoadIC::NameRegister() { return r0; } |
553 | 552 |
554 | 553 |
555 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { | 554 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { |
556 // ---------- S t a t e -------------- | 555 // The return address is on the stack. |
557 // -- lr : return address | |
558 // -- r0 : key | |
559 // -- r1 : receiver | |
560 // ----------------------------------- | |
561 | 556 |
562 __ Push(r1, r0); | 557 __ Push(ReceiverRegister(), NameRegister()); |
563 | 558 |
564 __ TailCallRuntime(Runtime::kKeyedGetProperty, 2, 1); | 559 __ TailCallRuntime(Runtime::kKeyedGetProperty, 2, 1); |
565 } | 560 } |
566 | 561 |
567 | 562 |
568 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { | 563 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { |
569 // ---------- S t a t e -------------- | 564 // ---------- S t a t e -------------- |
570 // -- lr : return address | 565 // -- lr : return address |
571 // -- r0 : key | 566 // -- r0 : key |
572 // -- r1 : receiver | 567 // -- r1 : receiver |
573 // ----------------------------------- | 568 // ----------------------------------- |
574 Label slow, check_name, index_smi, index_name, property_array_property; | 569 Label slow, check_name, index_smi, index_name, property_array_property; |
575 Label probe_dictionary, check_number_dictionary; | 570 Label probe_dictionary, check_number_dictionary; |
576 | 571 |
577 Register key = r0; | 572 Register key = NameRegister(); |
578 Register receiver = r1; | 573 Register receiver = ReceiverRegister(); |
| 574 ASSERT(key.is(r0)); |
| 575 ASSERT(receiver.is(r1)); |
579 | 576 |
580 Isolate* isolate = masm->isolate(); | 577 Isolate* isolate = masm->isolate(); |
581 | 578 |
582 // Check that the key is a smi. | 579 // Check that the key is a smi. |
583 __ JumpIfNotSmi(key, &check_name); | 580 __ JumpIfNotSmi(key, &check_name); |
584 __ bind(&index_smi); | 581 __ bind(&index_smi); |
585 // Now the key is known to be a smi. This place is also jumped to from below | 582 // Now the key is known to be a smi. This place is also jumped to from below |
586 // where a numeric string is converted to a smi. | 583 // where a numeric string is converted to a smi. |
587 | 584 |
588 GenerateKeyedLoadReceiverCheck( | 585 GenerateKeyedLoadReceiverCheck( |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 __ Ret(); | 727 __ Ret(); |
731 | 728 |
732 __ bind(&index_name); | 729 __ bind(&index_name); |
733 __ IndexFromHash(r3, key); | 730 __ IndexFromHash(r3, key); |
734 // Now jump to the place where smi keys are handled. | 731 // Now jump to the place where smi keys are handled. |
735 __ jmp(&index_smi); | 732 __ jmp(&index_smi); |
736 } | 733 } |
737 | 734 |
738 | 735 |
739 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { | 736 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { |
740 // ---------- S t a t e -------------- | 737 // Return address is on the stack. |
741 // -- lr : return address | |
742 // -- r0 : key (index) | |
743 // -- r1 : receiver | |
744 // ----------------------------------- | |
745 Label miss; | 738 Label miss; |
746 | 739 |
747 Register receiver = r1; | 740 Register receiver = ReceiverRegister(); |
748 Register index = r0; | 741 Register index = NameRegister(); |
749 Register scratch = r3; | 742 Register scratch = r3; |
750 Register result = r0; | 743 Register result = r0; |
| 744 ASSERT(!scratch.is(receiver) && !scratch.is(index)); |
751 | 745 |
752 StringCharAtGenerator char_at_generator(receiver, | 746 StringCharAtGenerator char_at_generator(receiver, |
753 index, | 747 index, |
754 scratch, | 748 scratch, |
755 result, | 749 result, |
756 &miss, // When not a string. | 750 &miss, // When not a string. |
757 &miss, // When not a number. | 751 &miss, // When not a number. |
758 &miss, // When index out of range. | 752 &miss, // When index out of range. |
759 STRING_INDEX_IS_ARRAY_INDEX); | 753 STRING_INDEX_IS_ARRAY_INDEX); |
760 char_at_generator.GenerateFast(masm); | 754 char_at_generator.GenerateFast(masm); |
761 __ Ret(); | 755 __ Ret(); |
762 | 756 |
763 StubRuntimeCallHelper call_helper; | 757 StubRuntimeCallHelper call_helper; |
764 char_at_generator.GenerateSlow(masm, call_helper); | 758 char_at_generator.GenerateSlow(masm, call_helper); |
765 | 759 |
766 __ bind(&miss); | 760 __ bind(&miss); |
767 GenerateMiss(masm); | 761 GenerateMiss(masm); |
768 } | 762 } |
769 | 763 |
770 | 764 |
771 void KeyedLoadIC::GenerateIndexedInterceptor(MacroAssembler* masm) { | 765 void KeyedLoadIC::GenerateIndexedInterceptor(MacroAssembler* masm) { |
772 // ---------- S t a t e -------------- | 766 // Return address is on the stack. |
773 // -- lr : return address | |
774 // -- r0 : key | |
775 // -- r1 : receiver | |
776 // ----------------------------------- | |
777 Label slow; | 767 Label slow; |
778 | 768 |
| 769 Register receiver = ReceiverRegister(); |
| 770 Register key = NameRegister(); |
| 771 Register scratch1 = r2; |
| 772 Register scratch2 = r3; |
| 773 ASSERT(!scratch1.is(receiver) && !scratch1.is(key)); |
| 774 ASSERT(!scratch2.is(receiver) && !scratch2.is(key)); |
| 775 |
779 // Check that the receiver isn't a smi. | 776 // Check that the receiver isn't a smi. |
780 __ JumpIfSmi(r1, &slow); | 777 __ JumpIfSmi(receiver, &slow); |
781 | 778 |
782 // Check that the key is an array index, that is Uint32. | 779 // Check that the key is an array index, that is Uint32. |
783 __ NonNegativeSmiTst(r0); | 780 __ NonNegativeSmiTst(key); |
784 __ b(ne, &slow); | 781 __ b(ne, &slow); |
785 | 782 |
786 // Get the map of the receiver. | 783 // Get the map of the receiver. |
787 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); | 784 __ ldr(scratch1, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
788 | 785 |
789 // Check that it has indexed interceptor and access checks | 786 // Check that it has indexed interceptor and access checks |
790 // are not enabled for this object. | 787 // are not enabled for this object. |
791 __ ldrb(r3, FieldMemOperand(r2, Map::kBitFieldOffset)); | 788 __ ldrb(scratch2, FieldMemOperand(scratch1, Map::kBitFieldOffset)); |
792 __ and_(r3, r3, Operand(kSlowCaseBitFieldMask)); | 789 __ and_(scratch2, scratch2, Operand(kSlowCaseBitFieldMask)); |
793 __ cmp(r3, Operand(1 << Map::kHasIndexedInterceptor)); | 790 __ cmp(scratch2, Operand(1 << Map::kHasIndexedInterceptor)); |
794 __ b(ne, &slow); | 791 __ b(ne, &slow); |
795 | 792 |
796 // Everything is fine, call runtime. | 793 // Everything is fine, call runtime. |
797 __ Push(r1, r0); // Receiver, key. | 794 __ Push(receiver, key); // Receiver, key. |
798 | 795 |
799 // Perform tail call to the entry. | 796 // Perform tail call to the entry. |
800 __ TailCallExternalReference( | 797 __ TailCallExternalReference( |
801 ExternalReference(IC_Utility(kKeyedLoadPropertyWithInterceptor), | 798 ExternalReference(IC_Utility(kKeyedLoadPropertyWithInterceptor), |
802 masm->isolate()), | 799 masm->isolate()), |
803 2, | 800 2, |
804 1); | 801 1); |
805 | 802 |
806 __ bind(&slow); | 803 __ bind(&slow); |
807 GenerateMiss(masm); | 804 GenerateMiss(masm); |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 } else { | 1316 } else { |
1320 ASSERT(Assembler::GetCondition(branch_instr) == ne); | 1317 ASSERT(Assembler::GetCondition(branch_instr) == ne); |
1321 patcher.EmitCondition(eq); | 1318 patcher.EmitCondition(eq); |
1322 } | 1319 } |
1323 } | 1320 } |
1324 | 1321 |
1325 | 1322 |
1326 } } // namespace v8::internal | 1323 } } // namespace v8::internal |
1327 | 1324 |
1328 #endif // V8_TARGET_ARCH_ARM | 1325 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |