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(RunMathFloorStub) { | 23 TEST(RunOptimizedMathFloorStub) { |
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); | 28 MathFloorStub stub(isolate, TurboFanIC::CALL_FROM_OPTIMIZED_CODE); |
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 | |
32 CompilationInfo info(&stub, isolate, zone); | 31 CompilationInfo info(&stub, isolate, zone); |
33 CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info); | 32 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)); |
48 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); | 50 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); |
49 Node* call = graph.NewNode(common.Call(descriptor), theCode, | 51 Node* call = |
50 js.UndefinedConstant(), js.UndefinedConstant(), | 52 graph.NewNode(common.Call(descriptor), theCode, js.UndefinedConstant(), |
51 numberParam, dummyContext, start, start); | 53 js.OneConstant(), vector, js.UndefinedConstant(), |
| 54 numberParam, dummyContext, start, start); |
52 Node* ret = graph.NewNode(common.Return(), call, call, start); | 55 Node* ret = graph.NewNode(common.Return(), call, call, start); |
53 Node* end = graph.NewNode(common.End(1), ret); | 56 Node* end = graph.NewNode(common.End(1), ret); |
54 graph.SetStart(start); | 57 graph.SetStart(start); |
55 graph.SetEnd(end); | 58 graph.SetEnd(end); |
56 FunctionTester ft(&graph); | 59 FunctionTester ft(&graph); |
57 | 60 |
58 Handle<Object> value = ft.Val(1.5); | 61 Handle<Object> value = ft.Val(1.5); |
59 Handle<Object> result = ft.Call(value, value).ToHandleChecked(); | 62 Handle<Object> result = ft.Call(value, value).ToHandleChecked(); |
60 CHECK_EQ(1, Smi::cast(*result)->value()); | 63 CHECK_EQ(1, Smi::cast(*result)->value()); |
61 } | 64 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 FunctionTester ft(&graph); | 141 FunctionTester ft(&graph); |
139 | 142 |
140 // Actuall call through to the stub, verifying its result. | 143 // Actuall call through to the stub, verifying its result. |
141 Handle<String> leftArg = ft.Val("links"); | 144 Handle<String> leftArg = ft.Val("links"); |
142 Handle<String> rightArg = ft.Val("rechts"); | 145 Handle<String> rightArg = ft.Val("rechts"); |
143 Handle<Object> result = ft.Call(leftArg, rightArg).ToHandleChecked(); | 146 Handle<Object> result = ft.Call(leftArg, rightArg).ToHandleChecked(); |
144 CHECK(String::Equals(ft.Val("linksrechts"), Handle<String>::cast(result))); | 147 CHECK(String::Equals(ft.Val("linksrechts"), Handle<String>::cast(result))); |
145 } | 148 } |
146 | 149 |
147 #endif // V8_TURBOFAN_TARGET | 150 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |