Backing out 408301 to see if it fixes winxp01 orange

This commit is contained in:
roc+@cs.cmu.edu 2008-01-08 19:21:35 -08:00
parent 7588c92bef
commit 2726b61178
4 changed files with 31 additions and 118 deletions

View File

@ -1159,7 +1159,6 @@ extern JSClass XPC_WN_NoMods_NoCall_Proto_JSClass;
extern JSClass XPC_WN_ModsAllowed_WithCall_Proto_JSClass;
extern JSClass XPC_WN_ModsAllowed_NoCall_Proto_JSClass;
extern JSClass XPC_WN_Tearoff_JSClass;
extern JSClass XPC_WN_NoHelper_Proto_JSClass;
extern JSObjectOps * JS_DLL_CALLBACK
XPC_WN_GetObjectOpsNoCall(JSContext *cx, JSClass *clazz);
@ -1167,9 +1166,6 @@ XPC_WN_GetObjectOpsNoCall(JSContext *cx, JSClass *clazz);
extern JSObjectOps * JS_DLL_CALLBACK
XPC_WN_GetObjectOpsWithCall(JSContext *cx, JSClass *clazz);
extern JSObjectOps * JS_DLL_CALLBACK
XPC_WN_Proto_GetObjectOps(JSContext *cx, JSClass *clazz);
extern JSBool JS_DLL_CALLBACK
XPC_WN_CallMethod(JSContext *cx, JSObject *obj,
uintN argc, jsval *argv, jsval *vp);
@ -1227,11 +1223,6 @@ public:
JSObject*
GetPrototypeJSObject() const {return mPrototypeJSObject;}
// Getter for the prototype that we use for wrappers that have no
// helper.
JSObject*
GetPrototypeNoHelper(XPCCallContext& ccx);
#ifndef XPCONNECT_STANDALONE
nsIPrincipal*
GetPrincipal() const
@ -1325,13 +1316,8 @@ private:
// unless a PreCreate hook overrides it. Note that this _may_ be null (see
// constructor).
JSObject* mGlobalJSObject;
// Cached value of Object.prototype
JSObject* mPrototypeJSObject;
// Cached value of Function.prototype
JSObject* mPrototypeJSFunction;
// Prototype to use for wrappers with no helper.
JSObject* mPrototypeNoHelper;
#ifndef XPCONNECT_STANDALONE
// The script object principal instance corresponding to our current global

View File

@ -874,11 +874,7 @@ XPCWrappedNative::Init(XPCCallContext& ccx, JSObject* parent, JSBool isGlobal,
JSObject* protoJSObject = HasProto() ?
GetProto()->GetJSProtoObject() :
GetScope()->GetPrototypeNoHelper(ccx);
if (!protoJSObject) {
return JS_FALSE;
}
GetScope()->GetPrototypeJSObject();
mFlatJSObject = xpc_NewSystemInheritingJSObject(ccx, jsclazz, protoJSObject,
parent);

View File

@ -899,7 +899,7 @@ JSExtendedClass XPC_WN_NoHelper_JSClass = {
XPC_WN_NoHelper_Finalize, // finalize;
/* Optionally non-null members start here. */
XPC_WN_GetObjectOpsNoCall, // getObjectOps;
nsnull, // getObjectOps;
nsnull, // checkAccess;
nsnull, // call;
nsnull, // construct;
@ -1186,11 +1186,9 @@ JS_STATIC_DLL_CALLBACK(JSBool)
XPC_WN_JSOp_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
jsval *statep, jsid *idp)
{
JSClass *clazz = JS_GET_CLASS(cx, obj);
if(!IS_WRAPPER_CLASS(clazz) || clazz == &XPC_WN_NoHelper_JSClass.base)
if(!IS_WRAPPER_CLASS(JS_GET_CLASS(cx, obj)))
{
// obj must be a prototype object or a wrapper w/o a
// helper. Short circuit this call to
// obj must be a prototype object. Short circuit this call to
// js_ObjectOps.enumerate().
return js_ObjectOps.enumerate(cx, obj, enum_op, statep, idp);
@ -1635,8 +1633,7 @@ XPC_WN_Proto_GetObjectOps(JSContext *cx, JSClass *clazz)
return &XPC_WN_WithCall_JSOps;
NS_ASSERTION(clazz == &XPC_WN_ModsAllowed_NoCall_Proto_JSClass ||
clazz == &XPC_WN_NoMods_NoCall_Proto_JSClass ||
clazz == &XPC_WN_NoHelper_Proto_JSClass,
clazz == &XPC_WN_NoMods_NoCall_Proto_JSClass,
"bad proto");
return &XPC_WN_NoCall_JSOps;

View File

@ -120,11 +120,10 @@ XPCWrappedNativeScope::GetNewOrUsed(XPCCallContext& ccx, JSObject* aGlobal)
else
{
// We need to call SetGlobal in order to refresh our cached
// mPrototypeJSObject and mPrototypeJSFunction and to clear
// mPrototypeNoHelper (so we get a new one if requested in the
// new scope) in the case where the global object is being
// reused (JS_ClearScope has been called). NOTE: We are only
// called by nsXPConnect::InitClasses.
// mPrototypeJSObject and mPrototypeJSFunction in the case where
// the global object is being reused (JS_ClearScope has been
// called).
// NOTE: We are only called by nsXPConnect::InitClasses.
scope->SetGlobal(ccx, aGlobal);
}
return scope;
@ -140,8 +139,7 @@ XPCWrappedNativeScope::XPCWrappedNativeScope(XPCCallContext& ccx,
mNext(nsnull),
mGlobalJSObject(nsnull),
mPrototypeJSObject(nsnull),
mPrototypeJSFunction(nsnull),
mPrototypeNoHelper(nsnull)
mPrototypeJSFunction(nsnull)
{
// add ourselves to the scopes list
{ // scoped lock
@ -183,41 +181,6 @@ XPCWrappedNativeScope::SetComponents(nsXPCComponents* aComponents)
mComponents = aComponents;
}
// Dummy JS class to let wrappers w/o an xpc prototype share
// scopes. By doing this we avoid allocating a new scope for every
// wrapper on creation of the wrapper, and most wrappers won't need
// their own scope at all for the lifetime of the wrapper.
// JSCLASS_HAS_PRIVATE is key here (even though there's never anything
// in the private data slot in these prototypes), as the number of
// reserved slots in this class needs to match that of the wrappers
// for the JS engine to share scopes.
JSClass XPC_WN_NoHelper_Proto_JSClass = {
"XPC_WN_NoHelper_Proto_JSClass",// name;
JSCLASS_HAS_PRIVATE, // flags;
/* Mandatory non-null function pointer members. */
JS_PropertyStub, // addProperty;
JS_PropertyStub, // delProperty;
JS_PropertyStub, // getProperty;
JS_PropertyStub, // setProperty;
JS_EnumerateStub, // enumerate;
JS_ResolveStub, // resolve;
JS_ConvertStub, // convert;
JS_FinalizeStub, // finalize;
/* Optionally non-null members start here. */
XPC_WN_Proto_GetObjectOps, // getObjectOps;
nsnull, // checkAccess;
nsnull, // call;
nsnull, // construct;
nsnull, // xdrObject;
nsnull, // hasInstance;
nsnull, // mark/trace;
nsnull // spare;
};
void
XPCWrappedNativeScope::SetGlobal(XPCCallContext& ccx, JSObject* aGlobal)
{
@ -228,10 +191,11 @@ XPCWrappedNativeScope::SetGlobal(XPCCallContext& ccx, JSObject* aGlobal)
#ifndef XPCONNECT_STANDALONE
mScriptObjectPrincipal = nsnull;
// Now init our script object principal, if the new global has one
if (aGlobal)
{
JSContext* cx = ccx.GetJSContext();
const JSClass* jsClass = JS_GetClass(cx, aGlobal);
if(!(~jsClass->flags & (JSCLASS_HAS_PRIVATE |
if (jsClass && !(~jsClass->flags & (JSCLASS_HAS_PRIVATE |
JSCLASS_PRIVATE_IS_NSISUPPORTS)))
{
// Our global has an nsISupports native pointer. Let's
@ -243,11 +207,11 @@ XPCWrappedNativeScope::SetGlobal(XPCCallContext& ccx, JSObject* aGlobal)
{
mScriptObjectPrincipal = do_QueryWrappedNative(native);
}
if(!mScriptObjectPrincipal)
{
if (!mScriptObjectPrincipal) {
mScriptObjectPrincipal = do_QueryInterface(priv);
}
}
}
#endif
// Lookup 'globalObject.Object.prototype' for our wrapper's proto
@ -283,10 +247,6 @@ XPCWrappedNativeScope::SetGlobal(XPCCallContext& ccx, JSObject* aGlobal)
NS_ERROR("Can't get globalObject.Function.prototype");
}
}
// Clear the no helper wrapper prototype object so that a new one
// gets created if needed.
mPrototypeNoHelper = nsnull;
}
XPCWrappedNativeScope::~XPCWrappedNativeScope()
@ -319,25 +279,6 @@ XPCWrappedNativeScope::~XPCWrappedNativeScope()
NS_IF_RELEASE(mComponents);
}
JSObject *
XPCWrappedNativeScope::GetPrototypeNoHelper(XPCCallContext& ccx)
{
// We could create this prototype in SetGlobal(), but all scopes
// don't need one, so we save ourselves a bit of space if we
// create these when they're needed.
if(!mPrototypeNoHelper)
{
mPrototypeNoHelper =
xpc_NewSystemInheritingJSObject(ccx, &XPC_WN_NoHelper_Proto_JSClass,
mPrototypeJSObject,
mGlobalJSObject);
NS_ASSERTION(mPrototypeNoHelper,
"Failed to create prototype for wrappers w/o a helper");
}
return mPrototypeNoHelper;
}
JS_STATIC_DLL_CALLBACK(JSDHashOperator)
WrappedNativeJSGCThingTracer(JSDHashTable *table, JSDHashEntryHdr *hdr,
@ -466,11 +407,6 @@ XPCWrappedNativeScope::FinishedMarkPhaseOfGC(JSContext* cx, XPCJSRuntime* rt)
{
cur->mPrototypeJSFunction = nsnull;
}
if(cur->mPrototypeNoHelper &&
JS_IsAboutToBeFinalized(cx, cur->mPrototypeNoHelper))
{
cur->mPrototypeNoHelper = nsnull;
}
}
if(cur)
prev = cur;
@ -701,12 +637,11 @@ GetScopeOfObject(JSContext* cx, JSObject* obj)
{
#ifdef DEBUG
{
if(!(~clazz->flags & (JSCLASS_HAS_PRIVATE |
JSCLASS_PRIVATE_IS_NSISUPPORTS)) &&
(supports = (nsISupports*) JS_GetPrivate(cx, obj)))
if(clazz->flags & JSCLASS_HAS_PRIVATE &&
clazz->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS)
{
nsCOMPtr<nsIXPConnectWrappedNative> iface =
do_QueryInterface(supports);
do_QueryInterface((nsISupports*) JS_GetPrivate(cx, obj));
NS_ASSERTION(!iface, "Uh, how'd this happen?");
}
@ -926,7 +861,6 @@ XPCWrappedNativeScope::DebugDump(PRInt16 depth)
XPC_LOG_ALWAYS(("mGlobalJSObject @ %x", mGlobalJSObject));
XPC_LOG_ALWAYS(("mPrototypeJSObject @ %x", mPrototypeJSObject));
XPC_LOG_ALWAYS(("mPrototypeJSFunction @ %x", mPrototypeJSFunction));
XPC_LOG_ALWAYS(("mPrototypeNoHelper @ %x", mPrototypeNoHelper));
XPC_LOG_ALWAYS(("mWrappedNativeMap @ %x with %d wrappers(s)", \
mWrappedNativeMap, \