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. |
| 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" |
| 34 " by guessing the other unknown argument cid"); |
30 DEFINE_FLAG(bool, load_cse, true, "Use redundant load elimination."); | 35 DEFINE_FLAG(bool, load_cse, true, "Use redundant load elimination."); |
31 DEFINE_FLAG(bool, dead_store_elimination, true, "Eliminate dead stores"); | 36 DEFINE_FLAG(bool, dead_store_elimination, true, "Eliminate dead stores"); |
32 DEFINE_FLAG(int, max_polymorphic_checks, 4, | 37 DEFINE_FLAG(int, max_polymorphic_checks, 4, |
33 "Maximum number of polymorphic check, otherwise it is megamorphic."); | 38 "Maximum number of polymorphic check, otherwise it is megamorphic."); |
34 DEFINE_FLAG(int, max_equality_polymorphic_checks, 32, | 39 DEFINE_FLAG(int, max_equality_polymorphic_checks, 32, |
35 "Maximum number of polymorphic checks in equality operator," | 40 "Maximum number of polymorphic checks in equality operator," |
36 " otherwise use megamorphic dispatch."); | 41 " otherwise use megamorphic dispatch."); |
37 DEFINE_FLAG(bool, merge_sin_cos, false, "Merge sin/cos into sincos"); | 42 DEFINE_FLAG(bool, merge_sin_cos, false, "Merge sin/cos into sincos"); |
38 DEFINE_FLAG(bool, trace_load_optimization, false, | 43 DEFINE_FLAG(bool, trace_load_optimization, false, |
39 "Print live sets for load optimization pass."); | 44 "Print live sets for load optimization pass."); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 const intptr_t cid = call->PushArgumentAt(i)->value()->Type()->ToCid(); | 194 const intptr_t cid = call->PushArgumentAt(i)->value()->Type()->ToCid(); |
190 class_ids.Add(cid); | 195 class_ids.Add(cid); |
191 } | 196 } |
192 | 197 |
193 const Token::Kind op_kind = call->token_kind(); | 198 const Token::Kind op_kind = call->token_kind(); |
194 if (Token::IsRelationalOperator(op_kind) || | 199 if (Token::IsRelationalOperator(op_kind) || |
195 Token::IsEqualityOperator(op_kind) || | 200 Token::IsEqualityOperator(op_kind) || |
196 Token::IsBinaryOperator(op_kind)) { | 201 Token::IsBinaryOperator(op_kind)) { |
197 // Guess cid: if one of the inputs is a number assume that the other | 202 // Guess cid: if one of the inputs is a number assume that the other |
198 // is a number of same type. | 203 // is a number of same type. |
199 if (Compiler::guess_other_cid()) { | 204 // Issue 23693. It is potentially wrong to assign types here that may |
| 205 // conflict with other graph analysis. |
| 206 if (FLAG_guess_other_cid) { |
200 const intptr_t cid_0 = class_ids[0]; | 207 const intptr_t cid_0 = class_ids[0]; |
201 const intptr_t cid_1 = class_ids[1]; | 208 const intptr_t cid_1 = class_ids[1]; |
202 if ((cid_0 == kDynamicCid) && (IsNumberCid(cid_1))) { | 209 if ((cid_0 == kDynamicCid) && (IsNumberCid(cid_1))) { |
203 class_ids[0] = cid_1; | 210 class_ids[0] = cid_1; |
204 } else if (IsNumberCid(cid_0) && (cid_1 == kDynamicCid)) { | 211 } else if (IsNumberCid(cid_0) && (cid_1 == kDynamicCid)) { |
205 class_ids[1] = cid_0; | 212 class_ids[1] = cid_0; |
206 } | 213 } |
207 } | 214 } |
208 } | 215 } |
209 | 216 |
(...skipping 8492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8702 | 8709 |
8703 // Insert materializations at environment uses. | 8710 // Insert materializations at environment uses. |
8704 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 8711 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
8705 CreateMaterializationAt( | 8712 CreateMaterializationAt( |
8706 exits_collector_.exits()[i], alloc, *slots); | 8713 exits_collector_.exits()[i], alloc, *slots); |
8707 } | 8714 } |
8708 } | 8715 } |
8709 | 8716 |
8710 | 8717 |
8711 } // namespace dart | 8718 } // namespace dart |
OLD | NEW |