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
93 changes: 46 additions & 47 deletions src/mono/mono/component/hot_reload.c

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/mono/mono/eglib/glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,8 @@ __CAST_PTRTYPE_TO_UTYPE(gintptr, gulong, ULONG_MAX)
__CAST_PTRTYPE_TO_STYPE(gintptr, gint, INT_MIN, INT_MAX)
__CAST_PTRTYPE_TO_UTYPE(gintptr, guint, UINT_MAX)

__CAST_PTRTYPE_TO_UTYPE(gintptr, gsize, SIZE_MAX)

__CAST_PTRTYPE_TO_STYPE(guintptr, gint32, INT32_MIN, INT32_MAX)
__CAST_PTRTYPE_TO_UTYPE(guintptr, guint32, UINT32_MAX)
__CAST_PTRTYPE_TO_STYPE(guintptr, gint16, INT16_MIN, INT16_MAX)
Expand Down Expand Up @@ -1443,6 +1445,9 @@ __CAST_STYPE_TO_UTYPE(gssize, guint, UINT_MAX)
__CAST_STYPE_TO_UTYPE(gssize, gsize, SIZE_MAX)
__CAST_UTYPE_TO_STYPE(gsize, gssize, PTRDIFF_MIN, PTRDIFF_MAX)

__CAST_STYPE_TO_UTYPE(glong, gulong, ULONG_MAX)
__CAST_UTYPE_TO_STYPE(gulong, glong, LONG_MIN, LONG_MAX)

__CAST_STYPE_TO_STYPE(gdouble, gint64, INT64_MIN, INT64_MAX)
__CAST_STYPE_TO_UTYPE(gdouble, guint64, UINT64_MAX)
__CAST_STYPE_TO_STYPE(gdouble, gint32, INT32_MIN, INT32_MAX)
Expand Down Expand Up @@ -1588,6 +1593,8 @@ __CAST_UTYPE_TO_STYPE(gunichar, gchar, CHAR_MIN, CHAR_MAX)
#define GINTPTR_TO_INT(v) G_CAST_PTRTYPE_TO_STYPE(gintptr, gint, v)
#define GINTPTR_TO_UINT(v) G_CAST_PTRTYPE_TO_UTYPE(gintptr, guint, v)

#define GINTPTR_TO_SIZE(v) G_CAST_PTRTYPE_TO_UTYPE(gintptr, gsize, v)

#define GUINTPTR_TO_INT32(v) G_CAST_PTRTYPE_TO_STYPE(guintptr, gint32, v)
#define GUINTPTR_TO_UINT32(v) G_CAST_PTRTYPE_TO_UTYPE(guintptr, guint32, v)

Expand Down Expand Up @@ -1624,6 +1631,9 @@ __CAST_UTYPE_TO_STYPE(gunichar, gchar, CHAR_MIN, CHAR_MAX)
#define GSSIZE_TO_SIZE(v) G_CAST_TYPE_TO_TYPE(gssize, gsize, v)
#define GSIZE_TO_SSIZE(v) G_CAST_TYPE_TO_TYPE(gsize, gssize, v)

#define GLONG_TO_ULONG(v) G_CAST_TYPE_TO_TYPE(glong, gulong, v)
#define GULONG_TO_LONG(v) G_CAST_TYPE_TO_TYPE(gulong, glong, v)

#define GDOUBLE_TO_INT64(v) G_CAST_TYPE_TO_TYPE(gdouble, gint64, v)
#define GDOUBLE_TO_UINT64(v) G_CAST_TYPE_TO_TYPE(gdouble, guint64, v)
#define GDOUBLE_TO_INT32(v) G_CAST_TYPE_TO_TYPE(gdouble, gint32, v)
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/metadata/assembly-load-context.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ ves_icall_System_Runtime_Loader_AssemblyLoadContext_InternalGetLoadedAssemblies

MonoArrayHandle res = mono_array_new_handle (mono_class_get_assembly_class (), assemblies->len, error);
goto_if_nok (error, leave);
for (int i = 0; i < assemblies->len; ++i) {
for (guint i = 0; i < assemblies->len; ++i) {
if (!add_assembly_to_array (res, i, (MonoAssembly *)g_ptr_array_index (assemblies, i), error))
goto leave;
}
Expand Down
3 changes: 1 addition & 2 deletions src/mono/mono/metadata/assembly.c
Original file line number Diff line number Diff line change
Expand Up @@ -2915,9 +2915,8 @@ mono_assembly_release_gc_roots (MonoAssembly *assembly)
return;

if (assembly_is_dynamic (assembly)) {
int i;
MonoDynamicImage *dynimg = (MonoDynamicImage *)assembly->image;
for (i = 0; i < dynimg->image.module_count; ++i)
for (guint32 i = 0; i < dynimg->image.module_count; ++i)
mono_dynamic_image_release_gc_roots ((MonoDynamicImage *)dynimg->image.modules [i]);
mono_dynamic_image_release_gc_roots (dynimg);
}
Expand Down
5 changes: 2 additions & 3 deletions src/mono/mono/metadata/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -3233,7 +3233,6 @@ search_modules (MonoImage *image, const char *name_space, const char *name, gboo
MonoTableInfo *file_table = &image->tables [MONO_TABLE_FILE];
MonoImage *file_image;
MonoClass *klass;
int i;

error_init (error);

Expand All @@ -3243,8 +3242,8 @@ search_modules (MonoImage *image, const char *name_space, const char *name, gboo
* Note: image->modules contains the contents of the MODULEREF table, while
* the real module list is in the FILE table.
*/
int rows = table_info_get_rows (file_table);
for (i = 0; i < rows; i++) {
guint32 rows = table_info_get_rows (file_table);
for (guint32 i = 0; i < rows; i++) {
guint32 cols [MONO_FILE_SIZE];
mono_metadata_decode_row (file_table, i, cols, MONO_FILE_SIZE);
if (cols [MONO_FILE_FLAGS] == FILE_CONTAINS_NO_METADATA)
Expand Down
21 changes: 9 additions & 12 deletions src/mono/mono/metadata/custom-attrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,9 @@ find_field_index (MonoClass *klass, MonoClassField *field) {
static guint32
find_property_index (MonoClass *klass, MonoProperty *property)
{
int i;
MonoClassPropertyInfo *info = mono_class_get_property_info (klass);

for (i = 0; i < info->count; ++i) {
for (guint32 i = 0; i < info->count; ++i) {
if (property == &info->properties [i])
return info->first + 1 + i;
}
Expand All @@ -185,10 +184,9 @@ find_property_index (MonoClass *klass, MonoProperty *property)
static guint32
find_event_index (MonoClass *klass, MonoEvent *event)
{
int i;
MonoClassEventInfo *info = mono_class_get_event_info (klass);

for (i = 0; i < info->count; ++i) {
for (guint32 i = 0; i < info->count; ++i) {
if (event == &info->events [i])
return info->first + 1 + i;
}
Expand Down Expand Up @@ -1631,7 +1629,6 @@ ves_icall_System_Reflection_RuntimeCustomAttributeData_ResolveArgumentsInternal
MonoReflectionAssembly *assembly = MONO_HANDLE_RAW (assembly_h);
MonoMethodSignature *sig;
MonoObjectHandle obj_h, namedarg_h, minfo_h;
int i;

if (len == 0)
return;
Expand All @@ -1658,7 +1655,7 @@ ves_icall_System_Reflection_RuntimeCustomAttributeData_ResolveArgumentsInternal
goto leave;

sig = mono_method_signature_internal (method);
for (i = 0; i < sig->param_count; ++i) {
for (guint16 i = 0; i < sig->param_count; ++i) {
MonoObject *obj;
MonoObject *typedarg;
MonoType *t;
Expand All @@ -1674,7 +1671,7 @@ ves_icall_System_Reflection_RuntimeCustomAttributeData_ResolveArgumentsInternal
mono_array_setref_internal (typed_args, i, typedarg);
}

for (i = 0; i < mono_array_length_internal (named_args); ++i) {
for (guint32 i = 0; i < mono_array_length_internal (named_args); ++i) {
MonoObject *obj;
MonoObject *namedarg, *minfo;

Expand Down Expand Up @@ -2761,7 +2758,7 @@ metadata_foreach_custom_attr_from_index (MonoImage *image, guint32 idx, MonoAsse
return;
i --;
gboolean stop_iterating = FALSE;
int rows = table_info_get_rows (ca);
guint32 rows = table_info_get_rows (ca);
while (!stop_iterating && i < rows) {
if (mono_metadata_decode_row_col (ca, i, MONO_CUSTOM_ATTR_PARENT) != idx)
break;
Expand Down Expand Up @@ -2878,8 +2875,8 @@ init_weak_fields_inner (MonoImage *image, GHashTable *indexes)

tdef = &image->tables [MONO_TABLE_CUSTOMATTRIBUTE];
guint32 parent, field_idx, col, mtoken, idx;
int rows = table_info_get_rows (tdef);
for (int i = 0; i < rows; ++i) {
guint32 rows = table_info_get_rows (tdef);
for (guint32 i = 0; i < rows; ++i) {
parent = mono_metadata_decode_row_col (tdef, i, MONO_CUSTOM_ATTR_PARENT);
if ((parent & MONO_CUSTOM_ATTR_MASK) != MONO_CUSTOM_ATTR_FIELDDEF)
continue;
Expand All @@ -2903,8 +2900,8 @@ init_weak_fields_inner (MonoImage *image, GHashTable *indexes)
/* Check whenever the assembly references the WeakAttribute type */
gboolean found = FALSE;
tdef = &image->tables [MONO_TABLE_TYPEREF];
int rows = table_info_get_rows (tdef);
for (int i = 0; i < rows; ++i) {
guint32 rows = table_info_get_rows (tdef);
for (guint32 i = 0; i < rows; ++i) {
guint32 string_offset = mono_metadata_decode_row_col (tdef, i, MONO_TYPEREF_NAME);
const char *name = mono_metadata_string_heap (image, string_offset);
if (!strcmp (name, "WeakAttribute")) {
Expand Down
15 changes: 5 additions & 10 deletions src/mono/mono/metadata/debug-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ mono_custom_modifiers_get_desc (GString *res, const MonoType *type, gboolean inc
void
mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace)
{
int i;

switch (type->type) {
case MONO_TYPE_VOID:
g_string_append (res, "void"); break;
Expand Down Expand Up @@ -177,7 +175,7 @@ mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace)
case MONO_TYPE_ARRAY:
mono_type_get_desc (res, &type->data.array->eklass->_byval_arg, include_namespace);
g_string_append_c (res, '[');
for (i = 1; i < type->data.array->rank; ++i)
for (guint8 i = 1; i < type->data.array->rank; ++i)
g_string_append_c (res, ',');
g_string_append_c (res, ']');
break;
Expand All @@ -196,7 +194,7 @@ mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace)
g_string_append (res, "<");
context = &type->data.generic_class->context;
if (context->class_inst) {
for (i = 0; i < context->class_inst->type_argc; ++i) {
for (guint i = 0; i < context->class_inst->type_argc; ++i) {
if (i > 0)
g_string_append (res, ", ");
mono_type_get_desc (res, context->class_inst->type_argv [i], include_namespace);
Expand All @@ -205,7 +203,7 @@ mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace)
if (context->method_inst) {
if (context->class_inst)
g_string_append (res, "; ");
for (i = 0; i < context->method_inst->type_argc; ++i) {
for (guint i = 0; i < context->method_inst->type_argc; ++i) {
if (i > 0)
g_string_append (res, ", ");
mono_type_get_desc (res, context->method_inst->type_argv [i], include_namespace);
Expand Down Expand Up @@ -305,9 +303,7 @@ mono_signature_full_name (MonoMethodSignature *sig)
void
mono_ginst_get_desc (GString *str, MonoGenericInst *ginst)
{
int i;

for (i = 0; i < ginst->type_argc; ++i) {
for (guint i = 0; i < ginst->type_argc; ++i) {
if (i > 0)
g_string_append (str, ", ");
mono_type_get_desc (str, ginst->type_argv [i], TRUE);
Expand Down Expand Up @@ -599,7 +595,6 @@ mono_method_desc_search_in_image (MonoMethodDesc *desc, MonoImage *image)
MonoClass *klass;
const MonoTableInfo *methods;
MonoMethod *method;
int i;

/* Handle short names for system classes */
if (!desc->name_space && image == mono_defaults.corlib) {
Expand All @@ -618,7 +613,7 @@ mono_method_desc_search_in_image (MonoMethodDesc *desc, MonoImage *image)
/* FIXME: Is this call necessary? We don't use its result. */
mono_image_get_table_info (image, MONO_TABLE_TYPEDEF);
methods = mono_image_get_table_info (image, MONO_TABLE_METHOD);
for (i = 0; i < mono_table_info_get_rows (methods); ++i) {
for (guint32 i = 0; i < table_info_get_rows (methods); ++i) {
ERROR_DECL (error);
guint32 token = mono_metadata_decode_row_col (methods, i, MONO_METHOD_NAME);
const char *n = mono_metadata_string_heap (image, token);
Expand Down
22 changes: 11 additions & 11 deletions src/mono/mono/metadata/debug-mono-ppdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ get_pe_debug_info (MonoImage *image, guint8 *out_guid, gint32 *out_age, gint32 *
{
MonoPEDirEntry *debug_dir_entry;
ImageDebugDirectory debug_dir;
int idx;
gboolean guid_found = FALSE;
guint8 *data;

Expand All @@ -77,7 +76,7 @@ get_pe_debug_info (MonoImage *image, guint8 *out_guid, gint32 *out_age, gint32 *
return FALSE;

int offset = mono_cli_rva_image_map (image, debug_dir_entry->rva);
for (idx = 0; idx < debug_dir_entry->size / sizeof (ImageDebugDirectory); ++idx) {
for (guint32 idx = 0; idx < debug_dir_entry->size / sizeof (ImageDebugDirectory); ++idx) {
data = (guint8 *) ((ImageDebugDirectory *) (image->raw_data + offset) + idx);
debug_dir.characteristics = read32(data);
debug_dir.time_date_stamp = read32(data + 4);
Expand Down Expand Up @@ -362,7 +361,8 @@ mono_ppdb_lookup_location_internal (MonoImage *image, int idx, uint32_t offset,
const char *ptr;
const char *end;
char *docname = NULL;
int size, docidx, iloffset, delta_il, delta_lines, delta_cols, start_line, start_col, adv_line, adv_col;
int size, docidx, delta_lines, delta_cols, start_line, start_col, adv_line, adv_col;
guint32 iloffset;
gboolean first = TRUE, first_non_hidden = TRUE;
MonoDebugSourceLocation *location;

Expand All @@ -386,7 +386,7 @@ mono_ppdb_lookup_location_internal (MonoImage *image, int idx, uint32_t offset,
start_line = 0;
start_col = 0;
while (ptr < end) {
delta_il = mono_metadata_decode_value (ptr, &ptr);
guint32 delta_il = mono_metadata_decode_value (ptr, &ptr);
if (!first && delta_il == 0) {
/* document-record */
docidx = mono_metadata_decode_value (ptr, &ptr);
Expand Down Expand Up @@ -493,7 +493,7 @@ mono_ppdb_get_seq_points_internal (MonoImage *image, MonoPPDBFile *ppdb, MonoMet
return -1;

MonoTableInfo *methodbody_table = &tables [MONO_TABLE_METHODBODY];
if (G_UNLIKELY (method_idx - 1 >= table_info_get_rows (methodbody_table))) {
if (G_UNLIKELY (GINT_TO_UINT32(method_idx) - 1 >= table_info_get_rows (methodbody_table))) {
char *method_name = mono_method_full_name (method, FALSE);
g_error ("Method idx %d is greater than number of rows (%d) in PPDB MethodDebugInformation table, for method %s in '%s'. Likely a malformed PDB file.",
method_idx - 1, table_info_get_rows (methodbody_table), method_name, image->name);
Expand Down Expand Up @@ -625,7 +625,7 @@ mono_ppdb_lookup_locals_internal (MonoImage *image, int method_idx)
guint32 cols [MONO_LOCALSCOPE_SIZE];
guint32 locals_cols [MONO_LOCALVARIABLE_SIZE];

int i, lindex, sindex, locals_idx, locals_end_idx, nscopes, start_scope_idx, scope_idx;
guint32 lindex, locals_idx, locals_end_idx, nscopes, start_scope_idx, scope_idx;

start_scope_idx = mono_metadata_localscope_from_methoddef (image, method_idx);

Expand All @@ -651,7 +651,7 @@ mono_ppdb_lookup_locals_internal (MonoImage *image, int method_idx)
// this endpoint becomes locals_end_idx below

// March to the last scope that is in this method
int rows = table_info_get_rows (&tables [MONO_TABLE_LOCALSCOPE]);
guint32 rows = table_info_get_rows (&tables [MONO_TABLE_LOCALSCOPE]);
while (scope_idx <= rows) {
mono_metadata_decode_row (&tables [MONO_TABLE_LOCALSCOPE], scope_idx-1, cols, MONO_LOCALSCOPE_SIZE);
if (cols [MONO_LOCALSCOPE_METHOD] != method_idx)
Expand Down Expand Up @@ -680,7 +680,7 @@ mono_ppdb_lookup_locals_internal (MonoImage *image, int method_idx)
res->locals = g_new0 (MonoDebugLocalVar, res->num_locals);

lindex = 0;
for (sindex = 0; sindex < nscopes; ++sindex) {
for (guint32 sindex = 0; sindex < nscopes; ++sindex) {
scope_idx = start_scope_idx + sindex;
mono_metadata_decode_row (&tables [MONO_TABLE_LOCALSCOPE], scope_idx-1, cols, MONO_LOCALSCOPE_SIZE);

Expand All @@ -696,7 +696,7 @@ mono_ppdb_lookup_locals_internal (MonoImage *image, int method_idx)

//printf ("Scope: %s %d %d %d-%d\n", mono_method_full_name (method, 1), cols [MONO_LOCALSCOPE_STARTOFFSET], cols [MONO_LOCALSCOPE_LENGTH], locals_idx, locals_end_idx);

for (i = locals_idx; i < locals_end_idx; ++i) {
for (guint32 i = locals_idx; i < locals_end_idx; ++i) {
mono_metadata_decode_row (&tables [MONO_TABLE_LOCALVARIABLE], i - 1, locals_cols, MONO_LOCALVARIABLE_SIZE);

res->locals [lindex].name = g_strdup (mono_metadata_string_heap (image, locals_cols [MONO_LOCALVARIABLE_NAME]));
Expand Down Expand Up @@ -743,8 +743,8 @@ mono_ppdb_lookup_locals (MonoDebugMethodInfo *minfo)
* We use this to pass context information to the row locator
*/
typedef struct {
int idx; /* The index that we are trying to locate */
int col_idx; /* The index in the row where idx may be stored */
guint32 idx; /* The index that we are trying to locate */
guint32 col_idx; /* The index in the row where idx may be stored */
MonoTableInfo *t; /* pointer to the table */
guint32 result;
} locator_t;
Expand Down
3 changes: 1 addition & 2 deletions src/mono/mono/metadata/dynamic-image.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,12 @@ MonoImage *
mono_find_dynamic_image_owner (void *ptr)
{
MonoImage *owner = NULL;
int i;

dynamic_images_lock ();

if (dynamic_images)
{
for (i = 0; !owner && i < dynamic_images->len; ++i) {
for (guint i = 0; !owner && i < dynamic_images->len; ++i) {
MonoImage *image = (MonoImage *)g_ptr_array_index (dynamic_images, i);
if (mono_mempool_contains_addr (image->mempool, ptr))
owner = image;
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/metadata/dynamic-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mono_dynstream_init (MonoDynamicStream *sh)
}

static void
make_room_in_stream (MonoDynamicStream *stream, int size)
make_room_in_stream (MonoDynamicStream *stream, guint32 size)
{
MONO_REQ_GC_NEUTRAL_MODE;

Expand Down Expand Up @@ -60,7 +60,7 @@ mono_dynstream_insert_string (MonoDynamicStream *sh, const char *str)
len = strlen (str) + 1;
idx = sh->index;

make_room_in_stream (sh, (int)(idx + len));
make_room_in_stream (sh, idx + GSIZE_TO_UINT32(len));

/*
* We strdup the string even if we already copy them in sh->data
Expand Down
5 changes: 2 additions & 3 deletions src/mono/mono/metadata/exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,6 @@ mono_error_set_field_missing (MonoError *error, MonoClass *klass, const char *fi
void
mono_error_set_method_missing (MonoError *error, MonoClass *klass, const char *method_name, MonoMethodSignature *sig, const char *reason, ...)
{
int i;
char *result;
GString *res;

Expand Down Expand Up @@ -1361,7 +1360,7 @@ mono_error_set_method_missing (MonoError *error, MonoClass *klass, const char *m
if (sig) {
if (sig->generic_param_count) {
g_string_append_c (res, '<');
for (i = 0; i < sig->generic_param_count; ++i) {
for (guint i = 0; i < sig->generic_param_count; ++i) {
if (i > 0)
g_string_append (res, ",");
g_string_append_printf (res, "!%d", i);
Expand All @@ -1370,7 +1369,7 @@ mono_error_set_method_missing (MonoError *error, MonoClass *klass, const char *m
}

g_string_append_c (res, '(');
for (i = 0; i < sig->param_count; ++i) {
for (guint16 i = 0; i < sig->param_count; ++i) {
if (i > 0)
g_string_append_c (res, ',');
mono_type_get_desc (res, sig->params [i], TRUE);
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/metadata/image-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ MonoImage*
mono_image_loaded_internal (MonoAssemblyLoadContext *alc, const char *name);

MonoImage*
mono_image_load_file_for_image_checked (MonoImage *image, int fileidx, MonoError *error);
mono_image_load_file_for_image_checked (MonoImage *image, uint32_t fileidx, MonoError *error);

MonoImage*
mono_image_load_module_checked (MonoImage *image, int idx, MonoError *error);
mono_image_load_module_checked (MonoImage *image, uint32_t idx, MonoError *error);

MonoImage *
mono_image_open_a_lot (MonoAssemblyLoadContext *alc, const char *fname, MonoImageOpenStatus *status, const MonoImageOpenOptions *options);
Expand Down
Loading