17template <
typename R,
size_t N>
18class SimpleAllocator {
20 explicit SimpleAllocator(
const R (®s)[
N]) : regs_(regs) {
23 if (
N == 1 && regs_[0] == -1) {
28 R Allocate() {
return next_ < N ? regs_[next_++] : static_cast<R>(-1); }
30 std::pair<R, R> AllocatePair() {
31 if ((next_ + 2) <=
N) {
36 return {
static_cast<R>(-1),
static_cast<R>(-1)};
44template <
typename R,
size_t N>
45SimpleAllocator(
const R (&)[
N]) -> SimpleAllocator<R, N>;
54 bool should_assign_stack_locations,
59 if (parameter_info !=
nullptr) {
64 const intptr_t max_arguments_in_registers =
65 !
target.IsNull() ?
target.MaxNumberOfParametersInRegisters(zone) : 0;
69 intptr_t stack_parameters_size_in_words = 0;
70 for (intptr_t
i = 0;
i < argc; ++
i) {
71 auto rep = argument_rep(
i);
74 if (
i < max_arguments_in_registers) {
77#if defined(TARGET_ARCH_IS_32_BIT)
78 if (
auto [lo_reg, hi_reg] = cpu_allocator.AllocatePair();
83 if (
auto reg = cpu_allocator.Allocate(); reg !=
kNoRegister) {
96 if (
auto reg = cpu_allocator.Allocate(); reg !=
kNoRegister) {
108 intptr_t size_in_words;
126 stack_parameters_size_in_words += size_in_words;
129 if (parameter_info !=
nullptr) {
130 (*parameter_info)[
i] = {location, rep};
134 if (parameter_info ==
nullptr || !should_assign_stack_locations) {
135 return stack_parameters_size_in_words;
140 const intptr_t offset_to_last_parameter_slot_from_fp =
142 intptr_t offset_in_words_from_fp = offset_to_last_parameter_slot_from_fp;
143 for (intptr_t
i = argc - 1;
i >= 0; --
i) {
144 auto& [location, representation] = (*parameter_info)[
i];
149 switch (representation) {
169 offset_in_words_from_fp += 1;
179 (offset_in_words_from_fp - offset_to_last_parameter_slot_from_fp) ==
180 stack_parameters_size_in_words);
182 return stack_parameters_size_in_words;
#define RELEASE_ASSERT(cond)
void TruncateTo(intptr_t length)
void EnsureLength(intptr_t new_length, const T &default_value)
static Location StackSlot(intptr_t stack_index, Register base)
static Location Pair(Location first, Location second)
static Location FpuRegisterLocation(FpuRegister reg)
static Location DoubleStackSlot(intptr_t stack_index, Register base)
static Location RegisterLocation(Register reg)
Dart_NativeFunction function
constexpr intptr_t kDoubleSpillFactor
constexpr intptr_t kIntSpillFactor
intptr_t ComputeCallingConvention(Zone *zone, const Function &target, intptr_t argc, std::function< Representation(intptr_t)> argument_rep, bool should_assign_stack_locations, ParameterInfoArray *parameter_info)
const FpuRegister kNoFpuRegister
static void * Allocate(uword size, Zone *zone)
static constexpr Register kCpuRegistersForArgs[]
static constexpr FpuRegister kFpuRegistersForArgs[]
intptr_t param_end_from_fp