From e48feaefc09e90be0282d0086929e8b778667ad4 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 27 Nov 2019 23:23:06 +0100 Subject: duktape: Import v2.5.0 --- duktape/duk_config.h | 49 +- duktape/duktape.c | 4633 ++++++++++++++++++++++++++++++++++++-------------- duktape/duktape.h | 19 +- 3 files changed, 3386 insertions(+), 1315 deletions(-) diff --git a/duktape/duk_config.h b/duktape/duk_config.h index 23b177b..130168a 100644 --- a/duktape/duk_config.h +++ b/duktape/duk_config.h @@ -1,8 +1,8 @@ /* * duk_config.h configuration header generated by genconfig.py. * - * Git commit: d4f2cff1c592d70f58bab8e1bd85705174c02a58 - * Git describe: v2.4.0 + * Git commit: 6001888049cb42656f8649db020e804bcdeca6a7 + * Git describe: v2.5.0 * Git branch: master * * Supported platforms: @@ -40,6 +40,8 @@ * - PowerPC 64-bit * - SPARC 32-bit * - SPARC 64-bit + * - RISC-V 32-bit + * - RISC-V 64-bit * - SuperH * - Motorola 68k * - Emscripten @@ -285,6 +287,22 @@ #endif #endif +/* RISC-V, https://github.com/riscv/riscv-toolchain-conventions#cc-preprocessor-definitions */ +#if defined(__riscv) +#define DUK_F_RISCV +#if defined(__riscv_xlen) +#if (__riscv_xlen == 32) +#define DUK_F_RISCV32 +#elif (__riscv_xlen == 64) +#define DUK_F_RISCV64 +#else +#error __riscv_xlen has unsupported value (not 32 or 64) +#endif +#else +#error __riscv defined without __riscv_xlen +#endif +#endif /* __riscv */ + /* SuperH */ #if defined(__sh__) || \ defined(__sh1__) || defined(__SH1__) || \ @@ -751,7 +769,7 @@ #define DUK_USE_BYTEORDER 3 #endif #else /* DUK_F_OLD_SOLARIS */ -#include +#include #endif /* DUK_F_OLD_SOLARIS */ #include @@ -963,6 +981,18 @@ /* SPARC byte order varies so rely on autodetection. */ #undef DUK_USE_PACKED_TVAL #define DUK_F_PACKED_TVAL_PROVIDED +#elif defined(DUK_F_RISCV32) +/* --- RISC-V 32-bit --- */ +#define DUK_USE_ARCH_STRING "riscv32" +#define DUK_USE_BYTEORDER 1 +#define DUK_USE_PACKED_TVAL +#define DUK_F_PACKED_TVAL_PROVIDED +#elif defined(DUK_F_RISCV64) +/* --- RISC-V 64-bit --- */ +#define DUK_USE_ARCH_STRING "riscv64" +#define DUK_USE_BYTEORDER 1 +#undef DUK_USE_PACKED_TVAL +#define DUK_F_PACKED_TVAL_PROVIDED #elif defined(DUK_F_SUPERH) /* --- SuperH --- */ #define DUK_USE_ARCH_STRING "sh" @@ -1103,7 +1133,7 @@ #define DUK_USE_FLEX_ZEROSIZE #endif -#undef DUK_USE_GCC_PRAGMAS +#define DUK_USE_CLANG_PRAGMAS #define DUK_USE_PACK_CLANG_ATTR #if defined(__clang__) && defined(__has_builtin) @@ -1243,6 +1273,7 @@ #define DUK_USE_FLEX_ZEROSIZE #endif +/* Since 4.6 one can '#pragma GCC diagnostic push/pop'. */ #if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40600) #define DUK_USE_GCC_PRAGMAS #else @@ -2648,12 +2679,15 @@ typedef struct duk_hthread duk_context; #define DUK_WO_NORETURN(stmt) do { stmt } while (0) #endif -#if !defined(DUK_UNREACHABLE) +#if defined(DUK_UNREACHABLE) +#define DUK_WO_UNREACHABLE(stmt) do { } while (0) +#else /* Don't know how to declare unreachable point, so don't do it; this * may cause some spurious compilation warnings (e.g. "variable used * uninitialized"). */ #define DUK_UNREACHABLE() do { } while (0) +#define DUK_WO_UNREACHABLE(stmt) do { stmt } while (0) #endif #if !defined(DUK_LOSE_CONST) @@ -2882,6 +2916,8 @@ typedef struct duk_hthread duk_context; #define DUK_USE_CACHE_ACTIVATION #define DUK_USE_CACHE_CATCHER #define DUK_USE_CALLSTACK_LIMIT 10000 +#define DUK_USE_CBOR_BUILTIN +#define DUK_USE_CBOR_SUPPORT #define DUK_USE_COMPILER_RECLIMIT 2500 #define DUK_USE_COROUTINE_SUPPORT #undef DUK_USE_CPP_EXCEPTIONS @@ -2945,7 +2981,7 @@ typedef struct duk_hthread duk_context; #undef DUK_USE_GC_TORTURE #undef DUK_USE_GET_MONOTONIC_TIME #undef DUK_USE_GET_RANDOM_DOUBLE -#undef DUK_USE_GLOBAL_BINDING +#define DUK_USE_GLOBAL_BINDING #define DUK_USE_GLOBAL_BUILTIN #undef DUK_USE_HEAPPTR16 #undef DUK_USE_HEAPPTR_DEC16 @@ -2953,6 +2989,7 @@ typedef struct duk_hthread duk_context; #define DUK_USE_HEX_FASTPATH #define DUK_USE_HEX_SUPPORT #define DUK_USE_HOBJECT_ARRAY_ABANDON_LIMIT 2 +#define DUK_USE_HOBJECT_ARRAY_ABANDON_MINSIZE 257 #define DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT 9 #define DUK_USE_HOBJECT_ARRAY_MINGROW_ADD 16 #define DUK_USE_HOBJECT_ARRAY_MINGROW_DIVISOR 8 diff --git a/duktape/duktape.c b/duktape/duktape.c index d57c17d..366883c 100644 --- a/duktape/duktape.c +++ b/duktape/duktape.c @@ -1,7 +1,7 @@ /* - * Single source autogenerated distributable for Duktape 2.4.0. + * Single source autogenerated distributable for Duktape 2.5.0. * - * Git commit d4f2cff1c592d70f58bab8e1bd85705174c02a58 (v2.4.0). + * Git commit 6001888049cb42656f8649db020e804bcdeca6a7 (v2.5.0). * Git branch master. * * See Duktape AUTHORS.rst and LICENSE.txt for copyright and @@ -104,6 +104,7 @@ * * James Swift (https://github.com/phraemer) * * Luis de Bethencourt (https://github.com/luisbg) * * Ian Whyman (https://github.com/v00d00) +* * Rick Sayre (https://github.com/whorfin) * * Other contributions * =================== @@ -228,13 +229,14 @@ * * A B C D E F G H Big endian (e.g. 68k) DUK_USE_DOUBLE_BE * H G F E D C B A Little endian (e.g. x86) DUK_USE_DOUBLE_LE - * D C B A H G F E Mixed/cross endian (e.g. ARM) DUK_USE_DOUBLE_ME + * D C B A H G F E Mixed endian (e.g. ARM FPA) DUK_USE_DOUBLE_ME * - * ARM is a special case: ARM double values are in mixed/cross endian - * format while ARM duk_uint64_t values are in standard little endian + * Legacy ARM (FPA) is a special case: ARM double values are in mixed + * endian format while ARM duk_uint64_t values are in standard little endian * format (H G F E D C B A). When a double is read as a duk_uint64_t * from memory, the register will contain the (logical) value * E F G H A B C D. This requires some special handling below. + * See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0056d/Bcfhgcgd.html. * * Indexes of various types (8-bit, 16-bit, 32-bit) in memory relative to * the logical (big endian) order: @@ -623,6 +625,47 @@ typedef union duk_double_union duk_double_union; #endif #endif /* DUK_DBLUNION_H_INCLUDED */ +/* #include duk_fltunion.h */ +#line 1 "duk_fltunion.h" +/* + * Union to access IEEE float memory representation. + */ + +#if !defined(DUK_FLTUNION_H_INCLUDED) +#define DUK_FLTUNION_H_INCLUDED + +/* #include duk_internal.h -> already included */ + +union duk_float_union { + float f; + duk_uint32_t ui[1]; + duk_uint16_t us[2]; + duk_uint8_t uc[4]; +}; + +typedef union duk_float_union duk_float_union; + +#if defined(DUK_USE_DOUBLE_LE) || defined(DUK_USE_DOUBLE_ME) +#define DUK_FLT_IDX_UI0 0 +#define DUK_FLT_IDX_US0 1 +#define DUK_FLT_IDX_US1 0 +#define DUK_FLT_IDX_UC0 3 +#define DUK_FLT_IDX_UC1 2 +#define DUK_FLT_IDX_UC2 1 +#define DUK_FLT_IDX_UC3 0 +#elif defined(DUK_USE_DOUBLE_BE) +#define DUK_FLT_IDX_UI0 0 +#define DUK_FLT_IDX_US0 0 +#define DUK_FLT_IDX_US1 1 +#define DUK_FLT_IDX_UC0 0 +#define DUK_FLT_IDX_UC1 1 +#define DUK_FLT_IDX_UC2 2 +#define DUK_FLT_IDX_UC3 3 +#else +#error internal error +#endif + +#endif /* DUK_FLTUNION_H_INCLUDED */ /* #include duk_replacements.h */ #line 1 "duk_replacements.h" #if !defined(DUK_REPLACEMENTS_H_INCLUDED) @@ -1519,9 +1562,9 @@ DUK_INTERNAL_DECL void duk_tval_assert_valid(duk_tval *tv); #define DUK_STRIDX_UC_FUNCTION 5 /* 'Function' */ #define DUK_HEAP_STRING_UC_FUNCTION(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_FUNCTION) #define DUK_HTHREAD_STRING_UC_FUNCTION(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_FUNCTION) -#define DUK_STRIDX_ARRAY 6 /* 'Array' */ -#define DUK_HEAP_STRING_ARRAY(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ARRAY) -#define DUK_HTHREAD_STRING_ARRAY(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ARRAY) +#define DUK_STRIDX_UC_ARRAY 6 /* 'Array' */ +#define DUK_HEAP_STRING_UC_ARRAY(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_ARRAY) +#define DUK_HTHREAD_STRING_UC_ARRAY(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_ARRAY) #define DUK_STRIDX_UC_STRING 7 /* 'String' */ #define DUK_HEAP_STRING_UC_STRING(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_STRING) #define DUK_HTHREAD_STRING_UC_STRING(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_STRING) @@ -1531,9 +1574,9 @@ DUK_INTERNAL_DECL void duk_tval_assert_valid(duk_tval *tv); #define DUK_STRIDX_UC_NUMBER 9 /* 'Number' */ #define DUK_HEAP_STRING_UC_NUMBER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_NUMBER) #define DUK_HTHREAD_STRING_UC_NUMBER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_NUMBER) -#define DUK_STRIDX_DATE 10 /* 'Date' */ -#define DUK_HEAP_STRING_DATE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DATE) -#define DUK_HTHREAD_STRING_DATE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DATE) +#define DUK_STRIDX_UC_DATE 10 /* 'Date' */ +#define DUK_HEAP_STRING_UC_DATE(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_DATE) +#define DUK_HTHREAD_STRING_UC_DATE(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_DATE) #define DUK_STRIDX_REG_EXP 11 /* 'RegExp' */ #define DUK_HEAP_STRING_REG_EXP(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_REG_EXP) #define DUK_HTHREAD_STRING_REG_EXP(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_REG_EXP) @@ -1759,260 +1802,263 @@ DUK_INTERNAL_DECL void duk_tval_assert_valid(duk_tval *tv); #define DUK_STRIDX_DATA 85 /* '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_LC_BUFFER 86 /* 'buffer' */ +#define DUK_HEAP_STRING_LC_BUFFER(heap) DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_BUFFER) +#define DUK_HTHREAD_STRING_LC_BUFFER(thr) DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_BUFFER) +#define DUK_STRIDX_LENGTH 87 /* '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 88 /* '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 89 /* '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 90 /* '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 91 /* '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 92 /* '\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 93 /* '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 94 /* '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 95 /* '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 96 /* '\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 97 /* '\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 98 /* '\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 99 /* '\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 100 /* '\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 101 /* '\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 102 /* '\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 103 /* '\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 104 /* '\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 105 /* '\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 106 /* '\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 107 /* '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 108 /* '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 109 /* '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 110 /* '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 111 /* '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 112 /* '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 113 /* '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 114 /* '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 115 /* '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 116 /* '{"_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 117 /* '{"_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 118 /* '{"_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 119 /* '{"_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 120 /* '{"_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 121 /* '{_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 122 /* '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 123 /* '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 124 /* '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 125 /* '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 126 /* '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 127 /* '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 128 /* '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 129 /* '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 130 /* '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 131 /* '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 132 /* '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 133 /* '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 134 /* '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 135 /* '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 136 /* '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 137 /* '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 138 /* '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 139 /* '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 140 /* '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 141 /* '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 142 /* '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 143 /* '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 144 /* '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 145 /* '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 146 /* '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 147 /* '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 148 /* '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 149 /* '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 150 /* '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 151 /* '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 152 /* '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 153 /* '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 154 /* '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 155 /* '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 156 /* '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 157 /* '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 158 /* '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 159 /* '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 160 /* '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 161 /* '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 162 /* '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 163 /* '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 164 /* '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 165 /* '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 166 /* '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 167 +#define DUK_STRIDX_START_RESERVED 122 +#define DUK_STRIDX_START_STRICT_RESERVED 158 +#define DUK_STRIDX_END_RESERVED 167 /* 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[972]; #endif /* !DUK_SINGLE_FILE */ #define DUK_STRDATA_MAX_STRLEN 27 -#define DUK_STRDATA_DATA_LENGTH 967 +#define DUK_STRDATA_DATA_LENGTH 972 #endif /* DUK_USE_ROM_STRINGS */ #if defined(DUK_USE_ROM_OBJECTS) @@ -2195,13 +2241,15 @@ DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_tojson(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_fill(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_copy(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_write(duk_context *ctx); +DUK_INTERNAL_DECL duk_ret_t duk_bi_cbor_encode(duk_context *ctx); +DUK_INTERNAL_DECL duk_ret_t duk_bi_cbor_decode(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_textencoder_prototype_encoding_getter(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_textencoder_prototype_encode(duk_context *ctx); DUK_INTERNAL_DECL duk_ret_t duk_bi_textdecoder_prototype_shared_getter(duk_context *ctx); 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[183]; +DUK_INTERNAL_DECL const duk_c_function duk_bi_native_functions[185]; #endif /* !DUK_SINGLE_FILE */ #define DUK_BIDX_GLOBAL 0 #define DUK_BIDX_GLOBAL_ENV 1 @@ -2256,28 +2304,28 @@ DUK_INTERNAL_DECL const duk_c_function duk_bi_native_functions[183]; #define DUK_BIDX_NODEJS_BUFFER_PROTOTYPE 50 #define DUK_NUM_BUILTINS 51 #define DUK_NUM_BIDX_BUILTINS 51 -#define DUK_NUM_ALL_BUILTINS 79 +#define DUK_NUM_ALL_BUILTINS 80 #if defined(DUK_USE_DOUBLE_LE) #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4251]; +DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4281]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_BUILTINS_DATA_LENGTH 4251 +#define DUK_BUILTINS_DATA_LENGTH 4281 #elif defined(DUK_USE_DOUBLE_BE) #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4251]; +DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4281]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_BUILTINS_DATA_LENGTH 4251 +#define DUK_BUILTINS_DATA_LENGTH 4281 #elif defined(DUK_USE_DOUBLE_ME) #if !defined(DUK_SINGLE_FILE) -DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4251]; +DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[4281]; #endif /* !DUK_SINGLE_FILE */ -#define DUK_BUILTINS_DATA_LENGTH 4251 +#define DUK_BUILTINS_DATA_LENGTH 4281 #else #error invalid endianness defines #endif #endif /* DUK_USE_ROM_OBJECTS */ #endif /* DUK_BUILTINS_H_INCLUDED */ -#line 44 "duk_internal.h" +#line 45 "duk_internal.h" /* #include duk_util.h */ #line 1 "duk_util.h" @@ -2350,40 +2398,49 @@ struct duk_bitencoder_ctx { /* * Raw write/read macros for big endian, unaligned basic values. - * Caller ensures there's enough space. The macros update the pointer - * argument automatically on resizes. The idiom seems a bit odd, but - * leads to compact code. + * Caller ensures there's enough space. The INC macro variants + * update the pointer argument automatically. */ #define DUK_RAW_WRITE_U8(ptr,val) do { \ - *(ptr)++ = (duk_uint8_t) (val); \ + *(ptr) = (duk_uint8_t) (val); \ } while (0) -#define DUK_RAW_WRITE_U16_BE(ptr,val) duk_raw_write_u16_be(&(ptr), (duk_uint16_t) (val)) -#define DUK_RAW_WRITE_U32_BE(ptr,val) duk_raw_write_u32_be(&(ptr), (duk_uint32_t) (val)) -#define DUK_RAW_WRITE_DOUBLE_BE(ptr,val) duk_raw_write_double_be(&(ptr), (duk_double_t) (val)) -#define DUK_RAW_WRITE_XUTF8(ptr,val) do { \ - /* 'ptr' is evaluated both as LHS and RHS. */ \ - duk_uint8_t *duk__ptr; \ - duk_small_int_t duk__len; \ - duk__ptr = (duk_uint8_t *) (ptr); \ - duk__len = duk_unicode_encode_xutf8((duk_ucodepoint_t) (val), duk__ptr); \ - duk__ptr += duk__len; \ - (ptr) = duk__ptr; \ - } while (0) -#define DUK_RAW_WRITE_CESU8(ptr,val) do { \ - /* 'ptr' is evaluated both as LHS and RHS. */ \ - duk_uint8_t *duk__ptr; \ - duk_small_int_t duk__len; \ - duk__ptr = (duk_uint8_t *) (ptr); \ - duk__len = duk_unicode_encode_cesu8((duk_ucodepoint_t) (val), duk__ptr); \ - duk__ptr += duk__len; \ - (ptr) = duk__ptr; \ +#define DUK_RAW_WRITE_U16_BE(ptr,val) duk_raw_write_u16_be((ptr), (duk_uint16_t) (val)) +#define DUK_RAW_WRITE_U32_BE(ptr,val) duk_raw_write_u32_be((ptr), (duk_uint32_t) (val)) +#define DUK_RAW_WRITE_FLOAT_BE(ptr,val) duk_raw_write_float_be((ptr), (duk_float_t) (val)) +#define DUK_RAW_WRITE_DOUBLE_BE(ptr,val) duk_raw_write_double_be((ptr), (duk_double_t) (val)) +#define DUK_RAW_WRITE_XUTF8(ptr,val) duk_raw_write_xutf8((ptr), (duk_ucodepoint_t) (val)) + +#define DUK_RAW_WRITEINC_U8(ptr,val) do { \ + *(ptr)++ = (duk_uint8_t) (val); \ } while (0) +#define DUK_RAW_WRITEINC_U16_BE(ptr,val) duk_raw_writeinc_u16_be(&(ptr), (duk_uint16_t) (val)) +#define DUK_RAW_WRITEINC_U32_BE(ptr,val) duk_raw_writeinc_u32_be(&(ptr), (duk_uint32_t) (val)) +#define DUK_RAW_WRITEINC_FLOAT_BE(ptr,val) duk_raw_writeinc_float_be(&(ptr), (duk_float_t) (val)) +#define DUK_RAW_WRITEINC_DOUBLE_BE(ptr,val) duk_raw_writeinc_double_be(&(ptr), (duk_double_t) (val)) +#define DUK_RAW_WRITEINC_XUTF8(ptr,val) duk_raw_writeinc_xutf8(&(ptr), (duk_ucodepoint_t) (val)) +#define DUK_RAW_WRITEINC_CESU8(ptr,val) duk_raw_writeinc_cesu8(&(ptr), (duk_ucodepoint_t) (val)) + +#define DUK_RAW_READ_U8(ptr) ((duk_uint8_t) (*(ptr))) +#define DUK_RAW_READ_U16_BE(ptr) duk_raw_read_u16_be((ptr)); +#define DUK_RAW_READ_U32_BE(ptr) duk_raw_read_u32_be((ptr)); +#define DUK_RAW_READ_DOUBLE_BE(ptr) duk_raw_read_double_be((ptr)); + +#define DUK_RAW_READINC_U8(ptr) ((duk_uint8_t) (*(ptr)++)) +#define DUK_RAW_READINC_U16_BE(ptr) duk_raw_readinc_u16_be(&(ptr)); +#define DUK_RAW_READINC_U32_BE(ptr) duk_raw_readinc_u32_be(&(ptr)); +#define DUK_RAW_READINC_DOUBLE_BE(ptr) duk_raw_readinc_double_be(&(ptr)); + +/* + * Double and float byte order operations. + */ -#define DUK_RAW_READ_U8(ptr) ((duk_uint8_t) (*(ptr)++)) -#define DUK_RAW_READ_U16_BE(ptr) duk_raw_read_u16_be(&(ptr)); -#define DUK_RAW_READ_U32_BE(ptr) duk_raw_read_u32_be(&(ptr)); -#define DUK_RAW_READ_DOUBLE_BE(ptr) duk_raw_read_double_be(&(ptr)); +DUK_INTERNAL_DECL void duk_dblunion_host_to_little(duk_double_union *u); +DUK_INTERNAL_DECL void duk_dblunion_little_to_host(duk_double_union *u); +DUK_INTERNAL_DECL void duk_dblunion_host_to_big(duk_double_union *u); +DUK_INTERNAL_DECL void duk_dblunion_big_to_host(duk_double_union *u); +DUK_INTERNAL_DECL void duk_fltunion_host_to_big(duk_float_union *u); +DUK_INTERNAL_DECL void duk_fltunion_big_to_host(duk_float_union *u); /* * Buffer writer (dynamic buffer only) @@ -2812,12 +2869,26 @@ DUK_INTERNAL_DECL duk_uint8_t *duk_bw_insert_ensure_area(duk_hthread *thr, duk_b DUK_INTERNAL_DECL void duk_bw_remove_raw_slice(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t off, duk_size_t len); /* No duk_bw_remove_ensure_slice(), functionality would be identical. */ -DUK_INTERNAL_DECL duk_uint16_t duk_raw_read_u16_be(duk_uint8_t **p); -DUK_INTERNAL_DECL duk_uint32_t duk_raw_read_u32_be(duk_uint8_t **p); -DUK_INTERNAL_DECL duk_double_t duk_raw_read_double_be(duk_uint8_t **p); -DUK_INTERNAL_DECL void duk_raw_write_u16_be(duk_uint8_t **p, duk_uint16_t val); -DUK_INTERNAL_DECL void duk_raw_write_u32_be(duk_uint8_t **p, duk_uint32_t val); -DUK_INTERNAL_DECL void duk_raw_write_double_be(duk_uint8_t **p, duk_double_t val); +DUK_INTERNAL_DECL duk_uint16_t duk_raw_read_u16_be(const duk_uint8_t *p); +DUK_INTERNAL_DECL duk_uint32_t duk_raw_read_u32_be(const duk_uint8_t *p); +DUK_INTERNAL_DECL duk_float_t duk_raw_read_float_be(const duk_uint8_t *p); +DUK_INTERNAL_DECL duk_double_t duk_raw_read_double_be(const duk_uint8_t *p); +DUK_INTERNAL_DECL duk_uint16_t duk_raw_readinc_u16_be(const duk_uint8_t **p); +DUK_INTERNAL_DECL duk_uint32_t duk_raw_readinc_u32_be(const duk_uint8_t **p); +DUK_INTERNAL_DECL duk_float_t duk_raw_readinc_float_be(const duk_uint8_t **p); +DUK_INTERNAL_DECL duk_double_t duk_raw_readinc_double_be(const duk_uint8_t **p); +DUK_INTERNAL_DECL void duk_raw_write_u16_be(duk_uint8_t *p, duk_uint16_t val); +DUK_INTERNAL_DECL void duk_raw_write_u32_be(duk_uint8_t *p, duk_uint32_t val); +DUK_INTERNAL_DECL void duk_raw_write_float_be(duk_uint8_t *p, duk_float_t val); +DUK_INTERNAL_DECL void duk_raw_write_double_be(duk_uint8_t *p, duk_double_t val); +DUK_INTERNAL_DECL duk_small_int_t duk_raw_write_xutf8(duk_uint8_t *p, duk_ucodepoint_t val); +DUK_INTERNAL_DECL duk_small_int_t duk_raw_write_cesu8(duk_uint8_t *p, duk_ucodepoint_t val); +DUK_INTERNAL_DECL void duk_raw_writeinc_u16_be(duk_uint8_t **p, duk_uint16_t val); +DUK_INTERNAL_DECL void duk_raw_writeinc_u32_be(duk_uint8_t **p, duk_uint32_t val); +DUK_INTERNAL_DECL void duk_raw_writeinc_float_be(duk_uint8_t **p, duk_float_t val); +DUK_INTERNAL_DECL void duk_raw_writeinc_double_be(duk_uint8_t **p, duk_double_t val); +DUK_INTERNAL_DECL void duk_raw_writeinc_xutf8(duk_uint8_t **p, duk_ucodepoint_t val); +DUK_INTERNAL_DECL void duk_raw_writeinc_cesu8(duk_uint8_t **p, duk_ucodepoint_t val); #if defined(DUK_USE_DEBUGGER_SUPPORT) /* For now only needed by the debugger. */ DUK_INTERNAL_DECL void duk_byteswap_bytes(duk_uint8_t *p, duk_small_uint_t len); @@ -2968,6 +3039,8 @@ 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); +DUK_INTERNAL_DECL duk_bool_t duk_double_equals(duk_double_t x, duk_double_t y); +DUK_INTERNAL_DECL duk_bool_t duk_float_equals(duk_float_t x, duk_float_t y); /* * Miscellaneous @@ -5431,6 +5504,28 @@ DUK_INTERNAL_DECL void duk_heaphdr_decref_norz(duk_hthread *thr, duk_heaphdr *h) #if !defined(DUK_API_INTERNAL_H_INCLUDED) #define DUK_API_INTERNAL_H_INCLUDED +/* Inline macro helpers. */ +#if defined(DUK_USE_PREFER_SIZE) +#define DUK_INLINE_PERF +#define DUK_ALWAYS_INLINE_PERF +#define DUK_NOINLINE_PERF +#else +#define DUK_INLINE_PERF DUK_INLINE +#define DUK_ALWAYS_INLINE_PERF DUK_ALWAYS_INLINE +#define DUK_NOINLINE_PERF DUK_NOINLINE +#endif + +/* Inline macro helpers, for bytecode executor. */ +#if defined(DUK_USE_EXEC_PREFER_SIZE) +#define DUK_EXEC_INLINE_PERF +#define DUK_EXEC_ALWAYS_INLINE_PERF +#define DUK_EXEC_NOINLINE_PERF +#else +#define DUK_EXEC_INLINE_PERF DUK_INLINE +#define DUK_EXEC_ALWAYS_INLINE_PERF DUK_ALWAYS_INLINE +#define DUK_EXEC_NOINLINE_PERF DUK_NOINLINE +#endif + /* duk_push_sprintf constants */ #define DUK_PUSH_SPRINTF_INITIAL_SIZE 256L #define DUK_PUSH_SPRINTF_SANITY_LIMIT (1L * 1024L * 1024L * 1024L) @@ -8454,20 +8549,17 @@ struct duk_hproxy { */ #define DUK_MS_FLAG_EMERGENCY (1U << 0) -/* Voluntary mark-and-sweep: triggered periodically. */ -#define DUK_MS_FLAG_VOLUNTARY (1U << 1) - /* Postpone rescue decisions for reachable objects with FINALIZED set. * Used during finalize_list processing to avoid incorrect rescue * decisions due to finalize_list being a reachability root. */ -#define DUK_MS_FLAG_POSTPONE_RESCUE (1U << 2) +#define DUK_MS_FLAG_POSTPONE_RESCUE (1U << 1) /* Don't compact objects; needed during object property table resize * to prevent a recursive resize. It would suffice to protect only the * current object being resized, but this is not yet implemented. */ -#define DUK_MS_FLAG_NO_OBJECT_COMPACTION (1U << 3) +#define DUK_MS_FLAG_NO_OBJECT_COMPACTION (1U << 2) /* * Thread switching @@ -10255,6 +10347,7 @@ DUK_INTERNAL_DECL duk_small_int_t duk_unicode_encode_cesu8(duk_ucodepoint_t cp, DUK_INTERNAL_DECL duk_small_int_t duk_unicode_decode_xutf8(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_ucodepoint_t *out_cp); DUK_INTERNAL_DECL duk_ucodepoint_t duk_unicode_decode_xutf8_checked(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end); DUK_INTERNAL_DECL duk_size_t duk_unicode_unvalidated_utf8_length(const duk_uint8_t *data, duk_size_t blen); +DUK_INTERNAL_DECL duk_bool_t duk_unicode_is_utf8_compatible(const duk_uint8_t *buf, duk_size_t len); DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_whitespace(duk_codepoint_t cp); DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_line_terminator(duk_codepoint_t cp); DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_identifier_start(duk_codepoint_t cp); @@ -10389,6 +10482,8 @@ DUK_INTERNAL_DECL duk_bool_t duk_js_instanceof_ordinary(duk_hthread *thr, duk_tv #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); +DUK_INTERNAL_DECL duk_bool_t duk_js_isarray_hobject(duk_hobject *h); +DUK_INTERNAL_DECL duk_bool_t duk_js_isarray(duk_tval *tv); /* arithmetic */ DUK_INTERNAL_DECL double duk_js_arith_pow(double x, double y); @@ -10659,7 +10754,7 @@ DUK_INTERNAL_DECL duk_uint_t duk_selftest_run_tests(duk_alloc_function alloc_fun #endif #endif /* DUK_SELFTEST_H_INCLUDED */ -#line 75 "duk_internal.h" +#line 76 "duk_internal.h" #endif /* DUK_INTERNAL_H_INCLUDED */ #line 10 "duk_replacements.c" @@ -10844,7 +10939,7 @@ DUK_INTERNAL void duk_debug_log(const char *fmt, ...) { #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[972] = { 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, @@ -10872,34 +10967,34 @@ DUK_INTERNAL const duk_uint8_t duk_strings_data[967] = { 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, +242,16,96,152,12,26,20,164,137,150,70,154,103,28,137,50,202,96,18,132,241, +41,104,105,56,218,48,36,138,183,57,56,128,68,24,38,2,52,12,34,10,133,147, +141,3,8,119,185,13,153,34,125,206,76,17,49,38,93,206,52,151,154,119,56,28, +76,130,112,200,141,206,21,209,96,23,35,238,114,160,139,0,243,238,114,78, +164,68,68,110,113,226,210,90,26,66,110,113,128,121,247,57,80,68,141,170, +183,56,84,52,11,70,73,19,110,114,160,93,8,113,57,143,66,200,84,53,244,154, +73,24,240,81,32,38,68,18,49,228,207,23,88,100,109,70,114,92,193,4,137,173, +168,36,220,73,19,247,247,182,168,209,144,187,223,58,156,104,79,190,183,127, +123,105,160,110,247,206,167,26,19,239,173,223,222,218,67,75,189,243,169, +198,132,251,235,183,247,182,154,134,151,123,231,83,141,9,247,215,111,239, +109,22,141,22,247,206,167,26,19,239,172,223,218,45,26,47,157,78,52,39,223, +74,24,144,10,32,129,34,20,64,152,142,129,57,179,67,104,68,12,129,161,140, +72,156,100,40,40,185,152,100,89,38,65,13,196,34,228,67,149,13,2,215,129, +149,209,65,104,209,77,14,104,144,81,33,170,67,101,48,52,68,113,70,210,88, +209,36,233,22,154,86,68,196,114,76,232,145,102,120,186,195,156,112,105,225, +228,113,71,80,68,162,115,101,50,85,200,25,108,116,44,132,178,38,114,137,96, +148,136,70,209,134,37,222,232,204,228,188,200,209,200,200,99,221,25,150,84, +121,34,70,209,107,36,227,66,20,160,92,136,164,49,235,35,8,217,201,40,108, +201,18,128,68,26,201,51,188,2,80,12,67,190,40,168,38,68,190,46,153,5,50,12, +207,160,86,129,26,83,4,208,34,225,4,88,192, }; #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: 183 */ -DUK_INTERNAL const duk_c_function duk_bi_native_functions[183] = { +/* native functions: 185 */ +DUK_INTERNAL const duk_c_function duk_bi_native_functions[185] = { NULL, duk_bi_array_constructor, duk_bi_array_constructor_is_array, @@ -10925,6 +11020,8 @@ DUK_INTERNAL const duk_c_function duk_bi_native_functions[183] = { duk_bi_buffer_readfield, duk_bi_buffer_slice_shared, duk_bi_buffer_writefield, + duk_bi_cbor_decode, + duk_bi_cbor_encode, duk_bi_dataview_constructor, duk_bi_date_constructor, duk_bi_date_constructor_now, @@ -11085,598 +11182,604 @@ DUK_INTERNAL const duk_c_function duk_bi_native_functions[183] = { duk_bi_uint8array_plainof, }; #if defined(DUK_USE_DOUBLE_LE) -DUK_INTERNAL const duk_uint8_t duk_builtins_data[4251] = { -144,148,105,225,32,68,52,228,126,12,104,201,37,132,52,167,194,138,105,244, -124,57,28,211,57,18,64,52,238,254,44,138,111,171,241,164,19,87,137,30,33, -167,18,145,159,8,211,137,9,225,42,5,240,145,139,163,163,8,211,137,10,228, -64,211,19,132,140,93,29,56,70,156,72,119,34,66,146,36,104,137,194,70,46, -142,172,35,78,36,47,146,195,102,11,240,145,139,163,175,8,211,137,9,228,240, -242,112,145,139,163,179,8,211,137,8,237,34,130,118,49,116,118,225,26,48,0, -1,94,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, -33,8,66,26,180,41,97,167,64,150,34,33,154,112,0,1,87,247,35,79,103,237,198, -174,216,47,31,23,95,17,13,31,217,96,211,49,50,53,212,77,141,24,0,0,179,10, -228,240,242,15,128,140,65,128,134,188,0,0,89,167,97,181,224,0,2,205,62,53, -224,0,2,205,66,237,120,0,0,179,81,204,107,192,0,5,154,150,67,94,0,0,44,212, -245,90,240,0,1,102,169,162,215,128,0,11,53,93,150,188,0,0,89,171,111,53, -108,150,163,70,0,0,42,2,249,50,94,124,35,68,225,146,49,13,24,0,0,165,161, -124,153,47,62,12,130,112,201,24,132,56,97,115,16,0,0,0,0,0,0,62,31,243,48, -0,0,0,0,0,0,60,31,242,241,32,26,193,55,132,112,161,156,72,135,26,41,200, -140,114,163,156,201,7,56,79,9,80,47,132,140,93,19,160,43,145,3,76,78,18,49, -116,78,144,238,68,133,36,72,209,19,132,140,93,19,168,47,146,195,102,11,240, -145,139,162,117,132,242,120,121,56,72,197,209,59,2,59,72,160,157,140,93,19, -181,36,242,50,143,36,31,131,162,166,7,144,238,133,227,226,235,224,242,161, -249,18,21,100,20,207,44,199,151,180,122,89,135,152,154,121,153,199,156,158, -121,218,7,158,162,121,250,71,160,166,122,26,135,162,170,122,58,199,164,16, -240,70,68,226,27,51,199,138,120,35,34,112,171,112,38,121,1,124,153,47,62, -17,162,112,201,19,211,11,228,201,121,240,100,19,134,72,158,160,91,201,18, -186,44,3,68,79,122,168,151,115,165,40,21,18,227,65,198,231,200,8,68,184,84, -53,19,38,120,128,145,144,78,25,59,72,163,48,64,144,200,39,12,157,164,80,46, -185,143,115,72,217,230,72,9,35,68,225,147,180,138,51,68,9,17,162,112,201, -218,69,2,235,152,247,52,141,158,108,128,98,72,64,121,51,132,4,81,164,144, -128,242,104,136,0,16,92,38,14,49,39,199,197,211,116,240,242,113,197,231,18, -53,189,116,65,131,18,124,117,155,199,197,207,36,103,142,12,146,20,80,249, -186,60,116,4,204,73,241,214,111,31,23,60,145,158,56,208,48,146,229,146,3,2, -82,65,155,195,94,3,10,36,4,201,196,64,56,100,42,26,78,62,46,121,35,60,113, -152,16,25,10,134,147,143,139,158,72,205,4,151,21,0,73,16,11,230,144,12,88, -144,153,39,52,144,69,241,37,72,217,240,151,153,27,36,57,178,230,16,16,137, -114,68,2,200,62,81,1,8,151,11,23,100,141,229,18,6,34,92,37,230,70,201,1,89, -57,36,2,40,152,151,44,129,83,18,124,117,155,199,197,207,36,103,142,75,12, -11,151,46,89,40,18,37,200,64,12,154,236,252,238,185,23,95,213,1,132,234,0, -194,245,128,14,56,37,199,89,188,124,92,242,70,120,232,16,26,137,113,241, -116,221,60,60,156,113,122,36,10,62,46,121,35,60,113,18,225,27,70,18,32,10, -201,211,32,67,107,104,100,42,26,78,24,147,153,35,181,181,207,64,67,107,104, -100,42,26,78,72,147,153,35,181,181,207,68,16,218,218,91,156,170,63,134,36, -230,72,237,109,116,136,16,218,218,91,156,170,63,146,36,230,72,237,109,116, -137,16,96,128,228,2,6,191,46,3,71,147,68,4,16,22,188,169,240,16,40,104,242, -135,198,171,44,68,65,5,217,231,215,6,231,62,188,8,49,1,3,162,92,4,98,12,41, -7,33,148,53,242,128,97,32,130,3,9,205,16,38,199,198,14,9,0,111,115,225,0,8, -250,72,240,207,128,241,37,73,25,18,40,0,178,58,11,56,192,2,201,104,17,35, -160,9,39,70,114,8,6,147,214,129,18,74,240,30,141,145,208,89,203,62,3,161, -163,37,248,226,185,244,11,88,37,62,33,163,37,248,226,185,252,0,127,255,130, -146,164,142,32,26,1,36,230,18,1,164,7,43,163,194,0,71,128,105,64,216,7,192, -52,192,197,66,230,72,192,52,224,209,32,232,34,68,62,129,113,32,232,34,114, -40,49,231,16,254,0,63,255,208,99,2,140,44,92,206,8,224,143,4,225,147,210, -124,13,44,92,206,9,195,39,30,228,54,126,163,225,200,169,198,133,42,166,191, -246,3,11,251,0,24,71,4,120,9,251,8,10,17,193,30,9,195,39,1,63,105,1,98,112, -201,199,185,13,159,1,63,105,32,48,156,209,2,126,227,224,58,26,50,95,142,47, -192,208,22,176,74,124,67,70,75,241,197,248,26,64,213,184,64,89,56,39,49, -224,137,62,36,2,176,19,17,254,68,3,196,143,88,4,79,162,0,210,32,34,35,253, -72,5,146,208,34,125,144,5,147,214,137,253,208,9,149,3,41,197,13,55,233,0, -185,187,139,117,137,30,8,18,39,172,1,25,187,139,112,128,178,113,110,177,35, -193,2,68,245,128,23,55,114,143,121,35,193,2,68,245,130,8,205,220,91,132,5, -147,148,123,201,30,8,18,39,172,16,18,113,67,63,128,3,68,143,32,39,243,32, -42,83,4,103,46,89,19,63,224,208,16,70,142,92,178,38,127,193,164,8,67,68, -186,12,146,247,154,1,165,64,202,113,252,160,131,32,7,35,167,26,50,235,231, -130,48,179,192,65,148,69,19,214,2,251,85,2,232,72,31,255,255,255,255,255, -253,239,226,122,196,55,106,160,93,9,0,4,0,0,0,0,0,0,3,49,0,0,0,0,0,0,3,225, -252,143,94,233,34,104,169,54,144,210,161,168,158,32,0,0,0,0,0,0,120,63,145, -235,72,96,77,21,38,210,26,84,53,19,196,0,0,0,0,0,0,15,15,240,253,35,228, -133,185,176,0,0,0,0,0,0,44,15,8,117,128,190,212,128,82,109,33,179,33,137, -24,31,255,255,255,255,255,231,232,100,58,196,55,106,64,41,54,144,217,144, -196,140,15,255,255,255,255,255,243,252,49,15,4,100,78,33,179,60,120,167, -130,50,39,10,183,2,103,144,113,8,151,10,134,162,100,221,16,18,137,113,13, -153,12,72,238,137,1,81,46,52,28,110,232,148,53,18,228,128,82,113,13,153,12, -72,238,137,142,73,78,52,0,0,0,0,0,0,0,0,8,58,254,1,12,38,248,134,23,130,0, -60,221,194,162,228,30,244,128,217,187,132,187,220,210,54,104,2,247,132,5, -205,220,124,72,36,73,14,110,252,132,25,128,193,94,8,200,149,200,3,237,38, -43,31,192,54,186,213,128,57,45,56,210,0,0,0,0,0,0,62,31,241,90,251,224,6, -77,220,24,38,78,74,113,67,77,124,16,50,110,228,208,194,114,83,138,26,107, -224,172,37,240,97,41,187,139,112,128,178,112,96,153,57,41,197,13,53,240, -113,41,187,139,112,128,178,114,104,97,57,41,197,13,53,240,128,195,95,8,44, -61,240,132,216,93,33,133,192,128,14,98,79,147,67,9,129,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,181,55,136, -200,51,128,114,108,28,100,128,0,0,0,0,0,0,0,12,110,127,32,98,115,249,73, -117,243,249,67,21,159,202,38,47,63,148,86,8,75,144,94,50,1,38,73,79,204,67, -95,231,1,6,128,14,79,129,185,40,249,18,149,181,207,142,199,155,172,248,172, -89,183,207,140,198,137,175,200,0,159,72,10,5,21,220,138,120,74,129,124,36, -98,232,228,74,81,62,160,20,10,107,185,21,114,32,105,137,194,70,46,142,68, -165,19,235,1,64,170,187,145,119,34,66,146,36,104,137,194,70,46,142,68,165, -19,236,1,64,174,187,145,95,37,134,204,23,225,35,23,71,34,82,137,246,128, -160,89,93,200,167,147,195,201,194,70,46,142,68,165,19,238,1,64,182,187,145, -71,105,20,19,177,139,163,145,41,68,16,7,6,15,82,70,72,115,96,0,0,0,0,0,118, -105,160,91,60,165,195,201,194,8,134,149,216,130,0,192,41,224,136,2,48,176, -228,1,149,13,195,15,0,200,209,97,71,128,99,32,176,131,192,113,57,143,0,167, -131,32,230,80,28,202,139,175,237,2,48,189,160,20,1,119,48,87,193,186,129, -89,56,72,197,209,200,193,185,35,23,71,109,13,219,36,98,232,237,156,13,26, -208,211,14,102,19,87,137,91,95,128,0,10,64,24,92,0,0,82,2,53,63,240,49,204, -202,10,14,38,78,44,141,52,207,31,0,0,22,32,129,100,180,8,148,145,78,102, -152,80,113,50,113,100,105,166,120,248,0,0,177,1,65,196,201,199,20,178,36, -227,224,0,2,200,3,6,133,41,35,31,0,0,22,1,44,57,137,62,33,179,216,162,152, -192,131,18,124,162,27,61,138,41,108,32,196,159,16,217,232,235,81,76,104,73, -137,62,81,13,158,142,181,20,184,16,98,79,136,108,244,244,168,166,56,36,196, -159,40,134,207,79,74,138,93,10,49,39,194,173,192,158,158,149,20,188,20,98, -79,133,91,129,61,109,74,41,124,30,68,159,16,217,236,83,108,96,68,137,62,81, -13,158,197,54,182,17,34,79,136,108,244,117,169,182,52,38,68,159,40,134,207, -71,90,155,92,8,145,39,196,54,122,122,84,219,28,19,34,79,148,67,103,167,165, -77,174,133,72,147,225,86,224,79,79,74,155,94,10,145,39,194,173,192,158,182, -165,54,190,206,25,212,35,208,226,100,150,211,201,29,162,44,140,35,103,0,0, -0,0,0,0,3,192,252,206,25,228,35,208,226,100,150,211,201,29,162,44,140,35, -103,0,0,0,0,0,0,3,192,252,206,25,244,35,208,226,100,150,211,201,29,162,44, -140,35,103,0,0,0,0,0,0,3,192,252,206,26,4,35,208,226,100,150,211,201,29, -162,44,140,35,103,0,0,0,0,0,0,0,1,0,206,26,20,35,208,226,100,150,211,201, -29,162,44,140,35,103,0,0,0,0,0,0,0,1,0,206,26,36,35,208,226,100,150,211, -201,29,162,44,140,35,103,0,0,0,0,0,0,0,65,0,206,26,52,35,208,226,100,150, -211,201,29,162,44,140,35,103,0,0,0,0,0,0,0,65,0,206,26,68,35,208,226,100, -150,211,201,29,162,44,140,35,103,0,0,0,0,0,0,0,65,0,206,26,84,35,208,226, -100,150,211,201,29,162,44,140,35,103,0,0,0,0,0,0,0,129,0,195,154,99,16,38, -36,0,251,68,117,179,216,162,128,68,72,1,241,13,158,197,20,150,25,18,0,125, -162,58,217,232,235,117,100,162,136,25,18,0,125,162,58,217,232,235,116,36, -162,145,2,226,64,15,136,108,244,117,186,178,81,73,129,113,32,7,196,54,122, -58,221,9,40,165,64,200,144,3,237,17,214,207,79,75,171,37,20,80,200,144,3, -237,17,214,207,79,75,161,37,20,138,23,18,0,124,67,103,167,165,213,146,138, -77,11,137,0,62,33,179,211,210,232,73,69,42,133,196,128,31,10,183,2,125,89, -40,163,5,196,128,31,10,183,2,125,9,40,164,96,200,144,3,224,221,64,172,157, -89,40,163,134,68,128,31,6,234,5,100,232,73,69,35,133,68,128,31,104,142,182, -125,89,40,180,0,168,144,3,237,17,214,207,161,37,22,144,19,18,0,124,67,103, -213,146,139,80,9,137,0,62,33,179,232,73,69,172,5,90,40,153,59,68,117,179, -216,166,192,77,162,137,147,136,108,246,41,180,176,219,69,19,39,104,142,182, -122,58,221,89,41,178,6,218,40,153,59,68,117,179,209,214,232,73,77,162,6,90, -40,153,56,134,207,71,91,171,37,54,152,25,104,162,100,226,27,61,29,110,132, -148,218,160,109,162,137,147,180,71,91,61,61,46,172,148,217,67,109,20,76, -157,162,58,217,233,233,116,36,166,209,67,45,20,76,156,67,103,167,165,213, -146,155,77,12,180,81,50,113,13,158,158,151,66,74,109,84,50,209,68,201,194, -173,192,159,86,74,108,193,150,138,38,78,21,110,4,250,18,83,104,193,182,138, -38,78,13,212,10,201,213,146,155,56,109,162,137,147,131,117,2,178,116,36, -166,209,194,237,20,76,157,162,58,217,245,100,167,16,2,237,20,76,157,162,58, -217,244,36,167,18,2,173,20,76,156,67,103,213,146,156,80,10,180,81,50,113, -13,159,66,74,113,97,175,220,48,216,109,192,4,42,22,189,163,0,196,133,0,185, -80,32,28,78,99,193,18,80,36,4,19,159,141,156,0,178,90,4,74,73,0,22,209,68, -201,185,129,4,2,8,3,132,64,60,36,6,149,113,72,176,171,240,84,0,157,91,116, -116,32,11,42,218,221,216,181,129,32,3,234,219,165,3,188,231,235,249,8,187, -152,252,47,86,227,105,18,7,244,17,91,42,56,175,185,248,110,173,198,209,208, -36,0,238,82,97,87,188,189,179,240,93,122,32,12,22,162,42,125,144,132,160,7, -236,161,25,232,237,105,64,205,59,127,102,158,160,230,63,11,217,66,51,210, -129,154,118,254,205,61,65,236,127,171,197,34,168,48,6,90,162,1,0,39,75,84, -72,8,9,33,186,162,80,64,76,13,213,19,2,130,96,110,150,181,0,65,6,51,213,20, -128,65,17,11,213,19,130,137,121,211,210,210,144,6,39,75,84,80,0,201,119, -234,138,8,41,86,231,71,84,80,129,79,135,186,122,101,224,34,25,69,233,208,3, -91,141,170,40,96,139,113,180,181,69,36,21,110,54,142,134,168,165,1,176,23, -212,47,0,216,134,234,87,128,111,117,181,168,128,209,3,70,230,106,192,5,139, -168,209,234,138,32,36,144,102,235,8,3,146,27,170,40,160,146,132,103,170,40, -192,115,3,117,69,28,22,113,163,69,170,41,103,1,66,188,17,145,52,104,4,202, -113,67,76,130,227,72,194,13,240,108,0,0,83,96,0,2,185,0,104,146,84,97,48,0, -1,90,192,56,169,24,145,179,192,0,5,96,8,56,16,32,128,56,18,52,125,198,86, -147,186,140,28,50,21,13,39,31,23,60,145,158,56,204,141,47,121,6,155,190, -188,24,49,39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,199,68, -14,49,39,199,197,211,116,240,242,113,197,231,18,180,254,4,3,17,46,18,243, -35,100,128,172,156,146,70,163,150,76,34,248,146,164,108,248,75,204,141,146, -28,217,115,9,27,79,11,241,173,235,162,160,224,200,2,206,9,113,13,148,192, -209,18,22,164,146,37,193,57,162,4,249,39,196,128,24,2,178,66,213,136,68, -201,16,77,209,131,31,192,242,88,96,92,191,151,34,100,136,38,232,255,252,92, -221,199,197,12,68,209,82,66,212,11,155,185,41,197,13,55,38,3,66,213,47,131, -250,72,12,162,99,133,116,127,196,32,225,1,3,34,92,170,9,105,164,32,225,64, -131,156,1,193,133,7,19,39,22,70,154,103,143,128,0,11,16,20,28,76,156,113, -75,34,78,62,0,0,44,128,48,104,82,146,49,240,0,1,96,11,180,192,0,5,162,1,18, -160,65,24,131,20,145,25,188,48,132,122,28,76,146,218,121,35,180,69,145,132, -108,224,0,0,0,0,0,0,120,31,153,188,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,181, -32,29,235,2,27,199,23,0,0,22,196,51,120,129,8,244,56,153,37,180,242,71,104, -139,35,8,217,192,0,0,0,0,0,0,240,63,51,120,145,8,244,56,153,37,180,242,71, -104,139,35,8,217,192,0,0,0,0,0,0,0,64,51,120,161,8,244,56,153,37,180,242, -71,104,139,35,8,217,192,0,0,0,0,0,0,0,64,51,120,177,8,244,56,153,37,180, -242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64,51,120,193,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64,51,120,209,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64,51,120,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,246,40,5,34,92,35,68,225,161,166,219,16,16,137,112,52,41,73,29, -169,1,65,196,201,197,145,166,153,246,8,3,137,204,120,34,74,8,200,58,128,28, -211,160,130,52,78,26,26,110,248,0,0,170,4,12,70,137,195,38,0,0,42,68,159,7, -84,3,154,150,16,70,137,195,67,77,223,0,0,20,224,20,160,152,23,223,0,0,20, -226,9,65,154,232,147,161,115,59,224,0,2,156,84,12,50,9,195,38,0,0,41,133, -30,224,32,54,186,221,128,60, +DUK_INTERNAL const duk_uint8_t duk_builtins_data[4281] = { +144,148,105,226,32,68,52,228,254,12,104,202,37,132,52,167,194,138,105,245, +124,57,28,211,57,18,64,52,239,126,44,138,111,175,241,164,19,87,145,30,33, +167,22,145,159,8,211,139,9,225,42,5,240,145,139,163,163,8,211,139,10,228, +64,211,19,132,140,93,29,56,70,156,88,119,34,66,146,36,104,137,194,70,46, +142,172,35,78,44,47,146,195,102,11,240,145,139,163,175,8,211,139,9,228,240, +242,112,145,139,163,179,8,211,139,8,237,34,130,118,49,116,118,225,26,48,0, +1,98,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, +33,8,66,26,180,105,97,167,68,150,34,33,154,112,0,1,91,247,35,79,111,237, +198,174,232,47,31,23,95,17,13,31,249,96,211,49,50,53,214,77,141,24,0,0,181, +10,228,240,242,15,128,140,65,128,134,188,0,0,90,167,97,181,224,0,2,213,62, +53,224,0,2,213,66,237,120,0,0,181,81,204,107,192,0,5,170,150,67,94,0,0,45, +84,245,90,240,0,1,106,169,162,215,128,0,11,85,93,150,188,0,0,90,171,111,53, +109,22,162,26,48,0,1,84,23,201,146,243,225,26,39,12,145,136,104,192,0,5,61, +11,228,201,121,240,100,19,134,72,196,33,195,14,40,203,112,64,190,76,232, +145,153,136,0,0,0,0,0,0,31,15,249,152,0,0,0,0,0,0,30,15,249,120,144,13,96, +155,194,56,80,206,36,67,141,20,228,70,57,81,206,100,131,156,39,132,168,23, +194,70,46,137,208,21,200,129,166,39,9,24,186,39,72,119,34,66,146,36,104, +137,194,70,46,137,212,23,201,97,179,5,248,72,197,209,58,194,121,60,60,156, +36,98,232,157,129,29,164,80,78,198,46,137,218,146,121,25,71,146,9,209,5, +209,61,48,126,14,138,152,30,67,186,23,143,139,175,131,202,135,228,72,85, +144,83,60,179,30,94,209,233,102,30,98,105,230,103,30,114,121,231,104,30, +122,137,231,233,30,130,153,232,106,30,138,169,232,235,30,144,67,193,25,19, +136,108,207,30,41,224,140,137,194,173,192,153,228,5,242,100,188,248,70,137, +195,36,79,78,47,147,37,231,193,144,78,25,34,122,145,111,36,74,232,176,13, +17,61,234,226,93,207,148,160,84,75,141,7,27,161,32,33,18,225,80,212,76,154, +2,2,70,65,56,100,237,34,140,209,2,67,32,156,50,118,145,64,186,230,61,205, +35,103,155,32,36,141,19,134,78,210,40,206,16,36,70,137,195,39,105,20,11, +174,99,220,210,54,121,210,1,137,33,1,228,207,16,17,70,146,66,3,201,164,32, +0,65,112,152,56,196,159,31,23,77,211,195,201,199,23,160,72,214,246,81,6,12, +73,241,214,111,31,23,60,145,158,56,50,72,81,67,230,232,242,80,19,49,39,199, +89,188,124,92,242,70,120,227,64,194,75,154,72,12,9,73,6,111,21,120,12,40, +144,19,39,25,0,225,144,168,105,56,248,185,228,140,241,200,96,64,100,42,26, +78,62,46,121,35,52,18,92,116,1,36,64,47,158,64,49,98,66,100,156,242,65,23, +196,149,35,103,194,94,100,108,144,230,203,156,64,66,37,201,16,11,32,249, +132,4,34,92,44,93,146,55,152,72,24,137,112,151,153,27,36,5,100,229,144,8, +162,98,92,210,5,76,73,241,214,111,31,23,60,145,158,57,44,48,46,92,185,164, +160,72,151,41,0,50,107,179,244,59,36,93,127,92,6,19,172,3,11,216,0,56,224, +151,29,102,241,241,115,201,25,227,164,64,106,37,199,197,211,116,240,242, +113,197,233,144,40,248,185,228,140,241,196,75,132,109,24,72,128,43,39,84, +129,13,173,161,144,168,105,56,98,78,100,142,214,215,69,1,13,173,161,144, +168,105,57,34,78,100,142,214,215,69,16,67,107,105,110,114,168,254,24,147, +153,35,181,181,212,32,67,107,105,110,114,168,254,72,147,153,35,181,181,212, +36,65,130,3,144,8,26,252,200,13,30,85,16,16,64,90,242,231,192,64,161,163, +203,31,26,172,193,17,4,23,105,159,96,27,172,251,16,32,196,4,14,137,112,17, +136,48,164,28,134,80,215,202,1,132,130,8,12,39,52,64,155,31,24,56,36,1,189, +207,132,0,35,233,35,195,62,3,196,149,36,100,72,160,2,200,232,44,227,0,11, +37,160,68,142,128,36,157,25,200,32,26,79,90,4,73,43,192,122,54,71,65,103, +44,248,14,134,140,151,227,138,231,208,45,96,148,248,134,140,151,227,138, +231,240,1,255,254,10,74,146,56,128,104,4,147,152,72,6,144,28,174,143,8,1, +30,1,165,3,96,31,0,211,3,21,11,153,35,0,211,131,68,131,160,137,16,250,5, +196,131,160,137,200,160,199,156,67,248,0,255,255,65,140,10,48,177,115,56, +35,130,60,19,134,79,89,240,52,177,115,56,39,12,156,123,144,217,251,15,135, +34,167,30,20,170,154,255,232,12,47,244,0,97,28,17,224,39,238,32,40,71,4, +120,39,12,156,4,253,228,5,137,195,39,30,228,54,124,4,253,228,128,194,115, +68,9,252,15,128,232,104,201,126,56,191,35,64,90,193,41,241,13,25,47,199,23, +228,105,3,86,225,1,100,224,156,199,130,36,249,144,10,192,76,71,250,16,15, +18,61,96,17,62,200,3,72,128,136,143,247,32,22,75,64,137,248,64,22,79,90,39, +249,64,38,84,12,167,20,52,223,196,2,230,238,45,214,36,120,32,72,158,208,4, +102,238,45,194,2,201,197,186,196,143,4,9,19,218,0,92,221,202,61,228,143,4, +9,19,218,8,35,55,113,110,16,22,78,81,239,36,120,32,72,158,208,64,73,197,12, +255,0,13,18,60,128,159,212,128,169,76,17,156,185,100,76,255,163,64,65,26, +57,114,200,153,255,70,144,33,13,18,232,50,75,226,104,6,149,3,41,199,246, +130,12,128,28,142,156,120,203,175,158,8,194,207,1,6,81,20,79,88,11,237,84, +11,161,32,127,255,255,255,255,255,247,191,137,235,16,221,170,129,116,36,0, +16,0,0,0,0,0,0,12,196,0,0,0,0,0,0,15,135,242,61,123,164,137,162,164,218,67, +74,134,162,120,128,0,0,0,0,0,1,224,254,71,173,33,129,52,84,155,72,105,80, +212,79,16,0,0,0,0,0,0,60,63,195,244,143,146,22,230,192,0,0,0,0,0,0,176,60, +33,214,2,251,82,1,73,180,134,204,134,36,96,127,255,255,255,255,255,159,161, +144,235,16,221,169,0,164,218,67,102,67,18,48,63,255,255,255,255,255,207, +240,196,60,17,145,56,134,204,241,226,158,8,200,156,42,220,9,158,65,196,34, +92,42,26,137,147,120,64,74,37,196,54,100,49,35,188,36,5,68,184,208,113,187, +194,80,212,75,146,1,73,196,54,100,49,35,188,38,57,37,56,240,0,0,0,0,0,0,0, +0,32,235,248,68,48,156,2,24,94,24,0,243,119,10,139,144,123,242,3,102,238, +18,239,115,72,217,160,11,223,16,23,55,113,241,32,145,36,57,188,18,16,102,3, +5,120,35,34,89,32,15,180,152,173,127,0,218,235,88,0,228,180,227,200,0,0,0, +0,0,0,248,127,197,107,240,64,6,77,220,24,38,78,74,113,67,77,130,4,12,155, +185,52,48,156,148,226,134,155,4,10,194,96,129,132,166,238,45,194,2,201,193, +130,100,228,167,20,52,216,32,113,41,187,139,112,128,178,114,104,97,57,41, +197,13,54,8,32,48,216,32,130,195,224,130,19,97,124,134,23,6,0,57,137,62,77, +12,38,12,0,179,18,124,45,22,190,96,128,141,176,134,28,98,79,180,152,139, +218,45,124,193,1,27,97,16,32,196,159,24,230,204,246,194,40,89,137,62,210, +98,103,92,217,158,216,70,7,49,39,193,130,100,182,17,194,140,73,246,147,16, +250,9,146,216,72,6,49,39,193,131,22,194,72,73,137,62,210,98,31,65,139,97, +40,32,196,159,14,234,70,86,194,88,89,137,62,210,98,63,93,72,202,216,76,10, +49,39,198,33,180,153,37,108,38,134,152,147,237,38,38,117,13,164,201,43,97, +56,40,196,159,36,65,57,163,149,176,158,26,98,79,180,152,165,210,9,205,28, +173,133,0,243,18,124,98,22,180,72,130,115,71,43,97,68,72,196,159,105,49,51, +168,90,209,34,9,205,28,173,133,33,19,18,124,154,24,76,185,164,227,138,89, +18,119,0,7,145,39,201,161,132,188,64,124,137,62,49,11,90,36,65,57,163,149, +210,166,37,34,79,180,152,153,212,45,104,145,4,230,142,87,74,160,84,137,62, +72,130,115,71,43,171,234,134,200,147,237,38,41,116,130,115,71,43,171,235,5, +72,147,227,16,218,76,146,186,254,184,108,137,62,210,98,103,80,218,76,146, +186,254,192,68,137,62,29,212,140,174,207,178,23,34,79,180,152,143,215,82, +50,187,62,208,60,137,62,12,19,37,210,182,21,34,79,180,152,135,208,76,151, +74,224,68,137,62,49,205,153,238,175,186,23,34,79,180,152,153,215,54,103, +186,190,240,92,137,62,22,139,95,48,64,70,235,251,225,210,36,251,73,136,189, +162,215,204,16,17,186,255,2,14,98,79,152,32,35,108,48,64,242,36,249,130,2, +55,75,6,212,224,72,200,51,128,114,108,28,100,128,0,0,0,0,0,0,0,12,110,127, +48,98,115,249,201,117,243,249,195,21,159,206,38,47,63,156,86,8,75,144,94, +82,1,38,73,79,208,67,95,233,1,6,128,14,79,129,186,40,249,18,149,182,207, +144,200,155,188,248,204,105,184,207,142,199,137,175,201,0,159,72,10,5,21, +221,10,120,74,129,124,36,98,232,228,74,81,62,160,20,10,107,186,21,114,32, +105,137,194,70,46,142,68,165,19,235,1,64,170,187,161,119,34,66,146,36,104, +137,194,70,46,142,68,165,19,236,1,64,174,187,161,95,37,134,204,23,225,35, +23,71,34,82,137,246,128,160,89,93,208,167,147,195,201,194,70,46,142,68,165, +19,238,1,64,182,187,161,71,105,20,19,177,139,163,145,41,68,16,7,6,15,82,70, +72,115,96,0,0,0,0,0,2,234,32,91,60,165,195,201,194,8,134,149,216,162,0,192, +41,225,8,2,48,177,36,1,149,13,196,15,0,200,209,97,199,128,99,32,176,195, +192,113,57,143,0,167,133,32,230,80,28,202,139,175,238,2,48,189,192,20,1, +119,80,87,193,186,129,89,56,72,197,209,200,193,185,35,23,71,109,13,219,36, +98,232,237,156,13,26,208,211,14,102,19,87,137,91,95,128,0,10,96,24,92,0,0, +83,2,53,56,0,0,165,3,28,204,160,160,226,100,226,200,211,76,241,240,0,1,102, +8,22,75,64,137,73,20,230,105,133,7,19,39,22,70,154,103,143,128,0,11,48,20, +28,76,156,113,75,34,78,62,0,0,45,3,103,31,0,0,22,65,44,57,137,62,33,179, +216,162,152,192,131,18,124,162,27,61,138,41,108,32,196,159,16,217,232,235, +81,76,104,73,137,62,81,13,158,142,181,20,184,16,98,79,136,108,244,244,168, +166,56,36,196,159,40,134,207,79,74,138,93,10,49,39,194,173,192,158,158,149, +20,188,20,98,79,133,91,129,61,109,74,41,124,30,68,159,16,217,236,83,108,96, +68,137,62,81,13,158,197,54,182,17,34,79,136,108,244,117,169,182,52,38,68, +159,40,134,207,71,90,155,92,8,145,39,196,54,122,122,84,219,28,19,34,79,148, +67,103,167,165,77,174,133,72,147,225,86,224,79,79,74,155,94,10,145,39,194, +173,192,158,182,165,54,190,206,25,212,35,208,226,100,150,211,201,29,162,44, +140,35,103,0,0,0,0,0,0,3,192,252,206,25,228,35,208,226,100,150,211,201,29, +162,44,140,35,103,0,0,0,0,0,0,3,192,252,206,25,244,35,208,226,100,150,211, +201,29,162,44,140,35,103,0,0,0,0,0,0,3,192,252,206,26,4,35,208,226,100,150, +211,201,29,162,44,140,35,103,0,0,0,0,0,0,0,1,0,206,26,20,35,208,226,100, +150,211,201,29,162,44,140,35,103,0,0,0,0,0,0,0,1,0,206,26,36,35,208,226, +100,150,211,201,29,162,44,140,35,103,0,0,0,0,0,0,0,65,0,206,26,52,35,208, +226,100,150,211,201,29,162,44,140,35,103,0,0,0,0,0,0,0,65,0,206,26,68,35, +208,226,100,150,211,201,29,162,44,140,35,103,0,0,0,0,0,0,0,65,0,206,26,84, +35,208,226,100,150,211,201,29,162,44,140,35,103,0,0,0,0,0,0,0,129,0,195, +154,99,16,38,36,0,251,68,117,179,216,162,128,68,72,1,241,13,158,197,20,150, +25,18,0,125,162,58,217,232,235,117,100,162,136,25,18,0,125,162,58,217,232, +235,116,36,162,145,2,226,64,15,136,108,244,117,186,178,81,73,129,113,32,7, +196,54,122,58,221,9,40,165,64,200,144,3,237,17,214,207,79,75,171,37,20,80, +200,144,3,237,17,214,207,79,75,161,37,20,138,23,18,0,124,67,103,167,165, +213,146,138,77,11,137,0,62,33,179,211,210,232,73,69,42,133,196,128,31,10, +183,2,125,89,40,163,5,196,128,31,10,183,2,125,9,40,164,96,200,144,3,224, +221,64,172,157,89,40,163,134,68,128,31,6,234,5,100,232,73,69,35,133,68,128, +31,104,142,182,125,89,40,180,0,168,144,3,237,17,214,207,161,37,22,144,19, +18,0,124,67,103,213,146,139,80,9,137,0,62,33,179,232,73,69,172,5,90,40,153, +59,68,117,179,216,166,192,77,162,137,147,136,108,246,41,180,176,219,69,19, +39,104,142,182,122,58,221,89,41,178,6,218,40,153,59,68,117,179,209,214,232, +73,77,162,6,90,40,153,56,134,207,71,91,171,37,54,152,25,104,162,100,226,27, +61,29,110,132,148,218,160,109,162,137,147,180,71,91,61,61,46,172,148,217, +67,109,20,76,157,162,58,217,233,233,116,36,166,209,67,45,20,76,156,67,103, +167,165,213,146,155,77,12,180,81,50,113,13,158,158,151,66,74,109,84,50,209, +68,201,194,173,192,159,86,74,108,193,150,138,38,78,21,110,4,250,18,83,104, +193,182,138,38,78,13,212,10,201,213,146,155,56,109,162,137,147,131,117,2, +178,116,36,166,209,194,237,20,76,157,162,58,217,245,100,167,16,2,237,20,76, +157,162,58,217,244,36,167,18,2,173,20,76,156,67,103,213,146,156,80,10,180, +81,50,113,13,159,66,74,113,97,175,221,48,216,110,64,4,42,22,189,179,0,196, +133,0,185,80,32,28,78,99,193,18,80,36,4,19,159,141,172,0,178,90,4,74,73,0, +22,209,68,201,187,129,4,2,8,3,132,64,60,36,6,149,113,72,176,171,240,84,0, +157,91,116,116,32,11,42,218,221,216,181,129,32,3,234,219,165,3,188,231,235, +249,8,187,152,252,47,86,227,105,18,7,244,17,91,42,56,175,185,248,110,173, +198,209,208,36,0,238,82,97,87,188,189,179,240,93,122,32,12,22,162,42,125, +144,132,160,7,236,161,25,232,237,105,64,205,59,127,102,158,160,230,63,11, +217,66,51,210,129,154,118,254,205,61,65,236,127,171,197,34,168,48,6,90,194, +1,0,39,75,88,72,8,9,33,186,194,80,64,76,13,214,19,2,130,96,110,150,189,0, +65,6,51,214,20,128,65,17,11,214,19,130,137,121,211,210,211,144,6,39,75,88, +80,0,201,119,235,10,8,41,86,231,71,88,80,129,79,135,186,122,133,224,34,25, +69,234,80,3,91,141,172,40,96,139,113,180,181,133,36,21,110,54,142,134,176, +165,1,176,23,213,47,0,216,134,234,215,128,111,117,181,232,128,209,3,70,230, +107,64,5,139,168,209,235,10,32,36,144,102,235,136,3,146,27,172,40,160,146, +132,103,172,40,192,115,3,117,133,28,22,113,163,69,172,41,103,1,66,188,17, +145,52,168,4,202,113,67,76,130,227,76,194,13,240,108,0,0,83,224,0,2,193,0, +104,146,84,97,48,0,1,94,192,56,169,24,145,179,192,0,5,112,8,56,16,32,128, +56,18,52,125,230,86,147,190,140,28,50,21,13,39,31,23,60,145,158,57,12,141, +47,129,6,155,194,188,24,49,39,199,89,188,124,92,242,70,120,224,201,33,69, +15,155,163,201,68,14,49,39,199,197,211,116,240,242,113,197,232,18,180,254, +36,3,17,46,18,243,35,100,128,172,156,178,70,163,154,76,34,248,146,164,108, +248,75,204,141,146,28,217,115,137,27,95,27,241,173,236,162,160,224,200,2, +206,9,113,13,148,192,209,18,22,164,146,37,193,57,162,4,249,39,196,128,24,2, +178,66,213,136,68,201,16,77,209,131,31,192,242,88,96,92,191,151,34,100,136, +38,232,255,252,92,221,199,197,12,68,209,82,66,212,11,155,185,41,197,13,55, +38,3,66,213,47,135,254,72,12,162,99,133,116,112,0,1,72,66,14,16,16,50,37, +202,160,150,154,66,14,20,8,57,192,28,24,80,113,50,113,100,105,166,120,248, +0,0,179,1,65,196,201,199,20,178,36,227,224,0,2,208,54,113,240,0,1,100,11, +181,192,0,5,178,1,18,160,65,24,131,20,145,25,188,48,132,122,28,76,146,218, +121,35,180,69,145,132,108,224,0,0,0,0,0,0,120,31,153,188,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,183,32,29,235,2,27,199,23,0,0,23,4,51,120,129,8,244,56, +153,37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,240,63,51,120,145,8,244, +56,153,37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,0,64,51,120,161,8, +244,56,153,37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,0,64,51,120,177, +8,244,56,153,37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64,51,120, +193,8,244,56,153,37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64,51, +120,209,8,244,56,153,37,180,242,71,104,139,35,8,217,192,0,0,0,0,0,0,16,64, +51,120,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,246,104,5,34,92,35,68,225,161,166,220,16,16, +137,112,52,41,73,29,185,1,65,196,201,197,145,166,153,246,72,3,137,204,120, +34,74,8,199,1,67,17,162,112,201,84,128,97,144,78,25,42,16,131,169,1,205,66, +8,35,68,225,161,166,239,128,0,10,192,64,196,104,156,50,96,0,2,172,73,240, +117,96,57,170,97,4,104,156,52,52,221,240,0,1,82,1,74,9,129,125,240,0,1,82, +32,148,25,174,137,58,23,51,190,0,0,42,69,64,195,32,156,50,96,0,2,160,81, +238,2,3,107,173,218,3,192, }; #elif defined(DUK_USE_DOUBLE_BE) -DUK_INTERNAL const duk_uint8_t duk_builtins_data[4251] = { -144,148,105,225,32,68,52,228,126,12,104,201,37,132,52,167,194,138,105,244, -124,57,28,211,57,18,64,52,238,254,44,138,111,171,241,164,19,87,137,30,33, -167,18,145,159,8,211,137,9,225,42,5,240,145,139,163,163,8,211,137,10,228, -64,211,19,132,140,93,29,56,70,156,72,119,34,66,146,36,104,137,194,70,46, -142,172,35,78,36,47,146,195,102,11,240,145,139,163,175,8,211,137,9,228,240, -242,112,145,139,163,179,8,211,137,8,237,34,130,118,49,116,118,225,26,48,0, -1,94,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, -33,8,66,26,180,41,97,167,64,150,34,33,154,112,0,1,87,247,35,79,103,237,198, -174,216,47,31,23,95,17,13,31,217,96,211,49,50,53,212,77,141,24,0,0,179,10, -228,240,242,15,128,140,65,128,134,188,0,0,89,167,97,181,224,0,2,205,62,53, -224,0,2,205,66,237,120,0,0,179,81,204,107,192,0,5,154,150,67,94,0,0,44,212, -245,90,240,0,1,102,169,162,215,128,0,11,53,93,150,188,0,0,89,171,111,53, -108,150,163,70,0,0,42,2,249,50,94,124,35,68,225,146,49,13,24,0,0,165,161, -124,153,47,62,12,130,112,201,24,132,56,97,115,16,31,254,0,0,0,0,0,0,51,48, -31,252,0,0,0,0,0,0,50,241,32,26,193,55,132,112,161,156,72,135,26,41,200, -140,114,163,156,201,7,56,79,9,80,47,132,140,93,19,160,43,145,3,76,78,18,49, -116,78,144,238,68,133,36,72,209,19,132,140,93,19,168,47,146,195,102,11,240, -145,139,162,117,132,242,120,121,56,72,197,209,59,2,59,72,160,157,140,93,19, -181,36,242,50,143,36,31,131,162,166,7,144,238,133,227,226,235,224,242,161, -249,18,21,100,20,207,44,199,151,180,122,89,135,152,154,121,153,199,156,158, -121,218,7,158,162,121,250,71,160,166,122,26,135,162,170,122,58,199,164,16, -240,70,68,226,27,51,199,138,120,35,34,112,171,112,38,121,1,124,153,47,62, -17,162,112,201,19,211,11,228,201,121,240,100,19,134,72,158,160,91,201,18, -186,44,3,68,79,122,168,151,115,165,40,21,18,227,65,198,231,200,8,68,184,84, -53,19,38,120,128,145,144,78,25,59,72,163,48,64,144,200,39,12,157,164,80,46, -185,143,115,72,217,230,72,9,35,68,225,147,180,138,51,68,9,17,162,112,201, -218,69,2,235,152,247,52,141,158,108,128,98,72,64,121,51,132,4,81,164,144, -128,242,104,136,0,16,92,38,14,49,39,199,197,211,116,240,242,113,197,231,18, -53,189,116,65,131,18,124,117,155,199,197,207,36,103,142,12,146,20,80,249, -186,60,116,4,204,73,241,214,111,31,23,60,145,158,56,208,48,146,229,146,3,2, -82,65,155,195,94,3,10,36,4,201,196,64,56,100,42,26,78,62,46,121,35,60,113, -152,16,25,10,134,147,143,139,158,72,205,4,151,21,0,73,16,11,230,144,12,88, -144,153,39,52,144,69,241,37,72,217,240,151,153,27,36,57,178,230,16,16,137, -114,68,2,200,62,81,1,8,151,11,23,100,141,229,18,6,34,92,37,230,70,201,1,89, -57,36,2,40,152,151,44,129,83,18,124,117,155,199,197,207,36,103,142,75,12, -11,151,46,89,40,18,37,200,64,12,154,236,252,238,185,23,95,213,1,132,234,0, -194,245,128,14,56,37,199,89,188,124,92,242,70,120,232,16,26,137,113,241, -116,221,60,60,156,113,122,36,10,62,46,121,35,60,113,18,225,27,70,18,32,10, -201,211,32,67,107,104,100,42,26,78,24,147,153,35,181,181,207,64,67,107,104, -100,42,26,78,72,147,153,35,181,181,207,68,16,218,218,91,156,170,63,134,36, -230,72,237,109,116,136,16,218,218,91,156,170,63,146,36,230,72,237,109,116, -137,16,96,128,228,2,6,191,46,3,71,147,68,4,16,22,188,169,240,16,40,104,242, -135,198,171,44,68,65,5,217,231,215,6,231,62,188,8,49,1,3,162,92,4,98,12,41, -7,33,148,53,242,128,97,32,130,3,9,205,16,38,199,198,14,9,0,111,115,225,0,8, -250,72,240,207,128,241,37,73,25,18,40,0,178,58,11,56,192,2,201,104,17,35, -160,9,39,70,114,8,6,147,214,129,18,74,240,30,141,145,208,89,203,62,3,161, -163,37,248,226,185,244,11,88,37,62,33,163,37,248,226,185,252,0,127,255,130, -146,164,142,32,26,1,36,230,18,1,164,7,43,163,194,0,71,128,105,64,216,7,192, -52,192,197,66,230,72,192,52,224,209,32,232,34,68,62,129,113,32,232,34,114, -40,49,231,16,254,0,63,255,208,99,2,140,44,92,206,8,224,143,4,225,147,210, -124,13,44,92,206,9,195,39,30,228,54,126,163,225,200,169,198,133,42,166,191, -246,3,11,251,0,24,71,4,120,9,251,8,10,17,193,30,9,195,39,1,63,105,1,98,112, -201,199,185,13,159,1,63,105,32,48,156,209,2,126,227,224,58,26,50,95,142,47, -192,208,22,176,74,124,67,70,75,241,197,248,26,64,213,184,64,89,56,39,49, -224,137,62,36,2,176,19,17,254,68,3,196,143,88,4,79,162,0,210,32,34,35,253, -72,5,146,208,34,125,144,5,147,214,137,253,208,9,149,3,41,197,13,55,233,0, -185,187,139,117,137,30,8,18,39,172,1,25,187,139,112,128,178,113,110,177,35, -193,2,68,245,128,23,55,114,143,121,35,193,2,68,245,130,8,205,220,91,132,5, -147,148,123,201,30,8,18,39,172,16,18,113,67,63,128,3,68,143,32,39,243,32, -42,83,4,103,46,89,19,63,224,208,16,70,142,92,178,38,127,193,164,8,67,68, -186,12,146,247,154,1,165,64,202,113,252,160,131,32,7,35,167,26,50,235,231, -130,48,179,192,65,148,69,19,214,2,251,85,2,232,72,15,253,255,255,255,255, -255,255,226,122,196,55,106,160,93,9,0,0,0,0,0,0,0,0,7,49,1,255,224,0,0,0,0, -0,0,143,94,233,34,104,169,54,144,210,161,168,158,32,63,248,0,0,0,0,0,0,17, -235,72,96,77,21,38,210,26,84,53,19,196,15,255,0,0,0,0,0,0,0,253,35,228,133, -185,176,15,44,0,0,0,0,0,0,8,117,128,190,212,128,82,109,33,179,33,137,24,8, -103,255,255,255,255,255,255,228,58,196,55,106,64,41,54,144,217,144,196,140, -12,51,255,255,255,255,255,255,241,15,4,100,78,33,179,60,120,167,130,50,39, -10,183,2,103,144,113,8,151,10,134,162,100,221,16,18,137,113,13,153,12,72, -238,137,1,81,46,52,28,110,232,148,53,18,228,128,82,113,13,153,12,72,238, -137,142,73,78,52,0,0,0,0,0,0,0,0,8,58,254,1,12,38,248,134,23,130,0,60,221, -194,162,228,30,244,128,217,187,132,187,220,210,54,104,2,247,132,5,205,220, -124,72,36,73,14,110,252,132,25,128,193,94,8,200,149,200,3,237,38,43,31,192, -54,186,213,128,57,45,56,210,31,254,0,0,0,0,0,0,49,90,251,224,6,77,220,24, -38,78,74,113,67,77,124,16,50,110,228,208,194,114,83,138,26,107,224,172,37, -240,97,41,187,139,112,128,178,112,96,153,57,41,197,13,53,240,113,41,187, -139,112,128,178,114,104,97,57,41,197,13,53,240,128,195,95,8,44,61,240,132, -216,93,33,133,192,128,14,98,79,147,67,9,129,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,181,55,136,200, -51,128,114,108,28,100,128,0,0,0,0,0,0,0,12,110,127,32,98,115,249,73,117, -243,249,67,21,159,202,38,47,63,148,86,8,75,144,94,50,1,38,73,79,204,67,95, -231,1,6,128,14,79,129,185,40,249,18,149,181,207,142,199,155,172,248,172,89, -183,207,140,198,137,175,200,0,159,72,10,5,21,220,138,120,74,129,124,36,98, -232,228,74,81,62,160,20,10,107,185,21,114,32,105,137,194,70,46,142,68,165, -19,235,1,64,170,187,145,119,34,66,146,36,104,137,194,70,46,142,68,165,19, -236,1,64,174,187,145,95,37,134,204,23,225,35,23,71,34,82,137,246,128,160, -89,93,200,167,147,195,201,194,70,46,142,68,165,19,238,1,64,182,187,145,71, -105,20,19,177,139,163,145,41,68,16,7,6,15,82,70,72,115,96,32,105,246,0,0,0, -0,0,91,60,165,195,201,194,8,134,149,216,130,0,192,41,224,136,2,48,176,228, -1,149,13,195,15,0,200,209,97,71,128,99,32,176,131,192,113,57,143,0,167,131, -32,230,80,28,202,139,175,237,2,48,189,160,20,1,119,48,87,193,186,129,89,56, -72,197,209,200,193,185,35,23,71,109,13,219,36,98,232,237,156,13,26,208,211, -14,102,19,87,137,91,95,128,0,10,64,24,92,0,0,82,2,53,63,240,49,204,202,10, -14,38,78,44,141,52,207,31,0,0,22,32,129,100,180,8,148,145,78,102,152,80, -113,50,113,100,105,166,120,248,0,0,177,1,65,196,201,199,20,178,36,227,224, -0,2,200,3,6,133,41,35,31,0,0,22,1,44,57,137,62,33,179,216,162,152,192,131, -18,124,162,27,61,138,41,108,32,196,159,16,217,232,235,81,76,104,73,137,62, -81,13,158,142,181,20,184,16,98,79,136,108,244,244,168,166,56,36,196,159,40, -134,207,79,74,138,93,10,49,39,194,173,192,158,158,149,20,188,20,98,79,133, -91,129,61,109,74,41,124,30,68,159,16,217,236,83,108,96,68,137,62,81,13,158, -197,54,182,17,34,79,136,108,244,117,169,182,52,38,68,159,40,134,207,71,90, -155,92,8,145,39,196,54,122,122,84,219,28,19,34,79,148,67,103,167,165,77, -174,133,72,147,225,86,224,79,79,74,155,94,10,145,39,194,173,192,158,182, -165,54,190,206,25,212,35,208,226,100,150,211,201,29,162,44,140,35,103,0, -255,192,0,0,0,0,0,0,206,25,228,35,208,226,100,150,211,201,29,162,44,140,35, -103,0,255,192,0,0,0,0,0,0,206,25,244,35,208,226,100,150,211,201,29,162,44, -140,35,103,0,255,192,0,0,0,0,0,0,206,26,4,35,208,226,100,150,211,201,29, -162,44,140,35,103,1,0,0,0,0,0,0,0,0,206,26,20,35,208,226,100,150,211,201, -29,162,44,140,35,103,1,0,0,0,0,0,0,0,0,206,26,36,35,208,226,100,150,211, -201,29,162,44,140,35,103,1,0,64,0,0,0,0,0,0,206,26,52,35,208,226,100,150, -211,201,29,162,44,140,35,103,1,0,64,0,0,0,0,0,0,206,26,68,35,208,226,100, -150,211,201,29,162,44,140,35,103,1,0,64,0,0,0,0,0,0,206,26,84,35,208,226, -100,150,211,201,29,162,44,140,35,103,1,0,128,0,0,0,0,0,0,195,154,99,16,38, -36,0,251,68,117,179,216,162,128,68,72,1,241,13,158,197,20,150,25,18,0,125, -162,58,217,232,235,117,100,162,136,25,18,0,125,162,58,217,232,235,116,36, -162,145,2,226,64,15,136,108,244,117,186,178,81,73,129,113,32,7,196,54,122, -58,221,9,40,165,64,200,144,3,237,17,214,207,79,75,171,37,20,80,200,144,3, -237,17,214,207,79,75,161,37,20,138,23,18,0,124,67,103,167,165,213,146,138, -77,11,137,0,62,33,179,211,210,232,73,69,42,133,196,128,31,10,183,2,125,89, -40,163,5,196,128,31,10,183,2,125,9,40,164,96,200,144,3,224,221,64,172,157, -89,40,163,134,68,128,31,6,234,5,100,232,73,69,35,133,68,128,31,104,142,182, -125,89,40,180,0,168,144,3,237,17,214,207,161,37,22,144,19,18,0,124,67,103, -213,146,139,80,9,137,0,62,33,179,232,73,69,172,5,90,40,153,59,68,117,179, -216,166,192,77,162,137,147,136,108,246,41,180,176,219,69,19,39,104,142,182, -122,58,221,89,41,178,6,218,40,153,59,68,117,179,209,214,232,73,77,162,6,90, -40,153,56,134,207,71,91,171,37,54,152,25,104,162,100,226,27,61,29,110,132, -148,218,160,109,162,137,147,180,71,91,61,61,46,172,148,217,67,109,20,76, -157,162,58,217,233,233,116,36,166,209,67,45,20,76,156,67,103,167,165,213, -146,155,77,12,180,81,50,113,13,158,158,151,66,74,109,84,50,209,68,201,194, -173,192,159,86,74,108,193,150,138,38,78,21,110,4,250,18,83,104,193,182,138, -38,78,13,212,10,201,213,146,155,56,109,162,137,147,131,117,2,178,116,36, -166,209,194,237,20,76,157,162,58,217,245,100,167,16,2,237,20,76,157,162,58, -217,244,36,167,18,2,173,20,76,156,67,103,213,146,156,80,10,180,81,50,113, -13,159,66,74,113,97,175,220,48,216,109,192,4,42,22,189,163,0,196,133,0,185, -80,32,28,78,99,193,18,80,36,4,19,159,141,156,0,178,90,4,74,73,0,22,209,68, -201,185,129,4,2,8,3,132,64,60,36,4,0,91,240,168,177,69,118,144,157,91,116, -116,32,32,1,53,216,221,218,170,139,3,234,219,165,0,255,152,185,11,251,232, -231,188,47,86,227,105,18,1,255,184,170,59,41,92,23,240,110,173,198,209,208, -36,3,253,188,183,177,82,110,80,224,93,122,32,32,4,144,253,170,34,22,140,7, -236,161,25,232,237,105,64,63,230,160,158,102,127,59,205,11,217,66,51,210, -128,127,237,65,60,204,254,119,155,171,197,34,168,48,6,90,162,1,0,39,75,84, -72,8,9,33,186,162,80,64,76,13,213,19,2,130,96,110,150,181,0,65,6,51,213,20, -128,65,17,11,213,19,130,137,121,211,210,210,144,6,39,75,84,80,0,201,119, -234,138,8,41,86,231,71,84,80,129,79,135,186,122,101,224,34,25,69,233,208,3, -91,141,170,40,96,139,113,180,181,69,36,21,110,54,142,134,168,165,1,176,23, -212,47,0,216,134,234,87,128,111,117,181,168,128,209,3,70,230,106,192,5,139, -168,209,234,138,32,36,144,102,235,8,3,146,27,170,40,160,146,132,103,170,40, -192,115,3,117,69,28,22,113,163,69,170,41,103,1,66,188,17,145,52,104,4,202, -113,67,76,130,227,72,194,13,240,108,0,0,83,96,0,2,185,0,104,146,84,97,48,0, -1,90,192,56,169,24,145,179,192,0,5,96,8,56,16,32,128,56,18,52,125,198,86, -147,186,140,28,50,21,13,39,31,23,60,145,158,56,204,141,47,121,6,155,190, -188,24,49,39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,199,68, -14,49,39,199,197,211,116,240,242,113,197,231,18,180,254,4,3,17,46,18,243, -35,100,128,172,156,146,70,163,150,76,34,248,146,164,108,248,75,204,141,146, -28,217,115,9,27,79,11,241,173,235,162,160,224,200,2,206,9,113,13,148,192, -209,18,22,164,146,37,193,57,162,4,249,39,196,128,24,2,178,66,213,136,68, -201,16,77,209,131,31,192,242,88,96,92,191,151,34,100,136,38,232,255,252,92, -221,199,197,12,68,209,82,66,212,11,155,185,41,197,13,55,38,3,66,213,47,131, -250,72,12,162,99,133,116,127,196,32,225,1,3,34,92,170,9,105,164,32,225,64, -131,156,1,193,133,7,19,39,22,70,154,103,143,128,0,11,16,20,28,76,156,113, -75,34,78,62,0,0,44,128,48,104,82,146,49,240,0,1,96,11,180,192,0,5,162,1,18, -160,65,24,131,20,145,25,188,48,132,122,28,76,146,218,121,35,180,69,145,132, -108,224,31,248,0,0,0,0,0,0,25,188,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,181, -32,29,235,2,27,199,23,0,0,22,196,51,120,129,8,244,56,153,37,180,242,71,104, -139,35,8,217,192,63,240,0,0,0,0,0,0,51,120,145,8,244,56,153,37,180,242,71, -104,139,35,8,217,192,64,0,0,0,0,0,0,0,51,120,161,8,244,56,153,37,180,242, -71,104,139,35,8,217,192,64,0,0,0,0,0,0,0,51,120,177,8,244,56,153,37,180, -242,71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51,120,193,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51,120,209,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51,120,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,246,40,5,34,92,35,68,225,161,166,219,16,16,137,112,52,41,73,29, -169,1,65,196,201,197,145,166,153,246,8,3,137,204,120,34,74,8,200,58,128,28, -211,160,130,52,78,26,26,110,248,0,0,170,4,12,70,137,195,38,0,0,42,68,159,7, -84,3,154,150,16,70,137,195,67,77,223,0,0,20,224,20,160,152,23,223,0,0,20, -226,9,65,154,232,147,161,115,59,224,0,2,156,84,12,50,9,195,38,0,0,41,133, -30,224,32,54,186,221,128,60, +DUK_INTERNAL const duk_uint8_t duk_builtins_data[4281] = { +144,148,105,226,32,68,52,228,254,12,104,202,37,132,52,167,194,138,105,245, +124,57,28,211,57,18,64,52,239,126,44,138,111,175,241,164,19,87,145,30,33, +167,22,145,159,8,211,139,9,225,42,5,240,145,139,163,163,8,211,139,10,228, +64,211,19,132,140,93,29,56,70,156,88,119,34,66,146,36,104,137,194,70,46, +142,172,35,78,44,47,146,195,102,11,240,145,139,163,175,8,211,139,9,228,240, +242,112,145,139,163,179,8,211,139,8,237,34,130,118,49,116,118,225,26,48,0, +1,98,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, +33,8,66,26,180,105,97,167,68,150,34,33,154,112,0,1,91,247,35,79,111,237, +198,174,232,47,31,23,95,17,13,31,249,96,211,49,50,53,214,77,141,24,0,0,181, +10,228,240,242,15,128,140,65,128,134,188,0,0,90,167,97,181,224,0,2,213,62, +53,224,0,2,213,66,237,120,0,0,181,81,204,107,192,0,5,170,150,67,94,0,0,45, +84,245,90,240,0,1,106,169,162,215,128,0,11,85,93,150,188,0,0,90,171,111,53, +109,22,162,26,48,0,1,84,23,201,146,243,225,26,39,12,145,136,104,192,0,5,61, +11,228,201,121,240,100,19,134,72,196,33,195,14,40,203,112,64,190,76,232, +145,153,136,15,255,0,0,0,0,0,0,25,152,15,254,0,0,0,0,0,0,25,120,144,13,96, +155,194,56,80,206,36,67,141,20,228,70,57,81,206,100,131,156,39,132,168,23, +194,70,46,137,208,21,200,129,166,39,9,24,186,39,72,119,34,66,146,36,104, +137,194,70,46,137,212,23,201,97,179,5,248,72,197,209,58,194,121,60,60,156, +36,98,232,157,129,29,164,80,78,198,46,137,218,146,121,25,71,146,9,209,5, +209,61,48,126,14,138,152,30,67,186,23,143,139,175,131,202,135,228,72,85, +144,83,60,179,30,94,209,233,102,30,98,105,230,103,30,114,121,231,104,30, +122,137,231,233,30,130,153,232,106,30,138,169,232,235,30,144,67,193,25,19, +136,108,207,30,41,224,140,137,194,173,192,153,228,5,242,100,188,248,70,137, +195,36,79,78,47,147,37,231,193,144,78,25,34,122,145,111,36,74,232,176,13, +17,61,234,226,93,207,148,160,84,75,141,7,27,161,32,33,18,225,80,212,76,154, +2,2,70,65,56,100,237,34,140,209,2,67,32,156,50,118,145,64,186,230,61,205, +35,103,155,32,36,141,19,134,78,210,40,206,16,36,70,137,195,39,105,20,11, +174,99,220,210,54,121,210,1,137,33,1,228,207,16,17,70,146,66,3,201,164,32, +0,65,112,152,56,196,159,31,23,77,211,195,201,199,23,160,72,214,246,81,6,12, +73,241,214,111,31,23,60,145,158,56,50,72,81,67,230,232,242,80,19,49,39,199, +89,188,124,92,242,70,120,227,64,194,75,154,72,12,9,73,6,111,21,120,12,40, +144,19,39,25,0,225,144,168,105,56,248,185,228,140,241,200,96,64,100,42,26, +78,62,46,121,35,52,18,92,116,1,36,64,47,158,64,49,98,66,100,156,242,65,23, +196,149,35,103,194,94,100,108,144,230,203,156,64,66,37,201,16,11,32,249, +132,4,34,92,44,93,146,55,152,72,24,137,112,151,153,27,36,5,100,229,144,8, +162,98,92,210,5,76,73,241,214,111,31,23,60,145,158,57,44,48,46,92,185,164, +160,72,151,41,0,50,107,179,244,59,36,93,127,92,6,19,172,3,11,216,0,56,224, +151,29,102,241,241,115,201,25,227,164,64,106,37,199,197,211,116,240,242, +113,197,233,144,40,248,185,228,140,241,196,75,132,109,24,72,128,43,39,84, +129,13,173,161,144,168,105,56,98,78,100,142,214,215,69,1,13,173,161,144, +168,105,57,34,78,100,142,214,215,69,16,67,107,105,110,114,168,254,24,147, +153,35,181,181,212,32,67,107,105,110,114,168,254,72,147,153,35,181,181,212, +36,65,130,3,144,8,26,252,200,13,30,85,16,16,64,90,242,231,192,64,161,163, +203,31,26,172,193,17,4,23,105,159,96,27,172,251,16,32,196,4,14,137,112,17, +136,48,164,28,134,80,215,202,1,132,130,8,12,39,52,64,155,31,24,56,36,1,189, +207,132,0,35,233,35,195,62,3,196,149,36,100,72,160,2,200,232,44,227,0,11, +37,160,68,142,128,36,157,25,200,32,26,79,90,4,73,43,192,122,54,71,65,103, +44,248,14,134,140,151,227,138,231,208,45,96,148,248,134,140,151,227,138, +231,240,1,255,254,10,74,146,56,128,104,4,147,152,72,6,144,28,174,143,8,1, +30,1,165,3,96,31,0,211,3,21,11,153,35,0,211,131,68,131,160,137,16,250,5, +196,131,160,137,200,160,199,156,67,248,0,255,255,65,140,10,48,177,115,56, +35,130,60,19,134,79,89,240,52,177,115,56,39,12,156,123,144,217,251,15,135, +34,167,30,20,170,154,255,232,12,47,244,0,97,28,17,224,39,238,32,40,71,4, +120,39,12,156,4,253,228,5,137,195,39,30,228,54,124,4,253,228,128,194,115, +68,9,252,15,128,232,104,201,126,56,191,35,64,90,193,41,241,13,25,47,199,23, +228,105,3,86,225,1,100,224,156,199,130,36,249,144,10,192,76,71,250,16,15, +18,61,96,17,62,200,3,72,128,136,143,247,32,22,75,64,137,248,64,22,79,90,39, +249,64,38,84,12,167,20,52,223,196,2,230,238,45,214,36,120,32,72,158,208,4, +102,238,45,194,2,201,197,186,196,143,4,9,19,218,0,92,221,202,61,228,143,4, +9,19,218,8,35,55,113,110,16,22,78,81,239,36,120,32,72,158,208,64,73,197,12, +255,0,13,18,60,128,159,212,128,169,76,17,156,185,100,76,255,163,64,65,26, +57,114,200,153,255,70,144,33,13,18,232,50,75,226,104,6,149,3,41,199,246, +130,12,128,28,142,156,120,203,175,158,8,194,207,1,6,81,20,79,88,11,237,84, +11,161,32,63,247,255,255,255,255,255,255,137,235,16,221,170,129,116,36,0,0, +0,0,0,0,0,0,28,196,7,255,128,0,0,0,0,0,2,61,123,164,137,162,164,218,67,74, +134,162,120,128,255,224,0,0,0,0,0,0,71,173,33,129,52,84,155,72,105,80,212, +79,16,63,252,0,0,0,0,0,0,3,244,143,146,22,230,192,60,176,0,0,0,0,0,0,33, +214,2,251,82,1,73,180,134,204,134,36,96,33,159,255,255,255,255,255,255,144, +235,16,221,169,0,164,218,67,102,67,18,48,48,207,255,255,255,255,255,255, +196,60,17,145,56,134,204,241,226,158,8,200,156,42,220,9,158,65,196,34,92, +42,26,137,147,120,64,74,37,196,54,100,49,35,188,36,5,68,184,208,113,187, +194,80,212,75,146,1,73,196,54,100,49,35,188,38,57,37,56,240,0,0,0,0,0,0,0, +0,32,235,248,68,48,156,2,24,94,24,0,243,119,10,139,144,123,242,3,102,238, +18,239,115,72,217,160,11,223,16,23,55,113,241,32,145,36,57,188,18,16,102,3, +5,120,35,34,89,32,15,180,152,173,127,0,218,235,88,0,228,180,227,200,127, +248,0,0,0,0,0,0,197,107,240,64,6,77,220,24,38,78,74,113,67,77,130,4,12,155, +185,52,48,156,148,226,134,155,4,10,194,96,129,132,166,238,45,194,2,201,193, +130,100,228,167,20,52,216,32,113,41,187,139,112,128,178,114,104,97,57,41, +197,13,54,8,32,48,216,32,130,195,224,130,19,97,124,134,23,6,0,57,137,62,77, +12,38,12,0,179,18,124,45,22,190,96,128,141,176,134,28,98,79,180,152,139, +218,45,124,193,1,27,97,16,32,196,159,24,230,204,246,194,40,89,137,62,210, +98,103,92,217,158,216,70,7,49,39,193,130,100,182,17,194,140,73,246,147,16, +250,9,146,216,72,6,49,39,193,131,22,194,72,73,137,62,210,98,31,65,139,97, +40,32,196,159,14,234,70,86,194,88,89,137,62,210,98,63,93,72,202,216,76,10, +49,39,198,33,180,153,37,108,38,134,152,147,237,38,38,117,13,164,201,43,97, +56,40,196,159,36,65,57,163,149,176,158,26,98,79,180,152,165,210,9,205,28, +173,133,0,243,18,124,98,22,180,72,130,115,71,43,97,68,72,196,159,105,49,51, +168,90,209,34,9,205,28,173,133,33,19,18,124,154,24,76,185,164,227,138,89, +18,119,0,7,145,39,201,161,132,188,64,124,137,62,49,11,90,36,65,57,163,149, +210,166,37,34,79,180,152,153,212,45,104,145,4,230,142,87,74,160,84,137,62, +72,130,115,71,43,171,234,134,200,147,237,38,41,116,130,115,71,43,171,235,5, +72,147,227,16,218,76,146,186,254,184,108,137,62,210,98,103,80,218,76,146, +186,254,192,68,137,62,29,212,140,174,207,178,23,34,79,180,152,143,215,82, +50,187,62,208,60,137,62,12,19,37,210,182,21,34,79,180,152,135,208,76,151, +74,224,68,137,62,49,205,153,238,175,186,23,34,79,180,152,153,215,54,103, +186,190,240,92,137,62,22,139,95,48,64,70,235,251,225,210,36,251,73,136,189, +162,215,204,16,17,186,255,2,14,98,79,152,32,35,108,48,64,242,36,249,130,2, +55,75,6,212,224,72,200,51,128,114,108,28,100,128,0,0,0,0,0,0,0,12,110,127, +48,98,115,249,201,117,243,249,195,21,159,206,38,47,63,156,86,8,75,144,94, +82,1,38,73,79,208,67,95,233,1,6,128,14,79,129,186,40,249,18,149,182,207, +144,200,155,188,248,204,105,184,207,142,199,137,175,201,0,159,72,10,5,21, +221,10,120,74,129,124,36,98,232,228,74,81,62,160,20,10,107,186,21,114,32, +105,137,194,70,46,142,68,165,19,235,1,64,170,187,161,119,34,66,146,36,104, +137,194,70,46,142,68,165,19,236,1,64,174,187,161,95,37,134,204,23,225,35, +23,71,34,82,137,246,128,160,89,93,208,167,147,195,201,194,70,46,142,68,165, +19,238,1,64,182,187,161,71,105,20,19,177,139,163,145,41,68,16,7,6,15,82,70, +72,115,96,32,106,2,128,0,0,0,0,91,60,165,195,201,194,8,134,149,216,162,0, +192,41,225,8,2,48,177,36,1,149,13,196,15,0,200,209,97,199,128,99,32,176, +195,192,113,57,143,0,167,133,32,230,80,28,202,139,175,238,2,48,189,192,20, +1,119,80,87,193,186,129,89,56,72,197,209,200,193,185,35,23,71,109,13,219, +36,98,232,237,156,13,26,208,211,14,102,19,87,137,91,95,128,0,10,96,24,92,0, +0,83,2,53,56,0,0,165,3,28,204,160,160,226,100,226,200,211,76,241,240,0,1, +102,8,22,75,64,137,73,20,230,105,133,7,19,39,22,70,154,103,143,128,0,11,48, +20,28,76,156,113,75,34,78,62,0,0,45,3,103,31,0,0,22,65,44,57,137,62,33,179, +216,162,152,192,131,18,124,162,27,61,138,41,108,32,196,159,16,217,232,235, +81,76,104,73,137,62,81,13,158,142,181,20,184,16,98,79,136,108,244,244,168, +166,56,36,196,159,40,134,207,79,74,138,93,10,49,39,194,173,192,158,158,149, +20,188,20,98,79,133,91,129,61,109,74,41,124,30,68,159,16,217,236,83,108,96, +68,137,62,81,13,158,197,54,182,17,34,79,136,108,244,117,169,182,52,38,68, +159,40,134,207,71,90,155,92,8,145,39,196,54,122,122,84,219,28,19,34,79,148, +67,103,167,165,77,174,133,72,147,225,86,224,79,79,74,155,94,10,145,39,194, +173,192,158,182,165,54,190,206,25,212,35,208,226,100,150,211,201,29,162,44, +140,35,103,0,255,192,0,0,0,0,0,0,206,25,228,35,208,226,100,150,211,201,29, +162,44,140,35,103,0,255,192,0,0,0,0,0,0,206,25,244,35,208,226,100,150,211, +201,29,162,44,140,35,103,0,255,192,0,0,0,0,0,0,206,26,4,35,208,226,100,150, +211,201,29,162,44,140,35,103,1,0,0,0,0,0,0,0,0,206,26,20,35,208,226,100, +150,211,201,29,162,44,140,35,103,1,0,0,0,0,0,0,0,0,206,26,36,35,208,226, +100,150,211,201,29,162,44,140,35,103,1,0,64,0,0,0,0,0,0,206,26,52,35,208, +226,100,150,211,201,29,162,44,140,35,103,1,0,64,0,0,0,0,0,0,206,26,68,35, +208,226,100,150,211,201,29,162,44,140,35,103,1,0,64,0,0,0,0,0,0,206,26,84, +35,208,226,100,150,211,201,29,162,44,140,35,103,1,0,128,0,0,0,0,0,0,195, +154,99,16,38,36,0,251,68,117,179,216,162,128,68,72,1,241,13,158,197,20,150, +25,18,0,125,162,58,217,232,235,117,100,162,136,25,18,0,125,162,58,217,232, +235,116,36,162,145,2,226,64,15,136,108,244,117,186,178,81,73,129,113,32,7, +196,54,122,58,221,9,40,165,64,200,144,3,237,17,214,207,79,75,171,37,20,80, +200,144,3,237,17,214,207,79,75,161,37,20,138,23,18,0,124,67,103,167,165, +213,146,138,77,11,137,0,62,33,179,211,210,232,73,69,42,133,196,128,31,10, +183,2,125,89,40,163,5,196,128,31,10,183,2,125,9,40,164,96,200,144,3,224, +221,64,172,157,89,40,163,134,68,128,31,6,234,5,100,232,73,69,35,133,68,128, +31,104,142,182,125,89,40,180,0,168,144,3,237,17,214,207,161,37,22,144,19, +18,0,124,67,103,213,146,139,80,9,137,0,62,33,179,232,73,69,172,5,90,40,153, +59,68,117,179,216,166,192,77,162,137,147,136,108,246,41,180,176,219,69,19, +39,104,142,182,122,58,221,89,41,178,6,218,40,153,59,68,117,179,209,214,232, +73,77,162,6,90,40,153,56,134,207,71,91,171,37,54,152,25,104,162,100,226,27, +61,29,110,132,148,218,160,109,162,137,147,180,71,91,61,61,46,172,148,217, +67,109,20,76,157,162,58,217,233,233,116,36,166,209,67,45,20,76,156,67,103, +167,165,213,146,155,77,12,180,81,50,113,13,158,158,151,66,74,109,84,50,209, +68,201,194,173,192,159,86,74,108,193,150,138,38,78,21,110,4,250,18,83,104, +193,182,138,38,78,13,212,10,201,213,146,155,56,109,162,137,147,131,117,2, +178,116,36,166,209,194,237,20,76,157,162,58,217,245,100,167,16,2,237,20,76, +157,162,58,217,244,36,167,18,2,173,20,76,156,67,103,213,146,156,80,10,180, +81,50,113,13,159,66,74,113,97,175,221,48,216,110,64,4,42,22,189,179,0,196, +133,0,185,80,32,28,78,99,193,18,80,36,4,19,159,141,172,0,178,90,4,74,73,0, +22,209,68,201,187,129,4,2,8,3,132,64,60,36,4,0,91,240,168,177,69,118,144, +157,91,116,116,32,32,1,53,216,221,218,170,139,3,234,219,165,0,255,152,185, +11,251,232,231,188,47,86,227,105,18,1,255,184,170,59,41,92,23,240,110,173, +198,209,208,36,3,253,188,183,177,82,110,80,224,93,122,32,32,4,144,253,170, +34,22,140,7,236,161,25,232,237,105,64,63,230,160,158,102,127,59,205,11,217, +66,51,210,128,127,237,65,60,204,254,119,155,171,197,34,168,48,6,90,194,1,0, +39,75,88,72,8,9,33,186,194,80,64,76,13,214,19,2,130,96,110,150,189,0,65,6, +51,214,20,128,65,17,11,214,19,130,137,121,211,210,211,144,6,39,75,88,80,0, +201,119,235,10,8,41,86,231,71,88,80,129,79,135,186,122,133,224,34,25,69, +234,80,3,91,141,172,40,96,139,113,180,181,133,36,21,110,54,142,134,176,165, +1,176,23,213,47,0,216,134,234,215,128,111,117,181,232,128,209,3,70,230,107, +64,5,139,168,209,235,10,32,36,144,102,235,136,3,146,27,172,40,160,146,132, +103,172,40,192,115,3,117,133,28,22,113,163,69,172,41,103,1,66,188,17,145, +52,168,4,202,113,67,76,130,227,76,194,13,240,108,0,0,83,224,0,2,193,0,104, +146,84,97,48,0,1,94,192,56,169,24,145,179,192,0,5,112,8,56,16,32,128,56,18, +52,125,230,86,147,190,140,28,50,21,13,39,31,23,60,145,158,57,12,141,47,129, +6,155,194,188,24,49,39,199,89,188,124,92,242,70,120,224,201,33,69,15,155, +163,201,68,14,49,39,199,197,211,116,240,242,113,197,232,18,180,254,36,3,17, +46,18,243,35,100,128,172,156,178,70,163,154,76,34,248,146,164,108,248,75, +204,141,146,28,217,115,137,27,95,27,241,173,236,162,160,224,200,2,206,9, +113,13,148,192,209,18,22,164,146,37,193,57,162,4,249,39,196,128,24,2,178, +66,213,136,68,201,16,77,209,131,31,192,242,88,96,92,191,151,34,100,136,38, +232,255,252,92,221,199,197,12,68,209,82,66,212,11,155,185,41,197,13,55,38, +3,66,213,47,135,254,72,12,162,99,133,116,112,0,1,72,66,14,16,16,50,37,202, +160,150,154,66,14,20,8,57,192,28,24,80,113,50,113,100,105,166,120,248,0,0, +179,1,65,196,201,199,20,178,36,227,224,0,2,208,54,113,240,0,1,100,11,181, +192,0,5,178,1,18,160,65,24,131,20,145,25,188,48,132,122,28,76,146,218,121, +35,180,69,145,132,108,224,31,248,0,0,0,0,0,0,25,188,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,183,32,29,235,2,27,199,23,0,0,23,4,51,120,129,8,244,56,153, +37,180,242,71,104,139,35,8,217,192,63,240,0,0,0,0,0,0,51,120,145,8,244,56, +153,37,180,242,71,104,139,35,8,217,192,64,0,0,0,0,0,0,0,51,120,161,8,244, +56,153,37,180,242,71,104,139,35,8,217,192,64,0,0,0,0,0,0,0,51,120,177,8, +244,56,153,37,180,242,71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51,120,193, +8,244,56,153,37,180,242,71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51,120, +209,8,244,56,153,37,180,242,71,104,139,35,8,217,192,64,16,0,0,0,0,0,0,51, +120,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,246,104,5,34,92,35,68,225,161,166,220,16,16,137, +112,52,41,73,29,185,1,65,196,201,197,145,166,153,246,72,3,137,204,120,34, +74,8,199,1,67,17,162,112,201,84,128,97,144,78,25,42,16,131,169,1,205,66,8, +35,68,225,161,166,239,128,0,10,192,64,196,104,156,50,96,0,2,172,73,240,117, +96,57,170,97,4,104,156,52,52,221,240,0,1,82,1,74,9,129,125,240,0,1,82,32, +148,25,174,137,58,23,51,190,0,0,42,69,64,195,32,156,50,96,0,2,160,81,238,2, +3,107,173,218,3,192, }; #elif defined(DUK_USE_DOUBLE_ME) -DUK_INTERNAL const duk_uint8_t duk_builtins_data[4251] = { -144,148,105,225,32,68,52,228,126,12,104,201,37,132,52,167,194,138,105,244, -124,57,28,211,57,18,64,52,238,254,44,138,111,171,241,164,19,87,137,30,33, -167,18,145,159,8,211,137,9,225,42,5,240,145,139,163,163,8,211,137,10,228, -64,211,19,132,140,93,29,56,70,156,72,119,34,66,146,36,104,137,194,70,46, -142,172,35,78,36,47,146,195,102,11,240,145,139,163,175,8,211,137,9,228,240, -242,112,145,139,163,179,8,211,137,8,237,34,130,118,49,116,118,225,26,48,0, -1,94,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, -33,8,66,26,180,41,97,167,64,150,34,33,154,112,0,1,87,247,35,79,103,237,198, -174,216,47,31,23,95,17,13,31,217,96,211,49,50,53,212,77,141,24,0,0,179,10, -228,240,242,15,128,140,65,128,134,188,0,0,89,167,97,181,224,0,2,205,62,53, -224,0,2,205,66,237,120,0,0,179,81,204,107,192,0,5,154,150,67,94,0,0,44,212, -245,90,240,0,1,102,169,162,215,128,0,11,53,93,150,188,0,0,89,171,111,53, -108,150,163,70,0,0,42,2,249,50,94,124,35,68,225,146,49,13,24,0,0,165,161, -124,153,47,62,12,130,112,201,24,132,56,97,115,16,0,0,62,31,192,0,0,0,51,48, -0,0,60,31,192,0,0,0,50,241,32,26,193,55,132,112,161,156,72,135,26,41,200, -140,114,163,156,201,7,56,79,9,80,47,132,140,93,19,160,43,145,3,76,78,18,49, -116,78,144,238,68,133,36,72,209,19,132,140,93,19,168,47,146,195,102,11,240, -145,139,162,117,132,242,120,121,56,72,197,209,59,2,59,72,160,157,140,93,19, -181,36,242,50,143,36,31,131,162,166,7,144,238,133,227,226,235,224,242,161, -249,18,21,100,20,207,44,199,151,180,122,89,135,152,154,121,153,199,156,158, -121,218,7,158,162,121,250,71,160,166,122,26,135,162,170,122,58,199,164,16, -240,70,68,226,27,51,199,138,120,35,34,112,171,112,38,121,1,124,153,47,62, -17,162,112,201,19,211,11,228,201,121,240,100,19,134,72,158,160,91,201,18, -186,44,3,68,79,122,168,151,115,165,40,21,18,227,65,198,231,200,8,68,184,84, -53,19,38,120,128,145,144,78,25,59,72,163,48,64,144,200,39,12,157,164,80,46, -185,143,115,72,217,230,72,9,35,68,225,147,180,138,51,68,9,17,162,112,201, -218,69,2,235,152,247,52,141,158,108,128,98,72,64,121,51,132,4,81,164,144, -128,242,104,136,0,16,92,38,14,49,39,199,197,211,116,240,242,113,197,231,18, -53,189,116,65,131,18,124,117,155,199,197,207,36,103,142,12,146,20,80,249, -186,60,116,4,204,73,241,214,111,31,23,60,145,158,56,208,48,146,229,146,3,2, -82,65,155,195,94,3,10,36,4,201,196,64,56,100,42,26,78,62,46,121,35,60,113, -152,16,25,10,134,147,143,139,158,72,205,4,151,21,0,73,16,11,230,144,12,88, -144,153,39,52,144,69,241,37,72,217,240,151,153,27,36,57,178,230,16,16,137, -114,68,2,200,62,81,1,8,151,11,23,100,141,229,18,6,34,92,37,230,70,201,1,89, -57,36,2,40,152,151,44,129,83,18,124,117,155,199,197,207,36,103,142,75,12, -11,151,46,89,40,18,37,200,64,12,154,236,252,238,185,23,95,213,1,132,234,0, -194,245,128,14,56,37,199,89,188,124,92,242,70,120,232,16,26,137,113,241, -116,221,60,60,156,113,122,36,10,62,46,121,35,60,113,18,225,27,70,18,32,10, -201,211,32,67,107,104,100,42,26,78,24,147,153,35,181,181,207,64,67,107,104, -100,42,26,78,72,147,153,35,181,181,207,68,16,218,218,91,156,170,63,134,36, -230,72,237,109,116,136,16,218,218,91,156,170,63,146,36,230,72,237,109,116, -137,16,96,128,228,2,6,191,46,3,71,147,68,4,16,22,188,169,240,16,40,104,242, -135,198,171,44,68,65,5,217,231,215,6,231,62,188,8,49,1,3,162,92,4,98,12,41, -7,33,148,53,242,128,97,32,130,3,9,205,16,38,199,198,14,9,0,111,115,225,0,8, -250,72,240,207,128,241,37,73,25,18,40,0,178,58,11,56,192,2,201,104,17,35, -160,9,39,70,114,8,6,147,214,129,18,74,240,30,141,145,208,89,203,62,3,161, -163,37,248,226,185,244,11,88,37,62,33,163,37,248,226,185,252,0,127,255,130, -146,164,142,32,26,1,36,230,18,1,164,7,43,163,194,0,71,128,105,64,216,7,192, -52,192,197,66,230,72,192,52,224,209,32,232,34,68,62,129,113,32,232,34,114, -40,49,231,16,254,0,63,255,208,99,2,140,44,92,206,8,224,143,4,225,147,210, -124,13,44,92,206,9,195,39,30,228,54,126,163,225,200,169,198,133,42,166,191, -246,3,11,251,0,24,71,4,120,9,251,8,10,17,193,30,9,195,39,1,63,105,1,98,112, -201,199,185,13,159,1,63,105,32,48,156,209,2,126,227,224,58,26,50,95,142,47, -192,208,22,176,74,124,67,70,75,241,197,248,26,64,213,184,64,89,56,39,49, -224,137,62,36,2,176,19,17,254,68,3,196,143,88,4,79,162,0,210,32,34,35,253, -72,5,146,208,34,125,144,5,147,214,137,253,208,9,149,3,41,197,13,55,233,0, -185,187,139,117,137,30,8,18,39,172,1,25,187,139,112,128,178,113,110,177,35, -193,2,68,245,128,23,55,114,143,121,35,193,2,68,245,130,8,205,220,91,132,5, -147,148,123,201,30,8,18,39,172,16,18,113,67,63,128,3,68,143,32,39,243,32, -42,83,4,103,46,89,19,63,224,208,16,70,142,92,178,38,127,193,164,8,67,68, -186,12,146,247,154,1,165,64,202,113,252,160,131,32,7,35,167,26,50,235,231, -130,48,179,192,65,148,69,19,214,2,251,85,2,232,72,31,255,253,239,255,255, -255,255,226,122,196,55,106,160,93,9,0,0,0,0,0,4,0,0,3,49,0,0,3,225,252,0,0, -0,0,143,94,233,34,104,169,54,144,210,161,168,158,32,0,0,120,63,128,0,0,0, -17,235,72,96,77,21,38,210,26,84,53,19,196,0,0,15,15,240,0,0,0,0,253,35,228, -133,185,176,0,0,44,15,0,0,0,0,8,117,128,190,212,128,82,109,33,179,33,137, -24,31,255,231,232,127,255,255,255,228,58,196,55,106,64,41,54,144,217,144, -196,140,15,255,243,252,63,255,255,255,241,15,4,100,78,33,179,60,120,167, -130,50,39,10,183,2,103,144,113,8,151,10,134,162,100,221,16,18,137,113,13, -153,12,72,238,137,1,81,46,52,28,110,232,148,53,18,228,128,82,113,13,153,12, -72,238,137,142,73,78,52,0,0,0,0,0,0,0,0,8,58,254,1,12,38,248,134,23,130,0, -60,221,194,162,228,30,244,128,217,187,132,187,220,210,54,104,2,247,132,5, -205,220,124,72,36,73,14,110,252,132,25,128,193,94,8,200,149,200,3,237,38, -43,31,192,54,186,213,128,57,45,56,210,0,0,62,31,192,0,0,0,49,90,251,224,6, -77,220,24,38,78,74,113,67,77,124,16,50,110,228,208,194,114,83,138,26,107, -224,172,37,240,97,41,187,139,112,128,178,112,96,153,57,41,197,13,53,240, -113,41,187,139,112,128,178,114,104,97,57,41,197,13,53,240,128,195,95,8,44, -61,240,132,216,93,33,133,192,128,14,98,79,147,67,9,129,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,181,55,136, -200,51,128,114,108,28,100,128,0,0,0,0,0,0,0,12,110,127,32,98,115,249,73, -117,243,249,67,21,159,202,38,47,63,148,86,8,75,144,94,50,1,38,73,79,204,67, -95,231,1,6,128,14,79,129,185,40,249,18,149,181,207,142,199,155,172,248,172, -89,183,207,140,198,137,175,200,0,159,72,10,5,21,220,138,120,74,129,124,36, -98,232,228,74,81,62,160,20,10,107,185,21,114,32,105,137,194,70,46,142,68, -165,19,235,1,64,170,187,145,119,34,66,146,36,104,137,194,70,46,142,68,165, -19,236,1,64,174,187,145,95,37,134,204,23,225,35,23,71,34,82,137,246,128, -160,89,93,200,167,147,195,201,194,70,46,142,68,165,19,238,1,64,182,187,145, -71,105,20,19,177,139,163,145,41,68,16,7,6,15,82,70,72,115,96,0,118,105,160, -0,0,0,0,91,60,165,195,201,194,8,134,149,216,130,0,192,41,224,136,2,48,176, -228,1,149,13,195,15,0,200,209,97,71,128,99,32,176,131,192,113,57,143,0,167, -131,32,230,80,28,202,139,175,237,2,48,189,160,20,1,119,48,87,193,186,129, -89,56,72,197,209,200,193,185,35,23,71,109,13,219,36,98,232,237,156,13,26, -208,211,14,102,19,87,137,91,95,128,0,10,64,24,92,0,0,82,2,53,63,240,49,204, -202,10,14,38,78,44,141,52,207,31,0,0,22,32,129,100,180,8,148,145,78,102, -152,80,113,50,113,100,105,166,120,248,0,0,177,1,65,196,201,199,20,178,36, -227,224,0,2,200,3,6,133,41,35,31,0,0,22,1,44,57,137,62,33,179,216,162,152, -192,131,18,124,162,27,61,138,41,108,32,196,159,16,217,232,235,81,76,104,73, -137,62,81,13,158,142,181,20,184,16,98,79,136,108,244,244,168,166,56,36,196, -159,40,134,207,79,74,138,93,10,49,39,194,173,192,158,158,149,20,188,20,98, -79,133,91,129,61,109,74,41,124,30,68,159,16,217,236,83,108,96,68,137,62,81, -13,158,197,54,182,17,34,79,136,108,244,117,169,182,52,38,68,159,40,134,207, -71,90,155,92,8,145,39,196,54,122,122,84,219,28,19,34,79,148,67,103,167,165, -77,174,133,72,147,225,86,224,79,79,74,155,94,10,145,39,194,173,192,158,182, -165,54,190,206,25,212,35,208,226,100,150,211,201,29,162,44,140,35,103,0,0, -3,192,252,0,0,0,0,206,25,228,35,208,226,100,150,211,201,29,162,44,140,35, -103,0,0,3,192,252,0,0,0,0,206,25,244,35,208,226,100,150,211,201,29,162,44, -140,35,103,0,0,3,192,252,0,0,0,0,206,26,4,35,208,226,100,150,211,201,29, -162,44,140,35,103,0,0,0,1,0,0,0,0,0,206,26,20,35,208,226,100,150,211,201, -29,162,44,140,35,103,0,0,0,1,0,0,0,0,0,206,26,36,35,208,226,100,150,211, -201,29,162,44,140,35,103,0,0,0,65,0,0,0,0,0,206,26,52,35,208,226,100,150, -211,201,29,162,44,140,35,103,0,0,0,65,0,0,0,0,0,206,26,68,35,208,226,100, -150,211,201,29,162,44,140,35,103,0,0,0,65,0,0,0,0,0,206,26,84,35,208,226, -100,150,211,201,29,162,44,140,35,103,0,0,0,129,0,0,0,0,0,195,154,99,16,38, -36,0,251,68,117,179,216,162,128,68,72,1,241,13,158,197,20,150,25,18,0,125, -162,58,217,232,235,117,100,162,136,25,18,0,125,162,58,217,232,235,116,36, -162,145,2,226,64,15,136,108,244,117,186,178,81,73,129,113,32,7,196,54,122, -58,221,9,40,165,64,200,144,3,237,17,214,207,79,75,171,37,20,80,200,144,3, -237,17,214,207,79,75,161,37,20,138,23,18,0,124,67,103,167,165,213,146,138, -77,11,137,0,62,33,179,211,210,232,73,69,42,133,196,128,31,10,183,2,125,89, -40,163,5,196,128,31,10,183,2,125,9,40,164,96,200,144,3,224,221,64,172,157, -89,40,163,134,68,128,31,6,234,5,100,232,73,69,35,133,68,128,31,104,142,182, -125,89,40,180,0,168,144,3,237,17,214,207,161,37,22,144,19,18,0,124,67,103, -213,146,139,80,9,137,0,62,33,179,232,73,69,172,5,90,40,153,59,68,117,179, -216,166,192,77,162,137,147,136,108,246,41,180,176,219,69,19,39,104,142,182, -122,58,221,89,41,178,6,218,40,153,59,68,117,179,209,214,232,73,77,162,6,90, -40,153,56,134,207,71,91,171,37,54,152,25,104,162,100,226,27,61,29,110,132, -148,218,160,109,162,137,147,180,71,91,61,61,46,172,148,217,67,109,20,76, -157,162,58,217,233,233,116,36,166,209,67,45,20,76,156,67,103,167,165,213, -146,155,77,12,180,81,50,113,13,158,158,151,66,74,109,84,50,209,68,201,194, -173,192,159,86,74,108,193,150,138,38,78,21,110,4,250,18,83,104,193,182,138, -38,78,13,212,10,201,213,146,155,56,109,162,137,147,131,117,2,178,116,36, -166,209,194,237,20,76,157,162,58,217,245,100,167,16,2,237,20,76,157,162,58, -217,244,36,167,18,2,173,20,76,156,67,103,213,146,156,80,10,180,81,50,113, -13,159,66,74,113,97,175,220,48,216,109,192,4,42,22,189,163,0,196,133,0,185, -80,32,28,78,99,193,18,80,36,4,19,159,141,156,0,178,90,4,74,73,0,22,209,68, -201,185,129,4,2,8,3,132,64,60,36,0,171,240,84,6,149,113,72,176,157,91,116, -116,32,88,181,129,32,11,42,218,221,131,234,219,165,1,8,187,152,255,188,231, -235,248,47,86,227,105,18,2,56,175,185,255,244,17,91,40,110,173,198,209,208, -36,7,188,189,179,240,238,82,97,80,93,122,32,125,144,132,160,12,22,162,42,7, -236,161,25,232,237,105,64,158,160,230,63,205,59,127,102,11,217,66,51,210, -129,61,65,236,127,154,118,254,205,171,197,34,168,48,6,90,162,1,0,39,75,84, -72,8,9,33,186,162,80,64,76,13,213,19,2,130,96,110,150,181,0,65,6,51,213,20, -128,65,17,11,213,19,130,137,121,211,210,210,144,6,39,75,84,80,0,201,119, -234,138,8,41,86,231,71,84,80,129,79,135,186,122,101,224,34,25,69,233,208,3, -91,141,170,40,96,139,113,180,181,69,36,21,110,54,142,134,168,165,1,176,23, -212,47,0,216,134,234,87,128,111,117,181,168,128,209,3,70,230,106,192,5,139, -168,209,234,138,32,36,144,102,235,8,3,146,27,170,40,160,146,132,103,170,40, -192,115,3,117,69,28,22,113,163,69,170,41,103,1,66,188,17,145,52,104,4,202, -113,67,76,130,227,72,194,13,240,108,0,0,83,96,0,2,185,0,104,146,84,97,48,0, -1,90,192,56,169,24,145,179,192,0,5,96,8,56,16,32,128,56,18,52,125,198,86, -147,186,140,28,50,21,13,39,31,23,60,145,158,56,204,141,47,121,6,155,190, -188,24,49,39,199,89,188,124,92,242,70,120,224,201,33,69,15,155,163,199,68, -14,49,39,199,197,211,116,240,242,113,197,231,18,180,254,4,3,17,46,18,243, -35,100,128,172,156,146,70,163,150,76,34,248,146,164,108,248,75,204,141,146, -28,217,115,9,27,79,11,241,173,235,162,160,224,200,2,206,9,113,13,148,192, -209,18,22,164,146,37,193,57,162,4,249,39,196,128,24,2,178,66,213,136,68, -201,16,77,209,131,31,192,242,88,96,92,191,151,34,100,136,38,232,255,252,92, -221,199,197,12,68,209,82,66,212,11,155,185,41,197,13,55,38,3,66,213,47,131, -250,72,12,162,99,133,116,127,196,32,225,1,3,34,92,170,9,105,164,32,225,64, -131,156,1,193,133,7,19,39,22,70,154,103,143,128,0,11,16,20,28,76,156,113, -75,34,78,62,0,0,44,128,48,104,82,146,49,240,0,1,96,11,180,192,0,5,162,1,18, -160,65,24,131,20,145,25,188,48,132,122,28,76,146,218,121,35,180,69,145,132, -108,224,0,0,120,31,128,0,0,0,25,188,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, -181,32,29,235,2,27,199,23,0,0,22,196,51,120,129,8,244,56,153,37,180,242,71, -104,139,35,8,217,192,0,0,240,63,0,0,0,0,51,120,145,8,244,56,153,37,180,242, -71,104,139,35,8,217,192,0,0,0,64,0,0,0,0,51,120,161,8,244,56,153,37,180, -242,71,104,139,35,8,217,192,0,0,0,64,0,0,0,0,51,120,177,8,244,56,153,37, -180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51,120,193,8,244,56,153, -37,180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51,120,209,8,244,56, -153,37,180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51,120,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,246,40,5,34,92,35,68,225,161,166,219,16,16,137,112,52,41,73,29, -169,1,65,196,201,197,145,166,153,246,8,3,137,204,120,34,74,8,200,58,128,28, -211,160,130,52,78,26,26,110,248,0,0,170,4,12,70,137,195,38,0,0,42,68,159,7, -84,3,154,150,16,70,137,195,67,77,223,0,0,20,224,20,160,152,23,223,0,0,20, -226,9,65,154,232,147,161,115,59,224,0,2,156,84,12,50,9,195,38,0,0,41,133, -30,224,32,54,186,221,128,60, +DUK_INTERNAL const duk_uint8_t duk_builtins_data[4281] = { +144,148,105,226,32,68,52,228,254,12,104,202,37,132,52,167,194,138,105,245, +124,57,28,211,57,18,64,52,239,126,44,138,111,175,241,164,19,87,145,30,33, +167,22,145,159,8,211,139,9,225,42,5,240,145,139,163,163,8,211,139,10,228, +64,211,19,132,140,93,29,56,70,156,88,119,34,66,146,36,104,137,194,70,46, +142,172,35,78,44,47,146,195,102,11,240,145,139,163,175,8,211,139,9,228,240, +242,112,145,139,163,179,8,211,139,8,237,34,130,118,49,116,118,225,26,48,0, +1,98,29,201,158,46,183,39,135,147,132,140,93,16,132,76,66,33,8,66,16,132, +33,8,66,26,180,105,97,167,68,150,34,33,154,112,0,1,91,247,35,79,111,237, +198,174,232,47,31,23,95,17,13,31,249,96,211,49,50,53,214,77,141,24,0,0,181, +10,228,240,242,15,128,140,65,128,134,188,0,0,90,167,97,181,224,0,2,213,62, +53,224,0,2,213,66,237,120,0,0,181,81,204,107,192,0,5,170,150,67,94,0,0,45, +84,245,90,240,0,1,106,169,162,215,128,0,11,85,93,150,188,0,0,90,171,111,53, +109,22,162,26,48,0,1,84,23,201,146,243,225,26,39,12,145,136,104,192,0,5,61, +11,228,201,121,240,100,19,134,72,196,33,195,14,40,203,112,64,190,76,232, +145,153,136,0,0,31,15,224,0,0,0,25,152,0,0,30,15,224,0,0,0,25,120,144,13, +96,155,194,56,80,206,36,67,141,20,228,70,57,81,206,100,131,156,39,132,168, +23,194,70,46,137,208,21,200,129,166,39,9,24,186,39,72,119,34,66,146,36,104, +137,194,70,46,137,212,23,201,97,179,5,248,72,197,209,58,194,121,60,60,156, +36,98,232,157,129,29,164,80,78,198,46,137,218,146,121,25,71,146,9,209,5, +209,61,48,126,14,138,152,30,67,186,23,143,139,175,131,202,135,228,72,85, +144,83,60,179,30,94,209,233,102,30,98,105,230,103,30,114,121,231,104,30, +122,137,231,233,30,130,153,232,106,30,138,169,232,235,30,144,67,193,25,19, +136,108,207,30,41,224,140,137,194,173,192,153,228,5,242,100,188,248,70,137, +195,36,79,78,47,147,37,231,193,144,78,25,34,122,145,111,36,74,232,176,13, +17,61,234,226,93,207,148,160,84,75,141,7,27,161,32,33,18,225,80,212,76,154, +2,2,70,65,56,100,237,34,140,209,2,67,32,156,50,118,145,64,186,230,61,205, +35,103,155,32,36,141,19,134,78,210,40,206,16,36,70,137,195,39,105,20,11, +174,99,220,210,54,121,210,1,137,33,1,228,207,16,17,70,146,66,3,201,164,32, +0,65,112,152,56,196,159,31,23,77,211,195,201,199,23,160,72,214,246,81,6,12, +73,241,214,111,31,23,60,145,158,56,50,72,81,67,230,232,242,80,19,49,39,199, +89,188,124,92,242,70,120,227,64,194,75,154,72,12,9,73,6,111,21,120,12,40, +144,19,39,25,0,225,144,168,105,56,248,185,228,140,241,200,96,64,100,42,26, +78,62,46,121,35,52,18,92,116,1,36,64,47,158,64,49,98,66,100,156,242,65,23, +196,149,35,103,194,94,100,108,144,230,203,156,64,66,37,201,16,11,32,249, +132,4,34,92,44,93,146,55,152,72,24,137,112,151,153,27,36,5,100,229,144,8, +162,98,92,210,5,76,73,241,214,111,31,23,60,145,158,57,44,48,46,92,185,164, +160,72,151,41,0,50,107,179,244,59,36,93,127,92,6,19,172,3,11,216,0,56,224, +151,29,102,241,241,115,201,25,227,164,64,106,37,199,197,211,116,240,242, +113,197,233,144,40,248,185,228,140,241,196,75,132,109,24,72,128,43,39,84, +129,13,173,161,144,168,105,56,98,78,100,142,214,215,69,1,13,173,161,144, +168,105,57,34,78,100,142,214,215,69,16,67,107,105,110,114,168,254,24,147, +153,35,181,181,212,32,67,107,105,110,114,168,254,72,147,153,35,181,181,212, +36,65,130,3,144,8,26,252,200,13,30,85,16,16,64,90,242,231,192,64,161,163, +203,31,26,172,193,17,4,23,105,159,96,27,172,251,16,32,196,4,14,137,112,17, +136,48,164,28,134,80,215,202,1,132,130,8,12,39,52,64,155,31,24,56,36,1,189, +207,132,0,35,233,35,195,62,3,196,149,36,100,72,160,2,200,232,44,227,0,11, +37,160,68,142,128,36,157,25,200,32,26,79,90,4,73,43,192,122,54,71,65,103, +44,248,14,134,140,151,227,138,231,208,45,96,148,248,134,140,151,227,138, +231,240,1,255,254,10,74,146,56,128,104,4,147,152,72,6,144,28,174,143,8,1, +30,1,165,3,96,31,0,211,3,21,11,153,35,0,211,131,68,131,160,137,16,250,5, +196,131,160,137,200,160,199,156,67,248,0,255,255,65,140,10,48,177,115,56, +35,130,60,19,134,79,89,240,52,177,115,56,39,12,156,123,144,217,251,15,135, +34,167,30,20,170,154,255,232,12,47,244,0,97,28,17,224,39,238,32,40,71,4, +120,39,12,156,4,253,228,5,137,195,39,30,228,54,124,4,253,228,128,194,115, +68,9,252,15,128,232,104,201,126,56,191,35,64,90,193,41,241,13,25,47,199,23, +228,105,3,86,225,1,100,224,156,199,130,36,249,144,10,192,76,71,250,16,15, +18,61,96,17,62,200,3,72,128,136,143,247,32,22,75,64,137,248,64,22,79,90,39, +249,64,38,84,12,167,20,52,223,196,2,230,238,45,214,36,120,32,72,158,208,4, +102,238,45,194,2,201,197,186,196,143,4,9,19,218,0,92,221,202,61,228,143,4, +9,19,218,8,35,55,113,110,16,22,78,81,239,36,120,32,72,158,208,64,73,197,12, +255,0,13,18,60,128,159,212,128,169,76,17,156,185,100,76,255,163,64,65,26, +57,114,200,153,255,70,144,33,13,18,232,50,75,226,104,6,149,3,41,199,246, +130,12,128,28,142,156,120,203,175,158,8,194,207,1,6,81,20,79,88,11,237,84, +11,161,32,127,255,247,191,255,255,255,255,137,235,16,221,170,129,116,36,0, +0,0,0,0,16,0,0,12,196,0,0,15,135,240,0,0,0,2,61,123,164,137,162,164,218,67, +74,134,162,120,128,0,1,224,254,0,0,0,0,71,173,33,129,52,84,155,72,105,80, +212,79,16,0,0,60,63,192,0,0,0,3,244,143,146,22,230,192,0,0,176,60,0,0,0,0, +33,214,2,251,82,1,73,180,134,204,134,36,96,127,255,159,161,255,255,255,255, +144,235,16,221,169,0,164,218,67,102,67,18,48,63,255,207,240,255,255,255, +255,196,60,17,145,56,134,204,241,226,158,8,200,156,42,220,9,158,65,196,34, +92,42,26,137,147,120,64,74,37,196,54,100,49,35,188,36,5,68,184,208,113,187, +194,80,212,75,146,1,73,196,54,100,49,35,188,38,57,37,56,240,0,0,0,0,0,0,0, +0,32,235,248,68,48,156,2,24,94,24,0,243,119,10,139,144,123,242,3,102,238, +18,239,115,72,217,160,11,223,16,23,55,113,241,32,145,36,57,188,18,16,102,3, +5,120,35,34,89,32,15,180,152,173,127,0,218,235,88,0,228,180,227,200,0,0, +248,127,0,0,0,0,197,107,240,64,6,77,220,24,38,78,74,113,67,77,130,4,12,155, +185,52,48,156,148,226,134,155,4,10,194,96,129,132,166,238,45,194,2,201,193, +130,100,228,167,20,52,216,32,113,41,187,139,112,128,178,114,104,97,57,41, +197,13,54,8,32,48,216,32,130,195,224,130,19,97,124,134,23,6,0,57,137,62,77, +12,38,12,0,179,18,124,45,22,190,96,128,141,176,134,28,98,79,180,152,139, +218,45,124,193,1,27,97,16,32,196,159,24,230,204,246,194,40,89,137,62,210, +98,103,92,217,158,216,70,7,49,39,193,130,100,182,17,194,140,73,246,147,16, +250,9,146,216,72,6,49,39,193,131,22,194,72,73,137,62,210,98,31,65,139,97, +40,32,196,159,14,234,70,86,194,88,89,137,62,210,98,63,93,72,202,216,76,10, +49,39,198,33,180,153,37,108,38,134,152,147,237,38,38,117,13,164,201,43,97, +56,40,196,159,36,65,57,163,149,176,158,26,98,79,180,152,165,210,9,205,28, +173,133,0,243,18,124,98,22,180,72,130,115,71,43,97,68,72,196,159,105,49,51, +168,90,209,34,9,205,28,173,133,33,19,18,124,154,24,76,185,164,227,138,89, +18,119,0,7,145,39,201,161,132,188,64,124,137,62,49,11,90,36,65,57,163,149, +210,166,37,34,79,180,152,153,212,45,104,145,4,230,142,87,74,160,84,137,62, +72,130,115,71,43,171,234,134,200,147,237,38,41,116,130,115,71,43,171,235,5, +72,147,227,16,218,76,146,186,254,184,108,137,62,210,98,103,80,218,76,146, +186,254,192,68,137,62,29,212,140,174,207,178,23,34,79,180,152,143,215,82, +50,187,62,208,60,137,62,12,19,37,210,182,21,34,79,180,152,135,208,76,151, +74,224,68,137,62,49,205,153,238,175,186,23,34,79,180,152,153,215,54,103, +186,190,240,92,137,62,22,139,95,48,64,70,235,251,225,210,36,251,73,136,189, +162,215,204,16,17,186,255,2,14,98,79,152,32,35,108,48,64,242,36,249,130,2, +55,75,6,212,224,72,200,51,128,114,108,28,100,128,0,0,0,0,0,0,0,12,110,127, +48,98,115,249,201,117,243,249,195,21,159,206,38,47,63,156,86,8,75,144,94, +82,1,38,73,79,208,67,95,233,1,6,128,14,79,129,186,40,249,18,149,182,207, +144,200,155,188,248,204,105,184,207,142,199,137,175,201,0,159,72,10,5,21, +221,10,120,74,129,124,36,98,232,228,74,81,62,160,20,10,107,186,21,114,32, +105,137,194,70,46,142,68,165,19,235,1,64,170,187,161,119,34,66,146,36,104, +137,194,70,46,142,68,165,19,236,1,64,174,187,161,95,37,134,204,23,225,35, +23,71,34,82,137,246,128,160,89,93,208,167,147,195,201,194,70,46,142,68,165, +19,238,1,64,182,187,161,71,105,20,19,177,139,163,145,41,68,16,7,6,15,82,70, +72,115,96,0,2,234,32,0,0,0,0,91,60,165,195,201,194,8,134,149,216,162,0,192, +41,225,8,2,48,177,36,1,149,13,196,15,0,200,209,97,199,128,99,32,176,195, +192,113,57,143,0,167,133,32,230,80,28,202,139,175,238,2,48,189,192,20,1, +119,80,87,193,186,129,89,56,72,197,209,200,193,185,35,23,71,109,13,219,36, +98,232,237,156,13,26,208,211,14,102,19,87,137,91,95,128,0,10,96,24,92,0,0, +83,2,53,56,0,0,165,3,28,204,160,160,226,100,226,200,211,76,241,240,0,1,102, +8,22,75,64,137,73,20,230,105,133,7,19,39,22,70,154,103,143,128,0,11,48,20, +28,76,156,113,75,34,78,62,0,0,45,3,103,31,0,0,22,65,44,57,137,62,33,179, +216,162,152,192,131,18,124,162,27,61,138,41,108,32,196,159,16,217,232,235, +81,76,104,73,137,62,81,13,158,142,181,20,184,16,98,79,136,108,244,244,168, +166,56,36,196,159,40,134,207,79,74,138,93,10,49,39,194,173,192,158,158,149, +20,188,20,98,79,133,91,129,61,109,74,41,124,30,68,159,16,217,236,83,108,96, +68,137,62,81,13,158,197,54,182,17,34,79,136,108,244,117,169,182,52,38,68, +159,40,134,207,71,90,155,92,8,145,39,196,54,122,122,84,219,28,19,34,79,148, +67,103,167,165,77,174,133,72,147,225,86,224,79,79,74,155,94,10,145,39,194, +173,192,158,182,165,54,190,206,25,212,35,208,226,100,150,211,201,29,162,44, +140,35,103,0,0,3,192,252,0,0,0,0,206,25,228,35,208,226,100,150,211,201,29, +162,44,140,35,103,0,0,3,192,252,0,0,0,0,206,25,244,35,208,226,100,150,211, +201,29,162,44,140,35,103,0,0,3,192,252,0,0,0,0,206,26,4,35,208,226,100,150, +211,201,29,162,44,140,35,103,0,0,0,1,0,0,0,0,0,206,26,20,35,208,226,100, +150,211,201,29,162,44,140,35,103,0,0,0,1,0,0,0,0,0,206,26,36,35,208,226, +100,150,211,201,29,162,44,140,35,103,0,0,0,65,0,0,0,0,0,206,26,52,35,208, +226,100,150,211,201,29,162,44,140,35,103,0,0,0,65,0,0,0,0,0,206,26,68,35, +208,226,100,150,211,201,29,162,44,140,35,103,0,0,0,65,0,0,0,0,0,206,26,84, +35,208,226,100,150,211,201,29,162,44,140,35,103,0,0,0,129,0,0,0,0,0,195, +154,99,16,38,36,0,251,68,117,179,216,162,128,68,72,1,241,13,158,197,20,150, +25,18,0,125,162,58,217,232,235,117,100,162,136,25,18,0,125,162,58,217,232, +235,116,36,162,145,2,226,64,15,136,108,244,117,186,178,81,73,129,113,32,7, +196,54,122,58,221,9,40,165,64,200,144,3,237,17,214,207,79,75,171,37,20,80, +200,144,3,237,17,214,207,79,75,161,37,20,138,23,18,0,124,67,103,167,165, +213,146,138,77,11,137,0,62,33,179,211,210,232,73,69,42,133,196,128,31,10, +183,2,125,89,40,163,5,196,128,31,10,183,2,125,9,40,164,96,200,144,3,224, +221,64,172,157,89,40,163,134,68,128,31,6,234,5,100,232,73,69,35,133,68,128, +31,104,142,182,125,89,40,180,0,168,144,3,237,17,214,207,161,37,22,144,19, +18,0,124,67,103,213,146,139,80,9,137,0,62,33,179,232,73,69,172,5,90,40,153, +59,68,117,179,216,166,192,77,162,137,147,136,108,246,41,180,176,219,69,19, +39,104,142,182,122,58,221,89,41,178,6,218,40,153,59,68,117,179,209,214,232, +73,77,162,6,90,40,153,56,134,207,71,91,171,37,54,152,25,104,162,100,226,27, +61,29,110,132,148,218,160,109,162,137,147,180,71,91,61,61,46,172,148,217, +67,109,20,76,157,162,58,217,233,233,116,36,166,209,67,45,20,76,156,67,103, +167,165,213,146,155,77,12,180,81,50,113,13,158,158,151,66,74,109,84,50,209, +68,201,194,173,192,159,86,74,108,193,150,138,38,78,21,110,4,250,18,83,104, +193,182,138,38,78,13,212,10,201,213,146,155,56,109,162,137,147,131,117,2, +178,116,36,166,209,194,237,20,76,157,162,58,217,245,100,167,16,2,237,20,76, +157,162,58,217,244,36,167,18,2,173,20,76,156,67,103,213,146,156,80,10,180, +81,50,113,13,159,66,74,113,97,175,221,48,216,110,64,4,42,22,189,179,0,196, +133,0,185,80,32,28,78,99,193,18,80,36,4,19,159,141,172,0,178,90,4,74,73,0, +22,209,68,201,187,129,4,2,8,3,132,64,60,36,0,171,240,84,6,149,113,72,176, +157,91,116,116,32,88,181,129,32,11,42,218,221,131,234,219,165,1,8,187,152, +255,188,231,235,248,47,86,227,105,18,2,56,175,185,255,244,17,91,40,110,173, +198,209,208,36,7,188,189,179,240,238,82,97,80,93,122,32,125,144,132,160,12, +22,162,42,7,236,161,25,232,237,105,64,158,160,230,63,205,59,127,102,11,217, +66,51,210,129,61,65,236,127,154,118,254,205,171,197,34,168,48,6,90,194,1,0, +39,75,88,72,8,9,33,186,194,80,64,76,13,214,19,2,130,96,110,150,189,0,65,6, +51,214,20,128,65,17,11,214,19,130,137,121,211,210,211,144,6,39,75,88,80,0, +201,119,235,10,8,41,86,231,71,88,80,129,79,135,186,122,133,224,34,25,69, +234,80,3,91,141,172,40,96,139,113,180,181,133,36,21,110,54,142,134,176,165, +1,176,23,213,47,0,216,134,234,215,128,111,117,181,232,128,209,3,70,230,107, +64,5,139,168,209,235,10,32,36,144,102,235,136,3,146,27,172,40,160,146,132, +103,172,40,192,115,3,117,133,28,22,113,163,69,172,41,103,1,66,188,17,145, +52,168,4,202,113,67,76,130,227,76,194,13,240,108,0,0,83,224,0,2,193,0,104, +146,84,97,48,0,1,94,192,56,169,24,145,179,192,0,5,112,8,56,16,32,128,56,18, +52,125,230,86,147,190,140,28,50,21,13,39,31,23,60,145,158,57,12,141,47,129, +6,155,194,188,24,49,39,199,89,188,124,92,242,70,120,224,201,33,69,15,155, +163,201,68,14,49,39,199,197,211,116,240,242,113,197,232,18,180,254,36,3,17, +46,18,243,35,100,128,172,156,178,70,163,154,76,34,248,146,164,108,248,75, +204,141,146,28,217,115,137,27,95,27,241,173,236,162,160,224,200,2,206,9, +113,13,148,192,209,18,22,164,146,37,193,57,162,4,249,39,196,128,24,2,178, +66,213,136,68,201,16,77,209,131,31,192,242,88,96,92,191,151,34,100,136,38, +232,255,252,92,221,199,197,12,68,209,82,66,212,11,155,185,41,197,13,55,38, +3,66,213,47,135,254,72,12,162,99,133,116,112,0,1,72,66,14,16,16,50,37,202, +160,150,154,66,14,20,8,57,192,28,24,80,113,50,113,100,105,166,120,248,0,0, +179,1,65,196,201,199,20,178,36,227,224,0,2,208,54,113,240,0,1,100,11,181, +192,0,5,178,1,18,160,65,24,131,20,145,25,188,48,132,122,28,76,146,218,121, +35,180,69,145,132,108,224,0,0,120,31,128,0,0,0,25,188,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,183,32,29,235,2,27,199,23,0,0,23,4,51,120,129,8,244,56,153, +37,180,242,71,104,139,35,8,217,192,0,0,240,63,0,0,0,0,51,120,145,8,244,56, +153,37,180,242,71,104,139,35,8,217,192,0,0,0,64,0,0,0,0,51,120,161,8,244, +56,153,37,180,242,71,104,139,35,8,217,192,0,0,0,64,0,0,0,0,51,120,177,8, +244,56,153,37,180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51,120,193, +8,244,56,153,37,180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51,120, +209,8,244,56,153,37,180,242,71,104,139,35,8,217,192,0,0,16,64,0,0,0,0,51, +120,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,246,104,5,34,92,35,68,225,161,166,220,16,16,137, +112,52,41,73,29,185,1,65,196,201,197,145,166,153,246,72,3,137,204,120,34, +74,8,199,1,67,17,162,112,201,84,128,97,144,78,25,42,16,131,169,1,205,66,8, +35,68,225,161,166,239,128,0,10,192,64,196,104,156,50,96,0,2,172,73,240,117, +96,57,170,97,4,104,156,52,52,221,240,0,1,82,1,74,9,129,125,240,0,1,82,32, +148,25,174,137,58,23,51,190,0,0,42,69,64,195,32,156,50,96,0,2,160,81,238,2, +3,107,173,218,3,192, }; #else #error invalid endianness defines @@ -12241,6 +12344,90 @@ DUK_INTERNAL duk_size_t duk_unicode_unvalidated_utf8_length(const duk_uint8_t *d } #endif /* DUK_USE_PREFER_SIZE */ +/* Check whether a string is UTF-8 compatible or not. */ +DUK_INTERNAL duk_bool_t duk_unicode_is_utf8_compatible(const duk_uint8_t *buf, duk_size_t len) { + duk_size_t i = 0; +#if !defined(DUK_USE_PREFER_SIZE) + duk_size_t len_safe; +#endif + + /* Many practical strings are ASCII only, so use a fast path check + * to check chunks of bytes at once with minimal branch cost. + */ +#if !defined(DUK_USE_PREFER_SIZE) + len_safe = len & ~0x03UL; + for (; i < len_safe; i += 4) { + duk_uint8_t t = buf[i] | buf[i + 1] | buf[i + 2] | buf[i + 3]; + if (DUK_UNLIKELY((t & 0x80U) != 0U)) { + /* At least one byte was outside 0x00-0x7f, break + * out to slow path (and remain there). + * + * XXX: We could also deal with the problem character + * and resume fast path later. + */ + break; + } + } +#endif + + for (; i < len;) { + duk_uint8_t t; + duk_size_t left; + duk_size_t ncont; + duk_uint32_t cp; + duk_uint32_t mincp; + + t = buf[i++]; + if (DUK_LIKELY((t & 0x80U) == 0U)) { + /* Fast path, ASCII. */ + continue; + } + + /* Non-ASCII start byte, slow path. + * + * 10xx xxxx -> continuation byte + * 110x xxxx + 1*CONT -> [0x80, 0x7ff] + * 1110 xxxx + 2*CONT -> [0x800, 0xffff], must reject [0xd800,0xdfff] + * 1111 0xxx + 3*CONT -> [0x10000, 0x10ffff] + */ + left = len - i; + if (t <= 0xdfU) { /* 1101 1111 = 0xdf */ + if (t <= 0xbfU) { /* 1011 1111 = 0xbf */ + return 0; + } + ncont = 1; + mincp = 0x80UL; + cp = t & 0x1fU; + } else if (t <= 0xefU) { /* 1110 1111 = 0xef */ + ncont = 2; + mincp = 0x800UL; + cp = t & 0x0fU; + } else if (t <= 0xf7U) { /* 1111 0111 = 0xf7 */ + ncont = 3; + mincp = 0x10000UL; + cp = t & 0x07U; + } else { + return 0; + } + if (left < ncont) { + return 0; + } + while (ncont > 0U) { + t = buf[i++]; + if ((t & 0xc0U) != 0x80U) { /* 10xx xxxx */ + return 0; + } + cp = (cp << 6) + (t & 0x3fU); + ncont--; + } + if (cp < mincp || cp > 0x10ffffUL || (cp >= 0xd800UL && cp <= 0xdfffUL)) { + return 0; + } + } + + return 1; +} + /* * Unicode range matcher * @@ -13023,6 +13210,155 @@ DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_not_wordchar[10] = { }; #endif /* DUK_USE_REGEXP_SUPPORT */ +#line 1 "duk_util_memrw.c" +/* + * Macro support functions for reading/writing raw data. + * + * These are done using memcpy to ensure they're valid even for unaligned + * reads/writes on platforms where alignment counts. On x86 at least gcc + * is able to compile these into a bswap+mov. "Always inline" is used to + * ensure these macros compile to minimal code. + */ + +/* #include duk_internal.h -> already included */ + +union duk__u16_union { + duk_uint8_t b[2]; + duk_uint16_t x; +}; +typedef union duk__u16_union duk__u16_union; + +union duk__u32_union { + duk_uint8_t b[4]; + duk_uint32_t x; +}; +typedef union duk__u32_union duk__u32_union; + +#if defined(DUK_USE_64BIT_OPS) +union duk__u64_union { + duk_uint8_t b[8]; + duk_uint64_t x; +}; +typedef union duk__u64_union duk__u64_union; +#endif + +DUK_INTERNAL DUK_ALWAYS_INLINE duk_uint16_t duk_raw_read_u16_be(const duk_uint8_t *p) { + duk__u16_union u; + duk_memcpy((void *) u.b, (const void *) p, (size_t) 2); + u.x = DUK_NTOH16(u.x); + return u.x; +} + +DUK_INTERNAL DUK_ALWAYS_INLINE duk_uint32_t duk_raw_read_u32_be(const duk_uint8_t *p) { + duk__u32_union u; + duk_memcpy((void *) u.b, (const void *) p, (size_t) 4); + u.x = DUK_NTOH32(u.x); + return u.x; +} + +DUK_INTERNAL DUK_ALWAYS_INLINE duk_float_t duk_raw_read_float_be(const duk_uint8_t *p) { + duk_float_union fu; + duk_memcpy((void *) fu.uc, (const void *) p, (size_t) 4); + duk_fltunion_big_to_host(&fu); + return fu.f; +} + +DUK_INTERNAL DUK_ALWAYS_INLINE duk_double_t duk_raw_read_double_be(const duk_uint8_t *p) { + duk_double_union du; + duk_memcpy((void *) du.uc, (const void *) p, (size_t) 8); + duk_dblunion_big_to_host(&du); + return du.d; +} + +DUK_INTERNAL DUK_ALWAYS_INLINE duk_uint16_t duk_raw_readinc_u16_be(const duk_uint8_t **p) { + duk_uint16_t res = duk_raw_read_u16_be(*p); + *p += 2; + return res; +} + +DUK_INTERNAL DUK_ALWAYS_INLINE duk_uint32_t duk_raw_readinc_u32_be(const duk_uint8_t **p) { + duk_uint32_t res = duk_raw_read_u32_be(*p); + *p += 4; + return res; +} + +DUK_INTERNAL DUK_ALWAYS_INLINE duk_float_t duk_raw_readinc_float_be(const duk_uint8_t **p) { + duk_float_t res = duk_raw_read_float_be(*p); + *p += 4; + return res; +} + +DUK_INTERNAL DUK_ALWAYS_INLINE duk_double_t duk_raw_readinc_double_be(const duk_uint8_t **p) { + duk_double_t res = duk_raw_read_double_be(*p); + *p += 8; + return res; +} + +DUK_INTERNAL DUK_ALWAYS_INLINE void duk_raw_write_u16_be(duk_uint8_t *p, duk_uint16_t val) { + duk__u16_union u; + u.x = DUK_HTON16(val); + duk_memcpy((void *) p, (const void *) u.b, (size_t) 2); +} + +DUK_INTERNAL DUK_ALWAYS_INLINE void duk_raw_write_u32_be(duk_uint8_t *p, duk_uint32_t val) { + duk__u32_union u; + u.x = DUK_HTON32(val); + duk_memcpy((void *) p, (const void *) u.b, (size_t) 4); +} + +DUK_INTERNAL DUK_ALWAYS_INLINE void duk_raw_write_float_be(duk_uint8_t *p, duk_float_t val) { + duk_float_union fu; + fu.f = val; + duk_fltunion_host_to_big(&fu); + duk_memcpy((void *) p, (const void *) fu.uc, (size_t) 4); +} + +DUK_INTERNAL DUK_ALWAYS_INLINE void duk_raw_write_double_be(duk_uint8_t *p, duk_double_t val) { + duk_double_union du; + du.d = val; + duk_dblunion_host_to_big(&du); + duk_memcpy((void *) p, (const void *) du.uc, (size_t) 8); +} + +DUK_INTERNAL duk_small_int_t duk_raw_write_xutf8(duk_uint8_t *p, duk_ucodepoint_t val) { + duk_small_int_t len = duk_unicode_encode_xutf8(val, p); + return len; +} + +DUK_INTERNAL duk_small_int_t duk_raw_write_cesu8(duk_uint8_t *p, duk_ucodepoint_t val) { + duk_small_int_t len = duk_unicode_encode_cesu8(val, p); + return len; +} + +DUK_INTERNAL DUK_ALWAYS_INLINE void duk_raw_writeinc_u16_be(duk_uint8_t **p, duk_uint16_t val) { + duk_raw_write_u16_be(*p, val); + *p += 2; +} + +DUK_INTERNAL DUK_ALWAYS_INLINE void duk_raw_writeinc_u32_be(duk_uint8_t **p, duk_uint32_t val) { + duk_raw_write_u32_be(*p, val); + *p += 4; +} + +DUK_INTERNAL DUK_ALWAYS_INLINE void duk_raw_writeinc_float_be(duk_uint8_t **p, duk_float_t val) { + duk_raw_write_float_be(*p, val); + *p += 4; +} + +DUK_INTERNAL DUK_ALWAYS_INLINE void duk_raw_writeinc_double_be(duk_uint8_t **p, duk_double_t val) { + duk_raw_write_double_be(*p, val); + *p += 8; +} + +DUK_INTERNAL void duk_raw_writeinc_xutf8(duk_uint8_t **p, duk_ucodepoint_t val) { + duk_small_int_t len = duk_unicode_encode_xutf8(val, *p); + *p += len; +} + +DUK_INTERNAL void duk_raw_writeinc_cesu8(duk_uint8_t **p, duk_ucodepoint_t val) { + duk_small_int_t len = duk_unicode_encode_cesu8(val, *p); + *p += len; +} #line 1 "duk_util_misc.c" /* * Misc util stuff. @@ -13217,13 +13553,13 @@ DUK_INTERNAL void duk_byteswap_bytes(duk_uint8_t *p, duk_small_uint_t len) { #if (DUK_STRIDX_UC_ARGUMENTS > 255) #error constant too large #endif -#if (DUK_STRIDX_ARRAY > 255) +#if (DUK_STRIDX_UC_ARRAY > 255) #error constant too large #endif #if (DUK_STRIDX_UC_BOOLEAN > 255) #error constant too large #endif -#if (DUK_STRIDX_DATE > 255) +#if (DUK_STRIDX_UC_DATE > 255) #error constant too large #endif #if (DUK_STRIDX_UC_ERROR > 255) @@ -13306,11 +13642,11 @@ DUK_INTERNAL void duk_byteswap_bytes(duk_uint8_t *p, duk_small_uint_t len) { DUK_INTERNAL duk_uint8_t duk_class_number_to_stridx[32] = { DUK_STRIDX_EMPTY_STRING, /* NONE, intentionally empty */ DUK_STRIDX_UC_OBJECT, - DUK_STRIDX_ARRAY, + DUK_STRIDX_UC_ARRAY, DUK_STRIDX_UC_FUNCTION, DUK_STRIDX_UC_ARGUMENTS, DUK_STRIDX_UC_BOOLEAN, - DUK_STRIDX_DATE, + DUK_STRIDX_UC_DATE, DUK_STRIDX_UC_ERROR, DUK_STRIDX_JSON, DUK_STRIDX_MATH, @@ -13473,20 +13809,20 @@ DUK_EXTERNAL void duk_config_buffer(duk_hthread *thr, duk_idx_t idx, void *ptr, * Dump/load helpers, xxx_raw() helpers do no buffer checks */ -DUK_LOCAL duk_uint8_t *duk__load_string_raw(duk_hthread *thr, duk_uint8_t *p) { +DUK_LOCAL const duk_uint8_t *duk__load_string_raw(duk_hthread *thr, const duk_uint8_t *p) { duk_uint32_t len; - len = DUK_RAW_READ_U32_BE(p); + len = DUK_RAW_READINC_U32_BE(p); duk_push_lstring(thr, (const char *) p, len); p += len; return p; } -DUK_LOCAL duk_uint8_t *duk__load_buffer_raw(duk_hthread *thr, duk_uint8_t *p) { +DUK_LOCAL const duk_uint8_t *duk__load_buffer_raw(duk_hthread *thr, const duk_uint8_t *p) { duk_uint32_t len; duk_uint8_t *buf; - len = DUK_RAW_READ_U32_BE(p); + len = DUK_RAW_READINC_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); @@ -13503,7 +13839,7 @@ DUK_LOCAL duk_uint8_t *duk__dump_hstring_raw(duk_uint8_t *p, duk_hstring *h) { len = DUK_HSTRING_GET_BYTELEN(h); DUK_ASSERT(len <= 0xffffffffUL); /* string limits */ tmp32 = (duk_uint32_t) len; - DUK_RAW_WRITE_U32_BE(p, tmp32); + DUK_RAW_WRITEINC_U32_BE(p, tmp32); duk_memcpy((void *) p, (const void *) DUK_HSTRING_GET_DATA(h), len); @@ -13522,7 +13858,7 @@ DUK_LOCAL duk_uint8_t *duk__dump_hbuffer_raw(duk_hthread *thr, duk_uint8_t *p, d len = DUK_HBUFFER_GET_SIZE(h); DUK_ASSERT(len <= 0xffffffffUL); /* buffer limits */ tmp32 = (duk_uint32_t) len; - DUK_RAW_WRITE_U32_BE(p, tmp32); + DUK_RAW_WRITEINC_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), @@ -13562,7 +13898,7 @@ DUK_LOCAL duk_uint8_t *duk__dump_buffer_prop(duk_hthread *thr, duk_uint8_t *p, d p = duk__dump_hbuffer_raw(thr, p, h_buf); } else { p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4U, p); - DUK_RAW_WRITE_U32_BE(p, 0); + DUK_RAW_WRITEINC_U32_BE(p, 0); } return p; } @@ -13578,7 +13914,7 @@ DUK_LOCAL duk_uint8_t *duk__dump_uint32_prop(duk_hthread *thr, duk_uint8_t *p, d val = def_value; } p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4U, p); - DUK_RAW_WRITE_U32_BE(p, val); + DUK_RAW_WRITEINC_U32_BE(p, val); return p; } @@ -13616,11 +13952,11 @@ DUK_LOCAL duk_uint8_t *duk__dump_varmap(duk_hthread *thr, duk_uint8_t *p, duk_bu DUK_ASSERT(DUK_HSTRING_MAX_BYTELEN <= 0x7fffffffUL); /* ensures no overflow */ p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4U + DUK_HSTRING_GET_BYTELEN(key) + 4U, p); p = duk__dump_hstring_raw(p, key); - DUK_RAW_WRITE_U32_BE(p, val); + DUK_RAW_WRITEINC_U32_BE(p, val); } } p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4U, p); - DUK_RAW_WRITE_U32_BE(p, 0); /* end of _Varmap */ + DUK_RAW_WRITEINC_U32_BE(p, 0); /* end of _Varmap */ return p; } @@ -13639,7 +13975,7 @@ DUK_LOCAL duk_uint8_t *duk__dump_formals(duk_hthread *thr, duk_uint8_t *p, duk_b p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4U, p); DUK_ASSERT(h->length != DUK__NO_FORMALS); /* limits */ - DUK_RAW_WRITE_U32_BE(p, h->length); + DUK_RAW_WRITEINC_U32_BE(p, h->length); for (i = 0; i < h->length; i++) { duk_tval *tv_val; @@ -13660,7 +13996,7 @@ DUK_LOCAL duk_uint8_t *duk__dump_formals(duk_hthread *thr, duk_uint8_t *p, duk_b } else { DUK_DD(DUK_DDPRINT("dumping function without _Formals, emit marker to indicate missing _Formals")); p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4U, p); - DUK_RAW_WRITE_U32_BE(p, DUK__NO_FORMALS); /* marker: no formals */ + DUK_RAW_WRITEINC_U32_BE(p, DUK__NO_FORMALS); /* marker: no formals */ } return p; } @@ -13700,27 +14036,27 @@ static duk_uint8_t *duk__dump_func(duk_hthread *thr, duk_hcompfunc *func, duk_bu /* Fixed header info. */ tmp32 = count_instr; - DUK_RAW_WRITE_U32_BE(p, tmp32); + DUK_RAW_WRITEINC_U32_BE(p, tmp32); tmp32 = (duk_uint32_t) DUK_HCOMPFUNC_GET_CONSTS_COUNT(thr->heap, func); - DUK_RAW_WRITE_U32_BE(p, tmp32); + DUK_RAW_WRITEINC_U32_BE(p, tmp32); tmp32 = (duk_uint32_t) DUK_HCOMPFUNC_GET_FUNCS_COUNT(thr->heap, func); - DUK_RAW_WRITE_U32_BE(p, tmp32); + DUK_RAW_WRITEINC_U32_BE(p, tmp32); tmp16 = func->nregs; - DUK_RAW_WRITE_U16_BE(p, tmp16); + DUK_RAW_WRITEINC_U16_BE(p, tmp16); tmp16 = func->nargs; - DUK_RAW_WRITE_U16_BE(p, tmp16); + DUK_RAW_WRITEINC_U16_BE(p, tmp16); #if defined(DUK_USE_DEBUGGER_SUPPORT) tmp32 = func->start_line; - DUK_RAW_WRITE_U32_BE(p, tmp32); + DUK_RAW_WRITEINC_U32_BE(p, tmp32); tmp32 = func->end_line; - DUK_RAW_WRITE_U32_BE(p, tmp32); + DUK_RAW_WRITEINC_U32_BE(p, tmp32); #else - DUK_RAW_WRITE_U32_BE(p, 0); - DUK_RAW_WRITE_U32_BE(p, 0); + DUK_RAW_WRITEINC_U32_BE(p, 0); + DUK_RAW_WRITEINC_U32_BE(p, 0); #endif tmp32 = DUK_HEAPHDR_GET_FLAGS((duk_heaphdr *) func); /* masks flags, only duk_hobject flags */ tmp32 &= ~(DUK_HOBJECT_FLAG_HAVE_FINALIZER); /* finalizer flag is lost */ - DUK_RAW_WRITE_U32_BE(p, tmp32); + DUK_RAW_WRITEINC_U32_BE(p, tmp32); /* Bytecode instructions: endian conversion needed unless * platform is big endian. @@ -13734,7 +14070,7 @@ static duk_uint8_t *duk__dump_func(duk_hthread *thr, duk_hcompfunc *func, duk_bu #else while (ins != ins_end) { tmp32 = (duk_uint32_t) (*ins); - DUK_RAW_WRITE_U32_BE(p, tmp32); + DUK_RAW_WRITEINC_U32_BE(p, tmp32); ins++; } #endif @@ -13759,7 +14095,7 @@ static duk_uint8_t *duk__dump_func(duk_hthread *thr, duk_hcompfunc *func, duk_bu p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 1U + 8U, p); *p++ = DUK__SER_NUMBER; d = DUK_TVAL_GET_NUMBER(tv); - DUK_RAW_WRITE_DOUBLE_BE(p, d); + DUK_RAW_WRITEINC_DOUBLE_BE(p, d); } tv++; } @@ -13820,7 +14156,7 @@ static duk_uint8_t *duk__dump_func(duk_hthread *thr, duk_hcompfunc *func, duk_bu DUK_ASSERT((duk_size_t) (p_end - p) >= (duk_size_t) (n)); \ } while (0) -static duk_uint8_t *duk__load_func(duk_hthread *thr, duk_uint8_t *p, duk_uint8_t *p_end) { +static const duk_uint8_t *duk__load_func(duk_hthread *thr, const duk_uint8_t *p, const duk_uint8_t *p_end) { duk_hcompfunc *h_fun; duk_hbuffer *h_data; duk_size_t data_size; @@ -13844,12 +14180,12 @@ static duk_uint8_t *duk__load_func(duk_hthread *thr, duk_uint8_t *p, duk_uint8_t DUK_ASSERT(thr != NULL); - DUK_DD(DUK_DDPRINT("loading function, p=%p, p_end=%p", (void *) p, (void *) p_end)); + DUK_DD(DUK_DDPRINT("loading function, p=%p, p_end=%p", (const void *) p, (const void *) p_end)); DUK__ASSERT_LEFT(3 * 4); - count_instr = DUK_RAW_READ_U32_BE(p); - count_const = DUK_RAW_READ_U32_BE(p); - count_funcs = DUK_RAW_READ_U32_BE(p); + count_instr = DUK_RAW_READINC_U32_BE(p); + count_const = DUK_RAW_READINC_U32_BE(p); + count_funcs = DUK_RAW_READINC_U32_BE(p); data_size = sizeof(duk_tval) * count_const + sizeof(duk_hobject *) * count_funcs + @@ -13877,17 +14213,17 @@ static duk_uint8_t *duk__load_func(duk_hthread *thr, duk_uint8_t *p, duk_uint8_t DUK_ASSERT(DUK_HCOMPFUNC_GET_BYTECODE(thr->heap, h_fun) == NULL); DUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, (duk_hobject *) h_fun) == thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE]); - h_fun->nregs = DUK_RAW_READ_U16_BE(p); - h_fun->nargs = DUK_RAW_READ_U16_BE(p); + h_fun->nregs = DUK_RAW_READINC_U16_BE(p); + h_fun->nargs = DUK_RAW_READINC_U16_BE(p); #if defined(DUK_USE_DEBUGGER_SUPPORT) - h_fun->start_line = DUK_RAW_READ_U32_BE(p); - h_fun->end_line = DUK_RAW_READ_U32_BE(p); + h_fun->start_line = DUK_RAW_READINC_U32_BE(p); + h_fun->end_line = DUK_RAW_READINC_U32_BE(p); #else p += 8; /* skip line info */ #endif /* duk_hcompfunc flags; quite version specific */ - tmp32 = DUK_RAW_READ_U32_BE(p); + tmp32 = DUK_RAW_READINC_U32_BE(p); DUK_HEAPHDR_SET_FLAGS((duk_heaphdr *) h_fun, tmp32); /* masks flags to only change duk_hobject flags */ /* standard prototype (no need to set here, already set) */ @@ -13923,7 +14259,7 @@ static duk_uint8_t *duk__load_func(duk_hthread *thr, duk_uint8_t *p, duk_uint8_t #else q = fun_data + sizeof(duk_tval) * count_const + sizeof(duk_hobject *) * count_funcs; for (n = count_instr; n > 0; n--) { - *((duk_instr_t *) (void *) q) = DUK_RAW_READ_U32_BE(p); + *((duk_instr_t *) (void *) q) = DUK_RAW_READINC_U32_BE(p); q += sizeof(duk_instr_t); } #endif @@ -13931,7 +14267,7 @@ static duk_uint8_t *duk__load_func(duk_hthread *thr, duk_uint8_t *p, duk_uint8_t /* Load constants onto value stack but don't yet copy to buffer. */ for (n = count_const; n > 0; n--) { DUK__ASSERT_LEFT(1); - const_type = DUK_RAW_READ_U8(p); + const_type = DUK_RAW_READINC_U8(p); switch (const_type) { case DUK__SER_STRING: { p = duk__load_string_raw(thr, p); @@ -13944,7 +14280,7 @@ static duk_uint8_t *duk__load_func(duk_hthread *thr, duk_uint8_t *p, duk_uint8_t duk_tval tv_tmp; duk_double_t val; DUK__ASSERT_LEFT(8); - val = DUK_RAW_READ_DOUBLE_BE(p); + val = DUK_RAW_READINC_DOUBLE_BE(p); DUK_TVAL_SET_NUMBER_CHKFAST_SLOW(&tv_tmp, val); duk_push_tval(thr, &tv_tmp); break; @@ -14011,7 +14347,7 @@ static duk_uint8_t *duk__load_func(duk_hthread *thr, duk_uint8_t *p, duk_uint8_t duk_set_top(thr, idx_base + 1); /* Setup function properties. */ - tmp32 = DUK_RAW_READ_U32_BE(p); + tmp32 = DUK_RAW_READINC_U32_BE(p); duk_push_u32(thr, tmp32); duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_C); @@ -14091,7 +14427,7 @@ static duk_uint8_t *duk__load_func(duk_hthread *thr, duk_uint8_t *p, duk_uint8_t duk_pop(thr); break; } - tmp32 = DUK_RAW_READ_U32_BE(p); + tmp32 = DUK_RAW_READINC_U32_BE(p); duk_push_u32(thr, tmp32); duk_put_prop(thr, -3); } @@ -14101,7 +14437,7 @@ static duk_uint8_t *duk__load_func(duk_hthread *thr, duk_uint8_t *p, duk_uint8_t /* _Formals may have been missing in the original function, which is * handled using a marker length. */ - arr_limit = DUK_RAW_READ_U32_BE(p); + arr_limit = DUK_RAW_READINC_U32_BE(p); if (arr_limit != DUK__NO_FORMALS) { duk_push_bare_array(thr); /* _Formals */ for (arr_idx = 0; arr_idx < arr_limit; arr_idx++) { @@ -14155,7 +14491,7 @@ DUK_EXTERNAL void duk_dump_function(duk_hthread *thr) { } DUK_EXTERNAL void duk_load_function(duk_hthread *thr) { - duk_uint8_t *p_buf, *p, *p_end; + const duk_uint8_t *p_buf, *p, *p_end; duk_size_t sz; DUK_ASSERT_API_ENTRY(thr); @@ -15423,7 +15759,7 @@ DUK_EXTERNAL void duk_base64_decode(duk_hthread *thr, duk_idx_t idx) { 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_WO_NORETURN(return NULL;); } DUK_EXTERNAL void duk_base64_decode(duk_hthread *thr, duk_idx_t idx) { @@ -18863,7 +19199,7 @@ DUK_EXTERNAL void duk_insert(duk_hthread *thr, duk_idx_t to_idx) { * => [ ... | q | p | x | x ] */ - nbytes = (duk_size_t) (((duk_uint8_t *) q) - ((duk_uint8_t *) p)); /* Note: 'q' is top-1 */ + nbytes = (duk_size_t) (((duk_uint8_t *) q) - ((duk_uint8_t *) p)); 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)); @@ -18899,6 +19235,40 @@ DUK_INTERNAL void duk_insert_undefined_n(duk_hthread *thr, duk_idx_t idx, duk_id } } +DUK_EXTERNAL void duk_pull(duk_hthread *thr, duk_idx_t from_idx) { + duk_tval *p; + duk_tval *q; + duk_tval tv_tmp; + duk_size_t nbytes; + + DUK_ASSERT_API_ENTRY(thr); + + /* nbytes + * <---------> + * [ ... | x | x | p | y | y | q ] + * => [ ... | x | x | y | y | q | p ] + */ + + p = duk_require_tval(thr, from_idx); + DUK_ASSERT(p != NULL); + q = duk_require_tval(thr, -1); + DUK_ASSERT(q != NULL); + + DUK_ASSERT(q >= p); + + nbytes = (duk_size_t) (((duk_uint8_t *) q) - ((duk_uint8_t *) p)); + + DUK_DDD(DUK_DDDPRINT("duk_pull: from_idx=%ld, p=%p, q=%p, nbytes=%lu", + (long) from_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, p); + duk_memmove((void *) p, (const void *) (p + 1), (size_t) nbytes); + DUK_TVAL_SET_TVAL(q, &tv_tmp); +} + DUK_EXTERNAL void duk_replace(duk_hthread *thr, duk_idx_t to_idx) { duk_tval *tv1; duk_tval *tv2; @@ -20695,7 +21065,7 @@ DUK_INTERNAL duk_uint8_t duk_to_uint8clamped(duk_hthread *thr, duk_idx_t idx) { } t = d - DUK_FLOOR(d); - if (t == 0.5) { + if (duk_double_equals(t, 0.5)) { /* Exact halfway, round to even. */ ret = (duk_uint8_t) d; ret = (ret + 1) & 0xfe; /* Example: d=3.5, t=0.5 -> ret = (3 + 1) & 0xfe = 4 & 0xfe = 4 @@ -20843,134 +21213,6 @@ DUK_INTERNAL duk_hstring *duk_safe_to_hstring(duk_hthread *thr, duk_idx_t idx) { #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_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; - } - case DUK_TAG_NULL: { - stridx_bidx = DUK_STRIDX_UC_NULL; - goto use_stridx; - } - case DUK_TAG_BOOLEAN: { - stridx_bidx = (DUK_BIDX_BOOLEAN_PROTOTYPE << 16) + DUK_STRIDX_UC_BOOLEAN; - goto use_proto_bidx; - } - case DUK_TAG_POINTER: { - stridx_bidx = (DUK_BIDX_POINTER_PROTOTYPE << 16) + DUK_STRIDX_UC_POINTER; - goto use_proto_bidx; - } - case DUK_TAG_LIGHTFUNC: { - stridx_bidx = (DUK_BIDX_FUNCTION_PROTOTYPE << 16) + DUK_STRIDX_UC_FUNCTION; - goto use_proto_bidx; - } - 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; - } else { - stridx_bidx = (DUK_BIDX_STRING_PROTOTYPE << 16) + DUK_STRIDX_UC_STRING; - } - goto use_proto_bidx; - } - case DUK_TAG_OBJECT: { - duk_push_tval(thr, tv); - stridx_bidx = 0xffffffffUL; /* Marker value. */ - goto use_pushed_object; - } - case DUK_TAG_BUFFER: { - stridx_bidx = (DUK_BIDX_UINT8ARRAY_PROTOTYPE << 16) + DUK_STRIDX_UINT8_ARRAY; - goto use_proto_bidx; - } -#if defined(DUK_USE_FASTINT) - case DUK_TAG_FASTINT: - /* Fall through to generic number case. */ -#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; @@ -20986,11 +21228,13 @@ DUK_INTERNAL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv, duk /* 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. + * prototype) to see if a custom result should be used, with the + * exception of Arrays which are handled specially first. + * + * 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. @@ -21015,31 +21259,33 @@ DUK_INTERNAL void duk_push_class_string_tval(duk_hthread *thr, duk_tval *tv, duk duk_push_tval(thr, tv); tv = NULL; /* Invalidated by ToObject(). */ - duk_to_object(thr, -1); - - /* [ ... "[object" obj ] */ + h_obj = duk_to_hobject(thr, -1); + DUK_ASSERT(h_obj != NULL); + if (duk_js_isarray_hobject(h_obj)) { + stridx = DUK_STRIDX_UC_ARRAY; + } else { + /* [ ... "[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; + /* 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); } - duk_pop_unsafe(thr); - } #else - DUK_UNREF(avoid_side_effects); + 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); + 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); @@ -21878,14 +22124,15 @@ DUK_EXTERNAL duk_bool_t duk_is_symbol(duk_hthread *thr, duk_idx_t idx) { return 0; } +/* IsArray(), returns true for Array instance or Proxy of Array instance. */ DUK_EXTERNAL duk_bool_t duk_is_array(duk_hthread *thr, duk_idx_t idx) { - duk_hobject *obj; + duk_tval *tv; DUK_ASSERT_API_ENTRY(thr); - obj = duk_get_hobject(thr, idx); - if (obj) { - return (DUK_HOBJECT_GET_CLASS_NUMBER(obj) == DUK_HOBJECT_CLASS_ARRAY ? 1 : 0); + tv = duk_get_tval(thr, idx); + if (tv) { + return duk_js_isarray(tv); } return 0; } @@ -24093,6 +24340,13 @@ DUK_INTERNAL duk_idx_t duk_unpack_array_like(duk_hthread *thr, duk_idx_t idx) { * Error throwing */ +#if defined(DUK_USE_GCC_PRAGMAS) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn" +#elif defined(DUK_USE_CLANG_PRAGMAS) +#pragma clang diagnostic push +#endif + DUK_EXTERNAL void duk_throw_raw(duk_hthread *thr) { duk_tval *tv_val; @@ -24182,6 +24436,12 @@ DUK_EXTERNAL void duk_error_raw(duk_hthread *thr, duk_errcode_t err_code, const DUK_WO_NORETURN(return;); } +#if defined(DUK_USE_GCC_PRAGMAS) +#pragma GCC diagnostic pop +#elif defined(DUK_USE_CLANG_PRAGMAS) +#pragma clang diagnostic pop +#endif + #if !defined(DUK_USE_VARIADIC_MACROS) DUK_NORETURN(DUK_LOCAL_DECL void duk__throw_error_from_stash(duk_hthread *thr, duk_errcode_t err_code, const char *fmt, va_list ap)); @@ -25291,7 +25551,7 @@ DUK_INTERNAL duk_ret_t duk_bi_array_constructor(duk_hthread *thr) { /* XXX: expensive check (also shared elsewhere - so add a shared internal API call?) */ d = duk_get_number(thr, 0); len = duk_to_uint32(thr, 0); - if (((duk_double_t) len) != d) { + if (!duk_double_equals((duk_double_t) len, d)) { DUK_DCERROR_RANGE_INVALID_LENGTH(thr); } @@ -25315,10 +25575,8 @@ DUK_INTERNAL duk_ret_t duk_bi_array_constructor(duk_hthread *thr) { */ DUK_INTERNAL duk_ret_t duk_bi_array_constructor_is_array(duk_hthread *thr) { - duk_hobject *h; - - h = duk_get_hobject_with_class(thr, 0, DUK_HOBJECT_CLASS_ARRAY); - duk_push_boolean(thr, (h != NULL)); + DUK_ASSERT_TOP(thr, 1); + duk_push_boolean(thr, duk_js_isarray(DUK_GET_TVAL_POSIDX(thr, 0))); return 1; } @@ -25411,13 +25669,13 @@ DUK_INTERNAL duk_ret_t duk_bi_array_prototype_concat(duk_hthread *thr) { #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); + spreadable = duk_js_isarray_hobject(h); } else { spreadable = duk_to_boolean(thr, -1); } duk_pop_nodecref_unsafe(thr); #else - spreadable = (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY); + spreadable = duk_js_isarray_hobject(h); #endif } @@ -29127,12 +29385,12 @@ DUK_INTERNAL duk_ret_t duk_bi_nodejs_buffer_concat(duk_hthread *thr) { /* XXX: split into separate functions for each field type? */ DUK_INTERNAL duk_ret_t duk_bi_buffer_readfield(duk_hthread *thr) { - duk_small_int_t magic = (duk_small_int_t) duk_get_current_magic(thr); - duk_small_int_t magic_ftype; - duk_small_int_t magic_bigendian; - duk_small_int_t magic_signed; - duk_small_int_t magic_typedarray; - duk_small_int_t endswap; + duk_small_uint_t magic = (duk_small_uint_t) duk_get_current_magic(thr); + duk_small_uint_t magic_ftype; + duk_small_uint_t magic_bigendian; + duk_small_uint_t magic_signed; + duk_small_uint_t magic_typedarray; + duk_small_uint_t endswap; duk_hbufobj *h_this; duk_bool_t no_assert; duk_int_t offset_signed; @@ -29142,10 +29400,10 @@ DUK_INTERNAL duk_ret_t duk_bi_buffer_readfield(duk_hthread *thr) { duk_uint8_t *buf; duk_double_union du; - magic_ftype = magic & 0x0007; - magic_bigendian = magic & 0x0008; - magic_signed = magic & 0x0010; - magic_typedarray = magic & 0x0020; + magic_ftype = magic & 0x0007U; + magic_bigendian = magic & 0x0008U; + magic_signed = magic & 0x0010U; + magic_typedarray = magic & 0x0020U; h_this = duk__require_bufobj_this(thr); /* XXX: very inefficient for plain buffers */ DUK_ASSERT(h_this != NULL); @@ -29184,7 +29442,7 @@ DUK_INTERNAL duk_ret_t duk_bi_buffer_readfield(duk_hthread *thr) { DUK_DDD(DUK_DDDPRINT("readfield, buffer_length=%ld, offset=%ld, no_assert=%d, " "magic=%04x, magic_fieldtype=%d, magic_bigendian=%d, magic_signed=%d, " - "endswap=%d", + "endswap=%u", (long) buffer_length, (long) offset, (int) no_assert, (unsigned int) magic, (int) magic_ftype, (int) (magic_bigendian >> 3), (int) (magic_signed >> 4), (int) endswap)); @@ -29386,12 +29644,12 @@ DUK_INTERNAL duk_ret_t duk_bi_buffer_readfield(duk_hthread *thr) { #if defined(DUK_USE_BUFFEROBJECT_SUPPORT) /* XXX: split into separate functions for each field type? */ DUK_INTERNAL duk_ret_t duk_bi_buffer_writefield(duk_hthread *thr) { - duk_small_int_t magic = (duk_small_int_t) duk_get_current_magic(thr); - duk_small_int_t magic_ftype; - duk_small_int_t magic_bigendian; - duk_small_int_t magic_signed; - duk_small_int_t magic_typedarray; - duk_small_int_t endswap; + duk_small_uint_t magic = (duk_small_uint_t) duk_get_current_magic(thr); + duk_small_uint_t magic_ftype; + duk_small_uint_t magic_bigendian; + duk_small_uint_t magic_signed; + duk_small_uint_t magic_typedarray; + duk_small_uint_t endswap; duk_hbufobj *h_this; duk_bool_t no_assert; duk_int_t offset_signed; @@ -29402,10 +29660,10 @@ DUK_INTERNAL duk_ret_t duk_bi_buffer_writefield(duk_hthread *thr) { duk_double_union du; duk_int_t nbytes = 0; - magic_ftype = magic & 0x0007; - magic_bigendian = magic & 0x0008; - magic_signed = magic & 0x0010; - magic_typedarray = magic & 0x0020; + magic_ftype = magic & 0x0007U; + magic_bigendian = magic & 0x0008U; + magic_signed = magic & 0x0010U; + magic_typedarray = magic & 0x0020U; DUK_UNREF(magic_signed); h_this = duk__require_bufobj_this(thr); /* XXX: very inefficient for plain buffers */ @@ -29445,7 +29703,7 @@ DUK_INTERNAL duk_ret_t duk_bi_buffer_writefield(duk_hthread *thr) { * (offset + nbytes) even when write fails due to invalid offset. */ if (magic_ftype != DUK__FLD_VARINT) { - DUK_ASSERT(magic_ftype >= 0 && magic_ftype < (duk_small_int_t) (sizeof(duk__buffer_nbytes_from_fldtype) / sizeof(duk_uint8_t))); + DUK_ASSERT(magic_ftype < (duk_small_uint_t) (sizeof(duk__buffer_nbytes_from_fldtype) / sizeof(duk_uint8_t))); nbytes = duk__buffer_nbytes_from_fldtype[magic_ftype]; } else { nbytes = duk_get_int(thr, 2); @@ -29462,7 +29720,7 @@ DUK_INTERNAL duk_ret_t duk_bi_buffer_writefield(duk_hthread *thr) { DUK_DDD(DUK_DDDPRINT("writefield, value=%!T, buffer_length=%ld, offset=%ld, no_assert=%d, " "magic=%04x, magic_fieldtype=%d, magic_bigendian=%d, magic_signed=%d, " - "endswap=%d", + "endswap=%u", duk_get_tval(thr, 0), (long) buffer_length, (long) offset, (int) no_assert, (unsigned int) magic, (int) magic_ftype, (int) (magic_bigendian >> 3), (int) (magic_signed >> 4), (int) endswap)); @@ -29798,6 +30056,1672 @@ DUK_INTERNAL duk_ret_t duk_bi_typedarray_bytelength_getter(duk_hthread *thr) { #undef DUK__FLD_SIGNED #undef DUK__FLD_TYPEDARRAY #undef DUK__FLD_VARINT +#line 1 "duk_bi_cbor.c" +/* + * CBOR bindings. + * + * http://cbor.io/ + * https://tools.ietf.org/html/rfc7049 + */ + +/* #include duk_internal.h -> already included */ + +#if defined(DUK_USE_CBOR_SUPPORT) + +/* #define DUK_CBOR_STRESS */ + +/* Default behavior for encoding strings: use CBOR text string if string + * is UTF-8 compatible, otherwise use CBOR byte string. These defines + * can be used to force either type for all strings. Using text strings + * for non-UTF-8 data is technically invalid CBOR. + */ +/* #define DUK_CBOR_TEXT_STRINGS */ +/* #define DUK_CBOR_BYTE_STRINGS */ + +/* Misc. defines. */ +/* #define DUK_CBOR_PREFER_SIZE */ +/* #define DUK_CBOR_DOUBLE_AS_IS */ +/* #define DUK_CBOR_DECODE_FASTPATH */ + +typedef struct { + duk_hthread *thr; + duk_uint8_t *ptr; + duk_uint8_t *buf; + duk_uint8_t *buf_end; + duk_size_t len; + duk_idx_t idx_buf; +} duk_cbor_encode_context; + +typedef struct { + duk_hthread *thr; + const duk_uint8_t *buf; + duk_size_t off; + duk_size_t len; +} duk_cbor_decode_context; + +DUK_LOCAL void duk__cbor_encode_value(duk_cbor_encode_context *enc_ctx); +DUK_LOCAL void duk__cbor_decode_value(duk_cbor_decode_context *dec_ctx); + +/* + * Misc + */ + +DUK_LOCAL duk_uint32_t duk__cbor_double_to_uint32(double d) { + /* Out of range casts are undefined behavior, so caller must avoid. */ + DUK_ASSERT(d >= 0.0 && d <= 4294967295.0); + return (duk_uint32_t) d; +} + +/* + * Encoding + */ + +DUK_LOCAL void duk__cbor_encode_error(duk_cbor_encode_context *enc_ctx) { + (void) duk_type_error(enc_ctx->thr, "cbor encode error"); +} + +/* Check that a size_t is in uint32 range to avoid out-of-range casts. */ +DUK_LOCAL void duk__cbor_encode_sizet_uint32_check(duk_cbor_encode_context *enc_ctx, duk_size_t len) { + if (DUK_UNLIKELY(sizeof(duk_size_t) > sizeof(duk_uint32_t) && len > (duk_size_t) DUK_UINT32_MAX)) { + duk__cbor_encode_error(enc_ctx); + } +} + +DUK_LOCAL DUK_NOINLINE void duk__cbor_encode_ensure_slowpath(duk_cbor_encode_context *enc_ctx, duk_size_t len) { + duk_size_t oldlen; + duk_size_t minlen; + duk_size_t newlen; + duk_uint8_t *p_new; + duk_size_t old_data_len; + + DUK_ASSERT(enc_ctx->ptr >= enc_ctx->buf); + DUK_ASSERT(enc_ctx->buf_end >= enc_ctx->ptr); + DUK_ASSERT(enc_ctx->buf_end >= enc_ctx->buf); + + /* Overflow check. + * + * Limit example: 0xffffffffUL / 2U = 0x7fffffffUL, we reject >= 0x80000000UL. + */ + oldlen = enc_ctx->len; + minlen = oldlen + len; + if (DUK_UNLIKELY(oldlen > DUK_SIZE_MAX / 2U || minlen < oldlen)) { + duk__cbor_encode_error(enc_ctx); + } + +#if defined(DUK_CBOR_STRESS) + newlen = oldlen + 1U; +#else + newlen = oldlen * 2U; +#endif + DUK_ASSERT(newlen >= oldlen); + + if (minlen > newlen) { + newlen = minlen; + } + DUK_ASSERT(newlen >= oldlen); + DUK_ASSERT(newlen >= minlen); + DUK_ASSERT(newlen > 0U); + + DUK_DD(DUK_DDPRINT("cbor encode buffer resized to %ld", (long) newlen)); + + p_new = (duk_uint8_t *) duk_resize_buffer(enc_ctx->thr, enc_ctx->idx_buf, newlen); + DUK_ASSERT(p_new != NULL); + old_data_len = (duk_size_t) (enc_ctx->ptr - enc_ctx->buf); + enc_ctx->buf = p_new; + enc_ctx->buf_end = p_new + newlen; + enc_ctx->ptr = p_new + old_data_len; + enc_ctx->len = newlen; +} + +DUK_LOCAL DUK_INLINE void duk__cbor_encode_ensure(duk_cbor_encode_context *enc_ctx, duk_size_t len) { + if (DUK_LIKELY((duk_size_t) (enc_ctx->buf_end - enc_ctx->ptr) >= len)) { + return; + } + duk__cbor_encode_ensure_slowpath(enc_ctx, len); +} + +DUK_LOCAL duk_size_t duk__cbor_get_reserve(duk_cbor_encode_context *enc_ctx) { + DUK_ASSERT(enc_ctx->ptr >= enc_ctx->buf); + DUK_ASSERT(enc_ctx->ptr <= enc_ctx->buf_end); + return (duk_size_t) (enc_ctx->buf_end - enc_ctx->ptr); +} + +DUK_LOCAL void duk__cbor_encode_uint32(duk_cbor_encode_context *enc_ctx, duk_uint32_t u, duk_uint8_t base) { + duk_uint8_t *p; + + /* Caller must ensure space. */ + DUK_ASSERT(duk__cbor_get_reserve(enc_ctx) >= 1 + 4); + + p = enc_ctx->ptr; + if (DUK_LIKELY(u <= 23U)) { + *p++ = (duk_uint8_t) (base + (duk_uint8_t) u); + } else if (u <= 0xffUL) { + *p++ = base + 0x18U; + *p++ = (duk_uint8_t) u; + } else if (u <= 0xffffUL) { + *p++ = base + 0x19U; + DUK_RAW_WRITEINC_U16_BE(p, (duk_uint16_t) u); + } else { + *p++ = base + 0x1aU; + DUK_RAW_WRITEINC_U32_BE(p, u); + } + enc_ctx->ptr = p; +} + +#if defined(DUK_CBOR_DOUBLE_AS_IS) +DUK_LOCAL void duk__cbor_encode_double(duk_cbor_encode_context *enc_ctx, double d) { + duk_uint8_t *p; + + /* Caller must ensure space. */ + DUK_ASSERT(duk__cbor_get_reserve(enc_ctx) >= 1 + 8); + + p = enc_ctx->ptr; + *p++ = 0xfbU; + DUK_RAW_WRITEINC_DOUBLE_BE(p, d); + p += 8; + enc_ctx->ptr = p; +} +#else /* DUK_CBOR_DOUBLE_AS_IS */ +DUK_LOCAL void duk__cbor_encode_double_fp(duk_cbor_encode_context *enc_ctx, double d) { + duk_double_union u; + duk_uint16_t u16; + duk_int16_t expt; + duk_uint8_t *p; + + DUK_ASSERT(DUK_FPCLASSIFY(d) != DUK_FP_ZERO); + + /* Caller must ensure space. */ + DUK_ASSERT(duk__cbor_get_reserve(enc_ctx) >= 1 + 8); + + /* Organize into little endian (no-op if platform is little endian). */ + u.d = d; + duk_dblunion_host_to_little(&u); + + /* 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'. + */ + u16 = (((duk_uint16_t) u.uc[7]) << 8) | ((duk_uint16_t) u.uc[6]); + expt = (duk_int16_t) ((u16 & 0x7ff0U) >> 4) - 1023; + + if (expt >= -14 && expt <= 15) { + /* Half-float normal exponents (excl. denormals). + * + * 7 6 5 4 3 2 1 0 (LE index) + * double: seeeeeee eeeemmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm + * half: seeeee mmmm mmmmmm00 00000000 00000000 00000000 00000000 00000000 + */ + duk_bool_t use_half_float; + + use_half_float = + (u.uc[0] == 0 && u.uc[1] == 0 && u.uc[2] == 0 && u.uc[3] == 0 && + u.uc[4] == 0 && (u.uc[5] & 0x03U) == 0); + + if (use_half_float) { + duk_uint32_t t; + + expt += 15; + t = (duk_uint32_t) (u.uc[7] & 0x80U) << 8; + t += (duk_uint32_t) expt << 10; + t += ((duk_uint32_t) u.uc[6] & 0x0fU) << 6; + t += ((duk_uint32_t) u.uc[5]) >> 2; + + /* seeeeemm mmmmmmmm */ + p = enc_ctx->ptr; + *p++ = 0xf9U; + DUK_RAW_WRITEINC_U16_BE(p, (duk_uint16_t) t); + enc_ctx->ptr = p; + return; + } + } + + /* Same check for plain float. Also no denormal support here. */ + if (expt >= -126 && expt <= 127) { + /* Float normal exponents (excl. denormals). + * + * double: seeeeeee eeeemmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm + * float: seeee eeeemmmm mmmmmmmm mmmmmmmm mmm00000 00000000 00000000 00000000 + */ + duk_bool_t use_float; + duk_float_t d_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 + use_float = + (u.uc[0] == 0 && u.uc[1] == 0 && u.uc[2] == 0 && (u.uc[3] & 0xe0U) == 0); +#endif + d_float = (duk_float_t) d; + use_float = duk_double_equals((duk_double_t) d_float, d); + if (use_float) { + p = enc_ctx->ptr; + *p++ = 0xfaU; + DUK_RAW_WRITEINC_FLOAT_BE(p, d_float); + enc_ctx->ptr = p; + return; + } + } + + /* Special handling for NaN and Inf which we want to encode as + * half-floats. They share the same (maximum) exponent. + */ + if (expt == 1024) { + DUK_ASSERT(DUK_ISNAN(d) || DUK_ISINF(d)); + p = enc_ctx->ptr; + *p++ = 0xf9U; + if (DUK_ISNAN(d)) { + /* 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++ = 0x7eU; + } else { + /* Shortest +/- Infinity encoding is using a half-float. */ + if (DUK_SIGNBIT(d)) { + *p++ = 0xfcU; + } else { + *p++ = 0x7cU; + } + } + *p++ = 0x00U; + enc_ctx->ptr = p; + return; + } + + /* Cannot use half-float or float, encode as full IEEE double. */ + p = enc_ctx->ptr; + *p++ = 0xfbU; + DUK_RAW_WRITEINC_DOUBLE_BE(p, d); + enc_ctx->ptr = p; +} + +DUK_LOCAL void duk__cbor_encode_double(duk_cbor_encode_context *enc_ctx, double d) { + duk_uint8_t *p; + double d_floor; + + /* 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 reach 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 + */ + + /* Caller must ensure space. */ + DUK_ASSERT(duk__cbor_get_reserve(enc_ctx) >= 1 + 8); + + /* Most important path is integers. The floor() test will be true + * for Inf too (but not NaN). + */ + d_floor = DUK_FLOOR(d); /* identity if d is +/- 0.0, NaN, or +/- Infinity */ + if (DUK_LIKELY(duk_double_equals(d_floor, d) != 0)) { + DUK_ASSERT(!DUK_ISNAN(d)); /* NaN == NaN compares false. */ + if (DUK_SIGNBIT(d)) { + if (d >= -4294967296.0) { + d = -1.0 - d; + if (d >= 0.0) { + DUK_ASSERT(d >= 0.0); + duk__cbor_encode_uint32(enc_ctx, duk__cbor_double_to_uint32(d), 0x20U); + return; + } + + /* Input was negative zero, d == -1.0 < 0.0. + * Shortest -0 is using half-float. + */ + p = enc_ctx->ptr; + *p++ = 0xf9U; + *p++ = 0x80U; + *p++ = 0x00U; + enc_ctx->ptr = p; + return; + } + } else { + if (d <= 4294967295.0) { + /* Positive zero needs no special handling. */ + DUK_ASSERT(d >= 0.0); + duk__cbor_encode_uint32(enc_ctx, duk__cbor_double_to_uint32(d), 0x00U); + 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. + */ + + DUK_ASSERT(DUK_FPCLASSIFY(d) != DUK_FP_ZERO); + duk__cbor_encode_double_fp(enc_ctx, d); +} +#endif /* DUK_CBOR_DOUBLE_AS_IS */ + +DUK_LOCAL 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; + + /* CBOR differentiates between UTF-8 text strings and byte strings. + * Text strings MUST be valid UTF-8, so not all Duktape strings can + * be encoded as valid CBOR text strings. Possible behaviors: + * + * 1. Use text string when input is valid UTF-8, otherwise use + * byte string (maybe tagged to indicate it was an extended + * UTF-8 string). + * 2. Always use text strings, but sanitize input string so that + * invalid UTF-8 is replaced with U+FFFD for example. Combine + * surrogates whenever possible. + * 3. Always use byte strings. This is simple and produces valid + * CBOR, but isn't ideal for interoperability. + * 4. Always use text strings, even for invalid UTF-8 such as + * codepoints in the surrogate pair range. This is simple but + * produces technically invalid CBOR for non-UTF-8 strings which + * may affect interoperability. + * + * Current default is 1; can be changed with defines. + */ + + /* Caller must ensure space. */ + DUK_ASSERT(duk__cbor_get_reserve(enc_ctx) >= 1 + 8); + + str = (const duk_uint8_t *) duk_require_lstring(enc_ctx->thr, -1, &len); + if (duk_is_symbol(enc_ctx->thr, -1)) { + /* Symbols, encode as an empty table for now. This matches + * the behavior of cbor-js. + * + * XXX: Maybe encode String() coercion with a tag? + * XXX: Option to keep enough information to recover + * Symbols when decoding (this is not always desirable). + */ + p = enc_ctx->ptr; + *p++ = 0xa0U; + enc_ctx->ptr = p; + return; + } + + duk__cbor_encode_sizet_uint32_check(enc_ctx, len); +#if defined(DUK_CBOR_TEXT_STRINGS) + duk__cbor_encode_uint32(enc_ctx, (duk_uint32_t) len, 0x60U); +#elif defined(DUK_CBOR_BYTE_STRINGS) + duk__cbor_encode_uint32(enc_ctx, (duk_uint32_t) len, 0x40U); +#else + duk__cbor_encode_uint32(enc_ctx, (duk_uint32_t) len, + (DUK_LIKELY(duk_unicode_is_utf8_compatible(str, len) != 0) ? 0x60U : 0x40U)); +#endif + duk__cbor_encode_ensure(enc_ctx, len); + p = enc_ctx->ptr; + duk_memcpy((void *) p, (const void *) str, len); + p += len; + enc_ctx->ptr = p; +} + +DUK_LOCAL void duk__cbor_encode_object(duk_cbor_encode_context *enc_ctx) { + duk_uint8_t *buf; + duk_size_t len; + duk_uint8_t *p; + duk_size_t i; + duk_size_t off_ib; + duk_uint32_t count; + + /* Caller must ensure space. */ + DUK_ASSERT(duk__cbor_get_reserve(enc_ctx) >= 1 + 8); + + /* XXX: Support for specific built-ins like Date and RegExp. */ + if (duk_is_array(enc_ctx->thr, -1)) { + /* Shortest encoding for arrays >= 256 in length is actually + * the indefinite length one (3 or more bytes vs. 2 bytes). + * We still use the definite length version because it is + * more decoding friendly. + */ + len = duk_get_length(enc_ctx->thr, -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->thr, -1, (duk_uarridx_t) i); + duk__cbor_encode_value(enc_ctx); + } + } else if (duk_is_buffer_data(enc_ctx->thr, -1)) { + /* XXX: Tag buffer data? + * XXX: Encode typed arrays as integer arrays rather + * than buffer data as is? + */ + buf = (duk_uint8_t *) duk_require_buffer_data(enc_ctx->thr, -1, &len); + duk__cbor_encode_sizet_uint32_check(enc_ctx, len); + duk__cbor_encode_uint32(enc_ctx, (duk_uint32_t) len, 0x40U); + duk__cbor_encode_ensure(enc_ctx, len); + p = enc_ctx->ptr; + duk_memcpy((void *) p, (const void *) buf, len); + p += len; + enc_ctx->ptr = p; + } 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. + */ + off_ib = (duk_size_t) (enc_ctx->ptr - enc_ctx->buf); /* XXX: get_offset? */ + count = 0U; + p = enc_ctx->ptr; + *p++ = 0xa0U + 0x1fU; /* indefinite length */ + enc_ctx->ptr = p; + duk_enum(enc_ctx->thr, -1, DUK_ENUM_OWN_PROPERTIES_ONLY); + while (duk_next(enc_ctx->thr, -1, 1 /*get_value*/)) { + duk_insert(enc_ctx->thr, -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->thr); + if (count <= 0x17U) { + DUK_ASSERT(off_ib < enc_ctx->len); + enc_ctx->buf[off_ib] = 0xa0U + (duk_uint8_t) count; + } else { + duk__cbor_encode_ensure(enc_ctx, 1); + p = enc_ctx->ptr; + *p++ = 0xffU; /* break */ + enc_ctx->ptr = p; + } + } +} + +DUK_LOCAL void duk__cbor_encode_buffer(duk_cbor_encode_context *enc_ctx) { + duk_uint8_t *buf; + duk_size_t len; + duk_uint8_t *p; + + /* Caller must ensure space. */ + DUK_ASSERT(duk__cbor_get_reserve(enc_ctx) >= 1 + 8); + + /* Tag buffer data? */ + buf = (duk_uint8_t *) duk_require_buffer(enc_ctx->thr, -1, &len); + duk__cbor_encode_sizet_uint32_check(enc_ctx, len); + duk__cbor_encode_uint32(enc_ctx, (duk_uint32_t) len, 0x40U); + duk__cbor_encode_ensure(enc_ctx, len); + p = enc_ctx->ptr; + duk_memcpy((void *) p, (const void *) buf, len); + p += len; + enc_ctx->ptr = p; +} + +DUK_LOCAL void duk__cbor_encode_pointer(duk_cbor_encode_context *enc_ctx) { + /* 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) but + * that's not portable. They could be encoded as direct memory + * representations. Recovering pointers is non-portable in any + * case but it would be nice to be able to detect and recover + * compatible pointers. + * + * For now, encode as "(%p)" string, matching JX. There doesn't + * seem to be an appropriate tag, so pointers don't currently + * survive a CBOR encode/decode roundtrip intact. + */ + const char *ptr; + + ptr = duk_to_string(enc_ctx->thr, -1); + DUK_ASSERT(ptr != NULL); + duk_push_sprintf(enc_ctx->thr, "(%s)", ptr); + duk_remove(enc_ctx->thr, -2); + duk__cbor_encode_string_top(enc_ctx); +} + +DUK_LOCAL void duk__cbor_encode_lightfunc(duk_cbor_encode_context *enc_ctx) { + duk_uint8_t *p; + + /* Caller must ensure space. */ + DUK_ASSERT(duk__cbor_get_reserve(enc_ctx) >= 1 + 8); + + /* For now encode as an empty object. */ + p = enc_ctx->ptr; + *p++ = 0xa0U; + enc_ctx->ptr = p; +} + +DUK_LOCAL void duk__cbor_encode_value(duk_cbor_encode_context *enc_ctx) { + duk_uint8_t *p; + + /* Encode/decode cycle currently loses some type information. + * This can be improved by registering custom tags with IANA. + */ + + /* When working with deeply recursive structures, this is important + * to ensure there's no effective depth limit. + */ + duk_require_stack(enc_ctx->thr, 4); + + /* Reserve space for up to 64-bit types (1 initial byte + 8 + * followup bytes). This allows encoding of integers, floats, + * string/buffer length fields, etc without separate checks + * in each code path. + */ + duk__cbor_encode_ensure(enc_ctx, 1 + 8); + + switch (duk_get_type(enc_ctx->thr, -1)) { + case DUK_TYPE_UNDEFINED: { + p = enc_ctx->ptr; + *p++ = 0xf7; + enc_ctx->ptr = p; + break; + } + case DUK_TYPE_NULL: { + p = enc_ctx->ptr; + *p++ = 0xf6; + enc_ctx->ptr = p; + break; + } + case DUK_TYPE_BOOLEAN: { + duk_uint8_t u8 = duk_get_boolean(enc_ctx->thr, -1) ? 0xf5U : 0xf4U; + p = enc_ctx->ptr; + *p++ = u8; + enc_ctx->ptr = p; + break; + } + case DUK_TYPE_NUMBER: { + duk__cbor_encode_double(enc_ctx, duk_get_number(enc_ctx->thr, -1)); + break; + } + case DUK_TYPE_STRING: { + duk__cbor_encode_string_top(enc_ctx); + break; + } + case DUK_TYPE_OBJECT: { + duk__cbor_encode_object(enc_ctx); + break; + } + case DUK_TYPE_BUFFER: { + duk__cbor_encode_buffer(enc_ctx); + break; + } + case DUK_TYPE_POINTER: { + duk__cbor_encode_pointer(enc_ctx); + break; + } + case DUK_TYPE_LIGHTFUNC: { + duk__cbor_encode_lightfunc(enc_ctx); + break; + } + case DUK_TYPE_NONE: + default: + goto fail; + } + + duk_pop(enc_ctx->thr); + return; + + fail: + duk__cbor_encode_error(enc_ctx); +} + +/* + * Decoding + */ + +DUK_LOCAL void duk__cbor_req_stack(duk_cbor_decode_context *dec_ctx) { + duk_require_stack(dec_ctx->thr, 4); +} + +DUK_LOCAL void duk__cbor_decode_error(duk_cbor_decode_context *dec_ctx) { + (void) duk_type_error(dec_ctx->thr, "cbor decode error"); +} + +DUK_LOCAL duk_uint8_t duk__cbor_decode_readbyte(duk_cbor_decode_context *dec_ctx) { + DUK_ASSERT(dec_ctx->off <= dec_ctx->len); + if (DUK_UNLIKELY(dec_ctx->len - dec_ctx->off < 1U)) { + duk__cbor_decode_error(dec_ctx); + } + return dec_ctx->buf[dec_ctx->off++]; +} + +DUK_LOCAL duk_uint16_t duk__cbor_decode_read_u16(duk_cbor_decode_context *dec_ctx) { + duk_uint16_t res; + + DUK_ASSERT(dec_ctx->off <= dec_ctx->len); + if (DUK_UNLIKELY(dec_ctx->len - dec_ctx->off < 2U)) { + duk__cbor_decode_error(dec_ctx); + } + res = DUK_RAW_READ_U16_BE(dec_ctx->buf + dec_ctx->off); + dec_ctx->off += 2; + return res; +} + +DUK_LOCAL duk_uint32_t duk__cbor_decode_read_u32(duk_cbor_decode_context *dec_ctx) { + duk_uint32_t res; + + DUK_ASSERT(dec_ctx->off <= dec_ctx->len); + if (DUK_UNLIKELY(dec_ctx->len - dec_ctx->off < 4U)) { + duk__cbor_decode_error(dec_ctx); + } + res = DUK_RAW_READ_U32_BE(dec_ctx->buf + dec_ctx->off); + dec_ctx->off += 4; + return res; +} + +DUK_LOCAL duk_uint8_t duk__cbor_decode_peekbyte(duk_cbor_decode_context *dec_ctx) { + if (DUK_UNLIKELY(dec_ctx->off >= dec_ctx->len)) { + duk__cbor_decode_error(dec_ctx); + } + return dec_ctx->buf[dec_ctx->off]; +} + +DUK_LOCAL void duk__cbor_decode_rewind(duk_cbor_decode_context *dec_ctx, duk_size_t len) { + DUK_ASSERT(len <= dec_ctx->off); /* Caller must ensure. */ + dec_ctx->off -= len; +} + +#if 0 +DUK_LOCAL 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 + +DUK_LOCAL const duk_uint8_t *duk__cbor_decode_consume(duk_cbor_decode_context *dec_ctx, duk_size_t len) { + DUK_ASSERT(dec_ctx->off <= dec_ctx->len); + if (DUK_LIKELY(dec_ctx->len - dec_ctx->off >= len)) { + const duk_uint8_t *res = dec_ctx->buf + dec_ctx->off; + dec_ctx->off += len; + return res; + } + + duk__cbor_decode_error(dec_ctx); /* Not enough input. */ + return NULL; +} + +DUK_LOCAL int duk__cbor_decode_checkbreak(duk_cbor_decode_context *dec_ctx) { + if (duk__cbor_decode_peekbyte(dec_ctx) == 0xffU) { + DUK_ASSERT(dec_ctx->off < dec_ctx->len); + dec_ctx->off++; +#if 0 + (void) duk__cbor_decode_readbyte(dec_ctx); +#endif + return 1; + } + return 0; +} + +DUK_LOCAL void duk__cbor_decode_push_aival_int(duk_cbor_decode_context *dec_ctx, duk_uint8_t ib, duk_bool_t negative) { + duk_uint8_t ai; + duk_uint32_t t, t1, t2; +#if 0 + duk_uint64_t t3; +#endif + duk_double_t d1, d2; + duk_double_t d; + + ai = ib & 0x1fU; + if (ai <= 0x17U) { + t = ai; + goto shared_exit; + } + + switch (ai) { + case 0x18U: /* 1 byte */ + t = (duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx); + goto shared_exit; + case 0x19U: /* 2 byte */ + t = (duk_uint32_t) duk__cbor_decode_read_u16(dec_ctx); + goto shared_exit; + case 0x1aU: /* 4 byte */ + t = (duk_uint32_t) duk__cbor_decode_read_u32(dec_ctx); + goto shared_exit; + case 0x1bU: /* 8 byte */ + /* For uint64 it's important to handle the -1.0 part before + * casting to double: otherwise the adjustment might be lost + * in the cast. Uses: -1.0 - d <=> -(d + 1.0). + */ + t = (duk_uint32_t) duk__cbor_decode_read_u32(dec_ctx); + t2 = t; + t = (duk_uint32_t) duk__cbor_decode_read_u32(dec_ctx); + t1 = t; +#if 0 + t3 = (duk_uint64_t) t2 * DUK_U64_CONSTANT(0x100000000) + (duk_uint64_t) t1; + if (negative) { + if (t3 == DUK_UINT64_MAX) { + /* -(0xffff'ffff'ffff'ffffULL + 1) = + * -0x1'0000'0000'0000'0000 + * + * >>> -0x10000000000000000 + * -18446744073709551616L + */ + return -18446744073709551616.0; + } else { + return -((duk_double_t) (t3 + DUK_U64_CONSTANT(1))); + } + } else { + return (duk_double_t) t3; /* XXX: cast helper */ + } +#endif +#if 0 + t3 = (duk_uint64_t) t2 * DUK_U64_CONSTANT(0x100000000) + (duk_uint64_t) t1; + if (negative) { + /* Simpler version: take advantage of the fact that + * 0xffff'ffff'ffff'ffff and 0x1'0000'0000'0000'0000 + * both round to 0x1'0000'0000'0000'0000: + * > (0xffffffffffffffff).toString(16) + * '10000000000000000' + * > (0x10000000000000000).toString(16) + * '10000000000000000' + * + * For the DUK_UINT64_MAX case we just skip the +1 + * increment to avoid wrapping; the result still + * comes out right for an IEEE double cast. + */ + if (t3 != DUK_UINT64_MAX) { + t3++; + } + return -((duk_double_t) t3); + } else { + return (duk_double_t) t3; /* XXX: cast helper */ + } +#endif +#if 1 + /* Use two double parts, avoids dependency on 64-bit type. + * Avoid precision loss carefully, especially when dealing + * with the required +1 for negative values. + * + * No fastint check for this path at present. + */ + d1 = (duk_double_t) t1; /* XXX: cast helpers */ + d2 = (duk_double_t) t2 * 4294967296.0; + if (negative) { + d1 += 1.0; + } + d = d2 + d1; + if (negative) { + d = -d; + } +#endif + /* XXX: a push and check for fastint API would be nice */ + duk_push_number(dec_ctx->thr, d); + return; + } + + duk__cbor_decode_error(dec_ctx); + return; + + shared_exit: + if (negative) { + /* XXX: a push and check for fastint API would be nice */ + if ((duk_uint_t) t <= (duk_uint_t) -(DUK_INT_MIN + 1)) { + duk_push_int(dec_ctx->thr, -1 - ((duk_int_t) t)); + } else { + duk_push_number(dec_ctx->thr, -1.0 - (duk_double_t) t); + } + } else { + duk_push_uint(dec_ctx->thr, (duk_uint_t) t); + } +} + +DUK_LOCAL void duk__cbor_decode_skip_aival_int(duk_cbor_decode_context *dec_ctx, duk_uint8_t ib) { + const duk_int8_t skips[32] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, -1, -1, -1, -1 + }; + duk_uint8_t ai; + duk_int8_t skip; + + ai = ib & 0x1fU; + skip = skips[ai]; + if (DUK_UNLIKELY(skip < 0)) { + duk__cbor_decode_error(dec_ctx); + } + duk__cbor_decode_consume(dec_ctx, (duk_size_t) skip); + return; +} + +DUK_LOCAL duk_uint32_t duk__cbor_decode_aival_uint32(duk_cbor_decode_context *dec_ctx, duk_uint8_t ib) { + duk_uint8_t ai; + duk_uint32_t t; + + ai = ib & 0x1fU; + if (ai <= 0x17U) { + return (duk_uint32_t) ai; + } + + switch (ai) { + case 0x18U: /* 1 byte */ + t = (duk_uint32_t) duk__cbor_decode_readbyte(dec_ctx); + return t; + case 0x19U: /* 2 byte */ + t = (duk_uint32_t) duk__cbor_decode_read_u16(dec_ctx); + return t; + case 0x1aU: /* 4 byte */ + t = (duk_uint32_t) duk__cbor_decode_read_u32(dec_ctx); + return t; + case 0x1bU: /* 8 byte */ + t = (duk_uint32_t) duk__cbor_decode_read_u32(dec_ctx); + if (t != 0U) { + break; + } + t = (duk_uint32_t) duk__cbor_decode_read_u32(dec_ctx); + return t; + } + + duk__cbor_decode_error(dec_ctx); + return 0U; +} + +DUK_LOCAL 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 on purpose. */ + len = duk__cbor_decode_aival_uint32(dec_ctx, ib); + inp = duk__cbor_decode_consume(dec_ctx, len); + /* XXX: duk_push_fixed_buffer_with_data() would be a nice API addition. */ + buf = (duk_uint8_t *) duk_push_fixed_buffer(dec_ctx->thr, (duk_size_t) len); + duk_memcpy((void *) buf, (const void *) inp, (size_t) len); +} + +DUK_LOCAL 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->thr); + duk_idx_t base = top - count; /* count is >= 1 */ + duk_idx_t idx; + duk_uint8_t *p = NULL; + + DUK_ASSERT(count >= 1); + DUK_ASSERT(top >= count); + + for (;;) { + /* First round: compute total size. + * Second round: copy into place. + */ + 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->thr, idx, &buf_size); + if (p != NULL) { + if (buf_size > 0U) { + duk_memcpy((void *) p, (const void *) buf_data, buf_size); + } + p += buf_size; + } else { + total_size += buf_size; + if (DUK_UNLIKELY(total_size < buf_size)) { /* Wrap check. */ + duk__cbor_decode_error(dec_ctx); + } + } + } + + if (p != NULL) { + break; + } else { + p = (duk_uint8_t *) duk_push_fixed_buffer(dec_ctx->thr, total_size); + DUK_ASSERT(p != NULL); + } + } + + duk_replace(dec_ctx->thr, base); + duk_pop_n(dec_ctx->thr, count - 1); +} + +DUK_LOCAL 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_require_stack(dec_ctx->thr, 1); + duk__cbor_decode_buffer(dec_ctx, expected_base); + count++; + if (DUK_UNLIKELY(count <= 0)) { /* Wrap check. */ + duk__cbor_decode_error(dec_ctx); + } + } + if (count == 0) { + (void) duk_push_fixed_buffer(dec_ctx->thr, 0); + } else if (count > 1) { + duk__cbor_decode_join_buffers(dec_ctx, count); + } +} + +DUK_LOCAL duk_double_t duk__cbor_decode_half_float(duk_cbor_decode_context *dec_ctx) { + duk_double_union u; + const duk_uint8_t *inp; + duk_int_t expt; + 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]; + expt = (duk_int_t) ((u16 >> 10) & 0x1fU) - 15; + + /* Reconstruct IEEE double into little endian order first, then convert + * to host order. + */ + + duk_memzero((void *) &u, sizeof(u)); + + if (expt == -15) { + /* Zero or denormal; but note that half float + * denormals become double normals. + */ + if ((u16 & 0x03ffU) == 0) { + u.uc[7] = inp[0] & 0x80U; + } 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.uc[7] = 0x3fU; + u.uc[6] = 0x10U + (duk_uint8_t) ((u16 >> 6) & 0x0fU); + u.uc[5] = (duk_uint8_t) ((u16 << 2) & 0xffU); /* Mask is really 0xfcU */ + + duk_dblunion_little_to_host(&u); + res = u.d - 0.00006103515625; /* 2^(-14) */ + if (u16 & 0x8000U) { + res = -res; + } + return res; + } + } else if (expt == 16) { + /* +/- Inf or NaN. */ + if ((u16 & 0x03ffU) == 0) { + u.uc[7] = (inp[0] & 0x80U) + 0x7fU; + u.uc[6] = 0xf0U; + } else { + /* Create a 'quiet NaN' with highest + * bit set (there are some platforms + * where the NaN payload convention is + * the opposite). Keep sign. + */ + u.uc[7] = (inp[0] & 0x80U) + 0x7fU; + u.uc[6] = 0xf8U; + } + } else { + /* Normal. */ + tmp = (inp[0] & 0x80U) ? 0x80000000UL : 0UL; + tmp += (duk_uint_t) (expt + 1023) << 20; + tmp += (duk_uint_t) (inp[0] & 0x03U) << 18; + tmp += (duk_uint_t) (inp[1] & 0xffU) << 10; + u.uc[7] = (tmp >> 24) & 0xffU; + u.uc[6] = (tmp >> 16) & 0xffU; + u.uc[5] = (tmp >> 8) & 0xffU; + u.uc[4] = (tmp >> 0) & 0xffU; + } + + duk_dblunion_little_to_host(&u); + return u.d; +} + +DUK_LOCAL void duk__cbor_decode_string(duk_cbor_decode_context *dec_ctx, duk_uint8_t ib, duk_uint8_t ai) { + /* If the CBOR string data is not valid UTF-8 it is technically + * invalid CBOR. Possible behaviors at least: + * + * 1. Reject the input, i.e. throw TypeError. + * + * 2. Accept the input, but sanitize non-UTF-8 data into UTF-8 + * using U+FFFD replacements. Also it might make sense to + * decode non-BMP codepoints into surrogates for better + * ECMAScript compatibility. + * + * 3. Accept the input as a Duktape string (which are not always + * valid UTF-8), but reject any input that would create a + * Symbol representation. + * + * Current behavior is 3. + */ + + 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->thr, -1, &buf_size); + (void) duk_push_lstring(dec_ctx->thr, (const char *) buf_data, buf_size); + duk_remove(dec_ctx->thr, -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->thr, (const char *) inp, (duk_size_t) len); + } + if (duk_is_symbol(dec_ctx->thr, -1)) { + /* Refuse to create Symbols when decoding. */ + duk__cbor_decode_error(dec_ctx); + } + + /* XXX: Here a Duktape API call to convert input -> utf-8 with + * replacements would be nice. + */ +} + +DUK_LOCAL duk_bool_t duk__cbor_decode_array(duk_cbor_decode_context *dec_ctx, duk_uint8_t ib, duk_uint8_t ai) { + duk_uint32_t idx, len; + + duk__cbor_req_stack(dec_ctx); + + /* 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) { + return 0; + } + } + + /* XXX: use bare array? */ + duk_push_array(dec_ctx->thr); + for (idx = 0U; ;) { + if (len == 0xffffffffUL && duk__cbor_decode_checkbreak(dec_ctx)) { + break; + } + if (idx == len) { + if (ai == 0x1fU) { + return 0; + } + break; + } + duk__cbor_decode_value(dec_ctx); + duk_put_prop_index(dec_ctx->thr, -2, (duk_uarridx_t) idx); + idx++; + if (idx == 0U) { + return 0; /* wrapped */ + } + } + + return 1; +} + +DUK_LOCAL duk_bool_t duk__cbor_decode_map(duk_cbor_decode_context *dec_ctx, duk_uint8_t ib, duk_uint8_t ai) { + duk_uint32_t count; + + duk__cbor_req_stack(dec_ctx); + + if (ai == 0x1fU) { + count = 0xffffffffUL; + } else { + count = duk__cbor_decode_aival_uint32(dec_ctx, ib); + if (count == 0xffffffffUL) { + return 0; + } + } + + /* XXX: use bare object? */ + duk_push_object(dec_ctx->thr); + 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->thr, -3); + } + + return 1; +} + +DUK_LOCAL duk_double_t duk__cbor_decode_float(duk_cbor_decode_context *dec_ctx) { + duk_float_union u; + const duk_uint8_t *inp; + inp = duk__cbor_decode_consume(dec_ctx, 4); + duk_memcpy((void *) u.uc, (const void *) inp, 4); + duk_fltunion_big_to_host(&u); + return (duk_double_t) u.f; +} + +DUK_LOCAL duk_double_t duk__cbor_decode_double(duk_cbor_decode_context *dec_ctx) { + duk_double_union u; + const duk_uint8_t *inp; + inp = duk__cbor_decode_consume(dec_ctx, 8); + duk_memcpy((void *) u.uc, (const void *) inp, 8); + duk_dblunion_big_to_host(&u); + return u.d; +} + +#if defined(DUK_CBOR_DECODE_FASTPATH) +#define DUK__CBOR_AI (ib & 0x1fU) + +DUK_LOCAL void duk__cbor_decode_value(duk_cbor_decode_context *dec_ctx) { + duk_uint8_t ib; + + /* Any paths potentially recursing back to duk__cbor_decode_value() + * must perform a Duktape value stack growth check. Avoid the check + * here for simple paths like primitive values. + */ + + reread_initial_byte: + DUK_DDD(DUK_DDDPRINT("cbor decode off=%ld len=%ld", (long) dec_ctx->off, (long) dec_ctx->len)); + + ib = duk__cbor_decode_readbyte(dec_ctx); + + /* Full initial byte switch, footprint cost over baseline is ~+1kB. */ + /* XXX: Force full switch with no range check. */ + + switch (ib) { + case 0x00U: case 0x01U: case 0x02U: case 0x03U: case 0x04U: case 0x05U: case 0x06U: case 0x07U: + case 0x08U: case 0x09U: case 0x0aU: case 0x0bU: case 0x0cU: case 0x0dU: case 0x0eU: case 0x0fU: + case 0x10U: case 0x11U: case 0x12U: case 0x13U: case 0x14U: case 0x15U: case 0x16U: case 0x17U: + duk_push_uint(dec_ctx->thr, ib); + break; + case 0x18U: case 0x19U: case 0x1aU: case 0x1bU: + duk__cbor_decode_push_aival_int(dec_ctx, ib, 0 /*negative*/); + break; + case 0x1cU: case 0x1dU: case 0x1eU: case 0x1fU: + goto format_error; + case 0x20U: case 0x21U: case 0x22U: case 0x23U: case 0x24U: case 0x25U: case 0x26U: case 0x27U: + case 0x28U: case 0x29U: case 0x2aU: case 0x2bU: case 0x2cU: case 0x2dU: case 0x2eU: case 0x2fU: + case 0x30U: case 0x31U: case 0x32U: case 0x33U: case 0x34U: case 0x35U: case 0x36U: case 0x37U: + duk_push_int(dec_ctx->thr, -((duk_int_t) ((ib - 0x20U) + 1U))); + break; + case 0x38U: case 0x39U: case 0x3aU: case 0x3bU: + duk__cbor_decode_push_aival_int(dec_ctx, ib, 1 /*negative*/); + break; + case 0x3cU: case 0x3dU: case 0x3eU: case 0x3fU: + goto format_error; + case 0x40U: case 0x41U: case 0x42U: case 0x43U: case 0x44U: case 0x45U: case 0x46U: case 0x47U: + case 0x48U: case 0x49U: case 0x4aU: case 0x4bU: case 0x4cU: case 0x4dU: case 0x4eU: case 0x4fU: + case 0x50U: case 0x51U: case 0x52U: case 0x53U: case 0x54U: case 0x55U: case 0x56U: case 0x57U: + /* XXX: Avoid rewind, we know the length already. */ + DUK_ASSERT(dec_ctx->off > 0U); + dec_ctx->off--; + duk__cbor_decode_buffer(dec_ctx, 0x40U); + break; + case 0x58U: case 0x59U: case 0x5aU: case 0x5bU: + /* XXX: Avoid rewind, decode length inline. */ + DUK_ASSERT(dec_ctx->off > 0U); + dec_ctx->off--; + duk__cbor_decode_buffer(dec_ctx, 0x40U); + break; + case 0x5cU: case 0x5dU: case 0x5eU: + goto format_error; + case 0x5fU: + duk__cbor_decode_and_join_strbuf(dec_ctx, 0x40U); + break; + case 0x60U: case 0x61U: case 0x62U: case 0x63U: case 0x64U: case 0x65U: case 0x66U: case 0x67U: + case 0x68U: case 0x69U: case 0x6aU: case 0x6bU: case 0x6cU: case 0x6dU: case 0x6eU: case 0x6fU: + case 0x70U: case 0x71U: case 0x72U: case 0x73U: case 0x74U: case 0x75U: case 0x76U: case 0x77U: + /* XXX: Avoid double decode of length. */ + duk__cbor_decode_string(dec_ctx, ib, DUK__CBOR_AI); + break; + case 0x78U: case 0x79U: case 0x7aU: case 0x7bU: + /* XXX: Avoid double decode of length. */ + duk__cbor_decode_string(dec_ctx, ib, DUK__CBOR_AI); + break; + case 0x7cU: case 0x7dU: case 0x7eU: + goto format_error; + case 0x7fU: + duk__cbor_decode_string(dec_ctx, ib, DUK__CBOR_AI); + break; + case 0x80U: case 0x81U: case 0x82U: case 0x83U: case 0x84U: case 0x85U: case 0x86U: case 0x87U: + case 0x88U: case 0x89U: case 0x8aU: case 0x8bU: case 0x8cU: case 0x8dU: case 0x8eU: case 0x8fU: + case 0x90U: case 0x91U: case 0x92U: case 0x93U: case 0x94U: case 0x95U: case 0x96U: case 0x97U: + if (DUK_UNLIKELY(duk__cbor_decode_array(dec_ctx, ib, DUK__CBOR_AI) == 0)) { + goto format_error; + } + break; + case 0x98U: case 0x99U: case 0x9aU: case 0x9bU: + if (DUK_UNLIKELY(duk__cbor_decode_array(dec_ctx, ib, DUK__CBOR_AI) == 0)) { + goto format_error; + } + break; + case 0x9cU: case 0x9dU: case 0x9eU: + goto format_error; + case 0x9fU: + if (DUK_UNLIKELY(duk__cbor_decode_array(dec_ctx, ib, DUK__CBOR_AI) == 0)) { + goto format_error; + } + break; + case 0xa0U: case 0xa1U: case 0xa2U: case 0xa3U: case 0xa4U: case 0xa5U: case 0xa6U: case 0xa7U: + case 0xa8U: case 0xa9U: case 0xaaU: case 0xabU: case 0xacU: case 0xadU: case 0xaeU: case 0xafU: + case 0xb0U: case 0xb1U: case 0xb2U: case 0xb3U: case 0xb4U: case 0xb5U: case 0xb6U: case 0xb7U: + if (DUK_UNLIKELY(duk__cbor_decode_map(dec_ctx, ib, DUK__CBOR_AI) == 0)) { + goto format_error; + } + break; + case 0xb8U: case 0xb9U: case 0xbaU: case 0xbbU: + if (DUK_UNLIKELY(duk__cbor_decode_map(dec_ctx, ib, DUK__CBOR_AI) == 0)) { + goto format_error; + } + break; + case 0xbcU: case 0xbdU: case 0xbeU: + goto format_error; + case 0xbfU: + if (DUK_UNLIKELY(duk__cbor_decode_map(dec_ctx, ib, DUK__CBOR_AI) == 0)) { + goto format_error; + } + break; + case 0xc0U: case 0xc1U: case 0xc2U: case 0xc3U: case 0xc4U: case 0xc5U: case 0xc6U: case 0xc7U: + case 0xc8U: case 0xc9U: case 0xcaU: case 0xcbU: case 0xccU: case 0xcdU: case 0xceU: case 0xcfU: + case 0xd0U: case 0xd1U: case 0xd2U: case 0xd3U: case 0xd4U: case 0xd5U: case 0xd6U: case 0xd7U: + /* Tag 0-23: drop. */ + goto reread_initial_byte; + case 0xd8U: case 0xd9U: case 0xdaU: case 0xdbU: + duk__cbor_decode_skip_aival_int(dec_ctx, ib); + goto reread_initial_byte; + case 0xdcU: case 0xddU: case 0xdeU: case 0xdfU: + goto format_error; + case 0xe0U: + goto format_error; + case 0xe1U: + goto format_error; + case 0xe2U: + goto format_error; + case 0xe3U: + goto format_error; + case 0xe4U: + goto format_error; + case 0xe5U: + goto format_error; + case 0xe6U: + goto format_error; + case 0xe7U: + goto format_error; + case 0xe8U: + goto format_error; + case 0xe9U: + goto format_error; + case 0xeaU: + goto format_error; + case 0xebU: + goto format_error; + case 0xecU: + goto format_error; + case 0xedU: + goto format_error; + case 0xeeU: + goto format_error; + case 0xefU: + goto format_error; + case 0xf0U: + goto format_error; + case 0xf1U: + goto format_error; + case 0xf2U: + goto format_error; + case 0xf3U: + goto format_error; + case 0xf4U: + duk_push_false(dec_ctx->thr); + break; + case 0xf5U: + duk_push_true(dec_ctx->thr); + break; + case 0xf6U: + duk_push_null(dec_ctx->thr); + break; + case 0xf7U: + duk_push_undefined(dec_ctx->thr); + break; + case 0xf8U: + /* Simple value 32-255, nothing defined yet, so reject. */ + goto format_error; + case 0xf9U: { + duk_double_t d; + d = duk__cbor_decode_half_float(dec_ctx); + duk_push_number(dec_ctx->thr, d); + break; + } + case 0xfaU: { + duk_double_t d; + d = duk__cbor_decode_float(dec_ctx); + duk_push_number(dec_ctx->thr, d); + break; + } + case 0xfbU: { + duk_double_t d; + d = duk__cbor_decode_double(dec_ctx); + duk_push_number(dec_ctx->thr, d); + break; + } + case 0xfcU: + case 0xfdU: + case 0xfeU: + case 0xffU: + goto format_error; + } /* end switch */ + + return; + + format_error: + duk__cbor_decode_error(dec_ctx); +} +#else /* DUK_CBOR_DECODE_FASTPATH */ +DUK_LOCAL void duk__cbor_decode_value(duk_cbor_decode_context *dec_ctx) { + duk_uint8_t ib, mt, ai; + + /* Any paths potentially recursing back to duk__cbor_decode_value() + * must perform a Duktape value stack growth check. Avoid the check + * here for simple paths like primitive values. + */ + + reread_initial_byte: + DUK_DDD(DUK_DDDPRINT("cbor decode off=%ld len=%ld", (long) dec_ctx->off, (long) dec_ctx->len)); + + 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__cbor_decode_push_aival_int(dec_ctx, ib, 0 /*negative*/); + break; + } + case 1U: { /* negative integer */ + duk__cbor_decode_push_aival_int(dec_ctx, ib, 1 /*negative*/); + 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 */ + duk__cbor_decode_string(dec_ctx, ib, ai); + break; + } + case 4U: { /* array of data items */ + if (DUK_UNLIKELY(duk__cbor_decode_array(dec_ctx, ib, ai) == 0)) { + goto format_error; + } + break; + } + case 5U: { /* map of pairs of data items */ + if (DUK_UNLIKELY(duk__cbor_decode_map(dec_ctx, ib, ai) == 0)) { + goto format_error; + } + 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. + */ + duk__cbor_decode_skip_aival_int(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->thr); + break; + } + case 0x15U: { + duk_push_true(dec_ctx->thr); + break; + } + case 0x16U: { + duk_push_null(dec_ctx->thr); + break; + } + case 0x17U: { + duk_push_undefined(dec_ctx->thr); + break; + } + case 0x18U: { /* more simple values (1 byte) */ + /* Simple value encoded in additional byte (none + * are defined so far). RFC 7049 states that the + * follow-up byte must be 32-255 to minimize + * confusion. So, a non-shortest encoding like + * f815 (= true, shortest encoding f5) must be + * rejected. cbor.me tester rejects f815, but + * e.g. Python CBOR binding decodes it as true. + */ + goto format_error; + } + case 0x19U: { /* half-float (2 bytes) */ + duk_double_t d; + d = duk__cbor_decode_half_float(dec_ctx); + duk_push_number(dec_ctx->thr, d); + break; + } + case 0x1aU: { /* float (4 bytes) */ + duk_double_t d; + d = duk__cbor_decode_float(dec_ctx); + duk_push_number(dec_ctx->thr, d); + break; + } + case 0x1bU: { /* double (8 bytes) */ + duk_double_t d; + d = duk__cbor_decode_double(dec_ctx); + duk_push_number(dec_ctx->thr, 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); +} +#endif /* DUK_CBOR_DECODE_FASTPATH */ + +DUK_LOCAL void duk__cbor_encode(duk_hthread *thr, duk_idx_t idx, duk_uint_t encode_flags) { + duk_cbor_encode_context enc_ctx; + duk_uint8_t *buf; + + DUK_UNREF(encode_flags); + + idx = duk_require_normalize_index(thr, idx); + + enc_ctx.thr = thr; + enc_ctx.idx_buf = duk_get_top(thr); + + enc_ctx.len = 64; + buf = (duk_uint8_t *) duk_push_dynamic_buffer(thr, enc_ctx.len); + enc_ctx.ptr = buf; + enc_ctx.buf = buf; + enc_ctx.buf_end = buf + enc_ctx.len; + + duk_dup(thr, idx); + duk__cbor_encode_value(&enc_ctx); + duk_resize_buffer(enc_ctx.thr, enc_ctx.idx_buf, (duk_size_t) (enc_ctx.ptr - enc_ctx.buf)); + duk_replace(thr, idx); +} + +DUK_LOCAL void duk__cbor_decode(duk_hthread *thr, duk_idx_t idx, duk_uint_t decode_flags) { + duk_cbor_decode_context dec_ctx; + + DUK_UNREF(decode_flags); + + /* Suppress compile warnings for functions only needed with e.g. + * asserts enabled. + */ + DUK_UNREF(duk__cbor_get_reserve); + + idx = duk_require_normalize_index(thr, idx); + + dec_ctx.thr = thr; + dec_ctx.buf = (const duk_uint8_t *) duk_require_buffer_data(thr, idx, &dec_ctx.len); + dec_ctx.off = 0; + /* dec_ctx.len: set above */ + + duk__cbor_req_stack(&dec_ctx); + duk__cbor_decode_value(&dec_ctx); + if (dec_ctx.off != dec_ctx.len) { + (void) duk_type_error(thr, "trailing garbage"); + } + + duk_replace(thr, idx); +} + +#else /* DUK_USE_CBOR_SUPPORT */ + +DUK_LOCAL void duk__cbor_encode(duk_hthread *thr, duk_idx_t idx, duk_uint_t encode_flags) { + DUK_UNREF(idx); + DUK_UNREF(encode_flags); + DUK_ERROR_UNSUPPORTED(thr); +} + +DUK_LOCAL void duk__cbor_decode(duk_hthread *thr, duk_idx_t idx, duk_uint_t decode_flags) { + DUK_UNREF(idx); + DUK_UNREF(decode_flags); + DUK_ERROR_UNSUPPORTED(thr); +} + +#endif /* DUK_USE_CBOR_SUPPORT */ + +/* + * Public APIs + */ + +DUK_EXTERNAL void duk_cbor_encode(duk_hthread *thr, duk_idx_t idx, duk_uint_t encode_flags) { + DUK_ASSERT_API_ENTRY(thr); + duk__cbor_encode(thr, idx, encode_flags); +} +DUK_EXTERNAL void duk_cbor_decode(duk_hthread *thr, duk_idx_t idx, duk_uint_t decode_flags) { + DUK_ASSERT_API_ENTRY(thr); + duk__cbor_decode(thr, idx, decode_flags); +} + +#if defined(DUK_USE_CBOR_BUILTIN) +#if defined(DUK_USE_CBOR_SUPPORT) +DUK_INTERNAL duk_ret_t duk_bi_cbor_encode(duk_hthread *thr) { + DUK_ASSERT_TOP(thr, 1); + + duk__cbor_encode(thr, -1, 0 /*flags*/); + + /* Produce an ArrayBuffer by first decoding into a plain buffer which + * mimics a Uint8Array and gettings its .buffer property. + */ + /* XXX: shortcut */ + (void) duk_get_prop_stridx(thr, -1, DUK_STRIDX_LC_BUFFER); + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_cbor_decode(duk_hthread *thr) { + DUK_ASSERT_TOP(thr, 1); + + duk__cbor_decode(thr, -1, 0 /*flags*/); + return 1; +} +#else /* DUK_USE_CBOR_SUPPORT */ +DUK_INTERNAL duk_ret_t duk_bi_cbor_encode(duk_hthread *thr) { + DUK_ERROR_UNSUPPORTED(thr); + DUK_WO_NORETURN(return 0;); +} +DUK_INTERNAL duk_ret_t duk_bi_cbor_decode(duk_hthread *thr) { + DUK_ERROR_UNSUPPORTED(thr); + DUK_WO_NORETURN(return 0;); +} +#endif /* DUK_USE_CBOR_SUPPORT */ +#endif /* DUK_USE_CBOR_BUILTIN */ + +/* automatic undefs */ +#undef DUK__CBOR_AI #line 1 "duk_bi_date.c" /* * Date built-ins @@ -30423,7 +32347,7 @@ DUK_INTERNAL void duk_bi_date_timeval_to_parts(duk_double_t d, duk_int_t *parts, DUK_ASSERT(DUK_ISFINITE(d)); /* caller checks */ d = DUK_FLOOR(d); /* remove fractions if present */ - DUK_ASSERT(DUK_FLOOR(d) == d); + DUK_ASSERT(duk_double_equals(DUK_FLOOR(d), d)); /* 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 @@ -30442,13 +32366,13 @@ DUK_INTERNAL void duk_bi_date_timeval_to_parts(duk_double_t d, duk_int_t *parts, d1 += (duk_double_t) DUK_DATE_MSEC_DAY; } d2 = DUK_FLOOR((double) (d / (duk_double_t) DUK_DATE_MSEC_DAY)); - DUK_ASSERT(d2 * ((duk_double_t) DUK_DATE_MSEC_DAY) + d1 == d); + DUK_ASSERT(duk_double_equals(d2 * ((duk_double_t) DUK_DATE_MSEC_DAY) + d1, d)); /* now expected to fit into a 32-bit integer */ t1 = (duk_int_t) d1; t2 = (duk_int_t) d2; day_since_epoch = t2; - DUK_ASSERT((duk_double_t) t1 == d1); - DUK_ASSERT((duk_double_t) t2 == d2); + DUK_ASSERT(duk_double_equals((duk_double_t) t1, d1)); + DUK_ASSERT(duk_double_equals((duk_double_t) t2, d2)); /* t1 = milliseconds within day (fits 32 bit) * t2 = day number from epoch (fits 32 bit, may be negative) @@ -31305,7 +33229,7 @@ DUK_INTERNAL duk_ret_t duk_bi_date_constructor_now(duk_hthread *thr) { duk_double_t d; d = duk_time_get_ecmascript_time_nofrac(thr); - DUK_ASSERT(duk__timeclip(d) == d); /* TimeClip() should never be necessary */ + DUK_ASSERT(duk_double_equals(duk__timeclip(d), d)); /* TimeClip() should never be necessary */ duk_push_number(thr, d); return 1; } @@ -34800,7 +36724,7 @@ DUK_LOCAL duk_small_int_t duk__dec_string_escape(duk_json_dec_ctx *js_ctx, duk_u return 1; /* syntax error */ } - DUK_RAW_WRITE_XUTF8(*ext_p, cp); + DUK_RAW_WRITEINC_XUTF8(*ext_p, cp); return 0; } @@ -35393,7 +37317,7 @@ DUK_LOCAL void duk__dec_reviver_walk(duk_json_dec_ctx *js_ctx) { h = duk_get_hobject(thr, -1); if (h != NULL) { - if (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY) { + if (duk_js_isarray_hobject(h)) { arr_len = (duk_uarridx_t) duk_get_length(thr, -1); for (i = 0; i < arr_len; i++) { /* [ ... holder name val ] */ @@ -35744,7 +37668,7 @@ DUK_LOCAL void duk__enc_quote_string(duk_json_enc_ctx *js_ctx, duk_hstring *h_st q = duk__emit_esc_auto_fast(js_ctx, cp, q); } else { /* as is */ - DUK_RAW_WRITE_XUTF8(q, cp); + DUK_RAW_WRITEINC_XUTF8(q, cp); } } } @@ -36596,7 +38520,7 @@ DUK_LOCAL duk_bool_t duk__enc_value(duk_json_enc_ctx *js_ctx, duk_idx_t idx_hold */ DUK_ASSERT(!DUK_HOBJECT_IS_CALLABLE(h)); - if (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY) { + if (duk_js_isarray_hobject(h)) { duk__enc_array(js_ctx); } else { duk__enc_object(js_ctx); @@ -37432,7 +39356,7 @@ void duk_bi_json_stringify_helper(duk_hthread *thr, if (h != NULL) { if (DUK_HOBJECT_IS_CALLABLE(h)) { js_ctx->h_replacer = h; - } else if (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY) { + } else if (duk_js_isarray_hobject(h)) { /* Here the specification requires correct array index enumeration * which is a bit tricky for sparse arrays (it is handled by the * enum setup code). We now enumerate ancestors too, although the @@ -37744,7 +39668,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. */ - if (x == 0 && y == 0) { + if (duk_double_equals(x, 0.0) && duk_double_equals(y, 0.0)) { duk_double_union du1, du2; du1.d = x; du2.d = y; @@ -37771,7 +39695,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. */ - if (x == 0 && y == 0) { + if (duk_double_equals(x, 0.0) && duk_double_equals(y, 0.0)) { if (DUK_SIGNBIT(x) == 0 || DUK_SIGNBIT(y) == 0) { return +0.0; } else { @@ -37938,10 +39862,11 @@ DUK_LOCAL double duk__atan2_fixed(double x, double y) { } #else /* Some ISO C assumptions. */ - DUK_ASSERT(DUK_ATAN2(DUK_DOUBLE_INFINITY, DUK_DOUBLE_INFINITY) == 0.7853981633974483); - DUK_ASSERT(DUK_ATAN2(-DUK_DOUBLE_INFINITY, DUK_DOUBLE_INFINITY) == -0.7853981633974483); - DUK_ASSERT(DUK_ATAN2(DUK_DOUBLE_INFINITY, -DUK_DOUBLE_INFINITY) == 2.356194490192345); - DUK_ASSERT(DUK_ATAN2(-DUK_DOUBLE_INFINITY, -DUK_DOUBLE_INFINITY) == -2.356194490192345); + + DUK_ASSERT(duk_double_equals(DUK_ATAN2(DUK_DOUBLE_INFINITY, DUK_DOUBLE_INFINITY), 0.7853981633974483)); + DUK_ASSERT(duk_double_equals(DUK_ATAN2(-DUK_DOUBLE_INFINITY, DUK_DOUBLE_INFINITY), -0.7853981633974483)); + DUK_ASSERT(duk_double_equals(DUK_ATAN2(DUK_DOUBLE_INFINITY, -DUK_DOUBLE_INFINITY), 2.356194490192345)); + DUK_ASSERT(duk_double_equals(DUK_ATAN2(-DUK_DOUBLE_INFINITY, -DUK_DOUBLE_INFINITY), -2.356194490192345)); #endif return DUK_ATAN2(x, y); @@ -38081,13 +40006,13 @@ DUK_INTERNAL duk_ret_t duk_bi_math_object_hypot(duk_hthread *thr) { } /* Early return cases. */ - if (max == DUK_DOUBLE_INFINITY) { + if (duk_double_equals(max, DUK_DOUBLE_INFINITY)) { duk_push_number(thr, DUK_DOUBLE_INFINITY); return 1; } else if (found_nan) { duk_push_number(thr, DUK_DOUBLE_NAN); return 1; - } else if (max == 0.0) { + } else if (duk_double_equals(max, 0.0)) { duk_push_number(thr, 0.0); /* Otherwise we'd divide by zero. */ return 1; @@ -38122,7 +40047,7 @@ DUK_INTERNAL duk_ret_t duk_bi_math_object_sign(duk_hthread *thr) { DUK_ASSERT(duk_is_nan(thr, -1)); return 1; /* NaN input -> return NaN */ } - if (d == 0.0) { + if (duk_double_equals(d, 0.0)) { /* Zero sign kept, i.e. -0 -> -0, +0 -> +0. */ return 1; } @@ -46480,7 +48405,28 @@ DUK_LOCAL void duk__add_compiler_error_line(duk_hthread *thr) { (duk_tval *) duk_get_tval(thr, -1))); if (duk_get_prop_stridx_short(thr, -1, DUK_STRIDX_MESSAGE)) { - duk_push_sprintf(thr, " (line %ld)", (long) thr->compile_ctx->curr_token.start_line); + duk_bool_t at_end; + + /* Best guesstimate that error occurred at end of input, token + * truncated by end of input, etc. + */ +#if 0 + at_end = (thr->compile_ctx->curr_token.start_offset + 1 >= thr->compile_ctx->lex.input_length); + at_end = (thr->compile_ctx->lex.window[0].codepoint < 0 || thr->compile_ctx->lex.window[1].codepoint < 0); +#endif + at_end = (thr->compile_ctx->lex.window[0].codepoint < 0); + + DUK_D(DUK_DPRINT("syntax error, determined at_end=%ld; curr_token.start_offset=%ld, " + "lex.input_length=%ld, window[0].codepoint=%ld, window[1].codepoint=%ld", + (long) at_end, + (long) thr->compile_ctx->curr_token.start_offset, + (long) thr->compile_ctx->lex.input_length, + (long) thr->compile_ctx->lex.window[0].codepoint, + (long) thr->compile_ctx->lex.window[1].codepoint)); + + duk_push_sprintf(thr, " (line %ld%s)", + (long) thr->compile_ctx->curr_token.start_line, + at_end ? ", end of input" : ""); duk_concat(thr, 2); duk_put_prop_stridx_short(thr, -2, DUK_STRIDX_MESSAGE); } else { @@ -50586,84 +52532,31 @@ DUK_INTERNAL void duk_heap_mark_and_sweep(duk_heap *heap, duk_small_uint_t flags /* #include duk_internal.h -> already included */ /* - * Voluntary GC check - */ - -#if defined(DUK_USE_VOLUNTARY_GC) -DUK_LOCAL DUK_INLINE void duk__check_voluntary_gc(duk_heap *heap) { - if (DUK_UNLIKELY(--(heap)->ms_trigger_counter < 0)) { -#if defined(DUK_USE_DEBUG) - if (heap->ms_prevent_count == 0) { - DUK_D(DUK_DPRINT("triggering voluntary mark-and-sweep")); - } else { - DUK_DD(DUK_DDPRINT("gc blocked -> skip voluntary mark-and-sweep now")); - } -#endif - - /* Prevention checks in the call target handle cases where - * voluntary GC is not allowed. The voluntary GC trigger - * counter is only rewritten if mark-and-sweep actually runs. - */ - duk_heap_mark_and_sweep(heap, DUK_MS_FLAG_VOLUNTARY /*flags*/); - } -} -#define DUK__VOLUNTARY_PERIODIC_GC(heap) do { duk__check_voluntary_gc((heap)); } while (0) -#else -#define DUK__VOLUNTARY_PERIODIC_GC(heap) /* no voluntary gc */ -#endif /* DUK_USE_VOLUNTARY_GC */ - -/* - * Allocate memory with garbage collection + * Allocate memory with garbage collection. */ -DUK_INTERNAL void *duk_heap_mem_alloc(duk_heap *heap, duk_size_t size) { +/* Slow path: voluntary GC triggered, first alloc attempt failed, or zero size. */ +DUK_LOCAL DUK_NOINLINE_PERF DUK_COLD void *duk__heap_mem_alloc_slowpath(duk_heap *heap, duk_size_t size) { void *res; duk_small_int_t i; DUK_ASSERT(heap != NULL); + DUK_ASSERT(heap->alloc_func != NULL); DUK_ASSERT_DISABLE(size >= 0); - /* - * Voluntary periodic GC (if enabled) - */ - - DUK__VOLUNTARY_PERIODIC_GC(heap); - - /* - * First attempt - */ - -#if defined(DUK_USE_GC_TORTURE) - /* Simulate alloc failure on every alloc, except when mark-and-sweep - * is running. - */ - if (heap->ms_prevent_count == 0) { - DUK_DDD(DUK_DDDPRINT("gc torture enabled, pretend that first alloc attempt fails")); - res = NULL; - DUK_UNREF(res); - goto skip_attempt; - } -#endif - res = heap->alloc_func(heap->heap_udata, size); - if (DUK_LIKELY(res || size == 0)) { - /* For zero size allocations NULL is allowed. */ - return res; + if (size == 0) { + DUK_D(DUK_DPRINT("zero size alloc in slow path, return NULL")); + return NULL; } -#if defined(DUK_USE_GC_TORTURE) - skip_attempt: -#endif - DUK_D(DUK_DPRINT("first alloc attempt failed, attempt to gc and retry")); + DUK_D(DUK_DPRINT("first alloc attempt failed or voluntary GC limit reached, attempt to gc and retry")); #if 0 /* - * Avoid a GC if GC is already running. This can happen at a late - * stage in a GC when we try to e.g. resize the stringtable - * or compact objects. - * - * NOTE: explicit handling isn't actually be needed: if the GC is - * not allowed, duk_heap_mark_and_sweep() will reject it for every - * attempt in the loop below, resulting in a NULL same as here. + * If GC is already running there is no point in attempting a GC + * because it will be skipped. This could be checked for explicitly, + * but it isn't actually needed: the loop below will eventually + * fail resulting in a NULL. */ if (heap->ms_prevent_count != 0) { @@ -50688,8 +52581,9 @@ DUK_INTERNAL void *duk_heap_mem_alloc(duk_heap *heap, duk_size_t size) { duk_heap_mark_and_sweep(heap, flags); + DUK_ASSERT(size > 0); res = heap->alloc_func(heap->heap_udata, size); - if (res) { + if (res != NULL) { DUK_D(DUK_DPRINT("duk_heap_mem_alloc() succeeded after gc (pass %ld), alloc size %ld", (long) (i + 1), (long) size)); return res; @@ -50700,10 +52594,56 @@ DUK_INTERNAL void *duk_heap_mem_alloc(duk_heap *heap, duk_size_t size) { return NULL; } -DUK_INTERNAL void *duk_heap_mem_alloc_zeroed(duk_heap *heap, duk_size_t size) { +DUK_INTERNAL DUK_INLINE_PERF DUK_HOT void *duk_heap_mem_alloc(duk_heap *heap, duk_size_t size) { void *res; DUK_ASSERT(heap != NULL); + DUK_ASSERT(heap->alloc_func != NULL); + DUK_ASSERT_DISABLE(size >= 0); + +#if defined(DUK_USE_VOLUNTARY_GC) + /* Voluntary periodic GC (if enabled). */ + if (DUK_UNLIKELY(--(heap)->ms_trigger_counter < 0)) { + goto slowpath; + } +#endif + +#if defined(DUK_USE_GC_TORTURE) + /* Simulate alloc failure on every alloc, except when mark-and-sweep + * is running. + */ + if (heap->ms_prevent_count == 0) { + DUK_DDD(DUK_DDDPRINT("gc torture enabled, pretend that first alloc attempt fails")); + res = NULL; + DUK_UNREF(res); + goto slowpath; + } +#endif + + /* Zero-size allocation should happen very rarely (if at all), so + * don't check zero size on NULL; handle it in the slow path + * instead. This reduces size of inlined code. + */ + res = heap->alloc_func(heap->heap_udata, size); + if (DUK_LIKELY(res != NULL)) { + return res; + } + + slowpath: + + if (size == 0) { + DUK_D(DUK_DPRINT("first alloc attempt returned NULL for zero size alloc, use slow path to deal with it")); + } else { + DUK_D(DUK_DPRINT("first alloc attempt failed, attempt to gc and retry")); + } + return duk__heap_mem_alloc_slowpath(heap, size); +} + +DUK_INTERNAL DUK_INLINE_PERF DUK_HOT void *duk_heap_mem_alloc_zeroed(duk_heap *heap, duk_size_t size) { + void *res; + + DUK_ASSERT(heap != NULL); + DUK_ASSERT(heap->alloc_func != NULL); DUK_ASSERT_DISABLE(size >= 0); res = DUK_ALLOC(heap, size); @@ -50713,24 +52653,37 @@ DUK_INTERNAL void *duk_heap_mem_alloc_zeroed(duk_heap *heap, duk_size_t size) { return res; } -DUK_INTERNAL void *duk_heap_mem_alloc_checked(duk_hthread *thr, duk_size_t size) { +DUK_INTERNAL DUK_INLINE_PERF DUK_HOT void *duk_heap_mem_alloc_checked(duk_hthread *thr, duk_size_t size) { void *res; DUK_ASSERT(thr != NULL); + DUK_ASSERT(thr->heap != NULL); + DUK_ASSERT(thr->heap->alloc_func != NULL); + res = duk_heap_mem_alloc(thr->heap, size); - if (DUK_LIKELY(res != NULL || size == 0)) { + if (DUK_LIKELY(res != NULL)) { + return res; + } else if (size == 0) { + DUK_ASSERT(res == NULL); return res; } DUK_ERROR_ALLOC_FAILED(thr); DUK_WO_NORETURN(return NULL;); } -DUK_INTERNAL void *duk_heap_mem_alloc_checked_zeroed(duk_hthread *thr, duk_size_t size) { +DUK_INTERNAL DUK_INLINE_PERF DUK_HOT void *duk_heap_mem_alloc_checked_zeroed(duk_hthread *thr, duk_size_t size) { void *res; DUK_ASSERT(thr != NULL); - res = duk_heap_mem_alloc_zeroed(thr->heap, size); - if (DUK_LIKELY(res != NULL || size == 0)) { + DUK_ASSERT(thr->heap != NULL); + DUK_ASSERT(thr->heap->alloc_func != NULL); + + res = duk_heap_mem_alloc(thr->heap, size); + if (DUK_LIKELY(res != NULL)) { + duk_memzero(res, size); + return res; + } else if (size == 0) { + DUK_ASSERT(res == NULL); return res; } DUK_ERROR_ALLOC_FAILED(thr); @@ -50738,46 +52691,26 @@ DUK_INTERNAL void *duk_heap_mem_alloc_checked_zeroed(duk_hthread *thr, duk_size_ } /* - * Reallocate memory with garbage collection + * Reallocate memory with garbage collection. */ -DUK_INTERNAL void *duk_heap_mem_realloc(duk_heap *heap, void *ptr, duk_size_t newsize) { +/* Slow path: voluntary GC triggered, first realloc attempt failed, or zero size. */ +DUK_LOCAL DUK_NOINLINE_PERF DUK_COLD void *duk__heap_mem_realloc_slowpath(duk_heap *heap, void *ptr, duk_size_t newsize) { void *res; duk_small_int_t i; DUK_ASSERT(heap != NULL); + DUK_ASSERT(heap->realloc_func != NULL); /* ptr may be NULL */ DUK_ASSERT_DISABLE(newsize >= 0); - /* - * Voluntary periodic GC (if enabled) - */ - - DUK__VOLUNTARY_PERIODIC_GC(heap); - - /* - * First attempt + /* Newsize was 0 and realloc() returned NULL, this has the semantics + * of free(oldptr), i.e. memory was successfully freed. */ - -#if defined(DUK_USE_GC_TORTURE) - /* Simulate alloc failure on every realloc, except when mark-and-sweep - * is running. - */ - if (heap->ms_prevent_count == 0) { - DUK_DDD(DUK_DDDPRINT("gc torture enabled, pretend that first realloc attempt fails")); - res = NULL; - DUK_UNREF(res); - goto skip_attempt; - } -#endif - res = heap->realloc_func(heap->heap_udata, ptr, newsize); - if (DUK_LIKELY(res || newsize == 0)) { - /* For zero size allocations NULL is allowed. */ - return res; + if (newsize == 0) { + DUK_D(DUK_DPRINT("zero size realloc in slow path, return NULL")); + return NULL; } -#if defined(DUK_USE_GC_TORTURE) - skip_attempt: -#endif DUK_D(DUK_DPRINT("first realloc attempt failed, attempt to gc and retry")); @@ -50808,6 +52741,7 @@ DUK_INTERNAL void *duk_heap_mem_realloc(duk_heap *heap, void *ptr, duk_size_t ne duk_heap_mark_and_sweep(heap, flags); + DUK_ASSERT(newsize > 0); res = heap->realloc_func(heap->heap_udata, ptr, newsize); if (res || newsize == 0) { DUK_D(DUK_DPRINT("duk_heap_mem_realloc() succeeded after gc (pass %ld), alloc size %ld", @@ -50820,48 +52754,67 @@ DUK_INTERNAL void *duk_heap_mem_realloc(duk_heap *heap, void *ptr, duk_size_t ne return NULL; } -/* - * Reallocate memory with garbage collection, using a callback to provide - * the current allocated pointer. This variant is used when a mark-and-sweep - * (e.g. finalizers) might change the original pointer. - */ - -DUK_INTERNAL void *duk_heap_mem_realloc_indirect(duk_heap *heap, duk_mem_getptr cb, void *ud, duk_size_t newsize) { +DUK_INTERNAL DUK_INLINE_PERF DUK_HOT void *duk_heap_mem_realloc(duk_heap *heap, void *ptr, duk_size_t newsize) { void *res; - duk_small_int_t i; DUK_ASSERT(heap != NULL); + DUK_ASSERT(heap->realloc_func != NULL); + /* ptr may be NULL */ DUK_ASSERT_DISABLE(newsize >= 0); - /* - * Voluntary periodic GC (if enabled) - */ - - DUK__VOLUNTARY_PERIODIC_GC(heap); - - /* - * First attempt - */ +#if defined(DUK_USE_VOLUNTARY_GC) + /* Voluntary periodic GC (if enabled). */ + if (DUK_UNLIKELY(--(heap)->ms_trigger_counter < 0)) { + goto slowpath; + } +#endif #if defined(DUK_USE_GC_TORTURE) /* Simulate alloc failure on every realloc, except when mark-and-sweep * is running. */ if (heap->ms_prevent_count == 0) { - DUK_DDD(DUK_DDDPRINT("gc torture enabled, pretend that first indirect realloc attempt fails")); + DUK_DDD(DUK_DDDPRINT("gc torture enabled, pretend that first realloc attempt fails")); res = NULL; DUK_UNREF(res); - goto skip_attempt; + goto slowpath; } #endif - res = heap->realloc_func(heap->heap_udata, cb(heap, ud), newsize); - if (DUK_LIKELY(res || newsize == 0)) { - /* For zero size allocations NULL is allowed. */ + + res = heap->realloc_func(heap->heap_udata, ptr, newsize); + if (DUK_LIKELY(res != NULL)) { return res; } -#if defined(DUK_USE_GC_TORTURE) - skip_attempt: -#endif + + slowpath: + + if (newsize == 0) { + DUK_D(DUK_DPRINT("first realloc attempt returned NULL for zero size realloc, use slow path to deal with it")); + } else { + DUK_D(DUK_DPRINT("first realloc attempt failed, attempt to gc and retry")); + } + return duk__heap_mem_realloc_slowpath(heap, ptr, newsize); +} + +/* + * Reallocate memory with garbage collection, using a callback to provide + * the current allocated pointer. This variant is used when a mark-and-sweep + * (e.g. finalizers) might change the original pointer. + */ + +/* Slow path: voluntary GC triggered, first realloc attempt failed, or zero size. */ +DUK_LOCAL DUK_NOINLINE_PERF DUK_COLD void *duk__heap_mem_realloc_indirect_slowpath(duk_heap *heap, duk_mem_getptr cb, void *ud, duk_size_t newsize) { + void *res; + duk_small_int_t i; + + DUK_ASSERT(heap != NULL); + DUK_ASSERT(heap->realloc_func != NULL); + DUK_ASSERT_DISABLE(newsize >= 0); + + if (newsize == 0) { + DUK_D(DUK_DPRINT("zero size indirect realloc in slow path, return NULL")); + return NULL; + } DUK_D(DUK_DPRINT("first indirect realloc attempt failed, attempt to gc and retry")); @@ -50911,6 +52864,7 @@ DUK_INTERNAL void *duk_heap_mem_realloc_indirect(duk_heap *heap, duk_mem_getptr * The pointer being reallocated may change after every mark-and-sweep. */ + DUK_ASSERT(newsize > 0); res = heap->realloc_func(heap->heap_udata, cb(heap, ud), newsize); if (res || newsize == 0) { DUK_D(DUK_DPRINT("duk_heap_mem_realloc_indirect() succeeded after gc (pass %ld), alloc size %ld", @@ -50923,12 +52877,54 @@ DUK_INTERNAL void *duk_heap_mem_realloc_indirect(duk_heap *heap, duk_mem_getptr return NULL; } +DUK_INTERNAL DUK_INLINE_PERF DUK_HOT void *duk_heap_mem_realloc_indirect(duk_heap *heap, duk_mem_getptr cb, void *ud, duk_size_t newsize) { + void *res; + + DUK_ASSERT(heap != NULL); + DUK_ASSERT(heap->realloc_func != NULL); + DUK_ASSERT_DISABLE(newsize >= 0); + +#if defined(DUK_USE_VOLUNTARY_GC) + /* Voluntary periodic GC (if enabled). */ + if (DUK_UNLIKELY(--(heap)->ms_trigger_counter < 0)) { + goto slowpath; + } +#endif + +#if defined(DUK_USE_GC_TORTURE) + /* Simulate alloc failure on every realloc, except when mark-and-sweep + * is running. + */ + if (heap->ms_prevent_count == 0) { + DUK_DDD(DUK_DDDPRINT("gc torture enabled, pretend that first indirect realloc attempt fails")); + res = NULL; + DUK_UNREF(res); + goto slowpath; + } +#endif + + res = heap->realloc_func(heap->heap_udata, cb(heap, ud), newsize); + if (DUK_LIKELY(res != NULL)) { + return res; + } + + slowpath: + + if (newsize == 0) { + DUK_D(DUK_DPRINT("first indirect realloc attempt returned NULL for zero size realloc, use slow path to deal with it")); + } else { + DUK_D(DUK_DPRINT("first indirect realloc attempt failed, attempt to gc and retry")); + } + return duk__heap_mem_realloc_indirect_slowpath(heap, cb, ud, newsize); +} + /* * Free memory */ -DUK_INTERNAL void duk_heap_mem_free(duk_heap *heap, void *ptr) { +DUK_INTERNAL DUK_INLINE_PERF DUK_HOT void duk_heap_mem_free(duk_heap *heap, void *ptr) { DUK_ASSERT(heap != NULL); + DUK_ASSERT(heap->free_func != NULL); /* ptr may be NULL */ /* Must behave like a no-op with NULL and any pointer returned from @@ -50941,9 +52937,6 @@ DUK_INTERNAL void duk_heap_mem_free(duk_heap *heap, void *ptr) { * No need to update voluntary GC counter either. */ } - -/* automatic undefs */ -#undef DUK__VOLUNTARY_PERIODIC_GC #line 1 "duk_heap_misc.c" /* * Support functions for duk_heap. @@ -54932,7 +56925,7 @@ DUK_LOCAL duk_uint32_t duk__tval_number_to_arr_idx(duk_tval *tv) { */ dbl = DUK_TVAL_GET_NUMBER(tv); idx = (duk_uint32_t) dbl; - if ((duk_double_t) idx == dbl) { + if (duk_double_equals((duk_double_t) idx, dbl)) { /* Is whole and within 32 bit range. If the value happens to be 0xFFFFFFFF, * it's not a valid array index but will then match DUK__NO_ARRAY_INDEX. */ @@ -55156,6 +57149,8 @@ DUK_LOCAL duk_bool_t duk__abandon_array_density_check(duk_uint32_t a_used, duk_u /* Fast check for extending array: check whether or not a slow density check is required. */ DUK_LOCAL duk_bool_t duk__abandon_array_slow_check_required(duk_uint32_t arr_idx, duk_uint32_t old_size) { + duk_uint32_t new_size_min; + /* * In a fast check we assume old_size equals old_used (i.e., existing * array is fully dense). @@ -55177,7 +57172,9 @@ DUK_LOCAL duk_bool_t duk__abandon_array_slow_check_required(duk_uint32_t arr_idx * arr_idx > limit'' * ((old_size + 7) / 8) */ - return (arr_idx > DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT * ((old_size + 7) >> 3)); + new_size_min = arr_idx + 1; + return (new_size_min >= DUK_USE_HOBJECT_ARRAY_ABANDON_MINSIZE) && + (arr_idx > DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT * ((old_size + 7) >> 3)); } DUK_LOCAL duk_bool_t duk__abandon_array_check(duk_hthread *thr, duk_uint32_t arr_idx, duk_hobject *obj) { @@ -58015,7 +60012,7 @@ DUK_LOCAL duk_uint32_t duk__to_new_array_length_checked(duk_hthread *thr, duk_tv * 32-bit range. Negative zero is accepted as zero. */ res = duk_double_to_uint32_t(d); - if ((duk_double_t) res != d) { + if (!duk_double_equals((duk_double_t) res, d)) { goto fail_range; } @@ -62725,11 +64722,11 @@ DUK_INTERNAL double duk_js_arith_mod(double d1, double d2) { } else { return d1; } - } else if (d1 == 0.0) { + } else if (duk_double_equals(d1, 0.0)) { /* d1 +/-0 is returned as is (preserving sign) except when * d2 is zero or NaN. */ - if (d2 == 0.0 || DUK_ISNAN(d2)) { + if (duk_double_equals(d2, 0.0) || DUK_ISNAN(d2)) { return DUK_DOUBLE_NAN; } else { return d1; @@ -62737,20 +64734,20 @@ DUK_INTERNAL double duk_js_arith_mod(double d1, double d2) { } #else /* Some ISO C assumptions. */ - DUK_ASSERT(DUK_FMOD(1.0, DUK_DOUBLE_INFINITY) == 1.0); - DUK_ASSERT(DUK_FMOD(-1.0, DUK_DOUBLE_INFINITY) == -1.0); - DUK_ASSERT(DUK_FMOD(1.0, -DUK_DOUBLE_INFINITY) == 1.0); - DUK_ASSERT(DUK_FMOD(-1.0, -DUK_DOUBLE_INFINITY) == -1.0); + DUK_ASSERT(duk_double_equals(DUK_FMOD(1.0, DUK_DOUBLE_INFINITY), 1.0)); + DUK_ASSERT(duk_double_equals(DUK_FMOD(-1.0, DUK_DOUBLE_INFINITY), -1.0)); + DUK_ASSERT(duk_double_equals(DUK_FMOD(1.0, -DUK_DOUBLE_INFINITY), 1.0)); + DUK_ASSERT(duk_double_equals(DUK_FMOD(-1.0, -DUK_DOUBLE_INFINITY), -1.0)); DUK_ASSERT(DUK_ISNAN(DUK_FMOD(DUK_DOUBLE_INFINITY, DUK_DOUBLE_INFINITY))); DUK_ASSERT(DUK_ISNAN(DUK_FMOD(DUK_DOUBLE_INFINITY, -DUK_DOUBLE_INFINITY))); DUK_ASSERT(DUK_ISNAN(DUK_FMOD(-DUK_DOUBLE_INFINITY, DUK_DOUBLE_INFINITY))); DUK_ASSERT(DUK_ISNAN(DUK_FMOD(-DUK_DOUBLE_INFINITY, -DUK_DOUBLE_INFINITY))); - DUK_ASSERT(DUK_FMOD(0.0, 1.0) == 0.0 && DUK_SIGNBIT(DUK_FMOD(0.0, 1.0)) == 0); - DUK_ASSERT(DUK_FMOD(-0.0, 1.0) == 0.0 && DUK_SIGNBIT(DUK_FMOD(-0.0, 1.0)) != 0); - DUK_ASSERT(DUK_FMOD(0.0, DUK_DOUBLE_INFINITY) == 0.0 && DUK_SIGNBIT(DUK_FMOD(0.0, DUK_DOUBLE_INFINITY)) == 0); - DUK_ASSERT(DUK_FMOD(-0.0, DUK_DOUBLE_INFINITY) == 0.0 && DUK_SIGNBIT(DUK_FMOD(-0.0, DUK_DOUBLE_INFINITY)) != 0); - DUK_ASSERT(DUK_FMOD(0.0, -DUK_DOUBLE_INFINITY) == 0.0 && DUK_SIGNBIT(DUK_FMOD(0.0, DUK_DOUBLE_INFINITY)) == 0); - DUK_ASSERT(DUK_FMOD(-0.0, -DUK_DOUBLE_INFINITY) == 0.0 && DUK_SIGNBIT(DUK_FMOD(-0.0, -DUK_DOUBLE_INFINITY)) != 0); + DUK_ASSERT(duk_double_equals(DUK_FMOD(0.0, 1.0), 0.0) && DUK_SIGNBIT(DUK_FMOD(0.0, 1.0)) == 0); + DUK_ASSERT(duk_double_equals(DUK_FMOD(-0.0, 1.0), 0.0) && DUK_SIGNBIT(DUK_FMOD(-0.0, 1.0)) != 0); + DUK_ASSERT(duk_double_equals(DUK_FMOD(0.0, DUK_DOUBLE_INFINITY), 0.0) && DUK_SIGNBIT(DUK_FMOD(0.0, DUK_DOUBLE_INFINITY)) == 0); + DUK_ASSERT(duk_double_equals(DUK_FMOD(-0.0, DUK_DOUBLE_INFINITY), 0.0) && DUK_SIGNBIT(DUK_FMOD(-0.0, DUK_DOUBLE_INFINITY)) != 0); + DUK_ASSERT(duk_double_equals(DUK_FMOD(0.0, -DUK_DOUBLE_INFINITY), 0.0) && DUK_SIGNBIT(DUK_FMOD(0.0, DUK_DOUBLE_INFINITY)) == 0); + DUK_ASSERT(duk_double_equals(DUK_FMOD(-0.0, -DUK_DOUBLE_INFINITY), 0.0) && DUK_SIGNBIT(DUK_FMOD(-0.0, -DUK_DOUBLE_INFINITY)) != 0); DUK_ASSERT(DUK_ISNAN(DUK_FMOD(0.0, 0.0))); DUK_ASSERT(DUK_ISNAN(DUK_FMOD(-0.0, 0.0))); DUK_ASSERT(DUK_ISNAN(DUK_FMOD(0.0, -0.0))); @@ -62779,7 +64776,7 @@ DUK_INTERNAL double duk_js_arith_pow(double x, double y) { if (cy == DUK_FP_NAN) { goto ret_nan; } - if (DUK_FABS(x) == 1.0 && cy == DUK_FP_INFINITE) { + if (duk_double_equals(DUK_FABS(x), 1.0) && cy == DUK_FP_INFINITE) { goto ret_nan; } @@ -62821,7 +64818,7 @@ DUK_INTERNAL double duk_js_arith_pow(double x, double y) { } } } else if (cx == DUK_FP_NAN) { - if (y == 0.0) { + if (duk_double_equals(y, 0.0)) { /* NaN ** +/- 0 should always be 1, but is NaN on * at least some Cygwin/MinGW versions. */ @@ -62830,7 +64827,7 @@ DUK_INTERNAL double duk_js_arith_pow(double x, double y) { } #else /* Some ISO C assumptions. */ - DUK_ASSERT(DUK_POW(DUK_DOUBLE_NAN, 0.0) == 1.0); + DUK_ASSERT(duk_double_equals(DUK_POW(DUK_DOUBLE_NAN, 0.0), 1.0)); DUK_ASSERT(DUK_ISINF(DUK_POW(0.0, -1.0)) && DUK_SIGNBIT(DUK_POW(0.0, -1.0)) == 0); DUK_ASSERT(DUK_ISINF(DUK_POW(-0.0, -2.0)) && DUK_SIGNBIT(DUK_POW(-0.0, -2.0)) == 0); DUK_ASSERT(DUK_ISINF(DUK_POW(-0.0, -3.0)) && DUK_SIGNBIT(DUK_POW(-0.0, -3.0)) != 0); @@ -65613,6 +67610,7 @@ DUK_INTERNAL duk_int_t duk_handle_safe_call(duk_hthread *thr, #if defined(DUK_USE_CPP_EXCEPTIONS) catch (duk_fatal_exception &exc) { DUK_D(DUK_DPRINT("rethrow duk_fatal_exception")); + DUK_UNREF(exc); throw; } catch (std::exception &exc) { const char *what = exc.what(); @@ -69493,12 +71491,12 @@ DUK_LOCAL void duk__expr_nud(duk_compiler_ctx *comp_ctx, duk_ivalue *res) { if (DUK_TVAL_IS_NUMBER(tv_val)) { duk_double_t d; d = DUK_TVAL_GET_NUMBER(tv_val); - if (d == 0.0) { + if (duk_double_equals(d, 0.0)) { /* Matches both +0 and -0 on purpose. */ DUK_DDD(DUK_DDDPRINT("inlined lnot: !0 -> true")); DUK_TVAL_SET_BOOLEAN_TRUE(tv_val); return; - } else if (d == 1.0) { + } else if (duk_double_equals(d, 1.0)) { DUK_DDD(DUK_DDDPRINT("inlined lnot: !1 -> false")); DUK_TVAL_SET_BOOLEAN_FALSE(tv_val); return; @@ -73903,15 +75901,6 @@ DUK_LOCAL_DECL void duk__js_execute_bytecode_inner(duk_hthread *entry_thread, du * Misc helpers. */ -/* Forced inline declaration, only applied for performance oriented build. */ -#if defined(DUK_USE_EXEC_PREFER_SIZE) -#define DUK__INLINE_PERF -#define DUK__NOINLINE_PERF -#else -#define DUK__INLINE_PERF DUK_ALWAYS_INLINE -#define DUK__NOINLINE_PERF DUK_NOINLINE -#endif - /* Replace value stack top to value at 'tv_ptr'. Optimize for * performance by only applying the net refcount change. */ @@ -73963,17 +75952,17 @@ DUK_LOCAL void duk__push_tvals_incref_only(duk_hthread *thr, duk_tval *tv_src, d * possible. */ -DUK_LOCAL DUK__INLINE_PERF duk_double_t duk__compute_mod(duk_double_t d1, duk_double_t d2) { +DUK_LOCAL DUK_EXEC_ALWAYS_INLINE_PERF duk_double_t duk__compute_mod(duk_double_t d1, duk_double_t d2) { return (duk_double_t) duk_js_arith_mod((double) d1, (double) d2); } #if defined(DUK_USE_ES7_EXP_OPERATOR) -DUK_LOCAL DUK__INLINE_PERF duk_double_t duk__compute_exp(duk_double_t d1, duk_double_t d2) { +DUK_LOCAL DUK_EXEC_ALWAYS_INLINE_PERF duk_double_t duk__compute_exp(duk_double_t d1, duk_double_t d2) { return (duk_double_t) duk_js_arith_pow((double) d1, (double) d2); } #endif -DUK_LOCAL DUK__INLINE_PERF void duk__vm_arith_add(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_uint_fast_t idx_z) { +DUK_LOCAL DUK_EXEC_ALWAYS_INLINE_PERF void duk__vm_arith_add(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_uint_fast_t idx_z) { /* * Addition operator is different from other arithmetic * operations in that it also provides string concatenation. @@ -74080,7 +76069,7 @@ DUK_LOCAL DUK__INLINE_PERF void duk__vm_arith_add(duk_hthread *thr, duk_tval *tv duk_replace(thr, (duk_idx_t) idx_z); /* side effects */ } -DUK_LOCAL DUK__INLINE_PERF void duk__vm_arith_binary_op(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_uint_fast_t idx_z, duk_small_uint_fast_t opcode) { +DUK_LOCAL DUK_EXEC_ALWAYS_INLINE_PERF void duk__vm_arith_binary_op(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_uint_fast_t idx_z, duk_small_uint_fast_t opcode) { /* * Arithmetic operations other than '+' have number-only semantics * and are implemented here. The separate switch-case here means a @@ -74238,7 +76227,7 @@ DUK_LOCAL DUK__INLINE_PERF void duk__vm_arith_binary_op(duk_hthread *thr, duk_tv #endif /* DUK_USE_EXEC_PREFER_SIZE */ } -DUK_LOCAL DUK__INLINE_PERF void duk__vm_bitwise_binary_op(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_uint_fast_t idx_z, duk_small_uint_fast_t opcode) { +DUK_LOCAL DUK_EXEC_ALWAYS_INLINE_PERF void duk__vm_bitwise_binary_op(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_uint_fast_t idx_z, duk_small_uint_fast_t opcode) { /* * Binary bitwise operations use different coercions (ToInt32, ToUint32) * depending on the operation. We coerce the arguments first using @@ -74366,7 +76355,7 @@ DUK_LOCAL DUK__INLINE_PERF void duk__vm_bitwise_binary_op(duk_hthread *thr, duk_ } /* In-place unary operation. */ -DUK_LOCAL DUK__INLINE_PERF void duk__vm_arith_unary_op(duk_hthread *thr, duk_uint_fast_t idx_src, duk_uint_fast_t idx_dst, duk_small_uint_fast_t opcode) { +DUK_LOCAL DUK_EXEC_ALWAYS_INLINE_PERF void duk__vm_arith_unary_op(duk_hthread *thr, duk_uint_fast_t idx_src, duk_uint_fast_t idx_dst, duk_small_uint_fast_t opcode) { /* * Arithmetic operations other than '+' have number-only semantics * and are implemented here. The separate switch-case here means a @@ -74443,7 +76432,7 @@ DUK_LOCAL DUK__INLINE_PERF void duk__vm_arith_unary_op(duk_hthread *thr, duk_uin DUK_TVAL_SET_NUMBER_UPDREF(thr, tv, du.d); } -DUK_LOCAL DUK__INLINE_PERF void duk__vm_bitwise_not(duk_hthread *thr, duk_uint_fast_t idx_src, duk_uint_fast_t idx_dst) { +DUK_LOCAL DUK_EXEC_ALWAYS_INLINE_PERF void duk__vm_bitwise_not(duk_hthread *thr, duk_uint_fast_t idx_src, duk_uint_fast_t idx_dst) { /* * E5 Section 11.4.8 */ @@ -74477,7 +76466,7 @@ DUK_LOCAL DUK__INLINE_PERF void duk__vm_bitwise_not(duk_hthread *thr, duk_uint_f DUK_TVAL_SET_I32_UPDREF(thr, tv, i2); /* side effects */ } -DUK_LOCAL DUK__INLINE_PERF void duk__vm_logical_not(duk_hthread *thr, duk_uint_fast_t idx_src, duk_uint_fast_t idx_dst) { +DUK_LOCAL DUK_EXEC_ALWAYS_INLINE_PERF void duk__vm_logical_not(duk_hthread *thr, duk_uint_fast_t idx_src, duk_uint_fast_t idx_dst) { /* * E5 Section 11.4.9 */ @@ -74505,7 +76494,7 @@ DUK_LOCAL DUK__INLINE_PERF void duk__vm_logical_not(duk_hthread *thr, duk_uint_f } /* XXX: size optimized variant */ -DUK_LOCAL DUK__INLINE_PERF void duk__prepost_incdec_reg_helper(duk_hthread *thr, duk_tval *tv_dst, duk_tval *tv_src, duk_small_uint_t op) { +DUK_LOCAL DUK_EXEC_ALWAYS_INLINE_PERF void duk__prepost_incdec_reg_helper(duk_hthread *thr, duk_tval *tv_dst, duk_tval *tv_src, duk_small_uint_t op) { duk_double_t x, y, z; /* Two lowest bits of opcode are used to distinguish @@ -74581,7 +76570,7 @@ DUK_LOCAL DUK__INLINE_PERF void duk__prepost_incdec_reg_helper(duk_hthread *thr, DUK_TVAL_SET_NUMBER_UPDREF(thr, tv_dst, z); /* side effects */ } -DUK_LOCAL DUK__INLINE_PERF void duk__prepost_incdec_var_helper(duk_hthread *thr, duk_small_uint_t idx_dst, duk_tval *tv_id, duk_small_uint_t op, duk_small_uint_t is_strict) { +DUK_LOCAL DUK_EXEC_ALWAYS_INLINE_PERF void duk__prepost_incdec_var_helper(duk_hthread *thr, duk_small_uint_t idx_dst, duk_tval *tv_id, duk_small_uint_t op, duk_small_uint_t is_strict) { duk_activation *act; duk_double_t x, y; duk_hstring *name; @@ -75379,9 +77368,9 @@ DUK_LOCAL duk_small_uint_t duk__handle_longjmp(duk_hthread *thr, duk_activation * handling because it has a measurable performance impact in ordinary * environments and an extreme impact in Emscripten (GH-342). */ -DUK_LOCAL DUK__NOINLINE_PERF void duk__handle_break_or_continue(duk_hthread *thr, - duk_uint_t label_id, - duk_small_uint_t lj_type) { +DUK_LOCAL DUK_EXEC_NOINLINE_PERF void duk__handle_break_or_continue(duk_hthread *thr, + duk_uint_t label_id, + duk_small_uint_t lj_type) { duk_activation *act; duk_catcher *cat; @@ -75832,7 +77821,7 @@ DUK_LOCAL void duk__interrupt_handle_debugger(duk_hthread *thr, duk_bool_t *out_ } #endif /* DUK_USE_DEBUGGER_SUPPORT */ -DUK_LOCAL DUK__NOINLINE_PERF DUK_COLD duk_small_uint_t duk__executor_interrupt(duk_hthread *thr) { +DUK_LOCAL DUK_EXEC_NOINLINE_PERF DUK_COLD duk_small_uint_t duk__executor_interrupt(duk_hthread *thr) { duk_int_t ctr; duk_activation *act; duk_hcompfunc *fun; @@ -76085,7 +78074,7 @@ DUK_LOCAL void duk__executor_recheck_debugger(duk_hthread *thr, duk_activation * * rare; NOINLINE to reduce amount of code in main bytecode dispatcher. */ -DUK_LOCAL DUK__NOINLINE_PERF void duk__handle_op_initset_initget(duk_hthread *thr, duk_uint_fast32_t ins) { +DUK_LOCAL DUK_EXEC_NOINLINE_PERF void duk__handle_op_initset_initget(duk_hthread *thr, duk_uint_fast32_t ins) { duk_bool_t is_set = (DUK_DEC_OP(ins) == DUK_OP_INITSET); duk_uint_fast_t idx; duk_uint_t defprop_flags; @@ -76118,7 +78107,7 @@ DUK_LOCAL DUK__NOINLINE_PERF void duk__handle_op_initset_initget(duk_hthread *th duk_def_prop(thr, (duk_idx_t) DUK_DEC_A(ins), defprop_flags); } -DUK_LOCAL DUK__NOINLINE_PERF void duk__handle_op_trycatch(duk_hthread *thr, duk_uint_fast32_t ins, duk_instr_t *curr_pc) { +DUK_LOCAL DUK_EXEC_NOINLINE_PERF void duk__handle_op_trycatch(duk_hthread *thr, duk_uint_fast32_t ins, duk_instr_t *curr_pc) { duk_activation *act; duk_catcher *cat; duk_tval *tv1; @@ -76283,7 +78272,7 @@ DUK_LOCAL DUK__NOINLINE_PERF void duk__handle_op_trycatch(duk_hthread *thr, duk_ duk_pop_unsafe(thr); } -DUK_LOCAL DUK__NOINLINE_PERF duk_instr_t *duk__handle_op_endtry(duk_hthread *thr, duk_uint_fast32_t ins) { +DUK_LOCAL DUK_EXEC_NOINLINE_PERF duk_instr_t *duk__handle_op_endtry(duk_hthread *thr, duk_uint_fast32_t ins) { duk_activation *act; duk_catcher *cat; duk_tval *tv1; @@ -76327,7 +78316,7 @@ DUK_LOCAL DUK__NOINLINE_PERF duk_instr_t *duk__handle_op_endtry(duk_hthread *thr return pc_base + 1; /* new curr_pc value */ } -DUK_LOCAL DUK__NOINLINE_PERF duk_instr_t *duk__handle_op_endcatch(duk_hthread *thr, duk_uint_fast32_t ins) { +DUK_LOCAL DUK_EXEC_NOINLINE_PERF duk_instr_t *duk__handle_op_endcatch(duk_hthread *thr, duk_uint_fast32_t ins) { duk_activation *act; duk_catcher *cat; duk_tval *tv1; @@ -76388,7 +78377,7 @@ DUK_LOCAL DUK__NOINLINE_PERF duk_instr_t *duk__handle_op_endcatch(duk_hthread *t return pc_base + 1; /* new curr_pc value */ } -DUK_LOCAL DUK__NOINLINE_PERF duk_small_uint_t duk__handle_op_endfin(duk_hthread *thr, duk_uint_fast32_t ins, duk_activation *entry_act) { +DUK_LOCAL DUK_EXEC_NOINLINE_PERF duk_small_uint_t duk__handle_op_endfin(duk_hthread *thr, duk_uint_fast32_t ins, duk_activation *entry_act) { duk_activation *act; duk_tval *tv1; duk_uint_t reg_catch; @@ -76489,7 +78478,7 @@ DUK_LOCAL DUK__NOINLINE_PERF duk_small_uint_t duk__handle_op_endfin(duk_hthread return 0; } -DUK_LOCAL DUK__NOINLINE_PERF void duk__handle_op_initenum(duk_hthread *thr, duk_uint_fast32_t ins) { +DUK_LOCAL DUK_EXEC_NOINLINE_PERF void duk__handle_op_initenum(duk_hthread *thr, duk_uint_fast32_t ins) { duk_small_uint_t b; duk_small_uint_t c; @@ -76517,7 +78506,7 @@ DUK_LOCAL DUK__NOINLINE_PERF void duk__handle_op_initenum(duk_hthread *thr, duk_ } } -DUK_LOCAL DUK__NOINLINE_PERF duk_small_uint_t duk__handle_op_nextenum(duk_hthread *thr, duk_uint_fast32_t ins) { +DUK_LOCAL DUK_EXEC_NOINLINE_PERF duk_small_uint_t duk__handle_op_nextenum(duk_hthread *thr, duk_uint_fast32_t ins) { duk_small_uint_t b; duk_small_uint_t c; duk_small_uint_t pc_skip = 0; @@ -76877,6 +78866,7 @@ DUK_INTERNAL void duk_js_execute_bytecode(duk_hthread *exec_thr) { #if defined(DUK_USE_CPP_EXCEPTIONS) catch (duk_fatal_exception &exc) { DUK_D(DUK_DPRINT("rethrow duk_fatal_exception")); + DUK_UNREF(exc); throw; } catch (std::exception &exc) { const char *what = exc.what(); @@ -79113,7 +81103,6 @@ DUK_LOCAL DUK_NOINLINE DUK_HOT void duk__js_execute_bytecode_inner(duk_hthread * #undef DUK__GETPROP_BODY #undef DUK__GE_BODY #undef DUK__GT_BODY -#undef DUK__INLINE_PERF #undef DUK__INSTOF_BODY #undef DUK__INTERNAL_ERROR #undef DUK__INT_NOACTION @@ -79129,7 +81118,6 @@ DUK_LOCAL DUK_NOINLINE DUK_HOT void duk__js_execute_bytecode_inner(duk_hthread * #undef DUK__MASK_BC #undef DUK__MASK_C #undef DUK__NEQ_BODY -#undef DUK__NOINLINE_PERF #undef DUK__PUTPROP_BODY #undef DUK__RCBIT_B #undef DUK__RCBIT_C @@ -79280,6 +81268,7 @@ DUK_INTERNAL duk_bool_t duk_js_toboolean(duk_tval *tv) { } } DUK_UNREACHABLE(); + DUK_WO_UNREACHABLE(return 0;); } /* @@ -79421,6 +81410,7 @@ DUK_INTERNAL duk_double_t duk_js_tonumber(duk_hthread *thr, duk_tval *tv) { } DUK_UNREACHABLE(); + DUK_WO_UNREACHABLE(return 0.0;); } /* @@ -79523,7 +81513,7 @@ DUK_INTERNAL duk_int32_t duk_js_toint32(duk_hthread *thr, duk_tval *tv) { d = duk__toint32_touint32_helper(d, 1); DUK_ASSERT(DUK_FPCLASSIFY(d) == DUK_FP_ZERO || DUK_FPCLASSIFY(d) == DUK_FP_NORMAL); DUK_ASSERT(d >= -2147483648.0 && d <= 2147483647.0); /* [-0x80000000,0x7fffffff] */ - DUK_ASSERT(d == ((duk_double_t) ((duk_int32_t) d))); /* whole, won't clip */ + DUK_ASSERT(duk_double_equals(d, (duk_double_t) ((duk_int32_t) d))); /* whole, won't clip */ return (duk_int32_t) d; } @@ -79541,7 +81531,7 @@ DUK_INTERNAL duk_uint32_t duk_js_touint32(duk_hthread *thr, duk_tval *tv) { d = duk__toint32_touint32_helper(d, 0); DUK_ASSERT(DUK_FPCLASSIFY(d) == DUK_FP_ZERO || DUK_FPCLASSIFY(d) == DUK_FP_NORMAL); DUK_ASSERT(d >= 0.0 && d <= 4294967295.0); /* [0x00000000, 0xffffffff] */ - DUK_ASSERT(d == ((duk_double_t) ((duk_uint32_t) d))); /* whole, won't clip */ + DUK_ASSERT(duk_double_equals(d, (duk_double_t) ((duk_uint32_t) d))); /* whole, won't clip */ return (duk_uint32_t) d; } @@ -79600,7 +81590,7 @@ DUK_LOCAL duk_bool_t duk__js_equals_number(duk_double_t x, duk_double_t y) { * equal regardless of sign. Could also use a macro, but this inlines * already nicely (no difference on gcc, for instance). */ - if (x == y) { + if (duk_double_equals(x, y)) { /* IEEE requires that NaNs compare false */ DUK_ASSERT(DUK_FPCLASSIFY(x) != DUK_FP_NAN); DUK_ASSERT(DUK_FPCLASSIFY(y) != DUK_FP_NAN); @@ -79647,7 +81637,7 @@ DUK_LOCAL duk_bool_t duk__js_samevalue_number(duk_double_t x, duk_double_t y) { duk_small_int_t cx = (duk_small_int_t) DUK_FPCLASSIFY(x); duk_small_int_t cy = (duk_small_int_t) DUK_FPCLASSIFY(y); - if (x == y) { + if (duk_double_equals(x, y)) { /* IEEE requires that NaNs compare false */ DUK_ASSERT(DUK_FPCLASSIFY(x) != DUK_FP_NAN); DUK_ASSERT(DUK_FPCLASSIFY(y) != DUK_FP_NAN); @@ -79772,7 +81762,7 @@ DUK_INTERNAL duk_bool_t duk_js_equals_helper(duk_hthread *thr, duk_tval *tv_x, d DUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_x)); DUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_y)); DUK_UNREACHABLE(); - return 0; + DUK_WO_UNREACHABLE(return 0;); } } } @@ -80336,11 +82326,9 @@ DUK_LOCAL duk_bool_t duk__js_instanceof_helper(duk_hthread *thr, duk_tval *tv_x, val = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, val); } while (--sanity > 0); - if (DUK_UNLIKELY(sanity == 0)) { - DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); - DUK_WO_NORETURN(return 0;); - } - DUK_UNREACHABLE(); + DUK_ASSERT(sanity == 0); + DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); + DUK_WO_NORETURN(return 0;); pop2_and_false: duk_pop_2_unsafe(thr); @@ -80506,6 +82494,26 @@ DUK_INTERNAL duk_small_uint_t duk_js_typeof_stridx(duk_tval *tv_x) { return stridx; } +/* + * IsArray() + */ + +DUK_INTERNAL duk_bool_t duk_js_isarray_hobject(duk_hobject *h) { + DUK_ASSERT(h != NULL); +#if defined(DUK_USE_ES6_PROXY) + h = duk_hobject_resolve_proxy_target(h); +#endif + return (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY ? 1 : 0); +} + +DUK_INTERNAL duk_bool_t duk_js_isarray(duk_tval *tv) { + DUK_ASSERT(tv != NULL); + if (DUK_TVAL_IS_OBJECT(tv)) { + return duk_js_isarray_hobject(DUK_TVAL_GET_OBJECT(tv)); + } + return 0; +} + /* * Array index and length * @@ -86470,8 +88478,8 @@ DUK_LOCAL DUK_NOINLINE void duk__numconv_stringify_raw(duk_hthread *thr, duk_sma */ uval = duk_double_to_uint32_t(x); - if (((double) uval) == x && /* integer number in range */ - flags == 0) { /* no special formatting */ + if (duk_double_equals((double) uval, x) && /* integer number in range */ + flags == 0) { /* no special formatting */ /* use bigint area as a temp */ duk_uint8_t *buf = (duk_uint8_t *) (&nc_ctx->f); duk_uint8_t *p = buf; @@ -89664,7 +91672,7 @@ DUK_LOCAL duk_uint_t duk__selftest_byte_order(void) { DUK__FAILED("duk_uint32_t byte order"); } - if (u2.d != (double) 102030405060.0) { + if (!duk_double_equals(u2.d, 102030405060.0)) { DUK__FAILED("double byte order"); } @@ -90039,7 +92047,7 @@ DUK_LOCAL duk_uint_t duk__selftest_cast_double_to_small_uint(void) { u = (duk_small_uint_t) d1; d2 = (duk_double_t) u; - if (!(d1 == 1.0 && u == 1 && d2 == 1.0 && d1 == d2)) { + if (!(duk_double_equals(d1, 1.0) && u == 1 && duk_double_equals(d2, 1.0) && duk_double_equals(d1, d2))) { DUK__FAILED("double to duk_small_uint_t cast failed"); } @@ -90049,7 +92057,7 @@ DUK_LOCAL duk_uint_t duk__selftest_cast_double_to_small_uint(void) { uv = (duk_small_uint_t) d1v; d2v = (duk_double_t) uv; - if (!(d1v == 1.0 && uv == 1 && d2v == 1.0 && d1v == d2v)) { + if (!(duk_double_equals(d1v, 1.0) && uv == 1 && duk_double_equals(d2v, 1.0) && duk_double_equals(d1v, d2v))) { DUK__FAILED("double to duk_small_uint_t cast failed"); } @@ -96983,98 +98991,6 @@ DUK_INTERNAL void duk_bw_remove_raw_slice(duk_hthread *thr, duk_bufwriter_ctx *b bw->p -= len; } -/* - * Macro support functions for reading/writing raw data. - * - * These are done using mempcy to ensure they're valid even for unaligned - * reads/writes on platforms where alignment counts. On x86 at least gcc - * is able to compile these into a bswap+mov. "Always inline" is used to - * ensure these macros compile to minimal code. - * - * Not really bufwriter related, but currently used together. - */ - -DUK_INTERNAL DUK_ALWAYS_INLINE duk_uint16_t duk_raw_read_u16_be(duk_uint8_t **p) { - union { - duk_uint8_t b[2]; - duk_uint16_t x; - } u; - - duk_memcpy((void *) u.b, (const void *) (*p), (size_t) 2); - u.x = DUK_NTOH16(u.x); - *p += 2; - return u.x; -} - -DUK_INTERNAL DUK_ALWAYS_INLINE duk_uint32_t duk_raw_read_u32_be(duk_uint8_t **p) { - union { - duk_uint8_t b[4]; - duk_uint32_t x; - } u; - - duk_memcpy((void *) u.b, (const void *) (*p), (size_t) 4); - u.x = DUK_NTOH32(u.x); - *p += 4; - return u.x; -} - -DUK_INTERNAL DUK_ALWAYS_INLINE duk_double_t duk_raw_read_double_be(duk_uint8_t **p) { - duk_double_union du; - union { - duk_uint8_t b[4]; - duk_uint32_t x; - } u; - - 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); - u.x = DUK_NTOH32(u.x); - du.ui[DUK_DBL_IDX_UI1] = u.x; - *p += 8; - - return du.d; -} - -DUK_INTERNAL DUK_ALWAYS_INLINE void duk_raw_write_u16_be(duk_uint8_t **p, duk_uint16_t val) { - union { - duk_uint8_t b[2]; - duk_uint16_t x; - } u; - - u.x = DUK_HTON16(val); - duk_memcpy((void *) (*p), (const void *) u.b, (size_t) 2); - *p += 2; -} - -DUK_INTERNAL DUK_ALWAYS_INLINE void duk_raw_write_u32_be(duk_uint8_t **p, duk_uint32_t val) { - union { - duk_uint8_t b[4]; - duk_uint32_t x; - } u; - - u.x = DUK_HTON32(val); - duk_memcpy((void *) (*p), (const void *) u.b, (size_t) 4); - *p += 4; -} - -DUK_INTERNAL DUK_ALWAYS_INLINE void duk_raw_write_double_be(duk_uint8_t **p, duk_double_t val) { - duk_double_union du; - union { - duk_uint8_t b[4]; - duk_uint32_t x; - } u; - - 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); - 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); - *p += 8; -} - /* * Assertion helpers */ @@ -97415,7 +99331,7 @@ 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; + return duk_double_equals(duk_js_tointeger_number(x), x); } } @@ -97435,7 +99351,7 @@ DUK_INTERNAL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int duk_int32_t t; t = duk_double_to_int32_t(x); - if (!((duk_double_t) t == x)) { + if (!duk_double_equals((duk_double_t) t, x)) { return 0; } if (t == 0) { @@ -97456,7 +99372,7 @@ 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)) { + if (!duk_double_equals((duk_double_t) t, x)) { return 0; } *ival = t; @@ -97469,7 +99385,7 @@ DUK_INTERNAL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival 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)) { + if (DUK_UNLIKELY(duk_double_equals(y, 0.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 @@ -97497,6 +99413,115 @@ DUK_INTERNAL DUK_INLINE duk_double_t duk_double_div(duk_double_t x, duk_double_t return x / y; } + +/* Double and float byteorder changes. */ + +DUK_INTERNAL DUK_INLINE void duk_dblunion_host_to_little(duk_double_union *u) { +#if defined(DUK_USE_DOUBLE_LE) + /* HGFEDCBA -> HGFEDCBA */ + DUK_UNREF(u); +#elif defined(DUK_USE_DOUBLE_ME) + duk_uint32_t a, b; + + /* DCBAHGFE -> HGFEDCBA */ + a = u->ui[0]; + b = u->ui[1]; + u->ui[0] = b; + u->ui[1] = a; +#elif defined(DUK_USE_DOUBLE_BE) + /* ABCDEFGH -> HGFEDCBA */ +#if defined(DUK_USE_64BIT_OPS) + u->ull[0] = DUK_BSWAP64(u->ull[0]); +#else + duk_uint32_t a, b; + + a = u->ui[0]; + b = u->ui[1]; + u->ui[0] = DUK_BSWAP32(b); + u->ui[1] = DUK_BSWAP32(a); +#endif +#else +#error internal error +#endif +} + +DUK_INTERNAL DUK_INLINE void duk_dblunion_little_to_host(duk_double_union *u) { + duk_dblunion_host_to_little(u); +} + +DUK_INTERNAL DUK_INLINE void duk_dblunion_host_to_big(duk_double_union *u) { +#if defined(DUK_USE_DOUBLE_LE) + /* HGFEDCBA -> ABCDEFGH */ +#if defined(DUK_USE_64BIT_OPS) + u->ull[0] = DUK_BSWAP64(u->ull[0]); +#else + duk_uint32_t a, b; + + a = u->ui[0]; + b = u->ui[1]; + u->ui[0] = DUK_BSWAP32(b); + u->ui[1] = DUK_BSWAP32(a); +#endif +#elif defined(DUK_USE_DOUBLE_ME) + duk_uint32_t a, b; + + /* DCBAHGFE -> ABCDEFGH */ + a = u->ui[0]; + b = u->ui[1]; + u->ui[0] = DUK_BSWAP32(a); + u->ui[1] = DUK_BSWAP32(b); +#elif defined(DUK_USE_DOUBLE_BE) + /* ABCDEFGH -> ABCDEFGH */ + DUK_UNREF(u); +#else +#error internal error +#endif +} + +DUK_INTERNAL DUK_INLINE void duk_dblunion_big_to_host(duk_double_union *u) { + duk_dblunion_host_to_big(u); +} + +DUK_INTERNAL DUK_INLINE void duk_fltunion_host_to_big(duk_float_union *u) { +#if defined(DUK_USE_DOUBLE_LE) || defined(DUK_USE_DOUBLE_ME) + /* DCBA -> ABCD */ + u->ui[0] = DUK_BSWAP32(u->ui[0]); +#elif defined(DUK_USE_DOUBLE_BE) + /* ABCD -> ABCD */ + DUK_UNREF(u); +#else +#error internal error +#endif +} + +DUK_INTERNAL DUK_INLINE void duk_fltunion_big_to_host(duk_float_union *u) { + duk_fltunion_host_to_big(u); +} + +/* Comparison: ensures comparison operates on exactly correct types, avoiding + * some floating point comparison pitfalls (e.g. atan2() assertions failed on + * -m32 with direct comparison, even with explicit casts). + */ +#if defined(DUK_USE_GCC_PRAGMAS) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfloat-equal" +#elif defined(DUK_USE_CLANG_PRAGMAS) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wfloat-equal" +#endif + +DUK_INTERNAL DUK_ALWAYS_INLINE duk_bool_t duk_double_equals(duk_double_t x, duk_double_t y) { + return x == y; +} + +DUK_INTERNAL DUK_ALWAYS_INLINE duk_bool_t duk_float_equals(duk_float_t x, duk_float_t y) { + return x == y; +} +#if defined(DUK_USE_GCC_PRAGMAS) +#pragma GCC diagnostic pop +#elif defined(DUK_USE_CLANG_PRAGMAS) +#pragma clang diagnostic pop +#endif #line 1 "duk_util_hashbytes.c" /* * Hash function duk_util_hashbytes(). diff --git a/duktape/duktape.h b/duktape/duktape.h index d51af0f..7850c99 100644 --- a/duktape/duktape.h +++ b/duktape/duktape.h @@ -1,12 +1,12 @@ /* - * Duktape public API for Duktape 2.4.0. + * Duktape public API for Duktape 2.5.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 d4f2cff1c592d70f58bab8e1bd85705174c02a58 (v2.4.0). + * Git commit 6001888049cb42656f8649db020e804bcdeca6a7 (v2.5.0). * Git branch master. * * See Duktape AUTHORS.rst and LICENSE.txt for copyright and @@ -109,6 +109,7 @@ * * James Swift (https://github.com/phraemer) * * Luis de Bethencourt (https://github.com/luisbg) * * Ian Whyman (https://github.com/v00d00) + * * Rick Sayre (https://github.com/whorfin) * * Other contributions * =================== @@ -175,15 +176,15 @@ * 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 20400L +#define DUK_VERSION 20500L /* 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 * environment. */ -#define DUK_GIT_COMMIT "d4f2cff1c592d70f58bab8e1bd85705174c02a58" -#define DUK_GIT_DESCRIBE "v2.4.0" +#define DUK_GIT_COMMIT "6001888049cb42656f8649db020e804bcdeca6a7" +#define DUK_GIT_DESCRIBE "v2.5.0" #define DUK_GIT_BRANCH "master" /* External duk_config.h provides platform/compiler/OS dependent @@ -394,30 +395,35 @@ struct duk_time_components { #define DUK_DEFPROP_C DUK_DEFPROP_CONFIGURABLE #define DUK_DEFPROP_WE (DUK_DEFPROP_WRITABLE | DUK_DEFPROP_ENUMERABLE) #define DUK_DEFPROP_WC (DUK_DEFPROP_WRITABLE | DUK_DEFPROP_CONFIGURABLE) +#define DUK_DEFPROP_EC (DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_CONFIGURABLE) #define DUK_DEFPROP_WEC (DUK_DEFPROP_WRITABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_CONFIGURABLE) #define DUK_DEFPROP_HAVE_W DUK_DEFPROP_HAVE_WRITABLE #define DUK_DEFPROP_HAVE_E DUK_DEFPROP_HAVE_ENUMERABLE #define DUK_DEFPROP_HAVE_C DUK_DEFPROP_HAVE_CONFIGURABLE #define DUK_DEFPROP_HAVE_WE (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE) #define DUK_DEFPROP_HAVE_WC (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_CONFIGURABLE) +#define DUK_DEFPROP_HAVE_EC (DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE) #define DUK_DEFPROP_HAVE_WEC (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE) #define DUK_DEFPROP_SET_W DUK_DEFPROP_SET_WRITABLE #define DUK_DEFPROP_SET_E DUK_DEFPROP_SET_ENUMERABLE #define DUK_DEFPROP_SET_C DUK_DEFPROP_SET_CONFIGURABLE #define DUK_DEFPROP_SET_WE (DUK_DEFPROP_SET_WRITABLE | DUK_DEFPROP_SET_ENUMERABLE) #define DUK_DEFPROP_SET_WC (DUK_DEFPROP_SET_WRITABLE | DUK_DEFPROP_SET_CONFIGURABLE) +#define DUK_DEFPROP_SET_EC (DUK_DEFPROP_SET_ENUMERABLE | DUK_DEFPROP_SET_CONFIGURABLE) #define DUK_DEFPROP_SET_WEC (DUK_DEFPROP_SET_WRITABLE | DUK_DEFPROP_SET_ENUMERABLE | DUK_DEFPROP_SET_CONFIGURABLE) #define DUK_DEFPROP_CLEAR_W DUK_DEFPROP_CLEAR_WRITABLE #define DUK_DEFPROP_CLEAR_E DUK_DEFPROP_CLEAR_ENUMERABLE #define DUK_DEFPROP_CLEAR_C DUK_DEFPROP_CLEAR_CONFIGURABLE #define DUK_DEFPROP_CLEAR_WE (DUK_DEFPROP_CLEAR_WRITABLE | DUK_DEFPROP_CLEAR_ENUMERABLE) #define DUK_DEFPROP_CLEAR_WC (DUK_DEFPROP_CLEAR_WRITABLE | DUK_DEFPROP_CLEAR_CONFIGURABLE) +#define DUK_DEFPROP_CLEAR_EC (DUK_DEFPROP_CLEAR_ENUMERABLE | DUK_DEFPROP_CLEAR_CONFIGURABLE) #define DUK_DEFPROP_CLEAR_WEC (DUK_DEFPROP_CLEAR_WRITABLE | DUK_DEFPROP_CLEAR_ENUMERABLE | DUK_DEFPROP_CLEAR_CONFIGURABLE) #define DUK_DEFPROP_ATTR_W (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_W) #define DUK_DEFPROP_ATTR_E (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_E) #define DUK_DEFPROP_ATTR_C (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_C) #define DUK_DEFPROP_ATTR_WE (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_WE) #define DUK_DEFPROP_ATTR_WC (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_WC) +#define DUK_DEFPROP_ATTR_EC (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_EC) #define DUK_DEFPROP_ATTR_WEC (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_WEC) /* Flags for duk_push_thread_raw() */ @@ -661,6 +667,7 @@ DUK_EXTERNAL_DECL void duk_swap_top(duk_context *ctx, duk_idx_t idx); DUK_EXTERNAL_DECL void duk_dup(duk_context *ctx, duk_idx_t from_idx); DUK_EXTERNAL_DECL void duk_dup_top(duk_context *ctx); DUK_EXTERNAL_DECL void duk_insert(duk_context *ctx, duk_idx_t to_idx); +DUK_EXTERNAL_DECL void duk_pull(duk_context *ctx, duk_idx_t from_idx); DUK_EXTERNAL_DECL void duk_replace(duk_context *ctx, duk_idx_t to_idx); DUK_EXTERNAL_DECL void duk_copy(duk_context *ctx, duk_idx_t from_idx, duk_idx_t to_idx); DUK_EXTERNAL_DECL void duk_remove(duk_context *ctx, duk_idx_t idx); @@ -1032,6 +1039,8 @@ DUK_EXTERNAL_DECL const char *duk_hex_encode(duk_context *ctx, duk_idx_t idx); DUK_EXTERNAL_DECL void duk_hex_decode(duk_context *ctx, duk_idx_t idx); DUK_EXTERNAL_DECL const char *duk_json_encode(duk_context *ctx, duk_idx_t idx); DUK_EXTERNAL_DECL void duk_json_decode(duk_context *ctx, duk_idx_t idx); +DUK_EXTERNAL_DECL void duk_cbor_encode(duk_context *ctx, duk_idx_t idx, duk_uint_t encode_flags); +DUK_EXTERNAL_DECL void duk_cbor_decode(duk_context *ctx, duk_idx_t idx, duk_uint_t decode_flags); DUK_EXTERNAL_DECL const char *duk_buffer_to_string(duk_context *ctx, duk_idx_t idx); -- cgit 1.2.3-korg