105 |
105 |
106 JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_instance(JavaThread* thread, Klass* klass)) |
106 JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_instance(JavaThread* thread, Klass* klass)) |
107 JRT_BLOCK; |
107 JRT_BLOCK; |
108 assert(klass->is_klass(), "not a class"); |
108 assert(klass->is_klass(), "not a class"); |
109 Handle holder(THREAD, klass->klass_holder()); // keep the klass alive |
109 Handle holder(THREAD, klass->klass_holder()); // keep the klass alive |
110 instanceKlassHandle h(thread, klass); |
110 InstanceKlass* ik = InstanceKlass::cast(klass); |
111 h->check_valid_for_instantiation(true, CHECK); |
111 ik->check_valid_for_instantiation(true, CHECK); |
112 // make sure klass is initialized |
112 // make sure klass is initialized |
113 h->initialize(CHECK); |
113 ik->initialize(CHECK); |
114 // allocate instance and return via TLS |
114 // allocate instance and return via TLS |
115 oop obj = h->allocate_instance(CHECK); |
115 oop obj = ik->allocate_instance(CHECK); |
116 thread->set_vm_result(obj); |
116 thread->set_vm_result(obj); |
117 JRT_BLOCK_END; |
117 JRT_BLOCK_END; |
118 |
118 |
119 if (ReduceInitialCardMarks) { |
119 if (ReduceInitialCardMarks) { |
120 new_store_pre_barrier(thread); |
120 new_store_pre_barrier(thread); |
185 oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK); |
185 oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK); |
186 thread->set_vm_result(obj); |
186 thread->set_vm_result(obj); |
187 JRT_END |
187 JRT_END |
188 |
188 |
189 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror)) |
189 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror)) |
190 instanceKlassHandle klass(THREAD, java_lang_Class::as_Klass(type_mirror)); |
190 InstanceKlass* klass = InstanceKlass::cast(java_lang_Class::as_Klass(type_mirror)); |
191 |
191 |
192 if (klass == NULL) { |
192 if (klass == NULL) { |
193 ResourceMark rm(THREAD); |
193 ResourceMark rm(THREAD); |
194 THROW(vmSymbols::java_lang_InstantiationException()); |
194 THROW(vmSymbols::java_lang_InstantiationException()); |
195 } |
195 } |
639 return ret; |
639 return ret; |
640 JVM_END |
640 JVM_END |
641 |
641 |
642 Handle JVMCIRuntime::callStatic(const char* className, const char* methodName, const char* signature, JavaCallArguments* args, TRAPS) { |
642 Handle JVMCIRuntime::callStatic(const char* className, const char* methodName, const char* signature, JavaCallArguments* args, TRAPS) { |
643 TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_(Handle())); |
643 TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_(Handle())); |
644 KlassHandle klass = SystemDictionary::resolve_or_fail(name, true, CHECK_(Handle())); |
644 Klass* klass = SystemDictionary::resolve_or_fail(name, true, CHECK_(Handle())); |
645 TempNewSymbol runtime = SymbolTable::new_symbol(methodName, CHECK_(Handle())); |
645 TempNewSymbol runtime = SymbolTable::new_symbol(methodName, CHECK_(Handle())); |
646 TempNewSymbol sig = SymbolTable::new_symbol(signature, CHECK_(Handle())); |
646 TempNewSymbol sig = SymbolTable::new_symbol(signature, CHECK_(Handle())); |
647 JavaValue result(T_OBJECT); |
647 JavaValue result(T_OBJECT); |
648 if (args == NULL) { |
648 if (args == NULL) { |
649 JavaCalls::call_static(&result, klass, runtime, sig, CHECK_(Handle())); |
649 JavaCalls::call_static(&result, klass, runtime, sig, CHECK_(Handle())); |
655 |
655 |
656 void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(TRAPS) { |
656 void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(TRAPS) { |
657 guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime"); |
657 guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime"); |
658 JVMCIRuntime::initialize_well_known_classes(CHECK); |
658 JVMCIRuntime::initialize_well_known_classes(CHECK); |
659 // This should only be called in the context of the JVMCI class being initialized |
659 // This should only be called in the context of the JVMCI class being initialized |
660 instanceKlassHandle klass = InstanceKlass::cast(SystemDictionary::JVMCI_klass()); |
660 InstanceKlass* klass = SystemDictionary::JVMCI_klass(); |
661 guarantee(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD), |
661 guarantee(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD), |
662 "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization"); |
662 "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization"); |
663 |
663 |
664 Handle result = callStatic("jdk/vm/ci/hotspot/HotSpotJVMCIRuntime", |
664 Handle result = callStatic("jdk/vm/ci/hotspot/HotSpotJVMCIRuntime", |
665 "runtime", |
665 "runtime", |