8223626: move print() functions to cpp files

Improve debugging experience

Reviewed-by: dholmes, dlong
This commit is contained in:
Coleen Phillimore 2019-05-10 09:05:29 -04:00
parent c90f3ee68b
commit 77d60eff6a
44 changed files with 100 additions and 45 deletions

View File

@ -915,6 +915,8 @@ void ClassLoaderData::print_value_on(outputStream* out) const {
}
}
void ClassLoaderData::print_value() const { print_value_on(tty); }
#ifndef PRODUCT
void ClassLoaderData::print_on(outputStream* out) const {
out->print("ClassLoaderData CLD: " PTR_FORMAT ", loader: " PTR_FORMAT ", loader_klass: %s {",
@ -933,6 +935,8 @@ void ClassLoaderData::print_on(outputStream* out) const {
}
#endif // PRODUCT
void ClassLoaderData::print() const { print_on(tty); }
void ClassLoaderData::verify() {
assert_locked_or_safepoint(_metaspace_lock);
oop cl = class_loader();

View File

@ -282,9 +282,9 @@ class ClassLoaderData : public CHeapObj<mtClass> {
JNIMethodBlock* jmethod_ids() const { return _jmethod_ids; }
void set_jmethod_ids(JNIMethodBlock* new_block) { _jmethod_ids = new_block; }
void print() { print_on(tty); }
void print() const;
void print_on(outputStream* out) const PRODUCT_RETURN;
void print_value() { print_value_on(tty); }
void print_value() const;
void print_value_on(outputStream* out) const;
void verify();

View File

@ -707,3 +707,5 @@ void ClassLoaderDataGraph::print_on(outputStream * const out) {
}
}
#endif // PRODUCT
void ClassLoaderDataGraph::print() { print_on(tty); }

View File

@ -134,7 +134,7 @@ class ClassLoaderDataGraph : public AllStatic {
static void set_metaspace_oom(bool value) { _metaspace_oom = value; }
static void print_on(outputStream * const out) PRODUCT_RETURN;
static void print() { print_on(tty); }
static void print();
static void verify();
// instance and array class counters

View File

@ -2825,6 +2825,8 @@ void SystemDictionary::print_on(outputStream *st) {
st->cr();
}
void SystemDictionary::print() { print_on(tty); }
void SystemDictionary::verify() {
guarantee(constraints() != NULL,
"Verify of loader constraints failed");

View File

@ -355,7 +355,7 @@ public:
public:
// Printing
static void print() { return print_on(tty); }
static void print();
static void print_on(outputStream* st);
static void dump(outputStream* st, bool verbose);

View File

@ -1269,6 +1269,8 @@ void SystemDictionaryShared::print_on(outputStream* st) {
}
}
void SystemDictionaryShared::print() { print_on(tty); }
void SystemDictionaryShared::print_table_statistics(outputStream* st) {
if (UseSharedSpaces) {
_builtin_dictionary.print_table_statistics(st, "Builtin Shared Dictionary");

View File

@ -295,7 +295,7 @@ public:
static void dumptime_classes_do(class MetaspaceClosure* it);
static void write_to_archive();
static void serialize_dictionary_headers(class SerializeClosure* soc);
static void print() { return print_on(tty); }
static void print();
static void print_on(outputStream* st) NOT_CDS_RETURN;
static void print_table_statistics(outputStream* st) NOT_CDS_RETURN;

View File

@ -558,6 +558,8 @@ void CodeBlob::print_on(outputStream* st) const {
st->print_cr("Framesize: %d", _frame_size);
}
void CodeBlob::print() const { print_on(tty); }
void CodeBlob::print_value_on(outputStream* st) const {
st->print_cr("[CodeBlob]");
}

View File

@ -224,7 +224,7 @@ public:
// Debugging
virtual void verify() = 0;
virtual void print() const { print_on(tty); };
virtual void print() const;
virtual void print_on(outputStream* st) const;
virtual void print_value_on(outputStream* st) const;
void dump_for_addr(address addr, outputStream* st, bool verbose) const;
@ -374,7 +374,6 @@ class RuntimeBlob : public CodeBlob {
virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { ShouldNotReachHere(); }
// Debugging
void print() const { print_on(tty); }
virtual void print_on(outputStream* st) const { CodeBlob::print_on(st); }
virtual void print_value_on(outputStream* st) const { CodeBlob::print_value_on(st); }

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -48,3 +48,5 @@ void VMRegImpl::print_on(outputStream* st) const {
st->print("BAD!");
}
}
void VMRegImpl::print() const { print_on(tty); }

View File

@ -112,7 +112,7 @@ public:
intptr_t value() const {return (intptr_t) this; }
void print_on(outputStream* st) const;
void print() const { print_on(tty); }
void print() const;
// bias a stack slot.
// Typically used to adjust a virtual frame slots by amounts that are offset by

View File

@ -84,6 +84,7 @@ void VtableStub::print_on(outputStream* st) const {
index(), p2i(receiver_location()), p2i(code_begin()), p2i(code_end()));
}
void VtableStub::print() const { print_on(tty); }
// -----------------------------------------------------------------------------------------
// Implementation of VtableStubs

View File

@ -177,7 +177,7 @@ class VtableStub {
bool is_null_pointer_exception(address epc) { return epc == code_begin()+_npe_offset; }
void print_on(outputStream* st) const;
void print() const { print_on(tty); }
void print() const;
};

View File

@ -510,6 +510,8 @@ void OopMapValue::print_on(outputStream* st) const {
st->print(" ");
}
void OopMapValue::print() const { print_on(tty); }
void ImmutableOopMap::print_on(outputStream* st) const {
OopMapValue omv;
st->print("ImmutableOopMap{");
@ -520,6 +522,8 @@ void ImmutableOopMap::print_on(outputStream* st) const {
st->print("}");
}
void ImmutableOopMap::print() const { print_on(tty); }
void OopMap::print_on(outputStream* st) const {
OopMapValue omv;
st->print("OopMap{");
@ -530,6 +534,8 @@ void OopMap::print_on(outputStream* st) const {
st->print("off=%d}", (int) offset());
}
void OopMap::print() const { print_on(tty); }
void ImmutableOopMapSet::print_on(outputStream* st) const {
const ImmutableOopMap* last = NULL;
for (int i = 0; i < _count; ++i) {
@ -545,6 +551,8 @@ void ImmutableOopMapSet::print_on(outputStream* st) const {
}
}
void ImmutableOopMapSet::print() const { print_on(tty); }
void OopMapSet::print_on(outputStream* st) const {
int i, len = om_count();
@ -558,6 +566,8 @@ void OopMapSet::print_on(outputStream* st) const {
}
}
void OopMapSet::print() const { print_on(tty); }
bool OopMap::equals(const OopMap* other) const {
if (other->_omv_count != _omv_count) {
return false;

View File

@ -133,7 +133,7 @@ public:
}
void print_on(outputStream* st) const;
void print() const { print_on(tty); }
void print() const;
};
@ -194,7 +194,7 @@ class OopMap: public ResourceObj {
// Printing
void print_on(outputStream* st) const;
void print() const { print_on(tty); }
void print() const;
bool equals(const OopMap* other) const;
};
@ -253,7 +253,7 @@ class OopMapSet : public ResourceObj {
// Printing
void print_on(outputStream* st) const;
void print() const { print_on(tty); }
void print() const;
};
class ImmutableOopMapBuilder;
@ -279,7 +279,7 @@ public:
// Printing
void print_on(outputStream* st) const;
void print() const { print_on(tty); }
void print() const;
};
class ImmutableOopMapSet;
@ -330,7 +330,7 @@ public:
int nr_of_bytes() const { return _size; }
void print_on(outputStream* st) const;
void print() const { print_on(tty); }
void print() const;
};
class OopMapStream : public StackObj {

View File

@ -136,6 +136,8 @@ void CollectedHeap::print_heap_after_gc() {
}
}
void CollectedHeap::print() const { print_on(tty); }
void CollectedHeap::print_on_error(outputStream* st) const {
st->print_cr("Heap:");
print_extended_on(st);

View File

@ -449,9 +449,8 @@ class CollectedHeap : public CHeapObj<mtInternal> {
// Print heap information on the given outputStream.
virtual void print_on(outputStream* st) const = 0;
// The default behavior is to call print_on() on tty.
virtual void print() const {
print_on(tty);
}
virtual void print() const;
// Print more detailed heap information on the given
// outputStream. The default behavior is to call print_on(). It is
// up to each subclass to override it and add any additional output

View File

@ -318,6 +318,8 @@ void AbstractGangWorker::print_on(outputStream* st) const {
st->cr();
}
void AbstractGangWorker::print() const { print_on(tty); }
WorkData GangWorker::wait_for_task() {
return gang()->dispatcher()->worker_wait_for_task();
}

View File

@ -239,7 +239,7 @@ public:
virtual bool is_ConcurrentGC_thread() const;
// Printing
void print_on(outputStream* st) const;
virtual void print() const { print_on(tty); }
virtual void print() const;
protected:
AbstractWorkGang* _gang;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -81,6 +81,8 @@ void InterpreterCodelet::print_on(outputStream* st) const {
}
}
void InterpreterCodelet::print() const { print_on(tty); }
CodeletMark::CodeletMark(InterpreterMacroAssembler*& masm,
const char* description,
Bytecodes::Code bytecode) :

View File

@ -69,7 +69,7 @@ class InterpreterCodelet: public Stub {
// Debugging
void verify();
void print_on(outputStream* st) const;
void print() const { print_on(tty); }
void print() const;
// Interpreter-specific initialization
void initialize(const char* description, Bytecodes::Code bytecode);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@ -41,6 +41,9 @@ void Metadata::print_on(outputStream* st) const {
st->cr();
}
void Metadata::print() const { print_on(tty); }
void Metadata::print_value() const { print_value_on(tty); }
char* Metadata::print_value_string() const {
char buf[256];
stringStream st(buf, sizeof(buf));

View File

@ -50,8 +50,8 @@ class Metadata : public MetaspaceObj {
virtual const char* internal_name() const = 0;
virtual void metaspace_pointers_do(MetaspaceClosure* iter) {}
void print() const { print_on(tty); }
void print_value() const { print_value_on(tty); }
void print() const;
void print_value() const;
static void print_value_on_maybe_null(outputStream* st, const Metadata* m) {
if (NULL == m)

View File

@ -366,6 +366,8 @@ void Symbol::print_on(outputStream* st) const {
st->print(" count %d", refcount());
}
void Symbol::print() const { print_on(tty); }
// The print_value functions are present in all builds, to support the
// disassembler and error reporting.
void Symbol::print_value_on(outputStream* st) const {
@ -376,6 +378,8 @@ void Symbol::print_value_on(outputStream* st) const {
st->print("'");
}
void Symbol::print_value() const { print_value_on(tty); }
bool Symbol::is_valid(Symbol* s) {
if (!is_aligned(s, sizeof(MetaWord))) return false;
if ((size_t)s < os::min_page_size()) return false;

View File

@ -248,8 +248,8 @@ class Symbol : public MetaspaceObj {
void print_value_on(outputStream* st) const; // Second level print.
// printing on default output stream
void print() { print_on(tty); }
void print_value() { print_value_on(tty); }
void print() const;
void print_value() const;
static bool is_valid(Symbol* s);

View File

@ -865,7 +865,7 @@ int* BiasedLocking::slow_path_entry_count_addr() { return _counter
// BiasedLockingCounters
int BiasedLockingCounters::slow_path_entry_count() {
int BiasedLockingCounters::slow_path_entry_count() const {
if (_slow_path_entry_count != 0) {
return _slow_path_entry_count;
}
@ -876,7 +876,7 @@ int BiasedLockingCounters::slow_path_entry_count() {
return _total_entry_count - sum;
}
void BiasedLockingCounters::print_on(outputStream* st) {
void BiasedLockingCounters::print_on(outputStream* st) const {
tty->print_cr("# total entries: %d", _total_entry_count);
tty->print_cr("# biased lock entries: %d", _biased_lock_entry_count);
tty->print_cr("# anonymously biased lock entries: %d", _anonymously_biased_lock_entry_count);
@ -885,3 +885,5 @@ void BiasedLockingCounters::print_on(outputStream* st) {
tty->print_cr("# fast path lock entries: %d", _fast_path_entry_count);
tty->print_cr("# slow path lock entries: %d", slow_path_entry_count());
}
void BiasedLockingCounters::print() const { print_on(tty); }

View File

@ -128,7 +128,7 @@ class BiasedLockingCounters {
_fast_path_entry_count(0),
_slow_path_entry_count(0) {}
int slow_path_entry_count(); // Compute this field if necessary
int slow_path_entry_count() const; // Compute this field if necessary
int* total_entry_count_addr() { return &_total_entry_count; }
int* biased_lock_entry_count_addr() { return &_biased_lock_entry_count; }
@ -140,8 +140,8 @@ class BiasedLockingCounters {
bool nonzero() { return _total_entry_count > 0; }
void print_on(outputStream* st);
void print() { print_on(tty); }
void print_on(outputStream* st) const;
void print() const;
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -145,6 +145,8 @@ void fieldDescriptor::print_on(outputStream* st) const {
}
}
void fieldDescriptor::print() const { print_on(tty); }
void fieldDescriptor::print_on_for(outputStream* st, oop obj) {
print_on(st);
BasicType ft = field_type();

View File

@ -111,7 +111,7 @@ class fieldDescriptor {
void reinitialize(InstanceKlass* ik, int index);
// Print
void print() { print_on(tty); }
void print() const;
void print_on(outputStream* st) const PRODUCT_RETURN;
void print_on_for(outputStream* st, oop obj) PRODUCT_RETURN;
void verify() const PRODUCT_RETURN;

View File

@ -310,6 +310,8 @@ void JNIHandles::print_on(outputStream* st) {
st->flush();
}
void JNIHandles::print() { print_on(tty); }
class VerifyJNIHandles: public OopClosure {
public:
virtual void do_oop(oop* root) {

View File

@ -97,7 +97,7 @@ class JNIHandles : AllStatic {
// Debugging
static void print_on(outputStream* st);
static void print() { print_on(tty); }
static void print();
static void verify();
// The category predicates all require handle != NULL.
static bool is_local_handle(Thread* thread, jobject handle);

View File

@ -1934,3 +1934,4 @@ void ObjectMonitor::print_on(outputStream* st) const {
contentions(), waiters(), recursions(),
p2i(owner()));
}
void ObjectMonitor::print() const { print_on(tty); }

View File

@ -292,7 +292,7 @@ class ObjectMonitor {
void notify(TRAPS);
void notifyAll(TRAPS);
void print() const { print_on(tty); }
void print() const;
void print_on(outputStream* st) const;
// Use the following at your own risk

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -53,3 +53,5 @@ void OSThread::print_on(outputStream *st) const {
default: st->print("unknown state %d", _state); break;
}
}
void OSThread::print() const { print_on(tty); }

View File

@ -88,7 +88,7 @@ class OSThread: public CHeapObj<mtThread> {
// Printing
void print_on(outputStream* st) const;
void print() const { print_on(tty); }
void print() const;
// For java intrinsics:
static ByteSize interrupted_offset() { return byte_offset_of(OSThread, _interrupted); }

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
@ -56,12 +56,13 @@ void RTMLockingCounters::init() {
}
//------------------------------print_on-------------------------------
void RTMLockingCounters::print_on(outputStream* st) {
void RTMLockingCounters::print_on(outputStream* st) const {
tty->print_cr("# rtm locks total (estimated): " UINTX_FORMAT, _total_count * RTMTotalCountIncrRate);
tty->print_cr("# rtm lock aborts : " UINTX_FORMAT, _abort_count);
for (int i = 0; i < ABORT_STATUS_LIMIT; i++) {
tty->print_cr("# rtm lock aborts %d: " UINTX_FORMAT, i, _abortX_count[i]);
}
}
void RTMLockingCounters::print() const { print_on(tty); }
#endif

View File

@ -106,8 +106,8 @@ class RTMLockingCounters {
bool nonzero() { return (_abort_count + _total_count) > 0; }
void print_on(outputStream* st);
void print() { print_on(tty); }
void print_on(outputStream* st) const;
void print() const;
};
#endif // SHARE_RUNTIME_RTMLOCKING_HPP

View File

@ -1037,6 +1037,8 @@ void ThreadSafepointState::print_on(outputStream *st) const {
_thread->print_thread_state_on(st);
}
void ThreadSafepointState::print() const { print_on(tty); }
// ---------------------------------------------------------------------------------------------------------------------
// Block the thread at poll or poll return for safepoint/handshake.

View File

@ -226,7 +226,7 @@ class ThreadSafepointState: public CHeapObj<mtThread> {
// debugging
void print_on(outputStream* st) const;
void print() const { print_on(tty); }
void print() const;
// Initialize
static void create(JavaThread *thread);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -63,6 +63,8 @@ void StubCodeDesc::print_on(outputStream* st) const {
st->print(" [" INTPTR_FORMAT ", " INTPTR_FORMAT "[ (%d bytes)", p2i(begin()), p2i(end()), size_in_bytes());
}
void StubCodeDesc::print() const { print_on(tty); }
// Implementation of StubCodeGenerator
StubCodeGenerator::StubCodeGenerator(CodeBuffer* code, bool print_code) {

View File

@ -88,7 +88,7 @@ class StubCodeDesc: public CHeapObj<mtCode> {
int size_in_bytes() const { return _end - _begin; }
bool contains(address pc) const { return _begin <= pc && pc < _end; }
void print_on(outputStream* st) const;
void print() const { print_on(tty); }
void print() const;
};
// The base class for all stub-generating code generators.

View File

@ -953,6 +953,8 @@ void Thread::print_on(outputStream* st, bool print_extended_info) const {
debug_only(if (WizardMode) print_owned_locks_on(st);)
}
void Thread::print() const { print_on(tty); }
// Thread::print_on_error() is called by fatal error handler. Don't use
// any lock or allocate memory.
void Thread::print_on_error(outputStream* st, char* buf, int buflen) const {
@ -3026,6 +3028,8 @@ void JavaThread::print_on(outputStream *st, bool print_extended_info) const {
}
}
void JavaThread::print() const { print_on(tty); }
void JavaThread::print_name_on_error(outputStream* st, char *buf, int buflen) const {
st->print("%s", get_thread_name_string(buf, buflen));
}

View File

@ -732,7 +732,7 @@ protected:
// Printing
void print_on(outputStream* st, bool print_extended_info) const;
virtual void print_on(outputStream* st) const { print_on(st, false); }
void print() const { print_on(tty); }
void print() const;
virtual void print_on_error(outputStream* st, char* buf, int buflen) const;
void print_value_on(outputStream* st) const;
@ -1874,6 +1874,7 @@ class JavaThread: public Thread {
char* name() const { return (char*)get_thread_name(); }
void print_on(outputStream* st, bool print_extended_info) const;
void print_on(outputStream* st) const { print_on(st, false); }
void print() const;
void print_value();
void print_thread_state_on(outputStream*) const PRODUCT_RETURN;
void print_thread_state() const PRODUCT_RETURN;