8207779: Method::is_valid_method() compares 'this' with NULL
Add Method* parameter and make method static to avoid 'thi's comparison with NULL Reviewed-by: lfoltan, coleenp
This commit is contained in:
parent
d86f3a8cb2
commit
c277f9ed8e
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
@ -539,7 +539,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
|
||||
Method* m = *interpreter_frame_method_addr();
|
||||
|
||||
// validate the method we'd find in this potential sender
|
||||
if (!m->is_valid_method()) return false;
|
||||
if (!Method::is_valid_method(m)) return false;
|
||||
|
||||
// stack frames shouldn't be much larger than max_stack elements
|
||||
// this test requires the use of unextended_sp which is the sp as seen by
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2018, 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
|
||||
@ -500,7 +500,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
|
||||
Method* m = *interpreter_frame_method_addr();
|
||||
|
||||
// validate the method we'd find in this potential sender
|
||||
if (!m->is_valid_method()) return false;
|
||||
if (!Method::is_valid_method(m)) return false;
|
||||
|
||||
// stack frames shouldn't be much larger than max_stack elements
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2018, 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
|
||||
@ -648,7 +648,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
|
||||
Method* m = *interpreter_frame_method_addr();
|
||||
|
||||
// validate the method we'd find in this potential sender
|
||||
if (!m->is_valid_method()) return false;
|
||||
if (!Method::is_valid_method(m)) return false;
|
||||
|
||||
// stack frames shouldn't be much larger than max_stack elements
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2018, 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
|
||||
@ -526,7 +526,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
|
||||
Method* m = *interpreter_frame_method_addr();
|
||||
|
||||
// validate the method we'd find in this potential sender
|
||||
if (!m->is_valid_method()) return false;
|
||||
if (!Method::is_valid_method(m)) return false;
|
||||
|
||||
// stack frames shouldn't be much larger than max_stack elements
|
||||
// this test requires the use the unextended_sp which is the sp as seen by
|
||||
|
@ -50,7 +50,7 @@ bool JfrGetCallTrace::find_top_frame(frame& top_frame, Method** method, frame& f
|
||||
const bool known_valid = (state == _thread_in_native || state == _thread_in_vm || state == _thread_blocked);
|
||||
if (known_valid || candidate.is_interpreted_frame_valid(_thread)) {
|
||||
Method* im = candidate.interpreter_frame_method();
|
||||
if (known_valid && !im->is_valid_method()) {
|
||||
if (known_valid && !Method::is_valid_method(im)) {
|
||||
return false;
|
||||
}
|
||||
*method = im;
|
||||
|
@ -431,7 +431,7 @@ bool JfrStackTrace::record_thread(JavaThread& thread, frame& frame) {
|
||||
break;
|
||||
}
|
||||
const Method* method = st.method();
|
||||
if (!method->is_valid_method()) {
|
||||
if (!Method::is_valid_method(method)) {
|
||||
// we throw away everything we've gathered in this sample since
|
||||
// none of it is safe
|
||||
return false;
|
||||
|
@ -1095,7 +1095,7 @@ address Method::make_adapters(const methodHandle& mh, TRAPS) {
|
||||
}
|
||||
|
||||
void Method::restore_unshareable_info(TRAPS) {
|
||||
assert(is_method() && is_valid_method(), "ensure C++ vtable is restored");
|
||||
assert(is_method() && is_valid_method(this), "ensure C++ vtable is restored");
|
||||
|
||||
// Since restore_unshareable_info can be called more than once for a method, don't
|
||||
// redo any work.
|
||||
@ -2166,16 +2166,16 @@ bool Method::has_method_vptr(const void* ptr) {
|
||||
}
|
||||
|
||||
// Check that this pointer is valid by checking that the vtbl pointer matches
|
||||
bool Method::is_valid_method() const {
|
||||
if (this == NULL) {
|
||||
bool Method::is_valid_method(const Method* m) {
|
||||
if (m == NULL) {
|
||||
return false;
|
||||
} else if ((intptr_t(this) & (wordSize-1)) != 0) {
|
||||
} else if ((intptr_t(m) & (wordSize-1)) != 0) {
|
||||
// Quick sanity check on pointer.
|
||||
return false;
|
||||
} else if (is_shared()) {
|
||||
return MetaspaceShared::is_valid_shared_method(this);
|
||||
} else if (Metaspace::contains_non_shared(this)) {
|
||||
return has_method_vptr((const void*)this);
|
||||
} else if (m->is_shared()) {
|
||||
return MetaspaceShared::is_valid_shared_method(m);
|
||||
} else if (Metaspace::contains_non_shared(m)) {
|
||||
return has_method_vptr((const void*)m);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -984,7 +984,7 @@ class Method : public Metadata {
|
||||
|
||||
// Check for valid method pointer
|
||||
static bool has_method_vptr(const void* ptr);
|
||||
bool is_valid_method() const;
|
||||
static bool is_valid_method(const Method* m);
|
||||
|
||||
// Verify
|
||||
void verify() { verify_on(tty); }
|
||||
|
@ -248,7 +248,7 @@ static bool is_decipherable_interpreted_frame(JavaThread* thread,
|
||||
// a valid method. Then again we may have caught an interpreter
|
||||
// frame in the middle of construction and the bci field is
|
||||
// not yet valid.
|
||||
if (!method->is_valid_method()) return false;
|
||||
if (!Method::is_valid_method(method)) return false;
|
||||
*method_p = method; // If the Method* found is invalid, it is
|
||||
// ignored by forte_fill_call_trace_given_top().
|
||||
// So set method_p only if the Method is valid.
|
||||
@ -434,7 +434,7 @@ static void forte_fill_call_trace_given_top(JavaThread* thd,
|
||||
// Check if a Java Method has been found.
|
||||
if (method == NULL) return;
|
||||
|
||||
if (!method->is_valid_method()) {
|
||||
if (!Method::is_valid_method(method)) {
|
||||
trace->num_frames = ticks_GC_active; // -2
|
||||
return;
|
||||
}
|
||||
@ -445,7 +445,7 @@ static void forte_fill_call_trace_given_top(JavaThread* thd,
|
||||
bci = st.bci();
|
||||
method = st.method();
|
||||
|
||||
if (!method->is_valid_method()) {
|
||||
if (!Method::is_valid_method(method)) {
|
||||
// we throw away everything we've gathered in this sample since
|
||||
// none of it is safe
|
||||
trace->num_frames = ticks_GC_active; // -2
|
||||
|
Loading…
Reference in New Issue
Block a user