Rebase static-check-finalizers against slightly newer gc-annotation-checking patch.... perhaps it would be wiser to just merge these together?
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 02 May 2008 23:21:36 -0400
changeset 121 bed93b2f797b693ee39558d7bfe3410b1deaaa98
parent 120 8efda5af99c6144e195fdab2ad22e5ef9426523c
child 122 eb192196cd992859118c6da63ca40e6906da489c
push id11
push userbsmedberg@mozilla.com
push dateMon, 05 May 2008 14:53:12 +0000
Rebase static-check-finalizers against slightly newer gc-annotation-checking patch.... perhaps it would be wiser to just merge these together?
static-check-finalizers
--- a/static-check-finalizers
+++ b/static-check-finalizers
@@ -1,8 +1,10 @@
+Treehydra rocks. Dehydra is so-so. Switch the rest of this to use treehydra!
+
 diff --git a/config/config.mk b/config/config.mk
 --- a/config/config.mk
 +++ b/config/config.mk
 @@ -524,9 +524,10 @@ endif
  # script. Additional scripts may be added by specific subdirectories.
  
  DEHYDRA_SCRIPTS = $(topsrcdir)/xpcom/static-checking.js
 +DEHYDRA_ARGS = --topsrcdir=$(topsrcdir) --objdir=$(DEPTH)
@@ -11,27 +13,29 @@ diff --git a/config/config.mk b/config/c
 -DEHYDRA_FLAGS = -fplugin=$(DEHYDRA_PATH) $(foreach script,$(DEHYDRA_SCRIPTS),-fplugin-arg=$(script))
 +DEHYDRA_FLAGS = -fplugin=$(DEHYDRA_PATH) $(foreach script,$(DEHYDRA_SCRIPTS),-fplugin-arg="$(script) $(DEHYDRA_ARGS)")
  OS_CXXFLAGS += $(DEHYDRA_FLAGS)
  endif
  
 diff --git a/xpcom/base/nscore.h b/xpcom/base/nscore.h
 --- a/xpcom/base/nscore.h
 +++ b/xpcom/base/nscore.h
-@@ -502,11 +502,15 @@ typedef PRUint32 nsrefcnt;
- #define NS_FINAL_CLASS __attribute__((user("NS_final")))
- #define NS_GC_TYPE     __attribute__((user("NS_GC")))
+@@ -514,6 +514,8 @@ typedef PRUint32 nsrefcnt;
  #define NS_NOGC_TYPE   __attribute__((user("NS_NoGC")))
+ #define NS_MAYBEGC     __attribute__((user("NS_MaybeGC")))
+ #define NS_MAYBEGCFINALIZED __attribute__((user("NS_MaybeGCFinalized")))
 +#define NS_FINALIZER   __attribute__((user("NS_Finalizer")))
 +#define NS_NO_FINALIZER __attribute__((user("NS_No_Finalizer")))
  #else
  #define NS_STACK_CLASS
  #define NS_FINAL_CLASS
- #define NS_GC_TYPE
+@@ -521,6 +523,8 @@ typedef PRUint32 nsrefcnt;
  #define NS_NOGC_TYPE
+ #define NS_MAYBEGC
+ #define NS_MAYBEGCFINALIZED
 +#define NS_FINALIZER
 +#define NS_NO_FINALIZER
  #endif
  
  #endif /* nscore_h___ */
 diff --git a/xpcom/build/nsXPCOM.h b/xpcom/build/nsXPCOM.h
 --- a/xpcom/build/nsXPCOM.h
 +++ b/xpcom/build/nsXPCOM.h
@@ -724,101 +728,26 @@ diff --git a/xpcom/static-checking.js b/
 +
 +String.prototype.beginsWith = function(other)
 +{
 +  return this.substr(0, other.length) == other;
 +}
  
  /**
   * gClassMap maps class names to an object with the following properties:
-@@ -15,7 +25,7 @@
-  * .gcfinalizable = true
-  *                 if the left-most base of this object is MMgc::GCFinalizable
-  *                 exluding XPCOMGCFinalizedObject
-- * .finalized = true
-+ * .xpcomgcfinalizedobject = true
-  *                 if the object derives from XPCOMGCFinalizedObject
-  */
- var gClassMap = {};
-@@ -27,7 +37,7 @@ function ClassType(name)
- 
- ClassType.prototype = {
-   isFinal: false,
--  stack: false,
-+  stack: false
- };
- 
- function process_type(c)
-@@ -159,8 +169,11 @@ function get_class(c, allowIncomplete)
+@@ -173,6 +183,8 @@ function get_class(c, allowIncomplete)
    // check for .gc
  
    if (hasAttribute('NS_GC') ||
 +      c.name == "MMgc::GCObject" ||
-+      c.name == "MMgc::GCFinalizedObject" ||
++      c.name == "MMgc::GCFinalizable" ||
        c.name == "XPCOMGCObject" ||
--      c.name == "XPCOMGCFinalizedObject") {
-+      c.name == "XPCOMGCFinalizedObject" ||
-+      c.name == "MMgc::GCFinalizable") {
+       c.name == "XPCOMGCFinalizedObject") {
      classattr.gc = true;
-   }
-   else if (c.name == "nsIFrame") {
-@@ -169,6 +182,52 @@ function get_class(c, allowIncomplete)
-   else {
-     for each (base in bases) {
-       if (base.gc) {
-+        classattr.gc = true;
-+        break;
-+      }
-+    }
-+  }
-+
-+  if (!classattr.gc) {
-+    // Check members
-+    for each (member in c.members) {
-+      if (member.isFunction)
-+        continue;
-+
-+      type = member.type;
-+
-+      /* recurse through arrays and typedefs */
-+      while (true) {
-+          if (type === undefined) {
-+              break;
-+          }
-+              
-+          if (type.isArray) {
-+              type = type.type;
-+              continue;
-+          }
-+          if (type.typedef) {
-+              type = type.typedef;
-+              continue;
-+          }
-+          break;
-+      }
-+
-+      if (type === undefined) {
-+          warning("incomplete type  for member " + member + ".");
-+          continue;
-+      }
-+
-+      if (type.isPointer || type.isReference) {
-+          continue;
-+      }
-+
-+      if (!type.kind || (type.kind != 'class' && type.kind != 'struct')) {
-+          continue;
-+      }
-+
-+      var membertype = get_class(type, false);
-+      if (membertype.gc) {
-         classattr.gc = true;
-         break;
-       }
-@@ -292,3 +351,145 @@ function process_function(f, stmts)
+@@ -402,3 +414,145 @@ function process_function(f, stmts)
      iter(processVar, stmt.statements);
    }
  }
 +
 +/** FINALIZER SAFETY **/
 +
 +/* This should really end up in treehydra.js... it's a better replacement for
 + * get_user_attribute
@@ -954,17 +883,16 @@ diff --git a/xpcom/static-checking.js b/
 +    {
 +      fun = TREE_CHAIN (fun);
 +      index -= (TARGET_VTABLE_USES_DESCRIPTORS
 +                ? TARGET_VTABLE_USES_DESCRIPTORS : 1);
 +    }
 +
 +  return BV_FN (fun);
 +}
-\ No newline at end of file
 diff --git a/xpcom/string/public/nsXPCOMStrings.h b/xpcom/string/public/nsXPCOMStrings.h
 --- a/xpcom/string/public/nsXPCOMStrings.h
 +++ b/xpcom/string/public/nsXPCOMStrings.h
 @@ -192,7 +192,7 @@ enum {
   * @status FROZEN
   */
  XPCOM_API(nsresult)
 -NS_StringContainerInit(nsStringContainer &aContainer);