mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-09 04:25:38 +00:00
Bug 880697 - Add JSRuntime constructor for Rooted. r=terrence
This commit is contained in:
parent
6b8fe5f75e
commit
ba19c64e28
@ -506,9 +506,8 @@ class MOZ_STACK_CLASS Rooted : public js::RootedBase<T>
|
||||
#endif
|
||||
}
|
||||
|
||||
void init(js::PerThreadData *ptArg) {
|
||||
void init(js::PerThreadDataFriendFields *pt) {
|
||||
#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING)
|
||||
js::PerThreadDataFriendFields *pt = js::PerThreadDataFriendFields::get(ptArg);
|
||||
commonInit(pt->thingGCRooters);
|
||||
#endif
|
||||
}
|
||||
@ -535,7 +534,7 @@ class MOZ_STACK_CLASS Rooted : public js::RootedBase<T>
|
||||
: ptr(js::RootMethods<T>::initial())
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
init(pt);
|
||||
init(js::PerThreadDataFriendFields::get(pt));
|
||||
}
|
||||
|
||||
Rooted(js::PerThreadData *pt, T initial
|
||||
@ -543,7 +542,23 @@ class MOZ_STACK_CLASS Rooted : public js::RootedBase<T>
|
||||
: ptr(initial)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
init(pt);
|
||||
init(js::PerThreadDataFriendFields::get(pt));
|
||||
}
|
||||
|
||||
Rooted(JSRuntime *rt
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: ptr(js::RootMethods<T>::initial())
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
init(js::PerThreadDataFriendFields::getMainThread(rt));
|
||||
}
|
||||
|
||||
Rooted(JSRuntime *rt, T initial
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: ptr(initial)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
init(js::PerThreadDataFriendFields::getMainThread(rt));
|
||||
}
|
||||
|
||||
~Rooted() {
|
||||
|
@ -31,6 +31,7 @@ CPP_SOURCES += [
|
||||
'testFindSCCs.cpp',
|
||||
'testFuncCallback.cpp',
|
||||
'testFunctionProperties.cpp',
|
||||
'testGCExactRooting.cpp',
|
||||
'testGCFinalizeCallback.cpp',
|
||||
'testGCOutOfMemory.cpp',
|
||||
'testGetPropertyDefault.cpp',
|
||||
|
23
js/src/jsapi-tests/testGCExactRooting.cpp
Normal file
23
js/src/jsapi-tests/testGCExactRooting.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||
*/
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
BEGIN_TEST(testGCExactRooting)
|
||||
{
|
||||
JS::RootedObject rootCx(cx, JS_NewObject(cx, NULL, NULL, NULL));
|
||||
JS::RootedObject rootRt(cx->runtime(), JS_NewObject(cx, NULL, NULL, NULL));
|
||||
|
||||
JS_GC(cx->runtime());
|
||||
|
||||
/* Use the objects we just created to ensure that they are still alive. */
|
||||
JS_DefineProperty(cx, rootCx, "foo", JS::DoubleValue(0), NULL, NULL, 0);
|
||||
JS_DefineProperty(cx, rootRt, "foo", JS::DoubleValue(0), NULL, NULL, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
END_TEST(testGCExactRooting)
|
Loading…
x
Reference in New Issue
Block a user