Chromium Code Reviews| 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 if (!type_class.IsSignatureClass()) { |
|
regis
2013/07/12 00:29:31
A comment explaining why we do not do a class chec
srdjan
2013/07/12 16:56:11
Added comment:
Signature class is an instantiated
| |
| 245 const Register kClassIdReg = R2; | 245 if (is_raw_type) { |
| 246 // dynamic type argument, check only classes. | 246 const Register kClassIdReg = R2; |
| 247 __ LoadClassId(kClassIdReg, kInstanceReg); | 247 // dynamic type argument, check only classes. |
| 248 __ CompareImmediate(kClassIdReg, type_class.id()); | 248 __ LoadClassId(kClassIdReg, kInstanceReg); |
| 249 __ b(is_instance_lbl, EQ); | 249 __ CompareImmediate(kClassIdReg, type_class.id()); |
| 250 // List is a very common case. | 250 __ b(is_instance_lbl, EQ); |
| 251 if (IsListClass(type_class)) { | 251 // List is a very common case. |
| 252 GenerateListTypeCheck(kClassIdReg, is_instance_lbl); | 252 if (IsListClass(type_class)) { |
| 253 GenerateListTypeCheck(kClassIdReg, is_instance_lbl); | |
| 254 } | |
| 255 return GenerateSubtype1TestCacheLookup( | |
| 256 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); | |
| 253 } | 257 } |
| 254 return GenerateSubtype1TestCacheLookup( | 258 // 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); | 259 if (type_arguments.Length() == 1) { |
| 256 } | 260 const AbstractType& tp_argument = AbstractType::ZoneHandle( |
| 257 // If one type argument only, check if type argument is Object or dynamic. | 261 type_arguments.TypeAt(0)); |
| 258 if (type_arguments.Length() == 1) { | 262 ASSERT(!tp_argument.IsMalformed()); |
| 259 const AbstractType& tp_argument = AbstractType::ZoneHandle( | 263 if (tp_argument.IsType()) { |
| 260 type_arguments.TypeAt(0)); | 264 ASSERT(tp_argument.HasResolvedTypeClass()); |
| 261 ASSERT(!tp_argument.IsMalformed()); | 265 // Check if type argument is dynamic or Object. |
| 262 if (tp_argument.IsType()) { | 266 const Type& object_type = Type::Handle(Type::ObjectType()); |
| 263 ASSERT(tp_argument.HasResolvedTypeClass()); | 267 if (object_type.IsSubtypeOf(tp_argument, NULL)) { |
| 264 // Check if type argument is dynamic or Object. | 268 // Instance class test only necessary. |
| 265 const Type& object_type = Type::Handle(Type::ObjectType()); | 269 return GenerateSubtype1TestCacheLookup( |
| 266 if (object_type.IsSubtypeOf(tp_argument, NULL)) { | 270 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); |
| 267 // Instance class test only necessary. | 271 } |
| 268 return GenerateSubtype1TestCacheLookup( | |
| 269 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); | |
| 270 } | 272 } |
| 271 } | 273 } |
| 272 } | 274 } |
| 273 // Regular subtype test cache involving instance's type arguments. | 275 // Regular subtype test cache involving instance's type arguments. |
| 274 const Register kTypeArgumentsReg = kNoRegister; | 276 const Register kTypeArgumentsReg = kNoRegister; |
| 275 const Register kTempReg = kNoRegister; | 277 const Register kTempReg = kNoRegister; |
| 276 // R0: instance (must be preserved). | 278 // R0: instance (must be preserved). |
| 277 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs, | 279 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs, |
| 278 kInstanceReg, | 280 kInstanceReg, |
| 279 kTypeArgumentsReg, | 281 kTypeArgumentsReg, |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 __ b(is_not_instance_lbl, EQ); | 507 __ b(is_not_instance_lbl, EQ); |
| 506 __ CompareClassId(kInstanceReg, type_cid, R3); | 508 __ CompareClassId(kInstanceReg, type_cid, R3); |
| 507 __ b(is_instance_lbl, EQ); | 509 __ b(is_instance_lbl, EQ); |
| 508 } | 510 } |
| 509 __ b(is_not_instance_lbl); | 511 __ b(is_not_instance_lbl); |
| 510 return SubtypeTestCache::null(); | 512 return SubtypeTestCache::null(); |
| 511 } | 513 } |
| 512 if (type.IsInstantiated()) { | 514 if (type.IsInstantiated()) { |
| 513 const Class& type_class = Class::ZoneHandle(type.type_class()); | 515 const Class& type_class = Class::ZoneHandle(type.type_class()); |
| 514 // A class equality check is only applicable with a dst type of a | 516 // 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. | 517 // non-parameterized class or with a raw dst type of a parameterized class. |
|
regis
2013/07/12 00:29:31
Should this comment be updated?
srdjan
2013/07/12 16:56:11
Added:
non-signature class
| |
| 516 if (type_class.HasTypeArguments()) { | 518 if (type_class.IsSignatureClass() || type_class.HasTypeArguments()) { |
| 517 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, | 519 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, |
| 518 type, | 520 type, |
| 519 is_instance_lbl, | 521 is_instance_lbl, |
| 520 is_not_instance_lbl); | 522 is_not_instance_lbl); |
| 521 // Fall through to runtime call. | 523 // Fall through to runtime call. |
| 522 } | 524 } |
| 523 const bool has_fall_through = | 525 const bool has_fall_through = |
| 524 GenerateInstantiatedTypeNoArgumentsTest(token_pos, | 526 GenerateInstantiatedTypeNoArgumentsTest(token_pos, |
| 525 type, | 527 type, |
| 526 is_instance_lbl, | 528 is_instance_lbl, |
| (...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1844 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { | 1846 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { |
| 1845 __ vldrd(reg, Address(SP, kDoubleSize, Address::PostIndex)); | 1847 __ vldrd(reg, Address(SP, kDoubleSize, Address::PostIndex)); |
| 1846 } | 1848 } |
| 1847 | 1849 |
| 1848 | 1850 |
| 1849 #undef __ | 1851 #undef __ |
| 1850 | 1852 |
| 1851 } // namespace dart | 1853 } // namespace dart |
| 1852 | 1854 |
| 1853 #endif // defined TARGET_ARCH_ARM | 1855 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |