Example #1
0
void Thread::start_lightweight_thread() {
  Thread* thread = Thread::current();
  // idea here is that some threads can't be terminated
  // by throwing an uncatchable exceptions if they're in 'just started'
  // state (i.e. never executed), as this exception will be silently ignored
  // by shared_entry(), thus we have to check thread status before
  // actual execution of pending entries, and null them out, 
  // if thread is terminating
  if (thread->is_terminating()) {
    Oop::Raw null;
    thread->set_pending_entries(&null);
  } else {
    invoke_pending_entries(thread);
  }

  if (!Universe::is_stopping() && !TestCompiler) {
    if (CURRENT_HAS_PENDING_EXCEPTION) {
      call_on_primordial_stack(lightweight_thread_uncaught_exception);
    }
    call_on_primordial_stack(finish);
    invoke_pending_entries(thread);
    // Just in case the append_pending_entry() failed inside
    // Thread::finish()
    force_terminated(thread);
#if ENABLE_ISOLATES
#if !ARM && !HITACHI_SH
    {
      call_on_primordial_stack(thread_task_cleanup);
      invoke_pending_entries(thread);
    }
#endif
#endif
  }
  // The following returns to another Java thread, unless this is
  // the only remaining Java thread.
  call_on_primordial_stack(lightweight_thread_exit);

  // We can only return here if we are the last thread.
  // Running on the Java stack at this point, no handles please
  GUARANTEE(Scheduler::get_next_runnable_thread()->is_null(),
            "Must be last thread");

  // Back to C land
  current_thread_to_primordial();

  SHOULD_NOT_REACH_HERE();
}
Example #2
0
// pps = Print on Primordial Stack. Use this while you get stuck on
// the Java stack
void pps(int x) {
  pps_pointer = x;
  call_on_primordial_stack(pps_helper);
}