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

Side by Side Diff: runtime/vm/flow_graph_compiler_x64.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_mips.cc ('k') | runtime/vm/flow_graph_optimizer.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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 // - RDX: instantiator type arguments or raw_null. 566 // - RDX: instantiator type arguments or raw_null.
567 // - RCX: instantiator or raw_null. 567 // - RCX: instantiator or raw_null.
568 // Clobbers RCX and RDX. 568 // Clobbers RCX and RDX.
569 // Returns: 569 // Returns:
570 // - true or false in RAX. 570 // - true or false in RAX.
571 void FlowGraphCompiler::GenerateInstanceOf(intptr_t token_pos, 571 void FlowGraphCompiler::GenerateInstanceOf(intptr_t token_pos,
572 intptr_t deopt_id, 572 intptr_t deopt_id,
573 const AbstractType& type, 573 const AbstractType& type,
574 bool negate_result, 574 bool negate_result,
575 LocationSummary* locs) { 575 LocationSummary* locs) {
576 ASSERT(type.IsFinalized() && !type.IsMalformed()); 576 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded());
577 577
578 const Immediate& raw_null = 578 const Immediate& raw_null =
579 Immediate(reinterpret_cast<intptr_t>(Object::null())); 579 Immediate(reinterpret_cast<intptr_t>(Object::null()));
580 Label is_instance, is_not_instance; 580 Label is_instance, is_not_instance;
581 __ pushq(RCX); // Store instantiator on stack. 581 __ pushq(RCX); // Store instantiator on stack.
582 __ pushq(RDX); // Store instantiator type arguments. 582 __ pushq(RDX); // Store instantiator type arguments.
583 // If type is instantiated and non-parameterized, we can inline code 583 // If type is instantiated and non-parameterized, we can inline code
584 // checking whether the tested instance is a Smi. 584 // checking whether the tested instance is a Smi.
585 if (type.IsInstantiated()) { 585 if (type.IsInstantiated()) {
586 // A null object is only an instance of Object and dynamic, which has 586 // 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
656 // as they throw an exception. 656 // as they throw an exception.
657 void FlowGraphCompiler::GenerateAssertAssignable(intptr_t token_pos, 657 void FlowGraphCompiler::GenerateAssertAssignable(intptr_t token_pos,
658 intptr_t deopt_id, 658 intptr_t deopt_id,
659 const AbstractType& dst_type, 659 const AbstractType& dst_type,
660 const String& dst_name, 660 const String& dst_name,
661 LocationSummary* locs) { 661 LocationSummary* locs) {
662 ASSERT(token_pos >= 0); 662 ASSERT(token_pos >= 0);
663 ASSERT(!dst_type.IsNull()); 663 ASSERT(!dst_type.IsNull());
664 ASSERT(dst_type.IsFinalized()); 664 ASSERT(dst_type.IsFinalized());
665 // Assignable check is skipped in FlowGraphBuilder, not here. 665 // Assignable check is skipped in FlowGraphBuilder, not here.
666 ASSERT(dst_type.IsMalformed() || 666 ASSERT(dst_type.IsMalformed() || dst_type.IsMalbounded() ||
667 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); 667 (!dst_type.IsDynamicType() && !dst_type.IsObjectType()));
668 __ pushq(RCX); // Store instantiator. 668 __ pushq(RCX); // Store instantiator.
669 __ pushq(RDX); // Store instantiator type arguments. 669 __ pushq(RDX); // Store instantiator type arguments.
670 // A null object is always assignable and is returned as result. 670 // A null object is always assignable and is returned as result.
671 const Immediate& raw_null = 671 const Immediate& raw_null =
672 Immediate(reinterpret_cast<intptr_t>(Object::null())); 672 Immediate(reinterpret_cast<intptr_t>(Object::null()));
673 Label is_assignable, runtime_call; 673 Label is_assignable, runtime_call;
674 __ cmpq(RAX, raw_null); 674 __ cmpq(RAX, raw_null);
675 __ j(EQUAL, &is_assignable); 675 __ j(EQUAL, &is_assignable);
676 676
677 if (!FLAG_eliminate_type_checks || dst_type.IsMalformed()) { 677 if (!FLAG_eliminate_type_checks || dst_type.IsMalformed()) {
678 // If type checks are not eliminated during the graph building then 678 // If type checks are not eliminated during the graph building then
679 // a transition sentinel can be seen here. 679 // a transition sentinel can be seen here.
680 __ CompareObject(RAX, Object::transition_sentinel()); 680 __ CompareObject(RAX, Object::transition_sentinel());
681 __ j(EQUAL, &is_assignable); 681 __ j(EQUAL, &is_assignable);
682 } 682 }
683 683
684 // Generate throw new TypeError() if the type is malformed. 684 // Generate throw new TypeError() if the type is malformed or malbounded.
685 if (dst_type.IsMalformed()) { 685 if (dst_type.IsMalformed() || dst_type.IsMalbounded()) {
686 const Error& error = Error::Handle(dst_type.malformed_error()); 686 Error& error = Error::Handle();
687 if (dst_type.IsMalformed()) {
688 error = dst_type.malformed_error();
689 } else {
690 const bool is_malbounded = dst_type.IsMalboundedWithError(&error);
691 ASSERT(is_malbounded);
692 }
687 const String& error_message = String::ZoneHandle( 693 const String& error_message = String::ZoneHandle(
688 Symbols::New(error.ToErrorCString())); 694 Symbols::New(error.ToErrorCString()));
689 __ PushObject(Object::ZoneHandle()); // Make room for the result. 695 __ PushObject(Object::ZoneHandle()); // Make room for the result.
690 __ pushq(RAX); // Push the source object. 696 __ pushq(RAX); // Push the source object.
691 __ PushObject(dst_name); // Push the name of the destination. 697 __ PushObject(dst_name); // Push the name of the destination.
692 __ PushObject(error_message); 698 __ PushObject(error_message);
693 GenerateCallRuntime(token_pos, 699 GenerateCallRuntime(token_pos,
694 deopt_id, 700 deopt_id,
695 kMalformedTypeErrorRuntimeEntry, 701 kMalformedTypeErrorRuntimeEntry,
696 locs); 702 locs);
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 __ movups(reg, Address(RSP, 0)); 1895 __ movups(reg, Address(RSP, 0));
1890 __ addq(RSP, Immediate(kFpuRegisterSize)); 1896 __ addq(RSP, Immediate(kFpuRegisterSize));
1891 } 1897 }
1892 1898
1893 1899
1894 #undef __ 1900 #undef __
1895 1901
1896 } // namespace dart 1902 } // namespace dart
1897 1903
1898 #endif // defined TARGET_ARCH_X64 1904 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_mips.cc ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698