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

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

Issue 154393003: Implement eager instantiation and canonicalization of type arguments at run (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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) 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_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 "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 ASSERT(smi_is_ok || malformed_error.IsNull()); 244 ASSERT(smi_is_ok || malformed_error.IsNull());
245 __ testq(kInstanceReg, Immediate(kSmiTagMask)); 245 __ testq(kInstanceReg, Immediate(kSmiTagMask));
246 if (smi_is_ok) { 246 if (smi_is_ok) {
247 __ j(ZERO, is_instance_lbl); 247 __ j(ZERO, is_instance_lbl);
248 } else { 248 } else {
249 __ j(ZERO, is_not_instance_lbl); 249 __ j(ZERO, is_not_instance_lbl);
250 } 250 }
251 const intptr_t num_type_args = type_class.NumTypeArguments(); 251 const intptr_t num_type_args = type_class.NumTypeArguments();
252 const intptr_t num_type_params = type_class.NumTypeParameters(); 252 const intptr_t num_type_params = type_class.NumTypeParameters();
253 const intptr_t from_index = num_type_args - num_type_params; 253 const intptr_t from_index = num_type_args - num_type_params;
254 const AbstractTypeArguments& type_arguments = 254 const TypeArguments& type_arguments =
255 AbstractTypeArguments::ZoneHandle(type.arguments()); 255 TypeArguments::ZoneHandle(type.arguments());
256 const bool is_raw_type = type_arguments.IsNull() || 256 const bool is_raw_type = type_arguments.IsNull() ||
257 type_arguments.IsRaw(from_index, num_type_params); 257 type_arguments.IsRaw(from_index, num_type_params);
258 // Signature class is an instantiated parameterized type. 258 // Signature class is an instantiated parameterized type.
259 if (!type_class.IsSignatureClass()) { 259 if (!type_class.IsSignatureClass()) {
260 if (is_raw_type) { 260 if (is_raw_type) {
261 const Register kClassIdReg = R10; 261 const Register kClassIdReg = R10;
262 // dynamic type argument, check only classes. 262 // dynamic type argument, check only classes.
263 __ LoadClassId(kClassIdReg, kInstanceReg); 263 __ LoadClassId(kClassIdReg, kInstanceReg);
264 __ cmpl(kClassIdReg, Immediate(type_class.id())); 264 __ cmpl(kClassIdReg, Immediate(type_class.id()));
265 __ j(EQUAL, is_instance_lbl); 265 __ j(EQUAL, is_instance_lbl);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 Label* is_instance_lbl, 417 Label* is_instance_lbl,
418 Label* is_not_instance_lbl) { 418 Label* is_not_instance_lbl) {
419 __ Comment("UninstantiatedTypeTest"); 419 __ Comment("UninstantiatedTypeTest");
420 ASSERT(!type.IsInstantiated()); 420 ASSERT(!type.IsInstantiated());
421 // Skip check if destination is a dynamic type. 421 // Skip check if destination is a dynamic type.
422 if (type.IsTypeParameter()) { 422 if (type.IsTypeParameter()) {
423 const TypeParameter& type_param = TypeParameter::Cast(type); 423 const TypeParameter& type_param = TypeParameter::Cast(type);
424 // Load instantiator (or null) and instantiator type arguments on stack. 424 // Load instantiator (or null) and instantiator type arguments on stack.
425 __ movq(RDX, Address(RSP, 0)); // Get instantiator type arguments. 425 __ movq(RDX, Address(RSP, 0)); // Get instantiator type arguments.
426 // RDX: instantiator type arguments. 426 // RDX: instantiator type arguments.
427 // Check if type argument is dynamic. 427 // Check if type arguments are null, i.e. equivalent to vector of dynamic.
428 __ CompareObject(RDX, Object::null_object(), PP); 428 __ CompareObject(RDX, Object::null_object(), PP);
429 __ j(EQUAL, is_instance_lbl); 429 __ j(EQUAL, is_instance_lbl);
430 // Can handle only type arguments that are instances of TypeArguments.
431 // (runtime checks canonicalize type arguments).
432 Label fall_through;
433 __ CompareClassId(RDX, kTypeArgumentsCid);
434 __ j(NOT_EQUAL, &fall_through);
435 __ movq(RDI, 430 __ movq(RDI,
436 FieldAddress(RDX, TypeArguments::type_at_offset(type_param.index()))); 431 FieldAddress(RDX, TypeArguments::type_at_offset(type_param.index())));
437 // RDI: Concrete type of type. 432 // RDI: Concrete type of type.
438 // Check if type argument is dynamic. 433 // Check if type argument is dynamic.
439 __ CompareObject(RDI, Type::ZoneHandle(Type::DynamicType()), PP); 434 __ CompareObject(RDI, Type::ZoneHandle(Type::DynamicType()), PP);
440 __ j(EQUAL, is_instance_lbl); 435 __ j(EQUAL, is_instance_lbl);
441 __ CompareObject(RDI, Object::null_object(), PP);
442 __ j(EQUAL, is_instance_lbl);
443 const Type& object_type = Type::ZoneHandle(Type::ObjectType()); 436 const Type& object_type = Type::ZoneHandle(Type::ObjectType());
444 __ CompareObject(RDI, object_type, PP); 437 __ CompareObject(RDI, object_type, PP);
445 __ j(EQUAL, is_instance_lbl); 438 __ j(EQUAL, is_instance_lbl);
446 439
447 // For Smi check quickly against int and num interfaces. 440 // For Smi check quickly against int and num interfaces.
448 Label not_smi; 441 Label not_smi;
449 __ testq(RAX, Immediate(kSmiTagMask)); // Value is Smi? 442 __ testq(RAX, Immediate(kSmiTagMask)); // Value is Smi?
450 __ j(NOT_ZERO, &not_smi, Assembler::kNearJump); 443 __ j(NOT_ZERO, &not_smi, Assembler::kNearJump);
451 __ CompareObject(RDI, Type::ZoneHandle(Type::IntType()), PP); 444 __ CompareObject(RDI, Type::ZoneHandle(Type::IntType()), PP);
452 __ j(EQUAL, is_instance_lbl); 445 __ j(EQUAL, is_instance_lbl);
453 __ CompareObject(RDI, Type::ZoneHandle(Type::Number()), PP); 446 __ CompareObject(RDI, Type::ZoneHandle(Type::Number()), PP);
454 __ j(EQUAL, is_instance_lbl); 447 __ j(EQUAL, is_instance_lbl);
455 // Smi must be handled in runtime. 448 // Smi must be handled in runtime.
449 Label fall_through;
456 __ jmp(&fall_through); 450 __ jmp(&fall_through);
457 451
458 __ Bind(&not_smi); 452 __ Bind(&not_smi);
459 // RDX: instantiator type arguments. 453 // RDX: instantiator type arguments.
460 // RAX: instance. 454 // RAX: instance.
461 const Register kInstanceReg = RAX; 455 const Register kInstanceReg = RAX;
462 const Register kTypeArgumentsReg = RDX; 456 const Register kTypeArgumentsReg = RDX;
463 const Register kTempReg = R10; 457 const Register kTempReg = R10;
464 const SubtypeTestCache& type_test_cache = 458 const SubtypeTestCache& type_test_cache =
465 SubtypeTestCache::ZoneHandle( 459 SubtypeTestCache::ZoneHandle(
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 __ movups(reg, Address(RSP, 0)); 1852 __ movups(reg, Address(RSP, 0));
1859 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); 1853 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP);
1860 } 1854 }
1861 1855
1862 1856
1863 #undef __ 1857 #undef __
1864 1858
1865 } // namespace dart 1859 } // namespace dart
1866 1860
1867 #endif // defined TARGET_ARCH_X64 1861 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698