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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 Handle<JSReceiver> receiverArg = | 99 Handle<JSReceiver> receiverArg = |
100 Object::ToObject(isolate, ft.Val(testString)).ToHandleChecked(); | 100 Object::ToObject(isolate, ft.Val(testString)).ToHandleChecked(); |
101 Handle<String> nameArg = ft.Val("length"); | 101 Handle<String> nameArg = ft.Val("length"); |
102 Handle<Object> slot = ft.Val(0.0); | 102 Handle<Object> slot = ft.Val(0.0); |
103 Handle<Object> vector = ft.Val(0.0); | 103 Handle<Object> vector = ft.Val(0.0); |
104 Handle<Object> result = | 104 Handle<Object> result = |
105 ft.Call(receiverArg, nameArg, slot, vector).ToHandleChecked(); | 105 ft.Call(receiverArg, nameArg, slot, vector).ToHandleChecked(); |
106 CHECK_EQ(static_cast<int>(strlen(testString)), Smi::cast(*result)->value()); | 106 CHECK_EQ(static_cast<int>(strlen(testString)), Smi::cast(*result)->value()); |
107 } | 107 } |
108 | 108 |
| 109 |
| 110 TEST(RunStringAddTFStub) { |
| 111 HandleAndZoneScope scope; |
| 112 Isolate* isolate = scope.main_isolate(); |
| 113 Zone* zone = scope.main_zone(); |
| 114 |
| 115 // Create code and an accompanying descriptor. |
| 116 StringAddTFStub stub(isolate, STRING_ADD_CHECK_BOTH, NOT_TENURED); |
| 117 Handle<Code> code = stub.GenerateCode(); |
| 118 CompilationInfo info(&stub, isolate, zone); |
| 119 CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info); |
| 120 |
| 121 // Create a function to call the code using the descriptor. |
| 122 Graph graph(zone); |
| 123 CommonOperatorBuilder common(zone); |
| 124 // FunctionTester (ab)uses a 2-argument function |
| 125 Node* start = graph.NewNode(common.Start(2)); |
| 126 // Parameter 0 is the receiver |
| 127 Node* leftParam = graph.NewNode(common.Parameter(1), start); |
| 128 Node* rightParam = graph.NewNode(common.Parameter(2), start); |
| 129 Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code); |
| 130 Node* theCode = graph.NewNode(common.HeapConstant(u)); |
| 131 Node* dummyContext = graph.NewNode(common.NumberConstant(0.0)); |
| 132 Node* call = graph.NewNode(common.Call(descriptor), theCode, leftParam, |
| 133 rightParam, dummyContext, start, start); |
| 134 Node* ret = graph.NewNode(common.Return(), call, call, start); |
| 135 Node* end = graph.NewNode(common.End(), ret); |
| 136 graph.SetStart(start); |
| 137 graph.SetEnd(end); |
| 138 FunctionTester ft(&graph); |
| 139 |
| 140 // Actuall call through to the stub, verifying its result. |
| 141 Handle<String> leftArg = ft.Val("links"); |
| 142 Handle<String> rightArg = ft.Val("rechts"); |
| 143 Handle<Object> result = ft.Call(leftArg, rightArg).ToHandleChecked(); |
| 144 CHECK(String::Equals(ft.Val("linksrechts"), Handle<String>::cast(result))); |
| 145 } |
| 146 |
109 #endif // V8_TURBOFAN_TARGET | 147 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |