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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 const AbstractType& type, | 263 const AbstractType& type, |
264 Label* is_instance_lbl, | 264 Label* is_instance_lbl, |
265 Label* is_not_instance_lbl) { | 265 Label* is_not_instance_lbl) { |
266 __ Comment("InstantiatedTypeWithArgumentsTest"); | 266 __ Comment("InstantiatedTypeWithArgumentsTest"); |
267 ASSERT(type.IsInstantiated()); | 267 ASSERT(type.IsInstantiated()); |
268 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); | 268 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); |
269 ASSERT(type.IsFunctionType() || (type_class.NumTypeArguments() > 0)); | 269 ASSERT(type.IsFunctionType() || (type_class.NumTypeArguments() > 0)); |
270 const Register kInstanceReg = A0; | 270 const Register kInstanceReg = A0; |
271 Error& bound_error = Error::Handle(zone()); | 271 Error& bound_error = Error::Handle(zone()); |
272 const Type& int_type = Type::Handle(zone(), Type::IntType()); | 272 const Type& int_type = Type::Handle(zone(), Type::IntType()); |
273 const bool smi_is_ok = int_type.IsSubtypeOf(type, &bound_error, Heap::kOld); | 273 const bool smi_is_ok = |
| 274 int_type.IsSubtypeOf(type, &bound_error, NULL, Heap::kOld); |
274 // Malformed type should have been handled at graph construction time. | 275 // Malformed type should have been handled at graph construction time. |
275 ASSERT(smi_is_ok || bound_error.IsNull()); | 276 ASSERT(smi_is_ok || bound_error.IsNull()); |
276 __ andi(CMPRES1, kInstanceReg, Immediate(kSmiTagMask)); | 277 __ andi(CMPRES1, kInstanceReg, Immediate(kSmiTagMask)); |
277 if (smi_is_ok) { | 278 if (smi_is_ok) { |
278 __ beq(CMPRES1, ZR, is_instance_lbl); | 279 __ beq(CMPRES1, ZR, is_instance_lbl); |
279 } else { | 280 } else { |
280 __ beq(CMPRES1, ZR, is_not_instance_lbl); | 281 __ beq(CMPRES1, ZR, is_not_instance_lbl); |
281 } | 282 } |
282 // A function type test requires checking the function signature. | 283 // A function type test requires checking the function signature. |
283 if (!type.IsFunctionType()) { | 284 if (!type.IsFunctionType()) { |
(...skipping 18 matching lines...) Expand all Loading... |
302 } | 303 } |
303 // If one type argument only, check if type argument is Object or dynamic. | 304 // If one type argument only, check if type argument is Object or dynamic. |
304 if (type_arguments.Length() == 1) { | 305 if (type_arguments.Length() == 1) { |
305 const AbstractType& tp_argument = AbstractType::ZoneHandle(zone(), | 306 const AbstractType& tp_argument = AbstractType::ZoneHandle(zone(), |
306 type_arguments.TypeAt(0)); | 307 type_arguments.TypeAt(0)); |
307 ASSERT(!tp_argument.IsMalformed()); | 308 ASSERT(!tp_argument.IsMalformed()); |
308 if (tp_argument.IsType()) { | 309 if (tp_argument.IsType()) { |
309 ASSERT(tp_argument.HasResolvedTypeClass()); | 310 ASSERT(tp_argument.HasResolvedTypeClass()); |
310 // Check if type argument is dynamic or Object. | 311 // Check if type argument is dynamic or Object. |
311 const Type& object_type = Type::Handle(zone(), Type::ObjectType()); | 312 const Type& object_type = Type::Handle(zone(), Type::ObjectType()); |
312 if (object_type.IsSubtypeOf(tp_argument, NULL, Heap::kOld)) { | 313 if (object_type.IsSubtypeOf(tp_argument, NULL, NULL, Heap::kOld)) { |
313 // Instance class test only necessary. | 314 // Instance class test only necessary. |
314 return GenerateSubtype1TestCacheLookup( | 315 return GenerateSubtype1TestCacheLookup( |
315 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); | 316 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); |
316 } | 317 } |
317 } | 318 } |
318 } | 319 } |
319 } | 320 } |
320 // Regular subtype test cache involving instance's type arguments. | 321 // Regular subtype test cache involving instance's type arguments. |
321 const Register kTypeArgumentsReg = kNoRegister; | 322 const Register kTypeArgumentsReg = kNoRegister; |
322 const Register kTempReg = kNoRegister; | 323 const Register kTempReg = kNoRegister; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 ASSERT(type_class.NumTypeArguments() == 0); | 363 ASSERT(type_class.NumTypeArguments() == 0); |
363 | 364 |
364 const Register kInstanceReg = A0; | 365 const Register kInstanceReg = A0; |
365 __ andi(T0, A0, Immediate(kSmiTagMask)); | 366 __ andi(T0, A0, Immediate(kSmiTagMask)); |
366 // If instance is Smi, check directly. | 367 // If instance is Smi, check directly. |
367 const Class& smi_class = Class::Handle(zone(), Smi::Class()); | 368 const Class& smi_class = Class::Handle(zone(), Smi::Class()); |
368 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), | 369 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), |
369 type_class, | 370 type_class, |
370 TypeArguments::Handle(zone()), | 371 TypeArguments::Handle(zone()), |
371 NULL, | 372 NULL, |
| 373 NULL, |
372 Heap::kOld)) { | 374 Heap::kOld)) { |
373 __ beq(T0, ZR, is_instance_lbl); | 375 __ beq(T0, ZR, is_instance_lbl); |
374 } else { | 376 } else { |
375 __ beq(T0, ZR, is_not_instance_lbl); | 377 __ beq(T0, ZR, is_not_instance_lbl); |
376 } | 378 } |
377 // Compare if the classes are equal. | 379 // Compare if the classes are equal. |
378 const Register kClassIdReg = T0; | 380 const Register kClassIdReg = T0; |
379 __ LoadClassId(kClassIdReg, kInstanceReg); | 381 __ LoadClassId(kClassIdReg, kInstanceReg); |
380 __ BranchEqual(kClassIdReg, Immediate(type_class.id()), is_instance_lbl); | 382 __ BranchEqual(kClassIdReg, Immediate(type_class.id()), is_instance_lbl); |
381 | 383 |
382 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted | 384 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted |
383 // interfaces. | 385 // interfaces. |
384 // Bool interface can be implemented only by core class Bool. | 386 // Bool interface can be implemented only by core class Bool. |
385 if (type.IsBoolType()) { | 387 if (type.IsBoolType()) { |
386 __ BranchEqual(kClassIdReg, Immediate(kBoolCid), is_instance_lbl); | 388 __ BranchEqual(kClassIdReg, Immediate(kBoolCid), is_instance_lbl); |
387 __ b(is_not_instance_lbl); | 389 __ b(is_not_instance_lbl); |
388 return false; | 390 return false; |
389 } | 391 } |
390 if (type.IsDartFunctionType()) { | 392 if (type.IsDartFunctionType()) { |
391 // Check if instance is a closure. | 393 // Check if instance is a closure. |
392 __ BranchEqual(kClassIdReg, Immediate(kClosureCid), is_instance_lbl); | 394 __ BranchEqual(kClassIdReg, Immediate(kClosureCid), is_instance_lbl); |
393 } | 395 } |
394 // Custom checking for numbers (Smi, Mint, Bigint and Double). | 396 // Custom checking for numbers (Smi, Mint, Bigint and Double). |
395 // Note that instance is not Smi (checked above). | 397 // Note that instance is not Smi (checked above). |
396 if (type.IsSubtypeOf( | 398 if (type.IsSubtypeOf( |
397 Type::Handle(zone(), Type::Number()), NULL, Heap::kOld)) { | 399 Type::Handle(zone(), Type::Number()), NULL, NULL, Heap::kOld)) { |
398 GenerateNumberTypeCheck( | 400 GenerateNumberTypeCheck( |
399 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); | 401 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); |
400 return false; | 402 return false; |
401 } | 403 } |
402 if (type.IsStringType()) { | 404 if (type.IsStringType()) { |
403 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); | 405 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); |
404 return false; | 406 return false; |
405 } | 407 } |
406 // Otherwise fallthrough. | 408 // Otherwise fallthrough. |
407 return true; | 409 return true; |
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 __ AddImmediate(SP, kDoubleSize); | 1902 __ AddImmediate(SP, kDoubleSize); |
1901 } | 1903 } |
1902 | 1904 |
1903 | 1905 |
1904 #undef __ | 1906 #undef __ |
1905 | 1907 |
1906 | 1908 |
1907 } // namespace dart | 1909 } // namespace dart |
1908 | 1910 |
1909 #endif // defined TARGET_ARCH_MIPS | 1911 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |