Browse Source

DUK_REFZERO_CHECK() macro slow/fast variant

pull/1096/head
Sami Vaarala 8 years ago
parent
commit
ac75fe83b3
  1. 4
      src-input/duk_api_stack.c
  2. 9
      src-input/duk_heaphdr.h

4
src-input/duk_api_stack.c

@ -456,7 +456,7 @@ DUK_EXTERNAL void duk_set_top(duk_context *ctx, duk_idx_t idx) {
DUK_TVAL_SET_UNDEFINED_UPDREF_NORZ(thr, tv);
} while (tv != tv_end);
thr->valstack_top = tv_end;
DUK_REFZERO_CHECK(thr);
DUK_REFZERO_CHECK_FAST(thr);
#else /* DUK_USE_REFERENCE_COUNTING */
duk_uidx_t count;
duk_tval *tv_end;
@ -4448,7 +4448,7 @@ DUK_EXTERNAL void duk_pop_n(duk_context *ctx, duk_idx_t count) {
DUK_TVAL_SET_UNDEFINED_UPDREF_NORZ(thr, tv);
}
thr->valstack_top = tv;
DUK_REFZERO_CHECK(thr);
DUK_REFZERO_CHECK_FAST(thr);
#else
tv = thr->valstack_top;
while (count > 0) {

9
src-input/duk_heaphdr.h

@ -518,11 +518,14 @@ struct duk_heaphdr_string {
/* Free pending refzero entries; quick check to avoid call because often
* the queue is empty.
*/
#define DUK_REFZERO_CHECK(thr) do { \
#define DUK_REFZERO_CHECK_FAST(thr) do { \
if ((thr)->heap->refzero_list != NULL) { \
duk_refzero_free_pending((thr)); \
} \
} while (0)
#define DUK_REFZERO_CHECK_SLOW(thr) do { \
duk_refzero_free_pending((thr)); \
} while (0)
/*
* Macros to set a duk_tval and update refcount of the target (decref the
@ -767,7 +770,8 @@ struct duk_heaphdr_string {
#define DUK_HOBJECT_INCREF_ALLOWNULL(thr,h) do {} while (0) /* nop */
#define DUK_HOBJECT_DECREF_ALLOWNULL(thr,h) do {} while (0) /* nop */
#define DUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr,h) do {} while (0) /* nop */
#define DUK_REFZERO_CHECK(thr) do {} while (0) /* nop */
#define DUK_REFZERO_CHECK_FAST(thr) do {} while (0) /* nop */
#define DUK_REFZERO_CHECK_SLOW(thr) do {} while (0) /* nop */
#define DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0(thr,tvptr_dst) do { \
duk_tval *tv__dst; tv__dst = (tvptr_dst); \
@ -872,6 +876,7 @@ struct duk_heaphdr_string {
} while (0)
#define DUK_TVAL_SET_UNDEFINED_UPDREF DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0
#define DUK_TVAL_SET_UNDEFINED_UPDREF_NORZ DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0
#define DUK_TVAL_SET_UNUSED_UPDREF DUK_TVAL_SET_UNUSED_UPDREF_ALT0
#define DUK_TVAL_SET_NULL_UPDREF DUK_TVAL_SET_NULL_UPDREF_ALT0
#define DUK_TVAL_SET_BOOLEAN_UPDREF DUK_TVAL_SET_BOOLEAN_UPDREF_ALT0

Loading…
Cancel
Save