📄 jscntxt.h
字号:
* value. */#define NO_SCOPE_SHARING_TODO ((JSScope *) 0xfeedbeef) /* * The index for JSThread info, returned by PR_NewThreadPrivateIndex. * The value is visible and shared by all threads, but the data is * private to each thread. */ PRUintn threadTPIndex;#endif /* JS_THREADSAFE */ /* * Check property accessibility for objects of arbitrary class. Used at * present to check f.caller accessibility for any function object f. */ JSCheckAccessOp checkObjectAccess; /* Security principals serialization support. */ JSPrincipalsTranscoder principalsTranscoder; /* Optional hook to find principals for an object in this runtime. */ JSObjectPrincipalsFinder findObjectPrincipals; /* * Shared scope property tree, and arena-pool for allocating its nodes. * The propertyRemovals counter is incremented for every js_ClearScope, * and for each js_RemoveScopeProperty that frees a slot in an object. * See js_NativeGet and js_NativeSet in jsobj.c. */ JSDHashTable propertyTreeHash; JSScopeProperty *propertyFreeList; JSArenaPool propertyArenaPool; int32 propertyRemovals; /* Script filename table. */ struct JSHashTable *scriptFilenameTable; JSCList scriptFilenamePrefixes;#ifdef JS_THREADSAFE PRLock *scriptFilenameTableLock;#endif /* Number localization, used by jsnum.c */ const char *thousandsSeparator; const char *decimalSeparator; const char *numGrouping; /* * Weak references to lazily-created, well-known XML singletons. * * NB: Singleton objects must be carefully disconnected from the rest of * the object graph usually associated with a JSContext's global object, * including the set of standard class objects. See jsxml.c for details. */ JSObject *anynameObject; JSObject *functionNamespaceObject; /* * A helper list for the GC, so it can mark native iterator states. See * js_MarkNativeIteratorStates for details. */ JSNativeIteratorState *nativeIteratorStates;#ifndef JS_THREADSAFE /* * For thread-unsafe embeddings, the GSN cache lives in the runtime and * not each context, since we expect it to be filled once when decompiling * a longer script, then hit repeatedly as js_GetSrcNote is called during * the decompiler activation that filled it. */ JSGSNCache gsnCache;#define JS_GSN_CACHE(cx) ((cx)->runtime->gsnCache)#endif#ifdef DEBUG /* Function invocation metering. */ jsrefcount inlineCalls; jsrefcount nativeCalls; jsrefcount nonInlineCalls; jsrefcount constructs; /* Scope lock and property metering. */ jsrefcount claimAttempts; jsrefcount claimedScopes; jsrefcount deadContexts; jsrefcount deadlocksAvoided; jsrefcount liveScopes; jsrefcount sharedScopes; jsrefcount totalScopes; jsrefcount badUndependStrings; jsrefcount liveScopeProps; jsrefcount totalScopeProps; jsrefcount livePropTreeNodes; jsrefcount duplicatePropTreeNodes; jsrefcount totalPropTreeNodes; jsrefcount propTreeKidsChunks; jsrefcount middleDeleteFixups; /* String instrumentation. */ jsrefcount liveStrings; jsrefcount totalStrings; jsrefcount liveDependentStrings; jsrefcount totalDependentStrings; double lengthSum; double lengthSquaredSum; double strdepLengthSum; double strdepLengthSquaredSum;#endif};#ifdef DEBUG# define JS_RUNTIME_METER(rt, which) JS_ATOMIC_INCREMENT(&(rt)->which)# define JS_RUNTIME_UNMETER(rt, which) JS_ATOMIC_DECREMENT(&(rt)->which)#else# define JS_RUNTIME_METER(rt, which) /* nothing */# define JS_RUNTIME_UNMETER(rt, which) /* nothing */#endif#define JS_KEEP_ATOMS(rt) JS_ATOMIC_INCREMENT(&(rt)->gcKeepAtoms);#define JS_UNKEEP_ATOMS(rt) JS_ATOMIC_DECREMENT(&(rt)->gcKeepAtoms);#ifdef JS_ARGUMENT_FORMATTER_DEFINED/* * Linked list mapping format strings for JS_{Convert,Push}Arguments{,VA} to * formatter functions. Elements are sorted in non-increasing format string * length order. */struct JSArgumentFormatMap { const char *format; size_t length; JSArgumentFormatter formatter; JSArgumentFormatMap *next;};#endifstruct JSStackHeader { uintN nslots; JSStackHeader *down;};#define JS_STACK_SEGMENT(sh) ((jsval *)(sh) + 2)/* * Key and entry types for the JSContext.resolvingTable hash table, typedef'd * here because all consumers need to see these declarations (and not just the * typedef names, as would be the case for an opaque pointer-to-typedef'd-type * declaration), along with cx->resolvingTable. */typedef struct JSResolvingKey { JSObject *obj; jsid id;} JSResolvingKey;typedef struct JSResolvingEntry { JSDHashEntryHdr hdr; JSResolvingKey key; uint32 flags;} JSResolvingEntry;#define JSRESFLAG_LOOKUP 0x1 /* resolving id from lookup */#define JSRESFLAG_WATCH 0x2 /* resolving id from watch */typedef struct JSLocalRootChunk JSLocalRootChunk;#define JSLRS_CHUNK_SHIFT 8#define JSLRS_CHUNK_SIZE JS_BIT(JSLRS_CHUNK_SHIFT)#define JSLRS_CHUNK_MASK JS_BITMASK(JSLRS_CHUNK_SHIFT)struct JSLocalRootChunk { jsval roots[JSLRS_CHUNK_SIZE]; JSLocalRootChunk *down;};typedef struct JSLocalRootStack { uint32 scopeMark; uint32 rootCount; JSLocalRootChunk *topChunk; JSLocalRootChunk firstChunk;} JSLocalRootStack;#define JSLRS_NULL_MARK ((uint32) -1)typedef struct JSTempValueRooter JSTempValueRooter;typedef void(* JS_DLL_CALLBACK JSTempValueMarker)(JSContext *cx, JSTempValueRooter *tvr);typedef union JSTempValueUnion { jsval value; JSObject *object; JSString *string; void *gcthing; JSTempValueMarker marker; JSScopeProperty *sprop; JSWeakRoots *weakRoots; jsval *array;} JSTempValueUnion;/* * The following allows to reinterpret JSTempValueUnion.object as jsval using * the tagging property of a generic jsval described below. */JS_STATIC_ASSERT(sizeof(JSTempValueUnion) == sizeof(jsval));JS_STATIC_ASSERT(sizeof(JSTempValueUnion) == sizeof(JSObject *));/* * Context-linked stack of temporary GC roots. * * If count is -1, then u.value contains the single value or GC-thing to root. * If count is -2, then u.marker holds a mark hook called to mark the values. * If count is -3, then u.sprop points to the property tree node to mark. * If count is -4, then u.weakRoots points to saved weak roots. * If count >= 0, then u.array points to a stack-allocated vector of jsvals. * * To root a single GC-thing pointer, which need not be tagged and stored as a * jsval, use JS_PUSH_TEMP_ROOT_GCTHING. The macro reinterprets an arbitrary * GC-thing as jsval. It works because a GC-thing is aligned on a 0 mod 8 * boundary, and object has the 0 jsval tag. So any GC-thing may be tagged as * if it were an object and untagged, if it's then used only as an opaque * pointer until discriminated by other means than tag bits (this is how the * GC mark function uses its |thing| parameter -- it consults GC-thing flags * stored separately from the thing to decide the type of thing). * * JS_PUSH_TEMP_ROOT_OBJECT and JS_PUSH_TEMP_ROOT_STRING are type-safe * alternatives to JS_PUSH_TEMP_ROOT_GCTHING for JSObject and JSString. They * also provide a simple way to get a single pointer to rooted JSObject or * JSString via JS_PUSH_TEMP_ROOT_(OBJECT|STRTING)(cx, NULL, &tvr). Then * &tvr.u.object or tvr.u.string gives the necessary pointer, which puns * tvr.u.value safely because JSObject * and JSString * are GC-things and, as * such, their tag bits are all zeroes. * * If you need to protect a result value that flows out of a C function across * several layers of other functions, use the js_LeaveLocalRootScopeWithResult * internal API (see further below) instead. */struct JSTempValueRooter { JSTempValueRooter *down; ptrdiff_t count; JSTempValueUnion u;};#define JSTVU_SINGLE (-1)#define JSTVU_MARKER (-2)#define JSTVU_SPROP (-3)#define JSTVU_WEAK_ROOTS (-4)#define JS_PUSH_TEMP_ROOT_COMMON(cx,tvr) \ JS_BEGIN_MACRO \ JS_ASSERT((cx)->tempValueRooters != (tvr)); \ (tvr)->down = (cx)->tempValueRooters; \ (cx)->tempValueRooters = (tvr); \ JS_END_MACRO#define JS_PUSH_SINGLE_TEMP_ROOT(cx,val,tvr) \ JS_BEGIN_MACRO \ (tvr)->count = JSTVU_SINGLE; \ (tvr)->u.value = val; \ JS_PUSH_TEMP_ROOT_COMMON(cx, tvr); \ JS_END_MACRO#define JS_PUSH_TEMP_ROOT(cx,cnt,arr,tvr) \ JS_BEGIN_MACRO \ JS_ASSERT((ptrdiff_t)(cnt) >= 0); \ (tvr)->count = (ptrdiff_t)(cnt); \ (tvr)->u.array = (arr); \ JS_PUSH_TEMP_ROOT_COMMON(cx, tvr); \ JS_END_MACRO#define JS_PUSH_TEMP_ROOT_MARKER(cx,marker_,tvr) \ JS_BEGIN_MACRO \ (tvr)->count = JSTVU_MARKER; \ (tvr)->u.marker = (marker_); \ JS_PUSH_TEMP_ROOT_COMMON(cx, tvr); \ JS_END_MACRO#define JS_PUSH_TEMP_ROOT_OBJECT(cx,obj,tvr) \ JS_BEGIN_MACRO \ (tvr)->count = JSTVU_SINGLE; \ (tvr)->u.object = (obj); \ JS_PUSH_TEMP_ROOT_COMMON(cx, tvr); \ JS_END_MACRO#define JS_PUSH_TEMP_ROOT_STRING(cx,str,tvr) \ JS_BEGIN_MACRO \ (tvr)->count = JSTVU_SINGLE; \ (tvr)->u.string = (str); \ JS_PUSH_TEMP_ROOT_COMMON(cx, tvr); \ JS_END_MACRO#define JS_PUSH_TEMP_ROOT_GCTHING(cx,thing,tvr) \ JS_BEGIN_MACRO \ JS_ASSERT(JSVAL_IS_OBJECT((jsval)thing)); \ (tvr)->count = JSTVU_SINGLE; \ (tvr)->u.gcthing = (thing); \ JS_PUSH_TEMP_ROOT_COMMON(cx, tvr); \ JS_END_MACRO#define JS_POP_TEMP_ROOT(cx,tvr) \ JS_BEGIN_MACRO \ JS_ASSERT((cx)->tempValueRooters == (tvr)); \ (cx)->tempValueRooters = (tvr)->down; \ JS_END_MACRO#define JS_TEMP_ROOT_EVAL(cx,cnt,val,expr) \ JS_BEGIN_MACRO \ JSTempValueRooter tvr; \ JS_PUSH_TEMP_ROOT(cx, cnt, val, &tvr); \ (expr); \ JS_POP_TEMP_ROOT(cx, &tvr); \ JS_END_MACRO#define JS_PUSH_TEMP_ROOT_SPROP(cx,sprop_,tvr) \ JS_BEGIN_MACRO \ (tvr)->count = JSTVU_SPROP; \ (tvr)->u.sprop = (sprop_); \ JS_PUSH_TEMP_ROOT_COMMON(cx, tvr); \ JS_END_MACRO#define JS_PUSH_TEMP_ROOT_WEAK_COPY(cx,weakRoots_,tvr) \ JS_BEGIN_MACRO \ (tvr)->count = JSTVU_WEAK_ROOTS; \ (tvr)->u.weakRoots = (weakRoots_); \ JS_PUSH_TEMP_ROOT_COMMON(cx, tvr); \ JS_END_MACROstruct JSContext { /* JSRuntime contextList linkage. */ JSCList links; /* Interpreter activation count. */ uintN interpLevel; /* Limit pointer for checking stack consumption during recursion. */ jsuword stackLimit; /* Runtime version control identifier and equality operators. */ uint16 version; jsbytecode jsop_eq;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -