< prev index next >

src/hotspot/share/prims/nativeLookup.cpp

Print this page




  86 char* NativeLookup::critical_jni_name(const methodHandle& method) {
  87   stringStream st;
  88   // Prefix
  89   st.print("JavaCritical_");
  90   // Klass name
  91   mangle_name_on(&st, method->klass_name());
  92   st.print("_");
  93   // Method name
  94   mangle_name_on(&st, method->name());
  95   return st.as_string();
  96 }
  97 
  98 
  99 char* NativeLookup::long_jni_name(const methodHandle& method) {
 100   // Signature ignore the wrapping parenteses and the trailing return type
 101   stringStream st;
 102   Symbol* signature = method->signature();
 103   st.print("__");
 104   // find ')'
 105   int end;
 106   for (end = 0; end < signature->utf8_length() && signature->byte_at(end) != ')'; end++);
 107   // skip first '('
 108   mangle_name_on(&st, signature, 1, end);
 109   return st.as_string();
 110 }
 111 
 112 extern "C" {
 113   void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
 114   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
 115   void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);
 116 #if INCLUDE_JVMCI
 117   jobject  JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c);
 118   void     JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass);
 119 #endif
 120 }
 121 
 122 #define CC (char*)  /* cast a literal from (const char*) */
 123 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 124 
 125 static JNINativeMethod lookup_special_native_methods[] = {
 126   { CC"Java_jdk_internal_misc_Unsafe_registerNatives",             NULL, FN_PTR(JVM_RegisterJDKInternalMiscUnsafeMethods) },


 271 
 272   return entry; // NULL indicates not found
 273 }
 274 
 275 // Check all the formats of native implementation name to see if there is one
 276 // for the specified method.
 277 address NativeLookup::lookup_critical_entry(const methodHandle& method) {
 278   if (!CriticalJNINatives) return NULL;
 279 
 280   if (method->is_synchronized() ||
 281       !method->is_static()) {
 282     // Only static non-synchronized methods are allowed
 283     return NULL;
 284   }
 285 
 286   ResourceMark rm;
 287   address entry = NULL;
 288 
 289   Symbol* signature = method->signature();
 290   for (int end = 0; end < signature->utf8_length(); end++) {
 291     if (signature->byte_at(end) == 'L') {
 292       // Don't allow object types
 293       return NULL;
 294     }
 295   }
 296 
 297   // Compute critical name
 298   char* critical_name = critical_jni_name(method);
 299 
 300   // Compute argument size
 301   int args_size = method->size_of_parameters();
 302   for (SignatureStream ss(signature); !ss.at_return_type(); ss.next()) {
 303     if (ss.is_array()) {
 304       args_size += T_INT_size; // array length parameter
 305     }
 306   }
 307 
 308   // 1) Try JNI short style
 309   entry = lookup_critical_style(method, critical_name, "",        args_size, true);
 310   if (entry != NULL) return entry;
 311 




  86 char* NativeLookup::critical_jni_name(const methodHandle& method) {
  87   stringStream st;
  88   // Prefix
  89   st.print("JavaCritical_");
  90   // Klass name
  91   mangle_name_on(&st, method->klass_name());
  92   st.print("_");
  93   // Method name
  94   mangle_name_on(&st, method->name());
  95   return st.as_string();
  96 }
  97 
  98 
  99 char* NativeLookup::long_jni_name(const methodHandle& method) {
 100   // Signature ignore the wrapping parenteses and the trailing return type
 101   stringStream st;
 102   Symbol* signature = method->signature();
 103   st.print("__");
 104   // find ')'
 105   int end;
 106   for (end = 0; end < signature->utf8_length() && signature->char_at(end) != ')'; end++);
 107   // skip first '('
 108   mangle_name_on(&st, signature, 1, end);
 109   return st.as_string();
 110 }
 111 
 112 extern "C" {
 113   void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
 114   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
 115   void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);
 116 #if INCLUDE_JVMCI
 117   jobject  JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c);
 118   void     JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass);
 119 #endif
 120 }
 121 
 122 #define CC (char*)  /* cast a literal from (const char*) */
 123 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 124 
 125 static JNINativeMethod lookup_special_native_methods[] = {
 126   { CC"Java_jdk_internal_misc_Unsafe_registerNatives",             NULL, FN_PTR(JVM_RegisterJDKInternalMiscUnsafeMethods) },


 271 
 272   return entry; // NULL indicates not found
 273 }
 274 
 275 // Check all the formats of native implementation name to see if there is one
 276 // for the specified method.
 277 address NativeLookup::lookup_critical_entry(const methodHandle& method) {
 278   if (!CriticalJNINatives) return NULL;
 279 
 280   if (method->is_synchronized() ||
 281       !method->is_static()) {
 282     // Only static non-synchronized methods are allowed
 283     return NULL;
 284   }
 285 
 286   ResourceMark rm;
 287   address entry = NULL;
 288 
 289   Symbol* signature = method->signature();
 290   for (int end = 0; end < signature->utf8_length(); end++) {
 291     if (signature->char_at(end) == 'L') {
 292       // Don't allow object types
 293       return NULL;
 294     }
 295   }
 296 
 297   // Compute critical name
 298   char* critical_name = critical_jni_name(method);
 299 
 300   // Compute argument size
 301   int args_size = method->size_of_parameters();
 302   for (SignatureStream ss(signature); !ss.at_return_type(); ss.next()) {
 303     if (ss.is_array()) {
 304       args_size += T_INT_size; // array length parameter
 305     }
 306   }
 307 
 308   // 1) Try JNI short style
 309   entry = lookup_critical_style(method, critical_name, "",        args_size, true);
 310   if (entry != NULL) return entry;
 311 


< prev index next >