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

Unified Diff: runtime/vm/intermediate_language_mips.cc

Issue 2796283003: VM: [Kernel] Implement CatchBlockEntryInstr::should_restore_closure_context on all platforms. (Closed)
Patch Set: Address Zach's comment Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_mips.cc
diff --git a/runtime/vm/intermediate_language_mips.cc b/runtime/vm/intermediate_language_mips.cc
index 286902a260a8705d6f5d5681225ec24b91e4cd41..f57a6c350581b29ada6842aa55fbede150c3fda3 100644
--- a/runtime/vm/intermediate_language_mips.cc
+++ b/runtime/vm/intermediate_language_mips.cc
@@ -2753,12 +2753,41 @@ void CatchBlockEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
ASSERT(fp_sp_dist <= 0);
__ AddImmediate(SP, FP, fp_sp_dist);
- // Restore stack and initialize the two exception variables:
- // exception and stack trace variables.
- __ StoreToOffset(kExceptionObjectReg, FP,
- exception_var().index() * kWordSize);
- __ StoreToOffset(kStackTraceObjectReg, FP,
- stacktrace_var().index() * kWordSize);
+ // Auxiliary variables introduced by the try catch can be captured if we are
+ // inside a function with yield/resume points. In this case we first need
+ // to restore the context to match the context at entry into the closure.
+ if (should_restore_closure_context()) {
+ const ParsedFunction& parsed_function = compiler->parsed_function();
+ ASSERT(parsed_function.function().IsClosureFunction());
+ LocalScope* scope = parsed_function.node_sequence()->scope();
+
+ LocalVariable* closure_parameter = scope->VariableAt(0);
+ ASSERT(!closure_parameter->is_captured());
+ __ LoadFromOffset(CTX, FP, closure_parameter->index() * kWordSize);
+ __ LoadFieldFromOffset(CTX, CTX, Closure::context_offset());
+
+ const intptr_t context_index =
+ parsed_function.current_context_var()->index();
+ __ StoreToOffset(CTX, FP, context_index * kWordSize);
+ }
+
+ // Initialize exception and stack trace variables.
+ if (exception_var().is_captured()) {
+ ASSERT(stacktrace_var().is_captured());
+ __ StoreIntoObjectOffset(CTX,
+ Context::variable_offset(exception_var().index()),
+ kExceptionObjectReg);
+ __ StoreIntoObjectOffset(CTX,
+ Context::variable_offset(stacktrace_var().index()),
+ kStackTraceObjectReg);
+ } else {
+ // Restore stack and initialize the two exception variables:
+ // exception and stack trace variables.
+ __ StoreToOffset(kExceptionObjectReg, FP,
+ exception_var().index() * kWordSize);
+ __ StoreToOffset(kStackTraceObjectReg, FP,
+ stacktrace_var().index() * kWordSize);
+ }
}
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698