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