Chromium Code Reviews| 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 const Register kInstanceReg = RAX; | 124 const Register kInstanceReg = RAX; |
| 125 // A Smi object cannot be the instance of a parameterized class. | 125 // A Smi object cannot be the instance of a parameterized class. |
| 126 __ testq(kInstanceReg, Immediate(kSmiTagMask)); | 126 __ testq(kInstanceReg, Immediate(kSmiTagMask)); |
| 127 __ j(ZERO, is_not_instance_lbl); | 127 __ j(ZERO, is_not_instance_lbl); |
| 128 const AbstractTypeArguments& type_arguments = | 128 const AbstractTypeArguments& type_arguments = |
| 129 AbstractTypeArguments::ZoneHandle(type.arguments()); | 129 AbstractTypeArguments::ZoneHandle(type.arguments()); |
| 130 const bool is_raw_type = type_arguments.IsNull() || | 130 const bool is_raw_type = type_arguments.IsNull() || |
| 131 type_arguments.IsRaw(type_arguments.Length()); | 131 type_arguments.IsRaw(type_arguments.Length()); |
| 132 if (is_raw_type) { | 132 if (is_raw_type) { |
| 133 const Register kClassIdReg = R10; | 133 const Register kClassIdReg = R10; |
| 134 // dynamic type argument, check only classes. | 134 // dynamic type argument. |
|
srdjan
2012/11/29 23:52:12
ditto.
regis
2012/11/30 00:24:30
Done.
| |
| 135 __ LoadClassId(kClassIdReg, kInstanceReg); | |
| 136 __ cmpl(kClassIdReg, Immediate(type_class.id())); | |
| 137 __ j(EQUAL, is_instance_lbl); | |
| 135 // List is a very common case. | 138 // List is a very common case. |
| 136 __ LoadClassId(kClassIdReg, kInstanceReg); | |
| 137 if (!type_class.is_interface()) { | |
| 138 __ cmpl(kClassIdReg, Immediate(type_class.id())); | |
| 139 __ j(EQUAL, is_instance_lbl); | |
| 140 } | |
| 141 if (type_class.IsListClass()) { | 139 if (type_class.IsListClass()) { |
| 142 GenerateListTypeCheck(kClassIdReg, is_instance_lbl); | 140 GenerateListTypeCheck(kClassIdReg, is_instance_lbl); |
| 143 } | 141 } |
| 144 return GenerateSubtype1TestCacheLookup( | 142 return GenerateSubtype1TestCacheLookup( |
| 145 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); | 143 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); |
| 146 } | 144 } |
| 147 // If one type argument only, check if type argument is Object or dynamic. | 145 // If one type argument only, check if type argument is Object or dynamic. |
| 148 if (type_arguments.Length() == 1) { | 146 if (type_arguments.Length() == 1) { |
| 149 const AbstractType& tp_argument = AbstractType::ZoneHandle( | 147 const AbstractType& tp_argument = AbstractType::ZoneHandle( |
| 150 type_arguments.TypeAt(0)); | 148 type_arguments.TypeAt(0)); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 TypeArguments::Handle(), | 207 TypeArguments::Handle(), |
| 210 NULL)) { | 208 NULL)) { |
| 211 __ jmp(is_instance_lbl); | 209 __ jmp(is_instance_lbl); |
| 212 } else { | 210 } else { |
| 213 __ jmp(is_not_instance_lbl); | 211 __ jmp(is_not_instance_lbl); |
| 214 } | 212 } |
| 215 // Compare if the classes are equal. | 213 // Compare if the classes are equal. |
| 216 __ Bind(&compare_classes); | 214 __ Bind(&compare_classes); |
| 217 const Register kClassIdReg = R10; | 215 const Register kClassIdReg = R10; |
| 218 __ LoadClassId(kClassIdReg, kInstanceReg); | 216 __ LoadClassId(kClassIdReg, kInstanceReg); |
| 219 // If type is an interface, we can skip the class equality check. | 217 __ cmpl(kClassIdReg, Immediate(type_class.id())); |
| 220 if (!type_class.is_interface()) { | 218 __ j(EQUAL, is_instance_lbl); |
| 221 __ cmpl(kClassIdReg, Immediate(type_class.id())); | |
| 222 __ j(EQUAL, is_instance_lbl); | |
| 223 } | |
| 224 // Bool interface can be implemented only by core class Bool. | 219 // Bool interface can be implemented only by core class Bool. |
| 225 // (see ClassFinalizer::ResolveInterfaces for list of restricted interfaces). | 220 // (see ClassFinalizer::ResolveInterfaces for list of restricted interfaces). |
| 226 if (type.IsBoolType()) { | 221 if (type.IsBoolType()) { |
| 227 __ cmpl(kClassIdReg, Immediate(kBoolCid)); | 222 __ cmpl(kClassIdReg, Immediate(kBoolCid)); |
| 228 __ j(EQUAL, is_instance_lbl); | 223 __ j(EQUAL, is_instance_lbl); |
| 229 __ jmp(is_not_instance_lbl); | 224 __ jmp(is_not_instance_lbl); |
| 230 return false; | 225 return false; |
| 231 } | 226 } |
| 232 if (type.IsFunctionType()) { | 227 if (type.IsFunctionType()) { |
| 233 // Check if instance is a closure. | 228 // Check if instance is a closure. |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1409 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { | 1404 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { |
| 1410 __ Exchange(mem1, mem2); | 1405 __ Exchange(mem1, mem2); |
| 1411 } | 1406 } |
| 1412 | 1407 |
| 1413 | 1408 |
| 1414 #undef __ | 1409 #undef __ |
| 1415 | 1410 |
| 1416 } // namespace dart | 1411 } // namespace dart |
| 1417 | 1412 |
| 1418 #endif // defined TARGET_ARCH_X64 | 1413 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |