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

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

Issue 1402093002: [Interpreter]: Add fake support for try/catch/finally. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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-generator.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 459fe6232c7162ad1e00baefc4651fc91b408f82..c03f45df41e1912d600b90f491643c62b3a8268b 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -25,6 +25,7 @@ class BytecodeGeneratorHelper {
BytecodeGeneratorHelper() {
i::FLAG_vector_stores = true;
i::FLAG_ignition = true;
+ i::FLAG_ignition_fake_try_catch = true;
i::FLAG_ignition_filter = StrDup(kFunctionName);
i::FLAG_always_opt = false;
i::FLAG_allow_natives_syntax = true;
@@ -2051,6 +2052,79 @@ TEST(ArrayLiterals) {
}
}
+
+TEST(TryCatch) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+
+ // TODO(rmcilroy): modify tests when we have real try catch support.
+ ExpectedSnippet<int> snippets[] = {
+ {"try { return 1; } catch(e) { return 2; }",
+ 0,
+ 1,
+ 5,
+ {
+ B(LdaSmi8), U8(1), //
+ B(Return), //
+ B(LdaUndefined), //
+ 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);
+ }
+}
+
+
+TEST(TryFinally) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+
+ // TODO(rmcilroy): modify tests when we have real try finally support.
+ ExpectedSnippet<int> snippets[] = {
+ {"var a = 1; try { a = 2; } finally { a = 3; }",
+ 1 * kPointerSize,
+ 1,
+ 14,
+ {
+ B(LdaSmi8), U8(1), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(2), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(3), //
+ B(Star), R(0), //
+ B(LdaUndefined), //
+ B(Return), //
+ },
+ 0},
+ {"var a = 1; try { a = 2; } catch(e) { a = 20 } finally { a = 3; }",
+ 1 * kPointerSize,
+ 1,
+ 14,
+ {
+ B(LdaSmi8), U8(1), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(2), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(3), //
+ B(Star), R(0), //
+ B(LdaUndefined), //
+ 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/bytecode-generator.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698