⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jscntxt.h

📁 java script test programing source code
💻 H
📖 第 1 页 / 共 3 页
字号:
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sw=4 et tw=78: * * ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Mozilla Communicator client code, released * March 31, 1998. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */#ifndef jscntxt_h___#define jscntxt_h___/* * JS execution context. */#include "jsarena.h" /* Added by JSIFY */#include "jsclist.h"#include "jslong.h"#include "jsatom.h"#include "jsconfig.h"#include "jsdhash.h"#include "jsgc.h"#include "jsinterp.h"#include "jsobj.h"#include "jsprvtd.h"#include "jspubtd.h"#include "jsregexp.h"#include "jsutil.h"JS_BEGIN_EXTERN_C/* * js_GetSrcNote cache to avoid O(n^2) growth in finding a source note for a * given pc in a script. */typedef struct JSGSNCache {    JSScript        *script;    JSDHashTable    table;#ifdef JS_GSNMETER    uint32          hits;    uint32          misses;    uint32          fills;    uint32          clears;# define GSN_CACHE_METER(cache,cnt) (++(cache)->cnt)#else# define GSN_CACHE_METER(cache,cnt) /* nothing */#endif} JSGSNCache;#define GSN_CACHE_CLEAR(cache)                                                \    JS_BEGIN_MACRO                                                            \        (cache)->script = NULL;                                               \        if ((cache)->table.ops) {                                             \            JS_DHashTableFinish(&(cache)->table);                             \            (cache)->table.ops = NULL;                                        \        }                                                                     \        GSN_CACHE_METER(cache, clears);                                       \    JS_END_MACRO/* These helper macros take a cx as parameter and operate on its GSN cache. */#define JS_CLEAR_GSN_CACHE(cx)      GSN_CACHE_CLEAR(&JS_GSN_CACHE(cx))#define JS_METER_GSN_CACHE(cx,cnt)  GSN_CACHE_METER(&JS_GSN_CACHE(cx), cnt)#ifdef JS_THREADSAFE/* * Structure uniquely representing a thread.  It holds thread-private data * that can be accessed without a global lock. */struct JSThread {    /* Linked list of all contexts active on this thread. */    JSCList             contextList;    /* Opaque thread-id, from NSPR's PR_GetCurrentThread(). */    jsword              id;    /* Thread-local gc free lists array. */    JSGCThing           *gcFreeLists[GC_NUM_FREELISTS];    /*     * Thread-local version of JSRuntime.gcMallocBytes to avoid taking     * locks on each JS_malloc.     */    uint32              gcMallocBytes;#if JS_HAS_GENERATORS    /* Flag indicating that the current thread is executing close hooks. */    JSBool              gcRunningCloseHooks;#endif    /*     * Store the GSN cache in struct JSThread, not struct JSContext, both to     * save space and to simplify cleanup in js_GC.  Any embedding (Firefox     * or another Gecko application) that uses many contexts per thread is     * unlikely to interleave js_GetSrcNote-intensive loops in the decompiler     * among two or more contexts running script in one thread.     */    JSGSNCache          gsnCache;};#define JS_GSN_CACHE(cx) ((cx)->thread->gsnCache)extern void JS_DLL_CALLBACKjs_ThreadDestructorCB(void *ptr);extern JSBooljs_SetContextThread(JSContext *cx);extern voidjs_ClearContextThread(JSContext *cx);extern JSThread *js_GetCurrentThread(JSRuntime *rt);#endif /* JS_THREADSAFE */typedef enum JSDestroyContextMode {    JSDCM_NO_GC,    JSDCM_MAYBE_GC,    JSDCM_FORCE_GC,    JSDCM_NEW_FAILED} JSDestroyContextMode;typedef enum JSRuntimeState {    JSRTS_DOWN,    JSRTS_LAUNCHING,    JSRTS_UP,    JSRTS_LANDING} JSRuntimeState;typedef struct JSPropertyTreeEntry {    JSDHashEntryHdr     hdr;    JSScopeProperty     *child;} JSPropertyTreeEntry;/* * Forward declaration for opaque JSRuntime.nativeIteratorStates. */typedef struct JSNativeIteratorState JSNativeIteratorState;struct JSRuntime {    /* Runtime state, synchronized by the stateChange/gcLock condvar/lock. */    JSRuntimeState      state;    /* Context create/destroy callback. */    JSContextCallback   cxCallback;    /* Garbage collector state, used by jsgc.c. */    JSGCArenaList       gcArenaList[GC_NUM_FREELISTS];    JSDHashTable        gcRootsHash;    JSDHashTable        *gcLocksHash;    jsrefcount          gcKeepAtoms;    uint32              gcBytes;    uint32              gcLastBytes;    uint32              gcMaxBytes;    uint32              gcMaxMallocBytes;    uint32              gcLevel;    uint32              gcNumber;    /*     * NB: do not pack another flag here by claiming gcPadding unless the new     * flag is written only by the GC thread.  Atomic updates to packed bytes     * are not guaranteed, so stores issued by one thread may be lost due to     * unsynchronized read-modify-write cycles on other threads.     */    JSPackedBool        gcPoke;    JSPackedBool        gcRunning;    uint16              gcPadding;    JSGCCallback        gcCallback;    uint32              gcMallocBytes;    JSGCArena           *gcUnscannedArenaStackTop;#ifdef DEBUG    size_t              gcUnscannedBagSize;#endif    /*     * API compatibility requires keeping GCX_PRIVATE bytes separate from the     * original GC types' byte tally.  Otherwise embeddings that configure a     * good limit for pre-GCX_PRIVATE versions of the engine will see memory     * over-pressure too often, possibly leading to failed last-ditch GCs.     *     * The new XML GC-thing types do add to gcBytes, and they're larger than     * the original GC-thing type size (8 bytes on most architectures).  So a     * user who enables E4X may want to increase the maxbytes value passed to     * JS_NewRuntime.  TODO: Note this in the API docs.     */    uint32              gcPrivateBytes;    /*     * Table for tracking iterators to ensure that we close iterator's state     * before finalizing the iterable object.     */    JSPtrTable          gcIteratorTable;#if JS_HAS_GENERATORS    /* Runtime state to support close hooks. */    JSGCCloseState      gcCloseState;#endif#ifdef JS_GCMETER    JSGCStats           gcStats;#endif    /* Literal table maintained by jsatom.c functions. */    JSAtomState         atomState;    /* Random number generator state, used by jsmath.c. */    JSBool              rngInitialized;    int64               rngMultiplier;    int64               rngAddend;    int64               rngMask;    int64               rngSeed;    jsdouble            rngDscale;    /* Well-known numbers held for use by this runtime's contexts. */    jsdouble            *jsNaN;    jsdouble            *jsNegativeInfinity;    jsdouble            *jsPositiveInfinity;#ifdef JS_THREADSAFE    JSLock              *deflatedStringCacheLock;#endif    JSHashTable         *deflatedStringCache;#ifdef DEBUG    uint32              deflatedStringCacheBytes;#endif    /* Empty string held for use by this runtime's contexts. */    JSString            *emptyString;    /* List of active contexts sharing this runtime; protected by gcLock. */    JSCList             contextList;    /* These are used for debugging -- see jsprvtd.h and jsdbgapi.h. */    JSTrapHandler       interruptHandler;    void                *interruptHandlerData;    JSNewScriptHook     newScriptHook;    void                *newScriptHookData;    JSDestroyScriptHook destroyScriptHook;    void                *destroyScriptHookData;    JSTrapHandler       debuggerHandler;    void                *debuggerHandlerData;    JSSourceHandler     sourceHandler;    void                *sourceHandlerData;    JSInterpreterHook   executeHook;    void                *executeHookData;    JSInterpreterHook   callHook;    void                *callHookData;    JSObjectHook        objectHook;    void                *objectHookData;    JSTrapHandler       throwHook;    void                *throwHookData;    JSDebugErrorHook    debugErrorHook;    void                *debugErrorHookData;    /* More debugging state, see jsdbgapi.c. */    JSCList             trapList;    JSCList             watchPointList;    /* Weak links to properties, indexed by quickened get/set opcodes. */    /* XXX must come after JSCLists or MSVC alignment bug bites empty lists */    JSPropertyCache     propertyCache;    /* Client opaque pointer */    void                *data;#ifdef JS_THREADSAFE    /* These combine to interlock the GC and new requests. */    PRLock              *gcLock;    PRCondVar           *gcDone;    PRCondVar           *requestDone;    uint32              requestCount;    JSThread            *gcThread;    /* Lock and owning thread pointer for JS_LOCK_RUNTIME. */    PRLock              *rtLock;#ifdef DEBUG    jsword              rtLockOwner;#endif    /* Used to synchronize down/up state change; protected by gcLock. */    PRCondVar           *stateChange;    /* Used to serialize cycle checks when setting __proto__ or __parent__. */    PRLock              *setSlotLock;    PRCondVar           *setSlotDone;    JSBool              setSlotBusy;    JSScope             *setSlotScope;  /* deadlock avoidance, see jslock.c */    /*     * State for sharing single-threaded scopes, once a second thread tries to     * lock a scope.  The scopeSharingDone condvar is protected by rt->gcLock,     * to minimize number of locks taken in JS_EndRequest.     *     * The scopeSharingTodo linked list is likewise "global" per runtime, not     * one-list-per-context, to conserve space over all contexts, optimizing     * for the likely case that scopes become shared rarely, and among a very     * small set of threads (contexts).     */    PRCondVar           *scopeSharingDone;    JSScope             *scopeSharingTodo;/* * Magic terminator for the rt->scopeSharingTodo linked list, threaded through * scope->u.link.  This hack allows us to test whether a scope is on the list * by asking whether scope->u.link is non-null.  We use a large, likely bogus * pointer here to distinguish this value from any valid u.count (small int)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -