提交 5e3814f6 编写于 作者: C cfang

6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit

Summary: use PcDesc to keep record of the reexecute bit instead of using DebugInfoStreams
Reviewed-by: kvn, never, twisti
上级 092c2207
......@@ -81,4 +81,8 @@ public class DebugInfoReadStream extends CompressedReadStream {
Assert.that(false, "should not reach here");
return null;
}
public int readBCI() {
return readInt() + InvocationEntryBCI;
}
}
/*
* Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2009 Sun Microsystems, Inc. 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
......@@ -259,7 +259,7 @@ public class NMethod extends CodeBlob {
if (Assert.ASSERTS_ENABLED) {
Assert.that(pd != null, "scope must be present");
}
return new ScopeDesc(this, pd.getScopeDecodeOffset());
return new ScopeDesc(this, pd.getScopeDecodeOffset(), pd.getReexecute());
}
/** This is only for use by the debugging system, and is only
......@@ -291,7 +291,7 @@ public class NMethod extends CodeBlob {
public ScopeDesc getScopeDescNearDbg(Address pc) {
PCDesc pd = getPCDescNearDbg(pc);
if (pd == null) return null;
return new ScopeDesc(this, pd.getScopeDecodeOffset());
return new ScopeDesc(this, pd.getScopeDecodeOffset(), pd.getReexecute());
}
public Map/*<Address, PcDesc>*/ getSafepoints() {
......
/*
* Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2009 Sun Microsystems, Inc. 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
......@@ -36,6 +36,7 @@ import sun.jvm.hotspot.types.*;
public class PCDesc extends VMObject {
private static CIntegerField pcOffsetField;
private static CIntegerField scopeDecodeOffsetField;
private static CIntegerField pcFlagsField;
static {
VM.registerVMInitializedObserver(new Observer() {
......@@ -50,6 +51,7 @@ public class PCDesc extends VMObject {
pcOffsetField = type.getCIntegerField("_pc_offset");
scopeDecodeOffsetField = type.getCIntegerField("_scope_decode_offset");
pcFlagsField = type.getCIntegerField("_flags");
}
public PCDesc(Address addr) {
......@@ -70,6 +72,12 @@ public class PCDesc extends VMObject {
return code.instructionsBegin().addOffsetTo(getPCOffset());
}
public boolean getReexecute() {
int flags = (int)pcFlagsField.getValue(addr);
return ((flags & 0x1)== 1); //first is the reexecute bit
}
public void print(NMethod code) {
printOn(System.out, code);
}
......
......@@ -52,44 +52,46 @@ public class ScopeDesc {
private List objects; // ArrayList<ScopeValue>
public ScopeDesc(NMethod code, int decodeOffset) {
public ScopeDesc(NMethod code, int decodeOffset, boolean reexecute) {
this.code = code;
this.decodeOffset = decodeOffset;
this.objects = decodeObjectValues(DebugInformationRecorder.SERIALIZED_NULL);
this.reexecute = reexecute;
// Decode header
DebugInfoReadStream stream = streamAt(decodeOffset);
senderDecodeOffset = stream.readInt();
method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle());
setBCIAndReexecute(stream.readInt());
bci = stream.readBCI();
// Decode offsets for body and sender
localsDecodeOffset = stream.readInt();
expressionsDecodeOffset = stream.readInt();
monitorsDecodeOffset = stream.readInt();
}
public ScopeDesc(NMethod code, int decodeOffset, int objectDecodeOffset) {
public ScopeDesc(NMethod code, int decodeOffset, int objectDecodeOffset, boolean reexecute) {
this.code = code;
this.decodeOffset = decodeOffset;
this.objects = decodeObjectValues(objectDecodeOffset);
this.reexecute = reexecute;
// Decode header
DebugInfoReadStream stream = streamAt(decodeOffset);
senderDecodeOffset = stream.readInt();
method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle());
setBCIAndReexecute(stream.readInt());
bci = stream.readBCI();
// Decode offsets for body and sender
localsDecodeOffset = stream.readInt();
expressionsDecodeOffset = stream.readInt();
monitorsDecodeOffset = stream.readInt();
}
public NMethod getNMethod() { return code; }
public Method getMethod() { return method; }
public int getBCI() { return bci; }
public boolean getReexecute() {return reexecute;}
public NMethod getNMethod() { return code; }
public Method getMethod() { return method; }
public int getBCI() { return bci; }
public boolean getReexecute() { return reexecute;}
/** Returns a List&lt;ScopeValue&gt; */
public List getLocals() {
......@@ -117,7 +119,7 @@ public class ScopeDesc {
return null;
}
return new ScopeDesc(code, senderDecodeOffset);
return new ScopeDesc(code, senderDecodeOffset, false);
}
/** Returns where the scope was decoded */
......@@ -151,8 +153,8 @@ public class ScopeDesc {
public void printValueOn(PrintStream tty) {
tty.print("ScopeDesc for ");
method.printValueOn(tty);
tty.println(" @bci " + bci);
tty.println(" reexecute: " + reexecute);
tty.print(" @bci " + bci);
tty.println(" reexecute=" + reexecute);
}
// FIXME: add more accessors
......@@ -160,12 +162,6 @@ public class ScopeDesc {
//--------------------------------------------------------------------------------
// Internals only below this point
//
private void setBCIAndReexecute(int combination) {
int InvocationEntryBci = VM.getVM().getInvocationEntryBCI();
bci = (combination >> 1) + InvocationEntryBci;
reexecute = (combination & 1)==1 ? true : false;
}
private DebugInfoReadStream streamAt(int decodeOffset) {
return new DebugInfoReadStream(code, decodeOffset, objects);
}
......
......@@ -1229,13 +1229,10 @@ void java_lang_Throwable::fill_in_stack_trace(Handle throwable, TRAPS) {
// Compiled java method case.
if (decode_offset != 0) {
bool dummy_reexecute = false;
DebugInfoReadStream stream(nm, decode_offset);
decode_offset = stream.read_int();
method = (methodOop)nm->oop_at(stream.read_int());
//fill_in_stack_trace does not need the reexecute information which is designed
//for the deopt to reexecute
bci = stream.read_bci_and_reexecute(dummy_reexecute);
bci = stream.read_bci();
} else {
if (fr.is_first_frame()) break;
address pc = fr.pc();
......
/*
* Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. 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
......@@ -255,8 +255,7 @@ class DebugInfoReadStream : public CompressedReadStream {
ScopeValue* read_object_value();
ScopeValue* get_cached_object();
// BCI encoding is mostly unsigned, but -1 is a distinguished value
// Decoding based on encoding: bci = InvocationEntryBci + read_int()/2; reexecute = read_int()%2 == 1 ? true : false;
int read_bci_and_reexecute(bool& reexecute) { int i = read_int(); reexecute = (i & 1) ? true : false; return (i >> 1) + InvocationEntryBci; }
int read_bci() { return read_int() + InvocationEntryBci; }
};
// DebugInfoWriteStream specializes CompressedWriteStream for
......@@ -269,6 +268,5 @@ class DebugInfoWriteStream : public CompressedWriteStream {
public:
DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size);
void write_handle(jobject h);
//Encoding bci and reexecute into one word as (bci - InvocationEntryBci)*2 + reexecute
void write_bci_and_reexecute(int bci, bool reexecute) { write_int(((bci - InvocationEntryBci) << 1) + (reexecute ? 1 : 0)); }
void write_bci(int bci) { write_int(bci - InvocationEntryBci); }
};
/*
* Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1998-2009 Sun Microsystems, Inc. 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
......@@ -292,13 +292,16 @@ void DebugInformationRecorder::describe_scope(int pc_offset,
int stream_offset = stream()->position();
last_pd->set_scope_decode_offset(stream_offset);
// Record reexecute bit into pcDesc
last_pd->set_should_reexecute(reexecute);
// serialize sender stream offest
stream()->write_int(sender_stream_offset);
// serialize scope
jobject method_enc = (method == NULL)? NULL: method->encoding();
stream()->write_int(oop_recorder()->find_index(method_enc));
stream()->write_bci_and_reexecute(bci, reexecute);
stream()->write_bci(bci);
assert(method == NULL ||
(method->is_native() && bci == 0) ||
(!method->is_native() && 0 <= bci && bci < method->code_size()) ||
......
/*
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. 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
......@@ -966,7 +966,7 @@ ScopeDesc* nmethod::scope_desc_at(address pc) {
PcDesc* pd = pc_desc_at(pc);
guarantee(pd != NULL, "scope must be present");
return new ScopeDesc(this, pd->scope_decode_offset(),
pd->obj_decode_offset());
pd->obj_decode_offset(), pd->should_reexecute());
}
......@@ -1932,7 +1932,7 @@ void nmethod::verify_interrupt_point(address call_site) {
PcDesc* pd = pc_desc_at(ic->end_of_call());
assert(pd != NULL, "PcDesc must exist");
for (ScopeDesc* sd = new ScopeDesc(this, pd->scope_decode_offset(),
pd->obj_decode_offset());
pd->obj_decode_offset(), pd->should_reexecute());
!sd->is_top(); sd = sd->sender()) {
sd->verify();
}
......@@ -2181,7 +2181,7 @@ ScopeDesc* nmethod::scope_desc_in(address begin, address end) {
PcDesc* p = pc_desc_near(begin+1);
if (p != NULL && p->real_pc(this) <= end) {
return new ScopeDesc(this, p->scope_decode_offset(),
p->obj_decode_offset());
p->obj_decode_offset(), p->should_reexecute());
}
return NULL;
}
......
/*
* Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. 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
......@@ -26,9 +26,11 @@
# include "incls/_pcDesc.cpp.incl"
PcDesc::PcDesc(int pc_offset, int scope_decode_offset, int obj_decode_offset) {
assert(sizeof(PcDescFlags) <= 4, "occupies more than a word");
_pc_offset = pc_offset;
_scope_decode_offset = scope_decode_offset;
_obj_decode_offset = obj_decode_offset;
_flags.word = 0;
}
address PcDesc::real_pc(const nmethod* code) const {
......@@ -50,6 +52,7 @@ void PcDesc::print(nmethod* code) {
tty->print(" ");
sd->method()->print_short_name(tty);
tty->print(" @%d", sd->bci());
tty->print(" reexecute=%s", sd->should_reexecute()?"true":"false");
tty->cr();
}
#endif
......
/*
* Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. 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
......@@ -34,6 +34,13 @@ class PcDesc VALUE_OBJ_CLASS_SPEC {
int _scope_decode_offset; // offset for scope in nmethod
int _obj_decode_offset;
union PcDescFlags {
int word;
struct {
unsigned int reexecute: 1;
} bits;
} _flags;
public:
int pc_offset() const { return _pc_offset; }
int scope_decode_offset() const { return _scope_decode_offset; }
......@@ -53,6 +60,10 @@ class PcDesc VALUE_OBJ_CLASS_SPEC {
upper_offset_limit = (unsigned int)-1 >> 1
};
// Flags
bool should_reexecute() const { return _flags.bits.reexecute; }
void set_should_reexecute(bool z) { _flags.bits.reexecute = z; }
// Returns the real pc
address real_pc(const nmethod* code) const;
......
/*
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. 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
......@@ -26,17 +26,19 @@
# include "incls/_scopeDesc.cpp.incl"
ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset) {
ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset, bool reexecute) {
_code = code;
_decode_offset = decode_offset;
_objects = decode_object_values(obj_decode_offset);
_reexecute = reexecute;
decode_body();
}
ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset) {
ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, bool reexecute) {
_code = code;
_decode_offset = decode_offset;
_objects = decode_object_values(DebugInformationRecorder::serialized_null);
_reexecute = reexecute;
decode_body();
}
......@@ -45,8 +47,8 @@ ScopeDesc::ScopeDesc(const ScopeDesc* parent) {
_code = parent->_code;
_decode_offset = parent->_sender_decode_offset;
_objects = parent->_objects;
_reexecute = false; //reexecute only applies to the first scope
decode_body();
assert(_reexecute == false, "reexecute not allowed");
}
......@@ -57,7 +59,6 @@ void ScopeDesc::decode_body() {
_sender_decode_offset = DebugInformationRecorder::serialized_null;
_method = methodHandle(_code->method());
_bci = InvocationEntryBci;
_reexecute = false;
_locals_decode_offset = DebugInformationRecorder::serialized_null;
_expressions_decode_offset = DebugInformationRecorder::serialized_null;
_monitors_decode_offset = DebugInformationRecorder::serialized_null;
......@@ -67,7 +68,7 @@ void ScopeDesc::decode_body() {
_sender_decode_offset = stream->read_int();
_method = methodHandle((methodOop) stream->read_oop());
_bci = stream->read_bci_and_reexecute(_reexecute);
_bci = stream->read_bci();
// decode offsets for body and sender
_locals_decode_offset = stream->read_int();
......
/*
* Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. 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
......@@ -39,8 +39,7 @@ class SimpleScopeDesc : public StackObj {
DebugInfoReadStream buffer(code, pc_desc->scope_decode_offset());
int ignore_sender = buffer.read_int();
_method = methodOop(buffer.read_oop());
bool dummy_reexecute; //only methodOop and bci are needed!
_bci = buffer.read_bci_and_reexecute(dummy_reexecute);
_bci = buffer.read_bci();
}
methodOop method() { return _method; }
......@@ -53,12 +52,12 @@ class SimpleScopeDesc : public StackObj {
class ScopeDesc : public ResourceObj {
public:
// Constructor
ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset);
ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset, bool reexecute);
// Calls above, giving default value of "serialized_null" to the
// "obj_decode_offset" argument. (We don't use a default argument to
// avoid a .hpp-.hpp dependency.)
ScopeDesc(const nmethod* code, int decode_offset);
ScopeDesc(const nmethod* code, int decode_offset, bool reexecute);
// JVM state
methodHandle method() const { return _method; }
......
......@@ -493,7 +493,8 @@ void JVMState::dump_spec(outputStream *st) const {
if (!printed)
_method->print_short_name(st);
st->print(" @ bci:%d",_bci);
st->print(" reexecute:%s", _reexecute==Reexecute_True?"true":"false");
if(_reexecute == Reexecute_True)
st->print(" reexecute");
} else {
st->print(" runtime stub");
}
......
/*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-2009 Sun Microsystems, Inc. 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
......@@ -402,7 +402,7 @@ void JvmtiCodeBlobEvents::build_jvmti_addr_location_map(nmethod *nm,
address scopes_data = nm->scopes_data_begin();
for( pcd = nm->scopes_pcs_begin(); pcd < nm->scopes_pcs_end(); ++pcd ) {
ScopeDesc sc0(nm, pcd->scope_decode_offset());
ScopeDesc sc0(nm, pcd->scope_decode_offset(), pcd->should_reexecute());
ScopeDesc *sd = &sc0;
while( !sd->is_top() ) { sd = sd->sender(); }
int bci = sd->bci();
......
......@@ -402,12 +402,7 @@ inline void vframeStreamCommon::fill_from_compiled_frame(int decode_offset) {
DebugInfoReadStream buffer(nm(), decode_offset);
_sender_decode_offset = buffer.read_int();
_method = methodOop(buffer.read_oop());
// Deoptimization needs reexecute bit to determine whether to reexecute the bytecode
// only at the time when it "unpack_frames", and the reexecute bit info could always
// be obtained from the scopeDesc in the compiledVFrame. As a result, we don't keep
// the reexecute bit here.
bool dummy_reexecute;
_bci = buffer.read_bci_and_reexecute(dummy_reexecute);
_bci = buffer.read_bci();
assert(_method->is_method(), "checking type of decoded method");
}
......
......@@ -593,6 +593,7 @@ static inline uint64_t cast_uint64_t(size_t x)
\
nonstatic_field(PcDesc, _pc_offset, int) \
nonstatic_field(PcDesc, _scope_decode_offset, int) \
nonstatic_field(PcDesc, _flags, PcDesc::PcDescFlags) \
\
/***************************************************/ \
/* CodeBlobs (NOTE: incomplete, but only a little) */ \
......@@ -1158,6 +1159,7 @@ static inline uint64_t cast_uint64_t(size_t x)
/***************************************/ \
\
declare_toplevel_type(PcDesc) \
declare_integer_type(PcDesc::PcDescFlags) \
\
/************************/ \
/* OopMap and OopMapSet */ \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册