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

Unified Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 1412683011: [Interpreter] Enable assignments in expressions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Sync test bytecode sequences to avoid unnecessary Ldar/Star instructions. Created 5 years, 1 month 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/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/interpreter/test-bytecode-generator.cc
diff --git a/test/cctest/interpreter/test-bytecode-generator.cc b/test/cctest/interpreter/test-bytecode-generator.cc
index 54a8bb3fe57f2278bf39340397ae6d6e12b3e933..1c2094c6f72d566bbdfdea1ce47d8d0b3eebfae7 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -5265,6 +5265,225 @@ TEST(RemoveRedundantLdar) {
}
}
+
+TEST(AssignmentsInBinaryExpression) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+
+ ExpectedSnippet<const char*> snippets[] = {
+ {"var x = 0, y = 1;\n"
+ "return (x = 2, y = 3, x = 4, y = 5)",
+ 2 * kPointerSize,
+ 1,
+ 24,
+ {
+ B(LdaZero), B(Star), R(0), //
+ B(LdaSmi8), U8(1), //
+ B(Star), R(1), //
+ B(LdaSmi8), U8(2), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(3), //
+ B(Star), R(1), //
+ B(LdaSmi8), U8(4), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(5), //
+ B(Star), R(1), //
+ B(Return), //
+ },
+ 0},
+ {"var x = 55;\n"
+ "var y = (x = 100);\n"
+ "return y",
+ 2 * kPointerSize,
+ 1,
+ 11,
+ {
+ B(LdaSmi8), U8(55), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(100), //
+ B(Star), R(0), //
+ B(Star), R(1), //
+ B(Return), //
+ },
+ 0},
+ {"var x = 55;\n"
+ "x = x + (x = 100) + (x = 101);\n"
+ "return x;",
+ 4 * kPointerSize,
+ 1,
+ 24,
+ {
+ B(LdaSmi8), U8(55), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(100), //
+ B(Star), R(1), //
+ B(Add), R(0), //
+ B(Star), R(2), //
+ B(LdaSmi8), U8(101), //
+ B(Star), R(3), //
+ B(Add), R(2), //
+ B(Mov), R(3), R(0), //
+ B(Star), R(0), //
+ B(Return), //
+ },
+ 0},
+ {"var x = 55;\n"
+ "x = (x = 56) - x + (x = 57);\n"
+ "x++;\n"
+ "return x;",
+ 3 * kPointerSize,
+ 1,
+ 34,
+ {
+ B(LdaSmi8), U8(55), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(56), //
+ B(Star), R(0), //
+ B(Star), R(1), //
+ B(Ldar), R(0), //
+ B(Sub), R(1), //
+ B(Star), R(2), //
+ B(LdaSmi8), U8(57), //
+ B(Star), R(1), //
+ B(Add), R(2), //
+ B(Mov), R(1), R(0), //
+ B(Star), R(0), //
+ B(ToNumber), //
+ B(Star), R(1), //
+ B(Inc), //
+ B(Star), R(0), //
+ B(Return), //
+ },
+ 0},
+ {"var x = 55;\n"
+ "var y = x + (x = 1) + (x = 2) + (x = 3);\n"
+ "return y;",
+ 6 * kPointerSize,
+ 1,
+ 32,
+ {
+ B(LdaSmi8), U8(55), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(1), //
+ B(Star), R(2), //
+ B(Add), R(0), //
+ B(Star), R(3), //
+ B(LdaSmi8), U8(2), //
+ B(Star), R(4), //
+ B(Add), R(3), //
+ B(Star), R(5), //
+ B(LdaSmi8), U8(3), //
+ B(Star), R(3), //
+ B(Add), R(5), //
+ B(Mov), R(3), R(0), //
+ B(Star), R(1), //
+ B(Return), //
+ },
+ 0},
+ {"var x = 55;\n"
+ "var x = x + (x = 1) + (x = 2) + (x = 3);\n"
+ "return x;",
+ 5 * kPointerSize,
+ 1,
+ 32,
+ {
+ B(LdaSmi8), U8(55), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(1), //
+ B(Star), R(1), //
+ B(Add), R(0), //
+ B(Star), R(2), //
+ B(LdaSmi8), U8(2), //
+ B(Star), R(3), //
+ B(Add), R(2), //
+ B(Star), R(4), //
+ B(LdaSmi8), U8(3), //
+ B(Star), R(2), //
+ B(Add), R(4), //
+ B(Mov), R(2), R(0), //
+ B(Star), R(0), //
+ B(Return), //
+ },
+ 0},
+ {"var x = 10, y = 20;\n"
+ "return x + (x = 1) + (x + 1) * (y = 2) + (y = 3) + (x = 4) + (y = 5) + "
+ "y;\n",
+ 6 * kPointerSize,
+ 1,
+ 64,
+ {
+ B(LdaSmi8), U8(10), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(20), //
+ B(Star), R(1), //
+ B(LdaSmi8), U8(1), //
+ B(Star), R(2), //
+ B(Add), R(0), //
+ B(Star), R(3), //
+ B(LdaSmi8), U8(1), //
+ B(Add), R(2), //
+ B(Star), R(4), //
+ B(LdaSmi8), U8(2), //
+ B(Star), R(1), //
+ B(Mul), R(4), //
+ B(Add), R(3), //
+ B(Star), R(4), //
+ B(LdaSmi8), U8(3), //
+ B(Star), R(1), //
+ B(Add), R(4), //
+ B(Star), R(3), //
+ B(LdaSmi8), U8(4), //
+ B(Star), R(4), //
+ B(Add), R(3), //
+ B(Star), R(5), //
+ B(LdaSmi8), U8(5), //
+ B(Star), R(1), //
+ B(Add), R(5), //
+ B(Star), R(3), //
+ B(Ldar), R(1), //
+ B(Add), R(3), //
+ B(Mov), R(4), R(0), //
+ B(Return), //
+ },
+ 0},
+ {"var x = 17;\n"
+ "return 1 + x + (x++) + (++x);\n",
+ 5 * kPointerSize,
+ 1,
+ 40,
+ {
+ B(LdaSmi8), U8(17), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(1), //
+ B(Star), R(1), //
+ B(Ldar), R(0), //
+ B(Add), R(1), //
+ B(Star), R(2), //
+ B(Ldar), R(0), //
+ B(ToNumber), //
+ B(Star), R(1), //
+ B(Inc), //
+ B(Star), R(3), //
+ B(Ldar), R(1), //
+ B(Add), R(2), //
+ B(Star), R(4), //
+ B(Ldar), R(3), //
+ B(ToNumber), //
+ B(Inc), //
+ B(Star), R(1), //
+ B(Add), R(4), //
+ B(Mov), R(1), R(0), //
+ B(Return), //
+ },
+ 0}};
+
+ for (size_t i = 0; i < arraysize(snippets); i++) {
+ Handle<BytecodeArray> bytecode_array =
+ helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
+ CheckBytecodeArrayEqual(snippets[i], bytecode_array);
+ }
+}
+
} // namespace interpreter
} // namespace internal
} // namespace v8
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698