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

Unified Diff: runtime/vm/code_generator_ia32.cc

Issue 9705004: Do not chain the current context on entry in non-closure functions, but (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 | « no previous file | runtime/vm/code_generator_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator_ia32.cc
===================================================================
--- runtime/vm/code_generator_ia32.cc (revision 5443)
+++ runtime/vm/code_generator_ia32.cc (working copy)
@@ -595,8 +595,15 @@
// Unchain the context(s) up to context level 0.
int context_level = state()->context_level();
ASSERT(context_level >= 0);
- while (context_level-- > 0) {
- __ movl(CTX, FieldAddress(CTX, Context::parent_offset()));
+ if (!parsed_function_.function().IsClosureFunction()) {
+ if (context_level > 0) {
+ // CTX on entry was saved on the stack, but not linked as context parent.
+ __ popl(CTX);
+ }
+ } else {
+ while (context_level-- > 0) {
+ __ movl(CTX, FieldAddress(CTX, Context::parent_offset()));
+ }
}
#ifdef DEBUG
// Check that the entry stack size matches the exit stack size.
@@ -800,6 +807,18 @@
StubCode::AllocateContextEntryPoint());
GenerateCall(node_sequence->token_index(), &label, PcDescriptors::kOther);
+ // If this node_sequence is the body of the function being compiled, and if
+ // this function is not a closure, do not link the current context as the
+ // parent of the newly allocated context, as it is not accessible. Instead,
+ // save it on the stack and restore it on exit.
+ if ((node_sequence == parsed_function_.node_sequence()) &&
+ !parsed_function_.function().IsClosureFunction()) {
+ __ pushl(CTX);
+ const Immediate raw_null =
+ Immediate(reinterpret_cast<intptr_t>(Object::null()));
+ __ movl(CTX, raw_null);
+ }
+
// Chain the new context in EAX to its parent in CTX.
__ StoreIntoObject(EAX, FieldAddress(EAX, Context::parent_offset()), CTX);
// Set new context as current context.
@@ -845,12 +864,22 @@
}
if (num_context_variables > 0) {
// Unchain the previously allocated context.
- __ movl(CTX, FieldAddress(CTX, Context::parent_offset()));
+ if ((node_sequence == parsed_function_.node_sequence()) &&
+ !parsed_function_.function().IsClosureFunction()) {
+ __ popl(CTX);
+ } else {
+ __ movl(CTX, FieldAddress(CTX, Context::parent_offset()));
+ }
}
// If this node sequence is labeled, a break out of the sequence will have
// taken care of unchaining the context.
if (node_sequence->label() != NULL) {
__ Bind(node_sequence->label()->break_label());
+ if ((num_context_variables > 0) &&
+ (node_sequence == parsed_function_.node_sequence()) &&
+ !parsed_function_.function().IsClosureFunction()) {
+ __ popl(CTX);
+ }
}
}
@@ -2510,6 +2539,12 @@
__ movl(ESP, EBP);
__ subl(ESP, Immediate(locals_space_size()));
+ if ((state()->context_level() > 0) &&
+ !parsed_function_.function().IsClosureFunction()) {
+ // CTX was saved on entry.
+ __ subl(ESP, Immediate(kWordSize));
+ }
+
// The JumpToExceptionHandler trampoline code sets up
// - the exception object in EAX (kExceptionObjectReg)
// - the stacktrace object in register EDX (kStackTraceObjectReg)
« no previous file with comments | « no previous file | runtime/vm/code_generator_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698