OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // NOLINT | 5 #include "vm/globals.h" // NOLINT |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/heap.h" | 10 #include "vm/heap.h" |
(...skipping 3658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3669 SmiUntag(object); | 3669 SmiUntag(object); |
3670 j(NOT_CARRY, is_smi, kNearJump); | 3670 j(NOT_CARRY, is_smi, kNearJump); |
3671 // Load cid: can't use LoadClassId, object is untagged. Use TIMES_2 scale | 3671 // Load cid: can't use LoadClassId, object is untagged. Use TIMES_2 scale |
3672 // factor in the addressing mode to compensate for this. | 3672 // factor in the addressing mode to compensate for this. |
3673 movl(TMP, Address(object, TIMES_2, class_id_offset)); | 3673 movl(TMP, Address(object, TIMES_2, class_id_offset)); |
3674 cmpl(TMP, Immediate(class_id)); | 3674 cmpl(TMP, Immediate(class_id)); |
3675 } | 3675 } |
3676 | 3676 |
3677 | 3677 |
3678 void Assembler::LoadClassIdMayBeSmi(Register result, Register object) { | 3678 void Assembler::LoadClassIdMayBeSmi(Register result, Register object) { |
3679 ASSERT(result != object); | 3679 Label smi; |
3680 | 3680 |
3681 // Load up a null object. We only need it so we can use LoadClassId on it in | 3681 if (result == object) { |
3682 // the case that object is a Smi. | 3682 Label join; |
3683 LoadObject(result, Object::null_object()); | |
3684 // Check if the object is a Smi. | |
3685 testq(object, Immediate(kSmiTagMask)); | |
3686 // If the object *is* a Smi, use the null object instead. | |
3687 cmoveq(object, result); | |
3688 // Loads either the cid of the object if it isn't a Smi, or the cid of null | |
3689 // if it is a Smi, which will be ignored. | |
3690 LoadClassId(result, object); | |
3691 | 3683 |
3692 movq(TMP, Immediate(kSmiCid)); | 3684 testq(object, Immediate(kSmiTagMask)); |
3693 // If object is a Smi, move the Smi cid into result. o/w leave alone. | 3685 j(EQUAL, &smi, Assembler::kNearJump); |
3694 cmoveq(result, TMP); | 3686 LoadClassId(result, object); |
| 3687 jmp(&join, Assembler::kNearJump); |
| 3688 |
| 3689 Bind(&smi); |
| 3690 movq(result, Immediate(kSmiCid)); |
| 3691 |
| 3692 Bind(&join); |
| 3693 } else { |
| 3694 testq(object, Immediate(kSmiTagMask)); |
| 3695 movq(result, Immediate(kSmiCid)); |
| 3696 j(EQUAL, &smi, Assembler::kNearJump); |
| 3697 LoadClassId(result, object); |
| 3698 |
| 3699 Bind(&smi); |
| 3700 } |
3695 } | 3701 } |
3696 | 3702 |
3697 | 3703 |
3698 void Assembler::LoadTaggedClassIdMayBeSmi(Register result, Register object) { | 3704 void Assembler::LoadTaggedClassIdMayBeSmi(Register result, Register object) { |
3699 LoadClassIdMayBeSmi(result, object); | 3705 Label smi; |
3700 // Finally, tag the result. | 3706 |
3701 SmiTag(result); | 3707 if (result == object) { |
| 3708 Label join; |
| 3709 |
| 3710 testq(object, Immediate(kSmiTagMask)); |
| 3711 j(EQUAL, &smi, Assembler::kNearJump); |
| 3712 LoadClassId(result, object); |
| 3713 SmiTag(result); |
| 3714 jmp(&join, Assembler::kNearJump); |
| 3715 |
| 3716 Bind(&smi); |
| 3717 movq(result, Immediate(Smi::RawValue(kSmiCid))); |
| 3718 |
| 3719 Bind(&join); |
| 3720 } else { |
| 3721 testq(object, Immediate(kSmiTagMask)); |
| 3722 movq(result, Immediate(kSmiCid)); |
| 3723 j(EQUAL, &smi, Assembler::kNearJump); |
| 3724 LoadClassId(result, object); |
| 3725 |
| 3726 Bind(&smi); |
| 3727 SmiTag(result); |
| 3728 } |
3702 } | 3729 } |
3703 | 3730 |
3704 | 3731 |
3705 Address Assembler::ElementAddressForIntIndex(bool is_external, | 3732 Address Assembler::ElementAddressForIntIndex(bool is_external, |
3706 intptr_t cid, | 3733 intptr_t cid, |
3707 intptr_t index_scale, | 3734 intptr_t index_scale, |
3708 Register array, | 3735 Register array, |
3709 intptr_t index) { | 3736 intptr_t index) { |
3710 if (is_external) { | 3737 if (is_external) { |
3711 return Address(array, index * index_scale); | 3738 return Address(array, index * index_scale); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3772 | 3799 |
3773 | 3800 |
3774 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3801 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
3775 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 3802 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
3776 return xmm_reg_names[reg]; | 3803 return xmm_reg_names[reg]; |
3777 } | 3804 } |
3778 | 3805 |
3779 } // namespace dart | 3806 } // namespace dart |
3780 | 3807 |
3781 #endif // defined TARGET_ARCH_X64 | 3808 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |