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

Side by Side Diff: runtime/vm/flow_graph_compiler_ia32.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_arm.cc ('k') | runtime/vm/flow_graph_compiler_mips.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_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 "lib/error.h" 10 #include "lib/error.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // Clobbers ECX, EDI. 224 // Clobbers ECX, EDI.
225 RawSubtypeTestCache* 225 RawSubtypeTestCache*
226 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest( 226 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest(
227 intptr_t token_pos, 227 intptr_t token_pos,
228 const AbstractType& type, 228 const AbstractType& type,
229 Label* is_instance_lbl, 229 Label* is_instance_lbl,
230 Label* is_not_instance_lbl) { 230 Label* is_not_instance_lbl) {
231 __ Comment("InstantiatedTypeWithArgumentsTest"); 231 __ Comment("InstantiatedTypeWithArgumentsTest");
232 ASSERT(type.IsInstantiated()); 232 ASSERT(type.IsInstantiated());
233 const Class& type_class = Class::ZoneHandle(type.type_class()); 233 const Class& type_class = Class::ZoneHandle(type.type_class());
234 ASSERT(type_class.HasTypeArguments()); 234 ASSERT(type_class.HasTypeArguments() || type_class.IsSignatureClass());
235 const Register kInstanceReg = EAX; 235 const Register kInstanceReg = EAX;
236 Error& malformed_error = Error::Handle(); 236 Error& malformed_error = Error::Handle();
237 const Type& int_type = Type::Handle(Type::IntType()); 237 const Type& int_type = Type::Handle(Type::IntType());
238 const bool smi_is_ok = int_type.IsSubtypeOf(type, &malformed_error); 238 const bool smi_is_ok = int_type.IsSubtypeOf(type, &malformed_error);
239 // Malforrmed type should have been handled at graph construction time. 239 // Malformed type should have been handled at graph construction time.
240 ASSERT(smi_is_ok || malformed_error.IsNull()); 240 ASSERT(smi_is_ok || malformed_error.IsNull());
241 __ testl(kInstanceReg, Immediate(kSmiTagMask)); 241 __ testl(kInstanceReg, Immediate(kSmiTagMask));
242 if (smi_is_ok) { 242 if (smi_is_ok) {
243 __ j(ZERO, is_instance_lbl); 243 __ j(ZERO, is_instance_lbl);
244 } else { 244 } else {
245 __ j(ZERO, is_not_instance_lbl); 245 __ j(ZERO, is_not_instance_lbl);
246 } 246 }
247 const AbstractTypeArguments& type_arguments = 247 const AbstractTypeArguments& type_arguments =
248 AbstractTypeArguments::ZoneHandle(type.arguments()); 248 AbstractTypeArguments::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(type_arguments.Length()); 250 type_arguments.IsRaw(type_arguments.Length());
251 if (is_raw_type) { 251 // Signature class is an instantiated parameterized type.
252 const Register kClassIdReg = ECX; 252 if (!type_class.IsSignatureClass()) {
253 // dynamic type argument, check only classes. 253 if (is_raw_type) {
254 __ LoadClassId(kClassIdReg, kInstanceReg); 254 const Register kClassIdReg = ECX;
255 __ cmpl(kClassIdReg, Immediate(type_class.id())); 255 // dynamic type argument, check only classes.
256 __ j(EQUAL, is_instance_lbl); 256 __ LoadClassId(kClassIdReg, kInstanceReg);
257 // List is a very common case. 257 __ cmpl(kClassIdReg, Immediate(type_class.id()));
258 if (IsListClass(type_class)) { 258 __ j(EQUAL, is_instance_lbl);
259 GenerateListTypeCheck(kClassIdReg, is_instance_lbl); 259 // List is a very common case.
260 if (IsListClass(type_class)) {
261 GenerateListTypeCheck(kClassIdReg, is_instance_lbl);
262 }
263 return GenerateSubtype1TestCacheLookup(
264 token_pos, type_class, is_instance_lbl, is_not_instance_lbl);
260 } 265 }
261 return GenerateSubtype1TestCacheLookup( 266 // If one type argument only, check if type argument is Object or dynamic.
262 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); 267 if (type_arguments.Length() == 1) {
263 } 268 const AbstractType& tp_argument = AbstractType::ZoneHandle(
264 // If one type argument only, check if type argument is Object or dynamic. 269 type_arguments.TypeAt(0));
265 if (type_arguments.Length() == 1) { 270 ASSERT(!tp_argument.IsMalformed());
266 const AbstractType& tp_argument = AbstractType::ZoneHandle( 271 if (tp_argument.IsType()) {
267 type_arguments.TypeAt(0)); 272 ASSERT(tp_argument.HasResolvedTypeClass());
268 ASSERT(!tp_argument.IsMalformed()); 273 // Check if type argument is dynamic or Object.
269 if (tp_argument.IsType()) { 274 const Type& object_type = Type::Handle(Type::ObjectType());
270 ASSERT(tp_argument.HasResolvedTypeClass()); 275 if (object_type.IsSubtypeOf(tp_argument, NULL)) {
271 // Check if type argument is dynamic or Object. 276 // Instance class test only necessary.
272 const Type& object_type = Type::Handle(Type::ObjectType()); 277 return GenerateSubtype1TestCacheLookup(
273 if (object_type.IsSubtypeOf(tp_argument, NULL)) { 278 token_pos, type_class, is_instance_lbl, is_not_instance_lbl);
274 // Instance class test only necessary. 279 }
275 return GenerateSubtype1TestCacheLookup(
276 token_pos, type_class, is_instance_lbl, is_not_instance_lbl);
277 } 280 }
278 } 281 }
279 } 282 }
280 // Regular subtype test cache involving instance's type arguments. 283 // Regular subtype test cache involving instance's type arguments.
281 const Register kTypeArgumentsReg = kNoRegister; 284 const Register kTypeArgumentsReg = kNoRegister;
282 const Register kTempReg = EDI; 285 const Register kTempReg = EDI;
283 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs, 286 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs,
284 kInstanceReg, 287 kInstanceReg,
285 kTypeArgumentsReg, 288 kTypeArgumentsReg,
286 kTempReg, 289 kTempReg,
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 __ j(ZERO, is_not_instance_lbl); 519 __ j(ZERO, is_not_instance_lbl);
517 __ CompareClassId(kInstanceReg, type_cid, EDI); 520 __ CompareClassId(kInstanceReg, type_cid, EDI);
518 __ j(EQUAL, is_instance_lbl); 521 __ j(EQUAL, is_instance_lbl);
519 } 522 }
520 __ jmp(is_not_instance_lbl); 523 __ jmp(is_not_instance_lbl);
521 return SubtypeTestCache::null(); 524 return SubtypeTestCache::null();
522 } 525 }
523 if (type.IsInstantiated()) { 526 if (type.IsInstantiated()) {
524 const Class& type_class = Class::ZoneHandle(type.type_class()); 527 const Class& type_class = Class::ZoneHandle(type.type_class());
525 // A class equality check is only applicable with a dst type of a 528 // A class equality check is only applicable with a dst type of a
526 // non-parameterized class or with a raw dst type of a parameterized class. 529 // non-parameterized class, non-signature class, or with a raw dst type of
527 if (type_class.HasTypeArguments()) { 530 // a parameterized class.
531 if (type_class.IsSignatureClass() || type_class.HasTypeArguments()) {
528 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, 532 return GenerateInstantiatedTypeWithArgumentsTest(token_pos,
529 type, 533 type,
530 is_instance_lbl, 534 is_instance_lbl,
531 is_not_instance_lbl); 535 is_not_instance_lbl);
532 // Fall through to runtime call. 536 // Fall through to runtime call.
533 } 537 }
534 const bool has_fall_through = 538 const bool has_fall_through =
535 GenerateInstantiatedTypeNoArgumentsTest(token_pos, 539 GenerateInstantiatedTypeNoArgumentsTest(token_pos,
536 type, 540 type,
537 is_instance_lbl, 541 is_instance_lbl,
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 __ movups(reg, Address(ESP, 0)); 1910 __ movups(reg, Address(ESP, 0));
1907 __ addl(ESP, Immediate(kFpuRegisterSize)); 1911 __ addl(ESP, Immediate(kFpuRegisterSize));
1908 } 1912 }
1909 1913
1910 1914
1911 #undef __ 1915 #undef __
1912 1916
1913 } // namespace dart 1917 } // namespace dart
1914 1918
1915 #endif // defined TARGET_ARCH_IA32 1919 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_arm.cc ('k') | runtime/vm/flow_graph_compiler_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698