Compare commits

...

10 Commits

Author SHA1 Message Date
ea73f9f8d2 removed the containing subdir 2023-10-02 21:04:54 +09:00
hyunghwan.chung
5b2953c9c7 updated the structure packing pragmas 2022-06-10 02:43:01 +00:00
hyunghwan.chung
8889a6580d changed to use MOO_STACK_GETRCV() 2022-02-13 09:47:17 +00:00
hyunghwan.chung
8ac1af2bf6 fixed %js handling in the formatting funtion 2022-01-24 07:39:53 +00:00
hyunghwan.chung
f74f9c240d limited the utf8 ranges 2022-01-07 02:04:37 +00:00
hyunghwan.chung
f078e76763 removed conditional log output selection in decode.c 2021-11-20 04:32:51 +00:00
hyunghwan.chung
7ec3d19818 commented out debug messages from System.moo 2021-07-20 00:59:42 +00:00
hyunghwan.chung
8e507223c0 added more log options in std.c 2021-07-20 00:57:22 +00:00
hyunghwan.chung
3aa232ab3e added some VM clean-up code to make it more robust 2021-04-14 16:00:47 +00:00
hyunghwan.chung
5db759b684 added some VM clean-up code to make it more robust 2021-04-14 15:46:39 +00:00
163 changed files with 127 additions and 57 deletions

View File

View File

View File

View File

@ -166,28 +166,35 @@ class System(Apex)
// TODO: Do i have to protected this in an exception handler???
//TODO: Execute Handler for signo.
System logNl: "Interrupt dectected - signal no - " & signo asString.
System logNl: "Interrupt detected - signal no - " & signo asString.
//System logNl: "WWWWWWWWWWWWWWWWWWWWWWWWW ".
// user-defined signal handler is not allowed for 16rFF
if (signo == 16rFF) { goto done }.
//System logNl: "OHHHHHHHHHHHHHH ".
ifnot (self.shr isEmpty)
{
//System logNl: "About to execute handler for the signal detected - " & signo asString.
self.shr do: [ :handler | handler value: signo ].
}
else
{
//System logNl: "Jumping to done detected - signal no - " & signo asString.
if (signo == 2) { goto done }.
}.
}.
//System logNl: "Waiting for signal on os_intr_sem...".
os_intr_sem wait.
}.
done:
//System logNl: "Jumped to done detected - signal no - " & signo asString.
nil.
]
ensure: [
| pid proc oldps |
//System logNl: "Aborting signal handler......".
// stop subscribing to signals.
os_intr_sem signal.
os_intr_sem unsignal.

View File

@ -28,19 +28,10 @@
#define DECODE_LOG_MASK (MOO_LOG_MNEMONIC | MOO_LOG_DEBUG)
#if defined(MOO_BUILD_RELEASE)
/* get rid of instruction logging regardless of the log mask
* in the release build */
# define LOG_INST_0(moo,fmt)
# define LOG_INST_1(moo,fmt,a1)
# define LOG_INST_2(moo,fmt,a1,a2)
# define LOG_INST_3(moo,fmt,a1,a2,a3)
#else
# define LOG_INST_0(moo,fmt) MOO_LOG1(moo, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer)
# define LOG_INST_1(moo,fmt,a1) MOO_LOG2(moo, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer, a1)
# define LOG_INST_2(moo,fmt,a1,a2) MOO_LOG3(moo, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer, a1, a2)
# define LOG_INST_3(moo,fmt,a1,a2,a3) MOO_LOG4(moo, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer, a1, a2, a3)
#endif
#define LOG_INST_0(moo,fmt) MOO_LOG1(moo, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer)
#define LOG_INST_1(moo,fmt,a1) MOO_LOG2(moo, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer, a1)
#define LOG_INST_2(moo,fmt,a1,a2) MOO_LOG3(moo, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer, a1, a2)
#define LOG_INST_3(moo,fmt,a1,a2,a3) MOO_LOG4(moo, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer, a1, a2, a3)
#define FETCH_BYTE_CODE(moo) (cdptr[ip++])
#define FETCH_BYTE_CODE_TO(moo,v_oow) (v_oow = FETCH_BYTE_CODE(moo))

View File

@ -135,6 +135,7 @@ static MOO_INLINE const char* proc_state_to_string (int state)
static int delete_sem_from_sem_io_tuple (moo_t* moo, moo_oop_semaphore_t sem, int force);
static void signal_io_semaphore (moo_t* moo, moo_ooi_t io_handle, moo_ooi_t mask);
static void terminate_all_processes (moo_t* moo);
static int send_message (moo_t* moo, moo_oop_char_t selector, moo_ooi_t nargs, int to_super);
/* ------------------------------------------------------------------------- */
@ -165,6 +166,24 @@ static MOO_INLINE void vm_cleanup (moo_t* moo)
/* TODO: clean up semaphores being waited on
MOO_ASSERT (moo, moo->sem_io_wait_count == 0); */
if (moo->processor->total_count != MOO_SMOOI_TO_OOP(0))
{
/* the stock kernel code is supposed to stop all processes.
* if the code reaches here, the kernel code must be buggy */
MOO_LOG3 (moo, MOO_LOG_WARN, "Warning - non-zero number of processes upon VM clean-up - total: %zd runnable: %zd suspended: %zd\n",
(moo_ooi_t)MOO_OOP_TO_SMOOI(moo->processor->total_count),
(moo_ooi_t)MOO_OOP_TO_SMOOI(moo->processor->runnable.count),
(moo_ooi_t)MOO_OOP_TO_SMOOI(moo->processor->suspended.count));
MOO_LOG0 (moo, MOO_LOG_WARN, "Warning - terminating all residue processes\n");
terminate_all_processes (moo);
}
MOO_ASSERT (moo, moo->processor->active == moo->nil_process);
MOO_ASSERT (moo, MOO_OOP_TO_SMOOI(moo->processor->total_count) == 0);
MOO_ASSERT (moo, MOO_OOP_TO_SMOOI(moo->processor->runnable.count) == 0);
MOO_ASSERT (moo, MOO_OOP_TO_SMOOI(moo->processor->suspended.count) == 0);
for (i = 0; i < moo->sem_io_map_capa;)
{
moo_ooi_t sem_io_index;
@ -778,6 +797,22 @@ static void terminate_process (moo_t* moo, moo_oop_process_t proc)
#endif
}
static void terminate_all_processes (moo_t* moo)
{
while (MOO_OOP_TO_SMOOI(moo->processor->suspended.count) > 0)
{
terminate_process (moo, moo->processor->suspended.first);
}
while (MOO_OOP_TO_SMOOI(moo->processor->runnable.count) > 0)
{
terminate_process (moo, moo->processor->runnable.first);
}
MOO_ASSERT (moo, MOO_OOP_TO_SMOOI(moo->processor->total_count) == 0);
MOO_ASSERT (moo, moo->processor->active == moo->nil_process);
}
static void resume_process (moo_t* moo, moo_oop_process_t proc)
{
if (proc->state == MOO_SMOOI_TO_OOP(PROC_STATE_SUSPENDED))
@ -1959,11 +1994,11 @@ void moo_clearmethodcache (moo_t* moo)
static int start_initial_process_and_context (moo_t* moo, const moo_oocs_t* objname, const moo_oocs_t* mthname)
{
/* the initial context is a fake context. if objname is 'Stix' and
* mthname is 'main', this function emulates message sending 'Stix main'.
/* the initial context is a fake context. if objname is 'Moo' and
* mthname is 'main', this function emulates message sending 'Moo main'.
* it should emulate the following logical byte-code sequences:
*
* push Stix
* push Moo
* send #main
*/
moo_oop_context_t ctx;
@ -4868,7 +4903,7 @@ static int send_message (moo_t* moo, moo_oop_char_t selector, moo_ooi_t nargs, i
MOO_ASSERT (moo, MOO_OBJ_GET_FLAGS_TYPE(selector) == MOO_OBJ_TYPE_CHAR);
MOO_ASSERT (moo, MOO_CLASSOF(moo, selector) == moo->_symbol);
receiver = MOO_STACK_GET(moo, moo->sp - nargs);
receiver = MOO_STACK_GETRCV(moo, nargs);
#if defined(MOO_PROFILE_VM)
moo->stat.message_sends++;

View File

@ -839,7 +839,7 @@ static int fmt_outv (moo_fmtout_t* fmtout, va_list ap)
/* zeropad must not take effect for 's' */
if (flagc & FLAGC_ZEROPAD) padc = ' ';
if (lm_flag & LF_H) goto lowercase_s;
#if defined(MOO_OOCH_IS_UCH)
#if defined(MOO_OOCH_IS_BCH)
if (lm_flag & LF_J) goto lowercase_s;
#endif
uppercase_s:

View File

@ -1105,26 +1105,26 @@ struct moo_dbgi_method_t
enum moo_log_mask_t
{
MOO_LOG_DEBUG = (1u << 0),
MOO_LOG_INFO = (1u << 1),
MOO_LOG_WARN = (1u << 2),
MOO_LOG_ERROR = (1u << 3),
MOO_LOG_FATAL = (1u << 4),
MOO_LOG_DEBUG = ((moo_bitmask_t)1 << 0),
MOO_LOG_INFO = ((moo_bitmask_t)1 << 1),
MOO_LOG_WARN = ((moo_bitmask_t)1 << 2),
MOO_LOG_ERROR = ((moo_bitmask_t)1 << 3),
MOO_LOG_FATAL = ((moo_bitmask_t)1 << 4),
MOO_LOG_UNTYPED = (1u << 6), /* only to be used by MOO_DEBUGx() and MOO_INFOx() */
MOO_LOG_COMPILER = (1u << 7),
MOO_LOG_VM = (1u << 8),
MOO_LOG_MNEMONIC = (1u << 9), /* bytecode mnemonic */
MOO_LOG_GC = (1u << 10),
MOO_LOG_IC = (1u << 11), /* instruction cycle, fetch-decode-execute */
MOO_LOG_PRIMITIVE = (1u << 12),
MOO_LOG_APP = (1u << 13), /* moo applications, set by moo logging primitive */
MOO_LOG_UNTYPED = ((moo_bitmask_t)1 << 6), /* only to be used by MOO_DEBUGx() and MOO_INFOx() */
MOO_LOG_COMPILER = ((moo_bitmask_t)1 << 7),
MOO_LOG_VM = ((moo_bitmask_t)1 << 8),
MOO_LOG_MNEMONIC = ((moo_bitmask_t)1 << 9), /* bytecode mnemonic */
MOO_LOG_GC = ((moo_bitmask_t)1 << 10),
MOO_LOG_IC = ((moo_bitmask_t)1 << 11), /* instruction cycle, fetch-decode-execute */
MOO_LOG_PRIMITIVE = ((moo_bitmask_t)1 << 12),
MOO_LOG_APP = ((moo_bitmask_t)1 << 13), /* moo applications, set by moo logging primitive */
MOO_LOG_ALL_LEVELS = (MOO_LOG_DEBUG | MOO_LOG_INFO | MOO_LOG_WARN | MOO_LOG_ERROR | MOO_LOG_FATAL),
MOO_LOG_ALL_TYPES = (MOO_LOG_UNTYPED | MOO_LOG_COMPILER | MOO_LOG_VM | MOO_LOG_MNEMONIC | MOO_LOG_GC | MOO_LOG_IC | MOO_LOG_PRIMITIVE | MOO_LOG_APP),
MOO_LOG_STDOUT = (1u << 14), /* write log messages to stdout without timestamp. MOO_LOG_STDOUT wins over MOO_LOG_STDERR. */
MOO_LOG_STDERR = (1u << 15) /* write log messages to stderr without timestamp. */
MOO_LOG_STDOUT = ((moo_bitmask_t)1 << 14), /* write log messages to stdout without timestamp. MOO_LOG_STDOUT wins over MOO_LOG_STDERR. */
MOO_LOG_STDERR = ((moo_bitmask_t)1 << 15) /* write log messages to stderr without timestamp. */
};
typedef enum moo_log_mask_t moo_log_mask_t;

View File

@ -24,7 +24,10 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__GNUC__)
#if defined(__GNUC__) && (__GNUC__ >= 4)
# pragma pack(push,1)
#elif defined(__GNUC__)
# pragma pack(1)
#elif defined(__HP_aCC) || defined(__HP_cc)
# pragma PACK 1

Some files were not shown because too many files have changed in this diff Show More