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

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

Issue 18807007: Fix wrong type test optimization when testing against a signature class: we must always consider th… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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) 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 "lib/error.h" 10 #include "lib/error.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // Clobbers T0. 217 // Clobbers T0.
218 RawSubtypeTestCache* 218 RawSubtypeTestCache*
219 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest( 219 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest(
220 intptr_t token_pos, 220 intptr_t token_pos,
221 const AbstractType& type, 221 const AbstractType& type,
222 Label* is_instance_lbl, 222 Label* is_instance_lbl,
223 Label* is_not_instance_lbl) { 223 Label* is_not_instance_lbl) {
224 __ Comment("InstantiatedTypeWithArgumentsTest"); 224 __ Comment("InstantiatedTypeWithArgumentsTest");
225 ASSERT(type.IsInstantiated()); 225 ASSERT(type.IsInstantiated());
226 const Class& type_class = Class::ZoneHandle(type.type_class()); 226 const Class& type_class = Class::ZoneHandle(type.type_class());
227 ASSERT(type_class.HasTypeArguments()); 227 ASSERT(type_class.HasTypeArguments() || type_class.IsSignatureClass());
228 const Register kInstanceReg = A0; 228 const Register kInstanceReg = A0;
229 Error& malformed_error = Error::Handle(); 229 Error& malformed_error = Error::Handle();
230 const Type& int_type = Type::Handle(Type::IntType()); 230 const Type& int_type = Type::Handle(Type::IntType());
231 const bool smi_is_ok = int_type.IsSubtypeOf(type, &malformed_error); 231 const bool smi_is_ok = int_type.IsSubtypeOf(type, &malformed_error);
232 // Malforrmed type should have been handled at graph construction time. 232 // Malformed type should have been handled at graph construction time.
233 ASSERT(smi_is_ok || malformed_error.IsNull()); 233 ASSERT(smi_is_ok || malformed_error.IsNull());
234 __ andi(CMPRES, kInstanceReg, Immediate(kSmiTagMask)); 234 __ andi(CMPRES, kInstanceReg, Immediate(kSmiTagMask));
235 if (smi_is_ok) { 235 if (smi_is_ok) {
236 __ beq(CMPRES, ZR, is_instance_lbl); 236 __ beq(CMPRES, ZR, is_instance_lbl);
237 } else { 237 } else {
238 __ beq(CMPRES, ZR, is_not_instance_lbl); 238 __ beq(CMPRES, ZR, is_not_instance_lbl);
239 } 239 }
240 const AbstractTypeArguments& type_arguments = 240 const AbstractTypeArguments& type_arguments =
241 AbstractTypeArguments::ZoneHandle(type.arguments()); 241 AbstractTypeArguments::ZoneHandle(type.arguments());
242 const bool is_raw_type = type_arguments.IsNull() || 242 const bool is_raw_type = type_arguments.IsNull() ||
243 type_arguments.IsRaw(type_arguments.Length()); 243 type_arguments.IsRaw(type_arguments.Length());
244 if (is_raw_type) { 244 if (!type_class.IsSignatureClass()) {
245 const Register kClassIdReg = T0; 245 if (is_raw_type) {
246 // dynamic type argument, check only classes. 246 const Register kClassIdReg = T0;
247 __ LoadClassId(kClassIdReg, kInstanceReg); 247 // dynamic type argument, check only classes.
248 __ BranchEqual(kClassIdReg, type_class.id(), is_instance_lbl); 248 __ LoadClassId(kClassIdReg, kInstanceReg);
249 // List is a very common case. 249 __ BranchEqual(kClassIdReg, type_class.id(), is_instance_lbl);
250 if (IsListClass(type_class)) { 250 // List is a very common case.
251 GenerateListTypeCheck(kClassIdReg, is_instance_lbl); 251 if (IsListClass(type_class)) {
252 GenerateListTypeCheck(kClassIdReg, is_instance_lbl);
253 }
254 return GenerateSubtype1TestCacheLookup(
255 token_pos, type_class, is_instance_lbl, is_not_instance_lbl);
252 } 256 }
253 return GenerateSubtype1TestCacheLookup( 257 // If one type argument only, check if type argument is Object or dynamic.
254 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); 258 if (type_arguments.Length() == 1) {
255 } 259 const AbstractType& tp_argument = AbstractType::ZoneHandle(
256 // If one type argument only, check if type argument is Object or dynamic. 260 type_arguments.TypeAt(0));
257 if (type_arguments.Length() == 1) { 261 ASSERT(!tp_argument.IsMalformed());
258 const AbstractType& tp_argument = AbstractType::ZoneHandle( 262 if (tp_argument.IsType()) {
259 type_arguments.TypeAt(0)); 263 ASSERT(tp_argument.HasResolvedTypeClass());
260 ASSERT(!tp_argument.IsMalformed()); 264 // Check if type argument is dynamic or Object.
261 if (tp_argument.IsType()) { 265 const Type& object_type = Type::Handle(Type::ObjectType());
262 ASSERT(tp_argument.HasResolvedTypeClass()); 266 if (object_type.IsSubtypeOf(tp_argument, NULL)) {
263 // Check if type argument is dynamic or Object. 267 // Instance class test only necessary.
264 const Type& object_type = Type::Handle(Type::ObjectType()); 268 return GenerateSubtype1TestCacheLookup(
265 if (object_type.IsSubtypeOf(tp_argument, NULL)) { 269 token_pos, type_class, is_instance_lbl, is_not_instance_lbl);
266 // Instance class test only necessary. 270 }
267 return GenerateSubtype1TestCacheLookup(
268 token_pos, type_class, is_instance_lbl, is_not_instance_lbl);
269 } 271 }
270 } 272 }
271 } 273 }
272 // Regular subtype test cache involving instance's type arguments. 274 // Regular subtype test cache involving instance's type arguments.
273 const Register kTypeArgumentsReg = kNoRegister; 275 const Register kTypeArgumentsReg = kNoRegister;
274 const Register kTempReg = kNoRegister; 276 const Register kTempReg = kNoRegister;
275 // A0: instance (must be preserved). 277 // A0: instance (must be preserved).
276 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs, 278 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs,
277 kInstanceReg, 279 kInstanceReg,
278 kTypeArgumentsReg, 280 kTypeArgumentsReg,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 __ LoadClassId(T0, kInstanceReg); 505 __ LoadClassId(T0, kInstanceReg);
504 __ BranchEqual(T0, type_cid, is_instance_lbl); 506 __ BranchEqual(T0, type_cid, is_instance_lbl);
505 } 507 }
506 __ b(is_not_instance_lbl); 508 __ b(is_not_instance_lbl);
507 return SubtypeTestCache::null(); 509 return SubtypeTestCache::null();
508 } 510 }
509 if (type.IsInstantiated()) { 511 if (type.IsInstantiated()) {
510 const Class& type_class = Class::ZoneHandle(type.type_class()); 512 const Class& type_class = Class::ZoneHandle(type.type_class());
511 // A class equality check is only applicable with a dst type of a 513 // A class equality check is only applicable with a dst type of a
512 // non-parameterized class or with a raw dst type of a parameterized class. 514 // non-parameterized class or with a raw dst type of a parameterized class.
513 if (type_class.HasTypeArguments()) { 515 if (type_class.IsSignatureClass() || type_class.HasTypeArguments()) {
514 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, 516 return GenerateInstantiatedTypeWithArgumentsTest(token_pos,
515 type, 517 type,
516 is_instance_lbl, 518 is_instance_lbl,
517 is_not_instance_lbl); 519 is_not_instance_lbl);
518 // Fall through to runtime call. 520 // Fall through to runtime call.
519 } 521 }
520 const bool has_fall_through = 522 const bool has_fall_through =
521 GenerateInstantiatedTypeNoArgumentsTest(token_pos, 523 GenerateInstantiatedTypeNoArgumentsTest(token_pos,
522 type, 524 type,
523 is_instance_lbl, 525 is_instance_lbl,
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 __ AddImmediate(SP, kDoubleSize); 1999 __ AddImmediate(SP, kDoubleSize);
1998 } 2000 }
1999 2001
2000 2002
2001 #undef __ 2003 #undef __
2002 2004
2003 2005
2004 } // namespace dart 2006 } // namespace dart
2005 2007
2006 #endif // defined TARGET_ARCH_MIPS 2008 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698