Side effects may include finalizers which operate on the object and may thus
invalidate the 'e_idx' we've looked up. Fix by operating with NORZ macros and
using a single refzero check.
Also provide explicit fast / slow (small) variants for fastint downgrade
check: it doesn't make sense to inline the very large check except in the
hot paths of executor and call handling. Elsewhere it's better to save
footprint and thus code cache.
Uses Kahan summation combined with normalization to avoid overflow and
minimize rounding errors. The algorithm is based on V8's implementation
(without actually sharing any code).
Also some small performance optimization, e.g. when getting enumerates keys
(Object.keys() et al) write the keys into a preallocated dense array which is
allocated directly to size.
These can be used whenever we're 100% certain that the value stack index
exists and the type matches expected type. When these are true, a
duk_hstring, duk_hbuffer, or duk_hobject pointer fetch can be inlined to
small code.
The non-standard (default) variant allows non-BMP codepoints which get
encoded as extended UTF-8. The standard variant should use ToUint16()
coercion so that e.g. 0x123456 emits 0x3456.
The previous (buggy) code used ToUint32() + CESU-8 encoding in that case
which caused two codepoints (CESU-8) to be emitted for a codepoint (this
would actually be correct behavior for String.fromCodePoint()).
Fix the bug by using ToUint16() coercion when the standard behavior is
enabled.
Make duk_error_raw() noreturn but return void, and then define duk_error()
as a macro: (duk_error_raw(...), 0). This avoids MSVC warnings for duk_error()
being noreturn but still returning a value in its prototype.
Same changes for other throwers.
All Reflect functions specified in ECMAScript 2016 are implemented, and
most share Duktape/C helpers with their ES5 twins from Object.
* Reflect.apply()
* Reflect.construct()
* Reflect.defineProperty()
* Reflect.deleteProperty()
* Reflect.get()
* Reflect.getOwnPropertyDescriptor()
* Reflect.getPrototypeOf()
* Reflect.has()
* Reflect.isExtensible()
* Reflect.ownKeys()
* Reflect.preventExtensions()
* Reflect.set()
* Reflect.setPrototypeOf()
Presence of the Reflect object is controlled by DUK_USE_REFLECT_BUILTIN
and enabled by default in the standard configuration.
note: Reflect.enumerate() was retroactively removed in ES7, so it will
not be implemented in Duktape.