| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 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 2-argument function | 78 // FunctionTester (ab)uses a 4-argument function |
| 79 Node* start = graph.NewNode(common.Start(2)); | 79 Node* start = graph.NewNode(common.Start(4)); |
| 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); |
| 84 Node* vectorParam = graph.NewNode(common.Parameter(4), start); |
| 83 Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code); | 85 Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code); |
| 84 Node* theCode = graph.NewNode(common.HeapConstant(u)); | 86 Node* theCode = graph.NewNode(common.HeapConstant(u)); |
| 85 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); | 87 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); |
| 86 Node* call = graph.NewNode(common.Call(descriptor), theCode, receiverParam, | 88 Node* call = |
| 87 nameParam, dummyContext, start, start); | 89 graph.NewNode(common.Call(descriptor), theCode, receiverParam, nameParam, |
| 90 slotParam, vectorParam, dummyContext, start, start); |
| 88 Node* ret = graph.NewNode(common.Return(), call, call, start); | 91 Node* ret = graph.NewNode(common.Return(), call, call, start); |
| 89 Node* end = graph.NewNode(common.End(), ret); | 92 Node* end = graph.NewNode(common.End(), ret); |
| 90 graph.SetStart(start); | 93 graph.SetStart(start); |
| 91 graph.SetEnd(end); | 94 graph.SetEnd(end); |
| 92 FunctionTester ft(&graph); | 95 FunctionTester ft(&graph); |
| 93 | 96 |
| 94 // Actuall call through to the stub, verifying its result. | 97 // Actuall call through to the stub, verifying its result. |
| 95 const char* testString = "Und das Lamm schrie HURZ!"; | 98 const char* testString = "Und das Lamm schrie HURZ!"; |
| 96 Handle<JSReceiver> receiverArg = | 99 Handle<JSReceiver> receiverArg = |
| 97 Object::ToObject(isolate, ft.Val(testString)).ToHandleChecked(); | 100 Object::ToObject(isolate, ft.Val(testString)).ToHandleChecked(); |
| 98 Handle<String> nameArg = ft.Val("length"); | 101 Handle<String> nameArg = ft.Val("length"); |
| 99 Handle<Object> result = ft.Call(receiverArg, nameArg).ToHandleChecked(); | 102 Handle<Object> slot = ft.Val(0.0); |
| 103 Handle<Object> vector = ft.Val(0.0); |
| 104 Handle<Object> result = |
| 105 ft.Call(receiverArg, nameArg, slot, vector).ToHandleChecked(); |
| 100 CHECK_EQ(static_cast<int>(strlen(testString)), Smi::cast(*result)->value()); | 106 CHECK_EQ(static_cast<int>(strlen(testString)), Smi::cast(*result)->value()); |
| 101 } | 107 } |
| 102 | 108 |
| 103 #endif // V8_TURBOFAN_TARGET | 109 #endif // V8_TURBOFAN_TARGET |
| OLD | NEW |