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

Side by Side Diff: src/compiler/linkage-impl.h

Issue 1205023002: [turbofan] Add basic support for calling to (a subset of) C functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix argument slots. Created 5 years, 6 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #ifndef V8_COMPILER_LINKAGE_IMPL_H_ 5 #ifndef V8_COMPILER_LINKAGE_IMPL_H_
6 #define V8_COMPILER_LINKAGE_IMPL_H_ 6 #define V8_COMPILER_LINKAGE_IMPL_H_
7 7
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/compiler/osr.h" 9 #include "src/compiler/osr.h"
10 10
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 static CallDescriptor* GetSimplifiedCDescriptor( 198 static CallDescriptor* GetSimplifiedCDescriptor(
199 Zone* zone, const MachineSignature* msig) { 199 Zone* zone, const MachineSignature* msig) {
200 LocationSignature::Builder locations(zone, msig->return_count(), 200 LocationSignature::Builder locations(zone, msig->return_count(),
201 msig->parameter_count()); 201 msig->parameter_count());
202 // Add return location(s). 202 // Add return location(s).
203 AddReturnLocations(&locations); 203 AddReturnLocations(&locations);
204 204
205 // Add register and/or stack parameter(s). 205 // Add register and/or stack parameter(s).
206 const int parameter_count = static_cast<int>(msig->parameter_count()); 206 const int parameter_count = static_cast<int>(msig->parameter_count());
207 int stack_offset = LinkageTraits::CStackBackingStoreLength();
207 for (int i = 0; i < parameter_count; i++) { 208 for (int i = 0; i < parameter_count; i++) {
208 if (i < LinkageTraits::CRegisterParametersLength()) { 209 if (i < LinkageTraits::CRegisterParametersLength()) {
209 locations.AddParam(regloc(LinkageTraits::CRegisterParameter(i))); 210 locations.AddParam(regloc(LinkageTraits::CRegisterParameter(i)));
210 } else { 211 } else {
211 locations.AddParam(stackloc(-1 - i)); 212 locations.AddParam(stackloc(-1 - stack_offset));
213 stack_offset++;
212 } 214 }
213 } 215 }
214 216
215 // The target for C calls is always an address (i.e. machine pointer). 217 // The target for C calls is always an address (i.e. machine pointer).
216 MachineType target_type = kMachPtr; 218 MachineType target_type = kMachPtr;
217 LinkageLocation target_loc = LinkageLocation::AnyRegister(); 219 LinkageLocation target_loc = LinkageLocation::AnyRegister();
218 return new (zone) CallDescriptor( // -- 220 return new (zone) CallDescriptor( // --
219 CallDescriptor::kCallAddress, // kind 221 CallDescriptor::kCallAddress, // kind
220 target_type, // target MachineType 222 target_type, // target MachineType
221 target_loc, // target location 223 target_loc, // target location
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 int parameter_index = 1 + index; // skip index 0, which is the target. 286 int parameter_index = 1 + index; // skip index 0, which is the target.
285 return incoming_->GetInputLocation(parameter_index); 287 return incoming_->GetInputLocation(parameter_index);
286 } 288 }
287 } 289 }
288 290
289 } // namespace compiler 291 } // namespace compiler
290 } // namespace internal 292 } // namespace internal
291 } // namespace v8 293 } // namespace v8
292 294
293 #endif // V8_COMPILER_LINKAGE_IMPL_H_ 295 #endif // V8_COMPILER_LINKAGE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698