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

Unified Diff: runtime/vm/parser.cc

Issue 9721004: Use a local variable to save/restore the context on entry/exit, instead of (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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/parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 5648)
+++ runtime/vm/parser.cc (working copy)
@@ -142,6 +142,22 @@
first_stack_local_index_,
scope,
&context_owner);
+
+ // If this function is not a closure function and if it contains captured
+ // variables, the context needs to be saved on entry and restored on exit.
+ // Add and allocate a local variable to this purpose.
+ if ((context_owner != NULL) && !function().IsClosureFunction()) {
+ const String& context_var_name =
+ String::ZoneHandle(String::NewSymbol(":saved_entry_context_var"));
+ LocalVariable* context_var =
+ new LocalVariable(function().token_index(),
+ context_var_name,
+ Type::ZoneHandle(Type::DynamicType()));
+ context_var->set_index(next_free_frame_index--);
+ scope->AddVariable(context_var);
+ set_saved_context_var(context_var);
+ }
+
// Frame indices are relative to the frame pointer and are decreasing.
ASSERT(next_free_frame_index <= first_stack_local_index_);
stack_local_count_ = first_stack_local_index_ - next_free_frame_index;
« no previous file with comments | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698