61 const uint32_t x_high = x >> 32;
62 const uint32_t y = x_high >> (20 - FastLogNumBits) & FastLogMask;
63 const int32_t exponent = ((x_high >> 20) & 0x7FF) - 1023;
64 return exponent + _log_table[y];
65 }
66
67 public:
68 /*
69 * General note: currently none of these methods are deemed thread-safe.
70 */
71
72 // First method called by user to start the profiler:
73 // - Note: the lower the monitoring rate, the higher the overhead incurred.
74 static void initialize_profiling(jint monitoring_rate, jint max_gc_storage);
75
76 // Pick the next sample for a given size_t pointer using a geometric variable
77 // with specified mean. The specified mean is provided via the
78 // initialize_profiling method.
79 static void pick_next_sample(size_t* ptr);
80
81 // Get live/garbage traces and provide a method to release the traces.
82 static void get_live_traces(jvmtiStackTraces* stack_traces);
83 static void get_garbage_traces(jvmtiStackTraces* stack_traces);
84 static void get_frequent_garbage_traces(jvmtiStackTraces* stack_traces);
85 static void get_cached_traces(jvmtiStackTraces* stack_traces);
86 static void release_traces(jvmtiStackTraces* trace_info);
87
88 static void get_sampling_statistics(jvmtiHeapSamplingStats* stats);
89 static void stop_profiling();
90
91 // Called when o is to be sampled from a given thread and a given size.
92 static void object_alloc_do_sample(Thread* t, oopDesc* o, intx size_in_bytes);
93
94 // Called to clean up oops that have been saved by our sampling function,
95 // but which no longer have other references in the heap.
96 static void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f);
97 static void weak_oops_do(OopClosure* oop_closure) {
98 AlwaysTrueClosure _always_true;
99 weak_oops_do(&_always_true, oop_closure);
100 }
101
102 static bool enabled() {
103 return OrderAccess::load_acquire(&_enabled) != 0;
104 }
105 };
106
107 #endif // SHARE_RUNTIME_HEAPMONITORING_HPP
|
61 const uint32_t x_high = x >> 32;
62 const uint32_t y = x_high >> (20 - FastLogNumBits) & FastLogMask;
63 const int32_t exponent = ((x_high >> 20) & 0x7FF) - 1023;
64 return exponent + _log_table[y];
65 }
66
67 public:
68 /*
69 * General note: currently none of these methods are deemed thread-safe.
70 */
71
72 // First method called by user to start the profiler:
73 // - Note: the lower the monitoring rate, the higher the overhead incurred.
74 static void initialize_profiling(jint monitoring_rate, jint max_gc_storage);
75
76 // Pick the next sample for a given size_t pointer using a geometric variable
77 // with specified mean. The specified mean is provided via the
78 // initialize_profiling method.
79 static void pick_next_sample(size_t* ptr);
80
81 // Get live/cached/garbage traces.
82 static void get_live_traces(JvmtiEnv* env,
83 jvmtiAllocTraceInfo** stack_traces,
84 jint* trace_counter_ptr);
85 static void get_garbage_traces(JvmtiEnv* env,
86 jvmtiAllocTraceInfo** stack_traces,
87 jint* trace_counter_ptr);
88 static void get_frequent_garbage_traces(JvmtiEnv* env,
89 jvmtiAllocTraceInfo** stack_traces,
90 jint* trace_counter_ptr);
91 static void get_cached_traces(JvmtiEnv* env,
92 jvmtiAllocTraceInfo** stack_traces,
93 jint* trace_counter_ptr);
94
95 static void get_sampling_statistics(jvmtiHeapSamplingStats* stats);
96 static void stop_profiling();
97
98 // Called when o is to be sampled from a given thread and a given size.
99 static void object_alloc_do_sample(Thread* t, oopDesc* o, size_t size_in_bytes);
100
101 // Called to clean up oops that have been saved by our sampling function,
102 // but which no longer have other references in the heap.
103 static void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f);
104 static void weak_oops_do(OopClosure* oop_closure) {
105 AlwaysTrueClosure _always_true;
106 weak_oops_do(&_always_true, oop_closure);
107 }
108
109 static bool enabled() {
110 return OrderAccess::load_acquire(&_enabled) != 0;
111 }
112 };
113
114 #endif // SHARE_RUNTIME_HEAPMONITORING_HPP
|