149 deopt_caller();
150 }
151 }
152 JRT_BLOCK_END;
153
154 if (ReduceInitialCardMarks) {
155 new_store_pre_barrier(thread);
156 }
157 JRT_END
158
159 void JVMCIRuntime::new_store_pre_barrier(JavaThread* thread) {
160 // After any safepoint, just before going back to compiled code,
161 // we inform the GC that we will be doing initializing writes to
162 // this object in the future without emitting card-marks, so
163 // GC may take any compensating steps.
164 // NOTE: Keep this code consistent with GraphKit::store_barrier.
165
166 oop new_obj = thread->vm_result();
167 if (new_obj == NULL) return;
168
169 assert(Universe::heap()->can_elide_tlab_store_barriers(),
170 "compiler must check this first");
171 // GC may decide to give back a safer copy of new_obj.
172 new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj);
173 thread->set_vm_result(new_obj);
174 }
175
176 JRT_ENTRY(void, JVMCIRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims))
177 assert(klass->is_klass(), "not a class");
178 assert(rank >= 1, "rank must be nonzero");
179 Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
180 oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
181 thread->set_vm_result(obj);
182 JRT_END
183
184 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length))
185 oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK);
186 thread->set_vm_result(obj);
187 JRT_END
188
189 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror))
190 instanceKlassHandle klass(THREAD, java_lang_Class::as_Klass(type_mirror));
191
192 if (klass == NULL) {
461 ResourceMark rm;
462 assert(obj != NULL && java_lang_String::is_instance(obj), "must be");
463 char *buf = java_lang_String::as_utf8_string(obj);
464 tty->print_raw(buf);
465 }
466 if (newline) {
467 tty->cr();
468 }
469 JRT_END
470
471 JRT_LEAF(void, JVMCIRuntime::write_barrier_pre(JavaThread* thread, oopDesc* obj))
472 thread->satb_mark_queue().enqueue(obj);
473 JRT_END
474
475 JRT_LEAF(void, JVMCIRuntime::write_barrier_post(JavaThread* thread, void* card_addr))
476 thread->dirty_card_queue().enqueue(card_addr);
477 JRT_END
478
479 JRT_LEAF(jboolean, JVMCIRuntime::validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child))
480 bool ret = true;
481 if(!Universe::heap()->is_in_closed_subset(parent)) {
482 tty->print_cr("Parent Object " INTPTR_FORMAT " not in heap", p2i(parent));
483 parent->print();
484 ret=false;
485 }
486 if(!Universe::heap()->is_in_closed_subset(child)) {
487 tty->print_cr("Child Object " INTPTR_FORMAT " not in heap", p2i(child));
488 child->print();
489 ret=false;
490 }
491 return (jint)ret;
492 JRT_END
493
494 JRT_ENTRY(void, JVMCIRuntime::vm_error(JavaThread* thread, jlong where, jlong format, jlong value))
495 ResourceMark rm;
496 const char *error_msg = where == 0L ? "<internal JVMCI error>" : (char*) (address) where;
497 char *detail_msg = NULL;
498 if (format != 0L) {
499 const char* buf = (char*) (address) format;
500 size_t detail_msg_length = strlen(buf) * 2;
501 detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length);
502 jio_snprintf(detail_msg, detail_msg_length, buf, value);
503 report_vm_error(__FILE__, __LINE__, error_msg, "%s", detail_msg);
504 } else {
505 report_vm_error(__FILE__, __LINE__, error_msg);
506 }
520 ResourceMark rm;
521 assert(format != NULL && java_lang_String::is_instance(format), "must be");
522 char *buf = java_lang_String::as_utf8_string(format);
523 tty->print((const char*)buf, v1, v2, v3);
524 JRT_END
525 PRAGMA_DIAG_POP
526
527 static void decipher(jlong v, bool ignoreZero) {
528 if (v != 0 || !ignoreZero) {
529 void* p = (void *)(address) v;
530 CodeBlob* cb = CodeCache::find_blob(p);
531 if (cb) {
532 if (cb->is_nmethod()) {
533 char buf[O_BUFLEN];
534 tty->print("%s [" INTPTR_FORMAT "+" JLONG_FORMAT "]", cb->as_nmethod_or_null()->method()->name_and_sig_as_C_string(buf, O_BUFLEN), p2i(cb->code_begin()), (jlong)((address)v - cb->code_begin()));
535 return;
536 }
537 cb->print_value_on(tty);
538 return;
539 }
540 if (Universe::heap()->is_in(p)) {
541 oop obj = oop(p);
542 obj->print_value_on(tty);
543 return;
544 }
545 tty->print(INTPTR_FORMAT " [long: " JLONG_FORMAT ", double %lf, char %c]",p2i((void *)v), (jlong)v, (jdouble)v, (char)v);
546 }
547 }
548
549 PRAGMA_DIAG_PUSH
550 PRAGMA_FORMAT_NONLITERAL_IGNORED
551 JRT_LEAF(void, JVMCIRuntime::vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3))
552 ResourceMark rm;
553 const char *buf = (const char*) (address) format;
554 if (vmError) {
555 if (buf != NULL) {
556 fatal(buf, v1, v2, v3);
557 } else {
558 fatal("<anonymous error>");
559 }
560 } else if (buf != NULL) {
779 metadataRoot->print();
780 ShouldNotReachHere();
781 }
782 }
783 metadataRoots = (objArrayOop)metadataRoots->obj_at(metadataRoots->length() - 1);
784 assert(metadataRoots == NULL || metadataRoots->is_objArray(), "wrong type");
785 }
786 }
787 }
788 }
789 }
790
791 // private static void CompilerToVM.registerNatives()
792 JVM_ENTRY(void, JVM_RegisterJVMCINatives(JNIEnv *env, jclass c2vmClass))
793 if (!EnableJVMCI) {
794 THROW_MSG(vmSymbols::java_lang_InternalError(), "JVMCI is not enabled");
795 }
796
797 #ifdef _LP64
798 #ifndef SPARC
799 uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end();
800 uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024;
801 guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)");
802 #endif // !SPARC
803 #else
804 fatal("check TLAB allocation code for address space conflicts");
805 #endif // _LP64
806
807 JVMCIRuntime::initialize_well_known_classes(CHECK);
808
809 {
810 ThreadToNativeFromVM trans(thread);
811 env->RegisterNatives(c2vmClass, CompilerToVM::methods, CompilerToVM::methods_count());
812 }
813 JVM_END
814
815 #define CHECK_WARN_ABORT_(message) THREAD); \
816 if (HAS_PENDING_EXCEPTION) { \
817 warning(message); \
818 char buf[512]; \
819 jio_snprintf(buf, 512, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
|
149 deopt_caller();
150 }
151 }
152 JRT_BLOCK_END;
153
154 if (ReduceInitialCardMarks) {
155 new_store_pre_barrier(thread);
156 }
157 JRT_END
158
159 void JVMCIRuntime::new_store_pre_barrier(JavaThread* thread) {
160 // After any safepoint, just before going back to compiled code,
161 // we inform the GC that we will be doing initializing writes to
162 // this object in the future without emitting card-marks, so
163 // GC may take any compensating steps.
164 // NOTE: Keep this code consistent with GraphKit::store_barrier.
165
166 oop new_obj = thread->vm_result();
167 if (new_obj == NULL) return;
168
169 assert(GC::gc()->heap()->can_elide_tlab_store_barriers(),
170 "compiler must check this first");
171 // GC may decide to give back a safer copy of new_obj.
172 new_obj = GC::gc()->heap()->new_store_pre_barrier(thread, new_obj);
173 thread->set_vm_result(new_obj);
174 }
175
176 JRT_ENTRY(void, JVMCIRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims))
177 assert(klass->is_klass(), "not a class");
178 assert(rank >= 1, "rank must be nonzero");
179 Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
180 oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
181 thread->set_vm_result(obj);
182 JRT_END
183
184 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length))
185 oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK);
186 thread->set_vm_result(obj);
187 JRT_END
188
189 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror))
190 instanceKlassHandle klass(THREAD, java_lang_Class::as_Klass(type_mirror));
191
192 if (klass == NULL) {
461 ResourceMark rm;
462 assert(obj != NULL && java_lang_String::is_instance(obj), "must be");
463 char *buf = java_lang_String::as_utf8_string(obj);
464 tty->print_raw(buf);
465 }
466 if (newline) {
467 tty->cr();
468 }
469 JRT_END
470
471 JRT_LEAF(void, JVMCIRuntime::write_barrier_pre(JavaThread* thread, oopDesc* obj))
472 thread->satb_mark_queue().enqueue(obj);
473 JRT_END
474
475 JRT_LEAF(void, JVMCIRuntime::write_barrier_post(JavaThread* thread, void* card_addr))
476 thread->dirty_card_queue().enqueue(card_addr);
477 JRT_END
478
479 JRT_LEAF(jboolean, JVMCIRuntime::validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child))
480 bool ret = true;
481 if(!GC::gc()->heap()->is_in_closed_subset(parent)) {
482 tty->print_cr("Parent Object " INTPTR_FORMAT " not in heap", p2i(parent));
483 parent->print();
484 ret=false;
485 }
486 if(!GC::gc()->heap()->is_in_closed_subset(child)) {
487 tty->print_cr("Child Object " INTPTR_FORMAT " not in heap", p2i(child));
488 child->print();
489 ret=false;
490 }
491 return (jint)ret;
492 JRT_END
493
494 JRT_ENTRY(void, JVMCIRuntime::vm_error(JavaThread* thread, jlong where, jlong format, jlong value))
495 ResourceMark rm;
496 const char *error_msg = where == 0L ? "<internal JVMCI error>" : (char*) (address) where;
497 char *detail_msg = NULL;
498 if (format != 0L) {
499 const char* buf = (char*) (address) format;
500 size_t detail_msg_length = strlen(buf) * 2;
501 detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length);
502 jio_snprintf(detail_msg, detail_msg_length, buf, value);
503 report_vm_error(__FILE__, __LINE__, error_msg, "%s", detail_msg);
504 } else {
505 report_vm_error(__FILE__, __LINE__, error_msg);
506 }
520 ResourceMark rm;
521 assert(format != NULL && java_lang_String::is_instance(format), "must be");
522 char *buf = java_lang_String::as_utf8_string(format);
523 tty->print((const char*)buf, v1, v2, v3);
524 JRT_END
525 PRAGMA_DIAG_POP
526
527 static void decipher(jlong v, bool ignoreZero) {
528 if (v != 0 || !ignoreZero) {
529 void* p = (void *)(address) v;
530 CodeBlob* cb = CodeCache::find_blob(p);
531 if (cb) {
532 if (cb->is_nmethod()) {
533 char buf[O_BUFLEN];
534 tty->print("%s [" INTPTR_FORMAT "+" JLONG_FORMAT "]", cb->as_nmethod_or_null()->method()->name_and_sig_as_C_string(buf, O_BUFLEN), p2i(cb->code_begin()), (jlong)((address)v - cb->code_begin()));
535 return;
536 }
537 cb->print_value_on(tty);
538 return;
539 }
540 if (GC::gc()->heap()->is_in(p)) {
541 oop obj = oop(p);
542 obj->print_value_on(tty);
543 return;
544 }
545 tty->print(INTPTR_FORMAT " [long: " JLONG_FORMAT ", double %lf, char %c]",p2i((void *)v), (jlong)v, (jdouble)v, (char)v);
546 }
547 }
548
549 PRAGMA_DIAG_PUSH
550 PRAGMA_FORMAT_NONLITERAL_IGNORED
551 JRT_LEAF(void, JVMCIRuntime::vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3))
552 ResourceMark rm;
553 const char *buf = (const char*) (address) format;
554 if (vmError) {
555 if (buf != NULL) {
556 fatal(buf, v1, v2, v3);
557 } else {
558 fatal("<anonymous error>");
559 }
560 } else if (buf != NULL) {
779 metadataRoot->print();
780 ShouldNotReachHere();
781 }
782 }
783 metadataRoots = (objArrayOop)metadataRoots->obj_at(metadataRoots->length() - 1);
784 assert(metadataRoots == NULL || metadataRoots->is_objArray(), "wrong type");
785 }
786 }
787 }
788 }
789 }
790
791 // private static void CompilerToVM.registerNatives()
792 JVM_ENTRY(void, JVM_RegisterJVMCINatives(JNIEnv *env, jclass c2vmClass))
793 if (!EnableJVMCI) {
794 THROW_MSG(vmSymbols::java_lang_InternalError(), "JVMCI is not enabled");
795 }
796
797 #ifdef _LP64
798 #ifndef SPARC
799 uintptr_t heap_end = (uintptr_t) GC::gc()->heap()->reserved_region().end();
800 uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024;
801 guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)");
802 #endif // !SPARC
803 #else
804 fatal("check TLAB allocation code for address space conflicts");
805 #endif // _LP64
806
807 JVMCIRuntime::initialize_well_known_classes(CHECK);
808
809 {
810 ThreadToNativeFromVM trans(thread);
811 env->RegisterNatives(c2vmClass, CompilerToVM::methods, CompilerToVM::methods_count());
812 }
813 JVM_END
814
815 #define CHECK_WARN_ABORT_(message) THREAD); \
816 if (HAS_PENDING_EXCEPTION) { \
817 warning(message); \
818 char buf[512]; \
819 jio_snprintf(buf, 512, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
|