static void
dump_update_summary (MonoImage *image_base, MonoImage *image_dmeta)
{
- int rows;
-
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "dmeta tables:");
for (int idx = 0; idx < MONO_TABLE_NUM; ++idx) {
if (image_dmeta->tables [idx].base)
}
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "================================");
- rows = mono_image_get_table_rows (image_base, MONO_TABLE_TYPEREF);
- for (int i = 1; i <= rows; ++i) {
+ guint32 rows = table_info_get_rows (&image_base->tables [MONO_TABLE_TYPEREF]);
+ for (guint32 i = 1; i <= rows; ++i) {
guint32 cols [MONO_TYPEREF_SIZE];
mono_metadata_decode_row (&image_base->tables [MONO_TABLE_TYPEREF], i - 1, cols, MONO_TYPEREF_SIZE);
const char *scope = scope_to_string (cols [MONO_TYPEREF_SCOPE]);
if (!image_dmeta->minimal_delta) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "--------------------------------");
- rows = mono_image_get_table_rows (image_dmeta, MONO_TABLE_TYPEREF);
- for (int i = 1; i <= rows; ++i) {
+ rows = table_info_get_rows (&image_dmeta->tables [MONO_TABLE_TYPEREF]);
+ for (guint32 i = 1; i <= rows; ++i) {
guint32 cols [MONO_TYPEREF_SIZE];
mono_metadata_decode_row (&image_dmeta->tables [MONO_TABLE_TYPEREF], i - 1, cols, MONO_TYPEREF_SIZE);
const char *scope = scope_to_string (cols [MONO_TYPEREF_SCOPE]);
}
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "================================");
- rows = mono_image_get_table_rows (image_dmeta, MONO_TABLE_TYPEDEF);
- for (int i = 1; i <= rows; ++i) {
+ rows = table_info_get_rows (&image_dmeta->tables [MONO_TABLE_TYPEDEF]);
+ for (guint32 i = 1; i <= rows; ++i) {
guint32 cols [MONO_TYPEDEF_SIZE];
mono_metadata_decode_row (&image_dmeta->tables [MONO_TABLE_TYPEDEF], i - 1, cols, MONO_TYPEDEF_SIZE);
const char *name = mono_metadata_string_heap (image_base, cols [MONO_TYPEDEF_NAME]);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "================================");
- rows = mono_image_get_table_rows (image_base, MONO_TABLE_METHOD);
- for (int i = 1; i <= rows ; ++i) {
+ rows = table_info_get_rows (&image_base->tables [MONO_TABLE_METHOD]);
+ for (guint32 i = 1; i <= rows ; ++i) {
guint32 cols [MONO_METHOD_SIZE];
mono_metadata_decode_row_raw (&image_base->tables [MONO_TABLE_METHOD], i - 1, cols, MONO_METHOD_SIZE);
const char *name = mono_metadata_string_heap (image_base, cols [MONO_METHOD_NAME]);
}
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "--------------------------------");
- rows = mono_image_get_table_rows (image_dmeta, MONO_TABLE_METHOD);
- for (int i = 1; i <= rows ; ++i) {
+ rows = table_info_get_rows (&image_dmeta->tables [MONO_TABLE_METHOD]);
+ for (guint32 i = 1; i <= rows ; ++i) {
guint32 cols [MONO_METHOD_SIZE];
mono_metadata_decode_row_raw (&image_dmeta->tables [MONO_TABLE_METHOD], i - 1, cols, MONO_METHOD_SIZE);
const char *name = mono_metadata_string_heap (image_base, cols [MONO_METHOD_NAME]);
}
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "================================");
- rows = mono_image_get_table_rows (image_base, MONO_TABLE_STANDALONESIG);
- for (int i = 1; i <= rows; ++i) {
+ rows = table_info_get_rows (&image_base->tables [MONO_TABLE_STANDALONESIG]);
+ for (guint32 i = 1; i <= rows; ++i) {
guint32 cols [MONO_STAND_ALONE_SIGNATURE_SIZE];
mono_metadata_decode_row (&image_base->tables [MONO_TABLE_STANDALONESIG], i - 1, cols, MONO_STAND_ALONE_SIGNATURE_SIZE);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "base standalonesig i=%d (token=0x%08x) -> 0x%08x", i, MONO_TOKEN_SIGNATURE | i, cols [MONO_STAND_ALONE_SIGNATURE]);
if (!image_dmeta->minimal_delta) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "--------------------------------");
- rows = mono_image_get_table_rows (image_dmeta, MONO_TABLE_STANDALONESIG);
- for (int i = 1; i <= rows; ++i) {
+ rows = table_info_get_rows (&image_dmeta->tables [MONO_TABLE_STANDALONESIG]);
+ for (guint32 i = 1; i <= rows; ++i) {
guint32 cols [MONO_STAND_ALONE_SIGNATURE_SIZE];
mono_metadata_decode_row_raw (&image_dmeta->tables [MONO_TABLE_STANDALONESIG], i - 1, cols, MONO_STAND_ALONE_SIGNATURE_SIZE);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "dmeta standalonesig i=%d (token=0x%08x) -> 0x%08x", i, MONO_TOKEN_SIGNATURE | i, cols [MONO_STAND_ALONE_SIGNATURE]);
{
MonoTableInfo *encmap = &image_dmeta->tables [MONO_TABLE_ENCMAP];
- int table = mono_metadata_token_table (token);
- int index = mono_metadata_token_index (token);
+ guint32 table = mono_metadata_token_table (token);
+ guint32 index = mono_metadata_token_index (token);
- int index_map = delta_info->enc_recs [table];
- int encmap_rows = table_info_get_rows (encmap);
+ guint32 index_map = delta_info->enc_recs [table];
+ guint32 encmap_rows = table_info_get_rows (encmap);
if (!table_info_get_rows (encmap) || !image_dmeta->minimal_delta)
return mono_metadata_token_index (token);
guint32 cols[MONO_ENCMAP_SIZE];
mono_metadata_decode_row (encmap, index_map - 1, cols, MONO_ENCMAP_SIZE);
- int map_entry = cols [MONO_ENCMAP_TOKEN];
+ guint32 map_entry = cols [MONO_ENCMAP_TOKEN];
/* we're looking at the beginning of a sequence of encmap rows that are all the
* modifications+additions for the table we are looking for (or we're looking at an entry
if (mono_metadata_token_index (map_entry) == index) {
/* token resolves to this generation */
int return_val = index_map - delta_info->enc_recs [table] + 1;
- g_assert (return_val > 0 && return_val <= table_info_get_rows (&image_dmeta->tables[table]));
+ g_assert (return_val > 0 && GINT_TO_UINT32(return_val) <= table_info_get_rows (&image_dmeta->tables[table]));
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "relative index for token 0x%08x -> table 0x%02x row 0x%08x", token, table, return_val);
return return_val;
} else {
{
MonoTableInfo *encmap = &image_dmeta->tables [MONO_TABLE_ENCMAP];
- int table, prev_table = -1, idx;
+ int table, prev_table = -1;
+ guint32 idx;
/*** Compute logical table sizes ***/
if (base_info->delta_info == base_info->delta_info_last) {
/* TODO: while going through the tables, update delta_info->count[tbl].{modified,inserted}_rows */
- int encmap_rows = table_info_get_rows (encmap);
+ guint32 encmap_rows = table_info_get_rows (encmap);
for (idx = 1; idx <= encmap_rows; ++idx) {
guint32 cols[MONO_ENCMAP_SIZE];
mono_metadata_decode_row (encmap, idx - 1, cols, MONO_ENCMAP_SIZE);
delta_info_mutate_row (MonoImage *image_dmeta, DeltaInfo *cur_delta, guint32 log_token)
{
int token_table = mono_metadata_token_table (log_token);
- int token_index = mono_metadata_token_index (log_token); /* 1-based */
+ guint32 token_index = mono_metadata_token_index (log_token); /* 1-based */
gboolean modified = token_index <= cur_delta->count [token_table].prev_gen_rows;
char *dst_base = (char*)cur_delta->mutants [token_table].base + (token_index - 1) * cur_delta->mutants [token_table].row_size;
guint32 src_offset = 0, dst_offset = 0;
- for (int col = 0; col < mono_metadata_table_count (dst_bitfield); ++col) {
+ for (guint col = 0; col < mono_metadata_table_count (dst_bitfield); ++col) {
guint32 dst_col_size = mono_metadata_table_size (dst_bitfield, col);
guint32 src_col_size = mono_metadata_table_size (src_bitfield, col);
if ((m_SuppressedDeltaColumns [token_table] & (1 << col)) == 0) {
static void
prepare_mutated_rows (const MonoTableInfo *table_enclog, MonoImage *image_base, MonoImage *image_dmeta, DeltaInfo *delta_info)
{
- int rows = table_info_get_rows (table_enclog);
+ guint32 rows = table_info_get_rows (table_enclog);
/* Prepare the mutated metadata tables */
- for (int i = 0; i < rows ; ++i) {
+ for (guint32 i = 0; i < rows ; ++i) {
guint32 cols [MONO_ENCLOG_SIZE];
mono_metadata_decode_row (table_enclog, i, cols, MONO_ENCLOG_SIZE);
apply_enclog_pass1 (MonoImage *image_base, MonoImage *image_dmeta, DeltaInfo *delta_info, gconstpointer dil_data, uint32_t dil_length, MonoError *error)
{
MonoTableInfo *table_enclog = &image_dmeta->tables [MONO_TABLE_ENCLOG];
- int rows = table_info_get_rows (table_enclog);
+ guint32 rows = table_info_get_rows (table_enclog);
gboolean unsupported_edits = FALSE;
/* hack: make a pass over it, looking only for table method updates, in
* order to give more meaningful error messages first */
- for (int i = 0; i < rows ; ++i) {
+ for (guint32 i = 0; i < rows ; ++i) {
guint32 cols [MONO_ENCLOG_SIZE];
mono_metadata_decode_row (table_enclog, i, cols, MONO_ENCLOG_SIZE);
int func_code = cols [MONO_ENCLOG_FUNC_CODE];
int token_table = mono_metadata_token_table (log_token);
- int token_index = mono_metadata_token_index (log_token);
+ guint32 token_index = mono_metadata_token_index (log_token);
gboolean is_addition = token_index-1 >= delta_info->count[token_table].prev_gen_rows ;
g_assert (func_code == 0); /* anything else doesn't make sense here */
}
- for (int i = 0; i < rows ; ++i) {
+ for (guint32 i = 0; i < rows ; ++i) {
guint32 cols [MONO_ENCLOG_SIZE];
mono_metadata_decode_row (table_enclog, i, cols, MONO_ENCLOG_SIZE);
int func_code = cols [MONO_ENCLOG_FUNC_CODE];
int token_table = mono_metadata_token_table (log_token);
- int token_index = mono_metadata_token_index (log_token);
+ guint32 token_index = mono_metadata_token_index (log_token);
gboolean is_addition = token_index-1 >= delta_info->count[token_table].prev_gen_rows ;
g_assert (next_cols [MONO_ENCLOG_FUNC_CODE] == ENC_FUNC_DEFAULT);
int next_token = next_cols [MONO_ENCLOG_TOKEN];
int next_table = mono_metadata_token_table (next_token);
- int next_index = mono_metadata_token_index (next_token);
+ guint32 next_index = mono_metadata_token_index (next_token);
g_assert (next_table == MONO_TABLE_METHOD);
/* expecting an added method */
g_assert (next_index-1 >= delta_info->count[next_table].prev_gen_rows);
g_assert (next_cols [MONO_ENCLOG_FUNC_CODE] == ENC_FUNC_DEFAULT);
int next_token = next_cols [MONO_ENCLOG_TOKEN];
int next_table = mono_metadata_token_table (next_token);
- int next_index = mono_metadata_token_index (next_token);
+ guint32 next_index = mono_metadata_token_index (next_token);
g_assert (next_table == MONO_TABLE_FIELD);
/* expecting an added field */
g_assert (next_index-1 >= delta_info->count[next_table].prev_gen_rows);
MonoImage *image_dppdb = ppdb_file->image;
MonoTableInfo *table_encmap = &image_dppdb->tables [MONO_TABLE_ENCMAP];
- int rows = table_info_get_rows (table_encmap);
- for (int i = 0; i < rows ; ++i) {
+ guint32 rows = table_info_get_rows (table_encmap);
+ for (guint32 i = 0; i < rows ; ++i) {
guint32 cols [MONO_ENCMAP_SIZE];
mono_metadata_decode_row (table_encmap, i, cols, MONO_ENCMAP_SIZE);
int map_token = cols [MONO_ENCMAP_TOKEN];
int token_table = mono_metadata_token_table (map_token);
if (token_table == MONO_TABLE_METHODBODY) {
- int token_index = mono_metadata_token_index (map_token);
+ guint32 token_index = mono_metadata_token_index (map_token);
if (token_index == idx) {
MonoDebugInformationEnc *encDebugInfo = g_new0 (MonoDebugInformationEnc, 1);
encDebugInfo->idx = i + 1;
apply_enclog_pass2 (Pass2Context *ctx, MonoImage *image_base, BaselineInfo *base_info, uint32_t generation, MonoImage *image_dmeta, DeltaInfo *delta_info, gconstpointer dil_data, uint32_t dil_length, MonoError *error)
{
MonoTableInfo *table_enclog = &image_dmeta->tables [MONO_TABLE_ENCLOG];
- int rows = table_info_get_rows (table_enclog);
+ guint32 rows = table_info_get_rows (table_enclog);
/* NOTE: Suppressed colums
*
uint32_t add_event_eventmap = 0;
gboolean assemblyref_updated = FALSE;
- for (int i = 0; i < rows ; ++i) {
+ for (guint32 i = 0; i < rows ; ++i) {
guint32 cols [MONO_ENCLOG_SIZE];
mono_metadata_decode_row (table_enclog, i, cols, MONO_ENCLOG_SIZE);
int func_code = cols [MONO_ENCLOG_FUNC_CODE];
int token_table = mono_metadata_token_table (log_token);
- int token_index = mono_metadata_token_index (log_token);
+ guint32 token_index = mono_metadata_token_index (log_token);
gboolean is_addition = token_index-1 >= delta_info->count[token_table].prev_gen_rows ;
MonoImage *delta_child = ((DeltaInfo*)l->data)->delta_image;
old_rows += table_info_get_rows (&delta_child->tables [MONO_TABLE_ASSEMBLYREF]);
}
- int new_rows = table_info_get_rows (&image_dmeta->tables [MONO_TABLE_ASSEMBLYREF]);
+ guint32 new_rows = table_info_get_rows (&image_dmeta->tables [MONO_TABLE_ASSEMBLYREF]);
old_rows -= new_rows;
g_assert (new_rows > 0);
delta_info->method_ppdb_table_update = g_hash_table_new (g_direct_hash, g_direct_equal);
int mapped_token = hot_reload_relative_delta_index (image_dmeta, delta_info, mono_metadata_make_token (token_table, token_index));
- int rva = mono_metadata_decode_row_col (&image_dmeta->tables [MONO_TABLE_METHOD], mapped_token - 1, MONO_METHOD_RVA);
+ guint32 rva = mono_metadata_decode_row_col (&image_dmeta->tables [MONO_TABLE_METHOD], mapped_token - 1, MONO_METHOD_RVA);
if (rva < dil_length) {
char *il_address = ((char *) dil_data) + rva;
MonoDebugInformationEnc *method_debug_information = hot_reload_get_method_debug_information (delta_info->ppdb_file, token_index);
table = &delta_info->mutants [table_index];
ridx = token_index - 1;
- } while (ridx < 0 || ridx >= table_info_get_rows (table));
+ } while (ridx < 0 || GINT_TO_UINT32(ridx) >= table_info_get_rows (table));
return FALSE;
}
uint32_t current_gen = hot_reload_get_thread_generation ();
- int rows = table_info_get_rows (&base->tables [table_index]);
+ guint32 rows = table_info_get_rows (&base->tables [table_index]);
GList *cur;
for (cur = base_info->delta_info; cur; cur = cur->next) {
DeltaInfo *delta_info = (DeltaInfo*)cur->data;
/* HACK - keep in sync with locator_t in metadata/metadata.c */
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;
} upd_locator_t;
__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)
__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)
#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)
#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)
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;
}
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);
}
MonoTableInfo *file_table = &image->tables [MONO_TABLE_FILE];
MonoImage *file_image;
MonoClass *klass;
- int i;
error_init (error);
* 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)
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;
}
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;
}
MonoReflectionAssembly *assembly = MONO_HANDLE_RAW (assembly_h);
MonoMethodSignature *sig;
MonoObjectHandle obj_h, namedarg_h, minfo_h;
- int i;
if (len == 0)
return;
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;
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;
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;
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;
/* 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")) {
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;
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;
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);
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);
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);
MonoClass *klass;
const MonoTableInfo *methods;
MonoMethod *method;
- int i;
/* Handle short names for system classes */
if (!desc->name_space && image == mono_defaults.corlib) {
/* 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);
{
MonoPEDirEntry *debug_dir_entry;
ImageDebugDirectory debug_dir;
- int idx;
gboolean guid_found = FALSE;
guint8 *data;
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);
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;
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);
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);
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);
// 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)
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);
//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]));
* 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;
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;
}
static void
-make_room_in_stream (MonoDynamicStream *stream, int size)
+make_room_in_stream (MonoDynamicStream *stream, guint32 size)
{
MONO_REQ_GC_NEUTRAL_MODE;
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
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;
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);
}
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);
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);
* it cannot be loaded. NULL without MonoError being set will be interpreted as "not found".
*/
MonoImage*
-mono_image_load_module_checked (MonoImage *image, int idx, MonoError *error)
+mono_image_load_module_checked (MonoImage *image, uint32_t idx, MonoError *error)
{
error_init (error);
{
MonoDotNetHeader cli_header;
MonoMSDOSHeader msdos;
- int idx;
guint8 *data;
int offset = 0;
return FALSE;
else {
const int top = cli_header.coff.coff_sections;
- int addr = debug_dir_entry->rva;
+ guint32 addr = debug_dir_entry->rva;
int i = 0;
for (i = 0; i < top; i++){
MonoSectionTable t;
break;
}
}
- 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 *) (raw_data + addr) + idx);
debug_dir.characteristics = read32(data);
debug_dir.time_date_stamp = read32(data + 4);
if (mono_trace_is_traced (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE)) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "ENCMAP for %s", image->filename);
- for (int i = 0; i < table_info_get_rows (encmap); ++i) {
+ for (guint32 i = 0; i < table_info_get_rows (encmap); ++i) {
guint32 cols [MONO_ENCMAP_SIZE];
mono_metadata_decode_row (encmap, i, cols, MONO_ENCMAP_SIZE);
int token = cols [MONO_ENCMAP_TOKEN];
// Returning NULL with no error set will be interpeted as "not found"
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)
{
char *base_dir, *name;
MonoImage *res;
mono_image_unlock (image);
mono_image_close (old);
} else {
- int i;
/* g_print ("loaded file %s from %s (%p)\n", name, image->name, image->assembly); */
if (!assign_assembly_parent_for_netmodule (res, image, error)) {
mono_image_unlock (image);
return NULL;
}
- for (i = 0; i < res->module_count; ++i) {
+ for (guint32 i = 0; i < res->module_count; ++i) {
if (res->modules [i] && !res->modules [i]->assembly)
res->modules [i]->assembly = image->assembly;
}
if (!image->files) {
- int n = table_info_get_rows (t);
+ guint32 n = table_info_get_rows (t);
image->files = g_new0 (MonoImage*, n);
image->file_count = n;
}
{
MonoMethodSignature *res;
gboolean is_open;
- int i;
error_init (error);
if (!context)
if (!is_ok (error))
goto fail;
is_open = mono_class_is_open_constructed_type (res->ret);
- for (i = 0; i < sig->param_count; ++i) {
+ for (guint16 i = 0; i < sig->param_count; ++i) {
res->params [i] = mono_class_inflate_generic_type_checked (sig->params [i], context, error);
if (!is_ok (error))
goto fail;
fail:
if (res->ret)
mono_metadata_free_type (res->ret);
- for (i = 0; i < sig->param_count; ++i) {
+ for (guint16 i = 0; i < sig->param_count; ++i) {
if (res->params [i])
mono_metadata_free_type (res->params [i]);
}
error_init (error);
- for (int i = 0; i < header->num_locals; ++i) {
+ for (guint16 i = 0; i < header->num_locals; ++i) {
res->locals [i] = mono_class_inflate_generic_type_checked (header->locals [i], context, error);
goto_if_nok (error, fail);
}
if (res->num_clauses) {
- for (int i = 0; i < header->num_clauses; ++i) {
+ for (guint i = 0; i < header->num_clauses; ++i) {
MonoExceptionClause *clause = &res->clauses [i];
if (clause->flags != MONO_EXCEPTION_CLAUSE_NONE)
continue;
// FIXME Check max_len while scanning data? mono_string_from_byvalstr does.
const size_t len = g_utf16_len (data);
- return mono_string_new_utf16_handle (data, (gint32)MIN (len, max_len), error);
+ return mono_string_new_utf16_handle (data, (gint32)MIN (len, GINT_TO_UINT(max_len)), error);
}
gpointer
mono_error_assert_ok (error);
MonoArrayHandle chunkChars = MONO_HANDLE_NEW_GET (MonoArray, sb, chunkChars);
- g_assert (MONO_HANDLE_GETVAL (chunkChars, max_length) >= initial_len);
+ g_assert (MONO_HANDLE_GETVAL (chunkChars, max_length) >= GINT_TO_UINT(initial_len));
return sb;
}
do {
MONO_HANDLE_GET (chunkChars, chunk, chunkChars);
- const int maxLength = MONO_HANDLE_GETVAL (chunkChars, max_length);
+ const guint32 maxLength = MONO_HANDLE_GETVAL (chunkChars, max_length);
g_assert (maxLength >= 0);
- const int chunkOffset = MONO_HANDLE_GETVAL (chunk, chunkOffset);
+ const guint32 chunkOffset = MONO_HANDLE_GETVAL (chunk, chunkOffset);
g_assert (chunkOffset >= 0);
if (maxLength > 0 && chunkOffset < string_len) {
// Check that we will not overrun our boundaries.
GError *gerror = NULL;
glong copied;
gunichar2* ut = g_utf8_to_utf16 (text, (glong)len, NULL, &copied, &gerror);
- int capacity = mono_string_builder_capacity (sb);
+ guint capacity = mono_string_builder_capacity (sb);
- if (copied > capacity)
+ if (GLONG_TO_ULONG(copied) > capacity)
copied = capacity;
if (!gerror) {
}
len = mono_string_builder_capacity (sb) + 1;
- res = (char *)mono_marshal_alloc (MAX (byte_count + 1, len), error);
+ res = (char *)mono_marshal_alloc (MAX (GLONG_TO_ULONG(byte_count) + 1, len), error);
if (!is_ok (error)) {
res = NULL;
goto exit;
const int chunkOffset = MONO_HANDLE_GETVAL (chunk, chunkOffset);
g_assert (chunkOffset >= 0);
g_assertf ((chunkOffset + chunkLength) >= chunkLength, "integer overflow");
- g_assertf ((chunkOffset + chunkLength) <= capacity, "A chunk in the StringBuilder had a length longer than expected from the offset.");
+ g_assertf (GINT_TO_UINT(chunkOffset + chunkLength) <= capacity, "A chunk in the StringBuilder had a length longer than expected from the offset.");
memcpy (str + chunkOffset, MONO_HANDLE_RAW (chunkChars)->vector, chunkLength * sizeof (gunichar2));
}
MONO_HANDLE_GET (chunk, chunk, chunkPrevious);
char *s = mono_string_handle_to_utf8 (src, error);
return_if_nok (error);
- size_t len = MIN (size, strlen (s));
- len -= (len >= size);
+ size_t len = MIN (GINT_TO_UINT(size), strlen (s));
+ len -= (len >= GINT_TO_UINT(size));
memcpy (dst, s, len);
dst [len] = 0;
g_free (s);
return;
}
- mono_array_size_t i;
MonoCustomAttrEntry *attr = NULL;
- for (i = 0; i < cinfo->num_attrs; ++i) {
+ for (int i = 0; i < cinfo->num_attrs; ++i) {
MonoClass *ctor_class = cinfo->attrs [i].ctor->klass;
if (ctor_class == attr_class) {
attr = &cinfo->attrs [i];
MonoArray *named_args = mono_marshal_get_callconvs_array_from_attribute(attr, &arginfo);
if (named_args)
{
- for (i = 0; i < mono_array_length_internal(named_args); ++i) {
+ for (mono_array_size_t i = 0; i < mono_array_length_internal(named_args); ++i) {
CattrNamedArg *info = &arginfo[i];
g_assert(info->field);
if (strcmp(info->field->name, "CallConvs") != 0)
return;
}
- mono_array_size_t i;
MonoCustomAttrEntry *attr = NULL;
- for (i = 0; i < cinfo->num_attrs; ++i) {
+ for (int i = 0; i < cinfo->num_attrs; ++i) {
MonoClass *ctor_class = cinfo->attrs [i].ctor->klass;
if (ctor_class == attr_class) {
attr = &cinfo->attrs [i];
if (attr != NULL) {
MonoDecodeCustomAttr *decoded_args = mono_reflection_create_custom_attr_data_args_noalloc (mono_defaults.corlib, attr->ctor, attr->data, attr->data_size, error);
mono_error_assert_ok (error);
- for (i = 0; i < decoded_args->named_args_num; ++i) {
+ for (int i = 0; i < decoded_args->named_args_num; ++i) {
if (decoded_args->named_args_info [i].field && !strcmp (decoded_args->named_args_info [i].field->name, "CallConvs")) {
g_assertf(decoded_args->named_args_info [i].field->type->type == MONO_TYPE_SZARRAY, "UnmanagedCallersOnlyAttribute parameter %s must be an array, specified for method %s", decoded_args->named_args_info [i].field->name, method->name);
MonoCustomAttrValueArray *calling_conventions = decoded_args->named_args[i]->value.array;
mono_struct_delete_old (MonoClass *klass, char *ptr)
{
MonoMarshalType *info;
- int i;
info = mono_marshal_load_type_info (klass);
if (m_class_is_blittable (klass))
return;
- for (i = 0; i < info->num_fields; i++) {
+ for (guint32 i = 0; i < info->num_fields; i++) {
MonoMarshalConv conv;
MonoType *ftype = info->fields [i].field->type;
char *cpos;
int size;
size = mono_pagesize ();
- while (size - sizeof (LockFreeMempoolChunk) < len)
+ while (size - sizeof (LockFreeMempoolChunk) < GINT_TO_UINT(len))
size += mono_pagesize ();
chunk = (LockFreeMempoolChunk *)mono_valloc (0, size, MONO_MMAP_READ|MONO_MMAP_WRITE, MONO_MEM_ACCOUNT_MEM_MANAGER);
g_assert (chunk);
/* The code below is lock-free, 'chunk' is shared state */
oldpos = mono_atomic_fetch_add_i32 (&chunk->pos, size);
- if (oldpos + size > chunk->size) {
+ if (oldpos + size > GINT_TO_UINT(chunk->size)) {
chunk = lock_free_mempool_chunk_new (mp, size);
- g_assert (chunk->pos + size <= chunk->size);
+ g_assert (chunk->pos + size <= GINT_TO_UINT(chunk->size));
res = chunk->mem;
chunk->pos += size;
mono_memory_barrier ();
memory_manager->freeing = TRUE;
// Must be done before type_hash is freed
- for (int i = 0; i < memory_manager->class_vtable_array->len; i++)
+ for (guint i = 0; i < memory_manager->class_vtable_array->len; i++)
unregister_vtable_reflection_type ((MonoVTable *)g_ptr_array_index (memory_manager->class_vtable_array, i));
g_ptr_array_free (memory_manager->class_vtable_array, TRUE);
mem_managers = alc->generic_memory_managers;
res = NULL;
- for (int mindex = 0; mindex < mem_managers->len; ++mindex) {
+ for (guint mindex = 0; mindex < mem_managers->len; ++mindex) {
MonoMemoryManager *mm = (MonoMemoryManager*)g_ptr_array_index (mem_managers, mindex);
if (match_mem_manager (mm, alcs, nalcs)) {
do {
if (bb_idx_is_contained (first, target))
break;
- if (first->start > target)
+ if (GINT_TO_UINT(first->start )> target)
first = first->left;
else
first = first->right;
return;
}
- while (current && cli_addr >= current->end)
+ while (current && cli_addr >= GINT_TO_UINT(current->end))
current = current->next;
g_assert (current);
static void
bb_formation_eh_pass (MonoMethodHeader *header, MonoSimpleBasicBlock *bb, MonoSimpleBasicBlock **root, MonoMethod *method, MonoError *error)
{
- int i;
- int end = header->code_size;
+ guint32 end = header->code_size;
error_init (error);
/*We must split at all points to verify for targets in the middle of an instruction*/
- for (i = 0; i < header->num_clauses; ++i) {
+ for (guint i = 0; i < header->num_clauses; ++i) {
MonoExceptionClause *clause = header->clauses + i;
MonoSimpleBasicBlock *try_block, *handler;
}
/* Returns position of key or of an empty slot for it */
-static int mono_g_hash_table_find_slot (MonoGHashTable *hash, const MonoObject *key)
+static guint mono_g_hash_table_find_slot (MonoGHashTable *hash, const MonoObject *key)
{
guint start = ((*hash->hash_func) (key)) % hash->table_size;
guint i = start;
}
gint32 max_length = UnlockedRead (&mono_g_hash_table_max_chain_length);
- if (i > start && (i - start) > max_length)
+ if (i > start && (i - start) > GINT32_TO_UINT32(max_length))
UnlockedWrite (&mono_g_hash_table_max_chain_length, i - start);
- else if (i < start && (hash->table_size - (start - i)) > max_length)
+ else if (i < start && (hash->table_size - (start - i)) > GINT32_TO_UINT32(max_length))
UnlockedWrite (&mono_g_hash_table_max_chain_length, hash->table_size - (start - i));
return i;
for (i = 0; i < current_size; i++) {
if (old_keys [i]) {
- int slot = mono_g_hash_table_find_slot (hash, old_keys [i]);
+ guint slot = mono_g_hash_table_find_slot (hash, old_keys [i]);
mono_g_hash_table_key_store (hash, slot, old_keys [i]);
mono_g_hash_table_value_store (hash, slot, old_values [i]);
}
gboolean
mono_g_hash_table_lookup_extended (MonoGHashTable *hash, gconstpointer key, gpointer *orig_key, gpointer *value)
{
- int slot;
-
g_return_val_if_fail (hash != NULL, FALSE);
- slot = mono_g_hash_table_find_slot (hash, (MonoObject*)key);
+ guint slot = mono_g_hash_table_find_slot (hash, (MonoObject*)key);
if (hash->keys [slot]) {
if (orig_key)
gboolean
mono_g_hash_table_remove (MonoGHashTable *hash, gconstpointer key)
{
- int slot, last_clear_slot;
+ guint slot, last_clear_slot;
g_return_val_if_fail (hash != NULL, FALSE);
slot = mono_g_hash_table_find_slot (hash, (MonoObject*)key);
mono_g_hash_table_insert_replace (MonoGHashTable *hash, gpointer key, gpointer value, gboolean replace)
{
MONO_REQ_GC_UNSAFE_MODE;
- int slot;
g_return_if_fail (hash != NULL);
if (hash->in_use > (hash->table_size * HASH_TABLE_MAX_LOAD_FACTOR))
rehash (hash);
- slot = mono_g_hash_table_find_slot (hash, (MonoObject*)key);
+ guint slot = mono_g_hash_table_find_slot (hash, (MonoObject*)key);
if (hash->keys [slot]) {
if (replace) {
int maxCapacity;
};
-static inline int
+static inline guint
mono_string_builder_capacity (MonoStringBuilderHandle sbh)
{
MonoStringBuilder *sb = MONO_HANDLE_RAW (sbh);
case MONO_TYPE_ARRAY:
g_assert ((m_field_get_offset (field) % wordsize) == 0);
- g_assert (pos < size || pos <= max_size);
+ g_assert (pos < GINT_TO_UINT32(size) || pos <= GINT_TO_UINT32(max_size));
bitmap [pos / BITMAP_EL_SIZE] |= ((gsize)1) << (pos % BITMAP_EL_SIZE);
- *max_set = MAX (*max_set, pos);
+ *max_set = MAX (GINT_TO_UINT32(*max_set), pos);
break;
case MONO_TYPE_GENERICINST:
if (!mono_type_generic_inst_is_valuetype (type)) {
g_assert ((m_field_get_offset (field) % wordsize) == 0);
bitmap [pos / BITMAP_EL_SIZE] |= ((gsize)1) << (pos % BITMAP_EL_SIZE);
- *max_set = MAX (*max_set, pos);
+ *max_set = MAX (GINT_TO_UINT32(*max_set), pos);
break;
} else {
/* fall through */
/* Collision, build the trampoline */
GPtrArray *imt_ir = imt_sort_slot_entries (imt_builder_entry);
gpointer result;
- int i;
result = imt_trampoline_builder (vtable,
(MonoIMTCheckItem**)imt_ir->pdata, imt_ir->len, fail_tramp);
- for (i = 0; i < imt_ir->len; ++i)
+ for (guint i = 0; i < imt_ir->len; ++i)
g_free (g_ptr_array_index (imt_ir, i));
g_ptr_array_free (imt_ir, TRUE);
return result;
entries = next;
}
- for (int i = 0; i < sorted->len; ++i)
+ for (guint i = 0; i < sorted->len; ++i)
g_free (g_ptr_array_index (sorted, i));
g_ptr_array_free (sorted, TRUE);
// are also arrays and we allocate each one of them.
MonoClass *element_class = m_class_get_element_class (klass);
g_assert (m_class_get_rank (element_class) == 1);
- for (int i = 0; i < lengths [index]; i++) {
+ for (uintptr_t i = 0; i < lengths [index]; i++) {
MonoArray *o = mono_array_new_jagged_helper (element_class, n, lengths, index + 1, error);
goto_if_nok (error, exit);
mono_array_setref_fast (ret, i, o);
return NULL;
}
/* g_utf16_to_utf8 may not be able to complete the conversion (e.g. NULL values were found, #335488) */
- if (len2 > written) {
+ if (len2 > GLONG_TO_ULONG(written)) {
/* allocate the total length and copy the part of the string that has been converted */
char *as2 = (char *)g_malloc0 (len2);
memcpy (as2, as, written);
return NULL;
}
/* g_utf16_to_utf8 may not be able to complete the conversion (e.g. NULL values were found, #335488) */
- if (slength > written) {
+ if (slength > GLONG_TO_ULONG(written)) {
/* allocate the total length and copy the part of the string that has been converted */
char *as2 = (char *)g_malloc0 (slength);
memcpy (as2, as, written);
if (image->assembly->image == image) {
token = mono_metadata_make_token (MONO_TABLE_MODULE, 1);
} else {
- int i;
if (image->assembly->image->modules) {
- for (i = 0; i < image->assembly->image->module_count; i++) {
+ for (guint32 i = 0; i < image->assembly->image->module_count; i++) {
if (image->assembly->image->modules [i] == image)
token = mono_metadata_make_token (MONO_TABLE_MODULEREF, i + 1);
}
MonoTableInfo *table;
guint32 cols [MONO_FILE_SIZE];
const char *name;
- guint32 i, name_idx;
+ guint32 name_idx;
const char *val;
error_init (error);
goto_if_nok (error, fail);
table = &image->tables [MONO_TABLE_FILE];
- g_assert (table_index < table_info_get_rows (table));
+ g_assert (GINT_TO_UINT32(table_index) < table_info_get_rows (table));
mono_metadata_decode_row (table, table_index, cols, MONO_FILE_SIZE);
MONO_HANDLE_SETVAL (res, image, MonoImage*, NULL);
/* Check whenever the row has a corresponding row in the moduleref table */
table = &image->tables [MONO_TABLE_MODULEREF];
- int rows = table_info_get_rows (table);
- for (i = 0; i < rows; ++i) {
+ guint32 rows = table_info_get_rows (table);
+ for (guint32 i = 0; i < rows; ++i) {
name_idx = mono_metadata_decode_row_col (table, i, MONO_MODULEREF_NAME);
val = mono_metadata_string_heap (image, name_idx);
if (strcmp (val, name) == 0)
static MonoType*
mono_type_normalize (MonoType *type)
{
- int i;
MonoGenericClass *gclass;
MonoGenericInst *ginst;
MonoClass *gtd;
gcontainer = mono_class_get_generic_container (gtd);
argv = g_newa (MonoType*, ginst->type_argc);
- for (i = 0; i < ginst->type_argc; ++i) {
+ for (guint i = 0; i < ginst->type_argc; ++i) {
MonoType *t = ginst->type_argv [i], *norm;
if (t->type != MONO_TYPE_VAR || t->data.generic_param->num != i || t->data.generic_param->owner != gcontainer)
is_denorm_gtd = FALSE;
MonoType **type_args = g_new0 (MonoType *, info->type_arguments->len);
MonoReflectionTypeHandle the_type;
MonoType *instance;
- int i;
- for (i = 0; i < info->type_arguments->len; i++) {
+ for (guint i = 0; i < info->type_arguments->len; i++) {
MonoTypeNameParse *subinfo = (MonoTypeNameParse *)g_ptr_array_index (info->type_arguments, i);
type_args [i] = _mono_reflection_get_type_from_info (alc, subinfo, rootimage, ignorecase, search_mscorlib, error);
g_list_free (info->nested);
if (info->type_arguments) {
- int i;
-
- for (i = 0; i < info->type_arguments->len; i++) {
+ for (guint i = 0; i < info->type_arguments->len; i++) {
MonoTypeNameParse *subinfo = (MonoTypeNameParse *)g_ptr_array_index (info->type_arguments, i);
mono_reflection_free_type_info (subinfo);
MonoTableInfo *t = &image->tables [MONO_TABLE_DECLSECURITY];
guint32 result = 0;
guint32 action;
- int i;
/* HasSecurity can be present for other, not specially encoded, attributes,
e.g. SuppressUnmanagedCodeSecurityAttribute */
if (index < 0)
return 0;
- int rows = table_info_get_rows (t);
- for (i = index; i < rows; i++) {
+ guint32 rows = table_info_get_rows (t);
+ for (guint32 i = index; i < rows; i++) {
guint32 cols [MONO_DECL_SECURITY_SIZE];
mono_metadata_decode_row (t, i, cols, MONO_DECL_SECURITY_SIZE);
MonoBoolean result = FALSE;
MonoTableInfo *t;
guint32 cols [MONO_DECL_SECURITY_SIZE];
- int index = mono_metadata_declsec_from_index (image, token);
- int i;
+ guint32 index = mono_metadata_declsec_from_index (image, token);
t = &image->tables [MONO_TABLE_DECLSECURITY];
- int rows = table_info_get_rows (t);
- for (i = index; i < rows; i++) {
+ guint32 rows = table_info_get_rows (t);
+ for (guint32 i = index; i < rows; i++) {
mono_metadata_decode_row (t, i, cols, MONO_DECL_SECURITY_SIZE);
if (cols [MONO_DECL_SECURITY_PARENT] != token)
get_declsec_action (MonoImage *image, guint32 token, guint32 action, MonoDeclSecurityEntry *entry)
{
guint32 cols [MONO_DECL_SECURITY_SIZE];
- int i;
-
- int index = mono_metadata_declsec_from_index (image, token);
+ guint32 index = mono_metadata_declsec_from_index (image, token);
if (index == -1)
return FALSE;
MonoTableInfo *t = &image->tables [MONO_TABLE_DECLSECURITY];
- int rows = table_info_get_rows (t);
- for (i = index; i < rows; i++) {
+ guint32 rows = table_info_get_rows (t);
+ for (guint32 i = index; i < rows; i++) {
mono_metadata_decode_row (t, i, cols, MONO_DECL_SECURITY_SIZE);
/* shortcut - index are ordered */
{
MONO_REQ_GC_NEUTRAL_MODE;
- int i;
MonoGenericInst *class_inst;
MonoClass *klass;
sigbuffer_add_value (buf, mono_dynimage_encode_typedef_or_ref_full (assembly, m_class_get_byval_arg (klass), FALSE));
sigbuffer_add_value (buf, class_inst->type_argc);
- for (i = 0; i < class_inst->type_argc; ++i)
+ for (guint i = 0; i < class_inst->type_argc; ++i)
encode_type (assembly, class_inst->type_argv [i], buf);
}
for( i = 0; i < wait->num; i++)
mono_threads_close_thread_handle (wait->handles [i]);
- if (ret >= MONO_THREAD_INFO_WAIT_RET_SUCCESS_0 && ret < (MONO_THREAD_INFO_WAIT_RET_SUCCESS_0 + wait->num)) {
+ if (ret >= MONO_THREAD_INFO_WAIT_RET_SUCCESS_0 && GINT_TO_UINT32(ret) < MONO_THREAD_INFO_WAIT_RET_SUCCESS_0 + wait->num) {
MonoInternalThread *internal;
internal = wait->threads [ret - MONO_THREAD_INFO_WAIT_RET_SUCCESS_0];
#if MONO_SMALL_CONFIG
#define NUM_STATIC_DATA_IDX 4
-static const int static_data_size [NUM_STATIC_DATA_IDX] = {
+static const guint32 static_data_size [NUM_STATIC_DATA_IDX] = {
64, 256, 1024, 4096
};
#else
#define NUM_STATIC_DATA_IDX 8
-static const int static_data_size [NUM_STATIC_DATA_IDX] = {
+static const guint32 static_data_size [NUM_STATIC_DATA_IDX] = {
1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216
};
#endif
mono_alloc_static_data (gpointer **static_data_ptr, guint32 offset, void *alloc_key)
{
guint idx = ACCESS_SPECIAL_STATIC_OFFSET (offset, index);
- int i;
gpointer* static_data = *static_data_ptr;
if (!static_data) {
static_data [0] = static_data;
}
- for (i = 1; i <= idx; ++i) {
+ for (guint i = 1; i <= idx; ++i) {
if (static_data [i])
continue;
static void
mono_free_static_data (gpointer* static_data)
{
- int i;
- for (i = 1; i < NUM_STATIC_DATA_IDX; ++i) {
+ for (guint i = 1; i < NUM_STATIC_DATA_IDX; ++i) {
gpointer p = static_data [i];
if (!p)
continue;
offset = ACCESS_SPECIAL_STATIC_OFFSET (offset, offset);
offset /= sizeof (uintptr_t);
/* offset is now the bitmap offset */
- for (int i = 0; i < size / sizeof (uintptr_t); i++)
+ for (guint i = 0; i < size / sizeof (uintptr_t); i++)
mono_bitset_clear_fast (rb, offset + i);
}
}
if (internal->owned_mutexes) {
- int i;
-
g_string_append (text, ", owns : [");
- for (i = 0; i < internal->owned_mutexes->len; i++)
+ for (guint i = 0; i < internal->owned_mutexes->len; i++)
g_string_append_printf (text, i == 0 ? "%p" : ", %p", g_ptr_array_index (internal->owned_mutexes, i));
g_string_append (text, "]");
}
{
MonoVariableRelationsEvaluationArea area;
MonoBasicBlock *bb;
- int i;
verbose_level = cfg->verbose_level;
area.variable_value_kind = (MonoIntegerValueKind *)
mono_mempool_alloc (cfg->mempool, sizeof (MonoIntegerValueKind) * (cfg->next_vreg));
area.defs = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * cfg->next_vreg);
- for (i = 0; i < cfg->next_vreg; i++) {
+ for (guint32 i = 0; i < cfg->next_vreg; i++) {
area.variable_value_kind [i] = MONO_UNKNOWN_INTEGER_VALUE;
area.relations [i].relation = MONO_EQ_RELATION;
area.relations [i].relation_is_static_definition = TRUE;
}
/* Add symmetric relations */
- for (i = 0; i < cfg->next_vreg; i++) {
+ for (guint32 i = 0; i < cfg->next_vreg; i++) {
if (area.relations [i].related_value.type == MONO_VARIABLE_SUMMARIZED_VALUE) {
int related_index = cfg->next_vreg + i;
int related_variable = area.relations [i].related_value.value.variable.variable;
static gboolean
recompute_aliased_variables (MonoCompile *cfg, int *restored_vars)
{
- int i;
- MonoBasicBlock *bb;
- MonoInst *ins;
int kills = 0;
int adds = 0;
*restored_vars = 0;
- for (i = 0; i < cfg->num_varinfo; i++) {
+ for (guint i = 0; i < cfg->num_varinfo; i++) {
MonoInst *var = cfg->varinfo [i];
if (var->flags & MONO_INST_INDIRECT) {
if (cfg->verbose_level > 2) {
if (!kills)
return FALSE;
- for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
- for (ins = bb->code; ins; ins = ins->next) {
+ for (MonoBasicBlock *bb = cfg->bb_entry; bb; bb = bb->next_bb) {
+ for (MonoInst *ins = bb->code; ins; ins = ins->next) {
if (ins->opcode == OP_LDADDR) {
MonoInst *var;
MonoMethodHeader *header = cfg->header;
MonoExceptionClause *clause;
MonoClass *exclass;
- int i;
if (!(cfg->opt & MONO_OPT_EXCEPTION))
return NULL;
exclass = mono_class_load_from_name (mono_get_corlib (), "System", exname);
/* search for the handler */
- for (i = 0; i < header->num_clauses; ++i) {
+ for (guint i = 0; i < header->num_clauses; ++i) {
clause = &header->clauses [i];
if (MONO_OFFSET_IN_CLAUSE (clause, bb->real_offset)) {
if (clause->flags == MONO_EXCEPTION_CLAUSE_NONE && clause->data.catch_class && mono_class_is_assignable_from_internal (clause->data.catch_class, exclass)) {
int result, expected, failed, cfailed, run, code_size;
double elapsed, comp_time, start_time;
char *n;
- int i;
mono_set_defaults (verbose, opt_flags);
n = mono_opt_descr (opt_flags);
g_timer_start (timer);
if (mini_stats_fd)
fprintf (mini_stats_fd, "[");
- for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
+ for (guint32 i = 0; i < table_info_get_rows (&image->tables [MONO_TABLE_METHOD]); ++i) {
ERROR_DECL (error);
MonoMethod *method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL, NULL, error);
if (!method) {
static int
mini_regression (MonoImage *image, int verbose, int *total_run)
{
- guint32 i, opt;
MonoMethod *method;
char *n;
GTimer *timer = g_timer_new ();
fprintf (mini_stats_fd, "$stattitle = \'Mono Benchmark Results (various optimizations)\';\n");
fprintf (mini_stats_fd, "$graph->set_legend(qw(");
- for (opt = 0; opt < G_N_ELEMENTS (opt_sets); opt++) {
+ for (guint32 opt = 0; opt < G_N_ELEMENTS (opt_sets); opt++) {
guint32 opt_flags = opt_sets [opt];
n = mono_opt_descr (opt_flags);
if (!n [0])
}
/* load the metadata */
- for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
+ for (guint32 i = 0; i < table_info_get_rows (&image->tables [MONO_TABLE_METHOD]); ++i) {
ERROR_DECL (error);
method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL, NULL, error);
if (!method) {
return total;
}
} else {
- for (opt = 0; opt < G_N_ELEMENTS (opt_sets); ++opt) {
+ for (guint32 opt = 0; opt < G_N_ELEMENTS (opt_sets); ++opt) {
/* aot-tests.cs need OPT_INTRINS enabled */
if (!strcmp ("aot-tests", image->assembly_name))
if (!(opt_sets [opt] & MONO_OPT_INTRINS))
{
int result, expected, failed, cfailed, run;
double elapsed, transform_time;
- int i;
MonoObject *result_obj;
int local_skip_index = 0;
mini_get_interp_callbacks ()->invalidate_transformed ();
g_timer_start (timer);
- for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
+ for (guint32 i = 0; i < table_info_get_rows (&image->tables [MONO_TABLE_METHOD]); ++i) {
ERROR_DECL (error);
MonoMethod *method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL, NULL, error);
if (!method) {
{
MonoMethod *method;
GTimer *timer = g_timer_new ();
- guint32 i;
int total;
/* load the metadata */
- for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
+ for (guint32 i = 0; i < table_info_get_rows (&image->tables [MONO_TABLE_METHOD]); ++i) {
ERROR_DECL (error);
method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL, NULL, error);
if (!method) {
MonoImage *image = mono_assembly_get_image_internal (ass);
MonoMethod *method;
MonoCompile *cfg;
- int i, count = 0, fail_count = 0;
+ int count = 0, fail_count = 0;
- for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
+ for (guint32 i = 0; i < table_info_get_rows (&image->tables [MONO_TABLE_METHOD]); ++i) {
ERROR_DECL (error);
guint32 token = MONO_TOKEN_METHOD_DEF | (i + 1);
MonoMethodSignature *sig;
int new_argc = parsed_options->len + argc;
char **new_argv = g_new (char *, new_argc + 1);
guint i;
- guint j;
new_argv [0] = argv [0];
new_argv [i+1] = (char *)g_ptr_array_index (parsed_options, i);
i++;
}
- for (j = 1; j < argc; j++)
+ for (int j = 1; j < argc; j++)
new_argv [i++] = argv [j];
if (!prepend){
- for (j = 0; j < parsed_options->len; j++)
+ for (guint j = 0; j < parsed_options->len; j++)
new_argv [i++] = (char *)g_ptr_array_index (parsed_options, j);
}
new_argv [i] = NULL;
g_assert_checked (found_entry->end_range >= begin_range && found_entry->end_range >= end_range);
g_assert_checked (found_entry->rt_funcs != NULL);
- for (int i = 0; i < found_entry->rt_funcs_current_count; ++i) {
+ for (DWORD i = 0; i < found_entry->rt_funcs_current_count; ++i) {
PRUNTIME_FUNCTION current_rt_func = (PRUNTIME_FUNCTION)(&found_entry->rt_funcs [i]);
// Is this our RT function entry?
PRUNTIME_FUNCTION current_rt_func = NULL;
PRUNTIME_FUNCTION previous_rt_func = NULL;
- for (int i = 0; i < entry->rt_funcs_current_count; ++i) {
+ for (DWORD i = 0; i < entry->rt_funcs_current_count; ++i) {
current_rt_func = &(entry->rt_funcs [i]);
g_assert_checked (current_rt_func->BeginAddress < current_rt_func->EndAddress);
dtree_emit_one_loop_level (MonoCompile *cfg, FILE *fp, MonoBasicBlock *h)
{
MonoBasicBlock *bb;
- int i, level = 0;
+ gint8 level = 0;
if (h) {
level = h->nesting;
fprintf (fp, "label=\"loop_%d\"\n", h->block_num);
}
- for (i = 1; i < cfg->num_bblocks; ++i) {
+ for (guint i = 1; i < cfg->num_bblocks; ++i) {
bb = cfg->bblocks [i];
if (!h || (g_list_find (h->loop_blocks, bb) && bb != h)) {
mono_blockset_print (MonoCompile *cfg, MonoBitSet *set, const char *name, guint idom)
{
#ifndef DISABLE_LOGGING
- int i;
+ guint i;
if (name)
g_print ("%s:", name);
if (!(cfg->opt & MONO_OPT_ABCREM)) {
MONO_EMIT_NULL_CHECK (cfg, array_reg, FALSE);
if (COMPILE_LLVM (cfg))
- MONO_EMIT_DEFAULT_BOUNDS_CHECK ((cfg), (array_reg), (array_length_offset), (index_reg), TRUE, ex_name);
+ MONO_EMIT_DEFAULT_BOUNDS_CHECK ((cfg), (array_reg), GINT_TO_UINT(array_length_offset), (index_reg), TRUE, ex_name);
else
MONO_ARCH_EMIT_BOUNDS_CHECK ((cfg), (array_reg), (array_length_offset), (index_reg), ex_name);
} else {
vmv = (MonoMethodVar *)l->data;
if (vmv->reg >= 0) {
- if ((gains [vmv->reg] > mono_arch_regalloc_cost (cfg, vmv)) && (cfg->varinfo [vmv->idx]->opcode != OP_REGVAR)) {
+ if ((GINT_TO_UINT32(gains [vmv->reg]) > mono_arch_regalloc_cost (cfg, vmv)) && (cfg->varinfo [vmv->idx]->opcode != OP_REGVAR)) {
if (cfg->verbose_level > 2) {
printf ("ALLOCATED R%d(%d) TO HREG %d COST %d\n", cfg->varinfo [vmv->idx]->dreg, vmv->idx, vmv->reg, vmv->spill_costs);
}
/* During allocation, vmv->reg is an index into the regs list */
vmv->reg = GPOINTER_TO_INT (g_list_nth_data (regs, vmv->reg));
- if ((gains [reg_index] > regalloc_cost (cfg, vmv)) && (cfg->varinfo [vmv->idx]->opcode != OP_REGVAR)) {
+ if ((GINT_TO_UINT32(gains [reg_index]) > regalloc_cost (cfg, vmv)) && (cfg->varinfo [vmv->idx]->opcode != OP_REGVAR)) {
if (cfg->verbose_level > 2)
printf ("REGVAR R%d G%d C%d %s\n", cfg->varinfo [vmv->idx]->dreg, gains [reg_index], regalloc_cost (cfg, vmv), mono_arch_regname (vmv->reg));
cfg->varinfo [vmv->idx]->opcode = OP_REGVAR;
Buffer tmpbuf;
Buffer *buf = &tmpbuf;
MonoDebugMethodInfo *minfo;
- int i, j, n_il_offsets;
+ int n_il_offsets;
int *source_files;
GPtrArray *source_file_list;
MonoSymSeqPoint *sym_seq_points;
if (minfo && seq_points) {
mono_debug_get_seq_points (minfo, NULL, &source_file_list, &source_files, &sym_seq_points, &n_il_offsets);
buffer_add_int (buf, source_file_list->len);
- for (i = 0; i < source_file_list->len; ++i) {
+ for (guint i = 0; i < source_file_list->len; ++i) {
MonoDebugSourceInfo *sinfo = (MonoDebugSourceInfo *)g_ptr_array_index (source_file_list, i);
buffer_add_string (buf, sinfo->source_file);
- for (j = 0; j < 16; ++j)
+ for (guint j = 0; j < 16; ++j)
buffer_add_byte (buf, sinfo->hash [j]);
}
// The sym seq points are ordered by il offset, need to order them by address
int skipped = 0;
locs = g_new0 (FullSeqPoint, n_il_offsets);
- for (i = 0; i < n_il_offsets; ++i) {
+ for (int i = 0; i < n_il_offsets; ++i) {
locs [i].sp = sym_seq_points [i];
// FIXME: O(n^2)
n_il_offsets -= skipped;
buffer_add_int (buf, n_il_offsets);
- for (i = 0; i < n_il_offsets; ++i) {
+ for (int i = 0; i < n_il_offsets; ++i) {
MonoSymSeqPoint *sp = &locs [i].sp;
//printf ("%s %x %d %d\n", cfg->method->name, locs [i].native_offset, sp->il_offset, sp->line);
GSharedVtCallInfo *info;
CallInfo *caller_cinfo, *callee_cinfo;
MonoMethodSignature *caller_sig, *callee_sig;
- int aindex, i;
gboolean var_ret = FALSE;
CallInfo *cinfo, *gcinfo;
MonoMethodSignature *sig;
*/
map = g_ptr_array_new ();
- for (aindex = 0; aindex < cinfo->nargs; ++aindex) {
+ for (int aindex = 0; aindex < cinfo->nargs; ++aindex) {
ArgInfo *src_info = &caller_cinfo->args [aindex];
ArgInfo *dst_info = &callee_cinfo->args [aindex];
int *src = NULL, *dst = NULL;
nslots = MIN (nsrc, ndst);
DEBUG_AMD64_GSHAREDVT_PRINT ("nsrc %d ndst %d\n", nsrc, ndst);
- for (i = 0; i < nslots; ++i)
+ for (int i = 0; i < nslots; ++i)
add_to_map (map, src [i], dst [i]);
g_free (src);
#ifdef DEBUG_AMD64_GSHAREDVT
printf ("final map:\n");
- for (i = 0; i < map->len; i += 2) {
+ for (guint i = 0; i < map->len; i += 2) {
printf ("\t[%d] src %x dst %x\n ",
i / 2,
GPOINTER_TO_UINT (g_ptr_array_index (map, i)),
info->vcall_offset = vcall_offset;
info->map_count = map->len / 2;
- for (i = 0; i < map->len; ++i)
+ for (guint i = 0; i < map->len; ++i)
info->map [i] = GPOINTER_TO_UINT (g_ptr_array_index (map, i));
g_ptr_array_free (map, TRUE);
MONO_ADD_INS (cfg->cbb, args_alloc);
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, alloc->dreg, MONO_STRUCT_OFFSET (MonoProfilerCallContext, args), args_alloc->dreg);
- for (int i = 0; i < sig->hasthis + sig->param_count; ++i) {
+ for (guint i = 0; i < sig->hasthis + sig->param_count; ++i) {
NEW_VARLOADA (cfg, ins, cfg->args [i], cfg->args [i]->inst_vtype);
MONO_ADD_INS (cfg->cbb, ins);
mini_init_gsctx (MonoMemPool *mp, MonoGenericContext *context, MonoGenericSharingContext *gsctx)
{
MonoGenericInst *inst;
- int i;
memset (gsctx, 0, sizeof (MonoGenericSharingContext));
if (context && context->class_inst) {
inst = context->class_inst;
- for (i = 0; i < inst->type_argc; ++i) {
+ for (guint i = 0; i < inst->type_argc; ++i) {
MonoType *type = inst->type_argv [i];
if (mini_is_gsharedvt_gparam (type))
if (context && context->method_inst) {
inst = context->method_inst;
- for (i = 0; i < inst->type_argc; ++i) {
+ for (guint i = 0; i < inst->type_argc; ++i) {
MonoType *type = inst->type_argv [i];
if (mini_is_gsharedvt_gparam (type))
static JitCompilationEntry*
find_method (MonoMethod *method)
{
- int i;
- for (i = 0; i < compilation_data.in_flight_methods->len; ++i){
+ for (guint i = 0; i < compilation_data.in_flight_methods->len; ++i){
JitCompilationEntry *e = (JitCompilationEntry*)compilation_data.in_flight_methods->pdata [i];
if (e->method == method)
return e;
GHashTable *assemblies = (GHashTable*)user_data;
MonoImage *image = mono_assembly_get_image_internal (ass);
MonoMethod *method, *invoke;
- int i, count = 0;
+ int count = 0;
if (g_hash_table_lookup (assemblies, ass))
return;
if (mini_verbose > 0)
printf ("PRECOMPILE: %s.\n", mono_image_get_filename (image));
- for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
+ for (guint32 i = 0; i < table_info_get_rows (&image->tables [MONO_TABLE_METHOD]); ++i) {
ERROR_DECL (error);
method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL, NULL, error);
}
/* Load and precompile referenced assemblies as well */
- for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_ASSEMBLYREF); ++i) {
+ for (guint32 i = 0; i < table_info_get_rows (&image->tables [MONO_TABLE_ASSEMBLYREF]); ++i) {
mono_assembly_load_reference (image, i);
if (image->references [i])
mono_precompile_assembly (image->references [i], assemblies);
*
* query pagesize used to determine if an implicit NRE can be used
*/
-int
+guint
mono_target_pagesize (void)
{
/* We could query the system's pagesize via mono_pagesize (), however there
#define vreg_is_volatile(cfg, vreg) (G_UNLIKELY (get_vreg_to_inst ((cfg), (vreg)) && (get_vreg_to_inst ((cfg), (vreg))->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT))))
-#define vreg_is_ref(cfg, vreg) ((vreg) < (cfg)->vreg_is_ref_len ? (cfg)->vreg_is_ref [(vreg)] : 0)
-#define vreg_is_mp(cfg, vreg) ((vreg) < (cfg)->vreg_is_mp_len ? (cfg)->vreg_is_mp [(vreg)] : 0)
+#define vreg_is_ref(cfg, vreg) (GINT_TO_UINT32(vreg) < (cfg)->vreg_is_ref_len ? (cfg)->vreg_is_ref [(vreg)] : 0)
+#define vreg_is_mp(cfg, vreg) (GINT_TO_UINT32(vreg) < (cfg)->vreg_is_mp_len ? (cfg)->vreg_is_mp [(vreg)] : 0)
/*
* Control Flow Graph and compilation unit information
MonoInst* mono_emit_jit_icall_by_info (MonoCompile *cfg, int il_offset, MonoJitICallInfo *info, MonoInst **args);
MonoInst* mono_emit_method_call (MonoCompile *cfg, MonoMethod *method, MonoInst **args, MonoInst *this_ins);
gboolean mini_should_insert_breakpoint (MonoMethod *method);
-int mono_target_pagesize (void);
+guint mono_target_pagesize (void);
gboolean mini_class_is_system_array (MonoClass *klass);
size_t basename_len;
basename_len = strlen (basename);
- for (int i = 0; i < a->assembly_count; ++i) {
+ for (guint32 i = 0; i < a->assembly_count; ++i) {
if (basename_len == a->basename_lens [i] && !g_strncasecmp (basename, a->basenames [i], a->basename_lens [i])) {
MonoAssemblyOpenRequest req;
mono_assembly_request_prepare_open (&req, default_alc);
MonoBasicBlock *bb;
GSList *bb_seq_points, *l;
MonoInst *last;
- int i, seq_info_size;
+ int seq_info_size;
GSList **next = NULL;
SeqPoint* seq_points;
GByteArray* array;
seq_points = g_new0 (SeqPoint, cfg->seq_points->len);
- for (i = 0; i < cfg->seq_points->len; ++i) {
+ for (guint i = 0; i < cfg->seq_points->len; ++i) {
SeqPoint *sp = &seq_points [i];
MonoInst *ins = (MonoInst *)g_ptr_array_index (cfg->seq_points, i);
sp->il_offset = GTMREG_TO_INT (ins->inst_imm);
if (cfg->verbose_level > 2) {
printf ("\nSEQ POINT MAP: \n");
- for (i = 0; i < cfg->seq_points->len; ++i) {
+ for (guint i = 0; i < cfg->seq_points->len; ++i) {
SeqPoint *sp = &seq_points [i];
if (!next [i])
SeqPoint zero_seq_point = {0};
SeqPoint* last_seq_point = &zero_seq_point;
- for (i = 0; i < cfg->seq_points->len; ++i) {
+ for (guint i = 0; i < cfg->seq_points->len; ++i) {
SeqPoint *sp = &seq_points [i];
GSList* next_list = NULL;
mono_unwind_ops_encode_full (GSList *unwind_ops, guint32 *out_len, gboolean enable_extensions)
{
MonoUnwindOp *op;
- int loc = 0;
+ guint32 loc = 0;
guint8 buf [4096];
guint8 *p, *res;
if (!end)
return !strcmp (arg, opt_name);
- if (strncmp (arg, opt_name, strlen (opt_name)) || (end - arg) > strlen (opt_name) + 1)
+ if (strncmp (arg, opt_name, strlen (opt_name)) || (end - arg) > GSIZE_TO_SSIZE(strlen (opt_name)) + 1)
return FALSE;
*rval = end + 1;
return TRUE;
static int
add_ginst (MonoProfiler *prof, MonoGenericInst *inst)
{
- int i, id;
+ int id;
int *ids;
// FIXME: Cache
ids = g_malloc0 (inst->type_argc * sizeof (int));
- for (i = 0; i < inst->type_argc; ++i) {
+ for (guint i = 0; i < inst->type_argc; ++i) {
MonoType *t = inst->type_argv [i];
ids [i] = add_type (prof, t);
if (ids [i] == -1) {
id = prof->id ++;
emit_record (prof, AOTPROF_RECORD_GINST, id);
emit_int32 (prof, inst->type_argc);
- for (i = 0; i < inst->type_argc; ++i)
+ for (guint i = 0; i < inst->type_argc; ++i)
emit_int32 (prof, ids [i]);
g_free (ids);
if (already_shutdown)
return;
- int mindex;
char magic [32];
prof->buf_len = 4096;
GHashTable *all_methods = g_hash_table_new (NULL, NULL);
mono_os_mutex_lock (&prof->mutex);
- for (mindex = 0; mindex < prof->methods->len; ++mindex) {
+ for (guint mindex = 0; mindex < prof->methods->len; ++mindex) {
MonoMethod *m = (MonoMethod*)g_ptr_array_index (prof->methods, mindex);
if (!mono_method_get_token (m))
static void
descriptor_check_consistency (Descriptor *desc, gboolean print)
{
- int count = desc->anchor.data.count;
- int max_count = LOCK_FREE_ALLOC_SB_USABLE_SIZE (desc->block_size) / desc->slot_size;
+ guint32 count = desc->anchor.data.count;
+ guint32 max_count = LOCK_FREE_ALLOC_SB_USABLE_SIZE (desc->block_size) / desc->slot_size;
gboolean* linked = g_newa (gboolean, max_count);
- int i, last;
- unsigned int index;
+ int last;
+ guint32 index;
#ifndef DESC_AVAIL_DUMMY
Descriptor *avail;
g_assert_OR_PRINT (FALSE, "invalid state\n");
}
- for (i = 0; i < max_count; ++i)
+ for (guint32 i = 0; i < max_count; ++i)
linked [i] = FALSE;
index = desc->anchor.data.avail;
last = -1;
- for (i = 0; i < count; ++i) {
+ for (guint32 i = 0; i < count; ++i) {
gpointer addr = (char*)desc->sb + index * desc->slot_size;
g_assert_OR_PRINT (index >= 0 && index < max_count,
"index %d for %dth available slot, linked from %d, not in range [0 .. %d)\n",
if (recorder->cursor == MONO_FLIGHT_RECORDER_SENTINEL) {
iter->lowest_index = MONO_FLIGHT_RECORDER_SENTINEL;
iter->highest_index = MONO_FLIGHT_RECORDER_SENTINEL;
- } else if (recorder->cursor >= recorder->max_count) {
+ } else if (GINTPTR_TO_SIZE(recorder->cursor) >= recorder->max_count) {
// Ring buffer has wrapped around
// So the item *after* the highest index is the lowest index
iter->highest_index = (recorder->cursor + 1) % recorder->max_count;
return FALSE;
g_assert (iter->lowest_index >= 0);
- g_assert (iter->lowest_index < iter->recorder->max_count);
+ g_assert (GINTPTR_TO_SIZE(iter->lowest_index) < iter->recorder->max_count);
// Reference to the variably-sized logging payload
memcpy (payload, (gpointer *) &iter->recorder->items [iter->lowest_index]->payload, iter->recorder->payload_size);
memcpy (header, (gpointer *) &iter->recorder->items [iter->lowest_index]->header, sizeof (MonoFlightRecorderHeader));
iter->lowest_index++;
- if (iter->lowest_index >= iter->recorder->max_count)
+ if (GINTPTR_TO_SIZE(iter->lowest_index) >= iter->recorder->max_count)
iter->lowest_index = iter->lowest_index % iter->recorder->max_count;
return TRUE;
mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
{
struct timeval tv, *tvptr;
- int i, fd, events, affected, count;
+ int fd, events, affected, count;
fd_set rfds, wfds, efds;
int nexc = 0;
int maxfd = 0;
FD_ZERO (&wfds);
FD_ZERO (&efds);
- for (i = 0; i < nfds; i++) {
+ for (unsigned int i = 0; i < nfds; i++) {
ufds [i].revents = 0;
fd = ufds [i].fd;
if (fd < 0)
}
count = 0;
- for (i = 0; i < nfds && affected > 0; i++) {
+ for (unsigned int i = 0; i < nfds && affected > 0; i++) {
fd = ufds [i].fd;
if (fd < 0)
continue;
do \
{ \
MonoBitSet *__set = (set); \
- for (int __i = 0; __i < __set->size / MONO_BITSET_BITS_PER_CHUNK; __i++) { \
+ for (gsize __i = 0; __i < __set->size / MONO_BITSET_BITS_PER_CHUNK; __i++) { \
if (__set->data [__i]) { \
- for (int __j = 0; __j < MONO_BITSET_BITS_PER_CHUNK; __j++) { \
+ for (gsize __j = 0; __j < MONO_BITSET_BITS_PER_CHUNK; __j++) { \
if (__set->data [__i] & ((gsize) 1 << __j)) { \
- guint idx = __j + __i * MONO_BITSET_BITS_PER_CHUNK; \
+ gsize idx = __j + __i * MONO_BITSET_BITS_PER_CHUNK; \
__VA_ARGS__; \
} \
} \
MONO_API_FUNCTION(char*, mono_image_rva_map, (MonoImage *image, uint32_t rva))
MONO_API_FUNCTION(const MonoTableInfo *, mono_image_get_table_info, (MonoImage *image, int table_id))
-MONO_API_FUNCTION(int, mono_image_get_table_rows, (MonoImage *image, int table_id))
-MONO_API_FUNCTION(int, mono_table_info_get_rows, (const MonoTableInfo *table))
+MONO_API_FUNCTION(MONO_RT_EXTERNAL_ONLY int, mono_image_get_table_rows, (MonoImage *image, int table_id))
+MONO_API_FUNCTION(MONO_RT_EXTERNAL_ONLY int, mono_table_info_get_rows, (const MonoTableInfo *table))
/* This actually returns a MonoPEResourceDataEntry *, but declaring it
* causes an include file loop.