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

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

Issue 1396693003: [Interpreter] Add function literal support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_newcontext
Patch Set: Review comments 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/runtime/runtime-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 ab85a76206a46fd60140e0f76970e2543e08322d..e054f970991e3053e48d31c0272749736493a3c8 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -121,6 +121,11 @@ static void CheckConstant(Handle<Object> expected, Object* actual) {
}
+static void CheckConstant(InstanceType expected, Object* actual) {
+ CHECK_EQ(expected, HeapObject::cast(actual)->map()->instance_type());
+}
+
+
template <typename T>
static void CheckBytecodeArrayEqual(struct ExpectedSnippet<T> expected,
Handle<BytecodeArray> actual,
@@ -1813,6 +1818,63 @@ TEST(UnaryOperators) {
}
+TEST(FunctionLiterals) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+
+ ExpectedSnippet<InstanceType> snippets[] = {
+ {"return function(){ }",
+ 0,
+ 1,
+ 5,
+ {
+ B(LdaConstant), U8(0), //
+ B(CreateClosure), U8(0), //
+ B(Return) //
+ },
+ 1,
+ {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
+ {"return (function(){ })()",
+ 2 * kPointerSize,
+ 1,
+ 14,
+ {
+ B(LdaUndefined), //
+ B(Star), R(1), //
+ B(LdaConstant), U8(0), //
+ B(CreateClosure), U8(0), //
+ B(Star), R(0), //
+ B(Call), R(0), R(1), U8(0), //
+ B(Return) //
+ },
+ 1,
+ {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
+ {"return (function(x){ return x; })(1)",
+ 3 * kPointerSize,
+ 1,
+ 18,
+ {
+ B(LdaUndefined), //
+ B(Star), R(1), //
+ B(LdaConstant), U8(0), //
+ B(CreateClosure), U8(0), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(1), //
+ B(Star), R(2), //
+ B(Call), R(0), R(1), U8(1), //
+ B(Return) //
+ },
+ 1,
+ {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
+ };
+
+ 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/runtime/runtime-interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698