Imported Upstream version 4.6.0.243

Former-commit-id: ff34202749e8df2aa83f2578b16260b444f50987
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-09-09 07:19:48 +00:00
parent 804b15604f
commit 3cc9601fd9
113 changed files with 1476 additions and 4439 deletions

View File

@@ -1927,6 +1927,20 @@ mono_domain_assembly_search (MonoAssemblyName *aname,
return NULL;
}
static gboolean
prevent_running_reference_assembly (MonoAssembly *ass, MonoError *error)
{
mono_error_init (error);
gboolean refasm = mono_assembly_get_reference_assembly_attribute (ass, error);
if (!is_ok (error))
return TRUE;
if (refasm) {
mono_error_set_bad_image (error, ass->image, "Could not load file or assembly or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context.\n");
return TRUE;
}
return FALSE;
}
MonoReflectionAssembly *
ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname, MonoBoolean refOnly)
{
@@ -1935,37 +1949,40 @@ ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname, MonoBoolean re
MonoDomain *domain = mono_domain_get ();
char *name, *filename;
MonoImageOpenStatus status = MONO_IMAGE_OK;
MonoAssembly *ass;
MonoAssembly *ass = NULL;
name = NULL;
result = NULL;
mono_error_init (&error);
if (fname == NULL) {
MonoException *exc = mono_get_exception_argument_null ("assemblyFile");
mono_set_pending_exception (exc);
return NULL;
mono_error_set_argument_null (&error, "assemblyFile", "");
goto leave;
}
name = filename = mono_string_to_utf8_checked (fname, &error);
if (mono_error_set_pending_exception (&error))
return NULL;
if (!is_ok (&error))
goto leave;
ass = mono_assembly_open_full (filename, &status, refOnly);
if (!ass) {
MonoException *exc;
if (status == MONO_IMAGE_IMAGE_INVALID)
exc = mono_get_exception_bad_image_format2 (NULL, fname);
mono_error_set_bad_image_name (&error, name, "");
else
exc = mono_get_exception_file_not_found2 (NULL, fname);
g_free (name);
mono_set_pending_exception (exc);
return NULL;
mono_error_set_exception_instance (&error, mono_get_exception_file_not_found2 (NULL, fname));
goto leave;
}
g_free (name);
if (!refOnly && prevent_running_reference_assembly (ass, &error))
goto leave;
result = mono_assembly_get_object_checked (domain, ass, &error);
if (!result)
mono_error_set_pending_exception (&error);
leave:
mono_error_set_pending_exception (&error);
g_free (name);
return result;
}
@@ -2000,6 +2017,11 @@ ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomain *ad,
return NULL;
}
if (!refonly && prevent_running_reference_assembly (ass, &error)) {
mono_error_set_pending_exception (&error);
return NULL;
}
refass = mono_assembly_get_object_checked (domain, ass, &error);
if (!refass)
mono_error_set_pending_exception (&error);
@@ -2017,7 +2039,7 @@ ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad, MonoString *assRef,
MonoAssembly *ass;
MonoAssemblyName aname;
MonoReflectionAssembly *refass = NULL;
gchar *name;
gchar *name = NULL;
gboolean parsed;
g_assert (assRef);
@@ -2026,16 +2048,13 @@ ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad, MonoString *assRef,
if (mono_error_set_pending_exception (&error))
return NULL;
parsed = mono_assembly_name_parse (name, &aname);
g_free (name);
if (!parsed) {
/* This is a parse error... */
if (!refOnly) {
refass = mono_try_assembly_resolve (domain, assRef, NULL, refOnly, &error);
if (!mono_error_ok (&error)) {
mono_error_set_pending_exception (&error);
return NULL;
}
if (!is_ok (&error))
goto leave;
}
return refass;
}
@@ -2047,25 +2066,31 @@ ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad, MonoString *assRef,
/* MS.NET doesn't seem to call the assembly resolve handler for refonly assemblies */
if (!refOnly) {
refass = mono_try_assembly_resolve (domain, assRef, NULL, refOnly, &error);
if (!mono_error_ok (&error)) {
mono_error_set_pending_exception (&error);
return NULL;
}
if (!is_ok (&error))
goto leave;
}
else
refass = NULL;
if (!refass) {
return NULL;
}
if (!refass)
goto leave;
ass = refass->assembly;
}
if (refass == NULL)
refass = mono_assembly_get_object_checked (domain, ass, &error);
if (!refOnly && prevent_running_reference_assembly (ass, &error))
goto leave;
if (refass == NULL)
mono_error_set_pending_exception (&error);
else
MONO_OBJECT_SETREF (refass, evidence, evidence);
g_assert (ass);
if (refass == NULL) {
refass = mono_assembly_get_object_checked (domain, ass, &error);
if (!is_ok (&error))
goto leave;
}
MONO_OBJECT_SETREF (refass, evidence, evidence);
leave:
g_free (name);
mono_error_set_pending_exception (&error);
return refass;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
7bd02ff37eea77a111cb30ce2d3b64953d487736

View File

@@ -424,7 +424,6 @@ on_gc_notification (GC_EventType event)
switch (e) {
case MONO_GC_EVENT_PRE_STOP_WORLD:
MONO_GC_WORLD_STOP_BEGIN ();
mono_thread_info_suspend_lock ();
break;
case MONO_GC_EVENT_POST_STOP_WORLD:
@@ -437,7 +436,6 @@ on_gc_notification (GC_EventType event)
case MONO_GC_EVENT_POST_START_WORLD:
MONO_GC_WORLD_RESTART_END (1);
mono_thread_info_suspend_unlock ();
break;
case MONO_GC_EVENT_START:
@@ -477,7 +475,21 @@ on_gc_notification (GC_EventType event)
}
mono_profiler_gc_event (e, 0);
switch (e) {
case MONO_GC_EVENT_PRE_STOP_WORLD:
mono_thread_info_suspend_lock ();
mono_profiler_gc_event (MONO_GC_EVENT_PRE_STOP_WORLD_LOCKED, 0);
break;
case MONO_GC_EVENT_POST_START_WORLD:
mono_thread_info_suspend_unlock ();
mono_profiler_gc_event (MONO_GC_EVENT_POST_START_WORLD_UNLOCKED, 0);
break;
default:
break;
}
}
static void
on_gc_heap_resize (size_t new_size)
@@ -769,7 +781,7 @@ mono_gc_invoke_finalizers (void)
return 0;
}
gboolean
MonoBoolean
mono_gc_pending_finalizers (void)
{
return GC_should_invoke_finalizers ();

View File

@@ -1 +1 @@
17da478b5e9c1f089d76de0bc275da6ab5e21077
56e12ad673e2765956a4fc89dade62a15656a02f

View File

@@ -697,4 +697,8 @@ mono_runtime_init_checked (MonoDomain *domain, MonoThreadStartCB start_cb, MonoT
void
mono_context_init_checked (MonoDomain *domain, MonoError *error);
gboolean
mono_assembly_get_reference_assembly_attribute (MonoAssembly *assembly, MonoError *error);
#endif /* __MONO_METADATA_DOMAIN_INTERNALS_H__ */

View File

@@ -807,6 +807,16 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
mono_profiler_appdomain_name (domain, domain->friendly_name);
/* Have to do this quite late so that we at least have System.Object */
MonoError custom_attr_error;
if (mono_assembly_get_reference_assembly_attribute (ass, &custom_attr_error)) {
char *corlib_file = g_build_filename (mono_assembly_getrootdir (), "mono", current_runtime->framework_version, "mscorlib.dll", NULL);
g_print ("Could not load file or assembly %s. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context.", corlib_file);
g_free (corlib_file);
exit (1);
}
mono_error_assert_ok (&custom_attr_error);
return domain;
}

View File

@@ -145,10 +145,6 @@ void mono_gchandle_free_domain (MonoDomain *domain);
typedef void (*FinalizerThreadCallback) (gpointer user_data);
/* if there are finalizers to run, run them. Returns the number of finalizers run */
gboolean mono_gc_pending_finalizers (void);
void mono_gc_finalize_notify (void);
void* mono_gc_alloc_pinned_obj (MonoVTable *vtable, size_t size);
void* mono_gc_alloc_obj (MonoVTable *vtable, size_t size);
void* mono_gc_alloc_vector (MonoVTable *vtable, size_t size, uintptr_t max_length);

View File

@@ -263,8 +263,12 @@ mono_gc_run_finalize (void *obj, void *data)
if (log_finalizers)
g_log ("mono-gc-finalizers", G_LOG_LEVEL_MESSAGE, "<%s at %p> Calling finalizer.", o->vtable->klass->name, o);
mono_profiler_gc_finalize_object_begin (o);
runtime_invoke (o, NULL, &exc, NULL);
mono_profiler_gc_finalize_object_end (o);
if (log_finalizers)
g_log ("mono-gc-finalizers", G_LOG_LEVEL_MESSAGE, "<%s at %p> Returned from finalizer.", o->vtable->klass->name, o);
@@ -779,11 +783,15 @@ finalizer_thread (gpointer unused)
}
}
mono_profiler_gc_finalize_begin ();
/* If finished == TRUE, mono_gc_cleanup has been called (from mono_runtime_cleanup),
* before the domain is unloaded.
*/
mono_gc_invoke_finalizers ();
mono_profiler_gc_finalize_end ();
mono_threads_join_threads ();
reference_queue_proccess_all ();

View File

@@ -195,7 +195,7 @@ jit_info_table_chunk_index (MonoJitInfoTableChunk *chunk, MonoThreadHazardPointe
while (left < right) {
int pos = (left + right) / 2;
MonoJitInfo *ji = (MonoJitInfo *)get_hazardous_pointer((gpointer volatile*)&chunk->data [pos], hp, JIT_INFO_HAZARD_INDEX);
MonoJitInfo *ji = (MonoJitInfo *)mono_get_hazardous_pointer((gpointer volatile*)&chunk->data [pos], hp, JIT_INFO_HAZARD_INDEX);
gint8 *code_end = (gint8*)ji->code_start + ji->code_size;
if (addr < code_end)
@@ -228,7 +228,7 @@ jit_info_table_find (MonoJitInfoTable *table, MonoThreadHazardPointers *hp, gint
MonoJitInfoTableChunk *chunk = table->chunks [chunk_pos];
while (pos < chunk->num_elements) {
ji = (MonoJitInfo *)get_hazardous_pointer ((gpointer volatile*)&chunk->data [pos], hp, JIT_INFO_HAZARD_INDEX);
ji = (MonoJitInfo *)mono_get_hazardous_pointer ((gpointer volatile*)&chunk->data [pos], hp, JIT_INFO_HAZARD_INDEX);
++pos;
@@ -286,7 +286,7 @@ mono_jit_info_table_find_internal (MonoDomain *domain, char *addr, gboolean try_
table by a hazard pointer and make sure that the pointer is
still there after we've made it hazardous, we don't have to
worry about the writer freeing the table. */
table = (MonoJitInfoTable *)get_hazardous_pointer ((gpointer volatile*)&domain->jit_info_table, hp, JIT_INFO_TABLE_HAZARD_INDEX);
table = (MonoJitInfoTable *)mono_get_hazardous_pointer ((gpointer volatile*)&domain->jit_info_table, hp, JIT_INFO_TABLE_HAZARD_INDEX);
ji = jit_info_table_find (table, hp, (gint8*)addr);
if (hp)
@@ -298,7 +298,7 @@ mono_jit_info_table_find_internal (MonoDomain *domain, char *addr, gboolean try_
/* Maybe its an AOT module */
if (try_aot && mono_get_root_domain () && mono_get_root_domain ()->aot_modules) {
table = (MonoJitInfoTable *)get_hazardous_pointer ((gpointer volatile*)&mono_get_root_domain ()->aot_modules, hp, JIT_INFO_TABLE_HAZARD_INDEX);
table = (MonoJitInfoTable *)mono_get_hazardous_pointer ((gpointer volatile*)&mono_get_root_domain ()->aot_modules, hp, JIT_INFO_TABLE_HAZARD_INDEX);
module_ji = jit_info_table_find (table, hp, (gint8*)addr);
if (module_ji)
ji = jit_info_find_in_aot_func (domain, module_ji->d.image, addr);

View File

@@ -91,6 +91,39 @@
#endif
#endif
/**
* mono_config_get_os:
*
* Returns the operating system that Mono is running on, as used for dllmap entries.
*/
const char *
mono_config_get_os (void)
{
return CONFIG_OS;
}
/**
* mono_config_get_cpu:
*
* Returns the architecture that Mono is running on, as used for dllmap entries.
*/
const char *
mono_config_get_cpu (void)
{
return CONFIG_CPU;
}
/**
* mono_config_get_wordsize:
*
* Returns the word size that Mono is running on, as used for dllmap entries.
*/
const char *
mono_config_get_wordsize (void)
{
return CONFIG_WORDSIZE;
}
static void start_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,

View File

@@ -13,6 +13,10 @@
MONO_BEGIN_DECLS
MONO_API const char *mono_config_get_os (void);
MONO_API const char *mono_config_get_cpu (void);
MONO_API const char *mono_config_get_wordsize (void);
MONO_API const char* mono_get_config_dir (void);
MONO_API void mono_set_config_dir (const char *dir);

View File

@@ -50,6 +50,8 @@ MONO_API int mono_gc_get_generation (MonoObject *object);
MONO_API int mono_gc_collection_count (int generation);
MONO_API int64_t mono_gc_get_used_size (void);
MONO_API int64_t mono_gc_get_heap_size (void);
MONO_API MonoBoolean mono_gc_pending_finalizers (void);
MONO_API void mono_gc_finalize_notify (void);
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);

View File

@@ -75,6 +75,11 @@ void mono_profiler_gc_moves (void **objects, int num);
void mono_profiler_gc_handle (int op, int type, uintptr_t handle, MonoObject *obj);
void mono_profiler_gc_roots (int num, void **objects, int *root_types, uintptr_t *extra_info);
void mono_profiler_gc_finalize_begin (void);
void mono_profiler_gc_finalize_object_begin (MonoObject *obj);
void mono_profiler_gc_finalize_object_end (MonoObject *obj);
void mono_profiler_gc_finalize_end (void);
void mono_profiler_code_chunk_new (gpointer chunk, int size);
void mono_profiler_code_chunk_destroy (gpointer chunk);
void mono_profiler_code_buffer_new (gpointer buffer, int size, MonoProfilerCodeBufferType type, gconstpointer data);

View File

@@ -102,6 +102,11 @@ struct _ProfilerDesc {
MonoProfileGCHandleFunc gc_handle;
MonoProfileGCRootFunc gc_roots;
MonoProfileGCFinalizeFunc gc_finalize_begin;
MonoProfileGCFinalizeObjectFunc gc_finalize_object_begin;
MonoProfileGCFinalizeObjectFunc gc_finalize_object_end;
MonoProfileGCFinalizeFunc gc_finalize_end;
MonoProfileFunc runtime_initialized_event;
MonoProfilerCodeChunkNew code_chunk_new;
@@ -925,6 +930,50 @@ mono_profiler_install_gc_roots (MonoProfileGCHandleFunc handle_callback, MonoPro
prof_list->gc_roots = roots_callback;
}
void
mono_profiler_gc_finalize_begin (void)
{
for (ProfilerDesc *prof = prof_list; prof; prof = prof->next)
if ((prof->events & MONO_PROFILE_GC_FINALIZATION) && prof->gc_finalize_begin)
prof->gc_finalize_begin (prof->profiler);
}
void
mono_profiler_gc_finalize_object_begin (MonoObject *obj)
{
for (ProfilerDesc *prof = prof_list; prof; prof = prof->next)
if ((prof->events & MONO_PROFILE_GC_FINALIZATION) && prof->gc_finalize_object_begin)
prof->gc_finalize_object_begin (prof->profiler, obj);
}
void
mono_profiler_gc_finalize_object_end (MonoObject *obj)
{
for (ProfilerDesc *prof = prof_list; prof; prof = prof->next)
if ((prof->events & MONO_PROFILE_GC_FINALIZATION) && prof->gc_finalize_object_end)
prof->gc_finalize_object_end (prof->profiler, obj);
}
void
mono_profiler_gc_finalize_end (void)
{
for (ProfilerDesc *prof = prof_list; prof; prof = prof->next)
if ((prof->events & MONO_PROFILE_GC_FINALIZATION) && prof->gc_finalize_end)
prof->gc_finalize_end (prof->profiler);
}
void
mono_profiler_install_gc_finalize (MonoProfileGCFinalizeFunc begin, MonoProfileGCFinalizeObjectFunc begin_obj, MonoProfileGCFinalizeObjectFunc end_obj, MonoProfileGCFinalizeFunc end)
{
if (!prof_list)
return;
prof_list->gc_finalize_begin = begin;
prof_list->gc_finalize_object_begin = begin_obj;
prof_list->gc_finalize_object_begin = end_obj;
prof_list->gc_finalize_end = end;
}
void
mono_profiler_install_runtime_initialized (MonoProfileFunc runtime_initialized_callback)
{

View File

@@ -31,7 +31,8 @@ typedef enum {
MONO_PROFILE_IOMAP_EVENTS = 1 << 18, /* this should likely be removed, too */
MONO_PROFILE_GC_MOVES = 1 << 19,
MONO_PROFILE_GC_ROOTS = 1 << 20,
MONO_PROFILE_CONTEXT_EVENTS = 1 << 21
MONO_PROFILE_CONTEXT_EVENTS = 1 << 21,
MONO_PROFILE_GC_FINALIZATION = 1 << 22
} MonoProfileFlags;
typedef enum {
@@ -39,6 +40,7 @@ typedef enum {
MONO_PROFILE_FAILED
} MonoProfileResult;
// Keep somewhat in sync with libgc/include/gc.h:enum GC_EventType
typedef enum {
MONO_GC_EVENT_START,
MONO_GC_EVENT_MARK_START,
@@ -46,10 +48,26 @@ typedef enum {
MONO_GC_EVENT_RECLAIM_START,
MONO_GC_EVENT_RECLAIM_END,
MONO_GC_EVENT_END,
/*
* This is the actual arrival order of the following events:
*
* MONO_GC_EVENT_PRE_STOP_WORLD
* MONO_GC_EVENT_PRE_STOP_WORLD_LOCKED
* MONO_GC_EVENT_POST_STOP_WORLD
* MONO_GC_EVENT_PRE_START_WORLD
* MONO_GC_EVENT_POST_START_WORLD_UNLOCKED
* MONO_GC_EVENT_POST_START_WORLD
*
* The LOCKED and UNLOCKED events guarantee that, by the time they arrive,
* the GC and suspend locks will both have been acquired and released,
* respectively.
*/
MONO_GC_EVENT_PRE_STOP_WORLD,
MONO_GC_EVENT_POST_STOP_WORLD,
MONO_GC_EVENT_PRE_START_WORLD,
MONO_GC_EVENT_POST_START_WORLD
MONO_GC_EVENT_POST_START_WORLD,
MONO_GC_EVENT_PRE_STOP_WORLD_LOCKED,
MONO_GC_EVENT_POST_START_WORLD_UNLOCKED
} MonoGCEvent;
/* coverage info */
@@ -150,6 +168,9 @@ typedef void (*MonoProfileGCResizeFunc) (MonoProfiler *prof, int64_t new_size)
typedef void (*MonoProfileGCHandleFunc) (MonoProfiler *prof, int op, int type, uintptr_t handle, MonoObject *obj);
typedef void (*MonoProfileGCRootFunc) (MonoProfiler *prof, int num_roots, void **objects, int *root_types, uintptr_t *extra_info);
typedef void (*MonoProfileGCFinalizeFunc) (MonoProfiler *prof);
typedef void (*MonoProfileGCFinalizeObjectFunc) (MonoProfiler *prof, MonoObject *obj);
typedef void (*MonoProfileIomapFunc) (MonoProfiler *prof, const char *report, const char *pathname, const char *new_pathname);
typedef mono_bool (*MonoProfileCoverageFilterFunc) (MonoProfiler *prof, MonoMethod *method);
@@ -197,6 +218,7 @@ MONO_API void mono_profiler_coverage_get (MonoProfiler *prof, MonoMethod *metho
MONO_API void mono_profiler_install_gc (MonoProfileGCFunc callback, MonoProfileGCResizeFunc heap_resize_callback);
MONO_API void mono_profiler_install_gc_moves (MonoProfileGCMoveFunc callback);
MONO_API void mono_profiler_install_gc_roots (MonoProfileGCHandleFunc handle_callback, MonoProfileGCRootFunc roots_callback);
MONO_API void mono_profiler_install_gc_finalize (MonoProfileGCFinalizeFunc begin, MonoProfileGCFinalizeObjectFunc begin_obj, MonoProfileGCFinalizeObjectFunc end_obj, MonoProfileGCFinalizeFunc end);
MONO_API void mono_profiler_install_runtime_initialized (MonoProfileFunc runtime_initialized_callback);
MONO_API void mono_profiler_install_code_chunk_new (MonoProfilerCodeChunkNew callback);

View File

@@ -490,7 +490,7 @@ mono_gc_invoke_finalizers (void)
return sgen_gc_invoke_finalizers ();
}
gboolean
MonoBoolean
mono_gc_pending_finalizers (void)
{
return sgen_have_pending_finalizers ();

View File

@@ -209,6 +209,8 @@ sgen_client_stop_world (int generation)
acquire_gc_locks ();
mono_profiler_gc_event (MONO_GC_EVENT_PRE_STOP_WORLD_LOCKED, generation);
/* We start to scan after locks are taking, this ensures we won't be interrupted. */
sgen_process_togglerefs ();
@@ -283,6 +285,8 @@ sgen_client_restart_world (int generation, gint64 *stw_time)
*/
release_gc_locks ();
mono_profiler_gc_event (MONO_GC_EVENT_POST_START_WORLD_UNLOCKED, generation);
*stw_time = usec;
}

View File

@@ -824,7 +824,7 @@ EXTRA_DIST = TestDriver.cs \
Makefile.am.in
version.h: Makefile
echo "#define FULL_VERSION \"Stable 4.6.0.182/3ed2bba\"" > version.h
echo "#define FULL_VERSION \"Stable 4.6.0.243/dea2155\"" > version.h
# Utility target for patching libtool to speed up linking
patch-libtool:

View File

@@ -824,7 +824,7 @@ EXTRA_DIST = TestDriver.cs \
Makefile.am.in
version.h: Makefile
echo "#define FULL_VERSION \"Stable 4.6.0.182/3ed2bba\"" > version.h
echo "#define FULL_VERSION \"Stable 4.6.0.243/dea2155\"" > version.h
# Utility target for patching libtool to speed up linking
patch-libtool:

Some files were not shown because too many files have changed in this diff Show More