removed xtn->log.mask and set log mask using moo_setoption()

This commit is contained in:
hyunghwan.chung 2018-12-26 08:29:20 +00:00
parent 63371a52d5
commit 3c881ebe0c
5 changed files with 44 additions and 38 deletions

View File

@ -66,6 +66,3 @@ void moo_dumpdic (moo_t* moo, moo_oop_dic_t dic, const moo_bch_t* title)
}
MOO_DEBUG0 (moo, "--------------------------------------------\n");
}

View File

@ -325,8 +325,7 @@ found:
z = moo_hashoochars(MOO_OBJ_GET_CHAR_SLOT(ass->key), MOO_OBJ_GET_SIZE(ass->key)) % bs;
/* move an element if necesary */
if ((y > x && (z <= x || z > y)) ||
(y < x && (z <= x && z > y)))
if ((y > x && (z <= x || z > y)) || (y < x && (z <= x && z > y)))
{
MOO_STORE_OOP (moo, MOO_OBJ_GET_OOP_PTR(dic->bucket, x), MOO_OBJ_GET_OOP_VAL(dic->bucket, y));
x = y;

View File

@ -558,7 +558,9 @@ static int ignite_3 (moo_t* moo)
MOO_STORE_OOP (moo, (moo_oop_t*)&cls->name, sym);
cls->nsup = moo->sysdic;
MOO_LOG4 (moo, MOO_LOG_GC | MOO_LOG_DEBUG, "putting to sysdic... %.*js offset = %d %d\n", kernel_classes[i].len, kernel_classes[i].name, (int)kernel_classes[i].offset, (int)MOO_OBJ_GET_FLAGS_PERM(sym));
if (!moo_putatsysdic(moo, sym, (moo_oop_t)cls)) return -1;
MOO_LOG0 (moo, MOO_LOG_GC | MOO_LOG_DEBUG, "done putting to sysdic...\n");
}
/* Attach the system dictionary to the nsdic field of the System class */
@ -647,6 +649,7 @@ static void compact_symbol_table (moo_t* moo, moo_oop_t _nil)
}
MOO_ASSERT (moo, tmp != _nil);
MOO_LOG2 (moo, MOO_LOG_GC | MOO_LOG_INFO, "Compacting away a symbol - %.*js\n", MOO_OBJ_GET_SIZE(tmp), MOO_OBJ_GET_CHAR_SLOT(tmp));
for (i = 0, x = index, y = index; i < bucket_size; i++)
{
@ -661,11 +664,8 @@ static void compact_symbol_table (moo_t* moo, moo_oop_t _nil)
MOO_ASSERT (moo, MOO_CLASSOF(moo,tmp) == moo->_symbol);
z = moo_hashoochars(MOO_OBJ_GET_CHAR_SLOT(tmp), MOO_OBJ_GET_SIZE(tmp)) % bucket_size;
MOO_LOG2 (moo, MOO_LOG_GC | MOO_LOG_INFO, "Compacting away a symbol - %.*js\n", MOO_OBJ_GET_SIZE(tmp), MOO_OBJ_GET_CHAR_SLOT(tmp));
/* move an element if necessary */
if ((y > x && (z <= x || z > y)) ||
(y < x && (z <= x && z > y)))
if ((y > x && (z <= x || z > y)) || (y < x && (z <= x && z > y)))
{
tmp = MOO_OBJ_GET_OOP_VAL(bucket, y);
/* this function is called as part of garbage collection.
@ -779,15 +779,15 @@ static moo_uint8_t* scan_heap_space (moo_t* moo, moo_uint8_t* ptr, moo_uint8_t**
{
moo_oow_t i;
moo_oow_t nbytes_aligned;
moo_oop_t oop;
moo_oop_t oop, tmp;
oop = (moo_oop_t)ptr;
nbytes_aligned = get_payload_bytes(moo, oop);
MOO_OBJ_SET_CLASS (oop, moo_moveoop(moo, (moo_oop_t)MOO_OBJ_GET_CLASS(oop)));
tmp = moo_moveoop(moo, (moo_oop_t)MOO_OBJ_GET_CLASS(oop));
MOO_OBJ_SET_CLASS (oop, tmp);
if (MOO_OBJ_GET_FLAGS_TYPE(oop) == MOO_OBJ_TYPE_OOP)
{
register moo_oop_t tmp;
moo_oow_t size;
/* TODO: is it better to use a flag bit in the header to

View File

@ -215,22 +215,6 @@ int main (int argc, char* argv[])
moo_setoption (moo, MOO_PROCSTK_SIZE, &tab_size);
}
{
moo_bitmask_t bm = 0;
moo_getoption (moo, MOO_TRAIT, &bm);
/*bm |= MOO_NOGC;*/
bm |= MOO_AWAIT_PROCS;
moo_setoption (moo, MOO_TRAIT, &bm);
#if 0
/* disable GC logs */
moo_getoption (moo, MOO_LOG_MASK, &bm);
bm = ~MOO_LOG_GC;
moo_setoption (moo, MOO_LOG_MASK, &bm);
#endif
}
if (moo_ignite(moo, memsize) <= -1)
{
moo_logbfmt (moo, MOO_LOG_STDERR, "ERROR: cannot ignite moo - [%d] %js\n", moo_geterrnum(moo), moo_geterrstr(moo));

View File

@ -279,7 +279,7 @@ struct xtn_t
struct
{
moo_bitmask_t mask;
/*moo_bitmask_t mask;*/
int fd;
int fd_flag; /* bitwise OR'ed fo logfd_flag_t bits */
@ -849,8 +849,10 @@ static void log_write (moo_t* moo, moo_bitmask_t mask, const moo_ooch_t* msg, mo
}
else
{
#if 0
if (!(xtn->log.mask & mask & ~MOO_LOG_ALL_LEVELS)) return; /* check log types */
if (!(xtn->log.mask & mask & ~MOO_LOG_ALL_TYPES)) return; /* check log levels */
#endif
if (mask & MOO_LOG_STDOUT) logfd = 1;
else
@ -3212,6 +3214,7 @@ static struct
{ "gc", MOO_LOG_GC },
{ "ic", MOO_LOG_IC },
{ "primitive", MOO_LOG_PRIMITIVE },
{ "all", MOO_LOG_ALL_TYPES },
{ "fatal", MOO_LOG_FATAL },
{ "error", MOO_LOG_ERROR },
@ -3251,7 +3254,11 @@ static int parse_logoptb (moo_t* moo, const moo_bch_t* str, moo_oow_t* xpathlen,
cm = moo_find_bchar_in_bcstr(str, ',');
pathlen = cm - str;
#if 0
logmask = xtn->log.mask;
#else
logmask = 0;
#endif
do
{
flt = cm + 1;
@ -3276,15 +3283,17 @@ static int parse_logoptb (moo_t* moo, const moo_bch_t* str, moo_oow_t* xpathlen,
}
while (cm);
if (!(logmask & MOO_LOG_ALL_TYPES)) logmask |= MOO_LOG_ALL_TYPES; /* no types specified. force to all types */
if (!(logmask & MOO_LOG_ALL_TYPES)) logmask |= MOO_LOG_ALL_TYPES & ~(moo_bitmask_t)MOO_LOG_GC; /* no types specified. force to all types except gc */
if (!(logmask & MOO_LOG_ALL_LEVELS)) logmask |= MOO_LOG_ALL_LEVELS; /* no levels specified. force to all levels */
}
else
{
logmask = MOO_LOG_ALL_LEVELS | MOO_LOG_ALL_TYPES;
logmask = (MOO_LOG_ALL_LEVELS | MOO_LOG_ALL_TYPES) & ~(moo_bitmask_t)MOO_LOG_GC; /* all types except gc + all levels */
pathlen = moo_count_bcstr(str);
}
/* to have gc logs produced, you should specify 'all' or 'gc' */
*xlogmask = logmask;
*xpathlen = pathlen;
return 0;
@ -3304,7 +3313,8 @@ static int parse_logoptu (moo_t* moo, const moo_uch_t* str, moo_oow_t* xpathlen,
cm = moo_find_uchar_in_ucstr(str, ',');
pathlen = cm - str;
logmask = xtn->log.mask;
/*logmask = xtn->log.mask;*/
logmask = 0;
do
{
flt = cm + 1;
@ -3351,7 +3361,6 @@ static int handle_logoptb (moo_t* moo, const moo_bch_t* str)
moo_bch_t* xstr = (moo_bch_t*)str;
if (parse_logoptb(moo, str, &pathlen, &logmask) <= -1) return -1;
if (str[pathlen] != '\0')
{
xstr = moo_dupbchars(moo, str, pathlen);
@ -3366,13 +3375,14 @@ static int handle_logoptb (moo_t* moo, const moo_bch_t* str)
return -1;
}
xtn->log.mask = logmask;
/*xtn->log.mask = logmask;*/
xtn->log.fd_flag |= LOGFD_OPENED_HERE;
#if defined(HAVE_ISATTY)
if (isatty(xtn->log.fd)) xtn->log.fd_flag |= LOGFD_TTY;
#endif
if (str != xstr) moo_freemem (moo, xstr);
moo_setoption (moo, MOO_LOG_MASK, &logmask);
return 0;
}
@ -3396,13 +3406,14 @@ static int handle_logoptu (moo_t* moo, const moo_uch_t* str)
return -1;
}
xtn->log.mask = logmask;
/*xtn->log.mask = logmask;*/
xtn->log.fd_flag |= LOGFD_OPENED_HERE;
#if defined(HAVE_ISATTY)
if (isatty(xtn->log.fd)) xtn->log.fd_flag |= LOGFD_TTY;
#endif
moo_freemem (moo, xstr);
moo_setoption (moo, MOO_LOG_MASK, &logmask);
return 0;
}
@ -3521,11 +3532,11 @@ static MOO_INLINE void reset_log_to_default (xtn_t* xtn)
#if defined(HAVE_ISATTY)
if (isatty(xtn->log.fd)) xtn->log.fd_flag |= LOGFD_TTY;
#endif
xtn->log.mask = MOO_LOG_ALL_LEVELS | MOO_LOG_ALL_TYPES;
/*xtn->log.mask = MOO_LOG_ALL_LEVELS | MOO_LOG_ALL_TYPES;*/
#else
xtn->log.fd = -1;
xtn->log.fd_flag = 0;
xtn->log.mask = 0;
/*xtn->log.mask = 0;*/
#endif
}
@ -3606,6 +3617,21 @@ static void fini_moo (moo_t* moo)
evtcb.fini = fini_moo;
moo_regevtcb (moo, &evtcb);
{
moo_bitmask_t bm = 0;
moo_getoption (moo, MOO_TRAIT, &bm);
/*bm |= MOO_NOGC;*/
bm |= MOO_AWAIT_PROCS;
moo_setoption (moo, MOO_TRAIT, &bm);
/* disable GC logs */
moo_getoption (moo, MOO_LOG_MASK, &bm);
bm = ~MOO_LOG_GC;
moo_setoption (moo, MOO_LOG_MASK, &bm);
}
if (handle_cfg_options(moo, cfg) <= -1)
{
if (errinfo) moo_geterrinf (moo, errinfo);