Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Replace goobledigoobs trick with consistent and future-proof assembly. #163

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions Stackless/core/slp_transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ extern int slp_switch(void);
#endif

/* a write only variable used to prevent overly optimisation */
intptr_t *global_goobledigoobs;
static int
climb_stack_and_transfer(PyCStackObject **cstprev, PyCStackObject *cst,
PyTaskletObject *prev)
Expand All @@ -96,15 +95,9 @@ climb_stack_and_transfer(PyCStackObject **cstprev, PyCStackObject *cst,
intptr_t probe;
register ptrdiff_t needed = &probe - ts->st.cstack_base;
/* in rare cases, the need might have vanished due to the recursion */
register intptr_t *goobledigoobs;
if (needed > 0) {
goobledigoobs = alloca(needed * sizeof(intptr_t));
if (goobledigoobs == NULL)
return -1;
/* hinder the compiler to optimise away
goobledigoobs and the alloca call.
This happens with gcc 4.7.x and -O2 */
global_goobledigoobs = goobledigoobs;
void* stack_ptr_tmp = alloca(needed * sizeof(intptr_t));
__asm__ volatile("" : : "g"(stack_ptr_tmp) : "memory");
}
return slp_transfer(cstprev, cst, prev);
}
Expand Down
6 changes: 2 additions & 4 deletions Stackless/core/stacklesseval.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,9 @@ climb_stack_and_eval_frame(PyFrameObject *f)
intptr_t probe;
ptrdiff_t needed = &probe - ts->st.cstack_base;
/* in rare cases, the need might have vanished due to the recursion */
intptr_t *goobledigoobs;
if (needed > 0) {
goobledigoobs = alloca(needed * sizeof(intptr_t));
if (goobledigoobs == NULL)
return NULL;
void* stack_ptr_tmp = alloca(needed * sizeof(intptr_t));
__asm__ volatile("" : : "g"(stack_ptr_tmp) : "memory");
}
return slp_eval_frame(f);
}
Expand Down