Mercurial > hg > graal-compiler
comparison src/share/vm/oops/instanceKlass.cpp @ 6197:d2a62e0f25eb
6995781: Native Memory Tracking (Phase 1)
7151532: DCmd for hotspot native memory tracking
Summary: Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd
Reviewed-by: acorn, coleenp, fparain
author | zgu |
---|---|
date | Thu, 28 Jun 2012 17:03:16 -0400 |
parents | 8bafad97cd26 |
children | 04ade88d9712 |
comparison
equal
deleted
inserted
replaced
6174:74533f63b116 | 6197:d2a62e0f25eb |
---|---|
987 super->do_nonstatic_fields(cl); | 987 super->do_nonstatic_fields(cl); |
988 } | 988 } |
989 fieldDescriptor fd; | 989 fieldDescriptor fd; |
990 int length = java_fields_count(); | 990 int length = java_fields_count(); |
991 // In DebugInfo nonstatic fields are sorted by offset. | 991 // In DebugInfo nonstatic fields are sorted by offset. |
992 int* fields_sorted = NEW_C_HEAP_ARRAY(int, 2*(length+1)); | 992 int* fields_sorted = NEW_C_HEAP_ARRAY(int, 2*(length+1), mtClass); |
993 int j = 0; | 993 int j = 0; |
994 for (int i = 0; i < length; i += 1) { | 994 for (int i = 0; i < length; i += 1) { |
995 fd.initialize(as_klassOop(), i); | 995 fd.initialize(as_klassOop(), i); |
996 if (!fd.is_static()) { | 996 if (!fd.is_static()) { |
997 fields_sorted[j + 0] = fd.offset(); | 997 fields_sorted[j + 0] = fd.offset(); |
1007 fd.initialize(as_klassOop(), fields_sorted[i + 1]); | 1007 fd.initialize(as_klassOop(), fields_sorted[i + 1]); |
1008 assert(!fd.is_static() && fd.offset() == fields_sorted[i], "only nonstatic fields"); | 1008 assert(!fd.is_static() && fd.offset() == fields_sorted[i], "only nonstatic fields"); |
1009 cl->do_field(&fd); | 1009 cl->do_field(&fd); |
1010 } | 1010 } |
1011 } | 1011 } |
1012 FREE_C_HEAP_ARRAY(int, fields_sorted); | 1012 FREE_C_HEAP_ARRAY(int, fields_sorted, mtClass); |
1013 } | 1013 } |
1014 | 1014 |
1015 | 1015 |
1016 void instanceKlass::array_klasses_do(void f(klassOop k)) { | 1016 void instanceKlass::array_klasses_do(void f(klassOop k)) { |
1017 if (array_klasses() != NULL) | 1017 if (array_klasses() != NULL) |
1234 // may not allocate new_jmeths or use it if we allocate it | 1234 // may not allocate new_jmeths or use it if we allocate it |
1235 jmethodID* new_jmeths = NULL; | 1235 jmethodID* new_jmeths = NULL; |
1236 if (length <= idnum) { | 1236 if (length <= idnum) { |
1237 // allocate a new cache that might be used | 1237 // allocate a new cache that might be used |
1238 size_t size = MAX2(idnum+1, (size_t)ik_h->idnum_allocated_count()); | 1238 size_t size = MAX2(idnum+1, (size_t)ik_h->idnum_allocated_count()); |
1239 new_jmeths = NEW_C_HEAP_ARRAY(jmethodID, size+1); | 1239 new_jmeths = NEW_C_HEAP_ARRAY(jmethodID, size+1, mtClass); |
1240 memset(new_jmeths, 0, (size+1)*sizeof(jmethodID)); | 1240 memset(new_jmeths, 0, (size+1)*sizeof(jmethodID)); |
1241 // cache size is stored in element[0], other elements offset by one | 1241 // cache size is stored in element[0], other elements offset by one |
1242 new_jmeths[0] = (jmethodID)size; | 1242 new_jmeths[0] = (jmethodID)size; |
1243 } | 1243 } |
1244 | 1244 |
1395 indices = methods_cached_itable_indices_acquire(); | 1395 indices = methods_cached_itable_indices_acquire(); |
1396 size_t length = 0; | 1396 size_t length = 0; |
1397 // cache size is stored in element[0], other elements offset by one | 1397 // cache size is stored in element[0], other elements offset by one |
1398 if (indices == NULL || (length = (size_t)indices[0]) <= idnum) { | 1398 if (indices == NULL || (length = (size_t)indices[0]) <= idnum) { |
1399 size_t size = MAX2(idnum+1, (size_t)idnum_allocated_count()); | 1399 size_t size = MAX2(idnum+1, (size_t)idnum_allocated_count()); |
1400 int* new_indices = NEW_C_HEAP_ARRAY(int, size+1); | 1400 int* new_indices = NEW_C_HEAP_ARRAY(int, size+1, mtClass); |
1401 new_indices[0] = (int)size; | 1401 new_indices[0] = (int)size; |
1402 // copy any existing entries | 1402 // copy any existing entries |
1403 size_t i; | 1403 size_t i; |
1404 for (i = 0; i < length; i++) { | 1404 for (i = 0; i < length; i++) { |
1405 new_indices[i+1] = indices[i+1]; | 1405 new_indices[i+1] = indices[i+1]; |
1931 _previous_versions = NULL; | 1931 _previous_versions = NULL; |
1932 } | 1932 } |
1933 | 1933 |
1934 // deallocate the cached class file | 1934 // deallocate the cached class file |
1935 if (_cached_class_file_bytes != NULL) { | 1935 if (_cached_class_file_bytes != NULL) { |
1936 os::free(_cached_class_file_bytes); | 1936 os::free(_cached_class_file_bytes, mtClass); |
1937 _cached_class_file_bytes = NULL; | 1937 _cached_class_file_bytes = NULL; |
1938 _cached_class_file_len = 0; | 1938 _cached_class_file_len = 0; |
1939 } | 1939 } |
1940 | 1940 |
1941 // Decrement symbol reference counts associated with the unloaded class. | 1941 // Decrement symbol reference counts associated with the unloaded class. |
2528 | 2528 |
2529 if (_previous_versions == NULL) { | 2529 if (_previous_versions == NULL) { |
2530 // This is the first previous version so make some space. | 2530 // This is the first previous version so make some space. |
2531 // Start with 2 elements under the assumption that the class | 2531 // Start with 2 elements under the assumption that the class |
2532 // won't be redefined much. | 2532 // won't be redefined much. |
2533 _previous_versions = new (ResourceObj::C_HEAP) | 2533 _previous_versions = new (ResourceObj::C_HEAP, mtClass) |
2534 GrowableArray<PreviousVersionNode *>(2, true); | 2534 GrowableArray<PreviousVersionNode *>(2, true); |
2535 } | 2535 } |
2536 | 2536 |
2537 // RC_TRACE macro has an embedded ResourceMark | 2537 // RC_TRACE macro has an embedded ResourceMark |
2538 RC_TRACE(0x00000100, ("adding previous version ref for %s @%d, EMCP_cnt=%d", | 2538 RC_TRACE(0x00000100, ("adding previous version ref for %s @%d, EMCP_cnt=%d", |
2554 pv_node = new PreviousVersionNode(cp_ref, !cp_h->is_shared(), NULL); | 2554 pv_node = new PreviousVersionNode(cp_ref, !cp_h->is_shared(), NULL); |
2555 RC_TRACE(0x00000400, | 2555 RC_TRACE(0x00000400, |
2556 ("add: all methods are obsolete; flushing any EMCP weak refs")); | 2556 ("add: all methods are obsolete; flushing any EMCP weak refs")); |
2557 } else { | 2557 } else { |
2558 int local_count = 0; | 2558 int local_count = 0; |
2559 GrowableArray<jweak>* method_refs = new (ResourceObj::C_HEAP) | 2559 GrowableArray<jweak>* method_refs = new (ResourceObj::C_HEAP, mtClass) |
2560 GrowableArray<jweak>(emcp_method_count, true); | 2560 GrowableArray<jweak>(emcp_method_count, true); |
2561 for (int i = 0; i < old_methods->length(); i++) { | 2561 for (int i = 0; i < old_methods->length(); i++) { |
2562 if (emcp_methods->at(i)) { | 2562 if (emcp_methods->at(i)) { |
2563 // this old method is EMCP so save a weak ref | 2563 // this old method is EMCP so save a weak ref |
2564 methodOop old_method = (methodOop) old_methods->obj_at(i); | 2564 methodOop old_method = (methodOop) old_methods->obj_at(i); |
2946 | 2946 |
2947 int length = _previous_versions->length(); | 2947 int length = _previous_versions->length(); |
2948 | 2948 |
2949 while (_current_index < length) { | 2949 while (_current_index < length) { |
2950 PreviousVersionNode * pv_node = _previous_versions->at(_current_index++); | 2950 PreviousVersionNode * pv_node = _previous_versions->at(_current_index++); |
2951 PreviousVersionInfo * pv_info = new (ResourceObj::C_HEAP) | 2951 PreviousVersionInfo * pv_info = new (ResourceObj::C_HEAP, mtClass) |
2952 PreviousVersionInfo(pv_node); | 2952 PreviousVersionInfo(pv_node); |
2953 | 2953 |
2954 constantPoolHandle cp_h = pv_info->prev_constant_pool_handle(); | 2954 constantPoolHandle cp_h = pv_info->prev_constant_pool_handle(); |
2955 if (cp_h.is_null()) { | 2955 if (cp_h.is_null()) { |
2956 delete pv_info; | 2956 delete pv_info; |