Skip to content
Permalink
Browse files
-
  • Loading branch information
pron committed Mar 29, 2021
1 parent e6a6022 commit 34f8386fe599f18f9c1868af7d42cebc88e84018
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 21 deletions.
@@ -1154,6 +1154,8 @@ class jdk_internal_misc_StackChunk: AllStatic {
static inline oop cont(oop ref);
static inline void set_cont(oop ref, oop value);
template<typename P>
static inline oop cont_raw(oop ref);
template<typename P>
static inline void set_cont_raw(oop ref, oop value);
};

@@ -249,6 +249,12 @@ inline oop jdk_internal_misc_StackChunk::cont(oop ref) {
inline void jdk_internal_misc_StackChunk::set_cont(oop ref, oop value) {
ref->obj_field_put(_cont_offset, value);
}

template<typename P>
inline oop jdk_internal_misc_StackChunk::cont_raw(oop ref) {
return (oop)RawAccess<>::oop_load((P*)ref->field_addr(_cont_offset));
}

template<typename P>
inline void jdk_internal_misc_StackChunk::set_cont_raw(oop ref, oop value) {
RawAccess<IS_DEST_UNINITIALIZED>::oop_store((P*)ref->field_addr(_cont_offset), value);
@@ -24,6 +24,7 @@

#include "oops/instanceStackChunkKlass.hpp"
#include "memory/resourceArea.hpp"
#include "oops/oopsHierarchy.hpp"
#include "precompiled.hpp"
#include "code/scopeDesc.hpp"
#include "classfile/javaClasses.inline.hpp"
@@ -39,6 +40,7 @@
#include "oops/oop.inline.hpp"
#include "oops/symbol.hpp"
#include "runtime/continuation.hpp"
#include "runtime/globals.hpp"
#include "utilities/macros.hpp"

int InstanceStackChunkKlass::_offset_of_stack = 0;
@@ -407,6 +409,10 @@ static inline oop safe_load(P *addr) {
return obj;
}

// Returns true iff the address p is readable and *(intptr_t*)p != errvalue
extern "C" bool dbg_is_safe(void* p, intptr_t errvalue);
static bool is_good_oop(oop o) { return dbg_is_safe(o, -1) && dbg_is_safe(o->klass(), -1) && oopDesc::is_oop(o) && o->klass()->is_klass(); }

class StackChunkVerifyOopsClosure : public OopClosure {
intptr_t* _sp;
int _count;
@@ -421,7 +427,7 @@ class StackChunkVerifyOopsClosure : public OopClosure {
_count++;
oop obj = safe_load(p);
if (!SafepointSynchronize::is_at_safepoint()) {
assert (oopDesc::is_oop_or_null(obj), "p: " INTPTR_FORMAT " obj: " INTPTR_FORMAT, p2i(p), p2i((oopDesc*)obj));
assert (obj == nullptr || is_good_oop(obj), "p: " INTPTR_FORMAT " obj: " INTPTR_FORMAT, p2i(p), p2i((oopDesc*)obj));
}
}
};
@@ -431,6 +437,7 @@ class StackChunkVerifyDerivedPointersClosure : public DerivedOopClosure {
virtual void do_derived_oop(oop *base_loc, oop *derived_loc) override {
log_develop_trace(jvmcont)("debug_verify_stack_chunk base: " INTPTR_FORMAT " derived: " INTPTR_FORMAT, p2i(base_loc), p2i(derived_loc));
oop base = *(oop*)base_loc; // (oop)NativeAccess<>::oop_load((oop*)base_loc); //
assert (base == nullptr || is_good_oop(base), "p: " INTPTR_FORMAT " obj: " INTPTR_FORMAT, p2i(base_loc), p2i((oopDesc*)base));
if (base != (oop)nullptr) {
assert (!CompressedOops::is_base(base), "");
assert (oopDesc::is_oop(base), "");
@@ -522,7 +529,6 @@ bool InstanceStackChunkKlass::verify(oop obj, size_t* out_size, int* out_oops, i
assert (obj->is_stackChunk(), "");
stackChunkOop chunk = (stackChunkOop)obj;

oop cont = chunk->cont();
log_develop_trace(jvmcont)("debug_verify_stack_chunk barriers: %d", chunk->requires_barriers());
// chunk->print_on(true, tty);

@@ -575,15 +581,6 @@ bool InstanceStackChunkKlass::verify(oop obj, size_t* out_size, int* out_oops, i
}
assert (closure._num_interpreted_frames == 0 || chunk->has_mixed_frames(), "");

if (cont == (oop)nullptr || is_last) {
if (cont != (oop)nullptr) {
assert (chunk->argsize() == 0, "");
} else {
// closure._size += chunk->argsize();
closure._sp += closure._cb != nullptr ? ((closure._cb->as_compiled_method()->method()->num_stack_arg_slots() * VMRegImpl::stack_slot_size) >> LogBytesPerWord) : 0;
}
}

if (!concurrent) {
assert (closure._size <= size + chunk->argsize() + metadata_words(), "size: %d argsize: %d closure.size: %d end sp: %ld start sp: %d chunk size: %d", size, chunk->argsize(), closure._size, closure._sp - chunk->start_address(), chunk->sp(), chunk->stack_size());
assert (chunk->argsize() == (closure._callee_interpreted ? 0 : closure._argsize), "chunk->argsize(): %d closure.argsize: %d closure.callee_interpreted: %d", chunk->argsize(), closure._argsize, closure._callee_interpreted);
@@ -39,6 +39,7 @@
#include "oops/oop.inline.hpp"
#include "oops/stackChunkOop.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/globals.hpp"
#include "runtime/handles.inline.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
@@ -926,6 +927,7 @@ class OopOopIterateStackClosure {

if (f.is_compiled()) f.handle_deopted(); // because of deopt in thaw; TODO: remove when changing deoptimization

// For unload method debugging
// tty->print_cr(">>>> OopOopIterateStackClosure::do_frame is_compiled: %d return_barrier: %d pc: %p", f.is_compiled(), Continuation::is_return_barrier_entry(f.pc()), f.pc()); f.print_on(tty);
// if (f.is_compiled()) tty->print_cr(">>>> OopOopIterateStackClosure::do_frame nmethod: %p method: %p", f.cb()->as_nmethod(), f.cb()->as_compiled_method()->method());

@@ -1464,11 +1464,6 @@ class Freeze {
}

NOINLINE freeze_result recurse_freeze_interpreted_frame(frame& f, frame& caller, int callee_argsize, bool callee_interpreted) {
// ResourceMark rm;
// InterpreterOopMap mask;
// f.interpreted_frame_oop_map(&mask);
// int oops = Interpreted::num_oops(f, &mask);

{ // TODO PD
assert ((f.at<false>(frame::interpreter_frame_last_sp_offset) != 0) || (f.unextended_sp() == f.sp()), "");
intptr_t* real_unextended_sp = (intptr_t*)f.at<false>(frame::interpreter_frame_last_sp_offset);
@@ -2174,8 +2169,9 @@ inline bool can_thaw_fast() {
assert (chunk != nullptr && !chunk->is_empty(), ""); // guaranteed by prepare_thaw

if (UNLIKELY(should_fix(chunk))) {
log_develop_debug(jvmcont)("prepare_chunk fixing chunk");
InstanceStackChunkKlass::fix_chunk(chunk);
}
} else log_develop_debug(jvmcont)("prepare_chunk not fixing chunk");

assert (verify_stack_chunk<1>(chunk), "");
return chunk;
@@ -2416,7 +2412,7 @@ inline bool can_thaw_fast() {
OopT* loc = obj->obj_field_addr<OopT>(offset);
intptr_t before = *(intptr_t*)loc;
intptr_t after = cast_from_oop<intptr_t>(HeapAccess<>::oop_load(loc));
// tty->print_cr("!oop_fixed %d", before != after);
// tty->print_cr("!oop_fixed %d: " INTPTR_FORMAT " -> " INTPTR_FORMAT, before != after, before, after);
return before == after;
}

@@ -2858,7 +2854,7 @@ bool do_verify_after_thaw(JavaThread* thread, int mode, bool barriers, stackChun
StackFrameStream fst(thread, true, false);
fst.register_map()->set_include_argument_oops(false);
ContinuationHelper::update_register_map_with_callee(fst.register_map(), *fst.current());
for (; !fst.is_done(); fst.next()) {
for (; !fst.is_done() && !Continuation::is_continuation_enterSpecial(*fst.current()); fst.next()) {
if (fst.current()->cb()->is_compiled() && fst.current()->cb()->as_compiled_method()->is_marked_for_deoptimization()) {
tty->print_cr(">>> do_verify_after_thaw deopt");
fst.current()->deoptimize(nullptr);
@@ -2869,7 +2865,7 @@ bool do_verify_after_thaw(JavaThread* thread, int mode, bool barriers, stackChun
if (cl.p() != nullptr) {

frame fr = *fst.current();
tty->print_cr("Failed for frame %d, pc: %p, sp: %p, fp: %p; mode: %d barriers: %d", i, fr.pc(), fr.unextended_sp(), fr.fp(), mode, barriers);
tty->print_cr("Failed for frame %d, pc: %p, sp: %p, fp: %p; mode: %d barriers: %d %d", i, fr.pc(), fr.unextended_sp(), fr.fp(), mode, barriers, chunk->requires_barriers());
if (!fr.is_interpreted_frame()) {
tty->print_cr("size: %d argsize: %d", NonInterpretedUnknown::size(fr), NonInterpretedUnknown::stack_argsize(fr));
}
@@ -1290,14 +1290,17 @@ void frame::interpreter_frame_verify_monitor(BasicObjectLock* value) const {

#ifndef PRODUCT

// Returns true iff the address p is readable and *(intptr_t*)p != errvalue
extern "C" bool dbg_is_safe(void* p, intptr_t errvalue);

class FrameValuesOopClosure: public OopClosure, public DerivedOopClosure {
private:
FrameValues& _values;
int _frame_no;
public:
FrameValuesOopClosure(FrameValues& values, int frame_no) : _values(values), _frame_no(frame_no) {}
virtual void do_oop(oop* p) {
bool good = Universe::heap()->is_in_or_null(*p) && oopDesc::is_oop_or_null(*p);
bool good = *p == nullptr || (dbg_is_safe(*p, -1) && dbg_is_safe((*p)->klass(), -1) && Universe::heap()->is_in_or_null(*p) && oopDesc::is_oop_or_null(*p));
_values.describe(_frame_no, (intptr_t*)p, err_msg("oop%s for #%d", good ? "" : " (BAD)", _frame_no));
}
virtual void do_oop(narrowOop* p) { _values.describe(_frame_no, (intptr_t*)p, err_msg("narrow oop for #%d", _frame_no)); }

0 comments on commit 34f8386

Please sign in to comment.