Skip to content

Commit c277f9e

Browse files
author
Harold Seigel
committed
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
1 parent d86f3a8 commit c277f9e

9 files changed

Lines changed: 22 additions & 22 deletions

File tree

src/hotspot/cpu/aarch64/frame_aarch64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -539,7 +539,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
539539
Method* m = *interpreter_frame_method_addr();
540540

541541
// validate the method we'd find in this potential sender
542-
if (!m->is_valid_method()) return false;
542+
if (!Method::is_valid_method(m)) return false;
543543

544544
// stack frames shouldn't be much larger than max_stack elements
545545
// this test requires the use of unextended_sp which is the sp as seen by

src/hotspot/cpu/arm/frame_arm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* 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 {
500500
Method* m = *interpreter_frame_method_addr();
501501

502502
// validate the method we'd find in this potential sender
503-
if (!m->is_valid_method()) return false;
503+
if (!Method::is_valid_method(m)) return false;
504504

505505
// stack frames shouldn't be much larger than max_stack elements
506506

src/hotspot/cpu/sparc/frame_sparc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* 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 {
648648
Method* m = *interpreter_frame_method_addr();
649649

650650
// validate the method we'd find in this potential sender
651-
if (!m->is_valid_method()) return false;
651+
if (!Method::is_valid_method(m)) return false;
652652

653653
// stack frames shouldn't be much larger than max_stack elements
654654

src/hotspot/cpu/x86/frame_x86.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* 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 {
526526
Method* m = *interpreter_frame_method_addr();
527527

528528
// validate the method we'd find in this potential sender
529-
if (!m->is_valid_method()) return false;
529+
if (!Method::is_valid_method(m)) return false;
530530

531531
// stack frames shouldn't be much larger than max_stack elements
532532
// this test requires the use the unextended_sp which is the sp as seen by

src/hotspot/share/jfr/periodic/sampling/jfrCallTrace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ bool JfrGetCallTrace::find_top_frame(frame& top_frame, Method** method, frame& f
5050
const bool known_valid = (state == _thread_in_native || state == _thread_in_vm || state == _thread_blocked);
5151
if (known_valid || candidate.is_interpreted_frame_valid(_thread)) {
5252
Method* im = candidate.interpreter_frame_method();
53-
if (known_valid && !im->is_valid_method()) {
53+
if (known_valid && !Method::is_valid_method(im)) {
5454
return false;
5555
}
5656
*method = im;

src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ bool JfrStackTrace::record_thread(JavaThread& thread, frame& frame) {
431431
break;
432432
}
433433
const Method* method = st.method();
434-
if (!method->is_valid_method()) {
434+
if (!Method::is_valid_method(method)) {
435435
// we throw away everything we've gathered in this sample since
436436
// none of it is safe
437437
return false;

src/hotspot/share/oops/method.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ address Method::make_adapters(const methodHandle& mh, TRAPS) {
10951095
}
10961096

10971097
void Method::restore_unshareable_info(TRAPS) {
1098-
assert(is_method() && is_valid_method(), "ensure C++ vtable is restored");
1098+
assert(is_method() && is_valid_method(this), "ensure C++ vtable is restored");
10991099

11001100
// Since restore_unshareable_info can be called more than once for a method, don't
11011101
// redo any work.
@@ -2166,16 +2166,16 @@ bool Method::has_method_vptr(const void* ptr) {
21662166
}
21672167

21682168
// Check that this pointer is valid by checking that the vtbl pointer matches
2169-
bool Method::is_valid_method() const {
2170-
if (this == NULL) {
2169+
bool Method::is_valid_method(const Method* m) {
2170+
if (m == NULL) {
21712171
return false;
2172-
} else if ((intptr_t(this) & (wordSize-1)) != 0) {
2172+
} else if ((intptr_t(m) & (wordSize-1)) != 0) {
21732173
// Quick sanity check on pointer.
21742174
return false;
2175-
} else if (is_shared()) {
2176-
return MetaspaceShared::is_valid_shared_method(this);
2177-
} else if (Metaspace::contains_non_shared(this)) {
2178-
return has_method_vptr((const void*)this);
2175+
} else if (m->is_shared()) {
2176+
return MetaspaceShared::is_valid_shared_method(m);
2177+
} else if (Metaspace::contains_non_shared(m)) {
2178+
return has_method_vptr((const void*)m);
21792179
} else {
21802180
return false;
21812181
}

src/hotspot/share/oops/method.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ class Method : public Metadata {
984984

985985
// Check for valid method pointer
986986
static bool has_method_vptr(const void* ptr);
987-
bool is_valid_method() const;
987+
static bool is_valid_method(const Method* m);
988988

989989
// Verify
990990
void verify() { verify_on(tty); }

src/hotspot/share/prims/forte.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ static bool is_decipherable_interpreted_frame(JavaThread* thread,
248248
// a valid method. Then again we may have caught an interpreter
249249
// frame in the middle of construction and the bci field is
250250
// not yet valid.
251-
if (!method->is_valid_method()) return false;
251+
if (!Method::is_valid_method(method)) return false;
252252
*method_p = method; // If the Method* found is invalid, it is
253253
// ignored by forte_fill_call_trace_given_top().
254254
// So set method_p only if the Method is valid.
@@ -434,7 +434,7 @@ static void forte_fill_call_trace_given_top(JavaThread* thd,
434434
// Check if a Java Method has been found.
435435
if (method == NULL) return;
436436

437-
if (!method->is_valid_method()) {
437+
if (!Method::is_valid_method(method)) {
438438
trace->num_frames = ticks_GC_active; // -2
439439
return;
440440
}
@@ -445,7 +445,7 @@ static void forte_fill_call_trace_given_top(JavaThread* thd,
445445
bci = st.bci();
446446
method = st.method();
447447

448-
if (!method->is_valid_method()) {
448+
if (!Method::is_valid_method(method)) {
449449
// we throw away everything we've gathered in this sample since
450450
// none of it is safe
451451
trace->num_frames = ticks_GC_active; // -2

0 commit comments

Comments
 (0)