Пример #1
0
void Thread::set_current(Thread* value) {
  GUARANTEE(_last_handle == NULL, "No handles when switching threads");
  GUARANTEE(last_kni_handle_info == NULL,
                                 "No KNI handles when switching threads");
  GUARANTEE(!_jvm_in_quick_native_method,
            "cannot switch thread in quick native methods");

  if (VerifyOnly) {
    GUARANTEE(current()->is_null() || value->is_null() ||
              current()->equals(value),
              "cannot switch threads during Romization or VerifyOnly");
  }

  if (current()->not_null()) {
    decache_current_pending_exception();
  }
  _current_thread = value->obj();
  cache_current_pending_exception();

  if (TraceThreadsExcessive) {
    TTY_TRACE_CR(("set_current_thread: 0x%x (id=%d)", value->obj(),
                  (value->is_null() ? -1 : value->id())));
  }
#if ENABLE_ISOLATES
  {
    int tid = value->task_id();
    Task::Raw task = Universe::task_from_id(tid);
    Universe::set_current_task(tid);
    // have to be here, not in Universe::set_current_task()
    ObjectHeap::on_task_switch(tid);

    if (task().is_terminating()){
#ifdef AZZERT
      GUARANTEE(!task.is_null() && task().status() >= Task::TASK_STOPPING,
                "task of terminating thread must be stopping");
#endif
      // The task that this thread belongs to is dead
      if (TraceThreadsExcessive) { 
        TTY_TRACE_CR(("set_current: task dead: thread 0x%x",
                      current()->obj()));
      }
      current()->set_terminating();
      set_current_pending_exception(Task::get_termination_object());
    } 
  }
#endif

  // Update the current stack limit
  update_current_stack_limit(value);

#if ENABLE_JAVA_DEBUGGER
  if (_debugger_active) {
    JavaDebugger::set_stepping(value->is_stepping());
  }
#endif
}
Пример #2
0
jint IsolateObj::status( void ) const {
  Task::Raw t = task();
  if (t.is_null()) {
    if (is_terminated()) {
      return Task::TASK_STOPPED;
    } else {
      return Task::TASK_NEW;
    }
  } else {
    return t().status();
  }
}