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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info); | 33 CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info); |
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(2)); | 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 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); | 48 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); |
49 Node* call = graph.NewNode(common.Call(descriptor), theCode, | 49 Node* call = graph.NewNode(common.Call(descriptor), theCode, |
50 js.UndefinedConstant(), js.UndefinedConstant(), | 50 js.UndefinedConstant(), js.UndefinedConstant(), |
51 numberParam, dummyContext, start, start); | 51 numberParam, dummyContext, start, start); |
52 Node* ret = graph.NewNode(common.Return(), call, call, start); | 52 Node* ret = graph.NewNode(common.Return(), call, call, start); |
53 Node* end = graph.NewNode(common.End(1), ret); | 53 Node* end = graph.NewNode(common.End(1), ret); |
(...skipping 15 matching lines...) Expand all Loading... |
69 // Create code and an accompanying descriptor. | 69 // Create code and an accompanying descriptor. |
70 StringLengthTFStub stub(isolate); | 70 StringLengthTFStub stub(isolate); |
71 Handle<Code> code = stub.GenerateCode(); | 71 Handle<Code> code = stub.GenerateCode(); |
72 CompilationInfo info(&stub, isolate, zone); | 72 CompilationInfo info(&stub, isolate, zone); |
73 CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info); | 73 CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info); |
74 | 74 |
75 // Create a function to call the code using the descriptor. | 75 // Create a function to call the code using the descriptor. |
76 Graph graph(zone); | 76 Graph graph(zone); |
77 CommonOperatorBuilder common(zone); | 77 CommonOperatorBuilder common(zone); |
78 // FunctionTester (ab)uses a 4-argument function | 78 // FunctionTester (ab)uses a 4-argument function |
79 Node* start = graph.NewNode(common.Start(4)); | 79 Node* start = graph.NewNode(common.Start(6)); |
80 // Parameter 0 is the receiver | 80 // Parameter 0 is the receiver |
81 Node* receiverParam = graph.NewNode(common.Parameter(1), start); | 81 Node* receiverParam = graph.NewNode(common.Parameter(1), start); |
82 Node* nameParam = graph.NewNode(common.Parameter(2), start); | 82 Node* nameParam = graph.NewNode(common.Parameter(2), start); |
83 Node* slotParam = graph.NewNode(common.Parameter(3), start); | 83 Node* slotParam = graph.NewNode(common.Parameter(3), start); |
84 Node* vectorParam = graph.NewNode(common.Parameter(4), start); | 84 Node* vectorParam = graph.NewNode(common.Parameter(4), start); |
85 Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code); | 85 Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code); |
86 Node* theCode = graph.NewNode(common.HeapConstant(u)); | 86 Node* theCode = graph.NewNode(common.HeapConstant(u)); |
87 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); | 87 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); |
88 Node* call = | 88 Node* call = |
89 graph.NewNode(common.Call(descriptor), theCode, receiverParam, nameParam, | 89 graph.NewNode(common.Call(descriptor), theCode, receiverParam, nameParam, |
(...skipping 25 matching lines...) Expand all Loading... |
115 // Create code and an accompanying descriptor. | 115 // Create code and an accompanying descriptor. |
116 StringAddTFStub stub(isolate, STRING_ADD_CHECK_BOTH, NOT_TENURED); | 116 StringAddTFStub stub(isolate, STRING_ADD_CHECK_BOTH, NOT_TENURED); |
117 Handle<Code> code = stub.GenerateCode(); | 117 Handle<Code> code = stub.GenerateCode(); |
118 CompilationInfo info(&stub, isolate, zone); | 118 CompilationInfo info(&stub, isolate, zone); |
119 CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info); | 119 CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info); |
120 | 120 |
121 // Create a function to call the code using the descriptor. | 121 // Create a function to call the code using the descriptor. |
122 Graph graph(zone); | 122 Graph graph(zone); |
123 CommonOperatorBuilder common(zone); | 123 CommonOperatorBuilder common(zone); |
124 // FunctionTester (ab)uses a 2-argument function | 124 // FunctionTester (ab)uses a 2-argument function |
125 Node* start = graph.NewNode(common.Start(2)); | 125 Node* start = graph.NewNode(common.Start(4)); |
126 // Parameter 0 is the receiver | 126 // Parameter 0 is the receiver |
127 Node* leftParam = graph.NewNode(common.Parameter(1), start); | 127 Node* leftParam = graph.NewNode(common.Parameter(1), start); |
128 Node* rightParam = graph.NewNode(common.Parameter(2), start); | 128 Node* rightParam = graph.NewNode(common.Parameter(2), start); |
129 Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code); | 129 Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code); |
130 Node* theCode = graph.NewNode(common.HeapConstant(u)); | 130 Node* theCode = graph.NewNode(common.HeapConstant(u)); |
131 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); | 131 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); |
132 Node* call = graph.NewNode(common.Call(descriptor), theCode, leftParam, | 132 Node* call = graph.NewNode(common.Call(descriptor), theCode, leftParam, |
133 rightParam, dummyContext, start, start); | 133 rightParam, dummyContext, start, start); |
134 Node* ret = graph.NewNode(common.Return(), call, call, start); | 134 Node* ret = graph.NewNode(common.Return(), call, call, start); |
135 Node* end = graph.NewNode(common.End(1), ret); | 135 Node* end = graph.NewNode(common.End(1), ret); |
136 graph.SetStart(start); | 136 graph.SetStart(start); |
137 graph.SetEnd(end); | 137 graph.SetEnd(end); |
138 FunctionTester ft(&graph); | 138 FunctionTester ft(&graph); |
139 | 139 |
140 // Actuall call through to the stub, verifying its result. | 140 // Actuall call through to the stub, verifying its result. |
141 Handle<String> leftArg = ft.Val("links"); | 141 Handle<String> leftArg = ft.Val("links"); |
142 Handle<String> rightArg = ft.Val("rechts"); | 142 Handle<String> rightArg = ft.Val("rechts"); |
143 Handle<Object> result = ft.Call(leftArg, rightArg).ToHandleChecked(); | 143 Handle<Object> result = ft.Call(leftArg, rightArg).ToHandleChecked(); |
144 CHECK(String::Equals(ft.Val("linksrechts"), Handle<String>::cast(result))); | 144 CHECK(String::Equals(ft.Val("linksrechts"), Handle<String>::cast(result))); |
145 } | 145 } |
146 | 146 |
147 #endif // V8_TURBOFAN_TARGET | 147 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |