Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: runtime/vm/flow_graph_optimizer.cc

Issue 22590002: Fix bug with optimized try-catch on ARM/MIPS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: added cleanup of CatchEntry Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 3613 matching lines...) Expand 10 before | Expand all | Expand 10 after
3624 // For every catch-block: Iterate over all call instructions inside the 3624 // For every catch-block: Iterate over all call instructions inside the
3625 // corresponding try-block and figure out for each environment value if it 3625 // corresponding try-block and figure out for each environment value if it
3626 // is the same constant at all calls. If yes, replace the initial definition 3626 // is the same constant at all calls. If yes, replace the initial definition
3627 // at the catch-entry with this constant. 3627 // at the catch-entry with this constant.
3628 const GrowableArray<CatchBlockEntryInstr*>& catch_entries = 3628 const GrowableArray<CatchBlockEntryInstr*>& catch_entries =
3629 flow_graph->graph_entry()->catch_entries(); 3629 flow_graph->graph_entry()->catch_entries();
3630 intptr_t base = kFirstLocalSlotFromFp + flow_graph->num_non_copied_params(); 3630 intptr_t base = kFirstLocalSlotFromFp + flow_graph->num_non_copied_params();
3631 for (intptr_t catch_idx = 0; 3631 for (intptr_t catch_idx = 0;
3632 catch_idx < catch_entries.length(); 3632 catch_idx < catch_entries.length();
3633 ++catch_idx) { 3633 ++catch_idx) {
3634 CatchBlockEntryInstr* cb = catch_entries[catch_idx]; 3634 CatchBlockEntryInstr* catch_entry = catch_entries[catch_idx];
3635 CatchEntryInstr* catch_entry = cb->next()->AsCatchEntry();
3636 3635
3637 // Initialize cdefs with the original initial definitions (ParameterInstr). 3636 // Initialize cdefs with the original initial definitions (ParameterInstr).
3638 // The following representation is used: 3637 // The following representation is used:
3639 // ParameterInstr => unknown 3638 // ParameterInstr => unknown
3640 // ConstantInstr => known constant 3639 // ConstantInstr => known constant
3641 // NULL => non-constant 3640 // NULL => non-constant
3642 GrowableArray<Definition*>* idefs = cb->initial_definitions(); 3641 GrowableArray<Definition*>* idefs = catch_entry->initial_definitions();
3643 GrowableArray<Definition*> cdefs(idefs->length()); 3642 GrowableArray<Definition*> cdefs(idefs->length());
3644 cdefs.AddArray(*idefs); 3643 cdefs.AddArray(*idefs);
3645 3644
3646 // exception_var and stacktrace_var are never constant. 3645 // exception_var and stacktrace_var are never constant.
3647 intptr_t ex_idx = base - catch_entry->exception_var().index(); 3646 intptr_t ex_idx = base - catch_entry->exception_var().index();
3648 intptr_t st_idx = base - catch_entry->stacktrace_var().index(); 3647 intptr_t st_idx = base - catch_entry->stacktrace_var().index();
3649 cdefs[ex_idx] = cdefs[st_idx] = NULL; 3648 cdefs[ex_idx] = cdefs[st_idx] = NULL;
3650 3649
3651 for (BlockIterator block_it = flow_graph->reverse_postorder_iterator(); 3650 for (BlockIterator block_it = flow_graph->reverse_postorder_iterator();
3652 !block_it.Done(); 3651 !block_it.Done();
3653 block_it.Advance()) { 3652 block_it.Advance()) {
3654 BlockEntryInstr* block = block_it.Current(); 3653 BlockEntryInstr* block = block_it.Current();
3655 if (block->try_index() == cb->catch_try_index()) { 3654 if (block->try_index() == catch_entry->catch_try_index()) {
3656 for (ForwardInstructionIterator instr_it(block); 3655 for (ForwardInstructionIterator instr_it(block);
3657 !instr_it.Done(); 3656 !instr_it.Done();
3658 instr_it.Advance()) { 3657 instr_it.Advance()) {
3659 Instruction* current = instr_it.Current(); 3658 Instruction* current = instr_it.Current();
3660 if (current->MayThrow()) { 3659 if (current->MayThrow()) {
3661 Environment* env = current->env(); 3660 Environment* env = current->env();
3662 for (intptr_t env_idx = 0; env_idx < cdefs.length(); ++env_idx) { 3661 for (intptr_t env_idx = 0; env_idx < cdefs.length(); ++env_idx) {
3663 if (cdefs[env_idx] != NULL && 3662 if (cdefs[env_idx] != NULL &&
3664 env->ValueAt(env_idx)->BindsToConstant()) { 3663 env->ValueAt(env_idx)->BindsToConstant()) {
3665 cdefs[env_idx] = env->ValueAt(env_idx)->definition(); 3664 cdefs[env_idx] = env->ValueAt(env_idx)->definition();
(...skipping 2053 matching lines...) Expand 10 before | Expand all | Expand 10 after
5719 } 5718 }
5720 } 5719 }
5721 5720
5722 5721
5723 // -------------------------------------------------------------------------- 5722 // --------------------------------------------------------------------------
5724 // Analysis of non-definition instructions. They do not have values so they 5723 // Analysis of non-definition instructions. They do not have values so they
5725 // cannot have constant values. 5724 // cannot have constant values.
5726 void ConstantPropagator::VisitStoreContext(StoreContextInstr* instr) { } 5725 void ConstantPropagator::VisitStoreContext(StoreContextInstr* instr) { }
5727 5726
5728 5727
5729 void ConstantPropagator::VisitCatchEntry(CatchEntryInstr* instr) { }
5730
5731
5732 void ConstantPropagator::VisitCheckStackOverflow( 5728 void ConstantPropagator::VisitCheckStackOverflow(
5733 CheckStackOverflowInstr* instr) { } 5729 CheckStackOverflowInstr* instr) { }
5734 5730
5735 5731
5736 void ConstantPropagator::VisitCheckClass(CheckClassInstr* instr) { } 5732 void ConstantPropagator::VisitCheckClass(CheckClassInstr* instr) { }
5737 5733
5738 void ConstantPropagator::VisitGuardField(GuardFieldInstr* instr) { } 5734 void ConstantPropagator::VisitGuardField(GuardFieldInstr* instr) { }
5739 5735
5740 void ConstantPropagator::VisitCheckSmi(CheckSmiInstr* instr) { } 5736 void ConstantPropagator::VisitCheckSmi(CheckSmiInstr* instr) { }
5741 5737
(...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after
7413 } 7409 }
7414 7410
7415 // Insert materializations at environment uses. 7411 // Insert materializations at environment uses.
7416 for (intptr_t i = 0; i < exits.length(); i++) { 7412 for (intptr_t i = 0; i < exits.length(); i++) {
7417 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); 7413 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields);
7418 } 7414 }
7419 } 7415 }
7420 7416
7421 7417
7422 } // namespace dart 7418 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698