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

Side by Side Diff: runtime/vm/flow_graph_compiler_mips.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_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 ASSERT(smi_is_ok || malformed_error.IsNull()); 242 ASSERT(smi_is_ok || malformed_error.IsNull());
243 __ andi(CMPRES1, kInstanceReg, Immediate(kSmiTagMask)); 243 __ andi(CMPRES1, kInstanceReg, Immediate(kSmiTagMask));
244 if (smi_is_ok) { 244 if (smi_is_ok) {
245 __ beq(CMPRES1, ZR, is_instance_lbl); 245 __ beq(CMPRES1, ZR, is_instance_lbl);
246 } else { 246 } else {
247 __ beq(CMPRES1, ZR, is_not_instance_lbl); 247 __ beq(CMPRES1, ZR, is_not_instance_lbl);
248 } 248 }
249 const intptr_t num_type_args = type_class.NumTypeArguments(); 249 const intptr_t num_type_args = type_class.NumTypeArguments();
250 const intptr_t num_type_params = type_class.NumTypeParameters(); 250 const intptr_t num_type_params = type_class.NumTypeParameters();
251 const intptr_t from_index = num_type_args - num_type_params; 251 const intptr_t from_index = num_type_args - num_type_params;
252 const AbstractTypeArguments& type_arguments = 252 const TypeArguments& type_arguments =
253 AbstractTypeArguments::ZoneHandle(type.arguments()); 253 TypeArguments::ZoneHandle(type.arguments());
254 const bool is_raw_type = type_arguments.IsNull() || 254 const bool is_raw_type = type_arguments.IsNull() ||
255 type_arguments.IsRaw(from_index, num_type_params); 255 type_arguments.IsRaw(from_index, num_type_params);
256 // Signature class is an instantiated parameterized type. 256 // Signature class is an instantiated parameterized type.
257 if (!type_class.IsSignatureClass()) { 257 if (!type_class.IsSignatureClass()) {
258 if (is_raw_type) { 258 if (is_raw_type) {
259 const Register kClassIdReg = T0; 259 const Register kClassIdReg = T0;
260 // dynamic type argument, check only classes. 260 // dynamic type argument, check only classes.
261 __ LoadClassId(kClassIdReg, kInstanceReg); 261 __ LoadClassId(kClassIdReg, kInstanceReg);
262 __ BranchEqual(kClassIdReg, type_class.id(), is_instance_lbl); 262 __ BranchEqual(kClassIdReg, type_class.id(), is_instance_lbl);
263 // List is a very common case. 263 // List is a very common case.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 Label* is_not_instance_lbl) { 415 Label* is_not_instance_lbl) {
416 __ TraceSimMsg("UninstantiatedTypeTest"); 416 __ TraceSimMsg("UninstantiatedTypeTest");
417 __ Comment("UninstantiatedTypeTest"); 417 __ Comment("UninstantiatedTypeTest");
418 ASSERT(!type.IsInstantiated()); 418 ASSERT(!type.IsInstantiated());
419 // Skip check if destination is a dynamic type. 419 // Skip check if destination is a dynamic type.
420 if (type.IsTypeParameter()) { 420 if (type.IsTypeParameter()) {
421 const TypeParameter& type_param = TypeParameter::Cast(type); 421 const TypeParameter& type_param = TypeParameter::Cast(type);
422 // Load instantiator (or null) and instantiator type arguments on stack. 422 // Load instantiator (or null) and instantiator type arguments on stack.
423 __ lw(A1, Address(SP, 0)); // Get instantiator type arguments. 423 __ lw(A1, Address(SP, 0)); // Get instantiator type arguments.
424 // A1: instantiator type arguments. 424 // A1: instantiator type arguments.
425 // Check if type argument is dynamic. 425 // Check if type arguments are null, i.e. equivalent to vector of dynamic.
426 __ LoadImmediate(T7, reinterpret_cast<int32_t>(Object::null())); 426 __ LoadImmediate(T7, reinterpret_cast<int32_t>(Object::null()));
427 __ beq(A1, T7, is_instance_lbl); 427 __ beq(A1, T7, is_instance_lbl);
428 // Can handle only type arguments that are instances of TypeArguments.
429 // (runtime checks canonicalize type arguments).
430 Label fall_through;
431 __ LoadClassId(T2, A1);
432 __ BranchNotEqual(T2, kTypeArgumentsCid, &fall_through);
433 __ lw(T2, 428 __ lw(T2,
434 FieldAddress(A1, TypeArguments::type_at_offset(type_param.index()))); 429 FieldAddress(A1, TypeArguments::type_at_offset(type_param.index())));
435 // R2: concrete type of type. 430 // R2: concrete type of type.
436 // Check if type argument is dynamic. 431 // Check if type argument is dynamic.
437 __ BranchEqual(T2, Type::ZoneHandle(Type::DynamicType()), is_instance_lbl); 432 __ BranchEqual(T2, Type::ZoneHandle(Type::DynamicType()), is_instance_lbl);
438 __ beq(T2, T7, is_instance_lbl); 433 __ BranchEqual(T2, Type::ZoneHandle(Type::ObjectType()), is_instance_lbl);
439 const Type& object_type = Type::ZoneHandle(Type::ObjectType());
440 __ BranchEqual(T2, object_type, is_instance_lbl);
441 434
442 // For Smi check quickly against int and num interfaces. 435 // For Smi check quickly against int and num interfaces.
443 Label not_smi; 436 Label not_smi;
444 __ andi(CMPRES1, A0, Immediate(kSmiTagMask)); 437 __ andi(CMPRES1, A0, Immediate(kSmiTagMask));
445 __ bne(CMPRES1, ZR, &not_smi); // Value is Smi? 438 __ bne(CMPRES1, ZR, &not_smi); // Value is Smi?
446 __ BranchEqual(T2, Type::ZoneHandle(Type::IntType()), is_instance_lbl); 439 __ BranchEqual(T2, Type::ZoneHandle(Type::IntType()), is_instance_lbl);
447 __ BranchEqual(T2, Type::ZoneHandle(Type::Number()), is_instance_lbl); 440 __ BranchEqual(T2, Type::ZoneHandle(Type::Number()), is_instance_lbl);
448
449 // Smi must be handled in runtime. 441 // Smi must be handled in runtime.
442 Label fall_through;
450 __ b(&fall_through); 443 __ b(&fall_through);
451 444
452 __ Bind(&not_smi); 445 __ Bind(&not_smi);
453 // T1: instantiator type arguments. 446 // T1: instantiator type arguments.
454 // A0: instance. 447 // A0: instance.
455 const Register kInstanceReg = A0; 448 const Register kInstanceReg = A0;
456 const Register kTypeArgumentsReg = A1; 449 const Register kTypeArgumentsReg = A1;
457 const Register kTempReg = kNoRegister; 450 const Register kTempReg = kNoRegister;
458 const SubtypeTestCache& type_test_cache = 451 const SubtypeTestCache& type_test_cache =
459 SubtypeTestCache::ZoneHandle( 452 SubtypeTestCache::ZoneHandle(
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 __ AddImmediate(SP, kDoubleSize); 1871 __ AddImmediate(SP, kDoubleSize);
1879 } 1872 }
1880 1873
1881 1874
1882 #undef __ 1875 #undef __
1883 1876
1884 1877
1885 } // namespace dart 1878 } // namespace dart
1886 1879
1887 #endif // defined TARGET_ARCH_MIPS 1880 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698