@@ -171,14 +171,15 @@ static void fillFrameTypes(ASGCT_CallFrame *frames, int num_frames, VMNMethod *n
171171}
172172
173173// Fill the frame with raw method pointer
174- static inline void fillFrameRaw (ASGCT_CallFrame& frame, FrameTypeId type, int bci, const VMMethod* method) {
174+ static void fillFrameRaw (ASGCT_CallFrame& frame, FrameTypeId type, int bci, const VMMethod* method) {
175175 assert (method != nullptr );
176176 frame.bci = FrameType::encode (type, bci, true /* raw method pointer*/ );
177177 frame.method = static_cast <const void *>(method);
178178}
179179
180- static inline void fillFrame (ASGCT_CallFrame& frame, FrameTypeId type, int bci, jmethodID method_id, const VMMethod* method) {
181- if (method_id != nullptr ) {
180+ static void fillFrame (ASGCT_CallFrame& frame, FrameTypeId type, int bci, jmethodID method_id, const VMMethod* method) {
181+ // Pack JMETHODID_NOT_WALKABLE frame as raw pointer frame, so it can not resolved into nullptr to shared code.
182+ if (method_id != nullptr && method_id != JMETHODID_NOT_WALKABLE ) {
182183 fillFrame (frame, type, bci, method_id);
183184 } else {
184185 assert (method != nullptr );
@@ -1250,7 +1251,7 @@ static bool isLambdaClass(const char* signature) {
12501251 strncmp (signature, FFM_PREFIX , strlen (FFM_PREFIX )) == 0 ;
12511252}
12521253
1253- static inline bool isSystemClassLoaders (JNIEnv* jni, jobject cl) {
1254+ static bool isSystemClassLoader (JNIEnv* jni, jobject cl) {
12541255 return cl == nullptr || // bootstrap class loader
12551256 jni->IsSameObject (cl, JAVA_PLATFORM_CLASSLOADER ) || // platform class loader
12561257 jni->IsSameObject (cl, JAVA_APPLICATION_CLASSLOADER ); // application class loader (system class loader)
@@ -1271,7 +1272,7 @@ bool HotspotSupport::loadMethodIDsImpl(jvmtiEnv *jvmti, JNIEnv *jni, jclass klas
12711272 // we use Method instead.
12721273 if (!isHiddenClass (jvmti, klass) &&
12731274 jvmti->GetClassLoader (klass, &cl) == JVMTI_ERROR_NONE &&
1274- isSystemClassLoaders (jni, cl)) {
1275+ isSystemClassLoader (jni, cl)) {
12751276 char * signature_ptr = nullptr ;
12761277 if (jvmti->GetClassSignature (klass, &signature_ptr, nullptr ) == JVMTI_ERROR_NONE ) {
12771278 // Lambda classes, even loaded by bootstrap class loader, can be unloaded,
@@ -1299,6 +1300,13 @@ bool HotspotSupport::loadMethodIDsImpl(jvmtiEnv *jvmti, JNIEnv *jni, jclass klas
12991300jmethodID HotspotSupport::resolve (const void * method) {
13001301 assert (VM::isHotspot ());
13011302 assert (method != nullptr );
1303+ // We packed not walkable method as raw pointer,
1304+ // map it back to nullptr, as JMETHODID_NOT_WALKABLE is only
1305+ // known in hotspot.
1306+ if ((jmethodID)method == JMETHODID_NOT_WALKABLE ) {
1307+ return nullptr ;
1308+ }
1309+
13021310 VMMethod* vm_method = VMMethod::cast_or_null (method);
13031311 if (vm_method == nullptr ) {
13041312 return nullptr ;
0 commit comments