hotspot/src/share/vm/oops/annotations.cpp
changeset 15437 eabd4555d072
parent 15097 9db149412e0e
child 15601 df8faef6efaf
--- a/hotspot/src/share/vm/oops/annotations.cpp	Thu Jan 24 23:30:45 2013 -0800
+++ b/hotspot/src/share/vm/oops/annotations.cpp	Fri Jan 25 15:06:18 2013 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "classfile/classLoaderData.hpp"
+#include "memory/heapInspection.hpp"
 #include "memory/metadataFactory.hpp"
 #include "memory/oopFactory.hpp"
 #include "oops/annotations.hpp"
@@ -114,6 +115,50 @@
   st->print("Anotations(" INTPTR_FORMAT ")", this);
 }
 
+#if INCLUDE_SERVICES
+// Size Statistics
+
+julong Annotations::count_bytes(Array<AnnotationArray*>* p) {
+  julong bytes = 0;
+  if (p != NULL) {
+    for (int i = 0; i < p->length(); i++) {
+      bytes += KlassSizeStats::count_array(p->at(i));
+    }
+    bytes += KlassSizeStats::count_array(p);
+  }
+  return bytes;
+}
+
+void Annotations::collect_statistics(KlassSizeStats *sz) const {
+  sz->_annotations_bytes = sz->count(this);
+  sz->_class_annotations_bytes = sz->count(class_annotations());
+  sz->_fields_annotations_bytes = count_bytes(fields_annotations());
+  sz->_methods_annotations_bytes = count_bytes(methods_annotations());
+  sz->_methods_parameter_annotations_bytes =
+                          count_bytes(methods_parameter_annotations());
+  sz->_methods_default_annotations_bytes =
+                          count_bytes(methods_default_annotations());
+
+  const Annotations* type_anno = type_annotations();
+  if (type_anno != NULL) {
+    sz->_type_annotations_bytes = sz->count(type_anno);
+    sz->_type_annotations_bytes += sz->count(type_anno->class_annotations());
+    sz->_type_annotations_bytes += count_bytes(type_anno->fields_annotations());
+    sz->_type_annotations_bytes += count_bytes(type_anno->methods_annotations());
+  }
+
+  sz->_annotations_bytes +=
+      sz->_class_annotations_bytes +
+      sz->_fields_annotations_bytes +
+      sz->_methods_annotations_bytes +
+      sz->_methods_parameter_annotations_bytes +
+      sz->_methods_default_annotations_bytes +
+      sz->_type_annotations_bytes;
+
+  sz->_ro_bytes += sz->_annotations_bytes;
+}
+#endif // INCLUDE_SERVICES
+
 #define BULLET  " - "
 
 #ifndef PRODUCT