Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
duk_hthread.h File Reference

Go to the source code of this file.

Data Structures

struct  duk_activation
 
struct  duk_catcher
 
struct  duk_hthread
 

Macros

#define DUK_VALSTACK_GROW_STEP   128 /* roughly 1 kiB */
 
#define DUK_VALSTACK_SHRINK_THRESHOLD   256 /* roughly 2 kiB */
 
#define DUK_VALSTACK_SHRINK_SPARE   64 /* roughly 0.5 kiB */
 
#define DUK_VALSTACK_INITIAL_SIZE   128 /* roughly 1.0 kiB -> but rounds up to DUK_VALSTACK_GROW_STEP in practice */
 
#define DUK_VALSTACK_INTERNAL_EXTRA
 
#define DUK_VALSTACK_API_ENTRY_MINIMUM   DUK_API_ENTRY_STACK
 
#define DUK_VALSTACK_DEFAULT_MAX   1000000L
 
#define DUK_CALLSTACK_GROW_STEP   8 /* roughly 256 bytes */
 
#define DUK_CALLSTACK_SHRINK_THRESHOLD   16 /* roughly 512 bytes */
 
#define DUK_CALLSTACK_SHRINK_SPARE   8 /* roughly 256 bytes */
 
#define DUK_CALLSTACK_INITIAL_SIZE   8
 
#define DUK_CALLSTACK_DEFAULT_MAX   10000L
 
#define DUK_CATCHSTACK_GROW_STEP   4 /* roughly 64 bytes */
 
#define DUK_CATCHSTACK_SHRINK_THRESHOLD   8 /* roughly 128 bytes */
 
#define DUK_CATCHSTACK_SHRINK_SPARE   4 /* roughly 64 bytes */
 
#define DUK_CATCHSTACK_INITIAL_SIZE   4
 
#define DUK_CATCHSTACK_DEFAULT_MAX   10000L
 
#define DUK_ACT_FLAG_STRICT   (1 << 0) /* function executes in strict mode */
 
#define DUK_ACT_FLAG_TAILCALLED   (1 << 1) /* activation has tail called one or more times */
 
#define DUK_ACT_FLAG_CONSTRUCT   (1 << 2) /* function executes as a constructor (called via "new") */
 
#define DUK_ACT_FLAG_PREVENT_YIELD   (1 << 3) /* activation prevents yield (native call or "new") */
 
#define DUK_ACT_FLAG_DIRECT_EVAL   (1 << 4) /* activation is a direct eval call */
 
#define DUK_ACT_FLAG_BREAKPOINT_ACTIVE   (1 << 5) /* activation has active breakpoint(s) */
 
#define DUK_ACT_GET_FUNC(act)   ((act)->func)
 
#define DUK_TB_FLAG_NOBLAME_FILELINE   (1 << 0) /* don't report __FILE__ / __LINE__ as fileName/lineNumber */
 
#define DUK_CAT_TYPE_MASK   0x0000000fUL
 
#define DUK_CAT_TYPE_BITS   4
 
#define DUK_CAT_LABEL_MASK   0xffffff00UL
 
#define DUK_CAT_LABEL_BITS   24
 
#define DUK_CAT_LABEL_SHIFT   8
 
#define DUK_CAT_FLAG_CATCH_ENABLED   (1 << 4) /* catch part will catch */
 
#define DUK_CAT_FLAG_FINALLY_ENABLED   (1 << 5) /* finally part will catch */
 
#define DUK_CAT_FLAG_CATCH_BINDING_ENABLED   (1 << 6) /* request to create catch binding */
 
#define DUK_CAT_FLAG_LEXENV_ACTIVE   (1 << 7) /* catch or with binding is currently active */
 
#define DUK_CAT_TYPE_UNKNOWN   0
 
#define DUK_CAT_TYPE_TCF   1
 
#define DUK_CAT_TYPE_LABEL   2
 
#define DUK_CAT_GET_TYPE(c)   ((c)->flags & DUK_CAT_TYPE_MASK)
 
#define DUK_CAT_GET_LABEL(c)   (((c)->flags & DUK_CAT_LABEL_MASK) >> DUK_CAT_LABEL_SHIFT)
 
#define DUK_CAT_HAS_CATCH_ENABLED(c)   ((c)->flags & DUK_CAT_FLAG_CATCH_ENABLED)
 
#define DUK_CAT_HAS_FINALLY_ENABLED(c)   ((c)->flags & DUK_CAT_FLAG_FINALLY_ENABLED)
 
#define DUK_CAT_HAS_CATCH_BINDING_ENABLED(c)   ((c)->flags & DUK_CAT_FLAG_CATCH_BINDING_ENABLED)
 
#define DUK_CAT_HAS_LEXENV_ACTIVE(c)   ((c)->flags & DUK_CAT_FLAG_LEXENV_ACTIVE)
 
#define DUK_CAT_SET_CATCH_ENABLED(c)
 
#define DUK_CAT_SET_FINALLY_ENABLED(c)
 
#define DUK_CAT_SET_CATCH_BINDING_ENABLED(c)
 
#define DUK_CAT_SET_LEXENV_ACTIVE(c)
 
#define DUK_CAT_CLEAR_CATCH_ENABLED(c)
 
#define DUK_CAT_CLEAR_FINALLY_ENABLED(c)
 
#define DUK_CAT_CLEAR_CATCH_BINDING_ENABLED(c)
 
#define DUK_CAT_CLEAR_LEXENV_ACTIVE(c)
 
#define DUK_HTHREAD_GET_STRING(thr, idx)    ((thr)->strs[(idx)])
 
#define DUK_HTHREAD_GET_CURRENT_ACTIVATION(thr)   (&(thr)->callstack[(thr)->callstack_top - 1])
 
#define DUK_HTHREAD_STATE_INACTIVE   1 /* thread not currently running */
 
#define DUK_HTHREAD_STATE_RUNNING   2 /* thread currently running (only one at a time) */
 
#define DUK_HTHREAD_STATE_RESUMED   3 /* thread resumed another thread (active but not running) */
 
#define DUK_HTHREAD_STATE_YIELDED   4 /* thread has yielded */
 
#define DUK_HTHREAD_STATE_TERMINATED   5 /* thread has terminated */
 
#define DUK_ASSERT_CTX_VSSIZE(ctx)
 
#define DUK_ASSERT_CTX_VALID(ctx)
 

Functions

DUK_INTERNAL_DECL void duk_hthread_copy_builtin_objects (duk_hthread *thr_from, duk_hthread *thr_to)
 
DUK_INTERNAL_DECL void duk_hthread_create_builtin_objects (duk_hthread *thr)
 
DUK_INTERNAL_DECL duk_bool_t duk_hthread_init_stacks (duk_heap *heap, duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_hthread_terminate (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_hthread_callstack_grow (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_hthread_callstack_shrink_check (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_hthread_callstack_unwind (duk_hthread *thr, duk_size_t new_top)
 
DUK_INTERNAL_DECL void duk_hthread_catchstack_grow (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_hthread_catchstack_shrink_check (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_hthread_catchstack_unwind (duk_hthread *thr, duk_size_t new_top)
 
DUK_INTERNAL_DECL duk_activationduk_hthread_get_current_activation (duk_hthread *thr)
 
DUK_INTERNAL_DECL void * duk_hthread_get_valstack_ptr (duk_heap *heap, void *ud)
 
DUK_INTERNAL_DECL void * duk_hthread_get_callstack_ptr (duk_heap *heap, void *ud)
 
DUK_INTERNAL_DECL void * duk_hthread_get_catchstack_ptr (duk_heap *heap, void *ud)
 
DUK_INTERNAL_DECL duk_uint_fast32_t duk_hthread_get_act_prev_pc (duk_hthread *thr, duk_activation *act)
 
DUK_INTERNAL_DECL void duk_hthread_sync_currpc (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_hthread_sync_and_null_currpc (duk_hthread *thr)
 

Macro Definition Documentation

◆ DUK_ACT_FLAG_BREAKPOINT_ACTIVE

#define DUK_ACT_FLAG_BREAKPOINT_ACTIVE   (1 << 5) /* activation has active breakpoint(s) */

Definition at line 53 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_ACT_FLAG_CONSTRUCT

#define DUK_ACT_FLAG_CONSTRUCT   (1 << 2) /* function executes as a constructor (called via "new") */

Definition at line 50 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_ACT_FLAG_DIRECT_EVAL

#define DUK_ACT_FLAG_DIRECT_EVAL   (1 << 4) /* activation is a direct eval call */

Definition at line 52 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_ACT_FLAG_PREVENT_YIELD

#define DUK_ACT_FLAG_PREVENT_YIELD   (1 << 3) /* activation prevents yield (native call or "new") */

Definition at line 51 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_ACT_FLAG_STRICT

#define DUK_ACT_FLAG_STRICT   (1 << 0) /* function executes in strict mode */

Definition at line 48 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_ACT_FLAG_TAILCALLED

#define DUK_ACT_FLAG_TAILCALLED   (1 << 1) /* activation has tail called one or more times */

Definition at line 49 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_ACT_GET_FUNC

#define DUK_ACT_GET_FUNC ( act)    ((act)->func)

Definition at line 55 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_ASSERT_CTX_VALID

#define DUK_ASSERT_CTX_VALID ( ctx)
Value:
do { \
DUK_ASSERT((ctx) != NULL); \
DUK_ASSERT(DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) (ctx)) == DUK_HTYPE_OBJECT); \
DUK_ASSERT(DUK_HOBJECT_IS_THREAD((duk_hobject *) (ctx))); \
DUK_ASSERT(((duk_hthread *) (ctx))->unused1 == 0); \
DUK_ASSERT(((duk_hthread *) (ctx))->unused2 == 0); \
DUK_ASSERT(((duk_hthread *) (ctx))->valstack != NULL); \
DUK_ASSERT(((duk_hthread *) (ctx))->valstack_end >= ((duk_hthread *) (ctx))->valstack); \
DUK_ASSERT(((duk_hthread *) (ctx))->valstack_top >= ((duk_hthread *) (ctx))->valstack); \
DUK_ASSERT(((duk_hthread *) (ctx))->valstack_top >= ((duk_hthread *) (ctx))->valstack_bottom); \
DUK_ASSERT(((duk_hthread *) (ctx))->valstack_end >= ((duk_hthread *) (ctx))->valstack_top); \
DUK_ASSERT_CTX_VSSIZE((ctx)); \
} while (0)
#define DUK_HEAPHDR_GET_TYPE(h)
#define DUK_HOBJECT_IS_THREAD(h)
#define NULL
Definition gmacros.h:924

Definition at line 167 of file duktape-1.8.0/src-separate/duk_hthread.h.

167 DUK_ASSERT((duk_size_t) (((duk_hthread *) (ctx))->valstack_end - ((duk_hthread *) (ctx))->valstack) == \
168 ((duk_hthread *) (ctx))->valstack_size)
169#endif
170#define DUK_ASSERT_CTX_VALID(ctx) do { \
171 DUK_ASSERT((ctx) != NULL); \
172 DUK_ASSERT(DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) (ctx)) == DUK_HTYPE_OBJECT); \
173 DUK_ASSERT(DUK_HOBJECT_IS_THREAD((duk_hobject *) (ctx))); \
174 DUK_ASSERT(((duk_hthread *) (ctx))->unused1 == 0); \
175 DUK_ASSERT(((duk_hthread *) (ctx))->unused2 == 0); \
176 DUK_ASSERT(((duk_hthread *) (ctx))->valstack != NULL); \
177 DUK_ASSERT(((duk_hthread *) (ctx))->valstack_end >= ((duk_hthread *) (ctx))->valstack); \
178 DUK_ASSERT(((duk_hthread *) (ctx))->valstack_top >= ((duk_hthread *) (ctx))->valstack); \
179 DUK_ASSERT(((duk_hthread *) (ctx))->valstack_top >= ((duk_hthread *) (ctx))->valstack_bottom); \

◆ DUK_ASSERT_CTX_VSSIZE

#define DUK_ASSERT_CTX_VSSIZE ( ctx)
Value:
DUK_ASSERT((duk_size_t) (((duk_hthread *) (ctx))->valstack_end - ((duk_hthread *) (ctx))->valstack) == \
((duk_hthread *) (ctx))->valstack_size)

Definition at line 163 of file duktape-1.8.0/src-separate/duk_hthread.h.

163#if defined(DUK_USE_PREFER_SIZE)
164#define DUK_ASSERT_CTX_VSSIZE(ctx) /*nop*/
165#else

◆ DUK_CALLSTACK_DEFAULT_MAX

#define DUK_CALLSTACK_DEFAULT_MAX   10000L

Definition at line 36 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CALLSTACK_GROW_STEP

#define DUK_CALLSTACK_GROW_STEP   8 /* roughly 256 bytes */

Definition at line 32 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CALLSTACK_INITIAL_SIZE

#define DUK_CALLSTACK_INITIAL_SIZE   8

Definition at line 35 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CALLSTACK_SHRINK_SPARE

#define DUK_CALLSTACK_SHRINK_SPARE   8 /* roughly 256 bytes */

Definition at line 34 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CALLSTACK_SHRINK_THRESHOLD

#define DUK_CALLSTACK_SHRINK_THRESHOLD   16 /* roughly 512 bytes */

Definition at line 33 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_CLEAR_CATCH_BINDING_ENABLED

#define DUK_CAT_CLEAR_CATCH_BINDING_ENABLED ( c)
Value:
do { \
} while (0)
#define DUK_CAT_FLAG_CATCH_BINDING_ENABLED

Definition at line 110 of file duktape-1.8.0/src-separate/duk_hthread.h.

110#define DUK_CAT_CLEAR_FINALLY_ENABLED(c) do { \
111 (c)->flags &= ~DUK_CAT_FLAG_FINALLY_ENABLED; \
112 } while (0)

◆ DUK_CAT_CLEAR_CATCH_ENABLED

#define DUK_CAT_CLEAR_CATCH_ENABLED ( c)
Value:
do { \
(c)->flags &= ~DUK_CAT_FLAG_CATCH_ENABLED; \
} while (0)

Definition at line 104 of file duktape-1.8.0/src-separate/duk_hthread.h.

104 (c)->flags |= DUK_CAT_FLAG_LEXENV_ACTIVE; \
105 } while (0)
106

◆ DUK_CAT_CLEAR_FINALLY_ENABLED

#define DUK_CAT_CLEAR_FINALLY_ENABLED ( c)
Value:
do { \
(c)->flags &= ~DUK_CAT_FLAG_FINALLY_ENABLED; \
} while (0)

Definition at line 107 of file duktape-1.8.0/src-separate/duk_hthread.h.

107#define DUK_CAT_CLEAR_CATCH_ENABLED(c) do { \
108 (c)->flags &= ~DUK_CAT_FLAG_CATCH_ENABLED; \
109 } while (0)

◆ DUK_CAT_CLEAR_LEXENV_ACTIVE

#define DUK_CAT_CLEAR_LEXENV_ACTIVE ( c)
Value:
do { \
(c)->flags &= ~DUK_CAT_FLAG_LEXENV_ACTIVE; \
} while (0)

Definition at line 113 of file duktape-1.8.0/src-separate/duk_hthread.h.

113#define DUK_CAT_CLEAR_CATCH_BINDING_ENABLED(c) do { \
114 (c)->flags &= ~DUK_CAT_FLAG_CATCH_BINDING_ENABLED; \
115 } while (0)

◆ DUK_CAT_FLAG_CATCH_BINDING_ENABLED

#define DUK_CAT_FLAG_CATCH_BINDING_ENABLED   (1 << 6) /* request to create catch binding */

Definition at line 76 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_FLAG_CATCH_ENABLED

#define DUK_CAT_FLAG_CATCH_ENABLED   (1 << 4) /* catch part will catch */

Definition at line 74 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_FLAG_FINALLY_ENABLED

#define DUK_CAT_FLAG_FINALLY_ENABLED   (1 << 5) /* finally part will catch */

Definition at line 75 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_FLAG_LEXENV_ACTIVE

#define DUK_CAT_FLAG_LEXENV_ACTIVE   (1 << 7) /* catch or with binding is currently active */

Definition at line 77 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_GET_LABEL

#define DUK_CAT_GET_LABEL ( c)    (((c)->flags & DUK_CAT_LABEL_MASK) >> DUK_CAT_LABEL_SHIFT)

Definition at line 84 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_GET_TYPE

#define DUK_CAT_GET_TYPE ( c)    ((c)->flags & DUK_CAT_TYPE_MASK)

Definition at line 83 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_HAS_CATCH_BINDING_ENABLED

#define DUK_CAT_HAS_CATCH_BINDING_ENABLED ( c)    ((c)->flags & DUK_CAT_FLAG_CATCH_BINDING_ENABLED)

Definition at line 88 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_HAS_CATCH_ENABLED

#define DUK_CAT_HAS_CATCH_ENABLED ( c)    ((c)->flags & DUK_CAT_FLAG_CATCH_ENABLED)

Definition at line 86 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_HAS_FINALLY_ENABLED

#define DUK_CAT_HAS_FINALLY_ENABLED ( c)    ((c)->flags & DUK_CAT_FLAG_FINALLY_ENABLED)

Definition at line 87 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_HAS_LEXENV_ACTIVE

#define DUK_CAT_HAS_LEXENV_ACTIVE ( c)    ((c)->flags & DUK_CAT_FLAG_LEXENV_ACTIVE)

Definition at line 89 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_LABEL_BITS

#define DUK_CAT_LABEL_BITS   24

Definition at line 71 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_LABEL_MASK

#define DUK_CAT_LABEL_MASK   0xffffff00UL

Definition at line 70 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_LABEL_SHIFT

#define DUK_CAT_LABEL_SHIFT   8

Definition at line 72 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_SET_CATCH_BINDING_ENABLED

#define DUK_CAT_SET_CATCH_BINDING_ENABLED ( c)
Value:
do { \
} while (0)

Definition at line 97 of file duktape-1.8.0/src-separate/duk_hthread.h.

97#define DUK_CAT_SET_FINALLY_ENABLED(c) do { \
98 (c)->flags |= DUK_CAT_FLAG_FINALLY_ENABLED; \
99 } while (0)

◆ DUK_CAT_SET_CATCH_ENABLED

#define DUK_CAT_SET_CATCH_ENABLED ( c)
Value:
do { \
(c)->flags |= DUK_CAT_FLAG_CATCH_ENABLED; \
} while (0)

Definition at line 91 of file duktape-1.8.0/src-separate/duk_hthread.h.

91#define DUK_CAT_HAS_CATCH_BINDING_ENABLED(c) ((c)->flags & DUK_CAT_FLAG_CATCH_BINDING_ENABLED)
92#define DUK_CAT_HAS_LEXENV_ACTIVE(c) ((c)->flags & DUK_CAT_FLAG_LEXENV_ACTIVE)
93

◆ DUK_CAT_SET_FINALLY_ENABLED

#define DUK_CAT_SET_FINALLY_ENABLED ( c)
Value:
do { \
} while (0)

Definition at line 94 of file duktape-1.8.0/src-separate/duk_hthread.h.

94#define DUK_CAT_SET_CATCH_ENABLED(c) do { \
95 (c)->flags |= DUK_CAT_FLAG_CATCH_ENABLED; \
96 } while (0)

◆ DUK_CAT_SET_LEXENV_ACTIVE

#define DUK_CAT_SET_LEXENV_ACTIVE ( c)
Value:
do { \
(c)->flags |= DUK_CAT_FLAG_LEXENV_ACTIVE; \
} while (0)

Definition at line 100 of file duktape-1.8.0/src-separate/duk_hthread.h.

100#define DUK_CAT_SET_CATCH_BINDING_ENABLED(c) do { \
101 (c)->flags |= DUK_CAT_FLAG_CATCH_BINDING_ENABLED; \
102 } while (0)

◆ DUK_CAT_TYPE_BITS

#define DUK_CAT_TYPE_BITS   4

Definition at line 69 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_TYPE_LABEL

#define DUK_CAT_TYPE_LABEL   2

Definition at line 81 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_TYPE_MASK

#define DUK_CAT_TYPE_MASK   0x0000000fUL

Definition at line 68 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_TYPE_TCF

#define DUK_CAT_TYPE_TCF   1

Definition at line 80 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CAT_TYPE_UNKNOWN

#define DUK_CAT_TYPE_UNKNOWN   0

Definition at line 79 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CATCHSTACK_DEFAULT_MAX

#define DUK_CATCHSTACK_DEFAULT_MAX   10000L

Definition at line 42 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CATCHSTACK_GROW_STEP

#define DUK_CATCHSTACK_GROW_STEP   4 /* roughly 64 bytes */

Definition at line 38 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CATCHSTACK_INITIAL_SIZE

#define DUK_CATCHSTACK_INITIAL_SIZE   4

Definition at line 41 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CATCHSTACK_SHRINK_SPARE

#define DUK_CATCHSTACK_SHRINK_SPARE   4 /* roughly 64 bytes */

Definition at line 40 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_CATCHSTACK_SHRINK_THRESHOLD

#define DUK_CATCHSTACK_SHRINK_THRESHOLD   8 /* roughly 128 bytes */

Definition at line 39 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_HTHREAD_GET_CURRENT_ACTIVATION

#define DUK_HTHREAD_GET_CURRENT_ACTIVATION ( thr)    (&(thr)->callstack[(thr)->callstack_top - 1])

Definition at line 134 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_HTHREAD_GET_STRING

#define DUK_HTHREAD_GET_STRING ( thr,
idx )    ((thr)->strs[(idx)])

Definition at line 129 of file duktape-1.8.0/src-separate/duk_hthread.h.

129#define DUK_HTHREAD_GET_STRING(thr,idx) \
130 ((duk_hstring *) DUK_USE_HEAPPTR_DEC16((thr)->heap->heap_udata, (thr)->strs16[(idx)]))

◆ DUK_HTHREAD_STATE_INACTIVE

#define DUK_HTHREAD_STATE_INACTIVE   1 /* thread not currently running */

Definition at line 137 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_HTHREAD_STATE_RESUMED

#define DUK_HTHREAD_STATE_RESUMED   3 /* thread resumed another thread (active but not running) */

Definition at line 139 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_HTHREAD_STATE_RUNNING

#define DUK_HTHREAD_STATE_RUNNING   2 /* thread currently running (only one at a time) */

Definition at line 138 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_HTHREAD_STATE_TERMINATED

#define DUK_HTHREAD_STATE_TERMINATED   5 /* thread has terminated */

Definition at line 141 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_HTHREAD_STATE_YIELDED

#define DUK_HTHREAD_STATE_YIELDED   4 /* thread has yielded */

Definition at line 140 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_TB_FLAG_NOBLAME_FILELINE

#define DUK_TB_FLAG_NOBLAME_FILELINE   (1 << 0) /* don't report __FILE__ / __LINE__ as fileName/lineNumber */

Definition at line 61 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_VALSTACK_API_ENTRY_MINIMUM

#define DUK_VALSTACK_API_ENTRY_MINIMUM   DUK_API_ENTRY_STACK

Definition at line 20 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_VALSTACK_DEFAULT_MAX

#define DUK_VALSTACK_DEFAULT_MAX   1000000L

Definition at line 30 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_VALSTACK_GROW_STEP

#define DUK_VALSTACK_GROW_STEP   128 /* roughly 1 kiB */

Definition at line 15 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_VALSTACK_INITIAL_SIZE

#define DUK_VALSTACK_INITIAL_SIZE   128 /* roughly 1.0 kiB -> but rounds up to DUK_VALSTACK_GROW_STEP in practice */

Definition at line 18 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_VALSTACK_INTERNAL_EXTRA

#define DUK_VALSTACK_INTERNAL_EXTRA
Value:
64 /* internal extra elements assumed on function entry,
* always added to user-defined 'extra' for e.g. the
* duk_check_stack() call.
*/

Definition at line 19 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_VALSTACK_SHRINK_SPARE

#define DUK_VALSTACK_SHRINK_SPARE   64 /* roughly 0.5 kiB */

Definition at line 17 of file duktape-1.8.0/src-separate/duk_hthread.h.

◆ DUK_VALSTACK_SHRINK_THRESHOLD

#define DUK_VALSTACK_SHRINK_THRESHOLD   256 /* roughly 2 kiB */

Definition at line 16 of file duktape-1.8.0/src-separate/duk_hthread.h.

Function Documentation

◆ duk_hthread_callstack_grow()

DUK_INTERNAL_DECL void duk_hthread_callstack_grow ( duk_hthread * thr)

Definition at line 54177 of file duktape-1.5.2/src-noline/duktape.c.

54180 : This should be probably reworked so that there is a shared
54181 * unwind primitive which handles all stacks as requested, and knows
54182 * the proper order for unwinding.)
54183 *
54184 * Valstack entries above 'top' are always kept initialized to
54185 * "undefined unused". Callstack and catchstack entries above 'top'
54186 * are not zeroed and are left as garbage.
54187 *
54188 * Value stack handling is mostly a part of the API implementation.
54189 */
54190
54191/* include removed: duk_internal.h */
54192
54193/* check that there is space for at least one new entry */
54195 duk_activation *new_ptr;
54196 duk_size_t old_size;
54197 duk_size_t new_size;
54198
54199 DUK_ASSERT(thr != NULL);
54200 DUK_ASSERT_DISABLE(thr->callstack_top >= 0); /* avoid warning (unsigned) */
54202
54203 if (thr->callstack_top < thr->callstack_size) {
54204 return;
54205 }
54206
54207 old_size = thr->callstack_size;
54208 new_size = old_size + DUK_CALLSTACK_GROW_STEP;
54209
54210 /* this is a bit approximate (errors out before max is reached); this is OK */
54211 if (new_size >= thr->callstack_max) {
54213 }
54214
54215 DUK_DD(DUK_DDPRINT("growing callstack %ld -> %ld", (long) old_size, (long) new_size));
DUK_INTERNAL_DECL void duk_hthread_callstack_grow(duk_hthread *thr)
#define DUK_ERROR_RANGE(thr, msg)
#define DUK_ASSERT_DISABLE(x)
#define DUK_STR_CALLSTACK_LIMIT
#define DUK_CALLSTACK_GROW_STEP
lu_byte left

References duk_hthread::callstack, duk_hthread::callstack_max, duk_hthread::callstack_size, duk_hthread::callstack_top, DUK_ASSERT, DUK_ASSERT_DISABLE, DUK_CALLSTACK_GROW_STEP, DUK_DD, DUK_DDPRINT, DUK_ERROR_ALLOC_DEFMSG, DUK_ERROR_RANGE, duk_hthread_get_callstack_ptr(), DUK_REALLOC_INDIRECT, DUK_STR_CALLSTACK_LIMIT, duk_hthread::heap, and NULL.

Referenced by duk__handle_call_inner(), and duk_handle_ecma_call_setup().

◆ duk_hthread_callstack_shrink_check()

DUK_INTERNAL_DECL void duk_hthread_callstack_shrink_check ( duk_hthread * thr)

Definition at line 54217 of file duktape-1.5.2/src-noline/duktape.c.

54224 {
54225 /* No need for a NULL/zero-size check because new_size > 0) */
54227 }
54228 thr->callstack = new_ptr;
54229 thr->callstack_size = new_size;
54230
54231 /* note: any entries above the callstack top are garbage and not zeroed */
54232}
54233
54235 duk_size_t new_size;
54236 duk_activation *p;
54237
54238 DUK_ASSERT(thr != NULL);
54239 DUK_ASSERT_DISABLE(thr->callstack_top >= 0); /* avoid warning (unsigned) */
54241
54243 return;
54244 }
54245
54246 new_size = thr->callstack_top + DUK_CALLSTACK_SHRINK_SPARE;
54247 DUK_ASSERT(new_size >= thr->callstack_top);
54248
54249 DUK_DD(DUK_DDPRINT("shrinking callstack %ld -> %ld", (long) thr->callstack_size, (long) new_size));
54250
54251 /*
54252 * Note: must use indirect variant of DUK_REALLOC() because underlying
54253 * pointer may be changed by mark-and-sweep.
#define DUK_CALLSTACK_SHRINK_THRESHOLD
#define DUK_CALLSTACK_SHRINK_SPARE
#define DUK_ERROR_ALLOC_DEFMSG(thr)
DUK_INTERNAL_DECL void duk_hthread_callstack_shrink_check(duk_hthread *thr)

References duk_hthread::callstack, duk_hthread::callstack_size, duk_hthread::callstack_top, DUK_ASSERT, DUK_ASSERT_DISABLE, DUK_CALLSTACK_SHRINK_SPARE, DUK_CALLSTACK_SHRINK_THRESHOLD, DUK_D, DUK_DD, DUK_DDPRINT, DUK_DPRINT, duk_hthread_get_callstack_ptr(), DUK_REALLOC_INDIRECT, duk_hthread::heap, and NULL.

Referenced by duk__handle_call_error(), duk__handle_call_inner(), and duk__handle_safe_call_error().

◆ duk_hthread_callstack_unwind()

DUK_INTERNAL_DECL void duk_hthread_callstack_unwind ( duk_hthread * thr,
duk_size_t new_top )

Definition at line 54255 of file duktape-1.5.2/src-noline/duktape.c.

54258 {
54259 thr->callstack = p;
54260 thr->callstack_size = new_size;
54261 } else {
54262 /* Because new_size != 0, if condition doesn't need to be
54263 * (p != NULL || new_size == 0).
54264 */
54265 DUK_ASSERT(new_size != 0);
54266 DUK_D(DUK_DPRINT("callstack shrink failed, ignoring"));
54267 }
54268
54269 /* note: any entries above the callstack top are garbage and not zeroed */
54270}
54271
54273 duk_size_t idx;
54274
54275 DUK_DDD(DUK_DDDPRINT("unwind callstack top of thread %p from %ld to %ld",
54276 (void *) thr,
54277 (thr != NULL ? (long) thr->callstack_top : (long) -1),
54278 (long) new_top));
54279
54280 DUK_ASSERT(thr);
54281 DUK_ASSERT(thr->heap);
54282 DUK_ASSERT_DISABLE(new_top >= 0); /* unsigned */
54283 DUK_ASSERT((duk_size_t) new_top <= thr->callstack_top); /* cannot grow */
54284
54285 /*
54286 * The loop below must avoid issues with potential callstack
54287 * reallocations. A resize (and other side effects) may happen
54288 * e.g. due to finalizer/errhandler calls caused by a refzero or
54289 * mark-and-sweep. Arbitrary finalizers may run, because when
54290 * an environment record is refzero'd, it may refer to arbitrary
54291 * values which also become refzero'd.
54292 *
54293 * So, the pointer 'p' is re-looked-up below whenever a side effect
54294 * might have changed it.
54295 */
54296
54297 idx = thr->callstack_top;
54298 while (idx > new_top) {
54299 duk_activation *act;
54300 duk_hobject *func;
54301#ifdef DUK_USE_REFERENCE_COUNTING
54302 duk_hobject *tmp;
54303#endif
54304#ifdef DUK_USE_DEBUGGER_SUPPORT
54305 duk_heap *heap;
54306#endif
54307
54308 idx--;
54309 DUK_ASSERT_DISABLE(idx >= 0); /* unsigned */
54310 DUK_ASSERT((duk_size_t) idx < thr->callstack_size); /* true, despite side effect resizes */
54311
54312 act = thr->callstack + idx;
54313 /* With lightfuncs, act 'func' may be NULL */
54314
54315#ifdef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY
54316 /*
54317 * Restore 'caller' property for non-strict callee functions.
54318 */
54319
54320 func = DUK_ACT_GET_FUNC(act);
54321 if (func != NULL && !DUK_HOBJECT_HAS_STRICT(func)) {
54322 duk_tval *tv_caller;
54323 duk_tval tv_tmp;
54324 duk_hobject *h_tmp;
54325
54327
54328 /* The act->prev_caller should only be set if the entry for 'caller'
54329 * exists (as it is only set in that case, and the property is not
54330 * configurable), but handle all the cases anyway.
54331 */
54332
54333 if (tv_caller) {
54334 DUK_TVAL_SET_TVAL(&tv_tmp, tv_caller);
54335 if (act->prev_caller) {
54336 /* Just transfer the refcount from act->prev_caller to tv_caller,
54337 * so no need for a refcount update. This is the expected case.
54338 */
54339 DUK_TVAL_SET_OBJECT(tv_caller, act->prev_caller);
54340 act->prev_caller = NULL;
54341 } else {
54342 DUK_TVAL_SET_NULL(tv_caller); /* no incref needed */
54343 DUK_ASSERT(act->prev_caller == NULL);
54344 }
54345 DUK_TVAL_DECREF(thr, &tv_tmp); /* side effects */
54346 } else {
54347 h_tmp = act->prev_caller;
54348 if (h_tmp) {
54349 act->prev_caller = NULL;
54350 DUK_HOBJECT_DECREF(thr, h_tmp); /* side effects */
54351 }
54352 }
54353 act = thr->callstack + idx; /* avoid side effects */
54354 DUK_ASSERT(act->prev_caller == NULL);
54355 }
54356#endif
54357
54358 /*
54359 * Unwind debugger state. If we unwind while stepping
54360 * (either step over or step into), pause execution.
54361 */
54362
54363#if defined(DUK_USE_DEBUGGER_SUPPORT)
54364 heap = thr->heap;
54365 if (heap->dbg_step_thread == thr &&
54366 heap->dbg_step_csindex == idx) {
54367 /* Pause for all step types: step into, step over, step out.
54368 * This is the only place explicitly handling a step out.
54369 */
54370 DUK_HEAP_SET_PAUSED(heap);
54371 DUK_ASSERT(heap->dbg_step_thread == NULL);
54372 }
54373#endif
54374
54375 /*
54376 * Close environment record(s) if they exist.
54377 *
54378 * Only variable environments are closed. If lex_env != var_env, it
54379 * cannot currently contain any register bound declarations.
54380 *
54381 * Only environments created for a NEWENV function are closed. If an
54382 * environment is created for e.g. an eval call, it must not be closed.
54383 */
54384
54385 func = DUK_ACT_GET_FUNC(act);
54386 if (func != NULL && !DUK_HOBJECT_HAS_NEWENV(func)) {
54387 DUK_DDD(DUK_DDDPRINT("skip closing environments, envs not owned by this activation"));
54388 goto skip_env_close;
54389 }
54390 /* func is NULL for lightfunc */
54391
54392 DUK_ASSERT(act->lex_env == act->var_env);
54393 if (act->var_env != NULL) {
54394 DUK_DDD(DUK_DDDPRINT("closing var_env record %p -> %!O",
54395 (void *) act->var_env, (duk_heaphdr *) act->var_env));
54396 duk_js_close_environment_record(thr, act->var_env, func, act->idx_bottom);
54397 act = thr->callstack + idx; /* avoid side effect issues */
54398 }
54399
54400#if 0
54401 if (act->lex_env != NULL) {
54402 if (act->lex_env == act->var_env) {
54403 /* common case, already closed, so skip */
54404 DUK_DD(DUK_DDPRINT("lex_env and var_env are the same and lex_env "
54405 "already closed -> skip closing lex_env"));
54406 ;
54407 } else {
54408 DUK_DD(DUK_DDPRINT("closing lex_env record %p -> %!O",
54409 (void *) act->lex_env, (duk_heaphdr *) act->lex_env));
54411 act = thr->callstack + idx; /* avoid side effect issues */
54412 }
54413 }
54414#endif
54415
54416 DUK_ASSERT((act->lex_env == NULL) ||
54421
54422 DUK_ASSERT((act->var_env == NULL) ||
54427
54428 skip_env_close:
54429
54430 /*
54431 * Update preventcount
54432 */
54433
54434 if (act->flags & DUK_ACT_FLAG_PREVENT_YIELD) {
54435 DUK_ASSERT(thr->callstack_preventcount >= 1);
54436 thr->callstack_preventcount--;
54437 }
54438
54439 /*
54440 * Reference count updates
54441 *
54442 * Note: careful manipulation of refcounts. The top is
54443 * not updated yet, so all the activations are reachable
54444 * for mark-and-sweep (which may be triggered by decref).
54445 * However, the pointers are NULL so this is not an issue.
54446 */
54447
54448#ifdef DUK_USE_REFERENCE_COUNTING
54449 tmp = act->var_env;
54450#endif
54451 act->var_env = NULL;
54452#ifdef DUK_USE_REFERENCE_COUNTING
54454 act = thr->callstack + idx; /* avoid side effect issues */
54455#endif
54456
54457#ifdef DUK_USE_REFERENCE_COUNTING
54458 tmp = act->lex_env;
54459#endif
54460 act->lex_env = NULL;
54461#ifdef DUK_USE_REFERENCE_COUNTING
54463 act = thr->callstack + idx; /* avoid side effect issues */
54464#endif
54465
54466 /* Note: this may cause a corner case situation where a finalizer
54467 * may see a currently reachable activation whose 'func' is NULL.
54468 */
54469#ifdef DUK_USE_REFERENCE_COUNTING
54470 tmp = DUK_ACT_GET_FUNC(act);
54471#endif
54472 act->func = NULL;
54473#ifdef DUK_USE_REFERENCE_COUNTING
54475 act = thr->callstack + idx; /* avoid side effect issues */
54476 DUK_UNREF(act);
54477#endif
54478 }
54479
54480 thr->callstack_top = new_top;
#define DUK_TVAL_DECREF(thr, tv)
#define DUK_TVAL_SET_TVAL(v, x)
#define DUK_ACT_FLAG_PREVENT_YIELD
#define DUK_HOBJECT_DECREF_ALLOWNULL(thr, h)
#define DUK_TVAL_SET_NULL(tv)
#define DUK_TVAL_SET_OBJECT(tv, hptr)
#define DUK_HTHREAD_STRING_INT_REGBASE(thr)
#define DUK_HTHREAD_STRING_INT_THREAD(thr)
#define DUK_HTHREAD_STRING_INT_VARMAP(thr)
DUK_INTERNAL_DECL duk_tval * duk_hobject_find_existing_entry_tval_ptr(duk_heap *heap, duk_hobject *obj, duk_hstring *key)
DUK_INTERNAL_DECL void duk_hthread_callstack_unwind(duk_hthread *thr, duk_size_t new_top)
#define DUK_HOBJECT_DECREF(thr, h)
#define DUK_HTHREAD_STRING_INT_CALLEE(thr)
#define DUK_HOBJECT_HAS_NEWENV(h)
#define DUK_ACT_GET_FUNC(act)
DUK_INTERNAL_DECL void duk_js_close_environment_record(duk_hthread *thr, duk_hobject *env, duk_hobject *func, duk_size_t regbase)
#define DUK_HOBJECT_HAS_STRICT(h)
#define DUK_HTHREAD_STRING_CALLER(thr)

References duk_hthread::callstack, duk_hthread::callstack_preventcount, duk_hthread::callstack_size, duk_hthread::callstack_top, DUK_ACT_FLAG_PREVENT_YIELD, DUK_ACT_GET_FUNC, DUK_ASSERT, DUK_ASSERT_DISABLE, DUK_DD, DUK_DDD, DUK_DDDPRINT, DUK_DDPRINT, DUK_HOBJECT_DECREF, DUK_HOBJECT_DECREF_ALLOWNULL, duk_hobject_find_existing_entry_tval_ptr(), DUK_HOBJECT_HAS_NEWENV, DUK_HOBJECT_HAS_STRICT, DUK_HTHREAD_STRING_CALLER, DUK_HTHREAD_STRING_INT_CALLEE, DUK_HTHREAD_STRING_INT_REGBASE, DUK_HTHREAD_STRING_INT_THREAD, DUK_HTHREAD_STRING_INT_VARMAP, duk_js_close_environment_record(), DUK_TVAL_DECREF, DUK_TVAL_SET_NULL, DUK_TVAL_SET_OBJECT, DUK_TVAL_SET_TVAL, DUK_UNREF, duk_activation::flags, duk_activation::func, duk_hthread::heap, duk_activation::idx_bottom, duk_activation::idx_retval, duk_activation::lex_env, NULL, and duk_activation::var_env.

Referenced by duk__handle_call_error(), duk__handle_call_inner(), duk__handle_catch(), duk__handle_finally(), duk__handle_longjmp(), duk__handle_return(), duk__handle_safe_call_error(), duk__handle_yield(), duk_handle_ecma_call_setup(), and duk_hthread_terminate().

◆ duk_hthread_catchstack_grow()

DUK_INTERNAL_DECL void duk_hthread_catchstack_grow ( duk_hthread * thr)

Definition at line 54482 of file duktape-1.5.2/src-noline/duktape.c.

54487 {
54488 duk_activation *act = thr->callstack + thr->callstack_top - 1;
54489 act->idx_retval = 0;
54490 }
54491#endif
54492
54493 /* Note: any entries above the callstack top are garbage and not zeroed.
54494 * Also topmost activation idx_retval is garbage (not zeroed), and must
54495 * be ignored.
54496 */
54497}
54498
54500 duk_catcher *new_ptr;
54501 duk_size_t old_size;
54502 duk_size_t new_size;
54503
54504 DUK_ASSERT(thr != NULL);
54505 DUK_ASSERT_DISABLE(thr->catchstack_top); /* avoid warning (unsigned) */
54507
54508 if (thr->catchstack_top < thr->catchstack_size) {
54509 return;
54510 }
54511
54512 old_size = thr->catchstack_size;
54513 new_size = old_size + DUK_CATCHSTACK_GROW_STEP;
54514
54515 /* this is a bit approximate (errors out before max is reached); this is OK */
54516 if (new_size >= thr->catchstack_max) {
54518 }
54519
54520 DUK_DD(DUK_DDPRINT("growing catchstack %ld -> %ld", (long) old_size, (long) new_size));
#define DUK_STR_CATCHSTACK_LIMIT
#define DUK_CATCHSTACK_GROW_STEP
DUK_INTERNAL_DECL void duk_hthread_catchstack_grow(duk_hthread *thr)

References duk_hthread::catchstack, duk_hthread::catchstack_max, duk_hthread::catchstack_size, duk_hthread::catchstack_top, DUK_ASSERT, DUK_ASSERT_DISABLE, DUK_CATCHSTACK_GROW_STEP, DUK_DD, DUK_DDPRINT, DUK_ERROR_ALLOC_DEFMSG, DUK_ERROR_RANGE, duk_hthread_get_catchstack_ptr(), DUK_REALLOC_INDIRECT, DUK_STR_CATCHSTACK_LIMIT, duk_hthread::heap, duk_activation::idx_retval, and NULL.

Referenced by duk__js_execute_bytecode_inner().

◆ duk_hthread_catchstack_shrink_check()

DUK_INTERNAL_DECL void duk_hthread_catchstack_shrink_check ( duk_hthread * thr)

Definition at line 54522 of file duktape-1.5.2/src-noline/duktape.c.

54529 {
54530 /* No need for a NULL/zero-size check because new_size > 0) */
54532 }
54533 thr->catchstack = new_ptr;
54534 thr->catchstack_size = new_size;
54535
54536 /* note: any entries above the catchstack top are garbage and not zeroed */
54537}
54538
54540 duk_size_t new_size;
54541 duk_catcher *p;
54542
54543 DUK_ASSERT(thr != NULL);
54544 DUK_ASSERT_DISABLE(thr->catchstack_top >= 0); /* avoid warning (unsigned) */
54546
54548 return;
54549 }
54550
54552 DUK_ASSERT(new_size >= thr->catchstack_top);
54553
54554 DUK_DD(DUK_DDPRINT("shrinking catchstack %ld -> %ld", (long) thr->catchstack_size, (long) new_size));
54555
54556 /*
54557 * Note: must use indirect variant of DUK_REALLOC() because underlying
54558 * pointer may be changed by mark-and-sweep.
DUK_INTERNAL_DECL void duk_hthread_catchstack_shrink_check(duk_hthread *thr)
#define DUK_CATCHSTACK_SHRINK_THRESHOLD
#define DUK_CATCHSTACK_SHRINK_SPARE

References duk_hthread::catchstack, duk_hthread::catchstack_size, duk_hthread::catchstack_top, DUK_ASSERT, DUK_ASSERT_DISABLE, DUK_CATCHSTACK_SHRINK_SPARE, DUK_CATCHSTACK_SHRINK_THRESHOLD, DUK_D, DUK_DD, DUK_DDPRINT, DUK_DPRINT, duk_hthread_get_catchstack_ptr(), DUK_REALLOC_INDIRECT, duk_hthread::heap, and NULL.

Referenced by duk__handle_call_error(), duk__handle_call_inner(), and duk__handle_safe_call_error().

◆ duk_hthread_catchstack_unwind()

DUK_INTERNAL_DECL void duk_hthread_catchstack_unwind ( duk_hthread * thr,
duk_size_t new_top )

Definition at line 54560 of file duktape-1.5.2/src-noline/duktape.c.

54563 {
54564 thr->catchstack = p;
54565 thr->catchstack_size = new_size;
54566 } else {
54567 /* Because new_size != 0, if condition doesn't need to be
54568 * (p != NULL || new_size == 0).
54569 */
54570 DUK_ASSERT(new_size != 0);
54571 DUK_D(DUK_DPRINT("catchstack shrink failed, ignoring"));
54572 }
54573
54574 /* note: any entries above the catchstack top are garbage and not zeroed */
54575}
54576
54578 duk_size_t idx;
54579
54580 DUK_DDD(DUK_DDDPRINT("unwind catchstack top of thread %p from %ld to %ld",
54581 (void *) thr,
54582 (thr != NULL ? (long) thr->catchstack_top : (long) -1),
54583 (long) new_top));
54584
54585 DUK_ASSERT(thr);
54586 DUK_ASSERT(thr->heap);
54587 DUK_ASSERT_DISABLE(new_top >= 0); /* unsigned */
54588 DUK_ASSERT((duk_size_t) new_top <= thr->catchstack_top); /* cannot grow */
54589
54590 /*
54591 * Since there are no references in the catcher structure,
54592 * unwinding is quite simple. The only thing we need to
54593 * look out for is popping a possible lexical environment
54594 * established for an active catch clause.
54595 */
54596
54597 idx = thr->catchstack_top;
54598 while (idx > new_top) {
54599 duk_catcher *p;
54600 duk_activation *act;
54601 duk_hobject *env;
54602
54603 idx--;
54604 DUK_ASSERT_DISABLE(idx >= 0); /* unsigned */
54605 DUK_ASSERT((duk_size_t) idx < thr->catchstack_size);
54606
54607 p = thr->catchstack + idx;
54608
54610 DUK_DDD(DUK_DDDPRINT("unwinding catchstack idx %ld, callstack idx %ld, callstack top %ld: lexical environment active",
54611 (long) idx, (long) p->callstack_index, (long) thr->callstack_top));
54612
54613 /* XXX: Here we have a nasty dependency: the need to manipulate
54614 * the callstack means that catchstack must always be unwound by
54615 * the caller before unwinding the callstack. This should be fixed
54616 * later.
54617 */
54618
54619 /* Note that multiple catchstack entries may refer to the same
54620 * callstack entry.
54621 */
54622 act = thr->callstack + p->callstack_index;
54623 DUK_ASSERT(act >= thr->callstack);
54624 DUK_ASSERT(act < thr->callstack + thr->callstack_top);
54625
54626 DUK_DDD(DUK_DDDPRINT("catchstack_index=%ld, callstack_index=%ld, lex_env=%!iO",
54627 (long) idx, (long) p->callstack_index,
DUK_INTERNAL_DECL void duk_hthread_catchstack_unwind(duk_hthread *thr, duk_size_t new_top)
#define DUK_CAT_HAS_LEXENV_ACTIVE(c)

References duk_hthread::callstack, duk_catcher::callstack_index, duk_hthread::callstack_top, duk_hthread::catchstack, duk_hthread::catchstack_size, duk_hthread::catchstack_top, DUK_ASSERT, DUK_ASSERT_DISABLE, DUK_CAT_HAS_LEXENV_ACTIVE, DUK_DDD, DUK_DDDPRINT, DUK_HOBJECT_DECREF, DUK_HOBJECT_GET_PROTOTYPE, duk_hthread::heap, duk_activation::lex_env, and NULL.

Referenced by duk__handle_call_error(), duk__handle_call_inner(), duk__handle_catch(), duk__handle_finally(), duk__handle_label(), duk__handle_longjmp(), duk__handle_return(), duk__handle_safe_call_error(), duk__js_execute_bytecode_inner(), duk_handle_ecma_call_setup(), and duk_hthread_terminate().

◆ duk_hthread_copy_builtin_objects()

DUK_INTERNAL_DECL void duk_hthread_copy_builtin_objects ( duk_hthread * thr_from,
duk_hthread * thr_to )

Definition at line 54036 of file duktape-1.5.2/src-noline/duktape.c.

54036 {
54037 DUK_DD(DUK_DDPRINT("built-in object %ld after initialization and compacting: %!@iO",
54038 (long) i, (duk_heaphdr *) duk_require_hobject(ctx, i)));
54039 }
54040#endif
54041
54042 /*
54043 * Pop built-ins from stack: they are now INCREF'd and
DUK_INTERNAL_DECL duk_hobject * duk_require_hobject(duk_context *ctx, duk_idx_t index)

References duk_hthread::builtins, DUK_DD, DUK_DDPRINT, DUK_HOBJECT_INCREF_ALLOWNULL, DUK_NUM_BUILTINS, and duk_require_hobject().

Referenced by duk_push_thread_raw().

◆ duk_hthread_create_builtin_objects()

DUK_INTERNAL_DECL void duk_hthread_create_builtin_objects ( duk_hthread * thr)

Definition at line 53417 of file duktape-1.5.2/src-noline/duktape.c.

53420 {
53423
53424 for (i = 0; i < 8; i++) {
53425 /* Encoding endianness must match target memory layout,
53426 * build scripts and genbuiltins.py must ensure this.
53427 */
53428 du.uc[i] = (duk_uint8_t) duk_bd_decode(bd, 8);
53429 }
53430
53431 duk_push_number(ctx, du.d); /* push operation normalizes NaNs */
53432}
53433
53435 duk_context *ctx = (duk_context *) thr;
53436 duk_bitdecoder_ctx bd_ctx;
53437 duk_bitdecoder_ctx *bd = &bd_ctx; /* convenience */
53438 duk_hobject *h;
53439 duk_small_uint_t i, j;
53440
53441 DUK_D(DUK_DPRINT("INITBUILTINS BEGIN: DUK_NUM_BUILTINS=%d, DUK_NUM_BUILTINS_ALL=%d", (int) DUK_NUM_BUILTINS, (int) DUK_NUM_ALL_BUILTINS));
53442
53443 DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx));
53444 bd->data = (const duk_uint8_t *) duk_builtins_data;
53445 bd->length = (duk_size_t) DUK_BUILTINS_DATA_LENGTH;
53446
53447 /*
53448 * First create all built-in bare objects on the empty valstack.
53449 *
53450 * Built-ins in the index range [0,DUK_NUM_BUILTINS-1] have value
53451 * stack indices matching their eventual thr->builtins[] index.
53452 *
53453 * Built-ins in the index range [DUK_NUM_BUILTINS,DUK_NUM_ALL_BUILTINS]
53454 * will exist on the value stack during init but won't be placed
53455 * into thr->builtins[]. These are objects referenced in some way
53456 * from thr->builtins[] roots but which don't need to be indexed by
53457 * Duktape through thr->builtins[] (e.g. user custom objects).
53458 */
53459
53461
53462 DUK_DD(DUK_DDPRINT("create empty built-ins"));
53463 DUK_ASSERT_TOP(ctx, 0);
53464 for (i = 0; i < DUK_NUM_ALL_BUILTINS; i++) {
53465 duk_small_uint_t class_num;
53466 duk_small_int_t len = -1; /* must be signed */
53467
53469 len = (duk_small_int_t) duk_bd_decode_flagged(bd, DUK__LENGTH_PROP_BITS, (duk_int32_t) -1 /*def_value*/);
53470
53471 if (class_num == DUK_HOBJECT_CLASS_FUNCTION) {
53472 duk_small_uint_t natidx;
53473 duk_int_t c_nargs; /* must hold DUK_VARARGS */
53474 duk_c_function c_func;
53475 duk_int16_t magic;
53476
53477 DUK_DDD(DUK_DDDPRINT("len=%ld", (long) len));
53478 DUK_ASSERT(len >= 0);
53479
53481 c_func = duk_bi_native_functions[natidx];
53482
53483 c_nargs = (duk_small_uint_t) duk_bd_decode_flagged(bd, DUK__NARGS_BITS, len /*def_value*/);
53484 if (c_nargs == DUK__NARGS_VARARGS_MARKER) {
53485 c_nargs = DUK_VARARGS;
53486 }
53487
53488 /* XXX: set magic directly here? (it could share the c_nargs arg) */
53489 duk_push_c_function_noexotic(ctx, c_func, c_nargs);
53490
53491 h = duk_require_hobject(ctx, -1);
53492 DUK_ASSERT(h != NULL);
53493
53494 /* Currently all built-in native functions are strict.
53495 * duk_push_c_function() now sets strict flag, so
53496 * assert for it.
53497 */
53499
53500 /* XXX: function properties */
53501
53502 /* Built-in 'name' is not writable by default. Function '.name'
53503 * is writable to allow user code to set a '.name' on a native
53504 * function.
53505 */
53508 -2,
53512
53513 /* Almost all global level Function objects are constructable
53514 * but not all: Function.prototype is a non-constructable,
53515 * callable Function.
53516 */
53517 if (duk_bd_decode_flag(bd)) {
53519 } else {
53521 }
53522
53523 /* Cast converts magic to 16-bit signed value */
53524 magic = (duk_int16_t) duk_bd_decode_flagged(bd, DUK__MAGIC_BITS, 0 /*def_value*/);
53525 ((duk_hnativefunction *) h)->magic = magic;
53526 } else {
53527 /* XXX: ARRAY_PART for Array prototype? */
53528
53531 -1); /* no prototype or class yet */
53532
53533 h = duk_require_hobject(ctx, -1);
53534 DUK_ASSERT(h != NULL);
53535 }
53536
53537 DUK_HOBJECT_SET_CLASS_NUMBER(h, class_num);
53538
53539 if (i < DUK_NUM_BUILTINS) {
53540 thr->builtins[i] = h;
53541 DUK_HOBJECT_INCREF(thr, &h->hdr);
53542 }
53543
53544 if (len >= 0) {
53545 /*
53546 * For top-level objects, 'length' property has the following
53547 * default attributes: non-writable, non-enumerable, non-configurable
53548 * (E5 Section 15).
53549 *
53550 * However, 'length' property for Array.prototype has attributes
53551 * expected of an Array instance which are different: writable,
53552 * non-enumerable, non-configurable (E5 Section 15.4.5.2).
53553 *
53554 * This is currently determined implicitly based on class; there are
53555 * no attribute flags in the init data.
53556 */
53557
53558 duk_push_int(ctx, len);
53560 -2,
53562 (class_num == DUK_HOBJECT_CLASS_ARRAY ? /* only Array.prototype matches */
53564 }
53565
53566 /* enable exotic behaviors last */
53567
53568 if (class_num == DUK_HOBJECT_CLASS_ARRAY) {
53570 }
53571 if (class_num == DUK_HOBJECT_CLASS_STRING) {
53573 }
53574
53575 /* some assertions */
53576
53578 /* DUK_HOBJECT_FLAG_CONSTRUCTABLE varies */
53581 /* DUK_HOBJECT_FLAG_NATIVEFUNCTION varies */
53583 DUK_ASSERT(!DUK_HOBJECT_HAS_ARRAY_PART(h)); /* currently, even for Array.prototype */
53584 /* DUK_HOBJECT_FLAG_STRICT varies */
53585 DUK_ASSERT(!DUK_HOBJECT_HAS_NATIVEFUNCTION(h) || /* all native functions have NEWENV */
53590 /* DUK_HOBJECT_FLAG_EXOTIC_ARRAY varies */
53591 /* DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ varies */
53593
53594 DUK_DDD(DUK_DDDPRINT("created built-in %ld, class=%ld, length=%ld", (long) i, (long) class_num, (long) len));
53595 }
53596
53597 /*
53598 * Then decode the builtins init data (see genbuiltins.py) to
53599 * init objects
53600 */
53601
53602 DUK_DD(DUK_DDPRINT("initialize built-in object properties"));
53603 for (i = 0; i < DUK_NUM_ALL_BUILTINS; i++) {
53605 duk_small_uint_t num;
53606
53607 DUK_DDD(DUK_DDDPRINT("initializing built-in object at index %ld", (long) i));
53608 h = duk_require_hobject(ctx, i);
53609 DUK_ASSERT(h != NULL);
53610
53612 if (t != DUK__NO_BIDX_MARKER) {
53613 DUK_DDD(DUK_DDDPRINT("set internal prototype: built-in %ld", (long) t));
53615 }
53616
53618 if (t != DUK__NO_BIDX_MARKER) {
53619 /* 'prototype' property for all built-in objects (which have it) has attributes:
53620 * [[Writable]] = false,
53621 * [[Enumerable]] = false,
53622 * [[Configurable]] = false
53623 */
53624 DUK_DDD(DUK_DDDPRINT("set external prototype: built-in %ld", (long) t));
53626 }
53627
53629 if (t != DUK__NO_BIDX_MARKER) {
53630 /* 'constructor' property for all built-in objects (which have it) has attributes:
53631 * [[Writable]] = true,
53632 * [[Enumerable]] = false,
53633 * [[Configurable]] = true
53634 */
53635 DUK_DDD(DUK_DDDPRINT("set external constructor: built-in %ld", (long) t));
53637 }
53638
53639 /* normal valued properties */
53641 DUK_DDD(DUK_DDDPRINT("built-in object %ld, %ld normal valued properties", (long) i, (long) num));
53642 for (j = 0; j < num; j++) {
53643 duk_small_uint_t prop_flags;
53644
53646
53647 /*
53648 * Property attribute defaults are defined in E5 Section 15 (first
53649 * few pages); there is a default for all properties and a special
53650 * default for 'length' properties. Variation from the defaults is
53651 * signaled using a single flag bit in the bitstream.
53652 */
53653
53654 if (duk_bd_decode_flag(bd)) {
53656 } else {
53657 prop_flags = DUK_PROPDESC_FLAGS_WC;
53658 }
53659
53661
53662 DUK_DDD(DUK_DDDPRINT("built-in %ld, normal-valued property %ld, key %!T, flags 0x%02lx, type %ld",
53663 (long) i, (long) j, duk_get_tval(ctx, -1), (unsigned long) prop_flags, (long) t));
53664
53665 switch (t) {
53666 case DUK__PROP_TYPE_DOUBLE: {
53667 duk__push_double(ctx, bd);
53668 break;
53669 }
53670 case DUK__PROP_TYPE_STRING: {
53671 duk__push_string(ctx, bd);
53672 break;
53673 }
53674 case DUK__PROP_TYPE_STRIDX: {
53675 duk__push_stridx(ctx, bd);
53676 break;
53677 }
53679 duk_small_uint_t bidx;
53680
53683 duk_dup(ctx, (duk_idx_t) bidx);
53684 break;
53685 }
53687 duk_push_undefined(ctx);
53688 break;
53689 }
53691 duk_push_true(ctx);
53692 break;
53693 }
53695 duk_push_false(ctx);
53696 break;
53697 }
53701 duk_c_function c_func_getter;
53702 duk_c_function c_func_setter;
53703
53704 /* XXX: this is a bit awkward because there is no exposed helper
53705 * in the API style, only this internal helper.
53706 */
53707 DUK_DDD(DUK_DDDPRINT("built-in accessor property: objidx=%ld, key=%!T, getteridx=%ld, setteridx=%ld, flags=0x%04lx",
53708 (long) i, duk_get_tval(ctx, -1), (long) natidx_getter, (long) natidx_setter, (unsigned long) prop_flags));
53709
53710 c_func_getter = duk_bi_native_functions[natidx_getter];
53711 c_func_setter = duk_bi_native_functions[natidx_setter];
53712 duk_push_c_function_noconstruct_noexotic(ctx, c_func_getter, 0); /* always 0 args */
53713 duk_push_c_function_noconstruct_noexotic(ctx, c_func_setter, 1); /* always 1 arg */
53714
53715 /* XXX: magic for getter/setter? use duk_def_prop()? */
53716
53717 DUK_ASSERT((prop_flags & DUK_PROPDESC_FLAG_WRITABLE) == 0); /* genbuiltins.py ensures */
53718
53719 prop_flags |= DUK_PROPDESC_FLAG_ACCESSOR; /* accessor flag not encoded explicitly */
53721 duk_require_hobject(ctx, i),
53722 duk_get_hstring(ctx, -3),
53723 duk_require_hobject(ctx, -2),
53724 duk_require_hobject(ctx, -1),
53725 prop_flags);
53726 duk_pop_3(ctx); /* key, getter and setter, now reachable through object */
53727 goto skip_value;
53728 }
53729 default: {
53730 /* exhaustive */
53732 }
53733 }
53734
53735 DUK_ASSERT((prop_flags & DUK_PROPDESC_FLAG_ACCESSOR) == 0);
53736 duk_xdef_prop(ctx, i, prop_flags);
53737
53738 skip_value:
53739 continue; /* avoid empty label at the end of a compound statement */
53740 }
53741
53742 /* native function properties */
53744 DUK_DDD(DUK_DDDPRINT("built-in object %ld, %ld function valued properties", (long) i, (long) num));
53745 for (j = 0; j < num; j++) {
53746 duk_hstring *h_key;
53747 duk_small_uint_t natidx;
53748 duk_int_t c_nargs; /* must hold DUK_VARARGS */
53749 duk_small_uint_t c_length;
53750 duk_int16_t magic;
53751 duk_c_function c_func;
53752 duk_hnativefunction *h_func;
53753#if defined(DUK_USE_LIGHTFUNC_BUILTINS)
53754 duk_small_int_t lightfunc_eligible;
53755#endif
53756
53758 h_key = duk_get_hstring(ctx, -1);
53759 DUK_ASSERT(h_key != NULL);
53760 DUK_UNREF(h_key);
53762
53764 c_nargs = (duk_int_t) duk_bd_decode_flagged(bd, DUK__NARGS_BITS, (duk_int32_t) c_length /*def_value*/);
53765 if (c_nargs == DUK__NARGS_VARARGS_MARKER) {
53766 c_nargs = DUK_VARARGS;
53767 }
53768
53769 c_func = duk_bi_native_functions[natidx];
53770
53771 DUK_DDD(DUK_DDDPRINT("built-in %ld, function-valued property %ld, key %!O, natidx %ld, length %ld, nargs %ld",
53772 (long) i, (long) j, (duk_heaphdr *) h_key, (long) natidx, (long) c_length,
53773 (c_nargs == DUK_VARARGS ? (long) -1 : (long) c_nargs)));
53774
53775 /* Cast converts magic to 16-bit signed value */
53776 magic = (duk_int16_t) duk_bd_decode_flagged(bd, DUK__MAGIC_BITS, 0);
53777
53778#if defined(DUK_USE_LIGHTFUNC_BUILTINS)
53779 lightfunc_eligible =
53780 ((c_nargs >= DUK_LFUNC_NARGS_MIN && c_nargs <= DUK_LFUNC_NARGS_MAX) || (c_nargs == DUK_VARARGS)) &&
53781 (c_length <= DUK_LFUNC_LENGTH_MAX) &&
53782 (magic >= DUK_LFUNC_MAGIC_MIN && magic <= DUK_LFUNC_MAGIC_MAX);
53783
53784 if (h_key == DUK_HTHREAD_STRING_EVAL(thr) ||
53785 h_key == DUK_HTHREAD_STRING_YIELD(thr) ||
53786 h_key == DUK_HTHREAD_STRING_RESUME(thr) ||
53787 h_key == DUK_HTHREAD_STRING_REQUIRE(thr)) {
53788 /* These functions have trouble working as lightfuncs.
53789 * Some of them have specific asserts and some may have
53790 * additional properties (e.g. 'require.id' may be written).
53791 */
53792 DUK_D(DUK_DPRINT("reject as lightfunc: key=%!O, i=%d, j=%d", (duk_heaphdr *) h_key, (int) i, (int) j));
53793 lightfunc_eligible = 0;
53794 }
53795
53796 if (lightfunc_eligible) {
53797 duk_tval tv_lfunc;
53798 duk_small_uint_t lf_nargs = (c_nargs == DUK_VARARGS ? DUK_LFUNC_NARGS_VARARGS : c_nargs);
53799 duk_small_uint_t lf_flags = DUK_LFUNC_FLAGS_PACK(magic, c_length, lf_nargs);
53800 DUK_TVAL_SET_LIGHTFUNC(&tv_lfunc, c_func, lf_flags);
53801 duk_push_tval(ctx, &tv_lfunc);
53802 DUK_D(DUK_DPRINT("built-in function eligible as light function: i=%d, j=%d c_length=%ld, c_nargs=%ld, magic=%ld -> %!iT", (int) i, (int) j, (long) c_length, (long) c_nargs, (long) magic, duk_get_tval(ctx, -1)));
53803 goto lightfunc_skip;
53804 }
53805
53806 DUK_D(DUK_DPRINT("built-in function NOT ELIGIBLE as light function: i=%d, j=%d c_length=%ld, c_nargs=%ld, magic=%ld", (int) i, (int) j, (long) c_length, (long) c_nargs, (long) magic));
53807#endif /* DUK_USE_LIGHTFUNC_BUILTINS */
53808
53809 /* [ (builtin objects) name ] */
53810
53811 duk_push_c_function_noconstruct_noexotic(ctx, c_func, c_nargs);
53812 h_func = duk_require_hnativefunction(ctx, -1);
53813 DUK_UNREF(h_func);
53814
53815 /* Currently all built-in native functions are strict.
53816 * This doesn't matter for many functions, but e.g.
53817 * String.prototype.charAt (and other string functions)
53818 * rely on being strict so that their 'this' binding is
53819 * not automatically coerced.
53820 */
53822
53823 /* No built-in functions are constructable except the top
53824 * level ones (Number, etc).
53825 */
53827
53828 /* XXX: any way to avoid decoding magic bit; there are quite
53829 * many function properties and relatively few with magic values.
53830 */
53831 h_func->magic = magic;
53832
53833 /* [ (builtin objects) name func ] */
53834
53835 duk_push_int(ctx, c_length);
53837
53838 duk_dup(ctx, -2);
53840
53841 /* XXX: other properties of function instances; 'arguments', 'caller'. */
53842
53843 DUK_DD(DUK_DDPRINT("built-in object %ld, function property %ld -> %!T",
53844 (long) i, (long) j, (duk_tval *) duk_get_tval(ctx, -1)));
53845
53846 /* [ (builtin objects) name func ] */
53847
53848 /*
53849 * The default property attributes are correct for all
53850 * function valued properties of built-in objects now.
53851 */
53852
53853#if defined(DUK_USE_LIGHTFUNC_BUILTINS)
53854 lightfunc_skip:
53855#endif
53856
53858
53859 /* [ (builtin objects) ] */
53860 }
53861 }
53862
53863 /*
53864 * Special post-tweaks, for cases not covered by the init data format.
53865 *
53866 * - Set Date.prototype.toGMTString to Date.prototype.toUTCString.
53867 * toGMTString is required to have the same Function object as
53868 * toUTCString in E5 Section B.2.6. Note that while Smjs respects
53869 * this, V8 does not (the Function objects are distinct).
53870 *
53871 * - Make DoubleError non-extensible.
53872 *
53873 * - Add info about most important effective compile options to Duktape.
53874 *
53875 * - Possibly remove some properties (values or methods) which are not
53876 * desirable with current feature options but are not currently
53877 * conditional in init data.
53878 */
53879
53882
53884 DUK_ASSERT(h != NULL);
53886
53887#if !defined(DUK_USE_ES6_OBJECT_PROTO_PROPERTY)
53888 DUK_DD(DUK_DDPRINT("delete Object.prototype.__proto__ built-in which is not enabled in features"));
53890#endif
53891
53892#if !defined(DUK_USE_ES6_OBJECT_SETPROTOTYPEOF)
53893 DUK_DD(DUK_DDPRINT("delete Object.setPrototypeOf built-in which is not enabled in features"));
53895#endif
53896
53897 /* XXX: relocate */
53898 duk_push_string(ctx,
53899 /* Endianness indicator */
53900#if defined(DUK_USE_INTEGER_LE)
53901 "l"
53902#elif defined(DUK_USE_INTEGER_BE)
53903 "b"
53904#elif defined(DUK_USE_INTEGER_ME) /* integer mixed endian not really used now */
53905 "m"
53906#else
53907 "?"
53908#endif
53909#if defined(DUK_USE_DOUBLE_LE)
53910 "l"
53911#elif defined(DUK_USE_DOUBLE_BE)
53912 "b"
53913#elif defined(DUK_USE_DOUBLE_ME)
53914 "m"
53915#else
53916 "?"
53917#endif
53918 " "
53919 /* Packed or unpacked tval */
53920#if defined(DUK_USE_PACKED_TVAL)
53921 "p"
53922#else
53923 "u"
53924#endif
53925#if defined(DUK_USE_FASTINT)
53926 "f"
53927#endif
53928 " "
53929 /* Low memory options */
53930#if defined(DUK_USE_STRTAB_CHAIN)
53931 "c" /* chain */
53932#elif defined(DUK_USE_STRTAB_PROBE)
53933 "p" /* probe */
53934#else
53935 "?"
53936#endif
53937#if !defined(DUK_USE_HEAPPTR16) && !defined(DUK_DATAPTR16) && !defined(DUK_FUNCPTR16)
53938 "n"
53939#endif
53940#if defined(DUK_USE_HEAPPTR16)
53941 "h"
53942#endif
53943#if defined(DUK_USE_DATAPTR16)
53944 "d"
53945#endif
53946#if defined(DUK_USE_FUNCPTR16)
53947 "f"
53948#endif
53949#if defined(DUK_USE_REFCOUNT16)
53950 "R"
53951#endif
53952#if defined(DUK_USE_STRHASH16)
53953 "H"
53954#endif
53955#if defined(DUK_USE_STRLEN16)
53956 "S"
53957#endif
53958#if defined(DUK_USE_BUFLEN16)
53959 "B"
53960#endif
53961#if defined(DUK_USE_OBJSIZES16)
53962 "O"
53963#endif
53964#if defined(DUK_USE_LIGHTFUNC_BUILTINS)
53965 "L"
53966#endif
53967#if defined(DUK_USE_ROM_STRINGS) || defined(DUK_USE_ROM_OBJECTS)
53968 /* XXX: This won't be shown in practice now
53969 * because this code is not run when builtins
53970 * are in ROM.
53971 */
53972 "Z"
53973#endif
53974 " "
53975 /* Object property allocation layout */
53976#if defined(DUK_USE_HOBJECT_LAYOUT_1)
53977 "p1"
53978#elif defined(DUK_USE_HOBJECT_LAYOUT_2)
53979 "p2"
53980#elif defined(DUK_USE_HOBJECT_LAYOUT_3)
53981 "p3"
53982#else
53983 "p?"
53984#endif
53985 " "
53986 /* Alignment guarantee */
53987#if (DUK_USE_ALIGN_BY == 4)
53988 "a4"
53989#elif (DUK_USE_ALIGN_BY == 8)
53990 "a8"
53991#elif (DUK_USE_ALIGN_BY == 1)
53992 "a1"
53993#else
53994#error invalid DUK_USE_ALIGN_BY
53995#endif
53996 " "
53997 /* Architecture, OS, and compiler strings */
53999 " "
54001 " "
54004
54005 /*
54006 * InitJS code - Ecmascript code evaluated from a built-in source
54007 * which provides e.g. backward compatibility. User can also provide
54008 * JS code to be evaluated at startup.
54009 */
54010
54011#ifdef DUK_USE_BUILTIN_INITJS
54012 /* XXX: compression */
54013 DUK_DD(DUK_DDPRINT("running built-in initjs"));
54014 duk_eval_string(ctx, (const char *) duk_initjs_data); /* initjs data is NUL terminated */
54015 duk_pop(ctx);
54016#endif /* DUK_USE_BUILTIN_INITJS */
54017
54018#ifdef DUK_USE_USER_INITJS
54019 /* XXX: compression (as an option) */
54020 DUK_DD(DUK_DDPRINT("running user initjs"));
54021 duk_eval_string_noresult(ctx, (const char *) DUK_USE_USER_INITJS);
54022#endif /* DUK_USE_USER_INITJS */
54023
54024 /*
54025 * Since built-ins are not often extended, compact them.
54026 */
54027
54028 DUK_DD(DUK_DDPRINT("compact built-ins"));
54029 for (i = 0; i < DUK_NUM_ALL_BUILTINS; i++) {
54031 }
54032
54033 DUK_D(DUK_DPRINT("INITBUILTINS END"));
unsigned int duk_small_uint_t
duk_int_fast32_t duk_int_t
#define DUK_MEMZERO(p, n)
DUK_INTERNAL_DECL void duk_push_c_function_noexotic(duk_context *ctx, duk_c_function func, duk_int_t nargs)
DUK_INTERNAL_DECL duk_small_int_t duk_bd_decode_flag(duk_bitdecoder_ctx *ctx)
DUK_EXTERNAL const char * duk_push_string(duk_context *ctx, const char *str)
#define DUK__NARGS_VARARGS_MARKER
#define DUK_HOBJECT_HAS_BOUND(h)
DUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx)
DUK_EXTERNAL void duk_push_true(duk_context *ctx)
DUK_INTERNAL const duk_uint8_t duk_initjs_data[204]
#define DUK_STRIDX_TO_UTC_STRING
#define DUK_LFUNC_NARGS_MAX
#define DUK_DELPROP_FLAG_THROW
#define DUK_HOBJECT_SET_EXOTIC_STRINGOBJ(h)
#define DUK_BIDX_OBJECT_PROTOTYPE
DUK_INTERNAL_DECL void duk_xdef_prop_stridx_builtin(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_int_t builtin_idx, duk_small_uint_t desc_flags)
#define DUK_BIDX_DOUBLE_ERROR
DUK_INTERNAL_DECL void duk_push_c_function_noconstruct_noexotic(duk_context *ctx, duk_c_function func, duk_int_t nargs)
#define DUK__NUM_FUNC_PROPS_BITS
#define DUK_LFUNC_LENGTH_MAX
#define DUK_STRIDX_TO_GMT_STRING
#define DUK_HOBJECT_HAS_CREATEARGS(h)
#define DUK_BIDX_FUNCTION_PROTOTYPE
#define DUK_PROPDESC_FLAGS_NONE
#define DUK_HTHREAD_STRING___PROTO__(thr)
#define DUK_HOBJECT_CLASS_FUNCTION
DUK_EXTERNAL void duk_require_stack(duk_context *ctx, duk_idx_t extra)
DUK_INTERNAL_DECL void duk_hobject_define_accessor_internal(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_hobject *getter, duk_hobject *setter, duk_small_uint_t propflags)
#define DUK_HOBJECT_CLASS_ARRAY
#define DUK_STRIDX_CONSTRUCTOR
#define DUK_PROPDESC_FLAG_ACCESSOR
#define DUK_HOBJECT_HAS_CONSTRUCTABLE(h)
DUK_INTERNAL_DECL void duk_hthread_create_builtin_objects(duk_hthread *thr)
#define DUK__PROP_TYPE_ACCESSOR
#define DUK_HTHREAD_STRING_YIELD(thr)
#define DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h, p)
DUK_INTERNAL_DECL void duk_hobject_compact_props(duk_hthread *thr, duk_hobject *obj)
#define DUK_HOBJECT_SET_EXOTIC_ARRAY(h)
DUK_EXTERNAL void duk_push_int(duk_context *ctx, duk_int_t val)
DUK_EXTERNAL void duk_pop_3(duk_context *ctx)
#define DUK_LFUNC_MAGIC_MIN
DUK_INTERNAL const duk_c_function duk_bi_native_functions[149]
#define DUK_HOBJECT_SET_STRICT(h)
#define DUK_LFUNC_NARGS_VARARGS
DUK_INTERNAL_DECL duk_int32_t duk_bd_decode_flagged(duk_bitdecoder_ctx *ctx, duk_small_int_t bits, duk_int32_t def_value)
DUK_LOCAL void duk__push_stridx(duk_context *ctx, duk_bitdecoder_ctx *bd)
#define DUK_HTHREAD_STRING_RESUME(thr)
#define DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(h)
DUK_INTERNAL_DECL duk_bool_t duk_hobject_delprop_raw(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_small_uint_t flags)
#define DUK_HOBJECT_HAS_ARRAY_PART(h)
#define DUK_LFUNC_FLAGS_PACK(magic, length, nargs)
DUK_LOCAL void duk__push_string(duk_context *ctx, duk_bitdecoder_ctx *bd)
DUK_EXTERNAL void duk_dup(duk_context *ctx, duk_idx_t from_index)
#define DUK_HTHREAD_STRING_EVAL(thr)
DUK_INTERNAL_DECL void duk_push_tval(duk_context *ctx, duk_tval *tv)
#define DUK_HOBJECT_HAS_NATIVEFUNCTION(h)
#define DUK_HOBJECT_HAS_THREAD(h)
DUK_EXTERNAL void duk_push_undefined(duk_context *ctx)
DUK_LOCAL void duk__push_stridx_or_string(duk_context *ctx, duk_bitdecoder_ctx *bd)
#define DUK_HTHREAD_STRING_REQUIRE(thr)
#define DUK_PROPDESC_FLAGS_WC
DUK_LOCAL void duk__push_double(duk_context *ctx, duk_bitdecoder_ctx *bd)
#define DUK_PROPDESC_FLAG_WRITABLE
DUK_EXTERNAL void duk_push_number(duk_context *ctx, duk_double_t val)
#define DUK_ASSERT_TOP(ctx, n)
DUK_EXTERNAL void duk_push_false(duk_context *ctx)
#define DUK_HOBJECT_FLAG_EXTENSIBLE
DUK_INTERNAL_DECL duk_idx_t duk_push_object_helper(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx)
#define DUK_BIDX_OBJECT_CONSTRUCTOR
#define DUK_LFUNC_NARGS_MIN
#define DUK_HOBJECT_INCREF(thr, h)
DUK_EXTERNAL void duk_pop(duk_context *ctx)
#define DUK_TVAL_SET_LIGHTFUNC(tv, fp, flags)
#define DUK_HOBJECT_HAS_ENVRECCLOSED(h)
#define DUK_HOBJECT_CLEAR_CONSTRUCTABLE(h)
#define DUK_LFUNC_MAGIC_MAX
DUK_INTERNAL_DECL void duk_xdef_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_uint_t desc_flags)
#define DUK_HOBJECT_CLEAR_EXTENSIBLE(h)
DUK_INTERNAL_DECL duk_hstring * duk_get_hstring(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL duk_hnativefunction * duk_require_hnativefunction(duk_context *ctx, duk_idx_t index)
#define DUK__NUM_NORMAL_PROPS_BITS
#define DUK_HOBJECT_HAS_EXTENSIBLE(h)
#define DUK_HOBJECT_CLASS_STRING
DUK_INTERNAL_DECL duk_int32_t duk_bd_decode(duk_bitdecoder_ctx *ctx, duk_small_int_t bits)
#define DUK_HOBJECT_SET_CLASS_NUMBER(h, v)
#define DUK_BIDX_DATE_PROTOTYPE
#define DUK__PROP_TYPE_BOOLEAN_FALSE
#define DUK__PROP_TYPE_BOOLEAN_TRUE
#define DUK_HOBJECT_HAS_COMPILEDFUNCTION(h)
#define DUK_HTHREAD_STRING_SET_PROTOTYPE_OF(thr)
#define DUK__PROP_TYPE_UNDEFINED
DUK_INTERNAL_DECL duk_tval * duk_get_tval(duk_context *ctx, duk_idx_t index)
#define DUK_HOBJECT_HAS_NAMEBINDING(h)
DUK_INTERNAL_DECL void duk_xdef_prop(duk_context *ctx, duk_idx_t obj_index, duk_small_uint_t desc_flags)
#define duk_eval_string(ctx, src)
duk_ret_t(* duk_c_function)(duk_context *ctx)
#define duk_eval_string_noresult(ctx, src)
static void error(LoadState *S, const char *why)
duk_hobject * builtins[DUK_NUM_BUILTINS]

References duk_hthread::builtins, duk_bitdecoder_ctx::data, DUK__BIDX_BITS, DUK__CLASS_BITS, DUK__LENGTH_PROP_BITS, DUK__MAGIC_BITS, DUK__NARGS_BITS, DUK__NARGS_VARARGS_MARKER, DUK__NATIDX_BITS, DUK__NO_BIDX_MARKER, DUK__NUM_FUNC_PROPS_BITS, DUK__NUM_NORMAL_PROPS_BITS, DUK__PROP_FLAGS_BITS, DUK__PROP_TYPE_ACCESSOR, DUK__PROP_TYPE_BITS, DUK__PROP_TYPE_BOOLEAN_FALSE, DUK__PROP_TYPE_BOOLEAN_TRUE, DUK__PROP_TYPE_BUILTIN, DUK__PROP_TYPE_DOUBLE, DUK__PROP_TYPE_STRIDX, DUK__PROP_TYPE_STRING, DUK__PROP_TYPE_UNDEFINED, duk__push_double(), duk__push_stridx(), duk__push_stridx_or_string(), duk__push_string(), DUK_ASSERT, DUK_ASSERT_TOP, duk_bd_decode(), duk_bd_decode_flag(), duk_bd_decode_flagged(), duk_bi_native_functions, DUK_BIDX_DATE_PROTOTYPE, DUK_BIDX_DOUBLE_ERROR, DUK_BIDX_DUKTAPE, DUK_BIDX_FUNCTION_PROTOTYPE, DUK_BIDX_OBJECT_CONSTRUCTOR, DUK_BIDX_OBJECT_PROTOTYPE, DUK_D, DUK_DD, DUK_DDD, DUK_DDDPRINT, DUK_DDPRINT, DUK_DELPROP_FLAG_THROW, DUK_DPRINT, duk_dup(), duk_eval_string, duk_eval_string_noresult, duk_get_hstring(), duk_get_prop_stridx(), duk_get_tval(), DUK_HOBJECT_CLASS_ARRAY, DUK_HOBJECT_CLASS_FUNCTION, DUK_HOBJECT_CLASS_STRING, DUK_HOBJECT_CLEAR_CONSTRUCTABLE, DUK_HOBJECT_CLEAR_EXTENSIBLE, duk_hobject_compact_props(), duk_hobject_define_accessor_internal(), duk_hobject_delprop_raw(), DUK_HOBJECT_FLAG_EXTENSIBLE, DUK_HOBJECT_HAS_ARRAY_PART, DUK_HOBJECT_HAS_BOUND, DUK_HOBJECT_HAS_COMPILEDFUNCTION, DUK_HOBJECT_HAS_CONSTRUCTABLE, DUK_HOBJECT_HAS_CREATEARGS, DUK_HOBJECT_HAS_ENVRECCLOSED, DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS, DUK_HOBJECT_HAS_EXTENSIBLE, DUK_HOBJECT_HAS_NAMEBINDING, DUK_HOBJECT_HAS_NATIVEFUNCTION, DUK_HOBJECT_HAS_NEWENV, DUK_HOBJECT_HAS_STRICT, DUK_HOBJECT_HAS_THREAD, DUK_HOBJECT_INCREF, DUK_HOBJECT_SET_CLASS_NUMBER, DUK_HOBJECT_SET_EXOTIC_ARRAY, DUK_HOBJECT_SET_EXOTIC_STRINGOBJ, DUK_HOBJECT_SET_PROTOTYPE_UPDREF, DUK_HOBJECT_SET_STRICT, DUK_HTHREAD_STRING___PROTO__, DUK_HTHREAD_STRING_EVAL, DUK_HTHREAD_STRING_REQUIRE, DUK_HTHREAD_STRING_RESUME, DUK_HTHREAD_STRING_SET_PROTOTYPE_OF, DUK_HTHREAD_STRING_YIELD, duk_initjs_data, DUK_LFUNC_FLAGS_PACK, DUK_LFUNC_LENGTH_MAX, DUK_LFUNC_MAGIC_MAX, DUK_LFUNC_MAGIC_MIN, DUK_LFUNC_NARGS_MAX, DUK_LFUNC_NARGS_MIN, DUK_LFUNC_NARGS_VARARGS, DUK_MEMZERO, DUK_NUM_ALL_BUILTINS, DUK_NUM_BUILTINS, duk_pop(), duk_pop_3(), DUK_PROPDESC_FLAG_ACCESSOR, DUK_PROPDESC_FLAG_WRITABLE, DUK_PROPDESC_FLAGS_NONE, DUK_PROPDESC_FLAGS_W, DUK_PROPDESC_FLAGS_WC, duk_push_c_function_noconstruct_noexotic(), duk_push_c_function_noexotic(), duk_push_false(), duk_push_int(), duk_push_object_helper(), duk_push_string(), duk_push_true(), duk_push_tval(), duk_push_undefined(), duk_require_hnativefunction(), duk_require_hobject(), duk_require_stack(), duk_set_top(), DUK_STRIDX_CONSTRUCTOR, DUK_STRIDX_ENV, DUK_STRIDX_LENGTH, DUK_STRIDX_NAME, DUK_STRIDX_PROTOTYPE, DUK_STRIDX_TO_GMT_STRING, DUK_STRIDX_TO_UTC_STRING, DUK_TVAL_SET_LIGHTFUNC, DUK_UNREACHABLE, DUK_UNREF, DUK_USE_ALIGN_BY, DUK_USE_ARCH_STRING, DUK_USE_COMPILER_STRING, DUK_USE_HOBJECT_LAYOUT_2, DUK_USE_OS_STRING, DUK_USE_STRTAB_PROBE, DUK_VARARGS, duk_xdef_prop(), duk_xdef_prop_stridx(), duk_xdef_prop_stridx_builtin(), error(), duk_hobject::hdr, duk_bitdecoder_ctx::length, duk_hnativefunction::magic, and NULL.

Referenced by duk__init_heap_thread(), and duk_push_thread_raw().

◆ duk_hthread_get_act_prev_pc()

DUK_INTERNAL_DECL duk_uint_fast32_t duk_hthread_get_act_prev_pc ( duk_hthread * thr,
duk_activation * act )

Definition at line 54106 of file duktape-1.5.2/src-noline/duktape.c.

54107 {
54108 duk_instr_t *bcode;
54109
54110 DUK_ASSERT(thr != NULL);
54111 DUK_ASSERT(act != NULL);
54112 DUK_UNREF(thr);
54113
54114 /* XXX: store 'bcode' pointer to activation for faster lookup? */
54115 if (act->func && DUK_HOBJECT_IS_COMPILEDFUNCTION(act->func)) {
54117 return (duk_uint_fast32_t) (act->curr_pc - bcode);
54118 }
54119 return 0;
54120}
54121#endif /* DUK_USE_DEBUGGER_SUPPORT */
54122
duk_uint32_t duk_uint_fast32_t
#define DUK_HCOMPILEDFUNCTION_GET_CODE_BASE(heap, h)
#define DUK_HOBJECT_IS_COMPILEDFUNCTION(h)
duk_uint32_t duk_instr_t
DUK_INTERNAL_DECL duk_uint_fast32_t duk_hthread_get_act_prev_pc(duk_hthread *thr, duk_activation *act)

References duk_activation::curr_pc, DUK_ASSERT, DUK_HCOMPILEDFUNCTION_GET_CODE_BASE, DUK_HOBJECT_IS_COMPILEDFUNCTION, DUK_UNREF, duk_activation::func, duk_hthread::heap, and NULL.

Referenced by duk__add_traceback(), and duk_bi_duktape_object_act().

◆ duk_hthread_get_callstack_ptr()

DUK_INTERNAL_DECL void * duk_hthread_get_callstack_ptr ( duk_heap * heap,
void * ud )

◆ duk_hthread_get_catchstack_ptr()

DUK_INTERNAL_DECL void * duk_hthread_get_catchstack_ptr ( duk_heap * heap,
void * ud )

◆ duk_hthread_get_current_activation()

◆ duk_hthread_get_valstack_ptr()

DUK_INTERNAL_DECL void * duk_hthread_get_valstack_ptr ( duk_heap * heap,
void * ud )

Definition at line 53191 of file duktape-1.5.2/src-noline/duktape.c.

53195 :
53196

References DUK_UNREF, and duk_hthread::valstack.

Referenced by duk__resize_valstack().

◆ duk_hthread_init_stacks()

DUK_INTERNAL_DECL duk_bool_t duk_hthread_init_stacks ( duk_heap * heap,
duk_hthread * thr )

Definition at line 53125 of file duktape-1.5.2/src-noline/duktape.c.

53125 {
53127 }
53128}
53129#endif /* !DUK_USE_HSTRING_CLEN */
53130/*
53131 * duk_hthread allocation and freeing.
53132 */
53133
53134/* include removed: duk_internal.h */
53135
53136/*
53137 * Allocate initial stacks for a thread. Note that 'thr' must be reachable
53138 * as a garbage collection may be triggered by the allocation attempts.
53139 * Returns zero (without leaking memory) if init fails.
53140 */
53141
53143 duk_size_t alloc_size;
53144 duk_size_t i;
53145
53146 DUK_ASSERT(heap != NULL);
53147 DUK_ASSERT(thr != NULL);
53148 DUK_ASSERT(thr->valstack == NULL);
53149 DUK_ASSERT(thr->valstack_end == NULL);
53151 DUK_ASSERT(thr->valstack_top == NULL);
53152 DUK_ASSERT(thr->callstack == NULL);
53153 DUK_ASSERT(thr->catchstack == NULL);
53154
53155 /* valstack */
53156 alloc_size = sizeof(duk_tval) * DUK_VALSTACK_INITIAL_SIZE;
53157 thr->valstack = (duk_tval *) DUK_ALLOC(heap, alloc_size);
53158 if (!thr->valstack) {
53159 goto fail;
53160 }
53161 DUK_MEMZERO(thr->valstack, alloc_size);
53163#if !defined(DUK_USE_PREFER_SIZE)
53165#endif
53166 thr->valstack_bottom = thr->valstack;
53167 thr->valstack_top = thr->valstack;
53168
53169 for (i = 0; i < DUK_VALSTACK_INITIAL_SIZE; i++) {
53171 }
53172
53173 /* callstack */
53174 alloc_size = sizeof(duk_activation) * DUK_CALLSTACK_INITIAL_SIZE;
53175 thr->callstack = (duk_activation *) DUK_ALLOC(heap, alloc_size);
53176 if (!thr->callstack) {
53177 goto fail;
53178 }
53179 DUK_MEMZERO(thr->callstack, alloc_size);
53181 DUK_ASSERT(thr->callstack_top == 0);
53182
53183 /* catchstack */
53184 alloc_size = sizeof(duk_catcher) * DUK_CATCHSTACK_INITIAL_SIZE;
53185 thr->catchstack = (duk_catcher *) DUK_ALLOC(heap, alloc_size);
53186 if (!thr->catchstack) {
53187 goto fail;
duk_small_int_t duk_bool_t
#define DUK_HSTRING_GET_DATA(x)
DUK_INTERNAL_DECL duk_size_t duk_unicode_unvalidated_utf8_length(const duk_uint8_t *data, duk_size_t blen)
#define DUK_ALLOC(heap, size)
#define DUK_HSTRING_GET_BYTELEN(x)
DUK_INTERNAL_DECL duk_bool_t duk_hthread_init_stacks(duk_heap *heap, duk_hthread *thr)
struct duk_tval_struct duk_tval
#define DUK_VALSTACK_INITIAL_SIZE
#define DUK_CATCHSTACK_INITIAL_SIZE
struct duk_activation duk_activation
#define DUK_CALLSTACK_INITIAL_SIZE
#define DUK_TVAL_SET_UNDEFINED(tv)
struct duk_catcher duk_catcher

References duk_hthread::callstack, duk_hthread::callstack_size, duk_hthread::callstack_top, duk_hthread::catchstack, duk_hthread::catchstack_size, duk_hthread::catchstack_top, DUK_ALLOC, DUK_ASSERT, DUK_CALLSTACK_INITIAL_SIZE, DUK_CATCHSTACK_INITIAL_SIZE, DUK_FREE, DUK_MEMZERO, DUK_TVAL_SET_UNDEFINED, DUK_VALSTACK_INITIAL_SIZE, NULL, duk_hthread::valstack, duk_hthread::valstack_bottom, duk_hthread::valstack_end, duk_hthread::valstack_size, and duk_hthread::valstack_top.

Referenced by duk__init_heap_thread(), and duk_push_thread_raw().

◆ duk_hthread_sync_and_null_currpc()

DUK_INTERNAL_DECL void duk_hthread_sync_and_null_currpc ( duk_hthread * thr)

Definition at line 54139 of file duktape-1.5.2/src-noline/duktape.c.

54143 {
54144 duk_activation *act;
54145
54146 DUK_ASSERT(thr != NULL);
54147
54148 if (thr->ptr_curr_pc != NULL) {
54149 /* ptr_curr_pc != NULL only when bytecode executor is active. */
54150 DUK_ASSERT(thr->callstack_top > 0);
54151 act = thr->callstack + thr->callstack_top - 1;

References duk_hthread::callstack, duk_hthread::callstack_top, duk_activation::curr_pc, DUK_ASSERT, NULL, and duk_hthread::ptr_curr_pc.

Referenced by duk__handle_call_inner(), duk_err_create_and_throw(), duk_handle_ecma_call_setup(), and duk_throw().

◆ duk_hthread_sync_currpc()

DUK_INTERNAL_DECL void duk_hthread_sync_currpc ( duk_hthread * thr)

Definition at line 54126 of file duktape-1.5.2/src-noline/duktape.c.

54131 {
54132 bcode = DUK_HCOMPILEDFUNCTION_GET_CODE_BASE(thr->heap, (duk_hcompiledfunction *) (act->func));
54133 ret = (duk_uint_fast32_t) (act->curr_pc - bcode);
54134 if (ret > 0) {
54135 ret--;
54136 }
54137 return ret;

References duk_hthread::callstack, duk_hthread::callstack_top, duk_activation::curr_pc, DUK_ASSERT, NULL, and duk_hthread::ptr_curr_pc.

Referenced by duk_new().

◆ duk_hthread_terminate()

DUK_INTERNAL_DECL void duk_hthread_terminate ( duk_hthread * thr)

Definition at line 54050 of file duktape-1.5.2/src-noline/duktape.c.

54053 {
54055
54056 for (i = 0; i < DUK_NUM_BUILTINS; i++) {
54057 thr_to->builtins[i] = thr_from->builtins[i];
54058 DUK_HOBJECT_INCREF_ALLOWNULL(thr_to, thr_to->builtins[i]); /* side effect free */
54059 }
54060}
54061/*
54062 * Thread support.
54063 */
54064
54065/* include removed: duk_internal.h */
54066
54068 DUK_ASSERT(thr != NULL);
54069
54070 /* Order of unwinding is important */
54071
54073
54074 duk_hthread_callstack_unwind(thr, 0); /* side effects, possibly errors */
54075
54076 thr->valstack_bottom = thr->valstack;
54077 duk_set_top((duk_context *) thr, 0); /* unwinds valstack, updating refcounts */
DUK_INTERNAL_DECL void duk_hthread_terminate(duk_hthread *thr)
DUK_EXTERNAL void duk_set_top(duk_context *ctx, duk_idx_t index)
#define DUK_HOBJECT_INCREF_ALLOWNULL(thr, h)

References duk_hthread::builtins, DUK_ASSERT, DUK_HOBJECT_INCREF_ALLOWNULL, duk_hthread_callstack_unwind(), duk_hthread_catchstack_unwind(), DUK_HTHREAD_STATE_TERMINATED, DUK_NUM_BUILTINS, duk_set_top(), NULL, duk_hthread::state, duk_hthread::valstack, and duk_hthread::valstack_bottom.

Referenced by duk__handle_longjmp(), and duk__handle_return().