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

Side by Side Diff: runtime/vm/flow_graph_compiler_ia32.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_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 "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 ASSERT(smi_is_ok || malformed_error.IsNull()); 246 ASSERT(smi_is_ok || malformed_error.IsNull());
247 __ testl(kInstanceReg, Immediate(kSmiTagMask)); 247 __ testl(kInstanceReg, Immediate(kSmiTagMask));
248 if (smi_is_ok) { 248 if (smi_is_ok) {
249 __ j(ZERO, is_instance_lbl); 249 __ j(ZERO, is_instance_lbl);
250 } else { 250 } else {
251 __ j(ZERO, is_not_instance_lbl); 251 __ j(ZERO, is_not_instance_lbl);
252 } 252 }
253 const intptr_t num_type_args = type_class.NumTypeArguments(); 253 const intptr_t num_type_args = type_class.NumTypeArguments();
254 const intptr_t num_type_params = type_class.NumTypeParameters(); 254 const intptr_t num_type_params = type_class.NumTypeParameters();
255 const intptr_t from_index = num_type_args - num_type_params; 255 const intptr_t from_index = num_type_args - num_type_params;
256 const AbstractTypeArguments& type_arguments = 256 const TypeArguments& type_arguments =
257 AbstractTypeArguments::ZoneHandle(type.arguments()); 257 TypeArguments::ZoneHandle(type.arguments());
258 const bool is_raw_type = type_arguments.IsNull() || 258 const bool is_raw_type = type_arguments.IsNull() ||
259 type_arguments.IsRaw(from_index, num_type_params); 259 type_arguments.IsRaw(from_index, num_type_params);
260 // Signature class is an instantiated parameterized type. 260 // Signature class is an instantiated parameterized type.
261 if (!type_class.IsSignatureClass()) { 261 if (!type_class.IsSignatureClass()) {
262 if (is_raw_type) { 262 if (is_raw_type) {
263 const Register kClassIdReg = ECX; 263 const Register kClassIdReg = ECX;
264 // dynamic type argument, check only classes. 264 // dynamic type argument, check only classes.
265 __ LoadClassId(kClassIdReg, kInstanceReg); 265 __ LoadClassId(kClassIdReg, kInstanceReg);
266 __ cmpl(kClassIdReg, Immediate(type_class.id())); 266 __ cmpl(kClassIdReg, Immediate(type_class.id()));
267 __ j(EQUAL, is_instance_lbl); 267 __ j(EQUAL, is_instance_lbl);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 __ Comment("UninstantiatedTypeTest"); 423 __ Comment("UninstantiatedTypeTest");
424 ASSERT(!type.IsInstantiated()); 424 ASSERT(!type.IsInstantiated());
425 // Skip check if destination is a dynamic type. 425 // Skip check if destination is a dynamic type.
426 const Immediate& raw_null = 426 const Immediate& raw_null =
427 Immediate(reinterpret_cast<intptr_t>(Object::null())); 427 Immediate(reinterpret_cast<intptr_t>(Object::null()));
428 if (type.IsTypeParameter()) { 428 if (type.IsTypeParameter()) {
429 const TypeParameter& type_param = TypeParameter::Cast(type); 429 const TypeParameter& type_param = TypeParameter::Cast(type);
430 // Load instantiator (or null) and instantiator type arguments on stack. 430 // Load instantiator (or null) and instantiator type arguments on stack.
431 __ movl(EDX, Address(ESP, 0)); // Get instantiator type arguments. 431 __ movl(EDX, Address(ESP, 0)); // Get instantiator type arguments.
432 // EDX: instantiator type arguments. 432 // EDX: instantiator type arguments.
433 // Check if type argument is dynamic. 433 // Check if type arguments are null, i.e. equivalent to vector of dynamic.
434 __ cmpl(EDX, raw_null); 434 __ cmpl(EDX, raw_null);
435 __ j(EQUAL, is_instance_lbl); 435 __ j(EQUAL, is_instance_lbl);
436 // Can handle only type arguments that are instances of TypeArguments.
437 // (runtime checks canonicalize type arguments).
438 Label fall_through;
439 __ CompareClassId(EDX, kTypeArgumentsCid, EDI);
440 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump);
441 __ movl(EDI, 436 __ movl(EDI,
442 FieldAddress(EDX, TypeArguments::type_at_offset(type_param.index()))); 437 FieldAddress(EDX, TypeArguments::type_at_offset(type_param.index())));
443 // EDI: concrete type of type. 438 // EDI: concrete type of type.
444 // Check if type argument is dynamic. 439 // Check if type argument is dynamic.
445 __ CompareObject(EDI, Type::ZoneHandle(Type::DynamicType())); 440 __ CompareObject(EDI, Type::ZoneHandle(Type::DynamicType()));
446 __ j(EQUAL, is_instance_lbl); 441 __ j(EQUAL, is_instance_lbl);
447 __ cmpl(EDI, raw_null); 442 __ CompareObject(EDI, Type::ZoneHandle(Type::ObjectType()));
448 __ j(EQUAL, is_instance_lbl);
449 const Type& object_type = Type::ZoneHandle(Type::ObjectType());
450 __ CompareObject(EDI, object_type);
451 __ j(EQUAL, is_instance_lbl); 443 __ j(EQUAL, is_instance_lbl);
452 444
453 // For Smi check quickly against int and num interfaces. 445 // For Smi check quickly against int and num interfaces.
454 Label not_smi; 446 Label not_smi;
455 __ testl(EAX, Immediate(kSmiTagMask)); // Value is Smi? 447 __ testl(EAX, Immediate(kSmiTagMask)); // Value is Smi?
456 __ j(NOT_ZERO, &not_smi, Assembler::kNearJump); 448 __ j(NOT_ZERO, &not_smi, Assembler::kNearJump);
457 __ CompareObject(EDI, Type::ZoneHandle(Type::IntType())); 449 __ CompareObject(EDI, Type::ZoneHandle(Type::IntType()));
458 __ j(EQUAL, is_instance_lbl); 450 __ j(EQUAL, is_instance_lbl);
459 __ CompareObject(EDI, Type::ZoneHandle(Type::Number())); 451 __ CompareObject(EDI, Type::ZoneHandle(Type::Number()));
460 __ j(EQUAL, is_instance_lbl); 452 __ j(EQUAL, is_instance_lbl);
461 // Smi must be handled in runtime. 453 // Smi must be handled in runtime.
454 Label fall_through;
462 __ jmp(&fall_through); 455 __ jmp(&fall_through);
463 456
464 __ Bind(&not_smi); 457 __ Bind(&not_smi);
465 // EDX: instantiator type arguments. 458 // EDX: instantiator type arguments.
466 // EAX: instance. 459 // EAX: instance.
467 const Register kInstanceReg = EAX; 460 const Register kInstanceReg = EAX;
468 const Register kTypeArgumentsReg = EDX; 461 const Register kTypeArgumentsReg = EDX;
469 const Register kTempReg = EDI; 462 const Register kTempReg = EDI;
470 const SubtypeTestCache& type_test_cache = 463 const SubtypeTestCache& type_test_cache =
471 SubtypeTestCache::ZoneHandle( 464 SubtypeTestCache::ZoneHandle(
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 __ movups(reg, Address(ESP, 0)); 1825 __ movups(reg, Address(ESP, 0));
1833 __ addl(ESP, Immediate(kFpuRegisterSize)); 1826 __ addl(ESP, Immediate(kFpuRegisterSize));
1834 } 1827 }
1835 1828
1836 1829
1837 #undef __ 1830 #undef __
1838 1831
1839 } // namespace dart 1832 } // namespace dart
1840 1833
1841 #endif // defined TARGET_ARCH_IA32 1834 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698