switched many hardcoded printf() statements to STIX_LOGX()

This commit is contained in:
hyunghwan.chung 2016-06-05 18:01:35 +00:00
parent f43240ca4d
commit 512df8876b
10 changed files with 256 additions and 315 deletions

View File

@ -4230,8 +4230,9 @@ the compiler must collect all source method string collected so far.
need to write code to collect string. need to write code to collect string.
*/ */
/* TODO: call stix_decode only if decoding is enabled... */ #if defined(STIX_DEBUG_COMPILER)
stix_decode (stix, &stix->c->cls.fqn, mth); stix_decode (stix, mth, &stix->c->cls.fqn);
#endif
stix_poptmps (stix, tmp_count); tmp_count = 0; stix_poptmps (stix, tmp_count); tmp_count = 0;
@ -4545,14 +4546,7 @@ static int __compile_class_definition (stix_t* stix, int extend)
{ {
int super_is_nil = 0; int super_is_nil = 0;
if (STIX_LOG_ENABLED(stix,STIX_LOG_COMPILER | STIX_LOG_DEBUG)) STIX_INFO2 (stix, "Defining a class %.*S\n", stix->c->cls.fqn.len, stix->c->cls.fqn.ptr);
{
stix_logbfmt (stix,
STIX_LOG_COMPILER | STIX_LOG_DEBUG,
"Defining a class %.*S\n",
stix->c->cls.fqn.len,
stix->c->cls.fqn.ptr);
}
if (stix->c->tok.type == STIX_IOTOK_LPAREN) if (stix->c->tok.type == STIX_IOTOK_LPAREN)
{ {
@ -4826,14 +4820,7 @@ static int __compile_pooldic_definition (stix_t* stix)
return -1; return -1;
} }
if (STIX_LOG_ENABLED(stix,STIX_LOG_COMPILER | STIX_LOG_DEBUG)) STIX_INFO2 (stix, "Defining a pool dictionary %.*S\n", stix->c->cls.fqn.len, stix->c->cls.fqn.ptr);
{
stix_logbfmt (stix,
STIX_LOG_COMPILER | STIX_LOG_DEBUG,
"Defining a pool dictionary %.*S\n",
stix->c->cls.fqn.len,
stix->c->cls.fqn.ptr);
}
GET_TOKEN (stix); GET_TOKEN (stix);
@ -5199,5 +5186,3 @@ void stix_getsynerr (stix_t* stix, stix_synerr_t* synerr)
STIX_ASSERT (stix->c != STIX_NULL); STIX_ASSERT (stix->c != STIX_NULL);
if (synerr) *synerr = stix->c->synerr; if (synerr) *synerr = stix->c->synerr;
} }

View File

@ -184,7 +184,7 @@ void print_object (stix_t* stix, unsigned int mask, stix_oop_t oop)
} }
else else
{ {
stix_logbfmt (stix, mask, "instance of %.*S - (%p)", STIX_OBJ_GET_SIZE(c->name), ((stix_oop_char_t)c->name)->slot, oop); stix_logbfmt (stix, mask, "instance of %.*S(%p)", STIX_OBJ_GET_SIZE(c->name), ((stix_oop_char_t)c->name)->slot, oop);
} }
} }
} }

View File

@ -27,12 +27,12 @@
#include "stix-prv.h" #include "stix-prv.h"
#define LOG_MASK_INST (STIX_LOG_COMPILER | STIX_LOG_INFO) #define DECODE_LOG_MASK (STIX_LOG_MNEMONIC)
#define LOG_INST_0(stix,fmt) if (STIX_LOG_ENABLED(stix,LOG_MASK_INST)) stix_logbfmt(stix, LOG_MASK_INST, "\t" fmt "\n") #define LOG_INST_0(stix,fmt) STIX_LOG0(stix, DECODE_LOG_MASK, "\t" fmt "\n")
#define LOG_INST_1(stix,fmt,a1) if (STIX_LOG_ENABLED(stix,LOG_MASK_INST)) stix_logbfmt(stix, LOG_MASK_INST, "\t" fmt "\n",a1) #define LOG_INST_1(stix,fmt,a1) STIX_LOG1(stix, DECODE_LOG_MASK, "\t" fmt "\n",a1)
#define LOG_INST_2(stix,fmt,a1,a2) if (STIX_LOG_ENABLED(stix,LOG_MASK_INST)) stix_logbfmt(stix, LOG_MASK_INST, "\t" fmt "\n", a1, a2) #define LOG_INST_2(stix,fmt,a1,a2) STIX_LOG2(stix, DECODE_LOG_MASK, "\t" fmt "\n", a1, a2)
#define LOG_INST_3(stix,fmt,a1,a2,a3) if (STIX_LOG_ENABLED(stix,LOG_MASK_INST)) stix_logbfmt(stix, LOG_MASK_INST, "\t" fmt "\n", a1, a2, a3) #define LOG_INST_3(stix,fmt,a1,a2,a3) STIX_LOG3(stix, DECODE_LOG_MASK, "\t" fmt "\n", a1, a2, a3)
#define FETCH_BYTE_CODE(stix) (cdptr[ip++]) #define FETCH_BYTE_CODE(stix) (cdptr[ip++])
#define FETCH_BYTE_CODE_TO(stix,v_ooi) (v_ooi = FETCH_BYTE_CODE(stix)) #define FETCH_BYTE_CODE_TO(stix,v_ooi) (v_ooi = FETCH_BYTE_CODE(stix))
@ -47,7 +47,7 @@
#endif #endif
/* TODO: check if ip shoots beyond the maximum length in fetching code and parameters */ /* TODO: check if ip shoots beyond the maximum length in fetching code and parameters */
int stix_decode (stix_t* stix, const stix_oocs_t* classfqn, stix_oop_method_t mth) int stix_decode (stix_t* stix, stix_oop_method_t mth, const stix_oocs_t* classfqn)
{ {
stix_oob_t bcode, * cdptr; stix_oob_t bcode, * cdptr;
stix_oow_t ip = 0, cdlen; stix_oow_t ip = 0, cdlen;
@ -56,8 +56,10 @@ int stix_decode (stix_t* stix, const stix_oocs_t* classfqn, stix_oop_method_t mt
cdptr = STIX_METHOD_GET_CODE_BYTE(mth); cdptr = STIX_METHOD_GET_CODE_BYTE(mth);
cdlen = STIX_METHOD_GET_CODE_SIZE(mth); cdlen = STIX_METHOD_GET_CODE_SIZE(mth);
if (STIX_LOG_ENABLED(stix, LOG_MASK_INST)) if (classfqn)
stix_logbfmt (stix, LOG_MASK_INST, "%.*S>>%O\n", classfqn->len, classfqn->ptr, mth->name); STIX_LOG3 (stix, DECODE_LOG_MASK, "%.*S>>%O\n", classfqn->len, classfqn->ptr, mth->name);
else
STIX_LOG2 (stix, DECODE_LOG_MASK, "%O>>%O\n", mth->owner, mth->name);
/* TODO: check if ip increases beyon bcode when fetching parameters too */ /* TODO: check if ip increases beyon bcode when fetching parameters too */
while (ip < cdlen) while (ip < cdlen)
@ -185,7 +187,7 @@ int stix_decode (stix_t* stix, const stix_oocs_t* classfqn, stix_oop_method_t mt
case BCODE_PUSH_LITERAL_7: case BCODE_PUSH_LITERAL_7:
b1 = bcode & 0x7; /* low 3 bits */ b1 = bcode & 0x7; /* low 3 bits */
push_literal: push_literal:
LOG_INST_1 (stix, "push_literal %zd", b1); LOG_INST_1 (stix, "push_literal @%zd", b1);
break; break;
/* ------------------------------------------------- */ /* ------------------------------------------------- */
@ -213,16 +215,16 @@ int stix_decode (stix_t* stix, const stix_oocs_t* classfqn, stix_oop_method_t mt
{ {
if ((bcode >> 2) & 1) if ((bcode >> 2) & 1)
{ {
LOG_INST_1 (stix, "pop_into_object %zd", b1); LOG_INST_1 (stix, "pop_into_object @%zd", b1);
} }
else else
{ {
LOG_INST_1 (stix, "store_into_object %zd", b1); LOG_INST_1 (stix, "store_into_object @%zd", b1);
} }
} }
else else
{ {
LOG_INST_1 (stix, "push_object %zd", b1); LOG_INST_1 (stix, "push_object @%zd", b1);
} }
break; break;

View File

@ -138,16 +138,19 @@
#endif #endif
#if defined(STIX_DEBUG_EXEC_001) #if defined(STIX_DEBUG_VM_EXEC)
# define DBGOUT_EXEC_0(fmt) printf(fmt "\n") # define LOG_MASK_INST (STIX_LOG_VM | STIX_LOG_MNEMONIC)
# define DBGOUT_EXEC_1(fmt,a1) printf(fmt "\n",a1)
# define DBGOUT_EXEC_2(fmt,a1,a2) printf(fmt "\n", a1, a2) # define LOG_INST_0(stix,fmt) STIX_LOG0(stix, LOG_MASK_INST, "\t" fmt "\n")
# define DBGOUT_EXEC_3(fmt,a1,a2,a3) printf(fmt "\n", a1, a2, a3) # define LOG_INST_1(stix,fmt,a1) STIX_LOG1(stix, LOG_MASK_INST, "\t" fmt "\n",a1)
# define LOG_INST_2(stix,fmt,a1,a2) STIX_LOG2(stix, LOG_MASK_INST, "\t" fmt "\n", a1, a2)
# define LOG_INST_3(stix,fmt,a1,a2,a3) STIX_LOG3(stix, LOG_MASK_INST, "\t" fmt "\n", a1, a2, a3)
#else #else
# define DBGOUT_EXEC_0(fmt) # define LOG_INST_0(stix,fmt)
# define DBGOUT_EXEC_1(fmt,a1) # define LOG_INST_1(stix,fmt,a1)
# define DBGOUT_EXEC_2(fmt,a1,a2) # define LOG_INST_2(stix,fmt,a1,a2)
# define DBGOUT_EXEC_3(fmt,a1,a2,a3) # define LOG_INST_3(stix,fmt,a1,a2,a3)
#endif #endif
@ -297,16 +300,16 @@ static stix_oop_process_t make_process (stix_t* stix, stix_oop_context_t c)
STIX_ASSERT ((stix_oop_t)c->sender == stix->_nil); STIX_ASSERT ((stix_oop_t)c->sender == stix->_nil);
#if defined(STIX_DEBUG_PROCESSOR) #if defined(STIX_DEBUG_VM_PROCESSOR)
printf ("PROCESS %p SIZE => %ld\n", proc, (long int)STIX_OBJ_GET_SIZE(proc)); STIX_LOG2 (stix, STIX_LOG_VM | STIX_LOG_DEBUG, "Processor - made process %O of size %zd\n", proc, STIX_OBJ_GET_SIZE(proc));
#endif #endif
return proc; return proc;
} }
static STIX_INLINE void sleep_active_process (stix_t* stix, int state) static STIX_INLINE void sleep_active_process (stix_t* stix, int state)
{ {
#if defined(STIX_DEBUG_PROCESSOR) #if defined(STIX_DEBUG_VM_PROCESSOR)
printf ("PROCESS-SWITCHING: PUT ACTIVE_CONTEXT TO SLEEP..%d %p\n", (int)stix->ip, stix->active_context); STIX_LOG3 (stix, STIX_LOG_VM | STIX_LOG_DEBUG, "Processor - put process %O context %O ip=%zd to sleep\n", stix->processor->active, stix->active_context, stix->ip);
#endif #endif
#if defined(STIX_USE_PROCSTK) #if defined(STIX_USE_PROCSTK)
@ -337,8 +340,8 @@ static STIX_INLINE void wake_new_process (stix_t* stix, stix_oop_process_t proc)
/* activate the suspended context of the new process */ /* activate the suspended context of the new process */
SWITCH_ACTIVE_CONTEXT (stix, proc->current_context); SWITCH_ACTIVE_CONTEXT (stix, proc->current_context);
#if defined(STIX_DEBUG_PROCESSOR) #if defined(STIX_DEBUG_VM_PROCESSOR)
printf ("PROCESS-SWITCHING: WAKE NEW PROCESS...%d %p\n", (int)stix->ip, stix->active_context); STIX_LOG3 (stix, STIX_LOG_VM | STIX_LOG_DEBUG, "Processor - woke up process %O context %O ip=%zd\n", stix->processor->active, stix->active_context, stix->ip);
#endif #endif
} }
@ -391,8 +394,8 @@ static STIX_INLINE int chain_into_processor (stix_t* stix, stix_oop_process_t pr
STIX_ASSERT (tally >= 0); STIX_ASSERT (tally >= 0);
if (tally >= STIX_SMOOI_MAX) if (tally >= STIX_SMOOI_MAX)
{ {
#if defined(STIX_DEBUG_PROCESSOR) #if defined(STIX_DEBUG_VM_PROCESSOR)
printf ("TOO MANY PROCESS\n"); STIX_LOG0 (stix, STIX_LOG_VM | STIX_LOG_FATAL, "Processor - too many process\n");
#endif #endif
stix->errnum = STIX_EPFULL; stix->errnum = STIX_EPFULL;
return -1; return -1;
@ -412,9 +415,6 @@ printf ("TOO MANY PROCESS\n");
tally++; tally++;
stix->processor->tally = STIX_SMOOI_TO_OOP(tally); stix->processor->tally = STIX_SMOOI_TO_OOP(tally);
#if defined(STIX_DEBUG_PROCESSOR)
printf ("INSERTED PROCESS %d TO PROCESSOR\n", (int)tally);
#endif
return 0; return 0;
} }
@ -492,6 +492,11 @@ static void terminate_process (stix_t* stix, stix_oop_process_t proc)
proc->state == STIX_SMOOI_TO_OOP(PROC_STATE_RUNNABLE)) proc->state == STIX_SMOOI_TO_OOP(PROC_STATE_RUNNABLE))
{ {
/* RUNNING/RUNNABLE ---> TERMINATED */ /* RUNNING/RUNNABLE ---> TERMINATED */
#if defined(STIX_DEBUG_VM_PROCESSOR)
STIX_LOG1 (stix, STIX_LOG_VM | STIX_LOG_DEBUG, "Processor - process %O RUNNING/RUNNABLE->TERMINATED\n", proc);
#endif
if (proc == stix->processor->active) if (proc == stix->processor->active)
{ {
stix_oop_process_t nrp; stix_oop_process_t nrp;
@ -510,7 +515,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"); STIX_LOG0 (stix, STIX_LOG_VM | STIX_LOG_DEBUG, "No runnable process after process termination\n");
} }
else else
{ {
@ -526,6 +531,10 @@ printf ("NO RUNNABLE PROCESS AFTER PROCESS TERMINATION in terminate_process()...
else if (proc->state == STIX_SMOOI_TO_OOP(PROC_STATE_SUSPENDED)) else if (proc->state == STIX_SMOOI_TO_OOP(PROC_STATE_SUSPENDED))
{ {
/* SUSPENDED ---> TERMINATED */ /* SUSPENDED ---> TERMINATED */
#if defined(STIX_DEBUG_VM_PROCESSOR)
STIX_LOG1 (stix, STIX_LOG_VM | STIX_LOG_DEBUG, "Processor - process %O SUSPENDED->TERMINATED\n", proc);
#endif
proc->state = STIX_SMOOI_TO_OOP(PROC_STATE_TERMINATED); proc->state = STIX_SMOOI_TO_OOP(PROC_STATE_TERMINATED);
proc->sp = STIX_SMOOI_TO_OOP(-1); /* invalidate the proce stack */ proc->sp = STIX_SMOOI_TO_OOP(-1); /* invalidate the proce stack */
@ -546,11 +555,13 @@ static void resume_process (stix_t* stix, stix_oop_process_t proc)
if (proc->state == STIX_SMOOI_TO_OOP(PROC_STATE_SUSPENDED)) if (proc->state == STIX_SMOOI_TO_OOP(PROC_STATE_SUSPENDED))
{ {
/* SUSPENED ---> RUNNING */ /* SUSPENED ---> RUNNING */
/*printf ("TO RESUME PROCESS = %p %d SUSPENED ----> RUNNING\n", proc, (int)STIX_OOP_TO_SMOOI(proc->state));*/
STIX_ASSERT ((stix_oop_t)proc->prev == stix->_nil); STIX_ASSERT ((stix_oop_t)proc->prev == stix->_nil);
STIX_ASSERT ((stix_oop_t)proc->next == stix->_nil); STIX_ASSERT ((stix_oop_t)proc->next == stix->_nil);
#if defined(STIX_DEBUG_VM_PROCESSOR)
STIX_LOG1 (stix, STIX_LOG_VM | STIX_LOG_DEBUG, "Processor - process %O SUSPENDED->RUNNING\n", proc);
#endif
chain_into_processor (stix, proc); /* TODO: error check */ chain_into_processor (stix, proc); /* TODO: error check */
/*proc->current_context = proc->initial_context;*/ /*proc->current_context = proc->initial_context;*/
@ -558,6 +569,7 @@ static void resume_process (stix_t* stix, stix_oop_process_t proc)
/* don't switch to this process. just set the state to RUNNING */ /* don't switch to this process. just set the state to RUNNING */
} }
#if 0 #if 0
else if (proc->state == STIX_SMOOI_TO_OOP(PROC_STATE_RUNNABLE)) else if (proc->state == STIX_SMOOI_TO_OOP(PROC_STATE_RUNNABLE))
{ {
@ -576,28 +588,29 @@ static void suspend_process (stix_t* stix, stix_oop_process_t proc)
{ {
/* RUNNING/RUNNABLE ---> SUSPENDED */ /* RUNNING/RUNNABLE ---> SUSPENDED */
#if defined(STIX_DEBUG_VM_PROCESSOR)
STIX_LOG1 (stix, STIX_LOG_VM | STIX_LOG_DEBUG, "Processor - process %O RUNNING/RUNNABLE->SUSPENDED\n", proc);
#endif
if (proc == stix->processor->active) if (proc == stix->processor->active)
{ {
stix_oop_process_t nrp; stix_oop_process_t nrp;
nrp = find_next_runnable_process (stix); nrp = find_next_runnable_process (stix);
/*printf ("TO SUSPEND...%p %d\n", proc, (int)STIX_OOP_TO_SMOOI(proc->state));*/
if (nrp == proc) if (nrp == proc)
{ {
/* no runnable process after suspension */ /* no runnable process after suspension */
/*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);
/* the last running/runnable process has been unchained /* the last running/runnable process has been unchained
* from the processor and set to SUSPENDED. the active * from the processor and set to SUSPENDED. the active
* process must be the nil nil process */ * process must be the nil process */
STIX_ASSERT (stix->processor->active == stix->nil_process); STIX_ASSERT (stix->processor->active == stix->nil_process);
} }
else else
{ {
/*printf ("SWITCHING TO XXXXXXXXXXXXXXXXXXXXx\n");*/
/* keep the unchained process at the runnable state for /* keep the unchained process at the runnable state for
* the immediate call to switch_to_process() below */ * the immediate call to switch_to_process() below */
unchain_from_processor (stix, proc, PROC_STATE_RUNNABLE); unchain_from_processor (stix, proc, PROC_STATE_RUNNABLE);
@ -631,6 +644,9 @@ static void yield_process (stix_t* stix, stix_oop_process_t proc)
* runnable process must be different from proc */ * runnable process must be different from proc */
if (nrp != proc) if (nrp != proc)
{ {
#if defined(STIX_DEBUG_VM_PROCESSOR)
STIX_LOG1 (stix, STIX_LOG_VM | STIX_LOG_DEBUG, "Processor - process %O RUNNING->RUNNABLE\n", proc);
#endif
switch_to_process (stix, nrp, PROC_STATE_RUNNABLE); switch_to_process (stix, nrp, PROC_STATE_RUNNABLE);
} }
} }
@ -669,7 +685,6 @@ static stix_oop_process_t signal_semaphore (stix_t* stix, stix_oop_semaphore_t s
if ((stix_oop_t)sem->waiting_head == stix->_nil) if ((stix_oop_t)sem->waiting_head == stix->_nil)
{ {
/*printf ("signal semaphore...1111\n");*/
/* no process is waiting on this semaphore */ /* no process is waiting on this semaphore */
count = STIX_OOP_TO_SMOOI(sem->count); count = STIX_OOP_TO_SMOOI(sem->count);
count++; count++;
@ -686,7 +701,6 @@ static stix_oop_process_t signal_semaphore (stix_t* stix, stix_oop_semaphore_t s
unchain_from_semaphore (stix, proc); unchain_from_semaphore (stix, proc);
resume_process (stix, proc); /* TODO: error check */ resume_process (stix, proc); /* TODO: error check */
/*printf ("signal semaphore...2222 DONE -> resumed process -> proc state %d\n", (int)STIX_OOP_TO_SMOOI(proc->state));*/
/* return the resumed process */ /* return the resumed process */
return proc; return proc;
@ -704,14 +718,12 @@ static void await_semaphore (stix_t* stix, stix_oop_semaphore_t sem)
/* it's already signalled */ /* it's already signalled */
count--; count--;
sem->count = STIX_SMOOI_TO_OOP(count); sem->count = STIX_SMOOI_TO_OOP(count);
/*printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - NO SUSPENDING ...................\n");*/
} }
else else
{ {
/* not signaled. need to wait */ /* not signaled. need to wait */
proc = stix->processor->active; proc = stix->processor->active;
/*printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - SUEPENDING ACTIVE PROCESS..........state=>[%d].....PROC %p\n", (int)STIX_OOP_TO_SMOOI(proc->state), proc);*/
/* suspend the active process */ /* suspend the active process */
suspend_process (stix, proc); suspend_process (stix, proc);
@ -720,7 +732,6 @@ static void await_semaphore (stix_t* stix, stix_oop_semaphore_t sem)
STIX_ASSERT (sem->waiting_tail == proc); STIX_ASSERT (sem->waiting_tail == proc);
/*printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - SUEPENDING ACTIVE PROCESS....XX......state=>[%d]..PROC %p\n", (int)STIX_OOP_TO_SMOOI(proc->state), proc);*/
STIX_ASSERT (stix->processor->active != proc); STIX_ASSERT (stix->processor->active != proc);
} }
} }
@ -848,7 +859,6 @@ static void delete_from_sem_heap (stix_t* stix, stix_ooi_t index)
lastsem->heap_index = STIX_SMOOI_TO_OOP(index); lastsem->heap_index = STIX_SMOOI_TO_OOP(index);
stix->sem_heap[index] = lastsem; stix->sem_heap[index] = lastsem;
if (SEM_HEAP_EARLIER_THAN(stix, lastsem, sem)) if (SEM_HEAP_EARLIER_THAN(stix, lastsem, sem))
sift_up_sem_heap (stix, index); sift_up_sem_heap (stix, index);
else else
@ -1020,9 +1030,6 @@ static STIX_INLINE int activate_new_method (stix_t* stix, stix_oop_method_t mth)
/* switch the active context */ /* switch the active context */
SWITCH_ACTIVE_CONTEXT (stix, ctx); SWITCH_ACTIVE_CONTEXT (stix, ctx);
#if defined(STIX_DEBUG_EXEC_001)
printf ("<<ENTERING>> SP=%d\n", (int)stix->sp);
#endif
return 0; return 0;
} }
@ -1035,12 +1042,8 @@ static stix_oop_method_t find_method (stix_t* stix, stix_oop_t receiver, const s
int dic_no; int dic_no;
/* TODO: implement method lookup cache */ /* TODO: implement method lookup cache */
#if defined(STIX_DEBUG_EXEC_002) #if defined(STIX_DEBUG_VM_METHOD_LOOKUP)
printf ("==== FINDING METHOD FOR %p [", receiver); STIX_LOG3 (stix, STIX_LOG_VM | STIX_LOG_DEBUG, "Method lookup - Finding method %.*S for %O in ", message->len, message->ptr, receiver);
print_object (stix, 0, receiver);
printf ("] - [");
print_oocs (message);
printf ("] in ");
#endif #endif
cls = (stix_oop_class_t)STIX_CLASSOF(stix, receiver); cls = (stix_oop_class_t)STIX_CLASSOF(stix, receiver);
@ -1049,20 +1052,16 @@ printf ("] in ");
/* receiver is a class object (an instance of Class) */ /* receiver is a class object (an instance of Class) */
c = receiver; c = receiver;
dic_no = STIX_CLASS_MTHDIC_CLASS; dic_no = STIX_CLASS_MTHDIC_CLASS;
#if defined(STIX_DEBUG_EXEC_002) #if defined(STIX_DEBUG_VM_METHOD_LOOKUP)
printf ("class method dictioanry of "); STIX_LOG1 (stix, STIX_LOG_VM | STIX_LOG_DEBUG, "Method lookup - class method dictionary of %O\n", c);
print_object(stix, 0, (stix_oop_t)((stix_oop_class_t)c)->name);
printf ("\n");
#endif #endif
} }
else else
{ {
c = (stix_oop_t)cls; c = (stix_oop_t)cls;
dic_no = STIX_CLASS_MTHDIC_INSTANCE; dic_no = STIX_CLASS_MTHDIC_INSTANCE;
#if defined(STIX_DEBUG_EXEC_002) #if defined(STIX_DEBUG_VM_METHOD_LOOKUP)
printf ("instance method dictioanry of "); STIX_LOG1 (stix, STIX_LOG_VM | STIX_LOG_DEBUG, "Method lookup - instance method dictionary of %O\n", c);
print_object(stix, 0, (stix_oop_t)((stix_oop_class_t)c)->name);
printf ("\n");
#endif #endif
} }
@ -1562,7 +1561,7 @@ static int prim_context_goto (stix_t* stix, stix_ooi_t nargs)
rcv = STIX_STACK_GET(stix, stix->sp - 1); rcv = STIX_STACK_GET(stix, stix->sp - 1);
if (STIX_CLASSOF(stix, rcv) != stix->_method_context) if (STIX_CLASSOF(stix, rcv) != stix->_method_context)
{ {
#if defined(STIX_DEBUG_EXEC_001) #if defined(STIX_DEBUG_VM_EXEC)
printf ("prim_context_goto: PRIMITVE RECEIVER IS NOT A METHOD CONTEXT\n"); printf ("prim_context_goto: PRIMITVE RECEIVER IS NOT A METHOD CONTEXT\n");
#endif #endif
return 0; return 0;
@ -1571,7 +1570,7 @@ printf ("prim_context_goto: PRIMITVE RECEIVER IS NOT A METHOD CONTEXT\n");
pc = STIX_STACK_GET(stix, stix->sp); pc = STIX_STACK_GET(stix, stix->sp);
if (!STIX_OOP_IS_SMOOI(pc) || STIX_OOP_TO_SMOOI(pc) < 0) if (!STIX_OOP_IS_SMOOI(pc) || STIX_OOP_TO_SMOOI(pc) < 0)
{ {
#if defined(STIX_DEBUG_EXEC_001) #if defined(STIX_DEBUG_VM_EXEC)
printf ("prim_context_goto: PRIMITVE ARGUMENT IS INVALID\n"); printf ("prim_context_goto: PRIMITVE ARGUMENT IS INVALID\n");
#endif #endif
return 0; return 0;
@ -1610,7 +1609,7 @@ static int __block_value (stix_t* stix, stix_ooi_t rcv_blkctx_offset, stix_ooi_t
if (STIX_CLASSOF(stix, rcv_blkctx) != stix->_block_context) if (STIX_CLASSOF(stix, rcv_blkctx) != stix->_block_context)
{ {
/* the receiver must be a block context */ /* the receiver must be a block context */
#if defined(STIX_DEBUG_EXEC_001) #if defined(STIX_DEBUG_VM_EXEC)
printf ("PRIMITVE VALUE RECEIVER IS NOT A BLOCK CONTEXT\n"); printf ("PRIMITVE VALUE RECEIVER IS NOT A BLOCK CONTEXT\n");
#endif #endif
return 0; return 0;
@ -1623,7 +1622,7 @@ printf ("PRIMITVE VALUE RECEIVER IS NOT A BLOCK CONTEXT\n");
* you can't send 'value' again to reactivate it. * you can't send 'value' again to reactivate it.
* For example, [thisContext value] value. */ * For example, [thisContext value] value. */
STIX_ASSERT (STIX_OBJ_GET_SIZE(rcv_blkctx) > STIX_CONTEXT_NAMED_INSTVARS); STIX_ASSERT (STIX_OBJ_GET_SIZE(rcv_blkctx) > STIX_CONTEXT_NAMED_INSTVARS);
#if defined(STIX_DEBUG_EXEC_001) #if defined(STIX_DEBUG_VM_EXEC)
printf ("PRIM REVALUING AN BLOCKCONTEXT\n"); printf ("PRIM REVALUING AN BLOCKCONTEXT\n");
#endif #endif
return 0; return 0;
@ -1633,7 +1632,7 @@ printf ("PRIM REVALUING AN BLOCKCONTEXT\n");
if (STIX_OOP_TO_SMOOI(rcv_blkctx->method_or_nargs) != actual_arg_count /* nargs */) if (STIX_OOP_TO_SMOOI(rcv_blkctx->method_or_nargs) != actual_arg_count /* nargs */)
{ {
/* the number of argument doesn't match */ /* the number of argument doesn't match */
#if defined(STIX_DEBUG_EXEC_001) #if defined(STIX_DEBUG_VM_EXEC)
/* TODO: better handling of primitive failure */ /* TODO: better handling of primitive failure */
printf ("PRIM BlockContext value FAIL - NARGS MISMATCH\n"); printf ("PRIM BlockContext value FAIL - NARGS MISMATCH\n");
#endif #endif
@ -1711,9 +1710,6 @@ static int prim_block_value (stix_t* stix, stix_ooi_t nargs)
x = __block_value (stix, nargs, nargs, 0, &blkctx); x = __block_value (stix, nargs, nargs, 0, &blkctx);
if (x <= 0) return x; /* hard failure and soft failure */ if (x <= 0) return x; /* hard failure and soft failure */
#if defined(STIX_DEBUG_EXEC_001)
printf ("<<ENTERING BLOCK>> SP=%ld\n", (long int)stix->sp);
#endif
SWITCH_ACTIVE_CONTEXT (stix, (stix_oop_context_t)blkctx); SWITCH_ACTIVE_CONTEXT (stix, (stix_oop_context_t)blkctx);
return 1; return 1;
} }
@ -1757,7 +1753,7 @@ static int prim_block_new_process (stix_t* stix, stix_ooi_t nargs)
if (STIX_CLASSOF(stix, rcv_blkctx) != stix->_block_context) if (STIX_CLASSOF(stix, rcv_blkctx) != stix->_block_context)
{ {
/* the receiver must be a block context */ /* the receiver must be a block context */
#if defined(STIX_DEBUG_EXEC_001) #if defined(STIX_DEBUG_VM_EXEC)
printf ("PRIMITVE VALUE RECEIVER IS NOT A BLOCK CONTEXT\n"); printf ("PRIMITVE VALUE RECEIVER IS NOT A BLOCK CONTEXT\n");
#endif #endif
return 0; return 0;
@ -2901,12 +2897,6 @@ static int send_message (stix_t* stix, stix_oop_char_t selector, int to_super, s
receiver = STIX_STACK_GET(stix, stix->sp - nargs); receiver = STIX_STACK_GET(stix, stix->sp - nargs);
#if defined(STIX_DEBUG_EXEC_001)
printf (" RECEIVER = ");
print_object(stix, 0, receiver);
printf ("\n");
#endif
mthname.ptr = selector->slot; mthname.ptr = selector->slot;
mthname.len = STIX_OBJ_GET_SIZE(selector); mthname.len = STIX_OBJ_GET_SIZE(selector);
method = find_method (stix, receiver, &mthname, to_super); method = find_method (stix, receiver, &mthname, to_super);
@ -2923,18 +2913,11 @@ printf ("\n");
method = find_method (stix, receiver, &mthname, 0); method = find_method (stix, receiver, &mthname, 0);
if (!method) if (!method)
{ {
/* TODO: improve this hard error handling */ /* this must not happen as long as doesNotUnderstand: is implemented under Apex.
stix_oop_t c; * this check should indicate a very serious internal problem */
STIX_LOG4 (stix, STIX_LOG_VM | STIX_LOG_FATAL,
/* TODO: remove this print-out.... or have it gracefully returned to the caller side */ "Fatal error - receiver [%O] of class [%O] doesNotUnderstand: [%.*S]\n",
c = STIX_CLASSOF(stix,receiver); receiver, STIX_CLASSOF(stix, receiver), mthname.len, mthname.ptr);
printf ("HARD FAILURE ERROR [IMAGE PROBLEM] - receiver [");
print_object (stix, 0, receiver);
printf ("] class ");
print_object (stix, 0, c);
printf (" doesNotUnderstand: [");
print_oocs (&mthname);
printf ("]\n");
stix->errnum = STIX_EMSGSND; stix->errnum = STIX_EMSGSND;
return -1; return -1;
@ -2958,36 +2941,38 @@ printf ("\n");
switch (preamble_code) switch (preamble_code)
{ {
case STIX_METHOD_PREAMBLE_RETURN_RECEIVER: case STIX_METHOD_PREAMBLE_RETURN_RECEIVER:
DBGOUT_EXEC_0 ("METHOD_PREAMBLE_RETURN_RECEIVER"); LOG_INST_0 (stix, "preamble_return_receiver");
STIX_STACK_POPS (stix, nargs); /* pop arguments only*/ STIX_STACK_POPS (stix, nargs); /* pop arguments only*/
break; break;
case STIX_METHOD_PREAMBLE_RETURN_NIL: case STIX_METHOD_PREAMBLE_RETURN_NIL:
DBGOUT_EXEC_0 ("METHOD_PREAMBLE_RETURN_NIL"); LOG_INST_0 (stix, "preamble_return_nil");
STIX_STACK_POPS (stix, nargs); STIX_STACK_POPS (stix, nargs);
STIX_STACK_SETTOP (stix, stix->_nil); STIX_STACK_SETTOP (stix, stix->_nil);
break; break;
case STIX_METHOD_PREAMBLE_RETURN_TRUE: case STIX_METHOD_PREAMBLE_RETURN_TRUE:
DBGOUT_EXEC_0 ("METHOD_PREAMBLE_RETURN_TRUE"); LOG_INST_0 (stix, "preamble_return_true");
STIX_STACK_POPS (stix, nargs); STIX_STACK_POPS (stix, nargs);
STIX_STACK_SETTOP (stix, stix->_true); STIX_STACK_SETTOP (stix, stix->_true);
break; break;
case STIX_METHOD_PREAMBLE_RETURN_FALSE: case STIX_METHOD_PREAMBLE_RETURN_FALSE:
DBGOUT_EXEC_0 ("METHOD_PREAMBLE_RETURN_FALSE"); LOG_INST_0 (stix, "preamble_return_false");
STIX_STACK_POPS (stix, nargs); STIX_STACK_POPS (stix, nargs);
STIX_STACK_SETTOP (stix, stix->_false); STIX_STACK_SETTOP (stix, stix->_false);
break; break;
case STIX_METHOD_PREAMBLE_RETURN_INDEX: case STIX_METHOD_PREAMBLE_RETURN_INDEX:
DBGOUT_EXEC_1 ("METHOD_PREAMBLE_RETURN_INDEX %d", (int)STIX_METHOD_GET_PREAMBLE_INDEX(preamble)); /* preamble_index field is used to store a positive integer */
LOG_INST_1 (stix, "preamble_return_index %zd", STIX_METHOD_GET_PREAMBLE_INDEX(preamble));
STIX_STACK_POPS (stix, nargs); STIX_STACK_POPS (stix, nargs);
STIX_STACK_SETTOP (stix, STIX_SMOOI_TO_OOP(STIX_METHOD_GET_PREAMBLE_INDEX(preamble))); STIX_STACK_SETTOP (stix, STIX_SMOOI_TO_OOP(STIX_METHOD_GET_PREAMBLE_INDEX(preamble)));
break; break;
case STIX_METHOD_PREAMBLE_RETURN_NEGINDEX: case STIX_METHOD_PREAMBLE_RETURN_NEGINDEX:
DBGOUT_EXEC_1 ("METHOD_PREAMBLE_RETURN_NEGINDEX %d", (int)STIX_METHOD_GET_PREAMBLE_INDEX(preamble)); /* preamble_index field is used to store a negative integer */
LOG_INST_1 (stix, "preamble_return_negindex %zd", STIX_METHOD_GET_PREAMBLE_INDEX(preamble));
STIX_STACK_POPS (stix, nargs); STIX_STACK_POPS (stix, nargs);
STIX_STACK_SETTOP (stix, STIX_SMOOI_TO_OOP(-STIX_METHOD_GET_PREAMBLE_INDEX(preamble))); STIX_STACK_SETTOP (stix, STIX_SMOOI_TO_OOP(-STIX_METHOD_GET_PREAMBLE_INDEX(preamble)));
break; break;
@ -2998,7 +2983,7 @@ printf ("\n");
STIX_STACK_POPS (stix, nargs); /* pop arguments only */ STIX_STACK_POPS (stix, nargs); /* pop arguments only */
DBGOUT_EXEC_1 ("METHOD_PREAMBLE_RETURN_INSTVAR %d", (int)STIX_METHOD_GET_PREAMBLE_INDEX(preamble)); LOG_INST_1 (stix, "preamble_return_instvar %zd", STIX_METHOD_GET_PREAMBLE_INDEX(preamble));
/* replace the receiver by an instance variable of the receiver */ /* replace the receiver by an instance variable of the receiver */
rcv = (stix_oop_oop_t)STIX_STACK_GETTOP(stix); rcv = (stix_oop_oop_t)STIX_STACK_GETTOP(stix);
@ -3025,13 +3010,12 @@ printf ("\n");
break; break;
} }
case STIX_METHOD_PREAMBLE_PRIMITIVE: case STIX_METHOD_PREAMBLE_PRIMITIVE:
{ {
stix_ooi_t prim_no; stix_ooi_t prim_no;
prim_no = STIX_METHOD_GET_PREAMBLE_INDEX(preamble); prim_no = STIX_METHOD_GET_PREAMBLE_INDEX(preamble);
DBGOUT_EXEC_1 ("METHOD_PREAMBLE_PRIMITIVE %d", (int)prim_no); LOG_INST_1 (stix, "preamble_primitive %zd", prim_no);
if (prim_no >= 0 && prim_no < STIX_COUNTOF(primitives) && if (prim_no >= 0 && prim_no < STIX_COUNTOF(primitives) &&
(nargs >= primitives[prim_no].min_nargs && nargs <= primitives[prim_no].max_nargs)) (nargs >= primitives[prim_no].min_nargs && nargs <= primitives[prim_no].max_nargs))
@ -3058,7 +3042,7 @@ printf ("\n");
register stix_oow_t w; register stix_oow_t w;
prim_name_index = STIX_METHOD_GET_PREAMBLE_INDEX(preamble); prim_name_index = STIX_METHOD_GET_PREAMBLE_INDEX(preamble);
DBGOUT_EXEC_1 ("METHOD_PREAMBLE_NAMED_PRIMITIVE %d", (int)prim_name_index); LOG_INST_1 (stix, "preamble_named_primitive %zd", prim_name_index);
name = method->slot[prim_name_index]; name = method->slot[prim_name_index];
@ -3110,8 +3094,8 @@ int stix_execute (stix_t* stix)
stix_ooi_t b1, b2; stix_ooi_t b1, b2;
stix_oop_t return_value; stix_oop_t return_value;
#if defined(STIX_PROFILE_EXEC) #if defined(STIX_PROFILE_VM)
stix_oow_t inst_counter = 0; stix_uintmax_t inst_counter = 0;
#endif #endif
STIX_ASSERT (stix->active_context != STIX_NULL); STIX_ASSERT (stix->active_context != STIX_NULL);
@ -3183,8 +3167,7 @@ int stix_execute (stix_t* stix)
{ {
/* 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));
printf ("REALLY NO MORE RUNNABLE PROCESS...\n"); STIX_LOG0 (stix, STIX_LOG_VM | STIX_LOG_DEBUG, "No more runnable process\n");
#if 0 #if 0
if (there is semaphore awaited.... ) if (there is semaphore awaited.... )
@ -3221,11 +3204,7 @@ if (there is semaphore awaited.... )
FETCH_BYTE_CODE_TO (stix, bcode); FETCH_BYTE_CODE_TO (stix, bcode);
/*while (bcode == BCODE_NOOP) FETCH_BYTE_CODE_TO (stix, bcode);*/ /*while (bcode == BCODE_NOOP) FETCH_BYTE_CODE_TO (stix, bcode);*/
#if 0 #if defined(STIX_PROFILE_VM)
printf ("BCODE = %x\n", bcode);
#endif
#if defined(STIX_PROFILE_EXEC)
inst_counter++; inst_counter++;
#endif #endif
@ -3246,7 +3225,7 @@ printf ("BCODE = %x\n", bcode);
case BCODE_PUSH_INSTVAR_7: case BCODE_PUSH_INSTVAR_7:
b1 = bcode & 0x7; /* low 3 bits */ b1 = bcode & 0x7; /* low 3 bits */
push_instvar: push_instvar:
DBGOUT_EXEC_1 ("PUSH_INSTVAR %d", (int)b1); LOG_INST_1 (stix, "push_instvar %zd", b1);
STIX_ASSERT (STIX_OBJ_GET_FLAGS_TYPE(stix->active_context->origin->receiver_or_source) == STIX_OBJ_TYPE_OOP); STIX_ASSERT (STIX_OBJ_GET_FLAGS_TYPE(stix->active_context->origin->receiver_or_source) == STIX_OBJ_TYPE_OOP);
STIX_STACK_PUSH (stix, ((stix_oop_oop_t)stix->active_context->origin->receiver_or_source)->slot[b1]); STIX_STACK_PUSH (stix, ((stix_oop_oop_t)stix->active_context->origin->receiver_or_source)->slot[b1]);
break; break;
@ -3266,7 +3245,7 @@ printf ("BCODE = %x\n", bcode);
case BCODE_STORE_INTO_INSTVAR_7: case BCODE_STORE_INTO_INSTVAR_7:
b1 = bcode & 0x7; /* low 3 bits */ b1 = bcode & 0x7; /* low 3 bits */
store_instvar: store_instvar:
DBGOUT_EXEC_1 ("STORE_INTO_INSTVAR %d", (int)b1); LOG_INST_1 (stix, "store_into_instvar %zd", b1);
STIX_ASSERT (STIX_OBJ_GET_FLAGS_TYPE(stix->active_context->receiver_or_source) == STIX_OBJ_TYPE_OOP); STIX_ASSERT (STIX_OBJ_GET_FLAGS_TYPE(stix->active_context->receiver_or_source) == STIX_OBJ_TYPE_OOP);
((stix_oop_oop_t)stix->active_context->origin->receiver_or_source)->slot[b1] = STIX_STACK_GETTOP(stix); ((stix_oop_oop_t)stix->active_context->origin->receiver_or_source)->slot[b1] = STIX_STACK_GETTOP(stix);
break; break;
@ -3285,7 +3264,7 @@ printf ("BCODE = %x\n", bcode);
case BCODE_POP_INTO_INSTVAR_7: case BCODE_POP_INTO_INSTVAR_7:
b1 = bcode & 0x7; /* low 3 bits */ b1 = bcode & 0x7; /* low 3 bits */
pop_into_instvar: pop_into_instvar:
DBGOUT_EXEC_1 ("POP_INTO_INSTVAR %d", (int)b1); LOG_INST_1 (stix, "pop_into_instvar %zd", b1);
STIX_ASSERT (STIX_OBJ_GET_FLAGS_TYPE(stix->active_context->receiver_or_source) == STIX_OBJ_TYPE_OOP); STIX_ASSERT (STIX_OBJ_GET_FLAGS_TYPE(stix->active_context->receiver_or_source) == STIX_OBJ_TYPE_OOP);
((stix_oop_oop_t)stix->active_context->origin->receiver_or_source)->slot[b1] = STIX_STACK_GETTOP(stix); ((stix_oop_oop_t)stix->active_context->origin->receiver_or_source)->slot[b1] = STIX_STACK_GETTOP(stix);
STIX_STACK_POP (stix); STIX_STACK_POP (stix);
@ -3384,7 +3363,7 @@ printf ("BCODE = %x\n", bcode);
if ((bcode >> 4) & 1) if ((bcode >> 4) & 1)
{ {
/* push - bit 4 on */ /* push - bit 4 on */
DBGOUT_EXEC_1 ("PUSH_TEMPVAR %d", (int)b1); LOG_INST_1 (stix, "push_tempvar %zd", b1);
STIX_STACK_PUSH (stix, ctx->slot[bx]); STIX_STACK_PUSH (stix, ctx->slot[bx]);
} }
else else
@ -3395,18 +3374,15 @@ printf ("BCODE = %x\n", bcode);
if ((bcode >> 3) & 1) if ((bcode >> 3) & 1)
{ {
/* pop - bit 3 on */ /* pop - bit 3 on */
DBGOUT_EXEC_1 ("POP_INTO_TEMPVAR %d", (int)b1); LOG_INST_1 (stix, "pop_into_tempvar %zd", b1);
STIX_STACK_POP (stix); STIX_STACK_POP (stix);
} }
else else
{ {
DBGOUT_EXEC_1 ("STORE_INTO_TEMPVAR %d", (int)b1); LOG_INST_1 (stix, "store_into_tempvar %zd", b1);
} }
} }
/*
print_object (stix, 0, ctx->slot[bx]);
printf ("\n");
*/
break; break;
} }
@ -3425,11 +3401,7 @@ printf ("BCODE = %x\n", bcode);
case BCODE_PUSH_LITERAL_7: case BCODE_PUSH_LITERAL_7:
b1 = bcode & 0x7; /* low 3 bits */ b1 = bcode & 0x7; /* low 3 bits */
push_literal: push_literal:
DBGOUT_EXEC_1 ("PUSH_LITERAL %d", (int)b1); LOG_INST_1 (stix, "push_literal @%zd", b1);
/*
print_object (stix, 0, stix->active_method->slot[b1]);
printf ("\n");
*/
STIX_STACK_PUSH (stix, stix->active_method->slot[b1]); STIX_STACK_PUSH (stix, stix->active_method->slot[b1]);
break; break;
@ -3468,18 +3440,18 @@ printf ("BCODE = %x\n", bcode);
if ((bcode >> 2) & 1) if ((bcode >> 2) & 1)
{ {
/* pop */ /* pop */
DBGOUT_EXEC_1("POP_INTO_OBJECT %d", (int)b1); LOG_INST_1 (stix, "pop_into_object @%zd", b1);
STIX_STACK_POP (stix); STIX_STACK_POP (stix);
} }
else else
{ {
DBGOUT_EXEC_1("STORE_INTO_OBJECT %d", (int)b1); LOG_INST_1 (stix, "store_into_object @%zd", b1);
} }
} }
else else
{ {
/* push */ /* push */
DBGOUT_EXEC_1("PUSH_OBJECT %d", (int)b1); LOG_INST_1 (stix, "push_object @%zd", b1);
STIX_STACK_PUSH (stix, ass->value); STIX_STACK_PUSH (stix, ass->value);
} }
break; break;
@ -3489,7 +3461,7 @@ printf ("BCODE = %x\n", bcode);
case BCODE_JUMP_FORWARD_X: case BCODE_JUMP_FORWARD_X:
FETCH_PARAM_CODE_TO (stix, b1); FETCH_PARAM_CODE_TO (stix, b1);
DBGOUT_EXEC_1 ("JUMP_FORWARD %d", (int)b1); LOG_INST_1 (stix, "jump_forward %zd", b1);
stix->ip += b1; stix->ip += b1;
break; break;
@ -3497,13 +3469,13 @@ printf ("BCODE = %x\n", bcode);
case BCODE_JUMP_FORWARD_1: case BCODE_JUMP_FORWARD_1:
case BCODE_JUMP_FORWARD_2: case BCODE_JUMP_FORWARD_2:
case BCODE_JUMP_FORWARD_3: case BCODE_JUMP_FORWARD_3:
DBGOUT_EXEC_1 ("JUMP_FORWARD %d", (int)(bcode & 0x3)); LOG_INST_1 (stix, "jump_forward %zd", (bcode & 0x3));
stix->ip += (bcode & 0x3); /* low 2 bits */ stix->ip += (bcode & 0x3); /* low 2 bits */
break; break;
case BCODE_JUMP_BACKWARD_X: case BCODE_JUMP_BACKWARD_X:
FETCH_PARAM_CODE_TO (stix, b1); FETCH_PARAM_CODE_TO (stix, b1);
DBGOUT_EXEC_1 ("JUMP_BACKWARD %d", (int)b1); LOG_INST_1 (stix, "jump_backward %zd", b1);
stix->ip += b1; stix->ip += b1;
break; break;
@ -3511,7 +3483,7 @@ printf ("BCODE = %x\n", bcode);
case BCODE_JUMP_BACKWARD_1: case BCODE_JUMP_BACKWARD_1:
case BCODE_JUMP_BACKWARD_2: case BCODE_JUMP_BACKWARD_2:
case BCODE_JUMP_BACKWARD_3: case BCODE_JUMP_BACKWARD_3:
DBGOUT_EXEC_1 ("JUMP_BACKWARD %d", (int)(bcode & 0x3)); LOG_INST_1 (stix, "jump_backward %zd", (bcode & 0x3));
stix->ip -= (bcode & 0x3); /* low 2 bits */ stix->ip -= (bcode & 0x3); /* low 2 bits */
break; break;
@ -3525,19 +3497,19 @@ printf ("BCODE = %x\n", bcode);
case BCODE_JUMP_IF_FALSE_1: case BCODE_JUMP_IF_FALSE_1:
case BCODE_JUMP_IF_FALSE_2: case BCODE_JUMP_IF_FALSE_2:
case BCODE_JUMP_IF_FALSE_3: case BCODE_JUMP_IF_FALSE_3:
printf ("<<<<<<<<<<<<<< JUMP NOT IMPLEMENTED YET >>>>>>>>>>>> \n"); STIX_LOG0 (stix, STIX_LOG_VM | STIX_LOG_FATAL, "<<<<<<<<<<<<<< JUMP NOT IMPLEMENTED YET >>>>>>>>>>>>\n");
stix->errnum = STIX_ENOIMPL; stix->errnum = STIX_ENOIMPL;
return -1; return -1;
case BCODE_JUMP2_FORWARD: case BCODE_JUMP2_FORWARD:
FETCH_PARAM_CODE_TO (stix, b1); FETCH_PARAM_CODE_TO (stix, b1);
DBGOUT_EXEC_1 ("JUMP2_FORWARD %d", (int)b1); LOG_INST_1 (stix, "jump2_forward %zd", b1);
stix->ip += MAX_CODE_JUMP + b1; stix->ip += MAX_CODE_JUMP + b1;
break; break;
case BCODE_JUMP2_BACKWARD: case BCODE_JUMP2_BACKWARD:
FETCH_PARAM_CODE_TO (stix, b1); FETCH_PARAM_CODE_TO (stix, b1);
DBGOUT_EXEC_1 ("JUMP2_BACKWARD %d", (int)b1); LOG_INST_1 (stix, "jump2_backward %zd", b1);
stix->ip -= MAX_CODE_JUMP + b1; stix->ip -= MAX_CODE_JUMP + b1;
break; break;
@ -3586,23 +3558,19 @@ return -1;
{ {
/* pop */ /* pop */
STIX_STACK_POP (stix); STIX_STACK_POP (stix);
DBGOUT_EXEC_2 ("POP_INTO_CTXTEMPVAR %d %d", (int)b1, (int)b2); LOG_INST_2 (stix, "pop_into_ctxtempvar %zd %zd", b1, b2);
} }
else else
{ {
DBGOUT_EXEC_2 ("STORE_INTO_CTXTEMPVAR %d %d", (int)b1, (int)b2); LOG_INST_2 (stix, "store_into_ctxtempvar %zd %zd", b1, b2);
} }
} }
else else
{ {
/* push */ /* push */
STIX_STACK_PUSH (stix, ctx->slot[b2]); STIX_STACK_PUSH (stix, ctx->slot[b2]);
DBGOUT_EXEC_2 ("PUSH_CTXTEMPVAR %d %d", (int)b1, (int)b2); LOG_INST_2 (stix, "push_ctxtempvar %zd %zd", b1, b2);
} }
/*
print_object (stix, ctx->slot[b2]);
printf ("\n");
*/
break; break;
} }
@ -3650,23 +3618,19 @@ printf ("\n");
{ {
/* pop */ /* pop */
STIX_STACK_POP (stix); STIX_STACK_POP (stix);
DBGOUT_EXEC_2 ("POP_INTO_OBJVAR %d %d", (int)b1, (int)b2); LOG_INST_2 (stix, "pop_into_objvar %zd %zd", b1, b2);
} }
else else
{ {
DBGOUT_EXEC_2 ("STORE_INTO_OBJVAR %d %d", (int)b1, (int)b2); LOG_INST_2 (stix, "store_into_objvar %zd %zd", b1, b2);
} }
} }
else else
{ {
/* push */ /* push */
DBGOUT_EXEC_2 ("PUSH_OBJVAR %d %d", (int)b1, (int)b2); LOG_INST_2 (stix, "push_objvar %zd %zd", b1, b2);
STIX_STACK_PUSH (stix, t->slot[b1]); STIX_STACK_PUSH (stix, t->slot[b1]);
} }
/*
print_object (stix, t->slot[b1]);
printf ("\n");
*/
break; break;
} }
@ -3697,11 +3661,8 @@ printf ("\n");
/* get the selector from the literal frame */ /* get the selector from the literal frame */
selector = (stix_oop_char_t)stix->active_method->slot[b2]; selector = (stix_oop_char_t)stix->active_method->slot[b2];
#if defined(STIX_DEBUG_EXEC_001) LOG_INST_3 (stix, "send_message%hs %zd @%zd", (((bcode >> 2) & 1)? "_to_super": ""), b1, b2);
printf ("SEND_MESSAGE%s TO RECEIVER AT STACKPOS=%d NARGS=%d SELECTOR=", (((bcode >> 2) & 1)? "_TO_SUPER": ""), (int)(stix->sp - b1), (int)b1);
print_object (stix, 0, (stix_oop_t)selector);
fflush (stdout);
#endif
if (send_message (stix, selector, ((bcode >> 2) & 1), b1) <= -1) goto oops; if (send_message (stix, selector, ((bcode >> 2) & 1), b1) <= -1) goto oops;
break; /* CMD_SEND_MESSAGE */ break; /* CMD_SEND_MESSAGE */
} }
@ -3709,59 +3670,59 @@ fflush (stdout);
/* -------------------------------------------------------- */ /* -------------------------------------------------------- */
case BCODE_PUSH_RECEIVER: case BCODE_PUSH_RECEIVER:
DBGOUT_EXEC_0 ("PUSH_RECEIVER"); LOG_INST_0 (stix, "push_receiver");
STIX_STACK_PUSH (stix, stix->active_context->origin->receiver_or_source); STIX_STACK_PUSH (stix, stix->active_context->origin->receiver_or_source);
break; break;
case BCODE_PUSH_NIL: case BCODE_PUSH_NIL:
DBGOUT_EXEC_0 ("PUSH_NIL"); LOG_INST_0 (stix, "push_nil");
STIX_STACK_PUSH (stix, stix->_nil); STIX_STACK_PUSH (stix, stix->_nil);
break; break;
case BCODE_PUSH_TRUE: case BCODE_PUSH_TRUE:
DBGOUT_EXEC_0 ("PUSH_TRUE"); LOG_INST_0 (stix, "push_true");
STIX_STACK_PUSH (stix, stix->_true); STIX_STACK_PUSH (stix, stix->_true);
break; break;
case BCODE_PUSH_FALSE: case BCODE_PUSH_FALSE:
DBGOUT_EXEC_0 ("PUSH_FALSE"); LOG_INST_0 (stix, "push_false");
STIX_STACK_PUSH (stix, stix->_false); STIX_STACK_PUSH (stix, stix->_false);
break; break;
case BCODE_PUSH_CONTEXT: case BCODE_PUSH_CONTEXT:
DBGOUT_EXEC_0 ("PUSH_CONTEXT"); LOG_INST_0 (stix, "push_context");
STIX_STACK_PUSH (stix, (stix_oop_t)stix->active_context); STIX_STACK_PUSH (stix, (stix_oop_t)stix->active_context);
break; break;
case BCODE_PUSH_NEGONE: case BCODE_PUSH_NEGONE:
DBGOUT_EXEC_0 ("PUSH_NEGONE"); LOG_INST_0 (stix, "push_negone");
STIX_STACK_PUSH (stix, STIX_SMOOI_TO_OOP(-1)); STIX_STACK_PUSH (stix, STIX_SMOOI_TO_OOP(-1));
break; break;
case BCODE_PUSH_ZERO: case BCODE_PUSH_ZERO:
DBGOUT_EXEC_0 ("PUSH_ZERO"); LOG_INST_0 (stix, "push_zero");
STIX_STACK_PUSH (stix, STIX_SMOOI_TO_OOP(0)); STIX_STACK_PUSH (stix, STIX_SMOOI_TO_OOP(0));
break; break;
case BCODE_PUSH_ONE: case BCODE_PUSH_ONE:
DBGOUT_EXEC_0 ("PUSH_ONE"); LOG_INST_0 (stix, "push_one");
STIX_STACK_PUSH (stix, STIX_SMOOI_TO_OOP(1)); STIX_STACK_PUSH (stix, STIX_SMOOI_TO_OOP(1));
break; break;
case BCODE_PUSH_TWO: case BCODE_PUSH_TWO:
DBGOUT_EXEC_0 ("PUSH_TWO"); LOG_INST_0 (stix, "push_two");
STIX_STACK_PUSH (stix, STIX_SMOOI_TO_OOP(2)); STIX_STACK_PUSH (stix, STIX_SMOOI_TO_OOP(2));
break; break;
case BCODE_PUSH_INTLIT: case BCODE_PUSH_INTLIT:
FETCH_PARAM_CODE_TO (stix, b1); FETCH_PARAM_CODE_TO (stix, b1);
DBGOUT_EXEC_1 ("PUSH_INTLIT %d", (int)b1); LOG_INST_1 (stix, "push_intlit %zd", b1);
STIX_STACK_PUSH (stix, STIX_SMOOI_TO_OOP(b1)); STIX_STACK_PUSH (stix, STIX_SMOOI_TO_OOP(b1));
break; break;
case BCODE_PUSH_NEGINTLIT: case BCODE_PUSH_NEGINTLIT:
FETCH_PARAM_CODE_TO (stix, b1); FETCH_PARAM_CODE_TO (stix, b1);
DBGOUT_EXEC_1 ("PUSH_NEGINTLIT %d", (int)-b1); LOG_INST_1 (stix, "push_negintlit %zd", -b1);
STIX_STACK_PUSH (stix, STIX_SMOOI_TO_OOP(-b1)); STIX_STACK_PUSH (stix, STIX_SMOOI_TO_OOP(-b1));
break; break;
@ -3770,7 +3731,7 @@ fflush (stdout);
case BCODE_DUP_STACKTOP: case BCODE_DUP_STACKTOP:
{ {
stix_oop_t t; stix_oop_t t;
DBGOUT_EXEC_0 ("DUP_STACKTOP"); LOG_INST_0 (stix, "dup_stacktop");
STIX_ASSERT (!STIX_STACK_ISEMPTY(stix)); STIX_ASSERT (!STIX_STACK_ISEMPTY(stix));
t = STIX_STACK_GETTOP(stix); t = STIX_STACK_GETTOP(stix);
STIX_STACK_PUSH (stix, t); STIX_STACK_PUSH (stix, t);
@ -3778,25 +3739,22 @@ fflush (stdout);
} }
case BCODE_POP_STACKTOP: case BCODE_POP_STACKTOP:
DBGOUT_EXEC_0 ("POP_STACKTOP"); LOG_INST_0 (stix, "pop_stacktop");
STIX_ASSERT (!STIX_STACK_ISEMPTY(stix)); STIX_ASSERT (!STIX_STACK_ISEMPTY(stix));
STIX_STACK_POP (stix); STIX_STACK_POP (stix);
break; break;
case BCODE_RETURN_STACKTOP: case BCODE_RETURN_STACKTOP:
DBGOUT_EXEC_0 ("RETURN_STACKTOP"); LOG_INST_0 (stix, "return_stacktop");
return_value = STIX_STACK_GETTOP(stix); return_value = STIX_STACK_GETTOP(stix);
STIX_STACK_POP (stix); STIX_STACK_POP (stix);
goto handle_return; goto handle_return;
case BCODE_RETURN_RECEIVER: case BCODE_RETURN_RECEIVER:
DBGOUT_EXEC_0 ("RETURN_RECEIVER"); LOG_INST_0 (stix, "return_receiver");
return_value = stix->active_context->origin->receiver_or_source; return_value = stix->active_context->origin->receiver_or_source;
handle_return: handle_return:
#if defined(STIX_DEBUG_EXEC_001)
printf ("<<LEAVING>> SP=%d\n", (int)stix->sp);
#endif
#if 0 #if 0
/* put the instruction pointer back to the return /* put the instruction pointer back to the return
@ -3874,23 +3832,14 @@ printf ("<<LEAVING>> SP=%d\n", (int)stix->sp);
/* place the instruction pointer back at the return instruction. /* place the instruction pointer back at the return instruction.
* even if the context is reentered, it will just return. * even if the context is reentered, it will just return.
*stix->ip--;*/ *stix->ip--;*/
#if defined(STIX_DEBUG_EXEC_002)
printf ("TERMINATING A PROCESS RETURNING old_active context %p\n", stix->active_context);
#endif
terminate_process (stix, stix->processor->active); terminate_process (stix, stix->processor->active);
#if defined(STIX_DEBUG_EXEC_002)
printf ("TERMINATED A PROCESS RETURNING %lld new active_context %p\n", (long long int)stix->ip, stix->active_context);
#endif
} }
else else
{ {
if (stix->active_context->origin->ip == STIX_SMOOI_TO_OOP(STIX_SMOOI_MIN)) if (stix->active_context->origin->ip == STIX_SMOOI_TO_OOP(STIX_SMOOI_MIN))
{ {
printf ("ERROR: CAN'T RETURN FROM DEAD METHOD CONTEXT orgin->ip %ld origin->sender->ip %ld\n", STIX_LOG0 (stix, STIX_LOG_VM | STIX_LOG_ERROR, "Error - cannot return from dead context\n");
(long int)STIX_OOP_TO_SMOOI(stix->active_context->origin->ip), (long int)STIX_OOP_TO_SMOOI(stix->active_context->origin->sender->ip)); stix->errnum = STIX_EINTERN; /* TODO: make this error catchable at the stix level... */
printf ("ERROR: CAN'T RETURN FROM DEAD METHOD CONTEXT origin %p origin->sender %p\n", stix->active_context->origin, stix->active_context->origin->sender);
/* TODO: proper error handling */
stix->errnum = STIX_EINTERN; /* TODO: this should be caughtable at the stix level... */
return -1; return -1;
} }
@ -3900,9 +3849,6 @@ printf ("ERROR: CAN'T RETURN FROM DEAD METHOD CONTEXT origin %p origin->sender %
if (stix->active_context->origin == stix->active_context) if (stix->active_context->origin == stix->active_context)
{ {
/* returning from a method */ /* returning from a method */
#if defined(STIX_DEBUG_EXEC_002)
printf (">>>>>>>>>>>>> METHOD RETURN...\n");
#endif
STIX_ASSERT (STIX_CLASSOF(stix, stix->active_context) == stix->_method_context); STIX_ASSERT (STIX_CLASSOF(stix, stix->active_context) == stix->_method_context);
stix->ip = STIX_SMOOI_MIN; stix->ip = STIX_SMOOI_MIN;
} }
@ -3910,9 +3856,6 @@ printf (">>>>>>>>>>>>> METHOD RETURN...\n");
{ {
/* method return from within a block(including a non-local return) */ /* method return from within a block(including a non-local return) */
STIX_ASSERT (STIX_CLASSOF(stix, stix->active_context) == stix->_block_context); STIX_ASSERT (STIX_CLASSOF(stix, stix->active_context) == stix->_block_context);
#if defined(STIX_DEBUG_EXEC_002)
printf (">>>>>>>>>>>>>>>> METHOD RETURN FROM WITHIN A BLOCK. NON-LOCAL RETURN.. RESETTUBG IP OF CONTEXT %p.\n", stix->active_context->origin);
#endif
stix->active_context->origin->ip = STIX_SMOOI_TO_OOP(STIX_SMOOI_MIN); stix->active_context->origin->ip = STIX_SMOOI_TO_OOP(STIX_SMOOI_MIN);
} }
@ -3941,12 +3884,9 @@ printf (">>>>>>>>>>>>>>>> METHOD RETURN FROM WITHIN A BLOCK. NON-LOCAL RETURN..
/* NOTE: this condition is true for the processified block context also. /* NOTE: this condition is true for the processified block context also.
* stix->active_context->origin == stix->processor->active->initial_context->origin * stix->active_context->origin == stix->processor->active->initial_context->origin
* however, the check here is done after context switching and * however, the check here is done after context switching and the
* the processified block check is done against the context before switching */ * processified block check is done against the context before switching */
#if defined(STIX_DEBUG_EXEC_001)
printf ("<<<RETURNING TO THE INITIAL CONTEXT>>> TERMINATING SP => %ld\n", (long int)stix->sp);
#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);
@ -3965,26 +3905,25 @@ printf ("<<<RETURNING TO THE INITIAL CONTEXT>>> TERMINATING SP => %ld\n", (long
break; break;
case BCODE_RETURN_FROM_BLOCK: case BCODE_RETURN_FROM_BLOCK:
DBGOUT_EXEC_0 ("RETURN_FROM_BLOCK"); LOG_INST_0 (stix, "return_from_block");
STIX_ASSERT(STIX_CLASSOF(stix, stix->active_context) == stix->_block_context); STIX_ASSERT(STIX_CLASSOF(stix, stix->active_context) == stix->_block_context);
if (stix->active_context == stix->processor->active->initial_context) if (stix->active_context == stix->processor->active->initial_context)
{ {
/* the active context to return from is an initial context of
* the active process. this process must have been created
* over a block using the newProcess method. let's terminate
* the process. */
STIX_ASSERT ((stix_oop_t)stix->active_context->sender == stix->_nil); STIX_ASSERT ((stix_oop_t)stix->active_context->sender == stix->_nil);
#if defined(STIX_DEBUG_EXEC_002)
printf ("TERMINATE A PROCESS RETURNING FROM BLOCK\n");
#endif
terminate_process (stix, stix->processor->active); terminate_process (stix, stix->processor->active);
#if defined(STIX_DEBUG_EXEC_002)
printf ("TERMINATED A PROCESS RETURNING FROM BLOCK %lld new active_context %p\n", (long long int)stix->ip, stix->active_context);
#endif
} }
else else
{ {
#if defined(STIX_DEBUG_EXEC_001) /* it is a normal block return as the active block context
printf ("<<LEAVING BLOCK>>\n"); * is not the initial context of a process */
#endif
#if defined(STIX_USE_PROCSTK) #if defined(STIX_USE_PROCSTK)
/* the process stack is shared. the return value /* the process stack is shared. the return value
* doesn't need to get moved. */ * doesn't need to get moved. */
@ -4011,7 +3950,7 @@ printf ("<<LEAVING BLOCK>>\n");
FETCH_PARAM_CODE_TO (stix, b1); FETCH_PARAM_CODE_TO (stix, b1);
FETCH_PARAM_CODE_TO (stix, b2); FETCH_PARAM_CODE_TO (stix, b2);
DBGOUT_EXEC_2 ("MAKE_BLOCK %d %d", (int)b1, (int)b2); LOG_INST_2 (stix, "make_block %zd %zd", b1, b2);
STIX_ASSERT (b1 >= 0); STIX_ASSERT (b1 >= 0);
STIX_ASSERT (b2 >= b1); STIX_ASSERT (b2 >= b1);
@ -4056,7 +3995,7 @@ printf ("<<LEAVING BLOCK>>\n");
stix_oop_context_t rctx; stix_oop_context_t rctx;
stix_oop_context_t blkctx; stix_oop_context_t blkctx;
DBGOUT_EXEC_0 ("SEND_BLOCK_COPY"); LOG_INST_0 (stix, "send_block_copy");
/* it emulates thisContext blockCopy: nargs ofTmprCount: ntmprs */ /* it emulates thisContext blockCopy: nargs ofTmprCount: ntmprs */
STIX_ASSERT (stix->sp >= 2); STIX_ASSERT (stix->sp >= 2);
@ -4147,11 +4086,12 @@ printf ("<<LEAVING BLOCK>>\n");
case BCODE_NOOP: case BCODE_NOOP:
/* do nothing */ /* do nothing */
LOG_INST_0 (stix, "noop");
break; break;
default: default:
printf ("UNKNOWN BYTE CODE ENCOUNTERED %x\n", (int)bcode); STIX_LOG1 (stix, STIX_LOG_VM | STIX_LOG_FATAL, "Fatal error - unknown byte code 0x%zx\n", bcode);
stix->errnum = STIX_EINTERN; stix->errnum = STIX_EINTERN;
break; break;
@ -4161,12 +4101,11 @@ printf ("UNKNOWN BYTE CODE ENCOUNTERED %x\n", (int)bcode);
done: done:
vm_cleanup (stix); vm_cleanup (stix);
#if defined(STIX_PROFILE_EXEC) #if defined(STIX_PROFILE_VM)
printf ("TOTAL_INST_COUTNER = %lu\n", (unsigned long int)inst_counter); STIX_LOG1 (stix, STIX_LOG_VM | STIX_LOG_INFO, "TOTAL_INST_COUTNER = %zu\n", inst_counter);
#endif #endif
return 0; return 0;
oops: oops:
/* TODO: anything to do here? */ /* TODO: anything to do here? */
return -1; return -1;

View File

@ -293,10 +293,10 @@ void stix_gc (stix_t* stix)
stix->active_context->ip = STIX_SMOOI_TO_OOP(stix->ip); stix->active_context->ip = STIX_SMOOI_TO_OOP(stix->ip);
} }
#if defined(STIX_DEBUG_GC_002) STIX_LOG4 (stix, STIX_LOG_GC | STIX_LOG_INFO,
printf ("STARTING GC curheap base %p ptr %p newheap base %p ptr %p\n", "Starting GC curheap base %p ptr %p newheap base %p ptr %p\n",
stix->curheap->base, stix->curheap->ptr, stix->newheap->base, stix->newheap->ptr); stix->curheap->base, stix->curheap->ptr, stix->newheap->base, stix->newheap->ptr);
#endif
/* TODO: allocate common objects like _nil and the root dictionary /* TODO: allocate common objects like _nil and the root dictionary
* in the permanant heap. minimize moving around */ * in the permanant heap. minimize moving around */
old_nil = stix->_nil; old_nil = stix->_nil;
@ -395,25 +395,29 @@ printf ("STARTING GC curheap base %p ptr %p newheap base %p ptr %p\n",
stix->newheap = tmp; stix->newheap = tmp;
/* /*
{ if (stix->symtab && STIX_LOG_ENABLED(stix, STIX_LOG_GC | STIX_LOG_DEBUG))
stix_oow_t index; {
stix_oop_oop_t buc; stix_oow_t index;
printf ("=== SURVIVING SYMBOLS ===\n"); stix_oop_oop_t buc;
buc = (stix_oop_oop_t) stix->symtab->slot[STIX_SYMTAB_BUCKET]; STIX_LOG0 (stix, STIX_LOG_GC | STIX_LOG_DEBUG, "=== SURVIVING SYMBOLS IN GC ===\n");
for (index = 0; index < buc->size; index++) buc = (stix_oop_oop_t) stix->symtab->bucket;
{ for (index = 0; index < STIX_OBJ_GET_SIZE(buc); index++)
{
if ((stix_oop_t)buc->slot[index] != stix->_nil) if ((stix_oop_t)buc->slot[index] != stix->_nil)
{ {
const stix_oop_char_t* p = ((stix_oop_char_t)buc->slot[index])->slot; STIX_LOG1 (stix, STIX_LOG_GC | STIX_LOG_DEBUG, "\t%O\n", buc->slot[index]);
printf ("SYM ["); }
while (*p) printf ("%c", *p++); }
printf ("]\n"); STIX_LOG0 (stix, STIX_LOG_GC | STIX_LOG_DEBUG, "===============================\n");
} }
}
printf ("===========================\n");
}
*/ */
if (stix->active_method) SET_ACTIVE_METHOD_CODE (stix); /* update stix->active_code */ if (stix->active_method) SET_ACTIVE_METHOD_CODE (stix); /* update stix->active_code */
/* TODO: include some gc statstics like number of live objects, gc performance, etc */
STIX_LOG4 (stix, STIX_LOG_GC | STIX_LOG_INFO,
"Finished GC curheap base %p ptr %p newheap base %p ptr %p\n",
stix->curheap->base, stix->curheap->ptr, stix->newheap->base, stix->newheap->ptr);
} }

View File

@ -26,7 +26,7 @@
#include "stix-prv.h" #include "stix-prv.h"
#include <stdio.h> /* for snrintf(). used for floating-point number formatting */ /*#include <stdio.h>*/ /* for snrintf(). used for floating-point number formatting */
#include <stdarg.h> #include <stdarg.h>
#if defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1200)) #if defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1200))

View File

@ -264,8 +264,8 @@ reswitch:
case 'h': /* short int */ case 'h': /* short int */
case 'l': /* long int */ case 'l': /* long int */
case 'q': /* long long int */ case 'q': /* long long int */
case 'j': /* uintmax_t */ case 'j': /* stix_intmax_t/stix_uintmax_t */
case 'z': /* size_t */ case 'z': /* stix_ooi_t/stix_oow_t */
case 't': /* ptrdiff_t */ case 't': /* ptrdiff_t */
if (lm_flag & (LF_LD | LF_QD)) goto invalid_format; if (lm_flag & (LF_LD | LF_QD)) goto invalid_format;
@ -316,7 +316,6 @@ reswitch:
flagc |= FLAGC_LENMOD; flagc |= FLAGC_LENMOD;
lm_flag |= LF_QD; lm_flag |= LF_QD;
goto reswitch; goto reswitch;
/* end of length modifiers */ /* end of length modifiers */
case 'n': case 'n':

View File

@ -30,7 +30,7 @@ void* stix_allocbytes (stix_t* stix, stix_oow_t size)
{ {
stix_uint8_t* ptr; stix_uint8_t* ptr;
#if defined(STIX_DEBUG_GC_001) #if defined(STIX_DEBUG_GC)
if (!(stix->option.trait & STIX_NOGC)) stix_gc (stix); if (!(stix->option.trait & STIX_NOGC)) stix_gc (stix);
#endif #endif

View File

@ -45,12 +45,12 @@
#define STIX_USE_MAKE_BLOCK #define STIX_USE_MAKE_BLOCK
/* this is for gc debugging */ /* this is for gc debugging */
/*#define STIX_DEBUG_PROCESSOR*/ /* #define STIX_DEBUG_GC */
/*#define STIX_DEBUG_GC_001*/ #define SIIX_DEBUG_COMPILER
/*#define STIX_DEBUG_GC_002*/ /*#define STIX_DEBUG_VM_PROCESSOR*/
/*#define STIX_DEBUG_EXEC_001*/ /*#define STIX_DEBUG_VM_EXEC*/
/*#define STIX_DEBUG_EXEC_002*/ /*#define STIX_DEBUG_VM_METHOD_LOOKUP*/
#define STIX_PROFILE_EXEC #define STIX_PROFILE_VM
/* allow the caller to drive process switching by calling /* allow the caller to drive process switching by calling
* stix_switchprocess(). */ * stix_switchprocess(). */
@ -64,7 +64,7 @@
#define STIX_LIMIT_OBJ_SIZE #define STIX_LIMIT_OBJ_SIZE
#include <stdio.h> /* TODO: delete these header inclusion lines */ /* TODO: delete these header inclusion lines */
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>

View File

@ -740,7 +740,6 @@ typedef struct stix_prim_mod_data_t stix_prim_mod_data_t;
* ========================================================================= */ * ========================================================================= */
#if defined(STIX_INCLUDE_COMPILER) #if defined(STIX_INCLUDE_COMPILER)
typedef struct stix_compiler_t stix_compiler_t; typedef struct stix_compiler_t stix_compiler_t;
typedef struct stix_decoder_t stix_decoder_t;
#endif #endif
struct stix_t struct stix_t
@ -854,7 +853,6 @@ struct stix_t
#if defined(STIX_INCLUDE_COMPILER) #if defined(STIX_INCLUDE_COMPILER)
stix_compiler_t* c; stix_compiler_t* c;
stix_decoder_t* d;
#endif #endif
}; };
@ -894,26 +892,40 @@ struct stix_t
enum stix_log_mask_t enum stix_log_mask_t
{ {
/* for general messages */
STIX_LOG_DEBUG = (1 << 0), STIX_LOG_DEBUG = (1 << 0),
STIX_LOG_INFO = (1 << 1), STIX_LOG_INFO = (1 << 1),
STIX_LOG_ERROR = (1 << 2), STIX_LOG_WARN = (1 << 2),
STIX_LOG_ERROR = (1 << 3),
STIX_LOG_FATAL = (1 << 4),
/* for special messages */ STIX_LOG_MNEMONIC = (1 << 8), /* bytecode mnemonic */
STIX_LOG_COMPILER = (1 << 8), STIX_LOG_GC = (1 << 9),
STIX_LOG_EXECUTOR = (1 << 9), STIX_LOG_VM = (1 << 10)
STIX_LOG_DECODER = (1 << 10)
}; };
typedef enum stix_log_mask_t stix_log_mask_t; typedef enum stix_log_mask_t stix_log_mask_t;
#define STIX_LOG_ENABLED(stix,mask) ((stix)->option.log_mask & (mask)) #define STIX_LOG_ENABLED(stix,mask) ((stix)->option.log_mask & (mask))
#define STIX_LOG0(stix,mask,fmt) do { if (STIX_LOG_ENABLED(stix,mask)) stix_logbfmt(stix, mask, fmt); } while(0)
#define STIX_LOG1(stix,mask,fmt,a1) do { if (STIX_LOG_ENABLED(stix,mask)) stix_logbfmt(stix, mask, fmt, a1); } while(0)
#define STIX_LOG2(stix,mask,fmt,a1,a2) do { if (STIX_LOG_ENABLED(stix,mask)) stix_logbfmt(stix, mask, fmt, a1, a2); } while(0)
#define STIX_LOG3(stix,mask,fmt,a1,a2,a3) do { if (STIX_LOG_ENABLED(stix,mask)) stix_logbfmt(stix, mask, fmt, a1, a2, a3); } while(0)
#define STIX_LOG4(stix,mask,fmt,a1,a2,a3,a4) do { if (STIX_LOG_ENABLED(stix,mask)) stix_logbfmt(stix, mask, fmt, a1, a2, a3, a4); } while(0)
#define STIX_LOG5(stix,mask,fmt,a1,a2,a3,a4,a5) do { if (STIX_LOG_ENABLED(stix,mask)) stix_logbfmt(stix, mask, fmt, a1, a2, a3, a4, a5); } while(0)
/* #define STIX_DEBUG0(stix,fmt) STIX_LOG0(stix, STIX_LOG_DEBUG, fmt)
#define STIX_DEBUG0(stix,fmt) if (STIX_LOG_ENABLED(stix,STIX_LOG_DEBUG)) stix_logbfmt(stix, STIX_LOG_DEBUG, fmt) #define STIX_DEBUG1(stix,fmt,a1) STIX_LOG1(stix, STIX_LOG_DEBUG, fmt, a1)
#define STIX_DEBUG1(stix,fmt,a1) #define STIX_DEBUG2(stix,fmt,a1,a2) STIX_LOG2(stix, STIX_LOG_DEBUG, fmt, a1, a2)
#define STIX_DEBUG2(stix,fmt,a1,a2) #define STIX_DEBUG3(stix,fmt,a1,a2,a3) STIX_LOG3(stix, STIX_LOG_DEBUG, fmt, a1, a2, a3)
*/ #define STIX_DEBUG4(stix,fmt,a1,a2,a3,a4) STIX_LOG4(stix, STIX_LOG_DEBUG, fmt, a1, a2, a3, a4)
#define STIX_DEBUG5(stix,fmt,a1,a2,a3,a4,a5) STIX_LOG5(stix, STIX_LOG_DEBUG, fmt, a1, a2, a3, a4, a5)
#define STIX_INFO0(stix,fmt) STIX_LOG0(stix, STIX_LOG_INFO, fmt)
#define STIX_INFO1(stix,fmt,a1) STIX_LOG1(stix, STIX_LOG_INFO, fmt, a1)
#define STIX_INFO2(stix,fmt,a1,a2) STIX_LOG2(stix, STIX_LOG_INFO, fmt, a1, a2)
#define STIX_INFO3(stix,fmt,a1,a2,a3) STIX_LOG3(stix, STIX_LOG_INFO, fmt, a1, a2, a3)
#define STIX_INFO4(stix,fmt,a1,a2,a3,a4) STIX_LOG4(stix, STIX_LOG_INFO, fmt, a1, a2, a3, a4)
#define STIX_INFO5(stix,fmt,a1,a2,a3,a4,a5) STIX_LOG5(stix, STIX_LOG_INFO, fmt, a1, a2, a3, a4, a5
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
@ -1074,8 +1086,8 @@ STIX_EXPORT void stix_poptmps (
STIX_EXPORT int stix_decode ( STIX_EXPORT int stix_decode (
stix_t* stix, stix_t* stix,
const stix_oocs_t* classfqn, stix_oop_method_t mth,
stix_oop_method_t mth const stix_oocs_t* classfqn
); );
/* Memory allocation/deallocation functions using stix's MMGR */ /* Memory allocation/deallocation functions using stix's MMGR */