#include "src/compiler/linkage.h"
#include "src/builtins/builtins-descriptors.h"
#include "src/codegen/assembler-inl.h"
#include "src/codegen/macro-assembler.h"
#include "src/codegen/optimized-compilation-info.h"
#include "src/compiler/frame.h"
#include "src/compiler/globals.h"
#include "src/compiler/osr.h"
#include "src/compiler/pipeline.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/compiler/wasm-compiler-definitions.h"
#endif
namespace v8 {
namespace internal {
namespace compiler {
namespace {
constexpr int kFirstCallerSlotOffset = 1;
constexpr int kNoCallerSlotOffset = 0;
inline LinkageLocation regloc(Register reg, MachineType type) {
return LinkageLocation::ForRegister(reg.code(), type);
}
inline LinkageLocation regloc(DoubleRegister reg, MachineType type) {
return LinkageLocation::ForRegister(reg.code(), type);
}
}
std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k) {
switch (k) {
case CallDescriptor::kCallCodeObject:
os << "Code";
break;
case CallDescriptor::kCallJSFunction:
os << "JS";
break;
case CallDescriptor::kCallAddress:
os << "Addr";
break;
#if V8_ENABLE_WEBASSEMBLY
case CallDescriptor::kCallWasmCapiFunction:
os << "WasmExit";
break;
case CallDescriptor::kCallWasmFunction:
os << "WasmFunction";
break;
case CallDescriptor::kCallWasmFunctionIndirect:
os << "WasmFunctionIndirect";
break;
case CallDescriptor::kCallWasmImportWrapper:
os << "WasmImportWrapper";
break;
case CallDescriptor::kResumeWasmContinuation:
os << "WasmResumeContinuation";
break;
#endif
case CallDescriptor::kCallBuiltinPointer:
os << "BuiltinPointer";
break;
}
return os;
}
std::ostream& operator<<(std::ostream& os, const CallDescriptor& d) {
return os << d.kind() << ":" << d.debug_name() << ":r" << d.ReturnCount()
<< "s" << d.ParameterSlotCount() << "i" << d.InputCount() << "f"
<< d.FrameStateCount();
}
MachineSignature* CallDescriptor::GetMachineSignature(Zone* zone) const {
size_t param_count = ParameterCount();
size_t return_count = ReturnCount();
MachineType* types =
zone->AllocateArray<MachineType>(param_count + return_count);
int current = 0;
for (size_t i = 0; i < return_count; ++i) {
types[current++] = GetReturnType(i);
}
for (size_t i = 0; i < param_count; ++i) {
types[current++] = GetParameterType(i);
}
return zone->New<MachineSignature>(return_count, param_count, types);
}
int CallDescriptor::GetStackParameterDelta(
CallDescriptor const* tail_caller) const {
if (IsTailCallForTierUp()) return 0;
int callee_slots_above_sp = AddArgumentPaddingSlots(GetOffsetToReturns());
int tail_caller_slots_above_sp =
AddArgumentPaddingSlots(tail_caller->GetOffsetToReturns());
int stack_param_delta = callee_slots_above_sp - tail_caller_slots_above_sp;
DCHECK(!ShouldPadArguments(stack_param_delta));
return stack_param_delta;
}
int CallDescriptor::GetOffsetToFirstUnusedStackSlot() const {
int offset = kFirstCallerSlotOffset;
for (size_t i = 0; i < InputCount(); ++i) {
LinkageLocation operand = GetInputLocation(i);
if (!operand.IsRegister()) {
DCHECK(operand.IsCallerFrameSlot());
int slot_offset = -operand.GetLocation();
offset = std::max(offset, slot_offset + operand.GetSizeInPointers());
}
}
return offset;
}
int CallDescriptor::GetOffsetToReturns() const {
int offset = kNoCallerSlotOffset;
for (size_t i = 0; i < ReturnCount(); ++i) {
LinkageLocation operand = GetReturnLocation(i);
if (!operand.IsRegister()) {
DCHECK(operand.IsCallerFrameSlot());
int slot_offset = -operand.GetLocation();
offset = std::min(offset, slot_offset);
}
}
if (offset != kNoCallerSlotOffset) {
return offset - 1;
}
int last_argument_slot = GetOffsetToFirstUnusedStackSlot() - 1;
offset = AddArgumentPaddingSlots(last_argument_slot);
DCHECK_IMPLIES(offset == 0, ParameterSlotCount() == 0);
return offset;
}
uint32_t CallDescriptor::GetTaggedParameterSlots() const {
uint32_t count = 0;
uint32_t untagged_count = 0;
uint32_t first_offset = kMaxInt;
for (size_t i = 0; i < InputCount(); ++i) {
LinkageLocation operand = GetInputLocation(i);
if (!operand.IsRegister()) {
if (operand.GetType().IsTagged()) {
++count;
int slot_offset = -operand.GetLocation() - 1;
DCHECK_GE(slot_offset, 0);
first_offset =
std::min(first_offset, static_cast<uint32_t>(slot_offset));
} else {
untagged_count += operand.GetSizeInPointers();
}
}
}
if (count == 0) {
first_offset = untagged_count;
}
DCHECK(first_offset != kMaxInt);
return (first_offset << 16) | (count & 0xFFFFu);
}
bool CallDescriptor::CanTailCall(const CallDescriptor* callee) const {
if (ReturnCount() != callee->ReturnCount()) return false;
const int stack_returns_delta =
GetOffsetToReturns() - callee->GetOffsetToReturns();
for (size_t i = 0; i < ReturnCount(); ++i) {
if (GetReturnLocation(i).IsCallerFrameSlot() &&
callee->GetReturnLocation(i).IsCallerFrameSlot()) {
if (GetReturnLocation(i).AsCallerFrameSlot() + stack_returns_delta !=
callee->GetReturnLocation(i).AsCallerFrameSlot()) {
return false;
}
} else if (!LinkageLocation::IsSameLocation(GetReturnLocation(i),
callee->GetReturnLocation(i))) {
return false;
}
}
return true;
}
int CallDescriptor::CalculateFixedFrameSize(CodeKind code_kind) const {
switch (kind_) {
case kCallJSFunction:
return StandardFrameConstants::kFixedSlotCount;
case kCallAddress:
#if V8_ENABLE_WEBASSEMBLY
if (code_kind == CodeKind::C_WASM_ENTRY) {
return CWasmEntryFrameConstants::kFixedSlotCount;
}
#endif
return CommonFrameConstants::kFixedSlotCountAboveFp +
CommonFrameConstants::kCPSlotCount;
case kCallCodeObject:
case kCallBuiltinPointer:
return TypedFrameConstants::kFixedSlotCount;
#if V8_ENABLE_WEBASSEMBLY
case kCallWasmFunction:
case kCallWasmFunctionIndirect:
case kCallWasmImportWrapper:
case kResumeWasmContinuation:
return WasmFrameConstants::kFixedSlotCount;
case kCallWasmCapiFunction:
return WasmExitFrameConstants::kFixedSlotCount;
#endif
}
UNREACHABLE();
}
uint64_t CallDescriptor::signature_hash() const {
#if V8_ENABLE_WEBASSEMBLY
DCHECK_EQ(kind_, kCallWasmFunctionIndirect);
#endif
return signature_hash_;
}
EncodedCSignature CallDescriptor::ToEncodedCSignature() const {
int parameter_count = static_cast<int>(ParameterCount());
EncodedCSignature sig(parameter_count);
CHECK_LT(parameter_count, EncodedCSignature::kInvalidParamCount);
for (int i = 0; i < parameter_count; ++i) {
if (IsFloatingPoint(GetParameterType(i).representation())) {
sig.SetFloat(i);
}
}
if (ReturnCount() > 0) {
DCHECK_EQ(1, ReturnCount());
if (IsFloatingPoint(GetReturnType(0).representation())) {
if (GetReturnType(0).representation() ==
MachineRepresentation::kFloat64) {
sig.SetReturnFloat64();
} else {
sig.SetReturnFloat32();
}
}
}
return sig;
}
void CallDescriptor::ComputeParamCounts() const {
gp_param_count_ = 0;
fp_param_count_ = 0;
for (size_t i = 0; i < ParameterCount(); ++i) {
if (IsFloatingPoint(GetParameterType(i).representation())) {
++fp_param_count_.value();
} else {
++gp_param_count_.value();
}
}
}
#if V8_ENABLE_WEBASSEMBLY
namespace {
CallDescriptor* ReplaceTypeInCallDescriptorWith(
Zone* zone, const CallDescriptor* call_descriptor, size_t num_replacements,
MachineType from, MachineType to) {
bool extra_callable_param =
(call_descriptor->GetInputLocation(call_descriptor->InputCount() - 1) ==
LinkageLocation::ForRegister(kJSFunctionRegister.code(),
MachineType::TaggedPointer()));
size_t return_count = call_descriptor->ReturnCount();
size_t parameter_count =
call_descriptor->ParameterCount() - (extra_callable_param ? 2 : 1);
bool needs_change = false;
for (size_t i = 0; !needs_change && i < return_count; i++) {
needs_change = call_descriptor->GetReturnType(i) == from;
}
for (size_t i = 1; !needs_change && i < parameter_count + 1; i++) {
needs_change = call_descriptor->GetParameterType(i) == from;
}
if (!needs_change) return const_cast<CallDescriptor*>(call_descriptor);
std::vector<MachineType> reps;
for (size_t i = 0, limit = return_count; i < limit; i++) {
MachineType initial_type = call_descriptor->GetReturnType(i);
if (initial_type == from) {
for (size_t j = 0; j < num_replacements; j++) reps.push_back(to);
return_count += num_replacements - 1;
} else {
reps.push_back(initial_type);
}
}
for (size_t i = 1, limit = parameter_count + 1; i < limit; i++) {
MachineType initial_type = call_descriptor->GetParameterType(i);
if (initial_type == from) {
for (size_t j = 0; j < num_replacements; j++) reps.push_back(to);
parameter_count += num_replacements - 1;
} else {
reps.push_back(initial_type);
}
}
MachineSignature sig(return_count, parameter_count, reps.data());
int parameter_slots;
int return_slots;
LocationSignature* location_sig = BuildLocations(
zone, &sig, extra_callable_param, ¶meter_slots, &return_slots);
return zone->New<CallDescriptor>(
call_descriptor->kind(),
call_descriptor->tag(),
call_descriptor->GetInputType(0),
call_descriptor->GetInputLocation(0),
location_sig,
parameter_slots,
call_descriptor->properties(),
call_descriptor->CalleeSavedRegisters(),
call_descriptor->CalleeSavedFPRegisters(),
call_descriptor->flags(),
call_descriptor->debug_name(),
call_descriptor->GetStackArgumentOrder(),
call_descriptor->AllocatableRegisters(),
return_slots,
call_descriptor->IsIndirectWasmFunctionCall()
? call_descriptor->signature_hash()
: kInvalidWasmSignatureHash);
}
}
CallDescriptor* GetI32WasmCallDescriptor(
Zone* zone, const CallDescriptor* call_descriptor) {
return ReplaceTypeInCallDescriptorWith(
zone, call_descriptor, 2, MachineType::Int64(), MachineType::Int32());
}
#endif
CallDescriptor* Linkage::ComputeIncoming(Zone* zone,
OptimizedCompilationInfo* info) {
#if V8_ENABLE_WEBASSEMBLY
DCHECK(info->IsOptimizing() || info->IsWasm());
#else
DCHECK(info->IsOptimizing());
#endif
if (!info->closure().is_null()) {
DCHECK(info->has_bytecode_array());
DCHECK_EQ(info->closure()
->shared()
->internal_formal_parameter_count_with_receiver(),
info->bytecode_array()->parameter_count());
return GetJSCallDescriptor(zone, info->is_osr(),
info->bytecode_array()->parameter_count(),
CallDescriptor::kCanUseRoots);
}
return nullptr;
}
bool Linkage::NeedsFrameStateInput(Runtime::FunctionId function) {
switch (function) {
case Runtime::kAbort:
case Runtime::kAllocateInOldGeneration:
case Runtime::kCreateIterResultObject:
case Runtime::kGrowableSharedArrayBufferByteLength:
case Runtime::kIncBlockCounter:
case Runtime::kNewClosure:
case Runtime::kNewClosure_Tenured:
case Runtime::kNewFunctionContext:
case Runtime::kPushBlockContext:
case Runtime::kPushCatchContext:
case Runtime::kStringEqual:
case Runtime::kStringLessThan:
case Runtime::kStringLessThanOrEqual:
case Runtime::kStringGreaterThan:
case Runtime::kStringGreaterThanOrEqual:
case Runtime::kToFastProperties:
case Runtime::kTraceEnter:
case Runtime::kTraceExit:
return false;
case Runtime::kInlineCreateIterResultObject:
case Runtime::kInlineIncBlockCounter:
case Runtime::kInlineGeneratorClose:
case Runtime::kInlineGeneratorGetResumeMode:
case Runtime::kInlineCreateJSGeneratorObject:
return false;
default:
break;
}
return true;
}
CallDescriptor* Linkage::GetRuntimeCallDescriptor(
Zone* zone, Runtime::FunctionId function_id, int parameter_count,
Operator::Properties properties, CallDescriptor::Flags flags,
LazyDeoptOnThrow lazy_deopt_on_throw) {
const Runtime::Function* function = Runtime::FunctionForId(function_id);
const int return_count = function->result_size;
const char* debug_name = function->name;
if (lazy_deopt_on_throw == LazyDeoptOnThrow::kNo &&
!Linkage::NeedsFrameStateInput(function_id)) {
flags = static_cast<CallDescriptor::Flags>(
flags & ~CallDescriptor::kNeedsFrameState);
}
DCHECK_IMPLIES(lazy_deopt_on_throw == LazyDeoptOnThrow::kYes,
flags & CallDescriptor::kNeedsFrameState);
CallDescriptor* descriptor = GetCEntryStubCallDescriptor(
zone, return_count, parameter_count, debug_name, properties, flags,
StackArgumentOrder::kDefault, kCEntryEntrypointTag);
descriptor->runtime_function_id_ = function_id;
return descriptor;
}
CallDescriptor* Linkage::GetCPPBuiltinCallDescriptor(
Zone* zone, int js_parameter_count, const char* debug_name,
Operator::Properties properties, CallDescriptor::Flags flags) {
DCHECK_LE(BuiltinArguments::kNumExtraArgsWithReceiver, js_parameter_count);
return GetCEntryStubCallDescriptor(zone, 1, js_parameter_count, debug_name,
properties, flags, StackArgumentOrder::kJS,
kInvalidEntrypointTag);
}
CallDescriptor* Linkage::GetCEntryStubCallDescriptor(
Zone* zone, int return_count, int stack_parameter_count,
const char* debug_name, Operator::Properties properties,
CallDescriptor::Flags flags, StackArgumentOrder stack_order,
CodeEntrypointTag entrypoint_tag) {
const size_t function_count = 1;
const size_t num_args_count = 1;
const size_t context_count = 1;
const size_t parameter_count = function_count +
static_cast<size_t>(stack_parameter_count) +
num_args_count + context_count;
LocationSignature::Builder locations(zone, static_cast<size_t>(return_count),
static_cast<size_t>(parameter_count));
if (locations.return_count_ > 0) {
locations.AddReturn(regloc(kReturnRegister0, MachineType::AnyTagged()));
}
if (locations.return_count_ > 1) {
locations.AddReturn(regloc(kReturnRegister1, MachineType::AnyTagged()));
}
if (locations.return_count_ > 2) {
locations.AddReturn(regloc(kReturnRegister2, MachineType::AnyTagged()));
}
for (int i = 0; i < stack_parameter_count; i++) {
locations.AddParam(LinkageLocation::ForCallerFrameSlot(
i - stack_parameter_count, MachineType::AnyTagged()));
}
locations.AddParam(
regloc(kRuntimeCallFunctionRegister, MachineType::Pointer()));
locations.AddParam(
regloc(kRuntimeCallArgCountRegister, MachineType::Int32()));
locations.AddParam(regloc(kContextRegister, MachineType::AnyTagged()));
MachineType target_type = MachineType::AnyTagged();
LinkageLocation target_loc =
LinkageLocation::ForAnyRegister(MachineType::AnyTagged());
return zone->New<CallDescriptor>(
CallDescriptor::kCallCodeObject,
entrypoint_tag,
target_type,
target_loc,
locations.Get(),
stack_parameter_count,
properties,
kNoCalleeSaved,
kNoCalleeSavedFp,
flags,
debug_name,
stack_order);
}
CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr,
int js_parameter_count,
CallDescriptor::Flags flags,
Operator::Properties properties) {
const size_t return_count = 1;
const size_t context_count = 1;
const size_t new_target_count = 1;
const size_t num_args_count = 1;
const size_t dispatch_handle_count =
V8_JS_LINKAGE_INCLUDES_DISPATCH_HANDLE_BOOL ? 1 : 0;
const size_t parameter_count = js_parameter_count + new_target_count +
num_args_count + dispatch_handle_count +
context_count;
DCHECK_EQ(parameter_count, kJSBuiltinBaseParameterCount + js_parameter_count);
LocationSignature::Builder locations(zone, return_count, parameter_count);
locations.AddReturn(regloc(kReturnRegister0, MachineType::AnyTagged()));
for (int i = 0; i < js_parameter_count; i++) {
int spill_slot_index = -i - 1;
locations.AddParam(LinkageLocation::ForCallerFrameSlot(
spill_slot_index, MachineType::AnyTagged()));
}
locations.AddParam(
regloc(kJavaScriptCallNewTargetRegister, MachineType::AnyTagged()));
locations.AddParam(
regloc(kJavaScriptCallArgCountRegister, MachineType::Int32()));
#ifdef V8_JS_LINKAGE_INCLUDES_DISPATCH_HANDLE
locations.AddParam(
regloc(kJavaScriptCallDispatchHandleRegister, MachineType::Int32()));
#endif
locations.AddParam(regloc(kContextRegister, MachineType::AnyTagged()));
MachineType target_type = MachineType::AnyTagged();
LinkageLocation target_loc = is_osr
? LinkageLocation::ForSavedCallerFunction()
: regloc(kJSFunctionRegister, target_type);
CallDescriptor::Kind descriptor_kind = CallDescriptor::kCallJSFunction;
return zone->New<CallDescriptor>(
descriptor_kind,
kJSEntrypointTag,
target_type,
target_loc,
locations.Get(),
js_parameter_count,
properties,
kNoCalleeSaved,
kNoCalleeSavedFp,
flags,
"js-call");
}
CallDescriptor* Linkage::GetStubCallDescriptor(
Zone* zone, const CallInterfaceDescriptor& descriptor,
int stack_parameter_count, CallDescriptor::Flags flags,
Operator::Properties properties, StubCallMode stub_mode) {
const int register_parameter_count = descriptor.GetRegisterParameterCount();
const int js_parameter_count =
register_parameter_count + stack_parameter_count;
const int context_count = descriptor.HasContextParameter() ? 1 : 0;
const size_t parameter_count =
static_cast<size_t>(js_parameter_count + context_count);
DCHECK_GE(stack_parameter_count, descriptor.GetStackParameterCount());
int return_count = descriptor.GetReturnCount();
LocationSignature::Builder locations(zone, return_count, parameter_count);
for (int i = 0; i < return_count; i++) {
MachineType type = descriptor.GetReturnType(static_cast<int>(i));
if (IsFloatingPoint(type.representation())) {
DoubleRegister reg = descriptor.GetDoubleRegisterReturn(i);
locations.AddReturn(regloc(reg, type));
} else {
Register reg = descriptor.GetRegisterReturn(i);
locations.AddReturn(regloc(reg, type));
}
}
for (int i = 0; i < js_parameter_count; i++) {
if (i < register_parameter_count) {
MachineType type = descriptor.GetParameterType(i);
if (IsFloatingPoint(type.representation())) {
DoubleRegister reg = descriptor.GetDoubleRegisterParameter(i);
locations.AddParam(regloc(reg, type));
} else {
Register reg = descriptor.GetRegisterParameter(i);
locations.AddParam(regloc(reg, type));
}
} else {
int stack_slot = i - register_parameter_count - stack_parameter_count;
locations.AddParam(LinkageLocation::ForCallerFrameSlot(
stack_slot, i < descriptor.GetParameterCount()
? descriptor.GetParameterType(i)
: MachineType::AnyTagged()));
}
}
if (context_count) {
locations.AddParam(regloc(kContextRegister, MachineType::AnyTagged()));
}
CallDescriptor::Kind kind;
MachineType target_type;
switch (stub_mode) {
case StubCallMode::kCallCodeObject:
kind = CallDescriptor::kCallCodeObject;
target_type = MachineType::AnyTagged();
break;
#if V8_ENABLE_WEBASSEMBLY
case StubCallMode::kCallWasmRuntimeStub:
kind = CallDescriptor::kCallWasmFunction;
target_type = MachineType::Pointer();
break;
#endif
case StubCallMode::kCallBuiltinPointer:
kind = CallDescriptor::kCallBuiltinPointer;
target_type = MachineType::AnyTagged();
break;
}
RegList allocatable_registers = descriptor.allocatable_registers();
RegList callee_saved_registers = kNoCalleeSaved;
if (descriptor.CalleeSaveRegisters()) {
callee_saved_registers = allocatable_registers;
DCHECK(!callee_saved_registers.is_empty());
}
LinkageLocation target_loc = LinkageLocation::ForAnyRegister(target_type);
return zone->New<CallDescriptor>(
kind,
descriptor.tag(),
target_type,
target_loc,
locations.Get(),
stack_parameter_count,
properties,
callee_saved_registers,
kNoCalleeSavedFp,
CallDescriptor::kCanUseRoots | flags,
descriptor.DebugName(),
descriptor.GetStackArgumentOrder(),
allocatable_registers);
}
CallDescriptor* Linkage::GetBytecodeDispatchCallDescriptor(
Zone* zone, const CallInterfaceDescriptor& descriptor,
int stack_parameter_count) {
const int register_parameter_count = descriptor.GetRegisterParameterCount();
const int parameter_count = register_parameter_count + stack_parameter_count;
DCHECK_EQ(descriptor.GetReturnCount(), 1);
LocationSignature::Builder locations(zone, 1, parameter_count);
locations.AddReturn(regloc(kReturnRegister0, descriptor.GetReturnType(0)));
for (int i = 0; i < parameter_count; i++) {
if (i < register_parameter_count) {
Register reg = descriptor.GetRegisterParameter(i);
MachineType type = descriptor.GetParameterType(i);
locations.AddParam(regloc(reg, type));
} else {
int stack_slot = i - register_parameter_count - stack_parameter_count;
locations.AddParam(LinkageLocation::ForCallerFrameSlot(
stack_slot, MachineType::AnyTagged()));
}
}
MachineType target_type = MachineType::Pointer();
LinkageLocation target_loc = LinkageLocation::ForAnyRegister(target_type);
const CallDescriptor::Flags kFlags =
CallDescriptor::kCanUseRoots | CallDescriptor::kFixedTargetRegister;
return zone->New<CallDescriptor>(
CallDescriptor::kCallAddress,
kBytecodeHandlerEntrypointTag,
target_type,
target_loc,
locations.Get(),
stack_parameter_count,
Operator::kNoProperties,
kNoCalleeSaved,
kNoCalleeSavedFp,
kFlags,
descriptor.DebugName());
}
LinkageLocation Linkage::GetOsrValueLocation(int index) const {
CHECK(incoming_->IsJSFunctionCall());
int parameter_count_with_receiver =
static_cast<int>(incoming_->JSParameterCount());
int first_stack_slot =
OsrHelper::FirstStackSlotIndex(parameter_count_with_receiver - 1);
if (index == kOsrContextSpillSlotIndex) {
int context_index =
Linkage::GetJSCallContextParamIndex(parameter_count_with_receiver);
return GetParameterLocation(context_index);
} else if (index >= first_stack_slot) {
int spill_index =
index - first_stack_slot + StandardFrameConstants::kFixedSlotCount;
return LinkageLocation::ForCalleeFrameSlot(spill_index,
MachineType::AnyTagged());
} else {
return GetParameterLocation(index);
}
}
namespace {
inline bool IsTaggedReg(const LinkageLocation& loc, Register reg) {
return loc.IsRegister() && loc.AsRegister() == reg.code() &&
loc.GetType().representation() ==
MachineRepresentation::kTaggedPointer;
}
}
bool Linkage::ParameterHasSecondaryLocation(int index) const {
if (incoming_->IsJSFunctionCall()) {
LinkageLocation loc = GetParameterLocation(index);
return IsTaggedReg(loc, kJSFunctionRegister) ||
IsTaggedReg(loc, kContextRegister);
}
#if V8_ENABLE_WEBASSEMBLY
if (incoming_->IsAnyWasmFunctionCall()) {
LinkageLocation loc = GetParameterLocation(index);
return IsTaggedReg(loc, kWasmImplicitArgRegister);
}
#endif
return false;
}
LinkageLocation Linkage::GetParameterSecondaryLocation(int index) const {
static const int kJSContextSlot = 2 + StandardFrameConstants::kCPSlotCount;
static const int kJSFunctionSlot = 3 + StandardFrameConstants::kCPSlotCount;
DCHECK(ParameterHasSecondaryLocation(index));
LinkageLocation loc = GetParameterLocation(index);
if (incoming_->IsJSFunctionCall()) {
if (IsTaggedReg(loc, kJSFunctionRegister)) {
return LinkageLocation::ForCalleeFrameSlot(kJSFunctionSlot,
MachineType::AnyTagged());
} else {
DCHECK(IsTaggedReg(loc, kContextRegister));
return LinkageLocation::ForCalleeFrameSlot(kJSContextSlot,
MachineType::AnyTagged());
}
}
#if V8_ENABLE_WEBASSEMBLY
static const int kWasmInstanceDataSlot =
3 + StandardFrameConstants::kCPSlotCount;
if (incoming_->IsAnyWasmFunctionCall()) {
DCHECK(IsTaggedReg(loc, kWasmImplicitArgRegister));
return LinkageLocation::ForCalleeFrameSlot(kWasmInstanceDataSlot,
MachineType::AnyTagged());
}
#endif
UNREACHABLE();
}
}
}
}