| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 __ j(EQUAL, is_instance_lbl); | 230 __ j(EQUAL, is_instance_lbl); |
| 231 } | 231 } |
| 232 // Bool interface can be implemented only by core class Bool. | 232 // Bool interface can be implemented only by core class Bool. |
| 233 // (see ClassFinalizer::ResolveInterfaces for list of restricted interfaces). | 233 // (see ClassFinalizer::ResolveInterfaces for list of restricted interfaces). |
| 234 if (type.IsBoolInterface()) { | 234 if (type.IsBoolInterface()) { |
| 235 __ cmpl(kClassIdReg, Immediate(kBoolCid)); | 235 __ cmpl(kClassIdReg, Immediate(kBoolCid)); |
| 236 __ j(EQUAL, is_instance_lbl); | 236 __ j(EQUAL, is_instance_lbl); |
| 237 __ jmp(is_not_instance_lbl); | 237 __ jmp(is_not_instance_lbl); |
| 238 return false; | 238 return false; |
| 239 } | 239 } |
| 240 if (type.IsFunctionInterface()) { | 240 if (type.IsFunctionType()) { |
| 241 // Check if instance is a closure. | 241 // Check if instance is a closure. |
| 242 const Immediate raw_null = | 242 const Immediate raw_null = |
| 243 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 243 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 244 __ LoadClassById(EDI, kClassIdReg); | 244 __ LoadClassById(EDI, kClassIdReg); |
| 245 __ movl(EDI, FieldAddress(EDI, Class::signature_function_offset())); | 245 __ movl(EDI, FieldAddress(EDI, Class::signature_function_offset())); |
| 246 __ cmpl(EDI, raw_null); | 246 __ cmpl(EDI, raw_null); |
| 247 __ j(NOT_EQUAL, is_instance_lbl); | 247 __ j(NOT_EQUAL, is_instance_lbl); |
| 248 __ jmp(is_not_instance_lbl); | 248 __ jmp(is_not_instance_lbl); |
| 249 return false; | 249 return false; |
| 250 } | 250 } |
| 251 // Custom checking for numbers (Smi, Mint, Bigint and Double). | 251 // Custom checking for numbers (Smi, Mint, Bigint and Double). |
| 252 // Note that instance is not Smi (checked above). | 252 // Note that instance is not Smi (checked above). |
| 253 if (type.IsSubtypeOf(Type::Handle(Type::NumberInterface()), NULL)) { | 253 if (type.IsSubtypeOf(Type::Handle(Type::Number()), NULL)) { |
| 254 GenerateNumberTypeCheck( | 254 GenerateNumberTypeCheck( |
| 255 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); | 255 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); |
| 256 return false; | 256 return false; |
| 257 } | 257 } |
| 258 if (type.IsStringInterface()) { | 258 if (type.IsStringInterface()) { |
| 259 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); | 259 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); |
| 260 return false; | 260 return false; |
| 261 } | 261 } |
| 262 // Otherwise fallthrough. | 262 // Otherwise fallthrough. |
| 263 return true; | 263 return true; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 const Type& object_type = Type::ZoneHandle(Type::ObjectType()); | 332 const Type& object_type = Type::ZoneHandle(Type::ObjectType()); |
| 333 __ CompareObject(EDI, object_type); | 333 __ CompareObject(EDI, object_type); |
| 334 __ j(EQUAL, is_instance_lbl); | 334 __ j(EQUAL, is_instance_lbl); |
| 335 | 335 |
| 336 // For Smi check quickly against int and num interfaces. | 336 // For Smi check quickly against int and num interfaces. |
| 337 Label not_smi; | 337 Label not_smi; |
| 338 __ testl(EAX, Immediate(kSmiTagMask)); // Value is Smi? | 338 __ testl(EAX, Immediate(kSmiTagMask)); // Value is Smi? |
| 339 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); | 339 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); |
| 340 __ CompareObject(EDI, Type::ZoneHandle(Type::IntInterface())); | 340 __ CompareObject(EDI, Type::ZoneHandle(Type::IntInterface())); |
| 341 __ j(EQUAL, is_instance_lbl); | 341 __ j(EQUAL, is_instance_lbl); |
| 342 __ CompareObject(EDI, Type::ZoneHandle(Type::NumberInterface())); | 342 __ CompareObject(EDI, Type::ZoneHandle(Type::Number())); |
| 343 __ j(EQUAL, is_instance_lbl); | 343 __ j(EQUAL, is_instance_lbl); |
| 344 // Smi must be handled in runtime. | 344 // Smi must be handled in runtime. |
| 345 __ jmp(&fall_through); | 345 __ jmp(&fall_through); |
| 346 | 346 |
| 347 __ Bind(¬_smi); | 347 __ Bind(¬_smi); |
| 348 // EDX: instantiator type arguments. | 348 // EDX: instantiator type arguments. |
| 349 // EAX: instance. | 349 // EAX: instance. |
| 350 const Register kInstanceReg = EAX; | 350 const Register kInstanceReg = EAX; |
| 351 const Register kTypeArgumentsReg = EDX; | 351 const Register kTypeArgumentsReg = EDX; |
| 352 const Register kTempReg = EDI; | 352 const Register kTempReg = EDI; |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 __ popl(ECX); | 1234 __ popl(ECX); |
| 1235 __ popl(EAX); | 1235 __ popl(EAX); |
| 1236 } | 1236 } |
| 1237 | 1237 |
| 1238 | 1238 |
| 1239 #undef __ | 1239 #undef __ |
| 1240 | 1240 |
| 1241 } // namespace dart | 1241 } // namespace dart |
| 1242 | 1242 |
| 1243 #endif // defined TARGET_ARCH_IA32 | 1243 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |