Bug 692342 - Get rid of the large and unnecessary table-driven reflectability detector. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Fri, 25 Nov 2011 17:09:07 -0800
changeset 82438 911074d770a243111ba38651c19cc2a182715400
parent 82437 89e610a1014c7bd13b00a4ba73ccc07e83f262ca
child 82439 0408a35a67f9537ae901b787928fc877d184e8b8
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs692342
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 692342 - Get rid of the large and unnecessary table-driven reflectability detector. r=mrbkap The XPIDL machinery should never output an invalid configuration here, so all this checking is unnecessary. The only thing we have to watch out for is native types, which all get shoehorned into T_VOID. So let's make this a simple check.
js/xpconnect/src/XPCConvert.cpp
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -63,99 +63,35 @@ using namespace mozilla;
 //#define STRICT_CHECK_OF_UNICODE
 #ifdef STRICT_CHECK_OF_UNICODE
 #define ILLEGAL_RANGE(c) (0!=((c) & 0xFF80))
 #else // STRICT_CHECK_OF_UNICODE
 #define ILLEGAL_RANGE(c) (0!=((c) & 0xFF00))
 #endif // STRICT_CHECK_OF_UNICODE
 
 #define ILLEGAL_CHAR_RANGE(c) (0!=((c) & 0x80))
-/*
-* This is a table driven scheme to determine if the types of the params of the
-* given method exclude that method from being reflected via XPConnect.
-*
-* The table can be appended and modified as requirements change. However...
-*
-* The table ASSUMES that all the type idenetifiers are contiguous starting
-* at ZERO. And, it also ASSUMES that the additional criteria of whether or
-* not a give type is reflectable are its use as a pointer and/or 'out' type.
-*
-* The table has a row for each type and columns for the combinations of
-* that type being used as a pointer type and/or as an 'out' param.
-*/
-
-#define XPC_MK_BIT(p,o) (1 << (((p)?1:0)+((o)?2:0)))
-#define XPC_IS_REFLECTABLE(f, p, o) ((f) & XPC_MK_BIT((p),(o)))
-#define XPC_MK_FLAG(np_no,p_no,np_o,p_o) \
-        ((uint8)((np_no) | ((p_no) << 1) | ((np_o) << 2) | ((p_o) << 3)))
-
-/***********************************************************/
-// xpt uses 5 bits for this info. We deal with the possibility that
-// some new types might exist that we don't know about.
-
-#define XPC_FLAG_COUNT (1 << 5)
-
-/* '1' means 'reflectable'. '0' means 'not reflectable'.        */
-static uint8 xpc_reflectable_flags[XPC_FLAG_COUNT] = {
-    /* 'p' stands for 'pointer' and 'o' stands for 'out'        */
-    /*          !p&!o, p&!o, !p&o, p&o                          */
-    XPC_MK_FLAG(  1  ,  1  ,   1 ,  0 ), /* T_I8                */
-    XPC_MK_FLAG(  1  ,  1  ,   1 ,  0 ), /* T_I16               */
-    XPC_MK_FLAG(  1  ,  1  ,   1 ,  0 ), /* T_I32               */
-    XPC_MK_FLAG(  1  ,  1  ,   1 ,  0 ), /* T_I64               */
-    XPC_MK_FLAG(  1  ,  1  ,   1 ,  0 ), /* T_U8                */
-    XPC_MK_FLAG(  1  ,  1  ,   1 ,  0 ), /* T_U16               */
-    XPC_MK_FLAG(  1  ,  1  ,   1 ,  0 ), /* T_U32               */
-    XPC_MK_FLAG(  1  ,  1  ,   1 ,  0 ), /* T_U64               */
-    XPC_MK_FLAG(  1  ,  1  ,   1 ,  0 ), /* T_FLOAT             */
-    XPC_MK_FLAG(  1  ,  1  ,   1 ,  0 ), /* T_DOUBLE            */
-    XPC_MK_FLAG(  1  ,  1  ,   1 ,  0 ), /* T_BOOL              */
-    XPC_MK_FLAG(  1  ,  1  ,   1 ,  0 ), /* T_CHAR              */
-    XPC_MK_FLAG(  1  ,  1  ,   1 ,  0 ), /* T_WCHAR             */
-    XPC_MK_FLAG(  0  ,  0  ,   0 ,  0 ), /* T_VOID              */
-    XPC_MK_FLAG(  0  ,  1  ,   0 ,  1 ), /* T_IID               */
-    XPC_MK_FLAG(  0  ,  1  ,   0 ,  0 ), /* T_DOMSTRING         */
-    XPC_MK_FLAG(  0  ,  1  ,   0 ,  1 ), /* T_CHAR_STR          */
-    XPC_MK_FLAG(  0  ,  1  ,   0 ,  1 ), /* T_WCHAR_STR         */
-    XPC_MK_FLAG(  0  ,  1  ,   0 ,  1 ), /* T_INTERFACE         */
-    XPC_MK_FLAG(  0  ,  1  ,   0 ,  1 ), /* T_INTERFACE_IS      */
-    XPC_MK_FLAG(  0  ,  1  ,   0 ,  1 ), /* T_ARRAY             */
-    XPC_MK_FLAG(  0  ,  1  ,   0 ,  1 ), /* T_PSTRING_SIZE_IS   */
-    XPC_MK_FLAG(  0  ,  1  ,   0 ,  1 ), /* T_PWSTRING_SIZE_IS  */
-    XPC_MK_FLAG(  0  ,  1  ,   0 ,  0 ), /* T_UTF8STRING        */
-    XPC_MK_FLAG(  0  ,  1  ,   0 ,  0 ), /* T_CSTRING           */
-    XPC_MK_FLAG(  0  ,  1  ,   0 ,  0 ), /* T_ASTRING           */
-    XPC_MK_FLAG(  1  ,  0  ,   1 ,  0 ), /* T_JSVAL             */
-    XPC_MK_FLAG(  0  ,  0  ,   0 ,  0 ), /* 27 - reserved       */
-    XPC_MK_FLAG(  0  ,  0  ,   0 ,  0 ), /* 28 - reserved       */
-    XPC_MK_FLAG(  0  ,  0  ,   0 ,  0 ), /* 29 - reserved       */
-    XPC_MK_FLAG(  0  ,  0  ,   0 ,  0 ), /* 30 - reserved       */
-    XPC_MK_FLAG(  0  ,  0  ,   0 ,  0 )  /* 31 - reserved       */
-    };
 
 static intN sXPCOMUCStringFinalizerIndex = -1;
 
 /***********************************************************/
 
 // static
 JSBool
 XPCConvert::IsMethodReflectable(const XPTMethodDescriptor& info)
 {
     if (XPT_MD_IS_NOTXPCOM(info.flags) || XPT_MD_IS_HIDDEN(info.flags))
         return JS_FALSE;
 
     for (int i = info.num_args-1; i >= 0; i--) {
         const nsXPTParamInfo& param = info.params[i];
         const nsXPTType& type = param.GetType();
 
-        uint8 base_type = type.TagPart();
-        NS_ASSERTION(base_type < XPC_FLAG_COUNT, "BAD TYPE");
-
-        if (!XPC_IS_REFLECTABLE(xpc_reflectable_flags[base_type],
-                                type.IsPointer(), param.IsOut()))
+        // Reflected methods can't use native types. All native types end up
+        // getting tagged as void*, so this check is easy.
+        if (type.TagPart() == nsXPTType::T_VOID)
             return JS_FALSE;
     }
     return JS_TRUE;
 }
 
 /***************************************************************************/
 
 // static