58 using namespace cacao;
66 #if defined(__LINUX__)
68 bool threads_pthreads_implementation_nptl;
87 #if defined(__LINUX__) && defined(_CS_GNU_LIBPTHREAD_VERSION)
94 #if defined(__LINUX__)
103 # if defined(_CS_GNU_LIBPTHREAD_VERSION)
104 len = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, (
size_t) 0);
110 pathbuf =
MNEW(
char, len);
112 (
void) confstr(_CS_GNU_LIBPTHREAD_VERSION, pathbuf, len);
114 if (strstr(pathbuf,
"NPTL") != NULL)
115 threads_pthreads_implementation_nptl =
true;
117 threads_pthreads_implementation_nptl =
false;
120 threads_pthreads_implementation_nptl =
false;
122 threads_pthreads_implementation_nptl =
false;
144 if (mainthread->
index != 1)
145 vm_abort(
"threads_preinit: main thread index not 1: %d != 1",
170 ThreadRuntime::thread_create_initial_threadgroups(&threadgroup_main, &threadgroup_system);
174 thread_method_init = ThreadRuntime::get_thread_init_method();
176 if (thread_method_init == NULL)
177 vm_abort(
"threads_init: failed to resolve thread init method");
213 return ThreadRuntime::invoke_thread_initializer(jlt, t, thread_method_init, name, group);
237 #if defined(ENABLE_INTRP)
249 vm_abort(
"thread_create_initial_thread: failed to create Java object");
281 #ifdef ENABLE_GC_BOEHM
307 #ifdef ENABLE_GC_CACAO
327 #ifdef ENABLE_GC_CACAO
331 #ifdef ENABLE_DEBUG_FILTER
375 ThreadRuntime::clear_heap_reference(jlt);
421 #if defined(ENABLE_GC_BOEHM)
452 #if defined(ENABLE_JAVASE)
471 ThreadRuntime::setup_thread_vmdata(jlt, t);
473 #if defined(ENABLE_GC_BOEHM)
536 #if defined(ENABLE_JAVASE)
539 if (vm_aargs != NULL)
550 #if defined(ENABLE_INTRP)
637 ThreadRuntime::print_thread_name(jlt, stream);
675 printf(
" t=0x%" PRIxPTR
" tid=0x%" PRIxPTR
" (%" PRIdPTR
")", (uintptr_t) t, tid, tid);
676 printf(
" index=%d", t->index);
696 printf(
" waiting on condition");
708 vm_abort(
"thread_print_info: unknown thread state %d", state);
741 ThreadRuntime::set_javathread_state(t, state);
876 return ThreadRuntime::get_thread_from_object(h);
906 vm_abort(
"threads_thread_is_alive: unknown thread state %d", state);
1019 #if defined(ENABLE_TLH)
1021 void threads_tlh_add_frame() {
1025 void threads_tlh_remove_frame() {
void write_memory_barrier(void)
int32_t get_priority() const
bool thread_detach_current_external_thread(void)
Detaches the current external thread from the VM.
void gc_unregister_current_thread()
#define STATISTICS(x)
Wrapper for statistics only code.
virtual java_handle_t * get_handle() const
void threads_thread_interrupt(threadobject *t)
void threads_preinit(void)
#define MSET(ptr, byte, type, num)
static uintptr_t pre_compute_thinlock(int32_t index)
Pre-compute the thin lock value for a thread index.
intptr_t threads_get_tid(threadobject *t)
static JavaString from_utf8(Utf8String)
bool thread_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon)
Attaches the current thread to the VM.
void thread_set_state_runnable(threadobject *t)
struct threadobject * flc_list
void thread_set_state_timed_parked(threadobject *t)
bool threads_thread_start_internal(Utf8String name, functionptr f)
static void thread_cleanup_finalizer(java_handle_t *h, void *data)
typedef void(JNICALL *jvmtiEventSingleStep)(jvmtiEnv *jvmti_env
threadobject * get_main_thread()
bool thread_handle_is_interrupted(java_handle_t *th)
static bool thread_is_daemon(threadobject *t)
static int cacaothread_get_state(threadobject *t)
int thread_handle_get_state(java_handle_t *th)
Dummy implementation of a mutex.
static void * attach_custom_finalizer(java_handle_t *h, FinalizerFunc f, void *data)
void threads_impl_thread_clear(threadobject *t)
struct threadobject * flc_next
JNIEnv jclass jobject const char * name
#define GCNEW_UNCOLLECTABLE(type, num)
void threads_set_thread_priority(threadobject *t, int priority)
void release_thread(threadobject *t, bool needs_deactivate)
Release the thread.
static methodinfo * thread_method_init
static bool thread_current_is_attached(void)
int main(int argc, char **argv)
#define DEBUGTHREADS(message, thread)
#define TRACESUBSYSTEMINITIALIZATION(text)
#define MZERO(ptr, type, num)
static void thread_create_initial_thread(void)
java_handle_t * builtin_new(classinfo *c)
void vm_abort(const char *text,...)
static void create_object()
Supposed to be called exactly once, early during initialization.
void(* functionptr)(void)
static java_handle_t * threadgroup_main
static threadobject * thread_new(int32_t flags)
int32_t get_daemon() const
void threads_thread_start(java_handle_t *object)
void tlh_destroy(tlh_t *tlh)
static ThreadList * get()
Provides access to singleton.
java_object_t * _exceptionptr
static bool thread_create_object(threadobject *t, java_handle_t *name, java_handle_t *group)
void thread_set_state_parked(threadobject *t)
intptr_t threads_get_current_tid(void)
void deactivate_thread(threadobject *t)
void threads_impl_thread_start(threadobject *thread, functionptr f)
bool thread_attach_current_external_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon)
Attaches the current external thread to the VM.
void tlh_remove_frame(tlh_t *tlh)
void tlh_init(tlh_t *tlh)
void thread_fprint_name(threadobject *t, FILE *stream)
bool thread_is_interrupted(threadobject *t)
void thread_free(threadobject *t)
Dummy condition variable.
void thread_set_state_terminated(threadobject *t)
void gc_reference_register(java_object_t **ref, int32_t reftype)
void thread_handle_set_priority(java_handle_t *th, int priority)
bool thread_detach_current_thread(void)
Detaches the current thread from the VM.
static java_handle_t * threadgroup_system
threadobject * thread_get_thread(java_handle_t *h)
java_handle_t * flc_object
bool threads_thread_is_alive(threadobject *t)
void add_to_active_thread_list(threadobject *t)
void threads_impl_preinit()
void get_free_thread(threadobject **t, int32_t *index)
Get the next free thread object.
static void thread_set_state(threadobject *t, ThreadState state)
Set the current state of the given thread.
void thread_set_interrupted(threadobject *t, bool interrupted)
u2 filterverbosecallctr[2]
void tlh_add_frame(tlh_t *tlh)
static threadobject * thread_get_current()
Return the threadobject for the current thread.
void thread_set_state_timed_waiting(threadobject *t)
void thread_print_info(threadobject *t)
void unlock()
Unlocks the given mutex object and checks for errors.
GNU Classpath java/lang/Thread.
void thread_set_state_waiting(threadobject *t)
classinfo * class_java_lang_Thread
DumpMemory * _dumpmemory
Dump memory structure.
#define STAT_DECLARE_VAR(type, var, init)
Declare an external statistics variable.
Thread-local dump memory structure.
void gc_register_current_thread()
void lock()
Locks the given mutex object and checks for errors.
void threads_impl_thread_reuse(threadobject *t)
static void thread_set_current(threadobject *t)
Set the threadobject for the current thread.
void thread_handle_interrupt(java_handle_t *th)