Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JFR] Fix build issues caused by object allocation profiling on Windows/Mac #25

Merged
merged 1 commit into from
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/share/vm/gc_interface/allocTracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*
*/

#include "precompiled.hpp"
#include "gc_implementation/shared/gcId.hpp"
#include "gc_interface/allocTracer.hpp"
#include "trace/tracing.hpp"
Expand Down
8 changes: 5 additions & 3 deletions src/share/vm/gc_interface/allocTracer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@
#include "utilities/globalDefinitions.hpp"

class AllocTracer : AllStatic {
private:
static void send_opto_array_allocation_event(KlassHandle klass, oop obj,size_t alloc_size, Thread* thread);
static void send_opto_instance_allocation_event(KlassHandle klass, oop obj, Thread* thread);
public:
static void send_allocation_outside_tlab_event(KlassHandle klass, HeapWord* obj, size_t alloc_size, Thread* thread);
static void send_allocation_in_new_tlab_event(KlassHandle klass, HeapWord* obj, size_t tlab_size, size_t alloc_size, Thread* thread);
static void send_allocation_requiring_gc_event(size_t size, const GCId& gcId);
#if INCLUDE_TRACE
static void opto_slow_allocation_enter(bool is_array, Thread* thread);
static void opto_slow_allocation_leave(bool is_array, Thread* thread);
static void send_slow_allocation_event(KlassHandle klass, oop obj,size_t alloc_size, Thread* thread);
static void send_opto_fast_allocation_event(KlassHandle klass, oop obj, size_t alloc_size, Thread* thread);
private:
static void send_opto_array_allocation_event(KlassHandle klass, oop obj,size_t alloc_size, Thread* thread);
static void send_opto_instance_allocation_event(KlassHandle klass, oop obj, Thread* thread);
#endif
};

#endif /* SHARE_VM_GC_INTERFACE_ALLOCTRACER_HPP */
2 changes: 2 additions & 0 deletions src/share/vm/gc_interface/allocTracer.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#ifndef SHARE_VM_GC_INTERFACE_ALLOCTRACER_INLINE_HPP
#define SHARE_VM_GC_INTERFACE_ALLOCTRACER_INLINE_HPP

#if INCLUDE_TRACE
#include "trace/tracing.hpp"
#include "gc_implementation/shared/gcId.hpp"
#include "runtime/handles.hpp"
Expand Down Expand Up @@ -117,4 +118,5 @@ inline void AllocTracer::send_opto_fast_allocation_event(KlassHandle klass, oop
thread->trace_data()->incr_alloc_count_until_sample(interval);
}

#endif // INCLUDE_TRACE
#endif /* SHARE_VM_GC_INTERFACE_ALLOCTRACER_INLINE_HPP */
2 changes: 2 additions & 0 deletions src/share/vm/gc_interface/collectedHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,12 @@ class CollectedHeap : public CHeapObj<mtInternal> {
inline static void check_array_size(int size, int length, TRAPS);

public:
#if INCLUDE_TRACE
// Implicit Jfr inline methods.
static void trace_slow_allocation(KlassHandle klass, oop obj, size_t alloc_size, Thread* thread) {
AllocTracer::send_slow_allocation_event(klass, obj, alloc_size, thread);
}
#endif

static void trace_allocation_outside_tlab(KlassHandle klass, HeapWord* obj, size_t alloc_size, Thread* thread) {
AllocTracer::send_allocation_outside_tlab_event(klass, obj, alloc_size, thread);
Expand Down
2 changes: 2 additions & 0 deletions src/share/vm/gc_interface/collectedHeap.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ inline void post_allocation_notify(KlassHandle klass, oop obj, int size) {
}
}

#if INCLUDE_TRACE
// support for jfr
CollectedHeap::trace_slow_allocation(klass, obj, size * HeapWordSize, Thread::current());
#endif
}

void CollectedHeap::post_allocation_setup_obj(KlassHandle klass,
Expand Down
4 changes: 4 additions & 0 deletions src/share/vm/opto/macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1442,9 +1442,11 @@ void PhaseMacroExpand::expand_allocate_common(
}
}

#if INCLUDE_TRACE
if (EnableJFR && JfrOptionSet::sample_object_allocations()) {
jfr_sample_fast_object_allocation(alloc, fast_oop, fast_oop_ctrl, fast_oop_rawmem);
}
#endif

if (C->env()->dtrace_extended_probes()) {
// Slow-path call
Expand Down Expand Up @@ -1643,6 +1645,7 @@ static jint bottom_java_frame_bci(JVMState* state) {
return last->bci();
}

#if INCLUDE_TRACE
//
// Pseudo code:
//
Expand Down Expand Up @@ -1739,6 +1742,7 @@ void PhaseMacroExpand::jfr_sample_fast_object_allocation(
fast_oop_rawmem = alloc_sample_enabled_region_phi_mem;
}
}
#endif

// Helper for PhaseMacroExpand::expand_allocate_common.
// Initializes the newly-allocated storage.
Expand Down
2 changes: 2 additions & 0 deletions src/share/vm/opto/macro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ class PhaseMacroExpand : public Phase {
Node* old_eden_top, Node* new_eden_top,
Node* length);

#if INCLUDE_TRACE
//JFR tracing
void jfr_sample_fast_object_allocation(AllocateNode* alloc, Node* fast_oop,
Node*& fast_oop_ctrl, Node*& fast_oop_rawmem);
#endif

public:
PhaseMacroExpand(PhaseIterGVN &igvn) : Phase(Macro_Expand), _igvn(igvn), _has_locks(false) {
Expand Down
2 changes: 2 additions & 0 deletions src/share/vm/opto/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,7 @@ JRT_END

//-----------------------------------------------------------------------------
// JFR support.
#if INCLUDE_TRACE
const TypeFunc *OptoRuntime::jfr_fast_object_alloc_Type() {
const Type **fields = TypeTuple::fields(3);
fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // newly allocated object
Expand All @@ -1703,3 +1704,4 @@ void OptoRuntime::jfr_fast_object_alloc_C(oopDesc* obj, jint top_frame_bci, Java
thread->trace_data()->clear_cached_top_frame_bci();
thread->set_vm_result(obj);
}
#endif
4 changes: 4 additions & 0 deletions src/share/vm/opto/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ class OptoRuntime : public AllStatic {
static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock);

#if INCLUDE_TRACE
// JFR support
static void jfr_fast_object_alloc_C(oopDesc* obj, jint bci, JavaThread* thread);
#endif
private:

// Implicit exception support
Expand Down Expand Up @@ -339,8 +341,10 @@ class OptoRuntime : public AllStatic {
static const TypeFunc* zap_dead_locals_Type();
# endif

#if INCLUDE_TRACE
// JFR support
static const TypeFunc* jfr_fast_object_alloc_Type();
#endif

private:
static NamedCounter * volatile _named_counters;
Expand Down