Skip to content

Commit e66fd67

Browse files
Revert "Fix passing struct by value on aarch64"
This reverts commit 482b37f. That was actually a bug in python, see <https://bugs.python.org/issue30353>.
1 parent 9429968 commit e66fd67

1 file changed

Lines changed: 8 additions & 31 deletions

File tree

src/aarch64/ffi.c

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -238,18 +238,13 @@ is_vfp_type (const ffi_type *ty)
238238
state.
239239
240240
The terse state variable names match the names used in the AARCH64
241-
PCS.
242-
243-
The struct area is allocated downwards from the top of the argument
244-
area. It is used to hold copies of structures passed by value that are
245-
bigger than 16 bytes. */
241+
PCS. */
246242

247243
struct arg_state
248244
{
249245
unsigned ngrn; /* Next general-purpose register number. */
250246
unsigned nsrn; /* Next vector register number. */
251247
size_t nsaa; /* Next stack offset. */
252-
size_t next_struct_area; /* Place to allocate big structs. */
253248

254249
#if defined (__APPLE__)
255250
unsigned allocating_variadic;
@@ -258,12 +253,11 @@ struct arg_state
258253

259254
/* Initialize a procedure call argument marshalling state. */
260255
static void
261-
arg_init (struct arg_state *state, size_t size)
256+
arg_init (struct arg_state *state)
262257
{
263258
state->ngrn = 0;
264259
state->nsrn = 0;
265260
state->nsaa = 0;
266-
state->next_struct_area = size;
267261
#if defined (__APPLE__)
268262
state->allocating_variadic = 0;
269263
#endif
@@ -292,21 +286,6 @@ allocate_to_stack (struct arg_state *state, void *stack,
292286
return (char *)stack + nsaa;
293287
}
294288

295-
/* Allocate and copy a structure that is passed by value on the stack and
296-
return a pointer to it. */
297-
static void *
298-
allocate_and_copy_struct_to_stack (struct arg_state *state, void *stack,
299-
size_t alignment, size_t size, void *value)
300-
{
301-
size_t dest = state->next_struct_area - size;
302-
303-
/* Round down to the natural alignment of the value. */
304-
dest = ALIGN_DOWN (dest, alignment);
305-
state->next_struct_area = dest;
306-
307-
return memcpy ((char *) stack + dest, value, size);
308-
}
309-
310289
static ffi_arg
311290
extend_integer_type (void *source, int type)
312291
{
@@ -612,14 +591,13 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
612591
frame = stack + stack_bytes;
613592
rvalue = (rsize ? frame + 32 : orig_rvalue);
614593

615-
arg_init (&state, stack_bytes);
594+
arg_init (&state);
616595
for (i = 0, nargs = cif->nargs; i < nargs; i++)
617596
{
618597
ffi_type *ty = cif->arg_types[i];
619598
size_t s = ty->size;
620599
void *a = avalue[i];
621600
int h, t;
622-
void *dest;
623601

624602
t = ty->type;
625603
switch (t)
@@ -667,6 +645,8 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
667645
case FFI_TYPE_STRUCT:
668646
case FFI_TYPE_COMPLEX:
669647
{
648+
void *dest;
649+
670650
h = is_vfp_type (ty);
671651
if (h)
672652
{
@@ -684,12 +664,9 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
684664
else if (s > 16)
685665
{
686666
/* If the argument is a composite type that is larger than 16
687-
bytes, then the argument is copied to memory, and
667+
bytes, then the argument has been copied to memory, and
688668
the argument is replaced by a pointer to the copy. */
689-
dest = allocate_and_copy_struct_to_stack (&state, stack,
690-
ty->alignment, s,
691-
avalue[i]);
692-
a = &dest;
669+
a = &avalue[i];
693670
t = FFI_TYPE_POINTER;
694671
s = sizeof (void *);
695672
goto do_pointer;
@@ -858,7 +835,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
858835
int i, h, nargs, flags;
859836
struct arg_state state;
860837

861-
arg_init (&state, cif->bytes);
838+
arg_init (&state);
862839

863840
for (i = 0, nargs = cif->nargs; i < nargs; i++)
864841
{

0 commit comments

Comments
 (0)