| Index: runtime/vm/redundancy_elimination.cc
|
| diff --git a/runtime/vm/redundancy_elimination.cc b/runtime/vm/redundancy_elimination.cc
|
| index 0dffdf2a352eaa47bbc902d5f9544b51c6215851..c13ec9d2fcb23f568faa0d4141bc794fc31bd477 100644
|
| --- a/runtime/vm/redundancy_elimination.cc
|
| +++ b/runtime/vm/redundancy_elimination.cc
|
| @@ -3353,10 +3353,15 @@ void TryCatchAnalyzer::Optimize(FlowGraph* flow_graph) {
|
| GrowableArray<Definition*> cdefs(idefs->length());
|
| cdefs.AddArray(*idefs);
|
|
|
| - // exception_var and stacktrace_var are never constant.
|
| - intptr_t ex_idx = base - catch_entry->exception_var().index();
|
| - intptr_t st_idx = base - catch_entry->stacktrace_var().index();
|
| - cdefs[ex_idx] = cdefs[st_idx] = NULL;
|
| + // exception_var and stacktrace_var are never constant. In asynchronous or
|
| + // generator functions they may be context-allocated in which case they are
|
| + // not tracked in the environment anyway.
|
| + if (!catch_entry->exception_var().is_captured()) {
|
| + cdefs[base - catch_entry->exception_var().index()] = NULL;
|
| + }
|
| + if (!catch_entry->stacktrace_var().is_captured()) {
|
| + cdefs[base - catch_entry->stacktrace_var().index()] = NULL;
|
| + }
|
|
|
| for (BlockIterator block_it = flow_graph->reverse_postorder_iterator();
|
| !block_it.Done();
|
|
|