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

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

Issue 23190035: Distinguish between malformed and malbounded types (fix issues 12552 and 12554). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 // - EDX: instantiator type arguments or raw_null. 569 // - EDX: instantiator type arguments or raw_null.
570 // - ECX: instantiator or raw_null. 570 // - ECX: instantiator or raw_null.
571 // Clobbers ECX and EDX. 571 // Clobbers ECX and EDX.
572 // Returns: 572 // Returns:
573 // - true or false in EAX. 573 // - true or false in EAX.
574 void FlowGraphCompiler::GenerateInstanceOf(intptr_t token_pos, 574 void FlowGraphCompiler::GenerateInstanceOf(intptr_t token_pos,
575 intptr_t deopt_id, 575 intptr_t deopt_id,
576 const AbstractType& type, 576 const AbstractType& type,
577 bool negate_result, 577 bool negate_result,
578 LocationSummary* locs) { 578 LocationSummary* locs) {
579 ASSERT(type.IsFinalized() && !type.IsMalformed()); 579 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded());
580 580
581 const Immediate& raw_null = 581 const Immediate& raw_null =
582 Immediate(reinterpret_cast<intptr_t>(Object::null())); 582 Immediate(reinterpret_cast<intptr_t>(Object::null()));
583 Label is_instance, is_not_instance; 583 Label is_instance, is_not_instance;
584 __ pushl(ECX); // Store instantiator on stack. 584 __ pushl(ECX); // Store instantiator on stack.
585 __ pushl(EDX); // Store instantiator type arguments. 585 __ pushl(EDX); // Store instantiator type arguments.
586 // If type is instantiated and non-parameterized, we can inline code 586 // If type is instantiated and non-parameterized, we can inline code
587 // checking whether the tested instance is a Smi. 587 // checking whether the tested instance is a Smi.
588 if (type.IsInstantiated()) { 588 if (type.IsInstantiated()) {
589 // A null object is only an instance of Object and dynamic, which has 589 // A null object is only an instance of Object and dynamic, which has
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 // as they throw an exception. 659 // as they throw an exception.
660 void FlowGraphCompiler::GenerateAssertAssignable(intptr_t token_pos, 660 void FlowGraphCompiler::GenerateAssertAssignable(intptr_t token_pos,
661 intptr_t deopt_id, 661 intptr_t deopt_id,
662 const AbstractType& dst_type, 662 const AbstractType& dst_type,
663 const String& dst_name, 663 const String& dst_name,
664 LocationSummary* locs) { 664 LocationSummary* locs) {
665 ASSERT(token_pos >= 0); 665 ASSERT(token_pos >= 0);
666 ASSERT(!dst_type.IsNull()); 666 ASSERT(!dst_type.IsNull());
667 ASSERT(dst_type.IsFinalized()); 667 ASSERT(dst_type.IsFinalized());
668 // Assignable check is skipped in FlowGraphBuilder, not here. 668 // Assignable check is skipped in FlowGraphBuilder, not here.
669 ASSERT(dst_type.IsMalformed() || 669 ASSERT(dst_type.IsMalformed() || dst_type.IsMalbounded() ||
670 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); 670 (!dst_type.IsDynamicType() && !dst_type.IsObjectType()));
671 __ pushl(ECX); // Store instantiator. 671 __ pushl(ECX); // Store instantiator.
672 __ pushl(EDX); // Store instantiator type arguments. 672 __ pushl(EDX); // Store instantiator type arguments.
673 // A null object is always assignable and is returned as result. 673 // A null object is always assignable and is returned as result.
674 const Immediate& raw_null = 674 const Immediate& raw_null =
675 Immediate(reinterpret_cast<intptr_t>(Object::null())); 675 Immediate(reinterpret_cast<intptr_t>(Object::null()));
676 Label is_assignable, runtime_call; 676 Label is_assignable, runtime_call;
677 __ cmpl(EAX, raw_null); 677 __ cmpl(EAX, raw_null);
678 __ j(EQUAL, &is_assignable); 678 __ j(EQUAL, &is_assignable);
679 679
680 if (!FLAG_eliminate_type_checks || dst_type.IsMalformed()) { 680 if (!FLAG_eliminate_type_checks || dst_type.IsMalformed()) {
681 // If type checks are not eliminated during the graph building then 681 // If type checks are not eliminated during the graph building then
682 // a transition sentinel can be seen here. 682 // a transition sentinel can be seen here.
683 const Immediate& raw_transition_sentinel = 683 const Immediate& raw_transition_sentinel =
684 Immediate(reinterpret_cast<intptr_t>( 684 Immediate(reinterpret_cast<intptr_t>(
685 Object::transition_sentinel().raw())); 685 Object::transition_sentinel().raw()));
686 __ cmpl(EAX, raw_transition_sentinel); 686 __ cmpl(EAX, raw_transition_sentinel);
687 __ j(EQUAL, &is_assignable); 687 __ j(EQUAL, &is_assignable);
688 } 688 }
689 689
690 // Generate throw new TypeError() if the type is malformed. 690 // Generate throw new TypeError() if the type is malformed or malbounded.
691 if (dst_type.IsMalformed()) { 691 if (dst_type.IsMalformed() || dst_type.IsMalbounded()) {
692 const Error& error = Error::Handle(dst_type.malformed_error()); 692 Error& error = Error::Handle();
693 if (dst_type.IsMalformed()) {
694 error = dst_type.malformed_error();
695 } else {
696 const bool is_malbounded = dst_type.IsMalboundedWithError(&error);
697 ASSERT(is_malbounded);
698 }
693 const String& error_message = String::ZoneHandle( 699 const String& error_message = String::ZoneHandle(
694 Symbols::New(error.ToErrorCString())); 700 Symbols::New(error.ToErrorCString()));
695 __ PushObject(Object::ZoneHandle()); // Make room for the result. 701 __ PushObject(Object::ZoneHandle()); // Make room for the result.
696 __ pushl(EAX); // Push the source object. 702 __ pushl(EAX); // Push the source object.
697 __ PushObject(dst_name); // Push the name of the destination. 703 __ PushObject(dst_name); // Push the name of the destination.
698 __ PushObject(error_message); 704 __ PushObject(error_message);
699 GenerateCallRuntime(token_pos, 705 GenerateCallRuntime(token_pos,
700 deopt_id, 706 deopt_id,
701 kMalformedTypeErrorRuntimeEntry, 707 kMalformedTypeErrorRuntimeEntry,
702 locs); 708 locs);
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 __ movups(reg, Address(ESP, 0)); 1915 __ movups(reg, Address(ESP, 0));
1910 __ addl(ESP, Immediate(kFpuRegisterSize)); 1916 __ addl(ESP, Immediate(kFpuRegisterSize));
1911 } 1917 }
1912 1918
1913 1919
1914 #undef __ 1920 #undef __
1915 1921
1916 } // namespace dart 1922 } // namespace dart
1917 1923
1918 #endif // defined TARGET_ARCH_IA32 1924 #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