Input 'val' pointer may be a value stack pointer, which may become
stale if the variable lookup reallocates the current value stack.
This can happen e.g. in a with(proxy).
Rename duk_is_null_or_undefined() to duk_is_nullish() to better match
current ECMAScript terminology. Keep duk_is_null_or_undefined() as a
deprecated API macro. Add internal DUK_TVAL_IS_NULLISH().
Even though another native thread runs code on a different Duktape
thread, its code may trigger finalizers, and those always run on the
heap thread. And the heap thread may have been the one that was
suspended. This would in turn result in duk__call_thread_state_update()
failing, and finalizers being skipped, typically resulting in memory
leaks.
Allow unlabelled function declarations outside of top level also in strict
mode, and treat them as in non-strict mode (i.e., hoist). Previously they
were rejected with SyntaxError in strict mode. The lenient behavior is
better because it accepts more real world code. Ideally function
declarations in strict mode would have block visibility, but that's
not yet implementable.
* Fix Proxy behavior for Array.isArray() and duk_is_array(), when
argument is a proxied Array.
* Fix JSON serialization of proxied Arrays.
* Fix Object.prototype.toString() behavior for proxied Arrays.
Direct comparison may have portability concerns because a constant may
have more precision than its counterpart. Even a direct cast before
a comparison may not work (e.g. Math.atan2() assert with gcc -m32 still
fails even when both sides have an explicit double cast). So use an
internal always-inline helper for float/double comparisons, which also
allows -Wfloat-equal warning to be suppressed in a single helper; add
a clang pragma option so that both gcc and clang suppress the warning.
Other changes:
* Add -Wfloat-equal warning back to the Makefile.
* Fix all internal float comparison call sites to use the helper.
* Add code policy check for probable floating point comparison
(not very important with -Wfloat-equal enabled).
* Add minimal CBOR config options.
* Add 'CBOR' built-in YAML metadata.
* Add a public C API for CBOR.
* Remove examples/cmdline support for extras/cbor, use built-in CBOR
instead.
* Makefile, dist/tools changes.
* Rewrite CBOR extra to use Duktape internal helpers, also some related
refactoring.
* Bump DUK_VERSION to 2.4.0.
* Release checklist updates.
* Releases file update.
* Finalize release notes.
* Remove experimental status from some API calls.
* Bump LICENSE.txt year range.
* Add new public symbols to API test.
* CBOR extra trivial compile warning fix.
* Compile warning fix when hex support disabled.
* Update test262 known issues.
* Update index page footprints.
* Improve options for thumb index page size build.
* Add missing "skip: true" metadata to a CBOR test.
* AUTHORS update.
* Rename hobject helper functions for property entry access.
* Add helpers for looking up _Formals and _Varmap without inheritance.
* Add duk_xget_owndataprop() + variants for internal property lookups
without inheritance or side effects.
* Date built-in fix for .setTime(), .setYear(), etc on a frozen Date
instance. These should be allowed because they operate on an internal
slot which is not under normal property access control. Previously
the operations were incorrectly rejected with a TypeError.
* Changes to internal property definition and lookup here and there.
Mostly the changes should be no-op because e.g. inheritance only
matters if the internal property might be missing (which is not
usually the case).
When array size is limited to 16 bits, some internal operations which
don't support abandoning the array could try to grow it beyond 16 bits
rather than abandoning the array part. This caused an assertion failure
and also potentially memory unsafe behavior.
Changes:
* When growing the property table, sanity check entry and array sizes.
If the new values won't fit in the duk_hobject structure (which may
happen with 16-bit fields), fail the grow attempt with an internal
error. This avoids field truncation and potentially memory unsafe
behavior as a result.
* Rework array part growth vs. abandon code to avoid the GH-2023 issue.
* Add support for keeping array part when possible into
Object.defineProperty().
* Add support for abandoning array part when using internal variants
for defining properties (such as in Array .map()).
* Executor compile warning fix.
* Debug logging trivia, downgrade a noisy log entry.
* Fix compile warning in duk_cmdline.c.
While setting up an environment for running the catch clause, the
bytecode executor could trigger a memory allocation and thus a GC
within "error handling" state.
Fix this by splitting catch clause handling into two parts:
- Part 1: unwind activation(s) and catcher(s) until the desired
catcher is found (this should be side effect free). Then write
the error value and longjmp type to the value stack (at idx_base),
and set a calling scope flag to indicate we need to run part 2 too.
Finally, deactivate the "catch active" flag of the catcher.
- Part 2: runs after we're out of error handling and inside a new
setjmp. Setup the environment needed to run the catch clause and
execute it with the bytecode executor. If an error (such as out
of memory) happens here, it propagates out (or into a finally
clause) because the catcher no longer has "catch active" set.
It's as if the throw came from inside the catch code.
(Part 2 is only needed if a catch clause needs an environment for
the catch variable; currently this is always the case.)
Also add a sanity check to mark-and-sweep object compaction: in case
mark-and-sweep was called inside error handling (which should ideally
never happen), refuse to compact objects which causes side effects.
Also rename debug format code %!C to %!X, and add %!C (duk_catcher *)
and %!A (duk_activation *) format codes so that activations and
catchers can be debug printed conveniently.
* Add DUK_USE_NATIVE_STACK_CHECK config option.
* Add internal duk_native_stack_check() helper which checks and
throws if DUK_USE_NATIVE_STACK_CHECK() indicates we're out of
stack space.
* Add initial call sites for duk_native_stack_check(). These are
in addition to existing recursion limit checks.
* Add stack check example to cmdline example and 'duk' build on
Linux. Disabled by default for now.
* Add DUK_BSWAP64() fill-in when 64-bit types available.
* Add DUK_BSWAP16(), DUK_BSWAP32(), and DUK_BSWAP64() GCC and Clang
built-ins. These are nice but unnecessary except at low optimizations
because the macros compile down to proper bswap instructions.
* Improve bswap self tests.