< prev index next >

src/hotspot/cpu/zero/cppInterpreter_zero.cpp

Print this page




 354       else if (type->size == 8) {
 355         src--;
 356         *(dst++) = src--;
 357       }
 358       else {
 359         ShouldNotReachHere();
 360       }
 361     }
 362   }
 363 
 364   // Set up the Java frame anchor
 365   thread->set_last_Java_frame();
 366 
 367   // Change the thread state to _thread_in_native
 368   ThreadStateTransition::transition_from_java(thread, _thread_in_native);
 369 
 370   // Make the call
 371   intptr_t result[4 - LogBytesPerWord];
 372   ffi_call(handler->cif(), (void (*)()) function, result, arguments);
 373 
 374   // Change the thread state back to _thread_in_Java and ensure it
 375   // is seen by the GC thread.
 376   // ThreadStateTransition::transition_from_native() cannot be used
 377   // here because it does not check for asynchronous exceptions.
 378   // We have to manage the transition ourself.
 379   thread->set_thread_state_fence(_thread_in_native_trans);



 380 
 381   // Handle safepoint operations, pending suspend requests,
 382   // and pending asynchronous exceptions.
 383   if (SafepointMechanism::should_block(thread) ||
 384       thread->has_special_condition_for_native_trans()) {
 385     JavaThread::check_special_condition_for_native_trans(thread);
 386     CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops());
 387   }
 388 
 389   // Finally we can change the thread state to _thread_in_Java.
 390   thread->set_thread_state(_thread_in_Java);
 391   fixup_after_potential_safepoint();
 392 
 393   // Clear the frame anchor
 394   thread->reset_last_Java_frame();
 395 
 396   // If the result was an oop then unbox it and store it in
 397   // oop_temp where the garbage collector can see it before
 398   // we release the handle it might be protected by.
 399   if (handler->result_type() == &ffi_type_pointer) {


 682     SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i), i + num_slots);
 683 
 684   // Deallocate the space
 685   stack->set_sp(stack->sp() + num_slots);
 686 }
 687 
 688 BasicType CppInterpreter::result_type_of_handle(oop method_handle) {
 689   oop method_type = java_lang_invoke_MethodHandle::type(method_handle);
 690   oop return_type = java_lang_invoke_MethodType::rtype(method_type);
 691   return java_lang_Class::as_BasicType(return_type, (Klass* *) NULL);
 692 }
 693 
 694 intptr_t* CppInterpreter::calculate_unwind_sp(ZeroStack* stack,
 695                                               oop method_handle) {
 696   oop method_type = java_lang_invoke_MethodHandle::type(method_handle);
 697   int argument_slots = java_lang_invoke_MethodType::ptype_slot_count(method_type);
 698 
 699   return stack->sp() + argument_slots;
 700 }
 701 
 702 JRT_ENTRY(void, CppInterpreter::throw_exception(JavaThread* thread,
 703                                                 Symbol*     name,
 704                                                 char*       message))
 705   THROW_MSG(name, message);
 706 JRT_END
 707 
 708 InterpreterFrame *InterpreterFrame::build(Method* const method, TRAPS) {
 709   JavaThread *thread = (JavaThread *) THREAD;
 710   ZeroStack *stack = thread->zero_stack();
 711 
 712   // Calculate the size of the frame we'll build, including
 713   // any adjustments to the caller's frame that we'll make.
 714   int extra_locals  = 0;
 715   int monitor_words = 0;
 716   int stack_words   = 0;
 717 
 718   if (!method->is_native()) {
 719     extra_locals = method->max_locals() - method->size_of_parameters();
 720     stack_words  = method->max_stack();
 721   }
 722   if (method->is_synchronized()) {
 723     monitor_words = frame::interpreter_frame_monitor_size();
 724   }
 725   stack->overflow_check(
 726     extra_locals + header_words + monitor_words + stack_words, CHECK_NULL);




 354       else if (type->size == 8) {
 355         src--;
 356         *(dst++) = src--;
 357       }
 358       else {
 359         ShouldNotReachHere();
 360       }
 361     }
 362   }
 363 
 364   // Set up the Java frame anchor
 365   thread->set_last_Java_frame();
 366 
 367   // Change the thread state to _thread_in_native
 368   ThreadStateTransition::transition_from_java(thread, _thread_in_native);
 369 
 370   // Make the call
 371   intptr_t result[4 - LogBytesPerWord];
 372   ffi_call(handler->cif(), (void (*)()) function, result, arguments);
 373 
 374   // Change the thread state back to _thread_in_Java.

 375   // ThreadStateTransition::transition_from_native() cannot be used
 376   // here because it does not check for asynchronous exceptions.
 377   // We have to manage the transition ourself.
 378   thread->set_thread_state(_thread_in_native_trans);
 379 
 380   // Make sure new state is visible in the GC thread
 381   InterfaceSupport::serialize_thread_state(thread);
 382 
 383   // Handle safepoint operations, pending suspend requests,
 384   // and pending asynchronous exceptions.
 385   if (SafepointMechanism::should_block(thread) ||
 386       thread->has_special_condition_for_native_trans()) {
 387     JavaThread::check_special_condition_for_native_trans(thread);
 388     CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops());
 389   }
 390 
 391   // Finally we can change the thread state to _thread_in_Java.
 392   thread->set_thread_state(_thread_in_Java);
 393   fixup_after_potential_safepoint();
 394 
 395   // Clear the frame anchor
 396   thread->reset_last_Java_frame();
 397 
 398   // If the result was an oop then unbox it and store it in
 399   // oop_temp where the garbage collector can see it before
 400   // we release the handle it might be protected by.
 401   if (handler->result_type() == &ffi_type_pointer) {


 684     SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i), i + num_slots);
 685 
 686   // Deallocate the space
 687   stack->set_sp(stack->sp() + num_slots);
 688 }
 689 
 690 BasicType CppInterpreter::result_type_of_handle(oop method_handle) {
 691   oop method_type = java_lang_invoke_MethodHandle::type(method_handle);
 692   oop return_type = java_lang_invoke_MethodType::rtype(method_type);
 693   return java_lang_Class::as_BasicType(return_type, (Klass* *) NULL);
 694 }
 695 
 696 intptr_t* CppInterpreter::calculate_unwind_sp(ZeroStack* stack,
 697                                               oop method_handle) {
 698   oop method_type = java_lang_invoke_MethodHandle::type(method_handle);
 699   int argument_slots = java_lang_invoke_MethodType::ptype_slot_count(method_type);
 700 
 701   return stack->sp() + argument_slots;
 702 }
 703 
 704 IRT_ENTRY(void, CppInterpreter::throw_exception(JavaThread* thread,
 705                                                 Symbol*     name,
 706                                                 char*       message))
 707   THROW_MSG(name, message);
 708 IRT_END
 709 
 710 InterpreterFrame *InterpreterFrame::build(Method* const method, TRAPS) {
 711   JavaThread *thread = (JavaThread *) THREAD;
 712   ZeroStack *stack = thread->zero_stack();
 713 
 714   // Calculate the size of the frame we'll build, including
 715   // any adjustments to the caller's frame that we'll make.
 716   int extra_locals  = 0;
 717   int monitor_words = 0;
 718   int stack_words   = 0;
 719 
 720   if (!method->is_native()) {
 721     extra_locals = method->max_locals() - method->size_of_parameters();
 722     stack_words  = method->max_stack();
 723   }
 724   if (method->is_synchronized()) {
 725     monitor_words = frame::interpreter_frame_monitor_size();
 726   }
 727   stack->overflow_check(
 728     extra_locals + header_words + monitor_words + stack_words, CHECK_NULL);


< prev index next >