Merge pull request #4444 from lateralusX/jlorenss/windows-unwind-info
[mono.git] / mono / mini / aot-compiler.c
index 864d0b247c2bbebacaa2927b5c55ae19929711bd..22dc64f95197ac60691c4a89eac17f793438fc2f 100644 (file)
@@ -5246,11 +5246,11 @@ compute_line_numbers (MonoMethod *method, int code_size, MonoDebugMethodJitInfo
                if (il_offset == -1 || il_offset == prev_il_offset)
                        continue;
                prev_il_offset = il_offset;
-               loc = mono_debug_symfile_lookup_location (minfo, il_offset);
+               loc = mono_debug_method_lookup_location (minfo, il_offset);
                if (!(loc && loc->source_file))
                        continue;
                if (loc->row == prev_line) {
-                       mono_debug_symfile_free_location (loc);
+                       mono_debug_free_source_location (loc);
                        continue;
                }
                prev_line = loc->row;
@@ -5349,7 +5349,7 @@ emit_and_reloc_code (MonoAotCompile *acfg, MonoMethod *method, guint8 *code, gui
                                options = "";
                        prologue_end = TRUE;
                        fprintf (acfg->fp, ".loc %d %d 0%s\n", findex, loc->row, options);
-                       mono_debug_symfile_free_location (loc);
+                       mono_debug_free_source_location (loc);
                }
 
                skip = FALSE;
@@ -7892,14 +7892,13 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
 static mono_thread_start_return_t WINAPI
 compile_thread_main (gpointer user_data)
 {
-       MonoDomain *domain = ((MonoDomain **)user_data) [0];
-       MonoAotCompile *acfg = ((MonoAotCompile **)user_data) [1];
-       GPtrArray *methods = ((GPtrArray **)user_data) [2];
+       MonoAotCompile *acfg = ((MonoAotCompile **)user_data) [0];
+       GPtrArray *methods = ((GPtrArray **)user_data) [1];
        int i;
 
        MonoError error;
-       MonoThread *thread = mono_thread_attach (domain);
-       mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "AOT compiler"), TRUE, FALSE, &error);
+       MonoInternalThread *internal = mono_thread_internal_current ();
+       mono_thread_set_name_internal (internal, mono_string_new (mono_domain_get (), "AOT compiler"), TRUE, FALSE, &error);
        mono_error_assert_ok (&error);
 
        for (i = 0; i < methods->len; ++i)
@@ -9869,6 +9868,9 @@ compile_methods (MonoAotCompile *acfg)
                        methods [i] = (MonoMethod *)g_ptr_array_index (acfg->methods, i);
                i = 0;
                while (i < methods_len) {
+                       MonoError error;
+                       MonoInternalThread *thread;
+
                        frag = g_ptr_array_new ();
                        for (j = 0; j < len; ++j) {
                                if (i < methods_len) {
@@ -9878,11 +9880,13 @@ compile_methods (MonoAotCompile *acfg)
                        }
 
                        user_data = g_new0 (gpointer, 3);
-                       user_data [0] = mono_domain_get ();
-                       user_data [1] = acfg;
-                       user_data [2] = frag;
+                       user_data [0] = acfg;
+                       user_data [1] = frag;
                        
-                       thread_handle = mono_threads_create_thread (compile_thread_main, (gpointer) user_data, NULL, NULL);
+                       thread = mono_thread_create_internal (mono_domain_get (), compile_thread_main, (gpointer) user_data, MONO_THREAD_CREATE_FLAGS_NONE, &error);
+                       mono_error_assert_ok (&error);
+
+                       thread_handle = mono_threads_open_thread_handle (thread->handle);
                        g_ptr_array_add (threads, thread_handle);
                }
                g_free (methods);