OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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" // Needed here to get TARGET_ARCH_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
7 | 7 |
8 #include "vm/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
9 | 9 |
10 #include "lib/error.h" | 10 #include "lib/error.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 const Register kClassIdReg = ECX; | 276 const Register kClassIdReg = ECX; |
277 __ LoadClassId(kClassIdReg, kInstanceReg); | 277 __ LoadClassId(kClassIdReg, kInstanceReg); |
278 // If type is an interface, we can skip the class equality check. | 278 // If type is an interface, we can skip the class equality check. |
279 if (!type_class.is_interface()) { | 279 if (!type_class.is_interface()) { |
280 __ cmpl(kClassIdReg, Immediate(type_class.id())); | 280 __ cmpl(kClassIdReg, Immediate(type_class.id())); |
281 __ j(EQUAL, is_instance_lbl); | 281 __ j(EQUAL, is_instance_lbl); |
282 } | 282 } |
283 // Bool interface can be implemented only by core class Bool. | 283 // Bool interface can be implemented only by core class Bool. |
284 // (see ClassFinalizer::ResolveInterfaces for list of restricted interfaces). | 284 // (see ClassFinalizer::ResolveInterfaces for list of restricted interfaces). |
285 if (type.IsBoolInterface()) { | 285 if (type.IsBoolInterface()) { |
286 __ cmpl(kClassIdReg, Immediate(kBool)); | 286 __ cmpl(kClassIdReg, Immediate(kBoolCid)); |
287 __ j(EQUAL, is_instance_lbl); | 287 __ j(EQUAL, is_instance_lbl); |
288 __ jmp(is_not_instance_lbl); | 288 __ jmp(is_not_instance_lbl); |
289 return false; | 289 return false; |
290 } | 290 } |
291 if (type.IsFunctionInterface()) { | 291 if (type.IsFunctionInterface()) { |
292 // Check if instance is a closure. | 292 // Check if instance is a closure. |
293 const Immediate raw_null = | 293 const Immediate raw_null = |
294 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 294 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
295 __ LoadClassById(EDI, kClassIdReg); | 295 __ LoadClassById(EDI, kClassIdReg); |
296 __ movl(EDI, FieldAddress(EDI, Class::signature_function_offset())); | 296 __ movl(EDI, FieldAddress(EDI, Class::signature_function_offset())); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 const TypeParameter& type_param = TypeParameter::Cast(type); | 363 const TypeParameter& type_param = TypeParameter::Cast(type); |
364 // Load instantiator (or null) and instantiator type arguments on stack. | 364 // Load instantiator (or null) and instantiator type arguments on stack. |
365 __ movl(EDX, Address(ESP, 0)); // Get instantiator type arguments. | 365 __ movl(EDX, Address(ESP, 0)); // Get instantiator type arguments. |
366 // EDX: instantiator type arguments. | 366 // EDX: instantiator type arguments. |
367 // Check if type argument is Dynamic. | 367 // Check if type argument is Dynamic. |
368 __ cmpl(EDX, raw_null); | 368 __ cmpl(EDX, raw_null); |
369 __ j(EQUAL, is_instance_lbl); | 369 __ j(EQUAL, is_instance_lbl); |
370 // Can handle only type arguments that are instances of TypeArguments. | 370 // Can handle only type arguments that are instances of TypeArguments. |
371 // (runtime checks canonicalize type arguments). | 371 // (runtime checks canonicalize type arguments). |
372 Label fall_through; | 372 Label fall_through; |
373 __ CompareClassId(EDX, kTypeArguments, EDI); | 373 __ CompareClassId(EDX, kTypeArgumentsCid, EDI); |
374 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump); | 374 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump); |
375 __ movl(EDI, | 375 __ movl(EDI, |
376 FieldAddress(EDX, TypeArguments::type_at_offset(type_param.index()))); | 376 FieldAddress(EDX, TypeArguments::type_at_offset(type_param.index()))); |
377 // EDI: concrete type of type. | 377 // EDI: concrete type of type. |
378 // Check if type argument is dynamic. | 378 // Check if type argument is dynamic. |
379 __ CompareObject(EDI, Type::ZoneHandle(Type::DynamicType())); | 379 __ CompareObject(EDI, Type::ZoneHandle(Type::DynamicType())); |
380 __ j(EQUAL, is_instance_lbl); | 380 __ j(EQUAL, is_instance_lbl); |
381 __ cmpl(EDI, raw_null); | 381 __ cmpl(EDI, raw_null); |
382 __ j(EQUAL, is_instance_lbl); | 382 __ j(EQUAL, is_instance_lbl); |
383 const Type& object_type = Type::ZoneHandle(Type::ObjectType()); | 383 const Type& object_type = Type::ZoneHandle(Type::ObjectType()); |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 __ movl(EAX, raw_null); | 900 __ movl(EAX, raw_null); |
901 __ ret(); | 901 __ ret(); |
902 } | 902 } |
903 | 903 |
904 | 904 |
905 void FlowGraphCompiler::GenerateInlinedMathSqrt(Label* done) { | 905 void FlowGraphCompiler::GenerateInlinedMathSqrt(Label* done) { |
906 Label smi_to_double, double_op, call_method; | 906 Label smi_to_double, double_op, call_method; |
907 __ movl(EAX, Address(ESP, 0)); | 907 __ movl(EAX, Address(ESP, 0)); |
908 __ testl(EAX, Immediate(kSmiTagMask)); | 908 __ testl(EAX, Immediate(kSmiTagMask)); |
909 __ j(ZERO, &smi_to_double); | 909 __ j(ZERO, &smi_to_double); |
910 __ CompareClassId(EAX, kDouble, EBX); | 910 __ CompareClassId(EAX, kDoubleCid, EBX); |
911 __ j(NOT_EQUAL, &call_method); | 911 __ j(NOT_EQUAL, &call_method); |
912 __ movsd(XMM1, FieldAddress(EAX, Double::value_offset())); | 912 __ movsd(XMM1, FieldAddress(EAX, Double::value_offset())); |
913 __ Bind(&double_op); | 913 __ Bind(&double_op); |
914 __ sqrtsd(XMM0, XMM1); | 914 __ sqrtsd(XMM0, XMM1); |
915 AssemblerMacros::TryAllocate(assembler_, | 915 AssemblerMacros::TryAllocate(assembler_, |
916 double_class_, | 916 double_class_, |
917 &call_method, | 917 &call_method, |
918 EAX); // Result register. | 918 EAX); // Result register. |
919 __ movsd(FieldAddress(EAX, Double::value_offset()), XMM0); | 919 __ movsd(FieldAddress(EAX, Double::value_offset()), XMM0); |
920 __ Drop(1); | 920 __ Drop(1); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 } | 1076 } |
1077 | 1077 |
1078 | 1078 |
1079 // Checks class id of instance against all 'class_ids'. Jump to 'deopt' label | 1079 // Checks class id of instance against all 'class_ids'. Jump to 'deopt' label |
1080 // if no match or instance is Smi. | 1080 // if no match or instance is Smi. |
1081 void FlowGraphCompiler::EmitClassChecksNoSmi(const ICData& ic_data, | 1081 void FlowGraphCompiler::EmitClassChecksNoSmi(const ICData& ic_data, |
1082 Register instance_reg, | 1082 Register instance_reg, |
1083 Register temp_reg, | 1083 Register temp_reg, |
1084 Label* deopt) { | 1084 Label* deopt) { |
1085 Label ok; | 1085 Label ok; |
1086 ASSERT(ic_data.GetReceiverClassIdAt(0) != kSmi); | 1086 ASSERT(ic_data.GetReceiverClassIdAt(0) != kSmiCid); |
1087 __ testl(instance_reg, Immediate(kSmiTagMask)); | 1087 __ testl(instance_reg, Immediate(kSmiTagMask)); |
1088 __ j(ZERO, deopt); | 1088 __ j(ZERO, deopt); |
1089 Label is_ok; | 1089 Label is_ok; |
1090 const intptr_t num_checks = ic_data.NumberOfChecks(); | 1090 const intptr_t num_checks = ic_data.NumberOfChecks(); |
1091 const bool use_near_jump = num_checks < 5; | 1091 const bool use_near_jump = num_checks < 5; |
1092 __ LoadClassId(temp_reg, instance_reg); | 1092 __ LoadClassId(temp_reg, instance_reg); |
1093 for (intptr_t i = 0; i < num_checks; i++) { | 1093 for (intptr_t i = 0; i < num_checks; i++) { |
1094 __ cmpl(temp_reg, Immediate(ic_data.GetReceiverClassIdAt(i))); | 1094 __ cmpl(temp_reg, Immediate(ic_data.GetReceiverClassIdAt(i))); |
1095 if (i == (num_checks - 1)) { | 1095 if (i == (num_checks - 1)) { |
1096 __ j(NOT_EQUAL, deopt); | 1096 __ j(NOT_EQUAL, deopt); |
1097 } else { | 1097 } else { |
1098 if (use_near_jump) { | 1098 if (use_near_jump) { |
1099 __ j(EQUAL, &is_ok, Assembler::kNearJump); | 1099 __ j(EQUAL, &is_ok, Assembler::kNearJump); |
1100 } else { | 1100 } else { |
1101 __ j(EQUAL, &is_ok); | 1101 __ j(EQUAL, &is_ok); |
1102 } | 1102 } |
1103 } | 1103 } |
1104 } | 1104 } |
1105 __ Bind(&is_ok); | 1105 __ Bind(&is_ok); |
1106 } | 1106 } |
1107 | 1107 |
1108 | 1108 |
1109 void FlowGraphCompiler::LoadDoubleOrSmiToXmm(XmmRegister result, | 1109 void FlowGraphCompiler::LoadDoubleOrSmiToXmm(XmmRegister result, |
1110 Register reg, | 1110 Register reg, |
1111 Register temp, | 1111 Register temp, |
1112 Label* not_double_or_smi) { | 1112 Label* not_double_or_smi) { |
1113 Label is_smi, done; | 1113 Label is_smi, done; |
1114 __ testl(reg, Immediate(kSmiTagMask)); | 1114 __ testl(reg, Immediate(kSmiTagMask)); |
1115 __ j(ZERO, &is_smi); | 1115 __ j(ZERO, &is_smi); |
1116 __ CompareClassId(reg, kDouble, temp); | 1116 __ CompareClassId(reg, kDoubleCid, temp); |
1117 __ j(NOT_EQUAL, not_double_or_smi); | 1117 __ j(NOT_EQUAL, not_double_or_smi); |
1118 __ movsd(result, FieldAddress(reg, Double::value_offset())); | 1118 __ movsd(result, FieldAddress(reg, Double::value_offset())); |
1119 __ jmp(&done); | 1119 __ jmp(&done); |
1120 __ Bind(&is_smi); | 1120 __ Bind(&is_smi); |
1121 __ movl(temp, reg); | 1121 __ movl(temp, reg); |
1122 __ SmiUntag(temp); | 1122 __ SmiUntag(temp); |
1123 __ cvtsi2sd(result, temp); | 1123 __ cvtsi2sd(result, temp); |
1124 __ Bind(&done); | 1124 __ Bind(&done); |
1125 } | 1125 } |
1126 | 1126 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 __ popl(ECX); | 1253 __ popl(ECX); |
1254 __ popl(EAX); | 1254 __ popl(EAX); |
1255 } | 1255 } |
1256 | 1256 |
1257 | 1257 |
1258 #undef __ | 1258 #undef __ |
1259 | 1259 |
1260 } // namespace dart | 1260 } // namespace dart |
1261 | 1261 |
1262 #endif // defined TARGET_ARCH_IA32 | 1262 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |