| 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" // Needed here to get TARGET_ARCH_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
| 6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 7 | 7 |
| 8 #include "vm/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
| 9 | 9 |
| 10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 const AbstractType& type, | 250 const AbstractType& type, |
| 251 Label* is_instance_lbl, | 251 Label* is_instance_lbl, |
| 252 Label* is_not_instance_lbl) { | 252 Label* is_not_instance_lbl) { |
| 253 __ Comment("InstantiatedTypeWithArgumentsTest"); | 253 __ Comment("InstantiatedTypeWithArgumentsTest"); |
| 254 ASSERT(type.IsInstantiated()); | 254 ASSERT(type.IsInstantiated()); |
| 255 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); | 255 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); |
| 256 ASSERT((type_class.NumTypeArguments() > 0) || type_class.IsSignatureClass()); | 256 ASSERT((type_class.NumTypeArguments() > 0) || type_class.IsSignatureClass()); |
| 257 const Register kInstanceReg = A0; | 257 const Register kInstanceReg = A0; |
| 258 Error& malformed_error = Error::Handle(zone()); | 258 Error& malformed_error = Error::Handle(zone()); |
| 259 const Type& int_type = Type::Handle(zone(), Type::IntType()); | 259 const Type& int_type = Type::Handle(zone(), Type::IntType()); |
| 260 const bool smi_is_ok = int_type.IsSubtypeOf(type, &malformed_error); | 260 const bool smi_is_ok = |
| 261 int_type.IsSubtypeOf(type, &malformed_error, Heap::kOld); |
| 261 // Malformed type should have been handled at graph construction time. | 262 // Malformed type should have been handled at graph construction time. |
| 262 ASSERT(smi_is_ok || malformed_error.IsNull()); | 263 ASSERT(smi_is_ok || malformed_error.IsNull()); |
| 263 __ andi(CMPRES1, kInstanceReg, Immediate(kSmiTagMask)); | 264 __ andi(CMPRES1, kInstanceReg, Immediate(kSmiTagMask)); |
| 264 if (smi_is_ok) { | 265 if (smi_is_ok) { |
| 265 __ beq(CMPRES1, ZR, is_instance_lbl); | 266 __ beq(CMPRES1, ZR, is_instance_lbl); |
| 266 } else { | 267 } else { |
| 267 __ beq(CMPRES1, ZR, is_not_instance_lbl); | 268 __ beq(CMPRES1, ZR, is_not_instance_lbl); |
| 268 } | 269 } |
| 269 const intptr_t num_type_args = type_class.NumTypeArguments(); | 270 const intptr_t num_type_args = type_class.NumTypeArguments(); |
| 270 const intptr_t num_type_params = type_class.NumTypeParameters(); | 271 const intptr_t num_type_params = type_class.NumTypeParameters(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 289 } | 290 } |
| 290 // If one type argument only, check if type argument is Object or dynamic. | 291 // If one type argument only, check if type argument is Object or dynamic. |
| 291 if (type_arguments.Length() == 1) { | 292 if (type_arguments.Length() == 1) { |
| 292 const AbstractType& tp_argument = AbstractType::ZoneHandle(zone(), | 293 const AbstractType& tp_argument = AbstractType::ZoneHandle(zone(), |
| 293 type_arguments.TypeAt(0)); | 294 type_arguments.TypeAt(0)); |
| 294 ASSERT(!tp_argument.IsMalformed()); | 295 ASSERT(!tp_argument.IsMalformed()); |
| 295 if (tp_argument.IsType()) { | 296 if (tp_argument.IsType()) { |
| 296 ASSERT(tp_argument.HasResolvedTypeClass()); | 297 ASSERT(tp_argument.HasResolvedTypeClass()); |
| 297 // Check if type argument is dynamic or Object. | 298 // Check if type argument is dynamic or Object. |
| 298 const Type& object_type = Type::Handle(zone(), Type::ObjectType()); | 299 const Type& object_type = Type::Handle(zone(), Type::ObjectType()); |
| 299 if (object_type.IsSubtypeOf(tp_argument, NULL)) { | 300 if (object_type.IsSubtypeOf(tp_argument, NULL, Heap::kOld)) { |
| 300 // Instance class test only necessary. | 301 // Instance class test only necessary. |
| 301 return GenerateSubtype1TestCacheLookup( | 302 return GenerateSubtype1TestCacheLookup( |
| 302 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); | 303 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); |
| 303 } | 304 } |
| 304 } | 305 } |
| 305 } | 306 } |
| 306 } | 307 } |
| 307 // Regular subtype test cache involving instance's type arguments. | 308 // Regular subtype test cache involving instance's type arguments. |
| 308 const Register kTypeArgumentsReg = kNoRegister; | 309 const Register kTypeArgumentsReg = kNoRegister; |
| 309 const Register kTempReg = kNoRegister; | 310 const Register kTempReg = kNoRegister; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 const Class& type_class = Class::Handle(zone(), type.type_class()); | 345 const Class& type_class = Class::Handle(zone(), type.type_class()); |
| 345 ASSERT(type_class.NumTypeArguments() == 0); | 346 ASSERT(type_class.NumTypeArguments() == 0); |
| 346 | 347 |
| 347 const Register kInstanceReg = A0; | 348 const Register kInstanceReg = A0; |
| 348 __ andi(T0, A0, Immediate(kSmiTagMask)); | 349 __ andi(T0, A0, Immediate(kSmiTagMask)); |
| 349 // If instance is Smi, check directly. | 350 // If instance is Smi, check directly. |
| 350 const Class& smi_class = Class::Handle(zone(), Smi::Class()); | 351 const Class& smi_class = Class::Handle(zone(), Smi::Class()); |
| 351 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), | 352 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), |
| 352 type_class, | 353 type_class, |
| 353 TypeArguments::Handle(zone()), | 354 TypeArguments::Handle(zone()), |
| 354 NULL)) { | 355 NULL, |
| 356 Heap::kOld)) { |
| 355 __ beq(T0, ZR, is_instance_lbl); | 357 __ beq(T0, ZR, is_instance_lbl); |
| 356 } else { | 358 } else { |
| 357 __ beq(T0, ZR, is_not_instance_lbl); | 359 __ beq(T0, ZR, is_not_instance_lbl); |
| 358 } | 360 } |
| 359 // Compare if the classes are equal. | 361 // Compare if the classes are equal. |
| 360 const Register kClassIdReg = T0; | 362 const Register kClassIdReg = T0; |
| 361 __ LoadClassId(kClassIdReg, kInstanceReg); | 363 __ LoadClassId(kClassIdReg, kInstanceReg); |
| 362 __ BranchEqual(kClassIdReg, Immediate(type_class.id()), is_instance_lbl); | 364 __ BranchEqual(kClassIdReg, Immediate(type_class.id()), is_instance_lbl); |
| 363 | 365 |
| 364 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted | 366 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted |
| 365 // interfaces. | 367 // interfaces. |
| 366 // Bool interface can be implemented only by core class Bool. | 368 // Bool interface can be implemented only by core class Bool. |
| 367 if (type.IsBoolType()) { | 369 if (type.IsBoolType()) { |
| 368 __ BranchEqual(kClassIdReg, Immediate(kBoolCid), is_instance_lbl); | 370 __ BranchEqual(kClassIdReg, Immediate(kBoolCid), is_instance_lbl); |
| 369 __ b(is_not_instance_lbl); | 371 __ b(is_not_instance_lbl); |
| 370 return false; | 372 return false; |
| 371 } | 373 } |
| 372 if (type.IsFunctionType()) { | 374 if (type.IsFunctionType()) { |
| 373 // Check if instance is a closure. | 375 // Check if instance is a closure. |
| 374 __ LoadClassById(T1, kClassIdReg); | 376 __ LoadClassById(T1, kClassIdReg); |
| 375 __ lw(T1, FieldAddress(T1, Class::signature_function_offset())); | 377 __ lw(T1, FieldAddress(T1, Class::signature_function_offset())); |
| 376 __ BranchNotEqual(T1, Object::null_object(), is_instance_lbl); | 378 __ BranchNotEqual(T1, Object::null_object(), is_instance_lbl); |
| 377 } | 379 } |
| 378 // Custom checking for numbers (Smi, Mint, Bigint and Double). | 380 // Custom checking for numbers (Smi, Mint, Bigint and Double). |
| 379 // Note that instance is not Smi (checked above). | 381 // Note that instance is not Smi (checked above). |
| 380 if (type.IsSubtypeOf(Type::Handle(zone(), Type::Number()), NULL)) { | 382 if (type.IsSubtypeOf( |
| 383 Type::Handle(zone(), Type::Number()), NULL, Heap::kOld)) { |
| 381 GenerateNumberTypeCheck( | 384 GenerateNumberTypeCheck( |
| 382 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); | 385 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); |
| 383 return false; | 386 return false; |
| 384 } | 387 } |
| 385 if (type.IsStringType()) { | 388 if (type.IsStringType()) { |
| 386 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); | 389 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); |
| 387 return false; | 390 return false; |
| 388 } | 391 } |
| 389 // Otherwise fallthrough. | 392 // Otherwise fallthrough. |
| 390 return true; | 393 return true; |
| (...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1840 __ AddImmediate(SP, kDoubleSize); | 1843 __ AddImmediate(SP, kDoubleSize); |
| 1841 } | 1844 } |
| 1842 | 1845 |
| 1843 | 1846 |
| 1844 #undef __ | 1847 #undef __ |
| 1845 | 1848 |
| 1846 | 1849 |
| 1847 } // namespace dart | 1850 } // namespace dart |
| 1848 | 1851 |
| 1849 #endif // defined TARGET_ARCH_MIPS | 1852 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |