Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1062)

Side by Side Diff: src/compiler/fast-accessor-assembler.cc

Issue 1620293002: Add native callbacks to FastAccessorAssembler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/fast-accessor-assembler.h ('k') | test/cctest/test-api-fast-accessor-builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 CallApiFunctionStub.
8 #include "src/compiler/graph.h" 9 #include "src/compiler/graph.h"
9 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
10 #include "src/compiler/pipeline.h" 11 #include "src/compiler/pipeline.h"
11 #include "src/compiler/raw-machine-assembler.h" 12 #include "src/compiler/raw-machine-assembler.h"
12 #include "src/compiler/schedule.h" 13 #include "src/compiler/schedule.h"
13 #include "src/compiler/verifier.h" 14 #include "src/compiler/verifier.h"
14 #include "src/handles-inl.h" 15 #include "src/handles-inl.h"
15 #include "src/objects.h" // For FAA::GetInternalField impl. 16 #include "src/objects.h" // For FAA::GetInternalField impl.
16 17
17 namespace v8 { 18 namespace v8 {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 LabelId label_id) { 161 LabelId label_id) {
161 CHECK_EQ(kBuilding, state_); 162 CHECK_EQ(kBuilding, state_);
162 RawMachineLabel pass; 163 RawMachineLabel pass;
163 assembler_->Branch( 164 assembler_->Branch(
164 assembler_->IntPtrEqual(FromId(value_id), assembler_->IntPtrConstant(0)), 165 assembler_->IntPtrEqual(FromId(value_id), assembler_->IntPtrConstant(0)),
165 &pass, FromId(label_id)); 166 &pass, FromId(label_id));
166 assembler_->Bind(&pass); 167 assembler_->Bind(&pass);
167 } 168 }
168 169
169 170
171 FastAccessorAssembler::ValueId FastAccessorAssembler::Call(
172 FunctionCallback callback_function, ValueId arg) {
173 CHECK_EQ(kBuilding, state_);
174
175 // Create API function stub.
176 CallApiFunctionStub stub(assembler_->isolate(), true);
177
178 // Wrap the FunctionCallback in an ExternalReference.
179 ApiFunction callback_api_function(FUNCTION_ADDR(callback_function));
180 ExternalReference callback(&callback_api_function,
181 ExternalReference::DIRECT_API_CALL,
182 assembler_->isolate());
183
184 // The stub has 5 parameters, and N (here: N = 1) parameters to pass through
185 // to the callback.
186 // See: ApiFunctionDescriptor::BuildCallInterfaceDescriptorFunctionType
187 Node* args[] = {
188 // Stub arguments:
189 assembler_->Parameter(0), /* receiver (use accessor's) */
190 assembler_->UndefinedConstant(), /* call_data (undefined) */
191 assembler_->NullConstant(), /* holder (null) */
192 assembler_->ExternalConstant(callback), /* API callback function */
193 assembler_->IntPtrConstant(1), /* # arguments */
194
195 // Callback arguments:
196 FromId(arg),
197 FromId(arg)
vogelheim 2016/01/25 17:10:33 I'm not sure if I'm doing this right: As I unders
198 };
199
200 Node* call = assembler_->CallN(
201 Linkage::GetStubCallDescriptor(
202 assembler_->isolate(), zone(), stub.GetCallInterfaceDescriptor(),
203 1 + stub.GetStackParameterCount(), CallDescriptor::kNoFlags),
204 assembler_->HeapConstant(stub.GetCode()), args);
205 return FromRaw(call);
206 }
207
208
170 MaybeHandle<Code> FastAccessorAssembler::Build() { 209 MaybeHandle<Code> FastAccessorAssembler::Build() {
171 CHECK_EQ(kBuilding, state_); 210 CHECK_EQ(kBuilding, state_);
172 211
173 // Cleanup: We no longer need this. 212 // Cleanup: We no longer need this.
174 nodes_.clear(); 213 nodes_.clear();
175 labels_.clear(); 214 labels_.clear();
176 215
177 // Export the schedule and call the compiler. 216 // Export the schedule and call the compiler.
178 Schedule* schedule = assembler_->Export(); 217 Schedule* schedule = assembler_->Export();
179 MaybeHandle<Code> code = Pipeline::GenerateCodeForCodeStub( 218 MaybeHandle<Code> code = Pipeline::GenerateCodeForCodeStub(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 RawMachineLabel* FastAccessorAssembler::FromId(LabelId label) const { 250 RawMachineLabel* FastAccessorAssembler::FromId(LabelId label) const {
212 CHECK_LT(label.label_id, labels_.size()); 251 CHECK_LT(label.label_id, labels_.size());
213 CHECK_NOT_NULL(labels_.at(label.label_id)); 252 CHECK_NOT_NULL(labels_.at(label.label_id));
214 return labels_.at(label.label_id); 253 return labels_.at(label.label_id);
215 } 254 }
216 255
217 256
218 } // namespace compiler 257 } // namespace compiler
219 } // namespace internal 258 } // namespace internal
220 } // namespace v8 259 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/fast-accessor-assembler.h ('k') | test/cctest/test-api-fast-accessor-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698