diff -Nru duktape-2.3.0/AUTHORS.rst duktape-2.2.0/AUTHORS.rst --- duktape-2.3.0/AUTHORS.rst 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/AUTHORS.rst 2017-09-23 01:06:08.000000000 +0000 @@ -46,14 +46,6 @@ * Steven Don (https://github.com/shdon) * Simon Stone (https://github.com/sstone1) * \J. McC. (https://github.com/jmhmccr) -* Jakub Nowakowski (https://github.com/jimvonmoon) -* Tommy Nguyen (https://github.com/tn0502) -* Fabrice Fontaine (https://github.com/ffontaine) -* Christopher Hiller (https://github.com/boneskull) -* Gonzalo Diethelm (https://github.com/gonzus) -* Michal Kasperek (https://github.com/michalkas) -* Andrew Janke (https://github.com/apjanke) -* Steve Fan (https://github.com/stevefan1999) Other contributions =================== @@ -92,8 +84,6 @@ * https://github.com/chris-y * Laurent Zubiaur (https://github.com/lzubiaur) * Neil Kolban (https://github.com/nkolban) -* Wilhelm Wanecek (https://github.com/wanecek) -* Andrew Janke (https://github.com/apjanke) If you are accidentally missing from this list, send me an e-mail (``sami.vaarala@iki.fi``) and I'll fix the omission. diff -Nru duktape-2.3.0/config/architectures/architecture_arm32.h.in duktape-2.2.0/config/architectures/architecture_arm32.h.in --- duktape-2.3.0/config/architectures/architecture_arm32.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/architectures/architecture_arm32.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -1,3 +1,6 @@ #define DUK_USE_ARCH_STRING "arm32" /* Byte order varies, so rely on autodetect. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 4 +#endif #define DUK_USE_PACKED_TVAL diff -Nru duktape-2.3.0/config/architectures/architecture_arm64.h.in duktape-2.2.0/config/architectures/architecture_arm64.h.in --- duktape-2.3.0/config/architectures/architecture_arm64.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/architectures/architecture_arm64.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -1,3 +1,6 @@ #define DUK_USE_ARCH_STRING "arm64" /* Byte order varies, so rely on autodetect. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL diff -Nru duktape-2.3.0/config/architectures/architecture_emscripten.h.in duktape-2.2.0/config/architectures/architecture_emscripten.h.in --- duktape-2.3.0/config/architectures/architecture_emscripten.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/architectures/architecture_emscripten.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -2,4 +2,7 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL diff -Nru duktape-2.3.0/config/architectures/architecture_m68k.h.in duktape-2.2.0/config/architectures/architecture_m68k.h.in --- duktape-2.3.0/config/architectures/architecture_m68k.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/architectures/architecture_m68k.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -2,4 +2,7 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL diff -Nru duktape-2.3.0/config/architectures/architecture_mips32.h.in duktape-2.2.0/config/architectures/architecture_mips32.h.in --- duktape-2.3.0/config/architectures/architecture_mips32.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/architectures/architecture_mips32.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -1,3 +1,6 @@ #define DUK_USE_ARCH_STRING "mips32" /* MIPS byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL diff -Nru duktape-2.3.0/config/architectures/architecture_mips64.h.in duktape-2.2.0/config/architectures/architecture_mips64.h.in --- duktape-2.3.0/config/architectures/architecture_mips64.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/architectures/architecture_mips64.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -1,3 +1,6 @@ #define DUK_USE_ARCH_STRING "mips64" /* MIPS byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL diff -Nru duktape-2.3.0/config/architectures/architecture_powerpc32.h.in duktape-2.2.0/config/architectures/architecture_powerpc32.h.in --- duktape-2.3.0/config/architectures/architecture_powerpc32.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/architectures/architecture_powerpc32.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -2,4 +2,7 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL diff -Nru duktape-2.3.0/config/architectures/architecture_powerpc64.h.in duktape-2.2.0/config/architectures/architecture_powerpc64.h.in --- duktape-2.3.0/config/architectures/architecture_powerpc64.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/architectures/architecture_powerpc64.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -2,4 +2,7 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL diff -Nru duktape-2.3.0/config/architectures/architecture_sparc32.h.in duktape-2.2.0/config/architectures/architecture_sparc32.h.in --- duktape-2.3.0/config/architectures/architecture_sparc32.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/architectures/architecture_sparc32.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -1,3 +1,6 @@ #define DUK_USE_ARCH_STRING "sparc32" /* SPARC byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL diff -Nru duktape-2.3.0/config/architectures/architecture_sparc64.h.in duktape-2.2.0/config/architectures/architecture_sparc64.h.in --- duktape-2.3.0/config/architectures/architecture_sparc64.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/architectures/architecture_sparc64.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -1,3 +1,6 @@ #define DUK_USE_ARCH_STRING "sparc64" /* SPARC byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL diff -Nru duktape-2.3.0/config/architectures/architecture_superh.h.in duktape-2.2.0/config/architectures/architecture_superh.h.in --- duktape-2.3.0/config/architectures/architecture_superh.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/architectures/architecture_superh.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -1,3 +1,9 @@ #define DUK_USE_ARCH_STRING "sh" /* Byte order varies, rely on autodetection. */ +/* Based on 'make checkalign' there are no alignment requirements on + * Linux SH4, but align by 4 is probably a good basic default. + */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 4 +#endif #define DUK_USE_PACKED_TVAL diff -Nru duktape-2.3.0/config/architectures/architecture_x32.h.in duktape-2.2.0/config/architectures/architecture_x32.h.in --- duktape-2.3.0/config/architectures/architecture_x32.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/architectures/architecture_x32.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -2,4 +2,10 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif +/* XXX: This is technically not guaranteed because it's possible to configure + * an x86 to require aligned accesses with Alignment Check (AC) flag. + */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 1 +#endif #define DUK_USE_PACKED_TVAL diff -Nru duktape-2.3.0/config/architectures/architecture_x64.h.in duktape-2.2.0/config/architectures/architecture_x64.h.in --- duktape-2.3.0/config/architectures/architecture_x64.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/architectures/architecture_x64.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -2,4 +2,10 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif +/* XXX: This is technically not guaranteed because it's possible to configure + * an x86 to require aligned accesses with Alignment Check (AC) flag. + */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 1 +#endif #undef DUK_USE_PACKED_TVAL diff -Nru duktape-2.3.0/config/architectures/architecture_x86.h.in duktape-2.2.0/config/architectures/architecture_x86.h.in --- duktape-2.3.0/config/architectures/architecture_x86.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/architectures/architecture_x86.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -2,13 +2,10 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif - -#define DUK_USE_PACKED_TVAL - -/* FreeBSD, -m32, and clang prior to 5.0 has union aliasing issues which - * break duk_tval copying. Disable packed duk_tval automatically. +/* XXX: This is technically not guaranteed because it's possible to configure + * an x86 to require aligned accesses with Alignment Check (AC) flag. */ -#if defined(DUK_F_FREEBSD) && defined(DUK_F_X86) && \ - defined(__clang__) && defined(__clang_major__) && (__clang_major__ < 5) -#undef DUK_USE_PACKED_TVAL +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 1 #endif +#define DUK_USE_PACKED_TVAL diff -Nru duktape-2.3.0/config/config-options/DUK_USE_ALLOW_UNDEFINED_BEHAVIOR.yaml duktape-2.2.0/config/config-options/DUK_USE_ALLOW_UNDEFINED_BEHAVIOR.yaml --- duktape-2.3.0/config/config-options/DUK_USE_ALLOW_UNDEFINED_BEHAVIOR.yaml 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/config-options/DUK_USE_ALLOW_UNDEFINED_BEHAVIOR.yaml 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -define: DUK_USE_ALLOW_UNDEFINED_BEHAVIOR -introduced: 2.3.0 -default: false -tags: - - portability -description: > - Allow technically undefined behavior such as out-of-range double-to-integer - casts, floating point division by zero, etc. which are likely to work on the - majority of platforms. Default is to avoid such behaviors, at the cost of - some footprint and performance. diff -Nru duktape-2.3.0/config/config-options/DUK_USE_BASE64_SUPPORT.yaml duktape-2.2.0/config/config-options/DUK_USE_BASE64_SUPPORT.yaml --- duktape-2.3.0/config/config-options/DUK_USE_BASE64_SUPPORT.yaml 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/config-options/DUK_USE_BASE64_SUPPORT.yaml 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -define: DUK_USE_BASE64_SUPPORT -introduced: 2.3.0 -default: true -tags: - - codec -description: > - Enable base64 encoding/decoding support. diff -Nru duktape-2.3.0/config/config-options/DUK_USE_HEX_SUPPORT.yaml duktape-2.2.0/config/config-options/DUK_USE_HEX_SUPPORT.yaml --- duktape-2.3.0/config/config-options/DUK_USE_HEX_SUPPORT.yaml 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/config-options/DUK_USE_HEX_SUPPORT.yaml 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -define: DUK_USE_HEX_SUPPORT -introduced: 2.3.0 -default: true -tags: - - codec -description: > - Enable hex encoding/decoding support. diff -Nru duktape-2.3.0/config/config-options/DUK_USE_LITCACHE_SIZE.yaml duktape-2.2.0/config/config-options/DUK_USE_LITCACHE_SIZE.yaml --- duktape-2.3.0/config/config-options/DUK_USE_LITCACHE_SIZE.yaml 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/config-options/DUK_USE_LITCACHE_SIZE.yaml 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -define: DUK_USE_LITCACHE_SIZE -introduced: 2.3.0 -default: 256 -tags: - - performance - - lowmemory -description: > - Size of the literal cache, which maps C literal memory addresses into - pinned duk_hstring heap object addresses. The cache is used when - application code calls one of the duk_xxx_literal() API call variants, - such as duk_push_literal() or duk_get_prop_literal(), to speed up the - string intern check for the literal. In successful cases this caching - makes using duk_xxx_literal() almost as fast as using borrowed heap - pointers with duk_xxx_heapptr(). - - When this option is defined, duk_hstrings related to literals encountered - in duk_xxx_literal() API calls are automatically pinned between - mark-and-sweep rounds. This accomplishes two things. First, it avoids the - need for cache invalidation for the literal cache in normal operation between - mark-and-sweep rounds. Second, it reduces string table traffic (i.e. freeing - and reallocating) for literals which are likely to occur again and again. - However, the downside is that some strings that may occur only temporarily - will remain pinned until the next mark-and-sweep round. If this matter, you - can avoid it by simply using e.g. duk_xxx_string() when dealing with such - strings. - - The literal cache size must be a power of two (2^N). diff -Nru duktape-2.3.0/config/config-options/DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER.yaml duktape-2.2.0/config/config-options/DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER.yaml --- duktape-2.3.0/config/config-options/DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER.yaml 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/config-options/DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER.yaml 2017-09-23 01:06:08.000000000 +0000 @@ -1,11 +1,14 @@ define: DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER introduced: 1.0.0 -removed: 2.3.0 default: true tags: - ecmascript - compliance description: > - In ES5.1 trailing gaps of an argument array don't count towards the result - length. This is in essence a specification "bug" which was fixed in ES2015. - This option was removed in 2.3.0, and the remaining behavior matches ES2015. + For better compatibility with existing code, enable non-standard + Array.prototype.concat() behavior for trailing non-existent elements of + the concat result, see + https://github.com/svaarala/duktape/blob/master/tests/ecmascript/test-bi-array-proto-concat-nonstd-trailing.js. + + If this option is disabled, concat() will behave in a strictly conforming + fashion, ignoring non-existent trailing elements in the result length. diff -Nru duktape-2.3.0/config/config-options/DUK_USE_NONSTD_ARRAY_MAP_TRAILER.yaml duktape-2.2.0/config/config-options/DUK_USE_NONSTD_ARRAY_MAP_TRAILER.yaml --- duktape-2.3.0/config/config-options/DUK_USE_NONSTD_ARRAY_MAP_TRAILER.yaml 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/config-options/DUK_USE_NONSTD_ARRAY_MAP_TRAILER.yaml 2017-09-23 01:06:08.000000000 +0000 @@ -1,13 +1,14 @@ define: DUK_USE_NONSTD_ARRAY_MAP_TRAILER introduced: 1.0.0 -removed: 2.3.0 default: true tags: - ecmascript - compliance description: > - This option was removed in 2.3.0 as it was unnecessary and in essence fixing - a Duktape bug. ES5.0/ES5.1 already behave like ES2015 in that trailing gaps - in the input don't affect the result length. The result array is created - with a length based on the input array in Step 6 of ES5.1 Section 15.4.4.19 - and subsequent index writes don't affect the length. + For better compatibility with existing code, enable non-standard + Array.prototype.map() behavior for trailing non-existent elements of + the map result, see + https://github.com/svaarala/duktape/blob/master/tests/ecmascript/test-bi-array-proto-map-nonstd-trailing.js. + + If this option is disabled, map() will behave in a strictly conforming + fashion, ignoring non-existent trailing elements in the result length. diff -Nru duktape-2.3.0/config/examples/compliance.yaml duktape-2.2.0/config/examples/compliance.yaml --- duktape-2.3.0/config/examples/compliance.yaml 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/examples/compliance.yaml 2017-09-23 01:06:08.000000000 +0000 @@ -1,5 +1,7 @@ # Enable compliant behavior, defaults favor "real world" compatibility. +DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER: false +DUK_USE_NONSTD_ARRAY_MAP_TRAILER: false DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT: false DUK_USE_NONSTD_FUNC_CALLER_PROPERTY: false DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY: false diff -Nru duktape-2.3.0/config/examples/low_memory.yaml duktape-2.2.0/config/examples/low_memory.yaml --- duktape-2.3.0/config/examples/low_memory.yaml 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/examples/low_memory.yaml 2017-09-23 01:06:08.000000000 +0000 @@ -11,16 +11,6 @@ # - Does not enable ROM string/object support by default, enable manually # -# Consider switching alignment to align-by-1 or align-by-4 for more compact -# memory layout if the architecture supports it. -#DUK_USE_ALIGN_BY: 1 - -# With the vast majority of compilers some of the 'undefined behavior' -# assumptions are fine, and produce smaller and faster code, so enable -# by default for lowmem targets. You may need to disable this for some -# compilers. -DUK_USE_ALLOW_UNDEFINED_BEHAVIOR: true - DUK_USE_PREFER_SIZE: true DUK_USE_EXEC_PREFER_SIZE: true DUK_USE_FAST_REFCOUNT_DEFAULT: false @@ -71,9 +61,6 @@ DUK_USE_STRTAB_RESIZE_CHECK_MASK: 255 # -""- #DUK_USE_STRTAB_PTRCOMP: true # sometimes useful with pointer compression -# Disable literal pinning and litcache. -DUK_USE_LITCACHE_SIZE: false - DUK_USE_HSTRING_ARRIDX: false DUK_USE_HSTRING_LAZY_CLEN: false # non-lazy charlen is smaller @@ -139,8 +126,6 @@ DUK_USE_ES7: false DUK_USE_ES8: false DUK_USE_ES9: false -DUK_USE_BASE64_SUPPORT: false -DUK_USE_HEX_SUPPORT: false DUK_USE_COROUTINE_SUPPORT: false DUK_USE_SOURCE_NONBMP: false # <300 bytes footprint DUK_USE_ES6_PROXY: false # roughly 2kB footprint diff -Nru duktape-2.3.0/config/examples/performance_sensitive.yaml duktape-2.2.0/config/examples/performance_sensitive.yaml --- duktape-2.3.0/config/examples/performance_sensitive.yaml 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/examples/performance_sensitive.yaml 2017-09-23 01:06:08.000000000 +0000 @@ -3,18 +3,11 @@ # You should choose the fastest setjmp/longjmp for your platform. -# With the vast majority of compilers some of the 'undefined behavior' -# assumptions are fine, and produce smaller and faster code, so enable -# by default for performance oriented targets. You may need to disable -# this for some compilers. -DUK_USE_ALLOW_UNDEFINED_BEHAVIOR: true - DUK_USE_PREFER_SIZE: false DUK_USE_PACKED_TVAL: false # packed duk_tval slower in most cases DUK_USE_FASTINT: true DUK_USE_VALSTACK_UNSAFE: true DUK_USE_FAST_REFCOUNT_DEFAULT: true - DUK_USE_JSON_STRINGIFY_FASTPATH: true # not fully portable right now DUK_USE_JSON_QUOTESTRING_FASTPATH: true DUK_USE_JSON_DECSTRING_FASTPATH: true @@ -26,13 +19,8 @@ DUK_USE_ARRAY_PROP_FASTPATH: true DUK_USE_ARRAY_FASTPATH: true DUK_USE_INTERRUPT_COUNTER: false - DUK_USE_DEBUGGER_SUPPORT: false - DUK_USE_STRHASH_DENSE: false DUK_USE_STRHASH_SKIP_SHIFT: 5 # may be able to reduce #DUK_USE_EXEC_FUN_LOCAL: false # test both values, marginal benefit - -DUK_USE_LITCACHE_SIZE: 1024 - DUK_USE_REGEXP_CANON_WORKAROUND: true # high footprint impact (128kB), enabled until a better solution diff -Nru duktape-2.3.0/config/header-snippets/alignment_fillin.h.in duktape-2.2.0/config/header-snippets/alignment_fillin.h.in --- duktape-2.3.0/config/header-snippets/alignment_fillin.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/header-snippets/alignment_fillin.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -3,13 +3,10 @@ * * Assume unaligned accesses are not supported unless specifically allowed * in the target platform. Some platforms may support unaligned accesses - * but alignment to 4 or 8 may still be desirable. Note that unaligned - * accesses (and even pointers) relative to natural alignment (regardless - * of target alignment) are technically undefined behavior and thus - * compiler/architecture specific. + * but alignment to 4 or 8 may still be desirable. */ -/* If not forced, use safe default for alignment. */ +/* If not provided, use safe default for alignment. */ #if !defined(DUK_USE_ALIGN_BY) #define DUK_USE_ALIGN_BY 8 #endif diff -Nru duktape-2.3.0/config/header-snippets/compiler_fillins.h.in duktape-2.2.0/config/header-snippets/compiler_fillins.h.in --- duktape-2.3.0/config/header-snippets/compiler_fillins.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/header-snippets/compiler_fillins.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -34,7 +34,6 @@ */ #define DUK_CAUSE_SEGFAULT() do { *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; } while (0) #endif - #if !defined(DUK_UNREF) /* Macro for suppressing warnings for potentially unreferenced variables. * The variables can be actually unreferenced or unreferenced in some @@ -44,24 +43,9 @@ */ #define DUK_UNREF(x) do { (void) (x); } while (0) #endif - -/* Fillin for DUK_NORETURN; DUK_WO_NORETURN() is used to insert dummy - * dummy statements after noreturn calls to silence harmless compiler - * warnings, e.g.: - * - * DUK_ERROR_TYPE(thr, "aiee"); - * DUK_WO_NORETURN(return 0;); - * - * Statements inside DUK_WO_NORETURN() must NEVER be actually reachable, - * and they're only included to satisfy the compiler. - */ -#if defined(DUK_NORETURN) -#define DUK_WO_NORETURN(stmt) do { } while (0) -#else +#if !defined(DUK_NORETURN) #define DUK_NORETURN(decl) decl -#define DUK_WO_NORETURN(stmt) do { stmt } while (0) #endif - #if !defined(DUK_UNREACHABLE) /* Don't know how to declare unreachable point, so don't do it; this * may cause some spurious compilation warnings (e.g. "variable used @@ -69,7 +53,6 @@ */ #define DUK_UNREACHABLE() do { } while (0) #endif - #if !defined(DUK_LOSE_CONST) /* Convert any input pointer into a "void *", losing a const qualifier. * This is not fully portable because casting through duk_uintptr_t may diff -Nru duktape-2.3.0/config/header-snippets/packed_tval_fillin.h.in duktape-2.2.0/config/header-snippets/packed_tval_fillin.h.in --- duktape-2.3.0/config/header-snippets/packed_tval_fillin.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/header-snippets/packed_tval_fillin.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -35,6 +35,6 @@ #if defined(DUK_F_PACKED_TVAL_POSSIBLE) #define DUK_USE_PACKED_TVAL #endif -#undef DUK_F_PACKED_TVAL_POSSIBLE +#undef DUK_F_PACKED_TVAL_POSSIBLE #endif /* DUK_F_PACKED_TVAL_PROVIDED */ diff -Nru duktape-2.3.0/config/header-snippets/platform_conditionalincludes.h.in duktape-2.2.0/config/header-snippets/platform_conditionalincludes.h.in --- duktape-2.3.0/config/header-snippets/platform_conditionalincludes.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/header-snippets/platform_conditionalincludes.h.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -#if defined(DUK_F_CPP) && defined(DUK_USE_CPP_EXCEPTIONS) -#include /* std::exception */ -#include /* std::runtime_error */ -#endif diff -Nru duktape-2.3.0/config/header-snippets/platform_sharedincludes.h.in duktape-2.2.0/config/header-snippets/platform_sharedincludes.h.in --- duktape-2.3.0/config/header-snippets/platform_sharedincludes.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/header-snippets/platform_sharedincludes.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -21,4 +21,6 @@ #include #endif -/* is only included if needed, based on DUK_USE_xxx flags. */ +#if defined(DUK_F_CPP) +#include /* std::exception */ +#endif diff -Nru duktape-2.3.0/config/header-snippets/types2.h.in duktape-2.2.0/config/header-snippets/types2.h.in --- duktape-2.3.0/config/header-snippets/types2.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/header-snippets/types2.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -55,8 +55,8 @@ /* Boolean values are represented with the platform 'unsigned int'. */ typedef duk_small_uint_t duk_bool_t; -#define DUK_BOOL_MIN DUK_SMALL_UINT_MIN -#define DUK_BOOL_MAX DUK_SMALL_UINT_MAX +#define DUK_BOOL_MIN DUK_SMALL_INT_MIN +#define DUK_BOOL_MAX DUK_SMALL_INT_MAX /* Index values must have at least 32-bit signed range. */ typedef duk_int_t duk_idx_t; diff -Nru duktape-2.3.0/config/other-defines/platform_functions.yaml duktape-2.2.0/config/other-defines/platform_functions.yaml --- duktape-2.3.0/config/other-defines/platform_functions.yaml 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/other-defines/platform_functions.yaml 2017-09-23 01:06:08.000000000 +0000 @@ -5,6 +5,8 @@ - define: DUK_ISNAN - define: DUK_ISINF - define: DUK_FABS +- define: DUK_FMIN +- define: DUK_FMAX - define: DUK_FLOOR - define: DUK_CEIL - define: DUK_FMOD diff -Nru duktape-2.3.0/config/tags.yaml duktape-2.2.0/config/tags.yaml --- duktape-2.3.0/config/tags.yaml 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/config/tags.yaml 2017-09-23 01:06:08.000000000 +0000 @@ -4,19 +4,19 @@ # ecmascript: - title: ECMAScript Edition 5 (ES5) options + title: Ecmascript Edition 5 (ES5) options ecmascript2015: - title: ECMAScript 2015 (ES6) options + title: Ecmascript 2015 (ES6) options ecmascript2016: - title: ECMAScript 2016 (ES7) options + title: Ecmascript 2016 (ES7) options ecmascript2017: - title: ECMAScript 2017 (ES8) options + title: Ecmascript 2017 (ES8) options ecmascript2018: - title: ECMAScript 2018 (ES9) options + title: Ecmascript 2018 (ES9) options duktape: title: Duktape specific options @@ -89,9 +89,6 @@ Development time options to stress test corner case handling by e.g. causing a garbage collection on every allocation. -codec: - title: Codecs - encoding-api: title: WHATWG Encoding API diff -Nru duktape-2.3.0/debian/changelog duktape-2.2.0/debian/changelog --- duktape-2.3.0/debian/changelog 2018-08-14 20:12:45.000000000 +0000 +++ duktape-2.2.0/debian/changelog 2018-09-24 18:52:10.000000000 +0000 @@ -1,19 +1,8 @@ -duktape (2.3.0-1) unstable; urgency=medium +duktape (2.2.0-3~ppa1~xenial1) xenial; urgency=medium - * New upstream release - * add symbols file - * add debug symbols for dbg package + * Backport to xenial. - -- Thorsten Alteholz Tue, 14 Aug 2018 22:12:45 +0200 - -duktape (2.2.1-1) unstable; urgency=medium - - * New upstream release - * debian/control: set standard to 4.1.5 (no changes) - * debian/control: use dh11 - * debian/control: use salsa URLs - - -- Thorsten Alteholz Sat, 07 Jul 2018 10:52:52 +0200 + -- Stephen Czetty Mon, 24 Sep 2018 13:52:10 -0500 duktape (2.2.0-3) unstable; urgency=medium diff -Nru duktape-2.3.0/debian/compat duktape-2.2.0/debian/compat --- duktape-2.3.0/debian/compat 2018-07-07 08:52:52.000000000 +0000 +++ duktape-2.2.0/debian/compat 2018-09-24 18:52:10.000000000 +0000 @@ -1 +1 @@ -11 +9 diff -Nru duktape-2.3.0/debian/control duktape-2.2.0/debian/control --- duktape-2.3.0/debian/control 2018-08-14 20:12:45.000000000 +0000 +++ duktape-2.2.0/debian/control 2018-09-24 18:52:10.000000000 +0000 @@ -3,12 +3,12 @@ Priority: optional Maintainer: Debian IoT Maintainers Uploaders: Thorsten Alteholz -Build-Depends: debhelper (>=11) +Build-Depends: debhelper (>=9) , dh-exec -Standards-Version: 4.1.5 +Standards-Version: 4.1.1 Homepage: http://duktape.org -Vcs-Browser: https://salsa.debian.org/debian-iot-team/duktape -Vcs-Git: https://salsa.debian.org/debian-iot-team/duktape.git +Vcs-Browser: https://anonscm.debian.org/cgit/debian-iot/duktape.git +Vcs-Git: https://anonscm.debian.org/git/debian-iot/duktape.git Package: duktape Architecture: any @@ -45,7 +45,7 @@ Architecture: any Section: libdevel Depends: ${misc:Depends} - , libduktape203 (= ${binary:Version}) + , libduktape202 (= ${binary:Version}) Description: embeddable Javascript engine, development files Duktape is an embeddable Javascript engine, with a focus on portability and compact footprint. @@ -56,10 +56,9 @@ . This package contains all source files to use in own projects. -Package: libduktape203 +Package: libduktape202 Architecture: any Multi-Arch: same -Section: libs Depends: ${shlibs:Depends} , ${misc:Depends} Description: embeddable Javascript engine, library @@ -71,3 +70,17 @@ functions from C code and vice versa. . This package contains the shared library. + + + + + + + + + + + + + + diff -Nru duktape-2.3.0/debian/libduktape202.install duktape-2.2.0/debian/libduktape202.install --- duktape-2.3.0/debian/libduktape202.install 1970-01-01 00:00:00.000000000 +0000 +++ duktape-2.2.0/debian/libduktape202.install 2017-11-24 17:23:21.000000000 +0000 @@ -0,0 +1,2 @@ +#! /usr/bin/dh-exec +tmp-build/lib/libduktape.so.* usr/lib/${DEB_HOST_MULTIARCH}/ diff -Nru duktape-2.3.0/debian/libduktape203.install duktape-2.2.0/debian/libduktape203.install --- duktape-2.3.0/debian/libduktape203.install 2017-11-24 17:23:21.000000000 +0000 +++ duktape-2.2.0/debian/libduktape203.install 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -#! /usr/bin/dh-exec -tmp-build/lib/libduktape.so.* usr/lib/${DEB_HOST_MULTIARCH}/ diff -Nru duktape-2.3.0/debian/libduktape203.symbols duktape-2.2.0/debian/libduktape203.symbols --- duktape-2.3.0/debian/libduktape203.symbols 2018-08-14 20:12:45.000000000 +0000 +++ duktape-2.2.0/debian/libduktape203.symbols 1970-01-01 00:00:00.000000000 +0000 @@ -1,278 +0,0 @@ -# SymbolsHelper-Confirmed: 2.0.3 amd64 -libduktape.so.203 libduktape203 #MINVER# - duk_alloc@Base 2.0.3 - duk_alloc_raw@Base 2.0.3 - duk_base64_decode@Base 2.0.3 - duk_base64_encode@Base 2.0.3 - duk_buffer_to_string@Base 2.0.3 - duk_call@Base 2.0.3 - duk_call_method@Base 2.0.3 - duk_call_prop@Base 2.0.3 - duk_char_code_at@Base 2.0.3 - duk_check_stack@Base 2.0.3 - duk_check_stack_top@Base 2.0.3 - duk_check_type@Base 2.0.3 - duk_check_type_mask@Base 2.0.3 - duk_compact@Base 2.0.3 - duk_compile_raw@Base 2.0.3 - duk_components_to_time@Base 2.0.3 - duk_concat@Base 2.0.3 - duk_config_buffer@Base 2.0.3 - duk_copy@Base 2.0.3 - duk_create_heap@Base 2.0.3 - duk_debugger_attach@Base 2.0.3 - duk_debugger_cooperate@Base 2.0.3 - duk_debugger_detach@Base 2.0.3 - duk_debugger_notify@Base 2.0.3 - duk_debugger_pause@Base 2.0.3 - duk_decode_string@Base 2.0.3 - duk_def_prop@Base 2.0.3 - duk_del_prop@Base 2.0.3 - duk_del_prop_heapptr@Base 2.0.3 - duk_del_prop_index@Base 2.0.3 - duk_del_prop_literal_raw@Base 2.0.3 - duk_del_prop_lstring@Base 2.0.3 - duk_del_prop_string@Base 2.0.3 - duk_destroy_heap@Base 2.0.3 - duk_dump_function@Base 2.0.3 - duk_dup@Base 2.0.3 - duk_dup_top@Base 2.0.3 - duk_enum@Base 2.0.3 - duk_equals@Base 2.0.3 - duk_error_raw@Base 2.0.3 - duk_error_va_raw@Base 2.0.3 - duk_eval_raw@Base 2.0.3 - duk_fatal_raw@Base 2.0.3 - duk_free@Base 2.0.3 - duk_free_raw@Base 2.0.3 - duk_freeze@Base 2.0.3 - duk_gc@Base 2.0.3 - duk_get_boolean@Base 2.0.3 - duk_get_boolean_default@Base 2.0.3 - duk_get_buffer@Base 2.0.3 - duk_get_buffer_data@Base 2.0.3 - duk_get_buffer_data_default@Base 2.0.3 - duk_get_buffer_default@Base 2.0.3 - duk_get_c_function@Base 2.0.3 - duk_get_c_function_default@Base 2.0.3 - duk_get_context@Base 2.0.3 - duk_get_context_default@Base 2.0.3 - duk_get_current_magic@Base 2.0.3 - duk_get_error_code@Base 2.0.3 - duk_get_finalizer@Base 2.0.3 - duk_get_global_heapptr@Base 2.0.3 - duk_get_global_literal_raw@Base 2.0.3 - duk_get_global_lstring@Base 2.0.3 - duk_get_global_string@Base 2.0.3 - duk_get_heapptr@Base 2.0.3 - duk_get_heapptr_default@Base 2.0.3 - duk_get_int@Base 2.0.3 - duk_get_int_default@Base 2.0.3 - duk_get_length@Base 2.0.3 - duk_get_lstring@Base 2.0.3 - duk_get_lstring_default@Base 2.0.3 - duk_get_magic@Base 2.0.3 - duk_get_memory_functions@Base 2.0.3 - duk_get_now@Base 2.0.3 - duk_get_number@Base 2.0.3 - duk_get_number_default@Base 2.0.3 - duk_get_pointer@Base 2.0.3 - duk_get_pointer_default@Base 2.0.3 - duk_get_prop@Base 2.0.3 - duk_get_prop_desc@Base 2.0.3 - duk_get_prop_heapptr@Base 2.0.3 - duk_get_prop_index@Base 2.0.3 - duk_get_prop_literal_raw@Base 2.0.3 - duk_get_prop_lstring@Base 2.0.3 - duk_get_prop_string@Base 2.0.3 - duk_get_prototype@Base 2.0.3 - duk_get_string@Base 2.0.3 - duk_get_string_default@Base 2.0.3 - duk_get_top@Base 2.0.3 - duk_get_top_index@Base 2.0.3 - duk_get_type@Base 2.0.3 - duk_get_type_mask@Base 2.0.3 - duk_get_uint@Base 2.0.3 - duk_get_uint_default@Base 2.0.3 - duk_has_prop@Base 2.0.3 - duk_has_prop_heapptr@Base 2.0.3 - duk_has_prop_index@Base 2.0.3 - duk_has_prop_literal_raw@Base 2.0.3 - duk_has_prop_lstring@Base 2.0.3 - duk_has_prop_string@Base 2.0.3 - duk_hex_decode@Base 2.0.3 - duk_hex_encode@Base 2.0.3 - duk_insert@Base 2.0.3 - duk_inspect_callstack_entry@Base 2.0.3 - duk_inspect_value@Base 2.0.3 - duk_instanceof@Base 2.0.3 - duk_is_array@Base 2.0.3 - duk_is_boolean@Base 2.0.3 - duk_is_bound_function@Base 2.0.3 - duk_is_buffer@Base 2.0.3 - duk_is_buffer_data@Base 2.0.3 - duk_is_c_function@Base 2.0.3 - duk_is_constructable@Base 2.0.3 - duk_is_constructor_call@Base 2.0.3 - duk_is_dynamic_buffer@Base 2.0.3 - duk_is_ecmascript_function@Base 2.0.3 - duk_is_external_buffer@Base 2.0.3 - duk_is_fixed_buffer@Base 2.0.3 - duk_is_function@Base 2.0.3 - duk_is_lightfunc@Base 2.0.3 - duk_is_nan@Base 2.0.3 - duk_is_null@Base 2.0.3 - duk_is_number@Base 2.0.3 - duk_is_object@Base 2.0.3 - duk_is_pointer@Base 2.0.3 - duk_is_strict_call@Base 2.0.3 - duk_is_string@Base 2.0.3 - duk_is_symbol@Base 2.0.3 - duk_is_thread@Base 2.0.3 - duk_is_undefined@Base 2.0.3 - duk_is_valid_index@Base 2.0.3 - duk_join@Base 2.0.3 - duk_json_decode@Base 2.0.3 - duk_json_encode@Base 2.0.3 - duk_load_function@Base 2.0.3 - duk_map_string@Base 2.0.3 - duk_new@Base 2.0.3 - duk_next@Base 2.0.3 - duk_normalize_index@Base 2.0.3 - duk_opt_boolean@Base 2.0.3 - duk_opt_buffer@Base 2.0.3 - duk_opt_buffer_data@Base 2.0.3 - duk_opt_c_function@Base 2.0.3 - duk_opt_context@Base 2.0.3 - duk_opt_heapptr@Base 2.0.3 - duk_opt_int@Base 2.0.3 - duk_opt_lstring@Base 2.0.3 - duk_opt_number@Base 2.0.3 - duk_opt_pointer@Base 2.0.3 - duk_opt_string@Base 2.0.3 - duk_opt_uint@Base 2.0.3 - duk_pcall@Base 2.0.3 - duk_pcall_method@Base 2.0.3 - duk_pcall_prop@Base 2.0.3 - duk_pnew@Base 2.0.3 - duk_pop@Base 2.0.3 - duk_pop_2@Base 2.0.3 - duk_pop_3@Base 2.0.3 - duk_pop_n@Base 2.0.3 - duk_push_array@Base 2.0.3 - duk_push_bare_object@Base 2.0.3 - duk_push_boolean@Base 2.0.3 - duk_push_buffer_object@Base 2.0.3 - duk_push_buffer_raw@Base 2.0.3 - duk_push_c_function@Base 2.0.3 - duk_push_c_lightfunc@Base 2.0.3 - duk_push_context_dump@Base 2.0.3 - duk_push_current_function@Base 2.0.3 - duk_push_current_thread@Base 2.0.3 - duk_push_error_object_raw@Base 2.0.3 - duk_push_error_object_va_raw@Base 2.0.3 - duk_push_false@Base 2.0.3 - duk_push_global_object@Base 2.0.3 - duk_push_global_stash@Base 2.0.3 - duk_push_heap_stash@Base 2.0.3 - duk_push_heapptr@Base 2.0.3 - duk_push_int@Base 2.0.3 - duk_push_literal_raw@Base 2.0.3 - duk_push_lstring@Base 2.0.3 - duk_push_nan@Base 2.0.3 - duk_push_new_target@Base 2.0.3 - duk_push_null@Base 2.0.3 - duk_push_number@Base 2.0.3 - duk_push_object@Base 2.0.3 - duk_push_pointer@Base 2.0.3 - duk_push_proxy@Base 2.0.3 - duk_push_sprintf@Base 2.0.3 - duk_push_string@Base 2.0.3 - duk_push_this@Base 2.0.3 - duk_push_thread_raw@Base 2.0.3 - duk_push_thread_stash@Base 2.0.3 - duk_push_true@Base 2.0.3 - duk_push_uint@Base 2.0.3 - duk_push_undefined@Base 2.0.3 - duk_push_vsprintf@Base 2.0.3 - duk_put_function_list@Base 2.0.3 - duk_put_global_heapptr@Base 2.0.3 - duk_put_global_literal_raw@Base 2.0.3 - duk_put_global_lstring@Base 2.0.3 - duk_put_global_string@Base 2.0.3 - duk_put_number_list@Base 2.0.3 - duk_put_prop@Base 2.0.3 - duk_put_prop_heapptr@Base 2.0.3 - duk_put_prop_index@Base 2.0.3 - duk_put_prop_literal_raw@Base 2.0.3 - duk_put_prop_lstring@Base 2.0.3 - duk_put_prop_string@Base 2.0.3 - duk_random@Base 2.0.3 - duk_realloc@Base 2.0.3 - duk_realloc_raw@Base 2.0.3 - duk_remove@Base 2.0.3 - duk_replace@Base 2.0.3 - duk_require_boolean@Base 2.0.3 - duk_require_buffer@Base 2.0.3 - duk_require_buffer_data@Base 2.0.3 - duk_require_c_function@Base 2.0.3 - duk_require_context@Base 2.0.3 - duk_require_function@Base 2.0.3 - duk_require_heapptr@Base 2.0.3 - duk_require_int@Base 2.0.3 - duk_require_lstring@Base 2.0.3 - duk_require_normalize_index@Base 2.0.3 - duk_require_null@Base 2.0.3 - duk_require_number@Base 2.0.3 - duk_require_object@Base 2.0.3 - duk_require_pointer@Base 2.0.3 - duk_require_stack@Base 2.0.3 - duk_require_stack_top@Base 2.0.3 - duk_require_string@Base 2.0.3 - duk_require_top_index@Base 2.0.3 - duk_require_uint@Base 2.0.3 - duk_require_undefined@Base 2.0.3 - duk_require_valid_index@Base 2.0.3 - duk_resize_buffer@Base 2.0.3 - duk_resume@Base 2.0.3 - duk_safe_call@Base 2.0.3 - duk_safe_to_lstring@Base 2.0.3 - duk_samevalue@Base 2.0.3 - duk_seal@Base 2.0.3 - duk_set_finalizer@Base 2.0.3 - duk_set_global_object@Base 2.0.3 - duk_set_length@Base 2.0.3 - duk_set_magic@Base 2.0.3 - duk_set_prototype@Base 2.0.3 - duk_set_top@Base 2.0.3 - duk_steal_buffer@Base 2.0.3 - duk_strict_equals@Base 2.0.3 - duk_substring@Base 2.0.3 - duk_suspend@Base 2.0.3 - duk_swap@Base 2.0.3 - duk_swap_top@Base 2.0.3 - duk_throw_raw@Base 2.0.3 - duk_time_to_components@Base 2.0.3 - duk_to_boolean@Base 2.0.3 - duk_to_buffer_raw@Base 2.0.3 - duk_to_int32@Base 2.0.3 - duk_to_int@Base 2.0.3 - duk_to_lstring@Base 2.0.3 - duk_to_null@Base 2.0.3 - duk_to_number@Base 2.0.3 - duk_to_object@Base 2.0.3 - duk_to_pointer@Base 2.0.3 - duk_to_primitive@Base 2.0.3 - duk_to_string@Base 2.0.3 - duk_to_uint16@Base 2.0.3 - duk_to_uint32@Base 2.0.3 - duk_to_uint@Base 2.0.3 - duk_to_undefined@Base 2.0.3 - duk_trim@Base 2.0.3 - duk_unicode_caseconv_lc@Base 2.0.3 - duk_unicode_caseconv_uc@Base 2.0.3 - duk_unicode_idp_m_ids_noa@Base 2.0.3 - duk_unicode_ids_m_let_noa@Base 2.0.3 - duk_unicode_ids_noa@Base 2.0.3 - duk_unicode_re_canon_bitmap@Base 2.0.3 - duk_xcopymove_raw@Base 2.0.3 diff -Nru duktape-2.3.0/debian/patches/debug-symbols.patch duktape-2.2.0/debian/patches/debug-symbols.patch --- duktape-2.3.0/debian/patches/debug-symbols.patch 2018-08-14 20:12:45.000000000 +0000 +++ duktape-2.2.0/debian/patches/debug-symbols.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -Description: add debug symbols here for dbg package -Author: Thorsten Alteholz -Index: duktape-2.3.0/Makefile.sharedlibrary -=================================================================== ---- duktape-2.3.0.orig/Makefile.sharedlibrary 2018-08-14 09:43:56.183649324 +0200 -+++ duktape-2.3.0/Makefile.sharedlibrary 2018-08-14 12:38:05.611336078 +0200 -@@ -62,7 +62,7 @@ - # to $INSTALL_PREFIX/include on installation. - - libduktape.$(SO_SONAME_SUFFIX): -- $(CC) -shared -fPIC -Wall -Wextra -Os -Wl,$(LD_SONAME_ARG),libduktape.$(SO_SONAME_SUFFIX) \ -+ $(CC) -shared -fPIC -g -Wall -Wextra -Os -Wl,$(LD_SONAME_ARG),libduktape.$(SO_SONAME_SUFFIX) \ - -D_FORTIFY_SOURCE=2 -z relro -z now \ - -o $@ $(DUKTAPE_SRCDIR)/duktape.c - diff -Nru duktape-2.3.0/debian/patches/hardening.patch duktape-2.2.0/debian/patches/hardening.patch --- duktape-2.3.0/debian/patches/hardening.patch 2018-08-14 20:12:45.000000000 +0000 +++ duktape-2.2.0/debian/patches/hardening.patch 2017-10-25 17:39:13.000000000 +0000 @@ -1,72 +1,71 @@ Author: Thorsten Alteholz Description: add hardening flags -Index: duktape-2.3.0/Makefile.cmdline +Index: duktape-2.2.0/Makefile.cmdline =================================================================== ---- duktape-2.3.0.orig/Makefile.cmdline 2018-08-14 09:12:57.551705041 +0200 -+++ duktape-2.3.0/Makefile.cmdline 2018-08-14 09:23:45.979685603 +0200 +--- duktape-2.2.0.orig/Makefile.cmdline 2017-10-25 11:44:43.595165939 +0200 ++++ duktape-2.2.0/Makefile.cmdline 2017-10-25 11:44:43.591165801 +0200 @@ -11,7 +11,9 @@ - CC = gcc - CCOPTS = -Os -pedantic -std=c99 -Wall -fstrict-aliasing -fomit-frame-pointer + CC = gcc + CCOPTS = -Os -pedantic -std=c99 -Wall -fstrict-aliasing -fomit-frame-pointer CCOPTS += -I./examples/cmdline -I./src # duktape.h and duk_config.h must be in include path +CCOPTS += -fPIE -D_FORTIFY_SOURCE=2 -g - CCLIBS = -lm + CCLIBS = -lm +CCLIBS += -z relro -z now # Enable print() and alert() for command line using an optional extra module. CCOPTS += -DDUK_CMDLINE_PRINTALERT_SUPPORT -I./extras/print-alert -Index: duktape-2.3.0/Makefile.sharedlibrary +Index: duktape-2.2.0/Makefile.sharedlibrary =================================================================== ---- duktape-2.3.0.orig/Makefile.sharedlibrary 2018-08-14 09:12:57.551705041 +0200 -+++ duktape-2.3.0/Makefile.sharedlibrary 2018-08-14 09:43:56.183649324 +0200 -@@ -45,7 +45,7 @@ - endif +--- duktape-2.2.0.orig/Makefile.sharedlibrary 2017-10-25 11:44:43.595165939 +0200 ++++ duktape-2.2.0/Makefile.sharedlibrary 2017-10-25 13:21:59.648702111 +0200 +@@ -29,7 +29,7 @@ + REAL_VERSION=$(SONAME_VERSION).$(DUK_VERSION) # Change to actual path for actual distribution packaging. --INSTALL_PREFIX = /usr/local -+INSTALL_PREFIX = ./tmp-build +-INSTALL_PREFIX=/usr/local ++INSTALL_PREFIX=./tmp-build # The 'noline' variant may be more appropriate for some distributions; it # doesn't have #line directives in the combined source. -@@ -55,31 +55,33 @@ - CC = gcc +@@ -37,30 +37,32 @@ + #DUKTAPE_SRCDIR=./src-noline .PHONY: all --all: libduktape.$(SO_REALNAME_SUFFIX) libduktaped.$(SO_REALNAME_SUFFIX) -+all: libduktape.$(SO_SONAME_SUFFIX) libduktaped.$(SO_SONAME_SUFFIX) +-all: libduktape.so.$(REAL_VERSION) libduktaped.so.$(REAL_VERSION) ++all: libduktape.so.$(SONAME_VERSION) libduktaped.so.$(SONAME_VERSION) # If the default duk_config.h is not suitable for the distribution, modify it # before compiling the shared library and copy the same, edited duk_config.h # to $INSTALL_PREFIX/include on installation. --libduktape.$(SO_REALNAME_SUFFIX): -+libduktape.$(SO_SONAME_SUFFIX): - $(CC) -shared -fPIC -Wall -Wextra -Os -Wl,$(LD_SONAME_ARG),libduktape.$(SO_SONAME_SUFFIX) \ +-libduktape.so.$(REAL_VERSION): ++libduktape.so.$(SONAME_VERSION): + gcc -shared -fPIC -Wall -Wextra -Os -Wl,-soname,libduktape.so.$(SONAME_VERSION) \ + -D_FORTIFY_SOURCE=2 -z relro -z now \ -o $@ $(DUKTAPE_SRCDIR)/duktape.c --libduktaped.$(SO_REALNAME_SUFFIX): -+libduktaped.$(SO_SONAME_SUFFIX): - $(CC) -shared -fPIC -g -Wall -Wextra -Os -Wl,$(LD_SONAME_ARG),libduktaped.$(SO_SONAME_SUFFIX) \ +-libduktaped.so.$(REAL_VERSION): ++libduktaped.so.$(SONAME_VERSION): + gcc -shared -fPIC -g -Wall -Wextra -Os -Wl,-soname,libduktaped.so.$(SONAME_VERSION) \ + -D_FORTIFY_SOURCE=2 -z relro -z now \ -o $@ $(DUKTAPE_SRCDIR)/duktape.c # Symlinks depend on platform conventions. .PHONY: install --install: libduktape.$(SO_REALNAME_SUFFIX) libduktaped.$(SO_REALNAME_SUFFIX) -+install: libduktape.$(SO_SONAME_SUFFIX) libduktaped.$(SO_SONAME_SUFFIX) - mkdir -p $(INSTALL_PREFIX)/lib/ +-install: libduktape.so.$(REAL_VERSION) libduktaped.so.$(REAL_VERSION) ++install: libduktape.so.$(SONAME_VERSION) libduktaped.so.$(SONAME_VERSION) cp $+ $(INSTALL_PREFIX)/lib/ -- rm -f $(INSTALL_PREFIX)/lib/libduktape.so $(INSTALL_PREFIX)/lib/libduktape.$(SO_SONAME_SUFFIX) -- ln -s libduktape.$(SO_REALNAME_SUFFIX) $(INSTALL_PREFIX)/lib/libduktape.so -- ln -s libduktape.$(SO_REALNAME_SUFFIX) $(INSTALL_PREFIX)/lib/libduktape.$(SO_SONAME_SUFFIX) +- rm -f $(INSTALL_PREFIX)/lib/libduktape.so $(INSTALL_PREFIX)/lib/libduktape.so.$(SONAME_VERSION) +- ln -s libduktape.so.$(REAL_VERSION) $(INSTALL_PREFIX)/lib/libduktape.so +- ln -s libduktape.so.$(REAL_VERSION) $(INSTALL_PREFIX)/lib/libduktape.so.$(SONAME_VERSION) + rm -f $(INSTALL_PREFIX)/lib/libduktape.so -+ ln -s libduktape.$(SO_SONAME_SUFFIX) $(INSTALL_PREFIX)/lib/libduktape.so -+# ln -s libduktape.$(SO_REALNAME_SUFFIX) $(INSTALL_PREFIX)/lib/libduktape.$(SO_SONAME_SUFFIX) - rm -f $(INSTALL_PREFIX)/lib/libduktaped.so $(INSTALL_PREFIX)/lib/libduktaped.$(SO_SONAME_SUFFIX) -- ln -s libduktaped.$(SO_REALNAME_SUFFIX) $(INSTALL_PREFIX)/lib/libduktaped.so -- ln -s libduktaped.$(SO_REALNAME_SUFFIX) $(INSTALL_PREFIX)/lib/libduktaped.$(SO_SONAME_SUFFIX) -+ ln -s libduktaped.$(SO_SONAME_SUFFIX) $(INSTALL_PREFIX)/lib/libduktaped.so -+# ln -s libduktaped.$(SO_REALNAME_SUFFIX) $(INSTALL_PREFIX)/lib/libduktaped.$(SO_SONAME_SUFFIX) - mkdir -p $(INSTALL_PREFIX)/include/ ++ ln -s libduktape.so.$(SONAME_VERSION) $(INSTALL_PREFIX)/lib/libduktape.so ++# ln -s libduktape.so.$(REAL_VERSION) $(INSTALL_PREFIX)/lib/libduktape.so.$(SONAME_VERSION) + rm -f $(INSTALL_PREFIX)/lib/libduktaped.so $(INSTALL_PREFIX)/lib/libduktaped.so.$(SONAME_VERSION) +- ln -s libduktaped.so.$(REAL_VERSION) $(INSTALL_PREFIX)/lib/libduktaped.so +- ln -s libduktaped.so.$(REAL_VERSION) $(INSTALL_PREFIX)/lib/libduktaped.so.$(SONAME_VERSION) ++ ln -s libduktaped.so.$(SONAME_VERSION) $(INSTALL_PREFIX)/lib/libduktaped.so ++# ln -s libduktaped.so.$(REAL_VERSION) $(INSTALL_PREFIX)/lib/libduktaped.so.$(SONAME_VERSION) cp $(DUKTAPE_SRCDIR)/duktape.h $(DUKTAPE_SRCDIR)/duk_config.h $(INSTALL_PREFIX)/include/ + # Note: assumes /usr/local/include/ and /usr/local/lib/ are in include/link diff -Nru duktape-2.3.0/debian/patches/series duktape-2.2.0/debian/patches/series --- duktape-2.3.0/debian/patches/series 2018-08-14 20:12:45.000000000 +0000 +++ duktape-2.2.0/debian/patches/series 2017-10-25 17:39:13.000000000 +0000 @@ -1,3 +1 @@ -#XXX hardening.patch hardening.patch -debug-symbols.patch diff -Nru duktape-2.3.0/debian/watch duktape-2.2.0/debian/watch --- duktape-2.3.0/debian/watch 2018-08-14 20:12:45.000000000 +0000 +++ duktape-2.2.0/debian/watch 2017-03-07 21:18:53.000000000 +0000 @@ -4,5 +4,5 @@ #opts="pgpsigurlmangle=s%$%.sig%" # HTTP site (basic) -https://duktape.org/download.html \ +http://duktape.org/download.html \ duktape-([\d\.]+)\.tar\.xz debian uupdate diff -Nru duktape-2.3.0/debugger/duk_debug.js duktape-2.2.0/debugger/duk_debug.js --- duktape-2.3.0/debugger/duk_debug.js 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/debugger/duk_debug.js 2017-09-23 01:06:08.000000000 +0000 @@ -417,7 +417,7 @@ /* * Source file manager * - * Scan the list of search directories for ECMAScript source files and + * Scan the list of search directories for Ecmascript source files and * build an index of them. Provides a mechanism to find a source file * based on a raw 'fileName' property provided by the debug target, and * to provide a file list for the web UI. diff -Nru duktape-2.3.0/debugger/README.rst duktape-2.2.0/debugger/README.rst --- duktape-2.3.0/debugger/README.rst 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/debugger/README.rst 2017-09-23 01:06:08.000000000 +0000 @@ -92,8 +92,6 @@ * ``git clone https://github.com/creationix/dukluv.git`` -* ``cd dukluv`` - * ``git submodule init; git submodule update`` * ``make`` diff -Nru duktape-2.3.0/duk_dist_meta.json duktape-2.2.0/duk_dist_meta.json --- duktape-2.3.0/duk_dist_meta.json 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/duk_dist_meta.json 2017-09-23 01:06:08.000000000 +0000 @@ -1,9 +1,9 @@ { "comment": "Metadata for Duktape distributable", - "duk_version_string": "2.3.0", + "duk_version_string": "2.2.0", "type": "duk_dist_meta", - "duk_version": 20300, + "duk_version": 20200, "git_branch": "master", - "git_commit": "d7fdb67f18561a50e06bafd196c6b423af9ad6fe", - "git_describe": "v2.3.0" + "git_commit": "a459cf3c9bd1779fc01b435d69302b742675a08f", + "git_describe": "v2.2.0" } \ No newline at end of file diff -Nru duktape-2.3.0/examples/cmdline/duk_cmdline.c duktape-2.2.0/examples/cmdline/duk_cmdline.c --- duktape-2.3.0/examples/cmdline/duk_cmdline.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/examples/cmdline/duk_cmdline.c 2017-09-23 01:06:08.000000000 +0000 @@ -12,9 +12,6 @@ * - To enable Duktape.Logger, define DUK_CMDLINE_LOGGING_SUPPORT * and add extras/logging/duk_logging.c to compilation. * - * - To enable CBOR, define DUK_CMDLINE_CBOR_SUPPORT and add - * extras/cbor/duk_cbor.c to compilation. - * * - To enable Duktape 1.x module loading support (require(), * Duktape.modSearch() etc), define DUK_CMDLINE_MODULE_SUPPORT and add * extras/module-duktape/duk_module_duktape.c to compilation. @@ -71,9 +68,6 @@ #if defined(DUK_CMDLINE_MODULE_SUPPORT) #include "duk_module_duktape.h" #endif -#if defined(DUK_CMDLINE_CBOR_SUPPORT) -#include "duk_cbor.h" -#endif #if defined(DUK_CMDLINE_FILEIO) #include #endif @@ -1170,11 +1164,6 @@ duk_module_duktape_init(ctx); #endif - /* Register CBOR. */ -#if defined(DUK_CMDLINE_CBOR_SUPPORT) - duk_cbor_init(ctx, 0 /*flags*/); -#endif - /* Trivial readFile/writeFile bindings for testing. */ #if defined(DUK_CMDLINE_FILEIO) duk_push_c_function(ctx, fileio_read_file, 1 /*nargs*/); @@ -1565,12 +1554,7 @@ " --recreate-heap recreate heap after every file\n" " --no-heap-destroy force GC, but don't destroy heap at end (leak testing)\n" "\n" - "If is omitted, interactive mode is started automatically.\n" - "\n" - "Input files can be either Ecmascript source files or bytecode files.\n" - "Bytecode files are not validated prior to loading, so that incompatible\n" - "or crafted files can cause memory unsafe behavior. See discussion in\n" - "https://github.com/svaarala/duktape/blob/master/doc/bytecode.rst#memory-safety-and-bytecode-validation.\n"); + "If is omitted, interactive mode is started automatically.\n"); fflush(stderr); exit(1); } diff -Nru duktape-2.3.0/examples/cmdline/README.rst duktape-2.2.0/examples/cmdline/README.rst --- duktape-2.3.0/examples/cmdline/README.rst 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/examples/cmdline/README.rst 2017-09-23 01:06:08.000000000 +0000 @@ -2,5 +2,5 @@ Duktape command line ==================== -ECMAScript command line execution tool, useful for running ECMAScript code +Ecmascript command line execution tool, useful for running Ecmascript code from a file, stdin, or interactively. Also used by automatic testing. diff -Nru duktape-2.3.0/examples/debug-trans-socket/duk_trans_socket_windows.c duktape-2.2.0/examples/debug-trans-socket/duk_trans_socket_windows.c --- duktape-2.3.0/examples/debug-trans-socket/duk_trans_socket_windows.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/examples/debug-trans-socket/duk_trans_socket_windows.c 2017-09-23 01:06:08.000000000 +0000 @@ -251,7 +251,7 @@ * timeout here to recover from "black hole" disconnects. */ - ret = recv(client_sock, buffer, (int) length, 0); + ret = recv(client_sock, (void *) buffer, (int) length, 0); if (ret < 0) { fprintf(stderr, "%s: debug read failed, error %d, closing connection\n", __FILE__, ret); @@ -315,7 +315,7 @@ * timeout here to recover from "black hole" disconnects. */ - ret = send(client_sock, buffer, (int) length, 0); + ret = send(client_sock, (const void *) buffer, (int) length, 0); if (ret <= 0 || ret > (int) length) { fprintf(stderr, "%s: debug write failed, ret %d, closing connection\n", __FILE__, ret); diff -Nru duktape-2.3.0/examples/eventloop/basic-test.js duktape-2.2.0/examples/eventloop/basic-test.js --- duktape-2.3.0/examples/eventloop/basic-test.js 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/examples/eventloop/basic-test.js 2017-09-23 01:06:08.000000000 +0000 @@ -14,3 +14,4 @@ clearInterval(intervalId); } }, 400, 'foo', 'bar'); + diff -Nru duktape-2.3.0/examples/eventloop/c_eventloop.c duktape-2.2.0/examples/eventloop/c_eventloop.c --- duktape-2.3.0/examples/eventloop/c_eventloop.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/examples/eventloop/c_eventloop.c 2017-09-23 01:06:08.000000000 +0000 @@ -14,20 +14,14 @@ #include #include "duktape.h" -#include "c_eventloop.h" -#if !defined(DUKTAPE_EVENTLOOP_DEBUG) -#define DUKTAPE_EVENTLOOP_DEBUG 0 /* set to 1 to debug with printf */ -#endif - -#define TIMERS_SLOT_NAME "eventTimers" +#define MAX_TIMERS 4096 /* this is quite excessive for embedded use, but good for testing */ #define MIN_DELAY 1.0 #define MIN_WAIT 1.0 #define MAX_WAIT 60000.0 -#define MAX_EXPIRIES 10 +#define MAX_EXPIRYS 10 #define MAX_FDS 256 -#define MAX_TIMERS 4096 /* this is quite excessive for embedded use, but good for testing */ typedef struct { int64_t id; /* numeric ID (returned from e.g. setTimeout); zero if unused */ @@ -109,7 +103,7 @@ static void expire_timers(duk_context *ctx) { ev_timer *t; - int sanity = MAX_EXPIRIES; + int sanity = MAX_EXPIRYS; double now; int rc; @@ -119,7 +113,7 @@ */ duk_push_global_stash(ctx); - duk_get_prop_string(ctx, -1, TIMERS_SLOT_NAME); + duk_get_prop_string(ctx, -1, "eventTimers"); /* [ ... stash eventTimers ] */ @@ -131,7 +125,7 @@ */ if (exit_requested) { -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "exit requested, exiting timer expiry loop\n"); fflush(stderr); #endif @@ -174,7 +168,7 @@ * need to worry about the timer's offset changing on the timer list. */ -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "calling user callback for timer id %d\n", (int) t->id); fflush(stderr); #endif @@ -183,7 +177,7 @@ duk_get_prop(ctx, -2); /* -> [ ... stash eventTimers func ] */ rc = duk_pcall(ctx, 0 /*nargs*/); /* -> [ ... stash eventTimers retval ] */ if (rc != 0) { -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "timer callback failed for timer %d: %s\n", (int) t->id, duk_to_string(ctx, -1)); fflush(stderr); #endif @@ -192,7 +186,7 @@ if (t->removed) { /* One-shot timer (always removed) or removed by user callback. */ -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "deleting callback state for timer %d\n", (int) t->id); fflush(stderr); #endif @@ -202,7 +196,7 @@ /* Interval timer, not removed by user callback. Queue back to * timer list and bubble to its final sorted position. */ -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "queueing timer %d back into active list\n", (int) t->id); fflush(stderr); #endif @@ -232,7 +226,7 @@ struct pollfd *pfd = poll_list + i; if (pfd->fd == 0) { /* keep output index the same */ -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "remove pollfd (index %d): fd=%d, events=%d, revents=%d\n", i, pfd->fd, pfd->events, pfd->revents), fflush(stderr); @@ -240,7 +234,7 @@ continue; } -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "keep pollfd (index %d -> %d): fd=%d, events=%d, revents=%d\n", i, j, pfd->fd, pfd->events, pfd->revents), fflush(stderr); @@ -272,7 +266,7 @@ (void) udata; - /* The ECMAScript poll handler is passed through EventLoop.fdPollHandler + /* The Ecmascript poll handler is passed through EventLoop.fdPollHandler * which c_eventloop.js sets before we come here. */ duk_push_global_object(ctx); @@ -293,7 +287,7 @@ */ if (exit_requested) { -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "exit requested, exiting event loop\n"); fflush(stderr); #endif @@ -323,7 +317,7 @@ timeout = (int) diff; /* clamping ensures that fits */ } else { if (poll_count == 0) { -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "no timers and no sockets to poll, exiting\n"); fflush(stderr); #endif @@ -336,13 +330,13 @@ * Poll for activity or timeout. */ -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "going to poll, timeout %d ms, pollfd count %d\n", timeout, poll_count); fflush(stderr); #endif rc = poll(poll_list, poll_count, timeout); -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "poll rc: %d\n", rc); fflush(stderr); #endif @@ -356,7 +350,7 @@ /* * Check socket activity, handle all sockets. Handling is offloaded to - * ECMAScript code (fd + revents). + * Ecmascript code (fd + revents). * * If FDs are removed from the poll list while we're processing callbacks, * the entries are simply marked unused (fd set to 0) without actually @@ -374,7 +368,7 @@ } if (pfd->revents) { -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "fd %d has revents: %d\n", (int) pfd->fd, (int) pfd->revents); fflush(stderr); #endif @@ -384,7 +378,7 @@ duk_push_int(ctx, pfd->revents); rc = duk_pcall_method(ctx, 2 /*nargs*/); if (rc) { -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "fd callback failed for fd %d: %s\n", (int) pfd->fd, duk_to_string(ctx, -1)); fflush(stderr); #endif @@ -447,7 +441,7 @@ /* Finally, register the callback to the global stash 'eventTimers' object. */ duk_push_global_stash(ctx); - duk_get_prop_string(ctx, -1, TIMERS_SLOT_NAME); /* -> [ func delay oneshot stash eventTimers ] */ + duk_get_prop_string(ctx, -1, "eventTimers"); /* -> [ func delay oneshot stash eventTimers ] */ duk_push_number(ctx, (double) timer_id); duk_dup(ctx, 0); duk_put_prop(ctx, -3); /* eventTimers[timer_id] = callback */ @@ -455,7 +449,7 @@ /* Return timer id. */ duk_push_number(ctx, (double) timer_id); -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "created timer id: %d\n", (int) timer_id); fflush(stderr); #endif @@ -489,7 +483,7 @@ if (t->id == timer_id) { t->removed = 1; duk_push_true(ctx); -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "deleted expiring timer id: %d\n", (int) timer_id); fflush(stderr); #endif @@ -520,11 +514,11 @@ */ duk_push_global_stash(ctx); - duk_get_prop_string(ctx, -1, TIMERS_SLOT_NAME); /* -> [ timer_id stash eventTimers ] */ + duk_get_prop_string(ctx, -1, "eventTimers"); /* -> [ timer_id stash eventTimers ] */ duk_push_number(ctx, (double) timer_id); duk_del_prop(ctx, -2); /* delete eventTimers[timer_id] */ -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "deleted timer id: %d\n", (int) timer_id); fflush(stderr); #endif @@ -532,7 +526,7 @@ } } -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 if (!found) { fprintf(stderr, "trying to delete timer id %d, but not found; ignoring\n", (int) timer_id); fflush(stderr); @@ -549,7 +543,7 @@ int i, n; struct pollfd *pfd; -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "listen_fd: fd=%d, events=%d\n", fd, events); fflush(stderr); #endif @@ -559,7 +553,7 @@ for (i = 0; i < n; i++) { pfd = poll_list + i; if (pfd->fd == fd) { -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "listen_fd: fd found at index %d\n", i); fflush(stderr); #endif @@ -574,7 +568,7 @@ } /* not found, append to list */ -#if DUKTAPE_EVENTLOOP_DEBUG > 0 +#if 0 fprintf(stderr, "listen_fd: fd not found on list, add new entry\n"); fflush(stderr); #endif @@ -621,6 +615,6 @@ /* Initialize global stash 'eventTimers'. */ duk_push_global_stash(ctx); duk_push_object(ctx); - duk_put_prop_string(ctx, -2, TIMERS_SLOT_NAME); + duk_put_prop_string(ctx, -2, "eventTimers"); duk_pop(ctx); } diff -Nru duktape-2.3.0/examples/eventloop/c_eventloop.js duktape-2.2.0/examples/eventloop/c_eventloop.js --- duktape-2.3.0/examples/eventloop/c_eventloop.js 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/examples/eventloop/c_eventloop.js 2017-09-23 01:06:08.000000000 +0000 @@ -1,7 +1,7 @@ /* * C eventloop example (c_eventloop.c). * - * ECMAScript code to initialize the exposed API (setTimeout() etc) when + * Ecmascript code to initialize the exposed API (setTimeout() etc) when * using the C eventloop. * * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Timers @@ -16,14 +16,8 @@ var bind_args; var timer_id; - // Delay can be optional at least in some contexts, so tolerate that. - // https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout if (typeof delay !== 'number') { - if (typeof delay === 'undefined') { - delay = 0; - } else { - throw new TypeError('invalid delay'); - } + throw new TypeError('delay is not a number'); } if (typeof func === 'string') { @@ -59,11 +53,7 @@ var timer_id; if (typeof delay !== 'number') { - if (typeof delay === 'undefined') { - delay = 0; - } else { - throw new TypeError('invalid delay'); - } + throw new TypeError('delay is not a number'); } if (typeof func === 'string') { diff -Nru duktape-2.3.0/examples/eventloop/client-socket-test.js duktape-2.2.0/examples/eventloop/client-socket-test.js --- duktape-2.3.0/examples/eventloop/client-socket-test.js 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/examples/eventloop/client-socket-test.js 2017-09-23 01:06:08.000000000 +0000 @@ -21,3 +21,4 @@ "User-Agent: client-socket-test.js\r\n" + "\r\n"); }); + diff -Nru duktape-2.3.0/examples/eventloop/ecma_eventloop.js duktape-2.2.0/examples/eventloop/ecma_eventloop.js --- duktape-2.3.0/examples/eventloop/ecma_eventloop.js 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/examples/eventloop/ecma_eventloop.js 2017-09-23 01:06:08.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Pure ECMAScript eventloop example. + * Pure Ecmascript eventloop example. * * Timer state handling is inefficient in this trivial example. Timers are * kept in an array sorted by their expiry time which works well for expiring @@ -370,14 +370,8 @@ var timer_id; var evloop = EventLoop; - // Delay can be optional at least in some contexts, so tolerate that. - // https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout if (typeof delay !== 'number') { - if (typeof delay === 'undefined') { - delay = 0; - } else { - throw new TypeError('invalid delay'); - } + throw new TypeError('delay is not a number'); } delay = Math.max(evloop.minimumDelay, delay); @@ -425,11 +419,7 @@ var evloop = EventLoop; if (typeof delay !== 'number') { - if (typeof delay === 'undefined') { - delay = 0; - } else { - throw new TypeError('invalid delay'); - } + throw new TypeError('delay is not a number'); } delay = Math.max(evloop.minimumDelay, delay); diff -Nru duktape-2.3.0/examples/eventloop/main.c duktape-2.2.0/examples/eventloop/main.c --- duktape-2.3.0/examples/eventloop/main.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/examples/eventloop/main.c 2017-09-23 01:06:08.000000000 +0000 @@ -229,14 +229,14 @@ fileio_register(ctx); if (c_evloop) { - fprintf(stderr, "Using C based eventloop (omit -c to use ECMAScript based eventloop)\n"); + fprintf(stderr, "Using C based eventloop (omit -c to use Ecmascript based eventloop)\n"); fflush(stderr); eventloop_register(ctx); fileio_push_file_string(ctx, "c_eventloop.js"); duk_eval(ctx); } else { - fprintf(stderr, "Using ECMAScript based eventloop (give -c to use C based eventloop)\n"); + fprintf(stderr, "Using Ecmascript based eventloop (give -c to use C based eventloop)\n"); fflush(stderr); fileio_push_file_string(ctx, "ecma_eventloop.js"); @@ -268,7 +268,7 @@ usage: fprintf(stderr, "Usage: evloop [-c] \n"); fprintf(stderr, "\n"); - fprintf(stderr, "Uses an ECMAScript based eventloop (ecma_eventloop.js) by default.\n"); + fprintf(stderr, "Uses an Ecmascript based eventloop (ecma_eventloop.js) by default.\n"); fprintf(stderr, "If -c option given, uses a C based eventloop (c_eventloop.{c,js}).\n"); fprintf(stderr, "If is '-', the entire STDIN executed.\n"); fflush(stderr); diff -Nru duktape-2.3.0/examples/eventloop/README.rst duktape-2.2.0/examples/eventloop/README.rst --- duktape-2.3.0/examples/eventloop/README.rst 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/examples/eventloop/README.rst 2017-09-23 01:06:08.000000000 +0000 @@ -12,7 +12,7 @@ To test (Linux only, perhaps other Unix):: $ make - $ ./evloop curses-timers.js # run with ECMAScript eventloop + $ ./evloop curses-timers.js # run with Ecmascript eventloop $ ./evloop -c curses-timers.js # run with C eventloop Implementation approaches @@ -25,8 +25,8 @@ like timers, sockets, etc, is held in C structures. (See ``c_eventloop.c`` and ``c_eventloop.js``.) -2. Using an ECMAScript eventloop which never returns. All the event loop state - can be managed with ECMAScript code instead of C structures. The ECMAScript +2. Using an Ecmascript eventloop which never returns. All the event loop state + can be managed with Ecmascript code instead of C structures. The Ecmascript eventloop calls a Duktape/C helper to do the lowest level poll() call. (See ``ecma_eventloop.js``.) diff -Nru duktape-2.3.0/examples/guide/prime.js duktape-2.2.0/examples/guide/prime.js --- duktape-2.3.0/examples/guide/prime.js 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/examples/guide/prime.js 2017-09-23 01:06:08.000000000 +0000 @@ -1,7 +1,7 @@ // prime.js -// Pure ECMAScript version of low level helper -function primeCheckECMAScript(val, limit) { +// Pure Ecmascript version of low level helper +function primeCheckEcmascript(val, limit) { for (var i = 2; i <= limit; i++) { if ((val % i) == 0) { return false; } } @@ -9,7 +9,7 @@ } // Select available helper at load time -var primeCheckHelper = (this.primeCheckNative || primeCheckECMAScript); +var primeCheckHelper = (this.primeCheckNative || primeCheckEcmascript); // Check 'val' for primality function primeCheck(val) { @@ -23,7 +23,7 @@ function primeTest() { var res = []; - print('Have native helper: ' + (primeCheckHelper !== primeCheckECMAScript)); + print('Have native helper: ' + (primeCheckHelper !== primeCheckEcmascript)); for (var i = 1; i < 1000000; i++) { if (primeCheck(i) && (i % 10000) == 9999) { res.push(i); } } diff -Nru duktape-2.3.0/examples/jxpretty/jxpretty.c duktape-2.2.0/examples/jxpretty/jxpretty.c --- duktape-2.3.0/examples/jxpretty/jxpretty.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/examples/jxpretty/jxpretty.c 2017-09-23 01:06:08.000000000 +0000 @@ -23,7 +23,7 @@ for (;;) { if (ferror(f)) { - (void) duk_error(ctx, DUK_ERR_ERROR, "ferror() on stdin"); + duk_error(ctx, DUK_ERR_ERROR, "ferror() on stdin"); } if (feof(f)) { break; diff -Nru duktape-2.3.0/extras/alloc-pool/duk_alloc_pool.h duktape-2.2.0/extras/alloc-pool/duk_alloc_pool.h --- duktape-2.3.0/extras/alloc-pool/duk_alloc_pool.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/alloc-pool/duk_alloc_pool.h 2017-09-23 01:06:08.000000000 +0000 @@ -3,10 +3,6 @@ #include "duktape.h" -#if defined(__cplusplus) -extern "C" { -#endif - /* 32-bit (big endian) marker used at the end of pool entries so that wasted * space can be detected. Waste tracking must be enabled explicitly. */ @@ -224,8 +220,4 @@ } #endif -#if defined(__cplusplus) -} -#endif /* end 'extern "C"' wrapper */ - #endif /* DUK_ALLOC_POOL_H_INCLUDED */ diff -Nru duktape-2.3.0/extras/alloc-pool/Makefile duktape-2.2.0/extras/alloc-pool/Makefile --- duktape-2.3.0/extras/alloc-pool/Makefile 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/alloc-pool/Makefile 2017-09-23 01:06:08.000000000 +0000 @@ -1,8 +1,7 @@ # For manual testing; say 'make' in extras/alloc-pool and run ./test. -CC = gcc -DEFS = -#DEFS += '-DDUK_ALLOC_POOL_DEBUG' +DEFS= +#DEFS+='-DDUK_ALLOC_POOL_DEBUG' .PHONY: test test: @@ -13,7 +12,7 @@ --output-directory ./prep \ --option-file ./opts.yaml \ --fixup-line 'extern void my_fatal(const char *msg);' - $(CC) -std=c99 -Wall -Wextra -m32 -Os -otest \ + gcc -std=c99 -Wall -Wextra -m32 -Os -otest \ -I./prep ./prep/duktape.c \ $(DEFS) \ duk_alloc_pool.c test.c \ @@ -33,7 +32,7 @@ --option-file ../../config/examples/low_memory.yaml \ --option-file ptrcomp.yaml \ --fixup-file ptrcomp_fixup.h - $(CC) -std=c99 -Wall -Wextra -m32 -Os -optrcomptest \ + gcc -std=c99 -Wall -Wextra -m32 -Os -optrcomptest \ -I. -I./prep ./prep/duktape.c \ $(DEFS) \ duk_alloc_pool.c test.c \ diff -Nru duktape-2.3.0/extras/cbor/cbordecode.py duktape-2.2.0/extras/cbor/cbordecode.py --- duktape-2.3.0/extras/cbor/cbordecode.py 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/cbor/cbordecode.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -#!/usr/bin/env python2 - -def main(): - import sys - import cbor - import json - - data = sys.stdin.read() - print('LEN: %d' % len(data)) - sys.stdout.flush() - print('HEX: ' + data.encode('hex')) - sys.stdout.flush() - doc = cbor.loads(data) - print('REPR: ' + repr(doc)) - sys.stdout.flush() - try: - print('JSON: ' + json.dumps(doc)) - sys.stdout.flush() - except: - print('JSON: cannot encode') - sys.stdout.flush() - -if __name__ == '__main__': - main() diff -Nru duktape-2.3.0/extras/cbor/duk_cbor.c duktape-2.2.0/extras/cbor/duk_cbor.c --- duktape-2.3.0/extras/cbor/duk_cbor.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/cbor/duk_cbor.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1125 +0,0 @@ -/* - * CBOR bindings for Duktape. - * - * https://tools.ietf.org/html/rfc7049 - */ - -#include -#include "duktape.h" -#include "duk_cbor.h" - -#undef DUK_CBOR_DPRINT - -typedef struct { - duk_context *ctx; - duk_idx_t idx_buf; - duk_size_t off; - duk_size_t len; -} duk_cbor_encode_context; - -typedef struct { - duk_context *ctx; - const duk_uint8_t *buf; - duk_size_t off; - duk_size_t len; -} duk_cbor_decode_context; - -typedef union { - duk_uint8_t x[8]; - duk_uint16_t s[4]; - duk_uint32_t i[2]; - double d; -} duk_cbor_dblunion; - -typedef union { - float f; - duk_uint8_t x[4]; -} duk_cbor_fltunion; - -/* - * Misc - */ - -/* Endian detection. Technically happens at runtime, but in practice - * resolves at compile time to a true/false value. - */ -static int duk__cbor_is_little_endian(void) { - duk_cbor_dblunion u; - - /* >>> struct.pack('>d', 1.23456789).encode('hex') - * '3ff3c0ca4283de1b' - */ - - u.d = 1.23456789; - if (u.x[0] == 0x1bU) { - return 1; - } - return 0; -} - -static void duk__cbor_bswap4(duk_uint8_t *x) { - int i; - - for (i = 0; i < 2; i++) { - duk_uint8_t t; - - t = x[i]; x[i] = x[3 - i]; x[3 - i] = t; - } -} - -static void duk__cbor_bswap8(duk_uint8_t *x) { - int i; - - for (i = 0; i < 4; i++) { - duk_uint8_t t; - - t = x[i]; x[i] = x[7 - i]; x[7 - i] = t; - } -} - -/* - * Encoding - */ - -static void duk__cbor_encode_error(duk_cbor_encode_context *enc_ctx) { - (void) duk_type_error(enc_ctx->ctx, "cbor encode error"); -} - -/* Check that a size_t is in uint32 range to avoid out-of-range casts. */ -static void duk__cbor_encode_sizet_uint32_check(duk_cbor_encode_context *enc_ctx, duk_size_t len) { - if (sizeof(duk_size_t) > sizeof(duk_uint32_t) && len > (duk_size_t) DUK_UINT32_MAX) { - duk__cbor_encode_error(enc_ctx); - } -} - -static duk_uint8_t *duk__cbor_encode_reserve(duk_cbor_encode_context *enc_ctx, duk_size_t len) { - duk_uint8_t *res; - duk_size_t ignlen; - - for (;;) { - duk_size_t tmp; - duk_size_t newlen; - - tmp = enc_ctx->off + len; - if (tmp < len) { - duk__cbor_encode_error(enc_ctx); /* Overflow. */ - } - if (tmp <= enc_ctx->len) { - break; - } - newlen = enc_ctx->len * 2U; - if (newlen < enc_ctx->len) { - duk__cbor_encode_error(enc_ctx); /* Overflow. */ - } -#if defined(DUK_CBOR_DPRINT) - fprintf(stderr, "resize to %ld\n", (long) newlen); -#endif - duk_resize_buffer(enc_ctx->ctx, enc_ctx->idx_buf, newlen); - enc_ctx->len = newlen; - } - res = (duk_uint8_t *) duk_require_buffer(enc_ctx->ctx, enc_ctx->idx_buf, &ignlen) + enc_ctx->off; - enc_ctx->off += len; - return res; -} - -static void duk__cbor_encode_overwritebyte(duk_cbor_encode_context *enc_ctx, duk_size_t off, duk_uint8_t val) { - duk_uint8_t *res; - size_t len; - - res = (duk_uint8_t *) duk_require_buffer(enc_ctx->ctx, enc_ctx->idx_buf, &len); - if (off >= len) { - duk__cbor_encode_error(enc_ctx); - } - res[off] = val; -} - -static void duk__cbor_encode_emitbyte(duk_cbor_encode_context *enc_ctx, duk_uint8_t val) { - duk_uint8_t *p; - - p = duk__cbor_encode_reserve(enc_ctx, 1); - *p = val; -} - -static void duk__cbor_encode_uint32(duk_cbor_encode_context *enc_ctx, duk_uint32_t u, duk_uint8_t base) { - duk_uint8_t *p; - - if (u <= 23UL) { - duk__cbor_encode_emitbyte(enc_ctx, (duk_uint8_t) (base + (duk_uint8_t) u)); - } else if (u <= 0xffUL) { - p = duk__cbor_encode_reserve(enc_ctx, 1 + 1); - *p++ = base + 0x18U; - *p++ = (duk_uint8_t) u; - } else if (u <= 0xffffUL) { - p = duk__cbor_encode_reserve(enc_ctx, 1 + 2); - *p++ = base + 0x19U; - *p++ = (duk_uint8_t) ((u >> 8) & 0xffU); - *p++ = (duk_uint8_t) (u & 0xffU); - } else { - p = duk__cbor_encode_reserve(enc_ctx, 1 + 4); - *p++ = base + 0x1aU; - *p++ = (duk_uint8_t) ((u >> 24) & 0xffU); - *p++ = (duk_uint8_t) ((u >> 16) & 0xffU); - *p++ = (duk_uint8_t) ((u >> 8) & 0xffU); - *p++ = (duk_uint8_t) (u & 0xffU); - } -} - -static void duk__cbor_encode_double(duk_cbor_encode_context *enc_ctx, double d) { - duk_uint8_t *p; - duk_cbor_dblunion u; - - /* Integers and floating point values of all types are conceptually - * equivalent in CBOR. Try to always choose the shortest encoding - * which is not always immediately obvious. For example, NaN and Inf - * can be most compactly represented as a half-float (assuming NaN - * bits are not preserved), and 0x1'0000'0000 as a single precision - * float. Shortest forms in preference order (prefer integer over - * float when equal length): - * - * uint 1 byte [0,23] (not -0) - * sint 1 byte [-24,-1] - * uint+1 2 bytes [24,255] - * sint+1 2 bytes [-256,-25] - * uint+2 3 bytes [256,65535] - * sint+2 3 bytes [-65536,-257] - * half-float 3 bytes -0, NaN, +/- Infinity, range [-65504,65504] - * uint+4 5 bytes [65536,4294967295] - * sint+4 5 bytes [-4294967296,-258] - * float 5 bytes range [-(1 - 2^(-24)) * 2^128, (1 - 2^(-24)) * 2^128] - * uint+8 9 bytes [4294967296,18446744073709551615] - * sint+8 9 bytes [-18446744073709551616,-4294967297] - * double 9 bytes - * - * For whole numbers (compatible with integers): - * - 1-byte or 2-byte uint/sint representation is preferred for - * [-256,255]. - * - 3-byte uint/sint is preferred for [-65536,65535]. Half floats - * are never preferred because they have the same length. - * - 5-byte uint/sint is preferred for [-4294967296,4294967295]. - * Single precision floats are never preferred, and half-floats - * don't each above the 3-byte uint/sint range so they're never - * preferred. - * - So, for all integers up to signed/unsigned 32-bit range the - * preferred encoding is always an integer uint/sint. - * - For integers above 32 bits the situation is more complicated. - * Half-floats are never useful for them because of their limited - * range, but IEEE single precision floats (5 bytes encoded) can - * represent some integers between the 32-bit and 64-bit ranges - * which require 9 bytes as a uint/sint. - * - * For floating point values not compatible with integers, the - * preferred encoding is quite clear: - * - For +Inf/-Inf use half-float. - * - For NaN use a half-float, assuming NaN bits ("payload") is - * not worth preserving. Duktape doesn't in general guarantee - * preservation of the NaN payload so using a half-float seems - * consistent with that. - * - For remaining values, prefer the shortest form which doesn't - * lose any precision. For normal half-floats and single precision - * floats this is simple: just check exponent and mantissa bits - * using a fixed mask. For denormal half-floats and single - * precision floats the check is a bit more complicated: a normal - * IEEE double can sometimes be represented as a denormal - * half-float or single precision float. - * - * https://en.wikipedia.org/wiki/Half-precision_floating-point_format#IEEE_754_half-precision_binary_floating-point_format:_binary16 - */ - - u.d = d; - - if (isfinite(d)) { - double d_floor = floor(d); - duk_int16_t exp; - - if (d_floor == d) { - if (d == 0.0) { - if (signbit(d)) { - /* Shortest -0 is using half-float. */ - p = duk__cbor_encode_reserve(enc_ctx, 1 + 2); - *p++ = 0xf9U; - *p++ = 0x80U; - *p++ = 0x00U; - } else { - duk__cbor_encode_emitbyte(enc_ctx, 0x00U); - } - return; - } else if (d > 0.0) { - if (d <= 4294967295.0) { - duk__cbor_encode_uint32(enc_ctx, (duk_uint32_t) d, 0x00U); - return; - } - } else { - if (d >= -4294967296.0) { - duk__cbor_encode_uint32(enc_ctx, (duk_uint32_t) (-1.0 - d), 0x20U); - return; - } - } - /* 64-bit integers are not supported at present. So - * we also don't need to deal with choosing between a - * 64-bit uint/sint representation vs. IEEE double or - * float. - */ - } - - /* Check if 'd' can represented as a normal half-float. - * Denormal half-floats could also be used, but that check - * isn't done now (denormal half-floats are decoded of course). - * So just check exponent range and that at most 10 significant - * bits (excluding implicit leading 1) are used in 'd'. - */ - if (duk__cbor_is_little_endian()) { - exp = (duk_int16_t) ((u.s[3] & 0x7ff0U) >> 4) - 1023; - } else { - exp = (duk_int16_t) ((u.s[0] & 0x7ff0U) >> 4) - 1023; - } - - if (exp >= -14 && exp <= 15) { /* half-float normal exponents (excl. denormals) */ - /* double: seeeeeee eeeemmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm */ - /* half: seeeee mmmm mmmmmm00 00000000 00000000 00000000 00000000 00000000 */ - int use_half_float; - - if (duk__cbor_is_little_endian()) { - use_half_float = - (u.x[0] == 0 && u.x[1] == 0 && u.x[2] == 0 && u.x[3] == 0 && - u.x[4] == 0 && (u.x[5] & 0x03U) == 0); - } else { - use_half_float = - (u.x[7] == 0 && u.x[6] == 0 && u.x[5] == 0 && u.x[4] == 0 && - u.x[3] == 0 && (u.x[2] & 0x03U) == 0); - } - if (use_half_float) { - duk_uint32_t t; - - p = duk__cbor_encode_reserve(enc_ctx, 1 + 2); - - exp += 15; - if (duk__cbor_is_little_endian()) { - t = (duk_uint32_t) (u.x[7] & 0x80U) << 8; - t += (duk_uint32_t) exp << 10; - t += ((duk_uint32_t) u.x[6] & 0x0fU) << 6; - t += ((duk_uint32_t) u.x[5]) >> 2; - } else { - t = (duk_uint32_t) (u.x[0] & 0x80U) << 8; - t += (duk_uint32_t) exp << 10; - t += ((duk_uint32_t) u.x[1] & 0x0fU) << 6; - t += ((duk_uint32_t) u.x[2]) >> 2; - } - - /* seeeeemm mmmmmmmm */ - *p++ = 0xf9U; - *p++ = (t >> 8) & 0xffU; - *p++ = (t >> 0) & 0xffU; - return; - } - } - - /* Same check for plain float. Also no denormal support here. */ - if (exp >= -126 && exp <= 127) { /* float normal exponents (excl. denormals) */ - /* double: seeeeeee eeeemmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm */ - /* float: seeee eeeemmmm mmmmmmmm mmmmmmmm mmm00000 00000000 00000000 00000000 */ - int use_float; - - /* We could do this explicit mantissa check, but doing - * a double-float-double cast is fine because we've - * already verified that the exponent is in range so - * that the narrower cast is not undefined behavior. - */ -#if 0 - if (duk__cbor_is_little_endian()) { - use_float = - (u.x[0] == 0 && u.x[1] == 0 && u.x[2] == 0 && (u.x[3] & 0xe0U) == 0); - } else { - use_float = - (u.x[7] == 0 && u.x[6] == 0 && u.x[5] == 0 && (u.x[4] & 0xe0U) == 0); - } -#endif - use_float = ((duk_double_t) (duk_float_t) d == d); - if (use_float) { - duk_uint32_t t; - - p = duk__cbor_encode_reserve(enc_ctx, 1 + 4); - - exp += 127; - if (duk__cbor_is_little_endian()) { - t = (duk_uint32_t) (u.x[7] & 0x80U) << 24; - t += (duk_uint32_t) exp << 23; - t += ((duk_uint32_t) u.x[6] & 0x0fU) << 19; - t += ((duk_uint32_t) u.x[5]) << 11; - t += ((duk_uint32_t) u.x[4]) << 3; - t += ((duk_uint32_t) u.x[3]) >> 5; - } else { - t = (duk_uint32_t) (u.x[0] & 0x80U) << 24; - t += (duk_uint32_t) exp << 23; - t += ((duk_uint32_t) u.x[1] & 0x0fU) << 19; - t += ((duk_uint32_t) u.x[2]) << 11; - t += ((duk_uint32_t) u.x[3]) << 3; - t += ((duk_uint32_t) u.x[4]) >> 5; - } - - /* seeeeeee emmmmmmm mmmmmmmm mmmmmmmm */ - *p++ = 0xfaU; - *p++ = (t >> 24) & 0xffU; - *p++ = (t >> 16) & 0xffU; - *p++ = (t >> 8) & 0xffU; - *p++ = (t >> 0) & 0xffU; - return; - } - } - - /* Cannot use half-float or float, encode as full IEEE double. */ - p = duk__cbor_encode_reserve(enc_ctx, 1 + 8); - *p++ = 0xfbU; - if (duk__cbor_is_little_endian()) { - *p++ = u.x[7]; - *p++ = u.x[6]; - *p++ = u.x[5]; - *p++ = u.x[4]; - *p++ = u.x[3]; - *p++ = u.x[2]; - *p++ = u.x[1]; - *p++ = u.x[0]; - } else { - *p++ = u.x[0]; - *p++ = u.x[1]; - *p++ = u.x[2]; - *p++ = u.x[3]; - *p++ = u.x[4]; - *p++ = u.x[5]; - *p++ = u.x[6]; - *p++ = u.x[7]; - } - } else if (isinf(d)) { - /* Shortest +/- Infinity encoding is using a half-float. */ - p = duk__cbor_encode_reserve(enc_ctx, 1 + 2); - *p++ = 0xf9U; - if (signbit(d)) { - *p++ = 0xfcU; - } else { - *p++ = 0x7cU; - } - *p++ = 0x00U; - } else { - /* Shortest NaN encoding is using a half-float. Lose the - * exact NaN bits in the process. IEEE double would be - * 7ff8 0000 0000 0000, i.e. a quiet NaN in most architectures - * (https://en.wikipedia.org/wiki/NaN#Encoding). The - * equivalent half float is 7e00. - */ - p = duk__cbor_encode_reserve(enc_ctx, 1 + 2); - *p++ = 0xf9U; - *p++ = 0x7eU; - *p++ = 0x00U; - } -} - -static void duk__cbor_encode_string_top(duk_cbor_encode_context *enc_ctx) { - const duk_uint8_t *str; - duk_size_t len; - duk_uint8_t *p; - - /* XXX: String data should be transcoded to UTF-8, surrogate pairs - * combined and invalid surrogates replaced with U+FFFD. Internal - * representation is used as is for now. - */ - str = (const duk_uint8_t *) duk_require_lstring(enc_ctx->ctx, -1, &len); - duk__cbor_encode_sizet_uint32_check(enc_ctx, len); - duk__cbor_encode_uint32(enc_ctx, (duk_uint32_t) len, 0x60U); - p = duk__cbor_encode_reserve(enc_ctx, len); - (void) memcpy((void *) p, (const void *) str, len); -} - -static void duk__cbor_encode_value(duk_cbor_encode_context *enc_ctx) { - /* XXX: How to avoid losing information in an encode/decode cycle? - * Type tags would be enough to provide knowledge that a value is - * e.g. a pointer, but the tag space doesn't support non-registered - * custom values (all values are assigned by IANA). - */ - duk_uint8_t *buf; - duk_size_t len; - duk_uint8_t *p; - - /* When working with deeply recursive structures, this is important - * to ensure there's no effective depth limit. - */ - duk_require_stack(enc_ctx->ctx, 4); - - switch (duk_get_type(enc_ctx->ctx, -1)) { - case DUK_TYPE_UNDEFINED: - duk__cbor_encode_emitbyte(enc_ctx, 0xf7U); - break; - case DUK_TYPE_NULL: - duk__cbor_encode_emitbyte(enc_ctx, 0xf6U); - break; - case DUK_TYPE_BOOLEAN: - duk__cbor_encode_emitbyte(enc_ctx, duk_get_boolean(enc_ctx->ctx, -1) ? - 0xf5U : 0xf4U); - break; - case DUK_TYPE_NUMBER: - duk__cbor_encode_double(enc_ctx, duk_get_number(enc_ctx->ctx, -1)); - break; - case DUK_TYPE_STRING: - duk__cbor_encode_string_top(enc_ctx); - break; - case DUK_TYPE_OBJECT: - /* XXX: Date support */ - if (duk_is_array(enc_ctx->ctx, -1)) { - duk_size_t i; - len = duk_get_length(enc_ctx->ctx, -1); - duk__cbor_encode_sizet_uint32_check(enc_ctx, len); - duk__cbor_encode_uint32(enc_ctx, (duk_uint32_t) len, 0x80U); - for (i = 0; i < len; i++) { - duk_get_prop_index(enc_ctx->ctx, -1, (duk_uarridx_t) i); - duk__cbor_encode_value(enc_ctx); - } - } else if (duk_is_buffer_data(enc_ctx->ctx, -1)) { - /* Tag buffer data? */ - buf = (duk_uint8_t *) duk_require_buffer_data(enc_ctx->ctx, -1, &len); - duk__cbor_encode_sizet_uint32_check(enc_ctx, len); - duk__cbor_encode_uint32(enc_ctx, (duk_uint32_t) len, 0x40U); - p = duk__cbor_encode_reserve(enc_ctx, len); - (void) memcpy((void *) p, (const void *) buf, len); - } else { - /* We don't know the number of properties in advance - * but would still like to encode at least small - * objects without indefinite length. Emit an - * indefinite length byte initially, and if the final - * property count is small enough to also fit in one - * byte, backpatch it later. Otherwise keep the - * indefinite length. This works well up to 23 - * properties which is practical and good enough. - */ - duk_size_t off_ib = enc_ctx->off; - duk_uint32_t count = 0U; - duk__cbor_encode_emitbyte(enc_ctx, 0xa0U + 0x1fU); /* indefinite length */ - duk_enum(enc_ctx->ctx, -1, DUK_ENUM_OWN_PROPERTIES_ONLY); - while (duk_next(enc_ctx->ctx, -1, 1 /*get_value*/)) { - duk_insert(enc_ctx->ctx, -2); /* [ ... key value ] -> [ ... value key ] */ - duk__cbor_encode_value(enc_ctx); - duk__cbor_encode_value(enc_ctx); - count++; - if (count == 0U) { - duk__cbor_encode_error(enc_ctx); - } - } - duk_pop(enc_ctx->ctx); - if (count <= 0x17U) { - duk__cbor_encode_overwritebyte(enc_ctx, off_ib, (duk_size_t) (0xa0U + count)); - } else { - duk__cbor_encode_emitbyte(enc_ctx, 0xffU); /* break */ - } - } - break; - case DUK_TYPE_BUFFER: - /* Tag buffer data? */ - buf = (duk_uint8_t *) duk_require_buffer(enc_ctx->ctx, -1, &len); - duk__cbor_encode_sizet_uint32_check(enc_ctx, len); - duk__cbor_encode_uint32(enc_ctx, (duk_uint32_t) len, 0x40U); - p = duk__cbor_encode_reserve(enc_ctx, len); - (void) memcpy((void *) p, (const void *) buf, len); - break; - case DUK_TYPE_POINTER: - /* Pointers (void *) are challenging to encode. They can't - * be relied to be even 64-bit integer compatible (there are - * pointer models larger than that), nor can floats encode - * them. They could be encoded as strings (%p format), or - * as direct memory representations. Recovering pointers is - * non-portable in any case but it would be nice to be able - * to recover compatible pointers. - * - * For now, encode as %p string. There doesn't seem to be an - * appropriate tag, so pointers don't currently survive a CBOR - * encode/decode roundtrip intact. - */ - duk_to_string(enc_ctx->ctx, -1); - duk__cbor_encode_string_top(enc_ctx); - break; - case DUK_TYPE_LIGHTFUNC: - /* For now encode as an empty object. */ - duk__cbor_encode_emitbyte(enc_ctx, 0xa0U + 0); /* zero-length */ - break; - case DUK_TYPE_NONE: - default: - goto fail; - } - duk_pop(enc_ctx->ctx); - return; - - fail: - duk__cbor_encode_error(enc_ctx); -} - -/* - * Decoding - */ - -static void duk__cbor_decode_error(duk_cbor_decode_context *dec_ctx) { - (void) duk_type_error(dec_ctx->ctx, "cbor decode error"); -} - -static duk_uint8_t duk__cbor_decode_readbyte(duk_cbor_decode_context *dec_ctx) { - if (dec_ctx->off >= dec_ctx->len) { - duk__cbor_decode_error(dec_ctx); - } - return dec_ctx->buf[dec_ctx->off++]; -} - -static duk_uint8_t duk__cbor_decode_peekbyte(duk_cbor_decode_context *dec_ctx) { - if (dec_ctx->off >= dec_ctx->len) { - duk__cbor_decode_error(dec_ctx); - } - return dec_ctx->buf[dec_ctx->off]; -} - -static void duk__cbor_decode_rewind(duk_cbor_decode_context *dec_ctx, duk_size_t len) { - if (len > dec_ctx->off) { - duk__cbor_decode_error(dec_ctx); - } - dec_ctx->off -= len; -} - -#if 0 -static void duk__cbor_decode_ensure(duk_cbor_decode_context *dec_ctx, duk_size_t len) { - if (dec_ctx->off + len > dec_ctx->len) { - duk__cbor_decode_error(dec_ctx); - } -} -#endif - -static const duk_uint8_t *duk__cbor_decode_consume(duk_cbor_decode_context *dec_ctx, duk_size_t len) { - const duk_uint8_t *res; - duk_size_t tmp; - - tmp = dec_ctx->off + len; - if (tmp < len) { - duk__cbor_decode_error(dec_ctx); /* Overflow. */ - } - if (tmp > dec_ctx->len) { - duk__cbor_decode_error(dec_ctx); /* Not enough input. */ - } - res = dec_ctx->buf + dec_ctx->off; - dec_ctx->off += len; - return res; -} - -static int duk__cbor_decode_checkbreak(duk_cbor_decode_context *dec_ctx) { - if (duk__cbor_decode_peekbyte(dec_ctx) == 0xffU) { - (void) duk__cbor_decode_readbyte(dec_ctx); - return 1; - } - return 0; -} - -static duk_double_t duk__cbor_decode_aival_uint(duk_cbor_decode_context *dec_ctx, duk_uint8_t ib) { - duk_uint8_t ai; - duk_uint32_t t, t2; - - ai = ib & 0x1fU; - if (ai <= 0x17U) { - return (duk_double_t) ai; - } - - switch (ai) { - case 0x18U: /* 1 byte */ - return (duk_double_t) duk__cbor_decode_readbyte(dec_ctx); - case 0x19U: /* 2 byte */ - t = ((duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx)) << 8U; - t += (duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx); - return (duk_double_t) t; - case 0x1aU: /* 4 byte */ - t = ((duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx)) << 24U; - t += ((duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx)) << 16U; - t += ((duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx)) << 8U; - t += (duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx); - return (duk_double_t) t; - case 0x1bU: /* 8 byte */ - t = ((duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx)) << 24U; - t += ((duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx)) << 16U; - t += ((duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx)) << 8U; - t += (duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx); - t2 = t; - t = ((duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx)) << 24U; - t += ((duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx)) << 16U; - t += ((duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx)) << 8U; - t += (duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx); - return (duk_double_t) t2 * 4294967296.0 + (duk_double_t) t; - } - - duk__cbor_decode_error(dec_ctx); - return 0.0; -} - -static duk_uint32_t duk__cbor_decode_aival_uint32(duk_cbor_decode_context *dec_ctx, duk_uint8_t ib) { - duk_double_t t; - - t = duk__cbor_decode_aival_uint(dec_ctx, ib); - if (t >= 4294967296.0) { - duk__cbor_decode_error(dec_ctx); - } - return (duk_uint32_t) t; -} - -static void duk__cbor_decode_buffer(duk_cbor_decode_context *dec_ctx, duk_uint8_t expected_base) { - duk_uint32_t len; - duk_uint8_t *buf; - const duk_uint8_t *inp; - duk_uint8_t ib; - - ib = duk__cbor_decode_readbyte(dec_ctx); - if ((ib & 0xe0U) != expected_base) { - duk__cbor_decode_error(dec_ctx); - } - /* indefinite format is rejected by the following */ - len = duk__cbor_decode_aival_uint32(dec_ctx, ib); - inp = duk__cbor_decode_consume(dec_ctx, len); - buf = (duk_uint8_t *) duk_push_fixed_buffer(dec_ctx->ctx, (duk_size_t) len); - (void) memcpy((void *) buf, (const void *) inp, (size_t) len); -} - -static void duk__cbor_decode_join_buffers(duk_cbor_decode_context *dec_ctx, duk_idx_t count) { - duk_size_t total_size = 0; - duk_idx_t top = duk_get_top(dec_ctx->ctx); - duk_idx_t base = top - count; - duk_idx_t idx; - duk_uint8_t *p = NULL; - - for (;;) { - for (idx = base; idx < top; idx++) { - duk_uint8_t *buf_data; - duk_size_t buf_size; - - buf_data = (duk_uint8_t *) duk_require_buffer(dec_ctx->ctx, idx, &buf_size); - if (p != NULL) { - if (buf_size > 0U) { - (void) memcpy((void *) p, (const void *) buf_data, buf_size); - } - p += buf_size; - } else { - total_size += buf_size; - if (total_size < buf_size) { - duk__cbor_decode_error(dec_ctx); - } - } - } - - if (p != NULL) { - break; - } else { - p = (duk_uint8_t *) duk_push_fixed_buffer(dec_ctx->ctx, total_size); - } - } - - duk_replace(dec_ctx->ctx, base); - duk_pop_n(dec_ctx->ctx, count - 1); -} - -static void duk__cbor_decode_and_join_strbuf(duk_cbor_decode_context *dec_ctx, duk_uint8_t expected_base) { - duk_idx_t count = 0; - for (;;) { - if (duk__cbor_decode_checkbreak(dec_ctx)) { - break; - } - duk__cbor_decode_buffer(dec_ctx, expected_base); - count++; - if (count <= 0) { - duk__cbor_decode_error(dec_ctx); - } - } - if (count == 0) { - (void) duk_push_fixed_buffer(dec_ctx->ctx, 0); - } else if (count > 1) { - duk__cbor_decode_join_buffers(dec_ctx, count); - } -} - -static duk_double_t duk__cbor_decode_half_float(duk_cbor_decode_context *dec_ctx) { - duk_cbor_dblunion u; - const duk_uint8_t *inp; - duk_int_t exp; - duk_uint_t u16; - duk_uint_t tmp; - duk_double_t res; - - inp = duk__cbor_decode_consume(dec_ctx, 2); - u16 = ((duk_uint_t) inp[0] << 8) + (duk_uint_t) inp[1]; - exp = (duk_int_t) ((u16 >> 10) & 0x1fU) - 15; - - if (exp == -15) { - /* Zero or denormal; but note that half float - * denormals become double normals. - */ - if ((u16 & 0x03ffU) == 0) { - u.x[0] = inp[0] & 0x80U; - u.x[1] = 0U; - u.x[2] = 0U; - u.x[3] = 0U; - u.x[4] = 0U; - u.x[5] = 0U; - u.x[6] = 0U; - u.x[7] = 0U; - } else { - /* Create denormal by first creating a double that - * contains the denormal bits and a leading implicit - * 1-bit. Then subtract away the implicit 1-bit. - * - * 0.mmmmmmmmmm * 2^-14 - * 1.mmmmmmmmmm 0.... * 2^-14 - * -1.0000000000 0.... * 2^-14 - * - * Double exponent: -14 + 1023 = 0x3f1 - */ - u.x[0] = 0x3fU; - u.x[1] = 0x10U + (duk_uint8_t) ((u16 >> 6) & 0x0fU); - u.x[2] = (duk_uint8_t) ((u16 << 2) & 0xffU); /* Mask is really 0xfcU */ - u.x[3] = 0U; - u.x[4] = 0U; - u.x[5] = 0U; - u.x[6] = 0U; - u.x[7] = 0U; - if (duk__cbor_is_little_endian()) { - duk__cbor_bswap8(u.x); - } - res = u.d - 0.00006103515625; /* 2^(-14) */ - if (u16 & 0x8000U) { - res = -res; - } - return res; - } - } else if (exp == 16) { - /* +/- Inf or NaN. */ - if ((u16 & 0x03ffU) == 0) { - u.x[0] = (inp[0] & 0x80U) + 0x7fU; - u.x[1] = 0xf0U; - u.x[2] = 0U; - u.x[3] = 0U; - u.x[4] = 0U; - u.x[5] = 0U; - u.x[6] = 0U; - u.x[7] = 0U; - } else { - /* Create a 'quiet NaN' with highest - * bit set (there are some platforms - * where the NaN payload convention is - * the opposite). Keep sign. - */ - u.x[0] = (inp[0] & 0x80U) + 0x7fU; - u.x[1] = 0xf8U; - u.x[2] = 0U; - u.x[3] = 0U; - u.x[4] = 0U; - u.x[5] = 0U; - u.x[6] = 0U; - u.x[7] = 0U; - } - } else { - /* Normal. */ - tmp = (inp[0] & 0x80U) ? 0x80000000UL : 0UL; - tmp += (duk_uint_t) (exp + 1023) << 20; - tmp += (duk_uint_t) (inp[0] & 0x03U) << 18; - tmp += (duk_uint_t) (inp[1] & 0xffU) << 10; - u.x[0] = (tmp >> 24) & 0xffU; - u.x[1] = (tmp >> 16) & 0xffU; - u.x[2] = (tmp >> 8) & 0xffU; - u.x[3] = (tmp >> 0) & 0xffU; - u.x[4] = 0U; - u.x[5] = 0U; - u.x[6] = 0U; - u.x[7] = 0U; - } - if (duk__cbor_is_little_endian()) { - duk__cbor_bswap8(u.x); - } - - return u.d; -} - -static void duk__cbor_decode_value(duk_cbor_decode_context *dec_ctx) { - duk_uint8_t ib, mt, ai; - - /* When working with deeply recursive structures, this is important - * to ensure there's no effective depth limit. - */ - duk_require_stack(dec_ctx->ctx, 4); - - reread_initial_byte: -#if defined(DUK_CBOR_DPRINT) - fprintf(stderr, "decode off=%ld len=%ld\n", (long) dec_ctx->off, (long) dec_ctx->len); -#endif - - ib = duk__cbor_decode_readbyte(dec_ctx); - mt = ib >> 5U; - ai = ib & 0x1fU; - - /* Additional information in [24,27] = [0x18,0x1b] has relatively - * uniform handling for all major types: read 1/2/4/8 additional - * bytes. For major type 7 the 1-byte value is a 'simple type', and - * 2/4/8-byte values are floats. For other major types the 1/2/4/8 - * byte values are integers. The lengths are uniform, but the typing - * is not. - */ - - switch (mt) { - case 0U: { /* unsigned integer */ - duk_push_number(dec_ctx->ctx, duk__cbor_decode_aival_uint(dec_ctx, ib)); - break; - } - case 1U: { /* negative integer */ - /* XXX: precision, for -1.0 and 64-bit integers */ - duk_push_number(dec_ctx->ctx, -1.0 - duk__cbor_decode_aival_uint(dec_ctx, ib)); - break; - } - case 2U: { /* byte string */ - if (ai == 0x1fU) { - duk__cbor_decode_and_join_strbuf(dec_ctx, 0x40U); - } else { - duk__cbor_decode_rewind(dec_ctx, 1U); - duk__cbor_decode_buffer(dec_ctx, 0x40U); - } - break; - } - case 3U: { /* text string */ - /* XXX: Text data should be validated to be UTF-8 on input, - * and then be converted to surrogate pairs etc. Right now - * import as is, but reject strings that would create symbols. - */ - if (ai == 0x1fU) { - duk_uint8_t *buf_data; - duk_size_t buf_size; - - duk__cbor_decode_and_join_strbuf(dec_ctx, 0x60U); - buf_data = (duk_uint8_t *) duk_require_buffer(dec_ctx->ctx, -1, &buf_size); - (void) duk_push_lstring(dec_ctx->ctx, (const char *) buf_data, buf_size); - duk_remove(dec_ctx->ctx, -2); - } else { - duk_uint32_t len; - const duk_uint8_t *inp; - - len = duk__cbor_decode_aival_uint32(dec_ctx, ib); - inp = duk__cbor_decode_consume(dec_ctx, len); - (void) duk_push_lstring(dec_ctx->ctx, (const char *) inp, (duk_size_t) len); - } - /* XXX: Here a Duktape API call to convert input -> utf-8 with - * replacements would be nice. - */ - break; - } - case 4U: { /* array of data items */ - duk_uint32_t idx, len; - - /* Support arrays up to 0xfffffffeU in length. 0xffffffff is - * used as an indefinite length marker. - */ - if (ai == 0x1fU) { - len = 0xffffffffUL; - } else { - len = duk__cbor_decode_aival_uint32(dec_ctx, ib); - if (len == 0xffffffffUL) { - goto format_error; - } - } - - duk_push_array(dec_ctx->ctx); - for (idx = 0U; ;) { - if (len == 0xffffffffUL && duk__cbor_decode_checkbreak(dec_ctx)) { - break; - } - if (idx == len) { - if (ai == 0x1fU) { - goto format_error; - } - break; - } - duk__cbor_decode_value(dec_ctx); - duk_put_prop_index(dec_ctx->ctx, -2, (duk_uarridx_t) idx); - idx++; - if (idx == 0U) { - goto format_error; /* wrapped */ - } - } - break; - } - case 5U: { /* map of pairs of data items */ - duk_uint32_t count; - - if (ai == 0x1fU) { - count = 0xffffffffUL; - } else { - count = duk__cbor_decode_aival_uint32(dec_ctx, ib); - if (count == 0xffffffffUL) { - goto format_error; - } - } - - duk_push_object(dec_ctx->ctx); - for (;;) { - if (count == 0xffffffffUL) { - if (duk__cbor_decode_checkbreak(dec_ctx)) { - break; - } - } else { - if (count == 0UL) { - break; - } - count--; - } - - /* Non-string keys are coerced to strings, - * possibly leading to overwriting previous - * keys. Last key of a certain coerced name - * wins. If key is an object, it will coerce - * to '[object Object]' which is consistent - * but potentially misleading. One alternative - * would be to skip non-string keys. - */ - duk__cbor_decode_value(dec_ctx); - duk__cbor_decode_value(dec_ctx); - duk_put_prop(dec_ctx->ctx, -3); - } - break; - } - case 6U: { /* semantic tagging */ - /* Tags are ignored now, re-read initial byte. A tagged - * value may itself be tagged (an unlimited number of times) - * so keep on peeling away tags. - */ - (void) duk__cbor_decode_aival_uint32(dec_ctx, ib); - goto reread_initial_byte; - } - case 7U: { /* floating point numbers, simple data types, break; other */ - switch (ai) { - case 0x14U: { - duk_push_false(dec_ctx->ctx); - break; - } - case 0x15U: { - duk_push_true(dec_ctx->ctx); - break; - } - case 0x16U: { - duk_push_null(dec_ctx->ctx); - break; - } - case 0x17U: { - duk_push_undefined(dec_ctx->ctx); - break; - } - case 0x18U: { /* more simple values (1 byte) */ - goto format_error; /* none defined so far, and 0-31 not allowed */ - } - case 0x19U: { /* half-float (2 bytes) */ - duk_double_t d; - d = duk__cbor_decode_half_float(dec_ctx); - duk_push_number(dec_ctx->ctx, d); - break; - } - case 0x1aU: { /* float (4 bytes) */ - duk_cbor_fltunion u; - const duk_uint8_t *inp; - inp = duk__cbor_decode_consume(dec_ctx, 4); - (void) memcpy((void *) u.x, (const void *) inp, 4); - if (duk__cbor_is_little_endian()) { - duk__cbor_bswap4(u.x); - } - duk_push_number(dec_ctx->ctx, (duk_double_t) u.f); - break; - } - case 0x1bU: { /* double (8 bytes) */ - duk_cbor_dblunion u; - const duk_uint8_t *inp; - inp = duk__cbor_decode_consume(dec_ctx, 8); - (void) memcpy((void *) u.x, (const void *) inp, 8); - if (duk__cbor_is_little_endian()) { - duk__cbor_bswap8(u.x); - } - duk_push_number(dec_ctx->ctx, u.d); - break; - } - case 0xffU: /* unexpected break */ - default: { - goto format_error; - } - } /* end switch */ - break; - } - default: { - goto format_error; /* will never actually occur */ - } - } /* end switch */ - - return; - - format_error: - duk__cbor_decode_error(dec_ctx); -} - -/* - * Public APIs - */ - -static duk_ret_t duk__cbor_encode_binding(duk_context *ctx) { - /* Produce an ArrayBuffer by first decoding into a plain buffer which - * mimics a Uint8Array and gettings its .buffer property. - */ - duk_cbor_encode(ctx, -1, 0); - duk_get_prop_string(ctx, -1, "buffer"); - return 1; -} - -static duk_ret_t duk__cbor_decode_binding(duk_context *ctx) { - /* Lenient: accept any buffer like. */ - duk_cbor_decode(ctx, -1, 0); - return 1; -} - -void duk_cbor_init(duk_context *ctx, duk_uint_t flags) { - (void) flags; - duk_push_global_object(ctx); - duk_push_string(ctx, "CBOR"); - duk_push_object(ctx); - duk_push_string(ctx, "encode"); - duk_push_c_function(ctx, duk__cbor_encode_binding, 1); - duk_def_prop(ctx, -3, DUK_DEFPROP_ATTR_WC | DUK_DEFPROP_HAVE_VALUE); - duk_push_string(ctx, "decode"); - duk_push_c_function(ctx, duk__cbor_decode_binding, 1); - duk_def_prop(ctx, -3, DUK_DEFPROP_ATTR_WC | DUK_DEFPROP_HAVE_VALUE); - duk_def_prop(ctx, -3, DUK_DEFPROP_ATTR_WC | DUK_DEFPROP_HAVE_VALUE); - duk_pop(ctx); -} - -void duk_cbor_encode(duk_context *ctx, duk_idx_t idx, duk_uint_t encode_flags) { - duk_cbor_encode_context enc_ctx; - - (void) encode_flags; - - idx = duk_require_normalize_index(ctx, idx); - - enc_ctx.ctx = ctx; - enc_ctx.idx_buf = duk_get_top(ctx); - enc_ctx.off = 0; - enc_ctx.len = 64; - - duk_push_dynamic_buffer(ctx, enc_ctx.len); - duk_dup(ctx, idx); - duk__cbor_encode_value(&enc_ctx); - duk_resize_buffer(enc_ctx.ctx, enc_ctx.idx_buf, enc_ctx.off); - duk_replace(ctx, idx); -} - -void duk_cbor_decode(duk_context *ctx, duk_idx_t idx, duk_uint_t decode_flags) { - duk_cbor_decode_context dec_ctx; - - (void) decode_flags; - - idx = duk_require_normalize_index(ctx, idx); - - dec_ctx.ctx = ctx; - dec_ctx.buf = (const duk_uint8_t *) duk_require_buffer_data(ctx, idx, &dec_ctx.len); - dec_ctx.off = 0; - /* dec_ctx.len: set above */ - - duk__cbor_decode_value(&dec_ctx); - if (dec_ctx.off != dec_ctx.len) { - (void) duk_type_error(ctx, "trailing garbage"); - } - - duk_replace(ctx, idx); -} diff -Nru duktape-2.3.0/extras/cbor/duk_cbor.h duktape-2.2.0/extras/cbor/duk_cbor.h --- duktape-2.3.0/extras/cbor/duk_cbor.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/cbor/duk_cbor.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#if !defined(DUK_CBOR_H_INCLUDED) -#define DUK_CBOR_H_INCLUDED - -#include "duktape.h" - -#if defined(__cplusplus) -extern "C" { -#endif - -/* No flags at present. */ - -extern void duk_cbor_init(duk_context *ctx, duk_uint_t flags); -extern void duk_cbor_encode(duk_context *ctx, duk_idx_t idx, duk_uint_t encode_flags); -extern void duk_cbor_decode(duk_context *ctx, duk_idx_t idx, duk_uint_t decode_flags); - -#if defined(__cplusplus) -} -#endif /* end 'extern "C"' wrapper */ - -#endif /* DUK_CBOR_H_INCLUDED */ diff -Nru duktape-2.3.0/extras/cbor/jsoncbor.c duktape-2.2.0/extras/cbor/jsoncbor.c --- duktape-2.3.0/extras/cbor/jsoncbor.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/cbor/jsoncbor.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,207 +0,0 @@ -#include -#include "duktape.h" -#include "duk_cbor.h" - -#define FMT_CBOR 1 -#define FMT_JSON 2 -#define FMT_JX 3 -#define FMT_JS 4 - -static int read_format = 0; -static int write_format = 0; -static int write_indent = 0; - -static void push_stdin(duk_context *ctx, int to_string) { - unsigned char *buf; - size_t off; - size_t len; - size_t got; - - off = 0; - len = 256; - buf = (unsigned char *) duk_push_dynamic_buffer(ctx, len); - - for (;;) { -#if 0 - fprintf(stderr, "reading %ld of input\n", (long) (len - off)); -#endif - got = fread(buf + off, 1, len - off, stdin); - if (got == 0U) { - break; - } - off += got; - if (len - off < 256U) { - size_t newlen = len * 2U; - buf = (unsigned char *) duk_resize_buffer(ctx, -1, newlen); - len = newlen; - } - } - buf = (unsigned char *) duk_resize_buffer(ctx, -1, off); - - if (to_string) { - duk_push_lstring(ctx, (const char *) buf, off); - duk_remove(ctx, -2); - } -} - -static void usage_and_exit(void) { - fprintf(stderr, "Usage: jsoncbor -r cbor|json|jx|js -w cbor|json|jx [--indent N]\n" - " jsoncbor -e # shorthand for -r json -w cbor\n" - " jsoncbor -d [--indent N] # shorthand for -r cbor -w json [--indent N]\n" - "\n" - " Input is read from stdin, output is written to stdout.\n" - " 'jx' is a Duktape custom JSON extension.\n" - " 'js' means evaluate input as an ECMAScript expression.\n"); - exit(1); -} - -static duk_ret_t transcode_helper(duk_context *ctx, void *udata) { - const unsigned char *buf; - size_t len; - duk_idx_t top; - - (void) udata; - - /* For Duktape->JSON conversion map all typed arrays into base-64. - * This is generally more useful than the default behavior. However, - * the base-64 value doesn't have any kind of 'tag' to allow it to be - * parsed back into binary automatically. Right now the CBOR parser - * creates plain fixed buffers from incoming binary strings. - */ - duk_eval_string_noresult(ctx, - "(function () {\n" - " Object.getPrototypeOf(new Uint8Array(0)).toJSON = function () {\n" - " return Duktape.enc('base64', this);\n" - " };\n" - "}())\n"); - - top = duk_get_top(ctx); - - if (read_format == FMT_CBOR) { - push_stdin(ctx, 0 /*to_string*/); - duk_cbor_decode(ctx, -1, 0); - } else if (read_format == FMT_JSON) { - push_stdin(ctx, 1 /*to_string*/); - duk_json_decode(ctx, -1); - } else if (read_format == FMT_JX) { - duk_eval_string(ctx, "(function(v){return Duktape.dec('jx',v)})"); - push_stdin(ctx, 1 /*to_string*/); - duk_call(ctx, 1); - } else if (read_format == FMT_JS) { - push_stdin(ctx, 1 /*to_string*/); - duk_eval(ctx); - } else { - (void) duk_type_error(ctx, "invalid read format"); - } - - if (duk_get_top(ctx) != top + 1) { - fprintf(stderr, "top invalid after decoding: %d vs. %d\n", duk_get_top(ctx), top + 1); - exit(1); - } - - if (write_format == FMT_CBOR) { - duk_cbor_encode(ctx, -1, 0); - } else if (write_format == FMT_JSON) { - duk_eval_string(ctx, "(function(v,i){return JSON.stringify(v,null,i)})"); - duk_insert(ctx, -2); - duk_push_int(ctx, write_indent); - duk_call(ctx, 2); - } else if (write_format == FMT_JX) { - duk_eval_string(ctx, "(function(v,i){return Duktape.enc('jx',v,null,i)})"); - duk_insert(ctx, -2); - duk_push_int(ctx, write_indent); - duk_call(ctx, 2); - } else { - (void) duk_type_error(ctx, "invalid write format"); - } - - if (duk_is_string(ctx, -1)) { - buf = (const unsigned char *) duk_require_lstring(ctx, -1, &len); - fwrite((const void *) buf, 1, len, stdout); - fprintf(stdout, "\n"); - } else { - buf = (const unsigned char *) duk_require_buffer_data(ctx, -1, &len); - fwrite((const void *) buf, 1, len, stdout); - } - - if (duk_get_top(ctx) != top + 1) { - fprintf(stderr, "top invalid after encoding: %d vs. %d\n", duk_get_top(ctx), top + 1); - exit(1); - } - - return 0; -} - -static int parse_format(const char *s) { - if (strcmp(s, "cbor") == 0) { - return FMT_CBOR; - } else if (strcmp(s, "json") == 0) { - return FMT_JSON; - } else if (strcmp(s, "jx") == 0) { - return FMT_JX; - } else if (strcmp(s, "js") == 0) { - return FMT_JS; - } else { - return 0; - } -} - -int main(int argc, char *argv[]) { - duk_context *ctx; - duk_int_t rc; - int exitcode = 0; - int i; - - for (i = 1; i < argc; i++) { - if (strcmp(argv[i], "-e") == 0) { - read_format = FMT_JSON; - write_format = FMT_CBOR; - } else if (strcmp(argv[i], "-d") == 0) { - read_format = FMT_CBOR; - write_format = FMT_JSON; - } else if (strcmp(argv[i], "-r") == 0) { - if (i + 1 >= argc) { - goto usage; - } - read_format = parse_format(argv[i + 1]); - i++; - } else if (strcmp(argv[i], "-w") == 0) { - if (i + 1 >= argc) { - goto usage; - } - write_format = parse_format(argv[i + 1]); - i++; - } else if (strcmp(argv[i], "--indent") == 0) { - if (i + 1 >= argc) { - goto usage; - } - write_indent = atoi(argv[i + 1]); - i++; - } else { - goto usage; - } - } - - if (read_format == 0 || write_format == 0) { - goto usage; - } - - ctx = duk_create_heap_default(); - if (!ctx) { - return 1; - } - - rc = duk_safe_call(ctx, transcode_helper, NULL, 0, 1); - if (rc != 0) { - fprintf(stderr, "%s\n", duk_safe_to_string(ctx, -1)); - exitcode = 1; - } - /* duk_pop(ctx): unnecessary */ - - duk_destroy_heap(ctx); - - return exitcode; - - usage: - usage_and_exit(); -} diff -Nru duktape-2.3.0/extras/cbor/Makefile duktape-2.2.0/extras/cbor/Makefile --- duktape-2.3.0/extras/cbor/Makefile 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/cbor/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,261 +0,0 @@ -# For manual testing; say 'make' in extras/cbor. - -VALGRIND = valgrind -CC = gcc -CCOPTS = -std=c99 -Wall -Wextra -O2 -#CCOPTS += -fsanitize=undefined - -.PHONY: all -all: clean jsoncbor test-runs - -.PHONY: clean -clean: - -rm -rf ./prep - -rm -f jsoncbor - -rm -f appendix_a.json - -jsoncbor: jsoncbor.c duk_cbor.c duk_cbor.h - -rm -rf ./prep - python2 ../../tools/configure.py --quiet --output-directory ./prep \ - -DDUK_USE_JSON_DECNUMBER_FASTPATH \ - -DDUK_USE_JSON_DECSTRING_FASTPATH \ - -DDUK_USE_JSON_EATWHITE_FASTPATH \ - -DDUK_USE_JSON_QUOTESTRING_FASTPATH \ - -DDUK_USE_JSON_STRINGIFY_FASTPATH - $(CC) $(CCOPTS) -o $@ -I./prep -I. ./prep/duktape.c duk_cbor.c jsoncbor.c -lm - -appendix_a.json: - wget -O $@ https://raw.githubusercontent.com/cbor/test-vectors/master/appendix_a.json - -.PHONY: test-runs -test-runs: jsoncbor \ - enc-primitives enc-number enc-buffer enc-string enc-array enc-object enc-half-float enc-float enc-misc \ - dec-half-float dec-half-float dec-array dec-object - -.PHONY: test-vectors -test-vectors: appendix_a.json - echo "Expects 'duk' to exist in local directory for now..." - ./duk run_testvectors.js - -.PHONY: dec-half-float -dec-half-float: jsoncbor - @echo "half-float zero" - python -c 'import sys; sys.stdout.write("\xf9\x00\x00")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x00\x00")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x80\x00")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x80\x00")'| $(VALGRIND) -q ./jsoncbor -d - @echo "half-float denormal" - python -c 'import sys; sys.stdout.write("\xf9\x00\x01")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x00\x01")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x80\x01")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x80\x01")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x00\x02")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x00\x02")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x80\x02")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x80\x02")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x03\xff")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x03\xff")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x83\xff")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x83\xff")'| $(VALGRIND) -q ./jsoncbor -d - @echo "half-float normal" - python -c 'import sys; sys.stdout.write("\xf9\x04\x00")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x04\x00")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x84\x00")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x84\x00")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x07\xfe")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x07\xfe")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x87\xfe")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x87\xfe")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x08\x00")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x08\x00")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x88\x00")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x88\x00")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x78\x00")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x78\x00")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\xf8\x00")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\xf8\x00")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x7b\xff")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x7b\xff")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\xfb\xff")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\xfb\xff")'| $(VALGRIND) -q ./jsoncbor -d - @echo "half-float inf" - python -c 'import sys; sys.stdout.write("\xf9\x7c\x00")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x7c\x00")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\xfc\x00")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\xfc\x00")'| $(VALGRIND) -q ./jsoncbor -d - @echo "half-float nan" - python -c 'import sys; sys.stdout.write("\xf9\x7c\x01")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x7c\x01")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\xfc\x01")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\xfc\x01")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x7e\x00")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x7e\x00")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\xfe\x00")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\xfe\x00")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\x7f\x12")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\x7f\x12")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xf9\xff\x12")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xf9\xff\x12")'| $(VALGRIND) -q ./jsoncbor -d - -.PHONY: dec-array -dec-array: jsoncbor - python -c 'import sys; sys.stdout.write("\x9f\x01\x02\x03\x9f\xff\x04\x80\x80\x9f\x10\x11\xff\x84\x04\x03\x02\x01\xff")' | python cbordecode.py - python -c 'import sys; sys.stdout.write("\x9f\x01\x02\x03\x9f\xff\x04\x80\x80\x9f\x10\x11\xff\x84\x04\x03\x02\x01\xff")' | $(VALGRIND) -q ./jsoncbor -d - -.PHONY: dec-object -dec-object: jsoncbor - python -c 'import sys; sys.stdout.write("\xbf\x63foo\x63bar\x63bar\xa0\x64quux\xbf\xff\x63baz\xa2\x61a\x61b\x61c\x61d\x65quuux\xbf\x61x\x61y\x61z\x61w\xff\xff")' | python cbordecode.py - python -c 'import sys; sys.stdout.write("\xbf\x63foo\x63bar\x63bar\xa0\x64quux\xbf\xff\x63baz\xa2\x61a\x61b\x61c\x61d\x65quuux\xbf\x61x\x61y\x61z\x61w\xff\xff")' | $(VALGRIND) -q ./jsoncbor -d - -.PHONY: dec-misc -dec-misc: jsoncbor - python -c 'import sys; sys.stdout.write("\xa1cfoocbar")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xa1cfoocbar")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xa1\xa0\xa0")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xa1\xa0\xa0")'| $(VALGRIND) -q ./jsoncbor -d # object key, gets string coerced in JSON output - python -c 'import sys; sys.stdout.write("\x7f\xff")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\x7f\xff")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\x7f`````````````````````````````````````````````````````````````````````````````````````````````````````````\xff")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\x7f`````````````````````````````````````````````````````````````````````````````````````````````````````````\xff")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\x7fcfoo\xff")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\x7fcfoo\xff")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\x7fcfoocbaraqau`auax\xff")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\x7fcfoocbaraqau`auax\xff")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\x5f\xff")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\x5f\xff")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\x5f@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\xff")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\x5f@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\xff")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\x5fCfoo\xff")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\x5fCfoo\xff")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\x5fCfooCbarAqAu@AuAx\xff")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\x5fCfooCbarAqAu@AuAx\xff")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xc0cfoo")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xc0cfoo")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xc0\xc1cfoo")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xc0\xc1cfoo")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xc0\xd7cfoo")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xc0\xd7cfoo")'| $(VALGRIND) -q ./jsoncbor -d - python -c 'import sys; sys.stdout.write("\xc0\xd8\xffcfoo")'| python cbordecode.py - python -c 'import sys; sys.stdout.write("\xc0\xd8\xffcfoo")'| $(VALGRIND) -q ./jsoncbor -d - - -.PHONY: enc-primitives -enc-primitives: jsoncbor - echo 'void 0' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo 'null' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo 'true' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo 'false' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - -.PHONY: enc-number -enc-number: jsoncbor - echo '0' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '0.1' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '1' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '23' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '24' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '25' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '255' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '256' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '65535' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '65536' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '65536.9' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '1048576' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '4294967295' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '4294967296' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py # shortest encoding: ieee single - echo '4294967297' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '0xdeadbeef' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '3.141592653589793' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-0' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-0.1' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-1' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-23' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-24' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-25' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-255' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-256' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-257' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-65535' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-65536' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-65536.9' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-65537' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-1048576' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-4294967295' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-4294967296' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-4294967297' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-0xdeadbeef' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-3.141592653589793' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '1/0' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py # shortest encoding: half-float - echo '0/0' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py # shortest encoding: half-float - echo '-1/0' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py # shortest encoding: half-float - -.PHONY: enc-half-float -enc-half-float: - echo '1.5' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '1/16384' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '1/32768' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-1.5' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-1/16384' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-1/32768' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - -.PHONY: enc-float -enc-float: - echo '0xffffffff' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '0x100000000' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '0x1fedcbe0000000000' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '0x1fedcbf0000000000' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - # Unlike for positive integers, 0x100000000 encodes to a cbor integer (sint). - # Then -0x100000001 doesn't encode to a float because the mantissa is too long. - echo '-0x100000000' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-0x100000001' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-0x100010000' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-0x1fedcbe0000000000' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '-0x1fedcbf0000000000' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - -.PHONY: enc-buffer -enc-buffer: jsoncbor - echo '(function () { var p = Uint8Array.allocPlain(0); return p; })()' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '(function () { var p = Uint8Array.allocPlain(1); p[0] = 0xfe; return p; })()' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '(function () { var p = Uint8Array.allocPlain(2); p[0] = 0xc0; p[1] = 0x80; return p; })()' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '(function () { var p = Uint8Array.allocPlain(3); p[0] = 0x31; p[1] = 0x4a; p[2] = 0x7a; return p; })()' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '(function () { var p = Uint8Array.allocPlain(23); p[22] = 0xfe; return p; })()' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '(function () { var p = Uint8Array.allocPlain(24); p[23] = 0xfe; return p; })()' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '(function () { var p = Uint8Array.allocPlain(255); p[254] = 0xfe; return p; })()' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '(function () { var p = Uint8Array.allocPlain(256); p[255] = 0xfe; return p; })()' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '(function () { var p = Uint8Array.allocPlain(256); p[255] = 0xfe; return p; })()' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '(function () { var p = new Uint16Array([ 1, 2, 3, 4 ]); return p; })()' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - -.PHONY: enc-string -enc-string: jsoncbor - echo '""' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '"foo"' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '"foo\u20acbar"' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '"foo\ud800bar"' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py # unpaired surrogate - echo '"\u4321\u4321\u4321\u4321\u4321\u4321\u4321xy"' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '"\u4321\u4321\u4321\u4321\u4321\u4321\u4321xyz"' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '"\u4321\u4321\u4321\u4321\u4321\u4321\u4321xyzw"' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '"\u4321\u4321\u4321\u4321\u4321\u4321\u4321xyzw......................................................................................................................................................................................................................................"' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '"\u4321\u4321\u4321\u4321\u4321\u4321\u4321xyzw......................................................................................................................................................................................................................................!"' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - -.PHONY: enc-array -enc-array: jsoncbor - echo '[]' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '[ "foo", "bar", "quux" ]' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - # XXX: other lengths - echo '([[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{ foo: 123 }]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]])' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - -.PHONY: enc-object -enc-object: jsoncbor - echo '({})' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '({ foo: 123 })' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '({ foo: 123, bar: 234, quux: 345 })' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '({ foo: 123, bar: [ "foo", "bar", { baz: true } ], quux: 345 })' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '({ a:1, b:2, c:3, d:4, e:5, f:6, g:7, h:8, i:9, j:10, k:11, l:12, m:13, n:14, o:15, p:16, q:17, r:18, s:19, t:20, u:21, v:22 })' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '({ a:1, b:2, c:3, d:4, e:5, f:6, g:7, h:8, i:9, j:10, k:11, l:12, m:13, n:14, o:15, p:16, q:17, r:18, s:19, t:20, u:21, v:22, w:23 })' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '({ a:1, b:2, c:3, d:4, e:5, f:6, g:7, h:8, i:9, j:10, k:11, l:12, m:13, n:14, o:15, p:16, q:17, r:18, s:19, t:20, u:21, v:22, w:23, x:24 })' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '({ a:1, b:2, c:3, d:4, e:5, f:6, g:7, h:8, i:9, j:10, k:11, l:12, m:13, n:14, o:15, p:16, q:17, r:18, s:19, t:20, u:21, v:22, w:23, x:24, y:25 })' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '({ a:1, b:2, c:3, d:4, e:5, f:6, g:7, h:8, i:9, j:10, k:11, l:12, m:13, n:14, o:15, p:16, q:17, r:18, s:19, t:20, u:21, v:22, w:23, x:24, y:25, z:26 })' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - echo '({foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:{foo:123}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}})' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py - -.PHONY: enc-misc -enc-misc: jsoncbor - echo '({ jsonrpc: "2.0", id: "foo-1", method: "Add", params: { a: 123, b: 234 }})' | $(VALGRIND) -q ./jsoncbor -r js -w cbor | python2 cbordecode.py diff -Nru duktape-2.3.0/extras/cbor/README.rst duktape-2.2.0/extras/cbor/README.rst --- duktape-2.3.0/extras/cbor/README.rst 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/cbor/README.rst 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -============ -CBOR binding -============ - -Overview -======== - -C functions to encode/decode values in CBOR format, and a simple command -line utility to convert between JSON and CBOR. - -To integrate CBOR into your application: - -* Call ``duk_cbor_encode()`` and ``duk_cbor_decode()`` directly if a C API - is enough. - -* Call ``duk_cbor_init()`` to register a global ``CBOR`` object with - ECMAScript bindings ``CBOR.encode()`` and ``CBOR.decode()``, roughly - matching https://github.com/paroga/cbor-js. - -Basic usage of the ``jsoncbor`` conversion tool:: - - $ make jsoncbor - [...] - $ cat test.json | ./jsoncbor -e # writes CBOR to stdout - $ cat test.cbor | ./jsoncbor -d # writes JSON to stdout - -CBOR objects are decoded into ECMAScript objects, with non-string keys -coerced into strings. - -Direct support for CBOR is likely to be included in the Duktape API in the -future. This extra will then become unnecessary. - -CBOR -==== - -CBOR is a standard format for JSON-like binary interchange. It is -faster and smaller, and can encode more data types than JSON. In particular, -binary data can be serialized without encoding e.g. in base-64. These -properties make it useful for e.g. storing state files, IPC, etc. - -Some CBOR shortcomings for preserving information: - -- No property attribute or inheritance support. -- No DAGs or looped graphs. -- Array objects with properties lose their non-index properties. -- Array objects with gaps lose their gaps as they read back as undefined. -- Buffer objects and views lose much of their detail besides the raw data. -- ECMAScript strings cannot be fully represented; strings must be UTF-8. -- Functions and native objects lose most of their detail. -- CBOR tags are useful to provide soft decoding information, but the tags - are just integers from an IANA controlled space with no space for custom - tags. So tags cannot be easily used for private, application specific tags. - -Future work -=========== - -- Decode test cases, also for cases we don't produce. -- https://datatracker.ietf.org/doc/draft-jroatch-cbor-tags/?include_text=1 - could be used for typed arrays. -- 64-bit integer encoding. -- Better 64-bit integer decoding (workaround for non-64-bit targets). -- Objects with non-string keys, could be represented as a Map. -- Definite-length object encoding even when object has more than 23 keys. diff -Nru duktape-2.3.0/extras/cbor/run_testvectors.js duktape-2.2.0/extras/cbor/run_testvectors.js --- duktape-2.3.0/extras/cbor/run_testvectors.js 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/cbor/run_testvectors.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -var testvectors = JSON.parse(new TextDecoder().decode(readFile('appendix_a.json'))); - -// Very rudimentary for now, just dump useful information about decode -// results and (simple, unstructured) comparison to expected. This is -// only useful for manually inspecting the results right now. - -testvectors.forEach(function (test, idx) { - print('===', idx, '->', Duktape.enc('jx', test)); - - var cbor = Duktape.dec('base64', test.cbor); - try { - var dec = CBOR.decode(cbor); - } catch (e) { - print('decode failed: ' + e); - return; - } - - print('dec (jx): ' + Duktape.enc('jx', dec)); - - if (dec !== test.decoded) { - print('decoded compare failed'); - } - if (test.roundtrip) { - var enc = CBOR.encode(dec); - print('re-enc: ' + Duktape.enc('hex', enc)); - if (Duktape.enc('base64', cbor) !== Duktape.enc('base64', enc)) { - print('roundtrip failed'); - } - } -}); diff -Nru duktape-2.3.0/extras/console/duk_console.c duktape-2.2.0/extras/console/duk_console.c --- duktape-2.3.0/extras/console/duk_console.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/console/duk_console.c 2017-09-23 01:06:08.000000000 +0000 @@ -13,6 +13,10 @@ /* XXX: Add some form of log level filtering. */ +/* XXX: For now logs everything to stdout, V8/Node.js logs debug/info level + * to stdout, warn and above to stderr. Should this extra do the same? + */ + /* XXX: Should all output be written via e.g. console.write(formattedMsg)? * This would make it easier for user code to redirect all console output * to a custom backend. @@ -21,10 +25,12 @@ /* XXX: Init console object using duk_def_prop() when that call is available. */ static duk_ret_t duk__console_log_helper(duk_context *ctx, const char *error_name) { - duk_uint_t flags = (duk_uint_t) duk_get_current_magic(ctx); - FILE *output = (flags & DUK_CONSOLE_STDOUT_ONLY) ? stdout : stderr; - duk_idx_t n = duk_get_top(ctx); - duk_idx_t i; + duk_idx_t i, n; + duk_uint_t flags; + + flags = (duk_uint_t) duk_get_current_magic(ctx); + + n = duk_get_top(ctx); duk_get_global_string(ctx, "console"); duk_get_prop_string(ctx, -1, "format"); @@ -53,9 +59,9 @@ duk_get_prop_string(ctx, -1, "stack"); } - fprintf(output, "%s\n", duk_to_string(ctx, -1)); + fprintf(stdout, "%s\n", duk_to_string(ctx, -1)); if (flags & DUK_CONSOLE_FLUSH) { - fflush(output); + fflush(stdout); } return 0; } @@ -104,17 +110,6 @@ } void duk_console_init(duk_context *ctx, duk_uint_t flags) { - duk_uint_t flags_orig; - - /* If both DUK_CONSOLE_STDOUT_ONLY and DUK_CONSOLE_STDERR_ONLY where specified, - * just turn off DUK_CONSOLE_STDOUT_ONLY and keep DUK_CONSOLE_STDERR_ONLY. - */ - if ((flags & DUK_CONSOLE_STDOUT_ONLY) && (flags & DUK_CONSOLE_STDERR_ONLY)) { - flags &= ~DUK_CONSOLE_STDOUT_ONLY; - } - /* Remember the (possibly corrected) flags we received. */ - flags_orig = flags; - duk_push_object(ctx); /* Custom function to format objects; user can replace. @@ -133,22 +128,11 @@ "})(Duktape.enc)"); duk_put_prop_string(ctx, -2, "format"); - flags = flags_orig; - if (!(flags & DUK_CONSOLE_STDOUT_ONLY) && !(flags & DUK_CONSOLE_STDERR_ONLY)) { - /* No output indicators were specified; these levels go to stdout. */ - flags |= DUK_CONSOLE_STDOUT_ONLY; - } duk__console_reg_vararg_func(ctx, duk__console_assert, "assert", flags); duk__console_reg_vararg_func(ctx, duk__console_log, "log", flags); duk__console_reg_vararg_func(ctx, duk__console_log, "debug", flags); /* alias to console.log */ duk__console_reg_vararg_func(ctx, duk__console_trace, "trace", flags); duk__console_reg_vararg_func(ctx, duk__console_info, "info", flags); - - flags = flags_orig; - if (!(flags & DUK_CONSOLE_STDOUT_ONLY) && !(flags & DUK_CONSOLE_STDERR_ONLY)) { - /* No output indicators were specified; these levels go to stderr. */ - flags |= DUK_CONSOLE_STDERR_ONLY; - } duk__console_reg_vararg_func(ctx, duk__console_warn, "warn", flags); duk__console_reg_vararg_func(ctx, duk__console_error, "error", flags); duk__console_reg_vararg_func(ctx, duk__console_error, "exception", flags); /* alias to console.error */ diff -Nru duktape-2.3.0/extras/console/duk_console.h duktape-2.2.0/extras/console/duk_console.h --- duktape-2.3.0/extras/console/duk_console.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/console/duk_console.h 2017-09-23 01:06:08.000000000 +0000 @@ -3,27 +3,12 @@ #include "duktape.h" -#if defined(__cplusplus) -extern "C" { -#endif - /* Use a proxy wrapper to make undefined methods (console.foo()) no-ops. */ -#define DUK_CONSOLE_PROXY_WRAPPER (1U << 0) +#define DUK_CONSOLE_PROXY_WRAPPER (1 << 0) /* Flush output after every call. */ -#define DUK_CONSOLE_FLUSH (1U << 1) - -/* Send output to stdout only (default is mixed stdout/stderr). */ -#define DUK_CONSOLE_STDOUT_ONLY (1U << 2) +#define DUK_CONSOLE_FLUSH (1 << 1) -/* Send output to stderr only (default is mixed stdout/stderr). */ -#define DUK_CONSOLE_STDERR_ONLY (1U << 3) - -/* Initialize the console system */ extern void duk_console_init(duk_context *ctx, duk_uint_t flags); -#if defined(__cplusplus) -} -#endif /* end 'extern "C"' wrapper */ - #endif /* DUK_CONSOLE_H_INCLUDED */ diff -Nru duktape-2.3.0/extras/console/Makefile duktape-2.2.0/extras/console/Makefile --- duktape-2.3.0/extras/console/Makefile 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/console/Makefile 2017-09-23 01:06:08.000000000 +0000 @@ -1,20 +1,11 @@ -# For manual testing; say 'make' in extras/console and run ./test. - -CC = gcc +# For manual testing; say 'make' in extras/print-alert and run ./test. .PHONY: test test: - -rm -rf ./prep - python2 ../../tools/configure.py --quiet --output-directory ./prep - $(CC) -std=c99 -Wall -Wextra -o $@ -I./prep -I. ./prep/duktape.c duk_console.c test.c -lm + gcc -std=c99 -Wall -Wextra -o $@ -I../../src/ -I. ../../src/duktape.c duk_console.c test.c -lm ./test 'console.assert(true, "not shown");' ./test 'console.assert(false, "shown", { foo: 123 });' ./test 'console.log(1, 2, 3, { foo: "bar" });' ./test 'a={}; b={}; a.ref=b; console.log(a,b); b.ref=a; console.log(a,b)' # circular ref ./test 'console.trace(1, 2, 3)' ./test 'console.dir({ foo: 123, bar: [ "foo", "bar" ]});' - -.PHONY: clean -clean: - -rm -rf ./prep - -rm -f test diff -Nru duktape-2.3.0/extras/console/README.rst duktape-2.2.0/extras/console/README.rst --- duktape-2.3.0/extras/console/README.rst 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/console/README.rst 2017-09-23 01:06:08.000000000 +0000 @@ -28,8 +28,3 @@ * After these steps, ``console`` will be registered to the global object and is ready to use. - -* By default the console object will use ``stdout`` for log levels up to - info, and ``stderr`` for warning and above. You can change this by - providing either ``DUK_CONSOLE_STDOUT_ONLY`` or ``DUK_CONSOLE_STDERR_ONLY`` - in ``duk_console_init()`` flags. diff -Nru duktape-2.3.0/extras/duk-v1-compat/duk_v1_compat.h duktape-2.2.0/extras/duk-v1-compat/duk_v1_compat.h --- duktape-2.3.0/extras/duk-v1-compat/duk_v1_compat.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/duk-v1-compat/duk_v1_compat.h 2017-09-23 01:06:08.000000000 +0000 @@ -3,10 +3,6 @@ #include "duktape.h" -#if defined(__cplusplus) -extern "C" { -#endif - /* Straight flag rename */ #if !defined(DUK_ENUM_INCLUDE_INTERNAL) #define DUK_ENUM_INCLUDE_INTERNAL DUK_ENUM_INCLUDE_HIDDEN @@ -29,8 +25,4 @@ #define duk_push_string_file(ctx,path) \ duk_push_string_file_raw((ctx), (path), 0) -#if defined(__cplusplus) -} -#endif /* end 'extern "C"' wrapper */ - #endif /* DUK_V1_COMPAT_INCLUDED */ diff -Nru duktape-2.3.0/extras/duk-v1-compat/Makefile duktape-2.2.0/extras/duk-v1-compat/Makefile --- duktape-2.3.0/extras/duk-v1-compat/Makefile 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/duk-v1-compat/Makefile 2017-09-23 01:06:08.000000000 +0000 @@ -1,15 +1,6 @@ # For manual testing; say 'make' in extras/duk-v1-compat and run ./test. -CC = gcc - .PHONY: test test: - -rm -rf ./prep - python2 ../../tools/configure.py --quiet --output-directory ./prep - $(CC) -std=c99 -Wall -Wextra -o $@ -I./prep -I. ./prep/duktape.c duk_v1_compat.c test.c -lm + gcc -std=c99 -Wall -Wextra -o $@ -I../../src/ -I. ../../src/duktape.c duk_v1_compat.c test.c -lm ./test - -.PHONY: clean -clean: - -rm -rf ./prep - -rm -f test diff -Nru duktape-2.3.0/extras/logging/duk_logging.h duktape-2.2.0/extras/logging/duk_logging.h --- duktape-2.3.0/extras/logging/duk_logging.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/logging/duk_logging.h 2017-09-23 01:06:08.000000000 +0000 @@ -3,11 +3,7 @@ #include "duktape.h" -#if defined(__cplusplus) -extern "C" { -#endif - -/* Log levels. */ +/* Log levels */ #define DUK_LOG_TRACE 0 #define DUK_LOG_DEBUG 1 #define DUK_LOG_INFO 2 @@ -21,8 +17,4 @@ extern void duk_log_va(duk_context *ctx, duk_int_t level, const char *fmt, va_list ap); extern void duk_log(duk_context *ctx, duk_int_t level, const char *fmt, ...); -#if defined(__cplusplus) -} -#endif /* end 'extern "C"' wrapper */ - #endif /* DUK_LOGGING_H_INCLUDED */ diff -Nru duktape-2.3.0/extras/logging/Makefile duktape-2.2.0/extras/logging/Makefile --- duktape-2.3.0/extras/logging/Makefile 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/logging/Makefile 2017-09-23 01:06:08.000000000 +0000 @@ -1,12 +1,7 @@ # For manual testing; say 'make' in extras/logging and run ./test. - -CC = gcc - .PHONY: test test: - -rm -rf ./prep - python2 ../../tools/configure.py --quiet --output-directory ./prep - $(CC) -std=c99 -Wall -Wextra -otest -I./prep ./prep/duktape.c duk_logging.c test.c -lm + gcc -std=c99 -Wall -Wextra -otest -I../../src ../../src/duktape.c duk_logging.c test.c -lm ./test 'L = new Duktape.Logger(); L.trace("testing"); L.l = 0; L.trace("testing 2");' ./test 'L = new Duktape.Logger(); L.debug("testing"); L.l = 1; L.debug("testing 2");' ./test 'L = new Duktape.Logger(); L.info("testing");' @@ -15,8 +10,3 @@ ./test 'L = new Duktape.Logger(); L.fatal("testing");' ./test 'L = new Duktape.Logger(); L.info("testing"); L.n = "loggerName"; L.info("new name");' ./test 'L = new Duktape.Logger("argname"); L.info("testing");' - -.PHONY: clean -clean: - -rm -rf ./prep - -rm -f test diff -Nru duktape-2.3.0/extras/minimal-printf/duk_minimal_printf.h duktape-2.2.0/extras/minimal-printf/duk_minimal_printf.h --- duktape-2.3.0/extras/minimal-printf/duk_minimal_printf.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/minimal-printf/duk_minimal_printf.h 2017-09-23 01:06:08.000000000 +0000 @@ -4,17 +4,9 @@ #include /* va_list etc */ #include /* size_t */ -#if defined(__cplusplus) -extern "C" { -#endif - extern int duk_minimal_sprintf(char *str, const char *format, ...); extern int duk_minimal_snprintf(char *str, size_t size, const char *format, ...); extern int duk_minimal_vsnprintf(char *str, size_t size, const char *format, va_list ap); extern int duk_minimal_sscanf(const char *str, const char *format, ...); -#if defined(__cplusplus) -} -#endif /* end 'extern "C"' wrapper */ - #endif /* DUK_MINIMAL_PRINTF_H_INCLUDED */ diff -Nru duktape-2.3.0/extras/minimal-printf/Makefile duktape-2.2.0/extras/minimal-printf/Makefile --- duktape-2.3.0/extras/minimal-printf/Makefile 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/minimal-printf/Makefile 2017-09-23 01:06:08.000000000 +0000 @@ -1,7 +1,5 @@ # Just for manual testing -CC = gcc - .PHONY: test test: duk_minimal_printf.c - $(CC) -std=c99 -Wall -Wextra -fno-stack-protector -m32 -Os -fomit-frame-pointer -otest duk_minimal_printf.c test.c + gcc -std=c99 -Wall -Wextra -fno-stack-protector -m32 -Os -fomit-frame-pointer -otest duk_minimal_printf.c test.c ./test diff -Nru duktape-2.3.0/extras/module-duktape/duk_module_duktape.c duktape-2.2.0/extras/module-duktape/duk_module_duktape.c --- duktape-2.3.0/extras/module-duktape/duk_module_duktape.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/module-duktape/duk_module_duktape.c 2017-09-23 01:06:08.000000000 +0000 @@ -263,7 +263,7 @@ * done with Object.defineProperty(). * * XXX: require.id could also be just made non-configurable, as there - * is no practical reason to touch it (at least from ECMAScript code). + * is no practical reason to touch it (at least from Ecmascript code). */ duk_push_c_function(ctx, duk__require, 1 /*nargs*/); duk_push_string(ctx, "name"); @@ -307,7 +307,7 @@ * Call user provided module search function and build the wrapped * module source code (if necessary). The module search function * can be used to implement pure Ecmacsript, pure C, and mixed - * ECMAScript/C modules. + * Ecmascript/C modules. * * The module search function can operate on the exports table directly * (e.g. DLL code can register values to it). It can also return a diff -Nru duktape-2.3.0/extras/module-duktape/duk_module_duktape.h duktape-2.2.0/extras/module-duktape/duk_module_duktape.h --- duktape-2.3.0/extras/module-duktape/duk_module_duktape.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/module-duktape/duk_module_duktape.h 2017-09-23 01:06:08.000000000 +0000 @@ -3,10 +3,6 @@ #include "duktape.h" -#if defined(__cplusplus) -extern "C" { -#endif - /* Maximum length of CommonJS module identifier to resolve. Length includes * both current module ID, requested (possibly relative) module ID, and a * slash in between. @@ -15,8 +11,4 @@ extern void duk_module_duktape_init(duk_context *ctx); -#if defined(__cplusplus) -} -#endif /* end 'extern "C"' wrapper */ - #endif /* DUK_MODULE_DUKTAPE_H_INCLUDED */ diff -Nru duktape-2.3.0/extras/module-duktape/Makefile duktape-2.2.0/extras/module-duktape/Makefile --- duktape-2.3.0/extras/module-duktape/Makefile 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/module-duktape/Makefile 2017-09-23 01:06:08.000000000 +0000 @@ -1,13 +1,9 @@ # For manual testing; say 'make' in extras/module-duktape and run ./test. # There's test coverage in tests/ecmascript, so tests here are very simple. -CC = gcc - .PHONY: test test: - -rm -rf ./prep - python2 ../../tools/configure.py --quiet --output-directory ./prep - $(CC) -std=c99 -Wall -Wextra -o $@ -I./prep -I. ./prep/duktape.c duk_module_duktape.c test.c -lm + gcc -std=c99 -Wall -Wextra -o $@ -I../../src/ -I. ../../src/duktape.c duk_module_duktape.c test.c -lm @printf '\n' ./test 'assert(typeof require === "function");' ./test 'assert(require.name === "require");' @@ -16,8 +12,3 @@ ./test 'Duktape.modSearch = function myModSearch(id) { return "exports.foo = 123;" }; assert(require("dummy").foo === 123);' ./test 'Duktape.modSearch = function myModSearch(id) { return "exports.foo = 234;" }; delete Duktape; assert(typeof Duktape === "undefined"); assert(require("dummy").foo === 234);' ./test 'Duktape.modSearch = function myModSearch(id) { return "exports.foo = 234; // comment" }; delete Duktape; assert(typeof Duktape === "undefined"); assert(require("dummy").foo === 234);' - -.PHONY: clean -clean: - -rm -rf ./prep - -rm -f test diff -Nru duktape-2.3.0/extras/module-node/duk_module_node.h duktape-2.2.0/extras/module-node/duk_module_node.h --- duktape-2.3.0/extras/module-node/duk_module_node.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/module-node/duk_module_node.h 2017-09-23 01:06:08.000000000 +0000 @@ -3,15 +3,7 @@ #include "duktape.h" -#if defined(__cplusplus) -extern "C" { -#endif - extern duk_ret_t duk_module_node_peval_main(duk_context *ctx, const char *path); extern void duk_module_node_init(duk_context *ctx); -#if defined(__cplusplus) -} -#endif /* end 'extern "C"' wrapper */ - #endif /* DUK_MODULE_NODE_H_INCLUDED */ diff -Nru duktape-2.3.0/extras/module-node/Makefile duktape-2.2.0/extras/module-node/Makefile --- duktape-2.3.0/extras/module-node/Makefile 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/module-node/Makefile 2017-09-23 01:06:08.000000000 +0000 @@ -1,12 +1,8 @@ # For manual testing; say 'make' in extras/module-node and run ./test. -CC = gcc - .PHONY: test test: - -rm -rf ./prep - python2 ../../tools/configure.py --quiet --output-directory ./prep - $(CC) -std=c99 -Wall -Wextra -o $@ -I./prep -I. ./prep/duktape.c duk_module_node.c test.c -lm + gcc -std=c99 -Wall -Wextra -o $@ -I../../src/ -I. ../../src/duktape.c duk_module_node.c test.c -lm @printf '\n' ./test 'assert(typeof require("pig") === "string", "basic require()");' ./test 'assert(require("cow").indexOf("pig") !== -1, "nested require()");' @@ -21,8 +17,3 @@ ./test 'var badger = require("badger"); assert(badger.foo === 123 && badger.bar === 234, "exports.foo assignment");' ./test 'var comment = require("comment"); assert(comment.foo === 123 && comment.bar === 234, "last line with // comment");' ./test 'var shebang = require("shebang"); assert(shebang.foo === 123 && shebang.bar === 234, "shebang");' - -.PHONY: clean -clean: - -rm -rf ./prep - -rm -f test diff -Nru duktape-2.3.0/extras/module-node/README.rst duktape-2.2.0/extras/module-node/README.rst --- duktape-2.3.0/extras/module-node/README.rst 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/module-node/README.rst 2017-09-23 01:06:08.000000000 +0000 @@ -63,7 +63,7 @@ when the global ``require()`` is called, the parent ID is an empty string. * The load callback is a Duktape/C function which takes the resolved module ID - and: (1) returns the ECMAScript source code for the module or ``undefined`` + and: (1) returns the Ecmascript source code for the module or ``undefined`` if there's no source code, e.g. for pure C modules, (2) can populate ``module.exports`` itself, and (3) can replace ``module.exports``:: diff -Nru duktape-2.3.0/extras/print-alert/duk_print_alert.h duktape-2.2.0/extras/print-alert/duk_print_alert.h --- duktape-2.3.0/extras/print-alert/duk_print_alert.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/print-alert/duk_print_alert.h 2017-09-23 01:06:08.000000000 +0000 @@ -3,16 +3,8 @@ #include "duktape.h" -#if defined(__cplusplus) -extern "C" { -#endif - /* No flags at the moment. */ extern void duk_print_alert_init(duk_context *ctx, duk_uint_t flags); -#if defined(__cplusplus) -} -#endif /* end 'extern "C"' wrapper */ - #endif /* DUK_PRINT_ALERT_H_INCLUDED */ diff -Nru duktape-2.3.0/extras/print-alert/Makefile duktape-2.2.0/extras/print-alert/Makefile --- duktape-2.3.0/extras/print-alert/Makefile 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/extras/print-alert/Makefile 2017-09-23 01:06:08.000000000 +0000 @@ -1,16 +1,6 @@ # For manual testing; say 'make' in extras/print-alert and run ./test. - -CC = gcc - .PHONY: test test: - -rm -rf ./prep - python2 ../../tools/configure.py --quiet --output-directory ./prep - $(CC) -std=c99 -Wall -Wextra -otest -I./prep ./prep/duktape.c duk_print_alert.c test.c -lm + gcc -std=c99 -Wall -Wextra -otest -I../../src ../../src/duktape.c duk_print_alert.c test.c -lm ./test 'print("foo", "bar", 1, 2, 3)' ./test 'alert("foo", "bar", 1, 2, 3)' - -.PHONY: clean -clean: - -rm -rf ./prep - -rm -f test diff -Nru duktape-2.3.0/LICENSE.txt duktape-2.2.0/LICENSE.txt --- duktape-2.3.0/LICENSE.txt 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/LICENSE.txt 2017-09-23 01:06:08.000000000 +0000 @@ -4,7 +4,7 @@ (http://opensource.org/licenses/MIT) -Copyright (c) 2013-2018 by Duktape authors (see AUTHORS.rst) +Copyright (c) 2013-2017 by Duktape authors (see AUTHORS.rst) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff -Nru duktape-2.3.0/Makefile.cmdline duktape-2.2.0/Makefile.cmdline --- duktape-2.3.0/Makefile.cmdline 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/Makefile.cmdline 2017-09-23 01:06:08.000000000 +0000 @@ -8,10 +8,10 @@ CMDLINE_SOURCES = \ examples/cmdline/duk_cmdline.c -CC = gcc -CCOPTS = -Os -pedantic -std=c99 -Wall -fstrict-aliasing -fomit-frame-pointer +CC = gcc +CCOPTS = -Os -pedantic -std=c99 -Wall -fstrict-aliasing -fomit-frame-pointer CCOPTS += -I./examples/cmdline -I./src # duktape.h and duk_config.h must be in include path -CCLIBS = -lm +CCLIBS = -lm # Enable print() and alert() for command line using an optional extra module. CCOPTS += -DDUK_CMDLINE_PRINTALERT_SUPPORT -I./extras/print-alert @@ -33,13 +33,13 @@ # will cause some harmless compilation warnings. #CCOPTS += -DDUK_CMDLINE_FANCY -I./linenoise #CMDLINE_SOURCES += linenoise/linenoise.c -#duk: linenoise +#duk: linenoise # Use the tools/configure.py utility to modify Duktape default configuration: # http://duktape.org/guide.html#compiling # http://wiki.duktape.org/Configuring.html -duk: $(DUKTAPE_SOURCES) $(CMDLINE_SOURCES) +duk: $(DUKTAPE_SOURCES) $(CMDLINE_SOURCES) $(CC) -o $@ $(DEFINES) $(CCOPTS) $(DUKTAPE_SOURCES) $(CMDLINE_SOURCES) $(CCLIBS) linenoise/linenoise.c: linenoise diff -Nru duktape-2.3.0/Makefile.codepage duktape-2.2.0/Makefile.codepage --- duktape-2.3.0/Makefile.codepage 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/Makefile.codepage 2017-09-23 01:06:08.000000000 +0000 @@ -1,6 +1,4 @@ -CC = gcc - codepage: - $(CC) -o $@ -std=c99 -O2 -Wall -Wextra -Isrc/ \ + gcc -o $@ -std=c99 -O2 -Wall -Wextra -Isrc/ \ src/duktape.c examples/codepage-conv/duk_codepage_conv.c \ examples/codepage-conv/test.c -lm diff -Nru duktape-2.3.0/Makefile.dukdebug duktape-2.2.0/Makefile.dukdebug --- duktape-2.3.0/Makefile.dukdebug 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/Makefile.dukdebug 2017-09-23 01:06:08.000000000 +0000 @@ -10,11 +10,11 @@ examples/cmdline/duk_cmdline.c \ examples/debug-trans-socket/duk_trans_socket_unix.c -CC = gcc -CCOPTS = -Os -pedantic -std=c99 -Wall -fstrict-aliasing -fomit-frame-pointer +CC = gcc +CCOPTS = -Os -pedantic -std=c99 -Wall -fstrict-aliasing -fomit-frame-pointer CCOPTS += -I./prep -I./examples/cmdline -I./examples/debug-trans-socket CCOPTS += -DDUK_CMDLINE_DEBUGGER_SUPPORT # enable --debugger in ./duk -CCLIBS = -lm +CCLIBS = -lm # Enable a few optional modules. CCOPTS += -DDUK_CMDLINE_PRINTALERT_SUPPORT -I./extras/print-alert @@ -28,7 +28,7 @@ # Use tools/configure.py to prepare Duktape config header and sources with # custom configuration. -duk: $(CMDLINE_SOURCES) +duk: $(CMDLINE_SOURCES) @rm -rf prep python2 tools/configure.py \ --source-directory src-input \ diff -Nru duktape-2.3.0/Makefile.eval duktape-2.2.0/Makefile.eval --- duktape-2.3.0/Makefile.eval 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/Makefile.eval 2017-09-23 01:06:08.000000000 +0000 @@ -2,8 +2,6 @@ # Example Makefile for building the eval example # -CC = gcc - eval: - $(CC) -o $@ -std=c99 -O2 -Wall -Wextra -Isrc/ \ + gcc -o $@ -std=c99 -O2 -Wall -Wextra -Isrc/ \ src/duktape.c examples/eval/eval.c -lm diff -Nru duktape-2.3.0/Makefile.eventloop duktape-2.2.0/Makefile.eventloop --- duktape-2.3.0/Makefile.eventloop 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/Makefile.eventloop 2017-09-23 01:06:08.000000000 +0000 @@ -2,14 +2,12 @@ # Example Makefile for building the eventloop example # -CC = gcc - evloop: @echo "NOTE: The eventloop is example is intended to be used on Linux" @echo " or other common UNIX variants. It is not fully portable." @echo "" - $(CC) -o $@ -std=c99 -Wall -Wextra -O2 -Isrc \ + gcc -o $@ -std=c99 -Wall -Wextra -O2 -Isrc \ examples/eventloop/main.c \ examples/eventloop/c_eventloop.c \ examples/eventloop/poll.c \ diff -Nru duktape-2.3.0/Makefile.hello duktape-2.2.0/Makefile.hello --- duktape-2.3.0/Makefile.hello 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/Makefile.hello 2017-09-23 01:06:08.000000000 +0000 @@ -13,10 +13,10 @@ # Compiler options are quite flexible. GCC versions have a significant impact # on the size of -Os code, e.g. gcc-4.6 is much worse than gcc-4.5. -CC = gcc -CCOPTS = -Os -pedantic -std=c99 -Wall -fstrict-aliasing -fomit-frame-pointer +CC = gcc +CCOPTS = -Os -pedantic -std=c99 -Wall -fstrict-aliasing -fomit-frame-pointer CCOPTS += -I./src # for combined sources -CCLIBS = -lm +CCLIBS = -lm DEFINES = # If you want a 32-bit build on a 64-bit host @@ -28,5 +28,5 @@ # For debugging, use -O0 -g -ggdb, and don't add -fomit-frame-pointer -hello: $(DUKTAPE_SOURCES) examples/hello/hello.c +hello: $(DUKTAPE_SOURCES) examples/hello/hello.c $(CC) -o $@ $(DEFINES) $(CCOPTS) $(DUKTAPE_SOURCES) examples/hello/hello.c $(CCLIBS) diff -Nru duktape-2.3.0/Makefile.jsoncbor duktape-2.2.0/Makefile.jsoncbor --- duktape-2.3.0/Makefile.jsoncbor 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/Makefile.jsoncbor 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -# -# Example Makefile for building the jsoncbor example -# - -CC = gcc - -jsoncbor: - $(CC) -o $@ -std=c99 -Wall -Wextra -O2 -Isrc -Iextras/cbor \ - src/duktape.c extras/cbor/duk_cbor.c extras/cbor/jsoncbor.c \ - -lm diff -Nru duktape-2.3.0/Makefile.jxpretty duktape-2.2.0/Makefile.jxpretty --- duktape-2.3.0/Makefile.jxpretty 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/Makefile.jxpretty 2017-09-23 01:06:08.000000000 +0000 @@ -2,9 +2,7 @@ # Example Makefile for building the jxpretty example # -CC = gcc - jxpretty: - $(CC) -o $@ -std=c99 -Wall -Wextra -O2 -Isrc \ + gcc -o $@ -std=c99 -Wall -Wextra -O2 -Isrc \ src/duktape.c examples/jxpretty/jxpretty.c \ -lm diff -Nru duktape-2.3.0/Makefile.sandbox duktape-2.2.0/Makefile.sandbox --- duktape-2.3.0/Makefile.sandbox 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/Makefile.sandbox 2017-09-23 01:06:08.000000000 +0000 @@ -2,8 +2,6 @@ # Example Makefile for building the sandbox example # -CC = gcc - sandbox: - $(CC) -o $@ -std=c99 -O2 -Wall -Wextra -Isrc/ \ + gcc -o $@ -std=c99 -O2 -Wall -Wextra -Isrc/ \ src/duktape.c examples/sandbox/sandbox.c -lm diff -Nru duktape-2.3.0/Makefile.sharedlibrary duktape-2.2.0/Makefile.sharedlibrary --- duktape-2.3.0/Makefile.sharedlibrary 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/Makefile.sharedlibrary 2017-09-23 01:06:08.000000000 +0000 @@ -24,65 +24,48 @@ # convention is to set soname version to (100*MAJOR + MINOR), e.g. 104 for # Duktape 1.4.x, so that it gets automatically bumped for major and minor # releases (potentially binary incompatible), but not for patch releases. -DUK_VERSION = 20300 -SONAME_VERSION = 203 -REAL_VERSION = $(SONAME_VERSION).$(DUK_VERSION) - -# Mac has an unusual .so naming convention -ifeq ($(OS),Windows_NT) - DETECTED_OS := Windows -else - DETECTED_OS := $(shell uname -s) -endif -ifeq ($(DETECTED_OS),Darwin) - LD_SONAME_ARG=-install_name - SO_SONAME_SUFFIX=$(SONAME_VERSION).so - SO_REALNAME_SUFFIX=$(REAL_VERSION).so -else - LD_SONAME_ARG=-soname - SO_SONAME_SUFFIX=so.$(SONAME_VERSION) - SO_REALNAME_SUFFIX=so.$(REAL_VERSION) -endif +DUK_VERSION=20200 +SONAME_VERSION=202 +REAL_VERSION=$(SONAME_VERSION).$(DUK_VERSION) # Change to actual path for actual distribution packaging. -INSTALL_PREFIX = /usr/local +INSTALL_PREFIX=/usr/local # The 'noline' variant may be more appropriate for some distributions; it # doesn't have #line directives in the combined source. -DUKTAPE_SRCDIR = ./src -#DUKTAPE_SRCDIR = ./src-noline - -CC = gcc +DUKTAPE_SRCDIR=./src +#DUKTAPE_SRCDIR=./src-noline .PHONY: all -all: libduktape.$(SO_REALNAME_SUFFIX) libduktaped.$(SO_REALNAME_SUFFIX) +all: libduktape.so.$(REAL_VERSION) libduktaped.so.$(REAL_VERSION) # If the default duk_config.h is not suitable for the distribution, modify it # before compiling the shared library and copy the same, edited duk_config.h # to $INSTALL_PREFIX/include on installation. -libduktape.$(SO_REALNAME_SUFFIX): - $(CC) -shared -fPIC -Wall -Wextra -Os -Wl,$(LD_SONAME_ARG),libduktape.$(SO_SONAME_SUFFIX) \ +libduktape.so.$(REAL_VERSION): + gcc -shared -fPIC -Wall -Wextra -Os -Wl,-soname,libduktape.so.$(SONAME_VERSION) \ -o $@ $(DUKTAPE_SRCDIR)/duktape.c -libduktaped.$(SO_REALNAME_SUFFIX): - $(CC) -shared -fPIC -g -Wall -Wextra -Os -Wl,$(LD_SONAME_ARG),libduktaped.$(SO_SONAME_SUFFIX) \ +libduktaped.so.$(REAL_VERSION): + gcc -shared -fPIC -g -Wall -Wextra -Os -Wl,-soname,libduktaped.so.$(SONAME_VERSION) \ -o $@ $(DUKTAPE_SRCDIR)/duktape.c # Symlinks depend on platform conventions. .PHONY: install -install: libduktape.$(SO_REALNAME_SUFFIX) libduktaped.$(SO_REALNAME_SUFFIX) - mkdir -p $(INSTALL_PREFIX)/lib/ +install: libduktape.so.$(REAL_VERSION) libduktaped.so.$(REAL_VERSION) cp $+ $(INSTALL_PREFIX)/lib/ - rm -f $(INSTALL_PREFIX)/lib/libduktape.so $(INSTALL_PREFIX)/lib/libduktape.$(SO_SONAME_SUFFIX) - ln -s libduktape.$(SO_REALNAME_SUFFIX) $(INSTALL_PREFIX)/lib/libduktape.so - ln -s libduktape.$(SO_REALNAME_SUFFIX) $(INSTALL_PREFIX)/lib/libduktape.$(SO_SONAME_SUFFIX) - rm -f $(INSTALL_PREFIX)/lib/libduktaped.so $(INSTALL_PREFIX)/lib/libduktaped.$(SO_SONAME_SUFFIX) - ln -s libduktaped.$(SO_REALNAME_SUFFIX) $(INSTALL_PREFIX)/lib/libduktaped.so - ln -s libduktaped.$(SO_REALNAME_SUFFIX) $(INSTALL_PREFIX)/lib/libduktaped.$(SO_SONAME_SUFFIX) - mkdir -p $(INSTALL_PREFIX)/include/ + rm -f $(INSTALL_PREFIX)/lib/libduktape.so $(INSTALL_PREFIX)/lib/libduktape.so.$(SONAME_VERSION) + ln -s libduktape.so.$(REAL_VERSION) $(INSTALL_PREFIX)/lib/libduktape.so + ln -s libduktape.so.$(REAL_VERSION) $(INSTALL_PREFIX)/lib/libduktape.so.$(SONAME_VERSION) + rm -f $(INSTALL_PREFIX)/lib/libduktaped.so $(INSTALL_PREFIX)/lib/libduktaped.so.$(SONAME_VERSION) + ln -s libduktaped.so.$(REAL_VERSION) $(INSTALL_PREFIX)/lib/libduktaped.so + ln -s libduktaped.so.$(REAL_VERSION) $(INSTALL_PREFIX)/lib/libduktaped.so.$(SONAME_VERSION) cp $(DUKTAPE_SRCDIR)/duktape.h $(DUKTAPE_SRCDIR)/duk_config.h $(INSTALL_PREFIX)/include/ -CCOPTS = -I./examples/cmdline +# Note: assumes /usr/local/include/ and /usr/local/lib/ are in include/link +# path which may not be the case for all distributions. +#CCOPTS=-I/usr/local/include -L/usr/local/lib +CCOPTS=-I./examples/cmdline duk: - $(CC) $(CCOPTS) -I$(INSTALL_PREFIX)/include -L$(INSTALL_PREFIX)/lib -Wall -Wextra -Os -o $@ ./examples/cmdline/duk_cmdline.c -lduktape -lm + gcc $(CCOPTS) -Wall -Wextra -Os -o $@ ./examples/cmdline/duk_cmdline.c -lduktape -lm diff -Nru duktape-2.3.0/polyfills/promise.js duktape-2.2.0/polyfills/promise.js --- duktape-2.3.0/polyfills/promise.js 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/polyfills/promise.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,607 +0,0 @@ -/* - * Minimal ES2015+ Promise polyfill - * - * Limitations (also see XXX in source): - * - * - Caller must manually call Promise.runQueue() to process pending jobs. - * - No Promise subclassing or non-subclass foreign Promises yet. - * - Promise.all() and Promise.race() assume a plain array, not iterator. - * - Doesn't handle errors from core operations, e.g. out-of-memory or - * internal error when queueing/running jobs. These are implementation - * defined for the most part. - * - * This polyfill was originally used to gain a better understanding of the - * ES2015 specification algorithms, before implementing Promises natively. - * - * The polyfill uses a Symbol to mark Promise instances, but falls back to - * an ordinary (non-enumerable) property if no Symbol support is available. - * Presence of the polyfill itself can be checked using "Promise.isPolyfill". - * - * Unhandled Promise rejections use a custom API signature. For now, a - * single Promise.unhandledRejection() hook receives both 'rawReject' and - * 'rawHandle' events directly from HostPromiseRejectionTracker, and higher - * level (Node.js / WHATWG like) 'reject' and 'handle' events which filter - * out cases where a rejected Promise is initially unhandled but gets handled - * within the same "tick". - * - * See also: https://github.com/stefanpenner/es6-promise#readme - */ - -(function () { - if (typeof Promise !== 'undefined') { return; } - - // As far as the specification goes, almost all Promise settling is via - // concrete resolve/reject functions with mutual protection from being - // called multiple times. Sometimes the actual resolve/reject functions - // are not exposed to calling code, and can safely be omitted which is - // useful because resolve/reject functions are memory heavy. These - // optimizations are enabled by default; set to false to disable. - var allowOptimization = true; - - // Job queue to simulate ES2015 job queues, linked list, 'next' reference. - // While ES2015 doesn't guarantee the relative order of jobs in different - // job queues, within a certain queue strict FIFO is required. See ES5.1 - // https://www.ecma-international.org/ecma-262/6.0/#sec-jobs-and-job-queues: - // "The PendingJob records from a single Job Queue are always initiated in - // FIFO order. This specification does not define the order in which - // multiple Job Queues are serviced." - var queueHead = null, queueTail = null; - function enqueueJob(job) { - // Avoid inheriting conflicting properties if caller already didn't - // ensure it. - Object.setPrototypeOf(job, null); - compact(job); - if (queueHead) { - queueTail.next = job; - compact(queueTail); - queueTail = job; - } else { - queueHead = job; - queueTail = job; - } - } - function dequeueJob() { - var ret = queueHead; - if (ret) { - queueHead = ret.next; - if (!queueHead) { - queueTail = null; - } - } - return ret; - } - function queueEmpty() { - return !queueHead; - } - - // Helper to define/modify properties more compactly. - function def(obj, key, val, attrs) { - if (attrs === void 0) { attrs = 'wc'; } - Object.defineProperty(obj, key, { - value: val, - writable: attrs.indexOf('w') >= 0, - enumerable: attrs.indexOf('e') >= 0, - configurable: attrs.indexOf('c') >= 0 - }); - } - - // Helper for Duktape specific object compaction. - var compact = (typeof Duktape === 'object' && Duktape.compact) || - function (v) { return v; }; - - // Shared no-op function. - var nop = function nop() {}; - - // Promise detection (plain or subclassed Promise), in spec has - // [[PromiseState]] internal slot which isn't affected by Proxy - // behaviors etc. - var haveSymbols = (typeof Symbol === 'function'); - var promiseMarker = haveSymbols ? Symbol('promise') : '__PromiseInstance__'; - function isPromise(p) { - return p !== null && typeof p === 'object' && promiseMarker in p; - } - function requirePromise(p) { - if (!isPromise(p)) { throw new TypeError('Promise required'); } - } - - // Raw HostPromiseRejectionTracker call. This operation should "never" - // fail but that's in practice unachievable due to possible out-of-memory - // on any operation (including invocation of the callback). Higher level - // hook events are emitted from Promise.runQueue(). - function safeCallUnhandledRejection(event) { - try { - cons.unhandledRejection(event); - } catch (e) { - //console.log('Promise.unhandledRejection failed:', e); - } - } - function rejectionTracker(p, operation) { - try { - if (operation === 'reject') { - // Unhandled at resolution. - safeCallUnhandledRejection({ promise: p, event: 'rawReject', reason: p.value }); - def(p, 'unhandled', 1); - cons.potentiallyUnhandled.push(p); - } else if (operation === 'handle') { - safeCallUnhandledRejection({ promise: p, event: 'rawHandle', reason: p.value }); - if (p.unhandled === 2) { - // Unhandled, already notified, need handled notification. - def(p, 'unhandled', 3); - cons.potentiallyUnhandled.push(p); - } else { - // Handled but not yet notified -> no action needed. - // XXX: If this.unhandled was 1, we'd like to remove - // the Promise from cons.potentiallyUnhandled list. - // We skip that here because it would mean an expensive - // list remove. If cons.potentiallyUnhandled was a - // Set, it would be natural to remove from Set here. - delete p.unhandled; - } - } - } catch (e) { - //console.log('HostPromiseRejectionTracker failed:', e); - } - } - - // Raw fulfill/reject operations, assume resolution processing done. - // The specification algorithms RejectPromise() and FulfillPromise() - // assert that the Promise is pending so the initial check in these - // implementations (p.state !== void 0) is not needed: the resolve/reject - // function pairs always ensure a Promise is not ultimately settled twice. - // With some of the "as if" optimizations we rely on these raw operations - // to protect against multiple attempts to settle the Promise so the checks - // are actually needed. - function doFulfill(p, val) { - if (p.state !== void 0) { return; } // additional check needed with optimizations - p.state = true; p.value = val; - var reactions = p.fulfillReactions; - delete p.fulfillReactions; delete p.rejectReactions; compact(p); - reactions.forEach(function (ent) { - // Conceptually: create a job from the registered reaction. - // In practice: reuse the reaction object because it is unique, - // never leaks to calling code, and is never reused. - ent.value = val; - enqueueJob(ent); - }); - } - function doReject(p, val) { - if (p.state !== void 0) { return; } // additional check needed with optimizations - p.state = false; p.value = val; - var reactions = p.rejectReactions; - delete p.fulfillReactions; delete p.rejectReactions; compact(p); - reactions.forEach(function (ent) { - // As for doFulfill(), reuse the registered reaction object. - ent.value = val; - if (!ent.handler) { - // Without a .handler, we're dealing with an optimized - // entry where only .target exists and the resolve/reject - // behavior is simulated when the entry runs. However, - // we need to know whether to simulate resolve or reject - // at that time, so flag rejection explicitly (resolve - // requires no flag). - ent.rejected = true; - } - enqueueJob(ent); - }); - if (!p.isHandled) { - rejectionTracker(p, 'reject'); - } - } - - // Create a new resolve/reject pair for a Promise. Multiple pairs are - // needed in thenable handling, with all but the most recent pair being - // neutralized ('alreadyResolved'). Because Promises are resolved only - // via this resolution process, it shouldn't be possible for the Promise - // to be settled but check it anyway: it may be useful for e.g. the C API - // to forcibly resolve/fulfill/reject a Promise regardless of extant - // resolve/reject functions. - function createResolutionFunctions(p) { - // In ES2015 the resolve/reject functions have a shared 'state' object - // with a [[AlreadyResolved]] slot. Here we use an in-scope variable. - var alreadyResolved = false; - var reject = function (err) { - if (new.target) { throw new TypeError('reject is not constructable'); } - if (alreadyResolved) { return; } - alreadyResolved = true; // neutralize resolve/reject - if (p.state !== void 0) { return; } - doReject(p, err); - }; - reject.prototype = null; // drop .prototype object - var resolve = function (val) { - if (new.target) { throw new TypeError('resolve is not constructable'); } - if (alreadyResolved) { return; } - alreadyResolved = true; // neutralize resolve/reject - if (p.state !== void 0) { return; } - if (val === p) { - return doReject(p, new TypeError('self resolution')); - } - try { - var then = (val !== null && typeof val === 'object' && - val.then); - if (typeof then === 'function') { - var t = createResolutionFunctions(p); - var optimized = allowOptimization; - if (optimized) { - // XXX: this optimization may not be useful because the - // job entry runs usually very quickly, and as part of - // running the job, the resolve/reject function must be - // created for the then() call. - return enqueueJob({ - thenable: val, - then: then, - target: p - }); - } else { - return enqueueJob({ - thenable: val, - then: then, - resolve: t.resolve, - reject: t.reject - }); - } - // old resolve/reject is neutralized, only new pair is live - } - return doFulfill(p, val); - } catch (e) { - return doReject(p, e); - } - }; - resolve.prototype = null; // drop .prototype object - return { resolve: resolve, reject: reject }; - } - - // Job queue simulation. - function runQueueEntry() { - // XXX: In optimized cases, creating both resolution functions is - // not always necessary. There's also no need for alreadySettled - // protections for the optimized cases either. - var job = dequeueJob(); - var tmp; - if (!job) { return false; } - if (job.then) { - // PromiseResolveThenableJob - if (job.target) { - tmp = createResolutionFunctions(job.target); - } - try { - if (tmp) { - void job.then.call(job.thenable, tmp.resolve, tmp.reject); - } else { - void job.then.call(job.thenable, job.resolve, job.reject); - } - } catch (e) { - if (tmp) { - tmp.reject.call(void 0, e); - } else { - job.reject.call(void 0, e); - } - } - } else { - // PromiseReactionJob - try { - if (job.handler === void 0) { - // Optimized case where two Promises are tied together - // without the need for an actual 'handler'. - tmp = createResolutionFunctions(job.target); // must exist in this case - tmp = job.rejected ? tmp.reject : tmp.resolve; - tmp.call(void 0, job.value); - return true; - } else if (job.handler === 'Identity') { - res = job.value; - } else if (job.handler === 'Thrower') { - throw job.value; - } else { - res = job.handler.call(void 0, job.value); - } - if (job.target) { - createResolutionFunctions(job.target).resolve.call(void 0, res); - } else { - job.resolve.call(void 0, res); - } - } catch (e) { - if (job.target) { - createResolutionFunctions(job.target).reject.call(void 0, e); - } else { - job.reject.call(void 0, e); - } - } - } - return true; - } - - // %Promise% constructor. - var cons = function Promise(executor) { - if (!new.target) { - throw new TypeError('Promise must be called as a constructor'); - } - if (typeof executor !== 'function') { - throw new TypeError('executor must be callable'); - } - var _this = this; - def(this, promiseMarker, true, ''); - def(this, 'state', void 0); // undefined (pending), true/false - def(this, 'value', void 0); - def(this, 'fulfillReactions', []); - def(this, 'rejectReactions', []); - def(this, 'isHandled', false); // XXX: roll into 'state' to minimize fields - compact(this); - var t = createResolutionFunctions(this); - try { - void executor(t.resolve, t.reject); - } catch (e) { - t.reject(e); - } - }; - var proto = cons.prototype; - def(cons, 'prototype', proto, ''); - def(cons, 'potentiallyUnhandled', [], ''); - - // %Promise%.resolve(). - // XXX: direct handling - function resolve(val) { - if (isPromise(val) && val.constructor === this) { return val; } - return new Promise(function (resolve, reject) { resolve(val); }); - } - - // %Promise%.reject() - // XXX: direct handling - function reject(val) { - return new Promise(function (resolve, reject) { reject(val); }); - } - - // %Promise%.all(). - function all(list) { - if (!Array.isArray(list)) { - throw new TypeError('non-array all() argument not supported'); - } - var resolveFn, rejectFn; - var p = new Promise(function (resolve, reject) { - resolveFn = resolve; rejectFn = reject; - }); - var values = []; - var index = 0; - var remaining = 1; // remaining intentionally 1, not 0 - list.forEach(function (x) { // XXX: no iterator support - var t = Promise.resolve(x); - var f = function promiseAllElement(val) { - var F = promiseAllElement; - if (F.alreadyCalled) { return; } - F.alreadyCalled = true; - values[F.index] = val; - if (--remaining === 0) { - resolveFn.call(void 0, values); - } - }; - // In ES2015 the functions would reference a shared state object - // explicitly. Here the conceptual state is in scope. - f.index = index++; - remaining++; - t.then(f, rejectFn); - }); - if (--remaining === 0) { - resolveFn.call(void 0, values); - } - return p; - } - - // %Promise%.race(). - function race(list) { - if (!Array.isArray(list)) { - throw new TypeError('non-array race() argument not supported'); - } - var resolveFn, rejectFn; - var p = new Promise(function (resolve, reject) { - resolveFn = resolve; rejectFn = reject; - }); - list.forEach(function (x) { // XXX: no iterator support - var t = Promise.resolve(x); - var func = t.then; - var optimized = (func === then) && allowOptimization; - if (optimized) { - // If the .then() of the Promise.resolve() is the original - // built-in implementation, we don't need to queue the actual - // resolve and reject functions explicitly because (1) the - // functions don't leak and can't be called by anyone else, - // and (2) the onFulfilled/onRejected functions would just - // directly forward the result from 't' to 'p'. - optimizedThen(t, p); - } else { - // Generic case, the result Promise of .then() is ignored. - void func.call(t, resolveFn, rejectFn); - } - }); - return p; - } - - // %PromisePrototype%.then(), also used for .catch(). - function then(onFulfilled, onRejected) { - // No subclassing support here now, no NewPromiseCapability() handling. - requirePromise(this); - var resolveFn, rejectFn; - var p = new Promise(function (resolve, reject) { - resolveFn = resolve; rejectFn = reject; - }); - var optimized = allowOptimization; - if (typeof onFulfilled !== 'function') { onFulfilled = 'Identity'; } - if (typeof onRejected !== 'function') { onRejected = 'Thrower'; } - - if (this.state === void 0) { // pending - if (optimized) { - this.fulfillReactions.push({ - handler: onFulfilled, - target: p - }); - this.rejectReactions.push({ - handler: onRejected, - target: p - }); - } else { - this.fulfillReactions.push({ - handler: onFulfilled, - resolve: resolveFn, - reject: rejectFn - }); - this.rejectReactions.push({ - handler: onRejected, - resolve: resolveFn, - reject: rejectFn - }); - } - } else if (this.state) { // fulfilled - if (optimized) { - enqueueJob({ - handler: onFulfilled, - target: p, - value: this.value - }); - } else { - enqueueJob({ - handler: onFulfilled, - resolve: resolveFn, - reject: rejectFn, - value: this.value - }); - } - } else { // rejected - if (!this.isHandled) { - rejectionTracker(this, 'handle'); - } - if (optimized) { - enqueueJob({ - handler: onRejected, - target: p, - value: this.value - }); - } else { - enqueueJob({ - handler: onRejected, - resolve: resolveFn, - reject: rejectFn, - value: this.value - }); - } - } - this.isHandled = true; - return p; - } - - // Optimized .then() where a specific source Promise just forwards its - // result to a target Promise unless its already settled. - function optimizedThen(source, target) { - if (source.state === void 0) { // pending - source.fulfillReactions.push({ - target: target - }); - source.rejectReactions.push({ - target: target - }); - } else if (source.state) { // fulfilled - enqueueJob({ - target: target, - value: source.value - }); - } else { // rejected - if (!source.isHandled) { - rejectionTracker(source, 'handle'); - } - enqueueJob({ - target: target, - value: source.value, - rejected: true - }); - } - source.isHandled = true; - } - - // %PromisePrototype%.catch. - var _catch = function (onRejected) { - return this.then.call(this, void 0, onRejected); - }; - def(_catch, 'name', 'catch', 'c'); - - // %Promise%.try(), https://github.com/tc39/proposal-promise-try, - // simple polyfill-style implementation. - var _try = function (func) { - // XXX: check 'this' for callability, or Promise / subclass. - return new this(function (resolve, reject) { resolve(func()); }); - }; - def(_try, 'name', 'try', 'c'); - - // Emit higher level Node.js/WHATWG like 'reject' and 'handle' events, - // filtering out some cases where a rejected Promise is initially unhandled - // but is handled within the same "tick" (for a relatively murky definition - // of a "tick"). - // https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections - // https://www.ecma-international.org/ecma-262/8.0/#sec-host-promise-rejection-tracker - function checkUnhandledRejections() { - var idx; - - // The unhandledRejection() callbacks may have queued more Promises, - // settled existing Promises on the list, etc. Keep going until - // the list is empty. Null out entries to allow early GC when the - // Promises are no longer reachable. Callbacks may also queue more - // ordinary Promise jobs; they are also handled to completion within - // the tick. - - // XXX: It might be more natural to handle the notification callbacks - // via the job queue. This might be a bit simpler, but would change - // the Promise job vs. unhandledRejection callback ordering a bit. - // For example, Node.js emits 'handle' events before the related - // catch callbacks are called, while the polyfill in its current - // state does not. - - for (idx = 0; idx < cons.potentiallyUnhandled.length; idx++) { - var p = cons.potentiallyUnhandled[idx]; - cons.potentiallyUnhandled[idx] = null; - - // For consistency with hook calls from HostPromiseRejectionTracker - // errors from user callback are silently eaten. If a process exit - // is desirable, user callback may call a custom native binding to - // do that ("process.exit(1)" or similar). - // - // Use a custom object argument convention for flexibility. - - if (p.unhandled === 1) { - safeCallUnhandledRejection({ promise: p, event: 'reject', reason: p.value }); - def(p, 'unhandled', 2); - } else if (p.unhandled === 3) { - safeCallUnhandledRejection({ promise: p, event: 'handle', reason: p.value }); - delete p.unhandled; - } - } - - cons.potentiallyUnhandled.length = 0; - - return idx > 0; // true if we processed entries - } - - // Define visible objects and properties. - (function () { - def(this, 'Promise', cons); - def(cons, 'resolve', resolve); - def(cons, 'reject', reject); - def(cons, 'all', all); - def(cons, 'race', race); - def(cons, 'try', _try); - def(cons, 'isPolyfill', true); // needed by e.g. testcases - def(proto, 'then', then); - def(proto, 'catch', _catch); - if (haveSymbols) { - def(proto, Symbol.toStringTag, 'Promise', 'c'); - } - - // Custom API to drive the "job queue". We only want to exit when - // there are no more Promise jobs or unhandledRejection() callbacks, - // i.e. no more work to do. Note that an unhandledRejection() - // callback may queue more Promise job entries and vice versa. - def(cons, 'runQueue', function _runQueueUntilEmpty() { - do { - while (runQueueEntry()) {} - checkUnhandledRejections(); - } while(!(queueEmpty() && cons.potentiallyUnhandled.length === 0)); - }); - def(cons, 'unhandledRejection', nop); - - compact(this); compact(cons); compact(proto); - }()); -}()); diff -Nru duktape-2.3.0/README.rst duktape-2.2.0/README.rst --- duktape-2.3.0/README.rst 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/README.rst 2017-09-23 01:06:08.000000000 +0000 @@ -2,13 +2,13 @@ Duktape ======= -Duktape is a small and portable ECMAScript E5/E5.1 implementation. It is +Duktape is a small and portable Ecmascript E5/E5.1 implementation. It is intended to be easily embeddable into C programs, with a C API similar in spirit to Lua's. Duktape supports the full E5/E5.1 feature set (with some semantics updated from ES2015+) including errors, Unicode strings, and regular expressions, -a subset of ECMAScript 2015 (E6) and ECMAScript 2016 (E7) features (e.g. +a subset of Ecmascript 2015 (E6) and Ecmascript 2016 (E7) features (e.g. computed property names, Proxy objects, exponentiation operator, Reflect), ES2015 ArrayBuffer/TypedView, Node.js Buffer, performance.now(), and WHATWG Encoding API living standard. @@ -118,11 +118,11 @@ * https://github.com/svaarala/duktape/blob/master/RELEASES.rst (summary of all versions) -* https://github.com/svaarala/duktape/blob/master/doc/release-notes-v2-3.rst +* https://github.com/svaarala/duktape/blob/master/doc/release-notes-v2-2.rst (more detailed notes for this version) -This distributable contains Duktape version 2.3.0, created from git -commit d7fdb67f18561a50e06bafd196c6b423af9ad6fe (v2.3.0). +This distributable contains Duktape version 2.2.0, created from git +commit a459cf3c9bd1779fc01b435d69302b742675a08f (v2.2.0). Duktape is copyrighted by its authors (see ``AUTHORS.rst``) and licensed under the MIT license (see ``LICENSE.txt``). String hashing algorithms are diff -Nru duktape-2.3.0/src/duk_config.h duktape-2.2.0/src/duk_config.h --- duktape-2.3.0/src/duk_config.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src/duk_config.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,8 +1,8 @@ /* * duk_config.h configuration header generated by genconfig.py. * - * Git commit: d7fdb67f18561a50e06bafd196c6b423af9ad6fe - * Git describe: v2.3.0 + * Git commit: a459cf3c9bd1779fc01b435d69302b742675a08f + * Git describe: v2.2.0 * Git branch: master * * Supported platforms: @@ -218,6 +218,12 @@ #define DUK_F_UNIX #endif +/* C++ */ +#undef DUK_F_CPP +#if defined(__cplusplus) +#define DUK_F_CPP +#endif + /* Intel x86 (32-bit), x64 (64-bit) or x32 (64-bit but 32-bit pointers), * define only one of DUK_F_X86, DUK_F_X64, DUK_F_X32. * https://sites.google.com/site/x32abi/ @@ -295,12 +301,6 @@ #define DUK_F_CLANG #endif -/* C++ */ -#undef DUK_F_CPP -#if defined(__cplusplus) -#define DUK_F_CPP -#endif - /* C99 or above */ #undef DUK_F_C99 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) @@ -836,7 +836,9 @@ #include #endif -/* is only included if needed, based on DUK_USE_xxx flags. */ +#if defined(DUK_F_CPP) +#include /* std::exception */ +#endif /* * Architecture autodetection @@ -848,16 +850,13 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif - -#define DUK_USE_PACKED_TVAL - -/* FreeBSD, -m32, and clang prior to 5.0 has union aliasing issues which - * break duk_tval copying. Disable packed duk_tval automatically. +/* XXX: This is technically not guaranteed because it's possible to configure + * an x86 to require aligned accesses with Alignment Check (AC) flag. */ -#if defined(DUK_F_FREEBSD) && defined(DUK_F_X86) && \ - defined(__clang__) && defined(__clang_major__) && (__clang_major__ < 5) -#undef DUK_USE_PACKED_TVAL +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 1 #endif +#define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_X64) /* --- x64 --- */ @@ -865,6 +864,12 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif +/* XXX: This is technically not guaranteed because it's possible to configure + * an x86 to require aligned accesses with Alignment Check (AC) flag. + */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 1 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_X32) @@ -873,30 +878,48 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif +/* XXX: This is technically not guaranteed because it's possible to configure + * an x86 to require aligned accesses with Alignment Check (AC) flag. + */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 1 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_ARM32) /* --- ARM 32-bit --- */ #define DUK_USE_ARCH_STRING "arm32" /* Byte order varies, so rely on autodetect. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 4 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_ARM64) /* --- ARM 64-bit --- */ #define DUK_USE_ARCH_STRING "arm64" /* Byte order varies, so rely on autodetect. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_MIPS32) /* --- MIPS 32-bit --- */ #define DUK_USE_ARCH_STRING "mips32" /* MIPS byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_MIPS64) /* --- MIPS 64-bit --- */ #define DUK_USE_ARCH_STRING "mips64" /* MIPS byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_PPC32) @@ -905,6 +928,9 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_PPC64) @@ -913,24 +939,39 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_SPARC32) /* --- SPARC 32-bit --- */ #define DUK_USE_ARCH_STRING "sparc32" /* SPARC byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_SPARC64) /* --- SPARC 64-bit --- */ #define DUK_USE_ARCH_STRING "sparc64" /* SPARC byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_SUPERH) /* --- SuperH --- */ #define DUK_USE_ARCH_STRING "sh" /* Byte order varies, rely on autodetection. */ +/* Based on 'make checkalign' there are no alignment requirements on + * Linux SH4, but align by 4 is probably a good basic default. + */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 4 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_M68K) @@ -939,6 +980,9 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_EMSCRIPTEN) @@ -947,6 +991,9 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #else @@ -1958,8 +2005,8 @@ /* Boolean values are represented with the platform 'unsigned int'. */ typedef duk_small_uint_t duk_bool_t; -#define DUK_BOOL_MIN DUK_SMALL_UINT_MIN -#define DUK_BOOL_MAX DUK_SMALL_UINT_MAX +#define DUK_BOOL_MIN DUK_SMALL_INT_MIN +#define DUK_BOOL_MAX DUK_SMALL_INT_MAX /* Index values must have at least 32-bit signed range. */ typedef duk_int_t duk_idx_t; @@ -2493,13 +2540,10 @@ * * Assume unaligned accesses are not supported unless specifically allowed * in the target platform. Some platforms may support unaligned accesses - * but alignment to 4 or 8 may still be desirable. Note that unaligned - * accesses (and even pointers) relative to natural alignment (regardless - * of target alignment) are technically undefined behavior and thus - * compiler/architecture specific. + * but alignment to 4 or 8 may still be desirable. */ -/* If not forced, use safe default for alignment. */ +/* If not provided, use safe default for alignment. */ #if !defined(DUK_USE_ALIGN_BY) #define DUK_USE_ALIGN_BY 8 #endif @@ -2551,7 +2595,6 @@ */ #define DUK_CAUSE_SEGFAULT() do { *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; } while (0) #endif - #if !defined(DUK_UNREF) /* Macro for suppressing warnings for potentially unreferenced variables. * The variables can be actually unreferenced or unreferenced in some @@ -2561,24 +2604,9 @@ */ #define DUK_UNREF(x) do { (void) (x); } while (0) #endif - -/* Fillin for DUK_NORETURN; DUK_WO_NORETURN() is used to insert dummy - * dummy statements after noreturn calls to silence harmless compiler - * warnings, e.g.: - * - * DUK_ERROR_TYPE(thr, "aiee"); - * DUK_WO_NORETURN(return 0;); - * - * Statements inside DUK_WO_NORETURN() must NEVER be actually reachable, - * and they're only included to satisfy the compiler. - */ -#if defined(DUK_NORETURN) -#define DUK_WO_NORETURN(stmt) do { } while (0) -#else +#if !defined(DUK_NORETURN) #define DUK_NORETURN(decl) decl -#define DUK_WO_NORETURN(stmt) do { stmt } while (0) #endif - #if !defined(DUK_UNREACHABLE) /* Don't know how to declare unreachable point, so don't do it; this * may cause some spurious compilation warnings (e.g. "variable used @@ -2586,7 +2614,6 @@ */ #define DUK_UNREACHABLE() do { } while (0) #endif - #if !defined(DUK_LOSE_CONST) /* Convert any input pointer into a "void *", losing a const qualifier. * This is not fully portable because casting through duk_uintptr_t may @@ -2754,8 +2781,8 @@ #if defined(DUK_F_PACKED_TVAL_POSSIBLE) #define DUK_USE_PACKED_TVAL #endif -#undef DUK_F_PACKED_TVAL_POSSIBLE +#undef DUK_F_PACKED_TVAL_POSSIBLE #endif /* DUK_F_PACKED_TVAL_PROVIDED */ /* Object property allocation layout has implications for memory and code * footprint and generated code size/speed. The best layout also depends @@ -2790,7 +2817,6 @@ * Autogenerated defaults */ -#undef DUK_USE_ALLOW_UNDEFINED_BEHAVIOR #define DUK_USE_ARRAY_BUILTIN #define DUK_USE_ARRAY_FASTPATH #define DUK_USE_ARRAY_PROP_FASTPATH @@ -2799,7 +2825,6 @@ #define DUK_USE_AUGMENT_ERROR_THROW #define DUK_USE_AVOID_PLATFORM_FUNCPTRS #define DUK_USE_BASE64_FASTPATH -#define DUK_USE_BASE64_SUPPORT #define DUK_USE_BOOLEAN_BUILTIN #define DUK_USE_BUFFEROBJECT_SUPPORT #undef DUK_USE_BUFLEN16 @@ -2877,7 +2902,6 @@ #undef DUK_USE_HEAPPTR_DEC16 #undef DUK_USE_HEAPPTR_ENC16 #define DUK_USE_HEX_FASTPATH -#define DUK_USE_HEX_SUPPORT #define DUK_USE_HOBJECT_ARRAY_ABANDON_LIMIT 2 #define DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT 9 #define DUK_USE_HOBJECT_ARRAY_MINGROW_ADD 16 @@ -2908,10 +2932,11 @@ #define DUK_USE_JX #define DUK_USE_LEXER_SLIDING_WINDOW #undef DUK_USE_LIGHTFUNC_BUILTINS -#define DUK_USE_LITCACHE_SIZE 256 #define DUK_USE_MARK_AND_SWEEP_RECLIMIT 256 #define DUK_USE_MATH_BUILTIN #define DUK_USE_NATIVE_CALL_RECLIMIT 1000 +#define DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER +#define DUK_USE_NONSTD_ARRAY_MAP_TRAILER #define DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT #undef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY #undef DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY @@ -2987,15 +3012,6 @@ /* __OVERRIDE_DEFINES__ */ /* - * Conditional includes - */ - -#if defined(DUK_F_CPP) && defined(DUK_USE_CPP_EXCEPTIONS) -#include /* std::exception */ -#include /* std::runtime_error */ -#endif - -/* * Date provider selection * * User may define DUK_USE_DATE_GET_NOW() etc directly, in which case we'll @@ -3536,12 +3552,6 @@ #if defined(DUK_USE_MS_STRINGTABLE_RESIZE) #error unsupported config option used (option has been removed): DUK_USE_MS_STRINGTABLE_RESIZE #endif -#if defined(DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER) -#error unsupported config option used (option has been removed): DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER -#endif -#if defined(DUK_USE_NONSTD_ARRAY_MAP_TRAILER) -#error unsupported config option used (option has been removed): DUK_USE_NONSTD_ARRAY_MAP_TRAILER -#endif #if defined(DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE) #error unsupported config option used (option has been removed): DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE #endif diff -Nru duktape-2.3.0/src/duk_source_meta.json duktape-2.2.0/src/duk_source_meta.json --- duktape-2.3.0/src/duk_source_meta.json 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src/duk_source_meta.json 2017-09-23 01:06:08.000000000 +0000 @@ -1,702 +1,682 @@ { "comment": "Metadata for Duktape sources", - "duk_version_string": "2.3.0", + "duk_version_string": "2.2.0", "type": "duk_source_meta", "line_map": [ { "original_line": 1, - "combined_line": 144, + "combined_line": 134, "original_file": "duk_replacements.c" }, { "original_line": 1, - "combined_line": 154, + "combined_line": 144, "original_file": "duk_internal.h" }, { "original_line": 1, - "combined_line": 199, + "combined_line": 189, "original_file": "duk_dblunion.h" }, { "original_line": 1, - "combined_line": 624, + "combined_line": 614, "original_file": "duk_replacements.h" }, { "original_line": 1, - "combined_line": 655, + "combined_line": 645, "original_file": "duk_jmpbuf.h" }, { "original_line": 1, - "combined_line": 681, + "combined_line": 671, "original_file": "duk_exception.h" }, { "original_line": 1, - "combined_line": 713, + "combined_line": 691, "original_file": "duk_forwdecl.h" }, { "original_line": 1, - "combined_line": 849, + "combined_line": 825, "original_file": "duk_tval.h" }, { "original_line": 1, - "combined_line": 1483, + "combined_line": 1459, "original_file": "duk_builtins.h" }, { "original_line": 51, - "combined_line": 2264, + "combined_line": 2227, "original_file": "duk_internal.h" }, { "original_line": 1, - "combined_line": 2267, + "combined_line": 2230, "original_file": "duk_util.h" }, { "original_line": 1, - "combined_line": 2979, + "combined_line": 2796, "original_file": "duk_strings.h" }, { "original_line": 1, - "combined_line": 3148, + "combined_line": 2965, "original_file": "duk_js_bytecode.h" }, { "original_line": 1, - "combined_line": 3632, + "combined_line": 3449, "original_file": "duk_lexer.h" }, { "original_line": 1, - "combined_line": 4072, + "combined_line": 3889, "original_file": "duk_js_compiler.h" }, { "original_line": 1, - "combined_line": 4301, + "combined_line": 4117, "original_file": "duk_regexp.h" }, { "original_line": 1, - "combined_line": 4387, + "combined_line": 4203, "original_file": "duk_heaphdr.h" }, { "original_line": 1, - "combined_line": 4694, + "combined_line": 4510, "original_file": "duk_refcount.h" }, { "original_line": 1, - "combined_line": 5421, + "combined_line": 5237, "original_file": "duk_api_internal.h" }, { "original_line": 1, - "combined_line": 5779, + "combined_line": 5587, "original_file": "duk_hstring.h" }, { "original_line": 1, - "combined_line": 6026, + "combined_line": 5827, "original_file": "duk_hobject.h" }, { "original_line": 1, - "combined_line": 7026, + "combined_line": 6827, "original_file": "duk_hcompfunc.h" }, { "original_line": 1, - "combined_line": 7298, + "combined_line": 7099, "original_file": "duk_hnatfunc.h" }, { "original_line": 1, - "combined_line": 7332, + "combined_line": 7133, "original_file": "duk_hboundfunc.h" }, { "original_line": 1, - "combined_line": 7374, + "combined_line": 7175, "original_file": "duk_hbufobj.h" }, { "original_line": 1, - "combined_line": 7519, + "combined_line": 7319, "original_file": "duk_hthread.h" }, { "original_line": 1, - "combined_line": 7942, + "combined_line": 7742, "original_file": "duk_harray.h" }, { "original_line": 1, - "combined_line": 7991, + "combined_line": 7791, "original_file": "duk_henv.h" }, { "original_line": 1, - "combined_line": 8041, + "combined_line": 7841, "original_file": "duk_hbuffer.h" }, { "original_line": 1, - "combined_line": 8371, + "combined_line": 8168, "original_file": "duk_hproxy.h" }, { "original_line": 1, - "combined_line": 8399, + "combined_line": 8196, "original_file": "duk_heap.h" }, { "original_line": 1, - "combined_line": 9110, + "combined_line": 8884, "original_file": "duk_debugger.h" }, { "original_line": 1, - "combined_line": 9263, + "combined_line": 9037, "original_file": "duk_debug.h" }, { "original_line": 1, - "combined_line": 9449, + "combined_line": 9223, "original_file": "duk_error.h" }, { "original_line": 1, - "combined_line": 9968, + "combined_line": 9742, "original_file": "duk_unicode.h" }, { "original_line": 1, - "combined_line": 10259, + "combined_line": 10033, "original_file": "duk_json.h" }, { "original_line": 1, - "combined_line": 10329, + "combined_line": 10103, "original_file": "duk_js.h" }, { "original_line": 1, - "combined_line": 10444, + "combined_line": 10215, "original_file": "duk_numconv.h" }, { "original_line": 1, - "combined_line": 10550, + "combined_line": 10317, "original_file": "duk_bi_protos.h" }, { "original_line": 1, - "combined_line": 10633, + "combined_line": 10400, "original_file": "duk_selftest.h" }, { "original_line": 82, - "combined_line": 10649, + "combined_line": 10416, "original_file": "duk_internal.h" }, { "original_line": 10, - "combined_line": 10652, + "combined_line": 10419, "original_file": "duk_replacements.c" }, { "original_line": 1, - "combined_line": 10726, + "combined_line": 10493, "original_file": "duk_debug_macros.c" }, { "original_line": 1, - "combined_line": 10818, + "combined_line": 10585, "original_file": "duk_builtins.c" }, { "original_line": 1, - "combined_line": 11648, + "combined_line": 11389, "original_file": "duk_error_macros.c" }, { "original_line": 1, - "combined_line": 11804, + "combined_line": 11537, "original_file": "duk_unicode_support.c" }, { "original_line": 1, - "combined_line": 12986, + "combined_line": 12720, "original_file": "duk_util_misc.c" }, { "original_line": 1, - "combined_line": 13170, + "combined_line": 13126, "original_file": "duk_hobject_class.c" }, { "original_line": 1, - "combined_line": 13300, + "combined_line": 13256, "original_file": "duk_alloc_default.c" }, { "original_line": 1, - "combined_line": 13335, + "combined_line": 13291, "original_file": "duk_api_buffer.c" }, { "original_line": 1, - "combined_line": 13409, + "combined_line": 13362, "original_file": "duk_api_bytecode.c" }, { "original_line": 1, - "combined_line": 14184, + "combined_line": 14136, "original_file": "duk_api_call.c" }, { "original_line": 1, - "combined_line": 14706, + "combined_line": 14656, "original_file": "duk_api_codec.c" }, { "original_line": 1, - "combined_line": 15619, + "combined_line": 15314, "original_file": "duk_api_compile.c" }, { "original_line": 1, - "combined_line": 15792, + "combined_line": 15486, "original_file": "duk_api_debug.c" }, { "original_line": 1, - "combined_line": 16054, + "combined_line": 15745, "original_file": "duk_api_heap.c" }, { "original_line": 1, - "combined_line": 16260, + "combined_line": 15951, "original_file": "duk_api_inspect.c" }, { "original_line": 1, - "combined_line": 16506, + "combined_line": 16197, "original_file": "duk_api_memory.c" }, { "original_line": 1, - "combined_line": 16587, + "combined_line": 16278, "original_file": "duk_api_object.c" }, { "original_line": 1, - "combined_line": 17549, - "original_file": "duk_api_random.c" - }, - { - "original_line": 1, - "combined_line": 17559, + "combined_line": 17110, "original_file": "duk_api_stack.c" }, { "original_line": 1, - "combined_line": 24431, + "combined_line": 23708, "original_file": "duk_api_string.c" }, { "original_line": 1, - "combined_line": 24810, + "combined_line": 24085, "original_file": "duk_api_time.c" }, { "original_line": 1, - "combined_line": 24921, + "combined_line": 24196, "original_file": "duk_bi_array.c" }, { "original_line": 1, - "combined_line": 26578, + "combined_line": 25816, "original_file": "duk_bi_boolean.c" }, { "original_line": 1, - "combined_line": 26648, + "combined_line": 25886, "original_file": "duk_bi_buffer.c" }, { "original_line": 1, - "combined_line": 29584, + "combined_line": 28808, "original_file": "duk_bi_date.c" }, { "original_line": 1, - "combined_line": 31395, + "combined_line": 30582, "original_file": "duk_bi_date_unix.c" }, { "original_line": 1, - "combined_line": 31725, + "combined_line": 30912, "original_file": "duk_bi_date_windows.c" }, { "original_line": 1, - "combined_line": 31925, + "combined_line": 31096, "original_file": "duk_bi_duktape.c" }, { "original_line": 1, - "combined_line": 32084, + "combined_line": 31255, "original_file": "duk_bi_encoding.c" }, { "original_line": 1, - "combined_line": 32623, + "combined_line": 31792, "original_file": "duk_bi_error.c" }, { "original_line": 1, - "combined_line": 33016, + "combined_line": 32185, "original_file": "duk_bi_function.c" }, { "original_line": 1, - "combined_line": 33470, + "combined_line": 32628, "original_file": "duk_bi_global.c" }, { "original_line": 1, - "combined_line": 34202, + "combined_line": 33357, "original_file": "duk_bi_json.c" }, { "original_line": 1, - "combined_line": 37472, + "combined_line": 36620, "original_file": "duk_bi_math.c" }, { "original_line": 1, - "combined_line": 37991, + "combined_line": 37139, "original_file": "duk_bi_number.c" }, { "original_line": 1, - "combined_line": 38272, + "combined_line": 37380, "original_file": "duk_bi_object.c" }, { "original_line": 1, - "combined_line": 39076, + "combined_line": 38186, "original_file": "duk_bi_performance.c" }, { "original_line": 1, - "combined_line": 39108, + "combined_line": 38218, "original_file": "duk_bi_pointer.c" }, { "original_line": 1, - "combined_line": 39184, + "combined_line": 38294, "original_file": "duk_bi_promise.c" }, { "original_line": 1, - "combined_line": 39229, + "combined_line": 38339, "original_file": "duk_bi_proxy.c" }, { "original_line": 1, - "combined_line": 39326, + "combined_line": 38435, "original_file": "duk_bi_reflect.c" }, { "original_line": 1, - "combined_line": 39426, + "combined_line": 38533, "original_file": "duk_bi_regexp.c" }, { "original_line": 1, - "combined_line": 39653, + "combined_line": 38760, "original_file": "duk_bi_string.c" }, { "original_line": 1, - "combined_line": 41234, + "combined_line": 40315, "original_file": "duk_bi_symbol.c" }, { "original_line": 1, - "combined_line": 41406, + "combined_line": 40486, "original_file": "duk_bi_thread.c" }, { "original_line": 1, - "combined_line": 41721, + "combined_line": 40799, "original_file": "duk_bi_thrower.c" }, { "original_line": 1, - "combined_line": 41731, + "combined_line": 40809, "original_file": "duk_debug_fixedbuffer.c" }, { "original_line": 1, - "combined_line": 41801, + "combined_line": 40879, "original_file": "duk_debug_vsnprintf.c" }, { "original_line": 1, - "combined_line": 42851, + "combined_line": 41928, "original_file": "duk_debugger.c" }, { "original_line": 1, - "combined_line": 45759, + "combined_line": 44836, "original_file": "duk_error_augment.c" }, { "original_line": 1, - "combined_line": 46322, + "combined_line": 45400, "original_file": "duk_error_longjmp.c" }, { "original_line": 1, - "combined_line": 46426, + "combined_line": 45507, "original_file": "duk_error_misc.c" }, { "original_line": 1, - "combined_line": 46601, + "combined_line": 45682, "original_file": "duk_error_throw.c" }, { "original_line": 1, - "combined_line": 46764, + "combined_line": 45845, "original_file": "duk_hbuffer_alloc.c" }, { "original_line": 1, - "combined_line": 46897, + "combined_line": 45978, "original_file": "duk_hbuffer_ops.c" }, { "original_line": 2, - "combined_line": 46977, + "combined_line": 46056, "original_file": "duk_hbufobj_misc.c" }, { "original_line": 1, - "combined_line": 46997, + "combined_line": 46076, "original_file": "duk_heap_alloc.c" }, { "original_line": 1, - "combined_line": 48219, + "combined_line": 47280, "original_file": "duk_heap_finalize.c" }, { "original_line": 1, - "combined_line": 48665, + "combined_line": 47726, "original_file": "duk_heap_hashstring.c" }, { "original_line": 1, - "combined_line": 48787, + "combined_line": 47848, "original_file": "duk_heap_markandsweep.c" }, { "original_line": 1, - "combined_line": 50226, + "combined_line": 49223, "original_file": "duk_heap_memory.c" }, { "original_line": 1, - "combined_line": 50592, + "combined_line": 49590, "original_file": "duk_heap_misc.c" }, { "original_line": 1, - "combined_line": 50774, + "combined_line": 49772, "original_file": "duk_heap_refcount.c" }, { "original_line": 1, - "combined_line": 51617, + "combined_line": 50615, "original_file": "duk_heap_stringcache.c" }, { "original_line": 1, - "combined_line": 51927, + "combined_line": 50925, "original_file": "duk_heap_stringtable.c" }, { "original_line": 1, - "combined_line": 52977, + "combined_line": 51915, "original_file": "duk_hobject_alloc.c" }, { "original_line": 1, - "combined_line": 53249, + "combined_line": 52186, "original_file": "duk_hobject_enum.c" }, { "original_line": 1, - "combined_line": 53952, + "combined_line": 52889, "original_file": "duk_hobject_misc.c" }, { "original_line": 1, - "combined_line": 54006, + "combined_line": 52942, "original_file": "duk_hobject_pc2line.c" }, { "original_line": 1, - "combined_line": 54251, + "combined_line": 53187, "original_file": "duk_hobject_props.c" }, { "original_line": 1, - "combined_line": 60368, + "combined_line": 59282, "original_file": "duk_hstring_misc.c" }, { "original_line": 1, - "combined_line": 60565, + "combined_line": 59479, "original_file": "duk_hthread_alloc.c" }, { "original_line": 1, - "combined_line": 60625, + "combined_line": 59539, "original_file": "duk_hthread_builtins.c" }, { "original_line": 1, - "combined_line": 61511, + "combined_line": 60414, "original_file": "duk_hthread_misc.c" }, { "original_line": 1, - "combined_line": 61609, + "combined_line": 60512, "original_file": "duk_hthread_stacks.c" }, { "original_line": 1, - "combined_line": 62017, + "combined_line": 60920, "original_file": "duk_js_arith.c" }, { "original_line": 1, - "combined_line": 62155, + "combined_line": 61058, "original_file": "duk_js_call.c" }, { "original_line": 1, - "combined_line": 65041, + "combined_line": 63921, "original_file": "duk_js_compiler.c" }, { "original_line": 1, - "combined_line": 73149, + "combined_line": 71956, "original_file": "duk_js_executor.c" }, { "original_line": 1, - "combined_line": 78370, + "combined_line": 77178, "original_file": "duk_js_ops.c" }, { "original_line": 1, - "combined_line": 79828, + "combined_line": 78610, "original_file": "duk_js_var.c" }, { "original_line": 1, - "combined_line": 81585, + "combined_line": 80364, "original_file": "duk_lexer.c" }, { "original_line": 1, - "combined_line": 84047, + "combined_line": 82824, "original_file": "duk_numconv.c" }, { "original_line": 1, - "combined_line": 86324, + "combined_line": 85101, "original_file": "duk_regexp_compiler.c" }, { "original_line": 1, - "combined_line": 87615, + "combined_line": 86384, "original_file": "duk_regexp_executor.c" }, { "original_line": 1, - "combined_line": 88642, + "combined_line": 87409, "original_file": "duk_selftest.c" }, { "original_line": 2, - "combined_line": 89288, + "combined_line": 88055, "original_file": "duk_tval.c" }, { "original_line": 1, - "combined_line": 89430, + "combined_line": 88197, "original_file": "duk_unicode_tables.c" }, { "original_line": 1, - "combined_line": 95597, + "combined_line": 94362, "original_file": "duk_util_bitdecoder.c" }, { "original_line": 1, - "combined_line": 95764, + "combined_line": 94529, "original_file": "duk_util_bitencoder.c" }, { "original_line": 1, - "combined_line": 95808, + "combined_line": 94573, "original_file": "duk_util_bufwriter.c" }, { "original_line": 1, - "combined_line": 96168, - "original_file": "duk_util_cast.c" - }, - { - "original_line": 1, - "combined_line": 96337, - "original_file": "duk_util_double.c" - }, - { - "original_line": 1, - "combined_line": 96572, + "combined_line": 94926, "original_file": "duk_util_hashbytes.c" }, { "original_line": 1, - "combined_line": 96634, - "original_file": "duk_util_memory.c" - }, - { - "original_line": 1, - "combined_line": 96671, + "combined_line": 94988, "original_file": "duk_util_tinyrandom.c" } ], - "duk_version": 20300, + "duk_version": 20200, "git_branch": "master", - "git_commit": "d7fdb67f18561a50e06bafd196c6b423af9ad6fe", + "git_commit": "a459cf3c9bd1779fc01b435d69302b742675a08f", "builtin_strings_info": [ { "plain": "Undefined", @@ -1079,26 +1059,6 @@ "define": "DUK_STRIDX_OWN_KEYS" }, { - "plain": "\u0081Symbol.toPrimitive\u00ff", - "base64": "gVN5bWJvbC50b1ByaW1pdGl2Zf8=", - "define": "DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE" - }, - { - "plain": "\u0081Symbol.hasInstance\u00ff", - "base64": "gVN5bWJvbC5oYXNJbnN0YW5jZf8=", - "define": "DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE" - }, - { - "plain": "\u0081Symbol.toStringTag\u00ff", - "base64": "gVN5bWJvbC50b1N0cmluZ1RhZ/8=", - "define": "DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG" - }, - { - "plain": "\u0081Symbol.isConcatSpreadable\u00ff", - "base64": "gVN5bWJvbC5pc0NvbmNhdFNwcmVhZGFibGX/", - "define": "DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE" - }, - { "plain": "setPrototypeOf", "base64": "c2V0UHJvdG90eXBlT2Y=", "define": "DUK_STRIDX_SET_PROTOTYPE_OF" @@ -1606,10 +1566,6 @@ "Z2V0", "aGFz", "b3duS2V5cw==", - "gVN5bWJvbC50b1ByaW1pdGl2Zf8=", - "gVN5bWJvbC5oYXNJbnN0YW5jZf8=", - "gVN5bWJvbC50b1N0cmluZ1RhZ/8=", - "gVN5bWJvbC5pc0NvbmNhdFNwcmVhZGFibGX/", "c2V0UHJvdG90eXBlT2Y=", "X19wcm90b19f", "dG9TdHJpbmc=", @@ -1697,7 +1653,7 @@ "c3RhdGlj", "eWllbGQ=" ], - "git_describe": "v2.3.0", + "git_describe": "v2.2.0", "builtin_strings": [ "Undefined", "Null", @@ -1775,10 +1731,6 @@ "get", "has", "ownKeys", - "\u0081Symbol.toPrimitive\u00ff", - "\u0081Symbol.hasInstance\u00ff", - "\u0081Symbol.toStringTag\u00ff", - "\u0081Symbol.isConcatSpreadable\u00ff", "setPrototypeOf", "__proto__", "toString", diff -Nru duktape-2.3.0/src/duktape.c duktape-2.2.0/src/duktape.c --- duktape-2.3.0/src/duktape.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src/duktape.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,7 +1,7 @@ /* - * Single source autogenerated distributable for Duktape 2.3.0. + * Single source autogenerated distributable for Duktape 2.2.0. * - * Git commit d7fdb67f18561a50e06bafd196c6b423af9ad6fe (v2.3.0). + * Git commit a459cf3c9bd1779fc01b435d69302b742675a08f (v2.2.0). * Git branch master. * * See Duktape AUTHORS.rst and LICENSE.txt for copyright and @@ -16,7 +16,7 @@ * * (http://opensource.org/licenses/MIT) * -* Copyright (c) 2013-2018 by Duktape authors (see AUTHORS.rst) +* Copyright (c) 2013-2017 by Duktape authors (see AUTHORS.rst) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -87,14 +87,6 @@ * * Steven Don (https://github.com/shdon) * * Simon Stone (https://github.com/sstone1) * * \J. McC. (https://github.com/jmhmccr) -* * Jakub Nowakowski (https://github.com/jimvonmoon) -* * Tommy Nguyen (https://github.com/tn0502) -* * Fabrice Fontaine (https://github.com/ffontaine) -* * Christopher Hiller (https://github.com/boneskull) -* * Gonzalo Diethelm (https://github.com/gonzus) -* * Michal Kasperek (https://github.com/michalkas) -* * Andrew Janke (https://github.com/apjanke) -* * Steve Fan (https://github.com/stevefan1999) * * Other contributions * =================== @@ -133,8 +125,6 @@ * * https://github.com/chris-y * * Laurent Zubiaur (https://github.com/lzubiaur) * * Neil Kolban (https://github.com/nkolban) -* * Wilhelm Wanecek (https://github.com/wanecek) -* * Andrew Janke (https://github.com/apjanke) * * If you are accidentally missing from this list, send me an e-mail * (``sami.vaarala@iki.fi``) and I'll fix the omission. @@ -679,32 +669,20 @@ /* #include duk_exception.h */ #line 1 "duk_exception.h" /* - * Exceptions for Duktape internal throws when C++ exceptions are used + * Exception for Duktape internal throws when C++ exceptions are used * for long control transfers. + * + * Doesn't inherit from any exception base class to minimize the chance + * that user code would accidentally catch this exception. */ #if !defined(DUK_EXCEPTION_H_INCLUDED) #define DUK_EXCEPTION_H_INCLUDED #if defined(DUK_USE_CPP_EXCEPTIONS) -/* Internal exception used as a setjmp-longjmp replacement. User code should - * NEVER see or catch this exception, so it doesn't inherit from any base - * class which should minimize the chance of user code accidentally catching - * the exception. - */ class duk_internal_exception { /* intentionally empty */ }; - -/* Fatal error, thrown as a specific C++ exception with C++ exceptions - * enabled. It is unsafe to continue; doing so may cause crashes or memory - * leaks. This is intended to be either uncaught, or caught by user code - * aware of the "unsafe to continue" semantics. - */ -class duk_fatal_exception : public virtual std::runtime_error { - public: - duk_fatal_exception(const char *message) : std::runtime_error(message) {} -}; #endif #endif /* DUK_EXCEPTION_H_INCLUDED */ @@ -756,9 +734,8 @@ struct duk_activation; struct duk_catcher; +struct duk_strcache; struct duk_ljstate; -struct duk_strcache_entry; -struct duk_litcache_entry; struct duk_strtab_entry; #if defined(DUK_USE_DEBUG) @@ -817,9 +794,8 @@ typedef struct duk_activation duk_activation; typedef struct duk_catcher duk_catcher; +typedef struct duk_strcache duk_strcache; typedef struct duk_ljstate duk_ljstate; -typedef struct duk_strcache_entry duk_strcache_entry; -typedef struct duk_litcache_entry duk_litcache_entry; typedef struct duk_strtab_entry duk_strtab_entry; #if defined(DUK_USE_DEBUG) @@ -1718,290 +1694,278 @@ #define DUK_STRIDX_OWN_KEYS 75 /* 'ownKeys' */ #define DUK_HEAP_STRING_OWN_KEYS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_OWN_KEYS) #define DUK_HTHREAD_STRING_OWN_KEYS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_OWN_KEYS) -#define DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE 76 /* '\x81Symbol.toPrimitive\xff' */ -#define DUK_HEAP_STRING_WELLKNOWN_SYMBOL_TO_PRIMITIVE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE) -#define DUK_HTHREAD_STRING_WELLKNOWN_SYMBOL_TO_PRIMITIVE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE) -#define DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE 77 /* '\x81Symbol.hasInstance\xff' */ -#define DUK_HEAP_STRING_WELLKNOWN_SYMBOL_HAS_INSTANCE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE) -#define DUK_HTHREAD_STRING_WELLKNOWN_SYMBOL_HAS_INSTANCE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE) -#define DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG 78 /* '\x81Symbol.toStringTag\xff' */ -#define DUK_HEAP_STRING_WELLKNOWN_SYMBOL_TO_STRING_TAG(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG) -#define DUK_HTHREAD_STRING_WELLKNOWN_SYMBOL_TO_STRING_TAG(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG) -#define DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE 79 /* '\x81Symbol.isConcatSpreadable\xff' */ -#define DUK_HEAP_STRING_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE) -#define DUK_HTHREAD_STRING_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE) -#define DUK_STRIDX_SET_PROTOTYPE_OF 80 /* 'setPrototypeOf' */ +#define DUK_STRIDX_SET_PROTOTYPE_OF 76 /* 'setPrototypeOf' */ #define DUK_HEAP_STRING_SET_PROTOTYPE_OF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SET_PROTOTYPE_OF) #define DUK_HTHREAD_STRING_SET_PROTOTYPE_OF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SET_PROTOTYPE_OF) -#define DUK_STRIDX___PROTO__ 81 /* '__proto__' */ +#define DUK_STRIDX___PROTO__ 77 /* '__proto__' */ #define DUK_HEAP_STRING___PROTO__(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX___PROTO__) #define DUK_HTHREAD_STRING___PROTO__(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX___PROTO__) -#define DUK_STRIDX_TO_STRING 82 /* 'toString' */ +#define DUK_STRIDX_TO_STRING 78 /* 'toString' */ #define DUK_HEAP_STRING_TO_STRING(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_STRING) #define DUK_HTHREAD_STRING_TO_STRING(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_STRING) -#define DUK_STRIDX_TO_JSON 83 /* 'toJSON' */ +#define DUK_STRIDX_TO_JSON 79 /* 'toJSON' */ #define DUK_HEAP_STRING_TO_JSON(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_JSON) #define DUK_HTHREAD_STRING_TO_JSON(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_JSON) -#define DUK_STRIDX_TYPE 84 /* 'type' */ +#define DUK_STRIDX_TYPE 80 /* 'type' */ #define DUK_HEAP_STRING_TYPE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TYPE) #define DUK_HTHREAD_STRING_TYPE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TYPE) -#define DUK_STRIDX_DATA 85 /* 'data' */ +#define DUK_STRIDX_DATA 81 /* 'data' */ #define DUK_HEAP_STRING_DATA(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DATA) #define DUK_HTHREAD_STRING_DATA(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DATA) -#define DUK_STRIDX_LENGTH 86 /* 'length' */ +#define DUK_STRIDX_LENGTH 82 /* 'length' */ #define DUK_HEAP_STRING_LENGTH(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LENGTH) #define DUK_HTHREAD_STRING_LENGTH(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LENGTH) -#define DUK_STRIDX_SET 87 /* 'set' */ +#define DUK_STRIDX_SET 83 /* 'set' */ #define DUK_HEAP_STRING_SET(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SET) #define DUK_HTHREAD_STRING_SET(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SET) -#define DUK_STRIDX_STACK 88 /* 'stack' */ +#define DUK_STRIDX_STACK 84 /* 'stack' */ #define DUK_HEAP_STRING_STACK(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_STACK) #define DUK_HTHREAD_STRING_STACK(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_STACK) -#define DUK_STRIDX_PC 89 /* 'pc' */ +#define DUK_STRIDX_PC 85 /* 'pc' */ #define DUK_HEAP_STRING_PC(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PC) #define DUK_HTHREAD_STRING_PC(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PC) -#define DUK_STRIDX_LINE_NUMBER 90 /* 'lineNumber' */ +#define DUK_STRIDX_LINE_NUMBER 86 /* 'lineNumber' */ #define DUK_HEAP_STRING_LINE_NUMBER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LINE_NUMBER) #define DUK_HTHREAD_STRING_LINE_NUMBER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LINE_NUMBER) -#define DUK_STRIDX_INT_TRACEDATA 91 /* '\x82Tracedata' */ +#define DUK_STRIDX_INT_TRACEDATA 87 /* '\x82Tracedata' */ #define DUK_HEAP_STRING_INT_TRACEDATA(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_TRACEDATA) #define DUK_HTHREAD_STRING_INT_TRACEDATA(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_TRACEDATA) -#define DUK_STRIDX_NAME 92 /* 'name' */ +#define DUK_STRIDX_NAME 88 /* 'name' */ #define DUK_HEAP_STRING_NAME(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NAME) #define DUK_HTHREAD_STRING_NAME(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NAME) -#define DUK_STRIDX_FILE_NAME 93 /* 'fileName' */ +#define DUK_STRIDX_FILE_NAME 89 /* 'fileName' */ #define DUK_HEAP_STRING_FILE_NAME(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FILE_NAME) #define DUK_HTHREAD_STRING_FILE_NAME(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FILE_NAME) -#define DUK_STRIDX_LC_POINTER 94 /* 'pointer' */ +#define DUK_STRIDX_LC_POINTER 90 /* 'pointer' */ #define DUK_HEAP_STRING_LC_POINTER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_POINTER) #define DUK_HTHREAD_STRING_LC_POINTER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_POINTER) -#define DUK_STRIDX_INT_TARGET 95 /* '\x82Target' */ +#define DUK_STRIDX_INT_TARGET 91 /* '\x82Target' */ #define DUK_HEAP_STRING_INT_TARGET(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_TARGET) #define DUK_HTHREAD_STRING_INT_TARGET(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_TARGET) -#define DUK_STRIDX_INT_NEXT 96 /* '\x82Next' */ +#define DUK_STRIDX_INT_NEXT 92 /* '\x82Next' */ #define DUK_HEAP_STRING_INT_NEXT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_NEXT) #define DUK_HTHREAD_STRING_INT_NEXT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_NEXT) -#define DUK_STRIDX_INT_BYTECODE 97 /* '\x82Bytecode' */ +#define DUK_STRIDX_INT_BYTECODE 93 /* '\x82Bytecode' */ #define DUK_HEAP_STRING_INT_BYTECODE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_BYTECODE) #define DUK_HTHREAD_STRING_INT_BYTECODE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_BYTECODE) -#define DUK_STRIDX_INT_FORMALS 98 /* '\x82Formals' */ +#define DUK_STRIDX_INT_FORMALS 94 /* '\x82Formals' */ #define DUK_HEAP_STRING_INT_FORMALS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_FORMALS) #define DUK_HTHREAD_STRING_INT_FORMALS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_FORMALS) -#define DUK_STRIDX_INT_VARMAP 99 /* '\x82Varmap' */ +#define DUK_STRIDX_INT_VARMAP 95 /* '\x82Varmap' */ #define DUK_HEAP_STRING_INT_VARMAP(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VARMAP) #define DUK_HTHREAD_STRING_INT_VARMAP(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VARMAP) -#define DUK_STRIDX_INT_SOURCE 100 /* '\x82Source' */ +#define DUK_STRIDX_INT_SOURCE 96 /* '\x82Source' */ #define DUK_HEAP_STRING_INT_SOURCE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_SOURCE) #define DUK_HTHREAD_STRING_INT_SOURCE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_SOURCE) -#define DUK_STRIDX_INT_PC2LINE 101 /* '\x82Pc2line' */ +#define DUK_STRIDX_INT_PC2LINE 97 /* '\x82Pc2line' */ #define DUK_HEAP_STRING_INT_PC2LINE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_PC2LINE) #define DUK_HTHREAD_STRING_INT_PC2LINE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_PC2LINE) -#define DUK_STRIDX_INT_MAP 102 /* '\x82Map' */ +#define DUK_STRIDX_INT_MAP 98 /* '\x82Map' */ #define DUK_HEAP_STRING_INT_MAP(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_MAP) #define DUK_HTHREAD_STRING_INT_MAP(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_MAP) -#define DUK_STRIDX_INT_VARENV 103 /* '\x82Varenv' */ +#define DUK_STRIDX_INT_VARENV 99 /* '\x82Varenv' */ #define DUK_HEAP_STRING_INT_VARENV(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VARENV) #define DUK_HTHREAD_STRING_INT_VARENV(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VARENV) -#define DUK_STRIDX_INT_FINALIZER 104 /* '\x82Finalizer' */ +#define DUK_STRIDX_INT_FINALIZER 100 /* '\x82Finalizer' */ #define DUK_HEAP_STRING_INT_FINALIZER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_FINALIZER) #define DUK_HTHREAD_STRING_INT_FINALIZER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_FINALIZER) -#define DUK_STRIDX_INT_VALUE 105 /* '\x82Value' */ +#define DUK_STRIDX_INT_VALUE 101 /* '\x82Value' */ #define DUK_HEAP_STRING_INT_VALUE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VALUE) #define DUK_HTHREAD_STRING_INT_VALUE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VALUE) -#define DUK_STRIDX_COMPILE 106 /* 'compile' */ +#define DUK_STRIDX_COMPILE 102 /* 'compile' */ #define DUK_HEAP_STRING_COMPILE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_COMPILE) #define DUK_HTHREAD_STRING_COMPILE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_COMPILE) -#define DUK_STRIDX_INPUT 107 /* 'input' */ +#define DUK_STRIDX_INPUT 103 /* 'input' */ #define DUK_HEAP_STRING_INPUT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INPUT) #define DUK_HTHREAD_STRING_INPUT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INPUT) -#define DUK_STRIDX_ERR_CREATE 108 /* 'errCreate' */ +#define DUK_STRIDX_ERR_CREATE 104 /* 'errCreate' */ #define DUK_HEAP_STRING_ERR_CREATE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ERR_CREATE) #define DUK_HTHREAD_STRING_ERR_CREATE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ERR_CREATE) -#define DUK_STRIDX_ERR_THROW 109 /* 'errThrow' */ +#define DUK_STRIDX_ERR_THROW 105 /* 'errThrow' */ #define DUK_HEAP_STRING_ERR_THROW(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ERR_THROW) #define DUK_HTHREAD_STRING_ERR_THROW(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ERR_THROW) -#define DUK_STRIDX_ENV 110 /* 'env' */ +#define DUK_STRIDX_ENV 106 /* 'env' */ #define DUK_HEAP_STRING_ENV(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENV) #define DUK_HTHREAD_STRING_ENV(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENV) -#define DUK_STRIDX_HEX 111 /* 'hex' */ +#define DUK_STRIDX_HEX 107 /* 'hex' */ #define DUK_HEAP_STRING_HEX(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_HEX) #define DUK_HTHREAD_STRING_HEX(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_HEX) -#define DUK_STRIDX_BASE64 112 /* 'base64' */ +#define DUK_STRIDX_BASE64 108 /* 'base64' */ #define DUK_HEAP_STRING_BASE64(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BASE64) #define DUK_HTHREAD_STRING_BASE64(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BASE64) -#define DUK_STRIDX_JX 113 /* 'jx' */ +#define DUK_STRIDX_JX 109 /* 'jx' */ #define DUK_HEAP_STRING_JX(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JX) #define DUK_HTHREAD_STRING_JX(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JX) -#define DUK_STRIDX_JC 114 /* 'jc' */ +#define DUK_STRIDX_JC 110 /* 'jc' */ #define DUK_HEAP_STRING_JC(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JC) #define DUK_HTHREAD_STRING_JC(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JC) -#define DUK_STRIDX_JSON_EXT_UNDEFINED 115 /* '{"_undef":true}' */ +#define DUK_STRIDX_JSON_EXT_UNDEFINED 111 /* '{"_undef":true}' */ #define DUK_HEAP_STRING_JSON_EXT_UNDEFINED(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_UNDEFINED) #define DUK_HTHREAD_STRING_JSON_EXT_UNDEFINED(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_UNDEFINED) -#define DUK_STRIDX_JSON_EXT_NAN 116 /* '{"_nan":true}' */ +#define DUK_STRIDX_JSON_EXT_NAN 112 /* '{"_nan":true}' */ #define DUK_HEAP_STRING_JSON_EXT_NAN(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_NAN) #define DUK_HTHREAD_STRING_JSON_EXT_NAN(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_NAN) -#define DUK_STRIDX_JSON_EXT_POSINF 117 /* '{"_inf":true}' */ +#define DUK_STRIDX_JSON_EXT_POSINF 113 /* '{"_inf":true}' */ #define DUK_HEAP_STRING_JSON_EXT_POSINF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_POSINF) #define DUK_HTHREAD_STRING_JSON_EXT_POSINF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_POSINF) -#define DUK_STRIDX_JSON_EXT_NEGINF 118 /* '{"_ninf":true}' */ +#define DUK_STRIDX_JSON_EXT_NEGINF 114 /* '{"_ninf":true}' */ #define DUK_HEAP_STRING_JSON_EXT_NEGINF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_NEGINF) #define DUK_HTHREAD_STRING_JSON_EXT_NEGINF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_NEGINF) -#define DUK_STRIDX_JSON_EXT_FUNCTION1 119 /* '{"_func":true}' */ +#define DUK_STRIDX_JSON_EXT_FUNCTION1 115 /* '{"_func":true}' */ #define DUK_HEAP_STRING_JSON_EXT_FUNCTION1(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_FUNCTION1) #define DUK_HTHREAD_STRING_JSON_EXT_FUNCTION1(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_FUNCTION1) -#define DUK_STRIDX_JSON_EXT_FUNCTION2 120 /* '{_func:true}' */ +#define DUK_STRIDX_JSON_EXT_FUNCTION2 116 /* '{_func:true}' */ #define DUK_HEAP_STRING_JSON_EXT_FUNCTION2(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_FUNCTION2) #define DUK_HTHREAD_STRING_JSON_EXT_FUNCTION2(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_FUNCTION2) -#define DUK_STRIDX_BREAK 121 /* 'break' */ +#define DUK_STRIDX_BREAK 117 /* 'break' */ #define DUK_HEAP_STRING_BREAK(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BREAK) #define DUK_HTHREAD_STRING_BREAK(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BREAK) -#define DUK_STRIDX_CASE 122 /* 'case' */ +#define DUK_STRIDX_CASE 118 /* 'case' */ #define DUK_HEAP_STRING_CASE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CASE) #define DUK_HTHREAD_STRING_CASE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CASE) -#define DUK_STRIDX_CATCH 123 /* 'catch' */ +#define DUK_STRIDX_CATCH 119 /* 'catch' */ #define DUK_HEAP_STRING_CATCH(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CATCH) #define DUK_HTHREAD_STRING_CATCH(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CATCH) -#define DUK_STRIDX_CONTINUE 124 /* 'continue' */ +#define DUK_STRIDX_CONTINUE 120 /* 'continue' */ #define DUK_HEAP_STRING_CONTINUE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONTINUE) #define DUK_HTHREAD_STRING_CONTINUE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONTINUE) -#define DUK_STRIDX_DEBUGGER 125 /* 'debugger' */ +#define DUK_STRIDX_DEBUGGER 121 /* 'debugger' */ #define DUK_HEAP_STRING_DEBUGGER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEBUGGER) #define DUK_HTHREAD_STRING_DEBUGGER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEBUGGER) -#define DUK_STRIDX_DEFAULT 126 /* 'default' */ +#define DUK_STRIDX_DEFAULT 122 /* 'default' */ #define DUK_HEAP_STRING_DEFAULT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEFAULT) #define DUK_HTHREAD_STRING_DEFAULT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEFAULT) -#define DUK_STRIDX_DELETE 127 /* 'delete' */ +#define DUK_STRIDX_DELETE 123 /* 'delete' */ #define DUK_HEAP_STRING_DELETE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DELETE) #define DUK_HTHREAD_STRING_DELETE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DELETE) -#define DUK_STRIDX_DO 128 /* 'do' */ +#define DUK_STRIDX_DO 124 /* 'do' */ #define DUK_HEAP_STRING_DO(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DO) #define DUK_HTHREAD_STRING_DO(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DO) -#define DUK_STRIDX_ELSE 129 /* 'else' */ +#define DUK_STRIDX_ELSE 125 /* 'else' */ #define DUK_HEAP_STRING_ELSE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ELSE) #define DUK_HTHREAD_STRING_ELSE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ELSE) -#define DUK_STRIDX_FINALLY 130 /* 'finally' */ +#define DUK_STRIDX_FINALLY 126 /* 'finally' */ #define DUK_HEAP_STRING_FINALLY(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FINALLY) #define DUK_HTHREAD_STRING_FINALLY(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FINALLY) -#define DUK_STRIDX_FOR 131 /* 'for' */ +#define DUK_STRIDX_FOR 127 /* 'for' */ #define DUK_HEAP_STRING_FOR(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FOR) #define DUK_HTHREAD_STRING_FOR(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FOR) -#define DUK_STRIDX_LC_FUNCTION 132 /* 'function' */ +#define DUK_STRIDX_LC_FUNCTION 128 /* 'function' */ #define DUK_HEAP_STRING_LC_FUNCTION(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_FUNCTION) #define DUK_HTHREAD_STRING_LC_FUNCTION(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_FUNCTION) -#define DUK_STRIDX_IF 133 /* 'if' */ +#define DUK_STRIDX_IF 129 /* 'if' */ #define DUK_HEAP_STRING_IF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IF) #define DUK_HTHREAD_STRING_IF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IF) -#define DUK_STRIDX_IN 134 /* 'in' */ +#define DUK_STRIDX_IN 130 /* 'in' */ #define DUK_HEAP_STRING_IN(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IN) #define DUK_HTHREAD_STRING_IN(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IN) -#define DUK_STRIDX_INSTANCEOF 135 /* 'instanceof' */ +#define DUK_STRIDX_INSTANCEOF 131 /* 'instanceof' */ #define DUK_HEAP_STRING_INSTANCEOF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INSTANCEOF) #define DUK_HTHREAD_STRING_INSTANCEOF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INSTANCEOF) -#define DUK_STRIDX_NEW 136 /* 'new' */ +#define DUK_STRIDX_NEW 132 /* 'new' */ #define DUK_HEAP_STRING_NEW(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NEW) #define DUK_HTHREAD_STRING_NEW(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NEW) -#define DUK_STRIDX_RETURN 137 /* 'return' */ +#define DUK_STRIDX_RETURN 133 /* 'return' */ #define DUK_HEAP_STRING_RETURN(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_RETURN) #define DUK_HTHREAD_STRING_RETURN(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_RETURN) -#define DUK_STRIDX_SWITCH 138 /* 'switch' */ +#define DUK_STRIDX_SWITCH 134 /* 'switch' */ #define DUK_HEAP_STRING_SWITCH(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SWITCH) #define DUK_HTHREAD_STRING_SWITCH(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SWITCH) -#define DUK_STRIDX_THIS 139 /* 'this' */ +#define DUK_STRIDX_THIS 135 /* 'this' */ #define DUK_HEAP_STRING_THIS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_THIS) #define DUK_HTHREAD_STRING_THIS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_THIS) -#define DUK_STRIDX_THROW 140 /* 'throw' */ +#define DUK_STRIDX_THROW 136 /* 'throw' */ #define DUK_HEAP_STRING_THROW(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_THROW) #define DUK_HTHREAD_STRING_THROW(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_THROW) -#define DUK_STRIDX_TRY 141 /* 'try' */ +#define DUK_STRIDX_TRY 137 /* 'try' */ #define DUK_HEAP_STRING_TRY(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TRY) #define DUK_HTHREAD_STRING_TRY(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TRY) -#define DUK_STRIDX_TYPEOF 142 /* 'typeof' */ +#define DUK_STRIDX_TYPEOF 138 /* 'typeof' */ #define DUK_HEAP_STRING_TYPEOF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TYPEOF) #define DUK_HTHREAD_STRING_TYPEOF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TYPEOF) -#define DUK_STRIDX_VAR 143 /* 'var' */ +#define DUK_STRIDX_VAR 139 /* 'var' */ #define DUK_HEAP_STRING_VAR(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VAR) #define DUK_HTHREAD_STRING_VAR(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VAR) -#define DUK_STRIDX_CONST 144 /* 'const' */ +#define DUK_STRIDX_CONST 140 /* 'const' */ #define DUK_HEAP_STRING_CONST(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONST) #define DUK_HTHREAD_STRING_CONST(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONST) -#define DUK_STRIDX_VOID 145 /* 'void' */ +#define DUK_STRIDX_VOID 141 /* 'void' */ #define DUK_HEAP_STRING_VOID(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VOID) #define DUK_HTHREAD_STRING_VOID(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VOID) -#define DUK_STRIDX_WHILE 146 /* 'while' */ +#define DUK_STRIDX_WHILE 142 /* 'while' */ #define DUK_HEAP_STRING_WHILE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WHILE) #define DUK_HTHREAD_STRING_WHILE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WHILE) -#define DUK_STRIDX_WITH 147 /* 'with' */ +#define DUK_STRIDX_WITH 143 /* 'with' */ #define DUK_HEAP_STRING_WITH(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WITH) #define DUK_HTHREAD_STRING_WITH(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WITH) -#define DUK_STRIDX_CLASS 148 /* 'class' */ +#define DUK_STRIDX_CLASS 144 /* 'class' */ #define DUK_HEAP_STRING_CLASS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CLASS) #define DUK_HTHREAD_STRING_CLASS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CLASS) -#define DUK_STRIDX_ENUM 149 /* 'enum' */ +#define DUK_STRIDX_ENUM 145 /* 'enum' */ #define DUK_HEAP_STRING_ENUM(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENUM) #define DUK_HTHREAD_STRING_ENUM(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENUM) -#define DUK_STRIDX_EXPORT 150 /* 'export' */ +#define DUK_STRIDX_EXPORT 146 /* 'export' */ #define DUK_HEAP_STRING_EXPORT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EXPORT) #define DUK_HTHREAD_STRING_EXPORT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EXPORT) -#define DUK_STRIDX_EXTENDS 151 /* 'extends' */ +#define DUK_STRIDX_EXTENDS 147 /* 'extends' */ #define DUK_HEAP_STRING_EXTENDS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EXTENDS) #define DUK_HTHREAD_STRING_EXTENDS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EXTENDS) -#define DUK_STRIDX_IMPORT 152 /* 'import' */ +#define DUK_STRIDX_IMPORT 148 /* 'import' */ #define DUK_HEAP_STRING_IMPORT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IMPORT) #define DUK_HTHREAD_STRING_IMPORT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IMPORT) -#define DUK_STRIDX_SUPER 153 /* 'super' */ +#define DUK_STRIDX_SUPER 149 /* 'super' */ #define DUK_HEAP_STRING_SUPER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SUPER) #define DUK_HTHREAD_STRING_SUPER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SUPER) -#define DUK_STRIDX_LC_NULL 154 /* 'null' */ +#define DUK_STRIDX_LC_NULL 150 /* 'null' */ #define DUK_HEAP_STRING_LC_NULL(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_NULL) #define DUK_HTHREAD_STRING_LC_NULL(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_NULL) -#define DUK_STRIDX_TRUE 155 /* 'true' */ +#define DUK_STRIDX_TRUE 151 /* 'true' */ #define DUK_HEAP_STRING_TRUE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TRUE) #define DUK_HTHREAD_STRING_TRUE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TRUE) -#define DUK_STRIDX_FALSE 156 /* 'false' */ +#define DUK_STRIDX_FALSE 152 /* 'false' */ #define DUK_HEAP_STRING_FALSE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FALSE) #define DUK_HTHREAD_STRING_FALSE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FALSE) -#define DUK_STRIDX_IMPLEMENTS 157 /* 'implements' */ +#define DUK_STRIDX_IMPLEMENTS 153 /* 'implements' */ #define DUK_HEAP_STRING_IMPLEMENTS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IMPLEMENTS) #define DUK_HTHREAD_STRING_IMPLEMENTS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IMPLEMENTS) -#define DUK_STRIDX_INTERFACE 158 /* 'interface' */ +#define DUK_STRIDX_INTERFACE 154 /* 'interface' */ #define DUK_HEAP_STRING_INTERFACE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INTERFACE) #define DUK_HTHREAD_STRING_INTERFACE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INTERFACE) -#define DUK_STRIDX_LET 159 /* 'let' */ +#define DUK_STRIDX_LET 155 /* 'let' */ #define DUK_HEAP_STRING_LET(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LET) #define DUK_HTHREAD_STRING_LET(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LET) -#define DUK_STRIDX_PACKAGE 160 /* 'package' */ +#define DUK_STRIDX_PACKAGE 156 /* 'package' */ #define DUK_HEAP_STRING_PACKAGE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PACKAGE) #define DUK_HTHREAD_STRING_PACKAGE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PACKAGE) -#define DUK_STRIDX_PRIVATE 161 /* 'private' */ +#define DUK_STRIDX_PRIVATE 157 /* 'private' */ #define DUK_HEAP_STRING_PRIVATE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PRIVATE) #define DUK_HTHREAD_STRING_PRIVATE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PRIVATE) -#define DUK_STRIDX_PROTECTED 162 /* 'protected' */ +#define DUK_STRIDX_PROTECTED 158 /* 'protected' */ #define DUK_HEAP_STRING_PROTECTED(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PROTECTED) #define DUK_HTHREAD_STRING_PROTECTED(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PROTECTED) -#define DUK_STRIDX_PUBLIC 163 /* 'public' */ +#define DUK_STRIDX_PUBLIC 159 /* 'public' */ #define DUK_HEAP_STRING_PUBLIC(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PUBLIC) #define DUK_HTHREAD_STRING_PUBLIC(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PUBLIC) -#define DUK_STRIDX_STATIC 164 /* 'static' */ +#define DUK_STRIDX_STATIC 160 /* 'static' */ #define DUK_HEAP_STRING_STATIC(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_STATIC) #define DUK_HTHREAD_STRING_STATIC(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_STATIC) -#define DUK_STRIDX_YIELD 165 /* 'yield' */ +#define DUK_STRIDX_YIELD 161 /* 'yield' */ #define DUK_HEAP_STRING_YIELD(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_YIELD) #define DUK_HTHREAD_STRING_YIELD(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_YIELD) -#define DUK_HEAP_NUM_STRINGS 166 -#define DUK_STRIDX_START_RESERVED 121 -#define DUK_STRIDX_START_STRICT_RESERVED 157 -#define DUK_STRIDX_END_RESERVED 166 /* exclusive endpoint */ +#define DUK_HEAP_NUM_STRINGS 162 +#define DUK_STRIDX_START_RESERVED 117 +#define DUK_STRIDX_START_STRICT_RESERVED 153 +#define DUK_STRIDX_END_RESERVED 162 /* exclusive endpoint */ /* To convert a heap stridx to a token number, subtract * DUK_STRIDX_START_RESERVED and add DUK_TOK_START_RESERVED. */ #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_strings_data[967]; +DUK_INTERNAL_DECL const duk_uint8_t duk_strings_data[892]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_STRDATA_MAX_STRLEN 27 -#define DUK_STRDATA_DATA_LENGTH 967 +#define DUK_STRDATA_MAX_STRLEN 17 +#define DUK_STRDATA_DATA_LENGTH 892 #endif /* DUK_USE_ROM_STRINGS */ #if defined(DUK_USE_ROM_OBJECTS) @@ -2018,8 +1982,6 @@ DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_error_constructor_shared(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_type_error_thrower(duk_context *ctx); -DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_int(duk_context *ctx); -DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_float(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_thread_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_pointer_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_proxy_constructor(duk_context *ctx); @@ -2030,6 +1992,8 @@ DUK_INTERNAL_DECL duk_ret_t duk_bi_textencoder_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_textdecoder_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_eval(duk_context *ctx); +DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_int(duk_context *ctx); +DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_float(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_is_nan(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_is_finite(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_decode_uri(duk_context *ctx); @@ -2101,7 +2065,6 @@ DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_includes(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_substr(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_boolean_prototype_tostring_shared(duk_context *ctx); -DUK_INTERNAL_DECL duk_ret_t duk_bi_number_check_shared(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_string(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_locale_string(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_value_of(duk_context *ctx); @@ -2184,7 +2147,7 @@ DUK_INTERNAL_DECL duk_ret_t duk_bi_textdecoder_prototype_decode(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_performance_now(duk_context *ctx); #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_c_function duk_bi_native_functions[177]; +DUK_INTERNAL_DECL const duk_c_function duk_bi_native_functions[176]; #endif /* !DUK_SINGLE_FILE */ #define DUK_BIDX_GLOBAL 0 #define DUK_BIDX_GLOBAL_ENV 1 @@ -2239,22 +2202,22 @@ #define DUK_BIDX_NODEJS_BUFFER_PROTOTYPE 50 #define DUK_NUM_BUILTINS 51 #define DUK_NUM_BIDX_BUILTINS 51 -#define DUK_NUM_ALL_BUILTINS 78 +#define DUK_NUM_ALL_BUILTINS 76 #if defined(DUK_USE_DOUBLE_LE) #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4116]; +DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[3972]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_BUILTINS_DATA_LENGTH 4116 +#define DUK_BUILTINS_DATA_LENGTH 3972 #elif defined(DUK_USE_DOUBLE_BE) #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4116]; +DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[3972]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_BUILTINS_DATA_LENGTH 4116 +#define DUK_BUILTINS_DATA_LENGTH 3972 #elif defined(DUK_USE_DOUBLE_ME) #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4116]; +DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[3972]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_BUILTINS_DATA_LENGTH 4116 +#define DUK_BUILTINS_DATA_LENGTH 3972 #else #error invalid endianness defines #endif @@ -2581,13 +2544,12 @@ (bw_ctx)->p += duk__enc_len; \ } while (0) /* XXX: add temporary duk__p pointer here too; sharing */ -/* XXX: avoid unsafe variants */ #define DUK_BW_WRITE_RAW_BYTES(thr,bw_ctx,valptr,valsz) do { \ const void *duk__valptr; \ duk_size_t duk__valsz; \ duk__valptr = (const void *) (valptr); \ duk__valsz = (duk_size_t) (valsz); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ (bw_ctx)->p += duk__valsz; \ } while (0) #define DUK_BW_WRITE_RAW_CSTRING(thr,bw_ctx,val) do { \ @@ -2595,31 +2557,31 @@ duk_size_t duk__val_len; \ duk__val = (const duk_uint8_t *) (val); \ duk__val_len = DUK_STRLEN((const char *) duk__val); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HSTRING(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HSTRING_GET_BYTELEN((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HBUFFER(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_GET_SIZE((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HBUFFER_FIXED(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_FIXED_GET_SIZE((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HBUFFER_DYNAMIC(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_DYNAMIC_GET_SIZE((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) @@ -2683,14 +2645,13 @@ DUK_BW_WRITE_RAW_CESU8((thr), (bw_ctx), (cp)); \ } while (0) /* XXX: add temporary duk__p pointer here too; sharing */ -/* XXX: avoid unsafe */ #define DUK_BW_WRITE_ENSURE_BYTES(thr,bw_ctx,valptr,valsz) do { \ const void *duk__valptr; \ duk_size_t duk__valsz; \ duk__valptr = (const void *) (valptr); \ duk__valsz = (duk_size_t) (valsz); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__valsz); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ (bw_ctx)->p += duk__valsz; \ } while (0) #define DUK_BW_WRITE_ENSURE_CSTRING(thr,bw_ctx,val) do { \ @@ -2699,35 +2660,35 @@ duk__val = (const duk_uint8_t *) (val); \ duk__val_len = DUK_STRLEN((const char *) duk__val); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HSTRING(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HSTRING_GET_BYTELEN((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HBUFFER(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_GET_SIZE((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HBUFFER_FIXED(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_FIXED_GET_SIZE((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HBUFFER_DYNAMIC(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_DYNAMIC_GET_SIZE((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) @@ -2756,6 +2717,10 @@ DUK_INTERNAL_DECL const duk_int16_t duk_hex_dectab_shift4[256]; DUK_INTERNAL_DECL const duk_uint16_t duk_hex_enctab[256]; #endif +#if defined(DUK_USE_BASE64_FASTPATH) +DUK_INTERNAL_DECL const duk_uint8_t duk_base64_enctab[64]; +DUK_INTERNAL_DECL const duk_int8_t duk_base64_dectab[256]; +#endif #endif /* !DUK_SINGLE_FILE */ /* Note: assumes that duk_util_probe_steps size is 32 */ @@ -2810,127 +2775,6 @@ DUK_INTERNAL_DECL void duk_byteswap_bytes(duk_uint8_t *p, duk_small_uint_t len); #endif -/* memcpy(), memmove() etc wrappers. The plain variants like duk_memcpy() - * assume C99+ and 'src' and 'dst' pointers must be non-NULL even when the - * operation size is zero. The unsafe variants like duk_memcpy_safe() deal - * with the zero size case explicitly, and allow NULL pointers in that case - * (which is undefined behavior in C99+). For the majority of actual targets - * a NULL pointer with a zero length is fine in practice. These wrappers are - * macros to force inlining; because there are hundreds of call sites, even a - * few extra bytes per call site adds up to ~1kB footprint. - */ -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) -#define duk_memcpy(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - (void) DUK_MEMCPY(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memcpy_unsafe(dst,src,len) duk_memcpy((dst), (src), (len)) -#define duk_memmove(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - (void) DUK_MEMMOVE(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memmove_unsafe(dst,src,len) duk_memmove((dst), (src), (len)) -#define duk_memset(dst,val,len) do { \ - void *duk__dst = (dst); \ - duk_small_int_t duk__val = (val); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - (void) DUK_MEMSET(duk__dst, duk__val, (size_t) duk__len); \ - } while (0) -#define duk_memset_unsafe(dst,val,len) duk_memset((dst), (val), (len)) -#define duk_memzero(dst,len) do { \ - void *duk__dst = (dst); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - (void) DUK_MEMZERO(duk__dst, (size_t) duk__len); \ - } while (0) -#define duk_memzero_unsafe(dst,len) duk_memzero((dst), (len)) -#else /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ -#define duk_memcpy(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMCPY(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memcpy_unsafe(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMCPY(duk__dst, duk__src, (size_t) duk__len); \ - } \ - } while (0) -#define duk_memmove(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMMOVE(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memmove_unsafe(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMMOVE(duk__dst, duk__src, (size_t) duk__len); \ - } \ - } while (0) -#define duk_memset(dst,val,len) do { \ - void *duk__dst = (dst); \ - duk_small_int_t duk__val = (val); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMSET(duk__dst, duk__val, (size_t) duk__len); \ - } while (0) -#define duk_memset_unsafe(dst,val,len) do { \ - void *duk__dst = (dst); \ - duk_small_int_t duk__val = (val); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMSET(duk__dst, duk__val, (size_t) duk__len); \ - } \ - } while (0) -#define duk_memzero(dst,len) do { \ - void *duk__dst = (dst); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMZERO(duk__dst, (size_t) duk__len); \ - } while (0) -#define duk_memzero_unsafe(dst,len) do { \ - void *duk__dst = (dst); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMZERO(duk__dst, (size_t) duk__len); \ - } \ - } while (0) -#endif /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ - -DUK_INTERNAL_DECL duk_small_int_t duk_memcmp(const void *s1, const void *s2, duk_size_t len); -DUK_INTERNAL_DECL duk_small_int_t duk_memcmp_unsafe(const void *s1, const void *s2, duk_size_t len); - DUK_INTERNAL_DECL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int32_t *ival); DUK_INTERNAL_DECL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival); DUK_INTERNAL_DECL duk_bool_t duk_double_is_anyinf(duk_double_t x); @@ -2945,33 +2789,6 @@ DUK_INTERNAL_DECL duk_bool_t duk_double_same_sign(duk_double_t x, duk_double_t y); DUK_INTERNAL_DECL duk_double_t duk_double_fmin(duk_double_t x, duk_double_t y); DUK_INTERNAL_DECL duk_double_t duk_double_fmax(duk_double_t x, duk_double_t y); -DUK_INTERNAL_DECL duk_bool_t duk_double_is_finite(duk_double_t x); -DUK_INTERNAL_DECL duk_bool_t duk_double_is_integer(duk_double_t x); -DUK_INTERNAL_DECL duk_bool_t duk_double_is_safe_integer(duk_double_t x); - -DUK_INTERNAL_DECL duk_double_t duk_double_div(duk_double_t x, duk_double_t y); -DUK_INTERNAL_DECL duk_int_t duk_double_to_int_t(duk_double_t x); -DUK_INTERNAL_DECL duk_uint_t duk_double_to_uint_t(duk_double_t x); -DUK_INTERNAL_DECL duk_int32_t duk_double_to_int32_t(duk_double_t x); -DUK_INTERNAL_DECL duk_uint32_t duk_double_to_uint32_t(duk_double_t x); -DUK_INTERNAL_DECL duk_float_t duk_double_to_float_t(duk_double_t x); - -/* - * Miscellaneous - */ - -/* Example: x = 0x10 = 0b00010000 - * x - 1 = 0x0f = 0b00001111 - * x & (x - 1) == 0 - * - * x = 0x07 = 0b00000111 - * x - 1 = 0x06 = 0b00000110 - * x & (x - 1) != 0 - * - * However, incorrectly true for x == 0 so check for that explicitly. - */ -#define DUK_IS_POWER_OF_TWO(x) \ - ((x) != 0U && ((x) & ((x) - 1U)) == 0U) #endif /* DUK_UTIL_H_INCLUDED */ /* #include duk_strings.h */ @@ -3146,7 +2963,7 @@ /* #include duk_js_bytecode.h */ #line 1 "duk_js_bytecode.h" /* - * ECMAScript bytecode + * Ecmascript bytecode */ #if !defined(DUK_JS_BYTECODE_H_INCLUDED) @@ -4019,7 +3836,7 @@ duk_int_t line; }; -/* Lexer context. Same context is used for ECMAScript and Regexp parsing. */ +/* Lexer context. Same context is used for Ecmascript and Regexp parsing. */ struct duk_lexer_ctx { #if defined(DUK_USE_LEXER_SLIDING_WINDOW) duk_lexer_codepoint *window; /* unicode code points, window[0] is always next, points to 'buffer' */ @@ -4070,13 +3887,13 @@ /* #include duk_js_compiler.h */ #line 1 "duk_js_compiler.h" /* - * ECMAScript compiler. + * Ecmascript compiler. */ #if !defined(DUK_JS_COMPILER_H_INCLUDED) #define DUK_JS_COMPILER_H_INCLUDED -/* ECMAScript compiler limits */ +/* ecmascript compiler limits */ #define DUK_COMPILER_TOKEN_LIMIT 100000000L /* 1e8: protects against deeply nested inner functions */ /* maximum loopcount for peephole optimization */ @@ -4258,7 +4075,6 @@ duk_uint8_t is_arguments_shadowed; /* argument/function declaration shadows 'arguments' */ duk_uint8_t needs_shuffle; /* function needs shuffle registers */ duk_uint8_t reject_regexp_in_adv; /* reject RegExp literal on next advance() call; needed for handling IdentifierName productions */ - duk_uint8_t allow_regexp_in_adv; /* allow RegExp literal on next advance() call */ }; struct duk_compiler_ctx { @@ -5562,12 +5378,10 @@ DUK_INTERNAL_DECL duk_double_t duk_to_number_m1(duk_hthread *thr); DUK_INTERNAL_DECL duk_double_t duk_to_number_m2(duk_hthread *thr); -DUK_INTERNAL_DECL duk_bool_t duk_to_boolean_top_pop(duk_hthread *thr); - #if defined(DUK_USE_DEBUGGER_SUPPORT) /* only needed by debugger for now */ DUK_INTERNAL_DECL duk_hstring *duk_safe_to_hstring(duk_hthread *thr, duk_idx_t idx); #endif -DUK_INTERNAL_DECL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv, duk_bool_t avoid_side_effects); +DUK_INTERNAL_DECL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv); DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped_raw(duk_hthread *thr, duk_idx_t idx, duk_int_t minval, duk_int_t maxval, duk_bool_t *out_clamped); /* out_clamped=NULL, RangeError if outside range */ DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped(duk_hthread *thr, duk_idx_t idx, duk_int_t minval, duk_int_t maxval); @@ -5705,8 +5519,6 @@ DUK_INTERNAL_DECL void duk_xdef_prop_stridx_thrower(duk_hthread *thr, duk_idx_t obj_idx, duk_small_uint_t stridx); /* [] -> [] */ -DUK_INTERNAL_DECL duk_bool_t duk_get_method_stridx(duk_hthread *thr, duk_idx_t idx, duk_small_uint_t stridx); - DUK_INTERNAL_DECL void duk_pack(duk_hthread *thr, duk_idx_t count); DUK_INTERNAL_DECL duk_idx_t duk_unpack_array_like(duk_hthread *thr, duk_idx_t idx); #if 0 @@ -5743,10 +5555,6 @@ DUK_INTERNAL_DECL duk_int_t duk_pcall_method_flags(duk_hthread *thr, duk_idx_t nargs, duk_small_uint_t call_flags); -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL_DECL void duk_to_primitive_ordinary(duk_hthread *thr, duk_idx_t idx, duk_int_t hint); -#endif - /* Raw internal valstack access macros: access is unsafe so call site * must have a guarantee that the index is valid. When that is the case, * using these macro results in faster and smaller code than duk_get_tval(). @@ -5786,7 +5594,7 @@ * strings used as internal property names and raw buffers converted to * strings. In such cases the 'clen' field contains an inaccurate value. * - * ECMAScript requires support for 32-bit long strings. However, since each + * Ecmascript requires support for 32-bit long strings. However, since each * 16-bit codepoint can take 3 bytes in CESU-8, this representation can only * support about 1.4G codepoint long strings in extreme cases. This is not * really a practical issue. @@ -5810,15 +5618,12 @@ #define DUK_HSTRING_MAX_BYTELEN (0x7fffffffUL) #endif -/* XXX: could add flags for "is valid CESU-8" (ECMAScript compatible strings), +/* XXX: could add flags for "is valid CESU-8" (Ecmascript compatible strings), * "is valid UTF-8", "is valid extended UTF-8" (internal strings are not, * regexp bytecode is), and "contains non-BMP characters". These are not * needed right now. */ -/* With lowmem builds the high 16 bits of duk_heaphdr are used for other - * purposes, so this leaves 7 duk_heaphdr flags and 9 duk_hstring flags. - */ #define DUK_HSTRING_FLAG_ASCII DUK_HEAPHDR_USER_FLAG(0) /* string is ASCII, clen == blen */ #define DUK_HSTRING_FLAG_ARRIDX DUK_HEAPHDR_USER_FLAG(1) /* string is a valid array index */ #define DUK_HSTRING_FLAG_SYMBOL DUK_HEAPHDR_USER_FLAG(2) /* string is a symbol (invalid utf-8) */ @@ -5827,7 +5632,6 @@ #define DUK_HSTRING_FLAG_STRICT_RESERVED_WORD DUK_HEAPHDR_USER_FLAG(5) /* string is a reserved word (strict) */ #define DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS DUK_HEAPHDR_USER_FLAG(6) /* string is 'eval' or 'arguments' */ #define DUK_HSTRING_FLAG_EXTDATA DUK_HEAPHDR_USER_FLAG(7) /* string data is external (duk_hstring_external) */ -#define DUK_HSTRING_FLAG_PINNED_LITERAL DUK_HEAPHDR_USER_FLAG(8) /* string is a literal, and pinned */ #define DUK_HSTRING_HAS_ASCII(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) #define DUK_HSTRING_HAS_ARRIDX(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) @@ -5837,7 +5641,6 @@ #define DUK_HSTRING_HAS_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) #define DUK_HSTRING_HAS_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) #define DUK_HSTRING_HAS_EXTDATA(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) -#define DUK_HSTRING_HAS_PINNED_LITERAL(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) #define DUK_HSTRING_SET_ASCII(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) #define DUK_HSTRING_SET_ARRIDX(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) @@ -5847,7 +5650,6 @@ #define DUK_HSTRING_SET_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) #define DUK_HSTRING_SET_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) #define DUK_HSTRING_SET_EXTDATA(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) -#define DUK_HSTRING_SET_PINNED_LITERAL(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) #define DUK_HSTRING_CLEAR_ASCII(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) #define DUK_HSTRING_CLEAR_ARRIDX(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) @@ -5857,7 +5659,6 @@ #define DUK_HSTRING_CLEAR_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) #define DUK_HSTRING_CLEAR_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) #define DUK_HSTRING_CLEAR_EXTDATA(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) -#define DUK_HSTRING_CLEAR_PINNED_LITERAL(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) #if 0 /* Slightly smaller code without explicit flag, but explicit flag * is very useful when 'clen' is dropped. @@ -6026,12 +5827,12 @@ /* * Heap object representation. * - * Heap objects are used for ECMAScript objects, arrays, and functions, + * Heap objects are used for Ecmascript objects, arrays, and functions, * but also for internal control like declarative and object environment * records. Compiled functions, native functions, and threads are also * objects but with an extended C struct. * - * Objects provide the required ECMAScript semantics and exotic behaviors + * Objects provide the required Ecmascript semantics and exotic behaviors * especially for property access. * * Properties are stored in three conceptual parts: @@ -6660,7 +6461,7 @@ #define DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY 10000L /* - * ECMAScript [[Class]] + * Ecmascript [[Class]] */ /* range check not necessary because all 4-bit values are mapped */ @@ -7024,9 +6825,9 @@ /* #include duk_hcompfunc.h */ #line 1 "duk_hcompfunc.h" /* - * Heap compiled function (ECMAScript function) representation. + * Heap compiled function (Ecmascript function) representation. * - * There is a single data buffer containing the ECMAScript function's + * There is a single data buffer containing the Ecmascript function's * bytecode, constants, and inner functions. */ @@ -7420,8 +7221,7 @@ } while (0) /* Get the current data pointer (caller must ensure buf != NULL) as a - * duk_uint8_t ptr. Note that the result may be NULL if the underlying - * buffer has zero size and is not a fixed buffer. + * duk_uint8_t ptr. */ #define DUK_HBUFOBJ_GET_SLICE_BASE(heap,h) \ (DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \ @@ -7740,14 +7540,14 @@ duk_instr_t *curr_pc; /* next instruction to execute (points to 'func' bytecode, stable pointer), NULL for native calls */ /* bottom_byteoff and retval_byteoff are only used for book-keeping - * of ECMAScript-initiated calls, to allow returning to an ECMAScript + * of Ecmascript-initiated calls, to allow returning to an Ecmascript * function properly. */ /* Bottom of valstack for this activation, used to reset * valstack_bottom on return; offset is absolute. There's * no need to track 'top' because native call handling deals - * with that using locals, and for ECMAScript returns 'nregs' + * with that using locals, and for Ecmascript returns 'nregs' * indicates the necessary top. */ duk_size_t bottom_byteoff; @@ -8134,7 +7934,7 @@ #define DUK_HBUFFER_EXTERNAL_GET_SIZE(x) DUK_HBUFFER_GET_SIZE((duk_hbuffer *) (x)) #define DUK_HBUFFER_EXTERNAL_SET_SIZE(x,v) DUK_HBUFFER_SET_SIZE((duk_hbuffer *) (x), (v)) -#define DUK_HBUFFER_FIXED_GET_DATA_PTR(heap,x) ((duk_uint8_t *) (((duk_hbuffer_fixed *) (void *) (x)) + 1)) +#define DUK_HBUFFER_FIXED_GET_DATA_PTR(heap,x) ((duk_uint8_t *) (((duk_hbuffer_fixed *) (x)) + 1)) #if defined(DUK_USE_HEAPPTR16) #define DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap,x) \ @@ -8189,7 +7989,7 @@ DUK_HBUFFER_EXTERNAL_GET_DATA_PTR((heap), (duk_hbuffer_external *) (x)) : \ DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((heap), (duk_hbuffer_dynamic *) (x)) \ ) : \ - DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (void *) (x)) \ + DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (x)) \ ) #else /* Without heap pointer compression duk_hbuffer_dynamic and duk_hbuffer_external @@ -8198,7 +7998,7 @@ #define DUK_HBUFFER_GET_DATA_PTR(heap,x) ( \ DUK_HBUFFER_HAS_DYNAMIC((x)) ? \ DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((heap), (duk_hbuffer_dynamic *) (x)) : \ - DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (void *) (x)) \ + DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (x)) \ ) #endif @@ -8272,10 +8072,7 @@ #if (DUK_USE_ALIGN_BY == 4) duk_uint32_t dummy_for_align4; #elif (DUK_USE_ALIGN_BY == 8) - duk_double_t dummy_for_align8_1; -#if defined(DUK_USE_64BIT_OPS) - duk_uint64_t dummy_for_align8_2; -#endif + duk_double_t dummy_for_align8; #elif (DUK_USE_ALIGN_BY == 1) /* no extra padding */ #else @@ -8692,7 +8489,7 @@ * Thus, string caches are now at the heap level now. */ -struct duk_strcache_entry { +struct duk_strcache { duk_hstring *h; duk_uint32_t bidx; duk_uint32_t cidx; @@ -8724,15 +8521,6 @@ } while (0) /* - * Literal intern cache - */ - -struct duk_litcache_entry { - const duk_uint8_t *addr; - duk_hstring *h; -}; - -/* * Main heap structure */ @@ -8958,15 +8746,7 @@ /* String access cache (codepoint offset -> byte offset) for fast string * character looping; 'weak' reference which needs special handling in GC. */ - duk_strcache_entry strcache[DUK_HEAP_STRCACHE_SIZE]; - -#if defined(DUK_USE_LITCACHE_SIZE) - /* Literal intern cache. When enabled, strings interned as literals - * (e.g. duk_push_literal()) will be pinned and cached for the lifetime - * of the heap. - */ - duk_litcache_entry litcache[DUK_USE_LITCACHE_SIZE]; -#endif + duk_strcache strcache[DUK_HEAP_STRCACHE_SIZE]; /* Built-in strings. */ #if defined(DUK_USE_ROM_STRINGS) @@ -8998,9 +8778,6 @@ duk_int_t stats_strtab_resize_check; duk_int_t stats_strtab_resize_grow; duk_int_t stats_strtab_resize_shrink; - duk_int_t stats_strtab_litcache_hit; - duk_int_t stats_strtab_litcache_miss; - duk_int_t stats_strtab_litcache_pin; duk_int_t stats_object_realloc_props; duk_int_t stats_object_abandon_array; duk_int_t stats_getownpropdesc_count; @@ -9061,9 +8838,6 @@ DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen); DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t len); -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_literal_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t blen); -#endif DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_u32(duk_heap *heap, duk_uint32_t val); DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_u32_checked(duk_hthread *thr, duk_uint32_t val); #if defined(DUK_USE_REFERENCE_COUNTING) @@ -9468,8 +9242,8 @@ * Error codes: defined in duktape.h * * Error codes are used as a shorthand to throw exceptions from inside - * the implementation. The appropriate ECMAScript object is constructed - * based on the code. ECMAScript code throws objects directly. The error + * the implementation. The appropriate Ecmascript object is constructed + * based on the code. Ecmascript code throws objects directly. The error * codes are defined in the public API header because they are also used * by calling code. */ @@ -9871,7 +9645,7 @@ #if defined(DUK_USE_ASSERTIONS) #define DUK_ASSERT_SET_GARBAGE(ptr,size) do { \ - duk_memset_unsafe((void *) (ptr), 0x5a, size); \ + DUK_MEMSET((void *) (ptr), 0x5a, size); \ } while (0) #else #define DUK_ASSERT_SET_GARBAGE(ptr,size) do {} while (0) @@ -10150,13 +9924,13 @@ * Automatically generated by extract_chars.py, do not edit! */ -extern const duk_uint8_t duk_unicode_ids_noa[1063]; +extern const duk_uint8_t duk_unicode_ids_noa[1036]; #else /* * Automatically generated by extract_chars.py, do not edit! */ -extern const duk_uint8_t duk_unicode_ids_noabmp[626]; +extern const duk_uint8_t duk_unicode_ids_noabmp[625]; #endif #if defined(DUK_USE_SOURCE_NONBMP) @@ -10178,13 +9952,13 @@ * Automatically generated by extract_chars.py, do not edit! */ -extern const duk_uint8_t duk_unicode_idp_m_ids_noa[549]; +extern const duk_uint8_t duk_unicode_idp_m_ids_noa[530]; #else /* * Automatically generated by extract_chars.py, do not edit! */ -extern const duk_uint8_t duk_unicode_idp_m_ids_noabmp[358]; +extern const duk_uint8_t duk_unicode_idp_m_ids_noabmp[357]; #endif /* @@ -10327,7 +10101,7 @@ /* #include duk_js.h */ #line 1 "duk_js.h" /* - * ECMAScript execution, support primitives. + * Ecmascript execution, support primitives. */ #if !defined(DUK_JS_H_INCLUDED) @@ -10371,9 +10145,6 @@ #endif DUK_INTERNAL_DECL duk_bool_t duk_js_compare_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_uint_t flags); DUK_INTERNAL_DECL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y); -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL_DECL duk_bool_t duk_js_instanceof_ordinary(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y); -#endif DUK_INTERNAL_DECL duk_bool_t duk_js_in(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y); DUK_INTERNAL_DECL duk_small_uint_t duk_js_typeof_stridx(duk_tval *tv_x); @@ -10443,7 +10214,7 @@ #line 1 "duk_numconv.h" /* * Number-to-string conversion. The semantics of these is very tightly - * bound with the ECMAScript semantics required for call sites. + * bound with the Ecmascript semantics required for call sites. */ #if !defined(DUK_NUMCONV_H_INCLUDED) @@ -10476,13 +10247,9 @@ /* Maximum exponent value when parsing numbers. This is not strictly * compliant as there should be no upper limit, but as we parse the - * exponent without a bigint, impose some limit. The limit should be - * small enough that multiplying it (or limit-1 to be precise) won't - * overflow signed 32-bit integer range. Exponent is only parsed with - * radix 10, but with maximum radix (36) a safe limit is: - * (10000000*36).toString(16) -> '15752a00' + * exponent without a bigint, impose some limit. */ -#define DUK_S2N_MAX_EXPONENT 10000000L +#define DUK_S2N_MAX_EXPONENT 1000000000 /* Trim white space (= allow leading and trailing whitespace) */ #define DUK_S2N_FLAG_TRIM_WHITE (1U << 0) @@ -10758,7 +10525,7 @@ va_start(ap, fmt); - duk_memzero((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); + DUK_MEMZERO((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); duk_debug_vsnprintf(buf, DUK__DEBUG_BUFSIZE - 1, fmt, ap); arg_level = (long) level; @@ -10789,7 +10556,7 @@ va_start(ap, fmt); - duk_memzero((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); + DUK_MEMZERO((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); duk_debug_vsnprintf(buf, DUK__DEBUG_BUFSIZE - 1, fmt, ap); arg_level = (long) duk_debug_level_stash; @@ -10830,7 +10597,7 @@ #if defined(DUK_USE_ROM_STRINGS) #error ROM support not enabled, rerun configure.py with --rom-support #else /* DUK_USE_ROM_STRINGS */ -DUK_INTERNAL const duk_uint8_t duk_strings_data[967] = { +DUK_INTERNAL const duk_uint8_t duk_strings_data[892] = { 79,40,209,144,168,105,6,78,54,139,89,185,44,48,46,90,120,8,154,140,35,103, 35,113,193,73,5,52,112,180,104,166,135,52,188,4,98,12,27,146,156,80,211,31, 129,115,150,64,52,220,109,24,18,68,156,24,38,67,114,36,55,9,119,151,132, @@ -10852,40 +10619,36 @@ 249,110,128,126,88,95,133,109,237,237,237,151,235,127,46,249,119,203,190, 186,206,33,181,2,208,61,190,12,19,34,65,19,81,132,108,228,97,1,107,33,12, 32,45,100,137,64,247,175,9,19,155,41,198,130,155,134,69,146,100,227,226, -231,146,51,192,204,73,140,224,145,221,102,241,68,196,169,248,30,75,12,11, -151,242,233,187,143,138,24,137,162,164,255,253,63,3,201,97,129,114,254,92, -112,75,136,108,166,6,136,159,255,167,224,121,44,48,46,95,203,166,238,74, -113,67,77,201,128,223,255,223,224,121,44,48,46,95,203,145,46,9,205,16,39, -201,62,36,0,192,21,147,255,238,145,39,199,197,211,116,240,242,113,197,78, -214,211,226,233,187,107,105,19,119,37,56,161,166,52,221,212,201,205,36,240, -242,16,96,152,12,178,52,211,56,228,73,150,83,0,148,39,137,75,67,73,198,209, -129,36,85,185,201,196,2,32,193,48,17,160,97,16,84,44,156,104,24,67,189,200, -108,201,19,238,114,96,137,137,50,238,113,164,188,211,185,192,226,100,19, -134,68,110,112,174,139,0,185,31,115,149,4,88,7,159,115,146,117,34,34,35, -115,143,22,146,208,210,19,115,140,3,207,185,202,130,36,109,85,185,194,161, -160,90,50,72,155,115,149,2,232,67,137,204,122,22,66,161,175,164,210,72,199, -130,137,1,50,32,145,143,38,120,186,195,35,106,51,146,230,8,36,77,109,65,38, -226,72,159,191,189,181,70,140,133,222,249,212,227,66,125,245,187,251,219, -77,3,119,190,117,56,208,159,125,110,254,246,210,26,93,239,157,78,52,39,223, -93,191,189,180,212,52,187,223,58,156,104,79,190,187,127,123,104,180,104, -183,190,117,56,208,159,125,102,254,209,104,209,124,234,113,161,62,250,80, -196,128,81,4,9,16,162,4,196,116,9,205,154,27,66,32,100,13,12,98,68,227,33, -65,69,204,195,34,201,50,8,110,33,23,34,28,168,104,22,188,12,174,138,11,70, -138,104,115,68,130,137,13,82,27,41,129,162,35,138,54,146,198,137,39,72,180, -210,178,38,35,146,103,68,139,51,197,214,28,227,131,79,15,35,138,58,130,37, -19,155,41,146,174,64,203,99,161,100,37,145,51,148,75,4,164,66,54,140,49,46, -247,70,103,37,230,70,142,70,67,30,232,204,178,163,201,18,54,139,89,39,26, -16,165,2,228,69,33,143,89,24,70,206,73,67,102,72,148,2,32,214,73,157,224, -18,128,98,29,241,69,65,50,37,241,116,200,41,144,102,125,2,180,8,210,152,38, -129,23,8,34,198, +231,146,51,192,204,73,140,224,145,221,102,241,68,196,157,34,79,143,139,166, +233,225,228,227,138,157,173,167,197,211,118,214,210,38,238,74,113,67,76, +105,187,169,147,154,73,225,228,32,193,48,25,100,105,166,113,200,147,44,166, +1,40,79,18,150,134,147,141,163,2,72,171,115,147,136,4,65,130,96,35,64,194, +32,168,89,56,208,48,135,123,144,217,146,39,220,228,193,19,18,101,220,227, +73,121,167,115,129,196,200,39,12,136,220,225,93,22,1,114,62,231,42,8,176, +15,62,231,36,234,68,68,70,231,30,45,37,161,164,38,231,24,7,159,115,149,4, +72,218,171,115,133,67,64,180,100,145,54,231,42,5,208,135,19,152,244,44,133, +67,95,73,164,145,143,5,18,2,100,65,35,30,76,241,117,134,70,212,103,37,204, +16,72,154,218,130,77,196,145,63,127,123,106,141,25,11,189,243,169,198,132, +251,235,119,247,182,154,6,239,124,234,113,161,62,250,221,253,237,164,52, +187,223,58,156,104,79,190,187,127,123,105,168,105,119,190,117,56,208,159, +125,118,254,246,209,104,209,111,124,234,113,161,62,250,205,253,162,209,162, +249,212,227,66,125,244,161,137,0,162,8,18,33,68,9,136,232,19,155,52,54,132, +64,200,26,24,196,137,198,66,130,139,153,134,69,146,100,16,220,66,46,68,57, +80,208,45,120,25,93,20,22,141,20,208,230,137,5,18,26,164,54,83,3,68,71,20, +109,37,141,18,78,145,105,165,100,76,71,36,206,137,22,103,139,172,57,199,6, +158,30,71,20,117,4,74,39,54,83,37,92,129,150,199,66,200,75,34,103,40,150,9, +72,132,109,24,98,93,238,140,206,75,204,141,28,140,134,61,209,153,101,71, +146,36,109,22,178,78,52,33,74,5,200,138,67,30,178,48,141,156,146,134,204, +145,40,4,65,172,147,59,192,37,0,196,59,226,138,130,100,75,226,233,144,83, +32,204,250,5,104,17,165,48,77,2,46,16,69,140, }; #endif /* DUK_USE_ROM_STRINGS */ #if defined(DUK_USE_ROM_OBJECTS) #error ROM support not enabled, rerun configure.py with --rom-support #else /* DUK_USE_ROM_OBJECTS */ -/* native functions: 177 */ -DUK_INTERNAL const duk_c_function duk_bi_native_functions[177] = { +/* native functions: 176 */ +DUK_INTERNAL const duk_c_function duk_bi_native_functions[176] = { NULL, duk_bi_array_constructor, duk_bi_array_constructor_is_array, @@ -10978,7 +10741,6 @@ duk_bi_nodejs_buffer_tojson, duk_bi_nodejs_buffer_tostring, duk_bi_nodejs_buffer_write, - duk_bi_number_check_shared, duk_bi_number_constructor, duk_bi_number_prototype_to_exponential, duk_bi_number_prototype_to_fixed, @@ -11065,577 +10827,556 @@ duk_bi_uint8array_plainof, }; #if defined(DUK_USE_DOUBLE_LE) -DUK_INTERNAL const duk_uint8_t duk_builtins_data[4116] = { -144,148,105,224,32,68,52,228,62,12,104,200,165,132,52,167,194,138,105,243, -124,57,28,211,57,18,64,52,238,126,44,138,111,171,241,164,19,87,129,30,33, +DUK_INTERNAL const duk_uint8_t duk_builtins_data[3972] = { +144,148,105,223,160,68,52,228,62,12,104,200,165,132,52,167,194,138,105,242, +252,57,28,211,57,18,64,52,238,62,44,138,111,171,241,164,19,87,125,30,33, 167,16,145,159,8,211,136,9,225,42,5,240,145,139,163,163,8,211,136,10,228, 64,211,19,132,140,93,29,56,70,156,64,119,34,66,146,36,104,137,194,70,46, 142,172,35,78,32,47,146,195,102,11,240,145,139,163,175,8,211,136,9,228,240, 242,112,145,139,163,179,8,211,136,8,237,34,130,118,49,116,118,225,26,48,0, -1,82,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, -33,8,66,26,179,233,97,167,60,150,34,33,154,112,0,1,75,247,35,79,95,237,198, -174,200,47,31,23,95,17,13,51,19,35,93,68,216,209,128,0,10,208,174,79,15,32, -248,8,196,24,8,107,192,0,5,106,118,27,94,0,0,43,83,227,94,0,0,43,84,46,215, -128,0,10,213,28,198,188,0,0,86,169,100,53,224,0,2,181,79,85,175,0,0,21,170, -154,45,120,0,0,173,85,217,107,192,0,5,106,182,243,86,193,106,52,127,130, -249,50,94,124,35,68,225,146,49,13,31,186,23,201,146,243,224,200,39,12,145, -136,67,134,19,49,0,0,0,0,0,0,3,225,255,51,0,0,0,0,0,0,3,193,255,47,18,1, -172,19,120,71,10,25,196,136,113,162,156,136,199,42,57,204,144,115,132,240, -149,2,248,72,197,209,58,2,185,16,52,196,225,35,23,68,233,14,228,72,82,68, -141,17,56,72,197,209,58,130,249,44,54,96,191,9,24,186,39,88,79,39,135,147, -132,140,93,19,176,35,180,138,9,216,197,209,59,82,79,35,40,242,65,248,58,42, -96,121,14,232,94,62,46,190,15,42,31,145,33,86,65,76,242,214,143,73,48,242, -243,79,49,56,243,115,207,57,64,243,180,79,61,72,243,244,207,65,80,244,53, -79,69,88,244,98,30,8,200,156,67,102,120,241,79,4,100,78,21,110,4,207,32,47, -147,37,231,194,52,78,25,34,122,81,124,153,47,62,12,130,112,201,19,211,139, -121,34,87,69,128,104,137,239,83,18,238,108,165,2,162,92,104,56,220,233,1,8, -151,10,134,162,100,206,16,18,50,9,195,39,105,20,101,136,18,25,4,225,147, -180,138,5,215,49,238,105,27,60,185,1,36,104,156,50,118,145,70,96,129,34,52, -78,25,59,72,160,93,115,30,230,145,179,204,144,12,73,8,15,38,104,128,138,52, -146,16,30,77,1,0,2,11,132,193,198,36,248,248,186,110,158,30,78,56,188,194, -70,183,170,136,48,98,79,142,179,120,248,185,228,140,241,193,146,66,138,31, -55,71,138,128,153,137,62,58,205,227,226,231,146,51,199,26,6,18,92,146,64, -96,74,72,51,120,43,192,97,68,128,153,56,72,7,12,133,67,73,199,197,207,36, -103,142,35,2,3,33,80,210,113,241,115,201,25,160,146,225,160,9,34,1,124,178, -1,139,18,19,36,229,146,8,190,36,169,27,62,18,243,35,100,135,54,92,162,2,17, -46,72,128,89,7,200,32,33,18,225,98,236,145,188,130,64,196,75,132,188,200, -217,32,43,39,28,128,69,19,18,228,144,42,98,79,142,179,120,248,185,228,140, -241,201,97,129,114,229,201,37,2,68,184,200,1,147,93,159,153,213,34,235,250, -96,48,157,32,24,94,160,1,199,4,184,235,55,143,139,158,72,207,28,226,3,81, -46,62,46,155,167,135,147,142,47,60,129,71,197,207,36,103,142,34,92,35,104, -194,68,1,89,58,36,8,109,109,12,133,67,73,195,18,115,36,118,182,185,168,8, -109,109,12,133,67,73,201,18,115,36,118,182,185,168,130,27,91,75,115,149,71, -240,196,156,201,29,173,174,129,2,27,91,75,115,149,71,242,68,156,201,29,173, -174,129,34,12,16,28,128,62,191,42,3,71,146,68,4,16,22,188,161,240,16,40, -104,242,103,196,16,93,158,125,96,110,115,235,64,131,16,16,58,37,192,70,32, -194,144,114,25,67,95,40,6,18,8,32,48,156,209,2,108,124,96,224,144,6,247,62, -16,0,143,164,143,12,248,15,18,84,145,145,34,128,11,35,160,179,140,0,44,150, -129,18,58,0,146,116,103,32,128,105,61,104,17,36,175,1,232,217,29,5,156,179, -224,58,26,50,95,142,43,159,64,181,130,83,226,26,50,95,142,43,159,192,7,255, -248,41,42,72,226,1,160,18,78,97,32,26,64,114,186,60,32,4,120,6,148,13,128, -124,3,76,12,84,46,100,140,3,78,13,18,14,130,36,67,232,23,18,14,130,39,34, -131,30,113,15,224,3,255,253,6,48,40,194,197,204,224,142,8,240,78,25,60,231, -192,210,197,204,224,156,50,113,238,67,103,232,62,28,138,156,104,82,170,107, -255,32,48,191,144,1,132,112,71,128,159,168,128,161,28,17,224,156,50,112,19, -245,144,22,39,12,156,123,144,217,240,19,245,146,3,9,205,16,39,236,62,3,161, -163,37,248,226,251,141,1,107,4,167,196,52,100,191,28,95,113,164,13,91,132, -5,147,130,115,30,8,147,222,64,43,1,49,31,224,64,60,72,245,128,68,249,32,13, -34,2,34,63,204,128,89,45,2,39,209,0,89,61,104,159,213,0,153,80,50,156,80, -211,126,16,11,155,184,183,88,145,224,129,34,122,64,17,155,184,183,8,11,39, -22,235,18,60,16,36,79,72,1,115,119,40,247,146,60,16,36,79,72,32,140,221, -197,184,64,89,57,71,188,145,224,129,34,122,65,1,39,20,51,244,0,52,72,242,2, -127,18,2,165,48,70,114,229,145,51,253,141,1,4,104,229,203,34,103,251,26,64, -132,52,75,160,201,47,105,160,26,84,12,167,31,186,8,50,0,114,58,113,163,46, -190,120,35,11,60,4,25,68,81,61,96,47,181,80,46,132,129,255,255,255,255,255, -255,222,254,39,172,67,118,170,5,208,144,0,64,0,0,0,0,0,0,51,16,0,0,0,0,0,0, -62,31,200,245,238,146,38,138,147,105,13,42,26,137,226,0,0,0,0,0,0,7,131, -249,30,180,134,4,209,82,109,33,165,67,81,60,64,0,0,0,0,0,0,240,255,15,210, -62,72,91,155,0,0,0,0,0,0,2,192,240,135,88,11,237,72,5,38,210,27,50,24,145, -129,255,255,255,255,255,254,126,134,67,172,67,118,164,2,147,105,13,153,12, -72,192,255,255,255,255,255,255,63,195,16,240,70,68,226,27,51,199,138,120, -35,34,112,171,112,38,121,7,16,137,112,168,106,38,77,193,1,40,151,16,217, -144,196,142,224,144,21,18,227,65,198,238,9,67,81,46,72,5,39,16,217,144,196, -142,224,152,228,148,227,64,0,0,0,0,0,0,0,0,131,175,223,16,194,111,8,97,119, -224,3,205,220,42,46,65,238,200,13,155,184,75,189,205,35,102,128,47,116,64, -92,221,199,196,130,68,144,230,239,72,65,152,12,21,224,140,137,92,128,62, -210,98,177,252,3,107,173,88,3,146,211,141,32,0,0,0,0,0,3,225,255,19,175, -188,0,100,221,193,130,100,228,167,20,52,215,129,3,38,238,77,12,39,37,56, -161,166,188,10,194,94,6,18,155,184,183,8,11,39,6,9,147,146,156,80,211,94,7, -18,155,184,183,8,11,39,38,134,19,146,156,80,211,94,8,12,53,224,130,195,222, -8,77,133,210,24,91,224,3,152,147,228,208,194,95,0,44,196,159,11,69,175,152, -32,35,100,33,135,24,147,237,38,34,246,139,95,48,64,70,200,68,8,49,39,198, -57,179,61,144,138,22,98,79,180,152,153,215,54,103,178,17,129,204,73,240,96, -153,44,132,112,163,18,125,164,196,62,130,100,178,18,1,140,73,240,96,197, -144,146,18,98,79,180,152,135,208,98,200,74,8,49,39,195,186,145,149,144,150, -22,98,79,180,152,143,215,82,50,178,19,2,140,73,241,136,109,38,73,89,9,161, -166,36,251,73,137,157,67,105,50,74,200,78,10,49,39,201,16,78,104,229,100, -39,134,152,147,237,38,41,116,130,115,71,43,33,64,60,196,159,24,133,173,18, -32,156,209,202,200,81,18,49,39,218,76,76,234,22,180,72,130,115,71,43,33,72, -68,196,159,38,134,19,46,105,56,226,150,68,157,160,1,228,73,242,104,97,46, -16,31,34,79,140,66,214,137,16,78,104,229,108,169,137,72,147,237,38,38,117, -11,90,36,65,57,163,149,178,168,21,34,79,146,32,156,209,202,218,250,161,178, -36,251,73,138,93,32,156,209,202,218,250,193,82,36,248,196,54,147,36,173, -191,174,27,34,79,180,152,153,212,54,147,36,173,191,176,17,34,79,135,117,35, -43,115,236,133,200,147,237,38,35,245,212,140,173,207,180,15,34,79,131,4, -201,108,173,133,72,147,237,38,33,244,19,37,178,184,17,34,79,140,115,102, -123,107,238,133,200,147,237,38,38,117,205,153,237,175,188,23,34,79,133,162, -215,204,16,17,182,254,248,116,137,62,210,98,47,104,181,243,4,4,109,191,192, -131,152,147,230,8,8,217,12,16,60,137,62,96,128,141,178,193,160,206,1,201, -176,113,146,0,0,0,0,0,0,0,0,49,185,252,65,137,207,227,37,215,207,227,12,86, -127,24,152,188,254,49,88,33,46,65,120,72,4,153,37,63,33,13,127,148,4,26,0, -57,62,6,228,163,228,74,86,215,62,55,28,110,179,226,113,70,223,62,47,24,38, -191,30,2,125,32,40,20,87,114,41,225,42,5,240,145,139,163,145,41,68,250,128, -80,41,174,228,85,200,129,166,39,9,24,186,57,18,148,79,172,5,2,170,238,69, -220,137,10,72,145,162,39,9,24,186,57,18,148,79,176,5,2,186,238,69,124,150, -27,48,95,132,140,93,28,137,74,39,218,2,129,101,119,34,158,79,15,39,9,24, -186,57,18,148,79,184,5,2,218,238,69,29,164,80,78,198,46,142,68,165,16,64, -28,24,61,73,25,33,205,128,0,0,0,0,1,167,166,129,108,242,151,15,39,8,34,26, -87,97,200,3,0,167,129,32,8,194,195,16,6,84,55,10,60,3,35,69,132,30,1,140, -130,193,143,1,196,230,60,2,158,8,131,153,64,115,42,46,191,176,8,194,246,0, -80,5,220,193,95,6,234,5,100,225,35,23,71,35,6,228,140,93,29,180,55,108,145, -139,163,182,112,52,107,67,76,56,3,153,132,20,28,76,156,89,26,105,158,62,0, -0,42,193,2,201,104,17,41,34,156,204,176,160,226,100,226,200,211,76,241,240, -0,1,86,2,131,137,147,142,41,100,73,199,192,0,5,96,6,13,10,82,70,62,0,0,42, -130,88,115,18,124,67,103,177,69,49,129,6,36,249,68,54,123,20,82,216,65,137, -62,33,179,209,214,162,152,208,147,18,124,162,27,61,29,106,41,112,32,196, -159,16,217,233,233,81,76,112,73,137,62,81,13,158,158,149,20,186,20,98,79, -133,91,129,61,61,42,41,120,40,196,159,10,183,2,122,218,148,82,248,60,137, -62,33,179,216,166,216,192,137,18,124,162,27,61,138,109,108,34,68,159,16, -217,232,235,83,108,104,76,137,62,81,13,158,142,181,54,184,17,34,79,136,108, -244,244,169,182,56,38,68,159,40,134,207,79,74,155,93,10,145,39,194,173,192, -158,158,149,54,188,21,34,79,133,91,129,61,109,74,109,125,155,51,136,71,161, -196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,7,129,249,155,51,168,71, -161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,7,129,249,155,51,200, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,7,129,249,155,51, -232,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,2,1,155,52, -8,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,2,1,155,52,40, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,155,52,72, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,155,52, -104,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,155, -52,136,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,1,2,1,135, -52,166,32,76,72,1,246,136,235,103,177,69,0,136,144,3,226,27,61,138,41,44, -50,36,0,251,68,117,179,209,214,234,201,69,16,50,36,0,251,68,117,179,209, -214,232,73,69,34,5,196,128,31,16,217,232,235,117,100,162,147,2,226,64,15, -136,108,244,117,186,18,81,74,129,145,32,7,218,35,173,158,158,151,86,74,40, -161,145,32,7,218,35,173,158,158,151,66,74,41,20,46,36,0,248,134,207,79,75, -171,37,20,154,23,18,0,124,67,103,167,165,208,146,138,85,11,137,0,62,21,110, -4,250,178,81,70,11,137,0,62,21,110,4,250,18,81,72,193,145,32,7,193,186,129, -89,58,178,81,71,12,137,0,62,13,212,10,201,208,146,138,71,10,137,0,62,209, -29,108,250,178,81,104,1,81,32,7,218,35,173,159,66,74,45,32,38,36,0,248,134, -207,171,37,22,160,19,18,0,124,67,103,208,146,139,88,10,180,81,50,118,136, -235,103,177,77,128,155,69,19,39,16,217,236,83,105,97,182,138,38,78,209,29, -108,244,117,186,178,83,100,13,180,81,50,118,136,235,103,163,173,208,146, -155,68,12,180,81,50,113,13,158,142,183,86,74,109,48,50,209,68,201,196,54, -122,58,221,9,41,181,64,219,69,19,39,104,142,182,122,122,93,89,41,178,134, -218,40,153,59,68,117,179,211,210,232,73,77,162,134,90,40,153,56,134,207,79, -75,171,37,54,154,25,104,162,100,226,27,61,61,46,132,148,218,168,101,162, -137,147,133,91,129,62,172,148,217,131,45,20,76,156,42,220,9,244,36,166,209, -131,109,20,76,156,27,168,21,147,171,37,54,112,219,69,19,39,6,234,5,100,232, -73,77,163,133,218,40,153,59,68,117,179,234,201,78,32,5,218,40,153,59,68, -117,179,232,73,78,36,5,90,40,153,56,134,207,171,37,56,160,21,104,162,100, -226,27,62,132,148,226,195,95,182,97,176,218,128,8,84,45,123,38,1,137,10,1, -114,160,64,56,156,199,130,36,160,72,8,39,63,27,24,1,100,180,8,148,146,0,45, -162,137,147,111,2,8,4,16,7,8,96,120,72,13,42,226,145,97,87,224,168,1,58, -182,232,232,64,22,85,181,187,177,107,2,64,7,213,183,74,7,121,207,215,242, -17,119,49,248,94,173,198,210,36,15,232,34,182,84,113,95,115,240,221,91,141, -163,160,72,1,220,164,194,175,121,123,103,224,186,244,64,24,45,68,84,251,33, -9,64,15,217,66,51,209,218,210,129,154,118,254,205,61,65,204,126,23,178,132, -103,165,3,52,237,253,154,122,131,216,254,168,48,6,90,130,1,0,39,75,80,72,8, -9,33,186,130,80,64,76,13,212,19,2,130,96,110,150,173,0,65,6,51,212,20,128, -65,17,11,212,19,130,137,121,211,210,209,144,6,39,75,80,80,0,201,119,234,10, -8,41,86,231,71,80,80,129,79,135,186,122,69,224,34,25,69,233,80,3,91,141, -168,40,96,139,113,180,181,5,36,21,110,54,142,134,160,165,1,176,23,211,47,0, -216,134,233,215,128,111,117,181,104,128,209,3,70,230,106,64,5,139,168,209, -234,10,32,36,144,102,234,136,3,146,27,168,40,160,146,132,103,168,40,192, -115,3,117,5,28,22,113,163,69,168,41,103,1,66,188,17,145,52,40,4,202,113,67, -76,130,227,68,194,13,240,108,0,0,83,96,0,2,161,0,104,146,84,97,48,0,1,78, -192,56,169,24,145,179,192,0,5,48,8,56,16,32,128,56,18,52,125,166,86,147, -182,140,28,50,21,13,39,31,23,60,145,158,56,140,141,47,113,6,155,186,188,24, -49,39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,197,68,14,49, -39,199,197,211,116,240,242,113,197,230,18,180,253,228,3,17,46,18,243,35, -100,128,172,156,114,70,163,146,76,34,248,146,164,108,248,75,204,141,146,28, -217,114,137,27,78,251,241,173,234,162,160,225,1,3,34,92,170,9,105,164,32, -225,64,131,155,1,193,133,7,19,39,22,70,154,103,143,128,0,10,176,20,28,76, -156,113,75,34,78,62,0,0,43,0,48,104,82,146,49,240,0,1,84,11,180,192,0,5, -114,1,18,160,65,24,131,20,145,25,172,48,132,122,28,76,146,218,121,35,180, -69,145,132,108,224,0,0,0,0,0,0,120,31,153,172,56,132,122,28,76,146,218,121, -35,180,69,145,132,108,224,0,0,0,0,0,0,120,31,168,160,45,110,23,30,176,33, -184,0,0,175,32,29,235,2,27,199,23,0,0,22,4,51,88,129,8,244,56,153,37,180, -242,71,104,139,35,8,217,192,0,0,0,0,0,0,240,63,51,88,145,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,0,64,51,88,161,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,0,64,51,88,177,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64,51,88,193,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64,51,88,209,8,244,56, -153,37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64,51,88,225,8,244, -56,153,37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,32,64,32,227,194,0, -97,57,162,4,245,232,5,34,92,35,68,225,161,166,218,16,16,137,112,52,41,73, -29,153,1,65,196,201,197,145,166,153,245,200,3,137,204,120,34,74,8,200,58, -112,28,211,32,130,52,78,26,26,110,248,0,0,164,4,12,70,137,195,39,252,73, -240,117,32,57,168,97,4,104,156,52,52,221,255,160,20,160,152,23,223,250,32, -148,25,174,137,58,23,51,191,244,84,12,50,9,195,39,240,81,238,2,3,107,173, -214,3,192, +1,80,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, +33,8,66,34,33,154,112,0,1,73,247,35,79,91,237,198,174,192,47,31,23,95,17, +13,51,19,35,93,68,216,209,128,0,10,192,174,79,15,32,248,8,196,24,8,107,192, +0,5,98,118,27,94,0,0,43,19,227,94,0,0,43,20,46,215,128,0,10,197,28,198,188, +0,0,86,41,100,53,224,0,2,177,79,85,175,0,0,21,138,154,45,120,0,0,172,85, +217,107,192,0,5,98,182,243,86,193,106,52,127,66,249,50,94,124,35,68,225, +146,49,13,31,170,23,201,146,243,224,200,39,12,145,136,67,134,11,49,0,0,0,0, +0,0,3,225,255,51,0,0,0,0,0,0,3,193,255,47,18,1,172,19,120,71,10,25,196,136, +113,162,156,136,199,42,57,204,144,115,132,240,149,2,248,72,197,209,58,2, +185,16,52,196,225,35,23,68,233,14,228,72,82,68,141,17,56,72,197,209,58,130, +249,44,54,96,191,9,24,186,39,88,79,39,135,147,132,140,93,19,176,35,180,138, +9,216,197,209,59,82,79,31,40,242,1,248,58,42,96,121,14,232,94,62,46,190,15, +38,31,145,33,86,65,76,242,150,143,69,48,242,179,79,45,56,243,51,207,53,64, +243,116,79,57,72,243,180,207,61,80,243,245,79,65,88,244,34,249,50,94,124, +35,68,225,146,39,163,23,201,146,243,224,200,39,12,145,61,40,183,146,37,116, +88,6,136,158,244,241,174,230,202,80,135,130,50,39,16,217,231,208,20,240,70, +68,225,86,224,79,60,64,84,75,141,7,27,157,32,66,37,194,161,168,153,51,132, +9,25,4,225,147,180,138,50,196,18,25,4,225,147,180,138,5,215,49,238,105,27, +60,185,2,72,209,56,100,237,34,140,193,4,136,209,56,100,237,34,129,117,204, +123,154,70,207,50,64,98,72,64,121,51,68,8,163,73,33,1,228,208,16,0,65,112, +152,56,196,159,31,23,77,211,195,201,199,23,150,73,169,234,34,24,49,39,199, +89,188,124,92,242,70,120,224,201,33,69,15,155,163,196,64,153,137,62,58,205, +227,226,231,146,51,199,26,6,18,92,130,64,192,148,144,102,240,23,129,133,18, +2,100,224,160,56,100,42,26,78,62,46,121,35,60,112,216,32,50,21,13,39,31,23, +60,145,154,9,46,18,1,36,64,47,148,64,98,196,132,201,57,68,132,95,18,84,141, +159,9,121,145,178,67,155,46,73,2,17,46,72,128,89,7,199,32,66,37,194,197, +217,35,120,228,131,17,46,18,243,35,100,128,172,156,98,2,40,152,151,32,130, +166,36,248,235,55,143,139,158,72,207,28,150,24,23,46,92,130,80,72,151,21,0, +100,213,103,229,245,8,186,190,144,24,78,136,24,94,152,3,142,9,113,214,111, +31,23,60,145,158,57,164,13,68,184,248,186,110,158,30,78,56,188,226,10,62, +46,121,35,60,113,18,225,27,70,18,32,10,201,208,32,134,214,208,200,84,52, +156,49,39,50,71,107,107,152,129,13,173,161,144,168,105,57,34,78,100,142, +214,215,49,16,134,214,210,220,229,81,252,49,39,50,71,107,107,158,65,13,173, +165,185,202,163,249,34,78,100,142,214,215,60,146,12,16,28,128,62,175,42,6, +143,36,136,16,64,90,242,135,192,129,67,71,147,62,65,5,215,231,214,6,215,62, +180,8,49,1,3,162,92,4,98,12,41,14,67,40,106,229,1,132,130,8,24,78,104,129, +54,62,96,224,144,13,238,124,32,2,62,146,60,51,224,120,146,164,140,137,20,0, +178,58,11,56,192,5,146,208,34,71,64,36,157,25,200,32,52,158,180,8,146,87, +129,232,217,29,5,156,179,224,116,52,100,191,28,87,62,130,214,9,79,136,104, +201,126,56,174,127,0,31,255,225,73,82,71,16,13,1,36,230,18,1,164,14,87,71, +132,0,143,0,210,131,96,31,0,211,6,42,23,50,70,1,167,13,18,14,130,36,67,232, +46,36,29,4,78,69,6,60,226,31,192,7,255,252,24,192,163,11,23,51,130,56,35, +193,56,100,243,31,6,150,46,103,4,225,147,143,114,27,63,57,241,200,169,194, +133,42,166,175,240,6,23,240,0,97,28,17,224,39,233,32,80,142,8,240,78,25,56, +9,250,136,22,39,12,156,123,144,217,240,19,245,18,6,19,154,32,79,214,124,14, +134,140,151,227,139,237,52,11,88,37,62,33,163,37,248,226,251,77,32,213,184, +64,89,56,39,49,224,137,61,196,5,96,38,35,251,200,15,18,61,96,17,62,40,6, +145,1,17,31,228,64,89,45,2,39,205,0,178,122,209,63,162,2,101,64,202,113,67, +77,247,64,92,221,197,186,196,143,4,9,19,208,1,25,187,139,112,128,178,113, +110,177,35,193,2,68,244,0,46,110,229,30,242,71,130,4,137,232,4,35,55,113, +110,16,22,78,81,239,36,120,32,72,158,128,64,147,138,25,249,0,52,72,242,2, +127,2,5,74,96,140,229,203,34,103,250,154,4,17,163,151,44,137,159,234,105,4, +33,162,93,6,73,123,13,1,165,64,202,113,251,33,6,64,14,71,78,20,101,213,207, +4,194,207,2,12,162,0,158,176,23,218,168,23,66,64,255,255,255,255,255,255, +239,127,19,214,33,187,85,2,232,72,0,32,0,0,0,0,0,0,25,136,0,0,0,0,0,0,31, +15,228,122,247,73,19,69,73,180,134,149,13,68,241,0,0,0,0,0,0,3,193,252,143, +90,67,2,104,169,54,144,210,161,168,158,32,0,0,0,0,0,0,120,127,142,73,78,20, +0,0,0,0,0,0,0,0,8,58,189,233,24,77,217,24,93,240,1,230,238,21,23,32,247,68, +13,155,184,75,189,205,35,102,128,47,114,64,185,187,143,137,4,137,33,205, +222,17,6,96,48,87,130,50,37,114,1,246,147,21,143,224,54,186,213,128,114,90, +112,164,0,0,0,0,0,0,124,63,226,117,119,128,25,55,112,96,153,57,41,197,13, +53,224,65,147,119,38,134,19,146,156,80,211,94,5,194,94,6,37,55,113,110,16, +22,78,12,19,39,37,56,161,166,188,14,74,110,226,220,32,44,156,154,24,78,74, +113,67,77,120,32,97,175,4,28,61,224,133,172,186,70,22,248,1,204,73,242,104, +97,47,128,44,196,159,11,69,175,152,32,35,100,33,142,49,39,218,76,69,237,22, +190,96,128,141,144,136,32,196,159,24,230,204,246,66,40,179,18,125,164,196, +206,185,179,61,144,140,28,196,159,6,9,146,200,71,20,98,79,180,152,135,208, +76,150,66,64,99,18,124,24,49,100,36,137,49,39,218,76,67,232,49,100,37,8,49, +39,195,186,145,149,144,150,44,196,159,105,49,31,174,164,101,100,38,10,49, +39,198,33,180,153,37,100,38,141,49,39,218,76,76,234,27,73,146,86,66,112, +163,18,124,145,4,230,142,86,66,120,211,18,125,164,197,46,144,78,104,229, +100,40,15,49,39,198,33,107,68,136,39,52,114,178,20,73,24,147,237,38,38,117, +11,90,36,65,57,163,149,144,164,68,196,159,38,134,19,46,105,56,226,150,68, +157,160,3,200,147,228,208,194,92,32,124,137,62,49,11,90,36,65,57,163,149, +178,166,74,68,159,105,49,51,168,90,209,34,9,205,28,173,149,65,82,36,249,34, +9,205,28,173,175,170,54,68,159,105,49,75,164,19,154,57,91,95,88,84,137,62, +49,13,164,201,43,111,235,141,145,39,218,76,76,234,27,73,146,86,223,216,17, +34,79,135,117,35,43,115,236,139,145,39,218,76,71,235,169,25,91,159,104,60, +137,62,12,19,37,178,182,42,68,159,105,49,15,160,153,45,149,193,18,36,248, +199,54,103,182,190,232,185,18,125,164,196,206,185,179,61,181,247,133,200, +147,225,104,181,243,4,4,109,191,190,58,68,159,105,49,23,180,90,249,130,2, +54,223,224,67,152,147,230,8,8,217,12,16,121,18,124,193,1,27,101,131,131,56, +7,38,193,198,72,0,0,0,0,0,0,0,0,198,231,240,134,39,63,136,151,95,63,136,49, +89,252,66,98,243,248,133,96,132,185,5,224,32,36,201,41,248,200,213,249,0, +131,64,7,39,192,218,148,124,137,74,216,231,198,227,141,182,124,78,40,217, +231,197,227,4,213,227,192,159,72,10,5,21,218,138,120,74,129,124,36,98,232, +228,74,81,62,160,20,10,107,181,21,114,32,105,137,194,70,46,142,68,165,19, +235,1,64,170,187,81,119,34,66,146,36,104,137,194,70,46,142,68,165,19,236,1, +64,174,187,81,95,37,134,204,23,225,35,23,71,34,82,137,246,128,160,89,93, +168,167,147,195,201,194,70,46,142,68,165,19,238,1,64,182,187,81,71,105,20, +19,177,139,163,145,41,68,16,7,6,15,82,70,72,115,96,0,0,0,0,0,93,105,160,91, +60,149,195,200,194,8,134,149,216,114,1,128,83,192,144,8,194,195,16,12,168, +110,20,120,12,141,22,16,120,12,100,22,12,120,28,78,99,192,41,224,136,115, +36,14,100,197,213,245,193,48,189,112,40,2,237,96,175,131,117,2,178,112,145, +139,163,145,131,114,70,46,142,218,27,182,72,197,209,219,56,26,53,161,166, +28,1,204,178,10,14,38,78,44,141,52,207,31,0,0,21,64,129,100,180,8,148,145, +92,203,176,160,226,100,226,200,211,76,241,240,0,1,84,2,131,137,147,142,41, +100,73,199,192,0,5,88,6,13,10,82,70,62,0,0,42,66,88,115,18,124,67,103,177, +69,49,130,12,73,242,136,108,246,40,165,177,6,36,248,134,207,71,90,138,99, +68,152,147,229,16,217,232,235,81,75,130,12,73,241,13,158,158,149,20,199,9, +49,39,202,33,179,211,210,162,151,69,24,147,225,86,224,79,79,74,138,94,20, +98,79,133,91,129,61,109,74,41,124,60,137,62,33,179,216,166,216,193,18,36, +249,68,54,123,20,218,216,137,18,124,67,103,163,173,77,177,162,100,73,242, +136,108,244,117,169,181,193,18,36,248,134,207,79,74,155,99,132,200,147,229, +16,217,233,233,83,107,162,164,73,240,171,112,39,167,165,77,175,10,145,39, +194,173,192,158,182,165,54,191,153,51,72,71,161,196,201,45,167,146,59,68, +89,24,70,206,0,0,0,0,0,0,7,129,249,153,51,104,71,161,196,201,45,167,146,59, +68,89,24,70,206,0,0,0,0,0,0,7,129,249,153,51,136,71,161,196,201,45,167,146, +59,68,89,24,70,206,0,0,0,0,0,0,7,129,249,153,51,168,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,2,1,153,51,200,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,2,1,153,51,232,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,153,52,8,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,153,52,40,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,153,52,72,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,1,2,1,135,52,102,32,76,72,1,246,136,235, +103,177,69,1,17,32,7,196,54,123,20,82,88,200,144,3,237,17,214,207,71,91, +171,37,20,65,145,32,7,218,35,173,158,142,183,66,74,41,16,92,72,1,241,13, +158,142,183,86,74,41,48,92,72,1,241,13,158,142,183,66,74,41,80,100,72,1, +246,136,235,103,167,165,213,146,138,40,200,144,3,237,17,214,207,79,75,161, +37,20,138,46,36,0,248,134,207,79,75,171,37,20,154,46,36,0,248,134,207,79, +75,161,37,20,170,46,36,0,248,85,184,19,234,201,69,24,92,72,1,240,171,112, +39,208,146,138,70,25,18,0,124,27,168,21,147,171,37,20,113,145,32,7,193,186, +129,89,58,18,81,72,226,162,64,15,180,71,91,62,172,148,90,0,168,144,3,237, +17,214,207,161,37,22,144,38,36,0,248,134,207,171,37,22,160,38,36,0,248,134, +207,161,37,22,176,42,209,68,201,218,35,173,158,197,54,4,218,40,153,56,134, +207,98,155,75,27,104,162,100,237,17,214,207,71,91,171,37,54,65,182,138,38, +78,209,29,108,244,117,186,18,83,104,131,45,20,76,156,67,103,163,173,213, +146,155,76,25,104,162,100,226,27,61,29,110,132,148,218,160,219,69,19,39, +104,142,182,122,122,93,89,41,178,141,180,81,50,118,136,235,103,167,165,208, +146,155,69,25,104,162,100,226,27,61,61,46,172,148,218,104,203,69,19,39,16, +217,233,233,116,36,166,213,70,90,40,153,56,85,184,19,234,201,77,152,101, +162,137,147,133,91,129,62,132,148,218,48,219,69,19,39,6,234,5,100,234,201, +77,156,109,162,137,147,131,117,2,178,116,36,166,209,197,218,40,153,59,68, +117,179,234,201,78,32,11,180,81,50,118,136,235,103,208,146,156,72,21,104, +162,100,226,27,62,172,148,226,128,171,69,19,39,16,217,244,36,167,22,53,123, +102,53,155,80,2,21,11,94,201,128,196,133,0,185,80,32,56,156,199,130,36,160, +72,16,78,126,54,48,5,146,208,34,82,72,1,109,20,76,155,120,28,34,1,225,32, +52,171,138,69,133,95,130,160,4,234,219,163,161,0,89,86,214,238,197,172,9,0, +31,86,221,40,29,231,63,95,200,69,220,199,225,122,183,27,72,144,63,160,138, +217,81,197,125,207,195,117,110,54,142,129,32,7,114,147,10,189,229,237,159, +130,235,209,0,96,181,17,83,236,132,37,0,63,101,8,207,71,107,74,6,105,219, +251,52,245,7,49,248,94,202,17,158,148,12,211,183,246,105,234,15,99,242,159, +129,228,176,192,185,127,46,155,185,41,197,13,55,38,3,127,255,20,138,160, +192,25,106,8,8,1,58,90,130,64,128,146,27,168,37,8,9,129,186,130,96,160,152, +27,165,171,64,32,131,25,234,10,64,65,17,11,212,19,133,18,243,167,165,163, +32,24,157,45,65,64,6,75,191,80,80,66,149,110,116,117,5,8,41,240,247,79,72, +188,8,134,81,122,84,1,173,198,212,20,48,139,113,180,181,5,36,42,220,109,29, +13,65,74,6,192,95,76,188,6,196,55,78,188,6,247,91,86,136,26,32,104,220,205, +72,1,98,234,52,122,130,136,18,72,51,117,68,3,146,27,168,40,161,37,8,207,80, +81,129,204,13,212,20,112,179,141,26,45,65,75,112,20,43,193,25,19,66,128, +153,78,40,105,144,92,104,152,131,124,27,253,128,0,10,116,3,68,146,163,9, +128,0,10,102,3,138,145,137,27,60,0,0,82,129,7,2,4,16,7,2,70,143,178,203, +164,237,35,14,25,10,134,147,143,139,158,72,207,28,54,77,47,109,13,55,113, +120,96,196,159,29,102,241,241,115,201,25,227,131,36,133,20,62,110,143,17, +16,113,137,62,62,46,155,167,135,147,142,47,44,151,79,221,64,98,37,194,94, +100,108,144,21,147,140,73,168,228,19,17,124,73,82,54,124,37,230,70,201,14, +108,185,36,155,14,243,243,83,212,69,131,132,4,12,137,114,168,37,166,145,7, +10,4,28,200,14,12,40,56,153,56,178,52,211,60,124,0,0,85,0,160,226,100,227, +138,89,18,113,240,0,1,86,1,131,66,148,145,143,128,0,10,144,93,134,0,0,43, +80,17,42,4,17,136,49,73,19,49,134,16,143,67,137,146,91,79,36,118,136,178, +48,141,156,0,0,0,0,0,0,15,3,243,49,135,16,143,67,137,146,91,79,36,118,136, +178,48,141,156,0,0,0,0,0,0,15,3,245,20,5,173,194,227,214,4,55,0,0,21,196,7, +122,192,134,241,197,192,0,5,121,25,140,64,132,122,28,76,146,218,121,35,180, +69,145,132,108,224,0,0,0,0,0,0,120,31,153,140,72,132,122,28,76,146,218,121, +35,180,69,145,132,108,224,0,0,0,0,0,0,0,32,25,140,80,132,122,28,76,146,218, +121,35,180,69,145,132,108,224,0,0,0,0,0,0,0,32,25,140,88,132,122,28,76,146, +218,121,35,180,69,145,132,108,224,0,0,0,0,0,0,8,32,25,140,96,132,122,28,76, +146,218,121,35,180,69,145,132,108,224,0,0,0,0,0,0,8,32,25,140,104,132,122, +28,76,146,218,121,35,180,69,145,132,108,224,0,0,0,0,0,0,8,32,25,140,112, +132,122,28,76,146,218,121,35,180,69,145,132,108,224,0,0,0,0,0,0,16,32,16, +113,225,0,48,156,209,2,122,244,5,34,92,35,68,225,161,166,218,16,33,18,224, +104,82,146,59,50,5,7,19,39,22,70,154,103,215,32,28,78,99,193,18,80,70,131, +165,1,205,34,8,35,68,225,161,166,239,255,4,12,70,137,195,39,248,73,7,78,3, +154,102,16,70,137,195,67,77,223,248,1,74,9,129,125,255,130,9,65,154,232, +147,161,115,59,255,5,64,195,32,156,50,126,197,14,2,3,107,173,213,0, }; #elif defined(DUK_USE_DOUBLE_BE) -DUK_INTERNAL const duk_uint8_t duk_builtins_data[4116] = { -144,148,105,224,32,68,52,228,62,12,104,200,165,132,52,167,194,138,105,243, -124,57,28,211,57,18,64,52,238,126,44,138,111,171,241,164,19,87,129,30,33, +DUK_INTERNAL const duk_uint8_t duk_builtins_data[3972] = { +144,148,105,223,160,68,52,228,62,12,104,200,165,132,52,167,194,138,105,242, +252,57,28,211,57,18,64,52,238,62,44,138,111,171,241,164,19,87,125,30,33, 167,16,145,159,8,211,136,9,225,42,5,240,145,139,163,163,8,211,136,10,228, 64,211,19,132,140,93,29,56,70,156,64,119,34,66,146,36,104,137,194,70,46, 142,172,35,78,32,47,146,195,102,11,240,145,139,163,175,8,211,136,9,228,240, 242,112,145,139,163,179,8,211,136,8,237,34,130,118,49,116,118,225,26,48,0, -1,82,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, -33,8,66,26,179,233,97,167,60,150,34,33,154,112,0,1,75,247,35,79,95,237,198, -174,200,47,31,23,95,17,13,51,19,35,93,68,216,209,128,0,10,208,174,79,15,32, -248,8,196,24,8,107,192,0,5,106,118,27,94,0,0,43,83,227,94,0,0,43,84,46,215, -128,0,10,213,28,198,188,0,0,86,169,100,53,224,0,2,181,79,85,175,0,0,21,170, -154,45,120,0,0,173,85,217,107,192,0,5,106,182,243,86,193,106,52,127,130, -249,50,94,124,35,68,225,146,49,13,31,186,23,201,146,243,224,200,39,12,145, -136,67,134,19,49,1,255,224,0,0,0,0,0,3,51,1,255,192,0,0,0,0,0,3,47,18,1, -172,19,120,71,10,25,196,136,113,162,156,136,199,42,57,204,144,115,132,240, -149,2,248,72,197,209,58,2,185,16,52,196,225,35,23,68,233,14,228,72,82,68, -141,17,56,72,197,209,58,130,249,44,54,96,191,9,24,186,39,88,79,39,135,147, -132,140,93,19,176,35,180,138,9,216,197,209,59,82,79,35,40,242,65,248,58,42, -96,121,14,232,94,62,46,190,15,42,31,145,33,86,65,76,242,214,143,73,48,242, -243,79,49,56,243,115,207,57,64,243,180,79,61,72,243,244,207,65,80,244,53, -79,69,88,244,98,30,8,200,156,67,102,120,241,79,4,100,78,21,110,4,207,32,47, -147,37,231,194,52,78,25,34,122,81,124,153,47,62,12,130,112,201,19,211,139, -121,34,87,69,128,104,137,239,83,18,238,108,165,2,162,92,104,56,220,233,1,8, -151,10,134,162,100,206,16,18,50,9,195,39,105,20,101,136,18,25,4,225,147, -180,138,5,215,49,238,105,27,60,185,1,36,104,156,50,118,145,70,96,129,34,52, -78,25,59,72,160,93,115,30,230,145,179,204,144,12,73,8,15,38,104,128,138,52, -146,16,30,77,1,0,2,11,132,193,198,36,248,248,186,110,158,30,78,56,188,194, -70,183,170,136,48,98,79,142,179,120,248,185,228,140,241,193,146,66,138,31, -55,71,138,128,153,137,62,58,205,227,226,231,146,51,199,26,6,18,92,146,64, -96,74,72,51,120,43,192,97,68,128,153,56,72,7,12,133,67,73,199,197,207,36, -103,142,35,2,3,33,80,210,113,241,115,201,25,160,146,225,160,9,34,1,124,178, -1,139,18,19,36,229,146,8,190,36,169,27,62,18,243,35,100,135,54,92,162,2,17, -46,72,128,89,7,200,32,33,18,225,98,236,145,188,130,64,196,75,132,188,200, -217,32,43,39,28,128,69,19,18,228,144,42,98,79,142,179,120,248,185,228,140, -241,201,97,129,114,229,201,37,2,68,184,200,1,147,93,159,153,213,34,235,250, -96,48,157,32,24,94,160,1,199,4,184,235,55,143,139,158,72,207,28,226,3,81, -46,62,46,155,167,135,147,142,47,60,129,71,197,207,36,103,142,34,92,35,104, -194,68,1,89,58,36,8,109,109,12,133,67,73,195,18,115,36,118,182,185,168,8, -109,109,12,133,67,73,201,18,115,36,118,182,185,168,130,27,91,75,115,149,71, -240,196,156,201,29,173,174,129,2,27,91,75,115,149,71,242,68,156,201,29,173, -174,129,34,12,16,28,128,62,191,42,3,71,146,68,4,16,22,188,161,240,16,40, -104,242,103,196,16,93,158,125,96,110,115,235,64,131,16,16,58,37,192,70,32, -194,144,114,25,67,95,40,6,18,8,32,48,156,209,2,108,124,96,224,144,6,247,62, -16,0,143,164,143,12,248,15,18,84,145,145,34,128,11,35,160,179,140,0,44,150, -129,18,58,0,146,116,103,32,128,105,61,104,17,36,175,1,232,217,29,5,156,179, -224,58,26,50,95,142,43,159,64,181,130,83,226,26,50,95,142,43,159,192,7,255, -248,41,42,72,226,1,160,18,78,97,32,26,64,114,186,60,32,4,120,6,148,13,128, -124,3,76,12,84,46,100,140,3,78,13,18,14,130,36,67,232,23,18,14,130,39,34, -131,30,113,15,224,3,255,253,6,48,40,194,197,204,224,142,8,240,78,25,60,231, -192,210,197,204,224,156,50,113,238,67,103,232,62,28,138,156,104,82,170,107, -255,32,48,191,144,1,132,112,71,128,159,168,128,161,28,17,224,156,50,112,19, -245,144,22,39,12,156,123,144,217,240,19,245,146,3,9,205,16,39,236,62,3,161, -163,37,248,226,251,141,1,107,4,167,196,52,100,191,28,95,113,164,13,91,132, -5,147,130,115,30,8,147,222,64,43,1,49,31,224,64,60,72,245,128,68,249,32,13, -34,2,34,63,204,128,89,45,2,39,209,0,89,61,104,159,213,0,153,80,50,156,80, -211,126,16,11,155,184,183,88,145,224,129,34,122,64,17,155,184,183,8,11,39, -22,235,18,60,16,36,79,72,1,115,119,40,247,146,60,16,36,79,72,32,140,221, -197,184,64,89,57,71,188,145,224,129,34,122,65,1,39,20,51,244,0,52,72,242,2, -127,18,2,165,48,70,114,229,145,51,253,141,1,4,104,229,203,34,103,251,26,64, -132,52,75,160,201,47,105,160,26,84,12,167,31,186,8,50,0,114,58,113,163,46, -190,120,35,11,60,4,25,68,81,61,96,47,181,80,46,132,128,255,223,255,255,255, -255,255,254,39,172,67,118,170,5,208,144,0,0,0,0,0,0,0,0,115,16,31,254,0,0, -0,0,0,0,8,245,238,146,38,138,147,105,13,42,26,137,226,3,255,128,0,0,0,0,0, -1,30,180,134,4,209,82,109,33,165,67,81,60,64,255,240,0,0,0,0,0,0,15,210,62, -72,91,155,0,242,192,0,0,0,0,0,0,135,88,11,237,72,5,38,210,27,50,24,145,128, -134,127,255,255,255,255,255,254,67,172,67,118,164,2,147,105,13,153,12,72, -192,195,63,255,255,255,255,255,255,16,240,70,68,226,27,51,199,138,120,35, -34,112,171,112,38,121,7,16,137,112,168,106,38,77,193,1,40,151,16,217,144, -196,142,224,144,21,18,227,65,198,238,9,67,81,46,72,5,39,16,217,144,196,142, -224,152,228,148,227,64,0,0,0,0,0,0,0,0,131,175,223,16,194,111,8,97,119,224, -3,205,220,42,46,65,238,200,13,155,184,75,189,205,35,102,128,47,116,64,92, -221,199,196,130,68,144,230,239,72,65,152,12,21,224,140,137,92,128,62,210, -98,177,252,3,107,173,88,3,146,211,141,33,255,224,0,0,0,0,0,3,19,175,188,0, -100,221,193,130,100,228,167,20,52,215,129,3,38,238,77,12,39,37,56,161,166, -188,10,194,94,6,18,155,184,183,8,11,39,6,9,147,146,156,80,211,94,7,18,155, -184,183,8,11,39,38,134,19,146,156,80,211,94,8,12,53,224,130,195,222,8,77, -133,210,24,91,224,3,152,147,228,208,194,95,0,44,196,159,11,69,175,152,32, -35,100,33,135,24,147,237,38,34,246,139,95,48,64,70,200,68,8,49,39,198,57, -179,61,144,138,22,98,79,180,152,153,215,54,103,178,17,129,204,73,240,96, -153,44,132,112,163,18,125,164,196,62,130,100,178,18,1,140,73,240,96,197, -144,146,18,98,79,180,152,135,208,98,200,74,8,49,39,195,186,145,149,144,150, -22,98,79,180,152,143,215,82,50,178,19,2,140,73,241,136,109,38,73,89,9,161, -166,36,251,73,137,157,67,105,50,74,200,78,10,49,39,201,16,78,104,229,100, -39,134,152,147,237,38,41,116,130,115,71,43,33,64,60,196,159,24,133,173,18, -32,156,209,202,200,81,18,49,39,218,76,76,234,22,180,72,130,115,71,43,33,72, -68,196,159,38,134,19,46,105,56,226,150,68,157,160,1,228,73,242,104,97,46, -16,31,34,79,140,66,214,137,16,78,104,229,108,169,137,72,147,237,38,38,117, -11,90,36,65,57,163,149,178,168,21,34,79,146,32,156,209,202,218,250,161,178, -36,251,73,138,93,32,156,209,202,218,250,193,82,36,248,196,54,147,36,173, -191,174,27,34,79,180,152,153,212,54,147,36,173,191,176,17,34,79,135,117,35, -43,115,236,133,200,147,237,38,35,245,212,140,173,207,180,15,34,79,131,4, -201,108,173,133,72,147,237,38,33,244,19,37,178,184,17,34,79,140,115,102, -123,107,238,133,200,147,237,38,38,117,205,153,237,175,188,23,34,79,133,162, -215,204,16,17,182,254,248,116,137,62,210,98,47,104,181,243,4,4,109,191,192, -131,152,147,230,8,8,217,12,16,60,137,62,96,128,141,178,193,160,206,1,201, -176,113,146,0,0,0,0,0,0,0,0,49,185,252,65,137,207,227,37,215,207,227,12,86, -127,24,152,188,254,49,88,33,46,65,120,72,4,153,37,63,33,13,127,148,4,26,0, -57,62,6,228,163,228,74,86,215,62,55,28,110,179,226,113,70,223,62,47,24,38, -191,30,2,125,32,40,20,87,114,41,225,42,5,240,145,139,163,145,41,68,250,128, -80,41,174,228,85,200,129,166,39,9,24,186,57,18,148,79,172,5,2,170,238,69, -220,137,10,72,145,162,39,9,24,186,57,18,148,79,176,5,2,186,238,69,124,150, -27,48,95,132,140,93,28,137,74,39,218,2,129,101,119,34,158,79,15,39,9,24, -186,57,18,148,79,184,5,2,218,238,69,29,164,80,78,198,46,142,68,165,16,64, -28,24,61,73,25,33,205,128,129,167,166,0,0,0,0,1,108,242,151,15,39,8,34,26, -87,97,200,3,0,167,129,32,8,194,195,16,6,84,55,10,60,3,35,69,132,30,1,140, -130,193,143,1,196,230,60,2,158,8,131,153,64,115,42,46,191,176,8,194,246,0, -80,5,220,193,95,6,234,5,100,225,35,23,71,35,6,228,140,93,29,180,55,108,145, -139,163,182,112,52,107,67,76,56,3,153,132,20,28,76,156,89,26,105,158,62,0, -0,42,193,2,201,104,17,41,34,156,204,176,160,226,100,226,200,211,76,241,240, -0,1,86,2,131,137,147,142,41,100,73,199,192,0,5,96,6,13,10,82,70,62,0,0,42, -130,88,115,18,124,67,103,177,69,49,129,6,36,249,68,54,123,20,82,216,65,137, -62,33,179,209,214,162,152,208,147,18,124,162,27,61,29,106,41,112,32,196, -159,16,217,233,233,81,76,112,73,137,62,81,13,158,158,149,20,186,20,98,79, -133,91,129,61,61,42,41,120,40,196,159,10,183,2,122,218,148,82,248,60,137, -62,33,179,216,166,216,192,137,18,124,162,27,61,138,109,108,34,68,159,16, -217,232,235,83,108,104,76,137,62,81,13,158,142,181,54,184,17,34,79,136,108, -244,244,169,182,56,38,68,159,40,134,207,79,74,155,93,10,145,39,194,173,192, -158,158,149,54,188,21,34,79,133,91,129,61,109,74,109,125,155,51,136,71,161, -196,201,45,167,146,59,68,89,24,70,206,1,255,128,0,0,0,0,0,1,155,51,168,71, -161,196,201,45,167,146,59,68,89,24,70,206,1,255,128,0,0,0,0,0,1,155,51,200, -71,161,196,201,45,167,146,59,68,89,24,70,206,1,255,128,0,0,0,0,0,1,155,51, -232,71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,0,0,0,0,0,0,1,155,52, -8,71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,0,0,0,0,0,0,1,155,52,40, -71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,128,0,0,0,0,0,1,155,52,72, -71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,128,0,0,0,0,0,1,155,52, -104,71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,128,0,0,0,0,0,1,155, -52,136,71,161,196,201,45,167,146,59,68,89,24,70,206,2,1,0,0,0,0,0,0,1,135, -52,166,32,76,72,1,246,136,235,103,177,69,0,136,144,3,226,27,61,138,41,44, -50,36,0,251,68,117,179,209,214,234,201,69,16,50,36,0,251,68,117,179,209, -214,232,73,69,34,5,196,128,31,16,217,232,235,117,100,162,147,2,226,64,15, -136,108,244,117,186,18,81,74,129,145,32,7,218,35,173,158,158,151,86,74,40, -161,145,32,7,218,35,173,158,158,151,66,74,41,20,46,36,0,248,134,207,79,75, -171,37,20,154,23,18,0,124,67,103,167,165,208,146,138,85,11,137,0,62,21,110, -4,250,178,81,70,11,137,0,62,21,110,4,250,18,81,72,193,145,32,7,193,186,129, -89,58,178,81,71,12,137,0,62,13,212,10,201,208,146,138,71,10,137,0,62,209, -29,108,250,178,81,104,1,81,32,7,218,35,173,159,66,74,45,32,38,36,0,248,134, -207,171,37,22,160,19,18,0,124,67,103,208,146,139,88,10,180,81,50,118,136, -235,103,177,77,128,155,69,19,39,16,217,236,83,105,97,182,138,38,78,209,29, -108,244,117,186,178,83,100,13,180,81,50,118,136,235,103,163,173,208,146, -155,68,12,180,81,50,113,13,158,142,183,86,74,109,48,50,209,68,201,196,54, -122,58,221,9,41,181,64,219,69,19,39,104,142,182,122,122,93,89,41,178,134, -218,40,153,59,68,117,179,211,210,232,73,77,162,134,90,40,153,56,134,207,79, -75,171,37,54,154,25,104,162,100,226,27,61,61,46,132,148,218,168,101,162, -137,147,133,91,129,62,172,148,217,131,45,20,76,156,42,220,9,244,36,166,209, -131,109,20,76,156,27,168,21,147,171,37,54,112,219,69,19,39,6,234,5,100,232, -73,77,163,133,218,40,153,59,68,117,179,234,201,78,32,5,218,40,153,59,68, -117,179,232,73,78,36,5,90,40,153,56,134,207,171,37,56,160,21,104,162,100, -226,27,62,132,148,226,195,95,182,97,176,218,128,8,84,45,123,38,1,137,10,1, -114,160,64,56,156,199,130,36,160,72,8,39,63,27,24,1,100,180,8,148,146,0,45, -162,137,147,111,2,8,4,16,7,8,96,120,72,8,0,183,225,81,98,138,237,33,58,182, -232,232,64,64,2,107,177,187,181,85,22,7,213,183,74,1,255,49,114,23,247,209, -207,120,94,173,198,210,36,3,255,113,84,118,82,184,47,224,221,91,141,163, -160,72,7,251,121,111,98,164,220,161,192,186,244,64,64,9,33,251,84,68,45,24, -15,217,66,51,209,218,210,128,127,205,65,60,204,254,119,154,23,178,132,103, -165,0,255,218,130,121,153,252,239,54,168,48,6,90,130,1,0,39,75,80,72,8,9, -33,186,130,80,64,76,13,212,19,2,130,96,110,150,173,0,65,6,51,212,20,128,65, -17,11,212,19,130,137,121,211,210,209,144,6,39,75,80,80,0,201,119,234,10,8, -41,86,231,71,80,80,129,79,135,186,122,69,224,34,25,69,233,80,3,91,141,168, -40,96,139,113,180,181,5,36,21,110,54,142,134,160,165,1,176,23,211,47,0,216, -134,233,215,128,111,117,181,104,128,209,3,70,230,106,64,5,139,168,209,234, -10,32,36,144,102,234,136,3,146,27,168,40,160,146,132,103,168,40,192,115,3, -117,5,28,22,113,163,69,168,41,103,1,66,188,17,145,52,40,4,202,113,67,76, -130,227,68,194,13,240,108,0,0,83,96,0,2,161,0,104,146,84,97,48,0,1,78,192, -56,169,24,145,179,192,0,5,48,8,56,16,32,128,56,18,52,125,166,86,147,182, -140,28,50,21,13,39,31,23,60,145,158,56,140,141,47,113,6,155,186,188,24,49, -39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,197,68,14,49,39, -199,197,211,116,240,242,113,197,230,18,180,253,228,3,17,46,18,243,35,100, -128,172,156,114,70,163,146,76,34,248,146,164,108,248,75,204,141,146,28,217, -114,137,27,78,251,241,173,234,162,160,225,1,3,34,92,170,9,105,164,32,225, -64,131,155,1,193,133,7,19,39,22,70,154,103,143,128,0,10,176,20,28,76,156, -113,75,34,78,62,0,0,43,0,48,104,82,146,49,240,0,1,84,11,180,192,0,5,114,1, -18,160,65,24,131,20,145,25,172,48,132,122,28,76,146,218,121,35,180,69,145, -132,108,224,31,248,0,0,0,0,0,0,25,172,56,132,122,28,76,146,218,121,35,180, -69,145,132,108,224,31,248,0,0,0,0,0,0,40,160,45,110,23,30,176,33,184,0,0, -175,32,29,235,2,27,199,23,0,0,22,4,51,88,129,8,244,56,153,37,180,242,71, -104,139,35,8,217,192,63,240,0,0,0,0,0,0,51,88,145,8,244,56,153,37,180,242, -71,104,139,35,8,217,192,64,0,0,0,0,0,0,0,51,88,161,8,244,56,153,37,180,242, -71,104,139,35,8,217,192,64,0,0,0,0,0,0,0,51,88,177,8,244,56,153,37,180,242, -71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51,88,193,8,244,56,153,37,180, -242,71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51,88,209,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51,88,225,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,64,32,0,0,0,0,0,0,32,227,194,0,97,57, -162,4,245,232,5,34,92,35,68,225,161,166,218,16,16,137,112,52,41,73,29,153, -1,65,196,201,197,145,166,153,245,200,3,137,204,120,34,74,8,200,58,112,28, -211,32,130,52,78,26,26,110,248,0,0,164,4,12,70,137,195,39,252,73,240,117, -32,57,168,97,4,104,156,52,52,221,255,160,20,160,152,23,223,250,32,148,25, -174,137,58,23,51,191,244,84,12,50,9,195,39,240,81,238,2,3,107,173,214,3, -192, +1,80,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, +33,8,66,34,33,154,112,0,1,73,247,35,79,91,237,198,174,192,47,31,23,95,17, +13,51,19,35,93,68,216,209,128,0,10,192,174,79,15,32,248,8,196,24,8,107,192, +0,5,98,118,27,94,0,0,43,19,227,94,0,0,43,20,46,215,128,0,10,197,28,198,188, +0,0,86,41,100,53,224,0,2,177,79,85,175,0,0,21,138,154,45,120,0,0,172,85, +217,107,192,0,5,98,182,243,86,193,106,52,127,66,249,50,94,124,35,68,225, +146,49,13,31,170,23,201,146,243,224,200,39,12,145,136,67,134,11,49,1,255, +224,0,0,0,0,0,3,51,1,255,192,0,0,0,0,0,3,47,18,1,172,19,120,71,10,25,196, +136,113,162,156,136,199,42,57,204,144,115,132,240,149,2,248,72,197,209,58, +2,185,16,52,196,225,35,23,68,233,14,228,72,82,68,141,17,56,72,197,209,58, +130,249,44,54,96,191,9,24,186,39,88,79,39,135,147,132,140,93,19,176,35,180, +138,9,216,197,209,59,82,79,31,40,242,1,248,58,42,96,121,14,232,94,62,46, +190,15,38,31,145,33,86,65,76,242,150,143,69,48,242,179,79,45,56,243,51,207, +53,64,243,116,79,57,72,243,180,207,61,80,243,245,79,65,88,244,34,249,50,94, +124,35,68,225,146,39,163,23,201,146,243,224,200,39,12,145,61,40,183,146,37, +116,88,6,136,158,244,241,174,230,202,80,135,130,50,39,16,217,231,208,20, +240,70,68,225,86,224,79,60,64,84,75,141,7,27,157,32,66,37,194,161,168,153, +51,132,9,25,4,225,147,180,138,50,196,18,25,4,225,147,180,138,5,215,49,238, +105,27,60,185,2,72,209,56,100,237,34,140,193,4,136,209,56,100,237,34,129, +117,204,123,154,70,207,50,64,98,72,64,121,51,68,8,163,73,33,1,228,208,16,0, +65,112,152,56,196,159,31,23,77,211,195,201,199,23,150,73,169,234,34,24,49, +39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,196,64,153,137,62, +58,205,227,226,231,146,51,199,26,6,18,92,130,64,192,148,144,102,240,23,129, +133,18,2,100,224,160,56,100,42,26,78,62,46,121,35,60,112,216,32,50,21,13, +39,31,23,60,145,154,9,46,18,1,36,64,47,148,64,98,196,132,201,57,68,132,95, +18,84,141,159,9,121,145,178,67,155,46,73,2,17,46,72,128,89,7,199,32,66,37, +194,197,217,35,120,228,131,17,46,18,243,35,100,128,172,156,98,2,40,152,151, +32,130,166,36,248,235,55,143,139,158,72,207,28,150,24,23,46,92,130,80,72, +151,21,0,100,213,103,229,245,8,186,190,144,24,78,136,24,94,152,3,142,9,113, +214,111,31,23,60,145,158,57,164,13,68,184,248,186,110,158,30,78,56,188,226, +10,62,46,121,35,60,113,18,225,27,70,18,32,10,201,208,32,134,214,208,200,84, +52,156,49,39,50,71,107,107,152,129,13,173,161,144,168,105,57,34,78,100,142, +214,215,49,16,134,214,210,220,229,81,252,49,39,50,71,107,107,158,65,13,173, +165,185,202,163,249,34,78,100,142,214,215,60,146,12,16,28,128,62,175,42,6, +143,36,136,16,64,90,242,135,192,129,67,71,147,62,65,5,215,231,214,6,215,62, +180,8,49,1,3,162,92,4,98,12,41,14,67,40,106,229,1,132,130,8,24,78,104,129, +54,62,96,224,144,13,238,124,32,2,62,146,60,51,224,120,146,164,140,137,20,0, +178,58,11,56,192,5,146,208,34,71,64,36,157,25,200,32,52,158,180,8,146,87, +129,232,217,29,5,156,179,224,116,52,100,191,28,87,62,130,214,9,79,136,104, +201,126,56,174,127,0,31,255,225,73,82,71,16,13,1,36,230,18,1,164,14,87,71, +132,0,143,0,210,131,96,31,0,211,6,42,23,50,70,1,167,13,18,14,130,36,67,232, +46,36,29,4,78,69,6,60,226,31,192,7,255,252,24,192,163,11,23,51,130,56,35, +193,56,100,243,31,6,150,46,103,4,225,147,143,114,27,63,57,241,200,169,194, +133,42,166,175,240,6,23,240,0,97,28,17,224,39,233,32,80,142,8,240,78,25,56, +9,250,136,22,39,12,156,123,144,217,240,19,245,18,6,19,154,32,79,214,124,14, +134,140,151,227,139,237,52,11,88,37,62,33,163,37,248,226,251,77,32,213,184, +64,89,56,39,49,224,137,61,196,5,96,38,35,251,200,15,18,61,96,17,62,40,6, +145,1,17,31,228,64,89,45,2,39,205,0,178,122,209,63,162,2,101,64,202,113,67, +77,247,64,92,221,197,186,196,143,4,9,19,208,1,25,187,139,112,128,178,113, +110,177,35,193,2,68,244,0,46,110,229,30,242,71,130,4,137,232,4,35,55,113, +110,16,22,78,81,239,36,120,32,72,158,128,64,147,138,25,249,0,52,72,242,2, +127,2,5,74,96,140,229,203,34,103,250,154,4,17,163,151,44,137,159,234,105,4, +33,162,93,6,73,123,13,1,165,64,202,113,251,33,6,64,14,71,78,20,101,213,207, +4,194,207,2,12,162,0,158,176,23,218,168,23,66,64,127,239,255,255,255,255, +255,255,19,214,33,187,85,2,232,72,0,0,0,0,0,0,0,0,57,136,15,255,0,0,0,0,0, +0,4,122,247,73,19,69,73,180,134,149,13,68,241,1,255,192,0,0,0,0,0,0,143,90, +67,2,104,169,54,144,210,161,168,158,32,127,248,0,0,0,0,0,0,14,73,78,20,0,0, +0,0,0,0,0,0,8,58,189,233,24,77,217,24,93,240,1,230,238,21,23,32,247,68,13, +155,184,75,189,205,35,102,128,47,114,64,185,187,143,137,4,137,33,205,222, +17,6,96,48,87,130,50,37,114,1,246,147,21,143,224,54,186,213,128,114,90,112, +164,63,252,0,0,0,0,0,0,98,117,119,128,25,55,112,96,153,57,41,197,13,53,224, +65,147,119,38,134,19,146,156,80,211,94,5,194,94,6,37,55,113,110,16,22,78, +12,19,39,37,56,161,166,188,14,74,110,226,220,32,44,156,154,24,78,74,113,67, +77,120,32,97,175,4,28,61,224,133,172,186,70,22,248,1,204,73,242,104,97,47, +128,44,196,159,11,69,175,152,32,35,100,33,142,49,39,218,76,69,237,22,190, +96,128,141,144,136,32,196,159,24,230,204,246,66,40,179,18,125,164,196,206, +185,179,61,144,140,28,196,159,6,9,146,200,71,20,98,79,180,152,135,208,76, +150,66,64,99,18,124,24,49,100,36,137,49,39,218,76,67,232,49,100,37,8,49,39, +195,186,145,149,144,150,44,196,159,105,49,31,174,164,101,100,38,10,49,39, +198,33,180,153,37,100,38,141,49,39,218,76,76,234,27,73,146,86,66,112,163, +18,124,145,4,230,142,86,66,120,211,18,125,164,197,46,144,78,104,229,100,40, +15,49,39,198,33,107,68,136,39,52,114,178,20,73,24,147,237,38,38,117,11,90, +36,65,57,163,149,144,164,68,196,159,38,134,19,46,105,56,226,150,68,157,160, +3,200,147,228,208,194,92,32,124,137,62,49,11,90,36,65,57,163,149,178,166, +74,68,159,105,49,51,168,90,209,34,9,205,28,173,149,65,82,36,249,34,9,205, +28,173,175,170,54,68,159,105,49,75,164,19,154,57,91,95,88,84,137,62,49,13, +164,201,43,111,235,141,145,39,218,76,76,234,27,73,146,86,223,216,17,34,79, +135,117,35,43,115,236,139,145,39,218,76,71,235,169,25,91,159,104,60,137,62, +12,19,37,178,182,42,68,159,105,49,15,160,153,45,149,193,18,36,248,199,54, +103,182,190,232,185,18,125,164,196,206,185,179,61,181,247,133,200,147,225, +104,181,243,4,4,109,191,190,58,68,159,105,49,23,180,90,249,130,2,54,223, +224,67,152,147,230,8,8,217,12,16,121,18,124,193,1,27,101,131,131,56,7,38, +193,198,72,0,0,0,0,0,0,0,0,198,231,240,134,39,63,136,151,95,63,136,49,89, +252,66,98,243,248,133,96,132,185,5,224,32,36,201,41,248,200,213,249,0,131, +64,7,39,192,218,148,124,137,74,216,231,198,227,141,182,124,78,40,217,231, +197,227,4,213,227,192,159,72,10,5,21,218,138,120,74,129,124,36,98,232,228, +74,81,62,160,20,10,107,181,21,114,32,105,137,194,70,46,142,68,165,19,235,1, +64,170,187,81,119,34,66,146,36,104,137,194,70,46,142,68,165,19,236,1,64, +174,187,81,95,37,134,204,23,225,35,23,71,34,82,137,246,128,160,89,93,168, +167,147,195,201,194,70,46,142,68,165,19,238,1,64,182,187,81,71,105,20,19, +177,139,163,145,41,68,16,7,6,15,82,70,72,115,96,32,105,221,0,0,0,0,0,91,60, +149,195,200,194,8,134,149,216,114,1,128,83,192,144,8,194,195,16,12,168,110, +20,120,12,141,22,16,120,12,100,22,12,120,28,78,99,192,41,224,136,115,36,14, +100,197,213,245,193,48,189,112,40,2,237,96,175,131,117,2,178,112,145,139, +163,145,131,114,70,46,142,218,27,182,72,197,209,219,56,26,53,161,166,28,1, +204,178,10,14,38,78,44,141,52,207,31,0,0,21,64,129,100,180,8,148,145,92, +203,176,160,226,100,226,200,211,76,241,240,0,1,84,2,131,137,147,142,41,100, +73,199,192,0,5,88,6,13,10,82,70,62,0,0,42,66,88,115,18,124,67,103,177,69, +49,130,12,73,242,136,108,246,40,165,177,6,36,248,134,207,71,90,138,99,68, +152,147,229,16,217,232,235,81,75,130,12,73,241,13,158,158,149,20,199,9,49, +39,202,33,179,211,210,162,151,69,24,147,225,86,224,79,79,74,138,94,20,98, +79,133,91,129,61,109,74,41,124,60,137,62,33,179,216,166,216,193,18,36,249, +68,54,123,20,218,216,137,18,124,67,103,163,173,77,177,162,100,73,242,136, +108,244,117,169,181,193,18,36,248,134,207,79,74,155,99,132,200,147,229,16, +217,233,233,83,107,162,164,73,240,171,112,39,167,165,77,175,10,145,39,194, +173,192,158,182,165,54,191,153,51,72,71,161,196,201,45,167,146,59,68,89,24, +70,206,1,255,128,0,0,0,0,0,1,153,51,104,71,161,196,201,45,167,146,59,68,89, +24,70,206,1,255,128,0,0,0,0,0,1,153,51,136,71,161,196,201,45,167,146,59,68, +89,24,70,206,1,255,128,0,0,0,0,0,1,153,51,168,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,0,0,0,0,0,0,1,153,51,200,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,0,0,0,0,0,0,1,153,51,232,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,128,0,0,0,0,0,1,153,52,8,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,128,0,0,0,0,0,1,153,52,40,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,128,0,0,0,0,0,1,153,52,72,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,1,0,0,0,0,0,0,1,135,52,102,32,76,72,1,246,136,235,103, +177,69,1,17,32,7,196,54,123,20,82,88,200,144,3,237,17,214,207,71,91,171,37, +20,65,145,32,7,218,35,173,158,142,183,66,74,41,16,92,72,1,241,13,158,142, +183,86,74,41,48,92,72,1,241,13,158,142,183,66,74,41,80,100,72,1,246,136, +235,103,167,165,213,146,138,40,200,144,3,237,17,214,207,79,75,161,37,20, +138,46,36,0,248,134,207,79,75,171,37,20,154,46,36,0,248,134,207,79,75,161, +37,20,170,46,36,0,248,85,184,19,234,201,69,24,92,72,1,240,171,112,39,208, +146,138,70,25,18,0,124,27,168,21,147,171,37,20,113,145,32,7,193,186,129,89, +58,18,81,72,226,162,64,15,180,71,91,62,172,148,90,0,168,144,3,237,17,214, +207,161,37,22,144,38,36,0,248,134,207,171,37,22,160,38,36,0,248,134,207, +161,37,22,176,42,209,68,201,218,35,173,158,197,54,4,218,40,153,56,134,207, +98,155,75,27,104,162,100,237,17,214,207,71,91,171,37,54,65,182,138,38,78, +209,29,108,244,117,186,18,83,104,131,45,20,76,156,67,103,163,173,213,146, +155,76,25,104,162,100,226,27,61,29,110,132,148,218,160,219,69,19,39,104, +142,182,122,122,93,89,41,178,141,180,81,50,118,136,235,103,167,165,208,146, +155,69,25,104,162,100,226,27,61,61,46,172,148,218,104,203,69,19,39,16,217, +233,233,116,36,166,213,70,90,40,153,56,85,184,19,234,201,77,152,101,162, +137,147,133,91,129,62,132,148,218,48,219,69,19,39,6,234,5,100,234,201,77, +156,109,162,137,147,131,117,2,178,116,36,166,209,197,218,40,153,59,68,117, +179,234,201,78,32,11,180,81,50,118,136,235,103,208,146,156,72,21,104,162, +100,226,27,62,172,148,226,128,171,69,19,39,16,217,244,36,167,22,53,123,102, +53,155,80,2,21,11,94,201,128,196,133,0,185,80,32,56,156,199,130,36,160,72, +16,78,126,54,48,5,146,208,34,82,72,1,109,20,76,155,120,28,34,1,225,32,32,2, +223,133,69,138,43,180,132,234,219,163,161,1,0,9,174,198,238,213,84,88,31, +86,221,40,7,252,197,200,95,223,71,61,225,122,183,27,72,144,15,253,197,81, +217,74,224,191,131,117,110,54,142,129,32,31,237,229,189,138,147,114,135,2, +235,209,1,0,36,135,237,81,16,180,96,63,101,8,207,71,107,74,1,255,53,4,243, +51,249,222,104,94,202,17,158,148,3,255,106,9,230,103,243,188,210,159,129, +228,176,192,185,127,46,155,185,41,197,13,55,38,3,127,255,20,138,160,192,25, +106,8,8,1,58,90,130,64,128,146,27,168,37,8,9,129,186,130,96,160,152,27,165, +171,64,32,131,25,234,10,64,65,17,11,212,19,133,18,243,167,165,163,32,24, +157,45,65,64,6,75,191,80,80,66,149,110,116,117,5,8,41,240,247,79,72,188,8, +134,81,122,84,1,173,198,212,20,48,139,113,180,181,5,36,42,220,109,29,13,65, +74,6,192,95,76,188,6,196,55,78,188,6,247,91,86,136,26,32,104,220,205,72,1, +98,234,52,122,130,136,18,72,51,117,68,3,146,27,168,40,161,37,8,207,80,81, +129,204,13,212,20,112,179,141,26,45,65,75,112,20,43,193,25,19,66,128,153, +78,40,105,144,92,104,152,131,124,27,253,128,0,10,116,3,68,146,163,9,128,0, +10,102,3,138,145,137,27,60,0,0,82,129,7,2,4,16,7,2,70,143,178,203,164,237, +35,14,25,10,134,147,143,139,158,72,207,28,54,77,47,109,13,55,113,120,96, +196,159,29,102,241,241,115,201,25,227,131,36,133,20,62,110,143,17,16,113, +137,62,62,46,155,167,135,147,142,47,44,151,79,221,64,98,37,194,94,100,108, +144,21,147,140,73,168,228,19,17,124,73,82,54,124,37,230,70,201,14,108,185, +36,155,14,243,243,83,212,69,131,132,4,12,137,114,168,37,166,145,7,10,4,28, +200,14,12,40,56,153,56,178,52,211,60,124,0,0,85,0,160,226,100,227,138,89, +18,113,240,0,1,86,1,131,66,148,145,143,128,0,10,144,93,134,0,0,43,80,17,42, +4,17,136,49,73,19,49,134,16,143,67,137,146,91,79,36,118,136,178,48,141,156, +3,255,0,0,0,0,0,0,3,49,135,16,143,67,137,146,91,79,36,118,136,178,48,141, +156,3,255,0,0,0,0,0,0,5,20,5,173,194,227,214,4,55,0,0,21,196,7,122,192,134, +241,197,192,0,5,121,25,140,64,132,122,28,76,146,218,121,35,180,69,145,132, +108,224,31,248,0,0,0,0,0,0,25,140,72,132,122,28,76,146,218,121,35,180,69, +145,132,108,224,32,0,0,0,0,0,0,0,25,140,80,132,122,28,76,146,218,121,35, +180,69,145,132,108,224,32,0,0,0,0,0,0,0,25,140,88,132,122,28,76,146,218, +121,35,180,69,145,132,108,224,32,8,0,0,0,0,0,0,25,140,96,132,122,28,76,146, +218,121,35,180,69,145,132,108,224,32,8,0,0,0,0,0,0,25,140,104,132,122,28, +76,146,218,121,35,180,69,145,132,108,224,32,8,0,0,0,0,0,0,25,140,112,132, +122,28,76,146,218,121,35,180,69,145,132,108,224,32,16,0,0,0,0,0,0,16,113, +225,0,48,156,209,2,122,244,5,34,92,35,68,225,161,166,218,16,33,18,224,104, +82,146,59,50,5,7,19,39,22,70,154,103,215,32,28,78,99,193,18,80,70,131,165, +1,205,34,8,35,68,225,161,166,239,255,4,12,70,137,195,39,248,73,7,78,3,154, +102,16,70,137,195,67,77,223,248,1,74,9,129,125,255,130,9,65,154,232,147, +161,115,59,255,5,64,195,32,156,50,126,197,14,2,3,107,173,213,0, }; #elif defined(DUK_USE_DOUBLE_ME) -DUK_INTERNAL const duk_uint8_t duk_builtins_data[4116] = { -144,148,105,224,32,68,52,228,62,12,104,200,165,132,52,167,194,138,105,243, -124,57,28,211,57,18,64,52,238,126,44,138,111,171,241,164,19,87,129,30,33, +DUK_INTERNAL const duk_uint8_t duk_builtins_data[3972] = { +144,148,105,223,160,68,52,228,62,12,104,200,165,132,52,167,194,138,105,242, +252,57,28,211,57,18,64,52,238,62,44,138,111,171,241,164,19,87,125,30,33, 167,16,145,159,8,211,136,9,225,42,5,240,145,139,163,163,8,211,136,10,228, 64,211,19,132,140,93,29,56,70,156,64,119,34,66,146,36,104,137,194,70,46, 142,172,35,78,32,47,146,195,102,11,240,145,139,163,175,8,211,136,9,228,240, 242,112,145,139,163,179,8,211,136,8,237,34,130,118,49,116,118,225,26,48,0, -1,82,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, -33,8,66,26,179,233,97,167,60,150,34,33,154,112,0,1,75,247,35,79,95,237,198, -174,200,47,31,23,95,17,13,51,19,35,93,68,216,209,128,0,10,208,174,79,15,32, -248,8,196,24,8,107,192,0,5,106,118,27,94,0,0,43,83,227,94,0,0,43,84,46,215, -128,0,10,213,28,198,188,0,0,86,169,100,53,224,0,2,181,79,85,175,0,0,21,170, -154,45,120,0,0,173,85,217,107,192,0,5,106,182,243,86,193,106,52,127,130, -249,50,94,124,35,68,225,146,49,13,31,186,23,201,146,243,224,200,39,12,145, -136,67,134,19,49,0,0,3,225,252,0,0,0,3,51,0,0,3,193,252,0,0,0,3,47,18,1, -172,19,120,71,10,25,196,136,113,162,156,136,199,42,57,204,144,115,132,240, -149,2,248,72,197,209,58,2,185,16,52,196,225,35,23,68,233,14,228,72,82,68, -141,17,56,72,197,209,58,130,249,44,54,96,191,9,24,186,39,88,79,39,135,147, -132,140,93,19,176,35,180,138,9,216,197,209,59,82,79,35,40,242,65,248,58,42, -96,121,14,232,94,62,46,190,15,42,31,145,33,86,65,76,242,214,143,73,48,242, -243,79,49,56,243,115,207,57,64,243,180,79,61,72,243,244,207,65,80,244,53, -79,69,88,244,98,30,8,200,156,67,102,120,241,79,4,100,78,21,110,4,207,32,47, -147,37,231,194,52,78,25,34,122,81,124,153,47,62,12,130,112,201,19,211,139, -121,34,87,69,128,104,137,239,83,18,238,108,165,2,162,92,104,56,220,233,1,8, -151,10,134,162,100,206,16,18,50,9,195,39,105,20,101,136,18,25,4,225,147, -180,138,5,215,49,238,105,27,60,185,1,36,104,156,50,118,145,70,96,129,34,52, -78,25,59,72,160,93,115,30,230,145,179,204,144,12,73,8,15,38,104,128,138,52, -146,16,30,77,1,0,2,11,132,193,198,36,248,248,186,110,158,30,78,56,188,194, -70,183,170,136,48,98,79,142,179,120,248,185,228,140,241,193,146,66,138,31, -55,71,138,128,153,137,62,58,205,227,226,231,146,51,199,26,6,18,92,146,64, -96,74,72,51,120,43,192,97,68,128,153,56,72,7,12,133,67,73,199,197,207,36, -103,142,35,2,3,33,80,210,113,241,115,201,25,160,146,225,160,9,34,1,124,178, -1,139,18,19,36,229,146,8,190,36,169,27,62,18,243,35,100,135,54,92,162,2,17, -46,72,128,89,7,200,32,33,18,225,98,236,145,188,130,64,196,75,132,188,200, -217,32,43,39,28,128,69,19,18,228,144,42,98,79,142,179,120,248,185,228,140, -241,201,97,129,114,229,201,37,2,68,184,200,1,147,93,159,153,213,34,235,250, -96,48,157,32,24,94,160,1,199,4,184,235,55,143,139,158,72,207,28,226,3,81, -46,62,46,155,167,135,147,142,47,60,129,71,197,207,36,103,142,34,92,35,104, -194,68,1,89,58,36,8,109,109,12,133,67,73,195,18,115,36,118,182,185,168,8, -109,109,12,133,67,73,201,18,115,36,118,182,185,168,130,27,91,75,115,149,71, -240,196,156,201,29,173,174,129,2,27,91,75,115,149,71,242,68,156,201,29,173, -174,129,34,12,16,28,128,62,191,42,3,71,146,68,4,16,22,188,161,240,16,40, -104,242,103,196,16,93,158,125,96,110,115,235,64,131,16,16,58,37,192,70,32, -194,144,114,25,67,95,40,6,18,8,32,48,156,209,2,108,124,96,224,144,6,247,62, -16,0,143,164,143,12,248,15,18,84,145,145,34,128,11,35,160,179,140,0,44,150, -129,18,58,0,146,116,103,32,128,105,61,104,17,36,175,1,232,217,29,5,156,179, -224,58,26,50,95,142,43,159,64,181,130,83,226,26,50,95,142,43,159,192,7,255, -248,41,42,72,226,1,160,18,78,97,32,26,64,114,186,60,32,4,120,6,148,13,128, -124,3,76,12,84,46,100,140,3,78,13,18,14,130,36,67,232,23,18,14,130,39,34, -131,30,113,15,224,3,255,253,6,48,40,194,197,204,224,142,8,240,78,25,60,231, -192,210,197,204,224,156,50,113,238,67,103,232,62,28,138,156,104,82,170,107, -255,32,48,191,144,1,132,112,71,128,159,168,128,161,28,17,224,156,50,112,19, -245,144,22,39,12,156,123,144,217,240,19,245,146,3,9,205,16,39,236,62,3,161, -163,37,248,226,251,141,1,107,4,167,196,52,100,191,28,95,113,164,13,91,132, -5,147,130,115,30,8,147,222,64,43,1,49,31,224,64,60,72,245,128,68,249,32,13, -34,2,34,63,204,128,89,45,2,39,209,0,89,61,104,159,213,0,153,80,50,156,80, -211,126,16,11,155,184,183,88,145,224,129,34,122,64,17,155,184,183,8,11,39, -22,235,18,60,16,36,79,72,1,115,119,40,247,146,60,16,36,79,72,32,140,221, -197,184,64,89,57,71,188,145,224,129,34,122,65,1,39,20,51,244,0,52,72,242,2, -127,18,2,165,48,70,114,229,145,51,253,141,1,4,104,229,203,34,103,251,26,64, -132,52,75,160,201,47,105,160,26,84,12,167,31,186,8,50,0,114,58,113,163,46, -190,120,35,11,60,4,25,68,81,61,96,47,181,80,46,132,129,255,255,222,255,255, -255,255,254,39,172,67,118,170,5,208,144,0,0,0,0,0,64,0,0,51,16,0,0,62,31, -192,0,0,0,8,245,238,146,38,138,147,105,13,42,26,137,226,0,0,7,131,248,0,0, -0,1,30,180,134,4,209,82,109,33,165,67,81,60,64,0,0,240,255,0,0,0,0,15,210, -62,72,91,155,0,0,2,192,240,0,0,0,0,135,88,11,237,72,5,38,210,27,50,24,145, -129,255,254,126,135,255,255,255,254,67,172,67,118,164,2,147,105,13,153,12, -72,192,255,255,63,195,255,255,255,255,16,240,70,68,226,27,51,199,138,120, -35,34,112,171,112,38,121,7,16,137,112,168,106,38,77,193,1,40,151,16,217, -144,196,142,224,144,21,18,227,65,198,238,9,67,81,46,72,5,39,16,217,144,196, -142,224,152,228,148,227,64,0,0,0,0,0,0,0,0,131,175,223,16,194,111,8,97,119, -224,3,205,220,42,46,65,238,200,13,155,184,75,189,205,35,102,128,47,116,64, -92,221,199,196,130,68,144,230,239,72,65,152,12,21,224,140,137,92,128,62, -210,98,177,252,3,107,173,88,3,146,211,141,32,0,3,225,252,0,0,0,3,19,175, -188,0,100,221,193,130,100,228,167,20,52,215,129,3,38,238,77,12,39,37,56, -161,166,188,10,194,94,6,18,155,184,183,8,11,39,6,9,147,146,156,80,211,94,7, -18,155,184,183,8,11,39,38,134,19,146,156,80,211,94,8,12,53,224,130,195,222, -8,77,133,210,24,91,224,3,152,147,228,208,194,95,0,44,196,159,11,69,175,152, -32,35,100,33,135,24,147,237,38,34,246,139,95,48,64,70,200,68,8,49,39,198, -57,179,61,144,138,22,98,79,180,152,153,215,54,103,178,17,129,204,73,240,96, -153,44,132,112,163,18,125,164,196,62,130,100,178,18,1,140,73,240,96,197, -144,146,18,98,79,180,152,135,208,98,200,74,8,49,39,195,186,145,149,144,150, -22,98,79,180,152,143,215,82,50,178,19,2,140,73,241,136,109,38,73,89,9,161, -166,36,251,73,137,157,67,105,50,74,200,78,10,49,39,201,16,78,104,229,100, -39,134,152,147,237,38,41,116,130,115,71,43,33,64,60,196,159,24,133,173,18, -32,156,209,202,200,81,18,49,39,218,76,76,234,22,180,72,130,115,71,43,33,72, -68,196,159,38,134,19,46,105,56,226,150,68,157,160,1,228,73,242,104,97,46, -16,31,34,79,140,66,214,137,16,78,104,229,108,169,137,72,147,237,38,38,117, -11,90,36,65,57,163,149,178,168,21,34,79,146,32,156,209,202,218,250,161,178, -36,251,73,138,93,32,156,209,202,218,250,193,82,36,248,196,54,147,36,173, -191,174,27,34,79,180,152,153,212,54,147,36,173,191,176,17,34,79,135,117,35, -43,115,236,133,200,147,237,38,35,245,212,140,173,207,180,15,34,79,131,4, -201,108,173,133,72,147,237,38,33,244,19,37,178,184,17,34,79,140,115,102, -123,107,238,133,200,147,237,38,38,117,205,153,237,175,188,23,34,79,133,162, -215,204,16,17,182,254,248,116,137,62,210,98,47,104,181,243,4,4,109,191,192, -131,152,147,230,8,8,217,12,16,60,137,62,96,128,141,178,193,160,206,1,201, -176,113,146,0,0,0,0,0,0,0,0,49,185,252,65,137,207,227,37,215,207,227,12,86, -127,24,152,188,254,49,88,33,46,65,120,72,4,153,37,63,33,13,127,148,4,26,0, -57,62,6,228,163,228,74,86,215,62,55,28,110,179,226,113,70,223,62,47,24,38, -191,30,2,125,32,40,20,87,114,41,225,42,5,240,145,139,163,145,41,68,250,128, -80,41,174,228,85,200,129,166,39,9,24,186,57,18,148,79,172,5,2,170,238,69, -220,137,10,72,145,162,39,9,24,186,57,18,148,79,176,5,2,186,238,69,124,150, -27,48,95,132,140,93,28,137,74,39,218,2,129,101,119,34,158,79,15,39,9,24, -186,57,18,148,79,184,5,2,218,238,69,29,164,80,78,198,46,142,68,165,16,64, -28,24,61,73,25,33,205,128,1,167,166,128,0,0,0,1,108,242,151,15,39,8,34,26, -87,97,200,3,0,167,129,32,8,194,195,16,6,84,55,10,60,3,35,69,132,30,1,140, -130,193,143,1,196,230,60,2,158,8,131,153,64,115,42,46,191,176,8,194,246,0, -80,5,220,193,95,6,234,5,100,225,35,23,71,35,6,228,140,93,29,180,55,108,145, -139,163,182,112,52,107,67,76,56,3,153,132,20,28,76,156,89,26,105,158,62,0, -0,42,193,2,201,104,17,41,34,156,204,176,160,226,100,226,200,211,76,241,240, -0,1,86,2,131,137,147,142,41,100,73,199,192,0,5,96,6,13,10,82,70,62,0,0,42, -130,88,115,18,124,67,103,177,69,49,129,6,36,249,68,54,123,20,82,216,65,137, -62,33,179,209,214,162,152,208,147,18,124,162,27,61,29,106,41,112,32,196, -159,16,217,233,233,81,76,112,73,137,62,81,13,158,158,149,20,186,20,98,79, -133,91,129,61,61,42,41,120,40,196,159,10,183,2,122,218,148,82,248,60,137, -62,33,179,216,166,216,192,137,18,124,162,27,61,138,109,108,34,68,159,16, -217,232,235,83,108,104,76,137,62,81,13,158,142,181,54,184,17,34,79,136,108, -244,244,169,182,56,38,68,159,40,134,207,79,74,155,93,10,145,39,194,173,192, -158,158,149,54,188,21,34,79,133,91,129,61,109,74,109,125,155,51,136,71,161, -196,201,45,167,146,59,68,89,24,70,206,0,0,7,129,248,0,0,0,1,155,51,168,71, -161,196,201,45,167,146,59,68,89,24,70,206,0,0,7,129,248,0,0,0,1,155,51,200, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,7,129,248,0,0,0,1,155,51, -232,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,2,0,0,0,0,1,155,52, -8,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,2,0,0,0,0,1,155,52,40, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,155,52,72, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,155,52, -104,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,155, -52,136,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,1,2,0,0,0,0,1,135, -52,166,32,76,72,1,246,136,235,103,177,69,0,136,144,3,226,27,61,138,41,44, -50,36,0,251,68,117,179,209,214,234,201,69,16,50,36,0,251,68,117,179,209, -214,232,73,69,34,5,196,128,31,16,217,232,235,117,100,162,147,2,226,64,15, -136,108,244,117,186,18,81,74,129,145,32,7,218,35,173,158,158,151,86,74,40, -161,145,32,7,218,35,173,158,158,151,66,74,41,20,46,36,0,248,134,207,79,75, -171,37,20,154,23,18,0,124,67,103,167,165,208,146,138,85,11,137,0,62,21,110, -4,250,178,81,70,11,137,0,62,21,110,4,250,18,81,72,193,145,32,7,193,186,129, -89,58,178,81,71,12,137,0,62,13,212,10,201,208,146,138,71,10,137,0,62,209, -29,108,250,178,81,104,1,81,32,7,218,35,173,159,66,74,45,32,38,36,0,248,134, -207,171,37,22,160,19,18,0,124,67,103,208,146,139,88,10,180,81,50,118,136, -235,103,177,77,128,155,69,19,39,16,217,236,83,105,97,182,138,38,78,209,29, -108,244,117,186,178,83,100,13,180,81,50,118,136,235,103,163,173,208,146, -155,68,12,180,81,50,113,13,158,142,183,86,74,109,48,50,209,68,201,196,54, -122,58,221,9,41,181,64,219,69,19,39,104,142,182,122,122,93,89,41,178,134, -218,40,153,59,68,117,179,211,210,232,73,77,162,134,90,40,153,56,134,207,79, -75,171,37,54,154,25,104,162,100,226,27,61,61,46,132,148,218,168,101,162, -137,147,133,91,129,62,172,148,217,131,45,20,76,156,42,220,9,244,36,166,209, -131,109,20,76,156,27,168,21,147,171,37,54,112,219,69,19,39,6,234,5,100,232, -73,77,163,133,218,40,153,59,68,117,179,234,201,78,32,5,218,40,153,59,68, -117,179,232,73,78,36,5,90,40,153,56,134,207,171,37,56,160,21,104,162,100, -226,27,62,132,148,226,195,95,182,97,176,218,128,8,84,45,123,38,1,137,10,1, -114,160,64,56,156,199,130,36,160,72,8,39,63,27,24,1,100,180,8,148,146,0,45, -162,137,147,111,2,8,4,16,7,8,96,120,72,1,87,224,168,13,42,226,145,97,58, -182,232,232,64,177,107,2,64,22,85,181,187,7,213,183,74,2,17,119,49,255,121, -207,215,240,94,173,198,210,36,4,113,95,115,255,232,34,182,80,221,91,141, -163,160,72,15,121,123,103,225,220,164,194,160,186,244,64,251,33,9,64,24,45, -68,84,15,217,66,51,209,218,210,129,61,65,204,127,154,118,254,204,23,178, -132,103,165,2,122,131,216,255,52,237,253,154,168,48,6,90,130,1,0,39,75,80, -72,8,9,33,186,130,80,64,76,13,212,19,2,130,96,110,150,173,0,65,6,51,212,20, -128,65,17,11,212,19,130,137,121,211,210,209,144,6,39,75,80,80,0,201,119, -234,10,8,41,86,231,71,80,80,129,79,135,186,122,69,224,34,25,69,233,80,3,91, -141,168,40,96,139,113,180,181,5,36,21,110,54,142,134,160,165,1,176,23,211, -47,0,216,134,233,215,128,111,117,181,104,128,209,3,70,230,106,64,5,139,168, -209,234,10,32,36,144,102,234,136,3,146,27,168,40,160,146,132,103,168,40, -192,115,3,117,5,28,22,113,163,69,168,41,103,1,66,188,17,145,52,40,4,202, -113,67,76,130,227,68,194,13,240,108,0,0,83,96,0,2,161,0,104,146,84,97,48,0, -1,78,192,56,169,24,145,179,192,0,5,48,8,56,16,32,128,56,18,52,125,166,86, -147,182,140,28,50,21,13,39,31,23,60,145,158,56,140,141,47,113,6,155,186, -188,24,49,39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,197,68, -14,49,39,199,197,211,116,240,242,113,197,230,18,180,253,228,3,17,46,18,243, -35,100,128,172,156,114,70,163,146,76,34,248,146,164,108,248,75,204,141,146, -28,217,114,137,27,78,251,241,173,234,162,160,225,1,3,34,92,170,9,105,164, -32,225,64,131,155,1,193,133,7,19,39,22,70,154,103,143,128,0,10,176,20,28, -76,156,113,75,34,78,62,0,0,43,0,48,104,82,146,49,240,0,1,84,11,180,192,0,5, -114,1,18,160,65,24,131,20,145,25,172,48,132,122,28,76,146,218,121,35,180, -69,145,132,108,224,0,0,120,31,128,0,0,0,25,172,56,132,122,28,76,146,218, -121,35,180,69,145,132,108,224,0,0,120,31,128,0,0,0,40,160,45,110,23,30,176, -33,184,0,0,175,32,29,235,2,27,199,23,0,0,22,4,51,88,129,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,0,0,240,63,0,0,0,0,51,88,145,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,0,0,0,64,0,0,0,0,51,88,161,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,0,0,0,64,0,0,0,0,51,88,177,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51,88,193,8,244,56, -153,37,180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51,88,209,8,244, -56,153,37,180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51,88,225,8, -244,56,153,37,180,242,71,104,139,35,8,217,192,0,0,32,64,0,0,0,0,32,227,194, -0,97,57,162,4,245,232,5,34,92,35,68,225,161,166,218,16,16,137,112,52,41,73, -29,153,1,65,196,201,197,145,166,153,245,200,3,137,204,120,34,74,8,200,58, -112,28,211,32,130,52,78,26,26,110,248,0,0,164,4,12,70,137,195,39,252,73, -240,117,32,57,168,97,4,104,156,52,52,221,255,160,20,160,152,23,223,250,32, -148,25,174,137,58,23,51,191,244,84,12,50,9,195,39,240,81,238,2,3,107,173, -214,3,192, +1,80,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, +33,8,66,34,33,154,112,0,1,73,247,35,79,91,237,198,174,192,47,31,23,95,17, +13,51,19,35,93,68,216,209,128,0,10,192,174,79,15,32,248,8,196,24,8,107,192, +0,5,98,118,27,94,0,0,43,19,227,94,0,0,43,20,46,215,128,0,10,197,28,198,188, +0,0,86,41,100,53,224,0,2,177,79,85,175,0,0,21,138,154,45,120,0,0,172,85, +217,107,192,0,5,98,182,243,86,193,106,52,127,66,249,50,94,124,35,68,225, +146,49,13,31,170,23,201,146,243,224,200,39,12,145,136,67,134,11,49,0,0,3, +225,252,0,0,0,3,51,0,0,3,193,252,0,0,0,3,47,18,1,172,19,120,71,10,25,196, +136,113,162,156,136,199,42,57,204,144,115,132,240,149,2,248,72,197,209,58, +2,185,16,52,196,225,35,23,68,233,14,228,72,82,68,141,17,56,72,197,209,58, +130,249,44,54,96,191,9,24,186,39,88,79,39,135,147,132,140,93,19,176,35,180, +138,9,216,197,209,59,82,79,31,40,242,1,248,58,42,96,121,14,232,94,62,46, +190,15,38,31,145,33,86,65,76,242,150,143,69,48,242,179,79,45,56,243,51,207, +53,64,243,116,79,57,72,243,180,207,61,80,243,245,79,65,88,244,34,249,50,94, +124,35,68,225,146,39,163,23,201,146,243,224,200,39,12,145,61,40,183,146,37, +116,88,6,136,158,244,241,174,230,202,80,135,130,50,39,16,217,231,208,20, +240,70,68,225,86,224,79,60,64,84,75,141,7,27,157,32,66,37,194,161,168,153, +51,132,9,25,4,225,147,180,138,50,196,18,25,4,225,147,180,138,5,215,49,238, +105,27,60,185,2,72,209,56,100,237,34,140,193,4,136,209,56,100,237,34,129, +117,204,123,154,70,207,50,64,98,72,64,121,51,68,8,163,73,33,1,228,208,16,0, +65,112,152,56,196,159,31,23,77,211,195,201,199,23,150,73,169,234,34,24,49, +39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,196,64,153,137,62, +58,205,227,226,231,146,51,199,26,6,18,92,130,64,192,148,144,102,240,23,129, +133,18,2,100,224,160,56,100,42,26,78,62,46,121,35,60,112,216,32,50,21,13, +39,31,23,60,145,154,9,46,18,1,36,64,47,148,64,98,196,132,201,57,68,132,95, +18,84,141,159,9,121,145,178,67,155,46,73,2,17,46,72,128,89,7,199,32,66,37, +194,197,217,35,120,228,131,17,46,18,243,35,100,128,172,156,98,2,40,152,151, +32,130,166,36,248,235,55,143,139,158,72,207,28,150,24,23,46,92,130,80,72, +151,21,0,100,213,103,229,245,8,186,190,144,24,78,136,24,94,152,3,142,9,113, +214,111,31,23,60,145,158,57,164,13,68,184,248,186,110,158,30,78,56,188,226, +10,62,46,121,35,60,113,18,225,27,70,18,32,10,201,208,32,134,214,208,200,84, +52,156,49,39,50,71,107,107,152,129,13,173,161,144,168,105,57,34,78,100,142, +214,215,49,16,134,214,210,220,229,81,252,49,39,50,71,107,107,158,65,13,173, +165,185,202,163,249,34,78,100,142,214,215,60,146,12,16,28,128,62,175,42,6, +143,36,136,16,64,90,242,135,192,129,67,71,147,62,65,5,215,231,214,6,215,62, +180,8,49,1,3,162,92,4,98,12,41,14,67,40,106,229,1,132,130,8,24,78,104,129, +54,62,96,224,144,13,238,124,32,2,62,146,60,51,224,120,146,164,140,137,20,0, +178,58,11,56,192,5,146,208,34,71,64,36,157,25,200,32,52,158,180,8,146,87, +129,232,217,29,5,156,179,224,116,52,100,191,28,87,62,130,214,9,79,136,104, +201,126,56,174,127,0,31,255,225,73,82,71,16,13,1,36,230,18,1,164,14,87,71, +132,0,143,0,210,131,96,31,0,211,6,42,23,50,70,1,167,13,18,14,130,36,67,232, +46,36,29,4,78,69,6,60,226,31,192,7,255,252,24,192,163,11,23,51,130,56,35, +193,56,100,243,31,6,150,46,103,4,225,147,143,114,27,63,57,241,200,169,194, +133,42,166,175,240,6,23,240,0,97,28,17,224,39,233,32,80,142,8,240,78,25,56, +9,250,136,22,39,12,156,123,144,217,240,19,245,18,6,19,154,32,79,214,124,14, +134,140,151,227,139,237,52,11,88,37,62,33,163,37,248,226,251,77,32,213,184, +64,89,56,39,49,224,137,61,196,5,96,38,35,251,200,15,18,61,96,17,62,40,6, +145,1,17,31,228,64,89,45,2,39,205,0,178,122,209,63,162,2,101,64,202,113,67, +77,247,64,92,221,197,186,196,143,4,9,19,208,1,25,187,139,112,128,178,113, +110,177,35,193,2,68,244,0,46,110,229,30,242,71,130,4,137,232,4,35,55,113, +110,16,22,78,81,239,36,120,32,72,158,128,64,147,138,25,249,0,52,72,242,2, +127,2,5,74,96,140,229,203,34,103,250,154,4,17,163,151,44,137,159,234,105,4, +33,162,93,6,73,123,13,1,165,64,202,113,251,33,6,64,14,71,78,20,101,213,207, +4,194,207,2,12,162,0,158,176,23,218,168,23,66,64,255,255,239,127,255,255, +255,255,19,214,33,187,85,2,232,72,0,0,0,0,0,32,0,0,25,136,0,0,31,15,224,0, +0,0,4,122,247,73,19,69,73,180,134,149,13,68,241,0,0,3,193,252,0,0,0,0,143, +90,67,2,104,169,54,144,210,161,168,158,32,0,0,120,127,128,0,0,0,14,73,78, +20,0,0,0,0,0,0,0,0,8,58,189,233,24,77,217,24,93,240,1,230,238,21,23,32,247, +68,13,155,184,75,189,205,35,102,128,47,114,64,185,187,143,137,4,137,33,205, +222,17,6,96,48,87,130,50,37,114,1,246,147,21,143,224,54,186,213,128,114,90, +112,164,0,0,124,63,128,0,0,0,98,117,119,128,25,55,112,96,153,57,41,197,13, +53,224,65,147,119,38,134,19,146,156,80,211,94,5,194,94,6,37,55,113,110,16, +22,78,12,19,39,37,56,161,166,188,14,74,110,226,220,32,44,156,154,24,78,74, +113,67,77,120,32,97,175,4,28,61,224,133,172,186,70,22,248,1,204,73,242,104, +97,47,128,44,196,159,11,69,175,152,32,35,100,33,142,49,39,218,76,69,237,22, +190,96,128,141,144,136,32,196,159,24,230,204,246,66,40,179,18,125,164,196, +206,185,179,61,144,140,28,196,159,6,9,146,200,71,20,98,79,180,152,135,208, +76,150,66,64,99,18,124,24,49,100,36,137,49,39,218,76,67,232,49,100,37,8,49, +39,195,186,145,149,144,150,44,196,159,105,49,31,174,164,101,100,38,10,49, +39,198,33,180,153,37,100,38,141,49,39,218,76,76,234,27,73,146,86,66,112, +163,18,124,145,4,230,142,86,66,120,211,18,125,164,197,46,144,78,104,229, +100,40,15,49,39,198,33,107,68,136,39,52,114,178,20,73,24,147,237,38,38,117, +11,90,36,65,57,163,149,144,164,68,196,159,38,134,19,46,105,56,226,150,68, +157,160,3,200,147,228,208,194,92,32,124,137,62,49,11,90,36,65,57,163,149, +178,166,74,68,159,105,49,51,168,90,209,34,9,205,28,173,149,65,82,36,249,34, +9,205,28,173,175,170,54,68,159,105,49,75,164,19,154,57,91,95,88,84,137,62, +49,13,164,201,43,111,235,141,145,39,218,76,76,234,27,73,146,86,223,216,17, +34,79,135,117,35,43,115,236,139,145,39,218,76,71,235,169,25,91,159,104,60, +137,62,12,19,37,178,182,42,68,159,105,49,15,160,153,45,149,193,18,36,248, +199,54,103,182,190,232,185,18,125,164,196,206,185,179,61,181,247,133,200, +147,225,104,181,243,4,4,109,191,190,58,68,159,105,49,23,180,90,249,130,2, +54,223,224,67,152,147,230,8,8,217,12,16,121,18,124,193,1,27,101,131,131,56, +7,38,193,198,72,0,0,0,0,0,0,0,0,198,231,240,134,39,63,136,151,95,63,136,49, +89,252,66,98,243,248,133,96,132,185,5,224,32,36,201,41,248,200,213,249,0, +131,64,7,39,192,218,148,124,137,74,216,231,198,227,141,182,124,78,40,217, +231,197,227,4,213,227,192,159,72,10,5,21,218,138,120,74,129,124,36,98,232, +228,74,81,62,160,20,10,107,181,21,114,32,105,137,194,70,46,142,68,165,19, +235,1,64,170,187,81,119,34,66,146,36,104,137,194,70,46,142,68,165,19,236,1, +64,174,187,81,95,37,134,204,23,225,35,23,71,34,82,137,246,128,160,89,93, +168,167,147,195,201,194,70,46,142,68,165,19,238,1,64,182,187,81,71,105,20, +19,177,139,163,145,41,68,16,7,6,15,82,70,72,115,96,0,93,105,160,0,0,0,0,91, +60,149,195,200,194,8,134,149,216,114,1,128,83,192,144,8,194,195,16,12,168, +110,20,120,12,141,22,16,120,12,100,22,12,120,28,78,99,192,41,224,136,115, +36,14,100,197,213,245,193,48,189,112,40,2,237,96,175,131,117,2,178,112,145, +139,163,145,131,114,70,46,142,218,27,182,72,197,209,219,56,26,53,161,166, +28,1,204,178,10,14,38,78,44,141,52,207,31,0,0,21,64,129,100,180,8,148,145, +92,203,176,160,226,100,226,200,211,76,241,240,0,1,84,2,131,137,147,142,41, +100,73,199,192,0,5,88,6,13,10,82,70,62,0,0,42,66,88,115,18,124,67,103,177, +69,49,130,12,73,242,136,108,246,40,165,177,6,36,248,134,207,71,90,138,99, +68,152,147,229,16,217,232,235,81,75,130,12,73,241,13,158,158,149,20,199,9, +49,39,202,33,179,211,210,162,151,69,24,147,225,86,224,79,79,74,138,94,20, +98,79,133,91,129,61,109,74,41,124,60,137,62,33,179,216,166,216,193,18,36, +249,68,54,123,20,218,216,137,18,124,67,103,163,173,77,177,162,100,73,242, +136,108,244,117,169,181,193,18,36,248,134,207,79,74,155,99,132,200,147,229, +16,217,233,233,83,107,162,164,73,240,171,112,39,167,165,77,175,10,145,39, +194,173,192,158,182,165,54,191,153,51,72,71,161,196,201,45,167,146,59,68, +89,24,70,206,0,0,7,129,248,0,0,0,1,153,51,104,71,161,196,201,45,167,146,59, +68,89,24,70,206,0,0,7,129,248,0,0,0,1,153,51,136,71,161,196,201,45,167,146, +59,68,89,24,70,206,0,0,7,129,248,0,0,0,1,153,51,168,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,2,0,0,0,0,1,153,51,200,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,2,0,0,0,0,1,153,51,232,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,153,52,8,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,153,52,40,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,153,52,72,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,1,2,0,0,0,0,1,135,52,102,32,76,72,1,246,136,235, +103,177,69,1,17,32,7,196,54,123,20,82,88,200,144,3,237,17,214,207,71,91, +171,37,20,65,145,32,7,218,35,173,158,142,183,66,74,41,16,92,72,1,241,13, +158,142,183,86,74,41,48,92,72,1,241,13,158,142,183,66,74,41,80,100,72,1, +246,136,235,103,167,165,213,146,138,40,200,144,3,237,17,214,207,79,75,161, +37,20,138,46,36,0,248,134,207,79,75,171,37,20,154,46,36,0,248,134,207,79, +75,161,37,20,170,46,36,0,248,85,184,19,234,201,69,24,92,72,1,240,171,112, +39,208,146,138,70,25,18,0,124,27,168,21,147,171,37,20,113,145,32,7,193,186, +129,89,58,18,81,72,226,162,64,15,180,71,91,62,172,148,90,0,168,144,3,237, +17,214,207,161,37,22,144,38,36,0,248,134,207,171,37,22,160,38,36,0,248,134, +207,161,37,22,176,42,209,68,201,218,35,173,158,197,54,4,218,40,153,56,134, +207,98,155,75,27,104,162,100,237,17,214,207,71,91,171,37,54,65,182,138,38, +78,209,29,108,244,117,186,18,83,104,131,45,20,76,156,67,103,163,173,213, +146,155,76,25,104,162,100,226,27,61,29,110,132,148,218,160,219,69,19,39, +104,142,182,122,122,93,89,41,178,141,180,81,50,118,136,235,103,167,165,208, +146,155,69,25,104,162,100,226,27,61,61,46,172,148,218,104,203,69,19,39,16, +217,233,233,116,36,166,213,70,90,40,153,56,85,184,19,234,201,77,152,101, +162,137,147,133,91,129,62,132,148,218,48,219,69,19,39,6,234,5,100,234,201, +77,156,109,162,137,147,131,117,2,178,116,36,166,209,197,218,40,153,59,68, +117,179,234,201,78,32,11,180,81,50,118,136,235,103,208,146,156,72,21,104, +162,100,226,27,62,172,148,226,128,171,69,19,39,16,217,244,36,167,22,53,123, +102,53,155,80,2,21,11,94,201,128,196,133,0,185,80,32,56,156,199,130,36,160, +72,16,78,126,54,48,5,146,208,34,82,72,1,109,20,76,155,120,28,34,1,225,32,5, +95,130,160,52,171,138,69,132,234,219,163,161,2,197,172,9,0,89,86,214,236, +31,86,221,40,8,69,220,199,253,231,63,95,193,122,183,27,72,144,17,197,125, +207,255,160,138,217,67,117,110,54,142,129,32,61,229,237,159,135,114,147,10, +130,235,209,3,236,132,37,0,96,181,17,80,63,101,8,207,71,107,74,4,245,7,49, +254,105,219,251,48,94,202,17,158,148,9,234,15,99,252,211,183,246,98,159, +129,228,176,192,185,127,46,155,185,41,197,13,55,38,3,127,255,20,138,160, +192,25,106,8,8,1,58,90,130,64,128,146,27,168,37,8,9,129,186,130,96,160,152, +27,165,171,64,32,131,25,234,10,64,65,17,11,212,19,133,18,243,167,165,163, +32,24,157,45,65,64,6,75,191,80,80,66,149,110,116,117,5,8,41,240,247,79,72, +188,8,134,81,122,84,1,173,198,212,20,48,139,113,180,181,5,36,42,220,109,29, +13,65,74,6,192,95,76,188,6,196,55,78,188,6,247,91,86,136,26,32,104,220,205, +72,1,98,234,52,122,130,136,18,72,51,117,68,3,146,27,168,40,161,37,8,207,80, +81,129,204,13,212,20,112,179,141,26,45,65,75,112,20,43,193,25,19,66,128, +153,78,40,105,144,92,104,152,131,124,27,253,128,0,10,116,3,68,146,163,9, +128,0,10,102,3,138,145,137,27,60,0,0,82,129,7,2,4,16,7,2,70,143,178,203, +164,237,35,14,25,10,134,147,143,139,158,72,207,28,54,77,47,109,13,55,113, +120,96,196,159,29,102,241,241,115,201,25,227,131,36,133,20,62,110,143,17, +16,113,137,62,62,46,155,167,135,147,142,47,44,151,79,221,64,98,37,194,94, +100,108,144,21,147,140,73,168,228,19,17,124,73,82,54,124,37,230,70,201,14, +108,185,36,155,14,243,243,83,212,69,131,132,4,12,137,114,168,37,166,145,7, +10,4,28,200,14,12,40,56,153,56,178,52,211,60,124,0,0,85,0,160,226,100,227, +138,89,18,113,240,0,1,86,1,131,66,148,145,143,128,0,10,144,93,134,0,0,43, +80,17,42,4,17,136,49,73,19,49,134,16,143,67,137,146,91,79,36,118,136,178, +48,141,156,0,0,15,3,240,0,0,0,3,49,135,16,143,67,137,146,91,79,36,118,136, +178,48,141,156,0,0,15,3,240,0,0,0,5,20,5,173,194,227,214,4,55,0,0,21,196,7, +122,192,134,241,197,192,0,5,121,25,140,64,132,122,28,76,146,218,121,35,180, +69,145,132,108,224,0,0,120,31,128,0,0,0,25,140,72,132,122,28,76,146,218, +121,35,180,69,145,132,108,224,0,0,0,32,0,0,0,0,25,140,80,132,122,28,76,146, +218,121,35,180,69,145,132,108,224,0,0,0,32,0,0,0,0,25,140,88,132,122,28,76, +146,218,121,35,180,69,145,132,108,224,0,0,8,32,0,0,0,0,25,140,96,132,122, +28,76,146,218,121,35,180,69,145,132,108,224,0,0,8,32,0,0,0,0,25,140,104, +132,122,28,76,146,218,121,35,180,69,145,132,108,224,0,0,8,32,0,0,0,0,25, +140,112,132,122,28,76,146,218,121,35,180,69,145,132,108,224,0,0,16,32,0,0, +0,0,16,113,225,0,48,156,209,2,122,244,5,34,92,35,68,225,161,166,218,16,33, +18,224,104,82,146,59,50,5,7,19,39,22,70,154,103,215,32,28,78,99,193,18,80, +70,131,165,1,205,34,8,35,68,225,161,166,239,255,4,12,70,137,195,39,248,73, +7,78,3,154,102,16,70,137,195,67,77,223,248,1,74,9,129,125,255,130,9,65,154, +232,147,161,115,59,255,5,64,195,32,156,50,126,197,14,2,3,107,173,213,0, }; #else #error invalid endianness defines @@ -11760,18 +11501,10 @@ DUK_UNREF(udata); DUK_UNREF(msg); - msg = msg ? msg : "NULL"; - #if defined(DUK_USE_FATAL_HANDLER) /* duk_config.h provided a custom default fatal handler. */ - DUK_D(DUK_DPRINT("custom default fatal error handler called: %s", msg)); + DUK_D(DUK_DPRINT("custom default fatal error handler called: %s", msg ? msg : "NULL")); DUK_USE_FATAL_HANDLER(udata, msg); -#elif defined(DUK_USE_CPP_EXCEPTIONS) - /* With C++ use a duk_fatal_exception which user code can catch in - * a natural way. - */ - DUK_D(DUK_DPRINT("built-in default C++ fatal error handler called: %s", msg)); - throw duk_fatal_exception(msg); #else /* Default behavior is to abort() on error. There's no printout * which makes this awkward, so it's always recommended to use an @@ -11788,7 +11521,7 @@ * - http://duktape.org/api.html#taglist-protected * ==================================================================== */ - DUK_D(DUK_DPRINT("built-in default fatal error handler called: %s", msg)); + DUK_D(DUK_DPRINT("built-in default fatal error handler called: %s", msg ? msg : "NULL")); DUK_ABORT(); #endif @@ -11944,7 +11677,7 @@ /* * Unicode codepoints above U+FFFF are encoded as surrogate * pairs here. This ensures that all CESU-8 codepoints are - * 16-bit values as expected in ECMAScript. The surrogate + * 16-bit values as expected in Ecmascript. The surrogate * pairs always get a 3-byte encoding (each) in CESU-8. * See: http://en.wikipedia.org/wiki/Surrogate_pair * @@ -12083,7 +11816,8 @@ return cp; } DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); + return 0; } /* Compute (extended) utf-8 length without codepoint encoding validation, @@ -12232,7 +11966,7 @@ duk_bitdecoder_ctx bd_ctx; duk_codepoint_t prev_re; - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); bd_ctx.data = (const duk_uint8_t *) unitab; bd_ctx.length = (duk_size_t) unilen; @@ -12784,7 +12518,7 @@ } /* 1:1 or special conversions, but not locale/context specific: script generated rules */ - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); if (uppercase) { bd_ctx.data = (const duk_uint8_t *) duk_unicode_caseconv_uc; bd_ctx.length = (duk_size_t) sizeof(duk_unicode_caseconv_uc); @@ -12984,7 +12718,7 @@ #endif /* DUK_USE_REGEXP_SUPPORT */ #line 1 "duk_util_misc.c" /* - * Misc util stuff. + * Misc util stuff */ /* #include duk_internal.h -> already included */ @@ -13147,6 +12881,45 @@ #endif /* DUK_USE_HEX_FASTPATH */ /* + * Table for base-64 encoding + */ + +#if defined(DUK_USE_BASE64_FASTPATH) +DUK_INTERNAL const duk_uint8_t duk_base64_enctab[64] = { + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* A...P */ + 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* Q...f */ + 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* g...v */ + 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2b, 0x2f /* w.../ */ +}; +#endif /* DUK_USE_BASE64_FASTPATH */ + +/* + * Table for base-64 decoding + */ + +#if defined(DUK_USE_BASE64_FASTPATH) +DUK_INTERNAL const duk_int8_t duk_base64_dectab[256] = { + /* -1 = error, -2 = allowed whitespace, -3 = padding ('='), 0...63 decoded bytes */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -1, -1, -2, -1, -1, /* 0x00...0x0f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10...0x1f */ + -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* 0x20...0x2f */ + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -3, -1, -1, /* 0x30...0x3f */ + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40...0x4f */ + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 0x50...0x5f */ + -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60...0x6f */ + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, /* 0x70...0x7f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x80...0x8f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x90...0x9f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xa0...0xaf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xb0...0xbf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xc0...0xcf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xd0...0xdf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xe0...0xef */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 0xf0...0xff */ +}; +#endif /* DUK_USE_BASE64_FASTPATH */ + +/* * Arbitrary byteswap for potentially unaligned values * * Used to byteswap pointers e.g. in debugger code. @@ -13166,9 +12939,192 @@ } } #endif + +/* + * Miscellaneous coercion / clamping helpers. + */ + +/* Check whether a duk_double_t is a whole number in the 32-bit range (reject + * negative zero), and if so, return a duk_int32_t. + * For compiler use: don't allow negative zero as it will cause trouble with + * LDINT+LDINTX, positive zero is OK. + */ +DUK_INTERNAL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int32_t *ival) { + duk_int32_t t; + + t = (duk_int32_t) x; + if (!((duk_double_t) t == x)) { + return 0; + } + if (t == 0) { + duk_double_union du; + du.d = x; + if (DUK_DBLUNION_HAS_SIGNBIT(&du)) { + return 0; + } + } + *ival = t; + return 1; +} + +/* Check whether a duk_double_t is a whole number in the 32-bit range, and if + * so, return a duk_int32_t. + */ +DUK_INTERNAL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival) { + duk_int32_t t; + + t = (duk_int32_t) x; + if (!((duk_double_t) t == x)) { + return 0; + } + *ival = t; + return 1; +} + +/* + * IEEE double checks + */ + +DUK_INTERNAL duk_bool_t duk_double_is_anyinf(duk_double_t x) { + duk_double_union du; + du.d = x; + return DUK_DBLUNION_IS_ANYINF(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_posinf(duk_double_t x) { + duk_double_union du; + du.d = x; + return DUK_DBLUNION_IS_POSINF(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_neginf(duk_double_t x) { + duk_double_union du; + du.d = x; + return DUK_DBLUNION_IS_NEGINF(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan(duk_double_t x) { + duk_double_union du; + du.d = x; + /* Assumes we're dealing with a Duktape internal NaN which is + * NaN normalized if duk_tval requires it. + */ + DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); + return DUK_DBLUNION_IS_NAN(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan_or_zero(duk_double_t x) { + duk_double_union du; + du.d = x; + /* Assumes we're dealing with a Duktape internal NaN which is + * NaN normalized if duk_tval requires it. + */ + DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); + return DUK_DBLUNION_IS_NAN(&du) || DUK_DBLUNION_IS_ANYZERO(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan_or_inf(duk_double_t x) { + duk_double_union du; + du.d = x; + /* If exponent is 0x7FF the argument is either a NaN or an + * infinity. We don't need to check any other fields. + */ +#if defined(DUK_USE_64BIT_OPS) +#if defined(DUK_USE_DOUBLE_ME) + return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000)) == DUK_U64_CONSTANT(0x000000007ff00000); +#else + return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000)) == DUK_U64_CONSTANT(0x7ff0000000000000); +#endif +#else + return (du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL) == 0x7ff00000UL; +#endif +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan_zero_inf(duk_double_t x) { + duk_double_union du; +#if defined(DUK_USE_64BIT_OPS) + duk_uint64_t t; +#else + duk_uint32_t t; +#endif + du.d = x; +#if defined(DUK_USE_64BIT_OPS) +#if defined(DUK_USE_DOUBLE_ME) + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000); + if (t == DUK_U64_CONSTANT(0x0000000000000000)) { + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x0000000080000000); + return t == 0; + } + if (t == DUK_U64_CONSTANT(0x000000007ff00000)) { + return 1; + } +#else + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000); + if (t == DUK_U64_CONSTANT(0x0000000000000000)) { + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x8000000000000000); + return t == 0; + } + if (t == DUK_U64_CONSTANT(0x7ff0000000000000)) { + return 1; + } +#endif +#else + t = du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL; + if (t == 0x00000000UL) { + return DUK_DBLUNION_IS_ANYZERO(&du); + } + if (t == 0x7ff00000UL) { + return 1; + } +#endif + return 0; +} + +DUK_INTERNAL duk_small_uint_t duk_double_signbit(duk_double_t x) { + duk_double_union du; + du.d = x; + return (duk_small_uint_t) DUK_DBLUNION_GET_SIGNBIT(&du); +} + +DUK_INTERNAL duk_double_t duk_double_trunc_towards_zero(duk_double_t x) { + /* XXX: optimize */ + duk_small_uint_t s = duk_double_signbit(x); + x = DUK_FLOOR(DUK_FABS(x)); /* truncate towards zero */ + if (s) { + x = -x; + } + return x; +} + +DUK_INTERNAL duk_bool_t duk_double_same_sign(duk_double_t x, duk_double_t y) { + duk_double_union du1; + duk_double_union du2; + du1.d = x; + du2.d = y; + + return (((du1.ui[DUK_DBL_IDX_UI0] ^ du2.ui[DUK_DBL_IDX_UI0]) & 0x80000000UL) == 0); +} + +DUK_INTERNAL duk_double_t duk_double_fmin(duk_double_t x, duk_double_t y) { + /* Doesn't replicate fmin() behavior exactly: for fmin() if one + * argument is a NaN, the other argument should be returned. + * Duktape doesn't rely on this behavior so the replacement can + * be simplified. + */ + return (x < y ? x : y); +} + +DUK_INTERNAL duk_double_t duk_double_fmax(duk_double_t x, duk_double_t y) { + /* Doesn't replicate fmax() behavior exactly: for fmax() if one + * argument is a NaN, the other argument should be returned. + * Duktape doesn't rely on this behavior so the replacement can + * be simplified. + */ + return (x > y ? x : y); +} #line 1 "duk_hobject_class.c" /* - * Hobject ECMAScript [[Class]]. + * Hobject Ecmascript [[Class]]. */ /* #include duk_internal.h -> already included */ @@ -13348,10 +13304,9 @@ if (!(DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE); - DUK_WO_NORETURN(return NULL;); } - /* Maximum size check is handled by callee. */ + /* maximum size check is handled by callee */ duk_hbuffer_resize(thr, h, new_size); return DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, h); @@ -13369,7 +13324,6 @@ if (!(DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE); - DUK_WO_NORETURN(return NULL;); } /* Forget the previous allocation, setting size to 0 and alloc to @@ -13398,7 +13352,6 @@ if (!DUK_HBUFFER_HAS_EXTERNAL(h)) { DUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE); - DUK_WO_NORETURN(return;); } DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(h)); @@ -13448,7 +13401,7 @@ len = DUK_RAW_READ_U32_BE(p); buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, (duk_size_t) len); DUK_ASSERT(buf != NULL); - duk_memcpy((void *) buf, (const void *) p, (size_t) len); + DUK_MEMCPY((void *) buf, (const void *) p, (size_t) len); p += len; return p; } @@ -13463,7 +13416,7 @@ DUK_ASSERT(len <= 0xffffffffUL); /* string limits */ tmp32 = (duk_uint32_t) len; DUK_RAW_WRITE_U32_BE(p, tmp32); - duk_memcpy((void *) p, + DUK_MEMCPY((void *) p, (const void *) DUK_HSTRING_GET_DATA(h), len); p += len; @@ -13482,10 +13435,9 @@ DUK_ASSERT(len <= 0xffffffffUL); /* buffer limits */ tmp32 = (duk_uint32_t) len; DUK_RAW_WRITE_U32_BE(p, tmp32); - /* When len == 0, buffer data pointer may be NULL. */ - duk_memcpy_unsafe((void *) p, - (const void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h), - len); + DUK_MEMCPY((void *) p, + (const void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h), + len); p += len; return p; } @@ -13697,7 +13649,7 @@ ins_end = DUK_HCOMPFUNC_GET_CODE_END(thr->heap, func); DUK_ASSERT((duk_size_t) (ins_end - ins) == (duk_size_t) count_instr); #if defined(DUK_USE_INTEGER_BE) - duk_memcpy_unsafe((void *) p, (const void *) ins, (size_t) (ins_end - ins)); + DUK_MEMCPY((void *) p, (const void *) ins, (size_t) (ins_end - ins)); p += (size_t) (ins_end - ins); #else while (ins != ins_end) { @@ -13719,7 +13671,7 @@ h_str = DUK_TVAL_GET_STRING(tv); DUK_ASSERT(h_str != NULL); DUK_ASSERT(DUK_HSTRING_MAX_BYTELEN <= 0x7fffffffUL); /* ensures no overflow */ - p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 1U + 4U + DUK_HSTRING_GET_BYTELEN(h_str), p); + p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 1U + 4U + DUK_HSTRING_GET_BYTELEN(h_str), p), *p++ = DUK__SER_STRING; p = duk__dump_hstring_raw(p, h_str); } else { @@ -13883,7 +13835,7 @@ DUK__ASSERT_LEFT(count_instr * sizeof(duk_instr_t)); #if defined(DUK_USE_INTEGER_BE) q = fun_data + sizeof(duk_tval) * count_const + sizeof(duk_hobject *) * count_funcs; - duk_memcpy((void *) q, + DUK_MEMCPY((void *) q, (const void *) p, sizeof(duk_instr_t) * count_instr); p += sizeof(duk_instr_t) * count_instr; @@ -13948,12 +13900,15 @@ DUK_ASSERT((count_const == 0 && count_funcs == 0) || tv1 != NULL); q = fun_data; - duk_memcpy_unsafe((void *) q, (const void *) tv1, sizeof(duk_tval) * count_const); - for (n = count_const; n > 0; n--) { - DUK_TVAL_INCREF_FAST(thr, (duk_tval *) (void *) q); /* no side effects */ - q += sizeof(duk_tval); + if (count_const > 0) { + /* Explicit zero size check to avoid NULL 'tv1'. */ + DUK_MEMCPY((void *) q, (const void *) tv1, sizeof(duk_tval) * count_const); + for (n = count_const; n > 0; n--) { + DUK_TVAL_INCREF_FAST(thr, (duk_tval *) (void *) q); /* no side effects */ + q += sizeof(duk_tval); + } + tv1 += count_const; } - tv1 += count_const; DUK_HCOMPFUNC_SET_FUNCS(thr->heap, h_fun, (duk_hobject **) (void *) q); for (n = count_funcs; n > 0; n--) { @@ -14154,7 +14109,6 @@ format_error: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_BYTECODE); - DUK_WO_NORETURN(return;); } #else /* DUK_USE_BYTECODE_DUMP_SUPPORT */ @@ -14162,13 +14116,11 @@ DUK_EXTERNAL void duk_dump_function(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_load_function(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_BYTECODE_DUMP_SUPPORT */ @@ -14236,7 +14188,7 @@ idx_func = duk_get_top(thr) - nargs - other; if (DUK_UNLIKELY((idx_func | nargs) < 0)) { /* idx_func < 0 || nargs < 0; OR sign bits */ DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + /* unreachable */ } DUK_ASSERT(duk_is_valid_index(thr, idx_func)); return idx_func; @@ -14348,7 +14300,6 @@ obj_idx = duk_require_normalize_index(thr, obj_idx); /* make absolute */ if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return;); } duk__call_prop_prep_stack(thr, obj_idx, nargs); @@ -14385,7 +14336,7 @@ args.nargs = nargs; if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } args.call_flags = 0; @@ -14420,7 +14371,7 @@ args.nargs = nargs; if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } args.call_flags = call_flags; @@ -14461,7 +14412,7 @@ args.nargs = nargs; if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } args.call_flags = 0; @@ -14497,7 +14448,7 @@ (long) (thr->valstack_top - thr->valstack), (long) nrets)); DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } rc = duk_handle_safe_call(thr, /* thread */ @@ -14545,7 +14496,7 @@ if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } rc = duk_safe_call(thr, duk__pnew_helper, (void *) &nargs /*udata*/, nargs + 1 /*nargs*/, 1 /*nrets*/); @@ -14572,7 +14523,6 @@ if (!duk_is_constructor_call(thr)) { DUK_ERROR_TYPE(thr, DUK_STR_CONSTRUCT_ONLY); - DUK_WO_NORETURN(return;); } } @@ -14583,7 +14533,7 @@ * because all Duktape/C functions are considered strict, * and strict is also the default when nothing is running. * However, Duktape may call this function internally when - * the current activation is an ECMAScript function, so + * the current activation is an Ecmascript function, so * this cannot be replaced by a 'return 1' without fixing * the internal call sites. */ @@ -14650,7 +14600,7 @@ /* fall through */ type_error: DUK_ERROR_TYPE(thr, DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_EXTERNAL void duk_set_magic(duk_hthread *thr, duk_idx_t idx, duk_int_t magic) { @@ -14682,7 +14632,7 @@ h = DUK_TVAL_GET_OBJECT(tv); DUK_ASSERT(h != NULL); if (DUK_HOBJECT_HAS_BOUNDFUNC(h)) { - duk_push_tval(thr, &((duk_hboundfunc *) (void *) h)->target); + duk_push_tval(thr, &((duk_hboundfunc *) h)->target); duk_replace(thr, -2); #if 0 DUK_TVAL_SET_TVAL(tv, &((duk_hboundfunc *) h)->target); @@ -14713,10 +14663,6 @@ /* #include duk_internal.h -> already included */ -/* - * Misc helpers - */ - /* Shared handling for encode/decode argument. Fast path handling for * buffer and string values because they're the most common. In particular, * avoid creating a temporary string or buffer when possible. @@ -14738,425 +14684,250 @@ return (const duk_uint8_t *) duk_to_lstring(thr, idx, out_len); } -/* - * Base64 - */ - -#if defined(DUK_USE_BASE64_SUPPORT) -/* Bytes emitted for number of padding characters in range [0,4]. */ -DUK_LOCAL const duk_int8_t duk__base64_decode_nequal_step[5] = { - 3, /* #### -> 24 bits, emit 3 bytes */ - 2, /* ###= -> 18 bits, emit 2 bytes */ - 1, /* ##== -> 12 bits, emit 1 byte */ - -1, /* #=== -> 6 bits, error */ - 0, /* ==== -> 0 bits, emit 0 bytes */ -}; - -#if defined(DUK_USE_BASE64_FASTPATH) -DUK_LOCAL const duk_uint8_t duk__base64_enctab_fast[64] = { - 0x41U, 0x42U, 0x43U, 0x44U, 0x45U, 0x46U, 0x47U, 0x48U, 0x49U, 0x4aU, 0x4bU, 0x4cU, 0x4dU, 0x4eU, 0x4fU, 0x50U, /* A...P */ - 0x51U, 0x52U, 0x53U, 0x54U, 0x55U, 0x56U, 0x57U, 0x58U, 0x59U, 0x5aU, 0x61U, 0x62U, 0x63U, 0x64U, 0x65U, 0x66U, /* Q...f */ - 0x67U, 0x68U, 0x69U, 0x6aU, 0x6bU, 0x6cU, 0x6dU, 0x6eU, 0x6fU, 0x70U, 0x71U, 0x72U, 0x73U, 0x74U, 0x75U, 0x76U, /* g...v */ - 0x77U, 0x78U, 0x79U, 0x7aU, 0x30U, 0x31U, 0x32U, 0x33U, 0x34U, 0x35U, 0x36U, 0x37U, 0x38U, 0x39U, 0x2bU, 0x2fU /* w.../ */ -}; -#endif /* DUK_USE_BASE64_FASTPATH */ - #if defined(DUK_USE_BASE64_FASTPATH) -/* Decode table for one byte of input: - * -1 = allowed whitespace - * -2 = padding - * -3 = error - * 0...63 decoded bytes - */ -DUK_LOCAL const duk_int8_t duk__base64_dectab_fast[256] = { - -3, -3, -3, -3, -3, -3, -3, -3, -3, -1, -1, -3, -3, -1, -3, -3, /* 0x00...0x0f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0x10...0x1f */ - -1, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, 62, -3, -3, -3, 63, /* 0x20...0x2f */ - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -3, -3, -3, -2, -3, -3, /* 0x30...0x3f */ - -3, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40...0x4f */ - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -3, -3, -3, -3, -3, /* 0x50...0x5f */ - -3, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60...0x6f */ - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -3, -3, -3, -3, -3, /* 0x70...0x7f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0x80...0x8f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0x90...0x9f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xa0...0xaf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xb0...0xbf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xc0...0xcf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xd0...0xdf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xe0...0xef */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3 /* 0xf0...0xff */ -}; -#endif /* DUK_USE_BASE64_FASTPATH */ - -#if defined(DUK_USE_BASE64_FASTPATH) -DUK_LOCAL DUK_ALWAYS_INLINE void duk__base64_encode_fast_3(const duk_uint8_t *src, duk_uint8_t *dst) { +DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) { duk_uint_t t; + duk_size_t n_full, n_full3, n_final; + const duk_uint8_t *src_end_fast; - t = (duk_uint_t) src[0]; - t = (t << 8) + (duk_uint_t) src[1]; - t = (t << 8) + (duk_uint_t) src[2]; - - dst[0] = duk__base64_enctab_fast[t >> 18]; - dst[1] = duk__base64_enctab_fast[(t >> 12) & 0x3fU]; - dst[2] = duk__base64_enctab_fast[(t >> 6) & 0x3fU]; - dst[3] = duk__base64_enctab_fast[t & 0x3fU]; - -#if 0 - /* Tested: not faster on x64, most likely due to aliasing between - * output and input index computation. - */ - /* aaaaaabb bbbbcccc ccdddddd */ - dst[0] = duk__base64_enctab_fast[(src[0] >> 2) & 0x3fU]; - dst[1] = duk__base64_enctab_fast[((src[0] << 4) & 0x30U) | ((src[1] >> 4) & 0x0fU)]; - dst[2] = duk__base64_enctab_fast[((src[1] << 2) & 0x3fU) | ((src[2] >> 6) & 0x03U)]; - dst[3] = duk__base64_enctab_fast[src[2] & 0x3fU]; + n_full = srclen / 3; /* full 3-byte -> 4-char conversions */ + n_full3 = n_full * 3; + n_final = srclen - n_full3; + DUK_ASSERT_DISABLE(n_final >= 0); + DUK_ASSERT(n_final <= 2); + + src_end_fast = src + n_full3; + while (DUK_UNLIKELY(src != src_end_fast)) { + t = (duk_uint_t) (*src++); + t = (t << 8) + (duk_uint_t) (*src++); + t = (t << 8) + (duk_uint_t) (*src++); + + *dst++ = duk_base64_enctab[t >> 18]; + *dst++ = duk_base64_enctab[(t >> 12) & 0x3f]; + *dst++ = duk_base64_enctab[(t >> 6) & 0x3f]; + *dst++ = duk_base64_enctab[t & 0x3f]; + +#if 0 /* Tested: not faster on x64 */ + /* aaaaaabb bbbbcccc ccdddddd */ + dst[0] = duk_base64_enctab[(src[0] >> 2) & 0x3f]; + dst[1] = duk_base64_enctab[((src[0] << 4) & 0x30) | ((src[1] >> 4) & 0x0f)]; + dst[2] = duk_base64_enctab[((src[1] << 2) & 0x3f) | ((src[2] >> 6) & 0x03)]; + dst[3] = duk_base64_enctab[src[2] & 0x3f]; + src += 3; dst += 4; #endif -} - -DUK_LOCAL DUK_ALWAYS_INLINE void duk__base64_encode_fast_2(const duk_uint8_t *src, duk_uint8_t *dst) { - duk_uint_t t; - - t = (duk_uint_t) src[0]; - t = (t << 8) + (duk_uint_t) src[1]; - dst[0] = duk__base64_enctab_fast[t >> 10]; /* XXXXXX-- -------- */ - dst[1] = duk__base64_enctab_fast[(t >> 4) & 0x3fU]; /* ------XX XXXX---- */ - dst[2] = duk__base64_enctab_fast[(t << 2) & 0x3fU]; /* -------- ----XXXX */ - dst[3] = DUK_ASC_EQUALS; -} - -DUK_LOCAL DUK_ALWAYS_INLINE void duk__base64_encode_fast_1(const duk_uint8_t *src, duk_uint8_t *dst) { - duk_uint_t t; - - t = (duk_uint_t) src[0]; - dst[0] = duk__base64_enctab_fast[t >> 2]; /* XXXXXX-- */ - dst[1] = duk__base64_enctab_fast[(t << 4) & 0x3fU]; /* ------XX */ - dst[2] = DUK_ASC_EQUALS; - dst[3] = DUK_ASC_EQUALS; -} - -DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) { - duk_size_t n; - const duk_uint8_t *p; - duk_uint8_t *q; - - n = srclen; - p = src; - q = dst; - - if (n >= 16U) { - /* Fast path, unrolled by 4, allows interleaving. Process - * 12-byte input chunks which encode to 16-char output chunks. - * Only enter when at least one block is emitted (avoids div+mul - * for short inputs too). - */ - const duk_uint8_t *p_end_fast; + } - p_end_fast = p + ((n / 12U) * 12U); - DUK_ASSERT(p_end_fast >= p + 12); - do { - duk__base64_encode_fast_3(p, q); - duk__base64_encode_fast_3(p + 3, q + 4); - duk__base64_encode_fast_3(p + 6, q + 8); - duk__base64_encode_fast_3(p + 9, q + 12); - p += 12; - q += 16; - } while (DUK_LIKELY(p != p_end_fast)); - - DUK_ASSERT(src + srclen >= p); - n = (duk_size_t) (src + srclen - p); - DUK_ASSERT(n < 12U); - } - - /* Remainder. */ - while (n >= 3U) { - duk__base64_encode_fast_3(p, q); - p += 3; - q += 4; - n -= 3U; + switch (n_final) { + /* case 0: nop */ + case 1: { + /* XX== */ + t = (duk_uint_t) (*src++); + *dst++ = duk_base64_enctab[t >> 2]; /* XXXXXX-- */ + *dst++ = duk_base64_enctab[(t << 4) & 0x3f]; /* ------XX */ + *dst++ = DUK_ASC_EQUALS; + *dst++ = DUK_ASC_EQUALS; + break; + } + case 2: { + /* XXX= */ + t = (duk_uint_t) (*src++); + t = (t << 8) + (duk_uint_t) (*src++); + *dst++ = duk_base64_enctab[t >> 10]; /* XXXXXX-- -------- */ + *dst++ = duk_base64_enctab[(t >> 4) & 0x3f]; /* ------XX XXXX---- */ + *dst++ = duk_base64_enctab[(t << 2) & 0x3f]; /* -------- ----XXXX */ + *dst++ = DUK_ASC_EQUALS; + break; } - DUK_ASSERT(n == 0U || n == 1U || n == 2U); - if (n == 1U) { - duk__base64_encode_fast_1(p, q); -#if 0 /* Unnecessary. */ - p += 1; - q += 4; - n -= 1U; -#endif - } else if (n == 2U) { - duk__base64_encode_fast_2(p, q); -#if 0 /* Unnecessary. */ - p += 2; - q += 4; - n -= 2U; -#endif - } else { - DUK_ASSERT(n == 0U); /* nothing to do */ - ; } } #else /* DUK_USE_BASE64_FASTPATH */ DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) { - duk_small_uint_t i, npad; - duk_uint_t t, x, y; - const duk_uint8_t *p; - const duk_uint8_t *p_end; - duk_uint8_t *q; + duk_small_uint_t i, snip; + duk_uint_t t; + duk_uint_fast8_t x, y; + const duk_uint8_t *src_end; - p = src; - p_end = src + srclen; - q = dst; - npad = 0U; + src_end = src + srclen; - while (p < p_end) { - /* Read 3 bytes into 't', padded by zero. */ + while (src < src_end) { + /* read 3 bytes into 't', padded by zero */ + snip = 4; t = 0; for (i = 0; i < 3; i++) { t = t << 8; - if (p < p_end) { - t += (duk_uint_t) (*p++); + if (src >= src_end) { + snip--; } else { - /* This only happens on the last loop and we're - * guaranteed to exit on the next loop. - */ - npad++; + t += (duk_uint_t) (*src++); } } - DUK_ASSERT(npad <= 2U); - /* Emit 4 encoded characters. If npad > 0, some of the - * chars will be incorrect (zero bits) but we fix up the - * padding after the loop. A straightforward 64-byte - * lookup would be faster and cleaner, but this is shorter. + /* + * Missing bytes snip base64 example + * 0 4 XXXX + * 1 3 XXX= + * 2 2 XX== */ + + DUK_ASSERT(snip >= 2 && snip <= 4); + for (i = 0; i < 4; i++) { - x = ((t >> 18) & 0x3fU); + x = (duk_uint_fast8_t) ((t >> 18) & 0x3f); t = t << 6; - if (x <= 51U) { - if (x <= 25) { - y = x + DUK_ASC_UC_A; - } else { - y = x - 26 + DUK_ASC_LC_A; - } + /* A straightforward 64-byte lookup would be faster + * and cleaner, but this is shorter. + */ + if (i >= snip) { + y = '='; + } else if (x <= 25) { + y = x + 'A'; + } else if (x <= 51) { + y = x - 26 + 'a'; + } else if (x <= 61) { + y = x - 52 + '0'; + } else if (x == 62) { + y = '+'; } else { - if (x <= 61U) { - y = x - 52 + DUK_ASC_0; - } else if (x == 62) { - y = DUK_ASC_PLUS; - } else { - DUK_ASSERT(x == 63); - y = DUK_ASC_SLASH; - } + y = '/'; } - *q++ = (duk_uint8_t) y; + *dst++ = (duk_uint8_t) y; } } - - /* Handle padding by rewriting 0-2 bogus characters at the end. - * - * Missing bytes npad base64 example - * 0 0 #### - * 1 1 ###= - * 2 2 ##== - */ - DUK_ASSERT(npad <= 2U); - while (npad > 0U) { - *(q - npad) = DUK_ASC_EQUALS; - npad--; - } } #endif /* DUK_USE_BASE64_FASTPATH */ #if defined(DUK_USE_BASE64_FASTPATH) DUK_LOCAL duk_bool_t duk__base64_decode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst, duk_uint8_t **out_dst_final) { duk_int_t x; - duk_uint_t t; + duk_int_t t; duk_small_uint_t n_equal; - duk_int8_t step; - const duk_uint8_t *p; - const duk_uint8_t *p_end; - const duk_uint8_t *p_end_safe; - duk_uint8_t *q; - - p = src; - p_end = src + srclen; - p_end_safe = p_end - 8; /* If 'src <= src_end_safe', safe to read 8 bytes. */ - q = dst; - - /* Alternate between a fast path which processes clean groups with no - * padding or whitespace, and a slow path which processes one arbitrary - * group and then re-enters the fast path. This handles e.g. base64 - * with newlines reasonably well because the majority of a line is in - * the fast path. + duk_small_uint_t n_chars; + const duk_uint8_t *src_end; + const duk_uint8_t *src_end_safe; + + src_end = src + srclen; + src_end_safe = src_end - 4; /* if 'src < src_end_safe', safe to read 4 bytes */ + + /* Innermost fast path processes 4 valid base-64 characters at a time + * but bails out on whitespace, padding chars ('=') and invalid chars. + * Once the slow path segment has been processed, we return to the + * inner fast path again. This handles e.g. base64 with newlines + * reasonably well because the majority of a line is in the fast path. */ for (;;) { - /* Fast path, on each loop handle two 4-char input groups. - * If both are clean, emit 6 bytes and continue. If first - * is clean, emit 3 bytes and drop out; otherwise emit - * nothing and drop out. This approach could be extended to - * more groups per loop, but for inputs with e.g. periodic - * newlines (which are common) it might not be an improvement. - */ - while (DUK_LIKELY(p <= p_end_safe)) { - duk_int_t t1, t2; - - /* The lookup byte is intentionally sign extended to - * (at least) 32 bits and then ORed. This ensures - * that is at least 1 byte is negative, the highest - * bit of the accumulator will be set at the end and - * we don't need to check every byte. - * - * Read all input bytes first before writing output - * bytes to minimize aliasing. - */ - DUK_DDD(DUK_DDDPRINT("fast loop: p=%p, p_end_safe=%p, p_end=%p", - (const void *) p, (const void *) p_end_safe, (const void *) p_end)); + /* Fast path, handle units with just actual encoding characters. */ - t1 = (duk_int_t) duk__base64_dectab_fast[p[0]]; - t1 = (duk_int_t) ((duk_uint_t) t1 << 6) | (duk_int_t) duk__base64_dectab_fast[p[1]]; - t1 = (duk_int_t) ((duk_uint_t) t1 << 6) | (duk_int_t) duk__base64_dectab_fast[p[2]]; - t1 = (duk_int_t) ((duk_uint_t) t1 << 6) | (duk_int_t) duk__base64_dectab_fast[p[3]]; - - t2 = (duk_int_t) duk__base64_dectab_fast[p[4]]; - t2 = (duk_int_t) ((duk_uint_t) t2 << 6) | (duk_int_t) duk__base64_dectab_fast[p[5]]; - t2 = (duk_int_t) ((duk_uint_t) t2 << 6) | (duk_int_t) duk__base64_dectab_fast[p[6]]; - t2 = (duk_int_t) ((duk_uint_t) t2 << 6) | (duk_int_t) duk__base64_dectab_fast[p[7]]; - - q[0] = (duk_uint8_t) (((duk_uint_t) t1 >> 16) & 0xffU); - q[1] = (duk_uint8_t) (((duk_uint_t) t1 >> 8) & 0xffU); - q[2] = (duk_uint8_t) ((duk_uint_t) t1 & 0xffU); - - q[3] = (duk_uint8_t) (((duk_uint_t) t2 >> 16) & 0xffU); - q[4] = (duk_uint8_t) (((duk_uint_t) t2 >> 8) & 0xffU); - q[5] = (duk_uint8_t) ((duk_uint_t) t2 & 0xffU); - - /* Optimistic check using one branch. */ - if (DUK_LIKELY((t1 | t2) >= 0)) { - p += 8; - q += 6; - } else if (t1 >= 0) { - DUK_DDD(DUK_DDDPRINT("fast loop first group was clean, second was not, process one slow path group")); - DUK_ASSERT(t2 < 0); - p += 4; - q += 3; - break; - } else { - DUK_DDD(DUK_DDDPRINT("fast loop first group was not clean, second does not matter, process one slow path group")); - DUK_ASSERT(t1 < 0); + while (src <= src_end_safe) { + /* The lookup byte is intentionally sign extended to (at least) + * 32 bits and then ORed. This ensures that is at least 1 byte + * is negative, the highest bit of 't' will be set at the end + * and we don't need to check every byte. + */ + DUK_DDD(DUK_DDDPRINT("fast loop: src=%p, src_end_safe=%p, src_end=%p", + (const void *) src, (const void *) src_end_safe, (const void *) src_end)); + + t = (duk_int_t) duk_base64_dectab[*src++]; + t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++]; + t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++]; + t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++]; + + if (DUK_UNLIKELY(t < 0)) { + DUK_DDD(DUK_DDDPRINT("fast loop unit was not clean, process one slow path unit")); + src -= 4; break; } - } /* fast path */ - /* Slow path step 1: try to scan a 4-character encoded group, - * end-of-input, or start-of-padding. We exit with: - * 1. n_chars == 4: full group, no padding, no end-of-input. - * 2. n_chars < 4: partial group (may also be 0), encountered - * padding or end of input. - * - * The accumulator is initialized to 1; this allows us to detect - * a full group by comparing >= 0x1000000 without an extra - * counter variable. - */ - t = 1UL; + DUK_ASSERT(t <= 0xffffffL); + DUK_ASSERT((t >> 24) == 0); + *dst++ = (duk_uint8_t) (t >> 16); + *dst++ = (duk_uint8_t) ((t >> 8) & 0xff); + *dst++ = (duk_uint8_t) (t & 0xff); + } + + /* Handle one slow path unit (or finish if we're done). */ + + n_equal = 0; + n_chars = 0; + t = 0; for (;;) { - DUK_DDD(DUK_DDDPRINT("slow loop: p=%p, p_end=%p, t=%lu", - (const void *) p, (const void *) p_end, (unsigned long) t)); + DUK_DDD(DUK_DDDPRINT("slow loop: src=%p, src_end=%p, n_chars=%ld, n_equal=%ld, t=%ld", + (const void *) src, (const void *) src_end, (long) n_chars, (long) n_equal, (long) t)); - if (DUK_LIKELY(p < p_end)) { - x = duk__base64_dectab_fast[*p++]; - if (DUK_LIKELY(x >= 0)) { - DUK_ASSERT(x >= 0 && x <= 63); - t = (t << 6) + (duk_uint_t) x; - if (t >= 0x1000000UL) { - break; - } - } else if (x == -1) { + if (DUK_UNLIKELY(src >= src_end)) { + goto done; /* two level break */ + } + + x = duk_base64_dectab[*src++]; + if (DUK_UNLIKELY(x < 0)) { + if (x == -2) { continue; /* allowed ascii whitespace */ - } else if (x == -2) { - p--; - break; /* start of padding */ + } else if (x == -3) { + n_equal++; + t <<= 6; } else { - DUK_ASSERT(x == -3); + DUK_ASSERT(x == -1); goto decode_error; } } else { - break; /* end of input */ + DUK_ASSERT(x >= 0 && x <= 63); + if (n_equal > 0) { + /* Don't allow actual chars after equal sign. */ + goto decode_error; + } + t = (t << 6) + x; } - } /* slow path step 1 */ - - /* Complete the padding by simulating pad characters, - * regardless of actual input padding chars. - */ - n_equal = 0; - while (t < 0x1000000UL) { - t = (t << 6) + 0U; - n_equal++; - } - /* Slow path step 2: deal with full/partial group, padding, - * etc. Note that for num chars in [0,3] we intentionally emit - * 3 bytes but don't step forward that much, buffer space is - * guaranteed in setup. - * - * num chars: - * 0 #### no output (= step 0) - * 1 #=== reject, 6 bits of data - * 2 ##== 12 bits of data, output 1 byte (= step 1) - * 3 ###= 18 bits of data, output 2 bytes (= step 2) - * 4 #### 24 bits of data, output 3 bytes (= step 3) - */ - q[0] = (duk_uint8_t) ((t >> 16) & 0xffU); - q[1] = (duk_uint8_t) ((t >> 8) & 0xffU); - q[2] = (duk_uint8_t) (t & 0xffU); - - DUK_ASSERT(n_equal <= 4); - step = duk__base64_decode_nequal_step[n_equal]; - if (DUK_UNLIKELY(step < 0)) { - goto decode_error; - } - q += step; - - /* Slow path step 3: read and ignore padding and whitespace - * until (a) next non-padding and non-whitespace character - * after which we resume the fast path, or (b) end of input. - * This allows us to accept missing, partial, full, and extra - * padding cases uniformly. We also support concatenated - * base-64 documents because we resume scanning afterwards. - * - * Note that to support concatenated documents well, the '=' - * padding found inside the input must also allow for 'extra' - * padding. For example, 'Zm===' decodes to 'f' and has one - * extra padding char. So, 'Zm===Zm' should decode 'ff', even - * though the standard break-up would be 'Zm==' + '=Zm' which - * doesn't make sense. - * - * We also accept prepended padding like '==Zm9', because it - * is equivalent to an empty document with extra padding ('==') - * followed by a valid document. - */ + if (DUK_UNLIKELY(n_chars == 3)) { + /* Emit 3 bytes and backtrack if there was padding. There's + * always space for the whole 3 bytes so no check needed. + */ + DUK_ASSERT(t <= 0xffffffL); + DUK_ASSERT((t >> 24) == 0); + *dst++ = (duk_uint8_t) (t >> 16); + *dst++ = (duk_uint8_t) ((t >> 8) & 0xff); + *dst++ = (duk_uint8_t) (t & 0xff); + + if (DUK_UNLIKELY(n_equal > 0)) { + DUK_ASSERT(n_equal <= 4); + + /* There may be whitespace between the equal signs. */ + if (n_equal == 1) { + /* XXX= */ + dst -= 1; + } else if (n_equal == 2) { + /* XX== */ + dst -= 2; + } else { + goto decode_error; /* invalid padding */ + } - for (;;) { - if (DUK_UNLIKELY(p >= p_end)) { - goto done; - } - x = duk__base64_dectab_fast[*p++]; - if (x == -1 || x == -2) { - ; /* padding or whitespace, keep eating */ + /* Continue parsing after padding, allows concatenated, + * padded base64. + */ + } + break; /* back to fast loop */ } else { - p--; - break; /* backtrack and go back to fast path, even for -1 */ + n_chars++; } - } /* slow path step 3 */ - } /* outer fast+slow path loop */ - + } + } done: - DUK_DDD(DUK_DDDPRINT("done; p=%p, p_end=%p", - (const void *) p, (const void *) p_end)); + DUK_DDD(DUK_DDDPRINT("done; src=%p, src_end=%p, n_chars=%ld", + (const void *) src, (const void *) src_end, (long) n_chars)); - DUK_ASSERT(p == p_end); + DUK_ASSERT(src == src_end); + + if (n_chars != 0) { + /* Here we'd have the option of decoding unpadded base64 + * (e.g. "xxxxyy" instead of "xxxxyy==". Currently not + * accepted. + */ + goto decode_error; + } - *out_dst_final = q; + *out_dst_final = dst; return 1; decode_error: @@ -15164,138 +14935,94 @@ } #else /* DUK_USE_BASE64_FASTPATH */ DUK_LOCAL duk_bool_t duk__base64_decode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst, duk_uint8_t **out_dst_final) { - duk_uint_t t, x; - duk_int_t y; - duk_int8_t step; - const duk_uint8_t *p; - const duk_uint8_t *p_end; - duk_uint8_t *q; - /* 0x09, 0x0a, or 0x0d */ - duk_uint32_t mask_white = (1U << 9) | (1U << 10) | (1U << 13); + duk_uint_t t; + duk_uint_fast8_t x, y; + duk_small_uint_t group_idx; + duk_small_uint_t n_equal; + const duk_uint8_t *src_end; - /* 't' tracks progress of the decoded group: - * - * t == 1 no valid chars yet - * t >= 0x40 1x6 = 6 bits shifted in - * t >= 0x1000 2x6 = 12 bits shifted in - * t >= 0x40000 3x6 = 18 bits shifted in - * t >= 0x1000000 4x6 = 24 bits shifted in - * - * By initializing t=1 there's no need for a separate counter for - * the number of characters found so far. - */ - p = src; - p_end = src + srclen; - q = dst; - t = 1UL; + src_end = src + srclen; + t = 0; + group_idx = 0; + n_equal = 0; - for (;;) { - duk_small_uint_t n_equal; + while (src < src_end) { + x = *src++; - DUK_ASSERT(t >= 1U); - if (p >= p_end) { - /* End of input: if input exists, treat like - * start of padding, finish the block, then - * re-enter here to see we're done. + if (x >= 'A' && x <= 'Z') { + y = x - 'A' + 0; + } else if (x >= 'a' && x <= 'z') { + y = x - 'a' + 26; + } else if (x >= '0' && x <= '9') { + y = x - '0' + 52; + } else if (x == '+') { + y = 62; + } else if (x == '/') { + y = 63; + } else if (x == '=') { + /* We don't check the zero padding bytes here right now + * (that they're actually zero). This seems to be common + * behavior for base-64 decoders. */ - if (t == 1U) { - break; - } else { - goto simulate_padding; - } - } - x = *p++; - - if (x >= 0x41U) { - /* Valid: a-z and A-Z. */ - DUK_ASSERT(x >= 0x41U && x <= 0xffU); - if (x >= 0x61U && x <= 0x7aU) { - y = (duk_int_t) x - 0x61 + 26; - } else if (x <= 0x5aU) { - y = (duk_int_t) x - 0x41; - } else { - goto decode_error; - } - } else if (x >= 0x30U) { - /* Valid: 0-9 and =. */ - DUK_ASSERT(x >= 0x30U && x <= 0x40U); - if (x <= 0x39U) { - y = (duk_int_t) x - 0x30 + 52; - } else if (x == 0x3dU) { - /* Skip padding and whitespace unless we're in the - * middle of a block. Otherwise complete group by - * simulating shifting in the correct padding. - */ - if (t == 1U) { - continue; - } - goto simulate_padding; - } else { - goto decode_error; - } - } else if (x >= 0x20U) { - /* Valid: +, /, and 0x20 whitespace. */ - DUK_ASSERT(x >= 0x20U && x <= 0x2fU); - if (x == 0x2bU) { - y = 62; - } else if (x == 0x2fU) { - y = 63; - } else if (x == 0x20U) { - continue; - } else { - goto decode_error; - } + n_equal++; + t <<= 6; /* shift in zeroes */ + goto skip_add; + } else if (x == 0x09 || x == 0x0a || x == 0x0d || x == 0x20) { + /* allow basic ASCII whitespace */ + continue; } else { - /* Valid: whitespace. */ - duk_uint32_t m; - DUK_ASSERT(x < 0x20U); /* 0x00 to 0x1f */ - m = (1U << x); - if (mask_white & m) { - /* Allow basic ASCII whitespace. */ - continue; - } else { - goto decode_error; - } + goto decode_error; } - DUK_ASSERT(y >= 0 && y <= 63); - t = (t << 6) + (duk_uint_t) y; - if (t < 0x1000000UL) { - continue; + if (n_equal > 0) { + /* Don't allow mixed padding and actual chars. */ + goto decode_error; } - /* fall through; no padding will be added */ + t = (t << 6) + y; + skip_add: - simulate_padding: - n_equal = 0; - while (t < 0x1000000UL) { - t = (t << 6) + 0U; - n_equal++; - } + if (group_idx == 3) { + /* output 3 bytes from 't' */ + *dst++ = (duk_uint8_t) ((t >> 16) & 0xff); + *dst++ = (duk_uint8_t) ((t >> 8) & 0xff); + *dst++ = (duk_uint8_t) (t & 0xff); + + if (DUK_UNLIKELY(n_equal > 0)) { + /* Backtrack. */ + DUK_ASSERT(n_equal <= 4); + if (n_equal == 1) { + dst -= 1; + } else if (n_equal == 2) { + dst -= 2; + } else { + goto decode_error; /* invalid padding */ + } - /* Output 3 bytes from 't' and advance as needed. */ - q[0] = (duk_uint8_t) ((t >> 16) & 0xffU); - q[1] = (duk_uint8_t) ((t >> 8) & 0xffU); - q[2] = (duk_uint8_t) (t & 0xffU); - - DUK_ASSERT(n_equal <= 4U); - step = duk__base64_decode_nequal_step[n_equal]; - if (step < 0) { - goto decode_error; + /* Here we can choose either to end parsing and ignore + * whatever follows, or to continue parsing in case + * multiple (possibly padded) base64 strings have been + * concatenated. Currently, keep on parsing. + */ + n_equal = 0; + } + + t = 0; + group_idx = 0; + } else { + group_idx++; } - q += step; + } - /* Re-enter loop. The actual padding characters are skipped - * by the main loop. This handles cases like missing, partial, - * full, and extra padding, and allows parsing of concatenated - * documents (with extra padding) like: Zm===Zm. Also extra - * prepended padding is accepted: ===Zm9v. + if (group_idx != 0) { + /* Here we'd have the option of decoding unpadded base64 + * (e.g. "xxxxyy" instead of "xxxxyy==". Currently not + * accepted. */ - t = 1U; + goto decode_error; } - DUK_ASSERT(t == 1UL); - *out_dst_final = q; + *out_dst_final = dst; return 1; decode_error: @@ -15312,12 +15039,15 @@ DUK_ASSERT_API_ENTRY(thr); + /* XXX: optimize for string inputs: no need to coerce to a buffer + * which makes a copy of the input. + */ + idx = duk_require_normalize_index(thr, idx); src = duk__prep_codec_arg(thr, idx, &srclen); /* Note: for srclen=0, src may be NULL */ - /* Compute exact output length. Computation must not wrap; this - * limit works for 32-bit size_t: + /* Computation must not wrap; this limit works for 32-bit size_t: * >>> srclen = 3221225469 * >>> '%x' % ((srclen + 2) / 3 * 4) * 'fffffffc' @@ -15325,7 +15055,7 @@ if (srclen > 3221225469UL) { goto type_error; } - dstlen = (srclen + 2U) / 3U * 4U; + dstlen = (srclen + 2) / 3 * 4; dst = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, dstlen); duk__base64_encode_helper((const duk_uint8_t *) src, srclen, dst); @@ -15336,7 +15066,7 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_BASE64_ENCODE_FAILED); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } DUK_EXTERNAL void duk_base64_decode(duk_hthread *thr, duk_idx_t idx) { @@ -15345,24 +15075,31 @@ duk_size_t dstlen; duk_uint8_t *dst; duk_uint8_t *dst_final; + duk_bool_t retval; DUK_ASSERT_API_ENTRY(thr); + /* XXX: optimize for buffer inputs: no need to coerce to a string + * which causes an unnecessary interning. + */ + idx = duk_require_normalize_index(thr, idx); src = duk__prep_codec_arg(thr, idx, &srclen); - /* Round up and add safety margin. Avoid addition before division to - * avoid possibility of wrapping. Margin includes +3 for rounding up, - * and +3 for one extra group: the decoder may emit and then backtrack - * a full group (3 bytes) from zero-sized input for technical reasons. - * Similarly, 'xx' may ecause 1+3 = bytes to be emitted and then - * backtracked. + /* Computation must not wrap, only srclen + 3 is at risk of + * wrapping because after that the number gets smaller. + * This limit works for 32-bit size_t: + * 0x100000000 - 3 - 1 = 4294967292 */ - dstlen = (srclen / 4) * 3 + 6; /* upper limit, assuming no whitespace etc */ + if (srclen > 4294967292UL) { + goto type_error; + } + dstlen = (srclen + 3) / 4 * 3; /* upper limit, assuming no whitespace etc */ dst = (duk_uint8_t *) duk_push_dynamic_buffer(thr, dstlen); /* Note: for dstlen=0, dst may be NULL */ - if (!duk__base64_decode_helper((const duk_uint8_t *) src, srclen, dst, &dst_final)) { + retval = duk__base64_decode_helper((const duk_uint8_t *) src, srclen, dst, &dst_final); + if (!retval) { goto type_error; } @@ -15373,27 +15110,8 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_BASE64_DECODE_FAILED); - DUK_WO_NORETURN(return;); } -#else /* DUK_USE_BASE64_SUPPORT */ -DUK_EXTERNAL const char *duk_base64_encode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); -} - -DUK_EXTERNAL void duk_base64_decode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); -} -#endif /* DUK_USE_BASE64_SUPPORT */ - -/* - * Hex - */ -#if defined(DUK_USE_HEX_SUPPORT) DUK_EXTERNAL const char *duk_hex_encode(duk_hthread *thr, duk_idx_t idx) { const duk_uint8_t *inp; duk_size_t len; @@ -15504,12 +15222,8 @@ } } for (; i < len; i += 2) { - /* First cast to duk_int_t to sign extend, second cast to - * duk_uint_t to avoid signed left shift, and final cast to - * duk_int_t result type. - */ - t = (duk_int_t) ((((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i]]) << 4U) | - ((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i + 1]])); + t = (((duk_int_t) duk_hex_dectab[inp[i]]) << 4) | + ((duk_int_t) duk_hex_dectab[inp[i + 1]]); if (DUK_UNLIKELY(t < 0)) { goto type_error; } @@ -15521,8 +15235,8 @@ * at least 16 bits. If either nybble is invalid, the * resulting 't' will be < 0. */ - t = (duk_int_t) ((((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i]]) << 4U) | - ((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i + 1]])); + t = (((duk_int_t) duk_hex_dectab[inp[i]]) << 4) | + ((duk_int_t) duk_hex_dectab[inp[i + 1]]); if (DUK_UNLIKELY(t < 0)) { goto type_error; } @@ -15535,24 +15249,7 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_HEX_DECODE_FAILED); - DUK_WO_NORETURN(return;); -} -#else /* DUK_USE_HEX_SUPPORT */ -DUK_EXTERNAL const char *duk_hex_encode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } -DUK_EXTERNAL void duk_hex_decode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); -} -#endif /* DUK_USE_HEX_SUPPORT */ - -/* - * JSON - */ #if defined(DUK_USE_JSON_SUPPORT) DUK_EXTERNAL const char *duk_json_encode(duk_hthread *thr, duk_idx_t idx) { @@ -15605,14 +15302,12 @@ DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return NULL;); } DUK_EXTERNAL void duk_json_decode(duk_hthread *thr, duk_idx_t idx) { DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_JSON_SUPPORT */ #line 1 "duk_api_compile.c" @@ -15707,7 +15402,6 @@ if ((flags & DUK_COMPILE_NOSOURCE) || /* args incorrect */ (h_sourcecode == NULL)) { /* e.g. duk_push_string_file_raw() pushed undefined */ DUK_ERROR_TYPE(thr, DUK_STR_NO_SOURCECODE); - DUK_WO_NORETURN(return 0;); } DUK_ASSERT(h_sourcecode != NULL); comp_args->src_buffer = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_sourcecode); @@ -15833,7 +15527,6 @@ DUK_EXTERNAL void duk_push_context_dump(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_JSON_SUPPORT */ @@ -15945,7 +15638,7 @@ top = duk_get_top(thr); if (top < nvalues) { DUK_ERROR_RANGE(thr, "not enough stack values for notify"); - DUK_WO_NORETURN(return 0;); + return ret; /* unreachable */ } if (duk_debug_is_attached(thr->heap)) { duk_debug_write_notify(thr, DUK_DBG_CMD_APPNOTIFY); @@ -16012,13 +15705,11 @@ DUK_UNREF(detached_cb); DUK_UNREF(udata); DUK_ERROR_TYPE(thr, "no debugger support"); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_debugger_detach(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_TYPE(thr, "no debugger support"); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_debugger_cooperate(duk_hthread *thr) { @@ -16035,7 +15726,7 @@ top = duk_get_top(thr); if (top < nvalues) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } /* No debugger support, just pop values. */ @@ -16158,7 +15849,7 @@ duk_push_tval(thr, &lj->value2); /* XXX: creating_error == 0 is asserted above, so no need to store. */ - duk_memcpy((void *) &snapshot->lj, (const void *) lj, sizeof(duk_ljstate)); + DUK_MEMCPY((void *) &snapshot->lj, (const void *) lj, sizeof(duk_ljstate)); snapshot->creating_error = heap->creating_error; snapshot->curr_thread = heap->curr_thread; snapshot->call_recursion_depth = heap->call_recursion_depth; @@ -16188,7 +15879,7 @@ heap = thr->heap; - duk_memcpy((void *) &heap->lj, (const void *) &snapshot->lj, sizeof(duk_ljstate)); + DUK_MEMCPY((void *) &heap->lj, (const void *) &snapshot->lj, sizeof(duk_ljstate)); heap->creating_error = snapshot->creating_error; heap->curr_thread = snapshot->curr_thread; heap->call_recursion_depth = snapshot->call_recursion_depth; @@ -16325,7 +16016,7 @@ DUK_ASSERT_API_ENTRY(thr); /* Assume two's complement and set everything to -1. */ - duk_memset((void *) &vals, (int) 0xff, sizeof(vals)); + DUK_MEMSET((void *) &vals, (int) 0xff, sizeof(vals)); DUK_ASSERT(vals[DUK__IDX_TYPE] == -1); /* spot check one */ tv = duk_get_tval_or_unused(thr, idx); @@ -16341,12 +16032,12 @@ goto finish; } duk_push_pointer(thr, (void *) h); - duk_put_prop_literal(thr, -2, "hptr"); + duk_put_prop_string(thr, -2, "hptr"); #if 0 /* Covers a lot of information, e.g. buffer and string variants. */ duk_push_uint(thr, (duk_uint_t) DUK_HEAPHDR_GET_FLAGS(h)); - duk_put_prop_literal(thr, -2, "hflags"); + duk_put_prop_string(thr, -2, "hflags"); #endif #if defined(DUK_USE_REFERENCE_COUNTING) @@ -16391,7 +16082,7 @@ } vals[DUK__IDX_CLASS] = (duk_int_t) DUK_HOBJECT_GET_CLASS_NUMBER(h_obj); - vals[DUK__IDX_PBYTES] = (duk_int_t) DUK_HOBJECT_P_ALLOC_SIZE(h_obj); + vals[DUK__IDX_PBYTES] = (duk_int_t) DUK_HOBJECT_P_ALLOC_SIZE(h_obj), vals[DUK__IDX_ESIZE] = (duk_int_t) DUK_HOBJECT_GET_ESIZE(h_obj); vals[DUK__IDX_ENEXT] = (duk_int_t) DUK_HOBJECT_GET_ENEXT(h_obj); vals[DUK__IDX_ASIZE] = (duk_int_t) DUK_HOBJECT_GET_ASIZE(h_obj); @@ -16594,7 +16285,7 @@ * Property handling * * The API exposes only the most common property handling functions. - * The caller can invoke ECMAScript built-ins for full control (e.g. + * The caller can invoke Ecmascript built-ins for full control (e.g. * defineProperty, getOwnPropertyDescriptor). */ @@ -16626,7 +16317,7 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_string(thr, key); + duk_push_string(thr, key); return duk_get_prop(thr, obj_idx); } @@ -16635,21 +16326,9 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_lstring(thr, key, key_len); - return duk_get_prop(thr, obj_idx); -} - -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_get_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); + duk_push_lstring(thr, key, key_len); return duk_get_prop(thr, obj_idx); } -#endif DUK_EXTERNAL duk_bool_t duk_get_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -16663,7 +16342,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk_get_prop(thr, obj_idx); } @@ -16672,7 +16351,7 @@ DUK_ASSERT_STRIDX_VALID(stridx); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_hstring(thr, DUK_HTHREAD_GET_STRING(thr, stridx)); + duk_push_hstring(thr, DUK_HTHREAD_GET_STRING(thr, stridx)); return duk_get_prop(thr, obj_idx); } @@ -16691,7 +16370,10 @@ if (out_has_prop) { *out_has_prop = rc; } - return duk_to_boolean_top_pop(thr); + rc = duk_to_boolean(thr, -1); + DUK_ASSERT(rc == 0 || rc == 1); + duk_pop(thr); + return rc; } DUK_LOCAL duk_bool_t duk__put_prop_shared(duk_hthread *thr, duk_idx_t obj_idx, duk_idx_t idx_key) { @@ -16751,18 +16433,6 @@ return duk__put_prop_shared(thr, obj_idx, -1); } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_put_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); - return duk__put_prop_shared(thr, obj_idx, -1); -} -#endif - DUK_EXTERNAL duk_bool_t duk_put_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -16775,7 +16445,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk__put_prop_shared(thr, obj_idx, -1); } @@ -16822,7 +16492,7 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_string(thr, key); + duk_push_string(thr, key); return duk_del_prop(thr, obj_idx); } @@ -16831,22 +16501,10 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_lstring(thr, key, key_len); + duk_push_lstring(thr, key, key_len); return duk_del_prop(thr, obj_idx); } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_del_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); - return duk_del_prop(thr, obj_idx); -} -#endif - DUK_EXTERNAL duk_bool_t duk_del_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -16859,7 +16517,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk_del_prop(thr, obj_idx); } @@ -16905,7 +16563,7 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_string(thr, key); + duk_push_string(thr, key); return duk_has_prop(thr, obj_idx); } @@ -16914,21 +16572,9 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_lstring(thr, key, key_len); - return duk_has_prop(thr, obj_idx); -} - -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_has_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); + duk_push_lstring(thr, key, key_len); return duk_has_prop(thr, obj_idx); } -#endif DUK_EXTERNAL duk_bool_t duk_has_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -16942,7 +16588,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk_has_prop(thr, obj_idx); } @@ -17142,17 +16788,17 @@ fail_invalid_desc: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_DESCRIPTOR); - DUK_WO_NORETURN(return;); + return; fail_not_callable: DUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE); - DUK_WO_NORETURN(return;); + return; } /* * Object related * - * Note: seal() and freeze() are accessible through ECMAScript bindings, + * Note: seal() and freeze() are accessible through Ecmascript bindings, * and are not exposed through the API. */ @@ -17244,7 +16890,6 @@ fail_cannot_freeze: DUK_ERROR_TYPE_INVALID_ARGS(thr); /* XXX: proper error message */ - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_seal(duk_hthread *thr, duk_idx_t obj_idx) { @@ -17328,38 +16973,6 @@ return ret; } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_get_global_literal_raw(duk_hthread *thr, const char *key, duk_size_t key_len) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - ret = duk_get_prop_literal_raw(thr, -1, key, key_len); - duk_remove_m2(thr); - return ret; -} -#endif - -DUK_EXTERNAL duk_bool_t duk_get_global_heapptr(duk_hthread *thr, void *ptr) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - ret = duk_get_prop_heapptr(thr, -1, ptr); - duk_remove_m2(thr); - return ret; -} - - DUK_EXTERNAL duk_bool_t duk_put_global_string(duk_hthread *thr, const char *key) { duk_bool_t ret; @@ -17390,56 +17003,6 @@ return ret; } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_put_global_literal_raw(duk_hthread *thr, const char *key, duk_size_t key_len) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - duk_insert(thr, -2); - ret = duk_put_prop_literal_raw(thr, -2, key, key_len); /* [ ... global val ] -> [ ... global ] */ - duk_pop(thr); - return ret; -} -#endif - -DUK_EXTERNAL duk_bool_t duk_put_global_heapptr(duk_hthread *thr, void *ptr) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - duk_insert(thr, -2); - ret = duk_put_prop_heapptr(thr, -2, ptr); /* [ ... global val ] -> [ ... global ] */ - duk_pop(thr); - return ret; -} - -/* - * ES2015 GetMethod() - */ - -DUK_INTERNAL duk_bool_t duk_get_method_stridx(duk_hthread *thr, duk_idx_t idx, duk_small_uint_t stridx) { - (void) duk_get_prop_stridx(thr, idx, stridx); - if (duk_is_null_or_undefined(thr, -1)) { - duk_pop_nodecref_unsafe(thr); - return 0; - } - if (!duk_is_callable(thr, -1)) { - DUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE); - DUK_WO_NORETURN(return 0;); - } - return 1; -} - /* * Object prototype */ @@ -17478,7 +17041,7 @@ #if defined(DUK_USE_ROM_OBJECTS) if (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); /* XXX: "read only object"? */ - DUK_WO_NORETURN(return;); + return; } #endif @@ -17535,26 +17098,14 @@ DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_set_finalizer(duk_hthread *thr, duk_idx_t idx) { DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_FINALIZER_SUPPORT */ -#line 1 "duk_api_random.c" -/* - * Random numbers - */ - -/* #include duk_internal.h -> already included */ - -DUK_EXTERNAL duk_double_t duk_random(duk_hthread *thr) { - return (duk_double_t) DUK_UTIL_GET_RANDOM_DOUBLE(thr); -} #line 1 "duk_api_stack.c" /* * API calls related to general value stack manipulation: resizing the value @@ -17730,7 +17281,7 @@ if (require) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "number", DUK_STR_NOT_NUMBER); - DUK_WO_NORETURN(return 0;); + /* not reachable */ } return def_value; @@ -17781,7 +17332,7 @@ if (require) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "number", DUK_STR_NOT_NUMBER); - DUK_WO_NORETURN(return 0;); + /* not reachable */ } return def_value; @@ -17856,7 +17407,7 @@ return (duk_idx_t) uidx; } DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } DUK_INTERNAL duk_tval *duk_get_tval(duk_hthread *thr, duk_idx_t idx) { @@ -17932,7 +17483,7 @@ return thr->valstack_bottom + uidx; } DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return NULL;); + return NULL; } /* Non-critical. */ @@ -17950,7 +17501,7 @@ if (DUK_UNLIKELY(duk_normalize_index(thr, idx) < 0)) { DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return;); + return; /* unreachable */ } } @@ -17975,7 +17526,6 @@ ret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom); if (DUK_UNLIKELY(ret < min_top)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); } return ret; } @@ -18020,7 +17570,7 @@ #else if (DUK_UNLIKELY(uidx > vs_limit)) { DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return;); + return; /* unreachable */ } #endif DUK_ASSERT(uidx <= vs_limit); @@ -18203,7 +17753,7 @@ ret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom) - 1; if (DUK_UNLIKELY(ret < 0)) { DUK_ERROR_RANGE_INDEX(thr, -1); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } return ret; } @@ -18404,7 +17954,6 @@ */ if (throw_on_error) { DUK_ERROR_RANGE(thr, DUK_STR_VALSTACK_LIMIT); - DUK_WO_NORETURN(return 0;); } return 0; } @@ -18412,7 +17961,6 @@ if (duk__resize_valstack(thr, new_size) == 0) { if (throw_on_error) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return 0;); } return 0; } @@ -18673,7 +18221,7 @@ if (DUK_UNLIKELY(thr->valstack_top - thr->valstack_bottom <= 0)) { DUK_ERROR_RANGE_INDEX(thr, -1); - DUK_WO_NORETURN(return;); + return; /* unreachable */ } tv_from = thr->valstack_top - 1; tv_to = thr->valstack_top++; @@ -18735,12 +18283,18 @@ DUK_DDD(DUK_DDDPRINT("duk_insert: to_idx=%ld, p=%p, q=%p, nbytes=%lu", (long) to_idx, (void *) p, (void *) q, (unsigned long) nbytes)); - /* No net refcount changes. No need to special case nbytes == 0 - * (p == q). - */ - DUK_TVAL_SET_TVAL(&tv_tmp, q); - duk_memmove((void *) (p + 1), (const void *) p, (size_t) nbytes); - DUK_TVAL_SET_TVAL(p, &tv_tmp); + /* No net refcount changes. */ + + if (nbytes > 0) { + DUK_TVAL_SET_TVAL(&tv_tmp, q); + DUK_ASSERT(nbytes > 0); + DUK_MEMMOVE((void *) (p + 1), (const void *) p, (size_t) nbytes); + DUK_TVAL_SET_TVAL(p, &tv_tmp); + } else { + /* nop: insert top to top */ + DUK_ASSERT(nbytes == 0); + DUK_ASSERT(p == q); + } } DUK_INTERNAL void duk_insert_undefined(duk_hthread *thr, duk_idx_t idx) { @@ -18832,7 +18386,7 @@ #endif nbytes = (duk_size_t) (((duk_uint8_t *) q) - ((duk_uint8_t *) p)); /* Note: 'q' is top-1 */ - duk_memmove((void *) p, (const void *) (p + 1), (size_t) nbytes); + DUK_MEMMOVE((void *) p, (const void *) (p + 1), (size_t) nbytes); /* zero size not an issue: pointers are valid */ DUK_TVAL_SET_UNDEFINED(q); thr->valstack_top--; @@ -18885,7 +18439,7 @@ DUK_TVAL_DECREF_NORZ(thr, tv); } - duk_memmove((void *) tv_dst, (const void *) tv_src, bytes); + DUK_MEMMOVE((void *) tv_dst, (const void *) tv_src, bytes); tv_newtop = thr->valstack_top - count; for (tv = tv_newtop; tv < thr->valstack_top; tv++) { @@ -18924,14 +18478,14 @@ if (DUK_UNLIKELY(to_thr == from_thr)) { DUK_ERROR_TYPE(to_thr, DUK_STR_INVALID_CONTEXT); - DUK_WO_NORETURN(return;); + return; } if (DUK_UNLIKELY((duk_uidx_t) count > (duk_uidx_t) DUK_USE_VALSTACK_LIMIT)) { /* Maximum value check ensures 'nbytes' won't wrap below. * Also handles negative count. */ DUK_ERROR_RANGE_INVALID_COUNT(to_thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count >= 0); @@ -18942,19 +18496,17 @@ DUK_ASSERT(to_thr->valstack_top <= to_thr->valstack_end); if (DUK_UNLIKELY((duk_size_t) ((duk_uint8_t *) to_thr->valstack_end - (duk_uint8_t *) to_thr->valstack_top) < nbytes)) { DUK_ERROR_RANGE_PUSH_BEYOND(to_thr); - DUK_WO_NORETURN(return;); } src = (void *) ((duk_uint8_t *) from_thr->valstack_top - nbytes); if (DUK_UNLIKELY(src < (void *) from_thr->valstack_bottom)) { DUK_ERROR_RANGE_INVALID_COUNT(to_thr); - DUK_WO_NORETURN(return;); } - /* Copy values (no overlap even if to_thr == from_thr; that's not - * allowed now anyway). + /* copy values (no overlap even if to_thr == from_thr; that's not + * allowed now anyway) */ DUK_ASSERT(nbytes > 0); - duk_memcpy((void *) to_thr->valstack_top, (const void *) src, (size_t) nbytes); + DUK_MEMCPY((void *) to_thr->valstack_top, (const void *) src, (size_t) nbytes); p = to_thr->valstack_top; to_thr->valstack_top = (duk_tval *) (void *) (((duk_uint8_t *) p) + nbytes); @@ -19003,7 +18555,7 @@ tv_dst = (duk_tval *) (void *) ((duk_uint8_t *) tv_src + gap_bytes); copy_bytes = (duk_size_t) ((duk_uint8_t *) thr->valstack_top - (duk_uint8_t *) tv_src); thr->valstack_top = (duk_tval *) (void *) ((duk_uint8_t *) thr->valstack_top + gap_bytes); - duk_memmove((void *) tv_dst, (const void *) tv_src, copy_bytes); + DUK_MEMMOVE((void *) tv_dst, (const void *) tv_src, copy_bytes); /* Values in the gap are left as garbage: caller must fill them in * and INCREF them before any side effects. @@ -19024,7 +18576,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_UNDEFINED(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "undefined", DUK_STR_NOT_UNDEFINED); - DUK_WO_NORETURN(return;); } } @@ -19037,7 +18588,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_NULL(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "null", DUK_STR_NOT_NULL); - DUK_WO_NORETURN(return;); } } @@ -19086,7 +18636,6 @@ return ret; } else { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "boolean", DUK_STR_NOT_BOOLEAN); - DUK_WO_NORETURN(return 0;); } } @@ -19148,7 +18697,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_NUMBER(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "number", DUK_STR_NOT_NUMBER); - DUK_WO_NORETURN(return 0.0;); } ret.d = DUK_TVAL_GET_NUMBER(tv); @@ -19380,7 +18928,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_OBJECT(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "object", DUK_STR_NOT_OBJECT); - DUK_WO_NORETURN(return;); } } @@ -19432,7 +18979,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_POINTER(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "pointer", DUK_STR_NOT_POINTER); - DUK_WO_NORETURN(return NULL;); } p = DUK_TVAL_GET_POINTER(tv); /* may be NULL */ return p; @@ -19480,7 +19026,6 @@ } else { if (throw_flag) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "buffer", DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } len = def_size; ret = def_ptr; @@ -19584,7 +19129,6 @@ if (throw_flag) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "buffer", DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } return def_ptr; } @@ -19664,7 +19208,6 @@ h = (duk_hstring *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_STRING); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "string", DUK_STR_NOT_STRING); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -19677,7 +19220,6 @@ h = (duk_hstring *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_STRING); if (DUK_UNLIKELY(h == NULL || DUK_HSTRING_HAS_SYMBOL(h))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "string", DUK_STR_NOT_STRING); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -19695,7 +19237,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "object", DUK_STR_NOT_OBJECT); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -19713,7 +19254,6 @@ h = (duk_hbuffer *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_BUFFER); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "buffer", DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -19738,7 +19278,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_THREAD(h)))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "thread", DUK_STR_NOT_THREAD); - DUK_WO_NORETURN(return NULL;); } return (duk_hthread *) h; } @@ -19763,7 +19302,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_COMPFUNC(h)))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "compiledfunction", DUK_STR_NOT_COMPFUNC); - DUK_WO_NORETURN(return NULL;); } return (duk_hcompfunc *) h; } @@ -19788,7 +19326,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_NATFUNC(h)))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "nativefunction", DUK_STR_NOT_NATFUNC); - DUK_WO_NORETURN(return NULL;); } return (duk_hnatfunc *) h; } @@ -19847,7 +19384,6 @@ ret = duk_get_c_function(thr, idx); if (DUK_UNLIKELY(!ret)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "nativefunction", DUK_STR_NOT_NATFUNC); - DUK_WO_NORETURN(return ret;); } return ret; } @@ -19856,7 +19392,6 @@ DUK_ASSERT_API_ENTRY(thr); if (DUK_UNLIKELY(!duk_is_function(thr, idx))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "function", DUK_STR_NOT_FUNCTION); - DUK_WO_NORETURN(return;); } } @@ -19868,7 +19403,6 @@ h = duk_require_hobject_accept_mask(thr, idx, DUK_TYPE_MASK_LIGHTFUNC); if (DUK_UNLIKELY(h != NULL && !DUK_HOBJECT_HAS_CONSTRUCTABLE(h))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "constructable", DUK_STR_NOT_CONSTRUCTABLE); - DUK_WO_NORETURN(return;); } /* Lightfuncs (h == NULL) are constructable. */ } @@ -19956,7 +19490,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_HEAP_ALLOCATED(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "heapobject", DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return NULL;); } ret = (void *) DUK_TVAL_GET_HEAPHDR(tv); @@ -19990,7 +19523,6 @@ if (type_mask & DUK_TYPE_MASK_THROW) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "object", DUK_STR_NOT_OBJECT); - DUK_WO_NORETURN(return NULL;); } return NULL; } @@ -20051,7 +19583,6 @@ DUK_UNREF(h_class); DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, (const char *) DUK_HSTRING_GET_DATA(h_class), DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -20244,43 +19775,49 @@ } /* E5 Section 9.1 */ -DUK_LOCAL const char * const duk__toprim_hint_strings[3] = { - "default", "string", "number" -}; -DUK_LOCAL void duk__to_primitive_helper(duk_hthread *thr, duk_idx_t idx, duk_int_t hint, duk_bool_t check_symbol) { - /* Inline initializer for coercers[] is not allowed by old compilers like BCC. */ +DUK_EXTERNAL void duk_to_primitive(duk_hthread *thr, duk_idx_t idx, duk_int_t hint) { + /* inline initializer for coercers[] is not allowed by old compilers like BCC */ duk_small_uint_t coercers[2]; + duk_small_uint_t class_number; DUK_ASSERT_API_ENTRY(thr); DUK_ASSERT(hint == DUK_HINT_NONE || hint == DUK_HINT_NUMBER || hint == DUK_HINT_STRING); idx = duk_require_normalize_index(thr, idx); - /* If already primitive, return as is. */ if (!duk_check_type_mask(thr, idx, DUK_TYPE_MASK_OBJECT | DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER)) { + /* Any other values stay as is. */ DUK_ASSERT(!duk_is_buffer(thr, idx)); /* duk_to_string() relies on this behavior */ return; } - /* @@toPrimitive lookup. Also do for plain buffers and lightfuncs - * which mimic objects. + class_number = duk_get_class_number(thr, idx); + + /* XXX: Symbol objects normally coerce via the ES2015-revised ToPrimitive() + * algorithm which consults value[@@toPrimitive] and avoids calling + * .valueOf() and .toString(). Before that is implemented, special + * case Symbol objects to behave as if they had the default @@toPrimitive + * algorithm of E6 Section 19.4.3.4, i.e. return the plain symbol value + * with no further side effects. */ - if (check_symbol && duk_get_method_stridx(thr, idx, DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE)) { - DUK_ASSERT(hint >= 0 && (duk_size_t) hint < sizeof(duk__toprim_hint_strings) / sizeof(const char *)); - duk_dup(thr, idx); - duk_push_string(thr, duk__toprim_hint_strings[hint]); - duk_call_method(thr, 1); /* [ ... method value hint ] -> [ ... res] */ - if (duk_check_type_mask(thr, -1, DUK_TYPE_MASK_OBJECT | - DUK_TYPE_MASK_LIGHTFUNC | - DUK_TYPE_MASK_BUFFER)) { - goto fail; + + if (class_number == DUK_HOBJECT_CLASS_SYMBOL) { + duk_hobject *h_obj; + duk_hstring *h_str; + + /* XXX: pretty awkward, index based API for internal value access? */ + h_obj = duk_known_hobject(thr, idx); + h_str = duk_hobject_get_internal_value_string(thr->heap, h_obj); + if (h_str) { + duk_push_hstring(thr, h_str); + duk_replace(thr, idx); + return; } - duk_replace(thr, idx); - return; } + /* Objects are coerced based on E5 specification. * Lightfuncs are coerced because they behave like * objects even if they're internally a primitive @@ -20288,29 +19825,17 @@ * like ArrayBuffer objects since Duktape 2.x. */ - /* Hint magic for Date is unnecessary in ES2015 because of - * Date.prototype[@@toPrimitive]. However, it is needed if - * symbol support is not enabled. - */ -#if defined(DUK_USE_SYMBOL_BUILTIN) - if (hint == DUK_HINT_NONE) { - hint = DUK_HINT_NUMBER; - } -#else /* DUK_USE_SYMBOL_BUILTIN */ - if (hint == DUK_HINT_NONE) { - duk_small_uint_t class_number; + coercers[0] = DUK_STRIDX_VALUE_OF; + coercers[1] = DUK_STRIDX_TO_STRING; - class_number = duk_get_class_number(thr, idx); + if (hint == DUK_HINT_NONE) { if (class_number == DUK_HOBJECT_CLASS_DATE) { hint = DUK_HINT_STRING; } else { hint = DUK_HINT_NUMBER; } } -#endif /* DUK_USE_SYMBOL_BUILTIN */ - coercers[0] = DUK_STRIDX_VALUE_OF; - coercers[1] = DUK_STRIDX_TO_STRING; if (hint == DUK_HINT_STRING) { coercers[0] = DUK_STRIDX_TO_STRING; coercers[1] = DUK_STRIDX_VALUE_OF; @@ -20326,20 +19851,8 @@ return; } - fail: DUK_ERROR_TYPE(thr, DUK_STR_TOPRIMITIVE_FAILED); - DUK_WO_NORETURN(return;); -} - -DUK_EXTERNAL void duk_to_primitive(duk_hthread *thr, duk_idx_t idx, duk_int_t hint) { - duk__to_primitive_helper(thr, idx, hint, 1 /*check_symbol*/); -} - -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL void duk_to_primitive_ordinary(duk_hthread *thr, duk_idx_t idx, duk_int_t hint) { - duk__to_primitive_helper(thr, idx, hint, 0 /*check_symbol*/); } -#endif /* E5 Section 9.2 */ DUK_EXTERNAL duk_bool_t duk_to_boolean(duk_hthread *thr, duk_idx_t idx) { @@ -20361,22 +19874,6 @@ return val; } -DUK_INTERNAL duk_bool_t duk_to_boolean_top_pop(duk_hthread *thr) { - duk_tval *tv; - duk_bool_t val; - - DUK_ASSERT_API_ENTRY(thr); - - tv = duk_require_tval(thr, -1); - DUK_ASSERT(tv != NULL); - - val = duk_js_toboolean(tv); - DUK_ASSERT(val == 0 || val == 1); - - duk_pop_unsafe(thr); - return val; -} - DUK_EXTERNAL duk_double_t duk_to_number(duk_hthread *thr, duk_idx_t idx) { duk_tval *tv; duk_double_t d; @@ -20656,67 +20153,68 @@ #endif /* Push Object.prototype.toString() output for 'tv'. */ -#if 0 /* See XXX note why this variant doesn't work. */ -DUK_INTERNAL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv, duk_bool_t avoid_side_effects) { - duk_uint_t stridx_bidx = 0; /* (prototype_bidx << 16) + default_tag_stridx */ +DUK_INTERNAL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv) { + duk_small_uint_t stridx; + duk_hstring *h_strclass; DUK_ASSERT_API_ENTRY(thr); - /* Conceptually for any non-undefined/null value we should do a - * ToObject() coercion and look up @@toStringTag (from the object - * prototype) to see if a custom tag should be used. Avoid the - * actual conversion by doing a prototype lookup without the object - * coercion. However, see problem below. - */ - - duk_push_literal(thr, "[object "); /* -> [ ... "[object" ] */ - switch (DUK_TVAL_GET_TAG(tv)) { case DUK_TAG_UNUSED: /* Treat like 'undefined', shouldn't happen. */ case DUK_TAG_UNDEFINED: { - stridx_bidx = DUK_STRIDX_UC_UNDEFINED; - goto use_stridx; + stridx = DUK_STRIDX_UC_UNDEFINED; + break; } case DUK_TAG_NULL: { - stridx_bidx = DUK_STRIDX_UC_NULL; - goto use_stridx; + stridx = DUK_STRIDX_UC_NULL; + break; } case DUK_TAG_BOOLEAN: { - stridx_bidx = (DUK_BIDX_BOOLEAN_PROTOTYPE << 16) + DUK_STRIDX_UC_BOOLEAN; - goto use_proto_bidx; + stridx = DUK_STRIDX_UC_BOOLEAN; + break; } case DUK_TAG_POINTER: { - stridx_bidx = (DUK_BIDX_POINTER_PROTOTYPE << 16) + DUK_STRIDX_UC_POINTER; - goto use_proto_bidx; + stridx = DUK_STRIDX_UC_POINTER; + break; } case DUK_TAG_LIGHTFUNC: { - stridx_bidx = (DUK_BIDX_FUNCTION_PROTOTYPE << 16) + DUK_STRIDX_UC_FUNCTION; - goto use_proto_bidx; + stridx = DUK_STRIDX_UC_FUNCTION; + break; } case DUK_TAG_STRING: { duk_hstring *h; h = DUK_TVAL_GET_STRING(tv); DUK_ASSERT(h != NULL); if (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) { - /* Even without DUK_USE_SYMBOL_BUILTIN the Symbol - * prototype exists so we can lookup @@toStringTag - * and provide [object Symbol] for symbol values - * created from C code. - */ - stridx_bidx = (DUK_BIDX_SYMBOL_PROTOTYPE << 16) + DUK_STRIDX_UC_SYMBOL; + stridx = DUK_STRIDX_UC_SYMBOL; } else { - stridx_bidx = (DUK_BIDX_STRING_PROTOTYPE << 16) + DUK_STRIDX_UC_STRING; + stridx = DUK_STRIDX_UC_STRING; } - goto use_proto_bidx; + break; } case DUK_TAG_OBJECT: { - duk_push_tval(thr, tv); - stridx_bidx = 0xffffffffUL; /* Marker value. */ - goto use_pushed_object; + duk_hobject *h; + duk_small_uint_t classnum; + + h = DUK_TVAL_GET_OBJECT(tv); + DUK_ASSERT(h != NULL); + classnum = DUK_HOBJECT_GET_CLASS_NUMBER(h); + stridx = DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(classnum); + + /* XXX: This is not entirely correct anymore; in ES2015 the + * default lookup should use @@toStringTag to come up with + * e.g. [object Symbol], [object Uint8Array], etc. See + * ES2015 Section 19.1.3.6. The downside of implementing that + * directly is that the @@toStringTag lookup may have side + * effects, so all call sites must be checked for that. + * Some may need a side-effect free lookup, e.g. avoiding + * getters which are not typical. + */ + break; } case DUK_TAG_BUFFER: { - stridx_bidx = (DUK_BIDX_UINT8ARRAY_PROTOTYPE << 16) + DUK_STRIDX_UINT8_ARRAY; - goto use_proto_bidx; + stridx = DUK_STRIDX_UINT8_ARRAY; + break; } #if defined(DUK_USE_FASTINT) case DUK_TAG_FASTINT: @@ -20724,142 +20222,14 @@ #endif default: { DUK_ASSERT(DUK_TVAL_IS_NUMBER(tv)); /* number (maybe fastint) */ - stridx_bidx = (DUK_BIDX_NUMBER_PROTOTYPE << 16) + DUK_STRIDX_UC_NUMBER; - goto use_proto_bidx; - } - } - DUK_ASSERT(0); /* Never here. */ - - use_proto_bidx: - DUK_ASSERT_BIDX_VALID((stridx_bidx >> 16) & 0xffffUL); - duk_push_hobject(thr, thr->builtins[(stridx_bidx >> 16) & 0xffffUL]); - /* Fall through. */ - - use_pushed_object: - /* [ ... "[object" obj ] */ - -#if defined(DUK_USE_SYMBOL_BUILTIN) - /* XXX: better handling with avoid_side_effects == 1; lookup tval - * without Proxy or getter side effects, and use it in sanitized - * form if it's a string. - */ - if (!avoid_side_effects) { - /* XXX: The problem with using the prototype object as the - * lookup base is that if @@toStringTag is a getter, its - * 'this' binding must be the ToObject() coerced input value, - * not the prototype object of the type. - */ - (void) duk_get_prop_stridx(thr, -1, DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG); - if (duk_is_string_notsymbol(thr, -1)) { - duk_remove_m2(thr); - goto finish; - } - duk_pop_unsafe(thr); - } -#endif - - if (stridx_bidx == 0xffffffffUL) { - duk_hobject *h_obj; - duk_small_uint_t classnum; - - h_obj = duk_known_hobject(thr, -1); - DUK_ASSERT(h_obj != NULL); - classnum = DUK_HOBJECT_GET_CLASS_NUMBER(h_obj); - stridx_bidx = DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(classnum); - } else { - /* stridx_bidx already has the desired fallback stridx. */ - ; - } - duk_pop_unsafe(thr); - /* Fall through. */ - - use_stridx: - /* [ ... "[object" ] */ - duk_push_hstring_stridx(thr, stridx_bidx & 0xffffUL); - - finish: - /* [ ... "[object" tag ] */ - duk_push_literal(thr, "]"); - duk_concat(thr, 3); /* [ ... "[object" tag "]" ] -> [ ... res ] */ -} -#endif /* 0 */ - -DUK_INTERNAL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv, duk_bool_t avoid_side_effects) { - duk_hobject *h_obj; - duk_small_uint_t classnum; - duk_small_uint_t stridx; - duk_tval tv_tmp; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(tv != NULL); - - /* Stabilize 'tv', duk_push_literal() may trigger side effects. */ - DUK_TVAL_SET_TVAL(&tv_tmp, tv); - tv = &tv_tmp; - - /* Conceptually for any non-undefined/null value we should do a - * ToObject() coercion and look up @@toStringTag (from the object - * prototype) to see if a custom result should be used. We'd like to - * avoid the actual conversion, but even for primitive types the - * prototype may have @@toStringTag. What's worse, the @@toStringTag - * property may be a getter that must get the object coerced value - * (not the prototype) as its 'this' binding. - * - * For now, do an actual object coercion. This could be avoided by - * doing a side effect free lookup to see if a getter would be invoked. - * If not, the value can be read directly and the object coercion could - * be avoided. This may not be worth it in practice, because - * Object.prototype.toString() is usually not performance critical. - */ - - duk_push_literal(thr, "[object "); /* -> [ ... "[object" ] */ - - switch (DUK_TVAL_GET_TAG(tv)) { - case DUK_TAG_UNUSED: /* Treat like 'undefined', shouldn't happen. */ - case DUK_TAG_UNDEFINED: { - duk_push_hstring_stridx(thr, DUK_STRIDX_UC_UNDEFINED); - goto finish; - } - case DUK_TAG_NULL: { - duk_push_hstring_stridx(thr, DUK_STRIDX_UC_NULL); - goto finish; + stridx = DUK_STRIDX_UC_NUMBER; + break; } } + h_strclass = DUK_HTHREAD_GET_STRING(thr, stridx); + DUK_ASSERT(h_strclass != NULL); - duk_push_tval(thr, tv); - tv = NULL; /* Invalidated by ToObject(). */ - duk_to_object(thr, -1); - - /* [ ... "[object" obj ] */ - -#if defined(DUK_USE_SYMBOL_BUILTIN) - /* XXX: better handling with avoid_side_effects == 1; lookup tval - * without Proxy or getter side effects, and use it in sanitized - * form if it's a string. - */ - if (!avoid_side_effects) { - (void) duk_get_prop_stridx(thr, -1, DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG); - if (duk_is_string_notsymbol(thr, -1)) { - duk_remove_m2(thr); - goto finish; - } - duk_pop_unsafe(thr); - } -#else - DUK_UNREF(avoid_side_effects); -#endif - - h_obj = duk_known_hobject(thr, -1); - DUK_ASSERT(h_obj != NULL); - classnum = DUK_HOBJECT_GET_CLASS_NUMBER(h_obj); - stridx = DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(classnum); - duk_pop_unsafe(thr); - duk_push_hstring_stridx(thr, stridx); - - finish: - /* [ ... "[object" tag ] */ - duk_push_literal(thr, "]"); - duk_concat(thr, 3); /* [ ... "[object" tag "]" ] -> [ ... res ] */ + duk_push_sprintf(thr, "[object %s]", (const char *) DUK_HSTRING_GET_DATA(h_strclass)); } /* XXX: other variants like uint, u32 etc */ @@ -20919,7 +20289,6 @@ /* coerced value is updated to value stack even when RangeError thrown */ if (clamped) { DUK_ERROR_RANGE(thr, DUK_STR_NUMBER_OUTSIDE_RANGE); - DUK_WO_NORETURN(return 0;); } } @@ -20977,14 +20346,12 @@ DUK_ASSERT(h != NULL); if (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_CANNOT_STRING_COERCE_SYMBOL); - DUK_WO_NORETURN(goto skip_replace;); } else { goto skip_replace; } #else goto skip_replace; #endif - break; } case DUK_TAG_BUFFER: /* Go through Uint8Array.prototype.toString() for coercion. */ case DUK_TAG_OBJECT: { @@ -21135,9 +20502,14 @@ } dst_data = (duk_uint8_t *) duk_push_buffer(thr, src_size, (mode == DUK_BUF_MODE_DYNAMIC) /*dynamic*/); - /* dst_data may be NULL if size is zero. */ - duk_memcpy_unsafe((void *) dst_data, (const void *) src_data, (size_t) src_size); - + if (DUK_LIKELY(src_size > 0)) { + /* When src_size == 0, src_data may be NULL (if source + * buffer is dynamic), and dst_data may be NULL (if + * target buffer is dynamic). Avoid zero-size memcpy() + * with an invalid pointer. + */ + DUK_MEMCPY((void *) dst_data, (const void *) src_data, (size_t) src_size); + } duk_replace(thr, idx); skip_copy: @@ -21253,7 +20625,6 @@ case DUK_TAG_UNDEFINED: case DUK_TAG_NULL: { DUK_ERROR_TYPE(thr, DUK_STR_NOT_OBJECT_COERCIBLE); - DUK_WO_NORETURN(return;); break; } case DUK_TAG_BOOLEAN: { @@ -21561,7 +20932,7 @@ } if (mask & DUK_TYPE_MASK_THROW) { DUK_ERROR_TYPE(thr, DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); } return 0; } @@ -22034,22 +21405,21 @@ DUK_ASSERT_API_ENTRY(thr); - /* Check stack before interning (avoid hanging temp). */ + /* check stack before interning (avoid hanging temp) */ DUK__CHECK_SPACE(); /* NULL with zero length represents an empty string; NULL with higher - * length is also now treated like an empty string although it is + * length is also now trated like an empty string although it is * a bit dubious. This is unlike duk_push_string() which pushes a * 'null' if the input string is a NULL. */ - if (DUK_UNLIKELY(str == NULL)) { - len = 0U; + if (!str) { + len = 0; } - /* Check for maximum string length. */ + /* Check for maximum string length */ if (DUK_UNLIKELY(len > DUK_HSTRING_MAX_BYTELEN)) { DUK_ERROR_RANGE(thr, DUK_STR_STRING_TOO_LONG); - DUK_WO_NORETURN(return NULL;); } h = duk_heap_strtable_intern_checked(thr, (const duk_uint8_t *) str, (duk_uint32_t) len); @@ -22073,42 +21443,6 @@ } } -#if !defined(DUK_USE_PREFER_SIZE) -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_EXTERNAL const char *duk_push_literal_raw(duk_hthread *thr, const char *str, duk_size_t len) { - duk_hstring *h; - duk_tval *tv_slot; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(str != NULL); - DUK_ASSERT(str[len] == (char) 0); - - /* Check for maximum string length. */ - if (DUK_UNLIKELY(len > DUK_HSTRING_MAX_BYTELEN)) { - DUK_ERROR_RANGE(thr, DUK_STR_STRING_TOO_LONG); - DUK_WO_NORETURN(return NULL;); - } - - h = duk_heap_strtable_intern_literal_checked(thr, (const duk_uint8_t *) str, (duk_uint32_t) len); - DUK_ASSERT(h != NULL); - - tv_slot = thr->valstack_top++; - DUK_TVAL_SET_STRING(tv_slot, h); - DUK_HSTRING_INCREF(thr, h); /* no side effects */ - - return (const char *) DUK_HSTRING_GET_DATA(h); -} -#else /* DUK_USE_LITCACHE_SIZE */ -DUK_EXTERNAL const char *duk_push_literal_raw(duk_hthread *thr, const char *str, duk_size_t len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(str != NULL); - DUK_ASSERT(str[len] == (char) 0); - - return duk_push_lstring(thr, str, len); -} -#endif /* DUK_USE_LITCACHE_SIZE */ -#endif /* !DUK_USE_PREFER_SIZE */ - DUK_EXTERNAL void duk_push_pointer(duk_hthread *thr, void *val) { duk_tval *tv_slot; @@ -22162,7 +21496,6 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_NOT_OBJECT_COERCIBLE); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_push_this(duk_hthread *thr) { @@ -22206,46 +21539,6 @@ return thr->valstack_bottom - 1; } -DUK_EXTERNAL void duk_push_new_target(duk_hthread *thr) { - duk_activation *act; - - DUK_ASSERT_API_ENTRY(thr); - - /* https://www.ecma-international.org/ecma-262/6.0/#sec-meta-properties-runtime-semantics-evaluation - * https://www.ecma-international.org/ecma-262/6.0/#sec-getnewtarget - * - * No newTarget support now, so as a first approximation - * use the resolved (non-bound) target function. - * - * Check CONSTRUCT flag from current function, or if running - * direct eval, from a non-direct-eval parent (with possibly - * more than one nested direct eval). An alternative to this - * would be to store [[NewTarget]] as a hidden symbol of the - * lexical scope, and then just look up that variable. - * - * Calls from the application will either be for an empty - * call stack, or a Duktape/C function as the top activation. - */ - - act = thr->callstack_curr; - for (;;) { - if (act == NULL) { - break; - } - - if (act->flags & DUK_ACT_FLAG_CONSTRUCT) { - duk_push_tval(thr, &act->tv_func); - return; - } else if (act->flags & DUK_ACT_FLAG_DIRECT_EVAL) { - act = act->parent; - } else { - break; - } - } - - duk_push_undefined(thr); -} - DUK_EXTERNAL void duk_push_current_function(duk_hthread *thr) { duk_activation *act; @@ -22306,7 +21599,7 @@ DUK_ASSERT_API_ENTRY(thr); if (DUK_UNLIKELY(target_thr == NULL)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return;); + return; /* not reached */ } duk_push_hobject(thr, (duk_hobject *) target_thr); duk__push_stash(thr); @@ -22382,7 +21675,6 @@ sz = sz * 2; if (DUK_UNLIKELY(sz >= DUK_PUSH_SPRINTF_SANITY_LIMIT)) { DUK_ERROR_RANGE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return NULL;); } } @@ -22571,7 +21863,6 @@ /* important to do this *after* pushing, to make the thread reachable for gc */ if (DUK_UNLIKELY(!duk_hthread_init_stacks(thr->heap, obj))) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return 0;); } /* initialize built-ins - either by copying or creating new ones */ @@ -22613,7 +21904,6 @@ DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_FUNCTION)); if (DUK_UNLIKELY(obj == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } DUK_DDD(DUK_DDDPRINT("created compiled function object with flags: 0x%08lx", (unsigned long) obj->obj.hdr.h_flags)); @@ -22645,7 +21935,6 @@ DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_FUNCTION)); if (!obj) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } tv_slot = thr->valstack_top++; @@ -22702,7 +21991,7 @@ api_error: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + return 0; /* not reached */ } DUK_EXTERNAL duk_idx_t duk_push_c_function(duk_hthread *thr, duk_c_function func, duk_int_t nargs) { @@ -22794,7 +22083,7 @@ api_error: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + return 0; /* not reached */ } #if defined(DUK_USE_BUFFEROBJECT_SUPPORT) @@ -22946,11 +22235,11 @@ range_error: DUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARGS); - DUK_WO_NORETURN(return;); + return; /* not reached */ arg_error: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_ARGS); - DUK_WO_NORETURN(return;); + return; /* not reached */ } #else /* DUK_USE_BUFFEROBJECT_SUPPORT */ DUK_EXTERNAL void duk_push_buffer_object(duk_hthread *thr, duk_idx_t idx_buffer, duk_size_t byte_offset, duk_size_t byte_length, duk_uint_t flags) { @@ -22960,7 +22249,6 @@ DUK_UNREF(byte_length); DUK_UNREF(flags); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ @@ -22998,7 +22286,7 @@ duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_MESSAGE, DUK_PROPDESC_FLAGS_WC); } else { /* If no explicit message given, put error code into message field - * (as a number). This is not fully in keeping with the ECMAScript + * (as a number). This is not fully in keeping with the Ecmascript * error model because messages are supposed to be strings (Error * constructors use ToString() on their argument). However, it's * probably more useful than having a separate 'code' property. @@ -23060,13 +22348,11 @@ /* Check for maximum buffer length. */ if (DUK_UNLIKELY(size > DUK_HBUFFER_MAX_BYTELEN)) { DUK_ERROR_RANGE(thr, DUK_STR_BUFFER_TOO_LONG); - DUK_WO_NORETURN(return NULL;); } h = duk_hbuffer_alloc(thr->heap, size, flags, &buf_data); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } tv_slot = thr->valstack_top; @@ -23088,12 +22374,11 @@ DUK_ASSERT_API_ENTRY(thr); ptr = duk_push_buffer_raw(thr, len, 0); - DUK_ASSERT(ptr != NULL); #if !defined(DUK_USE_ZERO_BUFFER_DATA) /* ES2015 requires zeroing even when DUK_USE_ZERO_BUFFER_DATA * is not set. */ - duk_memzero((void *) ptr, (size_t) len); + DUK_MEMZERO((void *) ptr, (size_t) len); #endif return ptr; } @@ -23190,14 +22475,12 @@ fail_args: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); } #else /* DUK_USE_ES6_PROXY */ DUK_EXTERNAL duk_idx_t duk_push_proxy(duk_hthread *thr, duk_uint_t proxy_flags) { DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(proxy_flags); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } #endif /* DUK_USE_ES6_PROXY */ @@ -23495,7 +22778,7 @@ if (DUK_UNLIKELY((duk_uidx_t) (thr->valstack_top - thr->valstack_bottom) < (duk_uidx_t) count)) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count >= 0); @@ -23583,7 +22866,6 @@ DUK_ASSERT(thr->valstack_top >= thr->valstack_bottom); if (DUK_UNLIKELY(thr->valstack_top == thr->valstack_bottom)) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); } duk__pop_unsafe_raw(thr); @@ -23672,7 +22954,6 @@ DUK_ASSERT(thr->valstack_top >= thr->valstack_bottom); if (DUK_UNLIKELY(thr->valstack_top - 2 < thr->valstack_bottom)) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); } duk__pop_2_unsafe_raw(thr); @@ -23730,7 +23011,7 @@ if (DUK_UNLIKELY((duk_uidx_t) count > (duk_uidx_t) top)) { /* Also handles negative count. */ DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count >= 0); @@ -23747,8 +23028,9 @@ /* Copy value stack values directly to the array part without * any refcount updates: net refcount changes are zero. */ + tv_src = thr->valstack_top - count - 1; - duk_memcpy_unsafe((void *) tv_dst, (const void *) tv_src, (size_t) count * sizeof(duk_tval)); + DUK_MEMCPY((void *) tv_dst, (const void *) tv_src, (size_t) count * sizeof(duk_tval)); /* Overwrite result array to final value stack location and wipe * the rest; no refcount operations needed. @@ -23866,11 +23148,11 @@ } DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + return 0; fail_over_2g: DUK_ERROR_RANGE_INVALID_LENGTH(thr); - DUK_WO_NORETURN(return 0;); + return 0; } /* @@ -23887,7 +23169,6 @@ if (DUK_UNLIKELY(thr->valstack_top == thr->valstack_bottom)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return;); } /* Errors are augmented when they are created, not when they are @@ -23951,7 +23232,6 @@ duk_push_error_object_va_raw(thr, err_code, filename, line, fmt, ap); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_error_raw(duk_hthread *thr, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...) { @@ -23963,7 +23243,6 @@ duk_push_error_object_va_raw(thr, err_code, filename, line, fmt, ap); va_end(ap); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } #if !defined(DUK_USE_VARIADIC_MACROS) @@ -23982,7 +23261,6 @@ duk_push_error_object_va_raw(thr, err_code, filename, line, fmt, ap); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } #define DUK__ERROR_STASH_SHARED(code) do { \ @@ -23990,7 +23268,7 @@ va_start(ap, fmt); \ duk__throw_error_from_stash(thr, (code), fmt, ap); \ va_end(ap); \ - DUK_WO_NORETURN(return 0;); \ + /* Never reached; if return 0 here, gcc/clang will complain. */ \ } while (0) DUK_EXTERNAL duk_ret_t duk_error_stash(duk_hthread *thr, duk_errcode_t err_code, const char *fmt, ...) { @@ -24120,7 +23398,7 @@ DUK_ASSERT_API_ENTRY(thr); - duk_push_literal(thr, "light_"); + duk_push_sprintf(thr, "light_"); duk_push_string_funcptr(thr, (duk_uint8_t *) &func, sizeof(func)); duk_push_sprintf(thr, "_%04x", (unsigned int) lf_flags); duk_concat(thr, 3); @@ -24145,9 +23423,9 @@ DUK_ASSERT(DUK_TVAL_IS_LIGHTFUNC(tv)); DUK_TVAL_GET_LIGHTFUNC(tv, func, lf_flags); /* read before 'tv' potentially invalidated */ - duk_push_literal(thr, "function "); + duk_push_string(thr, "function "); duk_push_lightfunc_name_raw(thr, func, lf_flags); - duk_push_literal(thr, "() { [lightfunc code] }"); + duk_push_string(thr, "() { [lightfunc code] }"); duk_concat(thr, 3); } @@ -24259,7 +23537,7 @@ /* 'tv' may be NULL */ if (tv == NULL) { - duk_push_literal(thr, "none"); + duk_push_string(thr, "none"); } else { switch (DUK_TVAL_GET_TAG(tv)) { case DUK_TAG_STRING: { @@ -24268,11 +23546,11 @@ /* XXX: string summary produces question marks * so this is not very ideal. */ - duk_push_literal(thr, "[Symbol "); + duk_push_string(thr, "[Symbol "); duk_push_string(thr, duk__get_symbol_type_string(h)); - duk_push_literal(thr, " "); + duk_push_string(thr, " "); duk__push_hstring_readable_unicode(thr, h, DUK__READABLE_STRING_MAXCHARS); - duk_push_literal(thr, "]"); + duk_push_string(thr, "]"); duk_concat(thr, 5); break; } @@ -24302,7 +23580,7 @@ break; } } - duk_push_class_string_tval(thr, tv, 1 /*avoid_side_effects*/); + duk_push_class_string_tval(thr, tv); break; } case DUK_TAG_BUFFER: { @@ -24357,7 +23635,7 @@ DUK_ASSERT_API_ENTRY(thr); /* .toString() */ - duk_push_literal(thr, "Symbol("); + duk_push_string(thr, "Symbol("); p = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h); p_end = p + DUK_HSTRING_GET_BYTELEN(h); DUK_ASSERT(p[0] == 0xff || (p[0] & 0xc0) == 0x80); @@ -24373,7 +23651,7 @@ } } duk_push_lstring(thr, (const char *) p, (duk_size_t) (q - p)); - duk_push_literal(thr, ")"); + duk_push_string(thr, ")"); duk_concat(thr, 3); } @@ -24409,8 +23687,7 @@ DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(thr); DUK_ASSERT(count * sizeof(duk_tval) >= count); /* no wrap */ - - duk_memcpy_unsafe((void *) tv_dst, (const void *) tv_src, count * sizeof(duk_tval)); + DUK_MEMCPY((void *) tv_dst, (const void *) tv_src, count * sizeof(duk_tval)); tv = tv_dst; while (count-- > 0) { @@ -24447,7 +23724,7 @@ if (DUK_UNLIKELY(count_in <= 0)) { if (count_in < 0) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count_in == 0); duk_push_hstring_empty(thr); @@ -24503,11 +23780,11 @@ for (i = count; i >= 1; i--) { if (is_join && i != count) { h = duk_require_hstring(thr, -((duk_idx_t) count) - 2); /* extra -1 for buffer */ - duk_memcpy(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); + DUK_MEMCPY(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); idx += DUK_HSTRING_GET_BYTELEN(h); } h = duk_require_hstring(thr, -((duk_idx_t) i) - 1); /* extra -1 for buffer */ - duk_memcpy(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); + DUK_MEMCPY(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); idx += DUK_HSTRING_GET_BYTELEN(h); } @@ -24534,7 +23811,6 @@ error_overflow: DUK_ERROR_RANGE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_concat(duk_hthread *thr, duk_idx_t count) { @@ -24572,8 +23848,8 @@ buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, len); DUK_ASSERT(buf != NULL); - duk_memcpy((void *) buf, (const void *) DUK_HSTRING_GET_DATA(h1), (size_t) len1); - duk_memcpy((void *) (buf + len1), (const void *) DUK_HSTRING_GET_DATA(h2), (size_t) len2); + DUK_MEMCPY((void *) buf, (const void *) DUK_HSTRING_GET_DATA(h1), (size_t) len1); + DUK_MEMCPY((void *) (buf + len1), (const void *) DUK_HSTRING_GET_DATA(h2), (size_t) len2); (void) duk_buffer_to_string(thr, -1); /* Safe if inputs are safe. */ /* [ ... str1 str2 buf ] */ @@ -24584,7 +23860,6 @@ error_overflow: DUK_ERROR_RANGE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_PREFER_SIZE */ @@ -24814,7 +24089,7 @@ /* #include duk_internal.h -> already included */ DUK_INTERNAL duk_double_t duk_time_get_ecmascript_time(duk_hthread *thr) { - /* ECMAScript time, with millisecond fractions. Exposed via + /* Ecmascript time, with millisecond fractions. Exposed via * duk_get_now() for example. */ DUK_UNREF(thr); @@ -24822,7 +24097,7 @@ } DUK_INTERNAL duk_double_t duk_time_get_ecmascript_time_nofrac(duk_hthread *thr) { - /* ECMAScript time without millisecond fractions. Exposed via + /* Ecmascript time without millisecond fractions. Exposed via * the Date built-in which doesn't allow fractions. */ DUK_UNREF(thr); @@ -24865,7 +24140,7 @@ DUK_UNREF(thr); /* Convert as one-based, but change month to zero-based to match the - * ECMAScript Date built-in behavior 1:1. + * Ecmascript Date built-in behavior 1:1. */ flags = DUK_DATE_FLAG_ONEBASED | DUK_DATE_FLAG_NAN_TO_ZERO; @@ -24921,9 +24196,9 @@ /* * Array built-ins * - * Most Array built-ins are intentionally generic in ECMAScript, and are + * Most Array built-ins are intentionally generic in Ecmascript, and are * intended to work even when the 'this' binding is not an Array instance. - * This ECMAScript feature is also used by much real world code. For this + * This Ecmascript feature is also used by much real world code. For this * reason the implementations here don't assume exotic Array behavior or * e.g. presence of a .length property. However, some algorithms have a * fast path for duk_harray backed actual Array instances, enabled when @@ -24997,7 +24272,6 @@ duk_uint32_t ret = duk__push_this_obj_len_u32(thr); if (DUK_UNLIKELY(ret >= 0x80000000UL)) { DUK_ERROR_RANGE_INVALID_LENGTH(thr); - DUK_WO_NORETURN(return 0U;); } return ret; } @@ -25150,17 +24424,11 @@ DUK_INTERNAL duk_ret_t duk_bi_array_prototype_concat(duk_hthread *thr) { duk_idx_t i, n; - duk_uint32_t j, idx, len; + duk_uarridx_t idx, idx_last; + duk_uarridx_t j, len; duk_hobject *h; - duk_size_t tmp_len; - - /* XXX: In ES2015 Array .length can be up to 2^53-1. The current - * implementation is limited to 2^32-1. - */ - - /* XXX: Fast path for array 'this' and array element. */ - /* XXX: The insert here is a bit expensive if there are a lot of items. + /* XXX: the insert here is a bit expensive if there are a lot of items. * It could also be special cased in the outermost for loop quite easily * (as the element is dup()'d anyway). */ @@ -25178,97 +24446,59 @@ */ idx = 0; + idx_last = 0; for (i = 0; i < n; i++) { - duk_bool_t spreadable; - duk_bool_t need_has_check; - DUK_ASSERT_TOP(thr, n + 1); /* [ ToObject(this) item1 ... itemN arr ] */ - h = duk_get_hobject(thr, i); - - if (h == NULL) { - spreadable = 0; - } else { -#if defined(DUK_USE_SYMBOL_BUILTIN) - duk_get_prop_stridx(thr, i, DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE); - if (duk_is_undefined(thr, -1)) { - spreadable = (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY); - } else { - spreadable = duk_to_boolean(thr, -1); - } - duk_pop_nodecref_unsafe(thr); -#else - spreadable = (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY); -#endif - } - - if (!spreadable) { - duk_dup(thr, i); - duk_xdef_prop_index_wec(thr, -2, idx); - idx++; - if (DUK_UNLIKELY(idx == 0U)) { - /* Index after update is 0, and index written - * was 0xffffffffUL which is no longer a valid - * array index. - */ - goto fail_wrap; - } + duk_dup(thr, i); + h = duk_get_hobject_with_class(thr, -1, DUK_HOBJECT_CLASS_ARRAY); + if (!h) { + duk_xdef_prop_index_wec(thr, -2, idx++); + idx_last = idx; continue; } - DUK_ASSERT(duk_is_object(thr, i)); - need_has_check = (DUK_HOBJECT_IS_PROXY(h) != 0); /* Always 0 w/o Proxy support. */ + /* [ ToObject(this) item1 ... itemN arr item(i) ] */ - /* [ ToObject(this) item1 ... itemN arr ] */ - - tmp_len = duk_get_length(thr, i); - len = (duk_uint32_t) tmp_len; - if (DUK_UNLIKELY(tmp_len != (duk_size_t) len)) { - goto fail_wrap; - } - if (DUK_UNLIKELY(idx + len < idx)) { - /* Result length must be at most 0xffffffffUL to be - * a valid 32-bit array index. - */ - goto fail_wrap; - } + /* XXX: an array can have length higher than 32 bits; this is not handled + * correctly now. + */ + len = (duk_uarridx_t) duk_get_length(thr, -1); for (j = 0; j < len; j++) { - /* For a Proxy element, an explicit 'has' check is - * needed to allow the Proxy to present gaps. - */ - if (need_has_check) { - if (duk_has_prop_index(thr, i, j)) { - duk_get_prop_index(thr, i, j); - duk_xdef_prop_index_wec(thr, -2, idx); - } + if (duk_get_prop_index(thr, -1, j)) { + /* [ ToObject(this) item1 ... itemN arr item(i) item(i)[j] ] */ + duk_xdef_prop_index_wec(thr, -3, idx++); + idx_last = idx; } else { - if (duk_get_prop_index(thr, i, j)) { - duk_xdef_prop_index_wec(thr, -2, idx); - } else { - duk_pop_undefined(thr); - } + idx++; + duk_pop_undefined(thr); +#if defined(DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER) + /* According to E5.1 Section 15.4.4.4 nonexistent trailing + * elements do not affect 'length' of the result. Test262 + * and other engines disagree, so update idx_last here too. + */ + idx_last = idx; +#else + /* Strict standard behavior, ignore trailing elements for + * result 'length'. + */ +#endif } - idx++; - DUK_ASSERT(idx != 0U); /* Wrap check above. */ } + duk_pop_unsafe(thr); } - /* ES5.1 has a specification "bug" in that nonexistent trailing - * elements don't affect the result .length. Test262 and other - * engines disagree, and the specification bug was fixed in ES2015 - * (see NOTE 1 in https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.concat). + /* The E5.1 Section 15.4.4.4 algorithm doesn't set the length explicitly + * in the end, but because we're operating with an internal value which + * is known to be an array, this should be equivalent. */ - duk_push_uarridx(thr, idx); + duk_push_uarridx(thr, idx_last); duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_W); DUK_ASSERT_TOP(thr, n + 1); return 1; - - fail_wrap: - DUK_ERROR_RANGE_INVALID_LENGTH(thr); - DUK_WO_NORETURN(return 0;); } /* @@ -26390,12 +25620,20 @@ DUK_ASSERT_TOP(thr, 5); if (!duk_get_prop_index(thr, 2, (duk_uarridx_t) i)) { - /* For 'map' trailing missing elements don't invoke the - * callback but count towards the result length. +#if defined(DUK_USE_NONSTD_ARRAY_MAP_TRAILER) + /* Real world behavior for map(): trailing non-existent + * elements don't invoke the user callback, but are still + * counted towards result 'length'. */ if (iter_type == DUK__ITER_MAP) { res_length = i + 1; } +#else + /* Standard behavior for map(): trailing non-existent + * elements don't invoke the user callback and are not + * counted towards result 'length'. + */ +#endif duk_pop_undefined(thr); continue; } @@ -26822,7 +26060,6 @@ if (flags & DUK__BUFOBJ_FLAG_THROW) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } return NULL; } @@ -26864,7 +26101,7 @@ } DUK_ERROR_TYPE(thr, DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); + return NULL; /* not reachable */ } DUK_LOCAL void duk__set_bufobj_buffer(duk_hthread *thr, duk_hbufobj *h_bufobj, duk_hbuffer *h_val) { @@ -26939,7 +26176,6 @@ fail_range: DUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARGS); - DUK_WO_NORETURN(return;); } /* Shared lenient buffer length clamping helper. No negative indices, no @@ -27090,8 +26326,7 @@ DUK_INTERNAL void duk_hbufobj_push_validated_read(duk_hthread *thr, duk_hbufobj *h_bufobj, duk_uint8_t *p, duk_small_uint_t elem_size) { duk_double_union du; - DUK_ASSERT(elem_size > 0); - duk_memcpy((void *) du.uc, (const void *) p, (size_t) elem_size); + DUK_MEMCPY((void *) du.uc, (const void *) p, (size_t) elem_size); switch (h_bufobj->elem_type) { case DUK_HBUFOBJ_ELEM_UINT8: @@ -27159,11 +26394,7 @@ du.ui[0] = (duk_uint32_t) duk_to_int32(thr, -1); break; case DUK_HBUFOBJ_ELEM_FLOAT32: - /* A double-to-float cast is undefined behavior in C99 if - * the cast is out-of-range, so use a helper. Example: - * runtime error: value -1e+100 is outside the range of representable values of type 'float' - */ - du.f[0] = duk_double_to_float_t(duk_to_number_m1(thr)); + du.f[0] = (duk_float_t) duk_to_number_m1(thr); break; case DUK_HBUFOBJ_ELEM_FLOAT64: du.d = (duk_double_t) duk_to_number_m1(thr); @@ -27172,8 +26403,7 @@ DUK_UNREACHABLE(); } - DUK_ASSERT(elem_size > 0); - duk_memcpy((void *) p, (const void *) du.uc, (size_t) elem_size); + DUK_MEMCPY((void *) p, (const void *) du.uc, (size_t) elem_size); } /* Helper to create a fixed buffer from argument value at index 0. @@ -27209,14 +26439,12 @@ h_bufobj = (duk_hbufobj *) h; if (DUK_UNLIKELY(h_bufobj->buf == NULL)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } if (DUK_UNLIKELY(h_bufobj->offset != 0 || h_bufobj->length != DUK_HBUFFER_GET_SIZE(h_bufobj->buf))) { /* No support for ArrayBuffers with slice * offset/length. */ DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } duk_push_hbuffer(thr, h_bufobj->buf); return h_bufobj->buf; @@ -27232,7 +26460,6 @@ } default: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } done: @@ -27274,7 +26501,7 @@ duk_push_buffer_object(thr, -1, 0, - DUK_HBUFFER_FIXED_GET_SIZE((duk_hbuffer_fixed *) (void *) h_buf), + DUK_HBUFFER_FIXED_GET_SIZE((duk_hbuffer_fixed *) h_buf), DUK_BUFOBJ_UINT8ARRAY); duk_push_hobject_bidx(thr, DUK_BIDX_NODEJS_BUFFER_PROTOTYPE); duk_set_prototype(thr, -2); @@ -27602,7 +26829,7 @@ DUK_DDD(DUK_DDDPRINT("using memcpy: p_src=%p, p_dst=%p, byte_length=%ld", (void *) p_src, (void *) p_dst, (long) byte_length)); - duk_memcpy_unsafe((void *) p_dst, (const void *) p_src, (size_t) byte_length); + DUK_MEMCPY((void *) p_dst, (const void *) p_src, (size_t) byte_length); break; } case 1: { @@ -27838,7 +27065,7 @@ h_this = duk__get_bufobj_this(thr); if (h_this == NULL) { /* XXX: happens e.g. when evaluating: String(Buffer.prototype). */ - duk_push_literal(thr, "[object Object]"); + duk_push_string(thr, "[object Object]"); return 1; } DUK_ASSERT_HBUFOBJ_VALID(h_this); @@ -27869,9 +27096,9 @@ */ DUK_ASSERT(DUK_HBUFOBJ_VALID_BYTEOFFSET_EXCL(h_this, (duk_size_t) start_offset + slice_length)); - duk_memcpy_unsafe((void *) buf_slice, - (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), - (size_t) slice_length); + DUK_MEMCPY((void *) buf_slice, + (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), + (size_t) slice_length); /* Use the equivalent of: new TextEncoder().encode(this) to convert the * string. Result will be valid UTF-8; non-CESU-8 inputs are currently @@ -28033,7 +27260,7 @@ /* Handle single character fills as memset() even when * the fill data comes from a one-char argument. */ - duk_memset_unsafe((void *) p, (int) fill_str_ptr[0], (size_t) fill_length); + DUK_MEMSET((void *) p, (int) fill_str_ptr[0], (size_t) fill_length); } else if (fill_str_len > 1) { duk_size_t i, n, t; @@ -28084,9 +27311,9 @@ if (DUK_HBUFOBJ_VALID_SLICE(h_this)) { /* Cannot overlap. */ - duk_memcpy_unsafe((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + offset), - (const void *) str_data, - (size_t) length); + DUK_MEMCPY((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + offset), + (const void *) str_data, + (size_t) length); } else { DUK_DDD(DUK_DDDPRINT("write() target buffer is not covered, silent ignore")); } @@ -28182,9 +27409,9 @@ /* Must use memmove() because copy area may overlap (source and target * buffer may be the same, or from different slices. */ - duk_memmove_unsafe((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufarg) + target_ustart), - (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + source_ustart), - (size_t) copy_size); + DUK_MEMMOVE((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufarg) + target_ustart), + (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + source_ustart), + (size_t) copy_size); } else { DUK_DDD(DUK_DDDPRINT("buffer copy not covered by underlying buffer(s), ignoring")); } @@ -28370,7 +27597,7 @@ DUK_ASSERT(src_length == dst_length); DUK_DDD(DUK_DDDPRINT("fast path: able to use memmove() because views are compatible")); - duk_memmove_unsafe((void *) p_dst_base, (const void *) p_src_base, (size_t) dst_length); + DUK_MEMMOVE((void *) p_dst_base, (const void *) p_src_base, (size_t) dst_length); return 0; } DUK_DDD(DUK_DDDPRINT("fast path: views are not compatible with a byte copy, copy by item")); @@ -28413,7 +27640,7 @@ DUK_DDD(DUK_DDDPRINT("there is overlap, make a copy of the source")); p_src_copy = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, src_length); DUK_ASSERT(p_src_copy != NULL); - duk_memcpy_unsafe((void *) p_src_copy, (const void *) p_src_base, (size_t) src_length); + DUK_MEMCPY((void *) p_src_copy, (const void *) p_src_base, (size_t) src_length); p_src_base = p_src_copy; /* use p_src_base from now on */ } @@ -28540,9 +27767,9 @@ DUK_ASSERT(p_copy != NULL); copy_length = slice_length; - duk_memcpy_unsafe((void *) p_copy, - (const void *) ((duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_val) + start_offset), - copy_length); + DUK_MEMCPY((void *) p_copy, + (const void *) ((duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_val) + start_offset), + copy_length); } #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ @@ -28664,9 +27891,9 @@ * is left as zero. */ copy_length = DUK_HBUFOBJ_CLAMP_BYTELENGTH(h_this, slice_length); - duk_memcpy_unsafe((void *) p_copy, - (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), - copy_length); + DUK_MEMCPY((void *) p_copy, + (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), + copy_length); h_val = duk_known_hbuffer(thr, -1); @@ -28858,9 +28085,9 @@ if (h_bufobj->buf != NULL && DUK_HBUFOBJ_VALID_SLICE(h_bufobj)) { - duk_memcpy_unsafe((void *) p, - (const void *) DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufobj), - copy_size); + DUK_MEMCPY((void *) p, + (const void *) DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufobj), + copy_size); } else { /* Just skip, leaving zeroes in the result. */ ; @@ -29010,7 +28237,7 @@ if (offset + 2U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 2); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 2); tmp = du.us[0]; if (endswap) { tmp = DUK_BSWAP16(tmp); @@ -29027,7 +28254,7 @@ if (offset + 4U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 4); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 4); tmp = du.ui[0]; if (endswap) { tmp = DUK_BSWAP32(tmp); @@ -29044,7 +28271,7 @@ if (offset + 4U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 4); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 4); if (endswap) { tmp = du.ui[0]; tmp = DUK_BSWAP32(tmp); @@ -29057,7 +28284,7 @@ if (offset + 8U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 8); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 8); if (endswap) { DUK_DBLUNION_BSWAP64(&du); } @@ -29114,12 +28341,9 @@ } while (i != i_end); if (magic_signed) { - /* Shift to sign extend. Left shift must be unsigned - * to avoid undefined behavior; right shift must be - * signed to sign extend properly. - */ + /* Shift to sign extend. */ shift_tmp = (duk_small_uint_t) (64U - (duk_small_uint_t) field_bytelen * 8U); - tmp = (duk_int64_t) ((duk_uint64_t) tmp << shift_tmp) >> shift_tmp; + tmp = (tmp << shift_tmp) >> shift_tmp; } duk_push_i64(thr, tmp); @@ -29295,7 +28519,7 @@ } du.us[0] = tmp; /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 2); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 2); break; } case DUK__FLD_32BIT: { @@ -29309,7 +28533,7 @@ } du.ui[0] = tmp; /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 4); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 4); break; } case DUK__FLD_FLOAT: { @@ -29324,7 +28548,7 @@ du.ui[0] = tmp; } /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 4); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 4); break; } case DUK__FLD_DOUBLE: { @@ -29336,7 +28560,7 @@ DUK_DBLUNION_BSWAP64(&du); } /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 8); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 8); break; } case DUK__FLD_VARINT: { @@ -29783,7 +29007,7 @@ duk_small_uint_t i; /* During parsing, month and day are one-based; set defaults here. */ - duk_memzero(parts, sizeof(parts)); + DUK_MEMZERO(parts, sizeof(parts)); DUK_ASSERT(parts[DUK_DATE_IDX_YEAR] == 0); /* don't care value, year is mandatory */ parts[DUK_DATE_IDX_MONTH] = 1; parts[DUK_DATE_IDX_DAY] = 1; @@ -30010,13 +29234,13 @@ }; /* Maximum iteration count for computing UTC-to-local time offset when - * creating an ECMAScript time value from local parts. + * creating an Ecmascript time value from local parts. */ #define DUK__LOCAL_TZOFFSET_MAXITER 4 /* Because 'day since epoch' can be negative and is used to compute weekday * using a modulo operation, add this multiple of 7 to avoid negative values - * when year is below 1970 epoch. ECMAScript time values are restricted to + * when year is below 1970 epoch. Ecmascript time values are restricted to * +/- 100 million days from epoch, so this adder fits nicely into 32 bits. * Round to a multiple of 7 (= floor(100000000 / 7) * 7) and add margin. */ @@ -30207,10 +29431,10 @@ d = DUK_FLOOR(d); /* remove fractions if present */ DUK_ASSERT(DUK_FLOOR(d) == d); - /* The timevalue must be in valid ECMAScript range, but since a local + /* The timevalue must be in valid Ecmascript range, but since a local * time offset can be applied, we need to allow a +/- 24h leeway to * the value. In other words, although the UTC time is within the - * ECMAScript range, the local part values can be just outside of it. + * Ecmascript range, the local part values can be just outside of it. */ DUK_UNREF(duk_bi_date_timeval_in_leeway_range); DUK_ASSERT(duk_bi_date_timeval_in_leeway_range(d)); @@ -30253,7 +29477,7 @@ (long) parts[DUK_DATE_IDX_MILLISECOND])); /* This assert depends on the input parts representing time inside - * the ECMAScript range. + * the Ecmascript range. */ DUK_ASSERT(t2 + DUK__WEEKDAY_MOD_ADDER >= 0); parts[DUK_DATE_IDX_WEEKDAY] = (t2 + 4 + DUK__WEEKDAY_MOD_ADDER) % 7; /* E5.1 Section 15.9.1.6 */ @@ -30373,7 +29597,7 @@ * computation happens with intermediate results coerced to * double values (instead of using something more accurate). * E.g. E5.1 Section 15.9.1.11 requires use of IEEE 754 - * rules (= ECMAScript '+' and '*' operators). + * rules (= Ecmascript '+' and '*' operators). * * Without 'volatile' even this approach fails on some platform * and compiler combinations. For instance, gcc 4.8.1 on Ubuntu @@ -30480,7 +29704,6 @@ h = duk_get_hobject(thr, -1); /* XXX: getter with class check, useful in built-ins */ if (h == NULL || DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_DATE) { DUK_ERROR_TYPE(thr, "expected Date"); - DUK_WO_NORETURN(return 0.0;); } duk_get_prop_stridx_short(thr, -1, DUK_STRIDX_INT_VALUE); @@ -30493,7 +29716,6 @@ } if (flags & DUK_DATE_FLAG_NAN_TO_RANGE_ERROR) { DUK_ERROR_RANGE(thr, "Invalid Date"); - DUK_WO_NORETURN(return 0.0;); } } /* if no NaN handling flag, may still be NaN here, but not Inf */ @@ -31110,7 +30332,7 @@ * Notes: * * - Date.prototype.toGMTString() and Date.prototype.toUTCString() are - * required to be the same ECMAScript function object (!), so it is + * required to be the same Ecmascript function object (!), so it is * omitted from here. * * - Date.prototype.toUTCString(): E5.1 specification does not require a @@ -31306,41 +30528,6 @@ return 1; } -/* - * Misc. - */ - -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL duk_ret_t duk_bi_date_prototype_toprimitive(duk_hthread *thr) { - duk_size_t hintlen; - const char *hintstr; - duk_int_t hint; - - /* Invokes OrdinaryToPrimitive() with suitable hint. Note that the - * method is generic, and works on non-Date arguments too. - * - * https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype-@@toprimitive - */ - - duk_push_this(thr); - duk_require_object(thr, -1); - DUK_ASSERT_TOP(thr, 2); - - hintstr = duk_require_lstring(thr, 0, &hintlen); - if ((hintlen == 6 && DUK_STRCMP(hintstr, "string") == 0) || - (hintlen == 7 && DUK_STRCMP(hintstr, "default") == 0)) { - hint = DUK_HINT_STRING; - } else if (hintlen == 6 && DUK_STRCMP(hintstr, "number") == 0) { - hint = DUK_HINT_NUMBER; - } else { - DUK_DCERROR_TYPE_INVALID_ARGS(thr); - } - - duk_to_primitive_ordinary(thr, -1, hint); - return 1; -} -#endif /* DUK_USE_SYMBOL_BUILTIN */ - #endif /* DUK_USE_DATE_BUILTIN */ /* automatic undefs */ @@ -31409,7 +30596,7 @@ #define DUK__STRFTIME_BUF_SIZE 64 #if defined(DUK_USE_DATE_NOW_GETTIMEOFDAY) -/* Get current ECMAScript time (= UNIX/Posix time, but in milliseconds). */ +/* Get current Ecmascript time (= UNIX/Posix time, but in milliseconds). */ DUK_INTERNAL duk_double_t duk_bi_date_get_now_gettimeofday(void) { struct timeval tv; duk_double_t d; @@ -31457,7 +30644,7 @@ return 0; } - /* If not within ECMAScript range, some integer time calculations + /* If not within Ecmascript range, some integer time calculations * won't work correctly (and some asserts will fail), so bail out * if so. This fixes test-bug-date-insane-setyear.js. There is * a +/- 24h leeway in this range check to avoid a test262 corner @@ -31508,10 +30695,10 @@ * Since we rely on the platform APIs for conversions between local * time and UTC, we can't guarantee the above. Rather, if the platform * has historical DST rules they will be applied. This seems to be the - * general preferred direction in ECMAScript standardization (or at least + * general preferred direction in Ecmascript standardization (or at least * implementations) anyway, and even the equivalent year mapping should * be disabled if the platform is known to handle DST properly for the - * full ECMAScript range. + * full Ecmascript range. * * The following has useful discussion and links: * @@ -31526,7 +30713,7 @@ t = (time_t) (d / 1000.0); DUK_DDD(DUK_DDDPRINT("timeval: %lf -> time_t %ld", (double) d, (long) t)); - duk_memzero((void *) tms, sizeof(struct tm) * 2); + DUK_MEMZERO((void *) tms, sizeof(struct tm) * 2); #if defined(DUK_USE_DATE_TZO_GMTIME_R) (void) gmtime_r(&t, &tms[0]); @@ -31536,9 +30723,9 @@ (void) localtime_s(&t, &tms[1]); #elif defined(DUK_USE_DATE_TZO_GMTIME) tm_ptr = gmtime(&t); - duk_memcpy((void *) &tms[0], tm_ptr, sizeof(struct tm)); + DUK_MEMCPY((void *) &tms[0], tm_ptr, sizeof(struct tm)); tm_ptr = localtime(&t); - duk_memcpy((void *) &tms[1], tm_ptr, sizeof(struct tm)); + DUK_MEMCPY((void *) &tms[1], tm_ptr, sizeof(struct tm)); #else #error internal error #endif @@ -31599,13 +30786,13 @@ /* Copy to buffer with slack to avoid Valgrind gripes from strptime. */ DUK_ASSERT(str != NULL); - duk_memzero(buf, sizeof(buf)); /* valgrind whine without this */ + DUK_MEMZERO(buf, sizeof(buf)); /* valgrind whine without this */ DUK_SNPRINTF(buf, sizeof(buf), "%s", (const char *) str); buf[sizeof(buf) - 1] = (char) 0; DUK_DDD(DUK_DDDPRINT("parsing: '%s'", (const char *) buf)); - duk_memzero(&tm, sizeof(tm)); + DUK_MEMZERO(&tm, sizeof(tm)); if (strptime((const char *) buf, "%c", &tm) != NULL) { DUK_DDD(DUK_DDDPRINT("before mktime: tm={sec:%ld,min:%ld,hour:%ld,mday:%ld,mon:%ld,year:%ld," "wday:%ld,yday:%ld,isdst:%ld}", @@ -31636,7 +30823,7 @@ * convenient for an embeddable interpreter. */ - duk_memzero(&tm, sizeof(struct tm)); + DUK_MEMZERO(&tm, sizeof(struct tm)); rc = (duk_small_int_t) getdate_r(str, &tm); DUK_DDD(DUK_DDDPRINT("getdate_r() -> %ld", (long) rc)); @@ -31661,16 +30848,16 @@ DUK_UNREF(tzoffset); - /* If the platform doesn't support the entire ECMAScript range, we need + /* If the platform doesn't support the entire Ecmascript range, we need * to return 0 so that the caller can fall back to the default formatter. * - * For now, assume that if time_t is 8 bytes or more, the whole ECMAScript + * For now, assume that if time_t is 8 bytes or more, the whole Ecmascript * range is supported. For smaller time_t values (4 bytes in practice), * assumes that the signed 32-bit range is supported. * * XXX: detect this more correctly per platform. The size of time_t is * probably not an accurate guarantee of strftime() supporting or not - * supporting a large time range (the full ECMAScript range). + * supporting a large time range (the full Ecmascript range). */ if (sizeof(time_t) < 8 && (parts[DUK_DATE_IDX_YEAR] < 1970 || parts[DUK_DATE_IDX_YEAR] > 2037)) { @@ -31678,7 +30865,7 @@ return 0; } - duk_memzero(&tm, sizeof(tm)); + DUK_MEMZERO(&tm, sizeof(tm)); tm.tm_sec = parts[DUK_DATE_IDX_SECOND]; tm.tm_min = parts[DUK_DATE_IDX_MINUTE]; tm.tm_hour = parts[DUK_DATE_IDX_HOUR]; @@ -31688,7 +30875,7 @@ tm.tm_wday = parts[DUK_DATE_IDX_WEEKDAY]; tm.tm_isdst = 0; - duk_memzero(buf, sizeof(buf)); + DUK_MEMZERO(buf, sizeof(buf)); if ((flags & DUK_DATE_FLAG_TOSTRING_DATE) && (flags & DUK_DATE_FLAG_TOSTRING_TIME)) { fmt = "%c"; } else if (flags & DUK_DATE_FLAG_TOSTRING_DATE) { @@ -31747,15 +30934,13 @@ } } -#if defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS) DUK_LOCAL void duk__convert_filetime_to_ularge(const FILETIME *ft, ULARGE_INTEGER *res) { res->LowPart = ft->dwLowDateTime; res->HighPart = ft->dwHighDateTime; } -#endif /* DUK_USE_DATE_NOW_WINDOWS_SUBMS */ DUK_LOCAL void duk__set_systime_jan1970(SYSTEMTIME *st) { - duk_memzero((void *) st, sizeof(*st)); + DUK_MEMZERO((void *) st, sizeof(*st)); st->wYear = 1970; st->wMonth = 1; st->wDayOfWeek = 4; /* not sure whether or not needed; Thursday */ @@ -31820,11 +31005,10 @@ ULARGE_INTEGER tmp2; ULARGE_INTEGER tmp3; FILETIME ft1; - BOOL ret; /* XXX: handling of timestamps outside Windows supported range. * How does Windows deal with dates before 1600? Does windows - * support all ECMAScript years (like -200000 and +200000)? + * support all Ecmascript years (like -200000 and +200000)? * Should equivalent year mapping be used here too? If so, use * a shared helper (currently integrated into timeval-to-parts). */ @@ -31840,11 +31024,7 @@ ft1.dwLowDateTime = tmp2.LowPart; ft1.dwHighDateTime = tmp2.HighPart; - ret = FileTimeToSystemTime((const FILETIME *) &ft1, &st2); - if (!ret) { - DUK_D(DUK_DPRINT("FileTimeToSystemTime() failed, return tzoffset 0")); - return 0; - } + FileTimeToSystemTime((const FILETIME *) &ft1, &st2); if (SystemTimeToTzSpecificLocalTime((LPTIME_ZONE_INFORMATION) NULL, &st2, &st3) == 0) { DUK_D(DUK_DPRINT("SystemTimeToTzSpecificLocalTime() failed, return tzoffset 0")); return 0; @@ -31864,7 +31044,6 @@ FILETIME ft2; ULARGE_INTEGER tmp1; ULARGE_INTEGER tmp2; - BOOL ret; /* Do a similar computation to duk_bi_date_get_local_tzoffset_windows * but without accounting for daylight savings time. Use this on @@ -31880,17 +31059,9 @@ ft1.dwLowDateTime = tmp1.LowPart; ft1.dwHighDateTime = tmp1.HighPart; - ret = FileTimeToLocalFileTime((const FILETIME *) &ft1, &ft2); - if (!ret) { - DUK_D(DUK_DPRINT("FileTimeToLocalFileTime() failed, return tzoffset 0")); - return 0; - } + FileTimeToLocalFileTime((const FILETIME *) &ft1, &ft2); - ret = FileTimeToSystemTime((const FILETIME *) &ft2, &st2); - if (!ret) { - DUK_D(DUK_DPRINT("FileTimeToSystemTime() failed, return tzoffset 0")); - return 0; - } + FileTimeToSystemTime((const FILETIME *) &ft2, &st2); duk__convert_systime_to_ularge((const SYSTEMTIME *) &st2, &tmp2); return (duk_int_t) (((LONGLONG) tmp2.QuadPart - (LONGLONG) tmp1.QuadPart) / DUK_I64_CONSTANT(10000000)); /* seconds */ @@ -31927,7 +31098,7 @@ * * Size optimization note: it might seem that vararg multipurpose functions * like fin(), enc(), and dec() are not very size optimal, but using a single - * user-visible ECMAScript function saves a lot of run-time footprint; each + * user-visible Ecmascript function saves a lot of run-time footprint; each * Function instance takes >100 bytes. Using a shared native helper and a * 'magic' value won't save much if there are multiple Function instances * anyway. @@ -32322,7 +31493,7 @@ DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER | DUK_TYPE_MASK_OBJECT); - if (duk_get_prop_literal(thr, 1, "stream")) { + if (duk_get_prop_string(thr, 1, "stream")) { stream = duk_to_boolean(thr, -1); } } @@ -32337,7 +31508,6 @@ */ if (len >= (DUK_HBUFFER_MAX_BYTELEN / 3) - 3) { DUK_ERROR_TYPE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return 0;); } output = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, 3 + (3 * len)); /* used parts will be always manually written over */ @@ -32415,7 +31585,7 @@ fail_type: DUK_ERROR_TYPE(thr, DUK_STR_UTF8_DECODE_FAILED); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); } /* @@ -32433,7 +31603,7 @@ } DUK_INTERNAL duk_ret_t duk_bi_textencoder_prototype_encoding_getter(duk_hthread *thr) { - duk_push_literal(thr, "utf-8"); + duk_push_string(thr, "utf-8"); return 1; } @@ -32455,7 +31625,6 @@ len = (duk_size_t) DUK_HSTRING_GET_CHARLEN(h_input); if (len >= DUK_HBUFFER_MAX_BYTELEN / 3) { DUK_ERROR_TYPE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return 0;); } } @@ -32475,14 +31644,14 @@ DUK_ASSERT(duk_is_string(thr, 0)); /* True if len > 0. */ /* XXX: duk_decode_string() is used to process the input - * string. For standard ECMAScript strings, represented + * string. For standard Ecmascript strings, represented * internally as CESU-8, this is fine. However, behavior * beyond CESU-8 is not very strict: codepoints using an * extended form of UTF-8 are also accepted, and invalid * codepoint sequences (which are allowed in Duktape strings) * are not handled as well as they could (e.g. invalid * continuation bytes may mask following codepoints). - * This is how ECMAScript code would also see such strings. + * This is how Ecmascript code would also see such strings. * Maybe replace duk_decode_string() with an explicit strict * CESU-8 decoder here? */ @@ -32510,7 +31679,7 @@ /* Standard WHATWG output is a Uint8Array. Here the Uint8Array will * be backed by a dynamic buffer which differs from e.g. Uint8Arrays - * created as 'new Uint8Array(N)'. ECMAScript code won't see the + * created as 'new Uint8Array(N)'. Ecmascript code won't see the * difference but C code will. When bufferobjects are not supported, * returns a plain dynamic buffer. */ @@ -32532,10 +31701,10 @@ duk_to_string(thr, 0); } if (!duk_is_null_or_undefined(thr, 1)) { - if (duk_get_prop_literal(thr, 1, "fatal")) { + if (duk_get_prop_string(thr, 1, "fatal")) { fatal = duk_to_boolean(thr, -1); } - if (duk_get_prop_literal(thr, 1, "ignoreBOM")) { + if (duk_get_prop_string(thr, 1, "ignoreBOM")) { ignore_bom = duk_to_boolean(thr, -1); } } @@ -32550,7 +31719,7 @@ dec_ctx->ignore_bom = (duk_uint8_t) ignore_bom; duk__utf8_decode_init(dec_ctx); /* Initializes remaining fields. */ - duk_put_prop_literal(thr, -2, DUK_INTERNAL_SYMBOL("Context")); + duk_put_prop_string(thr, -2, DUK_INTERNAL_SYMBOL("Context")); return 0; } @@ -32558,7 +31727,7 @@ DUK_LOCAL duk__decode_context *duk__get_textdecoder_context(duk_hthread *thr) { duk__decode_context *dec_ctx; duk_push_this(thr); - duk_get_prop_literal(thr, -1, DUK_INTERNAL_SYMBOL("Context")); + duk_get_prop_string(thr, -1, DUK_INTERNAL_SYMBOL("Context")); dec_ctx = (duk__decode_context *) duk_require_buffer(thr, -1, NULL); DUK_ASSERT(dec_ctx != NULL); return dec_ctx; @@ -32575,7 +31744,7 @@ /* Encoding is now fixed, so _Context lookup is only needed to * validate the 'this' binding (TypeError if not TextDecoder-like). */ - duk_push_literal(thr, "utf-8"); + duk_push_string(thr, "utf-8"); break; case 1: duk_push_boolean(thr, dec_ctx->fatal); @@ -32676,7 +31845,7 @@ duk_get_prop_stridx_short(thr, -1, DUK_STRIDX_NAME); if (duk_is_undefined(thr, -1)) { duk_pop(thr); - duk_push_literal(thr, "Error"); + duk_push_string(thr, "Error"); } else { duk_to_string(thr, -1); } @@ -32706,7 +31875,7 @@ duk_pop(thr); return 1; } - duk_push_literal(thr, ": "); + duk_push_string(thr, ": "); duk_insert(thr, -2); /* ... name ': ' message */ duk_concat(thr, 3); @@ -32775,13 +31944,13 @@ duk_get_prop_index(thr, idx_td, (duk_uarridx_t) i); duk_get_prop_index(thr, idx_td, (duk_uarridx_t) (i + 1)); d = duk_to_number_m1(thr); - pc = duk_double_to_int_t(DUK_FMOD(d, DUK_DOUBLE_2TO32)); - flags = duk_double_to_uint_t(DUK_FLOOR(d / DUK_DOUBLE_2TO32)); + pc = (duk_int_t) DUK_FMOD(d, DUK_DOUBLE_2TO32); + flags = (duk_uint_t) DUK_FLOOR(d / DUK_DOUBLE_2TO32); t = (duk_small_int_t) duk_get_type(thr, -2); if (t == DUK_TYPE_OBJECT || t == DUK_TYPE_LIGHTFUNC) { /* - * ECMAScript/native function call or lightfunc call + * Ecmascript/native function call or lightfunc call */ count_func++; @@ -33051,7 +32220,7 @@ duk_push_hstring_empty(thr); } else { duk_insert(thr, 0); /* [ arg1 ... argN-1 body] -> [body arg1 ... argN-1] */ - duk_push_literal(thr, ","); + duk_push_string(thr, ","); duk_insert(thr, 1); duk_join(thr, nargs - 1); } @@ -33063,11 +32232,11 @@ /* XXX: this placeholder is not always correct, but use for now. * It will fail in corner cases; see test-dev-func-cons-args.js. */ - duk_push_literal(thr, "function("); + duk_push_string(thr, "function("); duk_dup_1(thr); - duk_push_literal(thr, "){"); + duk_push_string(thr, "){"); duk_dup_0(thr); - duk_push_literal(thr, "\n}"); /* Newline is important to handle trailing // comment. */ + duk_push_string(thr, "}"); duk_concat(thr, 5); /* [ body formals source ] */ @@ -33085,7 +32254,7 @@ comp_flags); /* Force .name to 'anonymous' (ES2015). */ - duk_push_literal(thr, "anonymous"); + duk_push_string(thr, "anonymous"); duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_NAME, DUK_PROPDESC_FLAGS_C); func = (duk_hcompfunc *) duk_known_hobject(thr, -1); @@ -33297,7 +32466,7 @@ if (DUK_HOBJECT_HAS_BOUNDFUNC(h_target)) { duk_hboundfunc *h_boundtarget; - h_boundtarget = (duk_hboundfunc *) (void *) h_target; + h_boundtarget = (duk_hboundfunc *) h_target; /* The final function should always be non-bound, unless * there's a bug in the internals. Assert for it. @@ -33331,7 +32500,7 @@ DUK_DCERROR_RANGE_INVALID_COUNT(thr); } tv_res = (duk_tval *) DUK_ALLOC_CHECKED(thr, ((duk_size_t) bound_nargs) * sizeof(duk_tval)); - DUK_ASSERT(tv_res != NULL || bound_nargs == 0); + DUK_ASSERT(tv_res != NULL); DUK_ASSERT(h_bound->args == NULL); DUK_ASSERT(h_bound->nargs == 0); h_bound->args = tv_res; @@ -33371,7 +32540,7 @@ duk_xdef_prop_stridx_thrower(thr, -1, DUK_STRIDX_LC_ARGUMENTS); /* Function name and fileName (non-standard). */ - duk_push_literal(thr, "bound "); /* ES2015 19.2.3.2. */ + duk_push_string(thr, "bound "); /* ES2015 19.2.3.2. */ duk_get_prop_stridx(thr, -3, DUK_STRIDX_NAME); if (!duk_is_string_notsymbol(thr, -1)) { /* ES2015 has requirement to check that .name of target is a string @@ -33455,17 +32624,6 @@ fail_type: DUK_DCERROR_TYPE_INVALID_ARGS(thr); } - -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL duk_ret_t duk_bi_function_prototype_hasinstance(duk_hthread *thr) { - /* This binding: RHS, stack index 0: LHS. */ - duk_bool_t ret; - - ret = duk_js_instanceof_ordinary(thr, DUK_GET_TVAL_POSIDX(thr, 0), DUK_GET_THIS_TVAL_PTR(thr)); - duk_push_boolean(thr, ret); - return 1; -} -#endif /* DUK_USE_SYMBOL_BUILTIN */ #line 1 "duk_bi_global.c" /* * Global object built-ins @@ -33669,7 +32827,6 @@ uri_error: DUK_ERROR_URI(tfm_ctx->thr, DUK_STR_INVALID_INPUT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__transform_callback_decode_uri(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp) { @@ -33808,7 +32965,6 @@ uri_error: DUK_ERROR_URI(tfm_ctx->thr, DUK_STR_INVALID_INPUT); - DUK_WO_NORETURN(return;); } #if defined(DUK_USE_SECTION_B) @@ -33849,7 +33005,6 @@ esc_error: DUK_ERROR_TYPE(tfm_ctx->thr, DUK_STR_INVALID_INPUT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__transform_callback_unescape(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp) { @@ -33882,7 +33037,7 @@ * Eval needs to handle both a "direct eval" and an "indirect eval". * Direct eval handling needs access to the caller's activation so that its * lexical environment can be accessed. A direct eval is only possible from - * ECMAScript code; an indirect eval call is possible also from C code. + * Ecmascript code; an indirect eval call is possible also from C code. * When an indirect eval call is made from C code, there may not be a * calling activation at all which needs careful handling. */ @@ -33921,7 +33076,7 @@ #if defined(DUK_USE_DEBUGGER_SUPPORT) /* NOTE: level is used only by the debugger and should never be present - * for an ECMAScript eval(). + * for an Ecmascript eval(). */ DUK_ASSERT(level == -2); /* by default, use caller's environment */ if (duk_get_top(thr) >= 2 && duk_is_number(thr, 1)) { @@ -34415,7 +33570,6 @@ */ DUK_ERROR_FMT1(js_ctx->thr, DUK_ERR_SYNTAX_ERROR, DUK_STR_FMT_INVALID_JSON, (long) (js_ctx->p - js_ctx->p_start)); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__dec_eat_white(duk_json_dec_ctx *js_ctx) { @@ -34831,7 +33985,7 @@ src_len = (duk_size_t) (p - js_ctx->p); buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, src_len); DUK_ASSERT(buf != NULL); - duk_memcpy((void *) buf, (const void *) js_ctx->p, src_len); + DUK_MEMCPY((void *) buf, (const void *) js_ctx->p, src_len); duk_hex_decode(thr, -1); js_ctx->p = p + 1; /* skip '|' */ @@ -34922,7 +34076,6 @@ DUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit); if (js_ctx->recursion_depth >= js_ctx->recursion_limit) { DUK_ERROR_RANGE(thr, DUK_STR_JSONDEC_RECLIMIT); - DUK_WO_NORETURN(return;); } js_ctx->recursion_depth++; } @@ -35499,9 +34652,9 @@ /* If XUTF-8 decoding fails, treat the offending byte as a codepoint directly * and go forward one byte. This is of course very lossy, but allows some kind * of output to be produced even for internal strings which don't conform to - * XUTF-8. All standard ECMAScript strings are always CESU-8, so this behavior - * does not violate the ECMAScript specification. The behavior is applied to - * all modes, including ECMAScript standard JSON. Because the current XUTF-8 + * XUTF-8. All standard Ecmascript strings are always CESU-8, so this behavior + * does not violate the Ecmascript specification. The behavior is applied to + * all modes, including Ecmascript standard JSON. Because the current XUTF-8 * decoding is not very strict, this behavior only really affects initial bytes * and truncated codepoints. * @@ -35638,7 +34791,7 @@ /* Unlike in duk_hex_encode() 'dst' is not necessarily aligned by 2. * For platforms where unaligned accesses are not allowed, shift 'dst' - * ahead by 1 byte to get alignment and then duk_memmove() the result + * ahead by 1 byte to get alignment and then DUK_MEMMOVE() the result * in place. The faster encoding loop makes up the difference. * There's always space for one extra byte because a terminator always * follows the hex data and that's been accounted for by the caller. @@ -35671,7 +34824,7 @@ #if !defined(DUK_USE_UNALIGNED_ACCESSES_POSSIBLE) if (shift_dst) { q--; - duk_memmove((void *) dst, (const void *) (dst + 1), 2 * len_safe); + DUK_MEMMOVE((void *) dst, (const void *) (dst + 1), 2 * len_safe); DUK_ASSERT(dst + 2 * len_safe == q); } #endif @@ -35747,7 +34900,7 @@ #if defined(DUK_USE_JC) { DUK_ASSERT(js_ctx->flag_ext_compatible); - duk_memcpy((void *) q, (const void *) "{\"_buf\":\"", 9); /* len: 9 */ + DUK_MEMCPY((void *) q, (const void *) "{\"_buf\":\"", 9); /* len: 9 */ q += 9; q = duk__enc_buffer_data_hex(buf_data, buf_len, q); *q++ = DUK_ASC_DOUBLEQUOTE; @@ -35820,7 +34973,7 @@ DUK_ASSERT(js_ctx->flag_ext_custom || js_ctx->flag_ext_compatible); /* caller checks */ DUK_ASSERT(js_ctx->flag_ext_custom_or_compatible); - duk_memzero(buf, sizeof(buf)); + DUK_MEMZERO(buf, sizeof(buf)); /* The #if defined() clutter here needs to handle the three * cases: (1) JX+JC, (2) JX only, (3) JC only. @@ -35910,21 +35063,21 @@ p = DUK_BW_ENSURE_GETPTR(js_ctx->thr, &js_ctx->bw, need_bytes); p_start = p; - duk_memcpy((void *) p, (const void *) gap_data, (size_t) gap_len); + DUK_MEMCPY((void *) p, (const void *) gap_data, (size_t) gap_len); p += gap_len; avail_bytes = gap_len; DUK_ASSERT(need_bytes >= gap_len); need_bytes -= gap_len; while (need_bytes >= avail_bytes) { - duk_memcpy((void *) p, (const void *) p_start, (size_t) avail_bytes); + DUK_MEMCPY((void *) p, (const void *) p_start, (size_t) avail_bytes); p += avail_bytes; need_bytes -= avail_bytes; avail_bytes <<= 1; } DUK_ASSERT(need_bytes < avail_bytes); /* need_bytes may be zero */ - duk_memcpy((void *) p, (const void *) p_start, (size_t) need_bytes); + DUK_MEMCPY((void *) p, (const void *) p_start, (size_t) need_bytes); p += need_bytes; /*avail_bytes += need_bytes*/ @@ -35956,7 +35109,6 @@ if (DUK_UNLIKELY(js_ctx->visiting[i] == h_target)) { DUK_DD(DUK_DDPRINT("slow path loop detect")); DUK_ERROR_TYPE(thr, DUK_STR_CYCLIC_INPUT); - DUK_WO_NORETURN(return;); } } if (js_ctx->recursion_depth < DUK_JSON_ENC_LOOPARRAY) { @@ -35966,7 +35118,6 @@ duk_dup_top(thr); /* -> [ ... voidp voidp ] */ if (duk_has_prop(thr, js_ctx->idx_loop)) { DUK_ERROR_TYPE(thr, DUK_STR_CYCLIC_INPUT); - DUK_WO_NORETURN(return;); } duk_push_true(thr); /* -> [ ... voidp true ] */ duk_put_prop(thr, js_ctx->idx_loop); /* -> [ ... ] */ @@ -35978,7 +35129,6 @@ DUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit); if (js_ctx->recursion_depth >= js_ctx->recursion_limit) { DUK_ERROR_RANGE(thr, DUK_STR_JSONENC_RECLIMIT); - DUK_WO_NORETURN(return;); } js_ctx->recursion_depth++; @@ -36576,14 +35726,12 @@ if (js_ctx->recursion_depth >= js_ctx->recursion_limit) { DUK_DD(DUK_DDPRINT("fast path recursion limit")); DUK_ERROR_RANGE(js_ctx->thr, DUK_STR_JSONDEC_RECLIMIT); - DUK_WO_NORETURN(return 0;); } for (i = 0, n = (duk_uint_fast32_t) js_ctx->recursion_depth; i < n; i++) { if (DUK_UNLIKELY(js_ctx->visiting[i] == obj)) { DUK_DD(DUK_DDPRINT("fast path loop detect")); DUK_ERROR_TYPE(js_ctx->thr, DUK_STR_CYCLIC_INPUT); - DUK_WO_NORETURN(return 0;); } } @@ -36964,7 +36112,7 @@ /* Error message doesn't matter: the error is ignored anyway. */ DUK_DD(DUK_DDPRINT("aborting fast path")); DUK_ERROR_INTERNAL(js_ctx->thr); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } DUK_LOCAL duk_ret_t duk__json_stringify_fast(duk_hthread *thr, void *udata) { @@ -37013,7 +36161,7 @@ (unsigned long) flags, (long) duk_get_top(thr))); - duk_memzero(&js_ctx_alloc, sizeof(js_ctx_alloc)); + DUK_MEMZERO(&js_ctx_alloc, sizeof(js_ctx_alloc)); js_ctx->thr = thr; #if defined(DUK_USE_EXPLICIT_NULL_INIT) /* nothing now */ @@ -37123,7 +36271,7 @@ * Context init */ - duk_memzero(&js_ctx_alloc, sizeof(js_ctx_alloc)); + DUK_MEMZERO(&js_ctx_alloc, sizeof(js_ctx_alloc)); js_ctx->thr = thr; #if defined(DUK_USE_EXPLICIT_NULL_INIT) js_ctx->h_replacer = NULL; @@ -37522,7 +36670,7 @@ DUK_LOCAL double duk__fmin_fixed(double x, double y) { /* fmin() with args -0 and +0 is not guaranteed to return - * -0 as ECMAScript requires. + * -0 as Ecmascript requires. */ if (x == 0 && y == 0) { duk_double_union du1, du2; @@ -37549,7 +36697,7 @@ DUK_LOCAL double duk__fmax_fixed(double x, double y) { /* fmax() with args -0 and +0 is not guaranteed to return - * +0 as ECMAScript requires. + * +0 as Ecmascript requires. */ if (x == 0 && y == 0) { if (DUK_SIGNBIT(x) == 0 || DUK_SIGNBIT(y) == 0) { @@ -38013,7 +37161,6 @@ (DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_NUMBER)) { DUK_DDD(DUK_DDDPRINT("unacceptable this value: %!T", (duk_tval *) duk_get_tval(thr, -1))); DUK_ERROR_TYPE(thr, "number expected"); - DUK_WO_NORETURN(return 0.0;); } duk_get_prop_stridx_short(thr, -1, DUK_STRIDX_INT_VALUE); DUK_ASSERT(duk_is_number(thr, -1)); @@ -38120,11 +37267,8 @@ duk_small_int_t c; duk_small_uint_t n2s_flags; - /* In ES5.1 frac_digits is coerced first; in ES2015 the 'this number - * value' check is done first. - */ - d = duk__push_this_number_plain(thr); frac_digits = (duk_small_int_t) duk_to_int_check_range(thr, 0, 0, 20); + d = duk__push_this_number_plain(thr); c = (duk_small_int_t) DUK_FPCLASSIFY(d); if (c == DUK_FP_NAN || c == DUK_FP_INFINITE) { @@ -38227,45 +37371,9 @@ */ DUK_ASSERT_TOP(thr, 2); - duk_to_string(thr, -1); - return 1; -} - -/* - * ES2015 isFinite() etc - */ - -#if defined(DUK_USE_ES6) -DUK_INTERNAL duk_ret_t duk_bi_number_check_shared(duk_hthread *thr) { - duk_int_t magic; - duk_bool_t ret = 0; - - if (duk_is_number(thr, 0)) { - duk_double_t d; - - magic = duk_get_current_magic(thr); - d = duk_get_number(thr, 0); - - switch (magic) { - case 0: /* isFinite() */ - ret = duk_double_is_finite(d); - break; - case 1: /* isInteger() */ - ret = duk_double_is_integer(d); - break; - case 2: /* isNaN() */ - ret = duk_double_is_nan(d); - break; - default: /* isSafeInteger() */ - DUK_ASSERT(magic == 3); - ret = duk_double_is_safe_integer(d); - } - } - - duk_push_boolean(thr, ret); + duk_to_string(thr, -1); return 1; } -#endif /* DUK_USE_ES6 */ #endif /* DUK_USE_NUMBER_BUILTIN */ #line 1 "duk_bi_object.c" @@ -38278,9 +37386,12 @@ /* Needed even when Object built-in disabled. */ DUK_INTERNAL duk_ret_t duk_bi_object_prototype_to_string(duk_hthread *thr) { duk_tval *tv; - tv = DUK_HTHREAD_THIS_PTR(thr); - duk_push_class_string_tval(thr, tv, 0 /*avoid_side_effects*/); + /* XXX: This is not entirely correct anymore; in ES2015 the + * default lookup should use @@toStringTag to come up with + * e.g. [object Symbol]. + */ + duk_push_class_string_tval(thr, tv); return 1; } @@ -38785,7 +37896,7 @@ DUK_ASSERT(duk_get_hobject(thr, 2) != NULL); /* - * Validate and convert argument property descriptor (an ECMAScript + * Validate and convert argument property descriptor (an Ecmascript * object) into a set of defprop_flags and possibly property value, * getter, and/or setter values on the value stack. * @@ -39063,7 +38174,6 @@ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } duk_get_prototype(thr, -1); @@ -39191,37 +38301,37 @@ DUK_INTERNAL duk_ret_t duk_bi_promise_constructor(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_all(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_race(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_reject(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_resolve(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_catch(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_then(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } #endif /* DUK_USE_PROMISE_BUILTIN */ @@ -39256,7 +38366,6 @@ h = duk_get_hstring(thr, -1); if (h == NULL) { DUK_ERROR_TYPE_INVALID_TRAP_RESULT(thr); - DUK_WO_NORETURN(return;); } if (!(flags & DUK_ENUM_INCLUDE_NONENUMERABLE)) { @@ -39365,7 +38474,6 @@ if (nargs >= 3 && !duk_strict_equals(thr, 0, 2)) { /* XXX: [[Get]] receiver currently unsupported */ DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } /* [ target key receiver? ...? ] */ @@ -39409,7 +38517,6 @@ if (nargs >= 4 && !duk_strict_equals(thr, 0, 3)) { /* XXX: [[Set]] receiver currently unsupported */ DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } /* [ target key value receiver? ...? ] */ @@ -39544,7 +38651,7 @@ /* This must be generic in ES2015 and later. */ DUK_ASSERT_TOP(thr, 0); duk_push_this(thr); - duk_push_literal(thr, "/"); + duk_push_string(thr, "/"); duk_get_prop_stridx(thr, 0, DUK_STRIDX_SOURCE); duk_dup_m2(thr); /* another "/" */ duk_get_prop_stridx(thr, 0, DUK_STRIDX_FLAGS); @@ -39608,7 +38715,7 @@ if (magic != 16 /* .source */) { return 0; } - duk_push_literal(thr, "(?:)"); /* .source handled by switch-case */ + duk_push_string(thr, "(?:)"); /* .source handled by switch-case */ re_flags = 0; } else { DUK_DCERROR_TYPE_INVALID_ARGS(thr); @@ -39680,7 +38787,6 @@ if (duk_get_class_number(thr, idx) == DUK_HOBJECT_CLASS_REGEXP) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } h = duk_to_hstring(thr, idx); DUK_ASSERT(h != NULL); @@ -39727,14 +38833,14 @@ while (p <= p_end && p >= p_start) { t = *p; - /* For ECMAScript strings, this check can only match for + /* For Ecmascript strings, this check can only match for * initial UTF-8 bytes (not continuation bytes). For other * strings all bets are off. */ if ((t == firstbyte) && ((duk_size_t) (p_end - p) >= (duk_size_t) q_blen)) { - DUK_ASSERT(q_blen > 0); - if (duk_memcmp((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { + DUK_ASSERT(q_blen > 0); /* no issues with memcmp() zero size, even if broken */ + if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { return cpos; } } @@ -39916,37 +39022,13 @@ */ DUK_INTERNAL duk_ret_t duk_bi_string_prototype_char_at(duk_hthread *thr) { - duk_hstring *h; duk_int_t pos; /* XXX: faster implementation */ - h = duk_push_this_coercible_to_string(thr); - DUK_ASSERT(h != NULL); - + (void) duk_push_this_coercible_to_string(thr); pos = duk_to_int(thr, 0); - - if (sizeof(duk_size_t) >= sizeof(duk_uint_t)) { - /* Cast to duk_size_t works in this case: - * - If pos < 0, (duk_size_t) pos will always be - * >= max_charlen, and result will be the empty string - * (see duk_substring()). - * - If pos >= 0, pos + 1 cannot wrap. - */ - DUK_ASSERT((duk_size_t) DUK_INT_MIN >= DUK_HSTRING_MAX_BYTELEN); - DUK_ASSERT((duk_size_t) DUK_INT_MAX + 1U > (duk_size_t) DUK_INT_MAX); - duk_substring(thr, -1, (duk_size_t) pos, (duk_size_t) pos + 1U); - } else { - /* If size_t is smaller than int, explicit bounds checks - * are needed because an int may wrap multiple times. - */ - if (DUK_UNLIKELY(pos < 0 || (duk_uint_t) pos >= (duk_uint_t) DUK_HSTRING_GET_CHARLEN(h))) { - duk_push_hstring_empty(thr); - } else { - duk_substring(thr, -1, (duk_size_t) pos, (duk_size_t) pos + 1U); - } - } - + duk_substring(thr, -1, (duk_size_t) pos, (duk_size_t) (pos + 1)); return 1; } @@ -40336,7 +39418,7 @@ while (p <= p_end) { DUK_ASSERT(p + q_blen <= DUK_HSTRING_GET_DATA(h_input) + DUK_HSTRING_GET_BYTELEN(h_input)); - if (duk_memcmp((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { + if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { duk_dup_0(thr); h_match = duk_known_hstring(thr, -1); #if defined(DUK_USE_REGEXP_SUPPORT) @@ -40717,7 +39799,7 @@ while (p <= p_end) { DUK_ASSERT(p + q_blen <= DUK_HSTRING_GET_DATA(h_input) + DUK_HSTRING_GET_BYTELEN(h_input)); DUK_ASSERT(q_blen > 0); /* no issues with empty memcmp() */ - if (duk_memcmp((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { + if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { /* never an empty match, so step 13.c.iii can't be triggered */ goto found; } @@ -41030,14 +40112,12 @@ /* Temporary fixed buffer, later converted to string. */ buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, result_len); - DUK_ASSERT(buf != NULL); src = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input); - DUK_ASSERT(src != NULL); #if defined(DUK_USE_PREFER_SIZE) p = buf; while (count-- > 0) { - duk_memcpy((void *) p, (const void *) src, input_blen); /* copy size may be zero, but pointers are valid */ + DUK_MEMCPY((void *) p, (const void *) src, input_blen); /* copy size may be zero */ p += input_blen; } #else /* DUK_USE_PREFER_SIZE */ @@ -41054,12 +40134,12 @@ (long) result_len)); if (remain <= copy_size) { /* If result_len is zero, this case is taken and does - * a zero size copy (with valid pointers). + * a zero size copy. */ - duk_memcpy((void *) p, (const void *) src, remain); + DUK_MEMCPY((void *) p, (const void *) src, remain); break; } else { - duk_memcpy((void *) p, (const void *) src, copy_size); + DUK_MEMCPY((void *) p, (const void *) src, copy_size); p += copy_size; } @@ -41114,7 +40194,8 @@ h2_len = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h2); prefix_len = (h1_len <= h2_len ? h1_len : h2_len); - rc = (duk_small_int_t) duk_memcmp((const void *) DUK_HSTRING_GET_DATA(h1), + /* Zero size compare not an issue with DUK_MEMCMP. */ + rc = (duk_small_int_t) DUK_MEMCMP((const void *) DUK_HSTRING_GET_DATA(h1), (const void *) DUK_HSTRING_GET_DATA(h2), (size_t) prefix_len); @@ -41164,7 +40245,7 @@ if (duk_is_undefined(thr, 1)) { if (magic) { - p_cmp_start = p_cmp_start + DUK_HSTRING_GET_BYTELEN(h) - blen_search; + p_cmp_start += DUK_HSTRING_GET_BYTELEN(h) - blen_search; } else { /* p_cmp_start already OK */ } @@ -41195,7 +40276,7 @@ result = 0; if (p_cmp_start >= DUK_HSTRING_GET_DATA(h) && (duk_size_t) (p_cmp_start - (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h)) + blen_search <= DUK_HSTRING_GET_BYTELEN(h)) { - if (duk_memcmp((const void *) p_cmp_start, + if (DUK_MEMCMP((const void *) p_cmp_start, (const void *) DUK_HSTRING_GET_DATA(h_search), (size_t) blen_search) == 0) { result = 1; @@ -41270,10 +40351,9 @@ * +1 0xff after unique suffix for symbols with undefined description */ buf = (duk_uint8_t *) duk_push_fixed_buffer(thr, 1 + len + 1 + 17 + 1); - DUK_ASSERT(buf != NULL); p = buf + 1; DUK_ASSERT(desc != NULL || len == 0); /* may be NULL if len is 0 */ - duk_memcpy_unsafe((void *) p, (const void *) desc, len); + DUK_MEMCPY((void *) p, (const void *) desc, len); p += len; if (magic == 0) { /* Symbol(): create unique symbol. Use two 32-bit values @@ -41445,7 +40525,7 @@ * * The thread must be in resumable state, either (a) new thread which hasn't * yet started, or (b) a thread which has previously yielded. This method - * must be called from an ECMAScript function. + * must be called from an Ecmascript function. * * Args: * - thread @@ -41471,9 +40551,8 @@ DUK_ASSERT(thr->heap->curr_thread == thr); thr_resume = duk_require_hthread(thr, 0); - DUK_ASSERT(duk_get_top(thr) == 3); - is_error = (duk_small_uint_t) duk_to_boolean_top_pop(thr); - DUK_ASSERT(duk_get_top(thr) == 2); + is_error = (duk_small_uint_t) duk_to_boolean(thr, 2); + duk_set_top(thr, 2); /* [ thread value ] */ @@ -41493,7 +40572,7 @@ caller_func = DUK_ACT_GET_FUNC(thr->callstack_curr->parent); if (!DUK_HOBJECT_IS_COMPFUNC(caller_func)) { - DUK_DD(DUK_DDPRINT("resume state invalid: caller must be ECMAScript code")); + DUK_DD(DUK_DDPRINT("resume state invalid: caller must be Ecmascript code")); goto state_error; } @@ -41521,7 +40600,7 @@ DUK_ASSERT(thr_resume->state == DUK_HTHREAD_STATE_INACTIVE); - /* The initial function must be an ECMAScript function (but + /* The initial function must be an Ecmascript function (but * can be bound). We must make sure of that before we longjmp * because an error in the RESUME handler call processing will * not be handled very cleanly. @@ -41600,7 +40679,7 @@ * The thread must be in yieldable state: it must have a resumer, and there * must not be any yield-preventing calls (native calls and constructor calls, * currently) in the thread's call stack (otherwise a resume would not be - * possible later). This method must be called from an ECMAScript function. + * possible later). This method must be called from an Ecmascript function. * * Args: * - value @@ -41621,9 +40700,8 @@ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); DUK_ASSERT(thr->heap->curr_thread == thr); - DUK_ASSERT(duk_get_top(thr) == 2); - is_error = (duk_small_uint_t) duk_to_boolean_top_pop(thr); - DUK_ASSERT(duk_get_top(thr) == 1); + is_error = (duk_small_uint_t) duk_to_boolean(thr, 1); + duk_set_top(thr, 1); /* [ value ] */ @@ -41649,7 +40727,7 @@ caller_func = DUK_ACT_GET_FUNC(thr->callstack_curr->parent); if (!DUK_HOBJECT_IS_COMPFUNC(caller_func)) { - DUK_DD(DUK_DDPRINT("yield state invalid: caller must be ECMAScript code")); + DUK_DD(DUK_DDPRINT("yield state invalid: caller must be Ecmascript code")); goto state_error; } @@ -41748,7 +40826,7 @@ } else { copylen = length; } - duk_memcpy_unsafe(fb->buffer + fb->offset, buffer, copylen); + DUK_MEMCPY(fb->buffer + fb->offset, buffer, copylen); fb->offset += copylen; } @@ -41835,7 +40913,7 @@ * (excluding the null terminator). If retval == buffer size, * output was truncated (except for corner cases). * - * * Output format is intentionally different from ECMAScript + * * Output format is intentionally different from Ecmascript * formatting requirements, as formatting here serves debugging * of internals. * @@ -42621,7 +41699,7 @@ const char *p_end = p + DUK_STRLEN(format); duk_int_t retval; - duk_memzero(&fb, sizeof(fb)); + DUK_MEMZERO(&fb, sizeof(fb)); fb.buffer = (duk_uint8_t *) str; fb.length = size; fb.offset = 0; @@ -42646,7 +41724,7 @@ * understand. See man 3 printf. */ - duk_memzero(&st, sizeof(st)); + DUK_MEMZERO(&st, sizeof(st)); st.fb = &fb; st.depth = 0; st.depth_limit = 1; @@ -42713,8 +41791,8 @@ /* format is too large, abort */ goto format_error; } - duk_memzero(fmtbuf, sizeof(fmtbuf)); - duk_memcpy(fmtbuf, p_begfmt, fmtlen); + DUK_MEMZERO(fmtbuf, sizeof(fmtbuf)); + DUK_MEMCPY(fmtbuf, p_begfmt, fmtlen); /* assume exactly 1 arg, which is why '*' is forbidden; arg size still * depends on type though. @@ -42819,8 +41897,7 @@ duk_uint8_t *p = (duk_uint8_t *) buf; duk_uint8_t *p_end = (duk_uint8_t *) (buf + buf_size - 1); - DUK_ASSERT(buf != NULL); - duk_memzero(buf, buf_size); + DUK_MEMZERO(buf, buf_size); for (i = 0; i < fptr_size; i++) { duk_int_t left = (duk_int_t) (p_end - p); @@ -43159,7 +42236,6 @@ DUK_ASSERT(thr != NULL); heap = thr->heap; DUK_ASSERT(heap != NULL); - DUK_ASSERT(data != NULL); if (heap->dbg_read_cb == NULL) { DUK_D(DUK_DPRINT("attempt to read %ld bytes in detached state, return zero data", (long) length)); @@ -43197,7 +42273,7 @@ return; fail: - duk_memzero((void *) data, (size_t) length); + DUK_MEMZERO((void *) data, (size_t) length); } DUK_INTERNAL duk_uint8_t duk_debug_read_byte(duk_hthread *thr) { @@ -43810,7 +42886,7 @@ (unsigned int) du2.uc[4], (unsigned int) du2.uc[5], (unsigned int) du2.uc[6], (unsigned int) du2.uc[7])); - if (duk_memcmp((const void *) du1.uc, (const void *) du2.uc, sizeof(du1.uc)) == 0) { + if (DUK_MEMCMP((const void *) du1.uc, (const void *) du2.uc, sizeof(du1.uc)) == 0) { duk_debug_write_int(thr, i32); } else { DUK_DBLUNION_DOUBLE_HTON(&du1); @@ -43919,9 +42995,9 @@ duk_debug_write_int(thr, 0); } else { duk_push_tval(thr, &act->tv_func); - duk_get_prop_literal(thr, -1, "fileName"); + duk_get_prop_string(thr, -1, "fileName"); duk__debug_write_hstring_safe_top(thr); - duk_get_prop_literal(thr, -2, "name"); + duk_get_prop_string(thr, -2, "name"); duk__debug_write_hstring_safe_top(thr); duk_pop_3(thr); /* Report next pc/line to be executed. */ @@ -43966,7 +43042,7 @@ act = thr->callstack_curr; if (act != NULL) { duk_push_tval(thr, &act->tv_func); - duk_get_prop_literal(thr, -1, "fileName"); + duk_get_prop_string(thr, -1, "fileName"); duk__debug_write_hstring_safe_top(thr); pc = (duk_uint32_t) duk_hthread_get_act_prev_pc(thr, act); duk_debug_write_uint(thr, (duk_uint32_t) duk_hobject_pc2line_query(thr, -2, pc)); @@ -44443,7 +43519,7 @@ fun = DUK_ACT_GET_FUNC(act); if (fun != NULL && DUK_HOBJECT_IS_COMPFUNC(fun)) { /* Direct eval requires that there's a current - * activation and it is an ECMAScript function. + * activation and it is an Ecmascript function. * When Eval is executed from e.g. cooperate API * call we'll need to do an indirect eval instead. */ @@ -45109,7 +44185,7 @@ if (DUK_HOBJECT_IS_BOUNDFUNC(h_obj)) { duk_hboundfunc *h_bfun; - h_bfun = (duk_hboundfunc *) (void *) h_obj; + h_bfun = (duk_hboundfunc *) h_obj; duk__debug_getinfo_flags_key(thr, "target"); duk_debug_write_tval(thr, &h_bfun->target); @@ -45586,7 +44662,7 @@ fun = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act); /* Short circuit if is safe: if act->curr_pc != NULL, 'fun' is - * guaranteed to be a non-NULL ECMAScript function. + * guaranteed to be a non-NULL Ecmascript function. */ DUK_ASSERT(act->curr_pc == NULL || (fun != NULL && DUK_HOBJECT_IS_COMPFUNC((duk_hobject *) fun))); @@ -45682,10 +44758,11 @@ DUK_ASSERT(h != NULL); move_size = sizeof(duk_breakpoint) * (heap->dbg_breakpoint_count - breakpoint_index - 1); - duk_memmove((void *) b, - (const void *) (b + 1), - (size_t) move_size); - + if (move_size > 0) { + DUK_MEMMOVE((void *) b, + (const void *) (b + 1), + (size_t) move_size); + } heap->dbg_breakpoint_count--; heap->dbg_breakpoints_active[0] = (duk_breakpoint *) NULL; @@ -45772,7 +44849,7 @@ * * Error augmentation may throw an internal error (e.g. alloc error). * - * ECMAScript allows throwing any values, so all values cannot be + * Ecmascript allows throwing any values, so all values cannot be * augmented. Currently, the built-in augmentation at error creation * only augments error values which are Error instances (= have the * built-in Error.prototype in their prototype chain) and are also @@ -46112,6 +45189,7 @@ DUK_UNREF(pc); DUK_ASSERT_DISABLE(pc >= 0); /* unsigned */ DUK_ASSERT((duk_double_t) pc < DUK_DOUBLE_2TO32); /* assume PC is at most 32 bits and non-negative */ + act = NULL; /* invalidated by pushes, so get out of the way */ duk_push_hobject(thr, func); @@ -46327,15 +45405,12 @@ /* #include duk_internal.h -> already included */ #if defined(DUK_USE_PREFER_SIZE) -DUK_NORETURN(DUK_LOCAL_DECL void duk__uncaught_minimal(duk_hthread *thr)); DUK_LOCAL void duk__uncaught_minimal(duk_hthread *thr) { (void) duk_fatal(thr, "uncaught error"); - DUK_WO_NORETURN(return;); } #endif #if 0 -DUK_NORETURN(DUK_LOCAL_DECL void duk__uncaught_readable(duk_hthread *thr)); DUK_LOCAL void duk__uncaught_readable(duk_hthread *thr) { const char *summary; char buf[DUK_USE_FATAL_MAXLEN]; @@ -46344,12 +45419,10 @@ DUK_SNPRINTF(buf, sizeof(buf), "uncaught: %s", summary); buf[sizeof(buf) - 1] = (char) 0; (void) duk_fatal(thr, (const char *) buf); - DUK_WO_NORETURN(return;); } #endif #if !defined(DUK_USE_PREFER_SIZE) -DUK_NORETURN(DUK_LOCAL_DECL void duk__uncaught_error_aware(duk_hthread *thr)); DUK_LOCAL void duk__uncaught_error_aware(duk_hthread *thr) { const char *summary; char buf[DUK_USE_FATAL_MAXLEN]; @@ -46359,7 +45432,6 @@ DUK_SNPRINTF(buf, sizeof(buf), "uncaught: %s", summary); buf[sizeof(buf) - 1] = (char) 0; (void) duk_fatal(thr, (const char *) buf); - DUK_WO_NORETURN(return;); } #endif @@ -46397,9 +45469,14 @@ DUK_DD(DUK_DDPRINT("about to longjmp, pf_prevent_count=%ld", (long) thr->heap->pf_prevent_count)); +#if !defined(DUK_USE_CPP_EXCEPTIONS) /* If we don't have a jmpbuf_ptr, there is little we can do except * cause a fatal error. The caller's expectation is that we never * return. + * + * With C++ exceptions we now just propagate an uncaught error + * instead of invoking the fatal error handler. Because there's + * a dummy jmpbuf for C++ exceptions now, this could be changed. */ if (!thr->heap->lj.jmpbuf_ptr) { DUK_D(DUK_DPRINT("uncaught error: type=%d iserror=%d value1=%!T value2=%!T", @@ -46413,12 +45490,16 @@ #endif DUK_UNREACHABLE(); } +#endif /* DUK_USE_CPP_EXCEPTIONS */ #if defined(DUK_USE_CPP_EXCEPTIONS) - throw duk_internal_exception(); /* dummy */ -#else + { + duk_internal_exception exc; /* dummy */ + throw exc; + } +#else /* DUK_USE_CPP_EXCEPTIONS */ DUK_LONGJMP(thr->heap->lj.jmpbuf_ptr->jb); -#endif +#endif /* DUK_USE_CPP_EXCEPTIONS */ DUK_UNREACHABLE(); } @@ -46599,10 +45680,10 @@ } #line 1 "duk_error_throw.c" /* - * Create and throw an ECMAScript error object based on a code and a message. + * Create and throw an Ecmascript error object based on a code and a message. * - * Used when we throw errors internally. ECMAScript generated error objects - * are created by ECMAScript code, and the throwing is handled by the bytecode + * Used when we throw errors internally. Ecmascript generated error objects + * are created by Ecmascript code, and the throwing is handled by the bytecode * executor. */ @@ -46758,7 +45839,7 @@ */ duk_error_raw(thr, -rc, NULL, 0, "error (rc %ld)", (long) rc); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); } #line 1 "duk_hbuffer_alloc.c" /* @@ -46810,10 +45891,10 @@ /* zero everything unless requested not to do so */ #if defined(DUK_USE_ZERO_BUFFER_DATA) - duk_memzero((void *) res, + DUK_MEMZERO((void *) res, (flags & DUK_BUF_FLAG_NOZERO) ? header_size : alloc_size); #else - duk_memzero((void *) res, header_size); + DUK_MEMZERO((void *) res, header_size); #endif if (flags & DUK_BUF_FLAG_EXTERNAL) { @@ -46860,7 +45941,7 @@ DUK_ASSERT(DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap, h) == NULL); } } else { - *out_bufdata = (void *) ((duk_hbuffer_fixed *) (void *) res + 1); + *out_bufdata = (void *) ((duk_hbuffer_fixed *) res + 1); } DUK_HBUFFER_SET_SIZE(res, size); @@ -46920,7 +46001,6 @@ if (new_size > DUK_HBUFFER_MAX_BYTELEN) { DUK_ERROR_RANGE(thr, "buffer too long"); - DUK_WO_NORETURN(return;); } /* @@ -46949,7 +46029,7 @@ if (new_size > prev_size) { DUK_ASSERT(new_size - prev_size > 0); #if defined(DUK_USE_ZERO_BUFFER_DATA) - duk_memzero((void *) ((char *) res + prev_size), + DUK_MEMZERO((void *) ((char *) res + prev_size), (duk_size_t) (new_size - prev_size)); #endif } @@ -46958,7 +46038,6 @@ DUK_HBUFFER_DYNAMIC_SET_DATA_PTR(thr->heap, buf, res); } else { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return;); } DUK_ASSERT(res != NULL || new_size == 0); @@ -47062,7 +46141,7 @@ * functions in the callstack. */ } else if (DUK_HOBJECT_IS_BOUNDFUNC(h)) { - duk_hboundfunc *f = (duk_hboundfunc *) (void *) h; + duk_hboundfunc *f = (duk_hboundfunc *) h; DUK_FREE(heap, f->args); } @@ -47460,7 +46539,7 @@ duk_bitdecoder_ctx *bd = &bd_ctx; /* convenience */ duk_small_uint_t i; - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); bd->data = (const duk_uint8_t *) duk_strings_data; bd->length = (duk_size_t) DUK_STRDATA_DATA_LENGTH; @@ -47681,8 +46760,7 @@ DUK__DUMPSZ(duk_heap); DUK__DUMPSZ(duk_activation); DUK__DUMPSZ(duk_catcher); - DUK__DUMPSZ(duk_strcache_entry); - DUK__DUMPSZ(duk_litcache_entry); + DUK__DUMPSZ(duk_strcache); DUK__DUMPSZ(duk_ljstate); DUK__DUMPSZ(duk_fixedbuffer); DUK__DUMPSZ(duk_bitdecoder_ctx); @@ -47891,7 +46969,7 @@ * Zero the struct, and start initializing roughly in order */ - duk_memzero(res, sizeof(*res)); + DUK_MEMZERO(res, sizeof(*res)); #if defined(DUK_USE_ASSERTIONS) res->heap_initializing = 1; #endif @@ -47976,7 +47054,7 @@ /* XXX: use the pointer as a seed for now: mix in time at least */ - /* The casts through duk_uintptr_t is to avoid the following GCC warning: + /* The casts through duk_intptr_t is to avoid the following GCC warning: * * warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] * @@ -47987,7 +47065,7 @@ DUK_D(DUK_DPRINT("using rom strings, force heap hash_seed to fixed value 0x%08lx", (long) DUK__FIXED_HASH_SEED)); res->hash_seed = (duk_uint32_t) DUK__FIXED_HASH_SEED; #else /* DUK_USE_ROM_STRINGS */ - res->hash_seed = (duk_uint32_t) (duk_uintptr_t) res; + res->hash_seed = (duk_uint32_t) (duk_intptr_t) res; #if !defined(DUK_USE_STRHASH_DENSE) res->hash_seed ^= 5381; /* Bernstein hash init value is normally 5381; XOR it in in case pointer low bits are 0 */ #endif @@ -48027,17 +47105,17 @@ #if defined(DUK_USE_STRTAB_PTRCOMP) /* zero assumption */ - duk_memzero(res->strtable16, sizeof(duk_uint16_t) * st_initsize); + DUK_MEMZERO(res->strtable16, sizeof(duk_uint16_t) * st_initsize); #else #if defined(DUK_USE_EXPLICIT_NULL_INIT) { - duk_uint32_t i; + duk_small_uint_t i; for (i = 0; i < st_initsize; i++) { res->strtable[i] = NULL; } } #else - duk_memzero(res->strtable, sizeof(duk_hstring *) * st_initsize); + DUK_MEMZERO(res->strtable, sizeof(duk_hstring *) * st_initsize); #endif /* DUK_USE_EXPLICIT_NULL_INIT */ #endif /* DUK_USE_STRTAB_PTRCOMP */ @@ -48047,30 +47125,13 @@ #if defined(DUK_USE_EXPLICIT_NULL_INIT) { - duk_uint_t i; + duk_small_uint_t i; for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { res->strcache[i].h = NULL; } } #endif - /* - * Init litcache - */ -#if defined(DUK_USE_LITCACHE_SIZE) - DUK_ASSERT(DUK_USE_LITCACHE_SIZE > 0); - DUK_ASSERT(DUK_IS_POWER_OF_TWO((duk_uint_t) DUK_USE_LITCACHE_SIZE)); -#if defined(DUK_USE_EXPLICIT_NULL_INIT) - { - duk_uint_t i; - for (i = 0; i < DUK_USE_LITCACHE_SIZE; i++) { - res->litcache[i].addr = NULL; - res->litcache[i].h = NULL; - } - } -#endif -#endif /* DUK_USE_LITCACHE_SIZE */ - /* XXX: error handling is incomplete. It would be cleanest if * there was a setjmp catchpoint, so that all init code could * freely throw errors. If that were the case, the return code @@ -48142,7 +47203,7 @@ { duk_uint64_t tmp_u64; tmp_u64 = 0; - duk_memcpy((void *) &tmp_u64, + DUK_MEMCPY((void *) &tmp_u64, (const void *) &res, (size_t) (sizeof(void *) >= sizeof(duk_uint64_t) ? sizeof(duk_uint64_t) : sizeof(void *))); res->rnd_state[1] ^= tmp_u64; @@ -48900,7 +47961,7 @@ duk__mark_heaphdr(heap, (duk_heaphdr *) b->buf_prop); #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ } else if (DUK_HOBJECT_IS_BOUNDFUNC(h)) { - duk_hboundfunc *f = (duk_hboundfunc *) (void *) h; + duk_hboundfunc *f = (duk_hboundfunc *) h; DUK_ASSERT_HBOUNDFUNC_VALID(f); duk__mark_tval(heap, &f->target); duk__mark_tval(heap, &f->this_binding); @@ -49374,8 +48435,7 @@ duk_hstring *next; next = h->hdr.h_next; - if (DUK_HEAPHDR_HAS_REACHABLE((duk_heaphdr *) h)) - { + if (DUK_HEAPHDR_HAS_REACHABLE((duk_heaphdr *) h)) { DUK_HEAPHDR_CLEAR_REACHABLE((duk_heaphdr *) h); count_keep++; prev = h; @@ -49384,26 +48444,13 @@ count_free++; #endif - /* For pinned strings the refcount has been - * bumped. We could unbump it here before - * freeing, but that's actually not necessary - * except for assertions. - */ -#if 0 - if (DUK_HSTRING_HAS_PINNED_LITERAL(h)) { - DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) > 0U); - DUK_HSTRING_DECREF_NORZ(heap->heap_thread, h); - DUK_HSTRING_CLEAR_PINNED_LITERAL(h); - } -#endif #if defined(DUK_USE_REFERENCE_COUNTING) /* Non-zero refcounts should not happen for unreachable strings, * because we refcount finalize all unreachable objects which * should have decreased unreachable string refcounts to zero - * (even for cycles). However, pinned strings have a +1 bump. + * (even for cycles). */ - DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) == - DUK_HSTRING_HAS_PINNED_LITERAL(h) ? 1U : 0U); + DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) == 0); #endif /* Deal with weak references first. */ @@ -49607,26 +48654,6 @@ } /* - * Litcache helpers. - */ - -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_LOCAL void duk__wipe_litcache(duk_heap *heap) { - duk_uint_t i; - duk_litcache_entry *e; - - e = heap->litcache; - for (i = 0; i < DUK_USE_LITCACHE_SIZE; i++) { - e->addr = NULL; - /* e->h does not need to be invalidated: when e->addr is - * NULL, e->h is considered garbage. - */ - e++; - } -} -#endif /* DUK_USE_LITCACHE_SIZE */ - -/* * Object compaction. * * Compaction is assumed to never throw an error. @@ -49810,7 +48837,6 @@ DUK_LOCAL void duk__check_refcount_heaphdr(duk_heaphdr *hdr) { duk_bool_t count_ok; - duk_size_t expect_refc; /* The refcount check only makes sense for reachable objects on * heap_allocated or string table, after the sweep phase. Prior to @@ -49827,11 +48853,7 @@ */ DUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY(hdr)); - expect_refc = hdr->h_assert_refcount; - if (DUK_HEAPHDR_IS_STRING(hdr) && DUK_HSTRING_HAS_PINNED_LITERAL((duk_hstring *) hdr)) { - expect_refc++; - } - count_ok = ((duk_size_t) DUK_HEAPHDR_GET_REFCOUNT(hdr) == expect_refc); + count_ok = ((duk_size_t) DUK_HEAPHDR_GET_REFCOUNT(hdr) == hdr->h_assert_refcount); if (!count_ok) { DUK_D(DUK_DPRINT("refcount mismatch for: %p: header=%ld counted=%ld --> %!iO", (void *) hdr, (long) DUK_HEAPHDR_GET_REFCOUNT(hdr), @@ -49868,22 +48890,6 @@ } } #endif /* DUK_USE_REFERENCE_COUNTING */ - -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_LOCAL void duk__assert_litcache_nulls(duk_heap *heap) { - duk_uint_t i; - duk_litcache_entry *e; - - e = heap->litcache; - for (i = 0; i < DUK_USE_LITCACHE_SIZE; i++) { - /* Entry addresses were NULLed before mark-and-sweep, check - * that they're still NULL afterwards to ensure no pointers - * were recorded through any side effects. - */ - DUK_ASSERT(e->addr == NULL); - } -} -#endif /* DUK_USE_LITCACHE_SIZE */ #endif /* DUK_USE_ASSERTIONS */ /* @@ -49904,13 +48910,10 @@ DUK_D(DUK_DPRINT("stats mark-and-sweep: try_count=%ld, skip_count=%ld, emergency_count=%ld", (long) heap->stats_ms_try_count, (long) heap->stats_ms_skip_count, (long) heap->stats_ms_emergency_count)); - DUK_D(DUK_DPRINT("stats stringtable: intern_hit=%ld, intern_miss=%ld, " - "resize_check=%ld, resize_grow=%ld, resize_shrink=%ld, " - "litcache_hit=%ld, litcache_miss=%ld, litcache_pin=%ld", + DUK_D(DUK_DPRINT("stats stringtable: intern_hit=%ld, intern_miss=%ld, resize_check=%ld, resize_grow=%ld, resize_shrink=%ld", (long) heap->stats_strtab_intern_hit, (long) heap->stats_strtab_intern_miss, (long) heap->stats_strtab_resize_check, (long) heap->stats_strtab_resize_grow, - (long) heap->stats_strtab_resize_shrink, (long) heap->stats_strtab_litcache_hit, - (long) heap->stats_strtab_litcache_miss, (long) heap->stats_strtab_litcache_pin)); + (long) heap->stats_strtab_resize_shrink)); DUK_D(DUK_DPRINT("stats object: realloc_props=%ld, abandon_array=%ld", (long) heap->stats_object_realloc_props, (long) heap->stats_object_abandon_array)); DUK_D(DUK_DPRINT("stats getownpropdesc: count=%ld, hit=%ld, miss=%ld", @@ -50051,9 +49054,6 @@ #if defined(DUK_USE_ASSERTIONS) && defined(DUK_USE_REFERENCE_COUNTING) duk__clear_assert_refcounts(heap); #endif -#if defined(DUK_USE_LITCACHE_SIZE) - duk__wipe_litcache(heap); -#endif duk__mark_roots_heap(heap); /* Mark main reachability roots. */ #if defined(DUK_USE_REFERENCE_COUNTING) DUK_ASSERT(heap->refzero_list == NULL); /* Always handled to completion inline in DECREF. */ @@ -50159,9 +49159,6 @@ */ duk__assert_valid_refcounts(heap); #endif /* DUK_USE_REFERENCE_COUNTING */ -#if defined(DUK_USE_LITCACHE_SIZE) - duk__assert_litcache_nulls(heap); -#endif /* DUK_USE_LITCACHE_SIZE */ #endif /* DUK_USE_ASSERTIONS */ /* @@ -50352,7 +49349,8 @@ res = DUK_ALLOC(heap, size); if (DUK_LIKELY(res != NULL)) { - duk_memzero(res, size); + /* assume memset with zero size is OK */ + DUK_MEMZERO(res, size); } return res; } @@ -50366,7 +49364,7 @@ return res; } DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; } DUK_INTERNAL void *duk_heap_mem_alloc_checked_zeroed(duk_hthread *thr, duk_size_t size) { @@ -50378,7 +49376,7 @@ return res; } DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; } /* @@ -50943,7 +49941,7 @@ DUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, (duk_hobject *) b->buf_prop); #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ } else if (DUK_HOBJECT_IS_BOUNDFUNC(h)) { - duk_hboundfunc *f = (duk_hboundfunc *) (void *) h; + duk_hboundfunc *f = (duk_hboundfunc *) h; DUK_ASSERT_HBOUNDFUNC_VALID(f); DUK_TVAL_DECREF_NORZ(thr, &f->target); DUK_TVAL_DECREF_NORZ(thr, &f->this_binding); @@ -51634,9 +50632,9 @@ */ DUK_INTERNAL void duk_heap_strcache_string_remove(duk_heap *heap, duk_hstring *h) { - duk_uint_t i; + duk_small_int_t i; for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { - duk_strcache_entry *c = heap->strcache + 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)); @@ -51708,9 +50706,9 @@ 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_entry *sce; + duk_strcache *sce; duk_uint_fast32_t byte_offset; - duk_uint_t i; + duk_small_int_t i; duk_bool_t use_cache; duk_uint_fast32_t dist_start, dist_end, dist_sce; duk_uint_fast32_t char_length; @@ -51761,14 +50759,14 @@ #if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2) DUK_DDD(DUK_DDDPRINT("stringcache before char2byte (using cache):")); for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { - duk_strcache_entry *c = heap->strcache + 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_entry *c = heap->strcache + i; + duk_strcache *c = heap->strcache + i; if (c->h == h) { sce = c; @@ -51897,10 +50895,10 @@ * C <- sce ==> B * D D */ - duk_strcache_entry tmp; + duk_strcache tmp; tmp = *sce; - duk_memmove((void *) (&heap->strcache[1]), + DUK_MEMMOVE((void *) (&heap->strcache[1]), (const void *) (&heap->strcache[0]), (size_t) (((char *) sce) - ((char *) &heap->strcache[0]))); heap->strcache[0] = tmp; @@ -51910,7 +50908,7 @@ #if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2) DUK_DDD(DUK_DDDPRINT("stringcache after char2byte (using cache):")); for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { - duk_strcache_entry *c = heap->strcache + 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)); } @@ -51921,7 +50919,7 @@ scan_error: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + return 0; } #line 1 "duk_heap_stringtable.c" /* @@ -51980,7 +50978,7 @@ return; } - duk_memzero((void *) count_len, sizeof(count_len)); + DUK_MEMZERO((void *) count_len, sizeof(count_len)); for (i = 0; i < heap->st_size; i++) { h = DUK__HEAPPTR_DEC16(heap, strtable[i]); count_chain = 0; @@ -52092,7 +51090,7 @@ if (DUK_UNLIKELY(res == NULL)) { goto alloc_error; } - duk_memzero(res, sizeof(duk_hstring_external)); + DUK_MEMZERO(res, sizeof(duk_hstring_external)); #if defined(DUK_USE_EXPLICIT_NULL_INIT) DUK_HEAPHDR_STRING_INIT_NULLS(&res->hdr); #endif @@ -52112,14 +51110,14 @@ if (DUK_UNLIKELY(res == NULL)) { goto alloc_error; } - duk_memzero(res, sizeof(duk_hstring)); + 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_tmp = (duk_uint8_t *) (res + 1); - duk_memcpy(data_tmp, str, blen); + DUK_MEMCPY(data_tmp, str, blen); data_tmp[blen] = (duk_uint8_t) 0; data = (const duk_uint8_t *) data_tmp; } @@ -52612,12 +51610,11 @@ } lookup_hash &= 0xff; - curr = (duk_hstring *) DUK_LOSE_CONST(duk_rom_strings_lookup[lookup_hash]); + curr = DUK_LOSE_CONST(duk_rom_strings_lookup[lookup_hash]); while (curr != NULL) { - /* Unsafe memcmp() because for zero blen, str may be NULL. */ if (strhash == DUK_HSTRING_GET_HASH(curr) && blen == DUK_HSTRING_GET_BYTELEN(curr) && - duk_memcmp_unsafe((const void *) str, (const void *) DUK_HSTRING_GET_DATA(curr), blen) == 0) { + DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(curr), blen) == 0) { DUK_DDD(DUK_DDDPRINT("intern check: rom string: %!O, computed hash 0x%08lx, rom hash 0x%08lx", curr, (unsigned long) strhash, (unsigned long) DUK_HSTRING_GET_HASH(curr))); return curr; @@ -52637,7 +51634,6 @@ /* Preliminaries. */ - /* XXX: maybe just require 'str != NULL' even for zero size? */ DUK_ASSERT(heap != NULL); DUK_ASSERT(blen == 0 || str != NULL); DUK_ASSERT(blen <= DUK_HSTRING_MAX_BYTELEN); /* Caller is responsible for ensuring this. */ @@ -52656,7 +51652,7 @@ while (h != NULL) { if (DUK_HSTRING_GET_HASH(h) == strhash && DUK_HSTRING_GET_BYTELEN(h) == blen && - duk_memcmp_unsafe((const void *) str, (const void *) DUK_HSTRING_GET_DATA(h), (size_t) blen) == 0) { + DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(h), (size_t) blen) == 0) { /* Found existing entry. */ DUK_STATS_INC(heap, stats_strtab_intern_hit); return h; @@ -52729,67 +51725,10 @@ res = duk_heap_strtable_intern(thr->heap, str, blen); if (DUK_UNLIKELY(res == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } return res; } -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_LOCAL duk_uint_t duk__strtable_litcache_key(const duk_uint8_t *str, duk_uint32_t blen) { - duk_uintptr_t key; - - DUK_ASSERT(DUK_USE_LITCACHE_SIZE > 0); - DUK_ASSERT(DUK_IS_POWER_OF_TWO((duk_uint_t) DUK_USE_LITCACHE_SIZE)); - - key = (duk_uintptr_t) blen ^ (duk_uintptr_t) str; - key &= (duk_uintptr_t) (DUK_USE_LITCACHE_SIZE - 1); /* Assumes size is power of 2. */ - /* Due to masking, cast is in 32-bit range. */ - DUK_ASSERT(key <= DUK_UINT_MAX); - return (duk_uint_t) key; -} - -DUK_INTERNAL duk_hstring *duk_heap_strtable_intern_literal_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t blen) { - duk_uint_t key; - duk_litcache_entry *ent; - duk_hstring *h; - - /* Fast path check: literal exists in literal cache. */ - key = duk__strtable_litcache_key(str, blen); - ent = thr->heap->litcache + key; - if (ent->addr == str) { - DUK_DD(DUK_DDPRINT("intern check for cached, pinned literal: str=%p, blen=%ld -> duk_hstring %!O", - (const void *) str, (long) blen, (duk_heaphdr *) ent->h)); - DUK_ASSERT(ent->h != NULL); - DUK_ASSERT(DUK_HSTRING_HAS_PINNED_LITERAL(ent->h)); - DUK_STATS_INC(thr->heap, stats_strtab_litcache_hit); - return ent->h; - } - - /* Intern and update (overwrite) cache entry. */ - h = duk_heap_strtable_intern_checked(thr, str, blen); - ent->addr = str; - ent->h = h; - DUK_STATS_INC(thr->heap, stats_strtab_litcache_miss); - - /* Pin the duk_hstring until the next mark-and-sweep. This means - * litcache entries don't need to be invalidated until the next - * mark-and-sweep as their target duk_hstring is not freed before - * the mark-and-sweep happens. The pin remains even if the literal - * cache entry is overwritten, and is still useful to avoid string - * table traffic. - */ - if (!DUK_HSTRING_HAS_PINNED_LITERAL(h)) { - DUK_DD(DUK_DDPRINT("pin duk_hstring because it is a literal: %!O", (duk_heaphdr *) h)); - DUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) h)); - DUK_HSTRING_INCREF(thr, h); - DUK_HSTRING_SET_PINNED_LITERAL(h); - DUK_STATS_INC(thr->heap, stats_strtab_litcache_pin); - } - - return h; -} -#endif /* DUK_USE_LITCACHE_SIZE */ - DUK_INTERNAL duk_hstring *duk_heap_strtable_intern_u32_checked(duk_hthread *thr, duk_uint32_t val) { duk_hstring *res; @@ -52799,7 +51738,6 @@ res = duk_heap_strtable_intern_u32(thr->heap, val); if (DUK_UNLIKELY(res == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } return res; } @@ -53106,7 +52044,7 @@ if (!res) { return NULL; } - duk_memzero(res, sizeof(duk_hboundfunc)); + DUK_MEMZERO(res, sizeof(duk_hboundfunc)); duk__init_object_parts(heap, hobject_flags, &res->obj); @@ -53148,7 +52086,7 @@ if (DUK_UNLIKELY(res == NULL)) { return NULL; } - duk_memzero(res, sizeof(duk_hthread)); + DUK_MEMZERO(res, sizeof(duk_hthread)); duk__init_object_parts(heap, hobject_flags, &res->obj); @@ -53190,7 +52128,6 @@ res = duk_hthread_alloc_unchecked(thr->heap, hobject_flags); if (res == NULL) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } return res; } @@ -53407,7 +52344,7 @@ * are very often in order already. */ if (idx != idx_insert) { - duk_memmove((void *) (keys + idx_insert + 1), + DUK_MEMMOVE((void *) (keys + idx_insert + 1), (const void *) (keys + idx_insert), ((size_t) (idx - idx_insert) * sizeof(duk_hstring *))); keys[idx_insert] = h_curr; @@ -53891,7 +52828,7 @@ } /* - * Get enumerated keys in an ECMAScript array. Matches Object.keys() behavior + * Get enumerated keys in an Ecmascript array. Matches Object.keys() behavior * described in E5 Section 15.2.3.14. */ @@ -53978,7 +52915,6 @@ break; } else { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } } h = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h); @@ -54063,7 +52999,7 @@ (long) hdr[hdr_index + 1])); #endif - duk_memzero(be_ctx, sizeof(*be_ctx)); + DUK_MEMZERO(be_ctx, sizeof(*be_ctx)); be_ctx->data = ((duk_uint8_t *) hdr) + curr_offset; be_ctx->length = (duk_size_t) DUK_PC2LINE_MAX_DIFF_LENGTH; @@ -54174,7 +53110,7 @@ * Iterate the bitstream (line diffs) until PC is reached */ - duk_memzero(bd_ctx, sizeof(*bd_ctx)); + DUK_MEMZERO(bd_ctx, sizeof(*bd_ctx)); bd_ctx->data = ((duk_uint8_t *) hdr) + start_offset; bd_ctx->length = (duk_size_t) (DUK_HBUFFER_FIXED_GET_SIZE(buf) - start_offset); @@ -54234,7 +53170,7 @@ */ duk_get_prop_stridx(thr, idx_func, DUK_STRIDX_INT_PC2LINE); - pc2line = (duk_hbuffer_fixed *) (void *) duk_get_hbuffer(thr, -1); + pc2line = (duk_hbuffer_fixed *) duk_get_hbuffer(thr, -1); if (pc2line != NULL) { DUK_ASSERT(!DUK_HBUFFER_HAS_DYNAMIC((duk_hbuffer *) pc2line) && !DUK_HBUFFER_HAS_EXTERNAL((duk_hbuffer *) pc2line)); line = duk__hobject_pc2line_query_raw(thr, pc2line, (duk_uint_fast32_t) pc); @@ -54303,7 +53239,7 @@ #define DUK__HASH_DELETED DUK_HOBJECT_HASHIDX_DELETED /* Valstack space that suffices for all local calls, excluding any recursion - * into ECMAScript or Duktape/C calls (Proxy, getters, etc). + * into Ecmascript or Duktape/C calls (Proxy, getters, etc). */ #define DUK__VALSTACK_SPACE 10 @@ -54853,7 +53789,6 @@ if (new_e_size_adjusted + new_a_size > DUK_HOBJECT_MAX_PROPERTIES) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return;); } /* @@ -55057,14 +53992,18 @@ } else { array_copy_size = sizeof(duk_tval) * new_a_size; } - - DUK_ASSERT(new_a != NULL || array_copy_size == 0U); - DUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, obj) != NULL || array_copy_size == 0U); - DUK_ASSERT(DUK_HOBJECT_GET_ASIZE(obj) > 0 || array_copy_size == 0U); - duk_memcpy_unsafe((void *) new_a, - (const void *) DUK_HOBJECT_A_GET_BASE(thr->heap, obj), - array_copy_size); - + if (array_copy_size > 0) { + /* Avoid zero copy with an invalid pointer. If obj->p is NULL, + * the 'new_a' pointer will be invalid which is not allowed even + * when copy size is zero. + */ + DUK_ASSERT(new_a != NULL); + DUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, obj) != NULL); + DUK_ASSERT(DUK_HOBJECT_GET_ASIZE(obj) > 0); + DUK_MEMCPY((void *) new_a, + (const void *) DUK_HOBJECT_A_GET_BASE(thr->heap, obj), + array_copy_size); + } for (i = DUK_HOBJECT_GET_ASIZE(obj); i < new_a_size; i++) { duk_tval *tv = &new_a[i]; DUK_TVAL_SET_UNUSED(tv); @@ -55089,7 +54028,7 @@ /* fill new_h with u32 0xff = UNUSED */ DUK_ASSERT(new_h_size > 0); - duk_memset(new_h, 0xff, sizeof(duk_uint32_t) * new_h_size); + DUK_MEMSET(new_h, 0xff, sizeof(duk_uint32_t) * new_h_size); DUK_ASSERT(new_e_next <= new_h_size); /* equality not actually possible */ @@ -55199,7 +54138,6 @@ #endif DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return;); } /* @@ -55677,7 +54615,7 @@ /* This is not strictly necessary, but avoids compiler warnings; e.g. * gcc won't reliably detect that no uninitialized data is read below. */ - duk_memzero((void *) &tv, sizeof(duk_tval)); + DUK_MEMZERO((void *) &tv, sizeof(duk_tval)); if (duk_hobject_get_internal_value(heap, obj, &tv)) { duk_hstring *h; @@ -55865,7 +54803,7 @@ } /* - * ECMAScript compliant [[GetOwnProperty]](P), for internal use only. + * Ecmascript compliant [[GetOwnProperty]](P), for internal use only. * * If property is found: * - Fills descriptor fields to 'out_desc' @@ -56240,7 +55178,7 @@ } /* - * ECMAScript compliant [[GetProperty]](P), for internal use only. + * Ecmascript compliant [[GetProperty]](P), for internal use only. * * If property is found: * - Fills descriptor fields to 'out_desc' @@ -56297,7 +55235,6 @@ break; } else { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } } curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr); @@ -56579,7 +55516,7 @@ #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ /* - * GETPROP: ECMAScript property read. + * GETPROP: Ecmascript property read. */ DUK_INTERNAL duk_bool_t duk_hobject_getprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key) { @@ -56633,8 +55570,7 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot read property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); - break; + return 0; } case DUK_TAG_BOOLEAN: { @@ -56790,7 +55726,6 @@ !DUK_TVAL_IS_UNDEFINED(tv_hook); if (datadesc_reject || accdesc_reject) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } duk_pop_2_unsafe(thr); @@ -56982,7 +55917,6 @@ */ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr); } while (curr != NULL); @@ -57053,7 +55987,6 @@ DUK_HOBJECT_HAS_STRICT(h)) { /* XXX: sufficient to check 'strict', assert for 'is function' */ DUK_ERROR_TYPE(thr, DUK_STR_STRICT_CALLER_READ); - DUK_WO_NORETURN(return 0;); } } } @@ -57066,7 +55999,7 @@ } /* - * HASPROP: ECMAScript property existence check ("in" operator). + * HASPROP: Ecmascript property existence check ("in" operator). * * Interestingly, the 'in' operator does not do any coercion of * the target object. @@ -57132,7 +56065,6 @@ /* Note: unconditional throw */ DUK_DDD(DUK_DDDPRINT("base object is not an object -> reject")); DUK_ERROR_TYPE(thr, DUK_STR_INVALID_BASE); - DUK_WO_NORETURN(return 0;); } /* XXX: fast path for arrays? */ @@ -57157,7 +56089,7 @@ duk_push_hobject(thr, h_target); /* target */ duk_push_tval(thr, tv_key); /* P */ duk_call_method(thr, 2 /*nargs*/); - tmp_bool = duk_to_boolean_top_pop(thr); + tmp_bool = duk_to_boolean(thr, -1); if (!tmp_bool) { /* Target object must be checked for a conflicting * non-configurable property. @@ -57176,12 +56108,11 @@ if (!((desc.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && /* property is configurable and */ DUK_HOBJECT_HAS_EXTENSIBLE(h_target))) { /* ... target is extensible */ DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } } } - duk_pop_unsafe(thr); /* [ key ] -> [] */ + duk_pop_2_unsafe(thr); /* [ key trap_result ] -> [] */ return tmp_bool; } @@ -57273,7 +56204,7 @@ /* Refuse to update an Array's 'length' to a value outside the * 32-bit range. Negative zero is accepted as zero. */ - res = duk_double_to_uint32_t(d); + res = (duk_uint32_t) d; if ((duk_double_t) res != d) { goto fail_range; } @@ -57282,7 +56213,7 @@ fail_range: DUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARRAY_LENGTH); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } /* Delete elements required by a smaller length, taking into account @@ -57551,9 +56482,9 @@ } /* - * PUTPROP: ECMAScript property write. + * PUTPROP: Ecmascript property write. * - * Unlike ECMAScript primitive which returns nothing, returns 1 to indicate + * Unlike Ecmascript primitive which returns nothing, returns 1 to indicate * success and 0 to indicate failure (assuming throw is not set). * * This is an extremely tricky function. Some examples: @@ -57640,8 +56571,7 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot write property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); - break; + return 0; } case DUK_TAG_BOOLEAN: { @@ -57745,7 +56675,8 @@ duk_push_tval(thr, tv_val); /* V */ duk_push_tval(thr, tv_obj); /* Receiver: Proxy object */ duk_call_method(thr, 4 /*nargs*/); - tmp_bool = duk_to_boolean_top_pop(thr); + tmp_bool = duk_to_boolean(thr, -1); + duk_pop_nodecref_unsafe(thr); if (!tmp_bool) { goto fail_proxy_rejected; } @@ -57777,7 +56708,6 @@ (desc.set == NULL); if (datadesc_reject || accdesc_reject) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } duk_pop_2_unsafe(thr); @@ -58077,7 +57007,6 @@ */ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr); } while (curr != NULL); @@ -58427,7 +57356,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, proxy rejects")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } /* Note: no key on stack */ return 0; @@ -58442,7 +57370,6 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot write property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -58451,7 +57378,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, not extensible")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_EXTENSIBLE); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -58460,7 +57386,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, not writable")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_WRITABLE); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -58470,7 +57395,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, not writable")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_WRITABLE); - DUK_WO_NORETURN(return 0;); } return 0; #endif @@ -58479,7 +57403,6 @@ DUK_DD(DUK_DDPRINT("result: error, array length write only partially successful")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -58488,7 +57411,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, accessor property without setter")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_SETTER_UNDEFINED); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -58497,14 +57419,13 @@ DUK_DDD(DUK_DDDPRINT("result: error, internal")); if (throw_flag) { DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; } /* - * ECMAScript compliant [[Delete]](P, Throw). + * Ecmascript compliant [[Delete]](P, Throw). */ DUK_INTERNAL duk_bool_t duk_hobject_delprop_raw(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_small_uint_t flags) { @@ -58658,13 +57579,12 @@ if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } return 0; } /* - * DELPROP: ECMAScript property deletion. + * DELPROP: Ecmascript property deletion. */ DUK_INTERNAL duk_bool_t duk_hobject_delprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key, duk_bool_t throw_flag) { @@ -58719,7 +57639,8 @@ duk_push_hobject(thr, h_target); /* target */ duk_dup_m4(thr); /* P */ duk_call_method(thr, 2 /*nargs*/); - tmp_bool = duk_to_boolean_top_pop(thr); + tmp_bool = duk_to_boolean(thr, -1); + duk_pop_nodecref_unsafe(thr); if (!tmp_bool) { goto fail_proxy_rejected; /* retval indicates delete failed */ } @@ -58744,7 +57665,6 @@ if (desc_reject) { /* unconditional */ DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } } rc = 1; /* success */ @@ -58828,13 +57748,12 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot delete property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); + return 0; #if defined(DUK_USE_ES6_PROXY) fail_proxy_rejected: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } duk_set_top_unsafe(thr, entry_top); return 0; @@ -58843,7 +57762,6 @@ fail_not_configurable: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } duk_set_top_unsafe(thr, entry_top); return 0; @@ -58983,7 +57901,7 @@ error_virtual: /* share error message */ error_internal: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); + return; } /* @@ -59063,7 +57981,7 @@ val = duk_to_number_m1(thr); duk_pop_3_unsafe(thr); - /* This isn't part of ECMAScript semantics; return a value within + /* This isn't part of Ecmascript semantics; return a value within * duk_size_t range, or 0 otherwise. */ if (val >= 0.0 && val <= (duk_double_t) DUK_SIZE_MAX) { @@ -59174,7 +58092,7 @@ * NormalizePropertyDescriptor() related helper. * * Internal helper which validates and normalizes a property descriptor - * represented as an ECMAScript object (e.g. argument to defineProperty()). + * represented as an Ecmascript object (e.g. argument to defineProperty()). * The output of this conversion is a set of defprop_flags and possibly * some values pushed on the value stack to (1) ensure borrowed pointers * remain valid, and (2) avoid unnecessary pops for footprint reasons. @@ -59224,7 +58142,7 @@ if (duk_get_prop_stridx(thr, idx_in, DUK_STRIDX_WRITABLE)) { is_data_desc = 1; - if (duk_to_boolean_top_pop(thr)) { + if (duk_to_boolean(thr, -1)) { defprop_flags |= DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_WRITABLE; } else { defprop_flags |= DUK_DEFPROP_HAVE_WRITABLE; @@ -59276,7 +58194,7 @@ } if (duk_get_prop_stridx(thr, idx_in, DUK_STRIDX_ENUMERABLE)) { - if (duk_to_boolean_top_pop(thr)) { + if (duk_to_boolean(thr, -1)) { defprop_flags |= DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE; } else { defprop_flags |= DUK_DEFPROP_HAVE_ENUMERABLE; @@ -59284,7 +58202,7 @@ } if (duk_get_prop_stridx(thr, idx_in, DUK_STRIDX_CONFIGURABLE)) { - if (duk_to_boolean_top_pop(thr)) { + if (duk_to_boolean(thr, -1)) { defprop_flags |= DUK_DEFPROP_HAVE_CONFIGURABLE | DUK_DEFPROP_CONFIGURABLE; } else { defprop_flags |= DUK_DEFPROP_HAVE_CONFIGURABLE; @@ -59305,7 +58223,6 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_DESCRIPTOR); - DUK_WO_NORETURN(return;); } /* @@ -59314,7 +58231,7 @@ * * Inlines all [[DefineOwnProperty]] exotic behaviors. * - * Note: ECMAScript compliant [[DefineOwnProperty]](P, Desc, Throw) is not + * Note: Ecmascript compliant [[DefineOwnProperty]](P, Desc, Throw) is not * implemented directly, but Object.defineProperty() serves its purpose. * We don't need the [[DefineOwnProperty]] internally and we don't have a * property descriptor with 'missing values' so it's easier to avoid it @@ -60187,7 +59104,6 @@ fail_not_extensible: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_EXTENSIBLE); - DUK_WO_NORETURN(return 0;); } return 0; @@ -60195,7 +59111,6 @@ fail_not_configurable: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } return 0; } @@ -60251,7 +59166,6 @@ if (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) { DUK_DD(DUK_DDPRINT("attempt to seal/freeze a readonly object, reject")); DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return;); } #endif @@ -60400,7 +59314,7 @@ (const void *) p_start, (const void *) p_end, (const void *) p)); - /* For invalid UTF-8 (never happens for standard ECMAScript strings) + /* For invalid UTF-8 (never happens for standard Ecmascript strings) * return U+FFFD replacement character. */ if (duk_unicode_decode_xutf8(thr, &p, p_start, p_end, &cp1)) { @@ -60556,7 +59470,7 @@ if (len != DUK_HSTRING_GET_BYTELEN(h)) { return 0; } - if (duk_memcmp((const void *) cstr, (const void *) DUK_HSTRING_GET_DATA(h), len) == 0) { + if (DUK_MEMCMP((const void *) cstr, (const void *) DUK_HSTRING_GET_DATA(h), len) == 0) { return 1; } return 0; @@ -60594,7 +59508,7 @@ if (!thr->valstack) { goto fail; } - duk_memzero(thr->valstack, alloc_size); + DUK_MEMZERO(thr->valstack, alloc_size); thr->valstack_end = thr->valstack + DUK_VALSTACK_API_ENTRY_MINIMUM; thr->valstack_alloc_end = thr->valstack + DUK_VALSTACK_INITIAL_SIZE; thr->valstack_bottom = thr->valstack; @@ -60699,7 +59613,7 @@ props = DUK_ALLOC_CHECKED(thr, alloc_size); DUK_ASSERT(props != NULL); DUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, h_oldglobal) != NULL); - duk_memcpy((void *) props, (const void *) DUK_HOBJECT_GET_PROPS(thr->heap, h_oldglobal), alloc_size); + DUK_MEMCPY((void *) props, (const void *) DUK_HOBJECT_GET_PROPS(thr->heap, h_oldglobal), alloc_size); /* XXX: keep property attributes or tweak them here? * Properties will now be non-configurable even when they're @@ -60826,7 +59740,7 @@ DUK_D(DUK_DPRINT("INITBUILTINS BEGIN: DUK_NUM_BUILTINS=%d, DUK_NUM_BUILTINS_ALL=%d", (int) DUK_NUM_BUILTINS, (int) DUK_NUM_ALL_BUILTINS)); - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); bd->data = (const duk_uint8_t *) duk_builtins_data; bd->length = (duk_size_t) DUK_BUILTINS_DATA_LENGTH; @@ -61068,9 +59982,11 @@ * signaled using a single flag bit in the bitstream. */ - defprop_flags = (duk_small_uint_t) duk_bd_decode_flagged(bd, - DUK__PROP_FLAGS_BITS, - (duk_uint32_t) DUK_PROPDESC_FLAGS_WC); + if (duk_bd_decode_flag(bd)) { + defprop_flags = (duk_small_uint_t) duk_bd_decode(bd, DUK__PROP_FLAGS_BITS); + } else { + defprop_flags = DUK_PROPDESC_FLAGS_WC; + } defprop_flags |= DUK_DEFPROP_FORCE | DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | @@ -61175,7 +60091,6 @@ #if defined(DUK_USE_LIGHTFUNC_BUILTINS) duk_small_int_t lightfunc_eligible; #endif - duk_small_uint_t defprop_flags; duk__push_stridx_or_string(thr, bd); h_key = duk_known_hstring(thr, -1); @@ -61295,19 +60210,10 @@ lightfunc_skip: #endif - defprop_flags = (duk_small_uint_t) duk_bd_decode_flagged(bd, - DUK__PROP_FLAGS_BITS, - (duk_uint32_t) DUK_PROPDESC_FLAGS_WC); - defprop_flags |= DUK_DEFPROP_FORCE | - DUK_DEFPROP_HAVE_VALUE | - DUK_DEFPROP_HAVE_WRITABLE | - DUK_DEFPROP_HAVE_ENUMERABLE | - DUK_DEFPROP_HAVE_CONFIGURABLE; - DUK_ASSERT(DUK_PROPDESC_FLAG_WRITABLE == DUK_DEFPROP_WRITABLE); - DUK_ASSERT(DUK_PROPDESC_FLAG_ENUMERABLE == DUK_DEFPROP_ENUMERABLE); - DUK_ASSERT(DUK_PROPDESC_FLAG_CONFIGURABLE == DUK_DEFPROP_CONFIGURABLE); - - duk_def_prop(thr, (duk_idx_t) i, defprop_flags); + /* XXX: So far all ES builtins are 'wc' but e.g. + * performance.now() should be 'wec'. + */ + duk_xdef_prop(thr, (duk_idx_t) i, DUK_PROPDESC_FLAGS_WC); /* [ (builtin objects) ] */ } @@ -61380,7 +60286,7 @@ "f" #endif " " - /* Low memory/performance options */ + /* Low memory options */ #if defined(DUK_USE_STRTAB_PTRCOMP) "s" #endif @@ -61421,9 +60327,6 @@ */ "Z" #endif -#if defined(DUK_USE_LITCACHE_SIZE) - "l" -#endif " " /* Object property allocation layout */ #if defined(DUK_USE_HOBJECT_LAYOUT_1) @@ -62000,8 +60903,8 @@ /* Use DUK_ALLOC_RAW() to avoid side effects. */ new_ptr = (duk_tval *) DUK_ALLOC_RAW(thr->heap, alloc_size); if (new_ptr != NULL) { - duk_memcpy((void *) new_ptr, (const void *) thr->valstack, alloc_size); - duk_memset((void *) thr->valstack, 0x55, alloc_size); + DUK_MEMCPY((void *) new_ptr, (const void *) thr->valstack, alloc_size); + DUK_MEMSET((void *) thr->valstack, 0x55, alloc_size); DUK_FREE_CHECKED(thr, (void *) thr->valstack); thr->valstack = new_ptr; thr->valstack_alloc_end = (duk_tval *) ((duk_uint8_t *) new_ptr + alloc_end_off); @@ -62020,7 +60923,7 @@ /* #include duk_internal.h -> already included */ -/* ECMAScript modulus ('%') does not match IEEE 754 "remainder" operation +/* Ecmascript modulus ('%') does not match IEEE 754 "remainder" operation * (implemented by remainder() in C99) but does seem to match ANSI C fmod(). * Compare E5 Section 11.5.3 and "man fmod". */ @@ -62074,9 +60977,9 @@ /* Shared helper for Math.pow() and exponentiation operator. */ DUK_INTERNAL double duk_js_arith_pow(double x, double y) { - /* The ANSI C pow() semantics differ from ECMAScript. + /* The ANSI C pow() semantics differ from Ecmascript. * - * E.g. when x==1 and y is +/- infinite, the ECMAScript required + * E.g. when x==1 and y is +/- infinite, the Ecmascript required * result is NaN, while at least Linux pow() returns 1. */ @@ -62157,7 +61060,7 @@ * * duk_handle_call_unprotected(): * - * - Unprotected call to ECMAScript or Duktape/C function, from native + * - Unprotected call to Ecmascript or Duktape/C function, from native * code or bytecode executor. * * - Also handles Ecma-to-Ecma calls which reuses a currently running @@ -62211,7 +61114,6 @@ DUK_D(DUK_DPRINT("call prevented because C recursion limit reached")); DUK_ERROR_RANGE(thr, DUK_STR_C_CALLSTACK_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL DUK_ALWAYS_INLINE void duk__call_c_recursion_limit_check(duk_hthread *thr) { @@ -62247,7 +61149,6 @@ */ DUK_D(DUK_DPRINT("call prevented because call stack limit reached")); DUK_ERROR_RANGE(thr, DUK_STR_CALLSTACK_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL DUK_ALWAYS_INLINE void duk__call_callstack_limit_check(duk_hthread *thr) { @@ -62661,7 +61562,6 @@ if (DUK_UNLIKELY(proxy_invariant != 0U)) { /* Proxy 'construct' return value invariant violated. */ DUK_ERROR_TYPE_INVALID_TRAP_RESULT(thr); - DUK_WO_NORETURN(return;); } /* XXX: direct value stack access */ duk_pop(thr); @@ -62722,7 +61622,7 @@ duk_tval *tv_args; duk_tval *tv_gap; - h_bound = (duk_hboundfunc *) (void *) func; + h_bound = (duk_hboundfunc *) func; tv_args = h_bound->args; len = h_bound->nargs; DUK_ASSERT(len == 0 || tv_args != NULL); @@ -62762,7 +61662,6 @@ } else { /* Shouldn't happen, so ugly error is enough. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); } DUK_ASSERT(duk_get_top(thr) >= idx_func + 2); @@ -62938,13 +61837,11 @@ if (top < idx_func + 3) { /* argArray is a mandatory argument for Reflect.construct(). */ DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); } if (top > idx_func + 3) { if (!duk_strict_equals(thr, idx_func, idx_func + 3)) { /* XXX: [[Construct]] newTarget currently unsupported */ DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } duk_set_top_unsafe(thr, idx_func + 3); /* remove any args beyond argArray */ } @@ -63481,7 +62378,6 @@ if (duk_hobject_find_existing_entry_tval_ptr(thr->heap, DUK_TVAL_GET_OBJECT(tv_func), DUK_HTHREAD_STRING_INT_TARGET(thr)) != NULL) { duk_push_tval(thr, tv_func); (void) duk_throw(thr); - DUK_WO_NORETURN(return NULL;); } } #endif @@ -63495,7 +62391,8 @@ #else DUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE); #endif - DUK_WO_NORETURN(return NULL;); + DUK_UNREACHABLE(); + return NULL; /* never executed */ not_constructable: /* For now GETPROPC delayed error not needed for constructor calls. */ @@ -63508,7 +62405,8 @@ #else DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONSTRUCTABLE); #endif - DUK_WO_NORETURN(return NULL;); + DUK_UNREACHABLE(); + return NULL; /* never executed */ } /* @@ -63532,7 +62430,6 @@ idx_rcbase = duk_get_top(thr) - num_actual_rets; /* base of known return values */ if (DUK_UNLIKELY(idx_rcbase < 0)) { DUK_ERROR_TYPE(thr, DUK_STR_INVALID_CFUNC_RC); - DUK_WO_NORETURN(return;); } DUK_DDD(DUK_DDDPRINT("adjust valstack after func call: " @@ -63667,10 +62564,9 @@ * - Disable StepOut processing for the activation unwind because * we reuse the activation, see: * https://github.com/svaarala/duktape/issues/1684. - * - Disable line change pause flag permanently if act == dbg_pause_act - * (if set) because it would no longer be relevant, see: - * https://github.com/svaarala/duktape/issues/1726, - * https://github.com/svaarala/duktape/issues/1786. + * - Disable line change pause flag permanently (if set) because + * it would no longer be relevant, see: + * https://github.com/svaarala/duktape/issues/1726. * - Check for function entry (e.g. StepInto) pause flag here, because * the executor pause check won't trigger due to shared activation, see: * https://github.com/svaarala/duktape/issues/1726. @@ -63691,12 +62587,9 @@ DUK_ASSERT(thr->callstack_top > 0); DUK_ASSERT(thr->callstack_curr != NULL); #if defined(DUK_USE_DEBUGGER_SUPPORT) - if (act == thr->heap->dbg_pause_act) { - thr->heap->dbg_pause_flags &= ~DUK_PAUSE_FLAG_LINE_CHANGE; - } - prev_pause_act = thr->heap->dbg_pause_act; thr->heap->dbg_pause_act = NULL; + thr->heap->dbg_pause_flags &= ~DUK_PAUSE_FLAG_LINE_CHANGE; if (thr->heap->dbg_pause_flags & DUK_PAUSE_FLAG_FUNC_ENTRY) { DUK_D(DUK_DPRINT("PAUSE TRIGGERED by function entry (tailcall)")); duk_debug_set_paused(thr->heap); @@ -63836,10 +62729,10 @@ * Update return value stack index of current activation (if any). * * Although it might seem this is not necessary (bytecode executor - * does this for ECMAScript-to-ECMAScript calls; other calls are + * does this for Ecmascript-to-Ecmascript calls; other calls are * handled here), this turns out to be necessary for handling yield - * and resume. For them, an ECMAScript-to-native call happens, and - * the ECMAScript call's retval_byteoff must be set for things to work. + * and resume. For them, an Ecmascript-to-native call happens, and + * the Ecmascript call's retval_byteoff must be set for things to work. */ act->retval_byteoff = entry_valstack_bottom_byteoff + (duk_size_t) idx_func * sizeof(duk_tval); @@ -64046,16 +62939,16 @@ thread_state_error: DUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, "invalid thread state (%ld)", (long) thr->state); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); } /* * Main unprotected call handler, handles: * - * - All combinations of native/ECMAScript caller and native/ECMAScript + * - All combinations of native/Ecmascript caller and native/Ecmascript * target. * - * - Optimized ECMAScript-to-ECMAScript call where call handling only + * - Optimized Ecmascript-to-Ecmascript call where call handling only * sets up a new duk_activation but reuses an existing bytecode executor * (the caller) without native recursion. * @@ -64104,7 +62997,7 @@ DUK_STATS_INC(thr->heap, stats_call_all); /* If a tail call: - * - an ECMAScript activation must be on top of the callstack + * - an Ecmascript activation must be on top of the callstack * - there cannot be any catch stack entries that would catch * a return */ @@ -64209,12 +63102,6 @@ * Because 'act' is not zeroed, all fields must be filled in. */ - /* Should not be necessary, but initialize to silence warnings. */ - act = NULL; - nargs = 0; - nregs = 0; - vs_min_bytes = 0; - #if defined(DUK_USE_TAILCALL) use_tailcall = (call_flags & DUK_CALL_FLAG_TAILCALL); if (use_tailcall) { @@ -64262,7 +63149,7 @@ * compiler; the compiled function's parent env will contain * the (immutable) binding already. * - * This handling is now identical for C and ECMAScript functions. + * This handling is now identical for C and Ecmascript functions. * C functions always have the 'NEWENV' flag set, so their * environment record initialization is delayed (which is good). * @@ -64309,7 +63196,7 @@ if (func != NULL && DUK_HOBJECT_IS_COMPFUNC(func)) { /* - * ECMAScript call. + * Ecmascript call. */ DUK_ASSERT(func != NULL); @@ -64403,10 +63290,9 @@ ; } else if (rc < 0) { duk_error_throw_from_negative_rc(thr, rc); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); } else { DUK_ERROR_TYPE(thr, DUK_STR_INVALID_CFUNC_RC); - DUK_WO_NORETURN(return 0;); } } DUK_ASSERT(thr->ptr_curr_pc == NULL); @@ -64494,7 +63380,7 @@ * calls caused by side effects (e.g. when doing a DUK_OP_GETPROP), see * GH-303. Only needed for success path, error path always causes a * breakpoint recheck in the executor. It would be enough to set this - * only when returning to an ECMAScript activation, but setting the flag + * only when returning to an Ecmascript activation, but setting the flag * on every return should have no ill effect. */ #if defined(DUK_USE_DEBUGGER_SUPPORT) @@ -64606,7 +63492,6 @@ if (DUK_UNLIKELY(rc < 0)) { duk_error_throw_from_negative_rc(thr, rc); - DUK_WO_NORETURN(return;); } DUK_ASSERT(rc >= 0); @@ -64884,10 +63769,7 @@ retval = DUK_EXEC_ERROR; } #if defined(DUK_USE_CPP_EXCEPTIONS) - catch (duk_fatal_exception &exc) { - DUK_D(DUK_DPRINT("rethrow duk_fatal_exception")); - throw; - } catch (std::exception &exc) { + catch (std::exception &exc) { const char *what = exc.what(); DUK_ASSERT((duk_size_t) ((duk_uint8_t *) thr->valstack_end - (duk_uint8_t *) thr->valstack) >= entry_valstack_end_byteoff); DUK_STATS_INC(thr->heap, stats_safecall_throw); @@ -64897,7 +63779,6 @@ DUK_D(DUK_DPRINT("unexpected c++ std::exception (perhaps thrown by user code)")); try { DUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, "caught invalid c++ std::exception '%s' (perhaps thrown by user code)", what); - DUK_WO_NORETURN(return 0;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ std::exception")); DUK_UNREF(exc); @@ -64920,7 +63801,6 @@ DUK_STATS_INC(thr->heap, stats_safecall_throw); try { DUK_ERROR_TYPE(thr, "caught invalid c++ exception (perhaps thrown by user code)"); - DUK_WO_NORETURN(return 0;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ exception")); DUK_UNREF(exc); @@ -64980,7 +63860,7 @@ /* * Property-based call (foo.noSuch()) error setup: replace target function * on stack top with a specially tagged (hidden Symbol) error which gets - * thrown in call handling at the proper spot to follow ECMAScript semantics. + * thrown in call handling at the proper spot to follow Ecmascript semantics. */ #if defined(DUK_USE_VERBOSE_ERRORS) @@ -65039,7 +63919,7 @@ #undef DUK__AUGMENT_CALL_RELAX_COUNT #line 1 "duk_js_compiler.c" /* - * ECMAScript compiler. + * Ecmascript compiler. * * Parses an input string and generates a function template result. * Compilation may happen in multiple contexts (global code, eval @@ -65275,9 +64155,9 @@ DUK_LOCAL_DECL void duk__parse_with_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res); DUK_LOCAL_DECL void duk__parse_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_bool_t allow_source_elem); DUK_LOCAL_DECL duk_int_t duk__stmt_label_site(duk_compiler_ctx *comp_ctx, duk_int_t label_id); -DUK_LOCAL_DECL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof, duk_bool_t regexp_after); +DUK_LOCAL_DECL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof); -DUK_LOCAL_DECL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_bool_t regexp_after, duk_small_int_t expect_token); +DUK_LOCAL_DECL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_small_int_t expect_token); DUK_LOCAL_DECL void duk__parse_func_formals(duk_compiler_ctx *comp_ctx); DUK_LOCAL_DECL void duk__parse_func_like_raw(duk_compiler_ctx *comp_ctx, duk_small_uint_t flags); DUK_LOCAL_DECL duk_int_t duk__parse_func_like_fnum(duk_compiler_ctx *comp_ctx, duk_small_uint_t flags); @@ -65449,7 +64329,6 @@ DUK_ASSERT(comp_ctx->recursion_depth >= 0); if (comp_ctx->recursion_depth >= comp_ctx->recursion_limit) { DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_COMPILER_RECURSION_LIMIT); - DUK_WO_NORETURN(return;); } comp_ctx->recursion_depth++; } @@ -65504,20 +64383,15 @@ comp_ctx->curr_func.reject_regexp_in_adv = 0; regexp = 0; } - if (comp_ctx->curr_func.allow_regexp_in_adv) { - comp_ctx->curr_func.allow_regexp_in_adv = 0; - regexp = 1; - } if (expect >= 0 && comp_ctx->curr_token.t != (duk_small_uint_t) expect) { DUK_D(DUK_DPRINT("parse error: expect=%ld, got=%ld", (long) expect, (long) comp_ctx->curr_token.t)); DUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR); - DUK_WO_NORETURN(return;); } /* make current token the previous; need to fiddle with valstack "backing store" */ - duk_memcpy(&comp_ctx->prev_token, &comp_ctx->curr_token, sizeof(duk_token)); + DUK_MEMCPY(&comp_ctx->prev_token, &comp_ctx->curr_token, sizeof(duk_token)); duk_copy(thr, comp_ctx->tok11_idx, comp_ctx->tok21_idx); duk_copy(thr, comp_ctx->tok12_idx, comp_ctx->tok22_idx); @@ -65565,7 +64439,7 @@ entry_top = duk_get_top(thr); - duk_memzero(func, sizeof(*func)); /* intentional overlap with earlier memzero */ + DUK_MEMZERO(func, sizeof(*func)); /* intentional overlap with earlier memzero */ #if defined(DUK_USE_EXPLICIT_NULL_INIT) func->h_name = NULL; func->h_consts = NULL; @@ -65812,7 +64686,7 @@ (long) code_size, (long) data_size)); duk_push_fixed_buffer_nozero(thr, data_size); - h_data = (duk_hbuffer_fixed *) (void *) duk_known_hbuffer(thr, -1); + h_data = (duk_hbuffer_fixed *) duk_known_hbuffer(thr, -1); DUK_HCOMPFUNC_SET_DATA(thr->heap, h_res, (duk_hbuffer *) h_data); DUK_HEAPHDR_INCREF(thr, h_data); @@ -66017,7 +64891,7 @@ */ #if 0 - duk_push_literal(thr, "XXX"); + duk_push_string(thr, "XXX"); duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_INT_SOURCE, DUK_PROPDESC_FLAGS_NONE); #endif } @@ -66216,7 +65090,6 @@ fail_bc_limit: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_BYTECODE_LIMIT); - DUK_WO_NORETURN(return;); } /* Update function min/max line from current token. Needed to improve @@ -66501,7 +65374,6 @@ error_outofregs: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } /* For many of the helpers below it'd be technically correct to add @@ -66600,7 +65472,6 @@ error_outofregs: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__emit_bc(duk_compiler_ctx *comp_ctx, duk_small_uint_t op, duk_regconst_t bc) { @@ -66635,7 +65506,6 @@ error_outofregs: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__emit_load_int32_raw(duk_compiler_ctx *comp_ctx, duk_regconst_t reg, duk_int32_t val, duk_small_uint_t op_flags) { @@ -66733,7 +65603,6 @@ fail_bc_limit: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_BYTECODE_LIMIT); - DUK_WO_NORETURN(return;); } /* Does not assume that jump_pc contains a DUK_OP_JUMP previously; this is intentional @@ -66789,7 +65658,6 @@ DUK_D(DUK_DPRINT("failed to patch trycatch: flags=%ld, reg_catch=%ld, const_varname=%ld (0x%08lx)", (long) flags, (long) reg_catch, (long) const_varname, (long) const_varname)); DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } instr->ins |= DUK_ENC_OP_A_BC(0, 0, const_varname); } else { @@ -66981,7 +65849,6 @@ if (comp_ctx->curr_func.temp_next > DUK__MAX_TEMPS) { /* == DUK__MAX_TEMPS is OK */ DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_TEMP_LIMIT); - DUK_WO_NORETURN(return 0;); } /* maintain highest 'used' temporary, needed to figure out nregs of function */ @@ -67041,7 +65908,6 @@ if (n > DUK__MAX_CONSTS) { DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_CONST_LIMIT); - DUK_WO_NORETURN(return 0;); } DUK_DDD(DUK_DDDPRINT("allocating new constant for %!T -> const index %ld", @@ -67215,7 +66081,6 @@ } } } /* end switch */ - goto fail_internal; /* never here */ } case DUK_ISPEC_REGCONST: { if (forced_reg >= 0) { @@ -67248,13 +66113,12 @@ return x->regconst; } default: { - break; /* never here */ + break; } } - fail_internal: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_LOCAL void duk__ispec_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ispec *x, duk_regconst_t forced_reg) { @@ -67327,10 +66191,7 @@ break; } case DUK_OP_DIV: { - /* Division-by-zero is undefined - * behavior, so rely on a helper. - */ - d3 = duk_double_div(d1, d2); + d3 = d1 / d2; break; } case DUK_OP_EXP: { @@ -67357,7 +66218,7 @@ } } else if (x->op == DUK_OP_ADD && DUK_TVAL_IS_STRING(tv1) && DUK_TVAL_IS_STRING(tv2)) { /* Inline string concatenation. No need to check for - * symbols, as all inputs are valid ECMAScript strings. + * symbols, as all inputs are valid Ecmascript strings. */ duk_dup(thr, x->x1.valstack_idx); duk_dup(thr, x->x2.valstack_idx); @@ -67455,7 +66316,7 @@ } DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); + return; } /* evaluate to plain value, no forced register (temp/bound reg both ok) */ @@ -67687,7 +66548,6 @@ if (li->h_label == h_label && h_label != DUK_HTHREAD_STRING_EMPTY_STRING(thr)) { DUK_ERROR_SYNTAX(thr, DUK_STR_DUPLICATE_LABEL); - DUK_WO_NORETURN(return;); } } @@ -67817,7 +66677,6 @@ */ if (h_label != DUK_HTHREAD_STRING_EMPTY_STRING(thr)) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LABEL); - DUK_WO_NORETURN(return;); } else { DUK_DDD(DUK_DDDPRINT("continue matched an empty label which does not " "allow a continue -> continue lookup deeper in label stack")); @@ -67827,7 +66686,6 @@ /* XXX: match flag is awkward, rework */ if (!match) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LABEL); - DUK_WO_NORETURN(return;); } DUK_DDD(DUK_DDDPRINT("label match: %!O -> label_id %ld, catch_depth=%ld, pc_label=%ld", @@ -68017,7 +66875,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_ARRAY_LITERAL); - DUK_WO_NORETURN(return;); } typedef struct { @@ -68294,14 +67151,13 @@ #endif DUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_RCURLY); - duk__advance(comp_ctx); /* No RegExp after object literal. */ + duk__advance(comp_ctx); duk__ivalue_regconst(res, st.reg_obj); return; syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_OBJECT_LITERAL); - DUK_WO_NORETURN(return;); } /* Parse argument list. Arguments are written to temps starting from @@ -68345,7 +67201,7 @@ } /* eat the right paren */ - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* RegExp mode does not matter. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); DUK_DDD(DUK_DDDPRINT("end parsing arguments")); @@ -68478,7 +67334,7 @@ duk__expr(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); /* Expression, terminates at a ')' */ - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* No RegExp after parenthesized expression. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); comp_ctx->curr_func.allow_in = prev_allow_in; comp_ctx->curr_func.paren_level--; return; @@ -68613,7 +67469,6 @@ if (comp_ctx->curr_func.is_strict) { DUK_ERROR_SYNTAX(thr, DUK_STR_CANNOT_DELETE_IDENTIFIER); - DUK_WO_NORETURN(return;); } DUK__SETTEMP(comp_ctx, temp_at_entry); @@ -68778,7 +67633,7 @@ } /* end switch */ DUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR); - DUK_WO_NORETURN(return;); + return; unary: { @@ -68882,12 +67737,10 @@ #if defined(DUK_USE_ES6) syntax_error_newtarget: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_NEWTARGET); - DUK_WO_NORETURN(return;); #endif syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_EXPRESSION); - DUK_WO_NORETURN(return;); } /* XXX: add flag to indicate whether caller cares about return value; this @@ -68942,7 +67795,6 @@ /* NB: must accept reserved words as property name */ if (comp_ctx->curr_token.t_nores != DUK_TOK_IDENTIFIER) { DUK_ERROR_SYNTAX(thr, DUK_STR_EXPECTED_IDENTIFIER); - DUK_WO_NORETURN(return;); } res->t = DUK_IVAL_PROP; @@ -69372,7 +68224,7 @@ DUK_D(DUK_DPRINT("parse error: unexpected token: %ld", (long) tok)); DUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR); - DUK_WO_NORETURN(return;); + return; #if 0 /* XXX: shared handling for 'duk__expr_lhs'? */ @@ -69602,7 +68454,7 @@ * one instruction, so use explicit PC computation. */ DUK_DD(DUK_DDPRINT("rhs is side effect free, rewind and avoid unnecessary temp for reg-based =")); - DUK_BW_ADD_PTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, (pc_temp_load - pc_before_rhs) * (duk_int_t) sizeof(duk_compiler_instr)); + DUK_BW_ADD_PTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, (duk_size_t) (pc_temp_load - pc_before_rhs) * sizeof(duk_compiler_instr)); reg_src = reg_varbind; } else { DUK_DD(DUK_DDPRINT("rhs evaluation emitted code, not sure if rhs is side effect free; use temp reg for LHS")); @@ -69862,11 +68714,11 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_EXPRESSION); - DUK_WO_NORETURN(return;); + return; syntax_error_lvalue: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LVALUE); - DUK_WO_NORETURN(return;); + return; } DUK_LOCAL duk_small_uint_t duk__expr_lbp(duk_compiler_ctx *comp_ctx) { @@ -69931,7 +68783,7 @@ (long) rbp_flags, (long) rbp, (long) comp_ctx->curr_func.allow_in, (long) comp_ctx->curr_func.paren_level)); - duk_memzero(&tmp_alloc, sizeof(tmp_alloc)); + DUK_MEMZERO(&tmp_alloc, sizeof(tmp_alloc)); tmp->x1.valstack_idx = duk_get_top(thr); tmp->x2.valstack_idx = tmp->x1.valstack_idx + 1; duk_push_undefined(thr); @@ -69951,7 +68803,6 @@ DUK_DDD(DUK_DDDPRINT("empty expression")); if (!(rbp_flags & DUK__EXPR_FLAG_ALLOW_EMPTY)) { DUK_ERROR_SYNTAX(thr, DUK_STR_EMPTY_EXPR_NOT_ALLOWED); - DUK_WO_NORETURN(return;); } duk_push_undefined(thr); duk__ivalue_plain_fromstack(comp_ctx, res); @@ -69990,7 +68841,6 @@ if (!(rbp_flags & DUK__EXPR_FLAG_ALLOW_EMPTY) && duk__expr_is_empty(comp_ctx)) { DUK_ERROR_SYNTAX(thr, DUK_STR_EMPTY_EXPR_NOT_ALLOWED); - DUK_WO_NORETURN(return;); } } @@ -70183,7 +69033,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_VAR_DECLARATION); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_var_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t expr_flags) { @@ -70415,8 +69264,7 @@ } DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); pc_l3 = duk__get_current_pc(comp_ctx); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -70507,8 +69355,7 @@ pc_jumpto_l4 = duk__emit_jump_empty(comp_ctx); DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); pc_l3 = duk__get_current_pc(comp_ctx); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -70557,7 +69404,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_FOR); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_switch_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site) { @@ -70599,7 +69445,7 @@ duk__advance(comp_ctx); duk__advance_expect(comp_ctx, DUK_TOK_LPAREN); rc_switch = duk__exprtop_toregconst(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* RegExp mode does not matter. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__advance_expect(comp_ctx, DUK_TOK_LCURLY); DUK_DDD(DUK_DDDPRINT("switch value in register %ld", (long) rc_switch)); @@ -70724,8 +69570,7 @@ } DUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_RCURLY); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance(comp_ctx); /* Allow RegExp as part of next stmt. */ + duk__advance(comp_ctx); /* default case control flow patchup; note that if pc_prevcase < 0 * (i.e. no case clauses), control enters default case automatically. @@ -70758,7 +69603,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_SWITCH); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_if_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res) { @@ -70778,8 +69622,7 @@ pc_jump_false = duk__emit_jump_empty(comp_ctx); /* jump to end or else part */ DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -70815,7 +69658,7 @@ DUK_DDD(DUK_DDDPRINT("begin parsing do statement")); - duk__advance(comp_ctx); /* Eat 'do'; allow RegExp as part of next stmt. */ + duk__advance(comp_ctx); /* eat 'do' */ pc_start = duk__get_current_pc(comp_ctx); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -70829,7 +69672,6 @@ duk__emit_jump(comp_ctx, pc_start); /* no need to reset temps, as we're finished emitting code */ - comp_ctx->curr_func.allow_regexp_in_adv = 1; /* Allow RegExp as part of next stmt. */ duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__patch_jump_here(comp_ctx, pc_label_site + 1); /* break jump */ @@ -70859,8 +69701,7 @@ pc_jump_false = duk__emit_jump_empty(comp_ctx); DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); duk__emit_jump(comp_ctx, pc_start); @@ -70896,7 +69737,6 @@ duk__advance(comp_ctx); } else { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_BREAK_CONT_LABEL); - DUK_WO_NORETURN(return;); } /* Use a fast break/continue when possible. A fast break/continue is @@ -70938,7 +69778,6 @@ */ if (!comp_ctx->curr_func.is_function) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_RETURN); - DUK_WO_NORETURN(return;); } if (comp_ctx->curr_token.t == DUK_TOK_SEMICOLON || /* explicit semi follows */ @@ -71040,7 +69879,6 @@ if (comp_ctx->curr_token.lineterm) { DUK_ERROR_SYNTAX(comp_ctx->thr, DUK_STR_INVALID_THROW); - DUK_WO_NORETURN(return;); } reg_val = duk__exprtop_toreg(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); @@ -71097,9 +69935,10 @@ /* try part */ duk__advance_expect(comp_ctx, DUK_TOK_LCURLY); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ - duk__emit_op_only(comp_ctx, DUK_OP_ENDTRY); + duk__emit_op_only(comp_ctx, + DUK_OP_ENDTRY); if (comp_ctx->curr_token.t == DUK_TOK_CATCH) { /* @@ -71195,7 +70034,7 @@ DUK_DDD(DUK_DDDPRINT("varmap before parsing catch clause: %!iT", (duk_tval *) duk_get_tval(thr, comp_ctx->curr_func.varmap_idx))); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ if (varmap_value == -2) { @@ -71237,7 +70076,7 @@ duk__advance(comp_ctx); duk__advance_expect(comp_ctx, DUK_TOK_LCURLY); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ duk__emit_abc(comp_ctx, DUK_OP_ENDFIN, @@ -71280,7 +70119,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_TRY); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_with_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res) { @@ -71291,7 +70129,6 @@ if (comp_ctx->curr_func.is_strict) { DUK_ERROR_SYNTAX(comp_ctx->thr, DUK_STR_WITH_IN_STRICT_MODE); - DUK_WO_NORETURN(return;); } comp_ctx->curr_func.catch_depth++; @@ -71302,8 +70139,7 @@ duk__advance_expect(comp_ctx, DUK_TOK_LPAREN); duk__exprtop_toforcedreg(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/, reg_catch); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); pc_trycatch = duk__get_current_pc(comp_ctx); trycatch_flags = DUK_BC_TRYCATCH_FLAG_WITH_BINDING; @@ -71315,7 +70151,8 @@ duk__emit_invalid(comp_ctx); /* finished jump */ duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); - duk__emit_op_only(comp_ctx, DUK_OP_ENDTRY); + duk__emit_op_only(comp_ctx, + DUK_OP_ENDTRY); pc_finished = duk__get_current_pc(comp_ctx); @@ -71482,14 +70319,13 @@ break; } else { DUK_ERROR_SYNTAX(thr, DUK_STR_FUNC_STMT_NOT_ALLOWED); - DUK_WO_NORETURN(return;); } break; } case DUK_TOK_LCURLY: { DUK_DDD(DUK_DDDPRINT("block statement")); duk__advance(comp_ctx); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ if (label_id >= 0) { duk__patch_jump_here(comp_ctx, pc_at_entry + 1); /* break jump */ @@ -71743,7 +70579,7 @@ */ if (DUK_HSTRING_GET_BYTELEN(h_dir) == 10 && - DUK_STRCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use strict") == 0) { + DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use strict", 10) == 0) { #if defined(DUK_USE_STRICT_DECL) DUK_DDD(DUK_DDDPRINT("use strict directive detected: strict flag %ld -> %ld", (long) comp_ctx->curr_func.is_strict, (long) 1)); @@ -71752,7 +70588,7 @@ DUK_DDD(DUK_DDDPRINT("use strict detected but strict declarations disabled, ignoring")); #endif } else if (DUK_HSTRING_GET_BYTELEN(h_dir) == 14 && - DUK_STRCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use duk notail") == 0) { + DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use duk notail", 14) == 0) { DUK_DDD(DUK_DDDPRINT("use duk notail directive detected: notail flag %ld -> %ld", (long) comp_ctx->curr_func.is_notail, (long) 1)); comp_ctx->curr_func.is_notail = 1; @@ -71820,7 +70656,6 @@ "even though no lineterm present before next token)")); } else { DUK_ERROR_SYNTAX(thr, DUK_STR_UNTERMINATED_STMT); - DUK_WO_NORETURN(return;); } } } else { @@ -71869,7 +70704,7 @@ * (EOF or closing brace). */ -DUK_LOCAL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof, duk_bool_t regexp_after) { +DUK_LOCAL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof) { duk_hthread *thr = comp_ctx->thr; duk_ivalue res_alloc; duk_ivalue *res = &res_alloc; @@ -71883,7 +70718,7 @@ * for nested functions (which may occur inside expressions). */ - duk_memzero(&res_alloc, sizeof(res_alloc)); + DUK_MEMZERO(&res_alloc, sizeof(res_alloc)); res->t = DUK_IVAL_PLAIN; res->x1.t = DUK_ISPEC_VALUE; res->x1.valstack_idx = duk_get_top(thr); @@ -71917,15 +70752,6 @@ duk__parse_stmt(comp_ctx, res, allow_source_elem); } - /* RegExp is allowed / not allowed depending on context. For function - * declarations RegExp is allowed because it follows a function - * declaration statement and may appear as part of the next statement. - * For function expressions RegExp is not allowed, and it's possible - * to do something like '(function () {} / 123)'. - */ - if (regexp_after) { - comp_ctx->curr_func.allow_regexp_in_adv = 1; - } duk__advance(comp_ctx); /* Tear down state. */ @@ -72249,11 +71075,13 @@ error_outofregs: DUK_ERROR_RANGE(thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); + return; error_argname: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_ARG_NAME); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); + return; } /* @@ -72290,7 +71118,7 @@ * token (EOF or closing brace). */ -DUK_LOCAL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_bool_t regexp_after, duk_small_int_t expect_token) { +DUK_LOCAL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_small_int_t expect_token) { duk_compiler_func *func; duk_hthread *thr; duk_regconst_t reg_stmt_value = -1; @@ -72362,9 +71190,7 @@ func->max_line = 0; #endif - /* duk__parse_stmts() expects curr_tok to be set; parse in "allow - * regexp literal" mode with current strictness. - */ + /* duk__parse_stmts() expects curr_tok to be set; parse in "allow regexp literal" mode with current strictness */ if (expect_token >= 0) { /* Eating a left curly; regexp mode is allowed by left curly * based on duk__token_lbp[] automatically. @@ -72383,8 +71209,7 @@ DUK_DDD(DUK_DDDPRINT("begin 1st pass")); duk__parse_stmts(comp_ctx, 1, /* allow source elements */ - expect_eof, /* expect EOF instead of } */ - regexp_after); /* regexp after */ + expect_eof); /* expect EOF instead of } */ DUK_DDD(DUK_DDDPRINT("end 1st pass")); /* @@ -72491,8 +71316,7 @@ DUK_DDD(DUK_DDDPRINT("begin 2nd pass")); duk__parse_stmts(comp_ctx, 1, /* allow source elements */ - expect_eof, /* expect EOF instead of } */ - regexp_after); /* regexp after */ + expect_eof); /* expect EOF instead of } */ DUK_DDD(DUK_DDDPRINT("end 2nd pass")); duk__update_lineinfo_currtoken(comp_ctx); @@ -72505,7 +71329,6 @@ /* Should never happen but avoid infinite loop just in case. */ DUK_D(DUK_DPRINT("more than 3 compile passes needed, should never happen")); DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); } DUK_D(DUK_DPRINT("need additional round to compile function, round now %d", (int) compile_round)); } @@ -72549,7 +71372,6 @@ error_funcname: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_FUNC_NAME); - DUK_WO_NORETURN(return;); } /* @@ -72598,7 +71420,6 @@ if (comp_ctx->curr_token.t != DUK_TOK_IDENTIFIER) { DUK_ERROR_SYNTAX(thr, DUK_STR_EXPECTED_IDENTIFIER); - DUK_WO_NORETURN(return;); } DUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_IDENTIFIER); DUK_ASSERT(comp_ctx->curr_token.str1 != NULL); @@ -72664,7 +71485,6 @@ duk_to_string(thr, -1); } else { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_GETSET_NAME); - DUK_WO_NORETURN(return;); } comp_ctx->curr_func.h_name = duk_known_hstring(thr, -1); /* borrowed reference */ } else { @@ -72682,7 +71502,6 @@ no_advance = 1; if (flags & DUK__FUNC_FLAG_DECL) { DUK_ERROR_SYNTAX(thr, DUK_STR_FUNC_NAME_REQUIRED); - DUK_WO_NORETURN(return;); } } } @@ -72716,7 +71535,6 @@ duk__parse_func_body(comp_ctx, 0, /* expect_eof */ 0, /* implicit_return_value */ - flags & DUK__FUNC_FLAG_DECL, /* regexp_after */ DUK_TOK_LCURLY); /* expect_token */ /* @@ -72769,14 +71587,6 @@ comp_ctx->curr_token.t = 0; /* this is needed for regexp mode */ comp_ctx->curr_token.start_line = 0; /* needed for line number tracking (becomes prev_token.start_line) */ duk__advance(comp_ctx); - - /* RegExp is not allowed after a function expression, e.g. in - * (function () {} / 123). A RegExp *is* allowed after a - * function declaration! - */ - if (flags & DUK__FUNC_FLAG_DECL) { - comp_ctx->curr_func.allow_regexp_in_adv = 1; - } duk__advance_expect(comp_ctx, DUK_TOK_RCURLY); return fnum; @@ -72791,9 +71601,9 @@ DUK_DDD(DUK_DDDPRINT("before func: entry_top=%ld, curr_tok.start_offset=%ld", (long) entry_top, (long) comp_ctx->curr_token.start_offset)); - duk_memcpy(&old_func, &comp_ctx->curr_func, sizeof(duk_compiler_func)); + DUK_MEMCPY(&old_func, &comp_ctx->curr_func, sizeof(duk_compiler_func)); - duk_memzero(&comp_ctx->curr_func, sizeof(duk_compiler_func)); + DUK_MEMZERO(&comp_ctx->curr_func, sizeof(duk_compiler_func)); duk__init_func_valstack_slots(comp_ctx); DUK_ASSERT(comp_ctx->curr_func.num_formals == 0); @@ -72835,7 +71645,6 @@ if (fnum > DUK__MAX_FUNCS) { DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_FUNC_LIMIT); - DUK_WO_NORETURN(return 0;); } /* array writes autoincrement length */ @@ -72860,7 +71669,7 @@ } else { duk_set_top(thr, entry_top); } - duk_memcpy((void *) &comp_ctx->curr_func, (void *) &old_func, sizeof(duk_compiler_func)); + DUK_MEMCPY((void *) &comp_ctx->curr_func, (void *) &old_func, sizeof(duk_compiler_func)); return fnum; } @@ -72869,7 +71678,7 @@ * Compile input string into an executable function template without * arguments. * - * The string is parsed as the "Program" production of ECMAScript E5. + * The string is parsed as the "Program" production of Ecmascript E5. * Compilation context can be either global code or eval code (see E5 * Sections 14 and 15.1.2.1). * @@ -73010,7 +71819,6 @@ duk__parse_func_body(comp_ctx, 1, /* expect_eof */ 1, /* implicit_return_value */ - 1, /* regexp_after (does not matter) */ -1); /* expect_token */ } @@ -73038,7 +71846,7 @@ DUK_ASSERT(src_buffer != NULL); /* preinitialize lexer state partially */ - duk_memzero(&comp_stk, sizeof(comp_stk)); + DUK_MEMZERO(&comp_stk, sizeof(comp_stk)); comp_stk.flags = flags; DUK_LEXER_INITCTX(&comp_stk.comp_ctx_alloc.lex); comp_stk.comp_ctx_alloc.lex.input = src_buffer; @@ -73055,7 +71863,6 @@ if (safe_rc != DUK_EXEC_SUCCESS) { DUK_D(DUK_DPRINT("compilation failed: %!T", duk_get_tval(thr, -1))); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } /* [ ... template ] */ @@ -73147,7 +71954,7 @@ #undef DUK__TOKEN_LBP_GET_BP #line 1 "duk_js_executor.c" /* - * ECMAScript bytecode executor. + * Ecmascript bytecode executor. */ /* #include duk_internal.h -> already included */ @@ -73198,7 +72005,7 @@ tv_dst = thr->valstack_top; copy_size = sizeof(duk_tval) * count; - duk_memcpy((void *) tv_dst, (const void *) tv_src, copy_size); + DUK_MEMCPY((void *) tv_dst, (const void *) tv_src, copy_size); for (i = 0; i < count; i++) { DUK_TVAL_INCREF(thr, tv_dst); tv_dst++; @@ -73462,10 +72269,7 @@ break; } case DUK_OP_DIV >> 2: { - /* Division-by-zero is undefined behavior, so - * rely on a helper. - */ - du.d = duk_double_div(d1, d2); + du.d = d1 / d2; break; } case DUK_OP_MOD >> 2: { @@ -73922,7 +72726,7 @@ * top are combined into one pass. */ -/* Reconfigure value stack for return to an ECMAScript function at +/* Reconfigure value stack for return to an Ecmascript function at * callstack top (caller unwinds). */ DUK_LOCAL void duk__reconfig_valstack_ecma_return(duk_hthread *thr) { @@ -73938,7 +72742,7 @@ /* Clamp so that values at 'clamp_top' and above are wiped and won't * retain reachable garbage. Then extend to 'nregs' because we're - * returning to an ECMAScript function. + * returning to an Ecmascript function. */ h_func = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act); @@ -73954,7 +72758,7 @@ /* XXX: a best effort shrink check would be OK here */ } -/* Reconfigure value stack for an ECMAScript catcher. Use topmost catcher +/* Reconfigure value stack for an Ecmascript catcher. Use topmost catcher * in 'act'. */ DUK_LOCAL void duk__reconfig_valstack_ecma_catcher(duk_hthread *thr, duk_activation *act) { @@ -74190,7 +72994,7 @@ act_resumer = resumer->callstack_curr; DUK_ASSERT(act_resumer != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(act_resumer) != NULL); - DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(act_resumer))); /* resume caller must be an ECMAScript func */ + DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(act_resumer))); /* resume caller must be an ecmascript func */ tv1 = (duk_tval *) (void *) ((duk_uint8_t *) resumer->valstack + act_resumer->retval_byteoff); /* return value from Duktape.Thread.resume() */ DUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv_val_unstable); /* side effects */ /* XXX: avoid side effects */ @@ -74246,7 +73050,7 @@ /* duk_bi_duk_object_yield() and duk_bi_duk_object_resume() ensure all of these are met */ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); /* unchanged by Duktape.Thread.resume() */ - DUK_ASSERT(thr->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(thr->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(thr->callstack_curr != NULL); DUK_ASSERT(thr->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL && @@ -74264,7 +73068,7 @@ DUK_ASSERT(resumee->state == DUK_HTHREAD_STATE_INACTIVE || resumee->state == DUK_HTHREAD_STATE_YIELDED); /* checked by Duktape.Thread.resume() */ DUK_ASSERT(resumee->state != DUK_HTHREAD_STATE_YIELDED || - resumee->callstack_top >= 2); /* YIELDED: ECMAScript activation + Duktape.Thread.yield() activation */ + resumee->callstack_top >= 2); /* YIELDED: Ecmascript activation + Duktape.Thread.yield() activation */ DUK_ASSERT(resumee->state != DUK_HTHREAD_STATE_YIELDED || (DUK_ACT_GET_FUNC(resumee->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(resumee->callstack_curr)) && @@ -74302,8 +73106,8 @@ goto check_longjmp; } else if (resumee->state == DUK_HTHREAD_STATE_YIELDED) { /* Unwind previous Duktape.Thread.yield() call. The - * activation remaining must always be an ECMAScript - * call now (yield() accepts calls from ECMAScript + * activation remaining must always be an Ecmascript + * call now (yield() accepts calls from Ecmascript * only). */ duk_activation *act_resumee; @@ -74311,7 +73115,7 @@ DUK_ASSERT(resumee->callstack_top >= 2); act_resumee = resumee->callstack_curr; /* Duktape.Thread.yield() */ DUK_ASSERT(act_resumee != NULL); - act_resumee = act_resumee->parent; /* ECMAScript call site for yield() */ + act_resumee = act_resumee->parent; /* Ecmascript call site for yield() */ DUK_ASSERT(act_resumee != NULL); tv = (duk_tval *) (void *) ((duk_uint8_t *) resumee->valstack + act_resumee->retval_byteoff); /* return value from Duktape.Thread.yield() */ @@ -74359,7 +73163,6 @@ * executor which can be quite misleading. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); } DUK_ASSERT(resumee->resumer == NULL); @@ -74382,7 +73185,7 @@ case DUK_LJ_TYPE_YIELD: { /* * Currently only allowed only if yielding thread has only - * ECMAScript activations (except for the Duktape.Thread.yield() + * Ecmascript activations (except for the Duktape.Thread.yield() * call at the callstack top) and none of them constructor * calls. * @@ -74398,27 +73201,27 @@ DUK_ASSERT(thr != entry_thread); /* Duktape.Thread.yield() should prevent */ #endif DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); /* unchanged from Duktape.Thread.yield() */ - DUK_ASSERT(thr->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.yield() activation */ + DUK_ASSERT(thr->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.yield() activation */ DUK_ASSERT(thr->callstack_curr != NULL); DUK_ASSERT(thr->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr)) && ((duk_hnatfunc *) DUK_ACT_GET_FUNC(thr->callstack_curr))->func == duk_bi_thread_yield); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* an Ecmascript function */ resumer = thr->resumer; DUK_ASSERT(resumer != NULL); DUK_ASSERT(resumer->state == DUK_HTHREAD_STATE_RESUMED); /* written by a previous RESUME handling */ - DUK_ASSERT(resumer->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(resumer->callstack_curr != NULL); DUK_ASSERT(resumer->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(resumer->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(resumer->callstack_curr)) && ((duk_hnatfunc *) DUK_ACT_GET_FUNC(resumer->callstack_curr))->func == duk_bi_thread_resume); DUK_ASSERT(DUK_ACT_GET_FUNC(resumer->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(resumer->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(resumer->callstack_curr->parent))); /* an Ecmascript function */ if (thr->heap->lj.iserror) { thr->state = DUK_HTHREAD_STATE_YIELDED; @@ -74472,7 +73275,7 @@ * resumer in this case.) * * Note: until we hit the entry level, there can only be - * ECMAScript activations. + * Ecmascript activations. */ duk_activation *act; @@ -74539,11 +73342,11 @@ */ DUK_ASSERT(thr->resumer != NULL); - DUK_ASSERT(thr->resumer->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(thr->resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(thr->resumer->callstack_curr != NULL); DUK_ASSERT(thr->resumer->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an Ecmascript function */ resumer = thr->resumer; @@ -74596,7 +73399,8 @@ * infinite loop in this catchpoint. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); + return retval; } /* Handle a BREAK/CONTINUE opcode. Avoid using longjmp() for BREAK/CONTINUE @@ -74660,7 +73464,7 @@ /* Should never happen, but be robust. */ DUK_D(DUK_DPRINT("-> break/continue not caught by anything in the current function (should never happen), throw internal error")); DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); + return; } /* Handle a RETURN opcode. Avoid using longjmp() for return handling because @@ -74695,7 +73499,7 @@ * 2. The return happens at the entry level of the bytecode * executor, so return from the executor (in C stack). * - * 3. There is a calling (ECMAScript) activation in the call + * 3. There is a calling (Ecmascript) activation in the call * stack => return to it, in the same executor instance. * * 4. There is no calling activation, and the thread is @@ -74740,16 +73544,16 @@ } if (thr->callstack_top >= 2) { - /* There is a caller; it MUST be an ECMAScript caller (otherwise it would + /* There is a caller; it MUST be an Ecmascript caller (otherwise it would * match entry_act check). */ - DUK_DDD(DUK_DDDPRINT("return to ECMAScript caller, retval_byteoff=%ld, lj_value1=%!T", + DUK_DDD(DUK_DDDPRINT("return to Ecmascript caller, retval_byteoff=%ld, lj_value1=%!T", (long) (thr->callstack_curr->parent->retval_byteoff), (duk_tval *) &thr->heap->lj.value1)); DUK_ASSERT(thr->callstack_curr != NULL); DUK_ASSERT(thr->callstack_curr->parent != NULL); - DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* must be ECMAScript */ + DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* must be ecmascript */ #if defined(DUK_USE_ES6_PROXY) if (thr->callstack_curr->flags & (DUK_ACT_FLAG_CONSTRUCT | DUK_ACT_FLAG_CONSTRUCT_PROXY)) { @@ -74779,51 +73583,31 @@ DUK_DD(DUK_DDPRINT("no calling activation, thread finishes (similar to yield)")); DUK_ASSERT(thr->resumer != NULL); - DUK_ASSERT(thr->resumer->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(thr->resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(thr->resumer->callstack_curr != NULL); DUK_ASSERT(thr->resumer->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr)) && ((duk_hnatfunc *) DUK_ACT_GET_FUNC(thr->resumer->callstack_curr))->func == duk_bi_thread_resume); /* Duktape.Thread.resume() */ DUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an Ecmascript function */ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); DUK_ASSERT(thr->resumer->state == DUK_HTHREAD_STATE_RESUMED); resumer = thr->resumer; - /* Share yield longjmp handler. - * - * This sequence of steps is a bit fragile (see GH-1845): - * - We need the return value from 'thr' (resumed thread) value stack. - * The termination unwinds its value stack, losing the value. - * - We need a refcounted reference for 'thr', which may only exist - * in the caller value stack. We can't unwind or reconfigure the - * caller's value stack without potentially freeing 'thr'. - * - * Current approach is to capture the 'thr' return value and store - * a reference to 'thr' in the caller value stack temporarily. This - * keeps 'thr' reachable until final yield/return handling which - * removes the references atomatically. - */ - + /* Share yield longjmp handler. */ DUK_ASSERT(thr->valstack_top - 1 >= thr->valstack_bottom); - duk_hthread_activation_unwind_norz(resumer); /* May remove last reference to 'thr', but is NORZ. */ - duk_push_tval(resumer, thr->valstack_top - 1); /* Capture return value, side effect free. */ - duk_push_hthread(resumer, thr); /* Make 'thr' reachable again, before side effects. */ + duk_hthread_activation_unwind_norz(resumer); + duk__handle_yield(thr, resumer, thr->valstack_top - 1); - duk_hthread_terminate(thr); /* Updates thread state, minimizes its allocations. */ - thr->resumer = NULL; - DUK_HTHREAD_DECREF(thr, resumer); + duk_hthread_terminate(thr); /* updates thread state, minimizes its allocations */ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_TERMINATED); + thr->resumer = NULL; + DUK_HTHREAD_DECREF(thr, resumer); resumer->state = DUK_HTHREAD_STATE_RUNNING; DUK_HEAP_SWITCH_THREAD(thr->heap, resumer); - - DUK_ASSERT(resumer->valstack_top - 2 >= resumer->valstack_bottom); - duk__handle_yield(thr, resumer, resumer->valstack_top - 2); - thr = NULL; /* 'thr' invalidated by call */ - #if 0 thr = resumer; /* not needed */ #endif @@ -74833,7 +73617,7 @@ #else /* Without coroutine support this case should never happen. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + return DUK__RETHAND_FINISHED; /* not executed */ #endif } @@ -74983,7 +73767,7 @@ if (diff_last < 0.0 || diff_last >= (duk_double_t) DUK_HEAP_DBG_RATELIMIT_MILLISECS) { /* Monotonic time should not experience time jumps, * but the provider may be missing and we're actually - * using ECMAScript time. So, tolerate negative values + * using Ecmascript time. So, tolerate negative values * so that a time jump works reasonably. * * Same interval is now used for status sending and @@ -75132,7 +73916,6 @@ thr->interrupt_counter = 0; DUK_HEAP_CLEAR_INTERRUPT_RUNNING(thr->heap); DUK_ERROR_RANGE(thr, "execution timeout"); - DUK_WO_NORETURN(return 0;); } #endif /* DUK_USE_EXEC_TIMEOUT_CHECK */ @@ -75818,7 +74601,7 @@ } /* - * ECMAScript bytecode executor. + * Ecmascript bytecode executor. * * Resume execution for the current thread from its current activation. * Returns when execution would return from the entry level activation, @@ -75827,7 +74610,7 @@ * a longjmp() with type DUK_LJ_TYPE_THROW is called on the entry level * setjmp() jmpbuf. * - * ECMAScript function calls and coroutine resumptions are handled + * Ecmascript function calls and coroutine resumptions are handled * internally (by the outer executor function) without recursive C calls. * Other function calls are handled using duk_handle_call(), increasing * C recursion depth. @@ -75920,7 +74703,6 @@ #if defined(DUK_USE_VERBOSE_EXECUTOR_ERRORS) #define DUK__INTERNAL_ERROR(msg) do { \ DUK_ERROR_ERROR(thr, (msg)); \ - DUK_WO_NORETURN(return;); \ } while (0) #else #define DUK__INTERNAL_ERROR(msg) do { \ @@ -76085,10 +74867,7 @@ entry_jmpbuf_ptr); } #if defined(DUK_USE_CPP_EXCEPTIONS) - catch (duk_fatal_exception &exc) { - DUK_D(DUK_DPRINT("rethrow duk_fatal_exception")); - throw; - } catch (std::exception &exc) { + catch (std::exception &exc) { const char *what = exc.what(); if (!what) { what = "unknown"; @@ -76098,7 +74877,6 @@ try { DUK_ASSERT(heap->curr_thread != NULL); DUK_ERROR_FMT1(heap->curr_thread, DUK_ERR_TYPE_ERROR, "caught invalid c++ std::exception '%s' (perhaps thrown by user code)", what); - DUK_WO_NORETURN(return;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ std::exception")); DUK_UNREF(exc); @@ -76113,7 +74891,6 @@ try { DUK_ASSERT(heap->curr_thread != NULL); DUK_ERROR_TYPE(heap->curr_thread, "caught invalid c++ exception (perhaps thrown by user code)"); - DUK_WO_NORETURN(return;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ exception")); DUK_UNREF(exc); @@ -76126,7 +74903,7 @@ #endif } - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); } /* Inner executor, performance critical. */ @@ -76495,7 +75272,7 @@ /* XXX: fast double-to-int conversion, we know number is integer in [-0x80000000,0xffffffff]. */ val = (duk_int32_t) DUK_TVAL_GET_NUMBER(tv1); #endif - val = (duk_int32_t) ((duk_uint32_t) val << DUK_BC_LDINTX_SHIFT) + (duk_int32_t) DUK_DEC_BC(ins); /* no bias */ + val = (val << DUK_BC_LDINTX_SHIFT) + (duk_int32_t) DUK_DEC_BC(ins); /* no bias */ DUK_TVAL_SET_I32_UPDREF(thr, tv1, val); /* side effects */ break; } @@ -78150,7 +76927,7 @@ case DUK_OP_INVLHS: { DUK_ERROR_REFERENCE(thr, DUK_STR_INVALID_LVALUE); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); break; } @@ -78185,13 +76962,45 @@ case DUK_OP_INVALID: { DUK_ERROR_FMT1(thr, DUK_ERR_ERROR, "INVALID opcode (%ld)", (long) DUK_DEC_ABC(ins)); - DUK_WO_NORETURN(return;); break; } #if defined(DUK_USE_ES6) case DUK_OP_NEWTARGET: { - duk_push_new_target(thr); + /* https://www.ecma-international.org/ecma-262/6.0/#sec-meta-properties-runtime-semantics-evaluation + * https://www.ecma-international.org/ecma-262/6.0/#sec-getnewtarget + * + * No newTarget support now, so as a first approximation + * use the resolved (non-bound) target function. + */ + /* XXX: C API: push_new_target()? */ + duk_activation *act; + + act = thr->callstack_curr; + DUK_ASSERT(act != NULL); + + /* Check CONSTRUCT flag from current function, or if running + * direct eval, from a non-direct-eval parent (with possibly + * more than one nested direct eval). An alternative to this + * would be to store [[NewTarget]] as a hidden symbol of the + * lexical scope, and then just look up that variable. + */ + for (;;) { + if (act == NULL) { + duk_push_undefined(thr); + break; + } + if (act->flags & DUK_ACT_FLAG_CONSTRUCT) { + duk_push_tval(thr, &act->tv_func); + break; + } else if (act->flags & DUK_ACT_FLAG_DIRECT_EVAL) { + act = act->parent; + } else { + duk_push_undefined(thr); + break; + } + } + DUK__REPLACE_TOP_BC_BREAK(); } #endif /* DUK_USE_ES6 */ @@ -78293,12 +77102,11 @@ continue; #endif } - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); #if !defined(DUK_USE_VERBOSE_EXECUTOR_ERRORS) internal_error: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); #endif } @@ -78368,9 +77176,9 @@ #undef DUK__TVAL_SHIFT #line 1 "duk_js_ops.c" /* - * ECMAScript specification algorithm and conversion helpers. + * Ecmascript specification algorithm and conversion helpers. * - * These helpers encapsulate the primitive ECMAScript operation semantics, + * These helpers encapsulate the primitive Ecmascript operation semantics, * and are used by the bytecode executor and the API (among other places). * Some primitives are only implemented as part of the API and have no * "internal" helper. This is the case when an internal helper would not @@ -78586,7 +77394,6 @@ duk_hstring *h = DUK_TVAL_GET_STRING(tv); if (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_CANNOT_NUMBER_COERCE_SYMBOL); - DUK_WO_NORETURN(return 0.0;); } duk_push_hstring(thr, h); return duk__tonumber_string_raw(thr); @@ -78802,7 +77609,7 @@ return 0; #else /* DUK_USE_PARANOID_MATH */ /* Better equivalent algorithm. If the compiler is compliant, C and - * ECMAScript semantics are identical for this particular comparison. + * Ecmascript semantics are identical for this particular comparison. * In particular, NaNs must never compare equal and zeroes must compare * equal regardless of sign. Could also use a macro, but this inlines * already nicely (no difference on gcc, for instance). @@ -79095,12 +77902,12 @@ prefix_len = (len1 <= len2 ? len1 : len2); - /* duk_memcmp() is guaranteed to return zero (equal) for zero length - * inputs. + /* DUK_MEMCMP() is guaranteed to return zero (equal) for zero length + * inputs so no zero length check is needed. */ - rc = duk_memcmp_unsafe((const void *) buf1, - (const void *) buf2, - (size_t) prefix_len); + rc = DUK_MEMCMP((const void *) buf1, + (const void *) buf2, + (size_t) prefix_len); if (rc < 0) { return -1; @@ -79367,19 +78174,22 @@ */ /* - * ES2015 Section 7.3.19 describes the OrdinaryHasInstance() algorithm - * which covers both bound and non-bound functions; in effect the algorithm - * includes E5 Sections 11.8.6, 15.3.5.3, and 15.3.4.5.3. - * - * ES2015 Section 12.9.4 describes the instanceof operator which first - * checks @@hasInstance well-known symbol and falls back to - * OrdinaryHasInstance(). + * E5 Section 11.8.6 describes the main algorithm, which uses + * [[HasInstance]]. [[HasInstance]] is defined for only + * function objects: + * + * - Normal functions: + * E5 Section 15.3.5.3 + * - Functions established with Function.prototype.bind(): + * E5 Section 15.3.4.5.3 + * + * For other objects, a TypeError is thrown. * * Limited Proxy support: don't support 'getPrototypeOf' trap but * continue lookup in Proxy target if the value is a Proxy. */ -DUK_LOCAL duk_bool_t duk__js_instanceof_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_bool_t skip_sym_check) { +DUK_INTERNAL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) { duk_hobject *func; duk_hobject *val; duk_hobject *proto; @@ -79402,23 +78212,6 @@ func = duk_require_hobject(thr, -1); DUK_ASSERT(func != NULL); -#if defined(DUK_USE_SYMBOL_BUILTIN) - /* - * @@hasInstance check, ES2015 Section 12.9.4, Steps 2-4. - */ - if (!skip_sym_check) { - if (duk_get_method_stridx(thr, -1, DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE)) { - /* [ ... lhs rhs func ] */ - duk_insert(thr, -3); /* -> [ ... func lhs rhs ] */ - duk_swap_top(thr, -2); /* -> [ ... func rhs(this) lhs ] */ - duk_call_method(thr, 1); - return duk_to_boolean_top_pop(thr); - } - } -#else - DUK_UNREF(skip_sym_check); -#endif - /* * For bound objects, [[HasInstance]] just calls the target function * [[HasInstance]]. If that is again a bound object, repeat until @@ -79430,7 +78223,7 @@ if (!DUK_HOBJECT_IS_CALLABLE(func)) { /* - * Note: of native ECMAScript objects, only Function instances + * Note: of native Ecmascript objects, only Function instances * have a [[HasInstance]] internal property. Custom objects might * also have it, but not in current implementation. * @@ -79440,7 +78233,7 @@ } if (DUK_HOBJECT_HAS_BOUNDFUNC(func)) { - duk_push_tval(thr, &((duk_hboundfunc *) (void *) func)->target); + duk_push_tval(thr, &((duk_hboundfunc *) func)->target); duk_replace(thr, -2); func = duk_require_hobject(thr, -1); /* lightfunc throws */ @@ -79545,7 +78338,6 @@ if (DUK_UNLIKELY(sanity == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } DUK_UNREACHABLE(); @@ -79563,23 +78355,13 @@ error_invalid_rval: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_INSTANCEOF_RVAL); - DUK_WO_NORETURN(return 0;); + return 0; #if defined(DUK_USE_VERBOSE_ERRORS) error_invalid_rval_noproto: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_INSTANCEOF_RVAL_NOPROTO); - DUK_WO_NORETURN(return 0;); -#endif -} - -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL duk_bool_t duk_js_instanceof_ordinary(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) { - return duk__js_instanceof_helper(thr, tv_x, tv_y, 1 /*skip_sym_check*/); -} + return 0; #endif - -DUK_INTERNAL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) { - return duk__js_instanceof_helper(thr, tv_x, tv_y, 0 /*skip_sym_check*/); } /* @@ -79833,7 +78615,7 @@ * be used for most identifier accesses. Consequently, these slow path * primitives should be optimized for maximum compactness. * - * ECMAScript environment records (declarative and object) are represented + * Ecmascript environment records (declarative and object) are represented * as internal objects with control keys. Environment records have a * parent record ("outer environment reference") which is represented by * the implicit prototype for technical reasons (in other words, it is a @@ -79875,7 +78657,7 @@ * Create a new function object based on a "template function" which contains * compiled bytecode, constants, etc, but lacks a lexical environment. * - * ECMAScript requires that each created closure is a separate object, with + * Ecmascript requires that each created closure is a separate object, with * its own set of editable properties. However, structured property values * (such as the formal arguments list and the variable map) are shared. * Also the bytecode, constants, and inner functions are shared. @@ -80884,7 +79666,6 @@ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } env = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, env); } @@ -81024,7 +79805,6 @@ DUK_ERROR_FMT1(thr, DUK_ERR_REFERENCE_ERROR, "identifier '%s' undefined", (const char *) DUK_HSTRING_GET_DATA(name)); - DUK_WO_NORETURN(return 0;); } return 0; @@ -81149,7 +79929,6 @@ DUK_ERROR_FMT1(thr, DUK_ERR_REFERENCE_ERROR, "identifier '%s' undefined", (const char *) DUK_HSTRING_GET_DATA(name)); - DUK_WO_NORETURN(return;); } DUK_DDD(DUK_DDDPRINT("identifier binding not found, not strict => set to global")); @@ -81540,7 +80319,7 @@ fail_existing_attributes: fail_not_extensible: DUK_ERROR_TYPE(thr, "declaration failed"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL @@ -81586,7 +80365,7 @@ * Lexer for source files, ToNumber() string conversions, RegExp expressions, * and JSON. * - * Provides a stream of ECMAScript tokens from an UTF-8/CESU-8 buffer. The + * Provides a stream of Ecmascript tokens from an UTF-8/CESU-8 buffer. The * caller can also rewind the token stream into a certain position which is * needed by the compiler part for multi-pass scanning. Tokens are * represented as duk_token structures, and contain line number information. @@ -81609,14 +80388,14 @@ * * Token parsing supports the full range of Unicode characters as described * in the E5 specification. Parsing has been optimized for ASCII characters - * because ordinary ECMAScript code consists almost entirely of ASCII + * because ordinary Ecmascript code consists almost entirely of ASCII * characters. Matching of complex Unicode codepoint sets (such as in the * IdentifierStart and IdentifierPart productions) is optimized for size, * and is done using a linear scan of a bit-packed list of ranges. This is * very slow, but should never be entered unless the source code actually * contains Unicode characters. * - * ECMAScript tokenization is partially context sensitive. First, + * Ecmascript tokenization is partially context sensitive. First, * additional future reserved words are recognized in strict mode (see E5 * Section 7.6.1.2). Second, a forward slash character ('/') can be * recognized either as starting a RegExp literal or as a division operator, @@ -81713,7 +80492,7 @@ * * * In particular, surrogate pairs are allowed and not combined, which * allows source files to represent all SourceCharacters with CESU-8. - * Broken surrogate pairs are allowed, as ECMAScript does not mandate + * Broken surrogate pairs are allowed, as Ecmascript does not mandate * their validation. * * * Allow non-shortest UTF-8 encodings. @@ -81721,20 +80500,20 @@ * Leniency here causes few security concerns because all character data is * decoded into Unicode codepoints before lexer processing, and is then * re-encoded into CESU-8. The source can be parsed as strict UTF-8 with - * a compiler option. However, ECMAScript source characters include -all- + * a compiler option. However, Ecmascript source characters include -all- * 16-bit unsigned integer codepoints, so leniency seems to be appropriate. * * Note that codepoints above the BMP are not strictly SourceCharacters, * but the lexer still accepts them as such. Before ending up in a string * or an identifier name, codepoints above BMP are converted into surrogate * pairs and then CESU-8 encoded, resulting in 16-bit Unicode data as - * expected by ECMAScript. + * expected by Ecmascript. * * An alternative approach to dealing with invalid or partial sequences * would be to skip them and replace them with e.g. the Unicode replacement * character U+FFFD. This has limited utility because a replacement character * will most likely cause a parse error, unless it occurs inside a string. - * Further, ECMAScript source is typically pure ASCII. + * Further, Ecmascript source is typically pure ASCII. * * See: * @@ -81897,7 +80676,6 @@ lex_ctx->input_line = input_line; DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_SOURCE_DECODE_FAILED); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__advance_bytes(duk_lexer_ctx *lex_ctx, duk_small_uint_t count_bytes) { @@ -81920,7 +80698,7 @@ /* Not enough data to provide a full window, so "scroll" window to * start of buffer and fill up the rest. */ - duk_memmove((void *) lex_ctx->buffer, + DUK_MEMMOVE((void *) lex_ctx->buffer, (const void *) lex_ctx->window, (size_t) avail_bytes); lex_ctx->window = lex_ctx->buffer; @@ -82058,7 +80836,7 @@ error_clipped: /* clipped codepoint */ error_encoding: /* invalid codepoint encoding or codepoint */ DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_SOURCE_DECODE_FAILED); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_LOCAL void duk__advance_bytes(duk_lexer_ctx *lex_ctx, duk_small_uint_t count_bytes) { @@ -82071,7 +80849,7 @@ /* Zero 'count' is also allowed to make call sites easier. */ keep_bytes = DUK_LEXER_WINDOW_SIZE * sizeof(duk_lexer_codepoint) - count_bytes; - duk_memmove((void *) lex_ctx->window, + DUK_MEMMOVE((void *) lex_ctx->window, (const void *) ((duk_uint8_t *) lex_ctx->window + count_bytes), (size_t) keep_bytes); @@ -82160,7 +80938,7 @@ DUK_INTERNAL void duk_lexer_initctx(duk_lexer_ctx *lex_ctx) { DUK_ASSERT(lex_ctx != NULL); - duk_memzero(lex_ctx, sizeof(*lex_ctx)); + DUK_MEMZERO(lex_ctx, sizeof(*lex_ctx)); #if defined(DUK_USE_EXPLICIT_NULL_INIT) #if defined(DUK_USE_LEXER_SLIDING_WINDOW) lex_ctx->window = NULL; @@ -82325,7 +81103,6 @@ fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE); - DUK_WO_NORETURN(return 0;); } /* Parse legacy octal escape of the form \N{1,3}, e.g. \0, \5, \0377. Maximum @@ -82522,11 +81299,11 @@ fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_unterminated: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_STRING); - DUK_WO_NORETURN(return;); + return; } /* Skip to end-of-line (or end-of-file), used for single line comments. */ @@ -82543,7 +81320,7 @@ } /* - * Parse ECMAScript source InputElementDiv or InputElementRegExp + * Parse Ecmascript source InputElementDiv or InputElementRegExp * (E5 Section 7), skipping whitespace, comments, and line terminators. * * Possible results are: @@ -82570,13 +81347,13 @@ * lookup window to quickly determine which production is the -longest- * matching one, and then parse that. The top-level if-else clauses * match the first character, and the code blocks for each clause - * handle -all- alternatives for that first character. ECMAScript + * handle -all- alternatives for that first character. Ecmascript * specification uses the "longest match wins" semantics, so the order * of the if-clauses matters. * * Misc notes: * - * * ECMAScript numeric literals do not accept a sign character. + * * Ecmascript numeric literals do not accept a sign character. * Consequently e.g. "-1.0" is parsed as two tokens: a negative * sign and a positive numeric literal. The compiler performs * the negation during compilation, so this has no adverse impact. @@ -83086,7 +81863,7 @@ * (the tokens DUK_TOK_GET and DUK_TOK_SET are actually not * used now). The compiler needs to work around this. * - * Strictly speaking, following ECMAScript longest match + * Strictly speaking, following Ecmascript longest match * specification, an invalid escape for the first character * should cause a syntax error. However, an invalid escape * for IdentifierParts should just terminate the identifier @@ -83370,32 +82147,32 @@ fail_token_limit: DUK_ERROR_RANGE(lex_ctx->thr, DUK_STR_TOKEN_LIMIT); - DUK_WO_NORETURN(return;); + return; fail_token: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_TOKEN); - DUK_WO_NORETURN(return;); + return; fail_number_literal: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_NUMBER_LITERAL); - DUK_WO_NORETURN(return;); + return; fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_unterm_regexp: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_REGEXP); - DUK_WO_NORETURN(return;); + return; fail_unterm_comment: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_COMMENT); - DUK_WO_NORETURN(return;); + return; #if !defined(DUK_USE_REGEXP_SUPPORT) fail_regexp_support: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_REGEXP_SUPPORT_DISABLED); - DUK_WO_NORETURN(return;); + return; #endif } @@ -83418,7 +82195,7 @@ goto fail_token_limit; } - duk_memzero(out_token, sizeof(*out_token)); + DUK_MEMZERO(out_token, sizeof(*out_token)); x = DUK__L0(); y = DUK__L1(); @@ -83743,24 +82520,24 @@ fail_token_limit: DUK_ERROR_RANGE(lex_ctx->thr, DUK_STR_TOKEN_LIMIT); - DUK_WO_NORETURN(return;); + return; fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_group: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_GROUP); - DUK_WO_NORETURN(return;); + return; #if !defined(DUK_USE_ES6_REGEXP_SYNTAX) fail_invalid_char: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_CHARACTER); - DUK_WO_NORETURN(return;); + return; fail_quantifier: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_QUANTIFIER); - DUK_WO_NORETURN(return;); + return; #endif } @@ -84009,15 +82786,15 @@ fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_range: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_RANGE); - DUK_WO_NORETURN(return;); + return; fail_unterm_charclass: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_CHARCLASS); - DUK_WO_NORETURN(return;); + return; } #endif /* DUK_USE_REGEXP_SUPPORT */ @@ -84179,8 +82956,10 @@ n = y->n; x->n = n; - /* No need to special case n == 0. */ - duk_memcpy((void *) x->v, (const void *) y->v, (size_t) (sizeof(duk_uint32_t) * (size_t) n)); + if (n == 0) { + return; + } + DUK_MEMCPY((void *) x->v, (const void *) y->v, (size_t) (sizeof(duk_uint32_t) * (size_t) n)); } DUK_LOCAL void duk__bi_set_small(duk__bigint *x, duk_uint32_t v) { @@ -84456,7 +83235,7 @@ return; } - duk_memzero((void *) x->v, (size_t) (sizeof(duk_uint32_t) * (size_t) nx)); + DUK_MEMZERO((void *) x->v, (size_t) (sizeof(duk_uint32_t) * (size_t) nx)); x->n = nx; nz = z->n; @@ -84606,7 +83385,7 @@ n = (y / 32) + 1; DUK_ASSERT(n > 0); r = y % 32; - duk_memzero((void *) x->v, sizeof(duk_uint32_t) * (size_t) n); + DUK_MEMZERO((void *) x->v, sizeof(duk_uint32_t) * (size_t) n); x->n = n; x->v[n - 1] = (((duk_uint32_t) 1) << r); } @@ -84720,7 +83499,6 @@ duk_small_int_t dig; duk_uint32_t t; - DUK_ASSERT(buf != NULL); DUK_ASSERT(radix >= 2 && radix <= 36); /* A 32-bit unsigned integer formats to at most 32 digits (the @@ -84743,7 +83521,7 @@ } len = (duk_size_t) ((buf + 32) - p); - duk_memmove((void *) buf, (const void *) p, (size_t) len); + DUK_MEMMOVE((void *) buf, (const void *) p, (size_t) len); return len; } @@ -85146,7 +83924,7 @@ { duk_uint8_t buf[2048]; duk_small_int_t i, t; - duk_memzero(buf, sizeof(buf)); + DUK_MEMZERO(buf, sizeof(buf)); for (i = 0; i < nc_ctx->count; i++) { t = nc_ctx->digits[i]; if (t < 0 || t > 36) { @@ -85211,7 +83989,7 @@ *p = 0; if (p == &nc_ctx->digits[0]) { DUK_DDD(DUK_DDDPRINT("carry propagated to first digit -> special case handling")); - duk_memmove((void *) (&nc_ctx->digits[1]), + DUK_MEMMOVE((void *) (&nc_ctx->digits[1]), (const void *) (&nc_ctx->digits[0]), (size_t) (sizeof(char) * (size_t) nc_ctx->count)); nc_ctx->digits[0] = 1; /* don't increase 'count' */ @@ -85255,7 +84033,7 @@ duk_uint8_t *buf; /* - * The string conversion here incorporates all the necessary ECMAScript + * The string conversion here incorporates all the necessary Ecmascript * semantics without attempting to be generic. nc_ctx->digits contains * nc_ctx->count digits (>= 1), with the topmost digit's 'position' * indicated by nc_ctx->k as follows: @@ -85266,11 +84044,11 @@ * digits="123" count=3 k=-1 --> 0.0123 * * Note that the identifier names used for format selection are different - * in Burger-Dybvig paper and ECMAScript specification (quite confusingly + * in Burger-Dybvig paper and Ecmascript specification (quite confusingly * so, because e.g. 'k' has a totally different meaning in each). See * documentation for discussion. * - * ECMAScript doesn't specify any specific behavior for format selection + * Ecmascript doesn't specify any specific behavior for format selection * (e.g. when to use exponent notation) for non-base-10 numbers. * * The bigint space in the context is reused for string output, as there @@ -85354,7 +84132,7 @@ /* Exponent */ if (expt != DUK__NO_EXP) { /* - * Exponent notation for non-base-10 numbers isn't specified in ECMAScript + * Exponent notation for non-base-10 numbers isn't specified in Ecmascript * specification, as it never explicitly turns up: non-decimal numbers can * only be formatted with Number.prototype.toString([radix]) and for that, * behavior is not explicitly specified. @@ -85456,7 +84234,7 @@ * (perhaps because the low part is set (seemingly) conditionally in a * loop), so this is here to avoid the bogus warning. */ - duk_memzero((void *) &u, sizeof(u)); + DUK_MEMZERO((void *) &u, sizeof(u)); /* * Figure out how generated digits match up with the mantissa, @@ -85639,7 +84417,7 @@ * sprintf "%lu" for the fast path and for exponent formatting. */ - uval = duk_double_to_uint32_t(x); + uval = (unsigned int) x; if (((double) uval) == x && /* integer number in range */ flags == 0) { /* no special formatting */ /* use bigint area as a temp */ @@ -85671,7 +84449,7 @@ * is 1-2 kilobytes and nothing should rely on it being zeroed. */ #if 0 - duk_memzero((void *) nc_ctx, sizeof(*nc_ctx)); /* slow init, do only for slow path cases */ + DUK_MEMZERO((void *) nc_ctx, sizeof(*nc_ctx)); /* slow init, do only for slow path cases */ #endif nc_ctx->is_s2n = 0; @@ -85711,7 +84489,7 @@ } DUK_DDD(DUK_DDDPRINT("count=%ld", (long) count)); DUK_ASSERT(count >= 1); - duk_memzero((void *) nc_ctx->digits, (size_t) count); + DUK_MEMZERO((void *) nc_ctx->digits, (size_t) count); nc_ctx->count = count; nc_ctx->k = 1; /* 0.000... */ neg = 0; @@ -85791,8 +84569,8 @@ duk__numconv_stringify_ctx *nc_ctx = &nc_ctx_alloc; duk_double_t res; duk_hstring *h_str; - duk_int_t expt; - duk_bool_t expt_neg; + duk_small_int_t expt; + duk_small_int_t expt_neg; duk_small_int_t expt_adj; duk_small_int_t neg; duk_small_int_t dig; @@ -85928,7 +84706,7 @@ * accuracy, so that Dragon4 will generate enough binary output digits. * For decimal numbers, this means generating a 20-digit significand, * which should yield enough practical accuracy to parse IEEE doubles. - * In fact, the ECMAScript specification explicitly allows an + * In fact, the Ecmascript specification explicitly allows an * implementation to treat digits beyond 20 as zeroes (and even * to round the 20th digit upwards). For non-decimal numbers, the * appropriate number of digits has been precomputed for comparable @@ -86099,10 +84877,9 @@ } else { /* exponent digit */ - DUK_ASSERT(radix == 10); expt = expt * radix + dig; if (expt > DUK_S2N_MAX_EXPONENT) { - /* Impose a reasonable exponent limit, so that exp + /* impose a reasonable exponent limit, so that exp * doesn't need to get tracked using a bigint. */ DUK_DDD(DUK_DDDPRINT("parse failed: exponent too large")); @@ -86305,7 +85082,7 @@ parse_explimit_error: DUK_DDD(DUK_DDDPRINT("parse failed, internal error, can't return a value")); DUK_ERROR_RANGE(thr, "exponent too large"); - DUK_WO_NORETURN(return;); + return; } /* automatic undefs */ @@ -86847,7 +85624,6 @@ if (re_ctx->recursion_depth >= re_ctx->recursion_limit) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_COMPILER_RECURSION_LIMIT); - DUK_WO_NORETURN(return;); } re_ctx->recursion_depth++; @@ -86921,11 +85697,9 @@ case DUK_RETOK_QUANTIFIER: { if (atom_start_offset < 0) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_INVALID_QUANTIFIER_NO_ATOM); - DUK_WO_NORETURN(return;); } if (re_ctx->curr_token.qmin > re_ctx->curr_token.qmax) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_INVALID_QUANTIFIER_VALUES); - DUK_WO_NORETURN(return;); } if (atom_char_length >= 0) { /* @@ -86994,7 +85768,6 @@ re_ctx->curr_token.qmin : re_ctx->curr_token.qmax; if (atom_copies > DUK_RE_MAX_ATOM_COPIES) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_QUANTIFIER_TOO_MANY_COPIES); - DUK_WO_NORETURN(return;); } /* wipe the capture range made by the atom (if any) */ @@ -87258,20 +86031,17 @@ case DUK_RETOK_ATOM_END_GROUP: { if (expect_eof) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_CLOSING_PAREN); - DUK_WO_NORETURN(return;); } goto done; } case DUK_RETOK_EOF: { if (!expect_eof) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_END_OF_PATTERN); - DUK_WO_NORETURN(return;); } goto done; } default: { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_REGEXP_TOKEN); - DUK_WO_NORETURN(return;); } } @@ -87366,7 +86136,7 @@ flags_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_REGEXP_FLAGS); - DUK_WO_NORETURN(return 0U;); + return 0; /* never here */ } /* @@ -87403,7 +86173,7 @@ n = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h); if (n == 0) { - duk_push_literal(thr, "(?:)"); + duk_push_string(thr, "(?:)"); return; } @@ -87483,7 +86253,7 @@ /* [ ... pattern flags escaped_source buffer ] */ - duk_memzero(&re_ctx, sizeof(re_ctx)); + DUK_MEMZERO(&re_ctx, sizeof(re_ctx)); DUK_LEXER_INITCTX(&re_ctx.lex); /* duplicate zeroing, expect for (possible) NULL inits */ re_ctx.thr = thr; re_ctx.lex.thr = thr; @@ -87530,7 +86300,6 @@ if (re_ctx.highest_backref > re_ctx.captures) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_BACKREFS); - DUK_WO_NORETURN(return;); } /* @@ -87615,7 +86384,7 @@ /* * Regexp executor. * - * Safety: the ECMAScript executor should prevent user from reading and + * Safety: the Ecmascript executor should prevent user from reading and * replacing regexp bytecode. Even so, the executor must validate all * memory accesses etc. When an invalid access is detected (e.g. a 'save' * opcode to invalid, unallocated index) it should fail with an internal @@ -87682,7 +86451,7 @@ fail: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } DUK_LOCAL const duk_uint8_t *duk__utf8_advance(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_uint_fast32_t count) { @@ -87713,7 +86482,7 @@ fail: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } /* @@ -87762,7 +86531,6 @@ DUK_LOCAL const duk_uint8_t *duk__match_regexp(duk_re_matcher_ctx *re_ctx, const duk_uint8_t *pc, const duk_uint8_t *sp) { if (re_ctx->recursion_depth >= re_ctx->recursion_limit) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_EXECUTOR_RECURSION_LIMIT); - DUK_WO_NORETURN(return NULL;); } re_ctx->recursion_depth++; @@ -87771,7 +86539,6 @@ if (re_ctx->steps_count >= re_ctx->steps_limit) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_EXECUTOR_STEP_LIMIT); - DUK_WO_NORETURN(return NULL;); } re_ctx->steps_count++; @@ -88117,14 +86884,14 @@ range_save = (duk_uint8_t **) duk_push_fixed_buffer_nozero(re_ctx->thr, sizeof(duk_uint8_t *) * idx_count); DUK_ASSERT(range_save != NULL); - duk_memcpy(range_save, re_ctx->saved + idx_start, sizeof(duk_uint8_t *) * idx_count); + DUK_MEMCPY(range_save, re_ctx->saved + idx_start, sizeof(duk_uint8_t *) * idx_count); #if defined(DUK_USE_EXPLICIT_NULL_INIT) idx_end = idx_start + idx_count; for (idx = idx_start; idx < idx_end; idx++) { re_ctx->saved[idx] = NULL; } #else - duk_memzero((void *) (re_ctx->saved + idx_start), sizeof(duk_uint8_t *) * idx_count); + DUK_MEMZERO((void *) (re_ctx->saved + idx_start), sizeof(duk_uint8_t *) * idx_count); #endif sub_sp = duk__match_regexp(re_ctx, pc, sp); @@ -88142,7 +86909,7 @@ DUK_DDD(DUK_DDDPRINT("fail: restore wiped/resaved values [%ld,%ld] (captures [%ld,%ld])", (long) idx_start, (long) (idx_start + idx_count - 1), (long) (idx_start / 2), (long) ((idx_start + idx_count - 1) / 2))); - duk_memcpy((void *) (re_ctx->saved + idx_start), + DUK_MEMCPY((void *) (re_ctx->saved + idx_start), (const void *) range_save, sizeof(duk_uint8_t *) * idx_count); duk_pop_unsafe(re_ctx->thr); @@ -88174,7 +86941,7 @@ full_save = (duk_uint8_t **) duk_push_fixed_buffer_nozero(re_ctx->thr, sizeof(duk_uint8_t *) * re_ctx->nsaved); DUK_ASSERT(full_save != NULL); - duk_memcpy(full_save, re_ctx->saved, sizeof(duk_uint8_t *) * re_ctx->nsaved); + DUK_MEMCPY(full_save, re_ctx->saved, sizeof(duk_uint8_t *) * re_ctx->nsaved); skip = duk__bc_get_i32(re_ctx, &pc); sub_sp = duk__match_regexp(re_ctx, pc, sp); @@ -88199,7 +86966,7 @@ lookahead_fail: /* fail: restore saves */ - duk_memcpy((void *) re_ctx->saved, + DUK_MEMCPY((void *) re_ctx->saved, (const void *) full_save, sizeof(duk_uint8_t *) * re_ctx->nsaved); duk_pop_unsafe(re_ctx->thr); @@ -88281,7 +87048,7 @@ internal_error: DUK_ERROR_INTERNAL(re_ctx->thr); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } /* @@ -88347,7 +87114,7 @@ /* [ ... re_obj input bc ] */ - duk_memzero(&re_ctx, sizeof(re_ctx)); + DUK_MEMZERO(&re_ctx, sizeof(re_ctx)); re_ctx.thr = thr; re_ctx.input = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input); @@ -88384,7 +87151,7 @@ #elif defined(DUK_USE_ZERO_BUFFER_DATA) /* buffer is automatically zeroed */ #else - duk_memzero((void *) p_buf, sizeof(duk_uint8_t *) * re_ctx.nsaved); + DUK_MEMZERO((void *) p_buf, sizeof(duk_uint8_t *) * re_ctx.nsaved); #endif DUK_DDD(DUK_DDDPRINT("regexp ctx initialized, flags=0x%08lx, nsaved=%ld, recursion_limit=%ld, steps_limit=%ld", @@ -88469,7 +87236,7 @@ * internal/limit error occurs (which causes a longjmp()) * * - If we supported anchored matches, we would break out here - * unconditionally; however, ECMAScript regexps don't have anchored + * unconditionally; however, Ecmascript regexps don't have anchored * matches. It might make sense to implement a fast bail-out if * the regexp begins with '^' and sp is not 0: currently we'll just * run through the entire input string, trivially failing the match @@ -88664,13 +87431,13 @@ } while (0) #define DUK__DBLUNION_CMP_TRUE(a,b) do { \ - if (duk_memcmp((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) != 0) { \ + if (DUK_MEMCMP((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) != 0) { \ DUK__FAILED("double union compares false (expected true)"); \ } \ } while (0) #define DUK__DBLUNION_CMP_FALSE(a,b) do { \ - if (duk_memcmp((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) == 0) { \ + if (DUK_MEMCMP((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) == 0) { \ DUK__FAILED("double union compares true (expected false)"); \ } \ } while (0) @@ -88979,7 +87746,7 @@ */ DUK__DOUBLE_INIT(&a, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); DUK__DOUBLE_INIT(&b, 0x3c, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - duk_memset((void *) &c, 0, sizeof(c)); + DUK_MEMSET((void *) &c, 0, sizeof(c)); c.d = a.d + b.d; if (!DUK__DOUBLE_COMPARE(&c, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)) { DUK_D(DUK_DPRINT("broken result (native endiannesss): %02x %02x %02x %02x %02x %02x %02x %02x", @@ -88999,7 +87766,7 @@ */ DUK__DOUBLE_INIT(&a, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01); DUK__DOUBLE_INIT(&b, 0x3c, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - duk_memset((void *) &c, 0, sizeof(c)); + DUK_MEMSET((void *) &c, 0, sizeof(c)); c.d = a.d + b.d; if (!DUK__DOUBLE_COMPARE(&c, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02)) { DUK_D(DUK_DPRINT("broken result (native endiannesss): %02x %02x %02x %02x %02x %02x %02x %02x", @@ -89438,7 +88205,7 @@ * packed format. These tables are used to match non-ASCII * characters of complex productions by resorting to a linear * range-by-range comparison. This is very slow, but is expected - * to be very rare in practical ECMAScript source code, and thus + * to be very rare in practical Ecmascript source code, and thus * compactness is most important. * * The tables are matched using uni_range_match() and the format @@ -89452,55 +88219,54 @@ * Automatically generated by extract_chars.py, do not edit! */ -const duk_uint8_t duk_unicode_ids_noa[1063] = { +const duk_uint8_t duk_unicode_ids_noa[1036] = { 249,176,176,80,111,7,47,15,47,254,11,197,191,0,72,2,15,115,66,19,50,7,2,34, 2,240,66,244,50,247,185,249,98,241,99,8,241,127,58,240,182,47,31,241,191, 21,18,245,50,15,1,24,27,35,15,2,2,240,239,15,244,156,15,10,241,26,21,6,240, -101,10,4,15,9,240,152,175,39,240,82,127,56,242,100,15,4,8,159,1,240,5,115, -19,240,98,98,4,52,15,2,14,18,47,0,27,9,85,19,240,98,98,18,18,31,17,50,15,5, -47,2,130,34,240,98,98,18,68,15,4,15,1,31,9,12,115,19,240,98,98,18,68,15,16, -18,47,1,15,3,2,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,240,4,15, -12,38,31,16,5,114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2, -6,41,47,10,86,240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50, -98,34,2,3,18,50,26,3,66,15,7,63,18,15,49,114,241,79,13,79,101,241,191,6,15, -2,85,52,4,24,37,205,15,3,241,98,6,3,241,178,255,224,63,35,54,32,35,63,25, -35,63,17,35,54,32,35,62,47,41,35,63,51,241,127,0,240,47,70,53,79,254,21, -227,240,18,240,166,243,180,168,194,63,0,240,47,0,240,47,0,194,47,1,242,79, -21,5,15,53,244,137,67,241,34,6,243,107,240,255,35,240,227,76,241,197,240, -175,40,240,122,242,95,68,15,79,241,255,3,111,41,240,238,27,241,207,12,241, -79,27,43,241,67,143,82,50,52,26,251,15,50,255,224,8,53,63,22,53,55,32,32, -32,47,15,63,37,38,32,66,38,67,53,92,98,38,246,96,224,240,44,245,112,80,57, -32,68,112,32,32,35,42,51,100,80,240,63,25,255,233,107,241,242,241,242,247, -87,52,29,241,98,6,3,242,136,15,2,240,122,98,98,98,98,98,98,98,111,66,15, -254,12,146,240,184,132,52,95,70,114,47,74,35,111,26,63,78,240,63,11,242, -127,0,255,224,244,255,240,0,138,143,60,255,240,4,13,223,7,255,227,127,243, -95,30,63,253,79,0,177,240,111,31,240,47,15,63,64,241,152,63,87,63,20,39, -243,26,34,35,47,7,240,255,36,240,15,34,243,5,64,32,223,12,191,7,240,191,13, -143,31,240,224,240,36,41,180,47,25,240,146,39,240,111,7,64,79,34,32,65,52, -48,32,240,162,58,130,213,53,53,166,38,47,27,41,191,99,240,255,255,0,26,150, -223,7,95,33,255,240,0,255,143,254,6,3,245,175,24,109,70,2,146,194,66,2,18, -18,245,207,19,255,224,93,240,79,48,63,38,241,171,246,100,47,119,241,111,10, -127,10,207,73,69,53,53,50,241,91,47,10,47,3,33,46,61,241,79,107,243,127,37, -255,223,13,79,33,242,31,16,239,14,111,22,191,14,63,20,87,36,241,207,142, -240,79,20,95,20,95,24,159,36,248,239,254,2,154,240,107,127,138,83,2,241, -194,20,3,240,123,240,122,240,255,51,240,50,27,240,107,240,175,56,242,135, -31,50,15,1,50,34,240,191,30,240,212,240,223,21,114,240,207,13,242,107,240, -107,240,62,240,47,96,243,159,41,242,62,242,63,254,32,79,37,243,223,29,241, -47,9,240,207,20,241,191,19,64,223,32,240,3,240,112,32,241,95,2,47,9,244, -102,32,35,46,41,143,31,241,135,49,63,6,38,33,36,64,240,64,212,249,15,37, -240,67,242,127,32,240,97,32,250,175,31,241,179,241,111,32,240,96,242,223, -27,244,127,10,255,224,122,243,15,17,15,242,11,241,136,15,7,12,241,131,63, -40,242,159,249,130,241,95,3,15,35,240,239,98,98,18,241,111,7,15,254,26,223, -254,40,207,88,245,255,3,251,79,254,155,15,254,50,31,254,236,95,254,19,159, -255,0,16,173,255,225,43,143,15,246,63,14,240,79,32,240,35,241,31,5,111,3, -255,226,100,243,92,15,52,207,50,31,16,255,240,0,109,255,5,255,225,229,255, -240,1,64,31,254,1,31,67,255,224,126,255,231,248,245,182,196,136,159,255,0, -6,90,244,82,243,114,19,3,19,50,178,2,98,243,18,51,114,98,240,194,50,66,4, -98,255,224,70,63,9,47,9,47,15,47,9,47,15,47,9,47,15,47,9,47,15,47,9,39,255, -239,40,251,95,45,243,79,254,59,3,47,11,33,32,48,41,35,32,32,112,80,32,32, -34,33,32,48,32,32,32,32,33,32,51,38,35,35,32,41,47,1,98,36,47,1,255,240,0, -3,143,255,0,149,201,241,191,254,242,124,252,227,255,240,0,87,79,0,255,240, -0,194,63,254,177,63,254,17,0, +101,10,4,15,9,240,159,57,240,82,127,56,242,100,15,4,8,159,1,240,5,115,19, +240,98,98,4,52,15,2,14,18,47,0,31,5,85,19,240,98,98,18,18,31,17,50,15,5,47, +2,130,34,240,98,98,18,68,15,4,15,1,31,9,12,115,19,240,98,98,18,68,15,16,18, +47,1,15,3,2,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,240,4,15,12, +38,31,16,5,114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2,6, +41,47,10,86,240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50,98, +34,2,3,18,50,26,3,66,15,7,63,18,15,49,114,241,79,13,79,101,241,191,6,15,2, +85,52,4,24,37,205,15,3,241,98,6,3,241,178,255,224,63,35,54,32,35,63,25,35, +63,17,35,54,32,35,62,47,41,35,63,51,241,127,0,240,47,70,53,79,254,21,227, +240,18,240,166,243,180,168,194,63,0,240,47,0,240,47,0,194,47,1,242,79,21,5, +15,53,244,137,67,241,34,6,243,107,240,255,35,240,227,76,241,197,240,175,40, +240,122,242,95,68,15,79,241,255,3,111,41,240,238,27,241,207,12,241,79,27, +43,241,67,143,82,50,52,26,251,15,50,255,224,8,53,63,22,53,55,32,32,32,47, +15,63,37,38,32,66,38,67,53,92,98,38,246,96,224,240,44,245,112,80,57,32,68, +112,32,32,35,42,51,100,80,240,63,25,255,233,107,241,242,241,242,247,87,52, +29,241,98,6,3,242,136,15,2,240,122,98,98,98,98,98,98,98,111,66,15,254,12, +146,240,184,132,52,95,70,114,47,74,35,111,25,79,78,240,63,11,242,127,0,255, +224,244,255,240,0,138,143,60,255,240,4,12,143,28,255,227,127,243,95,30,63, +253,79,0,177,240,111,31,240,47,15,63,64,241,152,63,87,63,20,39,243,26,34, +35,47,7,240,255,36,240,15,34,243,5,64,32,223,12,191,7,240,191,13,143,31, +240,224,240,36,41,180,47,25,240,146,39,240,111,7,64,79,34,32,65,52,48,32, +240,162,58,130,213,53,53,166,38,47,27,41,191,99,240,255,255,0,26,150,223,7, +95,33,255,240,0,255,143,254,6,3,245,175,24,109,70,2,146,194,66,2,18,18,245, +207,19,255,224,93,240,79,48,63,38,241,171,246,100,47,119,241,111,10,127,10, +207,73,69,53,53,50,241,91,47,10,47,3,33,46,61,241,79,107,243,127,37,255, +223,13,79,33,242,31,16,240,47,11,111,22,191,14,63,20,87,36,241,207,142,240, +79,20,95,20,95,24,159,36,248,239,254,2,154,240,107,127,138,83,2,241,194,20, +3,240,123,240,122,240,255,51,240,50,27,240,107,240,175,56,242,135,31,50,15, +1,50,34,240,191,30,240,212,240,223,21,114,240,207,13,242,107,240,107,240, +62,240,47,96,243,159,41,242,62,242,63,254,32,79,37,243,223,29,241,47,9,240, +207,20,241,191,19,64,223,32,240,3,240,112,32,241,95,2,47,9,244,102,32,35, +46,41,143,31,241,135,49,63,6,38,33,36,64,240,64,212,249,15,37,240,67,242, +127,32,240,97,32,250,175,31,241,179,241,111,32,240,96,242,223,27,244,127, +10,255,224,122,243,15,17,15,254,11,79,41,255,152,47,21,240,48,242,63,14, +255,226,100,255,226,140,245,143,95,240,63,180,255,233,176,255,227,33,255, +238,197,255,225,57,255,240,1,10,223,254,18,184,240,255,99,240,239,4,242,15, +2,63,17,240,86,240,63,254,38,79,53,192,243,76,243,32,241,31,255,0,6,223, +240,95,254,30,95,255,0,20,1,31,254,175,47,91,108,72,137,255,240,0,101,175, +69,47,55,33,48,49,51,43,32,38,47,49,35,55,38,47,12,35,36,32,70,47,254,4,99, +240,146,240,146,240,242,240,146,240,242,240,146,240,242,240,146,240,242, +240,146,127,254,242,143,181,242,223,52,255,227,176,50,240,178,18,3,2,146, +50,2,7,5,2,2,2,34,18,3,2,2,2,2,2,18,3,50,98,50,50,2,146,240,22,34,66,240, +31,255,0,0,56,255,240,9,92,159,27,255,239,39,207,206,63,255,0,5,116,255, +240,1,133,47,254,17,0, }; #else /* IdentifierStart production with ASCII and non-BMP excluded */ @@ -89509,35 +88275,35 @@ * Automatically generated by extract_chars.py, do not edit! */ -const duk_uint8_t duk_unicode_ids_noabmp[626] = { +const duk_uint8_t duk_unicode_ids_noabmp[625] = { 249,176,176,80,111,7,47,15,47,254,11,197,191,0,72,2,15,115,66,19,50,7,2,34, 2,240,66,244,50,247,185,249,98,241,99,8,241,127,58,240,182,47,31,241,191, 21,18,245,50,15,1,24,27,35,15,2,2,240,239,15,244,156,15,10,241,26,21,6,240, -101,10,4,15,9,240,152,175,39,240,82,127,56,242,100,15,4,8,159,1,240,5,115, -19,240,98,98,4,52,15,2,14,18,47,0,27,9,85,19,240,98,98,18,18,31,17,50,15,5, -47,2,130,34,240,98,98,18,68,15,4,15,1,31,9,12,115,19,240,98,98,18,68,15,16, -18,47,1,15,3,2,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,240,4,15, -12,38,31,16,5,114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2, -6,41,47,10,86,240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50, -98,34,2,3,18,50,26,3,66,15,7,63,18,15,49,114,241,79,13,79,101,241,191,6,15, -2,85,52,4,24,37,205,15,3,241,98,6,3,241,178,255,224,63,35,54,32,35,63,25, -35,63,17,35,54,32,35,62,47,41,35,63,51,241,127,0,240,47,70,53,79,254,21, -227,240,18,240,166,243,180,168,194,63,0,240,47,0,240,47,0,194,47,1,242,79, -21,5,15,53,244,137,67,241,34,6,243,107,240,255,35,240,227,76,241,197,240, -175,40,240,122,242,95,68,15,79,241,255,3,111,41,240,238,27,241,207,12,241, -79,27,43,241,67,143,82,50,52,26,251,15,50,255,224,8,53,63,22,53,55,32,32, -32,47,15,63,37,38,32,66,38,67,53,92,98,38,246,96,224,240,44,245,112,80,57, -32,68,112,32,32,35,42,51,100,80,240,63,25,255,233,107,241,242,241,242,247, -87,52,29,241,98,6,3,242,136,15,2,240,122,98,98,98,98,98,98,98,111,66,15, -254,12,146,240,184,132,52,95,70,114,47,74,35,111,26,63,78,240,63,11,242, -127,0,255,224,244,255,240,0,138,143,60,255,240,4,13,223,7,255,227,127,243, -95,30,63,253,79,0,177,240,111,31,240,47,15,63,64,241,152,63,87,63,20,39, -243,26,34,35,47,7,240,255,36,240,15,34,243,5,64,32,223,12,191,7,240,191,13, -143,31,240,224,240,36,41,180,47,25,240,146,39,240,111,7,64,79,34,32,65,52, -48,32,240,162,58,130,213,53,53,166,38,47,27,41,191,99,240,255,255,0,26,150, -223,7,95,33,255,240,0,255,143,254,6,3,245,175,24,109,70,2,146,194,66,2,18, -18,245,207,19,255,224,93,240,79,48,63,38,241,171,246,100,47,119,241,111,10, -127,10,207,73,69,53,53,50,0, +101,10,4,15,9,240,159,57,240,82,127,56,242,100,15,4,8,159,1,240,5,115,19, +240,98,98,4,52,15,2,14,18,47,0,31,5,85,19,240,98,98,18,18,31,17,50,15,5,47, +2,130,34,240,98,98,18,68,15,4,15,1,31,9,12,115,19,240,98,98,18,68,15,16,18, +47,1,15,3,2,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,240,4,15,12, +38,31,16,5,114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2,6, +41,47,10,86,240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50,98, +34,2,3,18,50,26,3,66,15,7,63,18,15,49,114,241,79,13,79,101,241,191,6,15,2, +85,52,4,24,37,205,15,3,241,98,6,3,241,178,255,224,63,35,54,32,35,63,25,35, +63,17,35,54,32,35,62,47,41,35,63,51,241,127,0,240,47,70,53,79,254,21,227, +240,18,240,166,243,180,168,194,63,0,240,47,0,240,47,0,194,47,1,242,79,21,5, +15,53,244,137,67,241,34,6,243,107,240,255,35,240,227,76,241,197,240,175,40, +240,122,242,95,68,15,79,241,255,3,111,41,240,238,27,241,207,12,241,79,27, +43,241,67,143,82,50,52,26,251,15,50,255,224,8,53,63,22,53,55,32,32,32,47, +15,63,37,38,32,66,38,67,53,92,98,38,246,96,224,240,44,245,112,80,57,32,68, +112,32,32,35,42,51,100,80,240,63,25,255,233,107,241,242,241,242,247,87,52, +29,241,98,6,3,242,136,15,2,240,122,98,98,98,98,98,98,98,111,66,15,254,12, +146,240,184,132,52,95,70,114,47,74,35,111,25,79,78,240,63,11,242,127,0,255, +224,244,255,240,0,138,143,60,255,240,4,12,143,28,255,227,127,243,95,30,63, +253,79,0,177,240,111,31,240,47,15,63,64,241,152,63,87,63,20,39,243,26,34, +35,47,7,240,255,36,240,15,34,243,5,64,32,223,12,191,7,240,191,13,143,31, +240,224,240,36,41,180,47,25,240,146,39,240,111,7,64,79,34,32,65,52,48,32, +240,162,58,130,213,53,53,166,38,47,27,41,191,99,240,255,255,0,26,150,223,7, +95,33,255,240,0,255,143,254,6,3,245,175,24,109,70,2,146,194,66,2,18,18,245, +207,19,255,224,93,240,79,48,63,38,241,171,246,100,47,119,241,111,10,127,10, +207,73,69,53,53,50,0, }; #endif @@ -89572,33 +88338,32 @@ * Automatically generated by extract_chars.py, do not edit! */ -const duk_uint8_t duk_unicode_idp_m_ids_noa[549] = { +const duk_uint8_t duk_unicode_idp_m_ids_noa[530] = { 255,225,243,246,15,254,0,116,255,191,29,32,33,33,32,243,170,242,47,15,112, 245,118,53,49,35,57,240,144,241,15,11,244,218,240,25,241,56,241,67,40,34, 36,241,210,246,173,47,17,242,130,47,2,38,177,57,240,50,242,160,38,49,50, 160,177,57,240,50,242,160,36,81,50,64,240,107,64,194,242,160,39,34,34,240, -97,57,181,34,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9, -240,35,242,198,34,35,129,193,57,240,50,242,160,38,34,35,129,193,57,240,35, -242,145,38,34,35,160,177,57,240,65,243,128,85,32,39,121,49,242,240,54,215, -41,244,144,53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160, -245,111,4,41,211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240, -241,241,1,243,47,16,160,57,241,50,57,245,209,241,64,246,139,91,185,247,41, -242,244,242,185,47,13,58,121,240,141,243,68,242,31,1,201,240,56,210,241,12, -57,241,237,242,47,4,153,121,246,130,47,5,80,82,50,251,143,42,36,255,225,0, -31,35,31,5,15,109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91, -31,255,0,100,121,159,55,5,159,18,31,66,31,254,0,64,64,80,240,148,244,161, -242,79,2,185,127,2,240,9,240,231,240,188,241,227,242,29,240,25,192,185,242, -29,208,145,57,241,50,242,64,34,49,97,32,241,180,97,253,231,33,57,255,240,3, +97,57,240,50,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9, +240,35,242,198,34,35,129,193,57,240,50,242,160,38,34,35,129,193,57,240,50, +242,198,34,35,160,177,57,240,65,243,128,85,32,39,121,49,242,240,54,215,41, +244,144,53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160,245, +111,4,41,211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240,241, +241,1,243,47,16,160,57,241,50,57,245,209,241,64,246,139,91,185,247,41,242, +244,242,185,47,13,58,121,240,141,243,68,242,31,1,201,240,56,210,241,12,57, +241,237,242,47,4,153,121,246,130,47,5,80,82,65,251,143,38,100,255,225,0,31, +35,31,5,15,109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91,31, +255,0,100,121,159,55,5,159,18,31,66,31,254,0,64,64,80,240,148,244,161,242, +79,2,185,127,2,240,9,240,231,240,188,241,227,242,29,240,25,192,185,242,29, +208,145,57,241,50,242,64,34,49,97,32,241,180,97,253,231,33,57,255,240,3, 225,128,255,225,213,240,15,2,240,4,31,10,47,178,159,23,15,254,27,16,253,64, 248,116,255,224,25,159,254,68,178,33,99,241,162,80,249,113,255,228,13,47, 39,239,17,159,1,63,31,175,39,151,47,22,210,159,37,13,47,34,218,36,159,68, 183,15,146,182,151,63,42,2,99,19,42,11,19,100,79,178,240,42,159,72,240,77, 159,199,99,143,13,31,68,240,31,1,159,67,201,159,69,229,159,254,9,169,255, -224,11,159,26,98,57,10,175,32,240,15,254,8,151,39,240,41,242,175,6,45,246, -197,64,33,38,32,153,255,240,3,191,169,247,132,242,214,240,185,255,226,235, -241,239,2,63,255,0,59,254,31,255,0,3,186,68,89,115,111,16,63,134,47,254,71, -223,34,255,224,244,242,117,242,41,15,0,15,8,66,239,254,68,70,47,1,54,33,36, -255,231,153,111,95,102,159,255,12,6,154,254,0, +226,57,114,127,2,159,42,240,98,223,255,0,60,157,159,120,79,45,111,11,159, +254,46,191,30,240,35,255,240,3,191,225,255,240,0,59,164,69,151,54,241,3, +248,98,255,228,125,242,47,254,15,79,39,95,34,144,240,0,240,132,46,255,228, +68,98,240,19,98,18,79,254,121,150,245,246,105,255,240,192,105,175,224,0, }; #else /* IdentifierPart production with IdentifierStart, ASCII, and non-BMP excluded */ @@ -89607,23 +88372,23 @@ * Automatically generated by extract_chars.py, do not edit! */ -const duk_uint8_t duk_unicode_idp_m_ids_noabmp[358] = { +const duk_uint8_t duk_unicode_idp_m_ids_noabmp[357] = { 255,225,243,246,15,254,0,116,255,191,29,32,33,33,32,243,170,242,47,15,112, 245,118,53,49,35,57,240,144,241,15,11,244,218,240,25,241,56,241,67,40,34, 36,241,210,246,173,47,17,242,130,47,2,38,177,57,240,50,242,160,38,49,50, 160,177,57,240,50,242,160,36,81,50,64,240,107,64,194,242,160,39,34,34,240, -97,57,181,34,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9, -240,35,242,198,34,35,129,193,57,240,50,242,160,38,34,35,129,193,57,240,35, -242,145,38,34,35,160,177,57,240,65,243,128,85,32,39,121,49,242,240,54,215, -41,244,144,53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160, -245,111,4,41,211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240, -241,241,1,243,47,16,160,57,241,50,57,245,209,241,64,246,139,91,185,247,41, -242,244,242,185,47,13,58,121,240,141,243,68,242,31,1,201,240,56,210,241,12, -57,241,237,242,47,4,153,121,246,130,47,5,80,82,50,251,143,42,36,255,225,0, -31,35,31,5,15,109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91, -31,255,0,100,121,159,55,5,159,18,31,66,31,254,0,64,64,80,240,148,244,161, -242,79,2,185,127,2,240,9,240,231,240,188,241,227,242,29,240,25,192,185,242, -29,208,145,57,241,50,242,64,34,49,97,32,241,180,97,253,231,33,57,255,240,3, +97,57,240,50,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9, +240,35,242,198,34,35,129,193,57,240,50,242,160,38,34,35,129,193,57,240,50, +242,198,34,35,160,177,57,240,65,243,128,85,32,39,121,49,242,240,54,215,41, +244,144,53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160,245, +111,4,41,211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240,241, +241,1,243,47,16,160,57,241,50,57,245,209,241,64,246,139,91,185,247,41,242, +244,242,185,47,13,58,121,240,141,243,68,242,31,1,201,240,56,210,241,12,57, +241,237,242,47,4,153,121,246,130,47,5,80,82,65,251,143,38,100,255,225,0,31, +35,31,5,15,109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91,31, +255,0,100,121,159,55,5,159,18,31,66,31,254,0,64,64,80,240,148,244,161,242, +79,2,185,127,2,240,9,240,231,240,188,241,227,242,29,240,25,192,185,242,29, +208,145,57,241,50,242,64,34,49,97,32,241,180,97,253,231,33,57,255,240,3, 225,128,255,225,213,240,15,2,240,4,31,10,47,178,159,23,0, }; #endif @@ -95811,10 +94576,6 @@ /* #include duk_internal.h -> already included */ -/* XXX: Avoid duk_{memcmp,memmove}_unsafe() by imposing a minimum length of - * >0 for the underlying dynamic buffer. - */ - /* * Macro support functions (use only macros in calling code) */ @@ -95826,9 +94587,6 @@ DUK_ASSERT(bw_ctx != NULL); DUK_UNREF(thr); - /* 'p' might be NULL when the underlying buffer is zero size. If so, - * the resulting pointers are not used unsafely. - */ p = (duk_uint8_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, bw_ctx->buf); DUK_ASSERT(p != NULL || (DUK_HBUFFER_DYNAMIC_GET_SIZE(bw_ctx->buf) == 0 && curr_offset == 0 && new_length == 0)); bw_ctx->p = p + curr_offset; @@ -95837,6 +94595,7 @@ } DUK_INTERNAL void duk_bw_init(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_hbuffer_dynamic *h_buf) { + DUK_ASSERT(thr != NULL); DUK_ASSERT(bw_ctx != NULL); DUK_ASSERT(h_buf != NULL); @@ -95851,7 +94610,6 @@ (void) duk_push_dynamic_buffer(thr, buf_size); bw_ctx->buf = (duk_hbuffer_dynamic *) duk_known_hbuffer(thr, -1); - DUK_ASSERT(bw_ctx->buf != NULL); duk__bw_update_ptrs(thr, bw_ctx, 0, buf_size); } @@ -95876,7 +94634,7 @@ if (DUK_UNLIKELY(new_sz < curr_off)) { /* overflow */ DUK_ERROR_RANGE(thr, DUK_STR_BUFFER_TOO_LONG); - DUK_WO_NORETURN(return NULL;); + return NULL; /* not reachable */ } #if 0 /* for manual torture testing: tight allocation, useful with valgrind */ new_sz = curr_off + sz; @@ -95919,9 +94677,9 @@ DUK_UNREF(thr); p_base = bw->p_base; - duk_memcpy_unsafe((void *) bw->p, - (const void *) (p_base + src_off), - (size_t) len); + DUK_MEMCPY((void *) bw->p, + (const void *) (p_base + src_off), + (size_t) len); bw->p += len; } @@ -95951,12 +94709,12 @@ move_sz = buf_sz - dst_off; DUK_ASSERT(p_base != NULL); /* buffer size is >= 1 */ - duk_memmove_unsafe((void *) (p_base + dst_off + len), - (const void *) (p_base + dst_off), - (size_t) move_sz); - duk_memcpy_unsafe((void *) (p_base + dst_off), - (const void *) buf, - (size_t) len); + DUK_MEMMOVE((void *) (p_base + dst_off + len), + (const void *) (p_base + dst_off), + (size_t) move_sz); + DUK_MEMCPY((void *) (p_base + dst_off), + (const void *) buf, + (size_t) len); bw->p += len; } @@ -95998,12 +94756,12 @@ move_sz = buf_sz - dst_off; DUK_ASSERT(p_base != NULL); /* buffer size is >= 1 */ - duk_memmove_unsafe((void *) (p_base + dst_off + len), - (const void *) (p_base + dst_off), - (size_t) move_sz); - duk_memcpy_unsafe((void *) (p_base + dst_off), - (const void *) (p_base + src_off), - (size_t) len); + DUK_MEMMOVE((void *) (p_base + dst_off + len), + (const void *) (p_base + dst_off), + (size_t) move_sz); + DUK_MEMCPY((void *) (p_base + dst_off), + (const void *) (p_base + src_off), + (size_t) len); bw->p += len; } @@ -96036,7 +94794,7 @@ move_sz = buf_sz - off; p_dst = p_base + off + len; p_src = p_base + off; - duk_memmove_unsafe((void *) p_dst, (const void *) p_src, (size_t) move_sz); + DUK_MEMMOVE((void *) p_dst, (const void *) p_src, (size_t) move_sz); return p_src; /* point to start of 'reserved area' */ } @@ -96067,9 +94825,9 @@ p_dst = p_base + off; p_src = p_dst + len; move_sz = (duk_size_t) (bw->p - p_src); - duk_memmove_unsafe((void *) p_dst, - (const void *) p_src, - (size_t) move_sz); + DUK_MEMMOVE((void *) p_dst, + (const void *) p_src, + (size_t) move_sz); bw->p -= len; } @@ -96090,7 +94848,7 @@ duk_uint16_t x; } u; - duk_memcpy((void *) u.b, (const void *) (*p), (size_t) 2); + DUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 2); u.x = DUK_NTOH16(u.x); *p += 2; return u.x; @@ -96102,7 +94860,7 @@ duk_uint32_t x; } u; - duk_memcpy((void *) u.b, (const void *) (*p), (size_t) 4); + DUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 4); u.x = DUK_NTOH32(u.x); *p += 4; return u.x; @@ -96115,10 +94873,10 @@ duk_uint32_t x; } u; - duk_memcpy((void *) u.b, (const void *) (*p), (size_t) 4); + DUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 4); u.x = DUK_NTOH32(u.x); du.ui[DUK_DBL_IDX_UI0] = u.x; - duk_memcpy((void *) u.b, (const void *) (*p + 4), (size_t) 4); + DUK_MEMCPY((void *) u.b, (const void *) (*p + 4), (size_t) 4); u.x = DUK_NTOH32(u.x); du.ui[DUK_DBL_IDX_UI1] = u.x; *p += 8; @@ -96133,7 +94891,7 @@ } u; u.x = DUK_HTON16(val); - duk_memcpy((void *) (*p), (const void *) u.b, (size_t) 2); + DUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 2); *p += 2; } @@ -96144,7 +94902,7 @@ } u; u.x = DUK_HTON32(val); - duk_memcpy((void *) (*p), (const void *) u.b, (size_t) 4); + DUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 4); *p += 4; } @@ -96158,416 +94916,12 @@ du.d = val; u.x = du.ui[DUK_DBL_IDX_UI0]; u.x = DUK_HTON32(u.x); - duk_memcpy((void *) (*p), (const void *) u.b, (size_t) 4); + DUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 4); u.x = du.ui[DUK_DBL_IDX_UI1]; u.x = DUK_HTON32(u.x); - duk_memcpy((void *) (*p + 4), (const void *) u.b, (size_t) 4); + DUK_MEMCPY((void *) (*p + 4), (const void *) u.b, (size_t) 4); *p += 8; } -#line 1 "duk_util_cast.c" -/* - * Cast helpers. - * - * C99+ coercion is challenging portability-wise because out-of-range casts - * may invoke implementation defined or even undefined behavior. See e.g. - * http://blog.frama-c.com/index.php?post/2013/10/09/Overflow-float-integer. - * - * Provide explicit cast helpers which try to avoid implementation defined - * or undefined behavior. These helpers can then be simplified in the vast - * majority of cases where the implementation defined or undefined behavior - * is not problematic. - */ - -/* #include duk_internal.h -> already included */ - -/* Portable double-to-integer cast which avoids undefined behavior and avoids - * relying on fmin(), fmax(), or other intrinsics. Out-of-range results are - * not assumed by caller, but here value is clamped, NaN converts to minval. - */ -#define DUK__DOUBLE_INT_CAST1(tname,minval,maxval) do { \ - if (DUK_LIKELY(x >= (duk_double_t) (minval))) { \ - DUK_ASSERT(!DUK_ISNAN(x)); \ - if (DUK_LIKELY(x <= (duk_double_t) (maxval))) { \ - return (tname) x; \ - } else { \ - return (tname) (maxval); \ - } \ - } else { \ - /* NaN or below minval. Since we don't care about the result \ - * for out-of-range values, just return the minimum value for \ - * both. \ - */ \ - return (tname) (minval); \ - } \ - } while (0) - -/* Rely on specific NaN behavior for duk_double_{fmin,fmax}(): if either - * argument is a NaN, return the second argument. This avoids a - * NaN-to-integer cast which is undefined behavior. - */ -#define DUK__DOUBLE_INT_CAST2(tname,minval,maxval) do { \ - return (tname) duk_double_fmin(duk_double_fmax(x, (duk_double_t) (minval)), (duk_double_t) (maxval)); \ - } while (0) - -/* Another solution which doesn't need C99+ behavior for fmin() and fmax(). */ -#define DUK__DOUBLE_INT_CAST3(tname,minval,maxval) do { \ - if (DUK_ISNAN(x)) { \ - /* 0 or any other value is fine. */ \ - return (tname) 0; \ - } else \ - return (tname) DUK_FMIN(DUK_FMAX(x, (duk_double_t) (minval)), (duk_double_t) (maxval)); \ - } \ - } while (0) - -/* C99+ solution: relies on specific fmin() and fmax() behavior in C99: if - * one argument is NaN but the other isn't, the non-NaN argument is returned. - * Because the limits are non-NaN values, explicit NaN check is not needed. - * This may not work on all legacy platforms, and also doesn't seem to inline - * the fmin() and fmax() calls (unless one uses -ffast-math which we don't - * support). - */ -#define DUK__DOUBLE_INT_CAST4(tname,minval,maxval) do { \ - return (tname) DUK_FMIN(DUK_FMAX(x, (duk_double_t) (minval)), (duk_double_t) (maxval)); \ - } while (0) - -DUK_INTERNAL duk_int_t duk_double_to_int_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - /* Real world solution: almost any practical platform will provide - * an integer value without any guarantees what it is (which is fine). - */ - return (duk_int_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_int_t, DUK_INT_MIN, DUK_INT_MAX); -#endif -} - -DUK_INTERNAL duk_uint_t duk_double_to_uint_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_uint_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_uint_t, DUK_UINT_MIN, DUK_UINT_MAX); -#endif -} - -DUK_INTERNAL duk_int32_t duk_double_to_int32_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_int32_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_int32_t, DUK_INT32_MIN, DUK_INT32_MAX); -#endif -} - -DUK_INTERNAL duk_uint32_t duk_double_to_uint32_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_uint32_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_uint32_t, DUK_UINT32_MIN, DUK_UINT32_MAX); -#endif -} - -/* Largest IEEE double that doesn't round to infinity in the default rounding - * mode. The exact midpoint between (1 - 2^(-24)) * 2^128 and 2^128 rounds to - * infinity, at least on x64. This number is one double unit below that - * midpoint. See misc/float_cast.c. - */ -#define DUK__FLOAT_ROUND_LIMIT 340282356779733623858607532500980858880.0 - -/* Maximum IEEE float. Double-to-float conversion above this would be out of - * range and thus technically undefined behavior. - */ -#define DUK__FLOAT_MAX 340282346638528859811704183484516925440.0 - -DUK_INTERNAL duk_float_t duk_double_to_float_t(duk_double_t x) { - /* Even a double-to-float cast is technically undefined behavior if - * the double is out-of-range. C99 Section 6.3.1.5: - * - * If the value being converted is in the range of values that can - * be represented but cannot be represented exactly, the result is - * either the nearest higher or nearest lower representable value, - * chosen in an implementation-defined manner. If the value being - * converted is outside the range of values that can be represented, - * the behavior is undefined. - */ -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_float_t) x; -#else - duk_double_t t; - - t = DUK_FABS(x); - DUK_ASSERT((DUK_ISNAN(x) && DUK_ISNAN(t)) || - (!DUK_ISNAN(x) && !DUK_ISNAN(t))); - - if (DUK_LIKELY(t <= DUK__FLOAT_MAX)) { - /* Standard in-range case, try to get here with a minimum - * number of checks and branches. - */ - DUK_ASSERT(!DUK_ISNAN(x)); - return (duk_float_t) x; - } else if (t <= DUK__FLOAT_ROUND_LIMIT) { - /* Out-of-range, but rounds to min/max float. */ - DUK_ASSERT(!DUK_ISNAN(x)); - if (x < 0.0) { - return (duk_float_t) -DUK__FLOAT_MAX; - } else { - return (duk_float_t) DUK__FLOAT_MAX; - } - } else if (DUK_ISNAN(x)) { - /* Assumes double NaN -> float NaN considered "in range". */ - DUK_ASSERT(DUK_ISNAN(x)); - return (duk_float_t) x; - } else { - /* Out-of-range, rounds to +/- Infinity. */ - if (x < 0.0) { - return (duk_float_t) -DUK_DOUBLE_INFINITY; - } else { - return (duk_float_t) DUK_DOUBLE_INFINITY; - } - } -#endif -} - -/* automatic undefs */ -#undef DUK__DOUBLE_INT_CAST1 -#undef DUK__DOUBLE_INT_CAST2 -#undef DUK__DOUBLE_INT_CAST3 -#undef DUK__DOUBLE_INT_CAST4 -#undef DUK__FLOAT_MAX -#undef DUK__FLOAT_ROUND_LIMIT -#line 1 "duk_util_double.c" -/* - * IEEE double helpers. - */ - -/* #include duk_internal.h -> already included */ - -DUK_INTERNAL duk_bool_t duk_double_is_anyinf(duk_double_t x) { - duk_double_union du; - du.d = x; - return DUK_DBLUNION_IS_ANYINF(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_posinf(duk_double_t x) { - duk_double_union du; - du.d = x; - return DUK_DBLUNION_IS_POSINF(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_neginf(duk_double_t x) { - duk_double_union du; - du.d = x; - return DUK_DBLUNION_IS_NEGINF(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan(duk_double_t x) { - duk_double_union du; - du.d = x; - /* Assumes we're dealing with a Duktape internal NaN which is - * NaN normalized if duk_tval requires it. - */ - DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); - return DUK_DBLUNION_IS_NAN(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan_or_zero(duk_double_t x) { - duk_double_union du; - du.d = x; - /* Assumes we're dealing with a Duktape internal NaN which is - * NaN normalized if duk_tval requires it. - */ - DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); - return DUK_DBLUNION_IS_NAN(&du) || DUK_DBLUNION_IS_ANYZERO(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan_or_inf(duk_double_t x) { - duk_double_union du; - du.d = x; - /* If exponent is 0x7FF the argument is either a NaN or an - * infinity. We don't need to check any other fields. - */ -#if defined(DUK_USE_64BIT_OPS) -#if defined(DUK_USE_DOUBLE_ME) - return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000)) == DUK_U64_CONSTANT(0x000000007ff00000); -#else - return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000)) == DUK_U64_CONSTANT(0x7ff0000000000000); -#endif -#else - return (du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL) == 0x7ff00000UL; -#endif -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan_zero_inf(duk_double_t x) { - duk_double_union du; -#if defined(DUK_USE_64BIT_OPS) - duk_uint64_t t; -#else - duk_uint32_t t; -#endif - du.d = x; -#if defined(DUK_USE_64BIT_OPS) -#if defined(DUK_USE_DOUBLE_ME) - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000); - if (t == DUK_U64_CONSTANT(0x0000000000000000)) { - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x0000000080000000); - return t == 0; - } - if (t == DUK_U64_CONSTANT(0x000000007ff00000)) { - return 1; - } -#else - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000); - if (t == DUK_U64_CONSTANT(0x0000000000000000)) { - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x8000000000000000); - return t == 0; - } - if (t == DUK_U64_CONSTANT(0x7ff0000000000000)) { - return 1; - } -#endif -#else - t = du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL; - if (t == 0x00000000UL) { - return DUK_DBLUNION_IS_ANYZERO(&du); - } - if (t == 0x7ff00000UL) { - return 1; - } -#endif - return 0; -} - -DUK_INTERNAL duk_small_uint_t duk_double_signbit(duk_double_t x) { - duk_double_union du; - du.d = x; - return (duk_small_uint_t) DUK_DBLUNION_GET_SIGNBIT(&du); -} - -DUK_INTERNAL duk_double_t duk_double_trunc_towards_zero(duk_double_t x) { - /* XXX: optimize */ - duk_small_uint_t s = duk_double_signbit(x); - x = DUK_FLOOR(DUK_FABS(x)); /* truncate towards zero */ - if (s) { - x = -x; - } - return x; -} - -DUK_INTERNAL duk_bool_t duk_double_same_sign(duk_double_t x, duk_double_t y) { - duk_double_union du1; - duk_double_union du2; - du1.d = x; - du2.d = y; - - return (((du1.ui[DUK_DBL_IDX_UI0] ^ du2.ui[DUK_DBL_IDX_UI0]) & 0x80000000UL) == 0); -} - -DUK_INTERNAL duk_double_t duk_double_fmin(duk_double_t x, duk_double_t y) { - /* Doesn't replicate fmin() behavior exactly: for fmin() if one - * argument is a NaN, the other argument should be returned. - * Duktape doesn't rely on this behavior so the replacement can - * be simplified. - */ - return (x < y ? x : y); -} - -DUK_INTERNAL duk_double_t duk_double_fmax(duk_double_t x, duk_double_t y) { - /* Doesn't replicate fmax() behavior exactly: for fmax() if one - * argument is a NaN, the other argument should be returned. - * Duktape doesn't rely on this behavior so the replacement can - * be simplified. - */ - return (x > y ? x : y); -} - -DUK_INTERNAL duk_bool_t duk_double_is_finite(duk_double_t x) { - return !duk_double_is_nan_or_inf(x); -} - -DUK_INTERNAL duk_bool_t duk_double_is_integer(duk_double_t x) { - if (duk_double_is_nan_or_inf(x)) { - return 0; - } else { - return duk_js_tointeger_number(x) == x; - } -} - -DUK_INTERNAL duk_bool_t duk_double_is_safe_integer(duk_double_t x) { - /* >>> 2**53-1 - * 9007199254740991 - */ - return duk_double_is_integer(x) && DUK_FABS(x) <= 9007199254740991.0; -} - -/* Check whether a duk_double_t is a whole number in the 32-bit range (reject - * negative zero), and if so, return a duk_int32_t. - * For compiler use: don't allow negative zero as it will cause trouble with - * LDINT+LDINTX, positive zero is OK. - */ -DUK_INTERNAL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int32_t *ival) { - duk_int32_t t; - - t = duk_double_to_int32_t(x); - if (!((duk_double_t) t == x)) { - return 0; - } - if (t == 0) { - duk_double_union du; - du.d = x; - if (DUK_DBLUNION_HAS_SIGNBIT(&du)) { - return 0; - } - } - *ival = t; - return 1; -} - -/* Check whether a duk_double_t is a whole number in the 32-bit range, and if - * so, return a duk_int32_t. - */ -DUK_INTERNAL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival) { - duk_int32_t t; - - t = duk_double_to_int32_t(x); - if (!((duk_double_t) t == x)) { - return 0; - } - *ival = t; - return 1; -} - -/* Division: division by zero is undefined behavior (and may in fact trap) - * so it needs special handling for portability. - */ - -DUK_INTERNAL DUK_INLINE duk_double_t duk_double_div(duk_double_t x, duk_double_t y) { -#if !defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - if (DUK_UNLIKELY(y == 0.0)) { - /* In C99+ division by zero is undefined behavior so - * avoid it entirely. Hopefully the compiler is - * smart enough to avoid emitting any actual code - * because almost all practical platforms behave as - * expected. - */ - if (x > 0.0) { - if (DUK_SIGNBIT(y)) { - return -DUK_DOUBLE_INFINITY; - } else { - return DUK_DOUBLE_INFINITY; - } - } else if (x < 0.0) { - if (DUK_SIGNBIT(y)) { - return DUK_DOUBLE_INFINITY; - } else { - return -DUK_DOUBLE_INFINITY; - } - } else { - /* +/- 0, NaN */ - return DUK_DOUBLE_NAN; - } - } -#endif - - return x / y; -} #line 1 "duk_util_hashbytes.c" /* * Hash function duk_util_hashbytes(). @@ -96630,43 +94984,6 @@ /* automatic undefs */ #undef DUK__MAGIC_M #undef DUK__MAGIC_R -#line 1 "duk_util_memory.c" -/* - * Memory utils. - */ - -/* #include duk_internal.h -> already included */ - -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp_unsafe(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL || len == 0U); - DUK_ASSERT(s2 != NULL || len == 0U); - return DUK_MEMCMP(s1, s2, (size_t) len); -} - -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL); - DUK_ASSERT(s2 != NULL); - return DUK_MEMCMP(s1, s2, (size_t) len); -} -#else /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp_unsafe(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL || len == 0U); - DUK_ASSERT(s2 != NULL || len == 0U); - if (DUK_UNLIKELY(len == 0U)) { - return 0; - } - DUK_ASSERT(s1 != NULL); - DUK_ASSERT(s2 != NULL); - return duk_memcmp(s1, s2, len); -} - -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL); - DUK_ASSERT(s2 != NULL); - return DUK_MEMCMP(s1, s2, (size_t) len); -} -#endif /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ #line 1 "duk_util_tinyrandom.c" /* * A tiny random number generator used for Math.random() and other internals. diff -Nru duktape-2.3.0/src/duktape.h duktape-2.2.0/src/duktape.h --- duktape-2.3.0/src/duktape.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src/duktape.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,12 +1,12 @@ /* - * Duktape public API for Duktape 2.3.0. + * Duktape public API for Duktape 2.2.0. * * See the API reference for documentation on call semantics. The exposed, * supported API is between the "BEGIN PUBLIC API" and "END PUBLIC API" * comments. Other parts of the header are Duktape internal and related to * e.g. platform/compiler/feature detection. * - * Git commit d7fdb67f18561a50e06bafd196c6b423af9ad6fe (v2.3.0). + * Git commit a459cf3c9bd1779fc01b435d69302b742675a08f (v2.2.0). * Git branch master. * * See Duktape AUTHORS.rst and LICENSE.txt for copyright and @@ -21,7 +21,7 @@ * * (http://opensource.org/licenses/MIT) * - * Copyright (c) 2013-2018 by Duktape authors (see AUTHORS.rst) + * Copyright (c) 2013-2017 by Duktape authors (see AUTHORS.rst) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -92,14 +92,6 @@ * * Steven Don (https://github.com/shdon) * * Simon Stone (https://github.com/sstone1) * * \J. McC. (https://github.com/jmhmccr) - * * Jakub Nowakowski (https://github.com/jimvonmoon) - * * Tommy Nguyen (https://github.com/tn0502) - * * Fabrice Fontaine (https://github.com/ffontaine) - * * Christopher Hiller (https://github.com/boneskull) - * * Gonzalo Diethelm (https://github.com/gonzus) - * * Michal Kasperek (https://github.com/michalkas) - * * Andrew Janke (https://github.com/apjanke) - * * Steve Fan (https://github.com/stevefan1999) * * Other contributions * =================== @@ -138,8 +130,6 @@ * * https://github.com/chris-y * * Laurent Zubiaur (https://github.com/lzubiaur) * * Neil Kolban (https://github.com/nkolban) - * * Wilhelm Wanecek (https://github.com/wanecek) - * * Andrew Janke (https://github.com/apjanke) * * If you are accidentally missing from this list, send me an e-mail * (``sami.vaarala@iki.fi``) and I'll fix the omission. @@ -160,19 +150,19 @@ /* Duktape version, (major * 10000) + (minor * 100) + patch. Allows C code * to #if (DUK_VERSION >= NNN) against Duktape API version. The same value - * is also available to ECMAScript code in Duktape.version. Unofficial + * is also available to Ecmascript code in Duktape.version. Unofficial * development snapshots have 99 for patch level (e.g. 0.10.99 would be a * development version after 0.10.0 but before the next official release). */ -#define DUK_VERSION 20300L +#define DUK_VERSION 20200L /* Git commit, describe, and branch for Duktape build. Useful for * non-official snapshot builds so that application code can easily log - * which Duktape snapshot was used. Not available in the ECMAScript + * which Duktape snapshot was used. Not available in the Ecmascript * environment. */ -#define DUK_GIT_COMMIT "d7fdb67f18561a50e06bafd196c6b423af9ad6fe" -#define DUK_GIT_DESCRIBE "v2.3.0" +#define DUK_GIT_COMMIT "a459cf3c9bd1779fc01b435d69302b742675a08f" +#define DUK_GIT_DESCRIBE "v2.2.0" #define DUK_GIT_BRANCH "master" /* External duk_config.h provides platform/compiler/OS dependent @@ -268,7 +258,7 @@ }; struct duk_time_components { - duk_double_t year; /* year, e.g. 2016, ECMAScript year range */ + duk_double_t year; /* year, e.g. 2016, Ecmascript year range */ duk_double_t month; /* month: 1-12 */ duk_double_t day; /* day: 1-31 */ duk_double_t hours; /* hour: 0-59 */ @@ -304,12 +294,12 @@ /* Value types, used by e.g. duk_get_type() */ #define DUK_TYPE_MIN 0U #define DUK_TYPE_NONE 0U /* no value, e.g. invalid index */ -#define DUK_TYPE_UNDEFINED 1U /* ECMAScript undefined */ -#define DUK_TYPE_NULL 2U /* ECMAScript null */ -#define DUK_TYPE_BOOLEAN 3U /* ECMAScript boolean: 0 or 1 */ -#define DUK_TYPE_NUMBER 4U /* ECMAScript number: double */ -#define DUK_TYPE_STRING 5U /* ECMAScript string: CESU-8 / extended UTF-8 encoded */ -#define DUK_TYPE_OBJECT 6U /* ECMAScript object: includes objects, arrays, functions, threads */ +#define DUK_TYPE_UNDEFINED 1U /* Ecmascript undefined */ +#define DUK_TYPE_NULL 2U /* Ecmascript null */ +#define DUK_TYPE_BOOLEAN 3U /* Ecmascript boolean: 0 or 1 */ +#define DUK_TYPE_NUMBER 4U /* Ecmascript number: double */ +#define DUK_TYPE_STRING 5U /* Ecmascript string: CESU-8 / extended UTF-8 encoded */ +#define DUK_TYPE_OBJECT 6U /* Ecmascript object: includes objects, arrays, functions, threads */ #define DUK_TYPE_BUFFER 7U /* fixed or dynamic, garbage collected byte buffer */ #define DUK_TYPE_POINTER 8U /* raw void pointer */ #define DUK_TYPE_LIGHTFUNC 9U /* lightweight function pointer */ @@ -678,21 +668,7 @@ DUK_EXTERNAL_DECL const char *duk_push_sprintf(duk_context *ctx, const char *fmt, ...); DUK_EXTERNAL_DECL const char *duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap); -/* duk_push_literal() may evaluate its argument (a C string literal) more than - * once on purpose. When speed is preferred, sizeof() avoids an unnecessary - * strlen() at runtime. Sizeof("foo") == 4, so subtract 1. The argument - * must be non-NULL and should not contain internal NUL characters as the - * behavior will then depend on config options. - */ -#if defined(DUK_USE_PREFER_SIZE) -#define duk_push_literal(ctx,cstring) duk_push_string((ctx), (cstring)) -#else -DUK_EXTERNAL_DECL const char *duk_push_literal_raw(duk_context *ctx, const char *str, duk_size_t len); -#define duk_push_literal(ctx,cstring) duk_push_literal_raw((ctx), (cstring), sizeof((cstring)) - 1U) -#endif - DUK_EXTERNAL_DECL void duk_push_this(duk_context *ctx); -DUK_EXTERNAL_DECL void duk_push_new_target(duk_context *ctx); DUK_EXTERNAL_DECL void duk_push_current_function(duk_context *ctx); DUK_EXTERNAL_DECL void duk_push_current_thread(duk_context *ctx); DUK_EXTERNAL_DECL void duk_push_global_object(duk_context *ctx); @@ -1024,55 +1000,29 @@ /* * Property access * - * The basic function assumes key is on stack. The _(l)string variant takes - * a C string as a property name; the _literal variant takes a C literal. - * The _index variant takes an array index as a property name (e.g. 123 is - * equivalent to the key "123"). The _heapptr variant takes a raw, borrowed - * heap pointer. + * The basic function assumes key is on stack. The _string variant takes + * a C string as a property name, while the _index variant takes an array + * index as a property name (e.g. 123 is equivalent to the key "123"). */ DUK_EXTERNAL_DECL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_get_prop_literal(ctx,obj_idx,key) duk_get_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_get_prop_literal(ctx,obj_idx,key) duk_get_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_put_prop_literal(ctx,obj_idx,key) duk_put_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_put_prop_literal(ctx,obj_idx,key) duk_put_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_del_prop_literal(ctx,obj_idx,key) duk_del_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_del_prop_literal(ctx,obj_idx,key) duk_del_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_has_prop_literal(ctx,obj_idx,key) duk_has_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_has_prop_literal(ctx,obj_idx,key) duk_has_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); @@ -1081,22 +1031,8 @@ DUK_EXTERNAL_DECL duk_bool_t duk_get_global_string(duk_context *ctx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_get_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_get_global_literal(ctx,key) duk_get_global_string((ctx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_get_global_literal_raw(duk_context *ctx, const char *key, duk_size_t key_len); -#define duk_get_global_literal(ctx,key) duk_get_global_literal_raw((ctx), (key), sizeof((key)) - 1U) -#endif -DUK_EXTERNAL_DECL duk_bool_t duk_get_global_heapptr(duk_context *ctx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_put_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_put_global_literal(ctx,key) duk_put_global_string((ctx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_put_global_literal_raw(duk_context *ctx, const char *key, duk_size_t key_len); -#define duk_put_global_literal(ctx,key) duk_put_global_literal_raw((ctx), (key), sizeof((key)) - 1U) -#endif -DUK_EXTERNAL_DECL duk_bool_t duk_put_global_heapptr(duk_context *ctx, void *ptr); /* * Inspection @@ -1163,7 +1099,7 @@ DUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t idx, duk_size_t char_offset); /* - * ECMAScript operators + * Ecmascript operators */ DUK_EXTERNAL_DECL duk_bool_t duk_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2); @@ -1172,12 +1108,6 @@ DUK_EXTERNAL_DECL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2); /* - * Random - */ - -DUK_EXTERNAL_DECL duk_double_t duk_random(duk_context *ctx); - -/* * Function (method) calls */ @@ -1327,7 +1257,7 @@ #define DUK_DATE_MSEC_HOUR (60L * 60L * 1000L) #define DUK_DATE_MSEC_DAY (24L * 60L * 60L * 1000L) -/* ECMAScript date range is 100 million days from Epoch: +/* Ecmascript date range is 100 million days from Epoch: * > 100e6 * 24 * 60 * 60 * 1000 // 100M days in millisecs * 8640000000000000 * (= 8.64e15) @@ -1335,7 +1265,7 @@ #define DUK_DATE_MSEC_100M_DAYS (8.64e15) #define DUK_DATE_MSEC_100M_DAYS_LEEWAY (8.64e15 + 24 * 3600e3) -/* ECMAScript year range: +/* Ecmascript year range: * > new Date(100e6 * 24 * 3600e3).toISOString() * '+275760-09-13T00:00:00.000Z' * > new Date(-100e6 * 24 * 3600e3).toISOString() @@ -1345,7 +1275,7 @@ #define DUK_DATE_MAX_ECMA_YEAR 275760L /* Part indices for internal breakdowns. Part order from DUK_DATE_IDX_YEAR - * to DUK_DATE_IDX_MILLISECOND matches argument ordering of ECMAScript API + * to DUK_DATE_IDX_MILLISECOND matches argument ordering of Ecmascript API * calls (like Date constructor call). Some functions in duk_bi_date.c * depend on the specific ordering, so change with care. 16 bits are not * enough for all parts (year, specifically). diff -Nru duktape-2.3.0/src-input/builtins.yaml duktape-2.2.0/src-input/builtins.yaml --- duktape-2.3.0/src-input/builtins.yaml 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/builtins.yaml 2017-09-23 01:06:08.000000000 +0000 @@ -57,10 +57,10 @@ # # Property value format: # -# - ECMAScript undefined: +# - Ecmascript undefined: # - type: undefined # - Plain YAML/JSON null (parses as Python None) -# - treated as ECMAScript null +# - treated as Ecmascript null # - Plain string: # - treated as plain string, string data as with keys # - Plain symbol: @@ -417,13 +417,15 @@ present_if: DUK_USE_GLOBAL_BUILTIN - key: "parseInt" value: - type: object - id: bi_parse_int + type: function + native: duk_bi_global_object_parse_int + length: 2 present_if: DUK_USE_GLOBAL_BUILTIN - key: "parseFloat" value: - type: object - id: bi_parse_float + type: function + native: duk_bi_global_object_parse_float + length: 1 present_if: DUK_USE_GLOBAL_BUILTIN - key: "isNaN" value: @@ -512,34 +514,6 @@ performance_api: true present_if: DUK_USE_PERFORMANCE_BUILTIN - - id: bi_parse_int - class: Function - internal_prototype: bi_function_prototype - native: duk_bi_global_object_parse_int - callable: true - constructable: false - bidx: false - present_if: DUK_USE_OBJECT_BUILTIN - - properties: - - key: "length" - value: 2 - attributes: "c" - - - id: bi_parse_float - class: Function - internal_prototype: bi_function_prototype - native: duk_bi_global_object_parse_float - callable: true - constructable: false - bidx: false - present_if: DUK_USE_OBJECT_BUILTIN - - properties: - - key: "length" - value: 1 - attributes: "c" - - id: bi_global_env class: ObjEnv duktape: true @@ -871,17 +845,12 @@ present_if: DUK_USE_FUNCTION_BUILTIN # ES2015 - - key: # @@hasInstance - type: symbol - variant: wellknown - string: "Symbol.hasInstance" - value: - type: function - native: duk_bi_function_prototype_hasinstance - length: 1 - attributes: "" - es6: true - present_if: DUK_USE_SYMBOL_BUILTIN + #- key: # @@hasInstance + # type: symbol + # variant: wellknown + # string: "Symbol.hasInstance" + # value: XXX + # es6: true # Duktape specific %NativeFunctionPrototype% which provides some getters. # @@ -1527,80 +1496,6 @@ type: double bytes: "fff0000000000000" # DBL_NEGATIVE_INFINITY attributes: "" - - key: "EPSILON" - value: - type: double - bytes: "3cb0000000000000" # 3ff0000000000001 - 3ff0000000000000 = 3cb0000000000000 - attributes: "" - es6: true - present_if: DUK_USE_ES6 - - key: "MAX_SAFE_INTEGER" - value: - # >>> struct.pack('>d', 9007199254740991.0).encode('hex') - # '433fffffffffffff' - type: double - bytes: "433fffffffffffff" - attributes: "" - es6: true - present_if: DUK_USE_ES6 - - key: "MIN_SAFE_INTEGER" - value: - # >>> struct.pack('>d', -9007199254740991.0).encode('hex') - # 'c33fffffffffffff' - type: double - bytes: "c33fffffffffffff" - attributes: "" - es6: true - present_if: DUK_USE_ES6 - - - key: "isFinite" - value: - type: function - native: duk_bi_number_check_shared - length: 1 - magic: 0 - attributes: "wc" - es6: true - present_if: DUK_USE_ES6 - - key: "isInteger" - value: - type: function - native: duk_bi_number_check_shared - length: 1 - magic: 1 - attributes: "wc" - es6: true - present_if: DUK_USE_ES6 - - key: "isNaN" - value: - type: function - native: duk_bi_number_check_shared - length: 1 - magic: 2 - attributes: "wc" - es6: true - present_if: DUK_USE_ES6 - - key: "isSafeInteger" - value: - type: function - native: duk_bi_number_check_shared - length: 1 - magic: 3 - attributes: "wc" - es6: true - present_if: DUK_USE_ES6 - - key: "parseInt" # Must map to the exactly same object as global parseInt() - value: - type: object - id: bi_parse_int - es6: true - present_if: DUK_USE_ES6 - - key: "parseFloat" # Must map to the exactly same object as global parseFloat() - value: - type: object - id: bi_parse_float - es6: true - present_if: DUK_USE_ES6 - id: bi_number_prototype class: Number @@ -1620,10 +1515,6 @@ # which prevents a Number instance's internal value also from being # written with standard methods. The internal code creating Number # instances has no such issues. - # - # Number.prototype is a Number itself in ES5.1 and ES2016+. It was - # briefly made a non-Number in ES2015 but this change was reverted - # in ES2016. - key: type: symbol variant: hidden @@ -2064,18 +1955,12 @@ magic: 39 section_b: true - - key: # @@toPrimitive - type: symbol - variant: wellknown - string: "Symbol.toPrimitive" - value: - type: function - native: duk_bi_date_prototype_toprimitive - length: 1 - name: "[Symbol.toPrimitive]" - attributes: "c" - es6: true - present_if: DUK_USE_SYMBOL_BUILTIN + #- key: # @@toPrimitive + # type: symbol + # variant: wellknown + # string: "Symbol.toPrimitive" + # value: XXX + # es6: true - id: bi_regexp_constructor class: Function @@ -2848,7 +2733,6 @@ value: "Math" attributes: "c" es6: true - present_if: DUK_USE_SYMBOL_BUILTIN - id: bi_json class: JSON @@ -2879,7 +2763,6 @@ # string: "Symbol.toStringTag" # value: XXX # es6: true - # present_if: DUK_USE_SYMBOL_BUILTIN # E5 Section 13.2.3 - id: bi_type_error_thrower @@ -3331,21 +3214,20 @@ attributes: "wc" es6: true - - key: "hasInstance" - value: - type: symbol - variant: wellknown - string: "Symbol.hasInstance" - attributes: "" - es6: true - present_if: DUK_USE_SYMBOL_BUILTIN - - key: "isConcatSpreadable" - value: - type: symbol - variant: wellknown - string: "Symbol.isConcatSpreadable" - attributes: "" - es6: true + #- key: "hasInstance" + # value: + # type: symbol + # variant: wellknown + # string: "Symbol.hasInstance" + # attributes: "" + # es6: true + #- key: "isConcatSpreadable" + # value: + # type: symbol + # variant: wellknown + # string: "Symbol.isConcatSpreadable" + # attributes: "" + # es6: true - key: "iterator" value: type: symbol @@ -3353,7 +3235,6 @@ string: "Symbol.iterator" attributes: "" es6: true - present_if: DUK_USE_SYMBOL_BUILTIN #- key: "match" # value: # type: symbol @@ -3463,7 +3344,7 @@ type: symbol variant: wellknown string: "Symbol.toStringTag" - value: "Symbol" + value: "symbol" attributes: "c" es6: true present_if: DUK_USE_SYMBOL_BUILTIN @@ -5488,13 +5369,16 @@ # Firefox and Chrome: data property with 'wec' attributes, # inherited from PerformancePrototype. Use own data property # for now. + # XXX: we'd like to use 'wec' but current built-in init data doesn't + # support it; use 'wc' for consistency so ROM built-ins have the same + # behavior. - key: "now" value: type: function native: duk_bi_performance_now length: 0 nargs: 0 - attributes: "wec" + attributes: "wc" performance_api: true # Missing until semantics decided. #- key: "timeOrigin" diff -Nru duktape-2.3.0/src-input/duk_api_buffer.c duktape-2.2.0/src-input/duk_api_buffer.c --- duktape-2.3.0/src-input/duk_api_buffer.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_api_buffer.c 2017-09-23 01:06:08.000000000 +0000 @@ -14,10 +14,9 @@ if (!(DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE); - DUK_WO_NORETURN(return NULL;); } - /* Maximum size check is handled by callee. */ + /* maximum size check is handled by callee */ duk_hbuffer_resize(thr, h, new_size); return DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, h); @@ -35,7 +34,6 @@ if (!(DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE); - DUK_WO_NORETURN(return NULL;); } /* Forget the previous allocation, setting size to 0 and alloc to @@ -64,7 +62,6 @@ if (!DUK_HBUFFER_HAS_EXTERNAL(h)) { DUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE); - DUK_WO_NORETURN(return;); } DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(h)); diff -Nru duktape-2.3.0/src-input/duk_api_bytecode.c duktape-2.2.0/src-input/duk_api_bytecode.c --- duktape-2.3.0/src-input/duk_api_bytecode.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_api_bytecode.c 2017-09-23 01:06:08.000000000 +0000 @@ -40,7 +40,7 @@ len = DUK_RAW_READ_U32_BE(p); buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, (duk_size_t) len); DUK_ASSERT(buf != NULL); - duk_memcpy((void *) buf, (const void *) p, (size_t) len); + DUK_MEMCPY((void *) buf, (const void *) p, (size_t) len); p += len; return p; } @@ -55,7 +55,7 @@ DUK_ASSERT(len <= 0xffffffffUL); /* string limits */ tmp32 = (duk_uint32_t) len; DUK_RAW_WRITE_U32_BE(p, tmp32); - duk_memcpy((void *) p, + DUK_MEMCPY((void *) p, (const void *) DUK_HSTRING_GET_DATA(h), len); p += len; @@ -74,10 +74,9 @@ DUK_ASSERT(len <= 0xffffffffUL); /* buffer limits */ tmp32 = (duk_uint32_t) len; DUK_RAW_WRITE_U32_BE(p, tmp32); - /* When len == 0, buffer data pointer may be NULL. */ - duk_memcpy_unsafe((void *) p, - (const void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h), - len); + DUK_MEMCPY((void *) p, + (const void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h), + len); p += len; return p; } @@ -289,7 +288,7 @@ ins_end = DUK_HCOMPFUNC_GET_CODE_END(thr->heap, func); DUK_ASSERT((duk_size_t) (ins_end - ins) == (duk_size_t) count_instr); #if defined(DUK_USE_INTEGER_BE) - duk_memcpy_unsafe((void *) p, (const void *) ins, (size_t) (ins_end - ins)); + DUK_MEMCPY((void *) p, (const void *) ins, (size_t) (ins_end - ins)); p += (size_t) (ins_end - ins); #else while (ins != ins_end) { @@ -311,7 +310,7 @@ h_str = DUK_TVAL_GET_STRING(tv); DUK_ASSERT(h_str != NULL); DUK_ASSERT(DUK_HSTRING_MAX_BYTELEN <= 0x7fffffffUL); /* ensures no overflow */ - p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 1U + 4U + DUK_HSTRING_GET_BYTELEN(h_str), p); + p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 1U + 4U + DUK_HSTRING_GET_BYTELEN(h_str), p), *p++ = DUK__SER_STRING; p = duk__dump_hstring_raw(p, h_str); } else { @@ -475,7 +474,7 @@ DUK__ASSERT_LEFT(count_instr * sizeof(duk_instr_t)); #if defined(DUK_USE_INTEGER_BE) q = fun_data + sizeof(duk_tval) * count_const + sizeof(duk_hobject *) * count_funcs; - duk_memcpy((void *) q, + DUK_MEMCPY((void *) q, (const void *) p, sizeof(duk_instr_t) * count_instr); p += sizeof(duk_instr_t) * count_instr; @@ -540,12 +539,15 @@ DUK_ASSERT((count_const == 0 && count_funcs == 0) || tv1 != NULL); q = fun_data; - duk_memcpy_unsafe((void *) q, (const void *) tv1, sizeof(duk_tval) * count_const); - for (n = count_const; n > 0; n--) { - DUK_TVAL_INCREF_FAST(thr, (duk_tval *) (void *) q); /* no side effects */ - q += sizeof(duk_tval); + if (count_const > 0) { + /* Explicit zero size check to avoid NULL 'tv1'. */ + DUK_MEMCPY((void *) q, (const void *) tv1, sizeof(duk_tval) * count_const); + for (n = count_const; n > 0; n--) { + DUK_TVAL_INCREF_FAST(thr, (duk_tval *) (void *) q); /* no side effects */ + q += sizeof(duk_tval); + } + tv1 += count_const; } - tv1 += count_const; DUK_HCOMPFUNC_SET_FUNCS(thr->heap, h_fun, (duk_hobject **) (void *) q); for (n = count_funcs; n > 0; n--) { @@ -746,7 +748,6 @@ format_error: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_BYTECODE); - DUK_WO_NORETURN(return;); } #else /* DUK_USE_BYTECODE_DUMP_SUPPORT */ @@ -754,13 +755,11 @@ DUK_EXTERNAL void duk_dump_function(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_load_function(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_BYTECODE_DUMP_SUPPORT */ diff -Nru duktape-2.3.0/src-input/duk_api_call.c duktape-2.2.0/src-input/duk_api_call.c --- duktape-2.3.0/src-input/duk_api_call.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_api_call.c 2017-09-23 01:06:08.000000000 +0000 @@ -53,7 +53,7 @@ idx_func = duk_get_top(thr) - nargs - other; if (DUK_UNLIKELY((idx_func | nargs) < 0)) { /* idx_func < 0 || nargs < 0; OR sign bits */ DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + /* unreachable */ } DUK_ASSERT(duk_is_valid_index(thr, idx_func)); return idx_func; @@ -165,7 +165,6 @@ obj_idx = duk_require_normalize_index(thr, obj_idx); /* make absolute */ if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return;); } duk__call_prop_prep_stack(thr, obj_idx, nargs); @@ -202,7 +201,7 @@ args.nargs = nargs; if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } args.call_flags = 0; @@ -237,7 +236,7 @@ args.nargs = nargs; if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } args.call_flags = call_flags; @@ -278,7 +277,7 @@ args.nargs = nargs; if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } args.call_flags = 0; @@ -314,7 +313,7 @@ (long) (thr->valstack_top - thr->valstack), (long) nrets)); DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } rc = duk_handle_safe_call(thr, /* thread */ @@ -362,7 +361,7 @@ if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } rc = duk_safe_call(thr, duk__pnew_helper, (void *) &nargs /*udata*/, nargs + 1 /*nargs*/, 1 /*nrets*/); @@ -389,7 +388,6 @@ if (!duk_is_constructor_call(thr)) { DUK_ERROR_TYPE(thr, DUK_STR_CONSTRUCT_ONLY); - DUK_WO_NORETURN(return;); } } @@ -400,7 +398,7 @@ * because all Duktape/C functions are considered strict, * and strict is also the default when nothing is running. * However, Duktape may call this function internally when - * the current activation is an ECMAScript function, so + * the current activation is an Ecmascript function, so * this cannot be replaced by a 'return 1' without fixing * the internal call sites. */ @@ -467,7 +465,7 @@ /* fall through */ type_error: DUK_ERROR_TYPE(thr, DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_EXTERNAL void duk_set_magic(duk_hthread *thr, duk_idx_t idx, duk_int_t magic) { @@ -499,7 +497,7 @@ h = DUK_TVAL_GET_OBJECT(tv); DUK_ASSERT(h != NULL); if (DUK_HOBJECT_HAS_BOUNDFUNC(h)) { - duk_push_tval(thr, &((duk_hboundfunc *) (void *) h)->target); + duk_push_tval(thr, &((duk_hboundfunc *) h)->target); duk_replace(thr, -2); #if 0 DUK_TVAL_SET_TVAL(tv, &((duk_hboundfunc *) h)->target); diff -Nru duktape-2.3.0/src-input/duk_api_codec.c duktape-2.2.0/src-input/duk_api_codec.c --- duktape-2.3.0/src-input/duk_api_codec.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_api_codec.c 2017-09-23 01:06:08.000000000 +0000 @@ -8,10 +8,6 @@ #include "duk_internal.h" -/* - * Misc helpers - */ - /* Shared handling for encode/decode argument. Fast path handling for * buffer and string values because they're the most common. In particular, * avoid creating a temporary string or buffer when possible. @@ -33,425 +29,250 @@ return (const duk_uint8_t *) duk_to_lstring(thr, idx, out_len); } -/* - * Base64 - */ - -#if defined(DUK_USE_BASE64_SUPPORT) -/* Bytes emitted for number of padding characters in range [0,4]. */ -DUK_LOCAL const duk_int8_t duk__base64_decode_nequal_step[5] = { - 3, /* #### -> 24 bits, emit 3 bytes */ - 2, /* ###= -> 18 bits, emit 2 bytes */ - 1, /* ##== -> 12 bits, emit 1 byte */ - -1, /* #=== -> 6 bits, error */ - 0, /* ==== -> 0 bits, emit 0 bytes */ -}; - #if defined(DUK_USE_BASE64_FASTPATH) -DUK_LOCAL const duk_uint8_t duk__base64_enctab_fast[64] = { - 0x41U, 0x42U, 0x43U, 0x44U, 0x45U, 0x46U, 0x47U, 0x48U, 0x49U, 0x4aU, 0x4bU, 0x4cU, 0x4dU, 0x4eU, 0x4fU, 0x50U, /* A...P */ - 0x51U, 0x52U, 0x53U, 0x54U, 0x55U, 0x56U, 0x57U, 0x58U, 0x59U, 0x5aU, 0x61U, 0x62U, 0x63U, 0x64U, 0x65U, 0x66U, /* Q...f */ - 0x67U, 0x68U, 0x69U, 0x6aU, 0x6bU, 0x6cU, 0x6dU, 0x6eU, 0x6fU, 0x70U, 0x71U, 0x72U, 0x73U, 0x74U, 0x75U, 0x76U, /* g...v */ - 0x77U, 0x78U, 0x79U, 0x7aU, 0x30U, 0x31U, 0x32U, 0x33U, 0x34U, 0x35U, 0x36U, 0x37U, 0x38U, 0x39U, 0x2bU, 0x2fU /* w.../ */ -}; -#endif /* DUK_USE_BASE64_FASTPATH */ - -#if defined(DUK_USE_BASE64_FASTPATH) -/* Decode table for one byte of input: - * -1 = allowed whitespace - * -2 = padding - * -3 = error - * 0...63 decoded bytes - */ -DUK_LOCAL const duk_int8_t duk__base64_dectab_fast[256] = { - -3, -3, -3, -3, -3, -3, -3, -3, -3, -1, -1, -3, -3, -1, -3, -3, /* 0x00...0x0f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0x10...0x1f */ - -1, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, 62, -3, -3, -3, 63, /* 0x20...0x2f */ - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -3, -3, -3, -2, -3, -3, /* 0x30...0x3f */ - -3, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40...0x4f */ - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -3, -3, -3, -3, -3, /* 0x50...0x5f */ - -3, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60...0x6f */ - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -3, -3, -3, -3, -3, /* 0x70...0x7f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0x80...0x8f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0x90...0x9f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xa0...0xaf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xb0...0xbf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xc0...0xcf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xd0...0xdf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xe0...0xef */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3 /* 0xf0...0xff */ -}; -#endif /* DUK_USE_BASE64_FASTPATH */ - -#if defined(DUK_USE_BASE64_FASTPATH) -DUK_LOCAL DUK_ALWAYS_INLINE void duk__base64_encode_fast_3(const duk_uint8_t *src, duk_uint8_t *dst) { +DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) { duk_uint_t t; + duk_size_t n_full, n_full3, n_final; + const duk_uint8_t *src_end_fast; - t = (duk_uint_t) src[0]; - t = (t << 8) + (duk_uint_t) src[1]; - t = (t << 8) + (duk_uint_t) src[2]; - - dst[0] = duk__base64_enctab_fast[t >> 18]; - dst[1] = duk__base64_enctab_fast[(t >> 12) & 0x3fU]; - dst[2] = duk__base64_enctab_fast[(t >> 6) & 0x3fU]; - dst[3] = duk__base64_enctab_fast[t & 0x3fU]; - -#if 0 - /* Tested: not faster on x64, most likely due to aliasing between - * output and input index computation. - */ - /* aaaaaabb bbbbcccc ccdddddd */ - dst[0] = duk__base64_enctab_fast[(src[0] >> 2) & 0x3fU]; - dst[1] = duk__base64_enctab_fast[((src[0] << 4) & 0x30U) | ((src[1] >> 4) & 0x0fU)]; - dst[2] = duk__base64_enctab_fast[((src[1] << 2) & 0x3fU) | ((src[2] >> 6) & 0x03U)]; - dst[3] = duk__base64_enctab_fast[src[2] & 0x3fU]; + n_full = srclen / 3; /* full 3-byte -> 4-char conversions */ + n_full3 = n_full * 3; + n_final = srclen - n_full3; + DUK_ASSERT_DISABLE(n_final >= 0); + DUK_ASSERT(n_final <= 2); + + src_end_fast = src + n_full3; + while (DUK_UNLIKELY(src != src_end_fast)) { + t = (duk_uint_t) (*src++); + t = (t << 8) + (duk_uint_t) (*src++); + t = (t << 8) + (duk_uint_t) (*src++); + + *dst++ = duk_base64_enctab[t >> 18]; + *dst++ = duk_base64_enctab[(t >> 12) & 0x3f]; + *dst++ = duk_base64_enctab[(t >> 6) & 0x3f]; + *dst++ = duk_base64_enctab[t & 0x3f]; + +#if 0 /* Tested: not faster on x64 */ + /* aaaaaabb bbbbcccc ccdddddd */ + dst[0] = duk_base64_enctab[(src[0] >> 2) & 0x3f]; + dst[1] = duk_base64_enctab[((src[0] << 4) & 0x30) | ((src[1] >> 4) & 0x0f)]; + dst[2] = duk_base64_enctab[((src[1] << 2) & 0x3f) | ((src[2] >> 6) & 0x03)]; + dst[3] = duk_base64_enctab[src[2] & 0x3f]; + src += 3; dst += 4; #endif -} - -DUK_LOCAL DUK_ALWAYS_INLINE void duk__base64_encode_fast_2(const duk_uint8_t *src, duk_uint8_t *dst) { - duk_uint_t t; - - t = (duk_uint_t) src[0]; - t = (t << 8) + (duk_uint_t) src[1]; - dst[0] = duk__base64_enctab_fast[t >> 10]; /* XXXXXX-- -------- */ - dst[1] = duk__base64_enctab_fast[(t >> 4) & 0x3fU]; /* ------XX XXXX---- */ - dst[2] = duk__base64_enctab_fast[(t << 2) & 0x3fU]; /* -------- ----XXXX */ - dst[3] = DUK_ASC_EQUALS; -} - -DUK_LOCAL DUK_ALWAYS_INLINE void duk__base64_encode_fast_1(const duk_uint8_t *src, duk_uint8_t *dst) { - duk_uint_t t; - - t = (duk_uint_t) src[0]; - dst[0] = duk__base64_enctab_fast[t >> 2]; /* XXXXXX-- */ - dst[1] = duk__base64_enctab_fast[(t << 4) & 0x3fU]; /* ------XX */ - dst[2] = DUK_ASC_EQUALS; - dst[3] = DUK_ASC_EQUALS; -} - -DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) { - duk_size_t n; - const duk_uint8_t *p; - duk_uint8_t *q; - - n = srclen; - p = src; - q = dst; - - if (n >= 16U) { - /* Fast path, unrolled by 4, allows interleaving. Process - * 12-byte input chunks which encode to 16-char output chunks. - * Only enter when at least one block is emitted (avoids div+mul - * for short inputs too). - */ - const duk_uint8_t *p_end_fast; + } - p_end_fast = p + ((n / 12U) * 12U); - DUK_ASSERT(p_end_fast >= p + 12); - do { - duk__base64_encode_fast_3(p, q); - duk__base64_encode_fast_3(p + 3, q + 4); - duk__base64_encode_fast_3(p + 6, q + 8); - duk__base64_encode_fast_3(p + 9, q + 12); - p += 12; - q += 16; - } while (DUK_LIKELY(p != p_end_fast)); - - DUK_ASSERT(src + srclen >= p); - n = (duk_size_t) (src + srclen - p); - DUK_ASSERT(n < 12U); - } - - /* Remainder. */ - while (n >= 3U) { - duk__base64_encode_fast_3(p, q); - p += 3; - q += 4; - n -= 3U; - } - DUK_ASSERT(n == 0U || n == 1U || n == 2U); - if (n == 1U) { - duk__base64_encode_fast_1(p, q); -#if 0 /* Unnecessary. */ - p += 1; - q += 4; - n -= 1U; -#endif - } else if (n == 2U) { - duk__base64_encode_fast_2(p, q); -#if 0 /* Unnecessary. */ - p += 2; - q += 4; - n -= 2U; -#endif - } else { - DUK_ASSERT(n == 0U); /* nothing to do */ - ; + switch (n_final) { + /* case 0: nop */ + case 1: { + /* XX== */ + t = (duk_uint_t) (*src++); + *dst++ = duk_base64_enctab[t >> 2]; /* XXXXXX-- */ + *dst++ = duk_base64_enctab[(t << 4) & 0x3f]; /* ------XX */ + *dst++ = DUK_ASC_EQUALS; + *dst++ = DUK_ASC_EQUALS; + break; + } + case 2: { + /* XXX= */ + t = (duk_uint_t) (*src++); + t = (t << 8) + (duk_uint_t) (*src++); + *dst++ = duk_base64_enctab[t >> 10]; /* XXXXXX-- -------- */ + *dst++ = duk_base64_enctab[(t >> 4) & 0x3f]; /* ------XX XXXX---- */ + *dst++ = duk_base64_enctab[(t << 2) & 0x3f]; /* -------- ----XXXX */ + *dst++ = DUK_ASC_EQUALS; + break; + } } } #else /* DUK_USE_BASE64_FASTPATH */ DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) { - duk_small_uint_t i, npad; - duk_uint_t t, x, y; - const duk_uint8_t *p; - const duk_uint8_t *p_end; - duk_uint8_t *q; - - p = src; - p_end = src + srclen; - q = dst; - npad = 0U; + duk_small_uint_t i, snip; + duk_uint_t t; + duk_uint_fast8_t x, y; + const duk_uint8_t *src_end; - while (p < p_end) { - /* Read 3 bytes into 't', padded by zero. */ + src_end = src + srclen; + + while (src < src_end) { + /* read 3 bytes into 't', padded by zero */ + snip = 4; t = 0; for (i = 0; i < 3; i++) { t = t << 8; - if (p < p_end) { - t += (duk_uint_t) (*p++); + if (src >= src_end) { + snip--; } else { - /* This only happens on the last loop and we're - * guaranteed to exit on the next loop. - */ - npad++; + t += (duk_uint_t) (*src++); } } - DUK_ASSERT(npad <= 2U); - /* Emit 4 encoded characters. If npad > 0, some of the - * chars will be incorrect (zero bits) but we fix up the - * padding after the loop. A straightforward 64-byte - * lookup would be faster and cleaner, but this is shorter. + /* + * Missing bytes snip base64 example + * 0 4 XXXX + * 1 3 XXX= + * 2 2 XX== */ + + DUK_ASSERT(snip >= 2 && snip <= 4); + for (i = 0; i < 4; i++) { - x = ((t >> 18) & 0x3fU); + x = (duk_uint_fast8_t) ((t >> 18) & 0x3f); t = t << 6; - if (x <= 51U) { - if (x <= 25) { - y = x + DUK_ASC_UC_A; - } else { - y = x - 26 + DUK_ASC_LC_A; - } + /* A straightforward 64-byte lookup would be faster + * and cleaner, but this is shorter. + */ + if (i >= snip) { + y = '='; + } else if (x <= 25) { + y = x + 'A'; + } else if (x <= 51) { + y = x - 26 + 'a'; + } else if (x <= 61) { + y = x - 52 + '0'; + } else if (x == 62) { + y = '+'; } else { - if (x <= 61U) { - y = x - 52 + DUK_ASC_0; - } else if (x == 62) { - y = DUK_ASC_PLUS; - } else { - DUK_ASSERT(x == 63); - y = DUK_ASC_SLASH; - } + y = '/'; } - *q++ = (duk_uint8_t) y; + *dst++ = (duk_uint8_t) y; } } - - /* Handle padding by rewriting 0-2 bogus characters at the end. - * - * Missing bytes npad base64 example - * 0 0 #### - * 1 1 ###= - * 2 2 ##== - */ - DUK_ASSERT(npad <= 2U); - while (npad > 0U) { - *(q - npad) = DUK_ASC_EQUALS; - npad--; - } } #endif /* DUK_USE_BASE64_FASTPATH */ #if defined(DUK_USE_BASE64_FASTPATH) DUK_LOCAL duk_bool_t duk__base64_decode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst, duk_uint8_t **out_dst_final) { duk_int_t x; - duk_uint_t t; + duk_int_t t; duk_small_uint_t n_equal; - duk_int8_t step; - const duk_uint8_t *p; - const duk_uint8_t *p_end; - const duk_uint8_t *p_end_safe; - duk_uint8_t *q; - - p = src; - p_end = src + srclen; - p_end_safe = p_end - 8; /* If 'src <= src_end_safe', safe to read 8 bytes. */ - q = dst; - - /* Alternate between a fast path which processes clean groups with no - * padding or whitespace, and a slow path which processes one arbitrary - * group and then re-enters the fast path. This handles e.g. base64 - * with newlines reasonably well because the majority of a line is in - * the fast path. + duk_small_uint_t n_chars; + const duk_uint8_t *src_end; + const duk_uint8_t *src_end_safe; + + src_end = src + srclen; + src_end_safe = src_end - 4; /* if 'src < src_end_safe', safe to read 4 bytes */ + + /* Innermost fast path processes 4 valid base-64 characters at a time + * but bails out on whitespace, padding chars ('=') and invalid chars. + * Once the slow path segment has been processed, we return to the + * inner fast path again. This handles e.g. base64 with newlines + * reasonably well because the majority of a line is in the fast path. */ for (;;) { - /* Fast path, on each loop handle two 4-char input groups. - * If both are clean, emit 6 bytes and continue. If first - * is clean, emit 3 bytes and drop out; otherwise emit - * nothing and drop out. This approach could be extended to - * more groups per loop, but for inputs with e.g. periodic - * newlines (which are common) it might not be an improvement. - */ - while (DUK_LIKELY(p <= p_end_safe)) { - duk_int_t t1, t2; + /* Fast path, handle units with just actual encoding characters. */ - /* The lookup byte is intentionally sign extended to - * (at least) 32 bits and then ORed. This ensures - * that is at least 1 byte is negative, the highest - * bit of the accumulator will be set at the end and - * we don't need to check every byte. - * - * Read all input bytes first before writing output - * bytes to minimize aliasing. + while (src <= src_end_safe) { + /* The lookup byte is intentionally sign extended to (at least) + * 32 bits and then ORed. This ensures that is at least 1 byte + * is negative, the highest bit of 't' will be set at the end + * and we don't need to check every byte. */ - DUK_DDD(DUK_DDDPRINT("fast loop: p=%p, p_end_safe=%p, p_end=%p", - (const void *) p, (const void *) p_end_safe, (const void *) p_end)); + DUK_DDD(DUK_DDDPRINT("fast loop: src=%p, src_end_safe=%p, src_end=%p", + (const void *) src, (const void *) src_end_safe, (const void *) src_end)); - t1 = (duk_int_t) duk__base64_dectab_fast[p[0]]; - t1 = (duk_int_t) ((duk_uint_t) t1 << 6) | (duk_int_t) duk__base64_dectab_fast[p[1]]; - t1 = (duk_int_t) ((duk_uint_t) t1 << 6) | (duk_int_t) duk__base64_dectab_fast[p[2]]; - t1 = (duk_int_t) ((duk_uint_t) t1 << 6) | (duk_int_t) duk__base64_dectab_fast[p[3]]; - - t2 = (duk_int_t) duk__base64_dectab_fast[p[4]]; - t2 = (duk_int_t) ((duk_uint_t) t2 << 6) | (duk_int_t) duk__base64_dectab_fast[p[5]]; - t2 = (duk_int_t) ((duk_uint_t) t2 << 6) | (duk_int_t) duk__base64_dectab_fast[p[6]]; - t2 = (duk_int_t) ((duk_uint_t) t2 << 6) | (duk_int_t) duk__base64_dectab_fast[p[7]]; - - q[0] = (duk_uint8_t) (((duk_uint_t) t1 >> 16) & 0xffU); - q[1] = (duk_uint8_t) (((duk_uint_t) t1 >> 8) & 0xffU); - q[2] = (duk_uint8_t) ((duk_uint_t) t1 & 0xffU); - - q[3] = (duk_uint8_t) (((duk_uint_t) t2 >> 16) & 0xffU); - q[4] = (duk_uint8_t) (((duk_uint_t) t2 >> 8) & 0xffU); - q[5] = (duk_uint8_t) ((duk_uint_t) t2 & 0xffU); - - /* Optimistic check using one branch. */ - if (DUK_LIKELY((t1 | t2) >= 0)) { - p += 8; - q += 6; - } else if (t1 >= 0) { - DUK_DDD(DUK_DDDPRINT("fast loop first group was clean, second was not, process one slow path group")); - DUK_ASSERT(t2 < 0); - p += 4; - q += 3; - break; - } else { - DUK_DDD(DUK_DDDPRINT("fast loop first group was not clean, second does not matter, process one slow path group")); - DUK_ASSERT(t1 < 0); + t = (duk_int_t) duk_base64_dectab[*src++]; + t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++]; + t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++]; + t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++]; + + if (DUK_UNLIKELY(t < 0)) { + DUK_DDD(DUK_DDDPRINT("fast loop unit was not clean, process one slow path unit")); + src -= 4; break; } - } /* fast path */ - /* Slow path step 1: try to scan a 4-character encoded group, - * end-of-input, or start-of-padding. We exit with: - * 1. n_chars == 4: full group, no padding, no end-of-input. - * 2. n_chars < 4: partial group (may also be 0), encountered - * padding or end of input. - * - * The accumulator is initialized to 1; this allows us to detect - * a full group by comparing >= 0x1000000 without an extra - * counter variable. - */ - t = 1UL; + DUK_ASSERT(t <= 0xffffffL); + DUK_ASSERT((t >> 24) == 0); + *dst++ = (duk_uint8_t) (t >> 16); + *dst++ = (duk_uint8_t) ((t >> 8) & 0xff); + *dst++ = (duk_uint8_t) (t & 0xff); + } + + /* Handle one slow path unit (or finish if we're done). */ + + n_equal = 0; + n_chars = 0; + t = 0; for (;;) { - DUK_DDD(DUK_DDDPRINT("slow loop: p=%p, p_end=%p, t=%lu", - (const void *) p, (const void *) p_end, (unsigned long) t)); + DUK_DDD(DUK_DDDPRINT("slow loop: src=%p, src_end=%p, n_chars=%ld, n_equal=%ld, t=%ld", + (const void *) src, (const void *) src_end, (long) n_chars, (long) n_equal, (long) t)); - if (DUK_LIKELY(p < p_end)) { - x = duk__base64_dectab_fast[*p++]; - if (DUK_LIKELY(x >= 0)) { - DUK_ASSERT(x >= 0 && x <= 63); - t = (t << 6) + (duk_uint_t) x; - if (t >= 0x1000000UL) { - break; - } - } else if (x == -1) { + if (DUK_UNLIKELY(src >= src_end)) { + goto done; /* two level break */ + } + + x = duk_base64_dectab[*src++]; + if (DUK_UNLIKELY(x < 0)) { + if (x == -2) { continue; /* allowed ascii whitespace */ - } else if (x == -2) { - p--; - break; /* start of padding */ + } else if (x == -3) { + n_equal++; + t <<= 6; } else { - DUK_ASSERT(x == -3); + DUK_ASSERT(x == -1); goto decode_error; } } else { - break; /* end of input */ + DUK_ASSERT(x >= 0 && x <= 63); + if (n_equal > 0) { + /* Don't allow actual chars after equal sign. */ + goto decode_error; + } + t = (t << 6) + x; } - } /* slow path step 1 */ - - /* Complete the padding by simulating pad characters, - * regardless of actual input padding chars. - */ - n_equal = 0; - while (t < 0x1000000UL) { - t = (t << 6) + 0U; - n_equal++; - } - /* Slow path step 2: deal with full/partial group, padding, - * etc. Note that for num chars in [0,3] we intentionally emit - * 3 bytes but don't step forward that much, buffer space is - * guaranteed in setup. - * - * num chars: - * 0 #### no output (= step 0) - * 1 #=== reject, 6 bits of data - * 2 ##== 12 bits of data, output 1 byte (= step 1) - * 3 ###= 18 bits of data, output 2 bytes (= step 2) - * 4 #### 24 bits of data, output 3 bytes (= step 3) - */ - q[0] = (duk_uint8_t) ((t >> 16) & 0xffU); - q[1] = (duk_uint8_t) ((t >> 8) & 0xffU); - q[2] = (duk_uint8_t) (t & 0xffU); - - DUK_ASSERT(n_equal <= 4); - step = duk__base64_decode_nequal_step[n_equal]; - if (DUK_UNLIKELY(step < 0)) { - goto decode_error; - } - q += step; - - /* Slow path step 3: read and ignore padding and whitespace - * until (a) next non-padding and non-whitespace character - * after which we resume the fast path, or (b) end of input. - * This allows us to accept missing, partial, full, and extra - * padding cases uniformly. We also support concatenated - * base-64 documents because we resume scanning afterwards. - * - * Note that to support concatenated documents well, the '=' - * padding found inside the input must also allow for 'extra' - * padding. For example, 'Zm===' decodes to 'f' and has one - * extra padding char. So, 'Zm===Zm' should decode 'ff', even - * though the standard break-up would be 'Zm==' + '=Zm' which - * doesn't make sense. - * - * We also accept prepended padding like '==Zm9', because it - * is equivalent to an empty document with extra padding ('==') - * followed by a valid document. - */ + if (DUK_UNLIKELY(n_chars == 3)) { + /* Emit 3 bytes and backtrack if there was padding. There's + * always space for the whole 3 bytes so no check needed. + */ + DUK_ASSERT(t <= 0xffffffL); + DUK_ASSERT((t >> 24) == 0); + *dst++ = (duk_uint8_t) (t >> 16); + *dst++ = (duk_uint8_t) ((t >> 8) & 0xff); + *dst++ = (duk_uint8_t) (t & 0xff); + + if (DUK_UNLIKELY(n_equal > 0)) { + DUK_ASSERT(n_equal <= 4); + + /* There may be whitespace between the equal signs. */ + if (n_equal == 1) { + /* XXX= */ + dst -= 1; + } else if (n_equal == 2) { + /* XX== */ + dst -= 2; + } else { + goto decode_error; /* invalid padding */ + } - for (;;) { - if (DUK_UNLIKELY(p >= p_end)) { - goto done; - } - x = duk__base64_dectab_fast[*p++]; - if (x == -1 || x == -2) { - ; /* padding or whitespace, keep eating */ + /* Continue parsing after padding, allows concatenated, + * padded base64. + */ + } + break; /* back to fast loop */ } else { - p--; - break; /* backtrack and go back to fast path, even for -1 */ + n_chars++; } - } /* slow path step 3 */ - } /* outer fast+slow path loop */ - + } + } done: - DUK_DDD(DUK_DDDPRINT("done; p=%p, p_end=%p", - (const void *) p, (const void *) p_end)); + DUK_DDD(DUK_DDDPRINT("done; src=%p, src_end=%p, n_chars=%ld", + (const void *) src, (const void *) src_end, (long) n_chars)); + + DUK_ASSERT(src == src_end); - DUK_ASSERT(p == p_end); + if (n_chars != 0) { + /* Here we'd have the option of decoding unpadded base64 + * (e.g. "xxxxyy" instead of "xxxxyy==". Currently not + * accepted. + */ + goto decode_error; + } - *out_dst_final = q; + *out_dst_final = dst; return 1; decode_error: @@ -459,138 +280,94 @@ } #else /* DUK_USE_BASE64_FASTPATH */ DUK_LOCAL duk_bool_t duk__base64_decode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst, duk_uint8_t **out_dst_final) { - duk_uint_t t, x; - duk_int_t y; - duk_int8_t step; - const duk_uint8_t *p; - const duk_uint8_t *p_end; - duk_uint8_t *q; - /* 0x09, 0x0a, or 0x0d */ - duk_uint32_t mask_white = (1U << 9) | (1U << 10) | (1U << 13); - - /* 't' tracks progress of the decoded group: - * - * t == 1 no valid chars yet - * t >= 0x40 1x6 = 6 bits shifted in - * t >= 0x1000 2x6 = 12 bits shifted in - * t >= 0x40000 3x6 = 18 bits shifted in - * t >= 0x1000000 4x6 = 24 bits shifted in - * - * By initializing t=1 there's no need for a separate counter for - * the number of characters found so far. - */ - p = src; - p_end = src + srclen; - q = dst; - t = 1UL; - - for (;;) { - duk_small_uint_t n_equal; + duk_uint_t t; + duk_uint_fast8_t x, y; + duk_small_uint_t group_idx; + duk_small_uint_t n_equal; + const duk_uint8_t *src_end; - DUK_ASSERT(t >= 1U); - if (p >= p_end) { - /* End of input: if input exists, treat like - * start of padding, finish the block, then - * re-enter here to see we're done. + src_end = src + srclen; + t = 0; + group_idx = 0; + n_equal = 0; + + while (src < src_end) { + x = *src++; + + if (x >= 'A' && x <= 'Z') { + y = x - 'A' + 0; + } else if (x >= 'a' && x <= 'z') { + y = x - 'a' + 26; + } else if (x >= '0' && x <= '9') { + y = x - '0' + 52; + } else if (x == '+') { + y = 62; + } else if (x == '/') { + y = 63; + } else if (x == '=') { + /* We don't check the zero padding bytes here right now + * (that they're actually zero). This seems to be common + * behavior for base-64 decoders. */ - if (t == 1U) { - break; - } else { - goto simulate_padding; - } - } - - x = *p++; - if (x >= 0x41U) { - /* Valid: a-z and A-Z. */ - DUK_ASSERT(x >= 0x41U && x <= 0xffU); - if (x >= 0x61U && x <= 0x7aU) { - y = (duk_int_t) x - 0x61 + 26; - } else if (x <= 0x5aU) { - y = (duk_int_t) x - 0x41; - } else { - goto decode_error; - } - } else if (x >= 0x30U) { - /* Valid: 0-9 and =. */ - DUK_ASSERT(x >= 0x30U && x <= 0x40U); - if (x <= 0x39U) { - y = (duk_int_t) x - 0x30 + 52; - } else if (x == 0x3dU) { - /* Skip padding and whitespace unless we're in the - * middle of a block. Otherwise complete group by - * simulating shifting in the correct padding. - */ - if (t == 1U) { - continue; - } - goto simulate_padding; - } else { - goto decode_error; - } - } else if (x >= 0x20U) { - /* Valid: +, /, and 0x20 whitespace. */ - DUK_ASSERT(x >= 0x20U && x <= 0x2fU); - if (x == 0x2bU) { - y = 62; - } else if (x == 0x2fU) { - y = 63; - } else if (x == 0x20U) { - continue; - } else { - goto decode_error; - } + n_equal++; + t <<= 6; /* shift in zeroes */ + goto skip_add; + } else if (x == 0x09 || x == 0x0a || x == 0x0d || x == 0x20) { + /* allow basic ASCII whitespace */ + continue; } else { - /* Valid: whitespace. */ - duk_uint32_t m; - DUK_ASSERT(x < 0x20U); /* 0x00 to 0x1f */ - m = (1U << x); - if (mask_white & m) { - /* Allow basic ASCII whitespace. */ - continue; - } else { - goto decode_error; - } + goto decode_error; } - DUK_ASSERT(y >= 0 && y <= 63); - t = (t << 6) + (duk_uint_t) y; - if (t < 0x1000000UL) { - continue; + if (n_equal > 0) { + /* Don't allow mixed padding and actual chars. */ + goto decode_error; } - /* fall through; no padding will be added */ + t = (t << 6) + y; + skip_add: - simulate_padding: - n_equal = 0; - while (t < 0x1000000UL) { - t = (t << 6) + 0U; - n_equal++; - } + if (group_idx == 3) { + /* output 3 bytes from 't' */ + *dst++ = (duk_uint8_t) ((t >> 16) & 0xff); + *dst++ = (duk_uint8_t) ((t >> 8) & 0xff); + *dst++ = (duk_uint8_t) (t & 0xff); + + if (DUK_UNLIKELY(n_equal > 0)) { + /* Backtrack. */ + DUK_ASSERT(n_equal <= 4); + if (n_equal == 1) { + dst -= 1; + } else if (n_equal == 2) { + dst -= 2; + } else { + goto decode_error; /* invalid padding */ + } - /* Output 3 bytes from 't' and advance as needed. */ - q[0] = (duk_uint8_t) ((t >> 16) & 0xffU); - q[1] = (duk_uint8_t) ((t >> 8) & 0xffU); - q[2] = (duk_uint8_t) (t & 0xffU); - - DUK_ASSERT(n_equal <= 4U); - step = duk__base64_decode_nequal_step[n_equal]; - if (step < 0) { - goto decode_error; + /* Here we can choose either to end parsing and ignore + * whatever follows, or to continue parsing in case + * multiple (possibly padded) base64 strings have been + * concatenated. Currently, keep on parsing. + */ + n_equal = 0; + } + + t = 0; + group_idx = 0; + } else { + group_idx++; } - q += step; + } - /* Re-enter loop. The actual padding characters are skipped - * by the main loop. This handles cases like missing, partial, - * full, and extra padding, and allows parsing of concatenated - * documents (with extra padding) like: Zm===Zm. Also extra - * prepended padding is accepted: ===Zm9v. + if (group_idx != 0) { + /* Here we'd have the option of decoding unpadded base64 + * (e.g. "xxxxyy" instead of "xxxxyy==". Currently not + * accepted. */ - t = 1U; + goto decode_error; } - DUK_ASSERT(t == 1UL); - *out_dst_final = q; + *out_dst_final = dst; return 1; decode_error: @@ -607,12 +384,15 @@ DUK_ASSERT_API_ENTRY(thr); + /* XXX: optimize for string inputs: no need to coerce to a buffer + * which makes a copy of the input. + */ + idx = duk_require_normalize_index(thr, idx); src = duk__prep_codec_arg(thr, idx, &srclen); /* Note: for srclen=0, src may be NULL */ - /* Compute exact output length. Computation must not wrap; this - * limit works for 32-bit size_t: + /* Computation must not wrap; this limit works for 32-bit size_t: * >>> srclen = 3221225469 * >>> '%x' % ((srclen + 2) / 3 * 4) * 'fffffffc' @@ -620,7 +400,7 @@ if (srclen > 3221225469UL) { goto type_error; } - dstlen = (srclen + 2U) / 3U * 4U; + dstlen = (srclen + 2) / 3 * 4; dst = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, dstlen); duk__base64_encode_helper((const duk_uint8_t *) src, srclen, dst); @@ -631,7 +411,7 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_BASE64_ENCODE_FAILED); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } DUK_EXTERNAL void duk_base64_decode(duk_hthread *thr, duk_idx_t idx) { @@ -640,24 +420,31 @@ duk_size_t dstlen; duk_uint8_t *dst; duk_uint8_t *dst_final; + duk_bool_t retval; DUK_ASSERT_API_ENTRY(thr); + /* XXX: optimize for buffer inputs: no need to coerce to a string + * which causes an unnecessary interning. + */ + idx = duk_require_normalize_index(thr, idx); src = duk__prep_codec_arg(thr, idx, &srclen); - /* Round up and add safety margin. Avoid addition before division to - * avoid possibility of wrapping. Margin includes +3 for rounding up, - * and +3 for one extra group: the decoder may emit and then backtrack - * a full group (3 bytes) from zero-sized input for technical reasons. - * Similarly, 'xx' may ecause 1+3 = bytes to be emitted and then - * backtracked. + /* Computation must not wrap, only srclen + 3 is at risk of + * wrapping because after that the number gets smaller. + * This limit works for 32-bit size_t: + * 0x100000000 - 3 - 1 = 4294967292 */ - dstlen = (srclen / 4) * 3 + 6; /* upper limit, assuming no whitespace etc */ + if (srclen > 4294967292UL) { + goto type_error; + } + dstlen = (srclen + 3) / 4 * 3; /* upper limit, assuming no whitespace etc */ dst = (duk_uint8_t *) duk_push_dynamic_buffer(thr, dstlen); /* Note: for dstlen=0, dst may be NULL */ - if (!duk__base64_decode_helper((const duk_uint8_t *) src, srclen, dst, &dst_final)) { + retval = duk__base64_decode_helper((const duk_uint8_t *) src, srclen, dst, &dst_final); + if (!retval) { goto type_error; } @@ -668,27 +455,8 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_BASE64_DECODE_FAILED); - DUK_WO_NORETURN(return;); -} -#else /* DUK_USE_BASE64_SUPPORT */ -DUK_EXTERNAL const char *duk_base64_encode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); -} - -DUK_EXTERNAL void duk_base64_decode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } -#endif /* DUK_USE_BASE64_SUPPORT */ - -/* - * Hex - */ -#if defined(DUK_USE_HEX_SUPPORT) DUK_EXTERNAL const char *duk_hex_encode(duk_hthread *thr, duk_idx_t idx) { const duk_uint8_t *inp; duk_size_t len; @@ -799,12 +567,8 @@ } } for (; i < len; i += 2) { - /* First cast to duk_int_t to sign extend, second cast to - * duk_uint_t to avoid signed left shift, and final cast to - * duk_int_t result type. - */ - t = (duk_int_t) ((((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i]]) << 4U) | - ((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i + 1]])); + t = (((duk_int_t) duk_hex_dectab[inp[i]]) << 4) | + ((duk_int_t) duk_hex_dectab[inp[i + 1]]); if (DUK_UNLIKELY(t < 0)) { goto type_error; } @@ -816,8 +580,8 @@ * at least 16 bits. If either nybble is invalid, the * resulting 't' will be < 0. */ - t = (duk_int_t) ((((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i]]) << 4U) | - ((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i + 1]])); + t = (((duk_int_t) duk_hex_dectab[inp[i]]) << 4) | + ((duk_int_t) duk_hex_dectab[inp[i + 1]]); if (DUK_UNLIKELY(t < 0)) { goto type_error; } @@ -830,24 +594,7 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_HEX_DECODE_FAILED); - DUK_WO_NORETURN(return;); -} -#else /* DUK_USE_HEX_SUPPORT */ -DUK_EXTERNAL const char *duk_hex_encode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } -DUK_EXTERNAL void duk_hex_decode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); -} -#endif /* DUK_USE_HEX_SUPPORT */ - -/* - * JSON - */ #if defined(DUK_USE_JSON_SUPPORT) DUK_EXTERNAL const char *duk_json_encode(duk_hthread *thr, duk_idx_t idx) { @@ -900,13 +647,11 @@ DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return NULL;); } DUK_EXTERNAL void duk_json_decode(duk_hthread *thr, duk_idx_t idx) { DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_JSON_SUPPORT */ diff -Nru duktape-2.3.0/src-input/duk_api_compile.c duktape-2.2.0/src-input/duk_api_compile.c --- duktape-2.3.0/src-input/duk_api_compile.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_api_compile.c 2017-09-23 01:06:08.000000000 +0000 @@ -89,7 +89,6 @@ if ((flags & DUK_COMPILE_NOSOURCE) || /* args incorrect */ (h_sourcecode == NULL)) { /* e.g. duk_push_string_file_raw() pushed undefined */ DUK_ERROR_TYPE(thr, DUK_STR_NO_SOURCECODE); - DUK_WO_NORETURN(return 0;); } DUK_ASSERT(h_sourcecode != NULL); comp_args->src_buffer = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_sourcecode); diff -Nru duktape-2.3.0/src-input/duk_api_debug.c duktape-2.2.0/src-input/duk_api_debug.c --- duktape-2.3.0/src-input/duk_api_debug.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_api_debug.c 2017-09-23 01:06:08.000000000 +0000 @@ -42,7 +42,6 @@ DUK_EXTERNAL void duk_push_context_dump(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_JSON_SUPPORT */ @@ -154,7 +153,7 @@ top = duk_get_top(thr); if (top < nvalues) { DUK_ERROR_RANGE(thr, "not enough stack values for notify"); - DUK_WO_NORETURN(return 0;); + return ret; /* unreachable */ } if (duk_debug_is_attached(thr->heap)) { duk_debug_write_notify(thr, DUK_DBG_CMD_APPNOTIFY); @@ -221,13 +220,11 @@ DUK_UNREF(detached_cb); DUK_UNREF(udata); DUK_ERROR_TYPE(thr, "no debugger support"); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_debugger_detach(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_TYPE(thr, "no debugger support"); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_debugger_cooperate(duk_hthread *thr) { @@ -244,7 +241,7 @@ top = duk_get_top(thr); if (top < nvalues) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } /* No debugger support, just pop values. */ diff -Nru duktape-2.3.0/src-input/duk_api_heap.c duktape-2.2.0/src-input/duk_api_heap.c --- duktape-2.3.0/src-input/duk_api_heap.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_api_heap.c 2017-09-23 01:06:08.000000000 +0000 @@ -105,7 +105,7 @@ duk_push_tval(thr, &lj->value2); /* XXX: creating_error == 0 is asserted above, so no need to store. */ - duk_memcpy((void *) &snapshot->lj, (const void *) lj, sizeof(duk_ljstate)); + DUK_MEMCPY((void *) &snapshot->lj, (const void *) lj, sizeof(duk_ljstate)); snapshot->creating_error = heap->creating_error; snapshot->curr_thread = heap->curr_thread; snapshot->call_recursion_depth = heap->call_recursion_depth; @@ -135,7 +135,7 @@ heap = thr->heap; - duk_memcpy((void *) &heap->lj, (const void *) &snapshot->lj, sizeof(duk_ljstate)); + DUK_MEMCPY((void *) &heap->lj, (const void *) &snapshot->lj, sizeof(duk_ljstate)); heap->creating_error = snapshot->creating_error; heap->curr_thread = snapshot->curr_thread; heap->call_recursion_depth = snapshot->call_recursion_depth; diff -Nru duktape-2.3.0/src-input/duk_api_inspect.c duktape-2.2.0/src-input/duk_api_inspect.c --- duktape-2.3.0/src-input/duk_api_inspect.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_api_inspect.c 2017-09-23 01:06:08.000000000 +0000 @@ -66,7 +66,7 @@ DUK_ASSERT_API_ENTRY(thr); /* Assume two's complement and set everything to -1. */ - duk_memset((void *) &vals, (int) 0xff, sizeof(vals)); + DUK_MEMSET((void *) &vals, (int) 0xff, sizeof(vals)); DUK_ASSERT(vals[DUK__IDX_TYPE] == -1); /* spot check one */ tv = duk_get_tval_or_unused(thr, idx); @@ -82,12 +82,12 @@ goto finish; } duk_push_pointer(thr, (void *) h); - duk_put_prop_literal(thr, -2, "hptr"); + duk_put_prop_string(thr, -2, "hptr"); #if 0 /* Covers a lot of information, e.g. buffer and string variants. */ duk_push_uint(thr, (duk_uint_t) DUK_HEAPHDR_GET_FLAGS(h)); - duk_put_prop_literal(thr, -2, "hflags"); + duk_put_prop_string(thr, -2, "hflags"); #endif #if defined(DUK_USE_REFERENCE_COUNTING) @@ -132,7 +132,7 @@ } vals[DUK__IDX_CLASS] = (duk_int_t) DUK_HOBJECT_GET_CLASS_NUMBER(h_obj); - vals[DUK__IDX_PBYTES] = (duk_int_t) DUK_HOBJECT_P_ALLOC_SIZE(h_obj); + vals[DUK__IDX_PBYTES] = (duk_int_t) DUK_HOBJECT_P_ALLOC_SIZE(h_obj), vals[DUK__IDX_ESIZE] = (duk_int_t) DUK_HOBJECT_GET_ESIZE(h_obj); vals[DUK__IDX_ENEXT] = (duk_int_t) DUK_HOBJECT_GET_ENEXT(h_obj); vals[DUK__IDX_ASIZE] = (duk_int_t) DUK_HOBJECT_GET_ASIZE(h_obj); diff -Nru duktape-2.3.0/src-input/duk_api_internal.h duktape-2.2.0/src-input/duk_api_internal.h --- duktape-2.3.0/src-input/duk_api_internal.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_api_internal.h 2017-09-23 01:06:08.000000000 +0000 @@ -142,12 +142,10 @@ DUK_INTERNAL_DECL duk_double_t duk_to_number_m1(duk_hthread *thr); DUK_INTERNAL_DECL duk_double_t duk_to_number_m2(duk_hthread *thr); -DUK_INTERNAL_DECL duk_bool_t duk_to_boolean_top_pop(duk_hthread *thr); - #if defined(DUK_USE_DEBUGGER_SUPPORT) /* only needed by debugger for now */ DUK_INTERNAL_DECL duk_hstring *duk_safe_to_hstring(duk_hthread *thr, duk_idx_t idx); #endif -DUK_INTERNAL_DECL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv, duk_bool_t avoid_side_effects); +DUK_INTERNAL_DECL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv); DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped_raw(duk_hthread *thr, duk_idx_t idx, duk_int_t minval, duk_int_t maxval, duk_bool_t *out_clamped); /* out_clamped=NULL, RangeError if outside range */ DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped(duk_hthread *thr, duk_idx_t idx, duk_int_t minval, duk_int_t maxval); @@ -285,8 +283,6 @@ DUK_INTERNAL_DECL void duk_xdef_prop_stridx_thrower(duk_hthread *thr, duk_idx_t obj_idx, duk_small_uint_t stridx); /* [] -> [] */ -DUK_INTERNAL_DECL duk_bool_t duk_get_method_stridx(duk_hthread *thr, duk_idx_t idx, duk_small_uint_t stridx); - DUK_INTERNAL_DECL void duk_pack(duk_hthread *thr, duk_idx_t count); DUK_INTERNAL_DECL duk_idx_t duk_unpack_array_like(duk_hthread *thr, duk_idx_t idx); #if 0 @@ -323,10 +319,6 @@ DUK_INTERNAL_DECL duk_int_t duk_pcall_method_flags(duk_hthread *thr, duk_idx_t nargs, duk_small_uint_t call_flags); -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL_DECL void duk_to_primitive_ordinary(duk_hthread *thr, duk_idx_t idx, duk_int_t hint); -#endif - /* Raw internal valstack access macros: access is unsafe so call site * must have a guarantee that the index is valid. When that is the case, * using these macro results in faster and smaller code than duk_get_tval(). diff -Nru duktape-2.3.0/src-input/duk_api_object.c duktape-2.2.0/src-input/duk_api_object.c --- duktape-2.3.0/src-input/duk_api_object.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_api_object.c 2017-09-23 01:06:08.000000000 +0000 @@ -8,7 +8,7 @@ * Property handling * * The API exposes only the most common property handling functions. - * The caller can invoke ECMAScript built-ins for full control (e.g. + * The caller can invoke Ecmascript built-ins for full control (e.g. * defineProperty, getOwnPropertyDescriptor). */ @@ -40,7 +40,7 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_string(thr, key); + duk_push_string(thr, key); return duk_get_prop(thr, obj_idx); } @@ -49,22 +49,10 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_lstring(thr, key, key_len); + duk_push_lstring(thr, key, key_len); return duk_get_prop(thr, obj_idx); } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_get_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); - return duk_get_prop(thr, obj_idx); -} -#endif - DUK_EXTERNAL duk_bool_t duk_get_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -77,7 +65,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk_get_prop(thr, obj_idx); } @@ -86,7 +74,7 @@ DUK_ASSERT_STRIDX_VALID(stridx); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_hstring(thr, DUK_HTHREAD_GET_STRING(thr, stridx)); + duk_push_hstring(thr, DUK_HTHREAD_GET_STRING(thr, stridx)); return duk_get_prop(thr, obj_idx); } @@ -105,7 +93,10 @@ if (out_has_prop) { *out_has_prop = rc; } - return duk_to_boolean_top_pop(thr); + rc = duk_to_boolean(thr, -1); + DUK_ASSERT(rc == 0 || rc == 1); + duk_pop(thr); + return rc; } DUK_LOCAL duk_bool_t duk__put_prop_shared(duk_hthread *thr, duk_idx_t obj_idx, duk_idx_t idx_key) { @@ -165,18 +156,6 @@ return duk__put_prop_shared(thr, obj_idx, -1); } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_put_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); - return duk__put_prop_shared(thr, obj_idx, -1); -} -#endif - DUK_EXTERNAL duk_bool_t duk_put_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -189,7 +168,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk__put_prop_shared(thr, obj_idx, -1); } @@ -236,7 +215,7 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_string(thr, key); + duk_push_string(thr, key); return duk_del_prop(thr, obj_idx); } @@ -245,21 +224,9 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_lstring(thr, key, key_len); - return duk_del_prop(thr, obj_idx); -} - -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_del_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); + duk_push_lstring(thr, key, key_len); return duk_del_prop(thr, obj_idx); } -#endif DUK_EXTERNAL duk_bool_t duk_del_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -273,7 +240,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk_del_prop(thr, obj_idx); } @@ -319,7 +286,7 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_string(thr, key); + duk_push_string(thr, key); return duk_has_prop(thr, obj_idx); } @@ -328,21 +295,9 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_lstring(thr, key, key_len); - return duk_has_prop(thr, obj_idx); -} - -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_has_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); + duk_push_lstring(thr, key, key_len); return duk_has_prop(thr, obj_idx); } -#endif DUK_EXTERNAL duk_bool_t duk_has_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -356,7 +311,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk_has_prop(thr, obj_idx); } @@ -556,17 +511,17 @@ fail_invalid_desc: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_DESCRIPTOR); - DUK_WO_NORETURN(return;); + return; fail_not_callable: DUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE); - DUK_WO_NORETURN(return;); + return; } /* * Object related * - * Note: seal() and freeze() are accessible through ECMAScript bindings, + * Note: seal() and freeze() are accessible through Ecmascript bindings, * and are not exposed through the API. */ @@ -658,7 +613,6 @@ fail_cannot_freeze: DUK_ERROR_TYPE_INVALID_ARGS(thr); /* XXX: proper error message */ - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_seal(duk_hthread *thr, duk_idx_t obj_idx) { @@ -742,38 +696,6 @@ return ret; } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_get_global_literal_raw(duk_hthread *thr, const char *key, duk_size_t key_len) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - ret = duk_get_prop_literal_raw(thr, -1, key, key_len); - duk_remove_m2(thr); - return ret; -} -#endif - -DUK_EXTERNAL duk_bool_t duk_get_global_heapptr(duk_hthread *thr, void *ptr) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - ret = duk_get_prop_heapptr(thr, -1, ptr); - duk_remove_m2(thr); - return ret; -} - - DUK_EXTERNAL duk_bool_t duk_put_global_string(duk_hthread *thr, const char *key) { duk_bool_t ret; @@ -804,56 +726,6 @@ return ret; } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_put_global_literal_raw(duk_hthread *thr, const char *key, duk_size_t key_len) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - duk_insert(thr, -2); - ret = duk_put_prop_literal_raw(thr, -2, key, key_len); /* [ ... global val ] -> [ ... global ] */ - duk_pop(thr); - return ret; -} -#endif - -DUK_EXTERNAL duk_bool_t duk_put_global_heapptr(duk_hthread *thr, void *ptr) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - duk_insert(thr, -2); - ret = duk_put_prop_heapptr(thr, -2, ptr); /* [ ... global val ] -> [ ... global ] */ - duk_pop(thr); - return ret; -} - -/* - * ES2015 GetMethod() - */ - -DUK_INTERNAL duk_bool_t duk_get_method_stridx(duk_hthread *thr, duk_idx_t idx, duk_small_uint_t stridx) { - (void) duk_get_prop_stridx(thr, idx, stridx); - if (duk_is_null_or_undefined(thr, -1)) { - duk_pop_nodecref_unsafe(thr); - return 0; - } - if (!duk_is_callable(thr, -1)) { - DUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE); - DUK_WO_NORETURN(return 0;); - } - return 1; -} - /* * Object prototype */ @@ -892,7 +764,7 @@ #if defined(DUK_USE_ROM_OBJECTS) if (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); /* XXX: "read only object"? */ - DUK_WO_NORETURN(return;); + return; } #endif @@ -949,13 +821,11 @@ DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_set_finalizer(duk_hthread *thr, duk_idx_t idx) { DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_FINALIZER_SUPPORT */ diff -Nru duktape-2.3.0/src-input/duk_api_random.c duktape-2.2.0/src-input/duk_api_random.c --- duktape-2.3.0/src-input/duk_api_random.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_api_random.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -/* - * Random numbers - */ - -#include "duk_internal.h" - -DUK_EXTERNAL duk_double_t duk_random(duk_hthread *thr) { - return (duk_double_t) DUK_UTIL_GET_RANDOM_DOUBLE(thr); -} diff -Nru duktape-2.3.0/src-input/duk_api_stack.c duktape-2.2.0/src-input/duk_api_stack.c --- duktape-2.3.0/src-input/duk_api_stack.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_api_stack.c 2017-09-23 01:06:08.000000000 +0000 @@ -172,7 +172,7 @@ if (require) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "number", DUK_STR_NOT_NUMBER); - DUK_WO_NORETURN(return 0;); + /* not reachable */ } return def_value; @@ -223,7 +223,7 @@ if (require) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "number", DUK_STR_NOT_NUMBER); - DUK_WO_NORETURN(return 0;); + /* not reachable */ } return def_value; @@ -298,7 +298,7 @@ return (duk_idx_t) uidx; } DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } DUK_INTERNAL duk_tval *duk_get_tval(duk_hthread *thr, duk_idx_t idx) { @@ -374,7 +374,7 @@ return thr->valstack_bottom + uidx; } DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return NULL;); + return NULL; } /* Non-critical. */ @@ -392,7 +392,7 @@ if (DUK_UNLIKELY(duk_normalize_index(thr, idx) < 0)) { DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return;); + return; /* unreachable */ } } @@ -417,7 +417,6 @@ ret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom); if (DUK_UNLIKELY(ret < min_top)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); } return ret; } @@ -462,7 +461,7 @@ #else if (DUK_UNLIKELY(uidx > vs_limit)) { DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return;); + return; /* unreachable */ } #endif DUK_ASSERT(uidx <= vs_limit); @@ -645,7 +644,7 @@ ret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom) - 1; if (DUK_UNLIKELY(ret < 0)) { DUK_ERROR_RANGE_INDEX(thr, -1); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } return ret; } @@ -846,7 +845,6 @@ */ if (throw_on_error) { DUK_ERROR_RANGE(thr, DUK_STR_VALSTACK_LIMIT); - DUK_WO_NORETURN(return 0;); } return 0; } @@ -854,7 +852,6 @@ if (duk__resize_valstack(thr, new_size) == 0) { if (throw_on_error) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return 0;); } return 0; } @@ -1115,7 +1112,7 @@ if (DUK_UNLIKELY(thr->valstack_top - thr->valstack_bottom <= 0)) { DUK_ERROR_RANGE_INDEX(thr, -1); - DUK_WO_NORETURN(return;); + return; /* unreachable */ } tv_from = thr->valstack_top - 1; tv_to = thr->valstack_top++; @@ -1177,12 +1174,18 @@ DUK_DDD(DUK_DDDPRINT("duk_insert: to_idx=%ld, p=%p, q=%p, nbytes=%lu", (long) to_idx, (void *) p, (void *) q, (unsigned long) nbytes)); - /* No net refcount changes. No need to special case nbytes == 0 - * (p == q). - */ - DUK_TVAL_SET_TVAL(&tv_tmp, q); - duk_memmove((void *) (p + 1), (const void *) p, (size_t) nbytes); - DUK_TVAL_SET_TVAL(p, &tv_tmp); + /* No net refcount changes. */ + + if (nbytes > 0) { + DUK_TVAL_SET_TVAL(&tv_tmp, q); + DUK_ASSERT(nbytes > 0); + DUK_MEMMOVE((void *) (p + 1), (const void *) p, (size_t) nbytes); + DUK_TVAL_SET_TVAL(p, &tv_tmp); + } else { + /* nop: insert top to top */ + DUK_ASSERT(nbytes == 0); + DUK_ASSERT(p == q); + } } DUK_INTERNAL void duk_insert_undefined(duk_hthread *thr, duk_idx_t idx) { @@ -1274,7 +1277,7 @@ #endif nbytes = (duk_size_t) (((duk_uint8_t *) q) - ((duk_uint8_t *) p)); /* Note: 'q' is top-1 */ - duk_memmove((void *) p, (const void *) (p + 1), (size_t) nbytes); + DUK_MEMMOVE((void *) p, (const void *) (p + 1), (size_t) nbytes); /* zero size not an issue: pointers are valid */ DUK_TVAL_SET_UNDEFINED(q); thr->valstack_top--; @@ -1327,7 +1330,7 @@ DUK_TVAL_DECREF_NORZ(thr, tv); } - duk_memmove((void *) tv_dst, (const void *) tv_src, bytes); + DUK_MEMMOVE((void *) tv_dst, (const void *) tv_src, bytes); tv_newtop = thr->valstack_top - count; for (tv = tv_newtop; tv < thr->valstack_top; tv++) { @@ -1366,14 +1369,14 @@ if (DUK_UNLIKELY(to_thr == from_thr)) { DUK_ERROR_TYPE(to_thr, DUK_STR_INVALID_CONTEXT); - DUK_WO_NORETURN(return;); + return; } if (DUK_UNLIKELY((duk_uidx_t) count > (duk_uidx_t) DUK_USE_VALSTACK_LIMIT)) { /* Maximum value check ensures 'nbytes' won't wrap below. * Also handles negative count. */ DUK_ERROR_RANGE_INVALID_COUNT(to_thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count >= 0); @@ -1384,19 +1387,17 @@ DUK_ASSERT(to_thr->valstack_top <= to_thr->valstack_end); if (DUK_UNLIKELY((duk_size_t) ((duk_uint8_t *) to_thr->valstack_end - (duk_uint8_t *) to_thr->valstack_top) < nbytes)) { DUK_ERROR_RANGE_PUSH_BEYOND(to_thr); - DUK_WO_NORETURN(return;); } src = (void *) ((duk_uint8_t *) from_thr->valstack_top - nbytes); if (DUK_UNLIKELY(src < (void *) from_thr->valstack_bottom)) { DUK_ERROR_RANGE_INVALID_COUNT(to_thr); - DUK_WO_NORETURN(return;); } - /* Copy values (no overlap even if to_thr == from_thr; that's not - * allowed now anyway). + /* copy values (no overlap even if to_thr == from_thr; that's not + * allowed now anyway) */ DUK_ASSERT(nbytes > 0); - duk_memcpy((void *) to_thr->valstack_top, (const void *) src, (size_t) nbytes); + DUK_MEMCPY((void *) to_thr->valstack_top, (const void *) src, (size_t) nbytes); p = to_thr->valstack_top; to_thr->valstack_top = (duk_tval *) (void *) (((duk_uint8_t *) p) + nbytes); @@ -1445,7 +1446,7 @@ tv_dst = (duk_tval *) (void *) ((duk_uint8_t *) tv_src + gap_bytes); copy_bytes = (duk_size_t) ((duk_uint8_t *) thr->valstack_top - (duk_uint8_t *) tv_src); thr->valstack_top = (duk_tval *) (void *) ((duk_uint8_t *) thr->valstack_top + gap_bytes); - duk_memmove((void *) tv_dst, (const void *) tv_src, copy_bytes); + DUK_MEMMOVE((void *) tv_dst, (const void *) tv_src, copy_bytes); /* Values in the gap are left as garbage: caller must fill them in * and INCREF them before any side effects. @@ -1466,7 +1467,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_UNDEFINED(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "undefined", DUK_STR_NOT_UNDEFINED); - DUK_WO_NORETURN(return;); } } @@ -1479,7 +1479,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_NULL(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "null", DUK_STR_NOT_NULL); - DUK_WO_NORETURN(return;); } } @@ -1528,7 +1527,6 @@ return ret; } else { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "boolean", DUK_STR_NOT_BOOLEAN); - DUK_WO_NORETURN(return 0;); } } @@ -1590,7 +1588,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_NUMBER(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "number", DUK_STR_NOT_NUMBER); - DUK_WO_NORETURN(return 0.0;); } ret.d = DUK_TVAL_GET_NUMBER(tv); @@ -1822,7 +1819,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_OBJECT(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "object", DUK_STR_NOT_OBJECT); - DUK_WO_NORETURN(return;); } } @@ -1874,7 +1870,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_POINTER(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "pointer", DUK_STR_NOT_POINTER); - DUK_WO_NORETURN(return NULL;); } p = DUK_TVAL_GET_POINTER(tv); /* may be NULL */ return p; @@ -1922,7 +1917,6 @@ } else { if (throw_flag) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "buffer", DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } len = def_size; ret = def_ptr; @@ -2026,7 +2020,6 @@ if (throw_flag) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "buffer", DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } return def_ptr; } @@ -2106,7 +2099,6 @@ h = (duk_hstring *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_STRING); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "string", DUK_STR_NOT_STRING); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -2119,7 +2111,6 @@ h = (duk_hstring *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_STRING); if (DUK_UNLIKELY(h == NULL || DUK_HSTRING_HAS_SYMBOL(h))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "string", DUK_STR_NOT_STRING); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -2137,7 +2128,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "object", DUK_STR_NOT_OBJECT); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -2155,7 +2145,6 @@ h = (duk_hbuffer *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_BUFFER); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "buffer", DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -2180,7 +2169,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_THREAD(h)))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "thread", DUK_STR_NOT_THREAD); - DUK_WO_NORETURN(return NULL;); } return (duk_hthread *) h; } @@ -2205,7 +2193,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_COMPFUNC(h)))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "compiledfunction", DUK_STR_NOT_COMPFUNC); - DUK_WO_NORETURN(return NULL;); } return (duk_hcompfunc *) h; } @@ -2230,7 +2217,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_NATFUNC(h)))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "nativefunction", DUK_STR_NOT_NATFUNC); - DUK_WO_NORETURN(return NULL;); } return (duk_hnatfunc *) h; } @@ -2289,7 +2275,6 @@ ret = duk_get_c_function(thr, idx); if (DUK_UNLIKELY(!ret)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "nativefunction", DUK_STR_NOT_NATFUNC); - DUK_WO_NORETURN(return ret;); } return ret; } @@ -2298,7 +2283,6 @@ DUK_ASSERT_API_ENTRY(thr); if (DUK_UNLIKELY(!duk_is_function(thr, idx))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "function", DUK_STR_NOT_FUNCTION); - DUK_WO_NORETURN(return;); } } @@ -2310,7 +2294,6 @@ h = duk_require_hobject_accept_mask(thr, idx, DUK_TYPE_MASK_LIGHTFUNC); if (DUK_UNLIKELY(h != NULL && !DUK_HOBJECT_HAS_CONSTRUCTABLE(h))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "constructable", DUK_STR_NOT_CONSTRUCTABLE); - DUK_WO_NORETURN(return;); } /* Lightfuncs (h == NULL) are constructable. */ } @@ -2398,7 +2381,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_HEAP_ALLOCATED(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "heapobject", DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return NULL;); } ret = (void *) DUK_TVAL_GET_HEAPHDR(tv); @@ -2432,7 +2414,6 @@ if (type_mask & DUK_TYPE_MASK_THROW) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "object", DUK_STR_NOT_OBJECT); - DUK_WO_NORETURN(return NULL;); } return NULL; } @@ -2493,7 +2474,6 @@ DUK_UNREF(h_class); DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, (const char *) DUK_HSTRING_GET_DATA(h_class), DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -2686,43 +2666,49 @@ } /* E5 Section 9.1 */ -DUK_LOCAL const char * const duk__toprim_hint_strings[3] = { - "default", "string", "number" -}; -DUK_LOCAL void duk__to_primitive_helper(duk_hthread *thr, duk_idx_t idx, duk_int_t hint, duk_bool_t check_symbol) { - /* Inline initializer for coercers[] is not allowed by old compilers like BCC. */ +DUK_EXTERNAL void duk_to_primitive(duk_hthread *thr, duk_idx_t idx, duk_int_t hint) { + /* inline initializer for coercers[] is not allowed by old compilers like BCC */ duk_small_uint_t coercers[2]; + duk_small_uint_t class_number; DUK_ASSERT_API_ENTRY(thr); DUK_ASSERT(hint == DUK_HINT_NONE || hint == DUK_HINT_NUMBER || hint == DUK_HINT_STRING); idx = duk_require_normalize_index(thr, idx); - /* If already primitive, return as is. */ if (!duk_check_type_mask(thr, idx, DUK_TYPE_MASK_OBJECT | DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER)) { + /* Any other values stay as is. */ DUK_ASSERT(!duk_is_buffer(thr, idx)); /* duk_to_string() relies on this behavior */ return; } - /* @@toPrimitive lookup. Also do for plain buffers and lightfuncs - * which mimic objects. + class_number = duk_get_class_number(thr, idx); + + /* XXX: Symbol objects normally coerce via the ES2015-revised ToPrimitive() + * algorithm which consults value[@@toPrimitive] and avoids calling + * .valueOf() and .toString(). Before that is implemented, special + * case Symbol objects to behave as if they had the default @@toPrimitive + * algorithm of E6 Section 19.4.3.4, i.e. return the plain symbol value + * with no further side effects. */ - if (check_symbol && duk_get_method_stridx(thr, idx, DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE)) { - DUK_ASSERT(hint >= 0 && (duk_size_t) hint < sizeof(duk__toprim_hint_strings) / sizeof(const char *)); - duk_dup(thr, idx); - duk_push_string(thr, duk__toprim_hint_strings[hint]); - duk_call_method(thr, 1); /* [ ... method value hint ] -> [ ... res] */ - if (duk_check_type_mask(thr, -1, DUK_TYPE_MASK_OBJECT | - DUK_TYPE_MASK_LIGHTFUNC | - DUK_TYPE_MASK_BUFFER)) { - goto fail; + + if (class_number == DUK_HOBJECT_CLASS_SYMBOL) { + duk_hobject *h_obj; + duk_hstring *h_str; + + /* XXX: pretty awkward, index based API for internal value access? */ + h_obj = duk_known_hobject(thr, idx); + h_str = duk_hobject_get_internal_value_string(thr->heap, h_obj); + if (h_str) { + duk_push_hstring(thr, h_str); + duk_replace(thr, idx); + return; } - duk_replace(thr, idx); - return; } + /* Objects are coerced based on E5 specification. * Lightfuncs are coerced because they behave like * objects even if they're internally a primitive @@ -2730,29 +2716,17 @@ * like ArrayBuffer objects since Duktape 2.x. */ - /* Hint magic for Date is unnecessary in ES2015 because of - * Date.prototype[@@toPrimitive]. However, it is needed if - * symbol support is not enabled. - */ -#if defined(DUK_USE_SYMBOL_BUILTIN) - if (hint == DUK_HINT_NONE) { - hint = DUK_HINT_NUMBER; - } -#else /* DUK_USE_SYMBOL_BUILTIN */ - if (hint == DUK_HINT_NONE) { - duk_small_uint_t class_number; + coercers[0] = DUK_STRIDX_VALUE_OF; + coercers[1] = DUK_STRIDX_TO_STRING; - class_number = duk_get_class_number(thr, idx); + if (hint == DUK_HINT_NONE) { if (class_number == DUK_HOBJECT_CLASS_DATE) { hint = DUK_HINT_STRING; } else { hint = DUK_HINT_NUMBER; } } -#endif /* DUK_USE_SYMBOL_BUILTIN */ - coercers[0] = DUK_STRIDX_VALUE_OF; - coercers[1] = DUK_STRIDX_TO_STRING; if (hint == DUK_HINT_STRING) { coercers[0] = DUK_STRIDX_TO_STRING; coercers[1] = DUK_STRIDX_VALUE_OF; @@ -2768,21 +2742,9 @@ return; } - fail: DUK_ERROR_TYPE(thr, DUK_STR_TOPRIMITIVE_FAILED); - DUK_WO_NORETURN(return;); -} - -DUK_EXTERNAL void duk_to_primitive(duk_hthread *thr, duk_idx_t idx, duk_int_t hint) { - duk__to_primitive_helper(thr, idx, hint, 1 /*check_symbol*/); } -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL void duk_to_primitive_ordinary(duk_hthread *thr, duk_idx_t idx, duk_int_t hint) { - duk__to_primitive_helper(thr, idx, hint, 0 /*check_symbol*/); -} -#endif - /* E5 Section 9.2 */ DUK_EXTERNAL duk_bool_t duk_to_boolean(duk_hthread *thr, duk_idx_t idx) { duk_tval *tv; @@ -2803,22 +2765,6 @@ return val; } -DUK_INTERNAL duk_bool_t duk_to_boolean_top_pop(duk_hthread *thr) { - duk_tval *tv; - duk_bool_t val; - - DUK_ASSERT_API_ENTRY(thr); - - tv = duk_require_tval(thr, -1); - DUK_ASSERT(tv != NULL); - - val = duk_js_toboolean(tv); - DUK_ASSERT(val == 0 || val == 1); - - duk_pop_unsafe(thr); - return val; -} - DUK_EXTERNAL duk_double_t duk_to_number(duk_hthread *thr, duk_idx_t idx) { duk_tval *tv; duk_double_t d; @@ -3098,67 +3044,68 @@ #endif /* Push Object.prototype.toString() output for 'tv'. */ -#if 0 /* See XXX note why this variant doesn't work. */ -DUK_INTERNAL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv, duk_bool_t avoid_side_effects) { - duk_uint_t stridx_bidx = 0; /* (prototype_bidx << 16) + default_tag_stridx */ +DUK_INTERNAL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv) { + duk_small_uint_t stridx; + duk_hstring *h_strclass; DUK_ASSERT_API_ENTRY(thr); - /* Conceptually for any non-undefined/null value we should do a - * ToObject() coercion and look up @@toStringTag (from the object - * prototype) to see if a custom tag should be used. Avoid the - * actual conversion by doing a prototype lookup without the object - * coercion. However, see problem below. - */ - - duk_push_literal(thr, "[object "); /* -> [ ... "[object" ] */ - switch (DUK_TVAL_GET_TAG(tv)) { case DUK_TAG_UNUSED: /* Treat like 'undefined', shouldn't happen. */ case DUK_TAG_UNDEFINED: { - stridx_bidx = DUK_STRIDX_UC_UNDEFINED; - goto use_stridx; + stridx = DUK_STRIDX_UC_UNDEFINED; + break; } case DUK_TAG_NULL: { - stridx_bidx = DUK_STRIDX_UC_NULL; - goto use_stridx; + stridx = DUK_STRIDX_UC_NULL; + break; } case DUK_TAG_BOOLEAN: { - stridx_bidx = (DUK_BIDX_BOOLEAN_PROTOTYPE << 16) + DUK_STRIDX_UC_BOOLEAN; - goto use_proto_bidx; + stridx = DUK_STRIDX_UC_BOOLEAN; + break; } case DUK_TAG_POINTER: { - stridx_bidx = (DUK_BIDX_POINTER_PROTOTYPE << 16) + DUK_STRIDX_UC_POINTER; - goto use_proto_bidx; + stridx = DUK_STRIDX_UC_POINTER; + break; } case DUK_TAG_LIGHTFUNC: { - stridx_bidx = (DUK_BIDX_FUNCTION_PROTOTYPE << 16) + DUK_STRIDX_UC_FUNCTION; - goto use_proto_bidx; + stridx = DUK_STRIDX_UC_FUNCTION; + break; } case DUK_TAG_STRING: { duk_hstring *h; h = DUK_TVAL_GET_STRING(tv); DUK_ASSERT(h != NULL); if (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) { - /* Even without DUK_USE_SYMBOL_BUILTIN the Symbol - * prototype exists so we can lookup @@toStringTag - * and provide [object Symbol] for symbol values - * created from C code. - */ - stridx_bidx = (DUK_BIDX_SYMBOL_PROTOTYPE << 16) + DUK_STRIDX_UC_SYMBOL; + stridx = DUK_STRIDX_UC_SYMBOL; } else { - stridx_bidx = (DUK_BIDX_STRING_PROTOTYPE << 16) + DUK_STRIDX_UC_STRING; + stridx = DUK_STRIDX_UC_STRING; } - goto use_proto_bidx; + break; } case DUK_TAG_OBJECT: { - duk_push_tval(thr, tv); - stridx_bidx = 0xffffffffUL; /* Marker value. */ - goto use_pushed_object; + duk_hobject *h; + duk_small_uint_t classnum; + + h = DUK_TVAL_GET_OBJECT(tv); + DUK_ASSERT(h != NULL); + classnum = DUK_HOBJECT_GET_CLASS_NUMBER(h); + stridx = DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(classnum); + + /* XXX: This is not entirely correct anymore; in ES2015 the + * default lookup should use @@toStringTag to come up with + * e.g. [object Symbol], [object Uint8Array], etc. See + * ES2015 Section 19.1.3.6. The downside of implementing that + * directly is that the @@toStringTag lookup may have side + * effects, so all call sites must be checked for that. + * Some may need a side-effect free lookup, e.g. avoiding + * getters which are not typical. + */ + break; } case DUK_TAG_BUFFER: { - stridx_bidx = (DUK_BIDX_UINT8ARRAY_PROTOTYPE << 16) + DUK_STRIDX_UINT8_ARRAY; - goto use_proto_bidx; + stridx = DUK_STRIDX_UINT8_ARRAY; + break; } #if defined(DUK_USE_FASTINT) case DUK_TAG_FASTINT: @@ -3166,142 +3113,14 @@ #endif default: { DUK_ASSERT(DUK_TVAL_IS_NUMBER(tv)); /* number (maybe fastint) */ - stridx_bidx = (DUK_BIDX_NUMBER_PROTOTYPE << 16) + DUK_STRIDX_UC_NUMBER; - goto use_proto_bidx; - } - } - DUK_ASSERT(0); /* Never here. */ - - use_proto_bidx: - DUK_ASSERT_BIDX_VALID((stridx_bidx >> 16) & 0xffffUL); - duk_push_hobject(thr, thr->builtins[(stridx_bidx >> 16) & 0xffffUL]); - /* Fall through. */ - - use_pushed_object: - /* [ ... "[object" obj ] */ - -#if defined(DUK_USE_SYMBOL_BUILTIN) - /* XXX: better handling with avoid_side_effects == 1; lookup tval - * without Proxy or getter side effects, and use it in sanitized - * form if it's a string. - */ - if (!avoid_side_effects) { - /* XXX: The problem with using the prototype object as the - * lookup base is that if @@toStringTag is a getter, its - * 'this' binding must be the ToObject() coerced input value, - * not the prototype object of the type. - */ - (void) duk_get_prop_stridx(thr, -1, DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG); - if (duk_is_string_notsymbol(thr, -1)) { - duk_remove_m2(thr); - goto finish; - } - duk_pop_unsafe(thr); - } -#endif - - if (stridx_bidx == 0xffffffffUL) { - duk_hobject *h_obj; - duk_small_uint_t classnum; - - h_obj = duk_known_hobject(thr, -1); - DUK_ASSERT(h_obj != NULL); - classnum = DUK_HOBJECT_GET_CLASS_NUMBER(h_obj); - stridx_bidx = DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(classnum); - } else { - /* stridx_bidx already has the desired fallback stridx. */ - ; - } - duk_pop_unsafe(thr); - /* Fall through. */ - - use_stridx: - /* [ ... "[object" ] */ - duk_push_hstring_stridx(thr, stridx_bidx & 0xffffUL); - - finish: - /* [ ... "[object" tag ] */ - duk_push_literal(thr, "]"); - duk_concat(thr, 3); /* [ ... "[object" tag "]" ] -> [ ... res ] */ -} -#endif /* 0 */ - -DUK_INTERNAL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv, duk_bool_t avoid_side_effects) { - duk_hobject *h_obj; - duk_small_uint_t classnum; - duk_small_uint_t stridx; - duk_tval tv_tmp; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(tv != NULL); - - /* Stabilize 'tv', duk_push_literal() may trigger side effects. */ - DUK_TVAL_SET_TVAL(&tv_tmp, tv); - tv = &tv_tmp; - - /* Conceptually for any non-undefined/null value we should do a - * ToObject() coercion and look up @@toStringTag (from the object - * prototype) to see if a custom result should be used. We'd like to - * avoid the actual conversion, but even for primitive types the - * prototype may have @@toStringTag. What's worse, the @@toStringTag - * property may be a getter that must get the object coerced value - * (not the prototype) as its 'this' binding. - * - * For now, do an actual object coercion. This could be avoided by - * doing a side effect free lookup to see if a getter would be invoked. - * If not, the value can be read directly and the object coercion could - * be avoided. This may not be worth it in practice, because - * Object.prototype.toString() is usually not performance critical. - */ - - duk_push_literal(thr, "[object "); /* -> [ ... "[object" ] */ - - switch (DUK_TVAL_GET_TAG(tv)) { - case DUK_TAG_UNUSED: /* Treat like 'undefined', shouldn't happen. */ - case DUK_TAG_UNDEFINED: { - duk_push_hstring_stridx(thr, DUK_STRIDX_UC_UNDEFINED); - goto finish; - } - case DUK_TAG_NULL: { - duk_push_hstring_stridx(thr, DUK_STRIDX_UC_NULL); - goto finish; + stridx = DUK_STRIDX_UC_NUMBER; + break; } } + h_strclass = DUK_HTHREAD_GET_STRING(thr, stridx); + DUK_ASSERT(h_strclass != NULL); - duk_push_tval(thr, tv); - tv = NULL; /* Invalidated by ToObject(). */ - duk_to_object(thr, -1); - - /* [ ... "[object" obj ] */ - -#if defined(DUK_USE_SYMBOL_BUILTIN) - /* XXX: better handling with avoid_side_effects == 1; lookup tval - * without Proxy or getter side effects, and use it in sanitized - * form if it's a string. - */ - if (!avoid_side_effects) { - (void) duk_get_prop_stridx(thr, -1, DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG); - if (duk_is_string_notsymbol(thr, -1)) { - duk_remove_m2(thr); - goto finish; - } - duk_pop_unsafe(thr); - } -#else - DUK_UNREF(avoid_side_effects); -#endif - - h_obj = duk_known_hobject(thr, -1); - DUK_ASSERT(h_obj != NULL); - classnum = DUK_HOBJECT_GET_CLASS_NUMBER(h_obj); - stridx = DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(classnum); - duk_pop_unsafe(thr); - duk_push_hstring_stridx(thr, stridx); - - finish: - /* [ ... "[object" tag ] */ - duk_push_literal(thr, "]"); - duk_concat(thr, 3); /* [ ... "[object" tag "]" ] -> [ ... res ] */ + duk_push_sprintf(thr, "[object %s]", (const char *) DUK_HSTRING_GET_DATA(h_strclass)); } /* XXX: other variants like uint, u32 etc */ @@ -3361,7 +3180,6 @@ /* coerced value is updated to value stack even when RangeError thrown */ if (clamped) { DUK_ERROR_RANGE(thr, DUK_STR_NUMBER_OUTSIDE_RANGE); - DUK_WO_NORETURN(return 0;); } } @@ -3419,14 +3237,12 @@ DUK_ASSERT(h != NULL); if (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_CANNOT_STRING_COERCE_SYMBOL); - DUK_WO_NORETURN(goto skip_replace;); } else { goto skip_replace; } #else goto skip_replace; #endif - break; } case DUK_TAG_BUFFER: /* Go through Uint8Array.prototype.toString() for coercion. */ case DUK_TAG_OBJECT: { @@ -3577,9 +3393,14 @@ } dst_data = (duk_uint8_t *) duk_push_buffer(thr, src_size, (mode == DUK_BUF_MODE_DYNAMIC) /*dynamic*/); - /* dst_data may be NULL if size is zero. */ - duk_memcpy_unsafe((void *) dst_data, (const void *) src_data, (size_t) src_size); - + if (DUK_LIKELY(src_size > 0)) { + /* When src_size == 0, src_data may be NULL (if source + * buffer is dynamic), and dst_data may be NULL (if + * target buffer is dynamic). Avoid zero-size memcpy() + * with an invalid pointer. + */ + DUK_MEMCPY((void *) dst_data, (const void *) src_data, (size_t) src_size); + } duk_replace(thr, idx); skip_copy: @@ -3695,7 +3516,6 @@ case DUK_TAG_UNDEFINED: case DUK_TAG_NULL: { DUK_ERROR_TYPE(thr, DUK_STR_NOT_OBJECT_COERCIBLE); - DUK_WO_NORETURN(return;); break; } case DUK_TAG_BOOLEAN: { @@ -4003,7 +3823,7 @@ } if (mask & DUK_TYPE_MASK_THROW) { DUK_ERROR_TYPE(thr, DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); } return 0; } @@ -4476,22 +4296,21 @@ DUK_ASSERT_API_ENTRY(thr); - /* Check stack before interning (avoid hanging temp). */ + /* check stack before interning (avoid hanging temp) */ DUK__CHECK_SPACE(); /* NULL with zero length represents an empty string; NULL with higher - * length is also now treated like an empty string although it is + * length is also now trated like an empty string although it is * a bit dubious. This is unlike duk_push_string() which pushes a * 'null' if the input string is a NULL. */ - if (DUK_UNLIKELY(str == NULL)) { - len = 0U; + if (!str) { + len = 0; } - /* Check for maximum string length. */ + /* Check for maximum string length */ if (DUK_UNLIKELY(len > DUK_HSTRING_MAX_BYTELEN)) { DUK_ERROR_RANGE(thr, DUK_STR_STRING_TOO_LONG); - DUK_WO_NORETURN(return NULL;); } h = duk_heap_strtable_intern_checked(thr, (const duk_uint8_t *) str, (duk_uint32_t) len); @@ -4515,42 +4334,6 @@ } } -#if !defined(DUK_USE_PREFER_SIZE) -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_EXTERNAL const char *duk_push_literal_raw(duk_hthread *thr, const char *str, duk_size_t len) { - duk_hstring *h; - duk_tval *tv_slot; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(str != NULL); - DUK_ASSERT(str[len] == (char) 0); - - /* Check for maximum string length. */ - if (DUK_UNLIKELY(len > DUK_HSTRING_MAX_BYTELEN)) { - DUK_ERROR_RANGE(thr, DUK_STR_STRING_TOO_LONG); - DUK_WO_NORETURN(return NULL;); - } - - h = duk_heap_strtable_intern_literal_checked(thr, (const duk_uint8_t *) str, (duk_uint32_t) len); - DUK_ASSERT(h != NULL); - - tv_slot = thr->valstack_top++; - DUK_TVAL_SET_STRING(tv_slot, h); - DUK_HSTRING_INCREF(thr, h); /* no side effects */ - - return (const char *) DUK_HSTRING_GET_DATA(h); -} -#else /* DUK_USE_LITCACHE_SIZE */ -DUK_EXTERNAL const char *duk_push_literal_raw(duk_hthread *thr, const char *str, duk_size_t len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(str != NULL); - DUK_ASSERT(str[len] == (char) 0); - - return duk_push_lstring(thr, str, len); -} -#endif /* DUK_USE_LITCACHE_SIZE */ -#endif /* !DUK_USE_PREFER_SIZE */ - DUK_EXTERNAL void duk_push_pointer(duk_hthread *thr, void *val) { duk_tval *tv_slot; @@ -4604,7 +4387,6 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_NOT_OBJECT_COERCIBLE); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_push_this(duk_hthread *thr) { @@ -4648,46 +4430,6 @@ return thr->valstack_bottom - 1; } -DUK_EXTERNAL void duk_push_new_target(duk_hthread *thr) { - duk_activation *act; - - DUK_ASSERT_API_ENTRY(thr); - - /* https://www.ecma-international.org/ecma-262/6.0/#sec-meta-properties-runtime-semantics-evaluation - * https://www.ecma-international.org/ecma-262/6.0/#sec-getnewtarget - * - * No newTarget support now, so as a first approximation - * use the resolved (non-bound) target function. - * - * Check CONSTRUCT flag from current function, or if running - * direct eval, from a non-direct-eval parent (with possibly - * more than one nested direct eval). An alternative to this - * would be to store [[NewTarget]] as a hidden symbol of the - * lexical scope, and then just look up that variable. - * - * Calls from the application will either be for an empty - * call stack, or a Duktape/C function as the top activation. - */ - - act = thr->callstack_curr; - for (;;) { - if (act == NULL) { - break; - } - - if (act->flags & DUK_ACT_FLAG_CONSTRUCT) { - duk_push_tval(thr, &act->tv_func); - return; - } else if (act->flags & DUK_ACT_FLAG_DIRECT_EVAL) { - act = act->parent; - } else { - break; - } - } - - duk_push_undefined(thr); -} - DUK_EXTERNAL void duk_push_current_function(duk_hthread *thr) { duk_activation *act; @@ -4748,7 +4490,7 @@ DUK_ASSERT_API_ENTRY(thr); if (DUK_UNLIKELY(target_thr == NULL)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return;); + return; /* not reached */ } duk_push_hobject(thr, (duk_hobject *) target_thr); duk__push_stash(thr); @@ -4824,7 +4566,6 @@ sz = sz * 2; if (DUK_UNLIKELY(sz >= DUK_PUSH_SPRINTF_SANITY_LIMIT)) { DUK_ERROR_RANGE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return NULL;); } } @@ -5013,7 +4754,6 @@ /* important to do this *after* pushing, to make the thread reachable for gc */ if (DUK_UNLIKELY(!duk_hthread_init_stacks(thr->heap, obj))) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return 0;); } /* initialize built-ins - either by copying or creating new ones */ @@ -5055,7 +4795,6 @@ DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_FUNCTION)); if (DUK_UNLIKELY(obj == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } DUK_DDD(DUK_DDDPRINT("created compiled function object with flags: 0x%08lx", (unsigned long) obj->obj.hdr.h_flags)); @@ -5087,7 +4826,6 @@ DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_FUNCTION)); if (!obj) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } tv_slot = thr->valstack_top++; @@ -5144,7 +4882,7 @@ api_error: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + return 0; /* not reached */ } DUK_EXTERNAL duk_idx_t duk_push_c_function(duk_hthread *thr, duk_c_function func, duk_int_t nargs) { @@ -5236,7 +4974,7 @@ api_error: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + return 0; /* not reached */ } #if defined(DUK_USE_BUFFEROBJECT_SUPPORT) @@ -5388,11 +5126,11 @@ range_error: DUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARGS); - DUK_WO_NORETURN(return;); + return; /* not reached */ arg_error: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_ARGS); - DUK_WO_NORETURN(return;); + return; /* not reached */ } #else /* DUK_USE_BUFFEROBJECT_SUPPORT */ DUK_EXTERNAL void duk_push_buffer_object(duk_hthread *thr, duk_idx_t idx_buffer, duk_size_t byte_offset, duk_size_t byte_length, duk_uint_t flags) { @@ -5402,7 +5140,6 @@ DUK_UNREF(byte_length); DUK_UNREF(flags); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ @@ -5440,7 +5177,7 @@ duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_MESSAGE, DUK_PROPDESC_FLAGS_WC); } else { /* If no explicit message given, put error code into message field - * (as a number). This is not fully in keeping with the ECMAScript + * (as a number). This is not fully in keeping with the Ecmascript * error model because messages are supposed to be strings (Error * constructors use ToString() on their argument). However, it's * probably more useful than having a separate 'code' property. @@ -5502,13 +5239,11 @@ /* Check for maximum buffer length. */ if (DUK_UNLIKELY(size > DUK_HBUFFER_MAX_BYTELEN)) { DUK_ERROR_RANGE(thr, DUK_STR_BUFFER_TOO_LONG); - DUK_WO_NORETURN(return NULL;); } h = duk_hbuffer_alloc(thr->heap, size, flags, &buf_data); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } tv_slot = thr->valstack_top; @@ -5530,12 +5265,11 @@ DUK_ASSERT_API_ENTRY(thr); ptr = duk_push_buffer_raw(thr, len, 0); - DUK_ASSERT(ptr != NULL); #if !defined(DUK_USE_ZERO_BUFFER_DATA) /* ES2015 requires zeroing even when DUK_USE_ZERO_BUFFER_DATA * is not set. */ - duk_memzero((void *) ptr, (size_t) len); + DUK_MEMZERO((void *) ptr, (size_t) len); #endif return ptr; } @@ -5632,14 +5366,12 @@ fail_args: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); } #else /* DUK_USE_ES6_PROXY */ DUK_EXTERNAL duk_idx_t duk_push_proxy(duk_hthread *thr, duk_uint_t proxy_flags) { DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(proxy_flags); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } #endif /* DUK_USE_ES6_PROXY */ @@ -5937,7 +5669,7 @@ if (DUK_UNLIKELY((duk_uidx_t) (thr->valstack_top - thr->valstack_bottom) < (duk_uidx_t) count)) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count >= 0); @@ -6025,7 +5757,6 @@ DUK_ASSERT(thr->valstack_top >= thr->valstack_bottom); if (DUK_UNLIKELY(thr->valstack_top == thr->valstack_bottom)) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); } duk__pop_unsafe_raw(thr); @@ -6114,7 +5845,6 @@ DUK_ASSERT(thr->valstack_top >= thr->valstack_bottom); if (DUK_UNLIKELY(thr->valstack_top - 2 < thr->valstack_bottom)) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); } duk__pop_2_unsafe_raw(thr); @@ -6172,7 +5902,7 @@ if (DUK_UNLIKELY((duk_uidx_t) count > (duk_uidx_t) top)) { /* Also handles negative count. */ DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count >= 0); @@ -6189,8 +5919,9 @@ /* Copy value stack values directly to the array part without * any refcount updates: net refcount changes are zero. */ + tv_src = thr->valstack_top - count - 1; - duk_memcpy_unsafe((void *) tv_dst, (const void *) tv_src, (size_t) count * sizeof(duk_tval)); + DUK_MEMCPY((void *) tv_dst, (const void *) tv_src, (size_t) count * sizeof(duk_tval)); /* Overwrite result array to final value stack location and wipe * the rest; no refcount operations needed. @@ -6308,11 +6039,11 @@ } DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + return 0; fail_over_2g: DUK_ERROR_RANGE_INVALID_LENGTH(thr); - DUK_WO_NORETURN(return 0;); + return 0; } /* @@ -6329,7 +6060,6 @@ if (DUK_UNLIKELY(thr->valstack_top == thr->valstack_bottom)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return;); } /* Errors are augmented when they are created, not when they are @@ -6393,7 +6123,6 @@ duk_push_error_object_va_raw(thr, err_code, filename, line, fmt, ap); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_error_raw(duk_hthread *thr, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...) { @@ -6405,7 +6134,6 @@ duk_push_error_object_va_raw(thr, err_code, filename, line, fmt, ap); va_end(ap); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } #if !defined(DUK_USE_VARIADIC_MACROS) @@ -6424,7 +6152,6 @@ duk_push_error_object_va_raw(thr, err_code, filename, line, fmt, ap); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } #define DUK__ERROR_STASH_SHARED(code) do { \ @@ -6432,7 +6159,7 @@ va_start(ap, fmt); \ duk__throw_error_from_stash(thr, (code), fmt, ap); \ va_end(ap); \ - DUK_WO_NORETURN(return 0;); \ + /* Never reached; if return 0 here, gcc/clang will complain. */ \ } while (0) DUK_EXTERNAL duk_ret_t duk_error_stash(duk_hthread *thr, duk_errcode_t err_code, const char *fmt, ...) { @@ -6562,7 +6289,7 @@ DUK_ASSERT_API_ENTRY(thr); - duk_push_literal(thr, "light_"); + duk_push_sprintf(thr, "light_"); duk_push_string_funcptr(thr, (duk_uint8_t *) &func, sizeof(func)); duk_push_sprintf(thr, "_%04x", (unsigned int) lf_flags); duk_concat(thr, 3); @@ -6587,9 +6314,9 @@ DUK_ASSERT(DUK_TVAL_IS_LIGHTFUNC(tv)); DUK_TVAL_GET_LIGHTFUNC(tv, func, lf_flags); /* read before 'tv' potentially invalidated */ - duk_push_literal(thr, "function "); + duk_push_string(thr, "function "); duk_push_lightfunc_name_raw(thr, func, lf_flags); - duk_push_literal(thr, "() { [lightfunc code] }"); + duk_push_string(thr, "() { [lightfunc code] }"); duk_concat(thr, 3); } @@ -6701,7 +6428,7 @@ /* 'tv' may be NULL */ if (tv == NULL) { - duk_push_literal(thr, "none"); + duk_push_string(thr, "none"); } else { switch (DUK_TVAL_GET_TAG(tv)) { case DUK_TAG_STRING: { @@ -6710,11 +6437,11 @@ /* XXX: string summary produces question marks * so this is not very ideal. */ - duk_push_literal(thr, "[Symbol "); + duk_push_string(thr, "[Symbol "); duk_push_string(thr, duk__get_symbol_type_string(h)); - duk_push_literal(thr, " "); + duk_push_string(thr, " "); duk__push_hstring_readable_unicode(thr, h, DUK__READABLE_STRING_MAXCHARS); - duk_push_literal(thr, "]"); + duk_push_string(thr, "]"); duk_concat(thr, 5); break; } @@ -6744,7 +6471,7 @@ break; } } - duk_push_class_string_tval(thr, tv, 1 /*avoid_side_effects*/); + duk_push_class_string_tval(thr, tv); break; } case DUK_TAG_BUFFER: { @@ -6799,7 +6526,7 @@ DUK_ASSERT_API_ENTRY(thr); /* .toString() */ - duk_push_literal(thr, "Symbol("); + duk_push_string(thr, "Symbol("); p = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h); p_end = p + DUK_HSTRING_GET_BYTELEN(h); DUK_ASSERT(p[0] == 0xff || (p[0] & 0xc0) == 0x80); @@ -6815,7 +6542,7 @@ } } duk_push_lstring(thr, (const char *) p, (duk_size_t) (q - p)); - duk_push_literal(thr, ")"); + duk_push_string(thr, ")"); duk_concat(thr, 3); } @@ -6851,8 +6578,7 @@ DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(thr); DUK_ASSERT(count * sizeof(duk_tval) >= count); /* no wrap */ - - duk_memcpy_unsafe((void *) tv_dst, (const void *) tv_src, count * sizeof(duk_tval)); + DUK_MEMCPY((void *) tv_dst, (const void *) tv_src, count * sizeof(duk_tval)); tv = tv_dst; while (count-- > 0) { diff -Nru duktape-2.3.0/src-input/duk_api_string.c duktape-2.2.0/src-input/duk_api_string.c --- duktape-2.3.0/src-input/duk_api_string.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_api_string.c 2017-09-23 01:06:08.000000000 +0000 @@ -17,7 +17,7 @@ if (DUK_UNLIKELY(count_in <= 0)) { if (count_in < 0) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count_in == 0); duk_push_hstring_empty(thr); @@ -73,11 +73,11 @@ for (i = count; i >= 1; i--) { if (is_join && i != count) { h = duk_require_hstring(thr, -((duk_idx_t) count) - 2); /* extra -1 for buffer */ - duk_memcpy(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); + DUK_MEMCPY(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); idx += DUK_HSTRING_GET_BYTELEN(h); } h = duk_require_hstring(thr, -((duk_idx_t) i) - 1); /* extra -1 for buffer */ - duk_memcpy(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); + DUK_MEMCPY(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); idx += DUK_HSTRING_GET_BYTELEN(h); } @@ -104,7 +104,6 @@ error_overflow: DUK_ERROR_RANGE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_concat(duk_hthread *thr, duk_idx_t count) { @@ -142,8 +141,8 @@ buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, len); DUK_ASSERT(buf != NULL); - duk_memcpy((void *) buf, (const void *) DUK_HSTRING_GET_DATA(h1), (size_t) len1); - duk_memcpy((void *) (buf + len1), (const void *) DUK_HSTRING_GET_DATA(h2), (size_t) len2); + DUK_MEMCPY((void *) buf, (const void *) DUK_HSTRING_GET_DATA(h1), (size_t) len1); + DUK_MEMCPY((void *) (buf + len1), (const void *) DUK_HSTRING_GET_DATA(h2), (size_t) len2); (void) duk_buffer_to_string(thr, -1); /* Safe if inputs are safe. */ /* [ ... str1 str2 buf ] */ @@ -154,7 +153,6 @@ error_overflow: DUK_ERROR_RANGE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_PREFER_SIZE */ diff -Nru duktape-2.3.0/src-input/duk_api_time.c duktape-2.2.0/src-input/duk_api_time.c --- duktape-2.3.0/src-input/duk_api_time.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_api_time.c 2017-09-23 01:06:08.000000000 +0000 @@ -5,7 +5,7 @@ #include "duk_internal.h" DUK_INTERNAL duk_double_t duk_time_get_ecmascript_time(duk_hthread *thr) { - /* ECMAScript time, with millisecond fractions. Exposed via + /* Ecmascript time, with millisecond fractions. Exposed via * duk_get_now() for example. */ DUK_UNREF(thr); @@ -13,7 +13,7 @@ } DUK_INTERNAL duk_double_t duk_time_get_ecmascript_time_nofrac(duk_hthread *thr) { - /* ECMAScript time without millisecond fractions. Exposed via + /* Ecmascript time without millisecond fractions. Exposed via * the Date built-in which doesn't allow fractions. */ DUK_UNREF(thr); @@ -56,7 +56,7 @@ DUK_UNREF(thr); /* Convert as one-based, but change month to zero-based to match the - * ECMAScript Date built-in behavior 1:1. + * Ecmascript Date built-in behavior 1:1. */ flags = DUK_DATE_FLAG_ONEBASED | DUK_DATE_FLAG_NAN_TO_ZERO; diff -Nru duktape-2.3.0/src-input/duk_bi_array.c duktape-2.2.0/src-input/duk_bi_array.c --- duktape-2.3.0/src-input/duk_bi_array.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_array.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,9 +1,9 @@ /* * Array built-ins * - * Most Array built-ins are intentionally generic in ECMAScript, and are + * Most Array built-ins are intentionally generic in Ecmascript, and are * intended to work even when the 'this' binding is not an Array instance. - * This ECMAScript feature is also used by much real world code. For this + * This Ecmascript feature is also used by much real world code. For this * reason the implementations here don't assume exotic Array behavior or * e.g. presence of a .length property. However, some algorithms have a * fast path for duk_harray backed actual Array instances, enabled when @@ -77,7 +77,6 @@ duk_uint32_t ret = duk__push_this_obj_len_u32(thr); if (DUK_UNLIKELY(ret >= 0x80000000UL)) { DUK_ERROR_RANGE_INVALID_LENGTH(thr); - DUK_WO_NORETURN(return 0U;); } return ret; } @@ -230,17 +229,11 @@ DUK_INTERNAL duk_ret_t duk_bi_array_prototype_concat(duk_hthread *thr) { duk_idx_t i, n; - duk_uint32_t j, idx, len; + duk_uarridx_t idx, idx_last; + duk_uarridx_t j, len; duk_hobject *h; - duk_size_t tmp_len; - /* XXX: In ES2015 Array .length can be up to 2^53-1. The current - * implementation is limited to 2^32-1. - */ - - /* XXX: Fast path for array 'this' and array element. */ - - /* XXX: The insert here is a bit expensive if there are a lot of items. + /* XXX: the insert here is a bit expensive if there are a lot of items. * It could also be special cased in the outermost for loop quite easily * (as the element is dup()'d anyway). */ @@ -258,97 +251,59 @@ */ idx = 0; + idx_last = 0; for (i = 0; i < n; i++) { - duk_bool_t spreadable; - duk_bool_t need_has_check; - DUK_ASSERT_TOP(thr, n + 1); /* [ ToObject(this) item1 ... itemN arr ] */ - h = duk_get_hobject(thr, i); - - if (h == NULL) { - spreadable = 0; - } else { -#if defined(DUK_USE_SYMBOL_BUILTIN) - duk_get_prop_stridx(thr, i, DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE); - if (duk_is_undefined(thr, -1)) { - spreadable = (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY); - } else { - spreadable = duk_to_boolean(thr, -1); - } - duk_pop_nodecref_unsafe(thr); -#else - spreadable = (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY); -#endif - } - - if (!spreadable) { - duk_dup(thr, i); - duk_xdef_prop_index_wec(thr, -2, idx); - idx++; - if (DUK_UNLIKELY(idx == 0U)) { - /* Index after update is 0, and index written - * was 0xffffffffUL which is no longer a valid - * array index. - */ - goto fail_wrap; - } + duk_dup(thr, i); + h = duk_get_hobject_with_class(thr, -1, DUK_HOBJECT_CLASS_ARRAY); + if (!h) { + duk_xdef_prop_index_wec(thr, -2, idx++); + idx_last = idx; continue; } - DUK_ASSERT(duk_is_object(thr, i)); - need_has_check = (DUK_HOBJECT_IS_PROXY(h) != 0); /* Always 0 w/o Proxy support. */ + /* [ ToObject(this) item1 ... itemN arr item(i) ] */ - /* [ ToObject(this) item1 ... itemN arr ] */ - - tmp_len = duk_get_length(thr, i); - len = (duk_uint32_t) tmp_len; - if (DUK_UNLIKELY(tmp_len != (duk_size_t) len)) { - goto fail_wrap; - } - if (DUK_UNLIKELY(idx + len < idx)) { - /* Result length must be at most 0xffffffffUL to be - * a valid 32-bit array index. - */ - goto fail_wrap; - } + /* XXX: an array can have length higher than 32 bits; this is not handled + * correctly now. + */ + len = (duk_uarridx_t) duk_get_length(thr, -1); for (j = 0; j < len; j++) { - /* For a Proxy element, an explicit 'has' check is - * needed to allow the Proxy to present gaps. - */ - if (need_has_check) { - if (duk_has_prop_index(thr, i, j)) { - duk_get_prop_index(thr, i, j); - duk_xdef_prop_index_wec(thr, -2, idx); - } + if (duk_get_prop_index(thr, -1, j)) { + /* [ ToObject(this) item1 ... itemN arr item(i) item(i)[j] ] */ + duk_xdef_prop_index_wec(thr, -3, idx++); + idx_last = idx; } else { - if (duk_get_prop_index(thr, i, j)) { - duk_xdef_prop_index_wec(thr, -2, idx); - } else { - duk_pop_undefined(thr); - } + idx++; + duk_pop_undefined(thr); +#if defined(DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER) + /* According to E5.1 Section 15.4.4.4 nonexistent trailing + * elements do not affect 'length' of the result. Test262 + * and other engines disagree, so update idx_last here too. + */ + idx_last = idx; +#else + /* Strict standard behavior, ignore trailing elements for + * result 'length'. + */ +#endif } - idx++; - DUK_ASSERT(idx != 0U); /* Wrap check above. */ } + duk_pop_unsafe(thr); } - /* ES5.1 has a specification "bug" in that nonexistent trailing - * elements don't affect the result .length. Test262 and other - * engines disagree, and the specification bug was fixed in ES2015 - * (see NOTE 1 in https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.concat). + /* The E5.1 Section 15.4.4.4 algorithm doesn't set the length explicitly + * in the end, but because we're operating with an internal value which + * is known to be an array, this should be equivalent. */ - duk_push_uarridx(thr, idx); + duk_push_uarridx(thr, idx_last); duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_W); DUK_ASSERT_TOP(thr, n + 1); return 1; - - fail_wrap: - DUK_ERROR_RANGE_INVALID_LENGTH(thr); - DUK_WO_NORETURN(return 0;); } /* @@ -1470,12 +1425,20 @@ DUK_ASSERT_TOP(thr, 5); if (!duk_get_prop_index(thr, 2, (duk_uarridx_t) i)) { - /* For 'map' trailing missing elements don't invoke the - * callback but count towards the result length. +#if defined(DUK_USE_NONSTD_ARRAY_MAP_TRAILER) + /* Real world behavior for map(): trailing non-existent + * elements don't invoke the user callback, but are still + * counted towards result 'length'. */ if (iter_type == DUK__ITER_MAP) { res_length = i + 1; } +#else + /* Standard behavior for map(): trailing non-existent + * elements don't invoke the user callback and are not + * counted towards result 'length'. + */ +#endif duk_pop_undefined(thr); continue; } diff -Nru duktape-2.3.0/src-input/duk_bi_buffer.c duktape-2.2.0/src-input/duk_bi_buffer.c --- duktape-2.3.0/src-input/duk_bi_buffer.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_buffer.c 2017-09-23 01:06:08.000000000 +0000 @@ -175,7 +175,6 @@ if (flags & DUK__BUFOBJ_FLAG_THROW) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } return NULL; } @@ -217,7 +216,7 @@ } DUK_ERROR_TYPE(thr, DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); + return NULL; /* not reachable */ } DUK_LOCAL void duk__set_bufobj_buffer(duk_hthread *thr, duk_hbufobj *h_bufobj, duk_hbuffer *h_val) { @@ -292,7 +291,6 @@ fail_range: DUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARGS); - DUK_WO_NORETURN(return;); } /* Shared lenient buffer length clamping helper. No negative indices, no @@ -443,8 +441,7 @@ DUK_INTERNAL void duk_hbufobj_push_validated_read(duk_hthread *thr, duk_hbufobj *h_bufobj, duk_uint8_t *p, duk_small_uint_t elem_size) { duk_double_union du; - DUK_ASSERT(elem_size > 0); - duk_memcpy((void *) du.uc, (const void *) p, (size_t) elem_size); + DUK_MEMCPY((void *) du.uc, (const void *) p, (size_t) elem_size); switch (h_bufobj->elem_type) { case DUK_HBUFOBJ_ELEM_UINT8: @@ -512,11 +509,7 @@ du.ui[0] = (duk_uint32_t) duk_to_int32(thr, -1); break; case DUK_HBUFOBJ_ELEM_FLOAT32: - /* A double-to-float cast is undefined behavior in C99 if - * the cast is out-of-range, so use a helper. Example: - * runtime error: value -1e+100 is outside the range of representable values of type 'float' - */ - du.f[0] = duk_double_to_float_t(duk_to_number_m1(thr)); + du.f[0] = (duk_float_t) duk_to_number_m1(thr); break; case DUK_HBUFOBJ_ELEM_FLOAT64: du.d = (duk_double_t) duk_to_number_m1(thr); @@ -525,8 +518,7 @@ DUK_UNREACHABLE(); } - DUK_ASSERT(elem_size > 0); - duk_memcpy((void *) p, (const void *) du.uc, (size_t) elem_size); + DUK_MEMCPY((void *) p, (const void *) du.uc, (size_t) elem_size); } /* Helper to create a fixed buffer from argument value at index 0. @@ -562,14 +554,12 @@ h_bufobj = (duk_hbufobj *) h; if (DUK_UNLIKELY(h_bufobj->buf == NULL)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } if (DUK_UNLIKELY(h_bufobj->offset != 0 || h_bufobj->length != DUK_HBUFFER_GET_SIZE(h_bufobj->buf))) { /* No support for ArrayBuffers with slice * offset/length. */ DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } duk_push_hbuffer(thr, h_bufobj->buf); return h_bufobj->buf; @@ -585,7 +575,6 @@ } default: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } done: @@ -627,7 +616,7 @@ duk_push_buffer_object(thr, -1, 0, - DUK_HBUFFER_FIXED_GET_SIZE((duk_hbuffer_fixed *) (void *) h_buf), + DUK_HBUFFER_FIXED_GET_SIZE((duk_hbuffer_fixed *) h_buf), DUK_BUFOBJ_UINT8ARRAY); duk_push_hobject_bidx(thr, DUK_BIDX_NODEJS_BUFFER_PROTOTYPE); duk_set_prototype(thr, -2); @@ -955,7 +944,7 @@ DUK_DDD(DUK_DDDPRINT("using memcpy: p_src=%p, p_dst=%p, byte_length=%ld", (void *) p_src, (void *) p_dst, (long) byte_length)); - duk_memcpy_unsafe((void *) p_dst, (const void *) p_src, (size_t) byte_length); + DUK_MEMCPY((void *) p_dst, (const void *) p_src, (size_t) byte_length); break; } case 1: { @@ -1191,7 +1180,7 @@ h_this = duk__get_bufobj_this(thr); if (h_this == NULL) { /* XXX: happens e.g. when evaluating: String(Buffer.prototype). */ - duk_push_literal(thr, "[object Object]"); + duk_push_string(thr, "[object Object]"); return 1; } DUK_ASSERT_HBUFOBJ_VALID(h_this); @@ -1222,9 +1211,9 @@ */ DUK_ASSERT(DUK_HBUFOBJ_VALID_BYTEOFFSET_EXCL(h_this, (duk_size_t) start_offset + slice_length)); - duk_memcpy_unsafe((void *) buf_slice, - (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), - (size_t) slice_length); + DUK_MEMCPY((void *) buf_slice, + (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), + (size_t) slice_length); /* Use the equivalent of: new TextEncoder().encode(this) to convert the * string. Result will be valid UTF-8; non-CESU-8 inputs are currently @@ -1386,7 +1375,7 @@ /* Handle single character fills as memset() even when * the fill data comes from a one-char argument. */ - duk_memset_unsafe((void *) p, (int) fill_str_ptr[0], (size_t) fill_length); + DUK_MEMSET((void *) p, (int) fill_str_ptr[0], (size_t) fill_length); } else if (fill_str_len > 1) { duk_size_t i, n, t; @@ -1437,9 +1426,9 @@ if (DUK_HBUFOBJ_VALID_SLICE(h_this)) { /* Cannot overlap. */ - duk_memcpy_unsafe((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + offset), - (const void *) str_data, - (size_t) length); + DUK_MEMCPY((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + offset), + (const void *) str_data, + (size_t) length); } else { DUK_DDD(DUK_DDDPRINT("write() target buffer is not covered, silent ignore")); } @@ -1535,9 +1524,9 @@ /* Must use memmove() because copy area may overlap (source and target * buffer may be the same, or from different slices. */ - duk_memmove_unsafe((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufarg) + target_ustart), - (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + source_ustart), - (size_t) copy_size); + DUK_MEMMOVE((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufarg) + target_ustart), + (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + source_ustart), + (size_t) copy_size); } else { DUK_DDD(DUK_DDDPRINT("buffer copy not covered by underlying buffer(s), ignoring")); } @@ -1723,7 +1712,7 @@ DUK_ASSERT(src_length == dst_length); DUK_DDD(DUK_DDDPRINT("fast path: able to use memmove() because views are compatible")); - duk_memmove_unsafe((void *) p_dst_base, (const void *) p_src_base, (size_t) dst_length); + DUK_MEMMOVE((void *) p_dst_base, (const void *) p_src_base, (size_t) dst_length); return 0; } DUK_DDD(DUK_DDDPRINT("fast path: views are not compatible with a byte copy, copy by item")); @@ -1766,7 +1755,7 @@ DUK_DDD(DUK_DDDPRINT("there is overlap, make a copy of the source")); p_src_copy = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, src_length); DUK_ASSERT(p_src_copy != NULL); - duk_memcpy_unsafe((void *) p_src_copy, (const void *) p_src_base, (size_t) src_length); + DUK_MEMCPY((void *) p_src_copy, (const void *) p_src_base, (size_t) src_length); p_src_base = p_src_copy; /* use p_src_base from now on */ } @@ -1893,9 +1882,9 @@ DUK_ASSERT(p_copy != NULL); copy_length = slice_length; - duk_memcpy_unsafe((void *) p_copy, - (const void *) ((duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_val) + start_offset), - copy_length); + DUK_MEMCPY((void *) p_copy, + (const void *) ((duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_val) + start_offset), + copy_length); } #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ @@ -2017,9 +2006,9 @@ * is left as zero. */ copy_length = DUK_HBUFOBJ_CLAMP_BYTELENGTH(h_this, slice_length); - duk_memcpy_unsafe((void *) p_copy, - (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), - copy_length); + DUK_MEMCPY((void *) p_copy, + (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), + copy_length); h_val = duk_known_hbuffer(thr, -1); @@ -2211,9 +2200,9 @@ if (h_bufobj->buf != NULL && DUK_HBUFOBJ_VALID_SLICE(h_bufobj)) { - duk_memcpy_unsafe((void *) p, - (const void *) DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufobj), - copy_size); + DUK_MEMCPY((void *) p, + (const void *) DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufobj), + copy_size); } else { /* Just skip, leaving zeroes in the result. */ ; @@ -2363,7 +2352,7 @@ if (offset + 2U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 2); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 2); tmp = du.us[0]; if (endswap) { tmp = DUK_BSWAP16(tmp); @@ -2380,7 +2369,7 @@ if (offset + 4U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 4); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 4); tmp = du.ui[0]; if (endswap) { tmp = DUK_BSWAP32(tmp); @@ -2397,7 +2386,7 @@ if (offset + 4U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 4); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 4); if (endswap) { tmp = du.ui[0]; tmp = DUK_BSWAP32(tmp); @@ -2410,7 +2399,7 @@ if (offset + 8U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 8); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 8); if (endswap) { DUK_DBLUNION_BSWAP64(&du); } @@ -2467,12 +2456,9 @@ } while (i != i_end); if (magic_signed) { - /* Shift to sign extend. Left shift must be unsigned - * to avoid undefined behavior; right shift must be - * signed to sign extend properly. - */ + /* Shift to sign extend. */ shift_tmp = (duk_small_uint_t) (64U - (duk_small_uint_t) field_bytelen * 8U); - tmp = (duk_int64_t) ((duk_uint64_t) tmp << shift_tmp) >> shift_tmp; + tmp = (tmp << shift_tmp) >> shift_tmp; } duk_push_i64(thr, tmp); @@ -2648,7 +2634,7 @@ } du.us[0] = tmp; /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 2); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 2); break; } case DUK__FLD_32BIT: { @@ -2662,7 +2648,7 @@ } du.ui[0] = tmp; /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 4); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 4); break; } case DUK__FLD_FLOAT: { @@ -2677,7 +2663,7 @@ du.ui[0] = tmp; } /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 4); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 4); break; } case DUK__FLD_DOUBLE: { @@ -2689,7 +2675,7 @@ DUK_DBLUNION_BSWAP64(&du); } /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 8); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 8); break; } case DUK__FLD_VARINT: { diff -Nru duktape-2.3.0/src-input/duk_bi_date.c duktape-2.2.0/src-input/duk_bi_date.c --- duktape-2.3.0/src-input/duk_bi_date.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_date.c 2017-09-23 01:06:08.000000000 +0000 @@ -200,7 +200,7 @@ duk_small_uint_t i; /* During parsing, month and day are one-based; set defaults here. */ - duk_memzero(parts, sizeof(parts)); + DUK_MEMZERO(parts, sizeof(parts)); DUK_ASSERT(parts[DUK_DATE_IDX_YEAR] == 0); /* don't care value, year is mandatory */ parts[DUK_DATE_IDX_MONTH] = 1; parts[DUK_DATE_IDX_DAY] = 1; @@ -427,13 +427,13 @@ }; /* Maximum iteration count for computing UTC-to-local time offset when - * creating an ECMAScript time value from local parts. + * creating an Ecmascript time value from local parts. */ #define DUK__LOCAL_TZOFFSET_MAXITER 4 /* Because 'day since epoch' can be negative and is used to compute weekday * using a modulo operation, add this multiple of 7 to avoid negative values - * when year is below 1970 epoch. ECMAScript time values are restricted to + * when year is below 1970 epoch. Ecmascript time values are restricted to * +/- 100 million days from epoch, so this adder fits nicely into 32 bits. * Round to a multiple of 7 (= floor(100000000 / 7) * 7) and add margin. */ @@ -624,10 +624,10 @@ d = DUK_FLOOR(d); /* remove fractions if present */ DUK_ASSERT(DUK_FLOOR(d) == d); - /* The timevalue must be in valid ECMAScript range, but since a local + /* The timevalue must be in valid Ecmascript range, but since a local * time offset can be applied, we need to allow a +/- 24h leeway to * the value. In other words, although the UTC time is within the - * ECMAScript range, the local part values can be just outside of it. + * Ecmascript range, the local part values can be just outside of it. */ DUK_UNREF(duk_bi_date_timeval_in_leeway_range); DUK_ASSERT(duk_bi_date_timeval_in_leeway_range(d)); @@ -670,7 +670,7 @@ (long) parts[DUK_DATE_IDX_MILLISECOND])); /* This assert depends on the input parts representing time inside - * the ECMAScript range. + * the Ecmascript range. */ DUK_ASSERT(t2 + DUK__WEEKDAY_MOD_ADDER >= 0); parts[DUK_DATE_IDX_WEEKDAY] = (t2 + 4 + DUK__WEEKDAY_MOD_ADDER) % 7; /* E5.1 Section 15.9.1.6 */ @@ -790,7 +790,7 @@ * computation happens with intermediate results coerced to * double values (instead of using something more accurate). * E.g. E5.1 Section 15.9.1.11 requires use of IEEE 754 - * rules (= ECMAScript '+' and '*' operators). + * rules (= Ecmascript '+' and '*' operators). * * Without 'volatile' even this approach fails on some platform * and compiler combinations. For instance, gcc 4.8.1 on Ubuntu @@ -897,7 +897,6 @@ h = duk_get_hobject(thr, -1); /* XXX: getter with class check, useful in built-ins */ if (h == NULL || DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_DATE) { DUK_ERROR_TYPE(thr, "expected Date"); - DUK_WO_NORETURN(return 0.0;); } duk_get_prop_stridx_short(thr, -1, DUK_STRIDX_INT_VALUE); @@ -910,7 +909,6 @@ } if (flags & DUK_DATE_FLAG_NAN_TO_RANGE_ERROR) { DUK_ERROR_RANGE(thr, "Invalid Date"); - DUK_WO_NORETURN(return 0.0;); } } /* if no NaN handling flag, may still be NaN here, but not Inf */ @@ -1527,7 +1525,7 @@ * Notes: * * - Date.prototype.toGMTString() and Date.prototype.toUTCString() are - * required to be the same ECMAScript function object (!), so it is + * required to be the same Ecmascript function object (!), so it is * omitted from here. * * - Date.prototype.toUTCString(): E5.1 specification does not require a @@ -1723,39 +1721,4 @@ return 1; } -/* - * Misc. - */ - -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL duk_ret_t duk_bi_date_prototype_toprimitive(duk_hthread *thr) { - duk_size_t hintlen; - const char *hintstr; - duk_int_t hint; - - /* Invokes OrdinaryToPrimitive() with suitable hint. Note that the - * method is generic, and works on non-Date arguments too. - * - * https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype-@@toprimitive - */ - - duk_push_this(thr); - duk_require_object(thr, -1); - DUK_ASSERT_TOP(thr, 2); - - hintstr = duk_require_lstring(thr, 0, &hintlen); - if ((hintlen == 6 && DUK_STRCMP(hintstr, "string") == 0) || - (hintlen == 7 && DUK_STRCMP(hintstr, "default") == 0)) { - hint = DUK_HINT_STRING; - } else if (hintlen == 6 && DUK_STRCMP(hintstr, "number") == 0) { - hint = DUK_HINT_NUMBER; - } else { - DUK_DCERROR_TYPE_INVALID_ARGS(thr); - } - - duk_to_primitive_ordinary(thr, -1, hint); - return 1; -} -#endif /* DUK_USE_SYMBOL_BUILTIN */ - #endif /* DUK_USE_DATE_BUILTIN */ diff -Nru duktape-2.3.0/src-input/duk_bi_date_unix.c duktape-2.2.0/src-input/duk_bi_date_unix.c --- duktape-2.3.0/src-input/duk_bi_date_unix.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_date_unix.c 2017-09-23 01:06:08.000000000 +0000 @@ -15,7 +15,7 @@ #define DUK__STRFTIME_BUF_SIZE 64 #if defined(DUK_USE_DATE_NOW_GETTIMEOFDAY) -/* Get current ECMAScript time (= UNIX/Posix time, but in milliseconds). */ +/* Get current Ecmascript time (= UNIX/Posix time, but in milliseconds). */ DUK_INTERNAL duk_double_t duk_bi_date_get_now_gettimeofday(void) { struct timeval tv; duk_double_t d; @@ -63,7 +63,7 @@ return 0; } - /* If not within ECMAScript range, some integer time calculations + /* If not within Ecmascript range, some integer time calculations * won't work correctly (and some asserts will fail), so bail out * if so. This fixes test-bug-date-insane-setyear.js. There is * a +/- 24h leeway in this range check to avoid a test262 corner @@ -114,10 +114,10 @@ * Since we rely on the platform APIs for conversions between local * time and UTC, we can't guarantee the above. Rather, if the platform * has historical DST rules they will be applied. This seems to be the - * general preferred direction in ECMAScript standardization (or at least + * general preferred direction in Ecmascript standardization (or at least * implementations) anyway, and even the equivalent year mapping should * be disabled if the platform is known to handle DST properly for the - * full ECMAScript range. + * full Ecmascript range. * * The following has useful discussion and links: * @@ -132,7 +132,7 @@ t = (time_t) (d / 1000.0); DUK_DDD(DUK_DDDPRINT("timeval: %lf -> time_t %ld", (double) d, (long) t)); - duk_memzero((void *) tms, sizeof(struct tm) * 2); + DUK_MEMZERO((void *) tms, sizeof(struct tm) * 2); #if defined(DUK_USE_DATE_TZO_GMTIME_R) (void) gmtime_r(&t, &tms[0]); @@ -142,9 +142,9 @@ (void) localtime_s(&t, &tms[1]); #elif defined(DUK_USE_DATE_TZO_GMTIME) tm_ptr = gmtime(&t); - duk_memcpy((void *) &tms[0], tm_ptr, sizeof(struct tm)); + DUK_MEMCPY((void *) &tms[0], tm_ptr, sizeof(struct tm)); tm_ptr = localtime(&t); - duk_memcpy((void *) &tms[1], tm_ptr, sizeof(struct tm)); + DUK_MEMCPY((void *) &tms[1], tm_ptr, sizeof(struct tm)); #else #error internal error #endif @@ -205,13 +205,13 @@ /* Copy to buffer with slack to avoid Valgrind gripes from strptime. */ DUK_ASSERT(str != NULL); - duk_memzero(buf, sizeof(buf)); /* valgrind whine without this */ + DUK_MEMZERO(buf, sizeof(buf)); /* valgrind whine without this */ DUK_SNPRINTF(buf, sizeof(buf), "%s", (const char *) str); buf[sizeof(buf) - 1] = (char) 0; DUK_DDD(DUK_DDDPRINT("parsing: '%s'", (const char *) buf)); - duk_memzero(&tm, sizeof(tm)); + DUK_MEMZERO(&tm, sizeof(tm)); if (strptime((const char *) buf, "%c", &tm) != NULL) { DUK_DDD(DUK_DDDPRINT("before mktime: tm={sec:%ld,min:%ld,hour:%ld,mday:%ld,mon:%ld,year:%ld," "wday:%ld,yday:%ld,isdst:%ld}", @@ -242,7 +242,7 @@ * convenient for an embeddable interpreter. */ - duk_memzero(&tm, sizeof(struct tm)); + DUK_MEMZERO(&tm, sizeof(struct tm)); rc = (duk_small_int_t) getdate_r(str, &tm); DUK_DDD(DUK_DDDPRINT("getdate_r() -> %ld", (long) rc)); @@ -267,16 +267,16 @@ DUK_UNREF(tzoffset); - /* If the platform doesn't support the entire ECMAScript range, we need + /* If the platform doesn't support the entire Ecmascript range, we need * to return 0 so that the caller can fall back to the default formatter. * - * For now, assume that if time_t is 8 bytes or more, the whole ECMAScript + * For now, assume that if time_t is 8 bytes or more, the whole Ecmascript * range is supported. For smaller time_t values (4 bytes in practice), * assumes that the signed 32-bit range is supported. * * XXX: detect this more correctly per platform. The size of time_t is * probably not an accurate guarantee of strftime() supporting or not - * supporting a large time range (the full ECMAScript range). + * supporting a large time range (the full Ecmascript range). */ if (sizeof(time_t) < 8 && (parts[DUK_DATE_IDX_YEAR] < 1970 || parts[DUK_DATE_IDX_YEAR] > 2037)) { @@ -284,7 +284,7 @@ return 0; } - duk_memzero(&tm, sizeof(tm)); + DUK_MEMZERO(&tm, sizeof(tm)); tm.tm_sec = parts[DUK_DATE_IDX_SECOND]; tm.tm_min = parts[DUK_DATE_IDX_MINUTE]; tm.tm_hour = parts[DUK_DATE_IDX_HOUR]; @@ -294,7 +294,7 @@ tm.tm_wday = parts[DUK_DATE_IDX_WEEKDAY]; tm.tm_isdst = 0; - duk_memzero(buf, sizeof(buf)); + DUK_MEMZERO(buf, sizeof(buf)); if ((flags & DUK_DATE_FLAG_TOSTRING_DATE) && (flags & DUK_DATE_FLAG_TOSTRING_TIME)) { fmt = "%c"; } else if (flags & DUK_DATE_FLAG_TOSTRING_DATE) { diff -Nru duktape-2.3.0/src-input/duk_bi_date_windows.c duktape-2.2.0/src-input/duk_bi_date_windows.c --- duktape-2.3.0/src-input/duk_bi_date_windows.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_date_windows.c 2017-09-23 01:06:08.000000000 +0000 @@ -23,15 +23,13 @@ } } -#if defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS) DUK_LOCAL void duk__convert_filetime_to_ularge(const FILETIME *ft, ULARGE_INTEGER *res) { res->LowPart = ft->dwLowDateTime; res->HighPart = ft->dwHighDateTime; } -#endif /* DUK_USE_DATE_NOW_WINDOWS_SUBMS */ DUK_LOCAL void duk__set_systime_jan1970(SYSTEMTIME *st) { - duk_memzero((void *) st, sizeof(*st)); + DUK_MEMZERO((void *) st, sizeof(*st)); st->wYear = 1970; st->wMonth = 1; st->wDayOfWeek = 4; /* not sure whether or not needed; Thursday */ @@ -96,11 +94,10 @@ ULARGE_INTEGER tmp2; ULARGE_INTEGER tmp3; FILETIME ft1; - BOOL ret; /* XXX: handling of timestamps outside Windows supported range. * How does Windows deal with dates before 1600? Does windows - * support all ECMAScript years (like -200000 and +200000)? + * support all Ecmascript years (like -200000 and +200000)? * Should equivalent year mapping be used here too? If so, use * a shared helper (currently integrated into timeval-to-parts). */ @@ -116,11 +113,7 @@ ft1.dwLowDateTime = tmp2.LowPart; ft1.dwHighDateTime = tmp2.HighPart; - ret = FileTimeToSystemTime((const FILETIME *) &ft1, &st2); - if (!ret) { - DUK_D(DUK_DPRINT("FileTimeToSystemTime() failed, return tzoffset 0")); - return 0; - } + FileTimeToSystemTime((const FILETIME *) &ft1, &st2); if (SystemTimeToTzSpecificLocalTime((LPTIME_ZONE_INFORMATION) NULL, &st2, &st3) == 0) { DUK_D(DUK_DPRINT("SystemTimeToTzSpecificLocalTime() failed, return tzoffset 0")); return 0; @@ -140,7 +133,6 @@ FILETIME ft2; ULARGE_INTEGER tmp1; ULARGE_INTEGER tmp2; - BOOL ret; /* Do a similar computation to duk_bi_date_get_local_tzoffset_windows * but without accounting for daylight savings time. Use this on @@ -156,17 +148,9 @@ ft1.dwLowDateTime = tmp1.LowPart; ft1.dwHighDateTime = tmp1.HighPart; - ret = FileTimeToLocalFileTime((const FILETIME *) &ft1, &ft2); - if (!ret) { - DUK_D(DUK_DPRINT("FileTimeToLocalFileTime() failed, return tzoffset 0")); - return 0; - } + FileTimeToLocalFileTime((const FILETIME *) &ft1, &ft2); - ret = FileTimeToSystemTime((const FILETIME *) &ft2, &st2); - if (!ret) { - DUK_D(DUK_DPRINT("FileTimeToSystemTime() failed, return tzoffset 0")); - return 0; - } + FileTimeToSystemTime((const FILETIME *) &ft2, &st2); duk__convert_systime_to_ularge((const SYSTEMTIME *) &st2, &tmp2); return (duk_int_t) (((LONGLONG) tmp2.QuadPart - (LONGLONG) tmp1.QuadPart) / DUK_I64_CONSTANT(10000000)); /* seconds */ diff -Nru duktape-2.3.0/src-input/duk_bi_duktape.c duktape-2.2.0/src-input/duk_bi_duktape.c --- duktape-2.3.0/src-input/duk_bi_duktape.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_duktape.c 2017-09-23 01:06:08.000000000 +0000 @@ -3,7 +3,7 @@ * * Size optimization note: it might seem that vararg multipurpose functions * like fin(), enc(), and dec() are not very size optimal, but using a single - * user-visible ECMAScript function saves a lot of run-time footprint; each + * user-visible Ecmascript function saves a lot of run-time footprint; each * Function instance takes >100 bytes. Using a shared native helper and a * 'magic' value won't save much if there are multiple Function instances * anyway. diff -Nru duktape-2.3.0/src-input/duk_bi_encoding.c duktape-2.2.0/src-input/duk_bi_encoding.c --- duktape-2.3.0/src-input/duk_bi_encoding.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_encoding.c 2017-09-23 01:06:08.000000000 +0000 @@ -239,7 +239,7 @@ DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER | DUK_TYPE_MASK_OBJECT); - if (duk_get_prop_literal(thr, 1, "stream")) { + if (duk_get_prop_string(thr, 1, "stream")) { stream = duk_to_boolean(thr, -1); } } @@ -254,7 +254,6 @@ */ if (len >= (DUK_HBUFFER_MAX_BYTELEN / 3) - 3) { DUK_ERROR_TYPE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return 0;); } output = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, 3 + (3 * len)); /* used parts will be always manually written over */ @@ -332,7 +331,7 @@ fail_type: DUK_ERROR_TYPE(thr, DUK_STR_UTF8_DECODE_FAILED); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); } /* @@ -350,7 +349,7 @@ } DUK_INTERNAL duk_ret_t duk_bi_textencoder_prototype_encoding_getter(duk_hthread *thr) { - duk_push_literal(thr, "utf-8"); + duk_push_string(thr, "utf-8"); return 1; } @@ -372,7 +371,6 @@ len = (duk_size_t) DUK_HSTRING_GET_CHARLEN(h_input); if (len >= DUK_HBUFFER_MAX_BYTELEN / 3) { DUK_ERROR_TYPE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return 0;); } } @@ -392,14 +390,14 @@ DUK_ASSERT(duk_is_string(thr, 0)); /* True if len > 0. */ /* XXX: duk_decode_string() is used to process the input - * string. For standard ECMAScript strings, represented + * string. For standard Ecmascript strings, represented * internally as CESU-8, this is fine. However, behavior * beyond CESU-8 is not very strict: codepoints using an * extended form of UTF-8 are also accepted, and invalid * codepoint sequences (which are allowed in Duktape strings) * are not handled as well as they could (e.g. invalid * continuation bytes may mask following codepoints). - * This is how ECMAScript code would also see such strings. + * This is how Ecmascript code would also see such strings. * Maybe replace duk_decode_string() with an explicit strict * CESU-8 decoder here? */ @@ -427,7 +425,7 @@ /* Standard WHATWG output is a Uint8Array. Here the Uint8Array will * be backed by a dynamic buffer which differs from e.g. Uint8Arrays - * created as 'new Uint8Array(N)'. ECMAScript code won't see the + * created as 'new Uint8Array(N)'. Ecmascript code won't see the * difference but C code will. When bufferobjects are not supported, * returns a plain dynamic buffer. */ @@ -449,10 +447,10 @@ duk_to_string(thr, 0); } if (!duk_is_null_or_undefined(thr, 1)) { - if (duk_get_prop_literal(thr, 1, "fatal")) { + if (duk_get_prop_string(thr, 1, "fatal")) { fatal = duk_to_boolean(thr, -1); } - if (duk_get_prop_literal(thr, 1, "ignoreBOM")) { + if (duk_get_prop_string(thr, 1, "ignoreBOM")) { ignore_bom = duk_to_boolean(thr, -1); } } @@ -467,7 +465,7 @@ dec_ctx->ignore_bom = (duk_uint8_t) ignore_bom; duk__utf8_decode_init(dec_ctx); /* Initializes remaining fields. */ - duk_put_prop_literal(thr, -2, DUK_INTERNAL_SYMBOL("Context")); + duk_put_prop_string(thr, -2, DUK_INTERNAL_SYMBOL("Context")); return 0; } @@ -475,7 +473,7 @@ DUK_LOCAL duk__decode_context *duk__get_textdecoder_context(duk_hthread *thr) { duk__decode_context *dec_ctx; duk_push_this(thr); - duk_get_prop_literal(thr, -1, DUK_INTERNAL_SYMBOL("Context")); + duk_get_prop_string(thr, -1, DUK_INTERNAL_SYMBOL("Context")); dec_ctx = (duk__decode_context *) duk_require_buffer(thr, -1, NULL); DUK_ASSERT(dec_ctx != NULL); return dec_ctx; @@ -492,7 +490,7 @@ /* Encoding is now fixed, so _Context lookup is only needed to * validate the 'this' binding (TypeError if not TextDecoder-like). */ - duk_push_literal(thr, "utf-8"); + duk_push_string(thr, "utf-8"); break; case 1: duk_push_boolean(thr, dec_ctx->fatal); diff -Nru duktape-2.3.0/src-input/duk_bi_error.c duktape-2.2.0/src-input/duk_bi_error.c --- duktape-2.3.0/src-input/duk_bi_error.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_error.c 2017-09-23 01:06:08.000000000 +0000 @@ -54,7 +54,7 @@ duk_get_prop_stridx_short(thr, -1, DUK_STRIDX_NAME); if (duk_is_undefined(thr, -1)) { duk_pop(thr); - duk_push_literal(thr, "Error"); + duk_push_string(thr, "Error"); } else { duk_to_string(thr, -1); } @@ -84,7 +84,7 @@ duk_pop(thr); return 1; } - duk_push_literal(thr, ": "); + duk_push_string(thr, ": "); duk_insert(thr, -2); /* ... name ': ' message */ duk_concat(thr, 3); @@ -153,13 +153,13 @@ duk_get_prop_index(thr, idx_td, (duk_uarridx_t) i); duk_get_prop_index(thr, idx_td, (duk_uarridx_t) (i + 1)); d = duk_to_number_m1(thr); - pc = duk_double_to_int_t(DUK_FMOD(d, DUK_DOUBLE_2TO32)); - flags = duk_double_to_uint_t(DUK_FLOOR(d / DUK_DOUBLE_2TO32)); + pc = (duk_int_t) DUK_FMOD(d, DUK_DOUBLE_2TO32); + flags = (duk_uint_t) DUK_FLOOR(d / DUK_DOUBLE_2TO32); t = (duk_small_int_t) duk_get_type(thr, -2); if (t == DUK_TYPE_OBJECT || t == DUK_TYPE_LIGHTFUNC) { /* - * ECMAScript/native function call or lightfunc call + * Ecmascript/native function call or lightfunc call */ count_func++; diff -Nru duktape-2.3.0/src-input/duk_bi_function.c duktape-2.2.0/src-input/duk_bi_function.c --- duktape-2.3.0/src-input/duk_bi_function.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_function.c 2017-09-23 01:06:08.000000000 +0000 @@ -36,7 +36,7 @@ duk_push_hstring_empty(thr); } else { duk_insert(thr, 0); /* [ arg1 ... argN-1 body] -> [body arg1 ... argN-1] */ - duk_push_literal(thr, ","); + duk_push_string(thr, ","); duk_insert(thr, 1); duk_join(thr, nargs - 1); } @@ -48,11 +48,11 @@ /* XXX: this placeholder is not always correct, but use for now. * It will fail in corner cases; see test-dev-func-cons-args.js. */ - duk_push_literal(thr, "function("); + duk_push_string(thr, "function("); duk_dup_1(thr); - duk_push_literal(thr, "){"); + duk_push_string(thr, "){"); duk_dup_0(thr); - duk_push_literal(thr, "\n}"); /* Newline is important to handle trailing // comment. */ + duk_push_string(thr, "}"); duk_concat(thr, 5); /* [ body formals source ] */ @@ -70,7 +70,7 @@ comp_flags); /* Force .name to 'anonymous' (ES2015). */ - duk_push_literal(thr, "anonymous"); + duk_push_string(thr, "anonymous"); duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_NAME, DUK_PROPDESC_FLAGS_C); func = (duk_hcompfunc *) duk_known_hobject(thr, -1); @@ -282,7 +282,7 @@ if (DUK_HOBJECT_HAS_BOUNDFUNC(h_target)) { duk_hboundfunc *h_boundtarget; - h_boundtarget = (duk_hboundfunc *) (void *) h_target; + h_boundtarget = (duk_hboundfunc *) h_target; /* The final function should always be non-bound, unless * there's a bug in the internals. Assert for it. @@ -316,7 +316,7 @@ DUK_DCERROR_RANGE_INVALID_COUNT(thr); } tv_res = (duk_tval *) DUK_ALLOC_CHECKED(thr, ((duk_size_t) bound_nargs) * sizeof(duk_tval)); - DUK_ASSERT(tv_res != NULL || bound_nargs == 0); + DUK_ASSERT(tv_res != NULL); DUK_ASSERT(h_bound->args == NULL); DUK_ASSERT(h_bound->nargs == 0); h_bound->args = tv_res; @@ -356,7 +356,7 @@ duk_xdef_prop_stridx_thrower(thr, -1, DUK_STRIDX_LC_ARGUMENTS); /* Function name and fileName (non-standard). */ - duk_push_literal(thr, "bound "); /* ES2015 19.2.3.2. */ + duk_push_string(thr, "bound "); /* ES2015 19.2.3.2. */ duk_get_prop_stridx(thr, -3, DUK_STRIDX_NAME); if (!duk_is_string_notsymbol(thr, -1)) { /* ES2015 has requirement to check that .name of target is a string @@ -440,14 +440,3 @@ fail_type: DUK_DCERROR_TYPE_INVALID_ARGS(thr); } - -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL duk_ret_t duk_bi_function_prototype_hasinstance(duk_hthread *thr) { - /* This binding: RHS, stack index 0: LHS. */ - duk_bool_t ret; - - ret = duk_js_instanceof_ordinary(thr, DUK_GET_TVAL_POSIDX(thr, 0), DUK_GET_THIS_TVAL_PTR(thr)); - duk_push_boolean(thr, ret); - return 1; -} -#endif /* DUK_USE_SYMBOL_BUILTIN */ diff -Nru duktape-2.3.0/src-input/duk_bi_global.c duktape-2.2.0/src-input/duk_bi_global.c --- duktape-2.3.0/src-input/duk_bi_global.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_global.c 2017-09-23 01:06:08.000000000 +0000 @@ -200,7 +200,6 @@ uri_error: DUK_ERROR_URI(tfm_ctx->thr, DUK_STR_INVALID_INPUT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__transform_callback_decode_uri(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp) { @@ -339,7 +338,6 @@ uri_error: DUK_ERROR_URI(tfm_ctx->thr, DUK_STR_INVALID_INPUT); - DUK_WO_NORETURN(return;); } #if defined(DUK_USE_SECTION_B) @@ -380,7 +378,6 @@ esc_error: DUK_ERROR_TYPE(tfm_ctx->thr, DUK_STR_INVALID_INPUT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__transform_callback_unescape(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp) { @@ -413,7 +410,7 @@ * Eval needs to handle both a "direct eval" and an "indirect eval". * Direct eval handling needs access to the caller's activation so that its * lexical environment can be accessed. A direct eval is only possible from - * ECMAScript code; an indirect eval call is possible also from C code. + * Ecmascript code; an indirect eval call is possible also from C code. * When an indirect eval call is made from C code, there may not be a * calling activation at all which needs careful handling. */ @@ -452,7 +449,7 @@ #if defined(DUK_USE_DEBUGGER_SUPPORT) /* NOTE: level is used only by the debugger and should never be present - * for an ECMAScript eval(). + * for an Ecmascript eval(). */ DUK_ASSERT(level == -2); /* by default, use caller's environment */ if (duk_get_top(thr) >= 2 && duk_is_number(thr, 1)) { diff -Nru duktape-2.3.0/src-input/duk_bi_json.c duktape-2.2.0/src-input/duk_bi_json.c --- duktape-2.3.0/src-input/duk_bi_json.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_json.c 2017-09-23 01:06:08.000000000 +0000 @@ -214,7 +214,6 @@ */ DUK_ERROR_FMT1(js_ctx->thr, DUK_ERR_SYNTAX_ERROR, DUK_STR_FMT_INVALID_JSON, (long) (js_ctx->p - js_ctx->p_start)); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__dec_eat_white(duk_json_dec_ctx *js_ctx) { @@ -630,7 +629,7 @@ src_len = (duk_size_t) (p - js_ctx->p); buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, src_len); DUK_ASSERT(buf != NULL); - duk_memcpy((void *) buf, (const void *) js_ctx->p, src_len); + DUK_MEMCPY((void *) buf, (const void *) js_ctx->p, src_len); duk_hex_decode(thr, -1); js_ctx->p = p + 1; /* skip '|' */ @@ -721,7 +720,6 @@ DUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit); if (js_ctx->recursion_depth >= js_ctx->recursion_limit) { DUK_ERROR_RANGE(thr, DUK_STR_JSONDEC_RECLIMIT); - DUK_WO_NORETURN(return;); } js_ctx->recursion_depth++; } @@ -1298,9 +1296,9 @@ /* If XUTF-8 decoding fails, treat the offending byte as a codepoint directly * and go forward one byte. This is of course very lossy, but allows some kind * of output to be produced even for internal strings which don't conform to - * XUTF-8. All standard ECMAScript strings are always CESU-8, so this behavior - * does not violate the ECMAScript specification. The behavior is applied to - * all modes, including ECMAScript standard JSON. Because the current XUTF-8 + * XUTF-8. All standard Ecmascript strings are always CESU-8, so this behavior + * does not violate the Ecmascript specification. The behavior is applied to + * all modes, including Ecmascript standard JSON. Because the current XUTF-8 * decoding is not very strict, this behavior only really affects initial bytes * and truncated codepoints. * @@ -1437,7 +1435,7 @@ /* Unlike in duk_hex_encode() 'dst' is not necessarily aligned by 2. * For platforms where unaligned accesses are not allowed, shift 'dst' - * ahead by 1 byte to get alignment and then duk_memmove() the result + * ahead by 1 byte to get alignment and then DUK_MEMMOVE() the result * in place. The faster encoding loop makes up the difference. * There's always space for one extra byte because a terminator always * follows the hex data and that's been accounted for by the caller. @@ -1470,7 +1468,7 @@ #if !defined(DUK_USE_UNALIGNED_ACCESSES_POSSIBLE) if (shift_dst) { q--; - duk_memmove((void *) dst, (const void *) (dst + 1), 2 * len_safe); + DUK_MEMMOVE((void *) dst, (const void *) (dst + 1), 2 * len_safe); DUK_ASSERT(dst + 2 * len_safe == q); } #endif @@ -1546,7 +1544,7 @@ #if defined(DUK_USE_JC) { DUK_ASSERT(js_ctx->flag_ext_compatible); - duk_memcpy((void *) q, (const void *) "{\"_buf\":\"", 9); /* len: 9 */ + DUK_MEMCPY((void *) q, (const void *) "{\"_buf\":\"", 9); /* len: 9 */ q += 9; q = duk__enc_buffer_data_hex(buf_data, buf_len, q); *q++ = DUK_ASC_DOUBLEQUOTE; @@ -1619,7 +1617,7 @@ DUK_ASSERT(js_ctx->flag_ext_custom || js_ctx->flag_ext_compatible); /* caller checks */ DUK_ASSERT(js_ctx->flag_ext_custom_or_compatible); - duk_memzero(buf, sizeof(buf)); + DUK_MEMZERO(buf, sizeof(buf)); /* The #if defined() clutter here needs to handle the three * cases: (1) JX+JC, (2) JX only, (3) JC only. @@ -1709,21 +1707,21 @@ p = DUK_BW_ENSURE_GETPTR(js_ctx->thr, &js_ctx->bw, need_bytes); p_start = p; - duk_memcpy((void *) p, (const void *) gap_data, (size_t) gap_len); + DUK_MEMCPY((void *) p, (const void *) gap_data, (size_t) gap_len); p += gap_len; avail_bytes = gap_len; DUK_ASSERT(need_bytes >= gap_len); need_bytes -= gap_len; while (need_bytes >= avail_bytes) { - duk_memcpy((void *) p, (const void *) p_start, (size_t) avail_bytes); + DUK_MEMCPY((void *) p, (const void *) p_start, (size_t) avail_bytes); p += avail_bytes; need_bytes -= avail_bytes; avail_bytes <<= 1; } DUK_ASSERT(need_bytes < avail_bytes); /* need_bytes may be zero */ - duk_memcpy((void *) p, (const void *) p_start, (size_t) need_bytes); + DUK_MEMCPY((void *) p, (const void *) p_start, (size_t) need_bytes); p += need_bytes; /*avail_bytes += need_bytes*/ @@ -1755,7 +1753,6 @@ if (DUK_UNLIKELY(js_ctx->visiting[i] == h_target)) { DUK_DD(DUK_DDPRINT("slow path loop detect")); DUK_ERROR_TYPE(thr, DUK_STR_CYCLIC_INPUT); - DUK_WO_NORETURN(return;); } } if (js_ctx->recursion_depth < DUK_JSON_ENC_LOOPARRAY) { @@ -1765,7 +1762,6 @@ duk_dup_top(thr); /* -> [ ... voidp voidp ] */ if (duk_has_prop(thr, js_ctx->idx_loop)) { DUK_ERROR_TYPE(thr, DUK_STR_CYCLIC_INPUT); - DUK_WO_NORETURN(return;); } duk_push_true(thr); /* -> [ ... voidp true ] */ duk_put_prop(thr, js_ctx->idx_loop); /* -> [ ... ] */ @@ -1777,7 +1773,6 @@ DUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit); if (js_ctx->recursion_depth >= js_ctx->recursion_limit) { DUK_ERROR_RANGE(thr, DUK_STR_JSONENC_RECLIMIT); - DUK_WO_NORETURN(return;); } js_ctx->recursion_depth++; @@ -2375,14 +2370,12 @@ if (js_ctx->recursion_depth >= js_ctx->recursion_limit) { DUK_DD(DUK_DDPRINT("fast path recursion limit")); DUK_ERROR_RANGE(js_ctx->thr, DUK_STR_JSONDEC_RECLIMIT); - DUK_WO_NORETURN(return 0;); } for (i = 0, n = (duk_uint_fast32_t) js_ctx->recursion_depth; i < n; i++) { if (DUK_UNLIKELY(js_ctx->visiting[i] == obj)) { DUK_DD(DUK_DDPRINT("fast path loop detect")); DUK_ERROR_TYPE(js_ctx->thr, DUK_STR_CYCLIC_INPUT); - DUK_WO_NORETURN(return 0;); } } @@ -2763,7 +2756,7 @@ /* Error message doesn't matter: the error is ignored anyway. */ DUK_DD(DUK_DDPRINT("aborting fast path")); DUK_ERROR_INTERNAL(js_ctx->thr); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } DUK_LOCAL duk_ret_t duk__json_stringify_fast(duk_hthread *thr, void *udata) { @@ -2812,7 +2805,7 @@ (unsigned long) flags, (long) duk_get_top(thr))); - duk_memzero(&js_ctx_alloc, sizeof(js_ctx_alloc)); + DUK_MEMZERO(&js_ctx_alloc, sizeof(js_ctx_alloc)); js_ctx->thr = thr; #if defined(DUK_USE_EXPLICIT_NULL_INIT) /* nothing now */ @@ -2922,7 +2915,7 @@ * Context init */ - duk_memzero(&js_ctx_alloc, sizeof(js_ctx_alloc)); + DUK_MEMZERO(&js_ctx_alloc, sizeof(js_ctx_alloc)); js_ctx->thr = thr; #if defined(DUK_USE_EXPLICIT_NULL_INIT) js_ctx->h_replacer = NULL; diff -Nru duktape-2.3.0/src-input/duk_bi_math.c duktape-2.2.0/src-input/duk_bi_math.c --- duktape-2.3.0/src-input/duk_bi_math.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_math.c 2017-09-23 01:06:08.000000000 +0000 @@ -51,7 +51,7 @@ DUK_LOCAL double duk__fmin_fixed(double x, double y) { /* fmin() with args -0 and +0 is not guaranteed to return - * -0 as ECMAScript requires. + * -0 as Ecmascript requires. */ if (x == 0 && y == 0) { duk_double_union du1, du2; @@ -78,7 +78,7 @@ DUK_LOCAL double duk__fmax_fixed(double x, double y) { /* fmax() with args -0 and +0 is not guaranteed to return - * +0 as ECMAScript requires. + * +0 as Ecmascript requires. */ if (x == 0 && y == 0) { if (DUK_SIGNBIT(x) == 0 || DUK_SIGNBIT(y) == 0) { diff -Nru duktape-2.3.0/src-input/duk_bi_number.c duktape-2.2.0/src-input/duk_bi_number.c --- duktape-2.3.0/src-input/duk_bi_number.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_number.c 2017-09-23 01:06:08.000000000 +0000 @@ -23,7 +23,6 @@ (DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_NUMBER)) { DUK_DDD(DUK_DDDPRINT("unacceptable this value: %!T", (duk_tval *) duk_get_tval(thr, -1))); DUK_ERROR_TYPE(thr, "number expected"); - DUK_WO_NORETURN(return 0.0;); } duk_get_prop_stridx_short(thr, -1, DUK_STRIDX_INT_VALUE); DUK_ASSERT(duk_is_number(thr, -1)); @@ -130,11 +129,8 @@ duk_small_int_t c; duk_small_uint_t n2s_flags; - /* In ES5.1 frac_digits is coerced first; in ES2015 the 'this number - * value' check is done first. - */ - d = duk__push_this_number_plain(thr); frac_digits = (duk_small_int_t) duk_to_int_check_range(thr, 0, 0, 20); + d = duk__push_this_number_plain(thr); c = (duk_small_int_t) DUK_FPCLASSIFY(d); if (c == DUK_FP_NAN || c == DUK_FP_INFINITE) { @@ -241,40 +237,4 @@ return 1; } -/* - * ES2015 isFinite() etc - */ - -#if defined(DUK_USE_ES6) -DUK_INTERNAL duk_ret_t duk_bi_number_check_shared(duk_hthread *thr) { - duk_int_t magic; - duk_bool_t ret = 0; - - if (duk_is_number(thr, 0)) { - duk_double_t d; - - magic = duk_get_current_magic(thr); - d = duk_get_number(thr, 0); - - switch (magic) { - case 0: /* isFinite() */ - ret = duk_double_is_finite(d); - break; - case 1: /* isInteger() */ - ret = duk_double_is_integer(d); - break; - case 2: /* isNaN() */ - ret = duk_double_is_nan(d); - break; - default: /* isSafeInteger() */ - DUK_ASSERT(magic == 3); - ret = duk_double_is_safe_integer(d); - } - } - - duk_push_boolean(thr, ret); - return 1; -} -#endif /* DUK_USE_ES6 */ - #endif /* DUK_USE_NUMBER_BUILTIN */ diff -Nru duktape-2.3.0/src-input/duk_bi_object.c duktape-2.2.0/src-input/duk_bi_object.c --- duktape-2.3.0/src-input/duk_bi_object.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_object.c 2017-09-23 01:06:08.000000000 +0000 @@ -7,9 +7,12 @@ /* Needed even when Object built-in disabled. */ DUK_INTERNAL duk_ret_t duk_bi_object_prototype_to_string(duk_hthread *thr) { duk_tval *tv; - tv = DUK_HTHREAD_THIS_PTR(thr); - duk_push_class_string_tval(thr, tv, 0 /*avoid_side_effects*/); + /* XXX: This is not entirely correct anymore; in ES2015 the + * default lookup should use @@toStringTag to come up with + * e.g. [object Symbol]. + */ + duk_push_class_string_tval(thr, tv); return 1; } @@ -514,7 +517,7 @@ DUK_ASSERT(duk_get_hobject(thr, 2) != NULL); /* - * Validate and convert argument property descriptor (an ECMAScript + * Validate and convert argument property descriptor (an Ecmascript * object) into a set of defprop_flags and possibly property value, * getter, and/or setter values on the value stack. * @@ -792,7 +795,6 @@ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } duk_get_prototype(thr, -1); diff -Nru duktape-2.3.0/src-input/duk_bi_promise.c duktape-2.2.0/src-input/duk_bi_promise.c --- duktape-2.3.0/src-input/duk_bi_promise.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_promise.c 2017-09-23 01:06:08.000000000 +0000 @@ -8,37 +8,37 @@ DUK_INTERNAL duk_ret_t duk_bi_promise_constructor(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_all(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_race(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_reject(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_resolve(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_catch(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_then(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } #endif /* DUK_USE_PROMISE_BUILTIN */ diff -Nru duktape-2.3.0/src-input/duk_bi_proxy.c duktape-2.2.0/src-input/duk_bi_proxy.c --- duktape-2.3.0/src-input/duk_bi_proxy.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_proxy.c 2017-09-23 01:06:08.000000000 +0000 @@ -28,7 +28,6 @@ h = duk_get_hstring(thr, -1); if (h == NULL) { DUK_ERROR_TYPE_INVALID_TRAP_RESULT(thr); - DUK_WO_NORETURN(return;); } if (!(flags & DUK_ENUM_INCLUDE_NONENUMERABLE)) { diff -Nru duktape-2.3.0/src-input/duk_bi_reflect.c duktape-2.2.0/src-input/duk_bi_reflect.c --- duktape-2.3.0/src-input/duk_bi_reflect.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_reflect.c 2017-09-23 01:06:08.000000000 +0000 @@ -40,7 +40,6 @@ if (nargs >= 3 && !duk_strict_equals(thr, 0, 2)) { /* XXX: [[Get]] receiver currently unsupported */ DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } /* [ target key receiver? ...? ] */ @@ -84,7 +83,6 @@ if (nargs >= 4 && !duk_strict_equals(thr, 0, 3)) { /* XXX: [[Set]] receiver currently unsupported */ DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } /* [ target key value receiver? ...? ] */ diff -Nru duktape-2.3.0/src-input/duk_bi_regexp.c duktape-2.2.0/src-input/duk_bi_regexp.c --- duktape-2.3.0/src-input/duk_bi_regexp.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_regexp.c 2017-09-23 01:06:08.000000000 +0000 @@ -119,7 +119,7 @@ /* This must be generic in ES2015 and later. */ DUK_ASSERT_TOP(thr, 0); duk_push_this(thr); - duk_push_literal(thr, "/"); + duk_push_string(thr, "/"); duk_get_prop_stridx(thr, 0, DUK_STRIDX_SOURCE); duk_dup_m2(thr); /* another "/" */ duk_get_prop_stridx(thr, 0, DUK_STRIDX_FLAGS); @@ -183,7 +183,7 @@ if (magic != 16 /* .source */) { return 0; } - duk_push_literal(thr, "(?:)"); /* .source handled by switch-case */ + duk_push_string(thr, "(?:)"); /* .source handled by switch-case */ re_flags = 0; } else { DUK_DCERROR_TYPE_INVALID_ARGS(thr); diff -Nru duktape-2.3.0/src-input/duk_bi_string.c duktape-2.2.0/src-input/duk_bi_string.c --- duktape-2.3.0/src-input/duk_bi_string.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_string.c 2017-09-23 01:06:08.000000000 +0000 @@ -28,7 +28,6 @@ if (duk_get_class_number(thr, idx) == DUK_HOBJECT_CLASS_REGEXP) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } h = duk_to_hstring(thr, idx); DUK_ASSERT(h != NULL); @@ -75,14 +74,14 @@ while (p <= p_end && p >= p_start) { t = *p; - /* For ECMAScript strings, this check can only match for + /* For Ecmascript strings, this check can only match for * initial UTF-8 bytes (not continuation bytes). For other * strings all bets are off. */ if ((t == firstbyte) && ((duk_size_t) (p_end - p) >= (duk_size_t) q_blen)) { - DUK_ASSERT(q_blen > 0); - if (duk_memcmp((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { + DUK_ASSERT(q_blen > 0); /* no issues with memcmp() zero size, even if broken */ + if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { return cpos; } } @@ -264,37 +263,13 @@ */ DUK_INTERNAL duk_ret_t duk_bi_string_prototype_char_at(duk_hthread *thr) { - duk_hstring *h; duk_int_t pos; /* XXX: faster implementation */ - h = duk_push_this_coercible_to_string(thr); - DUK_ASSERT(h != NULL); - + (void) duk_push_this_coercible_to_string(thr); pos = duk_to_int(thr, 0); - - if (sizeof(duk_size_t) >= sizeof(duk_uint_t)) { - /* Cast to duk_size_t works in this case: - * - If pos < 0, (duk_size_t) pos will always be - * >= max_charlen, and result will be the empty string - * (see duk_substring()). - * - If pos >= 0, pos + 1 cannot wrap. - */ - DUK_ASSERT((duk_size_t) DUK_INT_MIN >= DUK_HSTRING_MAX_BYTELEN); - DUK_ASSERT((duk_size_t) DUK_INT_MAX + 1U > (duk_size_t) DUK_INT_MAX); - duk_substring(thr, -1, (duk_size_t) pos, (duk_size_t) pos + 1U); - } else { - /* If size_t is smaller than int, explicit bounds checks - * are needed because an int may wrap multiple times. - */ - if (DUK_UNLIKELY(pos < 0 || (duk_uint_t) pos >= (duk_uint_t) DUK_HSTRING_GET_CHARLEN(h))) { - duk_push_hstring_empty(thr); - } else { - duk_substring(thr, -1, (duk_size_t) pos, (duk_size_t) pos + 1U); - } - } - + duk_substring(thr, -1, (duk_size_t) pos, (duk_size_t) (pos + 1)); return 1; } @@ -684,7 +659,7 @@ while (p <= p_end) { DUK_ASSERT(p + q_blen <= DUK_HSTRING_GET_DATA(h_input) + DUK_HSTRING_GET_BYTELEN(h_input)); - if (duk_memcmp((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { + if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { duk_dup_0(thr); h_match = duk_known_hstring(thr, -1); #if defined(DUK_USE_REGEXP_SUPPORT) @@ -1065,7 +1040,7 @@ while (p <= p_end) { DUK_ASSERT(p + q_blen <= DUK_HSTRING_GET_DATA(h_input) + DUK_HSTRING_GET_BYTELEN(h_input)); DUK_ASSERT(q_blen > 0); /* no issues with empty memcmp() */ - if (duk_memcmp((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { + if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { /* never an empty match, so step 13.c.iii can't be triggered */ goto found; } @@ -1378,14 +1353,12 @@ /* Temporary fixed buffer, later converted to string. */ buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, result_len); - DUK_ASSERT(buf != NULL); src = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input); - DUK_ASSERT(src != NULL); #if defined(DUK_USE_PREFER_SIZE) p = buf; while (count-- > 0) { - duk_memcpy((void *) p, (const void *) src, input_blen); /* copy size may be zero, but pointers are valid */ + DUK_MEMCPY((void *) p, (const void *) src, input_blen); /* copy size may be zero */ p += input_blen; } #else /* DUK_USE_PREFER_SIZE */ @@ -1402,12 +1375,12 @@ (long) result_len)); if (remain <= copy_size) { /* If result_len is zero, this case is taken and does - * a zero size copy (with valid pointers). + * a zero size copy. */ - duk_memcpy((void *) p, (const void *) src, remain); + DUK_MEMCPY((void *) p, (const void *) src, remain); break; } else { - duk_memcpy((void *) p, (const void *) src, copy_size); + DUK_MEMCPY((void *) p, (const void *) src, copy_size); p += copy_size; } @@ -1462,7 +1435,8 @@ h2_len = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h2); prefix_len = (h1_len <= h2_len ? h1_len : h2_len); - rc = (duk_small_int_t) duk_memcmp((const void *) DUK_HSTRING_GET_DATA(h1), + /* Zero size compare not an issue with DUK_MEMCMP. */ + rc = (duk_small_int_t) DUK_MEMCMP((const void *) DUK_HSTRING_GET_DATA(h1), (const void *) DUK_HSTRING_GET_DATA(h2), (size_t) prefix_len); @@ -1512,7 +1486,7 @@ if (duk_is_undefined(thr, 1)) { if (magic) { - p_cmp_start = p_cmp_start + DUK_HSTRING_GET_BYTELEN(h) - blen_search; + p_cmp_start += DUK_HSTRING_GET_BYTELEN(h) - blen_search; } else { /* p_cmp_start already OK */ } @@ -1543,7 +1517,7 @@ result = 0; if (p_cmp_start >= DUK_HSTRING_GET_DATA(h) && (duk_size_t) (p_cmp_start - (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h)) + blen_search <= DUK_HSTRING_GET_BYTELEN(h)) { - if (duk_memcmp((const void *) p_cmp_start, + if (DUK_MEMCMP((const void *) p_cmp_start, (const void *) DUK_HSTRING_GET_DATA(h_search), (size_t) blen_search) == 0) { result = 1; diff -Nru duktape-2.3.0/src-input/duk_bi_symbol.c duktape-2.2.0/src-input/duk_bi_symbol.c --- duktape-2.3.0/src-input/duk_bi_symbol.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_symbol.c 2017-09-23 01:06:08.000000000 +0000 @@ -37,10 +37,9 @@ * +1 0xff after unique suffix for symbols with undefined description */ buf = (duk_uint8_t *) duk_push_fixed_buffer(thr, 1 + len + 1 + 17 + 1); - DUK_ASSERT(buf != NULL); p = buf + 1; DUK_ASSERT(desc != NULL || len == 0); /* may be NULL if len is 0 */ - duk_memcpy_unsafe((void *) p, (const void *) desc, len); + DUK_MEMCPY((void *) p, (const void *) desc, len); p += len; if (magic == 0) { /* Symbol(): create unique symbol. Use two 32-bit values diff -Nru duktape-2.3.0/src-input/duk_bi_thread.c duktape-2.2.0/src-input/duk_bi_thread.c --- duktape-2.3.0/src-input/duk_bi_thread.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_bi_thread.c 2017-09-23 01:06:08.000000000 +0000 @@ -40,7 +40,7 @@ * * The thread must be in resumable state, either (a) new thread which hasn't * yet started, or (b) a thread which has previously yielded. This method - * must be called from an ECMAScript function. + * must be called from an Ecmascript function. * * Args: * - thread @@ -66,9 +66,8 @@ DUK_ASSERT(thr->heap->curr_thread == thr); thr_resume = duk_require_hthread(thr, 0); - DUK_ASSERT(duk_get_top(thr) == 3); - is_error = (duk_small_uint_t) duk_to_boolean_top_pop(thr); - DUK_ASSERT(duk_get_top(thr) == 2); + is_error = (duk_small_uint_t) duk_to_boolean(thr, 2); + duk_set_top(thr, 2); /* [ thread value ] */ @@ -88,7 +87,7 @@ caller_func = DUK_ACT_GET_FUNC(thr->callstack_curr->parent); if (!DUK_HOBJECT_IS_COMPFUNC(caller_func)) { - DUK_DD(DUK_DDPRINT("resume state invalid: caller must be ECMAScript code")); + DUK_DD(DUK_DDPRINT("resume state invalid: caller must be Ecmascript code")); goto state_error; } @@ -116,7 +115,7 @@ DUK_ASSERT(thr_resume->state == DUK_HTHREAD_STATE_INACTIVE); - /* The initial function must be an ECMAScript function (but + /* The initial function must be an Ecmascript function (but * can be bound). We must make sure of that before we longjmp * because an error in the RESUME handler call processing will * not be handled very cleanly. @@ -195,7 +194,7 @@ * The thread must be in yieldable state: it must have a resumer, and there * must not be any yield-preventing calls (native calls and constructor calls, * currently) in the thread's call stack (otherwise a resume would not be - * possible later). This method must be called from an ECMAScript function. + * possible later). This method must be called from an Ecmascript function. * * Args: * - value @@ -216,9 +215,8 @@ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); DUK_ASSERT(thr->heap->curr_thread == thr); - DUK_ASSERT(duk_get_top(thr) == 2); - is_error = (duk_small_uint_t) duk_to_boolean_top_pop(thr); - DUK_ASSERT(duk_get_top(thr) == 1); + is_error = (duk_small_uint_t) duk_to_boolean(thr, 1); + duk_set_top(thr, 1); /* [ value ] */ @@ -244,7 +242,7 @@ caller_func = DUK_ACT_GET_FUNC(thr->callstack_curr->parent); if (!DUK_HOBJECT_IS_COMPFUNC(caller_func)) { - DUK_DD(DUK_DDPRINT("yield state invalid: caller must be ECMAScript code")); + DUK_DD(DUK_DDPRINT("yield state invalid: caller must be Ecmascript code")); goto state_error; } diff -Nru duktape-2.3.0/src-input/duk_debug_fixedbuffer.c duktape-2.2.0/src-input/duk_debug_fixedbuffer.c --- duktape-2.3.0/src-input/duk_debug_fixedbuffer.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_debug_fixedbuffer.c 2017-09-23 01:06:08.000000000 +0000 @@ -18,7 +18,7 @@ } else { copylen = length; } - duk_memcpy_unsafe(fb->buffer + fb->offset, buffer, copylen); + DUK_MEMCPY(fb->buffer + fb->offset, buffer, copylen); fb->offset += copylen; } diff -Nru duktape-2.3.0/src-input/duk_debugger.c duktape-2.2.0/src-input/duk_debugger.c --- duktape-2.3.0/src-input/duk_debugger.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_debugger.c 2017-09-23 01:06:08.000000000 +0000 @@ -309,7 +309,6 @@ DUK_ASSERT(thr != NULL); heap = thr->heap; DUK_ASSERT(heap != NULL); - DUK_ASSERT(data != NULL); if (heap->dbg_read_cb == NULL) { DUK_D(DUK_DPRINT("attempt to read %ld bytes in detached state, return zero data", (long) length)); @@ -347,7 +346,7 @@ return; fail: - duk_memzero((void *) data, (size_t) length); + DUK_MEMZERO((void *) data, (size_t) length); } DUK_INTERNAL duk_uint8_t duk_debug_read_byte(duk_hthread *thr) { @@ -960,7 +959,7 @@ (unsigned int) du2.uc[4], (unsigned int) du2.uc[5], (unsigned int) du2.uc[6], (unsigned int) du2.uc[7])); - if (duk_memcmp((const void *) du1.uc, (const void *) du2.uc, sizeof(du1.uc)) == 0) { + if (DUK_MEMCMP((const void *) du1.uc, (const void *) du2.uc, sizeof(du1.uc)) == 0) { duk_debug_write_int(thr, i32); } else { DUK_DBLUNION_DOUBLE_HTON(&du1); @@ -1069,9 +1068,9 @@ duk_debug_write_int(thr, 0); } else { duk_push_tval(thr, &act->tv_func); - duk_get_prop_literal(thr, -1, "fileName"); + duk_get_prop_string(thr, -1, "fileName"); duk__debug_write_hstring_safe_top(thr); - duk_get_prop_literal(thr, -2, "name"); + duk_get_prop_string(thr, -2, "name"); duk__debug_write_hstring_safe_top(thr); duk_pop_3(thr); /* Report next pc/line to be executed. */ @@ -1116,7 +1115,7 @@ act = thr->callstack_curr; if (act != NULL) { duk_push_tval(thr, &act->tv_func); - duk_get_prop_literal(thr, -1, "fileName"); + duk_get_prop_string(thr, -1, "fileName"); duk__debug_write_hstring_safe_top(thr); pc = (duk_uint32_t) duk_hthread_get_act_prev_pc(thr, act); duk_debug_write_uint(thr, (duk_uint32_t) duk_hobject_pc2line_query(thr, -2, pc)); @@ -1593,7 +1592,7 @@ fun = DUK_ACT_GET_FUNC(act); if (fun != NULL && DUK_HOBJECT_IS_COMPFUNC(fun)) { /* Direct eval requires that there's a current - * activation and it is an ECMAScript function. + * activation and it is an Ecmascript function. * When Eval is executed from e.g. cooperate API * call we'll need to do an indirect eval instead. */ @@ -2259,7 +2258,7 @@ if (DUK_HOBJECT_IS_BOUNDFUNC(h_obj)) { duk_hboundfunc *h_bfun; - h_bfun = (duk_hboundfunc *) (void *) h_obj; + h_bfun = (duk_hboundfunc *) h_obj; duk__debug_getinfo_flags_key(thr, "target"); duk_debug_write_tval(thr, &h_bfun->target); @@ -2736,7 +2735,7 @@ fun = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act); /* Short circuit if is safe: if act->curr_pc != NULL, 'fun' is - * guaranteed to be a non-NULL ECMAScript function. + * guaranteed to be a non-NULL Ecmascript function. */ DUK_ASSERT(act->curr_pc == NULL || (fun != NULL && DUK_HOBJECT_IS_COMPFUNC((duk_hobject *) fun))); @@ -2832,10 +2831,11 @@ DUK_ASSERT(h != NULL); move_size = sizeof(duk_breakpoint) * (heap->dbg_breakpoint_count - breakpoint_index - 1); - duk_memmove((void *) b, - (const void *) (b + 1), - (size_t) move_size); - + if (move_size > 0) { + DUK_MEMMOVE((void *) b, + (const void *) (b + 1), + (size_t) move_size); + } heap->dbg_breakpoint_count--; heap->dbg_breakpoints_active[0] = (duk_breakpoint *) NULL; diff -Nru duktape-2.3.0/src-input/duk_debug_macros.c duktape-2.2.0/src-input/duk_debug_macros.c --- duktape-2.3.0/src-input/duk_debug_macros.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_debug_macros.c 2017-09-23 01:06:08.000000000 +0000 @@ -33,7 +33,7 @@ va_start(ap, fmt); - duk_memzero((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); + DUK_MEMZERO((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); duk_debug_vsnprintf(buf, DUK__DEBUG_BUFSIZE - 1, fmt, ap); arg_level = (long) level; @@ -64,7 +64,7 @@ va_start(ap, fmt); - duk_memzero((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); + DUK_MEMZERO((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); duk_debug_vsnprintf(buf, DUK__DEBUG_BUFSIZE - 1, fmt, ap); arg_level = (long) duk_debug_level_stash; diff -Nru duktape-2.3.0/src-input/duk_debug_vsnprintf.c duktape-2.2.0/src-input/duk_debug_vsnprintf.c --- duktape-2.3.0/src-input/duk_debug_vsnprintf.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_debug_vsnprintf.c 2017-09-23 01:06:08.000000000 +0000 @@ -35,7 +35,7 @@ * (excluding the null terminator). If retval == buffer size, * output was truncated (except for corner cases). * - * * Output format is intentionally different from ECMAScript + * * Output format is intentionally different from Ecmascript * formatting requirements, as formatting here serves debugging * of internals. * @@ -821,7 +821,7 @@ const char *p_end = p + DUK_STRLEN(format); duk_int_t retval; - duk_memzero(&fb, sizeof(fb)); + DUK_MEMZERO(&fb, sizeof(fb)); fb.buffer = (duk_uint8_t *) str; fb.length = size; fb.offset = 0; @@ -846,7 +846,7 @@ * understand. See man 3 printf. */ - duk_memzero(&st, sizeof(st)); + DUK_MEMZERO(&st, sizeof(st)); st.fb = &fb; st.depth = 0; st.depth_limit = 1; @@ -913,8 +913,8 @@ /* format is too large, abort */ goto format_error; } - duk_memzero(fmtbuf, sizeof(fmtbuf)); - duk_memcpy(fmtbuf, p_begfmt, fmtlen); + DUK_MEMZERO(fmtbuf, sizeof(fmtbuf)); + DUK_MEMCPY(fmtbuf, p_begfmt, fmtlen); /* assume exactly 1 arg, which is why '*' is forbidden; arg size still * depends on type though. @@ -1019,8 +1019,7 @@ duk_uint8_t *p = (duk_uint8_t *) buf; duk_uint8_t *p_end = (duk_uint8_t *) (buf + buf_size - 1); - DUK_ASSERT(buf != NULL); - duk_memzero(buf, buf_size); + DUK_MEMZERO(buf, buf_size); for (i = 0; i < fptr_size; i++) { duk_int_t left = (duk_int_t) (p_end - p); diff -Nru duktape-2.3.0/src-input/duk_error_augment.c duktape-2.2.0/src-input/duk_error_augment.c --- duktape-2.3.0/src-input/duk_error_augment.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_error_augment.c 2017-09-23 01:06:08.000000000 +0000 @@ -14,7 +14,7 @@ * * Error augmentation may throw an internal error (e.g. alloc error). * - * ECMAScript allows throwing any values, so all values cannot be + * Ecmascript allows throwing any values, so all values cannot be * augmented. Currently, the built-in augmentation at error creation * only augments error values which are Error instances (= have the * built-in Error.prototype in their prototype chain) and are also @@ -354,6 +354,7 @@ DUK_UNREF(pc); DUK_ASSERT_DISABLE(pc >= 0); /* unsigned */ DUK_ASSERT((duk_double_t) pc < DUK_DOUBLE_2TO32); /* assume PC is at most 32 bits and non-negative */ + act = NULL; /* invalidated by pushes, so get out of the way */ duk_push_hobject(thr, func); diff -Nru duktape-2.3.0/src-input/duk_error.h duktape-2.2.0/src-input/duk_error.h --- duktape-2.3.0/src-input/duk_error.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_error.h 2017-09-23 01:06:08.000000000 +0000 @@ -20,8 +20,8 @@ * Error codes: defined in duktape.h * * Error codes are used as a shorthand to throw exceptions from inside - * the implementation. The appropriate ECMAScript object is constructed - * based on the code. ECMAScript code throws objects directly. The error + * the implementation. The appropriate Ecmascript object is constructed + * based on the code. Ecmascript code throws objects directly. The error * codes are defined in the public API header because they are also used * by calling code. */ @@ -423,7 +423,7 @@ #if defined(DUK_USE_ASSERTIONS) #define DUK_ASSERT_SET_GARBAGE(ptr,size) do { \ - duk_memset_unsafe((void *) (ptr), 0x5a, size); \ + DUK_MEMSET((void *) (ptr), 0x5a, size); \ } while (0) #else #define DUK_ASSERT_SET_GARBAGE(ptr,size) do {} while (0) diff -Nru duktape-2.3.0/src-input/duk_error_longjmp.c duktape-2.2.0/src-input/duk_error_longjmp.c --- duktape-2.3.0/src-input/duk_error_longjmp.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_error_longjmp.c 2017-09-23 01:06:08.000000000 +0000 @@ -6,15 +6,12 @@ #include "duk_internal.h" #if defined(DUK_USE_PREFER_SIZE) -DUK_NORETURN(DUK_LOCAL_DECL void duk__uncaught_minimal(duk_hthread *thr)); DUK_LOCAL void duk__uncaught_minimal(duk_hthread *thr) { (void) duk_fatal(thr, "uncaught error"); - DUK_WO_NORETURN(return;); } #endif #if 0 -DUK_NORETURN(DUK_LOCAL_DECL void duk__uncaught_readable(duk_hthread *thr)); DUK_LOCAL void duk__uncaught_readable(duk_hthread *thr) { const char *summary; char buf[DUK_USE_FATAL_MAXLEN]; @@ -23,12 +20,10 @@ DUK_SNPRINTF(buf, sizeof(buf), "uncaught: %s", summary); buf[sizeof(buf) - 1] = (char) 0; (void) duk_fatal(thr, (const char *) buf); - DUK_WO_NORETURN(return;); } #endif #if !defined(DUK_USE_PREFER_SIZE) -DUK_NORETURN(DUK_LOCAL_DECL void duk__uncaught_error_aware(duk_hthread *thr)); DUK_LOCAL void duk__uncaught_error_aware(duk_hthread *thr) { const char *summary; char buf[DUK_USE_FATAL_MAXLEN]; @@ -38,7 +33,6 @@ DUK_SNPRINTF(buf, sizeof(buf), "uncaught: %s", summary); buf[sizeof(buf) - 1] = (char) 0; (void) duk_fatal(thr, (const char *) buf); - DUK_WO_NORETURN(return;); } #endif @@ -76,9 +70,14 @@ DUK_DD(DUK_DDPRINT("about to longjmp, pf_prevent_count=%ld", (long) thr->heap->pf_prevent_count)); +#if !defined(DUK_USE_CPP_EXCEPTIONS) /* If we don't have a jmpbuf_ptr, there is little we can do except * cause a fatal error. The caller's expectation is that we never * return. + * + * With C++ exceptions we now just propagate an uncaught error + * instead of invoking the fatal error handler. Because there's + * a dummy jmpbuf for C++ exceptions now, this could be changed. */ if (!thr->heap->lj.jmpbuf_ptr) { DUK_D(DUK_DPRINT("uncaught error: type=%d iserror=%d value1=%!T value2=%!T", @@ -92,12 +91,16 @@ #endif DUK_UNREACHABLE(); } +#endif /* DUK_USE_CPP_EXCEPTIONS */ #if defined(DUK_USE_CPP_EXCEPTIONS) - throw duk_internal_exception(); /* dummy */ -#else + { + duk_internal_exception exc; /* dummy */ + throw exc; + } +#else /* DUK_USE_CPP_EXCEPTIONS */ DUK_LONGJMP(thr->heap->lj.jmpbuf_ptr->jb); -#endif +#endif /* DUK_USE_CPP_EXCEPTIONS */ DUK_UNREACHABLE(); } diff -Nru duktape-2.3.0/src-input/duk_error_macros.c duktape-2.2.0/src-input/duk_error_macros.c --- duktape-2.3.0/src-input/duk_error_macros.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_error_macros.c 2017-09-23 01:06:08.000000000 +0000 @@ -113,18 +113,10 @@ DUK_UNREF(udata); DUK_UNREF(msg); - msg = msg ? msg : "NULL"; - #if defined(DUK_USE_FATAL_HANDLER) /* duk_config.h provided a custom default fatal handler. */ - DUK_D(DUK_DPRINT("custom default fatal error handler called: %s", msg)); + DUK_D(DUK_DPRINT("custom default fatal error handler called: %s", msg ? msg : "NULL")); DUK_USE_FATAL_HANDLER(udata, msg); -#elif defined(DUK_USE_CPP_EXCEPTIONS) - /* With C++ use a duk_fatal_exception which user code can catch in - * a natural way. - */ - DUK_D(DUK_DPRINT("built-in default C++ fatal error handler called: %s", msg)); - throw duk_fatal_exception(msg); #else /* Default behavior is to abort() on error. There's no printout * which makes this awkward, so it's always recommended to use an @@ -141,7 +133,7 @@ * - http://duktape.org/api.html#taglist-protected * ==================================================================== */ - DUK_D(DUK_DPRINT("built-in default fatal error handler called: %s", msg)); + DUK_D(DUK_DPRINT("built-in default fatal error handler called: %s", msg ? msg : "NULL")); DUK_ABORT(); #endif diff -Nru duktape-2.3.0/src-input/duk_error_throw.c duktape-2.2.0/src-input/duk_error_throw.c --- duktape-2.3.0/src-input/duk_error_throw.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_error_throw.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,8 +1,8 @@ /* - * Create and throw an ECMAScript error object based on a code and a message. + * Create and throw an Ecmascript error object based on a code and a message. * - * Used when we throw errors internally. ECMAScript generated error objects - * are created by ECMAScript code, and the throwing is handled by the bytecode + * Used when we throw errors internally. Ecmascript generated error objects + * are created by Ecmascript code, and the throwing is handled by the bytecode * executor. */ @@ -158,5 +158,5 @@ */ duk_error_raw(thr, -rc, NULL, 0, "error (rc %ld)", (long) rc); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); } diff -Nru duktape-2.3.0/src-input/duk_exception.h duktape-2.2.0/src-input/duk_exception.h --- duktape-2.3.0/src-input/duk_exception.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_exception.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,30 +1,18 @@ /* - * Exceptions for Duktape internal throws when C++ exceptions are used + * Exception for Duktape internal throws when C++ exceptions are used * for long control transfers. + * + * Doesn't inherit from any exception base class to minimize the chance + * that user code would accidentally catch this exception. */ #if !defined(DUK_EXCEPTION_H_INCLUDED) #define DUK_EXCEPTION_H_INCLUDED #if defined(DUK_USE_CPP_EXCEPTIONS) -/* Internal exception used as a setjmp-longjmp replacement. User code should - * NEVER see or catch this exception, so it doesn't inherit from any base - * class which should minimize the chance of user code accidentally catching - * the exception. - */ class duk_internal_exception { /* intentionally empty */ }; - -/* Fatal error, thrown as a specific C++ exception with C++ exceptions - * enabled. It is unsafe to continue; doing so may cause crashes or memory - * leaks. This is intended to be either uncaught, or caught by user code - * aware of the "unsafe to continue" semantics. - */ -class duk_fatal_exception : public virtual std::runtime_error { - public: - duk_fatal_exception(const char *message) : std::runtime_error(message) {} -}; #endif #endif /* DUK_EXCEPTION_H_INCLUDED */ diff -Nru duktape-2.3.0/src-input/duk_forwdecl.h duktape-2.2.0/src-input/duk_forwdecl.h --- duktape-2.3.0/src-input/duk_forwdecl.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_forwdecl.h 2017-09-23 01:06:08.000000000 +0000 @@ -44,9 +44,8 @@ struct duk_activation; struct duk_catcher; +struct duk_strcache; struct duk_ljstate; -struct duk_strcache_entry; -struct duk_litcache_entry; struct duk_strtab_entry; #if defined(DUK_USE_DEBUG) @@ -105,9 +104,8 @@ typedef struct duk_activation duk_activation; typedef struct duk_catcher duk_catcher; +typedef struct duk_strcache duk_strcache; typedef struct duk_ljstate duk_ljstate; -typedef struct duk_strcache_entry duk_strcache_entry; -typedef struct duk_litcache_entry duk_litcache_entry; typedef struct duk_strtab_entry duk_strtab_entry; #if defined(DUK_USE_DEBUG) diff -Nru duktape-2.3.0/src-input/duk_hbuffer_alloc.c duktape-2.2.0/src-input/duk_hbuffer_alloc.c --- duktape-2.3.0/src-input/duk_hbuffer_alloc.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hbuffer_alloc.c 2017-09-23 01:06:08.000000000 +0000 @@ -47,10 +47,10 @@ /* zero everything unless requested not to do so */ #if defined(DUK_USE_ZERO_BUFFER_DATA) - duk_memzero((void *) res, + DUK_MEMZERO((void *) res, (flags & DUK_BUF_FLAG_NOZERO) ? header_size : alloc_size); #else - duk_memzero((void *) res, header_size); + DUK_MEMZERO((void *) res, header_size); #endif if (flags & DUK_BUF_FLAG_EXTERNAL) { @@ -97,7 +97,7 @@ DUK_ASSERT(DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap, h) == NULL); } } else { - *out_bufdata = (void *) ((duk_hbuffer_fixed *) (void *) res + 1); + *out_bufdata = (void *) ((duk_hbuffer_fixed *) res + 1); } DUK_HBUFFER_SET_SIZE(res, size); diff -Nru duktape-2.3.0/src-input/duk_hbuffer.h duktape-2.2.0/src-input/duk_hbuffer.h --- duktape-2.3.0/src-input/duk_hbuffer.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hbuffer.h 2017-09-23 01:06:08.000000000 +0000 @@ -94,7 +94,7 @@ #define DUK_HBUFFER_EXTERNAL_GET_SIZE(x) DUK_HBUFFER_GET_SIZE((duk_hbuffer *) (x)) #define DUK_HBUFFER_EXTERNAL_SET_SIZE(x,v) DUK_HBUFFER_SET_SIZE((duk_hbuffer *) (x), (v)) -#define DUK_HBUFFER_FIXED_GET_DATA_PTR(heap,x) ((duk_uint8_t *) (((duk_hbuffer_fixed *) (void *) (x)) + 1)) +#define DUK_HBUFFER_FIXED_GET_DATA_PTR(heap,x) ((duk_uint8_t *) (((duk_hbuffer_fixed *) (x)) + 1)) #if defined(DUK_USE_HEAPPTR16) #define DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap,x) \ @@ -149,7 +149,7 @@ DUK_HBUFFER_EXTERNAL_GET_DATA_PTR((heap), (duk_hbuffer_external *) (x)) : \ DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((heap), (duk_hbuffer_dynamic *) (x)) \ ) : \ - DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (void *) (x)) \ + DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (x)) \ ) #else /* Without heap pointer compression duk_hbuffer_dynamic and duk_hbuffer_external @@ -158,7 +158,7 @@ #define DUK_HBUFFER_GET_DATA_PTR(heap,x) ( \ DUK_HBUFFER_HAS_DYNAMIC((x)) ? \ DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((heap), (duk_hbuffer_dynamic *) (x)) : \ - DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (void *) (x)) \ + DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (x)) \ ) #endif @@ -232,10 +232,7 @@ #if (DUK_USE_ALIGN_BY == 4) duk_uint32_t dummy_for_align4; #elif (DUK_USE_ALIGN_BY == 8) - duk_double_t dummy_for_align8_1; -#if defined(DUK_USE_64BIT_OPS) - duk_uint64_t dummy_for_align8_2; -#endif + duk_double_t dummy_for_align8; #elif (DUK_USE_ALIGN_BY == 1) /* no extra padding */ #else diff -Nru duktape-2.3.0/src-input/duk_hbuffer_ops.c duktape-2.2.0/src-input/duk_hbuffer_ops.c --- duktape-2.3.0/src-input/duk_hbuffer_ops.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hbuffer_ops.c 2017-09-23 01:06:08.000000000 +0000 @@ -24,7 +24,6 @@ if (new_size > DUK_HBUFFER_MAX_BYTELEN) { DUK_ERROR_RANGE(thr, "buffer too long"); - DUK_WO_NORETURN(return;); } /* @@ -53,7 +52,7 @@ if (new_size > prev_size) { DUK_ASSERT(new_size - prev_size > 0); #if defined(DUK_USE_ZERO_BUFFER_DATA) - duk_memzero((void *) ((char *) res + prev_size), + DUK_MEMZERO((void *) ((char *) res + prev_size), (duk_size_t) (new_size - prev_size)); #endif } @@ -62,7 +61,6 @@ DUK_HBUFFER_DYNAMIC_SET_DATA_PTR(thr->heap, buf, res); } else { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return;); } DUK_ASSERT(res != NULL || new_size == 0); diff -Nru duktape-2.3.0/src-input/duk_hbufobj.h duktape-2.2.0/src-input/duk_hbufobj.h --- duktape-2.3.0/src-input/duk_hbufobj.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hbufobj.h 2017-09-23 01:06:08.000000000 +0000 @@ -47,8 +47,7 @@ } while (0) /* Get the current data pointer (caller must ensure buf != NULL) as a - * duk_uint8_t ptr. Note that the result may be NULL if the underlying - * buffer has zero size and is not a fixed buffer. + * duk_uint8_t ptr. */ #define DUK_HBUFOBJ_GET_SLICE_BASE(heap,h) \ (DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \ diff -Nru duktape-2.3.0/src-input/duk_hcompfunc.h duktape-2.2.0/src-input/duk_hcompfunc.h --- duktape-2.3.0/src-input/duk_hcompfunc.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hcompfunc.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,7 +1,7 @@ /* - * Heap compiled function (ECMAScript function) representation. + * Heap compiled function (Ecmascript function) representation. * - * There is a single data buffer containing the ECMAScript function's + * There is a single data buffer containing the Ecmascript function's * bytecode, constants, and inner functions. */ diff -Nru duktape-2.3.0/src-input/duk_heap_alloc.c duktape-2.2.0/src-input/duk_heap_alloc.c --- duktape-2.3.0/src-input/duk_heap_alloc.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_heap_alloc.c 2017-09-23 01:06:08.000000000 +0000 @@ -66,7 +66,7 @@ * functions in the callstack. */ } else if (DUK_HOBJECT_IS_BOUNDFUNC(h)) { - duk_hboundfunc *f = (duk_hboundfunc *) (void *) h; + duk_hboundfunc *f = (duk_hboundfunc *) h; DUK_FREE(heap, f->args); } @@ -464,7 +464,7 @@ duk_bitdecoder_ctx *bd = &bd_ctx; /* convenience */ duk_small_uint_t i; - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); bd->data = (const duk_uint8_t *) duk_strings_data; bd->length = (duk_size_t) DUK_STRDATA_DATA_LENGTH; @@ -685,8 +685,7 @@ DUK__DUMPSZ(duk_heap); DUK__DUMPSZ(duk_activation); DUK__DUMPSZ(duk_catcher); - DUK__DUMPSZ(duk_strcache_entry); - DUK__DUMPSZ(duk_litcache_entry); + DUK__DUMPSZ(duk_strcache); DUK__DUMPSZ(duk_ljstate); DUK__DUMPSZ(duk_fixedbuffer); DUK__DUMPSZ(duk_bitdecoder_ctx); @@ -895,7 +894,7 @@ * Zero the struct, and start initializing roughly in order */ - duk_memzero(res, sizeof(*res)); + DUK_MEMZERO(res, sizeof(*res)); #if defined(DUK_USE_ASSERTIONS) res->heap_initializing = 1; #endif @@ -980,7 +979,7 @@ /* XXX: use the pointer as a seed for now: mix in time at least */ - /* The casts through duk_uintptr_t is to avoid the following GCC warning: + /* The casts through duk_intptr_t is to avoid the following GCC warning: * * warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] * @@ -991,7 +990,7 @@ DUK_D(DUK_DPRINT("using rom strings, force heap hash_seed to fixed value 0x%08lx", (long) DUK__FIXED_HASH_SEED)); res->hash_seed = (duk_uint32_t) DUK__FIXED_HASH_SEED; #else /* DUK_USE_ROM_STRINGS */ - res->hash_seed = (duk_uint32_t) (duk_uintptr_t) res; + res->hash_seed = (duk_uint32_t) (duk_intptr_t) res; #if !defined(DUK_USE_STRHASH_DENSE) res->hash_seed ^= 5381; /* Bernstein hash init value is normally 5381; XOR it in in case pointer low bits are 0 */ #endif @@ -1031,17 +1030,17 @@ #if defined(DUK_USE_STRTAB_PTRCOMP) /* zero assumption */ - duk_memzero(res->strtable16, sizeof(duk_uint16_t) * st_initsize); + DUK_MEMZERO(res->strtable16, sizeof(duk_uint16_t) * st_initsize); #else #if defined(DUK_USE_EXPLICIT_NULL_INIT) { - duk_uint32_t i; + duk_small_uint_t i; for (i = 0; i < st_initsize; i++) { res->strtable[i] = NULL; } } #else - duk_memzero(res->strtable, sizeof(duk_hstring *) * st_initsize); + DUK_MEMZERO(res->strtable, sizeof(duk_hstring *) * st_initsize); #endif /* DUK_USE_EXPLICIT_NULL_INIT */ #endif /* DUK_USE_STRTAB_PTRCOMP */ @@ -1051,30 +1050,13 @@ #if defined(DUK_USE_EXPLICIT_NULL_INIT) { - duk_uint_t i; + duk_small_uint_t i; for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { res->strcache[i].h = NULL; } } #endif - /* - * Init litcache - */ -#if defined(DUK_USE_LITCACHE_SIZE) - DUK_ASSERT(DUK_USE_LITCACHE_SIZE > 0); - DUK_ASSERT(DUK_IS_POWER_OF_TWO((duk_uint_t) DUK_USE_LITCACHE_SIZE)); -#if defined(DUK_USE_EXPLICIT_NULL_INIT) - { - duk_uint_t i; - for (i = 0; i < DUK_USE_LITCACHE_SIZE; i++) { - res->litcache[i].addr = NULL; - res->litcache[i].h = NULL; - } - } -#endif -#endif /* DUK_USE_LITCACHE_SIZE */ - /* XXX: error handling is incomplete. It would be cleanest if * there was a setjmp catchpoint, so that all init code could * freely throw errors. If that were the case, the return code @@ -1146,7 +1128,7 @@ { duk_uint64_t tmp_u64; tmp_u64 = 0; - duk_memcpy((void *) &tmp_u64, + DUK_MEMCPY((void *) &tmp_u64, (const void *) &res, (size_t) (sizeof(void *) >= sizeof(duk_uint64_t) ? sizeof(duk_uint64_t) : sizeof(void *))); res->rnd_state[1] ^= tmp_u64; diff -Nru duktape-2.3.0/src-input/duk_heap.h duktape-2.2.0/src-input/duk_heap.h --- duktape-2.3.0/src-input/duk_heap.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_heap.h 2017-09-23 01:06:08.000000000 +0000 @@ -294,7 +294,7 @@ * Thus, string caches are now at the heap level now. */ -struct duk_strcache_entry { +struct duk_strcache { duk_hstring *h; duk_uint32_t bidx; duk_uint32_t cidx; @@ -326,15 +326,6 @@ } while (0) /* - * Literal intern cache - */ - -struct duk_litcache_entry { - const duk_uint8_t *addr; - duk_hstring *h; -}; - -/* * Main heap structure */ @@ -560,15 +551,7 @@ /* String access cache (codepoint offset -> byte offset) for fast string * character looping; 'weak' reference which needs special handling in GC. */ - duk_strcache_entry strcache[DUK_HEAP_STRCACHE_SIZE]; - -#if defined(DUK_USE_LITCACHE_SIZE) - /* Literal intern cache. When enabled, strings interned as literals - * (e.g. duk_push_literal()) will be pinned and cached for the lifetime - * of the heap. - */ - duk_litcache_entry litcache[DUK_USE_LITCACHE_SIZE]; -#endif + duk_strcache strcache[DUK_HEAP_STRCACHE_SIZE]; /* Built-in strings. */ #if defined(DUK_USE_ROM_STRINGS) @@ -600,9 +583,6 @@ duk_int_t stats_strtab_resize_check; duk_int_t stats_strtab_resize_grow; duk_int_t stats_strtab_resize_shrink; - duk_int_t stats_strtab_litcache_hit; - duk_int_t stats_strtab_litcache_miss; - duk_int_t stats_strtab_litcache_pin; duk_int_t stats_object_realloc_props; duk_int_t stats_object_abandon_array; duk_int_t stats_getownpropdesc_count; @@ -663,9 +643,6 @@ DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen); DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t len); -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_literal_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t blen); -#endif DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_u32(duk_heap *heap, duk_uint32_t val); DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_u32_checked(duk_hthread *thr, duk_uint32_t val); #if defined(DUK_USE_REFERENCE_COUNTING) diff -Nru duktape-2.3.0/src-input/duk_heap_markandsweep.c duktape-2.2.0/src-input/duk_heap_markandsweep.c --- duktape-2.3.0/src-input/duk_heap_markandsweep.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_heap_markandsweep.c 2017-09-23 01:06:08.000000000 +0000 @@ -114,7 +114,7 @@ duk__mark_heaphdr(heap, (duk_heaphdr *) b->buf_prop); #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ } else if (DUK_HOBJECT_IS_BOUNDFUNC(h)) { - duk_hboundfunc *f = (duk_hboundfunc *) (void *) h; + duk_hboundfunc *f = (duk_hboundfunc *) h; DUK_ASSERT_HBOUNDFUNC_VALID(f); duk__mark_tval(heap, &f->target); duk__mark_tval(heap, &f->this_binding); @@ -588,8 +588,7 @@ duk_hstring *next; next = h->hdr.h_next; - if (DUK_HEAPHDR_HAS_REACHABLE((duk_heaphdr *) h)) - { + if (DUK_HEAPHDR_HAS_REACHABLE((duk_heaphdr *) h)) { DUK_HEAPHDR_CLEAR_REACHABLE((duk_heaphdr *) h); count_keep++; prev = h; @@ -598,26 +597,13 @@ count_free++; #endif - /* For pinned strings the refcount has been - * bumped. We could unbump it here before - * freeing, but that's actually not necessary - * except for assertions. - */ -#if 0 - if (DUK_HSTRING_HAS_PINNED_LITERAL(h)) { - DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) > 0U); - DUK_HSTRING_DECREF_NORZ(heap->heap_thread, h); - DUK_HSTRING_CLEAR_PINNED_LITERAL(h); - } -#endif #if defined(DUK_USE_REFERENCE_COUNTING) /* Non-zero refcounts should not happen for unreachable strings, * because we refcount finalize all unreachable objects which * should have decreased unreachable string refcounts to zero - * (even for cycles). However, pinned strings have a +1 bump. + * (even for cycles). */ - DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) == - DUK_HSTRING_HAS_PINNED_LITERAL(h) ? 1U : 0U); + DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) == 0); #endif /* Deal with weak references first. */ @@ -821,26 +807,6 @@ } /* - * Litcache helpers. - */ - -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_LOCAL void duk__wipe_litcache(duk_heap *heap) { - duk_uint_t i; - duk_litcache_entry *e; - - e = heap->litcache; - for (i = 0; i < DUK_USE_LITCACHE_SIZE; i++) { - e->addr = NULL; - /* e->h does not need to be invalidated: when e->addr is - * NULL, e->h is considered garbage. - */ - e++; - } -} -#endif /* DUK_USE_LITCACHE_SIZE */ - -/* * Object compaction. * * Compaction is assumed to never throw an error. @@ -1024,7 +990,6 @@ DUK_LOCAL void duk__check_refcount_heaphdr(duk_heaphdr *hdr) { duk_bool_t count_ok; - duk_size_t expect_refc; /* The refcount check only makes sense for reachable objects on * heap_allocated or string table, after the sweep phase. Prior to @@ -1041,11 +1006,7 @@ */ DUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY(hdr)); - expect_refc = hdr->h_assert_refcount; - if (DUK_HEAPHDR_IS_STRING(hdr) && DUK_HSTRING_HAS_PINNED_LITERAL((duk_hstring *) hdr)) { - expect_refc++; - } - count_ok = ((duk_size_t) DUK_HEAPHDR_GET_REFCOUNT(hdr) == expect_refc); + count_ok = ((duk_size_t) DUK_HEAPHDR_GET_REFCOUNT(hdr) == hdr->h_assert_refcount); if (!count_ok) { DUK_D(DUK_DPRINT("refcount mismatch for: %p: header=%ld counted=%ld --> %!iO", (void *) hdr, (long) DUK_HEAPHDR_GET_REFCOUNT(hdr), @@ -1082,22 +1043,6 @@ } } #endif /* DUK_USE_REFERENCE_COUNTING */ - -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_LOCAL void duk__assert_litcache_nulls(duk_heap *heap) { - duk_uint_t i; - duk_litcache_entry *e; - - e = heap->litcache; - for (i = 0; i < DUK_USE_LITCACHE_SIZE; i++) { - /* Entry addresses were NULLed before mark-and-sweep, check - * that they're still NULL afterwards to ensure no pointers - * were recorded through any side effects. - */ - DUK_ASSERT(e->addr == NULL); - } -} -#endif /* DUK_USE_LITCACHE_SIZE */ #endif /* DUK_USE_ASSERTIONS */ /* @@ -1118,13 +1063,10 @@ DUK_D(DUK_DPRINT("stats mark-and-sweep: try_count=%ld, skip_count=%ld, emergency_count=%ld", (long) heap->stats_ms_try_count, (long) heap->stats_ms_skip_count, (long) heap->stats_ms_emergency_count)); - DUK_D(DUK_DPRINT("stats stringtable: intern_hit=%ld, intern_miss=%ld, " - "resize_check=%ld, resize_grow=%ld, resize_shrink=%ld, " - "litcache_hit=%ld, litcache_miss=%ld, litcache_pin=%ld", + DUK_D(DUK_DPRINT("stats stringtable: intern_hit=%ld, intern_miss=%ld, resize_check=%ld, resize_grow=%ld, resize_shrink=%ld", (long) heap->stats_strtab_intern_hit, (long) heap->stats_strtab_intern_miss, (long) heap->stats_strtab_resize_check, (long) heap->stats_strtab_resize_grow, - (long) heap->stats_strtab_resize_shrink, (long) heap->stats_strtab_litcache_hit, - (long) heap->stats_strtab_litcache_miss, (long) heap->stats_strtab_litcache_pin)); + (long) heap->stats_strtab_resize_shrink)); DUK_D(DUK_DPRINT("stats object: realloc_props=%ld, abandon_array=%ld", (long) heap->stats_object_realloc_props, (long) heap->stats_object_abandon_array)); DUK_D(DUK_DPRINT("stats getownpropdesc: count=%ld, hit=%ld, miss=%ld", @@ -1265,9 +1207,6 @@ #if defined(DUK_USE_ASSERTIONS) && defined(DUK_USE_REFERENCE_COUNTING) duk__clear_assert_refcounts(heap); #endif -#if defined(DUK_USE_LITCACHE_SIZE) - duk__wipe_litcache(heap); -#endif duk__mark_roots_heap(heap); /* Mark main reachability roots. */ #if defined(DUK_USE_REFERENCE_COUNTING) DUK_ASSERT(heap->refzero_list == NULL); /* Always handled to completion inline in DECREF. */ @@ -1373,9 +1312,6 @@ */ duk__assert_valid_refcounts(heap); #endif /* DUK_USE_REFERENCE_COUNTING */ -#if defined(DUK_USE_LITCACHE_SIZE) - duk__assert_litcache_nulls(heap); -#endif /* DUK_USE_LITCACHE_SIZE */ #endif /* DUK_USE_ASSERTIONS */ /* diff -Nru duktape-2.3.0/src-input/duk_heap_memory.c duktape-2.2.0/src-input/duk_heap_memory.c --- duktape-2.3.0/src-input/duk_heap_memory.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_heap_memory.c 2017-09-23 01:06:08.000000000 +0000 @@ -127,7 +127,8 @@ res = DUK_ALLOC(heap, size); if (DUK_LIKELY(res != NULL)) { - duk_memzero(res, size); + /* assume memset with zero size is OK */ + DUK_MEMZERO(res, size); } return res; } @@ -141,7 +142,7 @@ return res; } DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; } DUK_INTERNAL void *duk_heap_mem_alloc_checked_zeroed(duk_hthread *thr, duk_size_t size) { @@ -153,7 +154,7 @@ return res; } DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; } /* diff -Nru duktape-2.3.0/src-input/duk_heap_refcount.c duktape-2.2.0/src-input/duk_heap_refcount.c --- duktape-2.3.0/src-input/duk_heap_refcount.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_heap_refcount.c 2017-09-23 01:06:08.000000000 +0000 @@ -170,7 +170,7 @@ DUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, (duk_hobject *) b->buf_prop); #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ } else if (DUK_HOBJECT_IS_BOUNDFUNC(h)) { - duk_hboundfunc *f = (duk_hboundfunc *) (void *) h; + duk_hboundfunc *f = (duk_hboundfunc *) h; DUK_ASSERT_HBOUNDFUNC_VALID(f); DUK_TVAL_DECREF_NORZ(thr, &f->target); DUK_TVAL_DECREF_NORZ(thr, &f->this_binding); diff -Nru duktape-2.3.0/src-input/duk_heap_stringcache.c duktape-2.2.0/src-input/duk_heap_stringcache.c --- duktape-2.3.0/src-input/duk_heap_stringcache.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_heap_stringcache.c 2017-09-23 01:06:08.000000000 +0000 @@ -18,9 +18,9 @@ */ DUK_INTERNAL void duk_heap_strcache_string_remove(duk_heap *heap, duk_hstring *h) { - duk_uint_t i; + duk_small_int_t i; for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { - duk_strcache_entry *c = heap->strcache + 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)); @@ -92,9 +92,9 @@ 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_entry *sce; + duk_strcache *sce; duk_uint_fast32_t byte_offset; - duk_uint_t i; + duk_small_int_t i; duk_bool_t use_cache; duk_uint_fast32_t dist_start, dist_end, dist_sce; duk_uint_fast32_t char_length; @@ -145,14 +145,14 @@ #if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2) DUK_DDD(DUK_DDDPRINT("stringcache before char2byte (using cache):")); for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { - duk_strcache_entry *c = heap->strcache + 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_entry *c = heap->strcache + i; + duk_strcache *c = heap->strcache + i; if (c->h == h) { sce = c; @@ -281,10 +281,10 @@ * C <- sce ==> B * D D */ - duk_strcache_entry tmp; + duk_strcache tmp; tmp = *sce; - duk_memmove((void *) (&heap->strcache[1]), + DUK_MEMMOVE((void *) (&heap->strcache[1]), (const void *) (&heap->strcache[0]), (size_t) (((char *) sce) - ((char *) &heap->strcache[0]))); heap->strcache[0] = tmp; @@ -294,7 +294,7 @@ #if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2) DUK_DDD(DUK_DDDPRINT("stringcache after char2byte (using cache):")); for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { - duk_strcache_entry *c = heap->strcache + 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)); } @@ -305,5 +305,5 @@ scan_error: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + return 0; } diff -Nru duktape-2.3.0/src-input/duk_heap_stringtable.c duktape-2.2.0/src-input/duk_heap_stringtable.c --- duktape-2.3.0/src-input/duk_heap_stringtable.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_heap_stringtable.c 2017-09-23 01:06:08.000000000 +0000 @@ -54,7 +54,7 @@ return; } - duk_memzero((void *) count_len, sizeof(count_len)); + DUK_MEMZERO((void *) count_len, sizeof(count_len)); for (i = 0; i < heap->st_size; i++) { h = DUK__HEAPPTR_DEC16(heap, strtable[i]); count_chain = 0; @@ -166,7 +166,7 @@ if (DUK_UNLIKELY(res == NULL)) { goto alloc_error; } - duk_memzero(res, sizeof(duk_hstring_external)); + DUK_MEMZERO(res, sizeof(duk_hstring_external)); #if defined(DUK_USE_EXPLICIT_NULL_INIT) DUK_HEAPHDR_STRING_INIT_NULLS(&res->hdr); #endif @@ -186,14 +186,14 @@ if (DUK_UNLIKELY(res == NULL)) { goto alloc_error; } - duk_memzero(res, sizeof(duk_hstring)); + 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_tmp = (duk_uint8_t *) (res + 1); - duk_memcpy(data_tmp, str, blen); + DUK_MEMCPY(data_tmp, str, blen); data_tmp[blen] = (duk_uint8_t) 0; data = (const duk_uint8_t *) data_tmp; } @@ -686,12 +686,11 @@ } lookup_hash &= 0xff; - curr = (duk_hstring *) DUK_LOSE_CONST(duk_rom_strings_lookup[lookup_hash]); + curr = DUK_LOSE_CONST(duk_rom_strings_lookup[lookup_hash]); while (curr != NULL) { - /* Unsafe memcmp() because for zero blen, str may be NULL. */ if (strhash == DUK_HSTRING_GET_HASH(curr) && blen == DUK_HSTRING_GET_BYTELEN(curr) && - duk_memcmp_unsafe((const void *) str, (const void *) DUK_HSTRING_GET_DATA(curr), blen) == 0) { + DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(curr), blen) == 0) { DUK_DDD(DUK_DDDPRINT("intern check: rom string: %!O, computed hash 0x%08lx, rom hash 0x%08lx", curr, (unsigned long) strhash, (unsigned long) DUK_HSTRING_GET_HASH(curr))); return curr; @@ -711,7 +710,6 @@ /* Preliminaries. */ - /* XXX: maybe just require 'str != NULL' even for zero size? */ DUK_ASSERT(heap != NULL); DUK_ASSERT(blen == 0 || str != NULL); DUK_ASSERT(blen <= DUK_HSTRING_MAX_BYTELEN); /* Caller is responsible for ensuring this. */ @@ -730,7 +728,7 @@ while (h != NULL) { if (DUK_HSTRING_GET_HASH(h) == strhash && DUK_HSTRING_GET_BYTELEN(h) == blen && - duk_memcmp_unsafe((const void *) str, (const void *) DUK_HSTRING_GET_DATA(h), (size_t) blen) == 0) { + DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(h), (size_t) blen) == 0) { /* Found existing entry. */ DUK_STATS_INC(heap, stats_strtab_intern_hit); return h; @@ -803,67 +801,10 @@ res = duk_heap_strtable_intern(thr->heap, str, blen); if (DUK_UNLIKELY(res == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } return res; } -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_LOCAL duk_uint_t duk__strtable_litcache_key(const duk_uint8_t *str, duk_uint32_t blen) { - duk_uintptr_t key; - - DUK_ASSERT(DUK_USE_LITCACHE_SIZE > 0); - DUK_ASSERT(DUK_IS_POWER_OF_TWO((duk_uint_t) DUK_USE_LITCACHE_SIZE)); - - key = (duk_uintptr_t) blen ^ (duk_uintptr_t) str; - key &= (duk_uintptr_t) (DUK_USE_LITCACHE_SIZE - 1); /* Assumes size is power of 2. */ - /* Due to masking, cast is in 32-bit range. */ - DUK_ASSERT(key <= DUK_UINT_MAX); - return (duk_uint_t) key; -} - -DUK_INTERNAL duk_hstring *duk_heap_strtable_intern_literal_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t blen) { - duk_uint_t key; - duk_litcache_entry *ent; - duk_hstring *h; - - /* Fast path check: literal exists in literal cache. */ - key = duk__strtable_litcache_key(str, blen); - ent = thr->heap->litcache + key; - if (ent->addr == str) { - DUK_DD(DUK_DDPRINT("intern check for cached, pinned literal: str=%p, blen=%ld -> duk_hstring %!O", - (const void *) str, (long) blen, (duk_heaphdr *) ent->h)); - DUK_ASSERT(ent->h != NULL); - DUK_ASSERT(DUK_HSTRING_HAS_PINNED_LITERAL(ent->h)); - DUK_STATS_INC(thr->heap, stats_strtab_litcache_hit); - return ent->h; - } - - /* Intern and update (overwrite) cache entry. */ - h = duk_heap_strtable_intern_checked(thr, str, blen); - ent->addr = str; - ent->h = h; - DUK_STATS_INC(thr->heap, stats_strtab_litcache_miss); - - /* Pin the duk_hstring until the next mark-and-sweep. This means - * litcache entries don't need to be invalidated until the next - * mark-and-sweep as their target duk_hstring is not freed before - * the mark-and-sweep happens. The pin remains even if the literal - * cache entry is overwritten, and is still useful to avoid string - * table traffic. - */ - if (!DUK_HSTRING_HAS_PINNED_LITERAL(h)) { - DUK_DD(DUK_DDPRINT("pin duk_hstring because it is a literal: %!O", (duk_heaphdr *) h)); - DUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) h)); - DUK_HSTRING_INCREF(thr, h); - DUK_HSTRING_SET_PINNED_LITERAL(h); - DUK_STATS_INC(thr->heap, stats_strtab_litcache_pin); - } - - return h; -} -#endif /* DUK_USE_LITCACHE_SIZE */ - DUK_INTERNAL duk_hstring *duk_heap_strtable_intern_u32_checked(duk_hthread *thr, duk_uint32_t val) { duk_hstring *res; @@ -873,7 +814,6 @@ res = duk_heap_strtable_intern_u32(thr->heap, val); if (DUK_UNLIKELY(res == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } return res; } diff -Nru duktape-2.3.0/src-input/duk_hobject_alloc.c duktape-2.2.0/src-input/duk_hobject_alloc.c --- duktape-2.3.0/src-input/duk_hobject_alloc.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hobject_alloc.c 2017-09-23 01:06:08.000000000 +0000 @@ -130,7 +130,7 @@ if (!res) { return NULL; } - duk_memzero(res, sizeof(duk_hboundfunc)); + DUK_MEMZERO(res, sizeof(duk_hboundfunc)); duk__init_object_parts(heap, hobject_flags, &res->obj); @@ -172,7 +172,7 @@ if (DUK_UNLIKELY(res == NULL)) { return NULL; } - duk_memzero(res, sizeof(duk_hthread)); + DUK_MEMZERO(res, sizeof(duk_hthread)); duk__init_object_parts(heap, hobject_flags, &res->obj); @@ -214,7 +214,6 @@ res = duk_hthread_alloc_unchecked(thr->heap, hobject_flags); if (res == NULL) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } return res; } diff -Nru duktape-2.3.0/src-input/duk_hobject_class.c duktape-2.2.0/src-input/duk_hobject_class.c --- duktape-2.3.0/src-input/duk_hobject_class.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hobject_class.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Hobject ECMAScript [[Class]]. + * Hobject Ecmascript [[Class]]. */ #include "duk_internal.h" diff -Nru duktape-2.3.0/src-input/duk_hobject_enum.c duktape-2.2.0/src-input/duk_hobject_enum.c --- duktape-2.3.0/src-input/duk_hobject_enum.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hobject_enum.c 2017-09-23 01:06:08.000000000 +0000 @@ -159,7 +159,7 @@ * are very often in order already. */ if (idx != idx_insert) { - duk_memmove((void *) (keys + idx_insert + 1), + DUK_MEMMOVE((void *) (keys + idx_insert + 1), (const void *) (keys + idx_insert), ((size_t) (idx - idx_insert) * sizeof(duk_hstring *))); keys[idx_insert] = h_curr; @@ -643,7 +643,7 @@ } /* - * Get enumerated keys in an ECMAScript array. Matches Object.keys() behavior + * Get enumerated keys in an Ecmascript array. Matches Object.keys() behavior * described in E5 Section 15.2.3.14. */ diff -Nru duktape-2.3.0/src-input/duk_hobject.h duktape-2.2.0/src-input/duk_hobject.h --- duktape-2.3.0/src-input/duk_hobject.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hobject.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,12 +1,12 @@ /* * Heap object representation. * - * Heap objects are used for ECMAScript objects, arrays, and functions, + * Heap objects are used for Ecmascript objects, arrays, and functions, * but also for internal control like declarative and object environment * records. Compiled functions, native functions, and threads are also * objects but with an extended C struct. * - * Objects provide the required ECMAScript semantics and exotic behaviors + * Objects provide the required Ecmascript semantics and exotic behaviors * especially for property access. * * Properties are stored in three conceptual parts: @@ -635,7 +635,7 @@ #define DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY 10000L /* - * ECMAScript [[Class]] + * Ecmascript [[Class]] */ /* range check not necessary because all 4-bit values are mapped */ diff -Nru duktape-2.3.0/src-input/duk_hobject_misc.c duktape-2.2.0/src-input/duk_hobject_misc.c --- duktape-2.3.0/src-input/duk_hobject_misc.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hobject_misc.c 2017-09-23 01:06:08.000000000 +0000 @@ -27,7 +27,6 @@ break; } else { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } } h = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h); diff -Nru duktape-2.3.0/src-input/duk_hobject_pc2line.c duktape-2.2.0/src-input/duk_hobject_pc2line.c --- duktape-2.3.0/src-input/duk_hobject_pc2line.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hobject_pc2line.c 2017-09-23 01:06:08.000000000 +0000 @@ -58,7 +58,7 @@ (long) hdr[hdr_index + 1])); #endif - duk_memzero(be_ctx, sizeof(*be_ctx)); + DUK_MEMZERO(be_ctx, sizeof(*be_ctx)); be_ctx->data = ((duk_uint8_t *) hdr) + curr_offset; be_ctx->length = (duk_size_t) DUK_PC2LINE_MAX_DIFF_LENGTH; @@ -169,7 +169,7 @@ * Iterate the bitstream (line diffs) until PC is reached */ - duk_memzero(bd_ctx, sizeof(*bd_ctx)); + DUK_MEMZERO(bd_ctx, sizeof(*bd_ctx)); bd_ctx->data = ((duk_uint8_t *) hdr) + start_offset; bd_ctx->length = (duk_size_t) (DUK_HBUFFER_FIXED_GET_SIZE(buf) - start_offset); @@ -229,7 +229,7 @@ */ duk_get_prop_stridx(thr, idx_func, DUK_STRIDX_INT_PC2LINE); - pc2line = (duk_hbuffer_fixed *) (void *) duk_get_hbuffer(thr, -1); + pc2line = (duk_hbuffer_fixed *) duk_get_hbuffer(thr, -1); if (pc2line != NULL) { DUK_ASSERT(!DUK_HBUFFER_HAS_DYNAMIC((duk_hbuffer *) pc2line) && !DUK_HBUFFER_HAS_EXTERNAL((duk_hbuffer *) pc2line)); line = duk__hobject_pc2line_query_raw(thr, pc2line, (duk_uint_fast32_t) pc); diff -Nru duktape-2.3.0/src-input/duk_hobject_props.c duktape-2.2.0/src-input/duk_hobject_props.c --- duktape-2.3.0/src-input/duk_hobject_props.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hobject_props.c 2017-09-23 01:06:08.000000000 +0000 @@ -53,7 +53,7 @@ #define DUK__HASH_DELETED DUK_HOBJECT_HASHIDX_DELETED /* Valstack space that suffices for all local calls, excluding any recursion - * into ECMAScript or Duktape/C calls (Proxy, getters, etc). + * into Ecmascript or Duktape/C calls (Proxy, getters, etc). */ #define DUK__VALSTACK_SPACE 10 @@ -603,7 +603,6 @@ if (new_e_size_adjusted + new_a_size > DUK_HOBJECT_MAX_PROPERTIES) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return;); } /* @@ -807,14 +806,18 @@ } else { array_copy_size = sizeof(duk_tval) * new_a_size; } - - DUK_ASSERT(new_a != NULL || array_copy_size == 0U); - DUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, obj) != NULL || array_copy_size == 0U); - DUK_ASSERT(DUK_HOBJECT_GET_ASIZE(obj) > 0 || array_copy_size == 0U); - duk_memcpy_unsafe((void *) new_a, - (const void *) DUK_HOBJECT_A_GET_BASE(thr->heap, obj), - array_copy_size); - + if (array_copy_size > 0) { + /* Avoid zero copy with an invalid pointer. If obj->p is NULL, + * the 'new_a' pointer will be invalid which is not allowed even + * when copy size is zero. + */ + DUK_ASSERT(new_a != NULL); + DUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, obj) != NULL); + DUK_ASSERT(DUK_HOBJECT_GET_ASIZE(obj) > 0); + DUK_MEMCPY((void *) new_a, + (const void *) DUK_HOBJECT_A_GET_BASE(thr->heap, obj), + array_copy_size); + } for (i = DUK_HOBJECT_GET_ASIZE(obj); i < new_a_size; i++) { duk_tval *tv = &new_a[i]; DUK_TVAL_SET_UNUSED(tv); @@ -839,7 +842,7 @@ /* fill new_h with u32 0xff = UNUSED */ DUK_ASSERT(new_h_size > 0); - duk_memset(new_h, 0xff, sizeof(duk_uint32_t) * new_h_size); + DUK_MEMSET(new_h, 0xff, sizeof(duk_uint32_t) * new_h_size); DUK_ASSERT(new_e_next <= new_h_size); /* equality not actually possible */ @@ -949,7 +952,6 @@ #endif DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return;); } /* @@ -1427,7 +1429,7 @@ /* This is not strictly necessary, but avoids compiler warnings; e.g. * gcc won't reliably detect that no uninitialized data is read below. */ - duk_memzero((void *) &tv, sizeof(duk_tval)); + DUK_MEMZERO((void *) &tv, sizeof(duk_tval)); if (duk_hobject_get_internal_value(heap, obj, &tv)) { duk_hstring *h; @@ -1615,7 +1617,7 @@ } /* - * ECMAScript compliant [[GetOwnProperty]](P), for internal use only. + * Ecmascript compliant [[GetOwnProperty]](P), for internal use only. * * If property is found: * - Fills descriptor fields to 'out_desc' @@ -1990,7 +1992,7 @@ } /* - * ECMAScript compliant [[GetProperty]](P), for internal use only. + * Ecmascript compliant [[GetProperty]](P), for internal use only. * * If property is found: * - Fills descriptor fields to 'out_desc' @@ -2047,7 +2049,6 @@ break; } else { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } } curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr); @@ -2329,7 +2330,7 @@ #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ /* - * GETPROP: ECMAScript property read. + * GETPROP: Ecmascript property read. */ DUK_INTERNAL duk_bool_t duk_hobject_getprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key) { @@ -2383,8 +2384,7 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot read property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); - break; + return 0; } case DUK_TAG_BOOLEAN: { @@ -2540,7 +2540,6 @@ !DUK_TVAL_IS_UNDEFINED(tv_hook); if (datadesc_reject || accdesc_reject) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } duk_pop_2_unsafe(thr); @@ -2732,7 +2731,6 @@ */ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr); } while (curr != NULL); @@ -2803,7 +2801,6 @@ DUK_HOBJECT_HAS_STRICT(h)) { /* XXX: sufficient to check 'strict', assert for 'is function' */ DUK_ERROR_TYPE(thr, DUK_STR_STRICT_CALLER_READ); - DUK_WO_NORETURN(return 0;); } } } @@ -2816,7 +2813,7 @@ } /* - * HASPROP: ECMAScript property existence check ("in" operator). + * HASPROP: Ecmascript property existence check ("in" operator). * * Interestingly, the 'in' operator does not do any coercion of * the target object. @@ -2882,7 +2879,6 @@ /* Note: unconditional throw */ DUK_DDD(DUK_DDDPRINT("base object is not an object -> reject")); DUK_ERROR_TYPE(thr, DUK_STR_INVALID_BASE); - DUK_WO_NORETURN(return 0;); } /* XXX: fast path for arrays? */ @@ -2907,7 +2903,7 @@ duk_push_hobject(thr, h_target); /* target */ duk_push_tval(thr, tv_key); /* P */ duk_call_method(thr, 2 /*nargs*/); - tmp_bool = duk_to_boolean_top_pop(thr); + tmp_bool = duk_to_boolean(thr, -1); if (!tmp_bool) { /* Target object must be checked for a conflicting * non-configurable property. @@ -2926,12 +2922,11 @@ if (!((desc.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && /* property is configurable and */ DUK_HOBJECT_HAS_EXTENSIBLE(h_target))) { /* ... target is extensible */ DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } } } - duk_pop_unsafe(thr); /* [ key ] -> [] */ + duk_pop_2_unsafe(thr); /* [ key trap_result ] -> [] */ return tmp_bool; } @@ -3023,7 +3018,7 @@ /* Refuse to update an Array's 'length' to a value outside the * 32-bit range. Negative zero is accepted as zero. */ - res = duk_double_to_uint32_t(d); + res = (duk_uint32_t) d; if ((duk_double_t) res != d) { goto fail_range; } @@ -3032,7 +3027,7 @@ fail_range: DUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARRAY_LENGTH); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } /* Delete elements required by a smaller length, taking into account @@ -3301,9 +3296,9 @@ } /* - * PUTPROP: ECMAScript property write. + * PUTPROP: Ecmascript property write. * - * Unlike ECMAScript primitive which returns nothing, returns 1 to indicate + * Unlike Ecmascript primitive which returns nothing, returns 1 to indicate * success and 0 to indicate failure (assuming throw is not set). * * This is an extremely tricky function. Some examples: @@ -3390,8 +3385,7 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot write property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); - break; + return 0; } case DUK_TAG_BOOLEAN: { @@ -3495,7 +3489,8 @@ duk_push_tval(thr, tv_val); /* V */ duk_push_tval(thr, tv_obj); /* Receiver: Proxy object */ duk_call_method(thr, 4 /*nargs*/); - tmp_bool = duk_to_boolean_top_pop(thr); + tmp_bool = duk_to_boolean(thr, -1); + duk_pop_nodecref_unsafe(thr); if (!tmp_bool) { goto fail_proxy_rejected; } @@ -3527,7 +3522,6 @@ (desc.set == NULL); if (datadesc_reject || accdesc_reject) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } duk_pop_2_unsafe(thr); @@ -3827,7 +3821,6 @@ */ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr); } while (curr != NULL); @@ -4177,7 +4170,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, proxy rejects")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } /* Note: no key on stack */ return 0; @@ -4192,7 +4184,6 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot write property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -4201,7 +4192,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, not extensible")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_EXTENSIBLE); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -4210,7 +4200,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, not writable")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_WRITABLE); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -4220,7 +4209,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, not writable")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_WRITABLE); - DUK_WO_NORETURN(return 0;); } return 0; #endif @@ -4229,7 +4217,6 @@ DUK_DD(DUK_DDPRINT("result: error, array length write only partially successful")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -4238,7 +4225,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, accessor property without setter")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_SETTER_UNDEFINED); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -4247,14 +4233,13 @@ DUK_DDD(DUK_DDDPRINT("result: error, internal")); if (throw_flag) { DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; } /* - * ECMAScript compliant [[Delete]](P, Throw). + * Ecmascript compliant [[Delete]](P, Throw). */ DUK_INTERNAL duk_bool_t duk_hobject_delprop_raw(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_small_uint_t flags) { @@ -4408,13 +4393,12 @@ if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } return 0; } /* - * DELPROP: ECMAScript property deletion. + * DELPROP: Ecmascript property deletion. */ DUK_INTERNAL duk_bool_t duk_hobject_delprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key, duk_bool_t throw_flag) { @@ -4469,7 +4453,8 @@ duk_push_hobject(thr, h_target); /* target */ duk_dup_m4(thr); /* P */ duk_call_method(thr, 2 /*nargs*/); - tmp_bool = duk_to_boolean_top_pop(thr); + tmp_bool = duk_to_boolean(thr, -1); + duk_pop_nodecref_unsafe(thr); if (!tmp_bool) { goto fail_proxy_rejected; /* retval indicates delete failed */ } @@ -4494,7 +4479,6 @@ if (desc_reject) { /* unconditional */ DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } } rc = 1; /* success */ @@ -4578,13 +4562,12 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot delete property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); + return 0; #if defined(DUK_USE_ES6_PROXY) fail_proxy_rejected: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } duk_set_top_unsafe(thr, entry_top); return 0; @@ -4593,7 +4576,6 @@ fail_not_configurable: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } duk_set_top_unsafe(thr, entry_top); return 0; @@ -4733,7 +4715,7 @@ error_virtual: /* share error message */ error_internal: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); + return; } /* @@ -4813,7 +4795,7 @@ val = duk_to_number_m1(thr); duk_pop_3_unsafe(thr); - /* This isn't part of ECMAScript semantics; return a value within + /* This isn't part of Ecmascript semantics; return a value within * duk_size_t range, or 0 otherwise. */ if (val >= 0.0 && val <= (duk_double_t) DUK_SIZE_MAX) { @@ -4924,7 +4906,7 @@ * NormalizePropertyDescriptor() related helper. * * Internal helper which validates and normalizes a property descriptor - * represented as an ECMAScript object (e.g. argument to defineProperty()). + * represented as an Ecmascript object (e.g. argument to defineProperty()). * The output of this conversion is a set of defprop_flags and possibly * some values pushed on the value stack to (1) ensure borrowed pointers * remain valid, and (2) avoid unnecessary pops for footprint reasons. @@ -4974,7 +4956,7 @@ if (duk_get_prop_stridx(thr, idx_in, DUK_STRIDX_WRITABLE)) { is_data_desc = 1; - if (duk_to_boolean_top_pop(thr)) { + if (duk_to_boolean(thr, -1)) { defprop_flags |= DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_WRITABLE; } else { defprop_flags |= DUK_DEFPROP_HAVE_WRITABLE; @@ -5026,7 +5008,7 @@ } if (duk_get_prop_stridx(thr, idx_in, DUK_STRIDX_ENUMERABLE)) { - if (duk_to_boolean_top_pop(thr)) { + if (duk_to_boolean(thr, -1)) { defprop_flags |= DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE; } else { defprop_flags |= DUK_DEFPROP_HAVE_ENUMERABLE; @@ -5034,7 +5016,7 @@ } if (duk_get_prop_stridx(thr, idx_in, DUK_STRIDX_CONFIGURABLE)) { - if (duk_to_boolean_top_pop(thr)) { + if (duk_to_boolean(thr, -1)) { defprop_flags |= DUK_DEFPROP_HAVE_CONFIGURABLE | DUK_DEFPROP_CONFIGURABLE; } else { defprop_flags |= DUK_DEFPROP_HAVE_CONFIGURABLE; @@ -5055,7 +5037,6 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_DESCRIPTOR); - DUK_WO_NORETURN(return;); } /* @@ -5064,7 +5045,7 @@ * * Inlines all [[DefineOwnProperty]] exotic behaviors. * - * Note: ECMAScript compliant [[DefineOwnProperty]](P, Desc, Throw) is not + * Note: Ecmascript compliant [[DefineOwnProperty]](P, Desc, Throw) is not * implemented directly, but Object.defineProperty() serves its purpose. * We don't need the [[DefineOwnProperty]] internally and we don't have a * property descriptor with 'missing values' so it's easier to avoid it @@ -5937,7 +5918,6 @@ fail_not_extensible: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_EXTENSIBLE); - DUK_WO_NORETURN(return 0;); } return 0; @@ -5945,7 +5925,6 @@ fail_not_configurable: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } return 0; } @@ -6001,7 +5980,6 @@ if (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) { DUK_DD(DUK_DDPRINT("attempt to seal/freeze a readonly object, reject")); DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return;); } #endif diff -Nru duktape-2.3.0/src-input/duk_hstring.h duktape-2.2.0/src-input/duk_hstring.h --- duktape-2.3.0/src-input/duk_hstring.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hstring.h 2017-09-23 01:06:08.000000000 +0000 @@ -8,7 +8,7 @@ * strings used as internal property names and raw buffers converted to * strings. In such cases the 'clen' field contains an inaccurate value. * - * ECMAScript requires support for 32-bit long strings. However, since each + * Ecmascript requires support for 32-bit long strings. However, since each * 16-bit codepoint can take 3 bytes in CESU-8, this representation can only * support about 1.4G codepoint long strings in extreme cases. This is not * really a practical issue. @@ -32,15 +32,12 @@ #define DUK_HSTRING_MAX_BYTELEN (0x7fffffffUL) #endif -/* XXX: could add flags for "is valid CESU-8" (ECMAScript compatible strings), +/* XXX: could add flags for "is valid CESU-8" (Ecmascript compatible strings), * "is valid UTF-8", "is valid extended UTF-8" (internal strings are not, * regexp bytecode is), and "contains non-BMP characters". These are not * needed right now. */ -/* With lowmem builds the high 16 bits of duk_heaphdr are used for other - * purposes, so this leaves 7 duk_heaphdr flags and 9 duk_hstring flags. - */ #define DUK_HSTRING_FLAG_ASCII DUK_HEAPHDR_USER_FLAG(0) /* string is ASCII, clen == blen */ #define DUK_HSTRING_FLAG_ARRIDX DUK_HEAPHDR_USER_FLAG(1) /* string is a valid array index */ #define DUK_HSTRING_FLAG_SYMBOL DUK_HEAPHDR_USER_FLAG(2) /* string is a symbol (invalid utf-8) */ @@ -49,7 +46,6 @@ #define DUK_HSTRING_FLAG_STRICT_RESERVED_WORD DUK_HEAPHDR_USER_FLAG(5) /* string is a reserved word (strict) */ #define DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS DUK_HEAPHDR_USER_FLAG(6) /* string is 'eval' or 'arguments' */ #define DUK_HSTRING_FLAG_EXTDATA DUK_HEAPHDR_USER_FLAG(7) /* string data is external (duk_hstring_external) */ -#define DUK_HSTRING_FLAG_PINNED_LITERAL DUK_HEAPHDR_USER_FLAG(8) /* string is a literal, and pinned */ #define DUK_HSTRING_HAS_ASCII(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) #define DUK_HSTRING_HAS_ARRIDX(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) @@ -59,7 +55,6 @@ #define DUK_HSTRING_HAS_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) #define DUK_HSTRING_HAS_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) #define DUK_HSTRING_HAS_EXTDATA(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) -#define DUK_HSTRING_HAS_PINNED_LITERAL(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) #define DUK_HSTRING_SET_ASCII(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) #define DUK_HSTRING_SET_ARRIDX(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) @@ -69,7 +64,6 @@ #define DUK_HSTRING_SET_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) #define DUK_HSTRING_SET_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) #define DUK_HSTRING_SET_EXTDATA(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) -#define DUK_HSTRING_SET_PINNED_LITERAL(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) #define DUK_HSTRING_CLEAR_ASCII(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) #define DUK_HSTRING_CLEAR_ARRIDX(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) @@ -79,7 +73,6 @@ #define DUK_HSTRING_CLEAR_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) #define DUK_HSTRING_CLEAR_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) #define DUK_HSTRING_CLEAR_EXTDATA(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) -#define DUK_HSTRING_CLEAR_PINNED_LITERAL(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) #if 0 /* Slightly smaller code without explicit flag, but explicit flag * is very useful when 'clen' is dropped. diff -Nru duktape-2.3.0/src-input/duk_hstring_misc.c duktape-2.2.0/src-input/duk_hstring_misc.c --- duktape-2.3.0/src-input/duk_hstring_misc.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hstring_misc.c 2017-09-23 01:06:08.000000000 +0000 @@ -33,7 +33,7 @@ (const void *) p_start, (const void *) p_end, (const void *) p)); - /* For invalid UTF-8 (never happens for standard ECMAScript strings) + /* For invalid UTF-8 (never happens for standard Ecmascript strings) * return U+FFFD replacement character. */ if (duk_unicode_decode_xutf8(thr, &p, p_start, p_end, &cp1)) { @@ -189,7 +189,7 @@ if (len != DUK_HSTRING_GET_BYTELEN(h)) { return 0; } - if (duk_memcmp((const void *) cstr, (const void *) DUK_HSTRING_GET_DATA(h), len) == 0) { + if (DUK_MEMCMP((const void *) cstr, (const void *) DUK_HSTRING_GET_DATA(h), len) == 0) { return 1; } return 0; diff -Nru duktape-2.3.0/src-input/duk_hthread_alloc.c duktape-2.2.0/src-input/duk_hthread_alloc.c --- duktape-2.3.0/src-input/duk_hthread_alloc.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hthread_alloc.c 2017-09-23 01:06:08.000000000 +0000 @@ -30,7 +30,7 @@ if (!thr->valstack) { goto fail; } - duk_memzero(thr->valstack, alloc_size); + DUK_MEMZERO(thr->valstack, alloc_size); thr->valstack_end = thr->valstack + DUK_VALSTACK_API_ENTRY_MINIMUM; thr->valstack_alloc_end = thr->valstack + DUK_VALSTACK_INITIAL_SIZE; thr->valstack_bottom = thr->valstack; diff -Nru duktape-2.3.0/src-input/duk_hthread_builtins.c duktape-2.2.0/src-input/duk_hthread_builtins.c --- duktape-2.3.0/src-input/duk_hthread_builtins.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hthread_builtins.c 2017-09-23 01:06:08.000000000 +0000 @@ -75,7 +75,7 @@ props = DUK_ALLOC_CHECKED(thr, alloc_size); DUK_ASSERT(props != NULL); DUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, h_oldglobal) != NULL); - duk_memcpy((void *) props, (const void *) DUK_HOBJECT_GET_PROPS(thr->heap, h_oldglobal), alloc_size); + DUK_MEMCPY((void *) props, (const void *) DUK_HOBJECT_GET_PROPS(thr->heap, h_oldglobal), alloc_size); /* XXX: keep property attributes or tweak them here? * Properties will now be non-configurable even when they're @@ -202,7 +202,7 @@ DUK_D(DUK_DPRINT("INITBUILTINS BEGIN: DUK_NUM_BUILTINS=%d, DUK_NUM_BUILTINS_ALL=%d", (int) DUK_NUM_BUILTINS, (int) DUK_NUM_ALL_BUILTINS)); - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); bd->data = (const duk_uint8_t *) duk_builtins_data; bd->length = (duk_size_t) DUK_BUILTINS_DATA_LENGTH; @@ -444,9 +444,11 @@ * signaled using a single flag bit in the bitstream. */ - defprop_flags = (duk_small_uint_t) duk_bd_decode_flagged(bd, - DUK__PROP_FLAGS_BITS, - (duk_uint32_t) DUK_PROPDESC_FLAGS_WC); + if (duk_bd_decode_flag(bd)) { + defprop_flags = (duk_small_uint_t) duk_bd_decode(bd, DUK__PROP_FLAGS_BITS); + } else { + defprop_flags = DUK_PROPDESC_FLAGS_WC; + } defprop_flags |= DUK_DEFPROP_FORCE | DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | @@ -551,7 +553,6 @@ #if defined(DUK_USE_LIGHTFUNC_BUILTINS) duk_small_int_t lightfunc_eligible; #endif - duk_small_uint_t defprop_flags; duk__push_stridx_or_string(thr, bd); h_key = duk_known_hstring(thr, -1); @@ -671,19 +672,10 @@ lightfunc_skip: #endif - defprop_flags = (duk_small_uint_t) duk_bd_decode_flagged(bd, - DUK__PROP_FLAGS_BITS, - (duk_uint32_t) DUK_PROPDESC_FLAGS_WC); - defprop_flags |= DUK_DEFPROP_FORCE | - DUK_DEFPROP_HAVE_VALUE | - DUK_DEFPROP_HAVE_WRITABLE | - DUK_DEFPROP_HAVE_ENUMERABLE | - DUK_DEFPROP_HAVE_CONFIGURABLE; - DUK_ASSERT(DUK_PROPDESC_FLAG_WRITABLE == DUK_DEFPROP_WRITABLE); - DUK_ASSERT(DUK_PROPDESC_FLAG_ENUMERABLE == DUK_DEFPROP_ENUMERABLE); - DUK_ASSERT(DUK_PROPDESC_FLAG_CONFIGURABLE == DUK_DEFPROP_CONFIGURABLE); - - duk_def_prop(thr, (duk_idx_t) i, defprop_flags); + /* XXX: So far all ES builtins are 'wc' but e.g. + * performance.now() should be 'wec'. + */ + duk_xdef_prop(thr, (duk_idx_t) i, DUK_PROPDESC_FLAGS_WC); /* [ (builtin objects) ] */ } @@ -756,7 +748,7 @@ "f" #endif " " - /* Low memory/performance options */ + /* Low memory options */ #if defined(DUK_USE_STRTAB_PTRCOMP) "s" #endif @@ -797,9 +789,6 @@ */ "Z" #endif -#if defined(DUK_USE_LITCACHE_SIZE) - "l" -#endif " " /* Object property allocation layout */ #if defined(DUK_USE_HOBJECT_LAYOUT_1) diff -Nru duktape-2.3.0/src-input/duk_hthread.h duktape-2.2.0/src-input/duk_hthread.h --- duktape-2.3.0/src-input/duk_hthread.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hthread.h 2017-09-23 01:06:08.000000000 +0000 @@ -222,14 +222,14 @@ duk_instr_t *curr_pc; /* next instruction to execute (points to 'func' bytecode, stable pointer), NULL for native calls */ /* bottom_byteoff and retval_byteoff are only used for book-keeping - * of ECMAScript-initiated calls, to allow returning to an ECMAScript + * of Ecmascript-initiated calls, to allow returning to an Ecmascript * function properly. */ /* Bottom of valstack for this activation, used to reset * valstack_bottom on return; offset is absolute. There's * no need to track 'top' because native call handling deals - * with that using locals, and for ECMAScript returns 'nregs' + * with that using locals, and for Ecmascript returns 'nregs' * indicates the necessary top. */ duk_size_t bottom_byteoff; diff -Nru duktape-2.3.0/src-input/duk_hthread_stacks.c duktape-2.2.0/src-input/duk_hthread_stacks.c --- duktape-2.3.0/src-input/duk_hthread_stacks.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_hthread_stacks.c 2017-09-23 01:06:08.000000000 +0000 @@ -392,8 +392,8 @@ /* Use DUK_ALLOC_RAW() to avoid side effects. */ new_ptr = (duk_tval *) DUK_ALLOC_RAW(thr->heap, alloc_size); if (new_ptr != NULL) { - duk_memcpy((void *) new_ptr, (const void *) thr->valstack, alloc_size); - duk_memset((void *) thr->valstack, 0x55, alloc_size); + DUK_MEMCPY((void *) new_ptr, (const void *) thr->valstack, alloc_size); + DUK_MEMSET((void *) thr->valstack, 0x55, alloc_size); DUK_FREE_CHECKED(thr, (void *) thr->valstack); thr->valstack = new_ptr; thr->valstack_alloc_end = (duk_tval *) ((duk_uint8_t *) new_ptr + alloc_end_off); diff -Nru duktape-2.3.0/src-input/duk_js_arith.c duktape-2.2.0/src-input/duk_js_arith.c --- duktape-2.3.0/src-input/duk_js_arith.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_js_arith.c 2017-09-23 01:06:08.000000000 +0000 @@ -4,7 +4,7 @@ #include "duk_internal.h" -/* ECMAScript modulus ('%') does not match IEEE 754 "remainder" operation +/* Ecmascript modulus ('%') does not match IEEE 754 "remainder" operation * (implemented by remainder() in C99) but does seem to match ANSI C fmod(). * Compare E5 Section 11.5.3 and "man fmod". */ @@ -58,9 +58,9 @@ /* Shared helper for Math.pow() and exponentiation operator. */ DUK_INTERNAL double duk_js_arith_pow(double x, double y) { - /* The ANSI C pow() semantics differ from ECMAScript. + /* The ANSI C pow() semantics differ from Ecmascript. * - * E.g. when x==1 and y is +/- infinite, the ECMAScript required + * E.g. when x==1 and y is +/- infinite, the Ecmascript required * result is NaN, while at least Linux pow() returns 1. */ diff -Nru duktape-2.3.0/src-input/duk_js_bytecode.h duktape-2.2.0/src-input/duk_js_bytecode.h --- duktape-2.3.0/src-input/duk_js_bytecode.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_js_bytecode.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,5 +1,5 @@ /* - * ECMAScript bytecode + * Ecmascript bytecode */ #if !defined(DUK_JS_BYTECODE_H_INCLUDED) diff -Nru duktape-2.3.0/src-input/duk_js_call.c duktape-2.2.0/src-input/duk_js_call.c --- duktape-2.3.0/src-input/duk_js_call.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_js_call.c 2017-09-23 01:06:08.000000000 +0000 @@ -3,7 +3,7 @@ * * duk_handle_call_unprotected(): * - * - Unprotected call to ECMAScript or Duktape/C function, from native + * - Unprotected call to Ecmascript or Duktape/C function, from native * code or bytecode executor. * * - Also handles Ecma-to-Ecma calls which reuses a currently running @@ -57,7 +57,6 @@ DUK_D(DUK_DPRINT("call prevented because C recursion limit reached")); DUK_ERROR_RANGE(thr, DUK_STR_C_CALLSTACK_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL DUK_ALWAYS_INLINE void duk__call_c_recursion_limit_check(duk_hthread *thr) { @@ -93,7 +92,6 @@ */ DUK_D(DUK_DPRINT("call prevented because call stack limit reached")); DUK_ERROR_RANGE(thr, DUK_STR_CALLSTACK_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL DUK_ALWAYS_INLINE void duk__call_callstack_limit_check(duk_hthread *thr) { @@ -507,7 +505,6 @@ if (DUK_UNLIKELY(proxy_invariant != 0U)) { /* Proxy 'construct' return value invariant violated. */ DUK_ERROR_TYPE_INVALID_TRAP_RESULT(thr); - DUK_WO_NORETURN(return;); } /* XXX: direct value stack access */ duk_pop(thr); @@ -568,7 +565,7 @@ duk_tval *tv_args; duk_tval *tv_gap; - h_bound = (duk_hboundfunc *) (void *) func; + h_bound = (duk_hboundfunc *) func; tv_args = h_bound->args; len = h_bound->nargs; DUK_ASSERT(len == 0 || tv_args != NULL); @@ -608,7 +605,6 @@ } else { /* Shouldn't happen, so ugly error is enough. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); } DUK_ASSERT(duk_get_top(thr) >= idx_func + 2); @@ -784,13 +780,11 @@ if (top < idx_func + 3) { /* argArray is a mandatory argument for Reflect.construct(). */ DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); } if (top > idx_func + 3) { if (!duk_strict_equals(thr, idx_func, idx_func + 3)) { /* XXX: [[Construct]] newTarget currently unsupported */ DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } duk_set_top_unsafe(thr, idx_func + 3); /* remove any args beyond argArray */ } @@ -1327,7 +1321,6 @@ if (duk_hobject_find_existing_entry_tval_ptr(thr->heap, DUK_TVAL_GET_OBJECT(tv_func), DUK_HTHREAD_STRING_INT_TARGET(thr)) != NULL) { duk_push_tval(thr, tv_func); (void) duk_throw(thr); - DUK_WO_NORETURN(return NULL;); } } #endif @@ -1341,7 +1334,8 @@ #else DUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE); #endif - DUK_WO_NORETURN(return NULL;); + DUK_UNREACHABLE(); + return NULL; /* never executed */ not_constructable: /* For now GETPROPC delayed error not needed for constructor calls. */ @@ -1354,7 +1348,8 @@ #else DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONSTRUCTABLE); #endif - DUK_WO_NORETURN(return NULL;); + DUK_UNREACHABLE(); + return NULL; /* never executed */ } /* @@ -1378,7 +1373,6 @@ idx_rcbase = duk_get_top(thr) - num_actual_rets; /* base of known return values */ if (DUK_UNLIKELY(idx_rcbase < 0)) { DUK_ERROR_TYPE(thr, DUK_STR_INVALID_CFUNC_RC); - DUK_WO_NORETURN(return;); } DUK_DDD(DUK_DDDPRINT("adjust valstack after func call: " @@ -1513,10 +1507,9 @@ * - Disable StepOut processing for the activation unwind because * we reuse the activation, see: * https://github.com/svaarala/duktape/issues/1684. - * - Disable line change pause flag permanently if act == dbg_pause_act - * (if set) because it would no longer be relevant, see: - * https://github.com/svaarala/duktape/issues/1726, - * https://github.com/svaarala/duktape/issues/1786. + * - Disable line change pause flag permanently (if set) because + * it would no longer be relevant, see: + * https://github.com/svaarala/duktape/issues/1726. * - Check for function entry (e.g. StepInto) pause flag here, because * the executor pause check won't trigger due to shared activation, see: * https://github.com/svaarala/duktape/issues/1726. @@ -1537,12 +1530,9 @@ DUK_ASSERT(thr->callstack_top > 0); DUK_ASSERT(thr->callstack_curr != NULL); #if defined(DUK_USE_DEBUGGER_SUPPORT) - if (act == thr->heap->dbg_pause_act) { - thr->heap->dbg_pause_flags &= ~DUK_PAUSE_FLAG_LINE_CHANGE; - } - prev_pause_act = thr->heap->dbg_pause_act; thr->heap->dbg_pause_act = NULL; + thr->heap->dbg_pause_flags &= ~DUK_PAUSE_FLAG_LINE_CHANGE; if (thr->heap->dbg_pause_flags & DUK_PAUSE_FLAG_FUNC_ENTRY) { DUK_D(DUK_DPRINT("PAUSE TRIGGERED by function entry (tailcall)")); duk_debug_set_paused(thr->heap); @@ -1682,10 +1672,10 @@ * Update return value stack index of current activation (if any). * * Although it might seem this is not necessary (bytecode executor - * does this for ECMAScript-to-ECMAScript calls; other calls are + * does this for Ecmascript-to-Ecmascript calls; other calls are * handled here), this turns out to be necessary for handling yield - * and resume. For them, an ECMAScript-to-native call happens, and - * the ECMAScript call's retval_byteoff must be set for things to work. + * and resume. For them, an Ecmascript-to-native call happens, and + * the Ecmascript call's retval_byteoff must be set for things to work. */ act->retval_byteoff = entry_valstack_bottom_byteoff + (duk_size_t) idx_func * sizeof(duk_tval); @@ -1892,16 +1882,16 @@ thread_state_error: DUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, "invalid thread state (%ld)", (long) thr->state); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); } /* * Main unprotected call handler, handles: * - * - All combinations of native/ECMAScript caller and native/ECMAScript + * - All combinations of native/Ecmascript caller and native/Ecmascript * target. * - * - Optimized ECMAScript-to-ECMAScript call where call handling only + * - Optimized Ecmascript-to-Ecmascript call where call handling only * sets up a new duk_activation but reuses an existing bytecode executor * (the caller) without native recursion. * @@ -1950,7 +1940,7 @@ DUK_STATS_INC(thr->heap, stats_call_all); /* If a tail call: - * - an ECMAScript activation must be on top of the callstack + * - an Ecmascript activation must be on top of the callstack * - there cannot be any catch stack entries that would catch * a return */ @@ -2055,12 +2045,6 @@ * Because 'act' is not zeroed, all fields must be filled in. */ - /* Should not be necessary, but initialize to silence warnings. */ - act = NULL; - nargs = 0; - nregs = 0; - vs_min_bytes = 0; - #if defined(DUK_USE_TAILCALL) use_tailcall = (call_flags & DUK_CALL_FLAG_TAILCALL); if (use_tailcall) { @@ -2108,7 +2092,7 @@ * compiler; the compiled function's parent env will contain * the (immutable) binding already. * - * This handling is now identical for C and ECMAScript functions. + * This handling is now identical for C and Ecmascript functions. * C functions always have the 'NEWENV' flag set, so their * environment record initialization is delayed (which is good). * @@ -2155,7 +2139,7 @@ if (func != NULL && DUK_HOBJECT_IS_COMPFUNC(func)) { /* - * ECMAScript call. + * Ecmascript call. */ DUK_ASSERT(func != NULL); @@ -2249,10 +2233,9 @@ ; } else if (rc < 0) { duk_error_throw_from_negative_rc(thr, rc); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); } else { DUK_ERROR_TYPE(thr, DUK_STR_INVALID_CFUNC_RC); - DUK_WO_NORETURN(return 0;); } } DUK_ASSERT(thr->ptr_curr_pc == NULL); @@ -2340,7 +2323,7 @@ * calls caused by side effects (e.g. when doing a DUK_OP_GETPROP), see * GH-303. Only needed for success path, error path always causes a * breakpoint recheck in the executor. It would be enough to set this - * only when returning to an ECMAScript activation, but setting the flag + * only when returning to an Ecmascript activation, but setting the flag * on every return should have no ill effect. */ #if defined(DUK_USE_DEBUGGER_SUPPORT) @@ -2452,7 +2435,6 @@ if (DUK_UNLIKELY(rc < 0)) { duk_error_throw_from_negative_rc(thr, rc); - DUK_WO_NORETURN(return;); } DUK_ASSERT(rc >= 0); @@ -2730,10 +2712,7 @@ retval = DUK_EXEC_ERROR; } #if defined(DUK_USE_CPP_EXCEPTIONS) - catch (duk_fatal_exception &exc) { - DUK_D(DUK_DPRINT("rethrow duk_fatal_exception")); - throw; - } catch (std::exception &exc) { + catch (std::exception &exc) { const char *what = exc.what(); DUK_ASSERT((duk_size_t) ((duk_uint8_t *) thr->valstack_end - (duk_uint8_t *) thr->valstack) >= entry_valstack_end_byteoff); DUK_STATS_INC(thr->heap, stats_safecall_throw); @@ -2743,7 +2722,6 @@ DUK_D(DUK_DPRINT("unexpected c++ std::exception (perhaps thrown by user code)")); try { DUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, "caught invalid c++ std::exception '%s' (perhaps thrown by user code)", what); - DUK_WO_NORETURN(return 0;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ std::exception")); DUK_UNREF(exc); @@ -2766,7 +2744,6 @@ DUK_STATS_INC(thr->heap, stats_safecall_throw); try { DUK_ERROR_TYPE(thr, "caught invalid c++ exception (perhaps thrown by user code)"); - DUK_WO_NORETURN(return 0;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ exception")); DUK_UNREF(exc); @@ -2826,7 +2803,7 @@ /* * Property-based call (foo.noSuch()) error setup: replace target function * on stack top with a specially tagged (hidden Symbol) error which gets - * thrown in call handling at the proper spot to follow ECMAScript semantics. + * thrown in call handling at the proper spot to follow Ecmascript semantics. */ #if defined(DUK_USE_VERBOSE_ERRORS) diff -Nru duktape-2.3.0/src-input/duk_js_compiler.c duktape-2.2.0/src-input/duk_js_compiler.c --- duktape-2.3.0/src-input/duk_js_compiler.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_js_compiler.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,5 +1,5 @@ /* - * ECMAScript compiler. + * Ecmascript compiler. * * Parses an input string and generates a function template result. * Compilation may happen in multiple contexts (global code, eval @@ -235,9 +235,9 @@ DUK_LOCAL_DECL void duk__parse_with_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res); DUK_LOCAL_DECL void duk__parse_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_bool_t allow_source_elem); DUK_LOCAL_DECL duk_int_t duk__stmt_label_site(duk_compiler_ctx *comp_ctx, duk_int_t label_id); -DUK_LOCAL_DECL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof, duk_bool_t regexp_after); +DUK_LOCAL_DECL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof); -DUK_LOCAL_DECL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_bool_t regexp_after, duk_small_int_t expect_token); +DUK_LOCAL_DECL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_small_int_t expect_token); DUK_LOCAL_DECL void duk__parse_func_formals(duk_compiler_ctx *comp_ctx); DUK_LOCAL_DECL void duk__parse_func_like_raw(duk_compiler_ctx *comp_ctx, duk_small_uint_t flags); DUK_LOCAL_DECL duk_int_t duk__parse_func_like_fnum(duk_compiler_ctx *comp_ctx, duk_small_uint_t flags); @@ -409,7 +409,6 @@ DUK_ASSERT(comp_ctx->recursion_depth >= 0); if (comp_ctx->recursion_depth >= comp_ctx->recursion_limit) { DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_COMPILER_RECURSION_LIMIT); - DUK_WO_NORETURN(return;); } comp_ctx->recursion_depth++; } @@ -464,20 +463,15 @@ comp_ctx->curr_func.reject_regexp_in_adv = 0; regexp = 0; } - if (comp_ctx->curr_func.allow_regexp_in_adv) { - comp_ctx->curr_func.allow_regexp_in_adv = 0; - regexp = 1; - } if (expect >= 0 && comp_ctx->curr_token.t != (duk_small_uint_t) expect) { DUK_D(DUK_DPRINT("parse error: expect=%ld, got=%ld", (long) expect, (long) comp_ctx->curr_token.t)); DUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR); - DUK_WO_NORETURN(return;); } /* make current token the previous; need to fiddle with valstack "backing store" */ - duk_memcpy(&comp_ctx->prev_token, &comp_ctx->curr_token, sizeof(duk_token)); + DUK_MEMCPY(&comp_ctx->prev_token, &comp_ctx->curr_token, sizeof(duk_token)); duk_copy(thr, comp_ctx->tok11_idx, comp_ctx->tok21_idx); duk_copy(thr, comp_ctx->tok12_idx, comp_ctx->tok22_idx); @@ -525,7 +519,7 @@ entry_top = duk_get_top(thr); - duk_memzero(func, sizeof(*func)); /* intentional overlap with earlier memzero */ + DUK_MEMZERO(func, sizeof(*func)); /* intentional overlap with earlier memzero */ #if defined(DUK_USE_EXPLICIT_NULL_INIT) func->h_name = NULL; func->h_consts = NULL; @@ -772,7 +766,7 @@ (long) code_size, (long) data_size)); duk_push_fixed_buffer_nozero(thr, data_size); - h_data = (duk_hbuffer_fixed *) (void *) duk_known_hbuffer(thr, -1); + h_data = (duk_hbuffer_fixed *) duk_known_hbuffer(thr, -1); DUK_HCOMPFUNC_SET_DATA(thr->heap, h_res, (duk_hbuffer *) h_data); DUK_HEAPHDR_INCREF(thr, h_data); @@ -977,7 +971,7 @@ */ #if 0 - duk_push_literal(thr, "XXX"); + duk_push_string(thr, "XXX"); duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_INT_SOURCE, DUK_PROPDESC_FLAGS_NONE); #endif } @@ -1176,7 +1170,6 @@ fail_bc_limit: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_BYTECODE_LIMIT); - DUK_WO_NORETURN(return;); } /* Update function min/max line from current token. Needed to improve @@ -1461,7 +1454,6 @@ error_outofregs: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } /* For many of the helpers below it'd be technically correct to add @@ -1560,7 +1552,6 @@ error_outofregs: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__emit_bc(duk_compiler_ctx *comp_ctx, duk_small_uint_t op, duk_regconst_t bc) { @@ -1595,7 +1586,6 @@ error_outofregs: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__emit_load_int32_raw(duk_compiler_ctx *comp_ctx, duk_regconst_t reg, duk_int32_t val, duk_small_uint_t op_flags) { @@ -1693,7 +1683,6 @@ fail_bc_limit: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_BYTECODE_LIMIT); - DUK_WO_NORETURN(return;); } /* Does not assume that jump_pc contains a DUK_OP_JUMP previously; this is intentional @@ -1749,7 +1738,6 @@ DUK_D(DUK_DPRINT("failed to patch trycatch: flags=%ld, reg_catch=%ld, const_varname=%ld (0x%08lx)", (long) flags, (long) reg_catch, (long) const_varname, (long) const_varname)); DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } instr->ins |= DUK_ENC_OP_A_BC(0, 0, const_varname); } else { @@ -1941,7 +1929,6 @@ if (comp_ctx->curr_func.temp_next > DUK__MAX_TEMPS) { /* == DUK__MAX_TEMPS is OK */ DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_TEMP_LIMIT); - DUK_WO_NORETURN(return 0;); } /* maintain highest 'used' temporary, needed to figure out nregs of function */ @@ -2001,7 +1988,6 @@ if (n > DUK__MAX_CONSTS) { DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_CONST_LIMIT); - DUK_WO_NORETURN(return 0;); } DUK_DDD(DUK_DDDPRINT("allocating new constant for %!T -> const index %ld", @@ -2175,7 +2161,6 @@ } } } /* end switch */ - goto fail_internal; /* never here */ } case DUK_ISPEC_REGCONST: { if (forced_reg >= 0) { @@ -2208,13 +2193,12 @@ return x->regconst; } default: { - break; /* never here */ + break; } } - fail_internal: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_LOCAL void duk__ispec_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ispec *x, duk_regconst_t forced_reg) { @@ -2287,10 +2271,7 @@ break; } case DUK_OP_DIV: { - /* Division-by-zero is undefined - * behavior, so rely on a helper. - */ - d3 = duk_double_div(d1, d2); + d3 = d1 / d2; break; } case DUK_OP_EXP: { @@ -2317,7 +2298,7 @@ } } else if (x->op == DUK_OP_ADD && DUK_TVAL_IS_STRING(tv1) && DUK_TVAL_IS_STRING(tv2)) { /* Inline string concatenation. No need to check for - * symbols, as all inputs are valid ECMAScript strings. + * symbols, as all inputs are valid Ecmascript strings. */ duk_dup(thr, x->x1.valstack_idx); duk_dup(thr, x->x2.valstack_idx); @@ -2415,7 +2396,7 @@ } DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); + return; } /* evaluate to plain value, no forced register (temp/bound reg both ok) */ @@ -2647,7 +2628,6 @@ if (li->h_label == h_label && h_label != DUK_HTHREAD_STRING_EMPTY_STRING(thr)) { DUK_ERROR_SYNTAX(thr, DUK_STR_DUPLICATE_LABEL); - DUK_WO_NORETURN(return;); } } @@ -2777,7 +2757,6 @@ */ if (h_label != DUK_HTHREAD_STRING_EMPTY_STRING(thr)) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LABEL); - DUK_WO_NORETURN(return;); } else { DUK_DDD(DUK_DDDPRINT("continue matched an empty label which does not " "allow a continue -> continue lookup deeper in label stack")); @@ -2787,7 +2766,6 @@ /* XXX: match flag is awkward, rework */ if (!match) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LABEL); - DUK_WO_NORETURN(return;); } DUK_DDD(DUK_DDDPRINT("label match: %!O -> label_id %ld, catch_depth=%ld, pc_label=%ld", @@ -2977,7 +2955,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_ARRAY_LITERAL); - DUK_WO_NORETURN(return;); } typedef struct { @@ -3254,14 +3231,13 @@ #endif DUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_RCURLY); - duk__advance(comp_ctx); /* No RegExp after object literal. */ + duk__advance(comp_ctx); duk__ivalue_regconst(res, st.reg_obj); return; syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_OBJECT_LITERAL); - DUK_WO_NORETURN(return;); } /* Parse argument list. Arguments are written to temps starting from @@ -3305,7 +3281,7 @@ } /* eat the right paren */ - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* RegExp mode does not matter. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); DUK_DDD(DUK_DDDPRINT("end parsing arguments")); @@ -3438,7 +3414,7 @@ duk__expr(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); /* Expression, terminates at a ')' */ - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* No RegExp after parenthesized expression. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); comp_ctx->curr_func.allow_in = prev_allow_in; comp_ctx->curr_func.paren_level--; return; @@ -3573,7 +3549,6 @@ if (comp_ctx->curr_func.is_strict) { DUK_ERROR_SYNTAX(thr, DUK_STR_CANNOT_DELETE_IDENTIFIER); - DUK_WO_NORETURN(return;); } DUK__SETTEMP(comp_ctx, temp_at_entry); @@ -3738,7 +3713,7 @@ } /* end switch */ DUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR); - DUK_WO_NORETURN(return;); + return; unary: { @@ -3842,12 +3817,10 @@ #if defined(DUK_USE_ES6) syntax_error_newtarget: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_NEWTARGET); - DUK_WO_NORETURN(return;); #endif syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_EXPRESSION); - DUK_WO_NORETURN(return;); } /* XXX: add flag to indicate whether caller cares about return value; this @@ -3902,7 +3875,6 @@ /* NB: must accept reserved words as property name */ if (comp_ctx->curr_token.t_nores != DUK_TOK_IDENTIFIER) { DUK_ERROR_SYNTAX(thr, DUK_STR_EXPECTED_IDENTIFIER); - DUK_WO_NORETURN(return;); } res->t = DUK_IVAL_PROP; @@ -4332,7 +4304,7 @@ DUK_D(DUK_DPRINT("parse error: unexpected token: %ld", (long) tok)); DUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR); - DUK_WO_NORETURN(return;); + return; #if 0 /* XXX: shared handling for 'duk__expr_lhs'? */ @@ -4562,7 +4534,7 @@ * one instruction, so use explicit PC computation. */ DUK_DD(DUK_DDPRINT("rhs is side effect free, rewind and avoid unnecessary temp for reg-based =")); - DUK_BW_ADD_PTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, (pc_temp_load - pc_before_rhs) * (duk_int_t) sizeof(duk_compiler_instr)); + DUK_BW_ADD_PTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, (duk_size_t) (pc_temp_load - pc_before_rhs) * sizeof(duk_compiler_instr)); reg_src = reg_varbind; } else { DUK_DD(DUK_DDPRINT("rhs evaluation emitted code, not sure if rhs is side effect free; use temp reg for LHS")); @@ -4822,11 +4794,11 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_EXPRESSION); - DUK_WO_NORETURN(return;); + return; syntax_error_lvalue: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LVALUE); - DUK_WO_NORETURN(return;); + return; } DUK_LOCAL duk_small_uint_t duk__expr_lbp(duk_compiler_ctx *comp_ctx) { @@ -4891,7 +4863,7 @@ (long) rbp_flags, (long) rbp, (long) comp_ctx->curr_func.allow_in, (long) comp_ctx->curr_func.paren_level)); - duk_memzero(&tmp_alloc, sizeof(tmp_alloc)); + DUK_MEMZERO(&tmp_alloc, sizeof(tmp_alloc)); tmp->x1.valstack_idx = duk_get_top(thr); tmp->x2.valstack_idx = tmp->x1.valstack_idx + 1; duk_push_undefined(thr); @@ -4911,7 +4883,6 @@ DUK_DDD(DUK_DDDPRINT("empty expression")); if (!(rbp_flags & DUK__EXPR_FLAG_ALLOW_EMPTY)) { DUK_ERROR_SYNTAX(thr, DUK_STR_EMPTY_EXPR_NOT_ALLOWED); - DUK_WO_NORETURN(return;); } duk_push_undefined(thr); duk__ivalue_plain_fromstack(comp_ctx, res); @@ -4950,7 +4921,6 @@ if (!(rbp_flags & DUK__EXPR_FLAG_ALLOW_EMPTY) && duk__expr_is_empty(comp_ctx)) { DUK_ERROR_SYNTAX(thr, DUK_STR_EMPTY_EXPR_NOT_ALLOWED); - DUK_WO_NORETURN(return;); } } @@ -5143,7 +5113,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_VAR_DECLARATION); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_var_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t expr_flags) { @@ -5375,8 +5344,7 @@ } DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); pc_l3 = duk__get_current_pc(comp_ctx); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -5467,8 +5435,7 @@ pc_jumpto_l4 = duk__emit_jump_empty(comp_ctx); DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); pc_l3 = duk__get_current_pc(comp_ctx); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -5517,7 +5484,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_FOR); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_switch_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site) { @@ -5559,7 +5525,7 @@ duk__advance(comp_ctx); duk__advance_expect(comp_ctx, DUK_TOK_LPAREN); rc_switch = duk__exprtop_toregconst(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* RegExp mode does not matter. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__advance_expect(comp_ctx, DUK_TOK_LCURLY); DUK_DDD(DUK_DDDPRINT("switch value in register %ld", (long) rc_switch)); @@ -5684,8 +5650,7 @@ } DUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_RCURLY); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance(comp_ctx); /* Allow RegExp as part of next stmt. */ + duk__advance(comp_ctx); /* default case control flow patchup; note that if pc_prevcase < 0 * (i.e. no case clauses), control enters default case automatically. @@ -5718,7 +5683,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_SWITCH); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_if_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res) { @@ -5738,8 +5702,7 @@ pc_jump_false = duk__emit_jump_empty(comp_ctx); /* jump to end or else part */ DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -5775,7 +5738,7 @@ DUK_DDD(DUK_DDDPRINT("begin parsing do statement")); - duk__advance(comp_ctx); /* Eat 'do'; allow RegExp as part of next stmt. */ + duk__advance(comp_ctx); /* eat 'do' */ pc_start = duk__get_current_pc(comp_ctx); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -5789,7 +5752,6 @@ duk__emit_jump(comp_ctx, pc_start); /* no need to reset temps, as we're finished emitting code */ - comp_ctx->curr_func.allow_regexp_in_adv = 1; /* Allow RegExp as part of next stmt. */ duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__patch_jump_here(comp_ctx, pc_label_site + 1); /* break jump */ @@ -5819,8 +5781,7 @@ pc_jump_false = duk__emit_jump_empty(comp_ctx); DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); duk__emit_jump(comp_ctx, pc_start); @@ -5856,7 +5817,6 @@ duk__advance(comp_ctx); } else { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_BREAK_CONT_LABEL); - DUK_WO_NORETURN(return;); } /* Use a fast break/continue when possible. A fast break/continue is @@ -5898,7 +5858,6 @@ */ if (!comp_ctx->curr_func.is_function) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_RETURN); - DUK_WO_NORETURN(return;); } if (comp_ctx->curr_token.t == DUK_TOK_SEMICOLON || /* explicit semi follows */ @@ -6000,7 +5959,6 @@ if (comp_ctx->curr_token.lineterm) { DUK_ERROR_SYNTAX(comp_ctx->thr, DUK_STR_INVALID_THROW); - DUK_WO_NORETURN(return;); } reg_val = duk__exprtop_toreg(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); @@ -6057,9 +6015,10 @@ /* try part */ duk__advance_expect(comp_ctx, DUK_TOK_LCURLY); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ - duk__emit_op_only(comp_ctx, DUK_OP_ENDTRY); + duk__emit_op_only(comp_ctx, + DUK_OP_ENDTRY); if (comp_ctx->curr_token.t == DUK_TOK_CATCH) { /* @@ -6155,7 +6114,7 @@ DUK_DDD(DUK_DDDPRINT("varmap before parsing catch clause: %!iT", (duk_tval *) duk_get_tval(thr, comp_ctx->curr_func.varmap_idx))); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ if (varmap_value == -2) { @@ -6197,7 +6156,7 @@ duk__advance(comp_ctx); duk__advance_expect(comp_ctx, DUK_TOK_LCURLY); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ duk__emit_abc(comp_ctx, DUK_OP_ENDFIN, @@ -6240,7 +6199,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_TRY); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_with_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res) { @@ -6251,7 +6209,6 @@ if (comp_ctx->curr_func.is_strict) { DUK_ERROR_SYNTAX(comp_ctx->thr, DUK_STR_WITH_IN_STRICT_MODE); - DUK_WO_NORETURN(return;); } comp_ctx->curr_func.catch_depth++; @@ -6262,8 +6219,7 @@ duk__advance_expect(comp_ctx, DUK_TOK_LPAREN); duk__exprtop_toforcedreg(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/, reg_catch); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); pc_trycatch = duk__get_current_pc(comp_ctx); trycatch_flags = DUK_BC_TRYCATCH_FLAG_WITH_BINDING; @@ -6275,7 +6231,8 @@ duk__emit_invalid(comp_ctx); /* finished jump */ duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); - duk__emit_op_only(comp_ctx, DUK_OP_ENDTRY); + duk__emit_op_only(comp_ctx, + DUK_OP_ENDTRY); pc_finished = duk__get_current_pc(comp_ctx); @@ -6442,14 +6399,13 @@ break; } else { DUK_ERROR_SYNTAX(thr, DUK_STR_FUNC_STMT_NOT_ALLOWED); - DUK_WO_NORETURN(return;); } break; } case DUK_TOK_LCURLY: { DUK_DDD(DUK_DDDPRINT("block statement")); duk__advance(comp_ctx); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ if (label_id >= 0) { duk__patch_jump_here(comp_ctx, pc_at_entry + 1); /* break jump */ @@ -6703,7 +6659,7 @@ */ if (DUK_HSTRING_GET_BYTELEN(h_dir) == 10 && - DUK_STRCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use strict") == 0) { + DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use strict", 10) == 0) { #if defined(DUK_USE_STRICT_DECL) DUK_DDD(DUK_DDDPRINT("use strict directive detected: strict flag %ld -> %ld", (long) comp_ctx->curr_func.is_strict, (long) 1)); @@ -6712,7 +6668,7 @@ DUK_DDD(DUK_DDDPRINT("use strict detected but strict declarations disabled, ignoring")); #endif } else if (DUK_HSTRING_GET_BYTELEN(h_dir) == 14 && - DUK_STRCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use duk notail") == 0) { + DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use duk notail", 14) == 0) { DUK_DDD(DUK_DDDPRINT("use duk notail directive detected: notail flag %ld -> %ld", (long) comp_ctx->curr_func.is_notail, (long) 1)); comp_ctx->curr_func.is_notail = 1; @@ -6780,7 +6736,6 @@ "even though no lineterm present before next token)")); } else { DUK_ERROR_SYNTAX(thr, DUK_STR_UNTERMINATED_STMT); - DUK_WO_NORETURN(return;); } } } else { @@ -6829,7 +6784,7 @@ * (EOF or closing brace). */ -DUK_LOCAL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof, duk_bool_t regexp_after) { +DUK_LOCAL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof) { duk_hthread *thr = comp_ctx->thr; duk_ivalue res_alloc; duk_ivalue *res = &res_alloc; @@ -6843,7 +6798,7 @@ * for nested functions (which may occur inside expressions). */ - duk_memzero(&res_alloc, sizeof(res_alloc)); + DUK_MEMZERO(&res_alloc, sizeof(res_alloc)); res->t = DUK_IVAL_PLAIN; res->x1.t = DUK_ISPEC_VALUE; res->x1.valstack_idx = duk_get_top(thr); @@ -6877,15 +6832,6 @@ duk__parse_stmt(comp_ctx, res, allow_source_elem); } - /* RegExp is allowed / not allowed depending on context. For function - * declarations RegExp is allowed because it follows a function - * declaration statement and may appear as part of the next statement. - * For function expressions RegExp is not allowed, and it's possible - * to do something like '(function () {} / 123)'. - */ - if (regexp_after) { - comp_ctx->curr_func.allow_regexp_in_adv = 1; - } duk__advance(comp_ctx); /* Tear down state. */ @@ -7209,11 +7155,13 @@ error_outofregs: DUK_ERROR_RANGE(thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); + return; error_argname: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_ARG_NAME); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); + return; } /* @@ -7250,7 +7198,7 @@ * token (EOF or closing brace). */ -DUK_LOCAL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_bool_t regexp_after, duk_small_int_t expect_token) { +DUK_LOCAL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_small_int_t expect_token) { duk_compiler_func *func; duk_hthread *thr; duk_regconst_t reg_stmt_value = -1; @@ -7322,9 +7270,7 @@ func->max_line = 0; #endif - /* duk__parse_stmts() expects curr_tok to be set; parse in "allow - * regexp literal" mode with current strictness. - */ + /* duk__parse_stmts() expects curr_tok to be set; parse in "allow regexp literal" mode with current strictness */ if (expect_token >= 0) { /* Eating a left curly; regexp mode is allowed by left curly * based on duk__token_lbp[] automatically. @@ -7343,8 +7289,7 @@ DUK_DDD(DUK_DDDPRINT("begin 1st pass")); duk__parse_stmts(comp_ctx, 1, /* allow source elements */ - expect_eof, /* expect EOF instead of } */ - regexp_after); /* regexp after */ + expect_eof); /* expect EOF instead of } */ DUK_DDD(DUK_DDDPRINT("end 1st pass")); /* @@ -7451,8 +7396,7 @@ DUK_DDD(DUK_DDDPRINT("begin 2nd pass")); duk__parse_stmts(comp_ctx, 1, /* allow source elements */ - expect_eof, /* expect EOF instead of } */ - regexp_after); /* regexp after */ + expect_eof); /* expect EOF instead of } */ DUK_DDD(DUK_DDDPRINT("end 2nd pass")); duk__update_lineinfo_currtoken(comp_ctx); @@ -7465,7 +7409,6 @@ /* Should never happen but avoid infinite loop just in case. */ DUK_D(DUK_DPRINT("more than 3 compile passes needed, should never happen")); DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); } DUK_D(DUK_DPRINT("need additional round to compile function, round now %d", (int) compile_round)); } @@ -7509,7 +7452,6 @@ error_funcname: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_FUNC_NAME); - DUK_WO_NORETURN(return;); } /* @@ -7558,7 +7500,6 @@ if (comp_ctx->curr_token.t != DUK_TOK_IDENTIFIER) { DUK_ERROR_SYNTAX(thr, DUK_STR_EXPECTED_IDENTIFIER); - DUK_WO_NORETURN(return;); } DUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_IDENTIFIER); DUK_ASSERT(comp_ctx->curr_token.str1 != NULL); @@ -7624,7 +7565,6 @@ duk_to_string(thr, -1); } else { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_GETSET_NAME); - DUK_WO_NORETURN(return;); } comp_ctx->curr_func.h_name = duk_known_hstring(thr, -1); /* borrowed reference */ } else { @@ -7642,7 +7582,6 @@ no_advance = 1; if (flags & DUK__FUNC_FLAG_DECL) { DUK_ERROR_SYNTAX(thr, DUK_STR_FUNC_NAME_REQUIRED); - DUK_WO_NORETURN(return;); } } } @@ -7676,7 +7615,6 @@ duk__parse_func_body(comp_ctx, 0, /* expect_eof */ 0, /* implicit_return_value */ - flags & DUK__FUNC_FLAG_DECL, /* regexp_after */ DUK_TOK_LCURLY); /* expect_token */ /* @@ -7729,14 +7667,6 @@ comp_ctx->curr_token.t = 0; /* this is needed for regexp mode */ comp_ctx->curr_token.start_line = 0; /* needed for line number tracking (becomes prev_token.start_line) */ duk__advance(comp_ctx); - - /* RegExp is not allowed after a function expression, e.g. in - * (function () {} / 123). A RegExp *is* allowed after a - * function declaration! - */ - if (flags & DUK__FUNC_FLAG_DECL) { - comp_ctx->curr_func.allow_regexp_in_adv = 1; - } duk__advance_expect(comp_ctx, DUK_TOK_RCURLY); return fnum; @@ -7751,9 +7681,9 @@ DUK_DDD(DUK_DDDPRINT("before func: entry_top=%ld, curr_tok.start_offset=%ld", (long) entry_top, (long) comp_ctx->curr_token.start_offset)); - duk_memcpy(&old_func, &comp_ctx->curr_func, sizeof(duk_compiler_func)); + DUK_MEMCPY(&old_func, &comp_ctx->curr_func, sizeof(duk_compiler_func)); - duk_memzero(&comp_ctx->curr_func, sizeof(duk_compiler_func)); + DUK_MEMZERO(&comp_ctx->curr_func, sizeof(duk_compiler_func)); duk__init_func_valstack_slots(comp_ctx); DUK_ASSERT(comp_ctx->curr_func.num_formals == 0); @@ -7795,7 +7725,6 @@ if (fnum > DUK__MAX_FUNCS) { DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_FUNC_LIMIT); - DUK_WO_NORETURN(return 0;); } /* array writes autoincrement length */ @@ -7820,7 +7749,7 @@ } else { duk_set_top(thr, entry_top); } - duk_memcpy((void *) &comp_ctx->curr_func, (void *) &old_func, sizeof(duk_compiler_func)); + DUK_MEMCPY((void *) &comp_ctx->curr_func, (void *) &old_func, sizeof(duk_compiler_func)); return fnum; } @@ -7829,7 +7758,7 @@ * Compile input string into an executable function template without * arguments. * - * The string is parsed as the "Program" production of ECMAScript E5. + * The string is parsed as the "Program" production of Ecmascript E5. * Compilation context can be either global code or eval code (see E5 * Sections 14 and 15.1.2.1). * @@ -7970,7 +7899,6 @@ duk__parse_func_body(comp_ctx, 1, /* expect_eof */ 1, /* implicit_return_value */ - 1, /* regexp_after (does not matter) */ -1); /* expect_token */ } @@ -7998,7 +7926,7 @@ DUK_ASSERT(src_buffer != NULL); /* preinitialize lexer state partially */ - duk_memzero(&comp_stk, sizeof(comp_stk)); + DUK_MEMZERO(&comp_stk, sizeof(comp_stk)); comp_stk.flags = flags; DUK_LEXER_INITCTX(&comp_stk.comp_ctx_alloc.lex); comp_stk.comp_ctx_alloc.lex.input = src_buffer; @@ -8015,7 +7943,6 @@ if (safe_rc != DUK_EXEC_SUCCESS) { DUK_D(DUK_DPRINT("compilation failed: %!T", duk_get_tval(thr, -1))); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } /* [ ... template ] */ diff -Nru duktape-2.3.0/src-input/duk_js_compiler.h duktape-2.2.0/src-input/duk_js_compiler.h --- duktape-2.3.0/src-input/duk_js_compiler.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_js_compiler.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,11 +1,11 @@ /* - * ECMAScript compiler. + * Ecmascript compiler. */ #if !defined(DUK_JS_COMPILER_H_INCLUDED) #define DUK_JS_COMPILER_H_INCLUDED -/* ECMAScript compiler limits */ +/* ecmascript compiler limits */ #define DUK_COMPILER_TOKEN_LIMIT 100000000L /* 1e8: protects against deeply nested inner functions */ /* maximum loopcount for peephole optimization */ @@ -187,7 +187,6 @@ duk_uint8_t is_arguments_shadowed; /* argument/function declaration shadows 'arguments' */ duk_uint8_t needs_shuffle; /* function needs shuffle registers */ duk_uint8_t reject_regexp_in_adv; /* reject RegExp literal on next advance() call; needed for handling IdentifierName productions */ - duk_uint8_t allow_regexp_in_adv; /* allow RegExp literal on next advance() call */ }; struct duk_compiler_ctx { diff -Nru duktape-2.3.0/src-input/duk_js_executor.c duktape-2.2.0/src-input/duk_js_executor.c --- duktape-2.3.0/src-input/duk_js_executor.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_js_executor.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,5 +1,5 @@ /* - * ECMAScript bytecode executor. + * Ecmascript bytecode executor. */ #include "duk_internal.h" @@ -50,7 +50,7 @@ tv_dst = thr->valstack_top; copy_size = sizeof(duk_tval) * count; - duk_memcpy((void *) tv_dst, (const void *) tv_src, copy_size); + DUK_MEMCPY((void *) tv_dst, (const void *) tv_src, copy_size); for (i = 0; i < count; i++) { DUK_TVAL_INCREF(thr, tv_dst); tv_dst++; @@ -314,10 +314,7 @@ break; } case DUK_OP_DIV >> 2: { - /* Division-by-zero is undefined behavior, so - * rely on a helper. - */ - du.d = duk_double_div(d1, d2); + du.d = d1 / d2; break; } case DUK_OP_MOD >> 2: { @@ -774,7 +771,7 @@ * top are combined into one pass. */ -/* Reconfigure value stack for return to an ECMAScript function at +/* Reconfigure value stack for return to an Ecmascript function at * callstack top (caller unwinds). */ DUK_LOCAL void duk__reconfig_valstack_ecma_return(duk_hthread *thr) { @@ -790,7 +787,7 @@ /* Clamp so that values at 'clamp_top' and above are wiped and won't * retain reachable garbage. Then extend to 'nregs' because we're - * returning to an ECMAScript function. + * returning to an Ecmascript function. */ h_func = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act); @@ -806,7 +803,7 @@ /* XXX: a best effort shrink check would be OK here */ } -/* Reconfigure value stack for an ECMAScript catcher. Use topmost catcher +/* Reconfigure value stack for an Ecmascript catcher. Use topmost catcher * in 'act'. */ DUK_LOCAL void duk__reconfig_valstack_ecma_catcher(duk_hthread *thr, duk_activation *act) { @@ -1042,7 +1039,7 @@ act_resumer = resumer->callstack_curr; DUK_ASSERT(act_resumer != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(act_resumer) != NULL); - DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(act_resumer))); /* resume caller must be an ECMAScript func */ + DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(act_resumer))); /* resume caller must be an ecmascript func */ tv1 = (duk_tval *) (void *) ((duk_uint8_t *) resumer->valstack + act_resumer->retval_byteoff); /* return value from Duktape.Thread.resume() */ DUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv_val_unstable); /* side effects */ /* XXX: avoid side effects */ @@ -1098,7 +1095,7 @@ /* duk_bi_duk_object_yield() and duk_bi_duk_object_resume() ensure all of these are met */ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); /* unchanged by Duktape.Thread.resume() */ - DUK_ASSERT(thr->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(thr->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(thr->callstack_curr != NULL); DUK_ASSERT(thr->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL && @@ -1116,7 +1113,7 @@ DUK_ASSERT(resumee->state == DUK_HTHREAD_STATE_INACTIVE || resumee->state == DUK_HTHREAD_STATE_YIELDED); /* checked by Duktape.Thread.resume() */ DUK_ASSERT(resumee->state != DUK_HTHREAD_STATE_YIELDED || - resumee->callstack_top >= 2); /* YIELDED: ECMAScript activation + Duktape.Thread.yield() activation */ + resumee->callstack_top >= 2); /* YIELDED: Ecmascript activation + Duktape.Thread.yield() activation */ DUK_ASSERT(resumee->state != DUK_HTHREAD_STATE_YIELDED || (DUK_ACT_GET_FUNC(resumee->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(resumee->callstack_curr)) && @@ -1154,8 +1151,8 @@ goto check_longjmp; } else if (resumee->state == DUK_HTHREAD_STATE_YIELDED) { /* Unwind previous Duktape.Thread.yield() call. The - * activation remaining must always be an ECMAScript - * call now (yield() accepts calls from ECMAScript + * activation remaining must always be an Ecmascript + * call now (yield() accepts calls from Ecmascript * only). */ duk_activation *act_resumee; @@ -1163,7 +1160,7 @@ DUK_ASSERT(resumee->callstack_top >= 2); act_resumee = resumee->callstack_curr; /* Duktape.Thread.yield() */ DUK_ASSERT(act_resumee != NULL); - act_resumee = act_resumee->parent; /* ECMAScript call site for yield() */ + act_resumee = act_resumee->parent; /* Ecmascript call site for yield() */ DUK_ASSERT(act_resumee != NULL); tv = (duk_tval *) (void *) ((duk_uint8_t *) resumee->valstack + act_resumee->retval_byteoff); /* return value from Duktape.Thread.yield() */ @@ -1211,7 +1208,6 @@ * executor which can be quite misleading. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); } DUK_ASSERT(resumee->resumer == NULL); @@ -1234,7 +1230,7 @@ case DUK_LJ_TYPE_YIELD: { /* * Currently only allowed only if yielding thread has only - * ECMAScript activations (except for the Duktape.Thread.yield() + * Ecmascript activations (except for the Duktape.Thread.yield() * call at the callstack top) and none of them constructor * calls. * @@ -1250,27 +1246,27 @@ DUK_ASSERT(thr != entry_thread); /* Duktape.Thread.yield() should prevent */ #endif DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); /* unchanged from Duktape.Thread.yield() */ - DUK_ASSERT(thr->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.yield() activation */ + DUK_ASSERT(thr->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.yield() activation */ DUK_ASSERT(thr->callstack_curr != NULL); DUK_ASSERT(thr->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr)) && ((duk_hnatfunc *) DUK_ACT_GET_FUNC(thr->callstack_curr))->func == duk_bi_thread_yield); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* an Ecmascript function */ resumer = thr->resumer; DUK_ASSERT(resumer != NULL); DUK_ASSERT(resumer->state == DUK_HTHREAD_STATE_RESUMED); /* written by a previous RESUME handling */ - DUK_ASSERT(resumer->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(resumer->callstack_curr != NULL); DUK_ASSERT(resumer->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(resumer->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(resumer->callstack_curr)) && ((duk_hnatfunc *) DUK_ACT_GET_FUNC(resumer->callstack_curr))->func == duk_bi_thread_resume); DUK_ASSERT(DUK_ACT_GET_FUNC(resumer->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(resumer->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(resumer->callstack_curr->parent))); /* an Ecmascript function */ if (thr->heap->lj.iserror) { thr->state = DUK_HTHREAD_STATE_YIELDED; @@ -1324,7 +1320,7 @@ * resumer in this case.) * * Note: until we hit the entry level, there can only be - * ECMAScript activations. + * Ecmascript activations. */ duk_activation *act; @@ -1391,11 +1387,11 @@ */ DUK_ASSERT(thr->resumer != NULL); - DUK_ASSERT(thr->resumer->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(thr->resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(thr->resumer->callstack_curr != NULL); DUK_ASSERT(thr->resumer->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an Ecmascript function */ resumer = thr->resumer; @@ -1448,7 +1444,8 @@ * infinite loop in this catchpoint. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); + return retval; } /* Handle a BREAK/CONTINUE opcode. Avoid using longjmp() for BREAK/CONTINUE @@ -1512,7 +1509,7 @@ /* Should never happen, but be robust. */ DUK_D(DUK_DPRINT("-> break/continue not caught by anything in the current function (should never happen), throw internal error")); DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); + return; } /* Handle a RETURN opcode. Avoid using longjmp() for return handling because @@ -1547,7 +1544,7 @@ * 2. The return happens at the entry level of the bytecode * executor, so return from the executor (in C stack). * - * 3. There is a calling (ECMAScript) activation in the call + * 3. There is a calling (Ecmascript) activation in the call * stack => return to it, in the same executor instance. * * 4. There is no calling activation, and the thread is @@ -1592,16 +1589,16 @@ } if (thr->callstack_top >= 2) { - /* There is a caller; it MUST be an ECMAScript caller (otherwise it would + /* There is a caller; it MUST be an Ecmascript caller (otherwise it would * match entry_act check). */ - DUK_DDD(DUK_DDDPRINT("return to ECMAScript caller, retval_byteoff=%ld, lj_value1=%!T", + DUK_DDD(DUK_DDDPRINT("return to Ecmascript caller, retval_byteoff=%ld, lj_value1=%!T", (long) (thr->callstack_curr->parent->retval_byteoff), (duk_tval *) &thr->heap->lj.value1)); DUK_ASSERT(thr->callstack_curr != NULL); DUK_ASSERT(thr->callstack_curr->parent != NULL); - DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* must be ECMAScript */ + DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* must be ecmascript */ #if defined(DUK_USE_ES6_PROXY) if (thr->callstack_curr->flags & (DUK_ACT_FLAG_CONSTRUCT | DUK_ACT_FLAG_CONSTRUCT_PROXY)) { @@ -1631,51 +1628,31 @@ DUK_DD(DUK_DDPRINT("no calling activation, thread finishes (similar to yield)")); DUK_ASSERT(thr->resumer != NULL); - DUK_ASSERT(thr->resumer->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(thr->resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(thr->resumer->callstack_curr != NULL); DUK_ASSERT(thr->resumer->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr)) && ((duk_hnatfunc *) DUK_ACT_GET_FUNC(thr->resumer->callstack_curr))->func == duk_bi_thread_resume); /* Duktape.Thread.resume() */ DUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an Ecmascript function */ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); DUK_ASSERT(thr->resumer->state == DUK_HTHREAD_STATE_RESUMED); resumer = thr->resumer; - /* Share yield longjmp handler. - * - * This sequence of steps is a bit fragile (see GH-1845): - * - We need the return value from 'thr' (resumed thread) value stack. - * The termination unwinds its value stack, losing the value. - * - We need a refcounted reference for 'thr', which may only exist - * in the caller value stack. We can't unwind or reconfigure the - * caller's value stack without potentially freeing 'thr'. - * - * Current approach is to capture the 'thr' return value and store - * a reference to 'thr' in the caller value stack temporarily. This - * keeps 'thr' reachable until final yield/return handling which - * removes the references atomatically. - */ - + /* Share yield longjmp handler. */ DUK_ASSERT(thr->valstack_top - 1 >= thr->valstack_bottom); - duk_hthread_activation_unwind_norz(resumer); /* May remove last reference to 'thr', but is NORZ. */ - duk_push_tval(resumer, thr->valstack_top - 1); /* Capture return value, side effect free. */ - duk_push_hthread(resumer, thr); /* Make 'thr' reachable again, before side effects. */ + duk_hthread_activation_unwind_norz(resumer); + duk__handle_yield(thr, resumer, thr->valstack_top - 1); - duk_hthread_terminate(thr); /* Updates thread state, minimizes its allocations. */ - thr->resumer = NULL; - DUK_HTHREAD_DECREF(thr, resumer); + duk_hthread_terminate(thr); /* updates thread state, minimizes its allocations */ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_TERMINATED); + thr->resumer = NULL; + DUK_HTHREAD_DECREF(thr, resumer); resumer->state = DUK_HTHREAD_STATE_RUNNING; DUK_HEAP_SWITCH_THREAD(thr->heap, resumer); - - DUK_ASSERT(resumer->valstack_top - 2 >= resumer->valstack_bottom); - duk__handle_yield(thr, resumer, resumer->valstack_top - 2); - thr = NULL; /* 'thr' invalidated by call */ - #if 0 thr = resumer; /* not needed */ #endif @@ -1685,7 +1662,7 @@ #else /* Without coroutine support this case should never happen. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + return DUK__RETHAND_FINISHED; /* not executed */ #endif } @@ -1835,7 +1812,7 @@ if (diff_last < 0.0 || diff_last >= (duk_double_t) DUK_HEAP_DBG_RATELIMIT_MILLISECS) { /* Monotonic time should not experience time jumps, * but the provider may be missing and we're actually - * using ECMAScript time. So, tolerate negative values + * using Ecmascript time. So, tolerate negative values * so that a time jump works reasonably. * * Same interval is now used for status sending and @@ -1984,7 +1961,6 @@ thr->interrupt_counter = 0; DUK_HEAP_CLEAR_INTERRUPT_RUNNING(thr->heap); DUK_ERROR_RANGE(thr, "execution timeout"); - DUK_WO_NORETURN(return 0;); } #endif /* DUK_USE_EXEC_TIMEOUT_CHECK */ @@ -2670,7 +2646,7 @@ } /* - * ECMAScript bytecode executor. + * Ecmascript bytecode executor. * * Resume execution for the current thread from its current activation. * Returns when execution would return from the entry level activation, @@ -2679,7 +2655,7 @@ * a longjmp() with type DUK_LJ_TYPE_THROW is called on the entry level * setjmp() jmpbuf. * - * ECMAScript function calls and coroutine resumptions are handled + * Ecmascript function calls and coroutine resumptions are handled * internally (by the outer executor function) without recursive C calls. * Other function calls are handled using duk_handle_call(), increasing * C recursion depth. @@ -2772,7 +2748,6 @@ #if defined(DUK_USE_VERBOSE_EXECUTOR_ERRORS) #define DUK__INTERNAL_ERROR(msg) do { \ DUK_ERROR_ERROR(thr, (msg)); \ - DUK_WO_NORETURN(return;); \ } while (0) #else #define DUK__INTERNAL_ERROR(msg) do { \ @@ -2937,10 +2912,7 @@ entry_jmpbuf_ptr); } #if defined(DUK_USE_CPP_EXCEPTIONS) - catch (duk_fatal_exception &exc) { - DUK_D(DUK_DPRINT("rethrow duk_fatal_exception")); - throw; - } catch (std::exception &exc) { + catch (std::exception &exc) { const char *what = exc.what(); if (!what) { what = "unknown"; @@ -2950,7 +2922,6 @@ try { DUK_ASSERT(heap->curr_thread != NULL); DUK_ERROR_FMT1(heap->curr_thread, DUK_ERR_TYPE_ERROR, "caught invalid c++ std::exception '%s' (perhaps thrown by user code)", what); - DUK_WO_NORETURN(return;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ std::exception")); DUK_UNREF(exc); @@ -2965,7 +2936,6 @@ try { DUK_ASSERT(heap->curr_thread != NULL); DUK_ERROR_TYPE(heap->curr_thread, "caught invalid c++ exception (perhaps thrown by user code)"); - DUK_WO_NORETURN(return;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ exception")); DUK_UNREF(exc); @@ -2978,7 +2948,7 @@ #endif } - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); } /* Inner executor, performance critical. */ @@ -3347,7 +3317,7 @@ /* XXX: fast double-to-int conversion, we know number is integer in [-0x80000000,0xffffffff]. */ val = (duk_int32_t) DUK_TVAL_GET_NUMBER(tv1); #endif - val = (duk_int32_t) ((duk_uint32_t) val << DUK_BC_LDINTX_SHIFT) + (duk_int32_t) DUK_DEC_BC(ins); /* no bias */ + val = (val << DUK_BC_LDINTX_SHIFT) + (duk_int32_t) DUK_DEC_BC(ins); /* no bias */ DUK_TVAL_SET_I32_UPDREF(thr, tv1, val); /* side effects */ break; } @@ -5002,7 +4972,7 @@ case DUK_OP_INVLHS: { DUK_ERROR_REFERENCE(thr, DUK_STR_INVALID_LVALUE); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); break; } @@ -5037,13 +5007,45 @@ case DUK_OP_INVALID: { DUK_ERROR_FMT1(thr, DUK_ERR_ERROR, "INVALID opcode (%ld)", (long) DUK_DEC_ABC(ins)); - DUK_WO_NORETURN(return;); break; } #if defined(DUK_USE_ES6) case DUK_OP_NEWTARGET: { - duk_push_new_target(thr); + /* https://www.ecma-international.org/ecma-262/6.0/#sec-meta-properties-runtime-semantics-evaluation + * https://www.ecma-international.org/ecma-262/6.0/#sec-getnewtarget + * + * No newTarget support now, so as a first approximation + * use the resolved (non-bound) target function. + */ + /* XXX: C API: push_new_target()? */ + duk_activation *act; + + act = thr->callstack_curr; + DUK_ASSERT(act != NULL); + + /* Check CONSTRUCT flag from current function, or if running + * direct eval, from a non-direct-eval parent (with possibly + * more than one nested direct eval). An alternative to this + * would be to store [[NewTarget]] as a hidden symbol of the + * lexical scope, and then just look up that variable. + */ + for (;;) { + if (act == NULL) { + duk_push_undefined(thr); + break; + } + if (act->flags & DUK_ACT_FLAG_CONSTRUCT) { + duk_push_tval(thr, &act->tv_func); + break; + } else if (act->flags & DUK_ACT_FLAG_DIRECT_EVAL) { + act = act->parent; + } else { + duk_push_undefined(thr); + break; + } + } + DUK__REPLACE_TOP_BC_BREAK(); } #endif /* DUK_USE_ES6 */ @@ -5145,11 +5147,10 @@ continue; #endif } - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); #if !defined(DUK_USE_VERBOSE_EXECUTOR_ERRORS) internal_error: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); #endif } diff -Nru duktape-2.3.0/src-input/duk_js.h duktape-2.2.0/src-input/duk_js.h --- duktape-2.3.0/src-input/duk_js.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_js.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,5 +1,5 @@ /* - * ECMAScript execution, support primitives. + * Ecmascript execution, support primitives. */ #if !defined(DUK_JS_H_INCLUDED) @@ -43,9 +43,6 @@ #endif DUK_INTERNAL_DECL duk_bool_t duk_js_compare_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_uint_t flags); DUK_INTERNAL_DECL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y); -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL_DECL duk_bool_t duk_js_instanceof_ordinary(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y); -#endif DUK_INTERNAL_DECL duk_bool_t duk_js_in(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y); DUK_INTERNAL_DECL duk_small_uint_t duk_js_typeof_stridx(duk_tval *tv_x); diff -Nru duktape-2.3.0/src-input/duk_js_ops.c duktape-2.2.0/src-input/duk_js_ops.c --- duktape-2.3.0/src-input/duk_js_ops.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_js_ops.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,7 +1,7 @@ /* - * ECMAScript specification algorithm and conversion helpers. + * Ecmascript specification algorithm and conversion helpers. * - * These helpers encapsulate the primitive ECMAScript operation semantics, + * These helpers encapsulate the primitive Ecmascript operation semantics, * and are used by the bytecode executor and the API (among other places). * Some primitives are only implemented as part of the API and have no * "internal" helper. This is the case when an internal helper would not @@ -217,7 +217,6 @@ duk_hstring *h = DUK_TVAL_GET_STRING(tv); if (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_CANNOT_NUMBER_COERCE_SYMBOL); - DUK_WO_NORETURN(return 0.0;); } duk_push_hstring(thr, h); return duk__tonumber_string_raw(thr); @@ -433,7 +432,7 @@ return 0; #else /* DUK_USE_PARANOID_MATH */ /* Better equivalent algorithm. If the compiler is compliant, C and - * ECMAScript semantics are identical for this particular comparison. + * Ecmascript semantics are identical for this particular comparison. * In particular, NaNs must never compare equal and zeroes must compare * equal regardless of sign. Could also use a macro, but this inlines * already nicely (no difference on gcc, for instance). @@ -726,12 +725,12 @@ prefix_len = (len1 <= len2 ? len1 : len2); - /* duk_memcmp() is guaranteed to return zero (equal) for zero length - * inputs. + /* DUK_MEMCMP() is guaranteed to return zero (equal) for zero length + * inputs so no zero length check is needed. */ - rc = duk_memcmp_unsafe((const void *) buf1, - (const void *) buf2, - (size_t) prefix_len); + rc = DUK_MEMCMP((const void *) buf1, + (const void *) buf2, + (size_t) prefix_len); if (rc < 0) { return -1; @@ -998,19 +997,22 @@ */ /* - * ES2015 Section 7.3.19 describes the OrdinaryHasInstance() algorithm - * which covers both bound and non-bound functions; in effect the algorithm - * includes E5 Sections 11.8.6, 15.3.5.3, and 15.3.4.5.3. - * - * ES2015 Section 12.9.4 describes the instanceof operator which first - * checks @@hasInstance well-known symbol and falls back to - * OrdinaryHasInstance(). + * E5 Section 11.8.6 describes the main algorithm, which uses + * [[HasInstance]]. [[HasInstance]] is defined for only + * function objects: + * + * - Normal functions: + * E5 Section 15.3.5.3 + * - Functions established with Function.prototype.bind(): + * E5 Section 15.3.4.5.3 + * + * For other objects, a TypeError is thrown. * * Limited Proxy support: don't support 'getPrototypeOf' trap but * continue lookup in Proxy target if the value is a Proxy. */ -DUK_LOCAL duk_bool_t duk__js_instanceof_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_bool_t skip_sym_check) { +DUK_INTERNAL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) { duk_hobject *func; duk_hobject *val; duk_hobject *proto; @@ -1033,23 +1035,6 @@ func = duk_require_hobject(thr, -1); DUK_ASSERT(func != NULL); -#if defined(DUK_USE_SYMBOL_BUILTIN) - /* - * @@hasInstance check, ES2015 Section 12.9.4, Steps 2-4. - */ - if (!skip_sym_check) { - if (duk_get_method_stridx(thr, -1, DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE)) { - /* [ ... lhs rhs func ] */ - duk_insert(thr, -3); /* -> [ ... func lhs rhs ] */ - duk_swap_top(thr, -2); /* -> [ ... func rhs(this) lhs ] */ - duk_call_method(thr, 1); - return duk_to_boolean_top_pop(thr); - } - } -#else - DUK_UNREF(skip_sym_check); -#endif - /* * For bound objects, [[HasInstance]] just calls the target function * [[HasInstance]]. If that is again a bound object, repeat until @@ -1061,7 +1046,7 @@ if (!DUK_HOBJECT_IS_CALLABLE(func)) { /* - * Note: of native ECMAScript objects, only Function instances + * Note: of native Ecmascript objects, only Function instances * have a [[HasInstance]] internal property. Custom objects might * also have it, but not in current implementation. * @@ -1071,7 +1056,7 @@ } if (DUK_HOBJECT_HAS_BOUNDFUNC(func)) { - duk_push_tval(thr, &((duk_hboundfunc *) (void *) func)->target); + duk_push_tval(thr, &((duk_hboundfunc *) func)->target); duk_replace(thr, -2); func = duk_require_hobject(thr, -1); /* lightfunc throws */ @@ -1176,7 +1161,6 @@ if (DUK_UNLIKELY(sanity == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } DUK_UNREACHABLE(); @@ -1194,23 +1178,13 @@ error_invalid_rval: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_INSTANCEOF_RVAL); - DUK_WO_NORETURN(return 0;); + return 0; #if defined(DUK_USE_VERBOSE_ERRORS) error_invalid_rval_noproto: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_INSTANCEOF_RVAL_NOPROTO); - DUK_WO_NORETURN(return 0;); -#endif -} - -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL duk_bool_t duk_js_instanceof_ordinary(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) { - return duk__js_instanceof_helper(thr, tv_x, tv_y, 1 /*skip_sym_check*/); -} + return 0; #endif - -DUK_INTERNAL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) { - return duk__js_instanceof_helper(thr, tv_x, tv_y, 0 /*skip_sym_check*/); } /* diff -Nru duktape-2.3.0/src-input/duk_js_var.c duktape-2.2.0/src-input/duk_js_var.c --- duktape-2.3.0/src-input/duk_js_var.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_js_var.c 2017-09-23 01:06:08.000000000 +0000 @@ -6,7 +6,7 @@ * be used for most identifier accesses. Consequently, these slow path * primitives should be optimized for maximum compactness. * - * ECMAScript environment records (declarative and object) are represented + * Ecmascript environment records (declarative and object) are represented * as internal objects with control keys. Environment records have a * parent record ("outer environment reference") which is represented by * the implicit prototype for technical reasons (in other words, it is a @@ -48,7 +48,7 @@ * Create a new function object based on a "template function" which contains * compiled bytecode, constants, etc, but lacks a lexical environment. * - * ECMAScript requires that each created closure is a separate object, with + * Ecmascript requires that each created closure is a separate object, with * its own set of editable properties. However, structured property values * (such as the formal arguments list and the variable map) are shared. * Also the bytecode, constants, and inner functions are shared. @@ -1057,7 +1057,6 @@ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } env = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, env); } @@ -1197,7 +1196,6 @@ DUK_ERROR_FMT1(thr, DUK_ERR_REFERENCE_ERROR, "identifier '%s' undefined", (const char *) DUK_HSTRING_GET_DATA(name)); - DUK_WO_NORETURN(return 0;); } return 0; @@ -1322,7 +1320,6 @@ DUK_ERROR_FMT1(thr, DUK_ERR_REFERENCE_ERROR, "identifier '%s' undefined", (const char *) DUK_HSTRING_GET_DATA(name)); - DUK_WO_NORETURN(return;); } DUK_DDD(DUK_DDDPRINT("identifier binding not found, not strict => set to global")); @@ -1713,7 +1710,7 @@ fail_existing_attributes: fail_not_extensible: DUK_ERROR_TYPE(thr, "declaration failed"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL diff -Nru duktape-2.3.0/src-input/duk_lexer.c duktape-2.2.0/src-input/duk_lexer.c --- duktape-2.3.0/src-input/duk_lexer.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_lexer.c 2017-09-23 01:06:08.000000000 +0000 @@ -2,7 +2,7 @@ * Lexer for source files, ToNumber() string conversions, RegExp expressions, * and JSON. * - * Provides a stream of ECMAScript tokens from an UTF-8/CESU-8 buffer. The + * Provides a stream of Ecmascript tokens from an UTF-8/CESU-8 buffer. The * caller can also rewind the token stream into a certain position which is * needed by the compiler part for multi-pass scanning. Tokens are * represented as duk_token structures, and contain line number information. @@ -25,14 +25,14 @@ * * Token parsing supports the full range of Unicode characters as described * in the E5 specification. Parsing has been optimized for ASCII characters - * because ordinary ECMAScript code consists almost entirely of ASCII + * because ordinary Ecmascript code consists almost entirely of ASCII * characters. Matching of complex Unicode codepoint sets (such as in the * IdentifierStart and IdentifierPart productions) is optimized for size, * and is done using a linear scan of a bit-packed list of ranges. This is * very slow, but should never be entered unless the source code actually * contains Unicode characters. * - * ECMAScript tokenization is partially context sensitive. First, + * Ecmascript tokenization is partially context sensitive. First, * additional future reserved words are recognized in strict mode (see E5 * Section 7.6.1.2). Second, a forward slash character ('/') can be * recognized either as starting a RegExp literal or as a division operator, @@ -129,7 +129,7 @@ * * * In particular, surrogate pairs are allowed and not combined, which * allows source files to represent all SourceCharacters with CESU-8. - * Broken surrogate pairs are allowed, as ECMAScript does not mandate + * Broken surrogate pairs are allowed, as Ecmascript does not mandate * their validation. * * * Allow non-shortest UTF-8 encodings. @@ -137,20 +137,20 @@ * Leniency here causes few security concerns because all character data is * decoded into Unicode codepoints before lexer processing, and is then * re-encoded into CESU-8. The source can be parsed as strict UTF-8 with - * a compiler option. However, ECMAScript source characters include -all- + * a compiler option. However, Ecmascript source characters include -all- * 16-bit unsigned integer codepoints, so leniency seems to be appropriate. * * Note that codepoints above the BMP are not strictly SourceCharacters, * but the lexer still accepts them as such. Before ending up in a string * or an identifier name, codepoints above BMP are converted into surrogate * pairs and then CESU-8 encoded, resulting in 16-bit Unicode data as - * expected by ECMAScript. + * expected by Ecmascript. * * An alternative approach to dealing with invalid or partial sequences * would be to skip them and replace them with e.g. the Unicode replacement * character U+FFFD. This has limited utility because a replacement character * will most likely cause a parse error, unless it occurs inside a string. - * Further, ECMAScript source is typically pure ASCII. + * Further, Ecmascript source is typically pure ASCII. * * See: * @@ -313,7 +313,6 @@ lex_ctx->input_line = input_line; DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_SOURCE_DECODE_FAILED); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__advance_bytes(duk_lexer_ctx *lex_ctx, duk_small_uint_t count_bytes) { @@ -336,7 +335,7 @@ /* Not enough data to provide a full window, so "scroll" window to * start of buffer and fill up the rest. */ - duk_memmove((void *) lex_ctx->buffer, + DUK_MEMMOVE((void *) lex_ctx->buffer, (const void *) lex_ctx->window, (size_t) avail_bytes); lex_ctx->window = lex_ctx->buffer; @@ -474,7 +473,7 @@ error_clipped: /* clipped codepoint */ error_encoding: /* invalid codepoint encoding or codepoint */ DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_SOURCE_DECODE_FAILED); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_LOCAL void duk__advance_bytes(duk_lexer_ctx *lex_ctx, duk_small_uint_t count_bytes) { @@ -487,7 +486,7 @@ /* Zero 'count' is also allowed to make call sites easier. */ keep_bytes = DUK_LEXER_WINDOW_SIZE * sizeof(duk_lexer_codepoint) - count_bytes; - duk_memmove((void *) lex_ctx->window, + DUK_MEMMOVE((void *) lex_ctx->window, (const void *) ((duk_uint8_t *) lex_ctx->window + count_bytes), (size_t) keep_bytes); @@ -576,7 +575,7 @@ DUK_INTERNAL void duk_lexer_initctx(duk_lexer_ctx *lex_ctx) { DUK_ASSERT(lex_ctx != NULL); - duk_memzero(lex_ctx, sizeof(*lex_ctx)); + DUK_MEMZERO(lex_ctx, sizeof(*lex_ctx)); #if defined(DUK_USE_EXPLICIT_NULL_INIT) #if defined(DUK_USE_LEXER_SLIDING_WINDOW) lex_ctx->window = NULL; @@ -741,7 +740,6 @@ fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE); - DUK_WO_NORETURN(return 0;); } /* Parse legacy octal escape of the form \N{1,3}, e.g. \0, \5, \0377. Maximum @@ -938,11 +936,11 @@ fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_unterminated: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_STRING); - DUK_WO_NORETURN(return;); + return; } /* Skip to end-of-line (or end-of-file), used for single line comments. */ @@ -959,7 +957,7 @@ } /* - * Parse ECMAScript source InputElementDiv or InputElementRegExp + * Parse Ecmascript source InputElementDiv or InputElementRegExp * (E5 Section 7), skipping whitespace, comments, and line terminators. * * Possible results are: @@ -986,13 +984,13 @@ * lookup window to quickly determine which production is the -longest- * matching one, and then parse that. The top-level if-else clauses * match the first character, and the code blocks for each clause - * handle -all- alternatives for that first character. ECMAScript + * handle -all- alternatives for that first character. Ecmascript * specification uses the "longest match wins" semantics, so the order * of the if-clauses matters. * * Misc notes: * - * * ECMAScript numeric literals do not accept a sign character. + * * Ecmascript numeric literals do not accept a sign character. * Consequently e.g. "-1.0" is parsed as two tokens: a negative * sign and a positive numeric literal. The compiler performs * the negation during compilation, so this has no adverse impact. @@ -1502,7 +1500,7 @@ * (the tokens DUK_TOK_GET and DUK_TOK_SET are actually not * used now). The compiler needs to work around this. * - * Strictly speaking, following ECMAScript longest match + * Strictly speaking, following Ecmascript longest match * specification, an invalid escape for the first character * should cause a syntax error. However, an invalid escape * for IdentifierParts should just terminate the identifier @@ -1786,32 +1784,32 @@ fail_token_limit: DUK_ERROR_RANGE(lex_ctx->thr, DUK_STR_TOKEN_LIMIT); - DUK_WO_NORETURN(return;); + return; fail_token: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_TOKEN); - DUK_WO_NORETURN(return;); + return; fail_number_literal: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_NUMBER_LITERAL); - DUK_WO_NORETURN(return;); + return; fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_unterm_regexp: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_REGEXP); - DUK_WO_NORETURN(return;); + return; fail_unterm_comment: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_COMMENT); - DUK_WO_NORETURN(return;); + return; #if !defined(DUK_USE_REGEXP_SUPPORT) fail_regexp_support: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_REGEXP_SUPPORT_DISABLED); - DUK_WO_NORETURN(return;); + return; #endif } @@ -1834,7 +1832,7 @@ goto fail_token_limit; } - duk_memzero(out_token, sizeof(*out_token)); + DUK_MEMZERO(out_token, sizeof(*out_token)); x = DUK__L0(); y = DUK__L1(); @@ -2159,24 +2157,24 @@ fail_token_limit: DUK_ERROR_RANGE(lex_ctx->thr, DUK_STR_TOKEN_LIMIT); - DUK_WO_NORETURN(return;); + return; fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_group: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_GROUP); - DUK_WO_NORETURN(return;); + return; #if !defined(DUK_USE_ES6_REGEXP_SYNTAX) fail_invalid_char: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_CHARACTER); - DUK_WO_NORETURN(return;); + return; fail_quantifier: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_QUANTIFIER); - DUK_WO_NORETURN(return;); + return; #endif } @@ -2425,15 +2423,15 @@ fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_range: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_RANGE); - DUK_WO_NORETURN(return;); + return; fail_unterm_charclass: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_CHARCLASS); - DUK_WO_NORETURN(return;); + return; } #endif /* DUK_USE_REGEXP_SUPPORT */ diff -Nru duktape-2.3.0/src-input/duk_lexer.h duktape-2.2.0/src-input/duk_lexer.h --- duktape-2.3.0/src-input/duk_lexer.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_lexer.h 2017-09-23 01:06:08.000000000 +0000 @@ -388,7 +388,7 @@ duk_int_t line; }; -/* Lexer context. Same context is used for ECMAScript and Regexp parsing. */ +/* Lexer context. Same context is used for Ecmascript and Regexp parsing. */ struct duk_lexer_ctx { #if defined(DUK_USE_LEXER_SLIDING_WINDOW) duk_lexer_codepoint *window; /* unicode code points, window[0] is always next, points to 'buffer' */ diff -Nru duktape-2.3.0/src-input/duk_numconv.c duktape-2.2.0/src-input/duk_numconv.c --- duktape-2.3.0/src-input/duk_numconv.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_numconv.c 2017-09-23 01:06:08.000000000 +0000 @@ -133,8 +133,10 @@ n = y->n; x->n = n; - /* No need to special case n == 0. */ - duk_memcpy((void *) x->v, (const void *) y->v, (size_t) (sizeof(duk_uint32_t) * (size_t) n)); + if (n == 0) { + return; + } + DUK_MEMCPY((void *) x->v, (const void *) y->v, (size_t) (sizeof(duk_uint32_t) * (size_t) n)); } DUK_LOCAL void duk__bi_set_small(duk__bigint *x, duk_uint32_t v) { @@ -410,7 +412,7 @@ return; } - duk_memzero((void *) x->v, (size_t) (sizeof(duk_uint32_t) * (size_t) nx)); + DUK_MEMZERO((void *) x->v, (size_t) (sizeof(duk_uint32_t) * (size_t) nx)); x->n = nx; nz = z->n; @@ -560,7 +562,7 @@ n = (y / 32) + 1; DUK_ASSERT(n > 0); r = y % 32; - duk_memzero((void *) x->v, sizeof(duk_uint32_t) * (size_t) n); + DUK_MEMZERO((void *) x->v, sizeof(duk_uint32_t) * (size_t) n); x->n = n; x->v[n - 1] = (((duk_uint32_t) 1) << r); } @@ -674,7 +676,6 @@ duk_small_int_t dig; duk_uint32_t t; - DUK_ASSERT(buf != NULL); DUK_ASSERT(radix >= 2 && radix <= 36); /* A 32-bit unsigned integer formats to at most 32 digits (the @@ -697,7 +698,7 @@ } len = (duk_size_t) ((buf + 32) - p); - duk_memmove((void *) buf, (const void *) p, (size_t) len); + DUK_MEMMOVE((void *) buf, (const void *) p, (size_t) len); return len; } @@ -1100,7 +1101,7 @@ { duk_uint8_t buf[2048]; duk_small_int_t i, t; - duk_memzero(buf, sizeof(buf)); + DUK_MEMZERO(buf, sizeof(buf)); for (i = 0; i < nc_ctx->count; i++) { t = nc_ctx->digits[i]; if (t < 0 || t > 36) { @@ -1165,7 +1166,7 @@ *p = 0; if (p == &nc_ctx->digits[0]) { DUK_DDD(DUK_DDDPRINT("carry propagated to first digit -> special case handling")); - duk_memmove((void *) (&nc_ctx->digits[1]), + DUK_MEMMOVE((void *) (&nc_ctx->digits[1]), (const void *) (&nc_ctx->digits[0]), (size_t) (sizeof(char) * (size_t) nc_ctx->count)); nc_ctx->digits[0] = 1; /* don't increase 'count' */ @@ -1209,7 +1210,7 @@ duk_uint8_t *buf; /* - * The string conversion here incorporates all the necessary ECMAScript + * The string conversion here incorporates all the necessary Ecmascript * semantics without attempting to be generic. nc_ctx->digits contains * nc_ctx->count digits (>= 1), with the topmost digit's 'position' * indicated by nc_ctx->k as follows: @@ -1220,11 +1221,11 @@ * digits="123" count=3 k=-1 --> 0.0123 * * Note that the identifier names used for format selection are different - * in Burger-Dybvig paper and ECMAScript specification (quite confusingly + * in Burger-Dybvig paper and Ecmascript specification (quite confusingly * so, because e.g. 'k' has a totally different meaning in each). See * documentation for discussion. * - * ECMAScript doesn't specify any specific behavior for format selection + * Ecmascript doesn't specify any specific behavior for format selection * (e.g. when to use exponent notation) for non-base-10 numbers. * * The bigint space in the context is reused for string output, as there @@ -1308,7 +1309,7 @@ /* Exponent */ if (expt != DUK__NO_EXP) { /* - * Exponent notation for non-base-10 numbers isn't specified in ECMAScript + * Exponent notation for non-base-10 numbers isn't specified in Ecmascript * specification, as it never explicitly turns up: non-decimal numbers can * only be formatted with Number.prototype.toString([radix]) and for that, * behavior is not explicitly specified. @@ -1410,7 +1411,7 @@ * (perhaps because the low part is set (seemingly) conditionally in a * loop), so this is here to avoid the bogus warning. */ - duk_memzero((void *) &u, sizeof(u)); + DUK_MEMZERO((void *) &u, sizeof(u)); /* * Figure out how generated digits match up with the mantissa, @@ -1593,7 +1594,7 @@ * sprintf "%lu" for the fast path and for exponent formatting. */ - uval = duk_double_to_uint32_t(x); + uval = (unsigned int) x; if (((double) uval) == x && /* integer number in range */ flags == 0) { /* no special formatting */ /* use bigint area as a temp */ @@ -1625,7 +1626,7 @@ * is 1-2 kilobytes and nothing should rely on it being zeroed. */ #if 0 - duk_memzero((void *) nc_ctx, sizeof(*nc_ctx)); /* slow init, do only for slow path cases */ + DUK_MEMZERO((void *) nc_ctx, sizeof(*nc_ctx)); /* slow init, do only for slow path cases */ #endif nc_ctx->is_s2n = 0; @@ -1665,7 +1666,7 @@ } DUK_DDD(DUK_DDDPRINT("count=%ld", (long) count)); DUK_ASSERT(count >= 1); - duk_memzero((void *) nc_ctx->digits, (size_t) count); + DUK_MEMZERO((void *) nc_ctx->digits, (size_t) count); nc_ctx->count = count; nc_ctx->k = 1; /* 0.000... */ neg = 0; @@ -1745,8 +1746,8 @@ duk__numconv_stringify_ctx *nc_ctx = &nc_ctx_alloc; duk_double_t res; duk_hstring *h_str; - duk_int_t expt; - duk_bool_t expt_neg; + duk_small_int_t expt; + duk_small_int_t expt_neg; duk_small_int_t expt_adj; duk_small_int_t neg; duk_small_int_t dig; @@ -1882,7 +1883,7 @@ * accuracy, so that Dragon4 will generate enough binary output digits. * For decimal numbers, this means generating a 20-digit significand, * which should yield enough practical accuracy to parse IEEE doubles. - * In fact, the ECMAScript specification explicitly allows an + * In fact, the Ecmascript specification explicitly allows an * implementation to treat digits beyond 20 as zeroes (and even * to round the 20th digit upwards). For non-decimal numbers, the * appropriate number of digits has been precomputed for comparable @@ -2053,10 +2054,9 @@ } else { /* exponent digit */ - DUK_ASSERT(radix == 10); expt = expt * radix + dig; if (expt > DUK_S2N_MAX_EXPONENT) { - /* Impose a reasonable exponent limit, so that exp + /* impose a reasonable exponent limit, so that exp * doesn't need to get tracked using a bigint. */ DUK_DDD(DUK_DDDPRINT("parse failed: exponent too large")); @@ -2259,5 +2259,5 @@ parse_explimit_error: DUK_DDD(DUK_DDDPRINT("parse failed, internal error, can't return a value")); DUK_ERROR_RANGE(thr, "exponent too large"); - DUK_WO_NORETURN(return;); + return; } diff -Nru duktape-2.3.0/src-input/duk_numconv.h duktape-2.2.0/src-input/duk_numconv.h --- duktape-2.3.0/src-input/duk_numconv.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_numconv.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,6 +1,6 @@ /* * Number-to-string conversion. The semantics of these is very tightly - * bound with the ECMAScript semantics required for call sites. + * bound with the Ecmascript semantics required for call sites. */ #if !defined(DUK_NUMCONV_H_INCLUDED) @@ -33,13 +33,9 @@ /* Maximum exponent value when parsing numbers. This is not strictly * compliant as there should be no upper limit, but as we parse the - * exponent without a bigint, impose some limit. The limit should be - * small enough that multiplying it (or limit-1 to be precise) won't - * overflow signed 32-bit integer range. Exponent is only parsed with - * radix 10, but with maximum radix (36) a safe limit is: - * (10000000*36).toString(16) -> '15752a00' + * exponent without a bigint, impose some limit. */ -#define DUK_S2N_MAX_EXPONENT 10000000L +#define DUK_S2N_MAX_EXPONENT 1000000000 /* Trim white space (= allow leading and trailing whitespace) */ #define DUK_S2N_FLAG_TRIM_WHITE (1U << 0) diff -Nru duktape-2.3.0/src-input/duk_regexp_compiler.c duktape-2.2.0/src-input/duk_regexp_compiler.c --- duktape-2.3.0/src-input/duk_regexp_compiler.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_regexp_compiler.c 2017-09-23 01:06:08.000000000 +0000 @@ -524,7 +524,6 @@ if (re_ctx->recursion_depth >= re_ctx->recursion_limit) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_COMPILER_RECURSION_LIMIT); - DUK_WO_NORETURN(return;); } re_ctx->recursion_depth++; @@ -598,11 +597,9 @@ case DUK_RETOK_QUANTIFIER: { if (atom_start_offset < 0) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_INVALID_QUANTIFIER_NO_ATOM); - DUK_WO_NORETURN(return;); } if (re_ctx->curr_token.qmin > re_ctx->curr_token.qmax) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_INVALID_QUANTIFIER_VALUES); - DUK_WO_NORETURN(return;); } if (atom_char_length >= 0) { /* @@ -671,7 +668,6 @@ re_ctx->curr_token.qmin : re_ctx->curr_token.qmax; if (atom_copies > DUK_RE_MAX_ATOM_COPIES) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_QUANTIFIER_TOO_MANY_COPIES); - DUK_WO_NORETURN(return;); } /* wipe the capture range made by the atom (if any) */ @@ -935,20 +931,17 @@ case DUK_RETOK_ATOM_END_GROUP: { if (expect_eof) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_CLOSING_PAREN); - DUK_WO_NORETURN(return;); } goto done; } case DUK_RETOK_EOF: { if (!expect_eof) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_END_OF_PATTERN); - DUK_WO_NORETURN(return;); } goto done; } default: { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_REGEXP_TOKEN); - DUK_WO_NORETURN(return;); } } @@ -1043,7 +1036,7 @@ flags_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_REGEXP_FLAGS); - DUK_WO_NORETURN(return 0U;); + return 0; /* never here */ } /* @@ -1080,7 +1073,7 @@ n = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h); if (n == 0) { - duk_push_literal(thr, "(?:)"); + duk_push_string(thr, "(?:)"); return; } @@ -1160,7 +1153,7 @@ /* [ ... pattern flags escaped_source buffer ] */ - duk_memzero(&re_ctx, sizeof(re_ctx)); + DUK_MEMZERO(&re_ctx, sizeof(re_ctx)); DUK_LEXER_INITCTX(&re_ctx.lex); /* duplicate zeroing, expect for (possible) NULL inits */ re_ctx.thr = thr; re_ctx.lex.thr = thr; @@ -1207,7 +1200,6 @@ if (re_ctx.highest_backref > re_ctx.captures) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_BACKREFS); - DUK_WO_NORETURN(return;); } /* diff -Nru duktape-2.3.0/src-input/duk_regexp_executor.c duktape-2.2.0/src-input/duk_regexp_executor.c --- duktape-2.3.0/src-input/duk_regexp_executor.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_regexp_executor.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,7 +1,7 @@ /* * Regexp executor. * - * Safety: the ECMAScript executor should prevent user from reading and + * Safety: the Ecmascript executor should prevent user from reading and * replacing regexp bytecode. Even so, the executor must validate all * memory accesses etc. When an invalid access is detected (e.g. a 'save' * opcode to invalid, unallocated index) it should fail with an internal @@ -68,7 +68,7 @@ fail: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } DUK_LOCAL const duk_uint8_t *duk__utf8_advance(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_uint_fast32_t count) { @@ -99,7 +99,7 @@ fail: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } /* @@ -148,7 +148,6 @@ DUK_LOCAL const duk_uint8_t *duk__match_regexp(duk_re_matcher_ctx *re_ctx, const duk_uint8_t *pc, const duk_uint8_t *sp) { if (re_ctx->recursion_depth >= re_ctx->recursion_limit) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_EXECUTOR_RECURSION_LIMIT); - DUK_WO_NORETURN(return NULL;); } re_ctx->recursion_depth++; @@ -157,7 +156,6 @@ if (re_ctx->steps_count >= re_ctx->steps_limit) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_EXECUTOR_STEP_LIMIT); - DUK_WO_NORETURN(return NULL;); } re_ctx->steps_count++; @@ -503,14 +501,14 @@ range_save = (duk_uint8_t **) duk_push_fixed_buffer_nozero(re_ctx->thr, sizeof(duk_uint8_t *) * idx_count); DUK_ASSERT(range_save != NULL); - duk_memcpy(range_save, re_ctx->saved + idx_start, sizeof(duk_uint8_t *) * idx_count); + DUK_MEMCPY(range_save, re_ctx->saved + idx_start, sizeof(duk_uint8_t *) * idx_count); #if defined(DUK_USE_EXPLICIT_NULL_INIT) idx_end = idx_start + idx_count; for (idx = idx_start; idx < idx_end; idx++) { re_ctx->saved[idx] = NULL; } #else - duk_memzero((void *) (re_ctx->saved + idx_start), sizeof(duk_uint8_t *) * idx_count); + DUK_MEMZERO((void *) (re_ctx->saved + idx_start), sizeof(duk_uint8_t *) * idx_count); #endif sub_sp = duk__match_regexp(re_ctx, pc, sp); @@ -528,7 +526,7 @@ DUK_DDD(DUK_DDDPRINT("fail: restore wiped/resaved values [%ld,%ld] (captures [%ld,%ld])", (long) idx_start, (long) (idx_start + idx_count - 1), (long) (idx_start / 2), (long) ((idx_start + idx_count - 1) / 2))); - duk_memcpy((void *) (re_ctx->saved + idx_start), + DUK_MEMCPY((void *) (re_ctx->saved + idx_start), (const void *) range_save, sizeof(duk_uint8_t *) * idx_count); duk_pop_unsafe(re_ctx->thr); @@ -560,7 +558,7 @@ full_save = (duk_uint8_t **) duk_push_fixed_buffer_nozero(re_ctx->thr, sizeof(duk_uint8_t *) * re_ctx->nsaved); DUK_ASSERT(full_save != NULL); - duk_memcpy(full_save, re_ctx->saved, sizeof(duk_uint8_t *) * re_ctx->nsaved); + DUK_MEMCPY(full_save, re_ctx->saved, sizeof(duk_uint8_t *) * re_ctx->nsaved); skip = duk__bc_get_i32(re_ctx, &pc); sub_sp = duk__match_regexp(re_ctx, pc, sp); @@ -585,7 +583,7 @@ lookahead_fail: /* fail: restore saves */ - duk_memcpy((void *) re_ctx->saved, + DUK_MEMCPY((void *) re_ctx->saved, (const void *) full_save, sizeof(duk_uint8_t *) * re_ctx->nsaved); duk_pop_unsafe(re_ctx->thr); @@ -667,7 +665,7 @@ internal_error: DUK_ERROR_INTERNAL(re_ctx->thr); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } /* @@ -733,7 +731,7 @@ /* [ ... re_obj input bc ] */ - duk_memzero(&re_ctx, sizeof(re_ctx)); + DUK_MEMZERO(&re_ctx, sizeof(re_ctx)); re_ctx.thr = thr; re_ctx.input = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input); @@ -770,7 +768,7 @@ #elif defined(DUK_USE_ZERO_BUFFER_DATA) /* buffer is automatically zeroed */ #else - duk_memzero((void *) p_buf, sizeof(duk_uint8_t *) * re_ctx.nsaved); + DUK_MEMZERO((void *) p_buf, sizeof(duk_uint8_t *) * re_ctx.nsaved); #endif DUK_DDD(DUK_DDDPRINT("regexp ctx initialized, flags=0x%08lx, nsaved=%ld, recursion_limit=%ld, steps_limit=%ld", @@ -855,7 +853,7 @@ * internal/limit error occurs (which causes a longjmp()) * * - If we supported anchored matches, we would break out here - * unconditionally; however, ECMAScript regexps don't have anchored + * unconditionally; however, Ecmascript regexps don't have anchored * matches. It might make sense to implement a fast bail-out if * the regexp begins with '^' and sp is not 0: currently we'll just * run through the entire input string, trivially failing the match diff -Nru duktape-2.3.0/src-input/duk_selftest.c duktape-2.2.0/src-input/duk_selftest.c --- duktape-2.3.0/src-input/duk_selftest.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_selftest.c 2017-09-23 01:06:08.000000000 +0000 @@ -23,13 +23,13 @@ } while (0) #define DUK__DBLUNION_CMP_TRUE(a,b) do { \ - if (duk_memcmp((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) != 0) { \ + if (DUK_MEMCMP((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) != 0) { \ DUK__FAILED("double union compares false (expected true)"); \ } \ } while (0) #define DUK__DBLUNION_CMP_FALSE(a,b) do { \ - if (duk_memcmp((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) == 0) { \ + if (DUK_MEMCMP((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) == 0) { \ DUK__FAILED("double union compares true (expected false)"); \ } \ } while (0) @@ -338,7 +338,7 @@ */ DUK__DOUBLE_INIT(&a, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); DUK__DOUBLE_INIT(&b, 0x3c, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - duk_memset((void *) &c, 0, sizeof(c)); + DUK_MEMSET((void *) &c, 0, sizeof(c)); c.d = a.d + b.d; if (!DUK__DOUBLE_COMPARE(&c, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)) { DUK_D(DUK_DPRINT("broken result (native endiannesss): %02x %02x %02x %02x %02x %02x %02x %02x", @@ -358,7 +358,7 @@ */ DUK__DOUBLE_INIT(&a, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01); DUK__DOUBLE_INIT(&b, 0x3c, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - duk_memset((void *) &c, 0, sizeof(c)); + DUK_MEMSET((void *) &c, 0, sizeof(c)); c.d = a.d + b.d; if (!DUK__DOUBLE_COMPARE(&c, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02)) { DUK_D(DUK_DPRINT("broken result (native endiannesss): %02x %02x %02x %02x %02x %02x %02x %02x", diff -Nru duktape-2.3.0/src-input/duktape.h.in duktape-2.2.0/src-input/duktape.h.in --- duktape-2.3.0/src-input/duktape.h.in 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duktape.h.in 2017-09-23 01:06:08.000000000 +0000 @@ -34,15 +34,15 @@ /* Duktape version, (major * 10000) + (minor * 100) + patch. Allows C code * to #if (DUK_VERSION >= NNN) against Duktape API version. The same value - * is also available to ECMAScript code in Duktape.version. Unofficial + * is also available to Ecmascript code in Duktape.version. Unofficial * development snapshots have 99 for patch level (e.g. 0.10.99 would be a * development version after 0.10.0 but before the next official release). */ -#define DUK_VERSION 20300L +#define DUK_VERSION 20200L /* Git commit, describe, and branch for Duktape build. Useful for * non-official snapshot builds so that application code can easily log - * which Duktape snapshot was used. Not available in the ECMAScript + * which Duktape snapshot was used. Not available in the Ecmascript * environment. */ #define DUK_GIT_COMMIT @GIT_COMMIT_CSTRING@ @@ -142,7 +142,7 @@ }; struct duk_time_components { - duk_double_t year; /* year, e.g. 2016, ECMAScript year range */ + duk_double_t year; /* year, e.g. 2016, Ecmascript year range */ duk_double_t month; /* month: 1-12 */ duk_double_t day; /* day: 1-31 */ duk_double_t hours; /* hour: 0-59 */ @@ -178,12 +178,12 @@ /* Value types, used by e.g. duk_get_type() */ #define DUK_TYPE_MIN 0U #define DUK_TYPE_NONE 0U /* no value, e.g. invalid index */ -#define DUK_TYPE_UNDEFINED 1U /* ECMAScript undefined */ -#define DUK_TYPE_NULL 2U /* ECMAScript null */ -#define DUK_TYPE_BOOLEAN 3U /* ECMAScript boolean: 0 or 1 */ -#define DUK_TYPE_NUMBER 4U /* ECMAScript number: double */ -#define DUK_TYPE_STRING 5U /* ECMAScript string: CESU-8 / extended UTF-8 encoded */ -#define DUK_TYPE_OBJECT 6U /* ECMAScript object: includes objects, arrays, functions, threads */ +#define DUK_TYPE_UNDEFINED 1U /* Ecmascript undefined */ +#define DUK_TYPE_NULL 2U /* Ecmascript null */ +#define DUK_TYPE_BOOLEAN 3U /* Ecmascript boolean: 0 or 1 */ +#define DUK_TYPE_NUMBER 4U /* Ecmascript number: double */ +#define DUK_TYPE_STRING 5U /* Ecmascript string: CESU-8 / extended UTF-8 encoded */ +#define DUK_TYPE_OBJECT 6U /* Ecmascript object: includes objects, arrays, functions, threads */ #define DUK_TYPE_BUFFER 7U /* fixed or dynamic, garbage collected byte buffer */ #define DUK_TYPE_POINTER 8U /* raw void pointer */ #define DUK_TYPE_LIGHTFUNC 9U /* lightweight function pointer */ @@ -552,21 +552,7 @@ DUK_EXTERNAL_DECL const char *duk_push_sprintf(duk_context *ctx, const char *fmt, ...); DUK_EXTERNAL_DECL const char *duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap); -/* duk_push_literal() may evaluate its argument (a C string literal) more than - * once on purpose. When speed is preferred, sizeof() avoids an unnecessary - * strlen() at runtime. Sizeof("foo") == 4, so subtract 1. The argument - * must be non-NULL and should not contain internal NUL characters as the - * behavior will then depend on config options. - */ -#if defined(DUK_USE_PREFER_SIZE) -#define duk_push_literal(ctx,cstring) duk_push_string((ctx), (cstring)) -#else -DUK_EXTERNAL_DECL const char *duk_push_literal_raw(duk_context *ctx, const char *str, duk_size_t len); -#define duk_push_literal(ctx,cstring) duk_push_literal_raw((ctx), (cstring), sizeof((cstring)) - 1U) -#endif - DUK_EXTERNAL_DECL void duk_push_this(duk_context *ctx); -DUK_EXTERNAL_DECL void duk_push_new_target(duk_context *ctx); DUK_EXTERNAL_DECL void duk_push_current_function(duk_context *ctx); DUK_EXTERNAL_DECL void duk_push_current_thread(duk_context *ctx); DUK_EXTERNAL_DECL void duk_push_global_object(duk_context *ctx); @@ -898,55 +884,29 @@ /* * Property access * - * The basic function assumes key is on stack. The _(l)string variant takes - * a C string as a property name; the _literal variant takes a C literal. - * The _index variant takes an array index as a property name (e.g. 123 is - * equivalent to the key "123"). The _heapptr variant takes a raw, borrowed - * heap pointer. + * The basic function assumes key is on stack. The _string variant takes + * a C string as a property name, while the _index variant takes an array + * index as a property name (e.g. 123 is equivalent to the key "123"). */ DUK_EXTERNAL_DECL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_get_prop_literal(ctx,obj_idx,key) duk_get_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_get_prop_literal(ctx,obj_idx,key) duk_get_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_put_prop_literal(ctx,obj_idx,key) duk_put_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_put_prop_literal(ctx,obj_idx,key) duk_put_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_del_prop_literal(ctx,obj_idx,key) duk_del_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_del_prop_literal(ctx,obj_idx,key) duk_del_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_has_prop_literal(ctx,obj_idx,key) duk_has_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_has_prop_literal(ctx,obj_idx,key) duk_has_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); @@ -955,22 +915,8 @@ DUK_EXTERNAL_DECL duk_bool_t duk_get_global_string(duk_context *ctx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_get_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_get_global_literal(ctx,key) duk_get_global_string((ctx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_get_global_literal_raw(duk_context *ctx, const char *key, duk_size_t key_len); -#define duk_get_global_literal(ctx,key) duk_get_global_literal_raw((ctx), (key), sizeof((key)) - 1U) -#endif -DUK_EXTERNAL_DECL duk_bool_t duk_get_global_heapptr(duk_context *ctx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_put_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_put_global_literal(ctx,key) duk_put_global_string((ctx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_put_global_literal_raw(duk_context *ctx, const char *key, duk_size_t key_len); -#define duk_put_global_literal(ctx,key) duk_put_global_literal_raw((ctx), (key), sizeof((key)) - 1U) -#endif -DUK_EXTERNAL_DECL duk_bool_t duk_put_global_heapptr(duk_context *ctx, void *ptr); /* * Inspection @@ -1037,7 +983,7 @@ DUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t idx, duk_size_t char_offset); /* - * ECMAScript operators + * Ecmascript operators */ DUK_EXTERNAL_DECL duk_bool_t duk_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2); @@ -1046,12 +992,6 @@ DUK_EXTERNAL_DECL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2); /* - * Random - */ - -DUK_EXTERNAL_DECL duk_double_t duk_random(duk_context *ctx); - -/* * Function (method) calls */ @@ -1201,7 +1141,7 @@ #define DUK_DATE_MSEC_HOUR (60L * 60L * 1000L) #define DUK_DATE_MSEC_DAY (24L * 60L * 60L * 1000L) -/* ECMAScript date range is 100 million days from Epoch: +/* Ecmascript date range is 100 million days from Epoch: * > 100e6 * 24 * 60 * 60 * 1000 // 100M days in millisecs * 8640000000000000 * (= 8.64e15) @@ -1209,7 +1149,7 @@ #define DUK_DATE_MSEC_100M_DAYS (8.64e15) #define DUK_DATE_MSEC_100M_DAYS_LEEWAY (8.64e15 + 24 * 3600e3) -/* ECMAScript year range: +/* Ecmascript year range: * > new Date(100e6 * 24 * 3600e3).toISOString() * '+275760-09-13T00:00:00.000Z' * > new Date(-100e6 * 24 * 3600e3).toISOString() @@ -1219,7 +1159,7 @@ #define DUK_DATE_MAX_ECMA_YEAR 275760L /* Part indices for internal breakdowns. Part order from DUK_DATE_IDX_YEAR - * to DUK_DATE_IDX_MILLISECOND matches argument ordering of ECMAScript API + * to DUK_DATE_IDX_MILLISECOND matches argument ordering of Ecmascript API * calls (like Date constructor call). Some functions in duk_bi_date.c * depend on the specific ordering, so change with care. 16 bits are not * enough for all parts (year, specifically). diff -Nru duktape-2.3.0/src-input/duk_unicode_support.c duktape-2.2.0/src-input/duk_unicode_support.c --- duktape-2.3.0/src-input/duk_unicode_support.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_unicode_support.c 2017-09-23 01:06:08.000000000 +0000 @@ -141,7 +141,7 @@ /* * Unicode codepoints above U+FFFF are encoded as surrogate * pairs here. This ensures that all CESU-8 codepoints are - * 16-bit values as expected in ECMAScript. The surrogate + * 16-bit values as expected in Ecmascript. The surrogate * pairs always get a 3-byte encoding (each) in CESU-8. * See: http://en.wikipedia.org/wiki/Surrogate_pair * @@ -280,7 +280,8 @@ return cp; } DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); + return 0; } /* Compute (extended) utf-8 length without codepoint encoding validation, @@ -429,7 +430,7 @@ duk_bitdecoder_ctx bd_ctx; duk_codepoint_t prev_re; - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); bd_ctx.data = (const duk_uint8_t *) unitab; bd_ctx.length = (duk_size_t) unilen; @@ -981,7 +982,7 @@ } /* 1:1 or special conversions, but not locale/context specific: script generated rules */ - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); if (uppercase) { bd_ctx.data = (const duk_uint8_t *) duk_unicode_caseconv_uc; bd_ctx.length = (duk_size_t) sizeof(duk_unicode_caseconv_uc); diff -Nru duktape-2.3.0/src-input/duk_unicode_tables.c duktape-2.2.0/src-input/duk_unicode_tables.c --- duktape-2.3.0/src-input/duk_unicode_tables.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_unicode_tables.c 2017-09-23 01:06:08.000000000 +0000 @@ -9,7 +9,7 @@ * packed format. These tables are used to match non-ASCII * characters of complex productions by resorting to a linear * range-by-range comparison. This is very slow, but is expected - * to be very rare in practical ECMAScript source code, and thus + * to be very rare in practical Ecmascript source code, and thus * compactness is most important. * * The tables are matched using uni_range_match() and the format diff -Nru duktape-2.3.0/src-input/duk_util_bufwriter.c duktape-2.2.0/src-input/duk_util_bufwriter.c --- duktape-2.3.0/src-input/duk_util_bufwriter.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_util_bufwriter.c 2017-09-23 01:06:08.000000000 +0000 @@ -4,10 +4,6 @@ #include "duk_internal.h" -/* XXX: Avoid duk_{memcmp,memmove}_unsafe() by imposing a minimum length of - * >0 for the underlying dynamic buffer. - */ - /* * Macro support functions (use only macros in calling code) */ @@ -19,9 +15,6 @@ DUK_ASSERT(bw_ctx != NULL); DUK_UNREF(thr); - /* 'p' might be NULL when the underlying buffer is zero size. If so, - * the resulting pointers are not used unsafely. - */ p = (duk_uint8_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, bw_ctx->buf); DUK_ASSERT(p != NULL || (DUK_HBUFFER_DYNAMIC_GET_SIZE(bw_ctx->buf) == 0 && curr_offset == 0 && new_length == 0)); bw_ctx->p = p + curr_offset; @@ -30,6 +23,7 @@ } DUK_INTERNAL void duk_bw_init(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_hbuffer_dynamic *h_buf) { + DUK_ASSERT(thr != NULL); DUK_ASSERT(bw_ctx != NULL); DUK_ASSERT(h_buf != NULL); @@ -44,7 +38,6 @@ (void) duk_push_dynamic_buffer(thr, buf_size); bw_ctx->buf = (duk_hbuffer_dynamic *) duk_known_hbuffer(thr, -1); - DUK_ASSERT(bw_ctx->buf != NULL); duk__bw_update_ptrs(thr, bw_ctx, 0, buf_size); } @@ -69,7 +62,7 @@ if (DUK_UNLIKELY(new_sz < curr_off)) { /* overflow */ DUK_ERROR_RANGE(thr, DUK_STR_BUFFER_TOO_LONG); - DUK_WO_NORETURN(return NULL;); + return NULL; /* not reachable */ } #if 0 /* for manual torture testing: tight allocation, useful with valgrind */ new_sz = curr_off + sz; @@ -112,9 +105,9 @@ DUK_UNREF(thr); p_base = bw->p_base; - duk_memcpy_unsafe((void *) bw->p, - (const void *) (p_base + src_off), - (size_t) len); + DUK_MEMCPY((void *) bw->p, + (const void *) (p_base + src_off), + (size_t) len); bw->p += len; } @@ -144,12 +137,12 @@ move_sz = buf_sz - dst_off; DUK_ASSERT(p_base != NULL); /* buffer size is >= 1 */ - duk_memmove_unsafe((void *) (p_base + dst_off + len), - (const void *) (p_base + dst_off), - (size_t) move_sz); - duk_memcpy_unsafe((void *) (p_base + dst_off), - (const void *) buf, - (size_t) len); + DUK_MEMMOVE((void *) (p_base + dst_off + len), + (const void *) (p_base + dst_off), + (size_t) move_sz); + DUK_MEMCPY((void *) (p_base + dst_off), + (const void *) buf, + (size_t) len); bw->p += len; } @@ -191,12 +184,12 @@ move_sz = buf_sz - dst_off; DUK_ASSERT(p_base != NULL); /* buffer size is >= 1 */ - duk_memmove_unsafe((void *) (p_base + dst_off + len), - (const void *) (p_base + dst_off), - (size_t) move_sz); - duk_memcpy_unsafe((void *) (p_base + dst_off), - (const void *) (p_base + src_off), - (size_t) len); + DUK_MEMMOVE((void *) (p_base + dst_off + len), + (const void *) (p_base + dst_off), + (size_t) move_sz); + DUK_MEMCPY((void *) (p_base + dst_off), + (const void *) (p_base + src_off), + (size_t) len); bw->p += len; } @@ -229,7 +222,7 @@ move_sz = buf_sz - off; p_dst = p_base + off + len; p_src = p_base + off; - duk_memmove_unsafe((void *) p_dst, (const void *) p_src, (size_t) move_sz); + DUK_MEMMOVE((void *) p_dst, (const void *) p_src, (size_t) move_sz); return p_src; /* point to start of 'reserved area' */ } @@ -260,9 +253,9 @@ p_dst = p_base + off; p_src = p_dst + len; move_sz = (duk_size_t) (bw->p - p_src); - duk_memmove_unsafe((void *) p_dst, - (const void *) p_src, - (size_t) move_sz); + DUK_MEMMOVE((void *) p_dst, + (const void *) p_src, + (size_t) move_sz); bw->p -= len; } @@ -283,7 +276,7 @@ duk_uint16_t x; } u; - duk_memcpy((void *) u.b, (const void *) (*p), (size_t) 2); + DUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 2); u.x = DUK_NTOH16(u.x); *p += 2; return u.x; @@ -295,7 +288,7 @@ duk_uint32_t x; } u; - duk_memcpy((void *) u.b, (const void *) (*p), (size_t) 4); + DUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 4); u.x = DUK_NTOH32(u.x); *p += 4; return u.x; @@ -308,10 +301,10 @@ duk_uint32_t x; } u; - duk_memcpy((void *) u.b, (const void *) (*p), (size_t) 4); + DUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 4); u.x = DUK_NTOH32(u.x); du.ui[DUK_DBL_IDX_UI0] = u.x; - duk_memcpy((void *) u.b, (const void *) (*p + 4), (size_t) 4); + DUK_MEMCPY((void *) u.b, (const void *) (*p + 4), (size_t) 4); u.x = DUK_NTOH32(u.x); du.ui[DUK_DBL_IDX_UI1] = u.x; *p += 8; @@ -326,7 +319,7 @@ } u; u.x = DUK_HTON16(val); - duk_memcpy((void *) (*p), (const void *) u.b, (size_t) 2); + DUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 2); *p += 2; } @@ -337,7 +330,7 @@ } u; u.x = DUK_HTON32(val); - duk_memcpy((void *) (*p), (const void *) u.b, (size_t) 4); + DUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 4); *p += 4; } @@ -351,9 +344,9 @@ du.d = val; u.x = du.ui[DUK_DBL_IDX_UI0]; u.x = DUK_HTON32(u.x); - duk_memcpy((void *) (*p), (const void *) u.b, (size_t) 4); + DUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 4); u.x = du.ui[DUK_DBL_IDX_UI1]; u.x = DUK_HTON32(u.x); - duk_memcpy((void *) (*p + 4), (const void *) u.b, (size_t) 4); + DUK_MEMCPY((void *) (*p + 4), (const void *) u.b, (size_t) 4); *p += 8; } diff -Nru duktape-2.3.0/src-input/duk_util_cast.c duktape-2.2.0/src-input/duk_util_cast.c --- duktape-2.3.0/src-input/duk_util_cast.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_util_cast.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ -/* - * Cast helpers. - * - * C99+ coercion is challenging portability-wise because out-of-range casts - * may invoke implementation defined or even undefined behavior. See e.g. - * http://blog.frama-c.com/index.php?post/2013/10/09/Overflow-float-integer. - * - * Provide explicit cast helpers which try to avoid implementation defined - * or undefined behavior. These helpers can then be simplified in the vast - * majority of cases where the implementation defined or undefined behavior - * is not problematic. - */ - -#include "duk_internal.h" - -/* Portable double-to-integer cast which avoids undefined behavior and avoids - * relying on fmin(), fmax(), or other intrinsics. Out-of-range results are - * not assumed by caller, but here value is clamped, NaN converts to minval. - */ -#define DUK__DOUBLE_INT_CAST1(tname,minval,maxval) do { \ - if (DUK_LIKELY(x >= (duk_double_t) (minval))) { \ - DUK_ASSERT(!DUK_ISNAN(x)); \ - if (DUK_LIKELY(x <= (duk_double_t) (maxval))) { \ - return (tname) x; \ - } else { \ - return (tname) (maxval); \ - } \ - } else { \ - /* NaN or below minval. Since we don't care about the result \ - * for out-of-range values, just return the minimum value for \ - * both. \ - */ \ - return (tname) (minval); \ - } \ - } while (0) - -/* Rely on specific NaN behavior for duk_double_{fmin,fmax}(): if either - * argument is a NaN, return the second argument. This avoids a - * NaN-to-integer cast which is undefined behavior. - */ -#define DUK__DOUBLE_INT_CAST2(tname,minval,maxval) do { \ - return (tname) duk_double_fmin(duk_double_fmax(x, (duk_double_t) (minval)), (duk_double_t) (maxval)); \ - } while (0) - -/* Another solution which doesn't need C99+ behavior for fmin() and fmax(). */ -#define DUK__DOUBLE_INT_CAST3(tname,minval,maxval) do { \ - if (DUK_ISNAN(x)) { \ - /* 0 or any other value is fine. */ \ - return (tname) 0; \ - } else \ - return (tname) DUK_FMIN(DUK_FMAX(x, (duk_double_t) (minval)), (duk_double_t) (maxval)); \ - } \ - } while (0) - -/* C99+ solution: relies on specific fmin() and fmax() behavior in C99: if - * one argument is NaN but the other isn't, the non-NaN argument is returned. - * Because the limits are non-NaN values, explicit NaN check is not needed. - * This may not work on all legacy platforms, and also doesn't seem to inline - * the fmin() and fmax() calls (unless one uses -ffast-math which we don't - * support). - */ -#define DUK__DOUBLE_INT_CAST4(tname,minval,maxval) do { \ - return (tname) DUK_FMIN(DUK_FMAX(x, (duk_double_t) (minval)), (duk_double_t) (maxval)); \ - } while (0) - -DUK_INTERNAL duk_int_t duk_double_to_int_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - /* Real world solution: almost any practical platform will provide - * an integer value without any guarantees what it is (which is fine). - */ - return (duk_int_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_int_t, DUK_INT_MIN, DUK_INT_MAX); -#endif -} - -DUK_INTERNAL duk_uint_t duk_double_to_uint_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_uint_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_uint_t, DUK_UINT_MIN, DUK_UINT_MAX); -#endif -} - -DUK_INTERNAL duk_int32_t duk_double_to_int32_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_int32_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_int32_t, DUK_INT32_MIN, DUK_INT32_MAX); -#endif -} - -DUK_INTERNAL duk_uint32_t duk_double_to_uint32_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_uint32_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_uint32_t, DUK_UINT32_MIN, DUK_UINT32_MAX); -#endif -} - -/* Largest IEEE double that doesn't round to infinity in the default rounding - * mode. The exact midpoint between (1 - 2^(-24)) * 2^128 and 2^128 rounds to - * infinity, at least on x64. This number is one double unit below that - * midpoint. See misc/float_cast.c. - */ -#define DUK__FLOAT_ROUND_LIMIT 340282356779733623858607532500980858880.0 - -/* Maximum IEEE float. Double-to-float conversion above this would be out of - * range and thus technically undefined behavior. - */ -#define DUK__FLOAT_MAX 340282346638528859811704183484516925440.0 - -DUK_INTERNAL duk_float_t duk_double_to_float_t(duk_double_t x) { - /* Even a double-to-float cast is technically undefined behavior if - * the double is out-of-range. C99 Section 6.3.1.5: - * - * If the value being converted is in the range of values that can - * be represented but cannot be represented exactly, the result is - * either the nearest higher or nearest lower representable value, - * chosen in an implementation-defined manner. If the value being - * converted is outside the range of values that can be represented, - * the behavior is undefined. - */ -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_float_t) x; -#else - duk_double_t t; - - t = DUK_FABS(x); - DUK_ASSERT((DUK_ISNAN(x) && DUK_ISNAN(t)) || - (!DUK_ISNAN(x) && !DUK_ISNAN(t))); - - if (DUK_LIKELY(t <= DUK__FLOAT_MAX)) { - /* Standard in-range case, try to get here with a minimum - * number of checks and branches. - */ - DUK_ASSERT(!DUK_ISNAN(x)); - return (duk_float_t) x; - } else if (t <= DUK__FLOAT_ROUND_LIMIT) { - /* Out-of-range, but rounds to min/max float. */ - DUK_ASSERT(!DUK_ISNAN(x)); - if (x < 0.0) { - return (duk_float_t) -DUK__FLOAT_MAX; - } else { - return (duk_float_t) DUK__FLOAT_MAX; - } - } else if (DUK_ISNAN(x)) { - /* Assumes double NaN -> float NaN considered "in range". */ - DUK_ASSERT(DUK_ISNAN(x)); - return (duk_float_t) x; - } else { - /* Out-of-range, rounds to +/- Infinity. */ - if (x < 0.0) { - return (duk_float_t) -DUK_DOUBLE_INFINITY; - } else { - return (duk_float_t) DUK_DOUBLE_INFINITY; - } - } -#endif -} diff -Nru duktape-2.3.0/src-input/duk_util_double.c duktape-2.2.0/src-input/duk_util_double.c --- duktape-2.3.0/src-input/duk_util_double.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_util_double.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,234 +0,0 @@ -/* - * IEEE double helpers. - */ - -#include "duk_internal.h" - -DUK_INTERNAL duk_bool_t duk_double_is_anyinf(duk_double_t x) { - duk_double_union du; - du.d = x; - return DUK_DBLUNION_IS_ANYINF(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_posinf(duk_double_t x) { - duk_double_union du; - du.d = x; - return DUK_DBLUNION_IS_POSINF(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_neginf(duk_double_t x) { - duk_double_union du; - du.d = x; - return DUK_DBLUNION_IS_NEGINF(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan(duk_double_t x) { - duk_double_union du; - du.d = x; - /* Assumes we're dealing with a Duktape internal NaN which is - * NaN normalized if duk_tval requires it. - */ - DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); - return DUK_DBLUNION_IS_NAN(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan_or_zero(duk_double_t x) { - duk_double_union du; - du.d = x; - /* Assumes we're dealing with a Duktape internal NaN which is - * NaN normalized if duk_tval requires it. - */ - DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); - return DUK_DBLUNION_IS_NAN(&du) || DUK_DBLUNION_IS_ANYZERO(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan_or_inf(duk_double_t x) { - duk_double_union du; - du.d = x; - /* If exponent is 0x7FF the argument is either a NaN or an - * infinity. We don't need to check any other fields. - */ -#if defined(DUK_USE_64BIT_OPS) -#if defined(DUK_USE_DOUBLE_ME) - return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000)) == DUK_U64_CONSTANT(0x000000007ff00000); -#else - return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000)) == DUK_U64_CONSTANT(0x7ff0000000000000); -#endif -#else - return (du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL) == 0x7ff00000UL; -#endif -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan_zero_inf(duk_double_t x) { - duk_double_union du; -#if defined(DUK_USE_64BIT_OPS) - duk_uint64_t t; -#else - duk_uint32_t t; -#endif - du.d = x; -#if defined(DUK_USE_64BIT_OPS) -#if defined(DUK_USE_DOUBLE_ME) - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000); - if (t == DUK_U64_CONSTANT(0x0000000000000000)) { - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x0000000080000000); - return t == 0; - } - if (t == DUK_U64_CONSTANT(0x000000007ff00000)) { - return 1; - } -#else - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000); - if (t == DUK_U64_CONSTANT(0x0000000000000000)) { - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x8000000000000000); - return t == 0; - } - if (t == DUK_U64_CONSTANT(0x7ff0000000000000)) { - return 1; - } -#endif -#else - t = du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL; - if (t == 0x00000000UL) { - return DUK_DBLUNION_IS_ANYZERO(&du); - } - if (t == 0x7ff00000UL) { - return 1; - } -#endif - return 0; -} - -DUK_INTERNAL duk_small_uint_t duk_double_signbit(duk_double_t x) { - duk_double_union du; - du.d = x; - return (duk_small_uint_t) DUK_DBLUNION_GET_SIGNBIT(&du); -} - -DUK_INTERNAL duk_double_t duk_double_trunc_towards_zero(duk_double_t x) { - /* XXX: optimize */ - duk_small_uint_t s = duk_double_signbit(x); - x = DUK_FLOOR(DUK_FABS(x)); /* truncate towards zero */ - if (s) { - x = -x; - } - return x; -} - -DUK_INTERNAL duk_bool_t duk_double_same_sign(duk_double_t x, duk_double_t y) { - duk_double_union du1; - duk_double_union du2; - du1.d = x; - du2.d = y; - - return (((du1.ui[DUK_DBL_IDX_UI0] ^ du2.ui[DUK_DBL_IDX_UI0]) & 0x80000000UL) == 0); -} - -DUK_INTERNAL duk_double_t duk_double_fmin(duk_double_t x, duk_double_t y) { - /* Doesn't replicate fmin() behavior exactly: for fmin() if one - * argument is a NaN, the other argument should be returned. - * Duktape doesn't rely on this behavior so the replacement can - * be simplified. - */ - return (x < y ? x : y); -} - -DUK_INTERNAL duk_double_t duk_double_fmax(duk_double_t x, duk_double_t y) { - /* Doesn't replicate fmax() behavior exactly: for fmax() if one - * argument is a NaN, the other argument should be returned. - * Duktape doesn't rely on this behavior so the replacement can - * be simplified. - */ - return (x > y ? x : y); -} - -DUK_INTERNAL duk_bool_t duk_double_is_finite(duk_double_t x) { - return !duk_double_is_nan_or_inf(x); -} - -DUK_INTERNAL duk_bool_t duk_double_is_integer(duk_double_t x) { - if (duk_double_is_nan_or_inf(x)) { - return 0; - } else { - return duk_js_tointeger_number(x) == x; - } -} - -DUK_INTERNAL duk_bool_t duk_double_is_safe_integer(duk_double_t x) { - /* >>> 2**53-1 - * 9007199254740991 - */ - return duk_double_is_integer(x) && DUK_FABS(x) <= 9007199254740991.0; -} - -/* Check whether a duk_double_t is a whole number in the 32-bit range (reject - * negative zero), and if so, return a duk_int32_t. - * For compiler use: don't allow negative zero as it will cause trouble with - * LDINT+LDINTX, positive zero is OK. - */ -DUK_INTERNAL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int32_t *ival) { - duk_int32_t t; - - t = duk_double_to_int32_t(x); - if (!((duk_double_t) t == x)) { - return 0; - } - if (t == 0) { - duk_double_union du; - du.d = x; - if (DUK_DBLUNION_HAS_SIGNBIT(&du)) { - return 0; - } - } - *ival = t; - return 1; -} - -/* Check whether a duk_double_t is a whole number in the 32-bit range, and if - * so, return a duk_int32_t. - */ -DUK_INTERNAL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival) { - duk_int32_t t; - - t = duk_double_to_int32_t(x); - if (!((duk_double_t) t == x)) { - return 0; - } - *ival = t; - return 1; -} - -/* Division: division by zero is undefined behavior (and may in fact trap) - * so it needs special handling for portability. - */ - -DUK_INTERNAL DUK_INLINE duk_double_t duk_double_div(duk_double_t x, duk_double_t y) { -#if !defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - if (DUK_UNLIKELY(y == 0.0)) { - /* In C99+ division by zero is undefined behavior so - * avoid it entirely. Hopefully the compiler is - * smart enough to avoid emitting any actual code - * because almost all practical platforms behave as - * expected. - */ - if (x > 0.0) { - if (DUK_SIGNBIT(y)) { - return -DUK_DOUBLE_INFINITY; - } else { - return DUK_DOUBLE_INFINITY; - } - } else if (x < 0.0) { - if (DUK_SIGNBIT(y)) { - return DUK_DOUBLE_INFINITY; - } else { - return -DUK_DOUBLE_INFINITY; - } - } else { - /* +/- 0, NaN */ - return DUK_DOUBLE_NAN; - } - } -#endif - - return x / y; -} diff -Nru duktape-2.3.0/src-input/duk_util.h duktape-2.2.0/src-input/duk_util.h --- duktape-2.3.0/src-input/duk_util.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_util.h 2017-09-23 01:06:08.000000000 +0000 @@ -315,13 +315,12 @@ (bw_ctx)->p += duk__enc_len; \ } while (0) /* XXX: add temporary duk__p pointer here too; sharing */ -/* XXX: avoid unsafe variants */ #define DUK_BW_WRITE_RAW_BYTES(thr,bw_ctx,valptr,valsz) do { \ const void *duk__valptr; \ duk_size_t duk__valsz; \ duk__valptr = (const void *) (valptr); \ duk__valsz = (duk_size_t) (valsz); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ (bw_ctx)->p += duk__valsz; \ } while (0) #define DUK_BW_WRITE_RAW_CSTRING(thr,bw_ctx,val) do { \ @@ -329,31 +328,31 @@ duk_size_t duk__val_len; \ duk__val = (const duk_uint8_t *) (val); \ duk__val_len = DUK_STRLEN((const char *) duk__val); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HSTRING(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HSTRING_GET_BYTELEN((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HBUFFER(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_GET_SIZE((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HBUFFER_FIXED(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_FIXED_GET_SIZE((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HBUFFER_DYNAMIC(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_DYNAMIC_GET_SIZE((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) @@ -417,14 +416,13 @@ DUK_BW_WRITE_RAW_CESU8((thr), (bw_ctx), (cp)); \ } while (0) /* XXX: add temporary duk__p pointer here too; sharing */ -/* XXX: avoid unsafe */ #define DUK_BW_WRITE_ENSURE_BYTES(thr,bw_ctx,valptr,valsz) do { \ const void *duk__valptr; \ duk_size_t duk__valsz; \ duk__valptr = (const void *) (valptr); \ duk__valsz = (duk_size_t) (valsz); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__valsz); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ (bw_ctx)->p += duk__valsz; \ } while (0) #define DUK_BW_WRITE_ENSURE_CSTRING(thr,bw_ctx,val) do { \ @@ -433,35 +431,35 @@ duk__val = (const duk_uint8_t *) (val); \ duk__val_len = DUK_STRLEN((const char *) duk__val); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HSTRING(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HSTRING_GET_BYTELEN((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HBUFFER(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_GET_SIZE((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HBUFFER_FIXED(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_FIXED_GET_SIZE((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HBUFFER_DYNAMIC(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_DYNAMIC_GET_SIZE((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) @@ -490,6 +488,10 @@ DUK_INTERNAL_DECL const duk_int16_t duk_hex_dectab_shift4[256]; DUK_INTERNAL_DECL const duk_uint16_t duk_hex_enctab[256]; #endif +#if defined(DUK_USE_BASE64_FASTPATH) +DUK_INTERNAL_DECL const duk_uint8_t duk_base64_enctab[64]; +DUK_INTERNAL_DECL const duk_int8_t duk_base64_dectab[256]; +#endif #endif /* !DUK_SINGLE_FILE */ /* Note: assumes that duk_util_probe_steps size is 32 */ @@ -544,127 +546,6 @@ DUK_INTERNAL_DECL void duk_byteswap_bytes(duk_uint8_t *p, duk_small_uint_t len); #endif -/* memcpy(), memmove() etc wrappers. The plain variants like duk_memcpy() - * assume C99+ and 'src' and 'dst' pointers must be non-NULL even when the - * operation size is zero. The unsafe variants like duk_memcpy_safe() deal - * with the zero size case explicitly, and allow NULL pointers in that case - * (which is undefined behavior in C99+). For the majority of actual targets - * a NULL pointer with a zero length is fine in practice. These wrappers are - * macros to force inlining; because there are hundreds of call sites, even a - * few extra bytes per call site adds up to ~1kB footprint. - */ -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) -#define duk_memcpy(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - (void) DUK_MEMCPY(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memcpy_unsafe(dst,src,len) duk_memcpy((dst), (src), (len)) -#define duk_memmove(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - (void) DUK_MEMMOVE(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memmove_unsafe(dst,src,len) duk_memmove((dst), (src), (len)) -#define duk_memset(dst,val,len) do { \ - void *duk__dst = (dst); \ - duk_small_int_t duk__val = (val); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - (void) DUK_MEMSET(duk__dst, duk__val, (size_t) duk__len); \ - } while (0) -#define duk_memset_unsafe(dst,val,len) duk_memset((dst), (val), (len)) -#define duk_memzero(dst,len) do { \ - void *duk__dst = (dst); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - (void) DUK_MEMZERO(duk__dst, (size_t) duk__len); \ - } while (0) -#define duk_memzero_unsafe(dst,len) duk_memzero((dst), (len)) -#else /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ -#define duk_memcpy(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMCPY(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memcpy_unsafe(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMCPY(duk__dst, duk__src, (size_t) duk__len); \ - } \ - } while (0) -#define duk_memmove(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMMOVE(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memmove_unsafe(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMMOVE(duk__dst, duk__src, (size_t) duk__len); \ - } \ - } while (0) -#define duk_memset(dst,val,len) do { \ - void *duk__dst = (dst); \ - duk_small_int_t duk__val = (val); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMSET(duk__dst, duk__val, (size_t) duk__len); \ - } while (0) -#define duk_memset_unsafe(dst,val,len) do { \ - void *duk__dst = (dst); \ - duk_small_int_t duk__val = (val); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMSET(duk__dst, duk__val, (size_t) duk__len); \ - } \ - } while (0) -#define duk_memzero(dst,len) do { \ - void *duk__dst = (dst); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMZERO(duk__dst, (size_t) duk__len); \ - } while (0) -#define duk_memzero_unsafe(dst,len) do { \ - void *duk__dst = (dst); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMZERO(duk__dst, (size_t) duk__len); \ - } \ - } while (0) -#endif /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ - -DUK_INTERNAL_DECL duk_small_int_t duk_memcmp(const void *s1, const void *s2, duk_size_t len); -DUK_INTERNAL_DECL duk_small_int_t duk_memcmp_unsafe(const void *s1, const void *s2, duk_size_t len); - DUK_INTERNAL_DECL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int32_t *ival); DUK_INTERNAL_DECL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival); DUK_INTERNAL_DECL duk_bool_t duk_double_is_anyinf(duk_double_t x); @@ -679,32 +560,5 @@ DUK_INTERNAL_DECL duk_bool_t duk_double_same_sign(duk_double_t x, duk_double_t y); DUK_INTERNAL_DECL duk_double_t duk_double_fmin(duk_double_t x, duk_double_t y); DUK_INTERNAL_DECL duk_double_t duk_double_fmax(duk_double_t x, duk_double_t y); -DUK_INTERNAL_DECL duk_bool_t duk_double_is_finite(duk_double_t x); -DUK_INTERNAL_DECL duk_bool_t duk_double_is_integer(duk_double_t x); -DUK_INTERNAL_DECL duk_bool_t duk_double_is_safe_integer(duk_double_t x); - -DUK_INTERNAL_DECL duk_double_t duk_double_div(duk_double_t x, duk_double_t y); -DUK_INTERNAL_DECL duk_int_t duk_double_to_int_t(duk_double_t x); -DUK_INTERNAL_DECL duk_uint_t duk_double_to_uint_t(duk_double_t x); -DUK_INTERNAL_DECL duk_int32_t duk_double_to_int32_t(duk_double_t x); -DUK_INTERNAL_DECL duk_uint32_t duk_double_to_uint32_t(duk_double_t x); -DUK_INTERNAL_DECL duk_float_t duk_double_to_float_t(duk_double_t x); - -/* - * Miscellaneous - */ - -/* Example: x = 0x10 = 0b00010000 - * x - 1 = 0x0f = 0b00001111 - * x & (x - 1) == 0 - * - * x = 0x07 = 0b00000111 - * x - 1 = 0x06 = 0b00000110 - * x & (x - 1) != 0 - * - * However, incorrectly true for x == 0 so check for that explicitly. - */ -#define DUK_IS_POWER_OF_TWO(x) \ - ((x) != 0U && ((x) & ((x) - 1U)) == 0U) #endif /* DUK_UTIL_H_INCLUDED */ diff -Nru duktape-2.3.0/src-input/duk_util_memory.c duktape-2.2.0/src-input/duk_util_memory.c --- duktape-2.3.0/src-input/duk_util_memory.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_util_memory.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* - * Memory utils. - */ - -#include "duk_internal.h" - -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp_unsafe(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL || len == 0U); - DUK_ASSERT(s2 != NULL || len == 0U); - return DUK_MEMCMP(s1, s2, (size_t) len); -} - -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL); - DUK_ASSERT(s2 != NULL); - return DUK_MEMCMP(s1, s2, (size_t) len); -} -#else /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp_unsafe(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL || len == 0U); - DUK_ASSERT(s2 != NULL || len == 0U); - if (DUK_UNLIKELY(len == 0U)) { - return 0; - } - DUK_ASSERT(s1 != NULL); - DUK_ASSERT(s2 != NULL); - return duk_memcmp(s1, s2, len); -} - -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL); - DUK_ASSERT(s2 != NULL); - return DUK_MEMCMP(s1, s2, (size_t) len); -} -#endif /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ diff -Nru duktape-2.3.0/src-input/duk_util_misc.c duktape-2.2.0/src-input/duk_util_misc.c --- duktape-2.3.0/src-input/duk_util_misc.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/duk_util_misc.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Misc util stuff. + * Misc util stuff */ #include "duk_internal.h" @@ -162,6 +162,45 @@ #endif /* DUK_USE_HEX_FASTPATH */ /* + * Table for base-64 encoding + */ + +#if defined(DUK_USE_BASE64_FASTPATH) +DUK_INTERNAL const duk_uint8_t duk_base64_enctab[64] = { + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* A...P */ + 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* Q...f */ + 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* g...v */ + 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2b, 0x2f /* w.../ */ +}; +#endif /* DUK_USE_BASE64_FASTPATH */ + +/* + * Table for base-64 decoding + */ + +#if defined(DUK_USE_BASE64_FASTPATH) +DUK_INTERNAL const duk_int8_t duk_base64_dectab[256] = { + /* -1 = error, -2 = allowed whitespace, -3 = padding ('='), 0...63 decoded bytes */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -1, -1, -2, -1, -1, /* 0x00...0x0f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10...0x1f */ + -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* 0x20...0x2f */ + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -3, -1, -1, /* 0x30...0x3f */ + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40...0x4f */ + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 0x50...0x5f */ + -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60...0x6f */ + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, /* 0x70...0x7f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x80...0x8f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x90...0x9f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xa0...0xaf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xb0...0xbf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xc0...0xcf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xd0...0xdf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xe0...0xef */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 0xf0...0xff */ +}; +#endif /* DUK_USE_BASE64_FASTPATH */ + +/* * Arbitrary byteswap for potentially unaligned values * * Used to byteswap pointers e.g. in debugger code. @@ -181,3 +220,186 @@ } } #endif + +/* + * Miscellaneous coercion / clamping helpers. + */ + +/* Check whether a duk_double_t is a whole number in the 32-bit range (reject + * negative zero), and if so, return a duk_int32_t. + * For compiler use: don't allow negative zero as it will cause trouble with + * LDINT+LDINTX, positive zero is OK. + */ +DUK_INTERNAL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int32_t *ival) { + duk_int32_t t; + + t = (duk_int32_t) x; + if (!((duk_double_t) t == x)) { + return 0; + } + if (t == 0) { + duk_double_union du; + du.d = x; + if (DUK_DBLUNION_HAS_SIGNBIT(&du)) { + return 0; + } + } + *ival = t; + return 1; +} + +/* Check whether a duk_double_t is a whole number in the 32-bit range, and if + * so, return a duk_int32_t. + */ +DUK_INTERNAL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival) { + duk_int32_t t; + + t = (duk_int32_t) x; + if (!((duk_double_t) t == x)) { + return 0; + } + *ival = t; + return 1; +} + +/* + * IEEE double checks + */ + +DUK_INTERNAL duk_bool_t duk_double_is_anyinf(duk_double_t x) { + duk_double_union du; + du.d = x; + return DUK_DBLUNION_IS_ANYINF(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_posinf(duk_double_t x) { + duk_double_union du; + du.d = x; + return DUK_DBLUNION_IS_POSINF(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_neginf(duk_double_t x) { + duk_double_union du; + du.d = x; + return DUK_DBLUNION_IS_NEGINF(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan(duk_double_t x) { + duk_double_union du; + du.d = x; + /* Assumes we're dealing with a Duktape internal NaN which is + * NaN normalized if duk_tval requires it. + */ + DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); + return DUK_DBLUNION_IS_NAN(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan_or_zero(duk_double_t x) { + duk_double_union du; + du.d = x; + /* Assumes we're dealing with a Duktape internal NaN which is + * NaN normalized if duk_tval requires it. + */ + DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); + return DUK_DBLUNION_IS_NAN(&du) || DUK_DBLUNION_IS_ANYZERO(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan_or_inf(duk_double_t x) { + duk_double_union du; + du.d = x; + /* If exponent is 0x7FF the argument is either a NaN or an + * infinity. We don't need to check any other fields. + */ +#if defined(DUK_USE_64BIT_OPS) +#if defined(DUK_USE_DOUBLE_ME) + return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000)) == DUK_U64_CONSTANT(0x000000007ff00000); +#else + return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000)) == DUK_U64_CONSTANT(0x7ff0000000000000); +#endif +#else + return (du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL) == 0x7ff00000UL; +#endif +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan_zero_inf(duk_double_t x) { + duk_double_union du; +#if defined(DUK_USE_64BIT_OPS) + duk_uint64_t t; +#else + duk_uint32_t t; +#endif + du.d = x; +#if defined(DUK_USE_64BIT_OPS) +#if defined(DUK_USE_DOUBLE_ME) + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000); + if (t == DUK_U64_CONSTANT(0x0000000000000000)) { + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x0000000080000000); + return t == 0; + } + if (t == DUK_U64_CONSTANT(0x000000007ff00000)) { + return 1; + } +#else + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000); + if (t == DUK_U64_CONSTANT(0x0000000000000000)) { + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x8000000000000000); + return t == 0; + } + if (t == DUK_U64_CONSTANT(0x7ff0000000000000)) { + return 1; + } +#endif +#else + t = du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL; + if (t == 0x00000000UL) { + return DUK_DBLUNION_IS_ANYZERO(&du); + } + if (t == 0x7ff00000UL) { + return 1; + } +#endif + return 0; +} + +DUK_INTERNAL duk_small_uint_t duk_double_signbit(duk_double_t x) { + duk_double_union du; + du.d = x; + return (duk_small_uint_t) DUK_DBLUNION_GET_SIGNBIT(&du); +} + +DUK_INTERNAL duk_double_t duk_double_trunc_towards_zero(duk_double_t x) { + /* XXX: optimize */ + duk_small_uint_t s = duk_double_signbit(x); + x = DUK_FLOOR(DUK_FABS(x)); /* truncate towards zero */ + if (s) { + x = -x; + } + return x; +} + +DUK_INTERNAL duk_bool_t duk_double_same_sign(duk_double_t x, duk_double_t y) { + duk_double_union du1; + duk_double_union du2; + du1.d = x; + du2.d = y; + + return (((du1.ui[DUK_DBL_IDX_UI0] ^ du2.ui[DUK_DBL_IDX_UI0]) & 0x80000000UL) == 0); +} + +DUK_INTERNAL duk_double_t duk_double_fmin(duk_double_t x, duk_double_t y) { + /* Doesn't replicate fmin() behavior exactly: for fmin() if one + * argument is a NaN, the other argument should be returned. + * Duktape doesn't rely on this behavior so the replacement can + * be simplified. + */ + return (x < y ? x : y); +} + +DUK_INTERNAL duk_double_t duk_double_fmax(duk_double_t x, duk_double_t y) { + /* Doesn't replicate fmax() behavior exactly: for fmax() if one + * argument is a NaN, the other argument should be returned. + * Duktape doesn't rely on this behavior so the replacement can + * be simplified. + */ + return (x > y ? x : y); +} diff -Nru duktape-2.3.0/src-input/SpecialCasing.txt duktape-2.2.0/src-input/SpecialCasing.txt --- duktape-2.3.0/src-input/SpecialCasing.txt 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/SpecialCasing.txt 2017-09-23 01:06:08.000000000 +0000 @@ -1,6 +1,6 @@ -# SpecialCasing-10.0.0.txt -# Date: 2017-04-14, 05:40:43 GMT -# © 2017 Unicode®, Inc. +# SpecialCasing-9.0.0.txt +# Date: 2016-03-02, 18:55:13 GMT +# © 2016 Unicode®, Inc. # Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries. # For terms of use, see http://www.unicode.org/terms_of_use.html # @@ -197,7 +197,7 @@ # ================================================================================ # Conditional Mappings -# The remainder of this file provides conditional casing data used to produce +# The remainder of this file provides conditional casing data used to produce # full case mappings. # ================================================================================ # Language-Insensitive Mappings diff -Nru duktape-2.3.0/src-input/strings.yaml duktape-2.2.0/src-input/strings.yaml --- duktape-2.3.0/src-input/strings.yaml 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/strings.yaml 2017-09-23 01:06:08.000000000 +0000 @@ -482,18 +482,6 @@ type: symbol variant: wellknown string: "Symbol.toPrimitive" - - str: - type: symbol - variant: wellknown - string: "Symbol.hasInstance" - - str: - type: symbol - variant: wellknown - string: "Symbol.toStringTag" - - str: - type: symbol - variant: wellknown - string: "Symbol.isConcatSpreadable" # Misc - str: "setPrototypeOf" diff -Nru duktape-2.3.0/src-input/UnicodeData.txt duktape-2.2.0/src-input/UnicodeData.txt --- duktape-2.3.0/src-input/UnicodeData.txt 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-input/UnicodeData.txt 2017-09-23 01:06:08.000000000 +0000 @@ -2072,17 +2072,6 @@ 085A;MANDAIC VOCALIZATION MARK;Mn;220;NSM;;;;;N;;;;; 085B;MANDAIC GEMINATION MARK;Mn;220;NSM;;;;;N;;;;; 085E;MANDAIC PUNCTUATION;Po;0;R;;;;;N;;;;; -0860;SYRIAC LETTER MALAYALAM NGA;Lo;0;AL;;;;;N;;;;; -0861;SYRIAC LETTER MALAYALAM JA;Lo;0;AL;;;;;N;;;;; -0862;SYRIAC LETTER MALAYALAM NYA;Lo;0;AL;;;;;N;;;;; -0863;SYRIAC LETTER MALAYALAM TTA;Lo;0;AL;;;;;N;;;;; -0864;SYRIAC LETTER MALAYALAM NNA;Lo;0;AL;;;;;N;;;;; -0865;SYRIAC LETTER MALAYALAM NNNA;Lo;0;AL;;;;;N;;;;; -0866;SYRIAC LETTER MALAYALAM BHA;Lo;0;AL;;;;;N;;;;; -0867;SYRIAC LETTER MALAYALAM RA;Lo;0;AL;;;;;N;;;;; -0868;SYRIAC LETTER MALAYALAM LLA;Lo;0;AL;;;;;N;;;;; -0869;SYRIAC LETTER MALAYALAM LLLA;Lo;0;AL;;;;;N;;;;; -086A;SYRIAC LETTER MALAYALAM SSA;Lo;0;AL;;;;;N;;;;; 08A0;ARABIC LETTER BEH WITH SMALL V BELOW;Lo;0;AL;;;;;N;;;;; 08A1;ARABIC LETTER BEH WITH HAMZA ABOVE;Lo;0;AL;;;;;N;;;;; 08A2;ARABIC LETTER JEEM WITH TWO DOTS ABOVE;Lo;0;AL;;;;;N;;;;; @@ -2377,8 +2366,6 @@ 09F9;BENGALI CURRENCY DENOMINATOR SIXTEEN;No;0;L;;;;16;N;;;;; 09FA;BENGALI ISSHAR;So;0;L;;;;;N;;;;; 09FB;BENGALI GANDA MARK;Sc;0;ET;;;;;N;;;;; -09FC;BENGALI LETTER VEDIC ANUSVARA;Lo;0;L;;;;;N;;;;; -09FD;BENGALI ABBREVIATION SIGN;Po;0;L;;;;;N;;;;; 0A01;GURMUKHI SIGN ADAK BINDI;Mn;0;NSM;;;;;N;;;;; 0A02;GURMUKHI SIGN BINDI;Mn;0;NSM;;;;;N;;;;; 0A03;GURMUKHI SIGN VISARGA;Mc;0;L;;;;;N;;;;; @@ -2543,12 +2530,6 @@ 0AF0;GUJARATI ABBREVIATION SIGN;Po;0;L;;;;;N;;;;; 0AF1;GUJARATI RUPEE SIGN;Sc;0;ET;;;;;N;;;;; 0AF9;GUJARATI LETTER ZHA;Lo;0;L;;;;;N;;;;; -0AFA;GUJARATI SIGN SUKUN;Mn;0;NSM;;;;;N;;;;; -0AFB;GUJARATI SIGN SHADDA;Mn;0;NSM;;;;;N;;;;; -0AFC;GUJARATI SIGN MADDAH;Mn;0;NSM;;;;;N;;;;; -0AFD;GUJARATI SIGN THREE-DOT NUKTA ABOVE;Mn;0;NSM;;;;;N;;;;; -0AFE;GUJARATI SIGN CIRCLE NUKTA ABOVE;Mn;0;NSM;;;;;N;;;;; -0AFF;GUJARATI SIGN TWO-CIRCLE NUKTA ABOVE;Mn;0;NSM;;;;;N;;;;; 0B01;ORIYA SIGN CANDRABINDU;Mn;0;NSM;;;;;N;;;;; 0B02;ORIYA SIGN ANUSVARA;Mc;0;L;;;;;N;;;;; 0B03;ORIYA SIGN VISARGA;Mc;0;L;;;;;N;;;;; @@ -2895,7 +2876,6 @@ 0CEF;KANNADA DIGIT NINE;Nd;0;L;;9;9;9;N;;;;; 0CF1;KANNADA SIGN JIHVAMULIYA;Lo;0;L;;;;;N;;;;; 0CF2;KANNADA SIGN UPADHMANIYA;Lo;0;L;;;;;N;;;;; -0D00;MALAYALAM SIGN COMBINING ANUSVARA ABOVE;Mn;0;NSM;;;;;N;;;;; 0D01;MALAYALAM SIGN CANDRABINDU;Mn;0;NSM;;;;;N;;;;; 0D02;MALAYALAM SIGN ANUSVARA;Mc;0;L;;;;;N;;;;; 0D03;MALAYALAM SIGN VISARGA;Mc;0;L;;;;;N;;;;; @@ -2951,8 +2931,6 @@ 0D38;MALAYALAM LETTER SA;Lo;0;L;;;;;N;;;;; 0D39;MALAYALAM LETTER HA;Lo;0;L;;;;;N;;;;; 0D3A;MALAYALAM LETTER TTTA;Lo;0;L;;;;;N;;;;; -0D3B;MALAYALAM SIGN VERTICAL BAR VIRAMA;Mn;9;NSM;;;;;N;;;;; -0D3C;MALAYALAM SIGN CIRCULAR VIRAMA;Mn;9;NSM;;;;;N;;;;; 0D3D;MALAYALAM SIGN AVAGRAHA;Lo;0;L;;;;;N;;;;; 0D3E;MALAYALAM VOWEL SIGN AA;Mc;0;L;;;;;N;;;;; 0D3F;MALAYALAM VOWEL SIGN I;Mc;0;L;;;;;N;;;;; @@ -6435,7 +6413,6 @@ 1CF4;VEDIC TONE CANDRA ABOVE;Mn;230;NSM;;;;;N;;;;; 1CF5;VEDIC SIGN JIHVAMULIYA;Lo;0;L;;;;;N;;;;; 1CF6;VEDIC SIGN UPADHMANIYA;Lo;0;L;;;;;N;;;;; -1CF7;VEDIC SIGN ATIKRAMA;Mc;0;L;;;;;N;;;;; 1CF8;VEDIC TONE RING ABOVE;Mn;230;NSM;;;;;N;;;;; 1CF9;VEDIC TONE DOUBLE RING ABOVE;Mn;230;NSM;;;;;N;;;;; 1D00;LATIN LETTER SMALL CAPITAL A;Ll;0;L;;;;;N;;;;; @@ -6684,10 +6661,6 @@ 1DF3;COMBINING LATIN SMALL LETTER O WITH DIAERESIS;Mn;230;NSM;;;;;N;;;;; 1DF4;COMBINING LATIN SMALL LETTER U WITH DIAERESIS;Mn;230;NSM;;;;;N;;;;; 1DF5;COMBINING UP TACK ABOVE;Mn;230;NSM;;;;;N;;;;; -1DF6;COMBINING KAVYKA ABOVE RIGHT;Mn;232;NSM;;;;;N;;;;; -1DF7;COMBINING KAVYKA ABOVE LEFT;Mn;228;NSM;;;;;N;;;;; -1DF8;COMBINING DOT ABOVE LEFT;Mn;228;NSM;;;;;N;;;;; -1DF9;COMBINING WIDE INVERTED BRIDGE BELOW;Mn;220;NSM;;;;;N;;;;; 1DFB;COMBINING DELETION MARK;Mn;230;NSM;;;;;N;;;;; 1DFC;COMBINING DOUBLE INVERTED BREVE BELOW;Mn;233;NSM;;;;;N;;;;; 1DFD;COMBINING ALMOST EQUAL TO BELOW;Mn;220;NSM;;;;;N;;;;; @@ -7366,7 +7339,6 @@ 20BC;MANAT SIGN;Sc;0;ET;;;;;N;;;;; 20BD;RUBLE SIGN;Sc;0;ET;;;;;N;;;;; 20BE;LARI SIGN;Sc;0;ET;;;;;N;;;;; -20BF;BITCOIN SIGN;Sc;0;ET;;;;;N;;;;; 20D0;COMBINING LEFT HARPOON ABOVE;Mn;230;NSM;;;;;N;NON-SPACING LEFT HARPOON ABOVE;;;; 20D1;COMBINING RIGHT HARPOON ABOVE;Mn;230;NSM;;;;;N;NON-SPACING RIGHT HARPOON ABOVE;;;; 20D2;COMBINING LONG VERTICAL LINE OVERLAY;Mn;1;NSM;;;;;N;NON-SPACING LONG VERTICAL BAR OVERLAY;;;; @@ -8163,7 +8135,6 @@ 23FC;POWER ON-OFF SYMBOL;So;0;ON;;;;;N;;;;; 23FD;POWER ON SYMBOL;So;0;ON;;;;;N;;;;; 23FE;POWER SLEEP SYMBOL;So;0;ON;;;;;N;;;;; -23FF;OBSERVER EYE SYMBOL;So;0;ON;;;;;N;;;;; 2400;SYMBOL FOR NULL;So;0;ON;;;;;N;GRAPHIC FOR NULL;;;; 2401;SYMBOL FOR START OF HEADING;So;0;ON;;;;;N;GRAPHIC FOR START OF HEADING;;;; 2402;SYMBOL FOR START OF TEXT;So;0;ON;;;;;N;GRAPHIC FOR START OF TEXT;;;; @@ -10112,7 +10083,6 @@ 2BCF;ROTATED WHITE FOUR POINTED CUSP;So;0;ON;;;;;N;;;;; 2BD0;SQUARE POSITION INDICATOR;So;0;ON;;;;;N;;;;; 2BD1;UNCERTAINTY SIGN;So;0;ON;;;;;N;;;;; -2BD2;GROUP MARK;So;0;ON;;;;;N;;;;; 2BEC;LEFTWARDS TWO-HEADED ARROW WITH TRIANGLE ARROWHEADS;So;0;ON;;;;;N;;;;; 2BED;UPWARDS TWO-HEADED ARROW WITH TRIANGLE ARROWHEADS;So;0;ON;;;;;N;;;;; 2BEE;RIGHTWARDS TWO-HEADED ARROW WITH TRIANGLE ARROWHEADS;So;0;ON;;;;;N;;;;; @@ -10645,11 +10615,6 @@ 2E42;DOUBLE LOW-REVERSED-9 QUOTATION MARK;Ps;0;ON;;;;;N;;;;; 2E43;DASH WITH LEFT UPTURN;Po;0;ON;;;;;N;;;;; 2E44;DOUBLE SUSPENSION MARK;Po;0;ON;;;;;N;;;;; -2E45;INVERTED LOW KAVYKA;Po;0;ON;;;;;N;;;;; -2E46;INVERTED LOW KAVYKA WITH KAVYKA ABOVE;Po;0;ON;;;;;N;;;;; -2E47;LOW KAVYKA;Po;0;ON;;;;;N;;;;; -2E48;LOW KAVYKA WITH DOT;Po;0;ON;;;;;N;;;;; -2E49;DOUBLE STACKED COMMA;Po;0;ON;;;;;N;;;;; 2E80;CJK RADICAL REPEAT;So;0;ON;;;;;N;;;;; 2E81;CJK RADICAL CLIFF;So;0;ON;;;;;N;;;;; 2E82;CJK RADICAL SECOND ONE;So;0;ON;;;;;N;;;;; @@ -11285,7 +11250,6 @@ 312B;BOPOMOFO LETTER NG;Lo;0;L;;;;;N;;;;; 312C;BOPOMOFO LETTER GN;Lo;0;L;;;;;N;;;;; 312D;BOPOMOFO LETTER IH;Lo;0;L;;;;;N;;;;; -312E;BOPOMOFO LETTER O WITH DOT ABOVE;Lo;0;L;;;;;N;;;;; 3131;HANGUL LETTER KIYEOK;Lo;0;L; 1100;;;;N;HANGUL LETTER GIYEOG;;;; 3132;HANGUL LETTER SSANGKIYEOK;Lo;0;L; 1101;;;;N;HANGUL LETTER SSANG GIYEOG;;;; 3133;HANGUL LETTER KIYEOK-SIOS;Lo;0;L; 11AA;;;;N;HANGUL LETTER GIYEOG SIOS;;;; @@ -12052,7 +12016,7 @@ 4DFE;HEXAGRAM FOR AFTER COMPLETION;So;0;ON;;;;;N;;;;; 4DFF;HEXAGRAM FOR BEFORE COMPLETION;So;0;ON;;;;;N;;;;; 4E00;;Lo;0;L;;;;;N;;;;; -9FEA;;Lo;0;L;;;;;N;;;;; +9FD5;;Lo;0;L;;;;;N;;;;; A000;YI SYLLABLE IT;Lo;0;L;;;;;N;;;;; A001;YI SYLLABLE IX;Lo;0;L;;;;;N;;;;; A002;YI SYLLABLE I;Lo;0;L;;;;;N;;;;; @@ -17129,9 +17093,6 @@ 10321;OLD ITALIC NUMERAL FIVE;No;0;L;;;;5;N;;;;; 10322;OLD ITALIC NUMERAL TEN;No;0;L;;;;10;N;;;;; 10323;OLD ITALIC NUMERAL FIFTY;No;0;L;;;;50;N;;;;; -1032D;OLD ITALIC LETTER YE;Lo;0;L;;;;;N;;;;; -1032E;OLD ITALIC LETTER NORTHERN TSE;Lo;0;L;;;;;N;;;;; -1032F;OLD ITALIC LETTER SOUTHERN TSE;Lo;0;L;;;;;N;;;;; 10330;GOTHIC LETTER AHSA;Lo;0;L;;;;;N;;;;; 10331;GOTHIC LETTER BAIRKAN;Lo;0;L;;;;;N;;;;; 10332;GOTHIC LETTER GIBA;Lo;0;L;;;;;N;;;;; @@ -20107,158 +20068,6 @@ 118F1;WARANG CITI NUMBER EIGHTY;No;0;L;;;;80;N;;;;; 118F2;WARANG CITI NUMBER NINETY;No;0;L;;;;90;N;;;;; 118FF;WARANG CITI OM;Lo;0;L;;;;;N;;;;; -11A00;ZANABAZAR SQUARE LETTER A;Lo;0;L;;;;;N;;;;; -11A01;ZANABAZAR SQUARE VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;; -11A02;ZANABAZAR SQUARE VOWEL SIGN UE;Mn;0;NSM;;;;;N;;;;; -11A03;ZANABAZAR SQUARE VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;; -11A04;ZANABAZAR SQUARE VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;; -11A05;ZANABAZAR SQUARE VOWEL SIGN OE;Mn;0;NSM;;;;;N;;;;; -11A06;ZANABAZAR SQUARE VOWEL SIGN O;Mn;0;NSM;;;;;N;;;;; -11A07;ZANABAZAR SQUARE VOWEL SIGN AI;Mc;0;L;;;;;N;;;;; -11A08;ZANABAZAR SQUARE VOWEL SIGN AU;Mc;0;L;;;;;N;;;;; -11A09;ZANABAZAR SQUARE VOWEL SIGN REVERSED I;Mn;0;NSM;;;;;N;;;;; -11A0A;ZANABAZAR SQUARE VOWEL LENGTH MARK;Mn;0;NSM;;;;;N;;;;; -11A0B;ZANABAZAR SQUARE LETTER KA;Lo;0;L;;;;;N;;;;; -11A0C;ZANABAZAR SQUARE LETTER KHA;Lo;0;L;;;;;N;;;;; -11A0D;ZANABAZAR SQUARE LETTER GA;Lo;0;L;;;;;N;;;;; -11A0E;ZANABAZAR SQUARE LETTER GHA;Lo;0;L;;;;;N;;;;; -11A0F;ZANABAZAR SQUARE LETTER NGA;Lo;0;L;;;;;N;;;;; -11A10;ZANABAZAR SQUARE LETTER CA;Lo;0;L;;;;;N;;;;; -11A11;ZANABAZAR SQUARE LETTER CHA;Lo;0;L;;;;;N;;;;; -11A12;ZANABAZAR SQUARE LETTER JA;Lo;0;L;;;;;N;;;;; -11A13;ZANABAZAR SQUARE LETTER NYA;Lo;0;L;;;;;N;;;;; -11A14;ZANABAZAR SQUARE LETTER TTA;Lo;0;L;;;;;N;;;;; -11A15;ZANABAZAR SQUARE LETTER TTHA;Lo;0;L;;;;;N;;;;; -11A16;ZANABAZAR SQUARE LETTER DDA;Lo;0;L;;;;;N;;;;; -11A17;ZANABAZAR SQUARE LETTER DDHA;Lo;0;L;;;;;N;;;;; -11A18;ZANABAZAR SQUARE LETTER NNA;Lo;0;L;;;;;N;;;;; -11A19;ZANABAZAR SQUARE LETTER TA;Lo;0;L;;;;;N;;;;; -11A1A;ZANABAZAR SQUARE LETTER THA;Lo;0;L;;;;;N;;;;; -11A1B;ZANABAZAR SQUARE LETTER DA;Lo;0;L;;;;;N;;;;; -11A1C;ZANABAZAR SQUARE LETTER DHA;Lo;0;L;;;;;N;;;;; -11A1D;ZANABAZAR SQUARE LETTER NA;Lo;0;L;;;;;N;;;;; -11A1E;ZANABAZAR SQUARE LETTER PA;Lo;0;L;;;;;N;;;;; -11A1F;ZANABAZAR SQUARE LETTER PHA;Lo;0;L;;;;;N;;;;; -11A20;ZANABAZAR SQUARE LETTER BA;Lo;0;L;;;;;N;;;;; -11A21;ZANABAZAR SQUARE LETTER BHA;Lo;0;L;;;;;N;;;;; -11A22;ZANABAZAR SQUARE LETTER MA;Lo;0;L;;;;;N;;;;; -11A23;ZANABAZAR SQUARE LETTER TSA;Lo;0;L;;;;;N;;;;; -11A24;ZANABAZAR SQUARE LETTER TSHA;Lo;0;L;;;;;N;;;;; -11A25;ZANABAZAR SQUARE LETTER DZA;Lo;0;L;;;;;N;;;;; -11A26;ZANABAZAR SQUARE LETTER DZHA;Lo;0;L;;;;;N;;;;; -11A27;ZANABAZAR SQUARE LETTER ZHA;Lo;0;L;;;;;N;;;;; -11A28;ZANABAZAR SQUARE LETTER ZA;Lo;0;L;;;;;N;;;;; -11A29;ZANABAZAR SQUARE LETTER -A;Lo;0;L;;;;;N;;;;; -11A2A;ZANABAZAR SQUARE LETTER YA;Lo;0;L;;;;;N;;;;; -11A2B;ZANABAZAR SQUARE LETTER RA;Lo;0;L;;;;;N;;;;; -11A2C;ZANABAZAR SQUARE LETTER LA;Lo;0;L;;;;;N;;;;; -11A2D;ZANABAZAR SQUARE LETTER VA;Lo;0;L;;;;;N;;;;; -11A2E;ZANABAZAR SQUARE LETTER SHA;Lo;0;L;;;;;N;;;;; -11A2F;ZANABAZAR SQUARE LETTER SSA;Lo;0;L;;;;;N;;;;; -11A30;ZANABAZAR SQUARE LETTER SA;Lo;0;L;;;;;N;;;;; -11A31;ZANABAZAR SQUARE LETTER HA;Lo;0;L;;;;;N;;;;; -11A32;ZANABAZAR SQUARE LETTER KSSA;Lo;0;L;;;;;N;;;;; -11A33;ZANABAZAR SQUARE FINAL CONSONANT MARK;Mn;0;NSM;;;;;N;;;;; -11A34;ZANABAZAR SQUARE SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;; -11A35;ZANABAZAR SQUARE SIGN CANDRABINDU;Mn;0;NSM;;;;;N;;;;; -11A36;ZANABAZAR SQUARE SIGN CANDRABINDU WITH ORNAMENT;Mn;0;NSM;;;;;N;;;;; -11A37;ZANABAZAR SQUARE SIGN CANDRA WITH ORNAMENT;Mn;0;NSM;;;;;N;;;;; -11A38;ZANABAZAR SQUARE SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;; -11A39;ZANABAZAR SQUARE SIGN VISARGA;Mc;0;L;;;;;N;;;;; -11A3A;ZANABAZAR SQUARE CLUSTER-INITIAL LETTER RA;Lo;0;L;;;;;N;;;;; -11A3B;ZANABAZAR SQUARE CLUSTER-FINAL LETTER YA;Mn;0;NSM;;;;;N;;;;; -11A3C;ZANABAZAR SQUARE CLUSTER-FINAL LETTER RA;Mn;0;NSM;;;;;N;;;;; -11A3D;ZANABAZAR SQUARE CLUSTER-FINAL LETTER LA;Mn;0;NSM;;;;;N;;;;; -11A3E;ZANABAZAR SQUARE CLUSTER-FINAL LETTER VA;Mn;0;NSM;;;;;N;;;;; -11A3F;ZANABAZAR SQUARE INITIAL HEAD MARK;Po;0;L;;;;;N;;;;; -11A40;ZANABAZAR SQUARE CLOSING HEAD MARK;Po;0;L;;;;;N;;;;; -11A41;ZANABAZAR SQUARE MARK TSHEG;Po;0;L;;;;;N;;;;; -11A42;ZANABAZAR SQUARE MARK SHAD;Po;0;L;;;;;N;;;;; -11A43;ZANABAZAR SQUARE MARK DOUBLE SHAD;Po;0;L;;;;;N;;;;; -11A44;ZANABAZAR SQUARE MARK LONG TSHEG;Po;0;L;;;;;N;;;;; -11A45;ZANABAZAR SQUARE INITIAL DOUBLE-LINED HEAD MARK;Po;0;L;;;;;N;;;;; -11A46;ZANABAZAR SQUARE CLOSING DOUBLE-LINED HEAD MARK;Po;0;L;;;;;N;;;;; -11A47;ZANABAZAR SQUARE SUBJOINER;Mn;9;NSM;;;;;N;;;;; -11A50;SOYOMBO LETTER A;Lo;0;L;;;;;N;;;;; -11A51;SOYOMBO VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;; -11A52;SOYOMBO VOWEL SIGN UE;Mn;0;NSM;;;;;N;;;;; -11A53;SOYOMBO VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;; -11A54;SOYOMBO VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;; -11A55;SOYOMBO VOWEL SIGN O;Mn;0;NSM;;;;;N;;;;; -11A56;SOYOMBO VOWEL SIGN OE;Mn;0;NSM;;;;;N;;;;; -11A57;SOYOMBO VOWEL SIGN AI;Mc;0;L;;;;;N;;;;; -11A58;SOYOMBO VOWEL SIGN AU;Mc;0;L;;;;;N;;;;; -11A59;SOYOMBO VOWEL SIGN VOCALIC R;Mn;0;NSM;;;;;N;;;;; -11A5A;SOYOMBO VOWEL SIGN VOCALIC L;Mn;0;NSM;;;;;N;;;;; -11A5B;SOYOMBO VOWEL LENGTH MARK;Mn;0;NSM;;;;;N;;;;; -11A5C;SOYOMBO LETTER KA;Lo;0;L;;;;;N;;;;; -11A5D;SOYOMBO LETTER KHA;Lo;0;L;;;;;N;;;;; -11A5E;SOYOMBO LETTER GA;Lo;0;L;;;;;N;;;;; -11A5F;SOYOMBO LETTER GHA;Lo;0;L;;;;;N;;;;; -11A60;SOYOMBO LETTER NGA;Lo;0;L;;;;;N;;;;; -11A61;SOYOMBO LETTER CA;Lo;0;L;;;;;N;;;;; -11A62;SOYOMBO LETTER CHA;Lo;0;L;;;;;N;;;;; -11A63;SOYOMBO LETTER JA;Lo;0;L;;;;;N;;;;; -11A64;SOYOMBO LETTER JHA;Lo;0;L;;;;;N;;;;; -11A65;SOYOMBO LETTER NYA;Lo;0;L;;;;;N;;;;; -11A66;SOYOMBO LETTER TTA;Lo;0;L;;;;;N;;;;; -11A67;SOYOMBO LETTER TTHA;Lo;0;L;;;;;N;;;;; -11A68;SOYOMBO LETTER DDA;Lo;0;L;;;;;N;;;;; -11A69;SOYOMBO LETTER DDHA;Lo;0;L;;;;;N;;;;; -11A6A;SOYOMBO LETTER NNA;Lo;0;L;;;;;N;;;;; -11A6B;SOYOMBO LETTER TA;Lo;0;L;;;;;N;;;;; -11A6C;SOYOMBO LETTER THA;Lo;0;L;;;;;N;;;;; -11A6D;SOYOMBO LETTER DA;Lo;0;L;;;;;N;;;;; -11A6E;SOYOMBO LETTER DHA;Lo;0;L;;;;;N;;;;; -11A6F;SOYOMBO LETTER NA;Lo;0;L;;;;;N;;;;; -11A70;SOYOMBO LETTER PA;Lo;0;L;;;;;N;;;;; -11A71;SOYOMBO LETTER PHA;Lo;0;L;;;;;N;;;;; -11A72;SOYOMBO LETTER BA;Lo;0;L;;;;;N;;;;; -11A73;SOYOMBO LETTER BHA;Lo;0;L;;;;;N;;;;; -11A74;SOYOMBO LETTER MA;Lo;0;L;;;;;N;;;;; -11A75;SOYOMBO LETTER TSA;Lo;0;L;;;;;N;;;;; -11A76;SOYOMBO LETTER TSHA;Lo;0;L;;;;;N;;;;; -11A77;SOYOMBO LETTER DZA;Lo;0;L;;;;;N;;;;; -11A78;SOYOMBO LETTER ZHA;Lo;0;L;;;;;N;;;;; -11A79;SOYOMBO LETTER ZA;Lo;0;L;;;;;N;;;;; -11A7A;SOYOMBO LETTER -A;Lo;0;L;;;;;N;;;;; -11A7B;SOYOMBO LETTER YA;Lo;0;L;;;;;N;;;;; -11A7C;SOYOMBO LETTER RA;Lo;0;L;;;;;N;;;;; -11A7D;SOYOMBO LETTER LA;Lo;0;L;;;;;N;;;;; -11A7E;SOYOMBO LETTER VA;Lo;0;L;;;;;N;;;;; -11A7F;SOYOMBO LETTER SHA;Lo;0;L;;;;;N;;;;; -11A80;SOYOMBO LETTER SSA;Lo;0;L;;;;;N;;;;; -11A81;SOYOMBO LETTER SA;Lo;0;L;;;;;N;;;;; -11A82;SOYOMBO LETTER HA;Lo;0;L;;;;;N;;;;; -11A83;SOYOMBO LETTER KSSA;Lo;0;L;;;;;N;;;;; -11A86;SOYOMBO CLUSTER-INITIAL LETTER RA;Lo;0;L;;;;;N;;;;; -11A87;SOYOMBO CLUSTER-INITIAL LETTER LA;Lo;0;L;;;;;N;;;;; -11A88;SOYOMBO CLUSTER-INITIAL LETTER SHA;Lo;0;L;;;;;N;;;;; -11A89;SOYOMBO CLUSTER-INITIAL LETTER SA;Lo;0;L;;;;;N;;;;; -11A8A;SOYOMBO FINAL CONSONANT SIGN G;Mn;0;NSM;;;;;N;;;;; -11A8B;SOYOMBO FINAL CONSONANT SIGN K;Mn;0;NSM;;;;;N;;;;; -11A8C;SOYOMBO FINAL CONSONANT SIGN NG;Mn;0;NSM;;;;;N;;;;; -11A8D;SOYOMBO FINAL CONSONANT SIGN D;Mn;0;NSM;;;;;N;;;;; -11A8E;SOYOMBO FINAL CONSONANT SIGN N;Mn;0;NSM;;;;;N;;;;; -11A8F;SOYOMBO FINAL CONSONANT SIGN B;Mn;0;NSM;;;;;N;;;;; -11A90;SOYOMBO FINAL CONSONANT SIGN M;Mn;0;NSM;;;;;N;;;;; -11A91;SOYOMBO FINAL CONSONANT SIGN R;Mn;0;NSM;;;;;N;;;;; -11A92;SOYOMBO FINAL CONSONANT SIGN L;Mn;0;NSM;;;;;N;;;;; -11A93;SOYOMBO FINAL CONSONANT SIGN SH;Mn;0;NSM;;;;;N;;;;; -11A94;SOYOMBO FINAL CONSONANT SIGN S;Mn;0;NSM;;;;;N;;;;; -11A95;SOYOMBO FINAL CONSONANT SIGN -A;Mn;0;NSM;;;;;N;;;;; -11A96;SOYOMBO SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;; -11A97;SOYOMBO SIGN VISARGA;Mc;0;L;;;;;N;;;;; -11A98;SOYOMBO GEMINATION MARK;Mn;0;NSM;;;;;N;;;;; -11A99;SOYOMBO SUBJOINER;Mn;9;NSM;;;;;N;;;;; -11A9A;SOYOMBO MARK TSHEG;Po;0;L;;;;;N;;;;; -11A9B;SOYOMBO MARK SHAD;Po;0;L;;;;;N;;;;; -11A9C;SOYOMBO MARK DOUBLE SHAD;Po;0;L;;;;;N;;;;; -11A9E;SOYOMBO HEAD MARK WITH MOON AND SUN AND TRIPLE FLAME;Po;0;L;;;;;N;;;;; -11A9F;SOYOMBO HEAD MARK WITH MOON AND SUN AND FLAME;Po;0;L;;;;;N;;;;; -11AA0;SOYOMBO HEAD MARK WITH MOON AND SUN;Po;0;L;;;;;N;;;;; -11AA1;SOYOMBO TERMINAL MARK-1;Po;0;L;;;;;N;;;;; -11AA2;SOYOMBO TERMINAL MARK-2;Po;0;L;;;;;N;;;;; 11AC0;PAU CIN HAU LETTER PA;Lo;0;L;;;;;N;;;;; 11AC1;PAU CIN HAU LETTER KA;Lo;0;L;;;;;N;;;;; 11AC2;PAU CIN HAU LETTER LA;Lo;0;L;;;;;N;;;;; @@ -20481,81 +20290,6 @@ 11CB4;MARCHEN VOWEL SIGN O;Mc;0;L;;;;;N;;;;; 11CB5;MARCHEN SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;; 11CB6;MARCHEN SIGN CANDRABINDU;Mn;0;NSM;;;;;N;;;;; -11D00;MASARAM GONDI LETTER A;Lo;0;L;;;;;N;;;;; -11D01;MASARAM GONDI LETTER AA;Lo;0;L;;;;;N;;;;; -11D02;MASARAM GONDI LETTER I;Lo;0;L;;;;;N;;;;; -11D03;MASARAM GONDI LETTER II;Lo;0;L;;;;;N;;;;; -11D04;MASARAM GONDI LETTER U;Lo;0;L;;;;;N;;;;; -11D05;MASARAM GONDI LETTER UU;Lo;0;L;;;;;N;;;;; -11D06;MASARAM GONDI LETTER E;Lo;0;L;;;;;N;;;;; -11D08;MASARAM GONDI LETTER AI;Lo;0;L;;;;;N;;;;; -11D09;MASARAM GONDI LETTER O;Lo;0;L;;;;;N;;;;; -11D0B;MASARAM GONDI LETTER AU;Lo;0;L;;;;;N;;;;; -11D0C;MASARAM GONDI LETTER KA;Lo;0;L;;;;;N;;;;; -11D0D;MASARAM GONDI LETTER KHA;Lo;0;L;;;;;N;;;;; -11D0E;MASARAM GONDI LETTER GA;Lo;0;L;;;;;N;;;;; -11D0F;MASARAM GONDI LETTER GHA;Lo;0;L;;;;;N;;;;; -11D10;MASARAM GONDI LETTER NGA;Lo;0;L;;;;;N;;;;; -11D11;MASARAM GONDI LETTER CA;Lo;0;L;;;;;N;;;;; -11D12;MASARAM GONDI LETTER CHA;Lo;0;L;;;;;N;;;;; -11D13;MASARAM GONDI LETTER JA;Lo;0;L;;;;;N;;;;; -11D14;MASARAM GONDI LETTER JHA;Lo;0;L;;;;;N;;;;; -11D15;MASARAM GONDI LETTER NYA;Lo;0;L;;;;;N;;;;; -11D16;MASARAM GONDI LETTER TTA;Lo;0;L;;;;;N;;;;; -11D17;MASARAM GONDI LETTER TTHA;Lo;0;L;;;;;N;;;;; -11D18;MASARAM GONDI LETTER DDA;Lo;0;L;;;;;N;;;;; -11D19;MASARAM GONDI LETTER DDHA;Lo;0;L;;;;;N;;;;; -11D1A;MASARAM GONDI LETTER NNA;Lo;0;L;;;;;N;;;;; -11D1B;MASARAM GONDI LETTER TA;Lo;0;L;;;;;N;;;;; -11D1C;MASARAM GONDI LETTER THA;Lo;0;L;;;;;N;;;;; -11D1D;MASARAM GONDI LETTER DA;Lo;0;L;;;;;N;;;;; -11D1E;MASARAM GONDI LETTER DHA;Lo;0;L;;;;;N;;;;; -11D1F;MASARAM GONDI LETTER NA;Lo;0;L;;;;;N;;;;; -11D20;MASARAM GONDI LETTER PA;Lo;0;L;;;;;N;;;;; -11D21;MASARAM GONDI LETTER PHA;Lo;0;L;;;;;N;;;;; -11D22;MASARAM GONDI LETTER BA;Lo;0;L;;;;;N;;;;; -11D23;MASARAM GONDI LETTER BHA;Lo;0;L;;;;;N;;;;; -11D24;MASARAM GONDI LETTER MA;Lo;0;L;;;;;N;;;;; -11D25;MASARAM GONDI LETTER YA;Lo;0;L;;;;;N;;;;; -11D26;MASARAM GONDI LETTER RA;Lo;0;L;;;;;N;;;;; -11D27;MASARAM GONDI LETTER LA;Lo;0;L;;;;;N;;;;; -11D28;MASARAM GONDI LETTER VA;Lo;0;L;;;;;N;;;;; -11D29;MASARAM GONDI LETTER SHA;Lo;0;L;;;;;N;;;;; -11D2A;MASARAM GONDI LETTER SSA;Lo;0;L;;;;;N;;;;; -11D2B;MASARAM GONDI LETTER SA;Lo;0;L;;;;;N;;;;; -11D2C;MASARAM GONDI LETTER HA;Lo;0;L;;;;;N;;;;; -11D2D;MASARAM GONDI LETTER LLA;Lo;0;L;;;;;N;;;;; -11D2E;MASARAM GONDI LETTER KSSA;Lo;0;L;;;;;N;;;;; -11D2F;MASARAM GONDI LETTER JNYA;Lo;0;L;;;;;N;;;;; -11D30;MASARAM GONDI LETTER TRA;Lo;0;L;;;;;N;;;;; -11D31;MASARAM GONDI VOWEL SIGN AA;Mn;0;NSM;;;;;N;;;;; -11D32;MASARAM GONDI VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;; -11D33;MASARAM GONDI VOWEL SIGN II;Mn;0;NSM;;;;;N;;;;; -11D34;MASARAM GONDI VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;; -11D35;MASARAM GONDI VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;; -11D36;MASARAM GONDI VOWEL SIGN VOCALIC R;Mn;0;NSM;;;;;N;;;;; -11D3A;MASARAM GONDI VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;; -11D3C;MASARAM GONDI VOWEL SIGN AI;Mn;0;NSM;;;;;N;;;;; -11D3D;MASARAM GONDI VOWEL SIGN O;Mn;0;NSM;;;;;N;;;;; -11D3F;MASARAM GONDI VOWEL SIGN AU;Mn;0;NSM;;;;;N;;;;; -11D40;MASARAM GONDI SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;; -11D41;MASARAM GONDI SIGN VISARGA;Mn;0;NSM;;;;;N;;;;; -11D42;MASARAM GONDI SIGN NUKTA;Mn;7;NSM;;;;;N;;;;; -11D43;MASARAM GONDI SIGN CANDRA;Mn;0;NSM;;;;;N;;;;; -11D44;MASARAM GONDI SIGN HALANTA;Mn;9;NSM;;;;;N;;;;; -11D45;MASARAM GONDI VIRAMA;Mn;9;NSM;;;;;N;;;;; -11D46;MASARAM GONDI REPHA;Lo;0;L;;;;;N;;;;; -11D47;MASARAM GONDI RA-KARA;Mn;0;NSM;;;;;N;;;;; -11D50;MASARAM GONDI DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;; -11D51;MASARAM GONDI DIGIT ONE;Nd;0;L;;1;1;1;N;;;;; -11D52;MASARAM GONDI DIGIT TWO;Nd;0;L;;2;2;2;N;;;;; -11D53;MASARAM GONDI DIGIT THREE;Nd;0;L;;3;3;3;N;;;;; -11D54;MASARAM GONDI DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;; -11D55;MASARAM GONDI DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;; -11D56;MASARAM GONDI DIGIT SIX;Nd;0;L;;6;6;6;N;;;;; -11D57;MASARAM GONDI DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;; -11D58;MASARAM GONDI DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;; -11D59;MASARAM GONDI DIGIT NINE;Nd;0;L;;9;9;9;N;;;;; 12000;CUNEIFORM SIGN A;Lo;0;L;;;;;N;;;;; 12001;CUNEIFORM SIGN A TIMES A;Lo;0;L;;;;;N;;;;; 12002;CUNEIFORM SIGN A TIMES BAD;Lo;0;L;;;;;N;;;;; @@ -24353,7 +24087,6 @@ 16F9E;MIAO LETTER REFORMED TONE-6;Lm;0;L;;;;;N;;;;; 16F9F;MIAO LETTER REFORMED TONE-8;Lm;0;L;;;;;N;;;;; 16FE0;TANGUT ITERATION MARK;Lm;0;L;;;;;N;;;;; -16FE1;NUSHU ITERATION MARK;Lm;0;L;;;;;N;;;;; 17000;;Lo;0;L;;;;;N;;;;; 187EC;;Lo;0;L;;;;;N;;;;; 18800;TANGUT COMPONENT-001;Lo;0;L;;;;;N;;;;; @@ -25113,687 +24846,6 @@ 18AF2;TANGUT COMPONENT-755;Lo;0;L;;;;;N;;;;; 1B000;KATAKANA LETTER ARCHAIC E;Lo;0;L;;;;;N;;;;; 1B001;HIRAGANA LETTER ARCHAIC YE;Lo;0;L;;;;;N;;;;; -1B002;HENTAIGANA LETTER A-1;Lo;0;L;;;;;N;;;;; -1B003;HENTAIGANA LETTER A-2;Lo;0;L;;;;;N;;;;; -1B004;HENTAIGANA LETTER A-3;Lo;0;L;;;;;N;;;;; -1B005;HENTAIGANA LETTER A-WO;Lo;0;L;;;;;N;;;;; -1B006;HENTAIGANA LETTER I-1;Lo;0;L;;;;;N;;;;; -1B007;HENTAIGANA LETTER I-2;Lo;0;L;;;;;N;;;;; -1B008;HENTAIGANA LETTER I-3;Lo;0;L;;;;;N;;;;; -1B009;HENTAIGANA LETTER I-4;Lo;0;L;;;;;N;;;;; -1B00A;HENTAIGANA LETTER U-1;Lo;0;L;;;;;N;;;;; -1B00B;HENTAIGANA LETTER U-2;Lo;0;L;;;;;N;;;;; -1B00C;HENTAIGANA LETTER U-3;Lo;0;L;;;;;N;;;;; -1B00D;HENTAIGANA LETTER U-4;Lo;0;L;;;;;N;;;;; -1B00E;HENTAIGANA LETTER U-5;Lo;0;L;;;;;N;;;;; -1B00F;HENTAIGANA LETTER E-2;Lo;0;L;;;;;N;;;;; -1B010;HENTAIGANA LETTER E-3;Lo;0;L;;;;;N;;;;; -1B011;HENTAIGANA LETTER E-4;Lo;0;L;;;;;N;;;;; -1B012;HENTAIGANA LETTER E-5;Lo;0;L;;;;;N;;;;; -1B013;HENTAIGANA LETTER E-6;Lo;0;L;;;;;N;;;;; -1B014;HENTAIGANA LETTER O-1;Lo;0;L;;;;;N;;;;; -1B015;HENTAIGANA LETTER O-2;Lo;0;L;;;;;N;;;;; -1B016;HENTAIGANA LETTER O-3;Lo;0;L;;;;;N;;;;; -1B017;HENTAIGANA LETTER KA-1;Lo;0;L;;;;;N;;;;; -1B018;HENTAIGANA LETTER KA-2;Lo;0;L;;;;;N;;;;; -1B019;HENTAIGANA LETTER KA-3;Lo;0;L;;;;;N;;;;; -1B01A;HENTAIGANA LETTER KA-4;Lo;0;L;;;;;N;;;;; -1B01B;HENTAIGANA LETTER KA-5;Lo;0;L;;;;;N;;;;; -1B01C;HENTAIGANA LETTER KA-6;Lo;0;L;;;;;N;;;;; -1B01D;HENTAIGANA LETTER KA-7;Lo;0;L;;;;;N;;;;; -1B01E;HENTAIGANA LETTER KA-8;Lo;0;L;;;;;N;;;;; -1B01F;HENTAIGANA LETTER KA-9;Lo;0;L;;;;;N;;;;; -1B020;HENTAIGANA LETTER KA-10;Lo;0;L;;;;;N;;;;; -1B021;HENTAIGANA LETTER KA-11;Lo;0;L;;;;;N;;;;; -1B022;HENTAIGANA LETTER KA-KE;Lo;0;L;;;;;N;;;;; -1B023;HENTAIGANA LETTER KI-1;Lo;0;L;;;;;N;;;;; -1B024;HENTAIGANA LETTER KI-2;Lo;0;L;;;;;N;;;;; -1B025;HENTAIGANA LETTER KI-3;Lo;0;L;;;;;N;;;;; -1B026;HENTAIGANA LETTER KI-4;Lo;0;L;;;;;N;;;;; -1B027;HENTAIGANA LETTER KI-5;Lo;0;L;;;;;N;;;;; -1B028;HENTAIGANA LETTER KI-6;Lo;0;L;;;;;N;;;;; -1B029;HENTAIGANA LETTER KI-7;Lo;0;L;;;;;N;;;;; -1B02A;HENTAIGANA LETTER KI-8;Lo;0;L;;;;;N;;;;; -1B02B;HENTAIGANA LETTER KU-1;Lo;0;L;;;;;N;;;;; -1B02C;HENTAIGANA LETTER KU-2;Lo;0;L;;;;;N;;;;; -1B02D;HENTAIGANA LETTER KU-3;Lo;0;L;;;;;N;;;;; -1B02E;HENTAIGANA LETTER KU-4;Lo;0;L;;;;;N;;;;; -1B02F;HENTAIGANA LETTER KU-5;Lo;0;L;;;;;N;;;;; -1B030;HENTAIGANA LETTER KU-6;Lo;0;L;;;;;N;;;;; -1B031;HENTAIGANA LETTER KU-7;Lo;0;L;;;;;N;;;;; -1B032;HENTAIGANA LETTER KE-1;Lo;0;L;;;;;N;;;;; -1B033;HENTAIGANA LETTER KE-2;Lo;0;L;;;;;N;;;;; -1B034;HENTAIGANA LETTER KE-3;Lo;0;L;;;;;N;;;;; -1B035;HENTAIGANA LETTER KE-4;Lo;0;L;;;;;N;;;;; -1B036;HENTAIGANA LETTER KE-5;Lo;0;L;;;;;N;;;;; -1B037;HENTAIGANA LETTER KE-6;Lo;0;L;;;;;N;;;;; -1B038;HENTAIGANA LETTER KO-1;Lo;0;L;;;;;N;;;;; -1B039;HENTAIGANA LETTER KO-2;Lo;0;L;;;;;N;;;;; -1B03A;HENTAIGANA LETTER KO-3;Lo;0;L;;;;;N;;;;; -1B03B;HENTAIGANA LETTER KO-KI;Lo;0;L;;;;;N;;;;; -1B03C;HENTAIGANA LETTER SA-1;Lo;0;L;;;;;N;;;;; -1B03D;HENTAIGANA LETTER SA-2;Lo;0;L;;;;;N;;;;; -1B03E;HENTAIGANA LETTER SA-3;Lo;0;L;;;;;N;;;;; -1B03F;HENTAIGANA LETTER SA-4;Lo;0;L;;;;;N;;;;; -1B040;HENTAIGANA LETTER SA-5;Lo;0;L;;;;;N;;;;; -1B041;HENTAIGANA LETTER SA-6;Lo;0;L;;;;;N;;;;; -1B042;HENTAIGANA LETTER SA-7;Lo;0;L;;;;;N;;;;; -1B043;HENTAIGANA LETTER SA-8;Lo;0;L;;;;;N;;;;; -1B044;HENTAIGANA LETTER SI-1;Lo;0;L;;;;;N;;;;; -1B045;HENTAIGANA LETTER SI-2;Lo;0;L;;;;;N;;;;; -1B046;HENTAIGANA LETTER SI-3;Lo;0;L;;;;;N;;;;; -1B047;HENTAIGANA LETTER SI-4;Lo;0;L;;;;;N;;;;; -1B048;HENTAIGANA LETTER SI-5;Lo;0;L;;;;;N;;;;; -1B049;HENTAIGANA LETTER SI-6;Lo;0;L;;;;;N;;;;; -1B04A;HENTAIGANA LETTER SU-1;Lo;0;L;;;;;N;;;;; -1B04B;HENTAIGANA LETTER SU-2;Lo;0;L;;;;;N;;;;; -1B04C;HENTAIGANA LETTER SU-3;Lo;0;L;;;;;N;;;;; -1B04D;HENTAIGANA LETTER SU-4;Lo;0;L;;;;;N;;;;; -1B04E;HENTAIGANA LETTER SU-5;Lo;0;L;;;;;N;;;;; -1B04F;HENTAIGANA LETTER SU-6;Lo;0;L;;;;;N;;;;; -1B050;HENTAIGANA LETTER SU-7;Lo;0;L;;;;;N;;;;; -1B051;HENTAIGANA LETTER SU-8;Lo;0;L;;;;;N;;;;; -1B052;HENTAIGANA LETTER SE-1;Lo;0;L;;;;;N;;;;; -1B053;HENTAIGANA LETTER SE-2;Lo;0;L;;;;;N;;;;; -1B054;HENTAIGANA LETTER SE-3;Lo;0;L;;;;;N;;;;; -1B055;HENTAIGANA LETTER SE-4;Lo;0;L;;;;;N;;;;; -1B056;HENTAIGANA LETTER SE-5;Lo;0;L;;;;;N;;;;; -1B057;HENTAIGANA LETTER SO-1;Lo;0;L;;;;;N;;;;; -1B058;HENTAIGANA LETTER SO-2;Lo;0;L;;;;;N;;;;; -1B059;HENTAIGANA LETTER SO-3;Lo;0;L;;;;;N;;;;; -1B05A;HENTAIGANA LETTER SO-4;Lo;0;L;;;;;N;;;;; -1B05B;HENTAIGANA LETTER SO-5;Lo;0;L;;;;;N;;;;; -1B05C;HENTAIGANA LETTER SO-6;Lo;0;L;;;;;N;;;;; -1B05D;HENTAIGANA LETTER SO-7;Lo;0;L;;;;;N;;;;; -1B05E;HENTAIGANA LETTER TA-1;Lo;0;L;;;;;N;;;;; -1B05F;HENTAIGANA LETTER TA-2;Lo;0;L;;;;;N;;;;; -1B060;HENTAIGANA LETTER TA-3;Lo;0;L;;;;;N;;;;; -1B061;HENTAIGANA LETTER TA-4;Lo;0;L;;;;;N;;;;; -1B062;HENTAIGANA LETTER TI-1;Lo;0;L;;;;;N;;;;; -1B063;HENTAIGANA LETTER TI-2;Lo;0;L;;;;;N;;;;; -1B064;HENTAIGANA LETTER TI-3;Lo;0;L;;;;;N;;;;; -1B065;HENTAIGANA LETTER TI-4;Lo;0;L;;;;;N;;;;; -1B066;HENTAIGANA LETTER TI-5;Lo;0;L;;;;;N;;;;; -1B067;HENTAIGANA LETTER TI-6;Lo;0;L;;;;;N;;;;; -1B068;HENTAIGANA LETTER TI-7;Lo;0;L;;;;;N;;;;; -1B069;HENTAIGANA LETTER TU-1;Lo;0;L;;;;;N;;;;; -1B06A;HENTAIGANA LETTER TU-2;Lo;0;L;;;;;N;;;;; -1B06B;HENTAIGANA LETTER TU-3;Lo;0;L;;;;;N;;;;; -1B06C;HENTAIGANA LETTER TU-4;Lo;0;L;;;;;N;;;;; -1B06D;HENTAIGANA LETTER TU-TO;Lo;0;L;;;;;N;;;;; -1B06E;HENTAIGANA LETTER TE-1;Lo;0;L;;;;;N;;;;; -1B06F;HENTAIGANA LETTER TE-2;Lo;0;L;;;;;N;;;;; -1B070;HENTAIGANA LETTER TE-3;Lo;0;L;;;;;N;;;;; -1B071;HENTAIGANA LETTER TE-4;Lo;0;L;;;;;N;;;;; -1B072;HENTAIGANA LETTER TE-5;Lo;0;L;;;;;N;;;;; -1B073;HENTAIGANA LETTER TE-6;Lo;0;L;;;;;N;;;;; -1B074;HENTAIGANA LETTER TE-7;Lo;0;L;;;;;N;;;;; -1B075;HENTAIGANA LETTER TE-8;Lo;0;L;;;;;N;;;;; -1B076;HENTAIGANA LETTER TE-9;Lo;0;L;;;;;N;;;;; -1B077;HENTAIGANA LETTER TO-1;Lo;0;L;;;;;N;;;;; -1B078;HENTAIGANA LETTER TO-2;Lo;0;L;;;;;N;;;;; -1B079;HENTAIGANA LETTER TO-3;Lo;0;L;;;;;N;;;;; -1B07A;HENTAIGANA LETTER TO-4;Lo;0;L;;;;;N;;;;; -1B07B;HENTAIGANA LETTER TO-5;Lo;0;L;;;;;N;;;;; -1B07C;HENTAIGANA LETTER TO-6;Lo;0;L;;;;;N;;;;; -1B07D;HENTAIGANA LETTER TO-RA;Lo;0;L;;;;;N;;;;; -1B07E;HENTAIGANA LETTER NA-1;Lo;0;L;;;;;N;;;;; -1B07F;HENTAIGANA LETTER NA-2;Lo;0;L;;;;;N;;;;; -1B080;HENTAIGANA LETTER NA-3;Lo;0;L;;;;;N;;;;; -1B081;HENTAIGANA LETTER NA-4;Lo;0;L;;;;;N;;;;; -1B082;HENTAIGANA LETTER NA-5;Lo;0;L;;;;;N;;;;; -1B083;HENTAIGANA LETTER NA-6;Lo;0;L;;;;;N;;;;; -1B084;HENTAIGANA LETTER NA-7;Lo;0;L;;;;;N;;;;; -1B085;HENTAIGANA LETTER NA-8;Lo;0;L;;;;;N;;;;; -1B086;HENTAIGANA LETTER NA-9;Lo;0;L;;;;;N;;;;; -1B087;HENTAIGANA LETTER NI-1;Lo;0;L;;;;;N;;;;; -1B088;HENTAIGANA LETTER NI-2;Lo;0;L;;;;;N;;;;; -1B089;HENTAIGANA LETTER NI-3;Lo;0;L;;;;;N;;;;; -1B08A;HENTAIGANA LETTER NI-4;Lo;0;L;;;;;N;;;;; -1B08B;HENTAIGANA LETTER NI-5;Lo;0;L;;;;;N;;;;; -1B08C;HENTAIGANA LETTER NI-6;Lo;0;L;;;;;N;;;;; -1B08D;HENTAIGANA LETTER NI-7;Lo;0;L;;;;;N;;;;; -1B08E;HENTAIGANA LETTER NI-TE;Lo;0;L;;;;;N;;;;; -1B08F;HENTAIGANA LETTER NU-1;Lo;0;L;;;;;N;;;;; -1B090;HENTAIGANA LETTER NU-2;Lo;0;L;;;;;N;;;;; -1B091;HENTAIGANA LETTER NU-3;Lo;0;L;;;;;N;;;;; -1B092;HENTAIGANA LETTER NE-1;Lo;0;L;;;;;N;;;;; -1B093;HENTAIGANA LETTER NE-2;Lo;0;L;;;;;N;;;;; -1B094;HENTAIGANA LETTER NE-3;Lo;0;L;;;;;N;;;;; -1B095;HENTAIGANA LETTER NE-4;Lo;0;L;;;;;N;;;;; -1B096;HENTAIGANA LETTER NE-5;Lo;0;L;;;;;N;;;;; -1B097;HENTAIGANA LETTER NE-6;Lo;0;L;;;;;N;;;;; -1B098;HENTAIGANA LETTER NE-KO;Lo;0;L;;;;;N;;;;; -1B099;HENTAIGANA LETTER NO-1;Lo;0;L;;;;;N;;;;; -1B09A;HENTAIGANA LETTER NO-2;Lo;0;L;;;;;N;;;;; -1B09B;HENTAIGANA LETTER NO-3;Lo;0;L;;;;;N;;;;; -1B09C;HENTAIGANA LETTER NO-4;Lo;0;L;;;;;N;;;;; -1B09D;HENTAIGANA LETTER NO-5;Lo;0;L;;;;;N;;;;; -1B09E;HENTAIGANA LETTER HA-1;Lo;0;L;;;;;N;;;;; -1B09F;HENTAIGANA LETTER HA-2;Lo;0;L;;;;;N;;;;; -1B0A0;HENTAIGANA LETTER HA-3;Lo;0;L;;;;;N;;;;; -1B0A1;HENTAIGANA LETTER HA-4;Lo;0;L;;;;;N;;;;; -1B0A2;HENTAIGANA LETTER HA-5;Lo;0;L;;;;;N;;;;; -1B0A3;HENTAIGANA LETTER HA-6;Lo;0;L;;;;;N;;;;; -1B0A4;HENTAIGANA LETTER HA-7;Lo;0;L;;;;;N;;;;; -1B0A5;HENTAIGANA LETTER HA-8;Lo;0;L;;;;;N;;;;; -1B0A6;HENTAIGANA LETTER HA-9;Lo;0;L;;;;;N;;;;; -1B0A7;HENTAIGANA LETTER HA-10;Lo;0;L;;;;;N;;;;; -1B0A8;HENTAIGANA LETTER HA-11;Lo;0;L;;;;;N;;;;; -1B0A9;HENTAIGANA LETTER HI-1;Lo;0;L;;;;;N;;;;; -1B0AA;HENTAIGANA LETTER HI-2;Lo;0;L;;;;;N;;;;; -1B0AB;HENTAIGANA LETTER HI-3;Lo;0;L;;;;;N;;;;; -1B0AC;HENTAIGANA LETTER HI-4;Lo;0;L;;;;;N;;;;; -1B0AD;HENTAIGANA LETTER HI-5;Lo;0;L;;;;;N;;;;; -1B0AE;HENTAIGANA LETTER HI-6;Lo;0;L;;;;;N;;;;; -1B0AF;HENTAIGANA LETTER HI-7;Lo;0;L;;;;;N;;;;; -1B0B0;HENTAIGANA LETTER HU-1;Lo;0;L;;;;;N;;;;; -1B0B1;HENTAIGANA LETTER HU-2;Lo;0;L;;;;;N;;;;; -1B0B2;HENTAIGANA LETTER HU-3;Lo;0;L;;;;;N;;;;; -1B0B3;HENTAIGANA LETTER HE-1;Lo;0;L;;;;;N;;;;; -1B0B4;HENTAIGANA LETTER HE-2;Lo;0;L;;;;;N;;;;; -1B0B5;HENTAIGANA LETTER HE-3;Lo;0;L;;;;;N;;;;; -1B0B6;HENTAIGANA LETTER HE-4;Lo;0;L;;;;;N;;;;; -1B0B7;HENTAIGANA LETTER HE-5;Lo;0;L;;;;;N;;;;; -1B0B8;HENTAIGANA LETTER HE-6;Lo;0;L;;;;;N;;;;; -1B0B9;HENTAIGANA LETTER HE-7;Lo;0;L;;;;;N;;;;; -1B0BA;HENTAIGANA LETTER HO-1;Lo;0;L;;;;;N;;;;; -1B0BB;HENTAIGANA LETTER HO-2;Lo;0;L;;;;;N;;;;; -1B0BC;HENTAIGANA LETTER HO-3;Lo;0;L;;;;;N;;;;; -1B0BD;HENTAIGANA LETTER HO-4;Lo;0;L;;;;;N;;;;; -1B0BE;HENTAIGANA LETTER HO-5;Lo;0;L;;;;;N;;;;; -1B0BF;HENTAIGANA LETTER HO-6;Lo;0;L;;;;;N;;;;; -1B0C0;HENTAIGANA LETTER HO-7;Lo;0;L;;;;;N;;;;; -1B0C1;HENTAIGANA LETTER HO-8;Lo;0;L;;;;;N;;;;; -1B0C2;HENTAIGANA LETTER MA-1;Lo;0;L;;;;;N;;;;; -1B0C3;HENTAIGANA LETTER MA-2;Lo;0;L;;;;;N;;;;; -1B0C4;HENTAIGANA LETTER MA-3;Lo;0;L;;;;;N;;;;; -1B0C5;HENTAIGANA LETTER MA-4;Lo;0;L;;;;;N;;;;; -1B0C6;HENTAIGANA LETTER MA-5;Lo;0;L;;;;;N;;;;; -1B0C7;HENTAIGANA LETTER MA-6;Lo;0;L;;;;;N;;;;; -1B0C8;HENTAIGANA LETTER MA-7;Lo;0;L;;;;;N;;;;; -1B0C9;HENTAIGANA LETTER MI-1;Lo;0;L;;;;;N;;;;; -1B0CA;HENTAIGANA LETTER MI-2;Lo;0;L;;;;;N;;;;; -1B0CB;HENTAIGANA LETTER MI-3;Lo;0;L;;;;;N;;;;; -1B0CC;HENTAIGANA LETTER MI-4;Lo;0;L;;;;;N;;;;; -1B0CD;HENTAIGANA LETTER MI-5;Lo;0;L;;;;;N;;;;; -1B0CE;HENTAIGANA LETTER MI-6;Lo;0;L;;;;;N;;;;; -1B0CF;HENTAIGANA LETTER MI-7;Lo;0;L;;;;;N;;;;; -1B0D0;HENTAIGANA LETTER MU-1;Lo;0;L;;;;;N;;;;; -1B0D1;HENTAIGANA LETTER MU-2;Lo;0;L;;;;;N;;;;; -1B0D2;HENTAIGANA LETTER MU-3;Lo;0;L;;;;;N;;;;; -1B0D3;HENTAIGANA LETTER MU-4;Lo;0;L;;;;;N;;;;; -1B0D4;HENTAIGANA LETTER ME-1;Lo;0;L;;;;;N;;;;; -1B0D5;HENTAIGANA LETTER ME-2;Lo;0;L;;;;;N;;;;; -1B0D6;HENTAIGANA LETTER ME-MA;Lo;0;L;;;;;N;;;;; -1B0D7;HENTAIGANA LETTER MO-1;Lo;0;L;;;;;N;;;;; -1B0D8;HENTAIGANA LETTER MO-2;Lo;0;L;;;;;N;;;;; -1B0D9;HENTAIGANA LETTER MO-3;Lo;0;L;;;;;N;;;;; -1B0DA;HENTAIGANA LETTER MO-4;Lo;0;L;;;;;N;;;;; -1B0DB;HENTAIGANA LETTER MO-5;Lo;0;L;;;;;N;;;;; -1B0DC;HENTAIGANA LETTER MO-6;Lo;0;L;;;;;N;;;;; -1B0DD;HENTAIGANA LETTER YA-1;Lo;0;L;;;;;N;;;;; -1B0DE;HENTAIGANA LETTER YA-2;Lo;0;L;;;;;N;;;;; -1B0DF;HENTAIGANA LETTER YA-3;Lo;0;L;;;;;N;;;;; -1B0E0;HENTAIGANA LETTER YA-4;Lo;0;L;;;;;N;;;;; -1B0E1;HENTAIGANA LETTER YA-5;Lo;0;L;;;;;N;;;;; -1B0E2;HENTAIGANA LETTER YA-YO;Lo;0;L;;;;;N;;;;; -1B0E3;HENTAIGANA LETTER YU-1;Lo;0;L;;;;;N;;;;; -1B0E4;HENTAIGANA LETTER YU-2;Lo;0;L;;;;;N;;;;; -1B0E5;HENTAIGANA LETTER YU-3;Lo;0;L;;;;;N;;;;; -1B0E6;HENTAIGANA LETTER YU-4;Lo;0;L;;;;;N;;;;; -1B0E7;HENTAIGANA LETTER YO-1;Lo;0;L;;;;;N;;;;; -1B0E8;HENTAIGANA LETTER YO-2;Lo;0;L;;;;;N;;;;; -1B0E9;HENTAIGANA LETTER YO-3;Lo;0;L;;;;;N;;;;; -1B0EA;HENTAIGANA LETTER YO-4;Lo;0;L;;;;;N;;;;; -1B0EB;HENTAIGANA LETTER YO-5;Lo;0;L;;;;;N;;;;; -1B0EC;HENTAIGANA LETTER YO-6;Lo;0;L;;;;;N;;;;; -1B0ED;HENTAIGANA LETTER RA-1;Lo;0;L;;;;;N;;;;; -1B0EE;HENTAIGANA LETTER RA-2;Lo;0;L;;;;;N;;;;; -1B0EF;HENTAIGANA LETTER RA-3;Lo;0;L;;;;;N;;;;; -1B0F0;HENTAIGANA LETTER RA-4;Lo;0;L;;;;;N;;;;; -1B0F1;HENTAIGANA LETTER RI-1;Lo;0;L;;;;;N;;;;; -1B0F2;HENTAIGANA LETTER RI-2;Lo;0;L;;;;;N;;;;; -1B0F3;HENTAIGANA LETTER RI-3;Lo;0;L;;;;;N;;;;; -1B0F4;HENTAIGANA LETTER RI-4;Lo;0;L;;;;;N;;;;; -1B0F5;HENTAIGANA LETTER RI-5;Lo;0;L;;;;;N;;;;; -1B0F6;HENTAIGANA LETTER RI-6;Lo;0;L;;;;;N;;;;; -1B0F7;HENTAIGANA LETTER RI-7;Lo;0;L;;;;;N;;;;; -1B0F8;HENTAIGANA LETTER RU-1;Lo;0;L;;;;;N;;;;; -1B0F9;HENTAIGANA LETTER RU-2;Lo;0;L;;;;;N;;;;; -1B0FA;HENTAIGANA LETTER RU-3;Lo;0;L;;;;;N;;;;; -1B0FB;HENTAIGANA LETTER RU-4;Lo;0;L;;;;;N;;;;; -1B0FC;HENTAIGANA LETTER RU-5;Lo;0;L;;;;;N;;;;; -1B0FD;HENTAIGANA LETTER RU-6;Lo;0;L;;;;;N;;;;; -1B0FE;HENTAIGANA LETTER RE-1;Lo;0;L;;;;;N;;;;; -1B0FF;HENTAIGANA LETTER RE-2;Lo;0;L;;;;;N;;;;; -1B100;HENTAIGANA LETTER RE-3;Lo;0;L;;;;;N;;;;; -1B101;HENTAIGANA LETTER RE-4;Lo;0;L;;;;;N;;;;; -1B102;HENTAIGANA LETTER RO-1;Lo;0;L;;;;;N;;;;; -1B103;HENTAIGANA LETTER RO-2;Lo;0;L;;;;;N;;;;; -1B104;HENTAIGANA LETTER RO-3;Lo;0;L;;;;;N;;;;; -1B105;HENTAIGANA LETTER RO-4;Lo;0;L;;;;;N;;;;; -1B106;HENTAIGANA LETTER RO-5;Lo;0;L;;;;;N;;;;; -1B107;HENTAIGANA LETTER RO-6;Lo;0;L;;;;;N;;;;; -1B108;HENTAIGANA LETTER WA-1;Lo;0;L;;;;;N;;;;; -1B109;HENTAIGANA LETTER WA-2;Lo;0;L;;;;;N;;;;; -1B10A;HENTAIGANA LETTER WA-3;Lo;0;L;;;;;N;;;;; -1B10B;HENTAIGANA LETTER WA-4;Lo;0;L;;;;;N;;;;; -1B10C;HENTAIGANA LETTER WA-5;Lo;0;L;;;;;N;;;;; -1B10D;HENTAIGANA LETTER WI-1;Lo;0;L;;;;;N;;;;; -1B10E;HENTAIGANA LETTER WI-2;Lo;0;L;;;;;N;;;;; -1B10F;HENTAIGANA LETTER WI-3;Lo;0;L;;;;;N;;;;; -1B110;HENTAIGANA LETTER WI-4;Lo;0;L;;;;;N;;;;; -1B111;HENTAIGANA LETTER WI-5;Lo;0;L;;;;;N;;;;; -1B112;HENTAIGANA LETTER WE-1;Lo;0;L;;;;;N;;;;; -1B113;HENTAIGANA LETTER WE-2;Lo;0;L;;;;;N;;;;; -1B114;HENTAIGANA LETTER WE-3;Lo;0;L;;;;;N;;;;; -1B115;HENTAIGANA LETTER WE-4;Lo;0;L;;;;;N;;;;; -1B116;HENTAIGANA LETTER WO-1;Lo;0;L;;;;;N;;;;; -1B117;HENTAIGANA LETTER WO-2;Lo;0;L;;;;;N;;;;; -1B118;HENTAIGANA LETTER WO-3;Lo;0;L;;;;;N;;;;; -1B119;HENTAIGANA LETTER WO-4;Lo;0;L;;;;;N;;;;; -1B11A;HENTAIGANA LETTER WO-5;Lo;0;L;;;;;N;;;;; -1B11B;HENTAIGANA LETTER WO-6;Lo;0;L;;;;;N;;;;; -1B11C;HENTAIGANA LETTER WO-7;Lo;0;L;;;;;N;;;;; -1B11D;HENTAIGANA LETTER N-MU-MO-1;Lo;0;L;;;;;N;;;;; -1B11E;HENTAIGANA LETTER N-MU-MO-2;Lo;0;L;;;;;N;;;;; -1B170;NUSHU CHARACTER-1B170;Lo;0;L;;;;;N;;;;; -1B171;NUSHU CHARACTER-1B171;Lo;0;L;;;;;N;;;;; -1B172;NUSHU CHARACTER-1B172;Lo;0;L;;;;;N;;;;; -1B173;NUSHU CHARACTER-1B173;Lo;0;L;;;;;N;;;;; -1B174;NUSHU CHARACTER-1B174;Lo;0;L;;;;;N;;;;; -1B175;NUSHU CHARACTER-1B175;Lo;0;L;;;;;N;;;;; -1B176;NUSHU CHARACTER-1B176;Lo;0;L;;;;;N;;;;; -1B177;NUSHU CHARACTER-1B177;Lo;0;L;;;;;N;;;;; -1B178;NUSHU CHARACTER-1B178;Lo;0;L;;;;;N;;;;; -1B179;NUSHU CHARACTER-1B179;Lo;0;L;;;;;N;;;;; -1B17A;NUSHU CHARACTER-1B17A;Lo;0;L;;;;;N;;;;; -1B17B;NUSHU CHARACTER-1B17B;Lo;0;L;;;;;N;;;;; -1B17C;NUSHU CHARACTER-1B17C;Lo;0;L;;;;;N;;;;; -1B17D;NUSHU CHARACTER-1B17D;Lo;0;L;;;;;N;;;;; -1B17E;NUSHU CHARACTER-1B17E;Lo;0;L;;;;;N;;;;; -1B17F;NUSHU CHARACTER-1B17F;Lo;0;L;;;;;N;;;;; -1B180;NUSHU CHARACTER-1B180;Lo;0;L;;;;;N;;;;; -1B181;NUSHU CHARACTER-1B181;Lo;0;L;;;;;N;;;;; -1B182;NUSHU CHARACTER-1B182;Lo;0;L;;;;;N;;;;; -1B183;NUSHU CHARACTER-1B183;Lo;0;L;;;;;N;;;;; -1B184;NUSHU CHARACTER-1B184;Lo;0;L;;;;;N;;;;; -1B185;NUSHU CHARACTER-1B185;Lo;0;L;;;;;N;;;;; -1B186;NUSHU CHARACTER-1B186;Lo;0;L;;;;;N;;;;; -1B187;NUSHU CHARACTER-1B187;Lo;0;L;;;;;N;;;;; -1B188;NUSHU CHARACTER-1B188;Lo;0;L;;;;;N;;;;; -1B189;NUSHU CHARACTER-1B189;Lo;0;L;;;;;N;;;;; -1B18A;NUSHU CHARACTER-1B18A;Lo;0;L;;;;;N;;;;; -1B18B;NUSHU CHARACTER-1B18B;Lo;0;L;;;;;N;;;;; -1B18C;NUSHU CHARACTER-1B18C;Lo;0;L;;;;;N;;;;; -1B18D;NUSHU CHARACTER-1B18D;Lo;0;L;;;;;N;;;;; -1B18E;NUSHU CHARACTER-1B18E;Lo;0;L;;;;;N;;;;; -1B18F;NUSHU CHARACTER-1B18F;Lo;0;L;;;;;N;;;;; -1B190;NUSHU CHARACTER-1B190;Lo;0;L;;;;;N;;;;; -1B191;NUSHU CHARACTER-1B191;Lo;0;L;;;;;N;;;;; -1B192;NUSHU CHARACTER-1B192;Lo;0;L;;;;;N;;;;; -1B193;NUSHU CHARACTER-1B193;Lo;0;L;;;;;N;;;;; -1B194;NUSHU CHARACTER-1B194;Lo;0;L;;;;;N;;;;; -1B195;NUSHU CHARACTER-1B195;Lo;0;L;;;;;N;;;;; -1B196;NUSHU CHARACTER-1B196;Lo;0;L;;;;;N;;;;; -1B197;NUSHU CHARACTER-1B197;Lo;0;L;;;;;N;;;;; -1B198;NUSHU CHARACTER-1B198;Lo;0;L;;;;;N;;;;; -1B199;NUSHU CHARACTER-1B199;Lo;0;L;;;;;N;;;;; -1B19A;NUSHU CHARACTER-1B19A;Lo;0;L;;;;;N;;;;; -1B19B;NUSHU CHARACTER-1B19B;Lo;0;L;;;;;N;;;;; -1B19C;NUSHU CHARACTER-1B19C;Lo;0;L;;;;;N;;;;; -1B19D;NUSHU CHARACTER-1B19D;Lo;0;L;;;;;N;;;;; -1B19E;NUSHU CHARACTER-1B19E;Lo;0;L;;;;;N;;;;; -1B19F;NUSHU CHARACTER-1B19F;Lo;0;L;;;;;N;;;;; -1B1A0;NUSHU CHARACTER-1B1A0;Lo;0;L;;;;;N;;;;; -1B1A1;NUSHU CHARACTER-1B1A1;Lo;0;L;;;;;N;;;;; -1B1A2;NUSHU CHARACTER-1B1A2;Lo;0;L;;;;;N;;;;; -1B1A3;NUSHU CHARACTER-1B1A3;Lo;0;L;;;;;N;;;;; -1B1A4;NUSHU CHARACTER-1B1A4;Lo;0;L;;;;;N;;;;; -1B1A5;NUSHU CHARACTER-1B1A5;Lo;0;L;;;;;N;;;;; -1B1A6;NUSHU CHARACTER-1B1A6;Lo;0;L;;;;;N;;;;; -1B1A7;NUSHU CHARACTER-1B1A7;Lo;0;L;;;;;N;;;;; -1B1A8;NUSHU CHARACTER-1B1A8;Lo;0;L;;;;;N;;;;; -1B1A9;NUSHU CHARACTER-1B1A9;Lo;0;L;;;;;N;;;;; -1B1AA;NUSHU CHARACTER-1B1AA;Lo;0;L;;;;;N;;;;; -1B1AB;NUSHU CHARACTER-1B1AB;Lo;0;L;;;;;N;;;;; -1B1AC;NUSHU CHARACTER-1B1AC;Lo;0;L;;;;;N;;;;; -1B1AD;NUSHU CHARACTER-1B1AD;Lo;0;L;;;;;N;;;;; -1B1AE;NUSHU CHARACTER-1B1AE;Lo;0;L;;;;;N;;;;; -1B1AF;NUSHU CHARACTER-1B1AF;Lo;0;L;;;;;N;;;;; -1B1B0;NUSHU CHARACTER-1B1B0;Lo;0;L;;;;;N;;;;; -1B1B1;NUSHU CHARACTER-1B1B1;Lo;0;L;;;;;N;;;;; -1B1B2;NUSHU CHARACTER-1B1B2;Lo;0;L;;;;;N;;;;; -1B1B3;NUSHU CHARACTER-1B1B3;Lo;0;L;;;;;N;;;;; -1B1B4;NUSHU CHARACTER-1B1B4;Lo;0;L;;;;;N;;;;; -1B1B5;NUSHU CHARACTER-1B1B5;Lo;0;L;;;;;N;;;;; -1B1B6;NUSHU CHARACTER-1B1B6;Lo;0;L;;;;;N;;;;; -1B1B7;NUSHU CHARACTER-1B1B7;Lo;0;L;;;;;N;;;;; -1B1B8;NUSHU CHARACTER-1B1B8;Lo;0;L;;;;;N;;;;; -1B1B9;NUSHU CHARACTER-1B1B9;Lo;0;L;;;;;N;;;;; -1B1BA;NUSHU CHARACTER-1B1BA;Lo;0;L;;;;;N;;;;; -1B1BB;NUSHU CHARACTER-1B1BB;Lo;0;L;;;;;N;;;;; -1B1BC;NUSHU CHARACTER-1B1BC;Lo;0;L;;;;;N;;;;; -1B1BD;NUSHU CHARACTER-1B1BD;Lo;0;L;;;;;N;;;;; -1B1BE;NUSHU CHARACTER-1B1BE;Lo;0;L;;;;;N;;;;; -1B1BF;NUSHU CHARACTER-1B1BF;Lo;0;L;;;;;N;;;;; -1B1C0;NUSHU CHARACTER-1B1C0;Lo;0;L;;;;;N;;;;; -1B1C1;NUSHU CHARACTER-1B1C1;Lo;0;L;;;;;N;;;;; -1B1C2;NUSHU CHARACTER-1B1C2;Lo;0;L;;;;;N;;;;; -1B1C3;NUSHU CHARACTER-1B1C3;Lo;0;L;;;;;N;;;;; -1B1C4;NUSHU CHARACTER-1B1C4;Lo;0;L;;;;;N;;;;; -1B1C5;NUSHU CHARACTER-1B1C5;Lo;0;L;;;;;N;;;;; -1B1C6;NUSHU CHARACTER-1B1C6;Lo;0;L;;;;;N;;;;; -1B1C7;NUSHU CHARACTER-1B1C7;Lo;0;L;;;;;N;;;;; -1B1C8;NUSHU CHARACTER-1B1C8;Lo;0;L;;;;;N;;;;; -1B1C9;NUSHU CHARACTER-1B1C9;Lo;0;L;;;;;N;;;;; -1B1CA;NUSHU CHARACTER-1B1CA;Lo;0;L;;;;;N;;;;; -1B1CB;NUSHU CHARACTER-1B1CB;Lo;0;L;;;;;N;;;;; -1B1CC;NUSHU CHARACTER-1B1CC;Lo;0;L;;;;;N;;;;; -1B1CD;NUSHU CHARACTER-1B1CD;Lo;0;L;;;;;N;;;;; -1B1CE;NUSHU CHARACTER-1B1CE;Lo;0;L;;;;;N;;;;; -1B1CF;NUSHU CHARACTER-1B1CF;Lo;0;L;;;;;N;;;;; -1B1D0;NUSHU CHARACTER-1B1D0;Lo;0;L;;;;;N;;;;; -1B1D1;NUSHU CHARACTER-1B1D1;Lo;0;L;;;;;N;;;;; -1B1D2;NUSHU CHARACTER-1B1D2;Lo;0;L;;;;;N;;;;; -1B1D3;NUSHU CHARACTER-1B1D3;Lo;0;L;;;;;N;;;;; -1B1D4;NUSHU CHARACTER-1B1D4;Lo;0;L;;;;;N;;;;; -1B1D5;NUSHU CHARACTER-1B1D5;Lo;0;L;;;;;N;;;;; -1B1D6;NUSHU CHARACTER-1B1D6;Lo;0;L;;;;;N;;;;; -1B1D7;NUSHU CHARACTER-1B1D7;Lo;0;L;;;;;N;;;;; -1B1D8;NUSHU CHARACTER-1B1D8;Lo;0;L;;;;;N;;;;; -1B1D9;NUSHU CHARACTER-1B1D9;Lo;0;L;;;;;N;;;;; -1B1DA;NUSHU CHARACTER-1B1DA;Lo;0;L;;;;;N;;;;; -1B1DB;NUSHU CHARACTER-1B1DB;Lo;0;L;;;;;N;;;;; -1B1DC;NUSHU CHARACTER-1B1DC;Lo;0;L;;;;;N;;;;; -1B1DD;NUSHU CHARACTER-1B1DD;Lo;0;L;;;;;N;;;;; -1B1DE;NUSHU CHARACTER-1B1DE;Lo;0;L;;;;;N;;;;; -1B1DF;NUSHU CHARACTER-1B1DF;Lo;0;L;;;;;N;;;;; -1B1E0;NUSHU CHARACTER-1B1E0;Lo;0;L;;;;;N;;;;; -1B1E1;NUSHU CHARACTER-1B1E1;Lo;0;L;;;;;N;;;;; -1B1E2;NUSHU CHARACTER-1B1E2;Lo;0;L;;;;;N;;;;; -1B1E3;NUSHU CHARACTER-1B1E3;Lo;0;L;;;;;N;;;;; -1B1E4;NUSHU CHARACTER-1B1E4;Lo;0;L;;;;;N;;;;; -1B1E5;NUSHU CHARACTER-1B1E5;Lo;0;L;;;;;N;;;;; -1B1E6;NUSHU CHARACTER-1B1E6;Lo;0;L;;;;;N;;;;; -1B1E7;NUSHU CHARACTER-1B1E7;Lo;0;L;;;;;N;;;;; -1B1E8;NUSHU CHARACTER-1B1E8;Lo;0;L;;;;;N;;;;; -1B1E9;NUSHU CHARACTER-1B1E9;Lo;0;L;;;;;N;;;;; -1B1EA;NUSHU CHARACTER-1B1EA;Lo;0;L;;;;;N;;;;; -1B1EB;NUSHU CHARACTER-1B1EB;Lo;0;L;;;;;N;;;;; -1B1EC;NUSHU CHARACTER-1B1EC;Lo;0;L;;;;;N;;;;; -1B1ED;NUSHU CHARACTER-1B1ED;Lo;0;L;;;;;N;;;;; -1B1EE;NUSHU CHARACTER-1B1EE;Lo;0;L;;;;;N;;;;; -1B1EF;NUSHU CHARACTER-1B1EF;Lo;0;L;;;;;N;;;;; -1B1F0;NUSHU CHARACTER-1B1F0;Lo;0;L;;;;;N;;;;; -1B1F1;NUSHU CHARACTER-1B1F1;Lo;0;L;;;;;N;;;;; -1B1F2;NUSHU CHARACTER-1B1F2;Lo;0;L;;;;;N;;;;; -1B1F3;NUSHU CHARACTER-1B1F3;Lo;0;L;;;;;N;;;;; -1B1F4;NUSHU CHARACTER-1B1F4;Lo;0;L;;;;;N;;;;; -1B1F5;NUSHU CHARACTER-1B1F5;Lo;0;L;;;;;N;;;;; -1B1F6;NUSHU CHARACTER-1B1F6;Lo;0;L;;;;;N;;;;; -1B1F7;NUSHU CHARACTER-1B1F7;Lo;0;L;;;;;N;;;;; -1B1F8;NUSHU CHARACTER-1B1F8;Lo;0;L;;;;;N;;;;; -1B1F9;NUSHU CHARACTER-1B1F9;Lo;0;L;;;;;N;;;;; -1B1FA;NUSHU CHARACTER-1B1FA;Lo;0;L;;;;;N;;;;; -1B1FB;NUSHU CHARACTER-1B1FB;Lo;0;L;;;;;N;;;;; -1B1FC;NUSHU CHARACTER-1B1FC;Lo;0;L;;;;;N;;;;; -1B1FD;NUSHU CHARACTER-1B1FD;Lo;0;L;;;;;N;;;;; -1B1FE;NUSHU CHARACTER-1B1FE;Lo;0;L;;;;;N;;;;; -1B1FF;NUSHU CHARACTER-1B1FF;Lo;0;L;;;;;N;;;;; -1B200;NUSHU CHARACTER-1B200;Lo;0;L;;;;;N;;;;; -1B201;NUSHU CHARACTER-1B201;Lo;0;L;;;;;N;;;;; -1B202;NUSHU CHARACTER-1B202;Lo;0;L;;;;;N;;;;; -1B203;NUSHU CHARACTER-1B203;Lo;0;L;;;;;N;;;;; -1B204;NUSHU CHARACTER-1B204;Lo;0;L;;;;;N;;;;; -1B205;NUSHU CHARACTER-1B205;Lo;0;L;;;;;N;;;;; -1B206;NUSHU CHARACTER-1B206;Lo;0;L;;;;;N;;;;; -1B207;NUSHU CHARACTER-1B207;Lo;0;L;;;;;N;;;;; -1B208;NUSHU CHARACTER-1B208;Lo;0;L;;;;;N;;;;; -1B209;NUSHU CHARACTER-1B209;Lo;0;L;;;;;N;;;;; -1B20A;NUSHU CHARACTER-1B20A;Lo;0;L;;;;;N;;;;; -1B20B;NUSHU CHARACTER-1B20B;Lo;0;L;;;;;N;;;;; -1B20C;NUSHU CHARACTER-1B20C;Lo;0;L;;;;;N;;;;; -1B20D;NUSHU CHARACTER-1B20D;Lo;0;L;;;;;N;;;;; -1B20E;NUSHU CHARACTER-1B20E;Lo;0;L;;;;;N;;;;; -1B20F;NUSHU CHARACTER-1B20F;Lo;0;L;;;;;N;;;;; -1B210;NUSHU CHARACTER-1B210;Lo;0;L;;;;;N;;;;; -1B211;NUSHU CHARACTER-1B211;Lo;0;L;;;;;N;;;;; -1B212;NUSHU CHARACTER-1B212;Lo;0;L;;;;;N;;;;; -1B213;NUSHU CHARACTER-1B213;Lo;0;L;;;;;N;;;;; -1B214;NUSHU CHARACTER-1B214;Lo;0;L;;;;;N;;;;; -1B215;NUSHU CHARACTER-1B215;Lo;0;L;;;;;N;;;;; -1B216;NUSHU CHARACTER-1B216;Lo;0;L;;;;;N;;;;; -1B217;NUSHU CHARACTER-1B217;Lo;0;L;;;;;N;;;;; -1B218;NUSHU CHARACTER-1B218;Lo;0;L;;;;;N;;;;; -1B219;NUSHU CHARACTER-1B219;Lo;0;L;;;;;N;;;;; -1B21A;NUSHU CHARACTER-1B21A;Lo;0;L;;;;;N;;;;; -1B21B;NUSHU CHARACTER-1B21B;Lo;0;L;;;;;N;;;;; -1B21C;NUSHU CHARACTER-1B21C;Lo;0;L;;;;;N;;;;; -1B21D;NUSHU CHARACTER-1B21D;Lo;0;L;;;;;N;;;;; -1B21E;NUSHU CHARACTER-1B21E;Lo;0;L;;;;;N;;;;; -1B21F;NUSHU CHARACTER-1B21F;Lo;0;L;;;;;N;;;;; -1B220;NUSHU CHARACTER-1B220;Lo;0;L;;;;;N;;;;; -1B221;NUSHU CHARACTER-1B221;Lo;0;L;;;;;N;;;;; -1B222;NUSHU CHARACTER-1B222;Lo;0;L;;;;;N;;;;; -1B223;NUSHU CHARACTER-1B223;Lo;0;L;;;;;N;;;;; -1B224;NUSHU CHARACTER-1B224;Lo;0;L;;;;;N;;;;; -1B225;NUSHU CHARACTER-1B225;Lo;0;L;;;;;N;;;;; -1B226;NUSHU CHARACTER-1B226;Lo;0;L;;;;;N;;;;; -1B227;NUSHU CHARACTER-1B227;Lo;0;L;;;;;N;;;;; -1B228;NUSHU CHARACTER-1B228;Lo;0;L;;;;;N;;;;; -1B229;NUSHU CHARACTER-1B229;Lo;0;L;;;;;N;;;;; -1B22A;NUSHU CHARACTER-1B22A;Lo;0;L;;;;;N;;;;; -1B22B;NUSHU CHARACTER-1B22B;Lo;0;L;;;;;N;;;;; -1B22C;NUSHU CHARACTER-1B22C;Lo;0;L;;;;;N;;;;; -1B22D;NUSHU CHARACTER-1B22D;Lo;0;L;;;;;N;;;;; -1B22E;NUSHU CHARACTER-1B22E;Lo;0;L;;;;;N;;;;; -1B22F;NUSHU CHARACTER-1B22F;Lo;0;L;;;;;N;;;;; -1B230;NUSHU CHARACTER-1B230;Lo;0;L;;;;;N;;;;; -1B231;NUSHU CHARACTER-1B231;Lo;0;L;;;;;N;;;;; -1B232;NUSHU CHARACTER-1B232;Lo;0;L;;;;;N;;;;; -1B233;NUSHU CHARACTER-1B233;Lo;0;L;;;;;N;;;;; -1B234;NUSHU CHARACTER-1B234;Lo;0;L;;;;;N;;;;; -1B235;NUSHU CHARACTER-1B235;Lo;0;L;;;;;N;;;;; -1B236;NUSHU CHARACTER-1B236;Lo;0;L;;;;;N;;;;; -1B237;NUSHU CHARACTER-1B237;Lo;0;L;;;;;N;;;;; -1B238;NUSHU CHARACTER-1B238;Lo;0;L;;;;;N;;;;; -1B239;NUSHU CHARACTER-1B239;Lo;0;L;;;;;N;;;;; -1B23A;NUSHU CHARACTER-1B23A;Lo;0;L;;;;;N;;;;; -1B23B;NUSHU CHARACTER-1B23B;Lo;0;L;;;;;N;;;;; -1B23C;NUSHU CHARACTER-1B23C;Lo;0;L;;;;;N;;;;; -1B23D;NUSHU CHARACTER-1B23D;Lo;0;L;;;;;N;;;;; -1B23E;NUSHU CHARACTER-1B23E;Lo;0;L;;;;;N;;;;; -1B23F;NUSHU CHARACTER-1B23F;Lo;0;L;;;;;N;;;;; -1B240;NUSHU CHARACTER-1B240;Lo;0;L;;;;;N;;;;; -1B241;NUSHU CHARACTER-1B241;Lo;0;L;;;;;N;;;;; -1B242;NUSHU CHARACTER-1B242;Lo;0;L;;;;;N;;;;; -1B243;NUSHU CHARACTER-1B243;Lo;0;L;;;;;N;;;;; -1B244;NUSHU CHARACTER-1B244;Lo;0;L;;;;;N;;;;; -1B245;NUSHU CHARACTER-1B245;Lo;0;L;;;;;N;;;;; -1B246;NUSHU CHARACTER-1B246;Lo;0;L;;;;;N;;;;; -1B247;NUSHU CHARACTER-1B247;Lo;0;L;;;;;N;;;;; -1B248;NUSHU CHARACTER-1B248;Lo;0;L;;;;;N;;;;; -1B249;NUSHU CHARACTER-1B249;Lo;0;L;;;;;N;;;;; -1B24A;NUSHU CHARACTER-1B24A;Lo;0;L;;;;;N;;;;; -1B24B;NUSHU CHARACTER-1B24B;Lo;0;L;;;;;N;;;;; -1B24C;NUSHU CHARACTER-1B24C;Lo;0;L;;;;;N;;;;; -1B24D;NUSHU CHARACTER-1B24D;Lo;0;L;;;;;N;;;;; -1B24E;NUSHU CHARACTER-1B24E;Lo;0;L;;;;;N;;;;; -1B24F;NUSHU CHARACTER-1B24F;Lo;0;L;;;;;N;;;;; -1B250;NUSHU CHARACTER-1B250;Lo;0;L;;;;;N;;;;; -1B251;NUSHU CHARACTER-1B251;Lo;0;L;;;;;N;;;;; -1B252;NUSHU CHARACTER-1B252;Lo;0;L;;;;;N;;;;; -1B253;NUSHU CHARACTER-1B253;Lo;0;L;;;;;N;;;;; -1B254;NUSHU CHARACTER-1B254;Lo;0;L;;;;;N;;;;; -1B255;NUSHU CHARACTER-1B255;Lo;0;L;;;;;N;;;;; -1B256;NUSHU CHARACTER-1B256;Lo;0;L;;;;;N;;;;; -1B257;NUSHU CHARACTER-1B257;Lo;0;L;;;;;N;;;;; -1B258;NUSHU CHARACTER-1B258;Lo;0;L;;;;;N;;;;; -1B259;NUSHU CHARACTER-1B259;Lo;0;L;;;;;N;;;;; -1B25A;NUSHU CHARACTER-1B25A;Lo;0;L;;;;;N;;;;; -1B25B;NUSHU CHARACTER-1B25B;Lo;0;L;;;;;N;;;;; -1B25C;NUSHU CHARACTER-1B25C;Lo;0;L;;;;;N;;;;; -1B25D;NUSHU CHARACTER-1B25D;Lo;0;L;;;;;N;;;;; -1B25E;NUSHU CHARACTER-1B25E;Lo;0;L;;;;;N;;;;; -1B25F;NUSHU CHARACTER-1B25F;Lo;0;L;;;;;N;;;;; -1B260;NUSHU CHARACTER-1B260;Lo;0;L;;;;;N;;;;; -1B261;NUSHU CHARACTER-1B261;Lo;0;L;;;;;N;;;;; -1B262;NUSHU CHARACTER-1B262;Lo;0;L;;;;;N;;;;; -1B263;NUSHU CHARACTER-1B263;Lo;0;L;;;;;N;;;;; -1B264;NUSHU CHARACTER-1B264;Lo;0;L;;;;;N;;;;; -1B265;NUSHU CHARACTER-1B265;Lo;0;L;;;;;N;;;;; -1B266;NUSHU CHARACTER-1B266;Lo;0;L;;;;;N;;;;; -1B267;NUSHU CHARACTER-1B267;Lo;0;L;;;;;N;;;;; -1B268;NUSHU CHARACTER-1B268;Lo;0;L;;;;;N;;;;; -1B269;NUSHU CHARACTER-1B269;Lo;0;L;;;;;N;;;;; -1B26A;NUSHU CHARACTER-1B26A;Lo;0;L;;;;;N;;;;; -1B26B;NUSHU CHARACTER-1B26B;Lo;0;L;;;;;N;;;;; -1B26C;NUSHU CHARACTER-1B26C;Lo;0;L;;;;;N;;;;; -1B26D;NUSHU CHARACTER-1B26D;Lo;0;L;;;;;N;;;;; -1B26E;NUSHU CHARACTER-1B26E;Lo;0;L;;;;;N;;;;; -1B26F;NUSHU CHARACTER-1B26F;Lo;0;L;;;;;N;;;;; -1B270;NUSHU CHARACTER-1B270;Lo;0;L;;;;;N;;;;; -1B271;NUSHU CHARACTER-1B271;Lo;0;L;;;;;N;;;;; -1B272;NUSHU CHARACTER-1B272;Lo;0;L;;;;;N;;;;; -1B273;NUSHU CHARACTER-1B273;Lo;0;L;;;;;N;;;;; -1B274;NUSHU CHARACTER-1B274;Lo;0;L;;;;;N;;;;; -1B275;NUSHU CHARACTER-1B275;Lo;0;L;;;;;N;;;;; -1B276;NUSHU CHARACTER-1B276;Lo;0;L;;;;;N;;;;; -1B277;NUSHU CHARACTER-1B277;Lo;0;L;;;;;N;;;;; -1B278;NUSHU CHARACTER-1B278;Lo;0;L;;;;;N;;;;; -1B279;NUSHU CHARACTER-1B279;Lo;0;L;;;;;N;;;;; -1B27A;NUSHU CHARACTER-1B27A;Lo;0;L;;;;;N;;;;; -1B27B;NUSHU CHARACTER-1B27B;Lo;0;L;;;;;N;;;;; -1B27C;NUSHU CHARACTER-1B27C;Lo;0;L;;;;;N;;;;; -1B27D;NUSHU CHARACTER-1B27D;Lo;0;L;;;;;N;;;;; -1B27E;NUSHU CHARACTER-1B27E;Lo;0;L;;;;;N;;;;; -1B27F;NUSHU CHARACTER-1B27F;Lo;0;L;;;;;N;;;;; -1B280;NUSHU CHARACTER-1B280;Lo;0;L;;;;;N;;;;; -1B281;NUSHU CHARACTER-1B281;Lo;0;L;;;;;N;;;;; -1B282;NUSHU CHARACTER-1B282;Lo;0;L;;;;;N;;;;; -1B283;NUSHU CHARACTER-1B283;Lo;0;L;;;;;N;;;;; -1B284;NUSHU CHARACTER-1B284;Lo;0;L;;;;;N;;;;; -1B285;NUSHU CHARACTER-1B285;Lo;0;L;;;;;N;;;;; -1B286;NUSHU CHARACTER-1B286;Lo;0;L;;;;;N;;;;; -1B287;NUSHU CHARACTER-1B287;Lo;0;L;;;;;N;;;;; -1B288;NUSHU CHARACTER-1B288;Lo;0;L;;;;;N;;;;; -1B289;NUSHU CHARACTER-1B289;Lo;0;L;;;;;N;;;;; -1B28A;NUSHU CHARACTER-1B28A;Lo;0;L;;;;;N;;;;; -1B28B;NUSHU CHARACTER-1B28B;Lo;0;L;;;;;N;;;;; -1B28C;NUSHU CHARACTER-1B28C;Lo;0;L;;;;;N;;;;; -1B28D;NUSHU CHARACTER-1B28D;Lo;0;L;;;;;N;;;;; -1B28E;NUSHU CHARACTER-1B28E;Lo;0;L;;;;;N;;;;; -1B28F;NUSHU CHARACTER-1B28F;Lo;0;L;;;;;N;;;;; -1B290;NUSHU CHARACTER-1B290;Lo;0;L;;;;;N;;;;; -1B291;NUSHU CHARACTER-1B291;Lo;0;L;;;;;N;;;;; -1B292;NUSHU CHARACTER-1B292;Lo;0;L;;;;;N;;;;; -1B293;NUSHU CHARACTER-1B293;Lo;0;L;;;;;N;;;;; -1B294;NUSHU CHARACTER-1B294;Lo;0;L;;;;;N;;;;; -1B295;NUSHU CHARACTER-1B295;Lo;0;L;;;;;N;;;;; -1B296;NUSHU CHARACTER-1B296;Lo;0;L;;;;;N;;;;; -1B297;NUSHU CHARACTER-1B297;Lo;0;L;;;;;N;;;;; -1B298;NUSHU CHARACTER-1B298;Lo;0;L;;;;;N;;;;; -1B299;NUSHU CHARACTER-1B299;Lo;0;L;;;;;N;;;;; -1B29A;NUSHU CHARACTER-1B29A;Lo;0;L;;;;;N;;;;; -1B29B;NUSHU CHARACTER-1B29B;Lo;0;L;;;;;N;;;;; -1B29C;NUSHU CHARACTER-1B29C;Lo;0;L;;;;;N;;;;; -1B29D;NUSHU CHARACTER-1B29D;Lo;0;L;;;;;N;;;;; -1B29E;NUSHU CHARACTER-1B29E;Lo;0;L;;;;;N;;;;; -1B29F;NUSHU CHARACTER-1B29F;Lo;0;L;;;;;N;;;;; -1B2A0;NUSHU CHARACTER-1B2A0;Lo;0;L;;;;;N;;;;; -1B2A1;NUSHU CHARACTER-1B2A1;Lo;0;L;;;;;N;;;;; -1B2A2;NUSHU CHARACTER-1B2A2;Lo;0;L;;;;;N;;;;; -1B2A3;NUSHU CHARACTER-1B2A3;Lo;0;L;;;;;N;;;;; -1B2A4;NUSHU CHARACTER-1B2A4;Lo;0;L;;;;;N;;;;; -1B2A5;NUSHU CHARACTER-1B2A5;Lo;0;L;;;;;N;;;;; -1B2A6;NUSHU CHARACTER-1B2A6;Lo;0;L;;;;;N;;;;; -1B2A7;NUSHU CHARACTER-1B2A7;Lo;0;L;;;;;N;;;;; -1B2A8;NUSHU CHARACTER-1B2A8;Lo;0;L;;;;;N;;;;; -1B2A9;NUSHU CHARACTER-1B2A9;Lo;0;L;;;;;N;;;;; -1B2AA;NUSHU CHARACTER-1B2AA;Lo;0;L;;;;;N;;;;; -1B2AB;NUSHU CHARACTER-1B2AB;Lo;0;L;;;;;N;;;;; -1B2AC;NUSHU CHARACTER-1B2AC;Lo;0;L;;;;;N;;;;; -1B2AD;NUSHU CHARACTER-1B2AD;Lo;0;L;;;;;N;;;;; -1B2AE;NUSHU CHARACTER-1B2AE;Lo;0;L;;;;;N;;;;; -1B2AF;NUSHU CHARACTER-1B2AF;Lo;0;L;;;;;N;;;;; -1B2B0;NUSHU CHARACTER-1B2B0;Lo;0;L;;;;;N;;;;; -1B2B1;NUSHU CHARACTER-1B2B1;Lo;0;L;;;;;N;;;;; -1B2B2;NUSHU CHARACTER-1B2B2;Lo;0;L;;;;;N;;;;; -1B2B3;NUSHU CHARACTER-1B2B3;Lo;0;L;;;;;N;;;;; -1B2B4;NUSHU CHARACTER-1B2B4;Lo;0;L;;;;;N;;;;; -1B2B5;NUSHU CHARACTER-1B2B5;Lo;0;L;;;;;N;;;;; -1B2B6;NUSHU CHARACTER-1B2B6;Lo;0;L;;;;;N;;;;; -1B2B7;NUSHU CHARACTER-1B2B7;Lo;0;L;;;;;N;;;;; -1B2B8;NUSHU CHARACTER-1B2B8;Lo;0;L;;;;;N;;;;; -1B2B9;NUSHU CHARACTER-1B2B9;Lo;0;L;;;;;N;;;;; -1B2BA;NUSHU CHARACTER-1B2BA;Lo;0;L;;;;;N;;;;; -1B2BB;NUSHU CHARACTER-1B2BB;Lo;0;L;;;;;N;;;;; -1B2BC;NUSHU CHARACTER-1B2BC;Lo;0;L;;;;;N;;;;; -1B2BD;NUSHU CHARACTER-1B2BD;Lo;0;L;;;;;N;;;;; -1B2BE;NUSHU CHARACTER-1B2BE;Lo;0;L;;;;;N;;;;; -1B2BF;NUSHU CHARACTER-1B2BF;Lo;0;L;;;;;N;;;;; -1B2C0;NUSHU CHARACTER-1B2C0;Lo;0;L;;;;;N;;;;; -1B2C1;NUSHU CHARACTER-1B2C1;Lo;0;L;;;;;N;;;;; -1B2C2;NUSHU CHARACTER-1B2C2;Lo;0;L;;;;;N;;;;; -1B2C3;NUSHU CHARACTER-1B2C3;Lo;0;L;;;;;N;;;;; -1B2C4;NUSHU CHARACTER-1B2C4;Lo;0;L;;;;;N;;;;; -1B2C5;NUSHU CHARACTER-1B2C5;Lo;0;L;;;;;N;;;;; -1B2C6;NUSHU CHARACTER-1B2C6;Lo;0;L;;;;;N;;;;; -1B2C7;NUSHU CHARACTER-1B2C7;Lo;0;L;;;;;N;;;;; -1B2C8;NUSHU CHARACTER-1B2C8;Lo;0;L;;;;;N;;;;; -1B2C9;NUSHU CHARACTER-1B2C9;Lo;0;L;;;;;N;;;;; -1B2CA;NUSHU CHARACTER-1B2CA;Lo;0;L;;;;;N;;;;; -1B2CB;NUSHU CHARACTER-1B2CB;Lo;0;L;;;;;N;;;;; -1B2CC;NUSHU CHARACTER-1B2CC;Lo;0;L;;;;;N;;;;; -1B2CD;NUSHU CHARACTER-1B2CD;Lo;0;L;;;;;N;;;;; -1B2CE;NUSHU CHARACTER-1B2CE;Lo;0;L;;;;;N;;;;; -1B2CF;NUSHU CHARACTER-1B2CF;Lo;0;L;;;;;N;;;;; -1B2D0;NUSHU CHARACTER-1B2D0;Lo;0;L;;;;;N;;;;; -1B2D1;NUSHU CHARACTER-1B2D1;Lo;0;L;;;;;N;;;;; -1B2D2;NUSHU CHARACTER-1B2D2;Lo;0;L;;;;;N;;;;; -1B2D3;NUSHU CHARACTER-1B2D3;Lo;0;L;;;;;N;;;;; -1B2D4;NUSHU CHARACTER-1B2D4;Lo;0;L;;;;;N;;;;; -1B2D5;NUSHU CHARACTER-1B2D5;Lo;0;L;;;;;N;;;;; -1B2D6;NUSHU CHARACTER-1B2D6;Lo;0;L;;;;;N;;;;; -1B2D7;NUSHU CHARACTER-1B2D7;Lo;0;L;;;;;N;;;;; -1B2D8;NUSHU CHARACTER-1B2D8;Lo;0;L;;;;;N;;;;; -1B2D9;NUSHU CHARACTER-1B2D9;Lo;0;L;;;;;N;;;;; -1B2DA;NUSHU CHARACTER-1B2DA;Lo;0;L;;;;;N;;;;; -1B2DB;NUSHU CHARACTER-1B2DB;Lo;0;L;;;;;N;;;;; -1B2DC;NUSHU CHARACTER-1B2DC;Lo;0;L;;;;;N;;;;; -1B2DD;NUSHU CHARACTER-1B2DD;Lo;0;L;;;;;N;;;;; -1B2DE;NUSHU CHARACTER-1B2DE;Lo;0;L;;;;;N;;;;; -1B2DF;NUSHU CHARACTER-1B2DF;Lo;0;L;;;;;N;;;;; -1B2E0;NUSHU CHARACTER-1B2E0;Lo;0;L;;;;;N;;;;; -1B2E1;NUSHU CHARACTER-1B2E1;Lo;0;L;;;;;N;;;;; -1B2E2;NUSHU CHARACTER-1B2E2;Lo;0;L;;;;;N;;;;; -1B2E3;NUSHU CHARACTER-1B2E3;Lo;0;L;;;;;N;;;;; -1B2E4;NUSHU CHARACTER-1B2E4;Lo;0;L;;;;;N;;;;; -1B2E5;NUSHU CHARACTER-1B2E5;Lo;0;L;;;;;N;;;;; -1B2E6;NUSHU CHARACTER-1B2E6;Lo;0;L;;;;;N;;;;; -1B2E7;NUSHU CHARACTER-1B2E7;Lo;0;L;;;;;N;;;;; -1B2E8;NUSHU CHARACTER-1B2E8;Lo;0;L;;;;;N;;;;; -1B2E9;NUSHU CHARACTER-1B2E9;Lo;0;L;;;;;N;;;;; -1B2EA;NUSHU CHARACTER-1B2EA;Lo;0;L;;;;;N;;;;; -1B2EB;NUSHU CHARACTER-1B2EB;Lo;0;L;;;;;N;;;;; -1B2EC;NUSHU CHARACTER-1B2EC;Lo;0;L;;;;;N;;;;; -1B2ED;NUSHU CHARACTER-1B2ED;Lo;0;L;;;;;N;;;;; -1B2EE;NUSHU CHARACTER-1B2EE;Lo;0;L;;;;;N;;;;; -1B2EF;NUSHU CHARACTER-1B2EF;Lo;0;L;;;;;N;;;;; -1B2F0;NUSHU CHARACTER-1B2F0;Lo;0;L;;;;;N;;;;; -1B2F1;NUSHU CHARACTER-1B2F1;Lo;0;L;;;;;N;;;;; -1B2F2;NUSHU CHARACTER-1B2F2;Lo;0;L;;;;;N;;;;; -1B2F3;NUSHU CHARACTER-1B2F3;Lo;0;L;;;;;N;;;;; -1B2F4;NUSHU CHARACTER-1B2F4;Lo;0;L;;;;;N;;;;; -1B2F5;NUSHU CHARACTER-1B2F5;Lo;0;L;;;;;N;;;;; -1B2F6;NUSHU CHARACTER-1B2F6;Lo;0;L;;;;;N;;;;; -1B2F7;NUSHU CHARACTER-1B2F7;Lo;0;L;;;;;N;;;;; -1B2F8;NUSHU CHARACTER-1B2F8;Lo;0;L;;;;;N;;;;; -1B2F9;NUSHU CHARACTER-1B2F9;Lo;0;L;;;;;N;;;;; -1B2FA;NUSHU CHARACTER-1B2FA;Lo;0;L;;;;;N;;;;; -1B2FB;NUSHU CHARACTER-1B2FB;Lo;0;L;;;;;N;;;;; 1BC00;DUPLOYAN LETTER H;Lo;0;L;;;;;N;;;;; 1BC01;DUPLOYAN LETTER X;Lo;0;L;;;;;N;;;;; 1BC02;DUPLOYAN LETTER P;Lo;0;L;;;;;N;;;;; @@ -29217,12 +28269,6 @@ 1F248;TORTOISE SHELL BRACKETED CJK UNIFIED IDEOGRAPH-6557;So;0;L; 3014 6557 3015;;;;N;;;;; 1F250;CIRCLED IDEOGRAPH ADVANTAGE;So;0;L; 5F97;;;;N;;;;; 1F251;CIRCLED IDEOGRAPH ACCEPT;So;0;L; 53EF;;;;N;;;;; -1F260;ROUNDED SYMBOL FOR FU;So;0;ON;;;;;N;;;;; -1F261;ROUNDED SYMBOL FOR LU;So;0;ON;;;;;N;;;;; -1F262;ROUNDED SYMBOL FOR SHOU;So;0;ON;;;;;N;;;;; -1F263;ROUNDED SYMBOL FOR XI;So;0;ON;;;;;N;;;;; -1F264;ROUNDED SYMBOL FOR SHUANGXI;So;0;ON;;;;;N;;;;; -1F265;ROUNDED SYMBOL FOR CAI;So;0;ON;;;;;N;;;;; 1F300;CYCLONE;So;0;ON;;;;;N;;;;; 1F301;FOGGY;So;0;ON;;;;;N;;;;; 1F302;CLOSED UMBRELLA;So;0;ON;;;;;N;;;;; @@ -30202,8 +29248,6 @@ 1F6D0;PLACE OF WORSHIP;So;0;ON;;;;;N;;;;; 1F6D1;OCTAGONAL SIGN;So;0;ON;;;;;N;;;;; 1F6D2;SHOPPING TROLLEY;So;0;ON;;;;;N;;;;; -1F6D3;STUPA;So;0;ON;;;;;N;;;;; -1F6D4;PAGODA;So;0;ON;;;;;N;;;;; 1F6E0;HAMMER AND WRENCH;So;0;ON;;;;;N;;;;; 1F6E1;SHIELD;So;0;ON;;;;;N;;;;; 1F6E2;OIL DRUM;So;0;ON;;;;;N;;;;; @@ -30224,8 +29268,6 @@ 1F6F4;SCOOTER;So;0;ON;;;;;N;;;;; 1F6F5;MOTOR SCOOTER;So;0;ON;;;;;N;;;;; 1F6F6;CANOE;So;0;ON;;;;;N;;;;; -1F6F7;SLED;So;0;ON;;;;;N;;;;; -1F6F8;FLYING SAUCER;So;0;ON;;;;;N;;;;; 1F700;ALCHEMICAL SYMBOL FOR QUINTESSENCE;So;0;ON;;;;;N;;;;; 1F701;ALCHEMICAL SYMBOL FOR AIR;So;0;ON;;;;;N;;;;; 1F702;ALCHEMICAL SYMBOL FOR FIRE;So;0;ON;;;;;N;;;;; @@ -30575,18 +29617,6 @@ 1F8AB;RIGHTWARDS FRONT-TILTED SHADOWED WHITE ARROW;So;0;ON;;;;;N;;;;; 1F8AC;WHITE ARROW SHAFT WIDTH ONE;So;0;ON;;;;;N;;;;; 1F8AD;WHITE ARROW SHAFT WIDTH TWO THIRDS;So;0;ON;;;;;N;;;;; -1F900;CIRCLED CROSS FORMEE WITH FOUR DOTS;So;0;ON;;;;;N;;;;; -1F901;CIRCLED CROSS FORMEE WITH TWO DOTS;So;0;ON;;;;;N;;;;; -1F902;CIRCLED CROSS FORMEE;So;0;ON;;;;;N;;;;; -1F903;LEFT HALF CIRCLE WITH FOUR DOTS;So;0;ON;;;;;N;;;;; -1F904;LEFT HALF CIRCLE WITH THREE DOTS;So;0;ON;;;;;N;;;;; -1F905;LEFT HALF CIRCLE WITH TWO DOTS;So;0;ON;;;;;N;;;;; -1F906;LEFT HALF CIRCLE WITH DOT;So;0;ON;;;;;N;;;;; -1F907;LEFT HALF CIRCLE;So;0;ON;;;;;N;;;;; -1F908;DOWNWARD FACING HOOK;So;0;ON;;;;;N;;;;; -1F909;DOWNWARD FACING NOTCHED HOOK;So;0;ON;;;;;N;;;;; -1F90A;DOWNWARD FACING HOOK WITH DOT;So;0;ON;;;;;N;;;;; -1F90B;DOWNWARD FACING NOTCHED HOOK WITH DOT;So;0;ON;;;;;N;;;;; 1F910;ZIPPER-MOUTH FACE;So;0;ON;;;;;N;;;;; 1F911;MONEY-MOUTH FACE;So;0;ON;;;;;N;;;;; 1F912;FACE WITH THERMOMETER;So;0;ON;;;;;N;;;;; @@ -30602,7 +29632,6 @@ 1F91C;RIGHT-FACING FIST;So;0;ON;;;;;N;;;;; 1F91D;HANDSHAKE;So;0;ON;;;;;N;;;;; 1F91E;HAND WITH INDEX AND MIDDLE FINGERS CROSSED;So;0;ON;;;;;N;;;;; -1F91F;I LOVE YOU HAND SIGN;So;0;ON;;;;;N;;;;; 1F920;FACE WITH COWBOY HAT;So;0;ON;;;;;N;;;;; 1F921;CLOWN FACE;So;0;ON;;;;;N;;;;; 1F922;NAUSEATED FACE;So;0;ON;;;;;N;;;;; @@ -30611,17 +29640,7 @@ 1F925;LYING FACE;So;0;ON;;;;;N;;;;; 1F926;FACE PALM;So;0;ON;;;;;N;;;;; 1F927;SNEEZING FACE;So;0;ON;;;;;N;;;;; -1F928;FACE WITH ONE EYEBROW RAISED;So;0;ON;;;;;N;;;;; -1F929;GRINNING FACE WITH STAR EYES;So;0;ON;;;;;N;;;;; -1F92A;GRINNING FACE WITH ONE LARGE AND ONE SMALL EYE;So;0;ON;;;;;N;;;;; -1F92B;FACE WITH FINGER COVERING CLOSED LIPS;So;0;ON;;;;;N;;;;; -1F92C;SERIOUS FACE WITH SYMBOLS COVERING MOUTH;So;0;ON;;;;;N;;;;; -1F92D;SMILING FACE WITH SMILING EYES AND HAND COVERING MOUTH;So;0;ON;;;;;N;;;;; -1F92E;FACE WITH OPEN MOUTH VOMITING;So;0;ON;;;;;N;;;;; -1F92F;SHOCKED FACE WITH EXPLODING HEAD;So;0;ON;;;;;N;;;;; 1F930;PREGNANT WOMAN;So;0;ON;;;;;N;;;;; -1F931;BREAST-FEEDING;So;0;ON;;;;;N;;;;; -1F932;PALMS UP TOGETHER;So;0;ON;;;;;N;;;;; 1F933;SELFIE;So;0;ON;;;;;N;;;;; 1F934;PRINCE;So;0;ON;;;;;N;;;;; 1F935;MAN IN TUXEDO;So;0;ON;;;;;N;;;;; @@ -30646,7 +29665,6 @@ 1F949;THIRD PLACE MEDAL;So;0;ON;;;;;N;;;;; 1F94A;BOXING GLOVE;So;0;ON;;;;;N;;;;; 1F94B;MARTIAL ARTS UNIFORM;So;0;ON;;;;;N;;;;; -1F94C;CURLING STONE;So;0;ON;;;;;N;;;;; 1F950;CROISSANT;So;0;ON;;;;;N;;;;; 1F951;AVOCADO;So;0;ON;;;;;N;;;;; 1F952;CUCUMBER;So;0;ON;;;;;N;;;;; @@ -30662,19 +29680,6 @@ 1F95C;PEANUTS;So;0;ON;;;;;N;;;;; 1F95D;KIWIFRUIT;So;0;ON;;;;;N;;;;; 1F95E;PANCAKES;So;0;ON;;;;;N;;;;; -1F95F;DUMPLING;So;0;ON;;;;;N;;;;; -1F960;FORTUNE COOKIE;So;0;ON;;;;;N;;;;; -1F961;TAKEOUT BOX;So;0;ON;;;;;N;;;;; -1F962;CHOPSTICKS;So;0;ON;;;;;N;;;;; -1F963;BOWL WITH SPOON;So;0;ON;;;;;N;;;;; -1F964;CUP WITH STRAW;So;0;ON;;;;;N;;;;; -1F965;COCONUT;So;0;ON;;;;;N;;;;; -1F966;BROCCOLI;So;0;ON;;;;;N;;;;; -1F967;PIE;So;0;ON;;;;;N;;;;; -1F968;PRETZEL;So;0;ON;;;;;N;;;;; -1F969;CUT OF MEAT;So;0;ON;;;;;N;;;;; -1F96A;SANDWICH;So;0;ON;;;;;N;;;;; -1F96B;CANNED FOOD;So;0;ON;;;;;N;;;;; 1F980;CRAB;So;0;ON;;;;;N;;;;; 1F981;LION FACE;So;0;ON;;;;;N;;;;; 1F982;SCORPION;So;0;ON;;;;;N;;;;; @@ -30693,36 +29698,7 @@ 1F98F;RHINOCEROS;So;0;ON;;;;;N;;;;; 1F990;SHRIMP;So;0;ON;;;;;N;;;;; 1F991;SQUID;So;0;ON;;;;;N;;;;; -1F992;GIRAFFE FACE;So;0;ON;;;;;N;;;;; -1F993;ZEBRA FACE;So;0;ON;;;;;N;;;;; -1F994;HEDGEHOG;So;0;ON;;;;;N;;;;; -1F995;SAUROPOD;So;0;ON;;;;;N;;;;; -1F996;T-REX;So;0;ON;;;;;N;;;;; -1F997;CRICKET;So;0;ON;;;;;N;;;;; 1F9C0;CHEESE WEDGE;So;0;ON;;;;;N;;;;; -1F9D0;FACE WITH MONOCLE;So;0;ON;;;;;N;;;;; -1F9D1;ADULT;So;0;ON;;;;;N;;;;; -1F9D2;CHILD;So;0;ON;;;;;N;;;;; -1F9D3;OLDER ADULT;So;0;ON;;;;;N;;;;; -1F9D4;BEARDED PERSON;So;0;ON;;;;;N;;;;; -1F9D5;PERSON WITH HEADSCARF;So;0;ON;;;;;N;;;;; -1F9D6;PERSON IN STEAMY ROOM;So;0;ON;;;;;N;;;;; -1F9D7;PERSON CLIMBING;So;0;ON;;;;;N;;;;; -1F9D8;PERSON IN LOTUS POSITION;So;0;ON;;;;;N;;;;; -1F9D9;MAGE;So;0;ON;;;;;N;;;;; -1F9DA;FAIRY;So;0;ON;;;;;N;;;;; -1F9DB;VAMPIRE;So;0;ON;;;;;N;;;;; -1F9DC;MERPERSON;So;0;ON;;;;;N;;;;; -1F9DD;ELF;So;0;ON;;;;;N;;;;; -1F9DE;GENIE;So;0;ON;;;;;N;;;;; -1F9DF;ZOMBIE;So;0;ON;;;;;N;;;;; -1F9E0;BRAIN;So;0;ON;;;;;N;;;;; -1F9E1;ORANGE HEART;So;0;ON;;;;;N;;;;; -1F9E2;BILLED CAP;So;0;ON;;;;;N;;;;; -1F9E3;SCARF;So;0;ON;;;;;N;;;;; -1F9E4;GLOVES;So;0;ON;;;;;N;;;;; -1F9E5;COAT;So;0;ON;;;;;N;;;;; -1F9E6;SOCKS;So;0;ON;;;;;N;;;;; 20000;;Lo;0;L;;;;;N;;;;; 2A6D6;;Lo;0;L;;;;;N;;;;; 2A700;;Lo;0;L;;;;;N;;;;; @@ -30731,8 +29707,6 @@ 2B81D;;Lo;0;L;;;;;N;;;;; 2B820;;Lo;0;L;;;;;N;;;;; 2CEA1;;Lo;0;L;;;;;N;;;;; -2CEB0;;Lo;0;L;;;;;N;;;;; -2EBE0;;Lo;0;L;;;;;N;;;;; 2F800;CJK COMPATIBILITY IDEOGRAPH-2F800;Lo;0;L;4E3D;;;;N;;;;; 2F801;CJK COMPATIBILITY IDEOGRAPH-2F801;Lo;0;L;4E38;;;;N;;;;; 2F802;CJK COMPATIBILITY IDEOGRAPH-2F802;Lo;0;L;4E41;;;;N;;;;; diff -Nru duktape-2.3.0/src-noline/duk_config.h duktape-2.2.0/src-noline/duk_config.h --- duktape-2.3.0/src-noline/duk_config.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-noline/duk_config.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,8 +1,8 @@ /* * duk_config.h configuration header generated by genconfig.py. * - * Git commit: d7fdb67f18561a50e06bafd196c6b423af9ad6fe - * Git describe: v2.3.0 + * Git commit: a459cf3c9bd1779fc01b435d69302b742675a08f + * Git describe: v2.2.0 * Git branch: master * * Supported platforms: @@ -218,6 +218,12 @@ #define DUK_F_UNIX #endif +/* C++ */ +#undef DUK_F_CPP +#if defined(__cplusplus) +#define DUK_F_CPP +#endif + /* Intel x86 (32-bit), x64 (64-bit) or x32 (64-bit but 32-bit pointers), * define only one of DUK_F_X86, DUK_F_X64, DUK_F_X32. * https://sites.google.com/site/x32abi/ @@ -295,12 +301,6 @@ #define DUK_F_CLANG #endif -/* C++ */ -#undef DUK_F_CPP -#if defined(__cplusplus) -#define DUK_F_CPP -#endif - /* C99 or above */ #undef DUK_F_C99 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) @@ -836,7 +836,9 @@ #include #endif -/* is only included if needed, based on DUK_USE_xxx flags. */ +#if defined(DUK_F_CPP) +#include /* std::exception */ +#endif /* * Architecture autodetection @@ -848,16 +850,13 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif - -#define DUK_USE_PACKED_TVAL - -/* FreeBSD, -m32, and clang prior to 5.0 has union aliasing issues which - * break duk_tval copying. Disable packed duk_tval automatically. +/* XXX: This is technically not guaranteed because it's possible to configure + * an x86 to require aligned accesses with Alignment Check (AC) flag. */ -#if defined(DUK_F_FREEBSD) && defined(DUK_F_X86) && \ - defined(__clang__) && defined(__clang_major__) && (__clang_major__ < 5) -#undef DUK_USE_PACKED_TVAL +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 1 #endif +#define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_X64) /* --- x64 --- */ @@ -865,6 +864,12 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif +/* XXX: This is technically not guaranteed because it's possible to configure + * an x86 to require aligned accesses with Alignment Check (AC) flag. + */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 1 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_X32) @@ -873,30 +878,48 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif +/* XXX: This is technically not guaranteed because it's possible to configure + * an x86 to require aligned accesses with Alignment Check (AC) flag. + */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 1 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_ARM32) /* --- ARM 32-bit --- */ #define DUK_USE_ARCH_STRING "arm32" /* Byte order varies, so rely on autodetect. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 4 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_ARM64) /* --- ARM 64-bit --- */ #define DUK_USE_ARCH_STRING "arm64" /* Byte order varies, so rely on autodetect. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_MIPS32) /* --- MIPS 32-bit --- */ #define DUK_USE_ARCH_STRING "mips32" /* MIPS byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_MIPS64) /* --- MIPS 64-bit --- */ #define DUK_USE_ARCH_STRING "mips64" /* MIPS byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_PPC32) @@ -905,6 +928,9 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_PPC64) @@ -913,24 +939,39 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_SPARC32) /* --- SPARC 32-bit --- */ #define DUK_USE_ARCH_STRING "sparc32" /* SPARC byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_SPARC64) /* --- SPARC 64-bit --- */ #define DUK_USE_ARCH_STRING "sparc64" /* SPARC byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_SUPERH) /* --- SuperH --- */ #define DUK_USE_ARCH_STRING "sh" /* Byte order varies, rely on autodetection. */ +/* Based on 'make checkalign' there are no alignment requirements on + * Linux SH4, but align by 4 is probably a good basic default. + */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 4 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_M68K) @@ -939,6 +980,9 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_EMSCRIPTEN) @@ -947,6 +991,9 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #else @@ -1958,8 +2005,8 @@ /* Boolean values are represented with the platform 'unsigned int'. */ typedef duk_small_uint_t duk_bool_t; -#define DUK_BOOL_MIN DUK_SMALL_UINT_MIN -#define DUK_BOOL_MAX DUK_SMALL_UINT_MAX +#define DUK_BOOL_MIN DUK_SMALL_INT_MIN +#define DUK_BOOL_MAX DUK_SMALL_INT_MAX /* Index values must have at least 32-bit signed range. */ typedef duk_int_t duk_idx_t; @@ -2493,13 +2540,10 @@ * * Assume unaligned accesses are not supported unless specifically allowed * in the target platform. Some platforms may support unaligned accesses - * but alignment to 4 or 8 may still be desirable. Note that unaligned - * accesses (and even pointers) relative to natural alignment (regardless - * of target alignment) are technically undefined behavior and thus - * compiler/architecture specific. + * but alignment to 4 or 8 may still be desirable. */ -/* If not forced, use safe default for alignment. */ +/* If not provided, use safe default for alignment. */ #if !defined(DUK_USE_ALIGN_BY) #define DUK_USE_ALIGN_BY 8 #endif @@ -2551,7 +2595,6 @@ */ #define DUK_CAUSE_SEGFAULT() do { *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; } while (0) #endif - #if !defined(DUK_UNREF) /* Macro for suppressing warnings for potentially unreferenced variables. * The variables can be actually unreferenced or unreferenced in some @@ -2561,24 +2604,9 @@ */ #define DUK_UNREF(x) do { (void) (x); } while (0) #endif - -/* Fillin for DUK_NORETURN; DUK_WO_NORETURN() is used to insert dummy - * dummy statements after noreturn calls to silence harmless compiler - * warnings, e.g.: - * - * DUK_ERROR_TYPE(thr, "aiee"); - * DUK_WO_NORETURN(return 0;); - * - * Statements inside DUK_WO_NORETURN() must NEVER be actually reachable, - * and they're only included to satisfy the compiler. - */ -#if defined(DUK_NORETURN) -#define DUK_WO_NORETURN(stmt) do { } while (0) -#else +#if !defined(DUK_NORETURN) #define DUK_NORETURN(decl) decl -#define DUK_WO_NORETURN(stmt) do { stmt } while (0) #endif - #if !defined(DUK_UNREACHABLE) /* Don't know how to declare unreachable point, so don't do it; this * may cause some spurious compilation warnings (e.g. "variable used @@ -2586,7 +2614,6 @@ */ #define DUK_UNREACHABLE() do { } while (0) #endif - #if !defined(DUK_LOSE_CONST) /* Convert any input pointer into a "void *", losing a const qualifier. * This is not fully portable because casting through duk_uintptr_t may @@ -2754,8 +2781,8 @@ #if defined(DUK_F_PACKED_TVAL_POSSIBLE) #define DUK_USE_PACKED_TVAL #endif -#undef DUK_F_PACKED_TVAL_POSSIBLE +#undef DUK_F_PACKED_TVAL_POSSIBLE #endif /* DUK_F_PACKED_TVAL_PROVIDED */ /* Object property allocation layout has implications for memory and code * footprint and generated code size/speed. The best layout also depends @@ -2790,7 +2817,6 @@ * Autogenerated defaults */ -#undef DUK_USE_ALLOW_UNDEFINED_BEHAVIOR #define DUK_USE_ARRAY_BUILTIN #define DUK_USE_ARRAY_FASTPATH #define DUK_USE_ARRAY_PROP_FASTPATH @@ -2799,7 +2825,6 @@ #define DUK_USE_AUGMENT_ERROR_THROW #define DUK_USE_AVOID_PLATFORM_FUNCPTRS #define DUK_USE_BASE64_FASTPATH -#define DUK_USE_BASE64_SUPPORT #define DUK_USE_BOOLEAN_BUILTIN #define DUK_USE_BUFFEROBJECT_SUPPORT #undef DUK_USE_BUFLEN16 @@ -2877,7 +2902,6 @@ #undef DUK_USE_HEAPPTR_DEC16 #undef DUK_USE_HEAPPTR_ENC16 #define DUK_USE_HEX_FASTPATH -#define DUK_USE_HEX_SUPPORT #define DUK_USE_HOBJECT_ARRAY_ABANDON_LIMIT 2 #define DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT 9 #define DUK_USE_HOBJECT_ARRAY_MINGROW_ADD 16 @@ -2908,10 +2932,11 @@ #define DUK_USE_JX #define DUK_USE_LEXER_SLIDING_WINDOW #undef DUK_USE_LIGHTFUNC_BUILTINS -#define DUK_USE_LITCACHE_SIZE 256 #define DUK_USE_MARK_AND_SWEEP_RECLIMIT 256 #define DUK_USE_MATH_BUILTIN #define DUK_USE_NATIVE_CALL_RECLIMIT 1000 +#define DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER +#define DUK_USE_NONSTD_ARRAY_MAP_TRAILER #define DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT #undef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY #undef DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY @@ -2987,15 +3012,6 @@ /* __OVERRIDE_DEFINES__ */ /* - * Conditional includes - */ - -#if defined(DUK_F_CPP) && defined(DUK_USE_CPP_EXCEPTIONS) -#include /* std::exception */ -#include /* std::runtime_error */ -#endif - -/* * Date provider selection * * User may define DUK_USE_DATE_GET_NOW() etc directly, in which case we'll @@ -3536,12 +3552,6 @@ #if defined(DUK_USE_MS_STRINGTABLE_RESIZE) #error unsupported config option used (option has been removed): DUK_USE_MS_STRINGTABLE_RESIZE #endif -#if defined(DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER) -#error unsupported config option used (option has been removed): DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER -#endif -#if defined(DUK_USE_NONSTD_ARRAY_MAP_TRAILER) -#error unsupported config option used (option has been removed): DUK_USE_NONSTD_ARRAY_MAP_TRAILER -#endif #if defined(DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE) #error unsupported config option used (option has been removed): DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE #endif diff -Nru duktape-2.3.0/src-noline/duk_source_meta.json duktape-2.2.0/src-noline/duk_source_meta.json --- duktape-2.3.0/src-noline/duk_source_meta.json 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-noline/duk_source_meta.json 2017-09-23 01:06:08.000000000 +0000 @@ -1,702 +1,682 @@ { "comment": "Metadata for Duktape sources", - "duk_version_string": "2.3.0", + "duk_version_string": "2.2.0", "type": "duk_source_meta", "line_map": [ { "original_line": 1, - "combined_line": 143, + "combined_line": 133, "original_file": "duk_replacements.c" }, { "original_line": 1, - "combined_line": 152, + "combined_line": 142, "original_file": "duk_internal.h" }, { "original_line": 1, - "combined_line": 196, + "combined_line": 186, "original_file": "duk_dblunion.h" }, { "original_line": 1, - "combined_line": 620, + "combined_line": 610, "original_file": "duk_replacements.h" }, { "original_line": 1, - "combined_line": 650, + "combined_line": 640, "original_file": "duk_jmpbuf.h" }, { "original_line": 1, - "combined_line": 675, + "combined_line": 665, "original_file": "duk_exception.h" }, { "original_line": 1, - "combined_line": 706, + "combined_line": 684, "original_file": "duk_forwdecl.h" }, { "original_line": 1, - "combined_line": 841, + "combined_line": 817, "original_file": "duk_tval.h" }, { "original_line": 1, - "combined_line": 1474, + "combined_line": 1450, "original_file": "duk_builtins.h" }, { "original_line": 51, - "combined_line": 2254, + "combined_line": 2217, "original_file": "duk_internal.h" }, { "original_line": 1, - "combined_line": 2256, + "combined_line": 2219, "original_file": "duk_util.h" }, { "original_line": 1, - "combined_line": 2967, + "combined_line": 2784, "original_file": "duk_strings.h" }, { "original_line": 1, - "combined_line": 3135, + "combined_line": 2952, "original_file": "duk_js_bytecode.h" }, { "original_line": 1, - "combined_line": 3618, + "combined_line": 3435, "original_file": "duk_lexer.h" }, { "original_line": 1, - "combined_line": 4057, + "combined_line": 3874, "original_file": "duk_js_compiler.h" }, { "original_line": 1, - "combined_line": 4285, + "combined_line": 4101, "original_file": "duk_regexp.h" }, { "original_line": 1, - "combined_line": 4370, + "combined_line": 4186, "original_file": "duk_heaphdr.h" }, { "original_line": 1, - "combined_line": 4676, + "combined_line": 4492, "original_file": "duk_refcount.h" }, { "original_line": 1, - "combined_line": 5402, + "combined_line": 5218, "original_file": "duk_api_internal.h" }, { "original_line": 1, - "combined_line": 5759, + "combined_line": 5567, "original_file": "duk_hstring.h" }, { "original_line": 1, - "combined_line": 6005, + "combined_line": 5806, "original_file": "duk_hobject.h" }, { "original_line": 1, - "combined_line": 7004, + "combined_line": 6805, "original_file": "duk_hcompfunc.h" }, { "original_line": 1, - "combined_line": 7275, + "combined_line": 7076, "original_file": "duk_hnatfunc.h" }, { "original_line": 1, - "combined_line": 7308, + "combined_line": 7109, "original_file": "duk_hboundfunc.h" }, { "original_line": 1, - "combined_line": 7349, + "combined_line": 7150, "original_file": "duk_hbufobj.h" }, { "original_line": 1, - "combined_line": 7493, + "combined_line": 7293, "original_file": "duk_hthread.h" }, { "original_line": 1, - "combined_line": 7915, + "combined_line": 7715, "original_file": "duk_harray.h" }, { "original_line": 1, - "combined_line": 7963, + "combined_line": 7763, "original_file": "duk_henv.h" }, { "original_line": 1, - "combined_line": 8012, + "combined_line": 7812, "original_file": "duk_hbuffer.h" }, { "original_line": 1, - "combined_line": 8341, + "combined_line": 8138, "original_file": "duk_hproxy.h" }, { "original_line": 1, - "combined_line": 8368, + "combined_line": 8165, "original_file": "duk_heap.h" }, { "original_line": 1, - "combined_line": 9078, + "combined_line": 8852, "original_file": "duk_debugger.h" }, { "original_line": 1, - "combined_line": 9230, + "combined_line": 9004, "original_file": "duk_debug.h" }, { "original_line": 1, - "combined_line": 9415, + "combined_line": 9189, "original_file": "duk_error.h" }, { "original_line": 1, - "combined_line": 9933, + "combined_line": 9707, "original_file": "duk_unicode.h" }, { "original_line": 1, - "combined_line": 10223, + "combined_line": 9997, "original_file": "duk_json.h" }, { "original_line": 1, - "combined_line": 10292, + "combined_line": 10066, "original_file": "duk_js.h" }, { "original_line": 1, - "combined_line": 10406, + "combined_line": 10177, "original_file": "duk_numconv.h" }, { "original_line": 1, - "combined_line": 10511, + "combined_line": 10278, "original_file": "duk_bi_protos.h" }, { "original_line": 1, - "combined_line": 10593, + "combined_line": 10360, "original_file": "duk_selftest.h" }, { "original_line": 82, - "combined_line": 10608, + "combined_line": 10375, "original_file": "duk_internal.h" }, { "original_line": 10, - "combined_line": 10610, + "combined_line": 10377, "original_file": "duk_replacements.c" }, { "original_line": 1, - "combined_line": 10683, + "combined_line": 10450, "original_file": "duk_debug_macros.c" }, { "original_line": 1, - "combined_line": 10774, + "combined_line": 10541, "original_file": "duk_builtins.c" }, { "original_line": 1, - "combined_line": 11603, + "combined_line": 11344, "original_file": "duk_error_macros.c" }, { "original_line": 1, - "combined_line": 11758, + "combined_line": 11491, "original_file": "duk_unicode_support.c" }, { "original_line": 1, - "combined_line": 12939, + "combined_line": 12673, "original_file": "duk_util_misc.c" }, { "original_line": 1, - "combined_line": 13122, + "combined_line": 13078, "original_file": "duk_hobject_class.c" }, { "original_line": 1, - "combined_line": 13251, + "combined_line": 13207, "original_file": "duk_alloc_default.c" }, { "original_line": 1, - "combined_line": 13285, + "combined_line": 13241, "original_file": "duk_api_buffer.c" }, { "original_line": 1, - "combined_line": 13358, + "combined_line": 13311, "original_file": "duk_api_bytecode.c" }, { "original_line": 1, - "combined_line": 14132, + "combined_line": 14084, "original_file": "duk_api_call.c" }, { "original_line": 1, - "combined_line": 14653, + "combined_line": 14603, "original_file": "duk_api_codec.c" }, { "original_line": 1, - "combined_line": 15565, + "combined_line": 15260, "original_file": "duk_api_compile.c" }, { "original_line": 1, - "combined_line": 15737, + "combined_line": 15431, "original_file": "duk_api_debug.c" }, { "original_line": 1, - "combined_line": 15998, + "combined_line": 15689, "original_file": "duk_api_heap.c" }, { "original_line": 1, - "combined_line": 16203, + "combined_line": 15894, "original_file": "duk_api_inspect.c" }, { "original_line": 1, - "combined_line": 16448, + "combined_line": 16139, "original_file": "duk_api_memory.c" }, { "original_line": 1, - "combined_line": 16528, + "combined_line": 16219, "original_file": "duk_api_object.c" }, { "original_line": 1, - "combined_line": 17489, - "original_file": "duk_api_random.c" - }, - { - "original_line": 1, - "combined_line": 17498, + "combined_line": 17050, "original_file": "duk_api_stack.c" }, { "original_line": 1, - "combined_line": 24369, + "combined_line": 23647, "original_file": "duk_api_string.c" }, { "original_line": 1, - "combined_line": 24747, + "combined_line": 24023, "original_file": "duk_api_time.c" }, { "original_line": 1, - "combined_line": 24857, + "combined_line": 24133, "original_file": "duk_bi_array.c" }, { "original_line": 1, - "combined_line": 26513, + "combined_line": 25752, "original_file": "duk_bi_boolean.c" }, { "original_line": 1, - "combined_line": 26582, + "combined_line": 25821, "original_file": "duk_bi_buffer.c" }, { "original_line": 1, - "combined_line": 29517, + "combined_line": 28742, "original_file": "duk_bi_date.c" }, { "original_line": 1, - "combined_line": 31327, + "combined_line": 30515, "original_file": "duk_bi_date_unix.c" }, { "original_line": 1, - "combined_line": 31656, + "combined_line": 30844, "original_file": "duk_bi_date_windows.c" }, { "original_line": 1, - "combined_line": 31855, + "combined_line": 31027, "original_file": "duk_bi_duktape.c" }, { "original_line": 1, - "combined_line": 32013, + "combined_line": 31185, "original_file": "duk_bi_encoding.c" }, { "original_line": 1, - "combined_line": 32551, + "combined_line": 31721, "original_file": "duk_bi_error.c" }, { "original_line": 1, - "combined_line": 32943, + "combined_line": 32113, "original_file": "duk_bi_function.c" }, { "original_line": 1, - "combined_line": 33396, + "combined_line": 32555, "original_file": "duk_bi_global.c" }, { "original_line": 1, - "combined_line": 34127, + "combined_line": 33283, "original_file": "duk_bi_json.c" }, { "original_line": 1, - "combined_line": 37396, + "combined_line": 36545, "original_file": "duk_bi_math.c" }, { "original_line": 1, - "combined_line": 37914, + "combined_line": 37063, "original_file": "duk_bi_number.c" }, { "original_line": 1, - "combined_line": 38194, + "combined_line": 37303, "original_file": "duk_bi_object.c" }, { "original_line": 1, - "combined_line": 38997, + "combined_line": 38108, "original_file": "duk_bi_performance.c" }, { "original_line": 1, - "combined_line": 39028, + "combined_line": 38139, "original_file": "duk_bi_pointer.c" }, { "original_line": 1, - "combined_line": 39103, + "combined_line": 38214, "original_file": "duk_bi_promise.c" }, { "original_line": 1, - "combined_line": 39147, + "combined_line": 38258, "original_file": "duk_bi_proxy.c" }, { "original_line": 1, - "combined_line": 39243, + "combined_line": 38353, "original_file": "duk_bi_reflect.c" }, { "original_line": 1, - "combined_line": 39342, + "combined_line": 38450, "original_file": "duk_bi_regexp.c" }, { "original_line": 1, - "combined_line": 39568, + "combined_line": 38676, "original_file": "duk_bi_string.c" }, { "original_line": 1, - "combined_line": 41148, + "combined_line": 40230, "original_file": "duk_bi_symbol.c" }, { "original_line": 1, - "combined_line": 41319, + "combined_line": 40400, "original_file": "duk_bi_thread.c" }, { "original_line": 1, - "combined_line": 41633, + "combined_line": 40712, "original_file": "duk_bi_thrower.c" }, { "original_line": 1, - "combined_line": 41642, + "combined_line": 40721, "original_file": "duk_debug_fixedbuffer.c" }, { "original_line": 1, - "combined_line": 41711, + "combined_line": 40790, "original_file": "duk_debug_vsnprintf.c" }, { "original_line": 1, - "combined_line": 42760, + "combined_line": 41838, "original_file": "duk_debugger.c" }, { "original_line": 1, - "combined_line": 45667, + "combined_line": 44745, "original_file": "duk_error_augment.c" }, { "original_line": 1, - "combined_line": 46229, + "combined_line": 45308, "original_file": "duk_error_longjmp.c" }, { "original_line": 1, - "combined_line": 46332, + "combined_line": 45414, "original_file": "duk_error_misc.c" }, { "original_line": 1, - "combined_line": 46506, + "combined_line": 45588, "original_file": "duk_error_throw.c" }, { "original_line": 1, - "combined_line": 46668, + "combined_line": 45750, "original_file": "duk_hbuffer_alloc.c" }, { "original_line": 1, - "combined_line": 46800, + "combined_line": 45882, "original_file": "duk_hbuffer_ops.c" }, { "original_line": 2, - "combined_line": 46879, + "combined_line": 45959, "original_file": "duk_hbufobj_misc.c" }, { "original_line": 1, - "combined_line": 46898, + "combined_line": 45978, "original_file": "duk_heap_alloc.c" }, { "original_line": 1, - "combined_line": 48119, + "combined_line": 47181, "original_file": "duk_heap_finalize.c" }, { "original_line": 1, - "combined_line": 48564, + "combined_line": 47626, "original_file": "duk_heap_hashstring.c" }, { "original_line": 1, - "combined_line": 48685, + "combined_line": 47747, "original_file": "duk_heap_markandsweep.c" }, { "original_line": 1, - "combined_line": 50123, + "combined_line": 49121, "original_file": "duk_heap_memory.c" }, { "original_line": 1, - "combined_line": 50488, + "combined_line": 49487, "original_file": "duk_heap_misc.c" }, { "original_line": 1, - "combined_line": 50669, + "combined_line": 49668, "original_file": "duk_heap_refcount.c" }, { "original_line": 1, - "combined_line": 51511, + "combined_line": 50510, "original_file": "duk_heap_stringcache.c" }, { "original_line": 1, - "combined_line": 51820, + "combined_line": 50819, "original_file": "duk_heap_stringtable.c" }, { "original_line": 1, - "combined_line": 52869, + "combined_line": 51808, "original_file": "duk_hobject_alloc.c" }, { "original_line": 1, - "combined_line": 53140, + "combined_line": 52078, "original_file": "duk_hobject_enum.c" }, { "original_line": 1, - "combined_line": 53842, + "combined_line": 52780, "original_file": "duk_hobject_misc.c" }, { "original_line": 1, - "combined_line": 53895, + "combined_line": 52832, "original_file": "duk_hobject_pc2line.c" }, { "original_line": 1, - "combined_line": 54139, + "combined_line": 53076, "original_file": "duk_hobject_props.c" }, { "original_line": 1, - "combined_line": 60255, + "combined_line": 59170, "original_file": "duk_hstring_misc.c" }, { "original_line": 1, - "combined_line": 60451, + "combined_line": 59366, "original_file": "duk_hthread_alloc.c" }, { "original_line": 1, - "combined_line": 60510, + "combined_line": 59425, "original_file": "duk_hthread_builtins.c" }, { "original_line": 1, - "combined_line": 61395, + "combined_line": 60299, "original_file": "duk_hthread_misc.c" }, { "original_line": 1, - "combined_line": 61492, + "combined_line": 60396, "original_file": "duk_hthread_stacks.c" }, { "original_line": 1, - "combined_line": 61899, + "combined_line": 60803, "original_file": "duk_js_arith.c" }, { "original_line": 1, - "combined_line": 62036, + "combined_line": 60940, "original_file": "duk_js_call.c" }, { "original_line": 1, - "combined_line": 64921, + "combined_line": 63802, "original_file": "duk_js_compiler.c" }, { "original_line": 1, - "combined_line": 73028, + "combined_line": 71836, "original_file": "duk_js_executor.c" }, { "original_line": 1, - "combined_line": 78248, + "combined_line": 77057, "original_file": "duk_js_ops.c" }, { "original_line": 1, - "combined_line": 79705, + "combined_line": 78488, "original_file": "duk_js_var.c" }, { "original_line": 1, - "combined_line": 81461, + "combined_line": 80241, "original_file": "duk_lexer.c" }, { "original_line": 1, - "combined_line": 83922, + "combined_line": 82700, "original_file": "duk_numconv.c" }, { "original_line": 1, - "combined_line": 86198, + "combined_line": 84976, "original_file": "duk_regexp_compiler.c" }, { "original_line": 1, - "combined_line": 87488, + "combined_line": 86258, "original_file": "duk_regexp_executor.c" }, { "original_line": 1, - "combined_line": 88514, + "combined_line": 87282, "original_file": "duk_selftest.c" }, { "original_line": 2, - "combined_line": 89159, + "combined_line": 87927, "original_file": "duk_tval.c" }, { "original_line": 1, - "combined_line": 89300, + "combined_line": 88068, "original_file": "duk_unicode_tables.c" }, { "original_line": 1, - "combined_line": 95466, + "combined_line": 94232, "original_file": "duk_util_bitdecoder.c" }, { "original_line": 1, - "combined_line": 95632, + "combined_line": 94398, "original_file": "duk_util_bitencoder.c" }, { "original_line": 1, - "combined_line": 95675, + "combined_line": 94441, "original_file": "duk_util_bufwriter.c" }, { "original_line": 1, - "combined_line": 96034, - "original_file": "duk_util_cast.c" - }, - { - "original_line": 1, - "combined_line": 96202, - "original_file": "duk_util_double.c" - }, - { - "original_line": 1, - "combined_line": 96436, + "combined_line": 94793, "original_file": "duk_util_hashbytes.c" }, { "original_line": 1, - "combined_line": 96497, - "original_file": "duk_util_memory.c" - }, - { - "original_line": 1, - "combined_line": 96533, + "combined_line": 94854, "original_file": "duk_util_tinyrandom.c" } ], - "duk_version": 20300, + "duk_version": 20200, "git_branch": "master", - "git_commit": "d7fdb67f18561a50e06bafd196c6b423af9ad6fe", + "git_commit": "a459cf3c9bd1779fc01b435d69302b742675a08f", "builtin_strings_info": [ { "plain": "Undefined", @@ -1079,26 +1059,6 @@ "define": "DUK_STRIDX_OWN_KEYS" }, { - "plain": "\u0081Symbol.toPrimitive\u00ff", - "base64": "gVN5bWJvbC50b1ByaW1pdGl2Zf8=", - "define": "DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE" - }, - { - "plain": "\u0081Symbol.hasInstance\u00ff", - "base64": "gVN5bWJvbC5oYXNJbnN0YW5jZf8=", - "define": "DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE" - }, - { - "plain": "\u0081Symbol.toStringTag\u00ff", - "base64": "gVN5bWJvbC50b1N0cmluZ1RhZ/8=", - "define": "DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG" - }, - { - "plain": "\u0081Symbol.isConcatSpreadable\u00ff", - "base64": "gVN5bWJvbC5pc0NvbmNhdFNwcmVhZGFibGX/", - "define": "DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE" - }, - { "plain": "setPrototypeOf", "base64": "c2V0UHJvdG90eXBlT2Y=", "define": "DUK_STRIDX_SET_PROTOTYPE_OF" @@ -1606,10 +1566,6 @@ "Z2V0", "aGFz", "b3duS2V5cw==", - "gVN5bWJvbC50b1ByaW1pdGl2Zf8=", - "gVN5bWJvbC5oYXNJbnN0YW5jZf8=", - "gVN5bWJvbC50b1N0cmluZ1RhZ/8=", - "gVN5bWJvbC5pc0NvbmNhdFNwcmVhZGFibGX/", "c2V0UHJvdG90eXBlT2Y=", "X19wcm90b19f", "dG9TdHJpbmc=", @@ -1697,7 +1653,7 @@ "c3RhdGlj", "eWllbGQ=" ], - "git_describe": "v2.3.0", + "git_describe": "v2.2.0", "builtin_strings": [ "Undefined", "Null", @@ -1775,10 +1731,6 @@ "get", "has", "ownKeys", - "\u0081Symbol.toPrimitive\u00ff", - "\u0081Symbol.hasInstance\u00ff", - "\u0081Symbol.toStringTag\u00ff", - "\u0081Symbol.isConcatSpreadable\u00ff", "setPrototypeOf", "__proto__", "toString", diff -Nru duktape-2.3.0/src-noline/duktape.c duktape-2.2.0/src-noline/duktape.c --- duktape-2.3.0/src-noline/duktape.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-noline/duktape.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,7 +1,7 @@ /* - * Single source autogenerated distributable for Duktape 2.3.0. + * Single source autogenerated distributable for Duktape 2.2.0. * - * Git commit d7fdb67f18561a50e06bafd196c6b423af9ad6fe (v2.3.0). + * Git commit a459cf3c9bd1779fc01b435d69302b742675a08f (v2.2.0). * Git branch master. * * See Duktape AUTHORS.rst and LICENSE.txt for copyright and @@ -16,7 +16,7 @@ * * (http://opensource.org/licenses/MIT) * -* Copyright (c) 2013-2018 by Duktape authors (see AUTHORS.rst) +* Copyright (c) 2013-2017 by Duktape authors (see AUTHORS.rst) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -87,14 +87,6 @@ * * Steven Don (https://github.com/shdon) * * Simon Stone (https://github.com/sstone1) * * \J. McC. (https://github.com/jmhmccr) -* * Jakub Nowakowski (https://github.com/jimvonmoon) -* * Tommy Nguyen (https://github.com/tn0502) -* * Fabrice Fontaine (https://github.com/ffontaine) -* * Christopher Hiller (https://github.com/boneskull) -* * Gonzalo Diethelm (https://github.com/gonzus) -* * Michal Kasperek (https://github.com/michalkas) -* * Andrew Janke (https://github.com/apjanke) -* * Steve Fan (https://github.com/stevefan1999) * * Other contributions * =================== @@ -133,8 +125,6 @@ * * https://github.com/chris-y * * Laurent Zubiaur (https://github.com/lzubiaur) * * Neil Kolban (https://github.com/nkolban) -* * Wilhelm Wanecek (https://github.com/wanecek) -* * Andrew Janke (https://github.com/apjanke) * * If you are accidentally missing from this list, send me an e-mail * (``sami.vaarala@iki.fi``) and I'll fix the omission. @@ -673,32 +663,20 @@ #endif /* DUK_JMPBUF_H_INCLUDED */ /* #include duk_exception.h */ /* - * Exceptions for Duktape internal throws when C++ exceptions are used + * Exception for Duktape internal throws when C++ exceptions are used * for long control transfers. + * + * Doesn't inherit from any exception base class to minimize the chance + * that user code would accidentally catch this exception. */ #if !defined(DUK_EXCEPTION_H_INCLUDED) #define DUK_EXCEPTION_H_INCLUDED #if defined(DUK_USE_CPP_EXCEPTIONS) -/* Internal exception used as a setjmp-longjmp replacement. User code should - * NEVER see or catch this exception, so it doesn't inherit from any base - * class which should minimize the chance of user code accidentally catching - * the exception. - */ class duk_internal_exception { /* intentionally empty */ }; - -/* Fatal error, thrown as a specific C++ exception with C++ exceptions - * enabled. It is unsafe to continue; doing so may cause crashes or memory - * leaks. This is intended to be either uncaught, or caught by user code - * aware of the "unsafe to continue" semantics. - */ -class duk_fatal_exception : public virtual std::runtime_error { - public: - duk_fatal_exception(const char *message) : std::runtime_error(message) {} -}; #endif #endif /* DUK_EXCEPTION_H_INCLUDED */ @@ -749,9 +727,8 @@ struct duk_activation; struct duk_catcher; +struct duk_strcache; struct duk_ljstate; -struct duk_strcache_entry; -struct duk_litcache_entry; struct duk_strtab_entry; #if defined(DUK_USE_DEBUG) @@ -810,9 +787,8 @@ typedef struct duk_activation duk_activation; typedef struct duk_catcher duk_catcher; +typedef struct duk_strcache duk_strcache; typedef struct duk_ljstate duk_ljstate; -typedef struct duk_strcache_entry duk_strcache_entry; -typedef struct duk_litcache_entry duk_litcache_entry; typedef struct duk_strtab_entry duk_strtab_entry; #if defined(DUK_USE_DEBUG) @@ -1709,290 +1685,278 @@ #define DUK_STRIDX_OWN_KEYS 75 /* 'ownKeys' */ #define DUK_HEAP_STRING_OWN_KEYS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_OWN_KEYS) #define DUK_HTHREAD_STRING_OWN_KEYS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_OWN_KEYS) -#define DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE 76 /* '\x81Symbol.toPrimitive\xff' */ -#define DUK_HEAP_STRING_WELLKNOWN_SYMBOL_TO_PRIMITIVE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE) -#define DUK_HTHREAD_STRING_WELLKNOWN_SYMBOL_TO_PRIMITIVE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE) -#define DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE 77 /* '\x81Symbol.hasInstance\xff' */ -#define DUK_HEAP_STRING_WELLKNOWN_SYMBOL_HAS_INSTANCE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE) -#define DUK_HTHREAD_STRING_WELLKNOWN_SYMBOL_HAS_INSTANCE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE) -#define DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG 78 /* '\x81Symbol.toStringTag\xff' */ -#define DUK_HEAP_STRING_WELLKNOWN_SYMBOL_TO_STRING_TAG(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG) -#define DUK_HTHREAD_STRING_WELLKNOWN_SYMBOL_TO_STRING_TAG(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG) -#define DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE 79 /* '\x81Symbol.isConcatSpreadable\xff' */ -#define DUK_HEAP_STRING_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE) -#define DUK_HTHREAD_STRING_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE) -#define DUK_STRIDX_SET_PROTOTYPE_OF 80 /* 'setPrototypeOf' */ +#define DUK_STRIDX_SET_PROTOTYPE_OF 76 /* 'setPrototypeOf' */ #define DUK_HEAP_STRING_SET_PROTOTYPE_OF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SET_PROTOTYPE_OF) #define DUK_HTHREAD_STRING_SET_PROTOTYPE_OF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SET_PROTOTYPE_OF) -#define DUK_STRIDX___PROTO__ 81 /* '__proto__' */ +#define DUK_STRIDX___PROTO__ 77 /* '__proto__' */ #define DUK_HEAP_STRING___PROTO__(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX___PROTO__) #define DUK_HTHREAD_STRING___PROTO__(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX___PROTO__) -#define DUK_STRIDX_TO_STRING 82 /* 'toString' */ +#define DUK_STRIDX_TO_STRING 78 /* 'toString' */ #define DUK_HEAP_STRING_TO_STRING(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_STRING) #define DUK_HTHREAD_STRING_TO_STRING(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_STRING) -#define DUK_STRIDX_TO_JSON 83 /* 'toJSON' */ +#define DUK_STRIDX_TO_JSON 79 /* 'toJSON' */ #define DUK_HEAP_STRING_TO_JSON(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_JSON) #define DUK_HTHREAD_STRING_TO_JSON(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_JSON) -#define DUK_STRIDX_TYPE 84 /* 'type' */ +#define DUK_STRIDX_TYPE 80 /* 'type' */ #define DUK_HEAP_STRING_TYPE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TYPE) #define DUK_HTHREAD_STRING_TYPE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TYPE) -#define DUK_STRIDX_DATA 85 /* 'data' */ +#define DUK_STRIDX_DATA 81 /* 'data' */ #define DUK_HEAP_STRING_DATA(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DATA) #define DUK_HTHREAD_STRING_DATA(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DATA) -#define DUK_STRIDX_LENGTH 86 /* 'length' */ +#define DUK_STRIDX_LENGTH 82 /* 'length' */ #define DUK_HEAP_STRING_LENGTH(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LENGTH) #define DUK_HTHREAD_STRING_LENGTH(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LENGTH) -#define DUK_STRIDX_SET 87 /* 'set' */ +#define DUK_STRIDX_SET 83 /* 'set' */ #define DUK_HEAP_STRING_SET(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SET) #define DUK_HTHREAD_STRING_SET(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SET) -#define DUK_STRIDX_STACK 88 /* 'stack' */ +#define DUK_STRIDX_STACK 84 /* 'stack' */ #define DUK_HEAP_STRING_STACK(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_STACK) #define DUK_HTHREAD_STRING_STACK(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_STACK) -#define DUK_STRIDX_PC 89 /* 'pc' */ +#define DUK_STRIDX_PC 85 /* 'pc' */ #define DUK_HEAP_STRING_PC(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PC) #define DUK_HTHREAD_STRING_PC(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PC) -#define DUK_STRIDX_LINE_NUMBER 90 /* 'lineNumber' */ +#define DUK_STRIDX_LINE_NUMBER 86 /* 'lineNumber' */ #define DUK_HEAP_STRING_LINE_NUMBER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LINE_NUMBER) #define DUK_HTHREAD_STRING_LINE_NUMBER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LINE_NUMBER) -#define DUK_STRIDX_INT_TRACEDATA 91 /* '\x82Tracedata' */ +#define DUK_STRIDX_INT_TRACEDATA 87 /* '\x82Tracedata' */ #define DUK_HEAP_STRING_INT_TRACEDATA(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_TRACEDATA) #define DUK_HTHREAD_STRING_INT_TRACEDATA(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_TRACEDATA) -#define DUK_STRIDX_NAME 92 /* 'name' */ +#define DUK_STRIDX_NAME 88 /* 'name' */ #define DUK_HEAP_STRING_NAME(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NAME) #define DUK_HTHREAD_STRING_NAME(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NAME) -#define DUK_STRIDX_FILE_NAME 93 /* 'fileName' */ +#define DUK_STRIDX_FILE_NAME 89 /* 'fileName' */ #define DUK_HEAP_STRING_FILE_NAME(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FILE_NAME) #define DUK_HTHREAD_STRING_FILE_NAME(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FILE_NAME) -#define DUK_STRIDX_LC_POINTER 94 /* 'pointer' */ +#define DUK_STRIDX_LC_POINTER 90 /* 'pointer' */ #define DUK_HEAP_STRING_LC_POINTER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_POINTER) #define DUK_HTHREAD_STRING_LC_POINTER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_POINTER) -#define DUK_STRIDX_INT_TARGET 95 /* '\x82Target' */ +#define DUK_STRIDX_INT_TARGET 91 /* '\x82Target' */ #define DUK_HEAP_STRING_INT_TARGET(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_TARGET) #define DUK_HTHREAD_STRING_INT_TARGET(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_TARGET) -#define DUK_STRIDX_INT_NEXT 96 /* '\x82Next' */ +#define DUK_STRIDX_INT_NEXT 92 /* '\x82Next' */ #define DUK_HEAP_STRING_INT_NEXT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_NEXT) #define DUK_HTHREAD_STRING_INT_NEXT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_NEXT) -#define DUK_STRIDX_INT_BYTECODE 97 /* '\x82Bytecode' */ +#define DUK_STRIDX_INT_BYTECODE 93 /* '\x82Bytecode' */ #define DUK_HEAP_STRING_INT_BYTECODE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_BYTECODE) #define DUK_HTHREAD_STRING_INT_BYTECODE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_BYTECODE) -#define DUK_STRIDX_INT_FORMALS 98 /* '\x82Formals' */ +#define DUK_STRIDX_INT_FORMALS 94 /* '\x82Formals' */ #define DUK_HEAP_STRING_INT_FORMALS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_FORMALS) #define DUK_HTHREAD_STRING_INT_FORMALS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_FORMALS) -#define DUK_STRIDX_INT_VARMAP 99 /* '\x82Varmap' */ +#define DUK_STRIDX_INT_VARMAP 95 /* '\x82Varmap' */ #define DUK_HEAP_STRING_INT_VARMAP(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VARMAP) #define DUK_HTHREAD_STRING_INT_VARMAP(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VARMAP) -#define DUK_STRIDX_INT_SOURCE 100 /* '\x82Source' */ +#define DUK_STRIDX_INT_SOURCE 96 /* '\x82Source' */ #define DUK_HEAP_STRING_INT_SOURCE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_SOURCE) #define DUK_HTHREAD_STRING_INT_SOURCE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_SOURCE) -#define DUK_STRIDX_INT_PC2LINE 101 /* '\x82Pc2line' */ +#define DUK_STRIDX_INT_PC2LINE 97 /* '\x82Pc2line' */ #define DUK_HEAP_STRING_INT_PC2LINE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_PC2LINE) #define DUK_HTHREAD_STRING_INT_PC2LINE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_PC2LINE) -#define DUK_STRIDX_INT_MAP 102 /* '\x82Map' */ +#define DUK_STRIDX_INT_MAP 98 /* '\x82Map' */ #define DUK_HEAP_STRING_INT_MAP(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_MAP) #define DUK_HTHREAD_STRING_INT_MAP(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_MAP) -#define DUK_STRIDX_INT_VARENV 103 /* '\x82Varenv' */ +#define DUK_STRIDX_INT_VARENV 99 /* '\x82Varenv' */ #define DUK_HEAP_STRING_INT_VARENV(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VARENV) #define DUK_HTHREAD_STRING_INT_VARENV(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VARENV) -#define DUK_STRIDX_INT_FINALIZER 104 /* '\x82Finalizer' */ +#define DUK_STRIDX_INT_FINALIZER 100 /* '\x82Finalizer' */ #define DUK_HEAP_STRING_INT_FINALIZER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_FINALIZER) #define DUK_HTHREAD_STRING_INT_FINALIZER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_FINALIZER) -#define DUK_STRIDX_INT_VALUE 105 /* '\x82Value' */ +#define DUK_STRIDX_INT_VALUE 101 /* '\x82Value' */ #define DUK_HEAP_STRING_INT_VALUE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VALUE) #define DUK_HTHREAD_STRING_INT_VALUE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VALUE) -#define DUK_STRIDX_COMPILE 106 /* 'compile' */ +#define DUK_STRIDX_COMPILE 102 /* 'compile' */ #define DUK_HEAP_STRING_COMPILE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_COMPILE) #define DUK_HTHREAD_STRING_COMPILE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_COMPILE) -#define DUK_STRIDX_INPUT 107 /* 'input' */ +#define DUK_STRIDX_INPUT 103 /* 'input' */ #define DUK_HEAP_STRING_INPUT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INPUT) #define DUK_HTHREAD_STRING_INPUT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INPUT) -#define DUK_STRIDX_ERR_CREATE 108 /* 'errCreate' */ +#define DUK_STRIDX_ERR_CREATE 104 /* 'errCreate' */ #define DUK_HEAP_STRING_ERR_CREATE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ERR_CREATE) #define DUK_HTHREAD_STRING_ERR_CREATE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ERR_CREATE) -#define DUK_STRIDX_ERR_THROW 109 /* 'errThrow' */ +#define DUK_STRIDX_ERR_THROW 105 /* 'errThrow' */ #define DUK_HEAP_STRING_ERR_THROW(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ERR_THROW) #define DUK_HTHREAD_STRING_ERR_THROW(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ERR_THROW) -#define DUK_STRIDX_ENV 110 /* 'env' */ +#define DUK_STRIDX_ENV 106 /* 'env' */ #define DUK_HEAP_STRING_ENV(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENV) #define DUK_HTHREAD_STRING_ENV(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENV) -#define DUK_STRIDX_HEX 111 /* 'hex' */ +#define DUK_STRIDX_HEX 107 /* 'hex' */ #define DUK_HEAP_STRING_HEX(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_HEX) #define DUK_HTHREAD_STRING_HEX(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_HEX) -#define DUK_STRIDX_BASE64 112 /* 'base64' */ +#define DUK_STRIDX_BASE64 108 /* 'base64' */ #define DUK_HEAP_STRING_BASE64(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BASE64) #define DUK_HTHREAD_STRING_BASE64(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BASE64) -#define DUK_STRIDX_JX 113 /* 'jx' */ +#define DUK_STRIDX_JX 109 /* 'jx' */ #define DUK_HEAP_STRING_JX(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JX) #define DUK_HTHREAD_STRING_JX(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JX) -#define DUK_STRIDX_JC 114 /* 'jc' */ +#define DUK_STRIDX_JC 110 /* 'jc' */ #define DUK_HEAP_STRING_JC(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JC) #define DUK_HTHREAD_STRING_JC(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JC) -#define DUK_STRIDX_JSON_EXT_UNDEFINED 115 /* '{"_undef":true}' */ +#define DUK_STRIDX_JSON_EXT_UNDEFINED 111 /* '{"_undef":true}' */ #define DUK_HEAP_STRING_JSON_EXT_UNDEFINED(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_UNDEFINED) #define DUK_HTHREAD_STRING_JSON_EXT_UNDEFINED(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_UNDEFINED) -#define DUK_STRIDX_JSON_EXT_NAN 116 /* '{"_nan":true}' */ +#define DUK_STRIDX_JSON_EXT_NAN 112 /* '{"_nan":true}' */ #define DUK_HEAP_STRING_JSON_EXT_NAN(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_NAN) #define DUK_HTHREAD_STRING_JSON_EXT_NAN(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_NAN) -#define DUK_STRIDX_JSON_EXT_POSINF 117 /* '{"_inf":true}' */ +#define DUK_STRIDX_JSON_EXT_POSINF 113 /* '{"_inf":true}' */ #define DUK_HEAP_STRING_JSON_EXT_POSINF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_POSINF) #define DUK_HTHREAD_STRING_JSON_EXT_POSINF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_POSINF) -#define DUK_STRIDX_JSON_EXT_NEGINF 118 /* '{"_ninf":true}' */ +#define DUK_STRIDX_JSON_EXT_NEGINF 114 /* '{"_ninf":true}' */ #define DUK_HEAP_STRING_JSON_EXT_NEGINF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_NEGINF) #define DUK_HTHREAD_STRING_JSON_EXT_NEGINF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_NEGINF) -#define DUK_STRIDX_JSON_EXT_FUNCTION1 119 /* '{"_func":true}' */ +#define DUK_STRIDX_JSON_EXT_FUNCTION1 115 /* '{"_func":true}' */ #define DUK_HEAP_STRING_JSON_EXT_FUNCTION1(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_FUNCTION1) #define DUK_HTHREAD_STRING_JSON_EXT_FUNCTION1(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_FUNCTION1) -#define DUK_STRIDX_JSON_EXT_FUNCTION2 120 /* '{_func:true}' */ +#define DUK_STRIDX_JSON_EXT_FUNCTION2 116 /* '{_func:true}' */ #define DUK_HEAP_STRING_JSON_EXT_FUNCTION2(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_FUNCTION2) #define DUK_HTHREAD_STRING_JSON_EXT_FUNCTION2(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_FUNCTION2) -#define DUK_STRIDX_BREAK 121 /* 'break' */ +#define DUK_STRIDX_BREAK 117 /* 'break' */ #define DUK_HEAP_STRING_BREAK(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BREAK) #define DUK_HTHREAD_STRING_BREAK(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BREAK) -#define DUK_STRIDX_CASE 122 /* 'case' */ +#define DUK_STRIDX_CASE 118 /* 'case' */ #define DUK_HEAP_STRING_CASE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CASE) #define DUK_HTHREAD_STRING_CASE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CASE) -#define DUK_STRIDX_CATCH 123 /* 'catch' */ +#define DUK_STRIDX_CATCH 119 /* 'catch' */ #define DUK_HEAP_STRING_CATCH(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CATCH) #define DUK_HTHREAD_STRING_CATCH(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CATCH) -#define DUK_STRIDX_CONTINUE 124 /* 'continue' */ +#define DUK_STRIDX_CONTINUE 120 /* 'continue' */ #define DUK_HEAP_STRING_CONTINUE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONTINUE) #define DUK_HTHREAD_STRING_CONTINUE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONTINUE) -#define DUK_STRIDX_DEBUGGER 125 /* 'debugger' */ +#define DUK_STRIDX_DEBUGGER 121 /* 'debugger' */ #define DUK_HEAP_STRING_DEBUGGER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEBUGGER) #define DUK_HTHREAD_STRING_DEBUGGER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEBUGGER) -#define DUK_STRIDX_DEFAULT 126 /* 'default' */ +#define DUK_STRIDX_DEFAULT 122 /* 'default' */ #define DUK_HEAP_STRING_DEFAULT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEFAULT) #define DUK_HTHREAD_STRING_DEFAULT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEFAULT) -#define DUK_STRIDX_DELETE 127 /* 'delete' */ +#define DUK_STRIDX_DELETE 123 /* 'delete' */ #define DUK_HEAP_STRING_DELETE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DELETE) #define DUK_HTHREAD_STRING_DELETE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DELETE) -#define DUK_STRIDX_DO 128 /* 'do' */ +#define DUK_STRIDX_DO 124 /* 'do' */ #define DUK_HEAP_STRING_DO(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DO) #define DUK_HTHREAD_STRING_DO(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DO) -#define DUK_STRIDX_ELSE 129 /* 'else' */ +#define DUK_STRIDX_ELSE 125 /* 'else' */ #define DUK_HEAP_STRING_ELSE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ELSE) #define DUK_HTHREAD_STRING_ELSE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ELSE) -#define DUK_STRIDX_FINALLY 130 /* 'finally' */ +#define DUK_STRIDX_FINALLY 126 /* 'finally' */ #define DUK_HEAP_STRING_FINALLY(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FINALLY) #define DUK_HTHREAD_STRING_FINALLY(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FINALLY) -#define DUK_STRIDX_FOR 131 /* 'for' */ +#define DUK_STRIDX_FOR 127 /* 'for' */ #define DUK_HEAP_STRING_FOR(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FOR) #define DUK_HTHREAD_STRING_FOR(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FOR) -#define DUK_STRIDX_LC_FUNCTION 132 /* 'function' */ +#define DUK_STRIDX_LC_FUNCTION 128 /* 'function' */ #define DUK_HEAP_STRING_LC_FUNCTION(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_FUNCTION) #define DUK_HTHREAD_STRING_LC_FUNCTION(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_FUNCTION) -#define DUK_STRIDX_IF 133 /* 'if' */ +#define DUK_STRIDX_IF 129 /* 'if' */ #define DUK_HEAP_STRING_IF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IF) #define DUK_HTHREAD_STRING_IF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IF) -#define DUK_STRIDX_IN 134 /* 'in' */ +#define DUK_STRIDX_IN 130 /* 'in' */ #define DUK_HEAP_STRING_IN(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IN) #define DUK_HTHREAD_STRING_IN(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IN) -#define DUK_STRIDX_INSTANCEOF 135 /* 'instanceof' */ +#define DUK_STRIDX_INSTANCEOF 131 /* 'instanceof' */ #define DUK_HEAP_STRING_INSTANCEOF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INSTANCEOF) #define DUK_HTHREAD_STRING_INSTANCEOF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INSTANCEOF) -#define DUK_STRIDX_NEW 136 /* 'new' */ +#define DUK_STRIDX_NEW 132 /* 'new' */ #define DUK_HEAP_STRING_NEW(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NEW) #define DUK_HTHREAD_STRING_NEW(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NEW) -#define DUK_STRIDX_RETURN 137 /* 'return' */ +#define DUK_STRIDX_RETURN 133 /* 'return' */ #define DUK_HEAP_STRING_RETURN(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_RETURN) #define DUK_HTHREAD_STRING_RETURN(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_RETURN) -#define DUK_STRIDX_SWITCH 138 /* 'switch' */ +#define DUK_STRIDX_SWITCH 134 /* 'switch' */ #define DUK_HEAP_STRING_SWITCH(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SWITCH) #define DUK_HTHREAD_STRING_SWITCH(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SWITCH) -#define DUK_STRIDX_THIS 139 /* 'this' */ +#define DUK_STRIDX_THIS 135 /* 'this' */ #define DUK_HEAP_STRING_THIS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_THIS) #define DUK_HTHREAD_STRING_THIS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_THIS) -#define DUK_STRIDX_THROW 140 /* 'throw' */ +#define DUK_STRIDX_THROW 136 /* 'throw' */ #define DUK_HEAP_STRING_THROW(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_THROW) #define DUK_HTHREAD_STRING_THROW(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_THROW) -#define DUK_STRIDX_TRY 141 /* 'try' */ +#define DUK_STRIDX_TRY 137 /* 'try' */ #define DUK_HEAP_STRING_TRY(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TRY) #define DUK_HTHREAD_STRING_TRY(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TRY) -#define DUK_STRIDX_TYPEOF 142 /* 'typeof' */ +#define DUK_STRIDX_TYPEOF 138 /* 'typeof' */ #define DUK_HEAP_STRING_TYPEOF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TYPEOF) #define DUK_HTHREAD_STRING_TYPEOF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TYPEOF) -#define DUK_STRIDX_VAR 143 /* 'var' */ +#define DUK_STRIDX_VAR 139 /* 'var' */ #define DUK_HEAP_STRING_VAR(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VAR) #define DUK_HTHREAD_STRING_VAR(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VAR) -#define DUK_STRIDX_CONST 144 /* 'const' */ +#define DUK_STRIDX_CONST 140 /* 'const' */ #define DUK_HEAP_STRING_CONST(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONST) #define DUK_HTHREAD_STRING_CONST(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONST) -#define DUK_STRIDX_VOID 145 /* 'void' */ +#define DUK_STRIDX_VOID 141 /* 'void' */ #define DUK_HEAP_STRING_VOID(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VOID) #define DUK_HTHREAD_STRING_VOID(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VOID) -#define DUK_STRIDX_WHILE 146 /* 'while' */ +#define DUK_STRIDX_WHILE 142 /* 'while' */ #define DUK_HEAP_STRING_WHILE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WHILE) #define DUK_HTHREAD_STRING_WHILE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WHILE) -#define DUK_STRIDX_WITH 147 /* 'with' */ +#define DUK_STRIDX_WITH 143 /* 'with' */ #define DUK_HEAP_STRING_WITH(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WITH) #define DUK_HTHREAD_STRING_WITH(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WITH) -#define DUK_STRIDX_CLASS 148 /* 'class' */ +#define DUK_STRIDX_CLASS 144 /* 'class' */ #define DUK_HEAP_STRING_CLASS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CLASS) #define DUK_HTHREAD_STRING_CLASS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CLASS) -#define DUK_STRIDX_ENUM 149 /* 'enum' */ +#define DUK_STRIDX_ENUM 145 /* 'enum' */ #define DUK_HEAP_STRING_ENUM(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENUM) #define DUK_HTHREAD_STRING_ENUM(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENUM) -#define DUK_STRIDX_EXPORT 150 /* 'export' */ +#define DUK_STRIDX_EXPORT 146 /* 'export' */ #define DUK_HEAP_STRING_EXPORT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EXPORT) #define DUK_HTHREAD_STRING_EXPORT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EXPORT) -#define DUK_STRIDX_EXTENDS 151 /* 'extends' */ +#define DUK_STRIDX_EXTENDS 147 /* 'extends' */ #define DUK_HEAP_STRING_EXTENDS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EXTENDS) #define DUK_HTHREAD_STRING_EXTENDS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EXTENDS) -#define DUK_STRIDX_IMPORT 152 /* 'import' */ +#define DUK_STRIDX_IMPORT 148 /* 'import' */ #define DUK_HEAP_STRING_IMPORT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IMPORT) #define DUK_HTHREAD_STRING_IMPORT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IMPORT) -#define DUK_STRIDX_SUPER 153 /* 'super' */ +#define DUK_STRIDX_SUPER 149 /* 'super' */ #define DUK_HEAP_STRING_SUPER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SUPER) #define DUK_HTHREAD_STRING_SUPER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SUPER) -#define DUK_STRIDX_LC_NULL 154 /* 'null' */ +#define DUK_STRIDX_LC_NULL 150 /* 'null' */ #define DUK_HEAP_STRING_LC_NULL(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_NULL) #define DUK_HTHREAD_STRING_LC_NULL(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_NULL) -#define DUK_STRIDX_TRUE 155 /* 'true' */ +#define DUK_STRIDX_TRUE 151 /* 'true' */ #define DUK_HEAP_STRING_TRUE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TRUE) #define DUK_HTHREAD_STRING_TRUE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TRUE) -#define DUK_STRIDX_FALSE 156 /* 'false' */ +#define DUK_STRIDX_FALSE 152 /* 'false' */ #define DUK_HEAP_STRING_FALSE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FALSE) #define DUK_HTHREAD_STRING_FALSE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FALSE) -#define DUK_STRIDX_IMPLEMENTS 157 /* 'implements' */ +#define DUK_STRIDX_IMPLEMENTS 153 /* 'implements' */ #define DUK_HEAP_STRING_IMPLEMENTS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IMPLEMENTS) #define DUK_HTHREAD_STRING_IMPLEMENTS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IMPLEMENTS) -#define DUK_STRIDX_INTERFACE 158 /* 'interface' */ +#define DUK_STRIDX_INTERFACE 154 /* 'interface' */ #define DUK_HEAP_STRING_INTERFACE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INTERFACE) #define DUK_HTHREAD_STRING_INTERFACE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INTERFACE) -#define DUK_STRIDX_LET 159 /* 'let' */ +#define DUK_STRIDX_LET 155 /* 'let' */ #define DUK_HEAP_STRING_LET(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LET) #define DUK_HTHREAD_STRING_LET(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LET) -#define DUK_STRIDX_PACKAGE 160 /* 'package' */ +#define DUK_STRIDX_PACKAGE 156 /* 'package' */ #define DUK_HEAP_STRING_PACKAGE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PACKAGE) #define DUK_HTHREAD_STRING_PACKAGE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PACKAGE) -#define DUK_STRIDX_PRIVATE 161 /* 'private' */ +#define DUK_STRIDX_PRIVATE 157 /* 'private' */ #define DUK_HEAP_STRING_PRIVATE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PRIVATE) #define DUK_HTHREAD_STRING_PRIVATE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PRIVATE) -#define DUK_STRIDX_PROTECTED 162 /* 'protected' */ +#define DUK_STRIDX_PROTECTED 158 /* 'protected' */ #define DUK_HEAP_STRING_PROTECTED(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PROTECTED) #define DUK_HTHREAD_STRING_PROTECTED(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PROTECTED) -#define DUK_STRIDX_PUBLIC 163 /* 'public' */ +#define DUK_STRIDX_PUBLIC 159 /* 'public' */ #define DUK_HEAP_STRING_PUBLIC(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PUBLIC) #define DUK_HTHREAD_STRING_PUBLIC(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PUBLIC) -#define DUK_STRIDX_STATIC 164 /* 'static' */ +#define DUK_STRIDX_STATIC 160 /* 'static' */ #define DUK_HEAP_STRING_STATIC(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_STATIC) #define DUK_HTHREAD_STRING_STATIC(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_STATIC) -#define DUK_STRIDX_YIELD 165 /* 'yield' */ +#define DUK_STRIDX_YIELD 161 /* 'yield' */ #define DUK_HEAP_STRING_YIELD(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_YIELD) #define DUK_HTHREAD_STRING_YIELD(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_YIELD) -#define DUK_HEAP_NUM_STRINGS 166 -#define DUK_STRIDX_START_RESERVED 121 -#define DUK_STRIDX_START_STRICT_RESERVED 157 -#define DUK_STRIDX_END_RESERVED 166 /* exclusive endpoint */ +#define DUK_HEAP_NUM_STRINGS 162 +#define DUK_STRIDX_START_RESERVED 117 +#define DUK_STRIDX_START_STRICT_RESERVED 153 +#define DUK_STRIDX_END_RESERVED 162 /* exclusive endpoint */ /* To convert a heap stridx to a token number, subtract * DUK_STRIDX_START_RESERVED and add DUK_TOK_START_RESERVED. */ #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_strings_data[967]; +DUK_INTERNAL_DECL const duk_uint8_t duk_strings_data[892]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_STRDATA_MAX_STRLEN 27 -#define DUK_STRDATA_DATA_LENGTH 967 +#define DUK_STRDATA_MAX_STRLEN 17 +#define DUK_STRDATA_DATA_LENGTH 892 #endif /* DUK_USE_ROM_STRINGS */ #if defined(DUK_USE_ROM_OBJECTS) @@ -2009,8 +1973,6 @@ DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_error_constructor_shared(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_type_error_thrower(duk_context *ctx); -DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_int(duk_context *ctx); -DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_float(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_thread_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_pointer_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_proxy_constructor(duk_context *ctx); @@ -2021,6 +1983,8 @@ DUK_INTERNAL_DECL duk_ret_t duk_bi_textencoder_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_textdecoder_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_eval(duk_context *ctx); +DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_int(duk_context *ctx); +DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_float(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_is_nan(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_is_finite(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_decode_uri(duk_context *ctx); @@ -2092,7 +2056,6 @@ DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_includes(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_substr(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_boolean_prototype_tostring_shared(duk_context *ctx); -DUK_INTERNAL_DECL duk_ret_t duk_bi_number_check_shared(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_string(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_locale_string(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_value_of(duk_context *ctx); @@ -2175,7 +2138,7 @@ DUK_INTERNAL_DECL duk_ret_t duk_bi_textdecoder_prototype_decode(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_performance_now(duk_context *ctx); #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_c_function duk_bi_native_functions[177]; +DUK_INTERNAL_DECL const duk_c_function duk_bi_native_functions[176]; #endif /* !DUK_SINGLE_FILE */ #define DUK_BIDX_GLOBAL 0 #define DUK_BIDX_GLOBAL_ENV 1 @@ -2230,22 +2193,22 @@ #define DUK_BIDX_NODEJS_BUFFER_PROTOTYPE 50 #define DUK_NUM_BUILTINS 51 #define DUK_NUM_BIDX_BUILTINS 51 -#define DUK_NUM_ALL_BUILTINS 78 +#define DUK_NUM_ALL_BUILTINS 76 #if defined(DUK_USE_DOUBLE_LE) #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4116]; +DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[3972]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_BUILTINS_DATA_LENGTH 4116 +#define DUK_BUILTINS_DATA_LENGTH 3972 #elif defined(DUK_USE_DOUBLE_BE) #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4116]; +DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[3972]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_BUILTINS_DATA_LENGTH 4116 +#define DUK_BUILTINS_DATA_LENGTH 3972 #elif defined(DUK_USE_DOUBLE_ME) #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4116]; +DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[3972]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_BUILTINS_DATA_LENGTH 4116 +#define DUK_BUILTINS_DATA_LENGTH 3972 #else #error invalid endianness defines #endif @@ -2570,13 +2533,12 @@ (bw_ctx)->p += duk__enc_len; \ } while (0) /* XXX: add temporary duk__p pointer here too; sharing */ -/* XXX: avoid unsafe variants */ #define DUK_BW_WRITE_RAW_BYTES(thr,bw_ctx,valptr,valsz) do { \ const void *duk__valptr; \ duk_size_t duk__valsz; \ duk__valptr = (const void *) (valptr); \ duk__valsz = (duk_size_t) (valsz); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ (bw_ctx)->p += duk__valsz; \ } while (0) #define DUK_BW_WRITE_RAW_CSTRING(thr,bw_ctx,val) do { \ @@ -2584,31 +2546,31 @@ duk_size_t duk__val_len; \ duk__val = (const duk_uint8_t *) (val); \ duk__val_len = DUK_STRLEN((const char *) duk__val); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HSTRING(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HSTRING_GET_BYTELEN((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HBUFFER(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_GET_SIZE((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HBUFFER_FIXED(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_FIXED_GET_SIZE((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HBUFFER_DYNAMIC(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_DYNAMIC_GET_SIZE((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) @@ -2672,14 +2634,13 @@ DUK_BW_WRITE_RAW_CESU8((thr), (bw_ctx), (cp)); \ } while (0) /* XXX: add temporary duk__p pointer here too; sharing */ -/* XXX: avoid unsafe */ #define DUK_BW_WRITE_ENSURE_BYTES(thr,bw_ctx,valptr,valsz) do { \ const void *duk__valptr; \ duk_size_t duk__valsz; \ duk__valptr = (const void *) (valptr); \ duk__valsz = (duk_size_t) (valsz); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__valsz); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ (bw_ctx)->p += duk__valsz; \ } while (0) #define DUK_BW_WRITE_ENSURE_CSTRING(thr,bw_ctx,val) do { \ @@ -2688,35 +2649,35 @@ duk__val = (const duk_uint8_t *) (val); \ duk__val_len = DUK_STRLEN((const char *) duk__val); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HSTRING(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HSTRING_GET_BYTELEN((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HBUFFER(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_GET_SIZE((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HBUFFER_FIXED(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_FIXED_GET_SIZE((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HBUFFER_DYNAMIC(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_DYNAMIC_GET_SIZE((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) @@ -2745,6 +2706,10 @@ DUK_INTERNAL_DECL const duk_int16_t duk_hex_dectab_shift4[256]; DUK_INTERNAL_DECL const duk_uint16_t duk_hex_enctab[256]; #endif +#if defined(DUK_USE_BASE64_FASTPATH) +DUK_INTERNAL_DECL const duk_uint8_t duk_base64_enctab[64]; +DUK_INTERNAL_DECL const duk_int8_t duk_base64_dectab[256]; +#endif #endif /* !DUK_SINGLE_FILE */ /* Note: assumes that duk_util_probe_steps size is 32 */ @@ -2799,127 +2764,6 @@ DUK_INTERNAL_DECL void duk_byteswap_bytes(duk_uint8_t *p, duk_small_uint_t len); #endif -/* memcpy(), memmove() etc wrappers. The plain variants like duk_memcpy() - * assume C99+ and 'src' and 'dst' pointers must be non-NULL even when the - * operation size is zero. The unsafe variants like duk_memcpy_safe() deal - * with the zero size case explicitly, and allow NULL pointers in that case - * (which is undefined behavior in C99+). For the majority of actual targets - * a NULL pointer with a zero length is fine in practice. These wrappers are - * macros to force inlining; because there are hundreds of call sites, even a - * few extra bytes per call site adds up to ~1kB footprint. - */ -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) -#define duk_memcpy(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - (void) DUK_MEMCPY(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memcpy_unsafe(dst,src,len) duk_memcpy((dst), (src), (len)) -#define duk_memmove(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - (void) DUK_MEMMOVE(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memmove_unsafe(dst,src,len) duk_memmove((dst), (src), (len)) -#define duk_memset(dst,val,len) do { \ - void *duk__dst = (dst); \ - duk_small_int_t duk__val = (val); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - (void) DUK_MEMSET(duk__dst, duk__val, (size_t) duk__len); \ - } while (0) -#define duk_memset_unsafe(dst,val,len) duk_memset((dst), (val), (len)) -#define duk_memzero(dst,len) do { \ - void *duk__dst = (dst); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - (void) DUK_MEMZERO(duk__dst, (size_t) duk__len); \ - } while (0) -#define duk_memzero_unsafe(dst,len) duk_memzero((dst), (len)) -#else /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ -#define duk_memcpy(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMCPY(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memcpy_unsafe(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMCPY(duk__dst, duk__src, (size_t) duk__len); \ - } \ - } while (0) -#define duk_memmove(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMMOVE(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memmove_unsafe(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMMOVE(duk__dst, duk__src, (size_t) duk__len); \ - } \ - } while (0) -#define duk_memset(dst,val,len) do { \ - void *duk__dst = (dst); \ - duk_small_int_t duk__val = (val); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMSET(duk__dst, duk__val, (size_t) duk__len); \ - } while (0) -#define duk_memset_unsafe(dst,val,len) do { \ - void *duk__dst = (dst); \ - duk_small_int_t duk__val = (val); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMSET(duk__dst, duk__val, (size_t) duk__len); \ - } \ - } while (0) -#define duk_memzero(dst,len) do { \ - void *duk__dst = (dst); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMZERO(duk__dst, (size_t) duk__len); \ - } while (0) -#define duk_memzero_unsafe(dst,len) do { \ - void *duk__dst = (dst); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMZERO(duk__dst, (size_t) duk__len); \ - } \ - } while (0) -#endif /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ - -DUK_INTERNAL_DECL duk_small_int_t duk_memcmp(const void *s1, const void *s2, duk_size_t len); -DUK_INTERNAL_DECL duk_small_int_t duk_memcmp_unsafe(const void *s1, const void *s2, duk_size_t len); - DUK_INTERNAL_DECL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int32_t *ival); DUK_INTERNAL_DECL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival); DUK_INTERNAL_DECL duk_bool_t duk_double_is_anyinf(duk_double_t x); @@ -2934,33 +2778,6 @@ DUK_INTERNAL_DECL duk_bool_t duk_double_same_sign(duk_double_t x, duk_double_t y); DUK_INTERNAL_DECL duk_double_t duk_double_fmin(duk_double_t x, duk_double_t y); DUK_INTERNAL_DECL duk_double_t duk_double_fmax(duk_double_t x, duk_double_t y); -DUK_INTERNAL_DECL duk_bool_t duk_double_is_finite(duk_double_t x); -DUK_INTERNAL_DECL duk_bool_t duk_double_is_integer(duk_double_t x); -DUK_INTERNAL_DECL duk_bool_t duk_double_is_safe_integer(duk_double_t x); - -DUK_INTERNAL_DECL duk_double_t duk_double_div(duk_double_t x, duk_double_t y); -DUK_INTERNAL_DECL duk_int_t duk_double_to_int_t(duk_double_t x); -DUK_INTERNAL_DECL duk_uint_t duk_double_to_uint_t(duk_double_t x); -DUK_INTERNAL_DECL duk_int32_t duk_double_to_int32_t(duk_double_t x); -DUK_INTERNAL_DECL duk_uint32_t duk_double_to_uint32_t(duk_double_t x); -DUK_INTERNAL_DECL duk_float_t duk_double_to_float_t(duk_double_t x); - -/* - * Miscellaneous - */ - -/* Example: x = 0x10 = 0b00010000 - * x - 1 = 0x0f = 0b00001111 - * x & (x - 1) == 0 - * - * x = 0x07 = 0b00000111 - * x - 1 = 0x06 = 0b00000110 - * x & (x - 1) != 0 - * - * However, incorrectly true for x == 0 so check for that explicitly. - */ -#define DUK_IS_POWER_OF_TWO(x) \ - ((x) != 0U && ((x) & ((x) - 1U)) == 0U) #endif /* DUK_UTIL_H_INCLUDED */ /* #include duk_strings.h */ @@ -3133,7 +2950,7 @@ #endif /* DUK_ERRMSG_H_INCLUDED */ /* #include duk_js_bytecode.h */ /* - * ECMAScript bytecode + * Ecmascript bytecode */ #if !defined(DUK_JS_BYTECODE_H_INCLUDED) @@ -4005,7 +3822,7 @@ duk_int_t line; }; -/* Lexer context. Same context is used for ECMAScript and Regexp parsing. */ +/* Lexer context. Same context is used for Ecmascript and Regexp parsing. */ struct duk_lexer_ctx { #if defined(DUK_USE_LEXER_SLIDING_WINDOW) duk_lexer_codepoint *window; /* unicode code points, window[0] is always next, points to 'buffer' */ @@ -4055,13 +3872,13 @@ #endif /* DUK_LEXER_H_INCLUDED */ /* #include duk_js_compiler.h */ /* - * ECMAScript compiler. + * Ecmascript compiler. */ #if !defined(DUK_JS_COMPILER_H_INCLUDED) #define DUK_JS_COMPILER_H_INCLUDED -/* ECMAScript compiler limits */ +/* ecmascript compiler limits */ #define DUK_COMPILER_TOKEN_LIMIT 100000000L /* 1e8: protects against deeply nested inner functions */ /* maximum loopcount for peephole optimization */ @@ -4243,7 +4060,6 @@ duk_uint8_t is_arguments_shadowed; /* argument/function declaration shadows 'arguments' */ duk_uint8_t needs_shuffle; /* function needs shuffle registers */ duk_uint8_t reject_regexp_in_adv; /* reject RegExp literal on next advance() call; needed for handling IdentifierName productions */ - duk_uint8_t allow_regexp_in_adv; /* allow RegExp literal on next advance() call */ }; struct duk_compiler_ctx { @@ -5543,12 +5359,10 @@ DUK_INTERNAL_DECL duk_double_t duk_to_number_m1(duk_hthread *thr); DUK_INTERNAL_DECL duk_double_t duk_to_number_m2(duk_hthread *thr); -DUK_INTERNAL_DECL duk_bool_t duk_to_boolean_top_pop(duk_hthread *thr); - #if defined(DUK_USE_DEBUGGER_SUPPORT) /* only needed by debugger for now */ DUK_INTERNAL_DECL duk_hstring *duk_safe_to_hstring(duk_hthread *thr, duk_idx_t idx); #endif -DUK_INTERNAL_DECL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv, duk_bool_t avoid_side_effects); +DUK_INTERNAL_DECL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv); DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped_raw(duk_hthread *thr, duk_idx_t idx, duk_int_t minval, duk_int_t maxval, duk_bool_t *out_clamped); /* out_clamped=NULL, RangeError if outside range */ DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped(duk_hthread *thr, duk_idx_t idx, duk_int_t minval, duk_int_t maxval); @@ -5686,8 +5500,6 @@ DUK_INTERNAL_DECL void duk_xdef_prop_stridx_thrower(duk_hthread *thr, duk_idx_t obj_idx, duk_small_uint_t stridx); /* [] -> [] */ -DUK_INTERNAL_DECL duk_bool_t duk_get_method_stridx(duk_hthread *thr, duk_idx_t idx, duk_small_uint_t stridx); - DUK_INTERNAL_DECL void duk_pack(duk_hthread *thr, duk_idx_t count); DUK_INTERNAL_DECL duk_idx_t duk_unpack_array_like(duk_hthread *thr, duk_idx_t idx); #if 0 @@ -5724,10 +5536,6 @@ DUK_INTERNAL_DECL duk_int_t duk_pcall_method_flags(duk_hthread *thr, duk_idx_t nargs, duk_small_uint_t call_flags); -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL_DECL void duk_to_primitive_ordinary(duk_hthread *thr, duk_idx_t idx, duk_int_t hint); -#endif - /* Raw internal valstack access macros: access is unsafe so call site * must have a guarantee that the index is valid. When that is the case, * using these macro results in faster and smaller code than duk_get_tval(). @@ -5766,7 +5574,7 @@ * strings used as internal property names and raw buffers converted to * strings. In such cases the 'clen' field contains an inaccurate value. * - * ECMAScript requires support for 32-bit long strings. However, since each + * Ecmascript requires support for 32-bit long strings. However, since each * 16-bit codepoint can take 3 bytes in CESU-8, this representation can only * support about 1.4G codepoint long strings in extreme cases. This is not * really a practical issue. @@ -5790,15 +5598,12 @@ #define DUK_HSTRING_MAX_BYTELEN (0x7fffffffUL) #endif -/* XXX: could add flags for "is valid CESU-8" (ECMAScript compatible strings), +/* XXX: could add flags for "is valid CESU-8" (Ecmascript compatible strings), * "is valid UTF-8", "is valid extended UTF-8" (internal strings are not, * regexp bytecode is), and "contains non-BMP characters". These are not * needed right now. */ -/* With lowmem builds the high 16 bits of duk_heaphdr are used for other - * purposes, so this leaves 7 duk_heaphdr flags and 9 duk_hstring flags. - */ #define DUK_HSTRING_FLAG_ASCII DUK_HEAPHDR_USER_FLAG(0) /* string is ASCII, clen == blen */ #define DUK_HSTRING_FLAG_ARRIDX DUK_HEAPHDR_USER_FLAG(1) /* string is a valid array index */ #define DUK_HSTRING_FLAG_SYMBOL DUK_HEAPHDR_USER_FLAG(2) /* string is a symbol (invalid utf-8) */ @@ -5807,7 +5612,6 @@ #define DUK_HSTRING_FLAG_STRICT_RESERVED_WORD DUK_HEAPHDR_USER_FLAG(5) /* string is a reserved word (strict) */ #define DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS DUK_HEAPHDR_USER_FLAG(6) /* string is 'eval' or 'arguments' */ #define DUK_HSTRING_FLAG_EXTDATA DUK_HEAPHDR_USER_FLAG(7) /* string data is external (duk_hstring_external) */ -#define DUK_HSTRING_FLAG_PINNED_LITERAL DUK_HEAPHDR_USER_FLAG(8) /* string is a literal, and pinned */ #define DUK_HSTRING_HAS_ASCII(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) #define DUK_HSTRING_HAS_ARRIDX(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) @@ -5817,7 +5621,6 @@ #define DUK_HSTRING_HAS_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) #define DUK_HSTRING_HAS_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) #define DUK_HSTRING_HAS_EXTDATA(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) -#define DUK_HSTRING_HAS_PINNED_LITERAL(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) #define DUK_HSTRING_SET_ASCII(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) #define DUK_HSTRING_SET_ARRIDX(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) @@ -5827,7 +5630,6 @@ #define DUK_HSTRING_SET_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) #define DUK_HSTRING_SET_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) #define DUK_HSTRING_SET_EXTDATA(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) -#define DUK_HSTRING_SET_PINNED_LITERAL(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) #define DUK_HSTRING_CLEAR_ASCII(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) #define DUK_HSTRING_CLEAR_ARRIDX(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) @@ -5837,7 +5639,6 @@ #define DUK_HSTRING_CLEAR_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) #define DUK_HSTRING_CLEAR_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) #define DUK_HSTRING_CLEAR_EXTDATA(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) -#define DUK_HSTRING_CLEAR_PINNED_LITERAL(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) #if 0 /* Slightly smaller code without explicit flag, but explicit flag * is very useful when 'clen' is dropped. @@ -6005,12 +5806,12 @@ /* * Heap object representation. * - * Heap objects are used for ECMAScript objects, arrays, and functions, + * Heap objects are used for Ecmascript objects, arrays, and functions, * but also for internal control like declarative and object environment * records. Compiled functions, native functions, and threads are also * objects but with an extended C struct. * - * Objects provide the required ECMAScript semantics and exotic behaviors + * Objects provide the required Ecmascript semantics and exotic behaviors * especially for property access. * * Properties are stored in three conceptual parts: @@ -6639,7 +6440,7 @@ #define DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY 10000L /* - * ECMAScript [[Class]] + * Ecmascript [[Class]] */ /* range check not necessary because all 4-bit values are mapped */ @@ -7002,9 +6803,9 @@ #endif /* DUK_HOBJECT_H_INCLUDED */ /* #include duk_hcompfunc.h */ /* - * Heap compiled function (ECMAScript function) representation. + * Heap compiled function (Ecmascript function) representation. * - * There is a single data buffer containing the ECMAScript function's + * There is a single data buffer containing the Ecmascript function's * bytecode, constants, and inner functions. */ @@ -7395,8 +7196,7 @@ } while (0) /* Get the current data pointer (caller must ensure buf != NULL) as a - * duk_uint8_t ptr. Note that the result may be NULL if the underlying - * buffer has zero size and is not a fixed buffer. + * duk_uint8_t ptr. */ #define DUK_HBUFOBJ_GET_SLICE_BASE(heap,h) \ (DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \ @@ -7714,14 +7514,14 @@ duk_instr_t *curr_pc; /* next instruction to execute (points to 'func' bytecode, stable pointer), NULL for native calls */ /* bottom_byteoff and retval_byteoff are only used for book-keeping - * of ECMAScript-initiated calls, to allow returning to an ECMAScript + * of Ecmascript-initiated calls, to allow returning to an Ecmascript * function properly. */ /* Bottom of valstack for this activation, used to reset * valstack_bottom on return; offset is absolute. There's * no need to track 'top' because native call handling deals - * with that using locals, and for ECMAScript returns 'nregs' + * with that using locals, and for Ecmascript returns 'nregs' * indicates the necessary top. */ duk_size_t bottom_byteoff; @@ -8105,7 +7905,7 @@ #define DUK_HBUFFER_EXTERNAL_GET_SIZE(x) DUK_HBUFFER_GET_SIZE((duk_hbuffer *) (x)) #define DUK_HBUFFER_EXTERNAL_SET_SIZE(x,v) DUK_HBUFFER_SET_SIZE((duk_hbuffer *) (x), (v)) -#define DUK_HBUFFER_FIXED_GET_DATA_PTR(heap,x) ((duk_uint8_t *) (((duk_hbuffer_fixed *) (void *) (x)) + 1)) +#define DUK_HBUFFER_FIXED_GET_DATA_PTR(heap,x) ((duk_uint8_t *) (((duk_hbuffer_fixed *) (x)) + 1)) #if defined(DUK_USE_HEAPPTR16) #define DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap,x) \ @@ -8160,7 +7960,7 @@ DUK_HBUFFER_EXTERNAL_GET_DATA_PTR((heap), (duk_hbuffer_external *) (x)) : \ DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((heap), (duk_hbuffer_dynamic *) (x)) \ ) : \ - DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (void *) (x)) \ + DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (x)) \ ) #else /* Without heap pointer compression duk_hbuffer_dynamic and duk_hbuffer_external @@ -8169,7 +7969,7 @@ #define DUK_HBUFFER_GET_DATA_PTR(heap,x) ( \ DUK_HBUFFER_HAS_DYNAMIC((x)) ? \ DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((heap), (duk_hbuffer_dynamic *) (x)) : \ - DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (void *) (x)) \ + DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (x)) \ ) #endif @@ -8243,10 +8043,7 @@ #if (DUK_USE_ALIGN_BY == 4) duk_uint32_t dummy_for_align4; #elif (DUK_USE_ALIGN_BY == 8) - duk_double_t dummy_for_align8_1; -#if defined(DUK_USE_64BIT_OPS) - duk_uint64_t dummy_for_align8_2; -#endif + duk_double_t dummy_for_align8; #elif (DUK_USE_ALIGN_BY == 1) /* no extra padding */ #else @@ -8661,7 +8458,7 @@ * Thus, string caches are now at the heap level now. */ -struct duk_strcache_entry { +struct duk_strcache { duk_hstring *h; duk_uint32_t bidx; duk_uint32_t cidx; @@ -8693,15 +8490,6 @@ } while (0) /* - * Literal intern cache - */ - -struct duk_litcache_entry { - const duk_uint8_t *addr; - duk_hstring *h; -}; - -/* * Main heap structure */ @@ -8927,15 +8715,7 @@ /* String access cache (codepoint offset -> byte offset) for fast string * character looping; 'weak' reference which needs special handling in GC. */ - duk_strcache_entry strcache[DUK_HEAP_STRCACHE_SIZE]; - -#if defined(DUK_USE_LITCACHE_SIZE) - /* Literal intern cache. When enabled, strings interned as literals - * (e.g. duk_push_literal()) will be pinned and cached for the lifetime - * of the heap. - */ - duk_litcache_entry litcache[DUK_USE_LITCACHE_SIZE]; -#endif + duk_strcache strcache[DUK_HEAP_STRCACHE_SIZE]; /* Built-in strings. */ #if defined(DUK_USE_ROM_STRINGS) @@ -8967,9 +8747,6 @@ duk_int_t stats_strtab_resize_check; duk_int_t stats_strtab_resize_grow; duk_int_t stats_strtab_resize_shrink; - duk_int_t stats_strtab_litcache_hit; - duk_int_t stats_strtab_litcache_miss; - duk_int_t stats_strtab_litcache_pin; duk_int_t stats_object_realloc_props; duk_int_t stats_object_abandon_array; duk_int_t stats_getownpropdesc_count; @@ -9030,9 +8807,6 @@ DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen); DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t len); -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_literal_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t blen); -#endif DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_u32(duk_heap *heap, duk_uint32_t val); DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_u32_checked(duk_hthread *thr, duk_uint32_t val); #if defined(DUK_USE_REFERENCE_COUNTING) @@ -9434,8 +9208,8 @@ * Error codes: defined in duktape.h * * Error codes are used as a shorthand to throw exceptions from inside - * the implementation. The appropriate ECMAScript object is constructed - * based on the code. ECMAScript code throws objects directly. The error + * the implementation. The appropriate Ecmascript object is constructed + * based on the code. Ecmascript code throws objects directly. The error * codes are defined in the public API header because they are also used * by calling code. */ @@ -9837,7 +9611,7 @@ #if defined(DUK_USE_ASSERTIONS) #define DUK_ASSERT_SET_GARBAGE(ptr,size) do { \ - duk_memset_unsafe((void *) (ptr), 0x5a, size); \ + DUK_MEMSET((void *) (ptr), 0x5a, size); \ } while (0) #else #define DUK_ASSERT_SET_GARBAGE(ptr,size) do {} while (0) @@ -10115,13 +9889,13 @@ * Automatically generated by extract_chars.py, do not edit! */ -extern const duk_uint8_t duk_unicode_ids_noa[1063]; +extern const duk_uint8_t duk_unicode_ids_noa[1036]; #else /* * Automatically generated by extract_chars.py, do not edit! */ -extern const duk_uint8_t duk_unicode_ids_noabmp[626]; +extern const duk_uint8_t duk_unicode_ids_noabmp[625]; #endif #if defined(DUK_USE_SOURCE_NONBMP) @@ -10143,13 +9917,13 @@ * Automatically generated by extract_chars.py, do not edit! */ -extern const duk_uint8_t duk_unicode_idp_m_ids_noa[549]; +extern const duk_uint8_t duk_unicode_idp_m_ids_noa[530]; #else /* * Automatically generated by extract_chars.py, do not edit! */ -extern const duk_uint8_t duk_unicode_idp_m_ids_noabmp[358]; +extern const duk_uint8_t duk_unicode_idp_m_ids_noabmp[357]; #endif /* @@ -10290,7 +10064,7 @@ #endif /* DUK_JSON_H_INCLUDED */ /* #include duk_js.h */ /* - * ECMAScript execution, support primitives. + * Ecmascript execution, support primitives. */ #if !defined(DUK_JS_H_INCLUDED) @@ -10334,9 +10108,6 @@ #endif DUK_INTERNAL_DECL duk_bool_t duk_js_compare_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_uint_t flags); DUK_INTERNAL_DECL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y); -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL_DECL duk_bool_t duk_js_instanceof_ordinary(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y); -#endif DUK_INTERNAL_DECL duk_bool_t duk_js_in(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y); DUK_INTERNAL_DECL duk_small_uint_t duk_js_typeof_stridx(duk_tval *tv_x); @@ -10405,7 +10176,7 @@ /* #include duk_numconv.h */ /* * Number-to-string conversion. The semantics of these is very tightly - * bound with the ECMAScript semantics required for call sites. + * bound with the Ecmascript semantics required for call sites. */ #if !defined(DUK_NUMCONV_H_INCLUDED) @@ -10438,13 +10209,9 @@ /* Maximum exponent value when parsing numbers. This is not strictly * compliant as there should be no upper limit, but as we parse the - * exponent without a bigint, impose some limit. The limit should be - * small enough that multiplying it (or limit-1 to be precise) won't - * overflow signed 32-bit integer range. Exponent is only parsed with - * radix 10, but with maximum radix (36) a safe limit is: - * (10000000*36).toString(16) -> '15752a00' + * exponent without a bigint, impose some limit. */ -#define DUK_S2N_MAX_EXPONENT 10000000L +#define DUK_S2N_MAX_EXPONENT 1000000000 /* Trim white space (= allow leading and trailing whitespace) */ #define DUK_S2N_FLAG_TRIM_WHITE (1U << 0) @@ -10715,7 +10482,7 @@ va_start(ap, fmt); - duk_memzero((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); + DUK_MEMZERO((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); duk_debug_vsnprintf(buf, DUK__DEBUG_BUFSIZE - 1, fmt, ap); arg_level = (long) level; @@ -10746,7 +10513,7 @@ va_start(ap, fmt); - duk_memzero((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); + DUK_MEMZERO((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); duk_debug_vsnprintf(buf, DUK__DEBUG_BUFSIZE - 1, fmt, ap); arg_level = (long) duk_debug_level_stash; @@ -10786,7 +10553,7 @@ #if defined(DUK_USE_ROM_STRINGS) #error ROM support not enabled, rerun configure.py with --rom-support #else /* DUK_USE_ROM_STRINGS */ -DUK_INTERNAL const duk_uint8_t duk_strings_data[967] = { +DUK_INTERNAL const duk_uint8_t duk_strings_data[892] = { 79,40,209,144,168,105,6,78,54,139,89,185,44,48,46,90,120,8,154,140,35,103, 35,113,193,73,5,52,112,180,104,166,135,52,188,4,98,12,27,146,156,80,211,31, 129,115,150,64,52,220,109,24,18,68,156,24,38,67,114,36,55,9,119,151,132, @@ -10808,40 +10575,36 @@ 249,110,128,126,88,95,133,109,237,237,237,151,235,127,46,249,119,203,190, 186,206,33,181,2,208,61,190,12,19,34,65,19,81,132,108,228,97,1,107,33,12, 32,45,100,137,64,247,175,9,19,155,41,198,130,155,134,69,146,100,227,226, -231,146,51,192,204,73,140,224,145,221,102,241,68,196,169,248,30,75,12,11, -151,242,233,187,143,138,24,137,162,164,255,253,63,3,201,97,129,114,254,92, -112,75,136,108,166,6,136,159,255,167,224,121,44,48,46,95,203,166,238,74, -113,67,77,201,128,223,255,223,224,121,44,48,46,95,203,145,46,9,205,16,39, -201,62,36,0,192,21,147,255,238,145,39,199,197,211,116,240,242,113,197,78, -214,211,226,233,187,107,105,19,119,37,56,161,166,52,221,212,201,205,36,240, -242,16,96,152,12,178,52,211,56,228,73,150,83,0,148,39,137,75,67,73,198,209, -129,36,85,185,201,196,2,32,193,48,17,160,97,16,84,44,156,104,24,67,189,200, -108,201,19,238,114,96,137,137,50,238,113,164,188,211,185,192,226,100,19, -134,68,110,112,174,139,0,185,31,115,149,4,88,7,159,115,146,117,34,34,35, -115,143,22,146,208,210,19,115,140,3,207,185,202,130,36,109,85,185,194,161, -160,90,50,72,155,115,149,2,232,67,137,204,122,22,66,161,175,164,210,72,199, -130,137,1,50,32,145,143,38,120,186,195,35,106,51,146,230,8,36,77,109,65,38, -226,72,159,191,189,181,70,140,133,222,249,212,227,66,125,245,187,251,219, -77,3,119,190,117,56,208,159,125,110,254,246,210,26,93,239,157,78,52,39,223, -93,191,189,180,212,52,187,223,58,156,104,79,190,187,127,123,104,180,104, -183,190,117,56,208,159,125,102,254,209,104,209,124,234,113,161,62,250,80, -196,128,81,4,9,16,162,4,196,116,9,205,154,27,66,32,100,13,12,98,68,227,33, -65,69,204,195,34,201,50,8,110,33,23,34,28,168,104,22,188,12,174,138,11,70, -138,104,115,68,130,137,13,82,27,41,129,162,35,138,54,146,198,137,39,72,180, -210,178,38,35,146,103,68,139,51,197,214,28,227,131,79,15,35,138,58,130,37, -19,155,41,146,174,64,203,99,161,100,37,145,51,148,75,4,164,66,54,140,49,46, -247,70,103,37,230,70,142,70,67,30,232,204,178,163,201,18,54,139,89,39,26, -16,165,2,228,69,33,143,89,24,70,206,73,67,102,72,148,2,32,214,73,157,224, -18,128,98,29,241,69,65,50,37,241,116,200,41,144,102,125,2,180,8,210,152,38, -129,23,8,34,198, +231,146,51,192,204,73,140,224,145,221,102,241,68,196,157,34,79,143,139,166, +233,225,228,227,138,157,173,167,197,211,118,214,210,38,238,74,113,67,76, +105,187,169,147,154,73,225,228,32,193,48,25,100,105,166,113,200,147,44,166, +1,40,79,18,150,134,147,141,163,2,72,171,115,147,136,4,65,130,96,35,64,194, +32,168,89,56,208,48,135,123,144,217,146,39,220,228,193,19,18,101,220,227, +73,121,167,115,129,196,200,39,12,136,220,225,93,22,1,114,62,231,42,8,176, +15,62,231,36,234,68,68,70,231,30,45,37,161,164,38,231,24,7,159,115,149,4, +72,218,171,115,133,67,64,180,100,145,54,231,42,5,208,135,19,152,244,44,133, +67,95,73,164,145,143,5,18,2,100,65,35,30,76,241,117,134,70,212,103,37,204, +16,72,154,218,130,77,196,145,63,127,123,106,141,25,11,189,243,169,198,132, +251,235,119,247,182,154,6,239,124,234,113,161,62,250,221,253,237,164,52, +187,223,58,156,104,79,190,187,127,123,105,168,105,119,190,117,56,208,159, +125,118,254,246,209,104,209,111,124,234,113,161,62,250,205,253,162,209,162, +249,212,227,66,125,244,161,137,0,162,8,18,33,68,9,136,232,19,155,52,54,132, +64,200,26,24,196,137,198,66,130,139,153,134,69,146,100,16,220,66,46,68,57, +80,208,45,120,25,93,20,22,141,20,208,230,137,5,18,26,164,54,83,3,68,71,20, +109,37,141,18,78,145,105,165,100,76,71,36,206,137,22,103,139,172,57,199,6, +158,30,71,20,117,4,74,39,54,83,37,92,129,150,199,66,200,75,34,103,40,150,9, +72,132,109,24,98,93,238,140,206,75,204,141,28,140,134,61,209,153,101,71, +146,36,109,22,178,78,52,33,74,5,200,138,67,30,178,48,141,156,146,134,204, +145,40,4,65,172,147,59,192,37,0,196,59,226,138,130,100,75,226,233,144,83, +32,204,250,5,104,17,165,48,77,2,46,16,69,140, }; #endif /* DUK_USE_ROM_STRINGS */ #if defined(DUK_USE_ROM_OBJECTS) #error ROM support not enabled, rerun configure.py with --rom-support #else /* DUK_USE_ROM_OBJECTS */ -/* native functions: 177 */ -DUK_INTERNAL const duk_c_function duk_bi_native_functions[177] = { +/* native functions: 176 */ +DUK_INTERNAL const duk_c_function duk_bi_native_functions[176] = { NULL, duk_bi_array_constructor, duk_bi_array_constructor_is_array, @@ -10934,7 +10697,6 @@ duk_bi_nodejs_buffer_tojson, duk_bi_nodejs_buffer_tostring, duk_bi_nodejs_buffer_write, - duk_bi_number_check_shared, duk_bi_number_constructor, duk_bi_number_prototype_to_exponential, duk_bi_number_prototype_to_fixed, @@ -11021,577 +10783,556 @@ duk_bi_uint8array_plainof, }; #if defined(DUK_USE_DOUBLE_LE) -DUK_INTERNAL const duk_uint8_t duk_builtins_data[4116] = { -144,148,105,224,32,68,52,228,62,12,104,200,165,132,52,167,194,138,105,243, -124,57,28,211,57,18,64,52,238,126,44,138,111,171,241,164,19,87,129,30,33, +DUK_INTERNAL const duk_uint8_t duk_builtins_data[3972] = { +144,148,105,223,160,68,52,228,62,12,104,200,165,132,52,167,194,138,105,242, +252,57,28,211,57,18,64,52,238,62,44,138,111,171,241,164,19,87,125,30,33, 167,16,145,159,8,211,136,9,225,42,5,240,145,139,163,163,8,211,136,10,228, 64,211,19,132,140,93,29,56,70,156,64,119,34,66,146,36,104,137,194,70,46, 142,172,35,78,32,47,146,195,102,11,240,145,139,163,175,8,211,136,9,228,240, 242,112,145,139,163,179,8,211,136,8,237,34,130,118,49,116,118,225,26,48,0, -1,82,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, -33,8,66,26,179,233,97,167,60,150,34,33,154,112,0,1,75,247,35,79,95,237,198, -174,200,47,31,23,95,17,13,51,19,35,93,68,216,209,128,0,10,208,174,79,15,32, -248,8,196,24,8,107,192,0,5,106,118,27,94,0,0,43,83,227,94,0,0,43,84,46,215, -128,0,10,213,28,198,188,0,0,86,169,100,53,224,0,2,181,79,85,175,0,0,21,170, -154,45,120,0,0,173,85,217,107,192,0,5,106,182,243,86,193,106,52,127,130, -249,50,94,124,35,68,225,146,49,13,31,186,23,201,146,243,224,200,39,12,145, -136,67,134,19,49,0,0,0,0,0,0,3,225,255,51,0,0,0,0,0,0,3,193,255,47,18,1, -172,19,120,71,10,25,196,136,113,162,156,136,199,42,57,204,144,115,132,240, -149,2,248,72,197,209,58,2,185,16,52,196,225,35,23,68,233,14,228,72,82,68, -141,17,56,72,197,209,58,130,249,44,54,96,191,9,24,186,39,88,79,39,135,147, -132,140,93,19,176,35,180,138,9,216,197,209,59,82,79,35,40,242,65,248,58,42, -96,121,14,232,94,62,46,190,15,42,31,145,33,86,65,76,242,214,143,73,48,242, -243,79,49,56,243,115,207,57,64,243,180,79,61,72,243,244,207,65,80,244,53, -79,69,88,244,98,30,8,200,156,67,102,120,241,79,4,100,78,21,110,4,207,32,47, -147,37,231,194,52,78,25,34,122,81,124,153,47,62,12,130,112,201,19,211,139, -121,34,87,69,128,104,137,239,83,18,238,108,165,2,162,92,104,56,220,233,1,8, -151,10,134,162,100,206,16,18,50,9,195,39,105,20,101,136,18,25,4,225,147, -180,138,5,215,49,238,105,27,60,185,1,36,104,156,50,118,145,70,96,129,34,52, -78,25,59,72,160,93,115,30,230,145,179,204,144,12,73,8,15,38,104,128,138,52, -146,16,30,77,1,0,2,11,132,193,198,36,248,248,186,110,158,30,78,56,188,194, -70,183,170,136,48,98,79,142,179,120,248,185,228,140,241,193,146,66,138,31, -55,71,138,128,153,137,62,58,205,227,226,231,146,51,199,26,6,18,92,146,64, -96,74,72,51,120,43,192,97,68,128,153,56,72,7,12,133,67,73,199,197,207,36, -103,142,35,2,3,33,80,210,113,241,115,201,25,160,146,225,160,9,34,1,124,178, -1,139,18,19,36,229,146,8,190,36,169,27,62,18,243,35,100,135,54,92,162,2,17, -46,72,128,89,7,200,32,33,18,225,98,236,145,188,130,64,196,75,132,188,200, -217,32,43,39,28,128,69,19,18,228,144,42,98,79,142,179,120,248,185,228,140, -241,201,97,129,114,229,201,37,2,68,184,200,1,147,93,159,153,213,34,235,250, -96,48,157,32,24,94,160,1,199,4,184,235,55,143,139,158,72,207,28,226,3,81, -46,62,46,155,167,135,147,142,47,60,129,71,197,207,36,103,142,34,92,35,104, -194,68,1,89,58,36,8,109,109,12,133,67,73,195,18,115,36,118,182,185,168,8, -109,109,12,133,67,73,201,18,115,36,118,182,185,168,130,27,91,75,115,149,71, -240,196,156,201,29,173,174,129,2,27,91,75,115,149,71,242,68,156,201,29,173, -174,129,34,12,16,28,128,62,191,42,3,71,146,68,4,16,22,188,161,240,16,40, -104,242,103,196,16,93,158,125,96,110,115,235,64,131,16,16,58,37,192,70,32, -194,144,114,25,67,95,40,6,18,8,32,48,156,209,2,108,124,96,224,144,6,247,62, -16,0,143,164,143,12,248,15,18,84,145,145,34,128,11,35,160,179,140,0,44,150, -129,18,58,0,146,116,103,32,128,105,61,104,17,36,175,1,232,217,29,5,156,179, -224,58,26,50,95,142,43,159,64,181,130,83,226,26,50,95,142,43,159,192,7,255, -248,41,42,72,226,1,160,18,78,97,32,26,64,114,186,60,32,4,120,6,148,13,128, -124,3,76,12,84,46,100,140,3,78,13,18,14,130,36,67,232,23,18,14,130,39,34, -131,30,113,15,224,3,255,253,6,48,40,194,197,204,224,142,8,240,78,25,60,231, -192,210,197,204,224,156,50,113,238,67,103,232,62,28,138,156,104,82,170,107, -255,32,48,191,144,1,132,112,71,128,159,168,128,161,28,17,224,156,50,112,19, -245,144,22,39,12,156,123,144,217,240,19,245,146,3,9,205,16,39,236,62,3,161, -163,37,248,226,251,141,1,107,4,167,196,52,100,191,28,95,113,164,13,91,132, -5,147,130,115,30,8,147,222,64,43,1,49,31,224,64,60,72,245,128,68,249,32,13, -34,2,34,63,204,128,89,45,2,39,209,0,89,61,104,159,213,0,153,80,50,156,80, -211,126,16,11,155,184,183,88,145,224,129,34,122,64,17,155,184,183,8,11,39, -22,235,18,60,16,36,79,72,1,115,119,40,247,146,60,16,36,79,72,32,140,221, -197,184,64,89,57,71,188,145,224,129,34,122,65,1,39,20,51,244,0,52,72,242,2, -127,18,2,165,48,70,114,229,145,51,253,141,1,4,104,229,203,34,103,251,26,64, -132,52,75,160,201,47,105,160,26,84,12,167,31,186,8,50,0,114,58,113,163,46, -190,120,35,11,60,4,25,68,81,61,96,47,181,80,46,132,129,255,255,255,255,255, -255,222,254,39,172,67,118,170,5,208,144,0,64,0,0,0,0,0,0,51,16,0,0,0,0,0,0, -62,31,200,245,238,146,38,138,147,105,13,42,26,137,226,0,0,0,0,0,0,7,131, -249,30,180,134,4,209,82,109,33,165,67,81,60,64,0,0,0,0,0,0,240,255,15,210, -62,72,91,155,0,0,0,0,0,0,2,192,240,135,88,11,237,72,5,38,210,27,50,24,145, -129,255,255,255,255,255,254,126,134,67,172,67,118,164,2,147,105,13,153,12, -72,192,255,255,255,255,255,255,63,195,16,240,70,68,226,27,51,199,138,120, -35,34,112,171,112,38,121,7,16,137,112,168,106,38,77,193,1,40,151,16,217, -144,196,142,224,144,21,18,227,65,198,238,9,67,81,46,72,5,39,16,217,144,196, -142,224,152,228,148,227,64,0,0,0,0,0,0,0,0,131,175,223,16,194,111,8,97,119, -224,3,205,220,42,46,65,238,200,13,155,184,75,189,205,35,102,128,47,116,64, -92,221,199,196,130,68,144,230,239,72,65,152,12,21,224,140,137,92,128,62, -210,98,177,252,3,107,173,88,3,146,211,141,32,0,0,0,0,0,3,225,255,19,175, -188,0,100,221,193,130,100,228,167,20,52,215,129,3,38,238,77,12,39,37,56, -161,166,188,10,194,94,6,18,155,184,183,8,11,39,6,9,147,146,156,80,211,94,7, -18,155,184,183,8,11,39,38,134,19,146,156,80,211,94,8,12,53,224,130,195,222, -8,77,133,210,24,91,224,3,152,147,228,208,194,95,0,44,196,159,11,69,175,152, -32,35,100,33,135,24,147,237,38,34,246,139,95,48,64,70,200,68,8,49,39,198, -57,179,61,144,138,22,98,79,180,152,153,215,54,103,178,17,129,204,73,240,96, -153,44,132,112,163,18,125,164,196,62,130,100,178,18,1,140,73,240,96,197, -144,146,18,98,79,180,152,135,208,98,200,74,8,49,39,195,186,145,149,144,150, -22,98,79,180,152,143,215,82,50,178,19,2,140,73,241,136,109,38,73,89,9,161, -166,36,251,73,137,157,67,105,50,74,200,78,10,49,39,201,16,78,104,229,100, -39,134,152,147,237,38,41,116,130,115,71,43,33,64,60,196,159,24,133,173,18, -32,156,209,202,200,81,18,49,39,218,76,76,234,22,180,72,130,115,71,43,33,72, -68,196,159,38,134,19,46,105,56,226,150,68,157,160,1,228,73,242,104,97,46, -16,31,34,79,140,66,214,137,16,78,104,229,108,169,137,72,147,237,38,38,117, -11,90,36,65,57,163,149,178,168,21,34,79,146,32,156,209,202,218,250,161,178, -36,251,73,138,93,32,156,209,202,218,250,193,82,36,248,196,54,147,36,173, -191,174,27,34,79,180,152,153,212,54,147,36,173,191,176,17,34,79,135,117,35, -43,115,236,133,200,147,237,38,35,245,212,140,173,207,180,15,34,79,131,4, -201,108,173,133,72,147,237,38,33,244,19,37,178,184,17,34,79,140,115,102, -123,107,238,133,200,147,237,38,38,117,205,153,237,175,188,23,34,79,133,162, -215,204,16,17,182,254,248,116,137,62,210,98,47,104,181,243,4,4,109,191,192, -131,152,147,230,8,8,217,12,16,60,137,62,96,128,141,178,193,160,206,1,201, -176,113,146,0,0,0,0,0,0,0,0,49,185,252,65,137,207,227,37,215,207,227,12,86, -127,24,152,188,254,49,88,33,46,65,120,72,4,153,37,63,33,13,127,148,4,26,0, -57,62,6,228,163,228,74,86,215,62,55,28,110,179,226,113,70,223,62,47,24,38, -191,30,2,125,32,40,20,87,114,41,225,42,5,240,145,139,163,145,41,68,250,128, -80,41,174,228,85,200,129,166,39,9,24,186,57,18,148,79,172,5,2,170,238,69, -220,137,10,72,145,162,39,9,24,186,57,18,148,79,176,5,2,186,238,69,124,150, -27,48,95,132,140,93,28,137,74,39,218,2,129,101,119,34,158,79,15,39,9,24, -186,57,18,148,79,184,5,2,218,238,69,29,164,80,78,198,46,142,68,165,16,64, -28,24,61,73,25,33,205,128,0,0,0,0,1,167,166,129,108,242,151,15,39,8,34,26, -87,97,200,3,0,167,129,32,8,194,195,16,6,84,55,10,60,3,35,69,132,30,1,140, -130,193,143,1,196,230,60,2,158,8,131,153,64,115,42,46,191,176,8,194,246,0, -80,5,220,193,95,6,234,5,100,225,35,23,71,35,6,228,140,93,29,180,55,108,145, -139,163,182,112,52,107,67,76,56,3,153,132,20,28,76,156,89,26,105,158,62,0, -0,42,193,2,201,104,17,41,34,156,204,176,160,226,100,226,200,211,76,241,240, -0,1,86,2,131,137,147,142,41,100,73,199,192,0,5,96,6,13,10,82,70,62,0,0,42, -130,88,115,18,124,67,103,177,69,49,129,6,36,249,68,54,123,20,82,216,65,137, -62,33,179,209,214,162,152,208,147,18,124,162,27,61,29,106,41,112,32,196, -159,16,217,233,233,81,76,112,73,137,62,81,13,158,158,149,20,186,20,98,79, -133,91,129,61,61,42,41,120,40,196,159,10,183,2,122,218,148,82,248,60,137, -62,33,179,216,166,216,192,137,18,124,162,27,61,138,109,108,34,68,159,16, -217,232,235,83,108,104,76,137,62,81,13,158,142,181,54,184,17,34,79,136,108, -244,244,169,182,56,38,68,159,40,134,207,79,74,155,93,10,145,39,194,173,192, -158,158,149,54,188,21,34,79,133,91,129,61,109,74,109,125,155,51,136,71,161, -196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,7,129,249,155,51,168,71, -161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,7,129,249,155,51,200, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,7,129,249,155,51, -232,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,2,1,155,52, -8,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,2,1,155,52,40, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,155,52,72, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,155,52, -104,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,155, -52,136,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,1,2,1,135, -52,166,32,76,72,1,246,136,235,103,177,69,0,136,144,3,226,27,61,138,41,44, -50,36,0,251,68,117,179,209,214,234,201,69,16,50,36,0,251,68,117,179,209, -214,232,73,69,34,5,196,128,31,16,217,232,235,117,100,162,147,2,226,64,15, -136,108,244,117,186,18,81,74,129,145,32,7,218,35,173,158,158,151,86,74,40, -161,145,32,7,218,35,173,158,158,151,66,74,41,20,46,36,0,248,134,207,79,75, -171,37,20,154,23,18,0,124,67,103,167,165,208,146,138,85,11,137,0,62,21,110, -4,250,178,81,70,11,137,0,62,21,110,4,250,18,81,72,193,145,32,7,193,186,129, -89,58,178,81,71,12,137,0,62,13,212,10,201,208,146,138,71,10,137,0,62,209, -29,108,250,178,81,104,1,81,32,7,218,35,173,159,66,74,45,32,38,36,0,248,134, -207,171,37,22,160,19,18,0,124,67,103,208,146,139,88,10,180,81,50,118,136, -235,103,177,77,128,155,69,19,39,16,217,236,83,105,97,182,138,38,78,209,29, -108,244,117,186,178,83,100,13,180,81,50,118,136,235,103,163,173,208,146, -155,68,12,180,81,50,113,13,158,142,183,86,74,109,48,50,209,68,201,196,54, -122,58,221,9,41,181,64,219,69,19,39,104,142,182,122,122,93,89,41,178,134, -218,40,153,59,68,117,179,211,210,232,73,77,162,134,90,40,153,56,134,207,79, -75,171,37,54,154,25,104,162,100,226,27,61,61,46,132,148,218,168,101,162, -137,147,133,91,129,62,172,148,217,131,45,20,76,156,42,220,9,244,36,166,209, -131,109,20,76,156,27,168,21,147,171,37,54,112,219,69,19,39,6,234,5,100,232, -73,77,163,133,218,40,153,59,68,117,179,234,201,78,32,5,218,40,153,59,68, -117,179,232,73,78,36,5,90,40,153,56,134,207,171,37,56,160,21,104,162,100, -226,27,62,132,148,226,195,95,182,97,176,218,128,8,84,45,123,38,1,137,10,1, -114,160,64,56,156,199,130,36,160,72,8,39,63,27,24,1,100,180,8,148,146,0,45, -162,137,147,111,2,8,4,16,7,8,96,120,72,13,42,226,145,97,87,224,168,1,58, -182,232,232,64,22,85,181,187,177,107,2,64,7,213,183,74,7,121,207,215,242, -17,119,49,248,94,173,198,210,36,15,232,34,182,84,113,95,115,240,221,91,141, -163,160,72,1,220,164,194,175,121,123,103,224,186,244,64,24,45,68,84,251,33, -9,64,15,217,66,51,209,218,210,129,154,118,254,205,61,65,204,126,23,178,132, -103,165,3,52,237,253,154,122,131,216,254,168,48,6,90,130,1,0,39,75,80,72,8, -9,33,186,130,80,64,76,13,212,19,2,130,96,110,150,173,0,65,6,51,212,20,128, -65,17,11,212,19,130,137,121,211,210,209,144,6,39,75,80,80,0,201,119,234,10, -8,41,86,231,71,80,80,129,79,135,186,122,69,224,34,25,69,233,80,3,91,141, -168,40,96,139,113,180,181,5,36,21,110,54,142,134,160,165,1,176,23,211,47,0, -216,134,233,215,128,111,117,181,104,128,209,3,70,230,106,64,5,139,168,209, -234,10,32,36,144,102,234,136,3,146,27,168,40,160,146,132,103,168,40,192, -115,3,117,5,28,22,113,163,69,168,41,103,1,66,188,17,145,52,40,4,202,113,67, -76,130,227,68,194,13,240,108,0,0,83,96,0,2,161,0,104,146,84,97,48,0,1,78, -192,56,169,24,145,179,192,0,5,48,8,56,16,32,128,56,18,52,125,166,86,147, -182,140,28,50,21,13,39,31,23,60,145,158,56,140,141,47,113,6,155,186,188,24, -49,39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,197,68,14,49, -39,199,197,211,116,240,242,113,197,230,18,180,253,228,3,17,46,18,243,35, -100,128,172,156,114,70,163,146,76,34,248,146,164,108,248,75,204,141,146,28, -217,114,137,27,78,251,241,173,234,162,160,225,1,3,34,92,170,9,105,164,32, -225,64,131,155,1,193,133,7,19,39,22,70,154,103,143,128,0,10,176,20,28,76, -156,113,75,34,78,62,0,0,43,0,48,104,82,146,49,240,0,1,84,11,180,192,0,5, -114,1,18,160,65,24,131,20,145,25,172,48,132,122,28,76,146,218,121,35,180, -69,145,132,108,224,0,0,0,0,0,0,120,31,153,172,56,132,122,28,76,146,218,121, -35,180,69,145,132,108,224,0,0,0,0,0,0,120,31,168,160,45,110,23,30,176,33, -184,0,0,175,32,29,235,2,27,199,23,0,0,22,4,51,88,129,8,244,56,153,37,180, -242,71,104,139,35,8,217,192,0,0,0,0,0,0,240,63,51,88,145,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,0,64,51,88,161,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,0,64,51,88,177,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64,51,88,193,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64,51,88,209,8,244,56, -153,37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64,51,88,225,8,244, -56,153,37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,32,64,32,227,194,0, -97,57,162,4,245,232,5,34,92,35,68,225,161,166,218,16,16,137,112,52,41,73, -29,153,1,65,196,201,197,145,166,153,245,200,3,137,204,120,34,74,8,200,58, -112,28,211,32,130,52,78,26,26,110,248,0,0,164,4,12,70,137,195,39,252,73, -240,117,32,57,168,97,4,104,156,52,52,221,255,160,20,160,152,23,223,250,32, -148,25,174,137,58,23,51,191,244,84,12,50,9,195,39,240,81,238,2,3,107,173, -214,3,192, +1,80,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, +33,8,66,34,33,154,112,0,1,73,247,35,79,91,237,198,174,192,47,31,23,95,17, +13,51,19,35,93,68,216,209,128,0,10,192,174,79,15,32,248,8,196,24,8,107,192, +0,5,98,118,27,94,0,0,43,19,227,94,0,0,43,20,46,215,128,0,10,197,28,198,188, +0,0,86,41,100,53,224,0,2,177,79,85,175,0,0,21,138,154,45,120,0,0,172,85, +217,107,192,0,5,98,182,243,86,193,106,52,127,66,249,50,94,124,35,68,225, +146,49,13,31,170,23,201,146,243,224,200,39,12,145,136,67,134,11,49,0,0,0,0, +0,0,3,225,255,51,0,0,0,0,0,0,3,193,255,47,18,1,172,19,120,71,10,25,196,136, +113,162,156,136,199,42,57,204,144,115,132,240,149,2,248,72,197,209,58,2, +185,16,52,196,225,35,23,68,233,14,228,72,82,68,141,17,56,72,197,209,58,130, +249,44,54,96,191,9,24,186,39,88,79,39,135,147,132,140,93,19,176,35,180,138, +9,216,197,209,59,82,79,31,40,242,1,248,58,42,96,121,14,232,94,62,46,190,15, +38,31,145,33,86,65,76,242,150,143,69,48,242,179,79,45,56,243,51,207,53,64, +243,116,79,57,72,243,180,207,61,80,243,245,79,65,88,244,34,249,50,94,124, +35,68,225,146,39,163,23,201,146,243,224,200,39,12,145,61,40,183,146,37,116, +88,6,136,158,244,241,174,230,202,80,135,130,50,39,16,217,231,208,20,240,70, +68,225,86,224,79,60,64,84,75,141,7,27,157,32,66,37,194,161,168,153,51,132, +9,25,4,225,147,180,138,50,196,18,25,4,225,147,180,138,5,215,49,238,105,27, +60,185,2,72,209,56,100,237,34,140,193,4,136,209,56,100,237,34,129,117,204, +123,154,70,207,50,64,98,72,64,121,51,68,8,163,73,33,1,228,208,16,0,65,112, +152,56,196,159,31,23,77,211,195,201,199,23,150,73,169,234,34,24,49,39,199, +89,188,124,92,242,70,120,224,201,33,69,15,155,163,196,64,153,137,62,58,205, +227,226,231,146,51,199,26,6,18,92,130,64,192,148,144,102,240,23,129,133,18, +2,100,224,160,56,100,42,26,78,62,46,121,35,60,112,216,32,50,21,13,39,31,23, +60,145,154,9,46,18,1,36,64,47,148,64,98,196,132,201,57,68,132,95,18,84,141, +159,9,121,145,178,67,155,46,73,2,17,46,72,128,89,7,199,32,66,37,194,197, +217,35,120,228,131,17,46,18,243,35,100,128,172,156,98,2,40,152,151,32,130, +166,36,248,235,55,143,139,158,72,207,28,150,24,23,46,92,130,80,72,151,21,0, +100,213,103,229,245,8,186,190,144,24,78,136,24,94,152,3,142,9,113,214,111, +31,23,60,145,158,57,164,13,68,184,248,186,110,158,30,78,56,188,226,10,62, +46,121,35,60,113,18,225,27,70,18,32,10,201,208,32,134,214,208,200,84,52, +156,49,39,50,71,107,107,152,129,13,173,161,144,168,105,57,34,78,100,142, +214,215,49,16,134,214,210,220,229,81,252,49,39,50,71,107,107,158,65,13,173, +165,185,202,163,249,34,78,100,142,214,215,60,146,12,16,28,128,62,175,42,6, +143,36,136,16,64,90,242,135,192,129,67,71,147,62,65,5,215,231,214,6,215,62, +180,8,49,1,3,162,92,4,98,12,41,14,67,40,106,229,1,132,130,8,24,78,104,129, +54,62,96,224,144,13,238,124,32,2,62,146,60,51,224,120,146,164,140,137,20,0, +178,58,11,56,192,5,146,208,34,71,64,36,157,25,200,32,52,158,180,8,146,87, +129,232,217,29,5,156,179,224,116,52,100,191,28,87,62,130,214,9,79,136,104, +201,126,56,174,127,0,31,255,225,73,82,71,16,13,1,36,230,18,1,164,14,87,71, +132,0,143,0,210,131,96,31,0,211,6,42,23,50,70,1,167,13,18,14,130,36,67,232, +46,36,29,4,78,69,6,60,226,31,192,7,255,252,24,192,163,11,23,51,130,56,35, +193,56,100,243,31,6,150,46,103,4,225,147,143,114,27,63,57,241,200,169,194, +133,42,166,175,240,6,23,240,0,97,28,17,224,39,233,32,80,142,8,240,78,25,56, +9,250,136,22,39,12,156,123,144,217,240,19,245,18,6,19,154,32,79,214,124,14, +134,140,151,227,139,237,52,11,88,37,62,33,163,37,248,226,251,77,32,213,184, +64,89,56,39,49,224,137,61,196,5,96,38,35,251,200,15,18,61,96,17,62,40,6, +145,1,17,31,228,64,89,45,2,39,205,0,178,122,209,63,162,2,101,64,202,113,67, +77,247,64,92,221,197,186,196,143,4,9,19,208,1,25,187,139,112,128,178,113, +110,177,35,193,2,68,244,0,46,110,229,30,242,71,130,4,137,232,4,35,55,113, +110,16,22,78,81,239,36,120,32,72,158,128,64,147,138,25,249,0,52,72,242,2, +127,2,5,74,96,140,229,203,34,103,250,154,4,17,163,151,44,137,159,234,105,4, +33,162,93,6,73,123,13,1,165,64,202,113,251,33,6,64,14,71,78,20,101,213,207, +4,194,207,2,12,162,0,158,176,23,218,168,23,66,64,255,255,255,255,255,255, +239,127,19,214,33,187,85,2,232,72,0,32,0,0,0,0,0,0,25,136,0,0,0,0,0,0,31, +15,228,122,247,73,19,69,73,180,134,149,13,68,241,0,0,0,0,0,0,3,193,252,143, +90,67,2,104,169,54,144,210,161,168,158,32,0,0,0,0,0,0,120,127,142,73,78,20, +0,0,0,0,0,0,0,0,8,58,189,233,24,77,217,24,93,240,1,230,238,21,23,32,247,68, +13,155,184,75,189,205,35,102,128,47,114,64,185,187,143,137,4,137,33,205, +222,17,6,96,48,87,130,50,37,114,1,246,147,21,143,224,54,186,213,128,114,90, +112,164,0,0,0,0,0,0,124,63,226,117,119,128,25,55,112,96,153,57,41,197,13, +53,224,65,147,119,38,134,19,146,156,80,211,94,5,194,94,6,37,55,113,110,16, +22,78,12,19,39,37,56,161,166,188,14,74,110,226,220,32,44,156,154,24,78,74, +113,67,77,120,32,97,175,4,28,61,224,133,172,186,70,22,248,1,204,73,242,104, +97,47,128,44,196,159,11,69,175,152,32,35,100,33,142,49,39,218,76,69,237,22, +190,96,128,141,144,136,32,196,159,24,230,204,246,66,40,179,18,125,164,196, +206,185,179,61,144,140,28,196,159,6,9,146,200,71,20,98,79,180,152,135,208, +76,150,66,64,99,18,124,24,49,100,36,137,49,39,218,76,67,232,49,100,37,8,49, +39,195,186,145,149,144,150,44,196,159,105,49,31,174,164,101,100,38,10,49, +39,198,33,180,153,37,100,38,141,49,39,218,76,76,234,27,73,146,86,66,112, +163,18,124,145,4,230,142,86,66,120,211,18,125,164,197,46,144,78,104,229, +100,40,15,49,39,198,33,107,68,136,39,52,114,178,20,73,24,147,237,38,38,117, +11,90,36,65,57,163,149,144,164,68,196,159,38,134,19,46,105,56,226,150,68, +157,160,3,200,147,228,208,194,92,32,124,137,62,49,11,90,36,65,57,163,149, +178,166,74,68,159,105,49,51,168,90,209,34,9,205,28,173,149,65,82,36,249,34, +9,205,28,173,175,170,54,68,159,105,49,75,164,19,154,57,91,95,88,84,137,62, +49,13,164,201,43,111,235,141,145,39,218,76,76,234,27,73,146,86,223,216,17, +34,79,135,117,35,43,115,236,139,145,39,218,76,71,235,169,25,91,159,104,60, +137,62,12,19,37,178,182,42,68,159,105,49,15,160,153,45,149,193,18,36,248, +199,54,103,182,190,232,185,18,125,164,196,206,185,179,61,181,247,133,200, +147,225,104,181,243,4,4,109,191,190,58,68,159,105,49,23,180,90,249,130,2, +54,223,224,67,152,147,230,8,8,217,12,16,121,18,124,193,1,27,101,131,131,56, +7,38,193,198,72,0,0,0,0,0,0,0,0,198,231,240,134,39,63,136,151,95,63,136,49, +89,252,66,98,243,248,133,96,132,185,5,224,32,36,201,41,248,200,213,249,0, +131,64,7,39,192,218,148,124,137,74,216,231,198,227,141,182,124,78,40,217, +231,197,227,4,213,227,192,159,72,10,5,21,218,138,120,74,129,124,36,98,232, +228,74,81,62,160,20,10,107,181,21,114,32,105,137,194,70,46,142,68,165,19, +235,1,64,170,187,81,119,34,66,146,36,104,137,194,70,46,142,68,165,19,236,1, +64,174,187,81,95,37,134,204,23,225,35,23,71,34,82,137,246,128,160,89,93, +168,167,147,195,201,194,70,46,142,68,165,19,238,1,64,182,187,81,71,105,20, +19,177,139,163,145,41,68,16,7,6,15,82,70,72,115,96,0,0,0,0,0,93,105,160,91, +60,149,195,200,194,8,134,149,216,114,1,128,83,192,144,8,194,195,16,12,168, +110,20,120,12,141,22,16,120,12,100,22,12,120,28,78,99,192,41,224,136,115, +36,14,100,197,213,245,193,48,189,112,40,2,237,96,175,131,117,2,178,112,145, +139,163,145,131,114,70,46,142,218,27,182,72,197,209,219,56,26,53,161,166, +28,1,204,178,10,14,38,78,44,141,52,207,31,0,0,21,64,129,100,180,8,148,145, +92,203,176,160,226,100,226,200,211,76,241,240,0,1,84,2,131,137,147,142,41, +100,73,199,192,0,5,88,6,13,10,82,70,62,0,0,42,66,88,115,18,124,67,103,177, +69,49,130,12,73,242,136,108,246,40,165,177,6,36,248,134,207,71,90,138,99, +68,152,147,229,16,217,232,235,81,75,130,12,73,241,13,158,158,149,20,199,9, +49,39,202,33,179,211,210,162,151,69,24,147,225,86,224,79,79,74,138,94,20, +98,79,133,91,129,61,109,74,41,124,60,137,62,33,179,216,166,216,193,18,36, +249,68,54,123,20,218,216,137,18,124,67,103,163,173,77,177,162,100,73,242, +136,108,244,117,169,181,193,18,36,248,134,207,79,74,155,99,132,200,147,229, +16,217,233,233,83,107,162,164,73,240,171,112,39,167,165,77,175,10,145,39, +194,173,192,158,182,165,54,191,153,51,72,71,161,196,201,45,167,146,59,68, +89,24,70,206,0,0,0,0,0,0,7,129,249,153,51,104,71,161,196,201,45,167,146,59, +68,89,24,70,206,0,0,0,0,0,0,7,129,249,153,51,136,71,161,196,201,45,167,146, +59,68,89,24,70,206,0,0,0,0,0,0,7,129,249,153,51,168,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,2,1,153,51,200,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,2,1,153,51,232,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,153,52,8,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,153,52,40,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,153,52,72,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,1,2,1,135,52,102,32,76,72,1,246,136,235, +103,177,69,1,17,32,7,196,54,123,20,82,88,200,144,3,237,17,214,207,71,91, +171,37,20,65,145,32,7,218,35,173,158,142,183,66,74,41,16,92,72,1,241,13, +158,142,183,86,74,41,48,92,72,1,241,13,158,142,183,66,74,41,80,100,72,1, +246,136,235,103,167,165,213,146,138,40,200,144,3,237,17,214,207,79,75,161, +37,20,138,46,36,0,248,134,207,79,75,171,37,20,154,46,36,0,248,134,207,79, +75,161,37,20,170,46,36,0,248,85,184,19,234,201,69,24,92,72,1,240,171,112, +39,208,146,138,70,25,18,0,124,27,168,21,147,171,37,20,113,145,32,7,193,186, +129,89,58,18,81,72,226,162,64,15,180,71,91,62,172,148,90,0,168,144,3,237, +17,214,207,161,37,22,144,38,36,0,248,134,207,171,37,22,160,38,36,0,248,134, +207,161,37,22,176,42,209,68,201,218,35,173,158,197,54,4,218,40,153,56,134, +207,98,155,75,27,104,162,100,237,17,214,207,71,91,171,37,54,65,182,138,38, +78,209,29,108,244,117,186,18,83,104,131,45,20,76,156,67,103,163,173,213, +146,155,76,25,104,162,100,226,27,61,29,110,132,148,218,160,219,69,19,39, +104,142,182,122,122,93,89,41,178,141,180,81,50,118,136,235,103,167,165,208, +146,155,69,25,104,162,100,226,27,61,61,46,172,148,218,104,203,69,19,39,16, +217,233,233,116,36,166,213,70,90,40,153,56,85,184,19,234,201,77,152,101, +162,137,147,133,91,129,62,132,148,218,48,219,69,19,39,6,234,5,100,234,201, +77,156,109,162,137,147,131,117,2,178,116,36,166,209,197,218,40,153,59,68, +117,179,234,201,78,32,11,180,81,50,118,136,235,103,208,146,156,72,21,104, +162,100,226,27,62,172,148,226,128,171,69,19,39,16,217,244,36,167,22,53,123, +102,53,155,80,2,21,11,94,201,128,196,133,0,185,80,32,56,156,199,130,36,160, +72,16,78,126,54,48,5,146,208,34,82,72,1,109,20,76,155,120,28,34,1,225,32, +52,171,138,69,133,95,130,160,4,234,219,163,161,0,89,86,214,238,197,172,9,0, +31,86,221,40,29,231,63,95,200,69,220,199,225,122,183,27,72,144,63,160,138, +217,81,197,125,207,195,117,110,54,142,129,32,7,114,147,10,189,229,237,159, +130,235,209,0,96,181,17,83,236,132,37,0,63,101,8,207,71,107,74,6,105,219, +251,52,245,7,49,248,94,202,17,158,148,12,211,183,246,105,234,15,99,242,159, +129,228,176,192,185,127,46,155,185,41,197,13,55,38,3,127,255,20,138,160, +192,25,106,8,8,1,58,90,130,64,128,146,27,168,37,8,9,129,186,130,96,160,152, +27,165,171,64,32,131,25,234,10,64,65,17,11,212,19,133,18,243,167,165,163, +32,24,157,45,65,64,6,75,191,80,80,66,149,110,116,117,5,8,41,240,247,79,72, +188,8,134,81,122,84,1,173,198,212,20,48,139,113,180,181,5,36,42,220,109,29, +13,65,74,6,192,95,76,188,6,196,55,78,188,6,247,91,86,136,26,32,104,220,205, +72,1,98,234,52,122,130,136,18,72,51,117,68,3,146,27,168,40,161,37,8,207,80, +81,129,204,13,212,20,112,179,141,26,45,65,75,112,20,43,193,25,19,66,128, +153,78,40,105,144,92,104,152,131,124,27,253,128,0,10,116,3,68,146,163,9, +128,0,10,102,3,138,145,137,27,60,0,0,82,129,7,2,4,16,7,2,70,143,178,203, +164,237,35,14,25,10,134,147,143,139,158,72,207,28,54,77,47,109,13,55,113, +120,96,196,159,29,102,241,241,115,201,25,227,131,36,133,20,62,110,143,17, +16,113,137,62,62,46,155,167,135,147,142,47,44,151,79,221,64,98,37,194,94, +100,108,144,21,147,140,73,168,228,19,17,124,73,82,54,124,37,230,70,201,14, +108,185,36,155,14,243,243,83,212,69,131,132,4,12,137,114,168,37,166,145,7, +10,4,28,200,14,12,40,56,153,56,178,52,211,60,124,0,0,85,0,160,226,100,227, +138,89,18,113,240,0,1,86,1,131,66,148,145,143,128,0,10,144,93,134,0,0,43, +80,17,42,4,17,136,49,73,19,49,134,16,143,67,137,146,91,79,36,118,136,178, +48,141,156,0,0,0,0,0,0,15,3,243,49,135,16,143,67,137,146,91,79,36,118,136, +178,48,141,156,0,0,0,0,0,0,15,3,245,20,5,173,194,227,214,4,55,0,0,21,196,7, +122,192,134,241,197,192,0,5,121,25,140,64,132,122,28,76,146,218,121,35,180, +69,145,132,108,224,0,0,0,0,0,0,120,31,153,140,72,132,122,28,76,146,218,121, +35,180,69,145,132,108,224,0,0,0,0,0,0,0,32,25,140,80,132,122,28,76,146,218, +121,35,180,69,145,132,108,224,0,0,0,0,0,0,0,32,25,140,88,132,122,28,76,146, +218,121,35,180,69,145,132,108,224,0,0,0,0,0,0,8,32,25,140,96,132,122,28,76, +146,218,121,35,180,69,145,132,108,224,0,0,0,0,0,0,8,32,25,140,104,132,122, +28,76,146,218,121,35,180,69,145,132,108,224,0,0,0,0,0,0,8,32,25,140,112, +132,122,28,76,146,218,121,35,180,69,145,132,108,224,0,0,0,0,0,0,16,32,16, +113,225,0,48,156,209,2,122,244,5,34,92,35,68,225,161,166,218,16,33,18,224, +104,82,146,59,50,5,7,19,39,22,70,154,103,215,32,28,78,99,193,18,80,70,131, +165,1,205,34,8,35,68,225,161,166,239,255,4,12,70,137,195,39,248,73,7,78,3, +154,102,16,70,137,195,67,77,223,248,1,74,9,129,125,255,130,9,65,154,232, +147,161,115,59,255,5,64,195,32,156,50,126,197,14,2,3,107,173,213,0, }; #elif defined(DUK_USE_DOUBLE_BE) -DUK_INTERNAL const duk_uint8_t duk_builtins_data[4116] = { -144,148,105,224,32,68,52,228,62,12,104,200,165,132,52,167,194,138,105,243, -124,57,28,211,57,18,64,52,238,126,44,138,111,171,241,164,19,87,129,30,33, +DUK_INTERNAL const duk_uint8_t duk_builtins_data[3972] = { +144,148,105,223,160,68,52,228,62,12,104,200,165,132,52,167,194,138,105,242, +252,57,28,211,57,18,64,52,238,62,44,138,111,171,241,164,19,87,125,30,33, 167,16,145,159,8,211,136,9,225,42,5,240,145,139,163,163,8,211,136,10,228, 64,211,19,132,140,93,29,56,70,156,64,119,34,66,146,36,104,137,194,70,46, 142,172,35,78,32,47,146,195,102,11,240,145,139,163,175,8,211,136,9,228,240, 242,112,145,139,163,179,8,211,136,8,237,34,130,118,49,116,118,225,26,48,0, -1,82,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, -33,8,66,26,179,233,97,167,60,150,34,33,154,112,0,1,75,247,35,79,95,237,198, -174,200,47,31,23,95,17,13,51,19,35,93,68,216,209,128,0,10,208,174,79,15,32, -248,8,196,24,8,107,192,0,5,106,118,27,94,0,0,43,83,227,94,0,0,43,84,46,215, -128,0,10,213,28,198,188,0,0,86,169,100,53,224,0,2,181,79,85,175,0,0,21,170, -154,45,120,0,0,173,85,217,107,192,0,5,106,182,243,86,193,106,52,127,130, -249,50,94,124,35,68,225,146,49,13,31,186,23,201,146,243,224,200,39,12,145, -136,67,134,19,49,1,255,224,0,0,0,0,0,3,51,1,255,192,0,0,0,0,0,3,47,18,1, -172,19,120,71,10,25,196,136,113,162,156,136,199,42,57,204,144,115,132,240, -149,2,248,72,197,209,58,2,185,16,52,196,225,35,23,68,233,14,228,72,82,68, -141,17,56,72,197,209,58,130,249,44,54,96,191,9,24,186,39,88,79,39,135,147, -132,140,93,19,176,35,180,138,9,216,197,209,59,82,79,35,40,242,65,248,58,42, -96,121,14,232,94,62,46,190,15,42,31,145,33,86,65,76,242,214,143,73,48,242, -243,79,49,56,243,115,207,57,64,243,180,79,61,72,243,244,207,65,80,244,53, -79,69,88,244,98,30,8,200,156,67,102,120,241,79,4,100,78,21,110,4,207,32,47, -147,37,231,194,52,78,25,34,122,81,124,153,47,62,12,130,112,201,19,211,139, -121,34,87,69,128,104,137,239,83,18,238,108,165,2,162,92,104,56,220,233,1,8, -151,10,134,162,100,206,16,18,50,9,195,39,105,20,101,136,18,25,4,225,147, -180,138,5,215,49,238,105,27,60,185,1,36,104,156,50,118,145,70,96,129,34,52, -78,25,59,72,160,93,115,30,230,145,179,204,144,12,73,8,15,38,104,128,138,52, -146,16,30,77,1,0,2,11,132,193,198,36,248,248,186,110,158,30,78,56,188,194, -70,183,170,136,48,98,79,142,179,120,248,185,228,140,241,193,146,66,138,31, -55,71,138,128,153,137,62,58,205,227,226,231,146,51,199,26,6,18,92,146,64, -96,74,72,51,120,43,192,97,68,128,153,56,72,7,12,133,67,73,199,197,207,36, -103,142,35,2,3,33,80,210,113,241,115,201,25,160,146,225,160,9,34,1,124,178, -1,139,18,19,36,229,146,8,190,36,169,27,62,18,243,35,100,135,54,92,162,2,17, -46,72,128,89,7,200,32,33,18,225,98,236,145,188,130,64,196,75,132,188,200, -217,32,43,39,28,128,69,19,18,228,144,42,98,79,142,179,120,248,185,228,140, -241,201,97,129,114,229,201,37,2,68,184,200,1,147,93,159,153,213,34,235,250, -96,48,157,32,24,94,160,1,199,4,184,235,55,143,139,158,72,207,28,226,3,81, -46,62,46,155,167,135,147,142,47,60,129,71,197,207,36,103,142,34,92,35,104, -194,68,1,89,58,36,8,109,109,12,133,67,73,195,18,115,36,118,182,185,168,8, -109,109,12,133,67,73,201,18,115,36,118,182,185,168,130,27,91,75,115,149,71, -240,196,156,201,29,173,174,129,2,27,91,75,115,149,71,242,68,156,201,29,173, -174,129,34,12,16,28,128,62,191,42,3,71,146,68,4,16,22,188,161,240,16,40, -104,242,103,196,16,93,158,125,96,110,115,235,64,131,16,16,58,37,192,70,32, -194,144,114,25,67,95,40,6,18,8,32,48,156,209,2,108,124,96,224,144,6,247,62, -16,0,143,164,143,12,248,15,18,84,145,145,34,128,11,35,160,179,140,0,44,150, -129,18,58,0,146,116,103,32,128,105,61,104,17,36,175,1,232,217,29,5,156,179, -224,58,26,50,95,142,43,159,64,181,130,83,226,26,50,95,142,43,159,192,7,255, -248,41,42,72,226,1,160,18,78,97,32,26,64,114,186,60,32,4,120,6,148,13,128, -124,3,76,12,84,46,100,140,3,78,13,18,14,130,36,67,232,23,18,14,130,39,34, -131,30,113,15,224,3,255,253,6,48,40,194,197,204,224,142,8,240,78,25,60,231, -192,210,197,204,224,156,50,113,238,67,103,232,62,28,138,156,104,82,170,107, -255,32,48,191,144,1,132,112,71,128,159,168,128,161,28,17,224,156,50,112,19, -245,144,22,39,12,156,123,144,217,240,19,245,146,3,9,205,16,39,236,62,3,161, -163,37,248,226,251,141,1,107,4,167,196,52,100,191,28,95,113,164,13,91,132, -5,147,130,115,30,8,147,222,64,43,1,49,31,224,64,60,72,245,128,68,249,32,13, -34,2,34,63,204,128,89,45,2,39,209,0,89,61,104,159,213,0,153,80,50,156,80, -211,126,16,11,155,184,183,88,145,224,129,34,122,64,17,155,184,183,8,11,39, -22,235,18,60,16,36,79,72,1,115,119,40,247,146,60,16,36,79,72,32,140,221, -197,184,64,89,57,71,188,145,224,129,34,122,65,1,39,20,51,244,0,52,72,242,2, -127,18,2,165,48,70,114,229,145,51,253,141,1,4,104,229,203,34,103,251,26,64, -132,52,75,160,201,47,105,160,26,84,12,167,31,186,8,50,0,114,58,113,163,46, -190,120,35,11,60,4,25,68,81,61,96,47,181,80,46,132,128,255,223,255,255,255, -255,255,254,39,172,67,118,170,5,208,144,0,0,0,0,0,0,0,0,115,16,31,254,0,0, -0,0,0,0,8,245,238,146,38,138,147,105,13,42,26,137,226,3,255,128,0,0,0,0,0, -1,30,180,134,4,209,82,109,33,165,67,81,60,64,255,240,0,0,0,0,0,0,15,210,62, -72,91,155,0,242,192,0,0,0,0,0,0,135,88,11,237,72,5,38,210,27,50,24,145,128, -134,127,255,255,255,255,255,254,67,172,67,118,164,2,147,105,13,153,12,72, -192,195,63,255,255,255,255,255,255,16,240,70,68,226,27,51,199,138,120,35, -34,112,171,112,38,121,7,16,137,112,168,106,38,77,193,1,40,151,16,217,144, -196,142,224,144,21,18,227,65,198,238,9,67,81,46,72,5,39,16,217,144,196,142, -224,152,228,148,227,64,0,0,0,0,0,0,0,0,131,175,223,16,194,111,8,97,119,224, -3,205,220,42,46,65,238,200,13,155,184,75,189,205,35,102,128,47,116,64,92, -221,199,196,130,68,144,230,239,72,65,152,12,21,224,140,137,92,128,62,210, -98,177,252,3,107,173,88,3,146,211,141,33,255,224,0,0,0,0,0,3,19,175,188,0, -100,221,193,130,100,228,167,20,52,215,129,3,38,238,77,12,39,37,56,161,166, -188,10,194,94,6,18,155,184,183,8,11,39,6,9,147,146,156,80,211,94,7,18,155, -184,183,8,11,39,38,134,19,146,156,80,211,94,8,12,53,224,130,195,222,8,77, -133,210,24,91,224,3,152,147,228,208,194,95,0,44,196,159,11,69,175,152,32, -35,100,33,135,24,147,237,38,34,246,139,95,48,64,70,200,68,8,49,39,198,57, -179,61,144,138,22,98,79,180,152,153,215,54,103,178,17,129,204,73,240,96, -153,44,132,112,163,18,125,164,196,62,130,100,178,18,1,140,73,240,96,197, -144,146,18,98,79,180,152,135,208,98,200,74,8,49,39,195,186,145,149,144,150, -22,98,79,180,152,143,215,82,50,178,19,2,140,73,241,136,109,38,73,89,9,161, -166,36,251,73,137,157,67,105,50,74,200,78,10,49,39,201,16,78,104,229,100, -39,134,152,147,237,38,41,116,130,115,71,43,33,64,60,196,159,24,133,173,18, -32,156,209,202,200,81,18,49,39,218,76,76,234,22,180,72,130,115,71,43,33,72, -68,196,159,38,134,19,46,105,56,226,150,68,157,160,1,228,73,242,104,97,46, -16,31,34,79,140,66,214,137,16,78,104,229,108,169,137,72,147,237,38,38,117, -11,90,36,65,57,163,149,178,168,21,34,79,146,32,156,209,202,218,250,161,178, -36,251,73,138,93,32,156,209,202,218,250,193,82,36,248,196,54,147,36,173, -191,174,27,34,79,180,152,153,212,54,147,36,173,191,176,17,34,79,135,117,35, -43,115,236,133,200,147,237,38,35,245,212,140,173,207,180,15,34,79,131,4, -201,108,173,133,72,147,237,38,33,244,19,37,178,184,17,34,79,140,115,102, -123,107,238,133,200,147,237,38,38,117,205,153,237,175,188,23,34,79,133,162, -215,204,16,17,182,254,248,116,137,62,210,98,47,104,181,243,4,4,109,191,192, -131,152,147,230,8,8,217,12,16,60,137,62,96,128,141,178,193,160,206,1,201, -176,113,146,0,0,0,0,0,0,0,0,49,185,252,65,137,207,227,37,215,207,227,12,86, -127,24,152,188,254,49,88,33,46,65,120,72,4,153,37,63,33,13,127,148,4,26,0, -57,62,6,228,163,228,74,86,215,62,55,28,110,179,226,113,70,223,62,47,24,38, -191,30,2,125,32,40,20,87,114,41,225,42,5,240,145,139,163,145,41,68,250,128, -80,41,174,228,85,200,129,166,39,9,24,186,57,18,148,79,172,5,2,170,238,69, -220,137,10,72,145,162,39,9,24,186,57,18,148,79,176,5,2,186,238,69,124,150, -27,48,95,132,140,93,28,137,74,39,218,2,129,101,119,34,158,79,15,39,9,24, -186,57,18,148,79,184,5,2,218,238,69,29,164,80,78,198,46,142,68,165,16,64, -28,24,61,73,25,33,205,128,129,167,166,0,0,0,0,1,108,242,151,15,39,8,34,26, -87,97,200,3,0,167,129,32,8,194,195,16,6,84,55,10,60,3,35,69,132,30,1,140, -130,193,143,1,196,230,60,2,158,8,131,153,64,115,42,46,191,176,8,194,246,0, -80,5,220,193,95,6,234,5,100,225,35,23,71,35,6,228,140,93,29,180,55,108,145, -139,163,182,112,52,107,67,76,56,3,153,132,20,28,76,156,89,26,105,158,62,0, -0,42,193,2,201,104,17,41,34,156,204,176,160,226,100,226,200,211,76,241,240, -0,1,86,2,131,137,147,142,41,100,73,199,192,0,5,96,6,13,10,82,70,62,0,0,42, -130,88,115,18,124,67,103,177,69,49,129,6,36,249,68,54,123,20,82,216,65,137, -62,33,179,209,214,162,152,208,147,18,124,162,27,61,29,106,41,112,32,196, -159,16,217,233,233,81,76,112,73,137,62,81,13,158,158,149,20,186,20,98,79, -133,91,129,61,61,42,41,120,40,196,159,10,183,2,122,218,148,82,248,60,137, -62,33,179,216,166,216,192,137,18,124,162,27,61,138,109,108,34,68,159,16, -217,232,235,83,108,104,76,137,62,81,13,158,142,181,54,184,17,34,79,136,108, -244,244,169,182,56,38,68,159,40,134,207,79,74,155,93,10,145,39,194,173,192, -158,158,149,54,188,21,34,79,133,91,129,61,109,74,109,125,155,51,136,71,161, -196,201,45,167,146,59,68,89,24,70,206,1,255,128,0,0,0,0,0,1,155,51,168,71, -161,196,201,45,167,146,59,68,89,24,70,206,1,255,128,0,0,0,0,0,1,155,51,200, -71,161,196,201,45,167,146,59,68,89,24,70,206,1,255,128,0,0,0,0,0,1,155,51, -232,71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,0,0,0,0,0,0,1,155,52, -8,71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,0,0,0,0,0,0,1,155,52,40, -71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,128,0,0,0,0,0,1,155,52,72, -71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,128,0,0,0,0,0,1,155,52, -104,71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,128,0,0,0,0,0,1,155, -52,136,71,161,196,201,45,167,146,59,68,89,24,70,206,2,1,0,0,0,0,0,0,1,135, -52,166,32,76,72,1,246,136,235,103,177,69,0,136,144,3,226,27,61,138,41,44, -50,36,0,251,68,117,179,209,214,234,201,69,16,50,36,0,251,68,117,179,209, -214,232,73,69,34,5,196,128,31,16,217,232,235,117,100,162,147,2,226,64,15, -136,108,244,117,186,18,81,74,129,145,32,7,218,35,173,158,158,151,86,74,40, -161,145,32,7,218,35,173,158,158,151,66,74,41,20,46,36,0,248,134,207,79,75, -171,37,20,154,23,18,0,124,67,103,167,165,208,146,138,85,11,137,0,62,21,110, -4,250,178,81,70,11,137,0,62,21,110,4,250,18,81,72,193,145,32,7,193,186,129, -89,58,178,81,71,12,137,0,62,13,212,10,201,208,146,138,71,10,137,0,62,209, -29,108,250,178,81,104,1,81,32,7,218,35,173,159,66,74,45,32,38,36,0,248,134, -207,171,37,22,160,19,18,0,124,67,103,208,146,139,88,10,180,81,50,118,136, -235,103,177,77,128,155,69,19,39,16,217,236,83,105,97,182,138,38,78,209,29, -108,244,117,186,178,83,100,13,180,81,50,118,136,235,103,163,173,208,146, -155,68,12,180,81,50,113,13,158,142,183,86,74,109,48,50,209,68,201,196,54, -122,58,221,9,41,181,64,219,69,19,39,104,142,182,122,122,93,89,41,178,134, -218,40,153,59,68,117,179,211,210,232,73,77,162,134,90,40,153,56,134,207,79, -75,171,37,54,154,25,104,162,100,226,27,61,61,46,132,148,218,168,101,162, -137,147,133,91,129,62,172,148,217,131,45,20,76,156,42,220,9,244,36,166,209, -131,109,20,76,156,27,168,21,147,171,37,54,112,219,69,19,39,6,234,5,100,232, -73,77,163,133,218,40,153,59,68,117,179,234,201,78,32,5,218,40,153,59,68, -117,179,232,73,78,36,5,90,40,153,56,134,207,171,37,56,160,21,104,162,100, -226,27,62,132,148,226,195,95,182,97,176,218,128,8,84,45,123,38,1,137,10,1, -114,160,64,56,156,199,130,36,160,72,8,39,63,27,24,1,100,180,8,148,146,0,45, -162,137,147,111,2,8,4,16,7,8,96,120,72,8,0,183,225,81,98,138,237,33,58,182, -232,232,64,64,2,107,177,187,181,85,22,7,213,183,74,1,255,49,114,23,247,209, -207,120,94,173,198,210,36,3,255,113,84,118,82,184,47,224,221,91,141,163, -160,72,7,251,121,111,98,164,220,161,192,186,244,64,64,9,33,251,84,68,45,24, -15,217,66,51,209,218,210,128,127,205,65,60,204,254,119,154,23,178,132,103, -165,0,255,218,130,121,153,252,239,54,168,48,6,90,130,1,0,39,75,80,72,8,9, -33,186,130,80,64,76,13,212,19,2,130,96,110,150,173,0,65,6,51,212,20,128,65, -17,11,212,19,130,137,121,211,210,209,144,6,39,75,80,80,0,201,119,234,10,8, -41,86,231,71,80,80,129,79,135,186,122,69,224,34,25,69,233,80,3,91,141,168, -40,96,139,113,180,181,5,36,21,110,54,142,134,160,165,1,176,23,211,47,0,216, -134,233,215,128,111,117,181,104,128,209,3,70,230,106,64,5,139,168,209,234, -10,32,36,144,102,234,136,3,146,27,168,40,160,146,132,103,168,40,192,115,3, -117,5,28,22,113,163,69,168,41,103,1,66,188,17,145,52,40,4,202,113,67,76, -130,227,68,194,13,240,108,0,0,83,96,0,2,161,0,104,146,84,97,48,0,1,78,192, -56,169,24,145,179,192,0,5,48,8,56,16,32,128,56,18,52,125,166,86,147,182, -140,28,50,21,13,39,31,23,60,145,158,56,140,141,47,113,6,155,186,188,24,49, -39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,197,68,14,49,39, -199,197,211,116,240,242,113,197,230,18,180,253,228,3,17,46,18,243,35,100, -128,172,156,114,70,163,146,76,34,248,146,164,108,248,75,204,141,146,28,217, -114,137,27,78,251,241,173,234,162,160,225,1,3,34,92,170,9,105,164,32,225, -64,131,155,1,193,133,7,19,39,22,70,154,103,143,128,0,10,176,20,28,76,156, -113,75,34,78,62,0,0,43,0,48,104,82,146,49,240,0,1,84,11,180,192,0,5,114,1, -18,160,65,24,131,20,145,25,172,48,132,122,28,76,146,218,121,35,180,69,145, -132,108,224,31,248,0,0,0,0,0,0,25,172,56,132,122,28,76,146,218,121,35,180, -69,145,132,108,224,31,248,0,0,0,0,0,0,40,160,45,110,23,30,176,33,184,0,0, -175,32,29,235,2,27,199,23,0,0,22,4,51,88,129,8,244,56,153,37,180,242,71, -104,139,35,8,217,192,63,240,0,0,0,0,0,0,51,88,145,8,244,56,153,37,180,242, -71,104,139,35,8,217,192,64,0,0,0,0,0,0,0,51,88,161,8,244,56,153,37,180,242, -71,104,139,35,8,217,192,64,0,0,0,0,0,0,0,51,88,177,8,244,56,153,37,180,242, -71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51,88,193,8,244,56,153,37,180, -242,71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51,88,209,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51,88,225,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,64,32,0,0,0,0,0,0,32,227,194,0,97,57, -162,4,245,232,5,34,92,35,68,225,161,166,218,16,16,137,112,52,41,73,29,153, -1,65,196,201,197,145,166,153,245,200,3,137,204,120,34,74,8,200,58,112,28, -211,32,130,52,78,26,26,110,248,0,0,164,4,12,70,137,195,39,252,73,240,117, -32,57,168,97,4,104,156,52,52,221,255,160,20,160,152,23,223,250,32,148,25, -174,137,58,23,51,191,244,84,12,50,9,195,39,240,81,238,2,3,107,173,214,3, -192, +1,80,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, +33,8,66,34,33,154,112,0,1,73,247,35,79,91,237,198,174,192,47,31,23,95,17, +13,51,19,35,93,68,216,209,128,0,10,192,174,79,15,32,248,8,196,24,8,107,192, +0,5,98,118,27,94,0,0,43,19,227,94,0,0,43,20,46,215,128,0,10,197,28,198,188, +0,0,86,41,100,53,224,0,2,177,79,85,175,0,0,21,138,154,45,120,0,0,172,85, +217,107,192,0,5,98,182,243,86,193,106,52,127,66,249,50,94,124,35,68,225, +146,49,13,31,170,23,201,146,243,224,200,39,12,145,136,67,134,11,49,1,255, +224,0,0,0,0,0,3,51,1,255,192,0,0,0,0,0,3,47,18,1,172,19,120,71,10,25,196, +136,113,162,156,136,199,42,57,204,144,115,132,240,149,2,248,72,197,209,58, +2,185,16,52,196,225,35,23,68,233,14,228,72,82,68,141,17,56,72,197,209,58, +130,249,44,54,96,191,9,24,186,39,88,79,39,135,147,132,140,93,19,176,35,180, +138,9,216,197,209,59,82,79,31,40,242,1,248,58,42,96,121,14,232,94,62,46, +190,15,38,31,145,33,86,65,76,242,150,143,69,48,242,179,79,45,56,243,51,207, +53,64,243,116,79,57,72,243,180,207,61,80,243,245,79,65,88,244,34,249,50,94, +124,35,68,225,146,39,163,23,201,146,243,224,200,39,12,145,61,40,183,146,37, +116,88,6,136,158,244,241,174,230,202,80,135,130,50,39,16,217,231,208,20, +240,70,68,225,86,224,79,60,64,84,75,141,7,27,157,32,66,37,194,161,168,153, +51,132,9,25,4,225,147,180,138,50,196,18,25,4,225,147,180,138,5,215,49,238, +105,27,60,185,2,72,209,56,100,237,34,140,193,4,136,209,56,100,237,34,129, +117,204,123,154,70,207,50,64,98,72,64,121,51,68,8,163,73,33,1,228,208,16,0, +65,112,152,56,196,159,31,23,77,211,195,201,199,23,150,73,169,234,34,24,49, +39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,196,64,153,137,62, +58,205,227,226,231,146,51,199,26,6,18,92,130,64,192,148,144,102,240,23,129, +133,18,2,100,224,160,56,100,42,26,78,62,46,121,35,60,112,216,32,50,21,13, +39,31,23,60,145,154,9,46,18,1,36,64,47,148,64,98,196,132,201,57,68,132,95, +18,84,141,159,9,121,145,178,67,155,46,73,2,17,46,72,128,89,7,199,32,66,37, +194,197,217,35,120,228,131,17,46,18,243,35,100,128,172,156,98,2,40,152,151, +32,130,166,36,248,235,55,143,139,158,72,207,28,150,24,23,46,92,130,80,72, +151,21,0,100,213,103,229,245,8,186,190,144,24,78,136,24,94,152,3,142,9,113, +214,111,31,23,60,145,158,57,164,13,68,184,248,186,110,158,30,78,56,188,226, +10,62,46,121,35,60,113,18,225,27,70,18,32,10,201,208,32,134,214,208,200,84, +52,156,49,39,50,71,107,107,152,129,13,173,161,144,168,105,57,34,78,100,142, +214,215,49,16,134,214,210,220,229,81,252,49,39,50,71,107,107,158,65,13,173, +165,185,202,163,249,34,78,100,142,214,215,60,146,12,16,28,128,62,175,42,6, +143,36,136,16,64,90,242,135,192,129,67,71,147,62,65,5,215,231,214,6,215,62, +180,8,49,1,3,162,92,4,98,12,41,14,67,40,106,229,1,132,130,8,24,78,104,129, +54,62,96,224,144,13,238,124,32,2,62,146,60,51,224,120,146,164,140,137,20,0, +178,58,11,56,192,5,146,208,34,71,64,36,157,25,200,32,52,158,180,8,146,87, +129,232,217,29,5,156,179,224,116,52,100,191,28,87,62,130,214,9,79,136,104, +201,126,56,174,127,0,31,255,225,73,82,71,16,13,1,36,230,18,1,164,14,87,71, +132,0,143,0,210,131,96,31,0,211,6,42,23,50,70,1,167,13,18,14,130,36,67,232, +46,36,29,4,78,69,6,60,226,31,192,7,255,252,24,192,163,11,23,51,130,56,35, +193,56,100,243,31,6,150,46,103,4,225,147,143,114,27,63,57,241,200,169,194, +133,42,166,175,240,6,23,240,0,97,28,17,224,39,233,32,80,142,8,240,78,25,56, +9,250,136,22,39,12,156,123,144,217,240,19,245,18,6,19,154,32,79,214,124,14, +134,140,151,227,139,237,52,11,88,37,62,33,163,37,248,226,251,77,32,213,184, +64,89,56,39,49,224,137,61,196,5,96,38,35,251,200,15,18,61,96,17,62,40,6, +145,1,17,31,228,64,89,45,2,39,205,0,178,122,209,63,162,2,101,64,202,113,67, +77,247,64,92,221,197,186,196,143,4,9,19,208,1,25,187,139,112,128,178,113, +110,177,35,193,2,68,244,0,46,110,229,30,242,71,130,4,137,232,4,35,55,113, +110,16,22,78,81,239,36,120,32,72,158,128,64,147,138,25,249,0,52,72,242,2, +127,2,5,74,96,140,229,203,34,103,250,154,4,17,163,151,44,137,159,234,105,4, +33,162,93,6,73,123,13,1,165,64,202,113,251,33,6,64,14,71,78,20,101,213,207, +4,194,207,2,12,162,0,158,176,23,218,168,23,66,64,127,239,255,255,255,255, +255,255,19,214,33,187,85,2,232,72,0,0,0,0,0,0,0,0,57,136,15,255,0,0,0,0,0, +0,4,122,247,73,19,69,73,180,134,149,13,68,241,1,255,192,0,0,0,0,0,0,143,90, +67,2,104,169,54,144,210,161,168,158,32,127,248,0,0,0,0,0,0,14,73,78,20,0,0, +0,0,0,0,0,0,8,58,189,233,24,77,217,24,93,240,1,230,238,21,23,32,247,68,13, +155,184,75,189,205,35,102,128,47,114,64,185,187,143,137,4,137,33,205,222, +17,6,96,48,87,130,50,37,114,1,246,147,21,143,224,54,186,213,128,114,90,112, +164,63,252,0,0,0,0,0,0,98,117,119,128,25,55,112,96,153,57,41,197,13,53,224, +65,147,119,38,134,19,146,156,80,211,94,5,194,94,6,37,55,113,110,16,22,78, +12,19,39,37,56,161,166,188,14,74,110,226,220,32,44,156,154,24,78,74,113,67, +77,120,32,97,175,4,28,61,224,133,172,186,70,22,248,1,204,73,242,104,97,47, +128,44,196,159,11,69,175,152,32,35,100,33,142,49,39,218,76,69,237,22,190, +96,128,141,144,136,32,196,159,24,230,204,246,66,40,179,18,125,164,196,206, +185,179,61,144,140,28,196,159,6,9,146,200,71,20,98,79,180,152,135,208,76, +150,66,64,99,18,124,24,49,100,36,137,49,39,218,76,67,232,49,100,37,8,49,39, +195,186,145,149,144,150,44,196,159,105,49,31,174,164,101,100,38,10,49,39, +198,33,180,153,37,100,38,141,49,39,218,76,76,234,27,73,146,86,66,112,163, +18,124,145,4,230,142,86,66,120,211,18,125,164,197,46,144,78,104,229,100,40, +15,49,39,198,33,107,68,136,39,52,114,178,20,73,24,147,237,38,38,117,11,90, +36,65,57,163,149,144,164,68,196,159,38,134,19,46,105,56,226,150,68,157,160, +3,200,147,228,208,194,92,32,124,137,62,49,11,90,36,65,57,163,149,178,166, +74,68,159,105,49,51,168,90,209,34,9,205,28,173,149,65,82,36,249,34,9,205, +28,173,175,170,54,68,159,105,49,75,164,19,154,57,91,95,88,84,137,62,49,13, +164,201,43,111,235,141,145,39,218,76,76,234,27,73,146,86,223,216,17,34,79, +135,117,35,43,115,236,139,145,39,218,76,71,235,169,25,91,159,104,60,137,62, +12,19,37,178,182,42,68,159,105,49,15,160,153,45,149,193,18,36,248,199,54, +103,182,190,232,185,18,125,164,196,206,185,179,61,181,247,133,200,147,225, +104,181,243,4,4,109,191,190,58,68,159,105,49,23,180,90,249,130,2,54,223, +224,67,152,147,230,8,8,217,12,16,121,18,124,193,1,27,101,131,131,56,7,38, +193,198,72,0,0,0,0,0,0,0,0,198,231,240,134,39,63,136,151,95,63,136,49,89, +252,66,98,243,248,133,96,132,185,5,224,32,36,201,41,248,200,213,249,0,131, +64,7,39,192,218,148,124,137,74,216,231,198,227,141,182,124,78,40,217,231, +197,227,4,213,227,192,159,72,10,5,21,218,138,120,74,129,124,36,98,232,228, +74,81,62,160,20,10,107,181,21,114,32,105,137,194,70,46,142,68,165,19,235,1, +64,170,187,81,119,34,66,146,36,104,137,194,70,46,142,68,165,19,236,1,64, +174,187,81,95,37,134,204,23,225,35,23,71,34,82,137,246,128,160,89,93,168, +167,147,195,201,194,70,46,142,68,165,19,238,1,64,182,187,81,71,105,20,19, +177,139,163,145,41,68,16,7,6,15,82,70,72,115,96,32,105,221,0,0,0,0,0,91,60, +149,195,200,194,8,134,149,216,114,1,128,83,192,144,8,194,195,16,12,168,110, +20,120,12,141,22,16,120,12,100,22,12,120,28,78,99,192,41,224,136,115,36,14, +100,197,213,245,193,48,189,112,40,2,237,96,175,131,117,2,178,112,145,139, +163,145,131,114,70,46,142,218,27,182,72,197,209,219,56,26,53,161,166,28,1, +204,178,10,14,38,78,44,141,52,207,31,0,0,21,64,129,100,180,8,148,145,92, +203,176,160,226,100,226,200,211,76,241,240,0,1,84,2,131,137,147,142,41,100, +73,199,192,0,5,88,6,13,10,82,70,62,0,0,42,66,88,115,18,124,67,103,177,69, +49,130,12,73,242,136,108,246,40,165,177,6,36,248,134,207,71,90,138,99,68, +152,147,229,16,217,232,235,81,75,130,12,73,241,13,158,158,149,20,199,9,49, +39,202,33,179,211,210,162,151,69,24,147,225,86,224,79,79,74,138,94,20,98, +79,133,91,129,61,109,74,41,124,60,137,62,33,179,216,166,216,193,18,36,249, +68,54,123,20,218,216,137,18,124,67,103,163,173,77,177,162,100,73,242,136, +108,244,117,169,181,193,18,36,248,134,207,79,74,155,99,132,200,147,229,16, +217,233,233,83,107,162,164,73,240,171,112,39,167,165,77,175,10,145,39,194, +173,192,158,182,165,54,191,153,51,72,71,161,196,201,45,167,146,59,68,89,24, +70,206,1,255,128,0,0,0,0,0,1,153,51,104,71,161,196,201,45,167,146,59,68,89, +24,70,206,1,255,128,0,0,0,0,0,1,153,51,136,71,161,196,201,45,167,146,59,68, +89,24,70,206,1,255,128,0,0,0,0,0,1,153,51,168,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,0,0,0,0,0,0,1,153,51,200,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,0,0,0,0,0,0,1,153,51,232,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,128,0,0,0,0,0,1,153,52,8,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,128,0,0,0,0,0,1,153,52,40,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,128,0,0,0,0,0,1,153,52,72,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,1,0,0,0,0,0,0,1,135,52,102,32,76,72,1,246,136,235,103, +177,69,1,17,32,7,196,54,123,20,82,88,200,144,3,237,17,214,207,71,91,171,37, +20,65,145,32,7,218,35,173,158,142,183,66,74,41,16,92,72,1,241,13,158,142, +183,86,74,41,48,92,72,1,241,13,158,142,183,66,74,41,80,100,72,1,246,136, +235,103,167,165,213,146,138,40,200,144,3,237,17,214,207,79,75,161,37,20, +138,46,36,0,248,134,207,79,75,171,37,20,154,46,36,0,248,134,207,79,75,161, +37,20,170,46,36,0,248,85,184,19,234,201,69,24,92,72,1,240,171,112,39,208, +146,138,70,25,18,0,124,27,168,21,147,171,37,20,113,145,32,7,193,186,129,89, +58,18,81,72,226,162,64,15,180,71,91,62,172,148,90,0,168,144,3,237,17,214, +207,161,37,22,144,38,36,0,248,134,207,171,37,22,160,38,36,0,248,134,207, +161,37,22,176,42,209,68,201,218,35,173,158,197,54,4,218,40,153,56,134,207, +98,155,75,27,104,162,100,237,17,214,207,71,91,171,37,54,65,182,138,38,78, +209,29,108,244,117,186,18,83,104,131,45,20,76,156,67,103,163,173,213,146, +155,76,25,104,162,100,226,27,61,29,110,132,148,218,160,219,69,19,39,104, +142,182,122,122,93,89,41,178,141,180,81,50,118,136,235,103,167,165,208,146, +155,69,25,104,162,100,226,27,61,61,46,172,148,218,104,203,69,19,39,16,217, +233,233,116,36,166,213,70,90,40,153,56,85,184,19,234,201,77,152,101,162, +137,147,133,91,129,62,132,148,218,48,219,69,19,39,6,234,5,100,234,201,77, +156,109,162,137,147,131,117,2,178,116,36,166,209,197,218,40,153,59,68,117, +179,234,201,78,32,11,180,81,50,118,136,235,103,208,146,156,72,21,104,162, +100,226,27,62,172,148,226,128,171,69,19,39,16,217,244,36,167,22,53,123,102, +53,155,80,2,21,11,94,201,128,196,133,0,185,80,32,56,156,199,130,36,160,72, +16,78,126,54,48,5,146,208,34,82,72,1,109,20,76,155,120,28,34,1,225,32,32,2, +223,133,69,138,43,180,132,234,219,163,161,1,0,9,174,198,238,213,84,88,31, +86,221,40,7,252,197,200,95,223,71,61,225,122,183,27,72,144,15,253,197,81, +217,74,224,191,131,117,110,54,142,129,32,31,237,229,189,138,147,114,135,2, +235,209,1,0,36,135,237,81,16,180,96,63,101,8,207,71,107,74,1,255,53,4,243, +51,249,222,104,94,202,17,158,148,3,255,106,9,230,103,243,188,210,159,129, +228,176,192,185,127,46,155,185,41,197,13,55,38,3,127,255,20,138,160,192,25, +106,8,8,1,58,90,130,64,128,146,27,168,37,8,9,129,186,130,96,160,152,27,165, +171,64,32,131,25,234,10,64,65,17,11,212,19,133,18,243,167,165,163,32,24, +157,45,65,64,6,75,191,80,80,66,149,110,116,117,5,8,41,240,247,79,72,188,8, +134,81,122,84,1,173,198,212,20,48,139,113,180,181,5,36,42,220,109,29,13,65, +74,6,192,95,76,188,6,196,55,78,188,6,247,91,86,136,26,32,104,220,205,72,1, +98,234,52,122,130,136,18,72,51,117,68,3,146,27,168,40,161,37,8,207,80,81, +129,204,13,212,20,112,179,141,26,45,65,75,112,20,43,193,25,19,66,128,153, +78,40,105,144,92,104,152,131,124,27,253,128,0,10,116,3,68,146,163,9,128,0, +10,102,3,138,145,137,27,60,0,0,82,129,7,2,4,16,7,2,70,143,178,203,164,237, +35,14,25,10,134,147,143,139,158,72,207,28,54,77,47,109,13,55,113,120,96, +196,159,29,102,241,241,115,201,25,227,131,36,133,20,62,110,143,17,16,113, +137,62,62,46,155,167,135,147,142,47,44,151,79,221,64,98,37,194,94,100,108, +144,21,147,140,73,168,228,19,17,124,73,82,54,124,37,230,70,201,14,108,185, +36,155,14,243,243,83,212,69,131,132,4,12,137,114,168,37,166,145,7,10,4,28, +200,14,12,40,56,153,56,178,52,211,60,124,0,0,85,0,160,226,100,227,138,89, +18,113,240,0,1,86,1,131,66,148,145,143,128,0,10,144,93,134,0,0,43,80,17,42, +4,17,136,49,73,19,49,134,16,143,67,137,146,91,79,36,118,136,178,48,141,156, +3,255,0,0,0,0,0,0,3,49,135,16,143,67,137,146,91,79,36,118,136,178,48,141, +156,3,255,0,0,0,0,0,0,5,20,5,173,194,227,214,4,55,0,0,21,196,7,122,192,134, +241,197,192,0,5,121,25,140,64,132,122,28,76,146,218,121,35,180,69,145,132, +108,224,31,248,0,0,0,0,0,0,25,140,72,132,122,28,76,146,218,121,35,180,69, +145,132,108,224,32,0,0,0,0,0,0,0,25,140,80,132,122,28,76,146,218,121,35, +180,69,145,132,108,224,32,0,0,0,0,0,0,0,25,140,88,132,122,28,76,146,218, +121,35,180,69,145,132,108,224,32,8,0,0,0,0,0,0,25,140,96,132,122,28,76,146, +218,121,35,180,69,145,132,108,224,32,8,0,0,0,0,0,0,25,140,104,132,122,28, +76,146,218,121,35,180,69,145,132,108,224,32,8,0,0,0,0,0,0,25,140,112,132, +122,28,76,146,218,121,35,180,69,145,132,108,224,32,16,0,0,0,0,0,0,16,113, +225,0,48,156,209,2,122,244,5,34,92,35,68,225,161,166,218,16,33,18,224,104, +82,146,59,50,5,7,19,39,22,70,154,103,215,32,28,78,99,193,18,80,70,131,165, +1,205,34,8,35,68,225,161,166,239,255,4,12,70,137,195,39,248,73,7,78,3,154, +102,16,70,137,195,67,77,223,248,1,74,9,129,125,255,130,9,65,154,232,147, +161,115,59,255,5,64,195,32,156,50,126,197,14,2,3,107,173,213,0, }; #elif defined(DUK_USE_DOUBLE_ME) -DUK_INTERNAL const duk_uint8_t duk_builtins_data[4116] = { -144,148,105,224,32,68,52,228,62,12,104,200,165,132,52,167,194,138,105,243, -124,57,28,211,57,18,64,52,238,126,44,138,111,171,241,164,19,87,129,30,33, +DUK_INTERNAL const duk_uint8_t duk_builtins_data[3972] = { +144,148,105,223,160,68,52,228,62,12,104,200,165,132,52,167,194,138,105,242, +252,57,28,211,57,18,64,52,238,62,44,138,111,171,241,164,19,87,125,30,33, 167,16,145,159,8,211,136,9,225,42,5,240,145,139,163,163,8,211,136,10,228, 64,211,19,132,140,93,29,56,70,156,64,119,34,66,146,36,104,137,194,70,46, 142,172,35,78,32,47,146,195,102,11,240,145,139,163,175,8,211,136,9,228,240, 242,112,145,139,163,179,8,211,136,8,237,34,130,118,49,116,118,225,26,48,0, -1,82,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, -33,8,66,26,179,233,97,167,60,150,34,33,154,112,0,1,75,247,35,79,95,237,198, -174,200,47,31,23,95,17,13,51,19,35,93,68,216,209,128,0,10,208,174,79,15,32, -248,8,196,24,8,107,192,0,5,106,118,27,94,0,0,43,83,227,94,0,0,43,84,46,215, -128,0,10,213,28,198,188,0,0,86,169,100,53,224,0,2,181,79,85,175,0,0,21,170, -154,45,120,0,0,173,85,217,107,192,0,5,106,182,243,86,193,106,52,127,130, -249,50,94,124,35,68,225,146,49,13,31,186,23,201,146,243,224,200,39,12,145, -136,67,134,19,49,0,0,3,225,252,0,0,0,3,51,0,0,3,193,252,0,0,0,3,47,18,1, -172,19,120,71,10,25,196,136,113,162,156,136,199,42,57,204,144,115,132,240, -149,2,248,72,197,209,58,2,185,16,52,196,225,35,23,68,233,14,228,72,82,68, -141,17,56,72,197,209,58,130,249,44,54,96,191,9,24,186,39,88,79,39,135,147, -132,140,93,19,176,35,180,138,9,216,197,209,59,82,79,35,40,242,65,248,58,42, -96,121,14,232,94,62,46,190,15,42,31,145,33,86,65,76,242,214,143,73,48,242, -243,79,49,56,243,115,207,57,64,243,180,79,61,72,243,244,207,65,80,244,53, -79,69,88,244,98,30,8,200,156,67,102,120,241,79,4,100,78,21,110,4,207,32,47, -147,37,231,194,52,78,25,34,122,81,124,153,47,62,12,130,112,201,19,211,139, -121,34,87,69,128,104,137,239,83,18,238,108,165,2,162,92,104,56,220,233,1,8, -151,10,134,162,100,206,16,18,50,9,195,39,105,20,101,136,18,25,4,225,147, -180,138,5,215,49,238,105,27,60,185,1,36,104,156,50,118,145,70,96,129,34,52, -78,25,59,72,160,93,115,30,230,145,179,204,144,12,73,8,15,38,104,128,138,52, -146,16,30,77,1,0,2,11,132,193,198,36,248,248,186,110,158,30,78,56,188,194, -70,183,170,136,48,98,79,142,179,120,248,185,228,140,241,193,146,66,138,31, -55,71,138,128,153,137,62,58,205,227,226,231,146,51,199,26,6,18,92,146,64, -96,74,72,51,120,43,192,97,68,128,153,56,72,7,12,133,67,73,199,197,207,36, -103,142,35,2,3,33,80,210,113,241,115,201,25,160,146,225,160,9,34,1,124,178, -1,139,18,19,36,229,146,8,190,36,169,27,62,18,243,35,100,135,54,92,162,2,17, -46,72,128,89,7,200,32,33,18,225,98,236,145,188,130,64,196,75,132,188,200, -217,32,43,39,28,128,69,19,18,228,144,42,98,79,142,179,120,248,185,228,140, -241,201,97,129,114,229,201,37,2,68,184,200,1,147,93,159,153,213,34,235,250, -96,48,157,32,24,94,160,1,199,4,184,235,55,143,139,158,72,207,28,226,3,81, -46,62,46,155,167,135,147,142,47,60,129,71,197,207,36,103,142,34,92,35,104, -194,68,1,89,58,36,8,109,109,12,133,67,73,195,18,115,36,118,182,185,168,8, -109,109,12,133,67,73,201,18,115,36,118,182,185,168,130,27,91,75,115,149,71, -240,196,156,201,29,173,174,129,2,27,91,75,115,149,71,242,68,156,201,29,173, -174,129,34,12,16,28,128,62,191,42,3,71,146,68,4,16,22,188,161,240,16,40, -104,242,103,196,16,93,158,125,96,110,115,235,64,131,16,16,58,37,192,70,32, -194,144,114,25,67,95,40,6,18,8,32,48,156,209,2,108,124,96,224,144,6,247,62, -16,0,143,164,143,12,248,15,18,84,145,145,34,128,11,35,160,179,140,0,44,150, -129,18,58,0,146,116,103,32,128,105,61,104,17,36,175,1,232,217,29,5,156,179, -224,58,26,50,95,142,43,159,64,181,130,83,226,26,50,95,142,43,159,192,7,255, -248,41,42,72,226,1,160,18,78,97,32,26,64,114,186,60,32,4,120,6,148,13,128, -124,3,76,12,84,46,100,140,3,78,13,18,14,130,36,67,232,23,18,14,130,39,34, -131,30,113,15,224,3,255,253,6,48,40,194,197,204,224,142,8,240,78,25,60,231, -192,210,197,204,224,156,50,113,238,67,103,232,62,28,138,156,104,82,170,107, -255,32,48,191,144,1,132,112,71,128,159,168,128,161,28,17,224,156,50,112,19, -245,144,22,39,12,156,123,144,217,240,19,245,146,3,9,205,16,39,236,62,3,161, -163,37,248,226,251,141,1,107,4,167,196,52,100,191,28,95,113,164,13,91,132, -5,147,130,115,30,8,147,222,64,43,1,49,31,224,64,60,72,245,128,68,249,32,13, -34,2,34,63,204,128,89,45,2,39,209,0,89,61,104,159,213,0,153,80,50,156,80, -211,126,16,11,155,184,183,88,145,224,129,34,122,64,17,155,184,183,8,11,39, -22,235,18,60,16,36,79,72,1,115,119,40,247,146,60,16,36,79,72,32,140,221, -197,184,64,89,57,71,188,145,224,129,34,122,65,1,39,20,51,244,0,52,72,242,2, -127,18,2,165,48,70,114,229,145,51,253,141,1,4,104,229,203,34,103,251,26,64, -132,52,75,160,201,47,105,160,26,84,12,167,31,186,8,50,0,114,58,113,163,46, -190,120,35,11,60,4,25,68,81,61,96,47,181,80,46,132,129,255,255,222,255,255, -255,255,254,39,172,67,118,170,5,208,144,0,0,0,0,0,64,0,0,51,16,0,0,62,31, -192,0,0,0,8,245,238,146,38,138,147,105,13,42,26,137,226,0,0,7,131,248,0,0, -0,1,30,180,134,4,209,82,109,33,165,67,81,60,64,0,0,240,255,0,0,0,0,15,210, -62,72,91,155,0,0,2,192,240,0,0,0,0,135,88,11,237,72,5,38,210,27,50,24,145, -129,255,254,126,135,255,255,255,254,67,172,67,118,164,2,147,105,13,153,12, -72,192,255,255,63,195,255,255,255,255,16,240,70,68,226,27,51,199,138,120, -35,34,112,171,112,38,121,7,16,137,112,168,106,38,77,193,1,40,151,16,217, -144,196,142,224,144,21,18,227,65,198,238,9,67,81,46,72,5,39,16,217,144,196, -142,224,152,228,148,227,64,0,0,0,0,0,0,0,0,131,175,223,16,194,111,8,97,119, -224,3,205,220,42,46,65,238,200,13,155,184,75,189,205,35,102,128,47,116,64, -92,221,199,196,130,68,144,230,239,72,65,152,12,21,224,140,137,92,128,62, -210,98,177,252,3,107,173,88,3,146,211,141,32,0,3,225,252,0,0,0,3,19,175, -188,0,100,221,193,130,100,228,167,20,52,215,129,3,38,238,77,12,39,37,56, -161,166,188,10,194,94,6,18,155,184,183,8,11,39,6,9,147,146,156,80,211,94,7, -18,155,184,183,8,11,39,38,134,19,146,156,80,211,94,8,12,53,224,130,195,222, -8,77,133,210,24,91,224,3,152,147,228,208,194,95,0,44,196,159,11,69,175,152, -32,35,100,33,135,24,147,237,38,34,246,139,95,48,64,70,200,68,8,49,39,198, -57,179,61,144,138,22,98,79,180,152,153,215,54,103,178,17,129,204,73,240,96, -153,44,132,112,163,18,125,164,196,62,130,100,178,18,1,140,73,240,96,197, -144,146,18,98,79,180,152,135,208,98,200,74,8,49,39,195,186,145,149,144,150, -22,98,79,180,152,143,215,82,50,178,19,2,140,73,241,136,109,38,73,89,9,161, -166,36,251,73,137,157,67,105,50,74,200,78,10,49,39,201,16,78,104,229,100, -39,134,152,147,237,38,41,116,130,115,71,43,33,64,60,196,159,24,133,173,18, -32,156,209,202,200,81,18,49,39,218,76,76,234,22,180,72,130,115,71,43,33,72, -68,196,159,38,134,19,46,105,56,226,150,68,157,160,1,228,73,242,104,97,46, -16,31,34,79,140,66,214,137,16,78,104,229,108,169,137,72,147,237,38,38,117, -11,90,36,65,57,163,149,178,168,21,34,79,146,32,156,209,202,218,250,161,178, -36,251,73,138,93,32,156,209,202,218,250,193,82,36,248,196,54,147,36,173, -191,174,27,34,79,180,152,153,212,54,147,36,173,191,176,17,34,79,135,117,35, -43,115,236,133,200,147,237,38,35,245,212,140,173,207,180,15,34,79,131,4, -201,108,173,133,72,147,237,38,33,244,19,37,178,184,17,34,79,140,115,102, -123,107,238,133,200,147,237,38,38,117,205,153,237,175,188,23,34,79,133,162, -215,204,16,17,182,254,248,116,137,62,210,98,47,104,181,243,4,4,109,191,192, -131,152,147,230,8,8,217,12,16,60,137,62,96,128,141,178,193,160,206,1,201, -176,113,146,0,0,0,0,0,0,0,0,49,185,252,65,137,207,227,37,215,207,227,12,86, -127,24,152,188,254,49,88,33,46,65,120,72,4,153,37,63,33,13,127,148,4,26,0, -57,62,6,228,163,228,74,86,215,62,55,28,110,179,226,113,70,223,62,47,24,38, -191,30,2,125,32,40,20,87,114,41,225,42,5,240,145,139,163,145,41,68,250,128, -80,41,174,228,85,200,129,166,39,9,24,186,57,18,148,79,172,5,2,170,238,69, -220,137,10,72,145,162,39,9,24,186,57,18,148,79,176,5,2,186,238,69,124,150, -27,48,95,132,140,93,28,137,74,39,218,2,129,101,119,34,158,79,15,39,9,24, -186,57,18,148,79,184,5,2,218,238,69,29,164,80,78,198,46,142,68,165,16,64, -28,24,61,73,25,33,205,128,1,167,166,128,0,0,0,1,108,242,151,15,39,8,34,26, -87,97,200,3,0,167,129,32,8,194,195,16,6,84,55,10,60,3,35,69,132,30,1,140, -130,193,143,1,196,230,60,2,158,8,131,153,64,115,42,46,191,176,8,194,246,0, -80,5,220,193,95,6,234,5,100,225,35,23,71,35,6,228,140,93,29,180,55,108,145, -139,163,182,112,52,107,67,76,56,3,153,132,20,28,76,156,89,26,105,158,62,0, -0,42,193,2,201,104,17,41,34,156,204,176,160,226,100,226,200,211,76,241,240, -0,1,86,2,131,137,147,142,41,100,73,199,192,0,5,96,6,13,10,82,70,62,0,0,42, -130,88,115,18,124,67,103,177,69,49,129,6,36,249,68,54,123,20,82,216,65,137, -62,33,179,209,214,162,152,208,147,18,124,162,27,61,29,106,41,112,32,196, -159,16,217,233,233,81,76,112,73,137,62,81,13,158,158,149,20,186,20,98,79, -133,91,129,61,61,42,41,120,40,196,159,10,183,2,122,218,148,82,248,60,137, -62,33,179,216,166,216,192,137,18,124,162,27,61,138,109,108,34,68,159,16, -217,232,235,83,108,104,76,137,62,81,13,158,142,181,54,184,17,34,79,136,108, -244,244,169,182,56,38,68,159,40,134,207,79,74,155,93,10,145,39,194,173,192, -158,158,149,54,188,21,34,79,133,91,129,61,109,74,109,125,155,51,136,71,161, -196,201,45,167,146,59,68,89,24,70,206,0,0,7,129,248,0,0,0,1,155,51,168,71, -161,196,201,45,167,146,59,68,89,24,70,206,0,0,7,129,248,0,0,0,1,155,51,200, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,7,129,248,0,0,0,1,155,51, -232,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,2,0,0,0,0,1,155,52, -8,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,2,0,0,0,0,1,155,52,40, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,155,52,72, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,155,52, -104,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,155, -52,136,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,1,2,0,0,0,0,1,135, -52,166,32,76,72,1,246,136,235,103,177,69,0,136,144,3,226,27,61,138,41,44, -50,36,0,251,68,117,179,209,214,234,201,69,16,50,36,0,251,68,117,179,209, -214,232,73,69,34,5,196,128,31,16,217,232,235,117,100,162,147,2,226,64,15, -136,108,244,117,186,18,81,74,129,145,32,7,218,35,173,158,158,151,86,74,40, -161,145,32,7,218,35,173,158,158,151,66,74,41,20,46,36,0,248,134,207,79,75, -171,37,20,154,23,18,0,124,67,103,167,165,208,146,138,85,11,137,0,62,21,110, -4,250,178,81,70,11,137,0,62,21,110,4,250,18,81,72,193,145,32,7,193,186,129, -89,58,178,81,71,12,137,0,62,13,212,10,201,208,146,138,71,10,137,0,62,209, -29,108,250,178,81,104,1,81,32,7,218,35,173,159,66,74,45,32,38,36,0,248,134, -207,171,37,22,160,19,18,0,124,67,103,208,146,139,88,10,180,81,50,118,136, -235,103,177,77,128,155,69,19,39,16,217,236,83,105,97,182,138,38,78,209,29, -108,244,117,186,178,83,100,13,180,81,50,118,136,235,103,163,173,208,146, -155,68,12,180,81,50,113,13,158,142,183,86,74,109,48,50,209,68,201,196,54, -122,58,221,9,41,181,64,219,69,19,39,104,142,182,122,122,93,89,41,178,134, -218,40,153,59,68,117,179,211,210,232,73,77,162,134,90,40,153,56,134,207,79, -75,171,37,54,154,25,104,162,100,226,27,61,61,46,132,148,218,168,101,162, -137,147,133,91,129,62,172,148,217,131,45,20,76,156,42,220,9,244,36,166,209, -131,109,20,76,156,27,168,21,147,171,37,54,112,219,69,19,39,6,234,5,100,232, -73,77,163,133,218,40,153,59,68,117,179,234,201,78,32,5,218,40,153,59,68, -117,179,232,73,78,36,5,90,40,153,56,134,207,171,37,56,160,21,104,162,100, -226,27,62,132,148,226,195,95,182,97,176,218,128,8,84,45,123,38,1,137,10,1, -114,160,64,56,156,199,130,36,160,72,8,39,63,27,24,1,100,180,8,148,146,0,45, -162,137,147,111,2,8,4,16,7,8,96,120,72,1,87,224,168,13,42,226,145,97,58, -182,232,232,64,177,107,2,64,22,85,181,187,7,213,183,74,2,17,119,49,255,121, -207,215,240,94,173,198,210,36,4,113,95,115,255,232,34,182,80,221,91,141, -163,160,72,15,121,123,103,225,220,164,194,160,186,244,64,251,33,9,64,24,45, -68,84,15,217,66,51,209,218,210,129,61,65,204,127,154,118,254,204,23,178, -132,103,165,2,122,131,216,255,52,237,253,154,168,48,6,90,130,1,0,39,75,80, -72,8,9,33,186,130,80,64,76,13,212,19,2,130,96,110,150,173,0,65,6,51,212,20, -128,65,17,11,212,19,130,137,121,211,210,209,144,6,39,75,80,80,0,201,119, -234,10,8,41,86,231,71,80,80,129,79,135,186,122,69,224,34,25,69,233,80,3,91, -141,168,40,96,139,113,180,181,5,36,21,110,54,142,134,160,165,1,176,23,211, -47,0,216,134,233,215,128,111,117,181,104,128,209,3,70,230,106,64,5,139,168, -209,234,10,32,36,144,102,234,136,3,146,27,168,40,160,146,132,103,168,40, -192,115,3,117,5,28,22,113,163,69,168,41,103,1,66,188,17,145,52,40,4,202, -113,67,76,130,227,68,194,13,240,108,0,0,83,96,0,2,161,0,104,146,84,97,48,0, -1,78,192,56,169,24,145,179,192,0,5,48,8,56,16,32,128,56,18,52,125,166,86, -147,182,140,28,50,21,13,39,31,23,60,145,158,56,140,141,47,113,6,155,186, -188,24,49,39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,197,68, -14,49,39,199,197,211,116,240,242,113,197,230,18,180,253,228,3,17,46,18,243, -35,100,128,172,156,114,70,163,146,76,34,248,146,164,108,248,75,204,141,146, -28,217,114,137,27,78,251,241,173,234,162,160,225,1,3,34,92,170,9,105,164, -32,225,64,131,155,1,193,133,7,19,39,22,70,154,103,143,128,0,10,176,20,28, -76,156,113,75,34,78,62,0,0,43,0,48,104,82,146,49,240,0,1,84,11,180,192,0,5, -114,1,18,160,65,24,131,20,145,25,172,48,132,122,28,76,146,218,121,35,180, -69,145,132,108,224,0,0,120,31,128,0,0,0,25,172,56,132,122,28,76,146,218, -121,35,180,69,145,132,108,224,0,0,120,31,128,0,0,0,40,160,45,110,23,30,176, -33,184,0,0,175,32,29,235,2,27,199,23,0,0,22,4,51,88,129,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,0,0,240,63,0,0,0,0,51,88,145,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,0,0,0,64,0,0,0,0,51,88,161,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,0,0,0,64,0,0,0,0,51,88,177,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51,88,193,8,244,56, -153,37,180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51,88,209,8,244, -56,153,37,180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51,88,225,8, -244,56,153,37,180,242,71,104,139,35,8,217,192,0,0,32,64,0,0,0,0,32,227,194, -0,97,57,162,4,245,232,5,34,92,35,68,225,161,166,218,16,16,137,112,52,41,73, -29,153,1,65,196,201,197,145,166,153,245,200,3,137,204,120,34,74,8,200,58, -112,28,211,32,130,52,78,26,26,110,248,0,0,164,4,12,70,137,195,39,252,73, -240,117,32,57,168,97,4,104,156,52,52,221,255,160,20,160,152,23,223,250,32, -148,25,174,137,58,23,51,191,244,84,12,50,9,195,39,240,81,238,2,3,107,173, -214,3,192, +1,80,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, +33,8,66,34,33,154,112,0,1,73,247,35,79,91,237,198,174,192,47,31,23,95,17, +13,51,19,35,93,68,216,209,128,0,10,192,174,79,15,32,248,8,196,24,8,107,192, +0,5,98,118,27,94,0,0,43,19,227,94,0,0,43,20,46,215,128,0,10,197,28,198,188, +0,0,86,41,100,53,224,0,2,177,79,85,175,0,0,21,138,154,45,120,0,0,172,85, +217,107,192,0,5,98,182,243,86,193,106,52,127,66,249,50,94,124,35,68,225, +146,49,13,31,170,23,201,146,243,224,200,39,12,145,136,67,134,11,49,0,0,3, +225,252,0,0,0,3,51,0,0,3,193,252,0,0,0,3,47,18,1,172,19,120,71,10,25,196, +136,113,162,156,136,199,42,57,204,144,115,132,240,149,2,248,72,197,209,58, +2,185,16,52,196,225,35,23,68,233,14,228,72,82,68,141,17,56,72,197,209,58, +130,249,44,54,96,191,9,24,186,39,88,79,39,135,147,132,140,93,19,176,35,180, +138,9,216,197,209,59,82,79,31,40,242,1,248,58,42,96,121,14,232,94,62,46, +190,15,38,31,145,33,86,65,76,242,150,143,69,48,242,179,79,45,56,243,51,207, +53,64,243,116,79,57,72,243,180,207,61,80,243,245,79,65,88,244,34,249,50,94, +124,35,68,225,146,39,163,23,201,146,243,224,200,39,12,145,61,40,183,146,37, +116,88,6,136,158,244,241,174,230,202,80,135,130,50,39,16,217,231,208,20, +240,70,68,225,86,224,79,60,64,84,75,141,7,27,157,32,66,37,194,161,168,153, +51,132,9,25,4,225,147,180,138,50,196,18,25,4,225,147,180,138,5,215,49,238, +105,27,60,185,2,72,209,56,100,237,34,140,193,4,136,209,56,100,237,34,129, +117,204,123,154,70,207,50,64,98,72,64,121,51,68,8,163,73,33,1,228,208,16,0, +65,112,152,56,196,159,31,23,77,211,195,201,199,23,150,73,169,234,34,24,49, +39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,196,64,153,137,62, +58,205,227,226,231,146,51,199,26,6,18,92,130,64,192,148,144,102,240,23,129, +133,18,2,100,224,160,56,100,42,26,78,62,46,121,35,60,112,216,32,50,21,13, +39,31,23,60,145,154,9,46,18,1,36,64,47,148,64,98,196,132,201,57,68,132,95, +18,84,141,159,9,121,145,178,67,155,46,73,2,17,46,72,128,89,7,199,32,66,37, +194,197,217,35,120,228,131,17,46,18,243,35,100,128,172,156,98,2,40,152,151, +32,130,166,36,248,235,55,143,139,158,72,207,28,150,24,23,46,92,130,80,72, +151,21,0,100,213,103,229,245,8,186,190,144,24,78,136,24,94,152,3,142,9,113, +214,111,31,23,60,145,158,57,164,13,68,184,248,186,110,158,30,78,56,188,226, +10,62,46,121,35,60,113,18,225,27,70,18,32,10,201,208,32,134,214,208,200,84, +52,156,49,39,50,71,107,107,152,129,13,173,161,144,168,105,57,34,78,100,142, +214,215,49,16,134,214,210,220,229,81,252,49,39,50,71,107,107,158,65,13,173, +165,185,202,163,249,34,78,100,142,214,215,60,146,12,16,28,128,62,175,42,6, +143,36,136,16,64,90,242,135,192,129,67,71,147,62,65,5,215,231,214,6,215,62, +180,8,49,1,3,162,92,4,98,12,41,14,67,40,106,229,1,132,130,8,24,78,104,129, +54,62,96,224,144,13,238,124,32,2,62,146,60,51,224,120,146,164,140,137,20,0, +178,58,11,56,192,5,146,208,34,71,64,36,157,25,200,32,52,158,180,8,146,87, +129,232,217,29,5,156,179,224,116,52,100,191,28,87,62,130,214,9,79,136,104, +201,126,56,174,127,0,31,255,225,73,82,71,16,13,1,36,230,18,1,164,14,87,71, +132,0,143,0,210,131,96,31,0,211,6,42,23,50,70,1,167,13,18,14,130,36,67,232, +46,36,29,4,78,69,6,60,226,31,192,7,255,252,24,192,163,11,23,51,130,56,35, +193,56,100,243,31,6,150,46,103,4,225,147,143,114,27,63,57,241,200,169,194, +133,42,166,175,240,6,23,240,0,97,28,17,224,39,233,32,80,142,8,240,78,25,56, +9,250,136,22,39,12,156,123,144,217,240,19,245,18,6,19,154,32,79,214,124,14, +134,140,151,227,139,237,52,11,88,37,62,33,163,37,248,226,251,77,32,213,184, +64,89,56,39,49,224,137,61,196,5,96,38,35,251,200,15,18,61,96,17,62,40,6, +145,1,17,31,228,64,89,45,2,39,205,0,178,122,209,63,162,2,101,64,202,113,67, +77,247,64,92,221,197,186,196,143,4,9,19,208,1,25,187,139,112,128,178,113, +110,177,35,193,2,68,244,0,46,110,229,30,242,71,130,4,137,232,4,35,55,113, +110,16,22,78,81,239,36,120,32,72,158,128,64,147,138,25,249,0,52,72,242,2, +127,2,5,74,96,140,229,203,34,103,250,154,4,17,163,151,44,137,159,234,105,4, +33,162,93,6,73,123,13,1,165,64,202,113,251,33,6,64,14,71,78,20,101,213,207, +4,194,207,2,12,162,0,158,176,23,218,168,23,66,64,255,255,239,127,255,255, +255,255,19,214,33,187,85,2,232,72,0,0,0,0,0,32,0,0,25,136,0,0,31,15,224,0, +0,0,4,122,247,73,19,69,73,180,134,149,13,68,241,0,0,3,193,252,0,0,0,0,143, +90,67,2,104,169,54,144,210,161,168,158,32,0,0,120,127,128,0,0,0,14,73,78, +20,0,0,0,0,0,0,0,0,8,58,189,233,24,77,217,24,93,240,1,230,238,21,23,32,247, +68,13,155,184,75,189,205,35,102,128,47,114,64,185,187,143,137,4,137,33,205, +222,17,6,96,48,87,130,50,37,114,1,246,147,21,143,224,54,186,213,128,114,90, +112,164,0,0,124,63,128,0,0,0,98,117,119,128,25,55,112,96,153,57,41,197,13, +53,224,65,147,119,38,134,19,146,156,80,211,94,5,194,94,6,37,55,113,110,16, +22,78,12,19,39,37,56,161,166,188,14,74,110,226,220,32,44,156,154,24,78,74, +113,67,77,120,32,97,175,4,28,61,224,133,172,186,70,22,248,1,204,73,242,104, +97,47,128,44,196,159,11,69,175,152,32,35,100,33,142,49,39,218,76,69,237,22, +190,96,128,141,144,136,32,196,159,24,230,204,246,66,40,179,18,125,164,196, +206,185,179,61,144,140,28,196,159,6,9,146,200,71,20,98,79,180,152,135,208, +76,150,66,64,99,18,124,24,49,100,36,137,49,39,218,76,67,232,49,100,37,8,49, +39,195,186,145,149,144,150,44,196,159,105,49,31,174,164,101,100,38,10,49, +39,198,33,180,153,37,100,38,141,49,39,218,76,76,234,27,73,146,86,66,112, +163,18,124,145,4,230,142,86,66,120,211,18,125,164,197,46,144,78,104,229, +100,40,15,49,39,198,33,107,68,136,39,52,114,178,20,73,24,147,237,38,38,117, +11,90,36,65,57,163,149,144,164,68,196,159,38,134,19,46,105,56,226,150,68, +157,160,3,200,147,228,208,194,92,32,124,137,62,49,11,90,36,65,57,163,149, +178,166,74,68,159,105,49,51,168,90,209,34,9,205,28,173,149,65,82,36,249,34, +9,205,28,173,175,170,54,68,159,105,49,75,164,19,154,57,91,95,88,84,137,62, +49,13,164,201,43,111,235,141,145,39,218,76,76,234,27,73,146,86,223,216,17, +34,79,135,117,35,43,115,236,139,145,39,218,76,71,235,169,25,91,159,104,60, +137,62,12,19,37,178,182,42,68,159,105,49,15,160,153,45,149,193,18,36,248, +199,54,103,182,190,232,185,18,125,164,196,206,185,179,61,181,247,133,200, +147,225,104,181,243,4,4,109,191,190,58,68,159,105,49,23,180,90,249,130,2, +54,223,224,67,152,147,230,8,8,217,12,16,121,18,124,193,1,27,101,131,131,56, +7,38,193,198,72,0,0,0,0,0,0,0,0,198,231,240,134,39,63,136,151,95,63,136,49, +89,252,66,98,243,248,133,96,132,185,5,224,32,36,201,41,248,200,213,249,0, +131,64,7,39,192,218,148,124,137,74,216,231,198,227,141,182,124,78,40,217, +231,197,227,4,213,227,192,159,72,10,5,21,218,138,120,74,129,124,36,98,232, +228,74,81,62,160,20,10,107,181,21,114,32,105,137,194,70,46,142,68,165,19, +235,1,64,170,187,81,119,34,66,146,36,104,137,194,70,46,142,68,165,19,236,1, +64,174,187,81,95,37,134,204,23,225,35,23,71,34,82,137,246,128,160,89,93, +168,167,147,195,201,194,70,46,142,68,165,19,238,1,64,182,187,81,71,105,20, +19,177,139,163,145,41,68,16,7,6,15,82,70,72,115,96,0,93,105,160,0,0,0,0,91, +60,149,195,200,194,8,134,149,216,114,1,128,83,192,144,8,194,195,16,12,168, +110,20,120,12,141,22,16,120,12,100,22,12,120,28,78,99,192,41,224,136,115, +36,14,100,197,213,245,193,48,189,112,40,2,237,96,175,131,117,2,178,112,145, +139,163,145,131,114,70,46,142,218,27,182,72,197,209,219,56,26,53,161,166, +28,1,204,178,10,14,38,78,44,141,52,207,31,0,0,21,64,129,100,180,8,148,145, +92,203,176,160,226,100,226,200,211,76,241,240,0,1,84,2,131,137,147,142,41, +100,73,199,192,0,5,88,6,13,10,82,70,62,0,0,42,66,88,115,18,124,67,103,177, +69,49,130,12,73,242,136,108,246,40,165,177,6,36,248,134,207,71,90,138,99, +68,152,147,229,16,217,232,235,81,75,130,12,73,241,13,158,158,149,20,199,9, +49,39,202,33,179,211,210,162,151,69,24,147,225,86,224,79,79,74,138,94,20, +98,79,133,91,129,61,109,74,41,124,60,137,62,33,179,216,166,216,193,18,36, +249,68,54,123,20,218,216,137,18,124,67,103,163,173,77,177,162,100,73,242, +136,108,244,117,169,181,193,18,36,248,134,207,79,74,155,99,132,200,147,229, +16,217,233,233,83,107,162,164,73,240,171,112,39,167,165,77,175,10,145,39, +194,173,192,158,182,165,54,191,153,51,72,71,161,196,201,45,167,146,59,68, +89,24,70,206,0,0,7,129,248,0,0,0,1,153,51,104,71,161,196,201,45,167,146,59, +68,89,24,70,206,0,0,7,129,248,0,0,0,1,153,51,136,71,161,196,201,45,167,146, +59,68,89,24,70,206,0,0,7,129,248,0,0,0,1,153,51,168,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,2,0,0,0,0,1,153,51,200,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,2,0,0,0,0,1,153,51,232,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,153,52,8,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,153,52,40,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,153,52,72,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,1,2,0,0,0,0,1,135,52,102,32,76,72,1,246,136,235, +103,177,69,1,17,32,7,196,54,123,20,82,88,200,144,3,237,17,214,207,71,91, +171,37,20,65,145,32,7,218,35,173,158,142,183,66,74,41,16,92,72,1,241,13, +158,142,183,86,74,41,48,92,72,1,241,13,158,142,183,66,74,41,80,100,72,1, +246,136,235,103,167,165,213,146,138,40,200,144,3,237,17,214,207,79,75,161, +37,20,138,46,36,0,248,134,207,79,75,171,37,20,154,46,36,0,248,134,207,79, +75,161,37,20,170,46,36,0,248,85,184,19,234,201,69,24,92,72,1,240,171,112, +39,208,146,138,70,25,18,0,124,27,168,21,147,171,37,20,113,145,32,7,193,186, +129,89,58,18,81,72,226,162,64,15,180,71,91,62,172,148,90,0,168,144,3,237, +17,214,207,161,37,22,144,38,36,0,248,134,207,171,37,22,160,38,36,0,248,134, +207,161,37,22,176,42,209,68,201,218,35,173,158,197,54,4,218,40,153,56,134, +207,98,155,75,27,104,162,100,237,17,214,207,71,91,171,37,54,65,182,138,38, +78,209,29,108,244,117,186,18,83,104,131,45,20,76,156,67,103,163,173,213, +146,155,76,25,104,162,100,226,27,61,29,110,132,148,218,160,219,69,19,39, +104,142,182,122,122,93,89,41,178,141,180,81,50,118,136,235,103,167,165,208, +146,155,69,25,104,162,100,226,27,61,61,46,172,148,218,104,203,69,19,39,16, +217,233,233,116,36,166,213,70,90,40,153,56,85,184,19,234,201,77,152,101, +162,137,147,133,91,129,62,132,148,218,48,219,69,19,39,6,234,5,100,234,201, +77,156,109,162,137,147,131,117,2,178,116,36,166,209,197,218,40,153,59,68, +117,179,234,201,78,32,11,180,81,50,118,136,235,103,208,146,156,72,21,104, +162,100,226,27,62,172,148,226,128,171,69,19,39,16,217,244,36,167,22,53,123, +102,53,155,80,2,21,11,94,201,128,196,133,0,185,80,32,56,156,199,130,36,160, +72,16,78,126,54,48,5,146,208,34,82,72,1,109,20,76,155,120,28,34,1,225,32,5, +95,130,160,52,171,138,69,132,234,219,163,161,2,197,172,9,0,89,86,214,236, +31,86,221,40,8,69,220,199,253,231,63,95,193,122,183,27,72,144,17,197,125, +207,255,160,138,217,67,117,110,54,142,129,32,61,229,237,159,135,114,147,10, +130,235,209,3,236,132,37,0,96,181,17,80,63,101,8,207,71,107,74,4,245,7,49, +254,105,219,251,48,94,202,17,158,148,9,234,15,99,252,211,183,246,98,159, +129,228,176,192,185,127,46,155,185,41,197,13,55,38,3,127,255,20,138,160, +192,25,106,8,8,1,58,90,130,64,128,146,27,168,37,8,9,129,186,130,96,160,152, +27,165,171,64,32,131,25,234,10,64,65,17,11,212,19,133,18,243,167,165,163, +32,24,157,45,65,64,6,75,191,80,80,66,149,110,116,117,5,8,41,240,247,79,72, +188,8,134,81,122,84,1,173,198,212,20,48,139,113,180,181,5,36,42,220,109,29, +13,65,74,6,192,95,76,188,6,196,55,78,188,6,247,91,86,136,26,32,104,220,205, +72,1,98,234,52,122,130,136,18,72,51,117,68,3,146,27,168,40,161,37,8,207,80, +81,129,204,13,212,20,112,179,141,26,45,65,75,112,20,43,193,25,19,66,128, +153,78,40,105,144,92,104,152,131,124,27,253,128,0,10,116,3,68,146,163,9, +128,0,10,102,3,138,145,137,27,60,0,0,82,129,7,2,4,16,7,2,70,143,178,203, +164,237,35,14,25,10,134,147,143,139,158,72,207,28,54,77,47,109,13,55,113, +120,96,196,159,29,102,241,241,115,201,25,227,131,36,133,20,62,110,143,17, +16,113,137,62,62,46,155,167,135,147,142,47,44,151,79,221,64,98,37,194,94, +100,108,144,21,147,140,73,168,228,19,17,124,73,82,54,124,37,230,70,201,14, +108,185,36,155,14,243,243,83,212,69,131,132,4,12,137,114,168,37,166,145,7, +10,4,28,200,14,12,40,56,153,56,178,52,211,60,124,0,0,85,0,160,226,100,227, +138,89,18,113,240,0,1,86,1,131,66,148,145,143,128,0,10,144,93,134,0,0,43, +80,17,42,4,17,136,49,73,19,49,134,16,143,67,137,146,91,79,36,118,136,178, +48,141,156,0,0,15,3,240,0,0,0,3,49,135,16,143,67,137,146,91,79,36,118,136, +178,48,141,156,0,0,15,3,240,0,0,0,5,20,5,173,194,227,214,4,55,0,0,21,196,7, +122,192,134,241,197,192,0,5,121,25,140,64,132,122,28,76,146,218,121,35,180, +69,145,132,108,224,0,0,120,31,128,0,0,0,25,140,72,132,122,28,76,146,218, +121,35,180,69,145,132,108,224,0,0,0,32,0,0,0,0,25,140,80,132,122,28,76,146, +218,121,35,180,69,145,132,108,224,0,0,0,32,0,0,0,0,25,140,88,132,122,28,76, +146,218,121,35,180,69,145,132,108,224,0,0,8,32,0,0,0,0,25,140,96,132,122, +28,76,146,218,121,35,180,69,145,132,108,224,0,0,8,32,0,0,0,0,25,140,104, +132,122,28,76,146,218,121,35,180,69,145,132,108,224,0,0,8,32,0,0,0,0,25, +140,112,132,122,28,76,146,218,121,35,180,69,145,132,108,224,0,0,16,32,0,0, +0,0,16,113,225,0,48,156,209,2,122,244,5,34,92,35,68,225,161,166,218,16,33, +18,224,104,82,146,59,50,5,7,19,39,22,70,154,103,215,32,28,78,99,193,18,80, +70,131,165,1,205,34,8,35,68,225,161,166,239,255,4,12,70,137,195,39,248,73, +7,78,3,154,102,16,70,137,195,67,77,223,248,1,74,9,129,125,255,130,9,65,154, +232,147,161,115,59,255,5,64,195,32,156,50,126,197,14,2,3,107,173,213,0, }; #else #error invalid endianness defines @@ -11715,18 +11456,10 @@ DUK_UNREF(udata); DUK_UNREF(msg); - msg = msg ? msg : "NULL"; - #if defined(DUK_USE_FATAL_HANDLER) /* duk_config.h provided a custom default fatal handler. */ - DUK_D(DUK_DPRINT("custom default fatal error handler called: %s", msg)); + DUK_D(DUK_DPRINT("custom default fatal error handler called: %s", msg ? msg : "NULL")); DUK_USE_FATAL_HANDLER(udata, msg); -#elif defined(DUK_USE_CPP_EXCEPTIONS) - /* With C++ use a duk_fatal_exception which user code can catch in - * a natural way. - */ - DUK_D(DUK_DPRINT("built-in default C++ fatal error handler called: %s", msg)); - throw duk_fatal_exception(msg); #else /* Default behavior is to abort() on error. There's no printout * which makes this awkward, so it's always recommended to use an @@ -11743,7 +11476,7 @@ * - http://duktape.org/api.html#taglist-protected * ==================================================================== */ - DUK_D(DUK_DPRINT("built-in default fatal error handler called: %s", msg)); + DUK_D(DUK_DPRINT("built-in default fatal error handler called: %s", msg ? msg : "NULL")); DUK_ABORT(); #endif @@ -11898,7 +11631,7 @@ /* * Unicode codepoints above U+FFFF are encoded as surrogate * pairs here. This ensures that all CESU-8 codepoints are - * 16-bit values as expected in ECMAScript. The surrogate + * 16-bit values as expected in Ecmascript. The surrogate * pairs always get a 3-byte encoding (each) in CESU-8. * See: http://en.wikipedia.org/wiki/Surrogate_pair * @@ -12037,7 +11770,8 @@ return cp; } DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); + return 0; } /* Compute (extended) utf-8 length without codepoint encoding validation, @@ -12186,7 +11920,7 @@ duk_bitdecoder_ctx bd_ctx; duk_codepoint_t prev_re; - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); bd_ctx.data = (const duk_uint8_t *) unitab; bd_ctx.length = (duk_size_t) unilen; @@ -12738,7 +12472,7 @@ } /* 1:1 or special conversions, but not locale/context specific: script generated rules */ - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); if (uppercase) { bd_ctx.data = (const duk_uint8_t *) duk_unicode_caseconv_uc; bd_ctx.length = (duk_size_t) sizeof(duk_unicode_caseconv_uc); @@ -12937,7 +12671,7 @@ #endif /* DUK_USE_REGEXP_SUPPORT */ /* - * Misc util stuff. + * Misc util stuff */ /* #include duk_internal.h -> already included */ @@ -13100,6 +12834,45 @@ #endif /* DUK_USE_HEX_FASTPATH */ /* + * Table for base-64 encoding + */ + +#if defined(DUK_USE_BASE64_FASTPATH) +DUK_INTERNAL const duk_uint8_t duk_base64_enctab[64] = { + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* A...P */ + 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* Q...f */ + 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* g...v */ + 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2b, 0x2f /* w.../ */ +}; +#endif /* DUK_USE_BASE64_FASTPATH */ + +/* + * Table for base-64 decoding + */ + +#if defined(DUK_USE_BASE64_FASTPATH) +DUK_INTERNAL const duk_int8_t duk_base64_dectab[256] = { + /* -1 = error, -2 = allowed whitespace, -3 = padding ('='), 0...63 decoded bytes */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -1, -1, -2, -1, -1, /* 0x00...0x0f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10...0x1f */ + -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* 0x20...0x2f */ + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -3, -1, -1, /* 0x30...0x3f */ + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40...0x4f */ + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 0x50...0x5f */ + -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60...0x6f */ + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, /* 0x70...0x7f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x80...0x8f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x90...0x9f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xa0...0xaf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xb0...0xbf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xc0...0xcf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xd0...0xdf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xe0...0xef */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 0xf0...0xff */ +}; +#endif /* DUK_USE_BASE64_FASTPATH */ + +/* * Arbitrary byteswap for potentially unaligned values * * Used to byteswap pointers e.g. in debugger code. @@ -13119,8 +12892,191 @@ } } #endif + +/* + * Miscellaneous coercion / clamping helpers. + */ + +/* Check whether a duk_double_t is a whole number in the 32-bit range (reject + * negative zero), and if so, return a duk_int32_t. + * For compiler use: don't allow negative zero as it will cause trouble with + * LDINT+LDINTX, positive zero is OK. + */ +DUK_INTERNAL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int32_t *ival) { + duk_int32_t t; + + t = (duk_int32_t) x; + if (!((duk_double_t) t == x)) { + return 0; + } + if (t == 0) { + duk_double_union du; + du.d = x; + if (DUK_DBLUNION_HAS_SIGNBIT(&du)) { + return 0; + } + } + *ival = t; + return 1; +} + +/* Check whether a duk_double_t is a whole number in the 32-bit range, and if + * so, return a duk_int32_t. + */ +DUK_INTERNAL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival) { + duk_int32_t t; + + t = (duk_int32_t) x; + if (!((duk_double_t) t == x)) { + return 0; + } + *ival = t; + return 1; +} + +/* + * IEEE double checks + */ + +DUK_INTERNAL duk_bool_t duk_double_is_anyinf(duk_double_t x) { + duk_double_union du; + du.d = x; + return DUK_DBLUNION_IS_ANYINF(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_posinf(duk_double_t x) { + duk_double_union du; + du.d = x; + return DUK_DBLUNION_IS_POSINF(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_neginf(duk_double_t x) { + duk_double_union du; + du.d = x; + return DUK_DBLUNION_IS_NEGINF(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan(duk_double_t x) { + duk_double_union du; + du.d = x; + /* Assumes we're dealing with a Duktape internal NaN which is + * NaN normalized if duk_tval requires it. + */ + DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); + return DUK_DBLUNION_IS_NAN(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan_or_zero(duk_double_t x) { + duk_double_union du; + du.d = x; + /* Assumes we're dealing with a Duktape internal NaN which is + * NaN normalized if duk_tval requires it. + */ + DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); + return DUK_DBLUNION_IS_NAN(&du) || DUK_DBLUNION_IS_ANYZERO(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan_or_inf(duk_double_t x) { + duk_double_union du; + du.d = x; + /* If exponent is 0x7FF the argument is either a NaN or an + * infinity. We don't need to check any other fields. + */ +#if defined(DUK_USE_64BIT_OPS) +#if defined(DUK_USE_DOUBLE_ME) + return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000)) == DUK_U64_CONSTANT(0x000000007ff00000); +#else + return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000)) == DUK_U64_CONSTANT(0x7ff0000000000000); +#endif +#else + return (du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL) == 0x7ff00000UL; +#endif +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan_zero_inf(duk_double_t x) { + duk_double_union du; +#if defined(DUK_USE_64BIT_OPS) + duk_uint64_t t; +#else + duk_uint32_t t; +#endif + du.d = x; +#if defined(DUK_USE_64BIT_OPS) +#if defined(DUK_USE_DOUBLE_ME) + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000); + if (t == DUK_U64_CONSTANT(0x0000000000000000)) { + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x0000000080000000); + return t == 0; + } + if (t == DUK_U64_CONSTANT(0x000000007ff00000)) { + return 1; + } +#else + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000); + if (t == DUK_U64_CONSTANT(0x0000000000000000)) { + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x8000000000000000); + return t == 0; + } + if (t == DUK_U64_CONSTANT(0x7ff0000000000000)) { + return 1; + } +#endif +#else + t = du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL; + if (t == 0x00000000UL) { + return DUK_DBLUNION_IS_ANYZERO(&du); + } + if (t == 0x7ff00000UL) { + return 1; + } +#endif + return 0; +} + +DUK_INTERNAL duk_small_uint_t duk_double_signbit(duk_double_t x) { + duk_double_union du; + du.d = x; + return (duk_small_uint_t) DUK_DBLUNION_GET_SIGNBIT(&du); +} + +DUK_INTERNAL duk_double_t duk_double_trunc_towards_zero(duk_double_t x) { + /* XXX: optimize */ + duk_small_uint_t s = duk_double_signbit(x); + x = DUK_FLOOR(DUK_FABS(x)); /* truncate towards zero */ + if (s) { + x = -x; + } + return x; +} + +DUK_INTERNAL duk_bool_t duk_double_same_sign(duk_double_t x, duk_double_t y) { + duk_double_union du1; + duk_double_union du2; + du1.d = x; + du2.d = y; + + return (((du1.ui[DUK_DBL_IDX_UI0] ^ du2.ui[DUK_DBL_IDX_UI0]) & 0x80000000UL) == 0); +} + +DUK_INTERNAL duk_double_t duk_double_fmin(duk_double_t x, duk_double_t y) { + /* Doesn't replicate fmin() behavior exactly: for fmin() if one + * argument is a NaN, the other argument should be returned. + * Duktape doesn't rely on this behavior so the replacement can + * be simplified. + */ + return (x < y ? x : y); +} + +DUK_INTERNAL duk_double_t duk_double_fmax(duk_double_t x, duk_double_t y) { + /* Doesn't replicate fmax() behavior exactly: for fmax() if one + * argument is a NaN, the other argument should be returned. + * Duktape doesn't rely on this behavior so the replacement can + * be simplified. + */ + return (x > y ? x : y); +} /* - * Hobject ECMAScript [[Class]]. + * Hobject Ecmascript [[Class]]. */ /* #include duk_internal.h -> already included */ @@ -13298,10 +13254,9 @@ if (!(DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE); - DUK_WO_NORETURN(return NULL;); } - /* Maximum size check is handled by callee. */ + /* maximum size check is handled by callee */ duk_hbuffer_resize(thr, h, new_size); return DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, h); @@ -13319,7 +13274,6 @@ if (!(DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE); - DUK_WO_NORETURN(return NULL;); } /* Forget the previous allocation, setting size to 0 and alloc to @@ -13348,7 +13302,6 @@ if (!DUK_HBUFFER_HAS_EXTERNAL(h)) { DUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE); - DUK_WO_NORETURN(return;); } DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(h)); @@ -13397,7 +13350,7 @@ len = DUK_RAW_READ_U32_BE(p); buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, (duk_size_t) len); DUK_ASSERT(buf != NULL); - duk_memcpy((void *) buf, (const void *) p, (size_t) len); + DUK_MEMCPY((void *) buf, (const void *) p, (size_t) len); p += len; return p; } @@ -13412,7 +13365,7 @@ DUK_ASSERT(len <= 0xffffffffUL); /* string limits */ tmp32 = (duk_uint32_t) len; DUK_RAW_WRITE_U32_BE(p, tmp32); - duk_memcpy((void *) p, + DUK_MEMCPY((void *) p, (const void *) DUK_HSTRING_GET_DATA(h), len); p += len; @@ -13431,10 +13384,9 @@ DUK_ASSERT(len <= 0xffffffffUL); /* buffer limits */ tmp32 = (duk_uint32_t) len; DUK_RAW_WRITE_U32_BE(p, tmp32); - /* When len == 0, buffer data pointer may be NULL. */ - duk_memcpy_unsafe((void *) p, - (const void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h), - len); + DUK_MEMCPY((void *) p, + (const void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h), + len); p += len; return p; } @@ -13646,7 +13598,7 @@ ins_end = DUK_HCOMPFUNC_GET_CODE_END(thr->heap, func); DUK_ASSERT((duk_size_t) (ins_end - ins) == (duk_size_t) count_instr); #if defined(DUK_USE_INTEGER_BE) - duk_memcpy_unsafe((void *) p, (const void *) ins, (size_t) (ins_end - ins)); + DUK_MEMCPY((void *) p, (const void *) ins, (size_t) (ins_end - ins)); p += (size_t) (ins_end - ins); #else while (ins != ins_end) { @@ -13668,7 +13620,7 @@ h_str = DUK_TVAL_GET_STRING(tv); DUK_ASSERT(h_str != NULL); DUK_ASSERT(DUK_HSTRING_MAX_BYTELEN <= 0x7fffffffUL); /* ensures no overflow */ - p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 1U + 4U + DUK_HSTRING_GET_BYTELEN(h_str), p); + p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 1U + 4U + DUK_HSTRING_GET_BYTELEN(h_str), p), *p++ = DUK__SER_STRING; p = duk__dump_hstring_raw(p, h_str); } else { @@ -13832,7 +13784,7 @@ DUK__ASSERT_LEFT(count_instr * sizeof(duk_instr_t)); #if defined(DUK_USE_INTEGER_BE) q = fun_data + sizeof(duk_tval) * count_const + sizeof(duk_hobject *) * count_funcs; - duk_memcpy((void *) q, + DUK_MEMCPY((void *) q, (const void *) p, sizeof(duk_instr_t) * count_instr); p += sizeof(duk_instr_t) * count_instr; @@ -13897,12 +13849,15 @@ DUK_ASSERT((count_const == 0 && count_funcs == 0) || tv1 != NULL); q = fun_data; - duk_memcpy_unsafe((void *) q, (const void *) tv1, sizeof(duk_tval) * count_const); - for (n = count_const; n > 0; n--) { - DUK_TVAL_INCREF_FAST(thr, (duk_tval *) (void *) q); /* no side effects */ - q += sizeof(duk_tval); + if (count_const > 0) { + /* Explicit zero size check to avoid NULL 'tv1'. */ + DUK_MEMCPY((void *) q, (const void *) tv1, sizeof(duk_tval) * count_const); + for (n = count_const; n > 0; n--) { + DUK_TVAL_INCREF_FAST(thr, (duk_tval *) (void *) q); /* no side effects */ + q += sizeof(duk_tval); + } + tv1 += count_const; } - tv1 += count_const; DUK_HCOMPFUNC_SET_FUNCS(thr->heap, h_fun, (duk_hobject **) (void *) q); for (n = count_funcs; n > 0; n--) { @@ -14103,7 +14058,6 @@ format_error: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_BYTECODE); - DUK_WO_NORETURN(return;); } #else /* DUK_USE_BYTECODE_DUMP_SUPPORT */ @@ -14111,13 +14065,11 @@ DUK_EXTERNAL void duk_dump_function(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_load_function(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_BYTECODE_DUMP_SUPPORT */ @@ -14184,7 +14136,7 @@ idx_func = duk_get_top(thr) - nargs - other; if (DUK_UNLIKELY((idx_func | nargs) < 0)) { /* idx_func < 0 || nargs < 0; OR sign bits */ DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + /* unreachable */ } DUK_ASSERT(duk_is_valid_index(thr, idx_func)); return idx_func; @@ -14296,7 +14248,6 @@ obj_idx = duk_require_normalize_index(thr, obj_idx); /* make absolute */ if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return;); } duk__call_prop_prep_stack(thr, obj_idx, nargs); @@ -14333,7 +14284,7 @@ args.nargs = nargs; if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } args.call_flags = 0; @@ -14368,7 +14319,7 @@ args.nargs = nargs; if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } args.call_flags = call_flags; @@ -14409,7 +14360,7 @@ args.nargs = nargs; if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } args.call_flags = 0; @@ -14445,7 +14396,7 @@ (long) (thr->valstack_top - thr->valstack), (long) nrets)); DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } rc = duk_handle_safe_call(thr, /* thread */ @@ -14493,7 +14444,7 @@ if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } rc = duk_safe_call(thr, duk__pnew_helper, (void *) &nargs /*udata*/, nargs + 1 /*nargs*/, 1 /*nrets*/); @@ -14520,7 +14471,6 @@ if (!duk_is_constructor_call(thr)) { DUK_ERROR_TYPE(thr, DUK_STR_CONSTRUCT_ONLY); - DUK_WO_NORETURN(return;); } } @@ -14531,7 +14481,7 @@ * because all Duktape/C functions are considered strict, * and strict is also the default when nothing is running. * However, Duktape may call this function internally when - * the current activation is an ECMAScript function, so + * the current activation is an Ecmascript function, so * this cannot be replaced by a 'return 1' without fixing * the internal call sites. */ @@ -14598,7 +14548,7 @@ /* fall through */ type_error: DUK_ERROR_TYPE(thr, DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_EXTERNAL void duk_set_magic(duk_hthread *thr, duk_idx_t idx, duk_int_t magic) { @@ -14630,7 +14580,7 @@ h = DUK_TVAL_GET_OBJECT(tv); DUK_ASSERT(h != NULL); if (DUK_HOBJECT_HAS_BOUNDFUNC(h)) { - duk_push_tval(thr, &((duk_hboundfunc *) (void *) h)->target); + duk_push_tval(thr, &((duk_hboundfunc *) h)->target); duk_replace(thr, -2); #if 0 DUK_TVAL_SET_TVAL(tv, &((duk_hboundfunc *) h)->target); @@ -14660,10 +14610,6 @@ /* #include duk_internal.h -> already included */ -/* - * Misc helpers - */ - /* Shared handling for encode/decode argument. Fast path handling for * buffer and string values because they're the most common. In particular, * avoid creating a temporary string or buffer when possible. @@ -14685,425 +14631,250 @@ return (const duk_uint8_t *) duk_to_lstring(thr, idx, out_len); } -/* - * Base64 - */ - -#if defined(DUK_USE_BASE64_SUPPORT) -/* Bytes emitted for number of padding characters in range [0,4]. */ -DUK_LOCAL const duk_int8_t duk__base64_decode_nequal_step[5] = { - 3, /* #### -> 24 bits, emit 3 bytes */ - 2, /* ###= -> 18 bits, emit 2 bytes */ - 1, /* ##== -> 12 bits, emit 1 byte */ - -1, /* #=== -> 6 bits, error */ - 0, /* ==== -> 0 bits, emit 0 bytes */ -}; - -#if defined(DUK_USE_BASE64_FASTPATH) -DUK_LOCAL const duk_uint8_t duk__base64_enctab_fast[64] = { - 0x41U, 0x42U, 0x43U, 0x44U, 0x45U, 0x46U, 0x47U, 0x48U, 0x49U, 0x4aU, 0x4bU, 0x4cU, 0x4dU, 0x4eU, 0x4fU, 0x50U, /* A...P */ - 0x51U, 0x52U, 0x53U, 0x54U, 0x55U, 0x56U, 0x57U, 0x58U, 0x59U, 0x5aU, 0x61U, 0x62U, 0x63U, 0x64U, 0x65U, 0x66U, /* Q...f */ - 0x67U, 0x68U, 0x69U, 0x6aU, 0x6bU, 0x6cU, 0x6dU, 0x6eU, 0x6fU, 0x70U, 0x71U, 0x72U, 0x73U, 0x74U, 0x75U, 0x76U, /* g...v */ - 0x77U, 0x78U, 0x79U, 0x7aU, 0x30U, 0x31U, 0x32U, 0x33U, 0x34U, 0x35U, 0x36U, 0x37U, 0x38U, 0x39U, 0x2bU, 0x2fU /* w.../ */ -}; -#endif /* DUK_USE_BASE64_FASTPATH */ - #if defined(DUK_USE_BASE64_FASTPATH) -/* Decode table for one byte of input: - * -1 = allowed whitespace - * -2 = padding - * -3 = error - * 0...63 decoded bytes - */ -DUK_LOCAL const duk_int8_t duk__base64_dectab_fast[256] = { - -3, -3, -3, -3, -3, -3, -3, -3, -3, -1, -1, -3, -3, -1, -3, -3, /* 0x00...0x0f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0x10...0x1f */ - -1, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, 62, -3, -3, -3, 63, /* 0x20...0x2f */ - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -3, -3, -3, -2, -3, -3, /* 0x30...0x3f */ - -3, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40...0x4f */ - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -3, -3, -3, -3, -3, /* 0x50...0x5f */ - -3, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60...0x6f */ - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -3, -3, -3, -3, -3, /* 0x70...0x7f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0x80...0x8f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0x90...0x9f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xa0...0xaf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xb0...0xbf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xc0...0xcf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xd0...0xdf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xe0...0xef */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3 /* 0xf0...0xff */ -}; -#endif /* DUK_USE_BASE64_FASTPATH */ - -#if defined(DUK_USE_BASE64_FASTPATH) -DUK_LOCAL DUK_ALWAYS_INLINE void duk__base64_encode_fast_3(const duk_uint8_t *src, duk_uint8_t *dst) { +DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) { duk_uint_t t; + duk_size_t n_full, n_full3, n_final; + const duk_uint8_t *src_end_fast; - t = (duk_uint_t) src[0]; - t = (t << 8) + (duk_uint_t) src[1]; - t = (t << 8) + (duk_uint_t) src[2]; - - dst[0] = duk__base64_enctab_fast[t >> 18]; - dst[1] = duk__base64_enctab_fast[(t >> 12) & 0x3fU]; - dst[2] = duk__base64_enctab_fast[(t >> 6) & 0x3fU]; - dst[3] = duk__base64_enctab_fast[t & 0x3fU]; - -#if 0 - /* Tested: not faster on x64, most likely due to aliasing between - * output and input index computation. - */ - /* aaaaaabb bbbbcccc ccdddddd */ - dst[0] = duk__base64_enctab_fast[(src[0] >> 2) & 0x3fU]; - dst[1] = duk__base64_enctab_fast[((src[0] << 4) & 0x30U) | ((src[1] >> 4) & 0x0fU)]; - dst[2] = duk__base64_enctab_fast[((src[1] << 2) & 0x3fU) | ((src[2] >> 6) & 0x03U)]; - dst[3] = duk__base64_enctab_fast[src[2] & 0x3fU]; + n_full = srclen / 3; /* full 3-byte -> 4-char conversions */ + n_full3 = n_full * 3; + n_final = srclen - n_full3; + DUK_ASSERT_DISABLE(n_final >= 0); + DUK_ASSERT(n_final <= 2); + + src_end_fast = src + n_full3; + while (DUK_UNLIKELY(src != src_end_fast)) { + t = (duk_uint_t) (*src++); + t = (t << 8) + (duk_uint_t) (*src++); + t = (t << 8) + (duk_uint_t) (*src++); + + *dst++ = duk_base64_enctab[t >> 18]; + *dst++ = duk_base64_enctab[(t >> 12) & 0x3f]; + *dst++ = duk_base64_enctab[(t >> 6) & 0x3f]; + *dst++ = duk_base64_enctab[t & 0x3f]; + +#if 0 /* Tested: not faster on x64 */ + /* aaaaaabb bbbbcccc ccdddddd */ + dst[0] = duk_base64_enctab[(src[0] >> 2) & 0x3f]; + dst[1] = duk_base64_enctab[((src[0] << 4) & 0x30) | ((src[1] >> 4) & 0x0f)]; + dst[2] = duk_base64_enctab[((src[1] << 2) & 0x3f) | ((src[2] >> 6) & 0x03)]; + dst[3] = duk_base64_enctab[src[2] & 0x3f]; + src += 3; dst += 4; #endif -} - -DUK_LOCAL DUK_ALWAYS_INLINE void duk__base64_encode_fast_2(const duk_uint8_t *src, duk_uint8_t *dst) { - duk_uint_t t; - - t = (duk_uint_t) src[0]; - t = (t << 8) + (duk_uint_t) src[1]; - dst[0] = duk__base64_enctab_fast[t >> 10]; /* XXXXXX-- -------- */ - dst[1] = duk__base64_enctab_fast[(t >> 4) & 0x3fU]; /* ------XX XXXX---- */ - dst[2] = duk__base64_enctab_fast[(t << 2) & 0x3fU]; /* -------- ----XXXX */ - dst[3] = DUK_ASC_EQUALS; -} - -DUK_LOCAL DUK_ALWAYS_INLINE void duk__base64_encode_fast_1(const duk_uint8_t *src, duk_uint8_t *dst) { - duk_uint_t t; - - t = (duk_uint_t) src[0]; - dst[0] = duk__base64_enctab_fast[t >> 2]; /* XXXXXX-- */ - dst[1] = duk__base64_enctab_fast[(t << 4) & 0x3fU]; /* ------XX */ - dst[2] = DUK_ASC_EQUALS; - dst[3] = DUK_ASC_EQUALS; -} - -DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) { - duk_size_t n; - const duk_uint8_t *p; - duk_uint8_t *q; - - n = srclen; - p = src; - q = dst; - - if (n >= 16U) { - /* Fast path, unrolled by 4, allows interleaving. Process - * 12-byte input chunks which encode to 16-char output chunks. - * Only enter when at least one block is emitted (avoids div+mul - * for short inputs too). - */ - const duk_uint8_t *p_end_fast; + } - p_end_fast = p + ((n / 12U) * 12U); - DUK_ASSERT(p_end_fast >= p + 12); - do { - duk__base64_encode_fast_3(p, q); - duk__base64_encode_fast_3(p + 3, q + 4); - duk__base64_encode_fast_3(p + 6, q + 8); - duk__base64_encode_fast_3(p + 9, q + 12); - p += 12; - q += 16; - } while (DUK_LIKELY(p != p_end_fast)); - - DUK_ASSERT(src + srclen >= p); - n = (duk_size_t) (src + srclen - p); - DUK_ASSERT(n < 12U); - } - - /* Remainder. */ - while (n >= 3U) { - duk__base64_encode_fast_3(p, q); - p += 3; - q += 4; - n -= 3U; + switch (n_final) { + /* case 0: nop */ + case 1: { + /* XX== */ + t = (duk_uint_t) (*src++); + *dst++ = duk_base64_enctab[t >> 2]; /* XXXXXX-- */ + *dst++ = duk_base64_enctab[(t << 4) & 0x3f]; /* ------XX */ + *dst++ = DUK_ASC_EQUALS; + *dst++ = DUK_ASC_EQUALS; + break; + } + case 2: { + /* XXX= */ + t = (duk_uint_t) (*src++); + t = (t << 8) + (duk_uint_t) (*src++); + *dst++ = duk_base64_enctab[t >> 10]; /* XXXXXX-- -------- */ + *dst++ = duk_base64_enctab[(t >> 4) & 0x3f]; /* ------XX XXXX---- */ + *dst++ = duk_base64_enctab[(t << 2) & 0x3f]; /* -------- ----XXXX */ + *dst++ = DUK_ASC_EQUALS; + break; } - DUK_ASSERT(n == 0U || n == 1U || n == 2U); - if (n == 1U) { - duk__base64_encode_fast_1(p, q); -#if 0 /* Unnecessary. */ - p += 1; - q += 4; - n -= 1U; -#endif - } else if (n == 2U) { - duk__base64_encode_fast_2(p, q); -#if 0 /* Unnecessary. */ - p += 2; - q += 4; - n -= 2U; -#endif - } else { - DUK_ASSERT(n == 0U); /* nothing to do */ - ; } } #else /* DUK_USE_BASE64_FASTPATH */ DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) { - duk_small_uint_t i, npad; - duk_uint_t t, x, y; - const duk_uint8_t *p; - const duk_uint8_t *p_end; - duk_uint8_t *q; + duk_small_uint_t i, snip; + duk_uint_t t; + duk_uint_fast8_t x, y; + const duk_uint8_t *src_end; - p = src; - p_end = src + srclen; - q = dst; - npad = 0U; + src_end = src + srclen; - while (p < p_end) { - /* Read 3 bytes into 't', padded by zero. */ + while (src < src_end) { + /* read 3 bytes into 't', padded by zero */ + snip = 4; t = 0; for (i = 0; i < 3; i++) { t = t << 8; - if (p < p_end) { - t += (duk_uint_t) (*p++); + if (src >= src_end) { + snip--; } else { - /* This only happens on the last loop and we're - * guaranteed to exit on the next loop. - */ - npad++; + t += (duk_uint_t) (*src++); } } - DUK_ASSERT(npad <= 2U); - /* Emit 4 encoded characters. If npad > 0, some of the - * chars will be incorrect (zero bits) but we fix up the - * padding after the loop. A straightforward 64-byte - * lookup would be faster and cleaner, but this is shorter. + /* + * Missing bytes snip base64 example + * 0 4 XXXX + * 1 3 XXX= + * 2 2 XX== */ + + DUK_ASSERT(snip >= 2 && snip <= 4); + for (i = 0; i < 4; i++) { - x = ((t >> 18) & 0x3fU); + x = (duk_uint_fast8_t) ((t >> 18) & 0x3f); t = t << 6; - if (x <= 51U) { - if (x <= 25) { - y = x + DUK_ASC_UC_A; - } else { - y = x - 26 + DUK_ASC_LC_A; - } + /* A straightforward 64-byte lookup would be faster + * and cleaner, but this is shorter. + */ + if (i >= snip) { + y = '='; + } else if (x <= 25) { + y = x + 'A'; + } else if (x <= 51) { + y = x - 26 + 'a'; + } else if (x <= 61) { + y = x - 52 + '0'; + } else if (x == 62) { + y = '+'; } else { - if (x <= 61U) { - y = x - 52 + DUK_ASC_0; - } else if (x == 62) { - y = DUK_ASC_PLUS; - } else { - DUK_ASSERT(x == 63); - y = DUK_ASC_SLASH; - } + y = '/'; } - *q++ = (duk_uint8_t) y; + *dst++ = (duk_uint8_t) y; } } - - /* Handle padding by rewriting 0-2 bogus characters at the end. - * - * Missing bytes npad base64 example - * 0 0 #### - * 1 1 ###= - * 2 2 ##== - */ - DUK_ASSERT(npad <= 2U); - while (npad > 0U) { - *(q - npad) = DUK_ASC_EQUALS; - npad--; - } } #endif /* DUK_USE_BASE64_FASTPATH */ #if defined(DUK_USE_BASE64_FASTPATH) DUK_LOCAL duk_bool_t duk__base64_decode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst, duk_uint8_t **out_dst_final) { duk_int_t x; - duk_uint_t t; + duk_int_t t; duk_small_uint_t n_equal; - duk_int8_t step; - const duk_uint8_t *p; - const duk_uint8_t *p_end; - const duk_uint8_t *p_end_safe; - duk_uint8_t *q; - - p = src; - p_end = src + srclen; - p_end_safe = p_end - 8; /* If 'src <= src_end_safe', safe to read 8 bytes. */ - q = dst; - - /* Alternate between a fast path which processes clean groups with no - * padding or whitespace, and a slow path which processes one arbitrary - * group and then re-enters the fast path. This handles e.g. base64 - * with newlines reasonably well because the majority of a line is in - * the fast path. + duk_small_uint_t n_chars; + const duk_uint8_t *src_end; + const duk_uint8_t *src_end_safe; + + src_end = src + srclen; + src_end_safe = src_end - 4; /* if 'src < src_end_safe', safe to read 4 bytes */ + + /* Innermost fast path processes 4 valid base-64 characters at a time + * but bails out on whitespace, padding chars ('=') and invalid chars. + * Once the slow path segment has been processed, we return to the + * inner fast path again. This handles e.g. base64 with newlines + * reasonably well because the majority of a line is in the fast path. */ for (;;) { - /* Fast path, on each loop handle two 4-char input groups. - * If both are clean, emit 6 bytes and continue. If first - * is clean, emit 3 bytes and drop out; otherwise emit - * nothing and drop out. This approach could be extended to - * more groups per loop, but for inputs with e.g. periodic - * newlines (which are common) it might not be an improvement. - */ - while (DUK_LIKELY(p <= p_end_safe)) { - duk_int_t t1, t2; - - /* The lookup byte is intentionally sign extended to - * (at least) 32 bits and then ORed. This ensures - * that is at least 1 byte is negative, the highest - * bit of the accumulator will be set at the end and - * we don't need to check every byte. - * - * Read all input bytes first before writing output - * bytes to minimize aliasing. - */ - DUK_DDD(DUK_DDDPRINT("fast loop: p=%p, p_end_safe=%p, p_end=%p", - (const void *) p, (const void *) p_end_safe, (const void *) p_end)); + /* Fast path, handle units with just actual encoding characters. */ - t1 = (duk_int_t) duk__base64_dectab_fast[p[0]]; - t1 = (duk_int_t) ((duk_uint_t) t1 << 6) | (duk_int_t) duk__base64_dectab_fast[p[1]]; - t1 = (duk_int_t) ((duk_uint_t) t1 << 6) | (duk_int_t) duk__base64_dectab_fast[p[2]]; - t1 = (duk_int_t) ((duk_uint_t) t1 << 6) | (duk_int_t) duk__base64_dectab_fast[p[3]]; - - t2 = (duk_int_t) duk__base64_dectab_fast[p[4]]; - t2 = (duk_int_t) ((duk_uint_t) t2 << 6) | (duk_int_t) duk__base64_dectab_fast[p[5]]; - t2 = (duk_int_t) ((duk_uint_t) t2 << 6) | (duk_int_t) duk__base64_dectab_fast[p[6]]; - t2 = (duk_int_t) ((duk_uint_t) t2 << 6) | (duk_int_t) duk__base64_dectab_fast[p[7]]; - - q[0] = (duk_uint8_t) (((duk_uint_t) t1 >> 16) & 0xffU); - q[1] = (duk_uint8_t) (((duk_uint_t) t1 >> 8) & 0xffU); - q[2] = (duk_uint8_t) ((duk_uint_t) t1 & 0xffU); - - q[3] = (duk_uint8_t) (((duk_uint_t) t2 >> 16) & 0xffU); - q[4] = (duk_uint8_t) (((duk_uint_t) t2 >> 8) & 0xffU); - q[5] = (duk_uint8_t) ((duk_uint_t) t2 & 0xffU); - - /* Optimistic check using one branch. */ - if (DUK_LIKELY((t1 | t2) >= 0)) { - p += 8; - q += 6; - } else if (t1 >= 0) { - DUK_DDD(DUK_DDDPRINT("fast loop first group was clean, second was not, process one slow path group")); - DUK_ASSERT(t2 < 0); - p += 4; - q += 3; - break; - } else { - DUK_DDD(DUK_DDDPRINT("fast loop first group was not clean, second does not matter, process one slow path group")); - DUK_ASSERT(t1 < 0); + while (src <= src_end_safe) { + /* The lookup byte is intentionally sign extended to (at least) + * 32 bits and then ORed. This ensures that is at least 1 byte + * is negative, the highest bit of 't' will be set at the end + * and we don't need to check every byte. + */ + DUK_DDD(DUK_DDDPRINT("fast loop: src=%p, src_end_safe=%p, src_end=%p", + (const void *) src, (const void *) src_end_safe, (const void *) src_end)); + + t = (duk_int_t) duk_base64_dectab[*src++]; + t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++]; + t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++]; + t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++]; + + if (DUK_UNLIKELY(t < 0)) { + DUK_DDD(DUK_DDDPRINT("fast loop unit was not clean, process one slow path unit")); + src -= 4; break; } - } /* fast path */ - /* Slow path step 1: try to scan a 4-character encoded group, - * end-of-input, or start-of-padding. We exit with: - * 1. n_chars == 4: full group, no padding, no end-of-input. - * 2. n_chars < 4: partial group (may also be 0), encountered - * padding or end of input. - * - * The accumulator is initialized to 1; this allows us to detect - * a full group by comparing >= 0x1000000 without an extra - * counter variable. - */ - t = 1UL; + DUK_ASSERT(t <= 0xffffffL); + DUK_ASSERT((t >> 24) == 0); + *dst++ = (duk_uint8_t) (t >> 16); + *dst++ = (duk_uint8_t) ((t >> 8) & 0xff); + *dst++ = (duk_uint8_t) (t & 0xff); + } + + /* Handle one slow path unit (or finish if we're done). */ + + n_equal = 0; + n_chars = 0; + t = 0; for (;;) { - DUK_DDD(DUK_DDDPRINT("slow loop: p=%p, p_end=%p, t=%lu", - (const void *) p, (const void *) p_end, (unsigned long) t)); + DUK_DDD(DUK_DDDPRINT("slow loop: src=%p, src_end=%p, n_chars=%ld, n_equal=%ld, t=%ld", + (const void *) src, (const void *) src_end, (long) n_chars, (long) n_equal, (long) t)); - if (DUK_LIKELY(p < p_end)) { - x = duk__base64_dectab_fast[*p++]; - if (DUK_LIKELY(x >= 0)) { - DUK_ASSERT(x >= 0 && x <= 63); - t = (t << 6) + (duk_uint_t) x; - if (t >= 0x1000000UL) { - break; - } - } else if (x == -1) { + if (DUK_UNLIKELY(src >= src_end)) { + goto done; /* two level break */ + } + + x = duk_base64_dectab[*src++]; + if (DUK_UNLIKELY(x < 0)) { + if (x == -2) { continue; /* allowed ascii whitespace */ - } else if (x == -2) { - p--; - break; /* start of padding */ + } else if (x == -3) { + n_equal++; + t <<= 6; } else { - DUK_ASSERT(x == -3); + DUK_ASSERT(x == -1); goto decode_error; } } else { - break; /* end of input */ + DUK_ASSERT(x >= 0 && x <= 63); + if (n_equal > 0) { + /* Don't allow actual chars after equal sign. */ + goto decode_error; + } + t = (t << 6) + x; } - } /* slow path step 1 */ - - /* Complete the padding by simulating pad characters, - * regardless of actual input padding chars. - */ - n_equal = 0; - while (t < 0x1000000UL) { - t = (t << 6) + 0U; - n_equal++; - } - /* Slow path step 2: deal with full/partial group, padding, - * etc. Note that for num chars in [0,3] we intentionally emit - * 3 bytes but don't step forward that much, buffer space is - * guaranteed in setup. - * - * num chars: - * 0 #### no output (= step 0) - * 1 #=== reject, 6 bits of data - * 2 ##== 12 bits of data, output 1 byte (= step 1) - * 3 ###= 18 bits of data, output 2 bytes (= step 2) - * 4 #### 24 bits of data, output 3 bytes (= step 3) - */ - q[0] = (duk_uint8_t) ((t >> 16) & 0xffU); - q[1] = (duk_uint8_t) ((t >> 8) & 0xffU); - q[2] = (duk_uint8_t) (t & 0xffU); - - DUK_ASSERT(n_equal <= 4); - step = duk__base64_decode_nequal_step[n_equal]; - if (DUK_UNLIKELY(step < 0)) { - goto decode_error; - } - q += step; - - /* Slow path step 3: read and ignore padding and whitespace - * until (a) next non-padding and non-whitespace character - * after which we resume the fast path, or (b) end of input. - * This allows us to accept missing, partial, full, and extra - * padding cases uniformly. We also support concatenated - * base-64 documents because we resume scanning afterwards. - * - * Note that to support concatenated documents well, the '=' - * padding found inside the input must also allow for 'extra' - * padding. For example, 'Zm===' decodes to 'f' and has one - * extra padding char. So, 'Zm===Zm' should decode 'ff', even - * though the standard break-up would be 'Zm==' + '=Zm' which - * doesn't make sense. - * - * We also accept prepended padding like '==Zm9', because it - * is equivalent to an empty document with extra padding ('==') - * followed by a valid document. - */ + if (DUK_UNLIKELY(n_chars == 3)) { + /* Emit 3 bytes and backtrack if there was padding. There's + * always space for the whole 3 bytes so no check needed. + */ + DUK_ASSERT(t <= 0xffffffL); + DUK_ASSERT((t >> 24) == 0); + *dst++ = (duk_uint8_t) (t >> 16); + *dst++ = (duk_uint8_t) ((t >> 8) & 0xff); + *dst++ = (duk_uint8_t) (t & 0xff); + + if (DUK_UNLIKELY(n_equal > 0)) { + DUK_ASSERT(n_equal <= 4); + + /* There may be whitespace between the equal signs. */ + if (n_equal == 1) { + /* XXX= */ + dst -= 1; + } else if (n_equal == 2) { + /* XX== */ + dst -= 2; + } else { + goto decode_error; /* invalid padding */ + } - for (;;) { - if (DUK_UNLIKELY(p >= p_end)) { - goto done; - } - x = duk__base64_dectab_fast[*p++]; - if (x == -1 || x == -2) { - ; /* padding or whitespace, keep eating */ + /* Continue parsing after padding, allows concatenated, + * padded base64. + */ + } + break; /* back to fast loop */ } else { - p--; - break; /* backtrack and go back to fast path, even for -1 */ + n_chars++; } - } /* slow path step 3 */ - } /* outer fast+slow path loop */ - + } + } done: - DUK_DDD(DUK_DDDPRINT("done; p=%p, p_end=%p", - (const void *) p, (const void *) p_end)); + DUK_DDD(DUK_DDDPRINT("done; src=%p, src_end=%p, n_chars=%ld", + (const void *) src, (const void *) src_end, (long) n_chars)); - DUK_ASSERT(p == p_end); + DUK_ASSERT(src == src_end); + + if (n_chars != 0) { + /* Here we'd have the option of decoding unpadded base64 + * (e.g. "xxxxyy" instead of "xxxxyy==". Currently not + * accepted. + */ + goto decode_error; + } - *out_dst_final = q; + *out_dst_final = dst; return 1; decode_error: @@ -15111,138 +14882,94 @@ } #else /* DUK_USE_BASE64_FASTPATH */ DUK_LOCAL duk_bool_t duk__base64_decode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst, duk_uint8_t **out_dst_final) { - duk_uint_t t, x; - duk_int_t y; - duk_int8_t step; - const duk_uint8_t *p; - const duk_uint8_t *p_end; - duk_uint8_t *q; - /* 0x09, 0x0a, or 0x0d */ - duk_uint32_t mask_white = (1U << 9) | (1U << 10) | (1U << 13); + duk_uint_t t; + duk_uint_fast8_t x, y; + duk_small_uint_t group_idx; + duk_small_uint_t n_equal; + const duk_uint8_t *src_end; - /* 't' tracks progress of the decoded group: - * - * t == 1 no valid chars yet - * t >= 0x40 1x6 = 6 bits shifted in - * t >= 0x1000 2x6 = 12 bits shifted in - * t >= 0x40000 3x6 = 18 bits shifted in - * t >= 0x1000000 4x6 = 24 bits shifted in - * - * By initializing t=1 there's no need for a separate counter for - * the number of characters found so far. - */ - p = src; - p_end = src + srclen; - q = dst; - t = 1UL; + src_end = src + srclen; + t = 0; + group_idx = 0; + n_equal = 0; - for (;;) { - duk_small_uint_t n_equal; + while (src < src_end) { + x = *src++; - DUK_ASSERT(t >= 1U); - if (p >= p_end) { - /* End of input: if input exists, treat like - * start of padding, finish the block, then - * re-enter here to see we're done. + if (x >= 'A' && x <= 'Z') { + y = x - 'A' + 0; + } else if (x >= 'a' && x <= 'z') { + y = x - 'a' + 26; + } else if (x >= '0' && x <= '9') { + y = x - '0' + 52; + } else if (x == '+') { + y = 62; + } else if (x == '/') { + y = 63; + } else if (x == '=') { + /* We don't check the zero padding bytes here right now + * (that they're actually zero). This seems to be common + * behavior for base-64 decoders. */ - if (t == 1U) { - break; - } else { - goto simulate_padding; - } - } - x = *p++; - - if (x >= 0x41U) { - /* Valid: a-z and A-Z. */ - DUK_ASSERT(x >= 0x41U && x <= 0xffU); - if (x >= 0x61U && x <= 0x7aU) { - y = (duk_int_t) x - 0x61 + 26; - } else if (x <= 0x5aU) { - y = (duk_int_t) x - 0x41; - } else { - goto decode_error; - } - } else if (x >= 0x30U) { - /* Valid: 0-9 and =. */ - DUK_ASSERT(x >= 0x30U && x <= 0x40U); - if (x <= 0x39U) { - y = (duk_int_t) x - 0x30 + 52; - } else if (x == 0x3dU) { - /* Skip padding and whitespace unless we're in the - * middle of a block. Otherwise complete group by - * simulating shifting in the correct padding. - */ - if (t == 1U) { - continue; - } - goto simulate_padding; - } else { - goto decode_error; - } - } else if (x >= 0x20U) { - /* Valid: +, /, and 0x20 whitespace. */ - DUK_ASSERT(x >= 0x20U && x <= 0x2fU); - if (x == 0x2bU) { - y = 62; - } else if (x == 0x2fU) { - y = 63; - } else if (x == 0x20U) { - continue; - } else { - goto decode_error; - } + n_equal++; + t <<= 6; /* shift in zeroes */ + goto skip_add; + } else if (x == 0x09 || x == 0x0a || x == 0x0d || x == 0x20) { + /* allow basic ASCII whitespace */ + continue; } else { - /* Valid: whitespace. */ - duk_uint32_t m; - DUK_ASSERT(x < 0x20U); /* 0x00 to 0x1f */ - m = (1U << x); - if (mask_white & m) { - /* Allow basic ASCII whitespace. */ - continue; - } else { - goto decode_error; - } + goto decode_error; } - DUK_ASSERT(y >= 0 && y <= 63); - t = (t << 6) + (duk_uint_t) y; - if (t < 0x1000000UL) { - continue; + if (n_equal > 0) { + /* Don't allow mixed padding and actual chars. */ + goto decode_error; } - /* fall through; no padding will be added */ + t = (t << 6) + y; + skip_add: - simulate_padding: - n_equal = 0; - while (t < 0x1000000UL) { - t = (t << 6) + 0U; - n_equal++; - } + if (group_idx == 3) { + /* output 3 bytes from 't' */ + *dst++ = (duk_uint8_t) ((t >> 16) & 0xff); + *dst++ = (duk_uint8_t) ((t >> 8) & 0xff); + *dst++ = (duk_uint8_t) (t & 0xff); + + if (DUK_UNLIKELY(n_equal > 0)) { + /* Backtrack. */ + DUK_ASSERT(n_equal <= 4); + if (n_equal == 1) { + dst -= 1; + } else if (n_equal == 2) { + dst -= 2; + } else { + goto decode_error; /* invalid padding */ + } - /* Output 3 bytes from 't' and advance as needed. */ - q[0] = (duk_uint8_t) ((t >> 16) & 0xffU); - q[1] = (duk_uint8_t) ((t >> 8) & 0xffU); - q[2] = (duk_uint8_t) (t & 0xffU); - - DUK_ASSERT(n_equal <= 4U); - step = duk__base64_decode_nequal_step[n_equal]; - if (step < 0) { - goto decode_error; + /* Here we can choose either to end parsing and ignore + * whatever follows, or to continue parsing in case + * multiple (possibly padded) base64 strings have been + * concatenated. Currently, keep on parsing. + */ + n_equal = 0; + } + + t = 0; + group_idx = 0; + } else { + group_idx++; } - q += step; + } - /* Re-enter loop. The actual padding characters are skipped - * by the main loop. This handles cases like missing, partial, - * full, and extra padding, and allows parsing of concatenated - * documents (with extra padding) like: Zm===Zm. Also extra - * prepended padding is accepted: ===Zm9v. + if (group_idx != 0) { + /* Here we'd have the option of decoding unpadded base64 + * (e.g. "xxxxyy" instead of "xxxxyy==". Currently not + * accepted. */ - t = 1U; + goto decode_error; } - DUK_ASSERT(t == 1UL); - *out_dst_final = q; + *out_dst_final = dst; return 1; decode_error: @@ -15259,12 +14986,15 @@ DUK_ASSERT_API_ENTRY(thr); + /* XXX: optimize for string inputs: no need to coerce to a buffer + * which makes a copy of the input. + */ + idx = duk_require_normalize_index(thr, idx); src = duk__prep_codec_arg(thr, idx, &srclen); /* Note: for srclen=0, src may be NULL */ - /* Compute exact output length. Computation must not wrap; this - * limit works for 32-bit size_t: + /* Computation must not wrap; this limit works for 32-bit size_t: * >>> srclen = 3221225469 * >>> '%x' % ((srclen + 2) / 3 * 4) * 'fffffffc' @@ -15272,7 +15002,7 @@ if (srclen > 3221225469UL) { goto type_error; } - dstlen = (srclen + 2U) / 3U * 4U; + dstlen = (srclen + 2) / 3 * 4; dst = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, dstlen); duk__base64_encode_helper((const duk_uint8_t *) src, srclen, dst); @@ -15283,7 +15013,7 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_BASE64_ENCODE_FAILED); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } DUK_EXTERNAL void duk_base64_decode(duk_hthread *thr, duk_idx_t idx) { @@ -15292,24 +15022,31 @@ duk_size_t dstlen; duk_uint8_t *dst; duk_uint8_t *dst_final; + duk_bool_t retval; DUK_ASSERT_API_ENTRY(thr); + /* XXX: optimize for buffer inputs: no need to coerce to a string + * which causes an unnecessary interning. + */ + idx = duk_require_normalize_index(thr, idx); src = duk__prep_codec_arg(thr, idx, &srclen); - /* Round up and add safety margin. Avoid addition before division to - * avoid possibility of wrapping. Margin includes +3 for rounding up, - * and +3 for one extra group: the decoder may emit and then backtrack - * a full group (3 bytes) from zero-sized input for technical reasons. - * Similarly, 'xx' may ecause 1+3 = bytes to be emitted and then - * backtracked. + /* Computation must not wrap, only srclen + 3 is at risk of + * wrapping because after that the number gets smaller. + * This limit works for 32-bit size_t: + * 0x100000000 - 3 - 1 = 4294967292 */ - dstlen = (srclen / 4) * 3 + 6; /* upper limit, assuming no whitespace etc */ + if (srclen > 4294967292UL) { + goto type_error; + } + dstlen = (srclen + 3) / 4 * 3; /* upper limit, assuming no whitespace etc */ dst = (duk_uint8_t *) duk_push_dynamic_buffer(thr, dstlen); /* Note: for dstlen=0, dst may be NULL */ - if (!duk__base64_decode_helper((const duk_uint8_t *) src, srclen, dst, &dst_final)) { + retval = duk__base64_decode_helper((const duk_uint8_t *) src, srclen, dst, &dst_final); + if (!retval) { goto type_error; } @@ -15320,27 +15057,8 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_BASE64_DECODE_FAILED); - DUK_WO_NORETURN(return;); } -#else /* DUK_USE_BASE64_SUPPORT */ -DUK_EXTERNAL const char *duk_base64_encode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); -} - -DUK_EXTERNAL void duk_base64_decode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); -} -#endif /* DUK_USE_BASE64_SUPPORT */ - -/* - * Hex - */ -#if defined(DUK_USE_HEX_SUPPORT) DUK_EXTERNAL const char *duk_hex_encode(duk_hthread *thr, duk_idx_t idx) { const duk_uint8_t *inp; duk_size_t len; @@ -15451,12 +15169,8 @@ } } for (; i < len; i += 2) { - /* First cast to duk_int_t to sign extend, second cast to - * duk_uint_t to avoid signed left shift, and final cast to - * duk_int_t result type. - */ - t = (duk_int_t) ((((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i]]) << 4U) | - ((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i + 1]])); + t = (((duk_int_t) duk_hex_dectab[inp[i]]) << 4) | + ((duk_int_t) duk_hex_dectab[inp[i + 1]]); if (DUK_UNLIKELY(t < 0)) { goto type_error; } @@ -15468,8 +15182,8 @@ * at least 16 bits. If either nybble is invalid, the * resulting 't' will be < 0. */ - t = (duk_int_t) ((((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i]]) << 4U) | - ((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i + 1]])); + t = (((duk_int_t) duk_hex_dectab[inp[i]]) << 4) | + ((duk_int_t) duk_hex_dectab[inp[i + 1]]); if (DUK_UNLIKELY(t < 0)) { goto type_error; } @@ -15482,24 +15196,7 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_HEX_DECODE_FAILED); - DUK_WO_NORETURN(return;); -} -#else /* DUK_USE_HEX_SUPPORT */ -DUK_EXTERNAL const char *duk_hex_encode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } -DUK_EXTERNAL void duk_hex_decode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); -} -#endif /* DUK_USE_HEX_SUPPORT */ - -/* - * JSON - */ #if defined(DUK_USE_JSON_SUPPORT) DUK_EXTERNAL const char *duk_json_encode(duk_hthread *thr, duk_idx_t idx) { @@ -15552,14 +15249,12 @@ DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return NULL;); } DUK_EXTERNAL void duk_json_decode(duk_hthread *thr, duk_idx_t idx) { DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_JSON_SUPPORT */ /* @@ -15653,7 +15348,6 @@ if ((flags & DUK_COMPILE_NOSOURCE) || /* args incorrect */ (h_sourcecode == NULL)) { /* e.g. duk_push_string_file_raw() pushed undefined */ DUK_ERROR_TYPE(thr, DUK_STR_NO_SOURCECODE); - DUK_WO_NORETURN(return 0;); } DUK_ASSERT(h_sourcecode != NULL); comp_args->src_buffer = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_sourcecode); @@ -15778,7 +15472,6 @@ DUK_EXTERNAL void duk_push_context_dump(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_JSON_SUPPORT */ @@ -15890,7 +15583,7 @@ top = duk_get_top(thr); if (top < nvalues) { DUK_ERROR_RANGE(thr, "not enough stack values for notify"); - DUK_WO_NORETURN(return 0;); + return ret; /* unreachable */ } if (duk_debug_is_attached(thr->heap)) { duk_debug_write_notify(thr, DUK_DBG_CMD_APPNOTIFY); @@ -15957,13 +15650,11 @@ DUK_UNREF(detached_cb); DUK_UNREF(udata); DUK_ERROR_TYPE(thr, "no debugger support"); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_debugger_detach(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_TYPE(thr, "no debugger support"); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_debugger_cooperate(duk_hthread *thr) { @@ -15980,7 +15671,7 @@ top = duk_get_top(thr); if (top < nvalues) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } /* No debugger support, just pop values. */ @@ -16102,7 +15793,7 @@ duk_push_tval(thr, &lj->value2); /* XXX: creating_error == 0 is asserted above, so no need to store. */ - duk_memcpy((void *) &snapshot->lj, (const void *) lj, sizeof(duk_ljstate)); + DUK_MEMCPY((void *) &snapshot->lj, (const void *) lj, sizeof(duk_ljstate)); snapshot->creating_error = heap->creating_error; snapshot->curr_thread = heap->curr_thread; snapshot->call_recursion_depth = heap->call_recursion_depth; @@ -16132,7 +15823,7 @@ heap = thr->heap; - duk_memcpy((void *) &heap->lj, (const void *) &snapshot->lj, sizeof(duk_ljstate)); + DUK_MEMCPY((void *) &heap->lj, (const void *) &snapshot->lj, sizeof(duk_ljstate)); heap->creating_error = snapshot->creating_error; heap->curr_thread = snapshot->curr_thread; heap->call_recursion_depth = snapshot->call_recursion_depth; @@ -16268,7 +15959,7 @@ DUK_ASSERT_API_ENTRY(thr); /* Assume two's complement and set everything to -1. */ - duk_memset((void *) &vals, (int) 0xff, sizeof(vals)); + DUK_MEMSET((void *) &vals, (int) 0xff, sizeof(vals)); DUK_ASSERT(vals[DUK__IDX_TYPE] == -1); /* spot check one */ tv = duk_get_tval_or_unused(thr, idx); @@ -16284,12 +15975,12 @@ goto finish; } duk_push_pointer(thr, (void *) h); - duk_put_prop_literal(thr, -2, "hptr"); + duk_put_prop_string(thr, -2, "hptr"); #if 0 /* Covers a lot of information, e.g. buffer and string variants. */ duk_push_uint(thr, (duk_uint_t) DUK_HEAPHDR_GET_FLAGS(h)); - duk_put_prop_literal(thr, -2, "hflags"); + duk_put_prop_string(thr, -2, "hflags"); #endif #if defined(DUK_USE_REFERENCE_COUNTING) @@ -16334,7 +16025,7 @@ } vals[DUK__IDX_CLASS] = (duk_int_t) DUK_HOBJECT_GET_CLASS_NUMBER(h_obj); - vals[DUK__IDX_PBYTES] = (duk_int_t) DUK_HOBJECT_P_ALLOC_SIZE(h_obj); + vals[DUK__IDX_PBYTES] = (duk_int_t) DUK_HOBJECT_P_ALLOC_SIZE(h_obj), vals[DUK__IDX_ESIZE] = (duk_int_t) DUK_HOBJECT_GET_ESIZE(h_obj); vals[DUK__IDX_ENEXT] = (duk_int_t) DUK_HOBJECT_GET_ENEXT(h_obj); vals[DUK__IDX_ASIZE] = (duk_int_t) DUK_HOBJECT_GET_ASIZE(h_obj); @@ -16535,7 +16226,7 @@ * Property handling * * The API exposes only the most common property handling functions. - * The caller can invoke ECMAScript built-ins for full control (e.g. + * The caller can invoke Ecmascript built-ins for full control (e.g. * defineProperty, getOwnPropertyDescriptor). */ @@ -16567,7 +16258,7 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_string(thr, key); + duk_push_string(thr, key); return duk_get_prop(thr, obj_idx); } @@ -16576,21 +16267,9 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_lstring(thr, key, key_len); - return duk_get_prop(thr, obj_idx); -} - -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_get_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); + duk_push_lstring(thr, key, key_len); return duk_get_prop(thr, obj_idx); } -#endif DUK_EXTERNAL duk_bool_t duk_get_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -16604,7 +16283,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk_get_prop(thr, obj_idx); } @@ -16613,7 +16292,7 @@ DUK_ASSERT_STRIDX_VALID(stridx); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_hstring(thr, DUK_HTHREAD_GET_STRING(thr, stridx)); + duk_push_hstring(thr, DUK_HTHREAD_GET_STRING(thr, stridx)); return duk_get_prop(thr, obj_idx); } @@ -16632,7 +16311,10 @@ if (out_has_prop) { *out_has_prop = rc; } - return duk_to_boolean_top_pop(thr); + rc = duk_to_boolean(thr, -1); + DUK_ASSERT(rc == 0 || rc == 1); + duk_pop(thr); + return rc; } DUK_LOCAL duk_bool_t duk__put_prop_shared(duk_hthread *thr, duk_idx_t obj_idx, duk_idx_t idx_key) { @@ -16692,18 +16374,6 @@ return duk__put_prop_shared(thr, obj_idx, -1); } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_put_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); - return duk__put_prop_shared(thr, obj_idx, -1); -} -#endif - DUK_EXTERNAL duk_bool_t duk_put_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -16716,7 +16386,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk__put_prop_shared(thr, obj_idx, -1); } @@ -16763,7 +16433,7 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_string(thr, key); + duk_push_string(thr, key); return duk_del_prop(thr, obj_idx); } @@ -16772,22 +16442,10 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_lstring(thr, key, key_len); + duk_push_lstring(thr, key, key_len); return duk_del_prop(thr, obj_idx); } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_del_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); - return duk_del_prop(thr, obj_idx); -} -#endif - DUK_EXTERNAL duk_bool_t duk_del_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -16800,7 +16458,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk_del_prop(thr, obj_idx); } @@ -16846,7 +16504,7 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_string(thr, key); + duk_push_string(thr, key); return duk_has_prop(thr, obj_idx); } @@ -16855,21 +16513,9 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_lstring(thr, key, key_len); - return duk_has_prop(thr, obj_idx); -} - -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_has_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); + duk_push_lstring(thr, key, key_len); return duk_has_prop(thr, obj_idx); } -#endif DUK_EXTERNAL duk_bool_t duk_has_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -16883,7 +16529,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk_has_prop(thr, obj_idx); } @@ -17083,17 +16729,17 @@ fail_invalid_desc: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_DESCRIPTOR); - DUK_WO_NORETURN(return;); + return; fail_not_callable: DUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE); - DUK_WO_NORETURN(return;); + return; } /* * Object related * - * Note: seal() and freeze() are accessible through ECMAScript bindings, + * Note: seal() and freeze() are accessible through Ecmascript bindings, * and are not exposed through the API. */ @@ -17185,7 +16831,6 @@ fail_cannot_freeze: DUK_ERROR_TYPE_INVALID_ARGS(thr); /* XXX: proper error message */ - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_seal(duk_hthread *thr, duk_idx_t obj_idx) { @@ -17269,38 +16914,6 @@ return ret; } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_get_global_literal_raw(duk_hthread *thr, const char *key, duk_size_t key_len) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - ret = duk_get_prop_literal_raw(thr, -1, key, key_len); - duk_remove_m2(thr); - return ret; -} -#endif - -DUK_EXTERNAL duk_bool_t duk_get_global_heapptr(duk_hthread *thr, void *ptr) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - ret = duk_get_prop_heapptr(thr, -1, ptr); - duk_remove_m2(thr); - return ret; -} - - DUK_EXTERNAL duk_bool_t duk_put_global_string(duk_hthread *thr, const char *key) { duk_bool_t ret; @@ -17331,56 +16944,6 @@ return ret; } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_put_global_literal_raw(duk_hthread *thr, const char *key, duk_size_t key_len) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - duk_insert(thr, -2); - ret = duk_put_prop_literal_raw(thr, -2, key, key_len); /* [ ... global val ] -> [ ... global ] */ - duk_pop(thr); - return ret; -} -#endif - -DUK_EXTERNAL duk_bool_t duk_put_global_heapptr(duk_hthread *thr, void *ptr) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - duk_insert(thr, -2); - ret = duk_put_prop_heapptr(thr, -2, ptr); /* [ ... global val ] -> [ ... global ] */ - duk_pop(thr); - return ret; -} - -/* - * ES2015 GetMethod() - */ - -DUK_INTERNAL duk_bool_t duk_get_method_stridx(duk_hthread *thr, duk_idx_t idx, duk_small_uint_t stridx) { - (void) duk_get_prop_stridx(thr, idx, stridx); - if (duk_is_null_or_undefined(thr, -1)) { - duk_pop_nodecref_unsafe(thr); - return 0; - } - if (!duk_is_callable(thr, -1)) { - DUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE); - DUK_WO_NORETURN(return 0;); - } - return 1; -} - /* * Object prototype */ @@ -17419,7 +16982,7 @@ #if defined(DUK_USE_ROM_OBJECTS) if (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); /* XXX: "read only object"? */ - DUK_WO_NORETURN(return;); + return; } #endif @@ -17476,26 +17039,15 @@ DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_set_finalizer(duk_hthread *thr, duk_idx_t idx) { DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_FINALIZER_SUPPORT */ /* - * Random numbers - */ - -/* #include duk_internal.h -> already included */ - -DUK_EXTERNAL duk_double_t duk_random(duk_hthread *thr) { - return (duk_double_t) DUK_UTIL_GET_RANDOM_DOUBLE(thr); -} -/* * API calls related to general value stack manipulation: resizing the value * stack, pushing and popping values, type checking and reading values, * coercing values, etc. @@ -17669,7 +17221,7 @@ if (require) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "number", DUK_STR_NOT_NUMBER); - DUK_WO_NORETURN(return 0;); + /* not reachable */ } return def_value; @@ -17720,7 +17272,7 @@ if (require) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "number", DUK_STR_NOT_NUMBER); - DUK_WO_NORETURN(return 0;); + /* not reachable */ } return def_value; @@ -17795,7 +17347,7 @@ return (duk_idx_t) uidx; } DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } DUK_INTERNAL duk_tval *duk_get_tval(duk_hthread *thr, duk_idx_t idx) { @@ -17871,7 +17423,7 @@ return thr->valstack_bottom + uidx; } DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return NULL;); + return NULL; } /* Non-critical. */ @@ -17889,7 +17441,7 @@ if (DUK_UNLIKELY(duk_normalize_index(thr, idx) < 0)) { DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return;); + return; /* unreachable */ } } @@ -17914,7 +17466,6 @@ ret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom); if (DUK_UNLIKELY(ret < min_top)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); } return ret; } @@ -17959,7 +17510,7 @@ #else if (DUK_UNLIKELY(uidx > vs_limit)) { DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return;); + return; /* unreachable */ } #endif DUK_ASSERT(uidx <= vs_limit); @@ -18142,7 +17693,7 @@ ret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom) - 1; if (DUK_UNLIKELY(ret < 0)) { DUK_ERROR_RANGE_INDEX(thr, -1); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } return ret; } @@ -18343,7 +17894,6 @@ */ if (throw_on_error) { DUK_ERROR_RANGE(thr, DUK_STR_VALSTACK_LIMIT); - DUK_WO_NORETURN(return 0;); } return 0; } @@ -18351,7 +17901,6 @@ if (duk__resize_valstack(thr, new_size) == 0) { if (throw_on_error) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return 0;); } return 0; } @@ -18612,7 +18161,7 @@ if (DUK_UNLIKELY(thr->valstack_top - thr->valstack_bottom <= 0)) { DUK_ERROR_RANGE_INDEX(thr, -1); - DUK_WO_NORETURN(return;); + return; /* unreachable */ } tv_from = thr->valstack_top - 1; tv_to = thr->valstack_top++; @@ -18674,12 +18223,18 @@ DUK_DDD(DUK_DDDPRINT("duk_insert: to_idx=%ld, p=%p, q=%p, nbytes=%lu", (long) to_idx, (void *) p, (void *) q, (unsigned long) nbytes)); - /* No net refcount changes. No need to special case nbytes == 0 - * (p == q). - */ - DUK_TVAL_SET_TVAL(&tv_tmp, q); - duk_memmove((void *) (p + 1), (const void *) p, (size_t) nbytes); - DUK_TVAL_SET_TVAL(p, &tv_tmp); + /* No net refcount changes. */ + + if (nbytes > 0) { + DUK_TVAL_SET_TVAL(&tv_tmp, q); + DUK_ASSERT(nbytes > 0); + DUK_MEMMOVE((void *) (p + 1), (const void *) p, (size_t) nbytes); + DUK_TVAL_SET_TVAL(p, &tv_tmp); + } else { + /* nop: insert top to top */ + DUK_ASSERT(nbytes == 0); + DUK_ASSERT(p == q); + } } DUK_INTERNAL void duk_insert_undefined(duk_hthread *thr, duk_idx_t idx) { @@ -18771,7 +18326,7 @@ #endif nbytes = (duk_size_t) (((duk_uint8_t *) q) - ((duk_uint8_t *) p)); /* Note: 'q' is top-1 */ - duk_memmove((void *) p, (const void *) (p + 1), (size_t) nbytes); + DUK_MEMMOVE((void *) p, (const void *) (p + 1), (size_t) nbytes); /* zero size not an issue: pointers are valid */ DUK_TVAL_SET_UNDEFINED(q); thr->valstack_top--; @@ -18824,7 +18379,7 @@ DUK_TVAL_DECREF_NORZ(thr, tv); } - duk_memmove((void *) tv_dst, (const void *) tv_src, bytes); + DUK_MEMMOVE((void *) tv_dst, (const void *) tv_src, bytes); tv_newtop = thr->valstack_top - count; for (tv = tv_newtop; tv < thr->valstack_top; tv++) { @@ -18863,14 +18418,14 @@ if (DUK_UNLIKELY(to_thr == from_thr)) { DUK_ERROR_TYPE(to_thr, DUK_STR_INVALID_CONTEXT); - DUK_WO_NORETURN(return;); + return; } if (DUK_UNLIKELY((duk_uidx_t) count > (duk_uidx_t) DUK_USE_VALSTACK_LIMIT)) { /* Maximum value check ensures 'nbytes' won't wrap below. * Also handles negative count. */ DUK_ERROR_RANGE_INVALID_COUNT(to_thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count >= 0); @@ -18881,19 +18436,17 @@ DUK_ASSERT(to_thr->valstack_top <= to_thr->valstack_end); if (DUK_UNLIKELY((duk_size_t) ((duk_uint8_t *) to_thr->valstack_end - (duk_uint8_t *) to_thr->valstack_top) < nbytes)) { DUK_ERROR_RANGE_PUSH_BEYOND(to_thr); - DUK_WO_NORETURN(return;); } src = (void *) ((duk_uint8_t *) from_thr->valstack_top - nbytes); if (DUK_UNLIKELY(src < (void *) from_thr->valstack_bottom)) { DUK_ERROR_RANGE_INVALID_COUNT(to_thr); - DUK_WO_NORETURN(return;); } - /* Copy values (no overlap even if to_thr == from_thr; that's not - * allowed now anyway). + /* copy values (no overlap even if to_thr == from_thr; that's not + * allowed now anyway) */ DUK_ASSERT(nbytes > 0); - duk_memcpy((void *) to_thr->valstack_top, (const void *) src, (size_t) nbytes); + DUK_MEMCPY((void *) to_thr->valstack_top, (const void *) src, (size_t) nbytes); p = to_thr->valstack_top; to_thr->valstack_top = (duk_tval *) (void *) (((duk_uint8_t *) p) + nbytes); @@ -18942,7 +18495,7 @@ tv_dst = (duk_tval *) (void *) ((duk_uint8_t *) tv_src + gap_bytes); copy_bytes = (duk_size_t) ((duk_uint8_t *) thr->valstack_top - (duk_uint8_t *) tv_src); thr->valstack_top = (duk_tval *) (void *) ((duk_uint8_t *) thr->valstack_top + gap_bytes); - duk_memmove((void *) tv_dst, (const void *) tv_src, copy_bytes); + DUK_MEMMOVE((void *) tv_dst, (const void *) tv_src, copy_bytes); /* Values in the gap are left as garbage: caller must fill them in * and INCREF them before any side effects. @@ -18963,7 +18516,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_UNDEFINED(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "undefined", DUK_STR_NOT_UNDEFINED); - DUK_WO_NORETURN(return;); } } @@ -18976,7 +18528,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_NULL(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "null", DUK_STR_NOT_NULL); - DUK_WO_NORETURN(return;); } } @@ -19025,7 +18576,6 @@ return ret; } else { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "boolean", DUK_STR_NOT_BOOLEAN); - DUK_WO_NORETURN(return 0;); } } @@ -19087,7 +18637,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_NUMBER(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "number", DUK_STR_NOT_NUMBER); - DUK_WO_NORETURN(return 0.0;); } ret.d = DUK_TVAL_GET_NUMBER(tv); @@ -19319,7 +18868,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_OBJECT(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "object", DUK_STR_NOT_OBJECT); - DUK_WO_NORETURN(return;); } } @@ -19371,7 +18919,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_POINTER(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "pointer", DUK_STR_NOT_POINTER); - DUK_WO_NORETURN(return NULL;); } p = DUK_TVAL_GET_POINTER(tv); /* may be NULL */ return p; @@ -19419,7 +18966,6 @@ } else { if (throw_flag) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "buffer", DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } len = def_size; ret = def_ptr; @@ -19523,7 +19069,6 @@ if (throw_flag) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "buffer", DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } return def_ptr; } @@ -19603,7 +19148,6 @@ h = (duk_hstring *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_STRING); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "string", DUK_STR_NOT_STRING); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -19616,7 +19160,6 @@ h = (duk_hstring *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_STRING); if (DUK_UNLIKELY(h == NULL || DUK_HSTRING_HAS_SYMBOL(h))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "string", DUK_STR_NOT_STRING); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -19634,7 +19177,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "object", DUK_STR_NOT_OBJECT); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -19652,7 +19194,6 @@ h = (duk_hbuffer *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_BUFFER); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "buffer", DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -19677,7 +19218,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_THREAD(h)))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "thread", DUK_STR_NOT_THREAD); - DUK_WO_NORETURN(return NULL;); } return (duk_hthread *) h; } @@ -19702,7 +19242,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_COMPFUNC(h)))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "compiledfunction", DUK_STR_NOT_COMPFUNC); - DUK_WO_NORETURN(return NULL;); } return (duk_hcompfunc *) h; } @@ -19727,7 +19266,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_NATFUNC(h)))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "nativefunction", DUK_STR_NOT_NATFUNC); - DUK_WO_NORETURN(return NULL;); } return (duk_hnatfunc *) h; } @@ -19786,7 +19324,6 @@ ret = duk_get_c_function(thr, idx); if (DUK_UNLIKELY(!ret)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "nativefunction", DUK_STR_NOT_NATFUNC); - DUK_WO_NORETURN(return ret;); } return ret; } @@ -19795,7 +19332,6 @@ DUK_ASSERT_API_ENTRY(thr); if (DUK_UNLIKELY(!duk_is_function(thr, idx))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "function", DUK_STR_NOT_FUNCTION); - DUK_WO_NORETURN(return;); } } @@ -19807,7 +19343,6 @@ h = duk_require_hobject_accept_mask(thr, idx, DUK_TYPE_MASK_LIGHTFUNC); if (DUK_UNLIKELY(h != NULL && !DUK_HOBJECT_HAS_CONSTRUCTABLE(h))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "constructable", DUK_STR_NOT_CONSTRUCTABLE); - DUK_WO_NORETURN(return;); } /* Lightfuncs (h == NULL) are constructable. */ } @@ -19895,7 +19430,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_HEAP_ALLOCATED(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "heapobject", DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return NULL;); } ret = (void *) DUK_TVAL_GET_HEAPHDR(tv); @@ -19929,7 +19463,6 @@ if (type_mask & DUK_TYPE_MASK_THROW) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "object", DUK_STR_NOT_OBJECT); - DUK_WO_NORETURN(return NULL;); } return NULL; } @@ -19990,7 +19523,6 @@ DUK_UNREF(h_class); DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, (const char *) DUK_HSTRING_GET_DATA(h_class), DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -20183,43 +19715,49 @@ } /* E5 Section 9.1 */ -DUK_LOCAL const char * const duk__toprim_hint_strings[3] = { - "default", "string", "number" -}; -DUK_LOCAL void duk__to_primitive_helper(duk_hthread *thr, duk_idx_t idx, duk_int_t hint, duk_bool_t check_symbol) { - /* Inline initializer for coercers[] is not allowed by old compilers like BCC. */ +DUK_EXTERNAL void duk_to_primitive(duk_hthread *thr, duk_idx_t idx, duk_int_t hint) { + /* inline initializer for coercers[] is not allowed by old compilers like BCC */ duk_small_uint_t coercers[2]; + duk_small_uint_t class_number; DUK_ASSERT_API_ENTRY(thr); DUK_ASSERT(hint == DUK_HINT_NONE || hint == DUK_HINT_NUMBER || hint == DUK_HINT_STRING); idx = duk_require_normalize_index(thr, idx); - /* If already primitive, return as is. */ if (!duk_check_type_mask(thr, idx, DUK_TYPE_MASK_OBJECT | DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER)) { + /* Any other values stay as is. */ DUK_ASSERT(!duk_is_buffer(thr, idx)); /* duk_to_string() relies on this behavior */ return; } - /* @@toPrimitive lookup. Also do for plain buffers and lightfuncs - * which mimic objects. + class_number = duk_get_class_number(thr, idx); + + /* XXX: Symbol objects normally coerce via the ES2015-revised ToPrimitive() + * algorithm which consults value[@@toPrimitive] and avoids calling + * .valueOf() and .toString(). Before that is implemented, special + * case Symbol objects to behave as if they had the default @@toPrimitive + * algorithm of E6 Section 19.4.3.4, i.e. return the plain symbol value + * with no further side effects. */ - if (check_symbol && duk_get_method_stridx(thr, idx, DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE)) { - DUK_ASSERT(hint >= 0 && (duk_size_t) hint < sizeof(duk__toprim_hint_strings) / sizeof(const char *)); - duk_dup(thr, idx); - duk_push_string(thr, duk__toprim_hint_strings[hint]); - duk_call_method(thr, 1); /* [ ... method value hint ] -> [ ... res] */ - if (duk_check_type_mask(thr, -1, DUK_TYPE_MASK_OBJECT | - DUK_TYPE_MASK_LIGHTFUNC | - DUK_TYPE_MASK_BUFFER)) { - goto fail; + + if (class_number == DUK_HOBJECT_CLASS_SYMBOL) { + duk_hobject *h_obj; + duk_hstring *h_str; + + /* XXX: pretty awkward, index based API for internal value access? */ + h_obj = duk_known_hobject(thr, idx); + h_str = duk_hobject_get_internal_value_string(thr->heap, h_obj); + if (h_str) { + duk_push_hstring(thr, h_str); + duk_replace(thr, idx); + return; } - duk_replace(thr, idx); - return; } + /* Objects are coerced based on E5 specification. * Lightfuncs are coerced because they behave like * objects even if they're internally a primitive @@ -20227,29 +19765,17 @@ * like ArrayBuffer objects since Duktape 2.x. */ - /* Hint magic for Date is unnecessary in ES2015 because of - * Date.prototype[@@toPrimitive]. However, it is needed if - * symbol support is not enabled. - */ -#if defined(DUK_USE_SYMBOL_BUILTIN) - if (hint == DUK_HINT_NONE) { - hint = DUK_HINT_NUMBER; - } -#else /* DUK_USE_SYMBOL_BUILTIN */ - if (hint == DUK_HINT_NONE) { - duk_small_uint_t class_number; + coercers[0] = DUK_STRIDX_VALUE_OF; + coercers[1] = DUK_STRIDX_TO_STRING; - class_number = duk_get_class_number(thr, idx); + if (hint == DUK_HINT_NONE) { if (class_number == DUK_HOBJECT_CLASS_DATE) { hint = DUK_HINT_STRING; } else { hint = DUK_HINT_NUMBER; } } -#endif /* DUK_USE_SYMBOL_BUILTIN */ - coercers[0] = DUK_STRIDX_VALUE_OF; - coercers[1] = DUK_STRIDX_TO_STRING; if (hint == DUK_HINT_STRING) { coercers[0] = DUK_STRIDX_TO_STRING; coercers[1] = DUK_STRIDX_VALUE_OF; @@ -20265,20 +19791,8 @@ return; } - fail: DUK_ERROR_TYPE(thr, DUK_STR_TOPRIMITIVE_FAILED); - DUK_WO_NORETURN(return;); -} - -DUK_EXTERNAL void duk_to_primitive(duk_hthread *thr, duk_idx_t idx, duk_int_t hint) { - duk__to_primitive_helper(thr, idx, hint, 1 /*check_symbol*/); -} - -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL void duk_to_primitive_ordinary(duk_hthread *thr, duk_idx_t idx, duk_int_t hint) { - duk__to_primitive_helper(thr, idx, hint, 0 /*check_symbol*/); } -#endif /* E5 Section 9.2 */ DUK_EXTERNAL duk_bool_t duk_to_boolean(duk_hthread *thr, duk_idx_t idx) { @@ -20300,22 +19814,6 @@ return val; } -DUK_INTERNAL duk_bool_t duk_to_boolean_top_pop(duk_hthread *thr) { - duk_tval *tv; - duk_bool_t val; - - DUK_ASSERT_API_ENTRY(thr); - - tv = duk_require_tval(thr, -1); - DUK_ASSERT(tv != NULL); - - val = duk_js_toboolean(tv); - DUK_ASSERT(val == 0 || val == 1); - - duk_pop_unsafe(thr); - return val; -} - DUK_EXTERNAL duk_double_t duk_to_number(duk_hthread *thr, duk_idx_t idx) { duk_tval *tv; duk_double_t d; @@ -20595,67 +20093,68 @@ #endif /* Push Object.prototype.toString() output for 'tv'. */ -#if 0 /* See XXX note why this variant doesn't work. */ -DUK_INTERNAL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv, duk_bool_t avoid_side_effects) { - duk_uint_t stridx_bidx = 0; /* (prototype_bidx << 16) + default_tag_stridx */ +DUK_INTERNAL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv) { + duk_small_uint_t stridx; + duk_hstring *h_strclass; DUK_ASSERT_API_ENTRY(thr); - /* Conceptually for any non-undefined/null value we should do a - * ToObject() coercion and look up @@toStringTag (from the object - * prototype) to see if a custom tag should be used. Avoid the - * actual conversion by doing a prototype lookup without the object - * coercion. However, see problem below. - */ - - duk_push_literal(thr, "[object "); /* -> [ ... "[object" ] */ - switch (DUK_TVAL_GET_TAG(tv)) { case DUK_TAG_UNUSED: /* Treat like 'undefined', shouldn't happen. */ case DUK_TAG_UNDEFINED: { - stridx_bidx = DUK_STRIDX_UC_UNDEFINED; - goto use_stridx; + stridx = DUK_STRIDX_UC_UNDEFINED; + break; } case DUK_TAG_NULL: { - stridx_bidx = DUK_STRIDX_UC_NULL; - goto use_stridx; + stridx = DUK_STRIDX_UC_NULL; + break; } case DUK_TAG_BOOLEAN: { - stridx_bidx = (DUK_BIDX_BOOLEAN_PROTOTYPE << 16) + DUK_STRIDX_UC_BOOLEAN; - goto use_proto_bidx; + stridx = DUK_STRIDX_UC_BOOLEAN; + break; } case DUK_TAG_POINTER: { - stridx_bidx = (DUK_BIDX_POINTER_PROTOTYPE << 16) + DUK_STRIDX_UC_POINTER; - goto use_proto_bidx; + stridx = DUK_STRIDX_UC_POINTER; + break; } case DUK_TAG_LIGHTFUNC: { - stridx_bidx = (DUK_BIDX_FUNCTION_PROTOTYPE << 16) + DUK_STRIDX_UC_FUNCTION; - goto use_proto_bidx; + stridx = DUK_STRIDX_UC_FUNCTION; + break; } case DUK_TAG_STRING: { duk_hstring *h; h = DUK_TVAL_GET_STRING(tv); DUK_ASSERT(h != NULL); if (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) { - /* Even without DUK_USE_SYMBOL_BUILTIN the Symbol - * prototype exists so we can lookup @@toStringTag - * and provide [object Symbol] for symbol values - * created from C code. - */ - stridx_bidx = (DUK_BIDX_SYMBOL_PROTOTYPE << 16) + DUK_STRIDX_UC_SYMBOL; + stridx = DUK_STRIDX_UC_SYMBOL; } else { - stridx_bidx = (DUK_BIDX_STRING_PROTOTYPE << 16) + DUK_STRIDX_UC_STRING; + stridx = DUK_STRIDX_UC_STRING; } - goto use_proto_bidx; + break; } case DUK_TAG_OBJECT: { - duk_push_tval(thr, tv); - stridx_bidx = 0xffffffffUL; /* Marker value. */ - goto use_pushed_object; + duk_hobject *h; + duk_small_uint_t classnum; + + h = DUK_TVAL_GET_OBJECT(tv); + DUK_ASSERT(h != NULL); + classnum = DUK_HOBJECT_GET_CLASS_NUMBER(h); + stridx = DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(classnum); + + /* XXX: This is not entirely correct anymore; in ES2015 the + * default lookup should use @@toStringTag to come up with + * e.g. [object Symbol], [object Uint8Array], etc. See + * ES2015 Section 19.1.3.6. The downside of implementing that + * directly is that the @@toStringTag lookup may have side + * effects, so all call sites must be checked for that. + * Some may need a side-effect free lookup, e.g. avoiding + * getters which are not typical. + */ + break; } case DUK_TAG_BUFFER: { - stridx_bidx = (DUK_BIDX_UINT8ARRAY_PROTOTYPE << 16) + DUK_STRIDX_UINT8_ARRAY; - goto use_proto_bidx; + stridx = DUK_STRIDX_UINT8_ARRAY; + break; } #if defined(DUK_USE_FASTINT) case DUK_TAG_FASTINT: @@ -20663,142 +20162,14 @@ #endif default: { DUK_ASSERT(DUK_TVAL_IS_NUMBER(tv)); /* number (maybe fastint) */ - stridx_bidx = (DUK_BIDX_NUMBER_PROTOTYPE << 16) + DUK_STRIDX_UC_NUMBER; - goto use_proto_bidx; - } - } - DUK_ASSERT(0); /* Never here. */ - - use_proto_bidx: - DUK_ASSERT_BIDX_VALID((stridx_bidx >> 16) & 0xffffUL); - duk_push_hobject(thr, thr->builtins[(stridx_bidx >> 16) & 0xffffUL]); - /* Fall through. */ - - use_pushed_object: - /* [ ... "[object" obj ] */ - -#if defined(DUK_USE_SYMBOL_BUILTIN) - /* XXX: better handling with avoid_side_effects == 1; lookup tval - * without Proxy or getter side effects, and use it in sanitized - * form if it's a string. - */ - if (!avoid_side_effects) { - /* XXX: The problem with using the prototype object as the - * lookup base is that if @@toStringTag is a getter, its - * 'this' binding must be the ToObject() coerced input value, - * not the prototype object of the type. - */ - (void) duk_get_prop_stridx(thr, -1, DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG); - if (duk_is_string_notsymbol(thr, -1)) { - duk_remove_m2(thr); - goto finish; - } - duk_pop_unsafe(thr); - } -#endif - - if (stridx_bidx == 0xffffffffUL) { - duk_hobject *h_obj; - duk_small_uint_t classnum; - - h_obj = duk_known_hobject(thr, -1); - DUK_ASSERT(h_obj != NULL); - classnum = DUK_HOBJECT_GET_CLASS_NUMBER(h_obj); - stridx_bidx = DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(classnum); - } else { - /* stridx_bidx already has the desired fallback stridx. */ - ; - } - duk_pop_unsafe(thr); - /* Fall through. */ - - use_stridx: - /* [ ... "[object" ] */ - duk_push_hstring_stridx(thr, stridx_bidx & 0xffffUL); - - finish: - /* [ ... "[object" tag ] */ - duk_push_literal(thr, "]"); - duk_concat(thr, 3); /* [ ... "[object" tag "]" ] -> [ ... res ] */ -} -#endif /* 0 */ - -DUK_INTERNAL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv, duk_bool_t avoid_side_effects) { - duk_hobject *h_obj; - duk_small_uint_t classnum; - duk_small_uint_t stridx; - duk_tval tv_tmp; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(tv != NULL); - - /* Stabilize 'tv', duk_push_literal() may trigger side effects. */ - DUK_TVAL_SET_TVAL(&tv_tmp, tv); - tv = &tv_tmp; - - /* Conceptually for any non-undefined/null value we should do a - * ToObject() coercion and look up @@toStringTag (from the object - * prototype) to see if a custom result should be used. We'd like to - * avoid the actual conversion, but even for primitive types the - * prototype may have @@toStringTag. What's worse, the @@toStringTag - * property may be a getter that must get the object coerced value - * (not the prototype) as its 'this' binding. - * - * For now, do an actual object coercion. This could be avoided by - * doing a side effect free lookup to see if a getter would be invoked. - * If not, the value can be read directly and the object coercion could - * be avoided. This may not be worth it in practice, because - * Object.prototype.toString() is usually not performance critical. - */ - - duk_push_literal(thr, "[object "); /* -> [ ... "[object" ] */ - - switch (DUK_TVAL_GET_TAG(tv)) { - case DUK_TAG_UNUSED: /* Treat like 'undefined', shouldn't happen. */ - case DUK_TAG_UNDEFINED: { - duk_push_hstring_stridx(thr, DUK_STRIDX_UC_UNDEFINED); - goto finish; - } - case DUK_TAG_NULL: { - duk_push_hstring_stridx(thr, DUK_STRIDX_UC_NULL); - goto finish; + stridx = DUK_STRIDX_UC_NUMBER; + break; } } + h_strclass = DUK_HTHREAD_GET_STRING(thr, stridx); + DUK_ASSERT(h_strclass != NULL); - duk_push_tval(thr, tv); - tv = NULL; /* Invalidated by ToObject(). */ - duk_to_object(thr, -1); - - /* [ ... "[object" obj ] */ - -#if defined(DUK_USE_SYMBOL_BUILTIN) - /* XXX: better handling with avoid_side_effects == 1; lookup tval - * without Proxy or getter side effects, and use it in sanitized - * form if it's a string. - */ - if (!avoid_side_effects) { - (void) duk_get_prop_stridx(thr, -1, DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG); - if (duk_is_string_notsymbol(thr, -1)) { - duk_remove_m2(thr); - goto finish; - } - duk_pop_unsafe(thr); - } -#else - DUK_UNREF(avoid_side_effects); -#endif - - h_obj = duk_known_hobject(thr, -1); - DUK_ASSERT(h_obj != NULL); - classnum = DUK_HOBJECT_GET_CLASS_NUMBER(h_obj); - stridx = DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(classnum); - duk_pop_unsafe(thr); - duk_push_hstring_stridx(thr, stridx); - - finish: - /* [ ... "[object" tag ] */ - duk_push_literal(thr, "]"); - duk_concat(thr, 3); /* [ ... "[object" tag "]" ] -> [ ... res ] */ + duk_push_sprintf(thr, "[object %s]", (const char *) DUK_HSTRING_GET_DATA(h_strclass)); } /* XXX: other variants like uint, u32 etc */ @@ -20858,7 +20229,6 @@ /* coerced value is updated to value stack even when RangeError thrown */ if (clamped) { DUK_ERROR_RANGE(thr, DUK_STR_NUMBER_OUTSIDE_RANGE); - DUK_WO_NORETURN(return 0;); } } @@ -20916,14 +20286,12 @@ DUK_ASSERT(h != NULL); if (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_CANNOT_STRING_COERCE_SYMBOL); - DUK_WO_NORETURN(goto skip_replace;); } else { goto skip_replace; } #else goto skip_replace; #endif - break; } case DUK_TAG_BUFFER: /* Go through Uint8Array.prototype.toString() for coercion. */ case DUK_TAG_OBJECT: { @@ -21074,9 +20442,14 @@ } dst_data = (duk_uint8_t *) duk_push_buffer(thr, src_size, (mode == DUK_BUF_MODE_DYNAMIC) /*dynamic*/); - /* dst_data may be NULL if size is zero. */ - duk_memcpy_unsafe((void *) dst_data, (const void *) src_data, (size_t) src_size); - + if (DUK_LIKELY(src_size > 0)) { + /* When src_size == 0, src_data may be NULL (if source + * buffer is dynamic), and dst_data may be NULL (if + * target buffer is dynamic). Avoid zero-size memcpy() + * with an invalid pointer. + */ + DUK_MEMCPY((void *) dst_data, (const void *) src_data, (size_t) src_size); + } duk_replace(thr, idx); skip_copy: @@ -21192,7 +20565,6 @@ case DUK_TAG_UNDEFINED: case DUK_TAG_NULL: { DUK_ERROR_TYPE(thr, DUK_STR_NOT_OBJECT_COERCIBLE); - DUK_WO_NORETURN(return;); break; } case DUK_TAG_BOOLEAN: { @@ -21500,7 +20872,7 @@ } if (mask & DUK_TYPE_MASK_THROW) { DUK_ERROR_TYPE(thr, DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); } return 0; } @@ -21973,22 +21345,21 @@ DUK_ASSERT_API_ENTRY(thr); - /* Check stack before interning (avoid hanging temp). */ + /* check stack before interning (avoid hanging temp) */ DUK__CHECK_SPACE(); /* NULL with zero length represents an empty string; NULL with higher - * length is also now treated like an empty string although it is + * length is also now trated like an empty string although it is * a bit dubious. This is unlike duk_push_string() which pushes a * 'null' if the input string is a NULL. */ - if (DUK_UNLIKELY(str == NULL)) { - len = 0U; + if (!str) { + len = 0; } - /* Check for maximum string length. */ + /* Check for maximum string length */ if (DUK_UNLIKELY(len > DUK_HSTRING_MAX_BYTELEN)) { DUK_ERROR_RANGE(thr, DUK_STR_STRING_TOO_LONG); - DUK_WO_NORETURN(return NULL;); } h = duk_heap_strtable_intern_checked(thr, (const duk_uint8_t *) str, (duk_uint32_t) len); @@ -22012,42 +21383,6 @@ } } -#if !defined(DUK_USE_PREFER_SIZE) -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_EXTERNAL const char *duk_push_literal_raw(duk_hthread *thr, const char *str, duk_size_t len) { - duk_hstring *h; - duk_tval *tv_slot; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(str != NULL); - DUK_ASSERT(str[len] == (char) 0); - - /* Check for maximum string length. */ - if (DUK_UNLIKELY(len > DUK_HSTRING_MAX_BYTELEN)) { - DUK_ERROR_RANGE(thr, DUK_STR_STRING_TOO_LONG); - DUK_WO_NORETURN(return NULL;); - } - - h = duk_heap_strtable_intern_literal_checked(thr, (const duk_uint8_t *) str, (duk_uint32_t) len); - DUK_ASSERT(h != NULL); - - tv_slot = thr->valstack_top++; - DUK_TVAL_SET_STRING(tv_slot, h); - DUK_HSTRING_INCREF(thr, h); /* no side effects */ - - return (const char *) DUK_HSTRING_GET_DATA(h); -} -#else /* DUK_USE_LITCACHE_SIZE */ -DUK_EXTERNAL const char *duk_push_literal_raw(duk_hthread *thr, const char *str, duk_size_t len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(str != NULL); - DUK_ASSERT(str[len] == (char) 0); - - return duk_push_lstring(thr, str, len); -} -#endif /* DUK_USE_LITCACHE_SIZE */ -#endif /* !DUK_USE_PREFER_SIZE */ - DUK_EXTERNAL void duk_push_pointer(duk_hthread *thr, void *val) { duk_tval *tv_slot; @@ -22101,7 +21436,6 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_NOT_OBJECT_COERCIBLE); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_push_this(duk_hthread *thr) { @@ -22145,46 +21479,6 @@ return thr->valstack_bottom - 1; } -DUK_EXTERNAL void duk_push_new_target(duk_hthread *thr) { - duk_activation *act; - - DUK_ASSERT_API_ENTRY(thr); - - /* https://www.ecma-international.org/ecma-262/6.0/#sec-meta-properties-runtime-semantics-evaluation - * https://www.ecma-international.org/ecma-262/6.0/#sec-getnewtarget - * - * No newTarget support now, so as a first approximation - * use the resolved (non-bound) target function. - * - * Check CONSTRUCT flag from current function, or if running - * direct eval, from a non-direct-eval parent (with possibly - * more than one nested direct eval). An alternative to this - * would be to store [[NewTarget]] as a hidden symbol of the - * lexical scope, and then just look up that variable. - * - * Calls from the application will either be for an empty - * call stack, or a Duktape/C function as the top activation. - */ - - act = thr->callstack_curr; - for (;;) { - if (act == NULL) { - break; - } - - if (act->flags & DUK_ACT_FLAG_CONSTRUCT) { - duk_push_tval(thr, &act->tv_func); - return; - } else if (act->flags & DUK_ACT_FLAG_DIRECT_EVAL) { - act = act->parent; - } else { - break; - } - } - - duk_push_undefined(thr); -} - DUK_EXTERNAL void duk_push_current_function(duk_hthread *thr) { duk_activation *act; @@ -22245,7 +21539,7 @@ DUK_ASSERT_API_ENTRY(thr); if (DUK_UNLIKELY(target_thr == NULL)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return;); + return; /* not reached */ } duk_push_hobject(thr, (duk_hobject *) target_thr); duk__push_stash(thr); @@ -22321,7 +21615,6 @@ sz = sz * 2; if (DUK_UNLIKELY(sz >= DUK_PUSH_SPRINTF_SANITY_LIMIT)) { DUK_ERROR_RANGE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return NULL;); } } @@ -22510,7 +21803,6 @@ /* important to do this *after* pushing, to make the thread reachable for gc */ if (DUK_UNLIKELY(!duk_hthread_init_stacks(thr->heap, obj))) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return 0;); } /* initialize built-ins - either by copying or creating new ones */ @@ -22552,7 +21844,6 @@ DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_FUNCTION)); if (DUK_UNLIKELY(obj == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } DUK_DDD(DUK_DDDPRINT("created compiled function object with flags: 0x%08lx", (unsigned long) obj->obj.hdr.h_flags)); @@ -22584,7 +21875,6 @@ DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_FUNCTION)); if (!obj) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } tv_slot = thr->valstack_top++; @@ -22641,7 +21931,7 @@ api_error: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + return 0; /* not reached */ } DUK_EXTERNAL duk_idx_t duk_push_c_function(duk_hthread *thr, duk_c_function func, duk_int_t nargs) { @@ -22733,7 +22023,7 @@ api_error: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + return 0; /* not reached */ } #if defined(DUK_USE_BUFFEROBJECT_SUPPORT) @@ -22885,11 +22175,11 @@ range_error: DUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARGS); - DUK_WO_NORETURN(return;); + return; /* not reached */ arg_error: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_ARGS); - DUK_WO_NORETURN(return;); + return; /* not reached */ } #else /* DUK_USE_BUFFEROBJECT_SUPPORT */ DUK_EXTERNAL void duk_push_buffer_object(duk_hthread *thr, duk_idx_t idx_buffer, duk_size_t byte_offset, duk_size_t byte_length, duk_uint_t flags) { @@ -22899,7 +22189,6 @@ DUK_UNREF(byte_length); DUK_UNREF(flags); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ @@ -22937,7 +22226,7 @@ duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_MESSAGE, DUK_PROPDESC_FLAGS_WC); } else { /* If no explicit message given, put error code into message field - * (as a number). This is not fully in keeping with the ECMAScript + * (as a number). This is not fully in keeping with the Ecmascript * error model because messages are supposed to be strings (Error * constructors use ToString() on their argument). However, it's * probably more useful than having a separate 'code' property. @@ -22999,13 +22288,11 @@ /* Check for maximum buffer length. */ if (DUK_UNLIKELY(size > DUK_HBUFFER_MAX_BYTELEN)) { DUK_ERROR_RANGE(thr, DUK_STR_BUFFER_TOO_LONG); - DUK_WO_NORETURN(return NULL;); } h = duk_hbuffer_alloc(thr->heap, size, flags, &buf_data); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } tv_slot = thr->valstack_top; @@ -23027,12 +22314,11 @@ DUK_ASSERT_API_ENTRY(thr); ptr = duk_push_buffer_raw(thr, len, 0); - DUK_ASSERT(ptr != NULL); #if !defined(DUK_USE_ZERO_BUFFER_DATA) /* ES2015 requires zeroing even when DUK_USE_ZERO_BUFFER_DATA * is not set. */ - duk_memzero((void *) ptr, (size_t) len); + DUK_MEMZERO((void *) ptr, (size_t) len); #endif return ptr; } @@ -23129,14 +22415,12 @@ fail_args: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); } #else /* DUK_USE_ES6_PROXY */ DUK_EXTERNAL duk_idx_t duk_push_proxy(duk_hthread *thr, duk_uint_t proxy_flags) { DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(proxy_flags); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } #endif /* DUK_USE_ES6_PROXY */ @@ -23434,7 +22718,7 @@ if (DUK_UNLIKELY((duk_uidx_t) (thr->valstack_top - thr->valstack_bottom) < (duk_uidx_t) count)) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count >= 0); @@ -23522,7 +22806,6 @@ DUK_ASSERT(thr->valstack_top >= thr->valstack_bottom); if (DUK_UNLIKELY(thr->valstack_top == thr->valstack_bottom)) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); } duk__pop_unsafe_raw(thr); @@ -23611,7 +22894,6 @@ DUK_ASSERT(thr->valstack_top >= thr->valstack_bottom); if (DUK_UNLIKELY(thr->valstack_top - 2 < thr->valstack_bottom)) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); } duk__pop_2_unsafe_raw(thr); @@ -23669,7 +22951,7 @@ if (DUK_UNLIKELY((duk_uidx_t) count > (duk_uidx_t) top)) { /* Also handles negative count. */ DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count >= 0); @@ -23686,8 +22968,9 @@ /* Copy value stack values directly to the array part without * any refcount updates: net refcount changes are zero. */ + tv_src = thr->valstack_top - count - 1; - duk_memcpy_unsafe((void *) tv_dst, (const void *) tv_src, (size_t) count * sizeof(duk_tval)); + DUK_MEMCPY((void *) tv_dst, (const void *) tv_src, (size_t) count * sizeof(duk_tval)); /* Overwrite result array to final value stack location and wipe * the rest; no refcount operations needed. @@ -23805,11 +23088,11 @@ } DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + return 0; fail_over_2g: DUK_ERROR_RANGE_INVALID_LENGTH(thr); - DUK_WO_NORETURN(return 0;); + return 0; } /* @@ -23826,7 +23109,6 @@ if (DUK_UNLIKELY(thr->valstack_top == thr->valstack_bottom)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return;); } /* Errors are augmented when they are created, not when they are @@ -23890,7 +23172,6 @@ duk_push_error_object_va_raw(thr, err_code, filename, line, fmt, ap); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_error_raw(duk_hthread *thr, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...) { @@ -23902,7 +23183,6 @@ duk_push_error_object_va_raw(thr, err_code, filename, line, fmt, ap); va_end(ap); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } #if !defined(DUK_USE_VARIADIC_MACROS) @@ -23921,7 +23201,6 @@ duk_push_error_object_va_raw(thr, err_code, filename, line, fmt, ap); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } #define DUK__ERROR_STASH_SHARED(code) do { \ @@ -23929,7 +23208,7 @@ va_start(ap, fmt); \ duk__throw_error_from_stash(thr, (code), fmt, ap); \ va_end(ap); \ - DUK_WO_NORETURN(return 0;); \ + /* Never reached; if return 0 here, gcc/clang will complain. */ \ } while (0) DUK_EXTERNAL duk_ret_t duk_error_stash(duk_hthread *thr, duk_errcode_t err_code, const char *fmt, ...) { @@ -24059,7 +23338,7 @@ DUK_ASSERT_API_ENTRY(thr); - duk_push_literal(thr, "light_"); + duk_push_sprintf(thr, "light_"); duk_push_string_funcptr(thr, (duk_uint8_t *) &func, sizeof(func)); duk_push_sprintf(thr, "_%04x", (unsigned int) lf_flags); duk_concat(thr, 3); @@ -24084,9 +23363,9 @@ DUK_ASSERT(DUK_TVAL_IS_LIGHTFUNC(tv)); DUK_TVAL_GET_LIGHTFUNC(tv, func, lf_flags); /* read before 'tv' potentially invalidated */ - duk_push_literal(thr, "function "); + duk_push_string(thr, "function "); duk_push_lightfunc_name_raw(thr, func, lf_flags); - duk_push_literal(thr, "() { [lightfunc code] }"); + duk_push_string(thr, "() { [lightfunc code] }"); duk_concat(thr, 3); } @@ -24198,7 +23477,7 @@ /* 'tv' may be NULL */ if (tv == NULL) { - duk_push_literal(thr, "none"); + duk_push_string(thr, "none"); } else { switch (DUK_TVAL_GET_TAG(tv)) { case DUK_TAG_STRING: { @@ -24207,11 +23486,11 @@ /* XXX: string summary produces question marks * so this is not very ideal. */ - duk_push_literal(thr, "[Symbol "); + duk_push_string(thr, "[Symbol "); duk_push_string(thr, duk__get_symbol_type_string(h)); - duk_push_literal(thr, " "); + duk_push_string(thr, " "); duk__push_hstring_readable_unicode(thr, h, DUK__READABLE_STRING_MAXCHARS); - duk_push_literal(thr, "]"); + duk_push_string(thr, "]"); duk_concat(thr, 5); break; } @@ -24241,7 +23520,7 @@ break; } } - duk_push_class_string_tval(thr, tv, 1 /*avoid_side_effects*/); + duk_push_class_string_tval(thr, tv); break; } case DUK_TAG_BUFFER: { @@ -24296,7 +23575,7 @@ DUK_ASSERT_API_ENTRY(thr); /* .toString() */ - duk_push_literal(thr, "Symbol("); + duk_push_string(thr, "Symbol("); p = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h); p_end = p + DUK_HSTRING_GET_BYTELEN(h); DUK_ASSERT(p[0] == 0xff || (p[0] & 0xc0) == 0x80); @@ -24312,7 +23591,7 @@ } } duk_push_lstring(thr, (const char *) p, (duk_size_t) (q - p)); - duk_push_literal(thr, ")"); + duk_push_string(thr, ")"); duk_concat(thr, 3); } @@ -24348,8 +23627,7 @@ DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(thr); DUK_ASSERT(count * sizeof(duk_tval) >= count); /* no wrap */ - - duk_memcpy_unsafe((void *) tv_dst, (const void *) tv_src, count * sizeof(duk_tval)); + DUK_MEMCPY((void *) tv_dst, (const void *) tv_src, count * sizeof(duk_tval)); tv = tv_dst; while (count-- > 0) { @@ -24385,7 +23663,7 @@ if (DUK_UNLIKELY(count_in <= 0)) { if (count_in < 0) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count_in == 0); duk_push_hstring_empty(thr); @@ -24441,11 +23719,11 @@ for (i = count; i >= 1; i--) { if (is_join && i != count) { h = duk_require_hstring(thr, -((duk_idx_t) count) - 2); /* extra -1 for buffer */ - duk_memcpy(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); + DUK_MEMCPY(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); idx += DUK_HSTRING_GET_BYTELEN(h); } h = duk_require_hstring(thr, -((duk_idx_t) i) - 1); /* extra -1 for buffer */ - duk_memcpy(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); + DUK_MEMCPY(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); idx += DUK_HSTRING_GET_BYTELEN(h); } @@ -24472,7 +23750,6 @@ error_overflow: DUK_ERROR_RANGE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_concat(duk_hthread *thr, duk_idx_t count) { @@ -24510,8 +23787,8 @@ buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, len); DUK_ASSERT(buf != NULL); - duk_memcpy((void *) buf, (const void *) DUK_HSTRING_GET_DATA(h1), (size_t) len1); - duk_memcpy((void *) (buf + len1), (const void *) DUK_HSTRING_GET_DATA(h2), (size_t) len2); + DUK_MEMCPY((void *) buf, (const void *) DUK_HSTRING_GET_DATA(h1), (size_t) len1); + DUK_MEMCPY((void *) (buf + len1), (const void *) DUK_HSTRING_GET_DATA(h2), (size_t) len2); (void) duk_buffer_to_string(thr, -1); /* Safe if inputs are safe. */ /* [ ... str1 str2 buf ] */ @@ -24522,7 +23799,6 @@ error_overflow: DUK_ERROR_RANGE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_PREFER_SIZE */ @@ -24751,7 +24027,7 @@ /* #include duk_internal.h -> already included */ DUK_INTERNAL duk_double_t duk_time_get_ecmascript_time(duk_hthread *thr) { - /* ECMAScript time, with millisecond fractions. Exposed via + /* Ecmascript time, with millisecond fractions. Exposed via * duk_get_now() for example. */ DUK_UNREF(thr); @@ -24759,7 +24035,7 @@ } DUK_INTERNAL duk_double_t duk_time_get_ecmascript_time_nofrac(duk_hthread *thr) { - /* ECMAScript time without millisecond fractions. Exposed via + /* Ecmascript time without millisecond fractions. Exposed via * the Date built-in which doesn't allow fractions. */ DUK_UNREF(thr); @@ -24802,7 +24078,7 @@ DUK_UNREF(thr); /* Convert as one-based, but change month to zero-based to match the - * ECMAScript Date built-in behavior 1:1. + * Ecmascript Date built-in behavior 1:1. */ flags = DUK_DATE_FLAG_ONEBASED | DUK_DATE_FLAG_NAN_TO_ZERO; @@ -24857,9 +24133,9 @@ /* * Array built-ins * - * Most Array built-ins are intentionally generic in ECMAScript, and are + * Most Array built-ins are intentionally generic in Ecmascript, and are * intended to work even when the 'this' binding is not an Array instance. - * This ECMAScript feature is also used by much real world code. For this + * This Ecmascript feature is also used by much real world code. For this * reason the implementations here don't assume exotic Array behavior or * e.g. presence of a .length property. However, some algorithms have a * fast path for duk_harray backed actual Array instances, enabled when @@ -24933,7 +24209,6 @@ duk_uint32_t ret = duk__push_this_obj_len_u32(thr); if (DUK_UNLIKELY(ret >= 0x80000000UL)) { DUK_ERROR_RANGE_INVALID_LENGTH(thr); - DUK_WO_NORETURN(return 0U;); } return ret; } @@ -25086,17 +24361,11 @@ DUK_INTERNAL duk_ret_t duk_bi_array_prototype_concat(duk_hthread *thr) { duk_idx_t i, n; - duk_uint32_t j, idx, len; + duk_uarridx_t idx, idx_last; + duk_uarridx_t j, len; duk_hobject *h; - duk_size_t tmp_len; - - /* XXX: In ES2015 Array .length can be up to 2^53-1. The current - * implementation is limited to 2^32-1. - */ - - /* XXX: Fast path for array 'this' and array element. */ - /* XXX: The insert here is a bit expensive if there are a lot of items. + /* XXX: the insert here is a bit expensive if there are a lot of items. * It could also be special cased in the outermost for loop quite easily * (as the element is dup()'d anyway). */ @@ -25114,97 +24383,59 @@ */ idx = 0; + idx_last = 0; for (i = 0; i < n; i++) { - duk_bool_t spreadable; - duk_bool_t need_has_check; - DUK_ASSERT_TOP(thr, n + 1); /* [ ToObject(this) item1 ... itemN arr ] */ - h = duk_get_hobject(thr, i); - - if (h == NULL) { - spreadable = 0; - } else { -#if defined(DUK_USE_SYMBOL_BUILTIN) - duk_get_prop_stridx(thr, i, DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE); - if (duk_is_undefined(thr, -1)) { - spreadable = (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY); - } else { - spreadable = duk_to_boolean(thr, -1); - } - duk_pop_nodecref_unsafe(thr); -#else - spreadable = (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY); -#endif - } - - if (!spreadable) { - duk_dup(thr, i); - duk_xdef_prop_index_wec(thr, -2, idx); - idx++; - if (DUK_UNLIKELY(idx == 0U)) { - /* Index after update is 0, and index written - * was 0xffffffffUL which is no longer a valid - * array index. - */ - goto fail_wrap; - } + duk_dup(thr, i); + h = duk_get_hobject_with_class(thr, -1, DUK_HOBJECT_CLASS_ARRAY); + if (!h) { + duk_xdef_prop_index_wec(thr, -2, idx++); + idx_last = idx; continue; } - DUK_ASSERT(duk_is_object(thr, i)); - need_has_check = (DUK_HOBJECT_IS_PROXY(h) != 0); /* Always 0 w/o Proxy support. */ + /* [ ToObject(this) item1 ... itemN arr item(i) ] */ - /* [ ToObject(this) item1 ... itemN arr ] */ - - tmp_len = duk_get_length(thr, i); - len = (duk_uint32_t) tmp_len; - if (DUK_UNLIKELY(tmp_len != (duk_size_t) len)) { - goto fail_wrap; - } - if (DUK_UNLIKELY(idx + len < idx)) { - /* Result length must be at most 0xffffffffUL to be - * a valid 32-bit array index. - */ - goto fail_wrap; - } + /* XXX: an array can have length higher than 32 bits; this is not handled + * correctly now. + */ + len = (duk_uarridx_t) duk_get_length(thr, -1); for (j = 0; j < len; j++) { - /* For a Proxy element, an explicit 'has' check is - * needed to allow the Proxy to present gaps. - */ - if (need_has_check) { - if (duk_has_prop_index(thr, i, j)) { - duk_get_prop_index(thr, i, j); - duk_xdef_prop_index_wec(thr, -2, idx); - } + if (duk_get_prop_index(thr, -1, j)) { + /* [ ToObject(this) item1 ... itemN arr item(i) item(i)[j] ] */ + duk_xdef_prop_index_wec(thr, -3, idx++); + idx_last = idx; } else { - if (duk_get_prop_index(thr, i, j)) { - duk_xdef_prop_index_wec(thr, -2, idx); - } else { - duk_pop_undefined(thr); - } + idx++; + duk_pop_undefined(thr); +#if defined(DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER) + /* According to E5.1 Section 15.4.4.4 nonexistent trailing + * elements do not affect 'length' of the result. Test262 + * and other engines disagree, so update idx_last here too. + */ + idx_last = idx; +#else + /* Strict standard behavior, ignore trailing elements for + * result 'length'. + */ +#endif } - idx++; - DUK_ASSERT(idx != 0U); /* Wrap check above. */ } + duk_pop_unsafe(thr); } - /* ES5.1 has a specification "bug" in that nonexistent trailing - * elements don't affect the result .length. Test262 and other - * engines disagree, and the specification bug was fixed in ES2015 - * (see NOTE 1 in https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.concat). + /* The E5.1 Section 15.4.4.4 algorithm doesn't set the length explicitly + * in the end, but because we're operating with an internal value which + * is known to be an array, this should be equivalent. */ - duk_push_uarridx(thr, idx); + duk_push_uarridx(thr, idx_last); duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_W); DUK_ASSERT_TOP(thr, n + 1); return 1; - - fail_wrap: - DUK_ERROR_RANGE_INVALID_LENGTH(thr); - DUK_WO_NORETURN(return 0;); } /* @@ -26326,12 +25557,20 @@ DUK_ASSERT_TOP(thr, 5); if (!duk_get_prop_index(thr, 2, (duk_uarridx_t) i)) { - /* For 'map' trailing missing elements don't invoke the - * callback but count towards the result length. +#if defined(DUK_USE_NONSTD_ARRAY_MAP_TRAILER) + /* Real world behavior for map(): trailing non-existent + * elements don't invoke the user callback, but are still + * counted towards result 'length'. */ if (iter_type == DUK__ITER_MAP) { res_length = i + 1; } +#else + /* Standard behavior for map(): trailing non-existent + * elements don't invoke the user callback and are not + * counted towards result 'length'. + */ +#endif duk_pop_undefined(thr); continue; } @@ -26756,7 +25995,6 @@ if (flags & DUK__BUFOBJ_FLAG_THROW) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } return NULL; } @@ -26798,7 +26036,7 @@ } DUK_ERROR_TYPE(thr, DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); + return NULL; /* not reachable */ } DUK_LOCAL void duk__set_bufobj_buffer(duk_hthread *thr, duk_hbufobj *h_bufobj, duk_hbuffer *h_val) { @@ -26873,7 +26111,6 @@ fail_range: DUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARGS); - DUK_WO_NORETURN(return;); } /* Shared lenient buffer length clamping helper. No negative indices, no @@ -27024,8 +26261,7 @@ DUK_INTERNAL void duk_hbufobj_push_validated_read(duk_hthread *thr, duk_hbufobj *h_bufobj, duk_uint8_t *p, duk_small_uint_t elem_size) { duk_double_union du; - DUK_ASSERT(elem_size > 0); - duk_memcpy((void *) du.uc, (const void *) p, (size_t) elem_size); + DUK_MEMCPY((void *) du.uc, (const void *) p, (size_t) elem_size); switch (h_bufobj->elem_type) { case DUK_HBUFOBJ_ELEM_UINT8: @@ -27093,11 +26329,7 @@ du.ui[0] = (duk_uint32_t) duk_to_int32(thr, -1); break; case DUK_HBUFOBJ_ELEM_FLOAT32: - /* A double-to-float cast is undefined behavior in C99 if - * the cast is out-of-range, so use a helper. Example: - * runtime error: value -1e+100 is outside the range of representable values of type 'float' - */ - du.f[0] = duk_double_to_float_t(duk_to_number_m1(thr)); + du.f[0] = (duk_float_t) duk_to_number_m1(thr); break; case DUK_HBUFOBJ_ELEM_FLOAT64: du.d = (duk_double_t) duk_to_number_m1(thr); @@ -27106,8 +26338,7 @@ DUK_UNREACHABLE(); } - DUK_ASSERT(elem_size > 0); - duk_memcpy((void *) p, (const void *) du.uc, (size_t) elem_size); + DUK_MEMCPY((void *) p, (const void *) du.uc, (size_t) elem_size); } /* Helper to create a fixed buffer from argument value at index 0. @@ -27143,14 +26374,12 @@ h_bufobj = (duk_hbufobj *) h; if (DUK_UNLIKELY(h_bufobj->buf == NULL)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } if (DUK_UNLIKELY(h_bufobj->offset != 0 || h_bufobj->length != DUK_HBUFFER_GET_SIZE(h_bufobj->buf))) { /* No support for ArrayBuffers with slice * offset/length. */ DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } duk_push_hbuffer(thr, h_bufobj->buf); return h_bufobj->buf; @@ -27166,7 +26395,6 @@ } default: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } done: @@ -27208,7 +26436,7 @@ duk_push_buffer_object(thr, -1, 0, - DUK_HBUFFER_FIXED_GET_SIZE((duk_hbuffer_fixed *) (void *) h_buf), + DUK_HBUFFER_FIXED_GET_SIZE((duk_hbuffer_fixed *) h_buf), DUK_BUFOBJ_UINT8ARRAY); duk_push_hobject_bidx(thr, DUK_BIDX_NODEJS_BUFFER_PROTOTYPE); duk_set_prototype(thr, -2); @@ -27536,7 +26764,7 @@ DUK_DDD(DUK_DDDPRINT("using memcpy: p_src=%p, p_dst=%p, byte_length=%ld", (void *) p_src, (void *) p_dst, (long) byte_length)); - duk_memcpy_unsafe((void *) p_dst, (const void *) p_src, (size_t) byte_length); + DUK_MEMCPY((void *) p_dst, (const void *) p_src, (size_t) byte_length); break; } case 1: { @@ -27772,7 +27000,7 @@ h_this = duk__get_bufobj_this(thr); if (h_this == NULL) { /* XXX: happens e.g. when evaluating: String(Buffer.prototype). */ - duk_push_literal(thr, "[object Object]"); + duk_push_string(thr, "[object Object]"); return 1; } DUK_ASSERT_HBUFOBJ_VALID(h_this); @@ -27803,9 +27031,9 @@ */ DUK_ASSERT(DUK_HBUFOBJ_VALID_BYTEOFFSET_EXCL(h_this, (duk_size_t) start_offset + slice_length)); - duk_memcpy_unsafe((void *) buf_slice, - (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), - (size_t) slice_length); + DUK_MEMCPY((void *) buf_slice, + (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), + (size_t) slice_length); /* Use the equivalent of: new TextEncoder().encode(this) to convert the * string. Result will be valid UTF-8; non-CESU-8 inputs are currently @@ -27967,7 +27195,7 @@ /* Handle single character fills as memset() even when * the fill data comes from a one-char argument. */ - duk_memset_unsafe((void *) p, (int) fill_str_ptr[0], (size_t) fill_length); + DUK_MEMSET((void *) p, (int) fill_str_ptr[0], (size_t) fill_length); } else if (fill_str_len > 1) { duk_size_t i, n, t; @@ -28018,9 +27246,9 @@ if (DUK_HBUFOBJ_VALID_SLICE(h_this)) { /* Cannot overlap. */ - duk_memcpy_unsafe((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + offset), - (const void *) str_data, - (size_t) length); + DUK_MEMCPY((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + offset), + (const void *) str_data, + (size_t) length); } else { DUK_DDD(DUK_DDDPRINT("write() target buffer is not covered, silent ignore")); } @@ -28116,9 +27344,9 @@ /* Must use memmove() because copy area may overlap (source and target * buffer may be the same, or from different slices. */ - duk_memmove_unsafe((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufarg) + target_ustart), - (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + source_ustart), - (size_t) copy_size); + DUK_MEMMOVE((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufarg) + target_ustart), + (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + source_ustart), + (size_t) copy_size); } else { DUK_DDD(DUK_DDDPRINT("buffer copy not covered by underlying buffer(s), ignoring")); } @@ -28304,7 +27532,7 @@ DUK_ASSERT(src_length == dst_length); DUK_DDD(DUK_DDDPRINT("fast path: able to use memmove() because views are compatible")); - duk_memmove_unsafe((void *) p_dst_base, (const void *) p_src_base, (size_t) dst_length); + DUK_MEMMOVE((void *) p_dst_base, (const void *) p_src_base, (size_t) dst_length); return 0; } DUK_DDD(DUK_DDDPRINT("fast path: views are not compatible with a byte copy, copy by item")); @@ -28347,7 +27575,7 @@ DUK_DDD(DUK_DDDPRINT("there is overlap, make a copy of the source")); p_src_copy = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, src_length); DUK_ASSERT(p_src_copy != NULL); - duk_memcpy_unsafe((void *) p_src_copy, (const void *) p_src_base, (size_t) src_length); + DUK_MEMCPY((void *) p_src_copy, (const void *) p_src_base, (size_t) src_length); p_src_base = p_src_copy; /* use p_src_base from now on */ } @@ -28474,9 +27702,9 @@ DUK_ASSERT(p_copy != NULL); copy_length = slice_length; - duk_memcpy_unsafe((void *) p_copy, - (const void *) ((duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_val) + start_offset), - copy_length); + DUK_MEMCPY((void *) p_copy, + (const void *) ((duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_val) + start_offset), + copy_length); } #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ @@ -28598,9 +27826,9 @@ * is left as zero. */ copy_length = DUK_HBUFOBJ_CLAMP_BYTELENGTH(h_this, slice_length); - duk_memcpy_unsafe((void *) p_copy, - (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), - copy_length); + DUK_MEMCPY((void *) p_copy, + (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), + copy_length); h_val = duk_known_hbuffer(thr, -1); @@ -28792,9 +28020,9 @@ if (h_bufobj->buf != NULL && DUK_HBUFOBJ_VALID_SLICE(h_bufobj)) { - duk_memcpy_unsafe((void *) p, - (const void *) DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufobj), - copy_size); + DUK_MEMCPY((void *) p, + (const void *) DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufobj), + copy_size); } else { /* Just skip, leaving zeroes in the result. */ ; @@ -28944,7 +28172,7 @@ if (offset + 2U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 2); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 2); tmp = du.us[0]; if (endswap) { tmp = DUK_BSWAP16(tmp); @@ -28961,7 +28189,7 @@ if (offset + 4U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 4); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 4); tmp = du.ui[0]; if (endswap) { tmp = DUK_BSWAP32(tmp); @@ -28978,7 +28206,7 @@ if (offset + 4U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 4); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 4); if (endswap) { tmp = du.ui[0]; tmp = DUK_BSWAP32(tmp); @@ -28991,7 +28219,7 @@ if (offset + 8U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 8); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 8); if (endswap) { DUK_DBLUNION_BSWAP64(&du); } @@ -29048,12 +28276,9 @@ } while (i != i_end); if (magic_signed) { - /* Shift to sign extend. Left shift must be unsigned - * to avoid undefined behavior; right shift must be - * signed to sign extend properly. - */ + /* Shift to sign extend. */ shift_tmp = (duk_small_uint_t) (64U - (duk_small_uint_t) field_bytelen * 8U); - tmp = (duk_int64_t) ((duk_uint64_t) tmp << shift_tmp) >> shift_tmp; + tmp = (tmp << shift_tmp) >> shift_tmp; } duk_push_i64(thr, tmp); @@ -29229,7 +28454,7 @@ } du.us[0] = tmp; /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 2); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 2); break; } case DUK__FLD_32BIT: { @@ -29243,7 +28468,7 @@ } du.ui[0] = tmp; /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 4); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 4); break; } case DUK__FLD_FLOAT: { @@ -29258,7 +28483,7 @@ du.ui[0] = tmp; } /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 4); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 4); break; } case DUK__FLD_DOUBLE: { @@ -29270,7 +28495,7 @@ DUK_DBLUNION_BSWAP64(&du); } /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 8); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 8); break; } case DUK__FLD_VARINT: { @@ -29716,7 +28941,7 @@ duk_small_uint_t i; /* During parsing, month and day are one-based; set defaults here. */ - duk_memzero(parts, sizeof(parts)); + DUK_MEMZERO(parts, sizeof(parts)); DUK_ASSERT(parts[DUK_DATE_IDX_YEAR] == 0); /* don't care value, year is mandatory */ parts[DUK_DATE_IDX_MONTH] = 1; parts[DUK_DATE_IDX_DAY] = 1; @@ -29943,13 +29168,13 @@ }; /* Maximum iteration count for computing UTC-to-local time offset when - * creating an ECMAScript time value from local parts. + * creating an Ecmascript time value from local parts. */ #define DUK__LOCAL_TZOFFSET_MAXITER 4 /* Because 'day since epoch' can be negative and is used to compute weekday * using a modulo operation, add this multiple of 7 to avoid negative values - * when year is below 1970 epoch. ECMAScript time values are restricted to + * when year is below 1970 epoch. Ecmascript time values are restricted to * +/- 100 million days from epoch, so this adder fits nicely into 32 bits. * Round to a multiple of 7 (= floor(100000000 / 7) * 7) and add margin. */ @@ -30140,10 +29365,10 @@ d = DUK_FLOOR(d); /* remove fractions if present */ DUK_ASSERT(DUK_FLOOR(d) == d); - /* The timevalue must be in valid ECMAScript range, but since a local + /* The timevalue must be in valid Ecmascript range, but since a local * time offset can be applied, we need to allow a +/- 24h leeway to * the value. In other words, although the UTC time is within the - * ECMAScript range, the local part values can be just outside of it. + * Ecmascript range, the local part values can be just outside of it. */ DUK_UNREF(duk_bi_date_timeval_in_leeway_range); DUK_ASSERT(duk_bi_date_timeval_in_leeway_range(d)); @@ -30186,7 +29411,7 @@ (long) parts[DUK_DATE_IDX_MILLISECOND])); /* This assert depends on the input parts representing time inside - * the ECMAScript range. + * the Ecmascript range. */ DUK_ASSERT(t2 + DUK__WEEKDAY_MOD_ADDER >= 0); parts[DUK_DATE_IDX_WEEKDAY] = (t2 + 4 + DUK__WEEKDAY_MOD_ADDER) % 7; /* E5.1 Section 15.9.1.6 */ @@ -30306,7 +29531,7 @@ * computation happens with intermediate results coerced to * double values (instead of using something more accurate). * E.g. E5.1 Section 15.9.1.11 requires use of IEEE 754 - * rules (= ECMAScript '+' and '*' operators). + * rules (= Ecmascript '+' and '*' operators). * * Without 'volatile' even this approach fails on some platform * and compiler combinations. For instance, gcc 4.8.1 on Ubuntu @@ -30413,7 +29638,6 @@ h = duk_get_hobject(thr, -1); /* XXX: getter with class check, useful in built-ins */ if (h == NULL || DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_DATE) { DUK_ERROR_TYPE(thr, "expected Date"); - DUK_WO_NORETURN(return 0.0;); } duk_get_prop_stridx_short(thr, -1, DUK_STRIDX_INT_VALUE); @@ -30426,7 +29650,6 @@ } if (flags & DUK_DATE_FLAG_NAN_TO_RANGE_ERROR) { DUK_ERROR_RANGE(thr, "Invalid Date"); - DUK_WO_NORETURN(return 0.0;); } } /* if no NaN handling flag, may still be NaN here, but not Inf */ @@ -31043,7 +30266,7 @@ * Notes: * * - Date.prototype.toGMTString() and Date.prototype.toUTCString() are - * required to be the same ECMAScript function object (!), so it is + * required to be the same Ecmascript function object (!), so it is * omitted from here. * * - Date.prototype.toUTCString(): E5.1 specification does not require a @@ -31239,41 +30462,6 @@ return 1; } -/* - * Misc. - */ - -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL duk_ret_t duk_bi_date_prototype_toprimitive(duk_hthread *thr) { - duk_size_t hintlen; - const char *hintstr; - duk_int_t hint; - - /* Invokes OrdinaryToPrimitive() with suitable hint. Note that the - * method is generic, and works on non-Date arguments too. - * - * https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype-@@toprimitive - */ - - duk_push_this(thr); - duk_require_object(thr, -1); - DUK_ASSERT_TOP(thr, 2); - - hintstr = duk_require_lstring(thr, 0, &hintlen); - if ((hintlen == 6 && DUK_STRCMP(hintstr, "string") == 0) || - (hintlen == 7 && DUK_STRCMP(hintstr, "default") == 0)) { - hint = DUK_HINT_STRING; - } else if (hintlen == 6 && DUK_STRCMP(hintstr, "number") == 0) { - hint = DUK_HINT_NUMBER; - } else { - DUK_DCERROR_TYPE_INVALID_ARGS(thr); - } - - duk_to_primitive_ordinary(thr, -1, hint); - return 1; -} -#endif /* DUK_USE_SYMBOL_BUILTIN */ - #endif /* DUK_USE_DATE_BUILTIN */ /* automatic undefs */ @@ -31341,7 +30529,7 @@ #define DUK__STRFTIME_BUF_SIZE 64 #if defined(DUK_USE_DATE_NOW_GETTIMEOFDAY) -/* Get current ECMAScript time (= UNIX/Posix time, but in milliseconds). */ +/* Get current Ecmascript time (= UNIX/Posix time, but in milliseconds). */ DUK_INTERNAL duk_double_t duk_bi_date_get_now_gettimeofday(void) { struct timeval tv; duk_double_t d; @@ -31389,7 +30577,7 @@ return 0; } - /* If not within ECMAScript range, some integer time calculations + /* If not within Ecmascript range, some integer time calculations * won't work correctly (and some asserts will fail), so bail out * if so. This fixes test-bug-date-insane-setyear.js. There is * a +/- 24h leeway in this range check to avoid a test262 corner @@ -31440,10 +30628,10 @@ * Since we rely on the platform APIs for conversions between local * time and UTC, we can't guarantee the above. Rather, if the platform * has historical DST rules they will be applied. This seems to be the - * general preferred direction in ECMAScript standardization (or at least + * general preferred direction in Ecmascript standardization (or at least * implementations) anyway, and even the equivalent year mapping should * be disabled if the platform is known to handle DST properly for the - * full ECMAScript range. + * full Ecmascript range. * * The following has useful discussion and links: * @@ -31458,7 +30646,7 @@ t = (time_t) (d / 1000.0); DUK_DDD(DUK_DDDPRINT("timeval: %lf -> time_t %ld", (double) d, (long) t)); - duk_memzero((void *) tms, sizeof(struct tm) * 2); + DUK_MEMZERO((void *) tms, sizeof(struct tm) * 2); #if defined(DUK_USE_DATE_TZO_GMTIME_R) (void) gmtime_r(&t, &tms[0]); @@ -31468,9 +30656,9 @@ (void) localtime_s(&t, &tms[1]); #elif defined(DUK_USE_DATE_TZO_GMTIME) tm_ptr = gmtime(&t); - duk_memcpy((void *) &tms[0], tm_ptr, sizeof(struct tm)); + DUK_MEMCPY((void *) &tms[0], tm_ptr, sizeof(struct tm)); tm_ptr = localtime(&t); - duk_memcpy((void *) &tms[1], tm_ptr, sizeof(struct tm)); + DUK_MEMCPY((void *) &tms[1], tm_ptr, sizeof(struct tm)); #else #error internal error #endif @@ -31531,13 +30719,13 @@ /* Copy to buffer with slack to avoid Valgrind gripes from strptime. */ DUK_ASSERT(str != NULL); - duk_memzero(buf, sizeof(buf)); /* valgrind whine without this */ + DUK_MEMZERO(buf, sizeof(buf)); /* valgrind whine without this */ DUK_SNPRINTF(buf, sizeof(buf), "%s", (const char *) str); buf[sizeof(buf) - 1] = (char) 0; DUK_DDD(DUK_DDDPRINT("parsing: '%s'", (const char *) buf)); - duk_memzero(&tm, sizeof(tm)); + DUK_MEMZERO(&tm, sizeof(tm)); if (strptime((const char *) buf, "%c", &tm) != NULL) { DUK_DDD(DUK_DDDPRINT("before mktime: tm={sec:%ld,min:%ld,hour:%ld,mday:%ld,mon:%ld,year:%ld," "wday:%ld,yday:%ld,isdst:%ld}", @@ -31568,7 +30756,7 @@ * convenient for an embeddable interpreter. */ - duk_memzero(&tm, sizeof(struct tm)); + DUK_MEMZERO(&tm, sizeof(struct tm)); rc = (duk_small_int_t) getdate_r(str, &tm); DUK_DDD(DUK_DDDPRINT("getdate_r() -> %ld", (long) rc)); @@ -31593,16 +30781,16 @@ DUK_UNREF(tzoffset); - /* If the platform doesn't support the entire ECMAScript range, we need + /* If the platform doesn't support the entire Ecmascript range, we need * to return 0 so that the caller can fall back to the default formatter. * - * For now, assume that if time_t is 8 bytes or more, the whole ECMAScript + * For now, assume that if time_t is 8 bytes or more, the whole Ecmascript * range is supported. For smaller time_t values (4 bytes in practice), * assumes that the signed 32-bit range is supported. * * XXX: detect this more correctly per platform. The size of time_t is * probably not an accurate guarantee of strftime() supporting or not - * supporting a large time range (the full ECMAScript range). + * supporting a large time range (the full Ecmascript range). */ if (sizeof(time_t) < 8 && (parts[DUK_DATE_IDX_YEAR] < 1970 || parts[DUK_DATE_IDX_YEAR] > 2037)) { @@ -31610,7 +30798,7 @@ return 0; } - duk_memzero(&tm, sizeof(tm)); + DUK_MEMZERO(&tm, sizeof(tm)); tm.tm_sec = parts[DUK_DATE_IDX_SECOND]; tm.tm_min = parts[DUK_DATE_IDX_MINUTE]; tm.tm_hour = parts[DUK_DATE_IDX_HOUR]; @@ -31620,7 +30808,7 @@ tm.tm_wday = parts[DUK_DATE_IDX_WEEKDAY]; tm.tm_isdst = 0; - duk_memzero(buf, sizeof(buf)); + DUK_MEMZERO(buf, sizeof(buf)); if ((flags & DUK_DATE_FLAG_TOSTRING_DATE) && (flags & DUK_DATE_FLAG_TOSTRING_TIME)) { fmt = "%c"; } else if (flags & DUK_DATE_FLAG_TOSTRING_DATE) { @@ -31678,15 +30866,13 @@ } } -#if defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS) DUK_LOCAL void duk__convert_filetime_to_ularge(const FILETIME *ft, ULARGE_INTEGER *res) { res->LowPart = ft->dwLowDateTime; res->HighPart = ft->dwHighDateTime; } -#endif /* DUK_USE_DATE_NOW_WINDOWS_SUBMS */ DUK_LOCAL void duk__set_systime_jan1970(SYSTEMTIME *st) { - duk_memzero((void *) st, sizeof(*st)); + DUK_MEMZERO((void *) st, sizeof(*st)); st->wYear = 1970; st->wMonth = 1; st->wDayOfWeek = 4; /* not sure whether or not needed; Thursday */ @@ -31751,11 +30937,10 @@ ULARGE_INTEGER tmp2; ULARGE_INTEGER tmp3; FILETIME ft1; - BOOL ret; /* XXX: handling of timestamps outside Windows supported range. * How does Windows deal with dates before 1600? Does windows - * support all ECMAScript years (like -200000 and +200000)? + * support all Ecmascript years (like -200000 and +200000)? * Should equivalent year mapping be used here too? If so, use * a shared helper (currently integrated into timeval-to-parts). */ @@ -31771,11 +30956,7 @@ ft1.dwLowDateTime = tmp2.LowPart; ft1.dwHighDateTime = tmp2.HighPart; - ret = FileTimeToSystemTime((const FILETIME *) &ft1, &st2); - if (!ret) { - DUK_D(DUK_DPRINT("FileTimeToSystemTime() failed, return tzoffset 0")); - return 0; - } + FileTimeToSystemTime((const FILETIME *) &ft1, &st2); if (SystemTimeToTzSpecificLocalTime((LPTIME_ZONE_INFORMATION) NULL, &st2, &st3) == 0) { DUK_D(DUK_DPRINT("SystemTimeToTzSpecificLocalTime() failed, return tzoffset 0")); return 0; @@ -31795,7 +30976,6 @@ FILETIME ft2; ULARGE_INTEGER tmp1; ULARGE_INTEGER tmp2; - BOOL ret; /* Do a similar computation to duk_bi_date_get_local_tzoffset_windows * but without accounting for daylight savings time. Use this on @@ -31811,17 +30991,9 @@ ft1.dwLowDateTime = tmp1.LowPart; ft1.dwHighDateTime = tmp1.HighPart; - ret = FileTimeToLocalFileTime((const FILETIME *) &ft1, &ft2); - if (!ret) { - DUK_D(DUK_DPRINT("FileTimeToLocalFileTime() failed, return tzoffset 0")); - return 0; - } + FileTimeToLocalFileTime((const FILETIME *) &ft1, &ft2); - ret = FileTimeToSystemTime((const FILETIME *) &ft2, &st2); - if (!ret) { - DUK_D(DUK_DPRINT("FileTimeToSystemTime() failed, return tzoffset 0")); - return 0; - } + FileTimeToSystemTime((const FILETIME *) &ft2, &st2); duk__convert_systime_to_ularge((const SYSTEMTIME *) &st2, &tmp2); return (duk_int_t) (((LONGLONG) tmp2.QuadPart - (LONGLONG) tmp1.QuadPart) / DUK_I64_CONSTANT(10000000)); /* seconds */ @@ -31857,7 +31029,7 @@ * * Size optimization note: it might seem that vararg multipurpose functions * like fin(), enc(), and dec() are not very size optimal, but using a single - * user-visible ECMAScript function saves a lot of run-time footprint; each + * user-visible Ecmascript function saves a lot of run-time footprint; each * Function instance takes >100 bytes. Using a shared native helper and a * 'magic' value won't save much if there are multiple Function instances * anyway. @@ -32251,7 +31423,7 @@ DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER | DUK_TYPE_MASK_OBJECT); - if (duk_get_prop_literal(thr, 1, "stream")) { + if (duk_get_prop_string(thr, 1, "stream")) { stream = duk_to_boolean(thr, -1); } } @@ -32266,7 +31438,6 @@ */ if (len >= (DUK_HBUFFER_MAX_BYTELEN / 3) - 3) { DUK_ERROR_TYPE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return 0;); } output = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, 3 + (3 * len)); /* used parts will be always manually written over */ @@ -32344,7 +31515,7 @@ fail_type: DUK_ERROR_TYPE(thr, DUK_STR_UTF8_DECODE_FAILED); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); } /* @@ -32362,7 +31533,7 @@ } DUK_INTERNAL duk_ret_t duk_bi_textencoder_prototype_encoding_getter(duk_hthread *thr) { - duk_push_literal(thr, "utf-8"); + duk_push_string(thr, "utf-8"); return 1; } @@ -32384,7 +31555,6 @@ len = (duk_size_t) DUK_HSTRING_GET_CHARLEN(h_input); if (len >= DUK_HBUFFER_MAX_BYTELEN / 3) { DUK_ERROR_TYPE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return 0;); } } @@ -32404,14 +31574,14 @@ DUK_ASSERT(duk_is_string(thr, 0)); /* True if len > 0. */ /* XXX: duk_decode_string() is used to process the input - * string. For standard ECMAScript strings, represented + * string. For standard Ecmascript strings, represented * internally as CESU-8, this is fine. However, behavior * beyond CESU-8 is not very strict: codepoints using an * extended form of UTF-8 are also accepted, and invalid * codepoint sequences (which are allowed in Duktape strings) * are not handled as well as they could (e.g. invalid * continuation bytes may mask following codepoints). - * This is how ECMAScript code would also see such strings. + * This is how Ecmascript code would also see such strings. * Maybe replace duk_decode_string() with an explicit strict * CESU-8 decoder here? */ @@ -32439,7 +31609,7 @@ /* Standard WHATWG output is a Uint8Array. Here the Uint8Array will * be backed by a dynamic buffer which differs from e.g. Uint8Arrays - * created as 'new Uint8Array(N)'. ECMAScript code won't see the + * created as 'new Uint8Array(N)'. Ecmascript code won't see the * difference but C code will. When bufferobjects are not supported, * returns a plain dynamic buffer. */ @@ -32461,10 +31631,10 @@ duk_to_string(thr, 0); } if (!duk_is_null_or_undefined(thr, 1)) { - if (duk_get_prop_literal(thr, 1, "fatal")) { + if (duk_get_prop_string(thr, 1, "fatal")) { fatal = duk_to_boolean(thr, -1); } - if (duk_get_prop_literal(thr, 1, "ignoreBOM")) { + if (duk_get_prop_string(thr, 1, "ignoreBOM")) { ignore_bom = duk_to_boolean(thr, -1); } } @@ -32479,7 +31649,7 @@ dec_ctx->ignore_bom = (duk_uint8_t) ignore_bom; duk__utf8_decode_init(dec_ctx); /* Initializes remaining fields. */ - duk_put_prop_literal(thr, -2, DUK_INTERNAL_SYMBOL("Context")); + duk_put_prop_string(thr, -2, DUK_INTERNAL_SYMBOL("Context")); return 0; } @@ -32487,7 +31657,7 @@ DUK_LOCAL duk__decode_context *duk__get_textdecoder_context(duk_hthread *thr) { duk__decode_context *dec_ctx; duk_push_this(thr); - duk_get_prop_literal(thr, -1, DUK_INTERNAL_SYMBOL("Context")); + duk_get_prop_string(thr, -1, DUK_INTERNAL_SYMBOL("Context")); dec_ctx = (duk__decode_context *) duk_require_buffer(thr, -1, NULL); DUK_ASSERT(dec_ctx != NULL); return dec_ctx; @@ -32504,7 +31674,7 @@ /* Encoding is now fixed, so _Context lookup is only needed to * validate the 'this' binding (TypeError if not TextDecoder-like). */ - duk_push_literal(thr, "utf-8"); + duk_push_string(thr, "utf-8"); break; case 1: duk_push_boolean(thr, dec_ctx->fatal); @@ -32604,7 +31774,7 @@ duk_get_prop_stridx_short(thr, -1, DUK_STRIDX_NAME); if (duk_is_undefined(thr, -1)) { duk_pop(thr); - duk_push_literal(thr, "Error"); + duk_push_string(thr, "Error"); } else { duk_to_string(thr, -1); } @@ -32634,7 +31804,7 @@ duk_pop(thr); return 1; } - duk_push_literal(thr, ": "); + duk_push_string(thr, ": "); duk_insert(thr, -2); /* ... name ': ' message */ duk_concat(thr, 3); @@ -32703,13 +31873,13 @@ duk_get_prop_index(thr, idx_td, (duk_uarridx_t) i); duk_get_prop_index(thr, idx_td, (duk_uarridx_t) (i + 1)); d = duk_to_number_m1(thr); - pc = duk_double_to_int_t(DUK_FMOD(d, DUK_DOUBLE_2TO32)); - flags = duk_double_to_uint_t(DUK_FLOOR(d / DUK_DOUBLE_2TO32)); + pc = (duk_int_t) DUK_FMOD(d, DUK_DOUBLE_2TO32); + flags = (duk_uint_t) DUK_FLOOR(d / DUK_DOUBLE_2TO32); t = (duk_small_int_t) duk_get_type(thr, -2); if (t == DUK_TYPE_OBJECT || t == DUK_TYPE_LIGHTFUNC) { /* - * ECMAScript/native function call or lightfunc call + * Ecmascript/native function call or lightfunc call */ count_func++; @@ -32978,7 +32148,7 @@ duk_push_hstring_empty(thr); } else { duk_insert(thr, 0); /* [ arg1 ... argN-1 body] -> [body arg1 ... argN-1] */ - duk_push_literal(thr, ","); + duk_push_string(thr, ","); duk_insert(thr, 1); duk_join(thr, nargs - 1); } @@ -32990,11 +32160,11 @@ /* XXX: this placeholder is not always correct, but use for now. * It will fail in corner cases; see test-dev-func-cons-args.js. */ - duk_push_literal(thr, "function("); + duk_push_string(thr, "function("); duk_dup_1(thr); - duk_push_literal(thr, "){"); + duk_push_string(thr, "){"); duk_dup_0(thr); - duk_push_literal(thr, "\n}"); /* Newline is important to handle trailing // comment. */ + duk_push_string(thr, "}"); duk_concat(thr, 5); /* [ body formals source ] */ @@ -33012,7 +32182,7 @@ comp_flags); /* Force .name to 'anonymous' (ES2015). */ - duk_push_literal(thr, "anonymous"); + duk_push_string(thr, "anonymous"); duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_NAME, DUK_PROPDESC_FLAGS_C); func = (duk_hcompfunc *) duk_known_hobject(thr, -1); @@ -33224,7 +32394,7 @@ if (DUK_HOBJECT_HAS_BOUNDFUNC(h_target)) { duk_hboundfunc *h_boundtarget; - h_boundtarget = (duk_hboundfunc *) (void *) h_target; + h_boundtarget = (duk_hboundfunc *) h_target; /* The final function should always be non-bound, unless * there's a bug in the internals. Assert for it. @@ -33258,7 +32428,7 @@ DUK_DCERROR_RANGE_INVALID_COUNT(thr); } tv_res = (duk_tval *) DUK_ALLOC_CHECKED(thr, ((duk_size_t) bound_nargs) * sizeof(duk_tval)); - DUK_ASSERT(tv_res != NULL || bound_nargs == 0); + DUK_ASSERT(tv_res != NULL); DUK_ASSERT(h_bound->args == NULL); DUK_ASSERT(h_bound->nargs == 0); h_bound->args = tv_res; @@ -33298,7 +32468,7 @@ duk_xdef_prop_stridx_thrower(thr, -1, DUK_STRIDX_LC_ARGUMENTS); /* Function name and fileName (non-standard). */ - duk_push_literal(thr, "bound "); /* ES2015 19.2.3.2. */ + duk_push_string(thr, "bound "); /* ES2015 19.2.3.2. */ duk_get_prop_stridx(thr, -3, DUK_STRIDX_NAME); if (!duk_is_string_notsymbol(thr, -1)) { /* ES2015 has requirement to check that .name of target is a string @@ -33382,17 +32552,6 @@ fail_type: DUK_DCERROR_TYPE_INVALID_ARGS(thr); } - -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL duk_ret_t duk_bi_function_prototype_hasinstance(duk_hthread *thr) { - /* This binding: RHS, stack index 0: LHS. */ - duk_bool_t ret; - - ret = duk_js_instanceof_ordinary(thr, DUK_GET_TVAL_POSIDX(thr, 0), DUK_GET_THIS_TVAL_PTR(thr)); - duk_push_boolean(thr, ret); - return 1; -} -#endif /* DUK_USE_SYMBOL_BUILTIN */ /* * Global object built-ins */ @@ -33595,7 +32754,6 @@ uri_error: DUK_ERROR_URI(tfm_ctx->thr, DUK_STR_INVALID_INPUT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__transform_callback_decode_uri(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp) { @@ -33734,7 +32892,6 @@ uri_error: DUK_ERROR_URI(tfm_ctx->thr, DUK_STR_INVALID_INPUT); - DUK_WO_NORETURN(return;); } #if defined(DUK_USE_SECTION_B) @@ -33775,7 +32932,6 @@ esc_error: DUK_ERROR_TYPE(tfm_ctx->thr, DUK_STR_INVALID_INPUT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__transform_callback_unescape(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp) { @@ -33808,7 +32964,7 @@ * Eval needs to handle both a "direct eval" and an "indirect eval". * Direct eval handling needs access to the caller's activation so that its * lexical environment can be accessed. A direct eval is only possible from - * ECMAScript code; an indirect eval call is possible also from C code. + * Ecmascript code; an indirect eval call is possible also from C code. * When an indirect eval call is made from C code, there may not be a * calling activation at all which needs careful handling. */ @@ -33847,7 +33003,7 @@ #if defined(DUK_USE_DEBUGGER_SUPPORT) /* NOTE: level is used only by the debugger and should never be present - * for an ECMAScript eval(). + * for an Ecmascript eval(). */ DUK_ASSERT(level == -2); /* by default, use caller's environment */ if (duk_get_top(thr) >= 2 && duk_is_number(thr, 1)) { @@ -34340,7 +33496,6 @@ */ DUK_ERROR_FMT1(js_ctx->thr, DUK_ERR_SYNTAX_ERROR, DUK_STR_FMT_INVALID_JSON, (long) (js_ctx->p - js_ctx->p_start)); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__dec_eat_white(duk_json_dec_ctx *js_ctx) { @@ -34756,7 +33911,7 @@ src_len = (duk_size_t) (p - js_ctx->p); buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, src_len); DUK_ASSERT(buf != NULL); - duk_memcpy((void *) buf, (const void *) js_ctx->p, src_len); + DUK_MEMCPY((void *) buf, (const void *) js_ctx->p, src_len); duk_hex_decode(thr, -1); js_ctx->p = p + 1; /* skip '|' */ @@ -34847,7 +34002,6 @@ DUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit); if (js_ctx->recursion_depth >= js_ctx->recursion_limit) { DUK_ERROR_RANGE(thr, DUK_STR_JSONDEC_RECLIMIT); - DUK_WO_NORETURN(return;); } js_ctx->recursion_depth++; } @@ -35424,9 +34578,9 @@ /* If XUTF-8 decoding fails, treat the offending byte as a codepoint directly * and go forward one byte. This is of course very lossy, but allows some kind * of output to be produced even for internal strings which don't conform to - * XUTF-8. All standard ECMAScript strings are always CESU-8, so this behavior - * does not violate the ECMAScript specification. The behavior is applied to - * all modes, including ECMAScript standard JSON. Because the current XUTF-8 + * XUTF-8. All standard Ecmascript strings are always CESU-8, so this behavior + * does not violate the Ecmascript specification. The behavior is applied to + * all modes, including Ecmascript standard JSON. Because the current XUTF-8 * decoding is not very strict, this behavior only really affects initial bytes * and truncated codepoints. * @@ -35563,7 +34717,7 @@ /* Unlike in duk_hex_encode() 'dst' is not necessarily aligned by 2. * For platforms where unaligned accesses are not allowed, shift 'dst' - * ahead by 1 byte to get alignment and then duk_memmove() the result + * ahead by 1 byte to get alignment and then DUK_MEMMOVE() the result * in place. The faster encoding loop makes up the difference. * There's always space for one extra byte because a terminator always * follows the hex data and that's been accounted for by the caller. @@ -35596,7 +34750,7 @@ #if !defined(DUK_USE_UNALIGNED_ACCESSES_POSSIBLE) if (shift_dst) { q--; - duk_memmove((void *) dst, (const void *) (dst + 1), 2 * len_safe); + DUK_MEMMOVE((void *) dst, (const void *) (dst + 1), 2 * len_safe); DUK_ASSERT(dst + 2 * len_safe == q); } #endif @@ -35672,7 +34826,7 @@ #if defined(DUK_USE_JC) { DUK_ASSERT(js_ctx->flag_ext_compatible); - duk_memcpy((void *) q, (const void *) "{\"_buf\":\"", 9); /* len: 9 */ + DUK_MEMCPY((void *) q, (const void *) "{\"_buf\":\"", 9); /* len: 9 */ q += 9; q = duk__enc_buffer_data_hex(buf_data, buf_len, q); *q++ = DUK_ASC_DOUBLEQUOTE; @@ -35745,7 +34899,7 @@ DUK_ASSERT(js_ctx->flag_ext_custom || js_ctx->flag_ext_compatible); /* caller checks */ DUK_ASSERT(js_ctx->flag_ext_custom_or_compatible); - duk_memzero(buf, sizeof(buf)); + DUK_MEMZERO(buf, sizeof(buf)); /* The #if defined() clutter here needs to handle the three * cases: (1) JX+JC, (2) JX only, (3) JC only. @@ -35835,21 +34989,21 @@ p = DUK_BW_ENSURE_GETPTR(js_ctx->thr, &js_ctx->bw, need_bytes); p_start = p; - duk_memcpy((void *) p, (const void *) gap_data, (size_t) gap_len); + DUK_MEMCPY((void *) p, (const void *) gap_data, (size_t) gap_len); p += gap_len; avail_bytes = gap_len; DUK_ASSERT(need_bytes >= gap_len); need_bytes -= gap_len; while (need_bytes >= avail_bytes) { - duk_memcpy((void *) p, (const void *) p_start, (size_t) avail_bytes); + DUK_MEMCPY((void *) p, (const void *) p_start, (size_t) avail_bytes); p += avail_bytes; need_bytes -= avail_bytes; avail_bytes <<= 1; } DUK_ASSERT(need_bytes < avail_bytes); /* need_bytes may be zero */ - duk_memcpy((void *) p, (const void *) p_start, (size_t) need_bytes); + DUK_MEMCPY((void *) p, (const void *) p_start, (size_t) need_bytes); p += need_bytes; /*avail_bytes += need_bytes*/ @@ -35881,7 +35035,6 @@ if (DUK_UNLIKELY(js_ctx->visiting[i] == h_target)) { DUK_DD(DUK_DDPRINT("slow path loop detect")); DUK_ERROR_TYPE(thr, DUK_STR_CYCLIC_INPUT); - DUK_WO_NORETURN(return;); } } if (js_ctx->recursion_depth < DUK_JSON_ENC_LOOPARRAY) { @@ -35891,7 +35044,6 @@ duk_dup_top(thr); /* -> [ ... voidp voidp ] */ if (duk_has_prop(thr, js_ctx->idx_loop)) { DUK_ERROR_TYPE(thr, DUK_STR_CYCLIC_INPUT); - DUK_WO_NORETURN(return;); } duk_push_true(thr); /* -> [ ... voidp true ] */ duk_put_prop(thr, js_ctx->idx_loop); /* -> [ ... ] */ @@ -35903,7 +35055,6 @@ DUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit); if (js_ctx->recursion_depth >= js_ctx->recursion_limit) { DUK_ERROR_RANGE(thr, DUK_STR_JSONENC_RECLIMIT); - DUK_WO_NORETURN(return;); } js_ctx->recursion_depth++; @@ -36501,14 +35652,12 @@ if (js_ctx->recursion_depth >= js_ctx->recursion_limit) { DUK_DD(DUK_DDPRINT("fast path recursion limit")); DUK_ERROR_RANGE(js_ctx->thr, DUK_STR_JSONDEC_RECLIMIT); - DUK_WO_NORETURN(return 0;); } for (i = 0, n = (duk_uint_fast32_t) js_ctx->recursion_depth; i < n; i++) { if (DUK_UNLIKELY(js_ctx->visiting[i] == obj)) { DUK_DD(DUK_DDPRINT("fast path loop detect")); DUK_ERROR_TYPE(js_ctx->thr, DUK_STR_CYCLIC_INPUT); - DUK_WO_NORETURN(return 0;); } } @@ -36889,7 +36038,7 @@ /* Error message doesn't matter: the error is ignored anyway. */ DUK_DD(DUK_DDPRINT("aborting fast path")); DUK_ERROR_INTERNAL(js_ctx->thr); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } DUK_LOCAL duk_ret_t duk__json_stringify_fast(duk_hthread *thr, void *udata) { @@ -36938,7 +36087,7 @@ (unsigned long) flags, (long) duk_get_top(thr))); - duk_memzero(&js_ctx_alloc, sizeof(js_ctx_alloc)); + DUK_MEMZERO(&js_ctx_alloc, sizeof(js_ctx_alloc)); js_ctx->thr = thr; #if defined(DUK_USE_EXPLICIT_NULL_INIT) /* nothing now */ @@ -37048,7 +36197,7 @@ * Context init */ - duk_memzero(&js_ctx_alloc, sizeof(js_ctx_alloc)); + DUK_MEMZERO(&js_ctx_alloc, sizeof(js_ctx_alloc)); js_ctx->thr = thr; #if defined(DUK_USE_EXPLICIT_NULL_INIT) js_ctx->h_replacer = NULL; @@ -37446,7 +36595,7 @@ DUK_LOCAL double duk__fmin_fixed(double x, double y) { /* fmin() with args -0 and +0 is not guaranteed to return - * -0 as ECMAScript requires. + * -0 as Ecmascript requires. */ if (x == 0 && y == 0) { duk_double_union du1, du2; @@ -37473,7 +36622,7 @@ DUK_LOCAL double duk__fmax_fixed(double x, double y) { /* fmax() with args -0 and +0 is not guaranteed to return - * +0 as ECMAScript requires. + * +0 as Ecmascript requires. */ if (x == 0 && y == 0) { if (DUK_SIGNBIT(x) == 0 || DUK_SIGNBIT(y) == 0) { @@ -37936,7 +37085,6 @@ (DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_NUMBER)) { DUK_DDD(DUK_DDDPRINT("unacceptable this value: %!T", (duk_tval *) duk_get_tval(thr, -1))); DUK_ERROR_TYPE(thr, "number expected"); - DUK_WO_NORETURN(return 0.0;); } duk_get_prop_stridx_short(thr, -1, DUK_STRIDX_INT_VALUE); DUK_ASSERT(duk_is_number(thr, -1)); @@ -38043,11 +37191,8 @@ duk_small_int_t c; duk_small_uint_t n2s_flags; - /* In ES5.1 frac_digits is coerced first; in ES2015 the 'this number - * value' check is done first. - */ - d = duk__push_this_number_plain(thr); frac_digits = (duk_small_int_t) duk_to_int_check_range(thr, 0, 0, 20); + d = duk__push_this_number_plain(thr); c = (duk_small_int_t) DUK_FPCLASSIFY(d); if (c == DUK_FP_NAN || c == DUK_FP_INFINITE) { @@ -38150,45 +37295,9 @@ */ DUK_ASSERT_TOP(thr, 2); - duk_to_string(thr, -1); - return 1; -} - -/* - * ES2015 isFinite() etc - */ - -#if defined(DUK_USE_ES6) -DUK_INTERNAL duk_ret_t duk_bi_number_check_shared(duk_hthread *thr) { - duk_int_t magic; - duk_bool_t ret = 0; - - if (duk_is_number(thr, 0)) { - duk_double_t d; - - magic = duk_get_current_magic(thr); - d = duk_get_number(thr, 0); - - switch (magic) { - case 0: /* isFinite() */ - ret = duk_double_is_finite(d); - break; - case 1: /* isInteger() */ - ret = duk_double_is_integer(d); - break; - case 2: /* isNaN() */ - ret = duk_double_is_nan(d); - break; - default: /* isSafeInteger() */ - DUK_ASSERT(magic == 3); - ret = duk_double_is_safe_integer(d); - } - } - - duk_push_boolean(thr, ret); + duk_to_string(thr, -1); return 1; } -#endif /* DUK_USE_ES6 */ #endif /* DUK_USE_NUMBER_BUILTIN */ /* @@ -38200,9 +37309,12 @@ /* Needed even when Object built-in disabled. */ DUK_INTERNAL duk_ret_t duk_bi_object_prototype_to_string(duk_hthread *thr) { duk_tval *tv; - tv = DUK_HTHREAD_THIS_PTR(thr); - duk_push_class_string_tval(thr, tv, 0 /*avoid_side_effects*/); + /* XXX: This is not entirely correct anymore; in ES2015 the + * default lookup should use @@toStringTag to come up with + * e.g. [object Symbol]. + */ + duk_push_class_string_tval(thr, tv); return 1; } @@ -38707,7 +37819,7 @@ DUK_ASSERT(duk_get_hobject(thr, 2) != NULL); /* - * Validate and convert argument property descriptor (an ECMAScript + * Validate and convert argument property descriptor (an Ecmascript * object) into a set of defprop_flags and possibly property value, * getter, and/or setter values on the value stack. * @@ -38985,7 +38097,6 @@ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } duk_get_prototype(thr, -1); @@ -39110,37 +38221,37 @@ DUK_INTERNAL duk_ret_t duk_bi_promise_constructor(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_all(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_race(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_reject(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_resolve(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_catch(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_then(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } #endif /* DUK_USE_PROMISE_BUILTIN */ @@ -39174,7 +38285,6 @@ h = duk_get_hstring(thr, -1); if (h == NULL) { DUK_ERROR_TYPE_INVALID_TRAP_RESULT(thr); - DUK_WO_NORETURN(return;); } if (!(flags & DUK_ENUM_INCLUDE_NONENUMERABLE)) { @@ -39282,7 +38392,6 @@ if (nargs >= 3 && !duk_strict_equals(thr, 0, 2)) { /* XXX: [[Get]] receiver currently unsupported */ DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } /* [ target key receiver? ...? ] */ @@ -39326,7 +38435,6 @@ if (nargs >= 4 && !duk_strict_equals(thr, 0, 3)) { /* XXX: [[Set]] receiver currently unsupported */ DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } /* [ target key value receiver? ...? ] */ @@ -39460,7 +38568,7 @@ /* This must be generic in ES2015 and later. */ DUK_ASSERT_TOP(thr, 0); duk_push_this(thr); - duk_push_literal(thr, "/"); + duk_push_string(thr, "/"); duk_get_prop_stridx(thr, 0, DUK_STRIDX_SOURCE); duk_dup_m2(thr); /* another "/" */ duk_get_prop_stridx(thr, 0, DUK_STRIDX_FLAGS); @@ -39524,7 +38632,7 @@ if (magic != 16 /* .source */) { return 0; } - duk_push_literal(thr, "(?:)"); /* .source handled by switch-case */ + duk_push_string(thr, "(?:)"); /* .source handled by switch-case */ re_flags = 0; } else { DUK_DCERROR_TYPE_INVALID_ARGS(thr); @@ -39595,7 +38703,6 @@ if (duk_get_class_number(thr, idx) == DUK_HOBJECT_CLASS_REGEXP) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } h = duk_to_hstring(thr, idx); DUK_ASSERT(h != NULL); @@ -39642,14 +38749,14 @@ while (p <= p_end && p >= p_start) { t = *p; - /* For ECMAScript strings, this check can only match for + /* For Ecmascript strings, this check can only match for * initial UTF-8 bytes (not continuation bytes). For other * strings all bets are off. */ if ((t == firstbyte) && ((duk_size_t) (p_end - p) >= (duk_size_t) q_blen)) { - DUK_ASSERT(q_blen > 0); - if (duk_memcmp((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { + DUK_ASSERT(q_blen > 0); /* no issues with memcmp() zero size, even if broken */ + if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { return cpos; } } @@ -39831,37 +38938,13 @@ */ DUK_INTERNAL duk_ret_t duk_bi_string_prototype_char_at(duk_hthread *thr) { - duk_hstring *h; duk_int_t pos; /* XXX: faster implementation */ - h = duk_push_this_coercible_to_string(thr); - DUK_ASSERT(h != NULL); - + (void) duk_push_this_coercible_to_string(thr); pos = duk_to_int(thr, 0); - - if (sizeof(duk_size_t) >= sizeof(duk_uint_t)) { - /* Cast to duk_size_t works in this case: - * - If pos < 0, (duk_size_t) pos will always be - * >= max_charlen, and result will be the empty string - * (see duk_substring()). - * - If pos >= 0, pos + 1 cannot wrap. - */ - DUK_ASSERT((duk_size_t) DUK_INT_MIN >= DUK_HSTRING_MAX_BYTELEN); - DUK_ASSERT((duk_size_t) DUK_INT_MAX + 1U > (duk_size_t) DUK_INT_MAX); - duk_substring(thr, -1, (duk_size_t) pos, (duk_size_t) pos + 1U); - } else { - /* If size_t is smaller than int, explicit bounds checks - * are needed because an int may wrap multiple times. - */ - if (DUK_UNLIKELY(pos < 0 || (duk_uint_t) pos >= (duk_uint_t) DUK_HSTRING_GET_CHARLEN(h))) { - duk_push_hstring_empty(thr); - } else { - duk_substring(thr, -1, (duk_size_t) pos, (duk_size_t) pos + 1U); - } - } - + duk_substring(thr, -1, (duk_size_t) pos, (duk_size_t) (pos + 1)); return 1; } @@ -40251,7 +39334,7 @@ while (p <= p_end) { DUK_ASSERT(p + q_blen <= DUK_HSTRING_GET_DATA(h_input) + DUK_HSTRING_GET_BYTELEN(h_input)); - if (duk_memcmp((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { + if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { duk_dup_0(thr); h_match = duk_known_hstring(thr, -1); #if defined(DUK_USE_REGEXP_SUPPORT) @@ -40632,7 +39715,7 @@ while (p <= p_end) { DUK_ASSERT(p + q_blen <= DUK_HSTRING_GET_DATA(h_input) + DUK_HSTRING_GET_BYTELEN(h_input)); DUK_ASSERT(q_blen > 0); /* no issues with empty memcmp() */ - if (duk_memcmp((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { + if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { /* never an empty match, so step 13.c.iii can't be triggered */ goto found; } @@ -40945,14 +40028,12 @@ /* Temporary fixed buffer, later converted to string. */ buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, result_len); - DUK_ASSERT(buf != NULL); src = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input); - DUK_ASSERT(src != NULL); #if defined(DUK_USE_PREFER_SIZE) p = buf; while (count-- > 0) { - duk_memcpy((void *) p, (const void *) src, input_blen); /* copy size may be zero, but pointers are valid */ + DUK_MEMCPY((void *) p, (const void *) src, input_blen); /* copy size may be zero */ p += input_blen; } #else /* DUK_USE_PREFER_SIZE */ @@ -40969,12 +40050,12 @@ (long) result_len)); if (remain <= copy_size) { /* If result_len is zero, this case is taken and does - * a zero size copy (with valid pointers). + * a zero size copy. */ - duk_memcpy((void *) p, (const void *) src, remain); + DUK_MEMCPY((void *) p, (const void *) src, remain); break; } else { - duk_memcpy((void *) p, (const void *) src, copy_size); + DUK_MEMCPY((void *) p, (const void *) src, copy_size); p += copy_size; } @@ -41029,7 +40110,8 @@ h2_len = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h2); prefix_len = (h1_len <= h2_len ? h1_len : h2_len); - rc = (duk_small_int_t) duk_memcmp((const void *) DUK_HSTRING_GET_DATA(h1), + /* Zero size compare not an issue with DUK_MEMCMP. */ + rc = (duk_small_int_t) DUK_MEMCMP((const void *) DUK_HSTRING_GET_DATA(h1), (const void *) DUK_HSTRING_GET_DATA(h2), (size_t) prefix_len); @@ -41079,7 +40161,7 @@ if (duk_is_undefined(thr, 1)) { if (magic) { - p_cmp_start = p_cmp_start + DUK_HSTRING_GET_BYTELEN(h) - blen_search; + p_cmp_start += DUK_HSTRING_GET_BYTELEN(h) - blen_search; } else { /* p_cmp_start already OK */ } @@ -41110,7 +40192,7 @@ result = 0; if (p_cmp_start >= DUK_HSTRING_GET_DATA(h) && (duk_size_t) (p_cmp_start - (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h)) + blen_search <= DUK_HSTRING_GET_BYTELEN(h)) { - if (duk_memcmp((const void *) p_cmp_start, + if (DUK_MEMCMP((const void *) p_cmp_start, (const void *) DUK_HSTRING_GET_DATA(h_search), (size_t) blen_search) == 0) { result = 1; @@ -41184,10 +40266,9 @@ * +1 0xff after unique suffix for symbols with undefined description */ buf = (duk_uint8_t *) duk_push_fixed_buffer(thr, 1 + len + 1 + 17 + 1); - DUK_ASSERT(buf != NULL); p = buf + 1; DUK_ASSERT(desc != NULL || len == 0); /* may be NULL if len is 0 */ - duk_memcpy_unsafe((void *) p, (const void *) desc, len); + DUK_MEMCPY((void *) p, (const void *) desc, len); p += len; if (magic == 0) { /* Symbol(): create unique symbol. Use two 32-bit values @@ -41358,7 +40439,7 @@ * * The thread must be in resumable state, either (a) new thread which hasn't * yet started, or (b) a thread which has previously yielded. This method - * must be called from an ECMAScript function. + * must be called from an Ecmascript function. * * Args: * - thread @@ -41384,9 +40465,8 @@ DUK_ASSERT(thr->heap->curr_thread == thr); thr_resume = duk_require_hthread(thr, 0); - DUK_ASSERT(duk_get_top(thr) == 3); - is_error = (duk_small_uint_t) duk_to_boolean_top_pop(thr); - DUK_ASSERT(duk_get_top(thr) == 2); + is_error = (duk_small_uint_t) duk_to_boolean(thr, 2); + duk_set_top(thr, 2); /* [ thread value ] */ @@ -41406,7 +40486,7 @@ caller_func = DUK_ACT_GET_FUNC(thr->callstack_curr->parent); if (!DUK_HOBJECT_IS_COMPFUNC(caller_func)) { - DUK_DD(DUK_DDPRINT("resume state invalid: caller must be ECMAScript code")); + DUK_DD(DUK_DDPRINT("resume state invalid: caller must be Ecmascript code")); goto state_error; } @@ -41434,7 +40514,7 @@ DUK_ASSERT(thr_resume->state == DUK_HTHREAD_STATE_INACTIVE); - /* The initial function must be an ECMAScript function (but + /* The initial function must be an Ecmascript function (but * can be bound). We must make sure of that before we longjmp * because an error in the RESUME handler call processing will * not be handled very cleanly. @@ -41513,7 +40593,7 @@ * The thread must be in yieldable state: it must have a resumer, and there * must not be any yield-preventing calls (native calls and constructor calls, * currently) in the thread's call stack (otherwise a resume would not be - * possible later). This method must be called from an ECMAScript function. + * possible later). This method must be called from an Ecmascript function. * * Args: * - value @@ -41534,9 +40614,8 @@ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); DUK_ASSERT(thr->heap->curr_thread == thr); - DUK_ASSERT(duk_get_top(thr) == 2); - is_error = (duk_small_uint_t) duk_to_boolean_top_pop(thr); - DUK_ASSERT(duk_get_top(thr) == 1); + is_error = (duk_small_uint_t) duk_to_boolean(thr, 1); + duk_set_top(thr, 1); /* [ value ] */ @@ -41562,7 +40641,7 @@ caller_func = DUK_ACT_GET_FUNC(thr->callstack_curr->parent); if (!DUK_HOBJECT_IS_COMPFUNC(caller_func)) { - DUK_DD(DUK_DDPRINT("yield state invalid: caller must be ECMAScript code")); + DUK_DD(DUK_DDPRINT("yield state invalid: caller must be Ecmascript code")); goto state_error; } @@ -41659,7 +40738,7 @@ } else { copylen = length; } - duk_memcpy_unsafe(fb->buffer + fb->offset, buffer, copylen); + DUK_MEMCPY(fb->buffer + fb->offset, buffer, copylen); fb->offset += copylen; } @@ -41745,7 +40824,7 @@ * (excluding the null terminator). If retval == buffer size, * output was truncated (except for corner cases). * - * * Output format is intentionally different from ECMAScript + * * Output format is intentionally different from Ecmascript * formatting requirements, as formatting here serves debugging * of internals. * @@ -42531,7 +41610,7 @@ const char *p_end = p + DUK_STRLEN(format); duk_int_t retval; - duk_memzero(&fb, sizeof(fb)); + DUK_MEMZERO(&fb, sizeof(fb)); fb.buffer = (duk_uint8_t *) str; fb.length = size; fb.offset = 0; @@ -42556,7 +41635,7 @@ * understand. See man 3 printf. */ - duk_memzero(&st, sizeof(st)); + DUK_MEMZERO(&st, sizeof(st)); st.fb = &fb; st.depth = 0; st.depth_limit = 1; @@ -42623,8 +41702,8 @@ /* format is too large, abort */ goto format_error; } - duk_memzero(fmtbuf, sizeof(fmtbuf)); - duk_memcpy(fmtbuf, p_begfmt, fmtlen); + DUK_MEMZERO(fmtbuf, sizeof(fmtbuf)); + DUK_MEMCPY(fmtbuf, p_begfmt, fmtlen); /* assume exactly 1 arg, which is why '*' is forbidden; arg size still * depends on type though. @@ -42729,8 +41808,7 @@ duk_uint8_t *p = (duk_uint8_t *) buf; duk_uint8_t *p_end = (duk_uint8_t *) (buf + buf_size - 1); - DUK_ASSERT(buf != NULL); - duk_memzero(buf, buf_size); + DUK_MEMZERO(buf, buf_size); for (i = 0; i < fptr_size; i++) { duk_int_t left = (duk_int_t) (p_end - p); @@ -43068,7 +42146,6 @@ DUK_ASSERT(thr != NULL); heap = thr->heap; DUK_ASSERT(heap != NULL); - DUK_ASSERT(data != NULL); if (heap->dbg_read_cb == NULL) { DUK_D(DUK_DPRINT("attempt to read %ld bytes in detached state, return zero data", (long) length)); @@ -43106,7 +42183,7 @@ return; fail: - duk_memzero((void *) data, (size_t) length); + DUK_MEMZERO((void *) data, (size_t) length); } DUK_INTERNAL duk_uint8_t duk_debug_read_byte(duk_hthread *thr) { @@ -43719,7 +42796,7 @@ (unsigned int) du2.uc[4], (unsigned int) du2.uc[5], (unsigned int) du2.uc[6], (unsigned int) du2.uc[7])); - if (duk_memcmp((const void *) du1.uc, (const void *) du2.uc, sizeof(du1.uc)) == 0) { + if (DUK_MEMCMP((const void *) du1.uc, (const void *) du2.uc, sizeof(du1.uc)) == 0) { duk_debug_write_int(thr, i32); } else { DUK_DBLUNION_DOUBLE_HTON(&du1); @@ -43828,9 +42905,9 @@ duk_debug_write_int(thr, 0); } else { duk_push_tval(thr, &act->tv_func); - duk_get_prop_literal(thr, -1, "fileName"); + duk_get_prop_string(thr, -1, "fileName"); duk__debug_write_hstring_safe_top(thr); - duk_get_prop_literal(thr, -2, "name"); + duk_get_prop_string(thr, -2, "name"); duk__debug_write_hstring_safe_top(thr); duk_pop_3(thr); /* Report next pc/line to be executed. */ @@ -43875,7 +42952,7 @@ act = thr->callstack_curr; if (act != NULL) { duk_push_tval(thr, &act->tv_func); - duk_get_prop_literal(thr, -1, "fileName"); + duk_get_prop_string(thr, -1, "fileName"); duk__debug_write_hstring_safe_top(thr); pc = (duk_uint32_t) duk_hthread_get_act_prev_pc(thr, act); duk_debug_write_uint(thr, (duk_uint32_t) duk_hobject_pc2line_query(thr, -2, pc)); @@ -44352,7 +43429,7 @@ fun = DUK_ACT_GET_FUNC(act); if (fun != NULL && DUK_HOBJECT_IS_COMPFUNC(fun)) { /* Direct eval requires that there's a current - * activation and it is an ECMAScript function. + * activation and it is an Ecmascript function. * When Eval is executed from e.g. cooperate API * call we'll need to do an indirect eval instead. */ @@ -45018,7 +44095,7 @@ if (DUK_HOBJECT_IS_BOUNDFUNC(h_obj)) { duk_hboundfunc *h_bfun; - h_bfun = (duk_hboundfunc *) (void *) h_obj; + h_bfun = (duk_hboundfunc *) h_obj; duk__debug_getinfo_flags_key(thr, "target"); duk_debug_write_tval(thr, &h_bfun->target); @@ -45495,7 +44572,7 @@ fun = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act); /* Short circuit if is safe: if act->curr_pc != NULL, 'fun' is - * guaranteed to be a non-NULL ECMAScript function. + * guaranteed to be a non-NULL Ecmascript function. */ DUK_ASSERT(act->curr_pc == NULL || (fun != NULL && DUK_HOBJECT_IS_COMPFUNC((duk_hobject *) fun))); @@ -45591,10 +44668,11 @@ DUK_ASSERT(h != NULL); move_size = sizeof(duk_breakpoint) * (heap->dbg_breakpoint_count - breakpoint_index - 1); - duk_memmove((void *) b, - (const void *) (b + 1), - (size_t) move_size); - + if (move_size > 0) { + DUK_MEMMOVE((void *) b, + (const void *) (b + 1), + (size_t) move_size); + } heap->dbg_breakpoint_count--; heap->dbg_breakpoints_active[0] = (duk_breakpoint *) NULL; @@ -45680,7 +44758,7 @@ * * Error augmentation may throw an internal error (e.g. alloc error). * - * ECMAScript allows throwing any values, so all values cannot be + * Ecmascript allows throwing any values, so all values cannot be * augmented. Currently, the built-in augmentation at error creation * only augments error values which are Error instances (= have the * built-in Error.prototype in their prototype chain) and are also @@ -46020,6 +45098,7 @@ DUK_UNREF(pc); DUK_ASSERT_DISABLE(pc >= 0); /* unsigned */ DUK_ASSERT((duk_double_t) pc < DUK_DOUBLE_2TO32); /* assume PC is at most 32 bits and non-negative */ + act = NULL; /* invalidated by pushes, so get out of the way */ duk_push_hobject(thr, func); @@ -46234,15 +45313,12 @@ /* #include duk_internal.h -> already included */ #if defined(DUK_USE_PREFER_SIZE) -DUK_NORETURN(DUK_LOCAL_DECL void duk__uncaught_minimal(duk_hthread *thr)); DUK_LOCAL void duk__uncaught_minimal(duk_hthread *thr) { (void) duk_fatal(thr, "uncaught error"); - DUK_WO_NORETURN(return;); } #endif #if 0 -DUK_NORETURN(DUK_LOCAL_DECL void duk__uncaught_readable(duk_hthread *thr)); DUK_LOCAL void duk__uncaught_readable(duk_hthread *thr) { const char *summary; char buf[DUK_USE_FATAL_MAXLEN]; @@ -46251,12 +45327,10 @@ DUK_SNPRINTF(buf, sizeof(buf), "uncaught: %s", summary); buf[sizeof(buf) - 1] = (char) 0; (void) duk_fatal(thr, (const char *) buf); - DUK_WO_NORETURN(return;); } #endif #if !defined(DUK_USE_PREFER_SIZE) -DUK_NORETURN(DUK_LOCAL_DECL void duk__uncaught_error_aware(duk_hthread *thr)); DUK_LOCAL void duk__uncaught_error_aware(duk_hthread *thr) { const char *summary; char buf[DUK_USE_FATAL_MAXLEN]; @@ -46266,7 +45340,6 @@ DUK_SNPRINTF(buf, sizeof(buf), "uncaught: %s", summary); buf[sizeof(buf) - 1] = (char) 0; (void) duk_fatal(thr, (const char *) buf); - DUK_WO_NORETURN(return;); } #endif @@ -46304,9 +45377,14 @@ DUK_DD(DUK_DDPRINT("about to longjmp, pf_prevent_count=%ld", (long) thr->heap->pf_prevent_count)); +#if !defined(DUK_USE_CPP_EXCEPTIONS) /* If we don't have a jmpbuf_ptr, there is little we can do except * cause a fatal error. The caller's expectation is that we never * return. + * + * With C++ exceptions we now just propagate an uncaught error + * instead of invoking the fatal error handler. Because there's + * a dummy jmpbuf for C++ exceptions now, this could be changed. */ if (!thr->heap->lj.jmpbuf_ptr) { DUK_D(DUK_DPRINT("uncaught error: type=%d iserror=%d value1=%!T value2=%!T", @@ -46320,12 +45398,16 @@ #endif DUK_UNREACHABLE(); } +#endif /* DUK_USE_CPP_EXCEPTIONS */ #if defined(DUK_USE_CPP_EXCEPTIONS) - throw duk_internal_exception(); /* dummy */ -#else + { + duk_internal_exception exc; /* dummy */ + throw exc; + } +#else /* DUK_USE_CPP_EXCEPTIONS */ DUK_LONGJMP(thr->heap->lj.jmpbuf_ptr->jb); -#endif +#endif /* DUK_USE_CPP_EXCEPTIONS */ DUK_UNREACHABLE(); } @@ -46504,10 +45586,10 @@ DUK_ASSERT_LJSTATE_SET(heap); } /* - * Create and throw an ECMAScript error object based on a code and a message. + * Create and throw an Ecmascript error object based on a code and a message. * - * Used when we throw errors internally. ECMAScript generated error objects - * are created by ECMAScript code, and the throwing is handled by the bytecode + * Used when we throw errors internally. Ecmascript generated error objects + * are created by Ecmascript code, and the throwing is handled by the bytecode * executor. */ @@ -46663,7 +45745,7 @@ */ duk_error_raw(thr, -rc, NULL, 0, "error (rc %ld)", (long) rc); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); } /* * duk_hbuffer allocation and freeing. @@ -46714,10 +45796,10 @@ /* zero everything unless requested not to do so */ #if defined(DUK_USE_ZERO_BUFFER_DATA) - duk_memzero((void *) res, + DUK_MEMZERO((void *) res, (flags & DUK_BUF_FLAG_NOZERO) ? header_size : alloc_size); #else - duk_memzero((void *) res, header_size); + DUK_MEMZERO((void *) res, header_size); #endif if (flags & DUK_BUF_FLAG_EXTERNAL) { @@ -46764,7 +45846,7 @@ DUK_ASSERT(DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap, h) == NULL); } } else { - *out_bufdata = (void *) ((duk_hbuffer_fixed *) (void *) res + 1); + *out_bufdata = (void *) ((duk_hbuffer_fixed *) res + 1); } DUK_HBUFFER_SET_SIZE(res, size); @@ -46823,7 +45905,6 @@ if (new_size > DUK_HBUFFER_MAX_BYTELEN) { DUK_ERROR_RANGE(thr, "buffer too long"); - DUK_WO_NORETURN(return;); } /* @@ -46852,7 +45933,7 @@ if (new_size > prev_size) { DUK_ASSERT(new_size - prev_size > 0); #if defined(DUK_USE_ZERO_BUFFER_DATA) - duk_memzero((void *) ((char *) res + prev_size), + DUK_MEMZERO((void *) ((char *) res + prev_size), (duk_size_t) (new_size - prev_size)); #endif } @@ -46861,7 +45942,6 @@ DUK_HBUFFER_DYNAMIC_SET_DATA_PTR(thr->heap, buf, res); } else { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return;); } DUK_ASSERT(res != NULL || new_size == 0); @@ -46963,7 +46043,7 @@ * functions in the callstack. */ } else if (DUK_HOBJECT_IS_BOUNDFUNC(h)) { - duk_hboundfunc *f = (duk_hboundfunc *) (void *) h; + duk_hboundfunc *f = (duk_hboundfunc *) h; DUK_FREE(heap, f->args); } @@ -47361,7 +46441,7 @@ duk_bitdecoder_ctx *bd = &bd_ctx; /* convenience */ duk_small_uint_t i; - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); bd->data = (const duk_uint8_t *) duk_strings_data; bd->length = (duk_size_t) DUK_STRDATA_DATA_LENGTH; @@ -47582,8 +46662,7 @@ DUK__DUMPSZ(duk_heap); DUK__DUMPSZ(duk_activation); DUK__DUMPSZ(duk_catcher); - DUK__DUMPSZ(duk_strcache_entry); - DUK__DUMPSZ(duk_litcache_entry); + DUK__DUMPSZ(duk_strcache); DUK__DUMPSZ(duk_ljstate); DUK__DUMPSZ(duk_fixedbuffer); DUK__DUMPSZ(duk_bitdecoder_ctx); @@ -47792,7 +46871,7 @@ * Zero the struct, and start initializing roughly in order */ - duk_memzero(res, sizeof(*res)); + DUK_MEMZERO(res, sizeof(*res)); #if defined(DUK_USE_ASSERTIONS) res->heap_initializing = 1; #endif @@ -47877,7 +46956,7 @@ /* XXX: use the pointer as a seed for now: mix in time at least */ - /* The casts through duk_uintptr_t is to avoid the following GCC warning: + /* The casts through duk_intptr_t is to avoid the following GCC warning: * * warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] * @@ -47888,7 +46967,7 @@ DUK_D(DUK_DPRINT("using rom strings, force heap hash_seed to fixed value 0x%08lx", (long) DUK__FIXED_HASH_SEED)); res->hash_seed = (duk_uint32_t) DUK__FIXED_HASH_SEED; #else /* DUK_USE_ROM_STRINGS */ - res->hash_seed = (duk_uint32_t) (duk_uintptr_t) res; + res->hash_seed = (duk_uint32_t) (duk_intptr_t) res; #if !defined(DUK_USE_STRHASH_DENSE) res->hash_seed ^= 5381; /* Bernstein hash init value is normally 5381; XOR it in in case pointer low bits are 0 */ #endif @@ -47928,17 +47007,17 @@ #if defined(DUK_USE_STRTAB_PTRCOMP) /* zero assumption */ - duk_memzero(res->strtable16, sizeof(duk_uint16_t) * st_initsize); + DUK_MEMZERO(res->strtable16, sizeof(duk_uint16_t) * st_initsize); #else #if defined(DUK_USE_EXPLICIT_NULL_INIT) { - duk_uint32_t i; + duk_small_uint_t i; for (i = 0; i < st_initsize; i++) { res->strtable[i] = NULL; } } #else - duk_memzero(res->strtable, sizeof(duk_hstring *) * st_initsize); + DUK_MEMZERO(res->strtable, sizeof(duk_hstring *) * st_initsize); #endif /* DUK_USE_EXPLICIT_NULL_INIT */ #endif /* DUK_USE_STRTAB_PTRCOMP */ @@ -47948,30 +47027,13 @@ #if defined(DUK_USE_EXPLICIT_NULL_INIT) { - duk_uint_t i; + duk_small_uint_t i; for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { res->strcache[i].h = NULL; } } #endif - /* - * Init litcache - */ -#if defined(DUK_USE_LITCACHE_SIZE) - DUK_ASSERT(DUK_USE_LITCACHE_SIZE > 0); - DUK_ASSERT(DUK_IS_POWER_OF_TWO((duk_uint_t) DUK_USE_LITCACHE_SIZE)); -#if defined(DUK_USE_EXPLICIT_NULL_INIT) - { - duk_uint_t i; - for (i = 0; i < DUK_USE_LITCACHE_SIZE; i++) { - res->litcache[i].addr = NULL; - res->litcache[i].h = NULL; - } - } -#endif -#endif /* DUK_USE_LITCACHE_SIZE */ - /* XXX: error handling is incomplete. It would be cleanest if * there was a setjmp catchpoint, so that all init code could * freely throw errors. If that were the case, the return code @@ -48043,7 +47105,7 @@ { duk_uint64_t tmp_u64; tmp_u64 = 0; - duk_memcpy((void *) &tmp_u64, + DUK_MEMCPY((void *) &tmp_u64, (const void *) &res, (size_t) (sizeof(void *) >= sizeof(duk_uint64_t) ? sizeof(duk_uint64_t) : sizeof(void *))); res->rnd_state[1] ^= tmp_u64; @@ -48798,7 +47860,7 @@ duk__mark_heaphdr(heap, (duk_heaphdr *) b->buf_prop); #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ } else if (DUK_HOBJECT_IS_BOUNDFUNC(h)) { - duk_hboundfunc *f = (duk_hboundfunc *) (void *) h; + duk_hboundfunc *f = (duk_hboundfunc *) h; DUK_ASSERT_HBOUNDFUNC_VALID(f); duk__mark_tval(heap, &f->target); duk__mark_tval(heap, &f->this_binding); @@ -49272,8 +48334,7 @@ duk_hstring *next; next = h->hdr.h_next; - if (DUK_HEAPHDR_HAS_REACHABLE((duk_heaphdr *) h)) - { + if (DUK_HEAPHDR_HAS_REACHABLE((duk_heaphdr *) h)) { DUK_HEAPHDR_CLEAR_REACHABLE((duk_heaphdr *) h); count_keep++; prev = h; @@ -49282,26 +48343,13 @@ count_free++; #endif - /* For pinned strings the refcount has been - * bumped. We could unbump it here before - * freeing, but that's actually not necessary - * except for assertions. - */ -#if 0 - if (DUK_HSTRING_HAS_PINNED_LITERAL(h)) { - DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) > 0U); - DUK_HSTRING_DECREF_NORZ(heap->heap_thread, h); - DUK_HSTRING_CLEAR_PINNED_LITERAL(h); - } -#endif #if defined(DUK_USE_REFERENCE_COUNTING) /* Non-zero refcounts should not happen for unreachable strings, * because we refcount finalize all unreachable objects which * should have decreased unreachable string refcounts to zero - * (even for cycles). However, pinned strings have a +1 bump. + * (even for cycles). */ - DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) == - DUK_HSTRING_HAS_PINNED_LITERAL(h) ? 1U : 0U); + DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) == 0); #endif /* Deal with weak references first. */ @@ -49505,26 +48553,6 @@ } /* - * Litcache helpers. - */ - -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_LOCAL void duk__wipe_litcache(duk_heap *heap) { - duk_uint_t i; - duk_litcache_entry *e; - - e = heap->litcache; - for (i = 0; i < DUK_USE_LITCACHE_SIZE; i++) { - e->addr = NULL; - /* e->h does not need to be invalidated: when e->addr is - * NULL, e->h is considered garbage. - */ - e++; - } -} -#endif /* DUK_USE_LITCACHE_SIZE */ - -/* * Object compaction. * * Compaction is assumed to never throw an error. @@ -49708,7 +48736,6 @@ DUK_LOCAL void duk__check_refcount_heaphdr(duk_heaphdr *hdr) { duk_bool_t count_ok; - duk_size_t expect_refc; /* The refcount check only makes sense for reachable objects on * heap_allocated or string table, after the sweep phase. Prior to @@ -49725,11 +48752,7 @@ */ DUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY(hdr)); - expect_refc = hdr->h_assert_refcount; - if (DUK_HEAPHDR_IS_STRING(hdr) && DUK_HSTRING_HAS_PINNED_LITERAL((duk_hstring *) hdr)) { - expect_refc++; - } - count_ok = ((duk_size_t) DUK_HEAPHDR_GET_REFCOUNT(hdr) == expect_refc); + count_ok = ((duk_size_t) DUK_HEAPHDR_GET_REFCOUNT(hdr) == hdr->h_assert_refcount); if (!count_ok) { DUK_D(DUK_DPRINT("refcount mismatch for: %p: header=%ld counted=%ld --> %!iO", (void *) hdr, (long) DUK_HEAPHDR_GET_REFCOUNT(hdr), @@ -49766,22 +48789,6 @@ } } #endif /* DUK_USE_REFERENCE_COUNTING */ - -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_LOCAL void duk__assert_litcache_nulls(duk_heap *heap) { - duk_uint_t i; - duk_litcache_entry *e; - - e = heap->litcache; - for (i = 0; i < DUK_USE_LITCACHE_SIZE; i++) { - /* Entry addresses were NULLed before mark-and-sweep, check - * that they're still NULL afterwards to ensure no pointers - * were recorded through any side effects. - */ - DUK_ASSERT(e->addr == NULL); - } -} -#endif /* DUK_USE_LITCACHE_SIZE */ #endif /* DUK_USE_ASSERTIONS */ /* @@ -49802,13 +48809,10 @@ DUK_D(DUK_DPRINT("stats mark-and-sweep: try_count=%ld, skip_count=%ld, emergency_count=%ld", (long) heap->stats_ms_try_count, (long) heap->stats_ms_skip_count, (long) heap->stats_ms_emergency_count)); - DUK_D(DUK_DPRINT("stats stringtable: intern_hit=%ld, intern_miss=%ld, " - "resize_check=%ld, resize_grow=%ld, resize_shrink=%ld, " - "litcache_hit=%ld, litcache_miss=%ld, litcache_pin=%ld", + DUK_D(DUK_DPRINT("stats stringtable: intern_hit=%ld, intern_miss=%ld, resize_check=%ld, resize_grow=%ld, resize_shrink=%ld", (long) heap->stats_strtab_intern_hit, (long) heap->stats_strtab_intern_miss, (long) heap->stats_strtab_resize_check, (long) heap->stats_strtab_resize_grow, - (long) heap->stats_strtab_resize_shrink, (long) heap->stats_strtab_litcache_hit, - (long) heap->stats_strtab_litcache_miss, (long) heap->stats_strtab_litcache_pin)); + (long) heap->stats_strtab_resize_shrink)); DUK_D(DUK_DPRINT("stats object: realloc_props=%ld, abandon_array=%ld", (long) heap->stats_object_realloc_props, (long) heap->stats_object_abandon_array)); DUK_D(DUK_DPRINT("stats getownpropdesc: count=%ld, hit=%ld, miss=%ld", @@ -49949,9 +48953,6 @@ #if defined(DUK_USE_ASSERTIONS) && defined(DUK_USE_REFERENCE_COUNTING) duk__clear_assert_refcounts(heap); #endif -#if defined(DUK_USE_LITCACHE_SIZE) - duk__wipe_litcache(heap); -#endif duk__mark_roots_heap(heap); /* Mark main reachability roots. */ #if defined(DUK_USE_REFERENCE_COUNTING) DUK_ASSERT(heap->refzero_list == NULL); /* Always handled to completion inline in DECREF. */ @@ -50057,9 +49058,6 @@ */ duk__assert_valid_refcounts(heap); #endif /* DUK_USE_REFERENCE_COUNTING */ -#if defined(DUK_USE_LITCACHE_SIZE) - duk__assert_litcache_nulls(heap); -#endif /* DUK_USE_LITCACHE_SIZE */ #endif /* DUK_USE_ASSERTIONS */ /* @@ -50249,7 +49247,8 @@ res = DUK_ALLOC(heap, size); if (DUK_LIKELY(res != NULL)) { - duk_memzero(res, size); + /* assume memset with zero size is OK */ + DUK_MEMZERO(res, size); } return res; } @@ -50263,7 +49262,7 @@ return res; } DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; } DUK_INTERNAL void *duk_heap_mem_alloc_checked_zeroed(duk_hthread *thr, duk_size_t size) { @@ -50275,7 +49274,7 @@ return res; } DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; } /* @@ -50838,7 +49837,7 @@ DUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, (duk_hobject *) b->buf_prop); #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ } else if (DUK_HOBJECT_IS_BOUNDFUNC(h)) { - duk_hboundfunc *f = (duk_hboundfunc *) (void *) h; + duk_hboundfunc *f = (duk_hboundfunc *) h; DUK_ASSERT_HBOUNDFUNC_VALID(f); DUK_TVAL_DECREF_NORZ(thr, &f->target); DUK_TVAL_DECREF_NORZ(thr, &f->this_binding); @@ -51528,9 +50527,9 @@ */ DUK_INTERNAL void duk_heap_strcache_string_remove(duk_heap *heap, duk_hstring *h) { - duk_uint_t i; + duk_small_int_t i; for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { - duk_strcache_entry *c = heap->strcache + 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)); @@ -51602,9 +50601,9 @@ 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_entry *sce; + duk_strcache *sce; duk_uint_fast32_t byte_offset; - duk_uint_t i; + duk_small_int_t i; duk_bool_t use_cache; duk_uint_fast32_t dist_start, dist_end, dist_sce; duk_uint_fast32_t char_length; @@ -51655,14 +50654,14 @@ #if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2) DUK_DDD(DUK_DDDPRINT("stringcache before char2byte (using cache):")); for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { - duk_strcache_entry *c = heap->strcache + 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_entry *c = heap->strcache + i; + duk_strcache *c = heap->strcache + i; if (c->h == h) { sce = c; @@ -51791,10 +50790,10 @@ * C <- sce ==> B * D D */ - duk_strcache_entry tmp; + duk_strcache tmp; tmp = *sce; - duk_memmove((void *) (&heap->strcache[1]), + DUK_MEMMOVE((void *) (&heap->strcache[1]), (const void *) (&heap->strcache[0]), (size_t) (((char *) sce) - ((char *) &heap->strcache[0]))); heap->strcache[0] = tmp; @@ -51804,7 +50803,7 @@ #if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2) DUK_DDD(DUK_DDDPRINT("stringcache after char2byte (using cache):")); for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { - duk_strcache_entry *c = heap->strcache + 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)); } @@ -51815,7 +50814,7 @@ scan_error: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + return 0; } /* * Heap string table handling, string interning. @@ -51873,7 +50872,7 @@ return; } - duk_memzero((void *) count_len, sizeof(count_len)); + DUK_MEMZERO((void *) count_len, sizeof(count_len)); for (i = 0; i < heap->st_size; i++) { h = DUK__HEAPPTR_DEC16(heap, strtable[i]); count_chain = 0; @@ -51985,7 +50984,7 @@ if (DUK_UNLIKELY(res == NULL)) { goto alloc_error; } - duk_memzero(res, sizeof(duk_hstring_external)); + DUK_MEMZERO(res, sizeof(duk_hstring_external)); #if defined(DUK_USE_EXPLICIT_NULL_INIT) DUK_HEAPHDR_STRING_INIT_NULLS(&res->hdr); #endif @@ -52005,14 +51004,14 @@ if (DUK_UNLIKELY(res == NULL)) { goto alloc_error; } - duk_memzero(res, sizeof(duk_hstring)); + 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_tmp = (duk_uint8_t *) (res + 1); - duk_memcpy(data_tmp, str, blen); + DUK_MEMCPY(data_tmp, str, blen); data_tmp[blen] = (duk_uint8_t) 0; data = (const duk_uint8_t *) data_tmp; } @@ -52505,12 +51504,11 @@ } lookup_hash &= 0xff; - curr = (duk_hstring *) DUK_LOSE_CONST(duk_rom_strings_lookup[lookup_hash]); + curr = DUK_LOSE_CONST(duk_rom_strings_lookup[lookup_hash]); while (curr != NULL) { - /* Unsafe memcmp() because for zero blen, str may be NULL. */ if (strhash == DUK_HSTRING_GET_HASH(curr) && blen == DUK_HSTRING_GET_BYTELEN(curr) && - duk_memcmp_unsafe((const void *) str, (const void *) DUK_HSTRING_GET_DATA(curr), blen) == 0) { + DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(curr), blen) == 0) { DUK_DDD(DUK_DDDPRINT("intern check: rom string: %!O, computed hash 0x%08lx, rom hash 0x%08lx", curr, (unsigned long) strhash, (unsigned long) DUK_HSTRING_GET_HASH(curr))); return curr; @@ -52530,7 +51528,6 @@ /* Preliminaries. */ - /* XXX: maybe just require 'str != NULL' even for zero size? */ DUK_ASSERT(heap != NULL); DUK_ASSERT(blen == 0 || str != NULL); DUK_ASSERT(blen <= DUK_HSTRING_MAX_BYTELEN); /* Caller is responsible for ensuring this. */ @@ -52549,7 +51546,7 @@ while (h != NULL) { if (DUK_HSTRING_GET_HASH(h) == strhash && DUK_HSTRING_GET_BYTELEN(h) == blen && - duk_memcmp_unsafe((const void *) str, (const void *) DUK_HSTRING_GET_DATA(h), (size_t) blen) == 0) { + DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(h), (size_t) blen) == 0) { /* Found existing entry. */ DUK_STATS_INC(heap, stats_strtab_intern_hit); return h; @@ -52622,67 +51619,10 @@ res = duk_heap_strtable_intern(thr->heap, str, blen); if (DUK_UNLIKELY(res == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } return res; } -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_LOCAL duk_uint_t duk__strtable_litcache_key(const duk_uint8_t *str, duk_uint32_t blen) { - duk_uintptr_t key; - - DUK_ASSERT(DUK_USE_LITCACHE_SIZE > 0); - DUK_ASSERT(DUK_IS_POWER_OF_TWO((duk_uint_t) DUK_USE_LITCACHE_SIZE)); - - key = (duk_uintptr_t) blen ^ (duk_uintptr_t) str; - key &= (duk_uintptr_t) (DUK_USE_LITCACHE_SIZE - 1); /* Assumes size is power of 2. */ - /* Due to masking, cast is in 32-bit range. */ - DUK_ASSERT(key <= DUK_UINT_MAX); - return (duk_uint_t) key; -} - -DUK_INTERNAL duk_hstring *duk_heap_strtable_intern_literal_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t blen) { - duk_uint_t key; - duk_litcache_entry *ent; - duk_hstring *h; - - /* Fast path check: literal exists in literal cache. */ - key = duk__strtable_litcache_key(str, blen); - ent = thr->heap->litcache + key; - if (ent->addr == str) { - DUK_DD(DUK_DDPRINT("intern check for cached, pinned literal: str=%p, blen=%ld -> duk_hstring %!O", - (const void *) str, (long) blen, (duk_heaphdr *) ent->h)); - DUK_ASSERT(ent->h != NULL); - DUK_ASSERT(DUK_HSTRING_HAS_PINNED_LITERAL(ent->h)); - DUK_STATS_INC(thr->heap, stats_strtab_litcache_hit); - return ent->h; - } - - /* Intern and update (overwrite) cache entry. */ - h = duk_heap_strtable_intern_checked(thr, str, blen); - ent->addr = str; - ent->h = h; - DUK_STATS_INC(thr->heap, stats_strtab_litcache_miss); - - /* Pin the duk_hstring until the next mark-and-sweep. This means - * litcache entries don't need to be invalidated until the next - * mark-and-sweep as their target duk_hstring is not freed before - * the mark-and-sweep happens. The pin remains even if the literal - * cache entry is overwritten, and is still useful to avoid string - * table traffic. - */ - if (!DUK_HSTRING_HAS_PINNED_LITERAL(h)) { - DUK_DD(DUK_DDPRINT("pin duk_hstring because it is a literal: %!O", (duk_heaphdr *) h)); - DUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) h)); - DUK_HSTRING_INCREF(thr, h); - DUK_HSTRING_SET_PINNED_LITERAL(h); - DUK_STATS_INC(thr->heap, stats_strtab_litcache_pin); - } - - return h; -} -#endif /* DUK_USE_LITCACHE_SIZE */ - DUK_INTERNAL duk_hstring *duk_heap_strtable_intern_u32_checked(duk_hthread *thr, duk_uint32_t val) { duk_hstring *res; @@ -52692,7 +51632,6 @@ res = duk_heap_strtable_intern_u32(thr->heap, val); if (DUK_UNLIKELY(res == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } return res; } @@ -52998,7 +51937,7 @@ if (!res) { return NULL; } - duk_memzero(res, sizeof(duk_hboundfunc)); + DUK_MEMZERO(res, sizeof(duk_hboundfunc)); duk__init_object_parts(heap, hobject_flags, &res->obj); @@ -53040,7 +51979,7 @@ if (DUK_UNLIKELY(res == NULL)) { return NULL; } - duk_memzero(res, sizeof(duk_hthread)); + DUK_MEMZERO(res, sizeof(duk_hthread)); duk__init_object_parts(heap, hobject_flags, &res->obj); @@ -53082,7 +52021,6 @@ res = duk_hthread_alloc_unchecked(thr->heap, hobject_flags); if (res == NULL) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } return res; } @@ -53298,7 +52236,7 @@ * are very often in order already. */ if (idx != idx_insert) { - duk_memmove((void *) (keys + idx_insert + 1), + DUK_MEMMOVE((void *) (keys + idx_insert + 1), (const void *) (keys + idx_insert), ((size_t) (idx - idx_insert) * sizeof(duk_hstring *))); keys[idx_insert] = h_curr; @@ -53782,7 +52720,7 @@ } /* - * Get enumerated keys in an ECMAScript array. Matches Object.keys() behavior + * Get enumerated keys in an Ecmascript array. Matches Object.keys() behavior * described in E5 Section 15.2.3.14. */ @@ -53868,7 +52806,6 @@ break; } else { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } } h = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h); @@ -53952,7 +52889,7 @@ (long) hdr[hdr_index + 1])); #endif - duk_memzero(be_ctx, sizeof(*be_ctx)); + DUK_MEMZERO(be_ctx, sizeof(*be_ctx)); be_ctx->data = ((duk_uint8_t *) hdr) + curr_offset; be_ctx->length = (duk_size_t) DUK_PC2LINE_MAX_DIFF_LENGTH; @@ -54063,7 +53000,7 @@ * Iterate the bitstream (line diffs) until PC is reached */ - duk_memzero(bd_ctx, sizeof(*bd_ctx)); + DUK_MEMZERO(bd_ctx, sizeof(*bd_ctx)); bd_ctx->data = ((duk_uint8_t *) hdr) + start_offset; bd_ctx->length = (duk_size_t) (DUK_HBUFFER_FIXED_GET_SIZE(buf) - start_offset); @@ -54123,7 +53060,7 @@ */ duk_get_prop_stridx(thr, idx_func, DUK_STRIDX_INT_PC2LINE); - pc2line = (duk_hbuffer_fixed *) (void *) duk_get_hbuffer(thr, -1); + pc2line = (duk_hbuffer_fixed *) duk_get_hbuffer(thr, -1); if (pc2line != NULL) { DUK_ASSERT(!DUK_HBUFFER_HAS_DYNAMIC((duk_hbuffer *) pc2line) && !DUK_HBUFFER_HAS_EXTERNAL((duk_hbuffer *) pc2line)); line = duk__hobject_pc2line_query_raw(thr, pc2line, (duk_uint_fast32_t) pc); @@ -54191,7 +53128,7 @@ #define DUK__HASH_DELETED DUK_HOBJECT_HASHIDX_DELETED /* Valstack space that suffices for all local calls, excluding any recursion - * into ECMAScript or Duktape/C calls (Proxy, getters, etc). + * into Ecmascript or Duktape/C calls (Proxy, getters, etc). */ #define DUK__VALSTACK_SPACE 10 @@ -54741,7 +53678,6 @@ if (new_e_size_adjusted + new_a_size > DUK_HOBJECT_MAX_PROPERTIES) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return;); } /* @@ -54945,14 +53881,18 @@ } else { array_copy_size = sizeof(duk_tval) * new_a_size; } - - DUK_ASSERT(new_a != NULL || array_copy_size == 0U); - DUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, obj) != NULL || array_copy_size == 0U); - DUK_ASSERT(DUK_HOBJECT_GET_ASIZE(obj) > 0 || array_copy_size == 0U); - duk_memcpy_unsafe((void *) new_a, - (const void *) DUK_HOBJECT_A_GET_BASE(thr->heap, obj), - array_copy_size); - + if (array_copy_size > 0) { + /* Avoid zero copy with an invalid pointer. If obj->p is NULL, + * the 'new_a' pointer will be invalid which is not allowed even + * when copy size is zero. + */ + DUK_ASSERT(new_a != NULL); + DUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, obj) != NULL); + DUK_ASSERT(DUK_HOBJECT_GET_ASIZE(obj) > 0); + DUK_MEMCPY((void *) new_a, + (const void *) DUK_HOBJECT_A_GET_BASE(thr->heap, obj), + array_copy_size); + } for (i = DUK_HOBJECT_GET_ASIZE(obj); i < new_a_size; i++) { duk_tval *tv = &new_a[i]; DUK_TVAL_SET_UNUSED(tv); @@ -54977,7 +53917,7 @@ /* fill new_h with u32 0xff = UNUSED */ DUK_ASSERT(new_h_size > 0); - duk_memset(new_h, 0xff, sizeof(duk_uint32_t) * new_h_size); + DUK_MEMSET(new_h, 0xff, sizeof(duk_uint32_t) * new_h_size); DUK_ASSERT(new_e_next <= new_h_size); /* equality not actually possible */ @@ -55087,7 +54027,6 @@ #endif DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return;); } /* @@ -55565,7 +54504,7 @@ /* This is not strictly necessary, but avoids compiler warnings; e.g. * gcc won't reliably detect that no uninitialized data is read below. */ - duk_memzero((void *) &tv, sizeof(duk_tval)); + DUK_MEMZERO((void *) &tv, sizeof(duk_tval)); if (duk_hobject_get_internal_value(heap, obj, &tv)) { duk_hstring *h; @@ -55753,7 +54692,7 @@ } /* - * ECMAScript compliant [[GetOwnProperty]](P), for internal use only. + * Ecmascript compliant [[GetOwnProperty]](P), for internal use only. * * If property is found: * - Fills descriptor fields to 'out_desc' @@ -56128,7 +55067,7 @@ } /* - * ECMAScript compliant [[GetProperty]](P), for internal use only. + * Ecmascript compliant [[GetProperty]](P), for internal use only. * * If property is found: * - Fills descriptor fields to 'out_desc' @@ -56185,7 +55124,6 @@ break; } else { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } } curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr); @@ -56467,7 +55405,7 @@ #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ /* - * GETPROP: ECMAScript property read. + * GETPROP: Ecmascript property read. */ DUK_INTERNAL duk_bool_t duk_hobject_getprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key) { @@ -56521,8 +55459,7 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot read property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); - break; + return 0; } case DUK_TAG_BOOLEAN: { @@ -56678,7 +55615,6 @@ !DUK_TVAL_IS_UNDEFINED(tv_hook); if (datadesc_reject || accdesc_reject) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } duk_pop_2_unsafe(thr); @@ -56870,7 +55806,6 @@ */ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr); } while (curr != NULL); @@ -56941,7 +55876,6 @@ DUK_HOBJECT_HAS_STRICT(h)) { /* XXX: sufficient to check 'strict', assert for 'is function' */ DUK_ERROR_TYPE(thr, DUK_STR_STRICT_CALLER_READ); - DUK_WO_NORETURN(return 0;); } } } @@ -56954,7 +55888,7 @@ } /* - * HASPROP: ECMAScript property existence check ("in" operator). + * HASPROP: Ecmascript property existence check ("in" operator). * * Interestingly, the 'in' operator does not do any coercion of * the target object. @@ -57020,7 +55954,6 @@ /* Note: unconditional throw */ DUK_DDD(DUK_DDDPRINT("base object is not an object -> reject")); DUK_ERROR_TYPE(thr, DUK_STR_INVALID_BASE); - DUK_WO_NORETURN(return 0;); } /* XXX: fast path for arrays? */ @@ -57045,7 +55978,7 @@ duk_push_hobject(thr, h_target); /* target */ duk_push_tval(thr, tv_key); /* P */ duk_call_method(thr, 2 /*nargs*/); - tmp_bool = duk_to_boolean_top_pop(thr); + tmp_bool = duk_to_boolean(thr, -1); if (!tmp_bool) { /* Target object must be checked for a conflicting * non-configurable property. @@ -57064,12 +55997,11 @@ if (!((desc.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && /* property is configurable and */ DUK_HOBJECT_HAS_EXTENSIBLE(h_target))) { /* ... target is extensible */ DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } } } - duk_pop_unsafe(thr); /* [ key ] -> [] */ + duk_pop_2_unsafe(thr); /* [ key trap_result ] -> [] */ return tmp_bool; } @@ -57161,7 +56093,7 @@ /* Refuse to update an Array's 'length' to a value outside the * 32-bit range. Negative zero is accepted as zero. */ - res = duk_double_to_uint32_t(d); + res = (duk_uint32_t) d; if ((duk_double_t) res != d) { goto fail_range; } @@ -57170,7 +56102,7 @@ fail_range: DUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARRAY_LENGTH); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } /* Delete elements required by a smaller length, taking into account @@ -57439,9 +56371,9 @@ } /* - * PUTPROP: ECMAScript property write. + * PUTPROP: Ecmascript property write. * - * Unlike ECMAScript primitive which returns nothing, returns 1 to indicate + * Unlike Ecmascript primitive which returns nothing, returns 1 to indicate * success and 0 to indicate failure (assuming throw is not set). * * This is an extremely tricky function. Some examples: @@ -57528,8 +56460,7 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot write property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); - break; + return 0; } case DUK_TAG_BOOLEAN: { @@ -57633,7 +56564,8 @@ duk_push_tval(thr, tv_val); /* V */ duk_push_tval(thr, tv_obj); /* Receiver: Proxy object */ duk_call_method(thr, 4 /*nargs*/); - tmp_bool = duk_to_boolean_top_pop(thr); + tmp_bool = duk_to_boolean(thr, -1); + duk_pop_nodecref_unsafe(thr); if (!tmp_bool) { goto fail_proxy_rejected; } @@ -57665,7 +56597,6 @@ (desc.set == NULL); if (datadesc_reject || accdesc_reject) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } duk_pop_2_unsafe(thr); @@ -57965,7 +56896,6 @@ */ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr); } while (curr != NULL); @@ -58315,7 +57245,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, proxy rejects")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } /* Note: no key on stack */ return 0; @@ -58330,7 +57259,6 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot write property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -58339,7 +57267,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, not extensible")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_EXTENSIBLE); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -58348,7 +57275,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, not writable")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_WRITABLE); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -58358,7 +57284,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, not writable")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_WRITABLE); - DUK_WO_NORETURN(return 0;); } return 0; #endif @@ -58367,7 +57292,6 @@ DUK_DD(DUK_DDPRINT("result: error, array length write only partially successful")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -58376,7 +57300,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, accessor property without setter")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_SETTER_UNDEFINED); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -58385,14 +57308,13 @@ DUK_DDD(DUK_DDDPRINT("result: error, internal")); if (throw_flag) { DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; } /* - * ECMAScript compliant [[Delete]](P, Throw). + * Ecmascript compliant [[Delete]](P, Throw). */ DUK_INTERNAL duk_bool_t duk_hobject_delprop_raw(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_small_uint_t flags) { @@ -58546,13 +57468,12 @@ if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } return 0; } /* - * DELPROP: ECMAScript property deletion. + * DELPROP: Ecmascript property deletion. */ DUK_INTERNAL duk_bool_t duk_hobject_delprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key, duk_bool_t throw_flag) { @@ -58607,7 +57528,8 @@ duk_push_hobject(thr, h_target); /* target */ duk_dup_m4(thr); /* P */ duk_call_method(thr, 2 /*nargs*/); - tmp_bool = duk_to_boolean_top_pop(thr); + tmp_bool = duk_to_boolean(thr, -1); + duk_pop_nodecref_unsafe(thr); if (!tmp_bool) { goto fail_proxy_rejected; /* retval indicates delete failed */ } @@ -58632,7 +57554,6 @@ if (desc_reject) { /* unconditional */ DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } } rc = 1; /* success */ @@ -58716,13 +57637,12 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot delete property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); + return 0; #if defined(DUK_USE_ES6_PROXY) fail_proxy_rejected: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } duk_set_top_unsafe(thr, entry_top); return 0; @@ -58731,7 +57651,6 @@ fail_not_configurable: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } duk_set_top_unsafe(thr, entry_top); return 0; @@ -58871,7 +57790,7 @@ error_virtual: /* share error message */ error_internal: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); + return; } /* @@ -58951,7 +57870,7 @@ val = duk_to_number_m1(thr); duk_pop_3_unsafe(thr); - /* This isn't part of ECMAScript semantics; return a value within + /* This isn't part of Ecmascript semantics; return a value within * duk_size_t range, or 0 otherwise. */ if (val >= 0.0 && val <= (duk_double_t) DUK_SIZE_MAX) { @@ -59062,7 +57981,7 @@ * NormalizePropertyDescriptor() related helper. * * Internal helper which validates and normalizes a property descriptor - * represented as an ECMAScript object (e.g. argument to defineProperty()). + * represented as an Ecmascript object (e.g. argument to defineProperty()). * The output of this conversion is a set of defprop_flags and possibly * some values pushed on the value stack to (1) ensure borrowed pointers * remain valid, and (2) avoid unnecessary pops for footprint reasons. @@ -59112,7 +58031,7 @@ if (duk_get_prop_stridx(thr, idx_in, DUK_STRIDX_WRITABLE)) { is_data_desc = 1; - if (duk_to_boolean_top_pop(thr)) { + if (duk_to_boolean(thr, -1)) { defprop_flags |= DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_WRITABLE; } else { defprop_flags |= DUK_DEFPROP_HAVE_WRITABLE; @@ -59164,7 +58083,7 @@ } if (duk_get_prop_stridx(thr, idx_in, DUK_STRIDX_ENUMERABLE)) { - if (duk_to_boolean_top_pop(thr)) { + if (duk_to_boolean(thr, -1)) { defprop_flags |= DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE; } else { defprop_flags |= DUK_DEFPROP_HAVE_ENUMERABLE; @@ -59172,7 +58091,7 @@ } if (duk_get_prop_stridx(thr, idx_in, DUK_STRIDX_CONFIGURABLE)) { - if (duk_to_boolean_top_pop(thr)) { + if (duk_to_boolean(thr, -1)) { defprop_flags |= DUK_DEFPROP_HAVE_CONFIGURABLE | DUK_DEFPROP_CONFIGURABLE; } else { defprop_flags |= DUK_DEFPROP_HAVE_CONFIGURABLE; @@ -59193,7 +58112,6 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_DESCRIPTOR); - DUK_WO_NORETURN(return;); } /* @@ -59202,7 +58120,7 @@ * * Inlines all [[DefineOwnProperty]] exotic behaviors. * - * Note: ECMAScript compliant [[DefineOwnProperty]](P, Desc, Throw) is not + * Note: Ecmascript compliant [[DefineOwnProperty]](P, Desc, Throw) is not * implemented directly, but Object.defineProperty() serves its purpose. * We don't need the [[DefineOwnProperty]] internally and we don't have a * property descriptor with 'missing values' so it's easier to avoid it @@ -60075,7 +58993,6 @@ fail_not_extensible: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_EXTENSIBLE); - DUK_WO_NORETURN(return 0;); } return 0; @@ -60083,7 +59000,6 @@ fail_not_configurable: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } return 0; } @@ -60139,7 +59055,6 @@ if (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) { DUK_DD(DUK_DDPRINT("attempt to seal/freeze a readonly object, reject")); DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return;); } #endif @@ -60287,7 +59202,7 @@ (const void *) p_start, (const void *) p_end, (const void *) p)); - /* For invalid UTF-8 (never happens for standard ECMAScript strings) + /* For invalid UTF-8 (never happens for standard Ecmascript strings) * return U+FFFD replacement character. */ if (duk_unicode_decode_xutf8(thr, &p, p_start, p_end, &cp1)) { @@ -60443,7 +59358,7 @@ if (len != DUK_HSTRING_GET_BYTELEN(h)) { return 0; } - if (duk_memcmp((const void *) cstr, (const void *) DUK_HSTRING_GET_DATA(h), len) == 0) { + if (DUK_MEMCMP((const void *) cstr, (const void *) DUK_HSTRING_GET_DATA(h), len) == 0) { return 1; } return 0; @@ -60480,7 +59395,7 @@ if (!thr->valstack) { goto fail; } - duk_memzero(thr->valstack, alloc_size); + DUK_MEMZERO(thr->valstack, alloc_size); thr->valstack_end = thr->valstack + DUK_VALSTACK_API_ENTRY_MINIMUM; thr->valstack_alloc_end = thr->valstack + DUK_VALSTACK_INITIAL_SIZE; thr->valstack_bottom = thr->valstack; @@ -60584,7 +59499,7 @@ props = DUK_ALLOC_CHECKED(thr, alloc_size); DUK_ASSERT(props != NULL); DUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, h_oldglobal) != NULL); - duk_memcpy((void *) props, (const void *) DUK_HOBJECT_GET_PROPS(thr->heap, h_oldglobal), alloc_size); + DUK_MEMCPY((void *) props, (const void *) DUK_HOBJECT_GET_PROPS(thr->heap, h_oldglobal), alloc_size); /* XXX: keep property attributes or tweak them here? * Properties will now be non-configurable even when they're @@ -60711,7 +59626,7 @@ DUK_D(DUK_DPRINT("INITBUILTINS BEGIN: DUK_NUM_BUILTINS=%d, DUK_NUM_BUILTINS_ALL=%d", (int) DUK_NUM_BUILTINS, (int) DUK_NUM_ALL_BUILTINS)); - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); bd->data = (const duk_uint8_t *) duk_builtins_data; bd->length = (duk_size_t) DUK_BUILTINS_DATA_LENGTH; @@ -60953,9 +59868,11 @@ * signaled using a single flag bit in the bitstream. */ - defprop_flags = (duk_small_uint_t) duk_bd_decode_flagged(bd, - DUK__PROP_FLAGS_BITS, - (duk_uint32_t) DUK_PROPDESC_FLAGS_WC); + if (duk_bd_decode_flag(bd)) { + defprop_flags = (duk_small_uint_t) duk_bd_decode(bd, DUK__PROP_FLAGS_BITS); + } else { + defprop_flags = DUK_PROPDESC_FLAGS_WC; + } defprop_flags |= DUK_DEFPROP_FORCE | DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | @@ -61060,7 +59977,6 @@ #if defined(DUK_USE_LIGHTFUNC_BUILTINS) duk_small_int_t lightfunc_eligible; #endif - duk_small_uint_t defprop_flags; duk__push_stridx_or_string(thr, bd); h_key = duk_known_hstring(thr, -1); @@ -61180,19 +60096,10 @@ lightfunc_skip: #endif - defprop_flags = (duk_small_uint_t) duk_bd_decode_flagged(bd, - DUK__PROP_FLAGS_BITS, - (duk_uint32_t) DUK_PROPDESC_FLAGS_WC); - defprop_flags |= DUK_DEFPROP_FORCE | - DUK_DEFPROP_HAVE_VALUE | - DUK_DEFPROP_HAVE_WRITABLE | - DUK_DEFPROP_HAVE_ENUMERABLE | - DUK_DEFPROP_HAVE_CONFIGURABLE; - DUK_ASSERT(DUK_PROPDESC_FLAG_WRITABLE == DUK_DEFPROP_WRITABLE); - DUK_ASSERT(DUK_PROPDESC_FLAG_ENUMERABLE == DUK_DEFPROP_ENUMERABLE); - DUK_ASSERT(DUK_PROPDESC_FLAG_CONFIGURABLE == DUK_DEFPROP_CONFIGURABLE); - - duk_def_prop(thr, (duk_idx_t) i, defprop_flags); + /* XXX: So far all ES builtins are 'wc' but e.g. + * performance.now() should be 'wec'. + */ + duk_xdef_prop(thr, (duk_idx_t) i, DUK_PROPDESC_FLAGS_WC); /* [ (builtin objects) ] */ } @@ -61265,7 +60172,7 @@ "f" #endif " " - /* Low memory/performance options */ + /* Low memory options */ #if defined(DUK_USE_STRTAB_PTRCOMP) "s" #endif @@ -61306,9 +60213,6 @@ */ "Z" #endif -#if defined(DUK_USE_LITCACHE_SIZE) - "l" -#endif " " /* Object property allocation layout */ #if defined(DUK_USE_HOBJECT_LAYOUT_1) @@ -61883,8 +60787,8 @@ /* Use DUK_ALLOC_RAW() to avoid side effects. */ new_ptr = (duk_tval *) DUK_ALLOC_RAW(thr->heap, alloc_size); if (new_ptr != NULL) { - duk_memcpy((void *) new_ptr, (const void *) thr->valstack, alloc_size); - duk_memset((void *) thr->valstack, 0x55, alloc_size); + DUK_MEMCPY((void *) new_ptr, (const void *) thr->valstack, alloc_size); + DUK_MEMSET((void *) thr->valstack, 0x55, alloc_size); DUK_FREE_CHECKED(thr, (void *) thr->valstack); thr->valstack = new_ptr; thr->valstack_alloc_end = (duk_tval *) ((duk_uint8_t *) new_ptr + alloc_end_off); @@ -61902,7 +60806,7 @@ /* #include duk_internal.h -> already included */ -/* ECMAScript modulus ('%') does not match IEEE 754 "remainder" operation +/* Ecmascript modulus ('%') does not match IEEE 754 "remainder" operation * (implemented by remainder() in C99) but does seem to match ANSI C fmod(). * Compare E5 Section 11.5.3 and "man fmod". */ @@ -61956,9 +60860,9 @@ /* Shared helper for Math.pow() and exponentiation operator. */ DUK_INTERNAL double duk_js_arith_pow(double x, double y) { - /* The ANSI C pow() semantics differ from ECMAScript. + /* The ANSI C pow() semantics differ from Ecmascript. * - * E.g. when x==1 and y is +/- infinite, the ECMAScript required + * E.g. when x==1 and y is +/- infinite, the Ecmascript required * result is NaN, while at least Linux pow() returns 1. */ @@ -62038,7 +60942,7 @@ * * duk_handle_call_unprotected(): * - * - Unprotected call to ECMAScript or Duktape/C function, from native + * - Unprotected call to Ecmascript or Duktape/C function, from native * code or bytecode executor. * * - Also handles Ecma-to-Ecma calls which reuses a currently running @@ -62092,7 +60996,6 @@ DUK_D(DUK_DPRINT("call prevented because C recursion limit reached")); DUK_ERROR_RANGE(thr, DUK_STR_C_CALLSTACK_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL DUK_ALWAYS_INLINE void duk__call_c_recursion_limit_check(duk_hthread *thr) { @@ -62128,7 +61031,6 @@ */ DUK_D(DUK_DPRINT("call prevented because call stack limit reached")); DUK_ERROR_RANGE(thr, DUK_STR_CALLSTACK_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL DUK_ALWAYS_INLINE void duk__call_callstack_limit_check(duk_hthread *thr) { @@ -62542,7 +61444,6 @@ if (DUK_UNLIKELY(proxy_invariant != 0U)) { /* Proxy 'construct' return value invariant violated. */ DUK_ERROR_TYPE_INVALID_TRAP_RESULT(thr); - DUK_WO_NORETURN(return;); } /* XXX: direct value stack access */ duk_pop(thr); @@ -62603,7 +61504,7 @@ duk_tval *tv_args; duk_tval *tv_gap; - h_bound = (duk_hboundfunc *) (void *) func; + h_bound = (duk_hboundfunc *) func; tv_args = h_bound->args; len = h_bound->nargs; DUK_ASSERT(len == 0 || tv_args != NULL); @@ -62643,7 +61544,6 @@ } else { /* Shouldn't happen, so ugly error is enough. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); } DUK_ASSERT(duk_get_top(thr) >= idx_func + 2); @@ -62819,13 +61719,11 @@ if (top < idx_func + 3) { /* argArray is a mandatory argument for Reflect.construct(). */ DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); } if (top > idx_func + 3) { if (!duk_strict_equals(thr, idx_func, idx_func + 3)) { /* XXX: [[Construct]] newTarget currently unsupported */ DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } duk_set_top_unsafe(thr, idx_func + 3); /* remove any args beyond argArray */ } @@ -63362,7 +62260,6 @@ if (duk_hobject_find_existing_entry_tval_ptr(thr->heap, DUK_TVAL_GET_OBJECT(tv_func), DUK_HTHREAD_STRING_INT_TARGET(thr)) != NULL) { duk_push_tval(thr, tv_func); (void) duk_throw(thr); - DUK_WO_NORETURN(return NULL;); } } #endif @@ -63376,7 +62273,8 @@ #else DUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE); #endif - DUK_WO_NORETURN(return NULL;); + DUK_UNREACHABLE(); + return NULL; /* never executed */ not_constructable: /* For now GETPROPC delayed error not needed for constructor calls. */ @@ -63389,7 +62287,8 @@ #else DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONSTRUCTABLE); #endif - DUK_WO_NORETURN(return NULL;); + DUK_UNREACHABLE(); + return NULL; /* never executed */ } /* @@ -63413,7 +62312,6 @@ idx_rcbase = duk_get_top(thr) - num_actual_rets; /* base of known return values */ if (DUK_UNLIKELY(idx_rcbase < 0)) { DUK_ERROR_TYPE(thr, DUK_STR_INVALID_CFUNC_RC); - DUK_WO_NORETURN(return;); } DUK_DDD(DUK_DDDPRINT("adjust valstack after func call: " @@ -63548,10 +62446,9 @@ * - Disable StepOut processing for the activation unwind because * we reuse the activation, see: * https://github.com/svaarala/duktape/issues/1684. - * - Disable line change pause flag permanently if act == dbg_pause_act - * (if set) because it would no longer be relevant, see: - * https://github.com/svaarala/duktape/issues/1726, - * https://github.com/svaarala/duktape/issues/1786. + * - Disable line change pause flag permanently (if set) because + * it would no longer be relevant, see: + * https://github.com/svaarala/duktape/issues/1726. * - Check for function entry (e.g. StepInto) pause flag here, because * the executor pause check won't trigger due to shared activation, see: * https://github.com/svaarala/duktape/issues/1726. @@ -63572,12 +62469,9 @@ DUK_ASSERT(thr->callstack_top > 0); DUK_ASSERT(thr->callstack_curr != NULL); #if defined(DUK_USE_DEBUGGER_SUPPORT) - if (act == thr->heap->dbg_pause_act) { - thr->heap->dbg_pause_flags &= ~DUK_PAUSE_FLAG_LINE_CHANGE; - } - prev_pause_act = thr->heap->dbg_pause_act; thr->heap->dbg_pause_act = NULL; + thr->heap->dbg_pause_flags &= ~DUK_PAUSE_FLAG_LINE_CHANGE; if (thr->heap->dbg_pause_flags & DUK_PAUSE_FLAG_FUNC_ENTRY) { DUK_D(DUK_DPRINT("PAUSE TRIGGERED by function entry (tailcall)")); duk_debug_set_paused(thr->heap); @@ -63717,10 +62611,10 @@ * Update return value stack index of current activation (if any). * * Although it might seem this is not necessary (bytecode executor - * does this for ECMAScript-to-ECMAScript calls; other calls are + * does this for Ecmascript-to-Ecmascript calls; other calls are * handled here), this turns out to be necessary for handling yield - * and resume. For them, an ECMAScript-to-native call happens, and - * the ECMAScript call's retval_byteoff must be set for things to work. + * and resume. For them, an Ecmascript-to-native call happens, and + * the Ecmascript call's retval_byteoff must be set for things to work. */ act->retval_byteoff = entry_valstack_bottom_byteoff + (duk_size_t) idx_func * sizeof(duk_tval); @@ -63927,16 +62821,16 @@ thread_state_error: DUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, "invalid thread state (%ld)", (long) thr->state); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); } /* * Main unprotected call handler, handles: * - * - All combinations of native/ECMAScript caller and native/ECMAScript + * - All combinations of native/Ecmascript caller and native/Ecmascript * target. * - * - Optimized ECMAScript-to-ECMAScript call where call handling only + * - Optimized Ecmascript-to-Ecmascript call where call handling only * sets up a new duk_activation but reuses an existing bytecode executor * (the caller) without native recursion. * @@ -63985,7 +62879,7 @@ DUK_STATS_INC(thr->heap, stats_call_all); /* If a tail call: - * - an ECMAScript activation must be on top of the callstack + * - an Ecmascript activation must be on top of the callstack * - there cannot be any catch stack entries that would catch * a return */ @@ -64090,12 +62984,6 @@ * Because 'act' is not zeroed, all fields must be filled in. */ - /* Should not be necessary, but initialize to silence warnings. */ - act = NULL; - nargs = 0; - nregs = 0; - vs_min_bytes = 0; - #if defined(DUK_USE_TAILCALL) use_tailcall = (call_flags & DUK_CALL_FLAG_TAILCALL); if (use_tailcall) { @@ -64143,7 +63031,7 @@ * compiler; the compiled function's parent env will contain * the (immutable) binding already. * - * This handling is now identical for C and ECMAScript functions. + * This handling is now identical for C and Ecmascript functions. * C functions always have the 'NEWENV' flag set, so their * environment record initialization is delayed (which is good). * @@ -64190,7 +63078,7 @@ if (func != NULL && DUK_HOBJECT_IS_COMPFUNC(func)) { /* - * ECMAScript call. + * Ecmascript call. */ DUK_ASSERT(func != NULL); @@ -64284,10 +63172,9 @@ ; } else if (rc < 0) { duk_error_throw_from_negative_rc(thr, rc); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); } else { DUK_ERROR_TYPE(thr, DUK_STR_INVALID_CFUNC_RC); - DUK_WO_NORETURN(return 0;); } } DUK_ASSERT(thr->ptr_curr_pc == NULL); @@ -64375,7 +63262,7 @@ * calls caused by side effects (e.g. when doing a DUK_OP_GETPROP), see * GH-303. Only needed for success path, error path always causes a * breakpoint recheck in the executor. It would be enough to set this - * only when returning to an ECMAScript activation, but setting the flag + * only when returning to an Ecmascript activation, but setting the flag * on every return should have no ill effect. */ #if defined(DUK_USE_DEBUGGER_SUPPORT) @@ -64487,7 +63374,6 @@ if (DUK_UNLIKELY(rc < 0)) { duk_error_throw_from_negative_rc(thr, rc); - DUK_WO_NORETURN(return;); } DUK_ASSERT(rc >= 0); @@ -64765,10 +63651,7 @@ retval = DUK_EXEC_ERROR; } #if defined(DUK_USE_CPP_EXCEPTIONS) - catch (duk_fatal_exception &exc) { - DUK_D(DUK_DPRINT("rethrow duk_fatal_exception")); - throw; - } catch (std::exception &exc) { + catch (std::exception &exc) { const char *what = exc.what(); DUK_ASSERT((duk_size_t) ((duk_uint8_t *) thr->valstack_end - (duk_uint8_t *) thr->valstack) >= entry_valstack_end_byteoff); DUK_STATS_INC(thr->heap, stats_safecall_throw); @@ -64778,7 +63661,6 @@ DUK_D(DUK_DPRINT("unexpected c++ std::exception (perhaps thrown by user code)")); try { DUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, "caught invalid c++ std::exception '%s' (perhaps thrown by user code)", what); - DUK_WO_NORETURN(return 0;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ std::exception")); DUK_UNREF(exc); @@ -64801,7 +63683,6 @@ DUK_STATS_INC(thr->heap, stats_safecall_throw); try { DUK_ERROR_TYPE(thr, "caught invalid c++ exception (perhaps thrown by user code)"); - DUK_WO_NORETURN(return 0;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ exception")); DUK_UNREF(exc); @@ -64861,7 +63742,7 @@ /* * Property-based call (foo.noSuch()) error setup: replace target function * on stack top with a specially tagged (hidden Symbol) error which gets - * thrown in call handling at the proper spot to follow ECMAScript semantics. + * thrown in call handling at the proper spot to follow Ecmascript semantics. */ #if defined(DUK_USE_VERBOSE_ERRORS) @@ -64919,7 +63800,7 @@ /* automatic undefs */ #undef DUK__AUGMENT_CALL_RELAX_COUNT /* - * ECMAScript compiler. + * Ecmascript compiler. * * Parses an input string and generates a function template result. * Compilation may happen in multiple contexts (global code, eval @@ -65155,9 +64036,9 @@ DUK_LOCAL_DECL void duk__parse_with_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res); DUK_LOCAL_DECL void duk__parse_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_bool_t allow_source_elem); DUK_LOCAL_DECL duk_int_t duk__stmt_label_site(duk_compiler_ctx *comp_ctx, duk_int_t label_id); -DUK_LOCAL_DECL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof, duk_bool_t regexp_after); +DUK_LOCAL_DECL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof); -DUK_LOCAL_DECL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_bool_t regexp_after, duk_small_int_t expect_token); +DUK_LOCAL_DECL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_small_int_t expect_token); DUK_LOCAL_DECL void duk__parse_func_formals(duk_compiler_ctx *comp_ctx); DUK_LOCAL_DECL void duk__parse_func_like_raw(duk_compiler_ctx *comp_ctx, duk_small_uint_t flags); DUK_LOCAL_DECL duk_int_t duk__parse_func_like_fnum(duk_compiler_ctx *comp_ctx, duk_small_uint_t flags); @@ -65329,7 +64210,6 @@ DUK_ASSERT(comp_ctx->recursion_depth >= 0); if (comp_ctx->recursion_depth >= comp_ctx->recursion_limit) { DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_COMPILER_RECURSION_LIMIT); - DUK_WO_NORETURN(return;); } comp_ctx->recursion_depth++; } @@ -65384,20 +64264,15 @@ comp_ctx->curr_func.reject_regexp_in_adv = 0; regexp = 0; } - if (comp_ctx->curr_func.allow_regexp_in_adv) { - comp_ctx->curr_func.allow_regexp_in_adv = 0; - regexp = 1; - } if (expect >= 0 && comp_ctx->curr_token.t != (duk_small_uint_t) expect) { DUK_D(DUK_DPRINT("parse error: expect=%ld, got=%ld", (long) expect, (long) comp_ctx->curr_token.t)); DUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR); - DUK_WO_NORETURN(return;); } /* make current token the previous; need to fiddle with valstack "backing store" */ - duk_memcpy(&comp_ctx->prev_token, &comp_ctx->curr_token, sizeof(duk_token)); + DUK_MEMCPY(&comp_ctx->prev_token, &comp_ctx->curr_token, sizeof(duk_token)); duk_copy(thr, comp_ctx->tok11_idx, comp_ctx->tok21_idx); duk_copy(thr, comp_ctx->tok12_idx, comp_ctx->tok22_idx); @@ -65445,7 +64320,7 @@ entry_top = duk_get_top(thr); - duk_memzero(func, sizeof(*func)); /* intentional overlap with earlier memzero */ + DUK_MEMZERO(func, sizeof(*func)); /* intentional overlap with earlier memzero */ #if defined(DUK_USE_EXPLICIT_NULL_INIT) func->h_name = NULL; func->h_consts = NULL; @@ -65692,7 +64567,7 @@ (long) code_size, (long) data_size)); duk_push_fixed_buffer_nozero(thr, data_size); - h_data = (duk_hbuffer_fixed *) (void *) duk_known_hbuffer(thr, -1); + h_data = (duk_hbuffer_fixed *) duk_known_hbuffer(thr, -1); DUK_HCOMPFUNC_SET_DATA(thr->heap, h_res, (duk_hbuffer *) h_data); DUK_HEAPHDR_INCREF(thr, h_data); @@ -65897,7 +64772,7 @@ */ #if 0 - duk_push_literal(thr, "XXX"); + duk_push_string(thr, "XXX"); duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_INT_SOURCE, DUK_PROPDESC_FLAGS_NONE); #endif } @@ -66096,7 +64971,6 @@ fail_bc_limit: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_BYTECODE_LIMIT); - DUK_WO_NORETURN(return;); } /* Update function min/max line from current token. Needed to improve @@ -66381,7 +65255,6 @@ error_outofregs: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } /* For many of the helpers below it'd be technically correct to add @@ -66480,7 +65353,6 @@ error_outofregs: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__emit_bc(duk_compiler_ctx *comp_ctx, duk_small_uint_t op, duk_regconst_t bc) { @@ -66515,7 +65387,6 @@ error_outofregs: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__emit_load_int32_raw(duk_compiler_ctx *comp_ctx, duk_regconst_t reg, duk_int32_t val, duk_small_uint_t op_flags) { @@ -66613,7 +65484,6 @@ fail_bc_limit: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_BYTECODE_LIMIT); - DUK_WO_NORETURN(return;); } /* Does not assume that jump_pc contains a DUK_OP_JUMP previously; this is intentional @@ -66669,7 +65539,6 @@ DUK_D(DUK_DPRINT("failed to patch trycatch: flags=%ld, reg_catch=%ld, const_varname=%ld (0x%08lx)", (long) flags, (long) reg_catch, (long) const_varname, (long) const_varname)); DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } instr->ins |= DUK_ENC_OP_A_BC(0, 0, const_varname); } else { @@ -66861,7 +65730,6 @@ if (comp_ctx->curr_func.temp_next > DUK__MAX_TEMPS) { /* == DUK__MAX_TEMPS is OK */ DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_TEMP_LIMIT); - DUK_WO_NORETURN(return 0;); } /* maintain highest 'used' temporary, needed to figure out nregs of function */ @@ -66921,7 +65789,6 @@ if (n > DUK__MAX_CONSTS) { DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_CONST_LIMIT); - DUK_WO_NORETURN(return 0;); } DUK_DDD(DUK_DDDPRINT("allocating new constant for %!T -> const index %ld", @@ -67095,7 +65962,6 @@ } } } /* end switch */ - goto fail_internal; /* never here */ } case DUK_ISPEC_REGCONST: { if (forced_reg >= 0) { @@ -67128,13 +65994,12 @@ return x->regconst; } default: { - break; /* never here */ + break; } } - fail_internal: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_LOCAL void duk__ispec_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ispec *x, duk_regconst_t forced_reg) { @@ -67207,10 +66072,7 @@ break; } case DUK_OP_DIV: { - /* Division-by-zero is undefined - * behavior, so rely on a helper. - */ - d3 = duk_double_div(d1, d2); + d3 = d1 / d2; break; } case DUK_OP_EXP: { @@ -67237,7 +66099,7 @@ } } else if (x->op == DUK_OP_ADD && DUK_TVAL_IS_STRING(tv1) && DUK_TVAL_IS_STRING(tv2)) { /* Inline string concatenation. No need to check for - * symbols, as all inputs are valid ECMAScript strings. + * symbols, as all inputs are valid Ecmascript strings. */ duk_dup(thr, x->x1.valstack_idx); duk_dup(thr, x->x2.valstack_idx); @@ -67335,7 +66197,7 @@ } DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); + return; } /* evaluate to plain value, no forced register (temp/bound reg both ok) */ @@ -67567,7 +66429,6 @@ if (li->h_label == h_label && h_label != DUK_HTHREAD_STRING_EMPTY_STRING(thr)) { DUK_ERROR_SYNTAX(thr, DUK_STR_DUPLICATE_LABEL); - DUK_WO_NORETURN(return;); } } @@ -67697,7 +66558,6 @@ */ if (h_label != DUK_HTHREAD_STRING_EMPTY_STRING(thr)) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LABEL); - DUK_WO_NORETURN(return;); } else { DUK_DDD(DUK_DDDPRINT("continue matched an empty label which does not " "allow a continue -> continue lookup deeper in label stack")); @@ -67707,7 +66567,6 @@ /* XXX: match flag is awkward, rework */ if (!match) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LABEL); - DUK_WO_NORETURN(return;); } DUK_DDD(DUK_DDDPRINT("label match: %!O -> label_id %ld, catch_depth=%ld, pc_label=%ld", @@ -67897,7 +66756,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_ARRAY_LITERAL); - DUK_WO_NORETURN(return;); } typedef struct { @@ -68174,14 +67032,13 @@ #endif DUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_RCURLY); - duk__advance(comp_ctx); /* No RegExp after object literal. */ + duk__advance(comp_ctx); duk__ivalue_regconst(res, st.reg_obj); return; syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_OBJECT_LITERAL); - DUK_WO_NORETURN(return;); } /* Parse argument list. Arguments are written to temps starting from @@ -68225,7 +67082,7 @@ } /* eat the right paren */ - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* RegExp mode does not matter. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); DUK_DDD(DUK_DDDPRINT("end parsing arguments")); @@ -68358,7 +67215,7 @@ duk__expr(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); /* Expression, terminates at a ')' */ - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* No RegExp after parenthesized expression. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); comp_ctx->curr_func.allow_in = prev_allow_in; comp_ctx->curr_func.paren_level--; return; @@ -68493,7 +67350,6 @@ if (comp_ctx->curr_func.is_strict) { DUK_ERROR_SYNTAX(thr, DUK_STR_CANNOT_DELETE_IDENTIFIER); - DUK_WO_NORETURN(return;); } DUK__SETTEMP(comp_ctx, temp_at_entry); @@ -68658,7 +67514,7 @@ } /* end switch */ DUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR); - DUK_WO_NORETURN(return;); + return; unary: { @@ -68762,12 +67618,10 @@ #if defined(DUK_USE_ES6) syntax_error_newtarget: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_NEWTARGET); - DUK_WO_NORETURN(return;); #endif syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_EXPRESSION); - DUK_WO_NORETURN(return;); } /* XXX: add flag to indicate whether caller cares about return value; this @@ -68822,7 +67676,6 @@ /* NB: must accept reserved words as property name */ if (comp_ctx->curr_token.t_nores != DUK_TOK_IDENTIFIER) { DUK_ERROR_SYNTAX(thr, DUK_STR_EXPECTED_IDENTIFIER); - DUK_WO_NORETURN(return;); } res->t = DUK_IVAL_PROP; @@ -69252,7 +68105,7 @@ DUK_D(DUK_DPRINT("parse error: unexpected token: %ld", (long) tok)); DUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR); - DUK_WO_NORETURN(return;); + return; #if 0 /* XXX: shared handling for 'duk__expr_lhs'? */ @@ -69482,7 +68335,7 @@ * one instruction, so use explicit PC computation. */ DUK_DD(DUK_DDPRINT("rhs is side effect free, rewind and avoid unnecessary temp for reg-based =")); - DUK_BW_ADD_PTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, (pc_temp_load - pc_before_rhs) * (duk_int_t) sizeof(duk_compiler_instr)); + DUK_BW_ADD_PTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, (duk_size_t) (pc_temp_load - pc_before_rhs) * sizeof(duk_compiler_instr)); reg_src = reg_varbind; } else { DUK_DD(DUK_DDPRINT("rhs evaluation emitted code, not sure if rhs is side effect free; use temp reg for LHS")); @@ -69742,11 +68595,11 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_EXPRESSION); - DUK_WO_NORETURN(return;); + return; syntax_error_lvalue: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LVALUE); - DUK_WO_NORETURN(return;); + return; } DUK_LOCAL duk_small_uint_t duk__expr_lbp(duk_compiler_ctx *comp_ctx) { @@ -69811,7 +68664,7 @@ (long) rbp_flags, (long) rbp, (long) comp_ctx->curr_func.allow_in, (long) comp_ctx->curr_func.paren_level)); - duk_memzero(&tmp_alloc, sizeof(tmp_alloc)); + DUK_MEMZERO(&tmp_alloc, sizeof(tmp_alloc)); tmp->x1.valstack_idx = duk_get_top(thr); tmp->x2.valstack_idx = tmp->x1.valstack_idx + 1; duk_push_undefined(thr); @@ -69831,7 +68684,6 @@ DUK_DDD(DUK_DDDPRINT("empty expression")); if (!(rbp_flags & DUK__EXPR_FLAG_ALLOW_EMPTY)) { DUK_ERROR_SYNTAX(thr, DUK_STR_EMPTY_EXPR_NOT_ALLOWED); - DUK_WO_NORETURN(return;); } duk_push_undefined(thr); duk__ivalue_plain_fromstack(comp_ctx, res); @@ -69870,7 +68722,6 @@ if (!(rbp_flags & DUK__EXPR_FLAG_ALLOW_EMPTY) && duk__expr_is_empty(comp_ctx)) { DUK_ERROR_SYNTAX(thr, DUK_STR_EMPTY_EXPR_NOT_ALLOWED); - DUK_WO_NORETURN(return;); } } @@ -70063,7 +68914,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_VAR_DECLARATION); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_var_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t expr_flags) { @@ -70295,8 +69145,7 @@ } DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); pc_l3 = duk__get_current_pc(comp_ctx); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -70387,8 +69236,7 @@ pc_jumpto_l4 = duk__emit_jump_empty(comp_ctx); DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); pc_l3 = duk__get_current_pc(comp_ctx); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -70437,7 +69285,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_FOR); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_switch_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site) { @@ -70479,7 +69326,7 @@ duk__advance(comp_ctx); duk__advance_expect(comp_ctx, DUK_TOK_LPAREN); rc_switch = duk__exprtop_toregconst(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* RegExp mode does not matter. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__advance_expect(comp_ctx, DUK_TOK_LCURLY); DUK_DDD(DUK_DDDPRINT("switch value in register %ld", (long) rc_switch)); @@ -70604,8 +69451,7 @@ } DUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_RCURLY); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance(comp_ctx); /* Allow RegExp as part of next stmt. */ + duk__advance(comp_ctx); /* default case control flow patchup; note that if pc_prevcase < 0 * (i.e. no case clauses), control enters default case automatically. @@ -70638,7 +69484,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_SWITCH); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_if_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res) { @@ -70658,8 +69503,7 @@ pc_jump_false = duk__emit_jump_empty(comp_ctx); /* jump to end or else part */ DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -70695,7 +69539,7 @@ DUK_DDD(DUK_DDDPRINT("begin parsing do statement")); - duk__advance(comp_ctx); /* Eat 'do'; allow RegExp as part of next stmt. */ + duk__advance(comp_ctx); /* eat 'do' */ pc_start = duk__get_current_pc(comp_ctx); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -70709,7 +69553,6 @@ duk__emit_jump(comp_ctx, pc_start); /* no need to reset temps, as we're finished emitting code */ - comp_ctx->curr_func.allow_regexp_in_adv = 1; /* Allow RegExp as part of next stmt. */ duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__patch_jump_here(comp_ctx, pc_label_site + 1); /* break jump */ @@ -70739,8 +69582,7 @@ pc_jump_false = duk__emit_jump_empty(comp_ctx); DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); duk__emit_jump(comp_ctx, pc_start); @@ -70776,7 +69618,6 @@ duk__advance(comp_ctx); } else { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_BREAK_CONT_LABEL); - DUK_WO_NORETURN(return;); } /* Use a fast break/continue when possible. A fast break/continue is @@ -70818,7 +69659,6 @@ */ if (!comp_ctx->curr_func.is_function) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_RETURN); - DUK_WO_NORETURN(return;); } if (comp_ctx->curr_token.t == DUK_TOK_SEMICOLON || /* explicit semi follows */ @@ -70920,7 +69760,6 @@ if (comp_ctx->curr_token.lineterm) { DUK_ERROR_SYNTAX(comp_ctx->thr, DUK_STR_INVALID_THROW); - DUK_WO_NORETURN(return;); } reg_val = duk__exprtop_toreg(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); @@ -70977,9 +69816,10 @@ /* try part */ duk__advance_expect(comp_ctx, DUK_TOK_LCURLY); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ - duk__emit_op_only(comp_ctx, DUK_OP_ENDTRY); + duk__emit_op_only(comp_ctx, + DUK_OP_ENDTRY); if (comp_ctx->curr_token.t == DUK_TOK_CATCH) { /* @@ -71075,7 +69915,7 @@ DUK_DDD(DUK_DDDPRINT("varmap before parsing catch clause: %!iT", (duk_tval *) duk_get_tval(thr, comp_ctx->curr_func.varmap_idx))); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ if (varmap_value == -2) { @@ -71117,7 +69957,7 @@ duk__advance(comp_ctx); duk__advance_expect(comp_ctx, DUK_TOK_LCURLY); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ duk__emit_abc(comp_ctx, DUK_OP_ENDFIN, @@ -71160,7 +70000,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_TRY); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_with_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res) { @@ -71171,7 +70010,6 @@ if (comp_ctx->curr_func.is_strict) { DUK_ERROR_SYNTAX(comp_ctx->thr, DUK_STR_WITH_IN_STRICT_MODE); - DUK_WO_NORETURN(return;); } comp_ctx->curr_func.catch_depth++; @@ -71182,8 +70020,7 @@ duk__advance_expect(comp_ctx, DUK_TOK_LPAREN); duk__exprtop_toforcedreg(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/, reg_catch); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); pc_trycatch = duk__get_current_pc(comp_ctx); trycatch_flags = DUK_BC_TRYCATCH_FLAG_WITH_BINDING; @@ -71195,7 +70032,8 @@ duk__emit_invalid(comp_ctx); /* finished jump */ duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); - duk__emit_op_only(comp_ctx, DUK_OP_ENDTRY); + duk__emit_op_only(comp_ctx, + DUK_OP_ENDTRY); pc_finished = duk__get_current_pc(comp_ctx); @@ -71362,14 +70200,13 @@ break; } else { DUK_ERROR_SYNTAX(thr, DUK_STR_FUNC_STMT_NOT_ALLOWED); - DUK_WO_NORETURN(return;); } break; } case DUK_TOK_LCURLY: { DUK_DDD(DUK_DDDPRINT("block statement")); duk__advance(comp_ctx); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ if (label_id >= 0) { duk__patch_jump_here(comp_ctx, pc_at_entry + 1); /* break jump */ @@ -71623,7 +70460,7 @@ */ if (DUK_HSTRING_GET_BYTELEN(h_dir) == 10 && - DUK_STRCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use strict") == 0) { + DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use strict", 10) == 0) { #if defined(DUK_USE_STRICT_DECL) DUK_DDD(DUK_DDDPRINT("use strict directive detected: strict flag %ld -> %ld", (long) comp_ctx->curr_func.is_strict, (long) 1)); @@ -71632,7 +70469,7 @@ DUK_DDD(DUK_DDDPRINT("use strict detected but strict declarations disabled, ignoring")); #endif } else if (DUK_HSTRING_GET_BYTELEN(h_dir) == 14 && - DUK_STRCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use duk notail") == 0) { + DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use duk notail", 14) == 0) { DUK_DDD(DUK_DDDPRINT("use duk notail directive detected: notail flag %ld -> %ld", (long) comp_ctx->curr_func.is_notail, (long) 1)); comp_ctx->curr_func.is_notail = 1; @@ -71700,7 +70537,6 @@ "even though no lineterm present before next token)")); } else { DUK_ERROR_SYNTAX(thr, DUK_STR_UNTERMINATED_STMT); - DUK_WO_NORETURN(return;); } } } else { @@ -71749,7 +70585,7 @@ * (EOF or closing brace). */ -DUK_LOCAL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof, duk_bool_t regexp_after) { +DUK_LOCAL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof) { duk_hthread *thr = comp_ctx->thr; duk_ivalue res_alloc; duk_ivalue *res = &res_alloc; @@ -71763,7 +70599,7 @@ * for nested functions (which may occur inside expressions). */ - duk_memzero(&res_alloc, sizeof(res_alloc)); + DUK_MEMZERO(&res_alloc, sizeof(res_alloc)); res->t = DUK_IVAL_PLAIN; res->x1.t = DUK_ISPEC_VALUE; res->x1.valstack_idx = duk_get_top(thr); @@ -71797,15 +70633,6 @@ duk__parse_stmt(comp_ctx, res, allow_source_elem); } - /* RegExp is allowed / not allowed depending on context. For function - * declarations RegExp is allowed because it follows a function - * declaration statement and may appear as part of the next statement. - * For function expressions RegExp is not allowed, and it's possible - * to do something like '(function () {} / 123)'. - */ - if (regexp_after) { - comp_ctx->curr_func.allow_regexp_in_adv = 1; - } duk__advance(comp_ctx); /* Tear down state. */ @@ -72129,11 +70956,13 @@ error_outofregs: DUK_ERROR_RANGE(thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); + return; error_argname: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_ARG_NAME); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); + return; } /* @@ -72170,7 +70999,7 @@ * token (EOF or closing brace). */ -DUK_LOCAL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_bool_t regexp_after, duk_small_int_t expect_token) { +DUK_LOCAL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_small_int_t expect_token) { duk_compiler_func *func; duk_hthread *thr; duk_regconst_t reg_stmt_value = -1; @@ -72242,9 +71071,7 @@ func->max_line = 0; #endif - /* duk__parse_stmts() expects curr_tok to be set; parse in "allow - * regexp literal" mode with current strictness. - */ + /* duk__parse_stmts() expects curr_tok to be set; parse in "allow regexp literal" mode with current strictness */ if (expect_token >= 0) { /* Eating a left curly; regexp mode is allowed by left curly * based on duk__token_lbp[] automatically. @@ -72263,8 +71090,7 @@ DUK_DDD(DUK_DDDPRINT("begin 1st pass")); duk__parse_stmts(comp_ctx, 1, /* allow source elements */ - expect_eof, /* expect EOF instead of } */ - regexp_after); /* regexp after */ + expect_eof); /* expect EOF instead of } */ DUK_DDD(DUK_DDDPRINT("end 1st pass")); /* @@ -72371,8 +71197,7 @@ DUK_DDD(DUK_DDDPRINT("begin 2nd pass")); duk__parse_stmts(comp_ctx, 1, /* allow source elements */ - expect_eof, /* expect EOF instead of } */ - regexp_after); /* regexp after */ + expect_eof); /* expect EOF instead of } */ DUK_DDD(DUK_DDDPRINT("end 2nd pass")); duk__update_lineinfo_currtoken(comp_ctx); @@ -72385,7 +71210,6 @@ /* Should never happen but avoid infinite loop just in case. */ DUK_D(DUK_DPRINT("more than 3 compile passes needed, should never happen")); DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); } DUK_D(DUK_DPRINT("need additional round to compile function, round now %d", (int) compile_round)); } @@ -72429,7 +71253,6 @@ error_funcname: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_FUNC_NAME); - DUK_WO_NORETURN(return;); } /* @@ -72478,7 +71301,6 @@ if (comp_ctx->curr_token.t != DUK_TOK_IDENTIFIER) { DUK_ERROR_SYNTAX(thr, DUK_STR_EXPECTED_IDENTIFIER); - DUK_WO_NORETURN(return;); } DUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_IDENTIFIER); DUK_ASSERT(comp_ctx->curr_token.str1 != NULL); @@ -72544,7 +71366,6 @@ duk_to_string(thr, -1); } else { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_GETSET_NAME); - DUK_WO_NORETURN(return;); } comp_ctx->curr_func.h_name = duk_known_hstring(thr, -1); /* borrowed reference */ } else { @@ -72562,7 +71383,6 @@ no_advance = 1; if (flags & DUK__FUNC_FLAG_DECL) { DUK_ERROR_SYNTAX(thr, DUK_STR_FUNC_NAME_REQUIRED); - DUK_WO_NORETURN(return;); } } } @@ -72596,7 +71416,6 @@ duk__parse_func_body(comp_ctx, 0, /* expect_eof */ 0, /* implicit_return_value */ - flags & DUK__FUNC_FLAG_DECL, /* regexp_after */ DUK_TOK_LCURLY); /* expect_token */ /* @@ -72649,14 +71468,6 @@ comp_ctx->curr_token.t = 0; /* this is needed for regexp mode */ comp_ctx->curr_token.start_line = 0; /* needed for line number tracking (becomes prev_token.start_line) */ duk__advance(comp_ctx); - - /* RegExp is not allowed after a function expression, e.g. in - * (function () {} / 123). A RegExp *is* allowed after a - * function declaration! - */ - if (flags & DUK__FUNC_FLAG_DECL) { - comp_ctx->curr_func.allow_regexp_in_adv = 1; - } duk__advance_expect(comp_ctx, DUK_TOK_RCURLY); return fnum; @@ -72671,9 +71482,9 @@ DUK_DDD(DUK_DDDPRINT("before func: entry_top=%ld, curr_tok.start_offset=%ld", (long) entry_top, (long) comp_ctx->curr_token.start_offset)); - duk_memcpy(&old_func, &comp_ctx->curr_func, sizeof(duk_compiler_func)); + DUK_MEMCPY(&old_func, &comp_ctx->curr_func, sizeof(duk_compiler_func)); - duk_memzero(&comp_ctx->curr_func, sizeof(duk_compiler_func)); + DUK_MEMZERO(&comp_ctx->curr_func, sizeof(duk_compiler_func)); duk__init_func_valstack_slots(comp_ctx); DUK_ASSERT(comp_ctx->curr_func.num_formals == 0); @@ -72715,7 +71526,6 @@ if (fnum > DUK__MAX_FUNCS) { DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_FUNC_LIMIT); - DUK_WO_NORETURN(return 0;); } /* array writes autoincrement length */ @@ -72740,7 +71550,7 @@ } else { duk_set_top(thr, entry_top); } - duk_memcpy((void *) &comp_ctx->curr_func, (void *) &old_func, sizeof(duk_compiler_func)); + DUK_MEMCPY((void *) &comp_ctx->curr_func, (void *) &old_func, sizeof(duk_compiler_func)); return fnum; } @@ -72749,7 +71559,7 @@ * Compile input string into an executable function template without * arguments. * - * The string is parsed as the "Program" production of ECMAScript E5. + * The string is parsed as the "Program" production of Ecmascript E5. * Compilation context can be either global code or eval code (see E5 * Sections 14 and 15.1.2.1). * @@ -72890,7 +71700,6 @@ duk__parse_func_body(comp_ctx, 1, /* expect_eof */ 1, /* implicit_return_value */ - 1, /* regexp_after (does not matter) */ -1); /* expect_token */ } @@ -72918,7 +71727,7 @@ DUK_ASSERT(src_buffer != NULL); /* preinitialize lexer state partially */ - duk_memzero(&comp_stk, sizeof(comp_stk)); + DUK_MEMZERO(&comp_stk, sizeof(comp_stk)); comp_stk.flags = flags; DUK_LEXER_INITCTX(&comp_stk.comp_ctx_alloc.lex); comp_stk.comp_ctx_alloc.lex.input = src_buffer; @@ -72935,7 +71744,6 @@ if (safe_rc != DUK_EXEC_SUCCESS) { DUK_D(DUK_DPRINT("compilation failed: %!T", duk_get_tval(thr, -1))); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } /* [ ... template ] */ @@ -73026,7 +71834,7 @@ #undef DUK__TOKEN_LBP_FLAG_UNUSED #undef DUK__TOKEN_LBP_GET_BP /* - * ECMAScript bytecode executor. + * Ecmascript bytecode executor. */ /* #include duk_internal.h -> already included */ @@ -73077,7 +71885,7 @@ tv_dst = thr->valstack_top; copy_size = sizeof(duk_tval) * count; - duk_memcpy((void *) tv_dst, (const void *) tv_src, copy_size); + DUK_MEMCPY((void *) tv_dst, (const void *) tv_src, copy_size); for (i = 0; i < count; i++) { DUK_TVAL_INCREF(thr, tv_dst); tv_dst++; @@ -73341,10 +72149,7 @@ break; } case DUK_OP_DIV >> 2: { - /* Division-by-zero is undefined behavior, so - * rely on a helper. - */ - du.d = duk_double_div(d1, d2); + du.d = d1 / d2; break; } case DUK_OP_MOD >> 2: { @@ -73801,7 +72606,7 @@ * top are combined into one pass. */ -/* Reconfigure value stack for return to an ECMAScript function at +/* Reconfigure value stack for return to an Ecmascript function at * callstack top (caller unwinds). */ DUK_LOCAL void duk__reconfig_valstack_ecma_return(duk_hthread *thr) { @@ -73817,7 +72622,7 @@ /* Clamp so that values at 'clamp_top' and above are wiped and won't * retain reachable garbage. Then extend to 'nregs' because we're - * returning to an ECMAScript function. + * returning to an Ecmascript function. */ h_func = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act); @@ -73833,7 +72638,7 @@ /* XXX: a best effort shrink check would be OK here */ } -/* Reconfigure value stack for an ECMAScript catcher. Use topmost catcher +/* Reconfigure value stack for an Ecmascript catcher. Use topmost catcher * in 'act'. */ DUK_LOCAL void duk__reconfig_valstack_ecma_catcher(duk_hthread *thr, duk_activation *act) { @@ -74069,7 +72874,7 @@ act_resumer = resumer->callstack_curr; DUK_ASSERT(act_resumer != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(act_resumer) != NULL); - DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(act_resumer))); /* resume caller must be an ECMAScript func */ + DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(act_resumer))); /* resume caller must be an ecmascript func */ tv1 = (duk_tval *) (void *) ((duk_uint8_t *) resumer->valstack + act_resumer->retval_byteoff); /* return value from Duktape.Thread.resume() */ DUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv_val_unstable); /* side effects */ /* XXX: avoid side effects */ @@ -74125,7 +72930,7 @@ /* duk_bi_duk_object_yield() and duk_bi_duk_object_resume() ensure all of these are met */ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); /* unchanged by Duktape.Thread.resume() */ - DUK_ASSERT(thr->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(thr->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(thr->callstack_curr != NULL); DUK_ASSERT(thr->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL && @@ -74143,7 +72948,7 @@ DUK_ASSERT(resumee->state == DUK_HTHREAD_STATE_INACTIVE || resumee->state == DUK_HTHREAD_STATE_YIELDED); /* checked by Duktape.Thread.resume() */ DUK_ASSERT(resumee->state != DUK_HTHREAD_STATE_YIELDED || - resumee->callstack_top >= 2); /* YIELDED: ECMAScript activation + Duktape.Thread.yield() activation */ + resumee->callstack_top >= 2); /* YIELDED: Ecmascript activation + Duktape.Thread.yield() activation */ DUK_ASSERT(resumee->state != DUK_HTHREAD_STATE_YIELDED || (DUK_ACT_GET_FUNC(resumee->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(resumee->callstack_curr)) && @@ -74181,8 +72986,8 @@ goto check_longjmp; } else if (resumee->state == DUK_HTHREAD_STATE_YIELDED) { /* Unwind previous Duktape.Thread.yield() call. The - * activation remaining must always be an ECMAScript - * call now (yield() accepts calls from ECMAScript + * activation remaining must always be an Ecmascript + * call now (yield() accepts calls from Ecmascript * only). */ duk_activation *act_resumee; @@ -74190,7 +72995,7 @@ DUK_ASSERT(resumee->callstack_top >= 2); act_resumee = resumee->callstack_curr; /* Duktape.Thread.yield() */ DUK_ASSERT(act_resumee != NULL); - act_resumee = act_resumee->parent; /* ECMAScript call site for yield() */ + act_resumee = act_resumee->parent; /* Ecmascript call site for yield() */ DUK_ASSERT(act_resumee != NULL); tv = (duk_tval *) (void *) ((duk_uint8_t *) resumee->valstack + act_resumee->retval_byteoff); /* return value from Duktape.Thread.yield() */ @@ -74238,7 +73043,6 @@ * executor which can be quite misleading. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); } DUK_ASSERT(resumee->resumer == NULL); @@ -74261,7 +73065,7 @@ case DUK_LJ_TYPE_YIELD: { /* * Currently only allowed only if yielding thread has only - * ECMAScript activations (except for the Duktape.Thread.yield() + * Ecmascript activations (except for the Duktape.Thread.yield() * call at the callstack top) and none of them constructor * calls. * @@ -74277,27 +73081,27 @@ DUK_ASSERT(thr != entry_thread); /* Duktape.Thread.yield() should prevent */ #endif DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); /* unchanged from Duktape.Thread.yield() */ - DUK_ASSERT(thr->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.yield() activation */ + DUK_ASSERT(thr->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.yield() activation */ DUK_ASSERT(thr->callstack_curr != NULL); DUK_ASSERT(thr->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr)) && ((duk_hnatfunc *) DUK_ACT_GET_FUNC(thr->callstack_curr))->func == duk_bi_thread_yield); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* an Ecmascript function */ resumer = thr->resumer; DUK_ASSERT(resumer != NULL); DUK_ASSERT(resumer->state == DUK_HTHREAD_STATE_RESUMED); /* written by a previous RESUME handling */ - DUK_ASSERT(resumer->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(resumer->callstack_curr != NULL); DUK_ASSERT(resumer->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(resumer->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(resumer->callstack_curr)) && ((duk_hnatfunc *) DUK_ACT_GET_FUNC(resumer->callstack_curr))->func == duk_bi_thread_resume); DUK_ASSERT(DUK_ACT_GET_FUNC(resumer->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(resumer->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(resumer->callstack_curr->parent))); /* an Ecmascript function */ if (thr->heap->lj.iserror) { thr->state = DUK_HTHREAD_STATE_YIELDED; @@ -74351,7 +73155,7 @@ * resumer in this case.) * * Note: until we hit the entry level, there can only be - * ECMAScript activations. + * Ecmascript activations. */ duk_activation *act; @@ -74418,11 +73222,11 @@ */ DUK_ASSERT(thr->resumer != NULL); - DUK_ASSERT(thr->resumer->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(thr->resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(thr->resumer->callstack_curr != NULL); DUK_ASSERT(thr->resumer->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an Ecmascript function */ resumer = thr->resumer; @@ -74475,7 +73279,8 @@ * infinite loop in this catchpoint. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); + return retval; } /* Handle a BREAK/CONTINUE opcode. Avoid using longjmp() for BREAK/CONTINUE @@ -74539,7 +73344,7 @@ /* Should never happen, but be robust. */ DUK_D(DUK_DPRINT("-> break/continue not caught by anything in the current function (should never happen), throw internal error")); DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); + return; } /* Handle a RETURN opcode. Avoid using longjmp() for return handling because @@ -74574,7 +73379,7 @@ * 2. The return happens at the entry level of the bytecode * executor, so return from the executor (in C stack). * - * 3. There is a calling (ECMAScript) activation in the call + * 3. There is a calling (Ecmascript) activation in the call * stack => return to it, in the same executor instance. * * 4. There is no calling activation, and the thread is @@ -74619,16 +73424,16 @@ } if (thr->callstack_top >= 2) { - /* There is a caller; it MUST be an ECMAScript caller (otherwise it would + /* There is a caller; it MUST be an Ecmascript caller (otherwise it would * match entry_act check). */ - DUK_DDD(DUK_DDDPRINT("return to ECMAScript caller, retval_byteoff=%ld, lj_value1=%!T", + DUK_DDD(DUK_DDDPRINT("return to Ecmascript caller, retval_byteoff=%ld, lj_value1=%!T", (long) (thr->callstack_curr->parent->retval_byteoff), (duk_tval *) &thr->heap->lj.value1)); DUK_ASSERT(thr->callstack_curr != NULL); DUK_ASSERT(thr->callstack_curr->parent != NULL); - DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* must be ECMAScript */ + DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* must be ecmascript */ #if defined(DUK_USE_ES6_PROXY) if (thr->callstack_curr->flags & (DUK_ACT_FLAG_CONSTRUCT | DUK_ACT_FLAG_CONSTRUCT_PROXY)) { @@ -74658,51 +73463,31 @@ DUK_DD(DUK_DDPRINT("no calling activation, thread finishes (similar to yield)")); DUK_ASSERT(thr->resumer != NULL); - DUK_ASSERT(thr->resumer->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(thr->resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(thr->resumer->callstack_curr != NULL); DUK_ASSERT(thr->resumer->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr)) && ((duk_hnatfunc *) DUK_ACT_GET_FUNC(thr->resumer->callstack_curr))->func == duk_bi_thread_resume); /* Duktape.Thread.resume() */ DUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an Ecmascript function */ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); DUK_ASSERT(thr->resumer->state == DUK_HTHREAD_STATE_RESUMED); resumer = thr->resumer; - /* Share yield longjmp handler. - * - * This sequence of steps is a bit fragile (see GH-1845): - * - We need the return value from 'thr' (resumed thread) value stack. - * The termination unwinds its value stack, losing the value. - * - We need a refcounted reference for 'thr', which may only exist - * in the caller value stack. We can't unwind or reconfigure the - * caller's value stack without potentially freeing 'thr'. - * - * Current approach is to capture the 'thr' return value and store - * a reference to 'thr' in the caller value stack temporarily. This - * keeps 'thr' reachable until final yield/return handling which - * removes the references atomatically. - */ - + /* Share yield longjmp handler. */ DUK_ASSERT(thr->valstack_top - 1 >= thr->valstack_bottom); - duk_hthread_activation_unwind_norz(resumer); /* May remove last reference to 'thr', but is NORZ. */ - duk_push_tval(resumer, thr->valstack_top - 1); /* Capture return value, side effect free. */ - duk_push_hthread(resumer, thr); /* Make 'thr' reachable again, before side effects. */ + duk_hthread_activation_unwind_norz(resumer); + duk__handle_yield(thr, resumer, thr->valstack_top - 1); - duk_hthread_terminate(thr); /* Updates thread state, minimizes its allocations. */ - thr->resumer = NULL; - DUK_HTHREAD_DECREF(thr, resumer); + duk_hthread_terminate(thr); /* updates thread state, minimizes its allocations */ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_TERMINATED); + thr->resumer = NULL; + DUK_HTHREAD_DECREF(thr, resumer); resumer->state = DUK_HTHREAD_STATE_RUNNING; DUK_HEAP_SWITCH_THREAD(thr->heap, resumer); - - DUK_ASSERT(resumer->valstack_top - 2 >= resumer->valstack_bottom); - duk__handle_yield(thr, resumer, resumer->valstack_top - 2); - thr = NULL; /* 'thr' invalidated by call */ - #if 0 thr = resumer; /* not needed */ #endif @@ -74712,7 +73497,7 @@ #else /* Without coroutine support this case should never happen. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + return DUK__RETHAND_FINISHED; /* not executed */ #endif } @@ -74862,7 +73647,7 @@ if (diff_last < 0.0 || diff_last >= (duk_double_t) DUK_HEAP_DBG_RATELIMIT_MILLISECS) { /* Monotonic time should not experience time jumps, * but the provider may be missing and we're actually - * using ECMAScript time. So, tolerate negative values + * using Ecmascript time. So, tolerate negative values * so that a time jump works reasonably. * * Same interval is now used for status sending and @@ -75011,7 +73796,6 @@ thr->interrupt_counter = 0; DUK_HEAP_CLEAR_INTERRUPT_RUNNING(thr->heap); DUK_ERROR_RANGE(thr, "execution timeout"); - DUK_WO_NORETURN(return 0;); } #endif /* DUK_USE_EXEC_TIMEOUT_CHECK */ @@ -75697,7 +74481,7 @@ } /* - * ECMAScript bytecode executor. + * Ecmascript bytecode executor. * * Resume execution for the current thread from its current activation. * Returns when execution would return from the entry level activation, @@ -75706,7 +74490,7 @@ * a longjmp() with type DUK_LJ_TYPE_THROW is called on the entry level * setjmp() jmpbuf. * - * ECMAScript function calls and coroutine resumptions are handled + * Ecmascript function calls and coroutine resumptions are handled * internally (by the outer executor function) without recursive C calls. * Other function calls are handled using duk_handle_call(), increasing * C recursion depth. @@ -75799,7 +74583,6 @@ #if defined(DUK_USE_VERBOSE_EXECUTOR_ERRORS) #define DUK__INTERNAL_ERROR(msg) do { \ DUK_ERROR_ERROR(thr, (msg)); \ - DUK_WO_NORETURN(return;); \ } while (0) #else #define DUK__INTERNAL_ERROR(msg) do { \ @@ -75964,10 +74747,7 @@ entry_jmpbuf_ptr); } #if defined(DUK_USE_CPP_EXCEPTIONS) - catch (duk_fatal_exception &exc) { - DUK_D(DUK_DPRINT("rethrow duk_fatal_exception")); - throw; - } catch (std::exception &exc) { + catch (std::exception &exc) { const char *what = exc.what(); if (!what) { what = "unknown"; @@ -75977,7 +74757,6 @@ try { DUK_ASSERT(heap->curr_thread != NULL); DUK_ERROR_FMT1(heap->curr_thread, DUK_ERR_TYPE_ERROR, "caught invalid c++ std::exception '%s' (perhaps thrown by user code)", what); - DUK_WO_NORETURN(return;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ std::exception")); DUK_UNREF(exc); @@ -75992,7 +74771,6 @@ try { DUK_ASSERT(heap->curr_thread != NULL); DUK_ERROR_TYPE(heap->curr_thread, "caught invalid c++ exception (perhaps thrown by user code)"); - DUK_WO_NORETURN(return;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ exception")); DUK_UNREF(exc); @@ -76005,7 +74783,7 @@ #endif } - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); } /* Inner executor, performance critical. */ @@ -76374,7 +75152,7 @@ /* XXX: fast double-to-int conversion, we know number is integer in [-0x80000000,0xffffffff]. */ val = (duk_int32_t) DUK_TVAL_GET_NUMBER(tv1); #endif - val = (duk_int32_t) ((duk_uint32_t) val << DUK_BC_LDINTX_SHIFT) + (duk_int32_t) DUK_DEC_BC(ins); /* no bias */ + val = (val << DUK_BC_LDINTX_SHIFT) + (duk_int32_t) DUK_DEC_BC(ins); /* no bias */ DUK_TVAL_SET_I32_UPDREF(thr, tv1, val); /* side effects */ break; } @@ -78029,7 +76807,7 @@ case DUK_OP_INVLHS: { DUK_ERROR_REFERENCE(thr, DUK_STR_INVALID_LVALUE); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); break; } @@ -78064,13 +76842,45 @@ case DUK_OP_INVALID: { DUK_ERROR_FMT1(thr, DUK_ERR_ERROR, "INVALID opcode (%ld)", (long) DUK_DEC_ABC(ins)); - DUK_WO_NORETURN(return;); break; } #if defined(DUK_USE_ES6) case DUK_OP_NEWTARGET: { - duk_push_new_target(thr); + /* https://www.ecma-international.org/ecma-262/6.0/#sec-meta-properties-runtime-semantics-evaluation + * https://www.ecma-international.org/ecma-262/6.0/#sec-getnewtarget + * + * No newTarget support now, so as a first approximation + * use the resolved (non-bound) target function. + */ + /* XXX: C API: push_new_target()? */ + duk_activation *act; + + act = thr->callstack_curr; + DUK_ASSERT(act != NULL); + + /* Check CONSTRUCT flag from current function, or if running + * direct eval, from a non-direct-eval parent (with possibly + * more than one nested direct eval). An alternative to this + * would be to store [[NewTarget]] as a hidden symbol of the + * lexical scope, and then just look up that variable. + */ + for (;;) { + if (act == NULL) { + duk_push_undefined(thr); + break; + } + if (act->flags & DUK_ACT_FLAG_CONSTRUCT) { + duk_push_tval(thr, &act->tv_func); + break; + } else if (act->flags & DUK_ACT_FLAG_DIRECT_EVAL) { + act = act->parent; + } else { + duk_push_undefined(thr); + break; + } + } + DUK__REPLACE_TOP_BC_BREAK(); } #endif /* DUK_USE_ES6 */ @@ -78172,12 +76982,11 @@ continue; #endif } - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); #if !defined(DUK_USE_VERBOSE_EXECUTOR_ERRORS) internal_error: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); #endif } @@ -78246,9 +77055,9 @@ #undef DUK__SYNC_CURR_PC #undef DUK__TVAL_SHIFT /* - * ECMAScript specification algorithm and conversion helpers. + * Ecmascript specification algorithm and conversion helpers. * - * These helpers encapsulate the primitive ECMAScript operation semantics, + * These helpers encapsulate the primitive Ecmascript operation semantics, * and are used by the bytecode executor and the API (among other places). * Some primitives are only implemented as part of the API and have no * "internal" helper. This is the case when an internal helper would not @@ -78464,7 +77273,6 @@ duk_hstring *h = DUK_TVAL_GET_STRING(tv); if (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_CANNOT_NUMBER_COERCE_SYMBOL); - DUK_WO_NORETURN(return 0.0;); } duk_push_hstring(thr, h); return duk__tonumber_string_raw(thr); @@ -78680,7 +77488,7 @@ return 0; #else /* DUK_USE_PARANOID_MATH */ /* Better equivalent algorithm. If the compiler is compliant, C and - * ECMAScript semantics are identical for this particular comparison. + * Ecmascript semantics are identical for this particular comparison. * In particular, NaNs must never compare equal and zeroes must compare * equal regardless of sign. Could also use a macro, but this inlines * already nicely (no difference on gcc, for instance). @@ -78973,12 +77781,12 @@ prefix_len = (len1 <= len2 ? len1 : len2); - /* duk_memcmp() is guaranteed to return zero (equal) for zero length - * inputs. + /* DUK_MEMCMP() is guaranteed to return zero (equal) for zero length + * inputs so no zero length check is needed. */ - rc = duk_memcmp_unsafe((const void *) buf1, - (const void *) buf2, - (size_t) prefix_len); + rc = DUK_MEMCMP((const void *) buf1, + (const void *) buf2, + (size_t) prefix_len); if (rc < 0) { return -1; @@ -79245,19 +78053,22 @@ */ /* - * ES2015 Section 7.3.19 describes the OrdinaryHasInstance() algorithm - * which covers both bound and non-bound functions; in effect the algorithm - * includes E5 Sections 11.8.6, 15.3.5.3, and 15.3.4.5.3. - * - * ES2015 Section 12.9.4 describes the instanceof operator which first - * checks @@hasInstance well-known symbol and falls back to - * OrdinaryHasInstance(). + * E5 Section 11.8.6 describes the main algorithm, which uses + * [[HasInstance]]. [[HasInstance]] is defined for only + * function objects: + * + * - Normal functions: + * E5 Section 15.3.5.3 + * - Functions established with Function.prototype.bind(): + * E5 Section 15.3.4.5.3 + * + * For other objects, a TypeError is thrown. * * Limited Proxy support: don't support 'getPrototypeOf' trap but * continue lookup in Proxy target if the value is a Proxy. */ -DUK_LOCAL duk_bool_t duk__js_instanceof_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_bool_t skip_sym_check) { +DUK_INTERNAL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) { duk_hobject *func; duk_hobject *val; duk_hobject *proto; @@ -79280,23 +78091,6 @@ func = duk_require_hobject(thr, -1); DUK_ASSERT(func != NULL); -#if defined(DUK_USE_SYMBOL_BUILTIN) - /* - * @@hasInstance check, ES2015 Section 12.9.4, Steps 2-4. - */ - if (!skip_sym_check) { - if (duk_get_method_stridx(thr, -1, DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE)) { - /* [ ... lhs rhs func ] */ - duk_insert(thr, -3); /* -> [ ... func lhs rhs ] */ - duk_swap_top(thr, -2); /* -> [ ... func rhs(this) lhs ] */ - duk_call_method(thr, 1); - return duk_to_boolean_top_pop(thr); - } - } -#else - DUK_UNREF(skip_sym_check); -#endif - /* * For bound objects, [[HasInstance]] just calls the target function * [[HasInstance]]. If that is again a bound object, repeat until @@ -79308,7 +78102,7 @@ if (!DUK_HOBJECT_IS_CALLABLE(func)) { /* - * Note: of native ECMAScript objects, only Function instances + * Note: of native Ecmascript objects, only Function instances * have a [[HasInstance]] internal property. Custom objects might * also have it, but not in current implementation. * @@ -79318,7 +78112,7 @@ } if (DUK_HOBJECT_HAS_BOUNDFUNC(func)) { - duk_push_tval(thr, &((duk_hboundfunc *) (void *) func)->target); + duk_push_tval(thr, &((duk_hboundfunc *) func)->target); duk_replace(thr, -2); func = duk_require_hobject(thr, -1); /* lightfunc throws */ @@ -79423,7 +78217,6 @@ if (DUK_UNLIKELY(sanity == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } DUK_UNREACHABLE(); @@ -79441,23 +78234,13 @@ error_invalid_rval: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_INSTANCEOF_RVAL); - DUK_WO_NORETURN(return 0;); + return 0; #if defined(DUK_USE_VERBOSE_ERRORS) error_invalid_rval_noproto: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_INSTANCEOF_RVAL_NOPROTO); - DUK_WO_NORETURN(return 0;); -#endif -} - -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL duk_bool_t duk_js_instanceof_ordinary(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) { - return duk__js_instanceof_helper(thr, tv_x, tv_y, 1 /*skip_sym_check*/); -} + return 0; #endif - -DUK_INTERNAL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) { - return duk__js_instanceof_helper(thr, tv_x, tv_y, 0 /*skip_sym_check*/); } /* @@ -79710,7 +78493,7 @@ * be used for most identifier accesses. Consequently, these slow path * primitives should be optimized for maximum compactness. * - * ECMAScript environment records (declarative and object) are represented + * Ecmascript environment records (declarative and object) are represented * as internal objects with control keys. Environment records have a * parent record ("outer environment reference") which is represented by * the implicit prototype for technical reasons (in other words, it is a @@ -79752,7 +78535,7 @@ * Create a new function object based on a "template function" which contains * compiled bytecode, constants, etc, but lacks a lexical environment. * - * ECMAScript requires that each created closure is a separate object, with + * Ecmascript requires that each created closure is a separate object, with * its own set of editable properties. However, structured property values * (such as the formal arguments list and the variable map) are shared. * Also the bytecode, constants, and inner functions are shared. @@ -80761,7 +79544,6 @@ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } env = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, env); } @@ -80901,7 +79683,6 @@ DUK_ERROR_FMT1(thr, DUK_ERR_REFERENCE_ERROR, "identifier '%s' undefined", (const char *) DUK_HSTRING_GET_DATA(name)); - DUK_WO_NORETURN(return 0;); } return 0; @@ -81026,7 +79807,6 @@ DUK_ERROR_FMT1(thr, DUK_ERR_REFERENCE_ERROR, "identifier '%s' undefined", (const char *) DUK_HSTRING_GET_DATA(name)); - DUK_WO_NORETURN(return;); } DUK_DDD(DUK_DDDPRINT("identifier binding not found, not strict => set to global")); @@ -81417,7 +80197,7 @@ fail_existing_attributes: fail_not_extensible: DUK_ERROR_TYPE(thr, "declaration failed"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL @@ -81462,7 +80242,7 @@ * Lexer for source files, ToNumber() string conversions, RegExp expressions, * and JSON. * - * Provides a stream of ECMAScript tokens from an UTF-8/CESU-8 buffer. The + * Provides a stream of Ecmascript tokens from an UTF-8/CESU-8 buffer. The * caller can also rewind the token stream into a certain position which is * needed by the compiler part for multi-pass scanning. Tokens are * represented as duk_token structures, and contain line number information. @@ -81485,14 +80265,14 @@ * * Token parsing supports the full range of Unicode characters as described * in the E5 specification. Parsing has been optimized for ASCII characters - * because ordinary ECMAScript code consists almost entirely of ASCII + * because ordinary Ecmascript code consists almost entirely of ASCII * characters. Matching of complex Unicode codepoint sets (such as in the * IdentifierStart and IdentifierPart productions) is optimized for size, * and is done using a linear scan of a bit-packed list of ranges. This is * very slow, but should never be entered unless the source code actually * contains Unicode characters. * - * ECMAScript tokenization is partially context sensitive. First, + * Ecmascript tokenization is partially context sensitive. First, * additional future reserved words are recognized in strict mode (see E5 * Section 7.6.1.2). Second, a forward slash character ('/') can be * recognized either as starting a RegExp literal or as a division operator, @@ -81589,7 +80369,7 @@ * * * In particular, surrogate pairs are allowed and not combined, which * allows source files to represent all SourceCharacters with CESU-8. - * Broken surrogate pairs are allowed, as ECMAScript does not mandate + * Broken surrogate pairs are allowed, as Ecmascript does not mandate * their validation. * * * Allow non-shortest UTF-8 encodings. @@ -81597,20 +80377,20 @@ * Leniency here causes few security concerns because all character data is * decoded into Unicode codepoints before lexer processing, and is then * re-encoded into CESU-8. The source can be parsed as strict UTF-8 with - * a compiler option. However, ECMAScript source characters include -all- + * a compiler option. However, Ecmascript source characters include -all- * 16-bit unsigned integer codepoints, so leniency seems to be appropriate. * * Note that codepoints above the BMP are not strictly SourceCharacters, * but the lexer still accepts them as such. Before ending up in a string * or an identifier name, codepoints above BMP are converted into surrogate * pairs and then CESU-8 encoded, resulting in 16-bit Unicode data as - * expected by ECMAScript. + * expected by Ecmascript. * * An alternative approach to dealing with invalid or partial sequences * would be to skip them and replace them with e.g. the Unicode replacement * character U+FFFD. This has limited utility because a replacement character * will most likely cause a parse error, unless it occurs inside a string. - * Further, ECMAScript source is typically pure ASCII. + * Further, Ecmascript source is typically pure ASCII. * * See: * @@ -81773,7 +80553,6 @@ lex_ctx->input_line = input_line; DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_SOURCE_DECODE_FAILED); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__advance_bytes(duk_lexer_ctx *lex_ctx, duk_small_uint_t count_bytes) { @@ -81796,7 +80575,7 @@ /* Not enough data to provide a full window, so "scroll" window to * start of buffer and fill up the rest. */ - duk_memmove((void *) lex_ctx->buffer, + DUK_MEMMOVE((void *) lex_ctx->buffer, (const void *) lex_ctx->window, (size_t) avail_bytes); lex_ctx->window = lex_ctx->buffer; @@ -81934,7 +80713,7 @@ error_clipped: /* clipped codepoint */ error_encoding: /* invalid codepoint encoding or codepoint */ DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_SOURCE_DECODE_FAILED); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_LOCAL void duk__advance_bytes(duk_lexer_ctx *lex_ctx, duk_small_uint_t count_bytes) { @@ -81947,7 +80726,7 @@ /* Zero 'count' is also allowed to make call sites easier. */ keep_bytes = DUK_LEXER_WINDOW_SIZE * sizeof(duk_lexer_codepoint) - count_bytes; - duk_memmove((void *) lex_ctx->window, + DUK_MEMMOVE((void *) lex_ctx->window, (const void *) ((duk_uint8_t *) lex_ctx->window + count_bytes), (size_t) keep_bytes); @@ -82036,7 +80815,7 @@ DUK_INTERNAL void duk_lexer_initctx(duk_lexer_ctx *lex_ctx) { DUK_ASSERT(lex_ctx != NULL); - duk_memzero(lex_ctx, sizeof(*lex_ctx)); + DUK_MEMZERO(lex_ctx, sizeof(*lex_ctx)); #if defined(DUK_USE_EXPLICIT_NULL_INIT) #if defined(DUK_USE_LEXER_SLIDING_WINDOW) lex_ctx->window = NULL; @@ -82201,7 +80980,6 @@ fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE); - DUK_WO_NORETURN(return 0;); } /* Parse legacy octal escape of the form \N{1,3}, e.g. \0, \5, \0377. Maximum @@ -82398,11 +81176,11 @@ fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_unterminated: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_STRING); - DUK_WO_NORETURN(return;); + return; } /* Skip to end-of-line (or end-of-file), used for single line comments. */ @@ -82419,7 +81197,7 @@ } /* - * Parse ECMAScript source InputElementDiv or InputElementRegExp + * Parse Ecmascript source InputElementDiv or InputElementRegExp * (E5 Section 7), skipping whitespace, comments, and line terminators. * * Possible results are: @@ -82446,13 +81224,13 @@ * lookup window to quickly determine which production is the -longest- * matching one, and then parse that. The top-level if-else clauses * match the first character, and the code blocks for each clause - * handle -all- alternatives for that first character. ECMAScript + * handle -all- alternatives for that first character. Ecmascript * specification uses the "longest match wins" semantics, so the order * of the if-clauses matters. * * Misc notes: * - * * ECMAScript numeric literals do not accept a sign character. + * * Ecmascript numeric literals do not accept a sign character. * Consequently e.g. "-1.0" is parsed as two tokens: a negative * sign and a positive numeric literal. The compiler performs * the negation during compilation, so this has no adverse impact. @@ -82962,7 +81740,7 @@ * (the tokens DUK_TOK_GET and DUK_TOK_SET are actually not * used now). The compiler needs to work around this. * - * Strictly speaking, following ECMAScript longest match + * Strictly speaking, following Ecmascript longest match * specification, an invalid escape for the first character * should cause a syntax error. However, an invalid escape * for IdentifierParts should just terminate the identifier @@ -83246,32 +82024,32 @@ fail_token_limit: DUK_ERROR_RANGE(lex_ctx->thr, DUK_STR_TOKEN_LIMIT); - DUK_WO_NORETURN(return;); + return; fail_token: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_TOKEN); - DUK_WO_NORETURN(return;); + return; fail_number_literal: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_NUMBER_LITERAL); - DUK_WO_NORETURN(return;); + return; fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_unterm_regexp: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_REGEXP); - DUK_WO_NORETURN(return;); + return; fail_unterm_comment: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_COMMENT); - DUK_WO_NORETURN(return;); + return; #if !defined(DUK_USE_REGEXP_SUPPORT) fail_regexp_support: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_REGEXP_SUPPORT_DISABLED); - DUK_WO_NORETURN(return;); + return; #endif } @@ -83294,7 +82072,7 @@ goto fail_token_limit; } - duk_memzero(out_token, sizeof(*out_token)); + DUK_MEMZERO(out_token, sizeof(*out_token)); x = DUK__L0(); y = DUK__L1(); @@ -83619,24 +82397,24 @@ fail_token_limit: DUK_ERROR_RANGE(lex_ctx->thr, DUK_STR_TOKEN_LIMIT); - DUK_WO_NORETURN(return;); + return; fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_group: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_GROUP); - DUK_WO_NORETURN(return;); + return; #if !defined(DUK_USE_ES6_REGEXP_SYNTAX) fail_invalid_char: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_CHARACTER); - DUK_WO_NORETURN(return;); + return; fail_quantifier: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_QUANTIFIER); - DUK_WO_NORETURN(return;); + return; #endif } @@ -83885,15 +82663,15 @@ fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_range: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_RANGE); - DUK_WO_NORETURN(return;); + return; fail_unterm_charclass: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_CHARCLASS); - DUK_WO_NORETURN(return;); + return; } #endif /* DUK_USE_REGEXP_SUPPORT */ @@ -84054,8 +82832,10 @@ n = y->n; x->n = n; - /* No need to special case n == 0. */ - duk_memcpy((void *) x->v, (const void *) y->v, (size_t) (sizeof(duk_uint32_t) * (size_t) n)); + if (n == 0) { + return; + } + DUK_MEMCPY((void *) x->v, (const void *) y->v, (size_t) (sizeof(duk_uint32_t) * (size_t) n)); } DUK_LOCAL void duk__bi_set_small(duk__bigint *x, duk_uint32_t v) { @@ -84331,7 +83111,7 @@ return; } - duk_memzero((void *) x->v, (size_t) (sizeof(duk_uint32_t) * (size_t) nx)); + DUK_MEMZERO((void *) x->v, (size_t) (sizeof(duk_uint32_t) * (size_t) nx)); x->n = nx; nz = z->n; @@ -84481,7 +83261,7 @@ n = (y / 32) + 1; DUK_ASSERT(n > 0); r = y % 32; - duk_memzero((void *) x->v, sizeof(duk_uint32_t) * (size_t) n); + DUK_MEMZERO((void *) x->v, sizeof(duk_uint32_t) * (size_t) n); x->n = n; x->v[n - 1] = (((duk_uint32_t) 1) << r); } @@ -84595,7 +83375,6 @@ duk_small_int_t dig; duk_uint32_t t; - DUK_ASSERT(buf != NULL); DUK_ASSERT(radix >= 2 && radix <= 36); /* A 32-bit unsigned integer formats to at most 32 digits (the @@ -84618,7 +83397,7 @@ } len = (duk_size_t) ((buf + 32) - p); - duk_memmove((void *) buf, (const void *) p, (size_t) len); + DUK_MEMMOVE((void *) buf, (const void *) p, (size_t) len); return len; } @@ -85021,7 +83800,7 @@ { duk_uint8_t buf[2048]; duk_small_int_t i, t; - duk_memzero(buf, sizeof(buf)); + DUK_MEMZERO(buf, sizeof(buf)); for (i = 0; i < nc_ctx->count; i++) { t = nc_ctx->digits[i]; if (t < 0 || t > 36) { @@ -85086,7 +83865,7 @@ *p = 0; if (p == &nc_ctx->digits[0]) { DUK_DDD(DUK_DDDPRINT("carry propagated to first digit -> special case handling")); - duk_memmove((void *) (&nc_ctx->digits[1]), + DUK_MEMMOVE((void *) (&nc_ctx->digits[1]), (const void *) (&nc_ctx->digits[0]), (size_t) (sizeof(char) * (size_t) nc_ctx->count)); nc_ctx->digits[0] = 1; /* don't increase 'count' */ @@ -85130,7 +83909,7 @@ duk_uint8_t *buf; /* - * The string conversion here incorporates all the necessary ECMAScript + * The string conversion here incorporates all the necessary Ecmascript * semantics without attempting to be generic. nc_ctx->digits contains * nc_ctx->count digits (>= 1), with the topmost digit's 'position' * indicated by nc_ctx->k as follows: @@ -85141,11 +83920,11 @@ * digits="123" count=3 k=-1 --> 0.0123 * * Note that the identifier names used for format selection are different - * in Burger-Dybvig paper and ECMAScript specification (quite confusingly + * in Burger-Dybvig paper and Ecmascript specification (quite confusingly * so, because e.g. 'k' has a totally different meaning in each). See * documentation for discussion. * - * ECMAScript doesn't specify any specific behavior for format selection + * Ecmascript doesn't specify any specific behavior for format selection * (e.g. when to use exponent notation) for non-base-10 numbers. * * The bigint space in the context is reused for string output, as there @@ -85229,7 +84008,7 @@ /* Exponent */ if (expt != DUK__NO_EXP) { /* - * Exponent notation for non-base-10 numbers isn't specified in ECMAScript + * Exponent notation for non-base-10 numbers isn't specified in Ecmascript * specification, as it never explicitly turns up: non-decimal numbers can * only be formatted with Number.prototype.toString([radix]) and for that, * behavior is not explicitly specified. @@ -85331,7 +84110,7 @@ * (perhaps because the low part is set (seemingly) conditionally in a * loop), so this is here to avoid the bogus warning. */ - duk_memzero((void *) &u, sizeof(u)); + DUK_MEMZERO((void *) &u, sizeof(u)); /* * Figure out how generated digits match up with the mantissa, @@ -85514,7 +84293,7 @@ * sprintf "%lu" for the fast path and for exponent formatting. */ - uval = duk_double_to_uint32_t(x); + uval = (unsigned int) x; if (((double) uval) == x && /* integer number in range */ flags == 0) { /* no special formatting */ /* use bigint area as a temp */ @@ -85546,7 +84325,7 @@ * is 1-2 kilobytes and nothing should rely on it being zeroed. */ #if 0 - duk_memzero((void *) nc_ctx, sizeof(*nc_ctx)); /* slow init, do only for slow path cases */ + DUK_MEMZERO((void *) nc_ctx, sizeof(*nc_ctx)); /* slow init, do only for slow path cases */ #endif nc_ctx->is_s2n = 0; @@ -85586,7 +84365,7 @@ } DUK_DDD(DUK_DDDPRINT("count=%ld", (long) count)); DUK_ASSERT(count >= 1); - duk_memzero((void *) nc_ctx->digits, (size_t) count); + DUK_MEMZERO((void *) nc_ctx->digits, (size_t) count); nc_ctx->count = count; nc_ctx->k = 1; /* 0.000... */ neg = 0; @@ -85666,8 +84445,8 @@ duk__numconv_stringify_ctx *nc_ctx = &nc_ctx_alloc; duk_double_t res; duk_hstring *h_str; - duk_int_t expt; - duk_bool_t expt_neg; + duk_small_int_t expt; + duk_small_int_t expt_neg; duk_small_int_t expt_adj; duk_small_int_t neg; duk_small_int_t dig; @@ -85803,7 +84582,7 @@ * accuracy, so that Dragon4 will generate enough binary output digits. * For decimal numbers, this means generating a 20-digit significand, * which should yield enough practical accuracy to parse IEEE doubles. - * In fact, the ECMAScript specification explicitly allows an + * In fact, the Ecmascript specification explicitly allows an * implementation to treat digits beyond 20 as zeroes (and even * to round the 20th digit upwards). For non-decimal numbers, the * appropriate number of digits has been precomputed for comparable @@ -85974,10 +84753,9 @@ } else { /* exponent digit */ - DUK_ASSERT(radix == 10); expt = expt * radix + dig; if (expt > DUK_S2N_MAX_EXPONENT) { - /* Impose a reasonable exponent limit, so that exp + /* impose a reasonable exponent limit, so that exp * doesn't need to get tracked using a bigint. */ DUK_DDD(DUK_DDDPRINT("parse failed: exponent too large")); @@ -86180,7 +84958,7 @@ parse_explimit_error: DUK_DDD(DUK_DDDPRINT("parse failed, internal error, can't return a value")); DUK_ERROR_RANGE(thr, "exponent too large"); - DUK_WO_NORETURN(return;); + return; } /* automatic undefs */ @@ -86721,7 +85499,6 @@ if (re_ctx->recursion_depth >= re_ctx->recursion_limit) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_COMPILER_RECURSION_LIMIT); - DUK_WO_NORETURN(return;); } re_ctx->recursion_depth++; @@ -86795,11 +85572,9 @@ case DUK_RETOK_QUANTIFIER: { if (atom_start_offset < 0) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_INVALID_QUANTIFIER_NO_ATOM); - DUK_WO_NORETURN(return;); } if (re_ctx->curr_token.qmin > re_ctx->curr_token.qmax) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_INVALID_QUANTIFIER_VALUES); - DUK_WO_NORETURN(return;); } if (atom_char_length >= 0) { /* @@ -86868,7 +85643,6 @@ re_ctx->curr_token.qmin : re_ctx->curr_token.qmax; if (atom_copies > DUK_RE_MAX_ATOM_COPIES) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_QUANTIFIER_TOO_MANY_COPIES); - DUK_WO_NORETURN(return;); } /* wipe the capture range made by the atom (if any) */ @@ -87132,20 +85906,17 @@ case DUK_RETOK_ATOM_END_GROUP: { if (expect_eof) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_CLOSING_PAREN); - DUK_WO_NORETURN(return;); } goto done; } case DUK_RETOK_EOF: { if (!expect_eof) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_END_OF_PATTERN); - DUK_WO_NORETURN(return;); } goto done; } default: { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_REGEXP_TOKEN); - DUK_WO_NORETURN(return;); } } @@ -87240,7 +86011,7 @@ flags_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_REGEXP_FLAGS); - DUK_WO_NORETURN(return 0U;); + return 0; /* never here */ } /* @@ -87277,7 +86048,7 @@ n = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h); if (n == 0) { - duk_push_literal(thr, "(?:)"); + duk_push_string(thr, "(?:)"); return; } @@ -87357,7 +86128,7 @@ /* [ ... pattern flags escaped_source buffer ] */ - duk_memzero(&re_ctx, sizeof(re_ctx)); + DUK_MEMZERO(&re_ctx, sizeof(re_ctx)); DUK_LEXER_INITCTX(&re_ctx.lex); /* duplicate zeroing, expect for (possible) NULL inits */ re_ctx.thr = thr; re_ctx.lex.thr = thr; @@ -87404,7 +86175,6 @@ if (re_ctx.highest_backref > re_ctx.captures) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_BACKREFS); - DUK_WO_NORETURN(return;); } /* @@ -87488,7 +86258,7 @@ /* * Regexp executor. * - * Safety: the ECMAScript executor should prevent user from reading and + * Safety: the Ecmascript executor should prevent user from reading and * replacing regexp bytecode. Even so, the executor must validate all * memory accesses etc. When an invalid access is detected (e.g. a 'save' * opcode to invalid, unallocated index) it should fail with an internal @@ -87555,7 +86325,7 @@ fail: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } DUK_LOCAL const duk_uint8_t *duk__utf8_advance(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_uint_fast32_t count) { @@ -87586,7 +86356,7 @@ fail: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } /* @@ -87635,7 +86405,6 @@ DUK_LOCAL const duk_uint8_t *duk__match_regexp(duk_re_matcher_ctx *re_ctx, const duk_uint8_t *pc, const duk_uint8_t *sp) { if (re_ctx->recursion_depth >= re_ctx->recursion_limit) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_EXECUTOR_RECURSION_LIMIT); - DUK_WO_NORETURN(return NULL;); } re_ctx->recursion_depth++; @@ -87644,7 +86413,6 @@ if (re_ctx->steps_count >= re_ctx->steps_limit) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_EXECUTOR_STEP_LIMIT); - DUK_WO_NORETURN(return NULL;); } re_ctx->steps_count++; @@ -87990,14 +86758,14 @@ range_save = (duk_uint8_t **) duk_push_fixed_buffer_nozero(re_ctx->thr, sizeof(duk_uint8_t *) * idx_count); DUK_ASSERT(range_save != NULL); - duk_memcpy(range_save, re_ctx->saved + idx_start, sizeof(duk_uint8_t *) * idx_count); + DUK_MEMCPY(range_save, re_ctx->saved + idx_start, sizeof(duk_uint8_t *) * idx_count); #if defined(DUK_USE_EXPLICIT_NULL_INIT) idx_end = idx_start + idx_count; for (idx = idx_start; idx < idx_end; idx++) { re_ctx->saved[idx] = NULL; } #else - duk_memzero((void *) (re_ctx->saved + idx_start), sizeof(duk_uint8_t *) * idx_count); + DUK_MEMZERO((void *) (re_ctx->saved + idx_start), sizeof(duk_uint8_t *) * idx_count); #endif sub_sp = duk__match_regexp(re_ctx, pc, sp); @@ -88015,7 +86783,7 @@ DUK_DDD(DUK_DDDPRINT("fail: restore wiped/resaved values [%ld,%ld] (captures [%ld,%ld])", (long) idx_start, (long) (idx_start + idx_count - 1), (long) (idx_start / 2), (long) ((idx_start + idx_count - 1) / 2))); - duk_memcpy((void *) (re_ctx->saved + idx_start), + DUK_MEMCPY((void *) (re_ctx->saved + idx_start), (const void *) range_save, sizeof(duk_uint8_t *) * idx_count); duk_pop_unsafe(re_ctx->thr); @@ -88047,7 +86815,7 @@ full_save = (duk_uint8_t **) duk_push_fixed_buffer_nozero(re_ctx->thr, sizeof(duk_uint8_t *) * re_ctx->nsaved); DUK_ASSERT(full_save != NULL); - duk_memcpy(full_save, re_ctx->saved, sizeof(duk_uint8_t *) * re_ctx->nsaved); + DUK_MEMCPY(full_save, re_ctx->saved, sizeof(duk_uint8_t *) * re_ctx->nsaved); skip = duk__bc_get_i32(re_ctx, &pc); sub_sp = duk__match_regexp(re_ctx, pc, sp); @@ -88072,7 +86840,7 @@ lookahead_fail: /* fail: restore saves */ - duk_memcpy((void *) re_ctx->saved, + DUK_MEMCPY((void *) re_ctx->saved, (const void *) full_save, sizeof(duk_uint8_t *) * re_ctx->nsaved); duk_pop_unsafe(re_ctx->thr); @@ -88154,7 +86922,7 @@ internal_error: DUK_ERROR_INTERNAL(re_ctx->thr); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } /* @@ -88220,7 +86988,7 @@ /* [ ... re_obj input bc ] */ - duk_memzero(&re_ctx, sizeof(re_ctx)); + DUK_MEMZERO(&re_ctx, sizeof(re_ctx)); re_ctx.thr = thr; re_ctx.input = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input); @@ -88257,7 +87025,7 @@ #elif defined(DUK_USE_ZERO_BUFFER_DATA) /* buffer is automatically zeroed */ #else - duk_memzero((void *) p_buf, sizeof(duk_uint8_t *) * re_ctx.nsaved); + DUK_MEMZERO((void *) p_buf, sizeof(duk_uint8_t *) * re_ctx.nsaved); #endif DUK_DDD(DUK_DDDPRINT("regexp ctx initialized, flags=0x%08lx, nsaved=%ld, recursion_limit=%ld, steps_limit=%ld", @@ -88342,7 +87110,7 @@ * internal/limit error occurs (which causes a longjmp()) * * - If we supported anchored matches, we would break out here - * unconditionally; however, ECMAScript regexps don't have anchored + * unconditionally; however, Ecmascript regexps don't have anchored * matches. It might make sense to implement a fast bail-out if * the regexp begins with '^' and sp is not 0: currently we'll just * run through the entire input string, trivially failing the match @@ -88536,13 +87304,13 @@ } while (0) #define DUK__DBLUNION_CMP_TRUE(a,b) do { \ - if (duk_memcmp((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) != 0) { \ + if (DUK_MEMCMP((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) != 0) { \ DUK__FAILED("double union compares false (expected true)"); \ } \ } while (0) #define DUK__DBLUNION_CMP_FALSE(a,b) do { \ - if (duk_memcmp((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) == 0) { \ + if (DUK_MEMCMP((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) == 0) { \ DUK__FAILED("double union compares true (expected false)"); \ } \ } while (0) @@ -88851,7 +87619,7 @@ */ DUK__DOUBLE_INIT(&a, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); DUK__DOUBLE_INIT(&b, 0x3c, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - duk_memset((void *) &c, 0, sizeof(c)); + DUK_MEMSET((void *) &c, 0, sizeof(c)); c.d = a.d + b.d; if (!DUK__DOUBLE_COMPARE(&c, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)) { DUK_D(DUK_DPRINT("broken result (native endiannesss): %02x %02x %02x %02x %02x %02x %02x %02x", @@ -88871,7 +87639,7 @@ */ DUK__DOUBLE_INIT(&a, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01); DUK__DOUBLE_INIT(&b, 0x3c, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - duk_memset((void *) &c, 0, sizeof(c)); + DUK_MEMSET((void *) &c, 0, sizeof(c)); c.d = a.d + b.d; if (!DUK__DOUBLE_COMPARE(&c, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02)) { DUK_D(DUK_DPRINT("broken result (native endiannesss): %02x %02x %02x %02x %02x %02x %02x %02x", @@ -89308,7 +88076,7 @@ * packed format. These tables are used to match non-ASCII * characters of complex productions by resorting to a linear * range-by-range comparison. This is very slow, but is expected - * to be very rare in practical ECMAScript source code, and thus + * to be very rare in practical Ecmascript source code, and thus * compactness is most important. * * The tables are matched using uni_range_match() and the format @@ -89322,55 +88090,54 @@ * Automatically generated by extract_chars.py, do not edit! */ -const duk_uint8_t duk_unicode_ids_noa[1063] = { +const duk_uint8_t duk_unicode_ids_noa[1036] = { 249,176,176,80,111,7,47,15,47,254,11,197,191,0,72,2,15,115,66,19,50,7,2,34, 2,240,66,244,50,247,185,249,98,241,99,8,241,127,58,240,182,47,31,241,191, 21,18,245,50,15,1,24,27,35,15,2,2,240,239,15,244,156,15,10,241,26,21,6,240, -101,10,4,15,9,240,152,175,39,240,82,127,56,242,100,15,4,8,159,1,240,5,115, -19,240,98,98,4,52,15,2,14,18,47,0,27,9,85,19,240,98,98,18,18,31,17,50,15,5, -47,2,130,34,240,98,98,18,68,15,4,15,1,31,9,12,115,19,240,98,98,18,68,15,16, -18,47,1,15,3,2,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,240,4,15, -12,38,31,16,5,114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2, -6,41,47,10,86,240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50, -98,34,2,3,18,50,26,3,66,15,7,63,18,15,49,114,241,79,13,79,101,241,191,6,15, -2,85,52,4,24,37,205,15,3,241,98,6,3,241,178,255,224,63,35,54,32,35,63,25, -35,63,17,35,54,32,35,62,47,41,35,63,51,241,127,0,240,47,70,53,79,254,21, -227,240,18,240,166,243,180,168,194,63,0,240,47,0,240,47,0,194,47,1,242,79, -21,5,15,53,244,137,67,241,34,6,243,107,240,255,35,240,227,76,241,197,240, -175,40,240,122,242,95,68,15,79,241,255,3,111,41,240,238,27,241,207,12,241, -79,27,43,241,67,143,82,50,52,26,251,15,50,255,224,8,53,63,22,53,55,32,32, -32,47,15,63,37,38,32,66,38,67,53,92,98,38,246,96,224,240,44,245,112,80,57, -32,68,112,32,32,35,42,51,100,80,240,63,25,255,233,107,241,242,241,242,247, -87,52,29,241,98,6,3,242,136,15,2,240,122,98,98,98,98,98,98,98,111,66,15, -254,12,146,240,184,132,52,95,70,114,47,74,35,111,26,63,78,240,63,11,242, -127,0,255,224,244,255,240,0,138,143,60,255,240,4,13,223,7,255,227,127,243, -95,30,63,253,79,0,177,240,111,31,240,47,15,63,64,241,152,63,87,63,20,39, -243,26,34,35,47,7,240,255,36,240,15,34,243,5,64,32,223,12,191,7,240,191,13, -143,31,240,224,240,36,41,180,47,25,240,146,39,240,111,7,64,79,34,32,65,52, -48,32,240,162,58,130,213,53,53,166,38,47,27,41,191,99,240,255,255,0,26,150, -223,7,95,33,255,240,0,255,143,254,6,3,245,175,24,109,70,2,146,194,66,2,18, -18,245,207,19,255,224,93,240,79,48,63,38,241,171,246,100,47,119,241,111,10, -127,10,207,73,69,53,53,50,241,91,47,10,47,3,33,46,61,241,79,107,243,127,37, -255,223,13,79,33,242,31,16,239,14,111,22,191,14,63,20,87,36,241,207,142, -240,79,20,95,20,95,24,159,36,248,239,254,2,154,240,107,127,138,83,2,241, -194,20,3,240,123,240,122,240,255,51,240,50,27,240,107,240,175,56,242,135, -31,50,15,1,50,34,240,191,30,240,212,240,223,21,114,240,207,13,242,107,240, -107,240,62,240,47,96,243,159,41,242,62,242,63,254,32,79,37,243,223,29,241, -47,9,240,207,20,241,191,19,64,223,32,240,3,240,112,32,241,95,2,47,9,244, -102,32,35,46,41,143,31,241,135,49,63,6,38,33,36,64,240,64,212,249,15,37, -240,67,242,127,32,240,97,32,250,175,31,241,179,241,111,32,240,96,242,223, -27,244,127,10,255,224,122,243,15,17,15,242,11,241,136,15,7,12,241,131,63, -40,242,159,249,130,241,95,3,15,35,240,239,98,98,18,241,111,7,15,254,26,223, -254,40,207,88,245,255,3,251,79,254,155,15,254,50,31,254,236,95,254,19,159, -255,0,16,173,255,225,43,143,15,246,63,14,240,79,32,240,35,241,31,5,111,3, -255,226,100,243,92,15,52,207,50,31,16,255,240,0,109,255,5,255,225,229,255, -240,1,64,31,254,1,31,67,255,224,126,255,231,248,245,182,196,136,159,255,0, -6,90,244,82,243,114,19,3,19,50,178,2,98,243,18,51,114,98,240,194,50,66,4, -98,255,224,70,63,9,47,9,47,15,47,9,47,15,47,9,47,15,47,9,47,15,47,9,39,255, -239,40,251,95,45,243,79,254,59,3,47,11,33,32,48,41,35,32,32,112,80,32,32, -34,33,32,48,32,32,32,32,33,32,51,38,35,35,32,41,47,1,98,36,47,1,255,240,0, -3,143,255,0,149,201,241,191,254,242,124,252,227,255,240,0,87,79,0,255,240, -0,194,63,254,177,63,254,17,0, +101,10,4,15,9,240,159,57,240,82,127,56,242,100,15,4,8,159,1,240,5,115,19, +240,98,98,4,52,15,2,14,18,47,0,31,5,85,19,240,98,98,18,18,31,17,50,15,5,47, +2,130,34,240,98,98,18,68,15,4,15,1,31,9,12,115,19,240,98,98,18,68,15,16,18, +47,1,15,3,2,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,240,4,15,12, +38,31,16,5,114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2,6, +41,47,10,86,240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50,98, +34,2,3,18,50,26,3,66,15,7,63,18,15,49,114,241,79,13,79,101,241,191,6,15,2, +85,52,4,24,37,205,15,3,241,98,6,3,241,178,255,224,63,35,54,32,35,63,25,35, +63,17,35,54,32,35,62,47,41,35,63,51,241,127,0,240,47,70,53,79,254,21,227, +240,18,240,166,243,180,168,194,63,0,240,47,0,240,47,0,194,47,1,242,79,21,5, +15,53,244,137,67,241,34,6,243,107,240,255,35,240,227,76,241,197,240,175,40, +240,122,242,95,68,15,79,241,255,3,111,41,240,238,27,241,207,12,241,79,27, +43,241,67,143,82,50,52,26,251,15,50,255,224,8,53,63,22,53,55,32,32,32,47, +15,63,37,38,32,66,38,67,53,92,98,38,246,96,224,240,44,245,112,80,57,32,68, +112,32,32,35,42,51,100,80,240,63,25,255,233,107,241,242,241,242,247,87,52, +29,241,98,6,3,242,136,15,2,240,122,98,98,98,98,98,98,98,111,66,15,254,12, +146,240,184,132,52,95,70,114,47,74,35,111,25,79,78,240,63,11,242,127,0,255, +224,244,255,240,0,138,143,60,255,240,4,12,143,28,255,227,127,243,95,30,63, +253,79,0,177,240,111,31,240,47,15,63,64,241,152,63,87,63,20,39,243,26,34, +35,47,7,240,255,36,240,15,34,243,5,64,32,223,12,191,7,240,191,13,143,31, +240,224,240,36,41,180,47,25,240,146,39,240,111,7,64,79,34,32,65,52,48,32, +240,162,58,130,213,53,53,166,38,47,27,41,191,99,240,255,255,0,26,150,223,7, +95,33,255,240,0,255,143,254,6,3,245,175,24,109,70,2,146,194,66,2,18,18,245, +207,19,255,224,93,240,79,48,63,38,241,171,246,100,47,119,241,111,10,127,10, +207,73,69,53,53,50,241,91,47,10,47,3,33,46,61,241,79,107,243,127,37,255, +223,13,79,33,242,31,16,240,47,11,111,22,191,14,63,20,87,36,241,207,142,240, +79,20,95,20,95,24,159,36,248,239,254,2,154,240,107,127,138,83,2,241,194,20, +3,240,123,240,122,240,255,51,240,50,27,240,107,240,175,56,242,135,31,50,15, +1,50,34,240,191,30,240,212,240,223,21,114,240,207,13,242,107,240,107,240, +62,240,47,96,243,159,41,242,62,242,63,254,32,79,37,243,223,29,241,47,9,240, +207,20,241,191,19,64,223,32,240,3,240,112,32,241,95,2,47,9,244,102,32,35, +46,41,143,31,241,135,49,63,6,38,33,36,64,240,64,212,249,15,37,240,67,242, +127,32,240,97,32,250,175,31,241,179,241,111,32,240,96,242,223,27,244,127, +10,255,224,122,243,15,17,15,254,11,79,41,255,152,47,21,240,48,242,63,14, +255,226,100,255,226,140,245,143,95,240,63,180,255,233,176,255,227,33,255, +238,197,255,225,57,255,240,1,10,223,254,18,184,240,255,99,240,239,4,242,15, +2,63,17,240,86,240,63,254,38,79,53,192,243,76,243,32,241,31,255,0,6,223, +240,95,254,30,95,255,0,20,1,31,254,175,47,91,108,72,137,255,240,0,101,175, +69,47,55,33,48,49,51,43,32,38,47,49,35,55,38,47,12,35,36,32,70,47,254,4,99, +240,146,240,146,240,242,240,146,240,242,240,146,240,242,240,146,240,242, +240,146,127,254,242,143,181,242,223,52,255,227,176,50,240,178,18,3,2,146, +50,2,7,5,2,2,2,34,18,3,2,2,2,2,2,18,3,50,98,50,50,2,146,240,22,34,66,240, +31,255,0,0,56,255,240,9,92,159,27,255,239,39,207,206,63,255,0,5,116,255, +240,1,133,47,254,17,0, }; #else /* IdentifierStart production with ASCII and non-BMP excluded */ @@ -89379,35 +88146,35 @@ * Automatically generated by extract_chars.py, do not edit! */ -const duk_uint8_t duk_unicode_ids_noabmp[626] = { +const duk_uint8_t duk_unicode_ids_noabmp[625] = { 249,176,176,80,111,7,47,15,47,254,11,197,191,0,72,2,15,115,66,19,50,7,2,34, 2,240,66,244,50,247,185,249,98,241,99,8,241,127,58,240,182,47,31,241,191, 21,18,245,50,15,1,24,27,35,15,2,2,240,239,15,244,156,15,10,241,26,21,6,240, -101,10,4,15,9,240,152,175,39,240,82,127,56,242,100,15,4,8,159,1,240,5,115, -19,240,98,98,4,52,15,2,14,18,47,0,27,9,85,19,240,98,98,18,18,31,17,50,15,5, -47,2,130,34,240,98,98,18,68,15,4,15,1,31,9,12,115,19,240,98,98,18,68,15,16, -18,47,1,15,3,2,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,240,4,15, -12,38,31,16,5,114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2, -6,41,47,10,86,240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50, -98,34,2,3,18,50,26,3,66,15,7,63,18,15,49,114,241,79,13,79,101,241,191,6,15, -2,85,52,4,24,37,205,15,3,241,98,6,3,241,178,255,224,63,35,54,32,35,63,25, -35,63,17,35,54,32,35,62,47,41,35,63,51,241,127,0,240,47,70,53,79,254,21, -227,240,18,240,166,243,180,168,194,63,0,240,47,0,240,47,0,194,47,1,242,79, -21,5,15,53,244,137,67,241,34,6,243,107,240,255,35,240,227,76,241,197,240, -175,40,240,122,242,95,68,15,79,241,255,3,111,41,240,238,27,241,207,12,241, -79,27,43,241,67,143,82,50,52,26,251,15,50,255,224,8,53,63,22,53,55,32,32, -32,47,15,63,37,38,32,66,38,67,53,92,98,38,246,96,224,240,44,245,112,80,57, -32,68,112,32,32,35,42,51,100,80,240,63,25,255,233,107,241,242,241,242,247, -87,52,29,241,98,6,3,242,136,15,2,240,122,98,98,98,98,98,98,98,111,66,15, -254,12,146,240,184,132,52,95,70,114,47,74,35,111,26,63,78,240,63,11,242, -127,0,255,224,244,255,240,0,138,143,60,255,240,4,13,223,7,255,227,127,243, -95,30,63,253,79,0,177,240,111,31,240,47,15,63,64,241,152,63,87,63,20,39, -243,26,34,35,47,7,240,255,36,240,15,34,243,5,64,32,223,12,191,7,240,191,13, -143,31,240,224,240,36,41,180,47,25,240,146,39,240,111,7,64,79,34,32,65,52, -48,32,240,162,58,130,213,53,53,166,38,47,27,41,191,99,240,255,255,0,26,150, -223,7,95,33,255,240,0,255,143,254,6,3,245,175,24,109,70,2,146,194,66,2,18, -18,245,207,19,255,224,93,240,79,48,63,38,241,171,246,100,47,119,241,111,10, -127,10,207,73,69,53,53,50,0, +101,10,4,15,9,240,159,57,240,82,127,56,242,100,15,4,8,159,1,240,5,115,19, +240,98,98,4,52,15,2,14,18,47,0,31,5,85,19,240,98,98,18,18,31,17,50,15,5,47, +2,130,34,240,98,98,18,68,15,4,15,1,31,9,12,115,19,240,98,98,18,68,15,16,18, +47,1,15,3,2,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,240,4,15,12, +38,31,16,5,114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2,6, +41,47,10,86,240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50,98, +34,2,3,18,50,26,3,66,15,7,63,18,15,49,114,241,79,13,79,101,241,191,6,15,2, +85,52,4,24,37,205,15,3,241,98,6,3,241,178,255,224,63,35,54,32,35,63,25,35, +63,17,35,54,32,35,62,47,41,35,63,51,241,127,0,240,47,70,53,79,254,21,227, +240,18,240,166,243,180,168,194,63,0,240,47,0,240,47,0,194,47,1,242,79,21,5, +15,53,244,137,67,241,34,6,243,107,240,255,35,240,227,76,241,197,240,175,40, +240,122,242,95,68,15,79,241,255,3,111,41,240,238,27,241,207,12,241,79,27, +43,241,67,143,82,50,52,26,251,15,50,255,224,8,53,63,22,53,55,32,32,32,47, +15,63,37,38,32,66,38,67,53,92,98,38,246,96,224,240,44,245,112,80,57,32,68, +112,32,32,35,42,51,100,80,240,63,25,255,233,107,241,242,241,242,247,87,52, +29,241,98,6,3,242,136,15,2,240,122,98,98,98,98,98,98,98,111,66,15,254,12, +146,240,184,132,52,95,70,114,47,74,35,111,25,79,78,240,63,11,242,127,0,255, +224,244,255,240,0,138,143,60,255,240,4,12,143,28,255,227,127,243,95,30,63, +253,79,0,177,240,111,31,240,47,15,63,64,241,152,63,87,63,20,39,243,26,34, +35,47,7,240,255,36,240,15,34,243,5,64,32,223,12,191,7,240,191,13,143,31, +240,224,240,36,41,180,47,25,240,146,39,240,111,7,64,79,34,32,65,52,48,32, +240,162,58,130,213,53,53,166,38,47,27,41,191,99,240,255,255,0,26,150,223,7, +95,33,255,240,0,255,143,254,6,3,245,175,24,109,70,2,146,194,66,2,18,18,245, +207,19,255,224,93,240,79,48,63,38,241,171,246,100,47,119,241,111,10,127,10, +207,73,69,53,53,50,0, }; #endif @@ -89442,33 +88209,32 @@ * Automatically generated by extract_chars.py, do not edit! */ -const duk_uint8_t duk_unicode_idp_m_ids_noa[549] = { +const duk_uint8_t duk_unicode_idp_m_ids_noa[530] = { 255,225,243,246,15,254,0,116,255,191,29,32,33,33,32,243,170,242,47,15,112, 245,118,53,49,35,57,240,144,241,15,11,244,218,240,25,241,56,241,67,40,34, 36,241,210,246,173,47,17,242,130,47,2,38,177,57,240,50,242,160,38,49,50, 160,177,57,240,50,242,160,36,81,50,64,240,107,64,194,242,160,39,34,34,240, -97,57,181,34,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9, -240,35,242,198,34,35,129,193,57,240,50,242,160,38,34,35,129,193,57,240,35, -242,145,38,34,35,160,177,57,240,65,243,128,85,32,39,121,49,242,240,54,215, -41,244,144,53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160, -245,111,4,41,211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240, -241,241,1,243,47,16,160,57,241,50,57,245,209,241,64,246,139,91,185,247,41, -242,244,242,185,47,13,58,121,240,141,243,68,242,31,1,201,240,56,210,241,12, -57,241,237,242,47,4,153,121,246,130,47,5,80,82,50,251,143,42,36,255,225,0, -31,35,31,5,15,109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91, -31,255,0,100,121,159,55,5,159,18,31,66,31,254,0,64,64,80,240,148,244,161, -242,79,2,185,127,2,240,9,240,231,240,188,241,227,242,29,240,25,192,185,242, -29,208,145,57,241,50,242,64,34,49,97,32,241,180,97,253,231,33,57,255,240,3, +97,57,240,50,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9, +240,35,242,198,34,35,129,193,57,240,50,242,160,38,34,35,129,193,57,240,50, +242,198,34,35,160,177,57,240,65,243,128,85,32,39,121,49,242,240,54,215,41, +244,144,53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160,245, +111,4,41,211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240,241, +241,1,243,47,16,160,57,241,50,57,245,209,241,64,246,139,91,185,247,41,242, +244,242,185,47,13,58,121,240,141,243,68,242,31,1,201,240,56,210,241,12,57, +241,237,242,47,4,153,121,246,130,47,5,80,82,65,251,143,38,100,255,225,0,31, +35,31,5,15,109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91,31, +255,0,100,121,159,55,5,159,18,31,66,31,254,0,64,64,80,240,148,244,161,242, +79,2,185,127,2,240,9,240,231,240,188,241,227,242,29,240,25,192,185,242,29, +208,145,57,241,50,242,64,34,49,97,32,241,180,97,253,231,33,57,255,240,3, 225,128,255,225,213,240,15,2,240,4,31,10,47,178,159,23,15,254,27,16,253,64, 248,116,255,224,25,159,254,68,178,33,99,241,162,80,249,113,255,228,13,47, 39,239,17,159,1,63,31,175,39,151,47,22,210,159,37,13,47,34,218,36,159,68, 183,15,146,182,151,63,42,2,99,19,42,11,19,100,79,178,240,42,159,72,240,77, 159,199,99,143,13,31,68,240,31,1,159,67,201,159,69,229,159,254,9,169,255, -224,11,159,26,98,57,10,175,32,240,15,254,8,151,39,240,41,242,175,6,45,246, -197,64,33,38,32,153,255,240,3,191,169,247,132,242,214,240,185,255,226,235, -241,239,2,63,255,0,59,254,31,255,0,3,186,68,89,115,111,16,63,134,47,254,71, -223,34,255,224,244,242,117,242,41,15,0,15,8,66,239,254,68,70,47,1,54,33,36, -255,231,153,111,95,102,159,255,12,6,154,254,0, +226,57,114,127,2,159,42,240,98,223,255,0,60,157,159,120,79,45,111,11,159, +254,46,191,30,240,35,255,240,3,191,225,255,240,0,59,164,69,151,54,241,3, +248,98,255,228,125,242,47,254,15,79,39,95,34,144,240,0,240,132,46,255,228, +68,98,240,19,98,18,79,254,121,150,245,246,105,255,240,192,105,175,224,0, }; #else /* IdentifierPart production with IdentifierStart, ASCII, and non-BMP excluded */ @@ -89477,23 +88243,23 @@ * Automatically generated by extract_chars.py, do not edit! */ -const duk_uint8_t duk_unicode_idp_m_ids_noabmp[358] = { +const duk_uint8_t duk_unicode_idp_m_ids_noabmp[357] = { 255,225,243,246,15,254,0,116,255,191,29,32,33,33,32,243,170,242,47,15,112, 245,118,53,49,35,57,240,144,241,15,11,244,218,240,25,241,56,241,67,40,34, 36,241,210,246,173,47,17,242,130,47,2,38,177,57,240,50,242,160,38,49,50, 160,177,57,240,50,242,160,36,81,50,64,240,107,64,194,242,160,39,34,34,240, -97,57,181,34,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9, -240,35,242,198,34,35,129,193,57,240,50,242,160,38,34,35,129,193,57,240,35, -242,145,38,34,35,160,177,57,240,65,243,128,85,32,39,121,49,242,240,54,215, -41,244,144,53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160, -245,111,4,41,211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240, -241,241,1,243,47,16,160,57,241,50,57,245,209,241,64,246,139,91,185,247,41, -242,244,242,185,47,13,58,121,240,141,243,68,242,31,1,201,240,56,210,241,12, -57,241,237,242,47,4,153,121,246,130,47,5,80,82,50,251,143,42,36,255,225,0, -31,35,31,5,15,109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91, -31,255,0,100,121,159,55,5,159,18,31,66,31,254,0,64,64,80,240,148,244,161, -242,79,2,185,127,2,240,9,240,231,240,188,241,227,242,29,240,25,192,185,242, -29,208,145,57,241,50,242,64,34,49,97,32,241,180,97,253,231,33,57,255,240,3, +97,57,240,50,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9, +240,35,242,198,34,35,129,193,57,240,50,242,160,38,34,35,129,193,57,240,50, +242,198,34,35,160,177,57,240,65,243,128,85,32,39,121,49,242,240,54,215,41, +244,144,53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160,245, +111,4,41,211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240,241, +241,1,243,47,16,160,57,241,50,57,245,209,241,64,246,139,91,185,247,41,242, +244,242,185,47,13,58,121,240,141,243,68,242,31,1,201,240,56,210,241,12,57, +241,237,242,47,4,153,121,246,130,47,5,80,82,65,251,143,38,100,255,225,0,31, +35,31,5,15,109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91,31, +255,0,100,121,159,55,5,159,18,31,66,31,254,0,64,64,80,240,148,244,161,242, +79,2,185,127,2,240,9,240,231,240,188,241,227,242,29,240,25,192,185,242,29, +208,145,57,241,50,242,64,34,49,97,32,241,180,97,253,231,33,57,255,240,3, 225,128,255,225,213,240,15,2,240,4,31,10,47,178,159,23,0, }; #endif @@ -95678,10 +94444,6 @@ /* #include duk_internal.h -> already included */ -/* XXX: Avoid duk_{memcmp,memmove}_unsafe() by imposing a minimum length of - * >0 for the underlying dynamic buffer. - */ - /* * Macro support functions (use only macros in calling code) */ @@ -95693,9 +94455,6 @@ DUK_ASSERT(bw_ctx != NULL); DUK_UNREF(thr); - /* 'p' might be NULL when the underlying buffer is zero size. If so, - * the resulting pointers are not used unsafely. - */ p = (duk_uint8_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, bw_ctx->buf); DUK_ASSERT(p != NULL || (DUK_HBUFFER_DYNAMIC_GET_SIZE(bw_ctx->buf) == 0 && curr_offset == 0 && new_length == 0)); bw_ctx->p = p + curr_offset; @@ -95704,6 +94463,7 @@ } DUK_INTERNAL void duk_bw_init(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_hbuffer_dynamic *h_buf) { + DUK_ASSERT(thr != NULL); DUK_ASSERT(bw_ctx != NULL); DUK_ASSERT(h_buf != NULL); @@ -95718,7 +94478,6 @@ (void) duk_push_dynamic_buffer(thr, buf_size); bw_ctx->buf = (duk_hbuffer_dynamic *) duk_known_hbuffer(thr, -1); - DUK_ASSERT(bw_ctx->buf != NULL); duk__bw_update_ptrs(thr, bw_ctx, 0, buf_size); } @@ -95743,7 +94502,7 @@ if (DUK_UNLIKELY(new_sz < curr_off)) { /* overflow */ DUK_ERROR_RANGE(thr, DUK_STR_BUFFER_TOO_LONG); - DUK_WO_NORETURN(return NULL;); + return NULL; /* not reachable */ } #if 0 /* for manual torture testing: tight allocation, useful with valgrind */ new_sz = curr_off + sz; @@ -95786,9 +94545,9 @@ DUK_UNREF(thr); p_base = bw->p_base; - duk_memcpy_unsafe((void *) bw->p, - (const void *) (p_base + src_off), - (size_t) len); + DUK_MEMCPY((void *) bw->p, + (const void *) (p_base + src_off), + (size_t) len); bw->p += len; } @@ -95818,12 +94577,12 @@ move_sz = buf_sz - dst_off; DUK_ASSERT(p_base != NULL); /* buffer size is >= 1 */ - duk_memmove_unsafe((void *) (p_base + dst_off + len), - (const void *) (p_base + dst_off), - (size_t) move_sz); - duk_memcpy_unsafe((void *) (p_base + dst_off), - (const void *) buf, - (size_t) len); + DUK_MEMMOVE((void *) (p_base + dst_off + len), + (const void *) (p_base + dst_off), + (size_t) move_sz); + DUK_MEMCPY((void *) (p_base + dst_off), + (const void *) buf, + (size_t) len); bw->p += len; } @@ -95865,12 +94624,12 @@ move_sz = buf_sz - dst_off; DUK_ASSERT(p_base != NULL); /* buffer size is >= 1 */ - duk_memmove_unsafe((void *) (p_base + dst_off + len), - (const void *) (p_base + dst_off), - (size_t) move_sz); - duk_memcpy_unsafe((void *) (p_base + dst_off), - (const void *) (p_base + src_off), - (size_t) len); + DUK_MEMMOVE((void *) (p_base + dst_off + len), + (const void *) (p_base + dst_off), + (size_t) move_sz); + DUK_MEMCPY((void *) (p_base + dst_off), + (const void *) (p_base + src_off), + (size_t) len); bw->p += len; } @@ -95903,7 +94662,7 @@ move_sz = buf_sz - off; p_dst = p_base + off + len; p_src = p_base + off; - duk_memmove_unsafe((void *) p_dst, (const void *) p_src, (size_t) move_sz); + DUK_MEMMOVE((void *) p_dst, (const void *) p_src, (size_t) move_sz); return p_src; /* point to start of 'reserved area' */ } @@ -95934,9 +94693,9 @@ p_dst = p_base + off; p_src = p_dst + len; move_sz = (duk_size_t) (bw->p - p_src); - duk_memmove_unsafe((void *) p_dst, - (const void *) p_src, - (size_t) move_sz); + DUK_MEMMOVE((void *) p_dst, + (const void *) p_src, + (size_t) move_sz); bw->p -= len; } @@ -95957,7 +94716,7 @@ duk_uint16_t x; } u; - duk_memcpy((void *) u.b, (const void *) (*p), (size_t) 2); + DUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 2); u.x = DUK_NTOH16(u.x); *p += 2; return u.x; @@ -95969,7 +94728,7 @@ duk_uint32_t x; } u; - duk_memcpy((void *) u.b, (const void *) (*p), (size_t) 4); + DUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 4); u.x = DUK_NTOH32(u.x); *p += 4; return u.x; @@ -95982,10 +94741,10 @@ duk_uint32_t x; } u; - duk_memcpy((void *) u.b, (const void *) (*p), (size_t) 4); + DUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 4); u.x = DUK_NTOH32(u.x); du.ui[DUK_DBL_IDX_UI0] = u.x; - duk_memcpy((void *) u.b, (const void *) (*p + 4), (size_t) 4); + DUK_MEMCPY((void *) u.b, (const void *) (*p + 4), (size_t) 4); u.x = DUK_NTOH32(u.x); du.ui[DUK_DBL_IDX_UI1] = u.x; *p += 8; @@ -96000,7 +94759,7 @@ } u; u.x = DUK_HTON16(val); - duk_memcpy((void *) (*p), (const void *) u.b, (size_t) 2); + DUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 2); *p += 2; } @@ -96011,7 +94770,7 @@ } u; u.x = DUK_HTON32(val); - duk_memcpy((void *) (*p), (const void *) u.b, (size_t) 4); + DUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 4); *p += 4; } @@ -96025,415 +94784,13 @@ du.d = val; u.x = du.ui[DUK_DBL_IDX_UI0]; u.x = DUK_HTON32(u.x); - duk_memcpy((void *) (*p), (const void *) u.b, (size_t) 4); + DUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 4); u.x = du.ui[DUK_DBL_IDX_UI1]; u.x = DUK_HTON32(u.x); - duk_memcpy((void *) (*p + 4), (const void *) u.b, (size_t) 4); + DUK_MEMCPY((void *) (*p + 4), (const void *) u.b, (size_t) 4); *p += 8; } /* - * Cast helpers. - * - * C99+ coercion is challenging portability-wise because out-of-range casts - * may invoke implementation defined or even undefined behavior. See e.g. - * http://blog.frama-c.com/index.php?post/2013/10/09/Overflow-float-integer. - * - * Provide explicit cast helpers which try to avoid implementation defined - * or undefined behavior. These helpers can then be simplified in the vast - * majority of cases where the implementation defined or undefined behavior - * is not problematic. - */ - -/* #include duk_internal.h -> already included */ - -/* Portable double-to-integer cast which avoids undefined behavior and avoids - * relying on fmin(), fmax(), or other intrinsics. Out-of-range results are - * not assumed by caller, but here value is clamped, NaN converts to minval. - */ -#define DUK__DOUBLE_INT_CAST1(tname,minval,maxval) do { \ - if (DUK_LIKELY(x >= (duk_double_t) (minval))) { \ - DUK_ASSERT(!DUK_ISNAN(x)); \ - if (DUK_LIKELY(x <= (duk_double_t) (maxval))) { \ - return (tname) x; \ - } else { \ - return (tname) (maxval); \ - } \ - } else { \ - /* NaN or below minval. Since we don't care about the result \ - * for out-of-range values, just return the minimum value for \ - * both. \ - */ \ - return (tname) (minval); \ - } \ - } while (0) - -/* Rely on specific NaN behavior for duk_double_{fmin,fmax}(): if either - * argument is a NaN, return the second argument. This avoids a - * NaN-to-integer cast which is undefined behavior. - */ -#define DUK__DOUBLE_INT_CAST2(tname,minval,maxval) do { \ - return (tname) duk_double_fmin(duk_double_fmax(x, (duk_double_t) (minval)), (duk_double_t) (maxval)); \ - } while (0) - -/* Another solution which doesn't need C99+ behavior for fmin() and fmax(). */ -#define DUK__DOUBLE_INT_CAST3(tname,minval,maxval) do { \ - if (DUK_ISNAN(x)) { \ - /* 0 or any other value is fine. */ \ - return (tname) 0; \ - } else \ - return (tname) DUK_FMIN(DUK_FMAX(x, (duk_double_t) (minval)), (duk_double_t) (maxval)); \ - } \ - } while (0) - -/* C99+ solution: relies on specific fmin() and fmax() behavior in C99: if - * one argument is NaN but the other isn't, the non-NaN argument is returned. - * Because the limits are non-NaN values, explicit NaN check is not needed. - * This may not work on all legacy platforms, and also doesn't seem to inline - * the fmin() and fmax() calls (unless one uses -ffast-math which we don't - * support). - */ -#define DUK__DOUBLE_INT_CAST4(tname,minval,maxval) do { \ - return (tname) DUK_FMIN(DUK_FMAX(x, (duk_double_t) (minval)), (duk_double_t) (maxval)); \ - } while (0) - -DUK_INTERNAL duk_int_t duk_double_to_int_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - /* Real world solution: almost any practical platform will provide - * an integer value without any guarantees what it is (which is fine). - */ - return (duk_int_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_int_t, DUK_INT_MIN, DUK_INT_MAX); -#endif -} - -DUK_INTERNAL duk_uint_t duk_double_to_uint_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_uint_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_uint_t, DUK_UINT_MIN, DUK_UINT_MAX); -#endif -} - -DUK_INTERNAL duk_int32_t duk_double_to_int32_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_int32_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_int32_t, DUK_INT32_MIN, DUK_INT32_MAX); -#endif -} - -DUK_INTERNAL duk_uint32_t duk_double_to_uint32_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_uint32_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_uint32_t, DUK_UINT32_MIN, DUK_UINT32_MAX); -#endif -} - -/* Largest IEEE double that doesn't round to infinity in the default rounding - * mode. The exact midpoint between (1 - 2^(-24)) * 2^128 and 2^128 rounds to - * infinity, at least on x64. This number is one double unit below that - * midpoint. See misc/float_cast.c. - */ -#define DUK__FLOAT_ROUND_LIMIT 340282356779733623858607532500980858880.0 - -/* Maximum IEEE float. Double-to-float conversion above this would be out of - * range and thus technically undefined behavior. - */ -#define DUK__FLOAT_MAX 340282346638528859811704183484516925440.0 - -DUK_INTERNAL duk_float_t duk_double_to_float_t(duk_double_t x) { - /* Even a double-to-float cast is technically undefined behavior if - * the double is out-of-range. C99 Section 6.3.1.5: - * - * If the value being converted is in the range of values that can - * be represented but cannot be represented exactly, the result is - * either the nearest higher or nearest lower representable value, - * chosen in an implementation-defined manner. If the value being - * converted is outside the range of values that can be represented, - * the behavior is undefined. - */ -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_float_t) x; -#else - duk_double_t t; - - t = DUK_FABS(x); - DUK_ASSERT((DUK_ISNAN(x) && DUK_ISNAN(t)) || - (!DUK_ISNAN(x) && !DUK_ISNAN(t))); - - if (DUK_LIKELY(t <= DUK__FLOAT_MAX)) { - /* Standard in-range case, try to get here with a minimum - * number of checks and branches. - */ - DUK_ASSERT(!DUK_ISNAN(x)); - return (duk_float_t) x; - } else if (t <= DUK__FLOAT_ROUND_LIMIT) { - /* Out-of-range, but rounds to min/max float. */ - DUK_ASSERT(!DUK_ISNAN(x)); - if (x < 0.0) { - return (duk_float_t) -DUK__FLOAT_MAX; - } else { - return (duk_float_t) DUK__FLOAT_MAX; - } - } else if (DUK_ISNAN(x)) { - /* Assumes double NaN -> float NaN considered "in range". */ - DUK_ASSERT(DUK_ISNAN(x)); - return (duk_float_t) x; - } else { - /* Out-of-range, rounds to +/- Infinity. */ - if (x < 0.0) { - return (duk_float_t) -DUK_DOUBLE_INFINITY; - } else { - return (duk_float_t) DUK_DOUBLE_INFINITY; - } - } -#endif -} - -/* automatic undefs */ -#undef DUK__DOUBLE_INT_CAST1 -#undef DUK__DOUBLE_INT_CAST2 -#undef DUK__DOUBLE_INT_CAST3 -#undef DUK__DOUBLE_INT_CAST4 -#undef DUK__FLOAT_MAX -#undef DUK__FLOAT_ROUND_LIMIT -/* - * IEEE double helpers. - */ - -/* #include duk_internal.h -> already included */ - -DUK_INTERNAL duk_bool_t duk_double_is_anyinf(duk_double_t x) { - duk_double_union du; - du.d = x; - return DUK_DBLUNION_IS_ANYINF(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_posinf(duk_double_t x) { - duk_double_union du; - du.d = x; - return DUK_DBLUNION_IS_POSINF(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_neginf(duk_double_t x) { - duk_double_union du; - du.d = x; - return DUK_DBLUNION_IS_NEGINF(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan(duk_double_t x) { - duk_double_union du; - du.d = x; - /* Assumes we're dealing with a Duktape internal NaN which is - * NaN normalized if duk_tval requires it. - */ - DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); - return DUK_DBLUNION_IS_NAN(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan_or_zero(duk_double_t x) { - duk_double_union du; - du.d = x; - /* Assumes we're dealing with a Duktape internal NaN which is - * NaN normalized if duk_tval requires it. - */ - DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); - return DUK_DBLUNION_IS_NAN(&du) || DUK_DBLUNION_IS_ANYZERO(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan_or_inf(duk_double_t x) { - duk_double_union du; - du.d = x; - /* If exponent is 0x7FF the argument is either a NaN or an - * infinity. We don't need to check any other fields. - */ -#if defined(DUK_USE_64BIT_OPS) -#if defined(DUK_USE_DOUBLE_ME) - return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000)) == DUK_U64_CONSTANT(0x000000007ff00000); -#else - return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000)) == DUK_U64_CONSTANT(0x7ff0000000000000); -#endif -#else - return (du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL) == 0x7ff00000UL; -#endif -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan_zero_inf(duk_double_t x) { - duk_double_union du; -#if defined(DUK_USE_64BIT_OPS) - duk_uint64_t t; -#else - duk_uint32_t t; -#endif - du.d = x; -#if defined(DUK_USE_64BIT_OPS) -#if defined(DUK_USE_DOUBLE_ME) - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000); - if (t == DUK_U64_CONSTANT(0x0000000000000000)) { - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x0000000080000000); - return t == 0; - } - if (t == DUK_U64_CONSTANT(0x000000007ff00000)) { - return 1; - } -#else - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000); - if (t == DUK_U64_CONSTANT(0x0000000000000000)) { - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x8000000000000000); - return t == 0; - } - if (t == DUK_U64_CONSTANT(0x7ff0000000000000)) { - return 1; - } -#endif -#else - t = du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL; - if (t == 0x00000000UL) { - return DUK_DBLUNION_IS_ANYZERO(&du); - } - if (t == 0x7ff00000UL) { - return 1; - } -#endif - return 0; -} - -DUK_INTERNAL duk_small_uint_t duk_double_signbit(duk_double_t x) { - duk_double_union du; - du.d = x; - return (duk_small_uint_t) DUK_DBLUNION_GET_SIGNBIT(&du); -} - -DUK_INTERNAL duk_double_t duk_double_trunc_towards_zero(duk_double_t x) { - /* XXX: optimize */ - duk_small_uint_t s = duk_double_signbit(x); - x = DUK_FLOOR(DUK_FABS(x)); /* truncate towards zero */ - if (s) { - x = -x; - } - return x; -} - -DUK_INTERNAL duk_bool_t duk_double_same_sign(duk_double_t x, duk_double_t y) { - duk_double_union du1; - duk_double_union du2; - du1.d = x; - du2.d = y; - - return (((du1.ui[DUK_DBL_IDX_UI0] ^ du2.ui[DUK_DBL_IDX_UI0]) & 0x80000000UL) == 0); -} - -DUK_INTERNAL duk_double_t duk_double_fmin(duk_double_t x, duk_double_t y) { - /* Doesn't replicate fmin() behavior exactly: for fmin() if one - * argument is a NaN, the other argument should be returned. - * Duktape doesn't rely on this behavior so the replacement can - * be simplified. - */ - return (x < y ? x : y); -} - -DUK_INTERNAL duk_double_t duk_double_fmax(duk_double_t x, duk_double_t y) { - /* Doesn't replicate fmax() behavior exactly: for fmax() if one - * argument is a NaN, the other argument should be returned. - * Duktape doesn't rely on this behavior so the replacement can - * be simplified. - */ - return (x > y ? x : y); -} - -DUK_INTERNAL duk_bool_t duk_double_is_finite(duk_double_t x) { - return !duk_double_is_nan_or_inf(x); -} - -DUK_INTERNAL duk_bool_t duk_double_is_integer(duk_double_t x) { - if (duk_double_is_nan_or_inf(x)) { - return 0; - } else { - return duk_js_tointeger_number(x) == x; - } -} - -DUK_INTERNAL duk_bool_t duk_double_is_safe_integer(duk_double_t x) { - /* >>> 2**53-1 - * 9007199254740991 - */ - return duk_double_is_integer(x) && DUK_FABS(x) <= 9007199254740991.0; -} - -/* Check whether a duk_double_t is a whole number in the 32-bit range (reject - * negative zero), and if so, return a duk_int32_t. - * For compiler use: don't allow negative zero as it will cause trouble with - * LDINT+LDINTX, positive zero is OK. - */ -DUK_INTERNAL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int32_t *ival) { - duk_int32_t t; - - t = duk_double_to_int32_t(x); - if (!((duk_double_t) t == x)) { - return 0; - } - if (t == 0) { - duk_double_union du; - du.d = x; - if (DUK_DBLUNION_HAS_SIGNBIT(&du)) { - return 0; - } - } - *ival = t; - return 1; -} - -/* Check whether a duk_double_t is a whole number in the 32-bit range, and if - * so, return a duk_int32_t. - */ -DUK_INTERNAL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival) { - duk_int32_t t; - - t = duk_double_to_int32_t(x); - if (!((duk_double_t) t == x)) { - return 0; - } - *ival = t; - return 1; -} - -/* Division: division by zero is undefined behavior (and may in fact trap) - * so it needs special handling for portability. - */ - -DUK_INTERNAL DUK_INLINE duk_double_t duk_double_div(duk_double_t x, duk_double_t y) { -#if !defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - if (DUK_UNLIKELY(y == 0.0)) { - /* In C99+ division by zero is undefined behavior so - * avoid it entirely. Hopefully the compiler is - * smart enough to avoid emitting any actual code - * because almost all practical platforms behave as - * expected. - */ - if (x > 0.0) { - if (DUK_SIGNBIT(y)) { - return -DUK_DOUBLE_INFINITY; - } else { - return DUK_DOUBLE_INFINITY; - } - } else if (x < 0.0) { - if (DUK_SIGNBIT(y)) { - return DUK_DOUBLE_INFINITY; - } else { - return -DUK_DOUBLE_INFINITY; - } - } else { - /* +/- 0, NaN */ - return DUK_DOUBLE_NAN; - } - } -#endif - - return x / y; -} -/* * Hash function duk_util_hashbytes(). * * Currently, 32-bit MurmurHash2. @@ -96495,42 +94852,6 @@ #undef DUK__MAGIC_M #undef DUK__MAGIC_R /* - * Memory utils. - */ - -/* #include duk_internal.h -> already included */ - -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp_unsafe(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL || len == 0U); - DUK_ASSERT(s2 != NULL || len == 0U); - return DUK_MEMCMP(s1, s2, (size_t) len); -} - -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL); - DUK_ASSERT(s2 != NULL); - return DUK_MEMCMP(s1, s2, (size_t) len); -} -#else /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp_unsafe(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL || len == 0U); - DUK_ASSERT(s2 != NULL || len == 0U); - if (DUK_UNLIKELY(len == 0U)) { - return 0; - } - DUK_ASSERT(s1 != NULL); - DUK_ASSERT(s2 != NULL); - return duk_memcmp(s1, s2, len); -} - -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL); - DUK_ASSERT(s2 != NULL); - return DUK_MEMCMP(s1, s2, (size_t) len); -} -#endif /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ -/* * A tiny random number generator used for Math.random() and other internals. * * Default algorithm is xoroshiro128+: http://xoroshiro.di.unimi.it/xoroshiro128plus.c diff -Nru duktape-2.3.0/src-noline/duktape.h duktape-2.2.0/src-noline/duktape.h --- duktape-2.3.0/src-noline/duktape.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-noline/duktape.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,12 +1,12 @@ /* - * Duktape public API for Duktape 2.3.0. + * Duktape public API for Duktape 2.2.0. * * See the API reference for documentation on call semantics. The exposed, * supported API is between the "BEGIN PUBLIC API" and "END PUBLIC API" * comments. Other parts of the header are Duktape internal and related to * e.g. platform/compiler/feature detection. * - * Git commit d7fdb67f18561a50e06bafd196c6b423af9ad6fe (v2.3.0). + * Git commit a459cf3c9bd1779fc01b435d69302b742675a08f (v2.2.0). * Git branch master. * * See Duktape AUTHORS.rst and LICENSE.txt for copyright and @@ -21,7 +21,7 @@ * * (http://opensource.org/licenses/MIT) * - * Copyright (c) 2013-2018 by Duktape authors (see AUTHORS.rst) + * Copyright (c) 2013-2017 by Duktape authors (see AUTHORS.rst) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -92,14 +92,6 @@ * * Steven Don (https://github.com/shdon) * * Simon Stone (https://github.com/sstone1) * * \J. McC. (https://github.com/jmhmccr) - * * Jakub Nowakowski (https://github.com/jimvonmoon) - * * Tommy Nguyen (https://github.com/tn0502) - * * Fabrice Fontaine (https://github.com/ffontaine) - * * Christopher Hiller (https://github.com/boneskull) - * * Gonzalo Diethelm (https://github.com/gonzus) - * * Michal Kasperek (https://github.com/michalkas) - * * Andrew Janke (https://github.com/apjanke) - * * Steve Fan (https://github.com/stevefan1999) * * Other contributions * =================== @@ -138,8 +130,6 @@ * * https://github.com/chris-y * * Laurent Zubiaur (https://github.com/lzubiaur) * * Neil Kolban (https://github.com/nkolban) - * * Wilhelm Wanecek (https://github.com/wanecek) - * * Andrew Janke (https://github.com/apjanke) * * If you are accidentally missing from this list, send me an e-mail * (``sami.vaarala@iki.fi``) and I'll fix the omission. @@ -160,19 +150,19 @@ /* Duktape version, (major * 10000) + (minor * 100) + patch. Allows C code * to #if (DUK_VERSION >= NNN) against Duktape API version. The same value - * is also available to ECMAScript code in Duktape.version. Unofficial + * is also available to Ecmascript code in Duktape.version. Unofficial * development snapshots have 99 for patch level (e.g. 0.10.99 would be a * development version after 0.10.0 but before the next official release). */ -#define DUK_VERSION 20300L +#define DUK_VERSION 20200L /* Git commit, describe, and branch for Duktape build. Useful for * non-official snapshot builds so that application code can easily log - * which Duktape snapshot was used. Not available in the ECMAScript + * which Duktape snapshot was used. Not available in the Ecmascript * environment. */ -#define DUK_GIT_COMMIT "d7fdb67f18561a50e06bafd196c6b423af9ad6fe" -#define DUK_GIT_DESCRIBE "v2.3.0" +#define DUK_GIT_COMMIT "a459cf3c9bd1779fc01b435d69302b742675a08f" +#define DUK_GIT_DESCRIBE "v2.2.0" #define DUK_GIT_BRANCH "master" /* External duk_config.h provides platform/compiler/OS dependent @@ -268,7 +258,7 @@ }; struct duk_time_components { - duk_double_t year; /* year, e.g. 2016, ECMAScript year range */ + duk_double_t year; /* year, e.g. 2016, Ecmascript year range */ duk_double_t month; /* month: 1-12 */ duk_double_t day; /* day: 1-31 */ duk_double_t hours; /* hour: 0-59 */ @@ -304,12 +294,12 @@ /* Value types, used by e.g. duk_get_type() */ #define DUK_TYPE_MIN 0U #define DUK_TYPE_NONE 0U /* no value, e.g. invalid index */ -#define DUK_TYPE_UNDEFINED 1U /* ECMAScript undefined */ -#define DUK_TYPE_NULL 2U /* ECMAScript null */ -#define DUK_TYPE_BOOLEAN 3U /* ECMAScript boolean: 0 or 1 */ -#define DUK_TYPE_NUMBER 4U /* ECMAScript number: double */ -#define DUK_TYPE_STRING 5U /* ECMAScript string: CESU-8 / extended UTF-8 encoded */ -#define DUK_TYPE_OBJECT 6U /* ECMAScript object: includes objects, arrays, functions, threads */ +#define DUK_TYPE_UNDEFINED 1U /* Ecmascript undefined */ +#define DUK_TYPE_NULL 2U /* Ecmascript null */ +#define DUK_TYPE_BOOLEAN 3U /* Ecmascript boolean: 0 or 1 */ +#define DUK_TYPE_NUMBER 4U /* Ecmascript number: double */ +#define DUK_TYPE_STRING 5U /* Ecmascript string: CESU-8 / extended UTF-8 encoded */ +#define DUK_TYPE_OBJECT 6U /* Ecmascript object: includes objects, arrays, functions, threads */ #define DUK_TYPE_BUFFER 7U /* fixed or dynamic, garbage collected byte buffer */ #define DUK_TYPE_POINTER 8U /* raw void pointer */ #define DUK_TYPE_LIGHTFUNC 9U /* lightweight function pointer */ @@ -678,21 +668,7 @@ DUK_EXTERNAL_DECL const char *duk_push_sprintf(duk_context *ctx, const char *fmt, ...); DUK_EXTERNAL_DECL const char *duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap); -/* duk_push_literal() may evaluate its argument (a C string literal) more than - * once on purpose. When speed is preferred, sizeof() avoids an unnecessary - * strlen() at runtime. Sizeof("foo") == 4, so subtract 1. The argument - * must be non-NULL and should not contain internal NUL characters as the - * behavior will then depend on config options. - */ -#if defined(DUK_USE_PREFER_SIZE) -#define duk_push_literal(ctx,cstring) duk_push_string((ctx), (cstring)) -#else -DUK_EXTERNAL_DECL const char *duk_push_literal_raw(duk_context *ctx, const char *str, duk_size_t len); -#define duk_push_literal(ctx,cstring) duk_push_literal_raw((ctx), (cstring), sizeof((cstring)) - 1U) -#endif - DUK_EXTERNAL_DECL void duk_push_this(duk_context *ctx); -DUK_EXTERNAL_DECL void duk_push_new_target(duk_context *ctx); DUK_EXTERNAL_DECL void duk_push_current_function(duk_context *ctx); DUK_EXTERNAL_DECL void duk_push_current_thread(duk_context *ctx); DUK_EXTERNAL_DECL void duk_push_global_object(duk_context *ctx); @@ -1024,55 +1000,29 @@ /* * Property access * - * The basic function assumes key is on stack. The _(l)string variant takes - * a C string as a property name; the _literal variant takes a C literal. - * The _index variant takes an array index as a property name (e.g. 123 is - * equivalent to the key "123"). The _heapptr variant takes a raw, borrowed - * heap pointer. + * The basic function assumes key is on stack. The _string variant takes + * a C string as a property name, while the _index variant takes an array + * index as a property name (e.g. 123 is equivalent to the key "123"). */ DUK_EXTERNAL_DECL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_get_prop_literal(ctx,obj_idx,key) duk_get_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_get_prop_literal(ctx,obj_idx,key) duk_get_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_put_prop_literal(ctx,obj_idx,key) duk_put_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_put_prop_literal(ctx,obj_idx,key) duk_put_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_del_prop_literal(ctx,obj_idx,key) duk_del_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_del_prop_literal(ctx,obj_idx,key) duk_del_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_has_prop_literal(ctx,obj_idx,key) duk_has_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_has_prop_literal(ctx,obj_idx,key) duk_has_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); @@ -1081,22 +1031,8 @@ DUK_EXTERNAL_DECL duk_bool_t duk_get_global_string(duk_context *ctx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_get_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_get_global_literal(ctx,key) duk_get_global_string((ctx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_get_global_literal_raw(duk_context *ctx, const char *key, duk_size_t key_len); -#define duk_get_global_literal(ctx,key) duk_get_global_literal_raw((ctx), (key), sizeof((key)) - 1U) -#endif -DUK_EXTERNAL_DECL duk_bool_t duk_get_global_heapptr(duk_context *ctx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_put_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_put_global_literal(ctx,key) duk_put_global_string((ctx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_put_global_literal_raw(duk_context *ctx, const char *key, duk_size_t key_len); -#define duk_put_global_literal(ctx,key) duk_put_global_literal_raw((ctx), (key), sizeof((key)) - 1U) -#endif -DUK_EXTERNAL_DECL duk_bool_t duk_put_global_heapptr(duk_context *ctx, void *ptr); /* * Inspection @@ -1163,7 +1099,7 @@ DUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t idx, duk_size_t char_offset); /* - * ECMAScript operators + * Ecmascript operators */ DUK_EXTERNAL_DECL duk_bool_t duk_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2); @@ -1172,12 +1108,6 @@ DUK_EXTERNAL_DECL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2); /* - * Random - */ - -DUK_EXTERNAL_DECL duk_double_t duk_random(duk_context *ctx); - -/* * Function (method) calls */ @@ -1327,7 +1257,7 @@ #define DUK_DATE_MSEC_HOUR (60L * 60L * 1000L) #define DUK_DATE_MSEC_DAY (24L * 60L * 60L * 1000L) -/* ECMAScript date range is 100 million days from Epoch: +/* Ecmascript date range is 100 million days from Epoch: * > 100e6 * 24 * 60 * 60 * 1000 // 100M days in millisecs * 8640000000000000 * (= 8.64e15) @@ -1335,7 +1265,7 @@ #define DUK_DATE_MSEC_100M_DAYS (8.64e15) #define DUK_DATE_MSEC_100M_DAYS_LEEWAY (8.64e15 + 24 * 3600e3) -/* ECMAScript year range: +/* Ecmascript year range: * > new Date(100e6 * 24 * 3600e3).toISOString() * '+275760-09-13T00:00:00.000Z' * > new Date(-100e6 * 24 * 3600e3).toISOString() @@ -1345,7 +1275,7 @@ #define DUK_DATE_MAX_ECMA_YEAR 275760L /* Part indices for internal breakdowns. Part order from DUK_DATE_IDX_YEAR - * to DUK_DATE_IDX_MILLISECOND matches argument ordering of ECMAScript API + * to DUK_DATE_IDX_MILLISECOND matches argument ordering of Ecmascript API * calls (like Date constructor call). Some functions in duk_bi_date.c * depend on the specific ordering, so change with care. 16 bits are not * enough for all parts (year, specifically). diff -Nru duktape-2.3.0/src-separate/duk_api_buffer.c duktape-2.2.0/src-separate/duk_api_buffer.c --- duktape-2.3.0/src-separate/duk_api_buffer.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_api_buffer.c 2017-09-23 01:06:08.000000000 +0000 @@ -14,10 +14,9 @@ if (!(DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE); - DUK_WO_NORETURN(return NULL;); } - /* Maximum size check is handled by callee. */ + /* maximum size check is handled by callee */ duk_hbuffer_resize(thr, h, new_size); return DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, h); @@ -35,7 +34,6 @@ if (!(DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE); - DUK_WO_NORETURN(return NULL;); } /* Forget the previous allocation, setting size to 0 and alloc to @@ -64,7 +62,6 @@ if (!DUK_HBUFFER_HAS_EXTERNAL(h)) { DUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE); - DUK_WO_NORETURN(return;); } DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(h)); diff -Nru duktape-2.3.0/src-separate/duk_api_bytecode.c duktape-2.2.0/src-separate/duk_api_bytecode.c --- duktape-2.3.0/src-separate/duk_api_bytecode.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_api_bytecode.c 2017-09-23 01:06:08.000000000 +0000 @@ -40,7 +40,7 @@ len = DUK_RAW_READ_U32_BE(p); buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, (duk_size_t) len); DUK_ASSERT(buf != NULL); - duk_memcpy((void *) buf, (const void *) p, (size_t) len); + DUK_MEMCPY((void *) buf, (const void *) p, (size_t) len); p += len; return p; } @@ -55,7 +55,7 @@ DUK_ASSERT(len <= 0xffffffffUL); /* string limits */ tmp32 = (duk_uint32_t) len; DUK_RAW_WRITE_U32_BE(p, tmp32); - duk_memcpy((void *) p, + DUK_MEMCPY((void *) p, (const void *) DUK_HSTRING_GET_DATA(h), len); p += len; @@ -74,10 +74,9 @@ DUK_ASSERT(len <= 0xffffffffUL); /* buffer limits */ tmp32 = (duk_uint32_t) len; DUK_RAW_WRITE_U32_BE(p, tmp32); - /* When len == 0, buffer data pointer may be NULL. */ - duk_memcpy_unsafe((void *) p, - (const void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h), - len); + DUK_MEMCPY((void *) p, + (const void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h), + len); p += len; return p; } @@ -289,7 +288,7 @@ ins_end = DUK_HCOMPFUNC_GET_CODE_END(thr->heap, func); DUK_ASSERT((duk_size_t) (ins_end - ins) == (duk_size_t) count_instr); #if defined(DUK_USE_INTEGER_BE) - duk_memcpy_unsafe((void *) p, (const void *) ins, (size_t) (ins_end - ins)); + DUK_MEMCPY((void *) p, (const void *) ins, (size_t) (ins_end - ins)); p += (size_t) (ins_end - ins); #else while (ins != ins_end) { @@ -311,7 +310,7 @@ h_str = DUK_TVAL_GET_STRING(tv); DUK_ASSERT(h_str != NULL); DUK_ASSERT(DUK_HSTRING_MAX_BYTELEN <= 0x7fffffffUL); /* ensures no overflow */ - p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 1U + 4U + DUK_HSTRING_GET_BYTELEN(h_str), p); + p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 1U + 4U + DUK_HSTRING_GET_BYTELEN(h_str), p), *p++ = DUK__SER_STRING; p = duk__dump_hstring_raw(p, h_str); } else { @@ -475,7 +474,7 @@ DUK__ASSERT_LEFT(count_instr * sizeof(duk_instr_t)); #if defined(DUK_USE_INTEGER_BE) q = fun_data + sizeof(duk_tval) * count_const + sizeof(duk_hobject *) * count_funcs; - duk_memcpy((void *) q, + DUK_MEMCPY((void *) q, (const void *) p, sizeof(duk_instr_t) * count_instr); p += sizeof(duk_instr_t) * count_instr; @@ -540,12 +539,15 @@ DUK_ASSERT((count_const == 0 && count_funcs == 0) || tv1 != NULL); q = fun_data; - duk_memcpy_unsafe((void *) q, (const void *) tv1, sizeof(duk_tval) * count_const); - for (n = count_const; n > 0; n--) { - DUK_TVAL_INCREF_FAST(thr, (duk_tval *) (void *) q); /* no side effects */ - q += sizeof(duk_tval); + if (count_const > 0) { + /* Explicit zero size check to avoid NULL 'tv1'. */ + DUK_MEMCPY((void *) q, (const void *) tv1, sizeof(duk_tval) * count_const); + for (n = count_const; n > 0; n--) { + DUK_TVAL_INCREF_FAST(thr, (duk_tval *) (void *) q); /* no side effects */ + q += sizeof(duk_tval); + } + tv1 += count_const; } - tv1 += count_const; DUK_HCOMPFUNC_SET_FUNCS(thr->heap, h_fun, (duk_hobject **) (void *) q); for (n = count_funcs; n > 0; n--) { @@ -746,7 +748,6 @@ format_error: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_BYTECODE); - DUK_WO_NORETURN(return;); } #else /* DUK_USE_BYTECODE_DUMP_SUPPORT */ @@ -754,13 +755,11 @@ DUK_EXTERNAL void duk_dump_function(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_load_function(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_BYTECODE_DUMP_SUPPORT */ diff -Nru duktape-2.3.0/src-separate/duk_api_call.c duktape-2.2.0/src-separate/duk_api_call.c --- duktape-2.3.0/src-separate/duk_api_call.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_api_call.c 2017-09-23 01:06:08.000000000 +0000 @@ -53,7 +53,7 @@ idx_func = duk_get_top(thr) - nargs - other; if (DUK_UNLIKELY((idx_func | nargs) < 0)) { /* idx_func < 0 || nargs < 0; OR sign bits */ DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + /* unreachable */ } DUK_ASSERT(duk_is_valid_index(thr, idx_func)); return idx_func; @@ -165,7 +165,6 @@ obj_idx = duk_require_normalize_index(thr, obj_idx); /* make absolute */ if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return;); } duk__call_prop_prep_stack(thr, obj_idx, nargs); @@ -202,7 +201,7 @@ args.nargs = nargs; if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } args.call_flags = 0; @@ -237,7 +236,7 @@ args.nargs = nargs; if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } args.call_flags = call_flags; @@ -278,7 +277,7 @@ args.nargs = nargs; if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } args.call_flags = 0; @@ -314,7 +313,7 @@ (long) (thr->valstack_top - thr->valstack), (long) nrets)); DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } rc = duk_handle_safe_call(thr, /* thread */ @@ -362,7 +361,7 @@ if (DUK_UNLIKELY(nargs < 0)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return DUK_EXEC_ERROR;); + return DUK_EXEC_ERROR; /* unreachable */ } rc = duk_safe_call(thr, duk__pnew_helper, (void *) &nargs /*udata*/, nargs + 1 /*nargs*/, 1 /*nrets*/); @@ -389,7 +388,6 @@ if (!duk_is_constructor_call(thr)) { DUK_ERROR_TYPE(thr, DUK_STR_CONSTRUCT_ONLY); - DUK_WO_NORETURN(return;); } } @@ -400,7 +398,7 @@ * because all Duktape/C functions are considered strict, * and strict is also the default when nothing is running. * However, Duktape may call this function internally when - * the current activation is an ECMAScript function, so + * the current activation is an Ecmascript function, so * this cannot be replaced by a 'return 1' without fixing * the internal call sites. */ @@ -467,7 +465,7 @@ /* fall through */ type_error: DUK_ERROR_TYPE(thr, DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_EXTERNAL void duk_set_magic(duk_hthread *thr, duk_idx_t idx, duk_int_t magic) { @@ -499,7 +497,7 @@ h = DUK_TVAL_GET_OBJECT(tv); DUK_ASSERT(h != NULL); if (DUK_HOBJECT_HAS_BOUNDFUNC(h)) { - duk_push_tval(thr, &((duk_hboundfunc *) (void *) h)->target); + duk_push_tval(thr, &((duk_hboundfunc *) h)->target); duk_replace(thr, -2); #if 0 DUK_TVAL_SET_TVAL(tv, &((duk_hboundfunc *) h)->target); diff -Nru duktape-2.3.0/src-separate/duk_api_codec.c duktape-2.2.0/src-separate/duk_api_codec.c --- duktape-2.3.0/src-separate/duk_api_codec.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_api_codec.c 2017-09-23 01:06:08.000000000 +0000 @@ -8,10 +8,6 @@ #include "duk_internal.h" -/* - * Misc helpers - */ - /* Shared handling for encode/decode argument. Fast path handling for * buffer and string values because they're the most common. In particular, * avoid creating a temporary string or buffer when possible. @@ -33,425 +29,250 @@ return (const duk_uint8_t *) duk_to_lstring(thr, idx, out_len); } -/* - * Base64 - */ - -#if defined(DUK_USE_BASE64_SUPPORT) -/* Bytes emitted for number of padding characters in range [0,4]. */ -DUK_LOCAL const duk_int8_t duk__base64_decode_nequal_step[5] = { - 3, /* #### -> 24 bits, emit 3 bytes */ - 2, /* ###= -> 18 bits, emit 2 bytes */ - 1, /* ##== -> 12 bits, emit 1 byte */ - -1, /* #=== -> 6 bits, error */ - 0, /* ==== -> 0 bits, emit 0 bytes */ -}; - #if defined(DUK_USE_BASE64_FASTPATH) -DUK_LOCAL const duk_uint8_t duk__base64_enctab_fast[64] = { - 0x41U, 0x42U, 0x43U, 0x44U, 0x45U, 0x46U, 0x47U, 0x48U, 0x49U, 0x4aU, 0x4bU, 0x4cU, 0x4dU, 0x4eU, 0x4fU, 0x50U, /* A...P */ - 0x51U, 0x52U, 0x53U, 0x54U, 0x55U, 0x56U, 0x57U, 0x58U, 0x59U, 0x5aU, 0x61U, 0x62U, 0x63U, 0x64U, 0x65U, 0x66U, /* Q...f */ - 0x67U, 0x68U, 0x69U, 0x6aU, 0x6bU, 0x6cU, 0x6dU, 0x6eU, 0x6fU, 0x70U, 0x71U, 0x72U, 0x73U, 0x74U, 0x75U, 0x76U, /* g...v */ - 0x77U, 0x78U, 0x79U, 0x7aU, 0x30U, 0x31U, 0x32U, 0x33U, 0x34U, 0x35U, 0x36U, 0x37U, 0x38U, 0x39U, 0x2bU, 0x2fU /* w.../ */ -}; -#endif /* DUK_USE_BASE64_FASTPATH */ - -#if defined(DUK_USE_BASE64_FASTPATH) -/* Decode table for one byte of input: - * -1 = allowed whitespace - * -2 = padding - * -3 = error - * 0...63 decoded bytes - */ -DUK_LOCAL const duk_int8_t duk__base64_dectab_fast[256] = { - -3, -3, -3, -3, -3, -3, -3, -3, -3, -1, -1, -3, -3, -1, -3, -3, /* 0x00...0x0f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0x10...0x1f */ - -1, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, 62, -3, -3, -3, 63, /* 0x20...0x2f */ - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -3, -3, -3, -2, -3, -3, /* 0x30...0x3f */ - -3, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40...0x4f */ - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -3, -3, -3, -3, -3, /* 0x50...0x5f */ - -3, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60...0x6f */ - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -3, -3, -3, -3, -3, /* 0x70...0x7f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0x80...0x8f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0x90...0x9f */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xa0...0xaf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xb0...0xbf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xc0...0xcf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xd0...0xdf */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, /* 0xe0...0xef */ - -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3 /* 0xf0...0xff */ -}; -#endif /* DUK_USE_BASE64_FASTPATH */ - -#if defined(DUK_USE_BASE64_FASTPATH) -DUK_LOCAL DUK_ALWAYS_INLINE void duk__base64_encode_fast_3(const duk_uint8_t *src, duk_uint8_t *dst) { +DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) { duk_uint_t t; + duk_size_t n_full, n_full3, n_final; + const duk_uint8_t *src_end_fast; - t = (duk_uint_t) src[0]; - t = (t << 8) + (duk_uint_t) src[1]; - t = (t << 8) + (duk_uint_t) src[2]; - - dst[0] = duk__base64_enctab_fast[t >> 18]; - dst[1] = duk__base64_enctab_fast[(t >> 12) & 0x3fU]; - dst[2] = duk__base64_enctab_fast[(t >> 6) & 0x3fU]; - dst[3] = duk__base64_enctab_fast[t & 0x3fU]; - -#if 0 - /* Tested: not faster on x64, most likely due to aliasing between - * output and input index computation. - */ - /* aaaaaabb bbbbcccc ccdddddd */ - dst[0] = duk__base64_enctab_fast[(src[0] >> 2) & 0x3fU]; - dst[1] = duk__base64_enctab_fast[((src[0] << 4) & 0x30U) | ((src[1] >> 4) & 0x0fU)]; - dst[2] = duk__base64_enctab_fast[((src[1] << 2) & 0x3fU) | ((src[2] >> 6) & 0x03U)]; - dst[3] = duk__base64_enctab_fast[src[2] & 0x3fU]; + n_full = srclen / 3; /* full 3-byte -> 4-char conversions */ + n_full3 = n_full * 3; + n_final = srclen - n_full3; + DUK_ASSERT_DISABLE(n_final >= 0); + DUK_ASSERT(n_final <= 2); + + src_end_fast = src + n_full3; + while (DUK_UNLIKELY(src != src_end_fast)) { + t = (duk_uint_t) (*src++); + t = (t << 8) + (duk_uint_t) (*src++); + t = (t << 8) + (duk_uint_t) (*src++); + + *dst++ = duk_base64_enctab[t >> 18]; + *dst++ = duk_base64_enctab[(t >> 12) & 0x3f]; + *dst++ = duk_base64_enctab[(t >> 6) & 0x3f]; + *dst++ = duk_base64_enctab[t & 0x3f]; + +#if 0 /* Tested: not faster on x64 */ + /* aaaaaabb bbbbcccc ccdddddd */ + dst[0] = duk_base64_enctab[(src[0] >> 2) & 0x3f]; + dst[1] = duk_base64_enctab[((src[0] << 4) & 0x30) | ((src[1] >> 4) & 0x0f)]; + dst[2] = duk_base64_enctab[((src[1] << 2) & 0x3f) | ((src[2] >> 6) & 0x03)]; + dst[3] = duk_base64_enctab[src[2] & 0x3f]; + src += 3; dst += 4; #endif -} - -DUK_LOCAL DUK_ALWAYS_INLINE void duk__base64_encode_fast_2(const duk_uint8_t *src, duk_uint8_t *dst) { - duk_uint_t t; - - t = (duk_uint_t) src[0]; - t = (t << 8) + (duk_uint_t) src[1]; - dst[0] = duk__base64_enctab_fast[t >> 10]; /* XXXXXX-- -------- */ - dst[1] = duk__base64_enctab_fast[(t >> 4) & 0x3fU]; /* ------XX XXXX---- */ - dst[2] = duk__base64_enctab_fast[(t << 2) & 0x3fU]; /* -------- ----XXXX */ - dst[3] = DUK_ASC_EQUALS; -} - -DUK_LOCAL DUK_ALWAYS_INLINE void duk__base64_encode_fast_1(const duk_uint8_t *src, duk_uint8_t *dst) { - duk_uint_t t; - - t = (duk_uint_t) src[0]; - dst[0] = duk__base64_enctab_fast[t >> 2]; /* XXXXXX-- */ - dst[1] = duk__base64_enctab_fast[(t << 4) & 0x3fU]; /* ------XX */ - dst[2] = DUK_ASC_EQUALS; - dst[3] = DUK_ASC_EQUALS; -} - -DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) { - duk_size_t n; - const duk_uint8_t *p; - duk_uint8_t *q; - - n = srclen; - p = src; - q = dst; - - if (n >= 16U) { - /* Fast path, unrolled by 4, allows interleaving. Process - * 12-byte input chunks which encode to 16-char output chunks. - * Only enter when at least one block is emitted (avoids div+mul - * for short inputs too). - */ - const duk_uint8_t *p_end_fast; + } - p_end_fast = p + ((n / 12U) * 12U); - DUK_ASSERT(p_end_fast >= p + 12); - do { - duk__base64_encode_fast_3(p, q); - duk__base64_encode_fast_3(p + 3, q + 4); - duk__base64_encode_fast_3(p + 6, q + 8); - duk__base64_encode_fast_3(p + 9, q + 12); - p += 12; - q += 16; - } while (DUK_LIKELY(p != p_end_fast)); - - DUK_ASSERT(src + srclen >= p); - n = (duk_size_t) (src + srclen - p); - DUK_ASSERT(n < 12U); - } - - /* Remainder. */ - while (n >= 3U) { - duk__base64_encode_fast_3(p, q); - p += 3; - q += 4; - n -= 3U; - } - DUK_ASSERT(n == 0U || n == 1U || n == 2U); - if (n == 1U) { - duk__base64_encode_fast_1(p, q); -#if 0 /* Unnecessary. */ - p += 1; - q += 4; - n -= 1U; -#endif - } else if (n == 2U) { - duk__base64_encode_fast_2(p, q); -#if 0 /* Unnecessary. */ - p += 2; - q += 4; - n -= 2U; -#endif - } else { - DUK_ASSERT(n == 0U); /* nothing to do */ - ; + switch (n_final) { + /* case 0: nop */ + case 1: { + /* XX== */ + t = (duk_uint_t) (*src++); + *dst++ = duk_base64_enctab[t >> 2]; /* XXXXXX-- */ + *dst++ = duk_base64_enctab[(t << 4) & 0x3f]; /* ------XX */ + *dst++ = DUK_ASC_EQUALS; + *dst++ = DUK_ASC_EQUALS; + break; + } + case 2: { + /* XXX= */ + t = (duk_uint_t) (*src++); + t = (t << 8) + (duk_uint_t) (*src++); + *dst++ = duk_base64_enctab[t >> 10]; /* XXXXXX-- -------- */ + *dst++ = duk_base64_enctab[(t >> 4) & 0x3f]; /* ------XX XXXX---- */ + *dst++ = duk_base64_enctab[(t << 2) & 0x3f]; /* -------- ----XXXX */ + *dst++ = DUK_ASC_EQUALS; + break; + } } } #else /* DUK_USE_BASE64_FASTPATH */ DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) { - duk_small_uint_t i, npad; - duk_uint_t t, x, y; - const duk_uint8_t *p; - const duk_uint8_t *p_end; - duk_uint8_t *q; - - p = src; - p_end = src + srclen; - q = dst; - npad = 0U; + duk_small_uint_t i, snip; + duk_uint_t t; + duk_uint_fast8_t x, y; + const duk_uint8_t *src_end; - while (p < p_end) { - /* Read 3 bytes into 't', padded by zero. */ + src_end = src + srclen; + + while (src < src_end) { + /* read 3 bytes into 't', padded by zero */ + snip = 4; t = 0; for (i = 0; i < 3; i++) { t = t << 8; - if (p < p_end) { - t += (duk_uint_t) (*p++); + if (src >= src_end) { + snip--; } else { - /* This only happens on the last loop and we're - * guaranteed to exit on the next loop. - */ - npad++; + t += (duk_uint_t) (*src++); } } - DUK_ASSERT(npad <= 2U); - /* Emit 4 encoded characters. If npad > 0, some of the - * chars will be incorrect (zero bits) but we fix up the - * padding after the loop. A straightforward 64-byte - * lookup would be faster and cleaner, but this is shorter. + /* + * Missing bytes snip base64 example + * 0 4 XXXX + * 1 3 XXX= + * 2 2 XX== */ + + DUK_ASSERT(snip >= 2 && snip <= 4); + for (i = 0; i < 4; i++) { - x = ((t >> 18) & 0x3fU); + x = (duk_uint_fast8_t) ((t >> 18) & 0x3f); t = t << 6; - if (x <= 51U) { - if (x <= 25) { - y = x + DUK_ASC_UC_A; - } else { - y = x - 26 + DUK_ASC_LC_A; - } + /* A straightforward 64-byte lookup would be faster + * and cleaner, but this is shorter. + */ + if (i >= snip) { + y = '='; + } else if (x <= 25) { + y = x + 'A'; + } else if (x <= 51) { + y = x - 26 + 'a'; + } else if (x <= 61) { + y = x - 52 + '0'; + } else if (x == 62) { + y = '+'; } else { - if (x <= 61U) { - y = x - 52 + DUK_ASC_0; - } else if (x == 62) { - y = DUK_ASC_PLUS; - } else { - DUK_ASSERT(x == 63); - y = DUK_ASC_SLASH; - } + y = '/'; } - *q++ = (duk_uint8_t) y; + *dst++ = (duk_uint8_t) y; } } - - /* Handle padding by rewriting 0-2 bogus characters at the end. - * - * Missing bytes npad base64 example - * 0 0 #### - * 1 1 ###= - * 2 2 ##== - */ - DUK_ASSERT(npad <= 2U); - while (npad > 0U) { - *(q - npad) = DUK_ASC_EQUALS; - npad--; - } } #endif /* DUK_USE_BASE64_FASTPATH */ #if defined(DUK_USE_BASE64_FASTPATH) DUK_LOCAL duk_bool_t duk__base64_decode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst, duk_uint8_t **out_dst_final) { duk_int_t x; - duk_uint_t t; + duk_int_t t; duk_small_uint_t n_equal; - duk_int8_t step; - const duk_uint8_t *p; - const duk_uint8_t *p_end; - const duk_uint8_t *p_end_safe; - duk_uint8_t *q; - - p = src; - p_end = src + srclen; - p_end_safe = p_end - 8; /* If 'src <= src_end_safe', safe to read 8 bytes. */ - q = dst; - - /* Alternate between a fast path which processes clean groups with no - * padding or whitespace, and a slow path which processes one arbitrary - * group and then re-enters the fast path. This handles e.g. base64 - * with newlines reasonably well because the majority of a line is in - * the fast path. + duk_small_uint_t n_chars; + const duk_uint8_t *src_end; + const duk_uint8_t *src_end_safe; + + src_end = src + srclen; + src_end_safe = src_end - 4; /* if 'src < src_end_safe', safe to read 4 bytes */ + + /* Innermost fast path processes 4 valid base-64 characters at a time + * but bails out on whitespace, padding chars ('=') and invalid chars. + * Once the slow path segment has been processed, we return to the + * inner fast path again. This handles e.g. base64 with newlines + * reasonably well because the majority of a line is in the fast path. */ for (;;) { - /* Fast path, on each loop handle two 4-char input groups. - * If both are clean, emit 6 bytes and continue. If first - * is clean, emit 3 bytes and drop out; otherwise emit - * nothing and drop out. This approach could be extended to - * more groups per loop, but for inputs with e.g. periodic - * newlines (which are common) it might not be an improvement. - */ - while (DUK_LIKELY(p <= p_end_safe)) { - duk_int_t t1, t2; + /* Fast path, handle units with just actual encoding characters. */ - /* The lookup byte is intentionally sign extended to - * (at least) 32 bits and then ORed. This ensures - * that is at least 1 byte is negative, the highest - * bit of the accumulator will be set at the end and - * we don't need to check every byte. - * - * Read all input bytes first before writing output - * bytes to minimize aliasing. + while (src <= src_end_safe) { + /* The lookup byte is intentionally sign extended to (at least) + * 32 bits and then ORed. This ensures that is at least 1 byte + * is negative, the highest bit of 't' will be set at the end + * and we don't need to check every byte. */ - DUK_DDD(DUK_DDDPRINT("fast loop: p=%p, p_end_safe=%p, p_end=%p", - (const void *) p, (const void *) p_end_safe, (const void *) p_end)); + DUK_DDD(DUK_DDDPRINT("fast loop: src=%p, src_end_safe=%p, src_end=%p", + (const void *) src, (const void *) src_end_safe, (const void *) src_end)); - t1 = (duk_int_t) duk__base64_dectab_fast[p[0]]; - t1 = (duk_int_t) ((duk_uint_t) t1 << 6) | (duk_int_t) duk__base64_dectab_fast[p[1]]; - t1 = (duk_int_t) ((duk_uint_t) t1 << 6) | (duk_int_t) duk__base64_dectab_fast[p[2]]; - t1 = (duk_int_t) ((duk_uint_t) t1 << 6) | (duk_int_t) duk__base64_dectab_fast[p[3]]; - - t2 = (duk_int_t) duk__base64_dectab_fast[p[4]]; - t2 = (duk_int_t) ((duk_uint_t) t2 << 6) | (duk_int_t) duk__base64_dectab_fast[p[5]]; - t2 = (duk_int_t) ((duk_uint_t) t2 << 6) | (duk_int_t) duk__base64_dectab_fast[p[6]]; - t2 = (duk_int_t) ((duk_uint_t) t2 << 6) | (duk_int_t) duk__base64_dectab_fast[p[7]]; - - q[0] = (duk_uint8_t) (((duk_uint_t) t1 >> 16) & 0xffU); - q[1] = (duk_uint8_t) (((duk_uint_t) t1 >> 8) & 0xffU); - q[2] = (duk_uint8_t) ((duk_uint_t) t1 & 0xffU); - - q[3] = (duk_uint8_t) (((duk_uint_t) t2 >> 16) & 0xffU); - q[4] = (duk_uint8_t) (((duk_uint_t) t2 >> 8) & 0xffU); - q[5] = (duk_uint8_t) ((duk_uint_t) t2 & 0xffU); - - /* Optimistic check using one branch. */ - if (DUK_LIKELY((t1 | t2) >= 0)) { - p += 8; - q += 6; - } else if (t1 >= 0) { - DUK_DDD(DUK_DDDPRINT("fast loop first group was clean, second was not, process one slow path group")); - DUK_ASSERT(t2 < 0); - p += 4; - q += 3; - break; - } else { - DUK_DDD(DUK_DDDPRINT("fast loop first group was not clean, second does not matter, process one slow path group")); - DUK_ASSERT(t1 < 0); + t = (duk_int_t) duk_base64_dectab[*src++]; + t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++]; + t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++]; + t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++]; + + if (DUK_UNLIKELY(t < 0)) { + DUK_DDD(DUK_DDDPRINT("fast loop unit was not clean, process one slow path unit")); + src -= 4; break; } - } /* fast path */ - /* Slow path step 1: try to scan a 4-character encoded group, - * end-of-input, or start-of-padding. We exit with: - * 1. n_chars == 4: full group, no padding, no end-of-input. - * 2. n_chars < 4: partial group (may also be 0), encountered - * padding or end of input. - * - * The accumulator is initialized to 1; this allows us to detect - * a full group by comparing >= 0x1000000 without an extra - * counter variable. - */ - t = 1UL; + DUK_ASSERT(t <= 0xffffffL); + DUK_ASSERT((t >> 24) == 0); + *dst++ = (duk_uint8_t) (t >> 16); + *dst++ = (duk_uint8_t) ((t >> 8) & 0xff); + *dst++ = (duk_uint8_t) (t & 0xff); + } + + /* Handle one slow path unit (or finish if we're done). */ + + n_equal = 0; + n_chars = 0; + t = 0; for (;;) { - DUK_DDD(DUK_DDDPRINT("slow loop: p=%p, p_end=%p, t=%lu", - (const void *) p, (const void *) p_end, (unsigned long) t)); + DUK_DDD(DUK_DDDPRINT("slow loop: src=%p, src_end=%p, n_chars=%ld, n_equal=%ld, t=%ld", + (const void *) src, (const void *) src_end, (long) n_chars, (long) n_equal, (long) t)); - if (DUK_LIKELY(p < p_end)) { - x = duk__base64_dectab_fast[*p++]; - if (DUK_LIKELY(x >= 0)) { - DUK_ASSERT(x >= 0 && x <= 63); - t = (t << 6) + (duk_uint_t) x; - if (t >= 0x1000000UL) { - break; - } - } else if (x == -1) { + if (DUK_UNLIKELY(src >= src_end)) { + goto done; /* two level break */ + } + + x = duk_base64_dectab[*src++]; + if (DUK_UNLIKELY(x < 0)) { + if (x == -2) { continue; /* allowed ascii whitespace */ - } else if (x == -2) { - p--; - break; /* start of padding */ + } else if (x == -3) { + n_equal++; + t <<= 6; } else { - DUK_ASSERT(x == -3); + DUK_ASSERT(x == -1); goto decode_error; } } else { - break; /* end of input */ + DUK_ASSERT(x >= 0 && x <= 63); + if (n_equal > 0) { + /* Don't allow actual chars after equal sign. */ + goto decode_error; + } + t = (t << 6) + x; } - } /* slow path step 1 */ - - /* Complete the padding by simulating pad characters, - * regardless of actual input padding chars. - */ - n_equal = 0; - while (t < 0x1000000UL) { - t = (t << 6) + 0U; - n_equal++; - } - /* Slow path step 2: deal with full/partial group, padding, - * etc. Note that for num chars in [0,3] we intentionally emit - * 3 bytes but don't step forward that much, buffer space is - * guaranteed in setup. - * - * num chars: - * 0 #### no output (= step 0) - * 1 #=== reject, 6 bits of data - * 2 ##== 12 bits of data, output 1 byte (= step 1) - * 3 ###= 18 bits of data, output 2 bytes (= step 2) - * 4 #### 24 bits of data, output 3 bytes (= step 3) - */ - q[0] = (duk_uint8_t) ((t >> 16) & 0xffU); - q[1] = (duk_uint8_t) ((t >> 8) & 0xffU); - q[2] = (duk_uint8_t) (t & 0xffU); - - DUK_ASSERT(n_equal <= 4); - step = duk__base64_decode_nequal_step[n_equal]; - if (DUK_UNLIKELY(step < 0)) { - goto decode_error; - } - q += step; - - /* Slow path step 3: read and ignore padding and whitespace - * until (a) next non-padding and non-whitespace character - * after which we resume the fast path, or (b) end of input. - * This allows us to accept missing, partial, full, and extra - * padding cases uniformly. We also support concatenated - * base-64 documents because we resume scanning afterwards. - * - * Note that to support concatenated documents well, the '=' - * padding found inside the input must also allow for 'extra' - * padding. For example, 'Zm===' decodes to 'f' and has one - * extra padding char. So, 'Zm===Zm' should decode 'ff', even - * though the standard break-up would be 'Zm==' + '=Zm' which - * doesn't make sense. - * - * We also accept prepended padding like '==Zm9', because it - * is equivalent to an empty document with extra padding ('==') - * followed by a valid document. - */ + if (DUK_UNLIKELY(n_chars == 3)) { + /* Emit 3 bytes and backtrack if there was padding. There's + * always space for the whole 3 bytes so no check needed. + */ + DUK_ASSERT(t <= 0xffffffL); + DUK_ASSERT((t >> 24) == 0); + *dst++ = (duk_uint8_t) (t >> 16); + *dst++ = (duk_uint8_t) ((t >> 8) & 0xff); + *dst++ = (duk_uint8_t) (t & 0xff); + + if (DUK_UNLIKELY(n_equal > 0)) { + DUK_ASSERT(n_equal <= 4); + + /* There may be whitespace between the equal signs. */ + if (n_equal == 1) { + /* XXX= */ + dst -= 1; + } else if (n_equal == 2) { + /* XX== */ + dst -= 2; + } else { + goto decode_error; /* invalid padding */ + } - for (;;) { - if (DUK_UNLIKELY(p >= p_end)) { - goto done; - } - x = duk__base64_dectab_fast[*p++]; - if (x == -1 || x == -2) { - ; /* padding or whitespace, keep eating */ + /* Continue parsing after padding, allows concatenated, + * padded base64. + */ + } + break; /* back to fast loop */ } else { - p--; - break; /* backtrack and go back to fast path, even for -1 */ + n_chars++; } - } /* slow path step 3 */ - } /* outer fast+slow path loop */ - + } + } done: - DUK_DDD(DUK_DDDPRINT("done; p=%p, p_end=%p", - (const void *) p, (const void *) p_end)); + DUK_DDD(DUK_DDDPRINT("done; src=%p, src_end=%p, n_chars=%ld", + (const void *) src, (const void *) src_end, (long) n_chars)); + + DUK_ASSERT(src == src_end); - DUK_ASSERT(p == p_end); + if (n_chars != 0) { + /* Here we'd have the option of decoding unpadded base64 + * (e.g. "xxxxyy" instead of "xxxxyy==". Currently not + * accepted. + */ + goto decode_error; + } - *out_dst_final = q; + *out_dst_final = dst; return 1; decode_error: @@ -459,138 +280,94 @@ } #else /* DUK_USE_BASE64_FASTPATH */ DUK_LOCAL duk_bool_t duk__base64_decode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst, duk_uint8_t **out_dst_final) { - duk_uint_t t, x; - duk_int_t y; - duk_int8_t step; - const duk_uint8_t *p; - const duk_uint8_t *p_end; - duk_uint8_t *q; - /* 0x09, 0x0a, or 0x0d */ - duk_uint32_t mask_white = (1U << 9) | (1U << 10) | (1U << 13); - - /* 't' tracks progress of the decoded group: - * - * t == 1 no valid chars yet - * t >= 0x40 1x6 = 6 bits shifted in - * t >= 0x1000 2x6 = 12 bits shifted in - * t >= 0x40000 3x6 = 18 bits shifted in - * t >= 0x1000000 4x6 = 24 bits shifted in - * - * By initializing t=1 there's no need for a separate counter for - * the number of characters found so far. - */ - p = src; - p_end = src + srclen; - q = dst; - t = 1UL; - - for (;;) { - duk_small_uint_t n_equal; + duk_uint_t t; + duk_uint_fast8_t x, y; + duk_small_uint_t group_idx; + duk_small_uint_t n_equal; + const duk_uint8_t *src_end; - DUK_ASSERT(t >= 1U); - if (p >= p_end) { - /* End of input: if input exists, treat like - * start of padding, finish the block, then - * re-enter here to see we're done. + src_end = src + srclen; + t = 0; + group_idx = 0; + n_equal = 0; + + while (src < src_end) { + x = *src++; + + if (x >= 'A' && x <= 'Z') { + y = x - 'A' + 0; + } else if (x >= 'a' && x <= 'z') { + y = x - 'a' + 26; + } else if (x >= '0' && x <= '9') { + y = x - '0' + 52; + } else if (x == '+') { + y = 62; + } else if (x == '/') { + y = 63; + } else if (x == '=') { + /* We don't check the zero padding bytes here right now + * (that they're actually zero). This seems to be common + * behavior for base-64 decoders. */ - if (t == 1U) { - break; - } else { - goto simulate_padding; - } - } - - x = *p++; - if (x >= 0x41U) { - /* Valid: a-z and A-Z. */ - DUK_ASSERT(x >= 0x41U && x <= 0xffU); - if (x >= 0x61U && x <= 0x7aU) { - y = (duk_int_t) x - 0x61 + 26; - } else if (x <= 0x5aU) { - y = (duk_int_t) x - 0x41; - } else { - goto decode_error; - } - } else if (x >= 0x30U) { - /* Valid: 0-9 and =. */ - DUK_ASSERT(x >= 0x30U && x <= 0x40U); - if (x <= 0x39U) { - y = (duk_int_t) x - 0x30 + 52; - } else if (x == 0x3dU) { - /* Skip padding and whitespace unless we're in the - * middle of a block. Otherwise complete group by - * simulating shifting in the correct padding. - */ - if (t == 1U) { - continue; - } - goto simulate_padding; - } else { - goto decode_error; - } - } else if (x >= 0x20U) { - /* Valid: +, /, and 0x20 whitespace. */ - DUK_ASSERT(x >= 0x20U && x <= 0x2fU); - if (x == 0x2bU) { - y = 62; - } else if (x == 0x2fU) { - y = 63; - } else if (x == 0x20U) { - continue; - } else { - goto decode_error; - } + n_equal++; + t <<= 6; /* shift in zeroes */ + goto skip_add; + } else if (x == 0x09 || x == 0x0a || x == 0x0d || x == 0x20) { + /* allow basic ASCII whitespace */ + continue; } else { - /* Valid: whitespace. */ - duk_uint32_t m; - DUK_ASSERT(x < 0x20U); /* 0x00 to 0x1f */ - m = (1U << x); - if (mask_white & m) { - /* Allow basic ASCII whitespace. */ - continue; - } else { - goto decode_error; - } + goto decode_error; } - DUK_ASSERT(y >= 0 && y <= 63); - t = (t << 6) + (duk_uint_t) y; - if (t < 0x1000000UL) { - continue; + if (n_equal > 0) { + /* Don't allow mixed padding and actual chars. */ + goto decode_error; } - /* fall through; no padding will be added */ + t = (t << 6) + y; + skip_add: - simulate_padding: - n_equal = 0; - while (t < 0x1000000UL) { - t = (t << 6) + 0U; - n_equal++; - } + if (group_idx == 3) { + /* output 3 bytes from 't' */ + *dst++ = (duk_uint8_t) ((t >> 16) & 0xff); + *dst++ = (duk_uint8_t) ((t >> 8) & 0xff); + *dst++ = (duk_uint8_t) (t & 0xff); + + if (DUK_UNLIKELY(n_equal > 0)) { + /* Backtrack. */ + DUK_ASSERT(n_equal <= 4); + if (n_equal == 1) { + dst -= 1; + } else if (n_equal == 2) { + dst -= 2; + } else { + goto decode_error; /* invalid padding */ + } - /* Output 3 bytes from 't' and advance as needed. */ - q[0] = (duk_uint8_t) ((t >> 16) & 0xffU); - q[1] = (duk_uint8_t) ((t >> 8) & 0xffU); - q[2] = (duk_uint8_t) (t & 0xffU); - - DUK_ASSERT(n_equal <= 4U); - step = duk__base64_decode_nequal_step[n_equal]; - if (step < 0) { - goto decode_error; + /* Here we can choose either to end parsing and ignore + * whatever follows, or to continue parsing in case + * multiple (possibly padded) base64 strings have been + * concatenated. Currently, keep on parsing. + */ + n_equal = 0; + } + + t = 0; + group_idx = 0; + } else { + group_idx++; } - q += step; + } - /* Re-enter loop. The actual padding characters are skipped - * by the main loop. This handles cases like missing, partial, - * full, and extra padding, and allows parsing of concatenated - * documents (with extra padding) like: Zm===Zm. Also extra - * prepended padding is accepted: ===Zm9v. + if (group_idx != 0) { + /* Here we'd have the option of decoding unpadded base64 + * (e.g. "xxxxyy" instead of "xxxxyy==". Currently not + * accepted. */ - t = 1U; + goto decode_error; } - DUK_ASSERT(t == 1UL); - *out_dst_final = q; + *out_dst_final = dst; return 1; decode_error: @@ -607,12 +384,15 @@ DUK_ASSERT_API_ENTRY(thr); + /* XXX: optimize for string inputs: no need to coerce to a buffer + * which makes a copy of the input. + */ + idx = duk_require_normalize_index(thr, idx); src = duk__prep_codec_arg(thr, idx, &srclen); /* Note: for srclen=0, src may be NULL */ - /* Compute exact output length. Computation must not wrap; this - * limit works for 32-bit size_t: + /* Computation must not wrap; this limit works for 32-bit size_t: * >>> srclen = 3221225469 * >>> '%x' % ((srclen + 2) / 3 * 4) * 'fffffffc' @@ -620,7 +400,7 @@ if (srclen > 3221225469UL) { goto type_error; } - dstlen = (srclen + 2U) / 3U * 4U; + dstlen = (srclen + 2) / 3 * 4; dst = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, dstlen); duk__base64_encode_helper((const duk_uint8_t *) src, srclen, dst); @@ -631,7 +411,7 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_BASE64_ENCODE_FAILED); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } DUK_EXTERNAL void duk_base64_decode(duk_hthread *thr, duk_idx_t idx) { @@ -640,24 +420,31 @@ duk_size_t dstlen; duk_uint8_t *dst; duk_uint8_t *dst_final; + duk_bool_t retval; DUK_ASSERT_API_ENTRY(thr); + /* XXX: optimize for buffer inputs: no need to coerce to a string + * which causes an unnecessary interning. + */ + idx = duk_require_normalize_index(thr, idx); src = duk__prep_codec_arg(thr, idx, &srclen); - /* Round up and add safety margin. Avoid addition before division to - * avoid possibility of wrapping. Margin includes +3 for rounding up, - * and +3 for one extra group: the decoder may emit and then backtrack - * a full group (3 bytes) from zero-sized input for technical reasons. - * Similarly, 'xx' may ecause 1+3 = bytes to be emitted and then - * backtracked. + /* Computation must not wrap, only srclen + 3 is at risk of + * wrapping because after that the number gets smaller. + * This limit works for 32-bit size_t: + * 0x100000000 - 3 - 1 = 4294967292 */ - dstlen = (srclen / 4) * 3 + 6; /* upper limit, assuming no whitespace etc */ + if (srclen > 4294967292UL) { + goto type_error; + } + dstlen = (srclen + 3) / 4 * 3; /* upper limit, assuming no whitespace etc */ dst = (duk_uint8_t *) duk_push_dynamic_buffer(thr, dstlen); /* Note: for dstlen=0, dst may be NULL */ - if (!duk__base64_decode_helper((const duk_uint8_t *) src, srclen, dst, &dst_final)) { + retval = duk__base64_decode_helper((const duk_uint8_t *) src, srclen, dst, &dst_final); + if (!retval) { goto type_error; } @@ -668,27 +455,8 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_BASE64_DECODE_FAILED); - DUK_WO_NORETURN(return;); -} -#else /* DUK_USE_BASE64_SUPPORT */ -DUK_EXTERNAL const char *duk_base64_encode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); -} - -DUK_EXTERNAL void duk_base64_decode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } -#endif /* DUK_USE_BASE64_SUPPORT */ - -/* - * Hex - */ -#if defined(DUK_USE_HEX_SUPPORT) DUK_EXTERNAL const char *duk_hex_encode(duk_hthread *thr, duk_idx_t idx) { const duk_uint8_t *inp; duk_size_t len; @@ -799,12 +567,8 @@ } } for (; i < len; i += 2) { - /* First cast to duk_int_t to sign extend, second cast to - * duk_uint_t to avoid signed left shift, and final cast to - * duk_int_t result type. - */ - t = (duk_int_t) ((((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i]]) << 4U) | - ((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i + 1]])); + t = (((duk_int_t) duk_hex_dectab[inp[i]]) << 4) | + ((duk_int_t) duk_hex_dectab[inp[i + 1]]); if (DUK_UNLIKELY(t < 0)) { goto type_error; } @@ -816,8 +580,8 @@ * at least 16 bits. If either nybble is invalid, the * resulting 't' will be < 0. */ - t = (duk_int_t) ((((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i]]) << 4U) | - ((duk_uint_t) (duk_int_t) duk_hex_dectab[inp[i + 1]])); + t = (((duk_int_t) duk_hex_dectab[inp[i]]) << 4) | + ((duk_int_t) duk_hex_dectab[inp[i + 1]]); if (DUK_UNLIKELY(t < 0)) { goto type_error; } @@ -830,24 +594,7 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_HEX_DECODE_FAILED); - DUK_WO_NORETURN(return;); -} -#else /* DUK_USE_HEX_SUPPORT */ -DUK_EXTERNAL const char *duk_hex_encode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } -DUK_EXTERNAL void duk_hex_decode(duk_hthread *thr, duk_idx_t idx) { - DUK_UNREF(idx); - DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); -} -#endif /* DUK_USE_HEX_SUPPORT */ - -/* - * JSON - */ #if defined(DUK_USE_JSON_SUPPORT) DUK_EXTERNAL const char *duk_json_encode(duk_hthread *thr, duk_idx_t idx) { @@ -900,13 +647,11 @@ DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return NULL;); } DUK_EXTERNAL void duk_json_decode(duk_hthread *thr, duk_idx_t idx) { DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_JSON_SUPPORT */ diff -Nru duktape-2.3.0/src-separate/duk_api_compile.c duktape-2.2.0/src-separate/duk_api_compile.c --- duktape-2.3.0/src-separate/duk_api_compile.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_api_compile.c 2017-09-23 01:06:08.000000000 +0000 @@ -89,7 +89,6 @@ if ((flags & DUK_COMPILE_NOSOURCE) || /* args incorrect */ (h_sourcecode == NULL)) { /* e.g. duk_push_string_file_raw() pushed undefined */ DUK_ERROR_TYPE(thr, DUK_STR_NO_SOURCECODE); - DUK_WO_NORETURN(return 0;); } DUK_ASSERT(h_sourcecode != NULL); comp_args->src_buffer = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_sourcecode); diff -Nru duktape-2.3.0/src-separate/duk_api_debug.c duktape-2.2.0/src-separate/duk_api_debug.c --- duktape-2.3.0/src-separate/duk_api_debug.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_api_debug.c 2017-09-23 01:06:08.000000000 +0000 @@ -42,7 +42,6 @@ DUK_EXTERNAL void duk_push_context_dump(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_JSON_SUPPORT */ @@ -154,7 +153,7 @@ top = duk_get_top(thr); if (top < nvalues) { DUK_ERROR_RANGE(thr, "not enough stack values for notify"); - DUK_WO_NORETURN(return 0;); + return ret; /* unreachable */ } if (duk_debug_is_attached(thr->heap)) { duk_debug_write_notify(thr, DUK_DBG_CMD_APPNOTIFY); @@ -221,13 +220,11 @@ DUK_UNREF(detached_cb); DUK_UNREF(udata); DUK_ERROR_TYPE(thr, "no debugger support"); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_debugger_detach(duk_hthread *thr) { DUK_ASSERT_API_ENTRY(thr); DUK_ERROR_TYPE(thr, "no debugger support"); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_debugger_cooperate(duk_hthread *thr) { @@ -244,7 +241,7 @@ top = duk_get_top(thr); if (top < nvalues) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } /* No debugger support, just pop values. */ diff -Nru duktape-2.3.0/src-separate/duk_api_heap.c duktape-2.2.0/src-separate/duk_api_heap.c --- duktape-2.3.0/src-separate/duk_api_heap.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_api_heap.c 2017-09-23 01:06:08.000000000 +0000 @@ -105,7 +105,7 @@ duk_push_tval(thr, &lj->value2); /* XXX: creating_error == 0 is asserted above, so no need to store. */ - duk_memcpy((void *) &snapshot->lj, (const void *) lj, sizeof(duk_ljstate)); + DUK_MEMCPY((void *) &snapshot->lj, (const void *) lj, sizeof(duk_ljstate)); snapshot->creating_error = heap->creating_error; snapshot->curr_thread = heap->curr_thread; snapshot->call_recursion_depth = heap->call_recursion_depth; @@ -135,7 +135,7 @@ heap = thr->heap; - duk_memcpy((void *) &heap->lj, (const void *) &snapshot->lj, sizeof(duk_ljstate)); + DUK_MEMCPY((void *) &heap->lj, (const void *) &snapshot->lj, sizeof(duk_ljstate)); heap->creating_error = snapshot->creating_error; heap->curr_thread = snapshot->curr_thread; heap->call_recursion_depth = snapshot->call_recursion_depth; diff -Nru duktape-2.3.0/src-separate/duk_api_inspect.c duktape-2.2.0/src-separate/duk_api_inspect.c --- duktape-2.3.0/src-separate/duk_api_inspect.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_api_inspect.c 2017-09-23 01:06:08.000000000 +0000 @@ -66,7 +66,7 @@ DUK_ASSERT_API_ENTRY(thr); /* Assume two's complement and set everything to -1. */ - duk_memset((void *) &vals, (int) 0xff, sizeof(vals)); + DUK_MEMSET((void *) &vals, (int) 0xff, sizeof(vals)); DUK_ASSERT(vals[DUK__IDX_TYPE] == -1); /* spot check one */ tv = duk_get_tval_or_unused(thr, idx); @@ -82,12 +82,12 @@ goto finish; } duk_push_pointer(thr, (void *) h); - duk_put_prop_literal(thr, -2, "hptr"); + duk_put_prop_string(thr, -2, "hptr"); #if 0 /* Covers a lot of information, e.g. buffer and string variants. */ duk_push_uint(thr, (duk_uint_t) DUK_HEAPHDR_GET_FLAGS(h)); - duk_put_prop_literal(thr, -2, "hflags"); + duk_put_prop_string(thr, -2, "hflags"); #endif #if defined(DUK_USE_REFERENCE_COUNTING) @@ -132,7 +132,7 @@ } vals[DUK__IDX_CLASS] = (duk_int_t) DUK_HOBJECT_GET_CLASS_NUMBER(h_obj); - vals[DUK__IDX_PBYTES] = (duk_int_t) DUK_HOBJECT_P_ALLOC_SIZE(h_obj); + vals[DUK__IDX_PBYTES] = (duk_int_t) DUK_HOBJECT_P_ALLOC_SIZE(h_obj), vals[DUK__IDX_ESIZE] = (duk_int_t) DUK_HOBJECT_GET_ESIZE(h_obj); vals[DUK__IDX_ENEXT] = (duk_int_t) DUK_HOBJECT_GET_ENEXT(h_obj); vals[DUK__IDX_ASIZE] = (duk_int_t) DUK_HOBJECT_GET_ASIZE(h_obj); diff -Nru duktape-2.3.0/src-separate/duk_api_internal.h duktape-2.2.0/src-separate/duk_api_internal.h --- duktape-2.3.0/src-separate/duk_api_internal.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_api_internal.h 2017-09-23 01:06:08.000000000 +0000 @@ -142,12 +142,10 @@ DUK_INTERNAL_DECL duk_double_t duk_to_number_m1(duk_hthread *thr); DUK_INTERNAL_DECL duk_double_t duk_to_number_m2(duk_hthread *thr); -DUK_INTERNAL_DECL duk_bool_t duk_to_boolean_top_pop(duk_hthread *thr); - #if defined(DUK_USE_DEBUGGER_SUPPORT) /* only needed by debugger for now */ DUK_INTERNAL_DECL duk_hstring *duk_safe_to_hstring(duk_hthread *thr, duk_idx_t idx); #endif -DUK_INTERNAL_DECL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv, duk_bool_t avoid_side_effects); +DUK_INTERNAL_DECL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv); DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped_raw(duk_hthread *thr, duk_idx_t idx, duk_int_t minval, duk_int_t maxval, duk_bool_t *out_clamped); /* out_clamped=NULL, RangeError if outside range */ DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped(duk_hthread *thr, duk_idx_t idx, duk_int_t minval, duk_int_t maxval); @@ -285,8 +283,6 @@ DUK_INTERNAL_DECL void duk_xdef_prop_stridx_thrower(duk_hthread *thr, duk_idx_t obj_idx, duk_small_uint_t stridx); /* [] -> [] */ -DUK_INTERNAL_DECL duk_bool_t duk_get_method_stridx(duk_hthread *thr, duk_idx_t idx, duk_small_uint_t stridx); - DUK_INTERNAL_DECL void duk_pack(duk_hthread *thr, duk_idx_t count); DUK_INTERNAL_DECL duk_idx_t duk_unpack_array_like(duk_hthread *thr, duk_idx_t idx); #if 0 @@ -323,10 +319,6 @@ DUK_INTERNAL_DECL duk_int_t duk_pcall_method_flags(duk_hthread *thr, duk_idx_t nargs, duk_small_uint_t call_flags); -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL_DECL void duk_to_primitive_ordinary(duk_hthread *thr, duk_idx_t idx, duk_int_t hint); -#endif - /* Raw internal valstack access macros: access is unsafe so call site * must have a guarantee that the index is valid. When that is the case, * using these macro results in faster and smaller code than duk_get_tval(). diff -Nru duktape-2.3.0/src-separate/duk_api_object.c duktape-2.2.0/src-separate/duk_api_object.c --- duktape-2.3.0/src-separate/duk_api_object.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_api_object.c 2017-09-23 01:06:08.000000000 +0000 @@ -8,7 +8,7 @@ * Property handling * * The API exposes only the most common property handling functions. - * The caller can invoke ECMAScript built-ins for full control (e.g. + * The caller can invoke Ecmascript built-ins for full control (e.g. * defineProperty, getOwnPropertyDescriptor). */ @@ -40,7 +40,7 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_string(thr, key); + duk_push_string(thr, key); return duk_get_prop(thr, obj_idx); } @@ -49,22 +49,10 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_lstring(thr, key, key_len); + duk_push_lstring(thr, key, key_len); return duk_get_prop(thr, obj_idx); } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_get_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); - return duk_get_prop(thr, obj_idx); -} -#endif - DUK_EXTERNAL duk_bool_t duk_get_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -77,7 +65,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk_get_prop(thr, obj_idx); } @@ -86,7 +74,7 @@ DUK_ASSERT_STRIDX_VALID(stridx); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_hstring(thr, DUK_HTHREAD_GET_STRING(thr, stridx)); + duk_push_hstring(thr, DUK_HTHREAD_GET_STRING(thr, stridx)); return duk_get_prop(thr, obj_idx); } @@ -105,7 +93,10 @@ if (out_has_prop) { *out_has_prop = rc; } - return duk_to_boolean_top_pop(thr); + rc = duk_to_boolean(thr, -1); + DUK_ASSERT(rc == 0 || rc == 1); + duk_pop(thr); + return rc; } DUK_LOCAL duk_bool_t duk__put_prop_shared(duk_hthread *thr, duk_idx_t obj_idx, duk_idx_t idx_key) { @@ -165,18 +156,6 @@ return duk__put_prop_shared(thr, obj_idx, -1); } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_put_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); - return duk__put_prop_shared(thr, obj_idx, -1); -} -#endif - DUK_EXTERNAL duk_bool_t duk_put_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -189,7 +168,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk__put_prop_shared(thr, obj_idx, -1); } @@ -236,7 +215,7 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_string(thr, key); + duk_push_string(thr, key); return duk_del_prop(thr, obj_idx); } @@ -245,21 +224,9 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_lstring(thr, key, key_len); - return duk_del_prop(thr, obj_idx); -} - -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_del_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); + duk_push_lstring(thr, key, key_len); return duk_del_prop(thr, obj_idx); } -#endif DUK_EXTERNAL duk_bool_t duk_del_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -273,7 +240,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk_del_prop(thr, obj_idx); } @@ -319,7 +286,7 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_string(thr, key); + duk_push_string(thr, key); return duk_has_prop(thr, obj_idx); } @@ -328,21 +295,9 @@ DUK_ASSERT(key != NULL); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_lstring(thr, key, key_len); - return duk_has_prop(thr, obj_idx); -} - -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_has_prop_literal_raw(duk_hthread *thr, duk_idx_t obj_idx, const char *key, duk_size_t key_len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(key != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_literal_raw(thr, key, key_len); + duk_push_lstring(thr, key, key_len); return duk_has_prop(thr, obj_idx); } -#endif DUK_EXTERNAL duk_bool_t duk_has_prop_index(duk_hthread *thr, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { DUK_ASSERT_API_ENTRY(thr); @@ -356,7 +311,7 @@ DUK_ASSERT_API_ENTRY(thr); obj_idx = duk_require_normalize_index(thr, obj_idx); - (void) duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ + duk_push_heapptr(thr, ptr); /* NULL -> 'undefined' */ return duk_has_prop(thr, obj_idx); } @@ -556,17 +511,17 @@ fail_invalid_desc: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_DESCRIPTOR); - DUK_WO_NORETURN(return;); + return; fail_not_callable: DUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE); - DUK_WO_NORETURN(return;); + return; } /* * Object related * - * Note: seal() and freeze() are accessible through ECMAScript bindings, + * Note: seal() and freeze() are accessible through Ecmascript bindings, * and are not exposed through the API. */ @@ -658,7 +613,6 @@ fail_cannot_freeze: DUK_ERROR_TYPE_INVALID_ARGS(thr); /* XXX: proper error message */ - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_seal(duk_hthread *thr, duk_idx_t obj_idx) { @@ -742,38 +696,6 @@ return ret; } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_get_global_literal_raw(duk_hthread *thr, const char *key, duk_size_t key_len) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - ret = duk_get_prop_literal_raw(thr, -1, key, key_len); - duk_remove_m2(thr); - return ret; -} -#endif - -DUK_EXTERNAL duk_bool_t duk_get_global_heapptr(duk_hthread *thr, void *ptr) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - ret = duk_get_prop_heapptr(thr, -1, ptr); - duk_remove_m2(thr); - return ret; -} - - DUK_EXTERNAL duk_bool_t duk_put_global_string(duk_hthread *thr, const char *key) { duk_bool_t ret; @@ -804,56 +726,6 @@ return ret; } -#if !defined(DUK_USE_PREFER_SIZE) -DUK_EXTERNAL duk_bool_t duk_put_global_literal_raw(duk_hthread *thr, const char *key, duk_size_t key_len) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - DUK_ASSERT(key[key_len] == (char) 0); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - duk_insert(thr, -2); - ret = duk_put_prop_literal_raw(thr, -2, key, key_len); /* [ ... global val ] -> [ ... global ] */ - duk_pop(thr); - return ret; -} -#endif - -DUK_EXTERNAL duk_bool_t duk_put_global_heapptr(duk_hthread *thr, void *ptr) { - duk_bool_t ret; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - - /* XXX: direct implementation */ - - duk_push_hobject(thr, thr->builtins[DUK_BIDX_GLOBAL]); - duk_insert(thr, -2); - ret = duk_put_prop_heapptr(thr, -2, ptr); /* [ ... global val ] -> [ ... global ] */ - duk_pop(thr); - return ret; -} - -/* - * ES2015 GetMethod() - */ - -DUK_INTERNAL duk_bool_t duk_get_method_stridx(duk_hthread *thr, duk_idx_t idx, duk_small_uint_t stridx) { - (void) duk_get_prop_stridx(thr, idx, stridx); - if (duk_is_null_or_undefined(thr, -1)) { - duk_pop_nodecref_unsafe(thr); - return 0; - } - if (!duk_is_callable(thr, -1)) { - DUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE); - DUK_WO_NORETURN(return 0;); - } - return 1; -} - /* * Object prototype */ @@ -892,7 +764,7 @@ #if defined(DUK_USE_ROM_OBJECTS) if (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); /* XXX: "read only object"? */ - DUK_WO_NORETURN(return;); + return; } #endif @@ -949,13 +821,11 @@ DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_set_finalizer(duk_hthread *thr, duk_idx_t idx) { DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(idx); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_FINALIZER_SUPPORT */ diff -Nru duktape-2.3.0/src-separate/duk_api_random.c duktape-2.2.0/src-separate/duk_api_random.c --- duktape-2.3.0/src-separate/duk_api_random.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_api_random.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -/* - * Random numbers - */ - -#include "duk_internal.h" - -DUK_EXTERNAL duk_double_t duk_random(duk_hthread *thr) { - return (duk_double_t) DUK_UTIL_GET_RANDOM_DOUBLE(thr); -} diff -Nru duktape-2.3.0/src-separate/duk_api_stack.c duktape-2.2.0/src-separate/duk_api_stack.c --- duktape-2.3.0/src-separate/duk_api_stack.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_api_stack.c 2017-09-23 01:06:08.000000000 +0000 @@ -172,7 +172,7 @@ if (require) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "number", DUK_STR_NOT_NUMBER); - DUK_WO_NORETURN(return 0;); + /* not reachable */ } return def_value; @@ -223,7 +223,7 @@ if (require) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "number", DUK_STR_NOT_NUMBER); - DUK_WO_NORETURN(return 0;); + /* not reachable */ } return def_value; @@ -298,7 +298,7 @@ return (duk_idx_t) uidx; } DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } DUK_INTERNAL duk_tval *duk_get_tval(duk_hthread *thr, duk_idx_t idx) { @@ -374,7 +374,7 @@ return thr->valstack_bottom + uidx; } DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return NULL;); + return NULL; } /* Non-critical. */ @@ -392,7 +392,7 @@ if (DUK_UNLIKELY(duk_normalize_index(thr, idx) < 0)) { DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return;); + return; /* unreachable */ } } @@ -417,7 +417,6 @@ ret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom); if (DUK_UNLIKELY(ret < min_top)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); } return ret; } @@ -462,7 +461,7 @@ #else if (DUK_UNLIKELY(uidx > vs_limit)) { DUK_ERROR_RANGE_INDEX(thr, idx); - DUK_WO_NORETURN(return;); + return; /* unreachable */ } #endif DUK_ASSERT(uidx <= vs_limit); @@ -645,7 +644,7 @@ ret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom) - 1; if (DUK_UNLIKELY(ret < 0)) { DUK_ERROR_RANGE_INDEX(thr, -1); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } return ret; } @@ -846,7 +845,6 @@ */ if (throw_on_error) { DUK_ERROR_RANGE(thr, DUK_STR_VALSTACK_LIMIT); - DUK_WO_NORETURN(return 0;); } return 0; } @@ -854,7 +852,6 @@ if (duk__resize_valstack(thr, new_size) == 0) { if (throw_on_error) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return 0;); } return 0; } @@ -1115,7 +1112,7 @@ if (DUK_UNLIKELY(thr->valstack_top - thr->valstack_bottom <= 0)) { DUK_ERROR_RANGE_INDEX(thr, -1); - DUK_WO_NORETURN(return;); + return; /* unreachable */ } tv_from = thr->valstack_top - 1; tv_to = thr->valstack_top++; @@ -1177,12 +1174,18 @@ DUK_DDD(DUK_DDDPRINT("duk_insert: to_idx=%ld, p=%p, q=%p, nbytes=%lu", (long) to_idx, (void *) p, (void *) q, (unsigned long) nbytes)); - /* No net refcount changes. No need to special case nbytes == 0 - * (p == q). - */ - DUK_TVAL_SET_TVAL(&tv_tmp, q); - duk_memmove((void *) (p + 1), (const void *) p, (size_t) nbytes); - DUK_TVAL_SET_TVAL(p, &tv_tmp); + /* No net refcount changes. */ + + if (nbytes > 0) { + DUK_TVAL_SET_TVAL(&tv_tmp, q); + DUK_ASSERT(nbytes > 0); + DUK_MEMMOVE((void *) (p + 1), (const void *) p, (size_t) nbytes); + DUK_TVAL_SET_TVAL(p, &tv_tmp); + } else { + /* nop: insert top to top */ + DUK_ASSERT(nbytes == 0); + DUK_ASSERT(p == q); + } } DUK_INTERNAL void duk_insert_undefined(duk_hthread *thr, duk_idx_t idx) { @@ -1274,7 +1277,7 @@ #endif nbytes = (duk_size_t) (((duk_uint8_t *) q) - ((duk_uint8_t *) p)); /* Note: 'q' is top-1 */ - duk_memmove((void *) p, (const void *) (p + 1), (size_t) nbytes); + DUK_MEMMOVE((void *) p, (const void *) (p + 1), (size_t) nbytes); /* zero size not an issue: pointers are valid */ DUK_TVAL_SET_UNDEFINED(q); thr->valstack_top--; @@ -1327,7 +1330,7 @@ DUK_TVAL_DECREF_NORZ(thr, tv); } - duk_memmove((void *) tv_dst, (const void *) tv_src, bytes); + DUK_MEMMOVE((void *) tv_dst, (const void *) tv_src, bytes); tv_newtop = thr->valstack_top - count; for (tv = tv_newtop; tv < thr->valstack_top; tv++) { @@ -1366,14 +1369,14 @@ if (DUK_UNLIKELY(to_thr == from_thr)) { DUK_ERROR_TYPE(to_thr, DUK_STR_INVALID_CONTEXT); - DUK_WO_NORETURN(return;); + return; } if (DUK_UNLIKELY((duk_uidx_t) count > (duk_uidx_t) DUK_USE_VALSTACK_LIMIT)) { /* Maximum value check ensures 'nbytes' won't wrap below. * Also handles negative count. */ DUK_ERROR_RANGE_INVALID_COUNT(to_thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count >= 0); @@ -1384,19 +1387,17 @@ DUK_ASSERT(to_thr->valstack_top <= to_thr->valstack_end); if (DUK_UNLIKELY((duk_size_t) ((duk_uint8_t *) to_thr->valstack_end - (duk_uint8_t *) to_thr->valstack_top) < nbytes)) { DUK_ERROR_RANGE_PUSH_BEYOND(to_thr); - DUK_WO_NORETURN(return;); } src = (void *) ((duk_uint8_t *) from_thr->valstack_top - nbytes); if (DUK_UNLIKELY(src < (void *) from_thr->valstack_bottom)) { DUK_ERROR_RANGE_INVALID_COUNT(to_thr); - DUK_WO_NORETURN(return;); } - /* Copy values (no overlap even if to_thr == from_thr; that's not - * allowed now anyway). + /* copy values (no overlap even if to_thr == from_thr; that's not + * allowed now anyway) */ DUK_ASSERT(nbytes > 0); - duk_memcpy((void *) to_thr->valstack_top, (const void *) src, (size_t) nbytes); + DUK_MEMCPY((void *) to_thr->valstack_top, (const void *) src, (size_t) nbytes); p = to_thr->valstack_top; to_thr->valstack_top = (duk_tval *) (void *) (((duk_uint8_t *) p) + nbytes); @@ -1445,7 +1446,7 @@ tv_dst = (duk_tval *) (void *) ((duk_uint8_t *) tv_src + gap_bytes); copy_bytes = (duk_size_t) ((duk_uint8_t *) thr->valstack_top - (duk_uint8_t *) tv_src); thr->valstack_top = (duk_tval *) (void *) ((duk_uint8_t *) thr->valstack_top + gap_bytes); - duk_memmove((void *) tv_dst, (const void *) tv_src, copy_bytes); + DUK_MEMMOVE((void *) tv_dst, (const void *) tv_src, copy_bytes); /* Values in the gap are left as garbage: caller must fill them in * and INCREF them before any side effects. @@ -1466,7 +1467,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_UNDEFINED(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "undefined", DUK_STR_NOT_UNDEFINED); - DUK_WO_NORETURN(return;); } } @@ -1479,7 +1479,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_NULL(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "null", DUK_STR_NOT_NULL); - DUK_WO_NORETURN(return;); } } @@ -1528,7 +1527,6 @@ return ret; } else { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "boolean", DUK_STR_NOT_BOOLEAN); - DUK_WO_NORETURN(return 0;); } } @@ -1590,7 +1588,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_NUMBER(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "number", DUK_STR_NOT_NUMBER); - DUK_WO_NORETURN(return 0.0;); } ret.d = DUK_TVAL_GET_NUMBER(tv); @@ -1822,7 +1819,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_OBJECT(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "object", DUK_STR_NOT_OBJECT); - DUK_WO_NORETURN(return;); } } @@ -1874,7 +1870,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_POINTER(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "pointer", DUK_STR_NOT_POINTER); - DUK_WO_NORETURN(return NULL;); } p = DUK_TVAL_GET_POINTER(tv); /* may be NULL */ return p; @@ -1922,7 +1917,6 @@ } else { if (throw_flag) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "buffer", DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } len = def_size; ret = def_ptr; @@ -2026,7 +2020,6 @@ if (throw_flag) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "buffer", DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } return def_ptr; } @@ -2106,7 +2099,6 @@ h = (duk_hstring *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_STRING); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "string", DUK_STR_NOT_STRING); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -2119,7 +2111,6 @@ h = (duk_hstring *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_STRING); if (DUK_UNLIKELY(h == NULL || DUK_HSTRING_HAS_SYMBOL(h))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "string", DUK_STR_NOT_STRING); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -2137,7 +2128,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "object", DUK_STR_NOT_OBJECT); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -2155,7 +2145,6 @@ h = (duk_hbuffer *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_BUFFER); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "buffer", DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -2180,7 +2169,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_THREAD(h)))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "thread", DUK_STR_NOT_THREAD); - DUK_WO_NORETURN(return NULL;); } return (duk_hthread *) h; } @@ -2205,7 +2193,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_COMPFUNC(h)))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "compiledfunction", DUK_STR_NOT_COMPFUNC); - DUK_WO_NORETURN(return NULL;); } return (duk_hcompfunc *) h; } @@ -2230,7 +2217,6 @@ h = (duk_hobject *) duk__get_tagged_heaphdr_raw(thr, idx, DUK_TAG_OBJECT); if (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_NATFUNC(h)))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "nativefunction", DUK_STR_NOT_NATFUNC); - DUK_WO_NORETURN(return NULL;); } return (duk_hnatfunc *) h; } @@ -2289,7 +2275,6 @@ ret = duk_get_c_function(thr, idx); if (DUK_UNLIKELY(!ret)) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "nativefunction", DUK_STR_NOT_NATFUNC); - DUK_WO_NORETURN(return ret;); } return ret; } @@ -2298,7 +2283,6 @@ DUK_ASSERT_API_ENTRY(thr); if (DUK_UNLIKELY(!duk_is_function(thr, idx))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "function", DUK_STR_NOT_FUNCTION); - DUK_WO_NORETURN(return;); } } @@ -2310,7 +2294,6 @@ h = duk_require_hobject_accept_mask(thr, idx, DUK_TYPE_MASK_LIGHTFUNC); if (DUK_UNLIKELY(h != NULL && !DUK_HOBJECT_HAS_CONSTRUCTABLE(h))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "constructable", DUK_STR_NOT_CONSTRUCTABLE); - DUK_WO_NORETURN(return;); } /* Lightfuncs (h == NULL) are constructable. */ } @@ -2398,7 +2381,6 @@ DUK_ASSERT(tv != NULL); if (DUK_UNLIKELY(!DUK_TVAL_IS_HEAP_ALLOCATED(tv))) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "heapobject", DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return NULL;); } ret = (void *) DUK_TVAL_GET_HEAPHDR(tv); @@ -2432,7 +2414,6 @@ if (type_mask & DUK_TYPE_MASK_THROW) { DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, "object", DUK_STR_NOT_OBJECT); - DUK_WO_NORETURN(return NULL;); } return NULL; } @@ -2493,7 +2474,6 @@ DUK_UNREF(h_class); DUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, (const char *) DUK_HSTRING_GET_DATA(h_class), DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return NULL;); } return h; } @@ -2686,43 +2666,49 @@ } /* E5 Section 9.1 */ -DUK_LOCAL const char * const duk__toprim_hint_strings[3] = { - "default", "string", "number" -}; -DUK_LOCAL void duk__to_primitive_helper(duk_hthread *thr, duk_idx_t idx, duk_int_t hint, duk_bool_t check_symbol) { - /* Inline initializer for coercers[] is not allowed by old compilers like BCC. */ +DUK_EXTERNAL void duk_to_primitive(duk_hthread *thr, duk_idx_t idx, duk_int_t hint) { + /* inline initializer for coercers[] is not allowed by old compilers like BCC */ duk_small_uint_t coercers[2]; + duk_small_uint_t class_number; DUK_ASSERT_API_ENTRY(thr); DUK_ASSERT(hint == DUK_HINT_NONE || hint == DUK_HINT_NUMBER || hint == DUK_HINT_STRING); idx = duk_require_normalize_index(thr, idx); - /* If already primitive, return as is. */ if (!duk_check_type_mask(thr, idx, DUK_TYPE_MASK_OBJECT | DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER)) { + /* Any other values stay as is. */ DUK_ASSERT(!duk_is_buffer(thr, idx)); /* duk_to_string() relies on this behavior */ return; } - /* @@toPrimitive lookup. Also do for plain buffers and lightfuncs - * which mimic objects. + class_number = duk_get_class_number(thr, idx); + + /* XXX: Symbol objects normally coerce via the ES2015-revised ToPrimitive() + * algorithm which consults value[@@toPrimitive] and avoids calling + * .valueOf() and .toString(). Before that is implemented, special + * case Symbol objects to behave as if they had the default @@toPrimitive + * algorithm of E6 Section 19.4.3.4, i.e. return the plain symbol value + * with no further side effects. */ - if (check_symbol && duk_get_method_stridx(thr, idx, DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE)) { - DUK_ASSERT(hint >= 0 && (duk_size_t) hint < sizeof(duk__toprim_hint_strings) / sizeof(const char *)); - duk_dup(thr, idx); - duk_push_string(thr, duk__toprim_hint_strings[hint]); - duk_call_method(thr, 1); /* [ ... method value hint ] -> [ ... res] */ - if (duk_check_type_mask(thr, -1, DUK_TYPE_MASK_OBJECT | - DUK_TYPE_MASK_LIGHTFUNC | - DUK_TYPE_MASK_BUFFER)) { - goto fail; + + if (class_number == DUK_HOBJECT_CLASS_SYMBOL) { + duk_hobject *h_obj; + duk_hstring *h_str; + + /* XXX: pretty awkward, index based API for internal value access? */ + h_obj = duk_known_hobject(thr, idx); + h_str = duk_hobject_get_internal_value_string(thr->heap, h_obj); + if (h_str) { + duk_push_hstring(thr, h_str); + duk_replace(thr, idx); + return; } - duk_replace(thr, idx); - return; } + /* Objects are coerced based on E5 specification. * Lightfuncs are coerced because they behave like * objects even if they're internally a primitive @@ -2730,29 +2716,17 @@ * like ArrayBuffer objects since Duktape 2.x. */ - /* Hint magic for Date is unnecessary in ES2015 because of - * Date.prototype[@@toPrimitive]. However, it is needed if - * symbol support is not enabled. - */ -#if defined(DUK_USE_SYMBOL_BUILTIN) - if (hint == DUK_HINT_NONE) { - hint = DUK_HINT_NUMBER; - } -#else /* DUK_USE_SYMBOL_BUILTIN */ - if (hint == DUK_HINT_NONE) { - duk_small_uint_t class_number; + coercers[0] = DUK_STRIDX_VALUE_OF; + coercers[1] = DUK_STRIDX_TO_STRING; - class_number = duk_get_class_number(thr, idx); + if (hint == DUK_HINT_NONE) { if (class_number == DUK_HOBJECT_CLASS_DATE) { hint = DUK_HINT_STRING; } else { hint = DUK_HINT_NUMBER; } } -#endif /* DUK_USE_SYMBOL_BUILTIN */ - coercers[0] = DUK_STRIDX_VALUE_OF; - coercers[1] = DUK_STRIDX_TO_STRING; if (hint == DUK_HINT_STRING) { coercers[0] = DUK_STRIDX_TO_STRING; coercers[1] = DUK_STRIDX_VALUE_OF; @@ -2768,21 +2742,9 @@ return; } - fail: DUK_ERROR_TYPE(thr, DUK_STR_TOPRIMITIVE_FAILED); - DUK_WO_NORETURN(return;); -} - -DUK_EXTERNAL void duk_to_primitive(duk_hthread *thr, duk_idx_t idx, duk_int_t hint) { - duk__to_primitive_helper(thr, idx, hint, 1 /*check_symbol*/); } -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL void duk_to_primitive_ordinary(duk_hthread *thr, duk_idx_t idx, duk_int_t hint) { - duk__to_primitive_helper(thr, idx, hint, 0 /*check_symbol*/); -} -#endif - /* E5 Section 9.2 */ DUK_EXTERNAL duk_bool_t duk_to_boolean(duk_hthread *thr, duk_idx_t idx) { duk_tval *tv; @@ -2803,22 +2765,6 @@ return val; } -DUK_INTERNAL duk_bool_t duk_to_boolean_top_pop(duk_hthread *thr) { - duk_tval *tv; - duk_bool_t val; - - DUK_ASSERT_API_ENTRY(thr); - - tv = duk_require_tval(thr, -1); - DUK_ASSERT(tv != NULL); - - val = duk_js_toboolean(tv); - DUK_ASSERT(val == 0 || val == 1); - - duk_pop_unsafe(thr); - return val; -} - DUK_EXTERNAL duk_double_t duk_to_number(duk_hthread *thr, duk_idx_t idx) { duk_tval *tv; duk_double_t d; @@ -3098,67 +3044,68 @@ #endif /* Push Object.prototype.toString() output for 'tv'. */ -#if 0 /* See XXX note why this variant doesn't work. */ -DUK_INTERNAL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv, duk_bool_t avoid_side_effects) { - duk_uint_t stridx_bidx = 0; /* (prototype_bidx << 16) + default_tag_stridx */ +DUK_INTERNAL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv) { + duk_small_uint_t stridx; + duk_hstring *h_strclass; DUK_ASSERT_API_ENTRY(thr); - /* Conceptually for any non-undefined/null value we should do a - * ToObject() coercion and look up @@toStringTag (from the object - * prototype) to see if a custom tag should be used. Avoid the - * actual conversion by doing a prototype lookup without the object - * coercion. However, see problem below. - */ - - duk_push_literal(thr, "[object "); /* -> [ ... "[object" ] */ - switch (DUK_TVAL_GET_TAG(tv)) { case DUK_TAG_UNUSED: /* Treat like 'undefined', shouldn't happen. */ case DUK_TAG_UNDEFINED: { - stridx_bidx = DUK_STRIDX_UC_UNDEFINED; - goto use_stridx; + stridx = DUK_STRIDX_UC_UNDEFINED; + break; } case DUK_TAG_NULL: { - stridx_bidx = DUK_STRIDX_UC_NULL; - goto use_stridx; + stridx = DUK_STRIDX_UC_NULL; + break; } case DUK_TAG_BOOLEAN: { - stridx_bidx = (DUK_BIDX_BOOLEAN_PROTOTYPE << 16) + DUK_STRIDX_UC_BOOLEAN; - goto use_proto_bidx; + stridx = DUK_STRIDX_UC_BOOLEAN; + break; } case DUK_TAG_POINTER: { - stridx_bidx = (DUK_BIDX_POINTER_PROTOTYPE << 16) + DUK_STRIDX_UC_POINTER; - goto use_proto_bidx; + stridx = DUK_STRIDX_UC_POINTER; + break; } case DUK_TAG_LIGHTFUNC: { - stridx_bidx = (DUK_BIDX_FUNCTION_PROTOTYPE << 16) + DUK_STRIDX_UC_FUNCTION; - goto use_proto_bidx; + stridx = DUK_STRIDX_UC_FUNCTION; + break; } case DUK_TAG_STRING: { duk_hstring *h; h = DUK_TVAL_GET_STRING(tv); DUK_ASSERT(h != NULL); if (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) { - /* Even without DUK_USE_SYMBOL_BUILTIN the Symbol - * prototype exists so we can lookup @@toStringTag - * and provide [object Symbol] for symbol values - * created from C code. - */ - stridx_bidx = (DUK_BIDX_SYMBOL_PROTOTYPE << 16) + DUK_STRIDX_UC_SYMBOL; + stridx = DUK_STRIDX_UC_SYMBOL; } else { - stridx_bidx = (DUK_BIDX_STRING_PROTOTYPE << 16) + DUK_STRIDX_UC_STRING; + stridx = DUK_STRIDX_UC_STRING; } - goto use_proto_bidx; + break; } case DUK_TAG_OBJECT: { - duk_push_tval(thr, tv); - stridx_bidx = 0xffffffffUL; /* Marker value. */ - goto use_pushed_object; + duk_hobject *h; + duk_small_uint_t classnum; + + h = DUK_TVAL_GET_OBJECT(tv); + DUK_ASSERT(h != NULL); + classnum = DUK_HOBJECT_GET_CLASS_NUMBER(h); + stridx = DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(classnum); + + /* XXX: This is not entirely correct anymore; in ES2015 the + * default lookup should use @@toStringTag to come up with + * e.g. [object Symbol], [object Uint8Array], etc. See + * ES2015 Section 19.1.3.6. The downside of implementing that + * directly is that the @@toStringTag lookup may have side + * effects, so all call sites must be checked for that. + * Some may need a side-effect free lookup, e.g. avoiding + * getters which are not typical. + */ + break; } case DUK_TAG_BUFFER: { - stridx_bidx = (DUK_BIDX_UINT8ARRAY_PROTOTYPE << 16) + DUK_STRIDX_UINT8_ARRAY; - goto use_proto_bidx; + stridx = DUK_STRIDX_UINT8_ARRAY; + break; } #if defined(DUK_USE_FASTINT) case DUK_TAG_FASTINT: @@ -3166,142 +3113,14 @@ #endif default: { DUK_ASSERT(DUK_TVAL_IS_NUMBER(tv)); /* number (maybe fastint) */ - stridx_bidx = (DUK_BIDX_NUMBER_PROTOTYPE << 16) + DUK_STRIDX_UC_NUMBER; - goto use_proto_bidx; - } - } - DUK_ASSERT(0); /* Never here. */ - - use_proto_bidx: - DUK_ASSERT_BIDX_VALID((stridx_bidx >> 16) & 0xffffUL); - duk_push_hobject(thr, thr->builtins[(stridx_bidx >> 16) & 0xffffUL]); - /* Fall through. */ - - use_pushed_object: - /* [ ... "[object" obj ] */ - -#if defined(DUK_USE_SYMBOL_BUILTIN) - /* XXX: better handling with avoid_side_effects == 1; lookup tval - * without Proxy or getter side effects, and use it in sanitized - * form if it's a string. - */ - if (!avoid_side_effects) { - /* XXX: The problem with using the prototype object as the - * lookup base is that if @@toStringTag is a getter, its - * 'this' binding must be the ToObject() coerced input value, - * not the prototype object of the type. - */ - (void) duk_get_prop_stridx(thr, -1, DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG); - if (duk_is_string_notsymbol(thr, -1)) { - duk_remove_m2(thr); - goto finish; - } - duk_pop_unsafe(thr); - } -#endif - - if (stridx_bidx == 0xffffffffUL) { - duk_hobject *h_obj; - duk_small_uint_t classnum; - - h_obj = duk_known_hobject(thr, -1); - DUK_ASSERT(h_obj != NULL); - classnum = DUK_HOBJECT_GET_CLASS_NUMBER(h_obj); - stridx_bidx = DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(classnum); - } else { - /* stridx_bidx already has the desired fallback stridx. */ - ; - } - duk_pop_unsafe(thr); - /* Fall through. */ - - use_stridx: - /* [ ... "[object" ] */ - duk_push_hstring_stridx(thr, stridx_bidx & 0xffffUL); - - finish: - /* [ ... "[object" tag ] */ - duk_push_literal(thr, "]"); - duk_concat(thr, 3); /* [ ... "[object" tag "]" ] -> [ ... res ] */ -} -#endif /* 0 */ - -DUK_INTERNAL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv, duk_bool_t avoid_side_effects) { - duk_hobject *h_obj; - duk_small_uint_t classnum; - duk_small_uint_t stridx; - duk_tval tv_tmp; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(tv != NULL); - - /* Stabilize 'tv', duk_push_literal() may trigger side effects. */ - DUK_TVAL_SET_TVAL(&tv_tmp, tv); - tv = &tv_tmp; - - /* Conceptually for any non-undefined/null value we should do a - * ToObject() coercion and look up @@toStringTag (from the object - * prototype) to see if a custom result should be used. We'd like to - * avoid the actual conversion, but even for primitive types the - * prototype may have @@toStringTag. What's worse, the @@toStringTag - * property may be a getter that must get the object coerced value - * (not the prototype) as its 'this' binding. - * - * For now, do an actual object coercion. This could be avoided by - * doing a side effect free lookup to see if a getter would be invoked. - * If not, the value can be read directly and the object coercion could - * be avoided. This may not be worth it in practice, because - * Object.prototype.toString() is usually not performance critical. - */ - - duk_push_literal(thr, "[object "); /* -> [ ... "[object" ] */ - - switch (DUK_TVAL_GET_TAG(tv)) { - case DUK_TAG_UNUSED: /* Treat like 'undefined', shouldn't happen. */ - case DUK_TAG_UNDEFINED: { - duk_push_hstring_stridx(thr, DUK_STRIDX_UC_UNDEFINED); - goto finish; - } - case DUK_TAG_NULL: { - duk_push_hstring_stridx(thr, DUK_STRIDX_UC_NULL); - goto finish; + stridx = DUK_STRIDX_UC_NUMBER; + break; } } + h_strclass = DUK_HTHREAD_GET_STRING(thr, stridx); + DUK_ASSERT(h_strclass != NULL); - duk_push_tval(thr, tv); - tv = NULL; /* Invalidated by ToObject(). */ - duk_to_object(thr, -1); - - /* [ ... "[object" obj ] */ - -#if defined(DUK_USE_SYMBOL_BUILTIN) - /* XXX: better handling with avoid_side_effects == 1; lookup tval - * without Proxy or getter side effects, and use it in sanitized - * form if it's a string. - */ - if (!avoid_side_effects) { - (void) duk_get_prop_stridx(thr, -1, DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG); - if (duk_is_string_notsymbol(thr, -1)) { - duk_remove_m2(thr); - goto finish; - } - duk_pop_unsafe(thr); - } -#else - DUK_UNREF(avoid_side_effects); -#endif - - h_obj = duk_known_hobject(thr, -1); - DUK_ASSERT(h_obj != NULL); - classnum = DUK_HOBJECT_GET_CLASS_NUMBER(h_obj); - stridx = DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(classnum); - duk_pop_unsafe(thr); - duk_push_hstring_stridx(thr, stridx); - - finish: - /* [ ... "[object" tag ] */ - duk_push_literal(thr, "]"); - duk_concat(thr, 3); /* [ ... "[object" tag "]" ] -> [ ... res ] */ + duk_push_sprintf(thr, "[object %s]", (const char *) DUK_HSTRING_GET_DATA(h_strclass)); } /* XXX: other variants like uint, u32 etc */ @@ -3361,7 +3180,6 @@ /* coerced value is updated to value stack even when RangeError thrown */ if (clamped) { DUK_ERROR_RANGE(thr, DUK_STR_NUMBER_OUTSIDE_RANGE); - DUK_WO_NORETURN(return 0;); } } @@ -3419,14 +3237,12 @@ DUK_ASSERT(h != NULL); if (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_CANNOT_STRING_COERCE_SYMBOL); - DUK_WO_NORETURN(goto skip_replace;); } else { goto skip_replace; } #else goto skip_replace; #endif - break; } case DUK_TAG_BUFFER: /* Go through Uint8Array.prototype.toString() for coercion. */ case DUK_TAG_OBJECT: { @@ -3577,9 +3393,14 @@ } dst_data = (duk_uint8_t *) duk_push_buffer(thr, src_size, (mode == DUK_BUF_MODE_DYNAMIC) /*dynamic*/); - /* dst_data may be NULL if size is zero. */ - duk_memcpy_unsafe((void *) dst_data, (const void *) src_data, (size_t) src_size); - + if (DUK_LIKELY(src_size > 0)) { + /* When src_size == 0, src_data may be NULL (if source + * buffer is dynamic), and dst_data may be NULL (if + * target buffer is dynamic). Avoid zero-size memcpy() + * with an invalid pointer. + */ + DUK_MEMCPY((void *) dst_data, (const void *) src_data, (size_t) src_size); + } duk_replace(thr, idx); skip_copy: @@ -3695,7 +3516,6 @@ case DUK_TAG_UNDEFINED: case DUK_TAG_NULL: { DUK_ERROR_TYPE(thr, DUK_STR_NOT_OBJECT_COERCIBLE); - DUK_WO_NORETURN(return;); break; } case DUK_TAG_BOOLEAN: { @@ -4003,7 +3823,7 @@ } if (mask & DUK_TYPE_MASK_THROW) { DUK_ERROR_TYPE(thr, DUK_STR_UNEXPECTED_TYPE); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); } return 0; } @@ -4476,22 +4296,21 @@ DUK_ASSERT_API_ENTRY(thr); - /* Check stack before interning (avoid hanging temp). */ + /* check stack before interning (avoid hanging temp) */ DUK__CHECK_SPACE(); /* NULL with zero length represents an empty string; NULL with higher - * length is also now treated like an empty string although it is + * length is also now trated like an empty string although it is * a bit dubious. This is unlike duk_push_string() which pushes a * 'null' if the input string is a NULL. */ - if (DUK_UNLIKELY(str == NULL)) { - len = 0U; + if (!str) { + len = 0; } - /* Check for maximum string length. */ + /* Check for maximum string length */ if (DUK_UNLIKELY(len > DUK_HSTRING_MAX_BYTELEN)) { DUK_ERROR_RANGE(thr, DUK_STR_STRING_TOO_LONG); - DUK_WO_NORETURN(return NULL;); } h = duk_heap_strtable_intern_checked(thr, (const duk_uint8_t *) str, (duk_uint32_t) len); @@ -4515,42 +4334,6 @@ } } -#if !defined(DUK_USE_PREFER_SIZE) -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_EXTERNAL const char *duk_push_literal_raw(duk_hthread *thr, const char *str, duk_size_t len) { - duk_hstring *h; - duk_tval *tv_slot; - - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(str != NULL); - DUK_ASSERT(str[len] == (char) 0); - - /* Check for maximum string length. */ - if (DUK_UNLIKELY(len > DUK_HSTRING_MAX_BYTELEN)) { - DUK_ERROR_RANGE(thr, DUK_STR_STRING_TOO_LONG); - DUK_WO_NORETURN(return NULL;); - } - - h = duk_heap_strtable_intern_literal_checked(thr, (const duk_uint8_t *) str, (duk_uint32_t) len); - DUK_ASSERT(h != NULL); - - tv_slot = thr->valstack_top++; - DUK_TVAL_SET_STRING(tv_slot, h); - DUK_HSTRING_INCREF(thr, h); /* no side effects */ - - return (const char *) DUK_HSTRING_GET_DATA(h); -} -#else /* DUK_USE_LITCACHE_SIZE */ -DUK_EXTERNAL const char *duk_push_literal_raw(duk_hthread *thr, const char *str, duk_size_t len) { - DUK_ASSERT_API_ENTRY(thr); - DUK_ASSERT(str != NULL); - DUK_ASSERT(str[len] == (char) 0); - - return duk_push_lstring(thr, str, len); -} -#endif /* DUK_USE_LITCACHE_SIZE */ -#endif /* !DUK_USE_PREFER_SIZE */ - DUK_EXTERNAL void duk_push_pointer(duk_hthread *thr, void *val) { duk_tval *tv_slot; @@ -4604,7 +4387,6 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_NOT_OBJECT_COERCIBLE); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_push_this(duk_hthread *thr) { @@ -4648,46 +4430,6 @@ return thr->valstack_bottom - 1; } -DUK_EXTERNAL void duk_push_new_target(duk_hthread *thr) { - duk_activation *act; - - DUK_ASSERT_API_ENTRY(thr); - - /* https://www.ecma-international.org/ecma-262/6.0/#sec-meta-properties-runtime-semantics-evaluation - * https://www.ecma-international.org/ecma-262/6.0/#sec-getnewtarget - * - * No newTarget support now, so as a first approximation - * use the resolved (non-bound) target function. - * - * Check CONSTRUCT flag from current function, or if running - * direct eval, from a non-direct-eval parent (with possibly - * more than one nested direct eval). An alternative to this - * would be to store [[NewTarget]] as a hidden symbol of the - * lexical scope, and then just look up that variable. - * - * Calls from the application will either be for an empty - * call stack, or a Duktape/C function as the top activation. - */ - - act = thr->callstack_curr; - for (;;) { - if (act == NULL) { - break; - } - - if (act->flags & DUK_ACT_FLAG_CONSTRUCT) { - duk_push_tval(thr, &act->tv_func); - return; - } else if (act->flags & DUK_ACT_FLAG_DIRECT_EVAL) { - act = act->parent; - } else { - break; - } - } - - duk_push_undefined(thr); -} - DUK_EXTERNAL void duk_push_current_function(duk_hthread *thr) { duk_activation *act; @@ -4748,7 +4490,7 @@ DUK_ASSERT_API_ENTRY(thr); if (DUK_UNLIKELY(target_thr == NULL)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return;); + return; /* not reached */ } duk_push_hobject(thr, (duk_hobject *) target_thr); duk__push_stash(thr); @@ -4824,7 +4566,6 @@ sz = sz * 2; if (DUK_UNLIKELY(sz >= DUK_PUSH_SPRINTF_SANITY_LIMIT)) { DUK_ERROR_RANGE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return NULL;); } } @@ -5013,7 +4754,6 @@ /* important to do this *after* pushing, to make the thread reachable for gc */ if (DUK_UNLIKELY(!duk_hthread_init_stacks(thr->heap, obj))) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return 0;); } /* initialize built-ins - either by copying or creating new ones */ @@ -5055,7 +4795,6 @@ DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_FUNCTION)); if (DUK_UNLIKELY(obj == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } DUK_DDD(DUK_DDDPRINT("created compiled function object with flags: 0x%08lx", (unsigned long) obj->obj.hdr.h_flags)); @@ -5087,7 +4826,6 @@ DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_FUNCTION)); if (!obj) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } tv_slot = thr->valstack_top++; @@ -5144,7 +4882,7 @@ api_error: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + return 0; /* not reached */ } DUK_EXTERNAL duk_idx_t duk_push_c_function(duk_hthread *thr, duk_c_function func, duk_int_t nargs) { @@ -5236,7 +4974,7 @@ api_error: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + return 0; /* not reached */ } #if defined(DUK_USE_BUFFEROBJECT_SUPPORT) @@ -5388,11 +5126,11 @@ range_error: DUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARGS); - DUK_WO_NORETURN(return;); + return; /* not reached */ arg_error: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_ARGS); - DUK_WO_NORETURN(return;); + return; /* not reached */ } #else /* DUK_USE_BUFFEROBJECT_SUPPORT */ DUK_EXTERNAL void duk_push_buffer_object(duk_hthread *thr, duk_idx_t idx_buffer, duk_size_t byte_offset, duk_size_t byte_length, duk_uint_t flags) { @@ -5402,7 +5140,6 @@ DUK_UNREF(byte_length); DUK_UNREF(flags); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ @@ -5440,7 +5177,7 @@ duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_MESSAGE, DUK_PROPDESC_FLAGS_WC); } else { /* If no explicit message given, put error code into message field - * (as a number). This is not fully in keeping with the ECMAScript + * (as a number). This is not fully in keeping with the Ecmascript * error model because messages are supposed to be strings (Error * constructors use ToString() on their argument). However, it's * probably more useful than having a separate 'code' property. @@ -5502,13 +5239,11 @@ /* Check for maximum buffer length. */ if (DUK_UNLIKELY(size > DUK_HBUFFER_MAX_BYTELEN)) { DUK_ERROR_RANGE(thr, DUK_STR_BUFFER_TOO_LONG); - DUK_WO_NORETURN(return NULL;); } h = duk_hbuffer_alloc(thr->heap, size, flags, &buf_data); if (DUK_UNLIKELY(h == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } tv_slot = thr->valstack_top; @@ -5530,12 +5265,11 @@ DUK_ASSERT_API_ENTRY(thr); ptr = duk_push_buffer_raw(thr, len, 0); - DUK_ASSERT(ptr != NULL); #if !defined(DUK_USE_ZERO_BUFFER_DATA) /* ES2015 requires zeroing even when DUK_USE_ZERO_BUFFER_DATA * is not set. */ - duk_memzero((void *) ptr, (size_t) len); + DUK_MEMZERO((void *) ptr, (size_t) len); #endif return ptr; } @@ -5632,14 +5366,12 @@ fail_args: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); } #else /* DUK_USE_ES6_PROXY */ DUK_EXTERNAL duk_idx_t duk_push_proxy(duk_hthread *thr, duk_uint_t proxy_flags) { DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(proxy_flags); DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } #endif /* DUK_USE_ES6_PROXY */ @@ -5937,7 +5669,7 @@ if (DUK_UNLIKELY((duk_uidx_t) (thr->valstack_top - thr->valstack_bottom) < (duk_uidx_t) count)) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count >= 0); @@ -6025,7 +5757,6 @@ DUK_ASSERT(thr->valstack_top >= thr->valstack_bottom); if (DUK_UNLIKELY(thr->valstack_top == thr->valstack_bottom)) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); } duk__pop_unsafe_raw(thr); @@ -6114,7 +5845,6 @@ DUK_ASSERT(thr->valstack_top >= thr->valstack_bottom); if (DUK_UNLIKELY(thr->valstack_top - 2 < thr->valstack_bottom)) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); } duk__pop_2_unsafe_raw(thr); @@ -6172,7 +5902,7 @@ if (DUK_UNLIKELY((duk_uidx_t) count > (duk_uidx_t) top)) { /* Also handles negative count. */ DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count >= 0); @@ -6189,8 +5919,9 @@ /* Copy value stack values directly to the array part without * any refcount updates: net refcount changes are zero. */ + tv_src = thr->valstack_top - count - 1; - duk_memcpy_unsafe((void *) tv_dst, (const void *) tv_src, (size_t) count * sizeof(duk_tval)); + DUK_MEMCPY((void *) tv_dst, (const void *) tv_src, (size_t) count * sizeof(duk_tval)); /* Overwrite result array to final value stack location and wipe * the rest; no refcount operations needed. @@ -6308,11 +6039,11 @@ } DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); + return 0; fail_over_2g: DUK_ERROR_RANGE_INVALID_LENGTH(thr); - DUK_WO_NORETURN(return 0;); + return 0; } /* @@ -6329,7 +6060,6 @@ if (DUK_UNLIKELY(thr->valstack_top == thr->valstack_bottom)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return;); } /* Errors are augmented when they are created, not when they are @@ -6393,7 +6123,6 @@ duk_push_error_object_va_raw(thr, err_code, filename, line, fmt, ap); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_error_raw(duk_hthread *thr, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...) { @@ -6405,7 +6134,6 @@ duk_push_error_object_va_raw(thr, err_code, filename, line, fmt, ap); va_end(ap); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } #if !defined(DUK_USE_VARIADIC_MACROS) @@ -6424,7 +6152,6 @@ duk_push_error_object_va_raw(thr, err_code, filename, line, fmt, ap); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } #define DUK__ERROR_STASH_SHARED(code) do { \ @@ -6432,7 +6159,7 @@ va_start(ap, fmt); \ duk__throw_error_from_stash(thr, (code), fmt, ap); \ va_end(ap); \ - DUK_WO_NORETURN(return 0;); \ + /* Never reached; if return 0 here, gcc/clang will complain. */ \ } while (0) DUK_EXTERNAL duk_ret_t duk_error_stash(duk_hthread *thr, duk_errcode_t err_code, const char *fmt, ...) { @@ -6562,7 +6289,7 @@ DUK_ASSERT_API_ENTRY(thr); - duk_push_literal(thr, "light_"); + duk_push_sprintf(thr, "light_"); duk_push_string_funcptr(thr, (duk_uint8_t *) &func, sizeof(func)); duk_push_sprintf(thr, "_%04x", (unsigned int) lf_flags); duk_concat(thr, 3); @@ -6587,9 +6314,9 @@ DUK_ASSERT(DUK_TVAL_IS_LIGHTFUNC(tv)); DUK_TVAL_GET_LIGHTFUNC(tv, func, lf_flags); /* read before 'tv' potentially invalidated */ - duk_push_literal(thr, "function "); + duk_push_string(thr, "function "); duk_push_lightfunc_name_raw(thr, func, lf_flags); - duk_push_literal(thr, "() { [lightfunc code] }"); + duk_push_string(thr, "() { [lightfunc code] }"); duk_concat(thr, 3); } @@ -6701,7 +6428,7 @@ /* 'tv' may be NULL */ if (tv == NULL) { - duk_push_literal(thr, "none"); + duk_push_string(thr, "none"); } else { switch (DUK_TVAL_GET_TAG(tv)) { case DUK_TAG_STRING: { @@ -6710,11 +6437,11 @@ /* XXX: string summary produces question marks * so this is not very ideal. */ - duk_push_literal(thr, "[Symbol "); + duk_push_string(thr, "[Symbol "); duk_push_string(thr, duk__get_symbol_type_string(h)); - duk_push_literal(thr, " "); + duk_push_string(thr, " "); duk__push_hstring_readable_unicode(thr, h, DUK__READABLE_STRING_MAXCHARS); - duk_push_literal(thr, "]"); + duk_push_string(thr, "]"); duk_concat(thr, 5); break; } @@ -6744,7 +6471,7 @@ break; } } - duk_push_class_string_tval(thr, tv, 1 /*avoid_side_effects*/); + duk_push_class_string_tval(thr, tv); break; } case DUK_TAG_BUFFER: { @@ -6799,7 +6526,7 @@ DUK_ASSERT_API_ENTRY(thr); /* .toString() */ - duk_push_literal(thr, "Symbol("); + duk_push_string(thr, "Symbol("); p = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h); p_end = p + DUK_HSTRING_GET_BYTELEN(h); DUK_ASSERT(p[0] == 0xff || (p[0] & 0xc0) == 0x80); @@ -6815,7 +6542,7 @@ } } duk_push_lstring(thr, (const char *) p, (duk_size_t) (q - p)); - duk_push_literal(thr, ")"); + duk_push_string(thr, ")"); duk_concat(thr, 3); } @@ -6851,8 +6578,7 @@ DUK_ASSERT_API_ENTRY(thr); DUK_UNREF(thr); DUK_ASSERT(count * sizeof(duk_tval) >= count); /* no wrap */ - - duk_memcpy_unsafe((void *) tv_dst, (const void *) tv_src, count * sizeof(duk_tval)); + DUK_MEMCPY((void *) tv_dst, (const void *) tv_src, count * sizeof(duk_tval)); tv = tv_dst; while (count-- > 0) { diff -Nru duktape-2.3.0/src-separate/duk_api_string.c duktape-2.2.0/src-separate/duk_api_string.c --- duktape-2.3.0/src-separate/duk_api_string.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_api_string.c 2017-09-23 01:06:08.000000000 +0000 @@ -17,7 +17,7 @@ if (DUK_UNLIKELY(count_in <= 0)) { if (count_in < 0) { DUK_ERROR_RANGE_INVALID_COUNT(thr); - DUK_WO_NORETURN(return;); + return; } DUK_ASSERT(count_in == 0); duk_push_hstring_empty(thr); @@ -73,11 +73,11 @@ for (i = count; i >= 1; i--) { if (is_join && i != count) { h = duk_require_hstring(thr, -((duk_idx_t) count) - 2); /* extra -1 for buffer */ - duk_memcpy(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); + DUK_MEMCPY(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); idx += DUK_HSTRING_GET_BYTELEN(h); } h = duk_require_hstring(thr, -((duk_idx_t) i) - 1); /* extra -1 for buffer */ - duk_memcpy(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); + DUK_MEMCPY(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h)); idx += DUK_HSTRING_GET_BYTELEN(h); } @@ -104,7 +104,6 @@ error_overflow: DUK_ERROR_RANGE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return;); } DUK_EXTERNAL void duk_concat(duk_hthread *thr, duk_idx_t count) { @@ -142,8 +141,8 @@ buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, len); DUK_ASSERT(buf != NULL); - duk_memcpy((void *) buf, (const void *) DUK_HSTRING_GET_DATA(h1), (size_t) len1); - duk_memcpy((void *) (buf + len1), (const void *) DUK_HSTRING_GET_DATA(h2), (size_t) len2); + DUK_MEMCPY((void *) buf, (const void *) DUK_HSTRING_GET_DATA(h1), (size_t) len1); + DUK_MEMCPY((void *) (buf + len1), (const void *) DUK_HSTRING_GET_DATA(h2), (size_t) len2); (void) duk_buffer_to_string(thr, -1); /* Safe if inputs are safe. */ /* [ ... str1 str2 buf ] */ @@ -154,7 +153,6 @@ error_overflow: DUK_ERROR_RANGE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return;); } #endif /* DUK_USE_PREFER_SIZE */ diff -Nru duktape-2.3.0/src-separate/duk_api_time.c duktape-2.2.0/src-separate/duk_api_time.c --- duktape-2.3.0/src-separate/duk_api_time.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_api_time.c 2017-09-23 01:06:08.000000000 +0000 @@ -5,7 +5,7 @@ #include "duk_internal.h" DUK_INTERNAL duk_double_t duk_time_get_ecmascript_time(duk_hthread *thr) { - /* ECMAScript time, with millisecond fractions. Exposed via + /* Ecmascript time, with millisecond fractions. Exposed via * duk_get_now() for example. */ DUK_UNREF(thr); @@ -13,7 +13,7 @@ } DUK_INTERNAL duk_double_t duk_time_get_ecmascript_time_nofrac(duk_hthread *thr) { - /* ECMAScript time without millisecond fractions. Exposed via + /* Ecmascript time without millisecond fractions. Exposed via * the Date built-in which doesn't allow fractions. */ DUK_UNREF(thr); @@ -56,7 +56,7 @@ DUK_UNREF(thr); /* Convert as one-based, but change month to zero-based to match the - * ECMAScript Date built-in behavior 1:1. + * Ecmascript Date built-in behavior 1:1. */ flags = DUK_DATE_FLAG_ONEBASED | DUK_DATE_FLAG_NAN_TO_ZERO; diff -Nru duktape-2.3.0/src-separate/duk_bi_array.c duktape-2.2.0/src-separate/duk_bi_array.c --- duktape-2.3.0/src-separate/duk_bi_array.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_array.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,9 +1,9 @@ /* * Array built-ins * - * Most Array built-ins are intentionally generic in ECMAScript, and are + * Most Array built-ins are intentionally generic in Ecmascript, and are * intended to work even when the 'this' binding is not an Array instance. - * This ECMAScript feature is also used by much real world code. For this + * This Ecmascript feature is also used by much real world code. For this * reason the implementations here don't assume exotic Array behavior or * e.g. presence of a .length property. However, some algorithms have a * fast path for duk_harray backed actual Array instances, enabled when @@ -77,7 +77,6 @@ duk_uint32_t ret = duk__push_this_obj_len_u32(thr); if (DUK_UNLIKELY(ret >= 0x80000000UL)) { DUK_ERROR_RANGE_INVALID_LENGTH(thr); - DUK_WO_NORETURN(return 0U;); } return ret; } @@ -230,17 +229,11 @@ DUK_INTERNAL duk_ret_t duk_bi_array_prototype_concat(duk_hthread *thr) { duk_idx_t i, n; - duk_uint32_t j, idx, len; + duk_uarridx_t idx, idx_last; + duk_uarridx_t j, len; duk_hobject *h; - duk_size_t tmp_len; - /* XXX: In ES2015 Array .length can be up to 2^53-1. The current - * implementation is limited to 2^32-1. - */ - - /* XXX: Fast path for array 'this' and array element. */ - - /* XXX: The insert here is a bit expensive if there are a lot of items. + /* XXX: the insert here is a bit expensive if there are a lot of items. * It could also be special cased in the outermost for loop quite easily * (as the element is dup()'d anyway). */ @@ -258,97 +251,59 @@ */ idx = 0; + idx_last = 0; for (i = 0; i < n; i++) { - duk_bool_t spreadable; - duk_bool_t need_has_check; - DUK_ASSERT_TOP(thr, n + 1); /* [ ToObject(this) item1 ... itemN arr ] */ - h = duk_get_hobject(thr, i); - - if (h == NULL) { - spreadable = 0; - } else { -#if defined(DUK_USE_SYMBOL_BUILTIN) - duk_get_prop_stridx(thr, i, DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE); - if (duk_is_undefined(thr, -1)) { - spreadable = (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY); - } else { - spreadable = duk_to_boolean(thr, -1); - } - duk_pop_nodecref_unsafe(thr); -#else - spreadable = (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY); -#endif - } - - if (!spreadable) { - duk_dup(thr, i); - duk_xdef_prop_index_wec(thr, -2, idx); - idx++; - if (DUK_UNLIKELY(idx == 0U)) { - /* Index after update is 0, and index written - * was 0xffffffffUL which is no longer a valid - * array index. - */ - goto fail_wrap; - } + duk_dup(thr, i); + h = duk_get_hobject_with_class(thr, -1, DUK_HOBJECT_CLASS_ARRAY); + if (!h) { + duk_xdef_prop_index_wec(thr, -2, idx++); + idx_last = idx; continue; } - DUK_ASSERT(duk_is_object(thr, i)); - need_has_check = (DUK_HOBJECT_IS_PROXY(h) != 0); /* Always 0 w/o Proxy support. */ + /* [ ToObject(this) item1 ... itemN arr item(i) ] */ - /* [ ToObject(this) item1 ... itemN arr ] */ - - tmp_len = duk_get_length(thr, i); - len = (duk_uint32_t) tmp_len; - if (DUK_UNLIKELY(tmp_len != (duk_size_t) len)) { - goto fail_wrap; - } - if (DUK_UNLIKELY(idx + len < idx)) { - /* Result length must be at most 0xffffffffUL to be - * a valid 32-bit array index. - */ - goto fail_wrap; - } + /* XXX: an array can have length higher than 32 bits; this is not handled + * correctly now. + */ + len = (duk_uarridx_t) duk_get_length(thr, -1); for (j = 0; j < len; j++) { - /* For a Proxy element, an explicit 'has' check is - * needed to allow the Proxy to present gaps. - */ - if (need_has_check) { - if (duk_has_prop_index(thr, i, j)) { - duk_get_prop_index(thr, i, j); - duk_xdef_prop_index_wec(thr, -2, idx); - } + if (duk_get_prop_index(thr, -1, j)) { + /* [ ToObject(this) item1 ... itemN arr item(i) item(i)[j] ] */ + duk_xdef_prop_index_wec(thr, -3, idx++); + idx_last = idx; } else { - if (duk_get_prop_index(thr, i, j)) { - duk_xdef_prop_index_wec(thr, -2, idx); - } else { - duk_pop_undefined(thr); - } + idx++; + duk_pop_undefined(thr); +#if defined(DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER) + /* According to E5.1 Section 15.4.4.4 nonexistent trailing + * elements do not affect 'length' of the result. Test262 + * and other engines disagree, so update idx_last here too. + */ + idx_last = idx; +#else + /* Strict standard behavior, ignore trailing elements for + * result 'length'. + */ +#endif } - idx++; - DUK_ASSERT(idx != 0U); /* Wrap check above. */ } + duk_pop_unsafe(thr); } - /* ES5.1 has a specification "bug" in that nonexistent trailing - * elements don't affect the result .length. Test262 and other - * engines disagree, and the specification bug was fixed in ES2015 - * (see NOTE 1 in https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.concat). + /* The E5.1 Section 15.4.4.4 algorithm doesn't set the length explicitly + * in the end, but because we're operating with an internal value which + * is known to be an array, this should be equivalent. */ - duk_push_uarridx(thr, idx); + duk_push_uarridx(thr, idx_last); duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_W); DUK_ASSERT_TOP(thr, n + 1); return 1; - - fail_wrap: - DUK_ERROR_RANGE_INVALID_LENGTH(thr); - DUK_WO_NORETURN(return 0;); } /* @@ -1470,12 +1425,20 @@ DUK_ASSERT_TOP(thr, 5); if (!duk_get_prop_index(thr, 2, (duk_uarridx_t) i)) { - /* For 'map' trailing missing elements don't invoke the - * callback but count towards the result length. +#if defined(DUK_USE_NONSTD_ARRAY_MAP_TRAILER) + /* Real world behavior for map(): trailing non-existent + * elements don't invoke the user callback, but are still + * counted towards result 'length'. */ if (iter_type == DUK__ITER_MAP) { res_length = i + 1; } +#else + /* Standard behavior for map(): trailing non-existent + * elements don't invoke the user callback and are not + * counted towards result 'length'. + */ +#endif duk_pop_undefined(thr); continue; } diff -Nru duktape-2.3.0/src-separate/duk_bi_buffer.c duktape-2.2.0/src-separate/duk_bi_buffer.c --- duktape-2.3.0/src-separate/duk_bi_buffer.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_buffer.c 2017-09-23 01:06:08.000000000 +0000 @@ -175,7 +175,6 @@ if (flags & DUK__BUFOBJ_FLAG_THROW) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); } return NULL; } @@ -217,7 +216,7 @@ } DUK_ERROR_TYPE(thr, DUK_STR_NOT_BUFFER); - DUK_WO_NORETURN(return NULL;); + return NULL; /* not reachable */ } DUK_LOCAL void duk__set_bufobj_buffer(duk_hthread *thr, duk_hbufobj *h_bufobj, duk_hbuffer *h_val) { @@ -292,7 +291,6 @@ fail_range: DUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARGS); - DUK_WO_NORETURN(return;); } /* Shared lenient buffer length clamping helper. No negative indices, no @@ -443,8 +441,7 @@ DUK_INTERNAL void duk_hbufobj_push_validated_read(duk_hthread *thr, duk_hbufobj *h_bufobj, duk_uint8_t *p, duk_small_uint_t elem_size) { duk_double_union du; - DUK_ASSERT(elem_size > 0); - duk_memcpy((void *) du.uc, (const void *) p, (size_t) elem_size); + DUK_MEMCPY((void *) du.uc, (const void *) p, (size_t) elem_size); switch (h_bufobj->elem_type) { case DUK_HBUFOBJ_ELEM_UINT8: @@ -512,11 +509,7 @@ du.ui[0] = (duk_uint32_t) duk_to_int32(thr, -1); break; case DUK_HBUFOBJ_ELEM_FLOAT32: - /* A double-to-float cast is undefined behavior in C99 if - * the cast is out-of-range, so use a helper. Example: - * runtime error: value -1e+100 is outside the range of representable values of type 'float' - */ - du.f[0] = duk_double_to_float_t(duk_to_number_m1(thr)); + du.f[0] = (duk_float_t) duk_to_number_m1(thr); break; case DUK_HBUFOBJ_ELEM_FLOAT64: du.d = (duk_double_t) duk_to_number_m1(thr); @@ -525,8 +518,7 @@ DUK_UNREACHABLE(); } - DUK_ASSERT(elem_size > 0); - duk_memcpy((void *) p, (const void *) du.uc, (size_t) elem_size); + DUK_MEMCPY((void *) p, (const void *) du.uc, (size_t) elem_size); } /* Helper to create a fixed buffer from argument value at index 0. @@ -562,14 +554,12 @@ h_bufobj = (duk_hbufobj *) h; if (DUK_UNLIKELY(h_bufobj->buf == NULL)) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } if (DUK_UNLIKELY(h_bufobj->offset != 0 || h_bufobj->length != DUK_HBUFFER_GET_SIZE(h_bufobj->buf))) { /* No support for ArrayBuffers with slice * offset/length. */ DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } duk_push_hbuffer(thr, h_bufobj->buf); return h_bufobj->buf; @@ -585,7 +575,6 @@ } default: DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } done: @@ -627,7 +616,7 @@ duk_push_buffer_object(thr, -1, 0, - DUK_HBUFFER_FIXED_GET_SIZE((duk_hbuffer_fixed *) (void *) h_buf), + DUK_HBUFFER_FIXED_GET_SIZE((duk_hbuffer_fixed *) h_buf), DUK_BUFOBJ_UINT8ARRAY); duk_push_hobject_bidx(thr, DUK_BIDX_NODEJS_BUFFER_PROTOTYPE); duk_set_prototype(thr, -2); @@ -955,7 +944,7 @@ DUK_DDD(DUK_DDDPRINT("using memcpy: p_src=%p, p_dst=%p, byte_length=%ld", (void *) p_src, (void *) p_dst, (long) byte_length)); - duk_memcpy_unsafe((void *) p_dst, (const void *) p_src, (size_t) byte_length); + DUK_MEMCPY((void *) p_dst, (const void *) p_src, (size_t) byte_length); break; } case 1: { @@ -1191,7 +1180,7 @@ h_this = duk__get_bufobj_this(thr); if (h_this == NULL) { /* XXX: happens e.g. when evaluating: String(Buffer.prototype). */ - duk_push_literal(thr, "[object Object]"); + duk_push_string(thr, "[object Object]"); return 1; } DUK_ASSERT_HBUFOBJ_VALID(h_this); @@ -1222,9 +1211,9 @@ */ DUK_ASSERT(DUK_HBUFOBJ_VALID_BYTEOFFSET_EXCL(h_this, (duk_size_t) start_offset + slice_length)); - duk_memcpy_unsafe((void *) buf_slice, - (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), - (size_t) slice_length); + DUK_MEMCPY((void *) buf_slice, + (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), + (size_t) slice_length); /* Use the equivalent of: new TextEncoder().encode(this) to convert the * string. Result will be valid UTF-8; non-CESU-8 inputs are currently @@ -1386,7 +1375,7 @@ /* Handle single character fills as memset() even when * the fill data comes from a one-char argument. */ - duk_memset_unsafe((void *) p, (int) fill_str_ptr[0], (size_t) fill_length); + DUK_MEMSET((void *) p, (int) fill_str_ptr[0], (size_t) fill_length); } else if (fill_str_len > 1) { duk_size_t i, n, t; @@ -1437,9 +1426,9 @@ if (DUK_HBUFOBJ_VALID_SLICE(h_this)) { /* Cannot overlap. */ - duk_memcpy_unsafe((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + offset), - (const void *) str_data, - (size_t) length); + DUK_MEMCPY((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + offset), + (const void *) str_data, + (size_t) length); } else { DUK_DDD(DUK_DDDPRINT("write() target buffer is not covered, silent ignore")); } @@ -1535,9 +1524,9 @@ /* Must use memmove() because copy area may overlap (source and target * buffer may be the same, or from different slices. */ - duk_memmove_unsafe((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufarg) + target_ustart), - (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + source_ustart), - (size_t) copy_size); + DUK_MEMMOVE((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufarg) + target_ustart), + (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + source_ustart), + (size_t) copy_size); } else { DUK_DDD(DUK_DDDPRINT("buffer copy not covered by underlying buffer(s), ignoring")); } @@ -1723,7 +1712,7 @@ DUK_ASSERT(src_length == dst_length); DUK_DDD(DUK_DDDPRINT("fast path: able to use memmove() because views are compatible")); - duk_memmove_unsafe((void *) p_dst_base, (const void *) p_src_base, (size_t) dst_length); + DUK_MEMMOVE((void *) p_dst_base, (const void *) p_src_base, (size_t) dst_length); return 0; } DUK_DDD(DUK_DDDPRINT("fast path: views are not compatible with a byte copy, copy by item")); @@ -1766,7 +1755,7 @@ DUK_DDD(DUK_DDDPRINT("there is overlap, make a copy of the source")); p_src_copy = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, src_length); DUK_ASSERT(p_src_copy != NULL); - duk_memcpy_unsafe((void *) p_src_copy, (const void *) p_src_base, (size_t) src_length); + DUK_MEMCPY((void *) p_src_copy, (const void *) p_src_base, (size_t) src_length); p_src_base = p_src_copy; /* use p_src_base from now on */ } @@ -1893,9 +1882,9 @@ DUK_ASSERT(p_copy != NULL); copy_length = slice_length; - duk_memcpy_unsafe((void *) p_copy, - (const void *) ((duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_val) + start_offset), - copy_length); + DUK_MEMCPY((void *) p_copy, + (const void *) ((duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_val) + start_offset), + copy_length); } #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ @@ -2017,9 +2006,9 @@ * is left as zero. */ copy_length = DUK_HBUFOBJ_CLAMP_BYTELENGTH(h_this, slice_length); - duk_memcpy_unsafe((void *) p_copy, - (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), - copy_length); + DUK_MEMCPY((void *) p_copy, + (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset), + copy_length); h_val = duk_known_hbuffer(thr, -1); @@ -2211,9 +2200,9 @@ if (h_bufobj->buf != NULL && DUK_HBUFOBJ_VALID_SLICE(h_bufobj)) { - duk_memcpy_unsafe((void *) p, - (const void *) DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufobj), - copy_size); + DUK_MEMCPY((void *) p, + (const void *) DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufobj), + copy_size); } else { /* Just skip, leaving zeroes in the result. */ ; @@ -2363,7 +2352,7 @@ if (offset + 2U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 2); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 2); tmp = du.us[0]; if (endswap) { tmp = DUK_BSWAP16(tmp); @@ -2380,7 +2369,7 @@ if (offset + 4U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 4); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 4); tmp = du.ui[0]; if (endswap) { tmp = DUK_BSWAP32(tmp); @@ -2397,7 +2386,7 @@ if (offset + 4U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 4); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 4); if (endswap) { tmp = du.ui[0]; tmp = DUK_BSWAP32(tmp); @@ -2410,7 +2399,7 @@ if (offset + 8U > check_length) { goto fail_bounds; } - duk_memcpy((void *) du.uc, (const void *) (buf + offset), 8); + DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 8); if (endswap) { DUK_DBLUNION_BSWAP64(&du); } @@ -2467,12 +2456,9 @@ } while (i != i_end); if (magic_signed) { - /* Shift to sign extend. Left shift must be unsigned - * to avoid undefined behavior; right shift must be - * signed to sign extend properly. - */ + /* Shift to sign extend. */ shift_tmp = (duk_small_uint_t) (64U - (duk_small_uint_t) field_bytelen * 8U); - tmp = (duk_int64_t) ((duk_uint64_t) tmp << shift_tmp) >> shift_tmp; + tmp = (tmp << shift_tmp) >> shift_tmp; } duk_push_i64(thr, tmp); @@ -2648,7 +2634,7 @@ } du.us[0] = tmp; /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 2); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 2); break; } case DUK__FLD_32BIT: { @@ -2662,7 +2648,7 @@ } du.ui[0] = tmp; /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 4); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 4); break; } case DUK__FLD_FLOAT: { @@ -2677,7 +2663,7 @@ du.ui[0] = tmp; } /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 4); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 4); break; } case DUK__FLD_DOUBLE: { @@ -2689,7 +2675,7 @@ DUK_DBLUNION_BSWAP64(&du); } /* sign doesn't matter when writing */ - duk_memcpy((void *) (buf + offset), (const void *) du.uc, 8); + DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 8); break; } case DUK__FLD_VARINT: { diff -Nru duktape-2.3.0/src-separate/duk_bi_date.c duktape-2.2.0/src-separate/duk_bi_date.c --- duktape-2.3.0/src-separate/duk_bi_date.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_date.c 2017-09-23 01:06:08.000000000 +0000 @@ -200,7 +200,7 @@ duk_small_uint_t i; /* During parsing, month and day are one-based; set defaults here. */ - duk_memzero(parts, sizeof(parts)); + DUK_MEMZERO(parts, sizeof(parts)); DUK_ASSERT(parts[DUK_DATE_IDX_YEAR] == 0); /* don't care value, year is mandatory */ parts[DUK_DATE_IDX_MONTH] = 1; parts[DUK_DATE_IDX_DAY] = 1; @@ -427,13 +427,13 @@ }; /* Maximum iteration count for computing UTC-to-local time offset when - * creating an ECMAScript time value from local parts. + * creating an Ecmascript time value from local parts. */ #define DUK__LOCAL_TZOFFSET_MAXITER 4 /* Because 'day since epoch' can be negative and is used to compute weekday * using a modulo operation, add this multiple of 7 to avoid negative values - * when year is below 1970 epoch. ECMAScript time values are restricted to + * when year is below 1970 epoch. Ecmascript time values are restricted to * +/- 100 million days from epoch, so this adder fits nicely into 32 bits. * Round to a multiple of 7 (= floor(100000000 / 7) * 7) and add margin. */ @@ -624,10 +624,10 @@ d = DUK_FLOOR(d); /* remove fractions if present */ DUK_ASSERT(DUK_FLOOR(d) == d); - /* The timevalue must be in valid ECMAScript range, but since a local + /* The timevalue must be in valid Ecmascript range, but since a local * time offset can be applied, we need to allow a +/- 24h leeway to * the value. In other words, although the UTC time is within the - * ECMAScript range, the local part values can be just outside of it. + * Ecmascript range, the local part values can be just outside of it. */ DUK_UNREF(duk_bi_date_timeval_in_leeway_range); DUK_ASSERT(duk_bi_date_timeval_in_leeway_range(d)); @@ -670,7 +670,7 @@ (long) parts[DUK_DATE_IDX_MILLISECOND])); /* This assert depends on the input parts representing time inside - * the ECMAScript range. + * the Ecmascript range. */ DUK_ASSERT(t2 + DUK__WEEKDAY_MOD_ADDER >= 0); parts[DUK_DATE_IDX_WEEKDAY] = (t2 + 4 + DUK__WEEKDAY_MOD_ADDER) % 7; /* E5.1 Section 15.9.1.6 */ @@ -790,7 +790,7 @@ * computation happens with intermediate results coerced to * double values (instead of using something more accurate). * E.g. E5.1 Section 15.9.1.11 requires use of IEEE 754 - * rules (= ECMAScript '+' and '*' operators). + * rules (= Ecmascript '+' and '*' operators). * * Without 'volatile' even this approach fails on some platform * and compiler combinations. For instance, gcc 4.8.1 on Ubuntu @@ -897,7 +897,6 @@ h = duk_get_hobject(thr, -1); /* XXX: getter with class check, useful in built-ins */ if (h == NULL || DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_DATE) { DUK_ERROR_TYPE(thr, "expected Date"); - DUK_WO_NORETURN(return 0.0;); } duk_get_prop_stridx_short(thr, -1, DUK_STRIDX_INT_VALUE); @@ -910,7 +909,6 @@ } if (flags & DUK_DATE_FLAG_NAN_TO_RANGE_ERROR) { DUK_ERROR_RANGE(thr, "Invalid Date"); - DUK_WO_NORETURN(return 0.0;); } } /* if no NaN handling flag, may still be NaN here, but not Inf */ @@ -1527,7 +1525,7 @@ * Notes: * * - Date.prototype.toGMTString() and Date.prototype.toUTCString() are - * required to be the same ECMAScript function object (!), so it is + * required to be the same Ecmascript function object (!), so it is * omitted from here. * * - Date.prototype.toUTCString(): E5.1 specification does not require a @@ -1723,39 +1721,4 @@ return 1; } -/* - * Misc. - */ - -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL duk_ret_t duk_bi_date_prototype_toprimitive(duk_hthread *thr) { - duk_size_t hintlen; - const char *hintstr; - duk_int_t hint; - - /* Invokes OrdinaryToPrimitive() with suitable hint. Note that the - * method is generic, and works on non-Date arguments too. - * - * https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype-@@toprimitive - */ - - duk_push_this(thr); - duk_require_object(thr, -1); - DUK_ASSERT_TOP(thr, 2); - - hintstr = duk_require_lstring(thr, 0, &hintlen); - if ((hintlen == 6 && DUK_STRCMP(hintstr, "string") == 0) || - (hintlen == 7 && DUK_STRCMP(hintstr, "default") == 0)) { - hint = DUK_HINT_STRING; - } else if (hintlen == 6 && DUK_STRCMP(hintstr, "number") == 0) { - hint = DUK_HINT_NUMBER; - } else { - DUK_DCERROR_TYPE_INVALID_ARGS(thr); - } - - duk_to_primitive_ordinary(thr, -1, hint); - return 1; -} -#endif /* DUK_USE_SYMBOL_BUILTIN */ - #endif /* DUK_USE_DATE_BUILTIN */ diff -Nru duktape-2.3.0/src-separate/duk_bi_date_unix.c duktape-2.2.0/src-separate/duk_bi_date_unix.c --- duktape-2.3.0/src-separate/duk_bi_date_unix.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_date_unix.c 2017-09-23 01:06:08.000000000 +0000 @@ -15,7 +15,7 @@ #define DUK__STRFTIME_BUF_SIZE 64 #if defined(DUK_USE_DATE_NOW_GETTIMEOFDAY) -/* Get current ECMAScript time (= UNIX/Posix time, but in milliseconds). */ +/* Get current Ecmascript time (= UNIX/Posix time, but in milliseconds). */ DUK_INTERNAL duk_double_t duk_bi_date_get_now_gettimeofday(void) { struct timeval tv; duk_double_t d; @@ -63,7 +63,7 @@ return 0; } - /* If not within ECMAScript range, some integer time calculations + /* If not within Ecmascript range, some integer time calculations * won't work correctly (and some asserts will fail), so bail out * if so. This fixes test-bug-date-insane-setyear.js. There is * a +/- 24h leeway in this range check to avoid a test262 corner @@ -114,10 +114,10 @@ * Since we rely on the platform APIs for conversions between local * time and UTC, we can't guarantee the above. Rather, if the platform * has historical DST rules they will be applied. This seems to be the - * general preferred direction in ECMAScript standardization (or at least + * general preferred direction in Ecmascript standardization (or at least * implementations) anyway, and even the equivalent year mapping should * be disabled if the platform is known to handle DST properly for the - * full ECMAScript range. + * full Ecmascript range. * * The following has useful discussion and links: * @@ -132,7 +132,7 @@ t = (time_t) (d / 1000.0); DUK_DDD(DUK_DDDPRINT("timeval: %lf -> time_t %ld", (double) d, (long) t)); - duk_memzero((void *) tms, sizeof(struct tm) * 2); + DUK_MEMZERO((void *) tms, sizeof(struct tm) * 2); #if defined(DUK_USE_DATE_TZO_GMTIME_R) (void) gmtime_r(&t, &tms[0]); @@ -142,9 +142,9 @@ (void) localtime_s(&t, &tms[1]); #elif defined(DUK_USE_DATE_TZO_GMTIME) tm_ptr = gmtime(&t); - duk_memcpy((void *) &tms[0], tm_ptr, sizeof(struct tm)); + DUK_MEMCPY((void *) &tms[0], tm_ptr, sizeof(struct tm)); tm_ptr = localtime(&t); - duk_memcpy((void *) &tms[1], tm_ptr, sizeof(struct tm)); + DUK_MEMCPY((void *) &tms[1], tm_ptr, sizeof(struct tm)); #else #error internal error #endif @@ -205,13 +205,13 @@ /* Copy to buffer with slack to avoid Valgrind gripes from strptime. */ DUK_ASSERT(str != NULL); - duk_memzero(buf, sizeof(buf)); /* valgrind whine without this */ + DUK_MEMZERO(buf, sizeof(buf)); /* valgrind whine without this */ DUK_SNPRINTF(buf, sizeof(buf), "%s", (const char *) str); buf[sizeof(buf) - 1] = (char) 0; DUK_DDD(DUK_DDDPRINT("parsing: '%s'", (const char *) buf)); - duk_memzero(&tm, sizeof(tm)); + DUK_MEMZERO(&tm, sizeof(tm)); if (strptime((const char *) buf, "%c", &tm) != NULL) { DUK_DDD(DUK_DDDPRINT("before mktime: tm={sec:%ld,min:%ld,hour:%ld,mday:%ld,mon:%ld,year:%ld," "wday:%ld,yday:%ld,isdst:%ld}", @@ -242,7 +242,7 @@ * convenient for an embeddable interpreter. */ - duk_memzero(&tm, sizeof(struct tm)); + DUK_MEMZERO(&tm, sizeof(struct tm)); rc = (duk_small_int_t) getdate_r(str, &tm); DUK_DDD(DUK_DDDPRINT("getdate_r() -> %ld", (long) rc)); @@ -267,16 +267,16 @@ DUK_UNREF(tzoffset); - /* If the platform doesn't support the entire ECMAScript range, we need + /* If the platform doesn't support the entire Ecmascript range, we need * to return 0 so that the caller can fall back to the default formatter. * - * For now, assume that if time_t is 8 bytes or more, the whole ECMAScript + * For now, assume that if time_t is 8 bytes or more, the whole Ecmascript * range is supported. For smaller time_t values (4 bytes in practice), * assumes that the signed 32-bit range is supported. * * XXX: detect this more correctly per platform. The size of time_t is * probably not an accurate guarantee of strftime() supporting or not - * supporting a large time range (the full ECMAScript range). + * supporting a large time range (the full Ecmascript range). */ if (sizeof(time_t) < 8 && (parts[DUK_DATE_IDX_YEAR] < 1970 || parts[DUK_DATE_IDX_YEAR] > 2037)) { @@ -284,7 +284,7 @@ return 0; } - duk_memzero(&tm, sizeof(tm)); + DUK_MEMZERO(&tm, sizeof(tm)); tm.tm_sec = parts[DUK_DATE_IDX_SECOND]; tm.tm_min = parts[DUK_DATE_IDX_MINUTE]; tm.tm_hour = parts[DUK_DATE_IDX_HOUR]; @@ -294,7 +294,7 @@ tm.tm_wday = parts[DUK_DATE_IDX_WEEKDAY]; tm.tm_isdst = 0; - duk_memzero(buf, sizeof(buf)); + DUK_MEMZERO(buf, sizeof(buf)); if ((flags & DUK_DATE_FLAG_TOSTRING_DATE) && (flags & DUK_DATE_FLAG_TOSTRING_TIME)) { fmt = "%c"; } else if (flags & DUK_DATE_FLAG_TOSTRING_DATE) { diff -Nru duktape-2.3.0/src-separate/duk_bi_date_windows.c duktape-2.2.0/src-separate/duk_bi_date_windows.c --- duktape-2.3.0/src-separate/duk_bi_date_windows.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_date_windows.c 2017-09-23 01:06:08.000000000 +0000 @@ -23,15 +23,13 @@ } } -#if defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS) DUK_LOCAL void duk__convert_filetime_to_ularge(const FILETIME *ft, ULARGE_INTEGER *res) { res->LowPart = ft->dwLowDateTime; res->HighPart = ft->dwHighDateTime; } -#endif /* DUK_USE_DATE_NOW_WINDOWS_SUBMS */ DUK_LOCAL void duk__set_systime_jan1970(SYSTEMTIME *st) { - duk_memzero((void *) st, sizeof(*st)); + DUK_MEMZERO((void *) st, sizeof(*st)); st->wYear = 1970; st->wMonth = 1; st->wDayOfWeek = 4; /* not sure whether or not needed; Thursday */ @@ -96,11 +94,10 @@ ULARGE_INTEGER tmp2; ULARGE_INTEGER tmp3; FILETIME ft1; - BOOL ret; /* XXX: handling of timestamps outside Windows supported range. * How does Windows deal with dates before 1600? Does windows - * support all ECMAScript years (like -200000 and +200000)? + * support all Ecmascript years (like -200000 and +200000)? * Should equivalent year mapping be used here too? If so, use * a shared helper (currently integrated into timeval-to-parts). */ @@ -116,11 +113,7 @@ ft1.dwLowDateTime = tmp2.LowPart; ft1.dwHighDateTime = tmp2.HighPart; - ret = FileTimeToSystemTime((const FILETIME *) &ft1, &st2); - if (!ret) { - DUK_D(DUK_DPRINT("FileTimeToSystemTime() failed, return tzoffset 0")); - return 0; - } + FileTimeToSystemTime((const FILETIME *) &ft1, &st2); if (SystemTimeToTzSpecificLocalTime((LPTIME_ZONE_INFORMATION) NULL, &st2, &st3) == 0) { DUK_D(DUK_DPRINT("SystemTimeToTzSpecificLocalTime() failed, return tzoffset 0")); return 0; @@ -140,7 +133,6 @@ FILETIME ft2; ULARGE_INTEGER tmp1; ULARGE_INTEGER tmp2; - BOOL ret; /* Do a similar computation to duk_bi_date_get_local_tzoffset_windows * but without accounting for daylight savings time. Use this on @@ -156,17 +148,9 @@ ft1.dwLowDateTime = tmp1.LowPart; ft1.dwHighDateTime = tmp1.HighPart; - ret = FileTimeToLocalFileTime((const FILETIME *) &ft1, &ft2); - if (!ret) { - DUK_D(DUK_DPRINT("FileTimeToLocalFileTime() failed, return tzoffset 0")); - return 0; - } + FileTimeToLocalFileTime((const FILETIME *) &ft1, &ft2); - ret = FileTimeToSystemTime((const FILETIME *) &ft2, &st2); - if (!ret) { - DUK_D(DUK_DPRINT("FileTimeToSystemTime() failed, return tzoffset 0")); - return 0; - } + FileTimeToSystemTime((const FILETIME *) &ft2, &st2); duk__convert_systime_to_ularge((const SYSTEMTIME *) &st2, &tmp2); return (duk_int_t) (((LONGLONG) tmp2.QuadPart - (LONGLONG) tmp1.QuadPart) / DUK_I64_CONSTANT(10000000)); /* seconds */ diff -Nru duktape-2.3.0/src-separate/duk_bi_duktape.c duktape-2.2.0/src-separate/duk_bi_duktape.c --- duktape-2.3.0/src-separate/duk_bi_duktape.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_duktape.c 2017-09-23 01:06:08.000000000 +0000 @@ -3,7 +3,7 @@ * * Size optimization note: it might seem that vararg multipurpose functions * like fin(), enc(), and dec() are not very size optimal, but using a single - * user-visible ECMAScript function saves a lot of run-time footprint; each + * user-visible Ecmascript function saves a lot of run-time footprint; each * Function instance takes >100 bytes. Using a shared native helper and a * 'magic' value won't save much if there are multiple Function instances * anyway. diff -Nru duktape-2.3.0/src-separate/duk_bi_encoding.c duktape-2.2.0/src-separate/duk_bi_encoding.c --- duktape-2.3.0/src-separate/duk_bi_encoding.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_encoding.c 2017-09-23 01:06:08.000000000 +0000 @@ -239,7 +239,7 @@ DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER | DUK_TYPE_MASK_OBJECT); - if (duk_get_prop_literal(thr, 1, "stream")) { + if (duk_get_prop_string(thr, 1, "stream")) { stream = duk_to_boolean(thr, -1); } } @@ -254,7 +254,6 @@ */ if (len >= (DUK_HBUFFER_MAX_BYTELEN / 3) - 3) { DUK_ERROR_TYPE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return 0;); } output = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, 3 + (3 * len)); /* used parts will be always manually written over */ @@ -332,7 +331,7 @@ fail_type: DUK_ERROR_TYPE(thr, DUK_STR_UTF8_DECODE_FAILED); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); } /* @@ -350,7 +349,7 @@ } DUK_INTERNAL duk_ret_t duk_bi_textencoder_prototype_encoding_getter(duk_hthread *thr) { - duk_push_literal(thr, "utf-8"); + duk_push_string(thr, "utf-8"); return 1; } @@ -372,7 +371,6 @@ len = (duk_size_t) DUK_HSTRING_GET_CHARLEN(h_input); if (len >= DUK_HBUFFER_MAX_BYTELEN / 3) { DUK_ERROR_TYPE(thr, DUK_STR_RESULT_TOO_LONG); - DUK_WO_NORETURN(return 0;); } } @@ -392,14 +390,14 @@ DUK_ASSERT(duk_is_string(thr, 0)); /* True if len > 0. */ /* XXX: duk_decode_string() is used to process the input - * string. For standard ECMAScript strings, represented + * string. For standard Ecmascript strings, represented * internally as CESU-8, this is fine. However, behavior * beyond CESU-8 is not very strict: codepoints using an * extended form of UTF-8 are also accepted, and invalid * codepoint sequences (which are allowed in Duktape strings) * are not handled as well as they could (e.g. invalid * continuation bytes may mask following codepoints). - * This is how ECMAScript code would also see such strings. + * This is how Ecmascript code would also see such strings. * Maybe replace duk_decode_string() with an explicit strict * CESU-8 decoder here? */ @@ -427,7 +425,7 @@ /* Standard WHATWG output is a Uint8Array. Here the Uint8Array will * be backed by a dynamic buffer which differs from e.g. Uint8Arrays - * created as 'new Uint8Array(N)'. ECMAScript code won't see the + * created as 'new Uint8Array(N)'. Ecmascript code won't see the * difference but C code will. When bufferobjects are not supported, * returns a plain dynamic buffer. */ @@ -449,10 +447,10 @@ duk_to_string(thr, 0); } if (!duk_is_null_or_undefined(thr, 1)) { - if (duk_get_prop_literal(thr, 1, "fatal")) { + if (duk_get_prop_string(thr, 1, "fatal")) { fatal = duk_to_boolean(thr, -1); } - if (duk_get_prop_literal(thr, 1, "ignoreBOM")) { + if (duk_get_prop_string(thr, 1, "ignoreBOM")) { ignore_bom = duk_to_boolean(thr, -1); } } @@ -467,7 +465,7 @@ dec_ctx->ignore_bom = (duk_uint8_t) ignore_bom; duk__utf8_decode_init(dec_ctx); /* Initializes remaining fields. */ - duk_put_prop_literal(thr, -2, DUK_INTERNAL_SYMBOL("Context")); + duk_put_prop_string(thr, -2, DUK_INTERNAL_SYMBOL("Context")); return 0; } @@ -475,7 +473,7 @@ DUK_LOCAL duk__decode_context *duk__get_textdecoder_context(duk_hthread *thr) { duk__decode_context *dec_ctx; duk_push_this(thr); - duk_get_prop_literal(thr, -1, DUK_INTERNAL_SYMBOL("Context")); + duk_get_prop_string(thr, -1, DUK_INTERNAL_SYMBOL("Context")); dec_ctx = (duk__decode_context *) duk_require_buffer(thr, -1, NULL); DUK_ASSERT(dec_ctx != NULL); return dec_ctx; @@ -492,7 +490,7 @@ /* Encoding is now fixed, so _Context lookup is only needed to * validate the 'this' binding (TypeError if not TextDecoder-like). */ - duk_push_literal(thr, "utf-8"); + duk_push_string(thr, "utf-8"); break; case 1: duk_push_boolean(thr, dec_ctx->fatal); diff -Nru duktape-2.3.0/src-separate/duk_bi_error.c duktape-2.2.0/src-separate/duk_bi_error.c --- duktape-2.3.0/src-separate/duk_bi_error.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_error.c 2017-09-23 01:06:08.000000000 +0000 @@ -54,7 +54,7 @@ duk_get_prop_stridx_short(thr, -1, DUK_STRIDX_NAME); if (duk_is_undefined(thr, -1)) { duk_pop(thr); - duk_push_literal(thr, "Error"); + duk_push_string(thr, "Error"); } else { duk_to_string(thr, -1); } @@ -84,7 +84,7 @@ duk_pop(thr); return 1; } - duk_push_literal(thr, ": "); + duk_push_string(thr, ": "); duk_insert(thr, -2); /* ... name ': ' message */ duk_concat(thr, 3); @@ -153,13 +153,13 @@ duk_get_prop_index(thr, idx_td, (duk_uarridx_t) i); duk_get_prop_index(thr, idx_td, (duk_uarridx_t) (i + 1)); d = duk_to_number_m1(thr); - pc = duk_double_to_int_t(DUK_FMOD(d, DUK_DOUBLE_2TO32)); - flags = duk_double_to_uint_t(DUK_FLOOR(d / DUK_DOUBLE_2TO32)); + pc = (duk_int_t) DUK_FMOD(d, DUK_DOUBLE_2TO32); + flags = (duk_uint_t) DUK_FLOOR(d / DUK_DOUBLE_2TO32); t = (duk_small_int_t) duk_get_type(thr, -2); if (t == DUK_TYPE_OBJECT || t == DUK_TYPE_LIGHTFUNC) { /* - * ECMAScript/native function call or lightfunc call + * Ecmascript/native function call or lightfunc call */ count_func++; diff -Nru duktape-2.3.0/src-separate/duk_bi_function.c duktape-2.2.0/src-separate/duk_bi_function.c --- duktape-2.3.0/src-separate/duk_bi_function.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_function.c 2017-09-23 01:06:08.000000000 +0000 @@ -36,7 +36,7 @@ duk_push_hstring_empty(thr); } else { duk_insert(thr, 0); /* [ arg1 ... argN-1 body] -> [body arg1 ... argN-1] */ - duk_push_literal(thr, ","); + duk_push_string(thr, ","); duk_insert(thr, 1); duk_join(thr, nargs - 1); } @@ -48,11 +48,11 @@ /* XXX: this placeholder is not always correct, but use for now. * It will fail in corner cases; see test-dev-func-cons-args.js. */ - duk_push_literal(thr, "function("); + duk_push_string(thr, "function("); duk_dup_1(thr); - duk_push_literal(thr, "){"); + duk_push_string(thr, "){"); duk_dup_0(thr); - duk_push_literal(thr, "\n}"); /* Newline is important to handle trailing // comment. */ + duk_push_string(thr, "}"); duk_concat(thr, 5); /* [ body formals source ] */ @@ -70,7 +70,7 @@ comp_flags); /* Force .name to 'anonymous' (ES2015). */ - duk_push_literal(thr, "anonymous"); + duk_push_string(thr, "anonymous"); duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_NAME, DUK_PROPDESC_FLAGS_C); func = (duk_hcompfunc *) duk_known_hobject(thr, -1); @@ -282,7 +282,7 @@ if (DUK_HOBJECT_HAS_BOUNDFUNC(h_target)) { duk_hboundfunc *h_boundtarget; - h_boundtarget = (duk_hboundfunc *) (void *) h_target; + h_boundtarget = (duk_hboundfunc *) h_target; /* The final function should always be non-bound, unless * there's a bug in the internals. Assert for it. @@ -316,7 +316,7 @@ DUK_DCERROR_RANGE_INVALID_COUNT(thr); } tv_res = (duk_tval *) DUK_ALLOC_CHECKED(thr, ((duk_size_t) bound_nargs) * sizeof(duk_tval)); - DUK_ASSERT(tv_res != NULL || bound_nargs == 0); + DUK_ASSERT(tv_res != NULL); DUK_ASSERT(h_bound->args == NULL); DUK_ASSERT(h_bound->nargs == 0); h_bound->args = tv_res; @@ -356,7 +356,7 @@ duk_xdef_prop_stridx_thrower(thr, -1, DUK_STRIDX_LC_ARGUMENTS); /* Function name and fileName (non-standard). */ - duk_push_literal(thr, "bound "); /* ES2015 19.2.3.2. */ + duk_push_string(thr, "bound "); /* ES2015 19.2.3.2. */ duk_get_prop_stridx(thr, -3, DUK_STRIDX_NAME); if (!duk_is_string_notsymbol(thr, -1)) { /* ES2015 has requirement to check that .name of target is a string @@ -440,14 +440,3 @@ fail_type: DUK_DCERROR_TYPE_INVALID_ARGS(thr); } - -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL duk_ret_t duk_bi_function_prototype_hasinstance(duk_hthread *thr) { - /* This binding: RHS, stack index 0: LHS. */ - duk_bool_t ret; - - ret = duk_js_instanceof_ordinary(thr, DUK_GET_TVAL_POSIDX(thr, 0), DUK_GET_THIS_TVAL_PTR(thr)); - duk_push_boolean(thr, ret); - return 1; -} -#endif /* DUK_USE_SYMBOL_BUILTIN */ diff -Nru duktape-2.3.0/src-separate/duk_bi_global.c duktape-2.2.0/src-separate/duk_bi_global.c --- duktape-2.3.0/src-separate/duk_bi_global.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_global.c 2017-09-23 01:06:08.000000000 +0000 @@ -200,7 +200,6 @@ uri_error: DUK_ERROR_URI(tfm_ctx->thr, DUK_STR_INVALID_INPUT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__transform_callback_decode_uri(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp) { @@ -339,7 +338,6 @@ uri_error: DUK_ERROR_URI(tfm_ctx->thr, DUK_STR_INVALID_INPUT); - DUK_WO_NORETURN(return;); } #if defined(DUK_USE_SECTION_B) @@ -380,7 +378,6 @@ esc_error: DUK_ERROR_TYPE(tfm_ctx->thr, DUK_STR_INVALID_INPUT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__transform_callback_unescape(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp) { @@ -413,7 +410,7 @@ * Eval needs to handle both a "direct eval" and an "indirect eval". * Direct eval handling needs access to the caller's activation so that its * lexical environment can be accessed. A direct eval is only possible from - * ECMAScript code; an indirect eval call is possible also from C code. + * Ecmascript code; an indirect eval call is possible also from C code. * When an indirect eval call is made from C code, there may not be a * calling activation at all which needs careful handling. */ @@ -452,7 +449,7 @@ #if defined(DUK_USE_DEBUGGER_SUPPORT) /* NOTE: level is used only by the debugger and should never be present - * for an ECMAScript eval(). + * for an Ecmascript eval(). */ DUK_ASSERT(level == -2); /* by default, use caller's environment */ if (duk_get_top(thr) >= 2 && duk_is_number(thr, 1)) { diff -Nru duktape-2.3.0/src-separate/duk_bi_json.c duktape-2.2.0/src-separate/duk_bi_json.c --- duktape-2.3.0/src-separate/duk_bi_json.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_json.c 2017-09-23 01:06:08.000000000 +0000 @@ -214,7 +214,6 @@ */ DUK_ERROR_FMT1(js_ctx->thr, DUK_ERR_SYNTAX_ERROR, DUK_STR_FMT_INVALID_JSON, (long) (js_ctx->p - js_ctx->p_start)); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__dec_eat_white(duk_json_dec_ctx *js_ctx) { @@ -630,7 +629,7 @@ src_len = (duk_size_t) (p - js_ctx->p); buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, src_len); DUK_ASSERT(buf != NULL); - duk_memcpy((void *) buf, (const void *) js_ctx->p, src_len); + DUK_MEMCPY((void *) buf, (const void *) js_ctx->p, src_len); duk_hex_decode(thr, -1); js_ctx->p = p + 1; /* skip '|' */ @@ -721,7 +720,6 @@ DUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit); if (js_ctx->recursion_depth >= js_ctx->recursion_limit) { DUK_ERROR_RANGE(thr, DUK_STR_JSONDEC_RECLIMIT); - DUK_WO_NORETURN(return;); } js_ctx->recursion_depth++; } @@ -1298,9 +1296,9 @@ /* If XUTF-8 decoding fails, treat the offending byte as a codepoint directly * and go forward one byte. This is of course very lossy, but allows some kind * of output to be produced even for internal strings which don't conform to - * XUTF-8. All standard ECMAScript strings are always CESU-8, so this behavior - * does not violate the ECMAScript specification. The behavior is applied to - * all modes, including ECMAScript standard JSON. Because the current XUTF-8 + * XUTF-8. All standard Ecmascript strings are always CESU-8, so this behavior + * does not violate the Ecmascript specification. The behavior is applied to + * all modes, including Ecmascript standard JSON. Because the current XUTF-8 * decoding is not very strict, this behavior only really affects initial bytes * and truncated codepoints. * @@ -1437,7 +1435,7 @@ /* Unlike in duk_hex_encode() 'dst' is not necessarily aligned by 2. * For platforms where unaligned accesses are not allowed, shift 'dst' - * ahead by 1 byte to get alignment and then duk_memmove() the result + * ahead by 1 byte to get alignment and then DUK_MEMMOVE() the result * in place. The faster encoding loop makes up the difference. * There's always space for one extra byte because a terminator always * follows the hex data and that's been accounted for by the caller. @@ -1470,7 +1468,7 @@ #if !defined(DUK_USE_UNALIGNED_ACCESSES_POSSIBLE) if (shift_dst) { q--; - duk_memmove((void *) dst, (const void *) (dst + 1), 2 * len_safe); + DUK_MEMMOVE((void *) dst, (const void *) (dst + 1), 2 * len_safe); DUK_ASSERT(dst + 2 * len_safe == q); } #endif @@ -1546,7 +1544,7 @@ #if defined(DUK_USE_JC) { DUK_ASSERT(js_ctx->flag_ext_compatible); - duk_memcpy((void *) q, (const void *) "{\"_buf\":\"", 9); /* len: 9 */ + DUK_MEMCPY((void *) q, (const void *) "{\"_buf\":\"", 9); /* len: 9 */ q += 9; q = duk__enc_buffer_data_hex(buf_data, buf_len, q); *q++ = DUK_ASC_DOUBLEQUOTE; @@ -1619,7 +1617,7 @@ DUK_ASSERT(js_ctx->flag_ext_custom || js_ctx->flag_ext_compatible); /* caller checks */ DUK_ASSERT(js_ctx->flag_ext_custom_or_compatible); - duk_memzero(buf, sizeof(buf)); + DUK_MEMZERO(buf, sizeof(buf)); /* The #if defined() clutter here needs to handle the three * cases: (1) JX+JC, (2) JX only, (3) JC only. @@ -1709,21 +1707,21 @@ p = DUK_BW_ENSURE_GETPTR(js_ctx->thr, &js_ctx->bw, need_bytes); p_start = p; - duk_memcpy((void *) p, (const void *) gap_data, (size_t) gap_len); + DUK_MEMCPY((void *) p, (const void *) gap_data, (size_t) gap_len); p += gap_len; avail_bytes = gap_len; DUK_ASSERT(need_bytes >= gap_len); need_bytes -= gap_len; while (need_bytes >= avail_bytes) { - duk_memcpy((void *) p, (const void *) p_start, (size_t) avail_bytes); + DUK_MEMCPY((void *) p, (const void *) p_start, (size_t) avail_bytes); p += avail_bytes; need_bytes -= avail_bytes; avail_bytes <<= 1; } DUK_ASSERT(need_bytes < avail_bytes); /* need_bytes may be zero */ - duk_memcpy((void *) p, (const void *) p_start, (size_t) need_bytes); + DUK_MEMCPY((void *) p, (const void *) p_start, (size_t) need_bytes); p += need_bytes; /*avail_bytes += need_bytes*/ @@ -1755,7 +1753,6 @@ if (DUK_UNLIKELY(js_ctx->visiting[i] == h_target)) { DUK_DD(DUK_DDPRINT("slow path loop detect")); DUK_ERROR_TYPE(thr, DUK_STR_CYCLIC_INPUT); - DUK_WO_NORETURN(return;); } } if (js_ctx->recursion_depth < DUK_JSON_ENC_LOOPARRAY) { @@ -1765,7 +1762,6 @@ duk_dup_top(thr); /* -> [ ... voidp voidp ] */ if (duk_has_prop(thr, js_ctx->idx_loop)) { DUK_ERROR_TYPE(thr, DUK_STR_CYCLIC_INPUT); - DUK_WO_NORETURN(return;); } duk_push_true(thr); /* -> [ ... voidp true ] */ duk_put_prop(thr, js_ctx->idx_loop); /* -> [ ... ] */ @@ -1777,7 +1773,6 @@ DUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit); if (js_ctx->recursion_depth >= js_ctx->recursion_limit) { DUK_ERROR_RANGE(thr, DUK_STR_JSONENC_RECLIMIT); - DUK_WO_NORETURN(return;); } js_ctx->recursion_depth++; @@ -2375,14 +2370,12 @@ if (js_ctx->recursion_depth >= js_ctx->recursion_limit) { DUK_DD(DUK_DDPRINT("fast path recursion limit")); DUK_ERROR_RANGE(js_ctx->thr, DUK_STR_JSONDEC_RECLIMIT); - DUK_WO_NORETURN(return 0;); } for (i = 0, n = (duk_uint_fast32_t) js_ctx->recursion_depth; i < n; i++) { if (DUK_UNLIKELY(js_ctx->visiting[i] == obj)) { DUK_DD(DUK_DDPRINT("fast path loop detect")); DUK_ERROR_TYPE(js_ctx->thr, DUK_STR_CYCLIC_INPUT); - DUK_WO_NORETURN(return 0;); } } @@ -2763,7 +2756,7 @@ /* Error message doesn't matter: the error is ignored anyway. */ DUK_DD(DUK_DDPRINT("aborting fast path")); DUK_ERROR_INTERNAL(js_ctx->thr); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } DUK_LOCAL duk_ret_t duk__json_stringify_fast(duk_hthread *thr, void *udata) { @@ -2812,7 +2805,7 @@ (unsigned long) flags, (long) duk_get_top(thr))); - duk_memzero(&js_ctx_alloc, sizeof(js_ctx_alloc)); + DUK_MEMZERO(&js_ctx_alloc, sizeof(js_ctx_alloc)); js_ctx->thr = thr; #if defined(DUK_USE_EXPLICIT_NULL_INIT) /* nothing now */ @@ -2922,7 +2915,7 @@ * Context init */ - duk_memzero(&js_ctx_alloc, sizeof(js_ctx_alloc)); + DUK_MEMZERO(&js_ctx_alloc, sizeof(js_ctx_alloc)); js_ctx->thr = thr; #if defined(DUK_USE_EXPLICIT_NULL_INIT) js_ctx->h_replacer = NULL; diff -Nru duktape-2.3.0/src-separate/duk_bi_math.c duktape-2.2.0/src-separate/duk_bi_math.c --- duktape-2.3.0/src-separate/duk_bi_math.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_math.c 2017-09-23 01:06:08.000000000 +0000 @@ -51,7 +51,7 @@ DUK_LOCAL double duk__fmin_fixed(double x, double y) { /* fmin() with args -0 and +0 is not guaranteed to return - * -0 as ECMAScript requires. + * -0 as Ecmascript requires. */ if (x == 0 && y == 0) { duk_double_union du1, du2; @@ -78,7 +78,7 @@ DUK_LOCAL double duk__fmax_fixed(double x, double y) { /* fmax() with args -0 and +0 is not guaranteed to return - * +0 as ECMAScript requires. + * +0 as Ecmascript requires. */ if (x == 0 && y == 0) { if (DUK_SIGNBIT(x) == 0 || DUK_SIGNBIT(y) == 0) { diff -Nru duktape-2.3.0/src-separate/duk_bi_number.c duktape-2.2.0/src-separate/duk_bi_number.c --- duktape-2.3.0/src-separate/duk_bi_number.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_number.c 2017-09-23 01:06:08.000000000 +0000 @@ -23,7 +23,6 @@ (DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_NUMBER)) { DUK_DDD(DUK_DDDPRINT("unacceptable this value: %!T", (duk_tval *) duk_get_tval(thr, -1))); DUK_ERROR_TYPE(thr, "number expected"); - DUK_WO_NORETURN(return 0.0;); } duk_get_prop_stridx_short(thr, -1, DUK_STRIDX_INT_VALUE); DUK_ASSERT(duk_is_number(thr, -1)); @@ -130,11 +129,8 @@ duk_small_int_t c; duk_small_uint_t n2s_flags; - /* In ES5.1 frac_digits is coerced first; in ES2015 the 'this number - * value' check is done first. - */ - d = duk__push_this_number_plain(thr); frac_digits = (duk_small_int_t) duk_to_int_check_range(thr, 0, 0, 20); + d = duk__push_this_number_plain(thr); c = (duk_small_int_t) DUK_FPCLASSIFY(d); if (c == DUK_FP_NAN || c == DUK_FP_INFINITE) { @@ -241,40 +237,4 @@ return 1; } -/* - * ES2015 isFinite() etc - */ - -#if defined(DUK_USE_ES6) -DUK_INTERNAL duk_ret_t duk_bi_number_check_shared(duk_hthread *thr) { - duk_int_t magic; - duk_bool_t ret = 0; - - if (duk_is_number(thr, 0)) { - duk_double_t d; - - magic = duk_get_current_magic(thr); - d = duk_get_number(thr, 0); - - switch (magic) { - case 0: /* isFinite() */ - ret = duk_double_is_finite(d); - break; - case 1: /* isInteger() */ - ret = duk_double_is_integer(d); - break; - case 2: /* isNaN() */ - ret = duk_double_is_nan(d); - break; - default: /* isSafeInteger() */ - DUK_ASSERT(magic == 3); - ret = duk_double_is_safe_integer(d); - } - } - - duk_push_boolean(thr, ret); - return 1; -} -#endif /* DUK_USE_ES6 */ - #endif /* DUK_USE_NUMBER_BUILTIN */ diff -Nru duktape-2.3.0/src-separate/duk_bi_object.c duktape-2.2.0/src-separate/duk_bi_object.c --- duktape-2.3.0/src-separate/duk_bi_object.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_object.c 2017-09-23 01:06:08.000000000 +0000 @@ -7,9 +7,12 @@ /* Needed even when Object built-in disabled. */ DUK_INTERNAL duk_ret_t duk_bi_object_prototype_to_string(duk_hthread *thr) { duk_tval *tv; - tv = DUK_HTHREAD_THIS_PTR(thr); - duk_push_class_string_tval(thr, tv, 0 /*avoid_side_effects*/); + /* XXX: This is not entirely correct anymore; in ES2015 the + * default lookup should use @@toStringTag to come up with + * e.g. [object Symbol]. + */ + duk_push_class_string_tval(thr, tv); return 1; } @@ -514,7 +517,7 @@ DUK_ASSERT(duk_get_hobject(thr, 2) != NULL); /* - * Validate and convert argument property descriptor (an ECMAScript + * Validate and convert argument property descriptor (an Ecmascript * object) into a set of defprop_flags and possibly property value, * getter, and/or setter values on the value stack. * @@ -792,7 +795,6 @@ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } duk_get_prototype(thr, -1); diff -Nru duktape-2.3.0/src-separate/duk_bi_promise.c duktape-2.2.0/src-separate/duk_bi_promise.c --- duktape-2.3.0/src-separate/duk_bi_promise.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_promise.c 2017-09-23 01:06:08.000000000 +0000 @@ -8,37 +8,37 @@ DUK_INTERNAL duk_ret_t duk_bi_promise_constructor(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_all(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_race(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_reject(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_resolve(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_catch(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL duk_ret_t duk_bi_promise_then(duk_hthread *thr) { DUK_ERROR_TYPE(thr, "unimplemented"); - DUK_WO_NORETURN(return 0;); + return 0; } #endif /* DUK_USE_PROMISE_BUILTIN */ diff -Nru duktape-2.3.0/src-separate/duk_bi_proxy.c duktape-2.2.0/src-separate/duk_bi_proxy.c --- duktape-2.3.0/src-separate/duk_bi_proxy.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_proxy.c 2017-09-23 01:06:08.000000000 +0000 @@ -28,7 +28,6 @@ h = duk_get_hstring(thr, -1); if (h == NULL) { DUK_ERROR_TYPE_INVALID_TRAP_RESULT(thr); - DUK_WO_NORETURN(return;); } if (!(flags & DUK_ENUM_INCLUDE_NONENUMERABLE)) { diff -Nru duktape-2.3.0/src-separate/duk_bi_reflect.c duktape-2.2.0/src-separate/duk_bi_reflect.c --- duktape-2.3.0/src-separate/duk_bi_reflect.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_reflect.c 2017-09-23 01:06:08.000000000 +0000 @@ -40,7 +40,6 @@ if (nargs >= 3 && !duk_strict_equals(thr, 0, 2)) { /* XXX: [[Get]] receiver currently unsupported */ DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } /* [ target key receiver? ...? ] */ @@ -84,7 +83,6 @@ if (nargs >= 4 && !duk_strict_equals(thr, 0, 3)) { /* XXX: [[Set]] receiver currently unsupported */ DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } /* [ target key value receiver? ...? ] */ diff -Nru duktape-2.3.0/src-separate/duk_bi_regexp.c duktape-2.2.0/src-separate/duk_bi_regexp.c --- duktape-2.3.0/src-separate/duk_bi_regexp.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_regexp.c 2017-09-23 01:06:08.000000000 +0000 @@ -119,7 +119,7 @@ /* This must be generic in ES2015 and later. */ DUK_ASSERT_TOP(thr, 0); duk_push_this(thr); - duk_push_literal(thr, "/"); + duk_push_string(thr, "/"); duk_get_prop_stridx(thr, 0, DUK_STRIDX_SOURCE); duk_dup_m2(thr); /* another "/" */ duk_get_prop_stridx(thr, 0, DUK_STRIDX_FLAGS); @@ -183,7 +183,7 @@ if (magic != 16 /* .source */) { return 0; } - duk_push_literal(thr, "(?:)"); /* .source handled by switch-case */ + duk_push_string(thr, "(?:)"); /* .source handled by switch-case */ re_flags = 0; } else { DUK_DCERROR_TYPE_INVALID_ARGS(thr); diff -Nru duktape-2.3.0/src-separate/duk_bi_string.c duktape-2.2.0/src-separate/duk_bi_string.c --- duktape-2.3.0/src-separate/duk_bi_string.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_string.c 2017-09-23 01:06:08.000000000 +0000 @@ -28,7 +28,6 @@ if (duk_get_class_number(thr, idx) == DUK_HOBJECT_CLASS_REGEXP) { DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return NULL;); } h = duk_to_hstring(thr, idx); DUK_ASSERT(h != NULL); @@ -75,14 +74,14 @@ while (p <= p_end && p >= p_start) { t = *p; - /* For ECMAScript strings, this check can only match for + /* For Ecmascript strings, this check can only match for * initial UTF-8 bytes (not continuation bytes). For other * strings all bets are off. */ if ((t == firstbyte) && ((duk_size_t) (p_end - p) >= (duk_size_t) q_blen)) { - DUK_ASSERT(q_blen > 0); - if (duk_memcmp((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { + DUK_ASSERT(q_blen > 0); /* no issues with memcmp() zero size, even if broken */ + if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { return cpos; } } @@ -264,37 +263,13 @@ */ DUK_INTERNAL duk_ret_t duk_bi_string_prototype_char_at(duk_hthread *thr) { - duk_hstring *h; duk_int_t pos; /* XXX: faster implementation */ - h = duk_push_this_coercible_to_string(thr); - DUK_ASSERT(h != NULL); - + (void) duk_push_this_coercible_to_string(thr); pos = duk_to_int(thr, 0); - - if (sizeof(duk_size_t) >= sizeof(duk_uint_t)) { - /* Cast to duk_size_t works in this case: - * - If pos < 0, (duk_size_t) pos will always be - * >= max_charlen, and result will be the empty string - * (see duk_substring()). - * - If pos >= 0, pos + 1 cannot wrap. - */ - DUK_ASSERT((duk_size_t) DUK_INT_MIN >= DUK_HSTRING_MAX_BYTELEN); - DUK_ASSERT((duk_size_t) DUK_INT_MAX + 1U > (duk_size_t) DUK_INT_MAX); - duk_substring(thr, -1, (duk_size_t) pos, (duk_size_t) pos + 1U); - } else { - /* If size_t is smaller than int, explicit bounds checks - * are needed because an int may wrap multiple times. - */ - if (DUK_UNLIKELY(pos < 0 || (duk_uint_t) pos >= (duk_uint_t) DUK_HSTRING_GET_CHARLEN(h))) { - duk_push_hstring_empty(thr); - } else { - duk_substring(thr, -1, (duk_size_t) pos, (duk_size_t) pos + 1U); - } - } - + duk_substring(thr, -1, (duk_size_t) pos, (duk_size_t) (pos + 1)); return 1; } @@ -684,7 +659,7 @@ while (p <= p_end) { DUK_ASSERT(p + q_blen <= DUK_HSTRING_GET_DATA(h_input) + DUK_HSTRING_GET_BYTELEN(h_input)); - if (duk_memcmp((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { + if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { duk_dup_0(thr); h_match = duk_known_hstring(thr, -1); #if defined(DUK_USE_REGEXP_SUPPORT) @@ -1065,7 +1040,7 @@ while (p <= p_end) { DUK_ASSERT(p + q_blen <= DUK_HSTRING_GET_DATA(h_input) + DUK_HSTRING_GET_BYTELEN(h_input)); DUK_ASSERT(q_blen > 0); /* no issues with empty memcmp() */ - if (duk_memcmp((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { + if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) { /* never an empty match, so step 13.c.iii can't be triggered */ goto found; } @@ -1378,14 +1353,12 @@ /* Temporary fixed buffer, later converted to string. */ buf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(thr, result_len); - DUK_ASSERT(buf != NULL); src = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input); - DUK_ASSERT(src != NULL); #if defined(DUK_USE_PREFER_SIZE) p = buf; while (count-- > 0) { - duk_memcpy((void *) p, (const void *) src, input_blen); /* copy size may be zero, but pointers are valid */ + DUK_MEMCPY((void *) p, (const void *) src, input_blen); /* copy size may be zero */ p += input_blen; } #else /* DUK_USE_PREFER_SIZE */ @@ -1402,12 +1375,12 @@ (long) result_len)); if (remain <= copy_size) { /* If result_len is zero, this case is taken and does - * a zero size copy (with valid pointers). + * a zero size copy. */ - duk_memcpy((void *) p, (const void *) src, remain); + DUK_MEMCPY((void *) p, (const void *) src, remain); break; } else { - duk_memcpy((void *) p, (const void *) src, copy_size); + DUK_MEMCPY((void *) p, (const void *) src, copy_size); p += copy_size; } @@ -1462,7 +1435,8 @@ h2_len = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h2); prefix_len = (h1_len <= h2_len ? h1_len : h2_len); - rc = (duk_small_int_t) duk_memcmp((const void *) DUK_HSTRING_GET_DATA(h1), + /* Zero size compare not an issue with DUK_MEMCMP. */ + rc = (duk_small_int_t) DUK_MEMCMP((const void *) DUK_HSTRING_GET_DATA(h1), (const void *) DUK_HSTRING_GET_DATA(h2), (size_t) prefix_len); @@ -1512,7 +1486,7 @@ if (duk_is_undefined(thr, 1)) { if (magic) { - p_cmp_start = p_cmp_start + DUK_HSTRING_GET_BYTELEN(h) - blen_search; + p_cmp_start += DUK_HSTRING_GET_BYTELEN(h) - blen_search; } else { /* p_cmp_start already OK */ } @@ -1543,7 +1517,7 @@ result = 0; if (p_cmp_start >= DUK_HSTRING_GET_DATA(h) && (duk_size_t) (p_cmp_start - (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h)) + blen_search <= DUK_HSTRING_GET_BYTELEN(h)) { - if (duk_memcmp((const void *) p_cmp_start, + if (DUK_MEMCMP((const void *) p_cmp_start, (const void *) DUK_HSTRING_GET_DATA(h_search), (size_t) blen_search) == 0) { result = 1; diff -Nru duktape-2.3.0/src-separate/duk_bi_symbol.c duktape-2.2.0/src-separate/duk_bi_symbol.c --- duktape-2.3.0/src-separate/duk_bi_symbol.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_symbol.c 2017-09-23 01:06:08.000000000 +0000 @@ -37,10 +37,9 @@ * +1 0xff after unique suffix for symbols with undefined description */ buf = (duk_uint8_t *) duk_push_fixed_buffer(thr, 1 + len + 1 + 17 + 1); - DUK_ASSERT(buf != NULL); p = buf + 1; DUK_ASSERT(desc != NULL || len == 0); /* may be NULL if len is 0 */ - duk_memcpy_unsafe((void *) p, (const void *) desc, len); + DUK_MEMCPY((void *) p, (const void *) desc, len); p += len; if (magic == 0) { /* Symbol(): create unique symbol. Use two 32-bit values diff -Nru duktape-2.3.0/src-separate/duk_bi_thread.c duktape-2.2.0/src-separate/duk_bi_thread.c --- duktape-2.3.0/src-separate/duk_bi_thread.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_bi_thread.c 2017-09-23 01:06:08.000000000 +0000 @@ -40,7 +40,7 @@ * * The thread must be in resumable state, either (a) new thread which hasn't * yet started, or (b) a thread which has previously yielded. This method - * must be called from an ECMAScript function. + * must be called from an Ecmascript function. * * Args: * - thread @@ -66,9 +66,8 @@ DUK_ASSERT(thr->heap->curr_thread == thr); thr_resume = duk_require_hthread(thr, 0); - DUK_ASSERT(duk_get_top(thr) == 3); - is_error = (duk_small_uint_t) duk_to_boolean_top_pop(thr); - DUK_ASSERT(duk_get_top(thr) == 2); + is_error = (duk_small_uint_t) duk_to_boolean(thr, 2); + duk_set_top(thr, 2); /* [ thread value ] */ @@ -88,7 +87,7 @@ caller_func = DUK_ACT_GET_FUNC(thr->callstack_curr->parent); if (!DUK_HOBJECT_IS_COMPFUNC(caller_func)) { - DUK_DD(DUK_DDPRINT("resume state invalid: caller must be ECMAScript code")); + DUK_DD(DUK_DDPRINT("resume state invalid: caller must be Ecmascript code")); goto state_error; } @@ -116,7 +115,7 @@ DUK_ASSERT(thr_resume->state == DUK_HTHREAD_STATE_INACTIVE); - /* The initial function must be an ECMAScript function (but + /* The initial function must be an Ecmascript function (but * can be bound). We must make sure of that before we longjmp * because an error in the RESUME handler call processing will * not be handled very cleanly. @@ -195,7 +194,7 @@ * The thread must be in yieldable state: it must have a resumer, and there * must not be any yield-preventing calls (native calls and constructor calls, * currently) in the thread's call stack (otherwise a resume would not be - * possible later). This method must be called from an ECMAScript function. + * possible later). This method must be called from an Ecmascript function. * * Args: * - value @@ -216,9 +215,8 @@ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); DUK_ASSERT(thr->heap->curr_thread == thr); - DUK_ASSERT(duk_get_top(thr) == 2); - is_error = (duk_small_uint_t) duk_to_boolean_top_pop(thr); - DUK_ASSERT(duk_get_top(thr) == 1); + is_error = (duk_small_uint_t) duk_to_boolean(thr, 1); + duk_set_top(thr, 1); /* [ value ] */ @@ -244,7 +242,7 @@ caller_func = DUK_ACT_GET_FUNC(thr->callstack_curr->parent); if (!DUK_HOBJECT_IS_COMPFUNC(caller_func)) { - DUK_DD(DUK_DDPRINT("yield state invalid: caller must be ECMAScript code")); + DUK_DD(DUK_DDPRINT("yield state invalid: caller must be Ecmascript code")); goto state_error; } diff -Nru duktape-2.3.0/src-separate/duk_builtins.c duktape-2.2.0/src-separate/duk_builtins.c --- duktape-2.3.0/src-separate/duk_builtins.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_builtins.c 2017-09-23 01:06:08.000000000 +0000 @@ -13,7 +13,7 @@ #if defined(DUK_USE_ROM_STRINGS) #error ROM support not enabled, rerun configure.py with --rom-support #else /* DUK_USE_ROM_STRINGS */ -DUK_INTERNAL const duk_uint8_t duk_strings_data[967] = { +DUK_INTERNAL const duk_uint8_t duk_strings_data[892] = { 79,40,209,144,168,105,6,78,54,139,89,185,44,48,46,90,120,8,154,140,35,103, 35,113,193,73,5,52,112,180,104,166,135,52,188,4,98,12,27,146,156,80,211,31, 129,115,150,64,52,220,109,24,18,68,156,24,38,67,114,36,55,9,119,151,132, @@ -35,40 +35,36 @@ 249,110,128,126,88,95,133,109,237,237,237,151,235,127,46,249,119,203,190, 186,206,33,181,2,208,61,190,12,19,34,65,19,81,132,108,228,97,1,107,33,12, 32,45,100,137,64,247,175,9,19,155,41,198,130,155,134,69,146,100,227,226, -231,146,51,192,204,73,140,224,145,221,102,241,68,196,169,248,30,75,12,11, -151,242,233,187,143,138,24,137,162,164,255,253,63,3,201,97,129,114,254,92, -112,75,136,108,166,6,136,159,255,167,224,121,44,48,46,95,203,166,238,74, -113,67,77,201,128,223,255,223,224,121,44,48,46,95,203,145,46,9,205,16,39, -201,62,36,0,192,21,147,255,238,145,39,199,197,211,116,240,242,113,197,78, -214,211,226,233,187,107,105,19,119,37,56,161,166,52,221,212,201,205,36,240, -242,16,96,152,12,178,52,211,56,228,73,150,83,0,148,39,137,75,67,73,198,209, -129,36,85,185,201,196,2,32,193,48,17,160,97,16,84,44,156,104,24,67,189,200, -108,201,19,238,114,96,137,137,50,238,113,164,188,211,185,192,226,100,19, -134,68,110,112,174,139,0,185,31,115,149,4,88,7,159,115,146,117,34,34,35, -115,143,22,146,208,210,19,115,140,3,207,185,202,130,36,109,85,185,194,161, -160,90,50,72,155,115,149,2,232,67,137,204,122,22,66,161,175,164,210,72,199, -130,137,1,50,32,145,143,38,120,186,195,35,106,51,146,230,8,36,77,109,65,38, -226,72,159,191,189,181,70,140,133,222,249,212,227,66,125,245,187,251,219, -77,3,119,190,117,56,208,159,125,110,254,246,210,26,93,239,157,78,52,39,223, -93,191,189,180,212,52,187,223,58,156,104,79,190,187,127,123,104,180,104, -183,190,117,56,208,159,125,102,254,209,104,209,124,234,113,161,62,250,80, -196,128,81,4,9,16,162,4,196,116,9,205,154,27,66,32,100,13,12,98,68,227,33, -65,69,204,195,34,201,50,8,110,33,23,34,28,168,104,22,188,12,174,138,11,70, -138,104,115,68,130,137,13,82,27,41,129,162,35,138,54,146,198,137,39,72,180, -210,178,38,35,146,103,68,139,51,197,214,28,227,131,79,15,35,138,58,130,37, -19,155,41,146,174,64,203,99,161,100,37,145,51,148,75,4,164,66,54,140,49,46, -247,70,103,37,230,70,142,70,67,30,232,204,178,163,201,18,54,139,89,39,26, -16,165,2,228,69,33,143,89,24,70,206,73,67,102,72,148,2,32,214,73,157,224, -18,128,98,29,241,69,65,50,37,241,116,200,41,144,102,125,2,180,8,210,152,38, -129,23,8,34,198, +231,146,51,192,204,73,140,224,145,221,102,241,68,196,157,34,79,143,139,166, +233,225,228,227,138,157,173,167,197,211,118,214,210,38,238,74,113,67,76, +105,187,169,147,154,73,225,228,32,193,48,25,100,105,166,113,200,147,44,166, +1,40,79,18,150,134,147,141,163,2,72,171,115,147,136,4,65,130,96,35,64,194, +32,168,89,56,208,48,135,123,144,217,146,39,220,228,193,19,18,101,220,227, +73,121,167,115,129,196,200,39,12,136,220,225,93,22,1,114,62,231,42,8,176, +15,62,231,36,234,68,68,70,231,30,45,37,161,164,38,231,24,7,159,115,149,4, +72,218,171,115,133,67,64,180,100,145,54,231,42,5,208,135,19,152,244,44,133, +67,95,73,164,145,143,5,18,2,100,65,35,30,76,241,117,134,70,212,103,37,204, +16,72,154,218,130,77,196,145,63,127,123,106,141,25,11,189,243,169,198,132, +251,235,119,247,182,154,6,239,124,234,113,161,62,250,221,253,237,164,52, +187,223,58,156,104,79,190,187,127,123,105,168,105,119,190,117,56,208,159, +125,118,254,246,209,104,209,111,124,234,113,161,62,250,205,253,162,209,162, +249,212,227,66,125,244,161,137,0,162,8,18,33,68,9,136,232,19,155,52,54,132, +64,200,26,24,196,137,198,66,130,139,153,134,69,146,100,16,220,66,46,68,57, +80,208,45,120,25,93,20,22,141,20,208,230,137,5,18,26,164,54,83,3,68,71,20, +109,37,141,18,78,145,105,165,100,76,71,36,206,137,22,103,139,172,57,199,6, +158,30,71,20,117,4,74,39,54,83,37,92,129,150,199,66,200,75,34,103,40,150,9, +72,132,109,24,98,93,238,140,206,75,204,141,28,140,134,61,209,153,101,71, +146,36,109,22,178,78,52,33,74,5,200,138,67,30,178,48,141,156,146,134,204, +145,40,4,65,172,147,59,192,37,0,196,59,226,138,130,100,75,226,233,144,83, +32,204,250,5,104,17,165,48,77,2,46,16,69,140, }; #endif /* DUK_USE_ROM_STRINGS */ #if defined(DUK_USE_ROM_OBJECTS) #error ROM support not enabled, rerun configure.py with --rom-support #else /* DUK_USE_ROM_OBJECTS */ -/* native functions: 177 */ -DUK_INTERNAL const duk_c_function duk_bi_native_functions[177] = { +/* native functions: 176 */ +DUK_INTERNAL const duk_c_function duk_bi_native_functions[176] = { NULL, duk_bi_array_constructor, duk_bi_array_constructor_is_array, @@ -161,7 +157,6 @@ duk_bi_nodejs_buffer_tojson, duk_bi_nodejs_buffer_tostring, duk_bi_nodejs_buffer_write, - duk_bi_number_check_shared, duk_bi_number_constructor, duk_bi_number_prototype_to_exponential, duk_bi_number_prototype_to_fixed, @@ -248,577 +243,556 @@ duk_bi_uint8array_plainof, }; #if defined(DUK_USE_DOUBLE_LE) -DUK_INTERNAL const duk_uint8_t duk_builtins_data[4116] = { -144,148,105,224,32,68,52,228,62,12,104,200,165,132,52,167,194,138,105,243, -124,57,28,211,57,18,64,52,238,126,44,138,111,171,241,164,19,87,129,30,33, +DUK_INTERNAL const duk_uint8_t duk_builtins_data[3972] = { +144,148,105,223,160,68,52,228,62,12,104,200,165,132,52,167,194,138,105,242, +252,57,28,211,57,18,64,52,238,62,44,138,111,171,241,164,19,87,125,30,33, 167,16,145,159,8,211,136,9,225,42,5,240,145,139,163,163,8,211,136,10,228, 64,211,19,132,140,93,29,56,70,156,64,119,34,66,146,36,104,137,194,70,46, 142,172,35,78,32,47,146,195,102,11,240,145,139,163,175,8,211,136,9,228,240, 242,112,145,139,163,179,8,211,136,8,237,34,130,118,49,116,118,225,26,48,0, -1,82,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, -33,8,66,26,179,233,97,167,60,150,34,33,154,112,0,1,75,247,35,79,95,237,198, -174,200,47,31,23,95,17,13,51,19,35,93,68,216,209,128,0,10,208,174,79,15,32, -248,8,196,24,8,107,192,0,5,106,118,27,94,0,0,43,83,227,94,0,0,43,84,46,215, -128,0,10,213,28,198,188,0,0,86,169,100,53,224,0,2,181,79,85,175,0,0,21,170, -154,45,120,0,0,173,85,217,107,192,0,5,106,182,243,86,193,106,52,127,130, -249,50,94,124,35,68,225,146,49,13,31,186,23,201,146,243,224,200,39,12,145, -136,67,134,19,49,0,0,0,0,0,0,3,225,255,51,0,0,0,0,0,0,3,193,255,47,18,1, -172,19,120,71,10,25,196,136,113,162,156,136,199,42,57,204,144,115,132,240, -149,2,248,72,197,209,58,2,185,16,52,196,225,35,23,68,233,14,228,72,82,68, -141,17,56,72,197,209,58,130,249,44,54,96,191,9,24,186,39,88,79,39,135,147, -132,140,93,19,176,35,180,138,9,216,197,209,59,82,79,35,40,242,65,248,58,42, -96,121,14,232,94,62,46,190,15,42,31,145,33,86,65,76,242,214,143,73,48,242, -243,79,49,56,243,115,207,57,64,243,180,79,61,72,243,244,207,65,80,244,53, -79,69,88,244,98,30,8,200,156,67,102,120,241,79,4,100,78,21,110,4,207,32,47, -147,37,231,194,52,78,25,34,122,81,124,153,47,62,12,130,112,201,19,211,139, -121,34,87,69,128,104,137,239,83,18,238,108,165,2,162,92,104,56,220,233,1,8, -151,10,134,162,100,206,16,18,50,9,195,39,105,20,101,136,18,25,4,225,147, -180,138,5,215,49,238,105,27,60,185,1,36,104,156,50,118,145,70,96,129,34,52, -78,25,59,72,160,93,115,30,230,145,179,204,144,12,73,8,15,38,104,128,138,52, -146,16,30,77,1,0,2,11,132,193,198,36,248,248,186,110,158,30,78,56,188,194, -70,183,170,136,48,98,79,142,179,120,248,185,228,140,241,193,146,66,138,31, -55,71,138,128,153,137,62,58,205,227,226,231,146,51,199,26,6,18,92,146,64, -96,74,72,51,120,43,192,97,68,128,153,56,72,7,12,133,67,73,199,197,207,36, -103,142,35,2,3,33,80,210,113,241,115,201,25,160,146,225,160,9,34,1,124,178, -1,139,18,19,36,229,146,8,190,36,169,27,62,18,243,35,100,135,54,92,162,2,17, -46,72,128,89,7,200,32,33,18,225,98,236,145,188,130,64,196,75,132,188,200, -217,32,43,39,28,128,69,19,18,228,144,42,98,79,142,179,120,248,185,228,140, -241,201,97,129,114,229,201,37,2,68,184,200,1,147,93,159,153,213,34,235,250, -96,48,157,32,24,94,160,1,199,4,184,235,55,143,139,158,72,207,28,226,3,81, -46,62,46,155,167,135,147,142,47,60,129,71,197,207,36,103,142,34,92,35,104, -194,68,1,89,58,36,8,109,109,12,133,67,73,195,18,115,36,118,182,185,168,8, -109,109,12,133,67,73,201,18,115,36,118,182,185,168,130,27,91,75,115,149,71, -240,196,156,201,29,173,174,129,2,27,91,75,115,149,71,242,68,156,201,29,173, -174,129,34,12,16,28,128,62,191,42,3,71,146,68,4,16,22,188,161,240,16,40, -104,242,103,196,16,93,158,125,96,110,115,235,64,131,16,16,58,37,192,70,32, -194,144,114,25,67,95,40,6,18,8,32,48,156,209,2,108,124,96,224,144,6,247,62, -16,0,143,164,143,12,248,15,18,84,145,145,34,128,11,35,160,179,140,0,44,150, -129,18,58,0,146,116,103,32,128,105,61,104,17,36,175,1,232,217,29,5,156,179, -224,58,26,50,95,142,43,159,64,181,130,83,226,26,50,95,142,43,159,192,7,255, -248,41,42,72,226,1,160,18,78,97,32,26,64,114,186,60,32,4,120,6,148,13,128, -124,3,76,12,84,46,100,140,3,78,13,18,14,130,36,67,232,23,18,14,130,39,34, -131,30,113,15,224,3,255,253,6,48,40,194,197,204,224,142,8,240,78,25,60,231, -192,210,197,204,224,156,50,113,238,67,103,232,62,28,138,156,104,82,170,107, -255,32,48,191,144,1,132,112,71,128,159,168,128,161,28,17,224,156,50,112,19, -245,144,22,39,12,156,123,144,217,240,19,245,146,3,9,205,16,39,236,62,3,161, -163,37,248,226,251,141,1,107,4,167,196,52,100,191,28,95,113,164,13,91,132, -5,147,130,115,30,8,147,222,64,43,1,49,31,224,64,60,72,245,128,68,249,32,13, -34,2,34,63,204,128,89,45,2,39,209,0,89,61,104,159,213,0,153,80,50,156,80, -211,126,16,11,155,184,183,88,145,224,129,34,122,64,17,155,184,183,8,11,39, -22,235,18,60,16,36,79,72,1,115,119,40,247,146,60,16,36,79,72,32,140,221, -197,184,64,89,57,71,188,145,224,129,34,122,65,1,39,20,51,244,0,52,72,242,2, -127,18,2,165,48,70,114,229,145,51,253,141,1,4,104,229,203,34,103,251,26,64, -132,52,75,160,201,47,105,160,26,84,12,167,31,186,8,50,0,114,58,113,163,46, -190,120,35,11,60,4,25,68,81,61,96,47,181,80,46,132,129,255,255,255,255,255, -255,222,254,39,172,67,118,170,5,208,144,0,64,0,0,0,0,0,0,51,16,0,0,0,0,0,0, -62,31,200,245,238,146,38,138,147,105,13,42,26,137,226,0,0,0,0,0,0,7,131, -249,30,180,134,4,209,82,109,33,165,67,81,60,64,0,0,0,0,0,0,240,255,15,210, -62,72,91,155,0,0,0,0,0,0,2,192,240,135,88,11,237,72,5,38,210,27,50,24,145, -129,255,255,255,255,255,254,126,134,67,172,67,118,164,2,147,105,13,153,12, -72,192,255,255,255,255,255,255,63,195,16,240,70,68,226,27,51,199,138,120, -35,34,112,171,112,38,121,7,16,137,112,168,106,38,77,193,1,40,151,16,217, -144,196,142,224,144,21,18,227,65,198,238,9,67,81,46,72,5,39,16,217,144,196, -142,224,152,228,148,227,64,0,0,0,0,0,0,0,0,131,175,223,16,194,111,8,97,119, -224,3,205,220,42,46,65,238,200,13,155,184,75,189,205,35,102,128,47,116,64, -92,221,199,196,130,68,144,230,239,72,65,152,12,21,224,140,137,92,128,62, -210,98,177,252,3,107,173,88,3,146,211,141,32,0,0,0,0,0,3,225,255,19,175, -188,0,100,221,193,130,100,228,167,20,52,215,129,3,38,238,77,12,39,37,56, -161,166,188,10,194,94,6,18,155,184,183,8,11,39,6,9,147,146,156,80,211,94,7, -18,155,184,183,8,11,39,38,134,19,146,156,80,211,94,8,12,53,224,130,195,222, -8,77,133,210,24,91,224,3,152,147,228,208,194,95,0,44,196,159,11,69,175,152, -32,35,100,33,135,24,147,237,38,34,246,139,95,48,64,70,200,68,8,49,39,198, -57,179,61,144,138,22,98,79,180,152,153,215,54,103,178,17,129,204,73,240,96, -153,44,132,112,163,18,125,164,196,62,130,100,178,18,1,140,73,240,96,197, -144,146,18,98,79,180,152,135,208,98,200,74,8,49,39,195,186,145,149,144,150, -22,98,79,180,152,143,215,82,50,178,19,2,140,73,241,136,109,38,73,89,9,161, -166,36,251,73,137,157,67,105,50,74,200,78,10,49,39,201,16,78,104,229,100, -39,134,152,147,237,38,41,116,130,115,71,43,33,64,60,196,159,24,133,173,18, -32,156,209,202,200,81,18,49,39,218,76,76,234,22,180,72,130,115,71,43,33,72, -68,196,159,38,134,19,46,105,56,226,150,68,157,160,1,228,73,242,104,97,46, -16,31,34,79,140,66,214,137,16,78,104,229,108,169,137,72,147,237,38,38,117, -11,90,36,65,57,163,149,178,168,21,34,79,146,32,156,209,202,218,250,161,178, -36,251,73,138,93,32,156,209,202,218,250,193,82,36,248,196,54,147,36,173, -191,174,27,34,79,180,152,153,212,54,147,36,173,191,176,17,34,79,135,117,35, -43,115,236,133,200,147,237,38,35,245,212,140,173,207,180,15,34,79,131,4, -201,108,173,133,72,147,237,38,33,244,19,37,178,184,17,34,79,140,115,102, -123,107,238,133,200,147,237,38,38,117,205,153,237,175,188,23,34,79,133,162, -215,204,16,17,182,254,248,116,137,62,210,98,47,104,181,243,4,4,109,191,192, -131,152,147,230,8,8,217,12,16,60,137,62,96,128,141,178,193,160,206,1,201, -176,113,146,0,0,0,0,0,0,0,0,49,185,252,65,137,207,227,37,215,207,227,12,86, -127,24,152,188,254,49,88,33,46,65,120,72,4,153,37,63,33,13,127,148,4,26,0, -57,62,6,228,163,228,74,86,215,62,55,28,110,179,226,113,70,223,62,47,24,38, -191,30,2,125,32,40,20,87,114,41,225,42,5,240,145,139,163,145,41,68,250,128, -80,41,174,228,85,200,129,166,39,9,24,186,57,18,148,79,172,5,2,170,238,69, -220,137,10,72,145,162,39,9,24,186,57,18,148,79,176,5,2,186,238,69,124,150, -27,48,95,132,140,93,28,137,74,39,218,2,129,101,119,34,158,79,15,39,9,24, -186,57,18,148,79,184,5,2,218,238,69,29,164,80,78,198,46,142,68,165,16,64, -28,24,61,73,25,33,205,128,0,0,0,0,1,167,166,129,108,242,151,15,39,8,34,26, -87,97,200,3,0,167,129,32,8,194,195,16,6,84,55,10,60,3,35,69,132,30,1,140, -130,193,143,1,196,230,60,2,158,8,131,153,64,115,42,46,191,176,8,194,246,0, -80,5,220,193,95,6,234,5,100,225,35,23,71,35,6,228,140,93,29,180,55,108,145, -139,163,182,112,52,107,67,76,56,3,153,132,20,28,76,156,89,26,105,158,62,0, -0,42,193,2,201,104,17,41,34,156,204,176,160,226,100,226,200,211,76,241,240, -0,1,86,2,131,137,147,142,41,100,73,199,192,0,5,96,6,13,10,82,70,62,0,0,42, -130,88,115,18,124,67,103,177,69,49,129,6,36,249,68,54,123,20,82,216,65,137, -62,33,179,209,214,162,152,208,147,18,124,162,27,61,29,106,41,112,32,196, -159,16,217,233,233,81,76,112,73,137,62,81,13,158,158,149,20,186,20,98,79, -133,91,129,61,61,42,41,120,40,196,159,10,183,2,122,218,148,82,248,60,137, -62,33,179,216,166,216,192,137,18,124,162,27,61,138,109,108,34,68,159,16, -217,232,235,83,108,104,76,137,62,81,13,158,142,181,54,184,17,34,79,136,108, -244,244,169,182,56,38,68,159,40,134,207,79,74,155,93,10,145,39,194,173,192, -158,158,149,54,188,21,34,79,133,91,129,61,109,74,109,125,155,51,136,71,161, -196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,7,129,249,155,51,168,71, -161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,7,129,249,155,51,200, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,7,129,249,155,51, -232,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,2,1,155,52, -8,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,2,1,155,52,40, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,155,52,72, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,155,52, -104,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,155, -52,136,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,1,2,1,135, -52,166,32,76,72,1,246,136,235,103,177,69,0,136,144,3,226,27,61,138,41,44, -50,36,0,251,68,117,179,209,214,234,201,69,16,50,36,0,251,68,117,179,209, -214,232,73,69,34,5,196,128,31,16,217,232,235,117,100,162,147,2,226,64,15, -136,108,244,117,186,18,81,74,129,145,32,7,218,35,173,158,158,151,86,74,40, -161,145,32,7,218,35,173,158,158,151,66,74,41,20,46,36,0,248,134,207,79,75, -171,37,20,154,23,18,0,124,67,103,167,165,208,146,138,85,11,137,0,62,21,110, -4,250,178,81,70,11,137,0,62,21,110,4,250,18,81,72,193,145,32,7,193,186,129, -89,58,178,81,71,12,137,0,62,13,212,10,201,208,146,138,71,10,137,0,62,209, -29,108,250,178,81,104,1,81,32,7,218,35,173,159,66,74,45,32,38,36,0,248,134, -207,171,37,22,160,19,18,0,124,67,103,208,146,139,88,10,180,81,50,118,136, -235,103,177,77,128,155,69,19,39,16,217,236,83,105,97,182,138,38,78,209,29, -108,244,117,186,178,83,100,13,180,81,50,118,136,235,103,163,173,208,146, -155,68,12,180,81,50,113,13,158,142,183,86,74,109,48,50,209,68,201,196,54, -122,58,221,9,41,181,64,219,69,19,39,104,142,182,122,122,93,89,41,178,134, -218,40,153,59,68,117,179,211,210,232,73,77,162,134,90,40,153,56,134,207,79, -75,171,37,54,154,25,104,162,100,226,27,61,61,46,132,148,218,168,101,162, -137,147,133,91,129,62,172,148,217,131,45,20,76,156,42,220,9,244,36,166,209, -131,109,20,76,156,27,168,21,147,171,37,54,112,219,69,19,39,6,234,5,100,232, -73,77,163,133,218,40,153,59,68,117,179,234,201,78,32,5,218,40,153,59,68, -117,179,232,73,78,36,5,90,40,153,56,134,207,171,37,56,160,21,104,162,100, -226,27,62,132,148,226,195,95,182,97,176,218,128,8,84,45,123,38,1,137,10,1, -114,160,64,56,156,199,130,36,160,72,8,39,63,27,24,1,100,180,8,148,146,0,45, -162,137,147,111,2,8,4,16,7,8,96,120,72,13,42,226,145,97,87,224,168,1,58, -182,232,232,64,22,85,181,187,177,107,2,64,7,213,183,74,7,121,207,215,242, -17,119,49,248,94,173,198,210,36,15,232,34,182,84,113,95,115,240,221,91,141, -163,160,72,1,220,164,194,175,121,123,103,224,186,244,64,24,45,68,84,251,33, -9,64,15,217,66,51,209,218,210,129,154,118,254,205,61,65,204,126,23,178,132, -103,165,3,52,237,253,154,122,131,216,254,168,48,6,90,130,1,0,39,75,80,72,8, -9,33,186,130,80,64,76,13,212,19,2,130,96,110,150,173,0,65,6,51,212,20,128, -65,17,11,212,19,130,137,121,211,210,209,144,6,39,75,80,80,0,201,119,234,10, -8,41,86,231,71,80,80,129,79,135,186,122,69,224,34,25,69,233,80,3,91,141, -168,40,96,139,113,180,181,5,36,21,110,54,142,134,160,165,1,176,23,211,47,0, -216,134,233,215,128,111,117,181,104,128,209,3,70,230,106,64,5,139,168,209, -234,10,32,36,144,102,234,136,3,146,27,168,40,160,146,132,103,168,40,192, -115,3,117,5,28,22,113,163,69,168,41,103,1,66,188,17,145,52,40,4,202,113,67, -76,130,227,68,194,13,240,108,0,0,83,96,0,2,161,0,104,146,84,97,48,0,1,78, -192,56,169,24,145,179,192,0,5,48,8,56,16,32,128,56,18,52,125,166,86,147, -182,140,28,50,21,13,39,31,23,60,145,158,56,140,141,47,113,6,155,186,188,24, -49,39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,197,68,14,49, -39,199,197,211,116,240,242,113,197,230,18,180,253,228,3,17,46,18,243,35, -100,128,172,156,114,70,163,146,76,34,248,146,164,108,248,75,204,141,146,28, -217,114,137,27,78,251,241,173,234,162,160,225,1,3,34,92,170,9,105,164,32, -225,64,131,155,1,193,133,7,19,39,22,70,154,103,143,128,0,10,176,20,28,76, -156,113,75,34,78,62,0,0,43,0,48,104,82,146,49,240,0,1,84,11,180,192,0,5, -114,1,18,160,65,24,131,20,145,25,172,48,132,122,28,76,146,218,121,35,180, -69,145,132,108,224,0,0,0,0,0,0,120,31,153,172,56,132,122,28,76,146,218,121, -35,180,69,145,132,108,224,0,0,0,0,0,0,120,31,168,160,45,110,23,30,176,33, -184,0,0,175,32,29,235,2,27,199,23,0,0,22,4,51,88,129,8,244,56,153,37,180, -242,71,104,139,35,8,217,192,0,0,0,0,0,0,240,63,51,88,145,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,0,64,51,88,161,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,0,64,51,88,177,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64,51,88,193,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64,51,88,209,8,244,56, -153,37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64,51,88,225,8,244, -56,153,37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,32,64,32,227,194,0, -97,57,162,4,245,232,5,34,92,35,68,225,161,166,218,16,16,137,112,52,41,73, -29,153,1,65,196,201,197,145,166,153,245,200,3,137,204,120,34,74,8,200,58, -112,28,211,32,130,52,78,26,26,110,248,0,0,164,4,12,70,137,195,39,252,73, -240,117,32,57,168,97,4,104,156,52,52,221,255,160,20,160,152,23,223,250,32, -148,25,174,137,58,23,51,191,244,84,12,50,9,195,39,240,81,238,2,3,107,173, -214,3,192, +1,80,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, +33,8,66,34,33,154,112,0,1,73,247,35,79,91,237,198,174,192,47,31,23,95,17, +13,51,19,35,93,68,216,209,128,0,10,192,174,79,15,32,248,8,196,24,8,107,192, +0,5,98,118,27,94,0,0,43,19,227,94,0,0,43,20,46,215,128,0,10,197,28,198,188, +0,0,86,41,100,53,224,0,2,177,79,85,175,0,0,21,138,154,45,120,0,0,172,85, +217,107,192,0,5,98,182,243,86,193,106,52,127,66,249,50,94,124,35,68,225, +146,49,13,31,170,23,201,146,243,224,200,39,12,145,136,67,134,11,49,0,0,0,0, +0,0,3,225,255,51,0,0,0,0,0,0,3,193,255,47,18,1,172,19,120,71,10,25,196,136, +113,162,156,136,199,42,57,204,144,115,132,240,149,2,248,72,197,209,58,2, +185,16,52,196,225,35,23,68,233,14,228,72,82,68,141,17,56,72,197,209,58,130, +249,44,54,96,191,9,24,186,39,88,79,39,135,147,132,140,93,19,176,35,180,138, +9,216,197,209,59,82,79,31,40,242,1,248,58,42,96,121,14,232,94,62,46,190,15, +38,31,145,33,86,65,76,242,150,143,69,48,242,179,79,45,56,243,51,207,53,64, +243,116,79,57,72,243,180,207,61,80,243,245,79,65,88,244,34,249,50,94,124, +35,68,225,146,39,163,23,201,146,243,224,200,39,12,145,61,40,183,146,37,116, +88,6,136,158,244,241,174,230,202,80,135,130,50,39,16,217,231,208,20,240,70, +68,225,86,224,79,60,64,84,75,141,7,27,157,32,66,37,194,161,168,153,51,132, +9,25,4,225,147,180,138,50,196,18,25,4,225,147,180,138,5,215,49,238,105,27, +60,185,2,72,209,56,100,237,34,140,193,4,136,209,56,100,237,34,129,117,204, +123,154,70,207,50,64,98,72,64,121,51,68,8,163,73,33,1,228,208,16,0,65,112, +152,56,196,159,31,23,77,211,195,201,199,23,150,73,169,234,34,24,49,39,199, +89,188,124,92,242,70,120,224,201,33,69,15,155,163,196,64,153,137,62,58,205, +227,226,231,146,51,199,26,6,18,92,130,64,192,148,144,102,240,23,129,133,18, +2,100,224,160,56,100,42,26,78,62,46,121,35,60,112,216,32,50,21,13,39,31,23, +60,145,154,9,46,18,1,36,64,47,148,64,98,196,132,201,57,68,132,95,18,84,141, +159,9,121,145,178,67,155,46,73,2,17,46,72,128,89,7,199,32,66,37,194,197, +217,35,120,228,131,17,46,18,243,35,100,128,172,156,98,2,40,152,151,32,130, +166,36,248,235,55,143,139,158,72,207,28,150,24,23,46,92,130,80,72,151,21,0, +100,213,103,229,245,8,186,190,144,24,78,136,24,94,152,3,142,9,113,214,111, +31,23,60,145,158,57,164,13,68,184,248,186,110,158,30,78,56,188,226,10,62, +46,121,35,60,113,18,225,27,70,18,32,10,201,208,32,134,214,208,200,84,52, +156,49,39,50,71,107,107,152,129,13,173,161,144,168,105,57,34,78,100,142, +214,215,49,16,134,214,210,220,229,81,252,49,39,50,71,107,107,158,65,13,173, +165,185,202,163,249,34,78,100,142,214,215,60,146,12,16,28,128,62,175,42,6, +143,36,136,16,64,90,242,135,192,129,67,71,147,62,65,5,215,231,214,6,215,62, +180,8,49,1,3,162,92,4,98,12,41,14,67,40,106,229,1,132,130,8,24,78,104,129, +54,62,96,224,144,13,238,124,32,2,62,146,60,51,224,120,146,164,140,137,20,0, +178,58,11,56,192,5,146,208,34,71,64,36,157,25,200,32,52,158,180,8,146,87, +129,232,217,29,5,156,179,224,116,52,100,191,28,87,62,130,214,9,79,136,104, +201,126,56,174,127,0,31,255,225,73,82,71,16,13,1,36,230,18,1,164,14,87,71, +132,0,143,0,210,131,96,31,0,211,6,42,23,50,70,1,167,13,18,14,130,36,67,232, +46,36,29,4,78,69,6,60,226,31,192,7,255,252,24,192,163,11,23,51,130,56,35, +193,56,100,243,31,6,150,46,103,4,225,147,143,114,27,63,57,241,200,169,194, +133,42,166,175,240,6,23,240,0,97,28,17,224,39,233,32,80,142,8,240,78,25,56, +9,250,136,22,39,12,156,123,144,217,240,19,245,18,6,19,154,32,79,214,124,14, +134,140,151,227,139,237,52,11,88,37,62,33,163,37,248,226,251,77,32,213,184, +64,89,56,39,49,224,137,61,196,5,96,38,35,251,200,15,18,61,96,17,62,40,6, +145,1,17,31,228,64,89,45,2,39,205,0,178,122,209,63,162,2,101,64,202,113,67, +77,247,64,92,221,197,186,196,143,4,9,19,208,1,25,187,139,112,128,178,113, +110,177,35,193,2,68,244,0,46,110,229,30,242,71,130,4,137,232,4,35,55,113, +110,16,22,78,81,239,36,120,32,72,158,128,64,147,138,25,249,0,52,72,242,2, +127,2,5,74,96,140,229,203,34,103,250,154,4,17,163,151,44,137,159,234,105,4, +33,162,93,6,73,123,13,1,165,64,202,113,251,33,6,64,14,71,78,20,101,213,207, +4,194,207,2,12,162,0,158,176,23,218,168,23,66,64,255,255,255,255,255,255, +239,127,19,214,33,187,85,2,232,72,0,32,0,0,0,0,0,0,25,136,0,0,0,0,0,0,31, +15,228,122,247,73,19,69,73,180,134,149,13,68,241,0,0,0,0,0,0,3,193,252,143, +90,67,2,104,169,54,144,210,161,168,158,32,0,0,0,0,0,0,120,127,142,73,78,20, +0,0,0,0,0,0,0,0,8,58,189,233,24,77,217,24,93,240,1,230,238,21,23,32,247,68, +13,155,184,75,189,205,35,102,128,47,114,64,185,187,143,137,4,137,33,205, +222,17,6,96,48,87,130,50,37,114,1,246,147,21,143,224,54,186,213,128,114,90, +112,164,0,0,0,0,0,0,124,63,226,117,119,128,25,55,112,96,153,57,41,197,13, +53,224,65,147,119,38,134,19,146,156,80,211,94,5,194,94,6,37,55,113,110,16, +22,78,12,19,39,37,56,161,166,188,14,74,110,226,220,32,44,156,154,24,78,74, +113,67,77,120,32,97,175,4,28,61,224,133,172,186,70,22,248,1,204,73,242,104, +97,47,128,44,196,159,11,69,175,152,32,35,100,33,142,49,39,218,76,69,237,22, +190,96,128,141,144,136,32,196,159,24,230,204,246,66,40,179,18,125,164,196, +206,185,179,61,144,140,28,196,159,6,9,146,200,71,20,98,79,180,152,135,208, +76,150,66,64,99,18,124,24,49,100,36,137,49,39,218,76,67,232,49,100,37,8,49, +39,195,186,145,149,144,150,44,196,159,105,49,31,174,164,101,100,38,10,49, +39,198,33,180,153,37,100,38,141,49,39,218,76,76,234,27,73,146,86,66,112, +163,18,124,145,4,230,142,86,66,120,211,18,125,164,197,46,144,78,104,229, +100,40,15,49,39,198,33,107,68,136,39,52,114,178,20,73,24,147,237,38,38,117, +11,90,36,65,57,163,149,144,164,68,196,159,38,134,19,46,105,56,226,150,68, +157,160,3,200,147,228,208,194,92,32,124,137,62,49,11,90,36,65,57,163,149, +178,166,74,68,159,105,49,51,168,90,209,34,9,205,28,173,149,65,82,36,249,34, +9,205,28,173,175,170,54,68,159,105,49,75,164,19,154,57,91,95,88,84,137,62, +49,13,164,201,43,111,235,141,145,39,218,76,76,234,27,73,146,86,223,216,17, +34,79,135,117,35,43,115,236,139,145,39,218,76,71,235,169,25,91,159,104,60, +137,62,12,19,37,178,182,42,68,159,105,49,15,160,153,45,149,193,18,36,248, +199,54,103,182,190,232,185,18,125,164,196,206,185,179,61,181,247,133,200, +147,225,104,181,243,4,4,109,191,190,58,68,159,105,49,23,180,90,249,130,2, +54,223,224,67,152,147,230,8,8,217,12,16,121,18,124,193,1,27,101,131,131,56, +7,38,193,198,72,0,0,0,0,0,0,0,0,198,231,240,134,39,63,136,151,95,63,136,49, +89,252,66,98,243,248,133,96,132,185,5,224,32,36,201,41,248,200,213,249,0, +131,64,7,39,192,218,148,124,137,74,216,231,198,227,141,182,124,78,40,217, +231,197,227,4,213,227,192,159,72,10,5,21,218,138,120,74,129,124,36,98,232, +228,74,81,62,160,20,10,107,181,21,114,32,105,137,194,70,46,142,68,165,19, +235,1,64,170,187,81,119,34,66,146,36,104,137,194,70,46,142,68,165,19,236,1, +64,174,187,81,95,37,134,204,23,225,35,23,71,34,82,137,246,128,160,89,93, +168,167,147,195,201,194,70,46,142,68,165,19,238,1,64,182,187,81,71,105,20, +19,177,139,163,145,41,68,16,7,6,15,82,70,72,115,96,0,0,0,0,0,93,105,160,91, +60,149,195,200,194,8,134,149,216,114,1,128,83,192,144,8,194,195,16,12,168, +110,20,120,12,141,22,16,120,12,100,22,12,120,28,78,99,192,41,224,136,115, +36,14,100,197,213,245,193,48,189,112,40,2,237,96,175,131,117,2,178,112,145, +139,163,145,131,114,70,46,142,218,27,182,72,197,209,219,56,26,53,161,166, +28,1,204,178,10,14,38,78,44,141,52,207,31,0,0,21,64,129,100,180,8,148,145, +92,203,176,160,226,100,226,200,211,76,241,240,0,1,84,2,131,137,147,142,41, +100,73,199,192,0,5,88,6,13,10,82,70,62,0,0,42,66,88,115,18,124,67,103,177, +69,49,130,12,73,242,136,108,246,40,165,177,6,36,248,134,207,71,90,138,99, +68,152,147,229,16,217,232,235,81,75,130,12,73,241,13,158,158,149,20,199,9, +49,39,202,33,179,211,210,162,151,69,24,147,225,86,224,79,79,74,138,94,20, +98,79,133,91,129,61,109,74,41,124,60,137,62,33,179,216,166,216,193,18,36, +249,68,54,123,20,218,216,137,18,124,67,103,163,173,77,177,162,100,73,242, +136,108,244,117,169,181,193,18,36,248,134,207,79,74,155,99,132,200,147,229, +16,217,233,233,83,107,162,164,73,240,171,112,39,167,165,77,175,10,145,39, +194,173,192,158,182,165,54,191,153,51,72,71,161,196,201,45,167,146,59,68, +89,24,70,206,0,0,0,0,0,0,7,129,249,153,51,104,71,161,196,201,45,167,146,59, +68,89,24,70,206,0,0,0,0,0,0,7,129,249,153,51,136,71,161,196,201,45,167,146, +59,68,89,24,70,206,0,0,0,0,0,0,7,129,249,153,51,168,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,2,1,153,51,200,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,2,1,153,51,232,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,153,52,8,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,153,52,40,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,0,130,1,153,52,72,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,0,0,0,1,2,1,135,52,102,32,76,72,1,246,136,235, +103,177,69,1,17,32,7,196,54,123,20,82,88,200,144,3,237,17,214,207,71,91, +171,37,20,65,145,32,7,218,35,173,158,142,183,66,74,41,16,92,72,1,241,13, +158,142,183,86,74,41,48,92,72,1,241,13,158,142,183,66,74,41,80,100,72,1, +246,136,235,103,167,165,213,146,138,40,200,144,3,237,17,214,207,79,75,161, +37,20,138,46,36,0,248,134,207,79,75,171,37,20,154,46,36,0,248,134,207,79, +75,161,37,20,170,46,36,0,248,85,184,19,234,201,69,24,92,72,1,240,171,112, +39,208,146,138,70,25,18,0,124,27,168,21,147,171,37,20,113,145,32,7,193,186, +129,89,58,18,81,72,226,162,64,15,180,71,91,62,172,148,90,0,168,144,3,237, +17,214,207,161,37,22,144,38,36,0,248,134,207,171,37,22,160,38,36,0,248,134, +207,161,37,22,176,42,209,68,201,218,35,173,158,197,54,4,218,40,153,56,134, +207,98,155,75,27,104,162,100,237,17,214,207,71,91,171,37,54,65,182,138,38, +78,209,29,108,244,117,186,18,83,104,131,45,20,76,156,67,103,163,173,213, +146,155,76,25,104,162,100,226,27,61,29,110,132,148,218,160,219,69,19,39, +104,142,182,122,122,93,89,41,178,141,180,81,50,118,136,235,103,167,165,208, +146,155,69,25,104,162,100,226,27,61,61,46,172,148,218,104,203,69,19,39,16, +217,233,233,116,36,166,213,70,90,40,153,56,85,184,19,234,201,77,152,101, +162,137,147,133,91,129,62,132,148,218,48,219,69,19,39,6,234,5,100,234,201, +77,156,109,162,137,147,131,117,2,178,116,36,166,209,197,218,40,153,59,68, +117,179,234,201,78,32,11,180,81,50,118,136,235,103,208,146,156,72,21,104, +162,100,226,27,62,172,148,226,128,171,69,19,39,16,217,244,36,167,22,53,123, +102,53,155,80,2,21,11,94,201,128,196,133,0,185,80,32,56,156,199,130,36,160, +72,16,78,126,54,48,5,146,208,34,82,72,1,109,20,76,155,120,28,34,1,225,32, +52,171,138,69,133,95,130,160,4,234,219,163,161,0,89,86,214,238,197,172,9,0, +31,86,221,40,29,231,63,95,200,69,220,199,225,122,183,27,72,144,63,160,138, +217,81,197,125,207,195,117,110,54,142,129,32,7,114,147,10,189,229,237,159, +130,235,209,0,96,181,17,83,236,132,37,0,63,101,8,207,71,107,74,6,105,219, +251,52,245,7,49,248,94,202,17,158,148,12,211,183,246,105,234,15,99,242,159, +129,228,176,192,185,127,46,155,185,41,197,13,55,38,3,127,255,20,138,160, +192,25,106,8,8,1,58,90,130,64,128,146,27,168,37,8,9,129,186,130,96,160,152, +27,165,171,64,32,131,25,234,10,64,65,17,11,212,19,133,18,243,167,165,163, +32,24,157,45,65,64,6,75,191,80,80,66,149,110,116,117,5,8,41,240,247,79,72, +188,8,134,81,122,84,1,173,198,212,20,48,139,113,180,181,5,36,42,220,109,29, +13,65,74,6,192,95,76,188,6,196,55,78,188,6,247,91,86,136,26,32,104,220,205, +72,1,98,234,52,122,130,136,18,72,51,117,68,3,146,27,168,40,161,37,8,207,80, +81,129,204,13,212,20,112,179,141,26,45,65,75,112,20,43,193,25,19,66,128, +153,78,40,105,144,92,104,152,131,124,27,253,128,0,10,116,3,68,146,163,9, +128,0,10,102,3,138,145,137,27,60,0,0,82,129,7,2,4,16,7,2,70,143,178,203, +164,237,35,14,25,10,134,147,143,139,158,72,207,28,54,77,47,109,13,55,113, +120,96,196,159,29,102,241,241,115,201,25,227,131,36,133,20,62,110,143,17, +16,113,137,62,62,46,155,167,135,147,142,47,44,151,79,221,64,98,37,194,94, +100,108,144,21,147,140,73,168,228,19,17,124,73,82,54,124,37,230,70,201,14, +108,185,36,155,14,243,243,83,212,69,131,132,4,12,137,114,168,37,166,145,7, +10,4,28,200,14,12,40,56,153,56,178,52,211,60,124,0,0,85,0,160,226,100,227, +138,89,18,113,240,0,1,86,1,131,66,148,145,143,128,0,10,144,93,134,0,0,43, +80,17,42,4,17,136,49,73,19,49,134,16,143,67,137,146,91,79,36,118,136,178, +48,141,156,0,0,0,0,0,0,15,3,243,49,135,16,143,67,137,146,91,79,36,118,136, +178,48,141,156,0,0,0,0,0,0,15,3,245,20,5,173,194,227,214,4,55,0,0,21,196,7, +122,192,134,241,197,192,0,5,121,25,140,64,132,122,28,76,146,218,121,35,180, +69,145,132,108,224,0,0,0,0,0,0,120,31,153,140,72,132,122,28,76,146,218,121, +35,180,69,145,132,108,224,0,0,0,0,0,0,0,32,25,140,80,132,122,28,76,146,218, +121,35,180,69,145,132,108,224,0,0,0,0,0,0,0,32,25,140,88,132,122,28,76,146, +218,121,35,180,69,145,132,108,224,0,0,0,0,0,0,8,32,25,140,96,132,122,28,76, +146,218,121,35,180,69,145,132,108,224,0,0,0,0,0,0,8,32,25,140,104,132,122, +28,76,146,218,121,35,180,69,145,132,108,224,0,0,0,0,0,0,8,32,25,140,112, +132,122,28,76,146,218,121,35,180,69,145,132,108,224,0,0,0,0,0,0,16,32,16, +113,225,0,48,156,209,2,122,244,5,34,92,35,68,225,161,166,218,16,33,18,224, +104,82,146,59,50,5,7,19,39,22,70,154,103,215,32,28,78,99,193,18,80,70,131, +165,1,205,34,8,35,68,225,161,166,239,255,4,12,70,137,195,39,248,73,7,78,3, +154,102,16,70,137,195,67,77,223,248,1,74,9,129,125,255,130,9,65,154,232, +147,161,115,59,255,5,64,195,32,156,50,126,197,14,2,3,107,173,213,0, }; #elif defined(DUK_USE_DOUBLE_BE) -DUK_INTERNAL const duk_uint8_t duk_builtins_data[4116] = { -144,148,105,224,32,68,52,228,62,12,104,200,165,132,52,167,194,138,105,243, -124,57,28,211,57,18,64,52,238,126,44,138,111,171,241,164,19,87,129,30,33, +DUK_INTERNAL const duk_uint8_t duk_builtins_data[3972] = { +144,148,105,223,160,68,52,228,62,12,104,200,165,132,52,167,194,138,105,242, +252,57,28,211,57,18,64,52,238,62,44,138,111,171,241,164,19,87,125,30,33, 167,16,145,159,8,211,136,9,225,42,5,240,145,139,163,163,8,211,136,10,228, 64,211,19,132,140,93,29,56,70,156,64,119,34,66,146,36,104,137,194,70,46, 142,172,35,78,32,47,146,195,102,11,240,145,139,163,175,8,211,136,9,228,240, 242,112,145,139,163,179,8,211,136,8,237,34,130,118,49,116,118,225,26,48,0, -1,82,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, -33,8,66,26,179,233,97,167,60,150,34,33,154,112,0,1,75,247,35,79,95,237,198, -174,200,47,31,23,95,17,13,51,19,35,93,68,216,209,128,0,10,208,174,79,15,32, -248,8,196,24,8,107,192,0,5,106,118,27,94,0,0,43,83,227,94,0,0,43,84,46,215, -128,0,10,213,28,198,188,0,0,86,169,100,53,224,0,2,181,79,85,175,0,0,21,170, -154,45,120,0,0,173,85,217,107,192,0,5,106,182,243,86,193,106,52,127,130, -249,50,94,124,35,68,225,146,49,13,31,186,23,201,146,243,224,200,39,12,145, -136,67,134,19,49,1,255,224,0,0,0,0,0,3,51,1,255,192,0,0,0,0,0,3,47,18,1, -172,19,120,71,10,25,196,136,113,162,156,136,199,42,57,204,144,115,132,240, -149,2,248,72,197,209,58,2,185,16,52,196,225,35,23,68,233,14,228,72,82,68, -141,17,56,72,197,209,58,130,249,44,54,96,191,9,24,186,39,88,79,39,135,147, -132,140,93,19,176,35,180,138,9,216,197,209,59,82,79,35,40,242,65,248,58,42, -96,121,14,232,94,62,46,190,15,42,31,145,33,86,65,76,242,214,143,73,48,242, -243,79,49,56,243,115,207,57,64,243,180,79,61,72,243,244,207,65,80,244,53, -79,69,88,244,98,30,8,200,156,67,102,120,241,79,4,100,78,21,110,4,207,32,47, -147,37,231,194,52,78,25,34,122,81,124,153,47,62,12,130,112,201,19,211,139, -121,34,87,69,128,104,137,239,83,18,238,108,165,2,162,92,104,56,220,233,1,8, -151,10,134,162,100,206,16,18,50,9,195,39,105,20,101,136,18,25,4,225,147, -180,138,5,215,49,238,105,27,60,185,1,36,104,156,50,118,145,70,96,129,34,52, -78,25,59,72,160,93,115,30,230,145,179,204,144,12,73,8,15,38,104,128,138,52, -146,16,30,77,1,0,2,11,132,193,198,36,248,248,186,110,158,30,78,56,188,194, -70,183,170,136,48,98,79,142,179,120,248,185,228,140,241,193,146,66,138,31, -55,71,138,128,153,137,62,58,205,227,226,231,146,51,199,26,6,18,92,146,64, -96,74,72,51,120,43,192,97,68,128,153,56,72,7,12,133,67,73,199,197,207,36, -103,142,35,2,3,33,80,210,113,241,115,201,25,160,146,225,160,9,34,1,124,178, -1,139,18,19,36,229,146,8,190,36,169,27,62,18,243,35,100,135,54,92,162,2,17, -46,72,128,89,7,200,32,33,18,225,98,236,145,188,130,64,196,75,132,188,200, -217,32,43,39,28,128,69,19,18,228,144,42,98,79,142,179,120,248,185,228,140, -241,201,97,129,114,229,201,37,2,68,184,200,1,147,93,159,153,213,34,235,250, -96,48,157,32,24,94,160,1,199,4,184,235,55,143,139,158,72,207,28,226,3,81, -46,62,46,155,167,135,147,142,47,60,129,71,197,207,36,103,142,34,92,35,104, -194,68,1,89,58,36,8,109,109,12,133,67,73,195,18,115,36,118,182,185,168,8, -109,109,12,133,67,73,201,18,115,36,118,182,185,168,130,27,91,75,115,149,71, -240,196,156,201,29,173,174,129,2,27,91,75,115,149,71,242,68,156,201,29,173, -174,129,34,12,16,28,128,62,191,42,3,71,146,68,4,16,22,188,161,240,16,40, -104,242,103,196,16,93,158,125,96,110,115,235,64,131,16,16,58,37,192,70,32, -194,144,114,25,67,95,40,6,18,8,32,48,156,209,2,108,124,96,224,144,6,247,62, -16,0,143,164,143,12,248,15,18,84,145,145,34,128,11,35,160,179,140,0,44,150, -129,18,58,0,146,116,103,32,128,105,61,104,17,36,175,1,232,217,29,5,156,179, -224,58,26,50,95,142,43,159,64,181,130,83,226,26,50,95,142,43,159,192,7,255, -248,41,42,72,226,1,160,18,78,97,32,26,64,114,186,60,32,4,120,6,148,13,128, -124,3,76,12,84,46,100,140,3,78,13,18,14,130,36,67,232,23,18,14,130,39,34, -131,30,113,15,224,3,255,253,6,48,40,194,197,204,224,142,8,240,78,25,60,231, -192,210,197,204,224,156,50,113,238,67,103,232,62,28,138,156,104,82,170,107, -255,32,48,191,144,1,132,112,71,128,159,168,128,161,28,17,224,156,50,112,19, -245,144,22,39,12,156,123,144,217,240,19,245,146,3,9,205,16,39,236,62,3,161, -163,37,248,226,251,141,1,107,4,167,196,52,100,191,28,95,113,164,13,91,132, -5,147,130,115,30,8,147,222,64,43,1,49,31,224,64,60,72,245,128,68,249,32,13, -34,2,34,63,204,128,89,45,2,39,209,0,89,61,104,159,213,0,153,80,50,156,80, -211,126,16,11,155,184,183,88,145,224,129,34,122,64,17,155,184,183,8,11,39, -22,235,18,60,16,36,79,72,1,115,119,40,247,146,60,16,36,79,72,32,140,221, -197,184,64,89,57,71,188,145,224,129,34,122,65,1,39,20,51,244,0,52,72,242,2, -127,18,2,165,48,70,114,229,145,51,253,141,1,4,104,229,203,34,103,251,26,64, -132,52,75,160,201,47,105,160,26,84,12,167,31,186,8,50,0,114,58,113,163,46, -190,120,35,11,60,4,25,68,81,61,96,47,181,80,46,132,128,255,223,255,255,255, -255,255,254,39,172,67,118,170,5,208,144,0,0,0,0,0,0,0,0,115,16,31,254,0,0, -0,0,0,0,8,245,238,146,38,138,147,105,13,42,26,137,226,3,255,128,0,0,0,0,0, -1,30,180,134,4,209,82,109,33,165,67,81,60,64,255,240,0,0,0,0,0,0,15,210,62, -72,91,155,0,242,192,0,0,0,0,0,0,135,88,11,237,72,5,38,210,27,50,24,145,128, -134,127,255,255,255,255,255,254,67,172,67,118,164,2,147,105,13,153,12,72, -192,195,63,255,255,255,255,255,255,16,240,70,68,226,27,51,199,138,120,35, -34,112,171,112,38,121,7,16,137,112,168,106,38,77,193,1,40,151,16,217,144, -196,142,224,144,21,18,227,65,198,238,9,67,81,46,72,5,39,16,217,144,196,142, -224,152,228,148,227,64,0,0,0,0,0,0,0,0,131,175,223,16,194,111,8,97,119,224, -3,205,220,42,46,65,238,200,13,155,184,75,189,205,35,102,128,47,116,64,92, -221,199,196,130,68,144,230,239,72,65,152,12,21,224,140,137,92,128,62,210, -98,177,252,3,107,173,88,3,146,211,141,33,255,224,0,0,0,0,0,3,19,175,188,0, -100,221,193,130,100,228,167,20,52,215,129,3,38,238,77,12,39,37,56,161,166, -188,10,194,94,6,18,155,184,183,8,11,39,6,9,147,146,156,80,211,94,7,18,155, -184,183,8,11,39,38,134,19,146,156,80,211,94,8,12,53,224,130,195,222,8,77, -133,210,24,91,224,3,152,147,228,208,194,95,0,44,196,159,11,69,175,152,32, -35,100,33,135,24,147,237,38,34,246,139,95,48,64,70,200,68,8,49,39,198,57, -179,61,144,138,22,98,79,180,152,153,215,54,103,178,17,129,204,73,240,96, -153,44,132,112,163,18,125,164,196,62,130,100,178,18,1,140,73,240,96,197, -144,146,18,98,79,180,152,135,208,98,200,74,8,49,39,195,186,145,149,144,150, -22,98,79,180,152,143,215,82,50,178,19,2,140,73,241,136,109,38,73,89,9,161, -166,36,251,73,137,157,67,105,50,74,200,78,10,49,39,201,16,78,104,229,100, -39,134,152,147,237,38,41,116,130,115,71,43,33,64,60,196,159,24,133,173,18, -32,156,209,202,200,81,18,49,39,218,76,76,234,22,180,72,130,115,71,43,33,72, -68,196,159,38,134,19,46,105,56,226,150,68,157,160,1,228,73,242,104,97,46, -16,31,34,79,140,66,214,137,16,78,104,229,108,169,137,72,147,237,38,38,117, -11,90,36,65,57,163,149,178,168,21,34,79,146,32,156,209,202,218,250,161,178, -36,251,73,138,93,32,156,209,202,218,250,193,82,36,248,196,54,147,36,173, -191,174,27,34,79,180,152,153,212,54,147,36,173,191,176,17,34,79,135,117,35, -43,115,236,133,200,147,237,38,35,245,212,140,173,207,180,15,34,79,131,4, -201,108,173,133,72,147,237,38,33,244,19,37,178,184,17,34,79,140,115,102, -123,107,238,133,200,147,237,38,38,117,205,153,237,175,188,23,34,79,133,162, -215,204,16,17,182,254,248,116,137,62,210,98,47,104,181,243,4,4,109,191,192, -131,152,147,230,8,8,217,12,16,60,137,62,96,128,141,178,193,160,206,1,201, -176,113,146,0,0,0,0,0,0,0,0,49,185,252,65,137,207,227,37,215,207,227,12,86, -127,24,152,188,254,49,88,33,46,65,120,72,4,153,37,63,33,13,127,148,4,26,0, -57,62,6,228,163,228,74,86,215,62,55,28,110,179,226,113,70,223,62,47,24,38, -191,30,2,125,32,40,20,87,114,41,225,42,5,240,145,139,163,145,41,68,250,128, -80,41,174,228,85,200,129,166,39,9,24,186,57,18,148,79,172,5,2,170,238,69, -220,137,10,72,145,162,39,9,24,186,57,18,148,79,176,5,2,186,238,69,124,150, -27,48,95,132,140,93,28,137,74,39,218,2,129,101,119,34,158,79,15,39,9,24, -186,57,18,148,79,184,5,2,218,238,69,29,164,80,78,198,46,142,68,165,16,64, -28,24,61,73,25,33,205,128,129,167,166,0,0,0,0,1,108,242,151,15,39,8,34,26, -87,97,200,3,0,167,129,32,8,194,195,16,6,84,55,10,60,3,35,69,132,30,1,140, -130,193,143,1,196,230,60,2,158,8,131,153,64,115,42,46,191,176,8,194,246,0, -80,5,220,193,95,6,234,5,100,225,35,23,71,35,6,228,140,93,29,180,55,108,145, -139,163,182,112,52,107,67,76,56,3,153,132,20,28,76,156,89,26,105,158,62,0, -0,42,193,2,201,104,17,41,34,156,204,176,160,226,100,226,200,211,76,241,240, -0,1,86,2,131,137,147,142,41,100,73,199,192,0,5,96,6,13,10,82,70,62,0,0,42, -130,88,115,18,124,67,103,177,69,49,129,6,36,249,68,54,123,20,82,216,65,137, -62,33,179,209,214,162,152,208,147,18,124,162,27,61,29,106,41,112,32,196, -159,16,217,233,233,81,76,112,73,137,62,81,13,158,158,149,20,186,20,98,79, -133,91,129,61,61,42,41,120,40,196,159,10,183,2,122,218,148,82,248,60,137, -62,33,179,216,166,216,192,137,18,124,162,27,61,138,109,108,34,68,159,16, -217,232,235,83,108,104,76,137,62,81,13,158,142,181,54,184,17,34,79,136,108, -244,244,169,182,56,38,68,159,40,134,207,79,74,155,93,10,145,39,194,173,192, -158,158,149,54,188,21,34,79,133,91,129,61,109,74,109,125,155,51,136,71,161, -196,201,45,167,146,59,68,89,24,70,206,1,255,128,0,0,0,0,0,1,155,51,168,71, -161,196,201,45,167,146,59,68,89,24,70,206,1,255,128,0,0,0,0,0,1,155,51,200, -71,161,196,201,45,167,146,59,68,89,24,70,206,1,255,128,0,0,0,0,0,1,155,51, -232,71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,0,0,0,0,0,0,1,155,52, -8,71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,0,0,0,0,0,0,1,155,52,40, -71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,128,0,0,0,0,0,1,155,52,72, -71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,128,0,0,0,0,0,1,155,52, -104,71,161,196,201,45,167,146,59,68,89,24,70,206,2,0,128,0,0,0,0,0,1,155, -52,136,71,161,196,201,45,167,146,59,68,89,24,70,206,2,1,0,0,0,0,0,0,1,135, -52,166,32,76,72,1,246,136,235,103,177,69,0,136,144,3,226,27,61,138,41,44, -50,36,0,251,68,117,179,209,214,234,201,69,16,50,36,0,251,68,117,179,209, -214,232,73,69,34,5,196,128,31,16,217,232,235,117,100,162,147,2,226,64,15, -136,108,244,117,186,18,81,74,129,145,32,7,218,35,173,158,158,151,86,74,40, -161,145,32,7,218,35,173,158,158,151,66,74,41,20,46,36,0,248,134,207,79,75, -171,37,20,154,23,18,0,124,67,103,167,165,208,146,138,85,11,137,0,62,21,110, -4,250,178,81,70,11,137,0,62,21,110,4,250,18,81,72,193,145,32,7,193,186,129, -89,58,178,81,71,12,137,0,62,13,212,10,201,208,146,138,71,10,137,0,62,209, -29,108,250,178,81,104,1,81,32,7,218,35,173,159,66,74,45,32,38,36,0,248,134, -207,171,37,22,160,19,18,0,124,67,103,208,146,139,88,10,180,81,50,118,136, -235,103,177,77,128,155,69,19,39,16,217,236,83,105,97,182,138,38,78,209,29, -108,244,117,186,178,83,100,13,180,81,50,118,136,235,103,163,173,208,146, -155,68,12,180,81,50,113,13,158,142,183,86,74,109,48,50,209,68,201,196,54, -122,58,221,9,41,181,64,219,69,19,39,104,142,182,122,122,93,89,41,178,134, -218,40,153,59,68,117,179,211,210,232,73,77,162,134,90,40,153,56,134,207,79, -75,171,37,54,154,25,104,162,100,226,27,61,61,46,132,148,218,168,101,162, -137,147,133,91,129,62,172,148,217,131,45,20,76,156,42,220,9,244,36,166,209, -131,109,20,76,156,27,168,21,147,171,37,54,112,219,69,19,39,6,234,5,100,232, -73,77,163,133,218,40,153,59,68,117,179,234,201,78,32,5,218,40,153,59,68, -117,179,232,73,78,36,5,90,40,153,56,134,207,171,37,56,160,21,104,162,100, -226,27,62,132,148,226,195,95,182,97,176,218,128,8,84,45,123,38,1,137,10,1, -114,160,64,56,156,199,130,36,160,72,8,39,63,27,24,1,100,180,8,148,146,0,45, -162,137,147,111,2,8,4,16,7,8,96,120,72,8,0,183,225,81,98,138,237,33,58,182, -232,232,64,64,2,107,177,187,181,85,22,7,213,183,74,1,255,49,114,23,247,209, -207,120,94,173,198,210,36,3,255,113,84,118,82,184,47,224,221,91,141,163, -160,72,7,251,121,111,98,164,220,161,192,186,244,64,64,9,33,251,84,68,45,24, -15,217,66,51,209,218,210,128,127,205,65,60,204,254,119,154,23,178,132,103, -165,0,255,218,130,121,153,252,239,54,168,48,6,90,130,1,0,39,75,80,72,8,9, -33,186,130,80,64,76,13,212,19,2,130,96,110,150,173,0,65,6,51,212,20,128,65, -17,11,212,19,130,137,121,211,210,209,144,6,39,75,80,80,0,201,119,234,10,8, -41,86,231,71,80,80,129,79,135,186,122,69,224,34,25,69,233,80,3,91,141,168, -40,96,139,113,180,181,5,36,21,110,54,142,134,160,165,1,176,23,211,47,0,216, -134,233,215,128,111,117,181,104,128,209,3,70,230,106,64,5,139,168,209,234, -10,32,36,144,102,234,136,3,146,27,168,40,160,146,132,103,168,40,192,115,3, -117,5,28,22,113,163,69,168,41,103,1,66,188,17,145,52,40,4,202,113,67,76, -130,227,68,194,13,240,108,0,0,83,96,0,2,161,0,104,146,84,97,48,0,1,78,192, -56,169,24,145,179,192,0,5,48,8,56,16,32,128,56,18,52,125,166,86,147,182, -140,28,50,21,13,39,31,23,60,145,158,56,140,141,47,113,6,155,186,188,24,49, -39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,197,68,14,49,39, -199,197,211,116,240,242,113,197,230,18,180,253,228,3,17,46,18,243,35,100, -128,172,156,114,70,163,146,76,34,248,146,164,108,248,75,204,141,146,28,217, -114,137,27,78,251,241,173,234,162,160,225,1,3,34,92,170,9,105,164,32,225, -64,131,155,1,193,133,7,19,39,22,70,154,103,143,128,0,10,176,20,28,76,156, -113,75,34,78,62,0,0,43,0,48,104,82,146,49,240,0,1,84,11,180,192,0,5,114,1, -18,160,65,24,131,20,145,25,172,48,132,122,28,76,146,218,121,35,180,69,145, -132,108,224,31,248,0,0,0,0,0,0,25,172,56,132,122,28,76,146,218,121,35,180, -69,145,132,108,224,31,248,0,0,0,0,0,0,40,160,45,110,23,30,176,33,184,0,0, -175,32,29,235,2,27,199,23,0,0,22,4,51,88,129,8,244,56,153,37,180,242,71, -104,139,35,8,217,192,63,240,0,0,0,0,0,0,51,88,145,8,244,56,153,37,180,242, -71,104,139,35,8,217,192,64,0,0,0,0,0,0,0,51,88,161,8,244,56,153,37,180,242, -71,104,139,35,8,217,192,64,0,0,0,0,0,0,0,51,88,177,8,244,56,153,37,180,242, -71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51,88,193,8,244,56,153,37,180, -242,71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51,88,209,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51,88,225,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,64,32,0,0,0,0,0,0,32,227,194,0,97,57, -162,4,245,232,5,34,92,35,68,225,161,166,218,16,16,137,112,52,41,73,29,153, -1,65,196,201,197,145,166,153,245,200,3,137,204,120,34,74,8,200,58,112,28, -211,32,130,52,78,26,26,110,248,0,0,164,4,12,70,137,195,39,252,73,240,117, -32,57,168,97,4,104,156,52,52,221,255,160,20,160,152,23,223,250,32,148,25, -174,137,58,23,51,191,244,84,12,50,9,195,39,240,81,238,2,3,107,173,214,3, -192, +1,80,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, +33,8,66,34,33,154,112,0,1,73,247,35,79,91,237,198,174,192,47,31,23,95,17, +13,51,19,35,93,68,216,209,128,0,10,192,174,79,15,32,248,8,196,24,8,107,192, +0,5,98,118,27,94,0,0,43,19,227,94,0,0,43,20,46,215,128,0,10,197,28,198,188, +0,0,86,41,100,53,224,0,2,177,79,85,175,0,0,21,138,154,45,120,0,0,172,85, +217,107,192,0,5,98,182,243,86,193,106,52,127,66,249,50,94,124,35,68,225, +146,49,13,31,170,23,201,146,243,224,200,39,12,145,136,67,134,11,49,1,255, +224,0,0,0,0,0,3,51,1,255,192,0,0,0,0,0,3,47,18,1,172,19,120,71,10,25,196, +136,113,162,156,136,199,42,57,204,144,115,132,240,149,2,248,72,197,209,58, +2,185,16,52,196,225,35,23,68,233,14,228,72,82,68,141,17,56,72,197,209,58, +130,249,44,54,96,191,9,24,186,39,88,79,39,135,147,132,140,93,19,176,35,180, +138,9,216,197,209,59,82,79,31,40,242,1,248,58,42,96,121,14,232,94,62,46, +190,15,38,31,145,33,86,65,76,242,150,143,69,48,242,179,79,45,56,243,51,207, +53,64,243,116,79,57,72,243,180,207,61,80,243,245,79,65,88,244,34,249,50,94, +124,35,68,225,146,39,163,23,201,146,243,224,200,39,12,145,61,40,183,146,37, +116,88,6,136,158,244,241,174,230,202,80,135,130,50,39,16,217,231,208,20, +240,70,68,225,86,224,79,60,64,84,75,141,7,27,157,32,66,37,194,161,168,153, +51,132,9,25,4,225,147,180,138,50,196,18,25,4,225,147,180,138,5,215,49,238, +105,27,60,185,2,72,209,56,100,237,34,140,193,4,136,209,56,100,237,34,129, +117,204,123,154,70,207,50,64,98,72,64,121,51,68,8,163,73,33,1,228,208,16,0, +65,112,152,56,196,159,31,23,77,211,195,201,199,23,150,73,169,234,34,24,49, +39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,196,64,153,137,62, +58,205,227,226,231,146,51,199,26,6,18,92,130,64,192,148,144,102,240,23,129, +133,18,2,100,224,160,56,100,42,26,78,62,46,121,35,60,112,216,32,50,21,13, +39,31,23,60,145,154,9,46,18,1,36,64,47,148,64,98,196,132,201,57,68,132,95, +18,84,141,159,9,121,145,178,67,155,46,73,2,17,46,72,128,89,7,199,32,66,37, +194,197,217,35,120,228,131,17,46,18,243,35,100,128,172,156,98,2,40,152,151, +32,130,166,36,248,235,55,143,139,158,72,207,28,150,24,23,46,92,130,80,72, +151,21,0,100,213,103,229,245,8,186,190,144,24,78,136,24,94,152,3,142,9,113, +214,111,31,23,60,145,158,57,164,13,68,184,248,186,110,158,30,78,56,188,226, +10,62,46,121,35,60,113,18,225,27,70,18,32,10,201,208,32,134,214,208,200,84, +52,156,49,39,50,71,107,107,152,129,13,173,161,144,168,105,57,34,78,100,142, +214,215,49,16,134,214,210,220,229,81,252,49,39,50,71,107,107,158,65,13,173, +165,185,202,163,249,34,78,100,142,214,215,60,146,12,16,28,128,62,175,42,6, +143,36,136,16,64,90,242,135,192,129,67,71,147,62,65,5,215,231,214,6,215,62, +180,8,49,1,3,162,92,4,98,12,41,14,67,40,106,229,1,132,130,8,24,78,104,129, +54,62,96,224,144,13,238,124,32,2,62,146,60,51,224,120,146,164,140,137,20,0, +178,58,11,56,192,5,146,208,34,71,64,36,157,25,200,32,52,158,180,8,146,87, +129,232,217,29,5,156,179,224,116,52,100,191,28,87,62,130,214,9,79,136,104, +201,126,56,174,127,0,31,255,225,73,82,71,16,13,1,36,230,18,1,164,14,87,71, +132,0,143,0,210,131,96,31,0,211,6,42,23,50,70,1,167,13,18,14,130,36,67,232, +46,36,29,4,78,69,6,60,226,31,192,7,255,252,24,192,163,11,23,51,130,56,35, +193,56,100,243,31,6,150,46,103,4,225,147,143,114,27,63,57,241,200,169,194, +133,42,166,175,240,6,23,240,0,97,28,17,224,39,233,32,80,142,8,240,78,25,56, +9,250,136,22,39,12,156,123,144,217,240,19,245,18,6,19,154,32,79,214,124,14, +134,140,151,227,139,237,52,11,88,37,62,33,163,37,248,226,251,77,32,213,184, +64,89,56,39,49,224,137,61,196,5,96,38,35,251,200,15,18,61,96,17,62,40,6, +145,1,17,31,228,64,89,45,2,39,205,0,178,122,209,63,162,2,101,64,202,113,67, +77,247,64,92,221,197,186,196,143,4,9,19,208,1,25,187,139,112,128,178,113, +110,177,35,193,2,68,244,0,46,110,229,30,242,71,130,4,137,232,4,35,55,113, +110,16,22,78,81,239,36,120,32,72,158,128,64,147,138,25,249,0,52,72,242,2, +127,2,5,74,96,140,229,203,34,103,250,154,4,17,163,151,44,137,159,234,105,4, +33,162,93,6,73,123,13,1,165,64,202,113,251,33,6,64,14,71,78,20,101,213,207, +4,194,207,2,12,162,0,158,176,23,218,168,23,66,64,127,239,255,255,255,255, +255,255,19,214,33,187,85,2,232,72,0,0,0,0,0,0,0,0,57,136,15,255,0,0,0,0,0, +0,4,122,247,73,19,69,73,180,134,149,13,68,241,1,255,192,0,0,0,0,0,0,143,90, +67,2,104,169,54,144,210,161,168,158,32,127,248,0,0,0,0,0,0,14,73,78,20,0,0, +0,0,0,0,0,0,8,58,189,233,24,77,217,24,93,240,1,230,238,21,23,32,247,68,13, +155,184,75,189,205,35,102,128,47,114,64,185,187,143,137,4,137,33,205,222, +17,6,96,48,87,130,50,37,114,1,246,147,21,143,224,54,186,213,128,114,90,112, +164,63,252,0,0,0,0,0,0,98,117,119,128,25,55,112,96,153,57,41,197,13,53,224, +65,147,119,38,134,19,146,156,80,211,94,5,194,94,6,37,55,113,110,16,22,78, +12,19,39,37,56,161,166,188,14,74,110,226,220,32,44,156,154,24,78,74,113,67, +77,120,32,97,175,4,28,61,224,133,172,186,70,22,248,1,204,73,242,104,97,47, +128,44,196,159,11,69,175,152,32,35,100,33,142,49,39,218,76,69,237,22,190, +96,128,141,144,136,32,196,159,24,230,204,246,66,40,179,18,125,164,196,206, +185,179,61,144,140,28,196,159,6,9,146,200,71,20,98,79,180,152,135,208,76, +150,66,64,99,18,124,24,49,100,36,137,49,39,218,76,67,232,49,100,37,8,49,39, +195,186,145,149,144,150,44,196,159,105,49,31,174,164,101,100,38,10,49,39, +198,33,180,153,37,100,38,141,49,39,218,76,76,234,27,73,146,86,66,112,163, +18,124,145,4,230,142,86,66,120,211,18,125,164,197,46,144,78,104,229,100,40, +15,49,39,198,33,107,68,136,39,52,114,178,20,73,24,147,237,38,38,117,11,90, +36,65,57,163,149,144,164,68,196,159,38,134,19,46,105,56,226,150,68,157,160, +3,200,147,228,208,194,92,32,124,137,62,49,11,90,36,65,57,163,149,178,166, +74,68,159,105,49,51,168,90,209,34,9,205,28,173,149,65,82,36,249,34,9,205, +28,173,175,170,54,68,159,105,49,75,164,19,154,57,91,95,88,84,137,62,49,13, +164,201,43,111,235,141,145,39,218,76,76,234,27,73,146,86,223,216,17,34,79, +135,117,35,43,115,236,139,145,39,218,76,71,235,169,25,91,159,104,60,137,62, +12,19,37,178,182,42,68,159,105,49,15,160,153,45,149,193,18,36,248,199,54, +103,182,190,232,185,18,125,164,196,206,185,179,61,181,247,133,200,147,225, +104,181,243,4,4,109,191,190,58,68,159,105,49,23,180,90,249,130,2,54,223, +224,67,152,147,230,8,8,217,12,16,121,18,124,193,1,27,101,131,131,56,7,38, +193,198,72,0,0,0,0,0,0,0,0,198,231,240,134,39,63,136,151,95,63,136,49,89, +252,66,98,243,248,133,96,132,185,5,224,32,36,201,41,248,200,213,249,0,131, +64,7,39,192,218,148,124,137,74,216,231,198,227,141,182,124,78,40,217,231, +197,227,4,213,227,192,159,72,10,5,21,218,138,120,74,129,124,36,98,232,228, +74,81,62,160,20,10,107,181,21,114,32,105,137,194,70,46,142,68,165,19,235,1, +64,170,187,81,119,34,66,146,36,104,137,194,70,46,142,68,165,19,236,1,64, +174,187,81,95,37,134,204,23,225,35,23,71,34,82,137,246,128,160,89,93,168, +167,147,195,201,194,70,46,142,68,165,19,238,1,64,182,187,81,71,105,20,19, +177,139,163,145,41,68,16,7,6,15,82,70,72,115,96,32,105,221,0,0,0,0,0,91,60, +149,195,200,194,8,134,149,216,114,1,128,83,192,144,8,194,195,16,12,168,110, +20,120,12,141,22,16,120,12,100,22,12,120,28,78,99,192,41,224,136,115,36,14, +100,197,213,245,193,48,189,112,40,2,237,96,175,131,117,2,178,112,145,139, +163,145,131,114,70,46,142,218,27,182,72,197,209,219,56,26,53,161,166,28,1, +204,178,10,14,38,78,44,141,52,207,31,0,0,21,64,129,100,180,8,148,145,92, +203,176,160,226,100,226,200,211,76,241,240,0,1,84,2,131,137,147,142,41,100, +73,199,192,0,5,88,6,13,10,82,70,62,0,0,42,66,88,115,18,124,67,103,177,69, +49,130,12,73,242,136,108,246,40,165,177,6,36,248,134,207,71,90,138,99,68, +152,147,229,16,217,232,235,81,75,130,12,73,241,13,158,158,149,20,199,9,49, +39,202,33,179,211,210,162,151,69,24,147,225,86,224,79,79,74,138,94,20,98, +79,133,91,129,61,109,74,41,124,60,137,62,33,179,216,166,216,193,18,36,249, +68,54,123,20,218,216,137,18,124,67,103,163,173,77,177,162,100,73,242,136, +108,244,117,169,181,193,18,36,248,134,207,79,74,155,99,132,200,147,229,16, +217,233,233,83,107,162,164,73,240,171,112,39,167,165,77,175,10,145,39,194, +173,192,158,182,165,54,191,153,51,72,71,161,196,201,45,167,146,59,68,89,24, +70,206,1,255,128,0,0,0,0,0,1,153,51,104,71,161,196,201,45,167,146,59,68,89, +24,70,206,1,255,128,0,0,0,0,0,1,153,51,136,71,161,196,201,45,167,146,59,68, +89,24,70,206,1,255,128,0,0,0,0,0,1,153,51,168,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,0,0,0,0,0,0,1,153,51,200,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,0,0,0,0,0,0,1,153,51,232,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,128,0,0,0,0,0,1,153,52,8,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,128,0,0,0,0,0,1,153,52,40,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,0,128,0,0,0,0,0,1,153,52,72,71,161,196,201,45,167,146,59, +68,89,24,70,206,2,1,0,0,0,0,0,0,1,135,52,102,32,76,72,1,246,136,235,103, +177,69,1,17,32,7,196,54,123,20,82,88,200,144,3,237,17,214,207,71,91,171,37, +20,65,145,32,7,218,35,173,158,142,183,66,74,41,16,92,72,1,241,13,158,142, +183,86,74,41,48,92,72,1,241,13,158,142,183,66,74,41,80,100,72,1,246,136, +235,103,167,165,213,146,138,40,200,144,3,237,17,214,207,79,75,161,37,20, +138,46,36,0,248,134,207,79,75,171,37,20,154,46,36,0,248,134,207,79,75,161, +37,20,170,46,36,0,248,85,184,19,234,201,69,24,92,72,1,240,171,112,39,208, +146,138,70,25,18,0,124,27,168,21,147,171,37,20,113,145,32,7,193,186,129,89, +58,18,81,72,226,162,64,15,180,71,91,62,172,148,90,0,168,144,3,237,17,214, +207,161,37,22,144,38,36,0,248,134,207,171,37,22,160,38,36,0,248,134,207, +161,37,22,176,42,209,68,201,218,35,173,158,197,54,4,218,40,153,56,134,207, +98,155,75,27,104,162,100,237,17,214,207,71,91,171,37,54,65,182,138,38,78, +209,29,108,244,117,186,18,83,104,131,45,20,76,156,67,103,163,173,213,146, +155,76,25,104,162,100,226,27,61,29,110,132,148,218,160,219,69,19,39,104, +142,182,122,122,93,89,41,178,141,180,81,50,118,136,235,103,167,165,208,146, +155,69,25,104,162,100,226,27,61,61,46,172,148,218,104,203,69,19,39,16,217, +233,233,116,36,166,213,70,90,40,153,56,85,184,19,234,201,77,152,101,162, +137,147,133,91,129,62,132,148,218,48,219,69,19,39,6,234,5,100,234,201,77, +156,109,162,137,147,131,117,2,178,116,36,166,209,197,218,40,153,59,68,117, +179,234,201,78,32,11,180,81,50,118,136,235,103,208,146,156,72,21,104,162, +100,226,27,62,172,148,226,128,171,69,19,39,16,217,244,36,167,22,53,123,102, +53,155,80,2,21,11,94,201,128,196,133,0,185,80,32,56,156,199,130,36,160,72, +16,78,126,54,48,5,146,208,34,82,72,1,109,20,76,155,120,28,34,1,225,32,32,2, +223,133,69,138,43,180,132,234,219,163,161,1,0,9,174,198,238,213,84,88,31, +86,221,40,7,252,197,200,95,223,71,61,225,122,183,27,72,144,15,253,197,81, +217,74,224,191,131,117,110,54,142,129,32,31,237,229,189,138,147,114,135,2, +235,209,1,0,36,135,237,81,16,180,96,63,101,8,207,71,107,74,1,255,53,4,243, +51,249,222,104,94,202,17,158,148,3,255,106,9,230,103,243,188,210,159,129, +228,176,192,185,127,46,155,185,41,197,13,55,38,3,127,255,20,138,160,192,25, +106,8,8,1,58,90,130,64,128,146,27,168,37,8,9,129,186,130,96,160,152,27,165, +171,64,32,131,25,234,10,64,65,17,11,212,19,133,18,243,167,165,163,32,24, +157,45,65,64,6,75,191,80,80,66,149,110,116,117,5,8,41,240,247,79,72,188,8, +134,81,122,84,1,173,198,212,20,48,139,113,180,181,5,36,42,220,109,29,13,65, +74,6,192,95,76,188,6,196,55,78,188,6,247,91,86,136,26,32,104,220,205,72,1, +98,234,52,122,130,136,18,72,51,117,68,3,146,27,168,40,161,37,8,207,80,81, +129,204,13,212,20,112,179,141,26,45,65,75,112,20,43,193,25,19,66,128,153, +78,40,105,144,92,104,152,131,124,27,253,128,0,10,116,3,68,146,163,9,128,0, +10,102,3,138,145,137,27,60,0,0,82,129,7,2,4,16,7,2,70,143,178,203,164,237, +35,14,25,10,134,147,143,139,158,72,207,28,54,77,47,109,13,55,113,120,96, +196,159,29,102,241,241,115,201,25,227,131,36,133,20,62,110,143,17,16,113, +137,62,62,46,155,167,135,147,142,47,44,151,79,221,64,98,37,194,94,100,108, +144,21,147,140,73,168,228,19,17,124,73,82,54,124,37,230,70,201,14,108,185, +36,155,14,243,243,83,212,69,131,132,4,12,137,114,168,37,166,145,7,10,4,28, +200,14,12,40,56,153,56,178,52,211,60,124,0,0,85,0,160,226,100,227,138,89, +18,113,240,0,1,86,1,131,66,148,145,143,128,0,10,144,93,134,0,0,43,80,17,42, +4,17,136,49,73,19,49,134,16,143,67,137,146,91,79,36,118,136,178,48,141,156, +3,255,0,0,0,0,0,0,3,49,135,16,143,67,137,146,91,79,36,118,136,178,48,141, +156,3,255,0,0,0,0,0,0,5,20,5,173,194,227,214,4,55,0,0,21,196,7,122,192,134, +241,197,192,0,5,121,25,140,64,132,122,28,76,146,218,121,35,180,69,145,132, +108,224,31,248,0,0,0,0,0,0,25,140,72,132,122,28,76,146,218,121,35,180,69, +145,132,108,224,32,0,0,0,0,0,0,0,25,140,80,132,122,28,76,146,218,121,35, +180,69,145,132,108,224,32,0,0,0,0,0,0,0,25,140,88,132,122,28,76,146,218, +121,35,180,69,145,132,108,224,32,8,0,0,0,0,0,0,25,140,96,132,122,28,76,146, +218,121,35,180,69,145,132,108,224,32,8,0,0,0,0,0,0,25,140,104,132,122,28, +76,146,218,121,35,180,69,145,132,108,224,32,8,0,0,0,0,0,0,25,140,112,132, +122,28,76,146,218,121,35,180,69,145,132,108,224,32,16,0,0,0,0,0,0,16,113, +225,0,48,156,209,2,122,244,5,34,92,35,68,225,161,166,218,16,33,18,224,104, +82,146,59,50,5,7,19,39,22,70,154,103,215,32,28,78,99,193,18,80,70,131,165, +1,205,34,8,35,68,225,161,166,239,255,4,12,70,137,195,39,248,73,7,78,3,154, +102,16,70,137,195,67,77,223,248,1,74,9,129,125,255,130,9,65,154,232,147, +161,115,59,255,5,64,195,32,156,50,126,197,14,2,3,107,173,213,0, }; #elif defined(DUK_USE_DOUBLE_ME) -DUK_INTERNAL const duk_uint8_t duk_builtins_data[4116] = { -144,148,105,224,32,68,52,228,62,12,104,200,165,132,52,167,194,138,105,243, -124,57,28,211,57,18,64,52,238,126,44,138,111,171,241,164,19,87,129,30,33, +DUK_INTERNAL const duk_uint8_t duk_builtins_data[3972] = { +144,148,105,223,160,68,52,228,62,12,104,200,165,132,52,167,194,138,105,242, +252,57,28,211,57,18,64,52,238,62,44,138,111,171,241,164,19,87,125,30,33, 167,16,145,159,8,211,136,9,225,42,5,240,145,139,163,163,8,211,136,10,228, 64,211,19,132,140,93,29,56,70,156,64,119,34,66,146,36,104,137,194,70,46, 142,172,35,78,32,47,146,195,102,11,240,145,139,163,175,8,211,136,9,228,240, 242,112,145,139,163,179,8,211,136,8,237,34,130,118,49,116,118,225,26,48,0, -1,82,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, -33,8,66,26,179,233,97,167,60,150,34,33,154,112,0,1,75,247,35,79,95,237,198, -174,200,47,31,23,95,17,13,51,19,35,93,68,216,209,128,0,10,208,174,79,15,32, -248,8,196,24,8,107,192,0,5,106,118,27,94,0,0,43,83,227,94,0,0,43,84,46,215, -128,0,10,213,28,198,188,0,0,86,169,100,53,224,0,2,181,79,85,175,0,0,21,170, -154,45,120,0,0,173,85,217,107,192,0,5,106,182,243,86,193,106,52,127,130, -249,50,94,124,35,68,225,146,49,13,31,186,23,201,146,243,224,200,39,12,145, -136,67,134,19,49,0,0,3,225,252,0,0,0,3,51,0,0,3,193,252,0,0,0,3,47,18,1, -172,19,120,71,10,25,196,136,113,162,156,136,199,42,57,204,144,115,132,240, -149,2,248,72,197,209,58,2,185,16,52,196,225,35,23,68,233,14,228,72,82,68, -141,17,56,72,197,209,58,130,249,44,54,96,191,9,24,186,39,88,79,39,135,147, -132,140,93,19,176,35,180,138,9,216,197,209,59,82,79,35,40,242,65,248,58,42, -96,121,14,232,94,62,46,190,15,42,31,145,33,86,65,76,242,214,143,73,48,242, -243,79,49,56,243,115,207,57,64,243,180,79,61,72,243,244,207,65,80,244,53, -79,69,88,244,98,30,8,200,156,67,102,120,241,79,4,100,78,21,110,4,207,32,47, -147,37,231,194,52,78,25,34,122,81,124,153,47,62,12,130,112,201,19,211,139, -121,34,87,69,128,104,137,239,83,18,238,108,165,2,162,92,104,56,220,233,1,8, -151,10,134,162,100,206,16,18,50,9,195,39,105,20,101,136,18,25,4,225,147, -180,138,5,215,49,238,105,27,60,185,1,36,104,156,50,118,145,70,96,129,34,52, -78,25,59,72,160,93,115,30,230,145,179,204,144,12,73,8,15,38,104,128,138,52, -146,16,30,77,1,0,2,11,132,193,198,36,248,248,186,110,158,30,78,56,188,194, -70,183,170,136,48,98,79,142,179,120,248,185,228,140,241,193,146,66,138,31, -55,71,138,128,153,137,62,58,205,227,226,231,146,51,199,26,6,18,92,146,64, -96,74,72,51,120,43,192,97,68,128,153,56,72,7,12,133,67,73,199,197,207,36, -103,142,35,2,3,33,80,210,113,241,115,201,25,160,146,225,160,9,34,1,124,178, -1,139,18,19,36,229,146,8,190,36,169,27,62,18,243,35,100,135,54,92,162,2,17, -46,72,128,89,7,200,32,33,18,225,98,236,145,188,130,64,196,75,132,188,200, -217,32,43,39,28,128,69,19,18,228,144,42,98,79,142,179,120,248,185,228,140, -241,201,97,129,114,229,201,37,2,68,184,200,1,147,93,159,153,213,34,235,250, -96,48,157,32,24,94,160,1,199,4,184,235,55,143,139,158,72,207,28,226,3,81, -46,62,46,155,167,135,147,142,47,60,129,71,197,207,36,103,142,34,92,35,104, -194,68,1,89,58,36,8,109,109,12,133,67,73,195,18,115,36,118,182,185,168,8, -109,109,12,133,67,73,201,18,115,36,118,182,185,168,130,27,91,75,115,149,71, -240,196,156,201,29,173,174,129,2,27,91,75,115,149,71,242,68,156,201,29,173, -174,129,34,12,16,28,128,62,191,42,3,71,146,68,4,16,22,188,161,240,16,40, -104,242,103,196,16,93,158,125,96,110,115,235,64,131,16,16,58,37,192,70,32, -194,144,114,25,67,95,40,6,18,8,32,48,156,209,2,108,124,96,224,144,6,247,62, -16,0,143,164,143,12,248,15,18,84,145,145,34,128,11,35,160,179,140,0,44,150, -129,18,58,0,146,116,103,32,128,105,61,104,17,36,175,1,232,217,29,5,156,179, -224,58,26,50,95,142,43,159,64,181,130,83,226,26,50,95,142,43,159,192,7,255, -248,41,42,72,226,1,160,18,78,97,32,26,64,114,186,60,32,4,120,6,148,13,128, -124,3,76,12,84,46,100,140,3,78,13,18,14,130,36,67,232,23,18,14,130,39,34, -131,30,113,15,224,3,255,253,6,48,40,194,197,204,224,142,8,240,78,25,60,231, -192,210,197,204,224,156,50,113,238,67,103,232,62,28,138,156,104,82,170,107, -255,32,48,191,144,1,132,112,71,128,159,168,128,161,28,17,224,156,50,112,19, -245,144,22,39,12,156,123,144,217,240,19,245,146,3,9,205,16,39,236,62,3,161, -163,37,248,226,251,141,1,107,4,167,196,52,100,191,28,95,113,164,13,91,132, -5,147,130,115,30,8,147,222,64,43,1,49,31,224,64,60,72,245,128,68,249,32,13, -34,2,34,63,204,128,89,45,2,39,209,0,89,61,104,159,213,0,153,80,50,156,80, -211,126,16,11,155,184,183,88,145,224,129,34,122,64,17,155,184,183,8,11,39, -22,235,18,60,16,36,79,72,1,115,119,40,247,146,60,16,36,79,72,32,140,221, -197,184,64,89,57,71,188,145,224,129,34,122,65,1,39,20,51,244,0,52,72,242,2, -127,18,2,165,48,70,114,229,145,51,253,141,1,4,104,229,203,34,103,251,26,64, -132,52,75,160,201,47,105,160,26,84,12,167,31,186,8,50,0,114,58,113,163,46, -190,120,35,11,60,4,25,68,81,61,96,47,181,80,46,132,129,255,255,222,255,255, -255,255,254,39,172,67,118,170,5,208,144,0,0,0,0,0,64,0,0,51,16,0,0,62,31, -192,0,0,0,8,245,238,146,38,138,147,105,13,42,26,137,226,0,0,7,131,248,0,0, -0,1,30,180,134,4,209,82,109,33,165,67,81,60,64,0,0,240,255,0,0,0,0,15,210, -62,72,91,155,0,0,2,192,240,0,0,0,0,135,88,11,237,72,5,38,210,27,50,24,145, -129,255,254,126,135,255,255,255,254,67,172,67,118,164,2,147,105,13,153,12, -72,192,255,255,63,195,255,255,255,255,16,240,70,68,226,27,51,199,138,120, -35,34,112,171,112,38,121,7,16,137,112,168,106,38,77,193,1,40,151,16,217, -144,196,142,224,144,21,18,227,65,198,238,9,67,81,46,72,5,39,16,217,144,196, -142,224,152,228,148,227,64,0,0,0,0,0,0,0,0,131,175,223,16,194,111,8,97,119, -224,3,205,220,42,46,65,238,200,13,155,184,75,189,205,35,102,128,47,116,64, -92,221,199,196,130,68,144,230,239,72,65,152,12,21,224,140,137,92,128,62, -210,98,177,252,3,107,173,88,3,146,211,141,32,0,3,225,252,0,0,0,3,19,175, -188,0,100,221,193,130,100,228,167,20,52,215,129,3,38,238,77,12,39,37,56, -161,166,188,10,194,94,6,18,155,184,183,8,11,39,6,9,147,146,156,80,211,94,7, -18,155,184,183,8,11,39,38,134,19,146,156,80,211,94,8,12,53,224,130,195,222, -8,77,133,210,24,91,224,3,152,147,228,208,194,95,0,44,196,159,11,69,175,152, -32,35,100,33,135,24,147,237,38,34,246,139,95,48,64,70,200,68,8,49,39,198, -57,179,61,144,138,22,98,79,180,152,153,215,54,103,178,17,129,204,73,240,96, -153,44,132,112,163,18,125,164,196,62,130,100,178,18,1,140,73,240,96,197, -144,146,18,98,79,180,152,135,208,98,200,74,8,49,39,195,186,145,149,144,150, -22,98,79,180,152,143,215,82,50,178,19,2,140,73,241,136,109,38,73,89,9,161, -166,36,251,73,137,157,67,105,50,74,200,78,10,49,39,201,16,78,104,229,100, -39,134,152,147,237,38,41,116,130,115,71,43,33,64,60,196,159,24,133,173,18, -32,156,209,202,200,81,18,49,39,218,76,76,234,22,180,72,130,115,71,43,33,72, -68,196,159,38,134,19,46,105,56,226,150,68,157,160,1,228,73,242,104,97,46, -16,31,34,79,140,66,214,137,16,78,104,229,108,169,137,72,147,237,38,38,117, -11,90,36,65,57,163,149,178,168,21,34,79,146,32,156,209,202,218,250,161,178, -36,251,73,138,93,32,156,209,202,218,250,193,82,36,248,196,54,147,36,173, -191,174,27,34,79,180,152,153,212,54,147,36,173,191,176,17,34,79,135,117,35, -43,115,236,133,200,147,237,38,35,245,212,140,173,207,180,15,34,79,131,4, -201,108,173,133,72,147,237,38,33,244,19,37,178,184,17,34,79,140,115,102, -123,107,238,133,200,147,237,38,38,117,205,153,237,175,188,23,34,79,133,162, -215,204,16,17,182,254,248,116,137,62,210,98,47,104,181,243,4,4,109,191,192, -131,152,147,230,8,8,217,12,16,60,137,62,96,128,141,178,193,160,206,1,201, -176,113,146,0,0,0,0,0,0,0,0,49,185,252,65,137,207,227,37,215,207,227,12,86, -127,24,152,188,254,49,88,33,46,65,120,72,4,153,37,63,33,13,127,148,4,26,0, -57,62,6,228,163,228,74,86,215,62,55,28,110,179,226,113,70,223,62,47,24,38, -191,30,2,125,32,40,20,87,114,41,225,42,5,240,145,139,163,145,41,68,250,128, -80,41,174,228,85,200,129,166,39,9,24,186,57,18,148,79,172,5,2,170,238,69, -220,137,10,72,145,162,39,9,24,186,57,18,148,79,176,5,2,186,238,69,124,150, -27,48,95,132,140,93,28,137,74,39,218,2,129,101,119,34,158,79,15,39,9,24, -186,57,18,148,79,184,5,2,218,238,69,29,164,80,78,198,46,142,68,165,16,64, -28,24,61,73,25,33,205,128,1,167,166,128,0,0,0,1,108,242,151,15,39,8,34,26, -87,97,200,3,0,167,129,32,8,194,195,16,6,84,55,10,60,3,35,69,132,30,1,140, -130,193,143,1,196,230,60,2,158,8,131,153,64,115,42,46,191,176,8,194,246,0, -80,5,220,193,95,6,234,5,100,225,35,23,71,35,6,228,140,93,29,180,55,108,145, -139,163,182,112,52,107,67,76,56,3,153,132,20,28,76,156,89,26,105,158,62,0, -0,42,193,2,201,104,17,41,34,156,204,176,160,226,100,226,200,211,76,241,240, -0,1,86,2,131,137,147,142,41,100,73,199,192,0,5,96,6,13,10,82,70,62,0,0,42, -130,88,115,18,124,67,103,177,69,49,129,6,36,249,68,54,123,20,82,216,65,137, -62,33,179,209,214,162,152,208,147,18,124,162,27,61,29,106,41,112,32,196, -159,16,217,233,233,81,76,112,73,137,62,81,13,158,158,149,20,186,20,98,79, -133,91,129,61,61,42,41,120,40,196,159,10,183,2,122,218,148,82,248,60,137, -62,33,179,216,166,216,192,137,18,124,162,27,61,138,109,108,34,68,159,16, -217,232,235,83,108,104,76,137,62,81,13,158,142,181,54,184,17,34,79,136,108, -244,244,169,182,56,38,68,159,40,134,207,79,74,155,93,10,145,39,194,173,192, -158,158,149,54,188,21,34,79,133,91,129,61,109,74,109,125,155,51,136,71,161, -196,201,45,167,146,59,68,89,24,70,206,0,0,7,129,248,0,0,0,1,155,51,168,71, -161,196,201,45,167,146,59,68,89,24,70,206,0,0,7,129,248,0,0,0,1,155,51,200, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,7,129,248,0,0,0,1,155,51, -232,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,2,0,0,0,0,1,155,52, -8,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,2,0,0,0,0,1,155,52,40, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,155,52,72, -71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,155,52, -104,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,155, -52,136,71,161,196,201,45,167,146,59,68,89,24,70,206,0,0,1,2,0,0,0,0,1,135, -52,166,32,76,72,1,246,136,235,103,177,69,0,136,144,3,226,27,61,138,41,44, -50,36,0,251,68,117,179,209,214,234,201,69,16,50,36,0,251,68,117,179,209, -214,232,73,69,34,5,196,128,31,16,217,232,235,117,100,162,147,2,226,64,15, -136,108,244,117,186,18,81,74,129,145,32,7,218,35,173,158,158,151,86,74,40, -161,145,32,7,218,35,173,158,158,151,66,74,41,20,46,36,0,248,134,207,79,75, -171,37,20,154,23,18,0,124,67,103,167,165,208,146,138,85,11,137,0,62,21,110, -4,250,178,81,70,11,137,0,62,21,110,4,250,18,81,72,193,145,32,7,193,186,129, -89,58,178,81,71,12,137,0,62,13,212,10,201,208,146,138,71,10,137,0,62,209, -29,108,250,178,81,104,1,81,32,7,218,35,173,159,66,74,45,32,38,36,0,248,134, -207,171,37,22,160,19,18,0,124,67,103,208,146,139,88,10,180,81,50,118,136, -235,103,177,77,128,155,69,19,39,16,217,236,83,105,97,182,138,38,78,209,29, -108,244,117,186,178,83,100,13,180,81,50,118,136,235,103,163,173,208,146, -155,68,12,180,81,50,113,13,158,142,183,86,74,109,48,50,209,68,201,196,54, -122,58,221,9,41,181,64,219,69,19,39,104,142,182,122,122,93,89,41,178,134, -218,40,153,59,68,117,179,211,210,232,73,77,162,134,90,40,153,56,134,207,79, -75,171,37,54,154,25,104,162,100,226,27,61,61,46,132,148,218,168,101,162, -137,147,133,91,129,62,172,148,217,131,45,20,76,156,42,220,9,244,36,166,209, -131,109,20,76,156,27,168,21,147,171,37,54,112,219,69,19,39,6,234,5,100,232, -73,77,163,133,218,40,153,59,68,117,179,234,201,78,32,5,218,40,153,59,68, -117,179,232,73,78,36,5,90,40,153,56,134,207,171,37,56,160,21,104,162,100, -226,27,62,132,148,226,195,95,182,97,176,218,128,8,84,45,123,38,1,137,10,1, -114,160,64,56,156,199,130,36,160,72,8,39,63,27,24,1,100,180,8,148,146,0,45, -162,137,147,111,2,8,4,16,7,8,96,120,72,1,87,224,168,13,42,226,145,97,58, -182,232,232,64,177,107,2,64,22,85,181,187,7,213,183,74,2,17,119,49,255,121, -207,215,240,94,173,198,210,36,4,113,95,115,255,232,34,182,80,221,91,141, -163,160,72,15,121,123,103,225,220,164,194,160,186,244,64,251,33,9,64,24,45, -68,84,15,217,66,51,209,218,210,129,61,65,204,127,154,118,254,204,23,178, -132,103,165,2,122,131,216,255,52,237,253,154,168,48,6,90,130,1,0,39,75,80, -72,8,9,33,186,130,80,64,76,13,212,19,2,130,96,110,150,173,0,65,6,51,212,20, -128,65,17,11,212,19,130,137,121,211,210,209,144,6,39,75,80,80,0,201,119, -234,10,8,41,86,231,71,80,80,129,79,135,186,122,69,224,34,25,69,233,80,3,91, -141,168,40,96,139,113,180,181,5,36,21,110,54,142,134,160,165,1,176,23,211, -47,0,216,134,233,215,128,111,117,181,104,128,209,3,70,230,106,64,5,139,168, -209,234,10,32,36,144,102,234,136,3,146,27,168,40,160,146,132,103,168,40, -192,115,3,117,5,28,22,113,163,69,168,41,103,1,66,188,17,145,52,40,4,202, -113,67,76,130,227,68,194,13,240,108,0,0,83,96,0,2,161,0,104,146,84,97,48,0, -1,78,192,56,169,24,145,179,192,0,5,48,8,56,16,32,128,56,18,52,125,166,86, -147,182,140,28,50,21,13,39,31,23,60,145,158,56,140,141,47,113,6,155,186, -188,24,49,39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,197,68, -14,49,39,199,197,211,116,240,242,113,197,230,18,180,253,228,3,17,46,18,243, -35,100,128,172,156,114,70,163,146,76,34,248,146,164,108,248,75,204,141,146, -28,217,114,137,27,78,251,241,173,234,162,160,225,1,3,34,92,170,9,105,164, -32,225,64,131,155,1,193,133,7,19,39,22,70,154,103,143,128,0,10,176,20,28, -76,156,113,75,34,78,62,0,0,43,0,48,104,82,146,49,240,0,1,84,11,180,192,0,5, -114,1,18,160,65,24,131,20,145,25,172,48,132,122,28,76,146,218,121,35,180, -69,145,132,108,224,0,0,120,31,128,0,0,0,25,172,56,132,122,28,76,146,218, -121,35,180,69,145,132,108,224,0,0,120,31,128,0,0,0,40,160,45,110,23,30,176, -33,184,0,0,175,32,29,235,2,27,199,23,0,0,22,4,51,88,129,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,0,0,240,63,0,0,0,0,51,88,145,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,0,0,0,64,0,0,0,0,51,88,161,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,0,0,0,64,0,0,0,0,51,88,177,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51,88,193,8,244,56, -153,37,180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51,88,209,8,244, -56,153,37,180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51,88,225,8, -244,56,153,37,180,242,71,104,139,35,8,217,192,0,0,32,64,0,0,0,0,32,227,194, -0,97,57,162,4,245,232,5,34,92,35,68,225,161,166,218,16,16,137,112,52,41,73, -29,153,1,65,196,201,197,145,166,153,245,200,3,137,204,120,34,74,8,200,58, -112,28,211,32,130,52,78,26,26,110,248,0,0,164,4,12,70,137,195,39,252,73, -240,117,32,57,168,97,4,104,156,52,52,221,255,160,20,160,152,23,223,250,32, -148,25,174,137,58,23,51,191,244,84,12,50,9,195,39,240,81,238,2,3,107,173, -214,3,192, +1,80,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, +33,8,66,34,33,154,112,0,1,73,247,35,79,91,237,198,174,192,47,31,23,95,17, +13,51,19,35,93,68,216,209,128,0,10,192,174,79,15,32,248,8,196,24,8,107,192, +0,5,98,118,27,94,0,0,43,19,227,94,0,0,43,20,46,215,128,0,10,197,28,198,188, +0,0,86,41,100,53,224,0,2,177,79,85,175,0,0,21,138,154,45,120,0,0,172,85, +217,107,192,0,5,98,182,243,86,193,106,52,127,66,249,50,94,124,35,68,225, +146,49,13,31,170,23,201,146,243,224,200,39,12,145,136,67,134,11,49,0,0,3, +225,252,0,0,0,3,51,0,0,3,193,252,0,0,0,3,47,18,1,172,19,120,71,10,25,196, +136,113,162,156,136,199,42,57,204,144,115,132,240,149,2,248,72,197,209,58, +2,185,16,52,196,225,35,23,68,233,14,228,72,82,68,141,17,56,72,197,209,58, +130,249,44,54,96,191,9,24,186,39,88,79,39,135,147,132,140,93,19,176,35,180, +138,9,216,197,209,59,82,79,31,40,242,1,248,58,42,96,121,14,232,94,62,46, +190,15,38,31,145,33,86,65,76,242,150,143,69,48,242,179,79,45,56,243,51,207, +53,64,243,116,79,57,72,243,180,207,61,80,243,245,79,65,88,244,34,249,50,94, +124,35,68,225,146,39,163,23,201,146,243,224,200,39,12,145,61,40,183,146,37, +116,88,6,136,158,244,241,174,230,202,80,135,130,50,39,16,217,231,208,20, +240,70,68,225,86,224,79,60,64,84,75,141,7,27,157,32,66,37,194,161,168,153, +51,132,9,25,4,225,147,180,138,50,196,18,25,4,225,147,180,138,5,215,49,238, +105,27,60,185,2,72,209,56,100,237,34,140,193,4,136,209,56,100,237,34,129, +117,204,123,154,70,207,50,64,98,72,64,121,51,68,8,163,73,33,1,228,208,16,0, +65,112,152,56,196,159,31,23,77,211,195,201,199,23,150,73,169,234,34,24,49, +39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,196,64,153,137,62, +58,205,227,226,231,146,51,199,26,6,18,92,130,64,192,148,144,102,240,23,129, +133,18,2,100,224,160,56,100,42,26,78,62,46,121,35,60,112,216,32,50,21,13, +39,31,23,60,145,154,9,46,18,1,36,64,47,148,64,98,196,132,201,57,68,132,95, +18,84,141,159,9,121,145,178,67,155,46,73,2,17,46,72,128,89,7,199,32,66,37, +194,197,217,35,120,228,131,17,46,18,243,35,100,128,172,156,98,2,40,152,151, +32,130,166,36,248,235,55,143,139,158,72,207,28,150,24,23,46,92,130,80,72, +151,21,0,100,213,103,229,245,8,186,190,144,24,78,136,24,94,152,3,142,9,113, +214,111,31,23,60,145,158,57,164,13,68,184,248,186,110,158,30,78,56,188,226, +10,62,46,121,35,60,113,18,225,27,70,18,32,10,201,208,32,134,214,208,200,84, +52,156,49,39,50,71,107,107,152,129,13,173,161,144,168,105,57,34,78,100,142, +214,215,49,16,134,214,210,220,229,81,252,49,39,50,71,107,107,158,65,13,173, +165,185,202,163,249,34,78,100,142,214,215,60,146,12,16,28,128,62,175,42,6, +143,36,136,16,64,90,242,135,192,129,67,71,147,62,65,5,215,231,214,6,215,62, +180,8,49,1,3,162,92,4,98,12,41,14,67,40,106,229,1,132,130,8,24,78,104,129, +54,62,96,224,144,13,238,124,32,2,62,146,60,51,224,120,146,164,140,137,20,0, +178,58,11,56,192,5,146,208,34,71,64,36,157,25,200,32,52,158,180,8,146,87, +129,232,217,29,5,156,179,224,116,52,100,191,28,87,62,130,214,9,79,136,104, +201,126,56,174,127,0,31,255,225,73,82,71,16,13,1,36,230,18,1,164,14,87,71, +132,0,143,0,210,131,96,31,0,211,6,42,23,50,70,1,167,13,18,14,130,36,67,232, +46,36,29,4,78,69,6,60,226,31,192,7,255,252,24,192,163,11,23,51,130,56,35, +193,56,100,243,31,6,150,46,103,4,225,147,143,114,27,63,57,241,200,169,194, +133,42,166,175,240,6,23,240,0,97,28,17,224,39,233,32,80,142,8,240,78,25,56, +9,250,136,22,39,12,156,123,144,217,240,19,245,18,6,19,154,32,79,214,124,14, +134,140,151,227,139,237,52,11,88,37,62,33,163,37,248,226,251,77,32,213,184, +64,89,56,39,49,224,137,61,196,5,96,38,35,251,200,15,18,61,96,17,62,40,6, +145,1,17,31,228,64,89,45,2,39,205,0,178,122,209,63,162,2,101,64,202,113,67, +77,247,64,92,221,197,186,196,143,4,9,19,208,1,25,187,139,112,128,178,113, +110,177,35,193,2,68,244,0,46,110,229,30,242,71,130,4,137,232,4,35,55,113, +110,16,22,78,81,239,36,120,32,72,158,128,64,147,138,25,249,0,52,72,242,2, +127,2,5,74,96,140,229,203,34,103,250,154,4,17,163,151,44,137,159,234,105,4, +33,162,93,6,73,123,13,1,165,64,202,113,251,33,6,64,14,71,78,20,101,213,207, +4,194,207,2,12,162,0,158,176,23,218,168,23,66,64,255,255,239,127,255,255, +255,255,19,214,33,187,85,2,232,72,0,0,0,0,0,32,0,0,25,136,0,0,31,15,224,0, +0,0,4,122,247,73,19,69,73,180,134,149,13,68,241,0,0,3,193,252,0,0,0,0,143, +90,67,2,104,169,54,144,210,161,168,158,32,0,0,120,127,128,0,0,0,14,73,78, +20,0,0,0,0,0,0,0,0,8,58,189,233,24,77,217,24,93,240,1,230,238,21,23,32,247, +68,13,155,184,75,189,205,35,102,128,47,114,64,185,187,143,137,4,137,33,205, +222,17,6,96,48,87,130,50,37,114,1,246,147,21,143,224,54,186,213,128,114,90, +112,164,0,0,124,63,128,0,0,0,98,117,119,128,25,55,112,96,153,57,41,197,13, +53,224,65,147,119,38,134,19,146,156,80,211,94,5,194,94,6,37,55,113,110,16, +22,78,12,19,39,37,56,161,166,188,14,74,110,226,220,32,44,156,154,24,78,74, +113,67,77,120,32,97,175,4,28,61,224,133,172,186,70,22,248,1,204,73,242,104, +97,47,128,44,196,159,11,69,175,152,32,35,100,33,142,49,39,218,76,69,237,22, +190,96,128,141,144,136,32,196,159,24,230,204,246,66,40,179,18,125,164,196, +206,185,179,61,144,140,28,196,159,6,9,146,200,71,20,98,79,180,152,135,208, +76,150,66,64,99,18,124,24,49,100,36,137,49,39,218,76,67,232,49,100,37,8,49, +39,195,186,145,149,144,150,44,196,159,105,49,31,174,164,101,100,38,10,49, +39,198,33,180,153,37,100,38,141,49,39,218,76,76,234,27,73,146,86,66,112, +163,18,124,145,4,230,142,86,66,120,211,18,125,164,197,46,144,78,104,229, +100,40,15,49,39,198,33,107,68,136,39,52,114,178,20,73,24,147,237,38,38,117, +11,90,36,65,57,163,149,144,164,68,196,159,38,134,19,46,105,56,226,150,68, +157,160,3,200,147,228,208,194,92,32,124,137,62,49,11,90,36,65,57,163,149, +178,166,74,68,159,105,49,51,168,90,209,34,9,205,28,173,149,65,82,36,249,34, +9,205,28,173,175,170,54,68,159,105,49,75,164,19,154,57,91,95,88,84,137,62, +49,13,164,201,43,111,235,141,145,39,218,76,76,234,27,73,146,86,223,216,17, +34,79,135,117,35,43,115,236,139,145,39,218,76,71,235,169,25,91,159,104,60, +137,62,12,19,37,178,182,42,68,159,105,49,15,160,153,45,149,193,18,36,248, +199,54,103,182,190,232,185,18,125,164,196,206,185,179,61,181,247,133,200, +147,225,104,181,243,4,4,109,191,190,58,68,159,105,49,23,180,90,249,130,2, +54,223,224,67,152,147,230,8,8,217,12,16,121,18,124,193,1,27,101,131,131,56, +7,38,193,198,72,0,0,0,0,0,0,0,0,198,231,240,134,39,63,136,151,95,63,136,49, +89,252,66,98,243,248,133,96,132,185,5,224,32,36,201,41,248,200,213,249,0, +131,64,7,39,192,218,148,124,137,74,216,231,198,227,141,182,124,78,40,217, +231,197,227,4,213,227,192,159,72,10,5,21,218,138,120,74,129,124,36,98,232, +228,74,81,62,160,20,10,107,181,21,114,32,105,137,194,70,46,142,68,165,19, +235,1,64,170,187,81,119,34,66,146,36,104,137,194,70,46,142,68,165,19,236,1, +64,174,187,81,95,37,134,204,23,225,35,23,71,34,82,137,246,128,160,89,93, +168,167,147,195,201,194,70,46,142,68,165,19,238,1,64,182,187,81,71,105,20, +19,177,139,163,145,41,68,16,7,6,15,82,70,72,115,96,0,93,105,160,0,0,0,0,91, +60,149,195,200,194,8,134,149,216,114,1,128,83,192,144,8,194,195,16,12,168, +110,20,120,12,141,22,16,120,12,100,22,12,120,28,78,99,192,41,224,136,115, +36,14,100,197,213,245,193,48,189,112,40,2,237,96,175,131,117,2,178,112,145, +139,163,145,131,114,70,46,142,218,27,182,72,197,209,219,56,26,53,161,166, +28,1,204,178,10,14,38,78,44,141,52,207,31,0,0,21,64,129,100,180,8,148,145, +92,203,176,160,226,100,226,200,211,76,241,240,0,1,84,2,131,137,147,142,41, +100,73,199,192,0,5,88,6,13,10,82,70,62,0,0,42,66,88,115,18,124,67,103,177, +69,49,130,12,73,242,136,108,246,40,165,177,6,36,248,134,207,71,90,138,99, +68,152,147,229,16,217,232,235,81,75,130,12,73,241,13,158,158,149,20,199,9, +49,39,202,33,179,211,210,162,151,69,24,147,225,86,224,79,79,74,138,94,20, +98,79,133,91,129,61,109,74,41,124,60,137,62,33,179,216,166,216,193,18,36, +249,68,54,123,20,218,216,137,18,124,67,103,163,173,77,177,162,100,73,242, +136,108,244,117,169,181,193,18,36,248,134,207,79,74,155,99,132,200,147,229, +16,217,233,233,83,107,162,164,73,240,171,112,39,167,165,77,175,10,145,39, +194,173,192,158,182,165,54,191,153,51,72,71,161,196,201,45,167,146,59,68, +89,24,70,206,0,0,7,129,248,0,0,0,1,153,51,104,71,161,196,201,45,167,146,59, +68,89,24,70,206,0,0,7,129,248,0,0,0,1,153,51,136,71,161,196,201,45,167,146, +59,68,89,24,70,206,0,0,7,129,248,0,0,0,1,153,51,168,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,2,0,0,0,0,1,153,51,200,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,2,0,0,0,0,1,153,51,232,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,153,52,8,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,153,52,40,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,0,130,0,0,0,0,1,153,52,72,71,161,196,201,45,167, +146,59,68,89,24,70,206,0,0,1,2,0,0,0,0,1,135,52,102,32,76,72,1,246,136,235, +103,177,69,1,17,32,7,196,54,123,20,82,88,200,144,3,237,17,214,207,71,91, +171,37,20,65,145,32,7,218,35,173,158,142,183,66,74,41,16,92,72,1,241,13, +158,142,183,86,74,41,48,92,72,1,241,13,158,142,183,66,74,41,80,100,72,1, +246,136,235,103,167,165,213,146,138,40,200,144,3,237,17,214,207,79,75,161, +37,20,138,46,36,0,248,134,207,79,75,171,37,20,154,46,36,0,248,134,207,79, +75,161,37,20,170,46,36,0,248,85,184,19,234,201,69,24,92,72,1,240,171,112, +39,208,146,138,70,25,18,0,124,27,168,21,147,171,37,20,113,145,32,7,193,186, +129,89,58,18,81,72,226,162,64,15,180,71,91,62,172,148,90,0,168,144,3,237, +17,214,207,161,37,22,144,38,36,0,248,134,207,171,37,22,160,38,36,0,248,134, +207,161,37,22,176,42,209,68,201,218,35,173,158,197,54,4,218,40,153,56,134, +207,98,155,75,27,104,162,100,237,17,214,207,71,91,171,37,54,65,182,138,38, +78,209,29,108,244,117,186,18,83,104,131,45,20,76,156,67,103,163,173,213, +146,155,76,25,104,162,100,226,27,61,29,110,132,148,218,160,219,69,19,39, +104,142,182,122,122,93,89,41,178,141,180,81,50,118,136,235,103,167,165,208, +146,155,69,25,104,162,100,226,27,61,61,46,172,148,218,104,203,69,19,39,16, +217,233,233,116,36,166,213,70,90,40,153,56,85,184,19,234,201,77,152,101, +162,137,147,133,91,129,62,132,148,218,48,219,69,19,39,6,234,5,100,234,201, +77,156,109,162,137,147,131,117,2,178,116,36,166,209,197,218,40,153,59,68, +117,179,234,201,78,32,11,180,81,50,118,136,235,103,208,146,156,72,21,104, +162,100,226,27,62,172,148,226,128,171,69,19,39,16,217,244,36,167,22,53,123, +102,53,155,80,2,21,11,94,201,128,196,133,0,185,80,32,56,156,199,130,36,160, +72,16,78,126,54,48,5,146,208,34,82,72,1,109,20,76,155,120,28,34,1,225,32,5, +95,130,160,52,171,138,69,132,234,219,163,161,2,197,172,9,0,89,86,214,236, +31,86,221,40,8,69,220,199,253,231,63,95,193,122,183,27,72,144,17,197,125, +207,255,160,138,217,67,117,110,54,142,129,32,61,229,237,159,135,114,147,10, +130,235,209,3,236,132,37,0,96,181,17,80,63,101,8,207,71,107,74,4,245,7,49, +254,105,219,251,48,94,202,17,158,148,9,234,15,99,252,211,183,246,98,159, +129,228,176,192,185,127,46,155,185,41,197,13,55,38,3,127,255,20,138,160, +192,25,106,8,8,1,58,90,130,64,128,146,27,168,37,8,9,129,186,130,96,160,152, +27,165,171,64,32,131,25,234,10,64,65,17,11,212,19,133,18,243,167,165,163, +32,24,157,45,65,64,6,75,191,80,80,66,149,110,116,117,5,8,41,240,247,79,72, +188,8,134,81,122,84,1,173,198,212,20,48,139,113,180,181,5,36,42,220,109,29, +13,65,74,6,192,95,76,188,6,196,55,78,188,6,247,91,86,136,26,32,104,220,205, +72,1,98,234,52,122,130,136,18,72,51,117,68,3,146,27,168,40,161,37,8,207,80, +81,129,204,13,212,20,112,179,141,26,45,65,75,112,20,43,193,25,19,66,128, +153,78,40,105,144,92,104,152,131,124,27,253,128,0,10,116,3,68,146,163,9, +128,0,10,102,3,138,145,137,27,60,0,0,82,129,7,2,4,16,7,2,70,143,178,203, +164,237,35,14,25,10,134,147,143,139,158,72,207,28,54,77,47,109,13,55,113, +120,96,196,159,29,102,241,241,115,201,25,227,131,36,133,20,62,110,143,17, +16,113,137,62,62,46,155,167,135,147,142,47,44,151,79,221,64,98,37,194,94, +100,108,144,21,147,140,73,168,228,19,17,124,73,82,54,124,37,230,70,201,14, +108,185,36,155,14,243,243,83,212,69,131,132,4,12,137,114,168,37,166,145,7, +10,4,28,200,14,12,40,56,153,56,178,52,211,60,124,0,0,85,0,160,226,100,227, +138,89,18,113,240,0,1,86,1,131,66,148,145,143,128,0,10,144,93,134,0,0,43, +80,17,42,4,17,136,49,73,19,49,134,16,143,67,137,146,91,79,36,118,136,178, +48,141,156,0,0,15,3,240,0,0,0,3,49,135,16,143,67,137,146,91,79,36,118,136, +178,48,141,156,0,0,15,3,240,0,0,0,5,20,5,173,194,227,214,4,55,0,0,21,196,7, +122,192,134,241,197,192,0,5,121,25,140,64,132,122,28,76,146,218,121,35,180, +69,145,132,108,224,0,0,120,31,128,0,0,0,25,140,72,132,122,28,76,146,218, +121,35,180,69,145,132,108,224,0,0,0,32,0,0,0,0,25,140,80,132,122,28,76,146, +218,121,35,180,69,145,132,108,224,0,0,0,32,0,0,0,0,25,140,88,132,122,28,76, +146,218,121,35,180,69,145,132,108,224,0,0,8,32,0,0,0,0,25,140,96,132,122, +28,76,146,218,121,35,180,69,145,132,108,224,0,0,8,32,0,0,0,0,25,140,104, +132,122,28,76,146,218,121,35,180,69,145,132,108,224,0,0,8,32,0,0,0,0,25, +140,112,132,122,28,76,146,218,121,35,180,69,145,132,108,224,0,0,16,32,0,0, +0,0,16,113,225,0,48,156,209,2,122,244,5,34,92,35,68,225,161,166,218,16,33, +18,224,104,82,146,59,50,5,7,19,39,22,70,154,103,215,32,28,78,99,193,18,80, +70,131,165,1,205,34,8,35,68,225,161,166,239,255,4,12,70,137,195,39,248,73, +7,78,3,154,102,16,70,137,195,67,77,223,248,1,74,9,129,125,255,130,9,65,154, +232,147,161,115,59,255,5,64,195,32,156,50,126,197,14,2,3,107,173,213,0, }; #else #error invalid endianness defines diff -Nru duktape-2.3.0/src-separate/duk_builtins.h duktape-2.2.0/src-separate/duk_builtins.h --- duktape-2.3.0/src-separate/duk_builtins.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_builtins.h 2017-09-23 01:06:08.000000000 +0000 @@ -236,290 +236,278 @@ #define DUK_STRIDX_OWN_KEYS 75 /* 'ownKeys' */ #define DUK_HEAP_STRING_OWN_KEYS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_OWN_KEYS) #define DUK_HTHREAD_STRING_OWN_KEYS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_OWN_KEYS) -#define DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE 76 /* '\x81Symbol.toPrimitive\xff' */ -#define DUK_HEAP_STRING_WELLKNOWN_SYMBOL_TO_PRIMITIVE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE) -#define DUK_HTHREAD_STRING_WELLKNOWN_SYMBOL_TO_PRIMITIVE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE) -#define DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE 77 /* '\x81Symbol.hasInstance\xff' */ -#define DUK_HEAP_STRING_WELLKNOWN_SYMBOL_HAS_INSTANCE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE) -#define DUK_HTHREAD_STRING_WELLKNOWN_SYMBOL_HAS_INSTANCE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE) -#define DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG 78 /* '\x81Symbol.toStringTag\xff' */ -#define DUK_HEAP_STRING_WELLKNOWN_SYMBOL_TO_STRING_TAG(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG) -#define DUK_HTHREAD_STRING_WELLKNOWN_SYMBOL_TO_STRING_TAG(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG) -#define DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE 79 /* '\x81Symbol.isConcatSpreadable\xff' */ -#define DUK_HEAP_STRING_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE) -#define DUK_HTHREAD_STRING_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE) -#define DUK_STRIDX_SET_PROTOTYPE_OF 80 /* 'setPrototypeOf' */ +#define DUK_STRIDX_SET_PROTOTYPE_OF 76 /* 'setPrototypeOf' */ #define DUK_HEAP_STRING_SET_PROTOTYPE_OF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SET_PROTOTYPE_OF) #define DUK_HTHREAD_STRING_SET_PROTOTYPE_OF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SET_PROTOTYPE_OF) -#define DUK_STRIDX___PROTO__ 81 /* '__proto__' */ +#define DUK_STRIDX___PROTO__ 77 /* '__proto__' */ #define DUK_HEAP_STRING___PROTO__(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX___PROTO__) #define DUK_HTHREAD_STRING___PROTO__(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX___PROTO__) -#define DUK_STRIDX_TO_STRING 82 /* 'toString' */ +#define DUK_STRIDX_TO_STRING 78 /* 'toString' */ #define DUK_HEAP_STRING_TO_STRING(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_STRING) #define DUK_HTHREAD_STRING_TO_STRING(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_STRING) -#define DUK_STRIDX_TO_JSON 83 /* 'toJSON' */ +#define DUK_STRIDX_TO_JSON 79 /* 'toJSON' */ #define DUK_HEAP_STRING_TO_JSON(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_JSON) #define DUK_HTHREAD_STRING_TO_JSON(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_JSON) -#define DUK_STRIDX_TYPE 84 /* 'type' */ +#define DUK_STRIDX_TYPE 80 /* 'type' */ #define DUK_HEAP_STRING_TYPE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TYPE) #define DUK_HTHREAD_STRING_TYPE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TYPE) -#define DUK_STRIDX_DATA 85 /* 'data' */ +#define DUK_STRIDX_DATA 81 /* 'data' */ #define DUK_HEAP_STRING_DATA(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DATA) #define DUK_HTHREAD_STRING_DATA(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DATA) -#define DUK_STRIDX_LENGTH 86 /* 'length' */ +#define DUK_STRIDX_LENGTH 82 /* 'length' */ #define DUK_HEAP_STRING_LENGTH(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LENGTH) #define DUK_HTHREAD_STRING_LENGTH(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LENGTH) -#define DUK_STRIDX_SET 87 /* 'set' */ +#define DUK_STRIDX_SET 83 /* 'set' */ #define DUK_HEAP_STRING_SET(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SET) #define DUK_HTHREAD_STRING_SET(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SET) -#define DUK_STRIDX_STACK 88 /* 'stack' */ +#define DUK_STRIDX_STACK 84 /* 'stack' */ #define DUK_HEAP_STRING_STACK(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_STACK) #define DUK_HTHREAD_STRING_STACK(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_STACK) -#define DUK_STRIDX_PC 89 /* 'pc' */ +#define DUK_STRIDX_PC 85 /* 'pc' */ #define DUK_HEAP_STRING_PC(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PC) #define DUK_HTHREAD_STRING_PC(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PC) -#define DUK_STRIDX_LINE_NUMBER 90 /* 'lineNumber' */ +#define DUK_STRIDX_LINE_NUMBER 86 /* 'lineNumber' */ #define DUK_HEAP_STRING_LINE_NUMBER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LINE_NUMBER) #define DUK_HTHREAD_STRING_LINE_NUMBER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LINE_NUMBER) -#define DUK_STRIDX_INT_TRACEDATA 91 /* '\x82Tracedata' */ +#define DUK_STRIDX_INT_TRACEDATA 87 /* '\x82Tracedata' */ #define DUK_HEAP_STRING_INT_TRACEDATA(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_TRACEDATA) #define DUK_HTHREAD_STRING_INT_TRACEDATA(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_TRACEDATA) -#define DUK_STRIDX_NAME 92 /* 'name' */ +#define DUK_STRIDX_NAME 88 /* 'name' */ #define DUK_HEAP_STRING_NAME(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NAME) #define DUK_HTHREAD_STRING_NAME(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NAME) -#define DUK_STRIDX_FILE_NAME 93 /* 'fileName' */ +#define DUK_STRIDX_FILE_NAME 89 /* 'fileName' */ #define DUK_HEAP_STRING_FILE_NAME(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FILE_NAME) #define DUK_HTHREAD_STRING_FILE_NAME(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FILE_NAME) -#define DUK_STRIDX_LC_POINTER 94 /* 'pointer' */ +#define DUK_STRIDX_LC_POINTER 90 /* 'pointer' */ #define DUK_HEAP_STRING_LC_POINTER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_POINTER) #define DUK_HTHREAD_STRING_LC_POINTER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_POINTER) -#define DUK_STRIDX_INT_TARGET 95 /* '\x82Target' */ +#define DUK_STRIDX_INT_TARGET 91 /* '\x82Target' */ #define DUK_HEAP_STRING_INT_TARGET(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_TARGET) #define DUK_HTHREAD_STRING_INT_TARGET(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_TARGET) -#define DUK_STRIDX_INT_NEXT 96 /* '\x82Next' */ +#define DUK_STRIDX_INT_NEXT 92 /* '\x82Next' */ #define DUK_HEAP_STRING_INT_NEXT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_NEXT) #define DUK_HTHREAD_STRING_INT_NEXT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_NEXT) -#define DUK_STRIDX_INT_BYTECODE 97 /* '\x82Bytecode' */ +#define DUK_STRIDX_INT_BYTECODE 93 /* '\x82Bytecode' */ #define DUK_HEAP_STRING_INT_BYTECODE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_BYTECODE) #define DUK_HTHREAD_STRING_INT_BYTECODE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_BYTECODE) -#define DUK_STRIDX_INT_FORMALS 98 /* '\x82Formals' */ +#define DUK_STRIDX_INT_FORMALS 94 /* '\x82Formals' */ #define DUK_HEAP_STRING_INT_FORMALS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_FORMALS) #define DUK_HTHREAD_STRING_INT_FORMALS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_FORMALS) -#define DUK_STRIDX_INT_VARMAP 99 /* '\x82Varmap' */ +#define DUK_STRIDX_INT_VARMAP 95 /* '\x82Varmap' */ #define DUK_HEAP_STRING_INT_VARMAP(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VARMAP) #define DUK_HTHREAD_STRING_INT_VARMAP(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VARMAP) -#define DUK_STRIDX_INT_SOURCE 100 /* '\x82Source' */ +#define DUK_STRIDX_INT_SOURCE 96 /* '\x82Source' */ #define DUK_HEAP_STRING_INT_SOURCE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_SOURCE) #define DUK_HTHREAD_STRING_INT_SOURCE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_SOURCE) -#define DUK_STRIDX_INT_PC2LINE 101 /* '\x82Pc2line' */ +#define DUK_STRIDX_INT_PC2LINE 97 /* '\x82Pc2line' */ #define DUK_HEAP_STRING_INT_PC2LINE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_PC2LINE) #define DUK_HTHREAD_STRING_INT_PC2LINE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_PC2LINE) -#define DUK_STRIDX_INT_MAP 102 /* '\x82Map' */ +#define DUK_STRIDX_INT_MAP 98 /* '\x82Map' */ #define DUK_HEAP_STRING_INT_MAP(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_MAP) #define DUK_HTHREAD_STRING_INT_MAP(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_MAP) -#define DUK_STRIDX_INT_VARENV 103 /* '\x82Varenv' */ +#define DUK_STRIDX_INT_VARENV 99 /* '\x82Varenv' */ #define DUK_HEAP_STRING_INT_VARENV(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VARENV) #define DUK_HTHREAD_STRING_INT_VARENV(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VARENV) -#define DUK_STRIDX_INT_FINALIZER 104 /* '\x82Finalizer' */ +#define DUK_STRIDX_INT_FINALIZER 100 /* '\x82Finalizer' */ #define DUK_HEAP_STRING_INT_FINALIZER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_FINALIZER) #define DUK_HTHREAD_STRING_INT_FINALIZER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_FINALIZER) -#define DUK_STRIDX_INT_VALUE 105 /* '\x82Value' */ +#define DUK_STRIDX_INT_VALUE 101 /* '\x82Value' */ #define DUK_HEAP_STRING_INT_VALUE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VALUE) #define DUK_HTHREAD_STRING_INT_VALUE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VALUE) -#define DUK_STRIDX_COMPILE 106 /* 'compile' */ +#define DUK_STRIDX_COMPILE 102 /* 'compile' */ #define DUK_HEAP_STRING_COMPILE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_COMPILE) #define DUK_HTHREAD_STRING_COMPILE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_COMPILE) -#define DUK_STRIDX_INPUT 107 /* 'input' */ +#define DUK_STRIDX_INPUT 103 /* 'input' */ #define DUK_HEAP_STRING_INPUT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INPUT) #define DUK_HTHREAD_STRING_INPUT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INPUT) -#define DUK_STRIDX_ERR_CREATE 108 /* 'errCreate' */ +#define DUK_STRIDX_ERR_CREATE 104 /* 'errCreate' */ #define DUK_HEAP_STRING_ERR_CREATE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ERR_CREATE) #define DUK_HTHREAD_STRING_ERR_CREATE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ERR_CREATE) -#define DUK_STRIDX_ERR_THROW 109 /* 'errThrow' */ +#define DUK_STRIDX_ERR_THROW 105 /* 'errThrow' */ #define DUK_HEAP_STRING_ERR_THROW(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ERR_THROW) #define DUK_HTHREAD_STRING_ERR_THROW(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ERR_THROW) -#define DUK_STRIDX_ENV 110 /* 'env' */ +#define DUK_STRIDX_ENV 106 /* 'env' */ #define DUK_HEAP_STRING_ENV(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENV) #define DUK_HTHREAD_STRING_ENV(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENV) -#define DUK_STRIDX_HEX 111 /* 'hex' */ +#define DUK_STRIDX_HEX 107 /* 'hex' */ #define DUK_HEAP_STRING_HEX(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_HEX) #define DUK_HTHREAD_STRING_HEX(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_HEX) -#define DUK_STRIDX_BASE64 112 /* 'base64' */ +#define DUK_STRIDX_BASE64 108 /* 'base64' */ #define DUK_HEAP_STRING_BASE64(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BASE64) #define DUK_HTHREAD_STRING_BASE64(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BASE64) -#define DUK_STRIDX_JX 113 /* 'jx' */ +#define DUK_STRIDX_JX 109 /* 'jx' */ #define DUK_HEAP_STRING_JX(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JX) #define DUK_HTHREAD_STRING_JX(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JX) -#define DUK_STRIDX_JC 114 /* 'jc' */ +#define DUK_STRIDX_JC 110 /* 'jc' */ #define DUK_HEAP_STRING_JC(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JC) #define DUK_HTHREAD_STRING_JC(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JC) -#define DUK_STRIDX_JSON_EXT_UNDEFINED 115 /* '{"_undef":true}' */ +#define DUK_STRIDX_JSON_EXT_UNDEFINED 111 /* '{"_undef":true}' */ #define DUK_HEAP_STRING_JSON_EXT_UNDEFINED(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_UNDEFINED) #define DUK_HTHREAD_STRING_JSON_EXT_UNDEFINED(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_UNDEFINED) -#define DUK_STRIDX_JSON_EXT_NAN 116 /* '{"_nan":true}' */ +#define DUK_STRIDX_JSON_EXT_NAN 112 /* '{"_nan":true}' */ #define DUK_HEAP_STRING_JSON_EXT_NAN(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_NAN) #define DUK_HTHREAD_STRING_JSON_EXT_NAN(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_NAN) -#define DUK_STRIDX_JSON_EXT_POSINF 117 /* '{"_inf":true}' */ +#define DUK_STRIDX_JSON_EXT_POSINF 113 /* '{"_inf":true}' */ #define DUK_HEAP_STRING_JSON_EXT_POSINF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_POSINF) #define DUK_HTHREAD_STRING_JSON_EXT_POSINF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_POSINF) -#define DUK_STRIDX_JSON_EXT_NEGINF 118 /* '{"_ninf":true}' */ +#define DUK_STRIDX_JSON_EXT_NEGINF 114 /* '{"_ninf":true}' */ #define DUK_HEAP_STRING_JSON_EXT_NEGINF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_NEGINF) #define DUK_HTHREAD_STRING_JSON_EXT_NEGINF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_NEGINF) -#define DUK_STRIDX_JSON_EXT_FUNCTION1 119 /* '{"_func":true}' */ +#define DUK_STRIDX_JSON_EXT_FUNCTION1 115 /* '{"_func":true}' */ #define DUK_HEAP_STRING_JSON_EXT_FUNCTION1(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_FUNCTION1) #define DUK_HTHREAD_STRING_JSON_EXT_FUNCTION1(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_FUNCTION1) -#define DUK_STRIDX_JSON_EXT_FUNCTION2 120 /* '{_func:true}' */ +#define DUK_STRIDX_JSON_EXT_FUNCTION2 116 /* '{_func:true}' */ #define DUK_HEAP_STRING_JSON_EXT_FUNCTION2(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_FUNCTION2) #define DUK_HTHREAD_STRING_JSON_EXT_FUNCTION2(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_FUNCTION2) -#define DUK_STRIDX_BREAK 121 /* 'break' */ +#define DUK_STRIDX_BREAK 117 /* 'break' */ #define DUK_HEAP_STRING_BREAK(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BREAK) #define DUK_HTHREAD_STRING_BREAK(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BREAK) -#define DUK_STRIDX_CASE 122 /* 'case' */ +#define DUK_STRIDX_CASE 118 /* 'case' */ #define DUK_HEAP_STRING_CASE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CASE) #define DUK_HTHREAD_STRING_CASE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CASE) -#define DUK_STRIDX_CATCH 123 /* 'catch' */ +#define DUK_STRIDX_CATCH 119 /* 'catch' */ #define DUK_HEAP_STRING_CATCH(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CATCH) #define DUK_HTHREAD_STRING_CATCH(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CATCH) -#define DUK_STRIDX_CONTINUE 124 /* 'continue' */ +#define DUK_STRIDX_CONTINUE 120 /* 'continue' */ #define DUK_HEAP_STRING_CONTINUE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONTINUE) #define DUK_HTHREAD_STRING_CONTINUE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONTINUE) -#define DUK_STRIDX_DEBUGGER 125 /* 'debugger' */ +#define DUK_STRIDX_DEBUGGER 121 /* 'debugger' */ #define DUK_HEAP_STRING_DEBUGGER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEBUGGER) #define DUK_HTHREAD_STRING_DEBUGGER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEBUGGER) -#define DUK_STRIDX_DEFAULT 126 /* 'default' */ +#define DUK_STRIDX_DEFAULT 122 /* 'default' */ #define DUK_HEAP_STRING_DEFAULT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEFAULT) #define DUK_HTHREAD_STRING_DEFAULT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEFAULT) -#define DUK_STRIDX_DELETE 127 /* 'delete' */ +#define DUK_STRIDX_DELETE 123 /* 'delete' */ #define DUK_HEAP_STRING_DELETE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DELETE) #define DUK_HTHREAD_STRING_DELETE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DELETE) -#define DUK_STRIDX_DO 128 /* 'do' */ +#define DUK_STRIDX_DO 124 /* 'do' */ #define DUK_HEAP_STRING_DO(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DO) #define DUK_HTHREAD_STRING_DO(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DO) -#define DUK_STRIDX_ELSE 129 /* 'else' */ +#define DUK_STRIDX_ELSE 125 /* 'else' */ #define DUK_HEAP_STRING_ELSE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ELSE) #define DUK_HTHREAD_STRING_ELSE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ELSE) -#define DUK_STRIDX_FINALLY 130 /* 'finally' */ +#define DUK_STRIDX_FINALLY 126 /* 'finally' */ #define DUK_HEAP_STRING_FINALLY(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FINALLY) #define DUK_HTHREAD_STRING_FINALLY(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FINALLY) -#define DUK_STRIDX_FOR 131 /* 'for' */ +#define DUK_STRIDX_FOR 127 /* 'for' */ #define DUK_HEAP_STRING_FOR(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FOR) #define DUK_HTHREAD_STRING_FOR(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FOR) -#define DUK_STRIDX_LC_FUNCTION 132 /* 'function' */ +#define DUK_STRIDX_LC_FUNCTION 128 /* 'function' */ #define DUK_HEAP_STRING_LC_FUNCTION(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_FUNCTION) #define DUK_HTHREAD_STRING_LC_FUNCTION(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_FUNCTION) -#define DUK_STRIDX_IF 133 /* 'if' */ +#define DUK_STRIDX_IF 129 /* 'if' */ #define DUK_HEAP_STRING_IF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IF) #define DUK_HTHREAD_STRING_IF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IF) -#define DUK_STRIDX_IN 134 /* 'in' */ +#define DUK_STRIDX_IN 130 /* 'in' */ #define DUK_HEAP_STRING_IN(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IN) #define DUK_HTHREAD_STRING_IN(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IN) -#define DUK_STRIDX_INSTANCEOF 135 /* 'instanceof' */ +#define DUK_STRIDX_INSTANCEOF 131 /* 'instanceof' */ #define DUK_HEAP_STRING_INSTANCEOF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INSTANCEOF) #define DUK_HTHREAD_STRING_INSTANCEOF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INSTANCEOF) -#define DUK_STRIDX_NEW 136 /* 'new' */ +#define DUK_STRIDX_NEW 132 /* 'new' */ #define DUK_HEAP_STRING_NEW(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NEW) #define DUK_HTHREAD_STRING_NEW(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NEW) -#define DUK_STRIDX_RETURN 137 /* 'return' */ +#define DUK_STRIDX_RETURN 133 /* 'return' */ #define DUK_HEAP_STRING_RETURN(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_RETURN) #define DUK_HTHREAD_STRING_RETURN(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_RETURN) -#define DUK_STRIDX_SWITCH 138 /* 'switch' */ +#define DUK_STRIDX_SWITCH 134 /* 'switch' */ #define DUK_HEAP_STRING_SWITCH(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SWITCH) #define DUK_HTHREAD_STRING_SWITCH(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SWITCH) -#define DUK_STRIDX_THIS 139 /* 'this' */ +#define DUK_STRIDX_THIS 135 /* 'this' */ #define DUK_HEAP_STRING_THIS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_THIS) #define DUK_HTHREAD_STRING_THIS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_THIS) -#define DUK_STRIDX_THROW 140 /* 'throw' */ +#define DUK_STRIDX_THROW 136 /* 'throw' */ #define DUK_HEAP_STRING_THROW(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_THROW) #define DUK_HTHREAD_STRING_THROW(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_THROW) -#define DUK_STRIDX_TRY 141 /* 'try' */ +#define DUK_STRIDX_TRY 137 /* 'try' */ #define DUK_HEAP_STRING_TRY(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TRY) #define DUK_HTHREAD_STRING_TRY(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TRY) -#define DUK_STRIDX_TYPEOF 142 /* 'typeof' */ +#define DUK_STRIDX_TYPEOF 138 /* 'typeof' */ #define DUK_HEAP_STRING_TYPEOF(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TYPEOF) #define DUK_HTHREAD_STRING_TYPEOF(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TYPEOF) -#define DUK_STRIDX_VAR 143 /* 'var' */ +#define DUK_STRIDX_VAR 139 /* 'var' */ #define DUK_HEAP_STRING_VAR(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VAR) #define DUK_HTHREAD_STRING_VAR(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VAR) -#define DUK_STRIDX_CONST 144 /* 'const' */ +#define DUK_STRIDX_CONST 140 /* 'const' */ #define DUK_HEAP_STRING_CONST(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONST) #define DUK_HTHREAD_STRING_CONST(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONST) -#define DUK_STRIDX_VOID 145 /* 'void' */ +#define DUK_STRIDX_VOID 141 /* 'void' */ #define DUK_HEAP_STRING_VOID(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VOID) #define DUK_HTHREAD_STRING_VOID(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VOID) -#define DUK_STRIDX_WHILE 146 /* 'while' */ +#define DUK_STRIDX_WHILE 142 /* 'while' */ #define DUK_HEAP_STRING_WHILE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WHILE) #define DUK_HTHREAD_STRING_WHILE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WHILE) -#define DUK_STRIDX_WITH 147 /* 'with' */ +#define DUK_STRIDX_WITH 143 /* 'with' */ #define DUK_HEAP_STRING_WITH(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WITH) #define DUK_HTHREAD_STRING_WITH(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WITH) -#define DUK_STRIDX_CLASS 148 /* 'class' */ +#define DUK_STRIDX_CLASS 144 /* 'class' */ #define DUK_HEAP_STRING_CLASS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CLASS) #define DUK_HTHREAD_STRING_CLASS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CLASS) -#define DUK_STRIDX_ENUM 149 /* 'enum' */ +#define DUK_STRIDX_ENUM 145 /* 'enum' */ #define DUK_HEAP_STRING_ENUM(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENUM) #define DUK_HTHREAD_STRING_ENUM(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENUM) -#define DUK_STRIDX_EXPORT 150 /* 'export' */ +#define DUK_STRIDX_EXPORT 146 /* 'export' */ #define DUK_HEAP_STRING_EXPORT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EXPORT) #define DUK_HTHREAD_STRING_EXPORT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EXPORT) -#define DUK_STRIDX_EXTENDS 151 /* 'extends' */ +#define DUK_STRIDX_EXTENDS 147 /* 'extends' */ #define DUK_HEAP_STRING_EXTENDS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EXTENDS) #define DUK_HTHREAD_STRING_EXTENDS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EXTENDS) -#define DUK_STRIDX_IMPORT 152 /* 'import' */ +#define DUK_STRIDX_IMPORT 148 /* 'import' */ #define DUK_HEAP_STRING_IMPORT(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IMPORT) #define DUK_HTHREAD_STRING_IMPORT(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IMPORT) -#define DUK_STRIDX_SUPER 153 /* 'super' */ +#define DUK_STRIDX_SUPER 149 /* 'super' */ #define DUK_HEAP_STRING_SUPER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SUPER) #define DUK_HTHREAD_STRING_SUPER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SUPER) -#define DUK_STRIDX_LC_NULL 154 /* 'null' */ +#define DUK_STRIDX_LC_NULL 150 /* 'null' */ #define DUK_HEAP_STRING_LC_NULL(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_NULL) #define DUK_HTHREAD_STRING_LC_NULL(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_NULL) -#define DUK_STRIDX_TRUE 155 /* 'true' */ +#define DUK_STRIDX_TRUE 151 /* 'true' */ #define DUK_HEAP_STRING_TRUE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TRUE) #define DUK_HTHREAD_STRING_TRUE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TRUE) -#define DUK_STRIDX_FALSE 156 /* 'false' */ +#define DUK_STRIDX_FALSE 152 /* 'false' */ #define DUK_HEAP_STRING_FALSE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FALSE) #define DUK_HTHREAD_STRING_FALSE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FALSE) -#define DUK_STRIDX_IMPLEMENTS 157 /* 'implements' */ +#define DUK_STRIDX_IMPLEMENTS 153 /* 'implements' */ #define DUK_HEAP_STRING_IMPLEMENTS(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IMPLEMENTS) #define DUK_HTHREAD_STRING_IMPLEMENTS(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IMPLEMENTS) -#define DUK_STRIDX_INTERFACE 158 /* 'interface' */ +#define DUK_STRIDX_INTERFACE 154 /* 'interface' */ #define DUK_HEAP_STRING_INTERFACE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INTERFACE) #define DUK_HTHREAD_STRING_INTERFACE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INTERFACE) -#define DUK_STRIDX_LET 159 /* 'let' */ +#define DUK_STRIDX_LET 155 /* 'let' */ #define DUK_HEAP_STRING_LET(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LET) #define DUK_HTHREAD_STRING_LET(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LET) -#define DUK_STRIDX_PACKAGE 160 /* 'package' */ +#define DUK_STRIDX_PACKAGE 156 /* 'package' */ #define DUK_HEAP_STRING_PACKAGE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PACKAGE) #define DUK_HTHREAD_STRING_PACKAGE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PACKAGE) -#define DUK_STRIDX_PRIVATE 161 /* 'private' */ +#define DUK_STRIDX_PRIVATE 157 /* 'private' */ #define DUK_HEAP_STRING_PRIVATE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PRIVATE) #define DUK_HTHREAD_STRING_PRIVATE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PRIVATE) -#define DUK_STRIDX_PROTECTED 162 /* 'protected' */ +#define DUK_STRIDX_PROTECTED 158 /* 'protected' */ #define DUK_HEAP_STRING_PROTECTED(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PROTECTED) #define DUK_HTHREAD_STRING_PROTECTED(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PROTECTED) -#define DUK_STRIDX_PUBLIC 163 /* 'public' */ +#define DUK_STRIDX_PUBLIC 159 /* 'public' */ #define DUK_HEAP_STRING_PUBLIC(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PUBLIC) #define DUK_HTHREAD_STRING_PUBLIC(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PUBLIC) -#define DUK_STRIDX_STATIC 164 /* 'static' */ +#define DUK_STRIDX_STATIC 160 /* 'static' */ #define DUK_HEAP_STRING_STATIC(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_STATIC) #define DUK_HTHREAD_STRING_STATIC(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_STATIC) -#define DUK_STRIDX_YIELD 165 /* 'yield' */ +#define DUK_STRIDX_YIELD 161 /* 'yield' */ #define DUK_HEAP_STRING_YIELD(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_YIELD) #define DUK_HTHREAD_STRING_YIELD(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_YIELD) -#define DUK_HEAP_NUM_STRINGS 166 -#define DUK_STRIDX_START_RESERVED 121 -#define DUK_STRIDX_START_STRICT_RESERVED 157 -#define DUK_STRIDX_END_RESERVED 166 /* exclusive endpoint */ +#define DUK_HEAP_NUM_STRINGS 162 +#define DUK_STRIDX_START_RESERVED 117 +#define DUK_STRIDX_START_STRICT_RESERVED 153 +#define DUK_STRIDX_END_RESERVED 162 /* exclusive endpoint */ /* To convert a heap stridx to a token number, subtract * DUK_STRIDX_START_RESERVED and add DUK_TOK_START_RESERVED. */ #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_strings_data[967]; +DUK_INTERNAL_DECL const duk_uint8_t duk_strings_data[892]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_STRDATA_MAX_STRLEN 27 -#define DUK_STRDATA_DATA_LENGTH 967 +#define DUK_STRDATA_MAX_STRLEN 17 +#define DUK_STRDATA_DATA_LENGTH 892 #endif /* DUK_USE_ROM_STRINGS */ #if defined(DUK_USE_ROM_OBJECTS) @@ -536,8 +524,6 @@ DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_error_constructor_shared(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_type_error_thrower(duk_context *ctx); -DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_int(duk_context *ctx); -DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_float(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_thread_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_pointer_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_proxy_constructor(duk_context *ctx); @@ -548,6 +534,8 @@ DUK_INTERNAL_DECL duk_ret_t duk_bi_textencoder_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_textdecoder_constructor(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_eval(duk_context *ctx); +DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_int(duk_context *ctx); +DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_float(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_is_nan(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_is_finite(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_decode_uri(duk_context *ctx); @@ -619,7 +607,6 @@ DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_includes(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_substr(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_boolean_prototype_tostring_shared(duk_context *ctx); -DUK_INTERNAL_DECL duk_ret_t duk_bi_number_check_shared(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_string(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_locale_string(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_value_of(duk_context *ctx); @@ -702,7 +689,7 @@ DUK_INTERNAL_DECL duk_ret_t duk_bi_textdecoder_prototype_decode(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_performance_now(duk_context *ctx); #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_c_function duk_bi_native_functions[177]; +DUK_INTERNAL_DECL const duk_c_function duk_bi_native_functions[176]; #endif /* !DUK_SINGLE_FILE */ #define DUK_BIDX_GLOBAL 0 #define DUK_BIDX_GLOBAL_ENV 1 @@ -757,22 +744,22 @@ #define DUK_BIDX_NODEJS_BUFFER_PROTOTYPE 50 #define DUK_NUM_BUILTINS 51 #define DUK_NUM_BIDX_BUILTINS 51 -#define DUK_NUM_ALL_BUILTINS 78 +#define DUK_NUM_ALL_BUILTINS 76 #if defined(DUK_USE_DOUBLE_LE) #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4116]; +DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[3972]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_BUILTINS_DATA_LENGTH 4116 +#define DUK_BUILTINS_DATA_LENGTH 3972 #elif defined(DUK_USE_DOUBLE_BE) #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4116]; +DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[3972]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_BUILTINS_DATA_LENGTH 4116 +#define DUK_BUILTINS_DATA_LENGTH 3972 #elif defined(DUK_USE_DOUBLE_ME) #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4116]; +DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[3972]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_BUILTINS_DATA_LENGTH 4116 +#define DUK_BUILTINS_DATA_LENGTH 3972 #else #error invalid endianness defines #endif diff -Nru duktape-2.3.0/src-separate/duk_config.h duktape-2.2.0/src-separate/duk_config.h --- duktape-2.3.0/src-separate/duk_config.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_config.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,8 +1,8 @@ /* * duk_config.h configuration header generated by genconfig.py. * - * Git commit: d7fdb67f18561a50e06bafd196c6b423af9ad6fe - * Git describe: v2.3.0 + * Git commit: a459cf3c9bd1779fc01b435d69302b742675a08f + * Git describe: v2.2.0 * Git branch: master * * Supported platforms: @@ -218,6 +218,12 @@ #define DUK_F_UNIX #endif +/* C++ */ +#undef DUK_F_CPP +#if defined(__cplusplus) +#define DUK_F_CPP +#endif + /* Intel x86 (32-bit), x64 (64-bit) or x32 (64-bit but 32-bit pointers), * define only one of DUK_F_X86, DUK_F_X64, DUK_F_X32. * https://sites.google.com/site/x32abi/ @@ -295,12 +301,6 @@ #define DUK_F_CLANG #endif -/* C++ */ -#undef DUK_F_CPP -#if defined(__cplusplus) -#define DUK_F_CPP -#endif - /* C99 or above */ #undef DUK_F_C99 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) @@ -836,7 +836,9 @@ #include #endif -/* is only included if needed, based on DUK_USE_xxx flags. */ +#if defined(DUK_F_CPP) +#include /* std::exception */ +#endif /* * Architecture autodetection @@ -848,16 +850,13 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif - -#define DUK_USE_PACKED_TVAL - -/* FreeBSD, -m32, and clang prior to 5.0 has union aliasing issues which - * break duk_tval copying. Disable packed duk_tval automatically. +/* XXX: This is technically not guaranteed because it's possible to configure + * an x86 to require aligned accesses with Alignment Check (AC) flag. */ -#if defined(DUK_F_FREEBSD) && defined(DUK_F_X86) && \ - defined(__clang__) && defined(__clang_major__) && (__clang_major__ < 5) -#undef DUK_USE_PACKED_TVAL +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 1 #endif +#define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_X64) /* --- x64 --- */ @@ -865,6 +864,12 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif +/* XXX: This is technically not guaranteed because it's possible to configure + * an x86 to require aligned accesses with Alignment Check (AC) flag. + */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 1 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_X32) @@ -873,30 +878,48 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif +/* XXX: This is technically not guaranteed because it's possible to configure + * an x86 to require aligned accesses with Alignment Check (AC) flag. + */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 1 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_ARM32) /* --- ARM 32-bit --- */ #define DUK_USE_ARCH_STRING "arm32" /* Byte order varies, so rely on autodetect. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 4 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_ARM64) /* --- ARM 64-bit --- */ #define DUK_USE_ARCH_STRING "arm64" /* Byte order varies, so rely on autodetect. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_MIPS32) /* --- MIPS 32-bit --- */ #define DUK_USE_ARCH_STRING "mips32" /* MIPS byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_MIPS64) /* --- MIPS 64-bit --- */ #define DUK_USE_ARCH_STRING "mips64" /* MIPS byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_PPC32) @@ -905,6 +928,9 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_PPC64) @@ -913,24 +939,39 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_SPARC32) /* --- SPARC 32-bit --- */ #define DUK_USE_ARCH_STRING "sparc32" /* SPARC byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_SPARC64) /* --- SPARC 64-bit --- */ #define DUK_USE_ARCH_STRING "sparc64" /* SPARC byte order varies so rely on autodetection. */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_SUPERH) /* --- SuperH --- */ #define DUK_USE_ARCH_STRING "sh" /* Byte order varies, rely on autodetection. */ +/* Based on 'make checkalign' there are no alignment requirements on + * Linux SH4, but align by 4 is probably a good basic default. + */ +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 4 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_M68K) @@ -939,6 +980,9 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 3 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #define DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_EMSCRIPTEN) @@ -947,6 +991,9 @@ #if !defined(DUK_USE_BYTEORDER) #define DUK_USE_BYTEORDER 1 #endif +#if !defined(DUK_USE_ALIGN_BY) +#define DUK_USE_ALIGN_BY 8 +#endif #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED #else @@ -1958,8 +2005,8 @@ /* Boolean values are represented with the platform 'unsigned int'. */ typedef duk_small_uint_t duk_bool_t; -#define DUK_BOOL_MIN DUK_SMALL_UINT_MIN -#define DUK_BOOL_MAX DUK_SMALL_UINT_MAX +#define DUK_BOOL_MIN DUK_SMALL_INT_MIN +#define DUK_BOOL_MAX DUK_SMALL_INT_MAX /* Index values must have at least 32-bit signed range. */ typedef duk_int_t duk_idx_t; @@ -2493,13 +2540,10 @@ * * Assume unaligned accesses are not supported unless specifically allowed * in the target platform. Some platforms may support unaligned accesses - * but alignment to 4 or 8 may still be desirable. Note that unaligned - * accesses (and even pointers) relative to natural alignment (regardless - * of target alignment) are technically undefined behavior and thus - * compiler/architecture specific. + * but alignment to 4 or 8 may still be desirable. */ -/* If not forced, use safe default for alignment. */ +/* If not provided, use safe default for alignment. */ #if !defined(DUK_USE_ALIGN_BY) #define DUK_USE_ALIGN_BY 8 #endif @@ -2551,7 +2595,6 @@ */ #define DUK_CAUSE_SEGFAULT() do { *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; } while (0) #endif - #if !defined(DUK_UNREF) /* Macro for suppressing warnings for potentially unreferenced variables. * The variables can be actually unreferenced or unreferenced in some @@ -2561,24 +2604,9 @@ */ #define DUK_UNREF(x) do { (void) (x); } while (0) #endif - -/* Fillin for DUK_NORETURN; DUK_WO_NORETURN() is used to insert dummy - * dummy statements after noreturn calls to silence harmless compiler - * warnings, e.g.: - * - * DUK_ERROR_TYPE(thr, "aiee"); - * DUK_WO_NORETURN(return 0;); - * - * Statements inside DUK_WO_NORETURN() must NEVER be actually reachable, - * and they're only included to satisfy the compiler. - */ -#if defined(DUK_NORETURN) -#define DUK_WO_NORETURN(stmt) do { } while (0) -#else +#if !defined(DUK_NORETURN) #define DUK_NORETURN(decl) decl -#define DUK_WO_NORETURN(stmt) do { stmt } while (0) #endif - #if !defined(DUK_UNREACHABLE) /* Don't know how to declare unreachable point, so don't do it; this * may cause some spurious compilation warnings (e.g. "variable used @@ -2586,7 +2614,6 @@ */ #define DUK_UNREACHABLE() do { } while (0) #endif - #if !defined(DUK_LOSE_CONST) /* Convert any input pointer into a "void *", losing a const qualifier. * This is not fully portable because casting through duk_uintptr_t may @@ -2754,8 +2781,8 @@ #if defined(DUK_F_PACKED_TVAL_POSSIBLE) #define DUK_USE_PACKED_TVAL #endif -#undef DUK_F_PACKED_TVAL_POSSIBLE +#undef DUK_F_PACKED_TVAL_POSSIBLE #endif /* DUK_F_PACKED_TVAL_PROVIDED */ /* Object property allocation layout has implications for memory and code * footprint and generated code size/speed. The best layout also depends @@ -2790,7 +2817,6 @@ * Autogenerated defaults */ -#undef DUK_USE_ALLOW_UNDEFINED_BEHAVIOR #define DUK_USE_ARRAY_BUILTIN #define DUK_USE_ARRAY_FASTPATH #define DUK_USE_ARRAY_PROP_FASTPATH @@ -2799,7 +2825,6 @@ #define DUK_USE_AUGMENT_ERROR_THROW #define DUK_USE_AVOID_PLATFORM_FUNCPTRS #define DUK_USE_BASE64_FASTPATH -#define DUK_USE_BASE64_SUPPORT #define DUK_USE_BOOLEAN_BUILTIN #define DUK_USE_BUFFEROBJECT_SUPPORT #undef DUK_USE_BUFLEN16 @@ -2877,7 +2902,6 @@ #undef DUK_USE_HEAPPTR_DEC16 #undef DUK_USE_HEAPPTR_ENC16 #define DUK_USE_HEX_FASTPATH -#define DUK_USE_HEX_SUPPORT #define DUK_USE_HOBJECT_ARRAY_ABANDON_LIMIT 2 #define DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT 9 #define DUK_USE_HOBJECT_ARRAY_MINGROW_ADD 16 @@ -2908,10 +2932,11 @@ #define DUK_USE_JX #define DUK_USE_LEXER_SLIDING_WINDOW #undef DUK_USE_LIGHTFUNC_BUILTINS -#define DUK_USE_LITCACHE_SIZE 256 #define DUK_USE_MARK_AND_SWEEP_RECLIMIT 256 #define DUK_USE_MATH_BUILTIN #define DUK_USE_NATIVE_CALL_RECLIMIT 1000 +#define DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER +#define DUK_USE_NONSTD_ARRAY_MAP_TRAILER #define DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT #undef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY #undef DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY @@ -2987,15 +3012,6 @@ /* __OVERRIDE_DEFINES__ */ /* - * Conditional includes - */ - -#if defined(DUK_F_CPP) && defined(DUK_USE_CPP_EXCEPTIONS) -#include /* std::exception */ -#include /* std::runtime_error */ -#endif - -/* * Date provider selection * * User may define DUK_USE_DATE_GET_NOW() etc directly, in which case we'll @@ -3536,12 +3552,6 @@ #if defined(DUK_USE_MS_STRINGTABLE_RESIZE) #error unsupported config option used (option has been removed): DUK_USE_MS_STRINGTABLE_RESIZE #endif -#if defined(DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER) -#error unsupported config option used (option has been removed): DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER -#endif -#if defined(DUK_USE_NONSTD_ARRAY_MAP_TRAILER) -#error unsupported config option used (option has been removed): DUK_USE_NONSTD_ARRAY_MAP_TRAILER -#endif #if defined(DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE) #error unsupported config option used (option has been removed): DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE #endif diff -Nru duktape-2.3.0/src-separate/duk_debug_fixedbuffer.c duktape-2.2.0/src-separate/duk_debug_fixedbuffer.c --- duktape-2.3.0/src-separate/duk_debug_fixedbuffer.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_debug_fixedbuffer.c 2017-09-23 01:06:08.000000000 +0000 @@ -18,7 +18,7 @@ } else { copylen = length; } - duk_memcpy_unsafe(fb->buffer + fb->offset, buffer, copylen); + DUK_MEMCPY(fb->buffer + fb->offset, buffer, copylen); fb->offset += copylen; } diff -Nru duktape-2.3.0/src-separate/duk_debugger.c duktape-2.2.0/src-separate/duk_debugger.c --- duktape-2.3.0/src-separate/duk_debugger.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_debugger.c 2017-09-23 01:06:08.000000000 +0000 @@ -309,7 +309,6 @@ DUK_ASSERT(thr != NULL); heap = thr->heap; DUK_ASSERT(heap != NULL); - DUK_ASSERT(data != NULL); if (heap->dbg_read_cb == NULL) { DUK_D(DUK_DPRINT("attempt to read %ld bytes in detached state, return zero data", (long) length)); @@ -347,7 +346,7 @@ return; fail: - duk_memzero((void *) data, (size_t) length); + DUK_MEMZERO((void *) data, (size_t) length); } DUK_INTERNAL duk_uint8_t duk_debug_read_byte(duk_hthread *thr) { @@ -960,7 +959,7 @@ (unsigned int) du2.uc[4], (unsigned int) du2.uc[5], (unsigned int) du2.uc[6], (unsigned int) du2.uc[7])); - if (duk_memcmp((const void *) du1.uc, (const void *) du2.uc, sizeof(du1.uc)) == 0) { + if (DUK_MEMCMP((const void *) du1.uc, (const void *) du2.uc, sizeof(du1.uc)) == 0) { duk_debug_write_int(thr, i32); } else { DUK_DBLUNION_DOUBLE_HTON(&du1); @@ -1069,9 +1068,9 @@ duk_debug_write_int(thr, 0); } else { duk_push_tval(thr, &act->tv_func); - duk_get_prop_literal(thr, -1, "fileName"); + duk_get_prop_string(thr, -1, "fileName"); duk__debug_write_hstring_safe_top(thr); - duk_get_prop_literal(thr, -2, "name"); + duk_get_prop_string(thr, -2, "name"); duk__debug_write_hstring_safe_top(thr); duk_pop_3(thr); /* Report next pc/line to be executed. */ @@ -1116,7 +1115,7 @@ act = thr->callstack_curr; if (act != NULL) { duk_push_tval(thr, &act->tv_func); - duk_get_prop_literal(thr, -1, "fileName"); + duk_get_prop_string(thr, -1, "fileName"); duk__debug_write_hstring_safe_top(thr); pc = (duk_uint32_t) duk_hthread_get_act_prev_pc(thr, act); duk_debug_write_uint(thr, (duk_uint32_t) duk_hobject_pc2line_query(thr, -2, pc)); @@ -1593,7 +1592,7 @@ fun = DUK_ACT_GET_FUNC(act); if (fun != NULL && DUK_HOBJECT_IS_COMPFUNC(fun)) { /* Direct eval requires that there's a current - * activation and it is an ECMAScript function. + * activation and it is an Ecmascript function. * When Eval is executed from e.g. cooperate API * call we'll need to do an indirect eval instead. */ @@ -2259,7 +2258,7 @@ if (DUK_HOBJECT_IS_BOUNDFUNC(h_obj)) { duk_hboundfunc *h_bfun; - h_bfun = (duk_hboundfunc *) (void *) h_obj; + h_bfun = (duk_hboundfunc *) h_obj; duk__debug_getinfo_flags_key(thr, "target"); duk_debug_write_tval(thr, &h_bfun->target); @@ -2736,7 +2735,7 @@ fun = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act); /* Short circuit if is safe: if act->curr_pc != NULL, 'fun' is - * guaranteed to be a non-NULL ECMAScript function. + * guaranteed to be a non-NULL Ecmascript function. */ DUK_ASSERT(act->curr_pc == NULL || (fun != NULL && DUK_HOBJECT_IS_COMPFUNC((duk_hobject *) fun))); @@ -2832,10 +2831,11 @@ DUK_ASSERT(h != NULL); move_size = sizeof(duk_breakpoint) * (heap->dbg_breakpoint_count - breakpoint_index - 1); - duk_memmove((void *) b, - (const void *) (b + 1), - (size_t) move_size); - + if (move_size > 0) { + DUK_MEMMOVE((void *) b, + (const void *) (b + 1), + (size_t) move_size); + } heap->dbg_breakpoint_count--; heap->dbg_breakpoints_active[0] = (duk_breakpoint *) NULL; diff -Nru duktape-2.3.0/src-separate/duk_debug_macros.c duktape-2.2.0/src-separate/duk_debug_macros.c --- duktape-2.3.0/src-separate/duk_debug_macros.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_debug_macros.c 2017-09-23 01:06:08.000000000 +0000 @@ -33,7 +33,7 @@ va_start(ap, fmt); - duk_memzero((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); + DUK_MEMZERO((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); duk_debug_vsnprintf(buf, DUK__DEBUG_BUFSIZE - 1, fmt, ap); arg_level = (long) level; @@ -64,7 +64,7 @@ va_start(ap, fmt); - duk_memzero((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); + DUK_MEMZERO((void *) buf, (size_t) DUK__DEBUG_BUFSIZE); duk_debug_vsnprintf(buf, DUK__DEBUG_BUFSIZE - 1, fmt, ap); arg_level = (long) duk_debug_level_stash; diff -Nru duktape-2.3.0/src-separate/duk_debug_vsnprintf.c duktape-2.2.0/src-separate/duk_debug_vsnprintf.c --- duktape-2.3.0/src-separate/duk_debug_vsnprintf.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_debug_vsnprintf.c 2017-09-23 01:06:08.000000000 +0000 @@ -35,7 +35,7 @@ * (excluding the null terminator). If retval == buffer size, * output was truncated (except for corner cases). * - * * Output format is intentionally different from ECMAScript + * * Output format is intentionally different from Ecmascript * formatting requirements, as formatting here serves debugging * of internals. * @@ -821,7 +821,7 @@ const char *p_end = p + DUK_STRLEN(format); duk_int_t retval; - duk_memzero(&fb, sizeof(fb)); + DUK_MEMZERO(&fb, sizeof(fb)); fb.buffer = (duk_uint8_t *) str; fb.length = size; fb.offset = 0; @@ -846,7 +846,7 @@ * understand. See man 3 printf. */ - duk_memzero(&st, sizeof(st)); + DUK_MEMZERO(&st, sizeof(st)); st.fb = &fb; st.depth = 0; st.depth_limit = 1; @@ -913,8 +913,8 @@ /* format is too large, abort */ goto format_error; } - duk_memzero(fmtbuf, sizeof(fmtbuf)); - duk_memcpy(fmtbuf, p_begfmt, fmtlen); + DUK_MEMZERO(fmtbuf, sizeof(fmtbuf)); + DUK_MEMCPY(fmtbuf, p_begfmt, fmtlen); /* assume exactly 1 arg, which is why '*' is forbidden; arg size still * depends on type though. @@ -1019,8 +1019,7 @@ duk_uint8_t *p = (duk_uint8_t *) buf; duk_uint8_t *p_end = (duk_uint8_t *) (buf + buf_size - 1); - DUK_ASSERT(buf != NULL); - duk_memzero(buf, buf_size); + DUK_MEMZERO(buf, buf_size); for (i = 0; i < fptr_size; i++) { duk_int_t left = (duk_int_t) (p_end - p); diff -Nru duktape-2.3.0/src-separate/duk_error_augment.c duktape-2.2.0/src-separate/duk_error_augment.c --- duktape-2.3.0/src-separate/duk_error_augment.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_error_augment.c 2017-09-23 01:06:08.000000000 +0000 @@ -14,7 +14,7 @@ * * Error augmentation may throw an internal error (e.g. alloc error). * - * ECMAScript allows throwing any values, so all values cannot be + * Ecmascript allows throwing any values, so all values cannot be * augmented. Currently, the built-in augmentation at error creation * only augments error values which are Error instances (= have the * built-in Error.prototype in their prototype chain) and are also @@ -354,6 +354,7 @@ DUK_UNREF(pc); DUK_ASSERT_DISABLE(pc >= 0); /* unsigned */ DUK_ASSERT((duk_double_t) pc < DUK_DOUBLE_2TO32); /* assume PC is at most 32 bits and non-negative */ + act = NULL; /* invalidated by pushes, so get out of the way */ duk_push_hobject(thr, func); diff -Nru duktape-2.3.0/src-separate/duk_error.h duktape-2.2.0/src-separate/duk_error.h --- duktape-2.3.0/src-separate/duk_error.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_error.h 2017-09-23 01:06:08.000000000 +0000 @@ -20,8 +20,8 @@ * Error codes: defined in duktape.h * * Error codes are used as a shorthand to throw exceptions from inside - * the implementation. The appropriate ECMAScript object is constructed - * based on the code. ECMAScript code throws objects directly. The error + * the implementation. The appropriate Ecmascript object is constructed + * based on the code. Ecmascript code throws objects directly. The error * codes are defined in the public API header because they are also used * by calling code. */ @@ -423,7 +423,7 @@ #if defined(DUK_USE_ASSERTIONS) #define DUK_ASSERT_SET_GARBAGE(ptr,size) do { \ - duk_memset_unsafe((void *) (ptr), 0x5a, size); \ + DUK_MEMSET((void *) (ptr), 0x5a, size); \ } while (0) #else #define DUK_ASSERT_SET_GARBAGE(ptr,size) do {} while (0) diff -Nru duktape-2.3.0/src-separate/duk_error_longjmp.c duktape-2.2.0/src-separate/duk_error_longjmp.c --- duktape-2.3.0/src-separate/duk_error_longjmp.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_error_longjmp.c 2017-09-23 01:06:08.000000000 +0000 @@ -6,15 +6,12 @@ #include "duk_internal.h" #if defined(DUK_USE_PREFER_SIZE) -DUK_NORETURN(DUK_LOCAL_DECL void duk__uncaught_minimal(duk_hthread *thr)); DUK_LOCAL void duk__uncaught_minimal(duk_hthread *thr) { (void) duk_fatal(thr, "uncaught error"); - DUK_WO_NORETURN(return;); } #endif #if 0 -DUK_NORETURN(DUK_LOCAL_DECL void duk__uncaught_readable(duk_hthread *thr)); DUK_LOCAL void duk__uncaught_readable(duk_hthread *thr) { const char *summary; char buf[DUK_USE_FATAL_MAXLEN]; @@ -23,12 +20,10 @@ DUK_SNPRINTF(buf, sizeof(buf), "uncaught: %s", summary); buf[sizeof(buf) - 1] = (char) 0; (void) duk_fatal(thr, (const char *) buf); - DUK_WO_NORETURN(return;); } #endif #if !defined(DUK_USE_PREFER_SIZE) -DUK_NORETURN(DUK_LOCAL_DECL void duk__uncaught_error_aware(duk_hthread *thr)); DUK_LOCAL void duk__uncaught_error_aware(duk_hthread *thr) { const char *summary; char buf[DUK_USE_FATAL_MAXLEN]; @@ -38,7 +33,6 @@ DUK_SNPRINTF(buf, sizeof(buf), "uncaught: %s", summary); buf[sizeof(buf) - 1] = (char) 0; (void) duk_fatal(thr, (const char *) buf); - DUK_WO_NORETURN(return;); } #endif @@ -76,9 +70,14 @@ DUK_DD(DUK_DDPRINT("about to longjmp, pf_prevent_count=%ld", (long) thr->heap->pf_prevent_count)); +#if !defined(DUK_USE_CPP_EXCEPTIONS) /* If we don't have a jmpbuf_ptr, there is little we can do except * cause a fatal error. The caller's expectation is that we never * return. + * + * With C++ exceptions we now just propagate an uncaught error + * instead of invoking the fatal error handler. Because there's + * a dummy jmpbuf for C++ exceptions now, this could be changed. */ if (!thr->heap->lj.jmpbuf_ptr) { DUK_D(DUK_DPRINT("uncaught error: type=%d iserror=%d value1=%!T value2=%!T", @@ -92,12 +91,16 @@ #endif DUK_UNREACHABLE(); } +#endif /* DUK_USE_CPP_EXCEPTIONS */ #if defined(DUK_USE_CPP_EXCEPTIONS) - throw duk_internal_exception(); /* dummy */ -#else + { + duk_internal_exception exc; /* dummy */ + throw exc; + } +#else /* DUK_USE_CPP_EXCEPTIONS */ DUK_LONGJMP(thr->heap->lj.jmpbuf_ptr->jb); -#endif +#endif /* DUK_USE_CPP_EXCEPTIONS */ DUK_UNREACHABLE(); } diff -Nru duktape-2.3.0/src-separate/duk_error_macros.c duktape-2.2.0/src-separate/duk_error_macros.c --- duktape-2.3.0/src-separate/duk_error_macros.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_error_macros.c 2017-09-23 01:06:08.000000000 +0000 @@ -113,18 +113,10 @@ DUK_UNREF(udata); DUK_UNREF(msg); - msg = msg ? msg : "NULL"; - #if defined(DUK_USE_FATAL_HANDLER) /* duk_config.h provided a custom default fatal handler. */ - DUK_D(DUK_DPRINT("custom default fatal error handler called: %s", msg)); + DUK_D(DUK_DPRINT("custom default fatal error handler called: %s", msg ? msg : "NULL")); DUK_USE_FATAL_HANDLER(udata, msg); -#elif defined(DUK_USE_CPP_EXCEPTIONS) - /* With C++ use a duk_fatal_exception which user code can catch in - * a natural way. - */ - DUK_D(DUK_DPRINT("built-in default C++ fatal error handler called: %s", msg)); - throw duk_fatal_exception(msg); #else /* Default behavior is to abort() on error. There's no printout * which makes this awkward, so it's always recommended to use an @@ -141,7 +133,7 @@ * - http://duktape.org/api.html#taglist-protected * ==================================================================== */ - DUK_D(DUK_DPRINT("built-in default fatal error handler called: %s", msg)); + DUK_D(DUK_DPRINT("built-in default fatal error handler called: %s", msg ? msg : "NULL")); DUK_ABORT(); #endif diff -Nru duktape-2.3.0/src-separate/duk_error_throw.c duktape-2.2.0/src-separate/duk_error_throw.c --- duktape-2.3.0/src-separate/duk_error_throw.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_error_throw.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,8 +1,8 @@ /* - * Create and throw an ECMAScript error object based on a code and a message. + * Create and throw an Ecmascript error object based on a code and a message. * - * Used when we throw errors internally. ECMAScript generated error objects - * are created by ECMAScript code, and the throwing is handled by the bytecode + * Used when we throw errors internally. Ecmascript generated error objects + * are created by Ecmascript code, and the throwing is handled by the bytecode * executor. */ @@ -158,5 +158,5 @@ */ duk_error_raw(thr, -rc, NULL, 0, "error (rc %ld)", (long) rc); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); } diff -Nru duktape-2.3.0/src-separate/duk_exception.h duktape-2.2.0/src-separate/duk_exception.h --- duktape-2.3.0/src-separate/duk_exception.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_exception.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,30 +1,18 @@ /* - * Exceptions for Duktape internal throws when C++ exceptions are used + * Exception for Duktape internal throws when C++ exceptions are used * for long control transfers. + * + * Doesn't inherit from any exception base class to minimize the chance + * that user code would accidentally catch this exception. */ #if !defined(DUK_EXCEPTION_H_INCLUDED) #define DUK_EXCEPTION_H_INCLUDED #if defined(DUK_USE_CPP_EXCEPTIONS) -/* Internal exception used as a setjmp-longjmp replacement. User code should - * NEVER see or catch this exception, so it doesn't inherit from any base - * class which should minimize the chance of user code accidentally catching - * the exception. - */ class duk_internal_exception { /* intentionally empty */ }; - -/* Fatal error, thrown as a specific C++ exception with C++ exceptions - * enabled. It is unsafe to continue; doing so may cause crashes or memory - * leaks. This is intended to be either uncaught, or caught by user code - * aware of the "unsafe to continue" semantics. - */ -class duk_fatal_exception : public virtual std::runtime_error { - public: - duk_fatal_exception(const char *message) : std::runtime_error(message) {} -}; #endif #endif /* DUK_EXCEPTION_H_INCLUDED */ diff -Nru duktape-2.3.0/src-separate/duk_forwdecl.h duktape-2.2.0/src-separate/duk_forwdecl.h --- duktape-2.3.0/src-separate/duk_forwdecl.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_forwdecl.h 2017-09-23 01:06:08.000000000 +0000 @@ -44,9 +44,8 @@ struct duk_activation; struct duk_catcher; +struct duk_strcache; struct duk_ljstate; -struct duk_strcache_entry; -struct duk_litcache_entry; struct duk_strtab_entry; #if defined(DUK_USE_DEBUG) @@ -105,9 +104,8 @@ typedef struct duk_activation duk_activation; typedef struct duk_catcher duk_catcher; +typedef struct duk_strcache duk_strcache; typedef struct duk_ljstate duk_ljstate; -typedef struct duk_strcache_entry duk_strcache_entry; -typedef struct duk_litcache_entry duk_litcache_entry; typedef struct duk_strtab_entry duk_strtab_entry; #if defined(DUK_USE_DEBUG) diff -Nru duktape-2.3.0/src-separate/duk_hbuffer_alloc.c duktape-2.2.0/src-separate/duk_hbuffer_alloc.c --- duktape-2.3.0/src-separate/duk_hbuffer_alloc.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hbuffer_alloc.c 2017-09-23 01:06:08.000000000 +0000 @@ -47,10 +47,10 @@ /* zero everything unless requested not to do so */ #if defined(DUK_USE_ZERO_BUFFER_DATA) - duk_memzero((void *) res, + DUK_MEMZERO((void *) res, (flags & DUK_BUF_FLAG_NOZERO) ? header_size : alloc_size); #else - duk_memzero((void *) res, header_size); + DUK_MEMZERO((void *) res, header_size); #endif if (flags & DUK_BUF_FLAG_EXTERNAL) { @@ -97,7 +97,7 @@ DUK_ASSERT(DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap, h) == NULL); } } else { - *out_bufdata = (void *) ((duk_hbuffer_fixed *) (void *) res + 1); + *out_bufdata = (void *) ((duk_hbuffer_fixed *) res + 1); } DUK_HBUFFER_SET_SIZE(res, size); diff -Nru duktape-2.3.0/src-separate/duk_hbuffer.h duktape-2.2.0/src-separate/duk_hbuffer.h --- duktape-2.3.0/src-separate/duk_hbuffer.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hbuffer.h 2017-09-23 01:06:08.000000000 +0000 @@ -94,7 +94,7 @@ #define DUK_HBUFFER_EXTERNAL_GET_SIZE(x) DUK_HBUFFER_GET_SIZE((duk_hbuffer *) (x)) #define DUK_HBUFFER_EXTERNAL_SET_SIZE(x,v) DUK_HBUFFER_SET_SIZE((duk_hbuffer *) (x), (v)) -#define DUK_HBUFFER_FIXED_GET_DATA_PTR(heap,x) ((duk_uint8_t *) (((duk_hbuffer_fixed *) (void *) (x)) + 1)) +#define DUK_HBUFFER_FIXED_GET_DATA_PTR(heap,x) ((duk_uint8_t *) (((duk_hbuffer_fixed *) (x)) + 1)) #if defined(DUK_USE_HEAPPTR16) #define DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap,x) \ @@ -149,7 +149,7 @@ DUK_HBUFFER_EXTERNAL_GET_DATA_PTR((heap), (duk_hbuffer_external *) (x)) : \ DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((heap), (duk_hbuffer_dynamic *) (x)) \ ) : \ - DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (void *) (x)) \ + DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (x)) \ ) #else /* Without heap pointer compression duk_hbuffer_dynamic and duk_hbuffer_external @@ -158,7 +158,7 @@ #define DUK_HBUFFER_GET_DATA_PTR(heap,x) ( \ DUK_HBUFFER_HAS_DYNAMIC((x)) ? \ DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((heap), (duk_hbuffer_dynamic *) (x)) : \ - DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (void *) (x)) \ + DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (x)) \ ) #endif @@ -232,10 +232,7 @@ #if (DUK_USE_ALIGN_BY == 4) duk_uint32_t dummy_for_align4; #elif (DUK_USE_ALIGN_BY == 8) - duk_double_t dummy_for_align8_1; -#if defined(DUK_USE_64BIT_OPS) - duk_uint64_t dummy_for_align8_2; -#endif + duk_double_t dummy_for_align8; #elif (DUK_USE_ALIGN_BY == 1) /* no extra padding */ #else diff -Nru duktape-2.3.0/src-separate/duk_hbuffer_ops.c duktape-2.2.0/src-separate/duk_hbuffer_ops.c --- duktape-2.3.0/src-separate/duk_hbuffer_ops.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hbuffer_ops.c 2017-09-23 01:06:08.000000000 +0000 @@ -24,7 +24,6 @@ if (new_size > DUK_HBUFFER_MAX_BYTELEN) { DUK_ERROR_RANGE(thr, "buffer too long"); - DUK_WO_NORETURN(return;); } /* @@ -53,7 +52,7 @@ if (new_size > prev_size) { DUK_ASSERT(new_size - prev_size > 0); #if defined(DUK_USE_ZERO_BUFFER_DATA) - duk_memzero((void *) ((char *) res + prev_size), + DUK_MEMZERO((void *) ((char *) res + prev_size), (duk_size_t) (new_size - prev_size)); #endif } @@ -62,7 +61,6 @@ DUK_HBUFFER_DYNAMIC_SET_DATA_PTR(thr->heap, buf, res); } else { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return;); } DUK_ASSERT(res != NULL || new_size == 0); diff -Nru duktape-2.3.0/src-separate/duk_hbufobj.h duktape-2.2.0/src-separate/duk_hbufobj.h --- duktape-2.3.0/src-separate/duk_hbufobj.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hbufobj.h 2017-09-23 01:06:08.000000000 +0000 @@ -47,8 +47,7 @@ } while (0) /* Get the current data pointer (caller must ensure buf != NULL) as a - * duk_uint8_t ptr. Note that the result may be NULL if the underlying - * buffer has zero size and is not a fixed buffer. + * duk_uint8_t ptr. */ #define DUK_HBUFOBJ_GET_SLICE_BASE(heap,h) \ (DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \ diff -Nru duktape-2.3.0/src-separate/duk_hcompfunc.h duktape-2.2.0/src-separate/duk_hcompfunc.h --- duktape-2.3.0/src-separate/duk_hcompfunc.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hcompfunc.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,7 +1,7 @@ /* - * Heap compiled function (ECMAScript function) representation. + * Heap compiled function (Ecmascript function) representation. * - * There is a single data buffer containing the ECMAScript function's + * There is a single data buffer containing the Ecmascript function's * bytecode, constants, and inner functions. */ diff -Nru duktape-2.3.0/src-separate/duk_heap_alloc.c duktape-2.2.0/src-separate/duk_heap_alloc.c --- duktape-2.3.0/src-separate/duk_heap_alloc.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_heap_alloc.c 2017-09-23 01:06:08.000000000 +0000 @@ -66,7 +66,7 @@ * functions in the callstack. */ } else if (DUK_HOBJECT_IS_BOUNDFUNC(h)) { - duk_hboundfunc *f = (duk_hboundfunc *) (void *) h; + duk_hboundfunc *f = (duk_hboundfunc *) h; DUK_FREE(heap, f->args); } @@ -464,7 +464,7 @@ duk_bitdecoder_ctx *bd = &bd_ctx; /* convenience */ duk_small_uint_t i; - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); bd->data = (const duk_uint8_t *) duk_strings_data; bd->length = (duk_size_t) DUK_STRDATA_DATA_LENGTH; @@ -685,8 +685,7 @@ DUK__DUMPSZ(duk_heap); DUK__DUMPSZ(duk_activation); DUK__DUMPSZ(duk_catcher); - DUK__DUMPSZ(duk_strcache_entry); - DUK__DUMPSZ(duk_litcache_entry); + DUK__DUMPSZ(duk_strcache); DUK__DUMPSZ(duk_ljstate); DUK__DUMPSZ(duk_fixedbuffer); DUK__DUMPSZ(duk_bitdecoder_ctx); @@ -895,7 +894,7 @@ * Zero the struct, and start initializing roughly in order */ - duk_memzero(res, sizeof(*res)); + DUK_MEMZERO(res, sizeof(*res)); #if defined(DUK_USE_ASSERTIONS) res->heap_initializing = 1; #endif @@ -980,7 +979,7 @@ /* XXX: use the pointer as a seed for now: mix in time at least */ - /* The casts through duk_uintptr_t is to avoid the following GCC warning: + /* The casts through duk_intptr_t is to avoid the following GCC warning: * * warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] * @@ -991,7 +990,7 @@ DUK_D(DUK_DPRINT("using rom strings, force heap hash_seed to fixed value 0x%08lx", (long) DUK__FIXED_HASH_SEED)); res->hash_seed = (duk_uint32_t) DUK__FIXED_HASH_SEED; #else /* DUK_USE_ROM_STRINGS */ - res->hash_seed = (duk_uint32_t) (duk_uintptr_t) res; + res->hash_seed = (duk_uint32_t) (duk_intptr_t) res; #if !defined(DUK_USE_STRHASH_DENSE) res->hash_seed ^= 5381; /* Bernstein hash init value is normally 5381; XOR it in in case pointer low bits are 0 */ #endif @@ -1031,17 +1030,17 @@ #if defined(DUK_USE_STRTAB_PTRCOMP) /* zero assumption */ - duk_memzero(res->strtable16, sizeof(duk_uint16_t) * st_initsize); + DUK_MEMZERO(res->strtable16, sizeof(duk_uint16_t) * st_initsize); #else #if defined(DUK_USE_EXPLICIT_NULL_INIT) { - duk_uint32_t i; + duk_small_uint_t i; for (i = 0; i < st_initsize; i++) { res->strtable[i] = NULL; } } #else - duk_memzero(res->strtable, sizeof(duk_hstring *) * st_initsize); + DUK_MEMZERO(res->strtable, sizeof(duk_hstring *) * st_initsize); #endif /* DUK_USE_EXPLICIT_NULL_INIT */ #endif /* DUK_USE_STRTAB_PTRCOMP */ @@ -1051,30 +1050,13 @@ #if defined(DUK_USE_EXPLICIT_NULL_INIT) { - duk_uint_t i; + duk_small_uint_t i; for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { res->strcache[i].h = NULL; } } #endif - /* - * Init litcache - */ -#if defined(DUK_USE_LITCACHE_SIZE) - DUK_ASSERT(DUK_USE_LITCACHE_SIZE > 0); - DUK_ASSERT(DUK_IS_POWER_OF_TWO((duk_uint_t) DUK_USE_LITCACHE_SIZE)); -#if defined(DUK_USE_EXPLICIT_NULL_INIT) - { - duk_uint_t i; - for (i = 0; i < DUK_USE_LITCACHE_SIZE; i++) { - res->litcache[i].addr = NULL; - res->litcache[i].h = NULL; - } - } -#endif -#endif /* DUK_USE_LITCACHE_SIZE */ - /* XXX: error handling is incomplete. It would be cleanest if * there was a setjmp catchpoint, so that all init code could * freely throw errors. If that were the case, the return code @@ -1146,7 +1128,7 @@ { duk_uint64_t tmp_u64; tmp_u64 = 0; - duk_memcpy((void *) &tmp_u64, + DUK_MEMCPY((void *) &tmp_u64, (const void *) &res, (size_t) (sizeof(void *) >= sizeof(duk_uint64_t) ? sizeof(duk_uint64_t) : sizeof(void *))); res->rnd_state[1] ^= tmp_u64; diff -Nru duktape-2.3.0/src-separate/duk_heap.h duktape-2.2.0/src-separate/duk_heap.h --- duktape-2.3.0/src-separate/duk_heap.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_heap.h 2017-09-23 01:06:08.000000000 +0000 @@ -294,7 +294,7 @@ * Thus, string caches are now at the heap level now. */ -struct duk_strcache_entry { +struct duk_strcache { duk_hstring *h; duk_uint32_t bidx; duk_uint32_t cidx; @@ -326,15 +326,6 @@ } while (0) /* - * Literal intern cache - */ - -struct duk_litcache_entry { - const duk_uint8_t *addr; - duk_hstring *h; -}; - -/* * Main heap structure */ @@ -560,15 +551,7 @@ /* String access cache (codepoint offset -> byte offset) for fast string * character looping; 'weak' reference which needs special handling in GC. */ - duk_strcache_entry strcache[DUK_HEAP_STRCACHE_SIZE]; - -#if defined(DUK_USE_LITCACHE_SIZE) - /* Literal intern cache. When enabled, strings interned as literals - * (e.g. duk_push_literal()) will be pinned and cached for the lifetime - * of the heap. - */ - duk_litcache_entry litcache[DUK_USE_LITCACHE_SIZE]; -#endif + duk_strcache strcache[DUK_HEAP_STRCACHE_SIZE]; /* Built-in strings. */ #if defined(DUK_USE_ROM_STRINGS) @@ -600,9 +583,6 @@ duk_int_t stats_strtab_resize_check; duk_int_t stats_strtab_resize_grow; duk_int_t stats_strtab_resize_shrink; - duk_int_t stats_strtab_litcache_hit; - duk_int_t stats_strtab_litcache_miss; - duk_int_t stats_strtab_litcache_pin; duk_int_t stats_object_realloc_props; duk_int_t stats_object_abandon_array; duk_int_t stats_getownpropdesc_count; @@ -663,9 +643,6 @@ DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen); DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t len); -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_literal_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t blen); -#endif DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_u32(duk_heap *heap, duk_uint32_t val); DUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_u32_checked(duk_hthread *thr, duk_uint32_t val); #if defined(DUK_USE_REFERENCE_COUNTING) diff -Nru duktape-2.3.0/src-separate/duk_heap_markandsweep.c duktape-2.2.0/src-separate/duk_heap_markandsweep.c --- duktape-2.3.0/src-separate/duk_heap_markandsweep.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_heap_markandsweep.c 2017-09-23 01:06:08.000000000 +0000 @@ -114,7 +114,7 @@ duk__mark_heaphdr(heap, (duk_heaphdr *) b->buf_prop); #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ } else if (DUK_HOBJECT_IS_BOUNDFUNC(h)) { - duk_hboundfunc *f = (duk_hboundfunc *) (void *) h; + duk_hboundfunc *f = (duk_hboundfunc *) h; DUK_ASSERT_HBOUNDFUNC_VALID(f); duk__mark_tval(heap, &f->target); duk__mark_tval(heap, &f->this_binding); @@ -588,8 +588,7 @@ duk_hstring *next; next = h->hdr.h_next; - if (DUK_HEAPHDR_HAS_REACHABLE((duk_heaphdr *) h)) - { + if (DUK_HEAPHDR_HAS_REACHABLE((duk_heaphdr *) h)) { DUK_HEAPHDR_CLEAR_REACHABLE((duk_heaphdr *) h); count_keep++; prev = h; @@ -598,26 +597,13 @@ count_free++; #endif - /* For pinned strings the refcount has been - * bumped. We could unbump it here before - * freeing, but that's actually not necessary - * except for assertions. - */ -#if 0 - if (DUK_HSTRING_HAS_PINNED_LITERAL(h)) { - DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) > 0U); - DUK_HSTRING_DECREF_NORZ(heap->heap_thread, h); - DUK_HSTRING_CLEAR_PINNED_LITERAL(h); - } -#endif #if defined(DUK_USE_REFERENCE_COUNTING) /* Non-zero refcounts should not happen for unreachable strings, * because we refcount finalize all unreachable objects which * should have decreased unreachable string refcounts to zero - * (even for cycles). However, pinned strings have a +1 bump. + * (even for cycles). */ - DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) == - DUK_HSTRING_HAS_PINNED_LITERAL(h) ? 1U : 0U); + DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) == 0); #endif /* Deal with weak references first. */ @@ -821,26 +807,6 @@ } /* - * Litcache helpers. - */ - -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_LOCAL void duk__wipe_litcache(duk_heap *heap) { - duk_uint_t i; - duk_litcache_entry *e; - - e = heap->litcache; - for (i = 0; i < DUK_USE_LITCACHE_SIZE; i++) { - e->addr = NULL; - /* e->h does not need to be invalidated: when e->addr is - * NULL, e->h is considered garbage. - */ - e++; - } -} -#endif /* DUK_USE_LITCACHE_SIZE */ - -/* * Object compaction. * * Compaction is assumed to never throw an error. @@ -1024,7 +990,6 @@ DUK_LOCAL void duk__check_refcount_heaphdr(duk_heaphdr *hdr) { duk_bool_t count_ok; - duk_size_t expect_refc; /* The refcount check only makes sense for reachable objects on * heap_allocated or string table, after the sweep phase. Prior to @@ -1041,11 +1006,7 @@ */ DUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY(hdr)); - expect_refc = hdr->h_assert_refcount; - if (DUK_HEAPHDR_IS_STRING(hdr) && DUK_HSTRING_HAS_PINNED_LITERAL((duk_hstring *) hdr)) { - expect_refc++; - } - count_ok = ((duk_size_t) DUK_HEAPHDR_GET_REFCOUNT(hdr) == expect_refc); + count_ok = ((duk_size_t) DUK_HEAPHDR_GET_REFCOUNT(hdr) == hdr->h_assert_refcount); if (!count_ok) { DUK_D(DUK_DPRINT("refcount mismatch for: %p: header=%ld counted=%ld --> %!iO", (void *) hdr, (long) DUK_HEAPHDR_GET_REFCOUNT(hdr), @@ -1082,22 +1043,6 @@ } } #endif /* DUK_USE_REFERENCE_COUNTING */ - -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_LOCAL void duk__assert_litcache_nulls(duk_heap *heap) { - duk_uint_t i; - duk_litcache_entry *e; - - e = heap->litcache; - for (i = 0; i < DUK_USE_LITCACHE_SIZE; i++) { - /* Entry addresses were NULLed before mark-and-sweep, check - * that they're still NULL afterwards to ensure no pointers - * were recorded through any side effects. - */ - DUK_ASSERT(e->addr == NULL); - } -} -#endif /* DUK_USE_LITCACHE_SIZE */ #endif /* DUK_USE_ASSERTIONS */ /* @@ -1118,13 +1063,10 @@ DUK_D(DUK_DPRINT("stats mark-and-sweep: try_count=%ld, skip_count=%ld, emergency_count=%ld", (long) heap->stats_ms_try_count, (long) heap->stats_ms_skip_count, (long) heap->stats_ms_emergency_count)); - DUK_D(DUK_DPRINT("stats stringtable: intern_hit=%ld, intern_miss=%ld, " - "resize_check=%ld, resize_grow=%ld, resize_shrink=%ld, " - "litcache_hit=%ld, litcache_miss=%ld, litcache_pin=%ld", + DUK_D(DUK_DPRINT("stats stringtable: intern_hit=%ld, intern_miss=%ld, resize_check=%ld, resize_grow=%ld, resize_shrink=%ld", (long) heap->stats_strtab_intern_hit, (long) heap->stats_strtab_intern_miss, (long) heap->stats_strtab_resize_check, (long) heap->stats_strtab_resize_grow, - (long) heap->stats_strtab_resize_shrink, (long) heap->stats_strtab_litcache_hit, - (long) heap->stats_strtab_litcache_miss, (long) heap->stats_strtab_litcache_pin)); + (long) heap->stats_strtab_resize_shrink)); DUK_D(DUK_DPRINT("stats object: realloc_props=%ld, abandon_array=%ld", (long) heap->stats_object_realloc_props, (long) heap->stats_object_abandon_array)); DUK_D(DUK_DPRINT("stats getownpropdesc: count=%ld, hit=%ld, miss=%ld", @@ -1265,9 +1207,6 @@ #if defined(DUK_USE_ASSERTIONS) && defined(DUK_USE_REFERENCE_COUNTING) duk__clear_assert_refcounts(heap); #endif -#if defined(DUK_USE_LITCACHE_SIZE) - duk__wipe_litcache(heap); -#endif duk__mark_roots_heap(heap); /* Mark main reachability roots. */ #if defined(DUK_USE_REFERENCE_COUNTING) DUK_ASSERT(heap->refzero_list == NULL); /* Always handled to completion inline in DECREF. */ @@ -1373,9 +1312,6 @@ */ duk__assert_valid_refcounts(heap); #endif /* DUK_USE_REFERENCE_COUNTING */ -#if defined(DUK_USE_LITCACHE_SIZE) - duk__assert_litcache_nulls(heap); -#endif /* DUK_USE_LITCACHE_SIZE */ #endif /* DUK_USE_ASSERTIONS */ /* diff -Nru duktape-2.3.0/src-separate/duk_heap_memory.c duktape-2.2.0/src-separate/duk_heap_memory.c --- duktape-2.3.0/src-separate/duk_heap_memory.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_heap_memory.c 2017-09-23 01:06:08.000000000 +0000 @@ -127,7 +127,8 @@ res = DUK_ALLOC(heap, size); if (DUK_LIKELY(res != NULL)) { - duk_memzero(res, size); + /* assume memset with zero size is OK */ + DUK_MEMZERO(res, size); } return res; } @@ -141,7 +142,7 @@ return res; } DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; } DUK_INTERNAL void *duk_heap_mem_alloc_checked_zeroed(duk_hthread *thr, duk_size_t size) { @@ -153,7 +154,7 @@ return res; } DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; } /* diff -Nru duktape-2.3.0/src-separate/duk_heap_refcount.c duktape-2.2.0/src-separate/duk_heap_refcount.c --- duktape-2.3.0/src-separate/duk_heap_refcount.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_heap_refcount.c 2017-09-23 01:06:08.000000000 +0000 @@ -170,7 +170,7 @@ DUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, (duk_hobject *) b->buf_prop); #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ } else if (DUK_HOBJECT_IS_BOUNDFUNC(h)) { - duk_hboundfunc *f = (duk_hboundfunc *) (void *) h; + duk_hboundfunc *f = (duk_hboundfunc *) h; DUK_ASSERT_HBOUNDFUNC_VALID(f); DUK_TVAL_DECREF_NORZ(thr, &f->target); DUK_TVAL_DECREF_NORZ(thr, &f->this_binding); diff -Nru duktape-2.3.0/src-separate/duk_heap_stringcache.c duktape-2.2.0/src-separate/duk_heap_stringcache.c --- duktape-2.3.0/src-separate/duk_heap_stringcache.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_heap_stringcache.c 2017-09-23 01:06:08.000000000 +0000 @@ -18,9 +18,9 @@ */ DUK_INTERNAL void duk_heap_strcache_string_remove(duk_heap *heap, duk_hstring *h) { - duk_uint_t i; + duk_small_int_t i; for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { - duk_strcache_entry *c = heap->strcache + 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)); @@ -92,9 +92,9 @@ 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_entry *sce; + duk_strcache *sce; duk_uint_fast32_t byte_offset; - duk_uint_t i; + duk_small_int_t i; duk_bool_t use_cache; duk_uint_fast32_t dist_start, dist_end, dist_sce; duk_uint_fast32_t char_length; @@ -145,14 +145,14 @@ #if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2) DUK_DDD(DUK_DDDPRINT("stringcache before char2byte (using cache):")); for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { - duk_strcache_entry *c = heap->strcache + 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_entry *c = heap->strcache + i; + duk_strcache *c = heap->strcache + i; if (c->h == h) { sce = c; @@ -281,10 +281,10 @@ * C <- sce ==> B * D D */ - duk_strcache_entry tmp; + duk_strcache tmp; tmp = *sce; - duk_memmove((void *) (&heap->strcache[1]), + DUK_MEMMOVE((void *) (&heap->strcache[1]), (const void *) (&heap->strcache[0]), (size_t) (((char *) sce) - ((char *) &heap->strcache[0]))); heap->strcache[0] = tmp; @@ -294,7 +294,7 @@ #if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2) DUK_DDD(DUK_DDDPRINT("stringcache after char2byte (using cache):")); for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) { - duk_strcache_entry *c = heap->strcache + 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)); } @@ -305,5 +305,5 @@ scan_error: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + return 0; } diff -Nru duktape-2.3.0/src-separate/duk_heap_stringtable.c duktape-2.2.0/src-separate/duk_heap_stringtable.c --- duktape-2.3.0/src-separate/duk_heap_stringtable.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_heap_stringtable.c 2017-09-23 01:06:08.000000000 +0000 @@ -54,7 +54,7 @@ return; } - duk_memzero((void *) count_len, sizeof(count_len)); + DUK_MEMZERO((void *) count_len, sizeof(count_len)); for (i = 0; i < heap->st_size; i++) { h = DUK__HEAPPTR_DEC16(heap, strtable[i]); count_chain = 0; @@ -166,7 +166,7 @@ if (DUK_UNLIKELY(res == NULL)) { goto alloc_error; } - duk_memzero(res, sizeof(duk_hstring_external)); + DUK_MEMZERO(res, sizeof(duk_hstring_external)); #if defined(DUK_USE_EXPLICIT_NULL_INIT) DUK_HEAPHDR_STRING_INIT_NULLS(&res->hdr); #endif @@ -186,14 +186,14 @@ if (DUK_UNLIKELY(res == NULL)) { goto alloc_error; } - duk_memzero(res, sizeof(duk_hstring)); + 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_tmp = (duk_uint8_t *) (res + 1); - duk_memcpy(data_tmp, str, blen); + DUK_MEMCPY(data_tmp, str, blen); data_tmp[blen] = (duk_uint8_t) 0; data = (const duk_uint8_t *) data_tmp; } @@ -686,12 +686,11 @@ } lookup_hash &= 0xff; - curr = (duk_hstring *) DUK_LOSE_CONST(duk_rom_strings_lookup[lookup_hash]); + curr = DUK_LOSE_CONST(duk_rom_strings_lookup[lookup_hash]); while (curr != NULL) { - /* Unsafe memcmp() because for zero blen, str may be NULL. */ if (strhash == DUK_HSTRING_GET_HASH(curr) && blen == DUK_HSTRING_GET_BYTELEN(curr) && - duk_memcmp_unsafe((const void *) str, (const void *) DUK_HSTRING_GET_DATA(curr), blen) == 0) { + DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(curr), blen) == 0) { DUK_DDD(DUK_DDDPRINT("intern check: rom string: %!O, computed hash 0x%08lx, rom hash 0x%08lx", curr, (unsigned long) strhash, (unsigned long) DUK_HSTRING_GET_HASH(curr))); return curr; @@ -711,7 +710,6 @@ /* Preliminaries. */ - /* XXX: maybe just require 'str != NULL' even for zero size? */ DUK_ASSERT(heap != NULL); DUK_ASSERT(blen == 0 || str != NULL); DUK_ASSERT(blen <= DUK_HSTRING_MAX_BYTELEN); /* Caller is responsible for ensuring this. */ @@ -730,7 +728,7 @@ while (h != NULL) { if (DUK_HSTRING_GET_HASH(h) == strhash && DUK_HSTRING_GET_BYTELEN(h) == blen && - duk_memcmp_unsafe((const void *) str, (const void *) DUK_HSTRING_GET_DATA(h), (size_t) blen) == 0) { + DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(h), (size_t) blen) == 0) { /* Found existing entry. */ DUK_STATS_INC(heap, stats_strtab_intern_hit); return h; @@ -803,67 +801,10 @@ res = duk_heap_strtable_intern(thr->heap, str, blen); if (DUK_UNLIKELY(res == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } return res; } -#if defined(DUK_USE_LITCACHE_SIZE) -DUK_LOCAL duk_uint_t duk__strtable_litcache_key(const duk_uint8_t *str, duk_uint32_t blen) { - duk_uintptr_t key; - - DUK_ASSERT(DUK_USE_LITCACHE_SIZE > 0); - DUK_ASSERT(DUK_IS_POWER_OF_TWO((duk_uint_t) DUK_USE_LITCACHE_SIZE)); - - key = (duk_uintptr_t) blen ^ (duk_uintptr_t) str; - key &= (duk_uintptr_t) (DUK_USE_LITCACHE_SIZE - 1); /* Assumes size is power of 2. */ - /* Due to masking, cast is in 32-bit range. */ - DUK_ASSERT(key <= DUK_UINT_MAX); - return (duk_uint_t) key; -} - -DUK_INTERNAL duk_hstring *duk_heap_strtable_intern_literal_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t blen) { - duk_uint_t key; - duk_litcache_entry *ent; - duk_hstring *h; - - /* Fast path check: literal exists in literal cache. */ - key = duk__strtable_litcache_key(str, blen); - ent = thr->heap->litcache + key; - if (ent->addr == str) { - DUK_DD(DUK_DDPRINT("intern check for cached, pinned literal: str=%p, blen=%ld -> duk_hstring %!O", - (const void *) str, (long) blen, (duk_heaphdr *) ent->h)); - DUK_ASSERT(ent->h != NULL); - DUK_ASSERT(DUK_HSTRING_HAS_PINNED_LITERAL(ent->h)); - DUK_STATS_INC(thr->heap, stats_strtab_litcache_hit); - return ent->h; - } - - /* Intern and update (overwrite) cache entry. */ - h = duk_heap_strtable_intern_checked(thr, str, blen); - ent->addr = str; - ent->h = h; - DUK_STATS_INC(thr->heap, stats_strtab_litcache_miss); - - /* Pin the duk_hstring until the next mark-and-sweep. This means - * litcache entries don't need to be invalidated until the next - * mark-and-sweep as their target duk_hstring is not freed before - * the mark-and-sweep happens. The pin remains even if the literal - * cache entry is overwritten, and is still useful to avoid string - * table traffic. - */ - if (!DUK_HSTRING_HAS_PINNED_LITERAL(h)) { - DUK_DD(DUK_DDPRINT("pin duk_hstring because it is a literal: %!O", (duk_heaphdr *) h)); - DUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) h)); - DUK_HSTRING_INCREF(thr, h); - DUK_HSTRING_SET_PINNED_LITERAL(h); - DUK_STATS_INC(thr->heap, stats_strtab_litcache_pin); - } - - return h; -} -#endif /* DUK_USE_LITCACHE_SIZE */ - DUK_INTERNAL duk_hstring *duk_heap_strtable_intern_u32_checked(duk_hthread *thr, duk_uint32_t val) { duk_hstring *res; @@ -873,7 +814,6 @@ res = duk_heap_strtable_intern_u32(thr->heap, val); if (DUK_UNLIKELY(res == NULL)) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } return res; } diff -Nru duktape-2.3.0/src-separate/duk_hobject_alloc.c duktape-2.2.0/src-separate/duk_hobject_alloc.c --- duktape-2.3.0/src-separate/duk_hobject_alloc.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hobject_alloc.c 2017-09-23 01:06:08.000000000 +0000 @@ -130,7 +130,7 @@ if (!res) { return NULL; } - duk_memzero(res, sizeof(duk_hboundfunc)); + DUK_MEMZERO(res, sizeof(duk_hboundfunc)); duk__init_object_parts(heap, hobject_flags, &res->obj); @@ -172,7 +172,7 @@ if (DUK_UNLIKELY(res == NULL)) { return NULL; } - duk_memzero(res, sizeof(duk_hthread)); + DUK_MEMZERO(res, sizeof(duk_hthread)); duk__init_object_parts(heap, hobject_flags, &res->obj); @@ -214,7 +214,6 @@ res = duk_hthread_alloc_unchecked(thr->heap, hobject_flags); if (res == NULL) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return NULL;); } return res; } diff -Nru duktape-2.3.0/src-separate/duk_hobject_class.c duktape-2.2.0/src-separate/duk_hobject_class.c --- duktape-2.3.0/src-separate/duk_hobject_class.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hobject_class.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Hobject ECMAScript [[Class]]. + * Hobject Ecmascript [[Class]]. */ #include "duk_internal.h" diff -Nru duktape-2.3.0/src-separate/duk_hobject_enum.c duktape-2.2.0/src-separate/duk_hobject_enum.c --- duktape-2.3.0/src-separate/duk_hobject_enum.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hobject_enum.c 2017-09-23 01:06:08.000000000 +0000 @@ -159,7 +159,7 @@ * are very often in order already. */ if (idx != idx_insert) { - duk_memmove((void *) (keys + idx_insert + 1), + DUK_MEMMOVE((void *) (keys + idx_insert + 1), (const void *) (keys + idx_insert), ((size_t) (idx - idx_insert) * sizeof(duk_hstring *))); keys[idx_insert] = h_curr; @@ -643,7 +643,7 @@ } /* - * Get enumerated keys in an ECMAScript array. Matches Object.keys() behavior + * Get enumerated keys in an Ecmascript array. Matches Object.keys() behavior * described in E5 Section 15.2.3.14. */ diff -Nru duktape-2.3.0/src-separate/duk_hobject.h duktape-2.2.0/src-separate/duk_hobject.h --- duktape-2.3.0/src-separate/duk_hobject.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hobject.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,12 +1,12 @@ /* * Heap object representation. * - * Heap objects are used for ECMAScript objects, arrays, and functions, + * Heap objects are used for Ecmascript objects, arrays, and functions, * but also for internal control like declarative and object environment * records. Compiled functions, native functions, and threads are also * objects but with an extended C struct. * - * Objects provide the required ECMAScript semantics and exotic behaviors + * Objects provide the required Ecmascript semantics and exotic behaviors * especially for property access. * * Properties are stored in three conceptual parts: @@ -635,7 +635,7 @@ #define DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY 10000L /* - * ECMAScript [[Class]] + * Ecmascript [[Class]] */ /* range check not necessary because all 4-bit values are mapped */ diff -Nru duktape-2.3.0/src-separate/duk_hobject_misc.c duktape-2.2.0/src-separate/duk_hobject_misc.c --- duktape-2.3.0/src-separate/duk_hobject_misc.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hobject_misc.c 2017-09-23 01:06:08.000000000 +0000 @@ -27,7 +27,6 @@ break; } else { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } } h = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h); diff -Nru duktape-2.3.0/src-separate/duk_hobject_pc2line.c duktape-2.2.0/src-separate/duk_hobject_pc2line.c --- duktape-2.3.0/src-separate/duk_hobject_pc2line.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hobject_pc2line.c 2017-09-23 01:06:08.000000000 +0000 @@ -58,7 +58,7 @@ (long) hdr[hdr_index + 1])); #endif - duk_memzero(be_ctx, sizeof(*be_ctx)); + DUK_MEMZERO(be_ctx, sizeof(*be_ctx)); be_ctx->data = ((duk_uint8_t *) hdr) + curr_offset; be_ctx->length = (duk_size_t) DUK_PC2LINE_MAX_DIFF_LENGTH; @@ -169,7 +169,7 @@ * Iterate the bitstream (line diffs) until PC is reached */ - duk_memzero(bd_ctx, sizeof(*bd_ctx)); + DUK_MEMZERO(bd_ctx, sizeof(*bd_ctx)); bd_ctx->data = ((duk_uint8_t *) hdr) + start_offset; bd_ctx->length = (duk_size_t) (DUK_HBUFFER_FIXED_GET_SIZE(buf) - start_offset); @@ -229,7 +229,7 @@ */ duk_get_prop_stridx(thr, idx_func, DUK_STRIDX_INT_PC2LINE); - pc2line = (duk_hbuffer_fixed *) (void *) duk_get_hbuffer(thr, -1); + pc2line = (duk_hbuffer_fixed *) duk_get_hbuffer(thr, -1); if (pc2line != NULL) { DUK_ASSERT(!DUK_HBUFFER_HAS_DYNAMIC((duk_hbuffer *) pc2line) && !DUK_HBUFFER_HAS_EXTERNAL((duk_hbuffer *) pc2line)); line = duk__hobject_pc2line_query_raw(thr, pc2line, (duk_uint_fast32_t) pc); diff -Nru duktape-2.3.0/src-separate/duk_hobject_props.c duktape-2.2.0/src-separate/duk_hobject_props.c --- duktape-2.3.0/src-separate/duk_hobject_props.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hobject_props.c 2017-09-23 01:06:08.000000000 +0000 @@ -53,7 +53,7 @@ #define DUK__HASH_DELETED DUK_HOBJECT_HASHIDX_DELETED /* Valstack space that suffices for all local calls, excluding any recursion - * into ECMAScript or Duktape/C calls (Proxy, getters, etc). + * into Ecmascript or Duktape/C calls (Proxy, getters, etc). */ #define DUK__VALSTACK_SPACE 10 @@ -603,7 +603,6 @@ if (new_e_size_adjusted + new_a_size > DUK_HOBJECT_MAX_PROPERTIES) { DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return;); } /* @@ -807,14 +806,18 @@ } else { array_copy_size = sizeof(duk_tval) * new_a_size; } - - DUK_ASSERT(new_a != NULL || array_copy_size == 0U); - DUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, obj) != NULL || array_copy_size == 0U); - DUK_ASSERT(DUK_HOBJECT_GET_ASIZE(obj) > 0 || array_copy_size == 0U); - duk_memcpy_unsafe((void *) new_a, - (const void *) DUK_HOBJECT_A_GET_BASE(thr->heap, obj), - array_copy_size); - + if (array_copy_size > 0) { + /* Avoid zero copy with an invalid pointer. If obj->p is NULL, + * the 'new_a' pointer will be invalid which is not allowed even + * when copy size is zero. + */ + DUK_ASSERT(new_a != NULL); + DUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, obj) != NULL); + DUK_ASSERT(DUK_HOBJECT_GET_ASIZE(obj) > 0); + DUK_MEMCPY((void *) new_a, + (const void *) DUK_HOBJECT_A_GET_BASE(thr->heap, obj), + array_copy_size); + } for (i = DUK_HOBJECT_GET_ASIZE(obj); i < new_a_size; i++) { duk_tval *tv = &new_a[i]; DUK_TVAL_SET_UNUSED(tv); @@ -839,7 +842,7 @@ /* fill new_h with u32 0xff = UNUSED */ DUK_ASSERT(new_h_size > 0); - duk_memset(new_h, 0xff, sizeof(duk_uint32_t) * new_h_size); + DUK_MEMSET(new_h, 0xff, sizeof(duk_uint32_t) * new_h_size); DUK_ASSERT(new_e_next <= new_h_size); /* equality not actually possible */ @@ -949,7 +952,6 @@ #endif DUK_ERROR_ALLOC_FAILED(thr); - DUK_WO_NORETURN(return;); } /* @@ -1427,7 +1429,7 @@ /* This is not strictly necessary, but avoids compiler warnings; e.g. * gcc won't reliably detect that no uninitialized data is read below. */ - duk_memzero((void *) &tv, sizeof(duk_tval)); + DUK_MEMZERO((void *) &tv, sizeof(duk_tval)); if (duk_hobject_get_internal_value(heap, obj, &tv)) { duk_hstring *h; @@ -1615,7 +1617,7 @@ } /* - * ECMAScript compliant [[GetOwnProperty]](P), for internal use only. + * Ecmascript compliant [[GetOwnProperty]](P), for internal use only. * * If property is found: * - Fills descriptor fields to 'out_desc' @@ -1990,7 +1992,7 @@ } /* - * ECMAScript compliant [[GetProperty]](P), for internal use only. + * Ecmascript compliant [[GetProperty]](P), for internal use only. * * If property is found: * - Fills descriptor fields to 'out_desc' @@ -2047,7 +2049,6 @@ break; } else { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } } curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr); @@ -2329,7 +2330,7 @@ #endif /* DUK_USE_BUFFEROBJECT_SUPPORT */ /* - * GETPROP: ECMAScript property read. + * GETPROP: Ecmascript property read. */ DUK_INTERNAL duk_bool_t duk_hobject_getprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key) { @@ -2383,8 +2384,7 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot read property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); - break; + return 0; } case DUK_TAG_BOOLEAN: { @@ -2540,7 +2540,6 @@ !DUK_TVAL_IS_UNDEFINED(tv_hook); if (datadesc_reject || accdesc_reject) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } duk_pop_2_unsafe(thr); @@ -2732,7 +2731,6 @@ */ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr); } while (curr != NULL); @@ -2803,7 +2801,6 @@ DUK_HOBJECT_HAS_STRICT(h)) { /* XXX: sufficient to check 'strict', assert for 'is function' */ DUK_ERROR_TYPE(thr, DUK_STR_STRICT_CALLER_READ); - DUK_WO_NORETURN(return 0;); } } } @@ -2816,7 +2813,7 @@ } /* - * HASPROP: ECMAScript property existence check ("in" operator). + * HASPROP: Ecmascript property existence check ("in" operator). * * Interestingly, the 'in' operator does not do any coercion of * the target object. @@ -2882,7 +2879,6 @@ /* Note: unconditional throw */ DUK_DDD(DUK_DDDPRINT("base object is not an object -> reject")); DUK_ERROR_TYPE(thr, DUK_STR_INVALID_BASE); - DUK_WO_NORETURN(return 0;); } /* XXX: fast path for arrays? */ @@ -2907,7 +2903,7 @@ duk_push_hobject(thr, h_target); /* target */ duk_push_tval(thr, tv_key); /* P */ duk_call_method(thr, 2 /*nargs*/); - tmp_bool = duk_to_boolean_top_pop(thr); + tmp_bool = duk_to_boolean(thr, -1); if (!tmp_bool) { /* Target object must be checked for a conflicting * non-configurable property. @@ -2926,12 +2922,11 @@ if (!((desc.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && /* property is configurable and */ DUK_HOBJECT_HAS_EXTENSIBLE(h_target))) { /* ... target is extensible */ DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } } } - duk_pop_unsafe(thr); /* [ key ] -> [] */ + duk_pop_2_unsafe(thr); /* [ key trap_result ] -> [] */ return tmp_bool; } @@ -3023,7 +3018,7 @@ /* Refuse to update an Array's 'length' to a value outside the * 32-bit range. Negative zero is accepted as zero. */ - res = duk_double_to_uint32_t(d); + res = (duk_uint32_t) d; if ((duk_double_t) res != d) { goto fail_range; } @@ -3032,7 +3027,7 @@ fail_range: DUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARRAY_LENGTH); - DUK_WO_NORETURN(return 0;); + return 0; /* unreachable */ } /* Delete elements required by a smaller length, taking into account @@ -3301,9 +3296,9 @@ } /* - * PUTPROP: ECMAScript property write. + * PUTPROP: Ecmascript property write. * - * Unlike ECMAScript primitive which returns nothing, returns 1 to indicate + * Unlike Ecmascript primitive which returns nothing, returns 1 to indicate * success and 0 to indicate failure (assuming throw is not set). * * This is an extremely tricky function. Some examples: @@ -3390,8 +3385,7 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot write property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); - break; + return 0; } case DUK_TAG_BOOLEAN: { @@ -3495,7 +3489,8 @@ duk_push_tval(thr, tv_val); /* V */ duk_push_tval(thr, tv_obj); /* Receiver: Proxy object */ duk_call_method(thr, 4 /*nargs*/); - tmp_bool = duk_to_boolean_top_pop(thr); + tmp_bool = duk_to_boolean(thr, -1); + duk_pop_nodecref_unsafe(thr); if (!tmp_bool) { goto fail_proxy_rejected; } @@ -3527,7 +3522,6 @@ (desc.set == NULL); if (datadesc_reject || accdesc_reject) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } duk_pop_2_unsafe(thr); @@ -3827,7 +3821,6 @@ */ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr); } while (curr != NULL); @@ -4177,7 +4170,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, proxy rejects")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } /* Note: no key on stack */ return 0; @@ -4192,7 +4184,6 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot write property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -4201,7 +4192,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, not extensible")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_EXTENSIBLE); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -4210,7 +4200,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, not writable")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_WRITABLE); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -4220,7 +4209,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, not writable")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_WRITABLE); - DUK_WO_NORETURN(return 0;); } return 0; #endif @@ -4229,7 +4217,6 @@ DUK_DD(DUK_DDPRINT("result: error, array length write only partially successful")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -4238,7 +4225,6 @@ DUK_DDD(DUK_DDDPRINT("result: error, accessor property without setter")); if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_SETTER_UNDEFINED); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; @@ -4247,14 +4233,13 @@ DUK_DDD(DUK_DDDPRINT("result: error, internal")); if (throw_flag) { DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); } duk_pop_unsafe(thr); /* remove key */ return 0; } /* - * ECMAScript compliant [[Delete]](P, Throw). + * Ecmascript compliant [[Delete]](P, Throw). */ DUK_INTERNAL duk_bool_t duk_hobject_delprop_raw(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_small_uint_t flags) { @@ -4408,13 +4393,12 @@ if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } return 0; } /* - * DELPROP: ECMAScript property deletion. + * DELPROP: Ecmascript property deletion. */ DUK_INTERNAL duk_bool_t duk_hobject_delprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key, duk_bool_t throw_flag) { @@ -4469,7 +4453,8 @@ duk_push_hobject(thr, h_target); /* target */ duk_dup_m4(thr); /* P */ duk_call_method(thr, 2 /*nargs*/); - tmp_bool = duk_to_boolean_top_pop(thr); + tmp_bool = duk_to_boolean(thr, -1); + duk_pop_nodecref_unsafe(thr); if (!tmp_bool) { goto fail_proxy_rejected; /* retval indicates delete failed */ } @@ -4494,7 +4479,6 @@ if (desc_reject) { /* unconditional */ DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } } rc = 1; /* success */ @@ -4578,13 +4562,12 @@ DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot delete property %s of %s", duk_push_string_tval_readable(thr, tv_key), duk_push_string_tval_readable(thr, tv_obj)); #endif - DUK_WO_NORETURN(return 0;); + return 0; #if defined(DUK_USE_ES6_PROXY) fail_proxy_rejected: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED); - DUK_WO_NORETURN(return 0;); } duk_set_top_unsafe(thr, entry_top); return 0; @@ -4593,7 +4576,6 @@ fail_not_configurable: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } duk_set_top_unsafe(thr, entry_top); return 0; @@ -4733,7 +4715,7 @@ error_virtual: /* share error message */ error_internal: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); + return; } /* @@ -4813,7 +4795,7 @@ val = duk_to_number_m1(thr); duk_pop_3_unsafe(thr); - /* This isn't part of ECMAScript semantics; return a value within + /* This isn't part of Ecmascript semantics; return a value within * duk_size_t range, or 0 otherwise. */ if (val >= 0.0 && val <= (duk_double_t) DUK_SIZE_MAX) { @@ -4924,7 +4906,7 @@ * NormalizePropertyDescriptor() related helper. * * Internal helper which validates and normalizes a property descriptor - * represented as an ECMAScript object (e.g. argument to defineProperty()). + * represented as an Ecmascript object (e.g. argument to defineProperty()). * The output of this conversion is a set of defprop_flags and possibly * some values pushed on the value stack to (1) ensure borrowed pointers * remain valid, and (2) avoid unnecessary pops for footprint reasons. @@ -4974,7 +4956,7 @@ if (duk_get_prop_stridx(thr, idx_in, DUK_STRIDX_WRITABLE)) { is_data_desc = 1; - if (duk_to_boolean_top_pop(thr)) { + if (duk_to_boolean(thr, -1)) { defprop_flags |= DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_WRITABLE; } else { defprop_flags |= DUK_DEFPROP_HAVE_WRITABLE; @@ -5026,7 +5008,7 @@ } if (duk_get_prop_stridx(thr, idx_in, DUK_STRIDX_ENUMERABLE)) { - if (duk_to_boolean_top_pop(thr)) { + if (duk_to_boolean(thr, -1)) { defprop_flags |= DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE; } else { defprop_flags |= DUK_DEFPROP_HAVE_ENUMERABLE; @@ -5034,7 +5016,7 @@ } if (duk_get_prop_stridx(thr, idx_in, DUK_STRIDX_CONFIGURABLE)) { - if (duk_to_boolean_top_pop(thr)) { + if (duk_to_boolean(thr, -1)) { defprop_flags |= DUK_DEFPROP_HAVE_CONFIGURABLE | DUK_DEFPROP_CONFIGURABLE; } else { defprop_flags |= DUK_DEFPROP_HAVE_CONFIGURABLE; @@ -5055,7 +5037,6 @@ type_error: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_DESCRIPTOR); - DUK_WO_NORETURN(return;); } /* @@ -5064,7 +5045,7 @@ * * Inlines all [[DefineOwnProperty]] exotic behaviors. * - * Note: ECMAScript compliant [[DefineOwnProperty]](P, Desc, Throw) is not + * Note: Ecmascript compliant [[DefineOwnProperty]](P, Desc, Throw) is not * implemented directly, but Object.defineProperty() serves its purpose. * We don't need the [[DefineOwnProperty]] internally and we don't have a * property descriptor with 'missing values' so it's easier to avoid it @@ -5937,7 +5918,6 @@ fail_not_extensible: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_EXTENSIBLE); - DUK_WO_NORETURN(return 0;); } return 0; @@ -5945,7 +5925,6 @@ fail_not_configurable: if (throw_flag) { DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return 0;); } return 0; } @@ -6001,7 +5980,6 @@ if (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) { DUK_DD(DUK_DDPRINT("attempt to seal/freeze a readonly object, reject")); DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); - DUK_WO_NORETURN(return;); } #endif diff -Nru duktape-2.3.0/src-separate/duk_hstring.h duktape-2.2.0/src-separate/duk_hstring.h --- duktape-2.3.0/src-separate/duk_hstring.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hstring.h 2017-09-23 01:06:08.000000000 +0000 @@ -8,7 +8,7 @@ * strings used as internal property names and raw buffers converted to * strings. In such cases the 'clen' field contains an inaccurate value. * - * ECMAScript requires support for 32-bit long strings. However, since each + * Ecmascript requires support for 32-bit long strings. However, since each * 16-bit codepoint can take 3 bytes in CESU-8, this representation can only * support about 1.4G codepoint long strings in extreme cases. This is not * really a practical issue. @@ -32,15 +32,12 @@ #define DUK_HSTRING_MAX_BYTELEN (0x7fffffffUL) #endif -/* XXX: could add flags for "is valid CESU-8" (ECMAScript compatible strings), +/* XXX: could add flags for "is valid CESU-8" (Ecmascript compatible strings), * "is valid UTF-8", "is valid extended UTF-8" (internal strings are not, * regexp bytecode is), and "contains non-BMP characters". These are not * needed right now. */ -/* With lowmem builds the high 16 bits of duk_heaphdr are used for other - * purposes, so this leaves 7 duk_heaphdr flags and 9 duk_hstring flags. - */ #define DUK_HSTRING_FLAG_ASCII DUK_HEAPHDR_USER_FLAG(0) /* string is ASCII, clen == blen */ #define DUK_HSTRING_FLAG_ARRIDX DUK_HEAPHDR_USER_FLAG(1) /* string is a valid array index */ #define DUK_HSTRING_FLAG_SYMBOL DUK_HEAPHDR_USER_FLAG(2) /* string is a symbol (invalid utf-8) */ @@ -49,7 +46,6 @@ #define DUK_HSTRING_FLAG_STRICT_RESERVED_WORD DUK_HEAPHDR_USER_FLAG(5) /* string is a reserved word (strict) */ #define DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS DUK_HEAPHDR_USER_FLAG(6) /* string is 'eval' or 'arguments' */ #define DUK_HSTRING_FLAG_EXTDATA DUK_HEAPHDR_USER_FLAG(7) /* string data is external (duk_hstring_external) */ -#define DUK_HSTRING_FLAG_PINNED_LITERAL DUK_HEAPHDR_USER_FLAG(8) /* string is a literal, and pinned */ #define DUK_HSTRING_HAS_ASCII(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) #define DUK_HSTRING_HAS_ARRIDX(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) @@ -59,7 +55,6 @@ #define DUK_HSTRING_HAS_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) #define DUK_HSTRING_HAS_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) #define DUK_HSTRING_HAS_EXTDATA(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) -#define DUK_HSTRING_HAS_PINNED_LITERAL(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) #define DUK_HSTRING_SET_ASCII(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) #define DUK_HSTRING_SET_ARRIDX(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) @@ -69,7 +64,6 @@ #define DUK_HSTRING_SET_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) #define DUK_HSTRING_SET_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) #define DUK_HSTRING_SET_EXTDATA(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) -#define DUK_HSTRING_SET_PINNED_LITERAL(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) #define DUK_HSTRING_CLEAR_ASCII(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) #define DUK_HSTRING_CLEAR_ARRIDX(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) @@ -79,7 +73,6 @@ #define DUK_HSTRING_CLEAR_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) #define DUK_HSTRING_CLEAR_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) #define DUK_HSTRING_CLEAR_EXTDATA(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) -#define DUK_HSTRING_CLEAR_PINNED_LITERAL(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) #if 0 /* Slightly smaller code without explicit flag, but explicit flag * is very useful when 'clen' is dropped. diff -Nru duktape-2.3.0/src-separate/duk_hstring_misc.c duktape-2.2.0/src-separate/duk_hstring_misc.c --- duktape-2.3.0/src-separate/duk_hstring_misc.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hstring_misc.c 2017-09-23 01:06:08.000000000 +0000 @@ -33,7 +33,7 @@ (const void *) p_start, (const void *) p_end, (const void *) p)); - /* For invalid UTF-8 (never happens for standard ECMAScript strings) + /* For invalid UTF-8 (never happens for standard Ecmascript strings) * return U+FFFD replacement character. */ if (duk_unicode_decode_xutf8(thr, &p, p_start, p_end, &cp1)) { @@ -189,7 +189,7 @@ if (len != DUK_HSTRING_GET_BYTELEN(h)) { return 0; } - if (duk_memcmp((const void *) cstr, (const void *) DUK_HSTRING_GET_DATA(h), len) == 0) { + if (DUK_MEMCMP((const void *) cstr, (const void *) DUK_HSTRING_GET_DATA(h), len) == 0) { return 1; } return 0; diff -Nru duktape-2.3.0/src-separate/duk_hthread_alloc.c duktape-2.2.0/src-separate/duk_hthread_alloc.c --- duktape-2.3.0/src-separate/duk_hthread_alloc.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hthread_alloc.c 2017-09-23 01:06:08.000000000 +0000 @@ -30,7 +30,7 @@ if (!thr->valstack) { goto fail; } - duk_memzero(thr->valstack, alloc_size); + DUK_MEMZERO(thr->valstack, alloc_size); thr->valstack_end = thr->valstack + DUK_VALSTACK_API_ENTRY_MINIMUM; thr->valstack_alloc_end = thr->valstack + DUK_VALSTACK_INITIAL_SIZE; thr->valstack_bottom = thr->valstack; diff -Nru duktape-2.3.0/src-separate/duk_hthread_builtins.c duktape-2.2.0/src-separate/duk_hthread_builtins.c --- duktape-2.3.0/src-separate/duk_hthread_builtins.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hthread_builtins.c 2017-09-23 01:06:08.000000000 +0000 @@ -75,7 +75,7 @@ props = DUK_ALLOC_CHECKED(thr, alloc_size); DUK_ASSERT(props != NULL); DUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, h_oldglobal) != NULL); - duk_memcpy((void *) props, (const void *) DUK_HOBJECT_GET_PROPS(thr->heap, h_oldglobal), alloc_size); + DUK_MEMCPY((void *) props, (const void *) DUK_HOBJECT_GET_PROPS(thr->heap, h_oldglobal), alloc_size); /* XXX: keep property attributes or tweak them here? * Properties will now be non-configurable even when they're @@ -202,7 +202,7 @@ DUK_D(DUK_DPRINT("INITBUILTINS BEGIN: DUK_NUM_BUILTINS=%d, DUK_NUM_BUILTINS_ALL=%d", (int) DUK_NUM_BUILTINS, (int) DUK_NUM_ALL_BUILTINS)); - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); bd->data = (const duk_uint8_t *) duk_builtins_data; bd->length = (duk_size_t) DUK_BUILTINS_DATA_LENGTH; @@ -444,9 +444,11 @@ * signaled using a single flag bit in the bitstream. */ - defprop_flags = (duk_small_uint_t) duk_bd_decode_flagged(bd, - DUK__PROP_FLAGS_BITS, - (duk_uint32_t) DUK_PROPDESC_FLAGS_WC); + if (duk_bd_decode_flag(bd)) { + defprop_flags = (duk_small_uint_t) duk_bd_decode(bd, DUK__PROP_FLAGS_BITS); + } else { + defprop_flags = DUK_PROPDESC_FLAGS_WC; + } defprop_flags |= DUK_DEFPROP_FORCE | DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | @@ -551,7 +553,6 @@ #if defined(DUK_USE_LIGHTFUNC_BUILTINS) duk_small_int_t lightfunc_eligible; #endif - duk_small_uint_t defprop_flags; duk__push_stridx_or_string(thr, bd); h_key = duk_known_hstring(thr, -1); @@ -671,19 +672,10 @@ lightfunc_skip: #endif - defprop_flags = (duk_small_uint_t) duk_bd_decode_flagged(bd, - DUK__PROP_FLAGS_BITS, - (duk_uint32_t) DUK_PROPDESC_FLAGS_WC); - defprop_flags |= DUK_DEFPROP_FORCE | - DUK_DEFPROP_HAVE_VALUE | - DUK_DEFPROP_HAVE_WRITABLE | - DUK_DEFPROP_HAVE_ENUMERABLE | - DUK_DEFPROP_HAVE_CONFIGURABLE; - DUK_ASSERT(DUK_PROPDESC_FLAG_WRITABLE == DUK_DEFPROP_WRITABLE); - DUK_ASSERT(DUK_PROPDESC_FLAG_ENUMERABLE == DUK_DEFPROP_ENUMERABLE); - DUK_ASSERT(DUK_PROPDESC_FLAG_CONFIGURABLE == DUK_DEFPROP_CONFIGURABLE); - - duk_def_prop(thr, (duk_idx_t) i, defprop_flags); + /* XXX: So far all ES builtins are 'wc' but e.g. + * performance.now() should be 'wec'. + */ + duk_xdef_prop(thr, (duk_idx_t) i, DUK_PROPDESC_FLAGS_WC); /* [ (builtin objects) ] */ } @@ -756,7 +748,7 @@ "f" #endif " " - /* Low memory/performance options */ + /* Low memory options */ #if defined(DUK_USE_STRTAB_PTRCOMP) "s" #endif @@ -797,9 +789,6 @@ */ "Z" #endif -#if defined(DUK_USE_LITCACHE_SIZE) - "l" -#endif " " /* Object property allocation layout */ #if defined(DUK_USE_HOBJECT_LAYOUT_1) diff -Nru duktape-2.3.0/src-separate/duk_hthread.h duktape-2.2.0/src-separate/duk_hthread.h --- duktape-2.3.0/src-separate/duk_hthread.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hthread.h 2017-09-23 01:06:08.000000000 +0000 @@ -222,14 +222,14 @@ duk_instr_t *curr_pc; /* next instruction to execute (points to 'func' bytecode, stable pointer), NULL for native calls */ /* bottom_byteoff and retval_byteoff are only used for book-keeping - * of ECMAScript-initiated calls, to allow returning to an ECMAScript + * of Ecmascript-initiated calls, to allow returning to an Ecmascript * function properly. */ /* Bottom of valstack for this activation, used to reset * valstack_bottom on return; offset is absolute. There's * no need to track 'top' because native call handling deals - * with that using locals, and for ECMAScript returns 'nregs' + * with that using locals, and for Ecmascript returns 'nregs' * indicates the necessary top. */ duk_size_t bottom_byteoff; diff -Nru duktape-2.3.0/src-separate/duk_hthread_stacks.c duktape-2.2.0/src-separate/duk_hthread_stacks.c --- duktape-2.3.0/src-separate/duk_hthread_stacks.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_hthread_stacks.c 2017-09-23 01:06:08.000000000 +0000 @@ -392,8 +392,8 @@ /* Use DUK_ALLOC_RAW() to avoid side effects. */ new_ptr = (duk_tval *) DUK_ALLOC_RAW(thr->heap, alloc_size); if (new_ptr != NULL) { - duk_memcpy((void *) new_ptr, (const void *) thr->valstack, alloc_size); - duk_memset((void *) thr->valstack, 0x55, alloc_size); + DUK_MEMCPY((void *) new_ptr, (const void *) thr->valstack, alloc_size); + DUK_MEMSET((void *) thr->valstack, 0x55, alloc_size); DUK_FREE_CHECKED(thr, (void *) thr->valstack); thr->valstack = new_ptr; thr->valstack_alloc_end = (duk_tval *) ((duk_uint8_t *) new_ptr + alloc_end_off); diff -Nru duktape-2.3.0/src-separate/duk_js_arith.c duktape-2.2.0/src-separate/duk_js_arith.c --- duktape-2.3.0/src-separate/duk_js_arith.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_js_arith.c 2017-09-23 01:06:08.000000000 +0000 @@ -4,7 +4,7 @@ #include "duk_internal.h" -/* ECMAScript modulus ('%') does not match IEEE 754 "remainder" operation +/* Ecmascript modulus ('%') does not match IEEE 754 "remainder" operation * (implemented by remainder() in C99) but does seem to match ANSI C fmod(). * Compare E5 Section 11.5.3 and "man fmod". */ @@ -58,9 +58,9 @@ /* Shared helper for Math.pow() and exponentiation operator. */ DUK_INTERNAL double duk_js_arith_pow(double x, double y) { - /* The ANSI C pow() semantics differ from ECMAScript. + /* The ANSI C pow() semantics differ from Ecmascript. * - * E.g. when x==1 and y is +/- infinite, the ECMAScript required + * E.g. when x==1 and y is +/- infinite, the Ecmascript required * result is NaN, while at least Linux pow() returns 1. */ diff -Nru duktape-2.3.0/src-separate/duk_js_bytecode.h duktape-2.2.0/src-separate/duk_js_bytecode.h --- duktape-2.3.0/src-separate/duk_js_bytecode.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_js_bytecode.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,5 +1,5 @@ /* - * ECMAScript bytecode + * Ecmascript bytecode */ #if !defined(DUK_JS_BYTECODE_H_INCLUDED) diff -Nru duktape-2.3.0/src-separate/duk_js_call.c duktape-2.2.0/src-separate/duk_js_call.c --- duktape-2.3.0/src-separate/duk_js_call.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_js_call.c 2017-09-23 01:06:08.000000000 +0000 @@ -3,7 +3,7 @@ * * duk_handle_call_unprotected(): * - * - Unprotected call to ECMAScript or Duktape/C function, from native + * - Unprotected call to Ecmascript or Duktape/C function, from native * code or bytecode executor. * * - Also handles Ecma-to-Ecma calls which reuses a currently running @@ -57,7 +57,6 @@ DUK_D(DUK_DPRINT("call prevented because C recursion limit reached")); DUK_ERROR_RANGE(thr, DUK_STR_C_CALLSTACK_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL DUK_ALWAYS_INLINE void duk__call_c_recursion_limit_check(duk_hthread *thr) { @@ -93,7 +92,6 @@ */ DUK_D(DUK_DPRINT("call prevented because call stack limit reached")); DUK_ERROR_RANGE(thr, DUK_STR_CALLSTACK_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL DUK_ALWAYS_INLINE void duk__call_callstack_limit_check(duk_hthread *thr) { @@ -507,7 +505,6 @@ if (DUK_UNLIKELY(proxy_invariant != 0U)) { /* Proxy 'construct' return value invariant violated. */ DUK_ERROR_TYPE_INVALID_TRAP_RESULT(thr); - DUK_WO_NORETURN(return;); } /* XXX: direct value stack access */ duk_pop(thr); @@ -568,7 +565,7 @@ duk_tval *tv_args; duk_tval *tv_gap; - h_bound = (duk_hboundfunc *) (void *) func; + h_bound = (duk_hboundfunc *) func; tv_args = h_bound->args; len = h_bound->nargs; DUK_ASSERT(len == 0 || tv_args != NULL); @@ -608,7 +605,6 @@ } else { /* Shouldn't happen, so ugly error is enough. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); } DUK_ASSERT(duk_get_top(thr) >= idx_func + 2); @@ -784,13 +780,11 @@ if (top < idx_func + 3) { /* argArray is a mandatory argument for Reflect.construct(). */ DUK_ERROR_TYPE_INVALID_ARGS(thr); - DUK_WO_NORETURN(return 0;); } if (top > idx_func + 3) { if (!duk_strict_equals(thr, idx_func, idx_func + 3)) { /* XXX: [[Construct]] newTarget currently unsupported */ DUK_ERROR_UNSUPPORTED(thr); - DUK_WO_NORETURN(return 0;); } duk_set_top_unsafe(thr, idx_func + 3); /* remove any args beyond argArray */ } @@ -1327,7 +1321,6 @@ if (duk_hobject_find_existing_entry_tval_ptr(thr->heap, DUK_TVAL_GET_OBJECT(tv_func), DUK_HTHREAD_STRING_INT_TARGET(thr)) != NULL) { duk_push_tval(thr, tv_func); (void) duk_throw(thr); - DUK_WO_NORETURN(return NULL;); } } #endif @@ -1341,7 +1334,8 @@ #else DUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE); #endif - DUK_WO_NORETURN(return NULL;); + DUK_UNREACHABLE(); + return NULL; /* never executed */ not_constructable: /* For now GETPROPC delayed error not needed for constructor calls. */ @@ -1354,7 +1348,8 @@ #else DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONSTRUCTABLE); #endif - DUK_WO_NORETURN(return NULL;); + DUK_UNREACHABLE(); + return NULL; /* never executed */ } /* @@ -1378,7 +1373,6 @@ idx_rcbase = duk_get_top(thr) - num_actual_rets; /* base of known return values */ if (DUK_UNLIKELY(idx_rcbase < 0)) { DUK_ERROR_TYPE(thr, DUK_STR_INVALID_CFUNC_RC); - DUK_WO_NORETURN(return;); } DUK_DDD(DUK_DDDPRINT("adjust valstack after func call: " @@ -1513,10 +1507,9 @@ * - Disable StepOut processing for the activation unwind because * we reuse the activation, see: * https://github.com/svaarala/duktape/issues/1684. - * - Disable line change pause flag permanently if act == dbg_pause_act - * (if set) because it would no longer be relevant, see: - * https://github.com/svaarala/duktape/issues/1726, - * https://github.com/svaarala/duktape/issues/1786. + * - Disable line change pause flag permanently (if set) because + * it would no longer be relevant, see: + * https://github.com/svaarala/duktape/issues/1726. * - Check for function entry (e.g. StepInto) pause flag here, because * the executor pause check won't trigger due to shared activation, see: * https://github.com/svaarala/duktape/issues/1726. @@ -1537,12 +1530,9 @@ DUK_ASSERT(thr->callstack_top > 0); DUK_ASSERT(thr->callstack_curr != NULL); #if defined(DUK_USE_DEBUGGER_SUPPORT) - if (act == thr->heap->dbg_pause_act) { - thr->heap->dbg_pause_flags &= ~DUK_PAUSE_FLAG_LINE_CHANGE; - } - prev_pause_act = thr->heap->dbg_pause_act; thr->heap->dbg_pause_act = NULL; + thr->heap->dbg_pause_flags &= ~DUK_PAUSE_FLAG_LINE_CHANGE; if (thr->heap->dbg_pause_flags & DUK_PAUSE_FLAG_FUNC_ENTRY) { DUK_D(DUK_DPRINT("PAUSE TRIGGERED by function entry (tailcall)")); duk_debug_set_paused(thr->heap); @@ -1682,10 +1672,10 @@ * Update return value stack index of current activation (if any). * * Although it might seem this is not necessary (bytecode executor - * does this for ECMAScript-to-ECMAScript calls; other calls are + * does this for Ecmascript-to-Ecmascript calls; other calls are * handled here), this turns out to be necessary for handling yield - * and resume. For them, an ECMAScript-to-native call happens, and - * the ECMAScript call's retval_byteoff must be set for things to work. + * and resume. For them, an Ecmascript-to-native call happens, and + * the Ecmascript call's retval_byteoff must be set for things to work. */ act->retval_byteoff = entry_valstack_bottom_byteoff + (duk_size_t) idx_func * sizeof(duk_tval); @@ -1892,16 +1882,16 @@ thread_state_error: DUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, "invalid thread state (%ld)", (long) thr->state); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); } /* * Main unprotected call handler, handles: * - * - All combinations of native/ECMAScript caller and native/ECMAScript + * - All combinations of native/Ecmascript caller and native/Ecmascript * target. * - * - Optimized ECMAScript-to-ECMAScript call where call handling only + * - Optimized Ecmascript-to-Ecmascript call where call handling only * sets up a new duk_activation but reuses an existing bytecode executor * (the caller) without native recursion. * @@ -1950,7 +1940,7 @@ DUK_STATS_INC(thr->heap, stats_call_all); /* If a tail call: - * - an ECMAScript activation must be on top of the callstack + * - an Ecmascript activation must be on top of the callstack * - there cannot be any catch stack entries that would catch * a return */ @@ -2055,12 +2045,6 @@ * Because 'act' is not zeroed, all fields must be filled in. */ - /* Should not be necessary, but initialize to silence warnings. */ - act = NULL; - nargs = 0; - nregs = 0; - vs_min_bytes = 0; - #if defined(DUK_USE_TAILCALL) use_tailcall = (call_flags & DUK_CALL_FLAG_TAILCALL); if (use_tailcall) { @@ -2108,7 +2092,7 @@ * compiler; the compiled function's parent env will contain * the (immutable) binding already. * - * This handling is now identical for C and ECMAScript functions. + * This handling is now identical for C and Ecmascript functions. * C functions always have the 'NEWENV' flag set, so their * environment record initialization is delayed (which is good). * @@ -2155,7 +2139,7 @@ if (func != NULL && DUK_HOBJECT_IS_COMPFUNC(func)) { /* - * ECMAScript call. + * Ecmascript call. */ DUK_ASSERT(func != NULL); @@ -2249,10 +2233,9 @@ ; } else if (rc < 0) { duk_error_throw_from_negative_rc(thr, rc); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); } else { DUK_ERROR_TYPE(thr, DUK_STR_INVALID_CFUNC_RC); - DUK_WO_NORETURN(return 0;); } } DUK_ASSERT(thr->ptr_curr_pc == NULL); @@ -2340,7 +2323,7 @@ * calls caused by side effects (e.g. when doing a DUK_OP_GETPROP), see * GH-303. Only needed for success path, error path always causes a * breakpoint recheck in the executor. It would be enough to set this - * only when returning to an ECMAScript activation, but setting the flag + * only when returning to an Ecmascript activation, but setting the flag * on every return should have no ill effect. */ #if defined(DUK_USE_DEBUGGER_SUPPORT) @@ -2452,7 +2435,6 @@ if (DUK_UNLIKELY(rc < 0)) { duk_error_throw_from_negative_rc(thr, rc); - DUK_WO_NORETURN(return;); } DUK_ASSERT(rc >= 0); @@ -2730,10 +2712,7 @@ retval = DUK_EXEC_ERROR; } #if defined(DUK_USE_CPP_EXCEPTIONS) - catch (duk_fatal_exception &exc) { - DUK_D(DUK_DPRINT("rethrow duk_fatal_exception")); - throw; - } catch (std::exception &exc) { + catch (std::exception &exc) { const char *what = exc.what(); DUK_ASSERT((duk_size_t) ((duk_uint8_t *) thr->valstack_end - (duk_uint8_t *) thr->valstack) >= entry_valstack_end_byteoff); DUK_STATS_INC(thr->heap, stats_safecall_throw); @@ -2743,7 +2722,6 @@ DUK_D(DUK_DPRINT("unexpected c++ std::exception (perhaps thrown by user code)")); try { DUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, "caught invalid c++ std::exception '%s' (perhaps thrown by user code)", what); - DUK_WO_NORETURN(return 0;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ std::exception")); DUK_UNREF(exc); @@ -2766,7 +2744,6 @@ DUK_STATS_INC(thr->heap, stats_safecall_throw); try { DUK_ERROR_TYPE(thr, "caught invalid c++ exception (perhaps thrown by user code)"); - DUK_WO_NORETURN(return 0;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ exception")); DUK_UNREF(exc); @@ -2826,7 +2803,7 @@ /* * Property-based call (foo.noSuch()) error setup: replace target function * on stack top with a specially tagged (hidden Symbol) error which gets - * thrown in call handling at the proper spot to follow ECMAScript semantics. + * thrown in call handling at the proper spot to follow Ecmascript semantics. */ #if defined(DUK_USE_VERBOSE_ERRORS) diff -Nru duktape-2.3.0/src-separate/duk_js_compiler.c duktape-2.2.0/src-separate/duk_js_compiler.c --- duktape-2.3.0/src-separate/duk_js_compiler.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_js_compiler.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,5 +1,5 @@ /* - * ECMAScript compiler. + * Ecmascript compiler. * * Parses an input string and generates a function template result. * Compilation may happen in multiple contexts (global code, eval @@ -235,9 +235,9 @@ DUK_LOCAL_DECL void duk__parse_with_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res); DUK_LOCAL_DECL void duk__parse_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_bool_t allow_source_elem); DUK_LOCAL_DECL duk_int_t duk__stmt_label_site(duk_compiler_ctx *comp_ctx, duk_int_t label_id); -DUK_LOCAL_DECL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof, duk_bool_t regexp_after); +DUK_LOCAL_DECL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof); -DUK_LOCAL_DECL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_bool_t regexp_after, duk_small_int_t expect_token); +DUK_LOCAL_DECL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_small_int_t expect_token); DUK_LOCAL_DECL void duk__parse_func_formals(duk_compiler_ctx *comp_ctx); DUK_LOCAL_DECL void duk__parse_func_like_raw(duk_compiler_ctx *comp_ctx, duk_small_uint_t flags); DUK_LOCAL_DECL duk_int_t duk__parse_func_like_fnum(duk_compiler_ctx *comp_ctx, duk_small_uint_t flags); @@ -409,7 +409,6 @@ DUK_ASSERT(comp_ctx->recursion_depth >= 0); if (comp_ctx->recursion_depth >= comp_ctx->recursion_limit) { DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_COMPILER_RECURSION_LIMIT); - DUK_WO_NORETURN(return;); } comp_ctx->recursion_depth++; } @@ -464,20 +463,15 @@ comp_ctx->curr_func.reject_regexp_in_adv = 0; regexp = 0; } - if (comp_ctx->curr_func.allow_regexp_in_adv) { - comp_ctx->curr_func.allow_regexp_in_adv = 0; - regexp = 1; - } if (expect >= 0 && comp_ctx->curr_token.t != (duk_small_uint_t) expect) { DUK_D(DUK_DPRINT("parse error: expect=%ld, got=%ld", (long) expect, (long) comp_ctx->curr_token.t)); DUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR); - DUK_WO_NORETURN(return;); } /* make current token the previous; need to fiddle with valstack "backing store" */ - duk_memcpy(&comp_ctx->prev_token, &comp_ctx->curr_token, sizeof(duk_token)); + DUK_MEMCPY(&comp_ctx->prev_token, &comp_ctx->curr_token, sizeof(duk_token)); duk_copy(thr, comp_ctx->tok11_idx, comp_ctx->tok21_idx); duk_copy(thr, comp_ctx->tok12_idx, comp_ctx->tok22_idx); @@ -525,7 +519,7 @@ entry_top = duk_get_top(thr); - duk_memzero(func, sizeof(*func)); /* intentional overlap with earlier memzero */ + DUK_MEMZERO(func, sizeof(*func)); /* intentional overlap with earlier memzero */ #if defined(DUK_USE_EXPLICIT_NULL_INIT) func->h_name = NULL; func->h_consts = NULL; @@ -772,7 +766,7 @@ (long) code_size, (long) data_size)); duk_push_fixed_buffer_nozero(thr, data_size); - h_data = (duk_hbuffer_fixed *) (void *) duk_known_hbuffer(thr, -1); + h_data = (duk_hbuffer_fixed *) duk_known_hbuffer(thr, -1); DUK_HCOMPFUNC_SET_DATA(thr->heap, h_res, (duk_hbuffer *) h_data); DUK_HEAPHDR_INCREF(thr, h_data); @@ -977,7 +971,7 @@ */ #if 0 - duk_push_literal(thr, "XXX"); + duk_push_string(thr, "XXX"); duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_INT_SOURCE, DUK_PROPDESC_FLAGS_NONE); #endif } @@ -1176,7 +1170,6 @@ fail_bc_limit: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_BYTECODE_LIMIT); - DUK_WO_NORETURN(return;); } /* Update function min/max line from current token. Needed to improve @@ -1461,7 +1454,6 @@ error_outofregs: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } /* For many of the helpers below it'd be technically correct to add @@ -1560,7 +1552,6 @@ error_outofregs: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__emit_bc(duk_compiler_ctx *comp_ctx, duk_small_uint_t op, duk_regconst_t bc) { @@ -1595,7 +1586,6 @@ error_outofregs: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__emit_load_int32_raw(duk_compiler_ctx *comp_ctx, duk_regconst_t reg, duk_int32_t val, duk_small_uint_t op_flags) { @@ -1693,7 +1683,6 @@ fail_bc_limit: DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_BYTECODE_LIMIT); - DUK_WO_NORETURN(return;); } /* Does not assume that jump_pc contains a DUK_OP_JUMP previously; this is intentional @@ -1749,7 +1738,6 @@ DUK_D(DUK_DPRINT("failed to patch trycatch: flags=%ld, reg_catch=%ld, const_varname=%ld (0x%08lx)", (long) flags, (long) reg_catch, (long) const_varname, (long) const_varname)); DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); } instr->ins |= DUK_ENC_OP_A_BC(0, 0, const_varname); } else { @@ -1941,7 +1929,6 @@ if (comp_ctx->curr_func.temp_next > DUK__MAX_TEMPS) { /* == DUK__MAX_TEMPS is OK */ DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_TEMP_LIMIT); - DUK_WO_NORETURN(return 0;); } /* maintain highest 'used' temporary, needed to figure out nregs of function */ @@ -2001,7 +1988,6 @@ if (n > DUK__MAX_CONSTS) { DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_CONST_LIMIT); - DUK_WO_NORETURN(return 0;); } DUK_DDD(DUK_DDDPRINT("allocating new constant for %!T -> const index %ld", @@ -2175,7 +2161,6 @@ } } } /* end switch */ - goto fail_internal; /* never here */ } case DUK_ISPEC_REGCONST: { if (forced_reg >= 0) { @@ -2208,13 +2193,12 @@ return x->regconst; } default: { - break; /* never here */ + break; } } - fail_internal: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_LOCAL void duk__ispec_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ispec *x, duk_regconst_t forced_reg) { @@ -2287,10 +2271,7 @@ break; } case DUK_OP_DIV: { - /* Division-by-zero is undefined - * behavior, so rely on a helper. - */ - d3 = duk_double_div(d1, d2); + d3 = d1 / d2; break; } case DUK_OP_EXP: { @@ -2317,7 +2298,7 @@ } } else if (x->op == DUK_OP_ADD && DUK_TVAL_IS_STRING(tv1) && DUK_TVAL_IS_STRING(tv2)) { /* Inline string concatenation. No need to check for - * symbols, as all inputs are valid ECMAScript strings. + * symbols, as all inputs are valid Ecmascript strings. */ duk_dup(thr, x->x1.valstack_idx); duk_dup(thr, x->x2.valstack_idx); @@ -2415,7 +2396,7 @@ } DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); + return; } /* evaluate to plain value, no forced register (temp/bound reg both ok) */ @@ -2647,7 +2628,6 @@ if (li->h_label == h_label && h_label != DUK_HTHREAD_STRING_EMPTY_STRING(thr)) { DUK_ERROR_SYNTAX(thr, DUK_STR_DUPLICATE_LABEL); - DUK_WO_NORETURN(return;); } } @@ -2777,7 +2757,6 @@ */ if (h_label != DUK_HTHREAD_STRING_EMPTY_STRING(thr)) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LABEL); - DUK_WO_NORETURN(return;); } else { DUK_DDD(DUK_DDDPRINT("continue matched an empty label which does not " "allow a continue -> continue lookup deeper in label stack")); @@ -2787,7 +2766,6 @@ /* XXX: match flag is awkward, rework */ if (!match) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LABEL); - DUK_WO_NORETURN(return;); } DUK_DDD(DUK_DDDPRINT("label match: %!O -> label_id %ld, catch_depth=%ld, pc_label=%ld", @@ -2977,7 +2955,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_ARRAY_LITERAL); - DUK_WO_NORETURN(return;); } typedef struct { @@ -3254,14 +3231,13 @@ #endif DUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_RCURLY); - duk__advance(comp_ctx); /* No RegExp after object literal. */ + duk__advance(comp_ctx); duk__ivalue_regconst(res, st.reg_obj); return; syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_OBJECT_LITERAL); - DUK_WO_NORETURN(return;); } /* Parse argument list. Arguments are written to temps starting from @@ -3305,7 +3281,7 @@ } /* eat the right paren */ - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* RegExp mode does not matter. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); DUK_DDD(DUK_DDDPRINT("end parsing arguments")); @@ -3438,7 +3414,7 @@ duk__expr(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); /* Expression, terminates at a ')' */ - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* No RegExp after parenthesized expression. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); comp_ctx->curr_func.allow_in = prev_allow_in; comp_ctx->curr_func.paren_level--; return; @@ -3573,7 +3549,6 @@ if (comp_ctx->curr_func.is_strict) { DUK_ERROR_SYNTAX(thr, DUK_STR_CANNOT_DELETE_IDENTIFIER); - DUK_WO_NORETURN(return;); } DUK__SETTEMP(comp_ctx, temp_at_entry); @@ -3738,7 +3713,7 @@ } /* end switch */ DUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR); - DUK_WO_NORETURN(return;); + return; unary: { @@ -3842,12 +3817,10 @@ #if defined(DUK_USE_ES6) syntax_error_newtarget: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_NEWTARGET); - DUK_WO_NORETURN(return;); #endif syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_EXPRESSION); - DUK_WO_NORETURN(return;); } /* XXX: add flag to indicate whether caller cares about return value; this @@ -3902,7 +3875,6 @@ /* NB: must accept reserved words as property name */ if (comp_ctx->curr_token.t_nores != DUK_TOK_IDENTIFIER) { DUK_ERROR_SYNTAX(thr, DUK_STR_EXPECTED_IDENTIFIER); - DUK_WO_NORETURN(return;); } res->t = DUK_IVAL_PROP; @@ -4332,7 +4304,7 @@ DUK_D(DUK_DPRINT("parse error: unexpected token: %ld", (long) tok)); DUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR); - DUK_WO_NORETURN(return;); + return; #if 0 /* XXX: shared handling for 'duk__expr_lhs'? */ @@ -4562,7 +4534,7 @@ * one instruction, so use explicit PC computation. */ DUK_DD(DUK_DDPRINT("rhs is side effect free, rewind and avoid unnecessary temp for reg-based =")); - DUK_BW_ADD_PTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, (pc_temp_load - pc_before_rhs) * (duk_int_t) sizeof(duk_compiler_instr)); + DUK_BW_ADD_PTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, (duk_size_t) (pc_temp_load - pc_before_rhs) * sizeof(duk_compiler_instr)); reg_src = reg_varbind; } else { DUK_DD(DUK_DDPRINT("rhs evaluation emitted code, not sure if rhs is side effect free; use temp reg for LHS")); @@ -4822,11 +4794,11 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_EXPRESSION); - DUK_WO_NORETURN(return;); + return; syntax_error_lvalue: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LVALUE); - DUK_WO_NORETURN(return;); + return; } DUK_LOCAL duk_small_uint_t duk__expr_lbp(duk_compiler_ctx *comp_ctx) { @@ -4891,7 +4863,7 @@ (long) rbp_flags, (long) rbp, (long) comp_ctx->curr_func.allow_in, (long) comp_ctx->curr_func.paren_level)); - duk_memzero(&tmp_alloc, sizeof(tmp_alloc)); + DUK_MEMZERO(&tmp_alloc, sizeof(tmp_alloc)); tmp->x1.valstack_idx = duk_get_top(thr); tmp->x2.valstack_idx = tmp->x1.valstack_idx + 1; duk_push_undefined(thr); @@ -4911,7 +4883,6 @@ DUK_DDD(DUK_DDDPRINT("empty expression")); if (!(rbp_flags & DUK__EXPR_FLAG_ALLOW_EMPTY)) { DUK_ERROR_SYNTAX(thr, DUK_STR_EMPTY_EXPR_NOT_ALLOWED); - DUK_WO_NORETURN(return;); } duk_push_undefined(thr); duk__ivalue_plain_fromstack(comp_ctx, res); @@ -4950,7 +4921,6 @@ if (!(rbp_flags & DUK__EXPR_FLAG_ALLOW_EMPTY) && duk__expr_is_empty(comp_ctx)) { DUK_ERROR_SYNTAX(thr, DUK_STR_EMPTY_EXPR_NOT_ALLOWED); - DUK_WO_NORETURN(return;); } } @@ -5143,7 +5113,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_VAR_DECLARATION); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_var_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t expr_flags) { @@ -5375,8 +5344,7 @@ } DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); pc_l3 = duk__get_current_pc(comp_ctx); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -5467,8 +5435,7 @@ pc_jumpto_l4 = duk__emit_jump_empty(comp_ctx); DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); pc_l3 = duk__get_current_pc(comp_ctx); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -5517,7 +5484,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_FOR); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_switch_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site) { @@ -5559,7 +5525,7 @@ duk__advance(comp_ctx); duk__advance_expect(comp_ctx, DUK_TOK_LPAREN); rc_switch = duk__exprtop_toregconst(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* RegExp mode does not matter. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__advance_expect(comp_ctx, DUK_TOK_LCURLY); DUK_DDD(DUK_DDDPRINT("switch value in register %ld", (long) rc_switch)); @@ -5684,8 +5650,7 @@ } DUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_RCURLY); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance(comp_ctx); /* Allow RegExp as part of next stmt. */ + duk__advance(comp_ctx); /* default case control flow patchup; note that if pc_prevcase < 0 * (i.e. no case clauses), control enters default case automatically. @@ -5718,7 +5683,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_SWITCH); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_if_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res) { @@ -5738,8 +5702,7 @@ pc_jump_false = duk__emit_jump_empty(comp_ctx); /* jump to end or else part */ DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -5775,7 +5738,7 @@ DUK_DDD(DUK_DDDPRINT("begin parsing do statement")); - duk__advance(comp_ctx); /* Eat 'do'; allow RegExp as part of next stmt. */ + duk__advance(comp_ctx); /* eat 'do' */ pc_start = duk__get_current_pc(comp_ctx); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); @@ -5789,7 +5752,6 @@ duk__emit_jump(comp_ctx, pc_start); /* no need to reset temps, as we're finished emitting code */ - comp_ctx->curr_func.allow_regexp_in_adv = 1; /* Allow RegExp as part of next stmt. */ duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__patch_jump_here(comp_ctx, pc_label_site + 1); /* break jump */ @@ -5819,8 +5781,7 @@ pc_jump_false = duk__emit_jump_empty(comp_ctx); DUK__SETTEMP(comp_ctx, temp_reset); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); duk__emit_jump(comp_ctx, pc_start); @@ -5856,7 +5817,6 @@ duk__advance(comp_ctx); } else { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_BREAK_CONT_LABEL); - DUK_WO_NORETURN(return;); } /* Use a fast break/continue when possible. A fast break/continue is @@ -5898,7 +5858,6 @@ */ if (!comp_ctx->curr_func.is_function) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_RETURN); - DUK_WO_NORETURN(return;); } if (comp_ctx->curr_token.t == DUK_TOK_SEMICOLON || /* explicit semi follows */ @@ -6000,7 +5959,6 @@ if (comp_ctx->curr_token.lineterm) { DUK_ERROR_SYNTAX(comp_ctx->thr, DUK_STR_INVALID_THROW); - DUK_WO_NORETURN(return;); } reg_val = duk__exprtop_toreg(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); @@ -6057,9 +6015,10 @@ /* try part */ duk__advance_expect(comp_ctx, DUK_TOK_LCURLY); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ - duk__emit_op_only(comp_ctx, DUK_OP_ENDTRY); + duk__emit_op_only(comp_ctx, + DUK_OP_ENDTRY); if (comp_ctx->curr_token.t == DUK_TOK_CATCH) { /* @@ -6155,7 +6114,7 @@ DUK_DDD(DUK_DDDPRINT("varmap before parsing catch clause: %!iT", (duk_tval *) duk_get_tval(thr, comp_ctx->curr_func.varmap_idx))); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ if (varmap_value == -2) { @@ -6197,7 +6156,7 @@ duk__advance(comp_ctx); duk__advance_expect(comp_ctx, DUK_TOK_LCURLY); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ duk__emit_abc(comp_ctx, DUK_OP_ENDFIN, @@ -6240,7 +6199,6 @@ syntax_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_TRY); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__parse_with_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res) { @@ -6251,7 +6209,6 @@ if (comp_ctx->curr_func.is_strict) { DUK_ERROR_SYNTAX(comp_ctx->thr, DUK_STR_WITH_IN_STRICT_MODE); - DUK_WO_NORETURN(return;); } comp_ctx->curr_func.catch_depth++; @@ -6262,8 +6219,7 @@ duk__advance_expect(comp_ctx, DUK_TOK_LPAREN); duk__exprtop_toforcedreg(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/, reg_catch); - comp_ctx->curr_func.allow_regexp_in_adv = 1; - duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); /* Allow RegExp as part of next stmt. */ + duk__advance_expect(comp_ctx, DUK_TOK_RPAREN); pc_trycatch = duk__get_current_pc(comp_ctx); trycatch_flags = DUK_BC_TRYCATCH_FLAG_WITH_BINDING; @@ -6275,7 +6231,8 @@ duk__emit_invalid(comp_ctx); /* finished jump */ duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/); - duk__emit_op_only(comp_ctx, DUK_OP_ENDTRY); + duk__emit_op_only(comp_ctx, + DUK_OP_ENDTRY); pc_finished = duk__get_current_pc(comp_ctx); @@ -6442,14 +6399,13 @@ break; } else { DUK_ERROR_SYNTAX(thr, DUK_STR_FUNC_STMT_NOT_ALLOWED); - DUK_WO_NORETURN(return;); } break; } case DUK_TOK_LCURLY: { DUK_DDD(DUK_DDDPRINT("block statement")); duk__advance(comp_ctx); - duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/, 1 /*regexp_after*/); + duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/); /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */ if (label_id >= 0) { duk__patch_jump_here(comp_ctx, pc_at_entry + 1); /* break jump */ @@ -6703,7 +6659,7 @@ */ if (DUK_HSTRING_GET_BYTELEN(h_dir) == 10 && - DUK_STRCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use strict") == 0) { + DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use strict", 10) == 0) { #if defined(DUK_USE_STRICT_DECL) DUK_DDD(DUK_DDDPRINT("use strict directive detected: strict flag %ld -> %ld", (long) comp_ctx->curr_func.is_strict, (long) 1)); @@ -6712,7 +6668,7 @@ DUK_DDD(DUK_DDDPRINT("use strict detected but strict declarations disabled, ignoring")); #endif } else if (DUK_HSTRING_GET_BYTELEN(h_dir) == 14 && - DUK_STRCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use duk notail") == 0) { + DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use duk notail", 14) == 0) { DUK_DDD(DUK_DDDPRINT("use duk notail directive detected: notail flag %ld -> %ld", (long) comp_ctx->curr_func.is_notail, (long) 1)); comp_ctx->curr_func.is_notail = 1; @@ -6780,7 +6736,6 @@ "even though no lineterm present before next token)")); } else { DUK_ERROR_SYNTAX(thr, DUK_STR_UNTERMINATED_STMT); - DUK_WO_NORETURN(return;); } } } else { @@ -6829,7 +6784,7 @@ * (EOF or closing brace). */ -DUK_LOCAL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof, duk_bool_t regexp_after) { +DUK_LOCAL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof) { duk_hthread *thr = comp_ctx->thr; duk_ivalue res_alloc; duk_ivalue *res = &res_alloc; @@ -6843,7 +6798,7 @@ * for nested functions (which may occur inside expressions). */ - duk_memzero(&res_alloc, sizeof(res_alloc)); + DUK_MEMZERO(&res_alloc, sizeof(res_alloc)); res->t = DUK_IVAL_PLAIN; res->x1.t = DUK_ISPEC_VALUE; res->x1.valstack_idx = duk_get_top(thr); @@ -6877,15 +6832,6 @@ duk__parse_stmt(comp_ctx, res, allow_source_elem); } - /* RegExp is allowed / not allowed depending on context. For function - * declarations RegExp is allowed because it follows a function - * declaration statement and may appear as part of the next statement. - * For function expressions RegExp is not allowed, and it's possible - * to do something like '(function () {} / 123)'. - */ - if (regexp_after) { - comp_ctx->curr_func.allow_regexp_in_adv = 1; - } duk__advance(comp_ctx); /* Tear down state. */ @@ -7209,11 +7155,13 @@ error_outofregs: DUK_ERROR_RANGE(thr, DUK_STR_REG_LIMIT); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); + return; error_argname: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_ARG_NAME); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); + return; } /* @@ -7250,7 +7198,7 @@ * token (EOF or closing brace). */ -DUK_LOCAL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_bool_t regexp_after, duk_small_int_t expect_token) { +DUK_LOCAL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_small_int_t expect_token) { duk_compiler_func *func; duk_hthread *thr; duk_regconst_t reg_stmt_value = -1; @@ -7322,9 +7270,7 @@ func->max_line = 0; #endif - /* duk__parse_stmts() expects curr_tok to be set; parse in "allow - * regexp literal" mode with current strictness. - */ + /* duk__parse_stmts() expects curr_tok to be set; parse in "allow regexp literal" mode with current strictness */ if (expect_token >= 0) { /* Eating a left curly; regexp mode is allowed by left curly * based on duk__token_lbp[] automatically. @@ -7343,8 +7289,7 @@ DUK_DDD(DUK_DDDPRINT("begin 1st pass")); duk__parse_stmts(comp_ctx, 1, /* allow source elements */ - expect_eof, /* expect EOF instead of } */ - regexp_after); /* regexp after */ + expect_eof); /* expect EOF instead of } */ DUK_DDD(DUK_DDDPRINT("end 1st pass")); /* @@ -7451,8 +7396,7 @@ DUK_DDD(DUK_DDDPRINT("begin 2nd pass")); duk__parse_stmts(comp_ctx, 1, /* allow source elements */ - expect_eof, /* expect EOF instead of } */ - regexp_after); /* regexp after */ + expect_eof); /* expect EOF instead of } */ DUK_DDD(DUK_DDDPRINT("end 2nd pass")); duk__update_lineinfo_currtoken(comp_ctx); @@ -7465,7 +7409,6 @@ /* Should never happen but avoid infinite loop just in case. */ DUK_D(DUK_DPRINT("more than 3 compile passes needed, should never happen")); DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); } DUK_D(DUK_DPRINT("need additional round to compile function, round now %d", (int) compile_round)); } @@ -7509,7 +7452,6 @@ error_funcname: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_FUNC_NAME); - DUK_WO_NORETURN(return;); } /* @@ -7558,7 +7500,6 @@ if (comp_ctx->curr_token.t != DUK_TOK_IDENTIFIER) { DUK_ERROR_SYNTAX(thr, DUK_STR_EXPECTED_IDENTIFIER); - DUK_WO_NORETURN(return;); } DUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_IDENTIFIER); DUK_ASSERT(comp_ctx->curr_token.str1 != NULL); @@ -7624,7 +7565,6 @@ duk_to_string(thr, -1); } else { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_GETSET_NAME); - DUK_WO_NORETURN(return;); } comp_ctx->curr_func.h_name = duk_known_hstring(thr, -1); /* borrowed reference */ } else { @@ -7642,7 +7582,6 @@ no_advance = 1; if (flags & DUK__FUNC_FLAG_DECL) { DUK_ERROR_SYNTAX(thr, DUK_STR_FUNC_NAME_REQUIRED); - DUK_WO_NORETURN(return;); } } } @@ -7676,7 +7615,6 @@ duk__parse_func_body(comp_ctx, 0, /* expect_eof */ 0, /* implicit_return_value */ - flags & DUK__FUNC_FLAG_DECL, /* regexp_after */ DUK_TOK_LCURLY); /* expect_token */ /* @@ -7729,14 +7667,6 @@ comp_ctx->curr_token.t = 0; /* this is needed for regexp mode */ comp_ctx->curr_token.start_line = 0; /* needed for line number tracking (becomes prev_token.start_line) */ duk__advance(comp_ctx); - - /* RegExp is not allowed after a function expression, e.g. in - * (function () {} / 123). A RegExp *is* allowed after a - * function declaration! - */ - if (flags & DUK__FUNC_FLAG_DECL) { - comp_ctx->curr_func.allow_regexp_in_adv = 1; - } duk__advance_expect(comp_ctx, DUK_TOK_RCURLY); return fnum; @@ -7751,9 +7681,9 @@ DUK_DDD(DUK_DDDPRINT("before func: entry_top=%ld, curr_tok.start_offset=%ld", (long) entry_top, (long) comp_ctx->curr_token.start_offset)); - duk_memcpy(&old_func, &comp_ctx->curr_func, sizeof(duk_compiler_func)); + DUK_MEMCPY(&old_func, &comp_ctx->curr_func, sizeof(duk_compiler_func)); - duk_memzero(&comp_ctx->curr_func, sizeof(duk_compiler_func)); + DUK_MEMZERO(&comp_ctx->curr_func, sizeof(duk_compiler_func)); duk__init_func_valstack_slots(comp_ctx); DUK_ASSERT(comp_ctx->curr_func.num_formals == 0); @@ -7795,7 +7725,6 @@ if (fnum > DUK__MAX_FUNCS) { DUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_FUNC_LIMIT); - DUK_WO_NORETURN(return 0;); } /* array writes autoincrement length */ @@ -7820,7 +7749,7 @@ } else { duk_set_top(thr, entry_top); } - duk_memcpy((void *) &comp_ctx->curr_func, (void *) &old_func, sizeof(duk_compiler_func)); + DUK_MEMCPY((void *) &comp_ctx->curr_func, (void *) &old_func, sizeof(duk_compiler_func)); return fnum; } @@ -7829,7 +7758,7 @@ * Compile input string into an executable function template without * arguments. * - * The string is parsed as the "Program" production of ECMAScript E5. + * The string is parsed as the "Program" production of Ecmascript E5. * Compilation context can be either global code or eval code (see E5 * Sections 14 and 15.1.2.1). * @@ -7970,7 +7899,6 @@ duk__parse_func_body(comp_ctx, 1, /* expect_eof */ 1, /* implicit_return_value */ - 1, /* regexp_after (does not matter) */ -1); /* expect_token */ } @@ -7998,7 +7926,7 @@ DUK_ASSERT(src_buffer != NULL); /* preinitialize lexer state partially */ - duk_memzero(&comp_stk, sizeof(comp_stk)); + DUK_MEMZERO(&comp_stk, sizeof(comp_stk)); comp_stk.flags = flags; DUK_LEXER_INITCTX(&comp_stk.comp_ctx_alloc.lex); comp_stk.comp_ctx_alloc.lex.input = src_buffer; @@ -8015,7 +7943,6 @@ if (safe_rc != DUK_EXEC_SUCCESS) { DUK_D(DUK_DPRINT("compilation failed: %!T", duk_get_tval(thr, -1))); (void) duk_throw(thr); - DUK_WO_NORETURN(return;); } /* [ ... template ] */ diff -Nru duktape-2.3.0/src-separate/duk_js_compiler.h duktape-2.2.0/src-separate/duk_js_compiler.h --- duktape-2.3.0/src-separate/duk_js_compiler.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_js_compiler.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,11 +1,11 @@ /* - * ECMAScript compiler. + * Ecmascript compiler. */ #if !defined(DUK_JS_COMPILER_H_INCLUDED) #define DUK_JS_COMPILER_H_INCLUDED -/* ECMAScript compiler limits */ +/* ecmascript compiler limits */ #define DUK_COMPILER_TOKEN_LIMIT 100000000L /* 1e8: protects against deeply nested inner functions */ /* maximum loopcount for peephole optimization */ @@ -187,7 +187,6 @@ duk_uint8_t is_arguments_shadowed; /* argument/function declaration shadows 'arguments' */ duk_uint8_t needs_shuffle; /* function needs shuffle registers */ duk_uint8_t reject_regexp_in_adv; /* reject RegExp literal on next advance() call; needed for handling IdentifierName productions */ - duk_uint8_t allow_regexp_in_adv; /* allow RegExp literal on next advance() call */ }; struct duk_compiler_ctx { diff -Nru duktape-2.3.0/src-separate/duk_js_executor.c duktape-2.2.0/src-separate/duk_js_executor.c --- duktape-2.3.0/src-separate/duk_js_executor.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_js_executor.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,5 +1,5 @@ /* - * ECMAScript bytecode executor. + * Ecmascript bytecode executor. */ #include "duk_internal.h" @@ -50,7 +50,7 @@ tv_dst = thr->valstack_top; copy_size = sizeof(duk_tval) * count; - duk_memcpy((void *) tv_dst, (const void *) tv_src, copy_size); + DUK_MEMCPY((void *) tv_dst, (const void *) tv_src, copy_size); for (i = 0; i < count; i++) { DUK_TVAL_INCREF(thr, tv_dst); tv_dst++; @@ -314,10 +314,7 @@ break; } case DUK_OP_DIV >> 2: { - /* Division-by-zero is undefined behavior, so - * rely on a helper. - */ - du.d = duk_double_div(d1, d2); + du.d = d1 / d2; break; } case DUK_OP_MOD >> 2: { @@ -774,7 +771,7 @@ * top are combined into one pass. */ -/* Reconfigure value stack for return to an ECMAScript function at +/* Reconfigure value stack for return to an Ecmascript function at * callstack top (caller unwinds). */ DUK_LOCAL void duk__reconfig_valstack_ecma_return(duk_hthread *thr) { @@ -790,7 +787,7 @@ /* Clamp so that values at 'clamp_top' and above are wiped and won't * retain reachable garbage. Then extend to 'nregs' because we're - * returning to an ECMAScript function. + * returning to an Ecmascript function. */ h_func = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act); @@ -806,7 +803,7 @@ /* XXX: a best effort shrink check would be OK here */ } -/* Reconfigure value stack for an ECMAScript catcher. Use topmost catcher +/* Reconfigure value stack for an Ecmascript catcher. Use topmost catcher * in 'act'. */ DUK_LOCAL void duk__reconfig_valstack_ecma_catcher(duk_hthread *thr, duk_activation *act) { @@ -1042,7 +1039,7 @@ act_resumer = resumer->callstack_curr; DUK_ASSERT(act_resumer != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(act_resumer) != NULL); - DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(act_resumer))); /* resume caller must be an ECMAScript func */ + DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(act_resumer))); /* resume caller must be an ecmascript func */ tv1 = (duk_tval *) (void *) ((duk_uint8_t *) resumer->valstack + act_resumer->retval_byteoff); /* return value from Duktape.Thread.resume() */ DUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv_val_unstable); /* side effects */ /* XXX: avoid side effects */ @@ -1098,7 +1095,7 @@ /* duk_bi_duk_object_yield() and duk_bi_duk_object_resume() ensure all of these are met */ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); /* unchanged by Duktape.Thread.resume() */ - DUK_ASSERT(thr->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(thr->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(thr->callstack_curr != NULL); DUK_ASSERT(thr->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL && @@ -1116,7 +1113,7 @@ DUK_ASSERT(resumee->state == DUK_HTHREAD_STATE_INACTIVE || resumee->state == DUK_HTHREAD_STATE_YIELDED); /* checked by Duktape.Thread.resume() */ DUK_ASSERT(resumee->state != DUK_HTHREAD_STATE_YIELDED || - resumee->callstack_top >= 2); /* YIELDED: ECMAScript activation + Duktape.Thread.yield() activation */ + resumee->callstack_top >= 2); /* YIELDED: Ecmascript activation + Duktape.Thread.yield() activation */ DUK_ASSERT(resumee->state != DUK_HTHREAD_STATE_YIELDED || (DUK_ACT_GET_FUNC(resumee->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(resumee->callstack_curr)) && @@ -1154,8 +1151,8 @@ goto check_longjmp; } else if (resumee->state == DUK_HTHREAD_STATE_YIELDED) { /* Unwind previous Duktape.Thread.yield() call. The - * activation remaining must always be an ECMAScript - * call now (yield() accepts calls from ECMAScript + * activation remaining must always be an Ecmascript + * call now (yield() accepts calls from Ecmascript * only). */ duk_activation *act_resumee; @@ -1163,7 +1160,7 @@ DUK_ASSERT(resumee->callstack_top >= 2); act_resumee = resumee->callstack_curr; /* Duktape.Thread.yield() */ DUK_ASSERT(act_resumee != NULL); - act_resumee = act_resumee->parent; /* ECMAScript call site for yield() */ + act_resumee = act_resumee->parent; /* Ecmascript call site for yield() */ DUK_ASSERT(act_resumee != NULL); tv = (duk_tval *) (void *) ((duk_uint8_t *) resumee->valstack + act_resumee->retval_byteoff); /* return value from Duktape.Thread.yield() */ @@ -1211,7 +1208,6 @@ * executor which can be quite misleading. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); } DUK_ASSERT(resumee->resumer == NULL); @@ -1234,7 +1230,7 @@ case DUK_LJ_TYPE_YIELD: { /* * Currently only allowed only if yielding thread has only - * ECMAScript activations (except for the Duktape.Thread.yield() + * Ecmascript activations (except for the Duktape.Thread.yield() * call at the callstack top) and none of them constructor * calls. * @@ -1250,27 +1246,27 @@ DUK_ASSERT(thr != entry_thread); /* Duktape.Thread.yield() should prevent */ #endif DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); /* unchanged from Duktape.Thread.yield() */ - DUK_ASSERT(thr->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.yield() activation */ + DUK_ASSERT(thr->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.yield() activation */ DUK_ASSERT(thr->callstack_curr != NULL); DUK_ASSERT(thr->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr)) && ((duk_hnatfunc *) DUK_ACT_GET_FUNC(thr->callstack_curr))->func == duk_bi_thread_yield); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* an Ecmascript function */ resumer = thr->resumer; DUK_ASSERT(resumer != NULL); DUK_ASSERT(resumer->state == DUK_HTHREAD_STATE_RESUMED); /* written by a previous RESUME handling */ - DUK_ASSERT(resumer->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(resumer->callstack_curr != NULL); DUK_ASSERT(resumer->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(resumer->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(resumer->callstack_curr)) && ((duk_hnatfunc *) DUK_ACT_GET_FUNC(resumer->callstack_curr))->func == duk_bi_thread_resume); DUK_ASSERT(DUK_ACT_GET_FUNC(resumer->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(resumer->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(resumer->callstack_curr->parent))); /* an Ecmascript function */ if (thr->heap->lj.iserror) { thr->state = DUK_HTHREAD_STATE_YIELDED; @@ -1324,7 +1320,7 @@ * resumer in this case.) * * Note: until we hit the entry level, there can only be - * ECMAScript activations. + * Ecmascript activations. */ duk_activation *act; @@ -1391,11 +1387,11 @@ */ DUK_ASSERT(thr->resumer != NULL); - DUK_ASSERT(thr->resumer->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(thr->resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(thr->resumer->callstack_curr != NULL); DUK_ASSERT(thr->resumer->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an Ecmascript function */ resumer = thr->resumer; @@ -1448,7 +1444,8 @@ * infinite loop in this catchpoint. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); + return retval; } /* Handle a BREAK/CONTINUE opcode. Avoid using longjmp() for BREAK/CONTINUE @@ -1512,7 +1509,7 @@ /* Should never happen, but be robust. */ DUK_D(DUK_DPRINT("-> break/continue not caught by anything in the current function (should never happen), throw internal error")); DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); + return; } /* Handle a RETURN opcode. Avoid using longjmp() for return handling because @@ -1547,7 +1544,7 @@ * 2. The return happens at the entry level of the bytecode * executor, so return from the executor (in C stack). * - * 3. There is a calling (ECMAScript) activation in the call + * 3. There is a calling (Ecmascript) activation in the call * stack => return to it, in the same executor instance. * * 4. There is no calling activation, and the thread is @@ -1592,16 +1589,16 @@ } if (thr->callstack_top >= 2) { - /* There is a caller; it MUST be an ECMAScript caller (otherwise it would + /* There is a caller; it MUST be an Ecmascript caller (otherwise it would * match entry_act check). */ - DUK_DDD(DUK_DDDPRINT("return to ECMAScript caller, retval_byteoff=%ld, lj_value1=%!T", + DUK_DDD(DUK_DDDPRINT("return to Ecmascript caller, retval_byteoff=%ld, lj_value1=%!T", (long) (thr->callstack_curr->parent->retval_byteoff), (duk_tval *) &thr->heap->lj.value1)); DUK_ASSERT(thr->callstack_curr != NULL); DUK_ASSERT(thr->callstack_curr->parent != NULL); - DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* must be ECMAScript */ + DUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr->parent))); /* must be ecmascript */ #if defined(DUK_USE_ES6_PROXY) if (thr->callstack_curr->flags & (DUK_ACT_FLAG_CONSTRUCT | DUK_ACT_FLAG_CONSTRUCT_PROXY)) { @@ -1631,51 +1628,31 @@ DUK_DD(DUK_DDPRINT("no calling activation, thread finishes (similar to yield)")); DUK_ASSERT(thr->resumer != NULL); - DUK_ASSERT(thr->resumer->callstack_top >= 2); /* ECMAScript activation + Duktape.Thread.resume() activation */ + DUK_ASSERT(thr->resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */ DUK_ASSERT(thr->resumer->callstack_curr != NULL); DUK_ASSERT(thr->resumer->callstack_curr->parent != NULL); DUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr) != NULL && DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr)) && ((duk_hnatfunc *) DUK_ACT_GET_FUNC(thr->resumer->callstack_curr))->func == duk_bi_thread_resume); /* Duktape.Thread.resume() */ DUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent) != NULL && - DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an ECMAScript function */ + DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr->parent))); /* an Ecmascript function */ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); DUK_ASSERT(thr->resumer->state == DUK_HTHREAD_STATE_RESUMED); resumer = thr->resumer; - /* Share yield longjmp handler. - * - * This sequence of steps is a bit fragile (see GH-1845): - * - We need the return value from 'thr' (resumed thread) value stack. - * The termination unwinds its value stack, losing the value. - * - We need a refcounted reference for 'thr', which may only exist - * in the caller value stack. We can't unwind or reconfigure the - * caller's value stack without potentially freeing 'thr'. - * - * Current approach is to capture the 'thr' return value and store - * a reference to 'thr' in the caller value stack temporarily. This - * keeps 'thr' reachable until final yield/return handling which - * removes the references atomatically. - */ - + /* Share yield longjmp handler. */ DUK_ASSERT(thr->valstack_top - 1 >= thr->valstack_bottom); - duk_hthread_activation_unwind_norz(resumer); /* May remove last reference to 'thr', but is NORZ. */ - duk_push_tval(resumer, thr->valstack_top - 1); /* Capture return value, side effect free. */ - duk_push_hthread(resumer, thr); /* Make 'thr' reachable again, before side effects. */ + duk_hthread_activation_unwind_norz(resumer); + duk__handle_yield(thr, resumer, thr->valstack_top - 1); - duk_hthread_terminate(thr); /* Updates thread state, minimizes its allocations. */ - thr->resumer = NULL; - DUK_HTHREAD_DECREF(thr, resumer); + duk_hthread_terminate(thr); /* updates thread state, minimizes its allocations */ DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_TERMINATED); + thr->resumer = NULL; + DUK_HTHREAD_DECREF(thr, resumer); resumer->state = DUK_HTHREAD_STATE_RUNNING; DUK_HEAP_SWITCH_THREAD(thr->heap, resumer); - - DUK_ASSERT(resumer->valstack_top - 2 >= resumer->valstack_bottom); - duk__handle_yield(thr, resumer, resumer->valstack_top - 2); - thr = NULL; /* 'thr' invalidated by call */ - #if 0 thr = resumer; /* not needed */ #endif @@ -1685,7 +1662,7 @@ #else /* Without coroutine support this case should never happen. */ DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + return DUK__RETHAND_FINISHED; /* not executed */ #endif } @@ -1835,7 +1812,7 @@ if (diff_last < 0.0 || diff_last >= (duk_double_t) DUK_HEAP_DBG_RATELIMIT_MILLISECS) { /* Monotonic time should not experience time jumps, * but the provider may be missing and we're actually - * using ECMAScript time. So, tolerate negative values + * using Ecmascript time. So, tolerate negative values * so that a time jump works reasonably. * * Same interval is now used for status sending and @@ -1984,7 +1961,6 @@ thr->interrupt_counter = 0; DUK_HEAP_CLEAR_INTERRUPT_RUNNING(thr->heap); DUK_ERROR_RANGE(thr, "execution timeout"); - DUK_WO_NORETURN(return 0;); } #endif /* DUK_USE_EXEC_TIMEOUT_CHECK */ @@ -2670,7 +2646,7 @@ } /* - * ECMAScript bytecode executor. + * Ecmascript bytecode executor. * * Resume execution for the current thread from its current activation. * Returns when execution would return from the entry level activation, @@ -2679,7 +2655,7 @@ * a longjmp() with type DUK_LJ_TYPE_THROW is called on the entry level * setjmp() jmpbuf. * - * ECMAScript function calls and coroutine resumptions are handled + * Ecmascript function calls and coroutine resumptions are handled * internally (by the outer executor function) without recursive C calls. * Other function calls are handled using duk_handle_call(), increasing * C recursion depth. @@ -2772,7 +2748,6 @@ #if defined(DUK_USE_VERBOSE_EXECUTOR_ERRORS) #define DUK__INTERNAL_ERROR(msg) do { \ DUK_ERROR_ERROR(thr, (msg)); \ - DUK_WO_NORETURN(return;); \ } while (0) #else #define DUK__INTERNAL_ERROR(msg) do { \ @@ -2937,10 +2912,7 @@ entry_jmpbuf_ptr); } #if defined(DUK_USE_CPP_EXCEPTIONS) - catch (duk_fatal_exception &exc) { - DUK_D(DUK_DPRINT("rethrow duk_fatal_exception")); - throw; - } catch (std::exception &exc) { + catch (std::exception &exc) { const char *what = exc.what(); if (!what) { what = "unknown"; @@ -2950,7 +2922,6 @@ try { DUK_ASSERT(heap->curr_thread != NULL); DUK_ERROR_FMT1(heap->curr_thread, DUK_ERR_TYPE_ERROR, "caught invalid c++ std::exception '%s' (perhaps thrown by user code)", what); - DUK_WO_NORETURN(return;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ std::exception")); DUK_UNREF(exc); @@ -2965,7 +2936,6 @@ try { DUK_ASSERT(heap->curr_thread != NULL); DUK_ERROR_TYPE(heap->curr_thread, "caught invalid c++ exception (perhaps thrown by user code)"); - DUK_WO_NORETURN(return;); } catch (duk_internal_exception exc) { DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ exception")); DUK_UNREF(exc); @@ -2978,7 +2948,7 @@ #endif } - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); } /* Inner executor, performance critical. */ @@ -3347,7 +3317,7 @@ /* XXX: fast double-to-int conversion, we know number is integer in [-0x80000000,0xffffffff]. */ val = (duk_int32_t) DUK_TVAL_GET_NUMBER(tv1); #endif - val = (duk_int32_t) ((duk_uint32_t) val << DUK_BC_LDINTX_SHIFT) + (duk_int32_t) DUK_DEC_BC(ins); /* no bias */ + val = (val << DUK_BC_LDINTX_SHIFT) + (duk_int32_t) DUK_DEC_BC(ins); /* no bias */ DUK_TVAL_SET_I32_UPDREF(thr, tv1, val); /* side effects */ break; } @@ -5002,7 +4972,7 @@ case DUK_OP_INVLHS: { DUK_ERROR_REFERENCE(thr, DUK_STR_INVALID_LVALUE); - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); break; } @@ -5037,13 +5007,45 @@ case DUK_OP_INVALID: { DUK_ERROR_FMT1(thr, DUK_ERR_ERROR, "INVALID opcode (%ld)", (long) DUK_DEC_ABC(ins)); - DUK_WO_NORETURN(return;); break; } #if defined(DUK_USE_ES6) case DUK_OP_NEWTARGET: { - duk_push_new_target(thr); + /* https://www.ecma-international.org/ecma-262/6.0/#sec-meta-properties-runtime-semantics-evaluation + * https://www.ecma-international.org/ecma-262/6.0/#sec-getnewtarget + * + * No newTarget support now, so as a first approximation + * use the resolved (non-bound) target function. + */ + /* XXX: C API: push_new_target()? */ + duk_activation *act; + + act = thr->callstack_curr; + DUK_ASSERT(act != NULL); + + /* Check CONSTRUCT flag from current function, or if running + * direct eval, from a non-direct-eval parent (with possibly + * more than one nested direct eval). An alternative to this + * would be to store [[NewTarget]] as a hidden symbol of the + * lexical scope, and then just look up that variable. + */ + for (;;) { + if (act == NULL) { + duk_push_undefined(thr); + break; + } + if (act->flags & DUK_ACT_FLAG_CONSTRUCT) { + duk_push_tval(thr, &act->tv_func); + break; + } else if (act->flags & DUK_ACT_FLAG_DIRECT_EVAL) { + act = act->parent; + } else { + duk_push_undefined(thr); + break; + } + } + DUK__REPLACE_TOP_BC_BREAK(); } #endif /* DUK_USE_ES6 */ @@ -5145,11 +5147,10 @@ continue; #endif } - DUK_WO_NORETURN(return;); + DUK_UNREACHABLE(); #if !defined(DUK_USE_VERBOSE_EXECUTOR_ERRORS) internal_error: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return;); #endif } diff -Nru duktape-2.3.0/src-separate/duk_js.h duktape-2.2.0/src-separate/duk_js.h --- duktape-2.3.0/src-separate/duk_js.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_js.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,5 +1,5 @@ /* - * ECMAScript execution, support primitives. + * Ecmascript execution, support primitives. */ #if !defined(DUK_JS_H_INCLUDED) @@ -43,9 +43,6 @@ #endif DUK_INTERNAL_DECL duk_bool_t duk_js_compare_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_uint_t flags); DUK_INTERNAL_DECL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y); -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL_DECL duk_bool_t duk_js_instanceof_ordinary(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y); -#endif DUK_INTERNAL_DECL duk_bool_t duk_js_in(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y); DUK_INTERNAL_DECL duk_small_uint_t duk_js_typeof_stridx(duk_tval *tv_x); diff -Nru duktape-2.3.0/src-separate/duk_js_ops.c duktape-2.2.0/src-separate/duk_js_ops.c --- duktape-2.3.0/src-separate/duk_js_ops.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_js_ops.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,7 +1,7 @@ /* - * ECMAScript specification algorithm and conversion helpers. + * Ecmascript specification algorithm and conversion helpers. * - * These helpers encapsulate the primitive ECMAScript operation semantics, + * These helpers encapsulate the primitive Ecmascript operation semantics, * and are used by the bytecode executor and the API (among other places). * Some primitives are only implemented as part of the API and have no * "internal" helper. This is the case when an internal helper would not @@ -217,7 +217,6 @@ duk_hstring *h = DUK_TVAL_GET_STRING(tv); if (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) { DUK_ERROR_TYPE(thr, DUK_STR_CANNOT_NUMBER_COERCE_SYMBOL); - DUK_WO_NORETURN(return 0.0;); } duk_push_hstring(thr, h); return duk__tonumber_string_raw(thr); @@ -433,7 +432,7 @@ return 0; #else /* DUK_USE_PARANOID_MATH */ /* Better equivalent algorithm. If the compiler is compliant, C and - * ECMAScript semantics are identical for this particular comparison. + * Ecmascript semantics are identical for this particular comparison. * In particular, NaNs must never compare equal and zeroes must compare * equal regardless of sign. Could also use a macro, but this inlines * already nicely (no difference on gcc, for instance). @@ -726,12 +725,12 @@ prefix_len = (len1 <= len2 ? len1 : len2); - /* duk_memcmp() is guaranteed to return zero (equal) for zero length - * inputs. + /* DUK_MEMCMP() is guaranteed to return zero (equal) for zero length + * inputs so no zero length check is needed. */ - rc = duk_memcmp_unsafe((const void *) buf1, - (const void *) buf2, - (size_t) prefix_len); + rc = DUK_MEMCMP((const void *) buf1, + (const void *) buf2, + (size_t) prefix_len); if (rc < 0) { return -1; @@ -998,19 +997,22 @@ */ /* - * ES2015 Section 7.3.19 describes the OrdinaryHasInstance() algorithm - * which covers both bound and non-bound functions; in effect the algorithm - * includes E5 Sections 11.8.6, 15.3.5.3, and 15.3.4.5.3. - * - * ES2015 Section 12.9.4 describes the instanceof operator which first - * checks @@hasInstance well-known symbol and falls back to - * OrdinaryHasInstance(). + * E5 Section 11.8.6 describes the main algorithm, which uses + * [[HasInstance]]. [[HasInstance]] is defined for only + * function objects: + * + * - Normal functions: + * E5 Section 15.3.5.3 + * - Functions established with Function.prototype.bind(): + * E5 Section 15.3.4.5.3 + * + * For other objects, a TypeError is thrown. * * Limited Proxy support: don't support 'getPrototypeOf' trap but * continue lookup in Proxy target if the value is a Proxy. */ -DUK_LOCAL duk_bool_t duk__js_instanceof_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_bool_t skip_sym_check) { +DUK_INTERNAL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) { duk_hobject *func; duk_hobject *val; duk_hobject *proto; @@ -1033,23 +1035,6 @@ func = duk_require_hobject(thr, -1); DUK_ASSERT(func != NULL); -#if defined(DUK_USE_SYMBOL_BUILTIN) - /* - * @@hasInstance check, ES2015 Section 12.9.4, Steps 2-4. - */ - if (!skip_sym_check) { - if (duk_get_method_stridx(thr, -1, DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE)) { - /* [ ... lhs rhs func ] */ - duk_insert(thr, -3); /* -> [ ... func lhs rhs ] */ - duk_swap_top(thr, -2); /* -> [ ... func rhs(this) lhs ] */ - duk_call_method(thr, 1); - return duk_to_boolean_top_pop(thr); - } - } -#else - DUK_UNREF(skip_sym_check); -#endif - /* * For bound objects, [[HasInstance]] just calls the target function * [[HasInstance]]. If that is again a bound object, repeat until @@ -1061,7 +1046,7 @@ if (!DUK_HOBJECT_IS_CALLABLE(func)) { /* - * Note: of native ECMAScript objects, only Function instances + * Note: of native Ecmascript objects, only Function instances * have a [[HasInstance]] internal property. Custom objects might * also have it, but not in current implementation. * @@ -1071,7 +1056,7 @@ } if (DUK_HOBJECT_HAS_BOUNDFUNC(func)) { - duk_push_tval(thr, &((duk_hboundfunc *) (void *) func)->target); + duk_push_tval(thr, &((duk_hboundfunc *) func)->target); duk_replace(thr, -2); func = duk_require_hobject(thr, -1); /* lightfunc throws */ @@ -1176,7 +1161,6 @@ if (DUK_UNLIKELY(sanity == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } DUK_UNREACHABLE(); @@ -1194,23 +1178,13 @@ error_invalid_rval: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_INSTANCEOF_RVAL); - DUK_WO_NORETURN(return 0;); + return 0; #if defined(DUK_USE_VERBOSE_ERRORS) error_invalid_rval_noproto: DUK_ERROR_TYPE(thr, DUK_STR_INVALID_INSTANCEOF_RVAL_NOPROTO); - DUK_WO_NORETURN(return 0;); -#endif -} - -#if defined(DUK_USE_SYMBOL_BUILTIN) -DUK_INTERNAL duk_bool_t duk_js_instanceof_ordinary(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) { - return duk__js_instanceof_helper(thr, tv_x, tv_y, 1 /*skip_sym_check*/); -} + return 0; #endif - -DUK_INTERNAL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) { - return duk__js_instanceof_helper(thr, tv_x, tv_y, 0 /*skip_sym_check*/); } /* diff -Nru duktape-2.3.0/src-separate/duk_js_var.c duktape-2.2.0/src-separate/duk_js_var.c --- duktape-2.3.0/src-separate/duk_js_var.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_js_var.c 2017-09-23 01:06:08.000000000 +0000 @@ -6,7 +6,7 @@ * be used for most identifier accesses. Consequently, these slow path * primitives should be optimized for maximum compactness. * - * ECMAScript environment records (declarative and object) are represented + * Ecmascript environment records (declarative and object) are represented * as internal objects with control keys. Environment records have a * parent record ("outer environment reference") which is represented by * the implicit prototype for technical reasons (in other words, it is a @@ -48,7 +48,7 @@ * Create a new function object based on a "template function" which contains * compiled bytecode, constants, etc, but lacks a lexical environment. * - * ECMAScript requires that each created closure is a separate object, with + * Ecmascript requires that each created closure is a separate object, with * its own set of editable properties. However, structured property values * (such as the formal arguments list and the variable map) are shared. * Also the bytecode, constants, and inner functions are shared. @@ -1057,7 +1057,6 @@ if (DUK_UNLIKELY(sanity-- == 0)) { DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); } env = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, env); } @@ -1197,7 +1196,6 @@ DUK_ERROR_FMT1(thr, DUK_ERR_REFERENCE_ERROR, "identifier '%s' undefined", (const char *) DUK_HSTRING_GET_DATA(name)); - DUK_WO_NORETURN(return 0;); } return 0; @@ -1322,7 +1320,6 @@ DUK_ERROR_FMT1(thr, DUK_ERR_REFERENCE_ERROR, "identifier '%s' undefined", (const char *) DUK_HSTRING_GET_DATA(name)); - DUK_WO_NORETURN(return;); } DUK_DDD(DUK_DDDPRINT("identifier binding not found, not strict => set to global")); @@ -1713,7 +1710,7 @@ fail_existing_attributes: fail_not_extensible: DUK_ERROR_TYPE(thr, "declaration failed"); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_INTERNAL diff -Nru duktape-2.3.0/src-separate/duk_lexer.c duktape-2.2.0/src-separate/duk_lexer.c --- duktape-2.3.0/src-separate/duk_lexer.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_lexer.c 2017-09-23 01:06:08.000000000 +0000 @@ -2,7 +2,7 @@ * Lexer for source files, ToNumber() string conversions, RegExp expressions, * and JSON. * - * Provides a stream of ECMAScript tokens from an UTF-8/CESU-8 buffer. The + * Provides a stream of Ecmascript tokens from an UTF-8/CESU-8 buffer. The * caller can also rewind the token stream into a certain position which is * needed by the compiler part for multi-pass scanning. Tokens are * represented as duk_token structures, and contain line number information. @@ -25,14 +25,14 @@ * * Token parsing supports the full range of Unicode characters as described * in the E5 specification. Parsing has been optimized for ASCII characters - * because ordinary ECMAScript code consists almost entirely of ASCII + * because ordinary Ecmascript code consists almost entirely of ASCII * characters. Matching of complex Unicode codepoint sets (such as in the * IdentifierStart and IdentifierPart productions) is optimized for size, * and is done using a linear scan of a bit-packed list of ranges. This is * very slow, but should never be entered unless the source code actually * contains Unicode characters. * - * ECMAScript tokenization is partially context sensitive. First, + * Ecmascript tokenization is partially context sensitive. First, * additional future reserved words are recognized in strict mode (see E5 * Section 7.6.1.2). Second, a forward slash character ('/') can be * recognized either as starting a RegExp literal or as a division operator, @@ -129,7 +129,7 @@ * * * In particular, surrogate pairs are allowed and not combined, which * allows source files to represent all SourceCharacters with CESU-8. - * Broken surrogate pairs are allowed, as ECMAScript does not mandate + * Broken surrogate pairs are allowed, as Ecmascript does not mandate * their validation. * * * Allow non-shortest UTF-8 encodings. @@ -137,20 +137,20 @@ * Leniency here causes few security concerns because all character data is * decoded into Unicode codepoints before lexer processing, and is then * re-encoded into CESU-8. The source can be parsed as strict UTF-8 with - * a compiler option. However, ECMAScript source characters include -all- + * a compiler option. However, Ecmascript source characters include -all- * 16-bit unsigned integer codepoints, so leniency seems to be appropriate. * * Note that codepoints above the BMP are not strictly SourceCharacters, * but the lexer still accepts them as such. Before ending up in a string * or an identifier name, codepoints above BMP are converted into surrogate * pairs and then CESU-8 encoded, resulting in 16-bit Unicode data as - * expected by ECMAScript. + * expected by Ecmascript. * * An alternative approach to dealing with invalid or partial sequences * would be to skip them and replace them with e.g. the Unicode replacement * character U+FFFD. This has limited utility because a replacement character * will most likely cause a parse error, unless it occurs inside a string. - * Further, ECMAScript source is typically pure ASCII. + * Further, Ecmascript source is typically pure ASCII. * * See: * @@ -313,7 +313,6 @@ lex_ctx->input_line = input_line; DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_SOURCE_DECODE_FAILED); - DUK_WO_NORETURN(return;); } DUK_LOCAL void duk__advance_bytes(duk_lexer_ctx *lex_ctx, duk_small_uint_t count_bytes) { @@ -336,7 +335,7 @@ /* Not enough data to provide a full window, so "scroll" window to * start of buffer and fill up the rest. */ - duk_memmove((void *) lex_ctx->buffer, + DUK_MEMMOVE((void *) lex_ctx->buffer, (const void *) lex_ctx->window, (size_t) avail_bytes); lex_ctx->window = lex_ctx->buffer; @@ -474,7 +473,7 @@ error_clipped: /* clipped codepoint */ error_encoding: /* invalid codepoint encoding or codepoint */ DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_SOURCE_DECODE_FAILED); - DUK_WO_NORETURN(return 0;); + return 0; } DUK_LOCAL void duk__advance_bytes(duk_lexer_ctx *lex_ctx, duk_small_uint_t count_bytes) { @@ -487,7 +486,7 @@ /* Zero 'count' is also allowed to make call sites easier. */ keep_bytes = DUK_LEXER_WINDOW_SIZE * sizeof(duk_lexer_codepoint) - count_bytes; - duk_memmove((void *) lex_ctx->window, + DUK_MEMMOVE((void *) lex_ctx->window, (const void *) ((duk_uint8_t *) lex_ctx->window + count_bytes), (size_t) keep_bytes); @@ -576,7 +575,7 @@ DUK_INTERNAL void duk_lexer_initctx(duk_lexer_ctx *lex_ctx) { DUK_ASSERT(lex_ctx != NULL); - duk_memzero(lex_ctx, sizeof(*lex_ctx)); + DUK_MEMZERO(lex_ctx, sizeof(*lex_ctx)); #if defined(DUK_USE_EXPLICIT_NULL_INIT) #if defined(DUK_USE_LEXER_SLIDING_WINDOW) lex_ctx->window = NULL; @@ -741,7 +740,6 @@ fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE); - DUK_WO_NORETURN(return 0;); } /* Parse legacy octal escape of the form \N{1,3}, e.g. \0, \5, \0377. Maximum @@ -938,11 +936,11 @@ fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_unterminated: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_STRING); - DUK_WO_NORETURN(return;); + return; } /* Skip to end-of-line (or end-of-file), used for single line comments. */ @@ -959,7 +957,7 @@ } /* - * Parse ECMAScript source InputElementDiv or InputElementRegExp + * Parse Ecmascript source InputElementDiv or InputElementRegExp * (E5 Section 7), skipping whitespace, comments, and line terminators. * * Possible results are: @@ -986,13 +984,13 @@ * lookup window to quickly determine which production is the -longest- * matching one, and then parse that. The top-level if-else clauses * match the first character, and the code blocks for each clause - * handle -all- alternatives for that first character. ECMAScript + * handle -all- alternatives for that first character. Ecmascript * specification uses the "longest match wins" semantics, so the order * of the if-clauses matters. * * Misc notes: * - * * ECMAScript numeric literals do not accept a sign character. + * * Ecmascript numeric literals do not accept a sign character. * Consequently e.g. "-1.0" is parsed as two tokens: a negative * sign and a positive numeric literal. The compiler performs * the negation during compilation, so this has no adverse impact. @@ -1502,7 +1500,7 @@ * (the tokens DUK_TOK_GET and DUK_TOK_SET are actually not * used now). The compiler needs to work around this. * - * Strictly speaking, following ECMAScript longest match + * Strictly speaking, following Ecmascript longest match * specification, an invalid escape for the first character * should cause a syntax error. However, an invalid escape * for IdentifierParts should just terminate the identifier @@ -1786,32 +1784,32 @@ fail_token_limit: DUK_ERROR_RANGE(lex_ctx->thr, DUK_STR_TOKEN_LIMIT); - DUK_WO_NORETURN(return;); + return; fail_token: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_TOKEN); - DUK_WO_NORETURN(return;); + return; fail_number_literal: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_NUMBER_LITERAL); - DUK_WO_NORETURN(return;); + return; fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_unterm_regexp: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_REGEXP); - DUK_WO_NORETURN(return;); + return; fail_unterm_comment: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_COMMENT); - DUK_WO_NORETURN(return;); + return; #if !defined(DUK_USE_REGEXP_SUPPORT) fail_regexp_support: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_REGEXP_SUPPORT_DISABLED); - DUK_WO_NORETURN(return;); + return; #endif } @@ -1834,7 +1832,7 @@ goto fail_token_limit; } - duk_memzero(out_token, sizeof(*out_token)); + DUK_MEMZERO(out_token, sizeof(*out_token)); x = DUK__L0(); y = DUK__L1(); @@ -2159,24 +2157,24 @@ fail_token_limit: DUK_ERROR_RANGE(lex_ctx->thr, DUK_STR_TOKEN_LIMIT); - DUK_WO_NORETURN(return;); + return; fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_group: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_GROUP); - DUK_WO_NORETURN(return;); + return; #if !defined(DUK_USE_ES6_REGEXP_SYNTAX) fail_invalid_char: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_CHARACTER); - DUK_WO_NORETURN(return;); + return; fail_quantifier: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_QUANTIFIER); - DUK_WO_NORETURN(return;); + return; #endif } @@ -2425,15 +2423,15 @@ fail_escape: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_ESCAPE); - DUK_WO_NORETURN(return;); + return; fail_range: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_RANGE); - DUK_WO_NORETURN(return;); + return; fail_unterm_charclass: DUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_CHARCLASS); - DUK_WO_NORETURN(return;); + return; } #endif /* DUK_USE_REGEXP_SUPPORT */ diff -Nru duktape-2.3.0/src-separate/duk_lexer.h duktape-2.2.0/src-separate/duk_lexer.h --- duktape-2.3.0/src-separate/duk_lexer.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_lexer.h 2017-09-23 01:06:08.000000000 +0000 @@ -388,7 +388,7 @@ duk_int_t line; }; -/* Lexer context. Same context is used for ECMAScript and Regexp parsing. */ +/* Lexer context. Same context is used for Ecmascript and Regexp parsing. */ struct duk_lexer_ctx { #if defined(DUK_USE_LEXER_SLIDING_WINDOW) duk_lexer_codepoint *window; /* unicode code points, window[0] is always next, points to 'buffer' */ diff -Nru duktape-2.3.0/src-separate/duk_numconv.c duktape-2.2.0/src-separate/duk_numconv.c --- duktape-2.3.0/src-separate/duk_numconv.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_numconv.c 2017-09-23 01:06:08.000000000 +0000 @@ -133,8 +133,10 @@ n = y->n; x->n = n; - /* No need to special case n == 0. */ - duk_memcpy((void *) x->v, (const void *) y->v, (size_t) (sizeof(duk_uint32_t) * (size_t) n)); + if (n == 0) { + return; + } + DUK_MEMCPY((void *) x->v, (const void *) y->v, (size_t) (sizeof(duk_uint32_t) * (size_t) n)); } DUK_LOCAL void duk__bi_set_small(duk__bigint *x, duk_uint32_t v) { @@ -410,7 +412,7 @@ return; } - duk_memzero((void *) x->v, (size_t) (sizeof(duk_uint32_t) * (size_t) nx)); + DUK_MEMZERO((void *) x->v, (size_t) (sizeof(duk_uint32_t) * (size_t) nx)); x->n = nx; nz = z->n; @@ -560,7 +562,7 @@ n = (y / 32) + 1; DUK_ASSERT(n > 0); r = y % 32; - duk_memzero((void *) x->v, sizeof(duk_uint32_t) * (size_t) n); + DUK_MEMZERO((void *) x->v, sizeof(duk_uint32_t) * (size_t) n); x->n = n; x->v[n - 1] = (((duk_uint32_t) 1) << r); } @@ -674,7 +676,6 @@ duk_small_int_t dig; duk_uint32_t t; - DUK_ASSERT(buf != NULL); DUK_ASSERT(radix >= 2 && radix <= 36); /* A 32-bit unsigned integer formats to at most 32 digits (the @@ -697,7 +698,7 @@ } len = (duk_size_t) ((buf + 32) - p); - duk_memmove((void *) buf, (const void *) p, (size_t) len); + DUK_MEMMOVE((void *) buf, (const void *) p, (size_t) len); return len; } @@ -1100,7 +1101,7 @@ { duk_uint8_t buf[2048]; duk_small_int_t i, t; - duk_memzero(buf, sizeof(buf)); + DUK_MEMZERO(buf, sizeof(buf)); for (i = 0; i < nc_ctx->count; i++) { t = nc_ctx->digits[i]; if (t < 0 || t > 36) { @@ -1165,7 +1166,7 @@ *p = 0; if (p == &nc_ctx->digits[0]) { DUK_DDD(DUK_DDDPRINT("carry propagated to first digit -> special case handling")); - duk_memmove((void *) (&nc_ctx->digits[1]), + DUK_MEMMOVE((void *) (&nc_ctx->digits[1]), (const void *) (&nc_ctx->digits[0]), (size_t) (sizeof(char) * (size_t) nc_ctx->count)); nc_ctx->digits[0] = 1; /* don't increase 'count' */ @@ -1209,7 +1210,7 @@ duk_uint8_t *buf; /* - * The string conversion here incorporates all the necessary ECMAScript + * The string conversion here incorporates all the necessary Ecmascript * semantics without attempting to be generic. nc_ctx->digits contains * nc_ctx->count digits (>= 1), with the topmost digit's 'position' * indicated by nc_ctx->k as follows: @@ -1220,11 +1221,11 @@ * digits="123" count=3 k=-1 --> 0.0123 * * Note that the identifier names used for format selection are different - * in Burger-Dybvig paper and ECMAScript specification (quite confusingly + * in Burger-Dybvig paper and Ecmascript specification (quite confusingly * so, because e.g. 'k' has a totally different meaning in each). See * documentation for discussion. * - * ECMAScript doesn't specify any specific behavior for format selection + * Ecmascript doesn't specify any specific behavior for format selection * (e.g. when to use exponent notation) for non-base-10 numbers. * * The bigint space in the context is reused for string output, as there @@ -1308,7 +1309,7 @@ /* Exponent */ if (expt != DUK__NO_EXP) { /* - * Exponent notation for non-base-10 numbers isn't specified in ECMAScript + * Exponent notation for non-base-10 numbers isn't specified in Ecmascript * specification, as it never explicitly turns up: non-decimal numbers can * only be formatted with Number.prototype.toString([radix]) and for that, * behavior is not explicitly specified. @@ -1410,7 +1411,7 @@ * (perhaps because the low part is set (seemingly) conditionally in a * loop), so this is here to avoid the bogus warning. */ - duk_memzero((void *) &u, sizeof(u)); + DUK_MEMZERO((void *) &u, sizeof(u)); /* * Figure out how generated digits match up with the mantissa, @@ -1593,7 +1594,7 @@ * sprintf "%lu" for the fast path and for exponent formatting. */ - uval = duk_double_to_uint32_t(x); + uval = (unsigned int) x; if (((double) uval) == x && /* integer number in range */ flags == 0) { /* no special formatting */ /* use bigint area as a temp */ @@ -1625,7 +1626,7 @@ * is 1-2 kilobytes and nothing should rely on it being zeroed. */ #if 0 - duk_memzero((void *) nc_ctx, sizeof(*nc_ctx)); /* slow init, do only for slow path cases */ + DUK_MEMZERO((void *) nc_ctx, sizeof(*nc_ctx)); /* slow init, do only for slow path cases */ #endif nc_ctx->is_s2n = 0; @@ -1665,7 +1666,7 @@ } DUK_DDD(DUK_DDDPRINT("count=%ld", (long) count)); DUK_ASSERT(count >= 1); - duk_memzero((void *) nc_ctx->digits, (size_t) count); + DUK_MEMZERO((void *) nc_ctx->digits, (size_t) count); nc_ctx->count = count; nc_ctx->k = 1; /* 0.000... */ neg = 0; @@ -1745,8 +1746,8 @@ duk__numconv_stringify_ctx *nc_ctx = &nc_ctx_alloc; duk_double_t res; duk_hstring *h_str; - duk_int_t expt; - duk_bool_t expt_neg; + duk_small_int_t expt; + duk_small_int_t expt_neg; duk_small_int_t expt_adj; duk_small_int_t neg; duk_small_int_t dig; @@ -1882,7 +1883,7 @@ * accuracy, so that Dragon4 will generate enough binary output digits. * For decimal numbers, this means generating a 20-digit significand, * which should yield enough practical accuracy to parse IEEE doubles. - * In fact, the ECMAScript specification explicitly allows an + * In fact, the Ecmascript specification explicitly allows an * implementation to treat digits beyond 20 as zeroes (and even * to round the 20th digit upwards). For non-decimal numbers, the * appropriate number of digits has been precomputed for comparable @@ -2053,10 +2054,9 @@ } else { /* exponent digit */ - DUK_ASSERT(radix == 10); expt = expt * radix + dig; if (expt > DUK_S2N_MAX_EXPONENT) { - /* Impose a reasonable exponent limit, so that exp + /* impose a reasonable exponent limit, so that exp * doesn't need to get tracked using a bigint. */ DUK_DDD(DUK_DDDPRINT("parse failed: exponent too large")); @@ -2259,5 +2259,5 @@ parse_explimit_error: DUK_DDD(DUK_DDDPRINT("parse failed, internal error, can't return a value")); DUK_ERROR_RANGE(thr, "exponent too large"); - DUK_WO_NORETURN(return;); + return; } diff -Nru duktape-2.3.0/src-separate/duk_numconv.h duktape-2.2.0/src-separate/duk_numconv.h --- duktape-2.3.0/src-separate/duk_numconv.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_numconv.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,6 +1,6 @@ /* * Number-to-string conversion. The semantics of these is very tightly - * bound with the ECMAScript semantics required for call sites. + * bound with the Ecmascript semantics required for call sites. */ #if !defined(DUK_NUMCONV_H_INCLUDED) @@ -33,13 +33,9 @@ /* Maximum exponent value when parsing numbers. This is not strictly * compliant as there should be no upper limit, but as we parse the - * exponent without a bigint, impose some limit. The limit should be - * small enough that multiplying it (or limit-1 to be precise) won't - * overflow signed 32-bit integer range. Exponent is only parsed with - * radix 10, but with maximum radix (36) a safe limit is: - * (10000000*36).toString(16) -> '15752a00' + * exponent without a bigint, impose some limit. */ -#define DUK_S2N_MAX_EXPONENT 10000000L +#define DUK_S2N_MAX_EXPONENT 1000000000 /* Trim white space (= allow leading and trailing whitespace) */ #define DUK_S2N_FLAG_TRIM_WHITE (1U << 0) diff -Nru duktape-2.3.0/src-separate/duk_regexp_compiler.c duktape-2.2.0/src-separate/duk_regexp_compiler.c --- duktape-2.3.0/src-separate/duk_regexp_compiler.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_regexp_compiler.c 2017-09-23 01:06:08.000000000 +0000 @@ -524,7 +524,6 @@ if (re_ctx->recursion_depth >= re_ctx->recursion_limit) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_COMPILER_RECURSION_LIMIT); - DUK_WO_NORETURN(return;); } re_ctx->recursion_depth++; @@ -598,11 +597,9 @@ case DUK_RETOK_QUANTIFIER: { if (atom_start_offset < 0) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_INVALID_QUANTIFIER_NO_ATOM); - DUK_WO_NORETURN(return;); } if (re_ctx->curr_token.qmin > re_ctx->curr_token.qmax) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_INVALID_QUANTIFIER_VALUES); - DUK_WO_NORETURN(return;); } if (atom_char_length >= 0) { /* @@ -671,7 +668,6 @@ re_ctx->curr_token.qmin : re_ctx->curr_token.qmax; if (atom_copies > DUK_RE_MAX_ATOM_COPIES) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_QUANTIFIER_TOO_MANY_COPIES); - DUK_WO_NORETURN(return;); } /* wipe the capture range made by the atom (if any) */ @@ -935,20 +931,17 @@ case DUK_RETOK_ATOM_END_GROUP: { if (expect_eof) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_CLOSING_PAREN); - DUK_WO_NORETURN(return;); } goto done; } case DUK_RETOK_EOF: { if (!expect_eof) { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_END_OF_PATTERN); - DUK_WO_NORETURN(return;); } goto done; } default: { DUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_REGEXP_TOKEN); - DUK_WO_NORETURN(return;); } } @@ -1043,7 +1036,7 @@ flags_error: DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_REGEXP_FLAGS); - DUK_WO_NORETURN(return 0U;); + return 0; /* never here */ } /* @@ -1080,7 +1073,7 @@ n = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h); if (n == 0) { - duk_push_literal(thr, "(?:)"); + duk_push_string(thr, "(?:)"); return; } @@ -1160,7 +1153,7 @@ /* [ ... pattern flags escaped_source buffer ] */ - duk_memzero(&re_ctx, sizeof(re_ctx)); + DUK_MEMZERO(&re_ctx, sizeof(re_ctx)); DUK_LEXER_INITCTX(&re_ctx.lex); /* duplicate zeroing, expect for (possible) NULL inits */ re_ctx.thr = thr; re_ctx.lex.thr = thr; @@ -1207,7 +1200,6 @@ if (re_ctx.highest_backref > re_ctx.captures) { DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_BACKREFS); - DUK_WO_NORETURN(return;); } /* diff -Nru duktape-2.3.0/src-separate/duk_regexp_executor.c duktape-2.2.0/src-separate/duk_regexp_executor.c --- duktape-2.3.0/src-separate/duk_regexp_executor.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_regexp_executor.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,7 +1,7 @@ /* * Regexp executor. * - * Safety: the ECMAScript executor should prevent user from reading and + * Safety: the Ecmascript executor should prevent user from reading and * replacing regexp bytecode. Even so, the executor must validate all * memory accesses etc. When an invalid access is detected (e.g. a 'save' * opcode to invalid, unallocated index) it should fail with an internal @@ -68,7 +68,7 @@ fail: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } DUK_LOCAL const duk_uint8_t *duk__utf8_advance(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_uint_fast32_t count) { @@ -99,7 +99,7 @@ fail: DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } /* @@ -148,7 +148,6 @@ DUK_LOCAL const duk_uint8_t *duk__match_regexp(duk_re_matcher_ctx *re_ctx, const duk_uint8_t *pc, const duk_uint8_t *sp) { if (re_ctx->recursion_depth >= re_ctx->recursion_limit) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_EXECUTOR_RECURSION_LIMIT); - DUK_WO_NORETURN(return NULL;); } re_ctx->recursion_depth++; @@ -157,7 +156,6 @@ if (re_ctx->steps_count >= re_ctx->steps_limit) { DUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_EXECUTOR_STEP_LIMIT); - DUK_WO_NORETURN(return NULL;); } re_ctx->steps_count++; @@ -503,14 +501,14 @@ range_save = (duk_uint8_t **) duk_push_fixed_buffer_nozero(re_ctx->thr, sizeof(duk_uint8_t *) * idx_count); DUK_ASSERT(range_save != NULL); - duk_memcpy(range_save, re_ctx->saved + idx_start, sizeof(duk_uint8_t *) * idx_count); + DUK_MEMCPY(range_save, re_ctx->saved + idx_start, sizeof(duk_uint8_t *) * idx_count); #if defined(DUK_USE_EXPLICIT_NULL_INIT) idx_end = idx_start + idx_count; for (idx = idx_start; idx < idx_end; idx++) { re_ctx->saved[idx] = NULL; } #else - duk_memzero((void *) (re_ctx->saved + idx_start), sizeof(duk_uint8_t *) * idx_count); + DUK_MEMZERO((void *) (re_ctx->saved + idx_start), sizeof(duk_uint8_t *) * idx_count); #endif sub_sp = duk__match_regexp(re_ctx, pc, sp); @@ -528,7 +526,7 @@ DUK_DDD(DUK_DDDPRINT("fail: restore wiped/resaved values [%ld,%ld] (captures [%ld,%ld])", (long) idx_start, (long) (idx_start + idx_count - 1), (long) (idx_start / 2), (long) ((idx_start + idx_count - 1) / 2))); - duk_memcpy((void *) (re_ctx->saved + idx_start), + DUK_MEMCPY((void *) (re_ctx->saved + idx_start), (const void *) range_save, sizeof(duk_uint8_t *) * idx_count); duk_pop_unsafe(re_ctx->thr); @@ -560,7 +558,7 @@ full_save = (duk_uint8_t **) duk_push_fixed_buffer_nozero(re_ctx->thr, sizeof(duk_uint8_t *) * re_ctx->nsaved); DUK_ASSERT(full_save != NULL); - duk_memcpy(full_save, re_ctx->saved, sizeof(duk_uint8_t *) * re_ctx->nsaved); + DUK_MEMCPY(full_save, re_ctx->saved, sizeof(duk_uint8_t *) * re_ctx->nsaved); skip = duk__bc_get_i32(re_ctx, &pc); sub_sp = duk__match_regexp(re_ctx, pc, sp); @@ -585,7 +583,7 @@ lookahead_fail: /* fail: restore saves */ - duk_memcpy((void *) re_ctx->saved, + DUK_MEMCPY((void *) re_ctx->saved, (const void *) full_save, sizeof(duk_uint8_t *) * re_ctx->nsaved); duk_pop_unsafe(re_ctx->thr); @@ -667,7 +665,7 @@ internal_error: DUK_ERROR_INTERNAL(re_ctx->thr); - DUK_WO_NORETURN(return NULL;); + return NULL; /* never here */ } /* @@ -733,7 +731,7 @@ /* [ ... re_obj input bc ] */ - duk_memzero(&re_ctx, sizeof(re_ctx)); + DUK_MEMZERO(&re_ctx, sizeof(re_ctx)); re_ctx.thr = thr; re_ctx.input = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input); @@ -770,7 +768,7 @@ #elif defined(DUK_USE_ZERO_BUFFER_DATA) /* buffer is automatically zeroed */ #else - duk_memzero((void *) p_buf, sizeof(duk_uint8_t *) * re_ctx.nsaved); + DUK_MEMZERO((void *) p_buf, sizeof(duk_uint8_t *) * re_ctx.nsaved); #endif DUK_DDD(DUK_DDDPRINT("regexp ctx initialized, flags=0x%08lx, nsaved=%ld, recursion_limit=%ld, steps_limit=%ld", @@ -855,7 +853,7 @@ * internal/limit error occurs (which causes a longjmp()) * * - If we supported anchored matches, we would break out here - * unconditionally; however, ECMAScript regexps don't have anchored + * unconditionally; however, Ecmascript regexps don't have anchored * matches. It might make sense to implement a fast bail-out if * the regexp begins with '^' and sp is not 0: currently we'll just * run through the entire input string, trivially failing the match diff -Nru duktape-2.3.0/src-separate/duk_selftest.c duktape-2.2.0/src-separate/duk_selftest.c --- duktape-2.3.0/src-separate/duk_selftest.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_selftest.c 2017-09-23 01:06:08.000000000 +0000 @@ -23,13 +23,13 @@ } while (0) #define DUK__DBLUNION_CMP_TRUE(a,b) do { \ - if (duk_memcmp((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) != 0) { \ + if (DUK_MEMCMP((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) != 0) { \ DUK__FAILED("double union compares false (expected true)"); \ } \ } while (0) #define DUK__DBLUNION_CMP_FALSE(a,b) do { \ - if (duk_memcmp((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) == 0) { \ + if (DUK_MEMCMP((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) == 0) { \ DUK__FAILED("double union compares true (expected false)"); \ } \ } while (0) @@ -338,7 +338,7 @@ */ DUK__DOUBLE_INIT(&a, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); DUK__DOUBLE_INIT(&b, 0x3c, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - duk_memset((void *) &c, 0, sizeof(c)); + DUK_MEMSET((void *) &c, 0, sizeof(c)); c.d = a.d + b.d; if (!DUK__DOUBLE_COMPARE(&c, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)) { DUK_D(DUK_DPRINT("broken result (native endiannesss): %02x %02x %02x %02x %02x %02x %02x %02x", @@ -358,7 +358,7 @@ */ DUK__DOUBLE_INIT(&a, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01); DUK__DOUBLE_INIT(&b, 0x3c, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); - duk_memset((void *) &c, 0, sizeof(c)); + DUK_MEMSET((void *) &c, 0, sizeof(c)); c.d = a.d + b.d; if (!DUK__DOUBLE_COMPARE(&c, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02)) { DUK_D(DUK_DPRINT("broken result (native endiannesss): %02x %02x %02x %02x %02x %02x %02x %02x", diff -Nru duktape-2.3.0/src-separate/duk_source_meta.json duktape-2.2.0/src-separate/duk_source_meta.json --- duktape-2.3.0/src-separate/duk_source_meta.json 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_source_meta.json 2017-09-23 01:06:08.000000000 +0000 @@ -1,10 +1,10 @@ { "comment": "Metadata for Duktape sources", - "duk_version_string": "2.3.0", + "duk_version_string": "2.2.0", "type": "duk_source_meta", - "duk_version": 20300, + "duk_version": 20200, "git_branch": "master", - "git_commit": "d7fdb67f18561a50e06bafd196c6b423af9ad6fe", + "git_commit": "a459cf3c9bd1779fc01b435d69302b742675a08f", "builtin_strings_info": [ { "plain": "Undefined", @@ -387,26 +387,6 @@ "define": "DUK_STRIDX_OWN_KEYS" }, { - "plain": "\u0081Symbol.toPrimitive\u00ff", - "base64": "gVN5bWJvbC50b1ByaW1pdGl2Zf8=", - "define": "DUK_STRIDX_WELLKNOWN_SYMBOL_TO_PRIMITIVE" - }, - { - "plain": "\u0081Symbol.hasInstance\u00ff", - "base64": "gVN5bWJvbC5oYXNJbnN0YW5jZf8=", - "define": "DUK_STRIDX_WELLKNOWN_SYMBOL_HAS_INSTANCE" - }, - { - "plain": "\u0081Symbol.toStringTag\u00ff", - "base64": "gVN5bWJvbC50b1N0cmluZ1RhZ/8=", - "define": "DUK_STRIDX_WELLKNOWN_SYMBOL_TO_STRING_TAG" - }, - { - "plain": "\u0081Symbol.isConcatSpreadable\u00ff", - "base64": "gVN5bWJvbC5pc0NvbmNhdFNwcmVhZGFibGX/", - "define": "DUK_STRIDX_WELLKNOWN_SYMBOL_IS_CONCAT_SPREADABLE" - }, - { "plain": "setPrototypeOf", "base64": "c2V0UHJvdG90eXBlT2Y=", "define": "DUK_STRIDX_SET_PROTOTYPE_OF" @@ -914,10 +894,6 @@ "Z2V0", "aGFz", "b3duS2V5cw==", - "gVN5bWJvbC50b1ByaW1pdGl2Zf8=", - "gVN5bWJvbC5oYXNJbnN0YW5jZf8=", - "gVN5bWJvbC50b1N0cmluZ1RhZ/8=", - "gVN5bWJvbC5pc0NvbmNhdFNwcmVhZGFibGX/", "c2V0UHJvdG90eXBlT2Y=", "X19wcm90b19f", "dG9TdHJpbmc=", @@ -1005,7 +981,7 @@ "c3RhdGlj", "eWllbGQ=" ], - "git_describe": "v2.3.0", + "git_describe": "v2.2.0", "builtin_strings": [ "Undefined", "Null", @@ -1083,10 +1059,6 @@ "get", "has", "ownKeys", - "\u0081Symbol.toPrimitive\u00ff", - "\u0081Symbol.hasInstance\u00ff", - "\u0081Symbol.toStringTag\u00ff", - "\u0081Symbol.isConcatSpreadable\u00ff", "setPrototypeOf", "__proto__", "toString", diff -Nru duktape-2.3.0/src-separate/duktape.h duktape-2.2.0/src-separate/duktape.h --- duktape-2.3.0/src-separate/duktape.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duktape.h 2017-09-23 01:06:08.000000000 +0000 @@ -1,12 +1,12 @@ /* - * Duktape public API for Duktape 2.3.0. + * Duktape public API for Duktape 2.2.0. * * See the API reference for documentation on call semantics. The exposed, * supported API is between the "BEGIN PUBLIC API" and "END PUBLIC API" * comments. Other parts of the header are Duktape internal and related to * e.g. platform/compiler/feature detection. * - * Git commit d7fdb67f18561a50e06bafd196c6b423af9ad6fe (v2.3.0). + * Git commit a459cf3c9bd1779fc01b435d69302b742675a08f (v2.2.0). * Git branch master. * * See Duktape AUTHORS.rst and LICENSE.txt for copyright and @@ -21,7 +21,7 @@ * * (http://opensource.org/licenses/MIT) * - * Copyright (c) 2013-2018 by Duktape authors (see AUTHORS.rst) + * Copyright (c) 2013-2017 by Duktape authors (see AUTHORS.rst) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -92,14 +92,6 @@ * * Steven Don (https://github.com/shdon) * * Simon Stone (https://github.com/sstone1) * * \J. McC. (https://github.com/jmhmccr) - * * Jakub Nowakowski (https://github.com/jimvonmoon) - * * Tommy Nguyen (https://github.com/tn0502) - * * Fabrice Fontaine (https://github.com/ffontaine) - * * Christopher Hiller (https://github.com/boneskull) - * * Gonzalo Diethelm (https://github.com/gonzus) - * * Michal Kasperek (https://github.com/michalkas) - * * Andrew Janke (https://github.com/apjanke) - * * Steve Fan (https://github.com/stevefan1999) * * Other contributions * =================== @@ -138,8 +130,6 @@ * * https://github.com/chris-y * * Laurent Zubiaur (https://github.com/lzubiaur) * * Neil Kolban (https://github.com/nkolban) - * * Wilhelm Wanecek (https://github.com/wanecek) - * * Andrew Janke (https://github.com/apjanke) * * If you are accidentally missing from this list, send me an e-mail * (``sami.vaarala@iki.fi``) and I'll fix the omission. @@ -160,19 +150,19 @@ /* Duktape version, (major * 10000) + (minor * 100) + patch. Allows C code * to #if (DUK_VERSION >= NNN) against Duktape API version. The same value - * is also available to ECMAScript code in Duktape.version. Unofficial + * is also available to Ecmascript code in Duktape.version. Unofficial * development snapshots have 99 for patch level (e.g. 0.10.99 would be a * development version after 0.10.0 but before the next official release). */ -#define DUK_VERSION 20300L +#define DUK_VERSION 20200L /* Git commit, describe, and branch for Duktape build. Useful for * non-official snapshot builds so that application code can easily log - * which Duktape snapshot was used. Not available in the ECMAScript + * which Duktape snapshot was used. Not available in the Ecmascript * environment. */ -#define DUK_GIT_COMMIT "d7fdb67f18561a50e06bafd196c6b423af9ad6fe" -#define DUK_GIT_DESCRIBE "v2.3.0" +#define DUK_GIT_COMMIT "a459cf3c9bd1779fc01b435d69302b742675a08f" +#define DUK_GIT_DESCRIBE "v2.2.0" #define DUK_GIT_BRANCH "master" /* External duk_config.h provides platform/compiler/OS dependent @@ -268,7 +258,7 @@ }; struct duk_time_components { - duk_double_t year; /* year, e.g. 2016, ECMAScript year range */ + duk_double_t year; /* year, e.g. 2016, Ecmascript year range */ duk_double_t month; /* month: 1-12 */ duk_double_t day; /* day: 1-31 */ duk_double_t hours; /* hour: 0-59 */ @@ -304,12 +294,12 @@ /* Value types, used by e.g. duk_get_type() */ #define DUK_TYPE_MIN 0U #define DUK_TYPE_NONE 0U /* no value, e.g. invalid index */ -#define DUK_TYPE_UNDEFINED 1U /* ECMAScript undefined */ -#define DUK_TYPE_NULL 2U /* ECMAScript null */ -#define DUK_TYPE_BOOLEAN 3U /* ECMAScript boolean: 0 or 1 */ -#define DUK_TYPE_NUMBER 4U /* ECMAScript number: double */ -#define DUK_TYPE_STRING 5U /* ECMAScript string: CESU-8 / extended UTF-8 encoded */ -#define DUK_TYPE_OBJECT 6U /* ECMAScript object: includes objects, arrays, functions, threads */ +#define DUK_TYPE_UNDEFINED 1U /* Ecmascript undefined */ +#define DUK_TYPE_NULL 2U /* Ecmascript null */ +#define DUK_TYPE_BOOLEAN 3U /* Ecmascript boolean: 0 or 1 */ +#define DUK_TYPE_NUMBER 4U /* Ecmascript number: double */ +#define DUK_TYPE_STRING 5U /* Ecmascript string: CESU-8 / extended UTF-8 encoded */ +#define DUK_TYPE_OBJECT 6U /* Ecmascript object: includes objects, arrays, functions, threads */ #define DUK_TYPE_BUFFER 7U /* fixed or dynamic, garbage collected byte buffer */ #define DUK_TYPE_POINTER 8U /* raw void pointer */ #define DUK_TYPE_LIGHTFUNC 9U /* lightweight function pointer */ @@ -678,21 +668,7 @@ DUK_EXTERNAL_DECL const char *duk_push_sprintf(duk_context *ctx, const char *fmt, ...); DUK_EXTERNAL_DECL const char *duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap); -/* duk_push_literal() may evaluate its argument (a C string literal) more than - * once on purpose. When speed is preferred, sizeof() avoids an unnecessary - * strlen() at runtime. Sizeof("foo") == 4, so subtract 1. The argument - * must be non-NULL and should not contain internal NUL characters as the - * behavior will then depend on config options. - */ -#if defined(DUK_USE_PREFER_SIZE) -#define duk_push_literal(ctx,cstring) duk_push_string((ctx), (cstring)) -#else -DUK_EXTERNAL_DECL const char *duk_push_literal_raw(duk_context *ctx, const char *str, duk_size_t len); -#define duk_push_literal(ctx,cstring) duk_push_literal_raw((ctx), (cstring), sizeof((cstring)) - 1U) -#endif - DUK_EXTERNAL_DECL void duk_push_this(duk_context *ctx); -DUK_EXTERNAL_DECL void duk_push_new_target(duk_context *ctx); DUK_EXTERNAL_DECL void duk_push_current_function(duk_context *ctx); DUK_EXTERNAL_DECL void duk_push_current_thread(duk_context *ctx); DUK_EXTERNAL_DECL void duk_push_global_object(duk_context *ctx); @@ -1024,55 +1000,29 @@ /* * Property access * - * The basic function assumes key is on stack. The _(l)string variant takes - * a C string as a property name; the _literal variant takes a C literal. - * The _index variant takes an array index as a property name (e.g. 123 is - * equivalent to the key "123"). The _heapptr variant takes a raw, borrowed - * heap pointer. + * The basic function assumes key is on stack. The _string variant takes + * a C string as a property name, while the _index variant takes an array + * index as a property name (e.g. 123 is equivalent to the key "123"). */ DUK_EXTERNAL_DECL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_get_prop_literal(ctx,obj_idx,key) duk_get_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_get_prop_literal(ctx,obj_idx,key) duk_get_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_put_prop_literal(ctx,obj_idx,key) duk_put_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_put_prop_literal(ctx,obj_idx,key) duk_put_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_del_prop_literal(ctx,obj_idx,key) duk_del_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_del_prop_literal(ctx,obj_idx,key) duk_del_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_idx); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_has_prop_literal(ctx,obj_idx,key) duk_has_prop_string((ctx), (obj_idx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_literal_raw(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len); -#define duk_has_prop_literal(ctx,obj_idx,key) duk_has_prop_literal_raw((ctx), (obj_idx), (key), sizeof((key)) - 1U) -#endif DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); @@ -1081,22 +1031,8 @@ DUK_EXTERNAL_DECL duk_bool_t duk_get_global_string(duk_context *ctx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_get_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_get_global_literal(ctx,key) duk_get_global_string((ctx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_get_global_literal_raw(duk_context *ctx, const char *key, duk_size_t key_len); -#define duk_get_global_literal(ctx,key) duk_get_global_literal_raw((ctx), (key), sizeof((key)) - 1U) -#endif -DUK_EXTERNAL_DECL duk_bool_t duk_get_global_heapptr(duk_context *ctx, void *ptr); DUK_EXTERNAL_DECL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key); DUK_EXTERNAL_DECL duk_bool_t duk_put_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len); -#if defined(DUK_USE_PREFER_SIZE) -#define duk_put_global_literal(ctx,key) duk_put_global_string((ctx), (key)) -#else -DUK_EXTERNAL_DECL duk_bool_t duk_put_global_literal_raw(duk_context *ctx, const char *key, duk_size_t key_len); -#define duk_put_global_literal(ctx,key) duk_put_global_literal_raw((ctx), (key), sizeof((key)) - 1U) -#endif -DUK_EXTERNAL_DECL duk_bool_t duk_put_global_heapptr(duk_context *ctx, void *ptr); /* * Inspection @@ -1163,7 +1099,7 @@ DUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t idx, duk_size_t char_offset); /* - * ECMAScript operators + * Ecmascript operators */ DUK_EXTERNAL_DECL duk_bool_t duk_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2); @@ -1172,12 +1108,6 @@ DUK_EXTERNAL_DECL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2); /* - * Random - */ - -DUK_EXTERNAL_DECL duk_double_t duk_random(duk_context *ctx); - -/* * Function (method) calls */ @@ -1327,7 +1257,7 @@ #define DUK_DATE_MSEC_HOUR (60L * 60L * 1000L) #define DUK_DATE_MSEC_DAY (24L * 60L * 60L * 1000L) -/* ECMAScript date range is 100 million days from Epoch: +/* Ecmascript date range is 100 million days from Epoch: * > 100e6 * 24 * 60 * 60 * 1000 // 100M days in millisecs * 8640000000000000 * (= 8.64e15) @@ -1335,7 +1265,7 @@ #define DUK_DATE_MSEC_100M_DAYS (8.64e15) #define DUK_DATE_MSEC_100M_DAYS_LEEWAY (8.64e15 + 24 * 3600e3) -/* ECMAScript year range: +/* Ecmascript year range: * > new Date(100e6 * 24 * 3600e3).toISOString() * '+275760-09-13T00:00:00.000Z' * > new Date(-100e6 * 24 * 3600e3).toISOString() @@ -1345,7 +1275,7 @@ #define DUK_DATE_MAX_ECMA_YEAR 275760L /* Part indices for internal breakdowns. Part order from DUK_DATE_IDX_YEAR - * to DUK_DATE_IDX_MILLISECOND matches argument ordering of ECMAScript API + * to DUK_DATE_IDX_MILLISECOND matches argument ordering of Ecmascript API * calls (like Date constructor call). Some functions in duk_bi_date.c * depend on the specific ordering, so change with care. 16 bits are not * enough for all parts (year, specifically). diff -Nru duktape-2.3.0/src-separate/duk_unicode.h duktape-2.2.0/src-separate/duk_unicode.h --- duktape-2.3.0/src-separate/duk_unicode.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_unicode.h 2017-09-23 01:06:08.000000000 +0000 @@ -183,13 +183,13 @@ * Automatically generated by extract_chars.py, do not edit! */ -extern const duk_uint8_t duk_unicode_ids_noa[1063]; +extern const duk_uint8_t duk_unicode_ids_noa[1036]; #else /* * Automatically generated by extract_chars.py, do not edit! */ -extern const duk_uint8_t duk_unicode_ids_noabmp[626]; +extern const duk_uint8_t duk_unicode_ids_noabmp[625]; #endif #if defined(DUK_USE_SOURCE_NONBMP) @@ -211,13 +211,13 @@ * Automatically generated by extract_chars.py, do not edit! */ -extern const duk_uint8_t duk_unicode_idp_m_ids_noa[549]; +extern const duk_uint8_t duk_unicode_idp_m_ids_noa[530]; #else /* * Automatically generated by extract_chars.py, do not edit! */ -extern const duk_uint8_t duk_unicode_idp_m_ids_noabmp[358]; +extern const duk_uint8_t duk_unicode_idp_m_ids_noabmp[357]; #endif /* diff -Nru duktape-2.3.0/src-separate/duk_unicode_support.c duktape-2.2.0/src-separate/duk_unicode_support.c --- duktape-2.3.0/src-separate/duk_unicode_support.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_unicode_support.c 2017-09-23 01:06:08.000000000 +0000 @@ -141,7 +141,7 @@ /* * Unicode codepoints above U+FFFF are encoded as surrogate * pairs here. This ensures that all CESU-8 codepoints are - * 16-bit values as expected in ECMAScript. The surrogate + * 16-bit values as expected in Ecmascript. The surrogate * pairs always get a 3-byte encoding (each) in CESU-8. * See: http://en.wikipedia.org/wiki/Surrogate_pair * @@ -280,7 +280,8 @@ return cp; } DUK_ERROR_INTERNAL(thr); - DUK_WO_NORETURN(return 0;); + DUK_UNREACHABLE(); + return 0; } /* Compute (extended) utf-8 length without codepoint encoding validation, @@ -429,7 +430,7 @@ duk_bitdecoder_ctx bd_ctx; duk_codepoint_t prev_re; - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); bd_ctx.data = (const duk_uint8_t *) unitab; bd_ctx.length = (duk_size_t) unilen; @@ -981,7 +982,7 @@ } /* 1:1 or special conversions, but not locale/context specific: script generated rules */ - duk_memzero(&bd_ctx, sizeof(bd_ctx)); + DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx)); if (uppercase) { bd_ctx.data = (const duk_uint8_t *) duk_unicode_caseconv_uc; bd_ctx.length = (duk_size_t) sizeof(duk_unicode_caseconv_uc); diff -Nru duktape-2.3.0/src-separate/duk_unicode_tables.c duktape-2.2.0/src-separate/duk_unicode_tables.c --- duktape-2.3.0/src-separate/duk_unicode_tables.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_unicode_tables.c 2017-09-23 01:06:08.000000000 +0000 @@ -9,7 +9,7 @@ * packed format. These tables are used to match non-ASCII * characters of complex productions by resorting to a linear * range-by-range comparison. This is very slow, but is expected - * to be very rare in practical ECMAScript source code, and thus + * to be very rare in practical Ecmascript source code, and thus * compactness is most important. * * The tables are matched using uni_range_match() and the format @@ -23,55 +23,54 @@ * Automatically generated by extract_chars.py, do not edit! */ -const duk_uint8_t duk_unicode_ids_noa[1063] = { +const duk_uint8_t duk_unicode_ids_noa[1036] = { 249,176,176,80,111,7,47,15,47,254,11,197,191,0,72,2,15,115,66,19,50,7,2,34, 2,240,66,244,50,247,185,249,98,241,99,8,241,127,58,240,182,47,31,241,191, 21,18,245,50,15,1,24,27,35,15,2,2,240,239,15,244,156,15,10,241,26,21,6,240, -101,10,4,15,9,240,152,175,39,240,82,127,56,242,100,15,4,8,159,1,240,5,115, -19,240,98,98,4,52,15,2,14,18,47,0,27,9,85,19,240,98,98,18,18,31,17,50,15,5, -47,2,130,34,240,98,98,18,68,15,4,15,1,31,9,12,115,19,240,98,98,18,68,15,16, -18,47,1,15,3,2,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,240,4,15, -12,38,31,16,5,114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2, -6,41,47,10,86,240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50, -98,34,2,3,18,50,26,3,66,15,7,63,18,15,49,114,241,79,13,79,101,241,191,6,15, -2,85,52,4,24,37,205,15,3,241,98,6,3,241,178,255,224,63,35,54,32,35,63,25, -35,63,17,35,54,32,35,62,47,41,35,63,51,241,127,0,240,47,70,53,79,254,21, -227,240,18,240,166,243,180,168,194,63,0,240,47,0,240,47,0,194,47,1,242,79, -21,5,15,53,244,137,67,241,34,6,243,107,240,255,35,240,227,76,241,197,240, -175,40,240,122,242,95,68,15,79,241,255,3,111,41,240,238,27,241,207,12,241, -79,27,43,241,67,143,82,50,52,26,251,15,50,255,224,8,53,63,22,53,55,32,32, -32,47,15,63,37,38,32,66,38,67,53,92,98,38,246,96,224,240,44,245,112,80,57, -32,68,112,32,32,35,42,51,100,80,240,63,25,255,233,107,241,242,241,242,247, -87,52,29,241,98,6,3,242,136,15,2,240,122,98,98,98,98,98,98,98,111,66,15, -254,12,146,240,184,132,52,95,70,114,47,74,35,111,26,63,78,240,63,11,242, -127,0,255,224,244,255,240,0,138,143,60,255,240,4,13,223,7,255,227,127,243, -95,30,63,253,79,0,177,240,111,31,240,47,15,63,64,241,152,63,87,63,20,39, -243,26,34,35,47,7,240,255,36,240,15,34,243,5,64,32,223,12,191,7,240,191,13, -143,31,240,224,240,36,41,180,47,25,240,146,39,240,111,7,64,79,34,32,65,52, -48,32,240,162,58,130,213,53,53,166,38,47,27,41,191,99,240,255,255,0,26,150, -223,7,95,33,255,240,0,255,143,254,6,3,245,175,24,109,70,2,146,194,66,2,18, -18,245,207,19,255,224,93,240,79,48,63,38,241,171,246,100,47,119,241,111,10, -127,10,207,73,69,53,53,50,241,91,47,10,47,3,33,46,61,241,79,107,243,127,37, -255,223,13,79,33,242,31,16,239,14,111,22,191,14,63,20,87,36,241,207,142, -240,79,20,95,20,95,24,159,36,248,239,254,2,154,240,107,127,138,83,2,241, -194,20,3,240,123,240,122,240,255,51,240,50,27,240,107,240,175,56,242,135, -31,50,15,1,50,34,240,191,30,240,212,240,223,21,114,240,207,13,242,107,240, -107,240,62,240,47,96,243,159,41,242,62,242,63,254,32,79,37,243,223,29,241, -47,9,240,207,20,241,191,19,64,223,32,240,3,240,112,32,241,95,2,47,9,244, -102,32,35,46,41,143,31,241,135,49,63,6,38,33,36,64,240,64,212,249,15,37, -240,67,242,127,32,240,97,32,250,175,31,241,179,241,111,32,240,96,242,223, -27,244,127,10,255,224,122,243,15,17,15,242,11,241,136,15,7,12,241,131,63, -40,242,159,249,130,241,95,3,15,35,240,239,98,98,18,241,111,7,15,254,26,223, -254,40,207,88,245,255,3,251,79,254,155,15,254,50,31,254,236,95,254,19,159, -255,0,16,173,255,225,43,143,15,246,63,14,240,79,32,240,35,241,31,5,111,3, -255,226,100,243,92,15,52,207,50,31,16,255,240,0,109,255,5,255,225,229,255, -240,1,64,31,254,1,31,67,255,224,126,255,231,248,245,182,196,136,159,255,0, -6,90,244,82,243,114,19,3,19,50,178,2,98,243,18,51,114,98,240,194,50,66,4, -98,255,224,70,63,9,47,9,47,15,47,9,47,15,47,9,47,15,47,9,47,15,47,9,39,255, -239,40,251,95,45,243,79,254,59,3,47,11,33,32,48,41,35,32,32,112,80,32,32, -34,33,32,48,32,32,32,32,33,32,51,38,35,35,32,41,47,1,98,36,47,1,255,240,0, -3,143,255,0,149,201,241,191,254,242,124,252,227,255,240,0,87,79,0,255,240, -0,194,63,254,177,63,254,17,0, +101,10,4,15,9,240,159,57,240,82,127,56,242,100,15,4,8,159,1,240,5,115,19, +240,98,98,4,52,15,2,14,18,47,0,31,5,85,19,240,98,98,18,18,31,17,50,15,5,47, +2,130,34,240,98,98,18,68,15,4,15,1,31,9,12,115,19,240,98,98,18,68,15,16,18, +47,1,15,3,2,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,240,4,15,12, +38,31,16,5,114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2,6, +41,47,10,86,240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50,98, +34,2,3,18,50,26,3,66,15,7,63,18,15,49,114,241,79,13,79,101,241,191,6,15,2, +85,52,4,24,37,205,15,3,241,98,6,3,241,178,255,224,63,35,54,32,35,63,25,35, +63,17,35,54,32,35,62,47,41,35,63,51,241,127,0,240,47,70,53,79,254,21,227, +240,18,240,166,243,180,168,194,63,0,240,47,0,240,47,0,194,47,1,242,79,21,5, +15,53,244,137,67,241,34,6,243,107,240,255,35,240,227,76,241,197,240,175,40, +240,122,242,95,68,15,79,241,255,3,111,41,240,238,27,241,207,12,241,79,27, +43,241,67,143,82,50,52,26,251,15,50,255,224,8,53,63,22,53,55,32,32,32,47, +15,63,37,38,32,66,38,67,53,92,98,38,246,96,224,240,44,245,112,80,57,32,68, +112,32,32,35,42,51,100,80,240,63,25,255,233,107,241,242,241,242,247,87,52, +29,241,98,6,3,242,136,15,2,240,122,98,98,98,98,98,98,98,111,66,15,254,12, +146,240,184,132,52,95,70,114,47,74,35,111,25,79,78,240,63,11,242,127,0,255, +224,244,255,240,0,138,143,60,255,240,4,12,143,28,255,227,127,243,95,30,63, +253,79,0,177,240,111,31,240,47,15,63,64,241,152,63,87,63,20,39,243,26,34, +35,47,7,240,255,36,240,15,34,243,5,64,32,223,12,191,7,240,191,13,143,31, +240,224,240,36,41,180,47,25,240,146,39,240,111,7,64,79,34,32,65,52,48,32, +240,162,58,130,213,53,53,166,38,47,27,41,191,99,240,255,255,0,26,150,223,7, +95,33,255,240,0,255,143,254,6,3,245,175,24,109,70,2,146,194,66,2,18,18,245, +207,19,255,224,93,240,79,48,63,38,241,171,246,100,47,119,241,111,10,127,10, +207,73,69,53,53,50,241,91,47,10,47,3,33,46,61,241,79,107,243,127,37,255, +223,13,79,33,242,31,16,240,47,11,111,22,191,14,63,20,87,36,241,207,142,240, +79,20,95,20,95,24,159,36,248,239,254,2,154,240,107,127,138,83,2,241,194,20, +3,240,123,240,122,240,255,51,240,50,27,240,107,240,175,56,242,135,31,50,15, +1,50,34,240,191,30,240,212,240,223,21,114,240,207,13,242,107,240,107,240, +62,240,47,96,243,159,41,242,62,242,63,254,32,79,37,243,223,29,241,47,9,240, +207,20,241,191,19,64,223,32,240,3,240,112,32,241,95,2,47,9,244,102,32,35, +46,41,143,31,241,135,49,63,6,38,33,36,64,240,64,212,249,15,37,240,67,242, +127,32,240,97,32,250,175,31,241,179,241,111,32,240,96,242,223,27,244,127, +10,255,224,122,243,15,17,15,254,11,79,41,255,152,47,21,240,48,242,63,14, +255,226,100,255,226,140,245,143,95,240,63,180,255,233,176,255,227,33,255, +238,197,255,225,57,255,240,1,10,223,254,18,184,240,255,99,240,239,4,242,15, +2,63,17,240,86,240,63,254,38,79,53,192,243,76,243,32,241,31,255,0,6,223, +240,95,254,30,95,255,0,20,1,31,254,175,47,91,108,72,137,255,240,0,101,175, +69,47,55,33,48,49,51,43,32,38,47,49,35,55,38,47,12,35,36,32,70,47,254,4,99, +240,146,240,146,240,242,240,146,240,242,240,146,240,242,240,146,240,242, +240,146,127,254,242,143,181,242,223,52,255,227,176,50,240,178,18,3,2,146, +50,2,7,5,2,2,2,34,18,3,2,2,2,2,2,18,3,50,98,50,50,2,146,240,22,34,66,240, +31,255,0,0,56,255,240,9,92,159,27,255,239,39,207,206,63,255,0,5,116,255, +240,1,133,47,254,17,0, }; #else /* IdentifierStart production with ASCII and non-BMP excluded */ @@ -80,35 +79,35 @@ * Automatically generated by extract_chars.py, do not edit! */ -const duk_uint8_t duk_unicode_ids_noabmp[626] = { +const duk_uint8_t duk_unicode_ids_noabmp[625] = { 249,176,176,80,111,7,47,15,47,254,11,197,191,0,72,2,15,115,66,19,50,7,2,34, 2,240,66,244,50,247,185,249,98,241,99,8,241,127,58,240,182,47,31,241,191, 21,18,245,50,15,1,24,27,35,15,2,2,240,239,15,244,156,15,10,241,26,21,6,240, -101,10,4,15,9,240,152,175,39,240,82,127,56,242,100,15,4,8,159,1,240,5,115, -19,240,98,98,4,52,15,2,14,18,47,0,27,9,85,19,240,98,98,18,18,31,17,50,15,5, -47,2,130,34,240,98,98,18,68,15,4,15,1,31,9,12,115,19,240,98,98,18,68,15,16, -18,47,1,15,3,2,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,240,4,15, -12,38,31,16,5,114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2, -6,41,47,10,86,240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50, -98,34,2,3,18,50,26,3,66,15,7,63,18,15,49,114,241,79,13,79,101,241,191,6,15, -2,85,52,4,24,37,205,15,3,241,98,6,3,241,178,255,224,63,35,54,32,35,63,25, -35,63,17,35,54,32,35,62,47,41,35,63,51,241,127,0,240,47,70,53,79,254,21, -227,240,18,240,166,243,180,168,194,63,0,240,47,0,240,47,0,194,47,1,242,79, -21,5,15,53,244,137,67,241,34,6,243,107,240,255,35,240,227,76,241,197,240, -175,40,240,122,242,95,68,15,79,241,255,3,111,41,240,238,27,241,207,12,241, -79,27,43,241,67,143,82,50,52,26,251,15,50,255,224,8,53,63,22,53,55,32,32, -32,47,15,63,37,38,32,66,38,67,53,92,98,38,246,96,224,240,44,245,112,80,57, -32,68,112,32,32,35,42,51,100,80,240,63,25,255,233,107,241,242,241,242,247, -87,52,29,241,98,6,3,242,136,15,2,240,122,98,98,98,98,98,98,98,111,66,15, -254,12,146,240,184,132,52,95,70,114,47,74,35,111,26,63,78,240,63,11,242, -127,0,255,224,244,255,240,0,138,143,60,255,240,4,13,223,7,255,227,127,243, -95,30,63,253,79,0,177,240,111,31,240,47,15,63,64,241,152,63,87,63,20,39, -243,26,34,35,47,7,240,255,36,240,15,34,243,5,64,32,223,12,191,7,240,191,13, -143,31,240,224,240,36,41,180,47,25,240,146,39,240,111,7,64,79,34,32,65,52, -48,32,240,162,58,130,213,53,53,166,38,47,27,41,191,99,240,255,255,0,26,150, -223,7,95,33,255,240,0,255,143,254,6,3,245,175,24,109,70,2,146,194,66,2,18, -18,245,207,19,255,224,93,240,79,48,63,38,241,171,246,100,47,119,241,111,10, -127,10,207,73,69,53,53,50,0, +101,10,4,15,9,240,159,57,240,82,127,56,242,100,15,4,8,159,1,240,5,115,19, +240,98,98,4,52,15,2,14,18,47,0,31,5,85,19,240,98,98,18,18,31,17,50,15,5,47, +2,130,34,240,98,98,18,68,15,4,15,1,31,9,12,115,19,240,98,98,18,68,15,16,18, +47,1,15,3,2,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,240,4,15,12, +38,31,16,5,114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2,6, +41,47,10,86,240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50,98, +34,2,3,18,50,26,3,66,15,7,63,18,15,49,114,241,79,13,79,101,241,191,6,15,2, +85,52,4,24,37,205,15,3,241,98,6,3,241,178,255,224,63,35,54,32,35,63,25,35, +63,17,35,54,32,35,62,47,41,35,63,51,241,127,0,240,47,70,53,79,254,21,227, +240,18,240,166,243,180,168,194,63,0,240,47,0,240,47,0,194,47,1,242,79,21,5, +15,53,244,137,67,241,34,6,243,107,240,255,35,240,227,76,241,197,240,175,40, +240,122,242,95,68,15,79,241,255,3,111,41,240,238,27,241,207,12,241,79,27, +43,241,67,143,82,50,52,26,251,15,50,255,224,8,53,63,22,53,55,32,32,32,47, +15,63,37,38,32,66,38,67,53,92,98,38,246,96,224,240,44,245,112,80,57,32,68, +112,32,32,35,42,51,100,80,240,63,25,255,233,107,241,242,241,242,247,87,52, +29,241,98,6,3,242,136,15,2,240,122,98,98,98,98,98,98,98,111,66,15,254,12, +146,240,184,132,52,95,70,114,47,74,35,111,25,79,78,240,63,11,242,127,0,255, +224,244,255,240,0,138,143,60,255,240,4,12,143,28,255,227,127,243,95,30,63, +253,79,0,177,240,111,31,240,47,15,63,64,241,152,63,87,63,20,39,243,26,34, +35,47,7,240,255,36,240,15,34,243,5,64,32,223,12,191,7,240,191,13,143,31, +240,224,240,36,41,180,47,25,240,146,39,240,111,7,64,79,34,32,65,52,48,32, +240,162,58,130,213,53,53,166,38,47,27,41,191,99,240,255,255,0,26,150,223,7, +95,33,255,240,0,255,143,254,6,3,245,175,24,109,70,2,146,194,66,2,18,18,245, +207,19,255,224,93,240,79,48,63,38,241,171,246,100,47,119,241,111,10,127,10, +207,73,69,53,53,50,0, }; #endif @@ -143,33 +142,32 @@ * Automatically generated by extract_chars.py, do not edit! */ -const duk_uint8_t duk_unicode_idp_m_ids_noa[549] = { +const duk_uint8_t duk_unicode_idp_m_ids_noa[530] = { 255,225,243,246,15,254,0,116,255,191,29,32,33,33,32,243,170,242,47,15,112, 245,118,53,49,35,57,240,144,241,15,11,244,218,240,25,241,56,241,67,40,34, 36,241,210,246,173,47,17,242,130,47,2,38,177,57,240,50,242,160,38,49,50, 160,177,57,240,50,242,160,36,81,50,64,240,107,64,194,242,160,39,34,34,240, -97,57,181,34,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9, -240,35,242,198,34,35,129,193,57,240,50,242,160,38,34,35,129,193,57,240,35, -242,145,38,34,35,160,177,57,240,65,243,128,85,32,39,121,49,242,240,54,215, -41,244,144,53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160, -245,111,4,41,211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240, -241,241,1,243,47,16,160,57,241,50,57,245,209,241,64,246,139,91,185,247,41, -242,244,242,185,47,13,58,121,240,141,243,68,242,31,1,201,240,56,210,241,12, -57,241,237,242,47,4,153,121,246,130,47,5,80,82,50,251,143,42,36,255,225,0, -31,35,31,5,15,109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91, -31,255,0,100,121,159,55,5,159,18,31,66,31,254,0,64,64,80,240,148,244,161, -242,79,2,185,127,2,240,9,240,231,240,188,241,227,242,29,240,25,192,185,242, -29,208,145,57,241,50,242,64,34,49,97,32,241,180,97,253,231,33,57,255,240,3, +97,57,240,50,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9, +240,35,242,198,34,35,129,193,57,240,50,242,160,38,34,35,129,193,57,240,50, +242,198,34,35,160,177,57,240,65,243,128,85,32,39,121,49,242,240,54,215,41, +244,144,53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160,245, +111,4,41,211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240,241, +241,1,243,47,16,160,57,241,50,57,245,209,241,64,246,139,91,185,247,41,242, +244,242,185,47,13,58,121,240,141,243,68,242,31,1,201,240,56,210,241,12,57, +241,237,242,47,4,153,121,246,130,47,5,80,82,65,251,143,38,100,255,225,0,31, +35,31,5,15,109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91,31, +255,0,100,121,159,55,5,159,18,31,66,31,254,0,64,64,80,240,148,244,161,242, +79,2,185,127,2,240,9,240,231,240,188,241,227,242,29,240,25,192,185,242,29, +208,145,57,241,50,242,64,34,49,97,32,241,180,97,253,231,33,57,255,240,3, 225,128,255,225,213,240,15,2,240,4,31,10,47,178,159,23,15,254,27,16,253,64, 248,116,255,224,25,159,254,68,178,33,99,241,162,80,249,113,255,228,13,47, 39,239,17,159,1,63,31,175,39,151,47,22,210,159,37,13,47,34,218,36,159,68, 183,15,146,182,151,63,42,2,99,19,42,11,19,100,79,178,240,42,159,72,240,77, 159,199,99,143,13,31,68,240,31,1,159,67,201,159,69,229,159,254,9,169,255, -224,11,159,26,98,57,10,175,32,240,15,254,8,151,39,240,41,242,175,6,45,246, -197,64,33,38,32,153,255,240,3,191,169,247,132,242,214,240,185,255,226,235, -241,239,2,63,255,0,59,254,31,255,0,3,186,68,89,115,111,16,63,134,47,254,71, -223,34,255,224,244,242,117,242,41,15,0,15,8,66,239,254,68,70,47,1,54,33,36, -255,231,153,111,95,102,159,255,12,6,154,254,0, +226,57,114,127,2,159,42,240,98,223,255,0,60,157,159,120,79,45,111,11,159, +254,46,191,30,240,35,255,240,3,191,225,255,240,0,59,164,69,151,54,241,3, +248,98,255,228,125,242,47,254,15,79,39,95,34,144,240,0,240,132,46,255,228, +68,98,240,19,98,18,79,254,121,150,245,246,105,255,240,192,105,175,224,0, }; #else /* IdentifierPart production with IdentifierStart, ASCII, and non-BMP excluded */ @@ -178,23 +176,23 @@ * Automatically generated by extract_chars.py, do not edit! */ -const duk_uint8_t duk_unicode_idp_m_ids_noabmp[358] = { +const duk_uint8_t duk_unicode_idp_m_ids_noabmp[357] = { 255,225,243,246,15,254,0,116,255,191,29,32,33,33,32,243,170,242,47,15,112, 245,118,53,49,35,57,240,144,241,15,11,244,218,240,25,241,56,241,67,40,34, 36,241,210,246,173,47,17,242,130,47,2,38,177,57,240,50,242,160,38,49,50, 160,177,57,240,50,242,160,36,81,50,64,240,107,64,194,242,160,39,34,34,240, -97,57,181,34,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9, -240,35,242,198,34,35,129,193,57,240,50,242,160,38,34,35,129,193,57,240,35, -242,145,38,34,35,160,177,57,240,65,243,128,85,32,39,121,49,242,240,54,215, -41,244,144,53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160, -245,111,4,41,211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240, -241,241,1,243,47,16,160,57,241,50,57,245,209,241,64,246,139,91,185,247,41, -242,244,242,185,47,13,58,121,240,141,243,68,242,31,1,201,240,56,210,241,12, -57,241,237,242,47,4,153,121,246,130,47,5,80,82,50,251,143,42,36,255,225,0, -31,35,31,5,15,109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91, -31,255,0,100,121,159,55,5,159,18,31,66,31,254,0,64,64,80,240,148,244,161, -242,79,2,185,127,2,240,9,240,231,240,188,241,227,242,29,240,25,192,185,242, -29,208,145,57,241,50,242,64,34,49,97,32,241,180,97,253,231,33,57,255,240,3, +97,57,240,50,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9, +240,35,242,198,34,35,129,193,57,240,50,242,160,38,34,35,129,193,57,240,50, +242,198,34,35,160,177,57,240,65,243,128,85,32,39,121,49,242,240,54,215,41, +244,144,53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160,245, +111,4,41,211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240,241, +241,1,243,47,16,160,57,241,50,57,245,209,241,64,246,139,91,185,247,41,242, +244,242,185,47,13,58,121,240,141,243,68,242,31,1,201,240,56,210,241,12,57, +241,237,242,47,4,153,121,246,130,47,5,80,82,65,251,143,38,100,255,225,0,31, +35,31,5,15,109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91,31, +255,0,100,121,159,55,5,159,18,31,66,31,254,0,64,64,80,240,148,244,161,242, +79,2,185,127,2,240,9,240,231,240,188,241,227,242,29,240,25,192,185,242,29, +208,145,57,241,50,242,64,34,49,97,32,241,180,97,253,231,33,57,255,240,3, 225,128,255,225,213,240,15,2,240,4,31,10,47,178,159,23,0, }; #endif diff -Nru duktape-2.3.0/src-separate/duk_util_bufwriter.c duktape-2.2.0/src-separate/duk_util_bufwriter.c --- duktape-2.3.0/src-separate/duk_util_bufwriter.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_util_bufwriter.c 2017-09-23 01:06:08.000000000 +0000 @@ -4,10 +4,6 @@ #include "duk_internal.h" -/* XXX: Avoid duk_{memcmp,memmove}_unsafe() by imposing a minimum length of - * >0 for the underlying dynamic buffer. - */ - /* * Macro support functions (use only macros in calling code) */ @@ -19,9 +15,6 @@ DUK_ASSERT(bw_ctx != NULL); DUK_UNREF(thr); - /* 'p' might be NULL when the underlying buffer is zero size. If so, - * the resulting pointers are not used unsafely. - */ p = (duk_uint8_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, bw_ctx->buf); DUK_ASSERT(p != NULL || (DUK_HBUFFER_DYNAMIC_GET_SIZE(bw_ctx->buf) == 0 && curr_offset == 0 && new_length == 0)); bw_ctx->p = p + curr_offset; @@ -30,6 +23,7 @@ } DUK_INTERNAL void duk_bw_init(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_hbuffer_dynamic *h_buf) { + DUK_ASSERT(thr != NULL); DUK_ASSERT(bw_ctx != NULL); DUK_ASSERT(h_buf != NULL); @@ -44,7 +38,6 @@ (void) duk_push_dynamic_buffer(thr, buf_size); bw_ctx->buf = (duk_hbuffer_dynamic *) duk_known_hbuffer(thr, -1); - DUK_ASSERT(bw_ctx->buf != NULL); duk__bw_update_ptrs(thr, bw_ctx, 0, buf_size); } @@ -69,7 +62,7 @@ if (DUK_UNLIKELY(new_sz < curr_off)) { /* overflow */ DUK_ERROR_RANGE(thr, DUK_STR_BUFFER_TOO_LONG); - DUK_WO_NORETURN(return NULL;); + return NULL; /* not reachable */ } #if 0 /* for manual torture testing: tight allocation, useful with valgrind */ new_sz = curr_off + sz; @@ -112,9 +105,9 @@ DUK_UNREF(thr); p_base = bw->p_base; - duk_memcpy_unsafe((void *) bw->p, - (const void *) (p_base + src_off), - (size_t) len); + DUK_MEMCPY((void *) bw->p, + (const void *) (p_base + src_off), + (size_t) len); bw->p += len; } @@ -144,12 +137,12 @@ move_sz = buf_sz - dst_off; DUK_ASSERT(p_base != NULL); /* buffer size is >= 1 */ - duk_memmove_unsafe((void *) (p_base + dst_off + len), - (const void *) (p_base + dst_off), - (size_t) move_sz); - duk_memcpy_unsafe((void *) (p_base + dst_off), - (const void *) buf, - (size_t) len); + DUK_MEMMOVE((void *) (p_base + dst_off + len), + (const void *) (p_base + dst_off), + (size_t) move_sz); + DUK_MEMCPY((void *) (p_base + dst_off), + (const void *) buf, + (size_t) len); bw->p += len; } @@ -191,12 +184,12 @@ move_sz = buf_sz - dst_off; DUK_ASSERT(p_base != NULL); /* buffer size is >= 1 */ - duk_memmove_unsafe((void *) (p_base + dst_off + len), - (const void *) (p_base + dst_off), - (size_t) move_sz); - duk_memcpy_unsafe((void *) (p_base + dst_off), - (const void *) (p_base + src_off), - (size_t) len); + DUK_MEMMOVE((void *) (p_base + dst_off + len), + (const void *) (p_base + dst_off), + (size_t) move_sz); + DUK_MEMCPY((void *) (p_base + dst_off), + (const void *) (p_base + src_off), + (size_t) len); bw->p += len; } @@ -229,7 +222,7 @@ move_sz = buf_sz - off; p_dst = p_base + off + len; p_src = p_base + off; - duk_memmove_unsafe((void *) p_dst, (const void *) p_src, (size_t) move_sz); + DUK_MEMMOVE((void *) p_dst, (const void *) p_src, (size_t) move_sz); return p_src; /* point to start of 'reserved area' */ } @@ -260,9 +253,9 @@ p_dst = p_base + off; p_src = p_dst + len; move_sz = (duk_size_t) (bw->p - p_src); - duk_memmove_unsafe((void *) p_dst, - (const void *) p_src, - (size_t) move_sz); + DUK_MEMMOVE((void *) p_dst, + (const void *) p_src, + (size_t) move_sz); bw->p -= len; } @@ -283,7 +276,7 @@ duk_uint16_t x; } u; - duk_memcpy((void *) u.b, (const void *) (*p), (size_t) 2); + DUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 2); u.x = DUK_NTOH16(u.x); *p += 2; return u.x; @@ -295,7 +288,7 @@ duk_uint32_t x; } u; - duk_memcpy((void *) u.b, (const void *) (*p), (size_t) 4); + DUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 4); u.x = DUK_NTOH32(u.x); *p += 4; return u.x; @@ -308,10 +301,10 @@ duk_uint32_t x; } u; - duk_memcpy((void *) u.b, (const void *) (*p), (size_t) 4); + DUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 4); u.x = DUK_NTOH32(u.x); du.ui[DUK_DBL_IDX_UI0] = u.x; - duk_memcpy((void *) u.b, (const void *) (*p + 4), (size_t) 4); + DUK_MEMCPY((void *) u.b, (const void *) (*p + 4), (size_t) 4); u.x = DUK_NTOH32(u.x); du.ui[DUK_DBL_IDX_UI1] = u.x; *p += 8; @@ -326,7 +319,7 @@ } u; u.x = DUK_HTON16(val); - duk_memcpy((void *) (*p), (const void *) u.b, (size_t) 2); + DUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 2); *p += 2; } @@ -337,7 +330,7 @@ } u; u.x = DUK_HTON32(val); - duk_memcpy((void *) (*p), (const void *) u.b, (size_t) 4); + DUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 4); *p += 4; } @@ -351,9 +344,9 @@ du.d = val; u.x = du.ui[DUK_DBL_IDX_UI0]; u.x = DUK_HTON32(u.x); - duk_memcpy((void *) (*p), (const void *) u.b, (size_t) 4); + DUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 4); u.x = du.ui[DUK_DBL_IDX_UI1]; u.x = DUK_HTON32(u.x); - duk_memcpy((void *) (*p + 4), (const void *) u.b, (size_t) 4); + DUK_MEMCPY((void *) (*p + 4), (const void *) u.b, (size_t) 4); *p += 8; } diff -Nru duktape-2.3.0/src-separate/duk_util_cast.c duktape-2.2.0/src-separate/duk_util_cast.c --- duktape-2.3.0/src-separate/duk_util_cast.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_util_cast.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ -/* - * Cast helpers. - * - * C99+ coercion is challenging portability-wise because out-of-range casts - * may invoke implementation defined or even undefined behavior. See e.g. - * http://blog.frama-c.com/index.php?post/2013/10/09/Overflow-float-integer. - * - * Provide explicit cast helpers which try to avoid implementation defined - * or undefined behavior. These helpers can then be simplified in the vast - * majority of cases where the implementation defined or undefined behavior - * is not problematic. - */ - -#include "duk_internal.h" - -/* Portable double-to-integer cast which avoids undefined behavior and avoids - * relying on fmin(), fmax(), or other intrinsics. Out-of-range results are - * not assumed by caller, but here value is clamped, NaN converts to minval. - */ -#define DUK__DOUBLE_INT_CAST1(tname,minval,maxval) do { \ - if (DUK_LIKELY(x >= (duk_double_t) (minval))) { \ - DUK_ASSERT(!DUK_ISNAN(x)); \ - if (DUK_LIKELY(x <= (duk_double_t) (maxval))) { \ - return (tname) x; \ - } else { \ - return (tname) (maxval); \ - } \ - } else { \ - /* NaN or below minval. Since we don't care about the result \ - * for out-of-range values, just return the minimum value for \ - * both. \ - */ \ - return (tname) (minval); \ - } \ - } while (0) - -/* Rely on specific NaN behavior for duk_double_{fmin,fmax}(): if either - * argument is a NaN, return the second argument. This avoids a - * NaN-to-integer cast which is undefined behavior. - */ -#define DUK__DOUBLE_INT_CAST2(tname,minval,maxval) do { \ - return (tname) duk_double_fmin(duk_double_fmax(x, (duk_double_t) (minval)), (duk_double_t) (maxval)); \ - } while (0) - -/* Another solution which doesn't need C99+ behavior for fmin() and fmax(). */ -#define DUK__DOUBLE_INT_CAST3(tname,minval,maxval) do { \ - if (DUK_ISNAN(x)) { \ - /* 0 or any other value is fine. */ \ - return (tname) 0; \ - } else \ - return (tname) DUK_FMIN(DUK_FMAX(x, (duk_double_t) (minval)), (duk_double_t) (maxval)); \ - } \ - } while (0) - -/* C99+ solution: relies on specific fmin() and fmax() behavior in C99: if - * one argument is NaN but the other isn't, the non-NaN argument is returned. - * Because the limits are non-NaN values, explicit NaN check is not needed. - * This may not work on all legacy platforms, and also doesn't seem to inline - * the fmin() and fmax() calls (unless one uses -ffast-math which we don't - * support). - */ -#define DUK__DOUBLE_INT_CAST4(tname,minval,maxval) do { \ - return (tname) DUK_FMIN(DUK_FMAX(x, (duk_double_t) (minval)), (duk_double_t) (maxval)); \ - } while (0) - -DUK_INTERNAL duk_int_t duk_double_to_int_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - /* Real world solution: almost any practical platform will provide - * an integer value without any guarantees what it is (which is fine). - */ - return (duk_int_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_int_t, DUK_INT_MIN, DUK_INT_MAX); -#endif -} - -DUK_INTERNAL duk_uint_t duk_double_to_uint_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_uint_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_uint_t, DUK_UINT_MIN, DUK_UINT_MAX); -#endif -} - -DUK_INTERNAL duk_int32_t duk_double_to_int32_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_int32_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_int32_t, DUK_INT32_MIN, DUK_INT32_MAX); -#endif -} - -DUK_INTERNAL duk_uint32_t duk_double_to_uint32_t(duk_double_t x) { -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_uint32_t) x; -#else - DUK__DOUBLE_INT_CAST1(duk_uint32_t, DUK_UINT32_MIN, DUK_UINT32_MAX); -#endif -} - -/* Largest IEEE double that doesn't round to infinity in the default rounding - * mode. The exact midpoint between (1 - 2^(-24)) * 2^128 and 2^128 rounds to - * infinity, at least on x64. This number is one double unit below that - * midpoint. See misc/float_cast.c. - */ -#define DUK__FLOAT_ROUND_LIMIT 340282356779733623858607532500980858880.0 - -/* Maximum IEEE float. Double-to-float conversion above this would be out of - * range and thus technically undefined behavior. - */ -#define DUK__FLOAT_MAX 340282346638528859811704183484516925440.0 - -DUK_INTERNAL duk_float_t duk_double_to_float_t(duk_double_t x) { - /* Even a double-to-float cast is technically undefined behavior if - * the double is out-of-range. C99 Section 6.3.1.5: - * - * If the value being converted is in the range of values that can - * be represented but cannot be represented exactly, the result is - * either the nearest higher or nearest lower representable value, - * chosen in an implementation-defined manner. If the value being - * converted is outside the range of values that can be represented, - * the behavior is undefined. - */ -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - return (duk_float_t) x; -#else - duk_double_t t; - - t = DUK_FABS(x); - DUK_ASSERT((DUK_ISNAN(x) && DUK_ISNAN(t)) || - (!DUK_ISNAN(x) && !DUK_ISNAN(t))); - - if (DUK_LIKELY(t <= DUK__FLOAT_MAX)) { - /* Standard in-range case, try to get here with a minimum - * number of checks and branches. - */ - DUK_ASSERT(!DUK_ISNAN(x)); - return (duk_float_t) x; - } else if (t <= DUK__FLOAT_ROUND_LIMIT) { - /* Out-of-range, but rounds to min/max float. */ - DUK_ASSERT(!DUK_ISNAN(x)); - if (x < 0.0) { - return (duk_float_t) -DUK__FLOAT_MAX; - } else { - return (duk_float_t) DUK__FLOAT_MAX; - } - } else if (DUK_ISNAN(x)) { - /* Assumes double NaN -> float NaN considered "in range". */ - DUK_ASSERT(DUK_ISNAN(x)); - return (duk_float_t) x; - } else { - /* Out-of-range, rounds to +/- Infinity. */ - if (x < 0.0) { - return (duk_float_t) -DUK_DOUBLE_INFINITY; - } else { - return (duk_float_t) DUK_DOUBLE_INFINITY; - } - } -#endif -} diff -Nru duktape-2.3.0/src-separate/duk_util_double.c duktape-2.2.0/src-separate/duk_util_double.c --- duktape-2.3.0/src-separate/duk_util_double.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_util_double.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,234 +0,0 @@ -/* - * IEEE double helpers. - */ - -#include "duk_internal.h" - -DUK_INTERNAL duk_bool_t duk_double_is_anyinf(duk_double_t x) { - duk_double_union du; - du.d = x; - return DUK_DBLUNION_IS_ANYINF(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_posinf(duk_double_t x) { - duk_double_union du; - du.d = x; - return DUK_DBLUNION_IS_POSINF(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_neginf(duk_double_t x) { - duk_double_union du; - du.d = x; - return DUK_DBLUNION_IS_NEGINF(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan(duk_double_t x) { - duk_double_union du; - du.d = x; - /* Assumes we're dealing with a Duktape internal NaN which is - * NaN normalized if duk_tval requires it. - */ - DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); - return DUK_DBLUNION_IS_NAN(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan_or_zero(duk_double_t x) { - duk_double_union du; - du.d = x; - /* Assumes we're dealing with a Duktape internal NaN which is - * NaN normalized if duk_tval requires it. - */ - DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); - return DUK_DBLUNION_IS_NAN(&du) || DUK_DBLUNION_IS_ANYZERO(&du); -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan_or_inf(duk_double_t x) { - duk_double_union du; - du.d = x; - /* If exponent is 0x7FF the argument is either a NaN or an - * infinity. We don't need to check any other fields. - */ -#if defined(DUK_USE_64BIT_OPS) -#if defined(DUK_USE_DOUBLE_ME) - return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000)) == DUK_U64_CONSTANT(0x000000007ff00000); -#else - return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000)) == DUK_U64_CONSTANT(0x7ff0000000000000); -#endif -#else - return (du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL) == 0x7ff00000UL; -#endif -} - -DUK_INTERNAL duk_bool_t duk_double_is_nan_zero_inf(duk_double_t x) { - duk_double_union du; -#if defined(DUK_USE_64BIT_OPS) - duk_uint64_t t; -#else - duk_uint32_t t; -#endif - du.d = x; -#if defined(DUK_USE_64BIT_OPS) -#if defined(DUK_USE_DOUBLE_ME) - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000); - if (t == DUK_U64_CONSTANT(0x0000000000000000)) { - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x0000000080000000); - return t == 0; - } - if (t == DUK_U64_CONSTANT(0x000000007ff00000)) { - return 1; - } -#else - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000); - if (t == DUK_U64_CONSTANT(0x0000000000000000)) { - t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x8000000000000000); - return t == 0; - } - if (t == DUK_U64_CONSTANT(0x7ff0000000000000)) { - return 1; - } -#endif -#else - t = du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL; - if (t == 0x00000000UL) { - return DUK_DBLUNION_IS_ANYZERO(&du); - } - if (t == 0x7ff00000UL) { - return 1; - } -#endif - return 0; -} - -DUK_INTERNAL duk_small_uint_t duk_double_signbit(duk_double_t x) { - duk_double_union du; - du.d = x; - return (duk_small_uint_t) DUK_DBLUNION_GET_SIGNBIT(&du); -} - -DUK_INTERNAL duk_double_t duk_double_trunc_towards_zero(duk_double_t x) { - /* XXX: optimize */ - duk_small_uint_t s = duk_double_signbit(x); - x = DUK_FLOOR(DUK_FABS(x)); /* truncate towards zero */ - if (s) { - x = -x; - } - return x; -} - -DUK_INTERNAL duk_bool_t duk_double_same_sign(duk_double_t x, duk_double_t y) { - duk_double_union du1; - duk_double_union du2; - du1.d = x; - du2.d = y; - - return (((du1.ui[DUK_DBL_IDX_UI0] ^ du2.ui[DUK_DBL_IDX_UI0]) & 0x80000000UL) == 0); -} - -DUK_INTERNAL duk_double_t duk_double_fmin(duk_double_t x, duk_double_t y) { - /* Doesn't replicate fmin() behavior exactly: for fmin() if one - * argument is a NaN, the other argument should be returned. - * Duktape doesn't rely on this behavior so the replacement can - * be simplified. - */ - return (x < y ? x : y); -} - -DUK_INTERNAL duk_double_t duk_double_fmax(duk_double_t x, duk_double_t y) { - /* Doesn't replicate fmax() behavior exactly: for fmax() if one - * argument is a NaN, the other argument should be returned. - * Duktape doesn't rely on this behavior so the replacement can - * be simplified. - */ - return (x > y ? x : y); -} - -DUK_INTERNAL duk_bool_t duk_double_is_finite(duk_double_t x) { - return !duk_double_is_nan_or_inf(x); -} - -DUK_INTERNAL duk_bool_t duk_double_is_integer(duk_double_t x) { - if (duk_double_is_nan_or_inf(x)) { - return 0; - } else { - return duk_js_tointeger_number(x) == x; - } -} - -DUK_INTERNAL duk_bool_t duk_double_is_safe_integer(duk_double_t x) { - /* >>> 2**53-1 - * 9007199254740991 - */ - return duk_double_is_integer(x) && DUK_FABS(x) <= 9007199254740991.0; -} - -/* Check whether a duk_double_t is a whole number in the 32-bit range (reject - * negative zero), and if so, return a duk_int32_t. - * For compiler use: don't allow negative zero as it will cause trouble with - * LDINT+LDINTX, positive zero is OK. - */ -DUK_INTERNAL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int32_t *ival) { - duk_int32_t t; - - t = duk_double_to_int32_t(x); - if (!((duk_double_t) t == x)) { - return 0; - } - if (t == 0) { - duk_double_union du; - du.d = x; - if (DUK_DBLUNION_HAS_SIGNBIT(&du)) { - return 0; - } - } - *ival = t; - return 1; -} - -/* Check whether a duk_double_t is a whole number in the 32-bit range, and if - * so, return a duk_int32_t. - */ -DUK_INTERNAL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival) { - duk_int32_t t; - - t = duk_double_to_int32_t(x); - if (!((duk_double_t) t == x)) { - return 0; - } - *ival = t; - return 1; -} - -/* Division: division by zero is undefined behavior (and may in fact trap) - * so it needs special handling for portability. - */ - -DUK_INTERNAL DUK_INLINE duk_double_t duk_double_div(duk_double_t x, duk_double_t y) { -#if !defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) - if (DUK_UNLIKELY(y == 0.0)) { - /* In C99+ division by zero is undefined behavior so - * avoid it entirely. Hopefully the compiler is - * smart enough to avoid emitting any actual code - * because almost all practical platforms behave as - * expected. - */ - if (x > 0.0) { - if (DUK_SIGNBIT(y)) { - return -DUK_DOUBLE_INFINITY; - } else { - return DUK_DOUBLE_INFINITY; - } - } else if (x < 0.0) { - if (DUK_SIGNBIT(y)) { - return DUK_DOUBLE_INFINITY; - } else { - return -DUK_DOUBLE_INFINITY; - } - } else { - /* +/- 0, NaN */ - return DUK_DOUBLE_NAN; - } - } -#endif - - return x / y; -} diff -Nru duktape-2.3.0/src-separate/duk_util.h duktape-2.2.0/src-separate/duk_util.h --- duktape-2.3.0/src-separate/duk_util.h 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_util.h 2017-09-23 01:06:08.000000000 +0000 @@ -315,13 +315,12 @@ (bw_ctx)->p += duk__enc_len; \ } while (0) /* XXX: add temporary duk__p pointer here too; sharing */ -/* XXX: avoid unsafe variants */ #define DUK_BW_WRITE_RAW_BYTES(thr,bw_ctx,valptr,valsz) do { \ const void *duk__valptr; \ duk_size_t duk__valsz; \ duk__valptr = (const void *) (valptr); \ duk__valsz = (duk_size_t) (valsz); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ (bw_ctx)->p += duk__valsz; \ } while (0) #define DUK_BW_WRITE_RAW_CSTRING(thr,bw_ctx,val) do { \ @@ -329,31 +328,31 @@ duk_size_t duk__val_len; \ duk__val = (const duk_uint8_t *) (val); \ duk__val_len = DUK_STRLEN((const char *) duk__val); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HSTRING(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HSTRING_GET_BYTELEN((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HBUFFER(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_GET_SIZE((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HBUFFER_FIXED(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_FIXED_GET_SIZE((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_RAW_HBUFFER_DYNAMIC(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_DYNAMIC_GET_SIZE((val)); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) @@ -417,14 +416,13 @@ DUK_BW_WRITE_RAW_CESU8((thr), (bw_ctx), (cp)); \ } while (0) /* XXX: add temporary duk__p pointer here too; sharing */ -/* XXX: avoid unsafe */ #define DUK_BW_WRITE_ENSURE_BYTES(thr,bw_ctx,valptr,valsz) do { \ const void *duk__valptr; \ duk_size_t duk__valsz; \ duk__valptr = (const void *) (valptr); \ duk__valsz = (duk_size_t) (valsz); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__valsz); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \ (bw_ctx)->p += duk__valsz; \ } while (0) #define DUK_BW_WRITE_ENSURE_CSTRING(thr,bw_ctx,val) do { \ @@ -433,35 +431,35 @@ duk__val = (const duk_uint8_t *) (val); \ duk__val_len = DUK_STRLEN((const char *) duk__val); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HSTRING(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HSTRING_GET_BYTELEN((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HBUFFER(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_GET_SIZE((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HBUFFER_FIXED(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_FIXED_GET_SIZE((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) #define DUK_BW_WRITE_ENSURE_HBUFFER_DYNAMIC(thr,bw_ctx,val) do { \ duk_size_t duk__val_len; \ duk__val_len = DUK_HBUFFER_DYNAMIC_GET_SIZE((val)); \ DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \ - duk_memcpy_unsafe((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ + DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \ (bw_ctx)->p += duk__val_len; \ } while (0) @@ -490,6 +488,10 @@ DUK_INTERNAL_DECL const duk_int16_t duk_hex_dectab_shift4[256]; DUK_INTERNAL_DECL const duk_uint16_t duk_hex_enctab[256]; #endif +#if defined(DUK_USE_BASE64_FASTPATH) +DUK_INTERNAL_DECL const duk_uint8_t duk_base64_enctab[64]; +DUK_INTERNAL_DECL const duk_int8_t duk_base64_dectab[256]; +#endif #endif /* !DUK_SINGLE_FILE */ /* Note: assumes that duk_util_probe_steps size is 32 */ @@ -544,127 +546,6 @@ DUK_INTERNAL_DECL void duk_byteswap_bytes(duk_uint8_t *p, duk_small_uint_t len); #endif -/* memcpy(), memmove() etc wrappers. The plain variants like duk_memcpy() - * assume C99+ and 'src' and 'dst' pointers must be non-NULL even when the - * operation size is zero. The unsafe variants like duk_memcpy_safe() deal - * with the zero size case explicitly, and allow NULL pointers in that case - * (which is undefined behavior in C99+). For the majority of actual targets - * a NULL pointer with a zero length is fine in practice. These wrappers are - * macros to force inlining; because there are hundreds of call sites, even a - * few extra bytes per call site adds up to ~1kB footprint. - */ -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) -#define duk_memcpy(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - (void) DUK_MEMCPY(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memcpy_unsafe(dst,src,len) duk_memcpy((dst), (src), (len)) -#define duk_memmove(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - (void) DUK_MEMMOVE(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memmove_unsafe(dst,src,len) duk_memmove((dst), (src), (len)) -#define duk_memset(dst,val,len) do { \ - void *duk__dst = (dst); \ - duk_small_int_t duk__val = (val); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - (void) DUK_MEMSET(duk__dst, duk__val, (size_t) duk__len); \ - } while (0) -#define duk_memset_unsafe(dst,val,len) duk_memset((dst), (val), (len)) -#define duk_memzero(dst,len) do { \ - void *duk__dst = (dst); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - (void) DUK_MEMZERO(duk__dst, (size_t) duk__len); \ - } while (0) -#define duk_memzero_unsafe(dst,len) duk_memzero((dst), (len)) -#else /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ -#define duk_memcpy(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMCPY(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memcpy_unsafe(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMCPY(duk__dst, duk__src, (size_t) duk__len); \ - } \ - } while (0) -#define duk_memmove(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMMOVE(duk__dst, duk__src, (size_t) duk__len); \ - } while (0) -#define duk_memmove_unsafe(dst,src,len) do { \ - void *duk__dst = (dst); \ - const void *duk__src = (src); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - DUK_ASSERT(duk__src != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - DUK_ASSERT(duk__src != NULL); \ - (void) DUK_MEMMOVE(duk__dst, duk__src, (size_t) duk__len); \ - } \ - } while (0) -#define duk_memset(dst,val,len) do { \ - void *duk__dst = (dst); \ - duk_small_int_t duk__val = (val); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMSET(duk__dst, duk__val, (size_t) duk__len); \ - } while (0) -#define duk_memset_unsafe(dst,val,len) do { \ - void *duk__dst = (dst); \ - duk_small_int_t duk__val = (val); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMSET(duk__dst, duk__val, (size_t) duk__len); \ - } \ - } while (0) -#define duk_memzero(dst,len) do { \ - void *duk__dst = (dst); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMZERO(duk__dst, (size_t) duk__len); \ - } while (0) -#define duk_memzero_unsafe(dst,len) do { \ - void *duk__dst = (dst); \ - duk_size_t duk__len = (len); \ - DUK_ASSERT(duk__dst != NULL || duk__len == 0U); \ - if (DUK_LIKELY(duk__len > 0U)) { \ - DUK_ASSERT(duk__dst != NULL); \ - (void) DUK_MEMZERO(duk__dst, (size_t) duk__len); \ - } \ - } while (0) -#endif /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ - -DUK_INTERNAL_DECL duk_small_int_t duk_memcmp(const void *s1, const void *s2, duk_size_t len); -DUK_INTERNAL_DECL duk_small_int_t duk_memcmp_unsafe(const void *s1, const void *s2, duk_size_t len); - DUK_INTERNAL_DECL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int32_t *ival); DUK_INTERNAL_DECL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival); DUK_INTERNAL_DECL duk_bool_t duk_double_is_anyinf(duk_double_t x); @@ -679,32 +560,5 @@ DUK_INTERNAL_DECL duk_bool_t duk_double_same_sign(duk_double_t x, duk_double_t y); DUK_INTERNAL_DECL duk_double_t duk_double_fmin(duk_double_t x, duk_double_t y); DUK_INTERNAL_DECL duk_double_t duk_double_fmax(duk_double_t x, duk_double_t y); -DUK_INTERNAL_DECL duk_bool_t duk_double_is_finite(duk_double_t x); -DUK_INTERNAL_DECL duk_bool_t duk_double_is_integer(duk_double_t x); -DUK_INTERNAL_DECL duk_bool_t duk_double_is_safe_integer(duk_double_t x); - -DUK_INTERNAL_DECL duk_double_t duk_double_div(duk_double_t x, duk_double_t y); -DUK_INTERNAL_DECL duk_int_t duk_double_to_int_t(duk_double_t x); -DUK_INTERNAL_DECL duk_uint_t duk_double_to_uint_t(duk_double_t x); -DUK_INTERNAL_DECL duk_int32_t duk_double_to_int32_t(duk_double_t x); -DUK_INTERNAL_DECL duk_uint32_t duk_double_to_uint32_t(duk_double_t x); -DUK_INTERNAL_DECL duk_float_t duk_double_to_float_t(duk_double_t x); - -/* - * Miscellaneous - */ - -/* Example: x = 0x10 = 0b00010000 - * x - 1 = 0x0f = 0b00001111 - * x & (x - 1) == 0 - * - * x = 0x07 = 0b00000111 - * x - 1 = 0x06 = 0b00000110 - * x & (x - 1) != 0 - * - * However, incorrectly true for x == 0 so check for that explicitly. - */ -#define DUK_IS_POWER_OF_TWO(x) \ - ((x) != 0U && ((x) & ((x) - 1U)) == 0U) #endif /* DUK_UTIL_H_INCLUDED */ diff -Nru duktape-2.3.0/src-separate/duk_util_memory.c duktape-2.2.0/src-separate/duk_util_memory.c --- duktape-2.3.0/src-separate/duk_util_memory.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_util_memory.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* - * Memory utils. - */ - -#include "duk_internal.h" - -#if defined(DUK_USE_ALLOW_UNDEFINED_BEHAVIOR) -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp_unsafe(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL || len == 0U); - DUK_ASSERT(s2 != NULL || len == 0U); - return DUK_MEMCMP(s1, s2, (size_t) len); -} - -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL); - DUK_ASSERT(s2 != NULL); - return DUK_MEMCMP(s1, s2, (size_t) len); -} -#else /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp_unsafe(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL || len == 0U); - DUK_ASSERT(s2 != NULL || len == 0U); - if (DUK_UNLIKELY(len == 0U)) { - return 0; - } - DUK_ASSERT(s1 != NULL); - DUK_ASSERT(s2 != NULL); - return duk_memcmp(s1, s2, len); -} - -DUK_INTERNAL DUK_INLINE duk_small_int_t duk_memcmp(const void *s1, const void *s2, duk_size_t len) { - DUK_ASSERT(s1 != NULL); - DUK_ASSERT(s2 != NULL); - return DUK_MEMCMP(s1, s2, (size_t) len); -} -#endif /* DUK_USE_ALLOW_UNDEFINED_BEHAVIOR */ diff -Nru duktape-2.3.0/src-separate/duk_util_misc.c duktape-2.2.0/src-separate/duk_util_misc.c --- duktape-2.3.0/src-separate/duk_util_misc.c 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/src-separate/duk_util_misc.c 2017-09-23 01:06:08.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Misc util stuff. + * Misc util stuff */ #include "duk_internal.h" @@ -162,6 +162,45 @@ #endif /* DUK_USE_HEX_FASTPATH */ /* + * Table for base-64 encoding + */ + +#if defined(DUK_USE_BASE64_FASTPATH) +DUK_INTERNAL const duk_uint8_t duk_base64_enctab[64] = { + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* A...P */ + 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* Q...f */ + 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* g...v */ + 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2b, 0x2f /* w.../ */ +}; +#endif /* DUK_USE_BASE64_FASTPATH */ + +/* + * Table for base-64 decoding + */ + +#if defined(DUK_USE_BASE64_FASTPATH) +DUK_INTERNAL const duk_int8_t duk_base64_dectab[256] = { + /* -1 = error, -2 = allowed whitespace, -3 = padding ('='), 0...63 decoded bytes */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -1, -1, -2, -1, -1, /* 0x00...0x0f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10...0x1f */ + -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* 0x20...0x2f */ + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -3, -1, -1, /* 0x30...0x3f */ + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40...0x4f */ + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 0x50...0x5f */ + -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60...0x6f */ + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, /* 0x70...0x7f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x80...0x8f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x90...0x9f */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xa0...0xaf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xb0...0xbf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xc0...0xcf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xd0...0xdf */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xe0...0xef */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 0xf0...0xff */ +}; +#endif /* DUK_USE_BASE64_FASTPATH */ + +/* * Arbitrary byteswap for potentially unaligned values * * Used to byteswap pointers e.g. in debugger code. @@ -181,3 +220,186 @@ } } #endif + +/* + * Miscellaneous coercion / clamping helpers. + */ + +/* Check whether a duk_double_t is a whole number in the 32-bit range (reject + * negative zero), and if so, return a duk_int32_t. + * For compiler use: don't allow negative zero as it will cause trouble with + * LDINT+LDINTX, positive zero is OK. + */ +DUK_INTERNAL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int32_t *ival) { + duk_int32_t t; + + t = (duk_int32_t) x; + if (!((duk_double_t) t == x)) { + return 0; + } + if (t == 0) { + duk_double_union du; + du.d = x; + if (DUK_DBLUNION_HAS_SIGNBIT(&du)) { + return 0; + } + } + *ival = t; + return 1; +} + +/* Check whether a duk_double_t is a whole number in the 32-bit range, and if + * so, return a duk_int32_t. + */ +DUK_INTERNAL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival) { + duk_int32_t t; + + t = (duk_int32_t) x; + if (!((duk_double_t) t == x)) { + return 0; + } + *ival = t; + return 1; +} + +/* + * IEEE double checks + */ + +DUK_INTERNAL duk_bool_t duk_double_is_anyinf(duk_double_t x) { + duk_double_union du; + du.d = x; + return DUK_DBLUNION_IS_ANYINF(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_posinf(duk_double_t x) { + duk_double_union du; + du.d = x; + return DUK_DBLUNION_IS_POSINF(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_neginf(duk_double_t x) { + duk_double_union du; + du.d = x; + return DUK_DBLUNION_IS_NEGINF(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan(duk_double_t x) { + duk_double_union du; + du.d = x; + /* Assumes we're dealing with a Duktape internal NaN which is + * NaN normalized if duk_tval requires it. + */ + DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); + return DUK_DBLUNION_IS_NAN(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan_or_zero(duk_double_t x) { + duk_double_union du; + du.d = x; + /* Assumes we're dealing with a Duktape internal NaN which is + * NaN normalized if duk_tval requires it. + */ + DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); + return DUK_DBLUNION_IS_NAN(&du) || DUK_DBLUNION_IS_ANYZERO(&du); +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan_or_inf(duk_double_t x) { + duk_double_union du; + du.d = x; + /* If exponent is 0x7FF the argument is either a NaN or an + * infinity. We don't need to check any other fields. + */ +#if defined(DUK_USE_64BIT_OPS) +#if defined(DUK_USE_DOUBLE_ME) + return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000)) == DUK_U64_CONSTANT(0x000000007ff00000); +#else + return (du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000)) == DUK_U64_CONSTANT(0x7ff0000000000000); +#endif +#else + return (du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL) == 0x7ff00000UL; +#endif +} + +DUK_INTERNAL duk_bool_t duk_double_is_nan_zero_inf(duk_double_t x) { + duk_double_union du; +#if defined(DUK_USE_64BIT_OPS) + duk_uint64_t t; +#else + duk_uint32_t t; +#endif + du.d = x; +#if defined(DUK_USE_64BIT_OPS) +#if defined(DUK_USE_DOUBLE_ME) + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x000000007ff00000); + if (t == DUK_U64_CONSTANT(0x0000000000000000)) { + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x0000000080000000); + return t == 0; + } + if (t == DUK_U64_CONSTANT(0x000000007ff00000)) { + return 1; + } +#else + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x7ff0000000000000); + if (t == DUK_U64_CONSTANT(0x0000000000000000)) { + t = du.ull[DUK_DBL_IDX_ULL0] & DUK_U64_CONSTANT(0x8000000000000000); + return t == 0; + } + if (t == DUK_U64_CONSTANT(0x7ff0000000000000)) { + return 1; + } +#endif +#else + t = du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL; + if (t == 0x00000000UL) { + return DUK_DBLUNION_IS_ANYZERO(&du); + } + if (t == 0x7ff00000UL) { + return 1; + } +#endif + return 0; +} + +DUK_INTERNAL duk_small_uint_t duk_double_signbit(duk_double_t x) { + duk_double_union du; + du.d = x; + return (duk_small_uint_t) DUK_DBLUNION_GET_SIGNBIT(&du); +} + +DUK_INTERNAL duk_double_t duk_double_trunc_towards_zero(duk_double_t x) { + /* XXX: optimize */ + duk_small_uint_t s = duk_double_signbit(x); + x = DUK_FLOOR(DUK_FABS(x)); /* truncate towards zero */ + if (s) { + x = -x; + } + return x; +} + +DUK_INTERNAL duk_bool_t duk_double_same_sign(duk_double_t x, duk_double_t y) { + duk_double_union du1; + duk_double_union du2; + du1.d = x; + du2.d = y; + + return (((du1.ui[DUK_DBL_IDX_UI0] ^ du2.ui[DUK_DBL_IDX_UI0]) & 0x80000000UL) == 0); +} + +DUK_INTERNAL duk_double_t duk_double_fmin(duk_double_t x, duk_double_t y) { + /* Doesn't replicate fmin() behavior exactly: for fmin() if one + * argument is a NaN, the other argument should be returned. + * Duktape doesn't rely on this behavior so the replacement can + * be simplified. + */ + return (x < y ? x : y); +} + +DUK_INTERNAL duk_double_t duk_double_fmax(duk_double_t x, duk_double_t y) { + /* Doesn't replicate fmax() behavior exactly: for fmax() if one + * argument is a NaN, the other argument should be returned. + * Duktape doesn't rely on this behavior so the replacement can + * be simplified. + */ + return (x > y ? x : y); +} diff -Nru duktape-2.3.0/tools/configure.py duktape-2.2.0/tools/configure.py --- duktape-2.3.0/tools/configure.py 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/tools/configure.py 2017-09-23 01:06:08.000000000 +0000 @@ -405,7 +405,6 @@ 'duk_api_inspect.c', 'duk_api_memory.c', 'duk_api_object.c', - 'duk_api_random.c', 'duk_api_string.c', 'duk_api_time.c', 'duk_api_debug.c', @@ -511,16 +510,13 @@ 'duk_unicode.h', 'duk_unicode_support.c', 'duk_unicode_tables.c', - 'duk_util.h', 'duk_util_bitdecoder.c', 'duk_util_bitencoder.c', + 'duk_util.h', 'duk_util_hashbytes.c', + 'duk_util_misc.c', 'duk_util_tinyrandom.c', 'duk_util_bufwriter.c', - 'duk_util_double.c', - 'duk_util_cast.c', - 'duk_util_memory.c', - 'duk_util_misc.c', 'duk_selftest.c', 'duk_selftest.h', 'duk_strings.h', diff -Nru duktape-2.3.0/tools/create_spdx_license.py duktape-2.2.0/tools/create_spdx_license.py --- duktape-2.3.0/tools/create_spdx_license.py 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/tools/create_spdx_license.py 2017-09-23 01:06:08.000000000 +0000 @@ -177,7 +177,7 @@ g.add((pkg_node, SPDX.licenseDeclared, mit_license)) g.add((pkg_node, SPDX.licenseComments, Literal('Duktape is copyrighted by its authors and licensed under the MIT license. MurmurHash2 is used internally, it is also under the MIT license. Duktape module loader is based on the CommonJS module loading specification (without sharing any code), CommonJS is under the MIT license.'))) g.add((pkg_node, SPDX.copyrightText, duktape_copyright)) - g.add((pkg_node, SPDX.summary, Literal('Duktape ECMAScript interpreter'))) + g.add((pkg_node, SPDX.summary, Literal('Duktape Ecmascript interpreter'))) g.add((pkg_node, SPDX.description, Literal('Duktape is an embeddable Javascript engine, with a focus on portability and compact footprint'))) # hasFile properties added separately below diff -Nru duktape-2.3.0/tools/extract_caseconv.py duktape-2.2.0/tools/extract_caseconv.py --- duktape-2.3.0/tools/extract_caseconv.py 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/tools/extract_caseconv.py 2017-09-23 01:06:08.000000000 +0000 @@ -1,20 +1,20 @@ #!/usr/bin/env python2 # # Extract rules for Unicode case conversion, specifically the behavior -# required by ECMAScript E5 in Sections 15.5.4.16 to 15.5.4.19. The +# required by Ecmascript E5 in Sections 15.5.4.16 to 15.5.4.19. The # bitstream encoded rules are used for the slow path at run time, so # compactness is favored over speed. # # There is no support for context or locale sensitive rules, as they # are handled directly in C code before consulting tables generated -# here. ECMAScript requires case conversion both with and without +# here. Ecmascript requires case conversion both with and without # locale/language specific rules (e.g. String.prototype.toLowerCase() # and String.prototype.toLocaleLowerCase()), so they are best handled # in C anyway. # # Case conversion rules for ASCII are also excluded as they are handled # by the C fast path. Rules for non-BMP characters (codepoints above -# U+FFFF) are omitted as they're not required for standard ECMAScript. +# U+FFFF) are omitted as they're not required for standard Ecmascript. # import os diff -Nru duktape-2.3.0/tools/extract_chars.py duktape-2.2.0/tools/extract_chars.py --- duktape-2.3.0/tools/extract_chars.py 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/tools/extract_chars.py 2017-09-23 01:06:08.000000000 +0000 @@ -12,7 +12,7 @@ # typically contains an ASCII fast path so ASCII characters don't need # to be considered in the Unicode tables. "NONBMP" excludes codepoints # above U+FFFF which is useful because such codepoints don't need to be -# supported in standard ECMAScript. +# supported in standard Ecmascript. # import os diff -Nru duktape-2.3.0/tools/genbuiltins.py duktape-2.2.0/tools/genbuiltins.py --- duktape-2.3.0/tools/genbuiltins.py 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/tools/genbuiltins.py 2017-09-23 01:06:08.000000000 +0000 @@ -115,7 +115,7 @@ return f(doc) -# Check if string is an "array index" in ECMAScript terms. +# Check if string is an "array index" in Ecmascript terms. def string_is_arridx(v): is_arridx = False try: @@ -874,16 +874,11 @@ if len(v) >= 1 and v[0] == '\x82': pfx = 'DUK_STRIDX_INT_' v = v[1:] - elif len(v) >= 1 and v[0] == '\x81' and v[-1] == '\xff': - pfx = 'DUK_STRIDX_WELLKNOWN_' - v = v[1:-1] else: pfx = 'DUK_STRIDX_' t = re.sub(r'([a-z0-9])([A-Z])', r'\1_\2', v) # add underscores: aB -> a_B - t = re.sub(r'\.', '_', t) # replace . with _, e.g. Symbol.iterator s['define'] = pfx + t.upper() - logger.debug('stridx define: ' + s['define']) # Add a 'stridx_used' flag for strings which need a stridx. def metadata_add_string_used_stridx(strlist, used_stridx_meta): @@ -1394,7 +1389,6 @@ LENGTH_PROPERTY_ATTRIBUTES = 'c' ACCESSOR_PROPERTY_ATTRIBUTES = 'c' DEFAULT_DATA_PROPERTY_ATTRIBUTES = 'wc' -DEFAULT_FUNC_PROPERTY_ATTRIBUTES = 'wc' # Encoding constants (must match duk_hthread_builtins.c). PROP_FLAGS_BITS = 3 @@ -1967,16 +1961,6 @@ assert(magic <= 0xffff) be.varuint(magic) - default_attrs = DEFAULT_FUNC_PROPERTY_ATTRIBUTES - attrs = funprop.get('attributes', default_attrs) - attrs = attrs.replace('a', '') # ram bitstream doesn't encode 'accessor' attribute - if attrs != default_attrs: - logger.debug('non-default attributes: %s -> %r (default %r)' % (funprop['key'], attrs, default_attrs)) - be.bits(1, 1) # flag: have custom attributes - be.bits(encode_property_flags(attrs), PROP_FLAGS_BITS) - else: - be.bits(0, 1) # flag: no custom attributes - return count_normal_props, count_function_props # Get helper maps for RAM objects. @@ -2290,7 +2274,7 @@ genc.emitLine('#endif /* DUK_USE_HSTRING_CLEN */') genc.emitLine('#else /* DUK_USE_HEAPPTR16 */') genc.emitLine('#define DUK__STRINIT(heaphdr_flags,refcount,hash32,hash16,blen,clen,next) \\') - genc.emitLine('\t{ { (heaphdr_flags), DUK__REFCINIT((refcount)), (duk_hstring *) DUK_LOSE_CONST((next)) }, (hash32), (blen), (clen) }') + genc.emitLine('\t{ { (heaphdr_flags), DUK__REFCINIT((refcount)), DUK_LOSE_CONST((next)) }, (hash32), (blen), (clen) }') genc.emitLine('#endif /* DUK_USE_HEAPPTR16 */') # Organize ROM strings into a chained ROM string table. The ROM string @@ -2341,10 +2325,7 @@ for lst in romstr_hash: for v in reversed(lst): tmp = 'DUK_INTERNAL const duk_romstr_%d %s = {' % (len(v), bi_str_map[v]) - flags = [ 'DUK_HTYPE_STRING', - 'DUK_HEAPHDR_FLAG_READONLY', - 'DUK_HEAPHDR_FLAG_REACHABLE', - 'DUK_HSTRING_FLAG_PINNED_LITERAL' ] + flags = [ 'DUK_HTYPE_STRING', 'DUK_HEAPHDR_FLAG_READONLY', 'DUK_HEAPHDR_FLAG_REACHABLE' ] is_arridx = string_is_arridx(v) blen = len(v) diff -Nru duktape-2.3.0/tools/genconfig.py duktape-2.2.0/tools/genconfig.py --- duktape-2.3.0/tools/genconfig.py 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/tools/genconfig.py 2017-09-23 01:06:08.000000000 +0000 @@ -917,16 +917,6 @@ ret.line('/* __OVERRIDE_DEFINES__ */') ret.empty() -# Add a header snippet for conditional C/C++ include files. -def add_conditional_includes_section(opts, ret): - ret.empty() - ret.line('/*') - ret.line(' * Conditional includes') - ret.line(' */') - ret.empty() - ret.snippet_relative('platform_conditionalincludes.h.in') - ret.empty() - # Development time helper: add DUK_ACTIVE which provides a runtime C string # indicating what DUK_USE_xxx config options are active at run time. This # is useful in genconfig development so that one can e.g. diff the active @@ -980,11 +970,7 @@ forced_opts = get_forced_options(opts) for doc in use_defs_list: if doc.get('warn_if_missing', False) and not forced_opts.has_key(doc['define']): - # Awkward handling for DUK_USE_CPP_EXCEPTIONS + DUK_USE_FATAL_HANDLER. - if doc['define'] == 'DUK_USE_FATAL_HANDLER' and forced_opts.has_key('DUK_USE_CPP_EXCEPTIONS'): - pass # DUK_USE_FATAL_HANDLER not critical with DUK_USE_CPP_EXCEPTIONS - else: - logger.warning('Recommended config option ' + doc['define'] + ' not provided') + logger.warning('Recommended config option ' + doc['define'] + ' not provided') # Gather a map of "active options" for genbuiltins.py. This is used to # implement proper optional built-ins, e.g. if a certain config option @@ -1307,10 +1293,6 @@ add_override_defines_section(opts, ret) - # Some headers are only included if final DUK_USE_xxx option settings - # indicate they're needed, for example C++ . - add_conditional_includes_section(opts, ret) - # Date provider snippet is after custom header and overrides, so that # the user may define e.g. DUK_USE_DATE_NOW_GETTIMEOFDAY in their # custom header. diff -Nru duktape-2.3.0/tools/scan_strings.py duktape-2.2.0/tools/scan_strings.py --- duktape-2.3.0/tools/scan_strings.py 2018-08-04 17:36:21.000000000 +0000 +++ duktape-2.2.0/tools/scan_strings.py 2017-09-23 01:06:08.000000000 +0000 @@ -1,6 +1,6 @@ #!/usr/bin/env python2 # -# Scan potential external strings from ECMAScript and C files. +# Scan potential external strings from Ecmascript and C files. # # Very simplistic example with a lot of limitations: # @@ -17,28 +17,28 @@ strmap = {} -# ECMAScript function declaration +# Ecmascript function declaration re_funcname = re.compile(r'function\s+(\w+)', re.UNICODE) -# ECMAScript variable declaration +# Ecmascript variable declaration # XXX: doesn't handle multiple variables re_vardecl = re.compile(r'var\s+(\w+)', re.UNICODE) -# ECMAScript variable assignment +# Ecmascript variable assignment re_varassign = re.compile(r'(\w+)\s*=\s*', re.UNICODE) -# ECMAScript dotted property reference (also matches numbers like +# Ecmascript dotted property reference (also matches numbers like # '4.0', which are separately rejected below) re_propref = re.compile(r'(\w+(?:\.\w+)+)', re.UNICODE) re_digits = re.compile(r'^\d+$', re.UNICODE) -# ECMAScript or C string literal +# Ecmascript or C string literal re_strlit_dquot = re.compile(r'("(?:\\"|\\\\|[^"])*")', re.UNICODE) re_strlit_squot = re.compile(r'(\'(?:\\\'|\\\\|[^\'])*\')', re.UNICODE) def strDecode(x): # Need to decode hex, unicode, and other escapes. Python syntax - # is close enough to C and ECMAScript so use eval for now. + # is close enough to C and Ecmascript so use eval for now. try: return eval('u' + x) # interpret as unicode string