| Index: test/cctest/compiler/test-run-stubs.cc
|
| diff --git a/test/cctest/compiler/test-run-stubs.cc b/test/cctest/compiler/test-run-stubs.cc
|
| index 9c7998d7afa12dfeefdfbd15497935c262d4c03f..be45bae8bf3bd0a35bcb1712519396c2805f574a 100644
|
| --- a/test/cctest/compiler/test-run-stubs.cc
|
| +++ b/test/cctest/compiler/test-run-stubs.cc
|
| @@ -20,17 +20,61 @@ using namespace v8::internal;
|
| using namespace v8::internal::compiler;
|
|
|
|
|
| -TEST(RunMathFloorStub) {
|
| +TEST(RunOptimizedMathFloorStub) {
|
| HandleAndZoneScope scope;
|
| Isolate* isolate = scope.main_isolate();
|
|
|
| // Create code and an accompanying descriptor.
|
| - MathFloorStub stub(isolate);
|
| + MathFloorStub stub(isolate, TurboFanIC::CALL_FROM_OPTIMIZED_CODE);
|
| Handle<Code> code = stub.GenerateCode();
|
| Zone* zone = scope.main_zone();
|
| + CompilationInfo info(&stub, isolate, zone);
|
| + CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info);
|
| + Handle<FixedArray> tv = isolate->factory()->NewFixedArray(10);
|
| +
|
| + // Create a function to call the code using the descriptor.
|
| + Graph graph(zone);
|
| + CommonOperatorBuilder common(zone);
|
| + JSOperatorBuilder javascript(zone);
|
| + MachineOperatorBuilder machine(zone);
|
| + JSGraph js(isolate, &graph, &common, &javascript, &machine);
|
| +
|
| + // FunctionTester (ab)uses a 2-argument function
|
| + Node* start = graph.NewNode(common.Start(4));
|
| + // Parameter 0 is the number to round
|
| + Node* numberParam = graph.NewNode(common.Parameter(1), start);
|
| + Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code);
|
| + Node* theCode = graph.NewNode(common.HeapConstant(u));
|
| + Unique<HeapObject> tvu = Unique<HeapObject>::CreateImmovable(tv);
|
| + Node* vector = graph.NewNode(common.HeapConstant(tvu));
|
| + Node* dummyContext = graph.NewNode(common.NumberConstant(0.0));
|
| + Node* call =
|
| + graph.NewNode(common.Call(descriptor), theCode, js.UndefinedConstant(),
|
| + js.OneConstant(), vector, js.UndefinedConstant(),
|
| + numberParam, dummyContext, start, start);
|
| + Node* ret = graph.NewNode(common.Return(), call, call, start);
|
| + Node* end = graph.NewNode(common.End(1), ret);
|
| + graph.SetStart(start);
|
| + graph.SetEnd(end);
|
| + FunctionTester ft(&graph);
|
| +
|
| + Handle<Object> value = ft.Val(1.5);
|
| + Handle<Object> result = ft.Call(value, value).ToHandleChecked();
|
| + CHECK_EQ(1, Smi::cast(*result)->value());
|
| +}
|
| +
|
| +
|
| +TEST(RunUnoptimizedMathFloorStub) {
|
| + HandleAndZoneScope scope;
|
| + Isolate* isolate = scope.main_isolate();
|
|
|
| + // Create code and an accompanying descriptor.
|
| + MathFloorStub stub(isolate, TurboFanIC::CALL_FROM_UNOPTIMIZED_CODE);
|
| + Handle<Code> code = stub.GenerateCode();
|
| + Zone* zone = scope.main_zone();
|
| CompilationInfo info(&stub, isolate, zone);
|
| CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info);
|
| + Handle<FixedArray> tv = isolate->factory()->NewFixedArray(10);
|
|
|
| // Create a function to call the code using the descriptor.
|
| Graph graph(zone);
|
| @@ -45,10 +89,13 @@ TEST(RunMathFloorStub) {
|
| Node* numberParam = graph.NewNode(common.Parameter(1), start);
|
| Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code);
|
| Node* theCode = graph.NewNode(common.HeapConstant(u));
|
| + Unique<HeapObject> tvu = Unique<HeapObject>::CreateImmovable(tv);
|
| + Node* vector = graph.NewNode(common.HeapConstant(tvu));
|
| Node* dummyContext = graph.NewNode(common.NumberConstant(0.0));
|
| - Node* call = graph.NewNode(common.Call(descriptor), theCode,
|
| - js.UndefinedConstant(), js.UndefinedConstant(),
|
| - numberParam, dummyContext, start, start);
|
| + Node* call =
|
| + graph.NewNode(common.Call(descriptor), theCode, js.UndefinedConstant(),
|
| + js.OneConstant(), vector, js.UndefinedConstant(),
|
| + numberParam, dummyContext, start, start);
|
| Node* ret = graph.NewNode(common.Return(), call, call, start);
|
| Node* end = graph.NewNode(common.End(1), ret);
|
| graph.SetStart(start);
|
|
|