Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: runtime/vm/flow_graph_compiler_x64.cc

Issue 10696013: Consider upper bounds of type parameters in type checks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 intptr_t cid, 305 intptr_t cid,
306 intptr_t token_pos, 306 intptr_t token_pos,
307 const AbstractType& type, 307 const AbstractType& type,
308 Label* is_instance_lbl, 308 Label* is_instance_lbl,
309 Label* is_not_instance_lbl) { 309 Label* is_not_instance_lbl) {
310 ASSERT(!type.IsInstantiated()); 310 ASSERT(!type.IsInstantiated());
311 // Skip check if destination is a dynamic type. 311 // Skip check if destination is a dynamic type.
312 const Immediate raw_null = 312 const Immediate raw_null =
313 Immediate(reinterpret_cast<intptr_t>(Object::null())); 313 Immediate(reinterpret_cast<intptr_t>(Object::null()));
314 if (type.IsTypeParameter()) { 314 if (type.IsTypeParameter()) {
315 // Load instantiator (or null) and instantiator type arguments on stack. 315 // TODO(regis): Introduce and use TypeParameter::Cast().
316 const TypeParameter* type_param =
317 reinterpret_cast<const TypeParameter*>(&type);
318 // Load instantiator (or null) and instantiator type arguments on stack.
316 __ movq(RDX, Address(RSP, 0)); // Get instantiator type arguments. 319 __ movq(RDX, Address(RSP, 0)); // Get instantiator type arguments.
317 // RDX: instantiator type arguments. 320 // RDX: instantiator type arguments.
318 // Check if type argument is Dynamic. 321 // Check if type argument is Dynamic.
319 __ cmpq(RDX, raw_null); 322 __ cmpq(RDX, raw_null);
320 __ j(EQUAL, is_instance_lbl); 323 __ j(EQUAL, is_instance_lbl);
321 // Can handle only type arguments that are instances of TypeArguments. 324 // Can handle only type arguments that are instances of TypeArguments.
322 // (runtime checks canonicalize type arguments). 325 // (runtime checks canonicalize type arguments).
323 Label fall_through; 326 Label fall_through;
324 __ CompareClassId(RDX, kTypeArguments); 327 __ CompareClassId(RDX, kTypeArguments);
325 __ j(NOT_EQUAL, &fall_through); 328 __ j(NOT_EQUAL, &fall_through);
326 __ movq(RDI, 329 __ movq(RDI,
327 FieldAddress(RDX, TypeArguments::type_at_offset(type.Index()))); 330 FieldAddress(RDX, TypeArguments::type_at_offset(type_param->index())));
328 // RDI: Concrete type of type. 331 // RDI: Concrete type of type.
329 // Check if type argument is dynamic. 332 // Check if type argument is dynamic.
330 __ CompareObject(RDI, Type::ZoneHandle(Type::DynamicType())); 333 __ CompareObject(RDI, Type::ZoneHandle(Type::DynamicType()));
331 __ j(EQUAL, is_instance_lbl); 334 __ j(EQUAL, is_instance_lbl);
332 __ cmpq(RDI, raw_null); 335 __ cmpq(RDI, raw_null);
333 __ j(EQUAL, is_instance_lbl); 336 __ j(EQUAL, is_instance_lbl);
334 const Type& object_type = Type::ZoneHandle(Type::ObjectType()); 337 const Type& object_type = Type::ZoneHandle(Type::ObjectType());
335 __ CompareObject(RDI, object_type); 338 __ CompareObject(RDI, object_type);
336 __ j(EQUAL, is_instance_lbl); 339 __ j(EQUAL, is_instance_lbl);
337 340
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 __ cvtsi2sd(result, temp); 1080 __ cvtsi2sd(result, temp);
1078 __ Bind(&done); 1081 __ Bind(&done);
1079 } 1082 }
1080 1083
1081 1084
1082 #undef __ 1085 #undef __
1083 1086
1084 } // namespace dart 1087 } // namespace dart
1085 1088
1086 #endif // defined TARGET_ARCH_X64 1089 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698