16#if V8_ENABLE_WEBASSEMBLY
27constexpr int kFirstCallerSlotOffset = 1;
28constexpr int kNoCallerSlotOffset = 0;
30inline LinkageLocation regloc(Register
reg, MachineType type) {
52#if V8_ENABLE_WEBASSEMBLY
53 case CallDescriptor::kCallWasmCapiFunction:
56 case CallDescriptor::kCallWasmFunction:
59 case CallDescriptor::kCallWasmFunctionIndirect:
60 os <<
"WasmFunctionIndirect";
62 case CallDescriptor::kCallWasmImportWrapper:
63 os <<
"WasmImportWrapper";
67 os <<
"BuiltinPointer";
76 return os << d.kind() <<
":" << d.debug_name() <<
":r" << d.ReturnCount()
77 <<
"s" << d.ParameterSlotCount() <<
"i" << d.InputCount() <<
"f"
78 << d.FrameStateCount();
87 for (
size_t i = 0;
i < return_count; ++
i) {
90 for (
size_t i = 0;
i < param_count; ++
i) {
106 int tail_caller_slots_above_sp =
108 int stack_param_delta = callee_slots_above_sp - tail_caller_slots_above_sp;
110 return stack_param_delta;
114 int offset = kFirstCallerSlotOffset;
128 int offset = kNoCallerSlotOffset;
138 if (
offset != kNoCallerSlotOffset) {
153 uint32_t untagged_count = 0;
154 uint32_t first_offset =
kMaxInt;
166 std::min(first_offset,
static_cast<uint32_t
>(slot_offset));
176 first_offset = untagged_count;
179 return (first_offset << 16) | (
count & 0xFFFFu);
184 const int stack_returns_delta =
209#if V8_ENABLE_WEBASSEMBLY
210 if (code_kind == CodeKind::C_WASM_ENTRY) {
211 return CWasmEntryFrameConstants::kFixedSlotCount;
219#if V8_ENABLE_WEBASSEMBLY
220 case kCallWasmFunction:
221 case kCallWasmFunctionIndirect:
222 case kCallWasmImportWrapper:
223 return WasmFrameConstants::kFixedSlotCount;
224 case kCallWasmCapiFunction:
225 return WasmExitFrameConstants::kFixedSlotCount;
232#if V8_ENABLE_WEBASSEMBLY
253 sig.SetReturnFloat64();
255 sig.SetReturnFloat32();
274#if V8_ENABLE_WEBASSEMBLY
282 bool extra_callable_param =
287 size_t return_count = call_descriptor->
ReturnCount();
291 call_descriptor->
ParameterCount() - (extra_callable_param ? 2 : 1);
294 bool needs_change =
false;
295 for (
size_t i = 0; !needs_change &&
i < return_count;
i++) {
301 if (!needs_change)
return const_cast<CallDescriptor*
>(call_descriptor);
303 std::vector<MachineType> reps;
305 for (
size_t i = 0, limit = return_count;
i < limit;
i++) {
307 if (initial_type == from) {
308 for (
size_t j = 0; j < num_replacements; j++) reps.push_back(to);
309 return_count += num_replacements - 1;
311 reps.push_back(initial_type);
318 if (initial_type == from) {
319 for (
size_t j = 0; j < num_replacements; j++) reps.push_back(to);
322 reps.push_back(initial_type);
331 zone, &
sig, extra_callable_param, ¶meter_slots, &return_slots);
333 return zone->
New<CallDescriptor>(
334 call_descriptor->
kind(),
335 call_descriptor->
tag(),
343 call_descriptor->
flags(),
348 call_descriptor->IsIndirectWasmFunctionCall()
354CallDescriptor* GetI32WasmCallDescriptor(
355 Zone* zone,
const CallDescriptor* call_descriptor) {
356 return ReplaceTypeInCallDescriptorWith(
363#if V8_ENABLE_WEBASSEMBLY
364 DCHECK(info->IsOptimizing() || info->IsWasm());
366 DCHECK(info->IsOptimizing());
368 if (!info->closure().is_null()) {
371 DCHECK(info->has_bytecode_array());
374 ->internal_formal_parameter_count_with_receiver(),
375 info->bytecode_array()->parameter_count());
377 info->bytecode_array()->parameter_count(),
390 case Runtime::kAbort:
391 case Runtime::kAllocateInOldGeneration:
392 case Runtime::kCreateIterResultObject:
393 case Runtime::kGrowableSharedArrayBufferByteLength:
394 case Runtime::kIncBlockCounter:
395 case Runtime::kNewClosure:
396 case Runtime::kNewClosure_Tenured:
397 case Runtime::kNewFunctionContext:
398 case Runtime::kPushBlockContext:
399 case Runtime::kPushCatchContext:
400 case Runtime::kStringEqual:
401 case Runtime::kStringLessThan:
402 case Runtime::kStringLessThanOrEqual:
403 case Runtime::kStringGreaterThan:
404 case Runtime::kStringGreaterThanOrEqual:
405 case Runtime::kToFastProperties:
406 case Runtime::kTraceEnter:
407 case Runtime::kTraceExit:
411 case Runtime::kInlineCreateIterResultObject:
412 case Runtime::kInlineIncBlockCounter:
413 case Runtime::kInlineGeneratorClose:
414 case Runtime::kInlineGeneratorGetResumeMode:
415 case Runtime::kInlineCreateJSGeneratorObject:
431 const int return_count = function->result_size;
432 const char* debug_name = function->name;
444 debug_name, properties, flags);
448 Zone* zone,
int return_count,
int js_parameter_count,
451 const size_t function_count = 1;
452 const size_t num_args_count = 1;
453 const size_t context_count = 1;
455 static_cast<size_t>(js_parameter_count) +
456 num_args_count + context_count;
462 if (locations.return_count_ > 0) {
465 if (locations.return_count_ > 1) {
468 if (locations.return_count_ > 2) {
473 for (
int i = 0;
i < js_parameter_count;
i++) {
508 int js_parameter_count,
511 const size_t return_count = 1;
512 const size_t context_count = 1;
513 const size_t new_target_count = 1;
514 const size_t num_args_count = 1;
515 const size_t dispatch_handle_count =
518 num_args_count + dispatch_handle_count +
534 for (
int i = 0;
i < js_parameter_count;
i++) {
535 int spill_slot_index = -
i - 1;
548#ifdef V8_JS_LINKAGE_INCLUDES_DISPATCH_HANDLE
592 const int js_parameter_count =
593 register_parameter_count + stack_parameter_count;
596 static_cast<size_t>(js_parameter_count + context_count);
604 for (
int i = 0;
i < return_count;
i++) {
616 for (
int i = 0;
i < js_parameter_count;
i++) {
617 if (
i < register_parameter_count) {
629 int stack_slot =
i - register_parameter_count - stack_parameter_count;
650#if V8_ENABLE_WEBASSEMBLY
651 case StubCallMode::kCallWasmRuntimeStub:
652 kind = CallDescriptor::kCallWasmFunction;
665 callee_saved_registers = allocatable_registers;
675 stack_parameter_count,
677 callee_saved_registers,
682 allocatable_registers);
688 int stack_parameter_count) {
690 const int parameter_count = register_parameter_count + stack_parameter_count;
699 if (
i < register_parameter_count) {
706 int stack_slot =
i - register_parameter_count - stack_parameter_count;
723 stack_parameter_count,
733 int parameter_count_with_receiver =
735 int first_stack_slot =
742 }
else if (index >= first_stack_slot) {
769#if V8_ENABLE_WEBASSEMBLY
770 if (
incoming_->IsAnyWasmFunctionCall()) {
797#if V8_ENABLE_WEBASSEMBLY
798 static const int kWasmInstanceDataSlot =
800 if (
incoming_->IsAnyWasmFunctionCall()) {
Register GetRegisterReturn(int index) const
DoubleRegister GetDoubleRegisterParameter(int index) const
int GetStackParameterCount() const
const char * DebugName() const
RegList allocatable_registers() const
MachineType GetReturnType(int index) const
Register GetRegisterParameter(int index) const
int GetParameterCount() const
DoubleRegister GetDoubleRegisterReturn(int index) const
StackArgumentOrder GetStackArgumentOrder() const
CodeEntrypointTag tag() const
int GetRegisterParameterCount() const
int GetReturnCount() const
bool HasContextParameter() const
bool CalleeSaveRegisters() const
MachineType GetParameterType(int index) const
static constexpr int kFixedSlotCountAboveFp
static constexpr int kCPSlotCount
static LinkageLocation ForRegister(int32_t reg, MachineType type=MachineType::None())
static LinkageLocation ForCallerFrameSlot(int32_t slot, MachineType type)
static LinkageLocation ForAnyRegister(MachineType type=MachineType::None())
MachineType GetType() const
int GetSizeInPointers() const
static LinkageLocation ForCalleeFrameSlot(int32_t slot, MachineType type)
int32_t AsRegister() const
bool IsCallerFrameSlot() const
static bool IsSameLocation(const LinkageLocation &a, const LinkageLocation &b)
int32_t GetLocation() const
static LinkageLocation ForSavedCallerFunction()
NO_INLINE_FOR_ARM64_MSVC bool IsRegister() const
int32_t AsCallerFrameSlot() const
constexpr bool IsTagged() const
static constexpr MachineType Pointer()
constexpr MachineRepresentation representation() const
static constexpr MachineType Int32()
static constexpr MachineType AnyTagged()
static constexpr MachineType Int64()
static constexpr MachineType TaggedPointer()
constexpr bool is_empty() const
static V8_EXPORT_PRIVATE const Function * FunctionForId(FunctionId id)
static constexpr int kFixedSlotCount
static constexpr int kFixedSlotCount
T * AllocateArray(size_t length)
MachineSignature * GetMachineSignature(Zone *zone) const
int CalculateFixedFrameSize(CodeKind code_kind) const
size_t JSParameterCount() const
CodeEntrypointTag tag() const
RegList CalleeSavedRegisters() const
std::optional< size_t > gp_param_count_
RegList AllocatableRegisters() const
MachineType GetInputType(size_t index) const
uint64_t signature_hash() const
DoubleRegList CalleeSavedFPRegisters() const
int GetOffsetToFirstUnusedStackSlot() const
std::optional< size_t > fp_param_count_
size_t ParameterCount() const
size_t ParameterSlotCount() const
MachineType GetParameterType(size_t index) const
size_t ReturnCount() const
int GetStackParameterDelta(const CallDescriptor *tail_caller) const
StackArgumentOrder GetStackArgumentOrder() const
uint32_t GetTaggedParameterSlots() const
bool IsJSFunctionCall() const
MachineType GetReturnType(size_t index) const
size_t InputCount() const
LinkageLocation GetReturnLocation(size_t index) const
Operator::Properties properties() const
bool IsTailCallForTierUp() const
bool CanTailCall(const CallDescriptor *callee) const
EncodedCSignature ToEncodedCSignature() const
LinkageLocation GetInputLocation(size_t index) const
int GetOffsetToReturns() const
const char * debug_name() const
void ComputeParamCounts() const
static bool NeedsFrameStateInput(Runtime::FunctionId function)
CallDescriptor *const incoming_
static constexpr int GetJSCallContextParamIndex(int parameter_count)
bool ParameterHasSecondaryLocation(int index) const
static CallDescriptor * GetStubCallDescriptor(Zone *zone, const CallInterfaceDescriptor &descriptor, int stack_parameter_count, CallDescriptor::Flags flags, Operator::Properties properties=Operator::kNoProperties, StubCallMode stub_mode=StubCallMode::kCallCodeObject)
LinkageLocation GetParameterSecondaryLocation(int index) const
static CallDescriptor * GetRuntimeCallDescriptor(Zone *zone, Runtime::FunctionId function, int js_parameter_count, Operator::Properties properties, CallDescriptor::Flags flags, LazyDeoptOnThrow lazy_deopt_on_throw=LazyDeoptOnThrow::kNo)
static CallDescriptor * GetJSCallDescriptor(Zone *zone, bool is_osr, int parameter_count, CallDescriptor::Flags flags, Operator::Properties properties=Operator::kNoProperties)
static CallDescriptor * GetBytecodeDispatchCallDescriptor(Zone *zone, const CallInterfaceDescriptor &descriptor, int stack_parameter_count)
static const int kOsrContextSpillSlotIndex
LinkageLocation GetParameterLocation(int index) const
static CallDescriptor * GetCEntryStubCallDescriptor(Zone *zone, int return_count, int js_parameter_count, const char *debug_name, Operator::Properties properties, CallDescriptor::Flags flags, StackArgumentOrder stack_order=StackArgumentOrder::kDefault)
LinkageLocation GetOsrValueLocation(int index) const
static CallDescriptor * ComputeIncoming(Zone *zone, OptimizedCompilationInfo *info)
static int FirstStackSlotIndex(int parameter_count)
#define V8_JS_LINKAGE_INCLUDES_DISPATCH_HANDLE_BOOL
LocationSignature * BuildLocations(Zone *zone, const Signature< T > *sig, bool extra_callable_param, int *parameter_slots, int *return_slots)
constexpr RegList kNoCalleeSaved
std::ostream & operator<<(std::ostream &os, AccessMode access_mode)
constexpr DoubleRegList kNoCalleeSavedFp
constexpr bool ShouldPadArguments(int argument_count)
constexpr Register kRuntimeCallFunctionRegister
DwVfpRegister DoubleRegister
Signature< LinkageLocation > LocationSignature
constexpr int AddArgumentPaddingSlots(int argument_count)
@ kBytecodeHandlerEntrypointTag
@ kDefaultCodeEntrypointTag
constexpr Register kJavaScriptCallArgCountRegister
kWasmInternalFunctionIndirectPointerTag kProtectedInstanceDataOffset sig
Signature< MachineType > MachineSignature
constexpr Register kReturnRegister1
constexpr bool IsFloatingPoint(MachineRepresentation rep)
constexpr Register kReturnRegister0
constexpr Register kWasmImplicitArgRegister
constexpr Register kContextRegister
constexpr Register kRuntimeCallArgCountRegister
constexpr Register kReturnRegister2
constexpr size_t kJSBuiltinBaseParameterCount
constexpr Register kJavaScriptCallDispatchHandleRegister
constexpr uint64_t kInvalidWasmSignatureHash
constexpr Register kJavaScriptCallNewTargetRegister
constexpr Register kJSFunctionRegister
#define CHECK_LT(lhs, rhs)
#define DCHECK_IMPLIES(v1, v2)
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
static const int kInvalidParamCount