From 3356906904487e5931e38ba21e100bdec113e783 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 21 Oct 2017 15:51:55 +0100 Subject: Duktape: Update to 2.2.0 release. --- content/handlers/javascript/duktape/duk_config.h | 114 ++++++++++++++++++++--- 1 file changed, 99 insertions(+), 15 deletions(-) (limited to 'content/handlers/javascript/duktape/duk_config.h') diff --git a/content/handlers/javascript/duktape/duk_config.h b/content/handlers/javascript/duktape/duk_config.h index 4a16a68da..1f2b1dab0 100644 --- a/content/handlers/javascript/duktape/duk_config.h +++ b/content/handlers/javascript/duktape/duk_config.h @@ -525,6 +525,11 @@ #endif #elif defined(DUK_F_WINDOWS) /* --- Windows --- */ +/* Windows version can't obviously be determined at compile time, + * but _WIN32_WINNT indicates the minimum version targeted: + * - https://msdn.microsoft.com/en-us/library/6sehtctf.aspx + */ + /* Initial fix: disable secure CRT related warnings when compiling Duktape * itself (must be defined before including Windows headers). Don't define * for user code including duktape.h. @@ -535,17 +540,40 @@ /* Windows 32-bit and 64-bit are currently the same. */ /* MSVC does not have sys/param.h */ + +#if defined(DUK_COMPILING_DUKTAPE) +/* Only include when compiling Duktape to avoid polluting application build + * with a lot of unnecessary defines. + */ +#include +#endif + +/* GetSystemTimePreciseAsFileTime() available from Windows 8: + * https://msdn.microsoft.com/en-us/library/windows/desktop/hh706895(v=vs.85).aspx + */ +#if defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS) || defined(DUK_USE_DATE_NOW_WINDOWS) +/* User forced provider. */ +#else +#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602) +#define DUK_USE_DATE_NOW_WINDOWS_SUBMS +#else #define DUK_USE_DATE_NOW_WINDOWS +#endif +#endif + #define DUK_USE_DATE_TZO_WINDOWS + /* Note: PRS and FMT are intentionally left undefined for now. This means * there is no platform specific date parsing/formatting but there is still * the ISO 8601 standard format. */ -#if defined(DUK_COMPILING_DUKTAPE) -/* Only include when compiling Duktape to avoid polluting application build - * with a lot of unnecessary defines. + +/* QueryPerformanceCounter() may go backwards in Windows XP, so enable for + * Vista and later: https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx#qpc_support_in_windows_versions */ -#include +#if !defined(DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC) && \ + defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) +#define DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC #endif #define DUK_USE_OS_STRING "windows" @@ -667,6 +695,10 @@ #define DUK_USE_DATE_PRS_STRPTIME #define DUK_USE_DATE_FMT_STRFTIME +#if 0 /* XXX: safe condition? */ +#define DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME +#endif + #define DUK_USE_OS_STRING "linux" #elif defined(DUK_F_SUN) /* --- Solaris --- */ @@ -1307,7 +1339,16 @@ #endif /* Avoid warning when doing DUK_UNREF(some_function). */ +#if defined(_MSC_VER) && (_MSC_VER < 1500) +#pragma warning(disable: 4100 4101 4550 4551) +#define DUK_UNREF(x) +#else #define DUK_UNREF(x) do { __pragma(warning(suppress:4100 4101 4550 4551)) (x); } while (0) +#endif + +/* Older versions of MSVC don't support the LL/ULL suffix. */ +#define DUK_U64_CONSTANT(x) x##ui64 +#define DUK_I64_CONSTANT(x) x##i64 #elif defined(DUK_F_EMSCRIPTEN) /* --- Emscripten --- */ #define DUK_NORETURN(decl) decl __attribute__((noreturn)) @@ -1535,12 +1576,14 @@ defined(DUK_F_BCC) || \ (defined(__WORDSIZE) && (__WORDSIZE == 32)) || \ ((defined(DUK_F_OLD_SOLARIS) || defined(DUK_F_AIX) || \ - defined(DUK_F_HPUX)) && defined(_ILP32)) + defined(DUK_F_HPUX)) && defined(_ILP32)) || \ + defined(DUK_F_ARM32) #define DUK_F_32BIT_PTRS #elif defined(DUK_F_X64) || \ (defined(__WORDSIZE) && (__WORDSIZE == 64)) || \ ((defined(DUK_F_OLD_SOLARIS) || defined(DUK_F_AIX) || \ - defined(DUK_F_HPUX)) && defined(_LP64)) + defined(DUK_F_HPUX)) && defined(_LP64)) || \ + defined(DUK_F_ARM64) #define DUK_F_64BIT_PTRS #else /* not sure, not needed with C99 anyway */ @@ -1743,13 +1786,16 @@ typedef unsigned long long duk_uint64_t; typedef signed long long duk_int64_t; #endif #endif -#if !defined(DUK_F_HAVE_64BIT) && \ - (defined(DUK_F_MINGW) || defined(DUK_F_MSVC)) -/* Both MinGW and MSVC have a 64-bit type. */ +#if !defined(DUK_F_HAVE_64BIT) && defined(DUK_F_MINGW) #define DUK_F_HAVE_64BIT typedef unsigned long duk_uint64_t; typedef signed long duk_int64_t; #endif +#if !defined(DUK_F_HAVE_64BIT) && defined(DUK_F_MSVC) +#define DUK_F_HAVE_64BIT +typedef unsigned __int64 duk_uint64_t; +typedef signed __int64 duk_int64_t; +#endif #if !defined(DUK_F_HAVE_64BIT) /* cannot detect 64-bit type, not always needed so don't error */ #endif @@ -1957,8 +2003,8 @@ typedef duk_uint_fast16_t duk_small_uint_fast_t; #define DUK_SMALL_UINT_FAST_MIN DUK_UINT_FAST16_MIN #define DUK_SMALL_UINT_FAST_MAX DUK_UINT_FAST16_MAX -/* Boolean values are represented with the platform 'int'. */ -typedef duk_small_int_t duk_bool_t; +/* Boolean values are represented with the platform 'unsigned int'. */ +typedef duk_small_uint_t duk_bool_t; #define DUK_BOOL_MIN DUK_SMALL_INT_MIN #define DUK_BOOL_MAX DUK_SMALL_INT_MAX @@ -2029,7 +2075,10 @@ typedef double duk_double_t; #endif #endif -/* Type for public API calls. */ +/* Type used in public API declarations and user code. Typedef maps to + * 'struct duk_hthread' like the 'duk_hthread' typedef which is used + * exclusively in internals. + */ typedef struct duk_hthread duk_context; /* Check whether we should use 64-bit integers or not. @@ -2676,6 +2725,13 @@ typedef struct duk_hthread duk_context; #undef DUK_USE_GCC_PRAGMAS #endif +#if !defined(DUK_U64_CONSTANT) +#define DUK_U64_CONSTANT(x) x##ULL +#endif +#if !defined(DUK_I64_CONSTANT) +#define DUK_I64_CONSTANT(x) x##LL +#endif + /* Workaround for GH-323: avoid inlining control when compiling from * multiple sources, as it causes compiler portability trouble. */ @@ -2773,6 +2829,9 @@ typedef struct duk_hthread duk_context; #define DUK_USE_BUFFEROBJECT_SUPPORT #undef DUK_USE_BUFLEN16 #define DUK_USE_BYTECODE_DUMP_SUPPORT +#define DUK_USE_CACHE_ACTIVATION +#define DUK_USE_CACHE_CATCHER +#define DUK_USE_CALLSTACK_LIMIT 10000 #define DUK_USE_COMMONJS_MODULES #define DUK_USE_COMPILER_RECLIMIT 2500 #define DUK_USE_COROUTINE_SUPPORT @@ -2807,7 +2866,10 @@ typedef struct duk_hthread duk_context; #define DUK_USE_ES6_PROXY #define DUK_USE_ES6_REGEXP_SYNTAX #define DUK_USE_ES6_UNICODE_ESCAPE +#define DUK_USE_ES7 #define DUK_USE_ES7_EXP_OPERATOR +#define DUK_USE_ES8 +#define DUK_USE_ES9 #define DUK_USE_ESBC_LIMITS #define DUK_USE_ESBC_MAX_BYTES 2147418112L #define DUK_USE_ESBC_MAX_LINENUMBER 2147418112L @@ -2822,6 +2884,7 @@ typedef struct duk_hthread duk_context; #undef DUK_USE_FASTINT #define DUK_USE_FAST_REFCOUNT_DEFAULT #undef DUK_USE_FATAL_HANDLER +#define DUK_USE_FATAL_MAXLEN 128 #define DUK_USE_FINALIZER_SUPPORT #undef DUK_USE_FINALIZER_TORTURE #undef DUK_USE_FUNCPTR16 @@ -2831,6 +2894,7 @@ typedef struct duk_hthread duk_context; #define DUK_USE_FUNC_FILENAME_PROPERTY #define DUK_USE_FUNC_NAME_PROPERTY #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_BUILTIN @@ -2849,6 +2913,7 @@ typedef struct duk_hthread duk_context; #define DUK_USE_HSTRING_ARRIDX #define DUK_USE_HSTRING_CLEN #undef DUK_USE_HSTRING_EXTDATA +#define DUK_USE_HSTRING_LAZY_CLEN #define DUK_USE_HTML_COMMENTS #define DUK_USE_IDCHAR_FASTPATH #undef DUK_USE_INJECT_HEAP_ALLOC_ERROR @@ -2885,12 +2950,15 @@ typedef struct duk_hthread duk_context; #undef DUK_USE_OBJSIZES16 #undef DUK_USE_PARANOID_ERRORS #define DUK_USE_PC2LINE +#define DUK_USE_PERFORMANCE_BUILTIN #undef DUK_USE_PREFER_SIZE +#undef DUK_USE_PROMISE_BUILTIN #define DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS #undef DUK_USE_REFCOUNT16 #define DUK_USE_REFCOUNT32 #define DUK_USE_REFERENCE_COUNTING #define DUK_USE_REFLECT_BUILTIN +#define DUK_USE_REGEXP_CANON_BITMAP #undef DUK_USE_REGEXP_CANON_WORKAROUND #define DUK_USE_REGEXP_COMPILER_RECLIMIT 10000 #define DUK_USE_REGEXP_EXECUTOR_RECLIMIT 10000 @@ -2925,6 +2993,10 @@ typedef struct duk_hthread duk_context; #define DUK_USE_TRACEBACKS #define DUK_USE_TRACEBACK_DEPTH 10 #define DUK_USE_USER_DECLARE() /* no user declarations */ +#define DUK_USE_VALSTACK_GROW_SHIFT 2 +#define DUK_USE_VALSTACK_LIMIT 1000000L +#define DUK_USE_VALSTACK_SHRINK_CHECK_SHIFT 2 +#define DUK_USE_VALSTACK_SHRINK_SLACK_SHIFT 4 #undef DUK_USE_VALSTACK_UNSAFE #define DUK_USE_VERBOSE_ERRORS #define DUK_USE_VERBOSE_EXECUTOR_ERRORS @@ -2958,11 +3030,13 @@ typedef struct duk_hthread duk_context; #if defined(DUK_USE_DATE_GET_NOW) /* External provider already defined. */ #elif defined(DUK_USE_DATE_NOW_GETTIMEOFDAY) -#define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_gettimeofday((ctx)) +#define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_gettimeofday() #elif defined(DUK_USE_DATE_NOW_TIME) -#define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_time((ctx)) +#define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_time() #elif defined(DUK_USE_DATE_NOW_WINDOWS) -#define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_windows((ctx)) +#define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_windows() +#elif defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS) +#define DUK_USE_DATE_GET_NOW(ctx) duk_bi_date_get_now_windows_subms() #else #error no provider for DUK_USE_DATE_GET_NOW() #endif @@ -2998,6 +3072,16 @@ typedef struct duk_hthread duk_context; /* No provider for DUK_USE_DATE_FORMAT_STRING(), fall back to ISO 8601 only. */ #endif +#if defined(DUK_USE_GET_MONOTONIC_TIME) +/* External provider already defined. */ +#elif defined(DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME) +#define DUK_USE_GET_MONOTONIC_TIME(ctx) duk_bi_date_get_monotonic_time_clock_gettime() +#elif defined(DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC) +#define DUK_USE_GET_MONOTONIC_TIME(ctx) duk_bi_date_get_monotonic_time_windows_qpc() +#else +/* No provider for DUK_USE_GET_MONOTONIC_TIME(), fall back to DUK_USE_DATE_GET_NOW(). */ +#endif + #endif /* DUK_COMPILING_DUKTAPE */ /* -- cgit v1.2.3