changed to store the stack poitner of the active process before context switching. the stored stack pointer is used to restore stix->sp when a method return is performed
This commit is contained in:
parent
8f91b7adc3
commit
fc7a44ba7d
@ -432,7 +432,11 @@ static STIX_INLINE int activate_new_method (stix_t* stix, stix_oop_method_t mth)
|
|||||||
*
|
*
|
||||||
* if no temporaries exist, the initial sp is -1.
|
* if no temporaries exist, the initial sp is -1.
|
||||||
*/
|
*/
|
||||||
|
#if defined(STIX_USE_PROCSTK)
|
||||||
|
/* ctx->sp will be set further down */
|
||||||
|
#else
|
||||||
ctx->sp = STIX_SMOOI_TO_OOP(ntmprs - 1);
|
ctx->sp = STIX_SMOOI_TO_OOP(ntmprs - 1);
|
||||||
|
#endif
|
||||||
ctx->ntmprs = STIX_SMOOI_TO_OOP(ntmprs);
|
ctx->ntmprs = STIX_SMOOI_TO_OOP(ntmprs);
|
||||||
ctx->method_or_nargs = (stix_oop_t)mth;
|
ctx->method_or_nargs = (stix_oop_t)mth;
|
||||||
/* the 'home' field of a method context is always stix->_nil.
|
/* the 'home' field of a method context is always stix->_nil.
|
||||||
@ -472,6 +476,14 @@ static STIX_INLINE int activate_new_method (stix_t* stix, stix_oop_method_t mth)
|
|||||||
|
|
||||||
STIX_ASSERT (stix->sp >= -1);
|
STIX_ASSERT (stix->sp >= -1);
|
||||||
|
|
||||||
|
#if defined(STIX_USE_PROCSTK)
|
||||||
|
/* when process stack is used, the stack pointer in a context
|
||||||
|
* is a stack pointer of a process before it is activated */
|
||||||
|
ctx->sp = STIX_SMOOI_TO_OOP(stix->sp);
|
||||||
|
#else
|
||||||
|
/* do nothing */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* switch the active context */
|
/* switch the active context */
|
||||||
SWITCH_ACTIVE_CONTEXT (stix, ctx);
|
SWITCH_ACTIVE_CONTEXT (stix, ctx);
|
||||||
|
|
||||||
@ -3010,6 +3022,13 @@ printf (">>>>>>>>>>>>>>>> METHOD RETURN FROM WITHIN A BLOCK. NON-LOCAL RETURN..
|
|||||||
stix->active_context->origin->ip = STIX_SMOOI_TO_OOP(STIX_SMOOI_MIN);
|
stix->active_context->origin->ip = STIX_SMOOI_TO_OOP(STIX_SMOOI_MIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STIX_ASSERT (STIX_CLASSOF(stix, stix->active_context->origin) == stix->_method_context);
|
||||||
|
#if defined(STIX_USE_PROCSTK)
|
||||||
|
/* restore the stack pointer */
|
||||||
|
stix->sp = STIX_OOP_TO_SMOOI(stix->active_context->origin->sp);
|
||||||
|
#else
|
||||||
|
/* do nothing */
|
||||||
|
#endif
|
||||||
SWITCH_ACTIVE_CONTEXT (stix, stix->active_context->origin->sender);
|
SWITCH_ACTIVE_CONTEXT (stix, stix->active_context->origin->sender);
|
||||||
|
|
||||||
/* push the return value to the stack of the new active context */
|
/* push the return value to the stack of the new active context */
|
||||||
@ -3026,17 +3045,12 @@ printf (">>>>>>>>>>>>>>>> METHOD RETURN FROM WITHIN A BLOCK. NON-LOCAL RETURN..
|
|||||||
STIX_ASSERT (stix->active_context == stix->processor->active->initial_context);
|
STIX_ASSERT (stix->active_context == stix->processor->active->initial_context);
|
||||||
|
|
||||||
#if defined(STIX_DEBUG_EXEC_001)
|
#if defined(STIX_DEBUG_EXEC_001)
|
||||||
printf ("<<<RETURNIGN TO THE INITIAL CONTEXT>>>\n");
|
printf ("<<<RETURNIGN TO THE INITIAL CONTEXT>>> TERMINATING SP => %ld\n", (long int)stix->sp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf ("TERMINATING SP.... %ld\n", (long int)stix->sp);
|
|
||||||
|
|
||||||
#if defined(STIX_USE_PROCSTK)
|
|
||||||
/* TODO: */
|
|
||||||
#else
|
|
||||||
/* the stack contains the final return value so the stack pointer must be 0. */
|
/* the stack contains the final return value so the stack pointer must be 0. */
|
||||||
STIX_ASSERT (stix->sp == 0);
|
STIX_ASSERT (stix->sp == 0);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (stix->option.trait & STIX_AWAIT_PROCS)
|
if (stix->option.trait & STIX_AWAIT_PROCS)
|
||||||
terminate_process (stix, stix->processor->active);
|
terminate_process (stix, stix->processor->active);
|
||||||
|
@ -500,7 +500,9 @@ struct stix_context_t
|
|||||||
/* SmallInteger, instruction pointer */
|
/* SmallInteger, instruction pointer */
|
||||||
stix_oop_t ip;
|
stix_oop_t ip;
|
||||||
|
|
||||||
/* SmallInteger, stack pointer */
|
/* SmallInteger, stack pointer.
|
||||||
|
* For a method context, this pointer stores the stack pointer
|
||||||
|
* of the active process before it gets activated. */
|
||||||
stix_oop_t sp;
|
stix_oop_t sp;
|
||||||
|
|
||||||
/* SmallInteger. Number of temporaries.
|
/* SmallInteger. Number of temporaries.
|
||||||
|
Loading…
Reference in New Issue
Block a user