< prev index next >
src/hotspot/share/prims/jvmtiExport.hpp
Print this page
rev 48565 : [mq]: event
@@ -121,10 +121,11 @@
// we are holding objects on the heap - need to talk to GC - e.g.
// breakpoint info
JVMTI_SUPPORT_FLAG(should_clean_up_heap_objects)
JVMTI_SUPPORT_FLAG(should_post_vm_object_alloc)
+ JVMTI_SUPPORT_FLAG(should_post_sampled_object_alloc)
// If flag cannot be implemented, give an error if on=true
static void report_unsupported(bool on);
// these should only be called by the friend class
@@ -374,10 +375,21 @@
inline static void vm_object_alloc_event_collector(oop object) {
if (should_post_vm_object_alloc()) {
record_vm_internal_object_allocation(object);
}
}
+
+ static void record_sampled_internal_object_allocation(oop object) NOT_JVMTI_RETURN;
+ // Post objects collected by sampled_object_alloc_event_collector.
+ static void post_sampled_object_alloc(JavaThread *thread, oop object) NOT_JVMTI_RETURN;
+ // Collects vm internal objects for later event posting.
+ inline static void sampled_object_alloc_event_collector(oop object) {
+ if (should_post_sampled_object_alloc()) {
+ record_sampled_internal_object_allocation(object);
+ }
+ }
+
inline static void post_array_size_exhausted() {
if (should_post_resource_exhausted()) {
post_resource_exhausted(JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR,
"Requested array size exceeds VM limit");
}
@@ -435,14 +447,17 @@
class JvmtiEventCollector : public StackObj {
private:
JvmtiEventCollector* _prev; // Save previous one to support nested event collector.
public:
+ JvmtiEventCollector() : _prev(NULL) {}
+
void setup_jvmti_thread_state(); // Set this collector in current thread.
void unset_jvmti_thread_state(); // Reset previous collector in current thread.
virtual bool is_dynamic_code_event() { return false; }
virtual bool is_vm_object_alloc_event(){ return false; }
+ virtual bool is_sampled_object_alloc_event(){ return false; }
JvmtiEventCollector *get_prev() { return _prev; }
};
// A JvmtiDynamicCodeEventCollector is a helper class for the JvmtiExport
// interface. It collects "dynamic code generated" events that are posted
@@ -473,25 +488,22 @@
~JvmtiDynamicCodeEventCollector() NOT_JVMTI_RETURN;
bool is_dynamic_code_event() { return true; }
};
-// Used to record vm internally allocated object oops and post
-// vm object alloc event for objects visible to java world.
-// Constructor enables JvmtiThreadState flag and all vm allocated
-// objects are recorded in a growable array. When destructor is
-// called the vm object alloc event is posted for each objects
-// visible to java world.
-// See jvm.cpp file for its usage.
+// Used as a base class for object allocation collection and then posting
+// the allocations to any event notification callbacks.
//
-class JvmtiVMObjectAllocEventCollector : public JvmtiEventCollector {
- private:
+class JvmtiObjectAllocEventCollector : public JvmtiEventCollector {
+ protected:
GrowableArray<oop>* _allocated; // field to record vm internally allocated object oop.
bool _enable; // This flag is enabled in constructor and disabled
// in destructor before posting event. To avoid
// collection of objects allocated while running java code inside
- // agent post_vm_object_alloc() event handler.
+ // agent post_X_object_alloc() event handler.
+ void (*_post_callback)(JavaThread*, oop); // what callback to use when destroying the collector.
+ bool _callback_for_all_oops;
//GC support
void oops_do(OopClosure* f);
friend class JvmtiExport;
@@ -500,19 +512,46 @@
//GC support
static void oops_do_for_all_threads(OopClosure* f);
public:
- JvmtiVMObjectAllocEventCollector() NOT_JVMTI_RETURN;
- ~JvmtiVMObjectAllocEventCollector() NOT_JVMTI_RETURN;
- bool is_vm_object_alloc_event() { return true; }
+ JvmtiObjectAllocEventCollector() NOT_JVMTI_RETURN;
+
+ void generate_call_for_allocated();
bool is_enabled() { return _enable; }
void set_enabled(bool on) { _enable = on; }
};
+// Used to record vm internally allocated object oops and post
+// vm object alloc event for objects visible to java world.
+// Constructor enables JvmtiThreadState flag and all vm allocated
+// objects are recorded in a growable array. When destructor is
+// called the vm object alloc event is posted for each object
+// visible to java world.
+// See jvm.cpp file for its usage.
+//
+class JvmtiVMObjectAllocEventCollector : public JvmtiObjectAllocEventCollector {
+ public:
+ JvmtiVMObjectAllocEventCollector() NOT_JVMTI_RETURN;
+ ~JvmtiVMObjectAllocEventCollector() NOT_JVMTI_RETURN;
+ virtual bool is_vm_object_alloc_event() { return true; }
+};
+// Used to record sampled allocated object oops and post
+// sampled object alloc event.
+// Constructor enables JvmtiThreadState flag and all sampled allocated
+// objects are recorded in a growable array. When destructor is
+// called the sampled object alloc event is posted for each sampled object.
+// See jvm.cpp file for its usage.
+//
+class JvmtiSampledObjectAllocEventCollector : public JvmtiObjectAllocEventCollector {
+ public:
+ JvmtiSampledObjectAllocEventCollector() NOT_JVMTI_RETURN;
+ ~JvmtiSampledObjectAllocEventCollector() NOT_JVMTI_RETURN;
+ bool is_sampled_object_alloc_event() { return true; }
+};
// Marker class to disable the posting of VMObjectAlloc events
// within its scope.
//
// Usage :-
< prev index next >