< prev index next >

src/share/vm/classfile/javaClasses.cpp

Print this page




  35 #include "memory/resourceArea.hpp"
  36 #include "memory/universe.inline.hpp"
  37 #include "oops/fieldStreams.hpp"
  38 #include "oops/instanceKlass.hpp"
  39 #include "oops/instanceMirrorKlass.hpp"
  40 #include "oops/klass.hpp"
  41 #include "oops/method.hpp"
  42 #include "oops/symbol.hpp"
  43 #include "oops/typeArrayOop.hpp"
  44 #include "prims/jvmtiRedefineClassesTrace.hpp"
  45 #include "runtime/fieldDescriptor.hpp"
  46 #include "runtime/handles.inline.hpp"
  47 #include "runtime/interfaceSupport.hpp"
  48 #include "runtime/java.hpp"
  49 #include "runtime/javaCalls.hpp"
  50 #include "runtime/safepoint.hpp"
  51 #include "runtime/thread.inline.hpp"
  52 #include "runtime/vframe.hpp"
  53 #include "utilities/preserveException.hpp"
  54 




  55 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  56 
  57 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java)    \
  58   klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
  59 
  60 #define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java)           \
  61   { SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java },
  62 
  63 InjectedField JavaClasses::_injected_fields[] = {
  64   ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
  65 };
  66 
  67 int JavaClasses::compute_injected_offset(InjectedFieldID id) {
  68   return _injected_fields[id].compute_offset();
  69 }
  70 
  71 
  72 InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) {
  73   *field_count = 0;
  74 


1190 void java_lang_ThreadGroup::compute_offsets() {
1191   assert(_parent_offset == 0, "offsets should be initialized only once");
1192 
1193   Klass* k = SystemDictionary::ThreadGroup_klass();
1194 
1195   compute_offset(_parent_offset,      k, vmSymbols::parent_name(),      vmSymbols::threadgroup_signature());
1196   compute_offset(_name_offset,        k, vmSymbols::name_name(),        vmSymbols::string_signature());
1197   compute_offset(_threads_offset,     k, vmSymbols::threads_name(),     vmSymbols::thread_array_signature());
1198   compute_offset(_groups_offset,      k, vmSymbols::groups_name(),      vmSymbols::threadgroup_array_signature());
1199   compute_offset(_maxPriority_offset, k, vmSymbols::maxPriority_name(), vmSymbols::int_signature());
1200   compute_offset(_destroyed_offset,   k, vmSymbols::destroyed_name(),   vmSymbols::bool_signature());
1201   compute_offset(_daemon_offset,      k, vmSymbols::daemon_name(),      vmSymbols::bool_signature());
1202   compute_offset(_vmAllowSuspension_offset, k, vmSymbols::vmAllowSuspension_name(), vmSymbols::bool_signature());
1203   compute_offset(_nthreads_offset,    k, vmSymbols::nthreads_name(),    vmSymbols::int_signature());
1204   compute_offset(_ngroups_offset,     k, vmSymbols::ngroups_name(),     vmSymbols::int_signature());
1205 }
1206 
1207 oop java_lang_Throwable::unassigned_stacktrace() {
1208   InstanceKlass* ik = InstanceKlass::cast(SystemDictionary::Throwable_klass());
1209   address addr = ik->static_field_addr(static_unassigned_stacktrace_offset);

1210   if (UseCompressedOops) {
1211     return oopDesc::load_decode_heap_oop((narrowOop *)addr);
1212   } else {
1213     return oopDesc::load_decode_heap_oop((oop*)addr);




1214   }


1215 }
1216 
1217 oop java_lang_Throwable::backtrace(oop throwable) {
1218   return throwable->obj_field_acquire(backtrace_offset);
1219 }
1220 
1221 
1222 void java_lang_Throwable::set_backtrace(oop throwable, oop value) {
1223   throwable->release_obj_field_put(backtrace_offset, value);
1224 }
1225 
1226 
1227 oop java_lang_Throwable::message(oop throwable) {
1228   return throwable->obj_field(detailMessage_offset);
1229 }
1230 
1231 
1232 oop java_lang_Throwable::message(Handle throwable) {
1233   return throwable->obj_field(detailMessage_offset);
1234 }


2620   case T_SHORT:     st->print("%d", value->s);                      break;
2621   case T_INT:       st->print("%d", value->i);                      break;
2622   case T_LONG:      st->print(INT64_FORMAT, value->j);              break;
2623   case T_FLOAT:     st->print("%f", value->f);                      break;
2624   case T_DOUBLE:    st->print("%lf", value->d);                     break;
2625   default:          st->print("type %d?", type);                    break;
2626   }
2627 }
2628 
2629 
2630 // Support for java_lang_ref_Reference
2631 HeapWord *java_lang_ref_Reference::pending_list_lock_addr() {
2632   InstanceKlass* ik = InstanceKlass::cast(SystemDictionary::Reference_klass());
2633   address addr = ik->static_field_addr(static_lock_offset);
2634   return (HeapWord*) addr;
2635 }
2636 
2637 oop java_lang_ref_Reference::pending_list_lock() {
2638   InstanceKlass* ik = InstanceKlass::cast(SystemDictionary::Reference_klass());
2639   address addr = ik->static_field_addr(static_lock_offset);

2640   if (UseCompressedOops) {
2641     return oopDesc::load_decode_heap_oop((narrowOop *)addr);
2642   } else {
2643     return oopDesc::load_decode_heap_oop((oop*)addr);




2644   }


2645 }
2646 
2647 HeapWord *java_lang_ref_Reference::pending_list_addr() {
2648   InstanceKlass* ik = InstanceKlass::cast(SystemDictionary::Reference_klass());
2649   address addr = ik->static_field_addr(static_pending_offset);
2650   // XXX This might not be HeapWord aligned, almost rather be char *.
2651   return (HeapWord*)addr;
2652 }
2653 
2654 oop java_lang_ref_Reference::pending_list() {
2655   char *addr = (char *)pending_list_addr();

2656   if (UseCompressedOops) {
2657     return oopDesc::load_decode_heap_oop((narrowOop *)addr);
2658   } else {
2659     return oopDesc::load_decode_heap_oop((oop*)addr);




2660   }


2661 }
2662 
2663 
2664 // Support for java_lang_ref_SoftReference
2665 
2666 jlong java_lang_ref_SoftReference::timestamp(oop ref) {
2667   return ref->long_field(timestamp_offset);
2668 }
2669 
2670 jlong java_lang_ref_SoftReference::clock() {
2671   InstanceKlass* ik = InstanceKlass::cast(SystemDictionary::SoftReference_klass());
2672   jlong* offset = (jlong*)ik->static_field_addr(static_clock_offset);
2673   return *offset;
2674 }
2675 
2676 void java_lang_ref_SoftReference::set_clock(jlong value) {
2677   InstanceKlass* ik = InstanceKlass::cast(SystemDictionary::SoftReference_klass());
2678   jlong* offset = (jlong*)ik->static_field_addr(static_clock_offset);
2679   *offset = value;
2680 }




  35 #include "memory/resourceArea.hpp"
  36 #include "memory/universe.inline.hpp"
  37 #include "oops/fieldStreams.hpp"
  38 #include "oops/instanceKlass.hpp"
  39 #include "oops/instanceMirrorKlass.hpp"
  40 #include "oops/klass.hpp"
  41 #include "oops/method.hpp"
  42 #include "oops/symbol.hpp"
  43 #include "oops/typeArrayOop.hpp"
  44 #include "prims/jvmtiRedefineClassesTrace.hpp"
  45 #include "runtime/fieldDescriptor.hpp"
  46 #include "runtime/handles.inline.hpp"
  47 #include "runtime/interfaceSupport.hpp"
  48 #include "runtime/java.hpp"
  49 #include "runtime/javaCalls.hpp"
  50 #include "runtime/safepoint.hpp"
  51 #include "runtime/thread.inline.hpp"
  52 #include "runtime/vframe.hpp"
  53 #include "utilities/preserveException.hpp"
  54 
  55 #if INCLUDE_ALL_GCS
  56 #include "gc_implementation/shenandoah/shenandoahBarrierSet.hpp"
  57 #endif
  58 
  59 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  60 
  61 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java)    \
  62   klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
  63 
  64 #define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java)           \
  65   { SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java },
  66 
  67 InjectedField JavaClasses::_injected_fields[] = {
  68   ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
  69 };
  70 
  71 int JavaClasses::compute_injected_offset(InjectedFieldID id) {
  72   return _injected_fields[id].compute_offset();
  73 }
  74 
  75 
  76 InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) {
  77   *field_count = 0;
  78 


1194 void java_lang_ThreadGroup::compute_offsets() {
1195   assert(_parent_offset == 0, "offsets should be initialized only once");
1196 
1197   Klass* k = SystemDictionary::ThreadGroup_klass();
1198 
1199   compute_offset(_parent_offset,      k, vmSymbols::parent_name(),      vmSymbols::threadgroup_signature());
1200   compute_offset(_name_offset,        k, vmSymbols::name_name(),        vmSymbols::string_signature());
1201   compute_offset(_threads_offset,     k, vmSymbols::threads_name(),     vmSymbols::thread_array_signature());
1202   compute_offset(_groups_offset,      k, vmSymbols::groups_name(),      vmSymbols::threadgroup_array_signature());
1203   compute_offset(_maxPriority_offset, k, vmSymbols::maxPriority_name(), vmSymbols::int_signature());
1204   compute_offset(_destroyed_offset,   k, vmSymbols::destroyed_name(),   vmSymbols::bool_signature());
1205   compute_offset(_daemon_offset,      k, vmSymbols::daemon_name(),      vmSymbols::bool_signature());
1206   compute_offset(_vmAllowSuspension_offset, k, vmSymbols::vmAllowSuspension_name(), vmSymbols::bool_signature());
1207   compute_offset(_nthreads_offset,    k, vmSymbols::nthreads_name(),    vmSymbols::int_signature());
1208   compute_offset(_ngroups_offset,     k, vmSymbols::ngroups_name(),     vmSymbols::int_signature());
1209 }
1210 
1211 oop java_lang_Throwable::unassigned_stacktrace() {
1212   InstanceKlass* ik = InstanceKlass::cast(SystemDictionary::Throwable_klass());
1213   address addr = ik->static_field_addr(static_unassigned_stacktrace_offset);
1214   oop result;
1215   if (UseCompressedOops) {
1216     result = oopDesc::load_decode_heap_oop((narrowOop *)addr);
1217   } else {
1218     result = oopDesc::load_decode_heap_oop((oop*)addr);
1219   }
1220 #if INCLUDE_ALL_GCS
1221   if (UseShenandoahGC) {
1222     result = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(result);
1223   }
1224 #endif
1225   return result;
1226 }
1227 
1228 oop java_lang_Throwable::backtrace(oop throwable) {
1229   return throwable->obj_field_acquire(backtrace_offset);
1230 }
1231 
1232 
1233 void java_lang_Throwable::set_backtrace(oop throwable, oop value) {
1234   throwable->release_obj_field_put(backtrace_offset, value);
1235 }
1236 
1237 
1238 oop java_lang_Throwable::message(oop throwable) {
1239   return throwable->obj_field(detailMessage_offset);
1240 }
1241 
1242 
1243 oop java_lang_Throwable::message(Handle throwable) {
1244   return throwable->obj_field(detailMessage_offset);
1245 }


2631   case T_SHORT:     st->print("%d", value->s);                      break;
2632   case T_INT:       st->print("%d", value->i);                      break;
2633   case T_LONG:      st->print(INT64_FORMAT, value->j);              break;
2634   case T_FLOAT:     st->print("%f", value->f);                      break;
2635   case T_DOUBLE:    st->print("%lf", value->d);                     break;
2636   default:          st->print("type %d?", type);                    break;
2637   }
2638 }
2639 
2640 
2641 // Support for java_lang_ref_Reference
2642 HeapWord *java_lang_ref_Reference::pending_list_lock_addr() {
2643   InstanceKlass* ik = InstanceKlass::cast(SystemDictionary::Reference_klass());
2644   address addr = ik->static_field_addr(static_lock_offset);
2645   return (HeapWord*) addr;
2646 }
2647 
2648 oop java_lang_ref_Reference::pending_list_lock() {
2649   InstanceKlass* ik = InstanceKlass::cast(SystemDictionary::Reference_klass());
2650   address addr = ik->static_field_addr(static_lock_offset);
2651   oop result;
2652   if (UseCompressedOops) {
2653     result = oopDesc::load_decode_heap_oop((narrowOop *)addr);
2654   } else {
2655     result = oopDesc::load_decode_heap_oop((oop*)addr);
2656   }
2657 #if INCLUDE_ALL_GCS
2658   if (UseShenandoahGC) {
2659     result = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(result);
2660   }
2661 #endif
2662   return result;
2663 }
2664 
2665 HeapWord *java_lang_ref_Reference::pending_list_addr() {
2666   InstanceKlass* ik = InstanceKlass::cast(SystemDictionary::Reference_klass());
2667   address addr = ik->static_field_addr(static_pending_offset);
2668   // XXX This might not be HeapWord aligned, almost rather be char *.
2669   return (HeapWord*)addr;
2670 }
2671 
2672 oop java_lang_ref_Reference::pending_list() {
2673   char *addr = (char *)pending_list_addr();
2674   oop result;
2675   if (UseCompressedOops) {
2676     result = oopDesc::load_decode_heap_oop((narrowOop *)addr);
2677   } else {
2678     result = oopDesc::load_decode_heap_oop((oop*)addr);
2679   }
2680 #if INCLUDE_ALL_GCS
2681   if (UseShenandoahGC) {
2682     result = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(result);
2683   }
2684 #endif
2685   return result;
2686 }
2687 
2688 
2689 // Support for java_lang_ref_SoftReference
2690 
2691 jlong java_lang_ref_SoftReference::timestamp(oop ref) {
2692   return ref->long_field(timestamp_offset);
2693 }
2694 
2695 jlong java_lang_ref_SoftReference::clock() {
2696   InstanceKlass* ik = InstanceKlass::cast(SystemDictionary::SoftReference_klass());
2697   jlong* offset = (jlong*)ik->static_field_addr(static_clock_offset);
2698   return *offset;
2699 }
2700 
2701 void java_lang_ref_SoftReference::set_clock(jlong value) {
2702   InstanceKlass* ik = InstanceKlass::cast(SystemDictionary::SoftReference_klass());
2703   jlong* offset = (jlong*)ik->static_field_addr(static_clock_offset);
2704   *offset = value;
2705 }


< prev index next >