📄 jscntxt.h
字号:
jsbytecode jsop_ne; /* 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; /* Storage to root recently allocated GC things and script result. */ JSWeakRoots weakRoots; /* 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 JSThread *thread; jsrefcount requestDepth; JSScope *scopeToShare; /* weak reference, see jslock.c */ JSScope *lockedSealedScope; /* weak ref, for low-cost sealed scope locking */ JSCList threadLinks; /* JSThread contextList linkage */#define CX_FROM_THREAD_LINKS(tl) \ ((JSContext *)((char *)(tl) - offsetof(JSContext, threadLinks)))#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#if JS_HAS_XML_SUPPORT /* * Bit-set formed from binary exponentials of the XML_* tiny-ids defined * for boolean settings in jsxml.c, plus an XSF_CACHE_VALID bit. Together * these act as a cache of the boolean XML.ignore* and XML.prettyPrinting * property values associated with this context's global object. */ uint8 xmlSettingFlags;#endif /* * True if creating an exception object, to prevent runaway recursion. * NB: creatingException packs with rval2set, #if JS_HAS_LVALUE_RETURN; * with xmlSettingFlags, #if JS_HAS_XML_SUPPORT; 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 */ /* Flag to indicate that we run inside gcCallback(cx, JSGC_MARK_END). */ JSPackedBool insideGCMarkCallback; /* 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 stack of heap-allocated scoped local GC roots. */ JSLocalRootStack *localRootStack; /* Stack of thread-stack-allocated temporary GC roots. */ JSTempValueRooter *tempValueRooters;#ifdef GC_MARK_DEBUG /* Top of the GC mark stack. */ void *gcCurrentMarkNode;#endif};#ifdef JS_THREADSAFE# define JS_THREAD_ID(cx) ((cx)->thread ? (cx)->thread->id : 0)#endif#ifdef __cplusplus/* FIXME(bug 332648): Move this into a public header. */class JSAutoTempValueRooter{ public: JSAutoTempValueRooter(JSContext *cx, size_t len, jsval *vec) : mContext(cx) { JS_PUSH_TEMP_ROOT(mContext, len, vec, &mTvr); } JSAutoTempValueRooter(JSContext *cx, jsval v) : mContext(cx) { JS_PUSH_SINGLE_TEMP_ROOT(mContext, v, &mTvr); } ~JSAutoTempValueRooter() { JS_POP_TEMP_ROOT(mContext, &mTvr); } private: static void *operator new(size_t); static void operator delete(void *, size_t); JSContext *mContext; JSTempValueRooter mTvr;};#endif/* * Slightly more readable macros for testing per-context option settings (also * to hide bitset implementation detail). * * JSOPTION_XML must be handled specially in order to propagate from compile- * to run-time (from cx->options to script->version/cx->version). To do that, * we copy JSOPTION_XML from cx->options into cx->version as JSVERSION_HAS_XML * whenever options are set, and preserve this XML flag across version number * changes done via the JS_SetVersion API. * * But when executing a script or scripted function, the interpreter changes * cx->version, including the XML flag, to script->version. Thus JSOPTION_XML * is a compile-time option that causes a run-time version change during each * activation of the compiled script. That version change has the effect of * changing JS_HAS_XML_OPTION, so that any compiling done via eval enables XML * support. If an XML-enabled script or function calls a non-XML function, * the flag bit will be cleared during the callee's activation. * * Note that JS_SetVersion API calls never pass JSVERSION_HAS_XML or'd into * that API's version parameter. * * Note also that script->version must contain this XML option flag in order * for XDR'ed scripts to serialize and deserialize with that option preserved * for detection at run-time. We can't copy other compile-time options into * script->version because that would break backward compatibility (certain * other options, e.g. JSOPTION_VAROBJFIX, are analogous to JSOPTION_XML). */#define JS_HAS_OPTION(cx,option) (((cx)->options & (option)) != 0)#define JS_HAS_STRICT_OPTION(cx) JS_HAS_OPTION(cx, JSOPTION_STRICT)#define JS_HAS_WERROR_OPTION(cx) JS_HAS_OPTION(cx, JSOPTION_WERROR)#define JS_HAS_COMPILE_N_GO_OPTION(cx) JS_HAS_OPTION(cx, JSOPTION_COMPILE_N_GO)#define JS_HAS_ATLINE_OPTION(cx) JS_HAS_OPTION(cx, JSOPTION_ATLINE)#define JSVERSION_MASK 0x0FFF /* see JSVersion in jspubtd.h */#define JSVERSION_HAS_XML 0x1000 /* flag induced by XML option */#define JSVERSION_NUMBER(cx) ((cx)->version & JSVERSION_MASK)#define JS_HAS_XML_OPTION(cx) ((cx)->version & JSVERSION_HAS_XML || \ JSVERSION_NUMBER(cx) >= JSVERSION_1_6)#define JS_HAS_NATIVE_BRANCH_CALLBACK_OPTION(cx) \ JS_HAS_OPTION(cx, JSOPTION_NATIVE_BRANCH_CALLBACK)/* * Wrappers for the JSVERSION_IS_* macros from jspubtd.h taking JSContext *cx * and masking off the XML flag and any other high order bits. */#define JS_VERSION_IS_ECMA(cx) JSVERSION_IS_ECMA(JSVERSION_NUMBER(cx))/* * Common subroutine of JS_SetVersion and js_SetVersion, to update per-context * data that depends on version. */extern voidjs_OnVersionChange(JSContext *cx);/* * Unlike the JS_SetVersion API, this function stores JSVERSION_HAS_XML and * any future non-version-number flags induced by compiler options. */extern voidjs_SetVersion(JSContext *cx, JSVersion version);/* * Create and destroy functions for JSContext, which is manually allocated * and exclusively owned. */extern JSContext *js_NewContext(JSRuntime *rt, size_t stackChunkSize);extern voidjs_DestroyContext(JSContext *cx, JSDestroyContextMode mode);/* * 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);/* * JSClass.resolve and watchpoint recursion damping machinery. */extern JSBooljs_StartResolving(JSContext *cx, JSResolvingKey *key, uint32 flag, JSResolvingEntry **entryp);extern voidjs_StopResolving(JSContext *cx, JSResolvingKey *key, uint32 flag, JSResolvingEntry *entry, uint32 generation);/* * Local root set management. * * NB: the jsval parameters below may be properly tagged jsvals, or GC-thing * pointers cast to (jsval). This relies on JSObject's tag being zero, but * on the up side it lets us push int-jsval-encoded scopeMark values on the * local root stack. */extern JSBooljs_EnterLocalRootScope(JSContext *cx);#define js_LeaveLocalRootScope(cx) \ js_LeaveLocalRootScopeWithResult(cx, JSVAL_NULL)extern voidjs_LeaveLocalRootScopeWithResult(JSContext *cx, jsval rval);extern voidjs_ForgetLocalRoot(JSContext *cx, jsval v);extern intjs_PushLocalRoot(JSContext *cx, JSLocalRootStack *lrs, jsval v);extern voidjs_MarkLocalRoots(JSContext *cx, JSLocalRootStack *lrs);/* * 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);/* * 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 + -