Skip to content

Commit

Permalink
[Backport] 8225797: OldObjectSample event creates unexpected amount o…
Browse files Browse the repository at this point in the history
…f checkpoint data

Summary:

Test Plan: jdk/jfr

Reviewed-by: yuleil

Issue: dragonwell-project/dragonwell8#112
  • Loading branch information
D-D-H committed Jul 31, 2020
1 parent 49c13aa commit 0912115
Show file tree
Hide file tree
Showing 54 changed files with 2,512 additions and 2,381 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ static void copy_method_trace_flags(const InstanceKlass* the_original_klass, con
assert(new_method != NULL, "invariant");
assert(new_method->name() == old_method->name(), "invariant");
assert(new_method->signature() == old_method->signature(), "invariant");
*new_method->trace_flags_addr() = old_method->trace_flags();
new_method->set_trace_flags(old_method->trace_flags());
assert(new_method->trace_flags() == old_method->trace_flags(), "invariant");
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/share/vm/jfr/jfr.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -92,7 +92,9 @@ void Jfr::on_vm_shutdown(bool exception_handler) {
}

void Jfr::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f) {
LeakProfiler::oops_do(is_alive, f);
if (LeakProfiler::is_running()) {
LeakProfiler::oops_do(is_alive, f);
}
}

void Jfr::weak_oops_do(OopClosure* f) {
Expand Down
18 changes: 11 additions & 7 deletions src/share/vm/jfr/leakprofiler/chains/edgeStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,23 @@ bool EdgeStore::is_empty() const {
return !_edges->has_entries();
}

void EdgeStore::assign_id(EdgeEntry* entry) {
void EdgeStore::on_link(EdgeEntry* entry) {
assert(entry != NULL, "invariant");
assert(entry->id() == 0, "invariant");
entry->set_id(++_edge_id_counter);
}

bool EdgeStore::equals(const Edge& query, uintptr_t hash, const EdgeEntry* entry) {
bool EdgeStore::on_equals(uintptr_t hash, const EdgeEntry* entry) {
assert(entry != NULL, "invariant");
assert(entry->hash() == hash, "invariant");
return true;
}

void EdgeStore::on_unlink(EdgeEntry* entry) {
assert(entry != NULL, "invariant");
// nothing
}

#ifdef ASSERT
bool EdgeStore::contains(const oop* reference) const {
return get(reference) != NULL;
Expand All @@ -75,22 +80,21 @@ bool EdgeStore::contains(const oop* reference) const {

StoredEdge* EdgeStore::get(const oop* reference) const {
assert(reference != NULL, "invariant");
const StoredEdge e(NULL, reference);
EdgeEntry* const entry = _edges->lookup_only(e, (uintptr_t)reference);
EdgeEntry* const entry = _edges->lookup_only((uintptr_t)reference);
return entry != NULL ? entry->literal_addr() : NULL;
}

StoredEdge* EdgeStore::put(const oop* reference) {
assert(reference != NULL, "invariant");
const StoredEdge e(NULL, reference);
assert(NULL == _edges->lookup_only(e, (uintptr_t)reference), "invariant");
EdgeEntry& entry = _edges->put(e, (uintptr_t)reference);
assert(NULL == _edges->lookup_only((uintptr_t)reference), "invariant");
EdgeEntry& entry = _edges->put((uintptr_t)reference, e);
return entry.literal_addr();
}

traceid EdgeStore::get_id(const Edge* edge) const {
assert(edge != NULL, "invariant");
EdgeEntry* const entry = _edges->lookup_only(*edge, (uintptr_t)edge->reference());
EdgeEntry* const entry = _edges->lookup_only((uintptr_t)edge->reference());
assert(entry != NULL, "invariant");
return entry->id();
}
Expand Down
7 changes: 4 additions & 3 deletions src/share/vm/jfr/leakprofiler/chains/edgeStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class StoredEdge : public Edge {
};

class EdgeStore : public CHeapObj<mtTracing> {
typedef HashTableHost<StoredEdge, traceid, Entry, EdgeStore> EdgeHashTable;
typedef HashTableHost<StoredEdge, traceid, JfrHashtableEntry, EdgeStore> EdgeHashTable;
typedef EdgeHashTable::HashEntry EdgeEntry;
template <typename,
typename,
Expand All @@ -74,8 +74,9 @@ class EdgeStore : public CHeapObj<mtTracing> {
EdgeHashTable* _edges;

// Hash table callbacks
void assign_id(EdgeEntry* entry);
bool equals(const Edge& query, uintptr_t hash, const EdgeEntry* entry);
void on_link(EdgeEntry* entry);
bool on_equals(uintptr_t hash, const EdgeEntry* entry);
void on_unlink(EdgeEntry* entry);

StoredEdge* get(const oop* reference) const;
StoredEdge* put(const oop* reference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "jfr/leakprofiler/sampling/objectSampler.hpp"
#include "jfr/leakprofiler/utilities/granularTimer.hpp"
#include "memory/universe.hpp"
#include "oops/markOop.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/safepoint.hpp"
#include "utilities/globalDefinitions.hpp"
Expand Down Expand Up @@ -101,7 +100,7 @@ void PathToGcRootsOperation::doit() {
// Save the original markWord for the potential leak objects,
// to be restored on function exit
ObjectSampleMarker marker;
if (ObjectSampleCheckpoint::mark(_sampler, marker, _emit_all) == 0) {
if (ObjectSampleCheckpoint::save_mark_words(_sampler, marker, _emit_all) == 0) {
// no valid samples to process
return;
}
Expand Down
Loading

0 comments on commit 0912115

Please sign in to comment.