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/compiler/fast-accessor-assembler.h" | 5 #include "src/compiler/fast-accessor-assembler.h" |
6 | 6 |
7 #include "src/base/logging.h" | 7 #include "src/base/logging.h" |
8 #include "src/code-stubs.h" // For CallApiCallbackStub. | 8 #include "src/code-stubs.h" // For CallApiFunctionStub. |
9 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
11 #include "src/compiler/pipeline.h" | 11 #include "src/compiler/pipeline.h" |
12 #include "src/compiler/raw-machine-assembler.h" | 12 #include "src/compiler/raw-machine-assembler.h" |
13 #include "src/compiler/schedule.h" | 13 #include "src/compiler/schedule.h" |
14 #include "src/compiler/verifier.h" | 14 #include "src/compiler/verifier.h" |
15 #include "src/handles-inl.h" | 15 #include "src/handles-inl.h" |
16 #include "src/objects.h" // For FAA::GetInternalField impl. | 16 #include "src/objects.h" // For FAA::GetInternalField impl. |
17 | 17 |
18 namespace v8 { | 18 namespace v8 { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 assembler_->IntPtrEqual(FromId(value_id), assembler_->IntPtrConstant(0)), | 165 assembler_->IntPtrEqual(FromId(value_id), assembler_->IntPtrConstant(0)), |
166 &pass, FromId(label_id)); | 166 &pass, FromId(label_id)); |
167 assembler_->Bind(&pass); | 167 assembler_->Bind(&pass); |
168 } | 168 } |
169 | 169 |
170 FastAccessorAssembler::ValueId FastAccessorAssembler::Call( | 170 FastAccessorAssembler::ValueId FastAccessorAssembler::Call( |
171 FunctionCallback callback_function, ValueId arg) { | 171 FunctionCallback callback_function, ValueId arg) { |
172 CHECK_EQ(kBuilding, state_); | 172 CHECK_EQ(kBuilding, state_); |
173 | 173 |
174 // Create API function stub. | 174 // Create API function stub. |
175 CallApiCallbackStub stub(assembler_->isolate(), 1, true); | 175 CallApiFunctionStub stub(assembler_->isolate(), true); |
176 DCHECK_EQ(1, stub.GetCallInterfaceDescriptor().GetStackParameterCount()); | |
177 | 176 |
178 // Wrap the FunctionCallback in an ExternalReference. | 177 // Wrap the FunctionCallback in an ExternalReference. |
179 ApiFunction callback_api_function(FUNCTION_ADDR(callback_function)); | 178 ApiFunction callback_api_function(FUNCTION_ADDR(callback_function)); |
180 ExternalReference callback(&callback_api_function, | 179 ExternalReference callback(&callback_api_function, |
181 ExternalReference::DIRECT_API_CALL, | 180 ExternalReference::DIRECT_API_CALL, |
182 assembler_->isolate()); | 181 assembler_->isolate()); |
183 | 182 |
184 // The stub has 6 parameters. | 183 // The stub has 5 parameters, and kJSParam (here: 1) parameters to pass |
185 // See: ApiCallbackDescriptorBase::BuildCallInterfaceDescriptorFunctionType | 184 // through to the callback. |
| 185 // See: ApiFunctionDescriptor::BuildCallInterfaceDescriptorFunctionType |
| 186 static const int kStackParam = 1; |
186 Node* args[] = { | 187 Node* args[] = { |
187 // Stub/register parameters: | 188 // Stub/register parameters: |
188 assembler_->Parameter(0), /* receiver (use accessor's) */ | 189 assembler_->Parameter(0), /* receiver (use accessor's) */ |
189 assembler_->UndefinedConstant(), /* call_data (undefined) */ | 190 assembler_->UndefinedConstant(), /* call_data (undefined) */ |
190 assembler_->NullConstant(), /* holder (null) */ | 191 assembler_->NullConstant(), /* holder (null) */ |
191 assembler_->ExternalConstant(callback), /* API callback function */ | 192 assembler_->ExternalConstant(callback), /* API callback function */ |
| 193 assembler_->IntPtrConstant(kStackParam), /* # JS arguments */ |
192 | 194 |
193 // JS arguments, on stack: | 195 // kStackParam stack parameter(s): |
194 FromId(arg), | 196 FromId(arg), |
195 | 197 |
196 // Context parameter. (See Linkage::GetStubCallDescriptor.) | 198 // Context parameter. (See Linkage::GetStubCallDescriptor.) |
197 assembler_->UndefinedConstant()}; | 199 assembler_->UndefinedConstant()}; |
198 DCHECK_EQ(arraysize(args), | 200 CHECK_EQ(5 + kStackParam + 1, arraysize(args)); |
199 1 + stub.GetCallInterfaceDescriptor().GetParameterCount()); | |
200 | 201 |
201 Node* call = assembler_->CallN( | 202 Node* call = assembler_->CallN( |
202 Linkage::GetStubCallDescriptor( | 203 Linkage::GetStubCallDescriptor( |
203 assembler_->isolate(), zone(), stub.GetCallInterfaceDescriptor(), | 204 assembler_->isolate(), zone(), stub.GetCallInterfaceDescriptor(), |
204 stub.GetStackParameterCount(), CallDescriptor::kNoFlags), | 205 kStackParam + stub.GetStackParameterCount(), |
| 206 CallDescriptor::kNoFlags), |
205 assembler_->HeapConstant(stub.GetCode()), args); | 207 assembler_->HeapConstant(stub.GetCode()), args); |
206 return FromRaw(call); | 208 return FromRaw(call); |
207 } | 209 } |
208 | 210 |
209 MaybeHandle<Code> FastAccessorAssembler::Build() { | 211 MaybeHandle<Code> FastAccessorAssembler::Build() { |
210 CHECK_EQ(kBuilding, state_); | 212 CHECK_EQ(kBuilding, state_); |
211 | 213 |
212 // Cleanup: We no longer need this. | 214 // Cleanup: We no longer need this. |
213 nodes_.clear(); | 215 nodes_.clear(); |
214 labels_.clear(); | 216 labels_.clear(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 RawMachineLabel* FastAccessorAssembler::FromId(LabelId label) const { | 253 RawMachineLabel* FastAccessorAssembler::FromId(LabelId label) const { |
252 CHECK_LT(label.label_id, labels_.size()); | 254 CHECK_LT(label.label_id, labels_.size()); |
253 CHECK_NOT_NULL(labels_.at(label.label_id)); | 255 CHECK_NOT_NULL(labels_.at(label.label_id)); |
254 return labels_.at(label.label_id); | 256 return labels_.at(label.label_id); |
255 } | 257 } |
256 | 258 |
257 | 259 |
258 } // namespace compiler | 260 } // namespace compiler |
259 } // namespace internal | 261 } // namespace internal |
260 } // namespace v8 | 262 } // namespace v8 |
OLD | NEW |