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

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
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.cc ('k') | runtime/vm/flow_graph_compiler_x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Signature class is an instantiated parameterized type.
245 const Register kClassIdReg = T0; 245 if (!type_class.IsSignatureClass()) {
246 // dynamic type argument, check only classes. 246 if (is_raw_type) {
247 __ LoadClassId(kClassIdReg, kInstanceReg); 247 const Register kClassIdReg = T0;
248 __ BranchEqual(kClassIdReg, type_class.id(), is_instance_lbl); 248 // dynamic type argument, check only classes.
249 // List is a very common case. 249 __ LoadClassId(kClassIdReg, kInstanceReg);
250 if (IsListClass(type_class)) { 250 __ BranchEqual(kClassIdReg, type_class.id(), is_instance_lbl);
251 GenerateListTypeCheck(kClassIdReg, is_instance_lbl); 251 // List is a very common case.
252 if (IsListClass(type_class)) {
253 GenerateListTypeCheck(kClassIdReg, is_instance_lbl);
254 }
255 return GenerateSubtype1TestCacheLookup(
256 token_pos, type_class, is_instance_lbl, is_not_instance_lbl);
252 } 257 }
253 return GenerateSubtype1TestCacheLookup( 258 // 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); 259 if (type_arguments.Length() == 1) {
255 } 260 const AbstractType& tp_argument = AbstractType::ZoneHandle(
256 // If one type argument only, check if type argument is Object or dynamic. 261 type_arguments.TypeAt(0));
257 if (type_arguments.Length() == 1) { 262 ASSERT(!tp_argument.IsMalformed());
258 const AbstractType& tp_argument = AbstractType::ZoneHandle( 263 if (tp_argument.IsType()) {
259 type_arguments.TypeAt(0)); 264 ASSERT(tp_argument.HasResolvedTypeClass());
260 ASSERT(!tp_argument.IsMalformed()); 265 // Check if type argument is dynamic or Object.
261 if (tp_argument.IsType()) { 266 const Type& object_type = Type::Handle(Type::ObjectType());
262 ASSERT(tp_argument.HasResolvedTypeClass()); 267 if (object_type.IsSubtypeOf(tp_argument, NULL)) {
263 // Check if type argument is dynamic or Object. 268 // Instance class test only necessary.
264 const Type& object_type = Type::Handle(Type::ObjectType()); 269 return GenerateSubtype1TestCacheLookup(
265 if (object_type.IsSubtypeOf(tp_argument, NULL)) { 270 token_pos, type_class, is_instance_lbl, is_not_instance_lbl);
266 // Instance class test only necessary. 271 }
267 return GenerateSubtype1TestCacheLookup(
268 token_pos, type_class, is_instance_lbl, is_not_instance_lbl);
269 } 272 }
270 } 273 }
271 } 274 }
272 // Regular subtype test cache involving instance's type arguments. 275 // Regular subtype test cache involving instance's type arguments.
273 const Register kTypeArgumentsReg = kNoRegister; 276 const Register kTypeArgumentsReg = kNoRegister;
274 const Register kTempReg = kNoRegister; 277 const Register kTempReg = kNoRegister;
275 // A0: instance (must be preserved). 278 // A0: instance (must be preserved).
276 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs, 279 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs,
277 kInstanceReg, 280 kInstanceReg,
278 kTypeArgumentsReg, 281 kTypeArgumentsReg,
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 __ beq(CMPRES, ZR, is_not_instance_lbl); 505 __ beq(CMPRES, ZR, is_not_instance_lbl);
503 __ LoadClassId(T0, kInstanceReg); 506 __ LoadClassId(T0, kInstanceReg);
504 __ BranchEqual(T0, type_cid, is_instance_lbl); 507 __ BranchEqual(T0, type_cid, is_instance_lbl);
505 } 508 }
506 __ b(is_not_instance_lbl); 509 __ b(is_not_instance_lbl);
507 return SubtypeTestCache::null(); 510 return SubtypeTestCache::null();
508 } 511 }
509 if (type.IsInstantiated()) { 512 if (type.IsInstantiated()) {
510 const Class& type_class = Class::ZoneHandle(type.type_class()); 513 const Class& type_class = Class::ZoneHandle(type.type_class());
511 // A class equality check is only applicable with a dst type of a 514 // 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. 515 // non-parameterized class, non-signature class, or with a raw dst type of
513 if (type_class.HasTypeArguments()) { 516 // a parameterized class.
517 if (type_class.IsSignatureClass() || type_class.HasTypeArguments()) {
514 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, 518 return GenerateInstantiatedTypeWithArgumentsTest(token_pos,
515 type, 519 type,
516 is_instance_lbl, 520 is_instance_lbl,
517 is_not_instance_lbl); 521 is_not_instance_lbl);
518 // Fall through to runtime call. 522 // Fall through to runtime call.
519 } 523 }
520 const bool has_fall_through = 524 const bool has_fall_through =
521 GenerateInstantiatedTypeNoArgumentsTest(token_pos, 525 GenerateInstantiatedTypeNoArgumentsTest(token_pos,
522 type, 526 type,
523 is_instance_lbl, 527 is_instance_lbl,
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 __ AddImmediate(SP, kDoubleSize); 2001 __ AddImmediate(SP, kDoubleSize);
1998 } 2002 }
1999 2003
2000 2004
2001 #undef __ 2005 #undef __
2002 2006
2003 2007
2004 } // namespace dart 2008 } // namespace dart
2005 2009
2006 #endif // defined TARGET_ARCH_MIPS 2010 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.cc ('k') | runtime/vm/flow_graph_compiler_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698