Browse Source

typing / -Wextra fixes

pull/1/head
Sami Vaarala 11 years ago
parent
commit
eae6626942
  1. 19
      src/duk_hthread.h
  2. 40
      src/duk_hthread_stacks.c
  3. 20
      src/duk_js_executor.c

19
src/duk_hthread.h

@ -166,8 +166,9 @@ struct duk_activation {
/* Note: it's nice if size is 2^N (not 4x4 = 16 bytes on 32 bit) */
struct duk_catcher {
/* FIXME: typing */
duk_size_t callstack_index; /* callstack index of related activation */
int flags; /* type and control flags */
int callstack_index; /* callstack index of related activation */
int pc_base; /* resume execution from pc_base or pc_base+1 */
int idx_base; /* idx_base and idx_base+1 get completion value and type */
duk_hstring *h_varname; /* borrowed reference to catch variable name (or NULL if none) */
@ -188,9 +189,9 @@ struct duk_hthread {
duk_uint8_t unused2;
/* sanity limits */
size_t valstack_max;
size_t callstack_max;
size_t catchstack_max;
duk_size_t valstack_max;
duk_size_t callstack_max;
duk_size_t catchstack_max;
/* XXX: valstack, callstack, and catchstack are currently assumed
* to have non-NULL pointers. Relaxing this would not lead to big
@ -205,14 +206,14 @@ struct duk_hthread {
/* call stack */
duk_activation *callstack;
size_t callstack_size; /* allocation size */
size_t callstack_top; /* next to use, highest used is top - 1 */
size_t callstack_preventcount; /* number of activation records in callstack preventing a yield */
duk_size_t callstack_size; /* allocation size */
duk_size_t callstack_top; /* next to use, highest used is top - 1 */
duk_size_t callstack_preventcount; /* number of activation records in callstack preventing a yield */
/* catch stack */
duk_catcher *catchstack;
size_t catchstack_size; /* allocation size */
size_t catchstack_top; /* next to use, highest used is top - 1 */
duk_size_t catchstack_size; /* allocation size */
duk_size_t catchstack_top; /* next to use, highest used is top - 1 */
/* yield/resume book-keeping */
duk_hthread *resumer; /* who resumed us (if any) */

40
src/duk_hthread_stacks.c

@ -24,12 +24,14 @@
/* check that there is space for at least one new entry */
void duk_hthread_callstack_grow(duk_hthread *thr) {
int old_size;
int new_size;
duk_size_t old_size;
duk_size_t new_size;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(thr->callstack_top >= 0 &&
thr->callstack_size >= thr->callstack_top);
#if 0
DUK_ASSERT(thr->callstack_top >= 0); /* avoid warning (unsigned) */
#endif
DUK_ASSERT(thr->callstack_size >= thr->callstack_top);
if (thr->callstack_top < thr->callstack_size) {
return;
@ -57,12 +59,14 @@ void duk_hthread_callstack_grow(duk_hthread *thr) {
}
void duk_hthread_callstack_shrink_check(duk_hthread *thr) {
int new_size;
duk_size_t new_size;
duk_activation *p;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(thr->callstack_top >= 0 &&
thr->callstack_size >= thr->callstack_top);
#if 0
DUK_ASSERT(thr->callstack_top >= 0); /* avoid warning (unsigned) */
#endif
DUK_ASSERT(thr->callstack_size >= thr->callstack_top);
if (thr->callstack_size - thr->callstack_top < DUK_CALLSTACK_SHRINK_THRESHOLD) {
return;
@ -91,7 +95,7 @@ void duk_hthread_callstack_shrink_check(duk_hthread *thr) {
}
void duk_hthread_callstack_unwind(duk_hthread *thr, int new_top) {
int idx;
int idx; /* FIXME: typing of idx and new_top */
DUK_DDDPRINT("unwind callstack top of thread %p from %d to %d",
(void *) thr,
@ -249,12 +253,14 @@ void duk_hthread_callstack_unwind(duk_hthread *thr, int new_top) {
}
void duk_hthread_catchstack_grow(duk_hthread *thr) {
int old_size;
int new_size;
duk_size_t old_size;
duk_size_t new_size;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(thr->catchstack_top >= 0 &&
thr->catchstack_size >= thr->catchstack_top);
#if 0
DUK_ASSERT(thr->catchstack_top); /* avoid warning (unsigned) */
#endif
DUK_ASSERT(thr->catchstack_size >= thr->catchstack_top);
if (thr->catchstack_top < thr->catchstack_size) {
return;
@ -282,12 +288,14 @@ void duk_hthread_catchstack_grow(duk_hthread *thr) {
}
void duk_hthread_catchstack_shrink_check(duk_hthread *thr) {
int new_size;
duk_size_t new_size;
duk_catcher *p;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(thr->catchstack_top >= 0 &&
thr->catchstack_size >= thr->catchstack_top);
#if 0
DUK_ASSERT(thr->catchstack_top >= 0); /* avoid warning (unsigned) */
#endif
DUK_ASSERT(thr->catchstack_size >= thr->catchstack_top);
if (thr->catchstack_size - thr->catchstack_top < DUK_CATCHSTACK_SHRINK_THRESHOLD) {
return;
@ -316,7 +324,7 @@ void duk_hthread_catchstack_shrink_check(duk_hthread *thr) {
}
void duk_hthread_catchstack_unwind(duk_hthread *thr, int new_top) {
int idx;
int idx; /* FIXME: typing of 'new_top' and 'idx' */
DUK_DDDPRINT("unwind catchstack top of thread %p from %d to %d",
(void *) thr,

20
src/duk_js_executor.c

@ -665,13 +665,14 @@ static void handle_yield(duk_hthread *thr, duk_hthread *resumer, int act_idx) {
static int handle_longjmp(duk_hthread *thr,
duk_hthread *entry_thread,
int entry_callstack_top) {
duk_size_t entry_callstack_top) {
duk_tval tv_tmp;
int entry_callstack_index;
duk_size_t entry_callstack_index;
int retval = DUK__LONGJMP_RESTART;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(entry_thread != NULL);
DUK_ASSERT(entry_callstack_top > 0); /* guarantees entry_callstack_top - 1 >= 0 */
entry_callstack_index = entry_callstack_top - 1;
@ -925,7 +926,7 @@ static int handle_longjmp(duk_hthread *thr,
duk_tval *tv1;
duk_hthread *resumer;
duk_catcher *cat;
int orig_callstack_index;
duk_size_t orig_callstack_index;
DUK_ASSERT(thr != NULL);
DUK_ASSERT(thr->callstack_top >= 1);
@ -935,6 +936,7 @@ static int handle_longjmp(duk_hthread *thr,
/* FIXME: does not work if thr->catchstack is allocated but lowest pointer */
cat = thr->catchstack + thr->catchstack_top - 1; /* may be < thr->catchstack initially */
DUK_ASSERT(thr->callstack_top > 0); /* ensures callstack_top - 1 >= 0 */
orig_callstack_index = thr->callstack_top - 1;
while (cat >= thr->catchstack) {
@ -1047,17 +1049,17 @@ static int handle_longjmp(duk_hthread *thr,
*/
duk_catcher *cat;
int orig_callstack_index;
int lj_label;
duk_size_t orig_callstack_index;
duk_uint_t lj_label;
cat = thr->catchstack + thr->catchstack_top - 1;
orig_callstack_index = cat->callstack_index;
DUK_ASSERT(DUK_TVAL_IS_NUMBER(&thr->heap->lj.value1));
lj_label = DUK_TVAL_GET_NUMBER(&thr->heap->lj.value1);
lj_label = (duk_uint_t) DUK_TVAL_GET_NUMBER(&thr->heap->lj.value1);
DUK_DDDPRINT("handling break/continue with label=%d, callstack index=%d",
lj_label, cat->callstack_index);
(int) lj_label, (int) cat->callstack_index);
while (cat >= thr->catchstack) {
if (cat->callstack_index != orig_callstack_index) {
@ -1079,7 +1081,7 @@ static int handle_longjmp(duk_hthread *thr,
goto wipe_and_return;
}
if (DUK_CAT_GET_TYPE(cat) == DUK_CAT_TYPE_LABEL &&
DUK_CAT_GET_LABEL(cat) == lj_label) {
(duk_uint_t) DUK_CAT_GET_LABEL(cat) == lj_label) {
/* found label */
handle_label(thr,
cat - thr->catchstack);
@ -1377,7 +1379,7 @@ static void duk_executor_interrupt(duk_hthread *thr) {
void duk_js_execute_bytecode(duk_hthread *entry_thread) {
/* entry level info */
int entry_callstack_top;
duk_size_t entry_callstack_top;
int entry_call_recursion_depth;
duk_jmpbuf *entry_jmpbuf_ptr;

Loading…
Cancel
Save