| 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_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
| 6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // Clobbers R2. | 217 // Clobbers R2. |
| 218 RawSubtypeTestCache* | 218 RawSubtypeTestCache* |
| 219 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest( | 219 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest( |
| 220 intptr_t token_pos, | 220 intptr_t token_pos, |
| 221 const AbstractType& type, | 221 const AbstractType& type, |
| 222 Label* is_instance_lbl, | 222 Label* is_instance_lbl, |
| 223 Label* is_not_instance_lbl) { | 223 Label* is_not_instance_lbl) { |
| 224 __ Comment("InstantiatedTypeWithArgumentsTest"); | 224 __ Comment("InstantiatedTypeWithArgumentsTest"); |
| 225 ASSERT(type.IsInstantiated()); | 225 ASSERT(type.IsInstantiated()); |
| 226 const Class& type_class = Class::ZoneHandle(type.type_class()); | 226 const Class& type_class = Class::ZoneHandle(type.type_class()); |
| 227 ASSERT(type_class.HasTypeArguments()); | 227 ASSERT(type_class.HasTypeArguments() || type_class.IsSignatureClass()); |
| 228 const Register kInstanceReg = R0; | 228 const Register kInstanceReg = R0; |
| 229 Error& malformed_error = Error::Handle(); | 229 Error& malformed_error = Error::Handle(); |
| 230 const Type& int_type = Type::Handle(Type::IntType()); | 230 const Type& int_type = Type::Handle(Type::IntType()); |
| 231 const bool smi_is_ok = int_type.IsSubtypeOf(type, &malformed_error); | 231 const bool smi_is_ok = int_type.IsSubtypeOf(type, &malformed_error); |
| 232 // Malforrmed type should have been handled at graph construction time. | 232 // Malformed type should have been handled at graph construction time. |
| 233 ASSERT(smi_is_ok || malformed_error.IsNull()); | 233 ASSERT(smi_is_ok || malformed_error.IsNull()); |
| 234 __ tst(kInstanceReg, ShifterOperand(kSmiTagMask)); | 234 __ tst(kInstanceReg, ShifterOperand(kSmiTagMask)); |
| 235 if (smi_is_ok) { | 235 if (smi_is_ok) { |
| 236 __ b(is_instance_lbl, EQ); | 236 __ b(is_instance_lbl, EQ); |
| 237 } else { | 237 } else { |
| 238 __ b(is_not_instance_lbl, EQ); | 238 __ b(is_not_instance_lbl, EQ); |
| 239 } | 239 } |
| 240 const AbstractTypeArguments& type_arguments = | 240 const AbstractTypeArguments& type_arguments = |
| 241 AbstractTypeArguments::ZoneHandle(type.arguments()); | 241 AbstractTypeArguments::ZoneHandle(type.arguments()); |
| 242 const bool is_raw_type = type_arguments.IsNull() || | 242 const bool is_raw_type = type_arguments.IsNull() || |
| 243 type_arguments.IsRaw(type_arguments.Length()); | 243 type_arguments.IsRaw(type_arguments.Length()); |
| 244 if (is_raw_type) { | 244 // Signature class is an instantiated parameterized type. |
| 245 const Register kClassIdReg = R2; | 245 if (!type_class.IsSignatureClass()) { |
| 246 // dynamic type argument, check only classes. | 246 if (is_raw_type) { |
| 247 __ LoadClassId(kClassIdReg, kInstanceReg); | 247 const Register kClassIdReg = R2; |
| 248 __ CompareImmediate(kClassIdReg, type_class.id()); | 248 // dynamic type argument, check only classes. |
| 249 __ b(is_instance_lbl, EQ); | 249 __ LoadClassId(kClassIdReg, kInstanceReg); |
| 250 // List is a very common case. | 250 __ CompareImmediate(kClassIdReg, type_class.id()); |
| 251 if (IsListClass(type_class)) { | 251 __ b(is_instance_lbl, EQ); |
| 252 GenerateListTypeCheck(kClassIdReg, is_instance_lbl); | 252 // List is a very common case. |
| 253 if (IsListClass(type_class)) { |
| 254 GenerateListTypeCheck(kClassIdReg, is_instance_lbl); |
| 255 } |
| 256 return GenerateSubtype1TestCacheLookup( |
| 257 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); |
| 253 } | 258 } |
| 254 return GenerateSubtype1TestCacheLookup( | 259 // If one type argument only, check if type argument is Object or dynamic. |
| 255 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); | 260 if (type_arguments.Length() == 1) { |
| 256 } | 261 const AbstractType& tp_argument = AbstractType::ZoneHandle( |
| 257 // If one type argument only, check if type argument is Object or dynamic. | 262 type_arguments.TypeAt(0)); |
| 258 if (type_arguments.Length() == 1) { | 263 ASSERT(!tp_argument.IsMalformed()); |
| 259 const AbstractType& tp_argument = AbstractType::ZoneHandle( | 264 if (tp_argument.IsType()) { |
| 260 type_arguments.TypeAt(0)); | 265 ASSERT(tp_argument.HasResolvedTypeClass()); |
| 261 ASSERT(!tp_argument.IsMalformed()); | 266 // Check if type argument is dynamic or Object. |
| 262 if (tp_argument.IsType()) { | 267 const Type& object_type = Type::Handle(Type::ObjectType()); |
| 263 ASSERT(tp_argument.HasResolvedTypeClass()); | 268 if (object_type.IsSubtypeOf(tp_argument, NULL)) { |
| 264 // Check if type argument is dynamic or Object. | 269 // Instance class test only necessary. |
| 265 const Type& object_type = Type::Handle(Type::ObjectType()); | 270 return GenerateSubtype1TestCacheLookup( |
| 266 if (object_type.IsSubtypeOf(tp_argument, NULL)) { | 271 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); |
| 267 // Instance class test only necessary. | 272 } |
| 268 return GenerateSubtype1TestCacheLookup( | |
| 269 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); | |
| 270 } | 273 } |
| 271 } | 274 } |
| 272 } | 275 } |
| 273 // Regular subtype test cache involving instance's type arguments. | 276 // Regular subtype test cache involving instance's type arguments. |
| 274 const Register kTypeArgumentsReg = kNoRegister; | 277 const Register kTypeArgumentsReg = kNoRegister; |
| 275 const Register kTempReg = kNoRegister; | 278 const Register kTempReg = kNoRegister; |
| 276 // R0: instance (must be preserved). | 279 // R0: instance (must be preserved). |
| 277 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs, | 280 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs, |
| 278 kInstanceReg, | 281 kInstanceReg, |
| 279 kTypeArgumentsReg, | 282 kTypeArgumentsReg, |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 __ b(is_not_instance_lbl, EQ); | 508 __ b(is_not_instance_lbl, EQ); |
| 506 __ CompareClassId(kInstanceReg, type_cid, R3); | 509 __ CompareClassId(kInstanceReg, type_cid, R3); |
| 507 __ b(is_instance_lbl, EQ); | 510 __ b(is_instance_lbl, EQ); |
| 508 } | 511 } |
| 509 __ b(is_not_instance_lbl); | 512 __ b(is_not_instance_lbl); |
| 510 return SubtypeTestCache::null(); | 513 return SubtypeTestCache::null(); |
| 511 } | 514 } |
| 512 if (type.IsInstantiated()) { | 515 if (type.IsInstantiated()) { |
| 513 const Class& type_class = Class::ZoneHandle(type.type_class()); | 516 const Class& type_class = Class::ZoneHandle(type.type_class()); |
| 514 // A class equality check is only applicable with a dst type of a | 517 // A class equality check is only applicable with a dst type of a |
| 515 // non-parameterized class or with a raw dst type of a parameterized class. | 518 // non-parameterized class, non-signature class, or with a raw dst type of |
| 516 if (type_class.HasTypeArguments()) { | 519 // a parameterized class. |
| 520 if (type_class.IsSignatureClass() || type_class.HasTypeArguments()) { |
| 517 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, | 521 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, |
| 518 type, | 522 type, |
| 519 is_instance_lbl, | 523 is_instance_lbl, |
| 520 is_not_instance_lbl); | 524 is_not_instance_lbl); |
| 521 // Fall through to runtime call. | 525 // Fall through to runtime call. |
| 522 } | 526 } |
| 523 const bool has_fall_through = | 527 const bool has_fall_through = |
| 524 GenerateInstantiatedTypeNoArgumentsTest(token_pos, | 528 GenerateInstantiatedTypeNoArgumentsTest(token_pos, |
| 525 type, | 529 type, |
| 526 is_instance_lbl, | 530 is_instance_lbl, |
| (...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1844 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { | 1848 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { |
| 1845 __ vldrd(reg, Address(SP, kDoubleSize, Address::PostIndex)); | 1849 __ vldrd(reg, Address(SP, kDoubleSize, Address::PostIndex)); |
| 1846 } | 1850 } |
| 1847 | 1851 |
| 1848 | 1852 |
| 1849 #undef __ | 1853 #undef __ |
| 1850 | 1854 |
| 1851 } // namespace dart | 1855 } // namespace dart |
| 1852 | 1856 |
| 1853 #endif // defined TARGET_ARCH_ARM | 1857 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |