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

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

Issue 1705073005: CodeStubAssembler can generate code for builtins (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 | « test/cctest/compiler/function-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/compiler/test-code-stub-assembler.cc
diff --git a/test/cctest/compiler/test-code-stub-assembler.cc b/test/cctest/compiler/test-code-stub-assembler.cc
index 0306561020abe41e5342f9cc209062f67bd9d208..64c8a99dddbb0b40cb86c2eb615f2858e0eea021 100644
--- a/test/cctest/compiler/test-code-stub-assembler.cc
+++ b/test/cctest/compiler/test-code-stub-assembler.cc
@@ -13,12 +13,19 @@ namespace compiler {
class CodeStubAssemblerTester : public CodeStubAssembler {
public:
+ // Test generating code for a stub.
CodeStubAssemblerTester(Isolate* isolate,
const CallInterfaceDescriptor& descriptor)
: CodeStubAssembler(isolate, isolate->runtime_zone(), descriptor,
Code::ComputeFlags(Code::STUB), "test"),
scope_(isolate) {}
+ // Test generating code for a JS function (e.g. builtins).
+ CodeStubAssemblerTester(Isolate* isolate, int parameter_count)
+ : CodeStubAssembler(isolate, isolate->runtime_zone(), parameter_count,
+ Code::ComputeFlags(Code::FUNCTION), "test"),
+ scope_(isolate) {}
+
private:
HandleScope scope_;
LocalContext context_;
@@ -247,6 +254,20 @@ TEST(FixedArrayAccessSmiIndex) {
CHECK_EQ(733, Handle<Smi>::cast(result.ToHandleChecked())->value());
}
+TEST(JSFunction) {
+ const int kNumParams = 3; // Receiver, left, right.
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ CodeStubAssemblerTester m(isolate, kNumParams);
+ m.Return(m.SmiTag(
+ m.Int32Add(m.SmiUntag(m.Parameter(1)), m.SmiUntag(m.Parameter(2)))));
+ Handle<Code> code = m.GenerateCode();
+ FunctionTester ft(kNumParams - 1, code); // Implicit undefined receiver.
Jarin 2016/02/18 09:04:38 Apparently, there is a bug in FunctionTester::Buil
binji 2016/02/18 19:35:16 Acknowledged.
+ Handle<Object> left = Handle<Smi>(Smi::FromInt(23), isolate);
+ Handle<Object> right = Handle<Smi>(Smi::FromInt(34), isolate);
+ MaybeHandle<Object> result = ft.Call(left, right);
+ CHECK_EQ(57, Handle<Smi>::cast(result.ToHandleChecked())->value());
+}
Jarin 2016/02/18 12:32:15 Actually, FunctionTester as a whole seems to be a
binji 2016/02/18 19:35:17 Done.
+
} // namespace compiler
} // namespace internal
} // namespace v8
« no previous file with comments | « test/cctest/compiler/function-tester.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698