Example #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
}
Example #2
0
void Java_com_sun_cldc_isolate_Isolate_setPriority0() {
  IsolateObj::Raw isolate_obj = GET_PARAMETER_AS_OOP(0);
  const jint new_priority = KNI_GetParameterAsInt(1);
  // new_priority tested at java level, should never be out of range
  GUARANTEE(new_priority >= Task::PRIORITY_MIN &&
            new_priority <= Task::PRIORITY_MAX, "priority out of range");
  Task::Raw t = isolate_obj().task();
  if (t.not_null()) {
    t().set_priority(new_priority);
  }
}
Example #3
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();
  }
}
Example #4
0
jint IsolateObj::exit_code( void ) const {
  // Always fetch the exit code from the Task, if the Task still exists
  // (even if it is in the STOPPING state).
  Task::Raw t = task();
  return t.not_null() ? t().exit_code() : saved_exit_code();
}
Example #5
0
jint IsolateObj::task_id( void ) const {
  Task::Raw t = task();
  return t.not_null() ? t().task_id() : Task::INVALID_TASK_ID;
}