jsapi.h | jsapi.h | |||
---|---|---|---|---|
skipping to change at line 135 | skipping to change at line 135 | |||
object that delegates to a proto type | object that delegates to a proto type | |||
containing this property */ | containing this property */ | |||
#define JSPROP_INDEX 0x80 /* name is actually (jsint) index * / | #define JSPROP_INDEX 0x80 /* name is actually (jsint) index * / | |||
/* Function flags, set in JSFunctionSpec and passed to JS_NewFunction etc. */ | /* Function flags, set in JSFunctionSpec and passed to JS_NewFunction etc. */ | |||
#define JSFUN_LAMBDA 0x08 /* expressed, not declared, functio n */ | #define JSFUN_LAMBDA 0x08 /* expressed, not declared, functio n */ | |||
#define JSFUN_GETTER JSPROP_GETTER | #define JSFUN_GETTER JSPROP_GETTER | |||
#define JSFUN_SETTER JSPROP_SETTER | #define JSFUN_SETTER JSPROP_SETTER | |||
#define JSFUN_BOUND_METHOD 0x40 /* bind this to fun->object's paren t */ | #define JSFUN_BOUND_METHOD 0x40 /* bind this to fun->object's paren t */ | |||
#define JSFUN_HEAVYWEIGHT 0x80 /* activation requires a Call objec t */ | #define JSFUN_HEAVYWEIGHT 0x80 /* activation requires a Call objec t */ | |||
#define JSFUN_DISJOINT_FLAGS(f) ((f) & 0x0f) | ||||
#define JSFUN_GSFLAGS(f) ((f) & (JSFUN_GETTER | JSFUN_SETTER)) | ||||
#ifdef MOZILLA_1_8_BRANCH | ||||
/* | ||||
* Squeeze three more bits into existing 8-bit flags by taking advantage of | ||||
* the invalid combination (JSFUN_GETTER | JSFUN_SETTER). | ||||
*/ | ||||
#define JSFUN_GETTER_TEST(f) (JSFUN_GSFLAGS(f) == JSFUN_GETTER) | ||||
#define JSFUN_SETTER_TEST(f) (JSFUN_GSFLAGS(f) == JSFUN_SETTER) | ||||
#define JSFUN_FLAGS_TEST(f,t) (JSFUN_GSFLAGS(~(f)) ? (f) & (t) : 0) | ||||
#define JSFUN_BOUND_METHOD_TEST(f) JSFUN_FLAGS_TEST(f, JSFUN_BOUND_METHOD) | ||||
#define JSFUN_HEAVYWEIGHT_TEST(f) JSFUN_FLAGS_TEST(f, JSFUN_HEAVYWEIGHT) | ||||
#define JSFUN_GSFLAG2ATTR(f) (JSFUN_GETTER_TEST(f) ? JSPROP_GETTER : | ||||
\ | ||||
JSFUN_SETTER_TEST(f) ? JSPROP_SETTER : | ||||
0) | ||||
#define JSFUN_THISP_FLAGS(f) (JSFUN_GSFLAGS(~(f)) ? 0 : | ||||
\ | ||||
(f) & JSFUN_THISP_PRIMITIVE) | ||||
#define JSFUN_THISP_TEST(f,t) ((f) == (t) || (f) == JSFUN_THISP_PRIMITIVE | ||||
) | ||||
#define JSFUN_THISP_STRING 0x30 /* |this| may be a primitive string | ||||
*/ | ||||
#define JSFUN_THISP_NUMBER 0x70 /* |this| may be a primitive number | ||||
*/ | ||||
#define JSFUN_THISP_BOOLEAN 0xb0 /* |this| may be a primitive boolea | ||||
n */ | ||||
#define JSFUN_THISP_PRIMITIVE 0xf0 /* |this| may be any primitive valu | ||||
e */ | ||||
#define JSFUN_FLAGS_MASK 0xf8 /* overlay JSFUN_* attributes */ | #define JSFUN_FLAGS_MASK 0xf8 /* overlay JSFUN_* attributes */ | |||
#else | ||||
#define JSFUN_GETTER_TEST(f) ((f) & JSFUN_GETTER) | ||||
#define JSFUN_SETTER_TEST(f) ((f) & JSFUN_SETTER) | ||||
#define JSFUN_BOUND_METHOD_TEST(f) ((f) & JSFUN_BOUND_METHOD) | ||||
#define JSFUN_HEAVYWEIGHT_TEST(f) ((f) & JSFUN_HEAVYWEIGHT) | ||||
#define JSFUN_GSFLAG2ATTR(f) JSFUN_GSFLAGS(f) | ||||
#define JSFUN_THISP_FLAGS(f) (f) | ||||
#define JSFUN_THISP_TEST(f,t) ((f) & t) | ||||
#define JSFUN_THISP_STRING 0x0100 /* |this| may be a primitive string | ||||
*/ | ||||
#define JSFUN_THISP_NUMBER 0x0200 /* |this| may be a primitive number | ||||
*/ | ||||
#define JSFUN_THISP_BOOLEAN 0x0400 /* |this| may be a primitive boolea | ||||
n */ | ||||
#define JSFUN_THISP_PRIMITIVE 0x0700 /* |this| may be any primitive valu | ||||
e */ | ||||
#define JSFUN_FLAGS_MASK 0x07f8 /* overlay JSFUN_* attributes -- | ||||
note that bit #15 is used intern | ||||
ally | ||||
to flag interpreted functions */ | ||||
#endif | ||||
/* | ||||
* Re-use JSFUN_LAMBDA, which applies only to scripted functions, for use i | ||||
n | ||||
* JSFunctionSpec arrays that specify generic native prototype methods, i.e | ||||
., | ||||
* methods of a class prototype that are exposed as static methods taking a | ||||
n | ||||
* extra leading argument: the generic |this| parameter. | ||||
* | ||||
* If you set this flag in a JSFunctionSpec struct's flags initializer, the | ||||
n | ||||
* that struct must live at least as long as the native static method objec | ||||
t | ||||
* created due to this flag by JS_DefineFunctions or JS_InitClass. Typical | ||||
ly | ||||
* JSFunctionSpec structs are allocated in static arrays. | ||||
*/ | ||||
#define JSFUN_GENERIC_NATIVE JSFUN_LAMBDA | ||||
/* | /* | |||
* Well-known JS values. The extern'd variables are initialized when the | * Well-known JS values. The extern'd variables are initialized when the | |||
* first JSContext is created by JS_NewContext (see below). | * first JSContext is created by JS_NewContext (see below). | |||
*/ | */ | |||
#define JSVAL_VOID INT_TO_JSVAL(0 - JSVAL_INT_POW2(30)) | #define JSVAL_VOID INT_TO_JSVAL(0 - JSVAL_INT_POW2(30)) | |||
#define JSVAL_NULL OBJECT_TO_JSVAL(0) | #define JSVAL_NULL OBJECT_TO_JSVAL(0) | |||
#define JSVAL_ZERO INT_TO_JSVAL(0) | #define JSVAL_ZERO INT_TO_JSVAL(0) | |||
#define JSVAL_ONE INT_TO_JSVAL(1) | #define JSVAL_ONE INT_TO_JSVAL(1) | |||
#define JSVAL_FALSE BOOLEAN_TO_JSVAL(JS_FALSE) | #define JSVAL_FALSE BOOLEAN_TO_JSVAL(JS_FALSE) | |||
#define JSVAL_TRUE BOOLEAN_TO_JSVAL(JS_TRUE) | #define JSVAL_TRUE BOOLEAN_TO_JSVAL(JS_TRUE) | |||
skipping to change at line 380 | skipping to change at line 444 | |||
/* Yield to pending GC operations, regardless of request depth */ | /* Yield to pending GC operations, regardless of request depth */ | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_YieldRequest(JSContext *cx); | JS_YieldRequest(JSContext *cx); | |||
extern JS_PUBLIC_API(jsrefcount) | extern JS_PUBLIC_API(jsrefcount) | |||
JS_SuspendRequest(JSContext *cx); | JS_SuspendRequest(JSContext *cx); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_ResumeRequest(JSContext *cx, jsrefcount saveDepth); | JS_ResumeRequest(JSContext *cx, jsrefcount saveDepth); | |||
#ifdef __cplusplus | ||||
JS_END_EXTERN_C | ||||
class JSAutoRequest { | ||||
public: | ||||
JSAutoRequest(JSContext *cx) : mContext(cx), mSaveDepth(0) { | ||||
JS_BeginRequest(mContext); | ||||
} | ||||
~JSAutoRequest() { | ||||
JS_EndRequest(mContext); | ||||
} | ||||
void suspend() { | ||||
mSaveDepth = JS_SuspendRequest(mContext); | ||||
} | ||||
void resume() { | ||||
JS_ResumeRequest(mContext, mSaveDepth); | ||||
} | ||||
protected: | ||||
JSContext *mContext; | ||||
jsrefcount mSaveDepth; | ||||
#if 0 | ||||
private: | ||||
static void *operator new(size_t) CPP_THROW_NEW { return 0; }; | ||||
static void operator delete(void *, size_t) { }; | ||||
#endif | ||||
}; | ||||
JS_BEGIN_EXTERN_C | ||||
#endif | ||||
#endif /* JS_THREADSAFE */ | #endif /* JS_THREADSAFE */ | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_Lock(JSRuntime *rt); | JS_Lock(JSRuntime *rt); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_Unlock(JSRuntime *rt); | JS_Unlock(JSRuntime *rt); | |||
extern JS_PUBLIC_API(JSContextCallback) | ||||
JS_SetContextCallback(JSRuntime *rt, JSContextCallback cxCallback); | ||||
extern JS_PUBLIC_API(JSContext *) | extern JS_PUBLIC_API(JSContext *) | |||
JS_NewContext(JSRuntime *rt, size_t stackChunkSize); | JS_NewContext(JSRuntime *rt, size_t stackChunkSize); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_DestroyContext(JSContext *cx); | JS_DestroyContext(JSContext *cx); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_DestroyContextNoGC(JSContext *cx); | JS_DestroyContextNoGC(JSContext *cx); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
skipping to change at line 449 | skipping to change at line 549 | |||
to an nsISupports subcla ss */ | to an nsISupports subcla ss */ | |||
#define JSOPTION_COMPILE_N_GO JS_BIT(4) /* caller of JS_Compile*Scr ipt | #define JSOPTION_COMPILE_N_GO JS_BIT(4) /* caller of JS_Compile*Scr ipt | |||
promises to execute comp iled | promises to execute comp iled | |||
script once only; enable s | script once only; enable s | |||
compile-time scope chain | compile-time scope chain | |||
resolution of consts. */ | resolution of consts. */ | |||
#define JSOPTION_ATLINE JS_BIT(5) /* //@line number ["filenam e"] | #define JSOPTION_ATLINE JS_BIT(5) /* //@line number ["filenam e"] | |||
option supported for the | option supported for the | |||
XUL preprocessor and kin dred | XUL preprocessor and kin dred | |||
beasts. */ | beasts. */ | |||
#define JSOPTION_XML JS_BIT(6) /* EMCAScript for XML suppo | ||||
rt: | ||||
parse <!-- --> as a toke | ||||
n, | ||||
not backward compatible | ||||
with | ||||
the comment-hiding hack | ||||
used | ||||
in HTML script tags. */ | ||||
#define JSOPTION_NATIVE_BRANCH_CALLBACK \ | ||||
JS_BIT(7) /* the branch callback set | ||||
by | ||||
JS_SetBranchCallback may | ||||
be | ||||
called with a null scrip | ||||
t | ||||
parameter, by native cod | ||||
e | ||||
that loops intensively * | ||||
/ | ||||
#define JSOPTION_DONT_REPORT_UNCAUGHT \ | ||||
JS_BIT(8) /* When returning from the | ||||
outermost API call, prev | ||||
ent | ||||
uncaught exceptions from | ||||
being converted to error | ||||
reports */ | ||||
extern JS_PUBLIC_API(uint32) | extern JS_PUBLIC_API(uint32) | |||
JS_GetOptions(JSContext *cx); | JS_GetOptions(JSContext *cx); | |||
extern JS_PUBLIC_API(uint32) | extern JS_PUBLIC_API(uint32) | |||
JS_SetOptions(JSContext *cx, uint32 options); | JS_SetOptions(JSContext *cx, uint32 options); | |||
extern JS_PUBLIC_API(uint32) | extern JS_PUBLIC_API(uint32) | |||
JS_ToggleOptions(JSContext *cx, uint32 options); | JS_ToggleOptions(JSContext *cx, uint32 options); | |||
skipping to change at line 498 | skipping to change at line 615 | |||
* JS_EnumerateStandardClasses(cx, obj), to define eagerly during for..in | * JS_EnumerateStandardClasses(cx, obj), to define eagerly during for..in | |||
* loops any classes not yet resolved lazily. | * loops any classes not yet resolved lazily. | |||
*/ | */ | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_ResolveStandardClass(JSContext *cx, JSObject *obj, jsval id, | JS_ResolveStandardClass(JSContext *cx, JSObject *obj, jsval id, | |||
JSBool *resolved); | JSBool *resolved); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_EnumerateStandardClasses(JSContext *cx, JSObject *obj); | JS_EnumerateStandardClasses(JSContext *cx, JSObject *obj); | |||
/* | ||||
* Enumerate any already-resolved standard class ids into ida, or into a ne | ||||
w | ||||
* JSIdArray if ida is null. Return the augmented array on success, null o | ||||
n | ||||
* failure with ida (if it was non-null on entry) destroyed. | ||||
*/ | ||||
extern JS_PUBLIC_API(JSIdArray *) | ||||
JS_EnumerateResolvedStandardClasses(JSContext *cx, JSObject *obj, | ||||
JSIdArray *ida); | ||||
extern JS_PUBLIC_API(JSBool) | ||||
JS_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, | ||||
JSObject **objp); | ||||
extern JS_PUBLIC_API(JSObject *) | extern JS_PUBLIC_API(JSObject *) | |||
JS_GetScopeChain(JSContext *cx); | JS_GetScopeChain(JSContext *cx); | |||
extern JS_PUBLIC_API(void *) | extern JS_PUBLIC_API(void *) | |||
JS_malloc(JSContext *cx, size_t nbytes); | JS_malloc(JSContext *cx, size_t nbytes); | |||
extern JS_PUBLIC_API(void *) | extern JS_PUBLIC_API(void *) | |||
JS_realloc(JSContext *cx, void *p, size_t nbytes); | JS_realloc(JSContext *cx, void *p, size_t nbytes); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
skipping to change at line 608 | skipping to change at line 738 | |||
* return JS_FALSE; | * return JS_FALSE; | |||
* ok = my_GetPropertyBody(cx, obj, id, vp); | * ok = my_GetPropertyBody(cx, obj, id, vp); | |||
* JS_LeaveLocalRootScope(cx); | * JS_LeaveLocalRootScope(cx); | |||
* return ok; | * return ok; | |||
* } | * } | |||
* | * | |||
* NB: JS_LeaveLocalRootScope must be called once for every prior successfu l | * NB: JS_LeaveLocalRootScope must be called once for every prior successfu l | |||
* call to JS_EnterLocalRootScope. If JS_EnterLocalRootScope fails, you mu st | * call to JS_EnterLocalRootScope. If JS_EnterLocalRootScope fails, you mu st | |||
* not make the matching JS_LeaveLocalRootScope call. | * not make the matching JS_LeaveLocalRootScope call. | |||
* | * | |||
* JS_LeaveLocalRootScopeWithResult(cx, rval) is an alternative way to leav | ||||
e | ||||
* a local root scope that protects a result or return value, by effectivel | ||||
y | ||||
* pushing it in the caller's local root scope. | ||||
* | ||||
* In case a native hook allocates many objects or other GC-things, but the | * In case a native hook allocates many objects or other GC-things, but the | |||
* native protects some of those GC-things by storing them as property valu es | * native protects some of those GC-things by storing them as property valu es | |||
* in an object that is itself protected, the hook can call JS_ForgetLocalR oot | * in an object that is itself protected, the hook can call JS_ForgetLocalR oot | |||
* to free the local root automatically pushed for the now-protected GC-thi ng. | * to free the local root automatically pushed for the now-protected GC-thi ng. | |||
* | * | |||
* JS_ForgetLocalRoot works on any GC-thing allocated in the current local | * JS_ForgetLocalRoot works on any GC-thing allocated in the current local | |||
* root scope, but it's more time-efficient when called on references to mo re | * root scope, but it's more time-efficient when called on references to mo re | |||
* recently created GC-things. Calling it successively on other than the m ost | * recently created GC-things. Calling it successively on other than the m ost | |||
* recently allocated GC-thing will tend to average the time inefficiency, and | * recently allocated GC-thing will tend to average the time inefficiency, and | |||
* may risk O(n^2) growth rate, but in any event, you shouldn't allocate to o | * may risk O(n^2) growth rate, but in any event, you shouldn't allocate to o | |||
skipping to change at line 629 | skipping to change at line 763 | |||
* the top down, forgetting each latest-allocated GC-thing immediately upon | * the top down, forgetting each latest-allocated GC-thing immediately upon | |||
* linking it to its parent). | * linking it to its parent). | |||
*/ | */ | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_EnterLocalRootScope(JSContext *cx); | JS_EnterLocalRootScope(JSContext *cx); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_LeaveLocalRootScope(JSContext *cx); | JS_LeaveLocalRootScope(JSContext *cx); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_LeaveLocalRootScopeWithResult(JSContext *cx, jsval rval); | ||||
extern JS_PUBLIC_API(void) | ||||
JS_ForgetLocalRoot(JSContext *cx, void *thing); | JS_ForgetLocalRoot(JSContext *cx, void *thing); | |||
#ifdef __cplusplus | ||||
JS_END_EXTERN_C | ||||
class JSAutoLocalRootScope { | ||||
public: | ||||
JSAutoLocalRootScope(JSContext *cx) : mContext(cx) { | ||||
JS_EnterLocalRootScope(mContext); | ||||
} | ||||
~JSAutoLocalRootScope() { | ||||
JS_LeaveLocalRootScope(mContext); | ||||
} | ||||
void forget(void *thing) { | ||||
JS_ForgetLocalRoot(mContext, thing); | ||||
} | ||||
protected: | ||||
JSContext *mContext; | ||||
#if 0 | ||||
private: | ||||
static void *operator new(size_t) CPP_THROW_NEW { return 0; }; | ||||
static void operator delete(void *, size_t) { }; | ||||
#endif | ||||
}; | ||||
JS_BEGIN_EXTERN_C | ||||
#endif | ||||
#ifdef DEBUG | #ifdef DEBUG | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_DumpNamedRoots(JSRuntime *rt, | JS_DumpNamedRoots(JSRuntime *rt, | |||
void (*dump)(const char *name, void *rp, void *data), | void (*dump)(const char *name, void *rp, void *data), | |||
void *data); | void *data); | |||
#endif | #endif | |||
/* | /* | |||
* Call JS_MapGCRoots to map the GC's roots table using map(rp, name, data) . | * Call JS_MapGCRoots to map the GC's roots table using map(rp, name, data) . | |||
* The root is pointed at by rp; if the root is unnamed, name is null; data is | * The root is pointed at by rp; if the root is unnamed, name is null; data is | |||
skipping to change at line 709 | skipping to change at line 875 | |||
extern JS_PUBLIC_API(JSGCCallback) | extern JS_PUBLIC_API(JSGCCallback) | |||
JS_SetGCCallback(JSContext *cx, JSGCCallback cb); | JS_SetGCCallback(JSContext *cx, JSGCCallback cb); | |||
extern JS_PUBLIC_API(JSGCCallback) | extern JS_PUBLIC_API(JSGCCallback) | |||
JS_SetGCCallbackRT(JSRuntime *rt, JSGCCallback cb); | JS_SetGCCallbackRT(JSRuntime *rt, JSGCCallback cb); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_IsAboutToBeFinalized(JSContext *cx, void *thing); | JS_IsAboutToBeFinalized(JSContext *cx, void *thing); | |||
typedef enum JSGCParamKey { | ||||
JSGC_MAX_BYTES = 0, /* maximum nominal heap before last ditch G | ||||
C */ | ||||
JSGC_MAX_MALLOC_BYTES = 1 /* # of JS_malloc bytes before last ditch G | ||||
C */ | ||||
} JSGCParamKey; | ||||
extern JS_PUBLIC_API(void) | ||||
JS_SetGCParameter(JSRuntime *rt, JSGCParamKey key, uint32 value); | ||||
/* | /* | |||
* Add an external string finalizer, one created by JS_NewExternalString (s ee | * Add a finalizer for external strings created by JS_NewExternalString (se e | |||
* below) using a type-code returned from this function, and that understan ds | * below) using a type-code returned from this function, and that understan ds | |||
* how to free or release the memory pointed at by JS_GetStringChars(str). | * how to free or release the memory pointed at by JS_GetStringChars(str). | |||
* | * | |||
* Return a nonnegative type index if there is room for finalizer in the | * Return a nonnegative type index if there is room for finalizer in the | |||
* global GC finalizers table, else return -1. If the engine is compiled | * global GC finalizers table, else return -1. If the engine is compiled | |||
* JS_THREADSAFE and used in a multi-threaded environment, this function mu st | * JS_THREADSAFE and used in a multi-threaded environment, this function mu st | |||
* be invoked on the primordial thread only, at startup -- or else the enti re | * be invoked on the primordial thread only, at startup -- or else the enti re | |||
* program must single-thread itself while loading a module that calls this | * program must single-thread itself while loading a module that calls this | |||
* function. | * function. | |||
*/ | */ | |||
skipping to change at line 795 | skipping to change at line 969 | |||
JSGetObjectOps getObjectOps; | JSGetObjectOps getObjectOps; | |||
JSCheckAccessOp checkAccess; | JSCheckAccessOp checkAccess; | |||
JSNative call; | JSNative call; | |||
JSNative construct; | JSNative construct; | |||
JSXDRObjectOp xdrObject; | JSXDRObjectOp xdrObject; | |||
JSHasInstanceOp hasInstance; | JSHasInstanceOp hasInstance; | |||
JSMarkOp mark; | JSMarkOp mark; | |||
JSReserveSlotsOp reserveSlots; | JSReserveSlotsOp reserveSlots; | |||
}; | }; | |||
struct JSExtendedClass { | ||||
JSClass base; | ||||
JSEqualityOp equality; | ||||
JSObjectOp outerObject; | ||||
JSObjectOp innerObject; | ||||
void (*reserved0)(); | ||||
void (*reserved1)(); | ||||
void (*reserved2)(); | ||||
void (*reserved3)(); | ||||
void (*reserved4)(); | ||||
}; | ||||
#define JSCLASS_HAS_PRIVATE (1<<0) /* objects have private slo t */ | #define JSCLASS_HAS_PRIVATE (1<<0) /* objects have private slo t */ | |||
#define JSCLASS_NEW_ENUMERATE (1<<1) /* has JSNewEnumerateOp hoo k */ | #define JSCLASS_NEW_ENUMERATE (1<<1) /* has JSNewEnumerateOp hoo k */ | |||
#define JSCLASS_NEW_RESOLVE (1<<2) /* has JSNewResolveOp hook */ | #define JSCLASS_NEW_RESOLVE (1<<2) /* has JSNewResolveOp hook */ | |||
#define JSCLASS_PRIVATE_IS_NSISUPPORTS (1<<3) /* private is (nsISupports *) */ | #define JSCLASS_PRIVATE_IS_NSISUPPORTS (1<<3) /* private is (nsISupports *) */ | |||
#define JSCLASS_SHARE_ALL_PROPERTIES (1<<4) /* all properties are SHARE D */ | #define JSCLASS_SHARE_ALL_PROPERTIES (1<<4) /* all properties are SHARE D */ | |||
#define JSCLASS_NEW_RESOLVE_GETS_START (1<<5) /* JSNewResolveOp gets star ting | #define JSCLASS_NEW_RESOLVE_GETS_START (1<<5) /* JSNewResolveOp gets star ting | |||
object in prototype chai n | object in prototype chai n | |||
passed in via *objp in/o ut | passed in via *objp in/o ut | |||
parameter */ | parameter */ | |||
#define JSCLASS_CONSTRUCT_PROTOTYPE (1<<6) /* call constructor on clas | ||||
s | ||||
prototype */ | ||||
#define JSCLASS_DOCUMENT_OBSERVER (1<<7) /* DOM document observer */ | ||||
/* | /* | |||
* To reserve slots fetched and stored via JS_Get/SetReservedSlot, bitwise- or | * To reserve slots fetched and stored via JS_Get/SetReservedSlot, bitwise- or | |||
* JSCLASS_HAS_RESERVED_SLOTS(n) into the initializer for JSClass.flags, wh ere | * JSCLASS_HAS_RESERVED_SLOTS(n) into the initializer for JSClass.flags, wh ere | |||
* n is a constant in [1, 255]. Reserved slots are indexed from 0 to n-1. | * n is a constant in [1, 255]. Reserved slots are indexed from 0 to n-1. | |||
*/ | */ | |||
#define JSCLASS_RESERVED_SLOTS_SHIFT 8 /* room for 8 flags below * / | #define JSCLASS_RESERVED_SLOTS_SHIFT 8 /* room for 8 flags below * / | |||
#define JSCLASS_RESERVED_SLOTS_WIDTH 8 /* and 16 above this field */ | #define JSCLASS_RESERVED_SLOTS_WIDTH 8 /* and 16 above this field */ | |||
#define JSCLASS_RESERVED_SLOTS_MASK JS_BITMASK(JSCLASS_RESERVED_SLOTS_W IDTH) | #define JSCLASS_RESERVED_SLOTS_MASK JS_BITMASK(JSCLASS_RESERVED_SLOTS_W IDTH) | |||
#define JSCLASS_HAS_RESERVED_SLOTS(n) (((n) & JSCLASS_RESERVED_SLOTS_MASK ) \ | #define JSCLASS_HAS_RESERVED_SLOTS(n) (((n) & JSCLASS_RESERVED_SLOTS_MASK ) \ | |||
<< JSCLASS_RESERVED_SLOTS_SHIFT) | << JSCLASS_RESERVED_SLOTS_SHIFT) | |||
#define JSCLASS_RESERVED_SLOTS(clasp) (((clasp)->flags \ | #define JSCLASS_RESERVED_SLOTS(clasp) (((clasp)->flags \ | |||
>> JSCLASS_RESERVED_SLOTS_SHIFT) \ | >> JSCLASS_RESERVED_SLOTS_SHIFT) \ | |||
& JSCLASS_RESERVED_SLOTS_MASK) | & JSCLASS_RESERVED_SLOTS_MASK) | |||
#define JSCLASS_HIGH_FLAGS_SHIFT (JSCLASS_RESERVED_SLOTS_SHIFT + | ||||
\ | ||||
JSCLASS_RESERVED_SLOTS_WIDTH) | ||||
/* True if JSClass is really a JSExtendedClass. */ | ||||
#define JSCLASS_IS_EXTENDED (1<<(JSCLASS_HIGH_FLAGS_SHIFT+0)) | ||||
#define JSCLASS_IS_ANONYMOUS (1<<(JSCLASS_HIGH_FLAGS_SHIFT+1)) | ||||
#define JSCLASS_IS_GLOBAL (1<<(JSCLASS_HIGH_FLAGS_SHIFT+2)) | ||||
/* | ||||
* ECMA-262 requires that most constructors used internally create objects | ||||
* with "the original Foo.prototype value" as their [[Prototype]] (__proto_ | ||||
_) | ||||
* member initial value. The "original ... value" verbiage is there becaus | ||||
e | ||||
* in ECMA-262, global properties naming class objects are read/write and | ||||
* deleteable, for the most part. | ||||
* | ||||
* Implementing this efficiently requires that global objects have classes | ||||
* with the following flags. Failure to use JSCLASS_GLOBAL_FLAGS won't bre | ||||
ak | ||||
* anything except the ECMA-262 "original prototype value" behavior, which | ||||
was | ||||
* broken for years in SpiderMonkey. In other words, without these flags y | ||||
ou | ||||
* get backward compatibility. | ||||
*/ | ||||
#define JSCLASS_GLOBAL_FLAGS \ | ||||
(JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSProto_LIMIT)) | ||||
/* Fast access to the original value of each standard class's prototype. */ | ||||
#define JSCLASS_CACHED_PROTO_SHIFT (JSCLASS_HIGH_FLAGS_SHIFT + 8) | ||||
#define JSCLASS_CACHED_PROTO_WIDTH 8 | ||||
#define JSCLASS_CACHED_PROTO_MASK JS_BITMASK(JSCLASS_CACHED_PROTO_WID | ||||
TH) | ||||
#define JSCLASS_HAS_CACHED_PROTO(key) ((key) << JSCLASS_CACHED_PROTO_SHIF | ||||
T) | ||||
#define JSCLASS_CACHED_PROTO_KEY(clasp) (((clasp)->flags | ||||
\ | ||||
>> JSCLASS_CACHED_PROTO_SHIFT) | ||||
\ | ||||
& JSCLASS_CACHED_PROTO_MASK) | ||||
/* Initializer for unused members of statically initialized JSClass structs . */ | /* Initializer for unused members of statically initialized JSClass structs . */ | |||
#define JSCLASS_NO_OPTIONAL_MEMBERS 0,0,0,0,0,0,0,0 | #define JSCLASS_NO_OPTIONAL_MEMBERS 0,0,0,0,0,0,0,0 | |||
#define JSCLASS_NO_RESERVED_MEMBERS 0,0,0,0,0 | ||||
/* For detailed comments on these function pointer types, see jspubtd.h. */ | /* For detailed comments on these function pointer types, see jspubtd.h. */ | |||
struct JSObjectOps { | struct JSObjectOps { | |||
/* Mandatory non-null function pointer members. */ | /* Mandatory non-null function pointer members. */ | |||
JSNewObjectMapOp newObjectMap; | JSNewObjectMapOp newObjectMap; | |||
JSObjectMapOp destroyObjectMap; | JSObjectMapOp destroyObjectMap; | |||
JSLookupPropOp lookupProperty; | JSLookupPropOp lookupProperty; | |||
JSDefinePropOp defineProperty; | JSDefinePropOp defineProperty; | |||
JSPropertyIdOp getProperty; | JSPropertyIdOp getProperty; | |||
JSPropertyIdOp setProperty; | JSPropertyIdOp setProperty; | |||
skipping to change at line 853 | skipping to change at line 1076 | |||
JSXDRObjectOp xdrObject; | JSXDRObjectOp xdrObject; | |||
JSHasInstanceOp hasInstance; | JSHasInstanceOp hasInstance; | |||
JSSetObjectSlotOp setProto; | JSSetObjectSlotOp setProto; | |||
JSSetObjectSlotOp setParent; | JSSetObjectSlotOp setParent; | |||
JSMarkOp mark; | JSMarkOp mark; | |||
JSFinalizeOp clear; | JSFinalizeOp clear; | |||
JSGetRequiredSlotOp getRequiredSlot; | JSGetRequiredSlotOp getRequiredSlot; | |||
JSSetRequiredSlotOp setRequiredSlot; | JSSetRequiredSlotOp setRequiredSlot; | |||
}; | }; | |||
struct JSXMLObjectOps { | ||||
JSObjectOps base; | ||||
JSGetMethodOp getMethod; | ||||
JSSetMethodOp setMethod; | ||||
JSEnumerateValuesOp enumerateValues; | ||||
JSEqualityOp equality; | ||||
JSConcatenateOp concatenate; | ||||
}; | ||||
/* | /* | |||
* Classes that expose JSObjectOps via a non-null getObjectOps class hook m ay | * Classes that expose JSObjectOps via a non-null getObjectOps class hook m ay | |||
* derive a property structure from this struct, return a pointer to it fro m | * derive a property structure from this struct, return a pointer to it fro m | |||
* lookupProperty and defineProperty, and use the pointer to avoid rehashin g | * lookupProperty and defineProperty, and use the pointer to avoid rehashin g | |||
* in getAttributes and setAttributes. | * in getAttributes and setAttributes. | |||
* | * | |||
* The jsid type contains either an int jsval (see JSVAL_IS_INT above), or an | * The jsid type contains either an int jsval (see JSVAL_IS_INT above), or an | |||
* internal pointer that is opaque to users of this API, but which users ma y | * internal pointer that is opaque to users of this API, but which users ma y | |||
* convert from and to a jsval using JS_ValueToId and JS_IdToValue. | * convert from and to a jsval using JS_ValueToId and JS_IdToValue. | |||
*/ | */ | |||
skipping to change at line 881 | skipping to change at line 1113 | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_DestroyIdArray(JSContext *cx, JSIdArray *ida); | JS_DestroyIdArray(JSContext *cx, JSIdArray *ida); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_ValueToId(JSContext *cx, jsval v, jsid *idp); | JS_ValueToId(JSContext *cx, jsval v, jsid *idp); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_IdToValue(JSContext *cx, jsid id, jsval *vp); | JS_IdToValue(JSContext *cx, jsid id, jsval *vp); | |||
/* | ||||
* The magic XML namespace id is int-tagged, but not a valid integer jsval. | ||||
* Global object classes in embeddings that enable JS_HAS_XML_SUPPORT (E4X) | ||||
* should handle this id specially before converting id via JSVAL_TO_INT. | ||||
*/ | ||||
#define JS_DEFAULT_XML_NAMESPACE_ID ((jsid) JSVAL_VOID) | ||||
/* | ||||
* JSNewResolveOp flag bits. | ||||
*/ | ||||
#define JSRESOLVE_QUALIFIED 0x01 /* resolve a qualified property id */ | #define JSRESOLVE_QUALIFIED 0x01 /* resolve a qualified property id */ | |||
#define JSRESOLVE_ASSIGNING 0x02 /* resolve on the left of assignmen t */ | #define JSRESOLVE_ASSIGNING 0x02 /* resolve on the left of assignmen t */ | |||
#define JSRESOLVE_DETECTING 0x04 /* 'if (o.p)...' or '(o.p) ?...:... ' */ | #define JSRESOLVE_DETECTING 0x04 /* 'if (o.p)...' or '(o.p) ?...:... ' */ | |||
#define JSRESOLVE_DECLARING 0x08 /* var, const, or function prolog o p */ | #define JSRESOLVE_DECLARING 0x08 /* var, const, or function prolog o p */ | |||
#define JSRESOLVE_CLASSNAME 0x10 /* class name used when constructin g */ | #define JSRESOLVE_CLASSNAME 0x10 /* class name used when constructin g */ | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_PropertyStub(JSContext *cx, JSObject *obj, jsval id, jsval *vp); | JS_PropertyStub(JSContext *cx, JSObject *obj, jsval id, jsval *vp); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
skipping to change at line 925 | skipping to change at line 1167 | |||
const char *name; | const char *name; | |||
int8 tinyid; | int8 tinyid; | |||
uint8 flags; | uint8 flags; | |||
JSPropertyOp getter; | JSPropertyOp getter; | |||
JSPropertyOp setter; | JSPropertyOp setter; | |||
}; | }; | |||
struct JSFunctionSpec { | struct JSFunctionSpec { | |||
const char *name; | const char *name; | |||
JSNative call; | JSNative call; | |||
#ifdef MOZILLA_1_8_BRANCH | ||||
uint8 nargs; | uint8 nargs; | |||
uint8 flags; | uint8 flags; | |||
uint16 extra; /* number of arg slots for local GC roots * | uint16 extra; | |||
/ | #else | |||
uint16 nargs; | ||||
uint16 flags; | ||||
uint32 extra; /* extra & 0xFFFF: | ||||
number of arg slots for local GC roots | ||||
extra >> 16: | ||||
reserved, must be zero */ | ||||
#endif | ||||
}; | }; | |||
extern JS_PUBLIC_API(JSObject *) | extern JS_PUBLIC_API(JSObject *) | |||
JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto, | JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto, | |||
JSClass *clasp, JSNative constructor, uintN nargs, | JSClass *clasp, JSNative constructor, uintN nargs, | |||
JSPropertySpec *ps, JSFunctionSpec *fs, | JSPropertySpec *ps, JSFunctionSpec *fs, | |||
JSPropertySpec *static_ps, JSFunctionSpec *static_fs); | JSPropertySpec *static_ps, JSFunctionSpec *static_fs); | |||
#ifdef JS_THREADSAFE | #ifdef JS_THREADSAFE | |||
extern JS_PUBLIC_API(JSClass *) | extern JS_PUBLIC_API(JSClass *) | |||
skipping to change at line 951 | skipping to change at line 1202 | |||
#else | #else | |||
extern JS_PUBLIC_API(JSClass *) | extern JS_PUBLIC_API(JSClass *) | |||
JS_GetClass(JSObject *obj); | JS_GetClass(JSObject *obj); | |||
#define JS_GET_CLASS(cx,obj) JS_GetClass(obj) | #define JS_GET_CLASS(cx,obj) JS_GetClass(obj) | |||
#endif | #endif | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_InstanceOf(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv); | JS_InstanceOf(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv); | |||
extern JS_PUBLIC_API(JSBool) | ||||
JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); | ||||
extern JS_PUBLIC_API(void *) | extern JS_PUBLIC_API(void *) | |||
JS_GetPrivate(JSContext *cx, JSObject *obj); | JS_GetPrivate(JSContext *cx, JSObject *obj); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_SetPrivate(JSContext *cx, JSObject *obj, void *data); | JS_SetPrivate(JSContext *cx, JSObject *obj, void *data); | |||
extern JS_PUBLIC_API(void *) | extern JS_PUBLIC_API(void *) | |||
JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp, | JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp, | |||
jsval *argv); | jsval *argv); | |||
skipping to change at line 1023 | skipping to change at line 1277 | |||
* Determine the attributes (JSPROP_* flags) of a property on a given objec t. | * Determine the attributes (JSPROP_* flags) of a property on a given objec t. | |||
* | * | |||
* If the object does not have a property by that name, *foundp will be | * If the object does not have a property by that name, *foundp will be | |||
* JS_FALSE and the value of *attrsp is undefined. | * JS_FALSE and the value of *attrsp is undefined. | |||
*/ | */ | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_GetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, | JS_GetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, | |||
uintN *attrsp, JSBool *foundp); | uintN *attrsp, JSBool *foundp); | |||
/* | /* | |||
* The same, but if the property is native, return its getter and setter vi | ||||
a | ||||
* *getterp and *setterp, respectively (and only if the out parameter point | ||||
er | ||||
* is not null). | ||||
*/ | ||||
extern JS_PUBLIC_API(JSBool) | ||||
JS_GetPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj, | ||||
const char *name, | ||||
uintN *attrsp, JSBool *foundp, | ||||
JSPropertyOp *getterp, | ||||
JSPropertyOp *setterp); | ||||
/* | ||||
* Set the attributes of a property on a given object. | * Set the attributes of a property on a given object. | |||
* | * | |||
* If the object does not have a property by that name, *foundp will be | * If the object does not have a property by that name, *foundp will be | |||
* JS_FALSE and nothing will be altered. | * JS_FALSE and nothing will be altered. | |||
*/ | */ | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_SetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, | JS_SetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, | |||
uintN attrs, JSBool *foundp); | uintN attrs, JSBool *foundp); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
skipping to change at line 1056 | skipping to change at line 1322 | |||
JS_LookupProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp ); | JS_LookupProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp ); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, const char *name, | JS_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, const char *name, | |||
uintN flags, jsval *vp); | uintN flags, jsval *vp); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_GetProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp); | JS_GetProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_GetMethodById(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, | ||||
jsval *vp); | ||||
extern JS_PUBLIC_API(JSBool) | ||||
JS_GetMethod(JSContext *cx, JSObject *obj, const char *name, JSObject **obj | ||||
p, | ||||
jsval *vp); | ||||
extern JS_PUBLIC_API(JSBool) | ||||
JS_SetProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp); | JS_SetProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_DeleteProperty(JSContext *cx, JSObject *obj, const char *name); | JS_DeleteProperty(JSContext *cx, JSObject *obj, const char *name); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_DeleteProperty2(JSContext *cx, JSObject *obj, const char *name, | JS_DeleteProperty2(JSContext *cx, JSObject *obj, const char *name, | |||
jsval *rval); | jsval *rval); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
skipping to change at line 1083 | skipping to change at line 1357 | |||
* | * | |||
* If the object does not have a property by that name, *foundp will be | * If the object does not have a property by that name, *foundp will be | |||
* JS_FALSE and the value of *attrsp is undefined. | * JS_FALSE and the value of *attrsp is undefined. | |||
*/ | */ | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_GetUCPropertyAttributes(JSContext *cx, JSObject *obj, | JS_GetUCPropertyAttributes(JSContext *cx, JSObject *obj, | |||
const jschar *name, size_t namelen, | const jschar *name, size_t namelen, | |||
uintN *attrsp, JSBool *foundp); | uintN *attrsp, JSBool *foundp); | |||
/* | /* | |||
* The same, but if the property is native, return its getter and setter vi | ||||
a | ||||
* *getterp and *setterp, respectively (and only if the out parameter point | ||||
er | ||||
* is not null). | ||||
*/ | ||||
extern JS_PUBLIC_API(JSBool) | ||||
JS_GetUCPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj, | ||||
const jschar *name, size_t namelen, | ||||
uintN *attrsp, JSBool *foundp, | ||||
JSPropertyOp *getterp, | ||||
JSPropertyOp *setterp); | ||||
/* | ||||
* Set the attributes of a property on a given object. | * Set the attributes of a property on a given object. | |||
* | * | |||
* If the object does not have a property by that name, *foundp will be | * If the object does not have a property by that name, *foundp will be | |||
* JS_FALSE and nothing will be altered. | * JS_FALSE and nothing will be altered. | |||
*/ | */ | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_SetUCPropertyAttributes(JSContext *cx, JSObject *obj, | JS_SetUCPropertyAttributes(JSContext *cx, JSObject *obj, | |||
const jschar *name, size_t namelen, | const jschar *name, size_t namelen, | |||
uintN attrs, JSBool *foundp); | uintN attrs, JSBool *foundp); | |||
skipping to change at line 1171 | skipping to change at line 1457 | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_DeleteElement2(JSContext *cx, JSObject *obj, jsint index, jsval *rval); | JS_DeleteElement2(JSContext *cx, JSObject *obj, jsint index, jsval *rval); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_ClearScope(JSContext *cx, JSObject *obj); | JS_ClearScope(JSContext *cx, JSObject *obj); | |||
extern JS_PUBLIC_API(JSIdArray *) | extern JS_PUBLIC_API(JSIdArray *) | |||
JS_Enumerate(JSContext *cx, JSObject *obj); | JS_Enumerate(JSContext *cx, JSObject *obj); | |||
/* | ||||
* Create an object to iterate over enumerable properties of obj, in arbitr | ||||
ary | ||||
* property definition order. NB: This differs from longstanding for..in l | ||||
oop | ||||
* order, which uses order of property definition in obj. | ||||
*/ | ||||
extern JS_PUBLIC_API(JSObject *) | ||||
JS_NewPropertyIterator(JSContext *cx, JSObject *obj); | ||||
/* | ||||
* Return true on success with *idp containing the id of the next enumerabl | ||||
e | ||||
* property to visit using iterobj, or JSVAL_VOID if there is no such prope | ||||
rty | ||||
* left to visit. Return false on error. | ||||
*/ | ||||
extern JS_PUBLIC_API(JSBool) | ||||
JS_NextProperty(JSContext *cx, JSObject *iterobj, jsid *idp); | ||||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, | JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, | |||
jsval *vp, uintN *attrsp); | jsval *vp, uintN *attrsp); | |||
extern JS_PUBLIC_API(JSCheckAccessOp) | extern JS_PUBLIC_API(JSCheckAccessOp) | |||
JS_SetCheckObjectAccessCallback(JSRuntime *rt, JSCheckAccessOp acb); | JS_SetCheckObjectAccessCallback(JSRuntime *rt, JSCheckAccessOp acb); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_GetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval *vp); | JS_GetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval *vp); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_SetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval v); | JS_SetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval v); | |||
/************************************************************************/ | /************************************************************************/ | |||
/* | /* | |||
* Security protocol. | * Security protocol. | |||
*/ | */ | |||
struct JSPrincipals { | struct JSPrincipals { | |||
char *codebase; | char *codebase; | |||
/* XXX unspecified and unused by Mozilla code -- can we remove these? * | ||||
/ | ||||
void * (* JS_DLL_CALLBACK getPrincipalArray)(JSContext *cx, JSPrincipal s *); | void * (* JS_DLL_CALLBACK getPrincipalArray)(JSContext *cx, JSPrincipal s *); | |||
JSBool (* JS_DLL_CALLBACK globalPrivilegesEnabled)(JSContext *cx, JSPri ncipals *); | JSBool (* JS_DLL_CALLBACK globalPrivilegesEnabled)(JSContext *cx, JSPri ncipals *); | |||
/* Don't call "destroy"; use reference counting macros below. */ | /* Don't call "destroy"; use reference counting macros below. */ | |||
jsrefcount refcount; | jsrefcount refcount; | |||
void (* JS_DLL_CALLBACK destroy)(JSContext *cx, struct JSPrincipals *); | ||||
void (* JS_DLL_CALLBACK destroy)(JSContext *cx, JSPrincipals *); | ||||
JSBool (* JS_DLL_CALLBACK subsume)(JSPrincipals *, JSPrincipals *); | ||||
}; | }; | |||
#ifdef JS_THREADSAFE | #ifdef JS_THREADSAFE | |||
#define JSPRINCIPALS_HOLD(cx, principals) JS_HoldPrincipals(cx,principals ) | #define JSPRINCIPALS_HOLD(cx, principals) JS_HoldPrincipals(cx,principals ) | |||
#define JSPRINCIPALS_DROP(cx, principals) JS_DropPrincipals(cx,principals ) | #define JSPRINCIPALS_DROP(cx, principals) JS_DropPrincipals(cx,principals ) | |||
extern JS_PUBLIC_API(jsrefcount) | extern JS_PUBLIC_API(jsrefcount) | |||
JS_HoldPrincipals(JSContext *cx, JSPrincipals *principals); | JS_HoldPrincipals(JSContext *cx, JSPrincipals *principals); | |||
extern JS_PUBLIC_API(jsrefcount) | extern JS_PUBLIC_API(jsrefcount) | |||
skipping to change at line 1221 | skipping to change at line 1527 | |||
#define JSPRINCIPALS_DROP(cx, principals) \ | #define JSPRINCIPALS_DROP(cx, principals) \ | |||
((--(principals)->refcount == 0) \ | ((--(principals)->refcount == 0) \ | |||
? ((*(principals)->destroy)((cx), (principals)), 0) \ | ? ((*(principals)->destroy)((cx), (principals)), 0) \ | |||
: (principals)->refcount) | : (principals)->refcount) | |||
#endif | #endif | |||
extern JS_PUBLIC_API(JSPrincipalsTranscoder) | extern JS_PUBLIC_API(JSPrincipalsTranscoder) | |||
JS_SetPrincipalsTranscoder(JSRuntime *rt, JSPrincipalsTranscoder px); | JS_SetPrincipalsTranscoder(JSRuntime *rt, JSPrincipalsTranscoder px); | |||
extern JS_PUBLIC_API(JSObjectPrincipalsFinder) | extern JS_PUBLIC_API(JSObjectPrincipalsFinder) | |||
JS_SetObjectPrincipalsFinder(JSContext *cx, JSObjectPrincipalsFinder fop); | JS_SetObjectPrincipalsFinder(JSRuntime *rt, JSObjectPrincipalsFinder fop); | |||
/************************************************************************/ | /************************************************************************/ | |||
/* | /* | |||
* Functions and scripts. | * Functions and scripts. | |||
*/ | */ | |||
extern JS_PUBLIC_API(JSFunction *) | extern JS_PUBLIC_API(JSFunction *) | |||
JS_NewFunction(JSContext *cx, JSNative call, uintN nargs, uintN flags, | JS_NewFunction(JSContext *cx, JSNative call, uintN nargs, uintN flags, | |||
JSObject *parent, const char *name); | JSObject *parent, const char *name); | |||
skipping to change at line 1262 | skipping to change at line 1568 | |||
extern JS_PUBLIC_API(JSString *) | extern JS_PUBLIC_API(JSString *) | |||
JS_GetFunctionId(JSFunction *fun); | JS_GetFunctionId(JSFunction *fun); | |||
/* | /* | |||
* Return JSFUN_* flags for fun. | * Return JSFUN_* flags for fun. | |||
*/ | */ | |||
extern JS_PUBLIC_API(uintN) | extern JS_PUBLIC_API(uintN) | |||
JS_GetFunctionFlags(JSFunction *fun); | JS_GetFunctionFlags(JSFunction *fun); | |||
/* | /* | |||
* Return the arity (length) of fun. | ||||
*/ | ||||
extern JS_PUBLIC_API(uint16) | ||||
JS_GetFunctionArity(JSFunction *fun); | ||||
/* | ||||
* Infallible predicate to test whether obj is a function object (faster th an | * Infallible predicate to test whether obj is a function object (faster th an | |||
* comparing obj's class name to "Function", but equivalent unless someone has | * comparing obj's class name to "Function", but equivalent unless someone has | |||
* overwritten the "Function" identifier with a different constructor and t hen | * overwritten the "Function" identifier with a different constructor and t hen | |||
* created instances using that constructor that might be passed in as obj) . | * created instances using that constructor that might be passed in as obj) . | |||
*/ | */ | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_ObjectIsFunction(JSContext *cx, JSObject *obj); | JS_ObjectIsFunction(JSContext *cx, JSObject *obj); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_DefineFunctions(JSContext *cx, JSObject *obj, JSFunctionSpec *fs); | JS_DefineFunctions(JSContext *cx, JSObject *obj, JSFunctionSpec *fs); | |||
skipping to change at line 1522 | skipping to change at line 1834 | |||
* Set the second return value, which should be a string or int jsval that | * Set the second return value, which should be a string or int jsval that | |||
* identifies a property in the returned object, to form an ECMA reference | * identifies a property in the returned object, to form an ECMA reference | |||
* type value (obj, id). Only native methods can return reference types, | * type value (obj, id). Only native methods can return reference types, | |||
* and if the returned value is used on the left-hand side of an assignment | * and if the returned value is used on the left-hand side of an assignment | |||
* op, the identified property will be set. If the return value is in an | * op, the identified property will be set. If the return value is in an | |||
* r-value, the interpreter just gets obj[id]'s value. | * r-value, the interpreter just gets obj[id]'s value. | |||
*/ | */ | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_SetCallReturnValue2(JSContext *cx, jsval v); | JS_SetCallReturnValue2(JSContext *cx, jsval v); | |||
/* | ||||
* Saving and restoring frame chains. | ||||
* | ||||
* These two functions are used to set aside cx->fp while that frame is | ||||
* inactive. After a call to JS_SaveFrameChain, it looks as if there is no | ||||
* code running on cx. Before calling JS_RestoreFrameChain, cx's call stack | ||||
* must be balanced and all nested calls to JS_SaveFrameChain must have had | ||||
* matching JS_RestoreFrameChain calls. | ||||
* | ||||
* JS_SaveFrameChain deals with cx not having any code running on it. A nul | ||||
l | ||||
* return does not signify an error and JS_RestoreFrameChain handles null | ||||
* frames. | ||||
*/ | ||||
extern JS_PUBLIC_API(JSStackFrame *) | ||||
JS_SaveFrameChain(JSContext *cx); | ||||
extern JS_PUBLIC_API(void) | ||||
JS_RestoreFrameChain(JSContext *cx, JSStackFrame *fp); | ||||
/************************************************************************/ | /************************************************************************/ | |||
/* | /* | |||
* Strings. | * Strings. | |||
* | * | |||
* NB: JS_NewString takes ownership of bytes on success, avoiding a copy; b ut | * NB: JS_NewString takes ownership of bytes on success, avoiding a copy; b ut | |||
* on error (signified by null return), it leaves bytes owned by the caller . | * on error (signified by null return), it leaves bytes owned by the caller . | |||
* So the caller must free bytes in the error case, if it has no use for th em. | * So the caller must free bytes in the error case, if it has no use for th em. | |||
* In contrast, all the JS_New*StringCopy* functions do not take ownership of | * In contrast, all the JS_New*StringCopy* functions do not take ownership of | |||
* the character memory passed to them -- they copy it. | * the character memory passed to them -- they copy it. | |||
skipping to change at line 1627 | skipping to change at line 1958 | |||
extern JS_PUBLIC_API(const jschar *) | extern JS_PUBLIC_API(const jschar *) | |||
JS_UndependString(JSContext *cx, JSString *str); | JS_UndependString(JSContext *cx, JSString *str); | |||
/* | /* | |||
* Convert a mutable string (either growable or dependent) into an immutabl e, | * Convert a mutable string (either growable or dependent) into an immutabl e, | |||
* thread-safe one. | * thread-safe one. | |||
*/ | */ | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_MakeStringImmutable(JSContext *cx, JSString *str); | JS_MakeStringImmutable(JSContext *cx, JSString *str); | |||
/* | ||||
* Return JS_TRUE if C (char []) strings passed via the API and internally | ||||
* are UTF-8. The source must be compiled with JS_C_STRINGS_ARE_UTF8 define | ||||
d | ||||
* to get UTF-8 support. | ||||
*/ | ||||
JS_PUBLIC_API(JSBool) | ||||
JS_CStringsAreUTF8(); | ||||
/* | ||||
* Character encoding support. | ||||
* | ||||
* For both JS_EncodeCharacters and JS_DecodeBytes, set *dstlenp to the siz | ||||
e | ||||
* of the destination buffer before the call; on return, *dstlenp contains | ||||
the | ||||
* number of bytes (JS_EncodeCharacters) or jschars (JS_DecodeBytes) actual | ||||
ly | ||||
* stored. To determine the necessary destination buffer size, make a sizi | ||||
ng | ||||
* call that passes NULL for dst. | ||||
* | ||||
* On errors, the functions report the error. In that case, *dstlenp contai | ||||
ns | ||||
* the number of characters or bytes transferred so far. If cx is NULL, no | ||||
* error is reported on failure, and the functions simply return JS_FALSE. | ||||
* | ||||
* NB: Neither function stores an additional zero byte or jschar after the | ||||
* transcoded string. | ||||
* | ||||
* If the source has been compiled with the #define JS_C_STRINGS_ARE_UTF8 t | ||||
o | ||||
* enable UTF-8 interpretation of C char[] strings, then JS_EncodeCharacter | ||||
s | ||||
* encodes to UTF-8, and JS_DecodeBytes decodes from UTF-8, which may creat | ||||
e | ||||
* addititional errors if the character sequence is malformed. If UTF-8 | ||||
* support is disabled, the functions deflate and inflate, respectively. | ||||
*/ | ||||
JS_PUBLIC_API(JSBool) | ||||
JS_EncodeCharacters(JSContext *cx, const jschar *src, size_t srclen, char * | ||||
dst, | ||||
size_t *dstlenp); | ||||
JS_PUBLIC_API(JSBool) | ||||
JS_DecodeBytes(JSContext *cx, const char *src, size_t srclen, jschar *dst, | ||||
size_t *dstlenp); | ||||
/************************************************************************/ | /************************************************************************/ | |||
/* | /* | |||
* Locale specific string conversion callback. | * Locale specific string conversion and error message callbacks. | |||
*/ | */ | |||
struct JSLocaleCallbacks { | struct JSLocaleCallbacks { | |||
JSLocaleToUpperCase localeToUpperCase; | JSLocaleToUpperCase localeToUpperCase; | |||
JSLocaleToLowerCase localeToLowerCase; | JSLocaleToLowerCase localeToLowerCase; | |||
JSLocaleCompare localeCompare; | JSLocaleCompare localeCompare; | |||
JSLocaleToUnicode localeToUnicode; | JSLocaleToUnicode localeToUnicode; | |||
JSErrorCallback localeGetErrorMessage; | ||||
}; | }; | |||
/* | /* | |||
* Establish locale callbacks. The pointer must persist as long as the | * Establish locale callbacks. The pointer must persist as long as the | |||
* JSContext. Passing NULL restores the default behaviour. | * JSContext. Passing NULL restores the default behaviour. | |||
*/ | */ | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_SetLocaleCallbacks(JSContext *cx, JSLocaleCallbacks *callbacks); | JS_SetLocaleCallbacks(JSContext *cx, JSLocaleCallbacks *callbacks); | |||
/* | /* | |||
skipping to change at line 1815 | skipping to change at line 2185 | |||
/* | /* | |||
* If the given value is an exception object that originated from an error, | * If the given value is an exception object that originated from an error, | |||
* the exception will contain an error report struct, and this API will ret urn | * the exception will contain an error report struct, and this API will ret urn | |||
* the address of that struct. Otherwise, it returns NULL. The lifetime o f | * the address of that struct. Otherwise, it returns NULL. The lifetime o f | |||
* the error report struct that might be returned is the same as the lifeti me | * the error report struct that might be returned is the same as the lifeti me | |||
* of the exception object. | * of the exception object. | |||
*/ | */ | |||
extern JS_PUBLIC_API(JSErrorReport *) | extern JS_PUBLIC_API(JSErrorReport *) | |||
JS_ErrorFromException(JSContext *cx, jsval v); | JS_ErrorFromException(JSContext *cx, jsval v); | |||
/* | ||||
* Given a reported error's message and JSErrorReport struct pointer, throw | ||||
* the corresponding exception on cx. | ||||
*/ | ||||
extern JS_PUBLIC_API(JSBool) | ||||
JS_ThrowReportedError(JSContext *cx, const char *message, | ||||
JSErrorReport *reportp); | ||||
#ifdef JS_THREADSAFE | #ifdef JS_THREADSAFE | |||
/* | /* | |||
* Associate the current thread with the given context. This is done | * Associate the current thread with the given context. This is done | |||
* implicitly by JS_NewContext. | * implicitly by JS_NewContext. | |||
* | * | |||
* Returns the old thread id for this context, which should be treated as | * Returns the old thread id for this context, which should be treated as | |||
* an opaque value. This value is provided for comparison to 0, which | * an opaque value. This value is provided for comparison to 0, which | |||
* indicates that ClearContextThread has been called on this context | * indicates that ClearContextThread has been called on this context | |||
* since the last SetContextThread, or non-0, which indicates the opposite. | * since the last SetContextThread, or non-0, which indicates the opposite. | |||
End of changes. 33 change blocks. | ||||
6 lines changed or deleted | 450 lines changed or added | |||
jsarena.h | jsarena.h | |||
---|---|---|---|---|
skipping to change at line 73 | skipping to change at line 73 | |||
}; | }; | |||
#ifdef JS_ARENAMETER | #ifdef JS_ARENAMETER | |||
typedef struct JSArenaStats JSArenaStats; | typedef struct JSArenaStats JSArenaStats; | |||
struct JSArenaStats { | struct JSArenaStats { | |||
JSArenaStats *next; /* next in arenaStats list */ | JSArenaStats *next; /* next in arenaStats list */ | |||
char *name; /* name for debugging */ | char *name; /* name for debugging */ | |||
uint32 narenas; /* number of arenas in pool */ | uint32 narenas; /* number of arenas in pool */ | |||
uint32 nallocs; /* number of JS_ARENA_ALLOCATE() calls */ | uint32 nallocs; /* number of JS_ARENA_ALLOCATE() calls */ | |||
uint32 nreclaims; /* number of reclaims from freeArenas */ | ||||
uint32 nmallocs; /* number of malloc() calls */ | uint32 nmallocs; /* number of malloc() calls */ | |||
uint32 ndeallocs; /* number of lifetime deallocations */ | uint32 ndeallocs; /* number of lifetime deallocations */ | |||
uint32 ngrows; /* number of JS_ARENA_GROW() calls */ | uint32 ngrows; /* number of JS_ARENA_GROW() calls */ | |||
uint32 ninplace; /* number of in-place growths */ | uint32 ninplace; /* number of in-place growths */ | |||
uint32 nreallocs; /* number of arena grow extending reallocs */ | uint32 nreallocs; /* number of arena grow extending reallocs */ | |||
uint32 nreleases; /* number of JS_ARENA_RELEASE() calls */ | uint32 nreleases; /* number of JS_ARENA_RELEASE() calls */ | |||
uint32 nfastrels; /* number of "fast path" releases */ | uint32 nfastrels; /* number of "fast path" releases */ | |||
size_t nbytes; /* total bytes allocated */ | size_t nbytes; /* total bytes allocated */ | |||
size_t maxalloc; /* maximum allocation size in bytes */ | size_t maxalloc; /* maximum allocation size in bytes */ | |||
double variance; /* size variance accumulator */ | double variance; /* size variance accumulator */ | |||
skipping to change at line 116 | skipping to change at line 115 | |||
#define JS_INIT_ARENA_POOL(pool, name, size) \ | #define JS_INIT_ARENA_POOL(pool, name, size) \ | |||
JS_InitArenaPool(pool, name, size, JS_ARENA_CONST_ALIGN_MASK + 1) | JS_InitArenaPool(pool, name, size, JS_ARENA_CONST_ALIGN_MASK + 1) | |||
#else | #else | |||
#define JS_ARENA_ALIGN(pool, n) (((jsuword)(n) + (pool)->mask) & ~(pool)->m ask) | #define JS_ARENA_ALIGN(pool, n) (((jsuword)(n) + (pool)->mask) & ~(pool)->m ask) | |||
#endif | #endif | |||
#define JS_ARENA_ALLOCATE(p, pool, nb) \ | #define JS_ARENA_ALLOCATE(p, pool, nb) \ | |||
JS_ARENA_ALLOCATE_CAST(p, void *, pool, nb) | JS_ARENA_ALLOCATE_CAST(p, void *, pool, nb) | |||
#define JS_ARENA_ALLOCATE_TYPE(p, type, pool) \ | #define JS_ARENA_ALLOCATE_TYPE(p, type, pool) \ | |||
JS_ARENA_ALLOCATE_CAST(p, type *, pool, sizeof(type)) | JS_ARENA_ALLOCATE_COMMON(p, type *, pool, sizeof(type), 0) | |||
#define JS_ARENA_ALLOCATE_CAST(p, type, pool, nb) \ | #define JS_ARENA_ALLOCATE_CAST(p, type, pool, nb) \ | |||
JS_ARENA_ALLOCATE_COMMON(p, type, pool, nb, _nb > _a->limit) | ||||
/* | ||||
* NB: In JS_ARENA_ALLOCATE_CAST and JS_ARENA_GROW_CAST, always subtract _n | ||||
b | ||||
* from a->limit rather than adding _nb to _p, to avoid overflowing a 32-bi | ||||
t | ||||
* address space (possible when running a 32-bit program on a 64-bit system | ||||
* where the kernel maps the heap up against the top of the 32-bit address | ||||
* space). | ||||
* | ||||
* Thanks to Juergen Kreileder <jk@blackdown.de>, who brought this up in | ||||
* https://bugzilla.mozilla.org/show_bug.cgi?id=279273. | ||||
*/ | ||||
#define JS_ARENA_ALLOCATE_COMMON(p, type, pool, nb, guard) | ||||
\ | ||||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
JSArena *_a = (pool)->current; \ | JSArena *_a = (pool)->current; \ | |||
size_t _nb = JS_ARENA_ALIGN(pool, nb); \ | size_t _nb = JS_ARENA_ALIGN(pool, nb); \ | |||
jsuword _p = _a->avail; \ | jsuword _p = _a->avail; \ | |||
jsuword _q = _p + _nb; | if ((guard) || _p > _a->limit - _nb) | |||
\ | \ | |||
JS_ASSERT(_q >= _p); | ||||
\ | ||||
if (_q > _a->limit) | ||||
\ | ||||
_p = (jsuword)JS_ArenaAllocate(pool, _nb); \ | _p = (jsuword)JS_ArenaAllocate(pool, _nb); \ | |||
else \ | else \ | |||
_a->avail = _q; \ | _a->avail = _p + _nb; \ | |||
p = (type) _p; \ | p = (type) _p; \ | |||
JS_ArenaCountAllocation(pool, nb); \ | JS_ArenaCountAllocation(pool, nb); \ | |||
JS_END_MACRO | JS_END_MACRO | |||
#define JS_ARENA_GROW(p, pool, size, incr) \ | #define JS_ARENA_GROW(p, pool, size, incr) \ | |||
JS_ARENA_GROW_CAST(p, void *, pool, size, incr) | JS_ARENA_GROW_CAST(p, void *, pool, size, incr) | |||
#define JS_ARENA_GROW_CAST(p, type, pool, size, incr) \ | #define JS_ARENA_GROW_CAST(p, type, pool, size, incr) \ | |||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
JSArena *_a = (pool)->current; \ | JSArena *_a = (pool)->current; \ | |||
if (_a->avail == (jsuword)(p) + JS_ARENA_ALIGN(pool, size)) { \ | if (_a->avail == (jsuword)(p) + JS_ARENA_ALIGN(pool, size)) { \ | |||
size_t _nb = (size) + (incr); \ | size_t _nb = (size) + (incr); \ | |||
jsuword _q = (jsuword)(p) + JS_ARENA_ALIGN(pool, _nb); | _nb = JS_ARENA_ALIGN(pool, _nb); | |||
\ | \ | |||
if (_q <= _a->limit) { | if (_a->limit >= _nb && (jsuword)(p) <= _a->limit - _nb) { | |||
\ | \ | |||
_a->avail = _q; | _a->avail = (jsuword)(p) + _nb; | |||
\ | \ | |||
JS_ArenaCountInplaceGrowth(pool, size, incr); \ | JS_ArenaCountInplaceGrowth(pool, size, incr); \ | |||
} else if ((jsuword)(p) == _a->base) { \ | } else if ((jsuword)(p) == _a->base) { \ | |||
p = (type) JS_ArenaRealloc(pool, p, size, incr); \ | p = (type) JS_ArenaRealloc(pool, p, size, incr); \ | |||
} else { \ | } else { \ | |||
p = (type) JS_ArenaGrow(pool, p, size, incr); \ | p = (type) JS_ArenaGrow(pool, p, size, incr); \ | |||
} \ | } \ | |||
} else { \ | } else { \ | |||
p = (type) JS_ArenaGrow(pool, p, size, incr); \ | p = (type) JS_ArenaGrow(pool, p, size, incr); \ | |||
} \ | } \ | |||
JS_ArenaCountGrowth(pool, size, incr); \ | JS_ArenaCountGrowth(pool, size, incr); \ | |||
skipping to change at line 226 | skipping to change at line 236 | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_FreeArenaPool(JSArenaPool *pool); | JS_FreeArenaPool(JSArenaPool *pool); | |||
/* | /* | |||
* Free the arenas in pool and finish using it altogether. | * Free the arenas in pool and finish using it altogether. | |||
*/ | */ | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_FinishArenaPool(JSArenaPool *pool); | JS_FinishArenaPool(JSArenaPool *pool); | |||
/* | /* | |||
* Finish using arenas, freeing all memory associated with them except for | * Deprecated do-nothing function. | |||
* any locks needed for thread safety. | ||||
*/ | */ | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_ArenaFinish(void); | JS_ArenaFinish(void); | |||
/* | /* | |||
* Free any locks or other memory needed for thread safety, just before | * Deprecated do-nothing function. | |||
* shutting down. At that point, we must be called by a single thread. | ||||
* | ||||
* After shutting down, the next thread to call JS_InitArenaPool must not | ||||
* race with any other thread. Once a pool has been initialized, threads | ||||
* may safely call jsarena.c functions on thread-local pools. The upshot | ||||
* is that pools are per-thread, but the underlying global freelist is | ||||
* thread-safe, provided that both the first pool initialization and the | ||||
* shut-down call are single-threaded. | ||||
*/ | */ | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_ArenaShutDown(void); | JS_ArenaShutDown(void); | |||
/* | /* | |||
* Friend functions used by the JS_ARENA_*() macros. | * Friend functions used by the JS_ARENA_*() macros. | |||
*/ | */ | |||
extern JS_PUBLIC_API(void *) | extern JS_PUBLIC_API(void *) | |||
JS_ArenaAllocate(JSArenaPool *pool, size_t nb); | JS_ArenaAllocate(JSArenaPool *pool, size_t nb); | |||
End of changes. 8 change blocks. | ||||
26 lines changed or deleted | 28 lines changed or added | |||
jsarray.h | jsarray.h | |||
---|---|---|---|---|
skipping to change at line 50 | skipping to change at line 50 | |||
#ifndef jsarray_h___ | #ifndef jsarray_h___ | |||
#define jsarray_h___ | #define jsarray_h___ | |||
/* | /* | |||
* JS Array interface. | * JS Array interface. | |||
*/ | */ | |||
#include "jsprvtd.h" | #include "jsprvtd.h" | |||
#include "jspubtd.h" | #include "jspubtd.h" | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
/* Generous sanity-bound on length (in elements) of array initialiser. */ | ||||
#define ARRAY_INIT_LIMIT JS_BIT(24) | ||||
extern JSBool | ||||
js_IdIsIndex(jsval id, jsuint *indexp); | ||||
extern JSClass js_ArrayClass; | extern JSClass js_ArrayClass; | |||
extern JSObject * | extern JSObject * | |||
js_InitArrayClass(JSContext *cx, JSObject *obj); | js_InitArrayClass(JSContext *cx, JSObject *obj); | |||
extern JSObject * | extern JSObject * | |||
js_NewArrayObject(JSContext *cx, jsuint length, jsval *vector); | js_NewArrayObject(JSContext *cx, jsuint length, jsval *vector); | |||
extern JSBool | extern JSBool | |||
js_GetLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp); | js_GetLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp); | |||
extern JSBool | extern JSBool | |||
js_SetLengthProperty(JSContext *cx, JSObject *obj, jsuint length); | js_SetLengthProperty(JSContext *cx, JSObject *obj, jsuint length); | |||
extern JSBool | extern JSBool | |||
js_HasLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp); | js_HasLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp); | |||
/* | /* | |||
* Test whether an object is "array-like". Currently this means whether ob | ||||
j | ||||
* is an Array or an arguments object. We would like an API, and probably | ||||
a | ||||
* way in the language, to bless other objects as array-like: having indexe | ||||
d | ||||
* properties, and a 'length' property of uint32 value equal to one more th | ||||
an | ||||
* the greatest index. | ||||
*/ | ||||
extern JSBool | ||||
js_IsArrayLike(JSContext *cx, JSObject *obj, JSBool *answerp, jsuint *lengt | ||||
hp); | ||||
/* | ||||
* JS-specific heap sort function. | * JS-specific heap sort function. | |||
*/ | */ | |||
typedef int (*JSComparator)(const void *a, const void *b, void *arg); | typedef JSBool (*JSComparator)(void *arg, const void *a, const void *b, | |||
int *result); | ||||
extern JSBool | extern JSBool | |||
js_HeapSort(void *vec, size_t nel, size_t elsize, JSComparator cmp, void *a | js_HeapSort(void *vec, size_t nel, void *pivot, size_t elsize, | |||
rg); | JSComparator cmp, void *arg); | |||
JS_END_EXTERN_C | JS_END_EXTERN_C | |||
#endif /* jsarray_h___ */ | #endif /* jsarray_h___ */ | |||
End of changes. 4 change blocks. | ||||
3 lines changed or deleted | 25 lines changed or added | |||
jsatom.h | jsatom.h | |||
---|---|---|---|---|
skipping to change at line 61 | skipping to change at line 61 | |||
#ifdef JS_THREADSAFE | #ifdef JS_THREADSAFE | |||
#include "jslock.h" | #include "jslock.h" | |||
#endif | #endif | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
#define ATOM_PINNED 0x01 /* atom is pinned against GC */ | #define ATOM_PINNED 0x01 /* atom is pinned against GC */ | |||
#define ATOM_INTERNED 0x02 /* pinned variant for JS_Intern* AP I */ | #define ATOM_INTERNED 0x02 /* pinned variant for JS_Intern* AP I */ | |||
#define ATOM_MARK 0x04 /* atom is reachable via GC */ | #define ATOM_MARK 0x04 /* atom is reachable via GC */ | |||
#define ATOM_HIDDEN 0x08 /* atom is in special hidden subspa ce */ | ||||
#define ATOM_NOCOPY 0x40 /* don't copy atom string bytes */ | #define ATOM_NOCOPY 0x40 /* don't copy atom string bytes */ | |||
#define ATOM_TMPSTR 0x80 /* internal, to avoid extra string */ | #define ATOM_TMPSTR 0x80 /* internal, to avoid extra string */ | |||
struct JSAtom { | struct JSAtom { | |||
JSHashEntry entry; /* key is jsval, value keyword info | JSHashEntry entry; /* key is jsval or unhidden atom | |||
*/ | if ATOM_HIDDEN */ | |||
uint32 flags; /* pinned, interned, and mark flags */ | uint32 flags; /* pinned, interned, and mark flags */ | |||
jsatomid number; /* atom serial number and hash code */ | jsatomid number; /* atom serial number and hash code */ | |||
}; | }; | |||
#define ATOM_KEY(atom) ((jsval)(atom)->entry.key) | #define ATOM_KEY(atom) ((jsval)(atom)->entry.key) | |||
#define ATOM_IS_OBJECT(atom) JSVAL_IS_OBJECT(ATOM_KEY(atom)) | #define ATOM_IS_OBJECT(atom) JSVAL_IS_OBJECT(ATOM_KEY(atom)) | |||
#define ATOM_TO_OBJECT(atom) JSVAL_TO_OBJECT(ATOM_KEY(atom)) | #define ATOM_TO_OBJECT(atom) JSVAL_TO_OBJECT(ATOM_KEY(atom)) | |||
#define ATOM_IS_INT(atom) JSVAL_IS_INT(ATOM_KEY(atom)) | #define ATOM_IS_INT(atom) JSVAL_IS_INT(ATOM_KEY(atom)) | |||
#define ATOM_TO_INT(atom) JSVAL_TO_INT(ATOM_KEY(atom)) | #define ATOM_TO_INT(atom) JSVAL_TO_INT(ATOM_KEY(atom)) | |||
#define ATOM_IS_DOUBLE(atom) JSVAL_IS_DOUBLE(ATOM_KEY(atom)) | #define ATOM_IS_DOUBLE(atom) JSVAL_IS_DOUBLE(ATOM_KEY(atom)) | |||
skipping to change at line 90 | skipping to change at line 92 | |||
#define ATOM_TO_BOOLEAN(atom) JSVAL_TO_BOOLEAN(ATOM_KEY(atom)) | #define ATOM_TO_BOOLEAN(atom) JSVAL_TO_BOOLEAN(ATOM_KEY(atom)) | |||
/* | /* | |||
* Return a printable, lossless char[] representation of a string-type atom . | * Return a printable, lossless char[] representation of a string-type atom . | |||
* The lifetime of the result extends at least until the next GC activation , | * The lifetime of the result extends at least until the next GC activation , | |||
* longer if cx's string newborn root is not overwritten. | * longer if cx's string newborn root is not overwritten. | |||
*/ | */ | |||
extern JS_FRIEND_API(const char *) | extern JS_FRIEND_API(const char *) | |||
js_AtomToPrintableString(JSContext *cx, JSAtom *atom); | js_AtomToPrintableString(JSContext *cx, JSAtom *atom); | |||
#define ATOM_KEYWORD(atom) ((struct keyword *)(atom)->entry.value) | ||||
#define ATOM_SET_KEYWORD(atom,kw) ((atom)->entry.value = (kw)) | ||||
struct JSAtomListElement { | struct JSAtomListElement { | |||
JSHashEntry entry; | JSHashEntry entry; | |||
}; | }; | |||
#define ALE_ATOM(ale) ((JSAtom *) (ale)->entry.key) | #define ALE_ATOM(ale) ((JSAtom *) (ale)->entry.key) | |||
#define ALE_INDEX(ale) ((jsatomid) (ale)->entry.value) | #define ALE_INDEX(ale) ((jsatomid) JS_PTR_TO_UINT32((ale)->entry.value)) | |||
#define ALE_JSOP(ale) ((JSOp) (ale)->entry.value) | #define ALE_JSOP(ale) ((JSOp) (ale)->entry.value) | |||
#define ALE_VALUE(ale) ((jsval) (ale)->entry.value) | #define ALE_VALUE(ale) ((jsval) (ale)->entry.value) | |||
#define ALE_NEXT(ale) ((JSAtomListElement *) (ale)->entry.next) | #define ALE_NEXT(ale) ((JSAtomListElement *) (ale)->entry.next) | |||
#define ALE_SET_ATOM(ale,atom) ((ale)->entry.key = (const void *)(atom)) | #define ALE_SET_ATOM(ale,atom) ((ale)->entry.key = (const void *)(atom)) | |||
#define ALE_SET_INDEX(ale,index)((ale)->entry.value = (void *)(index)) | #define ALE_SET_INDEX(ale,index)((ale)->entry.value = JS_UINT32_TO_PTR(inde | |||
#define ALE_SET_JSOP(ale,op) ((ale)->entry.value = (void *)(op)) | x)) | |||
#define ALE_SET_JSOP(ale,op) ((ale)->entry.value = JS_UINT32_TO_PTR(op)) | ||||
#define ALE_SET_VALUE(ale,val) ((ale)->entry.value = (JSHashEntry *)(val)) | #define ALE_SET_VALUE(ale,val) ((ale)->entry.value = (JSHashEntry *)(val)) | |||
#define ALE_SET_NEXT(ale,link) ((ale)->entry.next = (JSHashEntry *)(link)) | #define ALE_SET_NEXT(ale,link) ((ale)->entry.next = (JSHashEntry *)(link)) | |||
struct JSAtomList { | struct JSAtomList { | |||
JSAtomListElement *list; /* literals indexed for mapping */ | JSAtomListElement *list; /* literals indexed for mapping */ | |||
JSHashTable *table; /* hash table if list gets too long */ | JSHashTable *table; /* hash table if list gets too long */ | |||
jsuint count; /* count of indexed literals */ | jsuint count; /* count of indexed literals */ | |||
}; | }; | |||
#define ATOM_LIST_INIT(al) ((al)->list = NULL, (al)->table = NULL, \ | #define ATOM_LIST_INIT(al) ((al)->list = NULL, (al)->table = NULL, \ | |||
skipping to change at line 156 | skipping to change at line 155 | |||
JSAtom **vector; /* array of ptrs to indexed atoms * / | JSAtom **vector; /* array of ptrs to indexed atoms * / | |||
jsatomid length; /* count of (to-be-)indexed atoms * / | jsatomid length; /* count of (to-be-)indexed atoms * / | |||
}; | }; | |||
struct JSAtomState { | struct JSAtomState { | |||
JSRuntime *runtime; /* runtime that owns us */ | JSRuntime *runtime; /* runtime that owns us */ | |||
JSHashTable *table; /* hash table containing all atoms */ | JSHashTable *table; /* hash table containing all atoms */ | |||
jsatomid number; /* one beyond greatest atom number */ | jsatomid number; /* one beyond greatest atom number */ | |||
jsatomid liveAtoms; /* number of live atoms after last GC */ | jsatomid liveAtoms; /* number of live atoms after last GC */ | |||
/* The rt->emptyString atom, see jsstr.c's js_InitRuntimeStringState. * | ||||
/ | ||||
JSAtom *emptyAtom; | ||||
/* Type names and value literals. */ | /* Type names and value literals. */ | |||
JSAtom *typeAtoms[JSTYPE_LIMIT]; | JSAtom *typeAtoms[JSTYPE_LIMIT]; | |||
JSAtom *booleanAtoms[2]; | JSAtom *booleanAtoms[2]; | |||
JSAtom *nullAtom; | JSAtom *nullAtom; | |||
/* Standard class constructor or prototype names. */ | ||||
JSAtom *classAtoms[JSProto_LIMIT]; | ||||
/* Various built-in or commonly-used atoms, pinned on first context. */ | /* Various built-in or commonly-used atoms, pinned on first context. */ | |||
JSAtom *ArgumentsAtom; | ||||
JSAtom *ArrayAtom; | ||||
JSAtom *BooleanAtom; | ||||
JSAtom *CallAtom; | ||||
JSAtom *DateAtom; | ||||
JSAtom *ErrorAtom; | ||||
JSAtom *FunctionAtom; | ||||
JSAtom *MathAtom; | ||||
JSAtom *NumberAtom; | ||||
JSAtom *ObjectAtom; | ||||
JSAtom *RegExpAtom; | ||||
JSAtom *ScriptAtom; | ||||
JSAtom *StringAtom; | ||||
JSAtom *anonymousAtom; | JSAtom *anonymousAtom; | |||
JSAtom *argumentsAtom; | JSAtom *argumentsAtom; | |||
JSAtom *arityAtom; | JSAtom *arityAtom; | |||
JSAtom *calleeAtom; | JSAtom *calleeAtom; | |||
JSAtom *callerAtom; | JSAtom *callerAtom; | |||
JSAtom *classPrototypeAtom; | JSAtom *classPrototypeAtom; | |||
JSAtom *closeAtom; | ||||
JSAtom *constructorAtom; | JSAtom *constructorAtom; | |||
JSAtom *countAtom; | JSAtom *countAtom; | |||
JSAtom *eachAtom; | ||||
JSAtom *etagoAtom; | ||||
JSAtom *evalAtom; | JSAtom *evalAtom; | |||
JSAtom *fileNameAtom; | ||||
JSAtom *getAtom; | JSAtom *getAtom; | |||
JSAtom *getterAtom; | JSAtom *getterAtom; | |||
JSAtom *indexAtom; | JSAtom *indexAtom; | |||
JSAtom *inputAtom; | JSAtom *inputAtom; | |||
JSAtom *iteratorAtom; | ||||
JSAtom *lengthAtom; | JSAtom *lengthAtom; | |||
JSAtom *lineNumberAtom; | ||||
JSAtom *messageAtom; | ||||
JSAtom *nameAtom; | JSAtom *nameAtom; | |||
JSAtom *namespaceAtom; | ||||
JSAtom *nextAtom; | ||||
JSAtom *noSuchMethodAtom; | JSAtom *noSuchMethodAtom; | |||
JSAtom *parentAtom; | JSAtom *parentAtom; | |||
JSAtom *protoAtom; | JSAtom *protoAtom; | |||
JSAtom *ptagcAtom; | ||||
JSAtom *qualifierAtom; | ||||
JSAtom *setAtom; | JSAtom *setAtom; | |||
JSAtom *setterAtom; | JSAtom *setterAtom; | |||
JSAtom *spaceAtom; | ||||
JSAtom *stackAtom; | ||||
JSAtom *stagoAtom; | ||||
JSAtom *starAtom; | ||||
JSAtom *starQualifierAtom; | ||||
JSAtom *tagcAtom; | ||||
JSAtom *toLocaleStringAtom; | JSAtom *toLocaleStringAtom; | |||
JSAtom *toSourceAtom; | JSAtom *toSourceAtom; | |||
JSAtom *toStringAtom; | JSAtom *toStringAtom; | |||
JSAtom *valueOfAtom; | JSAtom *valueOfAtom; | |||
JSAtom *xmlAtom; | ||||
/* Less frequently used atoms, pinned lazily by JS_ResolveStandardClass . */ | /* Less frequently used atoms, pinned lazily by JS_ResolveStandardClass . */ | |||
struct { | struct { | |||
JSAtom *EvalErrorAtom; | ||||
JSAtom *InfinityAtom; | JSAtom *InfinityAtom; | |||
JSAtom *InternalErrorAtom; | ||||
JSAtom *NaNAtom; | JSAtom *NaNAtom; | |||
JSAtom *RangeErrorAtom; | JSAtom *XMLListAtom; | |||
JSAtom *ReferenceErrorAtom; | ||||
JSAtom *SyntaxErrorAtom; | ||||
JSAtom *TypeErrorAtom; | ||||
JSAtom *URIErrorAtom; | ||||
JSAtom *decodeURIAtom; | JSAtom *decodeURIAtom; | |||
JSAtom *decodeURIComponentAtom; | JSAtom *decodeURIComponentAtom; | |||
JSAtom *defineGetterAtom; | JSAtom *defineGetterAtom; | |||
JSAtom *defineSetterAtom; | JSAtom *defineSetterAtom; | |||
JSAtom *encodeURIAtom; | JSAtom *encodeURIAtom; | |||
JSAtom *encodeURIComponentAtom; | JSAtom *encodeURIComponentAtom; | |||
JSAtom *escapeAtom; | JSAtom *escapeAtom; | |||
JSAtom *functionNamespaceURIAtom; | ||||
JSAtom *hasOwnPropertyAtom; | JSAtom *hasOwnPropertyAtom; | |||
JSAtom *isFiniteAtom; | JSAtom *isFiniteAtom; | |||
JSAtom *isNaNAtom; | JSAtom *isNaNAtom; | |||
JSAtom *isPrototypeOfAtom; | JSAtom *isPrototypeOfAtom; | |||
JSAtom *isXMLNameAtom; | ||||
JSAtom *lookupGetterAtom; | JSAtom *lookupGetterAtom; | |||
JSAtom *lookupSetterAtom; | JSAtom *lookupSetterAtom; | |||
JSAtom *parseFloatAtom; | JSAtom *parseFloatAtom; | |||
JSAtom *parseIntAtom; | JSAtom *parseIntAtom; | |||
JSAtom *propertyIsEnumerableAtom; | JSAtom *propertyIsEnumerableAtom; | |||
JSAtom *unescapeAtom; | JSAtom *unescapeAtom; | |||
JSAtom *unevalAtom; | JSAtom *unevalAtom; | |||
JSAtom *unwatchAtom; | JSAtom *unwatchAtom; | |||
JSAtom *watchAtom; | JSAtom *watchAtom; | |||
} lazy; | } lazy; | |||
skipping to change at line 246 | skipping to change at line 252 | |||
#endif | #endif | |||
#ifdef NARCISSUS | #ifdef NARCISSUS | |||
JSAtom *callAtom; | JSAtom *callAtom; | |||
JSAtom *constructAtom; | JSAtom *constructAtom; | |||
JSAtom *hasInstanceAtom; | JSAtom *hasInstanceAtom; | |||
JSAtom *ExecutionContextAtom; | JSAtom *ExecutionContextAtom; | |||
JSAtom *currentAtom; | JSAtom *currentAtom; | |||
#endif | #endif | |||
}; | }; | |||
#define CLASS_ATOM(cx,name) \ | ||||
((cx)->runtime->atomState.classAtoms[JSProto_##name]) | ||||
/* Well-known predefined strings and their atoms. */ | /* Well-known predefined strings and their atoms. */ | |||
extern const char *js_type_str[]; | extern const char *js_type_strs[]; | |||
extern const char *js_boolean_str[]; | extern const char *js_boolean_strs[]; | |||
extern const char *js_proto_strs[]; | ||||
#define JS_PROTO(name,code,init) extern const char js_##name##_str[]; | ||||
#include "jsproto.tbl" | ||||
#undef JS_PROTO | ||||
extern const char js_Arguments_str[]; | ||||
extern const char js_Array_str[]; | ||||
extern const char js_Boolean_str[]; | ||||
extern const char js_Call_str[]; | ||||
extern const char js_Date_str[]; | ||||
extern const char js_Function_str[]; | ||||
extern const char js_Math_str[]; | ||||
extern const char js_Number_str[]; | ||||
extern const char js_Object_str[]; | ||||
extern const char js_RegExp_str[]; | ||||
extern const char js_Script_str[]; | ||||
extern const char js_String_str[]; | ||||
extern const char js_anonymous_str[]; | extern const char js_anonymous_str[]; | |||
extern const char js_arguments_str[]; | extern const char js_arguments_str[]; | |||
extern const char js_arity_str[]; | extern const char js_arity_str[]; | |||
extern const char js_callee_str[]; | extern const char js_callee_str[]; | |||
extern const char js_caller_str[]; | extern const char js_caller_str[]; | |||
extern const char js_class_prototype_str[]; | extern const char js_class_prototype_str[]; | |||
extern const char js_close_str[]; | ||||
extern const char js_constructor_str[]; | extern const char js_constructor_str[]; | |||
extern const char js_count_str[]; | extern const char js_count_str[]; | |||
extern const char js_etago_str[]; | ||||
extern const char js_each_str[]; | ||||
extern const char js_eval_str[]; | extern const char js_eval_str[]; | |||
extern const char js_getter_str[]; | extern const char js_fileName_str[]; | |||
extern const char js_get_str[]; | extern const char js_get_str[]; | |||
extern const char js_getter_str[]; | ||||
extern const char js_index_str[]; | extern const char js_index_str[]; | |||
extern const char js_input_str[]; | extern const char js_input_str[]; | |||
extern const char js_iterator_str[]; | ||||
extern const char js_length_str[]; | extern const char js_length_str[]; | |||
extern const char js_lineNumber_str[]; | ||||
extern const char js_message_str[]; | ||||
extern const char js_name_str[]; | extern const char js_name_str[]; | |||
extern const char js_namespace_str[]; | ||||
extern const char js_next_str[]; | ||||
extern const char js_noSuchMethod_str[]; | extern const char js_noSuchMethod_str[]; | |||
extern const char js_object_str[]; | ||||
extern const char js_parent_str[]; | extern const char js_parent_str[]; | |||
extern const char js_private_str[]; | ||||
extern const char js_proto_str[]; | extern const char js_proto_str[]; | |||
extern const char js_ptagc_str[]; | ||||
extern const char js_qualifier_str[]; | ||||
extern const char js_send_str[]; | ||||
extern const char js_setter_str[]; | extern const char js_setter_str[]; | |||
extern const char js_set_str[]; | extern const char js_set_str[]; | |||
extern const char js_space_str[]; | ||||
extern const char js_stack_str[]; | ||||
extern const char js_stago_str[]; | ||||
extern const char js_star_str[]; | ||||
extern const char js_starQualifier_str[]; | ||||
extern const char js_tagc_str[]; | ||||
extern const char js_toSource_str[]; | extern const char js_toSource_str[]; | |||
extern const char js_toString_str[]; | extern const char js_toString_str[]; | |||
extern const char js_toLocaleString_str[]; | extern const char js_toLocaleString_str[]; | |||
extern const char js_valueOf_str[]; | extern const char js_valueOf_str[]; | |||
extern const char js_xml_str[]; | ||||
#ifdef NARCISSUS | #ifdef NARCISSUS | |||
extern const char js_call_str[]; | extern const char js_call_str[]; | |||
extern const char js_construct_str[]; | extern const char js_construct_str[]; | |||
extern const char js_hasInstance_str[]; | extern const char js_hasInstance_str[]; | |||
extern const char js_ExecutionContext_str[]; | extern const char js_ExecutionContext_str[]; | |||
extern const char js_current_str[]; | extern const char js_current_str[]; | |||
#endif | #endif | |||
/* | /* | |||
skipping to change at line 331 | skipping to change at line 354 | |||
extern void | extern void | |||
js_FinishAtomState(JSAtomState *state); | js_FinishAtomState(JSAtomState *state); | |||
/* | /* | |||
* Atom garbage collection hooks. | * Atom garbage collection hooks. | |||
*/ | */ | |||
typedef void | typedef void | |||
(*JSGCThingMarker)(void *thing, void *data); | (*JSGCThingMarker)(void *thing, void *data); | |||
extern void | extern void | |||
js_MarkAtomState(JSAtomState *state, uintN gcflags, JSGCThingMarker mark, | js_MarkAtomState(JSAtomState *state, JSBool keepAtoms, JSGCThingMarker mark , | |||
void *data); | void *data); | |||
extern void | extern void | |||
js_SweepAtomState(JSAtomState *state); | js_SweepAtomState(JSAtomState *state); | |||
extern JSBool | extern JSBool | |||
js_InitPinnedAtoms(JSContext *cx, JSAtomState *state); | js_InitPinnedAtoms(JSContext *cx, JSAtomState *state); | |||
extern void | extern void | |||
js_UnpinPinnedAtoms(JSAtomState *state); | js_UnpinPinnedAtoms(JSAtomState *state); | |||
skipping to change at line 385 | skipping to change at line 408 | |||
extern JSAtom * | extern JSAtom * | |||
js_AtomizeString(JSContext *cx, JSString *str, uintN flags); | js_AtomizeString(JSContext *cx, JSString *str, uintN flags); | |||
extern JS_FRIEND_API(JSAtom *) | extern JS_FRIEND_API(JSAtom *) | |||
js_Atomize(JSContext *cx, const char *bytes, size_t length, uintN flags); | js_Atomize(JSContext *cx, const char *bytes, size_t length, uintN flags); | |||
extern JS_FRIEND_API(JSAtom *) | extern JS_FRIEND_API(JSAtom *) | |||
js_AtomizeChars(JSContext *cx, const jschar *chars, size_t length, uintN fl ags); | js_AtomizeChars(JSContext *cx, const jschar *chars, size_t length, uintN fl ags); | |||
/* | /* | |||
* Return an existing atom for the given char array or null if the char | ||||
* sequence is currently not atomized. | ||||
*/ | ||||
extern JSAtom * | ||||
js_GetExistingStringAtom(JSContext *cx, const jschar *chars, size_t length) | ||||
; | ||||
/* | ||||
* This variant handles all value tag types. | * This variant handles all value tag types. | |||
*/ | */ | |||
extern JSAtom * | extern JSAtom * | |||
js_AtomizeValue(JSContext *cx, jsval value, uintN flags); | js_AtomizeValue(JSContext *cx, jsval value, uintN flags); | |||
/* | /* | |||
* Convert v to an atomized string. | * Convert v to an atomized string. | |||
*/ | */ | |||
extern JSAtom * | extern JSAtom * | |||
js_ValueToStringAtom(JSContext *cx, jsval v); | js_ValueToStringAtom(JSContext *cx, jsval v); | |||
End of changes. 39 change blocks. | ||||
44 lines changed or deleted | 76 lines changed or added | |||
jsbit.h | jsbit.h | |||
---|---|---|---|---|
skipping to change at line 43 | skipping to change at line 43 | |||
* and other provisions required by the GPL or the LGPL. If you do not dele te | * and other provisions required by the GPL or the LGPL. If you do not dele te | |||
* the provisions above, a recipient may use your version of this file unde r | * the provisions above, a recipient may use your version of this file unde r | |||
* the terms of any one of the MPL, the GPL or the LGPL. | * the terms of any one of the MPL, the GPL or the LGPL. | |||
* | * | |||
* ***** END LICENSE BLOCK ***** */ | * ***** END LICENSE BLOCK ***** */ | |||
#ifndef jsbit_h___ | #ifndef jsbit_h___ | |||
#define jsbit_h___ | #define jsbit_h___ | |||
#include "jstypes.h" | #include "jstypes.h" | |||
#include "jsutil.h" | ||||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
/* | /* | |||
** A jsbitmap_t is a long integer that can be used for bitmaps | ** A jsbitmap_t is a long integer that can be used for bitmaps | |||
*/ | */ | |||
typedef JSUword jsbitmap_t; /* NSPR name, a la Unix system types */ | typedef JSUword jsbitmap_t; /* NSPR name, a la Unix system types */ | |||
typedef jsbitmap_t jsbitmap; /* JS-style scalar typedef name */ | typedef jsbitmap_t jsbitmap; /* JS-style scalar typedef name */ | |||
#define JS_TEST_BIT(_map,_bit) \ | #define JS_TEST_BIT(_map,_bit) \ | |||
((_map)[(_bit)>>JS_BITS_PER_WORD_LOG2] & (1L << ((_bit) & (JS_BITS_PER_ WORD-1)))) | ((_map)[(_bit)>>JS_BITS_PER_WORD_LOG2] & (1L << ((_bit) & (JS_BITS_PER_ WORD-1)))) | |||
skipping to change at line 69 | skipping to change at line 71 | |||
** Compute the log of the least power of 2 greater than or equal to n | ** Compute the log of the least power of 2 greater than or equal to n | |||
*/ | */ | |||
extern JS_PUBLIC_API(JSIntn) JS_CeilingLog2(JSUint32 i); | extern JS_PUBLIC_API(JSIntn) JS_CeilingLog2(JSUint32 i); | |||
/* | /* | |||
** Compute the log of the greatest power of 2 less than or equal to n | ** Compute the log of the greatest power of 2 less than or equal to n | |||
*/ | */ | |||
extern JS_PUBLIC_API(JSIntn) JS_FloorLog2(JSUint32 i); | extern JS_PUBLIC_API(JSIntn) JS_FloorLog2(JSUint32 i); | |||
/* | /* | |||
* Check if __builtin_clz is available which apeared first in GCC 3.4. | ||||
* The built-in allows to speedup calculations of ceiling/floor log2, | ||||
* see bug 327129. | ||||
*/ | ||||
#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) | ||||
# define JS_HAS_GCC_BUILTIN_CLZ | ||||
#endif | ||||
/* | ||||
** Macro version of JS_CeilingLog2: Compute the log of the least power of | ** Macro version of JS_CeilingLog2: Compute the log of the least power of | |||
** 2 greater than or equal to _n. The result is returned in _log2. | ** 2 greater than or equal to _n. The result is returned in _log2. | |||
*/ | */ | |||
#define JS_CEILING_LOG2(_log2,_n) | #ifdef JS_HAS_GCC_BUILTIN_CLZ | |||
\ | /* | |||
* Use __builtin_clz or count-leading-zeros to calculate ceil(log2(_n)). | ||||
* The macro checks for "n <= 1" and not "n != 0" as __builtin_clz(0) is | ||||
* undefined. | ||||
*/ | ||||
# define JS_CEILING_LOG2(_log2,_n) | ||||
\ | ||||
JS_BEGIN_MACRO | ||||
\ | ||||
JS_STATIC_ASSERT(sizeof(unsigned int) == sizeof(JSUint32)); | ||||
\ | ||||
unsigned int j_ = (unsigned int)(_n); | ||||
\ | ||||
(_log2) = (j_ <= 1 ? 0 : 32 - __builtin_clz(j_ - 1)); | ||||
\ | ||||
JS_END_MACRO | ||||
#else | ||||
# define JS_CEILING_LOG2(_log2,_n) | ||||
\ | ||||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
JSUint32 j_ = (JSUint32)(_n); \ | JSUint32 j_ = (JSUint32)(_n); \ | |||
(_log2) = 0; \ | (_log2) = 0; \ | |||
if ((j_) & ((j_)-1)) \ | if ((j_) & ((j_)-1)) \ | |||
(_log2) += 1; \ | (_log2) += 1; \ | |||
if ((j_) >> 16) \ | if ((j_) >> 16) \ | |||
(_log2) += 16, (j_) >>= 16; \ | (_log2) += 16, (j_) >>= 16; \ | |||
if ((j_) >> 8) \ | if ((j_) >> 8) \ | |||
(_log2) += 8, (j_) >>= 8; \ | (_log2) += 8, (j_) >>= 8; \ | |||
if ((j_) >> 4) \ | if ((j_) >> 4) \ | |||
(_log2) += 4, (j_) >>= 4; \ | (_log2) += 4, (j_) >>= 4; \ | |||
if ((j_) >> 2) \ | if ((j_) >> 2) \ | |||
(_log2) += 2, (j_) >>= 2; \ | (_log2) += 2, (j_) >>= 2; \ | |||
if ((j_) >> 1) \ | if ((j_) >> 1) \ | |||
(_log2) += 1; \ | (_log2) += 1; \ | |||
JS_END_MACRO | JS_END_MACRO | |||
#endif | ||||
/* | /* | |||
** Macro version of JS_FloorLog2: Compute the log of the greatest power of | ** Macro version of JS_FloorLog2: Compute the log of the greatest power of | |||
** 2 less than or equal to _n. The result is returned in _log2. | ** 2 less than or equal to _n. The result is returned in _log2. | |||
** | ** | |||
** This is equivalent to finding the highest set bit in the word. | ** This is equivalent to finding the highest set bit in the word. | |||
*/ | */ | |||
#define JS_FLOOR_LOG2(_log2,_n) | #if JS_GCC_HAS_BUILTIN_CLZ | |||
\ | /* | |||
* Use __builtin_clz or count-leading-zeros to calculate floor(log2(_n)). | ||||
* Since __builtin_clz(0) is undefined, the macro set the loweset bit to 1 | ||||
* to ensure 0 result when _n == 0. | ||||
*/ | ||||
# define JS_FLOOR_LOG2(_log2,_n) | ||||
\ | ||||
JS_BEGIN_MACRO | ||||
\ | ||||
JS_STATIC_ASSERT(sizeof(unsigned int) == sizeof(JSUint32)); | ||||
\ | ||||
(_log2) = 31 - __builtin_clz(((unsigned int)(_n)) | 1); | ||||
\ | ||||
JS_END_MACRO | ||||
#else | ||||
# define JS_FLOOR_LOG2(_log2,_n) | ||||
\ | ||||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
JSUint32 j_ = (JSUint32)(_n); \ | JSUint32 j_ = (JSUint32)(_n); \ | |||
(_log2) = 0; \ | (_log2) = 0; \ | |||
if ((j_) >> 16) \ | if ((j_) >> 16) \ | |||
(_log2) += 16, (j_) >>= 16; \ | (_log2) += 16, (j_) >>= 16; \ | |||
if ((j_) >> 8) \ | if ((j_) >> 8) \ | |||
(_log2) += 8, (j_) >>= 8; \ | (_log2) += 8, (j_) >>= 8; \ | |||
if ((j_) >> 4) \ | if ((j_) >> 4) \ | |||
(_log2) += 4, (j_) >>= 4; \ | (_log2) += 4, (j_) >>= 4; \ | |||
if ((j_) >> 2) \ | if ((j_) >> 2) \ | |||
(_log2) += 2, (j_) >>= 2; \ | (_log2) += 2, (j_) >>= 2; \ | |||
if ((j_) >> 1) \ | if ((j_) >> 1) \ | |||
(_log2) += 1; \ | (_log2) += 1; \ | |||
JS_END_MACRO | JS_END_MACRO | |||
#endif | ||||
/* | ||||
* Internal function. | ||||
* Compute the log of the least power of 2 greater than or equal to n. | ||||
* This is a version of JS_CeilingLog2 that operates on jsuword with | ||||
* CPU-dependant size. | ||||
*/ | ||||
#define JS_CEILING_LOG2W(n) ((n) <= 1 ? 0 : 1 + JS_FLOOR_LOG2W((n) - 1)) | ||||
/* | ||||
* Internal function. | ||||
* Compute the log of the greatest power of 2 less than or equal to n. | ||||
* This is a version of JS_FloorLog2 that operates on jsuword with | ||||
* CPU-dependant size and requires that n != 0. | ||||
*/ | ||||
#define JS_FLOOR_LOG2W(n) (JS_ASSERT((n) != 0), js_FloorLog2wImpl(n)) | ||||
#ifdef JS_HAS_GCC_BUILTIN_CLZ | ||||
# if JS_BYTES_PER_WORD == 4 | ||||
JS_STATIC_ASSERT(sizeof(unsigned) == sizeof(JSUword)); | ||||
# define js_FloorLog2wImpl(n) | ||||
\ | ||||
((JSUword)(JS_BITS_PER_WORD - 1 - __builtin_clz(n))) | ||||
# elif JS_BYTES_PER_WORD == 8 | ||||
JS_STATIC_ASSERT(sizeof(unsigned long long) == sizeof(JSUword)); | ||||
# define js_FloorLog2wImpl(n) | ||||
\ | ||||
((JSUword)(JS_BITS_PER_WORD - 1 - __builtin_clzll(n))) | ||||
# else | ||||
# error "NOT SUPPORTED" | ||||
# endif | ||||
#else | ||||
# if JS_BYTES_PER_WORD == 4 | ||||
# define js_FloorLog2wImpl(n) ((JSUword)JS_FloorLog2(n)) | ||||
# elif JS_BYTES_PER_WORD == 8 | ||||
extern JSUword | ||||
js_FloorLog2wImpl(JSUword n); | ||||
# else | ||||
# error "NOT SUPPORTED" | ||||
# endif | ||||
#endif | ||||
JS_END_EXTERN_C | JS_END_EXTERN_C | |||
#endif /* jsbit_h___ */ | #endif /* jsbit_h___ */ | |||
End of changes. 6 change blocks. | ||||
4 lines changed or deleted | 96 lines changed or added | |||
jsbool.h | jsbool.h | |||
---|---|---|---|---|
skipping to change at line 48 | skipping to change at line 48 | |||
* ***** END LICENSE BLOCK ***** */ | * ***** END LICENSE BLOCK ***** */ | |||
#ifndef jsbool_h___ | #ifndef jsbool_h___ | |||
#define jsbool_h___ | #define jsbool_h___ | |||
/* | /* | |||
* JS boolean interface. | * JS boolean interface. | |||
*/ | */ | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
/* | ||||
* Crypto-booleans, not visible to script but used internally by the engine | ||||
. | ||||
* | ||||
* JSVAL_HOLE is a useful value for identifying a hole in an array. It's a | ||||
lso | ||||
* used in the interpreter to represent "no exception pending". In general | ||||
it | ||||
* can be used to represent "no value". | ||||
* | ||||
* JSVAL_ARETURN is used to throw asynchronous return for generator.close() | ||||
. | ||||
*/ | ||||
#define JSVAL_HOLE BOOLEAN_TO_JSVAL(2) | ||||
#define JSVAL_ARETURN BOOLEAN_TO_JSVAL(3) | ||||
extern JSClass js_BooleanClass; | ||||
extern JSObject * | extern JSObject * | |||
js_InitBooleanClass(JSContext *cx, JSObject *obj); | js_InitBooleanClass(JSContext *cx, JSObject *obj); | |||
extern JSObject * | extern JSObject * | |||
js_BooleanToObject(JSContext *cx, JSBool b); | js_BooleanToObject(JSContext *cx, JSBool b); | |||
extern JSString * | extern JSString * | |||
js_BooleanToString(JSContext *cx, JSBool b); | js_BooleanToString(JSContext *cx, JSBool b); | |||
extern JSBool | extern JSBool | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 18 lines changed or added | |||
jsclist.h | jsclist.h | |||
---|---|---|---|---|
skipping to change at line 55 | skipping to change at line 55 | |||
** Circular linked list | ** Circular linked list | |||
*/ | */ | |||
typedef struct JSCListStr { | typedef struct JSCListStr { | |||
struct JSCListStr *next; | struct JSCListStr *next; | |||
struct JSCListStr *prev; | struct JSCListStr *prev; | |||
} JSCList; | } JSCList; | |||
/* | /* | |||
** Insert element "_e" into the list, before "_l". | ** Insert element "_e" into the list, before "_l". | |||
*/ | */ | |||
#define JS_INSERT_BEFORE(_e,_l) \ | #define JS_INSERT_BEFORE(_e,_l) \ | |||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
(_e)->next = (_l); \ | (_e)->next = (_l); \ | |||
(_e)->prev = (_l)->prev; \ | (_e)->prev = (_l)->prev; \ | |||
(_l)->prev->next = (_e); \ | (_l)->prev->next = (_e); \ | |||
(_l)->prev = (_e); \ | (_l)->prev = (_e); \ | |||
JS_END_MACRO | JS_END_MACRO | |||
/* | /* | |||
** Insert element "_e" into the list, after "_l". | ** Insert element "_e" into the list, after "_l". | |||
*/ | */ | |||
#define JS_INSERT_AFTER(_e,_l) \ | #define JS_INSERT_AFTER(_e,_l) \ | |||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
(_e)->next = (_l)->next; \ | (_e)->next = (_l)->next; \ | |||
(_e)->prev = (_l); \ | (_e)->prev = (_l); \ | |||
(_l)->next->prev = (_e); \ | (_l)->next->prev = (_e); \ | |||
(_l)->next = (_e); \ | (_l)->next = (_e); \ | |||
JS_END_MACRO | JS_END_MACRO | |||
/* | /* | |||
** Return the element following element "_e" | ** Return the element following element "_e" | |||
*/ | */ | |||
#define JS_NEXT_LINK(_e) \ | #define JS_NEXT_LINK(_e) \ | |||
((_e)->next) | ((_e)->next) | |||
/* | /* | |||
** Return the element preceding element "_e" | ** Return the element preceding element "_e" | |||
*/ | */ | |||
#define JS_PREV_LINK(_e) \ | #define JS_PREV_LINK(_e) \ | |||
((_e)->prev) | ((_e)->prev) | |||
/* | /* | |||
** Append an element "_e" to the end of the list "_l" | ** Append an element "_e" to the end of the list "_l" | |||
*/ | */ | |||
#define JS_APPEND_LINK(_e,_l) JS_INSERT_BEFORE(_e,_l) | #define JS_APPEND_LINK(_e,_l) JS_INSERT_BEFORE(_e,_l) | |||
/* | /* | |||
** Insert an element "_e" at the head of the list "_l" | ** Insert an element "_e" at the head of the list "_l" | |||
*/ | */ | |||
#define JS_INSERT_LINK(_e,_l) JS_INSERT_AFTER(_e,_l) | #define JS_INSERT_LINK(_e,_l) JS_INSERT_AFTER(_e,_l) | |||
/* Return the head/tail of the list */ | /* Return the head/tail of the list */ | |||
#define JS_LIST_HEAD(_l) (_l)->next | #define JS_LIST_HEAD(_l) (_l)->next | |||
#define JS_LIST_TAIL(_l) (_l)->prev | #define JS_LIST_TAIL(_l) (_l)->prev | |||
/* | /* | |||
** Remove the element "_e" from it's circular list. | ** Remove the element "_e" from it's circular list. | |||
*/ | */ | |||
#define JS_REMOVE_LINK(_e) \ | #define JS_REMOVE_LINK(_e) \ | |||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
(_e)->prev->next = (_e)->next; \ | (_e)->prev->next = (_e)->next; \ | |||
(_e)->next->prev = (_e)->prev; \ | (_e)->next->prev = (_e)->prev; \ | |||
JS_END_MACRO | JS_END_MACRO | |||
/* | /* | |||
** Remove the element "_e" from it's circular list. Also initializes the | ** Remove the element "_e" from it's circular list. Also initializes the | |||
** linkage. | ** linkage. | |||
*/ | */ | |||
#define JS_REMOVE_AND_INIT_LINK(_e) \ | #define JS_REMOVE_AND_INIT_LINK(_e) \ | |||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
(_e)->prev->next = (_e)->next; \ | (_e)->prev->next = (_e)->next; \ | |||
(_e)->next->prev = (_e)->prev; \ | (_e)->next->prev = (_e)->prev; \ | |||
(_e)->next = (_e); \ | (_e)->next = (_e); \ | |||
(_e)->prev = (_e); \ | (_e)->prev = (_e); \ | |||
JS_END_MACRO | JS_END_MACRO | |||
/* | /* | |||
** Return non-zero if the given circular list "_l" is empty, zero if the | ** Return non-zero if the given circular list "_l" is empty, zero if the | |||
** circular list is not empty | ** circular list is not empty | |||
*/ | */ | |||
#define JS_CLIST_IS_EMPTY(_l) \ | #define JS_CLIST_IS_EMPTY(_l) \ | |||
((_l)->next == (_l)) | ((_l)->next == (_l)) | |||
/* | /* | |||
** Initialize a circular list | ** Initialize a circular list | |||
*/ | */ | |||
#define JS_INIT_CLIST(_l) \ | #define JS_INIT_CLIST(_l) \ | |||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
(_l)->next = (_l); \ | (_l)->next = (_l); \ | |||
(_l)->prev = (_l); \ | (_l)->prev = (_l); \ | |||
JS_END_MACRO | JS_END_MACRO | |||
#define JS_INIT_STATIC_CLIST(_l) \ | #define JS_INIT_STATIC_CLIST(_l) \ | |||
{(_l), (_l)} | {(_l), (_l)} | |||
#endif /* jsclist_h___ */ | #endif /* jsclist_h___ */ | |||
End of changes. 7 change blocks. | ||||
28 lines changed or deleted | 28 lines changed or added | |||
jscntxt.h | jscntxt.h | |||
---|---|---|---|---|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | /* -*- 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 ***** | * ***** BEGIN LICENSE BLOCK ***** | |||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | |||
* | * | |||
* The contents of this file are subject to the Mozilla Public License Vers ion | * The contents of this file are subject to the Mozilla Public License Vers ion | |||
* 1.1 (the "License"); you may not use this file except in compliance with | * 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 | * the License. You may obtain a copy of the License at | |||
* http://www.mozilla.org/MPL/ | * http://www.mozilla.org/MPL/ | |||
* | * | |||
* Software distributed under the License is distributed on an "AS IS" basi s, | * Software distributed under the License is distributed on an "AS IS" basi s, | |||
skipping to change at line 57 | skipping to change at line 58 | |||
#include "jslong.h" | #include "jslong.h" | |||
#include "jsatom.h" | #include "jsatom.h" | |||
#include "jsconfig.h" | #include "jsconfig.h" | |||
#include "jsdhash.h" | #include "jsdhash.h" | |||
#include "jsgc.h" | #include "jsgc.h" | |||
#include "jsinterp.h" | #include "jsinterp.h" | |||
#include "jsobj.h" | #include "jsobj.h" | |||
#include "jsprvtd.h" | #include "jsprvtd.h" | |||
#include "jspubtd.h" | #include "jspubtd.h" | |||
#include "jsregexp.h" | #include "jsregexp.h" | |||
#include "jsutil.h" | ||||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
typedef enum JSGCMode { JS_NO_GC, JS_MAYBE_GC, JS_FORCE_GC } JSGCMode; | /* | |||
* 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 t | ||||
o | ||||
* 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 decompil | ||||
er | ||||
* among two or more contexts running script in one thread. | ||||
*/ | ||||
JSGSNCache gsnCache; | ||||
}; | ||||
#define JS_GSN_CACHE(cx) ((cx)->thread->gsnCache) | ||||
extern void JS_DLL_CALLBACK | ||||
js_ThreadDestructorCB(void *ptr); | ||||
extern JSBool | ||||
js_SetContextThread(JSContext *cx); | ||||
extern void | ||||
js_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 { | typedef enum JSRuntimeState { | |||
JSRTS_DOWN, | JSRTS_DOWN, | |||
JSRTS_LAUNCHING, | JSRTS_LAUNCHING, | |||
JSRTS_UP, | JSRTS_UP, | |||
JSRTS_LANDING | JSRTS_LANDING | |||
} JSRuntimeState; | } JSRuntimeState; | |||
typedef struct JSPropertyTreeEntry { | typedef struct JSPropertyTreeEntry { | |||
JSDHashEntryHdr hdr; | JSDHashEntryHdr hdr; | |||
JSScopeProperty *child; | JSScopeProperty *child; | |||
} JSPropertyTreeEntry; | } JSPropertyTreeEntry; | |||
/* | ||||
* Forward declaration for opaque JSRuntime.nativeIteratorStates. | ||||
*/ | ||||
typedef struct JSNativeIteratorState JSNativeIteratorState; | ||||
struct JSRuntime { | struct JSRuntime { | |||
/* Runtime state, synchronized by the stateChange/gcLock condvar/lock. */ | /* Runtime state, synchronized by the stateChange/gcLock condvar/lock. */ | |||
JSRuntimeState state; | JSRuntimeState state; | |||
/* Context create/destroy callback. */ | ||||
JSContextCallback cxCallback; | ||||
/* Garbage collector state, used by jsgc.c. */ | /* Garbage collector state, used by jsgc.c. */ | |||
JSArenaPool gcArenaPool; | JSGCArenaList gcArenaList[GC_NUM_FREELISTS]; | |||
JSDHashTable gcRootsHash; | JSDHashTable gcRootsHash; | |||
JSDHashTable *gcLocksHash; | JSDHashTable *gcLocksHash; | |||
JSGCThing *gcFreeList; | ||||
jsrefcount gcKeepAtoms; | jsrefcount gcKeepAtoms; | |||
uint32 gcBytes; | uint32 gcBytes; | |||
uint32 gcLastBytes; | uint32 gcLastBytes; | |||
uint32 gcMaxBytes; | uint32 gcMaxBytes; | |||
uint32 gcMaxMallocBytes; | ||||
uint32 gcLevel; | uint32 gcLevel; | |||
uint32 gcNumber; | uint32 gcNumber; | |||
/* | ||||
* NB: do not pack another flag here by claiming gcPadding unless the n | ||||
ew | ||||
* flag is written only by the GC thread. Atomic updates to packed byt | ||||
es | ||||
* are not guaranteed, so stores issued by one thread may be lost due t | ||||
o | ||||
* unsynchronized read-modify-write cycles on other threads. | ||||
*/ | ||||
JSPackedBool gcPoke; | JSPackedBool gcPoke; | |||
JSPackedBool gcRunning; | JSPackedBool gcRunning; | |||
uint16 gcPadding; | ||||
JSGCCallback gcCallback; | JSGCCallback gcCallback; | |||
uint32 gcMallocBytes; | uint32 gcMallocBytes; | |||
JSGCArena *gcUnscannedArenaStackTop; | ||||
#ifdef DEBUG | ||||
size_t gcUnscannedBagSize; | ||||
#endif | ||||
/* | ||||
* API compatibility requires keeping GCX_PRIVATE bytes separate from t | ||||
he | ||||
* original GC types' byte tally. Otherwise embeddings that configure | ||||
a | ||||
* good limit for pre-GCX_PRIVATE versions of the engine will see memor | ||||
y | ||||
* 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 tha | ||||
n | ||||
* 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 stat | ||||
e | ||||
* before finalizing the iterable object. | ||||
*/ | ||||
JSPtrTable gcIteratorTable; | ||||
#if JS_HAS_GENERATORS | ||||
/* Runtime state to support close hooks. */ | ||||
JSGCCloseState gcCloseState; | ||||
#endif | ||||
#ifdef JS_GCMETER | #ifdef JS_GCMETER | |||
JSGCStats gcStats; | JSGCStats gcStats; | |||
#endif | #endif | |||
/* Literal table maintained by jsatom.c functions. */ | /* Literal table maintained by jsatom.c functions. */ | |||
JSAtomState atomState; | JSAtomState atomState; | |||
/* Random number generator state, used by jsmath.c. */ | /* Random number generator state, used by jsmath.c. */ | |||
JSBool rngInitialized; | JSBool rngInitialized; | |||
int64 rngMultiplier; | int64 rngMultiplier; | |||
int64 rngAddend; | int64 rngAddend; | |||
int64 rngMask; | int64 rngMask; | |||
int64 rngSeed; | int64 rngSeed; | |||
jsdouble rngDscale; | jsdouble rngDscale; | |||
/* Well-known numbers held for use by this runtime's contexts. */ | /* Well-known numbers held for use by this runtime's contexts. */ | |||
jsdouble *jsNaN; | jsdouble *jsNaN; | |||
jsdouble *jsNegativeInfinity; | jsdouble *jsNegativeInfinity; | |||
jsdouble *jsPositiveInfinity; | 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. */ | /* Empty string held for use by this runtime's contexts. */ | |||
JSString *emptyString; | JSString *emptyString; | |||
/* List of active contexts sharing this runtime; protected by gcLock. * / | /* List of active contexts sharing this runtime; protected by gcLock. * / | |||
JSCList contextList; | JSCList contextList; | |||
/* These are used for debugging -- see jsprvtd.h and jsdbgapi.h. */ | /* These are used for debugging -- see jsprvtd.h and jsdbgapi.h. */ | |||
JSTrapHandler interruptHandler; | JSTrapHandler interruptHandler; | |||
void *interruptHandlerData; | void *interruptHandlerData; | |||
JSNewScriptHook newScriptHook; | JSNewScriptHook newScriptHook; | |||
skipping to change at line 158 | skipping to change at line 304 | |||
/* Client opaque pointer */ | /* Client opaque pointer */ | |||
void *data; | void *data; | |||
#ifdef JS_THREADSAFE | #ifdef JS_THREADSAFE | |||
/* These combine to interlock the GC and new requests. */ | /* These combine to interlock the GC and new requests. */ | |||
PRLock *gcLock; | PRLock *gcLock; | |||
PRCondVar *gcDone; | PRCondVar *gcDone; | |||
PRCondVar *requestDone; | PRCondVar *requestDone; | |||
uint32 requestCount; | uint32 requestCount; | |||
jsword gcThread; | JSThread *gcThread; | |||
/* Lock and owning thread pointer for JS_LOCK_RUNTIME. */ | /* Lock and owning thread pointer for JS_LOCK_RUNTIME. */ | |||
PRLock *rtLock; | PRLock *rtLock; | |||
#ifdef DEBUG | #ifdef DEBUG | |||
jsword rtLockOwner; | jsword rtLockOwner; | |||
#endif | #endif | |||
/* Used to synchronize down/up state change; protected by gcLock. */ | /* Used to synchronize down/up state change; protected by gcLock. */ | |||
PRCondVar *stateChange; | PRCondVar *stateChange; | |||
skipping to change at line 196 | skipping to change at line 342 | |||
JSScope *scopeSharingTodo; | JSScope *scopeSharingTodo; | |||
/* | /* | |||
* Magic terminator for the rt->scopeSharingTodo linked list, threaded thro ugh | * Magic terminator for the rt->scopeSharingTodo linked list, threaded thro ugh | |||
* scope->u.link. This hack allows us to test whether a scope is on the li st | * scope->u.link. This hack allows us to test whether a scope is on the li st | |||
* by asking whether scope->u.link is non-null. We use a large, likely bog us | * by asking whether scope->u.link is non-null. We use a large, likely bog us | |||
* pointer here to distinguish this value from any valid u.count (small int ) | * pointer here to distinguish this value from any valid u.count (small int ) | |||
* value. | * value. | |||
*/ | */ | |||
#define NO_SCOPE_SHARING_TODO ((JSScope *) 0xfeedbeef) | #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 */ | #endif /* JS_THREADSAFE */ | |||
/* | /* | |||
* Check property accessibility for objects of arbitrary class. Used a t | * Check property accessibility for objects of arbitrary class. Used a t | |||
* present to check f.caller accessibility for any function object f. | * present to check f.caller accessibility for any function object f. | |||
*/ | */ | |||
JSCheckAccessOp checkObjectAccess; | JSCheckAccessOp checkObjectAccess; | |||
/* Security principals serialization support. */ | /* Security principals serialization support. */ | |||
JSPrincipalsTranscoder principalsTranscoder; | JSPrincipalsTranscoder principalsTranscoder; | |||
/* Shared scope property tree, and allocator for its nodes. */ | /* 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; | JSDHashTable propertyTreeHash; | |||
JSScopeProperty *propertyFreeList; | JSScopeProperty *propertyFreeList; | |||
JSArenaPool propertyArenaPool; | JSArenaPool propertyArenaPool; | |||
int32 propertyRemovals; | ||||
/* Script filename table. */ | /* Script filename table. */ | |||
struct JSHashTable *scriptFilenameTable; | struct JSHashTable *scriptFilenameTable; | |||
JSCList scriptFilenamePrefixes; | ||||
#ifdef JS_THREADSAFE | #ifdef JS_THREADSAFE | |||
PRLock *scriptFilenameTableLock; | PRLock *scriptFilenameTableLock; | |||
#endif | #endif | |||
/* Number localization, used by jsnum.c */ | /* Number localization, used by jsnum.c */ | |||
const char *thousandsSeparator; | const char *thousandsSeparator; | |||
const char *decimalSeparator; | const char *decimalSeparator; | |||
const char *numGrouping; | const char *numGrouping; | |||
/* | ||||
* Weak references to lazily-created, well-known XML singletons. | ||||
* | ||||
* NB: Singleton objects must be carefully disconnected from the rest o | ||||
f | ||||
* the object graph usually associated with a JSContext's global object | ||||
, | ||||
* including the set of standard class objects. See jsxml.c for detail | ||||
s. | ||||
*/ | ||||
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 decompil | ||||
ing | ||||
* a longer script, then hit repeatedly as js_GetSrcNote is called duri | ||||
ng | ||||
* the decompiler activation that filled it. | ||||
*/ | ||||
JSGSNCache gsnCache; | ||||
#define JS_GSN_CACHE(cx) ((cx)->runtime->gsnCache) | ||||
#endif | ||||
#ifdef DEBUG | #ifdef DEBUG | |||
/* Function invocation metering. */ | /* Function invocation metering. */ | |||
jsrefcount inlineCalls; | jsrefcount inlineCalls; | |||
jsrefcount nativeCalls; | jsrefcount nativeCalls; | |||
jsrefcount nonInlineCalls; | jsrefcount nonInlineCalls; | |||
jsrefcount constructs; | jsrefcount constructs; | |||
/* Scope lock and property metering. */ | /* Scope lock and property metering. */ | |||
jsrefcount claimAttempts; | jsrefcount claimAttempts; | |||
jsrefcount claimedScopes; | jsrefcount claimedScopes; | |||
skipping to change at line 313 | skipping to change at line 504 | |||
JSDHashEntryHdr hdr; | JSDHashEntryHdr hdr; | |||
JSResolvingKey key; | JSResolvingKey key; | |||
uint32 flags; | uint32 flags; | |||
} JSResolvingEntry; | } JSResolvingEntry; | |||
#define JSRESFLAG_LOOKUP 0x1 /* resolving id from lookup */ | #define JSRESFLAG_LOOKUP 0x1 /* resolving id from lookup */ | |||
#define JSRESFLAG_WATCH 0x2 /* resolving id from watch */ | #define JSRESFLAG_WATCH 0x2 /* resolving id from watch */ | |||
typedef struct JSLocalRootChunk JSLocalRootChunk; | typedef struct JSLocalRootChunk JSLocalRootChunk; | |||
#define JSLRS_CHUNK_SHIFT 6 | #define JSLRS_CHUNK_SHIFT 8 | |||
#define JSLRS_CHUNK_SIZE JS_BIT(JSLRS_CHUNK_SHIFT) | #define JSLRS_CHUNK_SIZE JS_BIT(JSLRS_CHUNK_SHIFT) | |||
#define JSLRS_CHUNK_MASK JS_BITMASK(JSLRS_CHUNK_SHIFT) | #define JSLRS_CHUNK_MASK JS_BITMASK(JSLRS_CHUNK_SHIFT) | |||
struct JSLocalRootChunk { | struct JSLocalRootChunk { | |||
jsval roots[JSLRS_CHUNK_SIZE]; | jsval roots[JSLRS_CHUNK_SIZE]; | |||
JSLocalRootChunk *down; | JSLocalRootChunk *down; | |||
}; | }; | |||
typedef struct JSLocalRootStack { | typedef struct JSLocalRootStack { | |||
uint16 scopeMark; | uint32 scopeMark; | |||
uint16 rootCount; | uint32 rootCount; | |||
JSLocalRootChunk *topChunk; | JSLocalRootChunk *topChunk; | |||
JSLocalRootChunk firstChunk; | JSLocalRootChunk firstChunk; | |||
} JSLocalRootStack; | } JSLocalRootStack; | |||
#define JSLRS_NULL_MARK ((uint16) -1) | #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 usi | ||||
ng | ||||
* 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 ro | ||||
ot. | ||||
* If count is -2, then u.marker holds a mark hook called to mark the value | ||||
s. | ||||
* 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 a | ||||
s a | ||||
* jsval, use JS_PUSH_TEMP_ROOT_GCTHING. The macro reinterprets an arbitrar | ||||
y | ||||
* 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 th | ||||
e | ||||
* GC mark function uses its |thing| parameter -- it consults GC-thing flag | ||||
s | ||||
* 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. The | ||||
y | ||||
* 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 acr | ||||
oss | ||||
* several layers of other functions, use the js_LeaveLocalRootScopeWithRes | ||||
ult | ||||
* 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_MACRO | ||||
struct JSContext { | struct JSContext { | |||
/* JSRuntime contextList linkage. */ | ||||
JSCList links; | JSCList links; | |||
/* Interpreter activation count. */ | /* Interpreter activation count. */ | |||
uintN interpLevel; | uintN interpLevel; | |||
/* Limit pointer for checking stack consumption during recursion. */ | /* Limit pointer for checking stack consumption during recursion. */ | |||
jsuword stackLimit; | jsuword stackLimit; | |||
/* Runtime version control identifier and equality operators. */ | /* Runtime version control identifier and equality operators. */ | |||
JSVersion version; | uint16 version; | |||
jsbytecode jsop_eq; | jsbytecode jsop_eq; | |||
jsbytecode jsop_ne; | jsbytecode jsop_ne; | |||
/* Data shared by threads in an address space. */ | /* Data shared by threads in an address space. */ | |||
JSRuntime *runtime; | JSRuntime *runtime; | |||
/* Stack arena pool and frame pointer register. */ | /* Stack arena pool and frame pointer register. */ | |||
JSArenaPool stackPool; | JSArenaPool stackPool; | |||
JSStackFrame *fp; | JSStackFrame *fp; | |||
/* Temporary arena pool used while compiling and decompiling. */ | /* Temporary arena pool used while compiling and decompiling. */ | |||
JSArenaPool tempPool; | JSArenaPool tempPool; | |||
/* Top-level object and pointer to top stack frame's scope chain. */ | /* Top-level object and pointer to top stack frame's scope chain. */ | |||
JSObject *globalObject; | JSObject *globalObject; | |||
/* Most recently created things by type, members of the GC's root set. | /* Storage to root recently allocated GC things and script result. */ | |||
*/ | JSWeakRoots weakRoots; | |||
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). */ | /* Regular expression class statics (XXX not shared globally). */ | |||
JSRegExpStatics regExpStatics; | JSRegExpStatics regExpStatics; | |||
/* State for object and array toSource conversion. */ | /* State for object and array toSource conversion. */ | |||
JSSharpObjectMap sharpObjectMap; | JSSharpObjectMap sharpObjectMap; | |||
/* Argument formatter support for JS_{Convert,Push}Arguments{,VA}. */ | /* Argument formatter support for JS_{Convert,Push}Arguments{,VA}. */ | |||
JSArgumentFormatMap *argumentFormatMap; | JSArgumentFormatMap *argumentFormatMap; | |||
skipping to change at line 389 | skipping to change at line 720 | |||
/* Per-context optional user callbacks. */ | /* Per-context optional user callbacks. */ | |||
JSBranchCallback branchCallback; | JSBranchCallback branchCallback; | |||
JSErrorReporter errorReporter; | JSErrorReporter errorReporter; | |||
/* Client opaque pointer */ | /* Client opaque pointer */ | |||
void *data; | void *data; | |||
/* GC and thread-safe state. */ | /* GC and thread-safe state. */ | |||
JSStackFrame *dormantFrameChain; /* dormant stack frame to scan */ | JSStackFrame *dormantFrameChain; /* dormant stack frame to scan */ | |||
#ifdef JS_THREADSAFE | #ifdef JS_THREADSAFE | |||
jsword thread; | JSThread *thread; | |||
jsrefcount requestDepth; | jsrefcount requestDepth; | |||
JSScope *scopeToShare; /* weak reference, see jslock.c */ | JSScope *scopeToShare; /* weak reference, see jslock.c */ | |||
JSScope *lockedSealedScope; /* weak ref, for low-cost seale d | JSScope *lockedSealedScope; /* weak ref, for low-cost seale d | |||
scope locking */ | scope locking */ | |||
JSCList threadLinks; /* JSThread contextList linkage | ||||
*/ | ||||
#define CX_FROM_THREAD_LINKS(tl) \ | ||||
((JSContext *)((char *)(tl) - offsetof(JSContext, threadLinks))) | ||||
#endif | #endif | |||
#if JS_HAS_LVALUE_RETURN | #if JS_HAS_LVALUE_RETURN | |||
/* | /* | |||
* Secondary return value from native method called on the left-hand si de | * Secondary return value from native method called on the left-hand si de | |||
* of an assignment operator. The native should store the object in wh ich | * of an assignment operator. The native should store the object in wh ich | |||
* to set a property in *rval, and return the property's id expressed a s a | * to set a property in *rval, and return the property's id expressed a s a | |||
* jsval by calling JS_SetCallReturnValue2(cx, idval). | * jsval by calling JS_SetCallReturnValue2(cx, idval). | |||
*/ | */ | |||
jsval rval2; | jsval rval2; | |||
JSPackedBool rval2set; | JSPackedBool rval2set; | |||
#endif | #endif | |||
#if JS_HAS_XML_SUPPORT | ||||
/* | ||||
* Bit-set formed from binary exponentials of the XML_* tiny-ids define | ||||
d | ||||
* for boolean settings in jsxml.c, plus an XSF_CACHE_VALID bit. Toget | ||||
her | ||||
* these act as a cache of the boolean XML.ignore* and XML.prettyPrinti | ||||
ng | ||||
* property values associated with this context's global object. | ||||
*/ | ||||
uint8 xmlSettingFlags; | ||||
#endif | ||||
/* | /* | |||
* True if creating an exception object, to prevent runaway recursion. | * True if creating an exception object, to prevent runaway recursion. | |||
* NB: creatingException packs with rval2set, #if JS_HAS_LVALUE_RETURN, | * NB: creatingException packs with rval2set, #if JS_HAS_LVALUE_RETURN; | |||
* and with throwing, below. | * with xmlSettingFlags, #if JS_HAS_XML_SUPPORT; and with throwing belo | |||
w. | ||||
*/ | */ | |||
JSPackedBool creatingException; | JSPackedBool creatingException; | |||
/* | /* | |||
* Exception state -- the exception member is a GC root by definition. | * Exception state -- the exception member is a GC root by definition. | |||
* NB: throwing packs with creatingException and rval2set, above. | * NB: throwing packs with creatingException and rval2set, above. | |||
*/ | */ | |||
JSPackedBool throwing; /* is there a pending exception ? */ | JSPackedBool throwing; /* is there a pending exception ? */ | |||
jsval exception; /* most-recently-thrown excepti on */ | jsval exception; /* most-recently-thrown excepti on */ | |||
/* Flag to indicate that we run inside gcCallback(cx, JSGC_MARK_END). * | ||||
/ | ||||
JSPackedBool insideGCMarkCallback; | ||||
/* Per-context options. */ | /* Per-context options. */ | |||
uint32 options; /* see jsapi.h for JSOPTION_* * / | uint32 options; /* see jsapi.h for JSOPTION_* * / | |||
/* Locale specific callbacks for string conversion. */ | /* Locale specific callbacks for string conversion. */ | |||
JSLocaleCallbacks *localeCallbacks; | JSLocaleCallbacks *localeCallbacks; | |||
/* | /* | |||
* cx->resolvingTable is non-null and non-empty if we are initializing | * cx->resolvingTable is non-null and non-empty if we are initializing | |||
* standard classes lazily, or if we are otherwise recursing indirectly | * standard classes lazily, or if we are otherwise recursing indirectly | |||
* from js_LookupProperty through a JSClass.resolve hook. It is used t o | * from js_LookupProperty through a JSClass.resolve hook. It is used t o | |||
* limit runaway recursion (see jsapi.c and jsobj.c). | * limit runaway recursion (see jsapi.c and jsobj.c). | |||
*/ | */ | |||
JSDHashTable *resolvingTable; | JSDHashTable *resolvingTable; | |||
/* PDL of stack headers describing stack slots not rooted by argv, etc. */ | /* PDL of stack headers describing stack slots not rooted by argv, etc. */ | |||
JSStackHeader *stackHeaders; | JSStackHeader *stackHeaders; | |||
/* Optional hook to find principals for an object being accessed on cx. | /* Optional stack of heap-allocated scoped local GC roots. */ | |||
*/ | ||||
JSObjectPrincipalsFinder findObjectPrincipals; | ||||
/* Optional stack of scoped local GC roots. */ | ||||
JSLocalRootStack *localRootStack; | 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, also to hide bitset implementation detail | * Slightly more readable macros for testing per-context option settings (a | |||
. | lso | |||
* XXX beware non-boolean truth values, which belie the bitset hiding claim | * to hide bitset implementation detail). | |||
! | * | |||
* JSOPTION_XML must be handled specially in order to propagate from compil | ||||
e- | ||||
* to run-time (from cx->options to script->version/cx->version). To do th | ||||
at, | ||||
* 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 numb | ||||
er | ||||
* changes done via the JS_SetVersion API. | ||||
* | ||||
* But when executing a script or scripted function, the interpreter change | ||||
s | ||||
* 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 ea | ||||
ch | ||||
* activation of the compiled script. That version change has the effect o | ||||
f | ||||
* 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 orde | ||||
r | ||||
* for XDR'ed scripts to serialize and deserialize with that option preserv | ||||
ed | ||||
* for detection at run-time. We can't copy other compile-time options int | ||||
o | ||||
* script->version because that would break backward compatibility (certain | ||||
* other options, e.g. JSOPTION_VAROBJFIX, are analogous to JSOPTION_XML). | ||||
*/ | */ | |||
#define JS_HAS_STRICT_OPTION(cx) ((cx)->options & JSOPTION_STRICT) | #define JS_HAS_OPTION(cx,option) (((cx)->options & (option)) != 0) | |||
#define JS_HAS_WERROR_OPTION(cx) ((cx)->options & JSOPTION_WERROR) | #define JS_HAS_STRICT_OPTION(cx) JS_HAS_OPTION(cx, JSOPTION_STRICT) | |||
#define JS_HAS_COMPILE_N_GO_OPTION(cx) ((cx)->options & JSOPTION_COMPILE_N | #define JS_HAS_WERROR_OPTION(cx) JS_HAS_OPTION(cx, JSOPTION_WERROR) | |||
_GO) | #define JS_HAS_COMPILE_N_GO_OPTION(cx) JS_HAS_OPTION(cx, JSOPTION_COMPILE_ | |||
#define JS_HAS_ATLINE_OPTION(cx) ((cx)->options & JSOPTION_ATLINE) | 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 opti | ||||
on */ | ||||
#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-cont | ||||
ext | ||||
* data that depends on version. | ||||
*/ | ||||
extern void | ||||
js_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 void | ||||
js_SetVersion(JSContext *cx, JSVersion version); | ||||
/* | ||||
* Create and destroy functions for JSContext, which is manually allocated | ||||
* and exclusively owned. | ||||
*/ | ||||
extern JSContext * | extern JSContext * | |||
js_NewContext(JSRuntime *rt, size_t stackChunkSize); | js_NewContext(JSRuntime *rt, size_t stackChunkSize); | |||
extern void | extern void | |||
js_DestroyContext(JSContext *cx, JSGCMode gcmode); | js_DestroyContext(JSContext *cx, JSDestroyContextMode mode); | |||
/* | /* | |||
* Return true if cx points to a context in rt->contextList, else return fa lse. | * Return true if cx points to a context in rt->contextList, else return fa lse. | |||
* NB: the caller (see jslock.c:ClaimScope) must hold rt->gcLock. | * NB: the caller (see jslock.c:ClaimScope) must hold rt->gcLock. | |||
*/ | */ | |||
extern JSBool | extern JSBool | |||
js_ValidContextPointer(JSRuntime *rt, JSContext *cx); | js_ValidContextPointer(JSRuntime *rt, JSContext *cx); | |||
/* | /* | |||
* If unlocked, acquire and release rt->gcLock around *iterp update; otherw ise | * If unlocked, acquire and release rt->gcLock around *iterp update; otherw ise | |||
skipping to change at line 487 | skipping to change at line 928 | |||
extern JSBool | extern JSBool | |||
js_StartResolving(JSContext *cx, JSResolvingKey *key, uint32 flag, | js_StartResolving(JSContext *cx, JSResolvingKey *key, uint32 flag, | |||
JSResolvingEntry **entryp); | JSResolvingEntry **entryp); | |||
extern void | extern void | |||
js_StopResolving(JSContext *cx, JSResolvingKey *key, uint32 flag, | js_StopResolving(JSContext *cx, JSResolvingKey *key, uint32 flag, | |||
JSResolvingEntry *entry, uint32 generation); | JSResolvingEntry *entry, uint32 generation); | |||
/* | /* | |||
* Local root set management. | * Local root set management. | |||
* | ||||
* NB: the jsval parameters below may be properly tagged jsvals, or GC-thin | ||||
g | ||||
* 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 JSBool | extern JSBool | |||
js_EnterLocalRootScope(JSContext *cx); | js_EnterLocalRootScope(JSContext *cx); | |||
#define js_LeaveLocalRootScope(cx) \ | ||||
js_LeaveLocalRootScopeWithResult(cx, JSVAL_NULL) | ||||
extern void | extern void | |||
js_LeaveLocalRootScope(JSContext *cx); | js_LeaveLocalRootScopeWithResult(JSContext *cx, jsval rval); | |||
extern void | extern void | |||
js_ForgetLocalRoot(JSContext *cx, jsval v); | js_ForgetLocalRoot(JSContext *cx, jsval v); | |||
extern int | extern int | |||
js_PushLocalRoot(JSContext *cx, JSLocalRootStack *lrs, jsval v); | js_PushLocalRoot(JSContext *cx, JSLocalRootStack *lrs, jsval v); | |||
extern void | extern void | |||
js_MarkLocalRoots(JSContext *cx, JSLocalRootStack *lrs); | js_MarkLocalRoots(JSContext *cx, JSLocalRootStack *lrs); | |||
skipping to change at line 535 | skipping to change at line 984 | |||
JSBool charArgs, va_list ap); | JSBool charArgs, va_list ap); | |||
extern JSBool | extern JSBool | |||
js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback, | js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback, | |||
void *userRef, const uintN errorNumber, | void *userRef, const uintN errorNumber, | |||
char **message, JSErrorReport *reportp, | char **message, JSErrorReport *reportp, | |||
JSBool *warningp, JSBool charArgs, va_list ap); | JSBool *warningp, JSBool charArgs, va_list ap); | |||
#endif | #endif | |||
extern void | extern void | |||
js_ReportOutOfMemory(JSContext *cx, JSErrorCallback errorCallback); | js_ReportOutOfMemory(JSContext *cx); | |||
/* | /* | |||
* Report an exception using a previously composed JSErrorReport. | * Report an exception using a previously composed JSErrorReport. | |||
* XXXbe remove from "friend" API | * XXXbe remove from "friend" API | |||
*/ | */ | |||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | |||
js_ReportErrorAgain(JSContext *cx, const char *message, JSErrorReport *repo rt); | js_ReportErrorAgain(JSContext *cx, const char *message, JSErrorReport *repo rt); | |||
extern void | extern void | |||
js_ReportIsNotDefined(JSContext *cx, const char *name); | js_ReportIsNotDefined(JSContext *cx, const char *name); | |||
End of changes. 40 change blocks. | ||||
36 lines changed or deleted | 607 lines changed or added | |||
jscompat.h | jscompat.h | |||
---|---|---|---|---|
skipping to change at line 39 | skipping to change at line 39 | |||
* under the terms of either the GPL or the LGPL, and not to allow others t o | * under the terms of either the GPL or the LGPL, and not to allow others t o | |||
* use your version of this file under the terms of the MPL, indicate your | * 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 noti ce | * decision by deleting the provisions above and replace them with the noti ce | |||
* and other provisions required by the GPL or the LGPL. If you do not dele te | * and other provisions required by the GPL or the LGPL. If you do not dele te | |||
* the provisions above, a recipient may use your version of this file unde r | * the provisions above, a recipient may use your version of this file unde r | |||
* the terms of any one of the MPL, the GPL or the LGPL. | * the terms of any one of the MPL, the GPL or the LGPL. | |||
* | * | |||
* ***** END LICENSE BLOCK ***** */ | * ***** END LICENSE BLOCK ***** */ | |||
/* -*- Mode: C; tab-width: 8 -*- | /* -*- Mode: C; tab-width: 8 -*- | |||
* Copyright | * Copyright (C) 1996-1999 Netscape Communications Corporation, All Rights Reserved. | |||
*/ | */ | |||
#ifndef jscompat_h___ | #ifndef jscompat_h___ | |||
#define jscompat_h___ | #define jscompat_h___ | |||
/* | /* | |||
* Compatibility glue for various NSPR versions. We must always define int 8, | * Compatibility glue for various NSPR versions. We must always define int 8, | |||
* int16, jsword, and so on to minimize differences with js/ref, no matter what | * int16, jsword, and so on to minimize differences with js/ref, no matter what | |||
* the NSPR typedef names may be. | * the NSPR typedef names may be. | |||
*/ | */ | |||
#include "jstypes.h" | #include "jstypes.h" | |||
#include "jslong.h" | #include "jslong.h" | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
jsconfig.h | jsconfig.h | |||
---|---|---|---|---|
skipping to change at line 44 | skipping to change at line 44 | |||
* and other provisions required by the GPL or the LGPL. If you do not dele te | * and other provisions required by the GPL or the LGPL. If you do not dele te | |||
* the provisions above, a recipient may use your version of this file unde r | * the provisions above, a recipient may use your version of this file unde r | |||
* the terms of any one of the MPL, the GPL or the LGPL. | * the terms of any one of the MPL, the GPL or the LGPL. | |||
* | * | |||
* ***** END LICENSE BLOCK ***** */ | * ***** END LICENSE BLOCK ***** */ | |||
/* | /* | |||
* JS configuration macros. | * JS configuration macros. | |||
*/ | */ | |||
#ifndef JS_VERSION | #ifndef JS_VERSION | |||
#define JS_VERSION 150 | #define JS_VERSION 170 | |||
#endif | #endif | |||
/* | /* | |||
* Compile-time JS version configuration. The JS version numbers lie on th e | * Compile-time JS version configuration. The JS version numbers lie on th e | |||
* number line like so: | * number line like so: | |||
* | * | |||
* 1.0 1.1 1.2 1.3 1.4 ECMAv3 1.5 | * 1.0 1.1 1.2 1.3 1.4 ECMAv3 1.5 1.6 | |||
* ^ ^ | * ^ ^ | |||
* | | | * | | | |||
* basis for ECMAv1 close to ECMAv2 | * basis for ECMAv1 close to ECMAv2 | |||
* | * | |||
* where ECMAv3 stands for ECMA-262 Edition 3. See the runtime version enu m | * where ECMAv3 stands for ECMA-262 Edition 3. See the runtime version enu m | |||
* JSVersion in jspubtd.h. Code in the engine can therefore count on versi on | * JSVersion in jspubtd.h. Code in the engine can therefore count on versi on | |||
* <= JSVERSION_1_4 to mean "before the Third Edition of ECMA-262" and vers ion | * <= JSVERSION_1_4 to mean "before the Third Edition of ECMA-262" and vers ion | |||
* > JSVERSION_1_4 to mean "at or after the Third Edition". | * > JSVERSION_1_4 to mean "at or after the Third Edition". | |||
* | * | |||
* In the unlikely event that SpiderMonkey ever implements JavaScript 2.0, | * In the (likely?) event that SpiderMonkey grows to implement JavaScript 2 | |||
or | .0, | |||
* ECMA-262 Edition 4 (JS2 without certain extensions), the version number | * or ECMA-262 Edition 4 (JS2 without certain extensions), the version numb | |||
to | er | |||
* use would be near 200, or greater. | * to use would be near 200, or greater. | |||
* | * | |||
* The JS_VERSION_ECMA_3 version is the minimal configuration conforming to | * The JS_VERSION_ECMA_3 version is the minimal configuration conforming to | |||
* the ECMA-262 Edition 3 specification. Use it for minimal embeddings, wh ere | * the ECMA-262 Edition 3 specification. Use it for minimal embeddings, wh ere | |||
* you're sure you don't need any of the extensions disabled in this versio n. | * you're sure you don't need any of the extensions disabled in this versio n. | |||
* In order to facilitate testing, JS_HAS_OBJ_PROTO_PROP is defined as part of | * In order to facilitate testing, JS_HAS_OBJ_PROTO_PROP is defined as part of | |||
* the JS_VERSION_ECMA_3_TEST version. | * the JS_VERSION_ECMA_3_TEST version. | |||
* | ||||
* To keep things sane in the modern age, where we need exceptions in order | ||||
to | ||||
* implement, e.g., iterators and generators, we are dropping support for a | ||||
ll | ||||
* versions <= 1.4. | ||||
*/ | */ | |||
#define JS_VERSION_ECMA_3 148 | #define JS_VERSION_ECMA_3 148 | |||
#define JS_VERSION_ECMA_3_TEST 149 | #define JS_VERSION_ECMA_3_TEST 149 | |||
#if JS_VERSION == JS_VERSION_ECMA_3 || \ | #if JS_VERSION == JS_VERSION_ECMA_3 || \ | |||
JS_VERSION == JS_VERSION_ECMA_3_TEST | JS_VERSION == JS_VERSION_ECMA_3_TEST | |||
#define JS_BUG_NULL_INDEX_PROPS 0 /* o[0] defaults to null, not void | ||||
*/ | ||||
#define JS_BUG_EMPTY_INDEX_ZERO 0 /* o[""] is equivalent to o[0] */ | ||||
#define JS_BUG_EAGER_TOSTRING 0 /* o.toString() trumps o.valueOf() | ||||
*/ | ||||
#define JS_BUG_VOID_TOSTRING 0 /* void 0 + 0 == "undefined0" */ | ||||
#define JS_BUG_EVAL_THIS_FUN 0 /* eval('this') in function f is f | ||||
*/ | ||||
#define JS_BUG_EVAL_THIS_SCOPE 0 /* Math.eval('sin(x)') vs. local x | ||||
*/ | ||||
#define JS_BUG_FALLIBLE_EQOPS 0 /* fallible/intransitive equality o | ||||
ps */ | ||||
#define JS_BUG_FALLIBLE_TONUM 0 /* fallible ValueToNumber primitive | ||||
*/ | ||||
#define JS_BUG_WITH_CLOSURE 0 /* with(o)function f(){} sets o.f * | ||||
/ | ||||
#define JS_HAS_PROP_DELETE 1 /* delete o.p removes p from o */ | ||||
#define JS_HAS_CALL_OBJECT 1 /* fun.caller is stack frame obj */ | ||||
#define JS_HAS_LABEL_STATEMENT 1 /* has break/continue to label: */ | ||||
#define JS_HAS_DO_WHILE_LOOP 1 /* has do {...} while (b) */ | ||||
#define JS_HAS_SWITCH_STATEMENT 1 /* has switch (v) {case c: ...} */ | ||||
#define JS_HAS_SOME_PERL_FUN 1 /* has array.join/reverse/sort */ | ||||
#define JS_HAS_MORE_PERL_FUN 1 /* has array.push, array.pop, etc * | ||||
/ | ||||
#define JS_HAS_STR_HTML_HELPERS 0 /* has str.anchor, str.bold, etc. * / | #define JS_HAS_STR_HTML_HELPERS 0 /* has str.anchor, str.bold, etc. * / | |||
#define JS_HAS_PERL_SUBSTR 0 /* has str.substr */ | #define JS_HAS_PERL_SUBSTR 0 /* has str.substr */ | |||
#define JS_HAS_VALUEOF_HINT 1 /* valueOf(hint) where hint is type | ||||
of */ | ||||
#define JS_HAS_LEXICAL_CLOSURE 1 /* nested functions, lexically clos | ||||
ed */ | ||||
#define JS_HAS_APPLY_FUNCTION 1 /* has fun.apply(obj, argArray) */ | ||||
#define JS_HAS_CALL_FUNCTION 1 /* has fun.call(obj, arg1, ... argN | ||||
) */ | ||||
#if JS_VERSION == JS_VERSION_ECMA_3_TEST | #if JS_VERSION == JS_VERSION_ECMA_3_TEST | |||
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ | #define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ | |||
#else | #else | |||
#define JS_HAS_OBJ_PROTO_PROP 0 /* has o.__proto__ etc. */ | #define JS_HAS_OBJ_PROTO_PROP 0 /* has o.__proto__ etc. */ | |||
#endif | #endif | |||
#define JS_HAS_REGEXPS 1 /* has perl r.e.s via RegExp, /pat/ | ||||
*/ | ||||
#define JS_HAS_SEQUENCE_OPS 1 /* has array.slice, string.concat * | ||||
/ | ||||
#define JS_HAS_INITIALIZERS 1 /* has var o = {'foo': 42, 'bar':3} | ||||
*/ | ||||
#define JS_HAS_OBJ_WATCHPOINT 0 /* has o.watch and o.unwatch */ | #define JS_HAS_OBJ_WATCHPOINT 0 /* has o.watch and o.unwatch */ | |||
#define JS_HAS_EXPORT_IMPORT 0 /* has export fun; import obj.fun * / | #define JS_HAS_EXPORT_IMPORT 0 /* has export fun; import obj.fun * / | |||
#define JS_HAS_EVAL_THIS_SCOPE 0 /* Math.eval is same as with (Math) */ | #define JS_HAS_EVAL_THIS_SCOPE 0 /* Math.eval is same as with (Math) */ | |||
#define JS_HAS_TRIPLE_EQOPS 1 /* has === and !== identity eqops * / | ||||
#define JS_HAS_SHARP_VARS 0 /* has #n=, #n# for object literals */ | #define JS_HAS_SHARP_VARS 0 /* has #n=, #n# for object literals */ | |||
#define JS_HAS_REPLACE_LAMBDA 1 /* has string.replace(re, lambda) * / | ||||
#define JS_HAS_SCRIPT_OBJECT 0 /* has (new Script("x++")).exec() * / | #define JS_HAS_SCRIPT_OBJECT 0 /* has (new Script("x++")).exec() * / | |||
#define JS_HAS_XDR 0 /* has XDR API and internal support */ | #define JS_HAS_XDR 0 /* has XDR API and internal support */ | |||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script metho ds */ | #define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script metho ds */ | |||
#define JS_HAS_EXCEPTIONS 1 /* has exception handling */ | ||||
#define JS_HAS_UNDEFINED 1 /* has global "undefined" property | ||||
*/ | ||||
#define JS_HAS_TOSOURCE 0 /* has Object/Array toSource method */ | #define JS_HAS_TOSOURCE 0 /* has Object/Array toSource method */ | |||
#define JS_HAS_IN_OPERATOR 1 /* has in operator ('p' in {p:1}) * | ||||
/ | ||||
#define JS_HAS_INSTANCEOF 1 /* has {p:1} instanceof Object */ | ||||
#define JS_HAS_ARGS_OBJECT 1 /* has minimal ECMA arguments objec | ||||
t */ | ||||
#define JS_HAS_DEBUGGER_KEYWORD 0 /* has hook for debugger keyword */ | #define JS_HAS_DEBUGGER_KEYWORD 0 /* has hook for debugger keyword */ | |||
#define JS_HAS_ERROR_EXCEPTIONS 1 /* has error object hierarchy */ | ||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch gua rd */ | #define JS_HAS_CATCH_GUARD 0 /* has exception handling catch gua rd */ | |||
#define JS_HAS_NEW_OBJ_METHODS 1 /* has Object.prototype query metho ds */ | ||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty ele ms */ | #define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty ele ms */ | |||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages | ||||
*/ | ||||
#define JS_HAS_NUMBER_FORMATS 1 /* numbers have formatting methods | ||||
*/ | ||||
#define JS_HAS_GETTER_SETTER 0 /* has JS2 getter/setter functions */ | #define JS_HAS_GETTER_SETTER 0 /* has JS2 getter/setter functions */ | |||
#define JS_HAS_UNEVAL 0 /* has uneval() top-level function */ | #define JS_HAS_UNEVAL 0 /* has uneval() top-level function */ | |||
#define JS_HAS_CONST 0 /* has JS2 const as alternative var */ | #define JS_HAS_CONST 0 /* has JS2 const as alternative var */ | |||
#define JS_HAS_FUN_EXPR_STMT 0 /* has function expression statemen t */ | #define JS_HAS_FUN_EXPR_STMT 0 /* has function expression statemen t */ | |||
#define JS_HAS_LVALUE_RETURN 1 /* has o.item(i) = j; for native it em */ | #define JS_HAS_LVALUE_RETURN 1 /* has o.item(i) = j; for native it em */ | |||
#define JS_HAS_NO_SUCH_METHOD 0 /* has o.__noSuchMethod__ handler * / | #define JS_HAS_NO_SUCH_METHOD 0 /* has o.__noSuchMethod__ handler * / | |||
#define JS_HAS_XML_SUPPORT 0 /* has ECMAScript for XML support * | ||||
/ | ||||
#define JS_HAS_ARRAY_EXTRAS 0 /* has indexOf and Lispy extras */ | ||||
#define JS_HAS_GENERATORS 0 /* has yield in generator function | ||||
*/ | ||||
#define JS_HAS_BLOCK_SCOPE 0 /* has block scope via let/arraycom | ||||
p */ | ||||
#define JS_HAS_DESTRUCTURING 0 /* has [a,b] = ... or {p:a,q:b} = . | ||||
.. */ | ||||
#elif JS_VERSION == 100 | #elif JS_VERSION < 150 | |||
#define JS_BUG_NULL_INDEX_PROPS 1 /* o[0] defaults to null, not void | ||||
*/ | ||||
#define JS_BUG_EMPTY_INDEX_ZERO 1 /* o[""] is equivalent to o[0] */ | ||||
#define JS_BUG_EAGER_TOSTRING 1 /* o.toString() trumps o.valueOf() | ||||
*/ | ||||
#define JS_BUG_VOID_TOSTRING 0 /* void 0 + 0 == "undefined0" */ | ||||
#define JS_BUG_EVAL_THIS_FUN 0 /* eval('this') in function f is f | ||||
*/ | ||||
#define JS_BUG_EVAL_THIS_SCOPE 0 /* Math.eval('sin(x)') vs. local x | ||||
*/ | ||||
#define JS_BUG_FALLIBLE_EQOPS 1 /* fallible/intransitive equality o | ||||
ps */ | ||||
#define JS_BUG_FALLIBLE_TONUM 1 /* fallible ValueToNumber primitive | ||||
*/ | ||||
#define JS_BUG_WITH_CLOSURE 0 /* with(o)function f(){} sets o.f * | ||||
/ | ||||
#define JS_HAS_PROP_DELETE 0 /* delete o.p removes p from o */ | ||||
#define JS_HAS_CALL_OBJECT 0 /* fun.caller is stack frame obj */ | ||||
#define JS_HAS_LABEL_STATEMENT 0 /* has break/continue to label: */ | ||||
#define JS_HAS_DO_WHILE_LOOP 0 /* has do {...} while (b) */ | ||||
#define JS_HAS_SWITCH_STATEMENT 0 /* has switch (v) {case c: ...} */ | ||||
#define JS_HAS_SOME_PERL_FUN 0 /* has array.join/reverse/sort */ | ||||
#define JS_HAS_MORE_PERL_FUN 0 /* has array.push, str.substr, etc | ||||
*/ | ||||
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. * | ||||
/ | ||||
#define JS_HAS_PERL_SUBSTR 0 /* has str.substr */ | ||||
#define JS_HAS_VALUEOF_HINT 0 /* valueOf(hint) where hint is type | ||||
of */ | ||||
#define JS_HAS_LEXICAL_CLOSURE 0 /* nested functions, lexically clos | ||||
ed */ | ||||
#define JS_HAS_APPLY_FUNCTION 0 /* has fun.apply(obj, argArray) */ | ||||
#define JS_HAS_CALL_FUNCTION 0 /* has fun.call(obj, arg1, ... argN | ||||
) */ | ||||
#define JS_HAS_OBJ_PROTO_PROP 0 /* has o.__proto__ etc. */ | ||||
#define JS_HAS_REGEXPS 0 /* has perl r.e.s via RegExp, /pat/ | ||||
*/ | ||||
#define JS_HAS_SEQUENCE_OPS 0 /* has array.slice, string.concat * | ||||
/ | ||||
#define JS_HAS_INITIALIZERS 0 /* has var o = {'foo': 42, 'bar':3} | ||||
*/ | ||||
#define JS_HAS_OBJ_WATCHPOINT 0 /* has o.watch and o.unwatch */ | ||||
#define JS_HAS_EXPORT_IMPORT 0 /* has export fun; import obj.fun * | ||||
/ | ||||
#define JS_HAS_EVAL_THIS_SCOPE 0 /* Math.eval is same as with (Math) | ||||
*/ | ||||
#define JS_HAS_TRIPLE_EQOPS 0 /* has === and !== identity eqops * | ||||
/ | ||||
#define JS_HAS_SHARP_VARS 0 /* has #n=, #n# for object literals | ||||
*/ | ||||
#define JS_HAS_REPLACE_LAMBDA 0 /* has string.replace(re, lambda) * | ||||
/ | ||||
#define JS_HAS_SCRIPT_OBJECT 0 /* has (new Script("x++")).exec() * | ||||
/ | ||||
#define JS_HAS_XDR 0 /* has XDR API and internal support | ||||
*/ | ||||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script metho | ||||
ds */ | ||||
#define JS_HAS_EXCEPTIONS 0 /* has exception handling */ | ||||
#define JS_HAS_UNDEFINED 0 /* has global "undefined" property | ||||
*/ | ||||
#define JS_HAS_TOSOURCE 0 /* has Object/Array toSource method | ||||
*/ | ||||
#define JS_HAS_IN_OPERATOR 0 /* has in operator ('p' in {p:1}) * | ||||
/ | ||||
#define JS_HAS_INSTANCEOF 0 /* has {p:1} instanceof Object */ | ||||
#define JS_HAS_ARGS_OBJECT 0 /* has minimal ECMA arguments objec | ||||
t */ | ||||
#define JS_HAS_DEBUGGER_KEYWORD 0 /* has hook for debugger keyword */ | ||||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* has error object hierarchy */ | ||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch gua | ||||
rd */ | ||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query metho | ||||
ds */ | ||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty ele | ||||
ms */ | ||||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages | ||||
*/ | ||||
#define JS_HAS_NUMBER_FORMATS 0 /* numbers have formatting methods | ||||
*/ | ||||
#define JS_HAS_GETTER_SETTER 0 /* has JS2 getter/setter functions | ||||
*/ | ||||
#define JS_HAS_UNEVAL 0 /* has uneval() top-level function | ||||
*/ | ||||
#define JS_HAS_CONST 0 /* has JS2 const as alternative var | ||||
*/ | ||||
#define JS_HAS_FUN_EXPR_STMT 0 /* has function expression statemen | ||||
t */ | ||||
#define JS_HAS_LVALUE_RETURN 0 /* has o.item(i) = j; for native it | ||||
em */ | ||||
#define JS_HAS_NO_SUCH_METHOD 0 /* has o.__noSuchMethod__ handler * | ||||
/ | ||||
#elif JS_VERSION == 110 | ||||
#define JS_BUG_NULL_INDEX_PROPS 1 /* o[0] defaults to null, not void | ||||
*/ | ||||
#define JS_BUG_EMPTY_INDEX_ZERO 1 /* o[""] is equivalent to o[0] */ | ||||
#define JS_BUG_EAGER_TOSTRING 1 /* o.toString() trumps o.valueOf() | ||||
*/ | ||||
#define JS_BUG_VOID_TOSTRING 0 /* void 0 + 0 == "undefined0" */ | ||||
#define JS_BUG_EVAL_THIS_FUN 1 /* eval('this') in function f is f | ||||
*/ | ||||
#define JS_BUG_EVAL_THIS_SCOPE 1 /* Math.eval('sin(x)') vs. local x | ||||
*/ | ||||
#define JS_BUG_FALLIBLE_EQOPS 1 /* fallible/intransitive equality o | ||||
ps */ | ||||
#define JS_BUG_FALLIBLE_TONUM 1 /* fallible ValueToNumber primitive | ||||
*/ | ||||
#define JS_BUG_WITH_CLOSURE 0 /* with(o)function f(){} sets o.f * | ||||
/ | ||||
#define JS_HAS_PROP_DELETE 0 /* delete o.p removes p from o */ | ||||
#define JS_HAS_CALL_OBJECT 0 /* fun.caller is stack frame obj */ | ||||
#define JS_HAS_LABEL_STATEMENT 0 /* has break/continue to label: */ | ||||
#define JS_HAS_DO_WHILE_LOOP 0 /* has do {...} while (b) */ | ||||
#define JS_HAS_SWITCH_STATEMENT 0 /* has switch (v) {case c: ...} */ | ||||
#define JS_HAS_SOME_PERL_FUN 1 /* has array.join/reverse/sort */ | ||||
#define JS_HAS_MORE_PERL_FUN 0 /* has array.push, str.substr, etc | ||||
*/ | ||||
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. * | ||||
/ | ||||
#define JS_HAS_PERL_SUBSTR 0 /* has str.substr */ | ||||
#define JS_HAS_VALUEOF_HINT 0 /* valueOf(hint) where hint is type | ||||
of */ | ||||
#define JS_HAS_LEXICAL_CLOSURE 0 /* nested functions, lexically clos | ||||
ed */ | ||||
#define JS_HAS_APPLY_FUNCTION 0 /* has apply(fun, arg1, ... argN) * | ||||
/ | ||||
#define JS_HAS_CALL_FUNCTION 0 /* has fun.call(obj, arg1, ... argN | ||||
) */ | ||||
#define JS_HAS_OBJ_PROTO_PROP 0 /* has o.__proto__ etc. */ | ||||
#define JS_HAS_REGEXPS 0 /* has perl r.e.s via RegExp, /pat/ | ||||
*/ | ||||
#define JS_HAS_SEQUENCE_OPS 0 /* has array.slice, string.concat * | ||||
/ | ||||
#define JS_HAS_INITIALIZERS 0 /* has var o = {'foo': 42, 'bar':3} | ||||
*/ | ||||
#define JS_HAS_OBJ_WATCHPOINT 0 /* has o.watch and o.unwatch */ | ||||
#define JS_HAS_EXPORT_IMPORT 0 /* has export fun; import obj.fun * | ||||
/ | ||||
#define JS_HAS_EVAL_THIS_SCOPE 0 /* Math.eval is same as with (Math) | ||||
*/ | ||||
#define JS_HAS_TRIPLE_EQOPS 0 /* has === and !== identity eqops * | ||||
/ | ||||
#define JS_HAS_SHARP_VARS 0 /* has #n=, #n# for object literals | ||||
*/ | ||||
#define JS_HAS_REPLACE_LAMBDA 0 /* has string.replace(re, lambda) * | ||||
/ | ||||
#define JS_HAS_SCRIPT_OBJECT 0 /* has (new Script("x++")).exec() * | ||||
/ | ||||
#define JS_HAS_XDR 0 /* has XDR API and internal support | ||||
*/ | ||||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script metho | ||||
ds */ | ||||
#define JS_HAS_EXCEPTIONS 0 /* has exception handling */ | ||||
#define JS_HAS_UNDEFINED 0 /* has global "undefined" property | ||||
*/ | ||||
#define JS_HAS_TOSOURCE 0 /* has Object/Array toSource method | ||||
*/ | ||||
#define JS_HAS_IN_OPERATOR 0 /* has in operator ('p' in {p:1}) * | ||||
/ | ||||
#define JS_HAS_INSTANCEOF 0 /* has {p:1} instanceof Object */ | ||||
#define JS_HAS_ARGS_OBJECT 0 /* has minimal ECMA arguments objec | ||||
t */ | ||||
#define JS_HAS_DEBUGGER_KEYWORD 0 /* has hook for debugger keyword */ | ||||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* has error object hierarchy */ | ||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch gua | ||||
rd */ | ||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query metho | ||||
ds */ | ||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty ele | ||||
ms */ | ||||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages | ||||
*/ | ||||
#define JS_HAS_NUMBER_FORMATS 0 /* numbers have formatting methods | ||||
*/ | ||||
#define JS_HAS_GETTER_SETTER 0 /* has JS2 getter/setter functions | ||||
*/ | ||||
#define JS_HAS_UNEVAL 0 /* has uneval() top-level function | ||||
*/ | ||||
#define JS_HAS_CONST 0 /* has JS2 const as alternative var | ||||
*/ | ||||
#define JS_HAS_FUN_EXPR_STMT 0 /* has function expression statemen | ||||
t */ | ||||
#define JS_HAS_LVALUE_RETURN 0 /* has o.item(i) = j; for native it | ||||
em */ | ||||
#define JS_HAS_NO_SUCH_METHOD 0 /* has o.__noSuchMethod__ handler * | ||||
/ | ||||
#elif JS_VERSION == 120 | ||||
#define JS_BUG_NULL_INDEX_PROPS 0 /* o[0] defaults to null, not void | ||||
*/ | ||||
#define JS_BUG_EMPTY_INDEX_ZERO 0 /* o[""] is equivalent to o[0] */ | ||||
#define JS_BUG_EAGER_TOSTRING 0 /* o.toString() trumps o.valueOf() | ||||
*/ | ||||
#define JS_BUG_VOID_TOSTRING 1 /* void 0 + 0 == "undefined0" */ | ||||
#define JS_BUG_EVAL_THIS_FUN 0 /* eval('this') in function f is f | ||||
*/ | ||||
#define JS_BUG_EVAL_THIS_SCOPE 0 /* Math.eval('sin(x)') vs. local x | ||||
*/ | ||||
#define JS_BUG_FALLIBLE_EQOPS 0 /* fallible/intransitive equality o | ||||
ps */ | ||||
#define JS_BUG_FALLIBLE_TONUM 0 /* fallible ValueToNumber primitive | ||||
*/ | ||||
#define JS_BUG_WITH_CLOSURE 1 /* with(o)function f(){} sets o.f * | ||||
/ | ||||
#define JS_HAS_PROP_DELETE 1 /* delete o.p removes p from o */ | ||||
#define JS_HAS_CALL_OBJECT 1 /* fun.caller is stack frame obj */ | ||||
#define JS_HAS_LABEL_STATEMENT 1 /* has break/continue to label: */ | ||||
#define JS_HAS_DO_WHILE_LOOP 1 /* has do {...} while (b) */ | ||||
#define JS_HAS_SWITCH_STATEMENT 1 /* has switch (v) {case c: ...} */ | ||||
#define JS_HAS_SOME_PERL_FUN 1 /* has array.join/reverse/sort */ | ||||
#define JS_HAS_MORE_PERL_FUN 1 /* has array.push, str.substr, etc | ||||
*/ | ||||
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. * | ||||
/ | ||||
#define JS_HAS_PERL_SUBSTR 1 /* has str.substr */ | ||||
#define JS_HAS_VALUEOF_HINT 1 /* valueOf(hint) where hint is type | ||||
of */ | ||||
#define JS_HAS_LEXICAL_CLOSURE 1 /* nested functions, lexically clos | ||||
ed */ | ||||
#define JS_HAS_APPLY_FUNCTION 1 /* has apply(fun, arg1, ... argN) * | ||||
/ | ||||
#define JS_HAS_CALL_FUNCTION 0 /* has fun.call(obj, arg1, ... argN | ||||
) */ | ||||
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ | ||||
#define JS_HAS_REGEXPS 1 /* has perl r.e.s via RegExp, /pat/ | ||||
*/ | ||||
#define JS_HAS_SEQUENCE_OPS 1 /* has array.slice, string.concat * | ||||
/ | ||||
#define JS_HAS_INITIALIZERS 1 /* has var o = {'foo': 42, 'bar':3} | ||||
*/ | ||||
#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ | ||||
#define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun * | ||||
/ | ||||
#define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) | ||||
*/ | ||||
#define JS_HAS_TRIPLE_EQOPS 0 /* has === and !== identity eqops * | ||||
/ | ||||
#define JS_HAS_SHARP_VARS 0 /* has #n=, #n# for object literals | ||||
*/ | ||||
#define JS_HAS_REPLACE_LAMBDA 0 /* has string.replace(re, lambda) * | ||||
/ | ||||
#define JS_HAS_SCRIPT_OBJECT 0 /* has (new Script("x++")).exec() * | ||||
/ | ||||
#define JS_HAS_XDR 0 /* has XDR API and internal support | ||||
*/ | ||||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script metho | ||||
ds */ | ||||
#define JS_HAS_EXCEPTIONS 0 /* has exception handling */ | ||||
#define JS_HAS_UNDEFINED 0 /* has global "undefined" property | ||||
*/ | ||||
#define JS_HAS_TOSOURCE 0 /* has Object/Array toSource method | ||||
*/ | ||||
#define JS_HAS_IN_OPERATOR 0 /* has in operator ('p' in {p:1}) * | ||||
/ | ||||
#define JS_HAS_INSTANCEOF 0 /* has {p:1} instanceof Object */ | ||||
#define JS_HAS_ARGS_OBJECT 0 /* has minimal ECMA arguments objec | ||||
t */ | ||||
#define JS_HAS_DEBUGGER_KEYWORD 0 /* has hook for debugger keyword */ | ||||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* has error object hierarchy */ | ||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch gua | ||||
rd */ | ||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query metho | ||||
ds */ | ||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty ele | ||||
ms */ | ||||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages | ||||
*/ | ||||
#define JS_HAS_NUMBER_FORMATS 0 /* numbers have formatting methods | ||||
*/ | ||||
#define JS_HAS_GETTER_SETTER 0 /* has JS2 getter/setter functions | ||||
*/ | ||||
#define JS_HAS_UNEVAL 0 /* has uneval() top-level function | ||||
*/ | ||||
#define JS_HAS_CONST 0 /* has JS2 const as alternative var | ||||
*/ | ||||
#define JS_HAS_FUN_EXPR_STMT 0 /* has function expression statemen | ||||
t */ | ||||
#define JS_HAS_LVALUE_RETURN 0 /* has o.item(i) = j; for native it | ||||
em */ | ||||
#define JS_HAS_NO_SUCH_METHOD 0 /* has o.__noSuchMethod__ handler * | ||||
/ | ||||
#elif JS_VERSION == 130 | #error "unsupported JS_VERSION" | |||
#define JS_BUG_NULL_INDEX_PROPS 0 /* o[0] defaults to null, not void | #elif JS_VERSION == 150 | |||
*/ | ||||
#define JS_BUG_EMPTY_INDEX_ZERO 0 /* o[""] is equivalent to o[0] */ | ||||
#define JS_BUG_EAGER_TOSTRING 0 /* o.toString() trumps o.valueOf() | ||||
*/ | ||||
#define JS_BUG_VOID_TOSTRING 0 /* void 0 + 0 == "undefined0" */ | ||||
#define JS_BUG_EVAL_THIS_FUN 0 /* eval('this') in function f is f | ||||
*/ | ||||
#define JS_BUG_EVAL_THIS_SCOPE 0 /* Math.eval('sin(x)') vs. local x | ||||
*/ | ||||
#define JS_BUG_FALLIBLE_EQOPS 0 /* fallible/intransitive equality o | ||||
ps */ | ||||
#define JS_BUG_FALLIBLE_TONUM 0 /* fallible ValueToNumber primitive | ||||
*/ | ||||
#define JS_BUG_WITH_CLOSURE 1 /* with(o)function f(){} sets o.f * | ||||
/ | ||||
#define JS_HAS_PROP_DELETE 1 /* delete o.p removes p from o */ | ||||
#define JS_HAS_CALL_OBJECT 1 /* fun.caller is stack frame obj */ | ||||
#define JS_HAS_LABEL_STATEMENT 1 /* has break/continue to label: */ | ||||
#define JS_HAS_DO_WHILE_LOOP 1 /* has do {...} while (b) */ | ||||
#define JS_HAS_SWITCH_STATEMENT 1 /* has switch (v) {case c: ...} */ | ||||
#define JS_HAS_SOME_PERL_FUN 1 /* has array.join/reverse/sort */ | ||||
#define JS_HAS_MORE_PERL_FUN 1 /* has array.push, str.substr, etc | ||||
*/ | ||||
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. * / | #define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. * / | |||
#define JS_HAS_PERL_SUBSTR 1 /* has str.substr */ | #define JS_HAS_PERL_SUBSTR 1 /* has str.substr */ | |||
#define JS_HAS_VALUEOF_HINT 1 /* valueOf(hint) where hint is type | ||||
of */ | ||||
#define JS_HAS_LEXICAL_CLOSURE 1 /* nested functions, lexically clos | ||||
ed */ | ||||
#define JS_HAS_APPLY_FUNCTION 1 /* has apply(fun, arg1, ... argN) * | ||||
/ | ||||
#define JS_HAS_CALL_FUNCTION 1 /* has fun.call(obj, arg1, ... argN | ||||
) */ | ||||
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ | #define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ | |||
#define JS_HAS_REGEXPS 1 /* has perl r.e.s via RegExp, /pat/ | ||||
*/ | ||||
#define JS_HAS_SEQUENCE_OPS 1 /* has array.slice, string.concat * | ||||
/ | ||||
#define JS_HAS_INITIALIZERS 1 /* has var o = {'foo': 42, 'bar':3} | ||||
*/ | ||||
#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ | #define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ | |||
#define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun * / | #define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun * / | |||
#define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */ | #define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */ | |||
#define JS_HAS_TRIPLE_EQOPS 1 /* has === and !== identity eqops * / | ||||
#define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */ | #define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */ | |||
#define JS_HAS_REPLACE_LAMBDA 1 /* has string.replace(re, lambda) * / | ||||
#define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() * / | #define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() * / | |||
#define JS_HAS_XDR 1 /* has XDR API and internal support */ | #define JS_HAS_XDR 1 /* has XDR API and internal support */ | |||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script metho ds */ | #define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script metho ds */ | |||
#define JS_HAS_EXCEPTIONS 0 /* has exception handling */ | ||||
#define JS_HAS_UNDEFINED 1 /* has global "undefined" property | ||||
*/ | ||||
#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ | #define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ | |||
#define JS_HAS_IN_OPERATOR 0 /* has in operator ('p' in {p:1}) * | ||||
/ | ||||
#define JS_HAS_INSTANCEOF 0 /* has {p:1} instanceof Object */ | ||||
#define JS_HAS_ARGS_OBJECT 1 /* has minimal ECMA arguments objec | ||||
t */ | ||||
#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */ | #define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */ | |||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* has error object hierarchy */ | #define JS_HAS_CATCH_GUARD 1 /* has exception handling catch gua | |||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch gua | rd */ | |||
rd */ | ||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query metho | ||||
ds */ | ||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty ele ms */ | #define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty ele ms */ | |||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages | #define JS_HAS_GETTER_SETTER 1 /* has JS2 getter/setter functions | |||
*/ | */ | |||
#define JS_HAS_NUMBER_FORMATS 0 /* numbers have formatting methods | #define JS_HAS_UNEVAL 1 /* has uneval() top-level function | |||
*/ | */ | |||
#define JS_HAS_GETTER_SETTER 0 /* has JS2 getter/setter functions | #define JS_HAS_CONST 1 /* has JS2 const as alternative var | |||
*/ | */ | |||
#define JS_HAS_UNEVAL 0 /* has uneval() top-level function | #define JS_HAS_FUN_EXPR_STMT 1 /* has function expression statemen | |||
*/ | t */ | |||
#define JS_HAS_CONST 0 /* has JS2 const as alternative var | #define JS_HAS_LVALUE_RETURN 1 /* has o.item(i) = j; for native it | |||
*/ | em */ | |||
#define JS_HAS_FUN_EXPR_STMT 0 /* has function expression statemen | #define JS_HAS_NO_SUCH_METHOD 1 /* has o.__noSuchMethod__ handler * | |||
t */ | / | |||
#define JS_HAS_LVALUE_RETURN 0 /* has o.item(i) = j; for native it | #define JS_HAS_XML_SUPPORT 0 /* has ECMAScript for XML support * | |||
em */ | / | |||
#define JS_HAS_NO_SUCH_METHOD 0 /* has o.__noSuchMethod__ handler * | #define JS_HAS_ARRAY_EXTRAS 0 /* has indexOf and Lispy extras */ | |||
/ | #define JS_HAS_GENERATORS 0 /* has yield in generator function | |||
*/ | ||||
#elif JS_VERSION == 140 | #define JS_HAS_BLOCK_SCOPE 0 /* has block scope via let/arraycom | |||
p */ | ||||
#define JS_HAS_DESTRUCTURING 0 /* has [a,b] = ... or {p:a,q:b} = . | ||||
.. */ | ||||
#define JS_BUG_NULL_INDEX_PROPS 0 /* o[0] defaults to null, not void | #elif JS_VERSION == 160 | |||
*/ | ||||
#define JS_BUG_EMPTY_INDEX_ZERO 0 /* o[""] is equivalent to o[0] */ | ||||
#define JS_BUG_EAGER_TOSTRING 0 /* o.toString() trumps o.valueOf() | ||||
*/ | ||||
#define JS_BUG_VOID_TOSTRING 0 /* void 0 + 0 == "undefined0" */ | ||||
#define JS_BUG_EVAL_THIS_FUN 0 /* eval('this') in function f is f | ||||
*/ | ||||
#define JS_BUG_EVAL_THIS_SCOPE 0 /* Math.eval('sin(x)') vs. local x | ||||
*/ | ||||
#define JS_BUG_FALLIBLE_EQOPS 0 /* fallible/intransitive equality o | ||||
ps */ | ||||
#define JS_BUG_FALLIBLE_TONUM 0 /* fallible ValueToNumber primitive | ||||
*/ | ||||
#define JS_BUG_WITH_CLOSURE 1 /* with(o)function f(){} sets o.f * | ||||
/ | ||||
#define JS_HAS_PROP_DELETE 1 /* delete o.p removes p from o */ | ||||
#define JS_HAS_CALL_OBJECT 1 /* fun.caller is stack frame obj */ | ||||
#define JS_HAS_LABEL_STATEMENT 1 /* has break/continue to label: */ | ||||
#define JS_HAS_DO_WHILE_LOOP 1 /* has do {...} while (b) */ | ||||
#define JS_HAS_SWITCH_STATEMENT 1 /* has switch (v) {case c: ...} */ | ||||
#define JS_HAS_SOME_PERL_FUN 1 /* has array.join/reverse/sort */ | ||||
#define JS_HAS_MORE_PERL_FUN 1 /* has array.push, str.substr, etc | ||||
*/ | ||||
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. * / | #define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. * / | |||
#define JS_HAS_PERL_SUBSTR 1 /* has str.substr */ | #define JS_HAS_PERL_SUBSTR 1 /* has str.substr */ | |||
#define JS_HAS_VALUEOF_HINT 1 /* valueOf(hint) where hint is type | ||||
of */ | ||||
#define JS_HAS_LEXICAL_CLOSURE 1 /* nested functions, lexically clos | ||||
ed */ | ||||
#define JS_HAS_APPLY_FUNCTION 1 /* has apply(fun, arg1, ... argN) * | ||||
/ | ||||
#define JS_HAS_CALL_FUNCTION 1 /* has fun.call(obj, arg1, ... argN | ||||
) */ | ||||
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ | #define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ | |||
#define JS_HAS_REGEXPS 1 /* has perl r.e.s via RegExp, /pat/ | ||||
*/ | ||||
#define JS_HAS_SEQUENCE_OPS 1 /* has array.slice, string.concat * | ||||
/ | ||||
#define JS_HAS_INITIALIZERS 1 /* has var o = {'foo': 42, 'bar':3} | ||||
*/ | ||||
#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ | #define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ | |||
#define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun * / | #define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun * / | |||
#define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */ | #define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */ | |||
#define JS_HAS_TRIPLE_EQOPS 1 /* has === and !== identity eqops * / | ||||
#define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */ | #define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */ | |||
#define JS_HAS_REPLACE_LAMBDA 1 /* has string.replace(re, lambda) * / | ||||
#define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() * / | #define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() * / | |||
#define JS_HAS_XDR 1 /* has XDR API and internal support */ | #define JS_HAS_XDR 1 /* has XDR API and internal support */ | |||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script metho ds */ | #define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script metho ds */ | |||
#define JS_HAS_EXCEPTIONS 1 /* has exception handling */ | ||||
#define JS_HAS_UNDEFINED 1 /* has global "undefined" property | ||||
*/ | ||||
#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ | #define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ | |||
#define JS_HAS_IN_OPERATOR 1 /* has in operator ('p' in {p:1}) * | ||||
/ | ||||
#define JS_HAS_INSTANCEOF 1 /* has {p:1} instanceof Object */ | ||||
#define JS_HAS_ARGS_OBJECT 1 /* has minimal ECMA arguments objec | ||||
t */ | ||||
#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */ | #define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */ | |||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* rt errors reflected as exception | #define JS_HAS_CATCH_GUARD 1 /* has exception handling catch gua | |||
s */ | rd */ | |||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch gua | ||||
rd */ | ||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query metho | ||||
ds */ | ||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty ele ms */ | #define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty ele ms */ | |||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages | #define JS_HAS_GETTER_SETTER 1 /* has JS2 getter/setter functions | |||
*/ | */ | |||
#define JS_HAS_NUMBER_FORMATS 0 /* numbers have formatting methods | #define JS_HAS_UNEVAL 1 /* has uneval() top-level function | |||
*/ | */ | |||
#define JS_HAS_GETTER_SETTER 0 /* has JS2 getter/setter functions | #define JS_HAS_CONST 1 /* has JS2 const as alternative var | |||
*/ | */ | |||
#define JS_HAS_UNEVAL 0 /* has uneval() top-level function | #define JS_HAS_FUN_EXPR_STMT 1 /* has function expression statemen | |||
*/ | t */ | |||
#define JS_HAS_CONST 0 /* has JS2 const as alternative var | #define JS_HAS_LVALUE_RETURN 1 /* has o.item(i) = j; for native it | |||
*/ | em */ | |||
#define JS_HAS_FUN_EXPR_STMT 0 /* has function expression statemen | #define JS_HAS_NO_SUCH_METHOD 1 /* has o.__noSuchMethod__ handler * | |||
t */ | / | |||
#define JS_HAS_LVALUE_RETURN 0 /* has o.item(i) = j; for native it | #define JS_HAS_XML_SUPPORT 1 /* has ECMAScript for XML support * | |||
em */ | / | |||
#define JS_HAS_NO_SUCH_METHOD 0 /* has o.__noSuchMethod__ handler * | #define JS_HAS_ARRAY_EXTRAS 1 /* has indexOf and Lispy extras */ | |||
/ | #define JS_HAS_GENERATORS 0 /* has yield in generator function | |||
*/ | ||||
#elif JS_VERSION == 150 | #define JS_HAS_BLOCK_SCOPE 0 /* has block scope via let/arraycom | |||
p */ | ||||
#define JS_HAS_DESTRUCTURING 0 /* has [a,b] = ... or {p:a,q:b} = . | ||||
.. */ | ||||
#define JS_BUG_NULL_INDEX_PROPS 0 /* o[0] defaults to null, not void | #elif JS_VERSION == 170 | |||
*/ | ||||
#define JS_BUG_EMPTY_INDEX_ZERO 0 /* o[""] is equivalent to o[0] */ | ||||
#define JS_BUG_EAGER_TOSTRING 0 /* o.toString() trumps o.valueOf() | ||||
*/ | ||||
#define JS_BUG_VOID_TOSTRING 0 /* void 0 + 0 == "undefined0" */ | ||||
#define JS_BUG_EVAL_THIS_FUN 0 /* eval('this') in function f is f | ||||
*/ | ||||
#define JS_BUG_EVAL_THIS_SCOPE 0 /* Math.eval('sin(x)') vs. local x | ||||
*/ | ||||
#define JS_BUG_FALLIBLE_EQOPS 0 /* fallible/intransitive equality o | ||||
ps */ | ||||
#define JS_BUG_FALLIBLE_TONUM 0 /* fallible ValueToNumber primitive | ||||
*/ | ||||
#define JS_BUG_WITH_CLOSURE 0 /* with(o)function f(){} sets o.f * | ||||
/ | ||||
#define JS_HAS_PROP_DELETE 1 /* delete o.p removes p from o */ | ||||
#define JS_HAS_CALL_OBJECT 1 /* fun.caller is stack frame obj */ | ||||
#define JS_HAS_LABEL_STATEMENT 1 /* has break/continue to label: */ | ||||
#define JS_HAS_DO_WHILE_LOOP 1 /* has do {...} while (b) */ | ||||
#define JS_HAS_SWITCH_STATEMENT 1 /* has switch (v) {case c: ...} */ | ||||
#define JS_HAS_SOME_PERL_FUN 1 /* has array.join/reverse/sort */ | ||||
#define JS_HAS_MORE_PERL_FUN 1 /* has array.push, str.substr, etc | ||||
*/ | ||||
#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. * / | #define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. * / | |||
#define JS_HAS_PERL_SUBSTR 1 /* has str.substr */ | #define JS_HAS_PERL_SUBSTR 1 /* has str.substr */ | |||
#define JS_HAS_VALUEOF_HINT 1 /* valueOf(hint) where hint is type | ||||
of */ | ||||
#define JS_HAS_LEXICAL_CLOSURE 1 /* nested functions, lexically clos | ||||
ed */ | ||||
#define JS_HAS_APPLY_FUNCTION 1 /* has apply(fun, arg1, ... argN) * | ||||
/ | ||||
#define JS_HAS_CALL_FUNCTION 1 /* has fun.call(obj, arg1, ... argN | ||||
) */ | ||||
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ | #define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ | |||
#define JS_HAS_REGEXPS 1 /* has perl r.e.s via RegExp, /pat/ | ||||
*/ | ||||
#define JS_HAS_SEQUENCE_OPS 1 /* has array.slice, string.concat * | ||||
/ | ||||
#define JS_HAS_INITIALIZERS 1 /* has var o = {'foo': 42, 'bar':3} | ||||
*/ | ||||
#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ | #define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ | |||
#define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun * / | #define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun * / | |||
#define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */ | #define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */ | |||
#define JS_HAS_TRIPLE_EQOPS 1 /* has === and !== identity eqops * / | ||||
#define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */ | #define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */ | |||
#define JS_HAS_REPLACE_LAMBDA 1 /* has string.replace(re, lambda) * / | ||||
#define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() * / | #define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() * / | |||
#define JS_HAS_XDR 1 /* has XDR API and internal support */ | #define JS_HAS_XDR 1 /* has XDR API and internal support */ | |||
#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script metho ds */ | #define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script metho ds */ | |||
#define JS_HAS_EXCEPTIONS 1 /* has exception handling */ | ||||
#define JS_HAS_UNDEFINED 1 /* has global "undefined" property | ||||
*/ | ||||
#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ | #define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ | |||
#define JS_HAS_IN_OPERATOR 1 /* has in operator ('p' in {p:1}) * | ||||
/ | ||||
#define JS_HAS_INSTANCEOF 1 /* has {p:1} instanceof Object */ | ||||
#define JS_HAS_ARGS_OBJECT 1 /* has minimal ECMA arguments objec | ||||
t */ | ||||
#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */ | #define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */ | |||
#define JS_HAS_ERROR_EXCEPTIONS 1 /* rt errors reflected as exception s */ | ||||
#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch gua rd */ | #define JS_HAS_CATCH_GUARD 1 /* has exception handling catch gua rd */ | |||
#define JS_HAS_NEW_OBJ_METHODS 1 /* has Object.prototype query metho ds */ | ||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty ele ms */ | #define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty ele ms */ | |||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages | ||||
*/ | ||||
#define JS_HAS_NUMBER_FORMATS 1 /* numbers have formatting methods | ||||
*/ | ||||
#define JS_HAS_GETTER_SETTER 1 /* has JS2 getter/setter functions */ | #define JS_HAS_GETTER_SETTER 1 /* has JS2 getter/setter functions */ | |||
#define JS_HAS_UNEVAL 1 /* has uneval() top-level function */ | #define JS_HAS_UNEVAL 1 /* has uneval() top-level function */ | |||
#define JS_HAS_CONST 1 /* has JS2 const as alternative var */ | #define JS_HAS_CONST 1 /* has JS2 const as alternative var */ | |||
#define JS_HAS_FUN_EXPR_STMT 1 /* has function expression statemen t */ | #define JS_HAS_FUN_EXPR_STMT 1 /* has function expression statemen t */ | |||
#define JS_HAS_LVALUE_RETURN 1 /* has o.item(i) = j; for native it em */ | #define JS_HAS_LVALUE_RETURN 1 /* has o.item(i) = j; for native it em */ | |||
#define JS_HAS_NO_SUCH_METHOD 1 /* has o.__noSuchMethod__ handler * / | #define JS_HAS_NO_SUCH_METHOD 1 /* has o.__noSuchMethod__ handler * / | |||
#define JS_HAS_XML_SUPPORT 1 /* has ECMAScript for XML support * | ||||
/ | ||||
#define JS_HAS_ARRAY_EXTRAS 1 /* has indexOf and Lispy extras */ | ||||
#define JS_HAS_GENERATORS 1 /* has yield in generator function | ||||
*/ | ||||
#define JS_HAS_BLOCK_SCOPE 1 /* has block scope via let/arraycom | ||||
p */ | ||||
#define JS_HAS_DESTRUCTURING 1 /* has [a,b] = ... or {p:a,q:b} = . | ||||
.. */ | ||||
#else | #else | |||
#error "unknown JS_VERSION" | #error "unknown JS_VERSION" | |||
#endif | #endif | |||
/* Features that are present in all versions. */ | ||||
#define JS_HAS_RESERVED_JAVA_KEYWORDS 1 | ||||
#define JS_HAS_RESERVED_ECMA_KEYWORDS 1 | ||||
End of changes. 50 change blocks. | ||||
548 lines changed or deleted | 82 lines changed or added | |||
jscpucfg.h | jscpucfg.h | |||
---|---|---|---|---|
skipping to change at line 45 | skipping to change at line 45 | |||
* the provisions above, a recipient may use your version of this file unde r | * the provisions above, a recipient may use your version of this file unde r | |||
* the terms of any one of the MPL, the GPL or the LGPL. | * the terms of any one of the MPL, the GPL or the LGPL. | |||
* | * | |||
* ***** END LICENSE BLOCK ***** */ | * ***** END LICENSE BLOCK ***** */ | |||
#ifndef js_cpucfg___ | #ifndef js_cpucfg___ | |||
#define js_cpucfg___ | #define js_cpucfg___ | |||
#include "jsosdep.h" | #include "jsosdep.h" | |||
#ifdef XP_MAC | #if defined(XP_WIN) || defined(XP_OS2) || defined(WINCE) | |||
#undef IS_LITTLE_ENDIAN | ||||
#define IS_BIG_ENDIAN 1 | #if defined(_WIN64) | |||
#if defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_) | ||||
#define IS_LITTLE_ENDIAN 1 | ||||
#undef IS_BIG_ENDIAN | ||||
#define JS_BYTES_PER_BYTE 1L | #define JS_BYTES_PER_BYTE 1L | |||
#define JS_BYTES_PER_SHORT 2L | #define JS_BYTES_PER_SHORT 2L | |||
#define JS_BYTES_PER_INT 4L | #define JS_BYTES_PER_INT 4L | |||
#define JS_BYTES_PER_INT64 8L | #define JS_BYTES_PER_INT64 8L | |||
#define JS_BYTES_PER_LONG 4L | #define JS_BYTES_PER_LONG 4L | |||
#define JS_BYTES_PER_FLOAT 4L | #define JS_BYTES_PER_FLOAT 4L | |||
#define JS_BYTES_PER_DOUBLE 8L | #define JS_BYTES_PER_DOUBLE 8L | |||
#define JS_BYTES_PER_WORD 4L | #define JS_BYTES_PER_WORD 8L | |||
#define JS_BYTES_PER_DWORD 8L | #define JS_BYTES_PER_DWORD 8L | |||
#define JS_BITS_PER_BYTE 8L | #define JS_BITS_PER_BYTE 8L | |||
#define JS_BITS_PER_SHORT 16L | #define JS_BITS_PER_SHORT 16L | |||
#define JS_BITS_PER_INT 32L | #define JS_BITS_PER_INT 32L | |||
#define JS_BITS_PER_INT64 64L | #define JS_BITS_PER_INT64 64L | |||
#define JS_BITS_PER_LONG 32L | #define JS_BITS_PER_LONG 32L | |||
#define JS_BITS_PER_FLOAT 32L | #define JS_BITS_PER_FLOAT 32L | |||
#define JS_BITS_PER_DOUBLE 64L | #define JS_BITS_PER_DOUBLE 64L | |||
#define JS_BITS_PER_WORD 32L | #define JS_BITS_PER_WORD 64L | |||
#define JS_BITS_PER_BYTE_LOG2 3L | #define JS_BITS_PER_BYTE_LOG2 3L | |||
#define JS_BITS_PER_SHORT_LOG2 4L | #define JS_BITS_PER_SHORT_LOG2 4L | |||
#define JS_BITS_PER_INT_LOG2 5L | #define JS_BITS_PER_INT_LOG2 5L | |||
#define JS_BITS_PER_INT64_LOG2 6L | #define JS_BITS_PER_INT64_LOG2 6L | |||
#define JS_BITS_PER_LONG_LOG2 5L | #define JS_BITS_PER_LONG_LOG2 5L | |||
#define JS_BITS_PER_FLOAT_LOG2 5L | #define JS_BITS_PER_FLOAT_LOG2 5L | |||
#define JS_BITS_PER_DOUBLE_LOG2 6L | #define JS_BITS_PER_DOUBLE_LOG2 6L | |||
#define JS_BITS_PER_WORD_LOG2 5L | #define JS_BITS_PER_WORD_LOG2 6L | |||
#define JS_ALIGN_OF_SHORT 2L | #define JS_ALIGN_OF_SHORT 2L | |||
#define JS_ALIGN_OF_INT 4L | #define JS_ALIGN_OF_INT 4L | |||
#define JS_ALIGN_OF_LONG 4L | #define JS_ALIGN_OF_LONG 4L | |||
#define JS_ALIGN_OF_INT64 2L | #define JS_ALIGN_OF_INT64 8L | |||
#define JS_ALIGN_OF_FLOAT 4L | #define JS_ALIGN_OF_FLOAT 4L | |||
#define JS_ALIGN_OF_DOUBLE 4L | #define JS_ALIGN_OF_DOUBLE 8L | |||
#define JS_ALIGN_OF_POINTER 4L | #define JS_ALIGN_OF_POINTER 8L | |||
#define JS_ALIGN_OF_WORD 4L | #define JS_ALIGN_OF_WORD 8L | |||
#define JS_BYTES_PER_WORD_LOG2 2L | #define JS_BYTES_PER_WORD_LOG2 3L | |||
#define JS_BYTES_PER_DWORD_LOG2 3L | #define JS_BYTES_PER_DWORD_LOG2 3L | |||
#define PR_WORDS_PER_DWORD_LOG2 1L | #define PR_WORDS_PER_DWORD_LOG2 0L | |||
#else /* !(defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)) */ | ||||
#error "CPU type is unknown" | ||||
#endif /* !(defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)) */ | ||||
#elif defined(XP_WIN) || defined(XP_OS2) | #elif defined(_WIN32) || defined(XP_OS2) || defined(WINCE) | |||
#ifdef __WATCOMC__ | #ifdef __WATCOMC__ | |||
#define HAVE_VA_LIST_AS_ARRAY | #define HAVE_VA_LIST_AS_ARRAY | |||
#endif | #endif | |||
#if defined( _WIN32) || defined(XP_OS2) | ||||
#define IS_LITTLE_ENDIAN 1 | #define IS_LITTLE_ENDIAN 1 | |||
#undef IS_BIG_ENDIAN | #undef IS_BIG_ENDIAN | |||
#define JS_BYTES_PER_BYTE 1L | #define JS_BYTES_PER_BYTE 1L | |||
#define JS_BYTES_PER_SHORT 2L | #define JS_BYTES_PER_SHORT 2L | |||
#define JS_BYTES_PER_INT 4L | #define JS_BYTES_PER_INT 4L | |||
#define JS_BYTES_PER_INT64 8L | #define JS_BYTES_PER_INT64 8L | |||
#define JS_BYTES_PER_LONG 4L | #define JS_BYTES_PER_LONG 4L | |||
#define JS_BYTES_PER_FLOAT 4L | #define JS_BYTES_PER_FLOAT 4L | |||
#define JS_BYTES_PER_DOUBLE 8L | #define JS_BYTES_PER_DOUBLE 8L | |||
skipping to change at line 140 | skipping to change at line 146 | |||
#define JS_ALIGN_OF_LONG 4L | #define JS_ALIGN_OF_LONG 4L | |||
#define JS_ALIGN_OF_INT64 8L | #define JS_ALIGN_OF_INT64 8L | |||
#define JS_ALIGN_OF_FLOAT 4L | #define JS_ALIGN_OF_FLOAT 4L | |||
#define JS_ALIGN_OF_DOUBLE 4L | #define JS_ALIGN_OF_DOUBLE 4L | |||
#define JS_ALIGN_OF_POINTER 4L | #define JS_ALIGN_OF_POINTER 4L | |||
#define JS_ALIGN_OF_WORD 4L | #define JS_ALIGN_OF_WORD 4L | |||
#define JS_BYTES_PER_WORD_LOG2 2L | #define JS_BYTES_PER_WORD_LOG2 2L | |||
#define JS_BYTES_PER_DWORD_LOG2 3L | #define JS_BYTES_PER_DWORD_LOG2 3L | |||
#define PR_WORDS_PER_DWORD_LOG2 1L | #define PR_WORDS_PER_DWORD_LOG2 1L | |||
#endif /* _WIN32 || XP_OS2 */ | #endif /* _WIN32 || XP_OS2 || WINCE*/ | |||
#if defined(_WINDOWS) && !defined(_WIN32) /* WIN16 */ | #if defined(_WINDOWS) && !defined(_WIN32) /* WIN16 */ | |||
#define IS_LITTLE_ENDIAN 1 | #define IS_LITTLE_ENDIAN 1 | |||
#undef IS_BIG_ENDIAN | #undef IS_BIG_ENDIAN | |||
#define JS_BYTES_PER_BYTE 1L | #define JS_BYTES_PER_BYTE 1L | |||
#define JS_BYTES_PER_SHORT 2L | #define JS_BYTES_PER_SHORT 2L | |||
#define JS_BYTES_PER_INT 2L | #define JS_BYTES_PER_INT 2L | |||
#define JS_BYTES_PER_INT64 8L | #define JS_BYTES_PER_INT64 8L | |||
#define JS_BYTES_PER_LONG 4L | #define JS_BYTES_PER_LONG 4L | |||
#define JS_BYTES_PER_FLOAT 4L | #define JS_BYTES_PER_FLOAT 4L | |||
#define JS_BYTES_PER_DOUBLE 8L | #define JS_BYTES_PER_DOUBLE 8L | |||
skipping to change at line 196 | skipping to change at line 204 | |||
#endif /* defined(_WINDOWS) && !defined(_WIN32) */ | #endif /* defined(_WINDOWS) && !defined(_WIN32) */ | |||
#elif defined(XP_UNIX) || defined(XP_BEOS) | #elif defined(XP_UNIX) || defined(XP_BEOS) | |||
#error "This file is supposed to be auto-generated on UNIX platforms, but t he" | #error "This file is supposed to be auto-generated on UNIX platforms, but t he" | |||
#error "static version for Mac and Windows platforms is being used." | #error "static version for Mac and Windows platforms is being used." | |||
#error "Something's probably wrong with paths/headers/dependencies/Makefile s." | #error "Something's probably wrong with paths/headers/dependencies/Makefile s." | |||
#else | #else | |||
#error "Must define one of XP_BEOS, XP_MAC, XP_OS2, XP_WIN, or XP_UNIX" | #error "Must define one of XP_BEOS, XP_OS2, XP_WIN, or XP_UNIX" | |||
#endif | #endif | |||
#ifndef JS_STACK_GROWTH_DIRECTION | #ifndef JS_STACK_GROWTH_DIRECTION | |||
#define JS_STACK_GROWTH_DIRECTION (-1) | #define JS_STACK_GROWTH_DIRECTION (-1) | |||
#endif | #endif | |||
#endif /* js_cpucfg___ */ | #endif /* js_cpucfg___ */ | |||
End of changes. 13 change blocks. | ||||
16 lines changed or deleted | 23 lines changed or added | |||
jsdate.h | jsdate.h | |||
---|---|---|---|---|
skipping to change at line 49 | skipping to change at line 49 | |||
/* | /* | |||
* JS Date class interface. | * JS Date class interface. | |||
*/ | */ | |||
#ifndef jsdate_h___ | #ifndef jsdate_h___ | |||
#define jsdate_h___ | #define jsdate_h___ | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
extern JSClass js_DateClass; | ||||
extern JSObject * | extern JSObject * | |||
js_InitDateClass(JSContext *cx, JSObject *obj); | js_InitDateClass(JSContext *cx, JSObject *obj); | |||
/* | /* | |||
* These functions provide a C interface to the date/time object | * These functions provide a C interface to the date/time object | |||
*/ | */ | |||
/* | /* | |||
* Construct a new Date Object from a time value given in milliseconds UTC | * Construct a new Date Object from a time value given in milliseconds UTC | |||
* since the epoch. | * since the epoch. | |||
*/ | */ | |||
extern JS_FRIEND_API(JSObject*) | extern JS_FRIEND_API(JSObject*) | |||
js_NewDateObjectMsec(JSContext* cx, jsdouble msec_time); | js_NewDateObjectMsec(JSContext* cx, jsdouble msec_time); | |||
/* | /* | |||
* Construct a new Date Object from an exploded local time value. | * Construct a new Date Object from an exploded local time value. | |||
*/ | */ | |||
extern JS_FRIEND_API(JSObject*) | extern JS_FRIEND_API(JSObject*) | |||
js_NewDateObject(JSContext* cx, int year, int mon, int mday, | js_NewDateObject(JSContext* cx, int year, int mon, int mday, | |||
int hour, int min, int sec); | int hour, int min, int sec); | |||
/* | /* | |||
* Detect whether the internal date value is NaN. (Because failure is | * Detect whether the internal date value is NaN. (Because failure is | |||
* out-of-band for js_DateGet*) | * out-of-band for js_DateGet*) | |||
*/ | */ | |||
extern JS_FRIEND_API(JSBool) | extern JS_FRIEND_API(JSBool) | |||
js_DateIsValid(JSContext *cx, JSObject* obj); | js_DateIsValid(JSContext *cx, JSObject* obj); | |||
extern JS_FRIEND_API(int) | extern JS_FRIEND_API(int) | |||
js_DateGetYear(JSContext *cx, JSObject* obj); | js_DateGetYear(JSContext *cx, JSObject* obj); | |||
End of changes. 2 change blocks. | ||||
1 lines changed or deleted | 3 lines changed or added | |||
jsdbgapi.h | jsdbgapi.h | |||
---|---|---|---|---|
skipping to change at line 56 | skipping to change at line 56 | |||
#include "jsopcode.h" | #include "jsopcode.h" | |||
#include "jsprvtd.h" | #include "jsprvtd.h" | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
extern void | extern void | |||
js_PatchOpcode(JSContext *cx, JSScript *script, jsbytecode *pc, JSOp op); | js_PatchOpcode(JSContext *cx, JSScript *script, jsbytecode *pc, JSOp op); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc, | JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc, | |||
JSTrapHandler handler, void *closure); | JSTrapHandler handler, void *closure); | |||
extern JS_PUBLIC_API(JSOp) | extern JS_PUBLIC_API(JSOp) | |||
JS_GetTrapOpcode(JSContext *cx, JSScript *script, jsbytecode *pc); | JS_GetTrapOpcode(JSContext *cx, JSScript *script, jsbytecode *pc); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc, | JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc, | |||
JSTrapHandler *handlerp, void **closurep); | JSTrapHandler *handlerp, void **closurep); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_ClearScriptTraps(JSContext *cx, JSScript *script); | JS_ClearScriptTraps(JSContext *cx, JSScript *script); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_ClearAllTraps(JSContext *cx); | JS_ClearAllTraps(JSContext *cx); | |||
extern JS_PUBLIC_API(JSTrapStatus) | extern JS_PUBLIC_API(JSTrapStatus) | |||
JS_HandleTrap(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval) ; | JS_HandleTrap(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval) ; | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_SetInterrupt(JSRuntime *rt, JSTrapHandler handler, void *closure); | JS_SetInterrupt(JSRuntime *rt, JSTrapHandler handler, void *closure); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_ClearInterrupt(JSRuntime *rt, JSTrapHandler *handlerp, void **closurep); | JS_ClearInterrupt(JSRuntime *rt, JSTrapHandler *handlerp, void **closurep); | |||
/************************************************************************/ | /************************************************************************/ | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsval id, | JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsval id, | |||
JSWatchPointHandler handler, void *closure); | JSWatchPointHandler handler, void *closure); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsval id, | JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsval id, | |||
JSWatchPointHandler *handlerp, void **closurep); | JSWatchPointHandler *handlerp, void **closurep); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj); | JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_ClearAllWatchPoints(JSContext *cx); | JS_ClearAllWatchPoints(JSContext *cx); | |||
#ifdef JS_HAS_OBJ_WATCHPOINT | #ifdef JS_HAS_OBJ_WATCHPOINT | |||
/* | /* | |||
* Hide these non-API function prototypes by testing whether the internal | * Hide these non-API function prototypes by testing whether the internal | |||
* header file "jsconfig.h" has been included. | * header file "jsconfig.h" has been included. | |||
*/ | */ | |||
extern void | extern void | |||
js_MarkWatchPoints(JSRuntime *rt); | js_MarkWatchPoints(JSContext *cx); | |||
extern JSScopeProperty * | extern JSScopeProperty * | |||
js_FindWatchPoint(JSRuntime *rt, JSScope *scope, jsid id); | js_FindWatchPoint(JSRuntime *rt, JSScope *scope, jsid id); | |||
extern JSPropertyOp | extern JSPropertyOp | |||
js_GetWatchedSetter(JSRuntime *rt, JSScope *scope, | js_GetWatchedSetter(JSRuntime *rt, JSScope *scope, | |||
const JSScopeProperty *sprop); | const JSScopeProperty *sprop); | |||
extern JSBool JS_DLL_CALLBACK | extern JSBool JS_DLL_CALLBACK | |||
js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp); | js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp); | |||
skipping to change at line 134 | skipping to change at line 134 | |||
extern JS_PUBLIC_API(uintN) | extern JS_PUBLIC_API(uintN) | |||
JS_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc); | JS_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc); | |||
extern JS_PUBLIC_API(jsbytecode *) | extern JS_PUBLIC_API(jsbytecode *) | |||
JS_LineNumberToPC(JSContext *cx, JSScript *script, uintN lineno); | JS_LineNumberToPC(JSContext *cx, JSScript *script, uintN lineno); | |||
extern JS_PUBLIC_API(JSScript *) | extern JS_PUBLIC_API(JSScript *) | |||
JS_GetFunctionScript(JSContext *cx, JSFunction *fun); | JS_GetFunctionScript(JSContext *cx, JSFunction *fun); | |||
extern JS_PUBLIC_API(JSNative) | ||||
JS_GetFunctionNative(JSContext *cx, JSFunction *fun); | ||||
extern JS_PUBLIC_API(JSPrincipals *) | extern JS_PUBLIC_API(JSPrincipals *) | |||
JS_GetScriptPrincipals(JSContext *cx, JSScript *script); | JS_GetScriptPrincipals(JSContext *cx, JSScript *script); | |||
/* | /* | |||
* Stack Frame Iterator | * Stack Frame Iterator | |||
* | * | |||
* Used to iterate through the JS stack frames to extract | * Used to iterate through the JS stack frames to extract | |||
* information from the frames. | * information from the frames. | |||
*/ | */ | |||
skipping to change at line 167 | skipping to change at line 170 | |||
JS_GetScriptedCaller(JSContext *cx, JSStackFrame *fp); | JS_GetScriptedCaller(JSContext *cx, JSStackFrame *fp); | |||
/* | /* | |||
* Return a weak reference to fp's principals. A null return does not deno te | * Return a weak reference to fp's principals. A null return does not deno te | |||
* an error, it means there are no principals. | * an error, it means there are no principals. | |||
*/ | */ | |||
extern JS_PUBLIC_API(JSPrincipals *) | extern JS_PUBLIC_API(JSPrincipals *) | |||
JS_StackFramePrincipals(JSContext *cx, JSStackFrame *fp); | JS_StackFramePrincipals(JSContext *cx, JSStackFrame *fp); | |||
/* | /* | |||
* Like JS_StackFramePrincipals(cx, caller), but if cx->findObjectPrincipal | * This API is like JS_StackFramePrincipals(cx, caller), except that if | |||
s | * cx->runtime->findObjectPrincipals is non-null, it returns the weaker of | |||
* is non-null, return the object principals for fp's callee function objec | * the caller's principals and the object principals of fp's callee functio | |||
t | n | |||
* (fp->argv[-2]), which is eval, Function, or a similar eval-like method. | * object (fp->argv[-2]), which is eval, Function, or a similar eval-like | |||
* The caller parameter should be the result of JS_GetScriptedCaller(cx, fp | * method. The caller parameter should be JS_GetScriptedCaller(cx, fp). | |||
). | ||||
* | * | |||
* All eval-like methods must use JS_EvalFramePrincipals to acquire a weak | * All eval-like methods must use JS_EvalFramePrincipals to acquire a weak | |||
* reference to the correct principals for the eval call to be secure, give n | * reference to the correct principals for the eval call to be secure, give n | |||
* an embedding that calls JS_SetObjectPrincipalsFinder (see jsapi.h). | * an embedding that calls JS_SetObjectPrincipalsFinder (see jsapi.h). | |||
*/ | */ | |||
extern JS_PUBLIC_API(JSPrincipals *) | extern JS_PUBLIC_API(JSPrincipals *) | |||
JS_EvalFramePrincipals(JSContext *cx, JSStackFrame *fp, JSStackFrame *calle r); | JS_EvalFramePrincipals(JSContext *cx, JSStackFrame *fp, JSStackFrame *calle r); | |||
extern JS_PUBLIC_API(void *) | extern JS_PUBLIC_API(void *) | |||
JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fp); | JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fp); | |||
skipping to change at line 224 | skipping to change at line 228 | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_IsDebuggerFrame(JSContext *cx, JSStackFrame *fp); | JS_IsDebuggerFrame(JSContext *cx, JSStackFrame *fp); | |||
extern JS_PUBLIC_API(jsval) | extern JS_PUBLIC_API(jsval) | |||
JS_GetFrameReturnValue(JSContext *cx, JSStackFrame *fp); | JS_GetFrameReturnValue(JSContext *cx, JSStackFrame *fp); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_SetFrameReturnValue(JSContext *cx, JSStackFrame *fp, jsval rval); | JS_SetFrameReturnValue(JSContext *cx, JSStackFrame *fp, jsval rval); | |||
/** | ||||
* Return fp's callee function object (fp->argv[-2]) if it has one. | ||||
*/ | ||||
extern JS_PUBLIC_API(JSObject *) | ||||
JS_GetFrameCalleeObject(JSContext *cx, JSStackFrame *fp); | ||||
/************************************************************************/ | /************************************************************************/ | |||
extern JS_PUBLIC_API(const char *) | extern JS_PUBLIC_API(const char *) | |||
JS_GetScriptFilename(JSContext *cx, JSScript *script); | JS_GetScriptFilename(JSContext *cx, JSScript *script); | |||
extern JS_PUBLIC_API(uintN) | extern JS_PUBLIC_API(uintN) | |||
JS_GetScriptBaseLineNumber(JSContext *cx, JSScript *script); | JS_GetScriptBaseLineNumber(JSContext *cx, JSScript *script); | |||
extern JS_PUBLIC_API(uintN) | extern JS_PUBLIC_API(uintN) | |||
JS_GetScriptLineExtent(JSContext *cx, JSScript *script); | JS_GetScriptLineExtent(JSContext *cx, JSScript *script); | |||
skipping to change at line 253 | skipping to change at line 263 | |||
* synonyms. | * synonyms. | |||
*/ | */ | |||
#define JS_SetNewScriptHook JS_SetNewScriptHookProc | #define JS_SetNewScriptHook JS_SetNewScriptHookProc | |||
#define JS_SetDestroyScriptHook JS_SetDestroyScriptHookProc | #define JS_SetDestroyScriptHook JS_SetDestroyScriptHookProc | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_SetNewScriptHook(JSRuntime *rt, JSNewScriptHook hook, void *callerdata); | JS_SetNewScriptHook(JSRuntime *rt, JSNewScriptHook hook, void *callerdata); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_SetDestroyScriptHook(JSRuntime *rt, JSDestroyScriptHook hook, | JS_SetDestroyScriptHook(JSRuntime *rt, JSDestroyScriptHook hook, | |||
void *callerdata); | void *callerdata); | |||
/************************************************************************/ | /************************************************************************/ | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_EvaluateUCInStackFrame(JSContext *cx, JSStackFrame *fp, | JS_EvaluateUCInStackFrame(JSContext *cx, JSStackFrame *fp, | |||
const jschar *bytes, uintN length, | const jschar *chars, uintN length, | |||
const char *filename, uintN lineno, | const char *filename, uintN lineno, | |||
jsval *rval); | jsval *rval); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_EvaluateInStackFrame(JSContext *cx, JSStackFrame *fp, | JS_EvaluateInStackFrame(JSContext *cx, JSStackFrame *fp, | |||
const char *bytes, uintN length, | const char *bytes, uintN length, | |||
const char *filename, uintN lineno, | const char *filename, uintN lineno, | |||
jsval *rval); | jsval *rval); | |||
/************************************************************************/ | /************************************************************************/ | |||
typedef struct JSPropertyDesc { | typedef struct JSPropertyDesc { | |||
jsval id; /* primary id, a string or int */ | jsval id; /* primary id, a string or int */ | |||
jsval value; /* property value */ | jsval value; /* property value */ | |||
uint8 flags; /* flags, see below */ | uint8 flags; /* flags, see below */ | |||
uint8 spare; /* unused */ | uint8 spare; /* unused */ | |||
uint16 slot; /* argument/variable slot */ | uint16 slot; /* argument/variable slot */ | |||
jsval alias; /* alias id if JSPD_ALIAS flag */ | jsval alias; /* alias id if JSPD_ALIAS flag */ | |||
skipping to change at line 301 | skipping to change at line 311 | |||
typedef struct JSPropertyDescArray { | typedef struct JSPropertyDescArray { | |||
uint32 length; /* number of elements in array */ | uint32 length; /* number of elements in array */ | |||
JSPropertyDesc *array; /* alloc'd by Get, freed by Put */ | JSPropertyDesc *array; /* alloc'd by Get, freed by Put */ | |||
} JSPropertyDescArray; | } JSPropertyDescArray; | |||
extern JS_PUBLIC_API(JSScopeProperty *) | extern JS_PUBLIC_API(JSScopeProperty *) | |||
JS_PropertyIterator(JSObject *obj, JSScopeProperty **iteratorp); | JS_PropertyIterator(JSObject *obj, JSScopeProperty **iteratorp); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *sprop, | JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *sprop, | |||
JSPropertyDesc *pd); | JSPropertyDesc *pd); | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
JS_GetPropertyDescArray(JSContext *cx, JSObject *obj, JSPropertyDescArray * pda); | JS_GetPropertyDescArray(JSContext *cx, JSObject *obj, JSPropertyDescArray * pda); | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda); | JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda); | |||
/************************************************************************/ | /************************************************************************/ | |||
extern JS_PUBLIC_API(JSBool) | extern JS_PUBLIC_API(JSBool) | |||
skipping to change at line 343 | skipping to change at line 353 | |||
extern JS_PUBLIC_API(size_t) | extern JS_PUBLIC_API(size_t) | |||
JS_GetObjectTotalSize(JSContext *cx, JSObject *obj); | JS_GetObjectTotalSize(JSContext *cx, JSObject *obj); | |||
extern JS_PUBLIC_API(size_t) | extern JS_PUBLIC_API(size_t) | |||
JS_GetFunctionTotalSize(JSContext *cx, JSFunction *fun); | JS_GetFunctionTotalSize(JSContext *cx, JSFunction *fun); | |||
extern JS_PUBLIC_API(size_t) | extern JS_PUBLIC_API(size_t) | |||
JS_GetScriptTotalSize(JSContext *cx, JSScript *script); | JS_GetScriptTotalSize(JSContext *cx, JSScript *script); | |||
/* | ||||
* Get the top-most running script on cx starting from fp, or from the top | ||||
of | ||||
* cx's frame stack if fp is null, and return its script filename flags. I | ||||
f | ||||
* the script has a null filename member, return JSFILENAME_NULL. | ||||
*/ | ||||
extern JS_PUBLIC_API(uint32) | ||||
JS_GetTopScriptFilenameFlags(JSContext *cx, JSStackFrame *fp); | ||||
/* | ||||
* Get the script filename flags for the script. If the script doesn't hav | ||||
e a | ||||
* filename, return JSFILENAME_NULL. | ||||
*/ | ||||
extern JS_PUBLIC_API(uint32) | ||||
JS_GetScriptFilenameFlags(JSScript *script); | ||||
/* | ||||
* Associate flags with a script filename prefix in rt, so that any subsequ | ||||
ent | ||||
* script compilation will inherit those flags if the script's filename is | ||||
the | ||||
* same as prefix, or if prefix is a substring of the script's filename. | ||||
* | ||||
* The API defines only one flag bit, JSFILENAME_SYSTEM, leaving the remain | ||||
ing | ||||
* 31 bits up to the API client to define. The union of all 32 bits must n | ||||
ot | ||||
* be a legal combination, however, in order to preserve JSFILENAME_NULL as | ||||
a | ||||
* unique value. API clients may depend on JSFILENAME_SYSTEM being a set b | ||||
it | ||||
* in JSFILENAME_NULL -- a script with a null filename member is presumed t | ||||
o | ||||
* be a "system" script. | ||||
*/ | ||||
extern JS_PUBLIC_API(JSBool) | ||||
JS_FlagScriptFilenamePrefix(JSRuntime *rt, const char *prefix, uint32 flags | ||||
); | ||||
#define JSFILENAME_NULL 0xffffffff /* null script filename */ | ||||
#define JSFILENAME_SYSTEM 0x00000001 /* "system" script, see bel | ||||
ow */ | ||||
/* | ||||
* Return true if obj is a "system" object, that is, one flagged by a prior | ||||
* call to JS_FlagSystemObject(cx, obj). What "system" means is up to the | ||||
API | ||||
* client, but it can be used to coordinate access control policies based o | ||||
n | ||||
* script filenames and their prefixes, using JS_FlagScriptFilenamePrefix a | ||||
nd | ||||
* JS_GetTopScriptFilenameFlags. | ||||
*/ | ||||
extern JS_PUBLIC_API(JSBool) | ||||
JS_IsSystemObject(JSContext *cx, JSObject *obj); | ||||
/* | ||||
* Flag obj as a "system" object. The API client can flag system objects t | ||||
o | ||||
* optimize access control checks. The engine stores but does not interpre | ||||
t | ||||
* the per-object flag set by this call. | ||||
*/ | ||||
extern JS_PUBLIC_API(void) | ||||
JS_FlagSystemObject(JSContext *cx, JSObject *obj); | ||||
JS_END_EXTERN_C | JS_END_EXTERN_C | |||
#endif /* jsdbgapi_h___ */ | #endif /* jsdbgapi_h___ */ | |||
End of changes. 13 change blocks. | ||||
18 lines changed or deleted | 94 lines changed or added | |||
jsdhash.h | jsdhash.h | |||
---|---|---|---|---|
skipping to change at line 50 | skipping to change at line 50 | |||
#define jsdhash_h___ | #define jsdhash_h___ | |||
/* | /* | |||
* Double hashing, a la Knuth 6. | * Double hashing, a la Knuth 6. | |||
*/ | */ | |||
#include "jstypes.h" | #include "jstypes.h" | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
#if defined(__GNUC__) && defined(__i386__) && (__GNUC__ >= 3) && !defined(X P_OS2) | #if defined(__GNUC__) && defined(__i386__) && (__GNUC__ >= 3) && !defined(X P_OS2) | |||
#define JS_DHASH_FASTCALL __attribute__ ((regparm (3),stdcall)) | #define JS_DHASH_FASTCALL __attribute__ ((regparm (3),stdcall)) | |||
#elif defined(XP_WIN) | ||||
#define JS_DHASH_FASTCALL __fastcall | ||||
#else | #else | |||
#define JS_DHASH_FASTCALL | #define JS_DHASH_FASTCALL | |||
#endif | #endif | |||
#ifdef DEBUG_XXXbrendan | #ifdef DEBUG_XXXbrendan | |||
#define JS_DHASHMETER 1 | #define JS_DHASHMETER 1 | |||
#endif | #endif | |||
/* Table size limit, do not equal or exceed (see min&maxAlphaFrac, below). */ | /* Table size limit, do not equal or exceed (see min&maxAlphaFrac, below). */ | |||
#undef JS_DHASH_SIZE_LIMIT | #undef JS_DHASH_SIZE_LIMIT | |||
skipping to change at line 442 | skipping to change at line 444 | |||
uint32 entrySize, uint32 capacity); | uint32 entrySize, uint32 capacity); | |||
/* | /* | |||
* Set maximum and minimum alpha for table. The defaults are 0.75 and .25. | * Set maximum and minimum alpha for table. The defaults are 0.75 and .25. | |||
* maxAlpha must be in [0.5, 0.9375] for the default JS_DHASH_MIN_SIZE; or if | * maxAlpha must be in [0.5, 0.9375] for the default JS_DHASH_MIN_SIZE; or if | |||
* MinSize=JS_DHASH_MIN_SIZE <= 256, in [0.5, (float)(MinSize-1)/MinSize]; or | * MinSize=JS_DHASH_MIN_SIZE <= 256, in [0.5, (float)(MinSize-1)/MinSize]; or | |||
* else in [0.5, 255.0/256]. minAlpha must be in [0, maxAlpha / 2), so tha t | * else in [0.5, 255.0/256]. minAlpha must be in [0, maxAlpha / 2), so tha t | |||
* we don't shrink on the very next remove after growing a table upon addin g | * we don't shrink on the very next remove after growing a table upon addin g | |||
* an entry that brings entryCount past maxAlpha * tableSize. | * an entry that brings entryCount past maxAlpha * tableSize. | |||
*/ | */ | |||
JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_DHashTableSetAlphaBounds(JSDHashTable *table, | JS_DHashTableSetAlphaBounds(JSDHashTable *table, | |||
float maxAlpha, | float maxAlpha, | |||
float minAlpha); | float minAlpha); | |||
/* | /* | |||
* Call this macro with k, the number of pointer-sized words wasted per ent ry | * Call this macro with k, the number of pointer-sized words wasted per ent ry | |||
* under chaining, to compute the minimum alpha at which double hashing sti ll | * under chaining, to compute the minimum alpha at which double hashing sti ll | |||
* beats chaining. | * beats chaining. | |||
*/ | */ | |||
#define JS_DHASH_MIN_ALPHA(table, k) \ | #define JS_DHASH_MIN_ALPHA(table, k) \ | |||
End of changes. 2 change blocks. | ||||
1 lines changed or deleted | 3 lines changed or added | |||
jsemit.h | jsemit.h | |||
---|---|---|---|---|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | /* -*- 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 ***** | * ***** BEGIN LICENSE BLOCK ***** | |||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | |||
* | * | |||
* The contents of this file are subject to the Mozilla Public License Vers ion | * The contents of this file are subject to the Mozilla Public License Vers ion | |||
* 1.1 (the "License"); you may not use this file except in compliance with | * 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 | * the License. You may obtain a copy of the License at | |||
* http://www.mozilla.org/MPL/ | * http://www.mozilla.org/MPL/ | |||
* | * | |||
* Software distributed under the License is distributed on an "AS IS" basi s, | * Software distributed under the License is distributed on an "AS IS" basi s, | |||
skipping to change at line 56 | skipping to change at line 57 | |||
#include "jsstddef.h" | #include "jsstddef.h" | |||
#include "jstypes.h" | #include "jstypes.h" | |||
#include "jsatom.h" | #include "jsatom.h" | |||
#include "jsopcode.h" | #include "jsopcode.h" | |||
#include "jsprvtd.h" | #include "jsprvtd.h" | |||
#include "jspubtd.h" | #include "jspubtd.h" | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
/* | /* | |||
* NB: If you add non-loop STMT_* enumerators, do so before STMT_DO_LOOP or | * NB: If you add enumerators for scope statements, add them between STMT_W | |||
* you will break the STMT_IS_LOOP macro, just below this enum. | ITH | |||
* and STMT_CATCH, or you will break the STMT_TYPE_IS_SCOPE macro. If you | ||||
add | ||||
* non-looping statement enumerators, add them before STMT_DO_LOOP or you w | ||||
ill | ||||
* break the STMT_TYPE_IS_LOOP macro. | ||||
* | ||||
* Also remember to keep the statementName array in jsemit.c in sync. | ||||
*/ | */ | |||
typedef enum JSStmtType { | typedef enum JSStmtType { | |||
STMT_BLOCK = 0, /* compound statement: { s1[;... sN] } */ | STMT_LABEL, /* labeled statement: L: s */ | |||
STMT_LABEL = 1, /* labeled statement: L: s */ | STMT_IF, /* if (then) statement */ | |||
STMT_IF = 2, /* if (then) statement */ | STMT_ELSE, /* else clause of if statement */ | |||
STMT_ELSE = 3, /* else clause of if statement */ | STMT_BODY, /* synthetic body of function with | |||
STMT_SWITCH = 4, /* switch statement */ | destructuring formal parameters */ | |||
STMT_WITH = 5, /* with statement */ | STMT_BLOCK, /* compound statement: { s1[;... sN] } */ | |||
STMT_TRY = 6, /* try statement */ | STMT_SWITCH, /* switch statement */ | |||
STMT_CATCH = 7, /* catch block */ | STMT_WITH, /* with statement */ | |||
STMT_FINALLY = 8, /* finally statement */ | STMT_CATCH, /* catch block */ | |||
STMT_SUBROUTINE = 9, /* gosub-target subroutine body */ | STMT_TRY, /* try block */ | |||
STMT_DO_LOOP = 10, /* do/while loop statement */ | STMT_FINALLY, /* finally block */ | |||
STMT_FOR_LOOP = 11, /* for loop statement */ | STMT_SUBROUTINE, /* gosub-target subroutine body */ | |||
STMT_FOR_IN_LOOP = 12, /* for/in loop statement */ | STMT_DO_LOOP, /* do/while loop statement */ | |||
STMT_WHILE_LOOP = 13 /* while loop statement */ | STMT_FOR_LOOP, /* for loop statement */ | |||
STMT_FOR_IN_LOOP, /* for/in loop statement */ | ||||
STMT_WHILE_LOOP /* while loop statement */ | ||||
} JSStmtType; | } JSStmtType; | |||
#define STMT_IS_LOOP(stmt) ((stmt)->type >= STMT_DO_LOOP) | #define STMT_TYPE_IN_RANGE(t,b,e) ((uint)((t) - (b)) <= (uintN)((e) - (b))) | |||
/* | ||||
* A comment on the encoding of the JSStmtType enum and type-testing macros | ||||
: | ||||
* | ||||
* STMT_TYPE_MAYBE_SCOPE tells whether a statement type is always, or may | ||||
* become, a lexical scope. It therefore includes block and switch (the tw | ||||
o | ||||
* low-numbered "maybe" scope types) and excludes with (with has dynamic sc | ||||
ope | ||||
* pending the "reformed with" in ES4/JS2). It includes all try-catch-fina | ||||
lly | ||||
* types, which are high-numbered maybe-scope types. | ||||
* | ||||
* STMT_TYPE_LINKS_SCOPE tells whether a JSStmtInfo of the given type eager | ||||
ly | ||||
* links to other scoping statement info records. It excludes the two earl | ||||
y | ||||
* "maybe" types, block and switch, as well as the try and both finally typ | ||||
es, | ||||
* since try and the other trailing maybe-scope types don't need block scop | ||||
e | ||||
* unless they contain let declarations. | ||||
* | ||||
* We treat with as a static scope because it prevents lexical binding from | ||||
* continuing further up the static scope chain. With the "reformed with" | ||||
* proposal for JS2, we'll be able to model it statically, too. | ||||
*/ | ||||
#define STMT_TYPE_MAYBE_SCOPE(type) | ||||
\ | ||||
(type != STMT_WITH && | ||||
\ | ||||
STMT_TYPE_IN_RANGE(type, STMT_BLOCK, STMT_SUBROUTINE)) | ||||
#define STMT_TYPE_LINKS_SCOPE(type) | ||||
\ | ||||
STMT_TYPE_IN_RANGE(type, STMT_WITH, STMT_CATCH) | ||||
#define STMT_TYPE_IS_TRYING(type) | ||||
\ | ||||
STMT_TYPE_IN_RANGE(type, STMT_TRY, STMT_SUBROUTINE) | ||||
#define STMT_TYPE_IS_LOOP(type) ((type) >= STMT_DO_LOOP) | ||||
#define STMT_MAYBE_SCOPE(stmt) STMT_TYPE_MAYBE_SCOPE((stmt)->type) | ||||
#define STMT_LINKS_SCOPE(stmt) (STMT_TYPE_LINKS_SCOPE((stmt)->type) || | ||||
\ | ||||
((stmt)->flags & SIF_SCOPE)) | ||||
#define STMT_IS_TRYING(stmt) STMT_TYPE_IS_TRYING((stmt)->type) | ||||
#define STMT_IS_LOOP(stmt) STMT_TYPE_IS_LOOP((stmt)->type) | ||||
typedef struct JSStmtInfo JSStmtInfo; | typedef struct JSStmtInfo JSStmtInfo; | |||
struct JSStmtInfo { | struct JSStmtInfo { | |||
JSStmtType type; /* statement type */ | uint16 type; /* statement type */ | |||
uint16 flags; /* flags, see below */ | ||||
ptrdiff_t update; /* loop update offset (top if none) */ | ptrdiff_t update; /* loop update offset (top if none) */ | |||
ptrdiff_t breaks; /* offset of last break in loop */ | ptrdiff_t breaks; /* offset of last break in loop */ | |||
ptrdiff_t continues; /* offset of last continue in loop */ | ptrdiff_t continues; /* offset of last continue in loop */ | |||
ptrdiff_t gosub; /* offset of last GOSUB for this finall | JSAtom *atom; /* name of LABEL, or block scope object | |||
y */ | */ | |||
ptrdiff_t catchJump; /* offset of last end-of-catch jump */ | ||||
JSAtom *label; /* name of LABEL or CATCH var */ | ||||
JSStmtInfo *down; /* info for enclosing statement */ | JSStmtInfo *down; /* info for enclosing statement */ | |||
JSStmtInfo *downScope; /* next enclosing lexical scope */ | ||||
}; | }; | |||
#define SIF_SCOPE 0x0001 /* statement has its own lexical scope | ||||
*/ | ||||
#define SIF_BODY_BLOCK 0x0002 /* STMT_BLOCK type is a function body * | ||||
/ | ||||
/* | ||||
* To reuse space in JSStmtInfo, rename breaks and continues for use during | ||||
* try/catch/finally code generation and backpatching. To match most commo | ||||
n | ||||
* use cases, the macro argument is a struct, not a struct pointer. Only a | ||||
* loop, switch, or label statement info record can have breaks and continu | ||||
es, | ||||
* and only a for loop has an update backpatch chain, so it's safe to overl | ||||
ay | ||||
* these for the "trying" JSStmtTypes. | ||||
*/ | ||||
#define CATCHNOTE(stmt) ((stmt).update) | ||||
#define GOSUBS(stmt) ((stmt).breaks) | ||||
#define GUARDJUMP(stmt) ((stmt).continues) | ||||
#define AT_TOP_LEVEL(tc) | ||||
\ | ||||
(!(tc)->topStmt || ((tc)->topStmt->flags & SIF_BODY_BLOCK)) | ||||
#define SET_STATEMENT_TOP(stmt, top) \ | #define SET_STATEMENT_TOP(stmt, top) \ | |||
((stmt)->update = (top), (stmt)->breaks = | ((stmt)->update = (top), (stmt)->breaks = (stmt)->continues = (-1)) | |||
\ | ||||
(stmt)->continues = (stmt)->catchJump = (stmt)->gosub = (-1)) | ||||
struct JSTreeContext { /* tree context for semantic checks */ | struct JSTreeContext { /* tree context for semantic checks */ | |||
uint16 flags; /* statement state flags, see below */ | uint16 flags; /* statement state flags, see below */ | |||
uint16 numGlobalVars; /* max. no. of global variables/regexps */ | uint16 numGlobalVars; /* max. no. of global variables/regexps */ | |||
uint32 tryCount; /* total count of try statements parsed */ | uint32 tryCount; /* total count of try statements parsed */ | |||
uint32 globalUses; /* optimizable global var uses in total */ | uint32 globalUses; /* optimizable global var uses in total */ | |||
uint32 loopyGlobalUses;/* optimizable global var uses in loops */ | uint32 loopyGlobalUses;/* optimizable global var uses in loops */ | |||
JSStmtInfo *topStmt; /* top of statement info stack */ | JSStmtInfo *topStmt; /* top of statement info stack */ | |||
JSStmtInfo *topScopeStmt; /* top lexical scope statement */ | ||||
JSObject *blockChain; /* compile time block scope chain (NB: | ||||
one | ||||
deeper than the topScopeStmt/downSco | ||||
pe | ||||
chain when in head of let block/expr | ||||
) */ | ||||
JSParseNode *blockNode; /* parse node for a lexical scope. | ||||
XXX combine with blockChain? */ | ||||
JSAtomList decls; /* function, const, and var declaration s */ | JSAtomList decls; /* function, const, and var declaration s */ | |||
JSParseNode *nodeList; /* list of recyclable parse-node struct s */ | JSParseNode *nodeList; /* list of recyclable parse-node struct s */ | |||
}; | }; | |||
#define TCF_COMPILING 0x01 /* generating bytecode; this tc is a cg */ | #define TCF_COMPILING 0x01 /* generating bytecode; this tc is a cg */ | |||
#define TCF_IN_FUNCTION 0x02 /* parsing inside function body */ | #define TCF_IN_FUNCTION 0x02 /* parsing inside function body */ | |||
#define TCF_RETURN_EXPR 0x04 /* function has 'return expr;' */ | #define TCF_RETURN_EXPR 0x04 /* function has 'return expr;' */ | |||
#define TCF_RETURN_VOID 0x08 /* function has 'return;' */ | #define TCF_RETURN_VOID 0x08 /* function has 'return;' */ | |||
#define TCF_RETURN_FLAGS 0x0C /* propagate these out of blocks */ | ||||
#define TCF_IN_FOR_INIT 0x10 /* parsing init expr of for; exclude 'i n' */ | #define TCF_IN_FOR_INIT 0x10 /* parsing init expr of for; exclude 'i n' */ | |||
#define TCF_FUN_CLOSURE_VS_VAR 0x20 /* function and var with same name */ | #define TCF_FUN_CLOSURE_VS_VAR 0x20 /* function and var with same name */ | |||
#define TCF_FUN_USES_NONLOCALS 0x40 /* function refers to non-local names * / | #define TCF_FUN_USES_NONLOCALS 0x40 /* function refers to non-local names * / | |||
#define TCF_FUN_HEAVYWEIGHT 0x80 /* function needs Call object per call */ | #define TCF_FUN_HEAVYWEIGHT 0x80 /* function needs Call object per call */ | |||
#define TCF_FUN_FLAGS 0xE0 /* flags to propagate from FunctionBody | #define TCF_FUN_IS_GENERATOR 0x100 /* parsed yield statement in function * | |||
*/ | / | |||
#define TCF_FUN_FLAGS 0x1E0 /* flags to propagate from FunctionBody | ||||
*/ | ||||
#define TCF_HAS_DEFXMLNS 0x200 /* default xml namespace = ...; parsed | ||||
*/ | ||||
#define TCF_HAS_FUNCTION_STMT 0x400 /* block contains a function statement | ||||
*/ | ||||
#define TREE_CONTEXT_INIT(tc) \ | #define TREE_CONTEXT_INIT(tc) \ | |||
((tc)->flags = (tc)->numGlobalVars = 0, \ | ((tc)->flags = (tc)->numGlobalVars = 0, \ | |||
(tc)->tryCount = (tc)->globalUses = (tc)->loopyGlobalUses = 0, \ | (tc)->tryCount = (tc)->globalUses = (tc)->loopyGlobalUses = 0, \ | |||
(tc)->topStmt = NULL, ATOM_LIST_INIT(&(tc)->decls), | (tc)->topStmt = (tc)->topScopeStmt = NULL, | |||
\ | \ | |||
(tc)->nodeList = NULL) | (tc)->blockChain = NULL, | |||
\ | ||||
ATOM_LIST_INIT(&(tc)->decls), | ||||
\ | ||||
(tc)->nodeList = NULL, (tc)->blockNode = NULL) | ||||
#define TREE_CONTEXT_FINISH(tc) \ | #define TREE_CONTEXT_FINISH(tc) \ | |||
((void)0) | ((void)0) | |||
/* | /* | |||
* Span-dependent instructions are jumps whose span (from the jump bytecode to | * Span-dependent instructions are jumps whose span (from the jump bytecode to | |||
* the jump target) may require 2 or 4 bytes of immediate operand. | * the jump target) may require 2 or 4 bytes of immediate operand. | |||
*/ | */ | |||
typedef struct JSSpanDep JSSpanDep; | typedef struct JSSpanDep JSSpanDep; | |||
typedef struct JSJumpTarget JSJumpTarget; | typedef struct JSJumpTarget JSJumpTarget; | |||
skipping to change at line 175 | skipping to change at line 248 | |||
#define JT_CLR_TAG(jt) ((JSJumpTarget *)((jsword)(jt) & ~JT_TAG_BI T)) | #define JT_CLR_TAG(jt) ((JSJumpTarget *)((jsword)(jt) & ~JT_TAG_BI T)) | |||
#define JT_HAS_TAG(jt) ((jsword)(jt) & JT_TAG_BIT) | #define JT_HAS_TAG(jt) ((jsword)(jt) & JT_TAG_BIT) | |||
#define BITS_PER_PTRDIFF (sizeof(ptrdiff_t) * JS_BITS_PER_BYTE) | #define BITS_PER_PTRDIFF (sizeof(ptrdiff_t) * JS_BITS_PER_BYTE) | |||
#define BITS_PER_BPDELTA (BITS_PER_PTRDIFF - 1 - JT_UNTAG_SHIFT) | #define BITS_PER_BPDELTA (BITS_PER_PTRDIFF - 1 - JT_UNTAG_SHIFT) | |||
#define BPDELTA_MAX (((ptrdiff_t)1 << BITS_PER_BPDELTA) - 1) | #define BPDELTA_MAX (((ptrdiff_t)1 << BITS_PER_BPDELTA) - 1) | |||
#define BPDELTA_TO_JT(bp) ((JSJumpTarget *)((bp) << JT_UNTAG_SHIFT)) | #define BPDELTA_TO_JT(bp) ((JSJumpTarget *)((bp) << JT_UNTAG_SHIFT)) | |||
#define JT_TO_BPDELTA(jt) ((ptrdiff_t)((jsword)(jt) >> JT_UNTAG_SHIFT )) | #define JT_TO_BPDELTA(jt) ((ptrdiff_t)((jsword)(jt) >> JT_UNTAG_SHIFT )) | |||
#define SD_SET_TARGET(sd,jt) ((sd)->target = JT_SET_TAG(jt)) | #define SD_SET_TARGET(sd,jt) ((sd)->target = JT_SET_TAG(jt)) | |||
#define SD_GET_TARGET(sd) (JS_ASSERT(JT_HAS_TAG((sd)->target)), | ||||
\ | ||||
JT_CLR_TAG((sd)->target)) | ||||
#define SD_SET_BPDELTA(sd,bp) ((sd)->target = BPDELTA_TO_JT(bp)) | #define SD_SET_BPDELTA(sd,bp) ((sd)->target = BPDELTA_TO_JT(bp)) | |||
#define SD_GET_BPDELTA(sd) (JS_ASSERT(!JT_HAS_TAG((sd)->target)), \ | #define SD_GET_BPDELTA(sd) (JS_ASSERT(!JT_HAS_TAG((sd)->target)), \ | |||
JT_TO_BPDELTA((sd)->target)) | JT_TO_BPDELTA((sd)->target)) | |||
#define SD_TARGET_OFFSET(sd) (JS_ASSERT(JT_HAS_TAG((sd)->target)), | ||||
\ | /* Avoid asserting twice by expanding SD_GET_TARGET in the "then" clause. * | |||
JT_CLR_TAG((sd)->target)->offset) | / | |||
#define SD_SPAN(sd,pivot) (SD_GET_TARGET(sd) | ||||
\ | ||||
? JT_CLR_TAG((sd)->target)->offset - (pivo | ||||
t) \ | ||||
: 0) | ||||
struct JSCodeGenerator { | struct JSCodeGenerator { | |||
JSTreeContext treeContext; /* base state: statement info stack, et c. */ | JSTreeContext treeContext; /* base state: statement info stack, et c. */ | |||
JSArenaPool *codePool; /* pointer to thread code arena pool */ | JSArenaPool *codePool; /* pointer to thread code arena pool */ | |||
JSArenaPool *notePool; /* pointer to thread srcnote arena pool */ | JSArenaPool *notePool; /* pointer to thread srcnote arena pool */ | |||
void *codeMark; /* low watermark in cg->codePool */ | void *codeMark; /* low watermark in cg->codePool */ | |||
void *noteMark; /* low watermark in cg->notePool */ | void *noteMark; /* low watermark in cg->notePool */ | |||
void *tempMark; /* low watermark in cx->tempPool */ | void *tempMark; /* low watermark in cx->tempPool */ | |||
struct { | struct { | |||
jsbytecode *base; /* base of JS bytecode vector */ | jsbytecode *base; /* base of JS bytecode vector */ | |||
jsbytecode *limit; /* one byte beyond end of bytecode */ | jsbytecode *limit; /* one byte beyond end of bytecode */ | |||
jsbytecode *next; /* pointer to next free bytecode */ | jsbytecode *next; /* pointer to next free bytecode */ | |||
jssrcnote *notes; /* source notes, see below */ | jssrcnote *notes; /* source notes, see below */ | |||
uintN noteCount; /* number of source notes so far */ | uintN noteCount; /* number of source notes so far */ | |||
uintN noteMask; /* growth increment for notes */ | uintN noteMask; /* growth increment for notes */ | |||
ptrdiff_t lastNoteOffset; /* code offset for last source note */ | ptrdiff_t lastNoteOffset; /* code offset for last source note */ | |||
uintN currentLine; /* line number for tree-based srcnote g en */ | uintN currentLine; /* line number for tree-based srcnote g en */ | |||
} prolog, main, *current; | } prolog, main, *current; | |||
skipping to change at line 198 | skipping to change at line 278 | |||
struct { | struct { | |||
jsbytecode *base; /* base of JS bytecode vector */ | jsbytecode *base; /* base of JS bytecode vector */ | |||
jsbytecode *limit; /* one byte beyond end of bytecode */ | jsbytecode *limit; /* one byte beyond end of bytecode */ | |||
jsbytecode *next; /* pointer to next free bytecode */ | jsbytecode *next; /* pointer to next free bytecode */ | |||
jssrcnote *notes; /* source notes, see below */ | jssrcnote *notes; /* source notes, see below */ | |||
uintN noteCount; /* number of source notes so far */ | uintN noteCount; /* number of source notes so far */ | |||
uintN noteMask; /* growth increment for notes */ | uintN noteMask; /* growth increment for notes */ | |||
ptrdiff_t lastNoteOffset; /* code offset for last source note */ | ptrdiff_t lastNoteOffset; /* code offset for last source note */ | |||
uintN currentLine; /* line number for tree-based srcnote g en */ | uintN currentLine; /* line number for tree-based srcnote g en */ | |||
} prolog, main, *current; | } prolog, main, *current; | |||
const char *filename; /* null or weak link to source filename */ | const char *filename; /* null or weak link to source filename */ | |||
uintN firstLine; /* first line, for js_NewScriptFromCG * / | uintN firstLine; /* first line, for js_NewScriptFromCG * / | |||
JSPrincipals *principals; /* principals for constant folding eval */ | JSPrincipals *principals; /* principals for constant folding eval */ | |||
JSAtomList atomList; /* literals indexed for mapping */ | JSAtomList atomList; /* literals indexed for mapping */ | |||
intN stackDepth; /* current stack depth in script frame */ | intN stackDepth; /* current stack depth in script frame */ | |||
uintN maxStackDepth; /* maximum stack depth so far */ | uintN maxStackDepth; /* maximum stack depth so far */ | |||
JSTryNote *tryBase; /* first exception handling note */ | JSTryNote *tryBase; /* first exception handling note */ | |||
JSTryNote *tryNext; /* next available note */ | JSTryNote *tryNext; /* next available note */ | |||
size_t tryNoteSpace; /* # of bytes allocated at tryBase */ | size_t tryNoteSpace; /* # of bytes allocated at tryBase */ | |||
JSSpanDep *spanDeps; /* span dependent instruction records * / | JSSpanDep *spanDeps; /* span dependent instruction records * / | |||
JSJumpTarget *jumpTargets; /* AVL tree of jump target offsets */ | JSJumpTarget *jumpTargets; /* AVL tree of jump target offsets */ | |||
JSJumpTarget *jtFreeList; /* JT_LEFT-linked list of free structs */ | JSJumpTarget *jtFreeList; /* JT_LEFT-linked list of free structs */ | |||
uintN numSpanDeps; /* number of span dependencies */ | uintN numSpanDeps; /* number of span dependencies */ | |||
uintN numJumpTargets; /* number of jump targets */ | uintN numJumpTargets; /* number of jump targets */ | |||
ptrdiff_t spanDepTodo; /* offset from main.base of potentially | ||||
unoptimized spandeps */ | ||||
uintN arrayCompSlot; /* stack slot of array in comprehension | ||||
*/ | ||||
uintN emitLevel; /* js_EmitTree recursion level */ | uintN emitLevel; /* js_EmitTree recursion level */ | |||
JSAtomList constList; /* compile time constants */ | JSAtomList constList; /* compile time constants */ | |||
JSCodeGenerator *parent; /* Enclosing function or global context */ | JSCodeGenerator *parent; /* Enclosing function or global context */ | |||
}; | }; | |||
#define CG_BASE(cg) ((cg)->current->base) | #define CG_BASE(cg) ((cg)->current->base) | |||
#define CG_LIMIT(cg) ((cg)->current->limit) | #define CG_LIMIT(cg) ((cg)->current->limit) | |||
#define CG_NEXT(cg) ((cg)->current->next) | #define CG_NEXT(cg) ((cg)->current->next) | |||
#define CG_CODE(cg,offset) (CG_BASE(cg) + (offset)) | #define CG_CODE(cg,offset) (CG_BASE(cg) + (offset)) | |||
#define CG_OFFSET(cg) PTRDIFF(CG_NEXT(cg), CG_BASE(cg), jsbytecod e) | #define CG_OFFSET(cg) PTRDIFF(CG_NEXT(cg), CG_BASE(cg), jsbytecod e) | |||
skipping to change at line 302 | skipping to change at line 391 | |||
return JS_FALSE; \ | return JS_FALSE; \ | |||
JS_END_MACRO | JS_END_MACRO | |||
#define CHECK_AND_SET_JUMP_OFFSET_AT(cx,cg,off) \ | #define CHECK_AND_SET_JUMP_OFFSET_AT(cx,cg,off) \ | |||
CHECK_AND_SET_JUMP_OFFSET(cx, cg, CG_CODE(cg,off), CG_OFFSET(cg) - (off )) | CHECK_AND_SET_JUMP_OFFSET(cx, cg, CG_CODE(cg,off), CG_OFFSET(cg) - (off )) | |||
extern JSBool | extern JSBool | |||
js_SetJumpOffset(JSContext *cx, JSCodeGenerator *cg, jsbytecode *pc, | js_SetJumpOffset(JSContext *cx, JSCodeGenerator *cg, jsbytecode *pc, | |||
ptrdiff_t off); | ptrdiff_t off); | |||
/* Test whether we're in a with statement. */ | /* Test whether we're in a statement of given type. */ | |||
extern JSBool | extern JSBool | |||
js_InWithStatement(JSTreeContext *tc); | js_InStatement(JSTreeContext *tc, JSStmtType type); | |||
/* Test whether we're in a catch block with exception named by atom. */ | /* Test whether we're in a with statement. */ | |||
#define js_InWithStatement(tc) js_InStatement(tc, STMT_WITH) | ||||
/* | ||||
* Test whether atom refers to a global variable (or is a reference error). | ||||
* Return true in *loopyp if any loops enclose the lexical reference, false | ||||
* otherwise. | ||||
*/ | ||||
extern JSBool | extern JSBool | |||
js_InCatchBlock(JSTreeContext *tc, JSAtom *atom); | js_IsGlobalReference(JSTreeContext *tc, JSAtom *atom, JSBool *loopyp); | |||
/* | /* | |||
* Push the C-stack-allocated struct at stmt onto the stmtInfo stack. | * Push the C-stack-allocated struct at stmt onto the stmtInfo stack. | |||
*/ | */ | |||
extern void | extern void | |||
js_PushStatement(JSTreeContext *tc, JSStmtInfo *stmt, JSStmtType type, | js_PushStatement(JSTreeContext *tc, JSStmtInfo *stmt, JSStmtType type, | |||
ptrdiff_t top); | ptrdiff_t top); | |||
/* | /* | |||
* Push a block scope statement and link blockAtom's object-valued key into | ||||
* tc->blockChain. To pop this statement info record, use js_PopStatement | ||||
as | ||||
* usual, or if appropriate (if generating code), js_PopStatementCG. | ||||
*/ | ||||
extern void | ||||
js_PushBlockScope(JSTreeContext *tc, JSStmtInfo *stmt, JSAtom *blockAtom, | ||||
ptrdiff_t top); | ||||
/* | ||||
* Pop tc->topStmt. If the top JSStmtInfo struct is not stack-allocated, i t | * Pop tc->topStmt. If the top JSStmtInfo struct is not stack-allocated, i t | |||
* is up to the caller to free it. | * is up to the caller to free it. | |||
*/ | */ | |||
extern void | extern void | |||
js_PopStatement(JSTreeContext *tc); | js_PopStatement(JSTreeContext *tc); | |||
/* | /* | |||
* Like js_PopStatement(&cg->treeContext), also patch breaks and continues. | * Like js_PopStatement(&cg->treeContext), also patch breaks and continues | |||
* unless the top statement info record represents a try-catch-finally suit | ||||
e. | ||||
* May fail if a jump offset overflows. | * May fail if a jump offset overflows. | |||
*/ | */ | |||
extern JSBool | extern JSBool | |||
js_PopStatementCG(JSContext *cx, JSCodeGenerator *cg); | js_PopStatementCG(JSContext *cx, JSCodeGenerator *cg); | |||
/* | /* | |||
* Define and lookup a primitive jsval associated with the const named by a tom. | * Define and lookup a primitive jsval associated with the const named by a tom. | |||
* js_DefineCompileTimeConstant analyzes the constant-folded initializer at pn | * js_DefineCompileTimeConstant analyzes the constant-folded initializer at pn | |||
* and saves the const's value in cg->constList, if it can be used at compi le | * and saves the const's value in cg->constList, if it can be used at compi le | |||
* time. It returns true unless an error occurred. | * time. It returns true unless an error occurred. | |||
skipping to change at line 352 | skipping to change at line 458 | |||
*/ | */ | |||
extern JSBool | extern JSBool | |||
js_DefineCompileTimeConstant(JSContext *cx, JSCodeGenerator *cg, JSAtom *at om, | js_DefineCompileTimeConstant(JSContext *cx, JSCodeGenerator *cg, JSAtom *at om, | |||
JSParseNode *pn); | JSParseNode *pn); | |||
extern JSBool | extern JSBool | |||
js_LookupCompileTimeConstant(JSContext *cx, JSCodeGenerator *cg, JSAtom *at om, | js_LookupCompileTimeConstant(JSContext *cx, JSCodeGenerator *cg, JSAtom *at om, | |||
jsval *vp); | jsval *vp); | |||
/* | /* | |||
* Find a lexically scoped variable (one declared by let, catch, or an arra | ||||
y | ||||
* comprehension) named by atom, looking in tc's compile-time scopes. | ||||
* | ||||
* If a WITH statement is reached along the scope stack, return its stateme | ||||
nt | ||||
* info record, so callers can tell that atom is ambiguous. If slotp is no | ||||
t | ||||
* null, then if atom is found, set *slotp to its stack slot, otherwise to | ||||
-1. | ||||
* This means that if slotp is not null, all the block objects on the lexic | ||||
al | ||||
* scope chain must have had their depth slots computed by the code generat | ||||
or, | ||||
* so the caller must be under js_EmitTree. | ||||
* | ||||
* In any event, directly return the statement info record in which atom wa | ||||
s | ||||
* found. Otherwise return null. | ||||
*/ | ||||
extern JSStmtInfo * | ||||
js_LexicalLookup(JSTreeContext *tc, JSAtom *atom, jsint *slotp, | ||||
JSBool letdecl); | ||||
/* | ||||
* Emit code into cg for the tree rooted at pn. | * Emit code into cg for the tree rooted at pn. | |||
*/ | */ | |||
extern JSBool | extern JSBool | |||
js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn); | js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn); | |||
/* | /* | |||
* Emit function code into cg for the tree rooted at body. | ||||
*/ | ||||
extern JSBool | ||||
js_EmitFunctionBytecode(JSContext *cx, JSCodeGenerator *cg, JSParseNode *bo | ||||
dy); | ||||
/* | ||||
* Emit code into cg for the tree rooted at body, then create a persistent | * Emit code into cg for the tree rooted at body, then create a persistent | |||
* script for fun from cg. | * script for fun from cg. | |||
*/ | */ | |||
extern JSBool | extern JSBool | |||
js_EmitFunctionBody(JSContext *cx, JSCodeGenerator *cg, JSParseNode *body, | js_EmitFunctionBody(JSContext *cx, JSCodeGenerator *cg, JSParseNode *body, | |||
JSFunction *fun); | JSFunction *fun); | |||
/* | /* | |||
* Source notes generated along with bytecode for decompiling and debugging . | * Source notes generated along with bytecode for decompiling and debugging . | |||
* A source note is a uint8 with 5 bits of type and 3 of offset from the pc of | * A source note is a uint8 with 5 bits of type and 3 of offset from the pc of | |||
skipping to change at line 383 | skipping to change at line 513 | |||
* Source Note Extended Delta | * Source Note Extended Delta | |||
* +7-6-5-4-3+2-1-0+ +7-6-5+4-3-2-1-0+ | * +7-6-5-4-3+2-1-0+ +7-6-5+4-3-2-1-0+ | |||
* |note-type|delta| |1 1| ext-delta | | * |note-type|delta| |1 1| ext-delta | | |||
* +---------+-----+ +---+-----------+ | * +---------+-----+ +---+-----------+ | |||
* | * | |||
* At most one "gettable" note (i.e., a note of type other than SRC_NEWLINE , | * At most one "gettable" note (i.e., a note of type other than SRC_NEWLINE , | |||
* SRC_SETLINE, and SRC_XDELTA) applies to a given bytecode. | * SRC_SETLINE, and SRC_XDELTA) applies to a given bytecode. | |||
* | * | |||
* NB: the js_SrcNoteSpec array in jsemit.c is indexed by this enum, so its | * NB: the js_SrcNoteSpec array in jsemit.c is indexed by this enum, so its | |||
* initializers need to match the order here. | * initializers need to match the order here. | |||
* | ||||
* Note on adding new source notes: every pair of bytecodes (A, B) where A | ||||
and | ||||
* B have disjoint sets of source notes that could apply to each bytecode m | ||||
ay | ||||
* reuse the same note type value for two notes (snA, snB) that have the sa | ||||
me | ||||
* arity, offsetBias, and isSpanDep initializers in js_SrcNoteSpec. This i | ||||
s | ||||
* why SRC_IF and SRC_INITPROP have the same value below. For bad historic | ||||
al | ||||
* reasons, some bytecodes below that could be overlayed have not been, but | ||||
* before using SRC_EXTENDED, consider compressing the existing note types. | ||||
* | ||||
* Don't forget to update JSXDR_BYTECODE_VERSION in jsxdrapi.h for all such | ||||
* incompatible source note or other bytecode changes. | ||||
*/ | */ | |||
typedef enum JSSrcNoteType { | typedef enum JSSrcNoteType { | |||
SRC_NULL = 0, /* terminates a note vector */ | SRC_NULL = 0, /* terminates a note vector */ | |||
SRC_IF = 1, /* JSOP_IFEQ bytecode is from an if-then */ | SRC_IF = 1, /* JSOP_IFEQ bytecode is from an if-then */ | |||
SRC_INITPROP = 1, /* disjoint meaning applied to JSOP_INITELE | ||||
M or | ||||
to an index label in a regular (structur | ||||
ing) | ||||
or a destructuring object initialiser */ | ||||
SRC_IF_ELSE = 2, /* JSOP_IFEQ bytecode is from an if-then-el se */ | SRC_IF_ELSE = 2, /* JSOP_IFEQ bytecode is from an if-then-el se */ | |||
SRC_WHILE = 3, /* JSOP_IFEQ is from a while loop */ | SRC_WHILE = 3, /* JSOP_IFEQ is from a while loop */ | |||
SRC_FOR = 4, /* JSOP_NOP or JSOP_POP in for loop head */ | SRC_FOR = 4, /* JSOP_NOP or JSOP_POP in for loop head */ | |||
SRC_CONTINUE = 5, /* JSOP_GOTO is a continue, not a break; | SRC_CONTINUE = 5, /* JSOP_GOTO is a continue, not a break; | |||
also used on JSOP_ENDINIT if extra comma | also used on JSOP_ENDINIT if extra comma | |||
at end of array literal: [1,2,,] */ | at end of array literal: [1,2,,] */ | |||
SRC_VAR = 6, /* JSOP_NAME/SETNAME/FORNAME in a var decl | SRC_DECL = 6, /* type of a declaration (var, const, let*) | |||
*/ | */ | |||
SRC_PCDELTA = 7, /* offset from comma-operator to next POP, | SRC_DESTRUCT = 6, /* JSOP_DUP starting a destructuring assign | |||
or from CONDSWITCH to first CASE opcode | ment | |||
*/ | operation, with SRC_DECL_* offset operan | |||
d */ | ||||
SRC_PCDELTA = 7, /* distance forward from comma-operator to | ||||
next POP, or from CONDSWITCH to first CA | ||||
SE | ||||
opcode, etc. -- always a forward delta * | ||||
/ | ||||
SRC_GROUPASSIGN = 7, /* SRC_DESTRUCT variant for [a, b] = [c, d] | ||||
*/ | ||||
SRC_ASSIGNOP = 8, /* += or another assign-op follows */ | SRC_ASSIGNOP = 8, /* += or another assign-op follows */ | |||
SRC_COND = 9, /* JSOP_IFEQ is from conditional ?: operato r */ | SRC_COND = 9, /* JSOP_IFEQ is from conditional ?: operato r */ | |||
SRC_RESERVED0 = 10, /* reserved for future use */ | SRC_BRACE = 10, /* mandatory brace, for scope or to avoid | |||
dangling else */ | ||||
SRC_HIDDEN = 11, /* opcode shouldn't be decompiled */ | SRC_HIDDEN = 11, /* opcode shouldn't be decompiled */ | |||
SRC_PCBASE = 12, /* offset of first obj.prop.subprop bytecod | SRC_PCBASE = 12, /* distance back from annotated getprop or | |||
e */ | setprop op to left-most obj.prop.subprop | |||
bytecode -- always a backward delta */ | ||||
SRC_METHODBASE = 13, /* SRC_PCBASE variant for obj.function::foo | ||||
gets and sets; disjoint from SRC_LABEL b | ||||
y | ||||
bytecode to which it applies */ | ||||
SRC_LABEL = 13, /* JSOP_NOP for label: with atomid immediat e */ | SRC_LABEL = 13, /* JSOP_NOP for label: with atomid immediat e */ | |||
SRC_LABELBRACE = 14, /* JSOP_NOP for label: {...} begin brace */ | SRC_LABELBRACE = 14, /* JSOP_NOP for label: {...} begin brace */ | |||
SRC_ENDBRACE = 15, /* JSOP_NOP for label: {...} end brace */ | SRC_ENDBRACE = 15, /* JSOP_NOP for label: {...} end brace */ | |||
SRC_BREAK2LABEL = 16, /* JSOP_GOTO for 'break label' with atomid */ | SRC_BREAK2LABEL = 16, /* JSOP_GOTO for 'break label' with atomid */ | |||
SRC_CONT2LABEL = 17, /* JSOP_GOTO for 'continue label' with atom id */ | SRC_CONT2LABEL = 17, /* JSOP_GOTO for 'continue label' with atom id */ | |||
SRC_SWITCH = 18, /* JSOP_*SWITCH with offset to end of switc h, | SRC_SWITCH = 18, /* JSOP_*SWITCH with offset to end of switc h, | |||
2nd off to first JSOP_CASE if condswitch */ | 2nd off to first JSOP_CASE if condswitch */ | |||
SRC_FUNCDEF = 19, /* JSOP_NOP for function f() with atomid */ | SRC_FUNCDEF = 19, /* JSOP_NOP for function f() with atomid */ | |||
SRC_CATCH = 20, /* catch block has guard */ | SRC_CATCH = 20, /* catch block has guard */ | |||
SRC_CONST = 21, /* JSOP_SETCONST in a const decl */ | SRC_EXTENDED = 21, /* extended source note, 32-159, in next by te */ | |||
SRC_NEWLINE = 22, /* bytecode follows a source newline */ | SRC_NEWLINE = 22, /* bytecode follows a source newline */ | |||
SRC_SETLINE = 23, /* a file-absolute source line number note */ | SRC_SETLINE = 23, /* a file-absolute source line number note */ | |||
SRC_XDELTA = 24 /* 24-31 are for extended delta notes */ | SRC_XDELTA = 24 /* 24-31 are for extended delta notes */ | |||
} JSSrcNoteType; | } JSSrcNoteType; | |||
/* | ||||
* Constants for the SRC_DECL source note. Note that span-dependent byteco | ||||
de | ||||
* selection means that any SRC_DECL offset greater than SRC_DECL_LET may n | ||||
eed | ||||
* to be adjusted, but these "offsets" are too small to span a span-depende | ||||
nt | ||||
* instruction, so can be used to denote distinct declaration syntaxes to t | ||||
he | ||||
* decompiler. | ||||
* | ||||
* NB: the var_prefix array in jsopcode.c depends on these dense indexes fr | ||||
om | ||||
* SRC_DECL_VAR through SRC_DECL_LET. | ||||
*/ | ||||
#define SRC_DECL_VAR 0 | ||||
#define SRC_DECL_CONST 1 | ||||
#define SRC_DECL_LET 2 | ||||
#define SRC_DECL_NONE 3 | ||||
#define SN_TYPE_BITS 5 | #define SN_TYPE_BITS 5 | |||
#define SN_DELTA_BITS 3 | #define SN_DELTA_BITS 3 | |||
#define SN_XDELTA_BITS 6 | #define SN_XDELTA_BITS 6 | |||
#define SN_TYPE_MASK (JS_BITMASK(SN_TYPE_BITS) << SN_DELTA_BITS) | #define SN_TYPE_MASK (JS_BITMASK(SN_TYPE_BITS) << SN_DELTA_BITS) | |||
#define SN_DELTA_MASK ((ptrdiff_t)JS_BITMASK(SN_DELTA_BITS)) | #define SN_DELTA_MASK ((ptrdiff_t)JS_BITMASK(SN_DELTA_BITS)) | |||
#define SN_XDELTA_MASK ((ptrdiff_t)JS_BITMASK(SN_XDELTA_BITS)) | #define SN_XDELTA_MASK ((ptrdiff_t)JS_BITMASK(SN_XDELTA_BITS)) | |||
#define SN_MAKE_NOTE(sn,t,d) (*(sn) = (jssrcnote) \ | #define SN_MAKE_NOTE(sn,t,d) (*(sn) = (jssrcnote) \ | |||
(((t) << SN_DELTA_BITS) \ | (((t) << SN_DELTA_BITS) \ | |||
| ((d) & SN_DELTA_MASK))) | | ((d) & SN_DELTA_MASK))) | |||
End of changes. 37 change blocks. | ||||
47 lines changed or deleted | 275 lines changed or added | |||
jsexn.h | jsexn.h | |||
---|---|---|---|---|
skipping to change at line 49 | skipping to change at line 49 | |||
/* | /* | |||
* JS runtime exception classes. | * JS runtime exception classes. | |||
*/ | */ | |||
#ifndef jsexn_h___ | #ifndef jsexn_h___ | |||
#define jsexn_h___ | #define jsexn_h___ | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
extern JSClass js_ErrorClass; | ||||
/* | /* | |||
* Initialize the exception constructor/prototype hierarchy. | * Initialize the exception constructor/prototype hierarchy. | |||
*/ | */ | |||
extern JSObject * | extern JSObject * | |||
js_InitExceptionClasses(JSContext *cx, JSObject *obj); | js_InitExceptionClasses(JSContext *cx, JSObject *obj); | |||
/* | /* | |||
* String constants naming the exception classes. | ||||
*/ | ||||
extern const char js_Error_str[]; | ||||
extern const char js_InternalError_str[]; | ||||
extern const char js_EvalError_str[]; | ||||
extern const char js_RangeError_str[]; | ||||
extern const char js_ReferenceError_str[]; | ||||
extern const char js_SyntaxError_str[]; | ||||
extern const char js_TypeError_str[]; | ||||
extern const char js_URIError_str[]; | ||||
/* | ||||
* Given a JSErrorReport, check to see if there is an exception associated with | * Given a JSErrorReport, check to see if there is an exception associated with | |||
* the error number. If there is, then create an appropriate exception obj ect, | * the error number. If there is, then create an appropriate exception obj ect, | |||
* set it as the pending exception, and set the JSREPORT_EXCEPTION flag on the | * set it as the pending exception, and set the JSREPORT_EXCEPTION flag on the | |||
* error report. Exception-aware host error reporters should probably igno re | * error report. Exception-aware host error reporters should probably igno re | |||
* error reports so flagged. Returns JS_TRUE if an associated exception is | * error reports so flagged. Returns JS_TRUE if an associated exception is | |||
* found and set, JS_FALSE otherwise.. | * found and set, JS_FALSE otherwise.. | |||
*/ | */ | |||
extern JSBool | extern JSBool | |||
js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *repo rtp); | js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *repo rtp); | |||
skipping to change at line 100 | skipping to change at line 90 | |||
* set; embeddings that want to silently propagate JavaScript exceptions to | * set; embeddings that want to silently propagate JavaScript exceptions to | |||
* other contexts may want to use an error reporter that ignores errors wit h | * other contexts may want to use an error reporter that ignores errors wit h | |||
* this flag. | * this flag. | |||
*/ | */ | |||
extern JSBool | extern JSBool | |||
js_ReportUncaughtException(JSContext *cx); | js_ReportUncaughtException(JSContext *cx); | |||
extern JSErrorReport * | extern JSErrorReport * | |||
js_ErrorFromException(JSContext *cx, jsval exn); | js_ErrorFromException(JSContext *cx, jsval exn); | |||
extern const JSErrorFormatString * | ||||
js_GetLocalizedErrorMessage(JSContext* cx, void *userRef, const char *local | ||||
e, | ||||
const uintN errorNumber); | ||||
JS_END_EXTERN_C | JS_END_EXTERN_C | |||
#endif /* jsexn_h___ */ | #endif /* jsexn_h___ */ | |||
End of changes. 3 change blocks. | ||||
12 lines changed or deleted | 7 lines changed or added | |||
jsfun.h | jsfun.h | |||
---|---|---|---|---|
skipping to change at line 51 | skipping to change at line 51 | |||
#define jsfun_h___ | #define jsfun_h___ | |||
/* | /* | |||
* JS function definitions. | * JS function definitions. | |||
*/ | */ | |||
#include "jsprvtd.h" | #include "jsprvtd.h" | |||
#include "jspubtd.h" | #include "jspubtd.h" | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
struct JSFunction { | struct JSFunction { | |||
jsrefcount nrefs; /* number of referencing objects */ | ||||
JSObject *object; /* back-pointer to GC'ed object header */ | JSObject *object; /* back-pointer to GC'ed object header */ | |||
uint16 nargs; /* minimum number of actual arguments */ | ||||
uint16 flags; /* bound method and other flags, see jsapi. | ||||
h */ | ||||
union { | union { | |||
JSNative native; /* native method pointer or null */ | struct { | |||
JSScript *script; /* interpreted bytecode descriptor or null | uint16 extra; /* number of arg slots for local GC roots * | |||
*/ | / | |||
uint16 spare; /* reserved for future use */ | ||||
JSNative native; /* native method pointer or null */ | ||||
} n; | ||||
struct { | ||||
uint16 nvars; /* number of local variables */ | ||||
uint16 nregexps; /* number of regular expressions literals * | ||||
/ | ||||
JSScript *script; /* interpreted bytecode descriptor or null | ||||
*/ | ||||
} i; | ||||
} u; | } u; | |||
uint16 nargs; /* minimum number of actual arguments */ | ||||
uint16 extra; /* number of arg slots for local GC roots * | ||||
/ | ||||
uint16 nvars; /* number of local variables */ | ||||
uint8 flags; /* bound method and other flags, see jsapi. | ||||
h */ | ||||
JSPackedBool interpreted; /* use u.script if true, u.native if false | ||||
*/ | ||||
uint16 nregexps; /* number of regular expressions literals * | ||||
/ | ||||
uint16 spare; /* reserved for future use */ | ||||
JSAtom *atom; /* name for diagnostics and decompiling */ | JSAtom *atom; /* name for diagnostics and decompiling */ | |||
JSClass *clasp; /* if non-null, constructor for this class */ | JSClass *clasp; /* if non-null, constructor for this class */ | |||
}; | }; | |||
#define FUN_NATIVE(fun) ((fun)->interpreted ? NULL : (fun)->u.nativ | #define JSFUN_INTERPRETED 0x8000 /* use u.i if set, u.n if unset */ | |||
e) | ||||
#define FUN_SCRIPT(fun) ((fun)->interpreted ? (fun)->u.script : NUL | #define FUN_INTERPRETED(fun) ((fun)->flags & JSFUN_INTERPRETED) | |||
L) | #define FUN_NATIVE(fun) (FUN_INTERPRETED(fun) ? NULL : (fun)->u.n.nati | |||
ve) | ||||
#define FUN_SCRIPT(fun) (FUN_INTERPRETED(fun) ? (fun)->u.i.script : NU | ||||
LL) | ||||
extern JSClass js_ArgumentsClass; | extern JSClass js_ArgumentsClass; | |||
extern JSClass js_CallClass; | extern JSClass js_CallClass; | |||
/* JS_FRIEND_DATA so that JSVAL_IS_FUNCTION is callable from outside */ | /* JS_FRIEND_DATA so that VALUE_IS_FUNCTION is callable from the shell. */ | |||
extern JS_FRIEND_DATA(JSClass) js_FunctionClass; | extern JS_FRIEND_DATA(JSClass) js_FunctionClass; | |||
/* | /* | |||
* NB: jsapi.h and jsobj.h must be included before any call to this macro. | * NB: jsapi.h and jsobj.h must be included before any call to this macro. | |||
*/ | */ | |||
#define JSVAL_IS_FUNCTION(cx, v) | #define VALUE_IS_FUNCTION(cx, v) | |||
\ | \ | |||
(JSVAL_IS_OBJECT(v) && JSVAL_TO_OBJECT(v) && | (!JSVAL_IS_PRIMITIVE(v) && | |||
\ | \ | |||
OBJ_GET_CLASS(cx, JSVAL_TO_OBJECT(v)) == &js_FunctionClass) | OBJ_GET_CLASS(cx, JSVAL_TO_OBJECT(v)) == &js_FunctionClass) | |||
extern JSBool | extern JSBool | |||
js_fun_toString(JSContext *cx, JSObject *obj, uint32 indent, | js_fun_toString(JSContext *cx, JSObject *obj, uint32 indent, | |||
uintN argc, jsval *argv, jsval *rval); | uintN argc, jsval *argv, jsval *rval); | |||
extern JSBool | extern JSBool | |||
js_IsIdentifier(JSString *str); | js_IsIdentifier(JSString *str); | |||
extern JSObject * | extern JSObject * | |||
js_InitFunctionClass(JSContext *cx, JSObject *obj); | js_InitFunctionClass(JSContext *cx, JSObject *obj); | |||
extern JSObject * | extern JSObject * | |||
js_InitArgumentsClass(JSContext *cx, JSObject *obj); | js_InitArgumentsClass(JSContext *cx, JSObject *obj); | |||
extern JSObject * | extern JSObject * | |||
js_InitCallClass(JSContext *cx, JSObject *obj); | js_InitCallClass(JSContext *cx, JSObject *obj); | |||
extern JSFunction * | extern JSFunction * | |||
js_NewFunction(JSContext *cx, JSObject *funobj, JSNative native, uintN narg s, | js_NewFunction(JSContext *cx, JSObject *funobj, JSNative native, uintN narg s, | |||
uintN flags, JSObject *parent, JSAtom *atom); | uintN flags, JSObject *parent, JSAtom *atom); | |||
extern JSObject * | extern JSObject * | |||
js_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent); | js_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent); | |||
extern JSBool | extern JSBool | |||
js_LinkFunctionObject(JSContext *cx, JSFunction *fun, JSObject *object); | js_LinkFunctionObject(JSContext *cx, JSFunction *fun, JSObject *object); | |||
extern JSFunction * | extern JSFunction * | |||
js_DefineFunction(JSContext *cx, JSObject *obj, JSAtom *atom, JSNative nati ve, | js_DefineFunction(JSContext *cx, JSObject *obj, JSAtom *atom, JSNative nati ve, | |||
uintN nargs, uintN flags); | uintN nargs, uintN flags); | |||
/* | /* | |||
* Flags for js_ValueToFunction and js_ReportIsNotFunction. We depend on t he | * Flags for js_ValueToFunction and js_ReportIsNotFunction. We depend on t he | |||
* fact that JSINVOKE_CONSTRUCT (aka JSFRAME_CONSTRUCTING) is 1, and test t hat | * fact that JSINVOKE_CONSTRUCT (aka JSFRAME_CONSTRUCTING) is 1, and test t hat | |||
* with #if/#error in jsfun.c. | * with #if/#error in jsfun.c. | |||
*/ | */ | |||
#define JSV2F_CONSTRUCT JSINVOKE_CONSTRUCT | #define JSV2F_CONSTRUCT JSINVOKE_CONSTRUCT | |||
#define JSV2F_SEARCH_STACK 2 | #define JSV2F_ITERATOR JSINVOKE_ITERATOR | |||
#define JSV2F_SEARCH_STACK 0x10000 | ||||
extern JSFunction * | extern JSFunction * | |||
js_ValueToFunction(JSContext *cx, jsval *vp, uintN flags); | js_ValueToFunction(JSContext *cx, jsval *vp, uintN flags); | |||
extern JSObject * | ||||
js_ValueToFunctionObject(JSContext *cx, jsval *vp, uintN flags); | ||||
extern JSObject * | ||||
js_ValueToCallableObject(JSContext *cx, jsval *vp, uintN flags); | ||||
extern void | extern void | |||
js_ReportIsNotFunction(JSContext *cx, jsval *vp, uintN flags); | js_ReportIsNotFunction(JSContext *cx, jsval *vp, uintN flags); | |||
extern JSObject * | extern JSObject * | |||
js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent); | js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent); | |||
extern JSBool | extern JSBool | |||
js_PutCallObject(JSContext *cx, JSStackFrame *fp); | js_PutCallObject(JSContext *cx, JSStackFrame *fp); | |||
extern JSBool | extern JSBool | |||
End of changes. 11 change blocks. | ||||
27 lines changed or deleted | 38 lines changed or added | |||
jsgc.h | jsgc.h | |||
---|---|---|---|---|
skipping to change at line 48 | skipping to change at line 48 | |||
* ***** END LICENSE BLOCK ***** */ | * ***** END LICENSE BLOCK ***** */ | |||
#ifndef jsgc_h___ | #ifndef jsgc_h___ | |||
#define jsgc_h___ | #define jsgc_h___ | |||
/* | /* | |||
* JS Garbage Collector. | * JS Garbage Collector. | |||
*/ | */ | |||
#include "jsprvtd.h" | #include "jsprvtd.h" | |||
#include "jspubtd.h" | #include "jspubtd.h" | |||
#include "jsdhash.h" | #include "jsdhash.h" | |||
#include "jsutil.h" | ||||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
/* GC thing type indexes. */ | /* GC thing type indexes. */ | |||
#define GCX_OBJECT 0 /* JSObject */ | #define GCX_OBJECT 0 /* JSObject */ | |||
#define GCX_STRING 1 /* JSString */ | #define GCX_STRING 1 /* JSString */ | |||
#define GCX_DOUBLE 2 /* jsdouble */ | #define GCX_DOUBLE 2 /* jsdouble */ | |||
#define GCX_MUTABLE_STRING 3 /* JSString that's mutable -- | #define GCX_MUTABLE_STRING 3 /* JSString that's mutable -- | |||
single-threaded only! */ | single-threaded only! */ | |||
#define GCX_EXTERNAL_STRING 4 /* JSString w/ external cha | #define GCX_PRIVATE 4 /* private (unscanned) data | |||
rs */ | */ | |||
#define GCX_NTYPES_LOG2 3 /* type index bits */ | #define GCX_NAMESPACE 5 /* JSXMLNamespace */ | |||
#define GCX_QNAME 6 /* JSXMLQName */ | ||||
#define GCX_XML 7 /* JSXML */ | ||||
#define GCX_EXTERNAL_STRING 8 /* JSString w/ external cha | ||||
rs */ | ||||
#define GCX_NTYPES_LOG2 4 /* type index bits */ | ||||
#define GCX_NTYPES JS_BIT(GCX_NTYPES_LOG2) | #define GCX_NTYPES JS_BIT(GCX_NTYPES_LOG2) | |||
/* GC flag definitions, must fit in 8 bits (type index goes in the low bits ). */ | /* GC flag definitions, must fit in 8 bits (type index goes in the low bits ). */ | |||
#define GCF_TYPEMASK JS_BITMASK(GCX_NTYPES_LOG2) | #define GCF_TYPEMASK JS_BITMASK(GCX_NTYPES_LOG2) | |||
#define GCF_MARK JS_BIT(GCX_NTYPES_LOG2) | #define GCF_MARK JS_BIT(GCX_NTYPES_LOG2) | |||
#define GCF_FINAL JS_BIT(GCX_NTYPES_LOG2 + 1) | #define GCF_FINAL JS_BIT(GCX_NTYPES_LOG2 + 1) | |||
#define GCF_LOCKSHIFT (GCX_NTYPES_LOG2 + 2) /* lock bit shift and mask | #define GCF_SYSTEM JS_BIT(GCX_NTYPES_LOG2 + 2) | |||
*/ | #define GCF_LOCKSHIFT (GCX_NTYPES_LOG2 + 3) /* lock bit shift */ | |||
#define GCF_LOCKMASK (JS_BITMASK(8 - GCF_LOCKSHIFT) << GCF_LOCKSHIFT) | ||||
#define GCF_LOCK JS_BIT(GCF_LOCKSHIFT) /* lock request bit in API */ | #define GCF_LOCK JS_BIT(GCF_LOCKSHIFT) /* lock request bit in API */ | |||
/* Pseudo-flag that modifies GCX_STRING to make GCX_MUTABLE_STRING. */ | /* Pseudo-flag that modifies GCX_STRING to make GCX_MUTABLE_STRING. */ | |||
#define GCF_MUTABLE 2 | #define GCF_MUTABLE 2 | |||
#if (GCX_STRING | GCF_MUTABLE) != GCX_MUTABLE_STRING | #if (GCX_STRING | GCF_MUTABLE) != GCX_MUTABLE_STRING | |||
# error "mutable string type index botch!" | # error "mutable string type index botch!" | |||
#endif | #endif | |||
extern uint8 * | extern uint8 * | |||
js_GetGCThingFlags(void *thing); | js_GetGCThingFlags(void *thing); | |||
/* These are compatible with JSDHashEntryStub. */ | /* | |||
struct JSGCRootHashEntry { | * The sole purpose of the function is to preserve public API compatibility | |||
JSDHashEntryHdr hdr; | * in JS_GetStringBytes which takes only single JSString* argument. | |||
void *root; | */ | |||
const char *name; | JSRuntime* | |||
}; | js_GetGCStringRuntime(JSString *str); | |||
struct JSGCLockHashEntry { | ||||
JSDHashEntryHdr hdr; | ||||
const JSGCThing *thing; | ||||
uint32 count; | ||||
}; | ||||
#if 1 | #if 1 | |||
/* | /* | |||
* Since we're forcing a GC from JS_GC anyway, don't bother wasting cycles | * Since we're forcing a GC from JS_GC anyway, don't bother wasting cycles | |||
* loading oldval. XXX remove implied force, fix jsinterp.c's "second arg | * loading oldval. XXX remove implied force, fix jsinterp.c's "second arg | |||
* ignored", etc. | * ignored", etc. | |||
*/ | */ | |||
#define GC_POKE(cx, oldval) ((cx)->runtime->gcPoke = JS_TRUE) | #define GC_POKE(cx, oldval) ((cx)->runtime->gcPoke = JS_TRUE) | |||
#else | #else | |||
#define GC_POKE(cx, oldval) ((cx)->runtime->gcPoke = JSVAL_IS_GCTHING(oldva l)) | #define GC_POKE(cx, oldval) ((cx)->runtime->gcPoke = JSVAL_IS_GCTHING(oldva l)) | |||
skipping to change at line 122 | skipping to change at line 122 | |||
extern JSBool | extern JSBool | |||
js_AddRoot(JSContext *cx, void *rp, const char *name); | js_AddRoot(JSContext *cx, void *rp, const char *name); | |||
extern JSBool | extern JSBool | |||
js_AddRootRT(JSRuntime *rt, void *rp, const char *name); | js_AddRootRT(JSRuntime *rt, void *rp, const char *name); | |||
extern JSBool | extern JSBool | |||
js_RemoveRoot(JSRuntime *rt, void *rp); | js_RemoveRoot(JSRuntime *rt, void *rp); | |||
#ifdef DEBUG | ||||
extern void | ||||
js_DumpNamedRoots(JSRuntime *rt, | ||||
void (*dump)(const char *name, void *rp, void *data), | ||||
void *data); | ||||
#endif | ||||
extern uint32 | ||||
js_MapGCRoots(JSRuntime *rt, JSGCRootMapFun map, void *data); | ||||
/* Table of pointers with count valid members. */ | ||||
typedef struct JSPtrTable { | ||||
size_t count; | ||||
void **array; | ||||
} JSPtrTable; | ||||
extern JSBool | ||||
js_RegisterCloseableIterator(JSContext *cx, JSObject *obj); | ||||
#if JS_HAS_GENERATORS | ||||
/* | ||||
* Runtime state to support generators' close hooks. | ||||
*/ | ||||
typedef struct JSGCCloseState { | ||||
/* | ||||
* Singly linked list of generators that are reachable from GC roots or | ||||
* were created after the last GC. | ||||
*/ | ||||
JSGenerator *reachableList; | ||||
/* | ||||
* Head of the queue of generators that have already become unreachable | ||||
but | ||||
* whose close hooks are not yet run. | ||||
*/ | ||||
JSGenerator *todoQueue; | ||||
#ifndef JS_THREADSAFE | ||||
/* | ||||
* Flag indicating that the current thread is excuting a close hook for | ||||
* single thread case. | ||||
*/ | ||||
JSBool runningCloseHook; | ||||
#endif | ||||
} JSGCCloseState; | ||||
extern void | ||||
js_RegisterGenerator(JSContext *cx, JSGenerator *gen); | ||||
extern JSBool | ||||
js_RunCloseHooks(JSContext *cx); | ||||
#endif | ||||
/* | ||||
* The private JSGCThing struct, which describes a gcFreeList element. | ||||
*/ | ||||
struct JSGCThing { | ||||
JSGCThing *next; | ||||
uint8 *flagp; | ||||
}; | ||||
#define GC_NBYTES_MAX (10 * sizeof(JSGCThing)) | ||||
#define GC_NUM_FREELISTS (GC_NBYTES_MAX / sizeof(JSGCThing)) | ||||
#define GC_FREELIST_NBYTES(i) (((i) + 1) * sizeof(JSGCThing)) | ||||
#define GC_FREELIST_INDEX(n) (((n) / sizeof(JSGCThing)) - 1) | ||||
extern void * | extern void * | |||
js_AllocGCThing(JSContext *cx, uintN flags); | js_NewGCThing(JSContext *cx, uintN flags, size_t nbytes); | |||
extern JSBool | extern JSBool | |||
js_LockGCThing(JSContext *cx, void *thing); | js_LockGCThing(JSContext *cx, void *thing); | |||
extern JSBool | extern JSBool | |||
js_LockGCThingRT(JSRuntime *rt, void *thing); | js_LockGCThingRT(JSRuntime *rt, void *thing); | |||
extern JSBool | extern JSBool | |||
js_UnlockGCThingRT(JSRuntime *rt, void *thing); | js_UnlockGCThingRT(JSRuntime *rt, void *thing); | |||
extern JSBool | extern JSBool | |||
js_IsAboutToBeFinalized(JSContext *cx, void *thing); | js_IsAboutToBeFinalized(JSContext *cx, void *thing); | |||
extern void | extern void | |||
js_MarkAtom(JSContext *cx, JSAtom *atom, void *arg); | js_MarkAtom(JSContext *cx, JSAtom *atom); | |||
/* We avoid a large number of unnecessary calls by doing the flag check fir st */ | /* We avoid a large number of unnecessary calls by doing the flag check fir st */ | |||
#define GC_MARK_ATOM(cx, atom, arg) \ | #define GC_MARK_ATOM(cx, atom) \ | |||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
if (!((atom)->flags & ATOM_MARK)) \ | if (!((atom)->flags & ATOM_MARK)) \ | |||
js_MarkAtom(cx, atom, arg); \ | js_MarkAtom(cx, atom); \ | |||
JS_END_MACRO | JS_END_MACRO | |||
/* | ||||
* Always use GC_MARK macro and never call js_MarkGCThing directly so | ||||
* when GC_MARK_DEBUG is defined the dump of live GC things does not miss | ||||
* a thing. | ||||
*/ | ||||
extern void | extern void | |||
js_MarkGCThing(JSContext *cx, void *thing, void *arg); | js_MarkGCThing(JSContext *cx, void *thing); | |||
#ifdef GC_MARK_DEBUG | #ifdef GC_MARK_DEBUG | |||
typedef struct GCMarkNode GCMarkNode; | # define GC_MARK(cx, thing, name) js_MarkNamedGCThing(cx, thing, name) | |||
struct GCMarkNode { | extern void | |||
void *thing; | js_MarkNamedGCThing(JSContext *cx, void *thing, const char *name); | |||
const char *name; | ||||
GCMarkNode *next; | ||||
GCMarkNode *prev; | ||||
}; | ||||
#define GC_MARK(cx_, thing_, name_, prev_) | extern JS_FRIEND_DATA(FILE *) js_DumpGCHeap; | |||
\ | JS_EXTERN_DATA(void *) js_LiveThingToFind; | |||
JS_BEGIN_MACRO | ||||
\ | ||||
GCMarkNode node_; | ||||
\ | ||||
node_.thing = thing_; | ||||
\ | ||||
node_.name = name_; | ||||
\ | ||||
node_.next = NULL; | ||||
\ | ||||
node_.prev = prev_; | ||||
\ | ||||
if (prev_) ((GCMarkNode *)(prev_))->next = &node_; | ||||
\ | ||||
js_MarkGCThing(cx_, thing_, &node_); | ||||
\ | ||||
JS_END_MACRO | ||||
#else /* !GC_MARK_DEBUG */ | #else | |||
#define GC_MARK(cx, thing, name, prev) js_MarkGCThing(cx, thing, NULL) | # define GC_MARK(cx, thing, name) js_MarkGCThing(cx, thing) | |||
#endif /* !GC_MARK_DEBUG */ | #endif | |||
extern void | ||||
js_MarkStackFrame(JSContext *cx, JSStackFrame *fp); | ||||
/* | /* | |||
* Flags to modify how a GC marks and sweeps: | * Kinds of js_GC invocation. | |||
* GC_KEEP_ATOMS Don't sweep unmarked atoms, they may be in use by t | ||||
he | ||||
* compiler, or by an API function that calls js_Atomi | ||||
ze, | ||||
* when the GC is called from js_AllocGCThing, due to | ||||
a | ||||
* malloc failure or the runtime GC-thing limit. | ||||
* GC_LAST_CONTEXT Called from js_DestroyContext for last JSContext in | ||||
a | ||||
* JSRuntime, when it is imperative that rt->gcPoke ge | ||||
ts | ||||
* cleared early in js_GC, if it is set. | ||||
* GC_ALREADY_LOCKED rt->gcLock is already held on entry to js_GC, and k | ||||
ept | ||||
* on return to its caller. | ||||
*/ | */ | |||
#define GC_KEEP_ATOMS 0x1 | typedef enum JSGCInvocationKind { | |||
#define GC_LAST_CONTEXT 0x2 | /* Normal invocation. */ | |||
#define GC_ALREADY_LOCKED 0x4 | GC_NORMAL, | |||
/* | ||||
* Called from js_DestroyContext for last JSContext in a JSRuntime, whe | ||||
n | ||||
* it is imperative that rt->gcPoke gets cleared early in js_GC. | ||||
*/ | ||||
GC_LAST_CONTEXT, | ||||
/* | ||||
* Called from js_NewGCThing as a last-ditch GC attempt. See comments | ||||
* before js_GC definition for details. | ||||
*/ | ||||
GC_LAST_DITCH | ||||
} JSGCInvocationKind; | ||||
extern void | extern void | |||
js_ForceGC(JSContext *cx, uintN gcflags); | js_GC(JSContext *cx, JSGCInvocationKind gckind); | |||
/* Call this after succesful malloc of memory for GC-related things. */ | ||||
extern void | extern void | |||
js_GC(JSContext *cx, uintN gcflags); | js_UpdateMallocCounter(JSContext *cx, size_t nbytes); | |||
#ifdef DEBUG_notme | ||||
#define JS_GCMETER 1 | ||||
#endif | ||||
#ifdef JS_GCMETER | #ifdef JS_GCMETER | |||
typedef struct JSGCStats { | typedef struct JSGCStats { | |||
#ifdef JS_THREADSAFE | ||||
uint32 localalloc; /* number of succeeded allocations from local lists | ||||
*/ | ||||
#endif | ||||
uint32 alloc; /* number of allocation attempts */ | uint32 alloc; /* number of allocation attempts */ | |||
uint32 freelen; /* gcFreeList length */ | ||||
uint32 recycle; /* number of things recycled through gcFreeList */ | ||||
uint32 retry; /* allocation attempt retries after running the GC */ | uint32 retry; /* allocation attempt retries after running the GC */ | |||
uint32 retryhalt; /* allocation retries halted by the branch callback */ | ||||
uint32 fail; /* allocation failures */ | uint32 fail; /* allocation failures */ | |||
uint32 finalfail; /* finalizer calls allocator failures */ | uint32 finalfail; /* finalizer calls allocator failures */ | |||
uint32 lockborn; /* things born locked */ | ||||
uint32 lock; /* valid lock calls */ | uint32 lock; /* valid lock calls */ | |||
uint32 unlock; /* valid unlock calls */ | uint32 unlock; /* valid unlock calls */ | |||
uint32 stuck; /* stuck reference counts seen by lock calls */ | uint32 depth; /* mark tail recursion depth */ | |||
uint32 unstuck; /* unlock calls that saw a stuck lock count */ | uint32 maxdepth; /* maximum mark tail recursion depth */ | |||
uint32 depth; /* mark recursion depth */ | uint32 cdepth; /* mark recursion depth of C functions */ | |||
uint32 maxdepth; /* maximum mark recursion depth */ | uint32 maxcdepth; /* maximum mark recursion depth of C functions */ | |||
uint32 unscanned; /* mark C stack overflows or number of times | ||||
GC things were put in unscanned bag */ | ||||
#ifdef DEBUG | ||||
uint32 maxunscanned; /* maximum size of unscanned bag */ | ||||
#endif | ||||
uint32 maxlevel; /* maximum GC nesting (indirect recursion) level */ | uint32 maxlevel; /* maximum GC nesting (indirect recursion) level */ | |||
uint32 poke; /* number of potentially useful GC calls */ | uint32 poke; /* number of potentially useful GC calls */ | |||
uint32 nopoke; /* useless GC calls where js_PokeGC was not set */ | uint32 nopoke; /* useless GC calls where js_PokeGC was not set */ | |||
uint32 afree; /* thing arenas freed so far */ | uint32 afree; /* thing arenas freed so far */ | |||
uint32 stackseg; /* total extraordinary stack segments scanned */ | uint32 stackseg; /* total extraordinary stack segments scanned */ | |||
uint32 segslots; /* total stack segment jsval slots scanned */ | uint32 segslots; /* total stack segment jsval slots scanned */ | |||
uint32 nclose; /* number of objects with close hooks */ | ||||
uint32 maxnclose; /* max number of objects with close hooks */ | ||||
uint32 closelater; /* number of close hooks scheduled to run */ | ||||
uint32 maxcloselater; /* max number of close hooks scheduled to run */ | ||||
} JSGCStats; | } JSGCStats; | |||
extern void | extern JS_FRIEND_API(void) | |||
js_DumpGCStats(JSRuntime *rt, FILE *fp); | js_DumpGCStats(JSRuntime *rt, FILE *fp); | |||
#endif /* JS_GCMETER */ | #endif /* JS_GCMETER */ | |||
typedef struct JSGCArena JSGCArena; | ||||
typedef struct JSGCArenaList JSGCArenaList; | ||||
#ifdef JS_GCMETER | ||||
typedef struct JSGCArenaStats JSGCArenaStats; | ||||
struct JSGCArenaStats { | ||||
uint32 narenas; /* number of arena in list */ | ||||
uint32 maxarenas; /* maximun number of allocated arenas */ | ||||
uint32 nthings; /* number of allocates JSGCThing */ | ||||
uint32 maxthings; /* maximum number number of allocates JSGCThing | ||||
*/ | ||||
uint32 totalnew; /* number of succeeded calls to js_NewGCThing * | ||||
/ | ||||
uint32 freelen; /* freeList lengths */ | ||||
uint32 recycle; /* number of things recycled through freeList * | ||||
/ | ||||
uint32 totalarenas; /* total number of arenas with live things that | ||||
GC scanned so far */ | ||||
uint32 totalfreelen; /* total number of things that GC put to free | ||||
list so far */ | ||||
}; | ||||
#endif | ||||
struct JSGCArenaList { | ||||
JSGCArena *last; /* last allocated GC arena */ | ||||
uint16 lastLimit; /* end offset of allocated so far things in | ||||
the last arena */ | ||||
uint16 thingSize; /* size of things to allocate on this list | ||||
*/ | ||||
JSGCThing *freeList; /* list of free GC things */ | ||||
#ifdef JS_GCMETER | ||||
JSGCArenaStats stats; | ||||
#endif | ||||
}; | ||||
typedef struct JSWeakRoots { | ||||
/* 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; | ||||
/* Root for the result of the most recent js_InternalInvoke call. */ | ||||
jsval lastInternalResult; | ||||
} JSWeakRoots; | ||||
JS_STATIC_ASSERT(JSVAL_NULL == 0); | ||||
#define JS_CLEAR_WEAK_ROOTS(wr) (memset((wr), 0, sizeof(JSWeakRoots))) | ||||
#ifdef DEBUG_notme | ||||
#define TOO_MUCH_GC 1 | ||||
#endif | ||||
#ifdef WAY_TOO_MUCH_GC | ||||
#define TOO_MUCH_GC 1 | ||||
#endif | ||||
JS_END_EXTERN_C | JS_END_EXTERN_C | |||
#endif /* jsgc_h___ */ | #endif /* jsgc_h___ */ | |||
End of changes. 30 change blocks. | ||||
80 lines changed or deleted | 211 lines changed or added | |||
jshash.h | jshash.h | |||
---|---|---|---|---|
skipping to change at line 67 | skipping to change at line 67 | |||
#define JS_GOLDEN_RATIO 0x9E3779B9U | #define JS_GOLDEN_RATIO 0x9E3779B9U | |||
typedef JSHashNumber (* JS_DLL_CALLBACK JSHashFunction)(const void *key); | typedef JSHashNumber (* JS_DLL_CALLBACK JSHashFunction)(const void *key); | |||
typedef intN (* JS_DLL_CALLBACK JSHashComparator)(const void *v1, const voi d *v2); | typedef intN (* JS_DLL_CALLBACK JSHashComparator)(const void *v1, const voi d *v2); | |||
typedef intN (* JS_DLL_CALLBACK JSHashEnumerator)(JSHashEntry *he, intN i, void *arg); | typedef intN (* JS_DLL_CALLBACK JSHashEnumerator)(JSHashEntry *he, intN i, void *arg); | |||
/* Flag bits in JSHashEnumerator's return value */ | /* Flag bits in JSHashEnumerator's return value */ | |||
#define HT_ENUMERATE_NEXT 0 /* continue enumerating entries */ | #define HT_ENUMERATE_NEXT 0 /* continue enumerating entries */ | |||
#define HT_ENUMERATE_STOP 1 /* stop enumerating entries */ | #define HT_ENUMERATE_STOP 1 /* stop enumerating entries */ | |||
#define HT_ENUMERATE_REMOVE 2 /* remove and free the current entr y */ | #define HT_ENUMERATE_REMOVE 2 /* remove and free the current entr y */ | |||
#define HT_ENUMERATE_UNHASH 4 /* just unhash the current entry */ | ||||
typedef struct JSHashAllocOps { | typedef struct JSHashAllocOps { | |||
void * (*allocTable)(void *pool, size_t size); | void * (*allocTable)(void *pool, size_t size); | |||
void (*freeTable)(void *pool, void *item); | void (*freeTable)(void *pool, void *item); | |||
JSHashEntry * (*allocEntry)(void *pool, const void *key); | JSHashEntry * (*allocEntry)(void *pool, const void *key); | |||
void (*freeEntry)(void *pool, JSHashEntry *he, uintN fla g); | void (*freeEntry)(void *pool, JSHashEntry *he, uintN fla g); | |||
} JSHashAllocOps; | } JSHashAllocOps; | |||
#define HT_FREE_VALUE 0 /* just free the entry's value */ | #define HT_FREE_VALUE 0 /* just free the entry's value */ | |||
#define HT_FREE_ENTRY 1 /* free value and entire entry */ | #define HT_FREE_ENTRY 1 /* free value and entire entry */ | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 0 lines changed or added | |||
jsinterp.h | jsinterp.h | |||
---|---|---|---|---|
skipping to change at line 51 | skipping to change at line 51 | |||
#define jsinterp_h___ | #define jsinterp_h___ | |||
/* | /* | |||
* JS interpreter interface. | * JS interpreter interface. | |||
*/ | */ | |||
#include "jsprvtd.h" | #include "jsprvtd.h" | |||
#include "jspubtd.h" | #include "jspubtd.h" | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
/* | /* | |||
* JS stack frame, allocated on the C stack. | * JS stack frame, may be allocated on the C stack by native callers. Alwa | |||
ys | ||||
* allocated on cx->stackPool for calls from the interpreter to an interpre | ||||
ted | ||||
* function. | ||||
* | ||||
* NB: This struct is manually initialized in jsinterp.c and jsiter.c. If | ||||
you | ||||
* add new members, update both files. But first, try to remove members. | ||||
The | ||||
* sharp* and xml* members should be moved onto the stack as local variable | ||||
s | ||||
* with well-known slots, if possible. | ||||
*/ | */ | |||
struct JSStackFrame { | struct JSStackFrame { | |||
JSObject *callobj; /* lazily created Call object */ | JSObject *callobj; /* lazily created Call object */ | |||
JSObject *argsobj; /* lazily created arguments object */ | JSObject *argsobj; /* lazily created arguments object */ | |||
JSObject *varobj; /* variables object, where vars go */ | JSObject *varobj; /* variables object, where vars go */ | |||
JSScript *script; /* script being interpreted */ | JSScript *script; /* script being interpreted */ | |||
JSFunction *fun; /* function being called or null */ | JSFunction *fun; /* function being called or null */ | |||
JSObject *thisp; /* "this" pointer if in method */ | JSObject *thisp; /* "this" pointer if in method */ | |||
uintN argc; /* actual argument count */ | uintN argc; /* actual argument count */ | |||
jsval *argv; /* base of argument stack slots */ | jsval *argv; /* base of argument stack slots */ | |||
skipping to change at line 75 | skipping to change at line 82 | |||
JSStackFrame *down; /* previous frame */ | JSStackFrame *down; /* previous frame */ | |||
void *annotation; /* used by Java security */ | void *annotation; /* used by Java security */ | |||
JSObject *scopeChain; /* scope chain */ | JSObject *scopeChain; /* scope chain */ | |||
jsbytecode *pc; /* program counter */ | jsbytecode *pc; /* program counter */ | |||
jsval *sp; /* stack pointer */ | jsval *sp; /* stack pointer */ | |||
jsval *spbase; /* operand stack base */ | jsval *spbase; /* operand stack base */ | |||
uintN sharpDepth; /* array/object initializer depth */ | uintN sharpDepth; /* array/object initializer depth */ | |||
JSObject *sharpArray; /* scope for #n= initializer vars */ | JSObject *sharpArray; /* scope for #n= initializer vars */ | |||
uint32 flags; /* frame flags -- see below */ | uint32 flags; /* frame flags -- see below */ | |||
JSStackFrame *dormantNext; /* next dormant frame chain */ | JSStackFrame *dormantNext; /* next dormant frame chain */ | |||
JSObject *xmlNamespace; /* null or default xml namespace in E4X | ||||
*/ | ||||
JSObject *blockChain; /* active compile-time block scopes */ | ||||
}; | }; | |||
typedef struct JSInlineFrame { | typedef struct JSInlineFrame { | |||
JSStackFrame frame; /* base struct */ | JSStackFrame frame; /* base struct */ | |||
jsval *rvp; /* ptr to caller's return value slot */ | ||||
void *mark; /* mark before inline frame */ | void *mark; /* mark before inline frame */ | |||
void *hookData; /* debugger call hook data */ | void *hookData; /* debugger call hook data */ | |||
JSVersion callerVersion; /* dynamic version of calling script */ | JSVersion callerVersion; /* dynamic version of calling script */ | |||
} JSInlineFrame; | } JSInlineFrame; | |||
/* JS stack frame flags. */ | /* JS stack frame flags. */ | |||
#define JSFRAME_CONSTRUCTING 0x01 /* frame is for a constructor invocatio n */ | #define JSFRAME_CONSTRUCTING 0x01 /* frame is for a constructor invocatio n */ | |||
#define JSFRAME_INTERNAL 0x02 /* internal call, not invoked by a scri pt */ | #define JSFRAME_INTERNAL 0x02 /* internal call, not invoked by a scri pt */ | |||
#define JSFRAME_SKIP_CALLER 0x04 /* skip one link when evaluating f.call er | #define JSFRAME_SKIP_CALLER 0x04 /* skip one link when evaluating f.call er | |||
for this invocation of f */ | for this invocation of f */ | |||
#define JSFRAME_ASSIGNING 0x08 /* a complex (not simplex JOF_ASSIGNING ) op | #define JSFRAME_ASSIGNING 0x08 /* a complex (not simplex JOF_ASSIGNING ) op | |||
is currently assigning to a property */ | is currently assigning to a property */ | |||
#define JSFRAME_DEBUGGER 0x10 /* frame for JS_EvaluateInStackFrame */ | #define JSFRAME_DEBUGGER 0x10 /* frame for JS_EvaluateInStackFrame */ | |||
#define JSFRAME_EVAL 0x20 /* frame for obj_eval */ | #define JSFRAME_EVAL 0x20 /* frame for obj_eval */ | |||
#define JSFRAME_SPECIAL 0x30 /* special evaluation frame flags */ | #define JSFRAME_SPECIAL 0x30 /* special evaluation frame flags */ | |||
#define JSFRAME_COMPILING 0x40 /* frame is being used by compiler */ | #define JSFRAME_COMPILING 0x40 /* frame is being used by compiler */ | |||
#define JSFRAME_COMPILE_N_GO 0x80 /* compiler-and-go mode, can optimize n ame | #define JSFRAME_COMPILE_N_GO 0x80 /* compiler-and-go mode, can optimize n ame | |||
references based on scope chain */ | references based on scope chain */ | |||
#define JSFRAME_SCRIPT_OBJECT 0x100 /* compiling source for a Script object | ||||
*/ | ||||
#define JSFRAME_YIELDING 0x200 /* js_Interpret dispatched JSOP_YIELD * | ||||
/ | ||||
#define JSFRAME_FILTERING 0x400 /* XML filtering predicate expression * | ||||
/ | ||||
#define JSFRAME_ITERATOR 0x800 /* trying to get an iterator for for-in | ||||
*/ | ||||
#define JSFRAME_POP_BLOCKS 0x1000 /* scope chain contains blocks to pop * | ||||
/ | ||||
#define JSFRAME_GENERATOR 0x2000 /* frame belongs to generator-iterator | ||||
*/ | ||||
#define JSFRAME_OVERRIDE_SHIFT 24 /* override bit-set params; see jsfun.c */ | #define JSFRAME_OVERRIDE_SHIFT 24 /* override bit-set params; see jsfun.c */ | |||
#define JSFRAME_OVERRIDE_BITS 8 | #define JSFRAME_OVERRIDE_BITS 8 | |||
/* | /* | |||
* Property cache for quickened get/set property opcodes. | * Property cache for quickened get/set property opcodes. | |||
*/ | */ | |||
#define PROPERTY_CACHE_LOG2 10 | #define PROPERTY_CACHE_LOG2 10 | |||
#define PROPERTY_CACHE_SIZE JS_BIT(PROPERTY_CACHE_LOG2) | #define PROPERTY_CACHE_SIZE JS_BIT(PROPERTY_CACHE_LOG2) | |||
#define PROPERTY_CACHE_MASK JS_BITMASK(PROPERTY_CACHE_LOG2) | #define PROPERTY_CACHE_MASK JS_BITMASK(PROPERTY_CACHE_LOG2) | |||
skipping to change at line 258 | skipping to change at line 274 | |||
#ifdef DUMP_CALL_TABLE | #ifdef DUMP_CALL_TABLE | |||
# define JSOPTION_LOGCALL_TOSOURCE JS_BIT(15) | # define JSOPTION_LOGCALL_TOSOURCE JS_BIT(15) | |||
extern JSHashTable *js_CallTable; | extern JSHashTable *js_CallTable; | |||
extern size_t js_LogCallToSourceLimit; | extern size_t js_LogCallToSourceLimit; | |||
extern void js_DumpCallTable(JSContext *cx); | extern void js_DumpCallTable(JSContext *cx); | |||
#endif | #endif | |||
/* | /* | |||
* Refresh and return fp->scopeChain. It may be stale if block scopes are | ||||
* active but not yet reflected by objects in the scope chain. If a block | ||||
* scope contains a with, eval, XML filtering predicate, or similar such | ||||
* dynamically scoped construct, then compile-time block scope at fp->block | ||||
s | ||||
* must reflect at runtime. | ||||
*/ | ||||
extern JSObject * | ||||
js_GetScopeChain(JSContext *cx, JSStackFrame *fp); | ||||
/* | ||||
* Compute the 'this' parameter for a call with nominal 'this' given by thi | ||||
sp | ||||
* and arguments including argv[-1] (nominal 'this') and argv[-2] (callee). | ||||
* Activation objects ("Call" objects not created with "new Call()", i.e., | ||||
* "Call" objects that have private data) may not be referred to by 'this', | ||||
* per ECMA-262, so js_ComputeThis censors them. | ||||
*/ | ||||
extern JSObject * | ||||
js_ComputeThis(JSContext *cx, JSObject *thisp, jsval *argv); | ||||
/* | ||||
* NB: js_Invoke requires that cx is currently running JS (i.e., that cx->f p | * NB: js_Invoke requires that cx is currently running JS (i.e., that cx->f p | |||
* is non-null). | * is non-null), and that the callee, |this| parameter, and actual argument | |||
s | ||||
* are already pushed on the stack under cx->fp->sp. | ||||
*/ | */ | |||
extern JS_FRIEND_API(JSBool) | extern JS_FRIEND_API(JSBool) | |||
js_Invoke(JSContext *cx, uintN argc, uintN flags); | js_Invoke(JSContext *cx, uintN argc, uintN flags); | |||
/* | /* | |||
* Consolidated js_Invoke flags simply rename the low JSFRAME_* flags. | * Consolidated js_Invoke flags simply rename certain JSFRAME_* flags, so t | |||
hat | ||||
* we can share bits stored in JSStackFrame.flags and passed to: | ||||
* | ||||
* js_Invoke | ||||
* js_InternalInvoke | ||||
* js_ValueToFunction | ||||
* js_ValueToFunctionObject | ||||
* js_ValueToCallableObject | ||||
* js_ReportIsNotFunction | ||||
* | ||||
* See jsfun.h for the latter four and flag renaming macros. | ||||
*/ | */ | |||
#define JSINVOKE_CONSTRUCT JSFRAME_CONSTRUCTING | #define JSINVOKE_CONSTRUCT JSFRAME_CONSTRUCTING | |||
#define JSINVOKE_INTERNAL JSFRAME_INTERNAL | #define JSINVOKE_INTERNAL JSFRAME_INTERNAL | |||
#define JSINVOKE_SKIP_CALLER JSFRAME_SKIP_CALLER | #define JSINVOKE_SKIP_CALLER JSFRAME_SKIP_CALLER | |||
#define JSINVOKE_ITERATOR JSFRAME_ITERATOR | ||||
/* | ||||
* Mask to isolate construct and iterator flags for use with jsfun.h functi | ||||
ons. | ||||
*/ | ||||
#define JSINVOKE_FUNFLAGS (JSINVOKE_CONSTRUCT | JSINVOKE_ITERATOR) | ||||
/* | /* | |||
* "Internal" calls may come from C or C++ code using a JSContext on which no | * "Internal" calls may come from C or C++ code using a JSContext on which no | |||
* JS is running (!cx->fp), so they may need to push a dummy JSStackFrame. | * JS is running (!cx->fp), so they may need to push a dummy JSStackFrame. | |||
*/ | */ | |||
#define js_InternalCall(cx,obj,fval,argc,argv,rval) \ | #define js_InternalCall(cx,obj,fval,argc,argv,rval) \ | |||
js_InternalInvoke(cx, obj, fval, 0, argc, argv, rval) | js_InternalInvoke(cx, obj, fval, 0, argc, argv, rval) | |||
#define js_InternalConstruct(cx,obj,fval,argc,argv,rval) \ | #define js_InternalConstruct(cx,obj,fval,argc,argv,rval) \ | |||
js_InternalInvoke(cx, obj, fval, JSINVOKE_CONSTRUCT, argc, argv, rval) | js_InternalInvoke(cx, obj, fval, JSINVOKE_CONSTRUCT, argc, argv, rval) | |||
skipping to change at line 298 | skipping to change at line 351 | |||
extern JSBool | extern JSBool | |||
js_Execute(JSContext *cx, JSObject *chain, JSScript *script, | js_Execute(JSContext *cx, JSObject *chain, JSScript *script, | |||
JSStackFrame *down, uintN flags, jsval *result); | JSStackFrame *down, uintN flags, jsval *result); | |||
extern JSBool | extern JSBool | |||
js_CheckRedeclaration(JSContext *cx, JSObject *obj, jsid id, uintN attrs, | js_CheckRedeclaration(JSContext *cx, JSObject *obj, jsid id, uintN attrs, | |||
JSObject **objp, JSProperty **propp); | JSObject **objp, JSProperty **propp); | |||
extern JSBool | extern JSBool | |||
js_Interpret(JSContext *cx, jsval *result); | js_StrictlyEqual(jsval lval, jsval rval); | |||
extern JSBool | ||||
js_InvokeConstructor(JSContext *cx, jsval *vp, uintN argc); | ||||
extern JSBool | ||||
js_Interpret(JSContext *cx, jsbytecode *pc, jsval *result); | ||||
JS_END_EXTERN_C | JS_END_EXTERN_C | |||
#endif /* jsinterp_h___ */ | #endif /* jsinterp_h___ */ | |||
End of changes. 9 change blocks. | ||||
4 lines changed or deleted | 80 lines changed or added | |||
jslibmath.h | jslibmath.h | |||
---|---|---|---|---|
skipping to change at line 53 | skipping to change at line 53 | |||
* remap the math calls to native routines. | * remap the math calls to native routines. | |||
*/ | */ | |||
#ifndef _LIBMATH_H | #ifndef _LIBMATH_H | |||
#define _LIBMATH_H | #define _LIBMATH_H | |||
#include <math.h> | #include <math.h> | |||
#include "jsconfig.h" | #include "jsconfig.h" | |||
/* | /* | |||
* Define which platforms on which to use fdlibm. Not used | * Define on which platforms to use fdlibm. Not used by default under | |||
* by default since there can be problems with endian-ness and such. | * assumption that native math library works unless proved guilty. | |||
* Plus there can be problems with endian-ness and such in fdlibm itself. | ||||
* | ||||
* fdlibm compatibility notes: | ||||
* - fdlibm broken on OSF1/alpha | ||||
*/ | */ | |||
#if defined(_WIN32) && !defined(__MWERKS__) | #ifndef JS_USE_FDLIBM_MATH | |||
#define JS_USE_FDLIBM_MATH 1 | ||||
#elif defined(SUNOS4) | ||||
#define JS_USE_FDLIBM_MATH 1 | ||||
#elif defined(IRIX) | ||||
#define JS_USE_FDLIBM_MATH 1 | ||||
#elif defined(SOLARIS) | ||||
#define JS_USE_FDLIBM_MATH 1 | ||||
#elif defined(HPUX) | ||||
#define JS_USE_FDLIBM_MATH 1 | ||||
#elif defined(linux) | ||||
#define JS_USE_FDLIBM_MATH 1 | ||||
#elif defined(OSF1) | ||||
/* Want to use some fdlibm functions but fdlibm broken on OSF1/alpha. */ | ||||
#define JS_USE_FDLIBM_MATH 0 | ||||
#elif defined(AIX) | ||||
#define JS_USE_FDLIBM_MATH 1 | ||||
#else | ||||
#define JS_USE_FDLIBM_MATH 0 | #define JS_USE_FDLIBM_MATH 0 | |||
#endif | #endif | |||
#if !JS_USE_FDLIBM_MATH | #if !JS_USE_FDLIBM_MATH | |||
/* | /* | |||
* Use system provided math routines. | * Use system provided math routines. | |||
*/ | */ | |||
#define fd_acos acos | #define fd_acos acos | |||
#define fd_asin asin | #define fd_asin asin | |||
#define fd_atan atan | #define fd_atan atan | |||
#define fd_atan2 atan2 | #define fd_atan2 atan2 | |||
#define fd_ceil ceil | #define fd_ceil ceil | |||
/* The right copysign function is not always named the same thing. */ | ||||
#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) | ||||
#define fd_copysign __builtin_copysign | ||||
#elif defined WINCE | ||||
#define fd_copysign _copysign | ||||
#elif defined _WIN32 | ||||
#if _MSC_VER < 1400 | ||||
/* Try to work around apparent _copysign bustage in VC6 and VC7. */ | ||||
#define fd_copysign js_copysign | ||||
extern double js_copysign(double, double); | ||||
#else | ||||
#define fd_copysign _copysign | ||||
#endif | ||||
#else | ||||
#define fd_copysign copysign | #define fd_copysign copysign | |||
#endif | ||||
#define fd_cos cos | #define fd_cos cos | |||
#define fd_exp exp | #define fd_exp exp | |||
#define fd_fabs fabs | #define fd_fabs fabs | |||
#define fd_floor floor | #define fd_floor floor | |||
#define fd_fmod fmod | #define fd_fmod fmod | |||
#define fd_log log | #define fd_log log | |||
#define fd_pow pow | #define fd_pow pow | |||
#define fd_sin sin | #define fd_sin sin | |||
#define fd_sqrt sqrt | #define fd_sqrt sqrt | |||
#define fd_tan tan | #define fd_tan tan | |||
skipping to change at line 122 | skipping to change at line 118 | |||
* Use math routines in fdlibm. | * Use math routines in fdlibm. | |||
*/ | */ | |||
#undef __P | #undef __P | |||
#ifdef __STDC__ | #ifdef __STDC__ | |||
#define __P(p) p | #define __P(p) p | |||
#else | #else | |||
#define __P(p) () | #define __P(p) () | |||
#endif | #endif | |||
#if defined _WIN32 || defined SUNOS4 | #if (defined _WIN32 && !defined WINCE) || defined SUNOS4 | |||
#define fd_acos acos | #define fd_acos acos | |||
#define fd_asin asin | #define fd_asin asin | |||
#define fd_atan atan | #define fd_atan atan | |||
#define fd_cos cos | #define fd_cos cos | |||
#define fd_sin sin | #define fd_sin sin | |||
#define fd_tan tan | #define fd_tan tan | |||
#define fd_exp exp | #define fd_exp exp | |||
#define fd_log log | #define fd_log log | |||
#define fd_sqrt sqrt | #define fd_sqrt sqrt | |||
skipping to change at line 203 | skipping to change at line 199 | |||
extern double fd_ceil __P((double)); | extern double fd_ceil __P((double)); | |||
extern double fd_acos __P((double)); | extern double fd_acos __P((double)); | |||
extern double fd_log __P((double)); | extern double fd_log __P((double)); | |||
extern double fd_atan2 __P((double, double)); | extern double fd_atan2 __P((double, double)); | |||
extern double fd_tan __P((double)); | extern double fd_tan __P((double)); | |||
extern double fd_pow __P((double, double)); | extern double fd_pow __P((double, double)); | |||
extern double fd_asin __P((double)); | extern double fd_asin __P((double)); | |||
extern double fd_atan __P((double)); | extern double fd_atan __P((double)); | |||
extern double fd_copysign __P((double, double)); | extern double fd_copysign __P((double, double)); | |||
#elif defined(linux) | ||||
#define fd_atan atan | ||||
#define fd_atan2 atan2 | ||||
#define fd_ceil ceil | ||||
#define fd_cos cos | ||||
#define fd_fabs fabs | ||||
#define fd_floor floor | ||||
#define fd_fmod fmod | ||||
#define fd_sin sin | ||||
#define fd_sqrt sqrt | ||||
#define fd_tan tan | ||||
#define fd_copysign copysign | ||||
extern double fd_asin __P((double)); | ||||
extern double fd_acos __P((double)); | ||||
extern double fd_exp __P((double)); | ||||
extern double fd_log __P((double)); | ||||
extern double fd_pow __P((double, double)); | ||||
#elif defined(OSF1) | #elif defined(OSF1) | |||
#define fd_acos acos | #define fd_acos acos | |||
#define fd_asin asin | #define fd_asin asin | |||
#define fd_atan atan | #define fd_atan atan | |||
#define fd_copysign copysign | #define fd_copysign copysign | |||
#define fd_cos cos | #define fd_cos cos | |||
#define fd_exp exp | #define fd_exp exp | |||
#define fd_fabs fabs | #define fd_fabs fabs | |||
#define fd_fmod fmod | #define fd_fmod fmod | |||
End of changes. 6 change blocks. | ||||
49 lines changed or deleted | 25 lines changed or added | |||
jslock.h | jslock.h | |||
---|---|---|---|---|
skipping to change at line 48 | skipping to change at line 48 | |||
* ***** END LICENSE BLOCK ***** */ | * ***** END LICENSE BLOCK ***** */ | |||
#ifndef jslock_h__ | #ifndef jslock_h__ | |||
#define jslock_h__ | #define jslock_h__ | |||
#ifdef JS_THREADSAFE | #ifdef JS_THREADSAFE | |||
#include "jstypes.h" | #include "jstypes.h" | |||
#include "pratom.h" | #include "pratom.h" | |||
#include "prlock.h" | #include "prlock.h" | |||
#include "prcvar.h" | #include "prcvar.h" | |||
#include "prthread.h" | ||||
#include "jsprvtd.h" /* for JSScope, etc. */ | #include "jsprvtd.h" /* for JSScope, etc. */ | |||
#include "jspubtd.h" /* for JSRuntime, etc. */ | #include "jspubtd.h" /* for JSRuntime, etc. */ | |||
#define Thin_GetWait(W) ((jsword)(W) & 0x1) | #define Thin_GetWait(W) ((jsword)(W) & 0x1) | |||
#define Thin_SetWait(W) ((jsword)(W) | 0x1) | #define Thin_SetWait(W) ((jsword)(W) | 0x1) | |||
#define Thin_RemoveWait(W) ((jsword)(W) & ~0x1) | #define Thin_RemoveWait(W) ((jsword)(W) & ~0x1) | |||
typedef struct JSFatLock JSFatLock; | typedef struct JSFatLock JSFatLock; | |||
skipping to change at line 71 | skipping to change at line 72 | |||
PRCondVar *svar; | PRCondVar *svar; | |||
JSFatLock *next; | JSFatLock *next; | |||
JSFatLock **prevp; | JSFatLock **prevp; | |||
}; | }; | |||
typedef struct JSThinLock { | typedef struct JSThinLock { | |||
jsword owner; | jsword owner; | |||
JSFatLock *fat; | JSFatLock *fat; | |||
} JSThinLock; | } JSThinLock; | |||
#define CX_THINLOCK_ID(cx) ((jsword)(cx)->thread) | ||||
#define CURRENT_THREAD_IS_ME(me) (((JSThread *)me)->id == js_CurrentThreadI | ||||
d()) | ||||
typedef PRLock JSLock; | typedef PRLock JSLock; | |||
typedef struct JSFatLockTable { | typedef struct JSFatLockTable { | |||
JSFatLock *free; | JSFatLock *free; | |||
JSFatLock *taken; | JSFatLock *taken; | |||
} JSFatLockTable; | } JSFatLockTable; | |||
/* | /* | |||
* Atomic increment and decrement for a reference counter, given jsrefcount *p. | * Atomic increment and decrement for a reference counter, given jsrefcount *p. | |||
* NB: jsrefcount is int32, aka PRInt32, so that pratom.h functions work. | * NB: jsrefcount is int32, aka PRInt32, so that pratom.h functions work. | |||
*/ | */ | |||
#define JS_ATOMIC_INCREMENT(p) PR_AtomicIncrement((PRInt32 *)(p)) | #define JS_ATOMIC_INCREMENT(p) PR_AtomicIncrement((PRInt32 *)(p)) | |||
#define JS_ATOMIC_DECREMENT(p) PR_AtomicDecrement((PRInt32 *)(p)) | #define JS_ATOMIC_DECREMENT(p) PR_AtomicDecrement((PRInt32 *)(p)) | |||
#define JS_ATOMIC_ADD(p,v) PR_AtomicAdd((PRInt32 *)(p), (PRInt32)( v)) | #define JS_ATOMIC_ADD(p,v) PR_AtomicAdd((PRInt32 *)(p), (PRInt32)( v)) | |||
#define CurrentThreadId() (jsword)PR_GetCurrentThread() | #define js_CurrentThreadId() (jsword)PR_GetCurrentThread() | |||
#define JS_CurrentThreadId() js_CurrentThreadId() | ||||
#define JS_NEW_LOCK() PR_NewLock() | #define JS_NEW_LOCK() PR_NewLock() | |||
#define JS_DESTROY_LOCK(l) PR_DestroyLock(l) | #define JS_DESTROY_LOCK(l) PR_DestroyLock(l) | |||
#define JS_ACQUIRE_LOCK(l) PR_Lock(l) | #define JS_ACQUIRE_LOCK(l) PR_Lock(l) | |||
#define JS_RELEASE_LOCK(l) PR_Unlock(l) | #define JS_RELEASE_LOCK(l) PR_Unlock(l) | |||
#define JS_LOCK0(P,M) js_Lock(P,M) | #define JS_LOCK0(P,M) js_Lock(P,M) | |||
#define JS_UNLOCK0(P,M) js_Unlock(P,M) | #define JS_UNLOCK0(P,M) js_Unlock(P,M) | |||
#define JS_NEW_CONDVAR(l) PR_NewCondVar(l) | #define JS_NEW_CONDVAR(l) PR_NewCondVar(l) | |||
#define JS_DESTROY_CONDVAR(cv) PR_DestroyCondVar(cv) | #define JS_DESTROY_CONDVAR(cv) PR_DestroyCondVar(cv) | |||
#define JS_WAIT_CONDVAR(cv,to) PR_WaitCondVar(cv,to) | #define JS_WAIT_CONDVAR(cv,to) PR_WaitCondVar(cv,to) | |||
skipping to change at line 109 | skipping to change at line 112 | |||
#define JS_NOTIFY_CONDVAR(cv) PR_NotifyCondVar(cv) | #define JS_NOTIFY_CONDVAR(cv) PR_NotifyCondVar(cv) | |||
#define JS_NOTIFY_ALL_CONDVAR(cv) PR_NotifyAllCondVar(cv) | #define JS_NOTIFY_ALL_CONDVAR(cv) PR_NotifyAllCondVar(cv) | |||
/* | /* | |||
* Include jsscope.h so JS_LOCK_OBJ macro callers don't have to include it. | * Include jsscope.h so JS_LOCK_OBJ macro callers don't have to include it. | |||
* Since there is a JSThinLock member in JSScope, we can't nest this includ e | * Since there is a JSThinLock member in JSScope, we can't nest this includ e | |||
* much earlier (see JSThinLock's typedef, above). Yes, that means there i s | * much earlier (see JSThinLock's typedef, above). Yes, that means there i s | |||
* an #include cycle between jslock.h and jsscope.h: moderate-sized XXX her e, | * an #include cycle between jslock.h and jsscope.h: moderate-sized XXX her e, | |||
* to be fixed by moving JS_LOCK_SCOPE to jsscope.h, JS_LOCK_OBJ to jsobj.h , | * to be fixed by moving JS_LOCK_SCOPE to jsscope.h, JS_LOCK_OBJ to jsobj.h , | |||
* and so on. | * and so on. | |||
* | ||||
* We also need jsscope.h #ifdef DEBUG for SET_OBJ_INFO and SET_SCOPE_INFO, | ||||
* but we do not want any nested includes that depend on DEBUG. Those lead | ||||
* to build bustage when someone makes a change that depends in a subtle wa | ||||
y | ||||
* on jsscope.h being included directly or indirectly, but does not test by | ||||
* building optimized as well as DEBUG. | ||||
*/ | */ | |||
#include "jsscope.h" | #include "jsscope.h" | |||
#ifdef DEBUG | ||||
#define SET_OBJ_INFO(obj_,file_,line_) | ||||
\ | ||||
SET_SCOPE_INFO(OBJ_SCOPE(obj_),file_,line_) | ||||
#define SET_SCOPE_INFO(scope_,file_,line_) | ||||
\ | ||||
((scope_)->ownercx ? (void)0 : | ||||
\ | ||||
(JS_ASSERT((0 < (scope_)->u.count && (scope_)->u.count <= 4) || | ||||
\ | ||||
SCOPE_IS_SEALED(scope_)), | ||||
\ | ||||
(void)((scope_)->file[(scope_)->u.count-1] = (file_), | ||||
\ | ||||
(scope_)->line[(scope_)->u.count-1] = (line_)))) | ||||
#endif /* DEBUG */ | ||||
#define JS_LOCK_RUNTIME(rt) js_LockRuntime(rt) | #define JS_LOCK_RUNTIME(rt) js_LockRuntime(rt) | |||
#define JS_UNLOCK_RUNTIME(rt) js_UnlockRuntime(rt) | #define JS_UNLOCK_RUNTIME(rt) js_UnlockRuntime(rt) | |||
/* | /* | |||
* NB: The JS_LOCK_OBJ and JS_UNLOCK_OBJ macros work *only* on native objec ts | * NB: The JS_LOCK_OBJ and JS_UNLOCK_OBJ macros work *only* on native objec ts | |||
* (objects for which OBJ_IS_NATIVE returns true). All uses of these macro s in | * (objects for which OBJ_IS_NATIVE returns true). All uses of these macro s in | |||
* the engine are predicated on OBJ_IS_NATIVE or equivalent checks. These uses | * the engine are predicated on OBJ_IS_NATIVE or equivalent checks. These uses | |||
* are for optimizations above the JSObjectOps layer, under which object lo cks | * are for optimizations above the JSObjectOps layer, under which object lo cks | |||
* normally hide. | * normally hide. | |||
*/ | */ | |||
#define JS_LOCK_OBJ(cx,obj) ((OBJ_SCOPE(obj)->ownercx == (cx)) \ | #define JS_LOCK_OBJ(cx,obj) ((OBJ_SCOPE(obj)->ownercx == (cx)) \ | |||
? (void)0 \ | ? (void)0 \ | |||
: (js_LockObj(cx, obj), | : (js_LockObj(cx, obj))) | |||
\ | ||||
SET_OBJ_INFO(obj,__FILE__,__LINE__) | ||||
)) | ||||
#define JS_UNLOCK_OBJ(cx,obj) ((OBJ_SCOPE(obj)->ownercx == (cx)) \ | #define JS_UNLOCK_OBJ(cx,obj) ((OBJ_SCOPE(obj)->ownercx == (cx)) \ | |||
? (void)0 : js_UnlockObj(cx, obj)) | ? (void)0 : js_UnlockObj(cx, obj)) | |||
#define JS_LOCK_SCOPE(cx,scope) ((scope)->ownercx == (cx) ? (void)0 : | #define JS_LOCK_SCOPE(cx,scope) ((scope)->ownercx == (cx) ? (void)0 | |||
\ | \ | |||
(js_LockScope(cx, scope), | : js_LockScope(cx, scope)) | |||
\ | #define JS_UNLOCK_SCOPE(cx,scope) ((scope)->ownercx == (cx) ? (void)0 | |||
SET_SCOPE_INFO(scope,__FILE__,__LINE_ | \ | |||
_))) | : js_UnlockScope(cx, scope)) | |||
#define JS_UNLOCK_SCOPE(cx,scope) ((scope)->ownercx == (cx) ? (void)0 : | ||||
\ | ||||
js_UnlockScope(cx, scope)) | ||||
#define JS_TRANSFER_SCOPE_LOCK(cx, scope, newscope) \ | #define JS_TRANSFER_SCOPE_LOCK(cx, scope, newscope) \ | |||
js_TransferScopeLock(cx, scope, newscop e) | js_TransferScopeLock(cx, scope, newscop e) | |||
extern jsword js_CurrentThreadId(); | ||||
extern void js_LockRuntime(JSRuntime *rt); | extern void js_LockRuntime(JSRuntime *rt); | |||
extern void js_UnlockRuntime(JSRuntime *rt); | extern void js_UnlockRuntime(JSRuntime *rt); | |||
extern void js_LockObj(JSContext *cx, JSObject *obj); | extern void js_LockObj(JSContext *cx, JSObject *obj); | |||
extern void js_UnlockObj(JSContext *cx, JSObject *obj); | extern void js_UnlockObj(JSContext *cx, JSObject *obj); | |||
extern void js_LockScope(JSContext *cx, JSScope *scope); | extern void js_LockScope(JSContext *cx, JSScope *scope); | |||
extern void js_UnlockScope(JSContext *cx, JSScope *scope); | extern void js_UnlockScope(JSContext *cx, JSScope *scope); | |||
extern int js_SetupLocks(int,int); | extern int js_SetupLocks(int,int); | |||
extern void js_CleanupLocks(); | extern void js_CleanupLocks(); | |||
extern void js_InitContextForLocking(JSContext *); | ||||
extern void js_TransferScopeLock(JSContext *, JSScope *, JSScope *); | extern void js_TransferScopeLock(JSContext *, JSScope *, JSScope *); | |||
extern JS_FRIEND_API(jsval) | extern JS_FRIEND_API(jsval) | |||
js_GetSlotThreadSafe(JSContext *, JSObject *, uint32); | js_GetSlotThreadSafe(JSContext *, JSObject *, uint32); | |||
extern void js_SetSlotThreadSafe(JSContext *, JSObject *, uint32, jsval); | extern void js_SetSlotThreadSafe(JSContext *, JSObject *, uint32, jsval); | |||
extern void js_InitLock(JSThinLock *); | extern void js_InitLock(JSThinLock *); | |||
extern void js_FinishLock(JSThinLock *); | extern void js_FinishLock(JSThinLock *); | |||
extern void js_FinishSharingScope(JSRuntime *rt, JSScope *scope); | extern void js_FinishSharingScope(JSRuntime *rt, JSScope *scope); | |||
#ifdef DEBUG | #ifdef DEBUG | |||
skipping to change at line 205 | skipping to change at line 185 | |||
e; \ | e; \ | |||
JS_UNLOCK_OBJ(cx, obj); \ | JS_UNLOCK_OBJ(cx, obj); \ | |||
JS_END_MACRO | JS_END_MACRO | |||
#define JS_LOCK_VOID(cx, e) \ | #define JS_LOCK_VOID(cx, e) \ | |||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
JSRuntime *_rt = (cx)->runtime; \ | JSRuntime *_rt = (cx)->runtime; \ | |||
JS_LOCK_RUNTIME_VOID(_rt, e); \ | JS_LOCK_RUNTIME_VOID(_rt, e); \ | |||
JS_END_MACRO | JS_END_MACRO | |||
/* FIXME: bug 353962 hackaround */ | ||||
#define JS_USE_ONLY_NSPR_LOCKS 1 | ||||
#if defined(JS_USE_ONLY_NSPR_LOCKS) || \ | #if defined(JS_USE_ONLY_NSPR_LOCKS) || \ | |||
!( (defined(_WIN32) && defined(_M_IX86)) || \ | !( (defined(_WIN32) && defined(_M_IX86)) || \ | |||
(defined(__GNUC__) && defined(__i386__)) || \ | (defined(__GNUC__) && defined(__i386__)) || \ | |||
((defined(__USLC__) || defined(_SCO_DS)) && defined(i386)) || \ | ||||
(defined(SOLARIS) && defined(sparc) && defined(ULTRA_SPARC)) || \ | (defined(SOLARIS) && defined(sparc) && defined(ULTRA_SPARC)) || \ | |||
defined(AIX) ) | defined(AIX) ) | |||
#define NSPR_LOCK 1 | #define NSPR_LOCK 1 | |||
#undef JS_LOCK0 | #undef JS_LOCK0 | |||
#undef JS_UNLOCK0 | #undef JS_UNLOCK0 | |||
#define JS_LOCK0(P,M) (JS_ACQUIRE_LOCK(((JSLock*)(P)->fat)), (P)->owner = (M)) | #define JS_LOCK0(P,M) (JS_ACQUIRE_LOCK(((JSLock*)(P)->fat)), (P)->owner = (M)) | |||
#define JS_UNLOCK0(P,M) ((P)->owner = 0, JS_RELEASE_LOCK(((JSLock*)(P)->fat ))) | #define JS_UNLOCK0(P,M) ((P)->owner = 0, JS_RELEASE_LOCK(((JSLock*)(P)->fat ))) | |||
skipping to change at line 279 | skipping to change at line 263 | |||
#define JS_LOCK_GC(rt) JS_ACQUIRE_LOCK((rt)->gcLock) | #define JS_LOCK_GC(rt) JS_ACQUIRE_LOCK((rt)->gcLock) | |||
#define JS_UNLOCK_GC(rt) JS_RELEASE_LOCK((rt)->gcLock) | #define JS_UNLOCK_GC(rt) JS_RELEASE_LOCK((rt)->gcLock) | |||
#define JS_LOCK_GC_VOID(rt,e) (JS_LOCK_GC(rt), (e), JS_UNLOCK_GC(rt)) | #define JS_LOCK_GC_VOID(rt,e) (JS_LOCK_GC(rt), (e), JS_UNLOCK_GC(rt)) | |||
#define JS_AWAIT_GC_DONE(rt) JS_WAIT_CONDVAR((rt)->gcDone, JS_NO_TIM EOUT) | #define JS_AWAIT_GC_DONE(rt) JS_WAIT_CONDVAR((rt)->gcDone, JS_NO_TIM EOUT) | |||
#define JS_NOTIFY_GC_DONE(rt) JS_NOTIFY_ALL_CONDVAR((rt)->gcDone) | #define JS_NOTIFY_GC_DONE(rt) JS_NOTIFY_ALL_CONDVAR((rt)->gcDone) | |||
#define JS_AWAIT_REQUEST_DONE(rt) JS_WAIT_CONDVAR((rt)->requestDone, \ | #define JS_AWAIT_REQUEST_DONE(rt) JS_WAIT_CONDVAR((rt)->requestDone, \ | |||
JS_NO_TIMEOUT) | JS_NO_TIMEOUT) | |||
#define JS_NOTIFY_REQUEST_DONE(rt) JS_NOTIFY_CONDVAR((rt)->requestDone) | #define JS_NOTIFY_REQUEST_DONE(rt) JS_NOTIFY_CONDVAR((rt)->requestDone) | |||
#define JS_LOCK(P,CX) JS_LOCK0(P,(CX)->thread) | #define JS_LOCK(P,CX) JS_LOCK0(P, CX_THINLOCK_ID(CX)) | |||
#define JS_UNLOCK(P,CX) JS_UNLOCK0(P,(CX)->thread) | #define JS_UNLOCK(P,CX) JS_UNLOCK0(P, CX_THINLOCK_ID(CX)) | |||
#ifndef SET_OBJ_INFO | ||||
#define SET_OBJ_INFO(obj,f,l) ((void)0) | ||||
#endif | ||||
#ifndef SET_SCOPE_INFO | ||||
#define SET_SCOPE_INFO(scope,f,l) ((void)0) | ||||
#endif | ||||
#endif /* jslock_h___ */ | #endif /* jslock_h___ */ | |||
End of changes. 12 change blocks. | ||||
52 lines changed or deleted | 19 lines changed or added | |||
jsmath.h | jsmath.h | |||
---|---|---|---|---|
skipping to change at line 50 | skipping to change at line 50 | |||
*/ | */ | |||
#ifndef jsmath_h___ | #ifndef jsmath_h___ | |||
#define jsmath_h___ | #define jsmath_h___ | |||
/* | /* | |||
* JS math functions. | * JS math functions. | |||
*/ | */ | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
extern JSClass js_MathClass; | ||||
extern JSObject * | extern JSObject * | |||
js_InitMathClass(JSContext *cx, JSObject *obj); | js_InitMathClass(JSContext *cx, JSObject *obj); | |||
JS_END_EXTERN_C | JS_END_EXTERN_C | |||
#endif /* jsmath_h___ */ | #endif /* jsmath_h___ */ | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 2 lines changed or added | |||
jsnum.h | jsnum.h | |||
---|---|---|---|---|
skipping to change at line 70 | skipping to change at line 70 | |||
* are stored in big endian`s way. | * are stored in big endian`s way. | |||
*/ | */ | |||
#if defined(__arm) || defined(__arm32__) || defined(__arm26__) || defined(_ _arm__) | #if defined(__arm) || defined(__arm32__) || defined(__arm26__) || defined(_ _arm__) | |||
#define CPU_IS_ARM | #define CPU_IS_ARM | |||
#endif | #endif | |||
typedef union jsdpun { | typedef union jsdpun { | |||
struct { | struct { | |||
#if defined(IS_LITTLE_ENDIAN) && !defined(CPU_IS_ARM) | #if defined(IS_LITTLE_ENDIAN) && !defined(CPU_IS_ARM) | |||
uint32 lo, hi; | uint32 lo, hi; | |||
#else | #else | |||
uint32 hi, lo; | uint32 hi, lo; | |||
#endif | #endif | |||
} s; | } s; | |||
jsdouble d; | jsdouble d; | |||
} jsdpun; | } jsdpun; | |||
#if (__GNUC__ == 2 && __GNUC_MINOR__ > 95) || __GNUC__ > 2 | #if (__GNUC__ == 2 && __GNUC_MINOR__ > 95) || __GNUC__ > 2 | |||
/* | /* | |||
* This version of the macros is safe for the alias optimizations that gcc | * This version of the macros is safe for the alias optimizations that gcc | |||
* does, but uses gcc-specific extensions. | * does, but uses gcc-specific extensions. | |||
*/ | */ | |||
skipping to change at line 127 | skipping to change at line 127 | |||
(JSDOUBLE_LO32(x) || (JSDOUBLE_HI32(x) & JSDOUBLE_HI32_MANTMASK))) | (JSDOUBLE_LO32(x) || (JSDOUBLE_HI32(x) & JSDOUBLE_HI32_MANTMASK))) | |||
#define JSDOUBLE_IS_INFINITE(x) \ | #define JSDOUBLE_IS_INFINITE(x) \ | |||
((JSDOUBLE_HI32(x) & ~JSDOUBLE_HI32_SIGNBIT) == JSDOUBLE_HI32_EXPMASK & & \ | ((JSDOUBLE_HI32(x) & ~JSDOUBLE_HI32_SIGNBIT) == JSDOUBLE_HI32_EXPMASK & & \ | |||
!JSDOUBLE_LO32(x)) | !JSDOUBLE_LO32(x)) | |||
#define JSDOUBLE_IS_FINITE(x) \ | #define JSDOUBLE_IS_FINITE(x) \ | |||
((JSDOUBLE_HI32(x) & JSDOUBLE_HI32_EXPMASK) != JSDOUBLE_HI32_EXPMASK) | ((JSDOUBLE_HI32(x) & JSDOUBLE_HI32_EXPMASK) != JSDOUBLE_HI32_EXPMASK) | |||
#define JSDOUBLE_IS_NEGZERO(d) (JSDOUBLE_HI32(d) == JSDOUBLE_HI32_SIGNBIT && \ | #define JSDOUBLE_IS_NEGZERO(d) (JSDOUBLE_HI32(d) == JSDOUBLE_HI32_SIGNBIT && \ | |||
JSDOUBLE_LO32(d) == 0) | JSDOUBLE_LO32(d) == 0) | |||
/* | /* | |||
* JSDOUBLE_IS_INT first checks that d is neither NaN nor infinite, to avoi d | * JSDOUBLE_IS_INT first checks that d is neither NaN nor infinite, to avoi d | |||
* raising SIGFPE on platforms such as Alpha Linux, then (only if the cast is | * raising SIGFPE on platforms such as Alpha Linux, then (only if the cast is | |||
* safe) leaves i as (jsint)d. This also avoid anomalous NaN floating poin t | * safe) leaves i as (jsint)d. This also avoid anomalous NaN floating poin t | |||
* comparisons under MSVC. | * comparisons under MSVC. | |||
*/ | */ | |||
#define JSDOUBLE_IS_INT(d, i) (JSDOUBLE_IS_FINITE(d) \ | #define JSDOUBLE_IS_INT(d, i) (JSDOUBLE_IS_FINITE(d) \ | |||
&& !JSDOUBLE_IS_NEGZERO(d) \ | && !JSDOUBLE_IS_NEGZERO(d) \ | |||
&& ((d) == (i = (jsint)(d)))) | && ((d) == (i = (jsint)(d)))) | |||
#if defined(XP_WIN) | ||||
#define JSDOUBLE_COMPARE(LVAL, OP, RVAL, IFNAN) | ||||
\ | ||||
((JSDOUBLE_IS_NaN(LVAL) || JSDOUBLE_IS_NaN(RVAL)) | ||||
\ | ||||
? (IFNAN) | ||||
\ | ||||
: (LVAL) OP (RVAL)) | ||||
#else | ||||
#define JSDOUBLE_COMPARE(LVAL, OP, RVAL, IFNAN) ((LVAL) OP (RVAL)) | ||||
#endif | ||||
/* Initialize number constants and runtime state for the first context. */ | /* Initialize number constants and runtime state for the first context. */ | |||
extern JSBool | extern JSBool | |||
js_InitRuntimeNumberState(JSContext *cx); | js_InitRuntimeNumberState(JSContext *cx); | |||
extern void | extern void | |||
js_FinishRuntimeNumberState(JSContext *cx); | js_FinishRuntimeNumberState(JSContext *cx); | |||
/* Initialize the Number class, returning its prototype object. */ | /* Initialize the Number class, returning its prototype object. */ | |||
extern JSClass js_NumberClass; | ||||
extern JSObject * | extern JSObject * | |||
js_InitNumberClass(JSContext *cx, JSObject *obj); | js_InitNumberClass(JSContext *cx, JSObject *obj); | |||
/* | /* | |||
* String constants for global function names, used in jsapi.c and jsnum.c. | * String constants for global function names, used in jsapi.c and jsnum.c. | |||
*/ | */ | |||
extern const char js_Infinity_str[]; | extern const char js_Infinity_str[]; | |||
extern const char js_NaN_str[]; | extern const char js_NaN_str[]; | |||
extern const char js_isNaN_str[]; | extern const char js_isNaN_str[]; | |||
extern const char js_isFinite_str[]; | extern const char js_isFinite_str[]; | |||
extern const char js_parseFloat_str[]; | extern const char js_parseFloat_str[]; | |||
extern const char js_parseInt_str[]; | extern const char js_parseInt_str[]; | |||
/* GC-allocate a new JS number. */ | /* GC-allocate a new JS number. */ | |||
extern jsdouble * | extern jsdouble * | |||
js_NewDouble(JSContext *cx, jsdouble d); | js_NewDouble(JSContext *cx, jsdouble d, uintN gcflag); | |||
extern void | extern void | |||
js_FinalizeDouble(JSContext *cx, jsdouble *dp); | js_FinalizeDouble(JSContext *cx, jsdouble *dp); | |||
extern JSBool | extern JSBool | |||
js_NewDoubleValue(JSContext *cx, jsdouble d, jsval *rval); | js_NewDoubleValue(JSContext *cx, jsdouble d, jsval *rval); | |||
extern JSBool | extern JSBool | |||
js_NewNumberValue(JSContext *cx, jsdouble d, jsval *rval); | js_NewNumberValue(JSContext *cx, jsdouble d, jsval *rval); | |||
End of changes. 6 change blocks. | ||||
5 lines changed or deleted | 19 lines changed or added | |||
jsobj.h | jsobj.h | |||
---|---|---|---|---|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* vim: set ts=8 sw=4 et tw=80: | ||||
* | * | |||
* ***** BEGIN LICENSE BLOCK ***** | * ***** BEGIN LICENSE BLOCK ***** | |||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | |||
* | * | |||
* The contents of this file are subject to the Mozilla Public License Vers ion | * The contents of this file are subject to the Mozilla Public License Vers ion | |||
* 1.1 (the "License"); you may not use this file except in compliance with | * 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 | * the License. You may obtain a copy of the License at | |||
* http://www.mozilla.org/MPL/ | * http://www.mozilla.org/MPL/ | |||
* | * | |||
* Software distributed under the License is distributed on an "AS IS" basi s, | * Software distributed under the License is distributed on an "AS IS" basi s, | |||
skipping to change at line 64 | skipping to change at line 65 | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
struct JSObjectMap { | struct JSObjectMap { | |||
jsrefcount nrefs; /* count of all referencing objects */ | jsrefcount nrefs; /* count of all referencing objects */ | |||
JSObjectOps *ops; /* high level object operation vtable */ | JSObjectOps *ops; /* high level object operation vtable */ | |||
uint32 nslots; /* length of obj->slots vector */ | uint32 nslots; /* length of obj->slots vector */ | |||
uint32 freeslot; /* index of next free obj->slots element */ | uint32 freeslot; /* index of next free obj->slots element */ | |||
}; | }; | |||
/* Shorthand macros for frequently-made calls. */ | /* Shorthand macros for frequently-made calls. */ | |||
#if defined JS_THREADSAFE && defined DEBUG | ||||
#define OBJ_LOOKUP_PROPERTY(cx,obj,id,objp,propp) | ||||
\ | ||||
(obj)->map->ops->lookupProperty(cx,obj,id,objp,propp,__FILE__,__LINE__) | ||||
#else | ||||
#define OBJ_LOOKUP_PROPERTY(cx,obj,id,objp,propp) \ | #define OBJ_LOOKUP_PROPERTY(cx,obj,id,objp,propp) \ | |||
(obj)->map->ops->lookupProperty(cx,obj,id,objp,propp) | (obj)->map->ops->lookupProperty(cx,obj,id,objp,propp) | |||
#endif | ||||
#define OBJ_DEFINE_PROPERTY(cx,obj,id,value,getter,setter,attrs,propp) \ | #define OBJ_DEFINE_PROPERTY(cx,obj,id,value,getter,setter,attrs,propp) \ | |||
(obj)->map->ops->defineProperty(cx,obj,id,value,getter,setter,attrs,pro pp) | (obj)->map->ops->defineProperty(cx,obj,id,value,getter,setter,attrs,pro pp) | |||
#define OBJ_GET_PROPERTY(cx,obj,id,vp) \ | #define OBJ_GET_PROPERTY(cx,obj,id,vp) \ | |||
(obj)->map->ops->getProperty(cx,obj,id,vp) | (obj)->map->ops->getProperty(cx,obj,id,vp) | |||
#define OBJ_SET_PROPERTY(cx,obj,id,vp) \ | #define OBJ_SET_PROPERTY(cx,obj,id,vp) \ | |||
(obj)->map->ops->setProperty(cx,obj,id,vp) | (obj)->map->ops->setProperty(cx,obj,id,vp) | |||
#define OBJ_GET_ATTRIBUTES(cx,obj,id,prop,attrsp) \ | #define OBJ_GET_ATTRIBUTES(cx,obj,id,prop,attrsp) \ | |||
(obj)->map->ops->getAttributes(cx,obj,id,prop,attrsp) | (obj)->map->ops->getAttributes(cx,obj,id,prop,attrsp) | |||
#define OBJ_SET_ATTRIBUTES(cx,obj,id,prop,attrsp) \ | #define OBJ_SET_ATTRIBUTES(cx,obj,id,prop,attrsp) \ | |||
(obj)->map->ops->setAttributes(cx,obj,id,prop,attrsp) | (obj)->map->ops->setAttributes(cx,obj,id,prop,attrsp) | |||
skipping to change at line 108 | skipping to change at line 104 | |||
: (void)0) | : (void)0) | |||
#define OBJ_GET_REQUIRED_SLOT(cx,obj,slot) \ | #define OBJ_GET_REQUIRED_SLOT(cx,obj,slot) \ | |||
((obj)->map->ops->getRequiredSlot \ | ((obj)->map->ops->getRequiredSlot \ | |||
? (obj)->map->ops->getRequiredSlot(cx, obj, slot) \ | ? (obj)->map->ops->getRequiredSlot(cx, obj, slot) \ | |||
: JSVAL_VOID) | : JSVAL_VOID) | |||
#define OBJ_SET_REQUIRED_SLOT(cx,obj,slot,v) \ | #define OBJ_SET_REQUIRED_SLOT(cx,obj,slot,v) \ | |||
((obj)->map->ops->setRequiredSlot \ | ((obj)->map->ops->setRequiredSlot \ | |||
? (obj)->map->ops->setRequiredSlot(cx, obj, slot, v) \ | ? (obj)->map->ops->setRequiredSlot(cx, obj, slot, v) \ | |||
: JS_TRUE) | : JS_TRUE) | |||
#define OBJ_TO_INNER_OBJECT(cx,obj) | ||||
\ | ||||
JS_BEGIN_MACRO | ||||
\ | ||||
JSClass *clasp_ = OBJ_GET_CLASS(cx, obj); | ||||
\ | ||||
if (clasp_->flags & JSCLASS_IS_EXTENDED) { | ||||
\ | ||||
JSExtendedClass *xclasp_ = (JSExtendedClass*)clasp_; | ||||
\ | ||||
if (xclasp_->innerObject) | ||||
\ | ||||
obj = xclasp_->innerObject(cx, obj); | ||||
\ | ||||
} | ||||
\ | ||||
JS_END_MACRO | ||||
/* | /* | |||
* In the original JS engine design, obj->slots pointed to a vector of leng th | * In the original JS engine design, obj->slots pointed to a vector of leng th | |||
* JS_INITIAL_NSLOTS words if obj->map was shared with a prototype object, | * JS_INITIAL_NSLOTS words if obj->map was shared with a prototype object, | |||
* else of length obj->map->nslots. With the advent of JS_GetReservedSlot, | * else of length obj->map->nslots. With the advent of JS_GetReservedSlot, | |||
* JS_SetReservedSlot, and JSCLASS_HAS_RESERVED_SLOTS (see jsapi.h), the si ze | * JS_SetReservedSlot, and JSCLASS_HAS_RESERVED_SLOTS (see jsapi.h), the si ze | |||
* of the minimum length slots vector in the case where map is shared canno t | * of the minimum length slots vector in the case where map is shared canno t | |||
* be constant. This length starts at JS_INITIAL_NSLOTS, but may advance t o | * be constant. This length starts at JS_INITIAL_NSLOTS, but may advance t o | |||
* include all the reserved slots. | * include all the reserved slots. | |||
* | * | |||
* Therefore slots must be self-describing. Rather than tag its low order bit | * Therefore slots must be self-describing. Rather than tag its low order bit | |||
skipping to change at line 233 | skipping to change at line 239 | |||
#define MAP_IS_NATIVE(map) \ | #define MAP_IS_NATIVE(map) \ | |||
((map)->ops == &js_ObjectOps || \ | ((map)->ops == &js_ObjectOps || \ | |||
((map)->ops && (map)->ops->newObjectMap == js_ObjectOps.newObjectMap)) | ((map)->ops && (map)->ops->newObjectMap == js_ObjectOps.newObjectMap)) | |||
#define OBJ_IS_NATIVE(obj) MAP_IS_NATIVE((obj)->map) | #define OBJ_IS_NATIVE(obj) MAP_IS_NATIVE((obj)->map) | |||
extern JS_FRIEND_DATA(JSObjectOps) js_ObjectOps; | extern JS_FRIEND_DATA(JSObjectOps) js_ObjectOps; | |||
extern JS_FRIEND_DATA(JSObjectOps) js_WithObjectOps; | extern JS_FRIEND_DATA(JSObjectOps) js_WithObjectOps; | |||
extern JSClass js_ObjectClass; | extern JSClass js_ObjectClass; | |||
extern JSClass js_WithClass; | extern JSClass js_WithClass; | |||
extern JSClass js_BlockClass; | ||||
/* | ||||
* Block scope object macros. The slots reserved by js_BlockClass are: | ||||
* | ||||
* JSSLOT_PRIVATE JSStackFrame * active frame pointer or null | ||||
* JSSLOT_BLOCK_DEPTH int depth of block slots in frame | ||||
* | ||||
* After JSSLOT_BLOCK_DEPTH come one or more slots for the block locals. | ||||
* OBJ_BLOCK_COUNT depends on this arrangement. | ||||
* | ||||
* A With object is like a Block object, in that both have one reserved slo | ||||
t | ||||
* telling the stack depth of the relevant slots (the slot whose value is t | ||||
he | ||||
* object named in the with statement, the slots containing the block's loc | ||||
al | ||||
* variables); and both have a private slot referring to the JSStackFrame i | ||||
n | ||||
* whose activation they were created (or null if the with or block object | ||||
* outlives the frame). | ||||
*/ | ||||
#define JSSLOT_BLOCK_DEPTH (JSSLOT_PRIVATE + 1) | ||||
#define OBJ_BLOCK_COUNT(cx,obj) \ | ||||
((obj)->map->freeslot - (JSSLOT_BLOCK_DEPTH + 1)) | ||||
#define OBJ_BLOCK_DEPTH(cx,obj) \ | ||||
JSVAL_TO_INT(OBJ_GET_SLOT(cx, obj, JSSLOT_BLOCK_DEPTH)) | ||||
#define OBJ_SET_BLOCK_DEPTH(cx,obj,depth) \ | ||||
OBJ_SET_SLOT(cx, obj, JSSLOT_BLOCK_DEPTH, INT_TO_JSVAL(depth)) | ||||
/* | ||||
* To make sure this slot is well-defined, always call js_NewWithObject to | ||||
* create a With object, don't call js_NewObject directly. When creating a | ||||
* With object that does not correspond to a stack slot, pass -1 for depth. | ||||
* | ||||
* When popping the stack across this object's "with" statement, client cod | ||||
e | ||||
* must call JS_SetPrivate(cx, withobj, NULL). | ||||
*/ | ||||
extern JSObject * | ||||
js_NewWithObject(JSContext *cx, JSObject *proto, JSObject *parent, jsint de | ||||
pth); | ||||
/* | ||||
* Create a new block scope object not linked to any proto or parent object | ||||
. | ||||
* Blocks are created by the compiler to reify let blocks and comprehension | ||||
s. | ||||
* Only when dynamic scope is captured do they need to be cloned and splice | ||||
d | ||||
* into an active scope chain. | ||||
*/ | ||||
extern JSObject * | ||||
js_NewBlockObject(JSContext *cx); | ||||
extern JSObject * | ||||
js_CloneBlockObject(JSContext *cx, JSObject *proto, JSObject *parent, | ||||
JSStackFrame *fp); | ||||
extern JSBool | ||||
js_PutBlockObject(JSContext *cx, JSObject *obj); | ||||
struct JSSharpObjectMap { | struct JSSharpObjectMap { | |||
jsrefcount depth; | jsrefcount depth; | |||
jsatomid sharpgen; | jsatomid sharpgen; | |||
JSHashTable *table; | JSHashTable *table; | |||
}; | }; | |||
#define SHARP_BIT ((jsatomid) 1) | #define SHARP_BIT ((jsatomid) 1) | |||
#define BUSY_BIT ((jsatomid) 2) | #define BUSY_BIT ((jsatomid) 2) | |||
#define SHARP_ID_SHIFT 2 | #define SHARP_ID_SHIFT 2 | |||
#define IS_SHARP(he) ((jsatomid)(he)->value & SHARP_BIT) | #define IS_SHARP(he) (JS_PTR_TO_UINT32((he)->value) & SHARP_BIT) | |||
#define MAKE_SHARP(he) ((he)->value = (void*)((jsatomid)(he)->value|SHARP_ | #define MAKE_SHARP(he) ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((h | |||
BIT)) | e)->value)|SHARP_BIT)) | |||
#define IS_BUSY(he) ((jsatomid)(he)->value & BUSY_BIT) | #define IS_BUSY(he) (JS_PTR_TO_UINT32((he)->value) & BUSY_BIT) | |||
#define MAKE_BUSY(he) ((he)->value = (void*)((jsatomid)(he)->value|BUSY_B | #define MAKE_BUSY(he) ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((h | |||
IT)) | e)->value)|BUSY_BIT)) | |||
#define CLEAR_BUSY(he) ((he)->value = (void*)((jsatomid)(he)->value&~BUSY_ | #define CLEAR_BUSY(he) ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((h | |||
BIT)) | e)->value)&~BUSY_BIT)) | |||
extern JSHashEntry * | extern JSHashEntry * | |||
js_EnterSharpObject(JSContext *cx, JSObject *obj, JSIdArray **idap, | js_EnterSharpObject(JSContext *cx, JSObject *obj, JSIdArray **idap, | |||
jschar **sp); | jschar **sp); | |||
extern void | extern void | |||
js_LeaveSharpObject(JSContext *cx, JSIdArray **idap); | js_LeaveSharpObject(JSContext *cx, JSIdArray **idap); | |||
/* | ||||
* Mark objects stored in map if GC happens between js_EnterSharpObject | ||||
* and js_LeaveSharpObject. GC calls this when map->depth > 0. | ||||
*/ | ||||
extern void | ||||
js_GCMarkSharpMap(JSContext *cx, JSSharpObjectMap *map); | ||||
extern JSBool | extern JSBool | |||
js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, | js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, | |||
jsval *rval); | jsval *rval); | |||
extern JSBool | extern JSBool | |||
js_obj_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, | js_obj_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, | |||
jsval *rval); | jsval *rval); | |||
extern JSBool | ||||
js_HasOwnPropertyHelper(JSContext *cx, JSObject *obj, JSLookupPropOp lookup | ||||
, | ||||
uintN argc, jsval *argv, jsval *rval); | ||||
extern JSObject* | ||||
js_InitBlockClass(JSContext *cx, JSObject* obj); | ||||
extern JSObject * | extern JSObject * | |||
js_InitObjectClass(JSContext *cx, JSObject *obj); | js_InitObjectClass(JSContext *cx, JSObject *obj); | |||
/* Select Object.prototype method names shared between jsapi.c and jsobj.c. */ | /* Select Object.prototype method names shared between jsapi.c and jsobj.c. */ | |||
extern const char js_watch_str[]; | extern const char js_watch_str[]; | |||
extern const char js_unwatch_str[]; | extern const char js_unwatch_str[]; | |||
extern const char js_hasOwnProperty_str[]; | extern const char js_hasOwnProperty_str[]; | |||
extern const char js_isPrototypeOf_str[]; | extern const char js_isPrototypeOf_str[]; | |||
extern const char js_propertyIsEnumerable_str[]; | extern const char js_propertyIsEnumerable_str[]; | |||
extern const char js_defineGetter_str[]; | extern const char js_defineGetter_str[]; | |||
extern const char js_defineSetter_str[]; | extern const char js_defineSetter_str[]; | |||
extern const char js_lookupGetter_str[]; | extern const char js_lookupGetter_str[]; | |||
extern const char js_lookupSetter_str[]; | extern const char js_lookupSetter_str[]; | |||
extern void | extern void | |||
js_InitObjectMap(JSObjectMap *map, jsrefcount nrefs, JSObjectOps *ops, | js_InitObjectMap(JSObjectMap *map, jsrefcount nrefs, JSObjectOps *ops, | |||
JSClass *clasp); | JSClass *clasp); | |||
extern JSObjectMap * | extern JSObjectMap * | |||
js_NewObjectMap(JSContext *cx, jsrefcount nrefs, JSObjectOps *ops, | js_NewObjectMap(JSContext *cx, jsrefcount nrefs, JSObjectOps *ops, | |||
JSClass *clasp, JSObject *obj); | JSClass *clasp, JSObject *obj); | |||
extern void | extern void | |||
js_DestroyObjectMap(JSContext *cx, JSObjectMap *map); | js_DestroyObjectMap(JSContext *cx, JSObjectMap *map); | |||
extern JSObjectMap * | extern JSObjectMap * | |||
js_HoldObjectMap(JSContext *cx, JSObjectMap *map); | js_HoldObjectMap(JSContext *cx, JSObjectMap *map); | |||
extern JSObjectMap * | extern JSObjectMap * | |||
js_DropObjectMap(JSContext *cx, JSObjectMap *map, JSObject *obj); | js_DropObjectMap(JSContext *cx, JSObjectMap *map, JSObject *obj); | |||
extern JSBool | ||||
js_GetClassId(JSContext *cx, JSClass *clasp, jsid *idp); | ||||
extern JSObject * | extern JSObject * | |||
js_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *pare nt); | js_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *pare nt); | |||
/* | ||||
* Fast access to immutable standard objects (constructors and prototypes). | ||||
*/ | ||||
extern JSBool | ||||
js_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, | ||||
JSObject **objp); | ||||
extern JSBool | ||||
js_SetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject *c | ||||
obj); | ||||
extern JSBool | ||||
js_FindClassObject(JSContext *cx, JSObject *start, jsid id, jsval *vp); | ||||
extern JSObject * | extern JSObject * | |||
js_ConstructObject(JSContext *cx, JSClass *clasp, JSObject *proto, | js_ConstructObject(JSContext *cx, JSClass *clasp, JSObject *proto, | |||
JSObject *parent, uintN argc, jsval *argv); | JSObject *parent, uintN argc, jsval *argv); | |||
extern void | extern void | |||
js_FinalizeObject(JSContext *cx, JSObject *obj); | js_FinalizeObject(JSContext *cx, JSObject *obj); | |||
extern JSBool | extern JSBool | |||
js_AllocSlot(JSContext *cx, JSObject *obj, uint32 *slotp); | js_AllocSlot(JSContext *cx, JSObject *obj, uint32 *slotp); | |||
extern void | extern void | |||
js_FreeSlot(JSContext *cx, JSObject *obj, uint32 slot); | js_FreeSlot(JSContext *cx, JSObject *obj, uint32 slot); | |||
/* | /* | |||
* Native property add and lookup variants that hide id in the hidden atom | ||||
* subspace, so as to avoid collisions between internal properties such as | ||||
* formal arguments and local variables in function objects, and externally | ||||
* set properties with the same ids. | ||||
*/ | ||||
extern JSScopeProperty * | ||||
js_AddHiddenProperty(JSContext *cx, JSObject *obj, jsid id, | ||||
JSPropertyOp getter, JSPropertyOp setter, uint32 slot, | ||||
uintN attrs, uintN flags, intN shortid); | ||||
extern JSBool | ||||
js_LookupHiddenProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **o | ||||
bjp, | ||||
JSProperty **propp); | ||||
/* | ||||
* Find or create a property named by id in obj's scope, with the given get ter | * Find or create a property named by id in obj's scope, with the given get ter | |||
* and setter, slot, attributes, and other members. | * and setter, slot, attributes, and other members. | |||
*/ | */ | |||
extern JSScopeProperty * | extern JSScopeProperty * | |||
js_AddNativeProperty(JSContext *cx, JSObject *obj, jsid id, | js_AddNativeProperty(JSContext *cx, JSObject *obj, jsid id, | |||
JSPropertyOp getter, JSPropertyOp setter, uint32 slot, | JSPropertyOp getter, JSPropertyOp setter, uint32 slot, | |||
uintN attrs, uintN flags, intN shortid); | uintN attrs, uintN flags, intN shortid); | |||
/* | /* | |||
* Change sprop to have the given attrs, getter, and setter in scope, morph ing | * Change sprop to have the given attrs, getter, and setter in scope, morph ing | |||
skipping to change at line 339 | skipping to change at line 443 | |||
/* | /* | |||
* On error, return false. On success, if propp is non-null, return true w ith | * On error, return false. On success, if propp is non-null, return true w ith | |||
* obj locked and with a held property in *propp; if propp is null, return true | * obj locked and with a held property in *propp; if propp is null, return true | |||
* but release obj's lock first. Therefore all callers who pass non-null p ropp | * but release obj's lock first. Therefore all callers who pass non-null p ropp | |||
* result parameters must later call OBJ_DROP_PROPERTY(cx, obj, *propp) bot h to | * result parameters must later call OBJ_DROP_PROPERTY(cx, obj, *propp) bot h to | |||
* drop the held property, and to release the lock on obj. | * drop the held property, and to release the lock on obj. | |||
*/ | */ | |||
extern JSBool | extern JSBool | |||
js_DefineProperty(JSContext *cx, JSObject *obj, jsid id, jsval value, | js_DefineProperty(JSContext *cx, JSObject *obj, jsid id, jsval value, | |||
JSPropertyOp getter, JSPropertyOp setter, uintN attrs, | JSPropertyOp getter, JSPropertyOp setter, uintN attrs, | |||
JSProperty **propp); | JSProperty **propp); | |||
extern JSBool | extern JSBool | |||
js_DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, jsval value, | js_DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, jsval value, | |||
JSPropertyOp getter, JSPropertyOp setter, uintN att rs, | JSPropertyOp getter, JSPropertyOp setter, uintN att rs, | |||
uintN flags, intN shortid, JSProperty **propp); | uintN flags, intN shortid, JSProperty **propp); | |||
/* | /* | |||
* Unlike js_DefineProperty, propp must be non-null. On success, and if id was | * Unlike js_DefineProperty, propp must be non-null. On success, and if id was | |||
* found, return true with *objp non-null and locked, and with a held prope rty | * found, return true with *objp non-null and locked, and with a held prope rty | |||
* stored in *propp. If successful but id was not found, return true with both | * stored in *propp. If successful but id was not found, return true with both | |||
* *objp and *propp null. Therefore all callers who receive a non-null *pr opp | * *objp and *propp null. Therefore all callers who receive a non-null *pr opp | |||
* must later call OBJ_DROP_PROPERTY(cx, *objp, *propp). | * must later call OBJ_DROP_PROPERTY(cx, *objp, *propp). | |||
*/ | */ | |||
#if defined JS_THREADSAFE && defined DEBUG | ||||
extern JS_FRIEND_API(JSBool) | ||||
_js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, | ||||
JSProperty **propp, const char *file, uintN line); | ||||
#define js_LookupProperty(cx,obj,id,objp,propp) \ | ||||
_js_LookupProperty(cx,obj,id,objp,propp,__FILE__,__LINE__) | ||||
#else | ||||
extern JS_FRIEND_API(JSBool) | extern JS_FRIEND_API(JSBool) | |||
js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, | js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, | |||
JSProperty **propp); | JSProperty **propp); | |||
#endif | ||||
/* | /* | |||
* Specialized subroutine that allows caller to preset JSRESOLVE_* flags. | * Specialized subroutine that allows caller to preset JSRESOLVE_* flags. | |||
* JSRESOLVE_HIDDEN flags hidden function param/local name lookups, just fo | ||||
r | ||||
* internal use by fun_resolve and similar built-ins. | ||||
*/ | */ | |||
extern JSBool | extern JSBool | |||
js_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, uintN fla gs, | js_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, uintN fla gs, | |||
JSObject **objp, JSProperty **propp | JSObject **objp, JSProperty **propp); | |||
#if defined JS_THREADSAFE && defined DEBUG | ||||
, const char *file, uintN line | #define JSRESOLVE_HIDDEN 0x8000 | |||
#endif | ||||
); | ||||
extern JS_FRIEND_API(JSBool) | extern JS_FRIEND_API(JSBool) | |||
js_FindProperty(JSContext *cx, jsid id, JSObject **objp, JSObject **pobjp, | js_FindProperty(JSContext *cx, jsid id, JSObject **objp, JSObject **pobjp, | |||
JSProperty **propp); | JSProperty **propp); | |||
extern JSObject * | extern JSObject * | |||
js_FindIdentifierBase(JSContext *cx, jsid id); | js_FindIdentifierBase(JSContext *cx, jsid id); | |||
extern JSObject * | extern JSObject * | |||
js_FindVariableScope(JSContext *cx, JSFunction **funp); | js_FindVariableScope(JSContext *cx, JSFunction **funp); | |||
/* | ||||
* NB: js_NativeGet and js_NativeSet are called with the scope containing s | ||||
prop | ||||
* (pobj's scope for Get, obj's for Set) locked, and on successful return, | ||||
that | ||||
* scope is again locked. But on failure, both functions return false with | ||||
the | ||||
* scope containing sprop unlocked. | ||||
*/ | ||||
extern JSBool | ||||
js_NativeGet(JSContext *cx, JSObject *obj, JSObject *pobj, | ||||
JSScopeProperty *sprop, jsval *vp); | ||||
extern JSBool | ||||
js_NativeSet(JSContext *cx, JSObject *obj, JSScopeProperty *sprop, jsval *v | ||||
p); | ||||
extern JSBool | extern JSBool | |||
js_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp); | js_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp); | |||
extern JSBool | extern JSBool | |||
js_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp); | js_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp); | |||
extern JSBool | extern JSBool | |||
js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop, | js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop, | |||
uintN *attrsp); | uintN *attrsp); | |||
extern JSBool | extern JSBool | |||
js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop, | js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop, | |||
uintN *attrsp); | uintN *attrsp); | |||
extern JSBool | extern JSBool | |||
js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, jsval *rval); | js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, jsval *rval); | |||
extern JSBool | extern JSBool | |||
js_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp); | js_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp); | |||
extern JSIdArray * | extern JSIdArray * | |||
js_NewIdArray(JSContext *cx, jsint length); | js_NewIdArray(JSContext *cx, jsint length); | |||
/* | ||||
* Unlike realloc(3), this function frees ida on failure. | ||||
*/ | ||||
extern JSIdArray * | extern JSIdArray * | |||
js_GrowIdArray(JSContext *cx, JSIdArray *ida, jsint length); | js_SetIdArrayLength(JSContext *cx, JSIdArray *ida, jsint length); | |||
extern JSBool | extern JSBool | |||
js_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, | js_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, | |||
jsval *statep, jsid *idp); | jsval *statep, jsid *idp); | |||
extern void | ||||
js_MarkNativeIteratorStates(JSContext *cx); | ||||
extern JSBool | extern JSBool | |||
js_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, | js_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, | |||
jsval *vp, uintN *attrsp); | jsval *vp, uintN *attrsp); | |||
extern JSBool | extern JSBool | |||
js_Call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) ; | js_Call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) ; | |||
extern JSBool | extern JSBool | |||
js_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, | js_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, | |||
jsval *rval); | jsval *rval); | |||
extern JSBool | extern JSBool | |||
js_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); | js_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); | |||
extern JSBool | extern JSBool | |||
js_SetProtoOrParent(JSContext *cx, JSObject *obj, uint32 slot, JSObject *po bj); | js_SetProtoOrParent(JSContext *cx, JSObject *obj, uint32 slot, JSObject *po bj); | |||
extern JSBool | extern JSBool | |||
js_IsDelegate(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); | js_IsDelegate(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); | |||
extern JSBool | extern JSBool | |||
js_GetClassPrototype(JSContext *cx, const char *name, JSObject **protop); | js_GetClassPrototype(JSContext *cx, JSObject *scope, jsid id, | |||
JSObject **protop); | ||||
extern JSBool | extern JSBool | |||
js_SetClassPrototype(JSContext *cx, JSObject *ctor, JSObject *proto, | js_SetClassPrototype(JSContext *cx, JSObject *ctor, JSObject *proto, | |||
uintN attrs); | uintN attrs); | |||
extern JSBool | extern JSBool | |||
js_ValueToObject(JSContext *cx, jsval v, JSObject **objp); | js_ValueToObject(JSContext *cx, jsval v, JSObject **objp); | |||
extern JSObject * | extern JSObject * | |||
js_ValueToNonNullObject(JSContext *cx, jsval v); | js_ValueToNonNullObject(JSContext *cx, jsval v); | |||
extern JSBool | extern JSBool | |||
js_TryValueOf(JSContext *cx, JSObject *obj, JSType type, jsval *rval); | js_TryValueOf(JSContext *cx, JSObject *obj, JSType type, jsval *rval); | |||
extern JSBool | extern JSBool | |||
js_TryMethod(JSContext *cx, JSObject *obj, JSAtom *atom, | js_TryMethod(JSContext *cx, JSObject *obj, JSAtom *atom, | |||
uintN argc, jsval *argv, jsval *rval); | uintN argc, jsval *argv, jsval *rval); | |||
extern JSBool | extern JSBool | |||
js_XDRObject(JSXDRState *xdr, JSObject **objp); | js_XDRObject(JSXDRState *xdr, JSObject **objp); | |||
extern uint32 | extern uint32 | |||
js_Mark(JSContext *cx, JSObject *obj, void *arg); | js_Mark(JSContext *cx, JSObject *obj, void *arg); | |||
extern void | extern void | |||
js_Clear(JSContext *cx, JSObject *obj); | js_Clear(JSContext *cx, JSObject *obj); | |||
extern jsval | extern jsval | |||
js_GetRequiredSlot(JSContext *cx, JSObject *obj, uint32 slot); | js_GetRequiredSlot(JSContext *cx, JSObject *obj, uint32 slot); | |||
extern JSBool | extern JSBool | |||
js_SetRequiredSlot(JSContext *cx, JSObject *obj, uint32 slot, jsval v); | js_SetRequiredSlot(JSContext *cx, JSObject *obj, uint32 slot, jsval v); | |||
extern JSObject * | ||||
js_CheckScopeChainValidity(JSContext *cx, JSObject *scopeobj, const char *c | ||||
aller); | ||||
extern JSBool | ||||
js_CheckPrincipalsAccess(JSContext *cx, JSObject *scopeobj, | ||||
JSPrincipals *principals, JSAtom *caller); | ||||
JS_END_EXTERN_C | JS_END_EXTERN_C | |||
#endif /* jsobj_h___ */ | #endif /* jsobj_h___ */ | |||
End of changes. 33 change blocks. | ||||
46 lines changed or deleted | 192 lines changed or added | |||
jsopcode.h | jsopcode.h | |||
---|---|---|---|---|
skipping to change at line 48 | skipping to change at line 48 | |||
* ***** END LICENSE BLOCK ***** */ | * ***** END LICENSE BLOCK ***** */ | |||
#ifndef jsopcode_h___ | #ifndef jsopcode_h___ | |||
#define jsopcode_h___ | #define jsopcode_h___ | |||
/* | /* | |||
* JS bytecode definitions. | * JS bytecode definitions. | |||
*/ | */ | |||
#include <stddef.h> | #include <stddef.h> | |||
#include "jsprvtd.h" | #include "jsprvtd.h" | |||
#include "jspubtd.h" | #include "jspubtd.h" | |||
#include "jsutil.h" | ||||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
/* | /* | |||
* JS operation bytecodes. | * JS operation bytecodes. | |||
*/ | */ | |||
typedef enum JSOp { | typedef enum JSOp { | |||
#define OPDEF(op,val,name,token,length,nuses,ndefs,prec,format) \ | #define OPDEF(op,val,name,token,length,nuses,ndefs,prec,format) \ | |||
op = val, | op = val, | |||
#include "jsopcode.tbl" | #include "jsopcode.tbl" | |||
#undef OPDEF | #undef OPDEF | |||
JSOP_LIMIT | JSOP_LIMIT | |||
} JSOp; | } JSOp; | |||
typedef enum JSOpLength { | ||||
#define OPDEF(op,val,name,token,length,nuses,ndefs,prec,format) \ | ||||
op##_LENGTH = length, | ||||
#include "jsopcode.tbl" | ||||
#undef OPDEF | ||||
JSOP_LIMIT_LENGTH | ||||
} JSOpLength; | ||||
/* | /* | |||
* JS bytecode formats. | * JS bytecode formats. | |||
*/ | */ | |||
#define JOF_BYTE 0 /* single bytecode, no immediates */ | #define JOF_BYTE 0 /* single bytecode, no immediates */ | |||
#define JOF_JUMP 1 /* signed 16-bit jump offset immediate */ | #define JOF_JUMP 1 /* signed 16-bit jump offset immediate */ | |||
#define JOF_CONST 2 /* unsigned 16-bit constant pool index */ | #define JOF_CONST 2 /* unsigned 16-bit constant pool index */ | |||
#define JOF_UINT16 3 /* unsigned 16-bit immediate operand */ | #define JOF_UINT16 3 /* unsigned 16-bit immediate operand */ | |||
#define JOF_TABLESWITCH 4 /* table switch */ | #define JOF_TABLESWITCH 4 /* table switch */ | |||
#define JOF_LOOKUPSWITCH 5 /* lookup switch */ | #define JOF_LOOKUPSWITCH 5 /* lookup switch */ | |||
#define JOF_QARG 6 /* quickened get/set function argument op s */ | #define JOF_QARG 6 /* quickened get/set function argument op s */ | |||
#define JOF_QVAR 7 /* quickened get/set local variable ops * / | #define JOF_QVAR 7 /* quickened get/set local variable ops * / | |||
#define JOF_DEFLOCALVAR 8 /* define local var with initial value */ | #define JOF_INDEXCONST 8 /* uint16 slot index + constant pool inde x */ | |||
#define JOF_JUMPX 9 /* signed 32-bit jump offset immediate */ | #define JOF_JUMPX 9 /* signed 32-bit jump offset immediate */ | |||
#define JOF_TABLESWITCHX 10 /* extended (32-bit offset) table switch */ | #define JOF_TABLESWITCHX 10 /* extended (32-bit offset) table switch */ | |||
#define JOF_LOOKUPSWITCHX 11 /* extended (32-bit offset) lookup switch */ | #define JOF_LOOKUPSWITCHX 11 /* extended (32-bit offset) lookup switch */ | |||
#define JOF_UINT24 12 /* extended unsigned 24-bit literal (inde | ||||
x) */ | ||||
#define JOF_LITOPX 13 /* JOF_UINT24 followed by op being extend | ||||
ed, | ||||
where op if JOF_CONST has no unsigned | ||||
16- | ||||
bit immediate operand */ | ||||
#define JOF_LOCAL 14 /* block-local operand stack variable */ | ||||
#define JOF_TYPEMASK 0x000f /* mask for above immediate types */ | #define JOF_TYPEMASK 0x000f /* mask for above immediate types */ | |||
#define JOF_NAME 0x0010 /* name operation */ | #define JOF_NAME 0x0010 /* name operation */ | |||
#define JOF_PROP 0x0020 /* obj.prop operation */ | #define JOF_PROP 0x0020 /* obj.prop operation */ | |||
#define JOF_ELEM 0x0030 /* obj[index] operation */ | #define JOF_ELEM 0x0030 /* obj[index] operation */ | |||
#define JOF_MODEMASK 0x0030 /* mask for above addressing modes */ | #define JOF_MODEMASK 0x0030 /* mask for above addressing modes */ | |||
#define JOF_SET 0x0040 /* set (i.e., assignment) operation */ | #define JOF_SET 0x0040 /* set (i.e., assignment) operation */ | |||
#define JOF_DEL 0x0080 /* delete operation */ | #define JOF_DEL 0x0080 /* delete operation */ | |||
#define JOF_DEC 0x0100 /* decrement (--, not ++) opcode */ | #define JOF_DEC 0x0100 /* decrement (--, not ++) opcode */ | |||
#define JOF_INC 0x0200 /* increment (++, not --) opcode */ | #define JOF_INC 0x0200 /* increment (++, not --) opcode */ | |||
#define JOF_INCDEC 0x0300 /* increment or decrement opcode */ | #define JOF_INCDEC 0x0300 /* increment or decrement opcode */ | |||
#define JOF_POST 0x0400 /* postorder increment or decrement */ | #define JOF_POST 0x0400 /* postorder increment or decrement */ | |||
#define JOF_IMPORT 0x0800 /* import property op */ | #define JOF_IMPORT 0x0800 /* import property op */ | |||
#define JOF_FOR 0x1000 /* for-in property op */ | #define JOF_FOR 0x1000 /* for-in property op */ | |||
#define JOF_ASSIGNING JOF_SET /* hint for JSClass.resolve, used for ops | #define JOF_ASSIGNING JOF_SET /* hint for JSClass.resolve, used for ops | |||
that do simplex assignment */ | that do simplex assignment */ | |||
#define JOF_DETECTING 0x2000 /* object detection flag for JSNewResolve Op */ | #define JOF_DETECTING 0x2000 /* object detection flag for JSNewResolve Op */ | |||
#define JOF_BACKPATCH 0x4000 /* backpatch placeholder during codegen * / | #define JOF_BACKPATCH 0x4000 /* backpatch placeholder during codegen * / | |||
#define JOF_LEFTASSOC 0x8000 /* left-associative operator */ | #define JOF_LEFTASSOC 0x8000 /* left-associative operator */ | |||
#define JOF_DECLARING 0x10000 /* var, const, or function declaration op */ | #define JOF_DECLARING 0x10000 /* var, const, or function declaration op */ | |||
#define JOF_XMLNAME 0x20000 /* XML name: *, a::b, @a, @a::b, etc. */ | ||||
#define JOF_TYPE_IS_EXTENDED_JUMP(t) \ | #define JOF_TYPE_IS_EXTENDED_JUMP(t) \ | |||
((unsigned)((t) - JOF_JUMPX) <= (unsigned)(JOF_LOOKUPSWITCHX - JOF_JUMP X)) | ((unsigned)((t) - JOF_JUMPX) <= (unsigned)(JOF_LOOKUPSWITCHX - JOF_JUMP X)) | |||
/* | /* | |||
* Immediate operand getters, setters, and bounds. | * Immediate operand getters, setters, and bounds. | |||
*/ | */ | |||
/* Short (2-byte signed offset) relative jump macros. */ | /* Short (2-byte signed offset) relative jump macros. */ | |||
#define JUMP_OFFSET_LEN 2 | #define JUMP_OFFSET_LEN 2 | |||
#define JUMP_OFFSET_HI(off) ((jsbytecode)((off) >> 8)) | #define JUMP_OFFSET_HI(off) ((jsbytecode)((off) >> 8)) | |||
#define JUMP_OFFSET_LO(off) ((jsbytecode)(off)) | #define JUMP_OFFSET_LO(off) ((jsbytecode)(off)) | |||
#define GET_JUMP_OFFSET(pc) ((int16)(((pc)[1] << 8) | (pc)[2])) | #define GET_JUMP_OFFSET(pc) ((int16)(((pc)[1] << 8) | (pc)[2])) | |||
#define SET_JUMP_OFFSET(pc,off) ((pc)[1] = JUMP_OFFSET_HI(off), \ | #define SET_JUMP_OFFSET(pc,off) ((pc)[1] = JUMP_OFFSET_HI(off), \ | |||
(pc)[2] = JUMP_OFFSET_LO(off)) | (pc)[2] = JUMP_OFFSET_LO(off)) | |||
#define JUMP_OFFSET_MIN ((int16)0x8000) | #define JUMP_OFFSET_MIN ((int16)0x8000) | |||
#define JUMP_OFFSET_MAX ((int16)0x7fff) | #define JUMP_OFFSET_MAX ((int16)0x7fff) | |||
/* | /* | |||
* When a short jump won't hold a relative offset, its 2-byte immediate off set | * When a short jump won't hold a relative offset, its 2-byte immediate off set | |||
* operand is an unsigned index of a span-dependency record, maintained unt il | * operand is an unsigned index of a span-dependency record, maintained unt il | |||
* code generation finishes -- after which some (but we hope not nearly all ) | * code generation finishes -- after which some (but we hope not nearly all ) | |||
* span-dependent jumps must be extended (see OptimizeSpanDeps in jsemit.c) . | * span-dependent jumps must be extended (see OptimizeSpanDeps in jsemit.c) . | |||
* | * | |||
* If the span-dependency record index overflows SPANDEP_INDEX_MAX, the jum p | * If the span-dependency record index overflows SPANDEP_INDEX_MAX, the jum p | |||
* offset will contain SPANDEP_INDEX_HUGE, indicating that the record must be | * offset will contain SPANDEP_INDEX_HUGE, indicating that the record must be | |||
* found (via binary search) by its "before span-dependency optimization" p c | * found (via binary search) by its "before span-dependency optimization" p c | |||
* offset (from script main entry point). | * offset (from script main entry point). | |||
*/ | */ | |||
#define GET_SPANDEP_INDEX(pc) ((uint16)(((pc)[1] << 8) | (pc)[2])) | #define GET_SPANDEP_INDEX(pc) ((uint16)(((pc)[1] << 8) | (pc)[2])) | |||
#define SET_SPANDEP_INDEX(pc,i) ((pc)[1] = JUMP_OFFSET_HI(i), \ | #define SET_SPANDEP_INDEX(pc,i) ((pc)[1] = JUMP_OFFSET_HI(i), \ | |||
(pc)[2] = JUMP_OFFSET_LO(i)) | (pc)[2] = JUMP_OFFSET_LO(i)) | |||
#define SPANDEP_INDEX_MAX ((uint16)0xfffe) | #define SPANDEP_INDEX_MAX ((uint16)0xfffe) | |||
#define SPANDEP_INDEX_HUGE ((uint16)0xffff) | #define SPANDEP_INDEX_HUGE ((uint16)0xffff) | |||
/* Ultimately, if short jumps won't do, emit long (4-byte signed) offsets. */ | /* Ultimately, if short jumps won't do, emit long (4-byte signed) offsets. */ | |||
#define JUMPX_OFFSET_LEN 4 | #define JUMPX_OFFSET_LEN 4 | |||
#define JUMPX_OFFSET_B3(off) ((jsbytecode)((off) >> 24)) | #define JUMPX_OFFSET_B3(off) ((jsbytecode)((off) >> 24)) | |||
#define JUMPX_OFFSET_B2(off) ((jsbytecode)((off) >> 16)) | #define JUMPX_OFFSET_B2(off) ((jsbytecode)((off) >> 16)) | |||
#define JUMPX_OFFSET_B1(off) ((jsbytecode)((off) >> 8)) | #define JUMPX_OFFSET_B1(off) ((jsbytecode)((off) >> 8)) | |||
#define JUMPX_OFFSET_B0(off) ((jsbytecode)(off)) | #define JUMPX_OFFSET_B0(off) ((jsbytecode)(off)) | |||
#define GET_JUMPX_OFFSET(pc) ((int32)(((pc)[1] << 24) | ((pc)[2] << 16) \ | #define GET_JUMPX_OFFSET(pc) ((int32)(((pc)[1] << 24) | ((pc)[2] << 16) \ | |||
| ((pc)[3] << 8) | (pc)[4])) | | ((pc)[3] << 8) | (pc)[4])) | |||
#define SET_JUMPX_OFFSET(pc,off)((pc)[1] = JUMPX_OFFSET_B3(off), \ | #define SET_JUMPX_OFFSET(pc,off)((pc)[1] = JUMPX_OFFSET_B3(off), \ | |||
(pc)[2] = JUMPX_OFFSET_B2(off), \ | (pc)[2] = JUMPX_OFFSET_B2(off), \ | |||
(pc)[3] = JUMPX_OFFSET_B1(off), \ | (pc)[3] = JUMPX_OFFSET_B1(off), \ | |||
(pc)[4] = JUMPX_OFFSET_B0(off)) | (pc)[4] = JUMPX_OFFSET_B0(off)) | |||
#define JUMPX_OFFSET_MIN ((int32)0x80000000) | #define JUMPX_OFFSET_MIN ((int32)0x80000000) | |||
#define JUMPX_OFFSET_MAX ((int32)0x7fffffff) | #define JUMPX_OFFSET_MAX ((int32)0x7fffffff) | |||
/* A literal is indexed by a per-script atom map. */ | /* | |||
* A literal is indexed by a per-script atom map. Most scripts have relati | ||||
vely | ||||
* few literals, so the standard JOF_CONST format specifies a fixed 16 bits | ||||
of | ||||
* immediate operand index. A script with more than 64K literals must push | ||||
all | ||||
* high-indexed literals on the stack using JSOP_LITERAL, then use JOF_ELEM | ||||
ops | ||||
* instead of JOF_PROP, etc. | ||||
*/ | ||||
#define ATOM_INDEX_LEN 2 | #define ATOM_INDEX_LEN 2 | |||
#define ATOM_INDEX_HI(index) ((jsbytecode)((index) >> 8)) | #define ATOM_INDEX_HI(i) ((jsbytecode)((i) >> 8)) | |||
#define ATOM_INDEX_LO(index) ((jsbytecode)(index)) | #define ATOM_INDEX_LO(i) ((jsbytecode)(i)) | |||
#define GET_ATOM_INDEX(pc) ((jsatomid)(((pc)[1] << 8) | (pc)[2])) | #define GET_ATOM_INDEX(pc) ((jsatomid)(((pc)[1] << 8) | (pc)[2])) | |||
#define SET_ATOM_INDEX(pc,index)((pc)[1] = ATOM_INDEX_HI(index), | #define SET_ATOM_INDEX(pc,i) ((pc)[1] = ATOM_INDEX_HI(i), | |||
\ | \ | |||
(pc)[2] = ATOM_INDEX_LO(index)) | (pc)[2] = ATOM_INDEX_LO(i)) | |||
#define GET_ATOM(cx,script,pc) js_GetAtom((cx), &(script)->atomMap, \ | #define GET_ATOM(cx,script,pc) js_GetAtom((cx), &(script)->atomMap, \ | |||
GET_ATOM_INDEX(pc)) | GET_ATOM_INDEX(pc)) | |||
#define ATOM_INDEX_LIMIT_LOG2 16 | ||||
/* A full atom index for JSOP_UINT24 uses 24 bits of immediate operand. */ | ||||
#define UINT24_HI(i) ((jsbytecode)((i) >> 16)) | ||||
#define UINT24_MID(i) ((jsbytecode)((i) >> 8)) | ||||
#define UINT24_LO(i) ((jsbytecode)(i)) | ||||
#define GET_UINT24(pc) ((jsatomid)(((pc)[1] << 16) | | ||||
\ | ||||
((pc)[2] << 8) | | ||||
\ | ||||
(pc)[3])) | ||||
#define SET_UINT24(pc,i) ((pc)[1] = UINT24_HI(i), | ||||
\ | ||||
(pc)[2] = UINT24_MID(i), | ||||
\ | ||||
(pc)[3] = UINT24_LO(i)) | ||||
/* Same format for JSOP_LITERAL, etc., but future-proof with different name | ||||
s. */ | ||||
#define LITERAL_INDEX_LEN 3 | ||||
#define LITERAL_INDEX_HI(i) UINT24_HI(i) | ||||
#define LITERAL_INDEX_MID(i) UINT24_MID(i) | ||||
#define LITERAL_INDEX_LO(i) UINT24_LO(i) | ||||
#define GET_LITERAL_INDEX(pc) GET_UINT24(pc) | ||||
#define SET_LITERAL_INDEX(pc,i) SET_UINT24(pc,i) | ||||
/* Atom index limit is determined by SN_3BYTE_OFFSET_FLAG, see jsemit.h. */ | ||||
#define ATOM_INDEX_LIMIT_LOG2 23 | ||||
#define ATOM_INDEX_LIMIT ((uint32)1 << ATOM_INDEX_LIMIT_LOG2) | #define ATOM_INDEX_LIMIT ((uint32)1 << ATOM_INDEX_LIMIT_LOG2) | |||
JS_STATIC_ASSERT(sizeof(jsatomid) * JS_BITS_PER_BYTE >= | ||||
ATOM_INDEX_LIMIT_LOG2 + 1); | ||||
/* Common uint16 immediate format helpers. */ | ||||
#define UINT16_HI(i) ((jsbytecode)((i) >> 8)) | ||||
#define UINT16_LO(i) ((jsbytecode)(i)) | ||||
#define GET_UINT16(pc) ((uintN)(((pc)[1] << 8) | (pc)[2])) | ||||
#define SET_UINT16(pc,i) ((pc)[1] = UINT16_HI(i), (pc)[2] = UINT16_L | ||||
O(i)) | ||||
#define UINT16_LIMIT ((uintN)1 << 16) | ||||
/* Actual argument count operand format helpers. */ | /* Actual argument count operand format helpers. */ | |||
#define ARGC_HI(argc) ((jsbytecode)((argc) >> 8)) | #define ARGC_HI(argc) UINT16_HI(argc) | |||
#define ARGC_LO(argc) ((jsbytecode)(argc)) | #define ARGC_LO(argc) UINT16_LO(argc) | |||
#define GET_ARGC(pc) ((uintN)(((pc)[1] << 8) | (pc)[2])) | #define GET_ARGC(pc) GET_UINT16(pc) | |||
#define ARGC_LIMIT ((uint32)1 << 16) | #define ARGC_LIMIT UINT16_LIMIT | |||
/* Synonyms for quick JOF_QARG and JOF_QVAR bytecodes. */ | /* Synonyms for quick JOF_QARG and JOF_QVAR bytecodes. */ | |||
#define GET_ARGNO(pc) GET_ARGC(pc) | #define GET_ARGNO(pc) GET_UINT16(pc) | |||
#define SET_ARGNO(pc,argno) SET_JUMP_OFFSET(pc,argno) | #define SET_ARGNO(pc,argno) SET_UINT16(pc,argno) | |||
#define ARGNO_LEN JUMP_OFFSET_LEN | #define ARGNO_LEN 2 | |||
#define GET_VARNO(pc) GET_ARGC(pc) | #define ARGNO_LIMIT UINT16_LIMIT | |||
#define SET_VARNO(pc,varno) SET_JUMP_OFFSET(pc,varno) | ||||
#define VARNO_LEN JUMP_OFFSET_LEN | #define GET_VARNO(pc) GET_UINT16(pc) | |||
#define SET_VARNO(pc,varno) SET_UINT16(pc,varno) | ||||
#define VARNO_LEN 2 | ||||
#define VARNO_LIMIT UINT16_LIMIT | ||||
struct JSCodeSpec { | struct JSCodeSpec { | |||
const char *name; /* JS bytecode name */ | const char *name; /* JS bytecode name */ | |||
const char *token; /* JS source literal or null */ | const char *token; /* JS source literal or null */ | |||
int8 length; /* length including opcode byte */ | int8 length; /* length including opcode byte */ | |||
int8 nuses; /* arity, -1 if variadic */ | int8 nuses; /* arity, -1 if variadic */ | |||
int8 ndefs; /* number of stack results */ | int8 ndefs; /* number of stack results */ | |||
uint8 prec; /* operator precedence */ | uint8 prec; /* operator precedence */ | |||
uint32 format; /* immediate operand format */ | uint32 format; /* immediate operand format */ | |||
}; | }; | |||
extern const char js_const_str[]; | ||||
extern const char js_var_str[]; | ||||
extern const char js_function_str[]; | ||||
extern const char js_in_str[]; | ||||
extern const char js_instanceof_str[]; | ||||
extern const char js_new_str[]; | ||||
extern const char js_delete_str[]; | ||||
extern const char js_typeof_str[]; | ||||
extern const char js_void_str[]; | ||||
extern const char js_null_str[]; | ||||
extern const char js_this_str[]; | ||||
extern const char js_false_str[]; | ||||
extern const char js_true_str[]; | ||||
extern const JSCodeSpec js_CodeSpec[]; | extern const JSCodeSpec js_CodeSpec[]; | |||
extern uintN js_NumCodeSpecs; | extern uintN js_NumCodeSpecs; | |||
extern const jschar js_EscapeMap[]; | extern const jschar js_EscapeMap[]; | |||
/* | /* | |||
* Return a GC'ed string containing the chars in str, with any non-printing | * Return a GC'ed string containing the chars in str, with any non-printing | |||
* chars or quotes (' or " as specified by the quote argument) escaped, and | * chars or quotes (' or " as specified by the quote argument) escaped, and | |||
* with the quote character at the beginning and end of the result string. | * with the quote character at the beginning and end of the result string. | |||
*/ | */ | |||
extern JSString * | extern JSString * | |||
skipping to change at line 233 | skipping to change at line 275 | |||
extern JSBool | extern JSBool | |||
js_puts(JSPrinter *jp, const char *s); | js_puts(JSPrinter *jp, const char *s); | |||
#ifdef DEBUG | #ifdef DEBUG | |||
/* | /* | |||
* Disassemblers, for debugging only. | * Disassemblers, for debugging only. | |||
*/ | */ | |||
#include <stdio.h> | #include <stdio.h> | |||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(JSBool) | |||
js_Disassemble(JSContext *cx, JSScript *script, JSBool lines, FILE *fp); | js_Disassemble(JSContext *cx, JSScript *script, JSBool lines, FILE *fp); | |||
extern JS_FRIEND_API(uintN) | extern JS_FRIEND_API(uintN) | |||
js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc, uintN loc, | js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc, uintN loc, | |||
JSBool lines, FILE *fp); | JSBool lines, FILE *fp); | |||
#endif /* DEBUG */ | #endif /* DEBUG */ | |||
/* | /* | |||
* Decompilers, for script, function, and expression pretty-printing. | * Decompilers, for script, function, and expression pretty-printing. | |||
*/ | */ | |||
extern JSBool | extern JSBool | |||
js_DecompileCode(JSPrinter *jp, JSScript *script, jsbytecode *pc, uintN len | js_DecompileCode(JSPrinter *jp, JSScript *script, jsbytecode *pc, uintN len | |||
); | , | |||
uintN pcdepth); | ||||
extern JSBool | extern JSBool | |||
js_DecompileScript(JSPrinter *jp, JSScript *script); | js_DecompileScript(JSPrinter *jp, JSScript *script); | |||
extern JSBool | extern JSBool | |||
js_DecompileFunctionBody(JSPrinter *jp, JSFunction *fun); | js_DecompileFunctionBody(JSPrinter *jp, JSFunction *fun); | |||
extern JSBool | extern JSBool | |||
js_DecompileFunction(JSPrinter *jp, JSFunction *fun); | js_DecompileFunction(JSPrinter *jp, JSFunction *fun); | |||
skipping to change at line 268 | skipping to change at line 311 | |||
* containing it. Fall back on v's string conversion (fallback) if we can' t | * containing it. Fall back on v's string conversion (fallback) if we can' t | |||
* find the bytecode that generated and pushed v on the operand stack. | * find the bytecode that generated and pushed v on the operand stack. | |||
* | * | |||
* Search the current stack frame if spindex is JSDVG_SEARCH_STACK. Don't | * Search the current stack frame if spindex is JSDVG_SEARCH_STACK. Don't | |||
* look for v on the stack if spindex is JSDVG_IGNORE_STACK. Otherwise, | * look for v on the stack if spindex is JSDVG_IGNORE_STACK. Otherwise, | |||
* spindex is the negative index of v, measured from cx->fp->sp, or from a | * spindex is the negative index of v, measured from cx->fp->sp, or from a | |||
* lower frame's sp if cx->fp is native. | * lower frame's sp if cx->fp is native. | |||
*/ | */ | |||
extern JSString * | extern JSString * | |||
js_DecompileValueGenerator(JSContext *cx, intN spindex, jsval v, | js_DecompileValueGenerator(JSContext *cx, intN spindex, jsval v, | |||
JSString *fallback); | JSString *fallback); | |||
#define JSDVG_IGNORE_STACK 0 | #define JSDVG_IGNORE_STACK 0 | |||
#define JSDVG_SEARCH_STACK 1 | #define JSDVG_SEARCH_STACK 1 | |||
JS_END_EXTERN_C | JS_END_EXTERN_C | |||
#endif /* jsopcode_h___ */ | #endif /* jsopcode_h___ */ | |||
End of changes. 19 change blocks. | ||||
39 lines changed or deleted | 95 lines changed or added | |||
jsosdep.h | jsosdep.h | |||
---|---|---|---|---|
skipping to change at line 55 | skipping to change at line 55 | |||
#if defined(XP_WIN) || defined(XP_OS2) | #if defined(XP_WIN) || defined(XP_OS2) | |||
#if defined(_WIN32) || defined (XP_OS2) | #if defined(_WIN32) || defined (XP_OS2) | |||
#define JS_HAVE_LONG_LONG | #define JS_HAVE_LONG_LONG | |||
#else | #else | |||
#undef JS_HAVE_LONG_LONG | #undef JS_HAVE_LONG_LONG | |||
#endif | #endif | |||
#endif /* XP_WIN || XP_OS2 */ | #endif /* XP_WIN || XP_OS2 */ | |||
#ifdef XP_MAC | ||||
#define JS_HAVE_LONG_LONG | ||||
JS_BEGIN_EXTERN_C | ||||
#include <stddef.h> | ||||
extern void* reallocSmaller(void* block, size_t newSize); | ||||
extern char* strdup(const char* str); | ||||
JS_END_EXTERN_C | ||||
#endif /* XP_MAC */ | ||||
#ifdef XP_BEOS | #ifdef XP_BEOS | |||
#define JS_HAVE_LONG_LONG | #define JS_HAVE_LONG_LONG | |||
#endif | #endif | |||
#ifdef XP_UNIX | #ifdef XP_UNIX | |||
/* | /* | |||
* Get OS specific header information. | * Get OS specific header information. | |||
*/ | */ | |||
#if defined(AIXV3) || defined(AIX) | #if defined(XP_MACOSX) || defined(DARWIN) | |||
#define JS_HAVE_LONG_LONG | ||||
#elif defined(AIXV3) || defined(AIX) | ||||
#define JS_HAVE_LONG_LONG | #define JS_HAVE_LONG_LONG | |||
#elif defined(BSDI) | #elif defined(BSDI) | |||
#define JS_HAVE_LONG_LONG | #define JS_HAVE_LONG_LONG | |||
#elif defined(HPUX) | #elif defined(HPUX) | |||
#define JS_HAVE_LONG_LONG | #define JS_HAVE_LONG_LONG | |||
#elif defined(IRIX) | #elif defined(IRIX) | |||
#define JS_HAVE_LONG_LONG | #define JS_HAVE_LONG_LONG | |||
End of changes. 2 change blocks. | ||||
16 lines changed or deleted | 4 lines changed or added | |||
jsotypes.h | jsotypes.h | |||
---|---|---|---|---|
skipping to change at line 70 | skipping to change at line 70 | |||
#include <SupportDefs.h> | #include <SupportDefs.h> | |||
typedef JSUintn uintn; | typedef JSUintn uintn; | |||
#ifndef _XP_Core_ | #ifndef _XP_Core_ | |||
typedef JSIntn intn; | typedef JSIntn intn; | |||
#endif | #endif | |||
#else | #else | |||
/* SVR4 typedef of uint is commonly found on UNIX machines. */ | /* SVR4 typedef of uint is commonly found on UNIX machines. */ | |||
#ifdef XP_UNIX | #if defined(XP_UNIX) && !defined(__QNXNTO__) | |||
#include <sys/types.h> | #include <sys/types.h> | |||
#else | #else | |||
typedef JSUintn uint; | typedef JSUintn uint; | |||
#endif | #endif | |||
typedef JSUintn uintn; | typedef JSUintn uintn; | |||
typedef JSUint64 uint64; | typedef JSUint64 uint64; | |||
#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2) | #if !defined(_WIN32) && !defined(XP_OS2) | |||
typedef JSUint32 uint32; | typedef JSUint32 uint32; | |||
#else | #else | |||
typedef unsigned long uint32; | typedef unsigned long uint32; | |||
#endif | #endif | |||
typedef JSUint16 uint16; | typedef JSUint16 uint16; | |||
typedef JSUint8 uint8; | typedef JSUint8 uint8; | |||
#ifndef _XP_Core_ | #ifndef _XP_Core_ | |||
typedef JSIntn intn; | typedef JSIntn intn; | |||
#endif | #endif | |||
skipping to change at line 105 | skipping to change at line 105 | |||
*/ | */ | |||
#if defined(AIX) && defined(HAVE_SYS_INTTYPES_H) | #if defined(AIX) && defined(HAVE_SYS_INTTYPES_H) | |||
#include <sys/inttypes.h> | #include <sys/inttypes.h> | |||
#else | #else | |||
typedef JSInt64 int64; | typedef JSInt64 int64; | |||
/* /usr/include/model.h on HP-UX defines int8, int16, and int32 */ | /* /usr/include/model.h on HP-UX defines int8, int16, and int32 */ | |||
#ifdef HPUX | #ifdef HPUX | |||
#include <model.h> | #include <model.h> | |||
#else | #else | |||
#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2) | #if !defined(_WIN32) && !defined(XP_OS2) | |||
typedef JSInt32 int32; | typedef JSInt32 int32; | |||
#else | #else | |||
typedef long int32; | typedef long int32; | |||
#endif | #endif | |||
typedef JSInt16 int16; | typedef JSInt16 int16; | |||
typedef JSInt8 int8; | typedef JSInt8 int8; | |||
#endif /* HPUX */ | #endif /* HPUX */ | |||
#endif /* AIX && HAVE_SYS_INTTYPES_H */ | #endif /* AIX && HAVE_SYS_INTTYPES_H */ | |||
#endif /* XP_BEOS */ | #endif /* XP_BEOS */ | |||
typedef JSFloat64 float64; | typedef JSFloat64 float64; | |||
/* Re: jsbit.h */ | /* Re: jsbit.h */ | |||
#define TEST_BIT JS_TEST_BIT | #define TEST_BIT JS_TEST_BIT | |||
#define SET_BIT JS_SET_BIT | #define SET_BIT JS_SET_BIT | |||
#define CLEAR_BIT JS_CLEAR_BIT | #define CLEAR_BIT JS_CLEAR_BIT | |||
/* Re: prarena.h->plarena.h */ | /* Re: prarena.h->plarena.h */ | |||
#define PRArena PLArena | #define PRArena PLArena | |||
#define PRArenaPool PLArenaPool | #define PRArenaPool PLArenaPool | |||
#define PRArenaStats PLArenaStats | #define PRArenaStats PLArenaStats | |||
#define PR_ARENA_ALIGN PL_ARENA_ALIGN | #define PR_ARENA_ALIGN PL_ARENA_ALIGN | |||
#define PR_INIT_ARENA_POOL PL_INIT_ARENA_POOL | #define PR_INIT_ARENA_POOL PL_INIT_ARENA_POOL | |||
#define PR_ARENA_ALLOCATE PL_ARENA_ALLOCATE | #define PR_ARENA_ALLOCATE PL_ARENA_ALLOCATE | |||
#define PR_ARENA_GROW PL_ARENA_GROW | #define PR_ARENA_GROW PL_ARENA_GROW | |||
#define PR_ARENA_MARK PL_ARENA_MARK | #define PR_ARENA_MARK PL_ARENA_MARK | |||
skipping to change at line 202 | skipping to change at line 202 | |||
#define PR_HashTableRawRemove PL_HashTableRawRemove | #define PR_HashTableRawRemove PL_HashTableRawRemove | |||
#define PR_HashTableAdd PL_HashTableAdd | #define PR_HashTableAdd PL_HashTableAdd | |||
#define PR_HashTableRemove PL_HashTableRemove | #define PR_HashTableRemove PL_HashTableRemove | |||
#define PR_HashTableEnumerateEntries PL_HashTableEnumerateEntries | #define PR_HashTableEnumerateEntries PL_HashTableEnumerateEntries | |||
#define PR_HashTableLookup PL_HashTableLookup | #define PR_HashTableLookup PL_HashTableLookup | |||
#define PR_HashTableDump PL_HashTableDump | #define PR_HashTableDump PL_HashTableDump | |||
#define PR_HashString PL_HashString | #define PR_HashString PL_HashString | |||
#define PR_CompareStrings PL_CompareStrings | #define PR_CompareStrings PL_CompareStrings | |||
#define PR_CompareValues PL_CompareValues | #define PR_CompareValues PL_CompareValues | |||
#ifdef XP_MAC | ||||
#ifndef TRUE /* Mac standard is lower case true * | ||||
/ | ||||
#define TRUE 1 | ||||
#endif | ||||
#ifndef FALSE /* Mac standard is lower case false | ||||
*/ | ||||
#define FALSE 0 | ||||
#endif | ||||
#endif | ||||
#endif /* !defined(PROTYPES_H) */ | #endif /* !defined(PROTYPES_H) */ | |||
End of changes. 6 change blocks. | ||||
18 lines changed or deleted | 7 lines changed or added | |||
jsparse.h | jsparse.h | |||
---|---|---|---|---|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | /* -*- 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 ***** | * ***** BEGIN LICENSE BLOCK ***** | |||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | |||
* | * | |||
* The contents of this file are subject to the Mozilla Public License Vers ion | * The contents of this file are subject to the Mozilla Public License Vers ion | |||
* 1.1 (the "License"); you may not use this file except in compliance with | * 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 | * the License. You may obtain a copy of the License at | |||
* http://www.mozilla.org/MPL/ | * http://www.mozilla.org/MPL/ | |||
* | * | |||
* Software distributed under the License is distributed on an "AS IS" basi s, | * Software distributed under the License is distributed on an "AS IS" basi s, | |||
skipping to change at line 45 | skipping to change at line 46 | |||
* the provisions above, a recipient may use your version of this file unde r | * the provisions above, a recipient may use your version of this file unde r | |||
* the terms of any one of the MPL, the GPL or the LGPL. | * the terms of any one of the MPL, the GPL or the LGPL. | |||
* | * | |||
* ***** END LICENSE BLOCK ***** */ | * ***** END LICENSE BLOCK ***** */ | |||
#ifndef jsparse_h___ | #ifndef jsparse_h___ | |||
#define jsparse_h___ | #define jsparse_h___ | |||
/* | /* | |||
* JS parser definitions. | * JS parser definitions. | |||
*/ | */ | |||
#include "jsconfig.h" | ||||
#include "jsprvtd.h" | #include "jsprvtd.h" | |||
#include "jspubtd.h" | #include "jspubtd.h" | |||
#include "jsscan.h" | #include "jsscan.h" | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
/* | /* | |||
* Parsing builds a tree of nodes that directs code generation. This tree is | * Parsing builds a tree of nodes that directs code generation. This tree is | |||
* not a concrete syntax tree in all respects (for example, || and && are l eft | * not a concrete syntax tree in all respects (for example, || and && are l eft | |||
* associative, but (A && B && C) translates into the right-associated tree | * associative, but (A && B && C) translates into the right-associated tree | |||
skipping to change at line 83 | skipping to change at line 85 | |||
* TOK_EXPORT list pn_head: list of pn_count TOK_NAMEs or one TOK_ STAR | * TOK_EXPORT list pn_head: list of pn_count TOK_NAMEs or one TOK_ STAR | |||
* (which is not a multiply node) | * (which is not a multiply node) | |||
* TOK_IMPORT list pn_head: list of pn_count sub-trees of the form | * TOK_IMPORT list pn_head: list of pn_count sub-trees of the form | |||
* a.b.*, a[b].*, a.*, a.b, or a[b] -- but never a. | * a.b.*, a[b].*, a.*, a.b, or a[b] -- but never a. | |||
* Each member is expressed with TOK_DOT or TOK_ LB. | * Each member is expressed with TOK_DOT or TOK_ LB. | |||
* Each sub-tree's root node has a pn_op in the set | * Each sub-tree's root node has a pn_op in the set | |||
* JSOP_IMPORT{ALL,PROP,ELEM} | * JSOP_IMPORT{ALL,PROP,ELEM} | |||
* TOK_IF ternary pn_kid1: cond, pn_kid2: then, pn_kid3: else or null | * TOK_IF ternary pn_kid1: cond, pn_kid2: then, pn_kid3: else or null | |||
* TOK_SWITCH binary pn_left: discriminant | * TOK_SWITCH binary pn_left: discriminant | |||
* pn_right: list of TOK_CASE nodes, with at most one | * pn_right: list of TOK_CASE nodes, with at most one | |||
* TOK_DEFAULT node | * TOK_DEFAULT node, or if there are let binding | |||
s | ||||
* in the top level of the switch body's cases, | ||||
a | ||||
* TOK_LEXICALSCOPE node that contains the list | ||||
of | ||||
* TOK_CASE nodes. | ||||
* TOK_CASE, binary pn_left: case expr or null if TOK_DEFAULT | * TOK_CASE, binary pn_left: case expr or null if TOK_DEFAULT | |||
* TOK_DEFAULT pn_right: TOK_LC node for this case's statement s | * TOK_DEFAULT pn_right: TOK_LC node for this case's statement s | |||
* pn_val: constant value if lookup or table switc h | * pn_val: constant value if lookup or table switc h | |||
* TOK_WHILE binary pn_left: cond, pn_right: body | * TOK_WHILE binary pn_left: cond, pn_right: body | |||
* TOK_DO binary pn_left: body, pn_right: cond | * TOK_DO binary pn_left: body, pn_right: cond | |||
* TOK_FOR binary pn_left: either | * TOK_FOR binary pn_left: either | |||
* for/in loop: a binary TOK_IN node with | * for/in loop: a binary TOK_IN node with | |||
* pn_left: TOK_VAR or TOK_NAME to left of 'i n' | * pn_left: TOK_VAR or TOK_NAME to left of 'i n' | |||
* if TOK_VAR, its pn_extra may have PNX_POP VAR | * if TOK_VAR, its pn_extra may have PNX_POP VAR | |||
* and PNX_FORINVAR bits set | * and PNX_FORINVAR bits set | |||
* pn_right: object expr to right of 'in' | * pn_right: object expr to right of 'in' | |||
* for(;;) loop: a ternary TOK_RESERVED node wit h | * for(;;) loop: a ternary TOK_RESERVED node wit h | |||
* pn_kid1: init expr before first ';' | * pn_kid1: init expr before first ';' | |||
* pn_kid2: cond expr before second ';' | * pn_kid2: cond expr before second ';' | |||
* pn_kid3: update expr after second ';' | * pn_kid3: update expr after second ';' | |||
* any kid may be null | * any kid may be null | |||
* pn_right: body | * pn_right: body | |||
* TOK_THROW unary pn_op: JSOP_THROW, pn_kid: exception | * TOK_THROW unary pn_op: JSOP_THROW, pn_kid: exception | |||
* TOK_TRY ternary pn_kid1: try block | * TOK_TRY ternary pn_kid1: try block | |||
* pn_kid2: catch blocks or null | * pn_kid2: null or TOK_RESERVED list of | |||
* pn_kid3: finally block or null | * TOK_LEXICALSCOPE nodes, each with pn_expr point | |||
* TOK_CATCH ternary pn_kid1: PN_NAME node for catch var (with pn_ex | ing | |||
pr | * to a TOK_CATCH node | |||
* null or the catch guard expression) | * pn_kid3: null or finally block | |||
* pn_kid2: more catch blocks or null | * TOK_CATCH ternary pn_kid1: TOK_NAME, TOK_RB, or TOK_RC catch var | |||
node | ||||
* (TOK_RB or TOK_RC if destructuring) | ||||
* pn_kid2: null or the catch guard expression | ||||
* pn_kid3: catch block statements | * pn_kid3: catch block statements | |||
* TOK_BREAK name pn_atom: label or null | * TOK_BREAK name pn_atom: label or null | |||
* TOK_CONTINUE name pn_atom: label or null | * TOK_CONTINUE name pn_atom: label or null | |||
* TOK_WITH binary pn_left: head expr, pn_right: body | * TOK_WITH binary pn_left: head expr, pn_right: body | |||
* TOK_VAR list pn_head: list of pn_count TOK_NAME nodes | * TOK_VAR list pn_head: list of pn_count TOK_NAME nodes | |||
* each name node has | * each name node has | |||
* pn_atom: variable name | * pn_atom: variable name | |||
* pn_expr: initializer or null | * pn_expr: initializer or null | |||
* TOK_RETURN unary pn_kid: return expr or null | * TOK_RETURN unary pn_kid: return expr or null | |||
* TOK_SEMI unary pn_kid: expr or null statement | * TOK_SEMI unary pn_kid: expr or null statement | |||
skipping to change at line 158 | skipping to change at line 165 | |||
* TOK_STAR, binary pn_left: left-assoc MUL expr, pn_right: UNARY e xpr | * TOK_STAR, binary pn_left: left-assoc MUL expr, pn_right: UNARY e xpr | |||
* TOK_DIVOP pn_op: JSOP_MUL, JSOP_DIV, JSOP_MOD | * TOK_DIVOP pn_op: JSOP_MUL, JSOP_DIV, JSOP_MOD | |||
* TOK_UNARYOP unary pn_kid: UNARY expr, pn_op: JSOP_NEG, JSOP_POS, | * TOK_UNARYOP unary pn_kid: UNARY expr, pn_op: JSOP_NEG, JSOP_POS, | |||
* JSOP_NOT, JSOP_BITNOT, JSOP_TYPEOF, JSOP_VOID | * JSOP_NOT, JSOP_BITNOT, JSOP_TYPEOF, JSOP_VOID | |||
* TOK_INC, unary pn_kid: MEMBER expr | * TOK_INC, unary pn_kid: MEMBER expr | |||
* TOK_DEC | * TOK_DEC | |||
* TOK_NEW list pn_head: list of ctor, arg1, arg2, ... argN | * TOK_NEW list pn_head: list of ctor, arg1, arg2, ... argN | |||
* pn_count: 1 + N (where N is number of args) | * pn_count: 1 + N (where N is number of args) | |||
* ctor is a MEMBER expr | * ctor is a MEMBER expr | |||
* TOK_DELETE unary pn_kid: MEMBER expr | * TOK_DELETE unary pn_kid: MEMBER expr | |||
* TOK_DOT name pn_expr: MEMBER expr to left of . | * TOK_DOT, name pn_expr: MEMBER expr to left of . | |||
* pn_atom: name to right of . | * TOK_DBLDOT pn_atom: name to right of . | |||
* TOK_LB binary pn_left: MEMBER expr to left of [ | * TOK_LB binary pn_left: MEMBER expr to left of [ | |||
* pn_right: expr between [ and ] | * pn_right: expr between [ and ] | |||
* TOK_LP list pn_head: list of call, arg1, arg2, ... argN | * TOK_LP list pn_head: list of call, arg1, arg2, ... argN | |||
* pn_count: 1 + N (where N is number of args) | * pn_count: 1 + N (where N is number of args) | |||
* call is a MEMBER expr naming a callable object | * call is a MEMBER expr naming a callable object | |||
* TOK_RB list pn_head: list of pn_count array element exprs | * TOK_RB list pn_head: list of pn_count array element exprs | |||
* [,,] holes are represented by TOK_COMMA nodes | * [,,] holes are represented by TOK_COMMA nodes | |||
* #n=[...] produces TOK_DEFSHARP at head of list | * #n=[...] produces TOK_DEFSHARP at head of list | |||
* pn_extra: PN_ENDCOMMA if extra comma at end | * pn_extra: PN_ENDCOMMA if extra comma at end | |||
* TOK_RC list pn_head: list of pn_count TOK_COLON nodes where | * TOK_RC list pn_head: list of pn_count TOK_COLON nodes where | |||
skipping to change at line 185 | skipping to change at line 192 | |||
* literal expressions | * literal expressions | |||
* TOK_USESHARP nullary pn_num: jsint value of n in #n# | * TOK_USESHARP nullary pn_num: jsint value of n in #n# | |||
* TOK_RP unary pn_kid: parenthesized expression | * TOK_RP unary pn_kid: parenthesized expression | |||
* TOK_NAME, name pn_atom: name, string, or object atom | * TOK_NAME, name pn_atom: name, string, or object atom | |||
* TOK_STRING, pn_op: JSOP_NAME, JSOP_STRING, or JSOP_OBJECT, or | * TOK_STRING, pn_op: JSOP_NAME, JSOP_STRING, or JSOP_OBJECT, or | |||
* JSOP_REGEXP | * JSOP_REGEXP | |||
* TOK_OBJECT If JSOP_NAME, pn_op may be JSOP_*ARG or JSOP_*V AR | * TOK_OBJECT If JSOP_NAME, pn_op may be JSOP_*ARG or JSOP_*V AR | |||
* with pn_slot >= 0 and pn_attrs telling const-ne ss | * with pn_slot >= 0 and pn_attrs telling const-ne ss | |||
* TOK_NUMBER dval pn_dval: double value of numeric literal | * TOK_NUMBER dval pn_dval: double value of numeric literal | |||
* TOK_PRIMARY nullary pn_op: JSOp bytecode | * TOK_PRIMARY nullary pn_op: JSOp bytecode | |||
* | ||||
* <E4X node descriptions> | ||||
* TOK_ANYNAME nullary pn_op: JSOP_ANYNAME | ||||
* pn_atom: cx->runtime->atomState.starAtom | ||||
* TOK_AT unary pn_op: JSOP_TOATTRNAME; pn_kid attribute id/exp | ||||
r | ||||
* TOK_DBLCOLON binary pn_op: JSOP_QNAME | ||||
* pn_left: TOK_ANYNAME or TOK_NAME node | ||||
* pn_right: TOK_STRING "*" node, or expr within [ | ||||
] | ||||
* name pn_op: JSOP_QNAMECONST | ||||
* pn_expr: TOK_ANYNAME or TOK_NAME left operand | ||||
* pn_atom: name on right of :: | ||||
* TOK_XMLELEM list XML element node | ||||
* pn_head: start tag, content1, ... contentN, end | ||||
tag | ||||
* pn_count: 2 + N where N is number of content no | ||||
des | ||||
* N may be > x.length() if {expr} embed | ||||
ded | ||||
* TOK_XMLLIST list XML list node | ||||
* pn_head: content1, ... contentN | ||||
* TOK_XMLSTAGO, list XML start, end, and point tag contents | ||||
* TOK_XMLETAGC, pn_head: tag name or {expr}, ... XML attrs ... | ||||
* TOK_XMLPTAGO | ||||
* TOK_XMLNAME nullary pn_atom: XML name, with no {expr} embedded | ||||
* TOK_XMLNAME list pn_head: tag name or {expr}, ... name or {expr} | ||||
* TOK_XMLATTR, nullary pn_atom: attribute value string; pn_op: JSOP_ST | ||||
RING | ||||
* TOK_XMLCDATA, | ||||
* TOK_XMLCOMMENT | ||||
* TOK_XMLPI nullary pn_atom: XML processing instruction target | ||||
* pn_atom2: XML PI content, or null if no content | ||||
* TOK_XMLTEXT nullary pn_atom: marked-up text, or null if empty strin | ||||
g | ||||
* TOK_LC unary {expr} in XML tag or content; pn_kid is expr | ||||
* | ||||
* So an XML tag with no {expr} and three attributes is a list with the for | ||||
m: | ||||
* | ||||
* (tagname attrname1 attrvalue1 attrname2 attrvalue2 attrname2 attrvalu | ||||
e3) | ||||
* | ||||
* An XML tag with embedded expressions like so: | ||||
* | ||||
* <name1{expr1} name2{expr2}name3={expr3}> | ||||
* | ||||
* would have the form: | ||||
* | ||||
* ((name1 {expr1}) (name2 {expr2} name3) {expr3}) | ||||
* | ||||
* where () bracket a list with elements separated by spaces, and {expr} is | ||||
a | ||||
* TOK_LC unary node with expr as its kid. | ||||
* | ||||
* Thus, the attribute name/value pairs occupy successive odd and even list | ||||
* locations, where pn_head is the TOK_XMLNAME node at list location 0. Th | ||||
e | ||||
* parser builds the same sort of structures for elements: | ||||
* | ||||
* <a x={x}>Hi there!<b y={y}>How are you?</b><answer>{x + y}</answer></ | ||||
a> | ||||
* | ||||
* translates to: | ||||
* | ||||
* ((a x {x}) 'Hi there!' ((b y {y}) 'How are you?') ((answer) {x + y})) | ||||
* | ||||
* <Non-E4X node descriptions, continued> | ||||
* | ||||
* Label Variant Members | ||||
* ----- ------- ------- | ||||
* TOK_LEXICALSCOPE name pn_op: JSOP_LEAVEBLOCK or JSOP_LEAVEBLOCKEX | ||||
PR | ||||
* pn_atom: block object | ||||
* pn_expr: block body | ||||
* TOK_ARRAYCOMP list pn_head: list of pn_count (1 or 2) elements | ||||
* if pn_count is 2, first element is #n=[...] | ||||
* last element is block enclosing for loop( | ||||
s) | ||||
* and optionally if-guarded TOK_ARRAYPUSH | ||||
* pn_extra: stack slot, used during code gen | ||||
* TOK_ARRAYPUSH unary pn_op: JSOP_ARRAYCOMP | ||||
* pn_kid: array comprehension expression | ||||
*/ | */ | |||
typedef enum JSParseNodeArity { | typedef enum JSParseNodeArity { | |||
PN_FUNC = -3, | PN_FUNC = -3, | |||
PN_LIST = -2, | PN_LIST = -2, | |||
PN_TERNARY = 3, | PN_TERNARY = 3, | |||
PN_BINARY = 2, | PN_BINARY = 2, | |||
PN_UNARY = 1, | PN_UNARY = 1, | |||
PN_NAME = -1, | PN_NAME = -1, | |||
PN_NULLARY = 0 | PN_NULLARY = 0 | |||
} JSParseNodeArity; | } JSParseNodeArity; | |||
struct JSParseNode { | struct JSParseNode { | |||
JSTokenType pn_type; | uint16 pn_type; | |||
uint8 pn_op; | ||||
int8 pn_arity; | ||||
JSTokenPos pn_pos; | JSTokenPos pn_pos; | |||
JSOp pn_op; | ||||
ptrdiff_t pn_offset; /* first generated bytecode offset */ | ptrdiff_t pn_offset; /* first generated bytecode offset */ | |||
JSParseNodeArity pn_arity; | ||||
union { | union { | |||
struct { /* TOK_FUNCTION node */ | struct { /* TOK_FUNCTION node */ | |||
JSAtom *funAtom; /* atomized function object */ | JSAtom *funAtom; /* atomized function object */ | |||
JSParseNode *body; /* TOK_LC list of statements */ | JSParseNode *body; /* TOK_LC list of statements */ | |||
uint32 flags; /* accumulated tree context flags * / | uint32 flags; /* accumulated tree context flags * / | |||
uint32 tryCount; /* count of try statements in body */ | uint32 tryCount; /* count of try statements in body */ | |||
} func; | } func; | |||
struct { /* list of next-linked nodes */ | struct { /* list of next-linked nodes */ | |||
JSParseNode *head; /* first node in list */ | JSParseNode *head; /* first node in list */ | |||
JSParseNode **tail; /* ptr to ptr to last node in list */ | JSParseNode **tail; /* ptr to ptr to last node in list */ | |||
uint32 count; /* number of nodes in list */ | uint32 count; /* number of nodes in list */ | |||
uint32 extra; /* extra comma flag for [1,2,,] */ | uint32 extra; /* extra flags, see below */ | |||
} list; | } list; | |||
struct { /* ternary: if, for(;;), ?: */ | struct { /* ternary: if, for(;;), ?: */ | |||
JSParseNode *kid1; /* condition, discriminant, etc. */ | JSParseNode *kid1; /* condition, discriminant, etc. */ | |||
JSParseNode *kid2; /* then-part, case list, etc. */ | JSParseNode *kid2; /* then-part, case list, etc. */ | |||
JSParseNode *kid3; /* else-part, default case, etc. */ | JSParseNode *kid3; /* else-part, default case, etc. */ | |||
} ternary; | } ternary; | |||
struct { /* two kids if binary */ | struct { /* two kids if binary */ | |||
JSParseNode *left; | JSParseNode *left; | |||
JSParseNode *right; | JSParseNode *right; | |||
jsval val; /* switch case value */ | jsval val; /* switch case value */ | |||
skipping to change at line 235 | skipping to change at line 311 | |||
struct { /* one kid if unary */ | struct { /* one kid if unary */ | |||
JSParseNode *kid; | JSParseNode *kid; | |||
jsint num; /* -1 or sharp variable number */ | jsint num; /* -1 or sharp variable number */ | |||
} unary; | } unary; | |||
struct { /* name, labeled statement, etc. */ | struct { /* name, labeled statement, etc. */ | |||
JSAtom *atom; /* name or label atom, null if slot */ | JSAtom *atom; /* name or label atom, null if slot */ | |||
JSParseNode *expr; /* object or initializer */ | JSParseNode *expr; /* object or initializer */ | |||
jsint slot; /* -1 or arg or local var slot */ | jsint slot; /* -1 or arg or local var slot */ | |||
uintN attrs; /* attributes if local var or const */ | uintN attrs; /* attributes if local var or const */ | |||
} name; | } name; | |||
struct { | ||||
JSAtom *atom; /* first atom in pair */ | ||||
JSAtom *atom2; /* second atom in pair or null */ | ||||
} apair; | ||||
jsdouble dval; /* aligned numeric literal value */ | jsdouble dval; /* aligned numeric literal value */ | |||
} pn_u; | } pn_u; | |||
JSParseNode *pn_next; /* to align dval and pn_u on RISCs */ | JSParseNode *pn_next; /* to align dval and pn_u on RISCs */ | |||
JSTokenStream *pn_ts; /* token stream for error reports * | ||||
/ | ||||
JSAtom *pn_source; /* saved source for decompilation * | ||||
/ | ||||
}; | }; | |||
#define pn_funAtom pn_u.func.funAtom | #define pn_funAtom pn_u.func.funAtom | |||
#define pn_body pn_u.func.body | #define pn_body pn_u.func.body | |||
#define pn_flags pn_u.func.flags | #define pn_flags pn_u.func.flags | |||
#define pn_tryCount pn_u.func.tryCount | #define pn_tryCount pn_u.func.tryCount | |||
#define pn_head pn_u.list.head | #define pn_head pn_u.list.head | |||
#define pn_tail pn_u.list.tail | #define pn_tail pn_u.list.tail | |||
#define pn_count pn_u.list.count | #define pn_count pn_u.list.count | |||
#define pn_extra pn_u.list.extra | #define pn_extra pn_u.list.extra | |||
skipping to change at line 261 | skipping to change at line 343 | |||
#define pn_left pn_u.binary.left | #define pn_left pn_u.binary.left | |||
#define pn_right pn_u.binary.right | #define pn_right pn_u.binary.right | |||
#define pn_val pn_u.binary.val | #define pn_val pn_u.binary.val | |||
#define pn_kid pn_u.unary.kid | #define pn_kid pn_u.unary.kid | |||
#define pn_num pn_u.unary.num | #define pn_num pn_u.unary.num | |||
#define pn_atom pn_u.name.atom | #define pn_atom pn_u.name.atom | |||
#define pn_expr pn_u.name.expr | #define pn_expr pn_u.name.expr | |||
#define pn_slot pn_u.name.slot | #define pn_slot pn_u.name.slot | |||
#define pn_attrs pn_u.name.attrs | #define pn_attrs pn_u.name.attrs | |||
#define pn_dval pn_u.dval | #define pn_dval pn_u.dval | |||
#define pn_atom2 pn_u.apair.atom2 | ||||
/* PN_LIST pn_extra flags. */ | /* PN_LIST pn_extra flags. */ | |||
#define PNX_STRCAT 0x01 /* TOK_PLUS list has string term */ | #define PNX_STRCAT 0x01 /* TOK_PLUS list has string term */ | |||
#define PNX_CANTFOLD 0x02 /* TOK_PLUS list has unfoldable ter m */ | #define PNX_CANTFOLD 0x02 /* TOK_PLUS list has unfoldable ter m */ | |||
#define PNX_POPVAR 0x04 /* TOK_VAR last result needs poppin g */ | #define PNX_POPVAR 0x04 /* TOK_VAR last result needs poppin g */ | |||
#define PNX_FORINVAR 0x08 /* TOK_VAR is left kid of TOK_IN no de, | #define PNX_FORINVAR 0x08 /* TOK_VAR is left kid of TOK_IN no de, | |||
which is left kid of TOK_FOR */ | which is left kid of TOK_FOR */ | |||
#define PNX_ENDCOMMA 0x10 /* array literal has comma at end * / | #define PNX_ENDCOMMA 0x10 /* array literal has comma at end * / | |||
#define PNX_XMLROOT 0x20 /* top-most node in XML literal tre | ||||
e */ | ||||
#define PNX_GROUPINIT 0x40 /* var [a, b] = [c, d]; unit list * | ||||
/ | ||||
#define PNX_NEEDBRACES 0x80 /* braces necessary due to closure | ||||
*/ | ||||
/* | /* | |||
* Move pn2 into pn, preserving pn->pn_pos and pn->pn_offset and handing of f | * Move pn2 into pn, preserving pn->pn_pos and pn->pn_offset and handing of f | |||
* any kids in pn2->pn_u, by clearing pn2. | * any kids in pn2->pn_u, by clearing pn2. | |||
*/ | */ | |||
#define PN_MOVE_NODE(pn, pn2) \ | #define PN_MOVE_NODE(pn, pn2) \ | |||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
(pn)->pn_type = (pn2)->pn_type; \ | (pn)->pn_type = (pn2)->pn_type; \ | |||
(pn)->pn_op = (pn2)->pn_op; \ | (pn)->pn_op = (pn2)->pn_op; \ | |||
(pn)->pn_arity = (pn2)->pn_arity; \ | (pn)->pn_arity = (pn2)->pn_arity; \ | |||
skipping to change at line 307 | skipping to change at line 393 | |||
* Compute a pointer to the last JSParseNode element in a singly-linked lis t. | * Compute a pointer to the last JSParseNode element in a singly-linked lis t. | |||
* NB: list must be non-empty for correct PN_LAST usage! | * NB: list must be non-empty for correct PN_LAST usage! | |||
*/ | */ | |||
#define PN_LAST(list) \ | #define PN_LAST(list) \ | |||
((JSParseNode *)((char *)(list)->pn_tail - offsetof(JSParseNode, pn_nex t))) | ((JSParseNode *)((char *)(list)->pn_tail - offsetof(JSParseNode, pn_nex t))) | |||
#define PN_INIT_LIST(list) \ | #define PN_INIT_LIST(list) \ | |||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
(list)->pn_head = NULL; \ | (list)->pn_head = NULL; \ | |||
(list)->pn_tail = &(list)->pn_head; \ | (list)->pn_tail = &(list)->pn_head; \ | |||
(list)->pn_count = 0; \ | (list)->pn_count = (list)->pn_extra = 0; \ | |||
JS_END_MACRO | JS_END_MACRO | |||
#define PN_INIT_LIST_1(list, pn) \ | #define PN_INIT_LIST_1(list, pn) \ | |||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
(list)->pn_head = (pn); \ | (list)->pn_head = (pn); \ | |||
(list)->pn_tail = &(pn)->pn_next; \ | (list)->pn_tail = &(pn)->pn_next; \ | |||
(list)->pn_count = 1; \ | (list)->pn_count = 1; \ | |||
(list)->pn_extra = 0; \ | ||||
JS_END_MACRO | JS_END_MACRO | |||
#define PN_APPEND(list, pn) \ | #define PN_APPEND(list, pn) \ | |||
JS_BEGIN_MACRO \ | JS_BEGIN_MACRO \ | |||
*(list)->pn_tail = (pn); \ | *(list)->pn_tail = (pn); \ | |||
(list)->pn_tail = &(pn)->pn_next; \ | (list)->pn_tail = &(pn)->pn_next; \ | |||
(list)->pn_count++; \ | (list)->pn_count++; \ | |||
JS_END_MACRO | JS_END_MACRO | |||
/* | /* | |||
skipping to change at line 343 | skipping to change at line 430 | |||
extern JS_FRIEND_API(JSBool) | extern JS_FRIEND_API(JSBool) | |||
js_CompileTokenStream(JSContext *cx, JSObject *chain, JSTokenStream *ts, | js_CompileTokenStream(JSContext *cx, JSObject *chain, JSTokenStream *ts, | |||
JSCodeGenerator *cg); | JSCodeGenerator *cg); | |||
extern JSBool | extern JSBool | |||
js_CompileFunctionBody(JSContext *cx, JSTokenStream *ts, JSFunction *fun); | js_CompileFunctionBody(JSContext *cx, JSTokenStream *ts, JSFunction *fun); | |||
extern JSBool | extern JSBool | |||
js_FoldConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc); | js_FoldConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc); | |||
#if JS_HAS_XML_SUPPORT | ||||
JS_FRIEND_API(JSParseNode *) | ||||
js_ParseXMLTokenStream(JSContext *cx, JSObject *chain, JSTokenStream *ts, | ||||
JSBool allowList); | ||||
#endif | ||||
JS_END_EXTERN_C | JS_END_EXTERN_C | |||
#endif /* jsparse_h___ */ | #endif /* jsparse_h___ */ | |||
End of changes. 17 change blocks. | ||||
14 lines changed or deleted | 130 lines changed or added | |||
jsprvtd.h | jsprvtd.h | |||
---|---|---|---|---|
skipping to change at line 59 | skipping to change at line 59 | |||
* all .h files that include this file may use the same typedef name, wheth er | * all .h files that include this file may use the same typedef name, wheth er | |||
* declaring a pointer to struct type, or defining a member of struct type. | * declaring a pointer to struct type, or defining a member of struct type. | |||
* | * | |||
* A few fundamental scalar types are defined here too. Neither the scalar | * A few fundamental scalar types are defined here too. Neither the scalar | |||
* nor the struct typedefs should change much, therefore the nearly-global | * nor the struct typedefs should change much, therefore the nearly-global | |||
* make dependency induced by this file should not prove painful. | * make dependency induced by this file should not prove painful. | |||
*/ | */ | |||
#include "jspubtd.h" | #include "jspubtd.h" | |||
/* Internal identifier (jsid) macros. */ | ||||
#define JSID_ATOM 0x0 | ||||
#define JSID_INT 0x1 | ||||
#define JSID_OBJECT 0x2 | ||||
#define JSID_TAGMASK 0x3 | ||||
#define JSID_TAG(id) ((id) & JSID_TAGMASK) | ||||
#define JSID_SETTAG(id,t) ((id) | (t)) | ||||
#define JSID_CLRTAG(id) ((id) & ~(jsid)JSID_TAGMASK) | ||||
#define JSID_IS_ATOM(id) (JSID_TAG(id) == JSID_ATOM) | ||||
#define JSID_TO_ATOM(id) ((JSAtom *)(id)) | ||||
#define ATOM_TO_JSID(atom) ((jsid)(atom)) | ||||
#define ATOM_JSID_TO_JSVAL(id) ATOM_KEY(JSID_TO_ATOM(id)) | ||||
#define JSID_IS_INT(id) ((id) & JSID_INT) | ||||
#define JSID_TO_INT(id) ((jsint)(id) >> 1) | ||||
#define INT_TO_JSID(i) (((jsint)(i) << 1) | JSID_INT) | ||||
#define INT_JSID_TO_JSVAL(id) (id) | ||||
#define INT_JSVAL_TO_JSID(v) (v) | ||||
#define JSID_IS_OBJECT(id) (JSID_TAG(id) == JSID_OBJECT) | ||||
#define JSID_TO_OBJECT(id) ((JSObject *) JSID_CLRTAG(id)) | ||||
#define OBJECT_TO_JSID(obj) ((jsid)(obj) | JSID_OBJECT) | ||||
#define OBJECT_JSID_TO_JSVAL(id) OBJECT_TO_JSVAL(JSID_CLRTAG(id)) | ||||
#define OBJECT_JSVAL_TO_JSID(v) OBJECT_TO_JSID(JSVAL_TO_OBJECT(v)) | ||||
/* Scalar typedefs. */ | /* Scalar typedefs. */ | |||
typedef uint8 jsbytecode; | typedef uint8 jsbytecode; | |||
typedef uint8 jssrcnote; | typedef uint8 jssrcnote; | |||
typedef uint32 jsatomid; | typedef uint32 jsatomid; | |||
/* Struct typedefs. */ | /* Struct typedefs. */ | |||
typedef struct JSArgumentFormatMap JSArgumentFormatMap; | typedef struct JSArgumentFormatMap JSArgumentFormatMap; | |||
typedef struct JSCodeGenerator JSCodeGenerator; | typedef struct JSCodeGenerator JSCodeGenerator; | |||
typedef struct JSDependentString JSDependentString; | typedef struct JSDependentString JSDependentString; | |||
typedef struct JSGCLockHashEntry JSGCLockHashEntry; | ||||
typedef struct JSGCRootHashEntry JSGCRootHashEntry; | ||||
typedef struct JSGCThing JSGCThing; | typedef struct JSGCThing JSGCThing; | |||
typedef struct JSGenerator JSGenerator; | ||||
typedef struct JSParseNode JSParseNode; | typedef struct JSParseNode JSParseNode; | |||
typedef struct JSSharpObjectMap JSSharpObjectMap; | typedef struct JSSharpObjectMap JSSharpObjectMap; | |||
typedef struct JSThread JSThread; | ||||
typedef struct JSToken JSToken; | typedef struct JSToken JSToken; | |||
typedef struct JSTokenPos JSTokenPos; | typedef struct JSTokenPos JSTokenPos; | |||
typedef struct JSTokenPtr JSTokenPtr; | typedef struct JSTokenPtr JSTokenPtr; | |||
typedef struct JSTokenStream JSTokenStream; | typedef struct JSTokenStream JSTokenStream; | |||
typedef struct JSTreeContext JSTreeContext; | typedef struct JSTreeContext JSTreeContext; | |||
typedef struct JSTryNote JSTryNote; | typedef struct JSTryNote JSTryNote; | |||
/* Friend "Advanced API" typedefs. */ | /* Friend "Advanced API" typedefs. */ | |||
typedef struct JSAtom JSAtom; | typedef struct JSAtom JSAtom; | |||
typedef struct JSAtomList JSAtomList; | typedef struct JSAtomList JSAtomList; | |||
typedef struct JSAtomListElement JSAtomListElement; | typedef struct JSAtomListElement JSAtomListElement; | |||
typedef struct JSAtomMap JSAtomMap; | typedef struct JSAtomMap JSAtomMap; | |||
typedef struct JSAtomState JSAtomState; | typedef struct JSAtomState JSAtomState; | |||
typedef struct JSCodeSpec JSCodeSpec; | typedef struct JSCodeSpec JSCodeSpec; | |||
typedef struct JSPrinter JSPrinter; | typedef struct JSPrinter JSPrinter; | |||
typedef struct JSRegExp JSRegExp; | typedef struct JSRegExp JSRegExp; | |||
typedef struct JSRegExpStatics JSRegExpStatics; | typedef struct JSRegExpStatics JSRegExpStatics; | |||
typedef struct JSScope JSScope; | typedef struct JSScope JSScope; | |||
typedef struct JSScopeOps JSScopeOps; | typedef struct JSScopeOps JSScopeOps; | |||
typedef struct JSScopeProperty JSScopeProperty; | typedef struct JSScopeProperty JSScopeProperty; | |||
typedef struct JSStackFrame JSStackFrame; | ||||
typedef struct JSStackHeader JSStackHeader; | typedef struct JSStackHeader JSStackHeader; | |||
typedef struct JSStringBuffer JSStringBuffer; | ||||
typedef struct JSSubString JSSubString; | typedef struct JSSubString JSSubString; | |||
typedef struct JSXML JSXML; | ||||
typedef struct JSXMLNamespace JSXMLNamespace; | ||||
typedef struct JSXMLQName JSXMLQName; | ||||
typedef struct JSXMLArray JSXMLArray; | ||||
typedef struct JSXMLArrayCursor JSXMLArrayCursor; | ||||
/* "Friend" types used by jscntxt.h and jsdbgapi.h. */ | /* "Friend" types used by jscntxt.h and jsdbgapi.h. */ | |||
typedef enum JSTrapStatus { | typedef enum JSTrapStatus { | |||
JSTRAP_ERROR, | JSTRAP_ERROR, | |||
JSTRAP_CONTINUE, | JSTRAP_CONTINUE, | |||
JSTRAP_RETURN, | JSTRAP_RETURN, | |||
JSTRAP_THROW, | JSTRAP_THROW, | |||
JSTRAP_LIMIT | JSTRAP_LIMIT | |||
} JSTrapStatus; | } JSTrapStatus; | |||
typedef JSTrapStatus | typedef JSTrapStatus | |||
(* JS_DLL_CALLBACK JSTrapHandler)(JSContext *cx, JSScript *script, jsbyteco | (* JS_DLL_CALLBACK JSTrapHandler)(JSContext *cx, JSScript *script, | |||
de *pc, | jsbytecode *pc, jsval *rval, void *closur | |||
jsval *rval, void *closure); | e); | |||
typedef JSBool | typedef JSBool | |||
(* JS_DLL_CALLBACK JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsval id, | (* JS_DLL_CALLBACK JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsval id, | |||
jsval old, jsval *newp, void *closu re); | jsval old, jsval *newp, void *closu re); | |||
/* called just after script creation */ | /* called just after script creation */ | |||
typedef void | typedef void | |||
(* JS_DLL_CALLBACK JSNewScriptHook)(JSContext *cx, | (* JS_DLL_CALLBACK JSNewScriptHook)(JSContext *cx, | |||
const char *filename, /* URL of script */ | const char *filename, /* URL of script */ | |||
uintN lineno, /* line script s tarts */ | uintN lineno, /* first line */ | |||
JSScript *script, | JSScript *script, | |||
JSFunction *fun, | JSFunction *fun, | |||
void *callerdata); | void *callerdata); | |||
/* called just before script destruction */ | /* called just before script destruction */ | |||
typedef void | typedef void | |||
(* JS_DLL_CALLBACK JSDestroyScriptHook)(JSContext *cx, | (* JS_DLL_CALLBACK JSDestroyScriptHook)(JSContext *cx, | |||
JSScript *script, | JSScript *script, | |||
void *callerdata); | void *callerdata); | |||
typedef void | typedef void | |||
(* JS_DLL_CALLBACK JSSourceHandler)(const char *filename, uintN lineno, | (* JS_DLL_CALLBACK JSSourceHandler)(const char *filename, uintN lineno, | |||
jschar *str, size_t length, | jschar *str, size_t length, | |||
void **listenerTSData, void *closure); | void **listenerTSData, void *closure); | |||
/* | /* | |||
* This hook captures high level script execution and function calls | * This hook captures high level script execution and function calls (JS or | |||
* (JS or native). | * native). It is used by JS_SetExecuteHook to hook top level scripts and | |||
* It is used by JS_SetExecuteHook to hook top level scripts and by | by | |||
* JS_SetCallHook to hook function calls. | * JS_SetCallHook to hook function calls. It will get called twice per scr | |||
* It will get called twice per script or function call: | ipt | |||
* just before execution begins and just after it finishes. In both cases | * or function call: just before execution begins and just after it finishe | |||
* the 'current' frame is that of the executing code. | s. | |||
* | * In both cases the 'current' frame is that of the executing code. | |||
* The 'before' param is JS_TRUE for the hook invocation before the executio | * | |||
n | * The 'before' param is JS_TRUE for the hook invocation before the executi | |||
* and JS_FALSE for the invocation after the code has run. | on | |||
* | * and JS_FALSE for the invocation after the code has run. | |||
* The 'ok' param is significant only on the post execution invocation to | * | |||
* signify whether or not the code completed 'normally'. | * The 'ok' param is significant only on the post execution invocation to | |||
* | * signify whether or not the code completed 'normally'. | |||
* The 'closure' param is as passed to JS_SetExecuteHook or JS_SetCallHook | * | |||
* for the 'before'invocation, but is whatever value is returned from that | * The 'closure' param is as passed to JS_SetExecuteHook or JS_SetCallHook | |||
* invocation for the 'after' invocation. Thus, the hook implementor *could* | * for the 'before'invocation, but is whatever value is returned from that | |||
* allocate a stucture in the 'before' invocation and return a pointer | * invocation for the 'after' invocation. Thus, the hook implementor *could | |||
* to that structure. The pointer would then be handed to the hook for | * | |||
* the 'after' invocation. Alternately, the 'before' could just return the | * allocate a structure in the 'before' invocation and return a pointer to | |||
* same value as in 'closure' to cause the 'after' invocation to be called | that | |||
* with the same 'closure' value as the 'before'. | * structure. The pointer would then be handed to the hook for the 'after' | |||
* | * invocation. Alternately, the 'before' could just return the same value a | |||
* Returning NULL in the 'before' hook will cause the 'after' hook to | s | |||
* NOT be called. | * in 'closure' to cause the 'after' invocation to be called with the same | |||
*/ | * 'closure' value as the 'before'. | |||
* | ||||
* Returning NULL in the 'before' hook will cause the 'after' hook *not* to | ||||
* be called. | ||||
*/ | ||||
typedef void * | typedef void * | |||
(* JS_DLL_CALLBACK JSInterpreterHook)(JSContext *cx, JSStackFrame *fp, JSBo ol before, | (* JS_DLL_CALLBACK JSInterpreterHook)(JSContext *cx, JSStackFrame *fp, JSBo ol before, | |||
JSBool *ok, void *closure); | JSBool *ok, void *closure); | |||
typedef void | typedef void | |||
(* JS_DLL_CALLBACK JSObjectHook)(JSContext *cx, JSObject *obj, JSBool isNew , | (* JS_DLL_CALLBACK JSObjectHook)(JSContext *cx, JSObject *obj, JSBool isNew , | |||
void *closure); | void *closure); | |||
typedef JSBool | typedef JSBool | |||
(* JS_DLL_CALLBACK JSDebugErrorHook)(JSContext *cx, const char *message, | (* JS_DLL_CALLBACK JSDebugErrorHook)(JSContext *cx, const char *message, | |||
End of changes. 10 change blocks. | ||||
35 lines changed or deleted | 69 lines changed or added | |||
jspubtd.h | jspubtd.h | |||
---|---|---|---|---|
skipping to change at line 72 | skipping to change at line 72 | |||
* #if expressions. | * #if expressions. | |||
*/ | */ | |||
typedef enum JSVersion { | typedef enum JSVersion { | |||
JSVERSION_1_0 = 100, | JSVERSION_1_0 = 100, | |||
JSVERSION_1_1 = 110, | JSVERSION_1_1 = 110, | |||
JSVERSION_1_2 = 120, | JSVERSION_1_2 = 120, | |||
JSVERSION_1_3 = 130, | JSVERSION_1_3 = 130, | |||
JSVERSION_1_4 = 140, | JSVERSION_1_4 = 140, | |||
JSVERSION_ECMA_3 = 148, | JSVERSION_ECMA_3 = 148, | |||
JSVERSION_1_5 = 150, | JSVERSION_1_5 = 150, | |||
JSVERSION_1_6 = 160, | ||||
JSVERSION_1_7 = 170, | ||||
JSVERSION_DEFAULT = 0, | JSVERSION_DEFAULT = 0, | |||
JSVERSION_UNKNOWN = -1 | JSVERSION_UNKNOWN = -1 | |||
} JSVersion; | } JSVersion; | |||
#define JSVERSION_IS_ECMA(version) \ | #define JSVERSION_IS_ECMA(version) \ | |||
((version) == JSVERSION_DEFAULT || (version) >= JSVERSION_1_3) | ((version) == JSVERSION_DEFAULT || (version) >= JSVERSION_1_3) | |||
/* Result of typeof operator enumeration. */ | /* Result of typeof operator enumeration. */ | |||
typedef enum JSType { | typedef enum JSType { | |||
JSTYPE_VOID, /* undefined */ | JSTYPE_VOID, /* undefined */ | |||
JSTYPE_OBJECT, /* object */ | JSTYPE_OBJECT, /* object */ | |||
JSTYPE_FUNCTION, /* function */ | JSTYPE_FUNCTION, /* function */ | |||
JSTYPE_STRING, /* string */ | JSTYPE_STRING, /* string */ | |||
JSTYPE_NUMBER, /* number */ | JSTYPE_NUMBER, /* number */ | |||
JSTYPE_BOOLEAN, /* boolean */ | JSTYPE_BOOLEAN, /* boolean */ | |||
JSTYPE_NULL, /* null */ | ||||
JSTYPE_XML, /* xml object */ | ||||
JSTYPE_LIMIT | JSTYPE_LIMIT | |||
} JSType; | } JSType; | |||
/* Dense index into cached prototypes and class atoms for standard objects. | ||||
*/ | ||||
typedef enum JSProtoKey { | ||||
#define JS_PROTO(name,code,init) JSProto_##name = code, | ||||
#include "jsproto.tbl" | ||||
#undef JS_PROTO | ||||
JSProto_LIMIT | ||||
} JSProtoKey; | ||||
/* JSObjectOps.checkAccess mode enumeration. */ | /* JSObjectOps.checkAccess mode enumeration. */ | |||
typedef enum JSAccessMode { | typedef enum JSAccessMode { | |||
JSACC_PROTO = 0, /* XXXbe redundant w.r.t. id */ | JSACC_PROTO = 0, /* XXXbe redundant w.r.t. id */ | |||
JSACC_PARENT = 1, /* XXXbe redundant w.r.t. id */ | JSACC_PARENT = 1, /* XXXbe redundant w.r.t. id */ | |||
JSACC_IMPORT = 2, /* import foo.bar */ | JSACC_IMPORT = 2, /* import foo.bar */ | |||
JSACC_WATCH = 3, /* a watchpoint on object foo for id 'bar' */ | JSACC_WATCH = 3, /* a watchpoint on object foo for id 'bar' */ | |||
JSACC_READ = 4, /* a "get" of foo.bar */ | JSACC_READ = 4, /* a "get" of foo.bar */ | |||
JSACC_WRITE = 8, /* a "set" of foo.bar = baz */ | JSACC_WRITE = 8, /* a "set" of foo.bar = baz */ | |||
JSACC_LIMIT | JSACC_LIMIT | |||
} JSAccessMode; | } JSAccessMode; | |||
skipping to change at line 115 | skipping to change at line 127 | |||
* iterator function that has type JSNewEnumerate. | * iterator function that has type JSNewEnumerate. | |||
*/ | */ | |||
typedef enum JSIterateOp { | typedef enum JSIterateOp { | |||
JSENUMERATE_INIT, /* Create new iterator state */ | JSENUMERATE_INIT, /* Create new iterator state */ | |||
JSENUMERATE_NEXT, /* Iterate once */ | JSENUMERATE_NEXT, /* Iterate once */ | |||
JSENUMERATE_DESTROY /* Destroy iterator state */ | JSENUMERATE_DESTROY /* Destroy iterator state */ | |||
} JSIterateOp; | } JSIterateOp; | |||
/* Struct typedefs. */ | /* Struct typedefs. */ | |||
typedef struct JSClass JSClass; | typedef struct JSClass JSClass; | |||
typedef struct JSExtendedClass JSExtendedClass; | ||||
typedef struct JSConstDoubleSpec JSConstDoubleSpec; | typedef struct JSConstDoubleSpec JSConstDoubleSpec; | |||
typedef struct JSContext JSContext; | typedef struct JSContext JSContext; | |||
typedef struct JSErrorReport JSErrorReport; | typedef struct JSErrorReport JSErrorReport; | |||
typedef struct JSFunction JSFunction; | typedef struct JSFunction JSFunction; | |||
typedef struct JSFunctionSpec JSFunctionSpec; | typedef struct JSFunctionSpec JSFunctionSpec; | |||
typedef struct JSIdArray JSIdArray; | typedef struct JSIdArray JSIdArray; | |||
typedef struct JSProperty JSProperty; | typedef struct JSProperty JSProperty; | |||
typedef struct JSPropertySpec JSPropertySpec; | typedef struct JSPropertySpec JSPropertySpec; | |||
typedef struct JSObject JSObject; | typedef struct JSObject JSObject; | |||
typedef struct JSObjectMap JSObjectMap; | typedef struct JSObjectMap JSObjectMap; | |||
typedef struct JSObjectOps JSObjectOps; | typedef struct JSObjectOps JSObjectOps; | |||
typedef struct JSXMLObjectOps JSXMLObjectOps; | ||||
typedef struct JSRuntime JSRuntime; | typedef struct JSRuntime JSRuntime; | |||
typedef struct JSRuntime JSTaskState; /* XXX deprecated name */ | typedef struct JSRuntime JSTaskState; /* XXX deprecated name */ | |||
typedef struct JSScript JSScript; | typedef struct JSScript JSScript; | |||
typedef struct JSStackFrame JSStackFrame; | ||||
typedef struct JSString JSString; | typedef struct JSString JSString; | |||
typedef struct JSXDRState JSXDRState; | typedef struct JSXDRState JSXDRState; | |||
typedef struct JSExceptionState JSExceptionState; | typedef struct JSExceptionState JSExceptionState; | |||
typedef struct JSLocaleCallbacks JSLocaleCallbacks; | typedef struct JSLocaleCallbacks JSLocaleCallbacks; | |||
/* JSClass (and JSObjectOps where appropriate) function pointer typedefs. * / | /* JSClass (and JSObjectOps where appropriate) function pointer typedefs. * / | |||
/* | /* | |||
* Add, delete, get or set a property named by id in obj. Note the jsval i d | * Add, delete, get or set a property named by id in obj. Note the jsval i d | |||
* type -- id may be a string (Unicode property identifier) or an int (elem ent | * type -- id may be a string (Unicode property identifier) or an int (elem ent | |||
* index). The *vp out parameter, on success, is the new property value af ter | * index). The *vp out parameter, on success, is the new property value af ter | |||
* an add, get, or set. After a successful delete, *vp is JSVAL_FALSE iff | * an add, get, or set. After a successful delete, *vp is JSVAL_FALSE iff | |||
skipping to change at line 206 | skipping to change at line 221 | |||
* NB: JSNewResolveOp provides a cheaper way to resolve lazy properties. | * NB: JSNewResolveOp provides a cheaper way to resolve lazy properties. | |||
*/ | */ | |||
typedef JSBool | typedef JSBool | |||
(* JS_DLL_CALLBACK JSResolveOp)(JSContext *cx, JSObject *obj, jsval id); | (* JS_DLL_CALLBACK JSResolveOp)(JSContext *cx, JSObject *obj, jsval id); | |||
/* | /* | |||
* Like JSResolveOp, but flags provide contextual information as follows: | * Like JSResolveOp, but flags provide contextual information as follows: | |||
* | * | |||
* JSRESOLVE_QUALIFIED a qualified property id: obj.id or obj[id], not i d | * JSRESOLVE_QUALIFIED a qualified property id: obj.id or obj[id], not i d | |||
* JSRESOLVE_ASSIGNING obj[id] is on the left-hand side of an assignment | * JSRESOLVE_ASSIGNING obj[id] is on the left-hand side of an assignment | |||
* JSRESOLVE_DETECTING 'if (o.p)...' or similar detection opcode sequenc | ||||
e | ||||
* JSRESOLVE_DECLARING var, const, or function prolog declaration opcode | ||||
* JSRESOLVE_CLASSNAME class name used when constructing | ||||
* | * | |||
* The *objp out parameter, on success, should be null to indicate that id | * The *objp out parameter, on success, should be null to indicate that id | |||
* was not resolved; and non-null, referring to obj or one of its prototype s, | * was not resolved; and non-null, referring to obj or one of its prototype s, | |||
* if id was resolved. | * if id was resolved. | |||
* | * | |||
* This hook instead of JSResolveOp is called via the JSClass.resolve membe r | * This hook instead of JSResolveOp is called via the JSClass.resolve membe r | |||
* if JSCLASS_NEW_RESOLVE is set in JSClass.flags. | * if JSCLASS_NEW_RESOLVE is set in JSClass.flags. | |||
* | * | |||
* Setting JSCLASS_NEW_RESOLVE and JSCLASS_NEW_RESOLVE_GETS_START further | * Setting JSCLASS_NEW_RESOLVE and JSCLASS_NEW_RESOLVE_GETS_START further | |||
* extends this hook by passing in the starting object on the prototype cha in | * extends this hook by passing in the starting object on the prototype cha in | |||
skipping to change at line 266 | skipping to change at line 284 | |||
* to discover the set of high-level object operations to use for new objec ts | * to discover the set of high-level object operations to use for new objec ts | |||
* of the given class. All native objects have a JSClass, which is stored as | * of the given class. All native objects have a JSClass, which is stored as | |||
* a private (int-tagged) pointer in obj->slots[JSSLOT_CLASS]. In contrast , | * a private (int-tagged) pointer in obj->slots[JSSLOT_CLASS]. In contrast , | |||
* all native and host objects have a JSObjectMap at obj->map, which may be | * all native and host objects have a JSObjectMap at obj->map, which may be | |||
* shared among a number of objects, and which contains the JSObjectOps *op s | * shared among a number of objects, and which contains the JSObjectOps *op s | |||
* pointer used to dispatch object operations from API calls. | * pointer used to dispatch object operations from API calls. | |||
* | * | |||
* Thus JSClass (which pre-dates JSObjectOps in the API) provides a low-lev el | * Thus JSClass (which pre-dates JSObjectOps in the API) provides a low-lev el | |||
* interface to class-specific code and data, while JSObjectOps allows for a | * interface to class-specific code and data, while JSObjectOps allows for a | |||
* higher level of operation, which does not use the object's class except to | * higher level of operation, which does not use the object's class except to | |||
* find the class's JSObjectOps struct, by calling clasp->getObjectOps. | * find the class's JSObjectOps struct, by calling clasp->getObjectOps, and | |||
to | ||||
* finalize the object. | ||||
* | * | |||
* If this seems backwards, that's because it is! API compatibility requir es | * If this seems backwards, that's because it is! API compatibility requir es | |||
* a JSClass *clasp parameter to JS_NewObject, etc. Most host objects do n ot | * a JSClass *clasp parameter to JS_NewObject, etc. Most host objects do n ot | |||
* need to implement the larger JSObjectOps, and can share the common JSSco pe | * need to implement the larger JSObjectOps, and can share the common JSSco pe | |||
* code and data used by the native (js_ObjectOps, see jsobj.c) ops. | * code and data used by the native (js_ObjectOps, see jsobj.c) ops. | |||
* | ||||
* Further extension to preserve API compatibility: if this function return | ||||
s | ||||
* a pointer to JSXMLObjectOps.base, not to JSObjectOps, then the engine ca | ||||
lls | ||||
* extended hooks needed for E4X. | ||||
*/ | */ | |||
typedef JSObjectOps * | typedef JSObjectOps * | |||
(* JS_DLL_CALLBACK JSGetObjectOps)(JSContext *cx, JSClass *clasp); | (* JS_DLL_CALLBACK JSGetObjectOps)(JSContext *cx, JSClass *clasp); | |||
/* | /* | |||
* JSClass.checkAccess type: check whether obj[id] may be accessed per mode , | * JSClass.checkAccess type: check whether obj[id] may be accessed per mode , | |||
* returning false on error/exception, true on success with obj[id]'s last- got | * returning false on error/exception, true on success with obj[id]'s last- got | |||
* value in *vp, and its attributes in *attrsp. As for JSPropertyOp above, id | * value in *vp, and its attributes in *attrsp. As for JSPropertyOp above, id | |||
* is either a string or an int jsval. | * is either a string or an int jsval. | |||
* | * | |||
skipping to change at line 390 | skipping to change at line 413 | |||
* that bypasses id re-lookup. In any case, a non-null *propp result after a | * that bypasses id re-lookup. In any case, a non-null *propp result after a | |||
* successful lookup must be dropped via JSObjectOps.dropProperty. | * successful lookup must be dropped via JSObjectOps.dropProperty. | |||
* | * | |||
* NB: successful return with non-null *propp means the implementation may | * NB: successful return with non-null *propp means the implementation may | |||
* have locked *objp and added a reference count associated with *propp, so | * have locked *objp and added a reference count associated with *propp, so | |||
* callers should not risk deadlock by nesting or interleaving other lookup s | * callers should not risk deadlock by nesting or interleaving other lookup s | |||
* or any obj-bearing ops before dropping *propp. | * or any obj-bearing ops before dropping *propp. | |||
*/ | */ | |||
typedef JSBool | typedef JSBool | |||
(* JS_DLL_CALLBACK JSLookupPropOp)(JSContext *cx, JSObject *obj, jsid id, | (* JS_DLL_CALLBACK JSLookupPropOp)(JSContext *cx, JSObject *obj, jsid id, | |||
JSObject **objp, JSProperty **propp | JSObject **objp, JSProperty **propp); | |||
#if defined JS_THREADSAFE && defined DEBUG | ||||
, const char *file, uintN line | ||||
#endif | ||||
); | ||||
/* | /* | |||
* Define obj[id], a direct property of obj named id, having the given init ial | * Define obj[id], a direct property of obj named id, having the given init ial | |||
* value, with the specified getter, setter, and attributes. If the propp out | * value, with the specified getter, setter, and attributes. If the propp out | |||
* param is non-null, *propp on successful return contains an opaque proper ty | * param is non-null, *propp on successful return contains an opaque proper ty | |||
* pointer usable as a speedup hint with JSAttributesOp. But note that pro pp | * pointer usable as a speedup hint with JSAttributesOp. But note that pro pp | |||
* may be null, indicating that the caller is not interested in recovering an | * may be null, indicating that the caller is not interested in recovering an | |||
* opaque pointer to the newly-defined property. | * opaque pointer to the newly-defined property. | |||
* | * | |||
* If propp is non-null and JSDefinePropOp succeeds, its caller must be sur e | * If propp is non-null and JSDefinePropOp succeeds, its caller must be sur e | |||
skipping to change at line 494 | skipping to change at line 513 | |||
* class, and optionally, the private data slot. | * class, and optionally, the private data slot. | |||
*/ | */ | |||
typedef jsval | typedef jsval | |||
(* JS_DLL_CALLBACK JSGetRequiredSlotOp)(JSContext *cx, JSObject *obj, | (* JS_DLL_CALLBACK JSGetRequiredSlotOp)(JSContext *cx, JSObject *obj, | |||
uint32 slot); | uint32 slot); | |||
typedef JSBool | typedef JSBool | |||
(* JS_DLL_CALLBACK JSSetRequiredSlotOp)(JSContext *cx, JSObject *obj, | (* JS_DLL_CALLBACK JSSetRequiredSlotOp)(JSContext *cx, JSObject *obj, | |||
uint32 slot, jsval v); | uint32 slot, jsval v); | |||
typedef JSObject * | ||||
(* JS_DLL_CALLBACK JSGetMethodOp)(JSContext *cx, JSObject *obj, jsid id, | ||||
jsval *vp); | ||||
typedef JSBool | ||||
(* JS_DLL_CALLBACK JSSetMethodOp)(JSContext *cx, JSObject *obj, jsid id, | ||||
jsval *vp); | ||||
typedef JSBool | ||||
(* JS_DLL_CALLBACK JSEnumerateValuesOp)(JSContext *cx, JSObject *obj, | ||||
JSIterateOp enum_op, | ||||
jsval *statep, jsid *idp, jsval *vp | ||||
); | ||||
typedef JSBool | ||||
(* JS_DLL_CALLBACK JSEqualityOp)(JSContext *cx, JSObject *obj, jsval v, | ||||
JSBool *bp); | ||||
typedef JSBool | ||||
(* JS_DLL_CALLBACK JSConcatenateOp)(JSContext *cx, JSObject *obj, jsval v, | ||||
jsval *vp); | ||||
/* Typedef for native functions called by the JS VM. */ | /* Typedef for native functions called by the JS VM. */ | |||
typedef JSBool | typedef JSBool | |||
(* JS_DLL_CALLBACK JSNative)(JSContext *cx, JSObject *obj, uintN argc, | (* JS_DLL_CALLBACK JSNative)(JSContext *cx, JSObject *obj, uintN argc, | |||
jsval *argv, jsval *rval); | jsval *argv, jsval *rval); | |||
/* Callbacks and their arguments. */ | /* Callbacks and their arguments. */ | |||
typedef enum JSContextOp { | ||||
JSCONTEXT_NEW, | ||||
JSCONTEXT_DESTROY | ||||
} JSContextOp; | ||||
/* | ||||
* The possible values for contextOp when the runtime calls the callback ar | ||||
e: | ||||
* JSCONTEXT_NEW JS_NewContext succesfully created a new JSContext | ||||
* instance. The callback can initialize the instance | ||||
as | ||||
* required. If the callback returns false, the instan | ||||
ce | ||||
* will be destroyed and JS_NewContext returns null. I | ||||
n | ||||
* this case the callback is not called again. | ||||
* JSCONTEXT_DESTROY One of JS_DestroyContext* methods is called. The | ||||
* callback may perform its own cleanup and must alway | ||||
s | ||||
* return true. | ||||
* Any other value For future compatibility the callback must do nothi | ||||
ng | ||||
* and return true in this case. | ||||
*/ | ||||
typedef JSBool | ||||
(* JS_DLL_CALLBACK JSContextCallback)(JSContext *cx, uintN contextOp); | ||||
typedef enum JSGCStatus { | typedef enum JSGCStatus { | |||
JSGC_BEGIN, | JSGC_BEGIN, | |||
JSGC_END, | JSGC_END, | |||
JSGC_MARK_END, | JSGC_MARK_END, | |||
JSGC_FINALIZE_END | JSGC_FINALIZE_END | |||
} JSGCStatus; | } JSGCStatus; | |||
typedef JSBool | typedef JSBool | |||
(* JS_DLL_CALLBACK JSGCCallback)(JSContext *cx, JSGCStatus status); | (* JS_DLL_CALLBACK JSGCCallback)(JSContext *cx, JSGCStatus status); | |||
typedef JSBool | typedef JSBool | |||
(* JS_DLL_CALLBACK JSBranchCallback)(JSContext *cx, JSScript *script); | (* JS_DLL_CALLBACK JSBranchCallback)(JSContext *cx, JSScript *script); | |||
typedef void | typedef void | |||
(* JS_DLL_CALLBACK JSErrorReporter)(JSContext *cx, const char *message, | (* JS_DLL_CALLBACK JSErrorReporter)(JSContext *cx, const char *message, | |||
JSErrorReport *report); | JSErrorReport *report); | |||
/* | ||||
* Possible exception types. These types are part of a JSErrorFormatString | ||||
* structure. They define which error to throw in case of a runtime error. | ||||
* JSEXN_NONE marks an unthrowable error. | ||||
*/ | ||||
typedef enum JSExnType { | ||||
JSEXN_NONE = -1, | ||||
JSEXN_ERR, | ||||
JSEXN_INTERNALERR, | ||||
JSEXN_EVALERR, | ||||
JSEXN_RANGEERR, | ||||
JSEXN_REFERENCEERR, | ||||
JSEXN_SYNTAXERR, | ||||
JSEXN_TYPEERR, | ||||
JSEXN_URIERR, | ||||
JSEXN_LIMIT | ||||
} JSExnType; | ||||
typedef struct JSErrorFormatString { | typedef struct JSErrorFormatString { | |||
/* The error format string (UTF-8 if JS_C_STRINGS_ARE_UTF8 is defined). */ | ||||
const char *format; | const char *format; | |||
uintN argCount; | ||||
/* The number of arguments to expand in the formatted error message. */ | ||||
uint16 argCount; | ||||
/* One of the JSExnType constants above. */ | ||||
int16 exnType; | ||||
} JSErrorFormatString; | } JSErrorFormatString; | |||
typedef const JSErrorFormatString * | typedef const JSErrorFormatString * | |||
(* JS_DLL_CALLBACK JSErrorCallback)(void *userRef, const char *locale, | (* JS_DLL_CALLBACK JSErrorCallback)(void *userRef, const char *locale, | |||
const uintN errorNumber); | const uintN errorNumber); | |||
#ifdef va_start | #ifdef va_start | |||
#define JS_ARGUMENT_FORMATTER_DEFINED 1 | #define JS_ARGUMENT_FORMATTER_DEFINED 1 | |||
typedef JSBool | typedef JSBool | |||
(* JS_DLL_CALLBACK JSArgumentFormatter)(JSContext *cx, const char *format, | (* JS_DLL_CALLBACK JSArgumentFormatter)(JSContext *cx, const char *format, | |||
JSBool fromJS, jsval **vpp, | JSBool fromJS, jsval **vpp, | |||
va_list *app); | va_list *app); | |||
#endif | #endif | |||
End of changes. 18 change blocks. | ||||
10 lines changed or deleted | 107 lines changed or added | |||
jsregexp.h | jsregexp.h | |||
---|---|---|---|---|
skipping to change at line 81 | skipping to change at line 81 | |||
* use of the class converts the source representation into a bitmap. | * use of the class converts the source representation into a bitmap. | |||
* | * | |||
*/ | */ | |||
typedef struct RECharSet { | typedef struct RECharSet { | |||
JSPackedBool converted; | JSPackedBool converted; | |||
JSPackedBool sense; | JSPackedBool sense; | |||
uint16 length; | uint16 length; | |||
union { | union { | |||
uint8 *bits; | uint8 *bits; | |||
struct { | struct { | |||
uint16 startIndex; | size_t startIndex; | |||
uint16 length; | size_t length; | |||
} src; | } src; | |||
} u; | } u; | |||
} RECharSet; | } RECharSet; | |||
/* | /* | |||
* This macro is safe because moreParens is guaranteed to be allocated and big | * This macro is safe because moreParens is guaranteed to be allocated and big | |||
* enough to hold parenCount, or else be null when parenCount is 0. | * enough to hold parenCount, or else be null when parenCount is 0. | |||
*/ | */ | |||
#define REGEXP_PAREN_SUBSTRING(res, num) \ | #define REGEXP_PAREN_SUBSTRING(res, num) \ | |||
(((jsuint)(num) < (jsuint)(res)->parenCount) \ | (((jsuint)(num) < (jsuint)(res)->parenCount) \ | |||
skipping to change at line 105 | skipping to change at line 105 | |||
: &(res)->moreParens[(num) - 9] \ | : &(res)->moreParens[(num) - 9] \ | |||
: &js_EmptySubString) | : &js_EmptySubString) | |||
typedef struct RENode RENode; | typedef struct RENode RENode; | |||
struct JSRegExp { | struct JSRegExp { | |||
jsrefcount nrefs; /* reference count */ | jsrefcount nrefs; /* reference count */ | |||
uint16 flags; /* flags, see jsapi.h's JSREG_* defines */ | uint16 flags; /* flags, see jsapi.h's JSREG_* defines */ | |||
uint16 cloneIndex; /* index in fp->vars or funobj->slots of | uint16 cloneIndex; /* index in fp->vars or funobj->slots of | |||
cloned regexp object */ | cloned regexp object */ | |||
uint16 parenCount; /* number of parenthesized submatches */ | size_t parenCount; /* number of parenthesized submatches */ | |||
uint16 classCount; /* count [...] bitmaps */ | size_t classCount; /* count [...] bitmaps */ | |||
RECharSet *classList; /* list of [...] bitmaps */ | RECharSet *classList; /* list of [...] bitmaps */ | |||
JSString *source; /* locked source string, sans // */ | JSString *source; /* locked source string, sans // */ | |||
jsbytecode program[1]; /* regular expression bytecode */ | jsbytecode program[1]; /* regular expression bytecode */ | |||
}; | }; | |||
extern JSRegExp * | extern JSRegExp * | |||
js_NewRegExp(JSContext *cx, JSTokenStream *ts, | js_NewRegExp(JSContext *cx, JSTokenStream *ts, | |||
JSString *str, uintN flags, JSBool flat); | JSString *str, uintN flags, JSBool flat); | |||
extern JSRegExp * | extern JSRegExp * | |||
js_NewRegExpOpt(JSContext *cx, JSTokenStream *ts, | js_NewRegExpOpt(JSContext *cx, JSTokenStream *ts, | |||
JSString *str, JSString *opt, JSBool flat); | JSString *str, JSString *opt, JSBool flat); | |||
#define HOLD_REGEXP(cx, re) JS_ATOMIC_INCREMENT(&(re)->nrefs) | ||||
#define DROP_REGEXP(cx, re) js_DestroyRegExp(cx, re) | ||||
extern void | extern void | |||
js_DestroyRegExp(JSContext *cx, JSRegExp *re); | js_DestroyRegExp(JSContext *cx, JSRegExp *re); | |||
/* | /* | |||
* Execute re on input str at *indexp, returning null in *rval on mismatch. | * Execute re on input str at *indexp, returning null in *rval on mismatch. | |||
* On match, return true if test is true, otherwise return an array object. | * On match, return true if test is true, otherwise return an array object. | |||
* Update *indexp and cx->regExpStatics always on match. | * Update *indexp and cx->regExpStatics always on match. | |||
*/ | */ | |||
extern JSBool | extern JSBool | |||
js_ExecuteRegExp(JSContext *cx, JSRegExp *re, JSString *str, size_t *indexp , | js_ExecuteRegExp(JSContext *cx, JSRegExp *re, JSString *str, size_t *indexp , | |||
JSBool test, jsval *rval); | JSBool test, jsval *rval); | |||
/* | /* | |||
* These two add and remove GC roots, respectively, so their calls must be | * These two add and remove GC roots, respectively, so their calls must be | |||
* well-ordered. | * well-ordered. | |||
*/ | */ | |||
extern JSBool | extern JSBool | |||
js_InitRegExpStatics(JSContext *cx, JSRegExpStatics *res); | js_InitRegExpStatics(JSContext *cx, JSRegExpStatics *res); | |||
extern void | extern void | |||
js_FreeRegExpStatics(JSContext *cx, JSRegExpStatics *res); | js_FreeRegExpStatics(JSContext *cx, JSRegExpStatics *res); | |||
End of changes. 4 change blocks. | ||||
5 lines changed or deleted | 8 lines changed or added | |||
jsscan.h | jsscan.h | |||
---|---|---|---|---|
skipping to change at line 47 | skipping to change at line 47 | |||
* | * | |||
* ***** END LICENSE BLOCK ***** */ | * ***** END LICENSE BLOCK ***** */ | |||
#ifndef jsscan_h___ | #ifndef jsscan_h___ | |||
#define jsscan_h___ | #define jsscan_h___ | |||
/* | /* | |||
* JS lexical scanner interface. | * JS lexical scanner interface. | |||
*/ | */ | |||
#include <stddef.h> | #include <stddef.h> | |||
#include <stdio.h> | #include <stdio.h> | |||
#include "jsconfig.h" | ||||
#include "jsopcode.h" | #include "jsopcode.h" | |||
#include "jsprvtd.h" | #include "jsprvtd.h" | |||
#include "jspubtd.h" | #include "jspubtd.h" | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
#define JS_KEYWORD(keyword, type, op, version) \ | ||||
extern const char js_##keyword##_str[]; | ||||
#include "jskeyword.tbl" | ||||
#undef JS_KEYWORD | ||||
typedef enum JSTokenType { | typedef enum JSTokenType { | |||
TOK_ERROR = -1, /* well-known as the only code < EO F */ | TOK_ERROR = -1, /* well-known as the only code < EO F */ | |||
TOK_EOF = 0, /* end of file */ | TOK_EOF = 0, /* end of file */ | |||
TOK_EOL = 1, /* end of line */ | TOK_EOL = 1, /* end of line */ | |||
TOK_SEMI = 2, /* semicolon */ | TOK_SEMI = 2, /* semicolon */ | |||
TOK_COMMA = 3, /* comma operator */ | TOK_COMMA = 3, /* comma operator */ | |||
TOK_ASSIGN = 4, /* assignment ops (= += -= etc.) */ | TOK_ASSIGN = 4, /* assignment ops (= += -= etc.) */ | |||
TOK_HOOK = 5, TOK_COLON = 6, /* conditional (?:) */ | TOK_HOOK = 5, TOK_COLON = 6, /* conditional (?:) */ | |||
TOK_OR = 7, /* logical or (||) */ | TOK_OR = 7, /* logical or (||) */ | |||
TOK_AND = 8, /* logical and (&&) */ | TOK_AND = 8, /* logical and (&&) */ | |||
skipping to change at line 110 | skipping to change at line 116 | |||
TOK_NEW = 51, /* new keyword */ | TOK_NEW = 51, /* new keyword */ | |||
TOK_DELETE = 52, /* delete keyword */ | TOK_DELETE = 52, /* delete keyword */ | |||
TOK_DEFSHARP = 53, /* #n= for object/array initializer s */ | TOK_DEFSHARP = 53, /* #n= for object/array initializer s */ | |||
TOK_USESHARP = 54, /* #n# for object/array initializer s */ | TOK_USESHARP = 54, /* #n# for object/array initializer s */ | |||
TOK_TRY = 55, /* try keyword */ | TOK_TRY = 55, /* try keyword */ | |||
TOK_CATCH = 56, /* catch keyword */ | TOK_CATCH = 56, /* catch keyword */ | |||
TOK_FINALLY = 57, /* finally keyword */ | TOK_FINALLY = 57, /* finally keyword */ | |||
TOK_THROW = 58, /* throw keyword */ | TOK_THROW = 58, /* throw keyword */ | |||
TOK_INSTANCEOF = 59, /* instanceof keyword */ | TOK_INSTANCEOF = 59, /* instanceof keyword */ | |||
TOK_DEBUGGER = 60, /* debugger keyword */ | TOK_DEBUGGER = 60, /* debugger keyword */ | |||
TOK_XMLSTAGO = 61, /* XML start tag open (<) */ | ||||
TOK_XMLETAGO = 62, /* XML end tag open (</) */ | ||||
TOK_XMLPTAGC = 63, /* XML point tag close (/>) */ | ||||
TOK_XMLTAGC = 64, /* XML start or end tag close (>) * | ||||
/ | ||||
TOK_XMLNAME = 65, /* XML start-tag non-final fragment | ||||
*/ | ||||
TOK_XMLATTR = 66, /* XML quoted attribute value */ | ||||
TOK_XMLSPACE = 67, /* XML whitespace */ | ||||
TOK_XMLTEXT = 68, /* XML text */ | ||||
TOK_XMLCOMMENT = 69, /* XML comment */ | ||||
TOK_XMLCDATA = 70, /* XML CDATA section */ | ||||
TOK_XMLPI = 71, /* XML processing instruction */ | ||||
TOK_AT = 72, /* XML attribute op (@) */ | ||||
TOK_DBLCOLON = 73, /* namespace qualified name op (::) | ||||
*/ | ||||
TOK_ANYNAME = 74, /* XML AnyName singleton (*) */ | ||||
TOK_DBLDOT = 75, /* XML descendant op (..) */ | ||||
TOK_FILTER = 76, /* XML filtering predicate op (.()) | ||||
*/ | ||||
TOK_XMLELEM = 77, /* XML element node type (no token) | ||||
*/ | ||||
TOK_XMLLIST = 78, /* XML list node type (no token) */ | ||||
TOK_YIELD = 79, /* yield from generator function */ | ||||
TOK_ARRAYCOMP = 80, /* array comprehension initialiser | ||||
*/ | ||||
TOK_ARRAYPUSH = 81, /* array push within comprehension | ||||
*/ | ||||
TOK_LEXICALSCOPE = 82, /* block scope AST node label */ | ||||
TOK_LET = 83, /* let keyword */ | ||||
TOK_BODY = 84, /* synthetic body of function with | ||||
destructuring formal parameters | ||||
*/ | ||||
TOK_RESERVED, /* reserved keywords */ | TOK_RESERVED, /* reserved keywords */ | |||
TOK_LIMIT /* domain size */ | TOK_LIMIT /* domain size */ | |||
} JSTokenType; | } JSTokenType; | |||
#define IS_PRIMARY_TOKEN(tt) \ | #define IS_PRIMARY_TOKEN(tt) \ | |||
((uintN)((tt) - TOK_NAME) <= (uintN)(TOK_PRIMARY - TOK_NAME)) | ((uintN)((tt) - TOK_NAME) <= (uintN)(TOK_PRIMARY - TOK_NAME)) | |||
#define TOKEN_TYPE_IS_XML(tt) \ | ||||
(tt == TOK_AT || tt == TOK_DBLCOLON || tt == TOK_ANYNAME) | ||||
#if JS_HAS_BLOCK_SCOPE | ||||
# define TOKEN_TYPE_IS_DECL(tt) ((tt) == TOK_VAR || (tt) == TOK_LET) | ||||
#else | ||||
# define TOKEN_TYPE_IS_DECL(tt) ((tt) == TOK_VAR) | ||||
#endif | ||||
struct JSStringBuffer { | ||||
jschar *base; | ||||
jschar *limit; /* length limit for quick bounds check */ | ||||
jschar *ptr; /* slot for next non-NUL char to store */ | ||||
void *data; | ||||
JSBool (*grow)(JSStringBuffer *sb, size_t newlength); | ||||
void (*free)(JSStringBuffer *sb); | ||||
}; | ||||
#define STRING_BUFFER_ERROR_BASE ((jschar *) 1) | ||||
#define STRING_BUFFER_OK(sb) ((sb)->base != STRING_BUFFER_ERROR_ | ||||
BASE) | ||||
#define STRING_BUFFER_OFFSET(sb) ((sb)->ptr -(sb)->base) | ||||
extern void | ||||
js_InitStringBuffer(JSStringBuffer *sb); | ||||
extern void | ||||
js_FinishStringBuffer(JSStringBuffer *sb); | ||||
extern void | ||||
js_AppendChar(JSStringBuffer *sb, jschar c); | ||||
extern void | ||||
js_RepeatChar(JSStringBuffer *sb, jschar c, uintN count); | ||||
extern void | ||||
js_AppendCString(JSStringBuffer *sb, const char *asciiz); | ||||
extern void | ||||
js_AppendJSString(JSStringBuffer *sb, JSString *str); | ||||
struct JSTokenPtr { | struct JSTokenPtr { | |||
uint16 index; /* index of char in physical line * / | uint16 index; /* index of char in physical line * / | |||
uint16 lineno; /* physical line number */ | uint16 lineno; /* physical line number */ | |||
}; | }; | |||
struct JSTokenPos { | struct JSTokenPos { | |||
JSTokenPtr begin; /* first character and line of toke n */ | JSTokenPtr begin; /* first character and line of toke n */ | |||
JSTokenPtr end; /* index 1 past last char, last lin e */ | JSTokenPtr end; /* index 1 past last char, last lin e */ | |||
}; | }; | |||
struct JSToken { | struct JSToken { | |||
JSTokenType type; /* char value or above enumerator * / | JSTokenType type; /* char value or above enumerator * / | |||
JSTokenPos pos; /* token position in file */ | JSTokenPos pos; /* token position in file */ | |||
jschar *ptr; /* beginning of token in line buffe r */ | jschar *ptr; /* beginning of token in line buffe r */ | |||
union { | union { | |||
struct { | struct { /* non-numeric literal */ | |||
JSOp op; /* operator, for minimal parser */ | JSOp op; /* operator, for minimal parser */ | |||
JSAtom *atom; /* atom table entry */ | JSAtom *atom; /* atom table entry */ | |||
} s; | } s; | |||
struct { /* atom pair, for XML PIs */ | ||||
JSAtom *atom2; /* auxiliary atom table entry */ | ||||
JSAtom *atom; /* main atom table entry */ | ||||
} p; | ||||
jsdouble dval; /* floating point number */ | jsdouble dval; /* floating point number */ | |||
} u; | } u; | |||
}; | }; | |||
#define t_op u.s.op | #define t_op u.s.op | |||
#define t_atom u.s.atom | #define t_atom u.s.atom | |||
#define t_atom2 u.p.atom2 | ||||
#define t_dval u.dval | #define t_dval u.dval | |||
typedef struct JSTokenBuf { | typedef struct JSTokenBuf { | |||
jschar *base; /* base of line or stream buffer */ | jschar *base; /* base of line or stream buffer */ | |||
jschar *limit; /* limit for quick bounds check */ | jschar *limit; /* limit for quick bounds check */ | |||
jschar *ptr; /* next char to get, or slot to use */ | jschar *ptr; /* next char to get, or slot to use */ | |||
} JSTokenBuf; | } JSTokenBuf; | |||
#define JS_LINE_LIMIT 256 /* logical line buffer size limit - - | #define JS_LINE_LIMIT 256 /* logical line buffer size limit - - | |||
physical line length is unlimite d */ | physical line length is unlimite d */ | |||
skipping to change at line 167 | skipping to change at line 243 | |||
uintN cursor; /* index of last parsed token */ | uintN cursor; /* index of last parsed token */ | |||
uintN lookahead; /* count of lookahead tokens */ | uintN lookahead; /* count of lookahead tokens */ | |||
uintN lineno; /* current line number */ | uintN lineno; /* current line number */ | |||
uintN ungetpos; /* next free char slot in ungetbuf */ | uintN ungetpos; /* next free char slot in ungetbuf */ | |||
jschar ungetbuf[6]; /* at most 6, for \uXXXX lookahead */ | jschar ungetbuf[6]; /* at most 6, for \uXXXX lookahead */ | |||
uintN flags; /* flags -- see below */ | uintN flags; /* flags -- see below */ | |||
ptrdiff_t linelen; /* physical linebuf segment length */ | ptrdiff_t linelen; /* physical linebuf segment length */ | |||
ptrdiff_t linepos; /* linebuf offset in physical line */ | ptrdiff_t linepos; /* linebuf offset in physical line */ | |||
JSTokenBuf linebuf; /* line buffer for diagnostics */ | JSTokenBuf linebuf; /* line buffer for diagnostics */ | |||
JSTokenBuf userbuf; /* user input buffer if !file */ | JSTokenBuf userbuf; /* user input buffer if !file */ | |||
JSTokenBuf tokenbuf; /* current token string buffer */ | JSStringBuffer tokenbuf; /* current token string buffer */ | |||
const char *filename; /* input filename or null */ | const char *filename; /* input filename or null */ | |||
FILE *file; /* stdio stream if reading from fil e */ | FILE *file; /* stdio stream if reading from fil e */ | |||
JSPrincipals *principals; /* principals associated with sourc e */ | JSPrincipals *principals; /* principals associated with sourc e */ | |||
JSSourceHandler listener; /* callback for source; eg debugger */ | JSSourceHandler listener; /* callback for source; eg debugger */ | |||
void *listenerData; /* listener 'this' data */ | void *listenerData; /* listener 'this' data */ | |||
void *listenerTSData;/* listener data for this TokenStre am */ | void *listenerTSData;/* listener data for this TokenStre am */ | |||
jschar *saveEOL; /* save next end of line in userbuf , to | jschar *saveEOL; /* save next end of line in userbuf , to | |||
optimize for very long lines */ | optimize for very long lines */ | |||
}; | }; | |||
skipping to change at line 190 | skipping to change at line 266 | |||
/* JSTokenStream flags */ | /* JSTokenStream flags */ | |||
#define TSF_ERROR 0x01 /* fatal error while compiling */ | #define TSF_ERROR 0x01 /* fatal error while compiling */ | |||
#define TSF_EOF 0x02 /* hit end of file */ | #define TSF_EOF 0x02 /* hit end of file */ | |||
#define TSF_NEWLINES 0x04 /* tokenize newlines */ | #define TSF_NEWLINES 0x04 /* tokenize newlines */ | |||
#define TSF_OPERAND 0x08 /* looking for operand, not operato r */ | #define TSF_OPERAND 0x08 /* looking for operand, not operato r */ | |||
#define TSF_NLFLAG 0x20 /* last linebuf ended with \n */ | #define TSF_NLFLAG 0x20 /* last linebuf ended with \n */ | |||
#define TSF_CRFLAG 0x40 /* linebuf would have ended with \r */ | #define TSF_CRFLAG 0x40 /* linebuf would have ended with \r */ | |||
#define TSF_DIRTYLINE 0x80 /* non-whitespace since start of li ne */ | #define TSF_DIRTYLINE 0x80 /* non-whitespace since start of li ne */ | |||
#define TSF_OWNFILENAME 0x100 /* ts->filename is malloc'd */ | #define TSF_OWNFILENAME 0x100 /* ts->filename is malloc'd */ | |||
#define TSF_XMLTAGMODE 0x200 /* scanning within an XML tag in E4 | ||||
X */ | ||||
#define TSF_XMLTEXTMODE 0x400 /* scanning XMLText terminal from E | ||||
4X */ | ||||
#define TSF_XMLONLYMODE 0x800 /* don't scan {expr} within text/ta | ||||
g */ | ||||
/* Flag indicating unexpected end of input, i.e. TOK_EOF not at top-level. | ||||
*/ | ||||
#define TSF_UNEXPECTED_EOF 0x1000 | ||||
/* | ||||
* To handle the hard case of contiguous HTML comments, we want to clear th | ||||
e | ||||
* TSF_DIRTYINPUT flag at the end of each such comment. But we'd rather no | ||||
t | ||||
* scan for --> within every //-style comment unless we have to. So we set | ||||
* TSF_IN_HTML_COMMENT when a <!-- is scanned as an HTML begin-comment, and | ||||
* clear it (and TSF_DIRTYINPUT) when we scan --> either on a clean line, o | ||||
r | ||||
* only if (ts->flags & TSF_IN_HTML_COMMENT), in a //-style comment. | ||||
* | ||||
* This still works as before given a malformed comment hiding hack such as | ||||
: | ||||
* | ||||
* <script> | ||||
* <!-- comment hiding hack #1 | ||||
* code goes here | ||||
* // --> oops, markup for script-unaware browsers goes here! | ||||
* </script> | ||||
* | ||||
* It does not cope with malformed comment hiding hacks where --> is hidden | ||||
* by C-style comments, or on a dirty line. Such cases are already broken. | ||||
*/ | ||||
#define TSF_IN_HTML_COMMENT 0x2000 | ||||
/* Ignore keywords and return TOK_NAME instead to the parser. */ | ||||
#define TSF_KEYWORD_IS_NAME 0x4000 | ||||
/* Unicode separators that are treated as line terminators, in addition to \n, \r */ | /* Unicode separators that are treated as line terminators, in addition to \n, \r */ | |||
#define LINE_SEPARATOR 0x2028 | #define LINE_SEPARATOR 0x2028 | |||
#define PARA_SEPARATOR 0x2029 | #define PARA_SEPARATOR 0x2029 | |||
/* | /* | |||
* Create a new token stream, either from an input buffer or from a file. | * Create a new token stream, either from an input buffer or from a file. | |||
* Return null on file-open or memory-allocation failure. | * Return null on file-open or memory-allocation failure. | |||
* | * | |||
* NB: All of js_New{,Buffer,File}TokenStream() return a pointer to transie nt | * NB: All of js_New{,Buffer,File}TokenStream() return a pointer to transie nt | |||
skipping to change at line 216 | skipping to change at line 322 | |||
extern JS_FRIEND_API(JSTokenStream *) | extern JS_FRIEND_API(JSTokenStream *) | |||
js_NewBufferTokenStream(JSContext *cx, const jschar *base, size_t length); | js_NewBufferTokenStream(JSContext *cx, const jschar *base, size_t length); | |||
extern JS_FRIEND_API(JSTokenStream *) | extern JS_FRIEND_API(JSTokenStream *) | |||
js_NewFileTokenStream(JSContext *cx, const char *filename, FILE *defaultfp) ; | js_NewFileTokenStream(JSContext *cx, const char *filename, FILE *defaultfp) ; | |||
extern JS_FRIEND_API(JSBool) | extern JS_FRIEND_API(JSBool) | |||
js_CloseTokenStream(JSContext *cx, JSTokenStream *ts); | js_CloseTokenStream(JSContext *cx, JSTokenStream *ts); | |||
extern JS_FRIEND_API(int) | ||||
js_fgets(char *buf, int size, FILE *file); | ||||
/* | /* | |||
* Initialize the scanner, installing JS keywords into cx's global scope. | * If the given char array forms JavaScript keyword, return corresponding | |||
* token. Otherwise return TOK_EOF. | ||||
*/ | */ | |||
extern JSBool | extern JSTokenType | |||
js_InitScanner(JSContext *cx); | js_CheckKeyword(const jschar *chars, size_t length); | |||
#define js_IsKeyword(chars, length) \ | ||||
(js_CheckKeyword(chars, length) != TOK_EOF) | ||||
/* | /* | |||
* Friend-exported API entry point to call a mapping function on each reser ved | * Friend-exported API entry point to call a mapping function on each reser ved | |||
* identifier in the scanner's keyword table. | * identifier in the scanner's keyword table. | |||
*/ | */ | |||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | |||
js_MapKeywords(void (*mapfun)(const char *)); | js_MapKeywords(void (*mapfun)(const char *)); | |||
/* | /* | |||
* Report a compile-time error by its number, using ts or cg to show contex t. | * Report a compile-time error by its number, using ts or cg to show contex t. | |||
* Return true for a warning, false for an error. | * Return true for a warning, false for an error. | |||
*/ | */ | |||
extern JSBool | extern JSBool | |||
js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, | js_ReportCompileErrorNumber(JSContext *cx, void *handle, uintN flags, | |||
JSCodeGenerator *cg, uintN flags, | uintN errorNumber, ...); | |||
const uintN errorNumber, ...); | ||||
extern JSBool | ||||
js_ReportCompileErrorNumberUC(JSContext *cx, void *handle, uintN flags, | ||||
uintN errorNumber, ...); | ||||
/* Steal some JSREPORT_* bits (see jsapi.h) to tell handle's type. */ | ||||
#define JSREPORT_HANDLE 0x300 | ||||
#define JSREPORT_TS 0x000 | ||||
#define JSREPORT_CG 0x100 | ||||
#define JSREPORT_PN 0x200 | ||||
/* | /* | |||
* Look ahead one token and return its type. | * Look ahead one token and return its type. | |||
*/ | */ | |||
extern JSTokenType | extern JSTokenType | |||
js_PeekToken(JSContext *cx, JSTokenStream *ts); | js_PeekToken(JSContext *cx, JSTokenStream *ts); | |||
extern JSTokenType | extern JSTokenType | |||
js_PeekTokenSameLine(JSContext *cx, JSTokenStream *ts); | js_PeekTokenSameLine(JSContext *cx, JSTokenStream *ts); | |||
End of changes. 13 change blocks. | ||||
8 lines changed or deleted | 147 lines changed or added | |||
jsscope.h | jsscope.h | |||
---|---|---|---|---|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | /* -*- 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 ***** | * ***** BEGIN LICENSE BLOCK ***** | |||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | |||
* | * | |||
* The contents of this file are subject to the Mozilla Public License Vers ion | * The contents of this file are subject to the Mozilla Public License Vers ion | |||
* 1.1 (the "License"); you may not use this file except in compliance with | * 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 | * the License. You may obtain a copy of the License at | |||
* http://www.mozilla.org/MPL/ | * http://www.mozilla.org/MPL/ | |||
* | * | |||
* Software distributed under the License is distributed on an "AS IS" basi s, | * Software distributed under the License is distributed on an "AS IS" basi s, | |||
skipping to change at line 204 | skipping to change at line 205 | |||
* allocating scope->table, we leave it null while initializing all the oth er | * allocating scope->table, we leave it null while initializing all the oth er | |||
* scope members as if it were non-null and minimal-length. Until a proper ty | * scope members as if it were non-null and minimal-length. Until a proper ty | |||
* is added that crosses the threshold of 6 or more entries for hashing, or | * is added that crosses the threshold of 6 or more entries for hashing, or | |||
* until a "middle delete" occurs, we use linear search from scope->lastPro p | * until a "middle delete" occurs, we use linear search from scope->lastPro p | |||
* to find a given id, and save on the space overhead of a hash table. | * to find a given id, and save on the space overhead of a hash table. | |||
*/ | */ | |||
struct JSScope { | struct JSScope { | |||
JSObjectMap map; /* base class state */ | JSObjectMap map; /* base class state */ | |||
JSObject *object; /* object that owns this scope */ | JSObject *object; /* object that owns this scope */ | |||
uint16 flags; /* flags, see below */ | uint8 flags; /* flags, see below */ | |||
int16 hashShift; /* multiplicative hash shift */ | int8 hashShift; /* multiplicative hash shift */ | |||
uint16 spare; /* reserved */ | ||||
uint32 entryCount; /* number of entries in table */ | uint32 entryCount; /* number of entries in table */ | |||
uint32 removedCount; /* removed entry sentinels in table */ | uint32 removedCount; /* removed entry sentinels in table */ | |||
JSScopeProperty **table; /* table of ptrs to shared tree nod es */ | JSScopeProperty **table; /* table of ptrs to shared tree nod es */ | |||
JSScopeProperty *lastProp; /* pointer to last property added * / | JSScopeProperty *lastProp; /* pointer to last property added * / | |||
#ifdef JS_THREADSAFE | #ifdef JS_THREADSAFE | |||
JSContext *ownercx; /* creating context, NULL if shared */ | JSContext *ownercx; /* creating context, NULL if shared */ | |||
JSThinLock lock; /* binary semaphore protecting scop e */ | JSThinLock lock; /* binary semaphore protecting scop e */ | |||
union { /* union lockful and lock-free stat e: */ | union { /* union lockful and lock-free stat e: */ | |||
jsrefcount count; /* lock entry count for reentrancy */ | jsrefcount count; /* lock entry count for reentrancy */ | |||
JSScope *link; /* next link in rt->scopeSharingTod o */ | JSScope *link; /* next link in rt->scopeSharingTod o */ | |||
skipping to change at line 293 | skipping to change at line 295 | |||
#define SPROP_STORE_PRESERVING_COLLISION(spp, sprop) \ | #define SPROP_STORE_PRESERVING_COLLISION(spp, sprop) \ | |||
(*(spp) = (JSScopeProperty *) ((jsuword)(sprop) \ | (*(spp) = (JSScopeProperty *) ((jsuword)(sprop) \ | |||
| SPROP_HAD_COLLISION(*(spp)))) | | SPROP_HAD_COLLISION(*(spp)))) | |||
/* Bits stored in sprop->flags. */ | /* Bits stored in sprop->flags. */ | |||
#define SPROP_MARK 0x01 | #define SPROP_MARK 0x01 | |||
#define SPROP_IS_DUPLICATE 0x02 | #define SPROP_IS_DUPLICATE 0x02 | |||
#define SPROP_IS_ALIAS 0x04 | #define SPROP_IS_ALIAS 0x04 | |||
#define SPROP_HAS_SHORTID 0x08 | #define SPROP_HAS_SHORTID 0x08 | |||
#define SPROP_IS_HIDDEN 0x10 /* a normally-hidden proper | ||||
ty, | ||||
e.g., function arg or va | ||||
r */ | ||||
/* | /* | |||
* If SPROP_HAS_SHORTID is set in sprop->flags, we use sprop->shortid rathe r | * If SPROP_HAS_SHORTID is set in sprop->flags, we use sprop->shortid rathe r | |||
* than id when calling sprop's getter or setter. | * than id when calling sprop's getter or setter. | |||
*/ | */ | |||
#define SPROP_USERID(sprop) \ | #define SPROP_USERID(sprop) \ | |||
(((sprop)->flags & SPROP_HAS_SHORTID) ? INT_TO_JSVAL((sprop)->shortid) \ | (((sprop)->flags & SPROP_HAS_SHORTID) ? INT_TO_JSVAL((sprop)->shortid) \ | |||
: ID_TO_VALUE((sprop)->id)) | : ID_TO_VALUE((sprop)->id)) | |||
#define SPROP_INVALID_SLOT 0xffffffff | #define SPROP_INVALID_SLOT 0xffffffff | |||
#define SPROP_HAS_VALID_SLOT(sprop, scope) | #define SLOT_IN_SCOPE(slot,scope) ((slot) < (scope)->map.freeslot) | |||
\ | #define SPROP_HAS_VALID_SLOT(sprop,scope) SLOT_IN_SCOPE((sprop)->slot, scop | |||
((sprop)->slot < (scope)->map.freeslot) | e) | |||
#define SPROP_HAS_STUB_GETTER(sprop) (!(sprop)->getter) | #define SPROP_HAS_STUB_GETTER(sprop) (!(sprop)->getter) | |||
#define SPROP_HAS_STUB_SETTER(sprop) (!(sprop)->setter) | #define SPROP_HAS_STUB_SETTER(sprop) (!(sprop)->setter) | |||
#define SPROP_CALL_GETTER(cx,sprop,getter,obj,obj2,vp) | /* | |||
\ | * NB: SPROP_GET must not be called if SPROP_HAS_STUB_GETTER(sprop). | |||
(!(getter) || | */ | |||
\ | ||||
(getter)(cx, OBJ_THIS_OBJECT(cx,obj), SPROP_USERID(sprop), vp)) | ||||
#define SPROP_CALL_SETTER(cx,sprop,setter,obj,obj2,vp) | ||||
\ | ||||
(!(setter) || | ||||
\ | ||||
(setter)(cx, OBJ_THIS_OBJECT(cx,obj), SPROP_USERID(sprop), vp)) | ||||
#define SPROP_GET(cx,sprop,obj,obj2,vp) \ | #define SPROP_GET(cx,sprop,obj,obj2,vp) \ | |||
(((sprop)->attrs & JSPROP_GETTER) \ | (((sprop)->attrs & JSPROP_GETTER) \ | |||
? js_InternalGetOrSet(cx, obj, (sprop)->id, \ | ? js_InternalGetOrSet(cx, obj, (sprop)->id, \ | |||
OBJECT_TO_JSVAL((sprop)->getter), JSACC_READ, \ | OBJECT_TO_JSVAL((sprop)->getter), JSACC_READ, \ | |||
0, 0, vp) \ | 0, 0, vp) \ | |||
: SPROP_CALL_GETTER(cx, sprop, (sprop)->getter, obj, obj2, vp)) | : (sprop)->getter(cx, OBJ_THIS_OBJECT(cx,obj), SPROP_USERID(sprop), vp )) | |||
/* | ||||
* NB: SPROP_SET must not be called if (SPROP_HAS_STUB_SETTER(sprop) && | ||||
* !(sprop->attrs & JSPROP_GETTER)). | ||||
*/ | ||||
#define SPROP_SET(cx,sprop,obj,obj2,vp) \ | #define SPROP_SET(cx,sprop,obj,obj2,vp) \ | |||
(((sprop)->attrs & JSPROP_SETTER) \ | (((sprop)->attrs & JSPROP_SETTER) \ | |||
? js_InternalGetOrSet(cx, obj, (sprop)->id, \ | ? js_InternalGetOrSet(cx, obj, (sprop)->id, \ | |||
OBJECT_TO_JSVAL((sprop)->setter), JSACC_WRITE, \ | OBJECT_TO_JSVAL((sprop)->setter), JSACC_WRITE, \ | |||
1, vp, vp) \ | 1, vp, vp) \ | |||
: ((sprop)->attrs & JSPROP_GETTER) \ | : ((sprop)->attrs & JSPROP_GETTER) \ | |||
? (JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, \ | ? (JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, \ | |||
JSMSG_GETTER_ONLY, NULL), JS_FALSE) \ | JSMSG_GETTER_ONLY, NULL), JS_FALSE) \ | |||
: SPROP_CALL_SETTER(cx, sprop, (sprop)->setter, obj, obj2, vp)) | : (sprop)->setter(cx, OBJ_THIS_OBJECT(cx,obj), SPROP_USERID(sprop), vp )) | |||
/* Macro for common expression to test for shared permanent attributes. */ | /* Macro for common expression to test for shared permanent attributes. */ | |||
#define SPROP_IS_SHARED_PERMANENT(sprop) \ | #define SPROP_IS_SHARED_PERMANENT(sprop) \ | |||
((~(sprop)->attrs & (JSPROP_SHARED | JSPROP_PERMANENT)) == 0) | ((~(sprop)->attrs & (JSPROP_SHARED | JSPROP_PERMANENT)) == 0) | |||
extern JSScope * | extern JSScope * | |||
js_GetMutableScope(JSContext *cx, JSObject *obj); | js_GetMutableScope(JSContext *cx, JSObject *obj); | |||
extern JSScope * | extern JSScope * | |||
js_NewScope(JSContext *cx, jsrefcount nrefs, JSObjectOps *ops, JSClass *cla sp, | js_NewScope(JSContext *cx, jsrefcount nrefs, JSObjectOps *ops, JSClass *cla sp, | |||
JSObject *obj); | JSObject *obj); | |||
extern void | extern void | |||
js_DestroyScope(JSContext *cx, JSScope *scope); | js_DestroyScope(JSContext *cx, JSScope *scope); | |||
#define ID_TO_VALUE(id) (((id) & JSVAL_INT) ? id : ATOM_KEY((JSAtom *)(id)) | #define ID_TO_VALUE(id) (JSID_IS_ATOM(id) ? ATOM_JSID_TO_JSVAL(id) : | |||
) | \ | |||
#define HASH_ID(id) (((id) & JSVAL_INT) | JSID_IS_OBJECT(id) ? OBJECT_JSID_TO_JSVAL(id) : | |||
\ | \ | |||
? (jsatomid) JSVAL_TO_INT(id) | (jsval)(id)) | |||
\ | #define HASH_ID(id) (JSID_IS_ATOM(id) ? JSID_TO_ATOM(id)->number : | |||
: ((JSAtom *)id)->number) | \ | |||
JSID_IS_OBJECT(id) ? (jsatomid) JSID_CLRTAG(id) : | ||||
\ | ||||
(jsatomid) JSID_TO_INT(id)) | ||||
extern JS_FRIEND_API(JSScopeProperty **) | extern JS_FRIEND_API(JSScopeProperty **) | |||
js_SearchScope(JSScope *scope, jsid id, JSBool adding); | js_SearchScope(JSScope *scope, jsid id, JSBool adding); | |||
#define SCOPE_GET_PROPERTY(scope, id) \ | #define SCOPE_GET_PROPERTY(scope, id) \ | |||
SPROP_FETCH(js_SearchScope(scope, id, JS_FALSE)) | SPROP_FETCH(js_SearchScope(scope, id, JS_FALSE)) | |||
#define SCOPE_HAS_PROPERTY(scope, sprop) \ | #define SCOPE_HAS_PROPERTY(scope, sprop) \ | |||
(SCOPE_GET_PROPERTY(scope, (sprop)->id) == (sprop)) | (SCOPE_GET_PROPERTY(scope, (sprop)->id) == (sprop)) | |||
skipping to change at line 378 | skipping to change at line 384 | |||
js_ChangeScopePropertyAttrs(JSContext *cx, JSScope *scope, | js_ChangeScopePropertyAttrs(JSContext *cx, JSScope *scope, | |||
JSScopeProperty *sprop, uintN attrs, uintN mask , | JSScopeProperty *sprop, uintN attrs, uintN mask , | |||
JSPropertyOp getter, JSPropertyOp setter); | JSPropertyOp getter, JSPropertyOp setter); | |||
extern JSBool | extern JSBool | |||
js_RemoveScopeProperty(JSContext *cx, JSScope *scope, jsid id); | js_RemoveScopeProperty(JSContext *cx, JSScope *scope, jsid id); | |||
extern void | extern void | |||
js_ClearScope(JSContext *cx, JSScope *scope); | js_ClearScope(JSContext *cx, JSScope *scope); | |||
#define MARK_SCOPE_PROPERTY(sprop) ((sprop)->flags |= SPROP_MARK) | /* | |||
* These macros used to inline short code sequences, but they grew over tim | ||||
e. | ||||
* We retain them for internal backward compatibility, and in case one or b | ||||
oth | ||||
* ever shrink to inline-able size. | ||||
*/ | ||||
#define MARK_ID(cx,id) js_MarkId(cx, id) | ||||
#define MARK_SCOPE_PROPERTY(cx,sprop) js_MarkScopeProperty(cx, sprop) | ||||
extern void | ||||
js_MarkId(JSContext *cx, jsid id); | ||||
extern void | ||||
js_MarkScopeProperty(JSContext *cx, JSScopeProperty *sprop); | ||||
extern void | extern void | |||
js_SweepScopeProperties(JSRuntime *rt); | js_SweepScopeProperties(JSRuntime *rt); | |||
extern JSBool | extern JSBool | |||
js_InitPropertyTree(JSRuntime *rt); | js_InitPropertyTree(JSRuntime *rt); | |||
extern void | extern void | |||
js_FinishPropertyTree(JSRuntime *rt); | js_FinishPropertyTree(JSRuntime *rt); | |||
End of changes. 10 change blocks. | ||||
26 lines changed or deleted | 45 lines changed or added | |||
jsscript.h | jsscript.h | |||
---|---|---|---|---|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | /* -*- 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 ***** | * ***** BEGIN LICENSE BLOCK ***** | |||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | |||
* | * | |||
* The contents of this file are subject to the Mozilla Public License Vers ion | * The contents of this file are subject to the Mozilla Public License Vers ion | |||
* 1.1 (the "License"); you may not use this file except in compliance with | * 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 | * the License. You may obtain a copy of the License at | |||
* http://www.mozilla.org/MPL/ | * http://www.mozilla.org/MPL/ | |||
* | * | |||
* Software distributed under the License is distributed on an "AS IS" basi s, | * Software distributed under the License is distributed on an "AS IS" basi s, | |||
skipping to change at line 53 | skipping to change at line 54 | |||
* JS script descriptor. | * JS script descriptor. | |||
*/ | */ | |||
#include "jsatom.h" | #include "jsatom.h" | |||
#include "jsprvtd.h" | #include "jsprvtd.h" | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
/* | /* | |||
* Exception handling runtime information. | * Exception handling runtime information. | |||
* | * | |||
* All fields except length are code offsets, relative to the beginning of | * All fields except length are code offsets relative to the main entry poi | |||
* the script. If script->trynotes is not null, it points to a vector of | nt | |||
* of the script. If script->trynotes is not null, it points to a vector o | ||||
f | ||||
* these structs terminated by one with catchStart == 0. | * these structs terminated by one with catchStart == 0. | |||
*/ | */ | |||
struct JSTryNote { | struct JSTryNote { | |||
ptrdiff_t start; /* start of try statement */ | ptrdiff_t start; /* start of try statement */ | |||
ptrdiff_t length; /* count of try statement bytecodes */ | ptrdiff_t length; /* count of try statement bytecodes */ | |||
ptrdiff_t catchStart; /* start of catch block (0 if end) */ | ptrdiff_t catchStart; /* start of catch block (0 if end) */ | |||
}; | }; | |||
#define JSTRYNOTE_GRAIN sizeof(ptrdiff_t) | #define JSTRYNOTE_GRAIN sizeof(ptrdiff_t) | |||
#define JSTRYNOTE_ALIGNMASK (JSTRYNOTE_GRAIN - 1) | #define JSTRYNOTE_ALIGNMASK (JSTRYNOTE_GRAIN - 1) | |||
skipping to change at line 100 | skipping to change at line 101 | |||
if (off_ >= 0) { \ | if (off_ >= 0) { \ | |||
while ((jsuword)(off_ - tn_->start) >= (jsuword)tn_->length ) \ | while ((jsuword)(off_ - tn_->start) >= (jsuword)tn_->length ) \ | |||
++tn_; \ | ++tn_; \ | |||
if (tn_->catchStart) \ | if (tn_->catchStart) \ | |||
catchpc_ = (script)->main + tn_->catchStart; \ | catchpc_ = (script)->main + tn_->catchStart; \ | |||
} \ | } \ | |||
} \ | } \ | |||
catchpc = catchpc_; \ | catchpc = catchpc_; \ | |||
JS_END_MACRO | JS_END_MACRO | |||
/* | ||||
* Find the innermost finally block that handles the given pc. This is a | ||||
* version of SCRIPT_FIND_CATCH_START that ignore catch blocks and is used | ||||
* to implement generator.close(). | ||||
*/ | ||||
jsbytecode * | ||||
js_FindFinallyHandler(JSScript *script, jsbytecode *pc); | ||||
extern JS_FRIEND_DATA(JSClass) js_ScriptClass; | extern JS_FRIEND_DATA(JSClass) js_ScriptClass; | |||
extern JSObject * | extern JSObject * | |||
js_InitScriptClass(JSContext *cx, JSObject *obj); | js_InitScriptClass(JSContext *cx, JSObject *obj); | |||
/* | ||||
* On first new context in rt, initialize script runtime state, specificall | ||||
y | ||||
* the script filename table and its lock. | ||||
*/ | ||||
extern JSBool | extern JSBool | |||
js_InitRuntimeScriptState(JSContext *cx); | js_InitRuntimeScriptState(JSRuntime *rt); | |||
/* | ||||
* On last context destroy for rt, if script filenames are all GC'd, free t | ||||
he | ||||
* script filename table and its lock. | ||||
*/ | ||||
extern void | extern void | |||
js_FinishRuntimeScriptState(JSContext *cx); | js_FinishRuntimeScriptState(JSRuntime *rt); | |||
/* | ||||
* On JS_DestroyRuntime(rt), forcibly free script filename prefixes and any | ||||
* script filename table entries that have not been GC'd, the latter using | ||||
* js_FinishRuntimeScriptState. | ||||
* | ||||
* This allows script filename prefixes to outlive any context in rt. | ||||
*/ | ||||
extern void | ||||
js_FreeRuntimeScriptState(JSRuntime *rt); | ||||
extern const char * | extern const char * | |||
js_SaveScriptFilename(JSContext *cx, const char *filename); | js_SaveScriptFilename(JSContext *cx, const char *filename); | |||
extern const char * | ||||
js_SaveScriptFilenameRT(JSRuntime *rt, const char *filename, uint32 flags); | ||||
extern uint32 | ||||
js_GetScriptFilenameFlags(const char *filename); | ||||
extern void | extern void | |||
js_MarkScriptFilename(const char *filename); | js_MarkScriptFilename(const char *filename); | |||
extern void | extern void | |||
js_MarkScriptFilenames(JSRuntime *rt, JSBool keepAtoms); | ||||
extern void | ||||
js_SweepScriptFilenames(JSRuntime *rt); | js_SweepScriptFilenames(JSRuntime *rt); | |||
/* | /* | |||
* Two successively less primitive ways to make a new JSScript. The first | * Two successively less primitive ways to make a new JSScript. The first | |||
* does *not* call a non-null cx->runtime->newScriptHook -- only the second , | * does *not* call a non-null cx->runtime->newScriptHook -- only the second , | |||
* js_NewScriptFromCG, calls this optional debugger hook. | * js_NewScriptFromCG, calls this optional debugger hook. | |||
* | * | |||
* The js_NewScript function can't know whether the script it creates belon gs | * The js_NewScript function can't know whether the script it creates belon gs | |||
* to a function, or is top-level or eval code, but the debugger wants acce ss | * to a function, or is top-level or eval code, but the debugger wants acce ss | |||
* to the newly made script's function, if any -- so callers of js_NewScrip t | * to the newly made script's function, if any -- so callers of js_NewScrip t | |||
skipping to change at line 146 | skipping to change at line 182 | |||
/* | /* | |||
* New-script-hook calling is factored from js_NewScriptFromCG so that it | * New-script-hook calling is factored from js_NewScriptFromCG so that it | |||
* and callers of js_XDRScript can share this code. In the case of callers | * and callers of js_XDRScript can share this code. In the case of callers | |||
* of js_XDRScript, the hook should be invoked only after successful decode | * of js_XDRScript, the hook should be invoked only after successful decode | |||
* of any owning function (the fun parameter) or script object (null fun). | * of any owning function (the fun parameter) or script object (null fun). | |||
*/ | */ | |||
extern JS_FRIEND_API(void) | extern JS_FRIEND_API(void) | |||
js_CallNewScriptHook(JSContext *cx, JSScript *script, JSFunction *fun); | js_CallNewScriptHook(JSContext *cx, JSScript *script, JSFunction *fun); | |||
extern JS_FRIEND_API(void) | ||||
js_CallDestroyScriptHook(JSContext *cx, JSScript *script); | ||||
extern void | extern void | |||
js_DestroyScript(JSContext *cx, JSScript *script); | js_DestroyScript(JSContext *cx, JSScript *script); | |||
extern void | extern void | |||
js_MarkScript(JSContext *cx, JSScript *script, void *arg); | js_MarkScript(JSContext *cx, JSScript *script); | |||
/* | ||||
* To perturb as little code as possible, we introduce a js_GetSrcNote look | ||||
up | ||||
* cache without adding an explicit cx parameter. Thus js_GetSrcNote becom | ||||
es | ||||
* a macro that uses cx from its calls' lexical environments. | ||||
*/ | ||||
#define js_GetSrcNote(script,pc) js_GetSrcNoteCached(cx, script, pc) | ||||
extern jssrcnote * | extern jssrcnote * | |||
js_GetSrcNote(JSScript *script, jsbytecode *pc); | js_GetSrcNoteCached(JSContext *cx, JSScript *script, jsbytecode *pc); | |||
/* XXX need cx to lock function objects declared by prolog bytecodes. */ | /* XXX need cx to lock function objects declared by prolog bytecodes. */ | |||
extern uintN | extern uintN | |||
js_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc); | js_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc); | |||
extern jsbytecode * | extern jsbytecode * | |||
js_LineNumberToPC(JSScript *script, uintN lineno); | js_LineNumberToPC(JSScript *script, uintN lineno); | |||
extern uintN | extern JS_FRIEND_API(uintN) | |||
js_GetScriptLineExtent(JSScript *script); | js_GetScriptLineExtent(JSScript *script); | |||
/* | /* | |||
* If magic is non-null, js_XDRScript succeeds on magic number mismatch but | * If magic is non-null, js_XDRScript succeeds on magic number mismatch but | |||
* returns false in *magic; it reflects a match via a true *magic out param . | * returns false in *magic; it reflects a match via a true *magic out param . | |||
* If magic is null, js_XDRScript returns false on bad magic number errors, | * If magic is null, js_XDRScript returns false on bad magic number errors, | |||
* which it reports. | * which it reports. | |||
* | * | |||
* NB: callers must call js_CallNewScriptHook after successful JSXDR_DECODE | * NB: callers must call js_CallNewScriptHook after successful JSXDR_DECODE | |||
* and subsequent set-up of owning function or script object, if any. | * and subsequent set-up of owning function or script object, if any. | |||
End of changes. 13 change blocks. | ||||
7 lines changed or deleted | 59 lines changed or added | |||
jsstddef.h | jsstddef.h | |||
---|---|---|---|---|
skipping to change at line 77 | skipping to change at line 77 | |||
* a 32-bit type. | * a 32-bit type. | |||
*/ | */ | |||
#define PTRDIFF(p1, p2, type) \ | #define PTRDIFF(p1, p2, type) \ | |||
((((unsigned long)(p1)) - ((unsigned long)(p2))) / sizeof(type)) | ((((unsigned long)(p1)) - ((unsigned long)(p2))) / sizeof(type)) | |||
#define _PTRDIFF_T_DEFINED | #define _PTRDIFF_T_DEFINED | |||
#endif /*_PTRDIFF_T_DEFINED*/ | #endif /*_PTRDIFF_T_DEFINED*/ | |||
#else /*WIN16*/ | #else /*WIN16*/ | |||
#define PTRDIFF(p1, p2, type) \ | #define PTRDIFF(p1, p2, type) \ | |||
((p1) - (p2)) | ((p1) - (p2)) | |||
#endif | #endif | |||
#include <stddef.h> | #include <stddef.h> | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
jsstr.h | jsstr.h | |||
---|---|---|---|---|
skipping to change at line 213 | skipping to change at line 213 | |||
JSCT_CURRENCY_SYMBOL = 26, | JSCT_CURRENCY_SYMBOL = 26, | |||
JSCT_MODIFIER_SYMBOL = 27, | JSCT_MODIFIER_SYMBOL = 27, | |||
JSCT_OTHER_SYMBOL = 28 | JSCT_OTHER_SYMBOL = 28 | |||
} JSCharType; | } JSCharType; | |||
/* Character classifying and mapping macros, based on java.lang.Character. */ | /* Character classifying and mapping macros, based on java.lang.Character. */ | |||
#define JS_CCODE(c) (js_A[js_Y[(js_X[(uint16)(c)>>6]<<6)|((c)&0x3F)]]) | #define JS_CCODE(c) (js_A[js_Y[(js_X[(uint16)(c)>>6]<<6)|((c)&0x3F)]]) | |||
#define JS_CTYPE(c) (JS_CCODE(c) & 0x1F) | #define JS_CTYPE(c) (JS_CCODE(c) & 0x1F) | |||
#define JS_ISALPHA(c) ((((1 << JSCT_UPPERCASE_LETTER) | \ | #define JS_ISALPHA(c) ((((1 << JSCT_UPPERCASE_LETTER) | \ | |||
(1 << JSCT_LOWERCASE_LETTER) | | (1 << JSCT_LOWERCASE_LETTER) | | |||
\ | \ | |||
(1 << JSCT_TITLECASE_LETTER) | | (1 << JSCT_TITLECASE_LETTER) | | |||
\ | \ | |||
(1 << JSCT_MODIFIER_LETTER) | | (1 << JSCT_MODIFIER_LETTER) | | |||
\ | \ | |||
(1 << JSCT_OTHER_LETTER)) | (1 << JSCT_OTHER_LETTER)) | |||
\ | \ | |||
>> JS_CTYPE(c)) & 1) | >> JS_CTYPE(c)) & 1) | |||
#define JS_ISALNUM(c) ((((1 << JSCT_UPPERCASE_LETTER) | \ | #define JS_ISALNUM(c) ((((1 << JSCT_UPPERCASE_LETTER) | \ | |||
(1 << JSCT_LOWERCASE_LETTER) | | (1 << JSCT_LOWERCASE_LETTER) | | |||
\ | \ | |||
(1 << JSCT_TITLECASE_LETTER) | | (1 << JSCT_TITLECASE_LETTER) | | |||
\ | \ | |||
(1 << JSCT_MODIFIER_LETTER) | | (1 << JSCT_MODIFIER_LETTER) | | |||
\ | \ | |||
(1 << JSCT_OTHER_LETTER) | | (1 << JSCT_OTHER_LETTER) | | |||
\ | \ | |||
(1 << JSCT_DECIMAL_DIGIT_NUMBER)) | (1 << JSCT_DECIMAL_DIGIT_NUMBER)) | |||
\ | \ | |||
>> JS_CTYPE(c)) & 1) | >> JS_CTYPE(c)) & 1) | |||
/* A unicode letter, suitable for use in an identifier. */ | /* A unicode letter, suitable for use in an identifier. */ | |||
#define JS_ISUC_LETTER(c) ((((1 << JSCT_UPPERCASE_LETTER) | | #define JS_ISLETTER(c) ((((1 << JSCT_UPPERCASE_LETTER) | | |||
\ | \ | |||
(1 << JSCT_LOWERCASE_LETTER) | | (1 << JSCT_LOWERCASE_LETTER) | | |||
\ | \ | |||
(1 << JSCT_TITLECASE_LETTER) | | (1 << JSCT_TITLECASE_LETTER) | | |||
\ | \ | |||
(1 << JSCT_MODIFIER_LETTER) | | (1 << JSCT_MODIFIER_LETTER) | | |||
\ | \ | |||
(1 << JSCT_OTHER_LETTER) | | (1 << JSCT_OTHER_LETTER) | | |||
\ | \ | |||
(1 << JSCT_LETTER_NUMBER)) | (1 << JSCT_LETTER_NUMBER)) | |||
\ | \ | |||
>> JS_CTYPE(c)) & 1) | >> JS_CTYPE(c)) & 1) | |||
/* | /* | |||
* 'IdentifierPart' from ECMA grammar, is Unicode letter or combining mark or | * 'IdentifierPart' from ECMA grammar, is Unicode letter or combining mark or | |||
* digit or connector punctuation. | * digit or connector punctuation. | |||
*/ | */ | |||
#define JS_ISID_PART(c) ((((1 << JSCT_UPPERCASE_LETTER) | | #define JS_ISIDPART(c) ((((1 << JSCT_UPPERCASE_LETTER) | | |||
\ | \ | |||
(1 << JSCT_LOWERCASE_LETTER) | | (1 << JSCT_LOWERCASE_LETTER) | | |||
\ | \ | |||
(1 << JSCT_TITLECASE_LETTER) | | (1 << JSCT_TITLECASE_LETTER) | | |||
\ | \ | |||
(1 << JSCT_MODIFIER_LETTER) | | (1 << JSCT_MODIFIER_LETTER) | | |||
\ | \ | |||
(1 << JSCT_OTHER_LETTER) | | (1 << JSCT_OTHER_LETTER) | | |||
\ | \ | |||
(1 << JSCT_LETTER_NUMBER) | | (1 << JSCT_LETTER_NUMBER) | | |||
\ | \ | |||
(1 << JSCT_NON_SPACING_MARK) | | (1 << JSCT_NON_SPACING_MARK) | | |||
\ | \ | |||
(1 << JSCT_COMBINING_SPACING_MARK) | | (1 << JSCT_COMBINING_SPACING_MARK) | | |||
\ | \ | |||
(1 << JSCT_DECIMAL_DIGIT_NUMBER) | | (1 << JSCT_DECIMAL_DIGIT_NUMBER) | | |||
\ | \ | |||
(1 << JSCT_CONNECTOR_PUNCTUATION)) | (1 << JSCT_CONNECTOR_PUNCTUATION)) | |||
\ | \ | |||
>> JS_CTYPE(c)) & 1) | >> JS_CTYPE(c)) & 1) | |||
/* Unicode control-format characters, ignored in input */ | /* Unicode control-format characters, ignored in input */ | |||
#define JS_ISFORMAT(c) (((1 << JSCT_FORMAT) >> JS_CTYPE(c)) & 1) | #define JS_ISFORMAT(c) (((1 << JSCT_FORMAT) >> JS_CTYPE(c)) & 1) | |||
/* | /* | |||
* Per ECMA-262 15.10.2.6, these characters are the only ones that make up a | * Per ECMA-262 15.10.2.6, these characters are the only ones that make up a | |||
* "word", as far as a RegExp is concerned. If we want a Unicode-friendlie r | * "word", as far as a RegExp is concerned. If we want a Unicode-friendlie r | |||
* definition of "word", we should rename this macro to something regexp-y. | * definition of "word", we should rename this macro to something regexp-y. | |||
*/ | */ | |||
#define JS_ISWORD(c) ((c) < 128 && (isalnum(c) || (c) == '_')) | #define JS_ISWORD(c) ((c) < 128 && (isalnum(c) || (c) == '_')) | |||
/* XXXbe unify on A/X/Y tbls, avoid ctype.h? */ | #define JS_ISIDSTART(c) (JS_ISLETTER(c) || (c) == '_' || (c) == '$') | |||
#define JS_ISIDENT_START(c) (JS_ISUC_LETTER(c) || (c) == '_' || (c) == '$') | #define JS_ISIDENT(c) (JS_ISIDPART(c) || (c) == '_' || (c) == '$') | |||
#define JS_ISIDENT(c) (JS_ISID_PART(c) || (c) == '_' || (c) == '$') | ||||
#define JS_ISXMLSPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' | | ||||
| \ | ||||
(c) == '\n') | ||||
#define JS_ISXMLNSSTART(c) ((JS_CCODE(c) & 0x00000100) || (c) == '_') | ||||
#define JS_ISXMLNS(c) ((JS_CCODE(c) & 0x00000080) || (c) == '.' | | ||||
| \ | ||||
(c) == '-' || (c) == '_') | ||||
#define JS_ISXMLNAMESTART(c) (JS_ISXMLNSSTART(c) || (c) == ':') | ||||
#define JS_ISXMLNAME(c) (JS_ISXMLNS(c) || (c) == ':') | ||||
#define JS_ISDIGIT(c) (JS_CTYPE(c) == JSCT_DECIMAL_DIGIT_NUMBER) | #define JS_ISDIGIT(c) (JS_CTYPE(c) == JSCT_DECIMAL_DIGIT_NUMBER) | |||
/* XXXbe unify on A/X/Y tbls, avoid ctype.h? */ | ||||
/* XXXbe fs, etc. ? */ | /* XXXbe fs, etc. ? */ | |||
#define JS_ISSPACE(c) ((JS_CCODE(c) & 0x00070000) == 0x00040000) | #define JS_ISSPACE(c) ((JS_CCODE(c) & 0x00070000) == 0x00040000) | |||
#define JS_ISPRINT(c) ((c) < 128 && isprint(c)) | #define JS_ISPRINT(c) ((c) < 128 && isprint(c)) | |||
#define JS_ISUPPER(c) (JS_CTYPE(c) == JSCT_UPPERCASE_LETTER) | #define JS_ISUPPER(c) (JS_CTYPE(c) == JSCT_UPPERCASE_LETTER) | |||
#define JS_ISLOWER(c) (JS_CTYPE(c) == JSCT_LOWERCASE_LETTER) | #define JS_ISLOWER(c) (JS_CTYPE(c) == JSCT_LOWERCASE_LETTER) | |||
#define JS_TOUPPER(c) ((jschar) ((JS_CCODE(c) & 0x00100000) \ | #define JS_TOUPPER(c) ((jschar) ((JS_CCODE(c) & 0x00100000) \ | |||
? (c) - ((int32)JS_CCODE(c) >> 22) \ | ? (c) - ((int32)JS_CCODE(c) >> 22) \ | |||
: (c))) | : (c))) | |||
#define JS_TOLOWER(c) ((jschar) ((JS_CCODE(c) & 0x00200000) \ | #define JS_TOLOWER(c) ((jschar) ((JS_CCODE(c) & 0x00200000) \ | |||
? (c) + ((int32)JS_CCODE(c) >> 22) \ | ? (c) + ((int32)JS_CCODE(c) >> 22) \ | |||
: (c))) | : (c))) | |||
#define JS_TOCTRL(c) ((c) ^ 64) /* XXX unsafe! requires uppercase c | /* | |||
*/ | * Shorthands for ASCII (7-bit) decimal and hex conversion. | |||
* Manually inline isdigit for performance; MSVC doesn't do this for us. | ||||
/* Shorthands for ASCII (7-bit) decimal and hex conversion. */ | */ | |||
#define JS7_ISDEC(c) ((c) < 128 && isdigit(c)) | #define JS7_ISDEC(c) ((((unsigned)(c)) - '0') <= 9) | |||
#define JS7_UNDEC(c) ((c) - '0') | #define JS7_UNDEC(c) ((c) - '0') | |||
#define JS7_ISHEX(c) ((c) < 128 && isxdigit(c)) | #define JS7_ISHEX(c) ((c) < 128 && isxdigit(c)) | |||
#define JS7_UNHEX(c) (uintN)(isdigit(c) ? (c) - '0' : 10 + tolower(c) - 'a') | #define JS7_UNHEX(c) (uintN)(JS7_ISDEC(c) ? (c) - '0' : 10 + tolower(c) - 'a') | |||
#define JS7_ISLET(c) ((c) < 128 && isalpha(c)) | #define JS7_ISLET(c) ((c) < 128 && isalpha(c)) | |||
/* Initialize truly global state associated with JS strings. */ | ||||
extern JSBool | ||||
js_InitStringGlobals(void); | ||||
extern void | ||||
js_FreeStringGlobals(void); | ||||
extern void | ||||
js_PurgeDeflatedStringCache(JSString *str); | ||||
/* Initialize per-runtime string state for the first context in the runtime . */ | /* Initialize per-runtime string state for the first context in the runtime . */ | |||
extern JSBool | extern JSBool | |||
js_InitRuntimeStringState(JSContext *cx); | js_InitRuntimeStringState(JSContext *cx); | |||
extern void | extern void | |||
js_FinishRuntimeStringState(JSContext *cx); | js_FinishRuntimeStringState(JSContext *cx); | |||
extern void | ||||
js_FinishDeflatedStringCache(JSRuntime *rt); | ||||
/* Initialize the String class, returning its prototype object. */ | /* Initialize the String class, returning its prototype object. */ | |||
extern JSClass js_StringClass; | ||||
extern JSObject * | extern JSObject * | |||
js_InitStringClass(JSContext *cx, JSObject *obj); | js_InitStringClass(JSContext *cx, JSObject *obj); | |||
extern const char js_escape_str[]; | extern const char js_escape_str[]; | |||
extern const char js_unescape_str[]; | extern const char js_unescape_str[]; | |||
extern const char js_uneval_str[]; | extern const char js_uneval_str[]; | |||
extern const char js_decodeURI_str[]; | extern const char js_decodeURI_str[]; | |||
extern const char js_encodeURI_str[]; | extern const char js_encodeURI_str[]; | |||
extern const char js_decodeURIComponent_str[]; | extern const char js_decodeURIComponent_str[]; | |||
extern const char js_encodeURIComponent_str[]; | extern const char js_encodeURIComponent_str[]; | |||
skipping to change at line 348 | skipping to change at line 352 | |||
js_FinalizeString(JSContext *cx, JSString *str); | js_FinalizeString(JSContext *cx, JSString *str); | |||
extern void | extern void | |||
js_FinalizeStringRT(JSRuntime *rt, JSString *str); | js_FinalizeStringRT(JSRuntime *rt, JSString *str); | |||
/* Wrap a string value in a String object. */ | /* Wrap a string value in a String object. */ | |||
extern JSObject * | extern JSObject * | |||
js_StringToObject(JSContext *cx, JSString *str); | js_StringToObject(JSContext *cx, JSString *str); | |||
/* | /* | |||
* Convert a value to a printable C string. | ||||
*/ | ||||
typedef JSString *(*JSValueToStringFun)(JSContext *cx, jsval v); | ||||
extern JS_FRIEND_API(const char *) | ||||
js_ValueToPrintable(JSContext *cx, jsval v, JSValueToStringFun v2sfun); | ||||
#define js_ValueToPrintableString(cx,v) \ | ||||
js_ValueToPrintable(cx, v, js_ValueToString) | ||||
#define js_ValueToPrintableSource(cx,v) \ | ||||
js_ValueToPrintable(cx, v, js_ValueToSource) | ||||
/* | ||||
* Convert a value to a string, returning null after reporting an error, | * Convert a value to a string, returning null after reporting an error, | |||
* otherwise returning a new string reference. | * otherwise returning a new string reference. | |||
*/ | */ | |||
extern JSString * | extern JS_FRIEND_API(JSString *) | |||
js_ValueToString(JSContext *cx, jsval v); | js_ValueToString(JSContext *cx, jsval v); | |||
/* | /* | |||
* Convert a value to its source expression, returning null after reporting | * Convert a value to its source expression, returning null after reporting | |||
* an error, otherwise returning a new string reference. | * an error, otherwise returning a new string reference. | |||
*/ | */ | |||
extern JSString * | extern JS_FRIEND_API(JSString *) | |||
js_ValueToSource(JSContext *cx, jsval v); | js_ValueToSource(JSContext *cx, jsval v); | |||
#ifdef HT_ENUMERATE_NEXT /* XXX don't require jshash.h */ | #ifdef HT_ENUMERATE_NEXT /* XXX don't require jshash.h */ | |||
/* | /* | |||
* Compute a hash function from str. | * Compute a hash function from str. | |||
*/ | */ | |||
extern JSHashNumber | extern JSHashNumber | |||
js_HashString(JSString *str); | js_HashString(JSString *str); | |||
#endif | #endif | |||
/* | /* | |||
* Return less than, equal to, or greater than zero depending on whether | * Return less than, equal to, or greater than zero depending on whether | |||
* str1 is less than, equal to, or greater than str2. | * str1 is less than, equal to, or greater than str2. | |||
*/ | */ | |||
extern intN | extern intN | |||
js_CompareStrings(JSString *str1, JSString *str2); | js_CompareStrings(JSString *str1, JSString *str2); | |||
/* | /* | |||
* Test if strings are equal. | ||||
*/ | ||||
extern JSBool | ||||
js_EqualStrings(JSString *str1, JSString *str2); | ||||
/* | ||||
* Boyer-Moore-Horspool superlinear search for pat:patlen in text:textlen. | * Boyer-Moore-Horspool superlinear search for pat:patlen in text:textlen. | |||
* The patlen argument must be positive and no greater than BMH_PATLEN_MAX. | * The patlen argument must be positive and no greater than BMH_PATLEN_MAX. | |||
* The start argument tells where in text to begin the search. | * The start argument tells where in text to begin the search. | |||
* | * | |||
* Return the index of pat in text, or -1 if not found. | * Return the index of pat in text, or -1 if not found. | |||
*/ | */ | |||
#define BMH_CHARSET_SIZE 256 /* ISO-Latin-1 */ | #define BMH_CHARSET_SIZE 256 /* ISO-Latin-1 */ | |||
#define BMH_PATLEN_MAX 255 /* skip table element is uint8 */ | #define BMH_PATLEN_MAX 255 /* skip table element is uint8 */ | |||
#define BMH_BAD_PATTERN (-2) /* return value if pat is not ISO-Latin-1 * / | #define BMH_BAD_PATTERN (-2) /* return value if pat is not ISO-Latin-1 * / | |||
skipping to change at line 413 | skipping to change at line 437 | |||
/* | /* | |||
* Return s advanced past any Unicode white space characters. | * Return s advanced past any Unicode white space characters. | |||
*/ | */ | |||
extern const jschar * | extern const jschar * | |||
js_SkipWhiteSpace(const jschar *s); | js_SkipWhiteSpace(const jschar *s); | |||
/* | /* | |||
* Inflate bytes to JS chars and vice versa. Report out of memory via cx | * Inflate bytes to JS chars and vice versa. Report out of memory via cx | |||
* and return null on error, otherwise return the jschar or byte vector tha t | * and return null on error, otherwise return the jschar or byte vector tha t | |||
* was JS_malloc'ed. | * was JS_malloc'ed. length is updated with the length of the new string in jschars. | |||
*/ | */ | |||
extern jschar * | extern jschar * | |||
js_InflateString(JSContext *cx, const char *bytes, size_t length); | js_InflateString(JSContext *cx, const char *bytes, size_t *length); | |||
extern char * | extern char * | |||
js_DeflateString(JSContext *cx, const jschar *chars, size_t length); | js_DeflateString(JSContext *cx, const jschar *chars, size_t length); | |||
/* | /* | |||
* Inflate bytes to JS chars into a buffer. | * Inflate bytes to JS chars into a buffer. | |||
* 'chars' must be large enough for 'length'+1 jschars. | * 'chars' must be large enough for 'length' jschars. | |||
* The buffer is NOT null-terminated. | ||||
* cx may be NULL, which means no errors are thrown. | ||||
* The destination length needs to be initialized with the buffer size, tak | ||||
es | ||||
* the number of chars moved. | ||||
*/ | */ | |||
extern void | extern JSBool | |||
js_InflateStringToBuffer(jschar *chars, const char *bytes, size_t length); | js_InflateStringToBuffer(JSContext* cx, const char *bytes, size_t length, | |||
jschar *chars, size_t* charsLength); | ||||
/* | ||||
* Deflate JS chars to bytes into a buffer. | ||||
* 'bytes' must be large enough for 'length chars. | ||||
* The buffer is NOT null-terminated. | ||||
* cx may be NULL, which means no errors are thrown. | ||||
* The destination length needs to be initialized with the buffer size, tak | ||||
es | ||||
* the number of bytes moved. | ||||
*/ | ||||
extern JSBool | ||||
js_DeflateStringToBuffer(JSContext* cx, const jschar *chars, | ||||
size_t charsLength, char *bytes, size_t* length); | ||||
/* | /* | |||
* Associate bytes with str in the deflated string cache, returning true on | * Associate bytes with str in the deflated string cache, returning true on | |||
* successful association, false on out of memory. | * successful association, false on out of memory. | |||
*/ | */ | |||
extern JSBool | extern JSBool | |||
js_SetStringBytes(JSString *str, char *bytes, size_t length); | js_SetStringBytes(JSRuntime *rt, JSString *str, char *bytes, size_t length) ; | |||
/* | /* | |||
* Find or create a deflated string cache entry for str that contains its | * Find or create a deflated string cache entry for str that contains its | |||
* characters chopped from Unicode code points into bytes. | * characters chopped from Unicode code points into bytes. | |||
*/ | */ | |||
extern char * | extern char * | |||
js_GetStringBytes(JSString *str); | js_GetStringBytes(JSRuntime *rt, JSString *str); | |||
/* Remove a deflated string cache entry associated with str if any. */ | ||||
extern void | ||||
js_PurgeDeflatedStringCache(JSRuntime *rt, JSString *str); | ||||
JSBool | JSBool | |||
js_str_escape(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, | js_str_escape(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, | |||
jsval *rval); | jsval *rval); | |||
/* | ||||
* Convert one UCS-4 char and write it into a UTF-8 buffer, which must be a | ||||
t | ||||
* least 6 bytes long. Return the number of UTF-8 bytes of data written. | ||||
*/ | ||||
extern int | ||||
js_OneUcs4ToUtf8Char(uint8 *utf8Buffer, uint32 ucs4Char); | ||||
JS_END_EXTERN_C | JS_END_EXTERN_C | |||
#endif /* jsstr_h___ */ | #endif /* jsstr_h___ */ | |||
End of changes. 23 change blocks. | ||||
83 lines changed or deleted | 139 lines changed or added | |||
jstypes.h | jstypes.h | |||
---|---|---|---|---|
skipping to change at line 89 | skipping to change at line 89 | |||
#ifdef WIN32 | #ifdef WIN32 | |||
/* These also work for __MWERKS__ */ | /* These also work for __MWERKS__ */ | |||
#define JS_EXTERN_API(__type) extern __declspec(dllexport) __type | #define JS_EXTERN_API(__type) extern __declspec(dllexport) __type | |||
#define JS_EXPORT_API(__type) __declspec(dllexport) __type | #define JS_EXPORT_API(__type) __declspec(dllexport) __type | |||
#define JS_EXTERN_DATA(__type) extern __declspec(dllexport) __type | #define JS_EXTERN_DATA(__type) extern __declspec(dllexport) __type | |||
#define JS_EXPORT_DATA(__type) __declspec(dllexport) __type | #define JS_EXPORT_DATA(__type) __declspec(dllexport) __type | |||
#define JS_DLL_CALLBACK | #define JS_DLL_CALLBACK | |||
#define JS_STATIC_DLL_CALLBACK(__x) static __x | #define JS_STATIC_DLL_CALLBACK(__x) static __x | |||
#elif defined(XP_OS2) && defined(__declspec) | ||||
#define JS_EXTERN_API(__type) extern __declspec(dllexport) __type | ||||
#define JS_EXPORT_API(__type) __declspec(dllexport) __type | ||||
#define JS_EXTERN_DATA(__type) extern __declspec(dllexport) __type | ||||
#define JS_EXPORT_DATA(__type) __declspec(dllexport) __type | ||||
#define JS_DLL_CALLBACK | ||||
#define JS_STATIC_DLL_CALLBACK(__x) static __x | ||||
#elif defined(WIN16) | #elif defined(WIN16) | |||
#ifdef _WINDLL | #ifdef _WINDLL | |||
#define JS_EXTERN_API(__type) extern __type _cdecl _export _loadds | #define JS_EXTERN_API(__type) extern __type _cdecl _export _loadds | |||
#define JS_EXPORT_API(__type) __type _cdecl _export _loadds | #define JS_EXPORT_API(__type) __type _cdecl _export _loadds | |||
#define JS_EXTERN_DATA(__type) extern __type _export | #define JS_EXTERN_DATA(__type) extern __type _export | |||
#define JS_EXPORT_DATA(__type) __type _export | #define JS_EXPORT_DATA(__type) __type _export | |||
#define JS_DLL_CALLBACK __cdecl __loadds | #define JS_DLL_CALLBACK __cdecl __loadds | |||
#define JS_STATIC_DLL_CALLBACK(__x) static __x CALLBACK | #define JS_STATIC_DLL_CALLBACK(__x) static __x CALLBACK | |||
skipping to change at line 110 | skipping to change at line 120 | |||
#else /* this must be .EXE */ | #else /* this must be .EXE */ | |||
#define JS_EXTERN_API(__type) extern __type _cdecl _export | #define JS_EXTERN_API(__type) extern __type _cdecl _export | |||
#define JS_EXPORT_API(__type) __type _cdecl _export | #define JS_EXPORT_API(__type) __type _cdecl _export | |||
#define JS_EXTERN_DATA(__type) extern __type _export | #define JS_EXTERN_DATA(__type) extern __type _export | |||
#define JS_EXPORT_DATA(__type) __type _export | #define JS_EXPORT_DATA(__type) __type _export | |||
#define JS_DLL_CALLBACK __cdecl __loadds | #define JS_DLL_CALLBACK __cdecl __loadds | |||
#define JS_STATIC_DLL_CALLBACK(__x) __x JS_DLL_CALLBACK | #define JS_STATIC_DLL_CALLBACK(__x) __x JS_DLL_CALLBACK | |||
#endif /* _WINDLL */ | #endif /* _WINDLL */ | |||
#elif defined(XP_MAC) | ||||
#define JS_EXTERN_API(__type) extern __declspec(export) __type | ||||
#define JS_EXPORT_API(__type) __declspec(export) __type | ||||
#define JS_EXTERN_DATA(__type) extern __declspec(export) __type | ||||
#define JS_EXPORT_DATA(__type) __declspec(export) __type | ||||
#define JS_DLL_CALLBACK | ||||
#define JS_STATIC_DLL_CALLBACK(__x) static __x | ||||
#else /* Unix */ | #else /* Unix */ | |||
#define JS_EXTERN_API(__type) extern __type | #ifdef HAVE_VISIBILITY_ATTRIBUTE | |||
#define JS_EXPORT_API(__type) __type | #define JS_EXTERNAL_VIS __attribute__((visibility ("default"))) | |||
#define JS_EXTERN_DATA(__type) extern __type | #else | |||
#define JS_EXPORT_DATA(__type) __type | #define JS_EXTERNAL_VIS | |||
#endif | ||||
#define JS_EXTERN_API(__type) extern JS_EXTERNAL_VIS __type | ||||
#define JS_EXPORT_API(__type) JS_EXTERNAL_VIS __type | ||||
#define JS_EXTERN_DATA(__type) extern JS_EXTERNAL_VIS __type | ||||
#define JS_EXPORT_DATA(__type) JS_EXTERNAL_VIS __type | ||||
#define JS_DLL_CALLBACK | #define JS_DLL_CALLBACK | |||
#define JS_STATIC_DLL_CALLBACK(__x) static __x | #define JS_STATIC_DLL_CALLBACK(__x) static __x | |||
#endif | #endif | |||
#ifdef _WIN32 | #ifdef _WIN32 | |||
# if defined(__MWERKS__) || defined(__GNUC__) | # if defined(__MWERKS__) || defined(__GNUC__) | |||
# define JS_IMPORT_API(__x) __x | # define JS_IMPORT_API(__x) __x | |||
# else | # else | |||
# define JS_IMPORT_API(__x) __declspec(dllimport) __x | # define JS_IMPORT_API(__x) __declspec(dllimport) __x | |||
# endif | # endif | |||
#elif defined(XP_OS2) && defined(__declspec) | ||||
# define JS_IMPORT_API(__x) __declspec(dllimport) __x | ||||
#else | #else | |||
# define JS_IMPORT_API(__x) JS_EXPORT_API (__x) | # define JS_IMPORT_API(__x) JS_EXPORT_API (__x) | |||
#endif | #endif | |||
#if defined(_WIN32) && !defined(__MWERKS__) | #if defined(_WIN32) && !defined(__MWERKS__) | |||
# define JS_IMPORT_DATA(__x) __declspec(dllimport) __x | # define JS_IMPORT_DATA(__x) __declspec(dllimport) __x | |||
#elif defined(XP_OS2) && defined(__declspec) | ||||
# define JS_IMPORT_DATA(__x) __declspec(dllimport) __x | ||||
#else | #else | |||
# define JS_IMPORT_DATA(__x) __x | # define JS_IMPORT_DATA(__x) JS_EXPORT_DATA (__x) | |||
#endif | #endif | |||
/* | /* | |||
* The linkage of JS API functions differs depending on whether the file is | * The linkage of JS API functions differs depending on whether the file is | |||
* used within the JS library or not. Any source file within the JS | * used within the JS library or not. Any source file within the JS | |||
* interpreter should define EXPORT_JS_API whereas any client of the librar y | * interpreter should define EXPORT_JS_API whereas any client of the librar y | |||
* should not. | * should not. | |||
*/ | */ | |||
#ifdef EXPORT_JS_API | #ifdef EXPORT_JS_API | |||
#define JS_PUBLIC_API(t) JS_EXPORT_API(t) | #define JS_PUBLIC_API(t) JS_EXPORT_API(t) | |||
skipping to change at line 206 | skipping to change at line 217 | |||
/*********************************************************************** | /*********************************************************************** | |||
** MACROS: JS_BIT | ** MACROS: JS_BIT | |||
** JS_BITMASK | ** JS_BITMASK | |||
** DESCRIPTION: | ** DESCRIPTION: | |||
** Bit masking macros. XXX n must be <= 31 to be portable | ** Bit masking macros. XXX n must be <= 31 to be portable | |||
***********************************************************************/ | ***********************************************************************/ | |||
#define JS_BIT(n) ((JSUint32)1 << (n)) | #define JS_BIT(n) ((JSUint32)1 << (n)) | |||
#define JS_BITMASK(n) (JS_BIT(n) - 1) | #define JS_BITMASK(n) (JS_BIT(n) - 1) | |||
/*********************************************************************** | /*********************************************************************** | |||
** MACROS: JS_PTR_TO_INT32 | ||||
** JS_PTR_TO_UINT32 | ||||
** JS_INT32_TO_PTR | ||||
** JS_UINT32_TO_PTR | ||||
** DESCRIPTION: | ||||
** Integer to pointer and pointer to integer conversion macros. | ||||
***********************************************************************/ | ||||
#define JS_PTR_TO_INT32(x) ((jsint)((char *)(x) - (char *)0)) | ||||
#define JS_PTR_TO_UINT32(x) ((jsuint)((char *)(x) - (char *)0)) | ||||
#define JS_INT32_TO_PTR(x) ((void *)((char *)0 + (jsint)(x))) | ||||
#define JS_UINT32_TO_PTR(x) ((void *)((char *)0 + (jsuint)(x))) | ||||
/*********************************************************************** | ||||
** MACROS: JS_HOWMANY | ** MACROS: JS_HOWMANY | |||
** JS_ROUNDUP | ** JS_ROUNDUP | |||
** JS_MIN | ** JS_MIN | |||
** JS_MAX | ** JS_MAX | |||
** DESCRIPTION: | ** DESCRIPTION: | |||
** Commonly used macros for operations on compatible types. | ** Commonly used macros for operations on compatible types. | |||
***********************************************************************/ | ***********************************************************************/ | |||
#define JS_HOWMANY(x,y) (((x)+(y)-1)/(y)) | #define JS_HOWMANY(x,y) (((x)+(y)-1)/(y)) | |||
#define JS_ROUNDUP(x,y) (JS_HOWMANY(x,y)*(y)) | #define JS_ROUNDUP(x,y) (JS_HOWMANY(x,y)*(y)) | |||
#define JS_MIN(x,y) ((x)<(y)?(x):(y)) | #define JS_MIN(x,y) ((x)<(y)?(x):(y)) | |||
#define JS_MAX(x,y) ((x)>(y)?(x):(y)) | #define JS_MAX(x,y) ((x)>(y)?(x):(y)) | |||
#if (defined(XP_MAC) || defined(XP_WIN)) && !defined(CROSS_COMPILE) | #if (defined(XP_WIN) && !defined(CROSS_COMPILE)) || defined (WINCE) | |||
# include "jscpucfg.h" /* Use standard Mac or Windows configurati on */ | # include "jscpucfg.h" /* Use standard Mac or Windows configurati on */ | |||
#elif defined(XP_UNIX) || defined(XP_BEOS) || defined(XP_OS2) || defined(CR OSS_COMPILE) | #elif defined(XP_UNIX) || defined(XP_BEOS) || defined(XP_OS2) || defined(CR OSS_COMPILE) | |||
# include "jsautocfg.h" /* Use auto-detected configuration */ | # include "jsautocfg.h" /* Use auto-detected configuration */ | |||
# include "jsosdep.h" /* ...and platform-specific flags */ | # include "jsosdep.h" /* ...and platform-specific flags */ | |||
#else | #else | |||
# error "Must define one of XP_BEOS, XP_MAC, XP_OS2, XP_WIN or XP_UNIX" | # error "Must define one of XP_BEOS, XP_OS2, XP_WIN or XP_UNIX" | |||
#endif | #endif | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
/************************************************************************ | /************************************************************************ | |||
** TYPES: JSUint8 | ** TYPES: JSUint8 | |||
** JSInt8 | ** JSInt8 | |||
** DESCRIPTION: | ** DESCRIPTION: | |||
** The int8 types are known to be 8 bits each. There is no type that | ** The int8 types are known to be 8 bits each. There is no type that | |||
** is equivalent to a plain "char". | ** is equivalent to a plain "char". | |||
skipping to change at line 355 | skipping to change at line 379 | |||
** for storing a pointer or pointer sutraction. | ** for storing a pointer or pointer sutraction. | |||
************************************************************************/ | ************************************************************************/ | |||
typedef ptrdiff_t JSPtrdiff; | typedef ptrdiff_t JSPtrdiff; | |||
/************************************************************************ | /************************************************************************ | |||
** TYPES: JSUptrdiff | ** TYPES: JSUptrdiff | |||
** DESCRIPTION: | ** DESCRIPTION: | |||
** A type for pointer difference. Variables of this type are suitable | ** A type for pointer difference. Variables of this type are suitable | |||
** for storing a pointer or pointer sutraction. | ** for storing a pointer or pointer sutraction. | |||
************************************************************************/ | ************************************************************************/ | |||
#if JS_BYTES_PER_WORD == 8 && JS_BYTES_PER_LONG != 8 | ||||
typedef JSUint64 JSUptrdiff; | ||||
#else | ||||
typedef unsigned long JSUptrdiff; | typedef unsigned long JSUptrdiff; | |||
#endif | ||||
/************************************************************************ | /************************************************************************ | |||
** TYPES: JSBool | ** TYPES: JSBool | |||
** DESCRIPTION: | ** DESCRIPTION: | |||
** Use JSBool for variables and parameter types. Use JS_FALSE and JS_TRUE | ** Use JSBool for variables and parameter types. Use JS_FALSE and JS_TRUE | |||
** for clarity of target type in assignments and actual arguments. Use | ** for clarity of target type in assignments and actual arguments. Use | |||
** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test boolea ns | ** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test boolea ns | |||
** just as you would C int-valued conditions. | ** just as you would C int-valued conditions. | |||
************************************************************************/ | ************************************************************************/ | |||
typedef JSIntn JSBool; | typedef JSIntn JSBool; | |||
#define JS_TRUE (JSIntn)1 | #define JS_TRUE (JSIntn)1 | |||
#define JS_FALSE (JSIntn)0 | #define JS_FALSE (JSIntn)0 | |||
/************************************************************************ | /************************************************************************ | |||
** TYPES: JSPackedBool | ** TYPES: JSPackedBool | |||
** DESCRIPTION: | ** DESCRIPTION: | |||
** Use JSPackedBool within structs where bitfields are not desireable | ** Use JSPackedBool within structs where bitfields are not desireable | |||
** but minimum and consistant overhead matters. | ** but minimum and consistent overhead matters. | |||
************************************************************************/ | ************************************************************************/ | |||
typedef JSUint8 JSPackedBool; | typedef JSUint8 JSPackedBool; | |||
/* | /* | |||
** A JSWord is an integer that is the same size as a void* | ** A JSWord is an integer that is the same size as a void* | |||
*/ | */ | |||
#if JS_BYTES_PER_WORD == 8 && JS_BYTES_PER_LONG != 8 | ||||
typedef JSInt64 JSWord; | ||||
typedef JSUint64 JSUword; | ||||
#else | ||||
typedef long JSWord; | typedef long JSWord; | |||
typedef unsigned long JSUword; | typedef unsigned long JSUword; | |||
#endif | ||||
#include "jsotypes.h" | #include "jsotypes.h" | |||
/*********************************************************************** | ||||
** MACROS: JS_LIKELY | ||||
** JS_UNLIKELY | ||||
** DESCRIPTION: | ||||
** These macros allow you to give a hint to the compiler about branch | ||||
** probability so that it can better optimize. Use them like this: | ||||
** | ||||
** if (JS_LIKELY(v == 1)) { | ||||
** ... expected code path ... | ||||
** } | ||||
** | ||||
** if (JS_UNLIKELY(v == 0)) { | ||||
** ... non-expected code path ... | ||||
** } | ||||
** | ||||
***********************************************************************/ | ||||
#if defined(__GNUC__) && (__GNUC__ > 2) | ||||
#define JS_LIKELY(x) (__builtin_expect((x), 1)) | ||||
#define JS_UNLIKELY(x) (__builtin_expect((x), 0)) | ||||
#else | ||||
#define JS_LIKELY(x) (x) | ||||
#define JS_UNLIKELY(x) (x) | ||||
#endif | ||||
/*********************************************************************** | ||||
** MACROS: JS_ARRAY_LENGTH | ||||
** JS_ARRAY_END | ||||
** DESCRIPTION: | ||||
** Macros to get the number of elements and the pointer to one past th | ||||
e | ||||
** last element of a C array. Use them like this: | ||||
** | ||||
** jschar buf[10], *s; | ||||
** JSString *str; | ||||
** ... | ||||
** for (s = buf; s != JS_ARRAY_END(buf); ++s) *s = ...; | ||||
** ... | ||||
** str = JS_NewStringCopyN(cx, buf, JS_ARRAY_LENGTH(buf)); | ||||
** ... | ||||
** | ||||
***********************************************************************/ | ||||
#define JS_ARRAY_LENGTH(array) (sizeof (array) / sizeof (array)[0]) | ||||
#define JS_ARRAY_END(array) ((array) + JS_ARRAY_LENGTH(array)) | ||||
JS_END_EXTERN_C | JS_END_EXTERN_C | |||
#endif /* jstypes_h___ */ | #endif /* jstypes_h___ */ | |||
End of changes. 15 change blocks. | ||||
17 lines changed or deleted | 95 lines changed or added | |||
jsxdrapi.h | jsxdrapi.h | |||
---|---|---|---|---|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | /* -*- 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 ***** | * ***** BEGIN LICENSE BLOCK ***** | |||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | |||
* | * | |||
* The contents of this file are subject to the Mozilla Public License Vers ion | * The contents of this file are subject to the Mozilla Public License Vers ion | |||
* 1.1 (the "License"); you may not use this file except in compliance with | * 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 | * the License. You may obtain a copy of the License at | |||
* http://www.mozilla.org/MPL/ | * http://www.mozilla.org/MPL/ | |||
* | * | |||
* Software distributed under the License is distributed on an "AS IS" basi s, | * Software distributed under the License is distributed on an "AS IS" basi s, | |||
skipping to change at line 117 | skipping to change at line 118 | |||
struct JSXDRState { | struct JSXDRState { | |||
JSXDRMode mode; | JSXDRMode mode; | |||
JSXDROps *ops; | JSXDROps *ops; | |||
JSContext *cx; | JSContext *cx; | |||
JSClass **registry; | JSClass **registry; | |||
uintN numclasses; | uintN numclasses; | |||
uintN maxclasses; | uintN maxclasses; | |||
void *reghash; | void *reghash; | |||
void *userdata; | void *userdata; | |||
JSScript *script; | ||||
}; | }; | |||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | |||
JS_XDRInitBase(JSXDRState *xdr, JSXDRMode mode, JSContext *cx); | JS_XDRInitBase(JSXDRState *xdr, JSXDRMode mode, JSContext *cx); | |||
extern JS_PUBLIC_API(JSXDRState *) | extern JS_PUBLIC_API(JSXDRState *) | |||
JS_XDRNewMem(JSContext *cx, JSXDRMode mode); | JS_XDRNewMem(JSContext *cx, JSXDRMode mode); | |||
extern JS_PUBLIC_API(void *) | extern JS_PUBLIC_API(void *) | |||
JS_XDRMemGetData(JSXDRState *xdr, uint32 *lp); | JS_XDRMemGetData(JSXDRState *xdr, uint32 *lp); | |||
skipping to change at line 189 | skipping to change at line 191 | |||
extern JS_PUBLIC_API(JSClass *) | extern JS_PUBLIC_API(JSClass *) | |||
JS_XDRFindClassById(JSXDRState *xdr, uint32 id); | JS_XDRFindClassById(JSXDRState *xdr, uint32 id); | |||
/* | /* | |||
* Magic numbers. | * Magic numbers. | |||
*/ | */ | |||
#define JSXDR_MAGIC_SCRIPT_1 0xdead0001 | #define JSXDR_MAGIC_SCRIPT_1 0xdead0001 | |||
#define JSXDR_MAGIC_SCRIPT_2 0xdead0002 | #define JSXDR_MAGIC_SCRIPT_2 0xdead0002 | |||
#define JSXDR_MAGIC_SCRIPT_3 0xdead0003 | #define JSXDR_MAGIC_SCRIPT_3 0xdead0003 | |||
#define JSXDR_MAGIC_SCRIPT_4 0xdead0004 | #define JSXDR_MAGIC_SCRIPT_4 0xdead0004 | |||
#define JSXDR_MAGIC_SCRIPT_CURRENT JSXDR_MAGIC_SCRIPT_4 | #define JSXDR_MAGIC_SCRIPT_5 0xdead0005 | |||
#define JSXDR_MAGIC_SCRIPT_CURRENT JSXDR_MAGIC_SCRIPT_5 | ||||
/* | ||||
* Bytecode version number. Decrement the second term whenever JS bytecode | ||||
* changes incompatibly. | ||||
* | ||||
* This version number should be XDR'ed once near the front of any file or | ||||
* larger storage unit containing XDR'ed bytecode and other data, and check | ||||
ed | ||||
* before deserialization of bytecode. If the saved version does not match | ||||
* the current version, abort deserialization and invalidate the file. | ||||
*/ | ||||
#define JSXDR_BYTECODE_VERSION (0xb973c0de - 16) | ||||
/* | ||||
* Library-private functions. | ||||
*/ | ||||
extern JSBool | ||||
js_XDRAtom(JSXDRState *xdr, JSAtom **atomp); | ||||
extern JSBool | ||||
js_XDRStringAtom(JSXDRState *xdr, JSAtom **atomp); | ||||
/* | ||||
* FIXME: This is non-unicode version of js_XDRStringAtom that performs los | ||||
sy | ||||
* conversion. Do not use it in the new code! See bug 325202. | ||||
*/ | ||||
extern JSBool | ||||
js_XDRCStringAtom(JSXDRState *xdr, JSAtom **atomp); | ||||
JS_END_EXTERN_C | JS_END_EXTERN_C | |||
#endif /* ! jsxdrapi_h___ */ | #endif /* ! jsxdrapi_h___ */ | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 33 lines changed or added | |||
prmjtime.h | prmjtime.h | |||
---|---|---|---|---|
skipping to change at line 60 | skipping to change at line 60 | |||
#endif | #endif | |||
JS_BEGIN_EXTERN_C | JS_BEGIN_EXTERN_C | |||
typedef struct PRMJTime PRMJTime; | typedef struct PRMJTime PRMJTime; | |||
/* | /* | |||
* Broken down form of 64 bit time value. | * Broken down form of 64 bit time value. | |||
*/ | */ | |||
struct PRMJTime { | struct PRMJTime { | |||
JSInt32 tm_usec; /* microseconds of second (0-999999) */ | JSInt32 tm_usec; /* microseconds of second (0-999999) */ | |||
JSInt8 tm_sec; /* seconds of minute (0-59) */ | JSInt8 tm_sec; /* seconds of minute (0-59) */ | |||
JSInt8 tm_min; /* minutes of hour (0-59) */ | JSInt8 tm_min; /* minutes of hour (0-59) */ | |||
JSInt8 tm_hour; /* hour of day (0-23) */ | JSInt8 tm_hour; /* hour of day (0-23) */ | |||
JSInt8 tm_mday; /* day of month (1-31) */ | JSInt8 tm_mday; /* day of month (1-31) */ | |||
JSInt8 tm_mon; /* month of year (0-11) */ | JSInt8 tm_mon; /* month of year (0-11) */ | |||
JSInt8 tm_wday; /* 0=sunday, 1=monday, ... */ | JSInt8 tm_wday; /* 0=sunday, 1=monday, ... */ | |||
JSInt16 tm_year; /* absolute year, AD */ | JSInt16 tm_year; /* absolute year, AD */ | |||
JSInt16 tm_yday; /* day of year (0 to 365) */ | JSInt16 tm_yday; /* day of year (0 to 365) */ | |||
JSInt8 tm_isdst; /* non-zero if DST in effect */ | JSInt8 tm_isdst; /* non-zero if DST in effect */ | |||
}; | }; | |||
/* Some handy constants */ | /* Some handy constants */ | |||
#define PRMJ_USEC_PER_SEC 1000000L | #define PRMJ_USEC_PER_SEC 1000000L | |||
#define PRMJ_USEC_PER_MSEC 1000L | #define PRMJ_USEC_PER_MSEC 1000L | |||
/* Return the current local time in micro-seconds */ | /* Return the current local time in micro-seconds */ | |||
extern JSInt64 | extern JSInt64 | |||
PRMJ_Now(void); | PRMJ_Now(void); | |||
/* get the difference between this time zone and gmt timezone in seconds * / | /* get the difference between this time zone and gmt timezone in seconds * / | |||
extern JSInt32 | extern JSInt32 | |||
PRMJ_LocalGMTDifference(void); | PRMJ_LocalGMTDifference(void); | |||
/* Format a time value into a buffer. Same semantics as strftime() */ | /* Format a time value into a buffer. Same semantics as strftime() */ | |||
End of changes. 2 change blocks. | ||||
12 lines changed or deleted | 12 lines changed or added | |||