| 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/branch_optimizer.h" | 8 #include "vm/branch_optimizer.h" |
| 9 #include "vm/cha.h" | 9 #include "vm/cha.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 LoadFieldInstr* load = new(Z) LoadFieldInstr( | 1410 LoadFieldInstr* load = new(Z) LoadFieldInstr( |
| 1411 new(Z) Value(call->ArgumentAt(0)), | 1411 new(Z) Value(call->ArgumentAt(0)), |
| 1412 &field, | 1412 &field, |
| 1413 AbstractType::ZoneHandle(Z, field.type()), | 1413 AbstractType::ZoneHandle(Z, field.type()), |
| 1414 call->token_pos()); | 1414 call->token_pos()); |
| 1415 load->set_is_immutable(field.is_final()); | 1415 load->set_is_immutable(field.is_final()); |
| 1416 if (field.guarded_cid() != kIllegalCid) { | 1416 if (field.guarded_cid() != kIllegalCid) { |
| 1417 if (!field.is_nullable() || (field.guarded_cid() == kNullCid)) { | 1417 if (!field.is_nullable() || (field.guarded_cid() == kNullCid)) { |
| 1418 load->set_result_cid(field.guarded_cid()); | 1418 load->set_result_cid(field.guarded_cid()); |
| 1419 } | 1419 } |
| 1420 FlowGraph::AddToGuardedFields(flow_graph_->guarded_fields(), &field); | 1420 flow_graph()->parsed_function().AddToGuardedFields(&field); |
| 1421 } | 1421 } |
| 1422 | 1422 |
| 1423 // Discard the environment from the original instruction because the load | 1423 // Discard the environment from the original instruction because the load |
| 1424 // can't deoptimize. | 1424 // can't deoptimize. |
| 1425 call->RemoveEnvironment(); | 1425 call->RemoveEnvironment(); |
| 1426 ReplaceCall(call, load); | 1426 ReplaceCall(call, load); |
| 1427 | 1427 |
| 1428 if (load->result_cid() != kDynamicCid) { | 1428 if (load->result_cid() != kDynamicCid) { |
| 1429 // Reset value types if guarded_cid was used. | 1429 // Reset value types if guarded_cid was used. |
| 1430 for (Value::Iterator it(load->input_use_list()); | 1430 for (Value::Iterator it(load->input_use_list()); |
| (...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3270 if (!setter.IsNull()) { | 3270 if (!setter.IsNull()) { |
| 3271 OS::Print(" setter usage count: %" Pd "\n", setter.usage_counter()); | 3271 OS::Print(" setter usage count: %" Pd "\n", setter.usage_counter()); |
| 3272 } | 3272 } |
| 3273 if (!getter.IsNull()) { | 3273 if (!getter.IsNull()) { |
| 3274 OS::Print(" getter usage count: %" Pd "\n", getter.usage_counter()); | 3274 OS::Print(" getter usage count: %" Pd "\n", getter.usage_counter()); |
| 3275 } | 3275 } |
| 3276 } | 3276 } |
| 3277 field.set_is_unboxing_candidate(false); | 3277 field.set_is_unboxing_candidate(false); |
| 3278 field.DeoptimizeDependentCode(); | 3278 field.DeoptimizeDependentCode(); |
| 3279 } else { | 3279 } else { |
| 3280 FlowGraph::AddToGuardedFields(flow_graph_->guarded_fields(), &field); | 3280 flow_graph()->parsed_function().AddToGuardedFields(&field); |
| 3281 } | 3281 } |
| 3282 } | 3282 } |
| 3283 } | 3283 } |
| 3284 | 3284 |
| 3285 | 3285 |
| 3286 void FlowGraphOptimizer::VisitAllocateContext(AllocateContextInstr* instr) { | 3286 void FlowGraphOptimizer::VisitAllocateContext(AllocateContextInstr* instr) { |
| 3287 // Replace generic allocation with a sequence of inlined allocation and | 3287 // Replace generic allocation with a sequence of inlined allocation and |
| 3288 // explicit initalizing stores. | 3288 // explicit initalizing stores. |
| 3289 AllocateUninitializedContextInstr* replacement = | 3289 AllocateUninitializedContextInstr* replacement = |
| 3290 new AllocateUninitializedContextInstr(instr->token_pos(), | 3290 new AllocateUninitializedContextInstr(instr->token_pos(), |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3396 | 3396 |
| 3397 // Field guard was detached. | 3397 // Field guard was detached. |
| 3398 StoreInstanceFieldInstr* store = new(Z) StoreInstanceFieldInstr( | 3398 StoreInstanceFieldInstr* store = new(Z) StoreInstanceFieldInstr( |
| 3399 field, | 3399 field, |
| 3400 new(Z) Value(instr->ArgumentAt(0)), | 3400 new(Z) Value(instr->ArgumentAt(0)), |
| 3401 new(Z) Value(instr->ArgumentAt(1)), | 3401 new(Z) Value(instr->ArgumentAt(1)), |
| 3402 kEmitStoreBarrier, | 3402 kEmitStoreBarrier, |
| 3403 instr->token_pos()); | 3403 instr->token_pos()); |
| 3404 | 3404 |
| 3405 if (store->IsUnboxedStore()) { | 3405 if (store->IsUnboxedStore()) { |
| 3406 FlowGraph::AddToGuardedFields(flow_graph_->guarded_fields(), &field); | 3406 flow_graph()->parsed_function().AddToGuardedFields(&field); |
| 3407 } | 3407 } |
| 3408 | 3408 |
| 3409 // Discard the environment from the original instruction because the store | 3409 // Discard the environment from the original instruction because the store |
| 3410 // can't deoptimize. | 3410 // can't deoptimize. |
| 3411 instr->RemoveEnvironment(); | 3411 instr->RemoveEnvironment(); |
| 3412 ReplaceCall(instr, store); | 3412 ReplaceCall(instr, store); |
| 3413 return true; | 3413 return true; |
| 3414 } | 3414 } |
| 3415 | 3415 |
| 3416 | 3416 |
| 3417 } // namespace dart | 3417 } // namespace dart |
| OLD | NEW |