📄 jscntxt.h
字号:
#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 */struct JSContext { JSCList links; /* Interpreter activation count. */ uintN interpLevel; /* Limit pointer for checking stack consumption during recursion. */ jsuword stackLimit; /* Runtime version control identifier and equality operators. */ JSVersion version; jsbytecode jsop_eq; jsbytecode jsop_ne; JSBool caseSensitive; /* Data shared by threads in an address space. */ JSRuntime *runtime; /* Stack arena pool and frame pointer register. */ JSArenaPool stackPool; JSStackFrame *fp; /* Temporary arena pool used while compiling and decompiling. */ JSArenaPool tempPool; /* Top-level object and pointer to top stack frame's scope chain. */ JSObject *globalObject; /* Most recently created things by type, members of the GC's root set. */ JSGCThing *newborn[GCX_NTYPES]; /* Atom root for the last-looked-up atom on this context. */ JSAtom *lastAtom; /* Regular expression class statics (XXX not shared globally). */ JSRegExpStatics regExpStatics; /* State for object and array toSource conversion. */ JSSharpObjectMap sharpObjectMap; /* Argument formatter support for JS_{Convert,Push}Arguments{,VA}. */ JSArgumentFormatMap *argumentFormatMap; /* Last message string and trace file for debugging. */ char *lastMessage;#ifdef DEBUG void *tracefp;#endif /* Per-context optional user callbacks. */ JSBranchCallback branchCallback; JSErrorReporter errorReporter; /* Client opaque pointer */ void *data; /* GC and thread-safe state. */ JSStackFrame *dormantFrameChain; /* dormant stack frame to scan */#ifdef JS_THREADSAFE jsword thread; jsrefcount requestDepth; JSScope *scopeToShare; /* weak reference, see jslock.c */ JSScope *lockedSealedScope; /* weak ref, for low-cost sealed scope locking */#endif#if JS_HAS_LVALUE_RETURN /* * Secondary return value from native method called on the left-hand side * of an assignment operator. The native should store the object in which * to set a property in *rval, and return the property's id expressed as a * jsval by calling JS_SetCallReturnValue2(cx, idval). */ jsval rval2; JSPackedBool rval2set;#endif /* * True if creating an exception object, to prevent runaway recursion. * NB: creatingException packs with rval2set, #if JS_HAS_LVALUE_RETURN, * and with throwing, below. */ JSPackedBool creatingException; /* * Exception state -- the exception member is a GC root by definition. * NB: throwing packs with creatingException and rval2set, above. */ JSPackedBool throwing; /* is there a pending exception? */ jsval exception; /* most-recently-thrown exception */ /* Per-context options. */ uint32 options; /* see jsapi.h for JSOPTION_* */ /* Locale specific callbacks for string conversion. */ JSLocaleCallbacks *localeCallbacks; /* * cx->resolvingTable is non-null and non-empty if we are initializing * standard classes lazily, or if we are otherwise recursing indirectly * from js_LookupProperty through a JSClass.resolve hook. It is used to * limit runaway recursion (see jsapi.c and jsobj.c). */ JSDHashTable *resolvingTable; /* PDL of stack headers describing stack slots not rooted by argv, etc. */ JSStackHeader *stackHeaders; /* Optional hook to find principals for an object being accessed on cx. */ JSObjectPrincipalsFinder findObjectPrincipals;};/* Slightly more readable macros, also to hide bitset implementation detail. */#define JS_HAS_STRICT_OPTION(cx) ((cx)->options & JSOPTION_STRICT)#define JS_HAS_WERROR_OPTION(cx) ((cx)->options & JSOPTION_WERROR)#define JS_HAS_COMPILE_N_GO_OPTION(cx) ((cx)->options & JSOPTION_COMPILE_N_GO)extern JSContext *js_NewContext(JSRuntime *rt, size_t stackChunkSize);extern voidjs_DestroyContext(JSContext *cx, JSGCMode gcmode);/* * Return true if cx points to a context in rt->contextList, else return false. * NB: the caller (see jslock.c:ClaimScope) must hold rt->gcLock. */extern JSBooljs_ValidContextPointer(JSRuntime *rt, JSContext *cx);/* * If unlocked, acquire and release rt->gcLock around *iterp update; otherwise * the caller must be holding rt->gcLock. */extern JSContext *js_ContextIterator(JSRuntime *rt, JSBool unlocked, JSContext **iterp);/* * Report an exception, which is currently realized as a printf-style format * string and its arguments. */typedef enum JSErrNum {#define MSG_DEF(name, number, count, exception, format) \ name = number,#include "js.msg"#undef MSG_DEF JSErr_Limit} JSErrNum;extern const JSErrorFormatString *js_GetErrorMessage(void *userRef, const char *locale, const uintN errorNumber);#ifdef va_startextern JSBooljs_ReportErrorVA(JSContext *cx, uintN flags, const char *format, va_list ap);extern JSBooljs_ReportErrorNumberVA(JSContext *cx, uintN flags, JSErrorCallback callback, void *userRef, const uintN errorNumber, JSBool charArgs, va_list ap);extern JSBooljs_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback, void *userRef, const uintN errorNumber, char **message, JSErrorReport *reportp, JSBool *warningp, JSBool charArgs, va_list ap);#endifextern voidjs_ReportOutOfMemory(JSContext *cx, JSErrorCallback errorCallback);/* * Report an exception using a previously composed JSErrorReport. * XXXbe remove from "friend" API */extern JS_FRIEND_API(void)js_ReportErrorAgain(JSContext *cx, const char *message, JSErrorReport *report);extern voidjs_ReportIsNotDefined(JSContext *cx, const char *name);extern JSErrorFormatString js_ErrorFormatString[JSErr_Limit];/* * See JS_SetThreadStackLimit in jsapi.c, where we check that the stack grows * in the expected direction. On Unix-y systems, JS_STACK_GROWTH_DIRECTION is * computed on the build host by jscpucfg.c and written into jsautocfg.h. The * macro is hardcoded in jscpucfg.h on Windows and Mac systems (for historical * reasons pre-dating autoconf usage). */#if JS_STACK_GROWTH_DIRECTION > 0# define JS_CHECK_STACK_SIZE(cx, lval) ((jsuword)&(lval) < (cx)->stackLimit)#else# define JS_CHECK_STACK_SIZE(cx, lval) ((jsuword)&(lval) > (cx)->stackLimit)#endifJS_END_EXTERN_C#endif /* jscntxt_h___ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -