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

Unified Diff: test/cctest/test-code-stub-assembler.cc

Issue 2469273003: [stubs] Add a utility class to generate code to access builtin arguments (Closed)
Patch Set: Review feedback Created 4 years, 1 month 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 | « test/cctest/compiler/code-assembler-tester.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-code-stub-assembler.cc
diff --git a/test/cctest/test-code-stub-assembler.cc b/test/cctest/test-code-stub-assembler.cc
index 94200aafdf4f9ecc5a7b04d9fef9c5d37b515f87..19fabe1f4d194bf13233840677b24126862ea9b9 100644
--- a/test/cctest/test-code-stub-assembler.cc
+++ b/test/cctest/test-code-stub-assembler.cc
@@ -1917,5 +1917,63 @@ TEST(TwoToTwoByteStringCopy) {
Handle<SeqTwoByteString>::cast(string2)->GetChars()[4]);
}
+TEST(Arguments) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+
+ const int kNumParams = 4;
+ CodeStubAssemblerTester m(isolate, kNumParams);
+
+ CodeStubArguments arguments(&m, m.IntPtrConstant(3));
+
+ m.Assert(m.WordEqual(arguments.AtIndex(0), m.SmiConstant(Smi::FromInt(12))));
+ m.Assert(m.WordEqual(arguments.AtIndex(1), m.SmiConstant(Smi::FromInt(13))));
+ m.Assert(m.WordEqual(arguments.AtIndex(2), m.SmiConstant(Smi::FromInt(14))));
+
+ m.Return(arguments.GetReceiver());
+
+ Handle<Code> code = m.GenerateCode();
+ CHECK(!code.is_null());
+
+ FunctionTester ft(code, kNumParams);
+ Handle<Object> result = ft.Call(isolate->factory()->undefined_value(),
+ Handle<Smi>(Smi::FromInt(12), isolate),
+ Handle<Smi>(Smi::FromInt(13), isolate),
+ Handle<Smi>(Smi::FromInt(14), isolate))
+ .ToHandleChecked();
+ CHECK_EQ(*isolate->factory()->undefined_value(), *result);
+}
+
+TEST(ArgumentsForEach) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+
+ const int kNumParams = 4;
+ CodeStubAssemblerTester m(isolate, kNumParams);
+
+ CodeStubArguments arguments(&m, m.IntPtrConstant(3));
+
+ CodeStubAssemblerTester::Variable sum(&m,
+ MachineType::PointerRepresentation());
+ CodeStubAssemblerTester::VariableList list({&sum}, m.zone());
+
+ sum.Bind(m.IntPtrConstant(0));
+
+ arguments.ForEach(list, [&m, &sum](CodeStubAssembler* assembler, Node* arg) {
+ sum.Bind(assembler->IntPtrAdd(sum.value(), arg));
+ });
+
+ m.Return(sum.value());
+
+ Handle<Code> code = m.GenerateCode();
+ CHECK(!code.is_null());
+
+ FunctionTester ft(code, kNumParams);
+ Handle<Object> result = ft.Call(isolate->factory()->undefined_value(),
+ Handle<Smi>(Smi::FromInt(12), isolate),
+ Handle<Smi>(Smi::FromInt(13), isolate),
+ Handle<Smi>(Smi::FromInt(14), isolate))
+ .ToHandleChecked();
+ CHECK_EQ(Smi::FromInt(12 + 13 + 14), *result);
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « test/cctest/compiler/code-assembler-tester.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698