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/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
12 #include "vm/exceptions.h" | 12 #include "vm/exceptions.h" |
13 #include "vm/flow_graph_builder.h" | 13 #include "vm/flow_graph_builder.h" |
14 #include "vm/flow_graph_compiler.h" | 14 #include "vm/flow_graph_compiler.h" |
15 #include "vm/flow_graph_range_analysis.h" | 15 #include "vm/flow_graph_range_analysis.h" |
16 #include "vm/hash_map.h" | 16 #include "vm/hash_map.h" |
17 #include "vm/il_printer.h" | 17 #include "vm/il_printer.h" |
18 #include "vm/intermediate_language.h" | 18 #include "vm/intermediate_language.h" |
19 #include "vm/object_store.h" | 19 #include "vm/object_store.h" |
20 #include "vm/parser.h" | 20 #include "vm/parser.h" |
21 #include "vm/resolver.h" | 21 #include "vm/resolver.h" |
22 #include "vm/scopes.h" | 22 #include "vm/scopes.h" |
23 #include "vm/stack_frame.h" | 23 #include "vm/stack_frame.h" |
24 #include "vm/symbols.h" | 24 #include "vm/symbols.h" |
25 | 25 |
26 namespace dart { | 26 namespace dart { |
27 | 27 |
28 DEFINE_FLAG(int, getter_setter_ratio, 13, | 28 DEFINE_FLAG(int, getter_setter_ratio, 13, |
29 "Ratio of getter/setter usage used for double field unboxing heuristics"); | 29 "Ratio of getter/setter usage used for double field unboxing heuristics"); |
30 // Setting 'guess_other_cid' to true causes issue 23693 crash. | 30 DEFINE_FLAG(bool, guess_other_cid, true, |
31 // TODO(srdjan): Evaluate if that optimization is wrong. | |
32 DEFINE_FLAG(bool, guess_other_cid, false, | |
33 "Artificially create type feedback for arithmetic etc. operations" | 31 "Artificially create type feedback for arithmetic etc. operations" |
34 " by guessing the other unknown argument cid"); | 32 " by guessing the other unknown argument cid"); |
35 DEFINE_FLAG(bool, load_cse, true, "Use redundant load elimination."); | 33 DEFINE_FLAG(bool, load_cse, true, "Use redundant load elimination."); |
36 DEFINE_FLAG(bool, dead_store_elimination, true, "Eliminate dead stores"); | 34 DEFINE_FLAG(bool, dead_store_elimination, true, "Eliminate dead stores"); |
37 DEFINE_FLAG(int, max_polymorphic_checks, 4, | 35 DEFINE_FLAG(int, max_polymorphic_checks, 4, |
38 "Maximum number of polymorphic check, otherwise it is megamorphic."); | 36 "Maximum number of polymorphic check, otherwise it is megamorphic."); |
39 DEFINE_FLAG(int, max_equality_polymorphic_checks, 32, | 37 DEFINE_FLAG(int, max_equality_polymorphic_checks, 32, |
40 "Maximum number of polymorphic checks in equality operator," | 38 "Maximum number of polymorphic checks in equality operator," |
41 " otherwise use megamorphic dispatch."); | 39 " otherwise use megamorphic dispatch."); |
42 DEFINE_FLAG(bool, merge_sin_cos, false, "Merge sin/cos into sincos"); | 40 DEFINE_FLAG(bool, merge_sin_cos, false, "Merge sin/cos into sincos"); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 const intptr_t cid = call->PushArgumentAt(i)->value()->Type()->ToCid(); | 188 const intptr_t cid = call->PushArgumentAt(i)->value()->Type()->ToCid(); |
191 class_ids.Add(cid); | 189 class_ids.Add(cid); |
192 } | 190 } |
193 | 191 |
194 const Token::Kind op_kind = call->token_kind(); | 192 const Token::Kind op_kind = call->token_kind(); |
195 if (Token::IsRelationalOperator(op_kind) || | 193 if (Token::IsRelationalOperator(op_kind) || |
196 Token::IsEqualityOperator(op_kind) || | 194 Token::IsEqualityOperator(op_kind) || |
197 Token::IsBinaryOperator(op_kind)) { | 195 Token::IsBinaryOperator(op_kind)) { |
198 // Guess cid: if one of the inputs is a number assume that the other | 196 // Guess cid: if one of the inputs is a number assume that the other |
199 // is a number of same type. | 197 // is a number of same type. |
200 // Issue 23693. It is potentially wrong to assign types here that may | |
201 // conflict with other graph analysis. | |
202 if (FLAG_guess_other_cid) { | 198 if (FLAG_guess_other_cid) { |
203 const intptr_t cid_0 = class_ids[0]; | 199 const intptr_t cid_0 = class_ids[0]; |
204 const intptr_t cid_1 = class_ids[1]; | 200 const intptr_t cid_1 = class_ids[1]; |
205 if ((cid_0 == kDynamicCid) && (IsNumberCid(cid_1))) { | 201 if ((cid_0 == kDynamicCid) && (IsNumberCid(cid_1))) { |
206 class_ids[0] = cid_1; | 202 class_ids[0] = cid_1; |
207 } else if (IsNumberCid(cid_0) && (cid_1 == kDynamicCid)) { | 203 } else if (IsNumberCid(cid_0) && (cid_1 == kDynamicCid)) { |
208 class_ids[1] = cid_0; | 204 class_ids[1] = cid_0; |
209 } | 205 } |
210 } | 206 } |
211 } | 207 } |
(...skipping 8523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8735 | 8731 |
8736 // Insert materializations at environment uses. | 8732 // Insert materializations at environment uses. |
8737 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 8733 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
8738 CreateMaterializationAt( | 8734 CreateMaterializationAt( |
8739 exits_collector_.exits()[i], alloc, *slots); | 8735 exits_collector_.exits()[i], alloc, *slots); |
8740 } | 8736 } |
8741 } | 8737 } |
8742 | 8738 |
8743 | 8739 |
8744 } // namespace dart | 8740 } // namespace dart |
OLD | NEW |