Update duktape to regexp-canonicalize-lookup branch.

- Add an optional 128kB lookup to optimize regexp canonicalization #411.
  https://github.com/svaarala/duktape/pull/411

This speeds up worst-case case-insensitive unicode regex handling.
This commit is contained in:
Michael Drake 2015-10-31 17:48:18 +00:00
parent 3aacba15f8
commit c22706b904
3 changed files with 9000 additions and 1892 deletions

View File

@ -170,6 +170,11 @@ static __inline__ unsigned long long duk_rdtsc(void) {
/* PowerPC */
#if defined(__powerpc) || defined(__powerpc__) || defined(__PPC__)
#define DUK_F_PPC
#if defined(__PPC64__)
#define DUK_F_PPC64
#else
#define DUK_F_PPC32
#endif
#endif
/* Linux */
@ -478,7 +483,9 @@ static __inline__ unsigned long long duk_rdtsc(void) {
* there is no platform specific date parsing/formatting but there is still
* the ISO 8601 standard format.
*/
#if defined(DUK_COMPILING_DUKTAPE)
#include <windows.h>
#endif
#include <limits.h>
#elif defined(DUK_F_FLASHPLAYER)
/* Crossbridge */
@ -1082,6 +1089,11 @@ typedef duk_int_t duk_idx_t;
#define DUK_IDX_MIN DUK_INT_MIN
#define DUK_IDX_MAX DUK_INT_MAX
/* Unsigned index variant. */
typedef duk_uint_t duk_uidx_t;
#define DUK_UIDX_MIN DUK_UINT_MIN
#define DUK_UIDX_MAX DUK_UINT_MAX
/* Array index values, could be exact 32 bits.
* Currently no need for signed duk_arridx_t.
*/
@ -1495,8 +1507,8 @@ typedef struct duk_hthread duk_context;
#define DUK_USE_PACKED_TVAL_POSSIBLE
#endif
/* PPC: packed always possible */
#if !defined(DUK_USE_PACKED_TVAL_POSSIBLE) && defined(DUK_F_PPC)
/* PPC32: packed always possible */
#if !defined(DUK_USE_PACKED_TVAL_POSSIBLE) && defined(DUK_F_PPC32)
#define DUK_USE_PACKED_TVAL_POSSIBLE
#endif
@ -2018,6 +2030,18 @@ typedef FILE duk_file;
#define DUK_ALWAYS_INLINE /*nop*/
#endif
/* Temporary workaround for GH-323: avoid inlining control when
* compiling from multiple sources, as it causes compiler trouble.
*/
#if !defined(DUK_SINGLE_FILE)
#undef DUK_NOINLINE
#undef DUK_INLINE
#undef DUK_ALWAYS_INLINE
#define DUK_NOINLINE /*nop*/
#define DUK_INLINE /*nop*/
#define DUK_ALWAYS_INLINE /*nop*/
#endif
/*
* Symbol visibility macros
*
@ -2227,6 +2251,16 @@ typedef FILE duk_file;
#define DUK_USE_COMPILER_STRING "unknown"
#endif
/*
* Target info string
*/
#if defined(DUK_OPT_TARGET_INFO)
#define DUK_USE_TARGET_INFO DUK_OPT_TARGET_INFO
#else
#define DUK_USE_TARGET_INFO "unknown"
#endif
/*
* Long control transfer, setjmp/longjmp or alternatives
*
@ -2263,16 +2297,6 @@ typedef FILE duk_file;
#error internal error
#endif
/*
* Target info string
*/
#if defined(DUK_OPT_TARGET_INFO)
#define DUK_USE_TARGET_INFO DUK_OPT_TARGET_INFO
#else
#define DUK_USE_TARGET_INFO "unknown"
#endif
/*
* Speed/size and other performance options
*/
@ -2294,11 +2318,17 @@ typedef FILE duk_file;
* where a speed-size tradeoff exists (e.g. lookup tables). When it really
* matters, specific use flags may be appropriate.
*/
#define DUK_USE_PREFER_SIZE
#undef DUK_USE_PREFER_SIZE
/* Use a sliding window for lexer; slightly larger footprint, slightly faster. */
#define DUK_USE_LEXER_SLIDING_WINDOW
/* Transparent JSON.stringify() fastpath. */
#undef DUK_USE_JSON_STRINGIFY_FASTPATH
#if defined(DUK_OPT_JSON_STRINGIFY_FASTPATH)
#define DUK_USE_JSON_STRINGIFY_FASTPATH
#endif
/*
* Tagged type representation (duk_tval)
*/
@ -2447,6 +2477,16 @@ typedef FILE duk_file;
#define DUK_USE_DEBUGGER_DUMPHEAP
#endif
#define DUK_USE_DEBUGGER_THROW_NOTIFY
#if defined(DUK_OPT_NO_DEBUGGER_THROW_NOTIFY)
#undef DUK_USE_DEBUGGER_THROW_NOTIFY
#endif
#undef DUK_USE_DEBUGGER_PAUSE_UNCAUGHT
#if defined(DUK_OPT_DEBUGGER_PAUSE_UNCAUGHT)
#define DUK_USE_DEBUGGER_PAUSE_UNCAUGHT
#endif
/* Debugger transport read/write torture. */
#undef DUK_USE_DEBUGGER_TRANSPORT_TORTURE
#if defined(DUK_OPT_DEBUGGER_TRANSPORT_TORTURE)
@ -2681,6 +2721,12 @@ typedef FILE duk_file;
#undef DUK_USE_NONSTD_ARRAY_WRITE
#endif
/* Node.js Buffer and Khronos/ES6 typed array support. */
#define DUK_USE_BUFFEROBJECT_SUPPORT
#if defined(DUK_OPT_NO_BUFFEROBJECT_SUPPORT)
#undef DUK_USE_BUFFEROBJECT_SUPPORT
#endif
/*
* Optional C API options
*/
@ -2703,20 +2749,6 @@ typedef FILE duk_file;
#undef DUK_USE_TAILCALL
#endif
/*
* Deep vs. shallow stack.
*
* Some embedded platforms have very shallow stack (e.g. 64kB); default to
* a shallow stack on unknown platforms or known embedded platforms.
*/
#if defined(DUK_F_LINUX) || defined(DUK_F_BSD) || defined(DUK_F_WINDOWS) || \
defined(DUK_F_APPLE) || defined(DUK_OPT_DEEP_C_STACK)
#define DUK_USE_DEEP_C_STACK
#else
#undef DUK_USE_DEEP_C_STACK
#endif
/*
* Ecmascript compiler
*/
@ -2930,10 +2962,6 @@ typedef FILE duk_file;
#define DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS
#undef DUK_USE_EXPLICIT_NULL_INIT
#if !defined(DUK_USE_PACKED_TVAL)
#define DUK_USE_EXPLICIT_NULL_INIT
#endif
#define DUK_USE_ZERO_BUFFER_DATA
#if defined(DUK_OPT_NO_ZERO_BUFFER_DATA)
#undef DUK_USE_ZERO_BUFFER_DATA
@ -2987,6 +3015,42 @@ typedef FILE duk_file;
#undef DUK_USE_GCC_PRAGMAS
#endif
/*
* User declarations
*/
#if defined(DUK_OPT_DECLARE)
#define DUK_USE_USER_DECLARE() DUK_OPT_DECLARE
#else
#define DUK_USE_USER_DECLARE() /* no user declarations */
#endif
/*
* Autogenerated defaults
*/
#define DUK_USE_COMPILER_RECLIMIT 2500
#undef DUK_USE_DATE_FORMAT_STRING
#undef DUK_USE_DATE_GET_LOCAL_TZOFFSET
#undef DUK_USE_DATE_GET_NOW
#undef DUK_USE_DATE_PARSE_STRING
#undef DUK_USE_DATE_PRS_GETDATE
#undef DUK_USE_EXEC_FUN_LOCAL
#undef DUK_USE_INTEGER_ME
#undef DUK_USE_INTERRUPT_DEBUG_FIXUP
#define DUK_USE_JSON_DECNUMBER_FASTPATH
#define DUK_USE_JSON_DECSTRING_FASTPATH
#define DUK_USE_JSON_DEC_RECLIMIT 1000
#define DUK_USE_JSON_EATWHITE_FASTPATH
#define DUK_USE_JSON_ENC_RECLIMIT 1000
#define DUK_USE_JSON_QUOTESTRING_FASTPATH
#undef DUK_USE_MARKANDSWEEP_FINALIZER_TORTURE
#define DUK_USE_MARK_AND_SWEEP_RECLIMIT 256
#define DUK_USE_NATIVE_CALL_RECLIMIT 1000
#undef DUK_USE_REFZERO_FINALIZER_TORTURE
#define DUK_USE_REGEXP_COMPILER_RECLIMIT 10000
#define DUK_USE_REGEXP_EXECUTOR_RECLIMIT 10000
/*
* Alternative customization header
*
@ -2999,6 +3063,14 @@ typedef FILE duk_file;
#include "duk_custom.h"
#endif
/*
* You may add overriding #define/#undef directives below for
* customization. You of course cannot un-#include or un-typedef
* anything; these require direct changes above.
*/
/* __OVERRIDE_DEFINES__ */
/*
* Date provider selection
*
@ -3060,36 +3132,6 @@ DUK_INTERNAL_DECL duk_bool_t duk_bi_date_format_parts_strftime(duk_context *ctx,
#endif /* DUK_COMPILING_DUKTAPE */
/*
* User declarations
*/
#if defined(DUK_OPT_DECLARE)
#define DUK_USE_USER_DECLARE() DUK_OPT_DECLARE
#else
#define DUK_USE_USER_DECLARE() /* no user declarations */
#endif
/*
* Autogenerated defaults
*/
#undef DUK_USE_DATE_PRS_GETDATE
#undef DUK_USE_INTEGER_ME
#define DUK_USE_JSON_DECNUMBER_FASTPATH
#define DUK_USE_JSON_DECSTRING_FASTPATH
#define DUK_USE_JSON_EATWHITE_FASTPATH
#define DUK_USE_JSON_QUOTESTRING_FASTPATH
#undef DUK_USE_JSON_STRINGIFY_FASTPATH
/*
* You may add overriding #define/#undef directives below for
* customization. You of course cannot un-#include or un-typedef
* anything; these require direct changes above.
*/
/* __OVERRIDE_DEFINES__ */
/*
* Sanity check for the final effective internal defines. Also
* double checks user tweaks made by an optional duk_custom.h header.

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,12 @@
/*
* Duktape public API for Duktape 1.2.99.
* Duktape public API for Duktape 1.3.99.
* See the API reference for documentation on call semantics.
* The exposed API is inside the DUK_API_PUBLIC_H_INCLUDED
* include guard. Other parts of the header are Duktape
* internal and related to platform/compiler/feature detection.
*
* Git commit 2a41d0a38eef5edfe8691cf09427b6ee8a3ad5c9 (v1.2.0-310-g2a41d0a).
* Git commit 40453939c5a5aa16898d19bbac4d02f77196cc8b (v1.3.0-138-g4045393).
* Git branch regexp-canonicalize-lookup.
*
* See Duktape AUTHORS.rst and LICENSE.txt for copyright and
* licensing information.
@ -59,8 +60,9 @@
* Please include an e-mail address, a link to your GitHub profile, or something
* similar to allow your contribution to be identified accurately.
*
* The following people have contributed code and agreed to irrevocably license
* their contributions under the Duktape ``LICENSE.txt`` (in order of appearance):
* The following people have contributed code, website contents, or Wiki contents,
* and agreed to irrevocably license their contributions under the Duktape
* ``LICENSE.txt`` (in order of appearance):
*
* * Sami Vaarala <sami.vaarala@iki.fi>
* * Niki Dobrev
@ -68,6 +70,7 @@
* * L\u00e1szl\u00f3 Lang\u00f3 <llango.u-szeged@partner.samsung.com>
* * Legimet <legimet.calc@gmail.com>
* * Karl Skomski <karl@skomski.com>
* * Bruce Pascoe <fatcerberus1@gmail.com>
*
* Other contributions
* ===================
@ -208,13 +211,16 @@ struct duk_number_list_entry {
* 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 10299L
#define DUK_VERSION 10399L
/* Git describe 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.
/* 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_DESCRIBE "v1.2.0-310-g2a41d0a"
#define DUK_GIT_COMMIT "40453939c5a5aa16898d19bbac4d02f77196cc8b"
#define DUK_GIT_DESCRIBE "v1.3.0-138-g4045393"
#define DUK_GIT_BRANCH "regexp-canonicalize-lookup"
/* Duktape debug protocol version used by this build. */
#define DUK_DEBUG_PROTOCOL_VERSION 1
@ -276,9 +282,9 @@ struct duk_number_list_entry {
#define DUK_ENUM_NO_PROXY_BEHAVIOR (1 << 5) /* enumerate a proxy object itself without invoking proxy behavior */
/* Compilation flags for duk_compile() and duk_eval() */
#define DUK_COMPILE_EVAL (1 << 0) /* compile eval code (instead of program) */
#define DUK_COMPILE_FUNCTION (1 << 1) /* compile function code (instead of program) */
#define DUK_COMPILE_STRICT (1 << 2) /* use strict (outer) context for program, eval, or function */
#define DUK_COMPILE_EVAL (1 << 0) /* compile eval code (instead of global code) */
#define DUK_COMPILE_FUNCTION (1 << 1) /* compile function code (instead of global code) */
#define DUK_COMPILE_STRICT (1 << 2) /* use strict (outer) context for global, eval, or function code */
#define DUK_COMPILE_SAFE (1 << 3) /* (internal) catch compilation errors */
#define DUK_COMPILE_NORESULT (1 << 4) /* (internal) omit eval result */
#define DUK_COMPILE_NOSOURCE (1 << 5) /* (internal) no source string on stack */
@ -536,16 +542,36 @@ DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_va_raw(duk_context *ctx, duk_e
duk_push_error_object_va_raw((ctx), (err_code), (const char *) (__FILE__), (duk_int_t) (__LINE__), (fmt), (ap))
#define DUK_BUF_FLAG_DYNAMIC (1 << 0) /* internal flag: dynamic buffer */
#define DUK_BUF_FLAG_NOZERO (1 << 1) /* internal flag: don't zero allocated buffer */
#define DUK_BUF_FLAG_EXTERNAL (1 << 1) /* internal flag: external buffer */
#define DUK_BUF_FLAG_NOZERO (1 << 2) /* internal flag: don't zero allocated buffer */
DUK_EXTERNAL_DECL void *duk_push_buffer_raw(duk_context *ctx, duk_size_t size, duk_small_uint_t flags);
#define duk_push_buffer(ctx,size,dynamic) \
duk_push_buffer_raw((ctx), (size), (dynamic));
duk_push_buffer_raw((ctx), (size), (dynamic) ? DUK_BUF_FLAG_DYNAMIC : 0);
#define duk_push_fixed_buffer(ctx,size) \
duk_push_buffer_raw((ctx), (size), 0 /*dynamic*/)
duk_push_buffer_raw((ctx), (size), 0 /*flags*/)
#define duk_push_dynamic_buffer(ctx,size) \
duk_push_buffer_raw((ctx), (size), 1 /*dynamic*/)
duk_push_buffer_raw((ctx), (size), DUK_BUF_FLAG_DYNAMIC /*flags*/)
#define duk_push_external_buffer(ctx) \
((void) duk_push_buffer_raw((ctx), 0, DUK_BUF_FLAG_DYNAMIC | DUK_BUF_FLAG_EXTERNAL))
#define DUK_BUFOBJ_CREATE_ARRBUF (1 << 4) /* internal flag: create backing ArrayBuffer; keep in one byte */
#define DUK_BUFOBJ_DUKTAPE_BUFFER 0
#define DUK_BUFOBJ_NODEJS_BUFFER 1
#define DUK_BUFOBJ_ARRAYBUFFER 2
#define DUK_BUFOBJ_DATAVIEW (3 | DUK_BUFOBJ_CREATE_ARRBUF)
#define DUK_BUFOBJ_INT8ARRAY (4 | DUK_BUFOBJ_CREATE_ARRBUF)
#define DUK_BUFOBJ_UINT8ARRAY (5 | DUK_BUFOBJ_CREATE_ARRBUF)
#define DUK_BUFOBJ_UINT8CLAMPEDARRAY (6 | DUK_BUFOBJ_CREATE_ARRBUF)
#define DUK_BUFOBJ_INT16ARRAY (7 | DUK_BUFOBJ_CREATE_ARRBUF)
#define DUK_BUFOBJ_UINT16ARRAY (8 | DUK_BUFOBJ_CREATE_ARRBUF)
#define DUK_BUFOBJ_INT32ARRAY (9 | DUK_BUFOBJ_CREATE_ARRBUF)
#define DUK_BUFOBJ_UINT32ARRAY (10 | DUK_BUFOBJ_CREATE_ARRBUF)
#define DUK_BUFOBJ_FLOAT32ARRAY (11 | DUK_BUFOBJ_CREATE_ARRBUF)
#define DUK_BUFOBJ_FLOAT64ARRAY (12 | DUK_BUFOBJ_CREATE_ARRBUF)
DUK_EXTERNAL_DECL void duk_push_buffer_object(duk_context *ctx, duk_idx_t idx_buffer, duk_size_t byte_offset, duk_size_t byte_length, duk_uint_t flags);
DUK_EXTERNAL_DECL duk_idx_t duk_push_heapptr(duk_context *ctx, void *ptr);
@ -592,8 +618,18 @@ DUK_EXTERNAL_DECL duk_bool_t duk_is_thread(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_callable(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_dynamic_buffer(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_fixed_buffer(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_external_buffer(duk_context *ctx, duk_idx_t index);
#define duk_is_primitive(ctx,index) \
duk_check_type_mask((ctx), (index), DUK_TYPE_MASK_UNDEFINED | \
DUK_TYPE_MASK_NULL | \
DUK_TYPE_MASK_BOOLEAN | \
DUK_TYPE_MASK_NUMBER | \
DUK_TYPE_MASK_STRING | \
DUK_TYPE_MASK_BUFFER | \
DUK_TYPE_MASK_POINTER | \
DUK_TYPE_MASK_LIGHTFUNC)
DUK_EXTERNAL_DECL duk_bool_t duk_is_primitive(duk_context *ctx, duk_idx_t index);
#define duk_is_object_coercible(ctx,index) \
duk_check_type_mask((ctx), (index), DUK_TYPE_MASK_BOOLEAN | \
DUK_TYPE_MASK_NUMBER | \
@ -719,6 +755,7 @@ DUK_EXTERNAL_DECL void duk_json_decode(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void *duk_resize_buffer(duk_context *ctx, duk_idx_t index, duk_size_t new_size);
DUK_EXTERNAL_DECL void *duk_steal_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
DUK_EXTERNAL_DECL void duk_config_buffer(duk_context *ctx, duk_idx_t index, void *ptr, duk_size_t len);
/*
* Property access
@ -831,6 +868,7 @@ DUK_EXTERNAL_DECL duk_int_t duk_pcall(duk_context *ctx, duk_idx_t nargs);
DUK_EXTERNAL_DECL duk_int_t duk_pcall_method(duk_context *ctx, duk_idx_t nargs);
DUK_EXTERNAL_DECL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs);
DUK_EXTERNAL_DECL void duk_new(duk_context *ctx, duk_idx_t nargs);
DUK_EXTERNAL_DECL duk_int_t duk_pnew(duk_context *ctx, duk_idx_t nargs);
DUK_EXTERNAL_DECL duk_int_t duk_safe_call(duk_context *ctx, duk_safe_call_function func, duk_idx_t nargs, duk_idx_t nrets);
/*
@ -1314,7 +1352,7 @@ typedef union duk_double_union duk_double_union;
*
* When packed duk_tval is used, the NaN space is used to store pointers
* and other tagged values in addition to NaNs. Actual NaNs are normalized
* to a specific format. The macros below are used by the implementation
* to a specific quiet NaN. The macros below are used by the implementation
* to check and normalize NaN values when they might be created. The macros
* are essentially NOPs when the non-packed duk_tval representation is used.
*
@ -1322,7 +1360,8 @@ typedef union duk_double_union duk_double_union;
* the packed duk_tval and works correctly for all NaNs except those that
* begin with 0x7ff0. Since the 'normalized NaN' values used with packed
* duk_tval begin with 0x7ff8, the partial check is reliable when packed
* duk_tval is used.
* duk_tval is used. The 0x7ff8 prefix means the normalized NaN will be a
* quiet NaN regardless of its remaining lower bits.
*
* The ME variant below is specifically for ARM byte order, which has the
* feature that while doubles have a mixed byte order (32107654), unsigned