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

Unified Diff: runtime/vm/code_generator_x64.cc

Issue 9706086: Clean-up CodeGenState: remove unused loop_level and move context_level to CodeGenerator (and add it… (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
Index: runtime/vm/code_generator_x64.cc
===================================================================
--- runtime/vm/code_generator_x64.cc (revision 5548)
+++ runtime/vm/code_generator_x64.cc (working copy)
@@ -41,13 +41,9 @@
parent_(codegen->state()) {
if (parent_ != NULL) {
root_node_ = parent_->root_node_;
- loop_level_ = parent_->loop_level_;
- context_level_ = parent_->context_level_;
current_try_index_ = parent_->current_try_index_;
} else {
root_node_ = NULL;
- loop_level_ = 0;
- context_level_ = 0;
current_try_index_ = CatchClauseNode::kInvalidTryIndex;
}
codegen_->set_state(this);
@@ -115,7 +111,8 @@
state_(NULL),
pc_descriptors_list_(NULL),
exception_handlers_list_(NULL),
- try_index_(CatchClauseNode::kInvalidTryIndex) {
+ try_index_(CatchClauseNode::kInvalidTryIndex),
+ context_level_(0) {
ASSERT(assembler_ != NULL);
ASSERT(parsed_function.node_sequence() != NULL);
ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump());
@@ -240,7 +237,7 @@
const LocalVariable& variable) {
if (variable.is_captured()) {
// The variable lives in the context.
- int delta = state()->context_level() - variable.owner()->context_level();
+ intptr_t delta = context_level() - variable.owner()->context_level();
ASSERT(delta >= 0);
Register base = CTX;
while (delta-- > 0) {
@@ -261,7 +258,7 @@
Register scratch) {
if (variable.is_captured()) {
// The variable lives in the context.
- int delta = state()->context_level() - variable.owner()->context_level();
+ intptr_t delta = context_level() - variable.owner()->context_level();
ASSERT(delta >= 0);
Register base = CTX;
while (delta-- > 0) {
@@ -283,7 +280,7 @@
Register scratch) {
if (variable.is_captured()) {
// The variable lives in the context.
- int delta = state()->context_level() - variable.owner()->context_level();
+ intptr_t delta = context_level() - variable.owner()->context_level();
ASSERT(delta >= 0);
Register base = CTX;
while (delta-- > 0) {
@@ -613,15 +610,15 @@
void CodeGenerator::GenerateReturnEpilog(ReturnNode* node) {
// Unchain the context(s) up to context level 0.
- int context_level = state()->context_level();
- ASSERT(context_level >= 0);
+ intptr_t current_context_level = context_level();
+ ASSERT(current_context_level >= 0);
if (!parsed_function_.function().IsClosureFunction()) {
- if (context_level > 0) {
+ if (current_context_level > 0) {
// CTX on entry was saved on the stack, but not linked as context parent.
__ popq(CTX);
}
} else {
- while (context_level-- > 0) {
+ while (current_context_level-- > 0) {
__ movq(CTX, FieldAddress(CTX, Context::parent_offset()));
}
}
@@ -748,7 +745,7 @@
// The context scope may have already been set by the new non-optimizing
// compiler. If it was not, set it here.
if (function.context_scope() == ContextScope::null()) {
- const int current_context_level = state()->context_level();
+ const intptr_t current_context_level = context_level();
const ContextScope& context_scope = ContextScope::ZoneHandle(
node->scope()->PreserveOuterScope(current_context_level));
ASSERT(!function.HasCode());
@@ -805,6 +802,7 @@
LocalScope* scope = node_sequence->scope();
const intptr_t num_context_variables =
(scope != NULL) ? scope->num_context_variables() : 0;
+ intptr_t previous_context_level = context_level();
if (num_context_variables > 0) {
// The loop local scope declares variables that are captured.
// Allocate and chain a new context.
@@ -831,7 +829,7 @@
CTX);
// Set new context as current context.
__ movq(CTX, RAX);
- state()->set_context_level(scope->context_level());
+ set_context_level(scope->context_level());
// If this node_sequence is the body of the function being compiled, copy
// the captured parameters from the frame into the context.
@@ -889,6 +887,7 @@
__ popq(CTX);
}
}
+ set_context_level(previous_context_level);
}
@@ -1865,7 +1864,7 @@
// Unchain the context(s) up to the outer context level of the scope which
// contains the destination label.
ASSERT(label->owner() != NULL);
- int target_context_level = 0;
+ intptr_t target_context_level = 0;
LocalScope* target_scope = label->owner();
if (target_scope->num_context_variables() > 0) {
// The scope of the target label allocates a context, therefore its outer
@@ -1883,9 +1882,9 @@
}
}
ASSERT(target_context_level >= 0);
- int context_level = state()->context_level();
- ASSERT(context_level >= target_context_level);
- while (context_level-- > target_context_level) {
+ int current_context_level = context_level();
+ ASSERT(current_context_level >= target_context_level);
+ while (current_context_level-- > target_context_level) {
__ movq(CTX, FieldAddress(CTX, Context::parent_offset()));
}
@@ -2547,7 +2546,7 @@
__ movq(RSP, RBP);
__ subq(RSP, Immediate(locals_space_size()));
- if ((state()->context_level() > 0) &&
+ if ((context_level() > 0) &&
!parsed_function_.function().IsClosureFunction()) {
// CTX was saved on entry.
__ subq(RSP, Immediate(kWordSize));

Powered by Google App Engine
This is Rietveld 408576698