src/hotspot/share/jvmci/jvmciJavaClasses.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff src/hotspot/share/jvmci

src/hotspot/share/jvmci/jvmciJavaClasses.cpp

Print this page




 339           }
 340 
 341 #define GET_JNI_CONSTRUCTOR(clazz, signature) \
 342   GET_JNI_METHOD(GetMethodID, JNIJVMCI::clazz::_constructor, clazz::_class, "<init>", signature) \
 343 
 344 #define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName, args) \
 345      GET_JNI_METHOD(jniGetMethod,                                        \
 346                     className::_##methodName##_method,                   \
 347                     className::clazz(),                                  \
 348                     vmSymbols::methodName##_name()->as_C_string(),       \
 349                     vmSymbols::signatureSymbolName()->as_C_string())
 350 
 351 #define CONSTRUCTOR(className, signature) \
 352   GET_JNI_CONSTRUCTOR(className, signature)
 353 
 354 extern "C" {
 355   void     JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass);
 356   jobject  JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c);
 357 }
 358 





































 359 #define IN_CLASS(fullClassName) current_class_name = vmSymbols::fullClassName()->as_C_string()
 360 /**
 361  * Initializes the JNI method and field ids used in JNIJVMCI.
 362  */
 363 void JNIJVMCI::initialize_ids(JNIEnv* env) {
 364   ResourceMark rm;
 365   const char* current_class_name = NULL;
 366   JVMCI_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OBJECT_FIELD, OBJECT_FIELD, OBJECT_FIELD, STATIC_OBJECT_FIELD, STATIC_OBJECT_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD, METHOD, CONSTRUCTOR)
 367 
 368   IN_CLASS(java_lang_Class);
 369   GET_JNI_METHOD(GetMethodID, _Class_getName_method, Class::_class, "getName", "()Ljava/lang/String;");
 370 
 371   IN_CLASS(jdk_vm_ci_hotspot_HotSpotResolvedPrimitiveType);
 372   GET_JNI_METHOD(GetStaticMethodID, _HotSpotResolvedPrimitiveType_fromMetaspace_method, HotSpotResolvedPrimitiveType::_class,
 373                                                                                           vmSymbols::fromMetaspace_name()->as_C_string(),
 374                                                                                           vmSymbols::primitive_fromMetaspace_signature()->as_C_string());
 375   IN_CLASS(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl);
 376   GET_JNI_METHOD(GetStaticMethodID, _HotSpotResolvedObjectTypeImpl_fromMetaspace_method, HotSpotResolvedObjectTypeImpl::_class,
 377                                                                                            vmSymbols::fromMetaspace_name()->as_C_string(),
 378                                                                                            vmSymbols::klass_fromMetaspace_signature()->as_C_string());


 424   }
 425 
 426 #define DUMP_ALL_NATIVE_METHODS(class_symbol) do {                                                                  \
 427   current_class_name = class_symbol->as_C_string();                                                                 \
 428   Klass* k = SystemDictionary::resolve_or_fail(class_symbol, true, CHECK_EXIT);                                     \
 429   InstanceKlass* iklass = InstanceKlass::cast(k);                                                                   \
 430   Array<Method*>* methods = iklass->methods();                                                                      \
 431   for (int i = 0; i < methods->length(); i++) {                                                                     \
 432     Method* m = methods->at(i);                                                                                     \
 433     if (m->is_native()) {                                                                                           \
 434       st->print_cr("method %s %s %s", current_class_name, m->name()->as_C_string(), m->signature()->as_C_string()); \
 435     }                                                                                                               \
 436   }                                                                                                                 \
 437 } while(0)
 438 
 439   if (JVMCILibDumpJNIConfig != NULL) {
 440     Thread* THREAD = Thread::current();
 441     fileStream* st = JVMCIGlobals::get_jni_config_file();
 442 
 443     DUMP_ALL_NATIVE_METHODS(vmSymbols::jdk_vm_ci_hotspot_CompilerToVM());


 444 
 445     st->flush();
 446     tty->print_cr("Dumped JVMCI shared library JNI configuration to %s", JVMCILibDumpJNIConfig);
 447     vm_exit(0);
 448   }
 449 
 450 #undef DUMP_ALL_NATIVE_METHODS
 451 #undef DO_BOX_CLASS
 452 #undef BOX_CLASSES
 453 #undef IN_CLASS
 454 
 455 #define CC (char*)  /*cast a literal from (const char*)*/
 456 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(f))
 457 
 458   if (env != JavaThread::current()->jni_environment()) {
 459     jclass clazz = env->FindClass("jdk/vm/ci/hotspot/CompilerToVM");
 460     if (env->ExceptionCheck()) {
 461       env->ExceptionDescribe();
 462       guarantee(false, "Could not find class jdk/vm/ci/hotspot/CompilerToVM");
 463     }




 339           }
 340 
 341 #define GET_JNI_CONSTRUCTOR(clazz, signature) \
 342   GET_JNI_METHOD(GetMethodID, JNIJVMCI::clazz::_constructor, clazz::_class, "<init>", signature) \
 343 
 344 #define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName, args) \
 345      GET_JNI_METHOD(jniGetMethod,                                        \
 346                     className::_##methodName##_method,                   \
 347                     className::clazz(),                                  \
 348                     vmSymbols::methodName##_name()->as_C_string(),       \
 349                     vmSymbols::signatureSymbolName()->as_C_string())
 350 
 351 #define CONSTRUCTOR(className, signature) \
 352   GET_JNI_CONSTRUCTOR(className, signature)
 353 
 354 extern "C" {
 355   void     JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass);
 356   jobject  JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c);
 357 }
 358 
 359 // Dumps symbols for public <init>() and <init>(String) methods of
 360 // non-abstract Throwable subtypes known by the VM. This is to
 361 // support the use of reflection in jdk.vm.ci.hotspot.TranslatedException.create().
 362 class ThrowableInitDumper : public SymbolClosure {
 363  private:
 364   fileStream* _st;
 365  public:
 366   ThrowableInitDumper(fileStream* st)     { _st = st; }
 367   void do_symbol(Symbol** p) {
 368     Thread* THREAD = Thread::current();
 369     Symbol* name = *p;
 370     if (name == NULL) {
 371       return;
 372     }
 373     Klass* k = SystemDictionary::resolve_or_null(name, CHECK_EXIT);
 374     if (k != NULL && k->is_instance_klass()) {
 375       InstanceKlass* iklass = InstanceKlass::cast(k);
 376       if (iklass->is_subclass_of(SystemDictionary::Throwable_klass()) && iklass->is_public() && !iklass->is_abstract()) {
 377         const char* class_name = NULL;
 378         Array<Method*>* methods = iklass->methods();
 379         for (int i = 0; i < methods->length(); i++) {
 380           Method* m = methods->at(i);
 381           if (m->name() == vmSymbols::object_initializer_name() &&
 382               m->is_public() &&
 383               (m->signature() == vmSymbols::void_method_signature() || m->signature() == vmSymbols::string_void_signature())) {
 384             if (class_name == NULL) {
 385               class_name = name->as_C_string();
 386               _st->print_cr("class %s", class_name);
 387             }
 388             _st->print_cr("method %s %s %s", class_name, m->name()->as_C_string(), m->signature()->as_C_string());
 389           }
 390         }
 391       }
 392     }
 393   }
 394 };
 395 
 396 #define IN_CLASS(fullClassName) current_class_name = vmSymbols::fullClassName()->as_C_string()
 397 /**
 398  * Initializes the JNI method and field ids used in JNIJVMCI.
 399  */
 400 void JNIJVMCI::initialize_ids(JNIEnv* env) {
 401   ResourceMark rm;
 402   const char* current_class_name = NULL;
 403   JVMCI_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OBJECT_FIELD, OBJECT_FIELD, OBJECT_FIELD, STATIC_OBJECT_FIELD, STATIC_OBJECT_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD, METHOD, CONSTRUCTOR)
 404 
 405   IN_CLASS(java_lang_Class);
 406   GET_JNI_METHOD(GetMethodID, _Class_getName_method, Class::_class, "getName", "()Ljava/lang/String;");
 407 
 408   IN_CLASS(jdk_vm_ci_hotspot_HotSpotResolvedPrimitiveType);
 409   GET_JNI_METHOD(GetStaticMethodID, _HotSpotResolvedPrimitiveType_fromMetaspace_method, HotSpotResolvedPrimitiveType::_class,
 410                                                                                           vmSymbols::fromMetaspace_name()->as_C_string(),
 411                                                                                           vmSymbols::primitive_fromMetaspace_signature()->as_C_string());
 412   IN_CLASS(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl);
 413   GET_JNI_METHOD(GetStaticMethodID, _HotSpotResolvedObjectTypeImpl_fromMetaspace_method, HotSpotResolvedObjectTypeImpl::_class,
 414                                                                                            vmSymbols::fromMetaspace_name()->as_C_string(),
 415                                                                                            vmSymbols::klass_fromMetaspace_signature()->as_C_string());


 461   }
 462 
 463 #define DUMP_ALL_NATIVE_METHODS(class_symbol) do {                                                                  \
 464   current_class_name = class_symbol->as_C_string();                                                                 \
 465   Klass* k = SystemDictionary::resolve_or_fail(class_symbol, true, CHECK_EXIT);                                     \
 466   InstanceKlass* iklass = InstanceKlass::cast(k);                                                                   \
 467   Array<Method*>* methods = iklass->methods();                                                                      \
 468   for (int i = 0; i < methods->length(); i++) {                                                                     \
 469     Method* m = methods->at(i);                                                                                     \
 470     if (m->is_native()) {                                                                                           \
 471       st->print_cr("method %s %s %s", current_class_name, m->name()->as_C_string(), m->signature()->as_C_string()); \
 472     }                                                                                                               \
 473   }                                                                                                                 \
 474 } while(0)
 475 
 476   if (JVMCILibDumpJNIConfig != NULL) {
 477     Thread* THREAD = Thread::current();
 478     fileStream* st = JVMCIGlobals::get_jni_config_file();
 479 
 480     DUMP_ALL_NATIVE_METHODS(vmSymbols::jdk_vm_ci_hotspot_CompilerToVM());
 481     ThrowableInitDumper dumper(st);
 482     vmSymbols::symbols_do(&dumper);
 483 
 484     st->flush();
 485     tty->print_cr("Dumped JVMCI shared library JNI configuration to %s", JVMCILibDumpJNIConfig);
 486     vm_exit(0);
 487   }
 488 
 489 #undef DUMP_ALL_NATIVE_METHODS
 490 #undef DO_BOX_CLASS
 491 #undef BOX_CLASSES
 492 #undef IN_CLASS
 493 
 494 #define CC (char*)  /*cast a literal from (const char*)*/
 495 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(f))
 496 
 497   if (env != JavaThread::current()->jni_environment()) {
 498     jclass clazz = env->FindClass("jdk/vm/ci/hotspot/CompilerToVM");
 499     if (env->ExceptionCheck()) {
 500       env->ExceptionDescribe();
 501       guarantee(false, "Could not find class jdk/vm/ci/hotspot/CompilerToVM");
 502     }


src/hotspot/share/jvmci/jvmciJavaClasses.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File