The entire code_begin() to code_end() region contains executable assembly but JVMTI dumps only insts_begin() to insts_end() which leaves out the stubs section. PrintNMethod output always dumps the code_begin() to code_end(). It's not usually a hot part of the nmethod but it can get profiler ticks so it's confusing to leave it out. Following the pattern from the dynamic generated code notification the fix should be something like this:
diff --git a/src/share/vm/prims/jvmtiExport.cpp b/src/share/vm/prims/jvmtiExport.cpp
index bac36634d6..b41be2c3f2 100644
--- a/src/share/vm/prims/jvmtiExport.cpp
+++ b/src/share/vm/prims/jvmtiExport.cpp
@@ -720,8 +720,8 @@ class JvmtiCompiledMethodLoadEventMark : public JvmtiMethodEventMark {
public:
JvmtiCompiledMethodLoadEventMark(JavaThread *thread, nmethod *nm, void* compile_info_ptr = NULL)
: JvmtiMethodEventMark(thread,methodHandle(thread, nm->method())) {
- _code_data = nm->insts_begin();
- _code_size = nm->insts_size();
+ _code_data = nm->code_begin();
+ _code_size = (jint)pointer_delta(nm->code_end(), nm->code_begin(), sizeof(char));
_compile_info = compile_info_ptr; // Set void pointer of compiledMethodLoad Event. Default value is NULL.
JvmtiCodeBlobEvents::build_jvmti_addr_location_map(nm, &_map, &_map_length);
}
diff --git a/src/share/vm/prims/jvmtiExport.cpp b/src/share/vm/prims/jvmtiExport.cpp
index bac36634d6..b41be2c3f2 100644
--- a/src/share/vm/prims/jvmtiExport.cpp
+++ b/src/share/vm/prims/jvmtiExport.cpp
@@ -720,8 +720,8 @@ class JvmtiCompiledMethodLoadEventMark : public JvmtiMethodEventMark {
public:
JvmtiCompiledMethodLoadEventMark(JavaThread *thread, nmethod *nm, void* compile_info_ptr = NULL)
: JvmtiMethodEventMark(thread,methodHandle(thread, nm->method())) {
- _code_data = nm->insts_begin();
- _code_size = nm->insts_size();
+ _code_data = nm->code_begin();
+ _code_size = (jint)pointer_delta(nm->code_end(), nm->code_begin(), sizeof(char));
_compile_info = compile_info_ptr; // Set void pointer of compiledMethodLoad Event. Default value is NULL.
JvmtiCodeBlobEvents::build_jvmti_addr_location_map(nm, &_map, &_map_length);
}