Bug 829372 - Don't clobber non-pointer-sized fields in root analysis; r=sfink

This commit is contained in:
Terrence Cole 2013-01-10 17:46:06 -08:00
parent ea850c1150
commit 8aa6190817

View File

@ -164,6 +164,11 @@ JS_FRIEND_API(void) LeaveAssertNoGCScope();
JS_FRIEND_API(bool) InNoGCScope();
JS_FRIEND_API(bool) isGCEnabled();
#if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE)
extern void
CheckStackRoots(JSContext *cx);
#endif
/*
* Handle provides an implicit constructor for NullPtr so that, given:
* foo(Handle<JSObject*> h);
@ -612,6 +617,9 @@ class Rooted : public RootedBase<T>
#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING)
PerThreadDataFriendFields *pt = PerThreadDataFriendFields::get(ptArg);
commonInit(pt->thingGCRooters);
#endif
#if defined(JSGC_ROOT_ANALYSIS)
scanned = false;
#endif
}
@ -619,9 +627,6 @@ class Rooted : public RootedBase<T>
Rooted(JSRuntime *rt
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: ptr(RootMethods<T>::initial())
#if defined(JSGC_ROOT_ANALYSIS)
, scanned(false)
#endif
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
init(rt);
@ -630,9 +635,6 @@ class Rooted : public RootedBase<T>
Rooted(JSRuntime *rt, T initial
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: ptr(initial)
#if defined(JSGC_ROOT_ANALYSIS)
, scanned(false)
#endif
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
init(rt);
@ -641,9 +643,6 @@ class Rooted : public RootedBase<T>
Rooted(JSContext *cx
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: ptr(RootMethods<T>::initial())
#if defined(JSGC_ROOT_ANALYSIS)
, scanned(false)
#endif
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
init(cx);
@ -652,9 +651,6 @@ class Rooted : public RootedBase<T>
Rooted(JSContext *cx, T initial
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: ptr(initial)
#if defined(JSGC_ROOT_ANALYSIS)
, scanned(false)
#endif
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
init(cx);
@ -680,9 +676,6 @@ class Rooted : public RootedBase<T>
Rooted(JSContext *cx, const Unrooted<S> &initial
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: ptr(static_cast<S>(initial))
#if defined(JSGC_ROOT_ANALYSIS)
, scanned(false)
#endif
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
init(cx);
@ -732,16 +725,22 @@ class Rooted : public RootedBase<T>
#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING)
Rooted<T> **stack, *prev;
#endif
#if defined(JSGC_ROOT_ANALYSIS)
/* Has the rooting analysis ever scanned this Rooted's stack location? */
friend void JS::CheckStackRoots(JSContext*);
bool scanned;
#endif
/*
* |ptr| must be the last field in Rooted because the analysis treats all
* Rooted as Rooted<void*> during the analysis. See bug 829372.
*/
T ptr;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
Rooted(const Rooted &) MOZ_DELETE;
#if defined(JSGC_ROOT_ANALYSIS)
public:
/* Has the rooting analysis ever scanned this Rooted's stack location? */
bool scanned;
#endif
};
#if !(defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING))
@ -887,11 +886,6 @@ AssertCanGC()
JS_ASSERT_IF(isGCEnabled(), !InNoGCScope());
}
#if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE)
extern void
CheckStackRoots(JSContext *cx);
#endif
JS_FRIEND_API(bool) NeedRelaxedRootChecks();
} /* namespace JS */