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

Unified Diff: test/cctest/compiler/test-run-machops.cc

Issue 1377423002: [turbofan] Fix calls to computed code objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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/codegen-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-run-machops.cc
diff --git a/test/cctest/compiler/test-run-machops.cc b/test/cctest/compiler/test-run-machops.cc
index 078b8c25cd9c1195e74baf1ea4dcf661adc87e63..38b044b727a53b039fcc4cd27afe62c211909b83 100644
--- a/test/cctest/compiler/test-run-machops.cc
+++ b/test/cctest/compiler/test-run-machops.cc
@@ -5387,3 +5387,52 @@ TEST(RunBitcastInt32ToFloat32) {
CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output));
}
}
+
+
+TEST(RunComputedCodeObject) {
+ RawMachineAssemblerTester<int32_t> a;
+ a.Return(a.Int32Constant(33));
+ CHECK_EQ(33, a.Call());
+
+ RawMachineAssemblerTester<int32_t> b;
+ b.Return(b.Int32Constant(44));
+ CHECK_EQ(44, b.Call());
+
+ RawMachineAssemblerTester<int32_t> r(kMachInt32);
+ RawMachineAssembler::Label tlabel;
+ RawMachineAssembler::Label flabel;
+ RawMachineAssembler::Label merge;
+ r.Branch(r.Parameter(0), &tlabel, &flabel);
+ r.Bind(&tlabel);
+ Node* fa = r.HeapConstant(a.GetCode());
+ r.Goto(&merge);
+ r.Bind(&flabel);
+ Node* fb = r.HeapConstant(b.GetCode());
+ r.Goto(&merge);
+ r.Bind(&merge);
+ Node* phi = r.Phi(kMachInt32, fa, fb);
+
+ // TODO(titzer): all this descriptor hackery is just to call the above
+ // functions as code objects instead of direct addresses.
+ CSignature0<int32_t> sig;
+ CallDescriptor* c = Linkage::GetSimplifiedCDescriptor(r.zone(), &sig);
+ LinkageLocation ret[] = {c->GetReturnLocation(0)};
+ Signature<LinkageLocation> loc(1, 0, ret);
+ CallDescriptor* desc = new (r.zone()) CallDescriptor( // --
+ CallDescriptor::kCallCodeObject, // kind
+ kMachAnyTagged, // target_type
+ c->GetInputLocation(0), // target_loc
+ &sig, // machine_sig
+ &loc, // location_sig
+ 0, // stack count
+ Operator::kNoProperties, // properties
+ c->CalleeSavedRegisters(), // callee saved
+ c->CalleeSavedFPRegisters(), // callee saved FP
+ CallDescriptor::kNoFlags, // flags
+ "c-call-as-code");
+ Node* call = r.AddNode(r.common()->Call(desc), phi);
+ r.Return(call);
+
+ CHECK_EQ(33, r.Call(1));
+ CHECK_EQ(44, r.Call(0));
+}
« no previous file with comments | « test/cctest/compiler/codegen-tester.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698