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

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

Issue 1402943002: [Interpreter] Support for operator new. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix missing receiver slot. 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/x64/interface-descriptors-x64.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 9dcfb5b01960a2dea91ef138c850da3b94d64f1e..33c5e50c633132ee4efca5bc6b140ec70eaa9fa8 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -1015,14 +1015,14 @@ TEST(PropertyCall) {
B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), //
B(Star), R(0), //
B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(2), //
+ B(Star), R(3), //
B(Ldar), R(helper.kLastParamIndex), //
- B(Add), R(2), //
+ B(Add), R(3), //
B(Star), R(2), //
B(Ldar), R(helper.kLastParamIndex), //
B(Star), R(3), //
B(Call), R(0), R(1), U8(2), //
- B(Return) //
+ B(Return), //
},
1,
{"func"}}};
@@ -2670,6 +2670,72 @@ TEST(TryFinally) {
}
}
+
+TEST(CallNew) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+
+ ExpectedSnippet<InstanceType> snippets[] = {
+ {"function bar() { this.value = 0; }\n"
+ "function f() { return new bar(); }\n"
+ "f()",
+ kPointerSize,
+ 1,
+ 9,
+ {
+ B(LdaGlobal), _, //
+ B(Star), R(0), //
+ B(New), R(0), R(0), U8(0), //
+ B(Return), //
+ },
+ 0},
+ {"function bar(x) { this.value = 18; this.x = x;}\n"
+ "function f() { return new bar(3); }\n"
+ "f()",
+ 2 * kPointerSize,
+ 1,
+ 13,
+ {
+ B(LdaGlobal), _, //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(3), //
+ B(Star), R(1), //
+ B(New), R(0), R(1), U8(1), //
+ B(Return), //
+ },
+ 0},
+ {"function bar(w, x, y, z) {\n"
+ " this.value = 18;\n"
+ " this.x = x;\n"
+ " this.y = y;\n"
+ " this.z = z;\n"
+ "}\n"
+ "function f() { return new bar(3, 4, 5); }\n"
+ "f()",
+ 4 * kPointerSize,
+ 1,
+ 21,
+ {
+ B(LdaGlobal), _, //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(3), //
+ B(Star), R(1), //
+ B(LdaSmi8), U8(4), //
+ B(Star), R(2), //
+ B(LdaSmi8), U8(5), //
+ B(Star), R(3), //
+ B(New), R(0), R(1), U8(3), //
+ B(Return), //
+ },
+ 0}};
+
+ for (size_t i = 0; i < arraysize(snippets); i++) {
+ Handle<BytecodeArray> bytecode_array =
+ helper.MakeBytecode(snippets[i].code_snippet, "f");
+ CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
+ }
+}
+
} // namespace interpreter
} // namespace internal
} // namespace v8
« no previous file with comments | « src/x64/interface-descriptors-x64.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698