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

Side by Side Diff: src/compiler/linkage.cc

Issue 2259883002: [turbofan] Inline calls to CPP builtins (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@builtin-descriptors
Patch Set: Address comments Created 4 years, 4 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/linkage.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "src/compiler/linkage.h"
6
5 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/builtins/builtins-utils.h"
6 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
7 #include "src/compiler.h" 10 #include "src/compiler.h"
8 #include "src/compiler/common-operator.h" 11 #include "src/compiler/common-operator.h"
9 #include "src/compiler/frame.h" 12 #include "src/compiler/frame.h"
10 #include "src/compiler/linkage.h"
11 #include "src/compiler/node.h" 13 #include "src/compiler/node.h"
12 #include "src/compiler/osr.h" 14 #include "src/compiler/osr.h"
13 #include "src/compiler/pipeline.h" 15 #include "src/compiler/pipeline.h"
14 16
15 namespace v8 { 17 namespace v8 {
16 namespace internal { 18 namespace internal {
17 namespace compiler { 19 namespace compiler {
18 20
19 namespace { 21 namespace {
20 22
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 for (size_t i = 0; i < ReturnCount(); ++i) { 217 for (size_t i = 0; i < ReturnCount(); ++i) {
216 if (!GetReturnLocation(i).IsRegister()) return false; 218 if (!GetReturnLocation(i).IsRegister()) return false;
217 } 219 }
218 return true; 220 return true;
219 } 221 }
220 222
221 223
222 CallDescriptor* Linkage::GetRuntimeCallDescriptor( 224 CallDescriptor* Linkage::GetRuntimeCallDescriptor(
223 Zone* zone, Runtime::FunctionId function_id, int js_parameter_count, 225 Zone* zone, Runtime::FunctionId function_id, int js_parameter_count,
224 Operator::Properties properties, CallDescriptor::Flags flags) { 226 Operator::Properties properties, CallDescriptor::Flags flags) {
227 const Runtime::Function* function = Runtime::FunctionForId(function_id);
228 const int return_count = function->result_size;
229 const char* debug_name = function->name;
230
231 if (!Linkage::NeedsFrameStateInput(function_id)) {
232 flags = static_cast<CallDescriptor::Flags>(
233 flags & ~CallDescriptor::kNeedsFrameState);
234 }
235
236 return GetCEntryStubCallDescriptor(zone, return_count, js_parameter_count,
237 debug_name, properties, flags);
238 }
239
240 CallDescriptor* Linkage::GetCEntryStubCallDescriptor(
241 Zone* zone, int return_count, int js_parameter_count,
242 const char* debug_name, Operator::Properties properties,
243 CallDescriptor::Flags flags) {
225 const size_t function_count = 1; 244 const size_t function_count = 1;
226 const size_t num_args_count = 1; 245 const size_t num_args_count = 1;
227 const size_t context_count = 1; 246 const size_t context_count = 1;
228 const size_t parameter_count = function_count + 247 const size_t parameter_count = function_count +
229 static_cast<size_t>(js_parameter_count) + 248 static_cast<size_t>(js_parameter_count) +
230 num_args_count + context_count; 249 num_args_count + context_count;
231 250
232 const Runtime::Function* function = Runtime::FunctionForId(function_id); 251 LocationSignature::Builder locations(zone, static_cast<size_t>(return_count),
233 const size_t return_count = static_cast<size_t>(function->result_size); 252 static_cast<size_t>(parameter_count));
234
235 LocationSignature::Builder locations(zone, return_count, parameter_count);
236 253
237 // Add returns. 254 // Add returns.
238 if (locations.return_count_ > 0) { 255 if (locations.return_count_ > 0) {
239 locations.AddReturn(regloc(kReturnRegister0, MachineType::AnyTagged())); 256 locations.AddReturn(regloc(kReturnRegister0, MachineType::AnyTagged()));
240 } 257 }
241 if (locations.return_count_ > 1) { 258 if (locations.return_count_ > 1) {
242 locations.AddReturn(regloc(kReturnRegister1, MachineType::AnyTagged())); 259 locations.AddReturn(regloc(kReturnRegister1, MachineType::AnyTagged()));
243 } 260 }
244 if (locations.return_count_ > 2) { 261 if (locations.return_count_ > 2) {
245 locations.AddReturn(regloc(kReturnRegister2, MachineType::AnyTagged())); 262 locations.AddReturn(regloc(kReturnRegister2, MachineType::AnyTagged()));
246 } 263 }
247 264
248 // All parameters to the runtime call go on the stack. 265 // All parameters to the runtime call go on the stack.
249 for (int i = 0; i < js_parameter_count; i++) { 266 for (int i = 0; i < js_parameter_count; i++) {
250 locations.AddParam(LinkageLocation::ForCallerFrameSlot( 267 locations.AddParam(LinkageLocation::ForCallerFrameSlot(
251 i - js_parameter_count, MachineType::AnyTagged())); 268 i - js_parameter_count, MachineType::AnyTagged()));
252 } 269 }
253 // Add runtime function itself. 270 // Add runtime function itself.
254 locations.AddParam( 271 locations.AddParam(
255 regloc(kRuntimeCallFunctionRegister, MachineType::Pointer())); 272 regloc(kRuntimeCallFunctionRegister, MachineType::Pointer()));
256 273
257 // Add runtime call argument count. 274 // Add runtime call argument count.
258 locations.AddParam( 275 locations.AddParam(
259 regloc(kRuntimeCallArgCountRegister, MachineType::Int32())); 276 regloc(kRuntimeCallArgCountRegister, MachineType::Int32()));
260 277
261 // Add context. 278 // Add context.
262 locations.AddParam(regloc(kContextRegister, MachineType::AnyTagged())); 279 locations.AddParam(regloc(kContextRegister, MachineType::AnyTagged()));
263 280
264 if (!Linkage::NeedsFrameStateInput(function_id)) {
265 flags = static_cast<CallDescriptor::Flags>(
266 flags & ~CallDescriptor::kNeedsFrameState);
267 }
268
269 // The target for runtime calls is a code object. 281 // The target for runtime calls is a code object.
270 MachineType target_type = MachineType::AnyTagged(); 282 MachineType target_type = MachineType::AnyTagged();
271 LinkageLocation target_loc = 283 LinkageLocation target_loc =
272 LinkageLocation::ForAnyRegister(MachineType::AnyTagged()); 284 LinkageLocation::ForAnyRegister(MachineType::AnyTagged());
273 return new (zone) CallDescriptor( // -- 285 return new (zone) CallDescriptor( // --
274 CallDescriptor::kCallCodeObject, // kind 286 CallDescriptor::kCallCodeObject, // kind
275 target_type, // target MachineType 287 target_type, // target MachineType
276 target_loc, // target location 288 target_loc, // target location
277 locations.Build(), // location_sig 289 locations.Build(), // location_sig
278 js_parameter_count, // stack_parameter_count 290 js_parameter_count, // stack_parameter_count
279 properties, // properties 291 properties, // properties
280 kNoCalleeSaved, // callee-saved 292 kNoCalleeSaved, // callee-saved
281 kNoCalleeSaved, // callee-saved fp 293 kNoCalleeSaved, // callee-saved fp
282 flags, // flags 294 flags, // flags
283 function->name); // debug name 295 debug_name); // debug name
284 } 296 }
285 297
286
287 CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr, 298 CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr,
288 int js_parameter_count, 299 int js_parameter_count,
289 CallDescriptor::Flags flags) { 300 CallDescriptor::Flags flags) {
290 const size_t return_count = 1; 301 const size_t return_count = 1;
291 const size_t context_count = 1; 302 const size_t context_count = 1;
292 const size_t new_target_count = 1; 303 const size_t new_target_count = 1;
293 const size_t num_args_count = 1; 304 const size_t num_args_count = 1;
294 const size_t parameter_count = 305 const size_t parameter_count =
295 js_parameter_count + new_target_count + num_args_count + context_count; 306 js_parameter_count + new_target_count + num_args_count + context_count;
296 307
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 DCHECK(loc == regloc(kContextRegister, MachineType::AnyTagged())); 523 DCHECK(loc == regloc(kContextRegister, MachineType::AnyTagged()));
513 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot, 524 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot,
514 MachineType::AnyTagged()); 525 MachineType::AnyTagged());
515 } 526 }
516 } 527 }
517 528
518 529
519 } // namespace compiler 530 } // namespace compiler
520 } // namespace internal 531 } // namespace internal
521 } // namespace v8 532 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/linkage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698