Back out 3ab1dcfb2218 and 46ae4bf4aaf4 (bug 622301) for Windows PGO bustage

This commit is contained in:
Phil Ringnalda 2012-01-14 18:56:00 -08:00
parent 6af65a3e2d
commit 569c6d1acc
6 changed files with 41 additions and 66 deletions

View File

@ -58,7 +58,7 @@ Canvas2D_SetStyleHelper(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
nsIDOMCanvasRenderingContext2D *self;
xpc_qsSelfRef selfref;
JS::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
return JS_FALSE;
nsresult rv = NS_OK;
@ -96,7 +96,7 @@ Canvas2D_GetStyleHelper(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
nsIDOMCanvasRenderingContext2D *self;
xpc_qsSelfRef selfref;
XPCLazyCallContext lccx(JS_CALLER, cx, obj);
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, vp, &lccx))
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, vp, &lccx))
return JS_FALSE;
nsresult rv;
@ -303,7 +303,7 @@ nsIDOMCanvasRenderingContext2D_GetImageData(JSContext *cx, uintN argc, jsval *vp
nsIDOMCanvasRenderingContext2D *self;
xpc_qsSelfRef selfref;
JS::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
return JS_FALSE;
if (argc < 4)
@ -362,7 +362,7 @@ nsIDOMCanvasRenderingContext2D_PutImageData(JSContext *cx, uintN argc, jsval *vp
nsIDOMCanvasRenderingContext2D *self;
xpc_qsSelfRef selfref;
JS::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
return JS_FALSE;
if (argc < 3)

View File

@ -93,7 +93,7 @@ nsIDOMWebGLRenderingContext_BufferData(JSContext *cx, uintN argc, jsval *vp)
nsIDOMWebGLRenderingContext *self;
xpc_qsSelfRef selfref;
JS::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
return JS_FALSE;
if (argc < 3)
@ -166,7 +166,7 @@ nsIDOMWebGLRenderingContext_BufferSubData(JSContext *cx, uintN argc, jsval *vp)
nsIDOMWebGLRenderingContext *self;
xpc_qsSelfRef selfref;
JS::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
return JS_FALSE;
if (argc < 3)
@ -240,7 +240,7 @@ nsIDOMWebGLRenderingContext_ReadPixels(JSContext *cx, uintN argc, jsval *vp)
nsIDOMWebGLRenderingContext *self;
xpc_qsSelfRef selfref;
JS::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
return JS_FALSE;
if (argc < 7)
@ -300,7 +300,7 @@ nsIDOMWebGLRenderingContext_TexImage2D(JSContext *cx, uintN argc, jsval *vp)
nsIDOMWebGLRenderingContext *self;
xpc_qsSelfRef selfref;
JS::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
return JS_FALSE;
if (argc < 6 || argc == 7 || argc == 8)
@ -421,7 +421,7 @@ nsIDOMWebGLRenderingContext_TexSubImage2D(JSContext *cx, uintN argc, jsval *vp)
nsIDOMWebGLRenderingContext *self;
xpc_qsSelfRef selfref;
JS::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
return JS_FALSE;
if (argc < 7 || argc == 8)
@ -532,7 +532,7 @@ helper_nsIDOMWebGLRenderingContext_Uniform_x_iv(JSContext *cx, uintN argc, jsval
nsIDOMWebGLRenderingContext *self;
xpc_qsSelfRef selfref;
JS::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
return JS_FALSE;
if (argc < 2)
@ -606,7 +606,7 @@ helper_nsIDOMWebGLRenderingContext_Uniform_x_fv(JSContext *cx, uintN argc, jsval
nsIDOMWebGLRenderingContext *self;
xpc_qsSelfRef selfref;
JS::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
return JS_FALSE;
if (argc < 2)
@ -678,7 +678,7 @@ helper_nsIDOMWebGLRenderingContext_UniformMatrix_x_fv(JSContext *cx, uintN argc,
nsIDOMWebGLRenderingContext *self;
xpc_qsSelfRef selfref;
JS::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
return JS_FALSE;
if (argc < 3)
@ -751,7 +751,7 @@ helper_nsIDOMWebGLRenderingContext_VertexAttrib_x_fv(JSContext *cx, uintN argc,
nsIDOMWebGLRenderingContext *self;
xpc_qsSelfRef selfref;
JS::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
return JS_FALSE;
if (argc < 2)

View File

@ -778,58 +778,22 @@ getNativeFromWrapper(JSContext *cx,
nsresult
getWrapper(JSContext *cx,
JSObject *obj,
JSObject *callee,
XPCWrappedNative **wrapper,
JSObject **cur,
XPCWrappedNativeTearOff **tearoff)
{
// We can have at most three layers in need of unwrapping here:
// * A (possible) security wrapper
// * A (possible) Xray waiver
// * A (possible) outer window
//
// The underlying call to js::Unwrap recursively unwraps, but stops if it
// hits an outer object. Thus, we need to make at most two unwrapping
// calls: one to handle security wrappers and waivers, and one to handle
// outer objects.
if (js::IsWrapper(obj)) {
obj = XPCWrapper::Unwrap(cx, obj);
if (obj && js::IsWrapper(obj)) {
MOZ_ASSERT(js::Wrapper::wrapperHandler(obj)->isOuterWindow());
obj = XPCWrapper::Unwrap(cx, obj);
}
// The safe unwrap might have failed for SCRIPT_ACCESS_ONLY objects. If it
// didn't fail though, we should be done with wrappers.
if (!obj)
return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
MOZ_ASSERT(!js::IsWrapper(obj));
if (XPCWrapper::IsSecurityWrapper(obj) &&
!(obj = XPCWrapper::Unwrap(cx, obj))) {
return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
}
// Start with sane values.
*wrapper = nsnull;
*cur = nsnull;
*cur = obj;
*tearoff = nsnull;
// Handle tearoffs.
//
// If |obj| is of the tearoff class, that means we're dealing with a JS
// object reflection of a particular interface (ie, |foo.nsIBar|). These
// JS objects are parented to their wrapper, so we snag the tearoff object
// along the way (if desired), and then set |obj| to its parent.
if (js::GetObjectClass(obj) == &XPC_WN_Tearoff_JSClass) {
*tearoff = (XPCWrappedNativeTearOff*) js::GetObjectPrivate(obj);
obj = js::GetObjectParent(obj);
}
// If we've got a WN or slim wrapper, store things the way callers expect.
// Otherwise, leave things null and return.
if (IS_WRAPPER_CLASS(js::GetObjectClass(obj))) {
if (IS_WN_WRAPPER_OBJECT(obj))
*wrapper = (XPCWrappedNative*) js::GetObjectPrivate(obj);
else
*cur = obj;
}
*wrapper =
XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj, callee, cur,
tearoff);
return NS_OK;
}
@ -947,7 +911,7 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
wrapper = nsnull;
obj2 = src;
} else {
rv = getWrapper(cx, src, &wrapper, &obj2, &tearoff);
rv = getWrapper(cx, src, nsnull, &wrapper, &obj2, &tearoff);
NS_ENSURE_SUCCESS(rv, rv);
}

View File

@ -441,6 +441,7 @@ xpc_qsStringToJsstring(JSContext *cx, nsString &str, JSString **rval);
nsresult
getWrapper(JSContext *cx,
JSObject *obj,
JSObject *callee,
XPCWrappedNative **wrapper,
JSObject **cur,
XPCWrappedNativeTearOff **tearoff);
@ -476,6 +477,7 @@ template <class T>
inline JSBool
xpc_qsUnwrapThis(JSContext *cx,
JSObject *obj,
JSObject *callee,
T **ppThis,
nsISupports **pThisRef,
jsval *pThisVal,
@ -484,7 +486,7 @@ xpc_qsUnwrapThis(JSContext *cx,
{
XPCWrappedNative *wrapper;
XPCWrappedNativeTearOff *tearoff;
nsresult rv = getWrapper(cx, obj, &wrapper, &obj, &tearoff);
nsresult rv = getWrapper(cx, obj, callee, &wrapper, &obj, &tearoff);
if (NS_SUCCEEDED(rv))
rv = castNative(cx, wrapper, obj, tearoff, NS_GET_TEMPLATE_IID(T),
reinterpret_cast<void **>(ppThis), pThisRef, pThisVal,
@ -501,6 +503,7 @@ xpc_qsUnwrapThis(JSContext *cx,
inline nsISupports*
castNativeFromWrapper(JSContext *cx,
JSObject *obj,
JSObject *callee,
PRUint32 interfaceBit,
nsISupports **pRef,
jsval *pVal,
@ -511,14 +514,14 @@ castNativeFromWrapper(JSContext *cx,
XPCWrappedNativeTearOff *tearoff;
JSObject *cur;
if (IS_WRAPPER_CLASS(js::GetObjectClass(obj))) {
if (!callee && IS_WRAPPER_CLASS(js::GetObjectClass(obj))) {
cur = obj;
wrapper = IS_WN_WRAPPER_OBJECT(cur) ?
(XPCWrappedNative*)xpc_GetJSPrivate(obj) :
nsnull;
tearoff = nsnull;
} else {
*rv = getWrapper(cx, obj, &wrapper, &cur, &tearoff);
*rv = getWrapper(cx, obj, callee, &wrapper, &cur, &tearoff);
if (NS_FAILED(*rv))
return nsnull;
}
@ -614,7 +617,7 @@ castNativeArgFromWrapper(JSContext *cx,
if (!src)
return nsnull;
return castNativeFromWrapper(cx, src, bit, pArgRef, vp, nsnull, rv);
return castNativeFromWrapper(cx, src, nsnull, bit, pArgRef, vp, nsnull, rv);
}
inline nsWrapperCache*

View File

@ -44,6 +44,7 @@ template <> \
inline JSBool \
xpc_qsUnwrapThis<_interface>(JSContext *cx, \
JSObject *obj, \
JSObject *callee, \
_interface **ppThis, \
nsISupports **pThisRef, \
jsval *pThisVal, \
@ -51,7 +52,7 @@ xpc_qsUnwrapThis<_interface>(JSContext *cx, \
bool failureFatal) \
{ \
nsresult rv; \
nsISupports *native = castNativeFromWrapper(cx, obj, _bit, \
nsISupports *native = castNativeFromWrapper(cx, obj, callee, _bit, \
pThisRef, pThisVal, lccx, \
&rv); \
*ppThis = NULL; /* avoids uninitialized warnings in callers */ \
@ -107,6 +108,7 @@ template <>
inline JSBool
xpc_qsUnwrapThis<nsGenericElement>(JSContext *cx,
JSObject *obj,
JSObject *callee,
nsGenericElement **ppThis,
nsISupports **pThisRef,
jsval *pThisVal,
@ -115,7 +117,7 @@ xpc_qsUnwrapThis<nsGenericElement>(JSContext *cx,
{
nsIContent *content;
jsval val;
JSBool ok = xpc_qsUnwrapThis<nsIContent>(cx, obj, &content,
JSBool ok = xpc_qsUnwrapThis<nsIContent>(cx, obj, callee, &content,
pThisRef, &val, lccx,
failureFatal);
if (ok) {

View File

@ -863,6 +863,12 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False):
"JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));\n")
if isInterfaceType(member.realtype):
f.write(" XPCLazyCallContext lccx(ccx);\n")
elif isInterfaceType(member.realtype):
if isMethod:
f.write(" JSObject *callee = "
"JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));\n")
elif isGetter:
f.write(" JSObject *callee = nsnull;\n")
# Get the 'self' pointer.
if customMethodCall is None or not 'thisType' in customMethodCall:
@ -894,10 +900,10 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False):
if not isSetter and isInterfaceType(member.realtype):
f.write(" XPCLazyCallContext lccx(JS_CALLER, cx, obj);\n")
f.write(" if (!xpc_qsUnwrapThis(cx, obj, &self, "
f.write(" if (!xpc_qsUnwrapThis(cx, obj, callee, &self, "
"&selfref.ptr, %s, &lccx, %s))\n" % (pthisval, unwrapFatalArg))
else:
f.write(" if (!xpc_qsUnwrapThis(cx, obj, &self, "
f.write(" if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, "
"&selfref.ptr, %s, nsnull, %s))\n" % (pthisval, unwrapFatalArg))
f.write(" return JS_FALSE;\n")