You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ph...@apache.org on 2018/01/02 18:28:11 UTC

[16/51] [partial] nifi-minifi-cpp git commit: MINIFICPP-351: Remove Civetweb third party directory

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/ede68a10/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_heap_stringcache.c
----------------------------------------------------------------------
diff --git a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_heap_stringcache.c b/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_heap_stringcache.c
deleted file mode 100644
index ace607e..0000000
--- a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_heap_stringcache.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- *  String cache.
- *
- *  Provides a cache to optimize indexed string lookups.  The cache keeps
- *  track of (byte offset, char offset) states for a fixed number of strings.
- *  Otherwise we'd need to scan from either end of the string, as we store
- *  strings in (extended) UTF-8.
- */
-
-#include "duk_internal.h"
-
-/*
- *  Delete references to given hstring from the heap string cache.
- *
- *  String cache references are 'weak': they are not counted towards
- *  reference counts, nor serve as roots for mark-and-sweep.  When an
- *  object is about to be freed, such references need to be removed.
- */
-
-DUK_INTERNAL void duk_heap_strcache_string_remove(duk_heap *heap, duk_hstring *h) {
-	duk_small_int_t i;
-	for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) {
-		duk_strcache *c = heap->strcache + i;
-		if (c->h == h) {
-			DUK_DD(DUK_DDPRINT("deleting weak strcache reference to hstring %p from heap %p",
-			                   (void *) h, (void *) heap));
-			c->h = NULL;
-
-			/* XXX: the string shouldn't appear twice, but we now loop to the
-			 * end anyway; if fixed, add a looping assertion to ensure there
-			 * is no duplicate.
-			 */
-		}
-	}
-}
-
-/*
- *  String scanning helpers
- *
- *  All bytes other than UTF-8 continuation bytes ([0x80,0xbf]) are
- *  considered to contribute a character.  This must match how string
- *  character length is computed.
- */
-
-DUK_LOCAL const duk_uint8_t *duk__scan_forwards(const duk_uint8_t *p, const duk_uint8_t *q, duk_uint_fast32_t n) {
-	while (n > 0) {
-		for (;;) {
-			p++;
-			if (p >= q) {
-				return NULL;
-			}
-			if ((*p & 0xc0) != 0x80) {
-				break;
-			}
-		}
-		n--;
-	}
-	return p;
-}
-
-DUK_LOCAL const duk_uint8_t *duk__scan_backwards(const duk_uint8_t *p, const duk_uint8_t *q, duk_uint_fast32_t n) {
-	while (n > 0) {
-		for (;;) {
-			p--;
-			if (p < q) {
-				return NULL;
-			}
-			if ((*p & 0xc0) != 0x80) {
-				break;
-			}
-		}
-		n--;
-	}
-	return p;
-}
-
-/*
- *  Convert char offset to byte offset
- *
- *  Avoid using the string cache if possible: for ASCII strings byte and
- *  char offsets are equal and for short strings direct scanning may be
- *  better than using the string cache (which may evict a more important
- *  entry).
- *
- *  Typing now assumes 32-bit string byte/char offsets (duk_uint_fast32_t).
- *  Better typing might be to use duk_size_t.
- */
-
-DUK_INTERNAL duk_uint_fast32_t duk_heap_strcache_offset_char2byte(duk_hthread *thr, duk_hstring *h, duk_uint_fast32_t char_offset) {
-	duk_heap *heap;
-	duk_strcache *sce;
-	duk_uint_fast32_t byte_offset;
-	duk_small_int_t i;
-	duk_bool_t use_cache;
-	duk_uint_fast32_t dist_start, dist_end, dist_sce;
-	const duk_uint8_t *p_start;
-	const duk_uint8_t *p_end;
-	const duk_uint8_t *p_found;
-
-	if (char_offset > DUK_HSTRING_GET_CHARLEN(h)) {
-		goto error;
-	}
-
-	/*
-	 *  For ASCII strings, the answer is simple.
-	 */
-
-	if (DUK_HSTRING_IS_ASCII(h)) {
-		/* clen == blen -> pure ascii */
-		return char_offset;
-	}
-
-	/*
-	 *  For non-ASCII strings, we need to scan forwards or backwards
-	 *  from some starting point.  The starting point may be the start
-	 *  or end of the string, or some cached midpoint in the string
-	 *  cache.
-	 *
-	 *  For "short" strings we simply scan without checking or updating
-	 *  the cache.  For longer strings we check and update the cache as
-	 *  necessary, inserting a new cache entry if none exists.
-	 */
-
-	DUK_DDD(DUK_DDDPRINT("non-ascii string %p, char_offset=%ld, clen=%ld, blen=%ld",
-	                     (void *) h, (long) char_offset,
-	                     (long) DUK_HSTRING_GET_CHARLEN(h),
-	                     (long) DUK_HSTRING_GET_BYTELEN(h)));
-
-	heap = thr->heap;
-	sce = NULL;
-	use_cache = (DUK_HSTRING_GET_CHARLEN(h) > DUK_HEAP_STRINGCACHE_NOCACHE_LIMIT);
-
-	if (use_cache) {
-#ifdef DUK_USE_DDDPRINT
-		DUK_DDD(DUK_DDDPRINT("stringcache before char2byte (using cache):"));
-		for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) {
-			duk_strcache *c = heap->strcache + i;
-			DUK_DDD(DUK_DDDPRINT("  [%ld] -> h=%p, cidx=%ld, bidx=%ld",
-			                     (long) i, (void *) c->h, (long) c->cidx, (long) c->bidx));
-		}
-#endif
-
-		for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) {
-			duk_strcache *c = heap->strcache + i;
-
-			if (c->h == h) {
-				sce = c;
-				break;
-			}
-		}
-	}
-
-	/*
-	 *  Scan from shortest distance:
-	 *    - start of string
-	 *    - end of string
-	 *    - cache entry (if exists)
-	 */
-
-	DUK_ASSERT(DUK_HSTRING_GET_CHARLEN(h) >= char_offset);
-	dist_start = char_offset;
-	dist_end = DUK_HSTRING_GET_CHARLEN(h) - char_offset;
-	dist_sce = 0; DUK_UNREF(dist_sce);  /* initialize for debug prints, needed if sce==NULL */
-
-	p_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h);
-	p_end = (const duk_uint8_t *) (p_start + DUK_HSTRING_GET_BYTELEN(h));
-	p_found = NULL;
-
-	if (sce) {
-		if (char_offset >= sce->cidx) {
-			dist_sce = char_offset - sce->cidx;
-			if ((dist_sce <= dist_start) && (dist_sce <= dist_end)) {
-				DUK_DDD(DUK_DDDPRINT("non-ascii string, use_cache=%ld, sce=%p:%ld:%ld, "
-				                     "dist_start=%ld, dist_end=%ld, dist_sce=%ld => "
-				                     "scan forwards from sce",
-				                     (long) use_cache, (void *) (sce ? sce->h : NULL),
-				                     (sce ? (long) sce->cidx : (long) -1),
-				                     (sce ? (long) sce->bidx : (long) -1),
-				                     (long) dist_start, (long) dist_end, (long) dist_sce));
-
-				p_found = duk__scan_forwards(p_start + sce->bidx,
-				                             p_end,
-				                             dist_sce);
-				goto scan_done;
-			}
-		} else {
-			dist_sce = sce->cidx - char_offset;
-			if ((dist_sce <= dist_start) && (dist_sce <= dist_end)) {
-				DUK_DDD(DUK_DDDPRINT("non-ascii string, use_cache=%ld, sce=%p:%ld:%ld, "
-				                     "dist_start=%ld, dist_end=%ld, dist_sce=%ld => "
-				                     "scan backwards from sce",
-				                     (long) use_cache, (void *) (sce ? sce->h : NULL),
-				                     (sce ? (long) sce->cidx : (long) -1),
-				                     (sce ? (long) sce->bidx : (long) -1),
-				                     (long) dist_start, (long) dist_end, (long) dist_sce));
-
-				p_found = duk__scan_backwards(p_start + sce->bidx,
-				                              p_start,
-				                              dist_sce);
-				goto scan_done;
-			}
-		}
-	}
-
-	/* no sce, or sce scan not best */
-
-	if (dist_start <= dist_end) {
-		DUK_DDD(DUK_DDDPRINT("non-ascii string, use_cache=%ld, sce=%p:%ld:%ld, "
-		                     "dist_start=%ld, dist_end=%ld, dist_sce=%ld => "
-		                     "scan forwards from string start",
-		                     (long) use_cache, (void *) (sce ? sce->h : NULL),
-		                     (sce ? (long) sce->cidx : (long) -1),
-		                     (sce ? (long) sce->bidx : (long) -1),
-		                     (long) dist_start, (long) dist_end, (long) dist_sce));
-
-		p_found = duk__scan_forwards(p_start,
-		                             p_end,
-		                             dist_start);
-	} else {
-		DUK_DDD(DUK_DDDPRINT("non-ascii string, use_cache=%ld, sce=%p:%ld:%ld, "
-		                     "dist_start=%ld, dist_end=%ld, dist_sce=%ld => "
-		                     "scan backwards from string end",
-		                     (long) use_cache, (void *) (sce ? sce->h : NULL),
-		                     (sce ? (long) sce->cidx : (long) -1),
-		                     (sce ? (long) sce->bidx : (long) -1),
-		                     (long) dist_start, (long) dist_end, (long) dist_sce));
-
-		p_found = duk__scan_backwards(p_end,
-		                              p_start,
-		                              dist_end);
-	}
-
- scan_done:
-
-	if (!p_found) {
-		/* Scan error: this shouldn't normally happen; it could happen if
-		 * string is not valid UTF-8 data, and clen/blen are not consistent
-		 * with the scanning algorithm.
-		 */
-		goto error;
-	}
-
-	DUK_ASSERT(p_found >= p_start);
-	DUK_ASSERT(p_found <= p_end);  /* may be equal */
-	byte_offset = (duk_uint32_t) (p_found - p_start);
-
-	DUK_DDD(DUK_DDDPRINT("-> string %p, cidx %ld -> bidx %ld",
-	                     (void *) h, (long) char_offset, (long) byte_offset));
-
-	/*
-	 *  Update cache entry (allocating if necessary), and move the
-	 *  cache entry to the first place (in an "LRU" policy).
-	 */
-
-	if (use_cache) {
-		/* update entry, allocating if necessary */
-		if (!sce) {
-			sce = heap->strcache + DUK_HEAP_STRCACHE_SIZE - 1;  /* take last entry */
-			sce->h = h;
-		}
-		DUK_ASSERT(sce != NULL);
-		sce->bidx = (duk_uint32_t) (p_found - p_start);
-		sce->cidx = (duk_uint32_t) char_offset;
-
-		/* LRU: move our entry to first */
-		if (sce > &heap->strcache[0]) {
-			/*
-			 *   A                  C
-			 *   B                  A
-			 *   C <- sce    ==>    B
-			 *   D                  D
-			 */
-			duk_strcache tmp;
-
-			tmp = *sce;
-			DUK_MEMMOVE((void *) (&heap->strcache[1]),
-			            (const void *) (&heap->strcache[0]),
-			            (size_t) (((char *) sce) - ((char *) &heap->strcache[0])));
-			heap->strcache[0] = tmp;
-
-			/* 'sce' points to the wrong entry here, but is no longer used */
-		}
-#ifdef DUK_USE_DDDPRINT
-		DUK_DDD(DUK_DDDPRINT("stringcache after char2byte (using cache):"));
-		for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) {
-			duk_strcache *c = heap->strcache + i;
-			DUK_DDD(DUK_DDDPRINT("  [%ld] -> h=%p, cidx=%ld, bidx=%ld",
-			                     (long) i, (void *) c->h, (long) c->cidx, (long) c->bidx));
-		}
-#endif
-	}
-
-	return byte_offset;
-
- error:
-	DUK_ERROR_INTERNAL_DEFMSG(thr);
-	return 0;
-}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/ede68a10/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_heap_stringtable.c
----------------------------------------------------------------------
diff --git a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_heap_stringtable.c b/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_heap_stringtable.c
deleted file mode 100644
index ad0a4fc..0000000
--- a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_heap_stringtable.c
+++ /dev/null
@@ -1,1181 +0,0 @@
-/*
- *  Heap stringtable handling, string interning.
- */
-
-#include "duk_internal.h"
-
-#if defined(DUK_USE_STRTAB_PROBE)
-#define DUK__HASH_INITIAL(hash,h_size)        DUK_STRTAB_HASH_INITIAL((hash),(h_size))
-#define DUK__HASH_PROBE_STEP(hash)            DUK_STRTAB_HASH_PROBE_STEP((hash))
-#define DUK__DELETED_MARKER(heap)             DUK_STRTAB_DELETED_MARKER((heap))
-#endif
-
-#if defined(DUK_USE_MARK_AND_SWEEP)
-#define DUK__PREVENT_MS_SIDE_EFFECTS(heap) do { \
-		(heap)->mark_and_sweep_base_flags |= \
-		        DUK_MS_FLAG_NO_STRINGTABLE_RESIZE |  /* avoid recursive string table call */ \
-		        DUK_MS_FLAG_NO_FINALIZERS |          /* avoid pressure to add/remove strings, invalidation of call data argument, etc. */ \
-		        DUK_MS_FLAG_NO_OBJECT_COMPACTION;    /* avoid array abandoning which interns strings */ \
-	} while (0)
-#endif
-
-/*
- *  Create a hstring and insert into the heap.  The created object
- *  is directly garbage collectable with reference count zero.
- *
- *  The caller must place the interned string into the stringtable
- *  immediately (without chance of a longjmp); otherwise the string
- *  is lost.
- */
-
-DUK_LOCAL
-duk_hstring *duk__alloc_init_hstring(duk_heap *heap,
-                                     const duk_uint8_t *str,
-                                     duk_uint32_t blen,
-                                     duk_uint32_t strhash,
-                                     const duk_uint8_t *extdata) {
-	duk_hstring *res = NULL;
-	duk_uint8_t *data;
-	duk_size_t alloc_size;
-	duk_uarridx_t dummy;
-	duk_uint32_t clen;
-
-#if defined(DUK_USE_STRLEN16)
-	/* If blen <= 0xffffUL, clen is also guaranteed to be <= 0xffffUL. */
-	if (blen > 0xffffUL) {
-		DUK_D(DUK_DPRINT("16-bit string blen/clen active and blen over 16 bits, reject intern"));
-		return NULL;
-	}
-#endif
-
-	if (extdata) {
-		alloc_size = (duk_size_t) sizeof(duk_hstring_external);
-		res = (duk_hstring *) DUK_ALLOC(heap, alloc_size);
-		if (!res) {
-			goto alloc_error;
-		}
-		DUK_MEMZERO(res, sizeof(duk_hstring_external));
-#if defined(DUK_USE_EXPLICIT_NULL_INIT)
-		DUK_HEAPHDR_STRING_INIT_NULLS(&res->hdr);
-#endif
-		DUK_HEAPHDR_SET_TYPE_AND_FLAGS(&res->hdr, DUK_HTYPE_STRING, DUK_HSTRING_FLAG_EXTDATA);
-
-		((duk_hstring_external *) res)->extdata = extdata;
-	} else {
-		/* NUL terminate for convenient C access */
-		alloc_size = (duk_size_t) (sizeof(duk_hstring) + blen + 1);
-		res = (duk_hstring *) DUK_ALLOC(heap, alloc_size);
-		if (!res) {
-			goto alloc_error;
-		}
-		DUK_MEMZERO(res, sizeof(duk_hstring));
-#if defined(DUK_USE_EXPLICIT_NULL_INIT)
-		DUK_HEAPHDR_STRING_INIT_NULLS(&res->hdr);
-#endif
-		DUK_HEAPHDR_SET_TYPE_AND_FLAGS(&res->hdr, DUK_HTYPE_STRING, 0);
-
-		data = (duk_uint8_t *) (res + 1);
-		DUK_MEMCPY(data, str, blen);
-		data[blen] = (duk_uint8_t) 0;
-	}
-
-	DUK_ASSERT(!DUK_HSTRING_HAS_ARRIDX(res));
-	if (duk_js_to_arrayindex_raw_string(str, blen, &dummy)) {
-		DUK_HSTRING_SET_ARRIDX(res);
-	}
-
-	/* All strings beginning with 0xff are treated as "internal",
-	 * even strings interned by the user.  This allows user code to
-	 * create internal properties too, and makes behavior consistent
-	 * in case user code happens to use a string also used by Duktape
-	 * (such as string has already been interned and has the 'internal'
-	 * flag set).
-	 */
-	DUK_ASSERT(!DUK_HSTRING_HAS_INTERNAL(res));
-	if (blen > 0 && str[0] == (duk_uint8_t) 0xff) {
-		DUK_HSTRING_SET_INTERNAL(res);
-	}
-
-	DUK_HSTRING_SET_HASH(res, strhash);
-	DUK_HSTRING_SET_BYTELEN(res, blen);
-
-	clen = (duk_uint32_t) duk_unicode_unvalidated_utf8_length(str, (duk_size_t) blen);
-	DUK_ASSERT(clen <= blen);
-#if defined(DUK_USE_HSTRING_CLEN)
-	DUK_HSTRING_SET_CHARLEN(res, clen);
-#endif
-
-	/* Using an explicit 'ASCII' flag has larger footprint (one call site
-	 * only) but is quite useful for the case when there's no explicit
-	 * 'clen' in duk_hstring.
-	 */
-	DUK_ASSERT(!DUK_HSTRING_HAS_ASCII(res));
-	if (clen == blen) {
-		DUK_HSTRING_SET_ASCII(res);
-	}
-
-	DUK_DDD(DUK_DDDPRINT("interned string, hash=0x%08lx, blen=%ld, clen=%ld, has_arridx=%ld, has_extdata=%ld",
-	                     (unsigned long) DUK_HSTRING_GET_HASH(res),
-	                     (long) DUK_HSTRING_GET_BYTELEN(res),
-	                     (long) DUK_HSTRING_GET_CHARLEN(res),
-	                     (long) (DUK_HSTRING_HAS_ARRIDX(res) ? 1 : 0),
-	                     (long) (DUK_HSTRING_HAS_EXTDATA(res) ? 1 : 0)));
-
-	return res;
-
- alloc_error:
-	DUK_FREE(heap, res);
-	return NULL;
-}
-
-/*
- *  String table algorithm: fixed size string table with array chaining
- *
- *  The top level string table has a fixed size, with each slot holding
- *  either NULL, string pointer, or pointer to a separately allocated
- *  string pointer list.
- *
- *  This is good for low memory environments using a pool allocator: the
- *  top level allocation has a fixed size and the pointer lists have quite
- *  small allocation size, which further matches the typical pool sizes
- *  needed by objects, strings, property tables, etc.
- */
-
-#if defined(DUK_USE_STRTAB_CHAIN)
-
-#if defined(DUK_USE_HEAPPTR16)
-DUK_LOCAL duk_bool_t duk__insert_hstring_chain(duk_heap *heap, duk_hstring *h) {
-	duk_small_uint_t slotidx;
-	duk_strtab_entry *e;
-	duk_uint16_t *lst;
-	duk_uint16_t *new_lst;
-	duk_size_t i, n;
-	duk_uint16_t null16 = heap->heapptr_null16;
-	duk_uint16_t h16 = DUK_USE_HEAPPTR_ENC16(heap->heap_udata, (void *) h);
-
-	DUK_ASSERT(heap != NULL);
-	DUK_ASSERT(h != NULL);
-
-	slotidx = DUK_HSTRING_GET_HASH(h) % DUK_STRTAB_CHAIN_SIZE;
-	DUK_ASSERT(slotidx < DUK_STRTAB_CHAIN_SIZE);
-
-	e = heap->strtable + slotidx;
-	if (e->listlen == 0) {
-		if (e->u.str16 == null16) {
-			e->u.str16 = h16;
-		} else {
-			/* Now two entries in the same slot, alloc list */
-			lst = (duk_uint16_t *) DUK_ALLOC(heap, sizeof(duk_uint16_t) * 2);
-			if (lst == NULL) {
-				return 1;  /* fail */
-			}
-			lst[0] = e->u.str16;
-			lst[1] = h16;
-			e->u.strlist16 = DUK_USE_HEAPPTR_ENC16(heap->heap_udata, (void *) lst);
-			e->listlen = 2;
-		}
-	} else {
-		DUK_ASSERT(e->u.strlist16 != null16);
-		lst = (duk_uint16_t *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, e->u.strlist16);
-		DUK_ASSERT(lst != NULL);
-		for (i = 0, n = e->listlen; i < n; i++) {
-			if (lst[i] == null16) {
-				lst[i] = h16;
-				return 0;
-			}
-		}
-
-		if (e->listlen + 1 == 0) {
-			/* Overflow, relevant mainly when listlen is 16 bits. */
-			return 1;  /* fail */
-		}
-
-		new_lst = (duk_uint16_t *) DUK_REALLOC(heap, lst, sizeof(duk_uint16_t) * (e->listlen + 1));
-		if (new_lst == NULL) {
-			return 1;  /* fail */
-		}
-		new_lst[e->listlen++] = h16;
-		e->u.strlist16 = DUK_USE_HEAPPTR_ENC16(heap->heap_udata, (void *) new_lst);
-	}
-	return 0;
-}
-#else  /* DUK_USE_HEAPPTR16 */
-DUK_LOCAL duk_bool_t duk__insert_hstring_chain(duk_heap *heap, duk_hstring *h) {
-	duk_small_uint_t slotidx;
-	duk_strtab_entry *e;
-	duk_hstring **lst;
-	duk_hstring **new_lst;
-	duk_size_t i, n;
-
-	DUK_ASSERT(heap != NULL);
-	DUK_ASSERT(h != NULL);
-
-	slotidx = DUK_HSTRING_GET_HASH(h) % DUK_STRTAB_CHAIN_SIZE;
-	DUK_ASSERT(slotidx < DUK_STRTAB_CHAIN_SIZE);
-
-	e = heap->strtable + slotidx;
-	if (e->listlen == 0) {
-		if (e->u.str == NULL) {
-			e->u.str = h;
-		} else {
-			/* Now two entries in the same slot, alloc list */
-			lst = (duk_hstring **) DUK_ALLOC(heap, sizeof(duk_hstring *) * 2);
-			if (lst == NULL) {
-				return 1;  /* fail */
-			}
-			lst[0] = e->u.str;
-			lst[1] = h;
-			e->u.strlist = lst;
-			e->listlen = 2;
-		}
-	} else {
-		DUK_ASSERT(e->u.strlist != NULL);
-		lst = e->u.strlist;
-		for (i = 0, n = e->listlen; i < n; i++) {
-			if (lst[i] == NULL) {
-				lst[i] = h;
-				return 0;
-			}
-		}
-
-		if (e->listlen + 1 == 0) {
-			/* Overflow, relevant mainly when listlen is 16 bits. */
-			return 1;  /* fail */
-		}
-
-		new_lst = (duk_hstring **) DUK_REALLOC(heap, e->u.strlist, sizeof(duk_hstring *) * (e->listlen + 1));
-		if (new_lst == NULL) {
-			return 1;  /* fail */
-		}
-		new_lst[e->listlen++] = h;
-		e->u.strlist = new_lst;
-	}
-	return 0;
-}
-#endif  /* DUK_USE_HEAPPTR16 */
-
-#if defined(DUK_USE_HEAPPTR16)
-DUK_LOCAL duk_hstring *duk__find_matching_string_chain(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t strhash) {
-	duk_small_uint_t slotidx;
-	duk_strtab_entry *e;
-	duk_uint16_t *lst;
-	duk_size_t i, n;
-	duk_uint16_t null16 = heap->heapptr_null16;
-
-	DUK_ASSERT(heap != NULL);
-
-	slotidx = strhash % DUK_STRTAB_CHAIN_SIZE;
-	DUK_ASSERT(slotidx < DUK_STRTAB_CHAIN_SIZE);
-
-	e = heap->strtable + slotidx;
-	if (e->listlen == 0) {
-		if (e->u.str16 != null16) {
-			duk_hstring *h = (duk_hstring *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, e->u.str16);
-			DUK_ASSERT(h != NULL);
-			if (DUK_HSTRING_GET_BYTELEN(h) == blen &&
-			    DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(h), (size_t) blen) == 0) {
-				return h;
-			}
-		}
-	} else {
-		DUK_ASSERT(e->u.strlist16 != null16);
-		lst = (duk_uint16_t *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, e->u.strlist16);
-		DUK_ASSERT(lst != NULL);
-		for (i = 0, n = e->listlen; i < n; i++) {
-			if (lst[i] != null16) {
-				duk_hstring *h = (duk_hstring *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, lst[i]);
-				DUK_ASSERT(h != NULL);
-				if (DUK_HSTRING_GET_BYTELEN(h) == blen &&
-				    DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(h), (size_t) blen) == 0) {
-					return h;
-				}
-			}
-		}
-	}
-
-	return NULL;
-}
-#else  /* DUK_USE_HEAPPTR16 */
-DUK_LOCAL duk_hstring *duk__find_matching_string_chain(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t strhash) {
-	duk_small_uint_t slotidx;
-	duk_strtab_entry *e;
-	duk_hstring **lst;
-	duk_size_t i, n;
-
-	DUK_ASSERT(heap != NULL);
-
-	slotidx = strhash % DUK_STRTAB_CHAIN_SIZE;
-	DUK_ASSERT(slotidx < DUK_STRTAB_CHAIN_SIZE);
-
-	e = heap->strtable + slotidx;
-	if (e->listlen == 0) {
-		if (e->u.str != NULL &&
-	           DUK_HSTRING_GET_BYTELEN(e->u.str) == blen &&
-	           DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(e->u.str), (size_t) blen) == 0) {
-			return e->u.str;
-		}
-	} else {
-		DUK_ASSERT(e->u.strlist != NULL);
-		lst = e->u.strlist;
-		for (i = 0, n = e->listlen; i < n; i++) {
-			if (lst[i] != NULL &&
-		           DUK_HSTRING_GET_BYTELEN(lst[i]) == blen &&
-		           DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(lst[i]), (size_t) blen) == 0) {
-				return lst[i];
-			}
-		}
-	}
-
-	return NULL;
-}
-#endif  /* DUK_USE_HEAPPTR16 */
-
-#if defined(DUK_USE_HEAPPTR16)
-DUK_LOCAL void duk__remove_matching_hstring_chain(duk_heap *heap, duk_hstring *h) {
-	duk_small_uint_t slotidx;
-	duk_strtab_entry *e;
-	duk_uint16_t *lst;
-	duk_size_t i, n;
-	duk_uint16_t h16;
-	duk_uint16_t null16 = heap->heapptr_null16;
-
-	DUK_ASSERT(heap != NULL);
-	DUK_ASSERT(h != NULL);
-
-	slotidx = DUK_HSTRING_GET_HASH(h) % DUK_STRTAB_CHAIN_SIZE;
-	DUK_ASSERT(slotidx < DUK_STRTAB_CHAIN_SIZE);
-
-	DUK_ASSERT(h != NULL);
-	h16 = DUK_USE_HEAPPTR_ENC16(heap->heap_udata, (void *) h);
-
-	e = heap->strtable + slotidx;
-	if (e->listlen == 0) {
-		if (e->u.str16 == h16) {
-			e->u.str16 = null16;
-			return;
-		}
-	} else {
-		DUK_ASSERT(e->u.strlist16 != null16);
-		lst = (duk_uint16_t *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, e->u.strlist16);
-		DUK_ASSERT(lst != NULL);
-		for (i = 0, n = e->listlen; i < n; i++) {
-			if (lst[i] == h16) {
-				lst[i] = null16;
-				return;
-			}
-		}
-	}
-
-	DUK_D(DUK_DPRINT("failed to find string that should be in stringtable"));
-	DUK_UNREACHABLE();
-	return;
-}
-#else  /* DUK_USE_HEAPPTR16 */
-DUK_LOCAL void duk__remove_matching_hstring_chain(duk_heap *heap, duk_hstring *h) {
-	duk_small_uint_t slotidx;
-	duk_strtab_entry *e;
-	duk_hstring **lst;
-	duk_size_t i, n;
-
-	DUK_ASSERT(heap != NULL);
-	DUK_ASSERT(h != NULL);
-
-	slotidx = DUK_HSTRING_GET_HASH(h) % DUK_STRTAB_CHAIN_SIZE;
-	DUK_ASSERT(slotidx < DUK_STRTAB_CHAIN_SIZE);
-
-	e = heap->strtable + slotidx;
-	if (e->listlen == 0) {
-		DUK_ASSERT(h != NULL);
-		if (e->u.str == h) {
-			e->u.str = NULL;
-			return;
-		}
-	} else {
-		DUK_ASSERT(e->u.strlist != NULL);
-		lst = e->u.strlist;
-		for (i = 0, n = e->listlen; i < n; i++) {
-			DUK_ASSERT(h != NULL);
-			if (lst[i] == h) {
-				lst[i] = NULL;
-				return;
-			}
-		}
-	}
-
-	DUK_D(DUK_DPRINT("failed to find string that should be in stringtable"));
-	DUK_UNREACHABLE();
-	return;
-}
-#endif  /* DUK_USE_HEAPPTR16 */
-
-#if defined(DUK_USE_DEBUG)
-DUK_INTERNAL void duk_heap_dump_strtab(duk_heap *heap) {
-	duk_strtab_entry *e;
-	duk_small_uint_t i;
-	duk_size_t j, n, used;
-#if defined(DUK_USE_HEAPPTR16)
-	duk_uint16_t *lst;
-	duk_uint16_t null16 = heap->heapptr_null16;
-#else
-	duk_hstring **lst;
-#endif
-
-	DUK_ASSERT(heap != NULL);
-
-	for (i = 0; i < DUK_STRTAB_CHAIN_SIZE; i++) {
-		e = heap->strtable + i;
-
-		if (e->listlen == 0) {
-#if defined(DUK_USE_HEAPPTR16)
-			DUK_DD(DUK_DDPRINT("[%03d] -> plain %d", (int) i, (int) (e->u.str16 != null16 ? 1 : 0)));
-#else
-			DUK_DD(DUK_DDPRINT("[%03d] -> plain %d", (int) i, (int) (e->u.str ? 1 : 0)));
-#endif
-		} else {
-			used = 0;
-#if defined(DUK_USE_HEAPPTR16)
-			lst = (duk_uint16_t *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, e->u.strlist16);
-#else
-			lst = e->u.strlist;
-#endif
-			DUK_ASSERT(lst != NULL);
-			for (j = 0, n = e->listlen; j < n; j++) {
-#if defined(DUK_USE_HEAPPTR16)
-				if (lst[j] != null16) {
-#else
-				if (lst[j] != NULL) {
-#endif
-					used++;
-				}
-			}
-			DUK_DD(DUK_DDPRINT("[%03d] -> array %d/%d", (int) i, (int) used, (int) e->listlen));
-		}
-	}
-}
-#endif  /* DUK_USE_DEBUG */
-
-#endif  /* DUK_USE_STRTAB_CHAIN */
-
-/*
- *  String table algorithm: closed hashing with a probe sequence
- *
- *  This is the default algorithm and works fine for environments with
- *  minimal memory constraints.
- */
-
-#if defined(DUK_USE_STRTAB_PROBE)
-
-/* Count actually used (non-NULL, non-DELETED) entries. */
-DUK_LOCAL duk_int_t duk__count_used_probe(duk_heap *heap) {
-	duk_int_t res = 0;
-	duk_uint_fast32_t i, n;
-#if defined(DUK_USE_HEAPPTR16)
-	duk_uint16_t null16 = heap->heapptr_null16;
-	duk_uint16_t deleted16 = heap->heapptr_deleted16;
-#endif
-
-	n = (duk_uint_fast32_t) heap->st_size;
-	for (i = 0; i < n; i++) {
-#if defined(DUK_USE_HEAPPTR16)
-		if (heap->strtable16[i] != null16 && heap->strtable16[i] != deleted16) {
-#else
-		if (heap->strtable[i] != NULL && heap->strtable[i] != DUK__DELETED_MARKER(heap)) {
-#endif
-			res++;
-		}
-	}
-	return res;
-}
-
-#if defined(DUK_USE_HEAPPTR16)
-DUK_LOCAL void duk__insert_hstring_probe(duk_heap *heap, duk_uint16_t *entries16, duk_uint32_t size, duk_uint32_t *p_used, duk_hstring *h) {
-#else
-DUK_LOCAL void duk__insert_hstring_probe(duk_heap *heap, duk_hstring **entries, duk_uint32_t size, duk_uint32_t *p_used, duk_hstring *h) {
-#endif
-	duk_uint32_t i;
-	duk_uint32_t step;
-#if defined(DUK_USE_HEAPPTR16)
-	duk_uint16_t null16 = heap->heapptr_null16;
-	duk_uint16_t deleted16 = heap->heapptr_deleted16;
-#endif
-
-	DUK_ASSERT(size > 0);
-
-	i = DUK__HASH_INITIAL(DUK_HSTRING_GET_HASH(h), size);
-	step = DUK__HASH_PROBE_STEP(DUK_HSTRING_GET_HASH(h));
-	for (;;) {
-#if defined(DUK_USE_HEAPPTR16)
-		duk_uint16_t e16 = entries16[i];
-#else
-		duk_hstring *e = entries[i];
-#endif
-
-#if defined(DUK_USE_HEAPPTR16)
-		/* XXX: could check for e16 == 0 because NULL is guaranteed to
-		 * encode to zero.
-		 */
-		if (e16 == null16) {
-#else
-		if (e == NULL) {
-#endif
-			DUK_DDD(DUK_DDDPRINT("insert hit (null): %ld", (long) i));
-#if defined(DUK_USE_HEAPPTR16)
-			entries16[i] = DUK_USE_HEAPPTR_ENC16(heap->heap_udata, (void *) h);
-#else
-			entries[i] = h;
-#endif
-			(*p_used)++;
-			break;
-#if defined(DUK_USE_HEAPPTR16)
-		} else if (e16 == deleted16) {
-#else
-		} else if (e == DUK__DELETED_MARKER(heap)) {
-#endif
-			/* st_used remains the same, DELETED is counted as used */
-			DUK_DDD(DUK_DDDPRINT("insert hit (deleted): %ld", (long) i));
-#if defined(DUK_USE_HEAPPTR16)
-			entries16[i] = DUK_USE_HEAPPTR_ENC16(heap->heap_udata, (void *) h);
-#else
-			entries[i] = h;
-#endif
-			break;
-		}
-		DUK_DDD(DUK_DDDPRINT("insert miss: %ld", (long) i));
-		i = (i + step) % size;
-
-		/* looping should never happen */
-		DUK_ASSERT(i != DUK__HASH_INITIAL(DUK_HSTRING_GET_HASH(h), size));
-	}
-}
-
-#if defined(DUK_USE_HEAPPTR16)
-DUK_LOCAL duk_hstring *duk__find_matching_string_probe(duk_heap *heap, duk_uint16_t *entries16, duk_uint32_t size, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t strhash) {
-#else
-DUK_LOCAL duk_hstring *duk__find_matching_string_probe(duk_heap *heap, duk_hstring **entries, duk_uint32_t size, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t strhash) {
-#endif
-	duk_uint32_t i;
-	duk_uint32_t step;
-
-	DUK_ASSERT(size > 0);
-
-	i = DUK__HASH_INITIAL(strhash, size);
-	step = DUK__HASH_PROBE_STEP(strhash);
-	for (;;) {
-		duk_hstring *e;
-#if defined(DUK_USE_HEAPPTR16)
-		e = (duk_hstring *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, entries16[i]);
-#else
-		e = entries[i];
-#endif
-
-		if (!e) {
-			return NULL;
-		}
-		if (e != DUK__DELETED_MARKER(heap) && DUK_HSTRING_GET_BYTELEN(e) == blen) {
-			if (DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(e), (size_t) blen) == 0) {
-				DUK_DDD(DUK_DDDPRINT("find matching hit: %ld (step %ld, size %ld)",
-				                     (long) i, (long) step, (long) size));
-				return e;
-			}
-		}
-		DUK_DDD(DUK_DDDPRINT("find matching miss: %ld (step %ld, size %ld)",
-		                     (long) i, (long) step, (long) size));
-		i = (i + step) % size;
-
-		/* looping should never happen */
-		DUK_ASSERT(i != DUK__HASH_INITIAL(strhash, size));
-	}
-	DUK_UNREACHABLE();
-}
-
-#if defined(DUK_USE_HEAPPTR16)
-DUK_LOCAL void duk__remove_matching_hstring_probe(duk_heap *heap, duk_uint16_t *entries16, duk_uint32_t size, duk_hstring *h) {
-#else
-DUK_LOCAL void duk__remove_matching_hstring_probe(duk_heap *heap, duk_hstring **entries, duk_uint32_t size, duk_hstring *h) {
-#endif
-	duk_uint32_t i;
-	duk_uint32_t step;
-	duk_uint32_t hash;
-#if defined(DUK_USE_HEAPPTR16)
-	duk_uint16_t null16 = heap->heapptr_null16;
-	duk_uint16_t h16 = DUK_USE_HEAPPTR_ENC16(heap->heap_udata, (void *) h);
-#endif
-
-	DUK_ASSERT(size > 0);
-
-	hash = DUK_HSTRING_GET_HASH(h);
-	i = DUK__HASH_INITIAL(hash, size);
-	step = DUK__HASH_PROBE_STEP(hash);
-	for (;;) {
-#if defined(DUK_USE_HEAPPTR16)
-		duk_uint16_t e16 = entries16[i];
-#else
-		duk_hstring *e = entries[i];
-#endif
-
-#if defined(DUK_USE_HEAPPTR16)
-		if (e16 == null16) {
-#else
-		if (!e) {
-#endif
-			DUK_UNREACHABLE();
-			break;
-		}
-#if defined(DUK_USE_HEAPPTR16)
-		if (e16 == h16) {
-#else
-		if (e == h) {
-#endif
-			/* st_used remains the same, DELETED is counted as used */
-			DUK_DDD(DUK_DDDPRINT("free matching hit: %ld", (long) i));
-#if defined(DUK_USE_HEAPPTR16)
-			entries16[i] = heap->heapptr_deleted16;
-#else
-			entries[i] = DUK__DELETED_MARKER(heap);
-#endif
-			break;
-		}
-
-		DUK_DDD(DUK_DDDPRINT("free matching miss: %ld", (long) i));
-		i = (i + step) % size;
-
-		/* looping should never happen */
-		DUK_ASSERT(i != DUK__HASH_INITIAL(hash, size));
-	}
-}
-
-DUK_LOCAL duk_bool_t duk__resize_strtab_raw_probe(duk_heap *heap, duk_uint32_t new_size) {
-#if defined(DUK_USE_DEBUG)
-	duk_uint32_t old_used = heap->st_used;
-#endif
-	duk_uint32_t old_size = heap->st_size;
-#if defined(DUK_USE_HEAPPTR16)
-	duk_uint16_t *old_entries = heap->strtable16;
-	duk_uint16_t *new_entries = NULL;
-#else
-	duk_hstring **old_entries = heap->strtable;
-	duk_hstring **new_entries = NULL;
-#endif
-	duk_uint32_t new_used = 0;
-	duk_uint32_t i;
-
-#if defined(DUK_USE_DEBUG)
-	DUK_UNREF(old_used);  /* unused with some debug level combinations */
-#endif
-
-#ifdef DUK_USE_DDDPRINT
-	DUK_DDD(DUK_DDDPRINT("attempt to resize stringtable: %ld entries, %ld bytes, %ld used, %ld%% load -> %ld entries, %ld bytes, %ld used, %ld%% load",
-	                     (long) old_size, (long) (sizeof(duk_hstring *) * old_size), (long) old_used,
-	                     (long) (((double) old_used) / ((double) old_size) * 100.0),
-	                     (long) new_size, (long) (sizeof(duk_hstring *) * new_size), (long) duk__count_used_probe(heap),
-	                     (long) (((double) duk__count_used_probe(heap)) / ((double) new_size) * 100.0)));
-#endif
-
-	DUK_ASSERT(new_size > (duk_uint32_t) duk__count_used_probe(heap));  /* required for rehash to succeed, equality not that useful */
-	DUK_ASSERT(old_entries);
-
-	/*
-	 *  The attempt to allocate may cause a GC.  Such a GC must not attempt to resize
-	 *  the stringtable (though it can be swept); finalizer execution and object
-	 *  compaction must also be postponed to avoid the pressure to add strings to the
-	 *  string table.  Call site must prevent these.
-	 */
-
-#if defined(DUK_USE_MARK_AND_SWEEP)
-	DUK_ASSERT(heap->mark_and_sweep_base_flags & DUK_MS_FLAG_NO_STRINGTABLE_RESIZE);
-	DUK_ASSERT(heap->mark_and_sweep_base_flags & DUK_MS_FLAG_NO_FINALIZERS);
-	DUK_ASSERT(heap->mark_and_sweep_base_flags & DUK_MS_FLAG_NO_OBJECT_COMPACTION);
-#endif
-
-#if defined(DUK_USE_HEAPPTR16)
-	new_entries = (duk_uint16_t *) DUK_ALLOC(heap, sizeof(duk_uint16_t) * new_size);
-#else
-	new_entries = (duk_hstring **) DUK_ALLOC(heap, sizeof(duk_hstring *) * new_size);
-#endif
-
-	if (!new_entries) {
-		goto resize_error;
-	}
-
-#if defined(DUK_USE_EXPLICIT_NULL_INIT)
-	for (i = 0; i < new_size; i++) {
-#if defined(DUK_USE_HEAPPTR16)
-		new_entries[i] = heap->heapptr_null16;
-#else
-		new_entries[i] = NULL;
-#endif
-	}
-#else
-#if defined(DUK_USE_HEAPPTR16)
-	/* Relies on NULL encoding to zero. */
-	DUK_MEMZERO(new_entries, sizeof(duk_uint16_t) * new_size);
-#else
-	DUK_MEMZERO(new_entries, sizeof(duk_hstring *) * new_size);
-#endif
-#endif
-
-	/* Because new_size > duk__count_used_probe(heap), guaranteed to work */
-	for (i = 0; i < old_size; i++) {
-		duk_hstring *e;
-
-#if defined(DUK_USE_HEAPPTR16)
-		e = (duk_hstring *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, old_entries[i]);
-#else
-		e = old_entries[i];
-#endif
-		if (e == NULL || e == DUK__DELETED_MARKER(heap)) {
-			continue;
-		}
-		/* checking for DUK__DELETED_MARKER is not necessary here, but helper does it now */
-		duk__insert_hstring_probe(heap, new_entries, new_size, &new_used, e);
-	}
-
-#ifdef DUK_USE_DDPRINT
-	DUK_DD(DUK_DDPRINT("resized stringtable: %ld entries, %ld bytes, %ld used, %ld%% load -> %ld entries, %ld bytes, %ld used, %ld%% load",
-	                   (long) old_size, (long) (sizeof(duk_hstring *) * old_size), (long) old_used,
-	                   (long) (((double) old_used) / ((double) old_size) * 100.0),
-	                   (long) new_size, (long) (sizeof(duk_hstring *) * new_size), (long) new_used,
-	                   (long) (((double) new_used) / ((double) new_size) * 100.0)));
-#endif
-
-#if defined(DUK_USE_HEAPPTR16)
-	DUK_FREE(heap, heap->strtable16);
-	heap->strtable16 = new_entries;
-#else
-	DUK_FREE(heap, heap->strtable);
-	heap->strtable = new_entries;
-#endif
-	heap->st_size = new_size;
-	heap->st_used = new_used;  /* may be less, since DELETED entries are NULLed by rehash */
-
-	return 0;  /* OK */
-
- resize_error:
-	DUK_FREE(heap, new_entries);
-	return 1;  /* FAIL */
-}
-
-DUK_LOCAL duk_bool_t duk__resize_strtab_probe(duk_heap *heap) {
-	duk_uint32_t new_size;
-	duk_bool_t ret;
-
-	new_size = (duk_uint32_t) duk__count_used_probe(heap);
-	if (new_size >= 0x80000000UL) {
-		new_size = DUK_STRTAB_HIGHEST_32BIT_PRIME;
-	} else {
-		new_size = duk_util_get_hash_prime(DUK_STRTAB_GROW_ST_SIZE(new_size));
-		new_size = duk_util_get_hash_prime(new_size);
-	}
-	DUK_ASSERT(new_size > 0);
-
-	/* rehash even if old and new sizes are the same to get rid of
-	 * DELETED entries.
-	*/
-
-	ret = duk__resize_strtab_raw_probe(heap, new_size);
-
-	return ret;
-}
-
-DUK_LOCAL duk_bool_t duk__recheck_strtab_size_probe(duk_heap *heap, duk_uint32_t new_used) {
-	duk_uint32_t new_free;
-	duk_uint32_t tmp1;
-	duk_uint32_t tmp2;
-
-	DUK_ASSERT(new_used <= heap->st_size);  /* grow by at most one */
-	new_free = heap->st_size - new_used;    /* unsigned intentionally */
-
-	/* new_free / size <= 1 / DIV  <=>  new_free <= size / DIV */
-	/* new_used / size <= 1 / DIV  <=>  new_used <= size / DIV */
-
-	tmp1 = heap->st_size / DUK_STRTAB_MIN_FREE_DIVISOR;
-	tmp2 = heap->st_size / DUK_STRTAB_MIN_USED_DIVISOR;
-
-	if (new_free <= tmp1 || new_used <= tmp2) {
-		/* load factor too low or high, count actually used entries and resize */
-		return duk__resize_strtab_probe(heap);
-	} else {
-		return 0;  /* OK */
-	}
-}
-
-#if defined(DUK_USE_DEBUG)
-DUK_INTERNAL void duk_heap_dump_strtab(duk_heap *heap) {
-	duk_uint32_t i;
-	duk_hstring *h;
-
-	DUK_ASSERT(heap != NULL);
-#if defined(DUK_USE_HEAPPTR16)
-	DUK_ASSERT(heap->strtable16 != NULL);
-#else
-	DUK_ASSERT(heap->strtable != NULL);
-#endif
-	DUK_UNREF(h);
-
-	for (i = 0; i < heap->st_size; i++) {
-#if defined(DUK_USE_HEAPPTR16)
-		h = (duk_hstring *) DUK_USE_HEAPPTR_DEC16(heap->strtable16[i]);
-#else
-		h = heap->strtable[i];
-#endif
-
-		DUK_DD(DUK_DDPRINT("[%03d] -> %p", (int) i, (void *) h));
-	}
-}
-#endif  /* DUK_USE_DEBUG */
-
-#endif  /* DUK_USE_STRTAB_PROBE */
-
-/*
- *  Raw intern and lookup
- */
-
-DUK_LOCAL duk_hstring *duk__do_intern(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t strhash) {
-	duk_hstring *res;
-	const duk_uint8_t *extdata;
-#if defined(DUK_USE_MARK_AND_SWEEP)
-	duk_small_uint_t prev_mark_and_sweep_base_flags;
-#endif
-
-	/* Prevent any side effects on the string table and the caller provided
-	 * str/blen arguments while interning is in progress.  For example, if
-	 * the caller provided str/blen from a dynamic buffer, a finalizer might
-	 * resize that dynamic buffer, invalidating the call arguments.
-	 */
-#if defined(DUK_USE_MARK_AND_SWEEP)
-	DUK_ASSERT((heap->mark_and_sweep_base_flags & DUK_MS_FLAG_NO_STRINGTABLE_RESIZE) == 0);
-	prev_mark_and_sweep_base_flags = heap->mark_and_sweep_base_flags;
-	DUK__PREVENT_MS_SIDE_EFFECTS(heap);
-#endif
-
-#if defined(DUK_USE_STRTAB_PROBE)
-	if (duk__recheck_strtab_size_probe(heap, heap->st_used + 1)) {
-		goto failed;
-	}
-#endif
-
-	/* For manual testing only. */
-#if 0
-	{
-		duk_size_t i;
-		DUK_PRINTF("INTERN: \"");
-		for (i = 0; i < blen; i++) {
-			duk_uint8_t x = str[i];
-			if (x >= 0x20 && x <= 0x7e && x != '"' && x != '\\') {
-				DUK_PRINTF("%c", (int) x);  /* char: use int cast */
-			} else {
-				DUK_PRINTF("\\x%02lx", (long) x);
-			}
-		}
-		DUK_PRINTF("\"\n");
-	}
-#endif
-
-#if defined(DUK_USE_HSTRING_EXTDATA) && defined(DUK_USE_EXTSTR_INTERN_CHECK)
-	extdata = (const duk_uint8_t *) DUK_USE_EXTSTR_INTERN_CHECK(heap->heap_udata, (void *) DUK_LOSE_CONST(str), (duk_size_t) blen);
-#else
-	extdata = (const duk_uint8_t *) NULL;
-#endif
-	res = duk__alloc_init_hstring(heap, str, blen, strhash, extdata);
-	if (!res) {
-		goto failed;
-	}
-
-#if defined(DUK_USE_STRTAB_CHAIN)
-	if (duk__insert_hstring_chain(heap, res)) {
-		/* failed */
-		DUK_FREE(heap, res);
-		goto failed;
-	}
-#elif defined(DUK_USE_STRTAB_PROBE)
-	/* guaranteed to succeed */
-	duk__insert_hstring_probe(heap,
-#if defined(DUK_USE_HEAPPTR16)
-	                          heap->strtable16,
-#else
-	                          heap->strtable,
-#endif
-	                          heap->st_size,
-	                          &heap->st_used,
-	                          res);
-#else
-#error internal error, invalid strtab options
-#endif
-
-	/* Note: hstring is in heap but has refcount zero and is not strongly reachable.
-	 * Caller should increase refcount and make the hstring reachable before any
-	 * operations which require allocation (and possible gc).
-	 */
-
- done:
-#if defined(DUK_USE_MARK_AND_SWEEP)
-	heap->mark_and_sweep_base_flags = prev_mark_and_sweep_base_flags;
-#endif
-	return res;
-
- failed:
-	res = NULL;
-	goto done;
-}
-
-DUK_LOCAL duk_hstring *duk__do_lookup(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t *out_strhash) {
-	duk_hstring *res;
-
-	DUK_ASSERT(out_strhash);
-
-	*out_strhash = duk_heap_hashstring(heap, str, (duk_size_t) blen);
-
-#if defined(DUK_USE_ROM_STRINGS)
-	{
-		duk_small_uint_t i;
-		/* XXX: This is VERY inefficient now, and should be e.g. a
-		 * binary search or perfect hash, to be fixed.
-		 */
-		for (i = 0; i < (duk_small_uint_t) (sizeof(duk_rom_strings) / sizeof(duk_hstring *)); i++) {
-			duk_hstring *romstr;
-			romstr = (duk_hstring *) DUK_LOSE_CONST(duk_rom_strings[i]);
-			if (blen == DUK_HSTRING_GET_BYTELEN(romstr) &&
-			    DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(romstr), blen) == 0) {
-				DUK_DD(DUK_DDPRINT("intern check: rom string: %!O, computed hash 0x%08lx, rom hash 0x%08lx",
-				                   romstr, (unsigned long) *out_strhash, (unsigned long) DUK_HSTRING_GET_HASH(romstr)));
-				DUK_ASSERT(*out_strhash == DUK_HSTRING_GET_HASH(romstr));
-				*out_strhash = DUK_HSTRING_GET_HASH(romstr);
-				return romstr;
-			}
-		}
-	}
-#endif  /* DUK_USE_ROM_STRINGS */
-
-#if defined(DUK_USE_STRTAB_CHAIN)
-	res = duk__find_matching_string_chain(heap, str, blen, *out_strhash);
-#elif defined(DUK_USE_STRTAB_PROBE)
-	res = duk__find_matching_string_probe(heap,
-#if defined(DUK_USE_HEAPPTR16)
-	                                      heap->strtable16,
-#else
-	                                      heap->strtable,
-#endif
-	                                      heap->st_size,
-	                                      str,
-	                                      blen,
-	                                      *out_strhash);
-#else
-#error internal error, invalid strtab options
-#endif
-
-	return res;
-}
-
-/*
- *  Exposed calls
- */
-
-#if 0  /*unused*/
-DUK_INTERNAL duk_hstring *duk_heap_string_lookup(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen) {
-	duk_uint32_t strhash;  /* dummy */
-	return duk__do_lookup(heap, str, blen, &strhash);
-}
-#endif
-
-DUK_INTERNAL duk_hstring *duk_heap_string_intern(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen) {
-	duk_hstring *res;
-	duk_uint32_t strhash;
-
-	/* caller is responsible for ensuring this */
-	DUK_ASSERT(blen <= DUK_HSTRING_MAX_BYTELEN);
-
-	res = duk__do_lookup(heap, str, blen, &strhash);
-	if (res) {
-		return res;
-	}
-
-	res = duk__do_intern(heap, str, blen, strhash);
-	return res;  /* may be NULL */
-}
-
-DUK_INTERNAL duk_hstring *duk_heap_string_intern_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t blen) {
-	duk_hstring *res = duk_heap_string_intern(thr->heap, str, blen);
-	if (!res) {
-		DUK_ERROR_ALLOC_DEFMSG(thr);
-	}
-	return res;
-}
-
-#if 0  /*unused*/
-DUK_INTERNAL duk_hstring *duk_heap_string_lookup_u32(duk_heap *heap, duk_uint32_t val) {
-	char buf[DUK_STRTAB_U32_MAX_STRLEN+1];
-	DUK_SNPRINTF(buf, sizeof(buf), "%lu", (unsigned long) val);
-	buf[sizeof(buf) - 1] = (char) 0;
-	DUK_ASSERT(DUK_STRLEN(buf) <= DUK_UINT32_MAX);  /* formatted result limited */
-	return duk_heap_string_lookup(heap, (const duk_uint8_t *) buf, (duk_uint32_t) DUK_STRLEN(buf));
-}
-#endif
-
-DUK_INTERNAL duk_hstring *duk_heap_string_intern_u32(duk_heap *heap, duk_uint32_t val) {
-	char buf[DUK_STRTAB_U32_MAX_STRLEN+1];
-	DUK_SNPRINTF(buf, sizeof(buf), "%lu", (unsigned long) val);
-	buf[sizeof(buf) - 1] = (char) 0;
-	DUK_ASSERT(DUK_STRLEN(buf) <= DUK_UINT32_MAX);  /* formatted result limited */
-	return duk_heap_string_intern(heap, (const duk_uint8_t *) buf, (duk_uint32_t) DUK_STRLEN(buf));
-}
-
-DUK_INTERNAL duk_hstring *duk_heap_string_intern_u32_checked(duk_hthread *thr, duk_uint32_t val) {
-	duk_hstring *res = duk_heap_string_intern_u32(thr->heap, val);
-	if (!res) {
-		DUK_ERROR_ALLOC_DEFMSG(thr);
-	}
-	return res;
-}
-
-/* find and remove string from stringtable; caller must free the string itself */
-#if defined(DUK_USE_REFERENCE_COUNTING)
-DUK_INTERNAL void duk_heap_string_remove(duk_heap *heap, duk_hstring *h) {
-	DUK_DDD(DUK_DDDPRINT("remove string from stringtable: %!O", (duk_heaphdr *) h));
-
-#if defined(DUK_USE_STRTAB_CHAIN)
-	duk__remove_matching_hstring_chain(heap, h);
-#elif defined(DUK_USE_STRTAB_PROBE)
-	duk__remove_matching_hstring_probe(heap,
-#if defined(DUK_USE_HEAPPTR16)
-	                                   heap->strtable16,
-#else
-	                                   heap->strtable,
-#endif
-	                                   heap->st_size,
-	                                   h);
-#else
-#error internal error, invalid strtab options
-#endif
-}
-#endif
-
-#if defined(DUK_USE_MARK_AND_SWEEP) && defined(DUK_USE_MS_STRINGTABLE_RESIZE)
-DUK_INTERNAL void duk_heap_force_strtab_resize(duk_heap *heap) {
-	duk_small_uint_t prev_mark_and_sweep_base_flags;
-	/* Force a resize so that DELETED entries are eliminated.
-	 * Another option would be duk__recheck_strtab_size_probe();
-	 * but since that happens on every intern anyway, this whole
-	 * check can now be disabled.
-	 */
-
-	DUK_ASSERT((heap->mark_and_sweep_base_flags & DUK_MS_FLAG_NO_STRINGTABLE_RESIZE) == 0);
-	prev_mark_and_sweep_base_flags = heap->mark_and_sweep_base_flags;
-	DUK__PREVENT_MS_SIDE_EFFECTS(heap);
-
-#if defined(DUK_USE_STRTAB_CHAIN)
-	DUK_UNREF(heap);
-#elif defined(DUK_USE_STRTAB_PROBE)
-	(void) duk__resize_strtab_probe(heap);
-#endif
-
-	heap->mark_and_sweep_base_flags = prev_mark_and_sweep_base_flags;
-}
-#endif
-
-#if defined(DUK_USE_STRTAB_CHAIN)
-DUK_INTERNAL void duk_heap_free_strtab(duk_heap *heap) {
-	/* Free strings in the stringtable and any allocations needed
-	 * by the stringtable itself.
-	 */
-	duk_uint_fast32_t i, j;
-	duk_strtab_entry *e;
-#if defined(DUK_USE_HEAPPTR16)
-	duk_uint16_t *lst;
-	duk_uint16_t null16 = heap->heapptr_null16;
-#else
-	duk_hstring **lst;
-#endif
-	duk_hstring *h;
-
-	for (i = 0; i < DUK_STRTAB_CHAIN_SIZE; i++) {
-		e = heap->strtable + i;
-		if (e->listlen > 0) {
-#if defined(DUK_USE_HEAPPTR16)
-			lst = (duk_uint16_t *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, e->u.strlist16);
-#else
-			lst = e->u.strlist;
-#endif
-			DUK_ASSERT(lst != NULL);
-
-			for (j = 0; j < e->listlen; j++) {
-#if defined(DUK_USE_HEAPPTR16)
-				h = DUK_USE_HEAPPTR_DEC16(heap->heap_udata, lst[j]);
-				lst[j] = null16;
-#else
-				h = lst[j];
-				lst[j] = NULL;
-#endif
-				/* strings may have inner refs (extdata) in some cases */
-				if (h != NULL) {
-					duk_free_hstring_inner(heap, h);
-					DUK_FREE(heap, h);
-				}
-			}
-#if defined(DUK_USE_HEAPPTR16)
-			e->u.strlist16 = null16;
-#else
-			e->u.strlist = NULL;
-#endif
-			DUK_FREE(heap, lst);
-		} else {
-#if defined(DUK_USE_HEAPPTR16)
-			h = DUK_USE_HEAPPTR_DEC16(heap->heap_udata, e->u.str16);
-			e->u.str16 = null16;
-#else
-			h = e->u.str;
-			e->u.str = NULL;
-#endif
-			if (h != NULL) {
-				duk_free_hstring_inner(heap, h);
-				DUK_FREE(heap, h);
-			}
-		}
-		e->listlen = 0;
-	}
-}
-#endif  /* DUK_USE_STRTAB_CHAIN */
-
-#if defined(DUK_USE_STRTAB_PROBE)
-DUK_INTERNAL void duk_heap_free_strtab(duk_heap *heap) {
-	duk_uint_fast32_t i;
-	duk_hstring *h;
-
-#if defined(DUK_USE_HEAPPTR16)
-	if (heap->strtable16) {
-#else
-	if (heap->strtable) {
-#endif
-		for (i = 0; i < (duk_uint_fast32_t) heap->st_size; i++) {
-#if defined(DUK_USE_HEAPPTR16)
-			h = (duk_hstring *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, heap->strtable16[i]);
-#else
-			h = heap->strtable[i];
-#endif
-			if (h == NULL || h == DUK_STRTAB_DELETED_MARKER(heap)) {
-				continue;
-			}
-			DUK_ASSERT(h != NULL);
-
-			/* strings may have inner refs (extdata) in some cases */
-			duk_free_hstring_inner(heap, h);
-			DUK_FREE(heap, h);
-#if 0  /* not strictly necessary */
-			heap->strtable[i] = NULL;
-#endif
-		}
-#if defined(DUK_USE_HEAPPTR16)
-		DUK_FREE(heap, heap->strtable16);
-#else
-		DUK_FREE(heap, heap->strtable);
-#endif
-#if 0  /* not strictly necessary */
-		heap->strtable = NULL;
-#endif
-	}
-}
-#endif  /* DUK_USE_STRTAB_PROBE */
-
-/* Undefine local defines */
-#undef DUK__HASH_INITIAL
-#undef DUK__HASH_PROBE_STEP
-#undef DUK__DELETED_MARKER

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/ede68a10/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_heaphdr.h
----------------------------------------------------------------------
diff --git a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_heaphdr.h b/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_heaphdr.h
deleted file mode 100644
index d489032..0000000
--- a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_heaphdr.h
+++ /dev/null
@@ -1,750 +0,0 @@
-/*
- *  Heap header definition and assorted macros, including ref counting.
- *  Access all fields through the accessor macros.
- */
-
-#ifndef DUK_HEAPHDR_H_INCLUDED
-#define DUK_HEAPHDR_H_INCLUDED
-
-/*
- *  Common heap header
- *
- *  All heap objects share the same flags and refcount fields.  Objects other
- *  than strings also need to have a single or double linked list pointers
- *  for insertion into the "heap allocated" list.  Strings are held in the
- *  heap-wide string table so they don't need link pointers.
- *
- *  Technically, 'h_refcount' must be wide enough to guarantee that it cannot
- *  wrap (otherwise objects might be freed incorrectly after wrapping).  This
- *  means essentially that the refcount field must be as wide as data pointers.
- *  On 64-bit platforms this means that the refcount needs to be 64 bits even
- *  if an 'int' is 32 bits.  This is a bit unfortunate, and compromising on
- *  this might be reasonable in the future.
- *
- *  Heap header size on 32-bit platforms: 8 bytes without reference counting,
- *  16 bytes with reference counting.
- */
-
-struct duk_heaphdr {
-	duk_uint32_t h_flags;
-
-#if defined(DUK_USE_REFERENCE_COUNTING)
-#if defined(DUK_USE_REFCOUNT16)
-	duk_uint16_t h_refcount16;
-#else
-	duk_size_t h_refcount;
-#endif
-#endif
-
-#if defined(DUK_USE_HEAPPTR16)
-	duk_uint16_t h_next16;
-#else
-	duk_heaphdr *h_next;
-#endif
-
-#if defined(DUK_USE_DOUBLE_LINKED_HEAP)
-	/* refcounting requires direct heap frees, which in turn requires a dual linked heap */
-#if defined(DUK_USE_HEAPPTR16)
-	duk_uint16_t h_prev16;
-#else
-	duk_heaphdr *h_prev;
-#endif
-#endif
-
-	/* When DUK_USE_HEAPPTR16 (and DUK_USE_REFCOUNT16) is in use, the
-	 * struct won't align nicely to 4 bytes.  This 16-bit extra field
-	 * is added to make the alignment clean; the field can be used by
-	 * heap objects when 16-bit packing is used.  This field is now
-	 * conditional to DUK_USE_HEAPPTR16 only, but it is intended to be
-	 * used with DUK_USE_REFCOUNT16 and DUK_USE_DOUBLE_LINKED_HEAP;
-	 * this only matter to low memory environments anyway.
-	 */
-#if defined(DUK_USE_HEAPPTR16)
-	duk_uint16_t h_extra16;
-#endif
-};
-
-struct duk_heaphdr_string {
-	/* 16 bits would be enough for shared heaphdr flags and duk_hstring
-	 * flags.  The initial parts of duk_heaphdr_string and duk_heaphdr
-	 * must match so changing the flags field size here would be quite
-	 * awkward.  However, to minimize struct size, we can pack at least
-	 * 16 bits of duk_hstring data into the flags field.
-	 */
-	duk_uint32_t h_flags;
-
-#if defined(DUK_USE_REFERENCE_COUNTING)
-#if defined(DUK_USE_REFCOUNT16)
-	duk_uint16_t h_refcount16;
-	duk_uint16_t h_strextra16;  /* round out to 8 bytes */
-#else
-	duk_size_t h_refcount;
-#endif
-#endif
-};
-
-#define DUK_HEAPHDR_FLAGS_TYPE_MASK      0x00000003UL
-#define DUK_HEAPHDR_FLAGS_FLAG_MASK      (~DUK_HEAPHDR_FLAGS_TYPE_MASK)
-
-                                             /* 2 bits for heap type */
-#define DUK_HEAPHDR_FLAGS_HEAP_START     2   /* 5 heap flags */
-#define DUK_HEAPHDR_FLAGS_USER_START     7   /* 25 user flags */
-
-#define DUK_HEAPHDR_HEAP_FLAG_NUMBER(n)  (DUK_HEAPHDR_FLAGS_HEAP_START + (n))
-#define DUK_HEAPHDR_USER_FLAG_NUMBER(n)  (DUK_HEAPHDR_FLAGS_USER_START + (n))
-#define DUK_HEAPHDR_HEAP_FLAG(n)         (1UL << (DUK_HEAPHDR_FLAGS_HEAP_START + (n)))
-#define DUK_HEAPHDR_USER_FLAG(n)         (1UL << (DUK_HEAPHDR_FLAGS_USER_START + (n)))
-
-#define DUK_HEAPHDR_FLAG_REACHABLE       DUK_HEAPHDR_HEAP_FLAG(0)  /* mark-and-sweep: reachable */
-#define DUK_HEAPHDR_FLAG_TEMPROOT        DUK_HEAPHDR_HEAP_FLAG(1)  /* mark-and-sweep: children not processed */
-#define DUK_HEAPHDR_FLAG_FINALIZABLE     DUK_HEAPHDR_HEAP_FLAG(2)  /* mark-and-sweep: finalizable (on current pass) */
-#define DUK_HEAPHDR_FLAG_FINALIZED       DUK_HEAPHDR_HEAP_FLAG(3)  /* mark-and-sweep: finalized (on previous pass) */
-#define DUK_HEAPHDR_FLAG_READONLY        DUK_HEAPHDR_HEAP_FLAG(4)  /* read-only object, in code section */
-
-#define DUK_HTYPE_MIN                    1
-#define DUK_HTYPE_STRING                 1
-#define DUK_HTYPE_OBJECT                 2
-#define DUK_HTYPE_BUFFER                 3
-#define DUK_HTYPE_MAX                    3
-
-#if defined(DUK_USE_HEAPPTR16)
-#define DUK_HEAPHDR_GET_NEXT(heap,h) \
-	((duk_heaphdr *) DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, (h)->h_next16))
-#define DUK_HEAPHDR_SET_NEXT(heap,h,val)   do { \
-		(h)->h_next16 = DUK_USE_HEAPPTR_ENC16((heap)->heap_udata, (void *) val); \
-	} while (0)
-#else
-#define DUK_HEAPHDR_GET_NEXT(heap,h)  ((h)->h_next)
-#define DUK_HEAPHDR_SET_NEXT(heap,h,val)   do { \
-		(h)->h_next = (val); \
-	} while (0)
-#endif
-
-#if defined(DUK_USE_DOUBLE_LINKED_HEAP)
-#if defined(DUK_USE_HEAPPTR16)
-#define DUK_HEAPHDR_GET_PREV(heap,h) \
-	((duk_heaphdr *) DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, (h)->h_prev16))
-#define DUK_HEAPHDR_SET_PREV(heap,h,val)   do { \
-		(h)->h_prev16 = DUK_USE_HEAPPTR_ENC16((heap)->heap_udata, (void *) (val)); \
-	} while (0)
-#else
-#define DUK_HEAPHDR_GET_PREV(heap,h)       ((h)->h_prev)
-#define DUK_HEAPHDR_SET_PREV(heap,h,val)   do { \
-		(h)->h_prev = (val); \
-	} while (0)
-#endif
-#endif
-
-#if defined(DUK_USE_REFERENCE_COUNTING)
-#if defined(DUK_USE_REFCOUNT16)
-#define DUK_HEAPHDR_GET_REFCOUNT(h)   ((h)->h_refcount16)
-#define DUK_HEAPHDR_SET_REFCOUNT(h,val)  do { \
-		(h)->h_refcount16 = (val); \
-	} while (0)
-#define DUK_HEAPHDR_PREINC_REFCOUNT(h)  (++(h)->h_refcount16)  /* result: updated refcount */
-#define DUK_HEAPHDR_PREDEC_REFCOUNT(h)  (--(h)->h_refcount16)  /* result: updated refcount */
-#else
-#define DUK_HEAPHDR_GET_REFCOUNT(h)   ((h)->h_refcount)
-#define DUK_HEAPHDR_SET_REFCOUNT(h,val)  do { \
-		(h)->h_refcount = (val); \
-	} while (0)
-#define DUK_HEAPHDR_PREINC_REFCOUNT(h)  (++(h)->h_refcount)  /* result: updated refcount */
-#define DUK_HEAPHDR_PREDEC_REFCOUNT(h)  (--(h)->h_refcount)  /* result: updated refcount */
-#endif
-#else
-/* refcount macros not defined without refcounting, caller must #ifdef now */
-#endif  /* DUK_USE_REFERENCE_COUNTING */
-
-/*
- *  Note: type is treated as a field separate from flags, so some masking is
- *  involved in the macros below.
- */
-
-#define DUK_HEAPHDR_GET_FLAGS_RAW(h)  ((h)->h_flags)
-
-#define DUK_HEAPHDR_GET_FLAGS(h)      ((h)->h_flags & DUK_HEAPHDR_FLAGS_FLAG_MASK)
-#define DUK_HEAPHDR_SET_FLAGS(h,val)  do { \
-		(h)->h_flags = ((h)->h_flags & ~(DUK_HEAPHDR_FLAGS_FLAG_MASK)) | (val); \
-	} while (0)
-
-#define DUK_HEAPHDR_GET_TYPE(h)       ((h)->h_flags & DUK_HEAPHDR_FLAGS_TYPE_MASK)
-#define DUK_HEAPHDR_SET_TYPE(h,val)   do { \
-		(h)->h_flags = ((h)->h_flags & ~(DUK_HEAPHDR_FLAGS_TYPE_MASK)) | (val); \
-	} while (0)
-
-#define DUK_HEAPHDR_HTYPE_VALID(h)    ( \
-	DUK_HEAPHDR_GET_TYPE((h)) >= DUK_HTYPE_MIN && \
-	DUK_HEAPHDR_GET_TYPE((h)) <= DUK_HTYPE_MAX \
-	)
-
-#define DUK_HEAPHDR_SET_TYPE_AND_FLAGS(h,tval,fval)  do { \
-		(h)->h_flags = ((tval) & DUK_HEAPHDR_FLAGS_TYPE_MASK) | \
-		               ((fval) & DUK_HEAPHDR_FLAGS_FLAG_MASK); \
-	} while (0)
-
-#define DUK_HEAPHDR_SET_FLAG_BITS(h,bits)  do { \
-		DUK_ASSERT(((bits) & ~(DUK_HEAPHDR_FLAGS_FLAG_MASK)) == 0); \
-		(h)->h_flags |= (bits); \
-	} while (0)
-
-#define DUK_HEAPHDR_CLEAR_FLAG_BITS(h,bits)  do { \
-		DUK_ASSERT(((bits) & ~(DUK_HEAPHDR_FLAGS_FLAG_MASK)) == 0); \
-		(h)->h_flags &= ~((bits)); \
-	} while (0)
-
-#define DUK_HEAPHDR_CHECK_FLAG_BITS(h,bits)  (((h)->h_flags & (bits)) != 0)
-
-#define DUK_HEAPHDR_SET_REACHABLE(h)      DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_REACHABLE)
-#define DUK_HEAPHDR_CLEAR_REACHABLE(h)    DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_REACHABLE)
-#define DUK_HEAPHDR_HAS_REACHABLE(h)      DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_REACHABLE)
-
-#define DUK_HEAPHDR_SET_TEMPROOT(h)       DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_TEMPROOT)
-#define DUK_HEAPHDR_CLEAR_TEMPROOT(h)     DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_TEMPROOT)
-#define DUK_HEAPHDR_HAS_TEMPROOT(h)       DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_TEMPROOT)
-
-#define DUK_HEAPHDR_SET_FINALIZABLE(h)    DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZABLE)
-#define DUK_HEAPHDR_CLEAR_FINALIZABLE(h)  DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZABLE)
-#define DUK_HEAPHDR_HAS_FINALIZABLE(h)    DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZABLE)
-
-#define DUK_HEAPHDR_SET_FINALIZED(h)      DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZED)
-#define DUK_HEAPHDR_CLEAR_FINALIZED(h)    DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZED)
-#define DUK_HEAPHDR_HAS_FINALIZED(h)      DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZED)
-
-#define DUK_HEAPHDR_SET_READONLY(h)       DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_READONLY)
-#define DUK_HEAPHDR_CLEAR_READONLY(h)     DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_READONLY)
-#define DUK_HEAPHDR_HAS_READONLY(h)       DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_READONLY)
-
-/* get or set a range of flags; m=first bit number, n=number of bits */
-#define DUK_HEAPHDR_GET_FLAG_RANGE(h,m,n)  (((h)->h_flags >> (m)) & ((1UL << (n)) - 1UL))
-
-#define DUK_HEAPHDR_SET_FLAG_RANGE(h,m,n,v)  do { \
-		(h)->h_flags = \
-			((h)->h_flags & (~(((1 << (n)) - 1) << (m)))) \
-			| ((v) << (m)); \
-	} while (0)
-
-/* init pointer fields to null */
-#if defined(DUK_USE_DOUBLE_LINKED_HEAP)
-#define DUK_HEAPHDR_INIT_NULLS(h)       do { \
-		DUK_HEAPHDR_SET_NEXT((h), (void *) NULL); \
-		DUK_HEAPHDR_SET_PREV((h), (void *) NULL); \
-	} while (0)
-#else
-#define DUK_HEAPHDR_INIT_NULLS(h)       do { \
-		DUK_HEAPHDR_SET_NEXT((h), (void *) NULL); \
-	} while (0)
-#endif
-
-#define DUK_HEAPHDR_STRING_INIT_NULLS(h)  /* currently nop */
-
-/*
- *  Assert helpers
- */
-
-/* Check that prev/next links are consistent: if e.g. h->prev is != NULL,
- * h->prev->next should point back to h.
- */
-#if defined(DUK_USE_DOUBLE_LINKED_HEAP) && defined(DUK_USE_ASSERTIONS)
-#define DUK_ASSERT_HEAPHDR_LINKS(heap,h) do { \
-		if ((h) != NULL) { \
-			duk_heaphdr *h__prev, *h__next; \
-			h__prev = DUK_HEAPHDR_GET_PREV((heap), (h)); \
-			h__next = DUK_HEAPHDR_GET_NEXT((heap), (h)); \
-			DUK_ASSERT(h__prev == NULL || (DUK_HEAPHDR_GET_NEXT((heap), h__prev) == (h))); \
-			DUK_ASSERT(h__next == NULL || (DUK_HEAPHDR_GET_PREV((heap), h__next) == (h))); \
-		} \
-	} while (0)
-#else
-#define DUK_ASSERT_HEAPHDR_LINKS(heap,h) do {} while (0)
-#endif
-
-/*
- *  Reference counting helper macros.  The macros take a thread argument
- *  and must thus always be executed in a specific thread context.  The
- *  thread argument is needed for features like finalization.  Currently
- *  it is not required for INCREF, but it is included just in case.
- *
- *  Note that 'raw' macros such as DUK_HEAPHDR_GET_REFCOUNT() are not
- *  defined without DUK_USE_REFERENCE_COUNTING, so caller must #ifdef
- *  around them.
- */
-
-#if defined(DUK_USE_REFERENCE_COUNTING)
-
-#if defined(DUK_USE_ROM_OBJECTS)
-/* With ROM objects "needs refcount update" is true when the value is
- * heap allocated and is not a ROM object.
- */
-/* XXX: double evaluation for 'tv' argument. */
-#define DUK_TVAL_NEEDS_REFCOUNT_UPDATE(tv) \
-	(DUK_TVAL_IS_HEAP_ALLOCATED((tv)) && !DUK_HEAPHDR_HAS_READONLY(DUK_TVAL_GET_HEAPHDR((tv))))
-#define DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE(h)  (!DUK_HEAPHDR_HAS_READONLY((h)))
-#else  /* DUK_USE_ROM_OBJECTS */
-/* Without ROM objects "needs refcount update" == is heap allocated. */
-#define DUK_TVAL_NEEDS_REFCOUNT_UPDATE(tv)    DUK_TVAL_IS_HEAP_ALLOCATED((tv))
-#define DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE(h)  1
-#endif  /* DUK_USE_ROM_OBJECTS */
-
-/* Fast variants, inline refcount operations except for refzero handling.
- * Can be used explicitly when speed is always more important than size.
- * For a good compiler and a single file build, these are basically the
- * same as a forced inline.
- */
-#define DUK_TVAL_INCREF_FAST(thr,tv) do { \
-		duk_tval *duk__tv = (tv); \
-		DUK_ASSERT(duk__tv != NULL); \
-		if (DUK_TVAL_NEEDS_REFCOUNT_UPDATE(duk__tv)) { \
-			duk_heaphdr *duk__h = DUK_TVAL_GET_HEAPHDR(duk__tv); \
-			DUK_ASSERT(duk__h != NULL); \
-			DUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \
-			DUK_HEAPHDR_PREINC_REFCOUNT(duk__h); \
-		} \
-	} while (0)
-#define DUK_TVAL_DECREF_FAST(thr,tv) do { \
-		duk_tval *duk__tv = (tv); \
-		DUK_ASSERT(duk__tv != NULL); \
-		if (DUK_TVAL_NEEDS_REFCOUNT_UPDATE(duk__tv)) { \
-			duk_heaphdr *duk__h = DUK_TVAL_GET_HEAPHDR(duk__tv); \
-			DUK_ASSERT(duk__h != NULL); \
-			DUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \
-			DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(duk__h) > 0); \
-			if (DUK_HEAPHDR_PREDEC_REFCOUNT(duk__h) == 0) { \
-				duk_heaphdr_refzero((thr), duk__h); \
-			} \
-		} \
-	} while (0)
-#define DUK_HEAPHDR_INCREF_FAST(thr,h) do { \
-		duk_heaphdr *duk__h = (duk_heaphdr *) (h); \
-		DUK_ASSERT(duk__h != NULL); \
-		DUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \
-		if (DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE(duk__h)) { \
-			DUK_HEAPHDR_PREINC_REFCOUNT(duk__h); \
-		} \
-	} while (0)
-#define DUK_HEAPHDR_DECREF_FAST(thr,h) do { \
-		duk_heaphdr *duk__h = (duk_heaphdr *) (h); \
-		DUK_ASSERT(duk__h != NULL); \
-		DUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \
-		DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(duk__h) > 0); \
-		if (DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE(duk__h)) { \
-			if (DUK_HEAPHDR_PREDEC_REFCOUNT(duk__h) == 0) { \
-				duk_heaphdr_refzero((thr), duk__h); \
-			} \
-		} \
-	} while (0)
-
-/* Slow variants, call to a helper to reduce code size.
- * Can be used explicitly when size is always more important than speed.
- */
-#define DUK_TVAL_INCREF_SLOW(thr,tv) do { \
-		duk_tval_incref((tv)); \
-	} while (0)
-#define DUK_TVAL_DECREF_SLOW(thr,tv) do { \
-		duk_tval_decref((thr), (tv)); \
-	} while (0)
-#define DUK_HEAPHDR_INCREF_SLOW(thr,h) do { \
-		duk_heaphdr_incref((duk_heaphdr *) (h)); \
-	} while (0)
-#define DUK_HEAPHDR_DECREF_SLOW(thr,h) do { \
-		duk_heaphdr_decref((thr), (duk_heaphdr *) (h)); \
-	} while (0)
-
-/* Default variants.  Selection depends on speed/size preference.
- * Concretely: with gcc 4.8.1 -Os x64 the difference in final binary
- * is about +1kB for _FAST variants.
- */
-#if defined(DUK_USE_FAST_REFCOUNT_DEFAULT)
-#define DUK_TVAL_INCREF(thr,tv)                DUK_TVAL_INCREF_FAST((thr),(tv))
-#define DUK_TVAL_DECREF(thr,tv)                DUK_TVAL_DECREF_FAST((thr),(tv))
-#define DUK_HEAPHDR_INCREF(thr,h)              DUK_HEAPHDR_INCREF_FAST((thr),(h))
-#define DUK_HEAPHDR_DECREF(thr,h)              DUK_HEAPHDR_DECREF_FAST((thr),(h))
-#else
-#define DUK_TVAL_INCREF(thr,tv)                DUK_TVAL_INCREF_SLOW((thr),(tv))
-#define DUK_TVAL_DECREF(thr,tv)                DUK_TVAL_DECREF_SLOW((thr),(tv))
-#define DUK_HEAPHDR_INCREF(thr,h)              DUK_HEAPHDR_INCREF_SLOW((thr),(h))
-#define DUK_HEAPHDR_DECREF(thr,h)              DUK_HEAPHDR_DECREF_SLOW((thr),(h))
-#endif
-
-/* Casting convenience. */
-#define DUK_HSTRING_INCREF(thr,h)              DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))
-#define DUK_HSTRING_DECREF(thr,h)              DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))
-#define DUK_HOBJECT_INCREF(thr,h)              DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))
-#define DUK_HOBJECT_DECREF(thr,h)              DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))
-#define DUK_HBUFFER_INCREF(thr,h)              DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))
-#define DUK_HBUFFER_DECREF(thr,h)              DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))
-#define DUK_HCOMPILEDFUNCTION_INCREF(thr,h)    DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)
-#define DUK_HCOMPILEDFUNCTION_DECREF(thr,h)    DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)
-#define DUK_HNATIVEFUNCTION_INCREF(thr,h)      DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)
-#define DUK_HNATIVEFUNCTION_DECREF(thr,h)      DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)
-#define DUK_HBUFFEROBJECT_INCREF(thr,h)        DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)
-#define DUK_HBUFFEROBJECT_DECREF(thr,h)        DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)
-#define DUK_HTHREAD_INCREF(thr,h)              DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)
-#define DUK_HTHREAD_DECREF(thr,h)              DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)
-
-/* Convenience for some situations; the above macros don't allow NULLs
- * for performance reasons.
- */
-#define DUK_HOBJECT_INCREF_ALLOWNULL(thr,h) do { \
-		if ((h) != NULL) { \
-			DUK_HEAPHDR_INCREF((thr), (duk_heaphdr *) (h)); \
-		} \
-	} while (0)
-#define DUK_HOBJECT_DECREF_ALLOWNULL(thr,h) do { \
-		if ((h) != NULL) { \
-			DUK_HEAPHDR_DECREF((thr), (duk_heaphdr *) (h)); \
-		} \
-	} while (0)
-
-/*
- *  Macros to set a duk_tval and update refcount of the target (decref the
- *  old value and incref the new value if necessary).  This is both performance
- *  and footprint critical; any changes made should be measured for size/speed.
- */
-
-#define DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0(thr,tvptr_dst) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_UNDEFINED(tv__dst); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-
-#define DUK_TVAL_SET_UNUSED_UPDREF_ALT0(thr,tvptr_dst) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_UNUSED(tv__dst); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-
-#define DUK_TVAL_SET_NULL_UPDREF_ALT0(thr,tvptr_dst) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_NULL(tv__dst); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-
-#define DUK_TVAL_SET_BOOLEAN_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_BOOLEAN(tv__dst, (newval)); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-
-#define DUK_TVAL_SET_NUMBER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_NUMBER(tv__dst, (newval)); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-#define DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_NUMBER_CHKFAST(tv__dst, (newval)); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-#define DUK_TVAL_SET_DOUBLE_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_DOUBLE(tv__dst, (newval)); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-#define DUK_TVAL_SET_NAN_UPDREF_ALT0(thr,tvptr_dst) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_NAN(tv__dst); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-#if defined(DUK_USE_FASTINT)
-#define DUK_TVAL_SET_FASTINT_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_FASTINT(tv__dst, (newval)); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-#define DUK_TVAL_SET_FASTINT_I32_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_FASTINT_I32(tv__dst, (newval)); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-#define DUK_TVAL_SET_FASTINT_U32_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_FASTINT_U32(tv__dst, (newval)); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-#else
-#define DUK_TVAL_SET_DOUBLE_CAST_UPDREF(thr,tvptr_dst,newval) \
-	DUK_TVAL_SET_DOUBLE_UPDREF((thr), (tvptr_dst), (duk_double_t) (newval))
-#endif  /* DUK_USE_FASTINT */
-
-#define DUK_TVAL_SET_LIGHTFUNC_UPDREF_ALT0(thr,tvptr_dst,lf_v,lf_fp,lf_flags) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_LIGHTFUNC(tv__dst, (lf_v), (lf_fp), (lf_flags)); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-
-#define DUK_TVAL_SET_STRING_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_STRING(tv__dst, (newval)); \
-		DUK_HSTRING_INCREF((thr), (newval)); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-
-#define DUK_TVAL_SET_OBJECT_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_OBJECT(tv__dst, (newval)); \
-		DUK_HOBJECT_INCREF((thr), (newval)); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-
-#define DUK_TVAL_SET_BUFFER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_BUFFER(tv__dst, (newval)); \
-		DUK_HBUFFER_INCREF((thr), (newval)); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-
-#define DUK_TVAL_SET_POINTER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_POINTER(tv__dst, (newval)); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-
-/* DUK_TVAL_SET_TVAL_UPDREF() is used a lot in executor, property lookups,
- * etc, so it's very important for performance.  Measure when changing.
- *
- * NOTE: the source and destination duk_tval pointers may be the same, and
- * the macros MUST deal with that correctly.
- */
-
-/* Original idiom used, minimal code size. */
-#define DUK_TVAL_SET_TVAL_UPDREF_ALT0(thr,tvptr_dst,tvptr_src) do { \
-		duk_tval *tv__dst, *tv__src; duk_tval tv__tmp; \
-		tv__dst = (tvptr_dst); tv__src = (tvptr_src); \
-		DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
-		DUK_TVAL_SET_TVAL(tv__dst, tv__src); \
-		DUK_TVAL_INCREF((thr), tv__src); \
-		DUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \
-	} while (0)
-
-/* Faster alternative: avoid making a temporary copy of tvptr_dst and use
- * fast incref/decref macros.
- */
-#define DUK_TVAL_SET_TVAL_UPDREF_ALT1(thr,tvptr_dst,tvptr_src) do { \
-		duk_tval *tv__dst, *tv__src; duk_heaphdr *h__obj; \
-		tv__dst = (tvptr_dst); tv__src = (tvptr_src); \
-		DUK_TVAL_INCREF_FAST((thr), tv__src); \
-		if (DUK_TVAL_NEEDS_REFCOUNT_UPDATE(tv__dst)) { \
-			h__obj = DUK_TVAL_GET_HEAPHDR(tv__dst); \
-			DUK_ASSERT(h__obj != NULL); \
-			DUK_TVAL_SET_TVAL(tv__dst, tv__src); \
-			DUK_HEAPHDR_DECREF_FAST((thr), h__obj);  /* side effects */ \
-		} else { \
-			DUK_TVAL_SET_TVAL(tv__dst, tv__src); \
-		} \
-	} while (0)
-
-/* XXX: no optimized variants yet */
-#define DUK_TVAL_SET_UNDEFINED_UPDREF         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
-#define DUK_TVAL_SET_NUMBER_UPDREF            DUK_TVAL_SET_NUMBER_UPDREF_ALT0
-#define DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF    DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF_ALT0
-#define DUK_TVAL_SET_DOUBLE_UPDREF            DUK_TVAL_SET_DOUBLE_UPDREF_ALT0
-#define DUK_TVAL_SET_NAN_UPDREF               DUK_TVAL_SET_NAN_UPDREF_ALT0
-#if defined(DUK_USE_FASTINT)
-#define DUK_TVAL_SET_FASTINT_UPDREF           DUK_TVAL_SET_FASTINT_UPDREF_ALT0
-#define DUK_TVAL_SET_FASTINT_I32_UPDREF       DUK_TVAL_SET_FASTINT_I32_UPDREF_ALT0
-#define DUK_TVAL_SET_FASTINT_U32_UPDREF       DUK_TVAL_SET_FASTINT_U32_UPDREF_ALT0
-#else
-#define DUK_TVAL_SET_FASTINT_UPDREF           DUK_TVAL_SET_DOUBLE_CAST_UPDREF  /* XXX: fast int-to-double */
-#define DUK_TVAL_SET_FASTINT_I32_UPDREF       DUK_TVAL_SET_DOUBLE_CAST_UPDREF
-#define DUK_TVAL_SET_FASTINT_U32_UPDREF       DUK_TVAL_SET_DOUBLE_CAST_UPDREF
-#endif  /* DUK_USE_FASTINT */
-#define DUK_TVAL_SET_LIGHTFUNC_UPDREF         DUK_TVAL_SET_LIGHTFUNC_UPDREF_ALT0
-#define DUK_TVAL_SET_STRING_UPDREF            DUK_TVAL_SET_STRING_UPDREF_ALT0
-#define DUK_TVAL_SET_OBJECT_UPDREF            DUK_TVAL_SET_OBJECT_UPDREF_ALT0
-#define DUK_TVAL_SET_BUFFER_UPDREF            DUK_TVAL_SET_BUFFER_UPDREF_ALT0
-#define DUK_TVAL_SET_POINTER_UPDREF           DUK_TVAL_SET_POINTER_UPDREF_ALT0
-
-#if defined(DUK_USE_FAST_REFCOUNT_DEFAULT)
-/* Optimized for speed. */
-#define DUK_TVAL_SET_TVAL_UPDREF              DUK_TVAL_SET_TVAL_UPDREF_ALT1
-#define DUK_TVAL_SET_TVAL_UPDREF_FAST         DUK_TVAL_SET_TVAL_UPDREF_ALT1
-#define DUK_TVAL_SET_TVAL_UPDREF_SLOW         DUK_TVAL_SET_TVAL_UPDREF_ALT0
-#else
-/* Optimized for size. */
-#define DUK_TVAL_SET_TVAL_UPDREF              DUK_TVAL_SET_TVAL_UPDREF_ALT0
-#define DUK_TVAL_SET_TVAL_UPDREF_FAST         DUK_TVAL_SET_TVAL_UPDREF_ALT0
-#define DUK_TVAL_SET_TVAL_UPDREF_SLOW         DUK_TVAL_SET_TVAL_UPDREF_ALT0
-#endif
-
-#else  /* DUK_USE_REFERENCE_COUNTING */
-
-#define DUK_TVAL_INCREF_FAST(thr,v)            do {} while (0) /* nop */
-#define DUK_TVAL_DECREF_FAST(thr,v)            do {} while (0) /* nop */
-#define DUK_TVAL_INCREF_SLOW(thr,v)            do {} while (0) /* nop */
-#define DUK_TVAL_DECREF_SLOW(thr,v)            do {} while (0) /* nop */
-#define DUK_TVAL_INCREF(thr,v)                 do {} while (0) /* nop */
-#define DUK_TVAL_DECREF(thr,v)                 do {} while (0) /* nop */
-#define DUK_HEAPHDR_INCREF_FAST(thr,h)         do {} while (0) /* nop */
-#define DUK_HEAPHDR_DECREF_FAST(thr,h)         do {} while (0) /* nop */
-#define DUK_HEAPHDR_INCREF_SLOW(thr,h)         do {} while (0) /* nop */
-#define DUK_HEAPHDR_DECREF_SLOW(thr,h)         do {} while (0) /* nop */
-#define DUK_HEAPHDR_INCREF(thr,h)              do {} while (0) /* nop */
-#define DUK_HEAPHDR_DECREF(thr,h)              do {} while (0) /* nop */
-#define DUK_HSTRING_INCREF(thr,h)              do {} while (0) /* nop */
-#define DUK_HSTRING_DECREF(thr,h)              do {} while (0) /* nop */
-#define DUK_HOBJECT_INCREF(thr,h)              do {} while (0) /* nop */
-#define DUK_HOBJECT_DECREF(thr,h)              do {} while (0) /* nop */
-#define DUK_HBUFFER_INCREF(thr,h)              do {} while (0) /* nop */
-#define DUK_HBUFFER_DECREF(thr,h)              do {} while (0) /* nop */
-#define DUK_HCOMPILEDFUNCTION_INCREF(thr,h)    do {} while (0) /* nop */
-#define DUK_HCOMPILEDFUNCTION_DECREF(thr,h)    do {} while (0) /* nop */
-#define DUK_HNATIVEFUNCTION_INCREF(thr,h)      do {} while (0) /* nop */
-#define DUK_HNATIVEFUNCTION_DECREF(thr,h)      do {} while (0) /* nop */
-#define DUK_HBUFFEROBJECT_INCREF(thr,h)        do {} while (0) /* nop */
-#define DUK_HBUFFEROBJECT_DECREF(thr,h)        do {} while (0) /* nop */
-#define DUK_HTHREAD_INCREF(thr,h)              do {} while (0) /* nop */
-#define DUK_HTHREAD_DECREF(thr,h)              do {} while (0) /* nop */
-#define DUK_HOBJECT_INCREF_ALLOWNULL(thr,h)    do {} while (0) /* nop */
-#define DUK_HOBJECT_DECREF_ALLOWNULL(thr,h)    do {} while (0) /* nop */
-
-#define DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0(thr,tvptr_dst) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_UNDEFINED(tv__dst); \
-		DUK_UNREF((thr)); \
-	} while (0)
-
-#define DUK_TVAL_SET_UNUSED_UPDREF_ALT0(thr,tvptr_dst) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_UNUSED(tv__dst); \
-		DUK_UNREF((thr)); \
-	} while (0)
-
-#define DUK_TVAL_SET_NULL_UPDREF_ALT0(thr,tvptr_dst) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_NULL(tv__dst); \
-		DUK_UNREF((thr)); \
-	} while (0)
-
-#define DUK_TVAL_SET_BOOLEAN_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_BOOLEAN(tv__dst, (newval)); \
-		DUK_UNREF((thr)); \
-	} while (0)
-
-#define DUK_TVAL_SET_NUMBER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_NUMBER(tv__dst, (newval)); \
-		DUK_UNREF((thr)); \
-	} while (0)
-#define DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_NUMBER_CHKFAST(tv__dst, (newval)); \
-		DUK_UNREF((thr)); \
-	} while (0)
-#define DUK_TVAL_SET_DOUBLE_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_DOUBLE(tv__dst, (newval)); \
-		DUK_UNREF((thr)); \
-	} while (0)
-#define DUK_TVAL_SET_NAN_UPDREF_ALT0(thr,tvptr_dst) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_NAN(tv__dst); \
-		DUK_UNREF((thr)); \
-	} while (0)
-#if defined(DUK_USE_FASTINT)
-#define DUK_TVAL_SET_FASTINT_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_FASTINT(tv__dst, (newval)); \
-		DUK_UNREF((thr)); \
-	} while (0)
-#define DUK_TVAL_SET_FASTINT_I32_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_FASTINT_I32(tv__dst, (newval)); \
-		DUK_UNREF((thr)); \
-	} while (0)
-#define DUK_TVAL_SET_FASTINT_U32_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_FASTINT_U32(tv__dst, (newval)); \
-		DUK_UNREF((thr)); \
-	} while (0)
-#else
-#define DUK_TVAL_SET_DOUBLE_CAST_UPDREF(thr,tvptr_dst,newval) \
-	DUK_TVAL_SET_DOUBLE_UPDREF((thr), (tvptr_dst), (duk_double_t) (newval))
-#endif  /* DUK_USE_FASTINT */
-
-#define DUK_TVAL_SET_LIGHTFUNC_UPDREF_ALT0(thr,tvptr_dst,lf_v,lf_fp,lf_flags) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_LIGHTFUNC(tv__dst, (lf_v), (lf_fp), (lf_flags)); \
-		DUK_UNREF((thr)); \
-	} while (0)
-
-#define DUK_TVAL_SET_STRING_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_STRING(tv__dst, (newval)); \
-		DUK_UNREF((thr)); \
-	} while (0)
-
-#define DUK_TVAL_SET_OBJECT_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_OBJECT(tv__dst, (newval)); \
-		DUK_UNREF((thr)); \
-	} while (0)
-
-#define DUK_TVAL_SET_BUFFER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_BUFFER(tv__dst, (newval)); \
-		DUK_UNREF((thr)); \
-	} while (0)
-
-#define DUK_TVAL_SET_POINTER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
-		duk_tval *tv__dst; tv__dst = (tvptr_dst); \
-		DUK_TVAL_SET_POINTER(tv__dst, (newval)); \
-		DUK_UNREF((thr)); \
-	} while (0)
-
-#define DUK_TVAL_SET_TVAL_UPDREF_ALT0(thr,tvptr_dst,tvptr_src) do { \
-		duk_tval *tv__dst, *tv__src; \
-		tv__dst = (tvptr_dst); tv__src = (tvptr_src); \
-		DUK_TVAL_SET_TVAL(tv__dst, tv__src); \
-		DUK_UNREF((thr)); \
-	} while (0)
-
-#define DUK_TVAL_SET_UNDEFINED_UPDREF         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
-#define DUK_TVAL_SET_NUMBER_UPDREF            DUK_TVAL_SET_NUMBER_UPDREF_ALT0
-#define DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF    DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF_ALT0
-#define DUK_TVAL_SET_DOUBLE_UPDREF            DUK_TVAL_SET_DOUBLE_UPDREF_ALT0
-#define DUK_TVAL_SET_NAN_UPDREF               DUK_TVAL_SET_NAN_UPDREF_ALT0
-#if defined(DUK_USE_FASTINT)
-#define DUK_TVAL_SET_FASTINT_UPDREF           DUK_TVAL_SET_FASTINT_UPDREF_ALT0
-#define DUK_TVAL_SET_FASTINT_I32_UPDREF       DUK_TVAL_SET_FASTINT_I32_UPDREF_ALT0
-#define DUK_TVAL_SET_FASTINT_U32_UPDREF       DUK_TVAL_SET_FASTINT_U32_UPDREF_ALT0
-#else
-#define DUK_TVAL_SET_FASTINT_UPDREF           DUK_TVAL_SET_DOUBLE_CAST_UPDREF  /* XXX: fast-int-to-double */
-#define DUK_TVAL_SET_FASTINT_I32_UPDREF       DUK_TVAL_SET_DOUBLE_CAST_UPDREF
-#define DUK_TVAL_SET_FASTINT_U32_UPDREF       DUK_TVAL_SET_DOUBLE_CAST_UPDREF
-#endif  /* DUK_USE_FASTINT */
-#define DUK_TVAL_SET_LIGHTFUNC_UPDREF         DUK_TVAL_SET_LIGHTFUNC_UPDREF_ALT0
-#define DUK_TVAL_SET_STRING_UPDREF            DUK_TVAL_SET_STRING_UPDREF_ALT0
-#define DUK_TVAL_SET_OBJECT_UPDREF            DUK_TVAL_SET_OBJECT_UPDREF_ALT0
-#define DUK_TVAL_SET_BUFFER_UPDREF            DUK_TVAL_SET_BUFFER_UPDREF_ALT0
-#define DUK_TVAL_SET_POINTER_UPDREF           DUK_TVAL_SET_POINTER_UPDREF_ALT0
-
-#define DUK_TVAL_SET_TVAL_UPDREF              DUK_TVAL_SET_TVAL_UPDREF_ALT0
-#define DUK_TVAL_SET_TVAL_UPDREF_FAST         DUK_TVAL_SET_TVAL_UPDREF_ALT0
-#define DUK_TVAL_SET_TVAL_UPDREF_SLOW         DUK_TVAL_SET_TVAL_UPDREF_ALT0
-
-#endif  /* DUK_USE_REFERENCE_COUNTING */
-
-#endif  /* DUK_HEAPHDR_H_INCLUDED */

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/ede68a10/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_hnativefunction.h
----------------------------------------------------------------------
diff --git a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_hnativefunction.h b/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_hnativefunction.h
deleted file mode 100644
index 74c48e6..0000000
--- a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_hnativefunction.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *  Heap native function representation.
- */
-
-#ifndef DUK_HNATIVEFUNCTION_H_INCLUDED
-#define DUK_HNATIVEFUNCTION_H_INCLUDED
-
-#define DUK_HNATIVEFUNCTION_NARGS_VARARGS  ((duk_int16_t) -1)
-#define DUK_HNATIVEFUNCTION_NARGS_MAX      ((duk_int16_t) 0x7fff)
-
-struct duk_hnativefunction {
-	/* shared object part */
-	duk_hobject obj;
-
-	duk_c_function func;
-	duk_int16_t nargs;
-	duk_int16_t magic;
-
-	/* The 'magic' field allows an opaque 16-bit field to be accessed by the
-	 * Duktape/C function.  This allows, for instance, the same native function
-	 * to be used for a set of very similar functions, with the 'magic' field
-	 * providing the necessary non-argument flags / values to guide the behavior
-	 * of the native function.  The value is signed on purpose: it is easier to
-	 * convert a signed value to unsigned (simply AND with 0xffff) than vice
-	 * versa.
-	 *
-	 * Note: cannot place nargs/magic into the heaphdr flags, because
-	 * duk_hobject takes almost all flags already (and needs the spare).
-	 */
-};
-
-#endif  /* DUK_HNATIVEFUNCTION_H_INCLUDED */