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

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

Issue 1664593003: [Interpreter] Adds support for rest parameters to interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixes comments. 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
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 b730fa63ebe15a0ff2f637a3da14b19dda0cc968..9cc1012249c96d2d0b486609d106c00646f877ae 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -5491,6 +5491,100 @@ TEST(CreateArguments) {
}
}
+TEST(CreateRestArguments) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+ Zone zone;
+
+ FeedbackVectorSpec feedback_spec(&zone);
+ FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot();
+ FeedbackVectorSlot slot1 = feedback_spec.AddKeyedLoadICSlot();
+
+ Handle<i::TypeFeedbackVector> vector =
+ i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
+
+ ExpectedSnippet<int> snippets[] = {
+ {"function f(...restArgs) { return restArgs; }",
+ 1 * kPointerSize,
+ 2,
+ 5,
+ {
+ B(CreateRestArguments), U8(0), //
+ B(Star), R(0), //
+ B(Return), //
+ },
+ 1,
+ {0}},
+ {"function f(a, ...restArgs) { return restArgs; }",
+ 2 * kPointerSize,
+ 3,
+ 14,
+ {
+ B(CreateRestArguments), U8(0), //
+ B(Star), R(0), //
+ B(LdaTheHole), //
+ B(Star), R(1), //
+ B(Ldar), A(1, 3), //
+ B(Star), R(1), //
+ B(Ldar), R(0), //
+ B(Return), //
+ },
+ 1,
+ {1}},
+ {"function f(a, ...restArgs) { return restArgs[0]; }",
+ 3 * kPointerSize,
+ 3,
+ 20,
+ {
+ B(CreateRestArguments), U8(0), //
+ B(Star), R(0), //
+ B(LdaTheHole), //
+ B(Star), R(1), //
+ B(Ldar), A(1, 3), //
+ B(Star), R(1), //
+ B(Ldar), R(0), //
+ B(Star), R(2), //
+ B(LdaZero), //
+ B(KeyedLoadICSloppy), R(2), U8(vector->GetIndex(slot)), //
+ B(Return), //
+ },
+ 1,
+ {1}},
+ {"function f(a, ...restArgs) { return restArgs[0] + arguments[0]; }",
+ 5 * kPointerSize,
+ 3,
+ 35,
+ {
+ B(CreateUnmappedArguments), //
+ B(Star), R(0), //
+ B(CreateRestArguments), U8(0), //
+ B(Star), R(1), //
+ B(LdaTheHole), //
+ B(Star), R(2), //
+ B(Ldar), A(1, 3), //
+ B(Star), R(2), //
+ B(Ldar), R(1), //
+ B(Star), R(3), //
+ B(LdaZero), //
+ B(KeyedLoadICSloppy), R(3), U8(vector->GetIndex(slot)), //
+ B(Star), R(4), //
+ B(Ldar), R(0), //
+ B(Star), R(3), //
+ B(LdaZero), //
+ B(KeyedLoadICSloppy), R(3), U8(vector->GetIndex(slot1)), //
+ B(Add), R(4), //
+ B(Return), //
+ },
+ 1,
+ {1}},
+ };
+
+ 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;
« no previous file with comments | « test/cctest/compiler/test-run-bytecode-graph-builder.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698