From f8a8e56c45541c788f9dbf6a84c1d691d1090e44 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Fri, 23 Sep 2011 14:50:28 -0700 Subject: [PATCH] Bug 683802 - Use an explicit indicator for direct vs indirect calling semantics. r=mrbkap --- js/src/xpconnect/src/xpcwrappedjsclass.cpp | 7 +++---- js/src/xpconnect/src/xpcwrappednative.cpp | 15 ++++++++------- xpcom/reflect/xptinfo/public/xptinfo.h | 6 ++++++ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/js/src/xpconnect/src/xpcwrappedjsclass.cpp b/js/src/xpconnect/src/xpcwrappedjsclass.cpp index 9d4a018263c7..ea442721cf94 100644 --- a/js/src/xpconnect/src/xpcwrappedjsclass.cpp +++ b/js/src/xpconnect/src/xpcwrappedjsclass.cpp @@ -932,7 +932,7 @@ nsXPCWrappedJSClass::GetArraySizeFromParam(JSContext* cx, if(arg_type.IsPointer() || arg_type.TagPart() != nsXPTType::T_U32) return JS_FALSE; - if(arg_param.IsOut()) + if(arg_param.IsIndirect()) *result = *(JSUint32*)nativeParams[argnum].val.p; else *result = nativeParams[argnum].val.u32; @@ -973,7 +973,7 @@ nsXPCWrappedJSClass::GetInterfaceTypeFromParam(JSContext* cx, if(arg_type.IsPointer() && arg_type.TagPart() == nsXPTType::T_IID) { - if(arg_param.IsOut()) + if(arg_param.IsIndirect()) { nsID** p = (nsID**) nativeParams[argnum].val.p; if(!p || !*p) @@ -1509,8 +1509,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex, { nsXPTCMiniVariant* pv; - // Temporary hack - we'll abstract this away soon. - if(param.IsOut() || type.TagPart() == nsXPTType::T_JSVAL) + if(param.IsIndirect()) pv = (nsXPTCMiniVariant*) nativeParams[i].val.p; else pv = &nativeParams[i]; diff --git a/js/src/xpconnect/src/xpcwrappednative.cpp b/js/src/xpconnect/src/xpcwrappednative.cpp index a7e89b4e61ce..6d99a5d6cff3 100644 --- a/js/src/xpconnect/src/xpcwrappednative.cpp +++ b/js/src/xpconnect/src/xpcwrappednative.cpp @@ -2830,6 +2830,10 @@ CallMethodHelper::ConvertIndependentParam(uint8 i) if(paramInfo.IsDipper()) return HandleDipperParam(dp, paramInfo); + // Specify the correct storage/calling semantics. + if(paramInfo.IsIndirect()) + dp->SetIndirect(); + if(type_tag == nsXPTType::T_INTERFACE) { dp->SetValIsInterface(); @@ -2844,9 +2848,6 @@ CallMethodHelper::ConvertIndependentParam(uint8 i) // indirectly, regardless of in/out-ness. if(type_tag == nsXPTType::T_JSVAL) { - // Indicate the storage semantics. - dp->SetIndirect(); - // Assign the value JS_STATIC_ASSERT(sizeof(jsval) <= sizeof(dp->val)); jsval *rootp = (jsval *)&dp->val; @@ -2859,8 +2860,6 @@ CallMethodHelper::ConvertIndependentParam(uint8 i) if(paramInfo.IsOut()) { - dp->SetIndirect(); - if(type.IsPointer() && type_tag != nsXPTType::T_INTERFACE && !paramInfo.IsShared()) @@ -2966,6 +2965,10 @@ CallMethodHelper::ConvertDependentParams() nsXPTCVariant* dp = GetDispatchParam(i); dp->type = type; + // Specify the correct storage/calling semantics. + if(paramInfo.IsIndirect()) + dp->SetIndirect(); + if(isArray) { dp->SetValIsArray(); @@ -2992,8 +2995,6 @@ CallMethodHelper::ConvertDependentParams() if(paramInfo.IsOut()) { - dp->SetIndirect(); - if(datum_type.IsPointer() && !datum_type.IsInterfacePointer() && (isArray || !paramInfo.IsShared())) diff --git a/xpcom/reflect/xptinfo/public/xptinfo.h b/xpcom/reflect/xptinfo/public/xptinfo.h index af49a88c19cd..bc0983fdb321 100644 --- a/xpcom/reflect/xptinfo/public/xptinfo.h +++ b/xpcom/reflect/xptinfo/public/xptinfo.h @@ -160,6 +160,12 @@ public: PRBool IsOptional() const {return 0 != (XPT_PD_IS_OPTIONAL(flags));} const nsXPTType GetType() const {return type.prefix;} + // Whether this parameter is passed indirectly on the stack. This mainly + // applies to out/inout params, but we use it unconditionally for certain + // types. + PRBool IsIndirect() const {return IsOut() || + GetType().TagPart() == nsXPTType::T_JSVAL;} + // NOTE: other activities on types are done via methods on nsIInterfaceInfo private: