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

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

Issue 1412953007: [Interpreter] Fill out function prologue support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased 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/x87/builtins-x87.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 4a33b3d3e36be309cd84a0d78033c30dc747510a..aa77d417aacd46cac67744461e7b6b7d74a758fb 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -3362,6 +3362,136 @@ TEST(GlobalCompoundExpressions) {
}
}
+
+TEST(CreateArguments) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+ Zone zone;
+
+ int closure = Register::function_closure().index();
+ int first_context_slot = Context::MIN_CONTEXT_SLOTS;
+
+ FeedbackVectorSpec feedback_spec(&zone);
+ FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot();
+
+ Handle<i::TypeFeedbackVector> vector =
+ i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
+
+ ExpectedSnippet<const char*> snippets[] = {
+ {"function f() { return arguments; }",
+ 1 * kPointerSize,
+ 1,
+ 6,
+ {
+ B(CreateMappedArguments), //
+ B(Star), R(0), //
+ B(Ldar), R(0), //
+ B(Return), //
+ }},
+ {"function f() { return arguments[0]; }",
+ 1 * kPointerSize,
+ 1,
+ 8,
+ {
+ B(CreateMappedArguments), //
+ B(Star), R(0), //
+ B(LdaZero), //
+ B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot)), //
+ B(Return), //
+ }},
+ {"function f() { 'use strict'; return arguments; }",
+ 1 * kPointerSize,
+ 1,
+ 6,
+ {
+ B(CreateUnmappedArguments), //
+ B(Star), R(0), //
+ B(Ldar), R(0), //
+ B(Return), //
+ }},
+ {"function f(a) { return arguments[0]; }",
+ 2 * kPointerSize,
+ 2,
+ 20,
+ {
+ B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
+ U8(1), //
+ B(PushContext), R(1), //
+ B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), //
+ B(StaContextSlot), R(1), U8(first_context_slot), //
+ B(CreateMappedArguments), //
+ B(Star), R(0), //
+ B(LdaZero), //
+ B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot)), //
+ B(Return), //
+ }},
+ {"function f(a, b, c) { return arguments; }",
+ 2 * kPointerSize,
+ 4,
+ 28,
+ {
+ B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
+ U8(1), //
+ B(PushContext), R(1), //
+ B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 2), //
+ B(StaContextSlot), R(1), U8(first_context_slot + 2), //
+ B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 1), //
+ B(StaContextSlot), R(1), U8(first_context_slot + 1), //
+ B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), //
+ B(StaContextSlot), R(1), U8(first_context_slot), //
+ B(CreateMappedArguments), //
+ B(Star), R(0), //
+ B(Ldar), R(0), //
+ B(Return), //
+ }},
+ {"function f(a, b, c) { 'use strict'; return arguments; }",
+ 1 * kPointerSize,
+ 4,
+ 6,
+ {
+ B(CreateUnmappedArguments), //
+ B(Star), R(0), //
+ B(Ldar), R(0), //
+ B(Return), //
+ }},
+ };
+
+ for (size_t i = 0; i < arraysize(snippets); i++) {
+ Handle<BytecodeArray> bytecode_array =
+ helper.MakeBytecodeForFunction(snippets[i].code_snippet);
+ CheckBytecodeArrayEqual(snippets[i], bytecode_array);
+ }
+}
+
+
+TEST(IllegalRedeclaration) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+
+ ExpectedSnippet<const char*> snippets[] = {
+ {"const a = 1; { var a = 2; }",
+ 3 * kPointerSize,
+ 1,
+ 14,
+ {
+ B(LdaSmi8), U8(MessageTemplate::kVarRedeclaration), //
+ B(Star), R(1), //
+ B(LdaConstant), U8(0), //
+ B(Star), R(2), //
+ B(CallRuntime), U16(Runtime::kNewSyntaxError), R(1), U8(2), //
+ B(Throw), //
+ },
+ 1,
+ {"a"}},
+ };
+
+ 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/x87/builtins-x87.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698