src/share/vm/oops/instanceKlass.cpp

changeset 4497
16fb9f942703
parent 4453
ed6154d7d259
child 4544
3c9bc17b9403
     1.1 --- a/src/share/vm/oops/instanceKlass.cpp	Thu Jan 24 23:30:45 2013 -0800
     1.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Fri Jan 25 15:06:18 2013 -0500
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 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 @@ -34,6 +34,7 @@
    1.11  #include "interpreter/rewriter.hpp"
    1.12  #include "jvmtifiles/jvmti.h"
    1.13  #include "memory/genOopClosures.inline.hpp"
    1.14 +#include "memory/heapInspection.hpp"
    1.15  #include "memory/metadataFactory.hpp"
    1.16  #include "memory/oopFactory.hpp"
    1.17  #include "oops/fieldStreams.hpp"
    1.18 @@ -2960,6 +2961,52 @@
    1.19    return external_name();
    1.20  }
    1.21  
    1.22 +#if INCLUDE_SERVICES
    1.23 +// Size Statistics
    1.24 +void InstanceKlass::collect_statistics(KlassSizeStats *sz) const {
    1.25 +  Klass::collect_statistics(sz);
    1.26 +
    1.27 +  sz->_inst_size  = HeapWordSize * size_helper();
    1.28 +  sz->_vtab_bytes = HeapWordSize * align_object_offset(vtable_length());
    1.29 +  sz->_itab_bytes = HeapWordSize * align_object_offset(itable_length());
    1.30 +  sz->_nonstatic_oopmap_bytes = HeapWordSize *
    1.31 +        ((is_interface() || is_anonymous()) ?
    1.32 +         align_object_offset(nonstatic_oop_map_size()) :
    1.33 +         nonstatic_oop_map_size());
    1.34 +
    1.35 +  int n = 0;
    1.36 +  n += (sz->_methods_array_bytes         = sz->count_array(methods()));
    1.37 +  n += (sz->_method_ordering_bytes       = sz->count_array(method_ordering()));
    1.38 +  n += (sz->_local_interfaces_bytes      = sz->count_array(local_interfaces()));
    1.39 +  n += (sz->_transitive_interfaces_bytes = sz->count_array(transitive_interfaces()));
    1.40 +  n += (sz->_signers_bytes               = sz->count_array(signers()));
    1.41 +  n += (sz->_fields_bytes                = sz->count_array(fields()));
    1.42 +  n += (sz->_inner_classes_bytes         = sz->count_array(inner_classes()));
    1.43 +  sz->_ro_bytes += n;
    1.44 +
    1.45 +  const ConstantPool* cp = constants();
    1.46 +  if (cp) {
    1.47 +    cp->collect_statistics(sz);
    1.48 +  }
    1.49 +
    1.50 +  const Annotations* anno = annotations();
    1.51 +  if (anno) {
    1.52 +    anno->collect_statistics(sz);
    1.53 +  }
    1.54 +
    1.55 +  const Array<Method*>* methods_array = methods();
    1.56 +  if (methods()) {
    1.57 +    for (int i = 0; i < methods_array->length(); i++) {
    1.58 +      Method* method = methods_array->at(i);
    1.59 +      if (method) {
    1.60 +        sz->_method_count ++;
    1.61 +        method->collect_statistics(sz);
    1.62 +      }
    1.63 +    }
    1.64 +  }
    1.65 +}
    1.66 +#endif // INCLUDE_SERVICES
    1.67 +
    1.68  // Verification
    1.69  
    1.70  class VerifyFieldClosure: public OopClosure {

mercurial