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" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 2723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2734 // If the object is not a Smi, use the original object to load the cid. | 2734 // If the object is not a Smi, use the original object to load the cid. |
2735 // Otherwise, the dummy object is used, and the result is kSmiCid. | 2735 // Otherwise, the dummy object is used, and the result is kSmiCid. |
2736 cmovne(result, object); | 2736 cmovne(result, object); |
2737 LoadClassId(result, result); | 2737 LoadClassId(result, result); |
2738 | 2738 |
2739 // Tag the result. | 2739 // Tag the result. |
2740 SmiTag(result); | 2740 SmiTag(result); |
2741 } | 2741 } |
2742 | 2742 |
2743 | 2743 |
| 2744 Address Assembler::ElementAddressForIntIndex(bool is_external, |
| 2745 intptr_t cid, |
| 2746 intptr_t index_scale, |
| 2747 Register array, |
| 2748 intptr_t index) { |
| 2749 if (is_external) { |
| 2750 return Address(array, index * index_scale); |
| 2751 } else { |
| 2752 const int64_t disp = static_cast<int64_t>(index) * index_scale + |
| 2753 Instance::DataOffsetFor(cid); |
| 2754 ASSERT(Utils::IsInt(32, disp)); |
| 2755 return FieldAddress(array, static_cast<int32_t>(disp)); |
| 2756 } |
| 2757 } |
| 2758 |
| 2759 |
| 2760 static ScaleFactor ToScaleFactor(intptr_t index_scale) { |
| 2761 // Note that index is expected smi-tagged, (i.e, times 2) for all arrays with |
| 2762 // index scale factor > 1. E.g., for Uint8Array and OneByteString the index is |
| 2763 // expected to be untagged before accessing. |
| 2764 ASSERT(kSmiTagShift == 1); |
| 2765 switch (index_scale) { |
| 2766 case 1: return TIMES_1; |
| 2767 case 2: return TIMES_1; |
| 2768 case 4: return TIMES_2; |
| 2769 case 8: return TIMES_4; |
| 2770 case 16: return TIMES_8; |
| 2771 default: |
| 2772 UNREACHABLE(); |
| 2773 return TIMES_1; |
| 2774 } |
| 2775 } |
| 2776 |
| 2777 |
| 2778 Address Assembler::ElementAddressForRegIndex(bool is_external, |
| 2779 intptr_t cid, |
| 2780 intptr_t index_scale, |
| 2781 Register array, |
| 2782 Register index) { |
| 2783 if (is_external) { |
| 2784 return Address(array, index, ToScaleFactor(index_scale), 0); |
| 2785 } else { |
| 2786 return FieldAddress(array, |
| 2787 index, |
| 2788 ToScaleFactor(index_scale), |
| 2789 Instance::DataOffsetFor(cid)); |
| 2790 } |
| 2791 } |
| 2792 |
| 2793 |
2744 static const char* cpu_reg_names[kNumberOfCpuRegisters] = { | 2794 static const char* cpu_reg_names[kNumberOfCpuRegisters] = { |
2745 "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" | 2795 "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" |
2746 }; | 2796 }; |
2747 | 2797 |
2748 | 2798 |
2749 const char* Assembler::RegisterName(Register reg) { | 2799 const char* Assembler::RegisterName(Register reg) { |
2750 ASSERT((0 <= reg) && (reg < kNumberOfCpuRegisters)); | 2800 ASSERT((0 <= reg) && (reg < kNumberOfCpuRegisters)); |
2751 return cpu_reg_names[reg]; | 2801 return cpu_reg_names[reg]; |
2752 } | 2802 } |
2753 | 2803 |
2754 | 2804 |
2755 static const char* xmm_reg_names[kNumberOfXmmRegisters] = { | 2805 static const char* xmm_reg_names[kNumberOfXmmRegisters] = { |
2756 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" | 2806 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
2757 }; | 2807 }; |
2758 | 2808 |
2759 | 2809 |
2760 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 2810 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
2761 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 2811 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
2762 return xmm_reg_names[reg]; | 2812 return xmm_reg_names[reg]; |
2763 } | 2813 } |
2764 | 2814 |
2765 | 2815 |
2766 } // namespace dart | 2816 } // namespace dart |
2767 | 2817 |
2768 #endif // defined TARGET_ARCH_IA32 | 2818 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |