Bug 692277 - Part b: Remove js/src from xpconnect LOCAL_INCLUDES; r=luke

This commit is contained in:
Ms2ger 2011-12-24 09:27:51 +01:00
Родитель 571eedbbef
Коммит 045c664fb2
11 изменённых файлов: 79 добавлений и 58 удалений

Просмотреть файл

@ -184,6 +184,12 @@ AutoSwitchCompartment::~AutoSwitchCompartment()
cx->compartment = oldCompartment;
}
JS_FRIEND_API(bool)
js::IsSystemCompartment(const JSCompartment *c)
{
return c->isSystemCompartment;
}
JS_FRIEND_API(bool)
js::IsScopeObject(const JSObject *obj)
{

Просмотреть файл

@ -190,6 +190,9 @@ JS_FRIEND_API(JSBool) obj_defineGetter(JSContext *cx, uintN argc, js::Value *vp)
JS_FRIEND_API(JSBool) obj_defineSetter(JSContext *cx, uintN argc, js::Value *vp);
#endif
extern JS_FRIEND_API(bool)
IsSystemCompartment(const JSCompartment *compartment);
/*
* Check whether it is OK to assign an undeclared property with name
* propname of the global object in the current script on cx. Reports
@ -438,6 +441,15 @@ JS_FRIEND_API(JSString *)
GetPCCountScriptContents(JSContext *cx, size_t script);
} /* namespace js */
/*
* If protoKey is not JSProto_Null, then clasp is ignored. If protoKey is
* JSProto_Null, clasp must non-null.
*/
extern JS_FRIEND_API(JSBool)
js_GetClassPrototype(JSContext *cx, JSObject *scope, JSProtoKey protoKey,
JSObject **protop, js::Class *clasp = NULL);
#endif
#endif /* jsfriendapi_h___ */

Просмотреть файл

@ -1230,6 +1230,12 @@ const size_t INITIAL_CHUNK_CAPACITY = 16 * 1024 * 1024 / ChunkSize;
/* The number of GC cycles an empty chunk can survive before been released. */
const size_t MAX_EMPTY_CHUNK_AGE = 4;
inline Cell *
AsCell(JSObject *obj)
{
return reinterpret_cast<Cell *>(obj);
}
} /* namespace gc */
struct GCPtrHasher

Просмотреть файл

@ -1901,14 +1901,6 @@ CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
extern bool
js_IsDelegate(JSContext *cx, JSObject *obj, const js::Value &v);
/*
* If protoKey is not JSProto_Null, then clasp is ignored. If protoKey is
* JSProto_Null, clasp must non-null.
*/
extern JS_FRIEND_API(JSBool)
js_GetClassPrototype(JSContext *cx, JSObject *scope, JSProtoKey protoKey,
JSObject **protop, js::Class *clasp = NULL);
/*
* Wrap boolean, number or string as Boolean, Number or String object.
* *vp must not be an object, null or undefined.

Просмотреть файл

@ -94,7 +94,6 @@ include $(topsrcdir)/config/config.mk
LOCAL_INCLUDES = \
-I$(srcdir)/../wrappers \
-I$(srcdir)/../loader \
-I$(topsrcdir)/js/src \
-I$(topsrcdir)/caps/include \
-I$(topsrcdir)/content/base/src \
-I$(topsrcdir)/content/html/content/src \

Просмотреть файл

@ -48,7 +48,6 @@
#include "WrapperFactory.h"
#include "dom_quickstubs.h"
#include "jscompartment.h"
#include "nsIMemoryReporter.h"
#include "nsPrintfCString.h"
#include "mozilla/FunctionTimer.h"
@ -511,7 +510,7 @@ XPCJSRuntime::SuspectWrappedNative(JSContext *cx, XPCWrappedNative *wrapper,
// Only suspect wrappedJSObjects that are in a compartment that
// participates in cycle collection.
JSObject* obj = wrapper->GetFlatJSObjectPreserveColor();
if (!xpc::ParticipatesInCycleCollection(cx, obj))
if (!xpc::ParticipatesInCycleCollection(cx, js::gc::AsCell(obj)))
return;
// Only record objects that might be part of a cycle as roots, unless
@ -588,7 +587,7 @@ XPCJSRuntime::AddXPConnectRoots(JSContext* cx,
// Only suspect wrappedJSObjects that are in a compartment that
// participates in cycle collection.
if (!xpc::ParticipatesInCycleCollection(cx, obj))
if (!xpc::ParticipatesInCycleCollection(cx, js::gc::AsCell(obj)))
continue;
cb.NoteXPCOMRoot(static_cast<nsIXPConnectWrappedJS *>(wrappedJS));
@ -1507,18 +1506,20 @@ CompartmentStats::CompartmentStats(JSContext *cx, JSCompartment *c)
if (c == cx->runtime->atomsCompartment) {
name.AssignLiteral("atoms");
} else if (c->principals) {
if (c->principals->codebase) {
name.Assign(c->principals->codebase);
} else if (JSPrincipals *principals = JS_GetCompartmentPrincipals(c)) {
if (principals->codebase) {
name.Assign(principals->codebase);
// If it's the system compartment, append the address.
// This means that multiple system compartments (and there
// can be many) can be distinguished.
if (c->isSystemCompartment) {
if (c->data &&
!((xpc::CompartmentPrivate*)c->data)->location.IsEmpty()) {
if (js::IsSystemCompartment(c)) {
xpc::CompartmentPrivate *compartmentPrivate =
static_cast<xpc::CompartmentPrivate*>(JS_GetCompartmentPrivate(cx, c));
if (compartmentPrivate &&
!compartmentPrivate->location.IsEmpty()) {
name.AppendLiteral(", ");
name.Append(((xpc::CompartmentPrivate*)c->data)->location);
name.Append(compartmentPrivate->location);
}
// ample; 64-bit address max is 18 chars
@ -2147,12 +2148,12 @@ bool XPCJSRuntime::gNewDOMBindingsEnabled;
bool PreserveWrapper(JSContext *cx, JSObject *obj)
{
JS_ASSERT(obj->getClass()->ext.isWrappedNative);
JS_ASSERT(IS_WRAPPER_CLASS(js::GetObjectClass(obj)));
nsISupports *native = nsXPConnect::GetXPConnect()->GetNativeOfWrapper(cx, obj);
if (!native)
return false;
nsresult rv;
nsCOMPtr<nsINode> node = nsQueryInterfaceWithError(native, &rv);
nsCOMPtr<nsINode> node = do_QueryInterface(native, &rv);
if (NS_FAILED(rv))
return false;
nsContentUtils::PreserveWrapper(native, node);

Просмотреть файл

@ -47,10 +47,14 @@
#include "WrapperFactory.h"
#include "nsDOMClassInfo.h"
#include "nsGlobalWindow.h"
#include "jsiter.h"
#include "nsWrapperCacheInlines.h"
using namespace js;
#include "jsapi.h"
#include "jscntxt.h" // js::AutoIdVector
using namespace JS;
using js::AutoIdVector;
namespace mozilla {
namespace dom {
@ -352,7 +356,7 @@ ListBase<LC>::namedItem(JSContext *cx, JSObject *obj, jsval *name, NameGetterTyp
}
JSBool
interface_hasInstance(JSContext *cx, JSObject *obj, const js::Value *vp, JSBool *bp)
interface_hasInstance(JSContext *cx, JSObject *obj, const JS::Value *vp, JSBool *bp)
{
if (vp->isObject()) {
jsval prototype;
@ -551,7 +555,7 @@ GetArrayIndexFromId(JSContext *cx, jsid id)
}
static void
FillPropertyDescriptor(PropertyDescriptor *desc, JSObject *obj, jsval v, bool readonly)
FillPropertyDescriptor(JSPropertyDescriptor *desc, JSObject *obj, jsval v, bool readonly)
{
desc->obj = obj;
desc->value = v;
@ -564,7 +568,7 @@ FillPropertyDescriptor(PropertyDescriptor *desc, JSObject *obj, jsval v, bool re
template<class LC>
bool
ListBase<LC>::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
PropertyDescriptor *desc)
JSPropertyDescriptor *desc)
{
if (set) {
if (hasIndexSetter) {
@ -630,7 +634,7 @@ ListBase<LC>::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
template<class LC>
bool
ListBase<LC>::getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
PropertyDescriptor *desc)
JSPropertyDescriptor *desc)
{
if (!getOwnPropertyDescriptor(cx, proxy, id, set, desc))
return false;
@ -684,7 +688,7 @@ ListBase<LC>::ensureExpandoObject(JSContext *cx, JSObject *obj)
template<class LC>
bool
ListBase<LC>::defineProperty(JSContext *cx, JSObject *proxy, jsid id, PropertyDescriptor *desc)
ListBase<LC>::defineProperty(JSContext *cx, JSObject *proxy, jsid id, JSPropertyDescriptor *desc)
{
if (hasIndexSetter) {
int32_t index = GetArrayIndexFromId(cx, id);
@ -874,7 +878,7 @@ ListBase<LC>::shouldCacheProtoShape(JSContext *cx, JSObject *proto, bool *should
template<class LC>
bool
ListBase<LC>::resolveNativeName(JSContext *cx, JSObject *proxy, jsid id, PropertyDescriptor *desc)
ListBase<LC>::resolveNativeName(JSContext *cx, JSObject *proxy, jsid id, JSPropertyDescriptor *desc)
{
JS_ASSERT(xpc::WrapperFactory::IsXrayWrapper(proxy));
@ -951,7 +955,7 @@ ListBase<LC>::nativeGet(JSContext *cx, JSObject *proxy, JSObject *proto, jsid id
template<class LC>
bool
ListBase<LC>::getPropertyOnPrototype(JSContext *cx, JSObject *proxy, jsid id, bool *found,
js::Value *vp)
JS::Value *vp)
{
JSObject *proto = js::GetObjectProto(proxy);
if (!proto)

Просмотреть файл

@ -132,12 +132,12 @@ public:
*shouldCache = true;
return true;
}
static bool resolveNativeName(JSContext *cx, JSObject *proxy, jsid id, js::PropertyDescriptor *desc)
static bool resolveNativeName(JSContext *cx, JSObject *proxy, jsid id, JSPropertyDescriptor *desc)
{
return true;
}
static bool nativeGet(JSContext *cx, JSObject *proxy, JSObject *proto, jsid id, bool *found,
js::Value *vp)
JS::Value *vp)
{
*found = false;
return true;
@ -203,7 +203,7 @@ private:
NameSetterType item);
static bool getPropertyOnPrototype(JSContext *cx, JSObject *proxy, jsid id, bool *found,
js::Value *vp);
JS::Value *vp);
static bool hasPropertyOnPrototype(JSContext *cx, JSObject *proxy, jsid id);
public:
@ -213,28 +213,28 @@ public:
static JSObject *getPrototype(JSContext *cx, XPCWrappedNativeScope *scope, bool *enabled);
bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
js::PropertyDescriptor *desc);
JSPropertyDescriptor *desc);
bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
js::PropertyDescriptor *desc);
JSPropertyDescriptor *desc);
bool defineProperty(JSContext *cx, JSObject *proxy, jsid id,
js::PropertyDescriptor *desc);
JSPropertyDescriptor *desc);
bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, js::AutoIdVector &props);
bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
bool enumerate(JSContext *cx, JSObject *proxy, js::AutoIdVector &props);
bool fix(JSContext *cx, JSObject *proxy, js::Value *vp);
bool fix(JSContext *cx, JSObject *proxy, JS::Value *vp);
bool has(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
bool hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, js::Value *vp);
bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, JS::Value *vp);
bool getElementIfPresent(JSContext *cx, JSObject *proxy, JSObject *receiver,
uint32 index, js::Value *vp, bool *present);
uint32 index, JS::Value *vp, bool *present);
bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict,
js::Value *vp);
JS::Value *vp);
bool keys(JSContext *cx, JSObject *proxy, js::AutoIdVector &props);
bool iterate(JSContext *cx, JSObject *proxy, uintN flags, js::Value *vp);
bool iterate(JSContext *cx, JSObject *proxy, uintN flags, JS::Value *vp);
/* Spidermonkey extensions. */
bool hasInstance(JSContext *cx, JSObject *proxy, const js::Value *vp, bool *bp);
bool hasInstance(JSContext *cx, JSObject *proxy, const JS::Value *vp, bool *bp);
JSString *obj_toString(JSContext *cx, JSObject *proxy);
void finalize(JSContext *cx, JSObject *proxy);
@ -254,9 +254,9 @@ public:
static JSObject *getPrototype(JSContext *cx, XPCWrappedNativeScope *scope);
static bool shouldCacheProtoShape(JSContext *cx, JSObject *proto, bool *shouldCache);
static bool resolveNativeName(JSContext *cx, JSObject *proxy, jsid id,
js::PropertyDescriptor *desc);
JSPropertyDescriptor *desc);
static bool nativeGet(JSContext *cx, JSObject *proxy, JSObject *proto, jsid id, bool *found,
js::Value *vp);
JS::Value *vp);
static ListType *getNative(JSObject *proxy);
};

Просмотреть файл

@ -47,11 +47,8 @@
#include "nsBaseHashtable.h"
#include "nsHashKeys.h"
#include "jsatom.h"
#include "jsobj.h"
#include "jsfriendapi.h"
#include "jsfun.h"
#include "jsgc.h"
#include "jsscript.h"
#include "nsThreadUtilsInternal.h"
#include "dom_quickstubs.h"
#include "nsNullPrincipal.h"
@ -738,7 +735,7 @@ xpc_UnmarkGrayObjectRecursive(JSObject *obj)
NS_ASSERTION(obj, "Don't pass me null!");
// Unmark.
obj->unmark(js::gc::GRAY);
js::gc::AsCell(obj)->unmark(js::gc::GRAY);
// Tracing requires a JSContext...
JSContext *cx;
@ -919,9 +916,9 @@ nsXPConnect::Traverse(void *p, nsCycleCollectionTraversalCallback &cb)
}
// Disable printing global for objects while we figure out ObjShrink fallout.
cb.DescribeGCedNode(isMarked, sizeof(JSObject), name);
cb.DescribeGCedNode(isMarked, sizeof(js::shadow::Object), name);
} else {
cb.DescribeGCedNode(isMarked, sizeof(JSObject), "JS Object");
cb.DescribeGCedNode(isMarked, sizeof(js::shadow::Object), "JS Object");
}
// There's no need to trace objects that have already been marked by the JS
@ -1115,7 +1112,7 @@ CreateNewCompartment(JSContext *cx, JSClass *clasp, nsIPrincipal *principal,
return false;
*global = tempGlobal;
*compartment = tempGlobal->compartment();
*compartment = js::GetObjectCompartment(tempGlobal);
js::AutoSwitchCompartment sc(cx, *compartment);
JS_SetCompartmentPrivate(cx, *compartment, priv_holder.forget());

Просмотреть файл

@ -1485,11 +1485,13 @@ XPC_WN_JSOp_ThisObject(JSContext *cx, JSObject *obj);
// Maybe this macro should check for class->enumerate ==
// XPC_WN_Shared_Proto_Enumerate or something rather than checking for
// 4 classes?
#define IS_PROTO_CLASS(clazz) \
((clazz) == &XPC_WN_NoMods_WithCall_Proto_JSClass || \
(clazz) == &XPC_WN_NoMods_NoCall_Proto_JSClass || \
(clazz) == &XPC_WN_ModsAllowed_WithCall_Proto_JSClass || \
(clazz) == &XPC_WN_ModsAllowed_NoCall_Proto_JSClass)
static inline bool IS_PROTO_CLASS(js::Class *clazz)
{
return clazz == &XPC_WN_NoMods_WithCall_Proto_JSClass ||
clazz == &XPC_WN_NoMods_NoCall_Proto_JSClass ||
clazz == &XPC_WN_ModsAllowed_WithCall_Proto_JSClass ||
clazz == &XPC_WN_ModsAllowed_NoCall_Proto_JSClass;
}
/***************************************************************************/

Просмотреть файл

@ -86,8 +86,10 @@ xpc_LocalizeContext(JSContext *cx);
nsresult
xpc_MorphSlimWrapper(JSContext *cx, nsISupports *tomorph);
#define IS_WRAPPER_CLASS(clazz) \
((clazz)->ext.isWrappedNative)
static inline bool IS_WRAPPER_CLASS(js::Class* clazz)
{
return clazz->ext.isWrappedNative;
}
inline JSBool
DebugCheckWrapperClass(JSObject* obj)