| OLD | NEW |
| 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" |
| 11 #include "vm/ast_printer.h" | 11 #include "vm/ast_printer.h" |
| 12 #include "vm/dart_entry.h" | 12 #include "vm/dart_entry.h" |
| 13 #include "vm/il_printer.h" | 13 #include "vm/il_printer.h" |
| 14 #include "vm/locations.h" | 14 #include "vm/locations.h" |
| 15 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
| 16 #include "vm/parser.h" | 16 #include "vm/parser.h" |
| 17 #include "vm/stub_code.h" | 17 #include "vm/stub_code.h" |
| 18 #include "vm/symbols.h" | 18 #include "vm/symbols.h" |
| 19 | 19 |
| 20 namespace dart { | 20 namespace dart { |
| 21 | 21 |
| 22 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization."); | 22 DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization."); |
| 23 DEFINE_FLAG(bool, unbox_mints, true, "Optimize 64-bit integer arithmetic."); | 23 DEFINE_FLAG(bool, unbox_mints, true, "Optimize 64-bit integer arithmetic."); |
| 24 DECLARE_FLAG(int, optimization_counter_threshold); | 24 DECLARE_FLAG(int, optimization_counter_threshold); |
| 25 DECLARE_FLAG(bool, print_ast); | 25 DECLARE_FLAG(bool, print_ast); |
| 26 DECLARE_FLAG(bool, print_scopes); | 26 DECLARE_FLAG(bool, print_scopes); |
| 27 DECLARE_FLAG(bool, eliminate_type_checks); | |
| 28 | 27 |
| 29 | 28 |
| 30 FlowGraphCompiler::~FlowGraphCompiler() { | 29 FlowGraphCompiler::~FlowGraphCompiler() { |
| 31 // BlockInfos are zone-allocated, so their destructors are not called. | 30 // BlockInfos are zone-allocated, so their destructors are not called. |
| 32 // Verify the labels explicitly here. | 31 // Verify the labels explicitly here. |
| 33 for (int i = 0; i < block_info_.length(); ++i) { | 32 for (int i = 0; i < block_info_.length(); ++i) { |
| 34 ASSERT(!block_info_[i]->label.IsLinked()); | 33 ASSERT(!block_info_[i]->label.IsLinked()); |
| 35 ASSERT(!block_info_[i]->label.HasNear()); | 34 ASSERT(!block_info_[i]->label.HasNear()); |
| 36 } | 35 } |
| 37 } | 36 } |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); | 554 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); |
| 556 __ pushl(ECX); // Store instantiator. | 555 __ pushl(ECX); // Store instantiator. |
| 557 __ pushl(EDX); // Store instantiator type arguments. | 556 __ pushl(EDX); // Store instantiator type arguments. |
| 558 // A null object is always assignable and is returned as result. | 557 // A null object is always assignable and is returned as result. |
| 559 const Immediate& raw_null = | 558 const Immediate& raw_null = |
| 560 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 559 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 561 Label is_assignable, runtime_call; | 560 Label is_assignable, runtime_call; |
| 562 __ cmpl(EAX, raw_null); | 561 __ cmpl(EAX, raw_null); |
| 563 __ j(EQUAL, &is_assignable); | 562 __ j(EQUAL, &is_assignable); |
| 564 | 563 |
| 565 if (!FLAG_eliminate_type_checks) { | |
| 566 // If type checks are not eliminated during the graph building then | |
| 567 // a transition sentinel can be seen here. | |
| 568 const Immediate& raw_transition_sentinel = | |
| 569 Immediate(reinterpret_cast<intptr_t>( | |
| 570 Object::transition_sentinel().raw())); | |
| 571 __ cmpl(EAX, raw_transition_sentinel); | |
| 572 __ j(EQUAL, &is_assignable); | |
| 573 } | |
| 574 | |
| 575 // Generate throw new TypeError() if the type is malformed. | 564 // Generate throw new TypeError() if the type is malformed. |
| 576 if (dst_type.IsMalformed()) { | 565 if (dst_type.IsMalformed()) { |
| 577 const Error& error = Error::Handle(dst_type.malformed_error()); | 566 const Error& error = Error::Handle(dst_type.malformed_error()); |
| 578 const String& error_message = String::ZoneHandle( | 567 const String& error_message = String::ZoneHandle( |
| 579 Symbols::New(error.ToErrorCString())); | 568 Symbols::New(error.ToErrorCString())); |
| 580 __ PushObject(Object::ZoneHandle()); // Make room for the result. | 569 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
| 581 __ pushl(EAX); // Push the source object. | 570 __ pushl(EAX); // Push the source object. |
| 582 __ PushObject(dst_name); // Push the name of the destination. | 571 __ PushObject(dst_name); // Push the name of the destination. |
| 583 __ PushObject(error_message); | 572 __ PushObject(error_message); |
| 584 GenerateCallRuntime(token_pos, | 573 GenerateCallRuntime(token_pos, |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1733 __ popl(ECX); | 1722 __ popl(ECX); |
| 1734 __ popl(EAX); | 1723 __ popl(EAX); |
| 1735 } | 1724 } |
| 1736 | 1725 |
| 1737 | 1726 |
| 1738 #undef __ | 1727 #undef __ |
| 1739 | 1728 |
| 1740 } // namespace dart | 1729 } // namespace dart |
| 1741 | 1730 |
| 1742 #endif // defined TARGET_ARCH_IA32 | 1731 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |