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
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/DebugInfoReadStream.java Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/DebugInfoReadStream.java Thu Aug 20 12:42:57 2009 -0700
@@ -81,4 +81,8 @@
Assert.that(false, "should not reach here");
return null;
}
+
+ public int readBCI() {
+ return readInt() + InvocationEntryBCI;
+ }
}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java Thu Aug 20 12:42:57 2009 -0700
@@ -1,5 +1,5 @@
/*
- * 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 @@
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 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() {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/PCDesc.java Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/PCDesc.java Thu Aug 20 12:42:57 2009 -0700
@@ -1,5 +1,5 @@
/*
- * 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 @@
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 @@
pcOffsetField = type.getCIntegerField("_pc_offset");
scopeDecodeOffsetField = type.getCIntegerField("_scope_decode_offset");
+ pcFlagsField = type.getCIntegerField("_flags");
}
public PCDesc(Address addr) {
@@ -70,6 +72,12 @@
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);
}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java Thu Aug 20 12:42:57 2009 -0700
@@ -52,44 +52,46 @@
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<ScopeValue> */
public List getLocals() {
@@ -117,7 +119,7 @@
return null;
}
- return new ScopeDesc(code, senderDecodeOffset);
+ return new ScopeDesc(code, senderDecodeOffset, false);
}
/** Returns where the scope was decoded */
@@ -151,8 +153,8 @@
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 @@
//--------------------------------------------------------------------------------
// 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);
}
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp Thu Aug 20 12:42:57 2009 -0700
@@ -1229,13 +1229,10 @@
// 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();
--- a/hotspot/src/share/vm/code/debugInfo.hpp Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/src/share/vm/code/debugInfo.hpp Thu Aug 20 12:42:57 2009 -0700
@@ -1,5 +1,5 @@
/*
- * 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 @@
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 @@
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); }
};
--- a/hotspot/src/share/vm/code/debugInfoRec.cpp Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/src/share/vm/code/debugInfoRec.cpp Thu Aug 20 12:42:57 2009 -0700
@@ -1,5 +1,5 @@
/*
- * 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 @@
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()) ||
--- a/hotspot/src/share/vm/code/nmethod.cpp Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/src/share/vm/code/nmethod.cpp Thu Aug 20 12:42:57 2009 -0700
@@ -1,5 +1,5 @@
/*
- * 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 @@
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 @@
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 @@
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;
}
--- a/hotspot/src/share/vm/code/pcDesc.cpp Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/src/share/vm/code/pcDesc.cpp Thu Aug 20 12:42:57 2009 -0700
@@ -1,5 +1,5 @@
/*
- * 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 @@
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
--- a/hotspot/src/share/vm/code/pcDesc.hpp Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/src/share/vm/code/pcDesc.hpp Thu Aug 20 12:42:57 2009 -0700
@@ -1,5 +1,5 @@
/*
- * 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 @@
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 @@
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;
--- a/hotspot/src/share/vm/code/scopeDesc.cpp Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/src/share/vm/code/scopeDesc.cpp Thu Aug 20 12:42:57 2009 -0700
@@ -1,5 +1,5 @@
/*
- * 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 @@
_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 @@
_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 @@
_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();
--- a/hotspot/src/share/vm/code/scopeDesc.hpp Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/src/share/vm/code/scopeDesc.hpp Thu Aug 20 12:42:57 2009 -0700
@@ -1,5 +1,5 @@
/*
- * 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 @@
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 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; }
--- a/hotspot/src/share/vm/opto/callnode.cpp Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/src/share/vm/opto/callnode.cpp Thu Aug 20 12:42:57 2009 -0700
@@ -493,7 +493,8 @@
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");
}
--- a/hotspot/src/share/vm/prims/jvmtiCodeBlobEvents.cpp Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiCodeBlobEvents.cpp Thu Aug 20 12:42:57 2009 -0700
@@ -1,5 +1,5 @@
/*
- * 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 @@
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();
--- a/hotspot/src/share/vm/runtime/vframe.hpp Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/src/share/vm/runtime/vframe.hpp Thu Aug 20 12:42:57 2009 -0700
@@ -402,12 +402,7 @@
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");
}
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp Wed Aug 19 19:05:18 2009 -0700
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp Thu Aug 20 12:42:57 2009 -0700
@@ -593,6 +593,7 @@
\
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 @@
/***************************************/ \
\
declare_toplevel_type(PcDesc) \
+ declare_integer_type(PcDesc::PcDescFlags) \
\
/************************/ \
/* OopMap and OopMapSet */ \