| 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 175 } |
| 176 // If one type argument only, check if type argument is Object or Dynamic. | 176 // If one type argument only, check if type argument is Object or Dynamic. |
| 177 if (type_arguments.Length() == 1) { | 177 if (type_arguments.Length() == 1) { |
| 178 const AbstractType& tp_argument = AbstractType::ZoneHandle( | 178 const AbstractType& tp_argument = AbstractType::ZoneHandle( |
| 179 type_arguments.TypeAt(0)); | 179 type_arguments.TypeAt(0)); |
| 180 ASSERT(!tp_argument.IsMalformed()); | 180 ASSERT(!tp_argument.IsMalformed()); |
| 181 if (tp_argument.IsType()) { | 181 if (tp_argument.IsType()) { |
| 182 ASSERT(tp_argument.HasResolvedTypeClass()); | 182 ASSERT(tp_argument.HasResolvedTypeClass()); |
| 183 // Check if type argument is dynamic or Object. | 183 // Check if type argument is dynamic or Object. |
| 184 const Type& object_type = Type::Handle(Type::ObjectType()); | 184 const Type& object_type = Type::Handle(Type::ObjectType()); |
| 185 Error& malformed_error = Error::Handle(); | 185 if (object_type.IsSubtypeOf(tp_argument, NULL)) { |
| 186 if (object_type.IsSubtypeOf(tp_argument, &malformed_error)) { | |
| 187 // Instance class test only necessary. | 186 // Instance class test only necessary. |
| 188 return GenerateSubtype1TestCacheLookup( | 187 return GenerateSubtype1TestCacheLookup( |
| 189 cid, token_pos, type_class, is_instance_lbl, is_not_instance_lbl); | 188 cid, token_pos, type_class, is_instance_lbl, is_not_instance_lbl); |
| 190 } | 189 } |
| 191 } | 190 } |
| 192 } | 191 } |
| 193 // Regular subtype test cache involving instance's type arguments. | 192 // Regular subtype test cache involving instance's type arguments. |
| 194 const Register kTypeArgumentsReg = kNoRegister; | 193 const Register kTypeArgumentsReg = kNoRegister; |
| 195 const Register kTempReg = R10; | 194 const Register kTempReg = R10; |
| 196 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs, | 195 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 ASSERT(type.IsInstantiated()); | 227 ASSERT(type.IsInstantiated()); |
| 229 const Class& type_class = Class::Handle(type.type_class()); | 228 const Class& type_class = Class::Handle(type.type_class()); |
| 230 ASSERT(!type_class.HasTypeArguments()); | 229 ASSERT(!type_class.HasTypeArguments()); |
| 231 | 230 |
| 232 const Register kInstanceReg = RAX; | 231 const Register kInstanceReg = RAX; |
| 233 Label compare_classes; | 232 Label compare_classes; |
| 234 __ testq(kInstanceReg, Immediate(kSmiTagMask)); | 233 __ testq(kInstanceReg, Immediate(kSmiTagMask)); |
| 235 __ j(NOT_ZERO, &compare_classes, Assembler::kNearJump); | 234 __ j(NOT_ZERO, &compare_classes, Assembler::kNearJump); |
| 236 // Instance is Smi, check directly. | 235 // Instance is Smi, check directly. |
| 237 const Class& smi_class = Class::Handle(Smi::Class()); | 236 const Class& smi_class = Class::Handle(Smi::Class()); |
| 238 Error& malformed_error = Error::Handle(); | |
| 239 if (smi_class.IsSubtypeOf(TypeArguments::Handle(), | 237 if (smi_class.IsSubtypeOf(TypeArguments::Handle(), |
| 240 type_class, | 238 type_class, |
| 241 TypeArguments::Handle(), | 239 TypeArguments::Handle(), |
| 242 &malformed_error)) { | 240 NULL)) { |
| 243 __ jmp(is_instance_lbl); | 241 __ jmp(is_instance_lbl); |
| 244 } else { | 242 } else { |
| 245 __ jmp(is_not_instance_lbl); | 243 __ jmp(is_not_instance_lbl); |
| 246 } | 244 } |
| 247 // Compare if the classes are equal. | 245 // Compare if the classes are equal. |
| 248 __ Bind(&compare_classes); | 246 __ Bind(&compare_classes); |
| 249 const Register kClassIdReg = R10; | 247 const Register kClassIdReg = R10; |
| 250 __ LoadClassId(kClassIdReg, kInstanceReg); | 248 __ LoadClassId(kClassIdReg, kInstanceReg); |
| 251 // If type is an interface, we can skip the class equality check. | 249 // If type is an interface, we can skip the class equality check. |
| 252 if (!type_class.is_interface()) { | 250 if (!type_class.is_interface()) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 267 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 265 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 268 __ LoadClassById(R13, kClassIdReg); | 266 __ LoadClassById(R13, kClassIdReg); |
| 269 __ movq(R13, FieldAddress(R13, Class::signature_function_offset())); | 267 __ movq(R13, FieldAddress(R13, Class::signature_function_offset())); |
| 270 __ cmpq(R13, raw_null); | 268 __ cmpq(R13, raw_null); |
| 271 __ j(NOT_EQUAL, is_instance_lbl); | 269 __ j(NOT_EQUAL, is_instance_lbl); |
| 272 __ jmp(is_not_instance_lbl); | 270 __ jmp(is_not_instance_lbl); |
| 273 return false; | 271 return false; |
| 274 } | 272 } |
| 275 // Custom checking for numbers (Smi, Mint, Bigint and Double). | 273 // Custom checking for numbers (Smi, Mint, Bigint and Double). |
| 276 // Note that instance is not Smi (checked above). | 274 // Note that instance is not Smi (checked above). |
| 277 if (type.IsSubtypeOf( | 275 if (type.IsSubtypeOf(Type::Handle(Type::NumberInterface()), NULL)) { |
| 278 Type::Handle(Type::NumberInterface()), &malformed_error)) { | |
| 279 GenerateNumberTypeCheck( | 276 GenerateNumberTypeCheck( |
| 280 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); | 277 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); |
| 281 return false; | 278 return false; |
| 282 } | 279 } |
| 283 if (type.IsStringInterface()) { | 280 if (type.IsStringInterface()) { |
| 284 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); | 281 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); |
| 285 return false; | 282 return false; |
| 286 } | 283 } |
| 287 // Otherwise fallthrough. | 284 // Otherwise fallthrough. |
| 288 return true; | 285 return true; |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { | 1204 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { |
| 1208 __ Exchange(mem1, mem2); | 1205 __ Exchange(mem1, mem2); |
| 1209 } | 1206 } |
| 1210 | 1207 |
| 1211 | 1208 |
| 1212 #undef __ | 1209 #undef __ |
| 1213 | 1210 |
| 1214 } // namespace dart | 1211 } // namespace dart |
| 1215 | 1212 |
| 1216 #endif // defined TARGET_ARCH_X64 | 1213 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |