touching up code for ongoing gc enhancement

This commit is contained in:
hyunghwan.chung 2018-12-08 15:35:26 +00:00
parent a7fc55efac
commit 033c34f9b2
10 changed files with 131 additions and 120 deletions

View File

@ -79,7 +79,7 @@ static moo_oop_oop_t expand_bucket (moo_t* moo, moo_oop_oop_t oldbuc)
index = moo_hashoochars(key->slot, MOO_OBJ_GET_SIZE(key)) % newsz; index = moo_hashoochars(key->slot, MOO_OBJ_GET_SIZE(key)) % newsz;
while (newbuc->slot[index] != moo->_nil) index = (index + 1) % newsz; while (newbuc->slot[index] != moo->_nil) index = (index + 1) % newsz;
MOO_STORE_OOP_TO_ARRAY (moo, newbuc, index, (moo_oop_t)ass); /* newbuc->slot[index] = (moo_oop_t)ass; */ MOO_STORE_OOP (moo, &newbuc->slot[index], (moo_oop_t)ass); /* newbuc->slot[index] = (moo_oop_t)ass; */
} }
} }
@ -117,7 +117,7 @@ static moo_oop_association_t find_or_upsert (moo_t* moo, moo_oop_dic_t dic, moo_
moo_equal_oochars(key->slot, ((moo_oop_char_t)ass->key)->slot, MOO_OBJ_GET_SIZE(key))) moo_equal_oochars(key->slot, ((moo_oop_char_t)ass->key)->slot, MOO_OBJ_GET_SIZE(key)))
{ {
/* the value of MOO_NULL indicates no insertion or update. */ /* the value of MOO_NULL indicates no insertion or update. */
if (value) ass->value = value; /* update */ if (value) MOO_STORE_OOP (moo, &ass->value, value); /*ass->value = value;*/ /* update */
return ass; return ass;
} }
@ -180,14 +180,14 @@ static moo_oop_association_t find_or_upsert (moo_t* moo, moo_oop_dic_t dic, moo_
ass = (moo_oop_association_t)moo_instantiate(moo, moo->_association, MOO_NULL, 0); ass = (moo_oop_association_t)moo_instantiate(moo, moo->_association, MOO_NULL, 0);
if (!ass) goto oops; if (!ass) goto oops;
ass->key = (moo_oop_t)key; MOO_STORE_OOP (moo, &ass->key, (moo_oop_t)key); /*ass->key = (moo_oop_t)key; */
ass->value = value; MOO_STORE_OOP (moo, &ass->value, value); /*ass->value = value;*/
/* the current tally must be less than the maximum value. otherwise, /* the current tally must be less than the maximum value. otherwise,
* it overflows after increment below */ * it overflows after increment below */
MOO_ASSERT (moo, tally < MOO_SMOOI_MAX); MOO_ASSERT (moo, tally < MOO_SMOOI_MAX);
dic->tally = MOO_SMOOI_TO_OOP(tally + 1); dic->tally = MOO_SMOOI_TO_OOP(tally + 1); /* no need to use MOO_STORE_OOP as the value is not a pointer object */
MOO_STORE_OOP_TO_ARRAY (moo, dic->bucket, index, (moo_oop_t)ass); /*dic->bucket->slot[index] = (moo_oop_t)ass;*/ MOO_STORE_OOP (moo, &dic->bucket->slot[index], (moo_oop_t)ass); /*dic->bucket->slot[index] = (moo_oop_t)ass;*/
moo_poptmps (moo, tmp_count); moo_poptmps (moo, tmp_count);
return ass; return ass;
@ -322,12 +322,12 @@ found:
if ((y > x && (z <= x || z > y)) || if ((y > x && (z <= x || z > y)) ||
(y < x && (z <= x && z > y))) (y < x && (z <= x && z > y)))
{ {
MOO_STORE_OOP_TO_ARRAY (moo, dic->bucket, x, dic->bucket->slot[y]); /*dic->bucket->slot[x] = dic->bucket->slot[y];*/ MOO_STORE_OOP (moo, &dic->bucket->slot[x], dic->bucket->slot[y]); /*dic->bucket->slot[x] = dic->bucket->slot[y];*/
x = y; x = y;
} }
} }
MOO_STORE_OOP_TO_ARRAY (moo, dic->bucket, x, moo->_nil); /*dic->bucket->slot[x] = moo->_nil;*/ MOO_STORE_OOP (moo, &dic->bucket->slot[x], moo->_nil); /*dic->bucket->slot[x] = moo->_nil;*/
tally--; tally--;
dic->tally = MOO_SMOOI_TO_OOP(tally); dic->tally = MOO_SMOOI_TO_OOP(tally);

View File

@ -1994,19 +1994,19 @@ static moo_pfrc_t pf_hash (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
switch (type) switch (type)
{ {
case MOO_OBJ_TYPE_BYTE: case MOO_OBJ_TYPE_BYTE:
hv = moo_hash_bytes(((moo_oop_byte_t)rcv)->slot, MOO_OBJ_GET_SIZE(rcv)); hv = moo_hash_bytes(MOO_OBJ_GET_BYTE_SLOT(rcv), MOO_OBJ_GET_SIZE(rcv));
break; break;
case MOO_OBJ_TYPE_CHAR: case MOO_OBJ_TYPE_CHAR:
hv = moo_hashoochars (((moo_oop_char_t)rcv)->slot, MOO_OBJ_GET_SIZE(rcv)); hv = moo_hashoochars (MOO_OBJ_GET_CHAR_SLOT(rcv), MOO_OBJ_GET_SIZE(rcv));
break; break;
case MOO_OBJ_TYPE_HALFWORD: case MOO_OBJ_TYPE_HALFWORD:
hv = moo_hashhalfwords(((moo_oop_halfword_t)rcv)->slot, MOO_OBJ_GET_SIZE(rcv)); hv = moo_hashhalfwords(MOO_OBJ_GET_HALFWORD_SLOT(rcv), MOO_OBJ_GET_SIZE(rcv));
break; break;
case MOO_OBJ_TYPE_WORD: case MOO_OBJ_TYPE_WORD:
hv = moo_hashwords(((moo_oop_word_t)rcv)->slot, MOO_OBJ_GET_SIZE(rcv)); hv = moo_hashwords(MOO_OBJ_GET_WORD_SLOT(rcv), MOO_OBJ_GET_SIZE(rcv));
break; break;
default: default:
@ -5408,7 +5408,7 @@ static int __execute (moo_t* moo)
else if (MOO_OOP_IS_ERROR(t1)) bv = MOO_OOP_TO_ERROR(t1); else if (MOO_OOP_IS_ERROR(t1)) bv = MOO_OOP_TO_ERROR(t1);
else if (MOO_OOP_IS_SMPTR(t1)) bv = ((moo_oow_t)MOO_OOP_TO_SMPTR(t1) & 0xFF); else if (MOO_OOP_IS_SMPTR(t1)) bv = ((moo_oow_t)MOO_OOP_TO_SMPTR(t1) & 0xFF);
else bv = 0; else bv = 0;
((moo_oop_byte_t)t2)->slot[b1] = bv; MOO_OBJ_GET_BYTE_SLOT(t2)[b1] = bv;
NEXT_INST(); NEXT_INST();
} }

View File

@ -583,7 +583,7 @@ int moo_ignite (moo_t* moo, moo_oow_t heapsz)
moo->heap = moo_makeheap(moo, heapsz); moo->heap = moo_makeheap(moo, heapsz);
if (!moo->heap) return -1; if (!moo->heap) return -1;
moo->_nil = moo_allocbytes (moo, MOO_SIZEOF(moo_obj_t)); moo->_nil = moo_allocpermbytes(moo, MOO_SIZEOF(moo_obj_t));
if (!moo->_nil) return -1; if (!moo->_nil) return -1;
moo->_nil->_flags = MOO_OBJ_MAKE_FLAGS (MOO_OBJ_TYPE_OOP, MOO_SIZEOF(moo_oop_t), 0, 1, 0, 0, 0); moo->_nil->_flags = MOO_OBJ_MAKE_FLAGS (MOO_OBJ_TYPE_OOP, MOO_SIZEOF(moo_oop_t), 0, 1, 0, 0, 0);
@ -601,6 +601,7 @@ int moo_ignite (moo_t* moo, moo_oow_t heapsz)
static void compact_symbol_table (moo_t* moo, moo_oop_t _nil) static void compact_symbol_table (moo_t* moo, moo_oop_t _nil)
{ {
moo_oop_oop_t bucket;
moo_oop_char_t symbol; moo_oop_char_t symbol;
moo_oow_t i, x, y, z; moo_oow_t i, x, y, z;
moo_oow_t bucket_size, index; moo_oow_t bucket_size, index;
@ -617,45 +618,46 @@ static void compact_symbol_table (moo_t* moo, moo_oop_t _nil)
MOO_ASSERT (moo, tally >= 0); /* it must not be less than 0 */ MOO_ASSERT (moo, tally >= 0); /* it must not be less than 0 */
if (tally <= 0) return; if (tally <= 0) return;
bucket = moo->symtab->bucket;
/* NOTE: in theory, the bucket size can be greater than MOO_SMOOI_MAX /* NOTE: in theory, the bucket size can be greater than MOO_SMOOI_MAX
* as it is an internal header field and is of an unsigned type */ * as it is an internal header field and is of an unsigned type */
bucket_size = MOO_OBJ_GET_SIZE(moo->symtab->bucket); bucket_size = MOO_OBJ_GET_SIZE(bucket);
for (index = 0; index < bucket_size; ) for (index = 0; index < bucket_size; )
{ {
if (MOO_OBJ_GET_FLAGS_MOVED(moo->symtab->bucket->slot[index])) if (MOO_OBJ_GET_FLAGS_MOVED(bucket->slot[index]))
{ {
index++; index++;
continue; continue;
} }
MOO_ASSERT (moo, moo->symtab->bucket->slot[index] != _nil); MOO_ASSERT (moo, bucket->slot[index] != _nil);
for (i = 0, x = index, y = index; i < bucket_size; i++) for (i = 0, x = index, y = index; i < bucket_size; i++)
{ {
y = (y + 1) % bucket_size; y = (y + 1) % bucket_size;
/* done if the slot at the current hash index is _nil */ /* done if the slot at the current hash index is _nil */
if (moo->symtab->bucket->slot[y] == _nil) break; if (bucket->slot[y] == _nil) break;
/* get the natural hash index for the data in the slot /* get the natural hash index for the data in the slot
* at the current hash index */ * at the current hash index */
symbol = (moo_oop_char_t)moo->symtab->bucket->slot[y]; symbol = (moo_oop_char_t)bucket->slot[y];
MOO_ASSERT (moo, MOO_CLASSOF(moo,symbol) == moo->_symbol); MOO_ASSERT (moo, MOO_CLASSOF(moo,symbol) == moo->_symbol);
z = moo_hashoochars(symbol->slot, MOO_OBJ_GET_SIZE(symbol)) % bucket_size; z = moo_hashoochars(MOO_OBJ_GET_CHAR_SLOT(symbol), MOO_OBJ_GET_SIZE(symbol)) % bucket_size;
/* move an element if necessary */ /* move an element if necessary */
if ((y > x && (z <= x || z > y)) || if ((y > x && (z <= x || z > y)) ||
(y < x && (z <= x && z > y))) (y < x && (z <= x && z > y)))
{ {
moo->symtab->bucket->slot[x] = moo->symtab->bucket->slot[y]; bucket->slot[x] = bucket->slot[y];
x = y; x = y;
} }
} }
moo->symtab->bucket->slot[x] = _nil; bucket->slot[x] = _nil;
tally--; tally--;
} }

View File

@ -26,15 +26,18 @@
#include "moo-prv.h" #include "moo-prv.h"
#define MIN_HEAP_SIZE 65536 /* TODO: adjust this value? */
#define PERM_SPACE_SIZE 2048 /* TODO: adjust perm space size depending on what's allocated in the permspace */
moo_heap_t* moo_makeheap (moo_t* moo, moo_oow_t size) moo_heap_t* moo_makeheap (moo_t* moo, moo_oow_t size)
{ {
moo_heap_t* heap; moo_heap_t* heap;
moo_oow_t half_size; moo_oow_t half_size;
if (size < 65536) size = 65536; /* not really useful check as 65536 is too small */ if (size < MIN_HEAP_SIZE) size = MIN_HEAP_SIZE;
half_size = size / 2; half_size = size / 2;
heap = (moo_heap_t*)moo->vmprim.alloc_heap(moo, MOO_SIZEOF(*heap) + size); heap = (moo_heap_t*)moo->vmprim.alloc_heap(moo, MOO_SIZEOF(*heap) + PERM_SPACE_SIZE + size);
if (!heap) if (!heap)
{ {
const moo_ooch_t* oldmsg = moo_backuperrmsg(moo); const moo_ooch_t* oldmsg = moo_backuperrmsg(moo);
@ -46,16 +49,23 @@ moo_heap_t* moo_makeheap (moo_t* moo, moo_oow_t size)
heap->base = (moo_uint8_t*)(heap + 1); heap->base = (moo_uint8_t*)(heap + 1);
heap->size = size; heap->size = size;
heap->curspace.base= (moo_uint8_t*)(heap + 1); /* TODO: consider placing permspace in a separate memory allocated block in case we have to grow
* other spaces. we may be able to realloc() the entire heap region without affecting the separately
* allocated block. */
heap->permspace.base = (moo_uint8_t*)(heap + 1);
heap->permspace.ptr = (moo_uint8_t*)MOO_ALIGN(((moo_uintptr_t)heap->permspace.base), MOO_SIZEOF(moo_oop_t));
heap->permspace.limit = heap->permspace.base + PERM_SPACE_SIZE;
heap->curspace.base = heap->permspace.limit;
heap->curspace.ptr = (moo_uint8_t*)MOO_ALIGN(((moo_uintptr_t)heap->curspace.base), MOO_SIZEOF(moo_oop_t)); heap->curspace.ptr = (moo_uint8_t*)MOO_ALIGN(((moo_uintptr_t)heap->curspace.base), MOO_SIZEOF(moo_oop_t));
heap->curspace.limit = heap->curspace.ptr + half_size; heap->curspace.limit = heap->curspace.base + half_size;
heap->newspace.base = (moo_uint8_t*)(heap + 1) + half_size; heap->newspace.base = heap->curspace.limit; /*(moo_uint8_t*)(heap + 1) + half_size;*/
heap->newspace.ptr = (moo_uint8_t*)MOO_ALIGN(((moo_uintptr_t)heap->newspace.base), MOO_SIZEOF(moo_oop_t)); heap->newspace.ptr = (moo_uint8_t*)MOO_ALIGN(((moo_uintptr_t)heap->newspace.base), MOO_SIZEOF(moo_oop_t));
heap->newspace.limit = heap->newspace.ptr + half_size; heap->newspace.limit = heap->newspace.base + half_size;
/* if size is too small, space->ptr may go past space->limit even at /* if size is too small, space.ptr may go past space.limit even at
* this moment depending on the alignment of space->base. subsequent * this moment depending on the alignment of space.base. subsequent
* calls to moo_allocheapspace() are bound to fail. Make sure to * calls to moo_allocheapspace() are bound to fail. Make sure to
* pass a heap size large enough */ * pass a heap size large enough */

View File

@ -420,7 +420,7 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_
if (outbfmt (moo, mask, "-16r") <= -1) return -1; if (outbfmt (moo, mask, "-16r") <= -1) return -1;
for (i = MOO_OBJ_GET_SIZE(oop); i > 0;) for (i = MOO_OBJ_GET_SIZE(oop); i > 0;)
{ {
if (outbfmt(moo, mask, "%0*lX", (int)(MOO_SIZEOF(moo_liw_t) * 2), (unsigned long)((moo_oop_liword_t)oop)->slot[--i]) <= -1) return -1; if (outbfmt(moo, mask, "%0*lX", (int)(MOO_SIZEOF(moo_liw_t) * 2), (unsigned long int)(MOO_OBJ_GET_LIWORD_SLOT(oop)[--i])) <= -1) return -1;
} }
} }
else if (c == moo->_large_positive_integer) else if (c == moo->_large_positive_integer)
@ -429,7 +429,7 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_
if (outbfmt (moo, mask, "16r") <= -1) return -1; if (outbfmt (moo, mask, "16r") <= -1) return -1;
for (i = MOO_OBJ_GET_SIZE(oop); i > 0;) for (i = MOO_OBJ_GET_SIZE(oop); i > 0;)
{ {
if (outbfmt(moo, mask, "%0*lX", (int)(MOO_SIZEOF(moo_liw_t) * 2), (unsigned long)((moo_oop_liword_t)oop)->slot[--i]) <= -1) return -1; if (outbfmt(moo, mask, "%0*lX", (int)(MOO_SIZEOF(moo_liw_t) * 2), (unsigned long int)(MOO_OBJ_GET_LIWORD_SLOT(oop)[--i])) <= -1) return -1;
} }
} }
else if (MOO_OBJ_GET_FLAGS_TYPE(oop) == MOO_OBJ_TYPE_CHAR) else if (MOO_OBJ_GET_FLAGS_TYPE(oop) == MOO_OBJ_TYPE_CHAR)
@ -445,7 +445,7 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_
for (i = 0; i < MOO_OBJ_GET_SIZE(oop); i++) for (i = 0; i < MOO_OBJ_GET_SIZE(oop); i++)
{ {
ch = ((moo_oop_char_t)oop)->slot[i]; ch = MOO_OBJ_GET_CHAR_SLOT(oop)[i];
if (ch < ' ') if (ch < ' ')
{ {
escape = 1; escape = 1;
@ -460,7 +460,7 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_
if (outbfmt(moo, mask, "S'") <= -1) return -1; if (outbfmt(moo, mask, "S'") <= -1) return -1;
for (i = 0; i < MOO_OBJ_GET_SIZE(oop); i++) for (i = 0; i < MOO_OBJ_GET_SIZE(oop); i++)
{ {
ch = ((moo_oop_char_t)oop)->slot[i]; ch = MOO_OBJ_GET_CHAR_SLOT(oop)[i];
if (ch < ' ') if (ch < ' ')
{ {
switch (ch) switch (ch)
@ -523,10 +523,10 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_
i = 0; i = 0;
if (i < MOO_OBJ_GET_SIZE(oop)) if (i < MOO_OBJ_GET_SIZE(oop))
{ {
if (outbfmt(moo, mask, "%d", ((moo_oop_byte_t)oop)->slot[i]) <= -1) return -1; if (outbfmt(moo, mask, "%d", MOO_OBJ_GET_BYTE_SLOT(oop)[i]) <= -1) return -1;
for (++i; i < MOO_OBJ_GET_SIZE(oop); i++) for (++i; i < MOO_OBJ_GET_SIZE(oop); i++)
{ {
if (outbfmt(moo, mask, " %d", ((moo_oop_byte_t)oop)->slot[i]) <= -1) return -1; if (outbfmt(moo, mask, " %d", MOO_OBJ_GET_BYTE_SLOT(oop)[i]) <= -1) return -1;
} }
} }
if (outbfmt(moo, mask, "]") <= -1) return -1; if (outbfmt(moo, mask, "]") <= -1) return -1;
@ -537,7 +537,7 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_
if (outbfmt(moo, mask, "#[[") <= -1) return -1;; /* TODO: fix this symbol/notation */ if (outbfmt(moo, mask, "#[[") <= -1) return -1;; /* TODO: fix this symbol/notation */
for (i = 0; i < MOO_OBJ_GET_SIZE(oop); i++) for (i = 0; i < MOO_OBJ_GET_SIZE(oop); i++)
{ {
if (outbfmt(moo, mask, " %zX", (moo_oow_t)((moo_oop_halfword_t)oop)->slot[i]) <= -1) return -1; if (outbfmt(moo, mask, " %zX", (moo_oow_t)(MOO_OBJ_GET_HALFWORD_SLOT(oop)[i])) <= -1) return -1;
} }
outbfmt (moo, mask, "]]"); outbfmt (moo, mask, "]]");
} }
@ -546,7 +546,7 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_
if (outbfmt(moo, mask, "#[[[") <= -1) return -1;; /* TODO: fix this symbol/notation */ if (outbfmt(moo, mask, "#[[[") <= -1) return -1;; /* TODO: fix this symbol/notation */
for (i = 0; i < MOO_OBJ_GET_SIZE(oop); i++) for (i = 0; i < MOO_OBJ_GET_SIZE(oop); i++)
{ {
if (outbfmt(moo, mask, " %zX", ((moo_oop_word_t)oop)->slot[i]) <= -1) return -1; if (outbfmt(moo, mask, " %zX", MOO_OBJ_GET_WORD_SLOT(oop)[i]) <= -1) return -1;
} }
if (outbfmt(moo, mask, "]]]") <= -1) return -1; if (outbfmt(moo, mask, "]]]") <= -1) return -1;
} }
@ -556,11 +556,11 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_
i = 0; i = 0;
if (i < MOO_OBJ_GET_SIZE(oop)) if (i < MOO_OBJ_GET_SIZE(oop))
{ {
if (print_object(moo, mask, ((moo_oop_oop_t)oop)->slot[i], outbfmt) <= -1) return -1; if (print_object(moo, mask, MOO_OBJ_GET_OOP_SLOT(oop)[i], outbfmt) <= -1) return -1;
for (++i; i < MOO_OBJ_GET_SIZE(oop); i++) for (++i; i < MOO_OBJ_GET_SIZE(oop); i++)
{ {
if (outbfmt(moo, mask, " ") <= -1) return -1; if (outbfmt(moo, mask, " ") <= -1) return -1;
if (print_object(moo, mask, ((moo_oop_oop_t)oop)->slot[i], outbfmt) <= -1) return -1; if (print_object(moo, mask, MOO_OBJ_GET_OOP_SLOT(oop)[i], outbfmt) <= -1) return -1;
} }
} }
if (outbfmt(moo, mask, ")") <= -1) return -1; if (outbfmt(moo, mask, ")") <= -1) return -1;
@ -568,7 +568,7 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_
else if (c == moo->_class) else if (c == moo->_class)
{ {
/* print the class name */ /* print the class name */
if (outbfmt(moo, mask, "%.*js", MOO_OBJ_GET_SIZE(((moo_oop_class_t)oop)->name), ((moo_oop_class_t)oop)->name->slot) <= -1) return -1; if (outbfmt(moo, mask, "%.*js", MOO_OBJ_GET_SIZE(((moo_oop_class_t)oop)->name), MOO_OBJ_GET_CHAR_SLOT(((moo_oop_class_t)oop)->name)) <= -1) return -1;
} }
else if (c == moo->_association) else if (c == moo->_association)
{ {
@ -576,7 +576,7 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_
} }
else else
{ {
if (outbfmt(moo, mask, "<<%.*js:%p>>", MOO_OBJ_GET_SIZE(c->name), ((moo_oop_char_t)c->name)->slot, oop) <= -1) return -1; if (outbfmt(moo, mask, "<<%.*js:%p>>", MOO_OBJ_GET_SIZE(c->name), MOO_OBJ_GET_CHAR_SLOT(c->name), oop) <= -1) return -1;
} }
} }

View File

@ -493,6 +493,7 @@ struct moo_obj_word_t
#define MOO_OBJ_GET_BYTE_SLOT(oop) (((moo_oop_byte_t)(oop))->slot) #define MOO_OBJ_GET_BYTE_SLOT(oop) (((moo_oop_byte_t)(oop))->slot)
#define MOO_OBJ_GET_HALFWORD_SLOT(oop) (((moo_oop_halfword_t)(oop))->slot) #define MOO_OBJ_GET_HALFWORD_SLOT(oop) (((moo_oop_halfword_t)(oop))->slot)
#define MOO_OBJ_GET_WORD_SLOT(oop) (((moo_oop_word_t)(oop))->slot) #define MOO_OBJ_GET_WORD_SLOT(oop) (((moo_oop_word_t)(oop))->slot)
#define MOO_OBJ_GET_LIWORD_SLOT(oop) (((moo_oop_liword_t)(oop))->slot)
typedef struct moo_trailer_t moo_trailer_t; typedef struct moo_trailer_t moo_trailer_t;
struct moo_trailer_t struct moo_trailer_t
@ -1840,10 +1841,8 @@ extern "C" {
#if defined(MOO_HAVE_INLINE) #if defined(MOO_HAVE_INLINE)
static MOO_INLINE void MOO_STORE_OOP (moo_t* moo, moo_oop_t* rcvaddr, moo_oop_t val) { *rcvaddr = val; } static MOO_INLINE void MOO_STORE_OOP (moo_t* moo, moo_oop_t* rcvaddr, moo_oop_t val) { *rcvaddr = val; }
static MOO_INLINE void MOO_STORE_OOP_TO_ARRAY (moo_t* moo, moo_oop_oop_t rcv, moo_oow_t idx, moo_oop_t val) { MOO_STORE_OOP (moo, &rcv->slot[idx], val); }
#else #else
# define MOO_STORE_OOP(moo,rcvaddr,val) (*(rcvaddr) = val) # define MOO_STORE_OOP(moo,rcvaddr,val) (*(rcvaddr) = val)
# define MOO_STORE_OOP_TO_ARRAY(moo,rcv,idx,val) MOO_STORE_OOP(moo, &((moo_oop_oop_t)rcv)->slot[idx], val)
#endif #endif
MOO_EXPORT moo_t* moo_open ( MOO_EXPORT moo_t* moo_open (

View File

@ -441,7 +441,7 @@ moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
} }
case MOO_OBJ_TYPE_OOP: case MOO_OBJ_TYPE_OOP:
MOO_STORE_OOP_TO_ARRAY (moo, (moo_oop_oop_t)rcv, idx, val); /*((moo_oop_oop_t)rcv)->slot[idx] = val;*/ MOO_STORE_OOP (moo, &((moo_oop_oop_t)rcv)->slot[idx], val); /*((moo_oop_oop_t)rcv)->slot[idx] = val;*/
break; break;
default: default:

View File

@ -622,7 +622,7 @@ moo_pfrc_t moo_pf_system_get_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (len_in_buffer > 0) if (len_in_buffer > 0)
{ {
MOO_MEMCPY (&((moo_oop_byte_t)tmp)->slot[offset_in_buffer], &rawptr[offset], len_in_buffer); MOO_MEMCPY (&MOO_OBJ_GET_BYTE_SLOT(tmp)[offset_in_buffer], &rawptr[offset], len_in_buffer);
} }
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer)); MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer));
@ -685,7 +685,7 @@ moo_pfrc_t moo_pf_system_put_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (len_in_buffer > 0) if (len_in_buffer > 0)
{ {
MOO_MEMCPY (&rawptr[offset], &((moo_oop_byte_t)tmp)->slot[offset_in_buffer], len_in_buffer); MOO_MEMCPY (&rawptr[offset], &MOO_OBJ_GET_BYTE_SLOT(tmp)[offset_in_buffer], len_in_buffer);
} }
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer)); MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer));
@ -941,7 +941,7 @@ moo_pfrc_t moo_pf_smptr_get_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (len_in_buffer > 0) if (len_in_buffer > 0)
{ {
MOO_MEMCPY (&((moo_oop_byte_t)tmp)->slot[offset_in_buffer], &rawptr[offset], len_in_buffer); MOO_MEMCPY (&MOO_OBJ_GET_BYTE_SLOT(tmp)[offset_in_buffer], &rawptr[offset], len_in_buffer);
} }
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer)); MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer));
@ -999,7 +999,7 @@ moo_pfrc_t moo_pf_smptr_put_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (len_in_buffer > 0) if (len_in_buffer > 0)
{ {
MOO_MEMCPY (&rawptr[offset], &((moo_oop_byte_t)tmp)->slot[offset_in_buffer], len_in_buffer); MOO_MEMCPY (&rawptr[offset], &MOO_OBJ_GET_BYTE_SLOT(tmp)[offset_in_buffer], len_in_buffer);
} }
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer)); MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer));