| 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/fast-accessor-assembler.h" | 5 #include "src/fast-accessor-assembler.h" |
| 6 | 6 |
| 7 #include "src/base/logging.h" | 7 #include "src/base/logging.h" |
| 8 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
| 9 #include "src/code-stubs.h" // For CallApiCallbackStub. | 9 #include "src/code-stubs.h" // For CallApiCallbackStub. |
| 10 #include "src/handles-inl.h" | 10 #include "src/handles-inl.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 FastAccessorAssembler::ValueId FastAccessorAssembler::Call( | 172 FastAccessorAssembler::ValueId FastAccessorAssembler::Call( |
| 173 FunctionCallback callback_function, ValueId arg) { | 173 FunctionCallback callback_function, ValueId arg) { |
| 174 CHECK_EQ(kBuilding, state_); | 174 CHECK_EQ(kBuilding, state_); |
| 175 | 175 |
| 176 // Wrap the FunctionCallback in an ExternalReference. | 176 // Wrap the FunctionCallback in an ExternalReference. |
| 177 ApiFunction callback_api_function(FUNCTION_ADDR(callback_function)); | 177 ApiFunction callback_api_function(FUNCTION_ADDR(callback_function)); |
| 178 ExternalReference callback(&callback_api_function, | 178 ExternalReference callback(&callback_api_function, |
| 179 ExternalReference::DIRECT_API_CALL, isolate()); | 179 ExternalReference::DIRECT_API_CALL, isolate()); |
| 180 | 180 |
| 181 // Create & call API callback via stub. | 181 // Create & call API callback via stub. |
| 182 CallApiCallbackStub stub(isolate(), 1, true, true); | 182 const int kJSParameterCount = 1; |
| 183 DCHECK_EQ(5, stub.GetCallInterfaceDescriptor().GetParameterCount()); | 183 CallApiCallbackStub stub(isolate(), kJSParameterCount, true, true); |
| 184 DCHECK_EQ(1, stub.GetCallInterfaceDescriptor().GetStackParameterCount()); | 184 CallInterfaceDescriptor descriptor = stub.GetCallInterfaceDescriptor(); |
| 185 DCHECK_EQ(4, descriptor.GetParameterCount()); |
| 186 DCHECK_EQ(0, descriptor.GetStackParameterCount()); |
| 185 // TODO(vogelheim): There is currently no clean way to retrieve the context | 187 // TODO(vogelheim): There is currently no clean way to retrieve the context |
| 186 // parameter for a stub and the implementation details are hidden in | 188 // parameter for a stub and the implementation details are hidden in |
| 187 // compiler/*. The context_paramter is computed as: | 189 // compiler/*. The context_paramter is computed as: |
| 188 // Linkage::GetJSCallContextParamIndex(descriptor->JSParameterCount()) | 190 // Linkage::GetJSCallContextParamIndex(descriptor->JSParameterCount()) |
| 189 const int context_parameter = 3; | 191 const int kContextParameter = 3; |
| 190 Node* call = assembler_->CallStub( | 192 Node* context = assembler_->Parameter(kContextParameter); |
| 191 stub.GetCallInterfaceDescriptor(), | 193 Node* target = assembler_->HeapConstant(stub.GetCode()); |
| 192 assembler_->HeapConstant(stub.GetCode()), | |
| 193 assembler_->Parameter(context_parameter), | |
| 194 | 194 |
| 195 // Stub/register parameters: | 195 int param_count = descriptor.GetParameterCount(); |
| 196 assembler_->UndefinedConstant(), /* callee (there's no JSFunction) */ | 196 Node** args = zone()->NewArray<Node*>(param_count + 1 + kJSParameterCount); |
| 197 assembler_->UndefinedConstant(), /* call_data (undefined) */ | 197 // Stub/register parameters: |
| 198 assembler_->Parameter(0), /* receiver (same as holder in this case) */ | 198 args[0] = assembler_->UndefinedConstant(); // callee (there's no JSFunction) |
| 199 assembler_->ExternalConstant(callback), /* API callback function */ | 199 args[1] = assembler_->UndefinedConstant(); // call_data (undefined) |
| 200 args[2] = assembler_->Parameter(0); // receiver (same as holder in this case) |
| 201 args[3] = assembler_->ExternalConstant(callback); // API callback function |
| 200 | 202 |
| 201 // JS arguments, on stack: | 203 // JS arguments, on stack: |
| 202 FromId(arg)); | 204 args[4] = FromId(arg); |
| 205 |
| 206 // Context. |
| 207 args[5] = context; |
| 208 |
| 209 Node* call = |
| 210 assembler_->CallStubN(descriptor, kJSParameterCount, target, args); |
| 203 | 211 |
| 204 return FromRaw(call); | 212 return FromRaw(call); |
| 205 } | 213 } |
| 206 | 214 |
| 207 void FastAccessorAssembler::CheckIsJSObjectOrJump(ValueId value_id, | 215 void FastAccessorAssembler::CheckIsJSObjectOrJump(ValueId value_id, |
| 208 LabelId label_id) { | 216 LabelId label_id) { |
| 209 CHECK_EQ(kBuilding, state_); | 217 CHECK_EQ(kBuilding, state_); |
| 210 | 218 |
| 211 // Determine the 'value' object's instance type. | 219 // Determine the 'value' object's instance type. |
| 212 Node* object_map = assembler_->LoadObjectField( | 220 Node* object_map = assembler_->LoadObjectField( |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 void FastAccessorAssembler::Clear() { | 282 void FastAccessorAssembler::Clear() { |
| 275 for (auto label : labels_) { | 283 for (auto label : labels_) { |
| 276 delete label; | 284 delete label; |
| 277 } | 285 } |
| 278 nodes_.clear(); | 286 nodes_.clear(); |
| 279 labels_.clear(); | 287 labels_.clear(); |
| 280 } | 288 } |
| 281 | 289 |
| 282 } // namespace internal | 290 } // namespace internal |
| 283 } // namespace v8 | 291 } // namespace v8 |
| OLD | NEW |