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

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

Powered by Google App Engine
This is Rietveld 408576698