static MonoGHashTable *threads=NULL;
/* List of app context GC handles.
- * Added to from ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext ().
+ * Added to from mono_threads_register_app_context ().
*/
static GHashTable *contexts = NULL;
start_info = (StartInfo*) data;
g_assert (start_info);
- info = mono_thread_info_attach (&res);
+ info = mono_thread_info_attach ();
info->runtime_thread = TRUE;
/* Run the actual main function of the thread */
- res = start_wrapper_internal (start_info, &res);
+ res = start_wrapper_internal (start_info, info->stack_end);
mono_thread_info_exit (res);
MonoThread *thread;
MonoThreadInfo *info;
MonoNativeThreadId tid;
- gsize stack_ptr;
if (mono_thread_internal_current_is_attached ()) {
if (domain != mono_domain_get ())
return mono_thread_current ();
}
- info = mono_thread_info_attach (&stack_ptr);
+ info = mono_thread_info_attach ();
g_assert (info);
tid=mono_native_thread_id_get ();
THREAD_DEBUG (g_message ("%s: Attached thread ID %"G_GSIZE_FORMAT" (handle %p)", __func__, tid, internal->handle));
- if (mono_thread_attach_cb) {
- guint8 *staddr;
- size_t stsize;
-
- mono_thread_info_get_stack_bounds (&staddr, &stsize);
-
- if (staddr == NULL)
- mono_thread_attach_cb (MONO_NATIVE_THREAD_ID_TO_UINT (tid), &stack_ptr);
- else
- mono_thread_attach_cb (MONO_NATIVE_THREAD_ID_TO_UINT (tid), staddr + stsize);
- }
+ if (mono_thread_attach_cb)
+ mono_thread_attach_cb (MONO_NATIVE_THREAD_ID_TO_UINT (tid), info->stack_end);
/* Can happen when we attach the profiler helper thread in order to heapshot. */
if (!mono_thread_info_current ()->tools_thread)
}
void
-ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext (MonoAppContext *ctx)
+mono_threads_register_app_context (MonoAppContext *ctx, MonoError *error)
{
+ error_init (error);
mono_threads_lock ();
//g_print ("Registering context %d in domain %d\n", ctx->context_id, ctx->domain_id);
}
void
-ves_icall_System_Runtime_Remoting_Contexts_Context_ReleaseContext (MonoAppContext *ctx)
+ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext (MonoAppContextHandle ctx, MonoError *error)
+{
+ error_init (error);
+ mono_threads_register_app_context (MONO_HANDLE_RAW (ctx), error); /* FIXME use handles in mono_threads_register_app_context */
+}
+
+void
+mono_threads_release_app_context (MonoAppContext* ctx, MonoError *error)
{
/*
* NOTE: Since finalizers are unreliable for the purposes of ensuring
mono_profiler_context_unloaded (ctx);
}
+void
+ves_icall_System_Runtime_Remoting_Contexts_Context_ReleaseContext (MonoAppContextHandle ctx, MonoError *error)
+{
+ error_init (error);
+ mono_threads_release_app_context (MONO_HANDLE_RAW (ctx), error); /* FIXME use handles in mono_threads_release_app_context */
+}
+
void mono_thread_init (MonoThreadStartCB start_cb,
MonoThreadAttachCB attach_cb)
{
sf->il_offset = location->il_offset;
if (location && location->source_file) {
- MONO_OBJECT_SETREF (sf, filename, mono_string_new (domain, location->source_file));
+ MonoString *filename = mono_string_new_checked (domain, location->source_file, error);
+ if (!is_ok (error))
+ goto leave;
+ MONO_OBJECT_SETREF (sf, filename, filename);
sf->line = location->row;
sf->column = location->column;
}
gboolean
mono_threads_abort_appdomain_threads (MonoDomain *domain, int timeout)
{
-#ifdef __native_client__
- return FALSE;
-#endif
-
abort_appdomain_data user_data;
gint64 start_time;
int orig_timeout = timeout;
LOCK_THREAD (thread);
/* MonoThread::interruption_requested can only be changed with atomics */
- if (mono_thread_clear_interruption_requested (thread)) {
- /* this will consume pending APC calls */
+ if (!mono_thread_clear_interruption_requested (thread)) {
+ UNLOCK_THREAD (thread);
+ return NULL;
+ }
+
+ /* this will consume pending APC calls */
#ifdef HOST_WIN32
- WaitForSingleObjectEx (GetCurrentThread(), 0, TRUE);
+ WaitForSingleObjectEx (GetCurrentThread(), 0, TRUE);
#endif
- /* Clear the interrupted flag of the thread so it can wait again */
- mono_thread_info_clear_self_interrupt ();
- }
+ /* Clear the interrupted flag of the thread so it can wait again */
+ mono_thread_info_clear_self_interrupt ();
/* If there's a pending exception and an AbortRequested, the pending exception takes precedence */
if (sys_thread->pending_exception) {