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

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

Issue 1524893003: [Interpreter] Add support for break statements in labelled blocks. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@oth-0009-phi
Patch Set: Rebase Created 5 years 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 | « test/cctest/compiler/test-run-bytecode-graph-builder.cc ('k') | no next file » | 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 61b8c36b1f28478dead596ea5b9af2d727352666..b31f5e23181ac1b4226f2019d0fcaa3608efcf9a 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -1968,6 +1968,91 @@ TEST(DeclareGlobals) {
}
+TEST(BreakableBlocks) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+
+ ExpectedSnippet<int> snippets[] = {
+ {"var x = 0;\n"
+ "label: {\n"
+ " x = x + 1;\n"
+ " break label;\n"
+ " x = x + 1;\n"
+ "}\n"
+ "return x;",
+ 1 * kPointerSize,
+ 1,
+ 14,
+ {
+ B(LdaZero), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(1), //
+ B(Add), R(0), //
+ B(Star), R(0), //
+ B(Jump), U8(2), //
+ B(Ldar), R(0), //
+ B(Return) //
+ }},
+ {"var sum = 0;\n"
+ "outer: {\n"
+ " for (var x = 0; x < 10; ++x) {\n"
+ " for (var y = 0; y < 3; ++y) {\n"
+ " ++sum;\n"
+ " if (x + y == 12) { break outer; }\n"
+ " }\n"
+ " }\n"
+ "}\n"
+ "return sum;",
+ 4 * kPointerSize,
+ 1,
+ 60,
+ {
+ B(LdaZero), //
+ B(Star), R(0), //
+ B(LdaZero), //
+ B(Star), R(1), //
+ B(LdaSmi8), U8(10), //
+ B(TestLessThan), R(1), //
+ B(JumpIfFalse), U8(47), //
+ B(LdaZero), //
+ B(Star), R(2), //
+ B(LdaSmi8), U8(3), //
+ B(TestLessThan), R(2), //
+ B(JumpIfFalse), U8(30), //
+ B(Ldar), R(0), //
+ B(ToNumber), //
+ B(Inc), //
+ B(Star), R(0), //
+ B(Ldar), R(2), //
+ B(Add), R(1), //
+ B(Star), R(3), //
+ B(LdaSmi8), U8(12), //
+ B(TestEqual), R(3), //
+ B(JumpIfFalse), U8(4), //
+ B(Jump), U8(18), //
+ B(Ldar), R(2), //
+ B(ToNumber), //
+ B(Inc), //
+ B(Star), R(2), //
+ B(Jump), U8(-32), //
+ B(Ldar), R(1), //
+ B(ToNumber), //
+ B(Inc), //
+ B(Star), R(1), //
+ B(Jump), U8(-49), //
+ B(Ldar), R(0), //
+ B(Return), //
+ }},
+ };
+
+ for (size_t i = 0; i < arraysize(snippets); i++) {
+ Handle<BytecodeArray> bytecode_array =
+ helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
+ CheckBytecodeArrayEqual(snippets[i], bytecode_array);
+ }
+}
+
+
TEST(BasicLoops) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
« no previous file with comments | « test/cctest/compiler/test-run-bytecode-graph-builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698