equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "classfile/symbolTable.hpp" |
26 #include "classfile/symbolTable.hpp" |
27 #include "classfile/systemDictionary.hpp" |
27 #include "classfile/systemDictionary.hpp" |
28 #include "classfile/vmSymbols.hpp" |
28 #include "classfile/vmSymbols.hpp" |
29 #include "jvmtifiles/jvmtiEnv.hpp" |
29 #include "jvmtifiles/jvmtiEnv.hpp" |
|
30 #include "oops/instanceMirrorKlass.hpp" |
30 #include "oops/objArrayKlass.hpp" |
31 #include "oops/objArrayKlass.hpp" |
31 #include "oops/oop.inline2.hpp" |
32 #include "oops/oop.inline2.hpp" |
32 #include "prims/jvmtiEventController.hpp" |
33 #include "prims/jvmtiEventController.hpp" |
33 #include "prims/jvmtiEventController.inline.hpp" |
34 #include "prims/jvmtiEventController.inline.hpp" |
34 #include "prims/jvmtiExport.hpp" |
35 #include "prims/jvmtiExport.hpp" |
2592 |
2593 |
2593 // many roots are Klasses so we use the java mirror |
2594 // many roots are Klasses so we use the java mirror |
2594 if (o->is_klass()) { |
2595 if (o->is_klass()) { |
2595 klassOop k = (klassOop)o; |
2596 klassOop k = (klassOop)o; |
2596 o = Klass::cast(k)->java_mirror(); |
2597 o = Klass::cast(k)->java_mirror(); |
|
2598 if (o == NULL) { |
|
2599 // Classes without mirrors don't correspond to real Java |
|
2600 // classes so just ignore them. |
|
2601 return; |
|
2602 } |
2597 } else { |
2603 } else { |
2598 |
2604 |
2599 // SystemDictionary::always_strong_oops_do reports the application |
2605 // SystemDictionary::always_strong_oops_do reports the application |
2600 // class loader as a root. We want this root to be reported as |
2606 // class loader as a root. We want this root to be reported as |
2601 // a root kind of "OTHER" rather than "SYSTEM_CLASS". |
2607 // a root kind of "OTHER" rather than "SYSTEM_CLASS". |
2832 return true; |
2838 return true; |
2833 } |
2839 } |
2834 |
2840 |
2835 // verify that a static oop field is in range |
2841 // verify that a static oop field is in range |
2836 static inline bool verify_static_oop(instanceKlass* ik, |
2842 static inline bool verify_static_oop(instanceKlass* ik, |
2837 klassOop k, int offset) { |
2843 oop mirror, int offset) { |
2838 address obj_p = (address)k + offset; |
2844 address obj_p = (address)mirror + offset; |
2839 address start = (address)ik->start_of_static_fields(); |
2845 address start = (address)instanceMirrorKlass::start_of_static_fields(mirror); |
2840 address end = start + (ik->static_oop_field_size() * heapOopSize); |
2846 address end = start + (java_lang_Class::static_oop_field_count(mirror) * heapOopSize); |
2841 assert(end >= start, "sanity check"); |
2847 assert(end >= start, "sanity check"); |
2842 |
2848 |
2843 if (obj_p >= start && obj_p < end) { |
2849 if (obj_p >= start && obj_p < end) { |
2844 return true; |
2850 return true; |
2845 } else { |
2851 } else { |
2936 ClassFieldMap* field_map = ClassFieldMap::create_map_of_static_fields(k); |
2942 ClassFieldMap* field_map = ClassFieldMap::create_map_of_static_fields(k); |
2937 for (i=0; i<field_map->field_count(); i++) { |
2943 for (i=0; i<field_map->field_count(); i++) { |
2938 ClassFieldDescriptor* field = field_map->field_at(i); |
2944 ClassFieldDescriptor* field = field_map->field_at(i); |
2939 char type = field->field_type(); |
2945 char type = field->field_type(); |
2940 if (!is_primitive_field_type(type)) { |
2946 if (!is_primitive_field_type(type)) { |
2941 oop fld_o = k->obj_field(field->field_offset()); |
2947 oop fld_o = mirror->obj_field(field->field_offset()); |
2942 assert(verify_static_oop(ik, k, field->field_offset()), "sanity check"); |
2948 assert(verify_static_oop(ik, mirror, field->field_offset()), "sanity check"); |
2943 if (fld_o != NULL) { |
2949 if (fld_o != NULL) { |
2944 int slot = field->field_index(); |
2950 int slot = field->field_index(); |
2945 if (!CallbackInvoker::report_static_field_reference(mirror, fld_o, slot)) { |
2951 if (!CallbackInvoker::report_static_field_reference(mirror, fld_o, slot)) { |
2946 delete field_map; |
2952 delete field_map; |
2947 return false; |
2953 return false; |