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

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: clean-up parameter handling Created 4 years, 10 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 kJSParam (here: 1) parameters to pass
185 // through to the callback.
186 // See: ApiFunctionDescriptor::BuildCallInterfaceDescriptorFunctionType
187 static const int kStackParam = 1;
188 Node* args[] = {
189 // Stub/register parameters:
190 assembler_->Parameter(0), /* receiver (use accessor's) */
191 assembler_->UndefinedConstant(), /* call_data (undefined) */
192 assembler_->NullConstant(), /* holder (null) */
193 assembler_->ExternalConstant(callback), /* API callback function */
194 assembler_->IntPtrConstant(kStackParam), /* # JS arguments */
195
196 // kStackParam stack parameter(s):
197 FromId(arg),
198
199 // Context parameter. (See Linkage::GetStubCallDescriptor.)
200 assembler_->UndefinedConstant()};
201 CHECK_EQ(5 + kStackParam + 1, arraysize(args));
202
203 Node* call = assembler_->CallN(
204 Linkage::GetStubCallDescriptor(
205 assembler_->isolate(), zone(), stub.GetCallInterfaceDescriptor(),
206 kStackParam + stub.GetStackParameterCount(),
207 CallDescriptor::kNoFlags),
208 assembler_->HeapConstant(stub.GetCode()), args);
209 return FromRaw(call);
210 }
211
212
170 MaybeHandle<Code> FastAccessorAssembler::Build() { 213 MaybeHandle<Code> FastAccessorAssembler::Build() {
171 CHECK_EQ(kBuilding, state_); 214 CHECK_EQ(kBuilding, state_);
172 215
173 // Cleanup: We no longer need this. 216 // Cleanup: We no longer need this.
174 nodes_.clear(); 217 nodes_.clear();
175 labels_.clear(); 218 labels_.clear();
176 219
177 // Export the schedule and call the compiler. 220 // Export the schedule and call the compiler.
178 Schedule* schedule = assembler_->Export(); 221 Schedule* schedule = assembler_->Export();
179 MaybeHandle<Code> code = Pipeline::GenerateCodeForCodeStub( 222 MaybeHandle<Code> code = Pipeline::GenerateCodeForCodeStub(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 RawMachineLabel* FastAccessorAssembler::FromId(LabelId label) const { 254 RawMachineLabel* FastAccessorAssembler::FromId(LabelId label) const {
212 CHECK_LT(label.label_id, labels_.size()); 255 CHECK_LT(label.label_id, labels_.size());
213 CHECK_NOT_NULL(labels_.at(label.label_id)); 256 CHECK_NOT_NULL(labels_.at(label.label_id));
214 return labels_.at(label.label_id); 257 return labels_.at(label.label_id);
215 } 258 }
216 259
217 260
218 } // namespace compiler 261 } // namespace compiler
219 } // namespace internal 262 } // namespace internal
220 } // namespace v8 263 } // 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