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

Unified Diff: runtime/vm/code_generator_x64.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/code_generator_ia32.cc ('k') | runtime/vm/parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator_x64.cc
===================================================================
--- runtime/vm/code_generator_x64.cc (revision 5648)
+++ runtime/vm/code_generator_x64.cc (working copy)
@@ -612,11 +612,9 @@
// Unchain the context(s) up to context level 0.
intptr_t current_context_level = context_level();
ASSERT(current_context_level >= 0);
- if (!parsed_function_.function().IsClosureFunction()) {
- if (current_context_level > 0) {
- // CTX on entry was saved on the stack, but not linked as context parent.
- __ popq(CTX);
- }
+ if (parsed_function_.saved_context_var() != NULL) {
+ // CTX on entry was saved, but not linked as context parent.
+ GenerateLoadVariable(CTX, *parsed_function_.saved_context_var());
} else {
while (current_context_level-- > 0) {
__ movq(CTX, FieldAddress(CTX, Context::parent_offset()));
@@ -814,10 +812,11 @@
// 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.
+ // save it in a pre-allocated variable and restore it on exit.
if ((node_sequence == parsed_function_.node_sequence()) &&
- !parsed_function_.function().IsClosureFunction()) {
- __ pushq(CTX);
+ (parsed_function_.saved_context_var() != NULL)) {
+ GenerateStoreVariable(
+ *parsed_function_.saved_context_var(), CTX, kNoRegister);
const Immediate raw_null =
Immediate(reinterpret_cast<intptr_t>(Object::null()));
__ movq(CTX, raw_null);
@@ -868,23 +867,25 @@
state()->set_root_node(child_node);
child_node->Visit(this);
}
- if (num_context_variables > 0) {
- // Unchain the previously allocated context.
- if ((node_sequence == parsed_function_.node_sequence()) &&
- !parsed_function_.function().IsClosureFunction()) {
- __ popq(CTX);
- } else {
- __ movq(CTX, FieldAddress(CTX, Context::parent_offset()));
- }
+
+ // Unchain the previously allocated context.
+ if ((node_sequence == parsed_function_.node_sequence()) &&
+ (parsed_function_.saved_context_var() != NULL)) {
+ ASSERT(num_context_variables > 0);
+ GenerateLoadVariable(CTX, *parsed_function_.saved_context_var());
+ } else if (num_context_variables > 0) {
+ __ movq(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()) {
- __ popq(CTX);
+
+ // The context saved on entry must be restored.
+ if ((node_sequence == parsed_function_.node_sequence()) &&
+ (parsed_function_.saved_context_var() != NULL)) {
+ GenerateLoadVariable(CTX, *parsed_function_.saved_context_var());
}
}
set_context_level(previous_context_level);
@@ -2546,12 +2547,6 @@
__ movq(RSP, RBP);
__ subq(RSP, Immediate(locals_space_size()));
- if ((context_level() > 0) &&
- !parsed_function_.function().IsClosureFunction()) {
- // CTX was saved on entry.
- __ subq(RSP, Immediate(kWordSize));
- }
-
// The JumpToExceptionHandler trampoline code sets up
// - the exception object in RAX (kExceptionObjectReg)
// - the stacktrace object in register RDX (kStackTraceObjectReg)
« no previous file with comments | « runtime/vm/code_generator_ia32.cc ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698