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

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

Issue 10704216: Fix type checking of void type. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 // - preserved instance in EAX and optional instantiator type arguments in EDX. 414 // - preserved instance in EAX and optional instantiator type arguments in EDX.
415 // Note that this inlined code must be followed by the runtime_call code, as it 415 // Note that this inlined code must be followed by the runtime_call code, as it
416 // may fall through to it. Otherwise, this inline code will jump to the label 416 // may fall through to it. Otherwise, this inline code will jump to the label
417 // is_instance or to the label is_not_instance. 417 // is_instance or to the label is_not_instance.
418 RawSubtypeTestCache* FlowGraphCompiler::GenerateInlineInstanceof( 418 RawSubtypeTestCache* FlowGraphCompiler::GenerateInlineInstanceof(
419 intptr_t cid, 419 intptr_t cid,
420 intptr_t token_pos, 420 intptr_t token_pos,
421 const AbstractType& type, 421 const AbstractType& type,
422 Label* is_instance_lbl, 422 Label* is_instance_lbl,
423 Label* is_not_instance_lbl) { 423 Label* is_not_instance_lbl) {
424 if (type.IsVoidType()) {
425 return SubtypeTestCache::null();
srdjan 2012/07/16 15:21:12 When can the type we check agains be void?
regis 2012/07/16 18:05:34 When we type check a value returned from a void fu
426 }
424 if (type.IsInstantiated()) { 427 if (type.IsInstantiated()) {
425 const Class& type_class = Class::ZoneHandle(type.type_class()); 428 const Class& type_class = Class::ZoneHandle(type.type_class());
426 // A Smi object cannot be the instance of a parameterized class. 429 // A Smi object cannot be the instance of a parameterized class.
427 // A class equality check is only applicable with a dst type of a 430 // A class equality check is only applicable with a dst type of a
428 // non-parameterized class or with a raw dst type of a parameterized class. 431 // non-parameterized class or with a raw dst type of a parameterized class.
429 if (type_class.HasTypeArguments()) { 432 if (type_class.HasTypeArguments()) {
430 return GenerateInstantiatedTypeWithArgumentsTest(cid, 433 return GenerateInstantiatedTypeWithArgumentsTest(cid,
431 token_pos, 434 token_pos,
432 type, 435 type,
433 is_instance_lbl, 436 is_instance_lbl,
434 is_not_instance_lbl); 437 is_not_instance_lbl);
435 // Fall through to runtime call. 438 // Fall through to runtime call.
436 } else {
437 GenerateInstantiatedTypeNoArgumentsTest(cid,
438 token_pos,
439 type,
440 is_instance_lbl,
441 is_not_instance_lbl);
442 // If test non-conclusive so far, try the inlined type-test cache.
443 // 'type' is known at compile time.
444 return GenerateSubtype1TestCacheLookup(
445 cid, token_pos, type_class,
446 is_instance_lbl, is_not_instance_lbl);
447 } 439 }
448 } else { 440 GenerateInstantiatedTypeNoArgumentsTest(cid,
449 return GenerateUninstantiatedTypeTest(cid, 441 token_pos,
450 token_pos, 442 type,
451 type, 443 is_instance_lbl,
452 is_instance_lbl, 444 is_not_instance_lbl);
453 is_not_instance_lbl); 445 // If test non-conclusive so far, try the inlined type-test cache.
446 // 'type' is known at compile time.
447 return GenerateSubtype1TestCacheLookup(
448 cid, token_pos, type_class,
449 is_instance_lbl, is_not_instance_lbl);
454 } 450 }
455 return SubtypeTestCache::null(); 451 return GenerateUninstantiatedTypeTest(cid,
452 token_pos,
453 type,
454 is_instance_lbl,
455 is_not_instance_lbl);
456 } 456 }
457 457
458 458
459 // If instanceof type test cannot be performed successfully at compile time and 459 // If instanceof type test cannot be performed successfully at compile time and
460 // therefore eliminated, optimize it by adding inlined tests for: 460 // therefore eliminated, optimize it by adding inlined tests for:
461 // - NULL -> return false. 461 // - NULL -> return false.
462 // - Smi -> compile time subtype check (only if dst class is not parameterized). 462 // - Smi -> compile time subtype check (only if dst class is not parameterized).
463 // - Class equality (only if class is not parameterized). 463 // - Class equality (only if class is not parameterized).
464 // Inputs: 464 // Inputs:
465 // - EAX: object. 465 // - EAX: object.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 intptr_t token_pos, 554 intptr_t token_pos,
555 intptr_t try_index, 555 intptr_t try_index,
556 const AbstractType& dst_type, 556 const AbstractType& dst_type,
557 const String& dst_name) { 557 const String& dst_name) {
558 ASSERT(token_pos >= 0); 558 ASSERT(token_pos >= 0);
559 ASSERT(!dst_type.IsNull()); 559 ASSERT(!dst_type.IsNull());
560 ASSERT(dst_type.IsFinalized()); 560 ASSERT(dst_type.IsFinalized());
561 // Assignable check is skipped in FlowGraphBuilder, not here. 561 // Assignable check is skipped in FlowGraphBuilder, not here.
562 ASSERT(dst_type.IsMalformed() || 562 ASSERT(dst_type.IsMalformed() ||
563 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); 563 (!dst_type.IsDynamicType() && !dst_type.IsObjectType()));
564 ASSERT(!dst_type.IsVoidType());
565 __ pushl(ECX); // Store instantiator. 564 __ pushl(ECX); // Store instantiator.
566 __ pushl(EDX); // Store instantiator type arguments. 565 __ pushl(EDX); // Store instantiator type arguments.
567 // A null object is always assignable and is returned as result. 566 // A null object is always assignable and is returned as result.
568 const Immediate raw_null = 567 const Immediate raw_null =
569 Immediate(reinterpret_cast<intptr_t>(Object::null())); 568 Immediate(reinterpret_cast<intptr_t>(Object::null()));
570 Label is_assignable, runtime_call; 569 Label is_assignable, runtime_call;
571 __ cmpl(EAX, raw_null); 570 __ cmpl(EAX, raw_null);
572 __ j(EQUAL, &is_assignable); 571 __ j(EQUAL, &is_assignable);
573 572
574 // Generate throw new TypeError() if the type is malformed. 573 // Generate throw new TypeError() if the type is malformed.
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 } 1137 }
1139 } 1138 }
1140 } 1139 }
1141 1140
1142 1141
1143 #undef __ 1142 #undef __
1144 1143
1145 } // namespace dart 1144 } // namespace dart
1146 1145
1147 #endif // defined TARGET_ARCH_IA32 1146 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698