| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 | 547 |
| 548 | 548 |
| 549 | 549 |
| 550 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { | 550 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { |
| 551 // ----------- S t a t e ------------- | 551 // ----------- S t a t e ------------- |
| 552 // -- rax : key | 552 // -- rax : key |
| 553 // -- rdx : receiver | 553 // -- rdx : receiver |
| 554 // -- rsp[0] : return address | 554 // -- rsp[0] : return address |
| 555 // ----------------------------------- | 555 // ----------------------------------- |
| 556 Label slow, check_string, index_smi, index_string, property_array_property; | 556 Label slow, check_string, index_smi, index_string, property_array_property; |
| 557 Label check_pixel_array, probe_dictionary, check_number_dictionary; | 557 Label probe_dictionary, check_number_dictionary; |
| 558 | 558 |
| 559 // Check that the key is a smi. | 559 // Check that the key is a smi. |
| 560 __ JumpIfNotSmi(rax, &check_string); | 560 __ JumpIfNotSmi(rax, &check_string); |
| 561 __ bind(&index_smi); | 561 __ bind(&index_smi); |
| 562 // Now the key is known to be a smi. This place is also jumped to from below | 562 // Now the key is known to be a smi. This place is also jumped to from below |
| 563 // where a numeric string is converted to a smi. | 563 // where a numeric string is converted to a smi. |
| 564 | 564 |
| 565 GenerateKeyedLoadReceiverCheck( | 565 GenerateKeyedLoadReceiverCheck( |
| 566 masm, rdx, rcx, Map::kHasIndexedInterceptor, &slow); | 566 masm, rdx, rcx, Map::kHasIndexedInterceptor, &slow); |
| 567 | 567 |
| 568 // Check the "has fast elements" bit in the receiver's map which is | 568 // Check the "has fast elements" bit in the receiver's map which is |
| 569 // now in rcx. | 569 // now in rcx. |
| 570 __ testb(FieldOperand(rcx, Map::kBitField2Offset), | 570 __ testb(FieldOperand(rcx, Map::kBitField2Offset), |
| 571 Immediate(1 << Map::kHasFastElements)); | 571 Immediate(1 << Map::kHasFastElements)); |
| 572 __ j(zero, &check_pixel_array); | 572 __ j(zero, &check_number_dictionary); |
| 573 | 573 |
| 574 GenerateFastArrayLoad(masm, | 574 GenerateFastArrayLoad(masm, |
| 575 rdx, | 575 rdx, |
| 576 rax, | 576 rax, |
| 577 rcx, | 577 rcx, |
| 578 rbx, | 578 rbx, |
| 579 rax, | 579 rax, |
| 580 NULL, | 580 NULL, |
| 581 &slow); | 581 &slow); |
| 582 __ IncrementCounter(&Counters::keyed_load_generic_smi, 1); | 582 __ IncrementCounter(&Counters::keyed_load_generic_smi, 1); |
| 583 __ ret(0); | 583 __ ret(0); |
| 584 | 584 |
| 585 __ bind(&check_pixel_array); | 585 __ bind(&check_number_dictionary); |
| 586 GenerateFastPixelArrayLoad(masm, | 586 __ SmiToInteger32(rbx, rax); |
| 587 rdx, | 587 __ movq(rcx, FieldOperand(rdx, JSObject::kElementsOffset)); |
| 588 rax, | |
| 589 rcx, | |
| 590 rbx, | |
| 591 rax, | |
| 592 &check_number_dictionary, | |
| 593 NULL, | |
| 594 &slow); | |
| 595 | 588 |
| 596 __ bind(&check_number_dictionary); | |
| 597 // Check whether the elements is a number dictionary. | 589 // Check whether the elements is a number dictionary. |
| 598 // rdx: receiver | 590 // rdx: receiver |
| 599 // rax: key | 591 // rax: key |
| 600 // rbx: key as untagged int32 | 592 // rbx: key as untagged int32 |
| 601 // rcx: elements | 593 // rcx: elements |
| 602 __ CompareRoot(FieldOperand(rcx, HeapObject::kMapOffset), | 594 __ CompareRoot(FieldOperand(rcx, HeapObject::kMapOffset), |
| 603 Heap::kHashTableMapRootIndex); | 595 Heap::kHashTableMapRootIndex); |
| 604 __ j(not_equal, &slow); | 596 __ j(not_equal, &slow); |
| 605 GenerateNumberDictionaryLoad(masm, &slow, rcx, rax, rbx, r9, rdi, rax); | 597 GenerateNumberDictionaryLoad(masm, &slow, rcx, rax, rbx, r9, rdi, rax); |
| 606 __ ret(0); | 598 __ ret(0); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 | 751 |
| 760 // Perform tail call to the entry. | 752 // Perform tail call to the entry. |
| 761 __ TailCallExternalReference(ExternalReference( | 753 __ TailCallExternalReference(ExternalReference( |
| 762 IC_Utility(kKeyedLoadPropertyWithInterceptor)), 2, 1); | 754 IC_Utility(kKeyedLoadPropertyWithInterceptor)), 2, 1); |
| 763 | 755 |
| 764 __ bind(&slow); | 756 __ bind(&slow); |
| 765 GenerateMiss(masm); | 757 GenerateMiss(masm); |
| 766 } | 758 } |
| 767 | 759 |
| 768 | 760 |
| 769 void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) { | 761 void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, |
| 762 StrictModeFlag strict_mode) { |
| 770 // ----------- S t a t e ------------- | 763 // ----------- S t a t e ------------- |
| 771 // -- rax : value | 764 // -- rax : value |
| 772 // -- rcx : key | 765 // -- rcx : key |
| 773 // -- rdx : receiver | 766 // -- rdx : receiver |
| 774 // -- rsp[0] : return address | 767 // -- rsp[0] : return address |
| 775 // ----------------------------------- | 768 // ----------------------------------- |
| 776 Label slow, slow_with_tagged_index, fast, array, extra, check_pixel_array; | 769 Label slow, slow_with_tagged_index, fast, array, extra; |
| 777 | 770 |
| 778 // Check that the object isn't a smi. | 771 // Check that the object isn't a smi. |
| 779 __ JumpIfSmi(rdx, &slow_with_tagged_index); | 772 __ JumpIfSmi(rdx, &slow_with_tagged_index); |
| 780 // Get the map from the receiver. | 773 // Get the map from the receiver. |
| 781 __ movq(rbx, FieldOperand(rdx, HeapObject::kMapOffset)); | 774 __ movq(rbx, FieldOperand(rdx, HeapObject::kMapOffset)); |
| 782 // Check that the receiver does not require access checks. We need | 775 // Check that the receiver does not require access checks. We need |
| 783 // to do this because this generic stub does not perform map checks. | 776 // to do this because this generic stub does not perform map checks. |
| 784 __ testb(FieldOperand(rbx, Map::kBitFieldOffset), | 777 __ testb(FieldOperand(rbx, Map::kBitFieldOffset), |
| 785 Immediate(1 << Map::kIsAccessCheckNeeded)); | 778 Immediate(1 << Map::kIsAccessCheckNeeded)); |
| 786 __ j(not_zero, &slow_with_tagged_index); | 779 __ j(not_zero, &slow_with_tagged_index); |
| 787 // Check that the key is a smi. | 780 // Check that the key is a smi. |
| 788 __ JumpIfNotSmi(rcx, &slow_with_tagged_index); | 781 __ JumpIfNotSmi(rcx, &slow_with_tagged_index); |
| 789 __ SmiToInteger32(rcx, rcx); | 782 __ SmiToInteger32(rcx, rcx); |
| 790 | 783 |
| 791 __ CmpInstanceType(rbx, JS_ARRAY_TYPE); | 784 __ CmpInstanceType(rbx, JS_ARRAY_TYPE); |
| 792 __ j(equal, &array); | 785 __ j(equal, &array); |
| 793 // Check that the object is some kind of JS object. | 786 // Check that the object is some kind of JS object. |
| 794 __ CmpInstanceType(rbx, FIRST_JS_OBJECT_TYPE); | 787 __ CmpInstanceType(rbx, FIRST_JS_OBJECT_TYPE); |
| 795 __ j(below, &slow); | 788 __ j(below, &slow); |
| 796 | 789 |
| 797 // Object case: Check key against length in the elements array. | 790 // Object case: Check key against length in the elements array. |
| 798 // rax: value | 791 // rax: value |
| 799 // rdx: JSObject | 792 // rdx: JSObject |
| 800 // rcx: index | 793 // rcx: index |
| 801 __ movq(rbx, FieldOperand(rdx, JSObject::kElementsOffset)); | 794 __ movq(rbx, FieldOperand(rdx, JSObject::kElementsOffset)); |
| 802 // Check that the object is in fast mode and writable. | 795 // Check that the object is in fast mode and writable. |
| 803 __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), | 796 __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), |
| 804 Heap::kFixedArrayMapRootIndex); | 797 Heap::kFixedArrayMapRootIndex); |
| 805 __ j(not_equal, &check_pixel_array); | 798 __ j(not_equal, &slow); |
| 806 __ SmiCompareInteger32(FieldOperand(rbx, FixedArray::kLengthOffset), rcx); | 799 __ SmiCompareInteger32(FieldOperand(rbx, FixedArray::kLengthOffset), rcx); |
| 807 // rax: value | 800 // rax: value |
| 808 // rbx: FixedArray | 801 // rbx: FixedArray |
| 809 // rcx: index | 802 // rcx: index |
| 810 __ j(above, &fast); | 803 __ j(above, &fast); |
| 811 | 804 |
| 812 // Slow case: call runtime. | 805 // Slow case: call runtime. |
| 813 __ bind(&slow); | 806 __ bind(&slow); |
| 814 __ Integer32ToSmi(rcx, rcx); | 807 __ Integer32ToSmi(rcx, rcx); |
| 815 __ bind(&slow_with_tagged_index); | 808 __ bind(&slow_with_tagged_index); |
| 816 GenerateRuntimeSetProperty(masm); | 809 GenerateRuntimeSetProperty(masm, strict_mode); |
| 817 // Never returns to here. | 810 // Never returns to here. |
| 818 | 811 |
| 819 // Check whether the elements is a pixel array. | |
| 820 // rax: value | |
| 821 // rdx: receiver | |
| 822 // rbx: receiver's elements array | |
| 823 // rcx: index, zero-extended. | |
| 824 __ bind(&check_pixel_array); | |
| 825 GenerateFastPixelArrayStore(masm, | |
| 826 rdx, | |
| 827 rcx, | |
| 828 rax, | |
| 829 rbx, | |
| 830 rdi, | |
| 831 false, | |
| 832 true, | |
| 833 NULL, | |
| 834 &slow, | |
| 835 &slow, | |
| 836 &slow); | |
| 837 | |
| 838 // Extra capacity case: Check if there is extra capacity to | 812 // Extra capacity case: Check if there is extra capacity to |
| 839 // perform the store and update the length. Used for adding one | 813 // perform the store and update the length. Used for adding one |
| 840 // element to the array by writing to array[array.length]. | 814 // element to the array by writing to array[array.length]. |
| 841 __ bind(&extra); | 815 __ bind(&extra); |
| 842 // rax: value | 816 // rax: value |
| 843 // rdx: receiver (a JSArray) | 817 // rdx: receiver (a JSArray) |
| 844 // rbx: receiver's elements array (a FixedArray) | 818 // rbx: receiver's elements array (a FixedArray) |
| 845 // rcx: index | 819 // rcx: index |
| 846 // flags: smicompare (rdx.length(), rbx) | 820 // flags: smicompare (rdx.length(), rbx) |
| 847 __ j(not_equal, &slow); // do not leave holes in the array | 821 __ j(not_equal, &slow); // do not leave holes in the array |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1467 __ push(rdx); // receiver | 1441 __ push(rdx); // receiver |
| 1468 __ push(rax); // name | 1442 __ push(rax); // name |
| 1469 __ push(rbx); // return address | 1443 __ push(rbx); // return address |
| 1470 | 1444 |
| 1471 // Perform tail call to the entry. | 1445 // Perform tail call to the entry. |
| 1472 __ TailCallRuntime(Runtime::kKeyedGetProperty, 2, 1); | 1446 __ TailCallRuntime(Runtime::kKeyedGetProperty, 2, 1); |
| 1473 } | 1447 } |
| 1474 | 1448 |
| 1475 | 1449 |
| 1476 void StoreIC::GenerateMegamorphic(MacroAssembler* masm, | 1450 void StoreIC::GenerateMegamorphic(MacroAssembler* masm, |
| 1477 Code::ExtraICState extra_ic_state) { | 1451 StrictModeFlag strict_mode) { |
| 1478 // ----------- S t a t e ------------- | 1452 // ----------- S t a t e ------------- |
| 1479 // -- rax : value | 1453 // -- rax : value |
| 1480 // -- rcx : name | 1454 // -- rcx : name |
| 1481 // -- rdx : receiver | 1455 // -- rdx : receiver |
| 1482 // -- rsp[0] : return address | 1456 // -- rsp[0] : return address |
| 1483 // ----------------------------------- | 1457 // ----------------------------------- |
| 1484 | 1458 |
| 1485 // Get the receiver from the stack and probe the stub cache. | 1459 // Get the receiver from the stack and probe the stub cache. |
| 1486 Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, | 1460 Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, |
| 1487 NOT_IN_LOOP, | 1461 NOT_IN_LOOP, |
| 1488 MONOMORPHIC, | 1462 MONOMORPHIC, |
| 1489 extra_ic_state); | 1463 strict_mode); |
| 1490 StubCache::GenerateProbe(masm, flags, rdx, rcx, rbx, no_reg); | 1464 StubCache::GenerateProbe(masm, flags, rdx, rcx, rbx, no_reg); |
| 1491 | 1465 |
| 1492 // Cache miss: Jump to runtime. | 1466 // Cache miss: Jump to runtime. |
| 1493 GenerateMiss(masm); | 1467 GenerateMiss(masm); |
| 1494 } | 1468 } |
| 1495 | 1469 |
| 1496 | 1470 |
| 1497 void StoreIC::GenerateMiss(MacroAssembler* masm) { | 1471 void StoreIC::GenerateMiss(MacroAssembler* masm) { |
| 1498 // ----------- S t a t e ------------- | 1472 // ----------- S t a t e ------------- |
| 1499 // -- rax : value | 1473 // -- rax : value |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 GenerateDictionaryStore(masm, &miss, rbx, rcx, rax, r8, r9); | 1560 GenerateDictionaryStore(masm, &miss, rbx, rcx, rax, r8, r9); |
| 1587 __ IncrementCounter(&Counters::store_normal_hit, 1); | 1561 __ IncrementCounter(&Counters::store_normal_hit, 1); |
| 1588 __ ret(0); | 1562 __ ret(0); |
| 1589 | 1563 |
| 1590 __ bind(&miss); | 1564 __ bind(&miss); |
| 1591 __ IncrementCounter(&Counters::store_normal_miss, 1); | 1565 __ IncrementCounter(&Counters::store_normal_miss, 1); |
| 1592 GenerateMiss(masm); | 1566 GenerateMiss(masm); |
| 1593 } | 1567 } |
| 1594 | 1568 |
| 1595 | 1569 |
| 1596 void StoreIC::GenerateGlobalProxy(MacroAssembler* masm) { | 1570 void StoreIC::GenerateGlobalProxy(MacroAssembler* masm, |
| 1571 StrictModeFlag strict_mode) { |
| 1597 // ----------- S t a t e ------------- | 1572 // ----------- S t a t e ------------- |
| 1598 // -- rax : value | 1573 // -- rax : value |
| 1599 // -- rcx : name | 1574 // -- rcx : name |
| 1600 // -- rdx : receiver | 1575 // -- rdx : receiver |
| 1601 // -- rsp[0] : return address | 1576 // -- rsp[0] : return address |
| 1602 // ----------------------------------- | 1577 // ----------------------------------- |
| 1603 __ pop(rbx); | 1578 __ pop(rbx); |
| 1604 __ push(rdx); | 1579 __ push(rdx); |
| 1605 __ push(rcx); | 1580 __ push(rcx); |
| 1606 __ push(rax); | 1581 __ push(rax); |
| 1607 __ push(rbx); | 1582 __ Push(Smi::FromInt(NONE)); // PropertyAttributes |
| 1583 __ Push(Smi::FromInt(strict_mode)); |
| 1584 __ push(rbx); // return address |
| 1608 | 1585 |
| 1609 // Do tail-call to runtime routine. | 1586 // Do tail-call to runtime routine. |
| 1610 __ TailCallRuntime(Runtime::kSetProperty, 3, 1); | 1587 __ TailCallRuntime(Runtime::kSetProperty, 5, 1); |
| 1611 } | 1588 } |
| 1612 | 1589 |
| 1613 | 1590 |
| 1614 void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm) { | 1591 void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm, |
| 1592 StrictModeFlag strict_mode) { |
| 1615 // ----------- S t a t e ------------- | 1593 // ----------- S t a t e ------------- |
| 1616 // -- rax : value | 1594 // -- rax : value |
| 1617 // -- rcx : key | 1595 // -- rcx : key |
| 1618 // -- rdx : receiver | 1596 // -- rdx : receiver |
| 1619 // -- rsp[0] : return address | 1597 // -- rsp[0] : return address |
| 1620 // ----------------------------------- | 1598 // ----------------------------------- |
| 1621 | 1599 |
| 1622 __ pop(rbx); | 1600 __ pop(rbx); |
| 1623 __ push(rdx); // receiver | 1601 __ push(rdx); // receiver |
| 1624 __ push(rcx); // key | 1602 __ push(rcx); // key |
| 1625 __ push(rax); // value | 1603 __ push(rax); // value |
| 1604 __ Push(Smi::FromInt(NONE)); // PropertyAttributes |
| 1605 __ Push(Smi::FromInt(strict_mode)); // Strict mode. |
| 1626 __ push(rbx); // return address | 1606 __ push(rbx); // return address |
| 1627 | 1607 |
| 1628 // Do tail-call to runtime routine. | 1608 // Do tail-call to runtime routine. |
| 1629 __ TailCallRuntime(Runtime::kSetProperty, 3, 1); | 1609 __ TailCallRuntime(Runtime::kSetProperty, 5, 1); |
| 1630 } | 1610 } |
| 1631 | 1611 |
| 1632 | 1612 |
| 1633 void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { | 1613 void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { |
| 1634 // ----------- S t a t e ------------- | 1614 // ----------- S t a t e ------------- |
| 1635 // -- rax : value | 1615 // -- rax : value |
| 1636 // -- rcx : key | 1616 // -- rcx : key |
| 1637 // -- rdx : receiver | 1617 // -- rdx : receiver |
| 1638 // -- rsp[0] : return address | 1618 // -- rsp[0] : return address |
| 1639 // ----------------------------------- | 1619 // ----------------------------------- |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1745 Condition cc = *jmp_address == Assembler::kJncShortOpcode | 1725 Condition cc = *jmp_address == Assembler::kJncShortOpcode |
| 1746 ? not_zero | 1726 ? not_zero |
| 1747 : zero; | 1727 : zero; |
| 1748 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); | 1728 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
| 1749 } | 1729 } |
| 1750 | 1730 |
| 1751 | 1731 |
| 1752 } } // namespace v8::internal | 1732 } } // namespace v8::internal |
| 1753 | 1733 |
| 1754 #endif // V8_TARGET_ARCH_X64 | 1734 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |