src/share/vm/oops/annotations.cpp

changeset 4497
16fb9f942703
parent 4393
35431a769282
child 4572
927a311d00f9
     1.1 --- a/src/share/vm/oops/annotations.cpp	Thu Jan 24 23:30:45 2013 -0800
     1.2 +++ b/src/share/vm/oops/annotations.cpp	Fri Jan 25 15:06:18 2013 -0500
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -24,6 +24,7 @@
    1.11  
    1.12  #include "precompiled.hpp"
    1.13  #include "classfile/classLoaderData.hpp"
    1.14 +#include "memory/heapInspection.hpp"
    1.15  #include "memory/metadataFactory.hpp"
    1.16  #include "memory/oopFactory.hpp"
    1.17  #include "oops/annotations.hpp"
    1.18 @@ -114,6 +115,50 @@
    1.19    st->print("Anotations(" INTPTR_FORMAT ")", this);
    1.20  }
    1.21  
    1.22 +#if INCLUDE_SERVICES
    1.23 +// Size Statistics
    1.24 +
    1.25 +julong Annotations::count_bytes(Array<AnnotationArray*>* p) {
    1.26 +  julong bytes = 0;
    1.27 +  if (p != NULL) {
    1.28 +    for (int i = 0; i < p->length(); i++) {
    1.29 +      bytes += KlassSizeStats::count_array(p->at(i));
    1.30 +    }
    1.31 +    bytes += KlassSizeStats::count_array(p);
    1.32 +  }
    1.33 +  return bytes;
    1.34 +}
    1.35 +
    1.36 +void Annotations::collect_statistics(KlassSizeStats *sz) const {
    1.37 +  sz->_annotations_bytes = sz->count(this);
    1.38 +  sz->_class_annotations_bytes = sz->count(class_annotations());
    1.39 +  sz->_fields_annotations_bytes = count_bytes(fields_annotations());
    1.40 +  sz->_methods_annotations_bytes = count_bytes(methods_annotations());
    1.41 +  sz->_methods_parameter_annotations_bytes =
    1.42 +                          count_bytes(methods_parameter_annotations());
    1.43 +  sz->_methods_default_annotations_bytes =
    1.44 +                          count_bytes(methods_default_annotations());
    1.45 +
    1.46 +  const Annotations* type_anno = type_annotations();
    1.47 +  if (type_anno != NULL) {
    1.48 +    sz->_type_annotations_bytes = sz->count(type_anno);
    1.49 +    sz->_type_annotations_bytes += sz->count(type_anno->class_annotations());
    1.50 +    sz->_type_annotations_bytes += count_bytes(type_anno->fields_annotations());
    1.51 +    sz->_type_annotations_bytes += count_bytes(type_anno->methods_annotations());
    1.52 +  }
    1.53 +
    1.54 +  sz->_annotations_bytes +=
    1.55 +      sz->_class_annotations_bytes +
    1.56 +      sz->_fields_annotations_bytes +
    1.57 +      sz->_methods_annotations_bytes +
    1.58 +      sz->_methods_parameter_annotations_bytes +
    1.59 +      sz->_methods_default_annotations_bytes +
    1.60 +      sz->_type_annotations_bytes;
    1.61 +
    1.62 +  sz->_ro_bytes += sz->_annotations_bytes;
    1.63 +}
    1.64 +#endif // INCLUDE_SERVICES
    1.65 +
    1.66  #define BULLET  " - "
    1.67  
    1.68  #ifndef PRODUCT

mercurial