| 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 "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest( | 218 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest( |
| 219 intptr_t token_pos, | 219 intptr_t token_pos, |
| 220 const AbstractType& type, | 220 const AbstractType& type, |
| 221 Label* is_instance_lbl, | 221 Label* is_instance_lbl, |
| 222 Label* is_not_instance_lbl) { | 222 Label* is_not_instance_lbl) { |
| 223 __ Comment("InstantiatedTypeWithArgumentsTest"); | 223 __ Comment("InstantiatedTypeWithArgumentsTest"); |
| 224 ASSERT(type.IsInstantiated()); | 224 ASSERT(type.IsInstantiated()); |
| 225 const Class& type_class = Class::ZoneHandle(type.type_class()); | 225 const Class& type_class = Class::ZoneHandle(type.type_class()); |
| 226 ASSERT(type_class.HasTypeArguments()); | 226 ASSERT(type_class.HasTypeArguments()); |
| 227 const Register kInstanceReg = A0; | 227 const Register kInstanceReg = A0; |
| 228 // A Smi object cannot be the instance of a parameterized class. | 228 Error& malformed_error = Error::Handle(); |
| 229 const Type& int_type = Type::Handle(Type::IntType()); |
| 230 const bool smi_is_ok = int_type.IsSubtypeOf(type, &malformed_error); |
| 231 // Malforrmed type should have been handled at graph construction time. |
| 232 ASSERT(smi_is_ok || malformed_error.IsNull()); |
| 229 __ andi(CMPRES, kInstanceReg, Immediate(kSmiTagMask)); | 233 __ andi(CMPRES, kInstanceReg, Immediate(kSmiTagMask)); |
| 230 __ beq(CMPRES, ZR, is_not_instance_lbl); | 234 if (smi_is_ok) { |
| 235 __ beq(CMPRES, ZR, is_instance_lbl); |
| 236 } else { |
| 237 __ beq(CMPRES, ZR, is_not_instance_lbl); |
| 238 } |
| 231 const AbstractTypeArguments& type_arguments = | 239 const AbstractTypeArguments& type_arguments = |
| 232 AbstractTypeArguments::ZoneHandle(type.arguments()); | 240 AbstractTypeArguments::ZoneHandle(type.arguments()); |
| 233 const bool is_raw_type = type_arguments.IsNull() || | 241 const bool is_raw_type = type_arguments.IsNull() || |
| 234 type_arguments.IsRaw(type_arguments.Length()); | 242 type_arguments.IsRaw(type_arguments.Length()); |
| 235 if (is_raw_type) { | 243 if (is_raw_type) { |
| 236 const Register kClassIdReg = T0; | 244 const Register kClassIdReg = T0; |
| 237 // dynamic type argument, check only classes. | 245 // dynamic type argument, check only classes. |
| 238 __ LoadClassId(kClassIdReg, kInstanceReg); | 246 __ LoadClassId(kClassIdReg, kInstanceReg); |
| 239 __ BranchEqual(kClassIdReg, type_class.id(), is_instance_lbl); | 247 __ BranchEqual(kClassIdReg, type_class.id(), is_instance_lbl); |
| 240 // List is a very common case. | 248 // List is a very common case. |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 } else { | 500 } else { |
| 493 __ beq(CMPRES, ZR, is_not_instance_lbl); | 501 __ beq(CMPRES, ZR, is_not_instance_lbl); |
| 494 __ LoadClassId(T0, kInstanceReg); | 502 __ LoadClassId(T0, kInstanceReg); |
| 495 __ BranchEqual(T0, type_cid, is_instance_lbl); | 503 __ BranchEqual(T0, type_cid, is_instance_lbl); |
| 496 } | 504 } |
| 497 __ b(is_not_instance_lbl); | 505 __ b(is_not_instance_lbl); |
| 498 return SubtypeTestCache::null(); | 506 return SubtypeTestCache::null(); |
| 499 } | 507 } |
| 500 if (type.IsInstantiated()) { | 508 if (type.IsInstantiated()) { |
| 501 const Class& type_class = Class::ZoneHandle(type.type_class()); | 509 const Class& type_class = Class::ZoneHandle(type.type_class()); |
| 502 // A Smi object cannot be the instance of a parameterized class. | |
| 503 // A class equality check is only applicable with a dst type of a | 510 // A class equality check is only applicable with a dst type of a |
| 504 // non-parameterized class or with a raw dst type of a parameterized class. | 511 // non-parameterized class or with a raw dst type of a parameterized class. |
| 505 if (type_class.HasTypeArguments()) { | 512 if (type_class.HasTypeArguments()) { |
| 506 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, | 513 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, |
| 507 type, | 514 type, |
| 508 is_instance_lbl, | 515 is_instance_lbl, |
| 509 is_not_instance_lbl); | 516 is_not_instance_lbl); |
| 510 // Fall through to runtime call. | 517 // Fall through to runtime call. |
| 511 } | 518 } |
| 512 const bool has_fall_through = | 519 const bool has_fall_through = |
| (...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1912 __ AddImmediate(SP, kDoubleSize); | 1919 __ AddImmediate(SP, kDoubleSize); |
| 1913 } | 1920 } |
| 1914 | 1921 |
| 1915 | 1922 |
| 1916 #undef __ | 1923 #undef __ |
| 1917 | 1924 |
| 1918 | 1925 |
| 1919 } // namespace dart | 1926 } // namespace dart |
| 1920 | 1927 |
| 1921 #endif // defined TARGET_ARCH_MIPS | 1928 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |