< prev index next >

src/share/vm/runtime/sharedRuntime.cpp

Print this page




 192   if (ICMissHistogram) {
 193     tty->print_cr("IC Miss Histogram:");
 194     int tot_misses = 0;
 195     for (int i = 0; i < _ICmiss_index; i++) {
 196       tty->print_cr("  at: " INTPTR_FORMAT "  nof: %d", p2i(_ICmiss_at[i]), _ICmiss_count[i]);
 197       tot_misses += _ICmiss_count[i];
 198     }
 199     tty->print_cr("Total IC misses: %7d", tot_misses);
 200   }
 201 }
 202 #endif // PRODUCT
 203 
 204 #if INCLUDE_ALL_GCS
 205 
 206 // G1 write-barrier pre: executed before a pointer store.
 207 JRT_LEAF(void, SharedRuntime::g1_wb_pre(oopDesc* orig, JavaThread *thread))
 208   if (orig == NULL) {
 209     assert(false, "should be optimized out");
 210     return;
 211   }
 212   assert(orig->is_oop(true /* ignore mark word */), "Error");
 213   // store the original value that was in the field reference
 214   thread->satb_mark_queue().enqueue(orig);
 215 JRT_END
 216 
 217 // G1 write-barrier post: executed after a pointer store.
 218 JRT_LEAF(void, SharedRuntime::g1_wb_post(void* card_addr, JavaThread* thread))
 219   thread->dirty_card_queue().enqueue(card_addr);
 220 JRT_END
 221 
 222 #endif // INCLUDE_ALL_GCS
 223 
 224 
 225 JRT_LEAF(jlong, SharedRuntime::lmul(jlong y, jlong x))
 226   return x * y;
 227 JRT_END
 228 
 229 
 230 JRT_LEAF(jlong, SharedRuntime::ldiv(jlong y, jlong x))
 231   if (x == min_jlong && y == CONST64(-1)) {
 232     return x;


 568            "polling page vectors safepoint stub not created yet");
 569     stub = SharedRuntime::polling_page_vectors_safepoint_handler_blob()->entry_point();
 570   } else {
 571     assert(SharedRuntime::polling_page_safepoint_handler_blob() != NULL,
 572            "polling page safepoint stub not created yet");
 573     stub = SharedRuntime::polling_page_safepoint_handler_blob()->entry_point();
 574   }
 575   log_debug(safepoint)("... found polling page %s exception at pc = "
 576                        INTPTR_FORMAT ", stub =" INTPTR_FORMAT,
 577                        at_poll_return ? "return" : "loop",
 578                        (intptr_t)pc, (intptr_t)stub);
 579   return stub;
 580 }
 581 
 582 
 583 oop SharedRuntime::retrieve_receiver( Symbol* sig, frame caller ) {
 584   assert(caller.is_interpreted_frame(), "");
 585   int args_size = ArgumentSizeComputer(sig).size() + 1;
 586   assert(args_size <= caller.interpreter_frame_expression_stack_size(), "receiver must be on interpreter stack");
 587   oop result = cast_to_oop(*caller.interpreter_frame_tos_at(args_size - 1));
 588   assert(Universe::heap()->is_in(result) && result->is_oop(), "receiver must be an oop");
 589   return result;
 590 }
 591 
 592 
 593 void SharedRuntime::throw_and_post_jvmti_exception(JavaThread *thread, Handle h_exception) {
 594   if (JvmtiExport::can_post_on_exceptions()) {
 595     vframeStream vfst(thread, true);
 596     methodHandle method = methodHandle(thread, vfst.method());
 597     address bcp = method()->bcp_from(vfst.bci());
 598     JvmtiExport::post_exception_throw(thread, method(), bcp, h_exception());
 599   }
 600   Exceptions::_throw(thread, __FILE__, __LINE__, h_exception);
 601 }
 602 
 603 void SharedRuntime::throw_and_post_jvmti_exception(JavaThread *thread, Symbol* name, const char *message) {
 604   Handle h_exception = Exceptions::new_exception(thread, name, message);
 605   throw_and_post_jvmti_exception(thread, h_exception);
 606 }
 607 
 608 // The interpreter code to call this tracing function is only


 980  * before the call to the native function.  This might change in the future.
 981  */
 982 JNI_ENTRY(void*, throw_unsatisfied_link_error(JNIEnv* env, ...))
 983 {
 984   // We return a bad value here to make sure that the exception is
 985   // forwarded before we look at the return value.
 986   THROW_(vmSymbols::java_lang_UnsatisfiedLinkError(), (void*)badJNIHandle);
 987 }
 988 JNI_END
 989 
 990 address SharedRuntime::native_method_throw_unsatisfied_link_error_entry() {
 991   return CAST_FROM_FN_PTR(address, &throw_unsatisfied_link_error);
 992 }
 993 
 994 JRT_ENTRY_NO_ASYNC(void, SharedRuntime::register_finalizer(JavaThread* thread, oopDesc* obj))
 995 #if INCLUDE_JVMCI
 996   if (!obj->klass()->has_finalizer()) {
 997     return;
 998   }
 999 #endif // INCLUDE_JVMCI
1000   assert(obj->is_oop(), "must be a valid oop");
1001   assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
1002   InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
1003 JRT_END
1004 
1005 
1006 jlong SharedRuntime::get_java_tid(Thread* thread) {
1007   if (thread != NULL) {
1008     if (thread->is_Java_thread()) {
1009       oop obj = ((JavaThread*)thread)->threadObj();
1010       return (obj == NULL) ? 0 : java_lang_Thread::thread_id(obj);
1011     }
1012   }
1013   return 0;
1014 }
1015 
1016 /**
1017  * This function ought to be a void function, but cannot be because
1018  * it gets turned into a tail-call on sparc, which runs into dtrace bug
1019  * 6254741.  Once that is fixed we can remove the dummy return value.
1020  */


1147     // compiled frames. The receiver might be in a register.
1148     RegisterMap reg_map2(thread);
1149     frame stubFrame   = thread->last_frame();
1150     // Caller-frame is a compiled frame
1151     frame callerFrame = stubFrame.sender(&reg_map2);
1152 
1153     if (attached_method.is_null()) {
1154       methodHandle callee = bytecode.static_target(CHECK_NH);
1155       if (callee.is_null()) {
1156         THROW_(vmSymbols::java_lang_NoSuchMethodException(), nullHandle);
1157       }
1158     }
1159 
1160     // Retrieve from a compiled argument list
1161     receiver = Handle(THREAD, callerFrame.retrieve_receiver(&reg_map2));
1162 
1163     if (receiver.is_null()) {
1164       THROW_(vmSymbols::java_lang_NullPointerException(), nullHandle);
1165     }
1166   }
1167 
1168   assert(receiver.is_null() || receiver->is_oop(), "wrong receiver");
1169 
1170   // Resolve method
1171   if (attached_method.not_null()) {
1172     // Parameterized by attached method.
1173     LinkResolver::resolve_invoke(callinfo, receiver, attached_method, bc, CHECK_NH);
1174   } else {
1175     // Parameterized by bytecode.
1176     constantPoolHandle constants(THREAD, caller->constants());
1177     LinkResolver::resolve_invoke(callinfo, receiver, constants, bytecode_index, bc, CHECK_NH);
1178   }
1179 
1180 #ifdef ASSERT
1181   // Check that the receiver klass is of the right subtype and that it is initialized for virtual calls
1182   if (has_receiver) {
1183     assert(receiver.not_null(), "should have thrown exception");
1184     Klass* receiver_klass = receiver->klass();
1185     Klass* rk = NULL;
1186     if (attached_method.not_null()) {
1187       // In case there's resolved method attached, use its holder during the check.
1188       rk = attached_method->method_holder();




 192   if (ICMissHistogram) {
 193     tty->print_cr("IC Miss Histogram:");
 194     int tot_misses = 0;
 195     for (int i = 0; i < _ICmiss_index; i++) {
 196       tty->print_cr("  at: " INTPTR_FORMAT "  nof: %d", p2i(_ICmiss_at[i]), _ICmiss_count[i]);
 197       tot_misses += _ICmiss_count[i];
 198     }
 199     tty->print_cr("Total IC misses: %7d", tot_misses);
 200   }
 201 }
 202 #endif // PRODUCT
 203 
 204 #if INCLUDE_ALL_GCS
 205 
 206 // G1 write-barrier pre: executed before a pointer store.
 207 JRT_LEAF(void, SharedRuntime::g1_wb_pre(oopDesc* orig, JavaThread *thread))
 208   if (orig == NULL) {
 209     assert(false, "should be optimized out");
 210     return;
 211   }
 212   assert(oopDesc::is_oop(orig, true /* ignore mark word */), "Error");
 213   // store the original value that was in the field reference
 214   thread->satb_mark_queue().enqueue(orig);
 215 JRT_END
 216 
 217 // G1 write-barrier post: executed after a pointer store.
 218 JRT_LEAF(void, SharedRuntime::g1_wb_post(void* card_addr, JavaThread* thread))
 219   thread->dirty_card_queue().enqueue(card_addr);
 220 JRT_END
 221 
 222 #endif // INCLUDE_ALL_GCS
 223 
 224 
 225 JRT_LEAF(jlong, SharedRuntime::lmul(jlong y, jlong x))
 226   return x * y;
 227 JRT_END
 228 
 229 
 230 JRT_LEAF(jlong, SharedRuntime::ldiv(jlong y, jlong x))
 231   if (x == min_jlong && y == CONST64(-1)) {
 232     return x;


 568            "polling page vectors safepoint stub not created yet");
 569     stub = SharedRuntime::polling_page_vectors_safepoint_handler_blob()->entry_point();
 570   } else {
 571     assert(SharedRuntime::polling_page_safepoint_handler_blob() != NULL,
 572            "polling page safepoint stub not created yet");
 573     stub = SharedRuntime::polling_page_safepoint_handler_blob()->entry_point();
 574   }
 575   log_debug(safepoint)("... found polling page %s exception at pc = "
 576                        INTPTR_FORMAT ", stub =" INTPTR_FORMAT,
 577                        at_poll_return ? "return" : "loop",
 578                        (intptr_t)pc, (intptr_t)stub);
 579   return stub;
 580 }
 581 
 582 
 583 oop SharedRuntime::retrieve_receiver( Symbol* sig, frame caller ) {
 584   assert(caller.is_interpreted_frame(), "");
 585   int args_size = ArgumentSizeComputer(sig).size() + 1;
 586   assert(args_size <= caller.interpreter_frame_expression_stack_size(), "receiver must be on interpreter stack");
 587   oop result = cast_to_oop(*caller.interpreter_frame_tos_at(args_size - 1));
 588   assert(Universe::heap()->is_in(result) && oopDesc::is_oop(result), "receiver must be an oop");
 589   return result;
 590 }
 591 
 592 
 593 void SharedRuntime::throw_and_post_jvmti_exception(JavaThread *thread, Handle h_exception) {
 594   if (JvmtiExport::can_post_on_exceptions()) {
 595     vframeStream vfst(thread, true);
 596     methodHandle method = methodHandle(thread, vfst.method());
 597     address bcp = method()->bcp_from(vfst.bci());
 598     JvmtiExport::post_exception_throw(thread, method(), bcp, h_exception());
 599   }
 600   Exceptions::_throw(thread, __FILE__, __LINE__, h_exception);
 601 }
 602 
 603 void SharedRuntime::throw_and_post_jvmti_exception(JavaThread *thread, Symbol* name, const char *message) {
 604   Handle h_exception = Exceptions::new_exception(thread, name, message);
 605   throw_and_post_jvmti_exception(thread, h_exception);
 606 }
 607 
 608 // The interpreter code to call this tracing function is only


 980  * before the call to the native function.  This might change in the future.
 981  */
 982 JNI_ENTRY(void*, throw_unsatisfied_link_error(JNIEnv* env, ...))
 983 {
 984   // We return a bad value here to make sure that the exception is
 985   // forwarded before we look at the return value.
 986   THROW_(vmSymbols::java_lang_UnsatisfiedLinkError(), (void*)badJNIHandle);
 987 }
 988 JNI_END
 989 
 990 address SharedRuntime::native_method_throw_unsatisfied_link_error_entry() {
 991   return CAST_FROM_FN_PTR(address, &throw_unsatisfied_link_error);
 992 }
 993 
 994 JRT_ENTRY_NO_ASYNC(void, SharedRuntime::register_finalizer(JavaThread* thread, oopDesc* obj))
 995 #if INCLUDE_JVMCI
 996   if (!obj->klass()->has_finalizer()) {
 997     return;
 998   }
 999 #endif // INCLUDE_JVMCI
1000   assert(oopDesc::is_oop(obj), "must be a valid oop");
1001   assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
1002   InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
1003 JRT_END
1004 
1005 
1006 jlong SharedRuntime::get_java_tid(Thread* thread) {
1007   if (thread != NULL) {
1008     if (thread->is_Java_thread()) {
1009       oop obj = ((JavaThread*)thread)->threadObj();
1010       return (obj == NULL) ? 0 : java_lang_Thread::thread_id(obj);
1011     }
1012   }
1013   return 0;
1014 }
1015 
1016 /**
1017  * This function ought to be a void function, but cannot be because
1018  * it gets turned into a tail-call on sparc, which runs into dtrace bug
1019  * 6254741.  Once that is fixed we can remove the dummy return value.
1020  */


1147     // compiled frames. The receiver might be in a register.
1148     RegisterMap reg_map2(thread);
1149     frame stubFrame   = thread->last_frame();
1150     // Caller-frame is a compiled frame
1151     frame callerFrame = stubFrame.sender(&reg_map2);
1152 
1153     if (attached_method.is_null()) {
1154       methodHandle callee = bytecode.static_target(CHECK_NH);
1155       if (callee.is_null()) {
1156         THROW_(vmSymbols::java_lang_NoSuchMethodException(), nullHandle);
1157       }
1158     }
1159 
1160     // Retrieve from a compiled argument list
1161     receiver = Handle(THREAD, callerFrame.retrieve_receiver(&reg_map2));
1162 
1163     if (receiver.is_null()) {
1164       THROW_(vmSymbols::java_lang_NullPointerException(), nullHandle);
1165     }
1166   }


1167 
1168   // Resolve method
1169   if (attached_method.not_null()) {
1170     // Parameterized by attached method.
1171     LinkResolver::resolve_invoke(callinfo, receiver, attached_method, bc, CHECK_NH);
1172   } else {
1173     // Parameterized by bytecode.
1174     constantPoolHandle constants(THREAD, caller->constants());
1175     LinkResolver::resolve_invoke(callinfo, receiver, constants, bytecode_index, bc, CHECK_NH);
1176   }
1177 
1178 #ifdef ASSERT
1179   // Check that the receiver klass is of the right subtype and that it is initialized for virtual calls
1180   if (has_receiver) {
1181     assert(receiver.not_null(), "should have thrown exception");
1182     Klass* receiver_klass = receiver->klass();
1183     Klass* rk = NULL;
1184     if (attached_method.not_null()) {
1185       // In case there's resolved method attached, use its holder during the check.
1186       rk = attached_method->method_holder();


< prev index next >