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 3606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3617 EmitRegisterREX(operand, REX_W); | 3617 EmitRegisterREX(operand, REX_W); |
3618 } else { | 3618 } else { |
3619 EmitRegisterREX(operand, REX_NONE); | 3619 EmitRegisterREX(operand, REX_NONE); |
3620 } | 3620 } |
3621 EmitUint8(0xD3); | 3621 EmitUint8(0xD3); |
3622 EmitOperand(rm, Operand(operand)); | 3622 EmitOperand(rm, Operand(operand)); |
3623 } | 3623 } |
3624 | 3624 |
3625 | 3625 |
3626 void Assembler::LoadClassId(Register result, Register object) { | 3626 void Assembler::LoadClassId(Register result, Register object) { |
3627 ASSERT(RawObject::kClassIdTagPos == 16); | 3627 ASSERT(RawObject::kClassIdTagPos == kBitsPerInt32); |
3628 ASSERT(RawObject::kClassIdTagSize == 16); | 3628 ASSERT(RawObject::kClassIdTagSize == kBitsPerInt32); |
3629 ASSERT(sizeof(classid_t) == sizeof(uint16_t)); | 3629 ASSERT(sizeof(classid_t) == sizeof(uint32_t)); |
3630 const intptr_t class_id_offset = | 3630 const intptr_t class_id_offset = |
3631 Object::tags_offset() + RawObject::kClassIdTagPos / kBitsPerByte; | 3631 Object::tags_offset() + RawObject::kClassIdTagPos / kBitsPerByte; |
3632 movzxw(result, FieldAddress(object, class_id_offset)); | 3632 movl(result, FieldAddress(object, class_id_offset)); |
3633 } | 3633 } |
3634 | 3634 |
3635 | 3635 |
3636 void Assembler::LoadClassById(Register result, Register class_id) { | 3636 void Assembler::LoadClassById(Register result, Register class_id) { |
3637 ASSERT(result != class_id); | 3637 ASSERT(result != class_id); |
3638 LoadIsolate(result); | 3638 LoadIsolate(result); |
3639 const intptr_t offset = | 3639 const intptr_t offset = |
3640 Isolate::class_table_offset() + ClassTable::table_offset(); | 3640 Isolate::class_table_offset() + ClassTable::table_offset(); |
3641 movq(result, Address(result, offset)); | 3641 movq(result, Address(result, offset)); |
3642 movq(result, Address(result, class_id, TIMES_8, 0)); | 3642 movq(result, Address(result, class_id, TIMES_8, 0)); |
3643 } | 3643 } |
3644 | 3644 |
3645 | 3645 |
3646 void Assembler::LoadClass(Register result, Register object) { | 3646 void Assembler::LoadClass(Register result, Register object) { |
3647 LoadClassId(TMP, object); | 3647 LoadClassId(TMP, object); |
3648 LoadClassById(result, TMP); | 3648 LoadClassById(result, TMP); |
3649 } | 3649 } |
3650 | 3650 |
3651 | 3651 |
3652 void Assembler::CompareClassId(Register object, intptr_t class_id) { | 3652 void Assembler::CompareClassId(Register object, intptr_t class_id) { |
3653 LoadClassId(TMP, object); | 3653 LoadClassId(TMP, object); |
3654 cmpl(TMP, Immediate(class_id)); | 3654 cmpl(TMP, Immediate(class_id)); |
3655 } | 3655 } |
3656 | 3656 |
3657 | 3657 |
3658 void Assembler::SmiUntagOrCheckClass(Register object, | 3658 void Assembler::SmiUntagOrCheckClass(Register object, |
3659 intptr_t class_id, | 3659 intptr_t class_id, |
3660 Label* is_smi) { | 3660 Label* is_smi) { |
3661 ASSERT(kSmiTagShift == 1); | 3661 ASSERT(kSmiTagShift == 1); |
3662 ASSERT(RawObject::kClassIdTagPos == 16); | 3662 ASSERT(RawObject::kClassIdTagPos == kBitsPerInt32); |
3663 ASSERT(RawObject::kClassIdTagSize == 16); | 3663 ASSERT(RawObject::kClassIdTagSize == kBitsPerInt32); |
3664 ASSERT(sizeof(classid_t) == sizeof(uint16_t)); | 3664 ASSERT(sizeof(classid_t) == sizeof(uint32_t)); |
3665 const intptr_t class_id_offset = | 3665 const intptr_t class_id_offset = |
3666 Object::tags_offset() + RawObject::kClassIdTagPos / kBitsPerByte; | 3666 Object::tags_offset() + RawObject::kClassIdTagPos / kBitsPerByte; |
3667 | 3667 |
3668 // Untag optimistically. Tag bit is shifted into the CARRY. | 3668 // Untag optimistically. Tag bit is shifted into the CARRY. |
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 movzxw(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 Label smi; | 3679 Label smi; |
3680 | 3680 |
3681 if (result == object) { | 3681 if (result == object) { |
3682 Label join; | 3682 Label join; |
3683 | 3683 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3799 | 3799 |
3800 | 3800 |
3801 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3801 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
3802 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 3802 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
3803 return xmm_reg_names[reg]; | 3803 return xmm_reg_names[reg]; |
3804 } | 3804 } |
3805 | 3805 |
3806 } // namespace dart | 3806 } // namespace dart |
3807 | 3807 |
3808 #endif // defined TARGET_ARCH_X64 | 3808 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |