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

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

Issue 1618693002: [Interpreter] Ensure context is popped when we break or continue (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
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.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 b2be0ec90e32fcc022a42cf34e81f8f7f6e179f2..ada20b7c0bf7dd80c22b61b926982d77a4e5ab25 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -2324,6 +2324,56 @@ TEST(BreakableBlocks) {
2,
{InstanceType::FIXED_ARRAY_TYPE,
InstanceType::SHARED_FUNCTION_INFO_TYPE}},
+ {"let x = 1;\n"
+ "outer: {\n"
+ " inner: {\n"
+ " let y = 2;\n"
+ " function f() { return x + y; }\n"
+ " if (y) break outer;\n"
+ " y = 3;\n"
+ " }\n"
+ "}\n"
+ "x = 4;",
+ 6 * kPointerSize,
+ 1,
+ 72,
+ {
+ B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
+ U8(1), //
+ B(PushContext), R(2), //
+ B(LdaTheHole), //
+ B(StaContextSlot), R(2), U8(4), //
+ B(LdaSmi8), U8(1), //
+ B(StaContextSlot), R(2), U8(4), //
+ B(LdaConstant), U8(0), //
+ B(Star), R(4), //
+ B(Ldar), R(closure), //
+ B(Star), R(5), //
+ B(CallRuntime), U16(Runtime::kPushBlockContext), R(4), U8(2), //
+ B(PushContext), R(3), //
+ B(LdaTheHole), //
+ B(StaContextSlot), R(3), U8(4), //
+ B(CreateClosure), U8(1), U8(0), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(2), //
+ B(StaContextSlot), R(3), U8(4), //
+ B(Ldar), R(0), //
+ B(Star), R(1), //
+ B(LdaContextSlot), R(3), U8(4), //
+ B(JumpIfToBooleanFalse), U8(6), //
+ B(PopContext), R(2), //
+ B(Jump), U8(9), //
+ B(LdaSmi8), U8(3), //
+ B(StaContextSlot), R(3), U8(4), //
+ B(PopContext), R(2), //
+ B(LdaSmi8), U8(4), //
+ B(StaContextSlot), R(2), U8(4), //
+ B(LdaUndefined), //
+ B(Return), //
+ },
+ 2,
+ {InstanceType::FIXED_ARRAY_TYPE,
+ InstanceType::SHARED_FUNCTION_INFO_TYPE}},
};
for (size_t i = 0; i < arraysize(snippets); i++) {
@@ -2338,7 +2388,10 @@ TEST(BasicLoops) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
- ExpectedSnippet<int> snippets[] = {
+ int closure = Register::function_closure().index();
+ int context = Register::function_context().index();
+
+ ExpectedSnippet<InstanceType> snippets[] = {
{"var x = 0;\n"
"while (false) { x = 99; break; continue; }\n"
"return x;",
@@ -2950,6 +3003,54 @@ TEST(BasicLoops) {
B(Return), //
},
0},
+ {"var a = 0;\n"
+ "while (a) {\n"
+ " { \n"
+ " let z = 1;\n"
+ " function f() { z = 2; }\n"
+ " if (z) continue;\n"
+ " z++;\n"
+ " }\n"
+ "}\n",
+ 6 * kPointerSize,
+ 1,
+ 65,
+ {
+ B(LdaZero), //
+ B(Star), R(1), //
+ B(Ldar), R(1), //
+ B(JumpIfToBooleanFalse), U8(58), //
+ B(LdaConstant), U8(0), //
+ B(Star), R(4), //
+ B(Ldar), R(closure), //
+ B(Star), R(5), //
+ B(CallRuntime), U16(Runtime::kPushBlockContext), R(4), U8(2), //
+ B(PushContext), R(3), //
+ B(LdaTheHole), //
+ B(StaContextSlot), R(3), U8(4), //
+ B(CreateClosure), U8(1), U8(0), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(1), //
+ B(StaContextSlot), R(3), U8(4), //
+ B(Ldar), R(0), //
+ B(Star), R(2), //
+ B(LdaContextSlot), R(3), U8(4), //
+ B(JumpIfToBooleanFalse), U8(6), //
+ B(PopContext), R(context), //
+ B(Jump), U8(-44), //
+ B(LdaContextSlot), R(3), U8(4), //
+ B(ToNumber), //
+ B(Star), R(4), //
+ B(Inc), //
+ B(StaContextSlot), R(3), U8(4), //
+ B(PopContext), R(context), //
+ B(Jump), U8(-58), //
+ B(LdaUndefined), //
+ B(Return), //
+ },
+ 2,
+ {InstanceType::FIXED_ARRAY_TYPE,
+ InstanceType::SHARED_FUNCTION_INFO_TYPE}},
};
for (size_t i = 0; i < arraysize(snippets); i++) {
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698