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); |
27 | 28 |
28 | 29 |
29 FlowGraphCompiler::~FlowGraphCompiler() { | 30 FlowGraphCompiler::~FlowGraphCompiler() { |
30 // BlockInfos are zone-allocated, so their destructors are not called. | 31 // BlockInfos are zone-allocated, so their destructors are not called. |
31 // Verify the labels explicitly here. | 32 // Verify the labels explicitly here. |
32 for (int i = 0; i < block_info_.length(); ++i) { | 33 for (int i = 0; i < block_info_.length(); ++i) { |
33 ASSERT(!block_info_[i]->label.IsLinked()); | 34 ASSERT(!block_info_[i]->label.IsLinked()); |
34 ASSERT(!block_info_[i]->label.HasNear()); | 35 ASSERT(!block_info_[i]->label.HasNear()); |
35 } | 36 } |
36 } | 37 } |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); | 555 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); |
555 __ pushl(ECX); // Store instantiator. | 556 __ pushl(ECX); // Store instantiator. |
556 __ pushl(EDX); // Store instantiator type arguments. | 557 __ pushl(EDX); // Store instantiator type arguments. |
557 // A null object is always assignable and is returned as result. | 558 // A null object is always assignable and is returned as result. |
558 const Immediate& raw_null = | 559 const Immediate& raw_null = |
559 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 560 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
560 Label is_assignable, runtime_call; | 561 Label is_assignable, runtime_call; |
561 __ cmpl(EAX, raw_null); | 562 __ cmpl(EAX, raw_null); |
562 __ j(EQUAL, &is_assignable); | 563 __ j(EQUAL, &is_assignable); |
563 | 564 |
| 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 |
564 // Generate throw new TypeError() if the type is malformed. | 575 // Generate throw new TypeError() if the type is malformed. |
565 if (dst_type.IsMalformed()) { | 576 if (dst_type.IsMalformed()) { |
566 const Error& error = Error::Handle(dst_type.malformed_error()); | 577 const Error& error = Error::Handle(dst_type.malformed_error()); |
567 const String& error_message = String::ZoneHandle( | 578 const String& error_message = String::ZoneHandle( |
568 Symbols::New(error.ToErrorCString())); | 579 Symbols::New(error.ToErrorCString())); |
569 __ PushObject(Object::ZoneHandle()); // Make room for the result. | 580 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
570 __ pushl(EAX); // Push the source object. | 581 __ pushl(EAX); // Push the source object. |
571 __ PushObject(dst_name); // Push the name of the destination. | 582 __ PushObject(dst_name); // Push the name of the destination. |
572 __ PushObject(error_message); | 583 __ PushObject(error_message); |
573 GenerateCallRuntime(token_pos, | 584 GenerateCallRuntime(token_pos, |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1722 __ popl(ECX); | 1733 __ popl(ECX); |
1723 __ popl(EAX); | 1734 __ popl(EAX); |
1724 } | 1735 } |
1725 | 1736 |
1726 | 1737 |
1727 #undef __ | 1738 #undef __ |
1728 | 1739 |
1729 } // namespace dart | 1740 } // namespace dart |
1730 | 1741 |
1731 #endif // defined TARGET_ARCH_IA32 | 1742 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |