提交 cd5532b1 编写于 作者: S sspitsyn

8025841: JVMTI: "vtable stub" dynamic code notification is misplaced

Summary: Generate correct "vtable stub" dynamic code notifications
Reviewed-by: sspitsyn, kvn, coleenp
Contributed-by: oleg.mazurov@oracle.com
上级 0b9d8119
......@@ -55,6 +55,9 @@ void* VtableStub::operator new(size_t size, int code_size) throw() {
const int chunk_factor = 32;
if (_chunk == NULL || _chunk + real_size > _chunk_end) {
const int bytes = chunk_factor * real_size + pd_code_alignment();
// There is a dependency on the name of the blob in src/share/vm/prims/jvmtiCodeBlobEvents.cpp
// If changing the name, update the other file accordingly.
BufferBlob* blob = BufferBlob::create("vtable chunks", bytes);
if (blob == NULL) {
return NULL;
......@@ -62,12 +65,6 @@ void* VtableStub::operator new(size_t size, int code_size) throw() {
_chunk = blob->content_begin();
_chunk_end = _chunk + bytes;
Forte::register_stub("vtable stub", _chunk, _chunk_end);
// Notify JVMTI about this stub. The event will be recorded by the enclosing
// JvmtiDynamicCodeEventCollector and posted when this thread has released
// all locks.
if (JvmtiExport::should_post_dynamic_code_generated()) {
JvmtiExport::post_dynamic_code_generated_while_holding_locks("vtable stub", _chunk, _chunk_end);
}
align_chunk();
}
assert(_chunk + real_size <= _chunk_end, "bad allocation");
......@@ -130,6 +127,13 @@ address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) {
is_vtable_stub? "vtbl": "itbl", vtable_index, VtableStub::receiver_location());
Disassembler::decode(s->code_begin(), s->code_end());
}
// Notify JVMTI about this stub. The event will be recorded by the enclosing
// JvmtiDynamicCodeEventCollector and posted when this thread has released
// all locks.
if (JvmtiExport::should_post_dynamic_code_generated()) {
JvmtiExport::post_dynamic_code_generated_while_holding_locks(is_vtable_stub? "vtable stub": "itable stub",
s->code_begin(), s->code_end());
}
}
return s->entry_point();
}
......@@ -195,6 +199,14 @@ void vtableStubs_init() {
VtableStubs::initialize();
}
void VtableStubs::vtable_stub_do(void f(VtableStub*)) {
for (int i = 0; i < N; i++) {
for (VtableStub* s = _table[i]; s != NULL; s = s->next()) {
f(s);
}
}
}
//-----------------------------------------------------------------------------------------------------
// Non-product code
......
......@@ -131,6 +131,7 @@ class VtableStubs : AllStatic {
static VtableStub* stub_containing(address pc); // stub containing pc or NULL
static int number_of_vtable_stubs() { return _number_of_vtable_stubs; }
static void initialize();
static void vtable_stub_do(void f(VtableStub*)); // iterates over all vtable stubs
};
#endif // SHARE_VM_CODE_VTABLESTUBS_HPP
......@@ -26,6 +26,7 @@
#include "code/codeBlob.hpp"
#include "code/codeCache.hpp"
#include "code/scopeDesc.hpp"
#include "code/vtableStubs.hpp"
#include "memory/resourceArea.hpp"
#include "oops/oop.inline.hpp"
#include "prims/jvmtiCodeBlobEvents.hpp"
......@@ -63,6 +64,7 @@ class CodeBlobCollector : StackObj {
// used during a collection
static GrowableArray<JvmtiCodeBlobDesc*>* _global_code_blobs;
static void do_blob(CodeBlob* cb);
static void do_vtable_stub(VtableStub* vs);
public:
CodeBlobCollector() {
_code_blobs = NULL;
......@@ -119,6 +121,10 @@ void CodeBlobCollector::do_blob(CodeBlob* cb) {
if (cb->is_nmethod()) {
return;
}
// exclude VtableStubs, which are processed separately
if (cb->is_buffer_blob() && strcmp(cb->name(), "vtable chunks") == 0) {
return;
}
// check if this starting address has been seen already - the
// assumption is that stubs are inserted into the list before the
......@@ -136,6 +142,13 @@ void CodeBlobCollector::do_blob(CodeBlob* cb) {
_global_code_blobs->append(scb);
}
// called for each VtableStub in VtableStubs
void CodeBlobCollector::do_vtable_stub(VtableStub* vs) {
JvmtiCodeBlobDesc* scb = new JvmtiCodeBlobDesc(vs->is_vtable_stub() ? "vtable stub" : "itable stub",
vs->code_begin(), vs->code_end());
_global_code_blobs->append(scb);
}
// collects a list of CodeBlobs in the CodeCache.
//
......@@ -166,6 +179,10 @@ void CodeBlobCollector::collect() {
_global_code_blobs->append(new JvmtiCodeBlobDesc(desc->name(), desc->begin(), desc->end()));
}
// Vtable stubs are not described with StubCodeDesc,
// process them separately
VtableStubs::vtable_stub_do(do_vtable_stub);
// next iterate over all the non-nmethod code blobs and add them to
// the list - as noted above this will filter out duplicates and
// enclosing blobs.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册