< prev index next >

src/share/vm/prims/nativeLookup.cpp

Print this page




  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "classfile/vmSymbols.hpp"
  29 #include "memory/oopFactory.hpp"
  30 #include "memory/resourceArea.hpp"
  31 #include "memory/universe.inline.hpp"
  32 #include "oops/instanceKlass.hpp"
  33 #include "oops/method.hpp"
  34 #include "oops/oop.inline.hpp"
  35 #include "oops/symbol.hpp"
  36 #include "prims/jvm_misc.hpp"
  37 #include "prims/nativeLookup.hpp"
  38 #include "runtime/arguments.hpp"
  39 #include "runtime/handles.inline.hpp"
  40 #include "runtime/javaCalls.hpp"
  41 #include "runtime/sharedRuntime.hpp"
  42 #include "runtime/signature.hpp"
  43 #include "utilities/macros.hpp"



  44 #ifdef TARGET_OS_FAMILY_linux
  45 # include "os_linux.inline.hpp"
  46 #endif
  47 #ifdef TARGET_OS_FAMILY_solaris
  48 # include "os_solaris.inline.hpp"
  49 #endif
  50 #ifdef TARGET_OS_FAMILY_windows
  51 # include "os_windows.inline.hpp"
  52 #endif
  53 #ifdef TARGET_OS_FAMILY_aix
  54 # include "os_aix.inline.hpp"
  55 #endif
  56 #ifdef TARGET_OS_FAMILY_bsd
  57 # include "os_bsd.inline.hpp"
  58 #endif
  59 
  60 
  61 static void mangle_name_on(outputStream* st, Symbol* name, int begin, int end) {
  62   char* bytes = (char*)name->bytes() + begin;
  63   char* end_bytes = (char*)name->bytes() + end;


 119   // skip first '('
 120   mangle_name_on(&st, signature, 1, end);
 121   return st.as_string();
 122 }
 123 
 124 extern "C" {
 125   void JNICALL JVM_RegisterUnsafeMethods(JNIEnv *env, jclass unsafecls);
 126   void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
 127   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
 128   void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);
 129 }
 130 
 131 #define CC (char*)  /* cast a literal from (const char*) */
 132 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 133 
 134 static JNINativeMethod lookup_special_native_methods[] = {
 135   { CC"Java_sun_misc_Unsafe_registerNatives",                      NULL, FN_PTR(JVM_RegisterUnsafeMethods)       },
 136   { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
 137   { CC"Java_sun_misc_Perf_registerNatives",                        NULL, FN_PTR(JVM_RegisterPerfMethods)         },
 138   { CC"Java_sun_hotspot_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },



 139 };
 140 
 141 static address lookup_special_native(char* jni_name) {
 142   int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
 143   for (int i = 0; i < count; i++) {
 144     // NB: To ignore the jni prefix and jni postfix strstr is used matching.
 145     if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {
 146       return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr);
 147     }
 148   }
 149   return NULL;
 150 }
 151 
 152 address NativeLookup::lookup_style(methodHandle method, char* pure_name, const char* long_name, int args_size, bool os_style, bool& in_base_library, TRAPS) {
 153   address entry;
 154   // Compute complete JNI name for style
 155   stringStream st;
 156   if (os_style) os::print_jni_name_prefix_on(&st, args_size);
 157   st.print_raw(pure_name);
 158   st.print_raw(long_name);




  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "classfile/vmSymbols.hpp"
  29 #include "memory/oopFactory.hpp"
  30 #include "memory/resourceArea.hpp"
  31 #include "memory/universe.inline.hpp"
  32 #include "oops/instanceKlass.hpp"
  33 #include "oops/method.hpp"
  34 #include "oops/oop.inline.hpp"
  35 #include "oops/symbol.hpp"
  36 #include "prims/jvm_misc.hpp"
  37 #include "prims/nativeLookup.hpp"
  38 #include "runtime/arguments.hpp"
  39 #include "runtime/handles.inline.hpp"
  40 #include "runtime/javaCalls.hpp"
  41 #include "runtime/sharedRuntime.hpp"
  42 #include "runtime/signature.hpp"
  43 #include "utilities/macros.hpp"
  44 #if INCLUDE_JFR
  45 #include "jfr/jfr.hpp"
  46 #endif
  47 #ifdef TARGET_OS_FAMILY_linux
  48 # include "os_linux.inline.hpp"
  49 #endif
  50 #ifdef TARGET_OS_FAMILY_solaris
  51 # include "os_solaris.inline.hpp"
  52 #endif
  53 #ifdef TARGET_OS_FAMILY_windows
  54 # include "os_windows.inline.hpp"
  55 #endif
  56 #ifdef TARGET_OS_FAMILY_aix
  57 # include "os_aix.inline.hpp"
  58 #endif
  59 #ifdef TARGET_OS_FAMILY_bsd
  60 # include "os_bsd.inline.hpp"
  61 #endif
  62 
  63 
  64 static void mangle_name_on(outputStream* st, Symbol* name, int begin, int end) {
  65   char* bytes = (char*)name->bytes() + begin;
  66   char* end_bytes = (char*)name->bytes() + end;


 122   // skip first '('
 123   mangle_name_on(&st, signature, 1, end);
 124   return st.as_string();
 125 }
 126 
 127 extern "C" {
 128   void JNICALL JVM_RegisterUnsafeMethods(JNIEnv *env, jclass unsafecls);
 129   void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
 130   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
 131   void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);
 132 }
 133 
 134 #define CC (char*)  /* cast a literal from (const char*) */
 135 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 136 
 137 static JNINativeMethod lookup_special_native_methods[] = {
 138   { CC"Java_sun_misc_Unsafe_registerNatives",                      NULL, FN_PTR(JVM_RegisterUnsafeMethods)       },
 139   { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
 140   { CC"Java_sun_misc_Perf_registerNatives",                        NULL, FN_PTR(JVM_RegisterPerfMethods)         },
 141   { CC"Java_sun_hotspot_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
 142 #if INCLUDE_JFR
 143   { CC"Java_jdk_jfr_internal_JVM_registerNatives",                 NULL, FN_PTR(jfr_register_natives)            },
 144 #endif
 145 };
 146 
 147 static address lookup_special_native(char* jni_name) {
 148   int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
 149   for (int i = 0; i < count; i++) {
 150     // NB: To ignore the jni prefix and jni postfix strstr is used matching.
 151     if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {
 152       return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr);
 153     }
 154   }
 155   return NULL;
 156 }
 157 
 158 address NativeLookup::lookup_style(methodHandle method, char* pure_name, const char* long_name, int args_size, bool os_style, bool& in_base_library, TRAPS) {
 159   address entry;
 160   // Compute complete JNI name for style
 161   stringStream st;
 162   if (os_style) os::print_jni_name_prefix_on(&st, args_size);
 163   st.print_raw(pure_name);
 164   st.print_raw(long_name);


< prev index next >