fixed a problem in breaking out of an initial context
This commit is contained in:
parent
801b6d92d4
commit
19735bac69
@ -439,8 +439,9 @@ PROCESS TESTING
|
|||||||
'====================' dump.
|
'====================' dump.
|
||||||
([ :a :b | "a := 20." b := [ a + 20 ]. b value.] value: 99 value: 100) dump.
|
([ :a :b | "a := 20." b := [ a + 20 ]. b value.] value: 99 value: 100) dump.
|
||||||
'====================' dump.
|
'====================' dump.
|
||||||
[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] value dump. ## not sufficient arguments. it must fail
|
|
||||||
|
|
||||||
|
[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] value dump. ## not sufficient arguments. it must fail
|
||||||
|
"[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] on: Exception do: [:ex | 'Exception' dump]."
|
||||||
|
|
||||||
"
|
"
|
||||||
FFI isNil dump.
|
FFI isNil dump.
|
||||||
|
@ -59,7 +59,10 @@
|
|||||||
10 timesRepeat: ['BLOCK #1' dump. Processor activeProcess sleep: 1.].
|
10 timesRepeat: ['BLOCK #1' dump. Processor activeProcess sleep: 1.].
|
||||||
s1 signal
|
s1 signal
|
||||||
] newProcess.
|
] newProcess.
|
||||||
t2 := [ 5 timesRepeat: ['BLOCK #2' dump]. s2 signal. ] newProcess.
|
t2 := [
|
||||||
|
5 timesRepeat: ['BLOCK #2' dump. "Processor activeProcess sleep: 1." ].
|
||||||
|
'SIGNALLING S2...' dump. s2 signal.
|
||||||
|
] newProcess.
|
||||||
|
|
||||||
t1 resume.
|
t1 resume.
|
||||||
t2 resume.
|
t2 resume.
|
||||||
@ -67,15 +70,18 @@
|
|||||||
Processor signal: s3 after: 10.
|
Processor signal: s3 after: 10.
|
||||||
|
|
||||||
'STARTED t1 and t2' dump.
|
'STARTED t1 and t2' dump.
|
||||||
s1 wait.
|
|
||||||
s2 wait.
|
|
||||||
|
|
||||||
|
s2 wait.
|
||||||
|
's2 WAITED....' dump.
|
||||||
|
s1 wait.
|
||||||
|
's1 WAITED....' dump.
|
||||||
|
|
||||||
|
|
||||||
|
'WAITING ON S3...' dump.
|
||||||
##Processor unsignal: s3.
|
##Processor unsignal: s3.
|
||||||
s3 wait.
|
s3 wait.
|
||||||
|
|
||||||
10 timesRepeat: ['WAITED t1 and t2' dump].
|
10 timesRepeat: ['WAITED t1 and t2' dump].
|
||||||
|
|
||||||
|
|
||||||
'END OF MAIN' dump.
|
'END OF MAIN' dump.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2620,8 +2620,6 @@ static int compile_method_primitive (stix_t* stix)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GET_TOKEN (stix);
|
GET_TOKEN (stix);
|
||||||
print_oocs (&stix->c->tok.name);
|
|
||||||
printf ("]]]]]]]]]]]]]]]]]]]]]]\n");
|
|
||||||
if (is_token_keyword(stix, VOCA_PRIMITIVE_COLON))
|
if (is_token_keyword(stix, VOCA_PRIMITIVE_COLON))
|
||||||
{
|
{
|
||||||
GET_TOKEN (stix);
|
GET_TOKEN (stix);
|
||||||
|
@ -207,7 +207,6 @@ static STIX_INLINE void vm_gettime (stix_t* stix, stix_ntime_t* now)
|
|||||||
#else
|
#else
|
||||||
# error UNSUPPORTED CLOCKS_PER_SEC
|
# error UNSUPPORTED CLOCKS_PER_SEC
|
||||||
#endif
|
#endif
|
||||||
printf ("%05ld %010ld\n", (long)now->sec, (long)now->nsec);
|
|
||||||
|
|
||||||
#elif defined(HAVE_CLOCK_GETTIME)
|
#elif defined(HAVE_CLOCK_GETTIME)
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
@ -350,6 +349,7 @@ static void switch_to_process (stix_t* stix, stix_oop_process_t proc, int new_st
|
|||||||
static STIX_INLINE stix_oop_process_t find_next_runnable_process (stix_t* stix)
|
static STIX_INLINE stix_oop_process_t find_next_runnable_process (stix_t* stix)
|
||||||
{
|
{
|
||||||
stix_oop_process_t npr;
|
stix_oop_process_t npr;
|
||||||
|
|
||||||
STIX_ASSERT (stix->processor->active->state == STIX_SMOOI_TO_OOP(PROC_STATE_RUNNING));
|
STIX_ASSERT (stix->processor->active->state == STIX_SMOOI_TO_OOP(PROC_STATE_RUNNING));
|
||||||
npr = stix->processor->active->next;
|
npr = stix->processor->active->next;
|
||||||
if ((stix_oop_t)npr == stix->_nil) npr = stix->processor->runnable_head;
|
if ((stix_oop_t)npr == stix->_nil) npr = stix->processor->runnable_head;
|
||||||
@ -499,6 +499,7 @@ static void terminate_process (stix_t* stix, stix_oop_process_t proc)
|
|||||||
{
|
{
|
||||||
/* no runnable process after termination */
|
/* no runnable process after termination */
|
||||||
STIX_ASSERT (stix->processor->active == stix->nil_process);
|
STIX_ASSERT (stix->processor->active == stix->nil_process);
|
||||||
|
printf ("NO RUNNABLE PROCESS AFTER PROCESS TERMINATION in terminate_process()...\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -574,7 +575,7 @@ static void suspend_process (stix_t* stix, stix_oop_process_t proc)
|
|||||||
if (nrp == proc)
|
if (nrp == proc)
|
||||||
{
|
{
|
||||||
/* no runnable process after suspension */
|
/* no runnable process after suspension */
|
||||||
/*printf ("NO RUNNABLE PROCESS AFTER SUPSENDISION\n");*/
|
/*printf ("NO RUNNABLE PROCESS AFTER PROCESS SUPSENDISION in suspend_process\n");*/
|
||||||
sleep_active_process (stix, PROC_STATE_RUNNABLE);
|
sleep_active_process (stix, PROC_STATE_RUNNABLE);
|
||||||
unchain_from_processor (stix, proc, PROC_STATE_SUSPENDED);
|
unchain_from_processor (stix, proc, PROC_STATE_SUSPENDED);
|
||||||
|
|
||||||
@ -3106,7 +3107,8 @@ int stix_execute (stix_t* stix)
|
|||||||
}
|
}
|
||||||
while (stix->sem_heap_count > 0);
|
while (stix->sem_heap_count > 0);
|
||||||
}
|
}
|
||||||
else if (stix->processor->active == stix->nil_process)
|
|
||||||
|
if (stix->processor->active == stix->nil_process)
|
||||||
{
|
{
|
||||||
/* no more waiting semaphore and no more process */
|
/* no more waiting semaphore and no more process */
|
||||||
STIX_ASSERT (stix->processor->tally = STIX_SMOOI_TO_OOP(0));
|
STIX_ASSERT (stix->processor->tally = STIX_SMOOI_TO_OOP(0));
|
||||||
@ -3841,20 +3843,25 @@ printf (">>>>>>>>>>>>>>>> METHOD RETURN FROM WITHIN A BLOCK. NON-LOCAL RETURN..
|
|||||||
/* push the return value to the stack of the new active context */
|
/* push the return value to the stack of the new active context */
|
||||||
ACTIVE_STACK_PUSH (stix, return_value);
|
ACTIVE_STACK_PUSH (stix, return_value);
|
||||||
|
|
||||||
if ((stix_oop_t)stix->active_context->sender == stix->_nil)
|
if (stix->active_context == stix->initial_context)
|
||||||
{
|
{
|
||||||
/* the sender of the intial context is nil.
|
/* the new active context is the fake initial context.
|
||||||
* use this fact to tell an initial context from a normal context. */
|
* this context can't get executed further. */
|
||||||
/* STIX_ASSERT (stix->active_context->receiver_or_source == stix->_nil);*/
|
STIX_ASSERT ((stix_oop_t)stix->active_context->sender == stix->_nil);
|
||||||
|
STIX_ASSERT (STIX_CLASSOF(stix, stix->active_context) == stix->_method_context);
|
||||||
/* when sender is nil, the following condition must be true.
|
STIX_ASSERT (stix->active_context->receiver_or_source == stix->_nil);
|
||||||
* but it's not always true the other way around */
|
|
||||||
STIX_ASSERT (stix->active_context == stix->processor->active->initial_context);
|
STIX_ASSERT (stix->active_context == stix->processor->active->initial_context);
|
||||||
|
STIX_ASSERT (stix->active_context->origin == stix->processor->active->initial_context->origin);
|
||||||
|
STIX_ASSERT (stix->active_context->origin == stix->active_context);
|
||||||
|
|
||||||
|
/* NOTE: this condition is true for the processified block context also.
|
||||||
|
* stix->active_context->origin == stix->processor->active->initial_context->origin
|
||||||
|
* however, the check here is done after context switching and
|
||||||
|
* the processified block check is done against the context before switching */
|
||||||
|
|
||||||
#if defined(STIX_DEBUG_EXEC_001)
|
#if defined(STIX_DEBUG_EXEC_001)
|
||||||
printf ("<<<RETURNIGN TO THE INITIAL CONTEXT>>> TERMINATING SP => %ld\n", (long int)stix->sp);
|
printf ("<<<RETURNING TO THE INITIAL CONTEXT>>> TERMINATING SP => %ld\n", (long int)stix->sp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* 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);
|
||||||
|
|
||||||
@ -3867,6 +3874,7 @@ printf ("<<<RETURNIGN TO THE INITIAL CONTEXT>>> TERMINATING SP => %ld\n", (long
|
|||||||
* the caller to stix_execute() can fetch it to return it to the system */
|
* the caller to stix_execute() can fetch it to return it to the system */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -4081,11 +4089,21 @@ oops:
|
|||||||
|
|
||||||
int stix_invoke (stix_t* stix, const stix_oocs_t* objname, const stix_oocs_t* mthname)
|
int stix_invoke (stix_t* stix, const stix_oocs_t* objname, const stix_oocs_t* mthname)
|
||||||
{
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
|
STIX_ASSERT (stix->initial_context == STIX_NULL);
|
||||||
|
STIX_ASSERT (stix->active_context == STIX_NULL);
|
||||||
|
STIX_ASSERT (stix->active_method == STIX_NULL);
|
||||||
|
|
||||||
if (start_initial_process_and_context (stix, objname, mthname) <= -1) return -1;
|
if (start_initial_process_and_context (stix, objname, mthname) <= -1) return -1;
|
||||||
return stix_execute (stix);
|
stix->initial_context = stix->processor->active->initial_context;
|
||||||
/* TODO: reset stix->active_context & stix->active_method to STIX_NULL
|
|
||||||
*
|
n = stix_execute (stix);
|
||||||
* TODO: remove the process. set processor->tally to zero. processor->active to nil_process...
|
|
||||||
*/
|
/* TODO: reset processor fields. set processor->tally to zero. processor->active to nil_process... */
|
||||||
|
stix->initial_context = STIX_NULL;
|
||||||
|
stix->active_context = STIX_NULL;
|
||||||
|
stix->active_method = STIX_NULL;
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,6 +354,8 @@ printf ("STARTING GC curheap base %p ptr %p newheap base %p ptr %p\n",
|
|||||||
*stix->tmp_stack[i] = stix_moveoop (stix, *stix->tmp_stack[i]);
|
*stix->tmp_stack[i] = stix_moveoop (stix, *stix->tmp_stack[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stix->initial_context)
|
||||||
|
stix->initial_context = (stix_oop_context_t)stix_moveoop (stix, (stix_oop_t)stix->initial_context);
|
||||||
if (stix->active_context)
|
if (stix->active_context)
|
||||||
stix->active_context = (stix_oop_context_t)stix_moveoop (stix, (stix_oop_t)stix->active_context);
|
stix->active_context = (stix_oop_context_t)stix_moveoop (stix, (stix_oop_t)stix->active_context);
|
||||||
if (stix->active_method)
|
if (stix->active_method)
|
||||||
|
@ -611,11 +611,22 @@ struct stix_cmgr_t
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
* COMPILER FEATURE TEST MACROS
|
* COMPILER FEATURE TEST MACROS
|
||||||
* =========================================================================*/
|
* =========================================================================*/
|
||||||
#if defined(_INTELC32_) && !defined(__has_builtin)
|
#if !defined(__has_builtin)
|
||||||
/* intel c code builder 1.0 ended up with an error without this override */
|
/* intel c code builder 1.0 ended up with an error without this override */
|
||||||
#define __has_builtin(x) 0
|
#define __has_builtin(x) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
#if !defined(__is_identifier)
|
||||||
|
#define __is_identifier(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(__has_attribute)
|
||||||
|
#define __has_attribute(x) 0
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#if defined(__has_builtin)
|
#if defined(__has_builtin)
|
||||||
#if __has_builtin(__builtin_ctz)
|
#if __has_builtin(__builtin_ctz)
|
||||||
#define STIX_HAVE_BUILTIN_CTZ
|
#define STIX_HAVE_BUILTIN_CTZ
|
||||||
@ -682,20 +693,8 @@ struct stix_cmgr_t
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
#if !defined(__has_builtin)
|
|
||||||
#define __has_builtin(x) 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(__is_identifier)
|
|
||||||
#define __is_identifier(x) 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(__has_attribute)
|
|
||||||
#define __has_attribute(x) 0
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -797,6 +797,7 @@ struct stix_t
|
|||||||
stix_oow_t tmp_count;
|
stix_oow_t tmp_count;
|
||||||
|
|
||||||
/* == EXECUTION REGISTERS == */
|
/* == EXECUTION REGISTERS == */
|
||||||
|
stix_oop_context_t initial_context; /* fake initial context */
|
||||||
stix_oop_context_t active_context;
|
stix_oop_context_t active_context;
|
||||||
stix_oop_method_t active_method;
|
stix_oop_method_t active_method;
|
||||||
stix_oob_t* active_code;
|
stix_oob_t* active_code;
|
||||||
|
Loading…
Reference in New Issue
Block a user