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

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
« no previous file with comments | « runtime/vm/flow_graph_builder.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) 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 // A non-null value is returned from a void function, which will result in a
426 // type error. A null value is handled prior to executing this inline code.
427 return SubtypeTestCache::null();
428 }
424 if (type.IsInstantiated()) { 429 if (type.IsInstantiated()) {
425 const Class& type_class = Class::ZoneHandle(type.type_class()); 430 const Class& type_class = Class::ZoneHandle(type.type_class());
426 // A Smi object cannot be the instance of a parameterized class. 431 // 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 432 // 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. 433 // non-parameterized class or with a raw dst type of a parameterized class.
429 if (type_class.HasTypeArguments()) { 434 if (type_class.HasTypeArguments()) {
430 return GenerateInstantiatedTypeWithArgumentsTest(cid, 435 return GenerateInstantiatedTypeWithArgumentsTest(cid,
431 token_pos, 436 token_pos,
432 type, 437 type,
433 is_instance_lbl, 438 is_instance_lbl,
434 is_not_instance_lbl); 439 is_not_instance_lbl);
435 // Fall through to runtime call. 440 // 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 } 441 }
448 } else { 442 GenerateInstantiatedTypeNoArgumentsTest(cid,
449 return GenerateUninstantiatedTypeTest(cid, 443 token_pos,
450 token_pos, 444 type,
451 type, 445 is_instance_lbl,
452 is_instance_lbl, 446 is_not_instance_lbl);
453 is_not_instance_lbl); 447 // If test non-conclusive so far, try the inlined type-test cache.
448 // 'type' is known at compile time.
449 return GenerateSubtype1TestCacheLookup(
450 cid, token_pos, type_class,
451 is_instance_lbl, is_not_instance_lbl);
454 } 452 }
455 return SubtypeTestCache::null(); 453 return GenerateUninstantiatedTypeTest(cid,
454 token_pos,
455 type,
456 is_instance_lbl,
457 is_not_instance_lbl);
456 } 458 }
457 459
458 460
459 // If instanceof type test cannot be performed successfully at compile time and 461 // If instanceof type test cannot be performed successfully at compile time and
460 // therefore eliminated, optimize it by adding inlined tests for: 462 // therefore eliminated, optimize it by adding inlined tests for:
461 // - NULL -> return false. 463 // - NULL -> return false.
462 // - Smi -> compile time subtype check (only if dst class is not parameterized). 464 // - Smi -> compile time subtype check (only if dst class is not parameterized).
463 // - Class equality (only if class is not parameterized). 465 // - Class equality (only if class is not parameterized).
464 // Inputs: 466 // Inputs:
465 // - EAX: object. 467 // - EAX: object.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 intptr_t token_pos, 556 intptr_t token_pos,
555 intptr_t try_index, 557 intptr_t try_index,
556 const AbstractType& dst_type, 558 const AbstractType& dst_type,
557 const String& dst_name) { 559 const String& dst_name) {
558 ASSERT(token_pos >= 0); 560 ASSERT(token_pos >= 0);
559 ASSERT(!dst_type.IsNull()); 561 ASSERT(!dst_type.IsNull());
560 ASSERT(dst_type.IsFinalized()); 562 ASSERT(dst_type.IsFinalized());
561 // Assignable check is skipped in FlowGraphBuilder, not here. 563 // Assignable check is skipped in FlowGraphBuilder, not here.
562 ASSERT(dst_type.IsMalformed() || 564 ASSERT(dst_type.IsMalformed() ||
563 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); 565 (!dst_type.IsDynamicType() && !dst_type.IsObjectType()));
564 ASSERT(!dst_type.IsVoidType());
565 __ pushl(ECX); // Store instantiator. 566 __ pushl(ECX); // Store instantiator.
566 __ pushl(EDX); // Store instantiator type arguments. 567 __ pushl(EDX); // Store instantiator type arguments.
567 // A null object is always assignable and is returned as result. 568 // A null object is always assignable and is returned as result.
568 const Immediate raw_null = 569 const Immediate raw_null =
569 Immediate(reinterpret_cast<intptr_t>(Object::null())); 570 Immediate(reinterpret_cast<intptr_t>(Object::null()));
570 Label is_assignable, runtime_call; 571 Label is_assignable, runtime_call;
571 __ cmpl(EAX, raw_null); 572 __ cmpl(EAX, raw_null);
572 __ j(EQUAL, &is_assignable); 573 __ j(EQUAL, &is_assignable);
573 574
574 // Generate throw new TypeError() if the type is malformed. 575 // Generate throw new TypeError() if the type is malformed.
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 } 1139 }
1139 } 1140 }
1140 } 1141 }
1141 1142
1142 1143
1143 #undef __ 1144 #undef __
1144 1145
1145 } // namespace dart 1146 } // namespace dart
1146 1147
1147 #endif // defined TARGET_ARCH_IA32 1148 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/flow_graph_compiler_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698