| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
| 6 | 6 |
| 7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
| 8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
| (...skipping 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 | 1612 |
| 1613 void MacroAssembler::AssertNotSmi(Register object, BailoutReason reason) { | 1613 void MacroAssembler::AssertNotSmi(Register object, BailoutReason reason) { |
| 1614 if (emit_debug_code()) { | 1614 if (emit_debug_code()) { |
| 1615 STATIC_ASSERT(kSmiTag == 0); | 1615 STATIC_ASSERT(kSmiTag == 0); |
| 1616 Tst(object, kSmiTagMask); | 1616 Tst(object, kSmiTagMask); |
| 1617 Check(ne, reason); | 1617 Check(ne, reason); |
| 1618 } | 1618 } |
| 1619 } | 1619 } |
| 1620 | 1620 |
| 1621 | 1621 |
| 1622 void MacroAssembler::AssertName(Register object) { | |
| 1623 if (emit_debug_code()) { | |
| 1624 AssertNotSmi(object, kOperandIsASmiAndNotAName); | |
| 1625 | |
| 1626 UseScratchRegisterScope temps(this); | |
| 1627 Register temp = temps.AcquireX(); | |
| 1628 | |
| 1629 Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset)); | |
| 1630 CompareInstanceType(temp, temp, LAST_NAME_TYPE); | |
| 1631 Check(ls, kOperandIsNotAName); | |
| 1632 } | |
| 1633 } | |
| 1634 | |
| 1635 | |
| 1636 void MacroAssembler::AssertFunction(Register object) { | 1622 void MacroAssembler::AssertFunction(Register object) { |
| 1637 if (emit_debug_code()) { | 1623 if (emit_debug_code()) { |
| 1638 AssertNotSmi(object, kOperandIsASmiAndNotAFunction); | 1624 AssertNotSmi(object, kOperandIsASmiAndNotAFunction); |
| 1639 | 1625 |
| 1640 UseScratchRegisterScope temps(this); | 1626 UseScratchRegisterScope temps(this); |
| 1641 Register temp = temps.AcquireX(); | 1627 Register temp = temps.AcquireX(); |
| 1642 | 1628 |
| 1643 CompareObjectType(object, temp, temp, JS_FUNCTION_TYPE); | 1629 CompareObjectType(object, temp, temp, JS_FUNCTION_TYPE); |
| 1644 Check(eq, kOperandIsNotAFunction); | 1630 Check(eq, kOperandIsNotAFunction); |
| 1645 } | 1631 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1663 AssertNotSmi(object, kOperandIsASmiAndNotAGeneratorObject); | 1649 AssertNotSmi(object, kOperandIsASmiAndNotAGeneratorObject); |
| 1664 | 1650 |
| 1665 UseScratchRegisterScope temps(this); | 1651 UseScratchRegisterScope temps(this); |
| 1666 Register temp = temps.AcquireX(); | 1652 Register temp = temps.AcquireX(); |
| 1667 | 1653 |
| 1668 CompareObjectType(object, temp, temp, JS_GENERATOR_OBJECT_TYPE); | 1654 CompareObjectType(object, temp, temp, JS_GENERATOR_OBJECT_TYPE); |
| 1669 Check(eq, kOperandIsNotAGeneratorObject); | 1655 Check(eq, kOperandIsNotAGeneratorObject); |
| 1670 } | 1656 } |
| 1671 } | 1657 } |
| 1672 | 1658 |
| 1673 void MacroAssembler::AssertReceiver(Register object) { | |
| 1674 if (emit_debug_code()) { | |
| 1675 AssertNotSmi(object, kOperandIsASmiAndNotAReceiver); | |
| 1676 | |
| 1677 UseScratchRegisterScope temps(this); | |
| 1678 Register temp = temps.AcquireX(); | |
| 1679 | |
| 1680 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); | |
| 1681 CompareObjectType(object, temp, temp, FIRST_JS_RECEIVER_TYPE); | |
| 1682 Check(hs, kOperandIsNotAReceiver); | |
| 1683 } | |
| 1684 } | |
| 1685 | |
| 1686 | |
| 1687 void MacroAssembler::AssertUndefinedOrAllocationSite(Register object, | 1659 void MacroAssembler::AssertUndefinedOrAllocationSite(Register object, |
| 1688 Register scratch) { | 1660 Register scratch) { |
| 1689 if (emit_debug_code()) { | 1661 if (emit_debug_code()) { |
| 1690 Label done_checking; | 1662 Label done_checking; |
| 1691 AssertNotSmi(object); | 1663 AssertNotSmi(object); |
| 1692 JumpIfRoot(object, Heap::kUndefinedValueRootIndex, &done_checking); | 1664 JumpIfRoot(object, Heap::kUndefinedValueRootIndex, &done_checking); |
| 1693 Ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); | 1665 Ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); |
| 1694 CompareRoot(scratch, Heap::kAllocationSiteMapRootIndex); | 1666 CompareRoot(scratch, Heap::kAllocationSiteMapRootIndex); |
| 1695 Assert(eq, kExpectedUndefinedOrCell); | 1667 Assert(eq, kExpectedUndefinedOrCell); |
| 1696 Bind(&done_checking); | 1668 Bind(&done_checking); |
| 1697 } | 1669 } |
| 1698 } | 1670 } |
| 1699 | 1671 |
| 1700 | 1672 |
| 1701 void MacroAssembler::AssertString(Register object) { | |
| 1702 if (emit_debug_code()) { | |
| 1703 UseScratchRegisterScope temps(this); | |
| 1704 Register temp = temps.AcquireX(); | |
| 1705 STATIC_ASSERT(kSmiTag == 0); | |
| 1706 Tst(object, kSmiTagMask); | |
| 1707 Check(ne, kOperandIsASmiAndNotAString); | |
| 1708 Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset)); | |
| 1709 CompareInstanceType(temp, temp, FIRST_NONSTRING_TYPE); | |
| 1710 Check(lo, kOperandIsNotAString); | |
| 1711 } | |
| 1712 } | |
| 1713 | |
| 1714 | |
| 1715 void MacroAssembler::AssertPositiveOrZero(Register value) { | 1673 void MacroAssembler::AssertPositiveOrZero(Register value) { |
| 1716 if (emit_debug_code()) { | 1674 if (emit_debug_code()) { |
| 1717 Label done; | 1675 Label done; |
| 1718 int sign_bit = value.Is64Bits() ? kXSignBit : kWSignBit; | 1676 int sign_bit = value.Is64Bits() ? kXSignBit : kWSignBit; |
| 1719 Tbz(value, sign_bit, &done); | 1677 Tbz(value, sign_bit, &done); |
| 1720 Abort(kUnexpectedNegativeValue); | 1678 Abort(kUnexpectedNegativeValue); |
| 1721 Bind(&done); | 1679 Bind(&done); |
| 1722 } | 1680 } |
| 1723 } | 1681 } |
| 1724 | 1682 |
| 1725 void MacroAssembler::AssertNotNumber(Register value) { | |
| 1726 if (emit_debug_code()) { | |
| 1727 STATIC_ASSERT(kSmiTag == 0); | |
| 1728 Tst(value, kSmiTagMask); | |
| 1729 Check(ne, kOperandIsANumber); | |
| 1730 Label done; | |
| 1731 JumpIfNotHeapNumber(value, &done); | |
| 1732 Abort(kOperandIsANumber); | |
| 1733 Bind(&done); | |
| 1734 } | |
| 1735 } | |
| 1736 | |
| 1737 void MacroAssembler::AssertNumber(Register value) { | |
| 1738 if (emit_debug_code()) { | |
| 1739 Label done; | |
| 1740 JumpIfSmi(value, &done); | |
| 1741 JumpIfHeapNumber(value, &done); | |
| 1742 Abort(kOperandIsNotANumber); | |
| 1743 Bind(&done); | |
| 1744 } | |
| 1745 } | |
| 1746 | |
| 1747 void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) { | 1683 void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) { |
| 1748 DCHECK(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs. | 1684 DCHECK(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs. |
| 1749 Call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id); | 1685 Call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id); |
| 1750 } | 1686 } |
| 1751 | 1687 |
| 1752 | 1688 |
| 1753 void MacroAssembler::TailCallStub(CodeStub* stub) { | 1689 void MacroAssembler::TailCallStub(CodeStub* stub) { |
| 1754 Jump(stub->GetCode(), RelocInfo::CODE_TARGET); | 1690 Jump(stub->GetCode(), RelocInfo::CODE_TARGET); |
| 1755 } | 1691 } |
| 1756 | 1692 |
| (...skipping 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3348 SmiCheckType smi_check_type) { | 3284 SmiCheckType smi_check_type) { |
| 3349 if (smi_check_type == DO_SMI_CHECK) { | 3285 if (smi_check_type == DO_SMI_CHECK) { |
| 3350 JumpIfSmi(obj_map, fail); | 3286 JumpIfSmi(obj_map, fail); |
| 3351 } | 3287 } |
| 3352 | 3288 |
| 3353 CompareMap(obj_map, map); | 3289 CompareMap(obj_map, map); |
| 3354 B(ne, fail); | 3290 B(ne, fail); |
| 3355 } | 3291 } |
| 3356 | 3292 |
| 3357 | 3293 |
| 3358 void MacroAssembler::DispatchWeakMap(Register obj, Register scratch1, | |
| 3359 Register scratch2, Handle<WeakCell> cell, | |
| 3360 Handle<Code> success, | |
| 3361 SmiCheckType smi_check_type) { | |
| 3362 Label fail; | |
| 3363 if (smi_check_type == DO_SMI_CHECK) { | |
| 3364 JumpIfSmi(obj, &fail); | |
| 3365 } | |
| 3366 Ldr(scratch1, FieldMemOperand(obj, HeapObject::kMapOffset)); | |
| 3367 CmpWeakValue(scratch1, cell, scratch2); | |
| 3368 B(ne, &fail); | |
| 3369 Jump(success, RelocInfo::CODE_TARGET); | |
| 3370 Bind(&fail); | |
| 3371 } | |
| 3372 | |
| 3373 | |
| 3374 void MacroAssembler::CmpWeakValue(Register value, Handle<WeakCell> cell, | |
| 3375 Register scratch) { | |
| 3376 Mov(scratch, Operand(cell)); | |
| 3377 Ldr(scratch, FieldMemOperand(scratch, WeakCell::kValueOffset)); | |
| 3378 Cmp(value, scratch); | |
| 3379 } | |
| 3380 | |
| 3381 | |
| 3382 void MacroAssembler::GetWeakValue(Register value, Handle<WeakCell> cell) { | 3294 void MacroAssembler::GetWeakValue(Register value, Handle<WeakCell> cell) { |
| 3383 Mov(value, Operand(cell)); | 3295 Mov(value, Operand(cell)); |
| 3384 Ldr(value, FieldMemOperand(value, WeakCell::kValueOffset)); | 3296 Ldr(value, FieldMemOperand(value, WeakCell::kValueOffset)); |
| 3385 } | 3297 } |
| 3386 | 3298 |
| 3387 | 3299 |
| 3388 void MacroAssembler::LoadWeakValue(Register value, Handle<WeakCell> cell, | 3300 void MacroAssembler::LoadWeakValue(Register value, Handle<WeakCell> cell, |
| 3389 Label* miss) { | 3301 Label* miss) { |
| 3390 GetWeakValue(value, cell); | 3302 GetWeakValue(value, cell); |
| 3391 JumpIfSmi(value, miss); | 3303 JumpIfSmi(value, miss); |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4093 void MacroAssembler::AssertRegisterIsRoot(Register reg, | 4005 void MacroAssembler::AssertRegisterIsRoot(Register reg, |
| 4094 Heap::RootListIndex index, | 4006 Heap::RootListIndex index, |
| 4095 BailoutReason reason) { | 4007 BailoutReason reason) { |
| 4096 if (emit_debug_code()) { | 4008 if (emit_debug_code()) { |
| 4097 CompareRoot(reg, index); | 4009 CompareRoot(reg, index); |
| 4098 Check(eq, reason); | 4010 Check(eq, reason); |
| 4099 } | 4011 } |
| 4100 } | 4012 } |
| 4101 | 4013 |
| 4102 | 4014 |
| 4103 void MacroAssembler::AssertFastElements(Register elements) { | |
| 4104 if (emit_debug_code()) { | |
| 4105 UseScratchRegisterScope temps(this); | |
| 4106 Register temp = temps.AcquireX(); | |
| 4107 Label ok; | |
| 4108 Ldr(temp, FieldMemOperand(elements, HeapObject::kMapOffset)); | |
| 4109 JumpIfRoot(temp, Heap::kFixedArrayMapRootIndex, &ok); | |
| 4110 JumpIfRoot(temp, Heap::kFixedDoubleArrayMapRootIndex, &ok); | |
| 4111 JumpIfRoot(temp, Heap::kFixedCOWArrayMapRootIndex, &ok); | |
| 4112 Abort(kJSObjectWithFastElementsMapHasSlowElements); | |
| 4113 Bind(&ok); | |
| 4114 } | |
| 4115 } | |
| 4116 | |
| 4117 | 4015 |
| 4118 void MacroAssembler::AssertIsString(const Register& object) { | 4016 void MacroAssembler::AssertIsString(const Register& object) { |
| 4119 if (emit_debug_code()) { | 4017 if (emit_debug_code()) { |
| 4120 UseScratchRegisterScope temps(this); | 4018 UseScratchRegisterScope temps(this); |
| 4121 Register temp = temps.AcquireX(); | 4019 Register temp = temps.AcquireX(); |
| 4122 STATIC_ASSERT(kSmiTag == 0); | 4020 STATIC_ASSERT(kSmiTag == 0); |
| 4123 Tst(object, kSmiTagMask); | 4021 Tst(object, kSmiTagMask); |
| 4124 Check(ne, kOperandIsNotAString); | 4022 Check(ne, kOperandIsNotAString); |
| 4125 Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset)); | 4023 Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset)); |
| 4126 CompareInstanceType(temp, temp, FIRST_NONSTRING_TYPE); | 4024 CompareInstanceType(temp, temp, FIRST_NONSTRING_TYPE); |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4656 } | 4554 } |
| 4657 | 4555 |
| 4658 | 4556 |
| 4659 #undef __ | 4557 #undef __ |
| 4660 | 4558 |
| 4661 | 4559 |
| 4662 } // namespace internal | 4560 } // namespace internal |
| 4663 } // namespace v8 | 4561 } // namespace v8 |
| 4664 | 4562 |
| 4665 #endif // V8_TARGET_ARCH_ARM64 | 4563 #endif // V8_TARGET_ARCH_ARM64 |
| OLD | NEW |