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_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 2885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2896 SmiUntag(object); | 2896 SmiUntag(object); |
2897 j(NOT_CARRY, is_smi, kNearJump); | 2897 j(NOT_CARRY, is_smi, kNearJump); |
2898 // Load cid: can't use LoadClassId, object is untagged. Use TIMES_2 scale | 2898 // Load cid: can't use LoadClassId, object is untagged. Use TIMES_2 scale |
2899 // factor in the addressing mode to compensate for this. | 2899 // factor in the addressing mode to compensate for this. |
2900 movzxw(scratch, Address(object, TIMES_2, class_id_offset)); | 2900 movzxw(scratch, Address(object, TIMES_2, class_id_offset)); |
2901 cmpl(scratch, Immediate(class_id)); | 2901 cmpl(scratch, Immediate(class_id)); |
2902 } | 2902 } |
2903 | 2903 |
2904 | 2904 |
2905 void Assembler::LoadClassIdMayBeSmi(Register result, Register object) { | 2905 void Assembler::LoadClassIdMayBeSmi(Register result, Register object) { |
2906 ASSERT(result != object); | 2906 Label smi, join; |
2907 static const intptr_t kSmiCidSource = kSmiCid << RawObject::kClassIdTagPos; | |
2908 | 2907 |
2909 // Make a dummy "Object" whose cid is kSmiCid. | 2908 testl(object, Immediate(kSmiTagMask)); |
2910 movl(result, Immediate(reinterpret_cast<int32_t>(&kSmiCidSource) + 1)); | 2909 j(EQUAL, &smi, Assembler::kNearJump); |
| 2910 LoadClassId(result, object); |
| 2911 jmp(&join, Assembler::kNearJump); |
2911 | 2912 |
2912 // Check if object (in tmp) is a Smi. | 2913 Bind(&smi); |
2913 testl(object, Immediate(kSmiTagMask)); | 2914 movl(result, Immediate(kSmiCid)); |
2914 | 2915 |
2915 // If the object is not a Smi, use the original object to load the cid. | 2916 Bind(&join); |
2916 // Otherwise, the dummy object is used, and the result is kSmiCid. | |
2917 cmovne(result, object); | |
2918 LoadClassId(result, result); | |
2919 } | 2917 } |
2920 | 2918 |
2921 | 2919 |
2922 void Assembler::LoadTaggedClassIdMayBeSmi(Register result, Register object) { | 2920 void Assembler::LoadTaggedClassIdMayBeSmi(Register result, Register object) { |
2923 LoadClassIdMayBeSmi(result, object); | 2921 Label smi, join; |
2924 // Tag the result. | 2922 |
| 2923 testl(object, Immediate(kSmiTagMask)); |
| 2924 j(EQUAL, &smi, Assembler::kNearJump); |
| 2925 LoadClassId(result, object); |
2925 SmiTag(result); | 2926 SmiTag(result); |
| 2927 jmp(&join, Assembler::kNearJump); |
| 2928 |
| 2929 Bind(&smi); |
| 2930 movl(result, Immediate(Smi::RawValue(kSmiCid))); |
| 2931 |
| 2932 Bind(&join); |
2926 } | 2933 } |
2927 | 2934 |
2928 | 2935 |
2929 Address Assembler::ElementAddressForIntIndex(bool is_external, | 2936 Address Assembler::ElementAddressForIntIndex(bool is_external, |
2930 intptr_t cid, | 2937 intptr_t cid, |
2931 intptr_t index_scale, | 2938 intptr_t index_scale, |
2932 Register array, | 2939 Register array, |
2933 intptr_t index) { | 2940 intptr_t index) { |
2934 if (is_external) { | 2941 if (is_external) { |
2935 return Address(array, index * index_scale); | 2942 return Address(array, index * index_scale); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2995 | 3002 |
2996 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3003 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
2997 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 3004 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
2998 return xmm_reg_names[reg]; | 3005 return xmm_reg_names[reg]; |
2999 } | 3006 } |
3000 | 3007 |
3001 | 3008 |
3002 } // namespace dart | 3009 } // namespace dart |
3003 | 3010 |
3004 #endif // defined TARGET_ARCH_IA32 | 3011 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |