8208399: Metadata methods print_(value_)on_maybe_null() compare 'this' to NULL

Add Method* parameter and make method static to avoid 'this' comparison with NULL

Reviewed-by: lfoltan, gziemski, coleenp
This commit is contained in:
Harold Seigel 2018-07-31 09:55:09 -04:00
parent c9d506055c
commit 7d04a31fc8
3 changed files with 10 additions and 17 deletions

View file

@ -2346,7 +2346,7 @@ void nmethod::print_recorded_metadata() {
if (m == (Metadata*)Universe::non_oop_word()) { if (m == (Metadata*)Universe::non_oop_word()) {
tty->print("non-metadata word"); tty->print("non-metadata word");
} else { } else {
m->print_value_on_maybe_null(tty); Metadata::print_value_on_maybe_null(tty, m);
} }
tty->cr(); tty->cr();
} }

View file

@ -3072,7 +3072,7 @@ void InstanceKlass::print_on(outputStream* st) const {
st->print(BULLET"access: "); access_flags().print_on(st); st->cr(); st->print(BULLET"access: "); access_flags().print_on(st); st->cr();
st->print(BULLET"state: "); st->print_cr("%s", state_names[_init_state]); st->print(BULLET"state: "); st->print_cr("%s", state_names[_init_state]);
st->print(BULLET"name: "); name()->print_value_on(st); st->cr(); st->print(BULLET"name: "); name()->print_value_on(st); st->cr();
st->print(BULLET"super: "); super()->print_value_on_maybe_null(st); st->cr(); st->print(BULLET"super: "); Metadata::print_value_on_maybe_null(st, super()); st->cr();
st->print(BULLET"sub: "); st->print(BULLET"sub: ");
Klass* sub = subklass(); Klass* sub = subklass();
int n; int n;
@ -3095,7 +3095,7 @@ void InstanceKlass::print_on(outputStream* st) const {
} }
} }
st->print(BULLET"arrays: "); array_klasses()->print_value_on_maybe_null(st); st->cr(); st->print(BULLET"arrays: "); Metadata::print_value_on_maybe_null(st, array_klasses()); st->cr();
st->print(BULLET"methods: "); methods()->print_value_on(st); st->cr(); st->print(BULLET"methods: "); methods()->print_value_on(st); st->cr();
if (Verbose || WizardMode) { if (Verbose || WizardMode) {
Array<Method*>* method_array = methods(); Array<Method*>* method_array = methods();
@ -3122,7 +3122,7 @@ void InstanceKlass::print_on(outputStream* st) const {
class_loader_data()->print_value_on(st); class_loader_data()->print_value_on(st);
st->cr(); st->cr();
} }
st->print(BULLET"host class: "); host_klass()->print_value_on_maybe_null(st); st->cr(); st->print(BULLET"host class: "); Metadata::print_value_on_maybe_null(st, host_klass()); st->cr();
if (source_file_name() != NULL) { if (source_file_name() != NULL) {
st->print(BULLET"source file: "); st->print(BULLET"source file: ");
source_file_name()->print_value_on(st); source_file_name()->print_value_on(st);
@ -3229,11 +3229,11 @@ void InstanceKlass::oop_print_on(oop obj, outputStream* st) {
st->cr(); st->cr();
Klass* mirrored_klass = java_lang_Class::as_Klass(obj); Klass* mirrored_klass = java_lang_Class::as_Klass(obj);
st->print(BULLET"fake entry for mirror: "); st->print(BULLET"fake entry for mirror: ");
mirrored_klass->print_value_on_maybe_null(st); Metadata::print_value_on_maybe_null(st, mirrored_klass);
st->cr(); st->cr();
Klass* array_klass = java_lang_Class::array_klass_acquire(obj); Klass* array_klass = java_lang_Class::array_klass_acquire(obj);
st->print(BULLET"fake entry for array: "); st->print(BULLET"fake entry for array: ");
array_klass->print_value_on_maybe_null(st); Metadata::print_value_on_maybe_null(st, array_klass);
st->cr(); st->cr();
st->print_cr(BULLET"fake entry for oop_size: %d", java_lang_Class::oop_size(obj)); st->print_cr(BULLET"fake entry for oop_size: %d", java_lang_Class::oop_size(obj));
st->print_cr(BULLET"fake entry for static_oop_field_count: %d", java_lang_Class::static_oop_field_count(obj)); st->print_cr(BULLET"fake entry for static_oop_field_count: %d", java_lang_Class::static_oop_field_count(obj));

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -56,18 +56,11 @@ class Metadata : public MetaspaceObj {
void print() const { print_on(tty); } void print() const { print_on(tty); }
void print_value() const { print_value_on(tty); } void print_value() const { print_value_on(tty); }
void print_maybe_null() const { print_on_maybe_null(tty); } static void print_value_on_maybe_null(outputStream* st, const Metadata* m) {
void print_on_maybe_null(outputStream* st) const { if (NULL == m)
if (this == NULL)
st->print("NULL"); st->print("NULL");
else else
print_on(st); m->print_value_on(st);
}
void print_value_on_maybe_null(outputStream* st) const {
if (this == NULL)
st->print("NULL");
else
print_value_on(st);
} }
virtual void print_on(outputStream* st) const; // First level print virtual void print_on(outputStream* st) const; // First level print