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

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 1604923002: [Interpreter] Always store current context in the frames context slot. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_fix_block_context_scope
Patch Set: Rebase Created 4 years, 11 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 | « src/interpreter/bytecode-generator.h ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index d3b1f2722379851370c198a56846e57b4ea81ee6..37cd938a15dacfe65548c79fa4713a83298fc46e 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -27,19 +27,26 @@ class BytecodeGenerator::ContextScope BASE_EMBEDDED {
: generator_(generator),
scope_(scope),
outer_(generator_->execution_context()),
- register_(generator_->NextContextRegister()),
+ register_(Register::current_context()),
depth_(0),
should_pop_context_(should_pop_context) {
if (outer_) {
depth_ = outer_->depth_ + 1;
- generator_->builder()->PushContext(register_);
+
+ // Push the outer context into a new context register.
+ Register outer_context_reg(builder()->first_context_register().index() +
+ outer_->depth_);
+ outer_->set_register(outer_context_reg);
+ generator_->builder()->PushContext(outer_context_reg);
}
generator_->set_execution_context(this);
}
~ContextScope() {
if (outer_ && should_pop_context_) {
+ DCHECK_EQ(register_.index(), Register::current_context().index());
generator_->builder()->PopContext(outer_->reg());
+ outer_->set_register(register_);
}
generator_->set_execution_context(outer_);
}
@@ -67,6 +74,10 @@ class BytecodeGenerator::ContextScope BASE_EMBEDDED {
Register reg() const { return register_; }
private:
+ const BytecodeArrayBuilder* builder() const { return generator_->builder(); }
+
+ void set_register(Register reg) { register_ = reg; }
+
BytecodeGenerator* generator_;
Scope* scope_;
ContextScope* outer_;
@@ -1866,7 +1877,7 @@ void BytecodeGenerator::VisitCall(Call* expr) {
DCHECK(Register::AreContiguous(callee, receiver));
Variable* variable = callee_expr->AsVariableProxy()->var();
builder()
- ->MoveRegister(execution_context()->reg(), context)
+ ->MoveRegister(Register::current_context(), context)
.LoadLiteral(variable->name())
.StoreAccumulatorInRegister(name)
.CallRuntimeForPair(Runtime::kLoadLookupSlot, context, 2, callee);
@@ -2480,24 +2491,6 @@ void BytecodeGenerator::VisitInScope(Statement* stmt, Scope* scope) {
}
-Register BytecodeGenerator::NextContextRegister() const {
- if (execution_context() == nullptr) {
- // Return the incoming function context for the outermost execution context.
- return Register::function_context();
- }
- Register previous = execution_context()->reg();
- if (previous == Register::function_context()) {
- // If the previous context was the incoming function context, then the next
- // context register is the first local context register.
- return builder_.first_context_register();
- } else {
- // Otherwise use the next local context register.
- DCHECK_LT(previous.index(), builder_.last_context_register().index());
- return Register(previous.index() + 1);
- }
-}
-
-
LanguageMode BytecodeGenerator::language_mode() const {
return info()->language_mode();
}
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698