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

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

Issue 1420503002: [Interpreter] Add support for compound expressions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased 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 | « no previous file | 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 ced5210bf6409c9f579a9818f55dcc469ed3a911..3317b51bcd894e3876c9f411c09cfd1636cc2b2b 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -1037,7 +1037,15 @@ void BytecodeGenerator::VisitAssignment(Assignment* expr) {
}
case KEYED_PROPERTY: {
object = VisitForRegisterValue(property->obj());
- key = VisitForRegisterValue(property->key());
+ if (expr->is_compound()) {
+ // Use VisitForAccumulator and store to register so that the key is
+ // still in the accumulator for loading the old value below.
+ key = execution_result()->NewRegister();
+ VisitForAccumulatorValue(property->key());
+ builder()->StoreAccumulatorInRegister(key);
+ } else {
+ key = VisitForRegisterValue(property->key());
+ }
break;
}
case NAMED_SUPER_PROPERTY:
@@ -1048,7 +1056,41 @@ void BytecodeGenerator::VisitAssignment(Assignment* expr) {
// Evaluate the value and potentially handle compound assignments by loading
// the left-hand side value and performing a binary operation.
if (expr->is_compound()) {
- UNIMPLEMENTED();
+ Register old_value;
+ switch (assign_type) {
+ case VARIABLE: {
+ VariableProxy* proxy = expr->target()->AsVariableProxy();
+ old_value = VisitVariableLoadForRegisterValue(
+ proxy->var(), proxy->VariableFeedbackSlot());
+ break;
+ }
+ case NAMED_PROPERTY: {
+ FeedbackVectorSlot slot = property->PropertyFeedbackSlot();
+ old_value = execution_result()->NewRegister();
+ builder()
+ ->LoadNamedProperty(object, name_index, feedback_index(slot),
+ language_mode())
+ .StoreAccumulatorInRegister(old_value);
+ break;
+ }
+ case KEYED_PROPERTY: {
+ // Key is already in accumulator at this point due to evaluating the
+ // LHS above.
+ FeedbackVectorSlot slot = property->PropertyFeedbackSlot();
+ old_value = execution_result()->NewRegister();
+ builder()
+ ->LoadKeyedProperty(object, feedback_index(slot), language_mode())
+ .StoreAccumulatorInRegister(old_value);
+ break;
+ }
+ case NAMED_SUPER_PROPERTY:
+ case KEYED_SUPER_PROPERTY:
+ UNIMPLEMENTED();
+ break;
+ }
+ VisitForAccumulatorValue(expr->value());
+ builder()->BinaryOperation(expr->binary_op(), old_value,
+ language_mode_strength());
} else {
VisitForAccumulatorValue(expr->value());
}
« no previous file with comments | « no previous file | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698