Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/mono/mono/metadata/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,17 +999,32 @@ finalizer_thread (gpointer unused)
return 0;
}

#ifndef LAZY_GC_THREAD_CREATION
static
#endif
void
mono_gc_init_finalizer_thread (void)
static void
init_finalizer_thread (void)
{
ERROR_DECL (error);
gc_thread = mono_thread_create_internal (mono_domain_get (), (gpointer)finalizer_thread, NULL, MONO_THREAD_CREATE_FLAGS_NONE, error);
mono_error_assert_ok (error);
}

/**
* mono_gc_init_finalizer_thread:
*
* If the runtime is compiled with --with-lazy-gc-thread-creation, this
* function must be called by embedders to create the finalizer. Otherwise, the
* function does nothing and the runtime creates the finalizer thread
* automatically.
*/
void
mono_gc_init_finalizer_thread (void)
{
#ifndef LAZY_GC_THREAD_CREATION
/* do nothing */
#else
init_finalizer_thread ();
#endif
}

static void
reference_queue_mutex_init (void)
{
Expand Down Expand Up @@ -1048,7 +1063,7 @@ mono_gc_init (void)

#ifndef LAZY_GC_THREAD_CREATION
if (!mono_runtime_get_no_exec ())
mono_gc_init_finalizer_thread ();
init_finalizer_thread ();
#endif
}

Expand Down
3 changes: 3 additions & 0 deletions src/mono/mono/metadata/mono-gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ MONO_API int mono_gc_invoke_finalizers (void);
/* heap walking is only valid in the pre-stop-world event callback */
MONO_API int mono_gc_walk_heap (int flags, MonoGCReferences callback, void *data);

MONO_API MONO_RT_EXTERNAL_ONLY void
mono_gc_init_finalizer_thread (void);

MONO_END_DECLS

#endif /* __METADATA_MONO_GC_H__ */
Expand Down
1 change: 1 addition & 0 deletions src/mono/mono/mini/aot-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#include "aot-runtime.h"
#include "jit-icalls.h"
#include "mini-runtime.h"
#include "mono-private-unstable.h"
#include "llvmonly-runtime.h"

#ifndef DISABLE_AOT
Expand Down
10 changes: 0 additions & 10 deletions src/mono/mono/mini/aot-runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,6 @@ gboolean mono_aot_init_llvmonly_method (gpointer amodule, guint32 method_in
GHashTable *mono_aot_get_weak_field_indexes (MonoImage *image);
MonoAotMethodFlags mono_aot_get_method_flags (guint8 *code);

/* These are used to load the AOT data for aot images compiled with MONO_AOT_FILE_FLAG_SEPARATE_DATA */
/*
* Return the AOT data for ASSEMBLY. SIZE is the size of the data. OUT_HANDLE should be set to a handle which is later
* passed to the free function.
*/
typedef unsigned char* (*MonoLoadAotDataFunc) (MonoAssembly *assembly, int size, gpointer user_data, void **out_handle);
/* Not yet used */
typedef void (*MonoFreeAotDataFunc) (MonoAssembly *assembly, int size, gpointer user_data, void *handle);
MONO_API void mono_install_load_aot_data_hook (MonoLoadAotDataFunc load_func, MonoFreeAotDataFunc free_func, gpointer user_data);

#ifdef MONO_ARCH_CODE_EXEC_ONLY
typedef guint32 (*MonoAotResolvePltInfoOffset)(gpointer amodule, guint32 plt_entry_index);
#endif
Expand Down
1 change: 0 additions & 1 deletion src/mono/mono/mini/jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ mono_aot_register_module (void **aot_info);
MONO_API MONO_RT_EXTERNAL_ONLY
MonoDomain* mono_jit_thread_attach (MonoDomain *domain);


MONO_END_DECLS

#endif
Expand Down
12 changes: 11 additions & 1 deletion src/mono/mono/mini/mono-private-unstable.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@
#define __MONO_JIT_MONO_PRIVATE_UNSTABLE_H__

#include <mono/utils/mono-publib.h>
#include <mono/metadata/image.h>


/* These are used to load the AOT data for aot images compiled with MONO_AOT_FILE_FLAG_SEPARATE_DATA */
/*
* Return the AOT data for ASSEMBLY. SIZE is the size of the data. OUT_HANDLE should be set to a handle which is later
* passed to the free function.
*/
typedef unsigned char* (*MonoLoadAotDataFunc) (MonoAssembly *assembly, int size, void* user_data, void **out_handle);
/* Not yet used */
typedef void (*MonoFreeAotDataFunc) (MonoAssembly *assembly, int size, void* user_data, void *handle);
MONO_API MONO_RT_EXTERNAL_ONLY void
mono_install_load_aot_data_hook (MonoLoadAotDataFunc load_func, MonoFreeAotDataFunc free_func, void* user_data);

#endif /*__MONO_JIT_MONO_PRIVATE_UNSTABLE_H__*/
7 changes: 7 additions & 0 deletions src/mono/mono/utils/mono-logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ mono_trace_set_log_handler (MonoLogCallback callback, void *user_data)
{
g_assert (callback);

if (level_stack == NULL)
mono_trace_init ();

if (logCallback.closer != NULL)
logCallback.closer();
UserSuppliedLoggerUserData *ll = (UserSuppliedLoggerUserData*)g_malloc (sizeof (UserSuppliedLoggerUserData));
Expand Down Expand Up @@ -514,6 +517,8 @@ void
mono_trace_set_print_handler (MonoPrintCallback callback)
{
g_assert (callback);
if (level_stack == NULL)
mono_trace_init ();
print_callback = callback;
g_set_print_handler (print_handler);
}
Expand All @@ -527,6 +532,8 @@ void
mono_trace_set_printerr_handler (MonoPrintCallback callback)
{
g_assert (callback);
if (level_stack == NULL)
mono_trace_init ();
printerr_callback = callback;
g_set_printerr_handler (printerr_handler);
}
Expand Down
10 changes: 2 additions & 8 deletions src/mono/netcore/sample/iOS/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,17 @@
#include <mono/utils/mono-logger.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/mono-gc.h>
#include <mono/metadata/exception.h>
#include <mono/jit/jit.h>
#include <mono/jit/mono-private-unstable.h>

#import <os/log.h>
#include <sys/stat.h>
#include <sys/mman.h>

static os_log_t stdout_log;

/* These are not in public headers */
typedef unsigned char* (*MonoLoadAotDataFunc) (MonoAssembly *assembly, int size, void *user_data, void **out_handle);
typedef void (*MonoFreeAotDataFunc) (MonoAssembly *assembly, int size, void *user_data, void *handle);
void mono_install_load_aot_data_hook (MonoLoadAotDataFunc load_func, MonoFreeAotDataFunc free_func, void *user_data);
void mono_trace_init (void);
void mono_gc_init_finalizer_thread (void);

static char *bundle_path;

const char *
Expand Down Expand Up @@ -272,7 +267,6 @@ void mono_ios_setup_execution_mode (void)
mono_install_assembly_preload_hook (assembly_preload_hook, NULL);
mono_install_load_aot_data_hook (load_aot_data, free_aot_data, NULL);
mono_install_unhandled_exception_hook (unhandled_exception_handler, NULL);
mono_trace_init ();
mono_trace_set_log_handler (log_callback, NULL);
mono_set_signal_chaining (TRUE);
mono_set_crash_chaining (TRUE);
Expand Down