зеркало из https://github.com/mozilla/gecko-dev.git
Checking in shaver's patch for bug 78100, adding JS_GetExternalStringGCType (sr=brendan&jband).
This commit is contained in:
Родитель
bd0a1540d1
Коммит
68f889e9bd
|
@ -1690,6 +1690,17 @@ JS_NewExternalString(JSContext *cx, jschar *chars, size_t length, intN type)
|
|||
return str;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(intN)
|
||||
JS_GetExternalStringGCType(JSRuntime *rt, JSString *str)
|
||||
{
|
||||
uint8 type = *js_GetGCThingFlags(str) & GCF_TYPEMASK;
|
||||
|
||||
JS_ASSERT(type == GCX_STRING || type >= GCX_EXTERNAL_STRING);
|
||||
if (type == GCX_STRING)
|
||||
return -1;
|
||||
return (intN)type;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
|
|
|
@ -640,6 +640,13 @@ JS_RemoveExternalStringFinalizer(JSStringFinalizeOp finalizer);
|
|||
extern JS_PUBLIC_API(JSString *)
|
||||
JS_NewExternalString(JSContext *cx, jschar *chars, size_t length, intN type);
|
||||
|
||||
/*
|
||||
* Returns the external-string finalizer index for this string, or -1 if it is
|
||||
* an "internal" (native to JS engine) string.
|
||||
*/
|
||||
extern JS_PUBLIC_API(intN)
|
||||
JS_GetExternalStringGCType(JSRuntime *rt, JSString *str);
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
|
|
|
@ -201,8 +201,8 @@ gc_new_arena(JSArenaPool *pool)
|
|||
return thing;
|
||||
}
|
||||
|
||||
static uint8 *
|
||||
gc_find_flags(void *thing)
|
||||
uint8 *
|
||||
js_GetGCThingFlags(void *thing)
|
||||
{
|
||||
JSGCPageInfo *pi;
|
||||
uint8 *flagp;
|
||||
|
@ -214,9 +214,11 @@ gc_find_flags(void *thing)
|
|||
return flagp;
|
||||
}
|
||||
|
||||
JSBool js_IsAboutToBeFinalized(JSContext *cx, void *thing)
|
||||
JSBool
|
||||
js_IsAboutToBeFinalized(JSContext *cx, void *thing)
|
||||
{
|
||||
uint8 flags = *gc_find_flags(thing);
|
||||
uint8 flags = *js_GetGCThingFlags(thing);
|
||||
|
||||
return !(flags & (GCF_MARK | GCF_LOCKMASK | GCF_FINAL));
|
||||
}
|
||||
|
||||
|
@ -518,7 +520,7 @@ retry:
|
|||
}
|
||||
|
||||
/* Find the flags pointer given thing's address. */
|
||||
flagp = gc_find_flags(thing);
|
||||
flagp = js_GetGCThingFlags(thing);
|
||||
}
|
||||
*flagp = (uint8)flags;
|
||||
rt->gcBytes += sizeof(JSGCThing) + sizeof(uint8);
|
||||
|
@ -544,7 +546,7 @@ js_LockGCThing(JSContext *cx, void *thing)
|
|||
|
||||
if (!thing)
|
||||
return JS_TRUE;
|
||||
flagp = gc_find_flags(thing);
|
||||
flagp = js_GetGCThingFlags(thing);
|
||||
flags = *flagp;
|
||||
|
||||
ok = JS_TRUE;
|
||||
|
@ -616,7 +618,7 @@ js_UnlockGCThing(JSContext *cx, void *thing)
|
|||
|
||||
if (!thing)
|
||||
return JS_TRUE;
|
||||
flagp = gc_find_flags(thing);
|
||||
flagp = js_GetGCThingFlags(thing);
|
||||
flags = *flagp;
|
||||
|
||||
rt = cx->runtime;
|
||||
|
@ -668,7 +670,7 @@ JS_EXPORT_DATA(void *) js_LiveThingToFind;
|
|||
static const char *
|
||||
gc_object_class_name(void* thing)
|
||||
{
|
||||
uint8 *flagp = gc_find_flags(thing);
|
||||
uint8 *flagp = js_GetGCThingFlags(thing);
|
||||
const char *className = "";
|
||||
|
||||
if (flagp && ((*flagp & GCF_TYPEMASK) == GCX_OBJECT)) {
|
||||
|
@ -788,7 +790,7 @@ js_MarkGCThing(JSContext *cx, void *thing, void *arg)
|
|||
if (!thing)
|
||||
return;
|
||||
|
||||
flagp = gc_find_flags(thing);
|
||||
flagp = js_GetGCThingFlags(thing);
|
||||
flags = *flagp;
|
||||
JS_ASSERT(flags != GCF_FINAL);
|
||||
#ifdef GC_MARK_DEBUG
|
||||
|
|
|
@ -59,6 +59,9 @@ JS_BEGIN_EXTERN_C
|
|||
#define GCF_LOCKMASK (JS_BITMASK(8 - GCF_LOCKSHIFT) << GCF_LOCKSHIFT)
|
||||
#define GCF_LOCK JS_BIT(GCF_LOCKSHIFT) /* lock request bit in API */
|
||||
|
||||
extern uint8 *
|
||||
js_GetGCThingFlags(void *thing);
|
||||
|
||||
/* These are compatible with JSDHashEntryStub. */
|
||||
struct JSGCRootHashEntry {
|
||||
JSDHashEntryHdr hdr;
|
||||
|
|
|
@ -275,11 +275,16 @@ typedef JSBool
|
|||
JSBool *bp);
|
||||
|
||||
/*
|
||||
* Function type for JSClass.mark and JSObjectOps.mark, called from the GC
|
||||
* to scan live GC-things reachable from obj's private data. For each such
|
||||
* private thing, an implementation must call js_MarkGCThing(cx, thing, arg).
|
||||
* The trailing arg is used for GC_MARK_DEBUG-mode heap dumping and ref-path
|
||||
* tracing.
|
||||
* Function type for JSClass.mark and JSObjectOps.mark, called from the GC to
|
||||
* scan live GC-things reachable from obj's private data structure. For each
|
||||
* such thing, a mark implementation must call
|
||||
*
|
||||
* JS_MarkGCThing(cx, thing, name, arg);
|
||||
*
|
||||
* The trailing name and arg parameters are used for GC_MARK_DEBUG-mode heap
|
||||
* dumping and ref-path tracing. The mark function should pass a (typically
|
||||
* literal) string naming the private data member for name, and it must pass
|
||||
* the opaque arg parameter through from its caller.
|
||||
*
|
||||
* For the JSObjectOps.mark hook, the return value is the number of slots at
|
||||
* obj->slots to scan. For JSClass.mark, the return value is ignored.
|
||||
|
|
Загрузка…
Ссылка в новой задаче