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

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

Issue 1413703007: [Interpreter] Fix a register allocation bug and add a DCHECK. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rename function Created 5 years, 2 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-array-builder.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('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 95d3f921b1551cc57ed72482e525f4bfaaeec298..110a3e84dc40b1f0e97e9699818f7d917472bd5e 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -193,6 +193,8 @@ class BytecodeGenerator::ExpressionResultScope {
bool result_identified() const { return result_identified_; }
+ const TemporaryRegisterScope* allocator() const { return &allocator_; }
+
private:
BytecodeGenerator* generator_;
Expression::Context kind_;
@@ -252,7 +254,8 @@ class BytecodeGenerator::RegisterResultScope final
virtual void SetResultInRegister(Register reg) {
DCHECK(builder()->RegisterIsParameterOrLocal(reg) ||
- builder()->RegisterIsTemporary(reg));
+ (builder()->RegisterIsTemporary(reg) &&
+ !allocator()->RegisterIsAllocatedInThisScope(reg)));
result_register_ = reg;
set_result_identified();
}
@@ -475,6 +478,8 @@ void BytecodeGenerator::VisitDeclarations(
void BytecodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) {
+ // TODO(rmcilroy): Replace this with a StatementResultScope when it exists.
+ EffectResultScope effect_scope(this);
VisitForEffect(stmt->expression());
}
@@ -522,6 +527,7 @@ void BytecodeGenerator::VisitBreakStatement(BreakStatement* stmt) {
void BytecodeGenerator::VisitReturnStatement(ReturnStatement* stmt) {
+ EffectResultScope effect_scope(this);
VisitForAccumulatorValue(stmt->expression());
builder()->Return();
}
@@ -1484,7 +1490,7 @@ void BytecodeGenerator::VisitCountOperation(CountOperation* expr) {
// Save result for postfix expressions.
if (is_postfix) {
- old_value = execution_result()->NewRegister();
+ old_value = execution_result()->outer()->NewRegister();
builder()->StoreAccumulatorInRegister(old_value);
}
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698