OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
8 #include "src/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/js-operator.h" | 10 #include "src/compiler/js-operator.h" |
11 #include "src/compiler/linkage.h" | 11 #include "src/compiler/linkage.h" |
12 #include "src/compiler/machine-operator.h" | 12 #include "src/compiler/machine-operator.h" |
13 #include "src/compiler/pipeline.h" | 13 #include "src/compiler/pipeline.h" |
14 #include "src/parser.h" | 14 #include "src/parser.h" |
15 #include "test/cctest/compiler/function-tester.h" | 15 #include "test/cctest/compiler/function-tester.h" |
16 | 16 |
17 #if V8_TURBOFAN_TARGET | 17 #if V8_TURBOFAN_TARGET |
18 | 18 |
19 using namespace v8::internal; | 19 using namespace v8::internal; |
20 using namespace v8::internal::compiler; | 20 using namespace v8::internal::compiler; |
21 | 21 |
22 | 22 |
23 TEST(RunOptimizedMathFloorStub) { | 23 TEST(RunMathFloorStub) { |
24 HandleAndZoneScope scope; | 24 HandleAndZoneScope scope; |
25 Isolate* isolate = scope.main_isolate(); | 25 Isolate* isolate = scope.main_isolate(); |
26 | 26 |
27 // Create code and an accompanying descriptor. | 27 // Create code and an accompanying descriptor. |
28 MathFloorStub stub(isolate, TurboFanIC::CALL_FROM_OPTIMIZED_CODE); | 28 MathFloorStub stub(isolate); |
29 Handle<Code> code = stub.GenerateCode(); | 29 Handle<Code> code = stub.GenerateCode(); |
30 Zone* zone = scope.main_zone(); | 30 Zone* zone = scope.main_zone(); |
| 31 |
31 CompilationInfo info(&stub, isolate, zone); | 32 CompilationInfo info(&stub, isolate, zone); |
32 CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info); | 33 CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info); |
33 Handle<FixedArray> tv = isolate->factory()->NewFixedArray(10); | |
34 | 34 |
35 // Create a function to call the code using the descriptor. | 35 // Create a function to call the code using the descriptor. |
36 Graph graph(zone); | 36 Graph graph(zone); |
37 CommonOperatorBuilder common(zone); | 37 CommonOperatorBuilder common(zone); |
38 JSOperatorBuilder javascript(zone); | 38 JSOperatorBuilder javascript(zone); |
39 MachineOperatorBuilder machine(zone); | 39 MachineOperatorBuilder machine(zone); |
40 JSGraph js(isolate, &graph, &common, &javascript, &machine); | 40 JSGraph js(isolate, &graph, &common, &javascript, &machine); |
41 | 41 |
42 // FunctionTester (ab)uses a 2-argument function | 42 // FunctionTester (ab)uses a 2-argument function |
43 Node* start = graph.NewNode(common.Start(4)); | 43 Node* start = graph.NewNode(common.Start(4)); |
44 // Parameter 0 is the number to round | 44 // Parameter 0 is the number to round |
45 Node* numberParam = graph.NewNode(common.Parameter(1), start); | 45 Node* numberParam = graph.NewNode(common.Parameter(1), start); |
46 Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code); | 46 Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code); |
47 Node* theCode = graph.NewNode(common.HeapConstant(u)); | 47 Node* theCode = graph.NewNode(common.HeapConstant(u)); |
48 Unique<HeapObject> tvu = Unique<HeapObject>::CreateImmovable(tv); | |
49 Node* vector = graph.NewNode(common.HeapConstant(tvu)); | |
50 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); | 48 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); |
51 Node* call = | 49 Node* call = graph.NewNode(common.Call(descriptor), theCode, |
52 graph.NewNode(common.Call(descriptor), theCode, js.UndefinedConstant(), | 50 js.UndefinedConstant(), js.UndefinedConstant(), |
53 js.OneConstant(), vector, js.UndefinedConstant(), | 51 numberParam, dummyContext, start, start); |
54 numberParam, dummyContext, start, start); | |
55 Node* ret = graph.NewNode(common.Return(), call, call, start); | 52 Node* ret = graph.NewNode(common.Return(), call, call, start); |
56 Node* end = graph.NewNode(common.End(1), ret); | 53 Node* end = graph.NewNode(common.End(1), ret); |
57 graph.SetStart(start); | 54 graph.SetStart(start); |
58 graph.SetEnd(end); | 55 graph.SetEnd(end); |
59 FunctionTester ft(&graph); | 56 FunctionTester ft(&graph); |
60 | 57 |
61 Handle<Object> value = ft.Val(1.5); | 58 Handle<Object> value = ft.Val(1.5); |
62 Handle<Object> result = ft.Call(value, value).ToHandleChecked(); | 59 Handle<Object> result = ft.Call(value, value).ToHandleChecked(); |
63 CHECK_EQ(1, Smi::cast(*result)->value()); | 60 CHECK_EQ(1, Smi::cast(*result)->value()); |
64 } | 61 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 FunctionTester ft(&graph); | 138 FunctionTester ft(&graph); |
142 | 139 |
143 // Actuall call through to the stub, verifying its result. | 140 // Actuall call through to the stub, verifying its result. |
144 Handle<String> leftArg = ft.Val("links"); | 141 Handle<String> leftArg = ft.Val("links"); |
145 Handle<String> rightArg = ft.Val("rechts"); | 142 Handle<String> rightArg = ft.Val("rechts"); |
146 Handle<Object> result = ft.Call(leftArg, rightArg).ToHandleChecked(); | 143 Handle<Object> result = ft.Call(leftArg, rightArg).ToHandleChecked(); |
147 CHECK(String::Equals(ft.Val("linksrechts"), Handle<String>::cast(result))); | 144 CHECK(String::Equals(ft.Val("linksrechts"), Handle<String>::cast(result))); |
148 } | 145 } |
149 | 146 |
150 #endif // V8_TURBOFAN_TARGET | 147 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |