diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 555b928bd07a4..963a48a909063 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -263,7 +263,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") set(MONO_ZERO_LEN_ARRAY 1) set(INTERNAL_ZLIB 1) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") # statically link VC runtime library - add_compile_options(/W3) # set warning level 3 + add_compile_options(/W4) # set warning level 4 add_compile_options(/EHsc) # set exception handling behavior add_compile_options(/FC) # use full pathnames in diagnostics add_link_options(/STACK:0x800000) # set stack size to 8MB (default is 1MB) @@ -623,7 +623,14 @@ if(LLVM_PREFIX) set(LLVM_LIBDIR "${LLVM_PREFIX}/lib") set(LLVM_INCLUDEDIR "${llvm_includedir}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${llvm_cflags}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${llvm_cxxflags} -fexceptions -fno-rtti") + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + # /EHsc already enabled, prevent LLVM flags to disable it. Corresponds to -fexceptions. + string(REPLACE "/EHs-c-" "" llvm_cxxflags "${llvm_cxxflags}") + # /GR- already enabled and inherited from LLVM flags. Corresponds to -fno-rtti. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${llvm_cxxflags}") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${llvm_cxxflags} -fexceptions -fno-rtti") + endif() add_definitions(-DLLVM_API_VERSION=${llvm_api_version}) endif() diff --git a/src/mono/cmake/config.h.in b/src/mono/cmake/config.h.in index fc25f49cad953..7b8a193da0c24 100644 --- a/src/mono/cmake/config.h.in +++ b/src/mono/cmake/config.h.in @@ -4,23 +4,47 @@ #ifdef _MSC_VER // FIXME This is all questionable but the logs are flooded and nothing else is fixing them. -#pragma warning(disable:4018) // signed/unsigned mismatch -#pragma warning(disable:4090) // const problem -#pragma warning(disable:4146) // unary minus operator applied to unsigned type, result still unsigned -#pragma warning(disable:4244) // integer conversion, possible loss of data +#pragma warning(disable:4018) // W3: signed/unsigned mismatch +#pragma warning(disable:4090) // W1: const problem +#pragma warning(disable:4100) // W4: unreferenced formal parameter +#pragma warning(disable:4152) // W4: nonstandard extension, function/data pointer conversion in expression +#pragma warning(disable:4201) // W4: nonstandard extension used: nameless struct/union +#pragma warning(disable:4210) // W4: nonstandard extension used: function given file scope +#pragma warning(disable:4244) // W2: integer conversion, possible loss of data +#pragma warning(disable:4245) // W4: signed/unsigned mismatch +#pragma warning(disable:4389) // W4: signed/unsigned mismatch +#pragma warning(disable:4505) // W4: unreferenced function with internal linkage has been removed +#pragma warning(disable:4702) // W4: unreachable code +#pragma warning(disable:4706) // W4: assignment within conditional expression // promote warnings to errors -#pragma warning( error:4013) // function undefined; assuming extern returning int -#pragma warning( error:4022) // call and prototype disagree -#pragma warning( error:4047) // differs in level of indirection -#pragma warning( error:4098) // void return returns a value -#pragma warning( error:4113) // call and prototype disagree -#pragma warning( error:4172) // returning address of local variable or temporary -#pragma warning( error:4197) // top-level volatile in cast is ignored -#pragma warning( error:4273) // inconsistent dll linkage -#pragma warning( error:4293) // shift count negative or too big, undefined behavior -#pragma warning( error:4312) // 'type cast': conversion from 'MonoNativeThreadId' to 'gpointer' of greater size -#pragma warning( error:4715) // 'keyword' not all control paths return a value +#pragma warning(error:4005) // W1: 'identifier' : macro redefinition +#pragma warning(error:4013) // W3: function undefined; assuming extern returning int +#pragma warning(error:4022) // W1: call and prototype disagree +#pragma warning(error:4047) // W1: differs in level of indirection +#pragma warning(error:4065) // W?: switch with default but no case +#pragma warning(error:4098) // W1: void return returns a value +#pragma warning(error:4113) // W1: call and prototype disagree +#pragma warning(error:4127) // W4: conditional expression is constant +#pragma warning(error:4131) // W4: 'function' : uses old-style declarator +#pragma warning(error:4146) // W2: unary minus operator applied to unsigned type, result still unsigned +#pragma warning(error:4172) // W1: returning address of local variable or temporary +#pragma warning(error:4189) // W4: local variable is initialized but not referenced +#pragma warning(error:4197) // W3: top-level volatile in cast is ignored +#pragma warning(error:4273) // W1: inconsistent dll linkage +#pragma warning(error:4293) // W1: shift count negative or too big, undefined behavior +#pragma warning(error:4297) // W1: function assumed not to throw an exception but does +#pragma warning(error:4306) // W2: conversion from 'type1' to 'type2' of greater size +#pragma warning(error:4309) // W2: truncation of constant +#pragma warning(error:4310) // W3: cast truncates constant value +#pragma warning(error:4312) // W1: conversion from 'type1' to 'type2' of greater size +#pragma warning(error:4324) // W4: structure was padded due to __declspec(align()) +#pragma warning(error:4456) // W4: declaration of 'identifier' hides previous local declaration +#pragma warning(error:4459) // W4: declaration of 'identifier' hides global declaration +#pragma warning(error:4701) // W4: potentially uninitialized local variable 'name' used +#pragma warning(error:4703) // W4: potentially uninitialized local pointer variable 'name' used +#pragma warning(error:4715) // W1: 'function' : not all control paths return a value +#pragma warning(error:4740) // W4: flow in or out of inline asm code suppresses global optimization, x86 only #include diff --git a/src/mono/dlls/mscordbi/socket-dbi/socket.cpp b/src/mono/dlls/mscordbi/socket-dbi/socket.cpp index 40ffe66d49cde..69d123c5b8cd0 100644 --- a/src/mono/dlls/mscordbi/socket-dbi/socket.cpp +++ b/src/mono/dlls/mscordbi/socket-dbi/socket.cpp @@ -30,25 +30,26 @@ #endif #include #include +#define INVALID_SOCKET -1 +#define SOCKET_ERROR -1 #endif - Socket::~Socket() { Close(); } int Socket::OpenSocketAcceptConnection(const char *address, const char *port) { - socketId = -1; + socketId = INVALID_SOCKET; #ifdef WIN32 - WSADATA wsadata; - int err; + WSADATA wsadata; + int err; - err = WSAStartup (2, &wsadata); - if (err) { + err = WSAStartup (2, &wsadata); + if (err) { return -1; - } + } #endif struct addrinfo *result = NULL, *ptr = NULL, hints; @@ -71,7 +72,7 @@ int Socket::OpenSocketAcceptConnection(const char *address, const char *port) { // Create a SOCKET for connecting to server socketId = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol); - if (socketId == -1) { + if (socketId == INVALID_SOCKET) { return -1; } @@ -80,17 +81,17 @@ int Socket::OpenSocketAcceptConnection(const char *address, const char *port) { continue; iResult = bind(socketId, ptr->ai_addr, (int)ptr->ai_addrlen); - if (iResult == -1) + if (iResult == SOCKET_ERROR) continue; iResult = listen(socketId, 16); - if (iResult == -1) + if (iResult == SOCKET_ERROR) continue; break; } - if (iResult != -1) + if (iResult != SOCKET_ERROR) socketId = accept(socketId, NULL, NULL); freeaddrinfo(result); diff --git a/src/mono/dlls/mscordbi/socket-dbi/socket.h b/src/mono/dlls/mscordbi/socket-dbi/socket.h index 62e321fe249f8..7f41cdfcc03e2 100644 --- a/src/mono/dlls/mscordbi/socket-dbi/socket.h +++ b/src/mono/dlls/mscordbi/socket-dbi/socket.h @@ -7,8 +7,17 @@ #ifndef __SOCKET_DBI_H__ #define __SOCKET_DBI_H__ +#ifdef WIN32 +#include +#endif + class Socket { +#ifdef WIN32 + SOCKET socketId; +#else long long socketId; +#endif + public: ~Socket(); int OpenSocketAcceptConnection(const char *address, const char *port); diff --git a/src/mono/mono/arch/x86/x86-codegen.h b/src/mono/mono/arch/x86/x86-codegen.h index c4edb3c1e2d62..9e0ae5605bb5a 100644 --- a/src/mono/mono/arch/x86/x86-codegen.h +++ b/src/mono/mono/arch/x86/x86-codegen.h @@ -280,7 +280,7 @@ typedef union { x86_byte (inst, imb.b [2]); \ x86_byte (inst, imb.b [3]); \ } while (0) -#define x86_imm_emit16(inst,imm) do { *(short*)(inst) = (imm); (inst) += 2; } while (0) +#define x86_imm_emit16(inst,imm) do { *(short*)(inst) = (short)(imm); (inst) += 2; } while (0) #define x86_imm_emit8(inst,imm) do { *(inst) = (unsigned char)((imm) & 0xff); ++(inst); } while (0) #define x86_is_imm8(imm) (((int)(imm) >= -128 && (int)(imm) <= 127)) #define x86_is_imm16(imm) (((int)(imm) >= -(1<<16) && (int)(imm) <= ((1<<16)-1))) @@ -1783,45 +1783,45 @@ mono_x86_patch_inline (guchar* code, gpointer target) #if defined(TARGET_X86) #define x86_branch(inst,cond,target,is_signed) \ do { \ - int offset; \ - guint8* branch_start; \ + int __offset; \ + guint8* __branch_start; \ x86_codegen_pre(&(inst), 2); \ - offset = (target) - (inst) - 2; \ - branch_start = (inst); \ - if (x86_is_imm8 ((offset))) \ - x86_branch8 ((inst), (cond), offset, (is_signed)); \ - else { \ + __offset = (target) - (inst) - 2; \ + __branch_start = (inst); \ + if (x86_is_imm8 ((__offset))) \ + x86_branch8 ((inst), (cond), __offset, (is_signed)); \ + else { \ x86_codegen_pre(&(inst), 6); \ - offset = (target) - (inst) - 6; \ - x86_branch32 ((inst), (cond), offset, (is_signed)); \ - } \ - x86_patch(branch_start, (target)); \ + __offset = (target) - (inst) - 6; \ + x86_branch32 ((inst), (cond), __offset, (is_signed)); \ + } \ + x86_patch(__branch_start, (target)); \ } while (0) #elif defined(TARGET_AMD64) /* This macro is used directly from mini-amd64.c and other */ /* amd64 specific files, so it needs to be instrumented directly. */ -#define x86_branch(inst,cond,target,is_signed) \ - do { \ - int offset = (target) - (inst) - 2; \ - if (x86_is_imm8 ((offset))) \ - x86_branch8 ((inst), (cond), offset, (is_signed)); \ - else { \ - offset = (target) - (inst) - 6; \ - x86_branch32 ((inst), (cond), offset, (is_signed)); \ - } \ +#define x86_branch(inst,cond,target,is_signed) \ + do { \ + int __offset = (target) - (inst) - 2; \ + if (x86_is_imm8 ((__offset))) \ + x86_branch8 ((inst), (cond), __offset, (is_signed)); \ + else { \ + __offset = (target) - (inst) - 6; \ + x86_branch32 ((inst), (cond), __offset, (is_signed)); \ + } \ } while (0) #endif /* TARGET_AMD64 */ #define x86_branch_disp(inst,cond,disp,is_signed) \ do { \ - int offset = (disp) - 2; \ - if (x86_is_imm8 ((offset))) \ - x86_branch8 ((inst), (cond), offset, (is_signed)); \ + int __offset = (disp) - 2; \ + if (x86_is_imm8 ((__offset))) \ + x86_branch8 ((inst), (cond), __offset, (is_signed)); \ else { \ - offset -= 4; \ - x86_branch32 ((inst), (cond), offset, (is_signed)); \ + __offset -= 4; \ + x86_branch32 ((inst), (cond), __offset, (is_signed)); \ } \ } while (0) diff --git a/src/mono/mono/component/debugger-agent.c b/src/mono/mono/component/debugger-agent.c index 05ebfe06f973d..2bd5aeef4c06f 100644 --- a/src/mono/mono/component/debugger-agent.c +++ b/src/mono/mono/component/debugger-agent.c @@ -1008,9 +1008,9 @@ socket_transport_send (void *data, int len) static void socket_transport_connect (const char *address) { - MonoAddressInfo *result; + MonoAddressInfo *result = NULL; MonoAddressEntry *rp; - int sfd = -1, s, res; + int sfd = -1, s = 0, res; char *host; int port; @@ -1042,7 +1042,7 @@ socket_transport_connect (const char *address) MONO_HINT_UNSPECIFIED }; - for (int i = 0; i < sizeof(hints) / sizeof(int); i++) { + for (size_t i = 0; i < sizeof(hints) / sizeof(int); i++) { /* Obtain address(es) matching host/port */ MONO_ENTER_GC_UNSAFE; s = mono_get_address_info (host, port, hints[i], &result); @@ -3295,7 +3295,6 @@ init_jit_info_dbg_attrs (MonoJitInfo *ji) static GSList* create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, EventInfo *ei, int *suspend_policy) { - int i, j; GSList *events = NULL; *suspend_policy = SUSPEND_POLICY_NONE; @@ -3313,13 +3312,13 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, EventInfo gint everything_else_suspend_policy = 0; gint everything_else_req_id = 0; gboolean is_already_filtered = FALSE; - for (i = 0; i < reqs->len; ++i) { + for (guint i = 0; i < reqs->len; ++i) { EventRequest *req = (EventRequest *)g_ptr_array_index (reqs, i); if (req->event_kind == event) { gboolean filtered = FALSE; /* Apply filters */ - for (j = 0; j < req->nmodifiers; ++j) { + for (int j = 0; j < req->nmodifiers; ++j) { Modifier *mod = &req->modifiers [j]; if (mod->kind == MOD_KIND_COUNT) { @@ -3386,7 +3385,6 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, EventInfo MonoDebugSourceInfo *sinfo; char *s; gboolean found = FALSE; - int i; GPtrArray *source_file_list; while ((method = mono_class_get_methods (ei->klass, &iter))) { @@ -3394,8 +3392,8 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, EventInfo if (minfo) { mono_debug_get_seq_points (minfo, NULL, &source_file_list, NULL, NULL, NULL); - for (i = 0; i < source_file_list->len; ++i) { - sinfo = (MonoDebugSourceInfo *)g_ptr_array_index (source_file_list, i); + for (guint k = 0; k < source_file_list->len; ++k) { + sinfo = (MonoDebugSourceInfo *)g_ptr_array_index (source_file_list, k); /* * Do a case-insesitive match by converting the file name to * lowercase. @@ -4022,7 +4020,7 @@ send_assemblies_for_domain (MonoDomain *domain, void *user_data) mono_domain_set_fast (domain); GPtrArray *assemblies = mono_alc_get_all_loaded_assemblies (); - for (int i = 0; i < assemblies->len; ++i) + for (guint i = 0; i < assemblies->len; ++i) emit_assembly_load ((MonoAssembly*)g_ptr_array_index (assemblies, i), NULL); g_ptr_array_free (assemblies, TRUE); @@ -4938,7 +4936,7 @@ buffer_add_fixed_array (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain buffer_add_byte (buf, VALUE_TYPE_ID_FIXED_ARRAY); buffer_add_byte (buf, t->type); buffer_add_int (buf, len_fixed_array ); - for (int i = 0; i < len_fixed_array; i++) { + for (gint32 i = 0; i < len_fixed_array; i++) { switch (t->type) { case MONO_TYPE_BOOLEAN: case MONO_TYPE_I1: @@ -5339,6 +5337,7 @@ static ErrorCode decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 **endbuf, guint8 *limit, gboolean check_field_datatype) { ErrorCode err; + if (type != t->type && !MONO_TYPE_IS_REFERENCE (t) && !(t->type == MONO_TYPE_I && type == MONO_TYPE_VALUETYPE) && !(type == VALUE_TYPE_ID_FIXED_ARRAY) && @@ -5418,7 +5417,6 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, if (type == MONO_TYPE_OBJECT || type == MONO_TYPE_STRING) { /* Boxed vtype */ int objid = decode_objid (buf, &buf, limit); - ErrorCode err; MonoObject *obj; err = get_object (objid, (MonoObject**)&obj); @@ -5442,7 +5440,6 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, if (MONO_TYPE_IS_REFERENCE (t)) { if (type == MONO_TYPE_CLASS || type == MONO_TYPE_OBJECT || type == MONO_TYPE_STRING) { int objid = decode_objid (buf, &buf, limit); - ErrorCode err; MonoObject *obj; err = get_object (objid, (MonoObject**)&obj); @@ -6057,7 +6054,6 @@ mono_do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, gu if (mono_class_is_abstract (m->klass)) return ERR_INVALID_ARGUMENT; else { - ERROR_DECL (error); this_arg = mono_object_new_checked (m->klass, error); if (!is_ok (error)) { mono_error_cleanup (error); @@ -6390,7 +6386,7 @@ get_types (gpointer key, gpointer value, gpointer user_data) GetTypesArgs *ud = (GetTypesArgs*)user_data; GPtrArray *assemblies = mono_alc_get_all_loaded_assemblies (); - for (int i = 0; i < assemblies->len; ++i) { + for (guint i = 0; i < assemblies->len; ++i) { ass = (MonoAssembly*)g_ptr_array_index (assemblies, i); if (ass->image) { @@ -6434,7 +6430,7 @@ get_types_for_source_file (gpointer key, gpointer value, gpointer user_data) files = get_source_files_for_type (klass); g_hash_table_insert (info->source_files, klass, files); - for (int i = 0; i < files->len; ++i) { + for (guint i = 0; i < files->len; ++i) { char *s = (char *)g_ptr_array_index (files, i); char *s2 = dbg_path_get_basename (s); char *s3; @@ -6976,18 +6972,17 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) /* Handled in the main loop */ break; case MDBGPROT_CMD_VM_READ_MEMORY: { - guint8* memory = (guint8*) decode_long (p, &p, end); + guint8* memory = (guint8*)GINT_TO_POINTER (decode_long (p, &p, end)); int size = decode_int (p, &p, end); PRINT_DEBUG_MSG(1, "MDBGPROT_CMD_VM_READ_MEMORY - [%p] - size - %d\n", memory, size); buffer_add_byte_array (buf, memory, size); break; } case MDBGPROT_CMD_GET_ASSEMBLY_BY_NAME: { - size_t i; char* assembly_name = decode_string (p, &p, end); //we get 'foo.dll' but mono_assembly_load expects 'foo' so we strip the last dot char *lookup_name = g_strdup (assembly_name); - for (i = strlen (lookup_name) - 1; i >= 0; --i) { + for (int i = ((int)strlen (lookup_name) - 1); i >= 0; --i) { if (lookup_name [i] == '.') { lookup_name [i] = 0; break; @@ -7008,7 +7003,7 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) g_free (lookup_name); if (!assembly) { GPtrArray *assemblies = mono_alc_get_all_loaded_assemblies (); - for (int i = 0; i < assemblies->len; ++i) { + for (guint i = 0; i < assemblies->len; ++i) { MonoAssembly *assemblyOnALC = (MonoAssembly*)g_ptr_array_index (assemblies, i); if (!strcmp(assemblyOnALC->aname.name, aname->name)) { assembly = assemblyOnALC; @@ -7032,7 +7027,7 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) uint8_t* guid = m_dbgprot_decode_byte_array (p, &p, end, &len); MonoAssembly *assembly = NULL; GPtrArray *assemblies = mono_alc_get_all_loaded_assemblies (); - for (int i = 0; i < assemblies->len; ++i) { + for (guint i = 0; i < assemblies->len; ++i) { MonoAssembly *assemblyOnALC = (MonoAssembly*)g_ptr_array_index (assemblies, i); if (!memcmp(assemblyOnALC->image->heap_guid.data, guid, len)) { assembly = assemblyOnALC; @@ -7351,7 +7346,7 @@ domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf) GPtrArray *assemblies = mono_alc_get_all_loaded_assemblies (); buffer_add_int (buf, assemblies->len); - for (int i = 0; i < assemblies->len; ++i) { + for (guint i = 0; i < assemblies->len; ++i) { MonoAssembly *ass = (MonoAssembly*)g_ptr_array_index (assemblies, i); buffer_add_assemblyid (buf, domain, ass); } @@ -7867,14 +7862,14 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint ERROR_DECL (error); MonoClass *nested; MonoType *type; - gpointer iter; guint8 b; int nnested; ErrorCode err; - char *name; switch (command) { case CMD_TYPE_GET_INFO: { + gpointer iter; + char *name; buffer_add_string (buf, m_class_get_name_space (klass)); buffer_add_string (buf, m_class_get_name (klass)); // FIXME: byref @@ -8002,18 +7997,18 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint int nprops; int i = 0; gpointer iter = NULL; - MonoProperty *p; + MonoProperty *prop; nprops = mono_class_num_properties (klass); buffer_add_int (buf, nprops); - while ((p = mono_class_get_properties (klass, &iter))) { - buffer_add_propertyid (buf, domain, p); - buffer_add_string (buf, p->name); - buffer_add_methodid (buf, domain, p->get); - buffer_add_methodid (buf, domain, p->set); - buffer_add_int (buf, p->attrs & ~MONO_PROPERTY_META_FLAG_MASK); + while ((prop = mono_class_get_properties (klass, &iter))) { + buffer_add_propertyid (buf, domain, prop); + buffer_add_string (buf, prop->name); + buffer_add_methodid (buf, domain, prop->get); + buffer_add_methodid (buf, domain, prop->set); + buffer_add_int (buf, prop->attrs & ~MONO_PROPERTY_META_FLAG_MASK); i ++; } g_assert (i == nprops); @@ -8159,7 +8154,10 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint // FIXME: Check for literal/const vtable = mono_class_vtable_checked (m_field_get_parent (f), error); - goto_if_nok (error, invalid_fieldid); + if (!is_ok (error)) { + mono_error_cleanup (error); + goto invalid_fieldid; + } val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type_internal (f->type))); err = decode_value (f->type, domain, val, p, &p, end, TRUE); @@ -8226,13 +8224,11 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint mlisttype = decode_int (p, &p, end); else mlisttype = 0; // MLISTTYPE_All - ERROR_DECL (error); - GPtrArray *array; if (!klass) goto invalid_argument; - error_init (error); + GPtrArray *array; array = mono_class_get_methods_by_name (klass, name, flags & ~BINDING_FLAGS_IGNORE_CASE, mlisttype, TRUE, error); if (!is_ok (error)) { mono_error_cleanup (error); @@ -8258,10 +8254,16 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint for (parent = tclass; parent; parent = m_class_get_parent (parent)) { mono_class_setup_interfaces (parent, error); - goto_if_nok (error, loader_error); + if (!is_ok (error)) { + mono_error_cleanup (error); + goto loader_error; + } collect_interfaces (parent, iface_hash, error); - goto_if_nok (error, loader_error); + if (!is_ok (error)) { + mono_error_cleanup (error); + goto loader_error; + } } buffer_add_int (buf, g_hash_table_size (iface_hash)); @@ -8307,7 +8309,10 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint } case CMD_TYPE_IS_INITIALIZED: { MonoVTable *vtable = mono_class_vtable_checked (klass, error); - goto_if_nok (error, loader_error); + if (!is_ok (error)) { + mono_error_cleanup (error); + goto loader_error; + } if (vtable) buffer_add_int (buf, (vtable->initialized || vtable->init_failed) ? 1 : 0); @@ -8316,7 +8321,6 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint break; } case CMD_TYPE_CREATE_INSTANCE: { - ERROR_DECL (error); MonoObject *obj; obj = mono_object_new_checked (klass, error); @@ -8350,9 +8354,15 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint } case MDBGPROT_CMD_TYPE_INITIALIZE: { MonoVTable *vtable = mono_class_vtable_checked (klass, error); - goto_if_nok (error, loader_error); + if (!is_ok (error)) { + mono_error_cleanup (error); + goto loader_error; + } mono_runtime_class_init_full (vtable, error); - goto_if_nok (error, loader_error); + if (!is_ok (error)) { + mono_error_cleanup (error); + goto loader_error; + } break; } default: @@ -9222,7 +9232,6 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) switch (command) { case MDBGPROT_CMD_STACK_FRAME_GET_ARGUMENTS: { - int i = 0; buffer_add_int(buf, sig->hasthis ? sig->param_count + 1 : sig->param_count); if (sig->hasthis) cmd_stack_frame_get_this (frame, sig, buf, jit); @@ -9288,7 +9297,6 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) break; } case CMD_STACK_FRAME_SET_VALUES: { - ERROR_DECL (error); guint8 *val_buf; MonoType *t; MonoDebugVarInfo *var = NULL; @@ -9588,10 +9596,10 @@ pointer_commands (int command, guint8 *p, guint8 *end, Buffer *buf) type = m_class_get_byval_arg (m_class_get_element_class (klass)); size = mono_type_size (type, &align); - if (!valid_memory_address((gpointer)addr, size)) + if (!valid_memory_address(GINT_TO_POINTER (addr), size)) return ERR_INVALID_ARGUMENT; - buffer_add_value (buf, type, (gpointer)addr, domain); + buffer_add_value (buf, type, GINT_TO_POINTER (addr), domain); break; default: diff --git a/src/mono/mono/component/debugger-engine.c b/src/mono/mono/component/debugger-engine.c index b85f0e337b54f..13e12137f000c 100644 --- a/src/mono/mono/component/debugger-engine.c +++ b/src/mono/mono/component/debugger-engine.c @@ -1260,7 +1260,7 @@ mono_de_ss_start (SingleStepReq *ss_req, SingleStepArgs *ss_args) SeqPoint *next_sp, *parent_sp = NULL; SeqPoint local_sp, local_parent_sp; gboolean found_sp; - MonoSeqPointInfo *parent_info; + MonoSeqPointInfo *parent_info = NULL; MonoMethod *parent_sp_method = NULL; gboolean enable_global = FALSE; diff --git a/src/mono/mono/component/hot_reload.c b/src/mono/mono/component/hot_reload.c index 69e21daaceb9a..b8bf4632269df 100644 --- a/src/mono/mono/component/hot_reload.c +++ b/src/mono/mono/component/hot_reload.c @@ -509,15 +509,15 @@ hot_reload_close_except_pools_all (MonoImage *base_image) if (!info) return; for (GList *ptr = info->delta_info; ptr; ptr = ptr->next) { - DeltaInfo *info = (DeltaInfo *)ptr->data; - MonoImage *image = info->delta_image; + DeltaInfo *delta_info = (DeltaInfo *)ptr->data; + MonoImage *image = delta_info->delta_image; if (image) { table_to_image_lock (); g_hash_table_remove (delta_image_to_info, image); table_to_image_unlock (); /* if for some reason the image has other references, break the link to this delta_info that is going away */ if (!mono_image_close_except_pools (image)) - info->delta_image = NULL; + delta_info->delta_image = NULL; } } } @@ -529,14 +529,14 @@ hot_reload_close_all (MonoImage *base_image) if (!info) return; for (GList *ptr = info->delta_info; ptr; ptr = ptr->next) { - DeltaInfo *info = (DeltaInfo *)ptr->data; - if (!info) + DeltaInfo *delta_info = (DeltaInfo *)ptr->data; + if (!delta_info) continue; - MonoImage *image = info->delta_image; + MonoImage *image = delta_info->delta_image; if (image) { mono_image_close_finish (image); } - delta_info_destroy (info); + delta_info_destroy (delta_info); ptr->data = NULL; } g_list_free (info->delta_info); @@ -2218,10 +2218,10 @@ apply_enclog_pass2 (Pass2Context *ctx, MonoImage *image_base, BaselineInfo *base default: g_assert_not_reached (); /* unexpected func code */ } - uint32_t cols[MONO_PROPERTY_MAP_SIZE]; - mono_metadata_decode_row (&image_base->tables [MONO_TABLE_PROPERTYMAP], token_index - 1, cols, MONO_PROPERTY_MAP_SIZE); + uint32_t prop_cols[MONO_PROPERTY_MAP_SIZE]; + mono_metadata_decode_row (&image_base->tables [MONO_TABLE_PROPERTYMAP], token_index - 1, prop_cols, MONO_PROPERTY_MAP_SIZE); - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "EnC: propertymap parent = 0x%08x, props = 0x%08x\n", cols[MONO_PROPERTY_MAP_PARENT], cols [MONO_PROPERTY_MAP_PROPERTY_LIST]); + mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "EnC: propertymap parent = 0x%08x, props = 0x%08x\n", prop_cols [MONO_PROPERTY_MAP_PARENT], prop_cols [MONO_PROPERTY_MAP_PROPERTY_LIST]); break; } case MONO_TABLE_PROPERTY: { @@ -2271,10 +2271,10 @@ apply_enclog_pass2 (Pass2Context *ctx, MonoImage *image_base, BaselineInfo *base default: g_assert_not_reached (); /* unexpected func code */ } - uint32_t cols[MONO_EVENT_MAP_SIZE]; - mono_metadata_decode_row (&image_base->tables [MONO_TABLE_EVENTMAP], token_index - 1, cols, MONO_EVENT_MAP_SIZE); + uint32_t prop_cols[MONO_EVENT_MAP_SIZE]; + mono_metadata_decode_row (&image_base->tables [MONO_TABLE_EVENTMAP], token_index - 1, prop_cols, MONO_EVENT_MAP_SIZE); - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "EnC: eventmap parent = 0x%08x, evts = 0x%08x\n", cols[MONO_EVENT_MAP_PARENT], cols [MONO_EVENT_MAP_EVENTLIST]); + mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "EnC: eventmap parent = 0x%08x, evts = 0x%08x\n", prop_cols [MONO_EVENT_MAP_PARENT], prop_cols [MONO_EVENT_MAP_EVENTLIST]); break; } diff --git a/src/mono/mono/eventpipe/ep-rt-mono.c b/src/mono/mono/eventpipe/ep-rt-mono.c index c29345098d8bf..096bc198184b0 100644 --- a/src/mono/mono/eventpipe/ep-rt-mono.c +++ b/src/mono/mono/eventpipe/ep-rt-mono.c @@ -1469,7 +1469,7 @@ eventpipe_fire_method_events ( il_offsets = (uint32_t*)events_data->buffer; native_offsets = il_offsets + offset_entries; - for (int offset_count = 0; offset_count < offset_entries; ++offset_count) { + for (int32_t offset_count = 0; offset_count < offset_entries; ++offset_count) { il_offsets [offset_count] = debug_info->line_numbers [offset_count].il_offset; native_offsets [offset_count] = debug_info->line_numbers [offset_count].native_offset; } @@ -1637,7 +1637,7 @@ eventpipe_execute_rundown ( // Iterate all assemblies in domain. GPtrArray *assemblies = mono_alc_get_all_loaded_assemblies (); if (assemblies) { - for (int i = 0; i < assemblies->len; ++i) { + for (uint32_t i = 0; i < assemblies->len; ++i) { MonoAssembly *assembly = (MonoAssembly *)g_ptr_array_index (assemblies, i); if (assembly) eventpipe_fire_assembly_events (root_domain, assembly, assembly_events_func); @@ -2765,15 +2765,15 @@ ep_rt_mono_sample_profiler_write_sampling_event_for_threads ( // Since we can't keep thread info around after runtime as been suspended, use an empty // adapter instance and only set recorded tid as parameter inside adapter. THREAD_INFO_TYPE adapter = { { 0 } }; - for (uint32_t i = 0; i < sampled_thread_count; ++i) { - EventPipeSampleProfileStackWalkData *data = &g_array_index (_ep_rt_mono_sampled_thread_callstacks, EventPipeSampleProfileStackWalkData, i); + for (uint32_t thread_count = 0; thread_count < sampled_thread_count; ++thread_count) { + EventPipeSampleProfileStackWalkData *data = &g_array_index (_ep_rt_mono_sampled_thread_callstacks, EventPipeSampleProfileStackWalkData, thread_count); if ((data->stack_walk_data.top_frame && data->payload_data == EP_SAMPLE_PROFILER_SAMPLE_TYPE_EXTERNAL) || (data->payload_data != EP_SAMPLE_PROFILER_SAMPLE_TYPE_ERROR && ep_stack_contents_get_length (&data->stack_contents) > 0)) { // Check if we have an async frame, if so we will need to make sure all frames are registered in regular jit info table. // TODO: An async frame can contain wrapper methods (no way to check during stackwalk), we could skip writing profile event // for this specific stackwalk or we could cleanup stack_frames before writing profile event. if (data->stack_walk_data.async_frame) { - for (int i = 0; i < data->stack_contents.next_available_frame; ++i) - mono_jit_info_table_find_internal ((gpointer)data->stack_contents.stack_frames [i], TRUE, FALSE); + for (uint32_t frame_count = 0; frame_count < data->stack_contents.next_available_frame; ++frame_count) + mono_jit_info_table_find_internal ((gpointer)data->stack_contents.stack_frames [frame_count], TRUE, FALSE); } mono_thread_info_set_tid (&adapter, ep_rt_uint64_t_to_thread_id_t (data->thread_id)); ep_write_sample_profile_event (sampling_thread, sampling_event, &adapter, &data->stack_contents, (uint8_t *)&data->payload_data, sizeof (data->payload_data)); @@ -2947,7 +2947,7 @@ ep_rt_mono_write_event_method_il_to_native_map ( } if (il_offsets) { native_offsets = il_offsets + offset_entries; - for (int offset_count = 0; offset_count < offset_entries; ++offset_count) { + for (int32_t offset_count = 0; offset_count < offset_entries; ++offset_count) { il_offsets [offset_count] = debug_info->line_numbers [offset_count].il_offset; native_offsets [offset_count] = debug_info->line_numbers [offset_count].native_offset; } @@ -3403,9 +3403,11 @@ get_type_start_id (MonoType *type) start_id = (((start_id * 215497) >> 16) ^ ((start_id * 1823231) + start_id)); +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ // Mix in highest bits on 64-bit systems only if (sizeof (type) > 4) start_id = start_id ^ (((uint64_t)type >> 31) >> 1); +MONO_RESTORE_WARNING return start_id; } @@ -4943,7 +4945,7 @@ mono_profiler_fire_buffered_gc_event_heap_dump_object_reference ( // Serialize directly as memory stream expected by FireEtwMonoProfilerGCHeapDumpObjectReference. uintptr_t last_offset = 0; - for (int i = 0; i < object_ref_count; i++) { + for (uintptr_t i = 0; i < object_ref_count; i++) { // GCEvent.Values[].ReferencesOffset object_ref_offset = offsets [i] - last_offset; memcpy (buffer, &object_ref_offset, sizeof (object_ref_offset)); @@ -6582,10 +6584,10 @@ mono_profiler_add_provider_param (const EventFilterDescriptor *key) if (param_ptr) { param = ep_event_filter_desc_alloc (param_ptr, key->size, key->type); if (param) { - memcpy ((uint8_t*)param->ptr,(const uint8_t*)key->ptr, key->size); + memcpy ((uint8_t*)(uintptr_t)param->ptr,(const uint8_t*)(uintptr_t)key->ptr, key->size); _ep_rt_mono_profiler_provider_params = g_slist_append (_ep_rt_mono_profiler_provider_params, param); } else { - g_free ((void *)param_ptr); + g_free ((void *)(uintptr_t)param_ptr); } } } @@ -6605,8 +6607,8 @@ mono_profiler_remove_provider_param (const EventFilterDescriptor *key) while (list) { param = (EventFilterDescriptor *)(list->data); if (param && param->ptr && param->type == key->type && param->size == key->size && - memcmp ((const void *)param->ptr, (const void *)key->ptr, param->size) == 0) { - g_free ((void *)param->ptr); + memcmp ((const void *)(uintptr_t)param->ptr, (const void *)(uintptr_t)key->ptr, param->size) == 0) { + g_free ((void *)(uintptr_t)param->ptr); ep_event_filter_desc_free (param); _ep_rt_mono_profiler_provider_params = g_slist_delete_link (_ep_rt_mono_profiler_provider_params, list); removed = true; @@ -6627,7 +6629,7 @@ mono_profiler_free_provider_params (void) for (GSList *list = _ep_rt_mono_profiler_provider_params; list; list = list->next) { EventFilterDescriptor *param = (EventFilterDescriptor *)(list->data); if (param) { - g_free ((void *)param->ptr); + g_free ((void *)(uintptr_t)param->ptr); ep_event_filter_desc_free (param); } } @@ -6645,7 +6647,7 @@ mono_profiler_provider_params_get_value ( if (!param || !param->ptr || !param->size || !key) return false; - const ep_char8_t *current = (ep_char8_t *)param->ptr; + const ep_char8_t *current = (ep_char8_t *)(uintptr_t)param->ptr; const ep_char8_t *end = current + param->size; bool found_key = false; diff --git a/src/mono/mono/eventpipe/ep-rt-mono.h b/src/mono/mono/eventpipe/ep-rt-mono.h index ac7e41dc8aee1..3cf0214b351fb 100644 --- a/src/mono/mono/eventpipe/ep-rt-mono.h +++ b/src/mono/mono/eventpipe/ep-rt-mono.h @@ -1265,7 +1265,7 @@ ep_rt_thread_create ( rt_mono_thread_params_internal_t *thread_params = g_new0 (rt_mono_thread_params_internal_t, 1); if (thread_params) { thread_params->thread_params.thread_type = thread_type; - thread_params->thread_params.thread_func = thread_func; + thread_params->thread_params.thread_func = (ep_rt_thread_start_func)thread_func; thread_params->thread_params.thread_params = params; thread_params->background_thread = true; return (mono_thread_platform_create_thread (ep_rt_thread_mono_start_func, thread_params, NULL, (ep_rt_thread_id_t *)id) == TRUE) ? true : false; @@ -1526,12 +1526,14 @@ ep_rt_spin_lock_set_owning_thread_id ( ep_rt_spin_lock_handle_t *spin_lock, MonoNativeThreadId thread_id) { +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ if (sizeof (spin_lock->owning_thread_id) == sizeof (uint32_t)) ep_rt_volatile_store_uint32_t ((uint32_t *)&spin_lock->owning_thread_id, MONO_NATIVE_THREAD_ID_TO_UINT (thread_id)); else if (sizeof (spin_lock->owning_thread_id) == sizeof (uint64_t)) ep_rt_volatile_store_uint64_t ((uint64_t *)&spin_lock->owning_thread_id, MONO_NATIVE_THREAD_ID_TO_UINT (thread_id)); else spin_lock->owning_thread_id = thread_id; +MONO_RESTORE_WARNING } static @@ -1539,12 +1541,14 @@ inline MonoNativeThreadId ep_rt_spin_lock_get_owning_thread_id (const ep_rt_spin_lock_handle_t *spin_lock) { +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ if (sizeof (spin_lock->owning_thread_id) == sizeof (uint32_t)) return MONO_UINT_TO_NATIVE_THREAD_ID (ep_rt_volatile_load_uint32_t ((const uint32_t *)&spin_lock->owning_thread_id)); else if (sizeof (spin_lock->owning_thread_id) == sizeof (uint64_t)) return MONO_UINT_TO_NATIVE_THREAD_ID (ep_rt_volatile_load_uint64_t ((const uint64_t *)&spin_lock->owning_thread_id)); else return spin_lock->owning_thread_id; +MONO_RESTORE_WARNING } #endif diff --git a/src/mono/mono/metadata/appdomain.c b/src/mono/mono/metadata/appdomain.c index f0818f455e65a..53b8d4306cd75 100644 --- a/src/mono/mono/metadata/appdomain.c +++ b/src/mono/mono/metadata/appdomain.c @@ -442,10 +442,12 @@ mono_domain_try_type_resolve_name (MonoAssembly *assembly, MonoStringHandle name if (assembly) { assembly_handle = mono_assembly_get_object_handle (assembly, error); goto_if_nok (error, return_null); + } else { + assembly_handle = MONO_HANDLE_CAST (MonoReflectionAssembly, NULL_HANDLE); } gpointer args [2]; - args [0] = assembly ? MONO_HANDLE_RAW (assembly_handle) : NULL; + args [0] = MONO_HANDLE_RAW (assembly_handle); args [1] = MONO_HANDLE_RAW (name); ret = mono_runtime_try_invoke_handle (method, NULL_HANDLE, args, error); goto_if_nok (error, return_null); @@ -504,10 +506,12 @@ mono_try_assembly_resolve_handle (MonoAssemblyLoadContext *alc, MonoStringHandle if (requesting) { requesting_handle = mono_assembly_get_object_handle (requesting, error); goto_if_nok (error, leave); + } else { + requesting_handle = MONO_HANDLE_CAST (MonoReflectionAssembly, NULL_HANDLE); } gpointer params [2]; - params [0] = requesting ? MONO_HANDLE_RAW (requesting_handle) : NULL; + params [0] = MONO_HANDLE_RAW (requesting_handle); params [1] = MONO_HANDLE_RAW (fname); MonoReflectionAssemblyHandle result; result = MONO_HANDLE_CAST (MonoReflectionAssembly, mono_runtime_try_invoke_handle (method, NULL_HANDLE, params, error)); diff --git a/src/mono/mono/metadata/class-init.c b/src/mono/mono/metadata/class-init.c index dc3257b12813e..df537732ca3a4 100644 --- a/src/mono/mono/metadata/class-init.c +++ b/src/mono/mono/metadata/class-init.c @@ -827,7 +827,7 @@ mono_class_setup_method_has_preserve_base_overrides_attribute (MonoMethod *metho static gboolean check_valid_generic_inst_arguments (MonoGenericInst *inst, MonoError *error) { - for (int i = 0; i < inst->type_argc; i++) { + for (guint i = 0; i < inst->type_argc; i++) { if (!mono_type_is_valid_generic_argument (inst->type_argv [i])) { char *type_name = mono_type_full_name (inst->type_argv [i]); mono_error_set_invalid_program (error, "generic type cannot be instantiated with type '%s'", type_name); @@ -2486,7 +2486,7 @@ mono_class_layout_fields (MonoClass *klass, int base_instance_size, int packing_ if (mono_class_has_static_metadata (klass)) { for (MonoClass *p = klass; p != NULL; p = p->parent) { gpointer iter = NULL; - guint32 first_field_idx = mono_class_get_first_field_idx (p); + first_field_idx = mono_class_get_first_field_idx (p); while ((field = mono_class_get_fields_internal (p, &iter))) { guint32 field_idx = first_field_idx + (field - p->fields); @@ -3854,7 +3854,7 @@ mono_class_setup_interface_id (MonoClass *klass) void mono_class_setup_interfaces (MonoClass *klass, MonoError *error) { - int i, interface_count; + int interface_count; MonoClass *iface, **interfaces; error_init (error); @@ -3916,7 +3916,7 @@ mono_class_setup_interfaces (MonoClass *klass, MonoError *error) interface_count = gklass->interface_count; interfaces = mono_class_new0 (klass, MonoClass *, interface_count); - for (i = 0; i < interface_count; i++) { + for (int i = 0; i < interface_count; i++) { interfaces [i] = mono_class_inflate_generic_class_checked (gklass->interfaces [i], mono_generic_class_get_context (mono_class_get_generic_class (klass)), error); if (!is_ok (error)) { mono_class_set_type_load_failure (klass, "Could not setup the interfaces"); diff --git a/src/mono/mono/metadata/class-setup-vtable.c b/src/mono/mono/metadata/class-setup-vtable.c index a7452c6a9f5b3..7d36cbd0b7928 100644 --- a/src/mono/mono/metadata/class-setup-vtable.c +++ b/src/mono/mono/metadata/class-setup-vtable.c @@ -151,7 +151,7 @@ mono_class_setup_interface_offsets_internal (MonoClass *klass, int cur_slot, gbo interface_offsets_full = (int *)g_malloc (sizeof (int) * num_ifaces); cur_slot = 0; - for (int i = 0; i < num_ifaces; ++i) { + for (i = 0; i < num_ifaces; ++i) { MonoClass *gklass_ic = gklass->interfaces_packed [i]; MonoClass *inflated = mono_class_inflate_generic_class_checked (gklass_ic, mono_class_get_context(klass), error); if (!is_ok (error)) { @@ -1675,11 +1675,10 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o ERROR_DECL (error); MonoClass *k, *ic; MonoMethod **vtable = NULL; - int i, max_vtsize = 0, cur_slot = 0; + int max_vtsize = 0, cur_slot = 0; GHashTable *override_map = NULL; GHashTable *override_class_map = NULL; GHashTable *conflict_map = NULL; - MonoMethod *cm; #if (DEBUG_INTERFACE_VTABLE_CODE|TRACE_INTERFACE_VTABLE_CODE) int first_non_interface_slot; #endif @@ -1755,7 +1754,7 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o } /* override interface methods */ - for (i = 0; i < onum; i++) { + for (int i = 0; i < onum; i++) { MonoMethod *decl = overrides [i*2]; MonoMethod *override = overrides [i*2 + 1]; if (MONO_CLASS_IS_INTERFACE_INTERNAL (decl->klass)) { @@ -1785,7 +1784,7 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o } // Loop on all implemented interfaces... - for (i = 0; i < klass->interface_offsets_count; i++) { + for (int i = 0; i < klass->interface_offsets_count; i++) { MonoClass *parent = klass->parent; int ic_offset; gboolean interface_is_explicitly_implemented_by_class; @@ -1870,10 +1869,9 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o // If the slot is still empty, look in all the inherited virtual methods... if ((vtable [im_slot] == NULL) && klass->parent != NULL) { - MonoClass *parent = klass->parent; // Reverse order, so that last added methods are preferred for (cm_index = parent->vtable_size - 1; cm_index >= 0; cm_index--) { - MonoMethod *cm = parent->vtable [cm_index]; + cm = parent->vtable [cm_index]; TRACE_INTERFACE_VTABLE ((cm != NULL) && printf (" For slot %d ('%s'.'%s':'%s'), trying (ancestor) method '%s'.'%s':'%s'... ", im_slot, ic->name_space, ic->name, im->name, cm->klass->name_space, cm->klass->name, cm->name)); if ((cm != NULL) && check_interface_method_override (klass, im, cm, MONO_ITF_OVERRIDE_SLOT_EMPTY)) { @@ -1910,7 +1908,7 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o // will not always be the first pass the one that fills the slot. // Now it is okay to implement a class that is not abstract and implements a interface that has an abstract method because it's reabstracted if (!mono_class_is_abstract (klass)) { - for (i = 0; i < klass->interface_offsets_count; i++) { + for (int i = 0; i < klass->interface_offsets_count; i++) { int ic_offset; int im_index; @@ -1939,7 +1937,7 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o TRACE_INTERFACE_VTABLE (print_vtable_full (klass, vtable, cur_slot, first_non_interface_slot, "AFTER SETTING UP INTERFACE METHODS", FALSE)); for (l = virt_methods; l; l = l->next) { - cm = (MonoMethod *)l->data; + MonoMethod *cm = (MonoMethod *)l->data; /* * If the method is REUSE_SLOT, we must check in the * base class for a method to override. @@ -2016,7 +2014,7 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o } /* override non interface methods */ - for (i = 0; i < onum; i++) { + for (int i = 0; i < onum; i++) { MonoMethod *decl = overrides [i*2]; MonoMethod *impl = overrides [i*2 + 1]; if (!MONO_CLASS_IS_INTERFACE_INTERNAL (decl->klass)) { @@ -2107,7 +2105,7 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o if (override_map) { MonoMethod *cm; - for (i = 0; i < max_vtsize; ++i) + for (int i = 0; i < max_vtsize; ++i) if (vtable [i]) { TRACE_INTERFACE_VTABLE (printf ("checking slot %d method %s[%p] for overrides\n", i, mono_method_full_name (vtable [i], 1), vtable [i])); @@ -2136,7 +2134,7 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o /* Ensure that all vtable slots are filled with concrete methods */ // Now it is okay to implement a class that is not abstract and implements a interface that has an abstract method because it's reabstracted if (!mono_class_is_abstract (klass)) { - for (i = 0; i < cur_slot; ++i) { + for (int i = 0; i < cur_slot; ++i) { if (vtable [i] == NULL || (vtable [i]->flags & METHOD_ATTRIBUTE_ABSTRACT)) { if (vtable [i] != NULL && mono_method_get_is_reabstracted (vtable [i])) continue; diff --git a/src/mono/mono/metadata/class.c b/src/mono/mono/metadata/class.c index 8a3ee6d50e46a..6a3fc112ce70e 100644 --- a/src/mono/mono/metadata/class.c +++ b/src/mono/mono/metadata/class.c @@ -218,9 +218,9 @@ mono_class_from_typeref_checked (MonoImage *image, guint32 type_token, MonoError done: /* Generic case, should be avoided for when a better error is possible. */ if (!res && is_ok (error)) { - char *name = mono_class_name_from_token (image, type_token); - char *assembly = mono_assembly_name_from_token (image, type_token); - mono_error_set_type_load_name (error, name, assembly, "Could not resolve type with token %08x from typeref (expected class '%s' in assembly '%s')", type_token, name, assembly); + char *class_name = mono_class_name_from_token (image, type_token); + char *assembly_name = mono_assembly_name_from_token (image, type_token); + mono_error_set_type_load_name (error, class_name, assembly_name, "Could not resolve type with token %08x from typeref (expected class '%s' in assembly '%s')", type_token, class_name, assembly_name); } return res; } @@ -1265,9 +1265,9 @@ mono_class_inflate_generic_method_full_checked (MonoMethod *method, MonoClass *k } /* Check that the method is not instantiated with any invalid types */ - for (int i = 0; i < method_inst->type_argc; i++) { + for (guint i = 0; i < method_inst->type_argc; i++) { if (!mono_type_is_valid_generic_argument (method_inst->type_argv [i])) { - mono_error_set_bad_image (error, mono_method_get_image (method), "MVAR %d cannot be expanded with type 0x%x", + mono_error_set_bad_image (error, mono_method_get_image (method), "MVAR %u cannot be expanded with type 0x%x", i, method_inst->type_argv [i]->type); goto fail; } @@ -3000,7 +3000,7 @@ mono_image_init_name_cache (MonoImage *image) guint32 cols [MONO_TYPEDEF_SIZE]; const char *name; const char *nspace; - guint32 i, visib, nspace_index; + guint32 visib, nspace_index; GHashTable *name_cache2, *nspace_table, *the_name_cache; if (image->name_cache) @@ -3025,7 +3025,7 @@ mono_image_init_name_cache (MonoImage *image) /* FIXME: metadata-update */ int rows = table_info_get_rows (t); - for (i = 1; i <= rows; ++i) { + for (int i = 1; i <= rows; ++i) { mono_metadata_decode_row (t, i - 1, cols, MONO_TYPEDEF_SIZE); visib = cols [MONO_TYPEDEF_FLAGS] & TYPE_ATTRIBUTE_VISIBILITY_MASK; /* @@ -3050,23 +3050,22 @@ mono_image_init_name_cache (MonoImage *image) /* Load type names from EXPORTEDTYPES table */ { - MonoTableInfo *t = &image->tables [MONO_TABLE_EXPORTEDTYPE]; - guint32 cols [MONO_EXP_TYPE_SIZE]; - int i; + MonoTableInfo *exptype_tbl = &image->tables [MONO_TABLE_EXPORTEDTYPE]; + guint32 exptype_cols [MONO_EXP_TYPE_SIZE]; - rows = table_info_get_rows (t); - for (i = 0; i < rows; ++i) { - mono_metadata_decode_row (t, i, cols, MONO_EXP_TYPE_SIZE); + rows = table_info_get_rows (exptype_tbl); + for (int i = 0; i < rows; ++i) { + mono_metadata_decode_row (exptype_tbl, i, exptype_cols, MONO_EXP_TYPE_SIZE); - guint32 impl = cols [MONO_EXP_TYPE_IMPLEMENTATION]; + guint32 impl = exptype_cols [MONO_EXP_TYPE_IMPLEMENTATION]; if ((impl & MONO_IMPLEMENTATION_MASK) == MONO_IMPLEMENTATION_EXP_TYPE) /* Nested type */ continue; - name = mono_metadata_string_heap (image, cols [MONO_EXP_TYPE_NAME]); - nspace = mono_metadata_string_heap (image, cols [MONO_EXP_TYPE_NAMESPACE]); + name = mono_metadata_string_heap (image, exptype_cols [MONO_EXP_TYPE_NAME]); + nspace = mono_metadata_string_heap (image, exptype_cols [MONO_EXP_TYPE_NAMESPACE]); - nspace_index = cols [MONO_EXP_TYPE_NAMESPACE]; + nspace_index = exptype_cols [MONO_EXP_TYPE_NAMESPACE]; nspace_table = (GHashTable *)g_hash_table_lookup (name_cache2, GUINT_TO_POINTER (nspace_index)); if (!nspace_table) { nspace_table = g_hash_table_new (g_str_hash, g_str_equal); diff --git a/src/mono/mono/metadata/custom-attrs.c b/src/mono/mono/metadata/custom-attrs.c index b007dd7eaec50..ab3daa866d2c5 100644 --- a/src/mono/mono/metadata/custom-attrs.c +++ b/src/mono/mono/metadata/custom-attrs.c @@ -408,14 +408,14 @@ MONO_RESTORE_WARNING return NULL; } case MONO_TYPE_CLASS: { - MonoType *type = load_cattr_type (image, t, TRUE, p, boundp, end, error, &slen); + MonoType *cattr_type = load_cattr_type (image, t, TRUE, p, boundp, end, error, &slen); if (out_obj) { - if (!type) + if (!cattr_type ) return NULL; - *out_obj = (MonoObject*)mono_type_get_object_checked (type, error); + *out_obj = (MonoObject*)mono_type_get_object_checked (cattr_type , error); return NULL; } else { - return type; + return cattr_type; } } case MONO_TYPE_OBJECT: { @@ -427,14 +427,14 @@ MONO_RESTORE_WARNING void *val; if (subt == CATTR_TYPE_SYSTEM_TYPE) { - MonoType *type = load_cattr_type (image, t, FALSE, p, boundp, end, error, &slen); + MonoType *cattr_type = load_cattr_type (image, t, FALSE, p, boundp, end, error, &slen); if (out_obj) { - if (!type) + if (!cattr_type) return NULL; - *out_obj = (MonoObject*)mono_type_get_object_checked (type, error); + *out_obj = (MonoObject*)mono_type_get_object_checked (cattr_type, error); return NULL; } else { - return type; + return cattr_type; } } else if (subt == 0x0E) { type = MONO_TYPE_STRING; @@ -463,18 +463,18 @@ MONO_RESTORE_WARNING goto handle_enum; } else if (subt == MONO_TYPE_ENUM) { char *n; - MonoType *t; + MonoType *enum_type; if (!decode_blob_value_checked (p, boundp, &slen, &p, error)) return NULL; if (slen > 0 && !bcheck_blob (p, slen - 1, boundp, error)) return NULL; n = (char *)g_memdup (p, slen + 1); n [slen] = 0; - t = cattr_type_from_name (n, image, FALSE, error); + enum_type = cattr_type_from_name (n, image, FALSE, error); g_free (n); return_val_if_nok (error, NULL); p += slen; - subc = mono_class_from_mono_type_internal (t); + subc = mono_class_from_mono_type_internal (enum_type); } else if (subt >= MONO_TYPE_BOOLEAN && subt <= MONO_TYPE_R8) { MonoType simple_type = {{0}}; simple_type.type = (MonoTypeEnum)subt; @@ -2416,17 +2416,17 @@ custom_attr_class_name_from_method_token (MonoImage *image, guint32 method_token guint32 type_token = MONO_TOKEN_TYPE_REF | nindex; /* mono_class_from_typeref_checked () */ { - guint32 cols [MONO_TYPEREF_SIZE]; + guint32 typeref_cols [MONO_TYPEREF_SIZE]; MonoTableInfo *t = &image->tables [MONO_TABLE_TYPEREF]; - mono_metadata_decode_row (t, (type_token&0xffffff)-1, cols, MONO_TYPEREF_SIZE); + mono_metadata_decode_row (t, (type_token&0xffffff)-1, typeref_cols, MONO_TYPEREF_SIZE); if (class_name) - *class_name = mono_metadata_string_heap (image, cols [MONO_TYPEREF_NAME]); + *class_name = mono_metadata_string_heap (image, typeref_cols [MONO_TYPEREF_NAME]); if (nspace) - *nspace = mono_metadata_string_heap (image, cols [MONO_TYPEREF_NAMESPACE]); + *nspace = mono_metadata_string_heap (image, typeref_cols [MONO_TYPEREF_NAMESPACE]); if (assembly_token) - *assembly_token = cols [MONO_TYPEREF_SCOPE]; + *assembly_token = typeref_cols [MONO_TYPEREF_SCOPE]; return TRUE; } } else if (class_index == MONO_MEMBERREF_PARENT_METHODDEF) { @@ -2659,28 +2659,28 @@ init_weak_fields_inner (MonoImage *image, GHashTable *indexes) tdef = &image->tables [MONO_TABLE_MEMBERREF]; rows = table_info_get_rows (tdef); for (int i = 0; i < rows; ++i) { - guint32 cols [MONO_MEMBERREF_SIZE]; + guint32 memberref_cols [MONO_MEMBERREF_SIZE]; const char *sig; - mono_metadata_decode_row (tdef, i, cols, MONO_MEMBERREF_SIZE); - sig = mono_metadata_blob_heap (image, cols [MONO_MEMBERREF_SIGNATURE]); + mono_metadata_decode_row (tdef, i, memberref_cols, MONO_MEMBERREF_SIZE); + sig = mono_metadata_blob_heap (image, memberref_cols [MONO_MEMBERREF_SIGNATURE]); mono_metadata_decode_blob_size (sig, &sig); - guint32 nindex = cols [MONO_MEMBERREF_CLASS] >> MONO_MEMBERREF_PARENT_BITS; - guint32 class_index = cols [MONO_MEMBERREF_CLASS] & MONO_MEMBERREF_PARENT_MASK; - const char *fname = mono_metadata_string_heap (image, cols [MONO_MEMBERREF_NAME]); + guint32 nindex = memberref_cols [MONO_MEMBERREF_CLASS] >> MONO_MEMBERREF_PARENT_BITS; + guint32 class_index = memberref_cols [MONO_MEMBERREF_CLASS] & MONO_MEMBERREF_PARENT_MASK; + const char *fname = mono_metadata_string_heap (image, memberref_cols [MONO_MEMBERREF_NAME]); if (!strcmp (fname, ".ctor") && class_index == MONO_MEMBERREF_PARENT_TYPEREF) { MonoTableInfo *typeref_table = &image->tables [MONO_TABLE_TYPEREF]; - guint32 cols [MONO_TYPEREF_SIZE]; + guint32 typeref_cols [MONO_TYPEREF_SIZE]; - mono_metadata_decode_row (typeref_table, nindex - 1, cols, MONO_TYPEREF_SIZE); + mono_metadata_decode_row (typeref_table, nindex - 1, typeref_cols, MONO_TYPEREF_SIZE); - const char *name = mono_metadata_string_heap (image, cols [MONO_TYPEREF_NAME]); - const char *nspace = mono_metadata_string_heap (image, cols [MONO_TYPEREF_NAMESPACE]); + const char *name = mono_metadata_string_heap (image, typeref_cols [MONO_TYPEREF_NAME]); + const char *nspace = mono_metadata_string_heap (image, typeref_cols [MONO_TYPEREF_NAMESPACE]); if (!strcmp (nspace, "System") && !strcmp (name, "WeakAttribute")) { - MonoClass *klass = mono_class_from_typeref_checked (image, MONO_TOKEN_TYPE_REF | nindex, error); + klass = mono_class_from_typeref_checked (image, MONO_TOKEN_TYPE_REF | nindex, error); if (!is_ok (error)) { mono_error_cleanup (error); return; diff --git a/src/mono/mono/metadata/debug-helpers.c b/src/mono/mono/metadata/debug-helpers.c index e2654cf9dfc8b..a5dcb439c066f 100644 --- a/src/mono/mono/metadata/debug-helpers.c +++ b/src/mono/mono/metadata/debug-helpers.c @@ -755,17 +755,17 @@ dis_one (GString *str, MonoDisHelper *dh, MonoMethod *method, const unsigned cha g_string_append_printf (str, "%d", sval); break; case MonoInlineSwitch: { - const unsigned char *end; + const unsigned char *sval_end; sval = read32 (ip); ip += 4; - end = ip + sval * 4; + sval_end = ip + sval * 4; g_string_append_c (str, '('); for (i = 0; i < sval; ++i) { if (i > 0) g_string_append (str, ", "); label = read32 (ip); if (dh->label_target) - g_string_append_printf (str, dh->label_target, end + label - il_code); + g_string_append_printf (str, dh->label_target, sval_end + label - il_code); else g_string_append_printf (str, "%d", label); ip += 4; diff --git a/src/mono/mono/metadata/gc.c b/src/mono/mono/metadata/gc.c index 5144e40eeec43..7434ab68d3cbc 100644 --- a/src/mono/mono/metadata/gc.c +++ b/src/mono/mono/metadata/gc.c @@ -147,7 +147,7 @@ break_coop_alertable_wait (gpointer user_data) static gint coop_cond_timedwait_alertable (MonoCoopCond *cond, MonoCoopMutex *mutex, guint32 timeout_ms, gboolean *alertable) { - BreakCoopAlertableWaitUD *ud; + BreakCoopAlertableWaitUD *ud = NULL; int res; if (alertable) { @@ -426,7 +426,7 @@ mono_domain_finalize (MonoDomain *domain, guint32 timeout) MonoInternalThread *thread = mono_thread_internal_current (); gint res; gboolean ret; - gint64 start; + gint64 start = 0; if (mono_thread_internal_current () == gc_thread) /* We are called from inside a finalizer, not much we can do here */ diff --git a/src/mono/mono/metadata/handle.h b/src/mono/mono/metadata/handle.h index c7b72ad1d99f9..e18ce15c210d3 100644 --- a/src/mono/mono/metadata/handle.h +++ b/src/mono/mono/metadata/handle.h @@ -427,16 +427,18 @@ This is why we evaluate index and value before any call to MONO_HANDLE_RAW or ot // This would be easier to write with the gcc extension typeof, // but it is not widely enough implemented (i.e. Microsoft C). // The value copy is needed in cases computing value causes a GC -#define MONO_HANDLE_SETVAL(HANDLE, FIELD, TYPE, VALUE) do { \ - TYPE __val = (VALUE); \ +#define MONO_HANDLE_SETVAL(HANDLE, FIELD, TYPE, VALUE) do { \ + MONO_DISABLE_WARNING(4189) \ + TYPE __val = (VALUE); \ if (0) { TYPE * typecheck G_GNUC_UNUSED = &MONO_HANDLE_SUPPRESS (MONO_HANDLE_RAW (HANDLE)->FIELD); } \ MONO_HANDLE_SUPPRESS (MONO_HANDLE_RAW (MONO_HANDLE_UNSUPPRESS (HANDLE))->FIELD = __val); \ + MONO_RESTORE_WARNING \ } while (0) // handle [idx] = value (for managed pointers) #define MONO_HANDLE_ARRAY_SETREF(HANDLE, IDX, VALUE) do { \ uintptr_t __idx = (IDX); \ - MonoObjectHandle __val = MONO_HANDLE_CAST (MonoObject, VALUE); \ + MonoObjectHandle __val = MONO_HANDLE_CAST (MonoObject, VALUE); \ { /* FIXME scope needed by Centrinel */ \ /* FIXME mono_array_setref_fast is not an expression. */ \ MONO_HANDLE_SUPPRESS_SCOPE(1); \ diff --git a/src/mono/mono/metadata/icall.c b/src/mono/mono/metadata/icall.c index 5da9a66548565..18a7878d7ef8a 100644 --- a/src/mono/mono/metadata/icall.c +++ b/src/mono/mono/metadata/icall.c @@ -2240,7 +2240,7 @@ ves_icall_RuntimeFieldInfo_GetRawConstantValue (MonoReflectionFieldHandle rfield goto invalid_operation; if (image_is_dynamic (m_class_get_image (m_field_get_parent (field)))) { - MonoClass *klass = m_field_get_parent (field); + klass = m_field_get_parent (field); int fidx = field - m_class_get_fields (klass); MonoFieldDefaultValue *def_values = mono_class_get_field_def_values (klass); @@ -2273,8 +2273,6 @@ ves_icall_RuntimeFieldInfo_GetRawConstantValue (MonoReflectionFieldHandle rfield case MONO_TYPE_U8: case MONO_TYPE_I8: case MONO_TYPE_R8: { - MonoType *t; - /* boxed value type */ t = g_new0 (MonoType, 1); t->type = def_type; diff --git a/src/mono/mono/metadata/image.c b/src/mono/mono/metadata/image.c index 38516a7f0b7c4..e942815ce7f31 100644 --- a/src/mono/mono/metadata/image.c +++ b/src/mono/mono/metadata/image.c @@ -1779,7 +1779,6 @@ mono_image_open_a_lot_parameterized (MonoLoadedImages *li, MonoAssemblyLoadConte if (coree_module_handle) { HMODULE module_handle; gunichar2 *fname_utf16; - DWORD last_error; absfname = mono_path_resolve_symlinks (fname); fname_utf16 = NULL; @@ -1804,6 +1803,8 @@ mono_image_open_a_lot_parameterized (MonoLoadedImages *li, MonoAssemblyLoadConte return image; } + DWORD last_error = ERROR_SUCCESS; + // Image not loaded, load it now fname_utf16 = g_utf8_to_utf16 (absfname, -1, NULL, NULL, NULL); module_handle = MonoLoadImage (fname_utf16); diff --git a/src/mono/mono/metadata/marshal-ilgen.c b/src/mono/mono/metadata/marshal-ilgen.c index 161271eed9172..9c391cf9ac76b 100644 --- a/src/mono/mono/metadata/marshal-ilgen.c +++ b/src/mono/mono/metadata/marshal-ilgen.c @@ -815,8 +815,6 @@ emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv case MONO_MARSHAL_CONV_STR_BSTR: case MONO_MARSHAL_CONV_STR_ANSIBSTR: case MONO_MARSHAL_CONV_STR_TBSTR: { - int pos; - /* free space if free == true */ mono_mb_emit_ldloc (mb, 2); pos = mono_mb_emit_short_branch (mb, CEE_BRFALSE_S); @@ -1005,8 +1003,6 @@ emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv #endif /* DISABLE_COM */ case MONO_MARSHAL_CONV_SAFEHANDLE: { - int pos; - mono_mb_emit_ldloc (mb, 0); mono_mb_emit_byte (mb, CEE_LDIND_I); pos = mono_mb_emit_branch (mb, CEE_BRTRUE); @@ -2222,7 +2218,7 @@ emit_native_wrapper_ilgen (MonoImage *image, MonoMethodBuilder *mb, MonoMethodSi } if (MONO_TYPE_ISSTRUCT (sig->ret)) { - MonoClass *klass = mono_class_from_mono_type_internal (sig->ret); + klass = mono_class_from_mono_type_internal (sig->ret); mono_class_init_internal (klass); if (!(mono_class_is_explicit_layout (klass) || m_class_is_blittable (klass))) { /* This is used by emit_marshal_vtype (), but it needs to go right before the call */ @@ -4136,7 +4132,7 @@ emit_delegate_end_invoke_ilgen (MonoMethodBuilder *mb, MonoMethodSignature *sig) static void emit_delegate_invoke_internal_ilgen (MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethodSignature *invoke_sig, gboolean static_method_with_first_arg_bound, gboolean callvirt, gboolean closed_over_null, MonoMethod *method, MonoMethod *target_method, MonoClass *target_class, MonoGenericContext *ctx, MonoGenericContainer *container) { - int local_i, local_len, local_delegates, local_d, local_target, local_res; + int local_i, local_len, local_delegates, local_d, local_target, local_res = 0; int pos0, pos1, pos2; int i; gboolean void_ret; @@ -4294,6 +4290,7 @@ emit_delegate_invoke_internal_ilgen (MonoMethodBuilder *mb, MonoMethodSignature mono_mb_emit_op (mb, CEE_CALLVIRT, mono_class_inflate_generic_method_checked (method, &container->context, error)); g_assert (is_ok (error)); /* FIXME don't swallow the error */ } + if (!void_ret) mono_mb_emit_stloc (mb, local_res); @@ -5297,11 +5294,11 @@ emit_marshal_string_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, break; } - MONO_STATIC_POINTER_INIT (MonoMethod, m) + MONO_STATIC_POINTER_INIT (MonoMethod, method) - m = get_method_nofail (mono_defaults.string_class, "get_Length", -1, 0); + method = get_method_nofail (mono_defaults.string_class, "get_Length", -1, 0); - MONO_STATIC_POINTER_INIT_END (MonoMethod, m) + MONO_STATIC_POINTER_INIT_END (MonoMethod, method) /* * Have to allocate a new string with the same length as the original, and @@ -5312,7 +5309,7 @@ emit_marshal_string_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, mono_mb_emit_ldloc (mb, conv_arg); mono_mb_emit_ldarg (mb, argnum); mono_mb_emit_byte (mb, CEE_LDIND_I); - mono_mb_emit_managed_call (mb, m, NULL); + mono_mb_emit_managed_call (mb, method, NULL); mono_mb_emit_icall (mb, mono_string_new_len_wrapper); mono_mb_emit_byte (mb, CEE_STIND_REF); } else if (m_type_is_byref (t) && (t->attrs & PARAM_ATTRIBUTE_OUT || !(t->attrs & PARAM_ATTRIBUTE_IN))) { @@ -6029,8 +6026,6 @@ emit_marshal_object_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, /* Set src */ mono_mb_emit_ldarg (mb, argnum); if (m_type_is_byref (t)) { - int pos2; - /* Check for NULL and raise an exception */ pos2 = mono_mb_emit_branch (mb, CEE_BRTRUE); diff --git a/src/mono/mono/metadata/marshal.c b/src/mono/mono/metadata/marshal.c index 2aec43d6439fe..d7f24a1e8d2f9 100644 --- a/src/mono/mono/metadata/marshal.c +++ b/src/mono/mono/metadata/marshal.c @@ -3312,7 +3312,7 @@ mono_marshal_set_callconv_from_unmanaged_callconv_attribute (MonoMethod *method, return; } - int i; + mono_array_size_t i; MonoCustomAttrEntry *attr = NULL; for (i = 0; i < cinfo->num_attrs; ++i) { MonoClass *ctor_class = cinfo->attrs [i].ctor->klass; @@ -3336,7 +3336,7 @@ mono_marshal_set_callconv_from_unmanaged_callconv_attribute (MonoMethod *method, /* CallConvs is an array of types */ MonoArray *callconv_array = mono_array_get_internal(named_args, MonoArray *, i); - for (int j = 0; j < mono_array_length_internal(callconv_array); ++j) { + for (mono_array_size_t j = 0; j < mono_array_length_internal(callconv_array); ++j) { MonoReflectionType *callconv_type = mono_array_get_internal(callconv_array, MonoReflectionType *, j); mono_marshal_set_callconv_for_type(callconv_type->type, csig, skip_gc_trans); } @@ -3371,7 +3371,6 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions, gboolean skip_gc_trans = FALSE; gboolean pinvoke_not_found = FALSE; gpointer iter; - int i; ERROR_DECL (emitted_error); WrapperInfo *info; @@ -3450,10 +3449,9 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions, * and returns a string. */ if (!strcmp ("Ctor", m->name)) { - int i; - MonoMethodSignature *rsig = mono_method_signature_internal (m); if (csig->param_count == rsig->param_count) { + int i; for (i = 0; i < csig->param_count; ++i) if (!mono_metadata_type_equal (csig->params [i], rsig->params [i])) break; @@ -3467,8 +3465,6 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions, g_assert (res); - WrapperInfo *info; - g_assert (!(res->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)); g_assert (!(res->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)); @@ -3576,7 +3572,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions, mono_error_assert_ok (error); gboolean found = FALSE; if (cinfo) { - 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 == mono_class_try_get_suppress_gc_transition_attribute_class ()) { found = TRUE; @@ -3609,7 +3605,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions, info, NULL); mono_mb_free (mb); - for (i = sig->param_count; i >= 0; i--) + for (int i = sig->param_count; i >= 0; i--) if (mspecs [i]) mono_metadata_free_marshal_spec (mspecs [i]); g_free (mspecs); @@ -3957,7 +3953,7 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, GHashTable *cache; int i; EmitMarshalContext m; - gboolean marshalling_enabled; + gboolean marshalling_enabled = FALSE; g_assert (method != NULL); error_init (error); @@ -4079,7 +4075,6 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, gint32 charset = 0; MonoBoolean set_last_error = 0; int num_named_args; - ERROR_DECL (error); mono_reflection_create_custom_attr_data_args_noalloc (mono_defaults.corlib, attr->ctor, attr->data, attr->data_size, &typed_args, &named_args, &num_named_args, &arginfo, error); @@ -5946,7 +5941,6 @@ void mono_marshal_free_asany_impl (MonoObjectHandle o, gpointer ptr, MonoMarshalNative string_encoding, int param_attrs, MonoError *error) { MonoType *t; - MonoClass *klass; if (MONO_HANDLE_IS_NULL (o)) return; @@ -5967,7 +5961,7 @@ mono_marshal_free_asany_impl (MonoObjectHandle o, gpointer ptr, MonoMarshalNativ break; case MONO_TYPE_CLASS: case MONO_TYPE_VALUETYPE: { - klass = t->data.klass; + MonoClass *klass = t->data.klass; if (m_class_is_valuetype (klass) && (mono_class_is_explicit_layout (klass) || m_class_is_blittable (klass) || m_class_is_enumtype (klass))) break; diff --git a/src/mono/mono/metadata/memory-manager.c b/src/mono/mono/metadata/memory-manager.c index a09b2bc288f8d..cee08f0cabb71 100644 --- a/src/mono/mono/metadata/memory-manager.c +++ b/src/mono/mono/metadata/memory-manager.c @@ -351,9 +351,11 @@ mix_hash (uintptr_t source) // Actual hash hash = (((hash * 215497) >> 16) ^ ((hash * 1823231) + hash)); +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ // Mix in highest bits on 64-bit systems only if (sizeof (source) > 4) hash = hash ^ ((source >> 31) >> 1); +MONO_RESTORE_WARNING return hash; } diff --git a/src/mono/mono/metadata/metadata.c b/src/mono/mono/metadata/metadata.c index e600f680c131c..d245f1ce2c0c6 100644 --- a/src/mono/mono/metadata/metadata.c +++ b/src/mono/mono/metadata/metadata.c @@ -2150,6 +2150,8 @@ do_mono_metadata_parse_type_with_cmods (MonoType *type, int cmod_count, MonoImag return TRUE; } +MONO_DISABLE_WARNING(4701) /* potentially uninitialized local variable 'stype' used */ + /** * mono_metadata_parse_type: * \param m metadata context @@ -2248,6 +2250,7 @@ mono_metadata_parse_type_internal (MonoImage *m, MonoGenericContainer *container return type; } +MONO_RESTORE_WARNING MonoType* mono_metadata_parse_type_checked (MonoImage *m, MonoGenericContainer *container, @@ -4890,6 +4893,7 @@ mono_metadata_interfaces_from_typedef_full (MonoImage *meta, guint32 index, Mono loc.idx = mono_metadata_token_index (index); loc.col_idx = MONO_INTERFACEIMPL_CLASS; loc.t = tdef; + loc.result = 0; gboolean found = tdef->base && mono_binary_search (&loc, tdef->base, table_info_get_rows (tdef), tdef->row_size, table_locator) != NULL; @@ -4996,6 +5000,7 @@ mono_metadata_nested_in_typedef (MonoImage *meta, guint32 index) loc.idx = mono_metadata_token_index (index); loc.col_idx = MONO_NESTED_CLASS_NESTED; loc.t = tdef; + loc.result = 0; gboolean found = tdef->base && mono_binary_search (&loc, tdef->base, table_info_get_rows (tdef), tdef->row_size, table_locator) != NULL; if (!found && !meta->has_updates) @@ -5101,6 +5106,7 @@ mono_metadata_custom_attrs_from_index (MonoImage *meta, guint32 index) loc.idx = index; loc.col_idx = MONO_CUSTOM_ATTR_PARENT; loc.t = tdef; + loc.result = 0; /* FIXME: Index translation */ @@ -6304,6 +6310,7 @@ mono_metadata_events_from_typedef (MonoImage *meta, guint32 index, guint *end_id loc.t = tdef; loc.col_idx = MONO_EVENT_MAP_PARENT; loc.idx = index + 1; + loc.result = 0; gboolean found = tdef->base && mono_binary_search (&loc, tdef->base, table_info_get_rows (tdef), tdef->row_size, table_locator) != NULL; if (!found && !meta->has_updates) @@ -6358,6 +6365,7 @@ mono_metadata_methods_from_event (MonoImage *meta, guint32 index, guint *end_i loc.t = msemt; loc.col_idx = MONO_METHOD_SEMA_ASSOCIATION; loc.idx = ((index + 1) << MONO_HAS_SEMANTICS_BITS) | MONO_HAS_SEMANTICS_EVENT; /* Method association coded index */ + loc.result = 0; gboolean found = msemt->base && mono_binary_search (&loc, msemt->base, table_info_get_rows (msemt), msemt->row_size, table_locator) != NULL; @@ -6414,6 +6422,7 @@ mono_metadata_properties_from_typedef (MonoImage *meta, guint32 index, guint *en loc.t = tdef; loc.col_idx = MONO_PROPERTY_MAP_PARENT; loc.idx = index + 1; + loc.result = 0; gboolean found = tdef->base && mono_binary_search (&loc, tdef->base, table_info_get_rows (tdef), tdef->row_size, table_locator) != NULL; @@ -6469,6 +6478,7 @@ mono_metadata_methods_from_property (MonoImage *meta, guint32 index, guint *en loc.t = msemt; loc.col_idx = MONO_METHOD_SEMA_ASSOCIATION; loc.idx = ((index + 1) << MONO_HAS_SEMANTICS_BITS) | MONO_HAS_SEMANTICS_PROPERTY; /* Method association coded index */ + loc.result = 0; gboolean found = msemt->base && mono_binary_search (&loc, msemt->base, table_info_get_rows (msemt), msemt->row_size, table_locator) != NULL; @@ -7169,6 +7179,7 @@ mono_metadata_get_generic_param_row (MonoImage *image, guint32 token, guint32 *o loc.idx = *owner; loc.col_idx = MONO_GENERICPARAM_OWNER; loc.t = tdef; + loc.result = 0; gboolean found = tdef->base && mono_binary_search (&loc, tdef->base, table_info_get_rows (tdef), tdef->row_size, table_locator) != NULL; if (!found && !image->has_updates) diff --git a/src/mono/mono/metadata/monitor.c b/src/mono/mono/metadata/monitor.c index aa65ea039381b..22f71514d38e0 100644 --- a/src/mono/mono/metadata/monitor.c +++ b/src/mono/mono/metadata/monitor.c @@ -762,7 +762,7 @@ mono_monitor_try_enter_inflated (MonoObject *obj, guint32 ms, gboolean allow_int guint32 waitms; guint32 new_status, old_status, tmp_status; MonoInternalThread *thread; - gboolean interrupted, timedout; + gboolean interrupted, timedout = FALSE; LOCK_DEBUG (g_message("%s: (%d) Trying to lock object %p (%d ms)", __func__, id, obj, ms)); @@ -1116,9 +1116,9 @@ mono_monitor_try_enter_loop_if_interrupted (MonoObject *obj, guint32 ms, if (error) { mono_error_set_argument_null (error, "obj", ""); } else { - ERROR_DECL (error); - mono_error_set_argument_null (error, "obj", ""); - mono_error_set_pending_exception (error); + ERROR_DECL (null_error); + mono_error_set_argument_null (null_error, "obj", ""); + mono_error_set_pending_exception (null_error); } return FALSE; } @@ -1330,7 +1330,6 @@ mono_monitor_wait (MonoObjectHandle obj_handle, guint32 ms, MonoBoolean allow_in event = mono_w32event_create (FALSE, FALSE); if (event == NULL) { - ERROR_DECL (error); mono_error_set_synchronization_lock (error, "Failed to set up wait event"); mono_error_set_pending_exception (error); return FALSE; diff --git a/src/mono/mono/metadata/mono-conc-hash.c b/src/mono/mono/metadata/mono-conc-hash.c index c79e7210ce20a..fbbbc72182993 100644 --- a/src/mono/mono/metadata/mono-conc-hash.c +++ b/src/mono/mono/metadata/mono-conc-hash.c @@ -364,8 +364,7 @@ mono_conc_g_hash_table_insert (MonoConcGHashTable *hash_table, gpointer key, gpo return NULL; } if (key == cur_key) { - gpointer value = table->values [i]; - return value; + return table->values [i]; } i = (i + 1) & table_mask; } @@ -387,8 +386,7 @@ mono_conc_g_hash_table_insert (MonoConcGHashTable *hash_table, gpointer key, gpo return NULL; } if (equal (key, cur_key)) { - gpointer value = table->values [i]; - return value; + return table->values [i]; } i = (i + 1) & table_mask; } diff --git a/src/mono/mono/metadata/object-internals.h b/src/mono/mono/metadata/object-internals.h index 329f9c4b7d954..b29b823901ded 100644 --- a/src/mono/mono/metadata/object-internals.h +++ b/src/mono/mono/metadata/object-internals.h @@ -27,61 +27,61 @@ #include /* Use this as MONO_CHECK_ARG (arg,expr,) in functions returning void */ -#define MONO_CHECK_ARG(arg, expr, retval) do { \ - if (G_UNLIKELY (!(expr))) \ - { \ - if (0) { (void)(arg); } /* check if the name exists */ \ - ERROR_DECL (error); \ - mono_error_set_argument_format (error, #arg, "assertion `%s' failed", #expr); \ - mono_error_set_pending_exception (error); \ - return retval; \ - } \ +#define MONO_CHECK_ARG(arg, expr, retval) do { \ + if (G_UNLIKELY (!(expr))) \ + { \ + if (0) { (void)(arg); } /* check if the name exists */ \ + ERROR_DECL (__error); \ + mono_error_set_argument_format (__error, #arg, "assertion `%s' failed", #expr); \ + mono_error_set_pending_exception (__error); \ + return retval; \ + } \ } while (0) -#define MONO_CHECK_ARG_NULL_NAMED(arg, argname, retval) do { \ - if (G_UNLIKELY (!(arg))) \ - { \ - ERROR_DECL (error); \ - mono_error_set_argument_null (error, (argname), ""); \ - mono_error_set_pending_exception (error); \ - return retval; \ - } \ +#define MONO_CHECK_ARG_NULL_NAMED(arg, argname, retval) do { \ + if (G_UNLIKELY (!(arg))) \ + { \ + ERROR_DECL (__error); \ + mono_error_set_argument_null (__error, (argname), ""); \ + mono_error_set_pending_exception (__error); \ + return retval; \ + } \ } while (0) /* Use this as MONO_CHECK_ARG_NULL (arg,) in functions returning void */ -#define MONO_CHECK_ARG_NULL(arg, retval) do { \ - if (G_UNLIKELY (!(arg))) \ - { \ - mono_error_set_argument_null (error, #arg, ""); \ - return retval; \ - } \ +#define MONO_CHECK_ARG_NULL(arg, retval) do { \ + if (G_UNLIKELY (!(arg))) \ + { \ + mono_error_set_argument_null (error, #arg, ""); \ + return retval; \ + } \ } while (0) /* Use this as MONO_CHECK_ARG_NULL_HANDLE (arg,) in functions returning void */ -#define MONO_CHECK_ARG_NULL_HANDLE(arg, retval) do { \ - if (G_UNLIKELY (MONO_HANDLE_IS_NULL (arg))) \ - { \ - mono_error_set_argument_null (error, #arg, ""); \ - return retval; \ - } \ +#define MONO_CHECK_ARG_NULL_HANDLE(arg, retval) do { \ + if (G_UNLIKELY (MONO_HANDLE_IS_NULL (arg))) \ + { \ + mono_error_set_argument_null (error, #arg, ""); \ + return retval; \ + } \ } while (0) #define MONO_CHECK_ARG_NULL_HANDLE_NAMED(arg, argname, retval) do { \ - if (G_UNLIKELY (MONO_HANDLE_IS_NULL (arg))) \ - { \ - mono_error_set_argument_null (error, (argname), ""); \ - return retval; \ - } \ + if (G_UNLIKELY (MONO_HANDLE_IS_NULL (arg))) \ + { \ + mono_error_set_argument_null (error, (argname), ""); \ + return retval; \ + } \ } while (0) /* Use this as MONO_CHECK_NULL (arg,) in functions returning void */ -#define MONO_CHECK_NULL(arg, retval) do { \ - if (G_UNLIKELY (!(arg))) \ - { \ - ERROR_DECL (error); \ - mono_error_set_null_reference (error); \ - mono_error_set_pending_exception (error); \ - return retval; \ - } \ +#define MONO_CHECK_NULL(arg, retval) do { \ + if (G_UNLIKELY (!(arg))) \ + { \ + ERROR_DECL (__error); \ + mono_error_set_null_reference (__error); \ + mono_error_set_pending_exception (__error); \ + return retval; \ + } \ } while (0) MONO_COMPONENT_API MonoClass * diff --git a/src/mono/mono/metadata/object.c b/src/mono/mono/metadata/object.c index ac36e93c7c54a..9896bd3b4efca 100644 --- a/src/mono/mono/metadata/object.c +++ b/src/mono/mono/metadata/object.c @@ -1911,6 +1911,7 @@ alloc_vtable (MonoClass *klass, size_t vtable_size, size_t imt_table_bytes) * address bits. The IMT has an odd number of entries, however, so on 32 bits the * alignment will be off. In that case we allocate 4 more bytes and skip over them. */ +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ if (sizeof (gpointer) == 4 && (imt_table_bytes & 7)) { g_assert ((imt_table_bytes & 7) == 4); vtable_size += 4; @@ -1918,6 +1919,7 @@ alloc_vtable (MonoClass *klass, size_t vtable_size, size_t imt_table_bytes) } else { alloc_offset = 0; } +MONO_RESTORE_WARNING return (gpointer*) ((char*)m_class_alloc0 (klass, (guint)vtable_size) + alloc_offset); } diff --git a/src/mono/mono/metadata/seq-points-data.c b/src/mono/mono/metadata/seq-points-data.c index 454227bf45bb4..6704ef2627743 100644 --- a/src/mono/mono/metadata/seq-points-data.c +++ b/src/mono/mono/metadata/seq-points-data.c @@ -174,7 +174,7 @@ mono_seq_point_info_add_seq_point (GByteArray* array, SeqPoint *sp, SeqPoint *la int il_delta, native_delta; GSList *l; guint8 buffer[4]; - guint8 len; + int len; int flags; if (!has_debug_data && @@ -209,8 +209,7 @@ mono_seq_point_info_add_seq_point (GByteArray* array, SeqPoint *sp, SeqPoint *la for (l = next; l; l = l->next) { int next_index = GPOINTER_TO_UINT (l->data); - guint8 buffer[4]; - int len = encode_var_int (buffer, NULL, next_index); + len = encode_var_int (buffer, NULL, next_index); g_byte_array_append (array, buffer, len); } } @@ -237,6 +236,7 @@ gboolean mono_seq_point_find_prev_by_native_offset (MonoSeqPointInfo* info, int native_offset, SeqPoint* seq_point) { SeqPoint prev_seq_point; + prev_seq_point.native_offset = 0; gboolean is_first = TRUE; SeqPointIterator it; mono_seq_point_iterator_init (&it, info); diff --git a/src/mono/mono/metadata/sgen-mono-ilgen.c b/src/mono/mono/metadata/sgen-mono-ilgen.c index 535c8055ef627..b3d7ae3d04351 100644 --- a/src/mono/mono/metadata/sgen-mono-ilgen.c +++ b/src/mono/mono/metadata/sgen-mono-ilgen.c @@ -179,7 +179,7 @@ emit_managed_allocator_ilgen (MonoMethodBuilder *mb, gboolean slowpath, gboolean #ifdef MANAGED_ALLOCATION int p_var, size_var, real_size_var, thread_var G_GNUC_UNUSED; int tlab_next_addr_var, new_next_var; - guint32 fastpath_branch, max_size_branch, no_oom_branch; + guint32 fastpath_branch, max_size_branch = 0, no_oom_branch; if (slowpath) { switch (atype) { diff --git a/src/mono/mono/metadata/sgen-new-bridge.c b/src/mono/mono/metadata/sgen-new-bridge.c index 1d4466c1fc4fd..b106f4e9e939a 100644 --- a/src/mono/mono/metadata/sgen-new-bridge.c +++ b/src/mono/mono/metadata/sgen-new-bridge.c @@ -747,7 +747,7 @@ processing_build_callback_data (int generation) int i, j; int num_sccs, num_xrefs; int max_entries, max_xrefs; - MonoObject *obj G_GNUC_UNUSED; + MonoObject *obj = NULL; HashEntry *entry; HashEntry **all_entries; MonoGCBridgeSCC **api_sccs; @@ -792,7 +792,7 @@ processing_build_callback_data (int generation) dyn_array_scc_init (&sccs); for (i = 0; i < hash_table.num_entries; ++i) { - HashEntry *entry = all_entries [i]; + entry = all_entries [i]; if (entry->v.dfs2.scc_index < 0) { int index = dyn_array_scc_size (&sccs); current_scc = dyn_array_scc_add (&sccs); @@ -889,27 +889,27 @@ processing_build_callback_data (int generation) if (bridge_accounting_enabled) { for (i = hash_table.num_entries - 1; i >= 0; --i) { double w; - HashEntryWithAccounting *entry = (HashEntryWithAccounting*)all_entries [i]; + HashEntryWithAccounting *entry_acc = (HashEntryWithAccounting*)all_entries [i]; - entry->weight += (double)sgen_safe_object_get_size (sgen_hash_table_key_for_value_pointer (entry)); - w = entry->weight / dyn_array_ptr_size (&entry->entry.srcs); - for (j = 0; j < dyn_array_ptr_size (&entry->entry.srcs); ++j) { - HashEntryWithAccounting *other = (HashEntryWithAccounting *)dyn_array_ptr_get (&entry->entry.srcs, j); + entry_acc->weight += (double)sgen_safe_object_get_size (sgen_hash_table_key_for_value_pointer (entry_acc)); + w = entry_acc->weight / dyn_array_ptr_size (&entry_acc->entry.srcs); + for (j = 0; j < dyn_array_ptr_size (&entry_acc->entry.srcs); ++j) { + HashEntryWithAccounting *other = (HashEntryWithAccounting *)dyn_array_ptr_get (&entry_acc->entry.srcs, j); other->weight += w; } } for (i = 0; i < hash_table.num_entries; ++i) { - HashEntryWithAccounting *entry = (HashEntryWithAccounting*)all_entries [i]; - if (entry->entry.is_bridge) { - MonoObject *obj = sgen_hash_table_key_for_value_pointer (entry); - MonoClass *klass = SGEN_LOAD_VTABLE (obj)->klass; - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_GC, "OBJECT %s::%s (%p) weight %f", m_class_get_name_space (klass), m_class_get_name (klass), obj, entry->weight); + HashEntryWithAccounting *entry_acc = (HashEntryWithAccounting*)all_entries [i]; + if (entry_acc->entry.is_bridge) { + MonoObject *instance = sgen_hash_table_key_for_value_pointer (entry_acc); + MonoClass *klass = SGEN_LOAD_VTABLE (instance)->klass; + mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_GC, "OBJECT %s::%s (%p) weight %f", m_class_get_name_space (klass), m_class_get_name (klass), instance, entry_acc->weight); } } } for (i = 0; i < hash_table.num_entries; ++i) { - HashEntry *entry = all_entries [i]; + entry = all_entries [i]; second_pass_links += dyn_array_ptr_size (&entry->srcs); } diff --git a/src/mono/mono/metadata/sgen-old-bridge.c b/src/mono/mono/metadata/sgen-old-bridge.c index 866a1daade594..169baa72227d4 100644 --- a/src/mono/mono/metadata/sgen-old-bridge.c +++ b/src/mono/mono/metadata/sgen-old-bridge.c @@ -701,7 +701,7 @@ processing_build_callback_data (int generation) dyn_array_scc_init (&sccs); for (i = 0; i < hash_table.num_entries; ++i) { - HashEntry *entry = all_entries [i]; + entry = all_entries [i]; if (entry->scc_index < 0) { int index = dyn_array_scc_size (&sccs); current_scc = dyn_array_scc_add (&sccs); @@ -733,26 +733,26 @@ processing_build_callback_data (int generation) if (bridge_accounting_enabled) { for (i = hash_table.num_entries - 1; i >= 0; --i) { double w; - HashEntryWithAccounting *entry = (HashEntryWithAccounting*)all_entries [i]; + HashEntryWithAccounting *entry_acc = (HashEntryWithAccounting*)all_entries [i]; - entry->weight += (double)sgen_safe_object_get_size (entry->entry.obj); - w = entry->weight / dyn_array_ptr_size (&entry->entry.srcs); - for (j = 0; j < dyn_array_ptr_size (&entry->entry.srcs); ++j) { - HashEntryWithAccounting *other = (HashEntryWithAccounting *)dyn_array_ptr_get (&entry->entry.srcs, j); + entry_acc->weight += (double)sgen_safe_object_get_size (entry_acc->entry.obj); + w = entry_acc->weight / dyn_array_ptr_size (&entry_acc->entry.srcs); + for (j = 0; j < dyn_array_ptr_size (&entry_acc->entry.srcs); ++j) { + HashEntryWithAccounting *other = (HashEntryWithAccounting *)dyn_array_ptr_get (&entry_acc->entry.srcs, j); other->weight += w; } } for (i = 0; i < hash_table.num_entries; ++i) { - HashEntryWithAccounting *entry = (HashEntryWithAccounting*)all_entries [i]; - if (entry->entry.is_bridge) { - MonoClass *klass = SGEN_LOAD_VTABLE (entry->entry.obj)->klass; - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_GC, "OBJECT %s::%s (%p) weight %f", m_class_get_name_space (klass), m_class_get_name (klass), entry->entry.obj, entry->weight); + HashEntryWithAccounting *entry_acc = (HashEntryWithAccounting*)all_entries [i]; + if (entry_acc->entry.is_bridge) { + MonoClass *klass = SGEN_LOAD_VTABLE (entry_acc->entry.obj)->klass; + mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_GC, "OBJECT %s::%s (%p) weight %f", m_class_get_name_space (klass), m_class_get_name (klass), entry_acc->entry.obj, entry_acc->weight); } } } for (i = 0; i < hash_table.num_entries; ++i) { - HashEntry *entry = all_entries [i]; + entry = all_entries [i]; second_pass_links += dyn_array_ptr_size (&entry->srcs); } diff --git a/src/mono/mono/metadata/sgen-stw.c b/src/mono/mono/metadata/sgen-stw.c index c79787b3eae1a..25c463d499136 100644 --- a/src/mono/mono/metadata/sgen-stw.c +++ b/src/mono/mono/metadata/sgen-stw.c @@ -65,6 +65,7 @@ align_pointer (void *ptr) return (void*)p; } +MONO_DISABLE_WARNING(4740) /* flow in or out of inline asm code suppresses global optimization, x86 only */ static void update_current_thread_stack (void *start) { @@ -86,6 +87,7 @@ update_current_thread_stack (void *start) if (mono_gc_get_gc_callbacks ()->thread_suspend_func) mono_gc_get_gc_callbacks ()->thread_suspend_func (info->client_info.runtime_data, NULL, &info->client_info.ctx); } +MONO_RESTORE_WARNING static void acquire_gc_locks (void) diff --git a/src/mono/mono/metadata/sgen-tarjan-bridge.c b/src/mono/mono/metadata/sgen-tarjan-bridge.c index f956277b0efb2..71fb4cc09837f 100644 --- a/src/mono/mono/metadata/sgen-tarjan-bridge.c +++ b/src/mono/mono/metadata/sgen-tarjan-bridge.c @@ -453,9 +453,11 @@ mix_hash (uintptr_t source) // Actual hash hash = (((hash * 215497) >> 16) ^ ((hash * 1823231) + hash)); +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ // Mix in highest bits on 64-bit systems only if (sizeof (source) > 4) hash = hash ^ ((source >> 31) >> 1); +MONO_RESTORE_WARNING return hash; } diff --git a/src/mono/mono/metadata/sre.c b/src/mono/mono/metadata/sre.c index 927ca947174c2..3bbdab9fc7a25 100644 --- a/src/mono/mono/metadata/sre.c +++ b/src/mono/mono/metadata/sre.c @@ -897,8 +897,8 @@ mono_image_get_array_token (MonoDynamicImage *assembly, MonoReflectionArrayMetho mtype = mono_reflection_type_handle_mono_type (parent, error); goto_if_nok (error, fail); - for (int i = 0; i < nparams; ++i) { - sig->params [i] = mono_type_array_get_and_resolve (parameters, i, error); + for (guint32 i = 0; i < nparams; ++i) { + sig->params [i] = mono_type_array_get_and_resolve (parameters, (int)i, error); goto_if_nok (error, fail); } @@ -1231,31 +1231,32 @@ mono_reflection_dynimage_basic_init (MonoReflectionAssemblyBuilder *assemblyb, M if (assemblyb->culture) { assembly->assembly.aname.culture = mono_string_to_utf8_checked_internal (assemblyb->culture, error); return_if_nok (error); - } else + } else { assembly->assembly.aname.culture = g_strdup (""); + } - if (assemblyb->version) { - char *vstr = mono_string_to_utf8_checked_internal (assemblyb->version, error); - if (mono_error_set_pending_exception (error)) - return; - char **version = g_strsplit (vstr, ".", 4); - char **parts = version; - assembly->assembly.aname.major = atoi (*parts++); - assembly->assembly.aname.minor = atoi (*parts++); - assembly->assembly.aname.build = *parts != NULL ? atoi (*parts++) : 0; - assembly->assembly.aname.revision = *parts != NULL ? atoi (*parts) : 0; - - g_strfreev (version); - g_free (vstr); - } else { - assembly->assembly.aname.major = 0; - assembly->assembly.aname.minor = 0; - assembly->assembly.aname.build = 0; - assembly->assembly.aname.revision = 0; - } + if (assemblyb->version) { + char *vstr = mono_string_to_utf8_checked_internal (assemblyb->version, error); + if (mono_error_set_pending_exception (error)) + return; + char **version = g_strsplit (vstr, ".", 4); + char **parts = version; + assembly->assembly.aname.major = atoi (*parts++); + assembly->assembly.aname.minor = atoi (*parts++); + assembly->assembly.aname.build = *parts != NULL ? atoi (*parts++) : 0; + assembly->assembly.aname.revision = *parts != NULL ? atoi (*parts) : 0; + + g_strfreev (version); + g_free (vstr); + } else { + assembly->assembly.aname.major = 0; + assembly->assembly.aname.minor = 0; + assembly->assembly.aname.build = 0; + assembly->assembly.aname.revision = 0; + } if (assemblyb->public_key_token) { - for (int i = 0; i < 8 && i < mono_array_length_internal (assemblyb->public_key_token); i++) { + for (mono_array_size_t i = 0; i < 8 && i < mono_array_length_internal (assemblyb->public_key_token); i++) { guint8 byte = mono_array_get_internal (assemblyb->public_key_token, guint8, i); sprintf ((char*)(assembly->assembly.aname.public_key_token + 2 * i), "%02x", byte); } @@ -2858,7 +2859,6 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass, MonoReflectionMethodAux *method_aux; MonoImage *image; gboolean dynamic; - int i; error_init (error); /* @@ -2921,7 +2921,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass, !(m->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME)) { MonoMethodHeader *header; guint32 code_size; - gint32 max_stack, i; + gint32 max_stack; gint32 num_locals = 0; gint32 num_clauses = 0; guint8 *code; @@ -2955,7 +2955,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass, header->init_locals = rmb->init_locals; header->num_locals = num_locals; - for (i = 0; i < num_locals; ++i) { + for (gint32 i = 0; i < num_locals; ++i) { MonoReflectionLocalBuilder *lb = mono_array_get_internal (rmb->ilgen->locals, MonoReflectionLocalBuilder*, i); @@ -2991,7 +2991,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass, m->is_generic = TRUE; mono_method_set_generic_container (m, container); - for (i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { MonoReflectionGenericParam *gp = mono_array_get_internal (rmb->generic_params, MonoReflectionGenericParam*, i); MonoType *gp_type = mono_reflection_type_get_handle ((MonoReflectionType*)gp, error); @@ -3011,7 +3011,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass, * This is a valid SRE case, but the resulting method signature must be encoded using the proper * generic parameters. */ - for (i = 0; i < m->signature->param_count; ++i) { + for (gint32 i = 0; i < m->signature->param_count; ++i) { MonoType *t = m->signature->params [i]; if (t->type == MONO_TYPE_MVAR) { MonoGenericParam *gparam = t->data.generic_param; @@ -3032,14 +3032,13 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass, if (rmb->refs) { MonoMethodWrapper *mw = (MonoMethodWrapper*)m; - int i; void **data; m->wrapper_type = MONO_WRAPPER_DYNAMIC_METHOD; mw->method_data = data = image_g_new (image, gpointer, rmb->nrefs + 1); data [0] = GUINT_TO_POINTER (rmb->nrefs); - for (i = 0; i < rmb->nrefs; ++i) + for (guint32 i = 0; i < rmb->nrefs; ++i) data [i + 1] = rmb->refs [i]; } @@ -3050,7 +3049,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass, if (!method_aux) method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1); method_aux->param_names = image_g_new0 (image, char *, mono_method_signature_internal (m)->param_count + 1); - for (i = 0; i <= m->signature->param_count; ++i) { + for (gint32 i = 0; i <= m->signature->param_count; ++i) { MonoReflectionParamBuilder *pb; if ((pb = mono_array_get_internal (rmb->pinfo, MonoReflectionParamBuilder*, i))) { if ((i > 0) && (pb->attrs)) { @@ -3096,7 +3095,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass, /* Parameter marshalling */ if (rmb->pinfo) - for (i = 0; i < mono_array_length_internal (rmb->pinfo); ++i) { + for (mono_array_size_t i = 0; i < mono_array_length_internal (rmb->pinfo); ++i) { MonoReflectionParamBuilder *pb; if ((pb = mono_array_get_internal (rmb->pinfo, MonoReflectionParamBuilder*, i))) { if (pb->marshal_info) { diff --git a/src/mono/mono/metadata/threads.c b/src/mono/mono/metadata/threads.c index 695f4e84a940e..f40e96030d308 100644 --- a/src/mono/mono/metadata/threads.c +++ b/src/mono/mono/metadata/threads.c @@ -993,7 +993,7 @@ mono_thread_detach_internal (MonoInternalThread *thread) g_assert (threads); - if (!mono_g_hash_table_lookup_extended (threads, (gpointer)thread->tid, NULL, (gpointer*) &value)) { + if (!mono_g_hash_table_lookup_extended (threads, GUINT_TO_POINTER (thread->tid), NULL, (gpointer*) &value)) { g_error ("%s: thread %p (tid: %p) should not have been removed yet from threads", __func__, thread, thread->tid); } else if (thread != value) { /* We have to check whether the thread object for the tid is still the same in the table because the @@ -1002,7 +1002,7 @@ mono_thread_detach_internal (MonoInternalThread *thread) g_error ("%s: thread %p (tid: %p) do not match with value %p (tid: %p)", __func__, thread, thread->tid, value, value->tid); } - removed = mono_g_hash_table_remove (threads, (gpointer)thread->tid); + removed = mono_g_hash_table_remove (threads, GUINT_TO_POINTER (thread->tid)); g_assert (removed); mono_threads_unlock (); @@ -2739,7 +2739,7 @@ wait_for_tids (struct wait_data *wait, guint32 timeout, gboolean check_state_cha internal = wait->threads [ret - MONO_THREAD_INFO_WAIT_RET_SUCCESS_0]; mono_threads_lock (); - if (mono_g_hash_table_lookup (threads, (gpointer) internal->tid) == internal) + if (mono_g_hash_table_lookup (threads, GUINT_TO_POINTER (internal->tid)) == internal) g_error ("%s: failed to call mono_thread_detach_internal on thread %p, InternalThread: %p", __func__, internal->tid, internal); mono_threads_unlock (); } diff --git a/src/mono/mono/metadata/w32handle.c b/src/mono/mono/metadata/w32handle.c index 6ecec42af5d79..4a66358ce90fd 100644 --- a/src/mono/mono/metadata/w32handle.c +++ b/src/mono/mono/metadata/w32handle.c @@ -505,16 +505,6 @@ mono_w32handle_ops_prewait (MonoW32Handle *handle_data) handle_ops [handle_data->type]->prewait (handle_data); } -static void -mono_w32handle_unlock_handles (MonoW32Handle **handles_data, gsize nhandles) -{ - for (int i = ((int)nhandles - 1); i >= 0; i--) { - if (!handles_data [i]) - continue; - mono_w32handle_unlock (handles_data [i]); - } -} - static int mono_w32handle_timedwait_signal_naked (MonoCoopCond *cond, MonoCoopMutex *mutex, guint32 timeout, gboolean poll, gboolean *alerted) { diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 0646efca77339..e8c08c8947680 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -305,6 +305,10 @@ elseif(NOT HOST_BROWSER) set(mini_sources "${mini_sources};${VERSION_FILE_PATH}") # this is generated by GenerateNativeVersionFile in Arcade endif() +if(HOST_WIN32) +set_source_files_properties(${ZLIB_SOURCES} PROPERTIES COMPILE_OPTIONS "/wd4005;/wd4127;/wd4131;/wd4244") +endif() + set(monosgen-sources "${metadata_sources};${utils_sources};${sgen_sources};${icu_shim_sources};${mini_sources};${ZLIB_SOURCES}") add_library(monosgen-objects OBJECT "${monosgen-sources}") diff --git a/src/mono/mono/mini/abcremoval.c b/src/mono/mono/mini/abcremoval.c index 6568a7003c540..a4326428fd03b 100644 --- a/src/mono/mono/mini/abcremoval.c +++ b/src/mono/mono/mini/abcremoval.c @@ -1191,6 +1191,8 @@ process_block (MonoCompile *cfg, MonoBasicBlock *bb, MonoVariableRelationsEvalua } } +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ + /* * Eliminate MONO_INST_FAULT flags if possible. */ @@ -1229,6 +1231,8 @@ process_block (MonoCompile *cfg, MonoBasicBlock *bb, MonoVariableRelationsEvalua } */ } + +MONO_RESTORE_WARNING } for (dominated_bb = bb->dominated; dominated_bb != NULL; dominated_bb = dominated_bb->next) { diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index 456def4683b6b..e820994dd9a63 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -1616,6 +1616,8 @@ arm64_emit_gsharedvt_arg_trampoline (MonoAotCompile *acfg, int offset, int *tram #endif +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ + #ifdef MONO_ARCH_AOT_SUPPORTED /* * arch_emit_direct_call: @@ -2143,7 +2145,7 @@ arch_emit_specific_trampoline_pages (MonoAotCompile *acfg) ARM_B_COND (code, ARMCOND_EQ, 0); /* Loop footer */ - ARM_ADD_REG_IMM8 (code, ARMREG_R0, ARMREG_R0, sizeof (target_mgreg_t) * 2); + ARM_ADD_REG_IMM8 (code, ARMREG_R0, ARMREG_R0, (guint32)(sizeof (target_mgreg_t) * 2)); loop_branch_back = code; ARM_B (code, 0); arm_patch (loop_branch_back, loop_start); @@ -2738,7 +2740,7 @@ arch_emit_imt_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size) ARM_B_COND (code, ARMCOND_EQ, 0); /* Loop footer */ - ARM_ADD_REG_IMM8 (code, ARMREG_R0, ARMREG_R0, sizeof (target_mgreg_t) * 2); + ARM_ADD_REG_IMM8 (code, ARMREG_R0, ARMREG_R0, (guint32)(sizeof (target_mgreg_t) * 2)); labels [4] = code; ARM_B (code, 0); arm_patch (labels [4], labels [1]); @@ -2763,7 +2765,7 @@ arch_emit_imt_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size) ARM_LDR_IMM (code2, ARMREG_R0, ARMREG_PC, (code - (labels [0] + 8))); emit_bytes (acfg, buf, code - buf); - emit_symbol_diff (acfg, acfg->got_symbol, ".", (offset * sizeof (target_mgreg_t)) + (code - (labels [0] + 8)) - 4); + emit_symbol_diff (acfg, acfg->got_symbol, ".", (int)((offset * sizeof (target_mgreg_t)) + (code - (labels [0] + 8)) - 4)); *tramp_size = code - buf + 4; #elif defined(TARGET_ARM64) @@ -2820,7 +2822,6 @@ arch_emit_imt_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size) #endif } - #if defined (TARGET_AMD64) static void @@ -2978,13 +2979,15 @@ arch_emit_unbox_arbitrary_trampoline (MonoAotCompile *acfg, int offset, int *tra /* Emit it */ emit_bytes (acfg, buf, code - buf); - emit_symbol_diff (acfg, acfg->got_symbol, ".", (offset * sizeof (target_mgreg_t)) + (code - (label + 8)) - 4); + emit_symbol_diff (acfg, acfg->got_symbol, ".", (int)((offset * sizeof (target_mgreg_t)) + (code - (label + 8)) - 4)); *tramp_size = 4 * 4; #else g_error ("NOT IMPLEMENTED: needed for AOT<>interp mixed mode transition"); #endif } +MONO_RESTORE_WARNING + /* END OF ARCH SPECIFIC CODE */ static guint32 @@ -3833,11 +3836,11 @@ encode_method_ref (MonoAotCompile *acfg, MonoMethod *method, guint8 *buf, guint8 encode_klass_ref (acfg, method->klass, p, &p); } else { MonoMethodSignature *sig = mono_method_signature_internal (method); - WrapperInfo *info = mono_marshal_get_wrapper_info (method); + WrapperInfo *wrapper_info = mono_marshal_get_wrapper_info (method); encode_value (0, p, &p); if (method->wrapper_type == MONO_WRAPPER_DELEGATE_INVOKE) - encode_value (info ? info->subtype : 0, p, &p); + encode_value (wrapper_info ? wrapper_info->subtype : 0, p, &p); encode_signature (acfg, sig, p, &p); } break; @@ -4630,7 +4633,6 @@ static void add_wrappers (MonoAotCompile *acfg) { MonoMethod *method, *m; - int i, j; MonoMethodSignature *sig, *csig; guint32 token; @@ -4640,11 +4642,11 @@ add_wrappers (MonoAotCompile *acfg) * callers. */ int rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_METHOD]); - for (i = 0; i < rows; ++i) { + for (int i = 0; i < rows; ++i) { ERROR_DECL (error); - MonoMethod *method; - guint32 token = MONO_TOKEN_METHOD_DEF | (i + 1); + gboolean skip = FALSE; + token = MONO_TOKEN_METHOD_DEF | (i + 1); method = mono_get_method_checked (acfg->image, token, NULL, NULL, error); report_loader_error (acfg, error, TRUE, "Failed to load method token 0x%x due to %s\n", i, mono_error_get_message (error)); @@ -4664,7 +4666,7 @@ add_wrappers (MonoAotCompile *acfg) if (mono_class_is_open_constructed_type (sig->ret) || m_class_is_byreflike (mono_class_from_mono_type_internal (sig->ret))) skip = TRUE; - for (j = 0; j < sig->param_count; j++) { + for (int j = 0; j < sig->param_count; j++) { if (sig->params [j]->type == MONO_TYPE_TYPEDBYREF) skip = TRUE; if (mono_class_is_open_constructed_type (sig->params [j])) @@ -4676,7 +4678,7 @@ add_wrappers (MonoAotCompile *acfg) MonoDynCallInfo *info = mono_arch_dyn_call_prepare (sig); gboolean has_nullable = FALSE; - for (j = 0; j < sig->param_count; j++) { + for (int j = 0; j < sig->param_count; j++) { if (sig->params [j]->type == MONO_TYPE_GENERICINST && mono_class_is_nullable (mono_class_from_mono_type_internal (sig->params [j]))) has_nullable = TRUE; } @@ -4770,11 +4772,9 @@ add_wrappers (MonoAotCompile *acfg) /* These are used by mono_jit_runtime_invoke () to calls gsharedvt out wrappers */ if (acfg->aot_opts.llvm_only) { - int variants; - /* Create simplified signatures which match the signature used by the gsharedvt out wrappers */ - for (variants = 0; variants < 4; ++variants) { - for (i = 0; i < 40; ++i) { + for (int variants = 0; variants < 4; ++variants) { + for (int i = 0; i < 40; ++i) { sig = mini_get_gsharedvt_out_sig_wrapper_signature ((variants & 1) > 0, (variants & 2) > 0, i); add_extra_method (acfg, mono_marshal_get_runtime_invoke_for_sig (sig)); @@ -4794,7 +4794,7 @@ add_wrappers (MonoAotCompile *acfg) int nwrappers; wrappers = mono_marshal_get_virtual_stelemref_wrappers (&nwrappers); - for (i = 0; i < nwrappers; ++i) + for (int i = 0; i < nwrappers; ++i) add_method (acfg, wrappers [i]); g_free (wrappers); } @@ -4832,9 +4832,8 @@ add_wrappers (MonoAotCompile *acfg) #if 0 /* remoting-invoke wrappers */ rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_METHOD]); - for (i = 0; i < rows; ++i) { + for (int i = 0; i < rows; ++i) { ERROR_DECL (error); - MonoMethodSignature *sig; token = MONO_TOKEN_METHOD_DEF | (i + 1); method = mono_get_method_checked (acfg->image, token, NULL, NULL, error); @@ -4852,7 +4851,7 @@ add_wrappers (MonoAotCompile *acfg) /* delegate-invoke wrappers */ rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_TYPEDEF]); - for (i = 0; i < rows; ++i) { + for (int i = 0; i < rows; ++i) { ERROR_DECL (error); MonoClass *klass; @@ -4911,7 +4910,6 @@ add_wrappers (MonoAotCompile *acfg) mono_custom_attrs_free (cattr); } } else if ((acfg->jit_opts & MONO_OPT_GSHAREDVT) && mono_class_is_gtd (klass)) { - ERROR_DECL (error); MonoGenericContext ctx; MonoMethod *inst, *gshared; @@ -4971,7 +4969,7 @@ add_wrappers (MonoAotCompile *acfg) /* array access wrappers */ rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_TYPESPEC]); - for (i = 0; i < rows; ++i) { + for (int i = 0; i < rows; ++i) { ERROR_DECL (error); MonoClass *klass; @@ -4984,20 +4982,20 @@ add_wrappers (MonoAotCompile *acfg) } if (m_class_get_rank (klass) && MONO_TYPE_IS_PRIMITIVE (m_class_get_byval_arg (m_class_get_element_class (klass)))) { - MonoMethod *m, *wrapper; + MonoMethod *array_m, *wrapper; /* Add runtime-invoke wrappers too */ - m = get_method_nofail (klass, "Get", -1, 0); - g_assert (m); - wrapper = mono_marshal_get_array_accessor_wrapper (m); + array_m = get_method_nofail (klass, "Get", -1, 0); + g_assert (array_m); + wrapper = mono_marshal_get_array_accessor_wrapper (array_m); add_extra_method (acfg, wrapper); if (!acfg->aot_opts.llvm_only) add_extra_method (acfg, get_runtime_invoke (acfg, wrapper, FALSE)); - m = get_method_nofail (klass, "Set", -1, 0); - g_assert (m); - wrapper = mono_marshal_get_array_accessor_wrapper (m); + array_m = get_method_nofail (klass, "Set", -1, 0); + g_assert (array_m); + wrapper = mono_marshal_get_array_accessor_wrapper (array_m); add_extra_method (acfg, wrapper); if (!acfg->aot_opts.llvm_only) add_extra_method (acfg, get_runtime_invoke (acfg, wrapper, FALSE)); @@ -5006,7 +5004,7 @@ add_wrappers (MonoAotCompile *acfg) /* Synchronized wrappers */ rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_METHOD]); - for (i = 0; i < rows; ++i) { + for (int i = 0; i < rows; ++i) { ERROR_DECL (error); token = MONO_TOKEN_METHOD_DEF | (i + 1); method = mono_get_method_checked (acfg->image, token, NULL, NULL, error); @@ -5016,9 +5014,8 @@ add_wrappers (MonoAotCompile *acfg) if (method->is_generic) { // FIXME: } else if ((acfg->jit_opts & MONO_OPT_GSHAREDVT) && mono_class_is_gtd (method->klass)) { - ERROR_DECL (error); MonoGenericContext ctx; - MonoMethod *inst, *gshared, *m; + MonoMethod *inst, *gshared, *wrapper; /* * Create a generic wrapper for a generic instance, and AOT that. @@ -5026,9 +5023,9 @@ add_wrappers (MonoAotCompile *acfg) create_gsharedvt_inst (acfg, method, &ctx); inst = mono_class_inflate_generic_method_checked (method, &ctx, error); g_assert (is_ok (error)); /* FIXME don't swallow the error */ - m = mono_marshal_get_synchronized_wrapper (inst); - g_assert (m->is_inflated); - gshared = mini_get_shared_method_full (m, SHARE_MODE_GSHAREDVT, error); + wrapper = mono_marshal_get_synchronized_wrapper (inst); + g_assert (wrapper->is_inflated); + gshared = mini_get_shared_method_full (wrapper, SHARE_MODE_GSHAREDVT, error); mono_error_assert_ok (error); add_method (acfg, gshared); @@ -5040,11 +5037,9 @@ add_wrappers (MonoAotCompile *acfg) /* pinvoke wrappers */ rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_METHOD]); - for (i = 0; i < rows; ++i) { + for (int i = 0; i < rows; ++i) { ERROR_DECL (error); - MonoMethod *method; - guint32 token = MONO_TOKEN_METHOD_DEF | (i + 1); - + token = MONO_TOKEN_METHOD_DEF | (i + 1); method = mono_get_method_checked (acfg->image, token, NULL, NULL, error); report_loader_error (acfg, error, TRUE, "Failed to load method token 0x%x due to %s\n", i, mono_error_get_message (error)); @@ -5063,13 +5058,13 @@ add_wrappers (MonoAotCompile *acfg) /* native-to-managed wrappers */ rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_METHOD]); - for (i = 0; i < rows; ++i) { + for (int i = 0; i < rows; ++i) { ERROR_DECL (error); - MonoMethod *method; - guint32 token = MONO_TOKEN_METHOD_DEF | (i + 1); + MonoCustomAttrInfo *cattr; int j; + token = MONO_TOKEN_METHOD_DEF | (i + 1); method = mono_get_method_checked (acfg->image, token, NULL, NULL, error); report_loader_error (acfg, error, TRUE, "Failed to load method token 0x%x due to %s\n", i, mono_error_get_message (error)); @@ -5091,7 +5086,6 @@ add_wrappers (MonoAotCompile *acfg) break; if (j < cattr->num_attrs) { MonoCustomAttrEntry *e = &cattr->attrs [j]; - MonoMethodSignature *sig = mono_method_signature_internal (e->ctor); const char *p = (const char*)e->data; const char *named; int slen, num_named, named_type; @@ -5108,6 +5102,8 @@ add_wrappers (MonoAotCompile *acfg) exit (1); } + sig = mono_method_signature_internal (e->ctor); + g_assert (sig->param_count == 1); g_assert (sig->params [0]->type == MONO_TYPE_CLASS && !strcmp (m_class_get_name (mono_class_from_mono_type_internal (sig->params [0])), "Type")); @@ -5229,7 +5225,7 @@ MONO_RESTORE_WARNING /* StructureToPtr/PtrToStructure wrappers */ rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_TYPEDEF]); - for (i = 0; i < rows; ++i) { + for (int i = 0; i < rows; ++i) { ERROR_DECL (error); MonoClass *klass; @@ -5380,7 +5376,7 @@ add_types_from_method_header (MonoAotCompile *acfg, MonoMethod *method); static gboolean inst_has_vtypes (MonoGenericInst *inst) { - for (int i = 0; i < inst->type_argc; ++i) { + for (guint i = 0; i < inst->type_argc; ++i) { MonoType *t = inst->type_argv [i]; if (MONO_TYPE_ISSTRUCT (t)) return TRUE; @@ -5510,11 +5506,11 @@ add_generic_class_with_depth (MonoAotCompile *acfg, MonoClass *klass, int depth, * For ICollection, add instances of the helper methods * in Array, since a T[] could be cast to ICollection. */ + iter = NULL; if (in_corlib && !strcmp (klass_name_space, "System.Collections.Generic") && (!strcmp(klass_name, "ICollection`1") || !strcmp (klass_name, "IEnumerable`1") || !strcmp (klass_name, "IList`1") || !strcmp (klass_name, "IEnumerator`1") || !strcmp (klass_name, "IReadOnlyList`1"))) { MonoClass *tclass = mono_class_from_mono_type_internal (mono_class_get_generic_class (klass)->context.class_inst->type_argv [0]); MonoClass *array_class = mono_class_create_bounded_array (tclass, 1, FALSE); - gpointer iter; char *name_prefix; if (!strcmp (klass_name, "IEnumerator`1")) @@ -5522,7 +5518,6 @@ add_generic_class_with_depth (MonoAotCompile *acfg, MonoClass *klass, int depth, else name_prefix = g_strdup_printf ("%s.%s", klass_name_space, klass_name); - iter = NULL; while ((method = mono_class_get_methods (array_class, &iter))) { if (!strncmp (method->name, name_prefix, strlen (name_prefix))) { MonoMethod *m = mono_aot_get_array_helper_from_wrapper (method); @@ -5581,7 +5576,6 @@ add_generic_class_with_depth (MonoAotCompile *acfg, MonoClass *klass, int depth, if (mono_class_is_assignable_from_internal (iface_inst, tclass)) { MonoClass *gcomparer_inst; - ERROR_DECL (error); gcomparer = mono_class_load_from_name (mono_defaults.corlib, "System.Collections.Generic", "GenericEqualityComparer`1"); gcomparer_inst = mono_class_inflate_generic_class_checked (gcomparer, &ctx, error); @@ -5694,7 +5688,6 @@ add_types_from_method_header (MonoAotCompile *acfg, MonoMethod *method) static void add_generic_instances (MonoAotCompile *acfg) { - int i; guint32 token; MonoMethod *method; MonoGenericContext *context; @@ -5703,7 +5696,7 @@ add_generic_instances (MonoAotCompile *acfg) return; int rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_METHODSPEC]); - for (i = 0; i < rows; ++i) { + for (int i = 0; i < rows; ++i) { ERROR_DECL (error); token = MONO_TOKEN_METHOD_SPEC | (i + 1); method = mono_get_method_checked (acfg->image, token, NULL, NULL, error); @@ -5728,30 +5721,28 @@ add_generic_instances (MonoAotCompile *acfg) * FIXME: Handle class_inst as well. */ if (context && context->method_inst && context->method_inst->is_open) { - ERROR_DECL (error); MonoGenericContext shared_context; MonoGenericInst *inst; MonoType **type_argv; - int i; MonoMethod *declaring_method; gboolean supported = TRUE; /* Check that the context doesn't contain open constructed types */ if (context->class_inst) { inst = context->class_inst; - for (i = 0; i < inst->type_argc; ++i) { - if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR) + for (guint j = 0; j < inst->type_argc; ++j) { + if (MONO_TYPE_IS_REFERENCE (inst->type_argv [j]) || inst->type_argv [j]->type == MONO_TYPE_VAR || inst->type_argv [j]->type == MONO_TYPE_MVAR) continue; - if (mono_class_is_open_constructed_type (inst->type_argv [i])) + if (mono_class_is_open_constructed_type (inst->type_argv [j])) supported = FALSE; } } if (context->method_inst) { inst = context->method_inst; - for (i = 0; i < inst->type_argc; ++i) { - if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR) + for (guint j = 0; j < inst->type_argc; ++j) { + if (MONO_TYPE_IS_REFERENCE (inst->type_argv [j]) || inst->type_argv [j]->type == MONO_TYPE_VAR || inst->type_argv [j]->type == MONO_TYPE_MVAR) continue; - if (mono_class_is_open_constructed_type (inst->type_argv [i])) + if (mono_class_is_open_constructed_type (inst->type_argv [j])) supported = FALSE; } } @@ -5764,11 +5755,11 @@ add_generic_instances (MonoAotCompile *acfg) inst = context->class_inst; if (inst) { type_argv = g_new0 (MonoType*, inst->type_argc); - for (i = 0; i < inst->type_argc; ++i) { - if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR) - type_argv [i] = mono_get_object_type (); + for (guint j = 0; j < inst->type_argc; ++j) { + if (MONO_TYPE_IS_REFERENCE (inst->type_argv [j]) || inst->type_argv [j]->type == MONO_TYPE_VAR || inst->type_argv [j]->type == MONO_TYPE_MVAR) + type_argv [j] = mono_get_object_type (); else - type_argv [i] = inst->type_argv [i]; + type_argv [j] = inst->type_argv [j]; } shared_context.class_inst = mono_metadata_get_generic_inst (inst->type_argc, type_argv); @@ -5778,11 +5769,11 @@ add_generic_instances (MonoAotCompile *acfg) inst = context->method_inst; if (inst) { type_argv = g_new0 (MonoType*, inst->type_argc); - for (i = 0; i < inst->type_argc; ++i) { - if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR) - type_argv [i] = mono_get_object_type (); + for (guint j = 0; j < inst->type_argc; ++j) { + if (MONO_TYPE_IS_REFERENCE (inst->type_argv [j]) || inst->type_argv [j]->type == MONO_TYPE_VAR || inst->type_argv [j]->type == MONO_TYPE_MVAR) + type_argv [j] = mono_get_object_type (); else - type_argv [i] = inst->type_argv [i]; + type_argv [j] = inst->type_argv [j]; } shared_context.method_inst = mono_metadata_get_generic_inst (inst->type_argc, type_argv); @@ -5813,7 +5804,7 @@ add_generic_instances (MonoAotCompile *acfg) } rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_TYPESPEC]); - for (i = 0; i < rows; ++i) { + for (int i = 0; i < rows; ++i) { ERROR_DECL (error); MonoClass *klass; @@ -5829,7 +5820,7 @@ add_generic_instances (MonoAotCompile *acfg) } /* Add types of args/locals */ - for (i = 0; i < acfg->methods->len; ++i) { + for (guint i = 0; i < acfg->methods->len; ++i) { method = (MonoMethod *)g_ptr_array_index (acfg->methods, i); add_types_from_method_header (acfg, method); } @@ -5873,20 +5864,20 @@ add_generic_instances (MonoAotCompile *acfg) /* Add instances of EnumEqualityComparer which are created by EqualityComparer for enums */ { MonoClass *k, *enum_comparer; - MonoType *insts [16]; - int ninsts; + MonoType *enum_insts [16]; + int enum_ninsts; const char *enum_names [] = { "I8Enum", "I16Enum", "I32Enum", "I64Enum", "UI8Enum", "UI16Enum", "UI32Enum", "UI64Enum" }; - ninsts = 0; - for (int i = 0; i < G_N_ELEMENTS (enum_names); ++i) { + enum_ninsts = 0; + for (size_t i = 0; i < G_N_ELEMENTS (enum_names); ++i) { k = mono_class_try_load_from_name (acfg->image, "Mono", enum_names [i]); g_assert (k); - insts [ninsts ++] = m_class_get_byval_arg (k); + enum_insts [enum_ninsts ++] = m_class_get_byval_arg (k); } enum_comparer = mono_class_load_from_name (mono_defaults.corlib, "System.Collections.Generic", "EnumEqualityComparer`1"); - add_instances_of (acfg, enum_comparer, insts, ninsts, TRUE); + add_instances_of (acfg, enum_comparer, enum_insts, enum_ninsts, TRUE); enum_comparer = mono_class_load_from_name (mono_defaults.corlib, "System.Collections.Generic", "EnumComparer`1"); - add_instances_of (acfg, enum_comparer, insts, ninsts, TRUE); + add_instances_of (acfg, enum_comparer, enum_insts, enum_ninsts, TRUE); } /* Add instances of the array generic interfaces for primitive types */ @@ -5930,7 +5921,7 @@ add_generic_instances (MonoAotCompile *acfg) } /* object[] accessor wrappers. */ - for (i = 1; i < 4; ++i) { + for (int i = 1; i < 4; ++i) { MonoClass *obj_array_class = mono_class_create_array (mono_defaults.object_class, i); MonoMethod *m; @@ -7933,9 +7924,7 @@ emit_trampolines (MonoAotCompile *acfg) GSList *l = mono_arch_get_trampolines (TRUE); while (l) { - MonoTrampInfo *info = (MonoTrampInfo *)l->data; - - emit_trampoline (acfg, info); + emit_trampoline (acfg, (MonoTrampInfo *)l->data); l = l->next; } } @@ -7967,9 +7956,7 @@ emit_trampolines (MonoAotCompile *acfg) /* delegate_invoke_impl trampolines */ l = mono_arch_get_delegate_invoke_impls (); while (l) { - MonoTrampInfo *info = (MonoTrampInfo *)l->data; - - emit_trampoline (acfg, info); + emit_trampoline (acfg, (MonoTrampInfo *)l->data); l = l->next; } } @@ -8402,7 +8389,7 @@ mono_aot_parse_options (const char *aot_options, MonoAotOptions *opts) GPtrArray* args; args = mono_aot_split_options (aot_options ? aot_options : ""); - for (int i = 0; i < args->len; ++i) { + for (guint i = 0; i < args->len; ++i) { const char *arg = (const char *)g_ptr_array_index (args, i); if (str_begins_with (arg, "outfile=")) { @@ -9692,7 +9679,7 @@ sanitize_mangled_string (const char *input) { GString *s = g_string_new (""); - for (int i=0; input [i] != '\0'; i++) { + for (size_t i = 0; input [i] != '\0'; i++) { char c = input [i]; switch (c) { case '.': @@ -9893,11 +9880,11 @@ append_mangled_wrapper (GString *s, MonoMethod *method) g_string_append_printf (s, "i_"); success = success && append_mangled_klass (s, method->klass); } else { - WrapperInfo *info = mono_marshal_get_wrapper_info (method); + WrapperInfo *wrapper_info = mono_marshal_get_wrapper_info (method); g_string_append_printf (s, "u_"); if (method->wrapper_type == MONO_WRAPPER_DELEGATE_INVOKE) - append_mangled_wrapper_subtype (s, info->subtype); + append_mangled_wrapper_subtype (s, wrapper_info->subtype); g_string_append_printf (s, "u_sigstart"); } break; @@ -10951,8 +10938,7 @@ emit_extra_methods (MonoAotCompile *acfg) encode_int (table_size, p, &p); for (i = 0; i < table->len; ++i) { - HashEntry *entry = (HashEntry *)g_ptr_array_index (table, i); - + entry = (HashEntry *)g_ptr_array_index (table, i); if (entry == NULL) { encode_int (0, p, &p); encode_int (0, p, &p); @@ -11187,8 +11173,7 @@ emit_class_name_table (MonoAotCompile *acfg) encode_int16 (table_size, p, &p); g_assert (table->len < 65000); for (i = 0; i < table->len; ++i) { - ClassNameTableEntry *entry = (ClassNameTableEntry *)g_ptr_array_index (table, i); - + entry = (ClassNameTableEntry *)g_ptr_array_index (table, i); if (entry == NULL) { encode_int16 (0, p, &p); encode_int16 (0, p, &p); @@ -11516,8 +11501,7 @@ emit_globals (MonoAotCompile *acfg) g_assert (table_size < 65000); emit_int16 (acfg, table_size); for (i = 0; i < table->len; ++i) { - GlobalsTableEntry *entry = (GlobalsTableEntry *)g_ptr_array_index (table, i); - + entry = (GlobalsTableEntry *)g_ptr_array_index (table, i); if (entry == NULL) { emit_int16 (acfg, 0); emit_int16 (acfg, 0); @@ -12845,14 +12829,12 @@ load_profile_file (MonoAotCompile *acfg, char *filename) break; } case AOTPROF_RECORD_GINST: { - int i; - int len = profread_int (infile); - GInstProfileData *gdata = g_new0 (GInstProfileData, 1); - gdata->argc = len; + len = profread_int (infile); + gdata->argc = (int)len; gdata->argv = g_new0 (ClassProfileData*, len); - for (i = 0; i < len; ++i) { + for (size_t i = 0; i < len; ++i) { int class_id = profread_int (infile); gdata->argv [i] = (ClassProfileData*)g_hash_table_lookup (data->classes, GINT_TO_POINTER (class_id)); @@ -12862,9 +12844,7 @@ load_profile_file (MonoAotCompile *acfg, char *filename) break; } case AOTPROF_RECORD_TYPE: { - int type = profread_byte (infile); - - switch (type) { + switch (profread_byte (infile)) { case MONO_TYPE_CLASS: { int image_id = profread_int (infile); int ginst_id = profread_int (infile); @@ -13840,7 +13820,7 @@ mono_setup_dedup_state (MonoAotCompile *acfg, MonoAotState **global_aot_state, M gchar *asm_file = NULL; // Get the last part of the path, the filename - for (int i=0; asm_path [i] != NULL; i++) + for (size_t i = 0; asm_path [i] != NULL; i++) asm_file = asm_path [i]; if (!strcmp (acfg->aot_opts.dedup_include, asm_file)) { @@ -14263,10 +14243,10 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options, add_method (acfg, wrapper); #ifndef MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE - for (int i = 0; i < G_N_ELEMENTS (interp_in_static_sigs); i++) + for (size_t i = 0; i < G_N_ELEMENTS (interp_in_static_sigs); i++) add_interp_in_wrapper_for_sig (acfg, *interp_in_static_sigs [i]); #else - for (int i = 0; i < G_N_ELEMENTS (interp_in_static_common_sigs); i++) + for (size_t i = 0; i < G_N_ELEMENTS (interp_in_static_common_sigs); i++) add_interp_in_wrapper_for_sig (acfg, *interp_in_static_common_sigs [i]); #endif @@ -14379,7 +14359,7 @@ create_depfile (MonoAotCompile *acfg) targets [0] = acfg->aot_opts.llvm_outfile; for (int tindex = 0; tindex < ntargets; ++tindex) { fprintf (depfile, "%s: ", targets [tindex]); - for (int i = 0; i < acfg->image_table->len; i++) { + for (guint i = 0; i < acfg->image_table->len; i++) { MonoImage *image = (MonoImage*)g_ptr_array_index (acfg->image_table, i); fprintf (depfile, " %s", image->filename); } @@ -14442,8 +14422,7 @@ emit_aot_image (MonoAotCompile *acfg) acfg->fp = fopen (acfg->tmpfname, "w+"); } else { if (strcmp (acfg->aot_opts.temp_path, "") == 0) { - int i = g_file_open_tmp ("mono_aot_XXXXXX", &acfg->tmpfname, NULL); - acfg->fp = fdopen (i, "w+"); + acfg->fp = fdopen (g_file_open_tmp ("mono_aot_XXXXXX", &acfg->tmpfname, NULL), "w+"); } else { acfg->tmpbasename = g_build_filename (acfg->aot_opts.temp_path, "temp", (const char*)NULL); acfg->tmpfname = g_strdup_printf ("%s.s", acfg->tmpbasename); @@ -14573,10 +14552,10 @@ emit_aot_image (MonoAotCompile *acfg) #ifdef ENABLE_LLVM if (acfg->llvm) { - gboolean res; + gboolean emit_res; - res = emit_llvm_file (acfg); - if (!res) + emit_res = emit_llvm_file (acfg); + if (!emit_res) return 1; } #endif diff --git a/src/mono/mono/mini/aot-runtime.c b/src/mono/mono/mini/aot-runtime.c index f23c02730c8da..c3e36f39923f7 100644 --- a/src/mono/mono/mini/aot-runtime.c +++ b/src/mono/mono/mini/aot-runtime.c @@ -283,8 +283,8 @@ amodule_unlock (MonoAotModule *amodule) static MonoImage * load_image (MonoAotModule *amodule, int index, MonoError *error) { - MonoAssembly *assembly; - MonoImageOpenStatus status; + MonoAssembly *assembly = NULL; + MonoImageOpenStatus status = MONO_IMAGE_OK; MonoAssemblyLoadContext *alc = mono_alc_get_ambient (); g_assert (index < amodule->image_table_len); @@ -1060,8 +1060,8 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod ref->method = mini_get_interp_in_wrapper (sig); g_free (sig); } else if (subtype == WRAPPER_SUBTYPE_INTERP_LMF) { - MonoJitICallInfo *info = mono_find_jit_icall_info ((MonoJitICallId)decode_value (p, &p)); - ref->method = mini_get_interp_lmf_wrapper (info->name, (gpointer) info->func); + MonoJitICallInfo *icall_info = mono_find_jit_icall_info ((MonoJitICallId)decode_value (p, &p)); + ref->method = mini_get_interp_lmf_wrapper (icall_info->name, (gpointer) icall_info->func); } else if (subtype == WRAPPER_SUBTYPE_GSHAREDVT_IN_SIG) { MonoMethodSignature *sig = decode_signature (module, p, &p); if (!sig) @@ -1128,8 +1128,8 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod int subtype = decode_value (p, &p); if (subtype == WRAPPER_SUBTYPE_ICALL_WRAPPER) { - MonoJitICallInfo *info = mono_find_jit_icall_info ((MonoJitICallId)decode_value (p, &p)); - ref->method = mono_icall_get_wrapper_method (info); + MonoJitICallInfo *icall_info = mono_find_jit_icall_info ((MonoJitICallId)decode_value (p, &p)); + ref->method = mono_icall_get_wrapper_method (icall_info); } else if (subtype == WRAPPER_SUBTYPE_NATIVE_FUNC_INDIRECT) { MonoClass *klass = decode_klass_ref (module, p, &p, error); if (!klass) @@ -1347,6 +1347,7 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod memset (&ctx, 0, sizeof (ctx)); +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ if (FALSE && mono_class_is_ginst (klass)) { ctx.class_inst = mono_class_get_generic_class (klass)->context.class_inst; ctx.method_inst = NULL; @@ -1355,6 +1356,7 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod if (!ref->method) return FALSE; } +MONO_RESTORE_WARNING memset (&ctx, 0, sizeof (ctx)); @@ -1904,7 +1906,7 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer char *msg = NULL; gpointer *globals = NULL; MonoAotFileInfo *info = NULL; - int i, version; + int version; int align_double, align_int64; guint8 *aot_data = NULL; @@ -2094,7 +2096,7 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer amodule->shared_got = g_new0 (gpointer, info->nshared_got_entries); if (info->flags & MONO_AOT_FILE_FLAG_SEPARATE_DATA) { - for (i = 0; i < MONO_AOT_TABLE_NUM; ++i) + for (int i = 0; i < MONO_AOT_TABLE_NUM; ++i) amodule->tables [i] = aot_data + info->table_offsets [i]; } @@ -2102,7 +2104,7 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer /* Read image table */ { - guint32 table_len, i; + guint32 table_len; char *table = NULL; if (info->flags & MONO_AOT_FILE_FLAG_SEPARATE_DATA) @@ -2117,7 +2119,7 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer amodule->image_names = g_new0 (MonoAssemblyName, table_len); amodule->image_guids = g_new0 (char*, table_len); amodule->image_table_len = table_len; - for (i = 0; i < table_len; ++i) { + for (guint32 i = 0; i < table_len; ++i) { MonoAssemblyName *aname = &(amodule->image_names [i]); aname->name = g_strdup (table); @@ -2194,7 +2196,7 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer /* Compute method addresses */ amodule->methods = (void **)g_malloc0 (amodule->info.nmethods * sizeof (gpointer)); - for (i = 0; i < amodule->info.nmethods; ++i) { + for (guint32 i = 0; i < amodule->info.nmethods; ++i) { void *addr = NULL; if (amodule->info.llvm_get_method) { @@ -2306,10 +2308,10 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer * The cached class info also depends on the exact assemblies. */ if (!mono_opt_aot_lazy_assembly_load) { - for (i = 0; i < amodule->image_table_len; ++i) { - ERROR_DECL (error); - load_image (amodule, i, error); - mono_error_cleanup (error); /* FIXME don't swallow the error */ + for (guint32 i = 0; i < amodule->image_table_len; ++i) { + ERROR_DECL (load_error); + load_image (amodule, i, load_error); + mono_error_cleanup (load_error); /* FIXME don't swallow the error */ } } @@ -2681,10 +2683,10 @@ compute_llvm_code_range (MonoAotModule *amodule, guint8 **code_start, guint8 **c //gsize prev = 0; // FIXME: This depends on emscripten allocating ftnptr ids sequentially - for (int i = 0; i < amodule->info.nmethods; ++i) { + for (guint32 i = 0; i < amodule->info.nmethods; ++i) { void *addr = NULL; - addr = get_method (i); + addr = get_method ((int)i); gsize val = (gsize)addr; if (val) { //g_assert (val > prev); @@ -2987,7 +2989,7 @@ decode_exception_debug_info (MonoAotModule *amodule, guint8 *code, guint32 code_len) { ERROR_DECL (error); - int i, buf_len, num_clauses, len; + int buf_len, num_clauses; MonoJitInfo *jinfo; MonoJitInfoFlags flags = JIT_INFO_NONE; guint unwind_info, eflags; @@ -3045,6 +3047,7 @@ decode_exception_debug_info (MonoAotModule *amodule, num_clauses = 0; if (from_llvm) { + int len; MonoJitExceptionInfo *clauses; GSList **nesting; @@ -3067,13 +3070,13 @@ decode_exception_debug_info (MonoAotModule *amodule, nesting = g_new0 (GSList*, num_clauses); } - for (i = 0; i < num_clauses; ++i) { + for (int i = 0; i < num_clauses; ++i) { MonoJitExceptionInfo *ei = &clauses [i]; ei->flags = decode_value (p, &p); if (!(ei->flags == MONO_EXCEPTION_CLAUSE_FILTER || ei->flags == MONO_EXCEPTION_CLAUSE_FINALLY)) { - int len = decode_value (p, &p); + len = decode_value (p, &p); if (len > 0) { if (async) { @@ -3116,18 +3119,18 @@ decode_exception_debug_info (MonoAotModule *amodule, if (!async) { g_free (clauses); - for (i = 0; i < num_clauses; ++i) + for (int i = 0; i < num_clauses; ++i) g_slist_free (nesting [i]); g_free (nesting); } jinfo->from_llvm = 1; } else { - len = mono_jit_info_size (flags, num_clauses, num_holes); + int len = mono_jit_info_size (flags, num_clauses, num_holes); jinfo = (MonoJitInfo *)alloc0_jit_info_data (mem_manager, len, async); /* The jit info table needs to sort addresses so it contains non-authenticated pointers on arm64e */ mono_jit_info_init (jinfo, method, code, code_len, flags, num_clauses, num_holes); - for (i = 0; i < jinfo->num_clauses; ++i) { + for (guint32 i = 0; i < jinfo->num_clauses; ++i) { MonoJitExceptionInfo *ei = &jinfo->clauses [i]; ei->flags = decode_value (p, &p); @@ -3143,7 +3146,7 @@ decode_exception_debug_info (MonoAotModule *amodule, if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER || ei->flags == MONO_EXCEPTION_CLAUSE_FINALLY) { ei->data.filter = code + decode_value (p, &p); } else { - int len = decode_value (p, &p); + len = decode_value (p, &p); if (len > 0) { if (async) { @@ -3182,7 +3185,7 @@ decode_exception_debug_info (MonoAotModule *amodule, g_assert (table); table->num_holes = (guint16)num_holes; - for (i = 0; i < num_holes; ++i) { + for (int i = 0; i < num_holes; ++i) { MonoTryBlockHoleJitInfo *hole = &table->holes [i]; hole->clause = decode_value (p, &p); hole->length = decode_value (p, &p); @@ -3220,7 +3223,7 @@ decode_exception_debug_info (MonoAotModule *amodule, gi->nlocs = decode_value (p, &p); if (gi->nlocs) { gi->locations = (MonoDwarfLocListEntry *)alloc0_jit_info_data (mem_manager, gi->nlocs * sizeof (MonoDwarfLocListEntry), async); - for (i = 0; i < gi->nlocs; ++i) { + for (int i = 0; i < gi->nlocs; ++i) { MonoDwarfLocListEntry *entry = &gi->locations [i]; entry->is_reg = decode_value (p, &p); @@ -3522,11 +3525,11 @@ mono_aot_find_jit_info (MonoImage *image, gpointer addr) /* In async mode, jinfo is not added to the normal jit info table, so have to cache it ourselves */ if (async) { - JitInfoMap **table = amodule->async_jit_info_table; + JitInfoMap **jinfo_table = amodule->async_jit_info_table; LOAD_ACQUIRE_FENCE; - if (table) { + if (jinfo_table) { int buckets = (amodule->info.nmethods / JIT_INFO_MAP_BUCKET_SIZE) + 1; - JitInfoMap *current_item = table [method_index % buckets]; + JitInfoMap *current_item = jinfo_table [method_index % buckets]; LOAD_ACQUIRE_FENCE; while (current_item) { if (current_item->method_index == method_index) @@ -3609,11 +3612,11 @@ mono_aot_find_jit_info (MonoImage *image, gpointer addr) /* Happens when a random address is passed in which matches a not-yey called wrapper encoded using its name */ return NULL; } else { - ERROR_DECL (error); token = mono_metadata_make_token (MONO_TABLE_METHOD, method_index + 1); method = mono_get_method_checked (image, token, NULL, NULL, error); if (!method) g_error ("AOT runtime could not load method due to %s", mono_error_get_message (error)); /* FIXME don't swallow the error */ + mono_error_cleanup (error); } } /* FIXME: */ @@ -3675,7 +3678,6 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin guint8 *p = buf; gpointer *table; MonoImage *image; - int i; MonoMemoryManager *mem_manager = m_image_get_mem_manager (aot_module->assembly->image); switch (ji->type) { @@ -3704,10 +3706,10 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin if (ref.method) { ji->data.method = ref.method; }else { - ERROR_DECL (error); ji->data.method = mono_get_method_checked (ref.image, ref.token, NULL, NULL, error); if (!ji->data.method) g_error ("AOT Runtime could not load method due to %s", mono_error_get_message (error)); /* FIXME don't swallow the error */ + mono_error_assert_ok (error); } g_assert (ji->data.method); mono_class_init_internal (ji->data.method->klass); @@ -3771,7 +3773,7 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin ji->data.table->table_size = decode_value (p, &p); table = (void **)mono_mem_manager_alloc (mem_manager, sizeof (gpointer) * ji->data.table->table_size); ji->data.table->table = (MonoBasicBlock**)table; - for (i = 0; i < ji->data.table->table_size; i++) + for (int i = 0; i < ji->data.table->table_size; i++) table [i] = (gpointer)(gssize)decode_value (p, &p); break; case MONO_PATCH_INFO_R4: @@ -3896,7 +3898,6 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin } case MONO_PATCH_INFO_GSHAREDVT_METHOD: { MonoGSharedVtMethodInfo *info = (MonoGSharedVtMethodInfo *)mono_mempool_alloc0 (mp, sizeof (MonoGSharedVtMethodInfo)); - int i; info->method = decode_resolve_method_ref (aot_module, p, &p, error); mono_error_assert_ok (error); /* FIXME don't swallow the error */ @@ -3904,7 +3905,7 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin info->num_entries = decode_value (p, &p); info->count_entries = info->num_entries; info->entries = (MonoRuntimeGenericContextInfoTemplate *)mono_mempool_alloc0 (mp, sizeof (MonoRuntimeGenericContextInfoTemplate) * info->num_entries); - for (i = 0; i < info->num_entries; ++i) { + for (int i = 0; i < info->num_entries; ++i) { MonoRuntimeGenericContextInfoTemplate *template_ = &info->entries [i]; template_->info_type = (MonoRgctxInfoType)decode_value (p, &p); @@ -4292,8 +4293,6 @@ load_method (MonoAotModule *amodule, MonoImage *image, MonoMethod *method, guint amodule_unlock (amodule); if (MONO_PROFILER_ENABLED (jit_begin) || MONO_PROFILER_ENABLED (jit_done)) { - MonoJitInfo *jinfo; - if (!method) { method = mono_get_method_checked (amodule->assembly->image, token, NULL, NULL, error); if (!method) @@ -4303,6 +4302,7 @@ load_method (MonoAotModule *amodule, MonoImage *image, MonoMethod *method, guint jinfo = mono_jit_info_table_find_internal (code, TRUE, FALSE); g_assert (jinfo); MONO_PROFILER_RAISE (jit_done, (method, jinfo)); + jinfo = NULL; } return code; @@ -4409,7 +4409,7 @@ add_module_cb (gpointer key, gpointer value, gpointer user_data) static gboolean inst_is_private (MonoGenericInst *inst) { - for (int i = 0; i < inst->type_argc; ++i) { + for (guint i = 0; i < inst->type_argc; ++i) { MonoType *t = inst->type_argv [i]; if ((t->type == MONO_TYPE_CLASS || t->type == MONO_TYPE_VALUETYPE)) { int access_level = mono_class_get_flags (t->data.klass) & TYPE_ATTRIBUTE_VISIBILITY_MASK; @@ -4758,7 +4758,7 @@ mono_aot_get_method (MonoMethod *method, MonoError *error) gboolean dedupable = mono_aot_can_dedup (method); if (method->is_inflated && !method->wrapper_type && mono_method_is_generic_sharable_full (method, TRUE, FALSE, FALSE) && !dedupable) { - MonoMethod *orig_method = method; + MonoMethod *generic_orig_method = method; /* * For generic methods, we store the fully shared instance in place of the * original method. @@ -4768,9 +4768,9 @@ mono_aot_get_method (MonoMethod *method, MonoError *error) if (amodule->info.flags & MONO_AOT_FILE_FLAG_WITH_LLVM) { /* Needed by mini_llvm_init_gshared_method_this () */ - /* orig_method is a random instance but it is enough to make init_method () work */ + /* generic_orig_method is a random instance but it is enough to make init_method () work */ amodule_lock (amodule); - g_hash_table_insert (amodule->extra_methods, GUINT_TO_POINTER (method_index), orig_method); + g_hash_table_insert (amodule->extra_methods, GUINT_TO_POINTER (method_index), generic_orig_method); amodule_unlock (amodule); } } diff --git a/src/mono/mono/mini/branch-opts.c b/src/mono/mono/mini/branch-opts.c index bdf889f57953e..c7c17b938b65d 100644 --- a/src/mono/mono/mini/branch-opts.c +++ b/src/mono/mono/mini/branch-opts.c @@ -971,7 +971,6 @@ mono_merge_basic_blocks (MonoCompile *cfg, MonoBasicBlock *bb, MonoBasicBlock *b { MonoInst *inst; MonoBasicBlock *prev_bb; - int i; /* There may be only one control flow edge between two BBs that we merge, and it should connect these BBs together. */ g_assert (bb->out_count == 1 && bbn->in_count == 1 && bb->out_bb [0] == bbn && bbn->in_bb [0] == bb); @@ -980,7 +979,7 @@ mono_merge_basic_blocks (MonoCompile *cfg, MonoBasicBlock *bb, MonoBasicBlock *b bb->extended |= bbn->extended; mono_unlink_bblock (cfg, bb, bbn); - for (i = 0; i < bbn->out_count; ++i) + for (gint16 i = 0; i < bbn->out_count; ++i) mono_link_bblock (cfg, bb, bbn->out_bb [i]); while (bbn->out_count) mono_unlink_bblock (cfg, bbn, bbn->out_bb [0]); @@ -997,9 +996,8 @@ mono_merge_basic_blocks (MonoCompile *cfg, MonoBasicBlock *bb, MonoBasicBlock *b if (bb->has_jump_table) { for (inst = bb->code; inst != NULL; inst = inst->next) { if (MONO_IS_JUMP_TABLE (inst)) { - int i; MonoJumpInfoBBTable *table = (MonoJumpInfoBBTable *)MONO_JUMP_TABLE_FROM_INS (inst); - for (i = 0; i < table->table_size; i++ ) { + for (int i = 0; i < table->table_size; i++ ) { /* Might be already NULL from a previous merge */ if (table->table [i]) g_assert (table->table [i] == bbn); diff --git a/src/mono/mono/mini/calls.c b/src/mono/mono/mini/calls.c index e6eed77d6884c..1b576f50782b6 100644 --- a/src/mono/mono/mini/calls.c +++ b/src/mono/mono/mini/calls.c @@ -661,7 +661,7 @@ mini_emit_llvmonly_virtual_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMeth static MonoMethodSignature *helper_sig_llvmonly_imt_trampoline = NULL; MonoInst *icall_args [16]; MonoInst *call_target, *ins, *vtable_ins; - int arg_reg, this_reg, vtable_reg; + int this_reg, vtable_reg; gboolean is_iface = mono_class_is_interface (cmethod->klass); gboolean is_gsharedvt = cfg->gsharedvt && mini_is_gsharedvt_variable_signature (fsig); gboolean variant_iface = FALSE; @@ -883,7 +883,7 @@ mini_emit_llvmonly_virtual_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMeth icall_args [2] = mini_emit_get_rgctx_method (cfg, context_used, cmethod, MONO_RGCTX_INFO_METHOD); - arg_reg = alloc_preg (cfg); + int arg_reg = alloc_preg (cfg); MONO_EMIT_NEW_PCONST (cfg, arg_reg, NULL); EMIT_NEW_VARLOADA_VREG (cfg, icall_args [3], arg_reg, mono_get_int_type ()); diff --git a/src/mono/mono/mini/decompose.c b/src/mono/mono/mini/decompose.c index 8e6db0073f589..8860abd064937 100644 --- a/src/mono/mono/mini/decompose.c +++ b/src/mono/mono/mini/decompose.c @@ -23,6 +23,8 @@ #ifndef DISABLE_JIT +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ + /* * Decompose complex long opcodes on 64 bit machines. * This is also used on 32 bit machines when using LLVM, so it needs to handle I/U correctly. @@ -216,7 +218,7 @@ decompose_long_opcode (MonoCompile *cfg, MonoInst *ins, MonoInst **repl_ins) MONO_EMIT_NEW_COND_EXC (cfg, GT, "OverflowException"); /* The int cast is needed for the VS compiler. See Compiler Warning (level 2) C4146. */ #if SIZEOF_REGISTER == 8 - MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, ((int)-2147483648)); + MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, (-(int)2147483648)); #else g_assert (COMPILE_LLVM (cfg)); MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg1, -2147483648LL); @@ -288,6 +290,8 @@ decompose_long_opcode (MonoCompile *cfg, MonoInst *ins, MonoInst **repl_ins) return TRUE; } +MONO_RESTORE_WARNING + /* * mono_decompose_opcode: * @@ -535,8 +539,10 @@ mono_decompose_opcode (MonoCompile *cfg, MonoInst *ins) if (decompose_long_opcode (cfg, ins, &repl)) emulate = FALSE; #else +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ if (COMPILE_LLVM (cfg) && decompose_long_opcode (cfg, ins, &repl)) emulate = FALSE; +MONO_RESTORE_WARNING #endif if (emulate && mono_find_jit_opcode_emulation (ins->opcode)) @@ -1145,6 +1151,8 @@ mono_decompose_long_opts (MonoCompile *cfg) */ } +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ + /** * mono_decompose_vtype_opts: * @@ -1432,8 +1440,6 @@ mono_decompose_vtype_opts (MonoCompile *cfg) } case OP_BOX: case OP_BOX_ICONST: { - MonoInst *src; - /* Temporary value required by emit_box () */ if (ins->opcode == OP_BOX_ICONST) { NEW_ICONST (cfg, src, ins->inst_c0); @@ -1480,6 +1486,8 @@ mono_decompose_vtype_opts (MonoCompile *cfg) } } +MONO_RESTORE_WARNING + /** * mono_decompose_array_access_opts: * diff --git a/src/mono/mono/mini/dominators.c b/src/mono/mono/mini/dominators.c index 3e8197c6a64db..653906c084932 100644 --- a/src/mono/mono/mini/dominators.c +++ b/src/mono/mono/mini/dominators.c @@ -263,7 +263,6 @@ static void df_set (MonoCompile *m, MonoBitSet* dest, MonoBitSet *set) { int i; - mono_bitset_foreach_bit (set, i, m->num_bblocks) { mono_bitset_union_fast (dest, m->bblocks [i]->dfrontier); } diff --git a/src/mono/mono/mini/driver.c b/src/mono/mono/mini/driver.c index e68b33bc0350e..ae6a56ae387c0 100644 --- a/src/mono/mono/mini/driver.c +++ b/src/mono/mono/mini/driver.c @@ -157,17 +157,17 @@ parse_optimizations (guint32 opt, const char* p, gboolean cpu_opts) parts = g_strsplit (p, ",", -1); for (ptr = parts; ptr && *ptr; ptr ++) { char *arg = *ptr; - char *p = arg; + char *parg = arg; - if (*p == '-') { - p++; + if (*parg == '-') { + parg++; invert = TRUE; } else { invert = FALSE; } for (i = 0; i < G_N_ELEMENTS (opt_names) && optflag_get_name (i); ++i) { n = optflag_get_name (i); - if (!strcmp (p, n)) { + if (!strcmp (parg, n)) { if (invert) opt &= ~ (1 << i); else @@ -176,13 +176,13 @@ parse_optimizations (guint32 opt, const char* p, gboolean cpu_opts) } } if (i == G_N_ELEMENTS (opt_names) || !optflag_get_name (i)) { - if (strncmp (p, "all", 3) == 0) { + if (strncmp (parg, "all", 3) == 0) { if (invert) opt = 0; else opt = ~(EXCLUDED_FROM_ALL | exclude); } else { - fprintf (stderr, "Invalid optimization name `%s'\n", p); + fprintf (stderr, "Invalid optimization name `%s'\n", parg); exit (1); } } @@ -514,7 +514,7 @@ mini_regression_step (MonoImage *image, int verbose, int *total_run, int *total, #ifdef DISABLE_JIT #ifdef MONO_USE_AOT_COMPILER - ERROR_DECL (error); + error_init_reuse (error); func = (TestMethod)mono_aot_get_method (method, error); mono_error_cleanup (error); #else @@ -527,7 +527,7 @@ mini_regression_step (MonoImage *image, int verbose, int *total_run, int *total, comp_time += g_timer_elapsed (timer, NULL); if (cfg->exception_type == MONO_EXCEPTION_NONE) { #ifdef MONO_USE_AOT_COMPILER - ERROR_DECL (error); + error_init_reuse (error); func = (TestMethod)mono_aot_get_method (method, error); mono_error_cleanup (error); if (!func) { @@ -1800,16 +1800,14 @@ mono_jit_parse_options (int argc, char * argv[]) if (argv [i] [0] != '-') break; if (strncmp (argv [i], "--debugger-agent=", 17) == 0) { - MonoDebugOptions *opt = mini_get_debug_options (); - + MonoDebugOptions *debug_opt = mini_get_debug_options (); mono_debugger_agent_parse_options (g_strdup (argv [i] + 17)); - opt->mdb_optimizations = TRUE; + debug_opt ->mdb_optimizations = TRUE; enable_debugging = TRUE; } else if (!strcmp (argv [i], "--soft-breakpoints")) { - MonoDebugOptions *opt = mini_get_debug_options (); - - opt->soft_breakpoints = TRUE; - opt->explicit_null_checks = TRUE; + MonoDebugOptions *debug_opt = mini_get_debug_options (); + debug_opt ->soft_breakpoints = TRUE; + debug_opt ->explicit_null_checks = TRUE; } else if (strncmp (argv [i], "--optimize=", 11) == 0) { opt = parse_optimizations (opt, argv [i] + 11, TRUE); mono_set_optimizations (opt); @@ -1823,9 +1821,8 @@ mono_jit_parse_options (int argc, char * argv[]) } else if (strcmp (argv [i], "--verbose") == 0 || strcmp (argv [i], "-v") == 0) { mini_verbose_level++; } else if (strcmp (argv [i], "--breakonex") == 0) { - MonoDebugOptions *opt = mini_get_debug_options (); - - opt->break_on_exc = TRUE; + MonoDebugOptions *debug_opt = mini_get_debug_options (); + debug_opt->break_on_exc = TRUE; } else if (strcmp (argv [i], "--stats") == 0) { enable_runtime_stats (); } else if (strncmp (argv [i], "--stats=", 8) == 0) { @@ -2178,10 +2175,10 @@ mono_main (int argc, char* argv[]) fprintf (stderr, "Error: --bisect requires OPT:FILENAME\n"); return 1; } - char *opt_string = g_strndup (param, sep - param); - guint32 opt = parse_optimizations (0, opt_string, FALSE); - g_free (opt_string); - mono_set_bisect_methods (opt, sep + 1); + char *bisect_opt_string = g_strndup (param, sep - param); + guint32 bisect_opt = parse_optimizations (0, bisect_opt_string, FALSE); + g_free (bisect_opt_string); + mono_set_bisect_methods (bisect_opt, sep + 1); } else if (strcmp (argv [i], "--gc=sgen") == 0) { switch_gc (argv, "sgen"); } else if (strcmp (argv [i], "--gc=boehm") == 0) { @@ -2222,9 +2219,8 @@ mono_main (int argc, char* argv[]) } else if (strncmp (argv [i], "--trace=", 8) == 0) { trace_options = &argv [i][8]; } else if (strcmp (argv [i], "--breakonex") == 0) { - MonoDebugOptions *opt = mini_get_debug_options (); - - opt->break_on_exc = TRUE; + MonoDebugOptions *debug_opt = mini_get_debug_options (); + debug_opt->break_on_exc = TRUE; } else if (strcmp (argv [i], "--break") == 0) { if (i+1 >= argc){ fprintf (stderr, "Missing method name in --break command line option\n"); @@ -2361,16 +2357,14 @@ mono_main (int argc, char* argv[]) enable_debugging = TRUE; if (!parse_debug_options (argv [i] + 8)) return 1; - MonoDebugOptions *opt = mini_get_debug_options (); - - if (!opt->enabled) { + MonoDebugOptions *debug_opt = mini_get_debug_options (); + if (!debug_opt->enabled) { enable_debugging = FALSE; } } else if (strncmp (argv [i], "--debugger-agent=", 17) == 0) { - MonoDebugOptions *opt = mini_get_debug_options (); - + MonoDebugOptions *debug_opt = mini_get_debug_options (); mono_debugger_agent_parse_options (g_strdup (argv [i] + 17)); - opt->mdb_optimizations = TRUE; + debug_opt->mdb_optimizations = TRUE; enable_debugging = TRUE; } else if (strcmp (argv [i], "--security") == 0) { fprintf (stderr, "error: --security is obsolete."); @@ -2386,11 +2380,11 @@ mono_main (int argc, char* argv[]) fprintf (stderr, "error: --security=cas is obsolete."); return 1; } else if (strcmp (argv [i] + 11, "validil") == 0) { - fprintf (stderr, "error: --security=validil is obsolete."); - return 1; + fprintf (stderr, "error: --security=validil is obsolete."); + return 1; } else if (strcmp (argv [i] + 11, "verifiable") == 0) { - fprintf (stderr, "error: --securty=verifiable is obsolete."); - return 1; + fprintf (stderr, "error: --securty=verifiable is obsolete."); + return 1; } else { fprintf (stderr, "error: --security= option has invalid argument (cas, core-clr, verifiable or validil)\n"); return 1; @@ -2517,13 +2511,13 @@ mono_main (int argc, char* argv[]) enable_debugging = TRUE; #ifdef MONO_CROSS_COMPILE - if (!mono_compile_aot) { - fprintf (stderr, "This mono runtime is compiled for cross-compiling. Only the --aot option is supported.\n"); - exit (1); - } + if (!mono_compile_aot) { + fprintf (stderr, "This mono runtime is compiled for cross-compiling. Only the --aot option is supported.\n"); + exit (1); + } #if TARGET_SIZEOF_VOID_P == 4 && (defined(TARGET_ARM64) || defined(TARGET_AMD64)) && !defined(MONO_ARCH_ILP32) - fprintf (stderr, "Can't cross-compile on 32-bit platforms to 64-bit architecture.\n"); - exit (1); + fprintf (stderr, "Can't cross-compile on 32-bit platforms to 64-bit architecture.\n"); + exit (1); #endif #endif @@ -2576,10 +2570,8 @@ mono_main (int argc, char* argv[]) mono_gc_set_stack_end (&domain); if (agents) { - int i; - - for (i = 0; i < agents->len; ++i) { - int res = load_agent (domain, (char*)g_ptr_array_index (agents, i)); + for (guint agent_idx = 0; agent_idx < agents->len; ++agent_idx) { + int res = load_agent (domain, (char*)g_ptr_array_index (agents, agent_idx)); if (res) { g_ptr_array_free (agents, TRUE); mini_cleanup (domain); @@ -2650,13 +2642,13 @@ mono_main (int argc, char* argv[]) mono_callspec_set_assembly (assembly); if (mono_compile_aot || action == DO_EXEC) { - const char *error; + const char *version_error; //mono_set_rootdir (); - error = mono_check_corlib_version (); - if (error) { - fprintf (stderr, "Corlib not in sync with this runtime: %s\n", error); + version_error = mono_check_corlib_version (); + if (version_error) { + fprintf (stderr, "Corlib not in sync with this runtime: %s\n", version_error); fprintf (stderr, "Loaded from: %s\n", mono_defaults.corlib? mono_image_get_filename (mono_defaults.corlib): "unknown"); fprintf (stderr, "Download a newer corlib or a newer runtime at http://www.mono-project.com/download.\n"); diff --git a/src/mono/mono/mini/dwarfwriter.c b/src/mono/mono/mini/dwarfwriter.c index d7af4c7b9e3d0..4ed10e903787f 100644 --- a/src/mono/mono/mini/dwarfwriter.c +++ b/src/mono/mono/mini/dwarfwriter.c @@ -925,7 +925,7 @@ static char* emit_class_dwarf_info (MonoDwarfWriter *w, MonoClass *klass, gboolean vtype) { char *die, *pointer_die, *reference_die; - char *full_name, *p; + char *full_name; gpointer iter; MonoClassField *field; const char *fdie; @@ -963,7 +963,7 @@ emit_class_dwarf_info (MonoDwarfWriter *w, MonoClass *klass, gboolean vtype) * gdb doesn't support namespaces for non-C++ dwarf objects, so use _ * to separate components. */ - for (p = full_name; *p; p ++) + for (char *p = full_name; *p; p ++) if (*p == '.') *p = '_'; @@ -1338,10 +1338,10 @@ token_handler (MonoDisHelper *dh, MonoMethod *method, guint32 token) if (method->wrapper_type) { cmethod = (MonoMethod *)data; } else { - ERROR_DECL (error); cmethod = mono_get_method_checked (m_class_get_image (method->klass), token, NULL, NULL, error); if (!cmethod) g_error ("Could not load method due to %s", mono_error_get_message (error)); /* FIXME don't swallow the error */ + mono_error_assert_ok (error); } desc = mono_method_full_name (cmethod, TRUE); res = g_strdup_printf ("<%s>", desc); @@ -1657,7 +1657,6 @@ emit_line_number_info (MonoDwarfWriter *w, MonoMethod *method, /* No debug info, XDEBUG mode */ char *name, *dis; const guint8 *ip = header->code; - int prev_line, prev_native_offset; int *il_to_line; /* @@ -1680,7 +1679,7 @@ emit_line_number_info (MonoDwarfWriter *w, MonoMethod *method, // FIXME: Optimize this while (ip < header->code + header->code_size) { - int il_offset = ip - header->code; + il_offset = ip - header->code; /* Emit IL */ w->il_file_line_index ++; diff --git a/src/mono/mono/mini/exceptions-amd64.c b/src/mono/mono/mini/exceptions-amd64.c index b6bf26db8c790..bbe4272e65bc5 100644 --- a/src/mono/mono/mini/exceptions-amd64.c +++ b/src/mono/mono/mini/exceptions-amd64.c @@ -69,6 +69,8 @@ static LONG CALLBACK seh_unhandled_exception_filter(EXCEPTION_POINTERS* ep) return EXCEPTION_CONTINUE_SEARCH; } +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ + #if HAVE_API_SUPPORT_WIN32_RESET_STKOFLW static gpointer get_win32_restore_stack (void) @@ -124,6 +126,8 @@ get_win32_restore_stack (void) } #endif /* HAVE_API_SUPPORT_WIN32_RESET_STKOFLW */ +MONO_RESTORE_WARNING + /* * Unhandled Exception Filter * Top-level per-process exception handler. @@ -230,6 +234,8 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler) #endif /* TARGET_WIN32 */ #ifndef DISABLE_JIT + +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ /* * mono_arch_get_restore_context: * @@ -372,6 +378,9 @@ mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot) return start; } + +MONO_RESTORE_WARNING + #endif /* !DISABLE_JIT */ /* @@ -441,6 +450,9 @@ mono_amd64_resume_unwind (guint64 dummy1, guint64 dummy2, guint64 dummy3, guint6 } #ifndef DISABLE_JIT + +MONO_DISABLE_WARNING(4127) + /* * get_throw_trampoline: * @@ -562,6 +574,8 @@ get_throw_trampoline (MonoTrampInfo **info, gboolean rethrow, gboolean corlib, g return start; } +MONO_RESTORE_WARNING + /** * mono_arch_get_throw_exception: * \returns a function pointer which can be used to raise diff --git a/src/mono/mono/mini/exceptions-arm.c b/src/mono/mono/mini/exceptions-arm.c index afa4a5f976c14..cf81f5ae16b62 100644 --- a/src/mono/mono/mini/exceptions-arm.c +++ b/src/mono/mono/mini/exceptions-arm.c @@ -243,7 +243,7 @@ get_throw_trampoline (int size, gboolean corlib, gboolean rethrow, gboolean llvm /* Save fp regs */ if (!mono_arch_is_soft_float ()) { - ARM_SUB_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, sizeof (double) * 16); + ARM_SUB_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, (guint32)(sizeof (double) * 16)); cfa_offset += sizeof (double) * 16; mono_add_unwind_op_def_cfa_offset (unwind_ops, code, start, cfa_offset); ARM_FSTMD (code, ARM_VFP_D0, 16, ARMREG_SP); diff --git a/src/mono/mono/mini/exceptions-x86.c b/src/mono/mono/mini/exceptions-x86.c index db6a76e5e06ed..0cfcaa553bde4 100644 --- a/src/mono/mono/mini/exceptions-x86.c +++ b/src/mono/mono/mini/exceptions-x86.c @@ -34,6 +34,8 @@ #include "aot-runtime.h" #include "mono/utils/mono-tls-inline.h" +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ + static gpointer signal_exception_trampoline; gpointer diff --git a/src/mono/mono/mini/helpers.c b/src/mono/mono/mini/helpers.c index a9e36445885a8..dd801c1da961f 100644 --- a/src/mono/mono/mini/helpers.c +++ b/src/mono/mono/mini/helpers.c @@ -149,6 +149,8 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id) } fprintf (ofd, ":\n"); +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ + if (emit_debug_info && cfg != NULL) { MonoBasicBlock *bb; @@ -183,6 +185,8 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id) fprintf (ofd, "\n"); fclose (ofd); +MONO_RESTORE_WARNING + #ifdef __APPLE__ #ifdef __ppc64__ #define DIS_CMD "otool64 -v -t" diff --git a/src/mono/mono/mini/interp/interp.c b/src/mono/mono/mini/interp/interp.c index f2f02f5fb2bff..768377c5bcd7b 100644 --- a/src/mono/mono/mini/interp/interp.c +++ b/src/mono/mono/mini/interp/interp.c @@ -3516,7 +3516,6 @@ static MONO_NEVER_INLINE void interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs *clause_args) { InterpMethod *cmethod; - MonoException *ex; ERROR_DECL(error); /* Interpreter main loop state (InterpState) */ @@ -3553,14 +3552,14 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs * can be reserved here. */ MonoObjectHandle tmp_handle = MONO_HANDLE_NEW (MonoObject, NULL); - + MonoException *method_entry_ex; if (method_entry (context, frame, #if DEBUG_INTERP &tracing, #endif - &ex)) { - if (ex) - THROW_EX (ex, NULL); + &method_entry_ex)) { + if (method_entry_ex) + THROW_EX (method_entry_ex, NULL); EXCEPTION_CHECKPOINT; } @@ -3725,9 +3724,9 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs MONO_PROFILER_RAISE (method_tail_call, (frame->imethod->method, new_method->method)); if (!new_method->transformed) { - MonoException *ex = do_transform_method (new_method, frame, context); - if (ex) - THROW_EX (ex, ip); + MonoException *transform_ex = do_transform_method (new_method, frame, context); + if (transform_ex) + THROW_EX (transform_ex, ip); EXCEPTION_CHECKPOINT; } /* @@ -3838,7 +3837,7 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs } MINT_IN_CASE(MINT_CALLI_NAT_FAST) { MonoMethodSignature *csignature = (MonoMethodSignature*)frame->imethod->data_items [ip [4]]; - int opcode = ip [5]; + int icall_opcode = ip [5]; gboolean save_last_error = ip [6]; stackval *ret = (stackval*)(locals + ip [1]); @@ -3847,7 +3846,7 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs /* for calls, have ip pointing at the start of next instruction */ frame->state.ip = ip + 7; - do_icall_wrapper (frame, csignature, opcode, ret, args, target_ip, save_last_error, &gc_transitions); + do_icall_wrapper (frame, csignature, icall_opcode , ret, args, target_ip, save_last_error, &gc_transitions); EXCEPTION_CHECKPOINT; CHECK_RESUME_STATE (context); ip += 7; @@ -3929,8 +3928,8 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs error_init_reuse (error); do_jit_call (context, (stackval*)(locals + return_offset), (stackval*)(locals + call_args_offset), frame, cmethod, error); if (!is_ok (error)) { - MonoException *ex = interp_error_convert_to_exception (frame, error, ip); - THROW_EX (ex, ip); + MonoException *call_ex = interp_error_convert_to_exception (frame, error, ip); + THROW_EX (call_ex, ip); } CHECK_RESUME_STATE (context); @@ -4000,13 +3999,15 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs reinit_frame (child_frame, frame, cmethod, locals + return_offset, locals + call_args_offset); frame = child_frame; } + + MonoException *call_ex; if (method_entry (context, frame, #if DEBUG_INTERP &tracing, #endif - &ex)) { - if (ex) - THROW_EX (ex, NULL); + &call_ex)) { + if (call_ex) + THROW_EX (call_ex, NULL); EXCEPTION_CHECKPOINT; } @@ -4030,8 +4031,8 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs frame->state.ip = ip + 4; do_jit_call (context, (stackval*)(locals + ip [1]), (stackval*)(locals + ip [2]), frame, rmethod, error); if (!is_ok (error)) { - MonoException *ex = interp_error_convert_to_exception (frame, error, ip); - THROW_EX (ex, ip); + MonoException *call_ex = interp_error_convert_to_exception (frame, error, ip); + THROW_EX (call_ex, ip); } CHECK_RESUME_STATE (context); @@ -4048,8 +4049,8 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs frame->state.ip = ip + 6; do_jit_call (context, (stackval*)(locals + ip [1]), frame, rmethod, error); if (!is_ok (error)) { - MonoException *ex = interp_error_convert_to_exception (frame, error); - THROW_EX (ex, ip); + MonoException *call_ex = interp_error_convert_to_exception (frame, error); + THROW_EX (call_ex, ip); } CHECK_RESUME_STATE (context); @@ -4664,6 +4665,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_BREAK; } #define LDIND(datatype,casttype,unaligned) do { \ + MONO_DISABLE_WARNING(4127) \ gpointer ptr = LOCAL_VAR (ip [2], gpointer); \ NULL_CHECK (ptr); \ if (unaligned && ((gsize)ptr % SIZEOF_VOID_P)) \ @@ -4671,6 +4673,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; else \ LOCAL_VAR (ip [1], datatype) = *(casttype*)ptr; \ ip += 3; \ + MONO_RESTORE_WARNING \ } while (0) MINT_IN_CASE(MINT_LDIND_I1) LDIND(int, gint8, FALSE); @@ -4707,6 +4710,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_BREAK; #define LDIND_OFFSET(datatype,casttype,unaligned) do { \ + MONO_DISABLE_WARNING(4127) \ gpointer ptr = LOCAL_VAR (ip [2], gpointer); \ NULL_CHECK (ptr); \ ptr = (char*)ptr + LOCAL_VAR (ip [3], mono_i); \ @@ -4715,6 +4719,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; else \ LOCAL_VAR (ip [1], datatype) = *(casttype*)ptr; \ ip += 4; \ + MONO_RESTORE_WARNING \ } while (0) MINT_IN_CASE(MINT_LDIND_OFFSET_I1) LDIND_OFFSET(int, gint8, FALSE); @@ -4740,6 +4745,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_BREAK; #define LDIND_OFFSET_IMM(datatype,casttype,unaligned) do { \ + MONO_DISABLE_WARNING(4127) \ gpointer ptr = LOCAL_VAR (ip [2], gpointer); \ NULL_CHECK (ptr); \ ptr = (char*)ptr + (gint16)ip [3]; \ @@ -4748,6 +4754,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; else \ LOCAL_VAR (ip [1], datatype) = *(casttype*)ptr; \ ip += 4; \ + MONO_RESTORE_WARNING \ } while (0) MINT_IN_CASE(MINT_LDIND_OFFSET_IMM_I1) LDIND_OFFSET_IMM(int, gint8, FALSE); @@ -4779,6 +4786,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_BREAK; } #define STIND(datatype,unaligned) do { \ + MONO_DISABLE_WARNING(4127) \ gpointer ptr = LOCAL_VAR (ip [1], gpointer); \ NULL_CHECK (ptr); \ if (unaligned && ((gsize)ptr % SIZEOF_VOID_P)) \ @@ -4786,6 +4794,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; else \ *(datatype*)ptr = LOCAL_VAR (ip [2], datatype); \ ip += 3; \ + MONO_RESTORE_WARNING \ } while (0) MINT_IN_CASE(MINT_STIND_I1) STIND(gint8, FALSE); @@ -4815,6 +4824,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_BREAK; #define STIND_OFFSET(datatype,unaligned) do { \ + MONO_DISABLE_WARNING(4127) \ gpointer ptr = LOCAL_VAR (ip [1], gpointer); \ NULL_CHECK (ptr); \ ptr = (char*)ptr + LOCAL_VAR (ip [2], mono_i); \ @@ -4823,6 +4833,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; else \ *(datatype*)ptr = LOCAL_VAR (ip [3], datatype); \ ip += 4; \ + MONO_RESTORE_WARNING \ } while (0) MINT_IN_CASE(MINT_STIND_OFFSET_I1) STIND_OFFSET(gint8, FALSE); @@ -4842,6 +4853,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_BREAK; #define STIND_OFFSET_IMM(datatype,unaligned) do { \ + MONO_DISABLE_WARNING(4127) \ gpointer ptr = LOCAL_VAR (ip [1], gpointer); \ NULL_CHECK (ptr); \ ptr = (char*)ptr + (gint16)ip [3]; \ @@ -4850,6 +4862,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; else \ *(datatype*)ptr = LOCAL_VAR (ip [2], datatype); \ ip += 4; \ + MONO_RESTORE_WARNING \ } while (0) MINT_IN_CASE(MINT_STIND_OFFSET_IMM_I1) STIND_OFFSET_IMM(gint8, FALSE); @@ -5605,11 +5618,11 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_BREAK; } MINT_IN_CASE(MINT_THROW) { - MonoException *ex = LOCAL_VAR (ip [1], MonoException*); - if (!ex) - ex = interp_get_exception_null_reference (frame, ip); + MonoException *local_ex = LOCAL_VAR (ip [1], MonoException*); + if (!local_ex) + local_ex = interp_get_exception_null_reference (frame, ip); - THROW_EX (ex, ip); + THROW_EX (local_ex, ip); MINT_IN_BREAK; } MINT_IN_CASE(MINT_SAFEPOINT) @@ -6049,9 +6062,9 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; NULL_CHECK (o); MonoClass *klass = (MonoClass*)frame->imethod->data_items [ip [3]]; - MonoException *ex = ves_array_element_address (frame, klass, (MonoArray *) o, (gpointer*)(locals + ip [1]), sp + 1, TRUE); - if (ex) - THROW_EX (ex, ip); + MonoException *address_ex = ves_array_element_address (frame, klass, (MonoArray *) o, (gpointer*)(locals + ip [1]), sp + 1, TRUE); + if (address_ex) + THROW_EX (address_ex, ip); ip += 4; MINT_IN_BREAK; } @@ -6580,8 +6593,8 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_CASE(MINT_LEAVE_S) MINT_IN_CASE(MINT_LEAVE_CHECK) MINT_IN_CASE(MINT_LEAVE_S_CHECK) { - int opcode = *ip; - gboolean const check = opcode == MINT_LEAVE_CHECK || opcode == MINT_LEAVE_S_CHECK; + int leave_opcode = *ip; + gboolean const check = leave_opcode == MINT_LEAVE_CHECK || leave_opcode == MINT_LEAVE_S_CHECK; if (check && frame->imethod->method->wrapper_type != MONO_WRAPPER_RUNTIME_INVOKE) { MonoException *abort_exc = mono_interp_leave (frame); @@ -6589,7 +6602,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; THROW_EX (abort_exc, ip); } - gboolean const short_offset = opcode == MINT_LEAVE_S || opcode == MINT_LEAVE_S_CHECK; + gboolean const short_offset = leave_opcode == MINT_LEAVE_S || leave_opcode == MINT_LEAVE_S_CHECK; ip += short_offset ? (gint16)*(ip + 1) : (gint32)READ32 (ip + 1); MINT_IN_BREAK; } @@ -6891,16 +6904,16 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; MINT_IN_CASE(MINT_LDFTN_DYNAMIC) { error_init_reuse (error); - MonoMethod *cmethod = LOCAL_VAR (ip [2], MonoMethod*); + MonoMethod *local_cmethod = LOCAL_VAR (ip [2], MonoMethod*); // FIXME push/pop LMF - if (G_UNLIKELY (mono_method_has_unmanaged_callers_only_attribute (cmethod))) { - cmethod = mono_marshal_get_managed_wrapper (cmethod, NULL, (MonoGCHandle)0, error); + if (G_UNLIKELY (mono_method_has_unmanaged_callers_only_attribute (local_cmethod))) { + local_cmethod = mono_marshal_get_managed_wrapper (local_cmethod, NULL, (MonoGCHandle)0, error); mono_error_assert_ok (error); - gpointer addr = mini_get_interp_callbacks ()->create_method_pointer (cmethod, TRUE, error); + gpointer addr = mini_get_interp_callbacks ()->create_method_pointer (local_cmethod, TRUE, error); LOCAL_VAR (ip [1], gpointer) = addr; } else { - InterpMethod *m = mono_interp_get_imethod (cmethod, error); + InterpMethod *m = mono_interp_get_imethod (local_cmethod, error); mono_error_assert_ok (error); LOCAL_VAR (ip [1], gpointer) = imethod_to_ftnptr (m, FALSE); } diff --git a/src/mono/mono/mini/interp/transform.c b/src/mono/mono/mini/interp/transform.c index 5c46d63880c8c..046aa948e91e3 100644 --- a/src/mono/mono/mini/interp/transform.c +++ b/src/mono/mono/mini/interp/transform.c @@ -1702,7 +1702,7 @@ static void interp_emit_ldobj (TransformData *td, MonoClass *klass) { int mt = mint_type (m_class_get_byval_arg (klass)); - gint32 size; + gint32 size = 0; td->sp--; if (mt == MINT_TYPE_VT) { @@ -3585,10 +3585,10 @@ recursively_make_pred_seq_points (TransformData *td, InterpBasicBlock *bb) recursively_make_pred_seq_points (td, in_bb); // Union sequence points with incoming bb's - for (int i=0; i < in_bb->num_pred_seq_points; i++) { - if (!g_hash_table_lookup (seen, in_bb->pred_seq_points [i])) { - g_array_append_val (predecessors, in_bb->pred_seq_points [i]); - g_hash_table_insert (seen, in_bb->pred_seq_points [i], (gpointer)&MONO_SEQ_SEEN_LOOP); + for (guint j = 0; j < in_bb->num_pred_seq_points; j++) { + if (!g_hash_table_lookup (seen, in_bb->pred_seq_points [j])) { + g_array_append_val (predecessors, in_bb->pred_seq_points [j]); + g_hash_table_insert (seen, in_bb->pred_seq_points [j], (gpointer)&MONO_SEQ_SEEN_LOOP); } } // predecessors = g_array_append_vals (predecessors, in_bb->pred_seq_points, in_bb->num_pred_seq_points); @@ -3600,7 +3600,7 @@ recursively_make_pred_seq_points (TransformData *td, InterpBasicBlock *bb) bb->pred_seq_points = (SeqPoint**)mono_mempool_alloc0 (td->mempool, sizeof (SeqPoint *) * predecessors->len); bb->num_pred_seq_points = predecessors->len; - for (int newer = 0; newer < bb->num_pred_seq_points; newer++) { + for (guint newer = 0; newer < bb->num_pred_seq_points; newer++) { bb->pred_seq_points [newer] = (SeqPoint*)g_array_index (predecessors, gpointer, newer); } } @@ -3615,7 +3615,7 @@ collect_pred_seq_points (TransformData *td, InterpBasicBlock *bb, SeqPoint *seqp if (bb->pred_seq_points == NULL && bb != td->entry_bb) recursively_make_pred_seq_points (td, bb); - for (int i = 0; i < bb->num_pred_seq_points; i++) + for (guint i = 0; i < bb->num_pred_seq_points; i++) insert_pred_seq_point (bb->pred_seq_points [i], seqp, next); return; @@ -4070,7 +4070,7 @@ initialize_clause_bblocks (TransformData *td) MonoExceptionClause *c = header->clauses + i; InterpBasicBlock *bb; - for (int j = c->handler_offset; j < c->handler_offset + c->handler_len; j++) { + for (uint32_t j = c->handler_offset; j < c->handler_offset + c->handler_len; j++) { if (td->clause_indexes [j] == -1) td->clause_indexes [j] = i; } @@ -4176,7 +4176,7 @@ handle_stelem (TransformData *td, int op) static gboolean is_ip_protected (MonoMethodHeader *header, int offset) { - for (int i = 0; i < header->num_clauses; i++) { + for (unsigned int i = 0; i < header->num_clauses; i++) { MonoExceptionClause *clause = &header->clauses [i]; if (clause->try_offset <= offset && offset < (clause->try_offset + clause->try_len)) return TRUE; @@ -4188,7 +4188,7 @@ static gboolean generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, MonoGenericContext *generic_context, MonoError *error) { int target; - int offset, mt, i, i32; + int mt, i32; guint32 token; int in_offset; const unsigned char *end; @@ -4251,14 +4251,14 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, if (minfo) { MonoSymSeqPoint *sps; - int i, n_il_offsets; + int n_il_offsets; mono_debug_get_seq_points (minfo, NULL, NULL, NULL, &sps, &n_il_offsets); // FIXME: Free seq_point_locs = mono_bitset_mem_new (mono_mempool_alloc0 (td->mempool, mono_bitset_alloc_size (header->code_size, 0)), header->code_size, 0); sym_seq_points = TRUE; - for (i = 0; i < n_il_offsets; ++i) { + for (int i = 0; i < n_il_offsets; ++i) { if (sps [i].il_offset < header->code_size) mono_bitset_set_fast (seq_point_locs, sps [i].il_offset); } @@ -4266,7 +4266,7 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, MonoDebugMethodAsyncInfo* asyncMethod = mono_debug_lookup_method_async_debug_info (method); if (asyncMethod) { - for (i = 0; asyncMethod != NULL && i < asyncMethod->num_awaits; i++) { + for (int i = 0; asyncMethod != NULL && i < asyncMethod->num_awaits; i++) { mono_bitset_set_fast (seq_point_locs, asyncMethod->resume_offsets [i]); mono_bitset_set_fast (seq_point_locs, asyncMethod->yield_offsets [i]); } @@ -4354,7 +4354,7 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, int local; arg_locals = (guint32*) g_malloc ((!!signature->hasthis + signature->param_count) * sizeof (guint32)); /* Allocate locals to store inlined method args from stack */ - for (i = signature->param_count - 1; i >= 0; i--) { + for (int i = signature->param_count - 1; i >= 0; i--) { local = create_interp_local (td, signature->params [i]); arg_locals [i + !!signature->hasthis] = local; store_local (td, local); @@ -4377,7 +4377,7 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, local_locals = (guint32*) g_malloc (header->num_locals * sizeof (guint32)); /* Allocate locals to store inlined method args from stack */ - for (i = 0; i < header->num_locals; i++) + for (int i = 0; i < header->num_locals; i++) local_locals [i] = create_interp_local (td, header->locals [i]); } @@ -4673,8 +4673,8 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, } case CEE_DUP: { int type = td->sp [-1].type; - MonoClass *klass = td->sp [-1].klass; - int mt = td->locals [td->sp [-1].local].mt; + klass = td->sp [-1].klass; + mt = td->locals [td->sp [-1].local].mt; if (mt == MINT_TYPE_VT) { gint32 size = mono_class_value_size (klass, NULL); g_assert (size < G_MAXUINT16); @@ -4772,10 +4772,8 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, int vt_size = 0; if (ult->type != MONO_TYPE_VOID) { --td->sp; - if (mint_type (ult) == MINT_TYPE_VT) { - MonoClass *klass = mono_class_from_mono_type_internal (ult); - vt_size = mono_class_value_size (klass, NULL); - } + if (mint_type (ult) == MINT_TYPE_VT) + vt_size = mono_class_value_size (mono_class_from_mono_type_internal (ult), NULL); } if (td->sp > td->stack) { mono_error_set_generic_error (error, "System", "InvalidProgramException", ""); @@ -4945,8 +4943,8 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, --td->sp; interp_ins_set_sreg (td->last_ins, td->sp [0].local); InterpBasicBlock **target_bb_table = (InterpBasicBlock**)mono_mempool_alloc0 (td->mempool, sizeof (InterpBasicBlock*) * n); - for (i = 0; i < n; i++) { - offset = read32 (td->ip); + for (guint32 i = 0; i < n; i++) { + int offset = read32 (td->ip); target = next_ip - td->il_code + offset; InterpBasicBlock *target_bb = td->offset_to_bb [target]; g_assert (target_bb); @@ -5406,7 +5404,7 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, goto_if_nok (error, exit); if (m_class_is_valuetype (klass)) { - int mt = mint_type (m_class_get_byval_arg (klass)); + mt = mint_type (m_class_get_byval_arg (klass)); td->sp -= 2; interp_add_ins (td, (mt == MINT_TYPE_VT) ? MINT_CPOBJ_VT : MINT_CPOBJ); interp_ins_set_sregs2 (td->last_ins, td->sp [0].local, td->sp [1].local); @@ -5717,7 +5715,7 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, if ((td->last_ins->opcode == MINT_BOX || td->last_ins->opcode == MINT_BOX_VT) && (td->sp - 1)->klass == klass && td->last_ins == td->cbb->last_ins) { interp_clear_ins (td->last_ins); - int mt = mint_type (m_class_get_byval_arg (klass)); + mt = mint_type (m_class_get_byval_arg (klass)); td->sp--; // Push back the original value that was boxed. We should handle this in CEE_BOX instead if (mt == MINT_TYPE_VT) @@ -6351,8 +6349,8 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, break; case CEE_CKFINITE: { CHECK_STACK (td, 1); - int stack_type = td->sp [-1].type; - switch (stack_type) { + int ckfinite_stack_type = td->sp [-1].type; + switch (ckfinite_stack_type) { case STACK_TYPE_R4: interp_add_ins (td, MINT_CKFINITE_R4); break; case STACK_TYPE_R8: interp_add_ins (td, MINT_CKFINITE_R8); break; default: @@ -6360,7 +6358,7 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, } td->sp--; interp_ins_set_sreg (td->last_ins, td->sp [0].local); - push_simple_type (td, stack_type); + push_simple_type (td, ckfinite_stack_type); interp_ins_set_dreg (td->last_ins, td->sp [-1].local); ++td->ip; break; @@ -6708,7 +6706,7 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, td->sp = td->stack; - for (i = 0; i < header->num_clauses; ++i) { + for (unsigned int i = 0; i < header->num_clauses; ++i) { MonoExceptionClause *clause = &header->clauses [i]; if (clause->flags != MONO_EXCEPTION_CLAUSE_FINALLY) continue; @@ -6768,9 +6766,9 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, break; } case CEE_MONO_JIT_ICALL_ADDR: { - const guint32 token = read32 (td->ip + 1); + const guint32 icall_id_token = read32 (td->ip + 1); td->ip += 5; - const gconstpointer func = mono_find_jit_icall_info ((MonoJitICallId)token)->func; + const gconstpointer func = mono_find_jit_icall_info ((MonoJitICallId)icall_id_token)->func; interp_add_ins (td, MINT_LDFTN_ADDR); push_simple_type (td, STACK_TYPE_I); @@ -6791,7 +6789,7 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, call_args [i] = td->sp [i].local; call_args [info->sig->param_count] = -1; if (!MONO_TYPE_IS_VOID (info->sig->ret)) { - int mt = mint_type (info->sig->ret); + mt = mint_type (info->sig->ret); push_simple_type (td, stack_type [mt]); dreg = td->sp [-1].local; } @@ -6818,7 +6816,7 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, case CEE_MONO_VTADDR: { int size; CHECK_STACK (td, 1); - MonoClass *klass = td->sp [-1].klass; + klass = td->sp [-1].klass; if (method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE && !signature->marshalling_disabled) size = mono_class_native_size (klass, NULL); else @@ -7396,9 +7394,9 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, } if (sym_seq_points) { - for (InterpBasicBlock *bb = td->entry_bb->next_bb; bb != NULL; bb = bb->next_bb) { - if (bb->first_ins && bb->in_count > 1 && bb->first_ins->opcode == MINT_SDB_SEQ_POINT) - interp_insert_ins_bb (td, bb, NULL, MINT_SDB_INTR_LOC); + for (InterpBasicBlock *interp_bb = td->entry_bb->next_bb; interp_bb != NULL; interp_bb = interp_bb->next_bb) { + if (interp_bb->first_ins && interp_bb->in_count > 1 && interp_bb->first_ins->opcode == MINT_SDB_SEQ_POINT) + interp_insert_ins_bb (td, interp_bb, NULL, MINT_SDB_INTR_LOC); } } @@ -7418,7 +7416,7 @@ static void handle_relocations (TransformData *td) { // Handle relocations - for (int i = 0; i < td->relocs->len; ++i) { + for (guint i = 0; i < td->relocs->len; ++i) { Reloc *reloc = (Reloc*)g_ptr_array_index (td->relocs, i); int offset = reloc->target_bb->native_offset - reloc->offset; @@ -7767,7 +7765,7 @@ interp_local_deadce (TransformData *td) gboolean needs_dce = FALSE; gboolean needs_cprop = FALSE; - for (int i = 0; i < td->locals_size; i++) { + for (unsigned int i = 0; i < td->locals_size; i++) { g_assert (local_ref_count [i] >= 0); g_assert (td->locals [i].indirects >= 0); if (!local_ref_count [i] && @@ -8402,7 +8400,7 @@ interp_cprop (TransformData *td) ins = interp_fold_binop (td, local_defs, ins, &folded); if (!folded) { int sreg = -1; - int mov_op; + int mov_op = 0; if ((opcode == MINT_MUL_I4 || opcode == MINT_DIV_I4) && local_defs [ins->sregs [1]].type == LOCAL_VALUE_I4 && local_defs [ins->sregs [1]].i == 1) { @@ -9334,7 +9332,7 @@ interp_alloc_offsets (TransformData *td) // Iterate over all call args locals, update their final offset (aka add td->total_locals_size to them) // then also update td->total_locals_size to account for this space. td->param_area_offset = final_total_locals_size; - for (int i = 0; i < td->locals_size; i++) { + for (unsigned int i = 0; i < td->locals_size; i++) { // These are allocated separately at the end of the stack if (td->locals [i].flags & INTERP_LOCAL_FLAG_CALL_ARGS) { td->locals [i].offset += td->param_area_offset; diff --git a/src/mono/mono/mini/intrinsics.c b/src/mono/mono/mini/intrinsics.c index 8c36c07d80db1..25d89f2ddcfe4 100644 --- a/src/mono/mono/mini/intrinsics.c +++ b/src/mono/mono/mini/intrinsics.c @@ -393,7 +393,6 @@ static MonoInst* emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) { MonoInst *ins; - int dreg, align; MonoGenericContext *ctx = mono_method_get_context (cmethod); MonoType *t; @@ -403,7 +402,7 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu t = ctx->method_inst->type_argv [0]; if (ctx->method_inst->type_argc == 2) { - dreg = alloc_preg (cfg); + int dreg = alloc_preg (cfg); EMIT_NEW_UNALU (cfg, ins, OP_MOVE, dreg, args [0]->dreg); ins->type = STACK_OBJ; ins->klass = mono_get_object_class (); @@ -414,7 +413,7 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu // Casts the given object to the specified type, performs no dynamic type checking. g_assert (fsig->param_count == 1); g_assert (fsig->params [0]->type == MONO_TYPE_OBJECT); - dreg = alloc_preg (cfg); + int dreg = alloc_preg (cfg); EMIT_NEW_UNALU (cfg, ins, OP_MOVE, dreg, args [0]->dreg); ins->type = STACK_OBJ; ins->klass = mono_class_from_mono_type_internal (ctx->method_inst->type_argv [0]); @@ -426,7 +425,7 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu g_assert (ctx->method_inst->type_argc == 1); g_assert (fsig->param_count == 1); - dreg = alloc_preg (cfg); + int dreg = alloc_preg (cfg); EMIT_NEW_UNALU (cfg, ins, OP_MOVE, dreg, args [0]->dreg); ins->type = STACK_PTR; return ins; @@ -436,7 +435,7 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu g_assert (ctx->method_inst->type_argc == 1); g_assert (fsig->param_count == 1); - dreg = alloc_preg (cfg); + int dreg = alloc_preg (cfg); EMIT_NEW_UNALU (cfg, ins, OP_MOVE, dreg, args [0]->dreg); ins->type = STACK_OBJ; ins->klass = mono_get_object_class (); @@ -447,7 +446,7 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu g_assert (ctx->method_inst->type_argc == 1); g_assert (fsig->param_count == 2); - dreg = alloc_ireg (cfg); + int dreg = alloc_ireg (cfg); EMIT_NEW_BIALU (cfg, ins, OP_COMPARE, -1, args [0]->dreg, args [1]->dreg); EMIT_NEW_UNALU (cfg, ins, OP_PCEQ, dreg, -1); return ins; @@ -457,7 +456,7 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu g_assert (ctx->method_inst->type_argc == 1); g_assert (fsig->param_count == 2); - dreg = alloc_ireg (cfg); + int dreg = alloc_ireg (cfg); EMIT_NEW_BIALU (cfg, ins, OP_COMPARE, -1, args [0]->dreg, args [1]->dreg); EMIT_NEW_UNALU (cfg, ins, OP_PCLT_UN, dreg, -1); return ins; @@ -467,7 +466,7 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu g_assert (ctx->method_inst->type_argc == 1); g_assert (fsig->param_count == 2); - dreg = alloc_ireg (cfg); + int dreg = alloc_ireg (cfg); EMIT_NEW_BIALU (cfg, ins, OP_COMPARE, -1, args [0]->dreg, args [1]->dreg); EMIT_NEW_UNALU (cfg, ins, OP_PCGT_UN, dreg, -1); return ins; @@ -483,8 +482,10 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu MonoInst *esize_ins; if (mini_is_gsharedvt_variable_type (t)) { esize_ins = mini_emit_get_gsharedvt_info_klass (cfg, mono_class_from_mono_type_internal (t), MONO_RGCTX_INFO_CLASS_SIZEOF); +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ if (SIZEOF_REGISTER == 8) MONO_EMIT_NEW_UNALU (cfg, OP_SEXT_I4, esize_ins->dreg, esize_ins->dreg); +MONO_RESTORE_WARNING } else { t = mini_type_get_underlying_type (t); int esize = mono_class_array_element_size (mono_class_from_mono_type_internal (t)); @@ -495,7 +496,7 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu EMIT_NEW_BIALU (cfg, ins, OP_PMUL, mul_reg, args [1]->dreg, esize_ins->dreg); ins->type = STACK_PTR; - dreg = alloc_preg (cfg); + int dreg = alloc_preg (cfg); EMIT_NEW_BIALU (cfg, ins, OP_PADD, dreg, args [0]->dreg, mul_reg); ins->type = STACK_PTR; return ins; @@ -512,10 +513,12 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu return ins; } else if (fsig->params [1]->type == MONO_TYPE_U8) { int sreg = args [1]->dreg; +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ if (SIZEOF_REGISTER == 4) { sreg = alloc_ireg (cfg); EMIT_NEW_UNALU (cfg, ins, OP_LCONV_TO_U4, sreg, args [1]->dreg); } +MONO_RESTORE_WARNING int dreg = alloc_preg (cfg); EMIT_NEW_BIALU (cfg, ins, OP_PADD, dreg, args [0]->dreg, sreg); ins->type = STACK_PTR; @@ -531,6 +534,7 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu if (mini_is_gsharedvt_variable_type (t)) { ins = mini_emit_get_gsharedvt_info_klass (cfg, mono_class_from_mono_type_internal (t), MONO_RGCTX_INFO_CLASS_SIZEOF); } else { + int align; int esize = mono_type_size (t, &align); EMIT_NEW_ICONST (cfg, ins, esize); } @@ -1311,7 +1315,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign } else if (strcmp (cmethod->name, "Exchange") == 0 && fsig->param_count == 2 && m_type_is_byref (fsig->params [0])) { MonoInst *f2i = NULL, *i2f; - guint32 opcode, f2i_opcode, i2f_opcode; + guint32 opcode, f2i_opcode = 0, i2f_opcode = 0; gboolean is_ref = byref_arg_is_reference (fsig->params [0]); gboolean is_float = fsig->params [0]->type == MONO_TYPE_R4 || fsig->params [0]->type == MONO_TYPE_R8; @@ -1407,7 +1411,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign } else if ((strcmp (cmethod->name, "CompareExchange") == 0) && fsig->param_count == 3) { MonoInst *f2i_new = NULL, *f2i_cmp = NULL, *i2f; - guint32 opcode, f2i_opcode, i2f_opcode; + guint32 opcode, f2i_opcode = 0, i2f_opcode = 0; gboolean is_ref = mini_type_is_reference (fsig->params [1]); gboolean is_float = fsig->params [1]->type == MONO_TYPE_R4 || fsig->params [1]->type == MONO_TYPE_R8; diff --git a/src/mono/mono/mini/ir-emit.h b/src/mono/mono/mini/ir-emit.h index a36efe38fbb43..b62a71d36c1c3 100644 --- a/src/mono/mono/mini/ir-emit.h +++ b/src/mono/mono/mini/ir-emit.h @@ -151,147 +151,147 @@ alloc_dreg (MonoCompile *cfg, MonoStackType stack_type) * from the memory pool associated with the MonoConfig, but it is not linked anywhere. * the cil_code is set to the cfg->ip address. */ -#define MONO_INST_NEW(cfg,dest,op) do { \ - (dest) = (MonoInst *)mono_mempool_alloc ((cfg)->mempool, sizeof (MonoInst)); \ +#define MONO_INST_NEW(cfg,dest,op) do { \ + (dest) = (MonoInst *)mono_mempool_alloc ((cfg)->mempool, sizeof (MonoInst)); \ (dest)->inst_i0 = (dest)->inst_i1 = 0; \ - (dest)->next = (dest)->prev = NULL; \ - (dest)->opcode = (op); \ - (dest)->flags = 0; \ - (dest)->type = 0; \ - (dest)->dreg = -1; \ - MONO_INST_NULLIFY_SREGS ((dest)); \ - (dest)->cil_code = (cfg)->ip; \ + (dest)->next = (dest)->prev = NULL; \ + (dest)->opcode = (op); \ + (dest)->flags = 0; \ + (dest)->type = 0; \ + (dest)->dreg = -1; \ + MONO_INST_NULLIFY_SREGS ((dest)); \ + (dest)->cil_code = (cfg)->ip; \ } while (0) /* * Variants which take a dest argument and don't do an emit */ -#define NEW_ICONST(cfg,dest,val) do { \ - MONO_INST_NEW ((cfg), (dest), OP_ICONST); \ - (dest)->inst_c0 = (val); \ - (dest)->type = STACK_I4; \ - (dest)->dreg = alloc_dreg ((cfg), STACK_I4); \ +#define NEW_ICONST(cfg,dest,val) do { \ + MONO_INST_NEW ((cfg), (dest), OP_ICONST); \ + (dest)->inst_c0 = (val); \ + (dest)->type = STACK_I4; \ + (dest)->dreg = alloc_dreg ((cfg), STACK_I4); \ } while (0) /* * Avoid using this with a non-NULL val if possible as it is not AOT * compatible. Use one of the NEW_xxxCONST variants instead. */ -#define NEW_PCONST(cfg,dest,val) do { \ - MONO_INST_NEW ((cfg), (dest), OP_PCONST); \ - (dest)->inst_p0 = (val); \ - (dest)->type = STACK_PTR; \ - (dest)->dreg = alloc_dreg ((cfg), STACK_PTR); \ +#define NEW_PCONST(cfg,dest,val) do { \ + MONO_INST_NEW ((cfg), (dest), OP_PCONST); \ + (dest)->inst_p0 = (val); \ + (dest)->type = STACK_PTR; \ + (dest)->dreg = alloc_dreg ((cfg), STACK_PTR); \ } while (0) -#define NEW_I8CONST(cfg,dest,val) do { \ - MONO_INST_NEW ((cfg), (dest), OP_I8CONST); \ - (dest)->dreg = alloc_lreg ((cfg)); \ - (dest)->type = STACK_I8; \ - (dest)->inst_l = (val); \ +#define NEW_I8CONST(cfg,dest,val) do { \ + MONO_INST_NEW ((cfg), (dest), OP_I8CONST); \ + (dest)->dreg = alloc_lreg ((cfg)); \ + (dest)->type = STACK_I8; \ + (dest)->inst_l = (val); \ } while (0) #define NEW_STORE_MEMBASE(cfg,dest,op,base,offset,sr) do { \ - MONO_INST_NEW ((cfg), (dest), (op)); \ - (dest)->sreg1 = sr; \ - (dest)->inst_destbasereg = base; \ - (dest)->inst_offset = offset; \ + MONO_INST_NEW ((cfg), (dest), (op)); \ + (dest)->sreg1 = sr; \ + (dest)->inst_destbasereg = base; \ + (dest)->inst_offset = offset; \ } while (0) #define NEW_LOAD_MEMBASE(cfg,dest,op,dr,base,offset) do { \ - MONO_INST_NEW ((cfg), (dest), (op)); \ - (dest)->dreg = (dr); \ - (dest)->inst_basereg = (base); \ - (dest)->inst_offset = (offset); \ - (dest)->type = STACK_I4; \ + MONO_INST_NEW ((cfg), (dest), (op)); \ + (dest)->dreg = (dr); \ + (dest)->inst_basereg = (base); \ + (dest)->inst_offset = (offset); \ + (dest)->type = STACK_I4; \ } while (0) #define NEW_LOAD_MEM(cfg,dest,op,dr,mem) do { \ - MONO_INST_NEW ((cfg), (dest), (op)); \ - (dest)->dreg = (dr); \ - (dest)->inst_p0 = (gpointer)(gssize)(mem); \ - (dest)->type = STACK_I4; \ + MONO_INST_NEW ((cfg), (dest), (op)); \ + (dest)->dreg = (dr); \ + (dest)->inst_p0 = (gpointer)(gssize)(mem); \ + (dest)->type = STACK_I4; \ } while (0) #define NEW_UNALU(cfg,dest,op,dr,sr1) do { \ - MONO_INST_NEW ((cfg), (dest), (op)); \ - (dest)->dreg = dr; \ - (dest)->sreg1 = sr1; \ - } while (0) + MONO_INST_NEW ((cfg), (dest), (op)); \ + (dest)->dreg = dr; \ + (dest)->sreg1 = sr1; \ + } while (0) #define NEW_BIALU(cfg,dest,op,dr,sr1,sr2) do { \ - MONO_INST_NEW ((cfg), (dest), (op)); \ - (dest)->dreg = (dr); \ - (dest)->sreg1 = (sr1); \ - (dest)->sreg2 = (sr2); \ + MONO_INST_NEW ((cfg), (dest), (op)); \ + (dest)->dreg = (dr); \ + (dest)->sreg1 = (sr1); \ + (dest)->sreg2 = (sr2); \ } while (0) #define NEW_BIALU_IMM(cfg,dest,op,dr,sr,imm) do { \ - MONO_INST_NEW ((cfg), (dest), (op)); \ - (dest)->dreg = dr; \ - (dest)->sreg1 = sr; \ - (dest)->inst_imm = (imm); \ - } while (0) - -#define NEW_PATCH_INFO(cfg,dest,el1,el2) do { \ - MONO_INST_NEW ((cfg), (dest), OP_PATCH_INFO); \ - (dest)->inst_left = (MonoInst*)(el1); \ - (dest)->inst_right = (MonoInst*)(el2); \ - } while (0) - -#define NEW_AOTCONST_GOT_VAR(cfg,dest,patch_type,cons) do { \ - MONO_INST_NEW ((cfg), (dest), cfg->compile_aot ? OP_GOT_ENTRY : OP_PCONST); \ - if (cfg->compile_aot) { \ - MonoInst *group, *got_loc; \ - got_loc = mono_get_got_var (cfg); \ - NEW_PATCH_INFO ((cfg), group, cons, patch_type); \ - (dest)->inst_basereg = got_loc->dreg; \ - (dest)->inst_p1 = group; \ - } else { \ - (dest)->inst_p0 = (cons); \ - (dest)->inst_i1 = (MonoInst*)(patch_type); \ - } \ - (dest)->type = STACK_PTR; \ - (dest)->dreg = alloc_dreg ((cfg), STACK_PTR); \ + MONO_INST_NEW ((cfg), (dest), (op)); \ + (dest)->dreg = dr; \ + (dest)->sreg1 = sr; \ + (dest)->inst_imm = (imm); \ + } while (0) + +#define NEW_PATCH_INFO(cfg,dest,el1,el2) do { \ + MONO_INST_NEW ((cfg), (dest), OP_PATCH_INFO); \ + (dest)->inst_left = (MonoInst*)(el1); \ + (dest)->inst_right = (MonoInst*)(el2); \ + } while (0) + +#define NEW_AOTCONST_GOT_VAR(cfg,dest,patch_type,cons) do { \ + MONO_INST_NEW ((cfg), (dest), cfg->compile_aot ? OP_GOT_ENTRY : OP_PCONST); \ + if (cfg->compile_aot) { \ + MonoInst *__group, *__got_loc; \ + __got_loc = mono_get_got_var (cfg); \ + NEW_PATCH_INFO ((cfg), __group, cons, patch_type); \ + (dest)->inst_basereg = __got_loc->dreg; \ + (dest)->inst_p1 = __group; \ + } else { \ + (dest)->inst_p0 = (cons); \ + (dest)->inst_i1 = (MonoInst*)(patch_type); \ + } \ + (dest)->type = STACK_PTR; \ + (dest)->dreg = alloc_dreg ((cfg), STACK_PTR); \ } while (0) #define NEW_AOTCONST_TOKEN_GOT_VAR(cfg,dest,patch_type,image,token,generic_context,stack_type,stack_class) do { \ - MonoInst *group, *got_loc; \ - MONO_INST_NEW ((cfg), (dest), OP_GOT_ENTRY); \ - got_loc = mono_get_got_var (cfg); \ - NEW_PATCH_INFO ((cfg), group, NULL, patch_type); \ - group->inst_p0 = mono_jump_info_token_new2 ((cfg)->mempool, (image), (token), (generic_context)); \ - (dest)->inst_basereg = got_loc->dreg; \ - (dest)->inst_p1 = group; \ - (dest)->type = (stack_type); \ - (dest)->klass = (stack_class); \ - (dest)->dreg = alloc_dreg ((cfg), (stack_type)); \ - } while (0) - -#define NEW_AOTCONST(cfg,dest,patch_type,cons) do { \ - if (cfg->backend->need_got_var && !cfg->llvm_only) { \ - NEW_AOTCONST_GOT_VAR ((cfg), (dest), (patch_type), (cons)); \ - } else { \ - MONO_INST_NEW ((cfg), (dest), cfg->compile_aot ? OP_AOTCONST : OP_PCONST); \ - (dest)->inst_p0 = (cons); \ - (dest)->inst_p1 = GUINT_TO_POINTER (patch_type); \ - (dest)->type = STACK_PTR; \ - (dest)->dreg = alloc_dreg ((cfg), STACK_PTR); \ - } \ - } while (0) + MonoInst *__group, *__got_loc; \ + MONO_INST_NEW ((cfg), (dest), OP_GOT_ENTRY); \ + __got_loc = mono_get_got_var (cfg); \ + NEW_PATCH_INFO ((cfg), __group, NULL, patch_type); \ + __group->inst_p0 = mono_jump_info_token_new2 ((cfg)->mempool, (image), (token), (generic_context)); \ + (dest)->inst_basereg = __got_loc->dreg; \ + (dest)->inst_p1 = __group; \ + (dest)->type = (stack_type); \ + (dest)->klass = (stack_class); \ + (dest)->dreg = alloc_dreg ((cfg), (stack_type)); \ + } while (0) + +#define NEW_AOTCONST(cfg,dest,patch_type,cons) do { \ + if (cfg->backend->need_got_var && !cfg->llvm_only) { \ + NEW_AOTCONST_GOT_VAR ((cfg), (dest), (patch_type), (cons)); \ + } else { \ + MONO_INST_NEW ((cfg), (dest), cfg->compile_aot ? OP_AOTCONST : OP_PCONST); \ + (dest)->inst_p0 = (cons); \ + (dest)->inst_p1 = GUINT_TO_POINTER (patch_type); \ + (dest)->type = STACK_PTR; \ + (dest)->dreg = alloc_dreg ((cfg), STACK_PTR); \ + } \ + } while (0) #define NEW_AOTCONST_TOKEN(cfg,dest,patch_type,image,token,generic_context,stack_type,stack_class) do { \ - if (cfg->backend->need_got_var && !cfg->llvm_only) { \ - NEW_AOTCONST_TOKEN_GOT_VAR ((cfg), (dest), (patch_type), (image), (token), (generic_context), (stack_type), (stack_class)); \ - } else { \ - MONO_INST_NEW ((cfg), (dest), OP_AOTCONST); \ - (dest)->inst_p0 = mono_jump_info_token_new2 ((cfg)->mempool, (image), (token), (generic_context)); \ - (dest)->inst_p1 = (gpointer)(patch_type); \ - (dest)->type = (stack_type); \ - (dest)->klass = (stack_class); \ - (dest)->dreg = alloc_dreg ((cfg), (stack_type)); \ - } \ - } while (0) + if (cfg->backend->need_got_var && !cfg->llvm_only) { \ + NEW_AOTCONST_TOKEN_GOT_VAR ((cfg), (dest), (patch_type), (image), (token), (generic_context), (stack_type), (stack_class)); \ + } else { \ + MONO_INST_NEW ((cfg), (dest), OP_AOTCONST); \ + (dest)->inst_p0 = mono_jump_info_token_new2 ((cfg)->mempool, (image), (token), (generic_context)); \ + (dest)->inst_p1 = (gpointer)(patch_type); \ + (dest)->type = (stack_type); \ + (dest)->klass = (stack_class); \ + (dest)->dreg = alloc_dreg ((cfg), (stack_type)); \ + } \ + } while (0) #define NEW_CLASSCONST(cfg,dest,val) NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_CLASS, (val)) @@ -322,25 +322,25 @@ alloc_dreg (MonoCompile *cfg, MonoStackType stack_type) } while (0) #define NEW_METHOD_RGCTX_CONST(cfg,dest,method) do { \ - if (cfg->compile_aot) { \ + if (cfg->compile_aot) { \ NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_METHOD_RGCTX, (method)); \ - } else { \ - MonoMethodRuntimeGenericContext *mrgctx; \ - mrgctx = (MonoMethodRuntimeGenericContext*)mini_method_get_rgctx ((method)); \ - NEW_PCONST ((cfg), (dest), (mrgctx)); \ - } \ + } else { \ + MonoMethodRuntimeGenericContext *mrgctx; \ + mrgctx = (MonoMethodRuntimeGenericContext*)mini_method_get_rgctx ((method)); \ + NEW_PCONST ((cfg), (dest), (mrgctx)); \ + } \ } while (0) #define NEW_JIT_ICALL_ADDRCONST(cfg, dest, jit_icall_id) NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_JIT_ICALL_ADDR, (jit_icall_id)) #define NEW_VARLOAD(cfg,dest,var,vartype) do { \ - MONO_INST_NEW ((cfg), (dest), OP_MOVE); \ - (dest)->opcode = mono_type_to_regmove ((cfg), (vartype)); \ - mini_type_to_eval_stack_type ((cfg), (vartype), (dest)); \ - (dest)->klass = var->klass; \ - (dest)->sreg1 = var->dreg; \ - (dest)->dreg = alloc_dreg ((cfg), (MonoStackType)(dest)->type); \ - if ((dest)->opcode == OP_VMOVE) (dest)->klass = mono_class_from_mono_type_internal ((vartype)); \ + MONO_INST_NEW ((cfg), (dest), OP_MOVE); \ + (dest)->opcode = mono_type_to_regmove ((cfg), (vartype)); \ + mini_type_to_eval_stack_type ((cfg), (vartype), (dest)); \ + (dest)->klass = var->klass; \ + (dest)->sreg1 = var->dreg; \ + (dest)->dreg = alloc_dreg ((cfg), (MonoStackType)(dest)->type); \ + if ((dest)->opcode == OP_VMOVE) (dest)->klass = mono_class_from_mono_type_internal ((vartype)); \ } while (0) #define DECOMPOSE_INTO_REGPAIR(stack_type) (mono_arch_is_soft_float () ? ((stack_type) == STACK_I8 || (stack_type) == STACK_R8) : ((stack_type) == STACK_I8)) @@ -359,25 +359,27 @@ handle_gsharedvt_ldaddr (MonoCompile *cfg) MONO_ADD_INS (cfg->cbb, use); } -#define NEW_VARLOADA(cfg,dest,var,vartype) do { \ - MONO_INST_NEW ((cfg), (dest), OP_LDADDR); \ +#define NEW_VARLOADA(cfg,dest,var,vartype) do { \ + MONO_DISABLE_WARNING(4127) \ + MONO_INST_NEW ((cfg), (dest), OP_LDADDR); \ (dest)->inst_p0 = (var); \ - (var)->flags |= MONO_INST_INDIRECT; \ - (dest)->type = STACK_MP; \ - (dest)->klass = (var)->klass; \ - (dest)->dreg = alloc_dreg ((cfg), STACK_MP); \ - (cfg)->has_indirection = TRUE; \ - if (G_UNLIKELY (cfg->gsharedvt) && mini_is_gsharedvt_variable_type ((var)->inst_vtype)) { handle_gsharedvt_ldaddr ((cfg)); } \ + (var)->flags |= MONO_INST_INDIRECT; \ + (dest)->type = STACK_MP; \ + (dest)->klass = (var)->klass; \ + (dest)->dreg = alloc_dreg ((cfg), STACK_MP); \ + (cfg)->has_indirection = TRUE; \ + if (G_UNLIKELY (cfg->gsharedvt) && mini_is_gsharedvt_variable_type ((var)->inst_vtype)) { handle_gsharedvt_ldaddr ((cfg)); } \ if (SIZEOF_REGISTER == 4 && DECOMPOSE_INTO_REGPAIR ((var)->type)) { MonoInst *var1 = get_vreg_to_inst (cfg, MONO_LVREG_LS ((var)->dreg)); MonoInst *var2 = get_vreg_to_inst (cfg, MONO_LVREG_MS ((var)->dreg)); g_assert (var1); g_assert (var2); var1->flags |= MONO_INST_INDIRECT; var2->flags |= MONO_INST_INDIRECT; } \ + MONO_RESTORE_WARNING \ } while (0) -#define NEW_VARSTORE(cfg,dest,var,vartype,inst) do { \ - MONO_INST_NEW ((cfg), (dest), OP_MOVE); \ - (dest)->opcode = mono_type_to_regmove ((cfg), (vartype)); \ - (dest)->klass = (var)->klass; \ - (dest)->sreg1 = (inst)->dreg; \ - (dest)->dreg = (var)->dreg; \ - if ((dest)->opcode == OP_VMOVE) (dest)->klass = mono_class_from_mono_type_internal ((vartype)); \ +#define NEW_VARSTORE(cfg,dest,var,vartype,inst) do { \ + MONO_INST_NEW ((cfg), (dest), OP_MOVE); \ + (dest)->opcode = mono_type_to_regmove ((cfg), (vartype)); \ + (dest)->klass = (var)->klass; \ + (dest)->sreg1 = (inst)->dreg; \ + (dest)->dreg = (var)->dreg; \ + if ((dest)->opcode == OP_VMOVE) (dest)->klass = mono_class_from_mono_type_internal ((vartype)); \ } while (0) #define NEW_TEMPLOAD(cfg,dest,num) NEW_VARLOAD ((cfg), (dest), (cfg)->varinfo [(num)], (cfg)->varinfo [(num)]->inst_vtype) @@ -396,46 +398,46 @@ handle_gsharedvt_ldaddr (MonoCompile *cfg) #define NEW_LOCLOADA(cfg,dest,num) NEW_VARLOADA ((cfg), (dest), (cfg)->locals [(num)], (cfg)->locals [(num)]->inst_vtype) -#define NEW_RETLOADA(cfg,dest) do { \ - MONO_INST_NEW ((cfg), (dest), OP_MOVE); \ - (dest)->type = STACK_MP; \ - (dest)->klass = cfg->ret->klass; \ - (dest)->sreg1 = cfg->vret_addr->dreg; \ - (dest)->dreg = alloc_dreg ((cfg), (MonoStackType)(dest)->type); \ +#define NEW_RETLOADA(cfg,dest) do { \ + MONO_INST_NEW ((cfg), (dest), OP_MOVE); \ + (dest)->type = STACK_MP; \ + (dest)->klass = cfg->ret->klass; \ + (dest)->sreg1 = cfg->vret_addr->dreg; \ + (dest)->dreg = alloc_dreg ((cfg), (MonoStackType)(dest)->type); \ } while (0) #define NEW_ARGLOADA(cfg,dest,num) NEW_VARLOADA ((cfg), (dest), arg_array [(num)], param_types [(num)]) /* Promote the vreg to a variable so its address can be taken */ #define NEW_VARLOADA_VREG(cfg,dest,vreg,ltype) do { \ - MonoInst *var = get_vreg_to_inst ((cfg), (vreg)); \ - if (!var) \ - var = mono_compile_create_var_for_vreg ((cfg), (ltype), OP_LOCAL, (vreg)); \ - NEW_VARLOADA ((cfg), (dest), (var), (ltype)); \ - } while (0) + MonoInst *__var = get_vreg_to_inst ((cfg), (vreg)); \ + if (!__var) \ + __var = mono_compile_create_var_for_vreg ((cfg), (ltype), OP_LOCAL, (vreg)); \ + NEW_VARLOADA ((cfg), (dest), (__var), (ltype)); \ + } while (0) #define NEW_DUMMY_USE(cfg,dest,var) do { \ - MONO_INST_NEW ((cfg), (dest), OP_DUMMY_USE); \ + MONO_INST_NEW ((cfg), (dest), OP_DUMMY_USE); \ (dest)->sreg1 = var->dreg; \ - } while (0) + } while (0) /* Variants which take a type argument and handle vtypes as well */ #define NEW_LOAD_MEMBASE_TYPE(cfg,dest,ltype,base,offset) do { \ - NEW_LOAD_MEMBASE ((cfg), (dest), mono_type_to_load_membase ((cfg), (ltype)), 0, (base), (offset)); \ - mini_type_to_eval_stack_type ((cfg), (ltype), (dest)); \ - (dest)->dreg = alloc_dreg ((cfg), (MonoStackType)(dest)->type); \ - } while (0) + NEW_LOAD_MEMBASE ((cfg), (dest), mono_type_to_load_membase ((cfg), (ltype)), 0, (base), (offset)); \ + mini_type_to_eval_stack_type ((cfg), (ltype), (dest)); \ + (dest)->dreg = alloc_dreg ((cfg), (MonoStackType)(dest)->type); \ + } while (0) #define NEW_STORE_MEMBASE_TYPE(cfg,dest,ltype,base,offset,sr) do { \ - MONO_INST_NEW ((cfg), (dest), mono_type_to_store_membase ((cfg), (ltype))); \ - (dest)->sreg1 = sr; \ - (dest)->inst_destbasereg = base; \ - (dest)->inst_offset = offset; \ - mini_type_to_eval_stack_type ((cfg), (ltype), (dest)); \ - (dest)->klass = mono_class_from_mono_type_internal (ltype); \ + MONO_INST_NEW ((cfg), (dest), mono_type_to_store_membase ((cfg), (ltype))); \ + (dest)->sreg1 = sr; \ + (dest)->inst_destbasereg = base; \ + (dest)->inst_offset = offset; \ + mini_type_to_eval_stack_type ((cfg), (ltype), (dest)); \ + (dest)->klass = mono_class_from_mono_type_internal (ltype); \ } while (0) -#define NEW_SEQ_POINT(cfg,dest,il_offset,intr_loc) do { \ +#define NEW_SEQ_POINT(cfg,dest,il_offset,intr_loc) do { \ MONO_INST_NEW ((cfg), (dest), cfg->gen_sdb_seq_points ? OP_SEQ_POINT : OP_IL_SEQ_POINT); \ (dest)->inst_imm = (il_offset); \ (dest)->flags = intr_loc ? MONO_INST_SINGLE_STEP_LOC : 0; \ @@ -503,59 +505,59 @@ handle_gsharedvt_ldaddr (MonoCompile *cfg) #define EMIT_NEW_VARLOAD_SFLOAT(cfg,dest,var,vartype) do { \ if (!COMPILE_LLVM ((cfg)) && !m_type_is_byref ((vartype)) && (vartype)->type == MONO_TYPE_R4) { \ - MonoInst *iargs [1]; \ - EMIT_NEW_VARLOADA (cfg, iargs [0], (var), (vartype)); \ - (dest) = mono_emit_jit_icall (cfg, mono_fload_r4, iargs); \ + MonoInst *__iargs [1]; \ + EMIT_NEW_VARLOADA (cfg, __iargs [0], (var), (vartype)); \ + (dest) = mono_emit_jit_icall (cfg, mono_fload_r4, __iargs); \ } else { \ EMIT_NEW_VARLOAD ((cfg), (dest), (var), (vartype)); \ } \ } while (0) -#define EMIT_NEW_VARSTORE_SFLOAT(cfg,dest,var,vartype,inst) do { \ +#define EMIT_NEW_VARSTORE_SFLOAT(cfg,dest,var,vartype,inst) do { \ if (COMPILE_SOFT_FLOAT ((cfg)) && !m_type_is_byref ((vartype)) && (vartype)->type == MONO_TYPE_R4) { \ - MonoInst *iargs [2]; \ - iargs [0] = (inst); \ - EMIT_NEW_VARLOADA (cfg, iargs [1], (var), (vartype)); \ - (dest) = mono_emit_jit_icall (cfg, mono_fstore_r4, iargs); \ + MonoInst *__iargs [2]; \ + __iargs [0] = (inst); \ + EMIT_NEW_VARLOADA (cfg, __iargs [1], (var), (vartype)); \ + (dest) = mono_emit_jit_icall (cfg, mono_fstore_r4, __iargs); \ } else { \ EMIT_NEW_VARSTORE ((cfg), (dest), (var), (vartype), (inst)); \ } \ } while (0) -#define EMIT_NEW_ARGLOAD(cfg,dest,num) do { \ - if (mono_arch_is_soft_float ()) { \ - EMIT_NEW_VARLOAD_SFLOAT ((cfg), (dest), cfg->args [(num)], cfg->arg_types [(num)]); \ - } else { \ - NEW_ARGLOAD ((cfg), (dest), (num)); \ - MONO_ADD_INS ((cfg)->cbb, (dest)); \ +#define EMIT_NEW_ARGLOAD(cfg,dest,num) do { \ + if (mono_arch_is_soft_float ()) { \ + EMIT_NEW_VARLOAD_SFLOAT ((cfg), (dest), cfg->args [(num)], cfg->arg_types [(num)]); \ + } else { \ + NEW_ARGLOAD ((cfg), (dest), (num)); \ + MONO_ADD_INS ((cfg)->cbb, (dest)); \ } \ } while (0) -#define EMIT_NEW_LOCLOAD(cfg,dest,num) do { \ - if (mono_arch_is_soft_float ()) { \ - EMIT_NEW_VARLOAD_SFLOAT ((cfg), (dest), cfg->locals [(num)], header->locals [(num)]); \ - } else { \ - NEW_LOCLOAD ((cfg), (dest), (num)); \ - MONO_ADD_INS ((cfg)->cbb, (dest)); \ - } \ +#define EMIT_NEW_LOCLOAD(cfg,dest,num) do { \ + if (mono_arch_is_soft_float ()) { \ + EMIT_NEW_VARLOAD_SFLOAT ((cfg), (dest), cfg->locals [(num)], header->locals [(num)]); \ + } else { \ + NEW_LOCLOAD ((cfg), (dest), (num)); \ + MONO_ADD_INS ((cfg)->cbb, (dest)); \ + } \ } while (0) -#define EMIT_NEW_LOCSTORE(cfg,dest,num,inst) do { \ - if (mono_arch_is_soft_float ()) { \ - EMIT_NEW_VARSTORE_SFLOAT ((cfg), (dest), (cfg)->locals [(num)], (cfg)->locals [(num)]->inst_vtype, (inst)); \ - } else { \ - NEW_LOCSTORE ((cfg), (dest), (num), (inst)); \ - MONO_ADD_INS ((cfg)->cbb, (dest)); \ - } \ +#define EMIT_NEW_LOCSTORE(cfg,dest,num,inst) do { \ + if (mono_arch_is_soft_float ()) { \ + EMIT_NEW_VARSTORE_SFLOAT ((cfg), (dest), (cfg)->locals [(num)], (cfg)->locals [(num)]->inst_vtype, (inst)); \ + } else { \ + NEW_LOCSTORE ((cfg), (dest), (num), (inst)); \ + MONO_ADD_INS ((cfg)->cbb, (dest)); \ + } \ } while (0) -#define EMIT_NEW_ARGSTORE(cfg,dest,num,inst) do { \ - if (mono_arch_is_soft_float ()) { \ - EMIT_NEW_VARSTORE_SFLOAT ((cfg), (dest), cfg->args [(num)], cfg->arg_types [(num)], (inst)); \ - } else { \ - NEW_ARGSTORE ((cfg), (dest), (num), (inst)); \ - MONO_ADD_INS ((cfg)->cbb, (dest)); \ - } \ +#define EMIT_NEW_ARGSTORE(cfg,dest,num,inst) do { \ + if (mono_arch_is_soft_float ()) { \ + EMIT_NEW_VARSTORE_SFLOAT ((cfg), (dest), cfg->args [(num)], cfg->arg_types [(num)], (inst)); \ + } else { \ + NEW_ARGSTORE ((cfg), (dest), (num), (inst)); \ + MONO_ADD_INS ((cfg)->cbb, (dest)); \ + } \ } while (0) #else @@ -605,55 +607,55 @@ handle_gsharedvt_ldaddr (MonoCompile *cfg) * Variants which do not take an dest argument, but take a dreg argument. */ #define MONO_EMIT_NEW_ICONST(cfg,dr,imm) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), OP_ICONST); \ - inst->dreg = dr; \ - inst->inst_c0 = imm; \ - MONO_ADD_INS ((cfg)->cbb, inst); \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), OP_ICONST); \ + __inst->dreg = dr; \ + __inst->inst_c0 = imm; \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ } while (0) -#define MONO_EMIT_NEW_PCONST(cfg,dr,val) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), OP_PCONST); \ - inst->dreg = dr; \ - (inst)->inst_p0 = (val); \ - (inst)->type = STACK_PTR; \ - MONO_ADD_INS ((cfg)->cbb, inst); \ +#define MONO_EMIT_NEW_PCONST(cfg,dr,val) do { \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), OP_PCONST); \ + __inst->dreg = dr; \ + (__inst)->inst_p0 = (val); \ + (__inst)->type = STACK_PTR; \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ } while (0) #define MONO_EMIT_NEW_I8CONST(cfg,dr,imm) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), OP_I8CONST); \ - inst->dreg = dr; \ - inst->inst_l = imm; \ - MONO_ADD_INS ((cfg)->cbb, inst); \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), OP_I8CONST); \ + __inst->dreg = dr; \ + __inst->inst_l = imm; \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ } while (0) -#define MONO_EMIT_NEW_DUMMY_INIT(cfg,dr,op) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), (op)); \ - inst->dreg = dr; \ - MONO_ADD_INS ((cfg)->cbb, inst); \ +#define MONO_EMIT_NEW_DUMMY_INIT(cfg,dr,op) do { \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), (op)); \ + __inst->dreg = dr; \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ } while (0) #ifdef MONO_ARCH_NEED_GOT_VAR #define MONO_EMIT_NEW_AOTCONST(cfg,dr,cons,patch_type) do { \ - MonoInst *inst; \ - NEW_AOTCONST ((cfg), (inst), (patch_type), (cons)); \ - inst->dreg = (dr); \ - MONO_ADD_INS ((cfg)->cbb, inst); \ - } while (0) + MonoInst *__inst; \ + NEW_AOTCONST ((cfg), (__inst), (patch_type), (cons)); \ + __inst->dreg = (dr); \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ + } while (0) #else #define MONO_EMIT_NEW_AOTCONST(cfg,dr,imm,type) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), cfg->compile_aot ? OP_AOTCONST : OP_PCONST); \ - inst->dreg = dr; \ - inst->inst_p0 = imm; \ - inst->inst_c1 = type; \ - MONO_ADD_INS ((cfg)->cbb, inst); \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), cfg->compile_aot ? OP_AOTCONST : OP_PCONST); \ + __inst->dreg = dr; \ + __inst->inst_p0 = imm; \ + __inst->inst_c1 = type; \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ } while (0) #endif @@ -662,101 +664,103 @@ handle_gsharedvt_ldaddr (MonoCompile *cfg) #define MONO_EMIT_NEW_VTABLECONST(cfg,dest,vtable) MONO_EMIT_NEW_AOTCONST ((cfg), (dest), (cfg)->compile_aot ? (gpointer)((vtable)->klass) : (vtable), MONO_PATCH_INFO_VTABLE) #define MONO_EMIT_NEW_SIGNATURECONST(cfg,dr,sig) MONO_EMIT_NEW_AOTCONST ((cfg), (dr), (sig), MONO_PATCH_INFO_SIGNATURE) -#define MONO_EMIT_NEW_VZERO(cfg,dr,kl) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), MONO_CLASS_IS_SIMD (cfg, kl) ? OP_XZERO : OP_VZERO); \ - inst->dreg = dr; \ - (inst)->type = STACK_VTYPE; \ - (inst)->klass = (kl); \ - MONO_ADD_INS ((cfg)->cbb, inst); \ +#define MONO_EMIT_NEW_VZERO(cfg,dr,kl) do { \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), MONO_CLASS_IS_SIMD (cfg, kl) ? OP_XZERO : OP_VZERO); \ + __inst->dreg = dr; \ + (__inst)->type = STACK_VTYPE; \ + (__inst)->klass = (kl); \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ } while (0) #define MONO_EMIT_NEW_UNALU(cfg,op,dr,sr1) do { \ - MonoInst *inst; \ - EMIT_NEW_UNALU ((cfg), (inst), (op), (dr), (sr1)); \ + MonoInst *__inst; \ + EMIT_NEW_UNALU ((cfg), (__inst), (op), (dr), (sr1)); \ } while (0) #define MONO_EMIT_NEW_BIALU(cfg,op,dr,sr1,sr2) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), (op)); \ - inst->dreg = dr; \ - inst->sreg1 = sr1; \ - inst->sreg2 = sr2; \ - MONO_ADD_INS (cfg->cbb, inst); \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), (op)); \ + __inst->dreg = dr; \ + __inst->sreg1 = sr1; \ + __inst->sreg2 = sr2; \ + MONO_ADD_INS (cfg->cbb, __inst); \ } while (0) #define MONO_EMIT_NEW_BIALU_IMM(cfg,op,dr,sr,imm) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), (op)); \ - inst->dreg = dr; \ - inst->sreg1 = sr; \ - inst->inst_imm = (target_mgreg_t)(imm); \ - MONO_ADD_INS (cfg->cbb, inst); \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), (op)); \ + __inst->dreg = dr; \ + __inst->sreg1 = sr; \ + __inst->inst_imm = (target_mgreg_t)(imm); \ + MONO_ADD_INS (cfg->cbb, __inst); \ } while (0) #define MONO_EMIT_NEW_COMPARE_IMM(cfg,sr1,imm) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), (OP_COMPARE_IMM)); \ - inst->sreg1 = sr1; \ - inst->inst_imm = (imm); \ - MONO_ADD_INS ((cfg)->cbb, inst); \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), (OP_COMPARE_IMM)); \ + __inst->sreg1 = sr1; \ + __inst->inst_imm = (imm); \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ } while (0) #define MONO_EMIT_NEW_ICOMPARE_IMM(cfg,sr1,imm) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), sizeof (target_mgreg_t) == 8 ? OP_ICOMPARE_IMM : OP_COMPARE_IMM); \ - inst->sreg1 = sr1; \ - inst->inst_imm = (imm); \ - MONO_ADD_INS ((cfg)->cbb, inst); \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), sizeof (target_mgreg_t) == 8 ? OP_ICOMPARE_IMM : OP_COMPARE_IMM); \ + __inst->sreg1 = sr1; \ + __inst->inst_imm = (imm); \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ } while (0) /* This is used on 32 bit machines too when running with LLVM */ #define MONO_EMIT_NEW_LCOMPARE_IMM(cfg,sr1,imm) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), (OP_LCOMPARE_IMM)); \ - inst->sreg1 = sr1; \ - if (SIZEOF_REGISTER == 4 && COMPILE_LLVM (cfg)) { \ - inst->inst_l = (imm); \ + MONO_DISABLE_WARNING(4127) \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), (OP_LCOMPARE_IMM)); \ + __inst->sreg1 = sr1; \ + if (SIZEOF_REGISTER == 4 && COMPILE_LLVM (cfg)) { \ + __inst->inst_l = (imm); \ } else { \ - inst->inst_imm = (imm); \ - } \ - MONO_ADD_INS ((cfg)->cbb, inst); \ + __inst->inst_imm = (imm); \ + } \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ + MONO_RESTORE_WARNING \ } while (0) #define MONO_EMIT_NEW_LOAD_MEMBASE_OP(cfg,op,dr,base,offset) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), (op)); \ - inst->dreg = dr; \ - inst->inst_basereg = base; \ - inst->inst_offset = offset; \ - MONO_ADD_INS (cfg->cbb, inst); \ - } while (0) + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), (op)); \ + __inst->dreg = dr; \ + __inst->inst_basereg = base; \ + __inst->inst_offset = offset; \ + MONO_ADD_INS (cfg->cbb, __inst); \ + } while (0) #define MONO_EMIT_NEW_LOAD_MEMBASE(cfg,dr,base,offset) MONO_EMIT_NEW_LOAD_MEMBASE_OP ((cfg), (OP_LOAD_MEMBASE), (dr), (base), (offset)) #define MONO_EMIT_NEW_STORE_MEMBASE(cfg,op,base,offset,sr) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), (op)); \ - (inst)->sreg1 = sr; \ - (inst)->inst_destbasereg = base; \ - (inst)->inst_offset = offset; \ - MONO_ADD_INS (cfg->cbb, inst); \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), (op)); \ + (__inst)->sreg1 = sr; \ + (__inst)->inst_destbasereg = base; \ + (__inst)->inst_offset = offset; \ + MONO_ADD_INS (cfg->cbb, __inst); \ } while (0) #define MONO_EMIT_NEW_STORE_MEMBASE_IMM(cfg,op,base,offset,imm) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), (op)); \ - inst->inst_destbasereg = base; \ - inst->inst_offset = offset; \ - inst->inst_imm = (target_mgreg_t)(imm); \ - MONO_ADD_INS ((cfg)->cbb, inst); \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), (op)); \ + __inst->inst_destbasereg = base; \ + __inst->inst_offset = offset; \ + __inst->inst_imm = (target_mgreg_t)(imm); \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ } while (0) #define MONO_EMIT_NEW_COND_EXC(cfg,cond,name) do { \ - MonoInst *inst; \ - MONO_INST_NEW ((cfg), (inst), (OP_COND_EXC_##cond)); \ - inst->inst_p1 = (char*)name; \ - MONO_ADD_INS ((cfg)->cbb, inst); \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), (OP_COND_EXC_##cond)); \ + __inst->inst_p1 = (char*)name; \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ } while (0) /* Branch support */ @@ -767,15 +771,15 @@ handle_gsharedvt_ldaddr (MonoCompile *cfg) * block_num: unique ID assigned at bblock creation */ #define NEW_BBLOCK(cfg,bblock) do { \ - (bblock) = (MonoBasicBlock *)mono_mempool_alloc0 ((cfg)->mempool, sizeof (MonoBasicBlock)); \ - (bblock)->block_num = cfg->num_bblocks++; \ - } while (0) + (bblock) = (MonoBasicBlock *)mono_mempool_alloc0 ((cfg)->mempool, sizeof (MonoBasicBlock)); \ + (bblock)->block_num = cfg->num_bblocks++; \ + } while (0) -#define ADD_BBLOCK(cfg,b) do { \ - if ((b)->cil_code) {\ - cfg->cil_offset_to_bb [(b)->cil_code - cfg->cil_start] = (b); \ - } \ - (b)->real_offset = cfg->real_offset; \ +#define ADD_BBLOCK(cfg,b) do { \ + if ((b)->cil_code) { \ + cfg->cil_offset_to_bb [(b)->cil_code - cfg->cil_start] = (b); \ + } \ + (b)->real_offset = cfg->real_offset; \ } while (0) /* @@ -786,137 +790,139 @@ handle_gsharedvt_ldaddr (MonoCompile *cfg) #ifdef DEBUG_EXTENDED_BBLOCKS static int ccount = 0; #define MONO_EMIT_NEW_BRANCH_BLOCK(cfg,op,truebb) do { \ - MonoInst *ins; \ - MonoBasicBlock *falsebb; \ - MONO_INST_NEW ((cfg), (ins), (op)); \ - if ((op) == OP_BR) { \ - NEW_BBLOCK ((cfg), falsebb); \ - ins->inst_target_bb = (truebb); \ - mono_link_bblock ((cfg), (cfg)->cbb, (truebb)); \ - MONO_ADD_INS ((cfg)->cbb, ins); \ - MONO_START_BB ((cfg), falsebb); \ - } else { \ - ccount ++; \ - ins->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); \ - ins->inst_true_bb = (truebb); \ - ins->inst_false_bb = NULL; \ - mono_link_bblock ((cfg), (cfg)->cbb, (truebb)); \ - MONO_ADD_INS ((cfg)->cbb, ins); \ - char *count2 = g_getenv ("COUNT2"); \ - if (count2 && ccount == atoi (count2) - 1) { printf ("HIT: %d\n", cfg->cbb->block_num); } \ - if (count2 && ccount < atoi (count2)) { \ - cfg->cbb->extended = TRUE; \ - } else { NEW_BBLOCK ((cfg), falsebb); ins->inst_false_bb = (falsebb); mono_link_bblock ((cfg), (cfg)->cbb, (falsebb)); MONO_START_BB ((cfg), falsebb); } \ - if (count2) g_free (count2); \ - } \ + MonoInst *__inst; \ + MonoBasicBlock *__falsebb; \ + MONO_INST_NEW ((cfg), (__inst), (op)); \ + if ((op) == OP_BR) { \ + NEW_BBLOCK ((cfg), __falsebb); \ + __inst->inst_target_bb = (truebb); \ + mono_link_bblock ((cfg), (cfg)->cbb, (truebb)); \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ + MONO_START_BB ((cfg), __falsebb); \ + } else { \ + ccount ++; \ + __inst->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); \ + __inst->inst_true_bb = (truebb); \ + __inst->inst_false_bb = NULL; \ + mono_link_bblock ((cfg), (cfg)->cbb, (truebb)); \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ + char *__count2 = g_getenv ("COUNT2"); \ + if (__count2 && ccount == atoi (__count2) - 1) { printf ("HIT: %d\n", cfg->cbb->block_num); } \ + if (__count2 && ccount < atoi (__count2)) { \ + cfg->cbb->extended = TRUE; \ + } else { NEW_BBLOCK ((cfg), __falsebb); __inst->inst_false_bb = (__falsebb); mono_link_bblock ((cfg), (cfg)->cbb, (__falsebb)); MONO_START_BB ((cfg), __falsebb); } \ + if (__count2) g_free (__count2); \ + } \ } while (0) #else #define MONO_EMIT_NEW_BRANCH_BLOCK(cfg,op,truebb) do { \ - MonoInst *ins; \ - MonoBasicBlock *falsebb; \ - MONO_INST_NEW ((cfg), (ins), (op)); \ - if ((op) == OP_BR) { \ - NEW_BBLOCK ((cfg), falsebb); \ - ins->inst_target_bb = (truebb); \ - mono_link_bblock ((cfg), (cfg)->cbb, (truebb)); \ - MONO_ADD_INS ((cfg)->cbb, ins); \ - MONO_START_BB ((cfg), falsebb); \ - } else { \ - ins->inst_many_bb = (MonoBasicBlock **)mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); \ - ins->inst_true_bb = (truebb); \ - ins->inst_false_bb = NULL; \ - mono_link_bblock ((cfg), (cfg)->cbb, (truebb)); \ - MONO_ADD_INS ((cfg)->cbb, ins); \ - if (!cfg->enable_extended_bblocks) { \ - NEW_BBLOCK ((cfg), falsebb); \ - ins->inst_false_bb = falsebb; \ - mono_link_bblock ((cfg), (cfg)->cbb, (falsebb)); \ - MONO_START_BB ((cfg), falsebb); \ - } else { \ + MONO_DISABLE_WARNING(4127) \ + MonoInst *__inst; \ + MonoBasicBlock *__falsebb; \ + MONO_INST_NEW ((cfg), (__inst), (op)); \ + if ((op) == OP_BR) { \ + NEW_BBLOCK ((cfg), __falsebb); \ + __inst->inst_target_bb = (truebb); \ + mono_link_bblock ((cfg), (cfg)->cbb, (truebb)); \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ + MONO_START_BB ((cfg), __falsebb); \ + } else { \ + __inst->inst_many_bb = (MonoBasicBlock **)mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); \ + __inst->inst_true_bb = (truebb); \ + __inst->inst_false_bb = NULL; \ + mono_link_bblock ((cfg), (cfg)->cbb, (truebb)); \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ + if (!cfg->enable_extended_bblocks) { \ + NEW_BBLOCK ((cfg), __falsebb); \ + __inst->inst_false_bb = __falsebb; \ + mono_link_bblock ((cfg), (cfg)->cbb, (__falsebb)); \ + MONO_START_BB ((cfg), __falsebb); \ + } else { \ cfg->cbb->extended = TRUE; \ } \ - } \ + } \ + MONO_RESTORE_WARNING \ } while (0) #endif /* Emit a two-way conditional branch */ #define MONO_EMIT_NEW_BRANCH_BLOCK2(cfg,op,truebb,falsebb) do { \ - MonoInst *ins; \ - MONO_INST_NEW ((cfg), (ins), (op)); \ - ins->inst_many_bb = (MonoBasicBlock **)mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); \ - ins->inst_true_bb = (truebb); \ - ins->inst_false_bb = (falsebb); \ - mono_link_bblock ((cfg), (cfg)->cbb, (truebb)); \ - mono_link_bblock ((cfg), (cfg)->cbb, (falsebb)); \ - MONO_ADD_INS ((cfg)->cbb, ins); \ + MonoInst *__inst; \ + MONO_INST_NEW ((cfg), (__inst), (op)); \ + __inst->inst_many_bb = (MonoBasicBlock **)mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); \ + __inst->inst_true_bb = (truebb); \ + __inst->inst_false_bb = (falsebb); \ + mono_link_bblock ((cfg), (cfg)->cbb, (truebb)); \ + mono_link_bblock ((cfg), (cfg)->cbb, (falsebb)); \ + MONO_ADD_INS ((cfg)->cbb, __inst); \ } while (0) #define MONO_START_BB(cfg, bblock) do { \ - ADD_BBLOCK ((cfg), (bblock)); \ - if (cfg->cbb->last_ins && MONO_IS_COND_BRANCH_OP (cfg->cbb->last_ins) && !cfg->cbb->last_ins->inst_false_bb) { \ - cfg->cbb->last_ins->inst_false_bb = (bblock); \ - mono_link_bblock ((cfg), (cfg)->cbb, (bblock)); \ - } else if (! (cfg->cbb->last_ins && ((cfg->cbb->last_ins->opcode == OP_BR) || (cfg->cbb->last_ins->opcode == OP_BR_REG) || MONO_IS_COND_BRANCH_OP (cfg->cbb->last_ins)))) { \ - mono_link_bblock ((cfg), (cfg)->cbb, (bblock)); \ - } \ - (cfg)->cbb->next_bb = (bblock); \ - (cfg)->cbb = (bblock); \ - } while (0) + ADD_BBLOCK ((cfg), (bblock)); \ + if (cfg->cbb->last_ins && MONO_IS_COND_BRANCH_OP (cfg->cbb->last_ins) && !cfg->cbb->last_ins->inst_false_bb) { \ + cfg->cbb->last_ins->inst_false_bb = (bblock); \ + mono_link_bblock ((cfg), (cfg)->cbb, (bblock)); \ + } else if (! (cfg->cbb->last_ins && ((cfg->cbb->last_ins->opcode == OP_BR) || (cfg->cbb->last_ins->opcode == OP_BR_REG) || MONO_IS_COND_BRANCH_OP (cfg->cbb->last_ins)))) { \ + mono_link_bblock ((cfg), (cfg)->cbb, (bblock)); \ + } \ + (cfg)->cbb->next_bb = (bblock); \ + (cfg)->cbb = (bblock); \ + } while (0) /* This marks a place in code where an implicit exception could be thrown */ #define MONO_EMIT_NEW_IMPLICIT_EXCEPTION(cfg) do { \ - if (COMPILE_LLVM ((cfg))) { \ - MONO_EMIT_NEW_UNALU (cfg, OP_IMPLICIT_EXCEPTION, -1, -1); \ + if (COMPILE_LLVM ((cfg))) { \ + MONO_EMIT_NEW_UNALU (cfg, OP_IMPLICIT_EXCEPTION, -1, -1); \ } \ } while (0) /* Loads/Stores which can fault are handled correctly by the LLVM mono branch */ #define MONO_EMIT_NEW_IMPLICIT_EXCEPTION_LOAD_STORE(cfg) do { \ - } while (0) + } while (0) /* Emit an explicit null check which doesn't depend on SIGSEGV signal handling */ #define MONO_EMIT_NULL_CHECK(cfg, reg, out_of_page) do { \ - if (cfg->explicit_null_checks || (out_of_page)) { \ + if (cfg->explicit_null_checks || (out_of_page)) { \ MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, (reg), 0); \ MONO_EMIT_NEW_COND_EXC (cfg, EQ, "NullReferenceException"); \ - } else { \ - MONO_EMIT_NEW_IMPLICIT_EXCEPTION_LOAD_STORE (cfg); \ - } \ - MONO_EMIT_NEW_UNALU (cfg, OP_NOT_NULL, -1, reg); \ + } else { \ + MONO_EMIT_NEW_IMPLICIT_EXCEPTION_LOAD_STORE (cfg); \ + } \ + MONO_EMIT_NEW_UNALU (cfg, OP_NOT_NULL, -1, reg); \ } while (0) #define MONO_EMIT_NEW_CHECK_THIS(cfg, sreg) do { \ - cfg->flags |= MONO_CFG_HAS_CHECK_THIS; \ - if (cfg->explicit_null_checks) { \ - MONO_EMIT_NULL_CHECK (cfg, sreg, FALSE); \ - } else { \ - MONO_EMIT_NEW_UNALU (cfg, OP_CHECK_THIS, -1, sreg); \ - MONO_EMIT_NEW_IMPLICIT_EXCEPTION_LOAD_STORE (cfg); \ - MONO_EMIT_NEW_UNALU (cfg, OP_NOT_NULL, -1, sreg); \ - } \ + cfg->flags |= MONO_CFG_HAS_CHECK_THIS; \ + if (cfg->explicit_null_checks) { \ + MONO_EMIT_NULL_CHECK (cfg, sreg, FALSE); \ + } else { \ + MONO_EMIT_NEW_UNALU (cfg, OP_CHECK_THIS, -1, sreg); \ + MONO_EMIT_NEW_IMPLICIT_EXCEPTION_LOAD_STORE (cfg); \ + MONO_EMIT_NEW_UNALU (cfg, OP_NOT_NULL, -1, sreg); \ + } \ } while (0) -#define NEW_LOAD_MEMBASE_FLAGS(cfg,dest,op,dr,base,offset,ins_flags) do { \ +#define NEW_LOAD_MEMBASE_FLAGS(cfg,dest,op,dr,base,offset,ins_flags) do { \ int __ins_flags = ins_flags; \ - if (__ins_flags & MONO_INST_FAULT) { \ + if (__ins_flags & MONO_INST_FAULT) { \ gboolean __out_of_page = offset > mono_target_pagesize (); \ - MONO_EMIT_NULL_CHECK ((cfg), (base), __out_of_page); \ - } \ - NEW_LOAD_MEMBASE ((cfg), (dest), (op), (dr), (base), (offset)); \ - (dest)->flags = (__ins_flags); \ + MONO_EMIT_NULL_CHECK ((cfg), (base), __out_of_page); \ + } \ + NEW_LOAD_MEMBASE ((cfg), (dest), (op), (dr), (base), (offset)); \ + (dest)->flags = (__ins_flags); \ } while (0) #define MONO_EMIT_NEW_LOAD_MEMBASE_OP_FLAGS(cfg,op,dr,base,offset,ins_flags) do { \ - MonoInst *inst; \ + MonoInst *__inst; \ int __ins_flags = ins_flags; \ - if (__ins_flags & MONO_INST_FAULT) { \ + if (__ins_flags & MONO_INST_FAULT) { \ int __out_of_page = offset > mono_target_pagesize (); \ MONO_EMIT_NULL_CHECK ((cfg), (base), __out_of_page); \ - } \ - NEW_LOAD_MEMBASE ((cfg), (inst), (op), (dr), (base), (offset)); \ - inst->flags = (__ins_flags); \ - MONO_ADD_INS (cfg->cbb, inst); \ - } while (0) + } \ + NEW_LOAD_MEMBASE ((cfg), (__inst), (op), (dr), (base), (offset)); \ + __inst->flags = (__ins_flags); \ + MONO_ADD_INS (cfg->cbb, __inst); \ + } while (0) #define MONO_EMIT_NEW_LOAD_MEMBASE_FLAGS(cfg,dr,base,offset,ins_flags) MONO_EMIT_NEW_LOAD_MEMBASE_OP_FLAGS ((cfg), (OP_LOAD_MEMBASE), (dr), (base), (offset),(ins_flags)) @@ -942,12 +948,12 @@ static int ccount = 0; /* Default bounds check implementation for most architectures + llvm */ #define MONO_EMIT_DEFAULT_BOUNDS_CHECK(cfg, array_reg, offset, index_reg, fault, ex_name) do { \ - int _length_reg = alloc_ireg (cfg); \ + int __length_reg = alloc_ireg (cfg); \ if (fault) \ - MONO_EMIT_NEW_LOAD_MEMBASE_OP_FAULT (cfg, OP_LOADI4_MEMBASE, _length_reg, array_reg, offset); \ + MONO_EMIT_NEW_LOAD_MEMBASE_OP_FAULT (cfg, OP_LOADI4_MEMBASE, __length_reg, array_reg, offset); \ else \ - MONO_EMIT_NEW_LOAD_MEMBASE_OP_FLAGS (cfg, OP_LOADI4_MEMBASE, _length_reg, array_reg, offset, MONO_INST_INVARIANT_LOAD); \ - MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, _length_reg, index_reg); \ + MONO_EMIT_NEW_LOAD_MEMBASE_OP_FLAGS (cfg, OP_LOADI4_MEMBASE, __length_reg, array_reg, offset, MONO_INST_INVARIANT_LOAD); \ + MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, __length_reg, index_reg); \ MONO_EMIT_NEW_COND_EXC (cfg, LE_UN, ex_name); \ } while (0) @@ -988,7 +994,7 @@ mini_emit_bounds_check_offset (MonoCompile *cfg, int array_reg, int array_length * index_reg is the vreg holding the index */ #define MONO_EMIT_BOUNDS_CHECK(cfg, array_reg, array_type, array_length_field, index_reg) do { \ - mini_emit_bounds_check_offset ((cfg), (array_reg), MONO_STRUCT_OFFSET (array_type, array_length_field), (index_reg), NULL); \ - } while (0) + mini_emit_bounds_check_offset ((cfg), (array_reg), MONO_STRUCT_OFFSET (array_type, array_length_field), (index_reg), NULL); \ + } while (0) #endif diff --git a/src/mono/mono/mini/liveness.c b/src/mono/mono/mini/liveness.c index 866f10be6889f..5186178b16a18 100644 --- a/src/mono/mono/mini/liveness.c +++ b/src/mono/mono/mini/liveness.c @@ -162,12 +162,14 @@ visit_bb (MonoCompile *cfg, MonoBasicBlock *bb, MonoPtrSet *visited) int idx = var->inst_c0; MonoMethodVar *vi = MONO_VARINFO (cfg, idx); +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ cfg->varinfo [vi->idx]->flags |= MONO_INST_VOLATILE; if (SIZEOF_REGISTER == 4 && (var->type == STACK_I8 || (var->type == STACK_R8 && COMPILE_SOFT_FLOAT (cfg)))) { /* Make the component vregs volatile as well (#612206) */ get_vreg_to_inst (cfg, MONO_LVREG_LS (var->dreg))->flags |= MONO_INST_VOLATILE; get_vreg_to_inst (cfg, MONO_LVREG_MS (var->dreg))->flags |= MONO_INST_VOLATILE; } +MONO_RESTORE_WARNING } /* SREGS */ @@ -181,12 +183,14 @@ visit_bb (MonoCompile *cfg, MonoBasicBlock *bb, MonoPtrSet *visited) int idx = var->inst_c0; MonoMethodVar *vi = MONO_VARINFO (cfg, idx); +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ cfg->varinfo [vi->idx]->flags |= MONO_INST_VOLATILE; if (SIZEOF_REGISTER == 4 && (var->type == STACK_I8 || (var->type == STACK_R8 && COMPILE_SOFT_FLOAT (cfg)))) { /* Make the component vregs volatile as well (#612206) */ get_vreg_to_inst (cfg, MONO_LVREG_LS (var->dreg))->flags |= MONO_INST_VOLATILE; get_vreg_to_inst (cfg, MONO_LVREG_MS (var->dreg))->flags |= MONO_INST_VOLATILE; } +MONO_RESTORE_WARNING } } } @@ -1189,9 +1193,7 @@ mono_analyze_liveness_gc (MonoCompile *cfg) /* Process instructions backwards */ callsites = NULL; for (i = nins - 1; i >= 0; --i) { - MonoInst *ins = (MonoInst*)reverse [i]; - - update_liveness_gc (cfg, bb, ins, last_use, vreg_to_varinfo, &callsites); + update_liveness_gc (cfg, bb, (MonoInst*)reverse [i], last_use, vreg_to_varinfo, &callsites); } /* The callsites should already be sorted by pc offset because we added them backwards */ bb->gc_callsites = callsites; diff --git a/src/mono/mono/mini/llvm-runtime.cpp b/src/mono/mono/mini/llvm-runtime.cpp index f4092d444d320..fb71c89c9150c 100644 --- a/src/mono/mono/mini/llvm-runtime.cpp +++ b/src/mono/mono/mini/llvm-runtime.cpp @@ -10,6 +10,10 @@ extern "C" { +// Only called by C functions or LLVM IR generated by Mono cross compiler. +// 'mono_llvm_cpp_throw_exception': function assumed not to throw an exception but does. The function is extern "C" and /EHc was specified. +MONO_DISABLE_WARNING(4297) + void mono_llvm_cpp_throw_exception (void) { @@ -22,6 +26,8 @@ mono_llvm_cpp_throw_exception (void) throw ex; } +MONO_RESTORE_WARNING + void mono_llvm_cpp_catch_exception (MonoLLVMInvokeCallback cb, gpointer arg, gboolean *out_thrown) { diff --git a/src/mono/mono/mini/llvmonly-runtime.c b/src/mono/mono/mini/llvmonly-runtime.c index e2b64a3e2fe94..c0bc3b802b1e8 100644 --- a/src/mono/mono/mini/llvmonly-runtime.c +++ b/src/mono/mono/mini/llvmonly-runtime.c @@ -805,7 +805,6 @@ mini_llvmonly_init_delegate (MonoDelegate *del, MonoDelegateTrampInfo *info) ftndesc = info->invoke_impl; if (G_UNLIKELY (!ftndesc) || subtype != WRAPPER_SUBTYPE_NONE) { - ERROR_DECL (error); MonoMethod *invoke_impl = mono_marshal_get_delegate_invoke (info->invoke, del); gpointer arg = NULL; gpointer addr = mini_llvmonly_load_method (invoke_impl, FALSE, FALSE, &arg, error); diff --git a/src/mono/mono/mini/local-propagation.c b/src/mono/mono/mini/local-propagation.c index 8eb4db79b5581..fa8ae1e15d75f 100644 --- a/src/mono/mono/mini/local-propagation.c +++ b/src/mono/mono/mini/local-propagation.c @@ -66,7 +66,7 @@ compute_magic_unsigned (guint32 divisor) { int p; magu.addition = 0; - nc = -1 - (-divisor) % divisor; + nc = -1 - (-(gint32)divisor) % divisor; p = 31; q1 = 0x80000000 / nc; r1 = 0x80000000 - q1 * nc; @@ -840,8 +840,8 @@ reg_is_softreg (int reg, const char spec) static gboolean mono_is_simd_accessor (MonoInst *ins) { - switch (ins->opcode) { #ifdef MONO_ARCH_SIMD_INTRINSICS + switch (ins->opcode) { case OP_INSERT_I1: case OP_INSERT_I2: case OP_INSERT_I4: @@ -855,10 +855,12 @@ mono_is_simd_accessor (MonoInst *ins) case OP_INSERTX_R8_SLOW: case OP_INSERTX_I8_SLOW: return TRUE; -#endif default: return FALSE; } +#else + return FALSE; +#endif } /** @@ -962,12 +964,12 @@ mono_local_deadce (MonoCompile *cfg) MONO_INS_HAS_NO_SIDE_EFFECT (ins)) { /* Happens with CMOV instructions */ if (prev_f && prev_f->opcode == OP_ICOMPARE_IMM) { - MonoInst *prev = prev_f; + MonoInst *prev_ins = prev_f; /* * Can't use DELETE_INS since that would interfere with the * FOR_EACH_INS loop. */ - NULLIFY_INS (prev); + NULLIFY_INS (prev_ins); } //printf ("DEADCE: "); mono_print_ins (ins); MONO_DELETE_INS (bb, ins); diff --git a/src/mono/mono/mini/memory-access.c b/src/mono/mono/mini/memory-access.c index 8f610a7f7e8c0..9a7fc99c02b7c 100644 --- a/src/mono/mono/mini/memory-access.c +++ b/src/mono/mono/mini/memory-access.c @@ -51,6 +51,7 @@ mini_emit_memset (MonoCompile *cfg, int destreg, int offset, int size, int val, val_reg = alloc_preg (cfg); +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ if (SIZEOF_REGISTER == 8) MONO_EMIT_NEW_I8CONST (cfg, val_reg, val); else @@ -85,6 +86,7 @@ mini_emit_memset (MonoCompile *cfg, int destreg, int offset, int size, int val, size -= 8; } } +MONO_RESTORE_WARNING set_4: while (size >= 4) { @@ -118,6 +120,7 @@ mini_emit_memcpy (MonoCompile *cfg, int destreg, int doffset, int srcreg, int so g_assert (size < MAX_INLINE_COPY_SIZE); g_assert (align > 0); +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ if (align < TARGET_SIZEOF_VOID_P) { if (align == 4) goto copy_4; @@ -139,7 +142,6 @@ mini_emit_memcpy (MonoCompile *cfg, int destreg, int doffset, int srcreg, int so goto copy_4; } - if (SIZEOF_REGISTER == 8) { while (size >= 8) { cur_reg = alloc_preg (cfg); @@ -150,6 +152,7 @@ mini_emit_memcpy (MonoCompile *cfg, int destreg, int doffset, int srcreg, int so size -= 8; } } +MONO_RESTORE_WARNING copy_4: while (size >= 4) { diff --git a/src/mono/mono/mini/method-to-ir.c b/src/mono/mono/mini/method-to-ir.c index ea951a7565b70..688004b83f60f 100644 --- a/src/mono/mono/mini/method-to-ir.c +++ b/src/mono/mono/mini/method-to-ir.c @@ -85,6 +85,8 @@ #include "llvmonly-runtime.h" #include "mono/utils/mono-tls-inline.h" +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ + #define BRANCH_COST 10 #define CALL_COST 10 /* Used for the JIT */ @@ -455,22 +457,22 @@ mini_set_inline_failure (MonoCompile *cfg, const char *msg) */ #define UNVERIFIED do { \ if (cfg->gsharedvt) { \ - if (cfg->verbose_level > 2) \ + if (cfg->verbose_level > 2) \ printf ("gsharedvt method failed to verify, falling back to instantiation.\n"); \ mono_cfg_set_exception (cfg, MONO_EXCEPTION_GENERIC_SHARING_FAILED); \ - goto exception_exit; \ - } \ - break_on_unverified (); \ - goto unverified; \ + goto exception_exit; \ + } \ + break_on_unverified (); \ + goto unverified; \ } while (0) -#define GET_BBLOCK(cfg,tblock,ip) do { \ +#define GET_BBLOCK(cfg,tblock,ip) do { \ (tblock) = cfg->cil_offset_to_bb [(ip) - cfg->cil_start]; \ - if (!(tblock)) { \ + if (!(tblock)) { \ if ((ip) >= end || (ip) < header->code) UNVERIFIED; \ NEW_BBLOCK (cfg, (tblock)); \ - (tblock)->cil_code = (ip); \ - ADD_BBLOCK (cfg, (tblock)); \ + (tblock)->cil_code = (ip); \ + ADD_BBLOCK (cfg, (tblock)); \ } \ } while (0) @@ -517,47 +519,49 @@ add_widen_op (MonoCompile *cfg, MonoInst *ins, MonoInst **arg1_ref, MonoInst **a #endif } -#define ADD_UNOP(op) do { \ - MONO_INST_NEW (cfg, ins, (op)); \ - sp--; \ - ins->sreg1 = sp [0]->dreg; \ - type_from_op (cfg, ins, sp [0], NULL); \ - CHECK_TYPE (ins); \ - (ins)->dreg = alloc_dreg ((cfg), (MonoStackType)(ins)->type); \ - MONO_ADD_INS ((cfg)->cbb, (ins)); \ - *sp++ = mono_decompose_opcode (cfg, ins); \ +#define ADD_UNOP(op) do { \ + MONO_INST_NEW (cfg, ins, (op)); \ + sp--; \ + ins->sreg1 = sp [0]->dreg; \ + type_from_op (cfg, ins, sp [0], NULL); \ + CHECK_TYPE (ins); \ + (ins)->dreg = alloc_dreg ((cfg), (MonoStackType)(ins)->type); \ + MONO_ADD_INS ((cfg)->cbb, (ins)); \ + *sp++ = mono_decompose_opcode (cfg, ins); \ } while (0) -#define ADD_BINCOND(next_block) do { \ - MonoInst *cmp; \ +#define ADD_BINCOND(next_block) do { \ + MonoInst *cmp; \ sp -= 2; \ - MONO_INST_NEW(cfg, cmp, OP_COMPARE); \ - cmp->sreg1 = sp [0]->dreg; \ - cmp->sreg2 = sp [1]->dreg; \ - add_widen_op (cfg, cmp, &sp [0], &sp [1]); \ - type_from_op (cfg, cmp, sp [0], sp [1]); \ - CHECK_TYPE (cmp); \ - type_from_op (cfg, ins, sp [0], sp [1]); \ - ins->inst_many_bb = (MonoBasicBlock **)mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); \ - GET_BBLOCK (cfg, tblock, target); \ - link_bblock (cfg, cfg->cbb, tblock); \ - ins->inst_true_bb = tblock; \ - if ((next_block)) { \ - link_bblock (cfg, cfg->cbb, (next_block)); \ - ins->inst_false_bb = (next_block); \ - start_new_bblock = 1; \ - } else { \ - GET_BBLOCK (cfg, tblock, next_ip); \ - link_bblock (cfg, cfg->cbb, tblock); \ - ins->inst_false_bb = tblock; \ - start_new_bblock = 2; \ - } \ - if (sp != stack_start) { \ - handle_stack_args (cfg, stack_start, sp - stack_start); \ + MONO_INST_NEW(cfg, cmp, OP_COMPARE); \ + cmp->sreg1 = sp [0]->dreg; \ + cmp->sreg2 = sp [1]->dreg; \ + add_widen_op (cfg, cmp, &sp [0], &sp [1]); \ + type_from_op (cfg, cmp, sp [0], sp [1]); \ + CHECK_TYPE (cmp); \ + type_from_op (cfg, ins, sp [0], sp [1]); \ + ins->inst_many_bb = (MonoBasicBlock **)mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); \ + GET_BBLOCK (cfg, tblock, target); \ + link_bblock (cfg, cfg->cbb, tblock); \ + ins->inst_true_bb = tblock; \ + MONO_DISABLE_WARNING(4127) \ + if ((next_block)) { \ + link_bblock (cfg, cfg->cbb, (next_block)); \ + ins->inst_false_bb = (next_block); \ + start_new_bblock = 1; \ + } else { \ + GET_BBLOCK (cfg, tblock, next_ip); \ + link_bblock (cfg, cfg->cbb, tblock); \ + ins->inst_false_bb = tblock; \ + start_new_bblock = 2; \ + } \ + MONO_RESTORE_WARNING \ + if (sp != stack_start) { \ + handle_stack_args (cfg, stack_start, sp - stack_start); \ CHECK_UNVERIFIABLE (cfg); \ } \ - MONO_ADD_INS (cfg->cbb, cmp); \ - MONO_ADD_INS (cfg->cbb, ins); \ + MONO_ADD_INS (cfg->cbb, cmp); \ + MONO_ADD_INS (cfg->cbb, ins); \ } while (0) /* * @@ -666,11 +670,10 @@ mark_bb_in_region (MonoCompile *cfg, guint region, uint32_t start, uint32_t end) static void compute_bb_regions (MonoCompile *cfg) { - MonoBasicBlock *bb; MonoMethodHeader *header = cfg->header; int i; - for (bb = cfg->bb_entry; bb; bb = bb->next_bb) + for (MonoBasicBlock *bb = cfg->bb_entry; bb; bb = bb->next_bb) bb->region = -1; for (i = 0; i < header->num_clauses; ++i) { @@ -692,8 +695,7 @@ compute_bb_regions (MonoCompile *cfg) } if (cfg->verbose_level > 2) { - MonoBasicBlock *bb; - for (bb = cfg->bb_entry; bb; bb = bb->next_bb) + for (MonoBasicBlock *bb = cfg->bb_entry; bb; bb = bb->next_bb) g_print ("REGION BB%d IL_%04x ID_%08X\n", bb->block_num, bb->real_offset, bb->region); } @@ -3278,7 +3280,7 @@ handle_unbox_gsharedvt (MonoCompile *cfg, MonoClass *klass, MonoInst *obj) MONO_START_BB (cfg, is_nullable_bb); { - MonoInst *addr = mini_emit_get_gsharedvt_info_klass (cfg, klass, MONO_RGCTX_INFO_NULLABLE_CLASS_UNBOX); + MonoInst *unbox_addr = mini_emit_get_gsharedvt_info_klass (cfg, klass, MONO_RGCTX_INFO_NULLABLE_CLASS_UNBOX); MonoInst *unbox_call; MonoMethodSignature *unbox_sig; @@ -3288,12 +3290,12 @@ handle_unbox_gsharedvt (MonoCompile *cfg, MonoClass *klass, MonoInst *obj) unbox_sig->params [0] = mono_get_object_type (); if (cfg->llvm_only) - unbox_call = mini_emit_llvmonly_calli (cfg, unbox_sig, &obj, addr); + unbox_call = mini_emit_llvmonly_calli (cfg, unbox_sig, &obj, unbox_addr ); else - unbox_call = mini_emit_calli (cfg, unbox_sig, &obj, addr, NULL, NULL); + unbox_call = mini_emit_calli (cfg, unbox_sig, &obj, unbox_addr , NULL, NULL); - EMIT_NEW_VARLOADA_VREG (cfg, addr, unbox_call->dreg, m_class_get_byval_arg (klass)); - addr->dreg = addr_reg; + EMIT_NEW_VARLOADA_VREG (cfg, unbox_addr , unbox_call->dreg, m_class_get_byval_arg (klass)); + unbox_addr ->dreg = addr_reg; } MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, end_bb); @@ -3465,7 +3467,7 @@ mini_emit_box (MonoCompile *cfg, MonoInst *val, MonoClass *klass, int context_us MONO_START_BB (cfg, is_nullable_bb); { - MonoInst *addr = mini_emit_get_gsharedvt_info_klass (cfg, klass, + MonoInst *box_addr = mini_emit_get_gsharedvt_info_klass (cfg, klass, MONO_RGCTX_INFO_NULLABLE_CLASS_BOX); MonoInst *box_call; MonoMethodSignature *box_sig; @@ -3480,9 +3482,9 @@ mini_emit_box (MonoCompile *cfg, MonoInst *val, MonoClass *klass, int context_us box_sig->params [0] = m_class_get_byval_arg (klass); if (cfg->llvm_only) - box_call = mini_emit_llvmonly_calli (cfg, box_sig, &val, addr); + box_call = mini_emit_llvmonly_calli (cfg, box_sig, &val, box_addr); else - box_call = mini_emit_calli (cfg, box_sig, &val, addr, NULL, NULL); + box_call = mini_emit_calli (cfg, box_sig, &val, box_addr, NULL, NULL); EMIT_NEW_UNALU (cfg, res, OP_MOVE, dreg, box_call->dreg); res->type = STACK_OBJ; res->klass = klass; @@ -4429,7 +4431,7 @@ mini_emit_array_store (MonoCompile *cfg, MonoClass *klass, MonoInst **sp, gboole if (safety_checks) MONO_EMIT_BOUNDS_CHECK (cfg, array_reg, MonoArray, max_length, index_reg); - EMIT_NEW_STORE_MEMBASE_TYPE (cfg, ins, m_class_get_byval_arg (klass), array_reg, offset, sp [2]->dreg); + EMIT_NEW_STORE_MEMBASE_TYPE (cfg, ins, m_class_get_byval_arg (klass), array_reg, (target_mgreg_t)offset, sp [2]->dreg); } else { MonoInst *addr = mini_emit_ldelema_1_ins (cfg, klass, sp [0], sp [1], safety_checks, FALSE); if (!mini_debug_options.weak_memory_model && mini_class_is_reference (klass)) @@ -5837,7 +5839,7 @@ handle_constrained_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignat } else if (need_box) { MonoInst *box_type; MonoBasicBlock *is_ref_bb, *end_bb; - MonoInst *nonbox_call, *addr; + MonoInst *nonbox_call, *nonbox_addr; /* * Determine at runtime whenever the called method is defined on object/valuetype/enum, and emit a boxing call @@ -5845,7 +5847,7 @@ handle_constrained_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignat * FIXME: It is possible to inline the called method in a lot of cases, i.e. for T_INT, * the no-box case goes to a method in Int32, while the box case goes to a method in Enum. */ - addr = emit_get_rgctx_virt_method (cfg, mono_class_check_context_used (constrained_class), constrained_class, cmethod, MONO_RGCTX_INFO_VIRT_METHOD_CODE); + nonbox_addr = emit_get_rgctx_virt_method (cfg, mono_class_check_context_used (constrained_class), constrained_class, cmethod, MONO_RGCTX_INFO_VIRT_METHOD_CODE); NEW_BBLOCK (cfg, is_ref_bb); NEW_BBLOCK (cfg, end_bb); @@ -5856,10 +5858,10 @@ handle_constrained_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignat /* Non-ref case */ if (cfg->llvm_only) - /* addr is an ftndesc in this case */ - nonbox_call = mini_emit_llvmonly_calli (cfg, fsig, sp, addr); + /* nonbox_addr is an ftndesc in this case */ + nonbox_call = mini_emit_llvmonly_calli (cfg, fsig, sp, nonbox_addr); else - nonbox_call = (MonoInst*)mini_emit_calli (cfg, fsig, sp, addr, NULL, NULL); + nonbox_call = (MonoInst*)mini_emit_calli (cfg, fsig, sp, nonbox_addr, NULL, NULL); MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, end_bb); @@ -5870,9 +5872,9 @@ handle_constrained_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignat sp [0] = mini_emit_box (cfg, ins, constrained_class, mono_class_check_context_used (constrained_class)); CHECK_CFG_EXCEPTION; if (cfg->llvm_only) - ins = mini_emit_llvmonly_calli (cfg, fsig, sp, addr); + ins = mini_emit_llvmonly_calli (cfg, fsig, sp, nonbox_addr); else - ins = (MonoInst*)mini_emit_calli (cfg, fsig, sp, addr, NULL, NULL); + ins = (MonoInst*)mini_emit_calli (cfg, fsig, sp, nonbox_addr, NULL, NULL); MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, end_bb); @@ -6004,7 +6006,7 @@ emit_llvmonly_interp_entry (MonoCompile *cfg, MonoMethodHeader *header) MONO_ADD_INS (cfg->cbb, ins); args_ins = ins; - for (int i = 0; i < sig->hasthis + sig->param_count; ++i) { + for (unsigned int i = 0; i < sig->hasthis + sig->param_count; ++i) { MonoInst *arg_addr_ins; EMIT_NEW_VARLOADA ((cfg), arg_addr_ins, cfg->args [i], cfg->arg_types [i]); EMIT_NEW_STORE_MEMBASE (cfg, ins, OP_STORE_MEMBASE_REG, args_ins->dreg, i * sizeof (target_mgreg_t), arg_addr_ins->dreg); @@ -6035,7 +6037,7 @@ emit_llvmonly_interp_entry (MonoCompile *cfg, MonoMethodHeader *header) /* Call it */ iargs = g_newa (MonoInst*, sig->param_count + 1); - for (int i = 0; i < sig->param_count + sig->hasthis; ++i) + for (unsigned int i = 0; i < sig->param_count + sig->hasthis; ++i) EMIT_NEW_ARGLOAD (cfg, iargs [i], i); ins = mini_emit_llvmonly_calli (cfg, sig, iargs, ftndesc); @@ -6208,7 +6210,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b MonoGenericContext *generic_context = NULL; MonoGenericContainer *generic_container = NULL; MonoType **param_types; - int i, n, start_new_bblock, dreg; + int n, start_new_bblock; int num_calls = 0, inline_costs = 0; guint num_args; GSList *class_inits = NULL; @@ -6286,13 +6288,13 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b minfo = mono_debug_lookup_method (method); if (minfo) { MonoSymSeqPoint *sps; - int i, n_il_offsets; + int n_il_offsets; mono_debug_get_seq_points (minfo, NULL, NULL, NULL, &sps, &n_il_offsets); seq_point_locs = mono_bitset_mem_new (mono_mempool_alloc0 (cfg->mempool, mono_bitset_alloc_size (header->code_size, 0)), header->code_size, 0); seq_point_set_locs = mono_bitset_mem_new (mono_mempool_alloc0 (cfg->mempool, mono_bitset_alloc_size (header->code_size, 0)), header->code_size, 0); sym_seq_points = TRUE; - for (i = 0; i < n_il_offsets; ++i) { + for (int i = 0; i < n_il_offsets; ++i) { if (sps [i].il_offset < header->code_size) mono_bitset_set_fast (seq_point_locs, sps [i].il_offset); } @@ -6300,7 +6302,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b MonoDebugMethodAsyncInfo* asyncMethod = mono_debug_lookup_method_async_debug_info (method); if (asyncMethod) { - for (i = 0; asyncMethod != NULL && i < asyncMethod->num_awaits; i++) + for (int i = 0; asyncMethod != NULL && i < asyncMethod->num_awaits; i++) { mono_bitset_set_fast (seq_point_locs, asyncMethod->resume_offsets[i]); mono_bitset_set_fast (seq_point_locs, asyncMethod->yield_offsets[i]); @@ -6392,7 +6394,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b cfg->clause_is_dead = mono_mempool_alloc0 (cfg->mempool, sizeof (gboolean) * header->num_clauses); /* handle exception clauses */ - for (i = 0; i < header->num_clauses; ++i) { + for (unsigned int i = 0; i < header->num_clauses; ++i) { MonoBasicBlock *try_bb; MonoExceptionClause *clause = &header->clauses [i]; GET_BBLOCK (cfg, try_bb, ip + clause->try_offset); @@ -6787,7 +6789,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b cfg->cbb->next_bb = tblock; cfg->cbb = tblock; start_new_bblock = 0; - for (i = 0; i < cfg->cbb->in_scount; ++i) { + for (int i = 0; i < cfg->cbb->in_scount; ++i) { if (cfg->verbose_level > 3) printf ("loading %d from temp %d\n", i, (int)cfg->cbb->in_stack [i]->inst_c0); EMIT_NEW_TEMPLOAD (cfg, ins, cfg->cbb->in_stack [i]->inst_c0); @@ -6807,7 +6809,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b } cfg->cbb->next_bb = tblock; cfg->cbb = tblock; - for (i = 0; i < cfg->cbb->in_scount; ++i) { + for (int i = 0; i < cfg->cbb->in_scount; ++i) { if (cfg->verbose_level > 3) printf ("loading %d from temp %d\n", i, (int)cfg->cbb->in_stack [i]->inst_c0); EMIT_NEW_TEMPLOAD (cfg, ins, cfg->cbb->in_stack [i]->inst_c0); @@ -6910,7 +6912,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b */ ins_has_side_effect = TRUE; - // Variables shared by CEE_CALLI CEE_CALL CEE_CALLVIRT CEE_JMP. + // Variables shared by CEE_CALLI CEE_CALL CEE_CALLVIRT CEE_JMP MONO_CEE_MONO_ICALL_ADDR MONO_CEE_MONO_CALLI_EXTRA_ARG. // Initialize to either what they all need or zero. gboolean emit_widen = TRUE; gboolean tailcall = FALSE; @@ -7034,11 +7036,11 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b break; case MONO_CEE_LDLOCA: case MONO_CEE_LDLOCA_S: { - guchar *tmp_ip; + guchar *ldloca_ip; CHECK_LOCAL (n); - if ((tmp_ip = emit_optimized_ldloca_ir (cfg, next_ip, end, n))) { - next_ip = tmp_ip; + if ((ldloca_ip = emit_optimized_ldloca_ir (cfg, next_ip, end, n))) { + next_ip = ldloca_ip; il_op = MONO_CEE_INITOBJ; inline_costs += 1; break; @@ -7144,7 +7146,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b } case MONO_CEE_DUP: { MonoInst *temp, *store; - MonoClass *klass; sp--; ins = *sp; klass = ins->klass; @@ -7174,7 +7175,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b break; case MONO_CEE_JMP: { MonoCallInst *call; - int i, n; INLINE_FAILURE ("jmp"); GSHAREDVT_FAILURE (il_op); @@ -7191,12 +7191,12 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b mini_profiler_emit_tail_call (cfg, cmethod); fsig = mono_method_signature_internal (cmethod); - n = fsig->param_count + fsig->hasthis; + int nargs = fsig->param_count + fsig->hasthis; if (cfg->llvm_only) { MonoInst **args; - args = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * n); - for (i = 0; i < n; ++i) + args = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * nargs); + for (int i = 0; i < nargs; ++i) EMIT_NEW_ARGLOAD (cfg, args [i], i); ins = mini_emit_method_call_full (cfg, cmethod, fsig, TRUE, args, NULL, NULL, NULL); /* @@ -7221,9 +7221,9 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b // it is used. So this is the only "real" use and needs more attention. call->tailcall = TRUE; call->signature = fsig; - call->args = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * n); + call->args = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * nargs); call->inst.inst_p0 = cmethod; - for (i = 0; i < n; ++i) + for (int i = 0; i < nargs; ++i) EMIT_NEW_ARGLOAD (cfg, call->args [i], i); if (mini_type_is_vtype (mini_get_underlying_type (call->signature->ret))) @@ -7432,6 +7432,10 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b gboolean inst_tailcall; inst_tailcall = G_UNLIKELY (debug_tailcall_try_all ? (next_ip < end && next_ip [0] == CEE_RET) : ((ins_flag & MONO_INST_TAILCALL) != 0)); + + gboolean make_generic_call_out_of_gsharedvt_method = FALSE; + gboolean will_have_imt_arg = FALSE; + ins = NULL; /* Used to pass arguments to called functions */ @@ -7578,8 +7582,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b sp -= n; if (virtual_ && cmethod && sp [0] && sp [0]->opcode == OP_TYPED_OBJREF) { - ERROR_DECL (error); - + error_init_reuse (error); MonoMethod *new_cmethod = mono_class_get_virtual_method (sp [0]->klass, cmethod, error); if (is_ok (error)) { cmethod = new_cmethod; @@ -7819,14 +7822,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b } } - // Capture some intent before computing tailcall. - - gboolean make_generic_call_out_of_gsharedvt_method; - gboolean will_have_imt_arg; - - make_generic_call_out_of_gsharedvt_method = FALSE; - will_have_imt_arg = FALSE; - /* * Making generic calls out of gsharedvt methods. * This needs to be used for all generic calls, not just ones with a gsharedvt signature, to avoid @@ -8101,7 +8096,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b /* Array methods */ if (array_rank) { - MonoInst *addr; + MonoInst *ldelema_addr; if (strcmp (cmethod->name, "Set") == 0) { /* array Set */ MonoInst *val = sp [fsig->param_count]; @@ -8111,26 +8106,26 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b mono_emit_jit_icall (cfg, mono_helper_stelem_ref_check, iargs); } - addr = mini_emit_ldelema_ins (cfg, cmethod, sp, ip, TRUE); + ldelema_addr = mini_emit_ldelema_ins (cfg, cmethod, sp, ip, TRUE); if (!mini_debug_options.weak_memory_model && val->type == STACK_OBJ) mini_emit_memory_barrier (cfg, MONO_MEMORY_BARRIER_REL); - EMIT_NEW_STORE_MEMBASE_TYPE (cfg, ins, fsig->params [fsig->param_count - 1], addr->dreg, 0, val->dreg); + EMIT_NEW_STORE_MEMBASE_TYPE (cfg, ins, fsig->params [fsig->param_count - 1], ldelema_addr->dreg, 0, val->dreg); if (cfg->gen_write_barriers && val->type == STACK_OBJ && !MONO_INS_IS_PCONST_NULL (val)) - mini_emit_write_barrier (cfg, addr, val); + mini_emit_write_barrier (cfg, ldelema_addr, val); if (cfg->gen_write_barriers && mini_is_gsharedvt_klass (cmethod->klass)) GSHAREDVT_FAILURE (il_op); } else if (strcmp (cmethod->name, "Get") == 0) { /* array Get */ - addr = mini_emit_ldelema_ins (cfg, cmethod, sp, ip, FALSE); + ldelema_addr = mini_emit_ldelema_ins (cfg, cmethod, sp, ip, FALSE); - EMIT_NEW_LOAD_MEMBASE_TYPE (cfg, ins, fsig->ret, addr->dreg, 0); + EMIT_NEW_LOAD_MEMBASE_TYPE (cfg, ins, fsig->ret, ldelema_addr->dreg, 0); } else if (strcmp (cmethod->name, "Address") == 0) { /* array Address */ if (!m_class_is_valuetype (m_class_get_element_class (cmethod->klass)) && !readonly) mini_emit_check_array_type (cfg, sp [0], cmethod->klass); CHECK_TYPELOAD (cmethod->klass); readonly = FALSE; - addr = mini_emit_ldelema_ins (cfg, cmethod, sp, ip, FALSE); - ins = addr; + ldelema_addr = mini_emit_ldelema_ins (cfg, cmethod, sp, ip, FALSE); + ins = ldelema_addr; } else { g_assert_not_reached (); } @@ -8513,7 +8508,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b default_bblock->flags |= BB_INDIRECT_JUMP_TARGET; targets = (MonoBasicBlock **)mono_mempool_alloc (cfg->mempool, sizeof (MonoBasicBlock*) * n); - for (i = 0; i < n; ++i) { + for (int i = 0; i < n; ++i) { GET_BBLOCK (cfg, tblock, next_ip + (gint32)read32 (ip)); targets [i] = tblock; targets [i]->flags |= BB_INDIRECT_JUMP_TARGET; @@ -8526,7 +8521,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b * will set their in_stack correctly. */ link_bblock (cfg, cfg->cbb, default_bblock); - for (i = 0; i < n; ++i) + for (int i = 0; i < n; ++i) link_bblock (cfg, cfg->cbb, targets [i]); handle_stack_args (cfg, stack_start, sp - stack_start); @@ -8535,14 +8530,14 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b /* Undo the links */ mono_unlink_bblock (cfg, cfg->cbb, default_bblock); - for (i = 0; i < n; ++i) + for (int i = 0; i < n; ++i) mono_unlink_bblock (cfg, cfg->cbb, targets [i]); } MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ICOMPARE_IMM, -1, src1->dreg, n); MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_IBGE_UN, default_bblock); - for (i = 0; i < n; ++i) + for (int i = 0; i < n; ++i) link_bblock (cfg, cfg->cbb, targets [i]); table = (MonoJumpInfoBBTable *)mono_mempool_alloc (cfg->mempool, sizeof (MonoJumpInfoBBTable)); @@ -8639,7 +8634,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b inline_costs += 1; break; } - case MONO_CEE_MUL: + case MONO_CEE_MUL: { MONO_INST_NEW (cfg, ins, il_op); sp -= 2; ins->sreg1 = sp [0]->dreg; @@ -8665,6 +8660,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b *sp++ = mono_decompose_opcode (cfg, ins); break; + } case MONO_CEE_ADD: case MONO_CEE_SUB: case MONO_CEE_DIV: @@ -8970,7 +8966,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b break; case MONO_CEE_NEWOBJ: { MonoInst *iargs [2]; - MonoMethodSignature *fsig; MonoInst this_ins; MonoInst *alloc; MonoInst *vtable_arg = NULL; @@ -9027,23 +9022,23 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b is_exception_class (cmethod->klass) && n <= 2 && ((n < 1) || (!m_type_is_byref (fsig->params [0]) && fsig->params [0]->type == MONO_TYPE_STRING)) && ((n < 2) || (!m_type_is_byref (fsig->params [1]) && fsig->params [1]->type == MONO_TYPE_STRING))) { - MonoInst *iargs [3]; + MonoInst *ex_iargs [3]; sp -= n; - EMIT_NEW_ICONST (cfg, iargs [0], m_class_get_type_token (cmethod->klass)); + EMIT_NEW_ICONST (cfg, ex_iargs [0], m_class_get_type_token (cmethod->klass)); switch (n) { case 0: - *sp ++ = mono_emit_jit_icall (cfg, mono_create_corlib_exception_0, iargs); + *sp ++ = mono_emit_jit_icall (cfg, mono_create_corlib_exception_0, ex_iargs); break; case 1: - iargs [1] = sp [0]; - *sp ++ = mono_emit_jit_icall (cfg, mono_create_corlib_exception_1, iargs); + ex_iargs [1] = sp [0]; + *sp ++ = mono_emit_jit_icall (cfg, mono_create_corlib_exception_1, ex_iargs); break; case 2: - iargs [1] = sp [0]; - iargs [2] = sp [1]; - *sp ++ = mono_emit_jit_icall (cfg, mono_create_corlib_exception_2, iargs); + ex_iargs [1] = sp [0]; + ex_iargs [2] = sp [1]; + *sp ++ = mono_emit_jit_icall (cfg, mono_create_corlib_exception_2, ex_iargs); break; default: g_assert_not_reached (); @@ -9075,10 +9070,10 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b cmethod, MONO_RGCTX_INFO_METHOD); MonoJitICallId function = MONO_JIT_ICALL_ZeroIsReserved; int rank = m_class_get_rank (cmethod->klass); - int n = fsig->param_count; + int param_count = fsig->param_count; /* Optimize the common cases, use ctor using length for each rank (no lbound). */ - if (n == rank) { - switch (n) { + if (param_count == rank) { + switch (param_count) { case 1: function = MONO_JIT_ICALL_mono_array_new_1; break; case 2: function = MONO_JIT_ICALL_mono_array_new_2; @@ -9101,9 +9096,9 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b cfg->flags |= MONO_CFG_HAS_ALLOCA; MONO_ADD_INS (init_localsbb, array_new_localalloc_ins); } - array_new_localalloc_ins->inst_imm = MAX (array_new_localalloc_ins->inst_imm, n * sizeof (target_mgreg_t)); + array_new_localalloc_ins->inst_imm = MAX (array_new_localalloc_ins->inst_imm, param_count * sizeof (target_mgreg_t)); int dreg = array_new_localalloc_ins->dreg; - if (2 * rank == n) { + if (2 * rank == param_count) { /* [lbound, length, lbound, length, ...] * mono_array_new_n_icall expects a non-interleaved list of * lbounds and lengths, so deinterleave here. @@ -9118,17 +9113,17 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b } } else { /* [length, length, length, ...] */ - for (int i = 0; i < n; ++i) { + for (int i = 0; i < param_count; ++i) { NEW_STORE_MEMBASE (cfg, ins, OP_STORE_MEMBASE_REG, dreg, i * sizeof (target_mgreg_t), sp [i + 1]->dreg); MONO_ADD_INS (cfg->cbb, ins); } } - EMIT_NEW_ICONST (cfg, ins, n); + EMIT_NEW_ICONST (cfg, ins, param_count); sp [1] = ins; EMIT_NEW_UNALU (cfg, ins, OP_MOVE, alloc_preg (cfg), dreg); ins->type = STACK_PTR; sp [2] = ins; - // FIXME Adjust sp by n - 3? Attempts failed. + // FIXME Adjust sp by param_count - 3? Attempts failed. function = MONO_JIT_ICALL_mono_array_new_n_icall; } alloc = mono_emit_jit_icall_id (cfg, function, sp); @@ -9465,7 +9460,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b // // ldc.i4.0 (or 1) // - guchar* ldnull_ip = NULL; + ldnull_ip = NULL; if ((ldnull_ip = il_read_op (ip, end, CEE_LDNULL, MONO_CEE_LDNULL)) && ip_in_bb (cfg, cfg->cbb, ldnull_ip)) { gboolean is_eq = FALSE, is_neq = FALSE; if ((ip = il_read_op (ldnull_ip, end, CEE_PREFIX1, MONO_CEE_CEQ))) @@ -9732,7 +9727,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b offset_ins = emit_get_gsharedvt_info (cfg, field, MONO_RGCTX_INFO_FIELD_OFFSET); /* The value is offset by 1 */ EMIT_NEW_BIALU_IMM (cfg, ins, OP_PSUB_IMM, offset_ins->dreg, offset_ins->dreg, 1); - dreg = alloc_ireg_mp (cfg); + int dreg = alloc_ireg_mp (cfg); EMIT_NEW_BIALU (cfg, ins, OP_PADD, dreg, sp [0]->dreg, offset_ins->dreg); if (cfg->gen_write_barriers && mini_type_to_stind (cfg, field->type) == CEE_STIND_REF && !MONO_INS_IS_PCONST_NULL (sp [1])) { store = mini_emit_storing_write_barrier (cfg, ins, sp [1]); @@ -9784,7 +9779,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b MONO_EMIT_NEW_COND_EXC (cfg, EQ, "NullReferenceException"); } - dreg = alloc_ireg_mp (cfg); + int dreg = alloc_ireg_mp (cfg); if (mini_is_gsharedvt_klass (klass)) { MonoInst *offset_ins; @@ -9949,7 +9944,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b offset_ins = emit_get_rgctx_field (cfg, context_used, field, MONO_RGCTX_INFO_FIELD_OFFSET); /* The value is offset by 1 */ EMIT_NEW_BIALU_IMM (cfg, ins, OP_PSUB_IMM, offset_ins->dreg, offset_ins->dreg, 1); - dreg = alloc_ireg_mp (cfg); + int dreg = alloc_ireg_mp (cfg); EMIT_NEW_BIALU (cfg, ins, OP_PADD, dreg, static_data->dreg, offset_ins->dreg); } else if (field->offset == 0) { ins = static_data; @@ -10031,8 +10026,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b } else { gboolean is_const = FALSE; MonoVTable *vtable = NULL; - gpointer addr = NULL; - + + addr = NULL; if (!context_used) { vtable = mono_class_vtable_checked (klass, cfg->error); CHECK_CFG_ERROR; @@ -10339,7 +10334,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b MONO_EMIT_NEW_UNALU (cfg, OP_ZEXT_I4, index_reg, index_reg); MONO_EMIT_BOUNDS_CHECK (cfg, array_reg, MonoArray, max_length, index_reg); - EMIT_NEW_LOAD_MEMBASE_TYPE (cfg, ins, m_class_get_byval_arg (klass), array_reg, offset); + EMIT_NEW_LOAD_MEMBASE_TYPE (cfg, ins, m_class_get_byval_arg (klass), array_reg, (target_mgreg_t)offset); } else { addr = mini_emit_ldelema_1_ins (cfg, klass, sp [0], sp [1], TRUE, FALSE); EMIT_NEW_LOAD_MEMBASE_TYPE (cfg, ins, m_class_get_byval_arg (klass), addr->dreg, 0); @@ -10647,7 +10642,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b * We avoid doing this in runtime invoke wrappers, since those are called * by native code which excepts the wrapper to catch all exceptions. */ - for (i = 0; i < header->num_clauses; ++i) { + for (unsigned int i = 0; i < header->num_clauses; ++i) { MonoExceptionClause *clause = &header->clauses [i]; /* @@ -10765,10 +10760,10 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b case MONO_CEE_MONO_ICALL: { g_assert (method->wrapper_type != MONO_WRAPPER_NONE); const MonoJitICallId jit_icall_id = (MonoJitICallId)token; - MonoJitICallInfo * const info = mono_find_jit_icall_info (jit_icall_id); + MonoJitICallInfo * const jit_icall_info = mono_find_jit_icall_info (jit_icall_id); - CHECK_STACK (info->sig->param_count); - sp -= info->sig->param_count; + CHECK_STACK (jit_icall_info->sig->param_count); + sp -= jit_icall_info->sig->param_count; if (token == MONO_JIT_ICALL_mono_threads_attach_coop) { MonoInst *addr; @@ -10781,7 +10776,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b * instead. */ EMIT_NEW_AOTCONST (cfg, addr, MONO_PATCH_INFO_JIT_ICALL_ADDR_NOCALL, GUINT_TO_POINTER (jit_icall_id)); - ins = mini_emit_calli (cfg, info->sig, sp, addr, NULL, NULL); + ins = mini_emit_calli (cfg, jit_icall_info->sig, sp, addr, NULL, NULL); } else { ins = mono_emit_jit_icall_id (cfg, jit_icall_id, sp); } @@ -10802,7 +10797,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b ins = mono_emit_jit_icall_id (cfg, jit_icall_id, sp); } - if (!MONO_TYPE_IS_VOID (info->sig->ret)) + if (!MONO_TYPE_IS_VOID (jit_icall_info->sig->ret)) *sp++ = ins; inline_costs += CALL_COST * MIN(10, num_calls++); @@ -10852,7 +10847,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b break; case MONO_CEE_MONO_ICALL_ADDR: { - MonoMethod *cmethod; gpointer ptr; g_assert (method->wrapper_type != MONO_WRAPPER_NONE); @@ -11071,14 +11065,13 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b CHECK_STACK (1); --sp; - dreg = alloc_preg (cfg); + int dreg = alloc_preg (cfg); EMIT_NEW_LOAD_MEMBASE (cfg, ins, OP_LOAD_MEMBASE, dreg, sp [0]->dreg, MONO_STRUCT_OFFSET (MonoDelegate, method_ptr)); *sp++ = ins; break; } case MONO_CEE_MONO_CALLI_EXTRA_ARG: { MonoInst *addr; - MonoMethodSignature *fsig; MonoInst *arg; /* @@ -11632,7 +11625,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b MonoInst *load; int handler_offset = -1; - for (i = 0; i < header->num_clauses; ++i) { + for (unsigned int i = 0; i < header->num_clauses; ++i) { MonoExceptionClause *clause = &header->clauses [i]; if (MONO_OFFSET_IN_HANDLER (clause, ip - header->code) && !(clause->flags & MONO_EXCEPTION_CLAUSE_FINALLY)) { handler_offset = clause->handler_offset; @@ -11689,7 +11682,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b val = mono_type_size (type, &ialign); EMIT_NEW_ICONST (cfg, ins, val); } else { - MonoClass *klass = mini_get_class (method, token, generic_context); + klass = mini_get_class (method, token, generic_context); CHECK_TYPELOAD (klass); if (mini_is_gsharedvt_klass (klass)) { @@ -11747,11 +11740,11 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b cfg->cbb->cil_length = ip - cfg->cbb->cil_code; if (cfg->cbb->next_bb) { /* This could already be set because of inlining, #693905 */ - MonoBasicBlock *bb = cfg->cbb; + MonoBasicBlock *cbb = cfg->cbb; - while (bb->next_bb) - bb = bb->next_bb; - bb->next_bb = end_bblock; + while (cbb->next_bb) + cbb = cbb->next_bb; + cbb->next_bb = end_bblock; } else { cfg->cbb->next_bb = end_bblock; } @@ -11778,7 +11771,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b if (init_localsbb) { cfg->cbb = init_localsbb; cfg->ip = NULL; - for (i = 0; i < header->num_locals; ++i) { + for (int i = 0; i < header->num_locals; ++i) { /* * Vtype initialization might need to be done after CEE_JIT_ATTACH, since it can make calls to memset (), * which need the trampoline code to work. @@ -11794,11 +11787,11 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b if (cfg->init_ref_vars && cfg->method == method) { /* Emit initialization for ref vars */ // FIXME: Avoid duplication initialization for IL locals. - for (i = 0; i < cfg->num_varinfo; ++i) { - MonoInst *ins = cfg->varinfo [i]; + for (guint i = 0; i < cfg->num_varinfo; ++i) { + MonoInst *var_ins = cfg->varinfo [i]; - if (ins->opcode == OP_LOCAL && ins->type == STACK_OBJ) - MONO_EMIT_NEW_PCONST (cfg, ins->dreg, NULL); + if (var_ins->opcode == OP_LOCAL && var_ins->type == STACK_OBJ) + MONO_EMIT_NEW_PCONST (cfg, var_ins->dreg, NULL); } } @@ -11813,14 +11806,14 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b cfg->cbb = init_localsbb; if (seq_points) { - MonoBasicBlock *bb; + MonoBasicBlock *cbb; /* * Make seq points at backward branch targets interruptable. */ - for (bb = cfg->bb_entry; bb; bb = bb->next_bb) - if (bb->code && bb->in_count > 1 && bb->code->opcode == OP_SEQ_POINT) - bb->code->flags |= MONO_INST_SINGLE_STEP_LOC; + for (cbb = cfg->bb_entry; cbb; cbb = cbb->next_bb) + if (cbb->code && cbb->in_count > 1 && cbb->code->opcode == OP_SEQ_POINT) + cbb->code->flags |= MONO_INST_SINGLE_STEP_LOC; } /* Add a sequence point for method entry/exit events */ @@ -11836,12 +11829,12 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b * the code they refer to was dead (#11880). */ if (sym_seq_points) { - for (i = 0; i < header->code_size; ++i) { + for (guint32 i = 0; i < header->code_size; ++i) { if (mono_bitset_test_fast (seq_point_locs, i) && !mono_bitset_test_fast (seq_point_set_locs, i)) { - MonoInst *ins; + MonoInst *seq_point_ins; - NEW_SEQ_POINT (cfg, ins, i, FALSE); - mono_add_seq_point (cfg, NULL, ins, SEQ_POINT_NATIVE_OFFSET_DEAD_CODE); + NEW_SEQ_POINT (cfg, seq_point_ins, i, FALSE); + mono_add_seq_point (cfg, NULL, seq_point_ins, SEQ_POINT_NATIVE_OFFSET_DEAD_CODE); } } } @@ -11851,10 +11844,10 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b if (cfg->method == method) { compute_bb_regions (cfg); } else { - MonoBasicBlock *bb; + MonoBasicBlock *cbb; /* get_most_deep_clause () in mini-llvm.c depends on this for inlined bblocks */ - for (bb = start_bblock; bb != end_bblock; bb = bb->next_bb) { - bb->real_offset = inline_offset; + for (cbb = start_bblock; cbb != end_bblock; cbb = cbb->next_bb) { + cbb->real_offset = inline_offset; } } diff --git a/src/mono/mono/mini/mini-amd64.c b/src/mono/mono/mini/mini-amd64.c index 2bbfa793b379d..c405856467e23 100644 --- a/src/mono/mono/mini/mini-amd64.c +++ b/src/mono/mono/mini/mini-amd64.c @@ -49,6 +49,8 @@ #include "mini-runtime.h" #include "aot-runtime.h" +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ + static GENERATE_TRY_GET_CLASS_WITH_CACHE (math, "System", "Math") @@ -1816,13 +1818,13 @@ mono_arch_allocate_vars (MonoCompile *cfg) cfg->locals_min_stack_offset = offset; cfg->locals_max_stack_offset = offset + locals_stack_size; } else { - cfg->locals_min_stack_offset = - (offset + locals_stack_size); + cfg->locals_min_stack_offset = - (offset + (int)locals_stack_size); cfg->locals_max_stack_offset = - offset; } for (i = cfg->locals_start; i < cfg->num_varinfo; i++) { if (offsets [i] != -1) { - MonoInst *ins = cfg->varinfo [i]; + ins = cfg->varinfo [i]; ins->opcode = OP_REGOFFSET; ins->inst_basereg = cfg->frame_reg; if (cfg->arch.omit_fp) @@ -1956,7 +1958,7 @@ mono_arch_create_vars (MonoCompile *cfg) MonoInst *ins; if (cfg->compile_aot) { - MonoInst *ins = mono_compile_create_var (cfg, mono_get_int_type (), OP_LOCAL); + ins = mono_compile_create_var (cfg, mono_get_int_type (), OP_LOCAL); ins->flags |= MONO_INST_VOLATILE; cfg->arch.seq_point_info_var = ins; } @@ -4443,7 +4445,7 @@ emit_setup_lmf (MonoCompile *cfg, guint8 *code, gint32 lmf_offset, int cfa_offse /* Save rbp */ amd64_mov_membase_reg (code, cfg->frame_reg, lmf_offset + MONO_STRUCT_OFFSET (MonoLMF, rbp), AMD64_RBP, 8); if (cfg->arch.omit_fp && cfa_offset != -1) - mono_emit_unwind_op_offset (cfg, code, AMD64_RBP, - (cfa_offset - (lmf_offset + MONO_STRUCT_OFFSET (MonoLMF, rbp)))); + mono_emit_unwind_op_offset (cfg, code, AMD64_RBP, - (cfa_offset - (lmf_offset + (gint32)MONO_STRUCT_OFFSET (MonoLMF, rbp)))); /* These can't contain refs */ mini_gc_set_slot_type_from_fp (cfg, lmf_offset + MONO_STRUCT_OFFSET (MonoLMF, previous_lmf), SLOT_NOREF); @@ -4514,7 +4516,7 @@ amd64_handle_varargs_call (MonoCompile *cfg, guint8 *code, MonoCallInst *call, g * potential vararg call. */ for (guint32 i = 0; i < AMD64_XMM_NREG; ++i) - nregs += (call->used_fregs & (1 << i)) != 0; + nregs += (call->used_fregs & ((regmask_t)1 << i)) != 0; } else { return code; } @@ -4939,15 +4941,15 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) mono_add_seq_point (cfg, bb, ins, code - cfg->native_code); if (cfg->compile_aot) { - const guint32 offset = code - cfg->native_code; + const guint32 code_offset = code - cfg->native_code; guint32 val; MonoInst *info_var = cfg->arch.seq_point_info_var; guint8 *label; /* Load info var */ amd64_mov_reg_membase (code, AMD64_R11, info_var->inst_basereg, info_var->inst_offset, 8); - val = ((offset) * sizeof (target_mgreg_t)) + MONO_STRUCT_OFFSET (SeqPointInfo, bp_addrs); - /* Load the info->bp_addrs [offset], which is either NULL or the address of the breakpoint trampoline */ + val = ((code_offset) * sizeof (target_mgreg_t)) + MONO_STRUCT_OFFSET (SeqPointInfo, bp_addrs); + /* Load the info->bp_addrs [code_offset], which is either NULL or the address of the breakpoint trampoline */ amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, val, 8); amd64_test_reg_reg (code, AMD64_R11, AMD64_R11); label = code; @@ -6657,6 +6659,9 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_ATOMIC_STORE_U8: size = 8; break; + default: + size = 0; + g_assert_not_reached (); } amd64_mov_membase_reg (code, ins->inst_destbasereg, ins->inst_offset, ins->sreg1, size); @@ -7821,15 +7826,15 @@ MONO_RESTORE_WARNING max_epilog_size = get_max_epilog_size (cfg); if (cfg->opt & MONO_OPT_BRANCH && cfg->max_block_num < MAX_BBLOCKS_FOR_BRANCH_OPTS) { for (bb = cfg->bb_entry; bb; bb = bb->next_bb) { - MonoInst *ins; + MonoInst *bb_ins; int max_length = 0; /* max alignment for loops */ if ((cfg->opt & MONO_OPT_LOOP) && bb_is_loop_start (bb)) max_length += LOOP_ALIGNMENT; - MONO_BB_FOR_EACH_INS (bb, ins) { - max_length += ins_get_size (ins->opcode); + MONO_BB_FOR_EACH_INS (bb, bb_ins) { + max_length += ins_get_size (bb_ins->opcode); } /* Take prolog and epilog instrumentation into account */ diff --git a/src/mono/mono/mini/mini-arm.c b/src/mono/mono/mini/mini-arm.c index 4ef4155439ad7..fa1200e51ddbb 100644 --- a/src/mono/mono/mini/mini-arm.c +++ b/src/mono/mono/mini/mini-arm.c @@ -36,6 +36,9 @@ #include "mono/arch/arm/arm-vfp-codegen.h" #include "mono/utils/mono-tls-inline.h" +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ +MONO_DISABLE_WARNING(4334) /* result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) */ + /* Sanity check: This makes no sense */ #if defined(ARM_FPU_NONE) && (defined(ARM_FPU_VFP) || defined(ARM_FPU_VFP_HARD)) #error "ARM_FPU_NONE is defined while one of ARM_FPU_VFP/ARM_FPU_VFP_HARD is defined" @@ -1472,8 +1475,7 @@ get_call_info (MonoMemPool *mp, MonoMethodSignature *sig) case MONO_TYPE_VALUETYPE: { gint size; int align_size; - int nwords, nfields, esize; - guint32 align; + int nwords; if (IS_HARD_FLOAT && sig->pinvoke && is_hfa (t, &nfields, &esize)) { if (fpr + nfields < ARM_VFP_F16) { @@ -1906,7 +1908,6 @@ mono_arch_allocate_vars (MonoCompile *cfg) { MonoMethodSignature *sig; MonoMethodHeader *header; - MonoInst *ins; MonoType *sig_ret; int i, offset, size, align, curinst; CallInfo *cinfo; @@ -1988,7 +1989,9 @@ mono_arch_allocate_vars (MonoCompile *cfg) else offset += 32; break; - case RegTypeStructByAddr: + case RegTypeStructByAddr: { + MonoInst *ins; + ins = cfg->vret_addr; offset += sizeof (target_mgreg_t) - 1; offset &= ~(sizeof (target_mgreg_t) - 1); @@ -2001,6 +2004,7 @@ mono_arch_allocate_vars (MonoCompile *cfg) } offset += sizeof (target_mgreg_t); break; + } default: break; } @@ -2080,6 +2084,7 @@ mono_arch_allocate_vars (MonoCompile *cfg) curinst = cfg->locals_start; for (i = curinst; i < cfg->num_varinfo; ++i) { MonoType *t; + MonoInst *ins; ins = cfg->varinfo [i]; if ((ins->flags & MONO_INST_IS_DEAD) || ins->opcode == OP_REGVAR || ins->opcode == OP_REGOFFSET) @@ -2118,6 +2123,7 @@ mono_arch_allocate_vars (MonoCompile *cfg) curinst = 0; if (sig->hasthis) { + MonoInst *ins; ins = cfg->args [curinst]; if (ins->opcode != OP_REGVAR) { ins->opcode = OP_REGOFFSET; @@ -2144,6 +2150,7 @@ mono_arch_allocate_vars (MonoCompile *cfg) for (i = 0; i < sig->param_count; ++i) { ainfo = cinfo->args + i; + MonoInst *ins; ins = cfg->args [curinst]; switch (ainfo->storage) { @@ -4648,14 +4655,14 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) /* Breakpoint check */ if (cfg->compile_aot) { - const guint32 offset = code - cfg->native_code; + const guint32 bp_offset = code - cfg->native_code; guint32 val; var = info_var; code = emit_ldr_imm (code, dreg, var->inst_basereg, var->inst_offset); - /* Add the offset */ - val = ((offset / 4) * sizeof (target_mgreg_t)) + MONO_STRUCT_OFFSET (SeqPointInfo, bp_addrs); - /* Load the info->bp_addrs [offset], which is either 0 or the address of a trigger page */ + /* Add the bp_offset */ + val = ((bp_offset / 4) * sizeof (target_mgreg_t)) + MONO_STRUCT_OFFSET (SeqPointInfo, bp_addrs); + /* Load the info->bp_addrs [bp_offset], which is either 0 or the address of a trigger page */ if (arm_is_imm12 ((int)val)) { ARM_LDR_IMM (code, dreg, dreg, val); } else { @@ -4993,12 +5000,12 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_TAILCALL_REG: { gboolean const tailcall_membase = ins->opcode == OP_TAILCALL_MEMBASE; gboolean const tailcall_reg = ins->opcode == OP_TAILCALL_REG; - MonoCallInst *call = (MonoCallInst*)ins; + MonoCallInst *call_ins = (MonoCallInst*)ins; - max_len += call->stack_usage / sizeof (target_mgreg_t) * ins_get_size (OP_TAILCALL_PARAMETER); + max_len += call_ins->stack_usage / sizeof (target_mgreg_t) * ins_get_size (OP_TAILCALL_PARAMETER); if (IS_HARD_FLOAT) - code = emit_float_args (cfg, call, code, &max_len, &offset); + code = emit_float_args (cfg, call_ins, code, &max_len, &offset); code = realloc_code (cfg, max_len); @@ -5029,7 +5036,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) * Need to copy the arguments from the callee argument area to * the caller argument area, and pop the frame. */ - if (call->stack_usage) { + if (call_ins->stack_usage) { int i, prev_sp_offset = 0; // When we get here, the parameters to the tailcall are already formed, @@ -5074,7 +5081,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) // FIXME For most functions, with frames < 4K, we can use frame_reg directly here instead of IP. // See https://github.com/mono/mono/pull/12079 // See https://github.com/mono/mono/pull/12079/commits/93e7007a9567b78fa8152ce404b372b26e735516 - for (i = 0; i < call->stack_usage; i += sizeof (target_mgreg_t)) { + for (i = 0; i < call_ins->stack_usage; i += sizeof (target_mgreg_t)) { ARM_LDR_IMM (code, ARMREG_LR, ARMREG_SP, i + offset_sp); ARM_STR_IMM (code, ARMREG_LR, ARMREG_IP, i + offset_ip); } @@ -5099,7 +5106,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) if (tailcall_reg || tailcall_membase) { code = emit_jmp_reg (code, ARMREG_IP); } else { - mono_add_patch_info (cfg, (guint8*) code - cfg->native_code, MONO_PATCH_INFO_METHOD_JUMP, call->method); + mono_add_patch_info (cfg, (guint8*) code - cfg->native_code, MONO_PATCH_INFO_METHOD_JUMP, call_ins->method); if (cfg->compile_aot) { ARM_LDR_IMM (code, ARMREG_IP, ARMREG_PC, 0); @@ -5256,9 +5263,9 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) labels [0] = code; ARM_B_COND (code, ARMCOND_EQ, 0); for (i = 0; i < FP_PARAM_REGS; ++i) { - const int offset = MONO_STRUCT_OFFSET (DynCallArgs, fpregs) + (i * sizeof (double)); - g_assert (arm_is_fpimm8 (offset)); - ARM_FLDD (code, i * 2, ARMREG_LR, offset); + const int struct_offset = MONO_STRUCT_OFFSET (DynCallArgs, fpregs) + (i * sizeof (double)); + g_assert (arm_is_fpimm8 (struct_offset)); + ARM_FLDD (code, i * 2, ARMREG_LR, struct_offset); } arm_patch (labels [0], code); } @@ -5281,8 +5288,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) labels [1] = code; ARM_LDR_IMM (code, ARMREG_R0, ARMREG_R2, 0); ARM_STR_IMM (code, ARMREG_R0, ARMREG_R3, 0); - ARM_ADD_REG_IMM (code, ARMREG_R2, ARMREG_R2, sizeof (target_mgreg_t), 0); - ARM_ADD_REG_IMM (code, ARMREG_R3, ARMREG_R3, sizeof (target_mgreg_t), 0); + ARM_ADD_REG_IMM (code, ARMREG_R2, ARMREG_R2, (guint32)sizeof (target_mgreg_t), 0); + ARM_ADD_REG_IMM (code, ARMREG_R3, ARMREG_R3, (guint32)sizeof (target_mgreg_t), 0); ARM_SUB_REG_IMM (code, ARMREG_R1, ARMREG_R1, 1, 0); arm_patch (labels [0], code); ARM_CMP_REG_IMM (code, ARMREG_R1, 0, 0); @@ -5325,7 +5332,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_START_HANDLER: { MonoInst *spvar = mono_find_spvar_for_region (cfg, bb->region); int param_area = ALIGN_TO (cfg->param_area, MONO_ARCH_FRAME_ALIGNMENT); - int i, rot_amount; + int i; /* Reserve a param area, see filter-stack.exe */ if (param_area) { @@ -5348,7 +5355,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_ENDFILTER: { MonoInst *spvar = mono_find_spvar_for_region (cfg, bb->region); int param_area = ALIGN_TO (cfg->param_area, MONO_ARCH_FRAME_ALIGNMENT); - int i, rot_amount; + int i; /* Free the param area */ if (param_area) { @@ -5375,7 +5382,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_ENDFINALLY: { MonoInst *spvar = mono_find_spvar_for_region (cfg, bb->region); int param_area = ALIGN_TO (cfg->param_area, MONO_ARCH_FRAME_ALIGNMENT); - int i, rot_amount; + int i; /* Free the param area */ if (param_area) { @@ -6491,7 +6498,7 @@ mono_arch_emit_prolog (MonoCompile *cfg) } break; case RegTypeFP: { - int imm8, rot_amount; + int imm8; if ((imm8 = mono_arm_is_rotated_imm8 (inst->inst_offset, &rot_amount)) == -1) { code = mono_arm_emit_load_imm (code, ARMREG_IP, inst->inst_offset); @@ -6714,12 +6721,12 @@ mono_arch_emit_epilog (MonoCompile *cfg) /* Restore saved r7, restore LR to PC */ /* Skip lr from the lmf */ mono_emit_unwind_op_def_cfa_offset (cfg, code, 3 * 4); - ARM_ADD_REG_IMM (code, ARMREG_SP, ARMREG_SP, sizeof (target_mgreg_t), 0); + ARM_ADD_REG_IMM (code, ARMREG_SP, ARMREG_SP, (guint32)sizeof (target_mgreg_t), 0); mono_emit_unwind_op_def_cfa_offset (cfg, code, 2 * 4); ARM_POP (code, (1 << ARMREG_R7) | (1 << ARMREG_PC)); } } else { - int i, nused_int_regs = 0; + int nused_int_regs = 0; for (i = 0; i < 16; i++) { if (cfg->used_int_regs & (1 << i)) @@ -7045,7 +7052,7 @@ mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoIMTCheckItem **imt_entri /* Restore registers and branch */ ARM_POP4 (code, ARMREG_R0, ARMREG_R1, ARMREG_IP, ARMREG_PC); - code = arm_emit_value_and_patch_ldr (code, target_code_ins, (gsize)item->value.target_code); + code = arm_emit_value_and_patch_ldr (code, target_code_ins, (guint32)(gsize)item->value.target_code); } else { vtable_offset = DISTANCE (vtable, &vtable->vtable[item->value.vtable_slot]); if (!arm_is_imm12 (vtable_offset)) { @@ -7060,7 +7067,7 @@ mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoIMTCheckItem **imt_entri ARM_LDR_IMM (code, ARMREG_R1, ARMREG_PC, 0); ARM_LDR_REG_REG (code, ARMREG_R1, ARMREG_IP, ARMREG_R1); /* Save it to the fourth slot */ - ARM_STR_IMM (code, ARMREG_R1, ARMREG_SP, 3 * sizeof (target_mgreg_t)); + ARM_STR_IMM (code, ARMREG_R1, ARMREG_SP, (guint32)(3 * sizeof (target_mgreg_t))); /* Restore registers and branch */ ARM_POP4 (code, ARMREG_R0, ARMREG_R1, ARMREG_IP, ARMREG_PC); @@ -7069,7 +7076,7 @@ mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoIMTCheckItem **imt_entri ARM_POP2 (code, ARMREG_R0, ARMREG_R1); if (large_offsets) { mono_add_unwind_op_def_cfa_offset (unwind_ops, code, start, 2 * sizeof (target_mgreg_t)); - ARM_ADD_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, 2 * sizeof (target_mgreg_t)); + ARM_ADD_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, (guint32)(2 * sizeof (target_mgreg_t))); } mono_add_unwind_op_def_cfa_offset (unwind_ops, code, start, 0); ARM_LDR_IMM (code, ARMREG_PC, ARMREG_IP, vtable_offset); @@ -7087,7 +7094,7 @@ mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoIMTCheckItem **imt_entri /* Restore registers and branch */ ARM_POP4 (code, ARMREG_R0, ARMREG_R1, ARMREG_IP, ARMREG_PC); - code = arm_emit_value_and_patch_ldr (code, target_code_ins, (gsize)fail_tramp); + code = arm_emit_value_and_patch_ldr (code, target_code_ins, (guint32)(gsize)fail_tramp); item->jmp_code = NULL; } diff --git a/src/mono/mono/mini/mini-arm64.c b/src/mono/mono/mini/mini-arm64.c index 607f99623c4ba..75a6d5b3adbc1 100644 --- a/src/mono/mono/mini/mini-arm64.c +++ b/src/mono/mono/mini/mini-arm64.c @@ -30,6 +30,10 @@ #include "interp/interp.h" +// Several of the 32-bit bit shifts must remain 32-bit, since they assume possible wrap around. +// result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) +MONO_DISABLE_WARNING(4334) + /* * Documentation: * @@ -2762,7 +2766,7 @@ mono_arch_emit_outarg_vt (MonoCompile *cfg, MonoInst *ins, MonoInst *src) break; case ArgVtypeByRef: case ArgVtypeByRefOnStack: { - MonoInst *vtaddr, *load, *arg; + MonoInst *vtaddr, *arg; /* Pass the vtype address in a reg/on the stack */ if (ainfo->gsharedvt) { @@ -3350,18 +3354,18 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) break; } case OP_LOCALLOC_IMM: { - int imm, offset; + int aligned_imm, aligned_imm_offset; - imm = ALIGN_TO (ins->inst_imm, MONO_ARCH_FRAME_ALIGNMENT); - g_assert (arm_is_arith_imm (imm)); - arm_subx_imm (code, ARMREG_SP, ARMREG_SP, imm); + aligned_imm = ALIGN_TO (ins->inst_imm, MONO_ARCH_FRAME_ALIGNMENT); + g_assert (arm_is_arith_imm (aligned_imm)); + arm_subx_imm (code, ARMREG_SP, ARMREG_SP, aligned_imm); /* Init */ g_assert (MONO_ARCH_FRAME_ALIGNMENT == 16); - offset = 0; - while (offset < imm) { - arm_stpx (code, ARMREG_RZR, ARMREG_RZR, ARMREG_SP, offset); - offset += 16; + aligned_imm_offset = 0; + while (aligned_imm_offset < aligned_imm) { + arm_stpx (code, ARMREG_RZR, ARMREG_RZR, ARMREG_SP, aligned_imm_offset); + aligned_imm_offset += 16; } arm_movspx (code, dreg, ARMREG_SP); if (cfg->param_area) @@ -3409,13 +3413,13 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) mono_add_seq_point (cfg, bb, ins, code - cfg->native_code); if (cfg->compile_aot) { - const guint32 offset = code - cfg->native_code; + const guint32 bp_tramp_offset = code - cfg->native_code; guint32 val; arm_ldrx (code, ARMREG_IP1, info_var->inst_basereg, info_var->inst_offset); - /* Add the offset */ - val = ((offset / 4) * sizeof (target_mgreg_t)) + MONO_STRUCT_OFFSET (SeqPointInfo, bp_addrs); - /* Load the info->bp_addrs [offset], which is either 0 or the address of the bp trampoline */ + /* Add the bp_tramp_offset */ + val = ((bp_tramp_offset / 4) * sizeof (target_mgreg_t)) + MONO_STRUCT_OFFSET (SeqPointInfo, bp_addrs); + /* Load the info->bp_addrs [bp_tramp_offset], which is either 0 or the address of the bp trampoline */ code = emit_ldrx (code, ARMREG_IP1, ARMREG_IP1, val); /* Skip the load if its 0 */ arm_cbzx (code, ARMREG_IP1, code + 8); @@ -4129,20 +4133,20 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) /* FP */ case OP_R8CONST: { - guint64 imm = *(guint64*)ins->inst_p0; + guint64 r8_imm = *(guint64*)ins->inst_p0; - if (imm == 0) { + if (r8_imm == 0) { arm_fmov_rx_to_double (code, dreg, ARMREG_RZR); } else { - code = emit_imm64 (code, ARMREG_LR, imm); + code = emit_imm64 (code, ARMREG_LR, r8_imm); arm_fmov_rx_to_double (code, ins->dreg, ARMREG_LR); } break; } case OP_R4CONST: { - guint64 imm = *(guint32*)ins->inst_p0; + guint64 r4_imm = *(guint32*)ins->inst_p0; - code = emit_imm64 (code, ARMREG_LR, imm); + code = emit_imm64 (code, ARMREG_LR, r4_imm); if (cfg->r4fp) { arm_fmov_rx_to_double (code, dreg, ARMREG_LR); } else { diff --git a/src/mono/mono/mini/mini-codegen.c b/src/mono/mono/mini/mini-codegen.c index 01e63d06d5d68..e5232283e89dc 100644 --- a/src/mono/mono/mini/mini-codegen.c +++ b/src/mono/mono/mini/mini-codegen.c @@ -485,12 +485,11 @@ mono_print_ins_index_strbuf (int i, MonoInst *ins) case OP_VPHI: case OP_XPHI: case OP_FPHI: { - int i; g_string_append_printf (sbuf, " [%d (", (int)ins->inst_c0); - for (i = 0; i < ins->inst_phi_args [0]; i++) { - if (i) + for (j = 0; j < ins->inst_phi_args [0]; j++) { + if (j) g_string_append_printf (sbuf, ", "); - g_string_append_printf (sbuf, "R%d", ins->inst_phi_args [i + 1]); + g_string_append_printf (sbuf, "R%d", ins->inst_phi_args [j + 1]); } g_string_append_printf (sbuf, ")]"); break; @@ -1116,6 +1115,8 @@ get_callee_mask (const char spec) static gint8 desc_to_fixed_reg [256]; static gboolean desc_to_fixed_reg_inited = FALSE; +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ + /* * Local register allocation. * We first scan the list of instructions and we save the liveness info of @@ -1746,7 +1747,7 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb) } if (spec [MONO_INST_CLOB] == 'c') { - int j, dreg, dreg2, cur_bank; + int dreg, dreg2, cur_bank; regmask_t s; guint64 clob_mask; @@ -2040,7 +2041,7 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb) if (((dreg_is_fp (spec) && sreg1_is_fp (spec)) || spec [MONO_INST_CLOB] == '1') && ins->dreg != sregs [0]) { MonoInst *sreg2_copy = NULL; MonoInst *copy; - int bank = reg_bank (spec_src1); + bank = reg_bank (spec_src1); if (ins->dreg == sregs [1]) { /* @@ -2188,12 +2189,12 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb) * arguments required by the fp opcodes are at the top of the stack. */ if (has_fp) { - MonoInst *prev = NULL; MonoInst *fxch; - int tmp; + int fpstack_tmp; g_assert (num_sregs <= 2); + prev = NULL; for (ins = bb->code; ins; ins = ins->next) { spec = ins_get_spec (ins->opcode); @@ -2229,9 +2230,9 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb) mono_bblock_insert_after_ins (bb, prev, fxch); prev = fxch; - tmp = fpstack [sp - 1]; + fpstack_tmp = fpstack [sp - 1]; fpstack [sp - 1] = fpstack [i]; - fpstack [i] = tmp; + fpstack [i] = fpstack_tmp; } /* Then move it to %st(1) */ @@ -2243,9 +2244,9 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb) mono_bblock_insert_after_ins (bb, prev, fxch); prev = fxch; - tmp = fpstack [sp - 1]; + fpstack_tmp = fpstack [sp - 1]; fpstack [sp - 1] = fpstack [sp - 2]; - fpstack [sp - 2] = tmp; + fpstack [sp - 2] = fpstack_tmp; } if (sreg2_is_fp (spec)) { @@ -2267,9 +2268,9 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb) mono_bblock_insert_after_ins (bb, prev, fxch); prev = fxch; - tmp = fpstack [sp - 1]; + fpstack_tmp = fpstack [sp - 1]; fpstack [sp - 1] = fpstack [i]; - fpstack [i] = tmp; + fpstack [i] = fpstack_tmp; } sp --; @@ -2294,9 +2295,9 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb) mono_bblock_insert_after_ins (bb, prev, fxch); prev = fxch; - tmp = fpstack [sp - 1]; + fpstack_tmp = fpstack [sp - 1]; fpstack [sp - 1] = fpstack [i]; - fpstack [i] = tmp; + fpstack [i] = fpstack_tmp; } sp --; @@ -2333,6 +2334,8 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb) #endif } +MONO_RESTORE_WARNING + CompRelation mono_opcode_to_cond (int opcode) { diff --git a/src/mono/mono/mini/mini-exceptions.c b/src/mono/mono/mini/mini-exceptions.c index 48aa4e1b4d0f4..477b24f7f82a3 100644 --- a/src/mono/mono/mini/mini-exceptions.c +++ b/src/mono/mono/mini/mini-exceptions.c @@ -966,7 +966,7 @@ mono_exception_stackframe_obj_walk (MonoStackFrame *captured_frame, MonoExceptio if (!captured_frame) return TRUE; - gpointer ip = (gpointer) (captured_frame->method_address + captured_frame->native_offset); + gpointer ip = GINT_TO_POINTER (captured_frame->method_address + captured_frame->native_offset); MonoJitInfo *ji = mono_jit_info_table_find_internal (ip, TRUE, TRUE); // Other domain maybe? @@ -974,7 +974,7 @@ mono_exception_stackframe_obj_walk (MonoStackFrame *captured_frame, MonoExceptio return FALSE; MonoMethod *method = jinfo_get_method (ji); - gboolean r = func (method, (gpointer) captured_frame->method_address, captured_frame->native_offset, TRUE, user_data); + gboolean r = func (method, GINT_TO_POINTER (captured_frame->method_address), captured_frame->native_offset, TRUE, user_data); if (r) return TRUE; @@ -2214,14 +2214,14 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu if (!resume) { MonoContext ctx_cp = *ctx; if (mono_trace_is_enabled ()) { - ERROR_DECL (error); + error_init_reuse (error); MonoMethod *system_exception_get_message = mono_class_get_method_from_name_checked (mono_defaults.exception_class, "get_Message", 0, 0, error); mono_error_cleanup (error); - error_init (error); MonoMethod *get_message = system_exception_get_message == NULL ? NULL : mono_object_get_virtual_method_internal (obj, system_exception_get_message); MonoObject *message; const char *type_name = m_class_get_name (mono_object_class (mono_ex)); char *msg = NULL; + error_init_reuse (error); if (get_message == NULL) { message = NULL; } else if (!strcmp (type_name, "OutOfMemoryException") || !strcmp (type_name, "StackOverflowException")) { @@ -2317,6 +2317,7 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu first_filter_idx = jit_tls->resume_state.first_filter_idx; filter_idx = jit_tls->resume_state.filter_idx; in_interp = FALSE; + frame.native_offset = 0; } else { unwind_res = unwinder_unwind_frame (&unwinder, jit_tls, NULL, ctx, &new_ctx, NULL, &lmf, NULL, &frame); if (!unwind_res) { @@ -3261,6 +3262,7 @@ mono_thread_state_init_from_sigctx (MonoThreadUnwindState *ctx, void *sigctx) return TRUE; } +MONO_DISABLE_WARNING(4740) /* flow in or out of inline asm code suppresses global optimization, x86 only */ void mono_thread_state_init (MonoThreadUnwindState *ctx) { @@ -3281,7 +3283,7 @@ mono_thread_state_init (MonoThreadUnwindState *ctx) ctx->unwind_data [MONO_UNWIND_DATA_JIT_TLS] = thread ? thread->jit_data : NULL; ctx->valid = TRUE; } - +MONO_RESTORE_WARNING gboolean mono_thread_state_init_from_monoctx (MonoThreadUnwindState *ctx, MonoContext *mctx) diff --git a/src/mono/mono/mini/mini-generic-sharing.c b/src/mono/mono/mini/mini-generic-sharing.c index b009270d86f7f..af34a2d8779f9 100644 --- a/src/mono/mono/mini/mini-generic-sharing.c +++ b/src/mono/mono/mini/mini-generic-sharing.c @@ -527,7 +527,6 @@ inflate_info (MonoMemoryManager *mem_manager, MonoRuntimeGenericContextInfoTempl { gpointer data = oti->data; MonoRgctxInfoType info_type = oti->info_type; - ERROR_DECL (error); g_assert (data); @@ -553,6 +552,7 @@ inflate_info (MonoMemoryManager *mem_manager, MonoRuntimeGenericContextInfoTempl case MONO_RGCTX_INFO_LOCAL_OFFSET: case MONO_RGCTX_INFO_NULLABLE_CLASS_BOX: case MONO_RGCTX_INFO_NULLABLE_CLASS_UNBOX: { + ERROR_DECL (error); gpointer result = mono_class_inflate_generic_type_with_mempool (temporary ? NULL : m_class_get_image (klass), (MonoType *)data, context, error); mono_error_assert_msg_ok (error, "Could not inflate generic type"); /* FIXME proper error handling */ @@ -569,6 +569,7 @@ inflate_info (MonoMemoryManager *mem_manager, MonoRuntimeGenericContextInfoTempl case MONO_RGCTX_INFO_METHOD_DELEGATE_CODE: case MONO_RGCTX_INFO_INTERP_METHOD: case MONO_RGCTX_INFO_LLVMONLY_INTERP_ENTRY: { + ERROR_DECL (error); MonoMethod *method = (MonoMethod *)data; MonoMethod *inflated_method; MonoType *inflated_type = mono_class_inflate_generic_type_checked (m_class_get_byval_arg (method->klass), context, error); @@ -587,7 +588,6 @@ inflate_info (MonoMemoryManager *mem_manager, MonoRuntimeGenericContextInfoTempl inflated_method = mono_method_search_in_array_class (inflated_class, method->name, method->signature); } else { - ERROR_DECL (error); inflated_method = mono_class_inflate_generic_method_checked (method, context, error); g_assert (is_ok (error)); /* FIXME don't swallow the error */ } @@ -620,6 +620,7 @@ inflate_info (MonoMemoryManager *mem_manager, MonoRuntimeGenericContextInfoTempl } case MONO_RGCTX_INFO_METHOD_GSHAREDVT_OUT_TRAMPOLINE: case MONO_RGCTX_INFO_METHOD_GSHAREDVT_OUT_TRAMPOLINE_VIRT: { + ERROR_DECL (error); MonoJumpInfoGSharedVtCall *info = (MonoJumpInfoGSharedVtCall *)data; MonoMethod *method = info->method; MonoMethod *inflated_method; @@ -651,7 +652,6 @@ inflate_info (MonoMemoryManager *mem_manager, MonoRuntimeGenericContextInfoTempl inflated_method = mono_method_search_in_array_class (inflated_class, method->name, method->signature); } else { - ERROR_DECL (error); inflated_method = mono_class_inflate_generic_method_checked (method, context, error); g_assert (is_ok (error)); /* FIXME don't swallow the error */ } @@ -727,20 +727,20 @@ inflate_info (MonoMemoryManager *mem_manager, MonoRuntimeGenericContextInfoTempl ERROR_DECL (error); MonoDelegateClassMethodPair *dele_info = (MonoDelegateClassMethodPair*)data; - MonoType *t = mono_class_inflate_generic_type_checked (m_class_get_byval_arg (dele_info->klass), context, error); + MonoType *dele_t = mono_class_inflate_generic_type_checked (m_class_get_byval_arg (dele_info->klass), context, error); mono_error_assert_msg_ok (error, "Could not inflate generic type"); /* FIXME proper error handling */ - MonoClass *klass = mono_class_from_mono_type_internal (t); - mono_metadata_free_type (t); + MonoClass *dele_klass = mono_class_from_mono_type_internal (dele_t); + mono_metadata_free_type (dele_t); - MonoMethod *method = mono_class_inflate_generic_method_checked (dele_info->method, context, error); + MonoMethod *dele_method = mono_class_inflate_generic_method_checked (dele_info->method, context, error); mono_error_assert_msg_ok (error, "Could not inflate generic method"); /* FIXME proper error handling */ // FIXME: Temporary MonoDelegateClassMethodPair *res = (MonoDelegateClassMethodPair *)mono_mem_manager_alloc0 (mem_manager, sizeof (MonoDelegateClassMethodPair)); res->is_virtual = dele_info->is_virtual; - res->method = method; - res->klass = klass; + res->method = dele_method; + res->klass = dele_klass; return res; } @@ -1472,7 +1472,7 @@ mini_get_gsharedvt_in_sig_wrapper (MonoMethodSignature *sig) MonoMethod *res, *cached; WrapperInfo *info; MonoMethodSignature *csig, *gsharedvt_sig; - int i, pindex; + int pindex; static GHashTable *cache; // FIXME: Memory management @@ -1511,7 +1511,7 @@ mini_get_gsharedvt_in_sig_wrapper (MonoMethodSignature *sig) gsharedvt_sig->params [pindex ++] = mono_get_int_type (); gsharedvt_sig->ret = mono_get_void_type (); } - for (i = 0; i < sig->param_count; i++) { + for (int i = 0; i < sig->param_count; i++) { gsharedvt_sig->params [pindex] = sig->params [i]; if (!m_type_is_byref (sig->params [i])) { gsharedvt_sig->params [pindex] = mono_metadata_type_dup (NULL, gsharedvt_sig->params [pindex]); @@ -1539,7 +1539,7 @@ mini_get_gsharedvt_in_sig_wrapper (MonoMethodSignature *sig) mono_mb_emit_ldarg (mb, 0); if (sig->ret->type != MONO_TYPE_VOID) mono_mb_emit_ldloc_addr (mb, retval_var); - for (i = 0; i < sig->param_count; i++) { + for (int i = 0; i < sig->param_count; i++) { if (m_type_is_byref (sig->params [i])) mono_mb_emit_ldarg (mb, i + (sig->hasthis == TRUE)); else @@ -1591,7 +1591,7 @@ mini_get_gsharedvt_out_sig_wrapper (MonoMethodSignature *sig) MonoMethod *res, *cached; WrapperInfo *info; MonoMethodSignature *normal_sig, *csig; - int i, pindex, args_start; + int pindex, args_start; static GHashTable *cache; // FIXME: Memory management @@ -1624,7 +1624,7 @@ mini_get_gsharedvt_out_sig_wrapper (MonoMethodSignature *sig) args_start = pindex; if (sig->hasthis) args_start ++; - for (i = 0; i < sig->param_count; i++) { + for (int i = 0; i < sig->param_count; i++) { csig->params [pindex] = sig->params [i]; param_names [pindex] = g_strdup_printf ("%d", i); if (!m_type_is_byref (sig->params [i])) { @@ -1660,7 +1660,7 @@ mini_get_gsharedvt_out_sig_wrapper (MonoMethodSignature *sig) /* Make the call */ if (sig->hasthis) mono_mb_emit_ldarg (mb, 0); - for (i = 0; i < sig->param_count; i++) { + for (int i = 0; i < sig->param_count; i++) { if (m_type_is_byref (sig->params [i])) { mono_mb_emit_ldarg (mb, args_start + i); } else { @@ -2727,7 +2727,6 @@ register_info (MonoClass *klass, int type_argc, gpointer data, MonoRgctxInfoType parent = m_class_get_parent (klass); while (parent != NULL) { MonoRuntimeGenericContextTemplate *parent_template; - MonoRuntimeGenericContextInfoTemplate *oti; if (mono_class_is_ginst (parent)) parent = mono_class_get_generic_class (parent)->container_class; @@ -3353,7 +3352,7 @@ mono_generic_context_is_sharable (MonoGenericContext *context, gboolean allow_ty static gboolean is_primitive_inst (MonoGenericInst *inst) { - for (int i = 0; i < inst->type_argc; ++i) { + for (guint i = 0; i < inst->type_argc; ++i) { if (!MONO_TYPE_IS_PRIMITIVE (inst->type_argv [i])) return FALSE; } @@ -3409,7 +3408,7 @@ gparam_can_be_enum (MonoGenericParam *gparam) * If a constraint is an interface which is not implemented by Enum, then the gparam can't be * instantiated with an enum. */ - for (int cindex = 0; gparam->info.constraints [cindex]; cindex ++) { + for (size_t cindex = 0; gparam->info.constraints [cindex]; cindex ++) { MonoClass *k = gparam->info.constraints [cindex]; if (MONO_CLASS_IS_INTERFACE_INTERNAL (k)) { MonoClass **enum_ifaces = m_class_get_interfaces (mono_defaults.enum_class); @@ -4056,7 +4055,7 @@ get_shared_gparam_name (MonoTypeEnum constraint, const char *name) t.type = constraint; tname = mono_type_full_name (&t); size_t len = strlen (tname); - for (int i = 0; i < len; ++i) + for (size_t i = 0; i < len; ++i) tname [i] = toupper (tname [i]); res = g_strdup_printf ("%s_%s", name, tname); g_free (tname); diff --git a/src/mono/mono/mini/mini-llvm-cpp.cpp b/src/mono/mono/mini/mini-llvm-cpp.cpp index 9c3efc31d2174..3e8aa2642f78f 100644 --- a/src/mono/mono/mini/mini-llvm-cpp.cpp +++ b/src/mono/mono/mini/mini-llvm-cpp.cpp @@ -21,16 +21,22 @@ // possible // +#include "config.h" + +#include + #ifdef _MSC_VER // Disable warnings generated by LLVM headers. #pragma warning(disable:4141) // modifier' : used more than once +#pragma warning(disable:4146) // unary minus operator applied to unsigned type, result still unsigned +#pragma warning(disable:4267) // conversion from 'size_t' to 'unsigned int', possible loss of data +#pragma warning(disable:4310) // cast truncates constant value +#pragma warning(disable:4324) // structure was padded due to alignment specifier +#pragma warning(disable:4458) // declaration of '' hides class member +#pragma warning(disable:4624) // destructor was implicitly defined as deleted #pragma warning(disable:4800) // type' : forcing value to bool 'true' or 'false' (performance warning) #endif -#include "config.h" - -#include - #include #include #include diff --git a/src/mono/mono/mini/mini-llvm.c b/src/mono/mono/mini/mini-llvm.c index 742c1d304aac4..0c0d906f94e61 100644 --- a/src/mono/mono/mini/mini-llvm.c +++ b/src/mono/mono/mini/mini-llvm.c @@ -1132,8 +1132,8 @@ ovf_op_to_intrins (int opcode) static IntrinsicId simd_ins_to_intrins (int opcode) { - switch (opcode) { #if defined(TARGET_X86) || defined(TARGET_AMD64) + switch (opcode) { case OP_CVTPD2DQ: return INTRINS_SSE_CVTPD2DQ; case OP_CVTPS2DQ: @@ -1148,11 +1148,14 @@ simd_ins_to_intrins (int opcode) return INTRINS_SSE_SQRT_SS; case OP_SSE2_SQRTSD: return INTRINS_SSE_SQRT_SD; -#endif default: g_assert_not_reached (); return (IntrinsicId)0; } +#else + g_assert_not_reached (); + return (IntrinsicId)0; +#endif } static LLVMTypeRef @@ -1491,7 +1494,7 @@ sig_to_llvm_sig_full (EmitContext *ctx, MonoMethodSignature *sig, LLVMCallInfo * LLVMTypeRef ret_type; LLVMTypeRef *param_types = NULL; LLVMTypeRef res; - int i, j, pindex, vret_arg_pindex = 0; + int pindex, vret_arg_pindex = 0; gboolean vretaddr = FALSE; MonoType *rtype; @@ -1547,7 +1550,7 @@ sig_to_llvm_sig_full (EmitContext *ctx, MonoMethodSignature *sig, LLVMCallInfo * LLVMTypeRef members [16]; /* Have to create our own structure since we don't map fp structures to LLVM fp structures yet */ - for (i = 0; i < cinfo->ret.nslots; ++i) + for (int i = 0; i < cinfo->ret.nslots; ++i) members [i] = cinfo->ret.esize == 8 ? LLVMDoubleType () : LLVMFloatType (); ret_type = LLVMStructType (members, cinfo->ret.nslots, FALSE); break; @@ -1606,7 +1609,7 @@ sig_to_llvm_sig_full (EmitContext *ctx, MonoMethodSignature *sig, LLVMCallInfo * LLVMArgInfo *ainfo = &cinfo->args [0]; switch (ainfo->storage) { case LLVMArgVtypeInReg: - for (j = 0; j < 2; ++j) { + for (int j = 0; j < 2; ++j) { if (ainfo->pair_storage [j] == LLVMArgInIReg) vret_arg_pindex ++; } @@ -1628,7 +1631,7 @@ sig_to_llvm_sig_full (EmitContext *ctx, MonoMethodSignature *sig, LLVMCallInfo * } if (vretaddr && vret_arg_pindex == pindex) param_types [pindex ++] = IntPtrType (); - for (i = 0; i < sig->param_count; ++i) { + for (int i = 0; i < sig->param_count; ++i) { LLVMArgInfo *ainfo = &cinfo->args [i + sig->hasthis]; if (vretaddr && vret_arg_pindex == pindex) @@ -1637,7 +1640,7 @@ sig_to_llvm_sig_full (EmitContext *ctx, MonoMethodSignature *sig, LLVMCallInfo * switch (ainfo->storage) { case LLVMArgVtypeInReg: - for (j = 0; j < 2; ++j) { + for (int j = 0; j < 2; ++j) { switch (ainfo->pair_storage [j]) { case LLVMArgInIReg: param_types [pindex ++] = LLVMIntType (TARGET_SIZEOF_VOID_P * 8); @@ -1672,12 +1675,10 @@ sig_to_llvm_sig_full (EmitContext *ctx, MonoMethodSignature *sig, LLVMCallInfo * pindex ++; break; case LLVMArgAsFpArgs: { - int j; - /* Emit dummy fp arguments if needed so the rest is passed on the stack */ - for (j = 0; j < ainfo->ndummy_fpargs; ++j) + for (int j = 0; j < ainfo->ndummy_fpargs; ++j) param_types [pindex ++] = LLVMDoubleType (); - for (j = 0; j < ainfo->nslots; ++j) + for (int j = 0; j < ainfo->nslots; ++j) param_types [pindex ++] = ainfo->esize == 8 ? LLVMDoubleType () : LLVMFloatType (); break; } @@ -1860,7 +1861,7 @@ static char* get_aotconst_name (MonoJumpInfoType type, gconstpointer data, int got_offset) { char *name; - int len; + size_t len; switch (type) { case MONO_PATCH_INFO_JIT_ICALL_ID: @@ -1882,13 +1883,13 @@ get_aotconst_name (MonoJumpInfoType type, gconstpointer data, int got_offset) case MONO_PATCH_INFO_INTERRUPTION_REQUEST_FLAG: name = g_strdup_printf ("%s", mono_ji_type_to_string (type)); len = strlen (name); - for (int i = 0; i < len; ++i) + for (size_t i = 0; i < len; ++i) name [i] = tolower (name [i]); break; default: name = g_strdup_printf ("%s_%d", mono_ji_type_to_string (type), got_offset); len = strlen (name); - for (int i = 0; i < len; ++i) + for (size_t i = 0; i < len; ++i) name [i] = tolower (name [i]); break; } @@ -1957,15 +1958,15 @@ get_aotconst_module (MonoLLVMModule *module, LLVMBuilderRef builder, MonoJumpInf LLVMValueRef const_var = g_hash_table_lookup (module->aotconst_vars, GINT_TO_POINTER (got_offset)); if (!const_var) { - LLVMTypeRef type = llvm_type; + LLVMTypeRef const_var_type = llvm_type; // FIXME: char *name = get_aotconst_name (ji->type, ji->data.target, got_offset); char *symbol = g_strdup_printf ("aotconst_%s", name); g_free (name); - LLVMValueRef v = LLVMAddGlobal (module->lmodule, type, symbol); + LLVMValueRef v = LLVMAddGlobal (module->lmodule, const_var_type, symbol); LLVMSetVisibility (v, LLVMHiddenVisibility); LLVMSetLinkage (v, LLVMInternalLinkage); - LLVMSetInitializer (v, LLVMConstNull (type)); + LLVMSetInitializer (v, LLVMConstNull (const_var_type)); // FIXME: LLVMSetAlignment (v, 8); @@ -2299,7 +2300,7 @@ set_metadata_flag (LLVMValueRef v, const char *flag_name) LLVMValueRef md_arg; int md_kind; - md_kind = LLVMGetMDKindID (flag_name, strlen (flag_name)); + md_kind = LLVMGetMDKindID (flag_name, (unsigned int)strlen (flag_name)); md_arg = LLVMMDString ("mono", 4); LLVMSetMetadata (v, md_kind, LLVMMDNode (&md_arg, 1)); } @@ -2312,8 +2313,8 @@ set_nonnull_load_flag (LLVMValueRef v) const char *flag_name; flag_name = "nonnull"; - md_kind = LLVMGetMDKindID (flag_name, strlen (flag_name)); - md_arg = LLVMMDString ("", strlen ("")); + md_kind = LLVMGetMDKindID (flag_name, (unsigned int)strlen (flag_name)); + md_arg = LLVMMDString ("", (unsigned int)strlen ("")); LLVMSetMetadata (v, md_kind, LLVMMDNode (&md_arg, 1)); } @@ -2326,7 +2327,7 @@ set_nontemporal_flag (LLVMValueRef v) // FIXME: Cache this flag_name = "nontemporal"; - md_kind = LLVMGetMDKindID (flag_name, strlen (flag_name)); + md_kind = LLVMGetMDKindID (flag_name, (unsigned int)strlen (flag_name)); md_arg = const_int32 (1); LLVMSetMetadata (v, md_kind, LLVMMDNode (&md_arg, 1)); } @@ -2340,8 +2341,8 @@ set_invariant_load_flag (LLVMValueRef v) // FIXME: Cache this flag_name = "invariant.load"; - md_kind = LLVMGetMDKindID (flag_name, strlen (flag_name)); - md_arg = LLVMMDString ("", strlen ("")); + md_kind = LLVMGetMDKindID (flag_name, (unsigned int)strlen (flag_name)); + md_arg = LLVMMDString ("", (unsigned int)strlen ("")); LLVMSetMetadata (v, md_kind, LLVMMDNode (&md_arg, 1)); } @@ -3752,7 +3753,7 @@ emit_gc_pin (EmitContext *ctx, LLVMBuilderRef builder, int vreg) static void emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder) { - int i, j, pindex; + int pindex; MonoCompile *cfg = ctx->cfg; MonoMethodSignature *sig = ctx->sig; LLVMCallInfo *linfo = ctx->linfo; @@ -3774,7 +3775,7 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder) */ ctx->gc_var_indexes = g_new0 (int, cfg->next_vreg); int ngc_vars = 0; - for (i = 0; i < cfg->next_vreg; ++i) { + for (int i = 0; i < cfg->next_vreg; ++i) { if (vreg_is_ref (cfg, i)) { ctx->gc_var_indexes [i] = ngc_vars + 1; ngc_vars ++; @@ -3789,7 +3790,7 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder) * Handle indirect/volatile variables by allocating memory for them * using 'alloca', and storing their address in a temporary. */ - for (i = 0; i < cfg->num_varinfo; ++i) { + for (int i = 0; i < cfg->num_varinfo; ++i) { MonoInst *var = cfg->varinfo [i]; if ((var->opcode == OP_GSHAREDVT_LOCAL || var->opcode == OP_GSHAREDVT_ARG_REGOFFSET)) @@ -3817,19 +3818,17 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder) names = g_new (char *, sig->param_count); mono_method_get_param_names (cfg->method, (const char **) names); - for (i = 0; i < sig->param_count; ++i) { + for (int i = 0; i < sig->param_count; ++i) { LLVMArgInfo *ainfo = &linfo->args [i + sig->hasthis]; int reg = cfg->args [i + sig->hasthis]->dreg; char *name; pindex = ainfo->pindex; - LLVMValueRef arg = LLVMGetParam (ctx->lmethod, pindex); switch (ainfo->storage) { case LLVMArgVtypeInReg: case LLVMArgAsFpArgs: { LLVMValueRef args [8]; - int j; pindex += ainfo->ndummy_fpargs; @@ -3841,7 +3840,7 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder) args [1] = LLVMGetParam (ctx->lmethod, pindex + 1); } else { g_assert (ainfo->nslots <= 8); - for (j = 0; j < ainfo->nslots; ++j) + for (int j = 0; j < ainfo->nslots; ++j) args [j] = LLVMGetParam (ctx->lmethod, pindex + j); } ctx->addresses [reg] = build_alloca (ctx, ainfo->type); @@ -3883,6 +3882,7 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder) g_assert_not_reached (); break; case LLVMArgWasmVtypeAsScalar: { + LLVMValueRef arg = LLVMGetParam (ctx->lmethod, pindex); MonoType *t = mini_get_underlying_type (ainfo->type); /* The argument is received as a scalar */ @@ -3965,7 +3965,7 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder) emit_volatile_store (ctx, cfg->vret_addr->dreg); if (sig->hasthis) emit_volatile_store (ctx, cfg->args [0]->dreg); - for (i = 0; i < sig->param_count; ++i) + for (int i = 0; i < sig->param_count; ++i) if (!mini_type_is_vtype (sig->params [i])) emit_volatile_store (ctx, cfg->args [i + sig->hasthis]->dreg); @@ -4011,7 +4011,7 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder) * Store ref arguments to the pin area. * FIXME: This might not be needed, since the caller already does it ? */ - for (i = 0; i < cfg->num_varinfo; ++i) { + for (int i = 0; i < cfg->num_varinfo; ++i) { MonoInst *var = cfg->varinfo [i]; if (var->opcode == OP_ARG && vreg_is_ref (cfg, var->dreg) && ctx->values [var->dreg]) @@ -4111,8 +4111,8 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder) /* Compute nesting between clauses */ ctx->nested_in = (GSList**)mono_mempool_alloc0 (cfg->mempool, sizeof (GSList*) * cfg->header->num_clauses); - for (i = 0; i < cfg->header->num_clauses; ++i) { - for (j = 0; j < cfg->header->num_clauses; ++j) { + for (int i = 0; i < cfg->header->num_clauses; ++i) { + for (int j = 0; j < cfg->header->num_clauses; ++j) { MonoExceptionClause *clause1 = &cfg->header->clauses [i]; MonoExceptionClause *clause2 = &cfg->header->clauses [j]; @@ -4469,7 +4469,7 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref, switch (ainfo->storage) { case LLVMArgVtypeInReg: case LLVMArgAsFpArgs: { - guint32 nargs; + guint32 vtype_nargs; int j; for (j = 0; j < ainfo->ndummy_fpargs; ++j) @@ -4477,8 +4477,8 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref, pindex += ainfo->ndummy_fpargs; g_assert (addresses [reg]); - emit_vtype_to_args (ctx, builder, ainfo->type, addresses [reg], ainfo, args + pindex, &nargs); - pindex += nargs; + emit_vtype_to_args (ctx, builder, ainfo->type, addresses [reg], ainfo, args + pindex, &vtype_nargs); + pindex += vtype_nargs; // FIXME: alignment // FIXME: Get rid of the VMOVE @@ -5420,7 +5420,6 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) LLVMBasicBlockRef cbb; LLVMBuilderRef builder; gboolean has_terminator; - LLVMValueRef v; LLVMValueRef lhs, rhs, arg3; int nins = 0; @@ -6270,11 +6269,13 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) values [ins->dreg] = LLVMBuildShl (builder, lhs, imm, dname); break; case OP_SHL_IMM: +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ if (TARGET_SIZEOF_VOID_P == 8) { /* The IL is not regular */ lhs = convert (ctx, lhs, LLVMInt64Type ()); imm = convert (ctx, imm, LLVMInt64Type ()); } +MONO_RESTORE_WARNING values [ins->dreg] = LLVMBuildShl (builder, lhs, imm, dname); break; case OP_ISHR_IMM: @@ -6376,6 +6377,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) sign = (ins->opcode == OP_ICONV_TO_I1) || (ins->opcode == OP_ICONV_TO_I2) || (ins->opcode == OP_ICONV_TO_I4) || (ins->opcode == OP_LCONV_TO_I1) || (ins->opcode == OP_LCONV_TO_I2); /* Have to do two casts since our vregs have type int */ + LLVMValueRef v; v = LLVMBuildTrunc (builder, lhs, op_to_llvm_type (ins->opcode), ""); if (sign) values [ins->dreg] = LLVMBuildSExt (builder, v, LLVMInt32Type (), dname); @@ -6436,20 +6438,24 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) values [ins->dreg] = LLVMBuildTrunc (builder, lhs, LLVMInt32Type (), dname); break; case OP_ICONV_TO_R4: - case OP_LCONV_TO_R4: + case OP_LCONV_TO_R4: { + LLVMValueRef v; v = LLVMBuildSIToFP (builder, lhs, LLVMFloatType (), ""); if (cfg->r4fp) values [ins->dreg] = v; else values [ins->dreg] = LLVMBuildFPExt (builder, v, LLVMDoubleType (), dname); break; - case OP_FCONV_TO_R4: + } + case OP_FCONV_TO_R4: { + LLVMValueRef v; v = LLVMBuildFPTrunc (builder, lhs, LLVMFloatType (), ""); if (cfg->r4fp) values [ins->dreg] = v; else values [ins->dreg] = LLVMBuildFPExt (builder, v, LLVMDoubleType (), dname); break; + } case OP_RCONV_TO_R8: values [ins->dreg] = LLVMBuildFPExt (builder, lhs, LLVMDoubleType (), dname); break; @@ -6721,17 +6727,16 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) * FIXME: If later code uses the regs defined by these instructions, * compilation will fail. */ - const char *spec = INS_INFO (next->opcode); - if (spec [MONO_INST_DEST] == 'i' && !MONO_IS_STORE_MEMBASE (next)) + const char *ins_spec = INS_INFO (next->opcode); + if (ins_spec [MONO_INST_DEST] == 'i' && !MONO_IS_STORE_MEMBASE (next)) ctx->values [next->dreg] = LLVMConstNull (LLVMInt32Type ()); MONO_DELETE_INS (bb, next); } break; case OP_LDADDR: { MonoInst *var = ins->inst_i0; - MonoClass *klass = var->klass; - if (var->opcode == OP_VTARG_ADDR && !MONO_CLASS_IS_SIMD(cfg, klass)) { + if (var->opcode == OP_VTARG_ADDR && !MONO_CLASS_IS_SIMD(cfg, var->klass)) { /* The variable contains the vtype address */ values [ins->dreg] = values [var->dreg]; } else if (var->opcode == OP_GSHAREDVT_LOCAL) { @@ -7199,7 +7204,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) LLVMValueRef val, cmp, callee, call; LLVMBasicBlockRef poll_bb, cont_bb; LLVMValueRef args [2]; - static LLVMTypeRef sig; + static LLVMTypeRef safe_point_sig; const char *icall_name = "mono_threads_state_poll"; /* @@ -7214,8 +7219,8 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) mono_error_assert_ok (error); } - if (!sig) - sig = LLVMFunctionType0 (LLVMVoidType (), FALSE); + if (!safe_point_sig) + safe_point_sig = LLVMFunctionType0 (LLVMVoidType (), FALSE); /* * if (!*sreg1) @@ -7236,10 +7241,10 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) LLVMPositionBuilderAtEnd (builder, poll_bb); if (ctx->cfg->compile_aot) { - callee = get_callee (ctx, sig, MONO_PATCH_INFO_JIT_ICALL_ID, GUINT_TO_POINTER (MONO_JIT_ICALL_mono_threads_state_poll)); + callee = get_callee (ctx, safe_point_sig, MONO_PATCH_INFO_JIT_ICALL_ID, GUINT_TO_POINTER (MONO_JIT_ICALL_mono_threads_state_poll)); call = LLVMBuildCall (builder, callee, NULL, 0, ""); } else { - callee = get_jit_callee (ctx, icall_name, sig, MONO_PATCH_INFO_ABS, ctx->module->gc_poll_cold_wrapper_compiled); + callee = get_jit_callee (ctx, icall_name, safe_point_sig, MONO_PATCH_INFO_ABS, ctx->module->gc_poll_cold_wrapper_compiled); call = LLVMBuildCall (builder, callee, NULL, 0, ""); set_call_cold_cconv (call); } @@ -7444,8 +7449,8 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) if (!var) { LLVMValueRef indexes [16]; - LLVMValueRef name_var = LLVMAddGlobal (ctx->lmodule, LLVMArrayType (LLVMInt8Type (), strlen (name) + 1), "@OBJC_METH_VAR_NAME_"); - LLVMSetInitializer (name_var, mono_llvm_create_constant_data_array ((const uint8_t*)name, strlen (name) + 1)); + LLVMValueRef name_var = LLVMAddGlobal (ctx->lmodule, LLVMArrayType (LLVMInt8Type (), (unsigned int)(strlen (name) + 1)), "@OBJC_METH_VAR_NAME_"); + LLVMSetInitializer (name_var, mono_llvm_create_constant_data_array ((const uint8_t*)name, (int)(strlen (name) + 1))); LLVMSetLinkage (name_var, LLVMPrivateLinkage); LLVMSetSection (name_var, "__TEXT,__objc_methname,cstring_literals"); mark_as_used (ctx->module, name_var); @@ -7631,7 +7636,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) case OP_FMAX: case OP_FMIN: { #if defined(TARGET_X86) || defined(TARGET_AMD64) - LLVMValueRef args [] = { l, r }; + LLVMValueRef min_max_args [] = { l, r }; LLVMTypeRef t = LLVMTypeOf (l); LLVMTypeRef elem_t = LLVMGetElementType (t); unsigned int elems = LLVMGetVectorSize (t); @@ -7651,7 +7656,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) else iid = is_r4 ? INTRINS_SSE_MINPS : INTRINS_SSE_MINPD; } - result = call_intrins (ctx, iid, args, dname); + result = call_intrins (ctx, iid, min_max_args, dname); } else { LLVMRealPredicate op = ins->inst_c0 == OP_FMAX ? LLVMRealUGE : LLVMRealULE; LLVMValueRef cmp = LLVMBuildFCmp (builder, op, l, r, ""); @@ -7659,10 +7664,10 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) } #elif defined(TARGET_ARM64) - LLVMValueRef args [] = { l, r }; + LLVMValueRef min_max_args [] = { l, r }; IntrinsicId iid = ins->inst_c0 == OP_FMAX ? INTRINS_AARCH64_ADV_SIMD_FMAX : INTRINS_AARCH64_ADV_SIMD_FMIN; llvm_ovr_tag_t ovr_tag = ovr_tag_from_mono_vector_class (ins->klass); - result = call_overloaded_intrins (ctx, iid, ovr_tag, args, ""); + result = call_overloaded_intrins (ctx, iid, ovr_tag, min_max_args, ""); #else NOT_IMPLEMENTED; #endif @@ -7698,9 +7703,9 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) default: g_assert_not_reached (); } - LLVMValueRef args [] = { l, r }; + LLVMValueRef call_args [] = { l, r }; llvm_ovr_tag_t ovr_tag = ovr_tag_from_mono_vector_class (ins->klass); - result = call_overloaded_intrins (ctx, iid, ovr_tag, args, ""); + result = call_overloaded_intrins (ctx, iid, ovr_tag, call_args, ""); } #else LLVMValueRef cmp = LLVMBuildICmp (builder, op, l, r, ""); @@ -11247,10 +11252,9 @@ static LLVMCallInfo* get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig) { LLVMCallInfo *linfo; - int i; if (cfg->gsharedvt && cfg->llvm_only && mini_is_gsharedvt_variable_signature (sig)) { - int i, n, pindex; + int n, pindex; /* * Gsharedvt methods have the following calling convention: @@ -11277,7 +11281,7 @@ get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig) linfo->ret.storage = LLVMArgNone; } - for (i = 0; i < sig->param_count; ++i) { + for (int i = 0; i < sig->param_count; ++i) { if (m_type_is_byref (sig->params [i])) linfo->args [pindex].storage = LLVMArgNormal; else if (mini_is_gsharedvt_variable_type (sig->params [i])) @@ -11294,7 +11298,7 @@ get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig) linfo = mono_arch_get_llvm_call_info (cfg, sig); linfo->dummy_arg_pindex = -1; - for (i = 0; i < sig->param_count; ++i) + for (int i = 0; i < sig->param_count; ++i) linfo->args [i + sig->hasthis].type = sig->params [i]; return linfo; @@ -11368,7 +11372,6 @@ mono_llvm_emit_method (MonoCompile *cfg) EmitContext *ctx; char *method_name; gboolean is_linkonce = FALSE; - int i; if (cfg->skip) return; @@ -11450,7 +11453,7 @@ mono_llvm_emit_method (MonoCompile *cfg) builder = create_builder (ctx); LLVMPositionBuilderAtEnd (builder, phi_bb); - for (i = 0; i < ctx->phi_values->len; ++i) { + for (int i = 0; i < ctx->phi_values->len; ++i) { LLVMValueRef v = (LLVMValueRef)g_ptr_array_index (ctx->phi_values, i); if (LLVMGetInstructionParent (v) == NULL) LLVMInsertIntoBuilder (builder, v); @@ -11503,14 +11506,13 @@ emit_method_inner (EmitContext *ctx) LLVMTypeRef method_type; LLVMValueRef method = NULL; LLVMValueRef *values = ctx->values; - int i, max_block_num, bb_index; + int max_block_num, bb_index; gboolean llvmonly_fail = FALSE; LLVMCallInfo *linfo; LLVMModuleRef lmodule = ctx->lmodule; BBInfo *bblocks; GPtrArray *bblock_list = ctx->bblock_list; MonoMethodHeader *header; - MonoExceptionClause *clause; char **names; LLVMBuilderRef entry_builder = NULL; LLVMBasicBlockRef entry_bb = NULL; @@ -11706,8 +11708,8 @@ emit_method_inner (EmitContext *ctx) #endif header = cfg->header; - for (i = 0; i < header->num_clauses; ++i) { - clause = &header->clauses [i]; + for (int i = 0; i < header->num_clauses; ++i) { + MonoExceptionClause *clause = &header->clauses [i]; if (clause->flags != MONO_EXCEPTION_CLAUSE_FINALLY && clause->flags != MONO_EXCEPTION_CLAUSE_FAULT && clause->flags != MONO_EXCEPTION_CLAUSE_NONE) { if (cfg->llvm_only) { if (!cfg->deopt && !cfg->interp_entry_only) @@ -11764,7 +11766,7 @@ emit_method_inner (EmitContext *ctx) mono_method_get_param_names (cfg->method, (const char **) names); /* Set parameter names/attributes */ - for (i = 0; i < sig->param_count; ++i) { + for (int i = 0; i < sig->param_count; ++i) { LLVMArgInfo *ainfo = &linfo->args [i + sig->hasthis]; char *name; int pindex = ainfo->pindex + ainfo->ndummy_fpargs; @@ -11880,7 +11882,7 @@ emit_method_inner (EmitContext *ctx) * Set the expected type of the incoming arguments since these have * to have the same type. */ - for (i = 0; i < ins->inst_phi_args [0]; i++) { + for (int i = 0; i < ins->inst_phi_args [0]; i++) { int sreg1 = ins->inst_phi_args [i + 1]; if (sreg1 != -1) { @@ -11975,7 +11977,7 @@ emit_method_inner (EmitContext *ctx) cursor++; } - LLVMBasicBlockRef lpad_bb = emit_llvmonly_landing_pad (ctx, group_index, count); + LLVMBasicBlockRef lpad_bb = emit_llvmonly_landing_pad (ctx, (int)group_index, count); intptr_t key = CLAUSE_END (&cfg->header->clauses [group_index]); g_hash_table_insert (ctx->exc_meta, (gpointer)key, lpad_bb); @@ -12069,7 +12071,7 @@ emit_method_inner (EmitContext *ctx) GSList *bb_list = info->call_handler_return_bbs; GSList *bb_list_iter; - i = 0; + int i = 0; for (bb_list_iter = bb_list; bb_list_iter; bb_list_iter = g_slist_next (bb_list_iter)) { LLVMAddCase (switch_ins, LLVMConstInt (LLVMInt32Type (), i + 1, FALSE), (LLVMBasicBlockRef)bb_list_iter->data); i ++; @@ -12085,13 +12087,13 @@ emit_method_inner (EmitContext *ctx) /* * FIXME: Maybe fallback to interpreter */ - static LLVMTypeRef sig; + static LLVMTypeRef missing_method_sig; ctx->builder = create_builder (ctx); LLVMPositionBuilderAtEnd (ctx->builder, ctx->inited_bb); char *name = mono_method_get_full_name (cfg->method); - int len = strlen (name); + int len = (int)strlen (name); LLVMTypeRef type = LLVMArrayType (LLVMInt8Type (), len + 1); LLVMValueRef name_var = LLVMAddGlobal (ctx->lmodule, type, "missing_method_name"); @@ -12101,9 +12103,9 @@ emit_method_inner (EmitContext *ctx) mono_llvm_set_is_constant (name_var); g_free (name); - if (!sig) - sig = LLVMFunctionType1 (LLVMVoidType (), ctx->module->ptr_type, FALSE); - LLVMValueRef callee = get_callee (ctx, sig, MONO_PATCH_INFO_JIT_ICALL_ADDR, GUINT_TO_POINTER (MONO_JIT_ICALL_mini_llvmonly_throw_aot_failed_exception)); + if (!missing_method_sig) + missing_method_sig = LLVMFunctionType1 (LLVMVoidType (), ctx->module->ptr_type, FALSE); + LLVMValueRef callee = get_callee (ctx, missing_method_sig, MONO_PATCH_INFO_JIT_ICALL_ADDR, GUINT_TO_POINTER (MONO_JIT_ICALL_mini_llvmonly_throw_aot_failed_exception)); LLVMValueRef args [] = { convert (ctx, name_var, ctx->module->ptr_type) }; LLVMBuildCall (ctx->builder, callee, args, 1, ""); LLVMBuildUnreachable (ctx->builder); @@ -12187,7 +12189,7 @@ emit_method_inner (EmitContext *ctx) method_index = mono_aot_get_method_index (cfg->orig_method); else method_index = 1; - md_args [0] = LLVMMDString (ctx->method_name, strlen (ctx->method_name)); + md_args [0] = LLVMMDString (ctx->method_name, (unsigned int)strlen (ctx->method_name)); md_args [1] = LLVMConstInt (LLVMInt32Type (), method_index, FALSE); md_node = LLVMMDNode (md_args, 2); LLVMAddNamedMetadataOperand (lmodule, "mono.function_indexes", md_node); @@ -12240,10 +12242,9 @@ mono_llvm_create_vars (MonoCompile *cfg) if (mini_is_gsharedvt_variable_signature (sig) && sig->ret->type != MONO_TYPE_VOID) { vretaddr = TRUE; } else { - MonoMethodSignature *sig = mono_method_signature_internal (cfg->method); LLVMCallInfo *linfo; - linfo = get_llvm_call_info (cfg, sig); + linfo = get_llvm_call_info (cfg, mono_method_signature_internal (cfg->method)); vretaddr = (linfo->ret.storage == LLVMArgVtypeRetAddr || linfo->ret.storage == LLVMArgVtypeByRef || linfo->ret.storage == LLVMArgGsharedvtFixed || linfo->ret.storage == LLVMArgGsharedvtVariable || linfo->ret.storage == LLVMArgGsharedvtFixedVtype); } if (vretaddr) { @@ -13405,7 +13406,7 @@ mono_llvm_emit_aot_module (const char *filename, const char *cu_name) static LLVMValueRef md_string (const char *s) { - return LLVMMDString (s, strlen (s)); + return LLVMMDString (s, (unsigned int)strlen (s)); } /* Debugging support */ @@ -13428,13 +13429,13 @@ emit_dbg_info (MonoLLVMModule *module, const char *filename, const char *cu_name mono_llvm_di_builder_finalize (module->di_builder); args [0] = LLVMConstInt (LLVMInt32Type (), 2, FALSE); - args [1] = LLVMMDString ("Dwarf Version", strlen ("Dwarf Version")); + args [1] = LLVMMDString ("Dwarf Version", (unsigned int)strlen ("Dwarf Version")); args [2] = LLVMConstInt (LLVMInt32Type (), 2, FALSE); ver = LLVMMDNode (args, 3); LLVMAddNamedMetadataOperand (lmodule, "llvm.module.flags", ver); args [0] = LLVMConstInt (LLVMInt32Type (), 2, FALSE); - args [1] = LLVMMDString ("Debug Info Version", strlen ("Debug Info Version")); + args [1] = LLVMMDString ("Debug Info Version", (unsigned int)strlen ("Debug Info Version")); args [2] = LLVMConstInt (LLVMInt64Type (), 3, FALSE); ver = LLVMMDNode (args, 3); LLVMAddNamedMetadataOperand (lmodule, "llvm.module.flags", ver); diff --git a/src/mono/mono/mini/mini-runtime.c b/src/mono/mono/mini/mini-runtime.c index 8c274dace16c8..0db698109afd4 100644 --- a/src/mono/mono/mini/mini-runtime.c +++ b/src/mono/mono/mini/mini-runtime.c @@ -1548,7 +1548,7 @@ mono_resolve_patch_target_ext (MonoMemoryManager *mem_manager, MonoMethod *metho break; case MONO_PATCH_INFO_ADJUSTED_IID: mono_class_init_internal (patch_info->data.klass); - target = GUINT_TO_POINTER ((guint32)(-((m_class_get_interface_id (patch_info->data.klass) + 1) * TARGET_SIZEOF_VOID_P))); + target = GUINT_TO_POINTER ((guint32)(-(gint32)((m_class_get_interface_id (patch_info->data.klass) + 1) * TARGET_SIZEOF_VOID_P))); break; case MONO_PATCH_INFO_VTABLE: target = mono_class_vtable_checked (patch_info->data.klass, error); @@ -2535,7 +2535,6 @@ compile_special (MonoMethod *method, MonoError *error) if (info->subtype == WRAPPER_SUBTYPE_GSHAREDVT_IN || info->subtype == WRAPPER_SUBTYPE_GSHAREDVT_OUT) { static MonoTrampInfo *in_tinfo, *out_tinfo; MonoTrampInfo *tinfo; - MonoJitInfo *jinfo; gboolean is_in = info->subtype == WRAPPER_SUBTYPE_GSHAREDVT_IN; if (is_in && in_tinfo) @@ -2605,14 +2604,14 @@ mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, gboolean jit_ callinfo = mono_find_jit_icall_info (winfo->d.icall.jit_icall_id); if (method->wrapper_type == MONO_WRAPPER_OTHER) { - WrapperInfo *info = mono_marshal_get_wrapper_info (method); + WrapperInfo *wrapper_info = mono_marshal_get_wrapper_info (method); - g_assert (info); - if (info->subtype == WRAPPER_SUBTYPE_SYNCHRONIZED_INNER) { + g_assert (wrapper_info ); + if (wrapper_info ->subtype == WRAPPER_SUBTYPE_SYNCHRONIZED_INNER) { MonoGenericContext *ctx = NULL; if (method->is_inflated) ctx = mono_method_get_context (method); - method = info->d.synchronized_inner.method; + method = wrapper_info ->d.synchronized_inner.method; if (ctx) { method = mono_class_inflate_generic_method_checked (method, ctx, error); g_assert (is_ok (error)); /* FIXME don't swallow the error */ diff --git a/src/mono/mono/mini/mini-runtime.h b/src/mono/mono/mini/mini-runtime.h index 85eee6a34a916..16b367a42b346 100644 --- a/src/mono/mono/mini/mini-runtime.h +++ b/src/mono/mono/mini/mini-runtime.h @@ -700,10 +700,12 @@ void mini_register_sigterm_handler (void); } while (0) #define MINI_END_CODEGEN(buf,size,type,arg) do { \ + MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ \ mono_codeman_disable_write (); \ mono_arch_flush_icache ((buf), (size)); \ if ((int)type != -1) \ MONO_PROFILER_RAISE (jit_code_buffer, ((buf), (size), (MonoProfilerCodeBufferType)(type), (arg))); \ + MONO_RESTORE_WARNING \ } while (0) #endif /* __MONO_MINI_RUNTIME_H__ */ diff --git a/src/mono/mono/mini/mini-trampolines.c b/src/mono/mono/mini/mini-trampolines.c index 81b597cc49f74..d5d356eac3a10 100644 --- a/src/mono/mono/mini/mini-trampolines.c +++ b/src/mono/mono/mini/mini-trampolines.c @@ -428,7 +428,6 @@ common_call_trampoline (host_mgreg_t *regs, guint8 *code, MonoMethod *m, MonoVTa gboolean generic_shared = FALSE; gboolean need_unbox_tramp = FALSE; gboolean need_rgctx_tramp = FALSE; - MonoMethod *declaring = NULL; MonoMethod *generic_virtual = NULL, *variant_iface = NULL; int context_used; gboolean imt_call, virtual_; @@ -513,13 +512,14 @@ common_call_trampoline (host_mgreg_t *regs, guint8 *code, MonoMethod *m, MonoVTa } } + MonoMethod *declaring = NULL; + /* * The virtual check is needed because is_generic_method_definition (m) could * return TRUE for methods used in IMT calls too. */ if (virtual_ && is_generic_method_definition (m)) { MonoGenericContext context = { NULL, NULL }; - MonoMethod *declaring; if (m->is_inflated) declaring = mono_method_get_declaring_generic_method (m); @@ -543,7 +543,7 @@ common_call_trampoline (host_mgreg_t *regs, guint8 *code, MonoMethod *m, MonoVTa } else if ((context_used = mono_method_check_context_used (m))) { MonoClass *klass = NULL; MonoMethod *actual_method = NULL; - MonoVTable *vt = NULL; + MonoVTable *actual_vt = NULL; MonoGenericInst *method_inst = NULL; vtable_slot = NULL; @@ -570,7 +570,7 @@ common_call_trampoline (host_mgreg_t *regs, guint8 *code, MonoMethod *m, MonoVTa } else { MonoObject *this_argument = (MonoObject *)mono_arch_get_this_arg_from_call (regs, code); - vt = this_argument->vtable; + actual_vt = this_argument->vtable; vtable_slot = orig_vtable_slot; g_assert (m_class_is_inited (this_argument->vtable->klass)); @@ -584,13 +584,13 @@ common_call_trampoline (host_mgreg_t *regs, guint8 *code, MonoMethod *m, MonoVTa g_assert (vtable_slot || klass); if (vtable_slot) { - int displacement = vtable_slot - ((gpointer*)vt); + int displacement = vtable_slot - ((gpointer*)actual_vt ); g_assert_not_reached (); g_assert (displacement > 0); - actual_method = m_class_get_vtable (vt->klass) [displacement]; + actual_method = m_class_get_vtable (actual_vt ->klass) [displacement]; } if (method_inst || m->wrapper_type) { diff --git a/src/mono/mono/mini/mini-windows-tls-callback.c b/src/mono/mono/mini/mini-windows-tls-callback.c index b2438670dd8be..616ccf0cc2510 100644 --- a/src/mono/mono/mini/mini-windows-tls-callback.c +++ b/src/mono/mono/mini/mini-windows-tls-callback.c @@ -13,6 +13,8 @@ /* both for DLL and LIB callbacks, so no need to protect this variable. */ static MonoWin32TLSCallbackType mono_win32_tls_callback_type = MONO_WIN32_TLS_CALLBACK_TYPE_NONE; +MONO_DISABLE_WARNING(4189) /* local variable is initialized but not referenced */ + /* NOTE, this function needs to be in this source file to make sure linker */ /* resolve this symbol from mini-windows.c, picking up callback and */ /* included it in TLS Directory PE header. Function makes sure we only activate */ @@ -33,6 +35,8 @@ mono_win32_handle_tls_callback_type (MonoWin32TLSCallbackType callback_type) return TRUE; } +MONO_RESTORE_WARNING + VOID NTAPI mono_win32_tls_callback (PVOID module_handle, DWORD reason, PVOID reserved); VOID NTAPI mono_win32_tls_callback (PVOID module_handle, DWORD reason, PVOID reserved) diff --git a/src/mono/mono/mini/mini-x86.c b/src/mono/mono/mini/mini-x86.c index 3b9b108b16581..9e3fb6fe8a844 100644 --- a/src/mono/mono/mini/mini-x86.c +++ b/src/mono/mono/mini/mini-x86.c @@ -42,6 +42,8 @@ #include "aot-runtime.h" #include "mini-runtime.h" +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ + static GENERATE_TRY_GET_CLASS_WITH_CACHE (math, "System", "Math") @@ -1180,7 +1182,7 @@ mono_arch_allocate_vars (MonoCompile *cfg) mini_gc_set_slot_type_from_fp (cfg, - prev_offset, SLOT_NOREF); } } - cfg->locals_min_stack_offset = - (offset + locals_stack_size); + cfg->locals_min_stack_offset = - (offset + (gint)locals_stack_size); cfg->locals_max_stack_offset = - offset; /* * EBP is at alignment 8 % MONO_ARCH_FRAME_ALIGNMENT, so if we @@ -1194,7 +1196,7 @@ mono_arch_allocate_vars (MonoCompile *cfg) } for (i = cfg->locals_start; i < cfg->num_varinfo; i++) { if (offsets [i] != -1) { - MonoInst *inst = cfg->varinfo [i]; + inst = cfg->varinfo [i]; inst->opcode = OP_REGOFFSET; inst->inst_basereg = X86_EBP; inst->inst_offset = - (offset + offsets [i]); @@ -1769,11 +1771,10 @@ if (ins->inst_true_bb->native_offset) { \ x86_branch (code, cond, cfg->native_code + ins->inst_true_bb->native_offset, sign); \ } else { \ mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_BB, ins->inst_true_bb); \ - if ((cfg->opt & MONO_OPT_BRANCH) && \ - x86_is_imm8 (ins->inst_true_bb->max_offset - cpos)) \ + if ((cfg->opt & MONO_OPT_BRANCH) && x86_is_imm8 (ins->inst_true_bb->max_offset - cpos)) \ x86_branch8 (code, cond, 0, sign); \ - else \ - x86_branch32 (code, cond, 0, sign); \ + else \ + x86_branch32 (code, cond, 0, sign); \ } /* @@ -3092,7 +3093,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) /* restore callee saved registers */ for (i = 0; i < X86_NREG; ++i) - if (X86_IS_CALLEE_SAVED_REG (i) && cfg->used_int_regs & (1 << i)) + if (X86_IS_CALLEE_SAVED_REG (i) && cfg->used_int_regs & ((regmask_t)1 << i)) pos -= 4; if (cfg->used_int_regs & (1 << X86_ESI)) { x86_mov_reg_membase (code, X86_ESI, X86_EBP, pos, 4); @@ -3413,7 +3414,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) } else { mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_R8, ins->inst_p0); - x86_fld (code, NULL, TRUE); + x86_fld (code, (gsize)NULL, TRUE); } } break; @@ -3434,7 +3435,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) } else { mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_R4, ins->inst_p0); - x86_fld (code, NULL, FALSE); + x86_fld (code, (gsize)NULL, FALSE); } } break; @@ -4263,6 +4264,9 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_ATOMIC_STORE_U4: size = 4; break; + default: + size = 0; + g_assert_not_reached (); } x86_mov_membase_reg (code, ins->inst_destbasereg, ins->inst_offset, ins->sreg1, size); @@ -4286,8 +4290,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) int nursery_shift, card_table_shift; gpointer card_table_mask; size_t nursery_size; - gulong card_table = (gsize)mono_gc_get_card_table (&card_table_shift, &card_table_mask); - gulong nursery_start = (gsize)mono_gc_get_nursery (&nursery_shift, &nursery_size); + gulong card_table = (gulong)(gsize)mono_gc_get_card_table (&card_table_shift, &card_table_mask); + gulong nursery_start = (gulong)(gsize)mono_gc_get_nursery (&nursery_shift, &nursery_size); gboolean card_table_nursery_check = mono_gc_card_table_nursery_check (); /* @@ -5279,7 +5283,7 @@ mono_arch_emit_epilog (MonoCompile *cfg) /* EBP is restored by LEAVE */ } else { for (i = 0; i < X86_NREG; ++i) { - if ((cfg->used_int_regs & X86_CALLER_REGS & (1 << i)) && (i != X86_EBP)) { + if ((cfg->used_int_regs & X86_CALLER_REGS & ((regmask_t)1 << i)) && (i != X86_EBP)) { pos -= 4; } } @@ -6162,7 +6166,6 @@ void mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *long_ins) { MonoInst *ins; - int vreg; if (long_ins->opcode == OP_LNEG) { ins = long_ins; @@ -6174,7 +6177,7 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *long_ins) } #ifdef MONO_ARCH_SIMD_INTRINSICS - + int vreg; if (!(cfg->opt & MONO_OPT_SIMD)) return; diff --git a/src/mono/mono/mini/mini.c b/src/mono/mono/mini/mini.c index feaec0ae870c9..19df1cc193e5e 100644 --- a/src/mono/mono/mini/mini.c +++ b/src/mono/mono/mini/mini.c @@ -2348,7 +2348,7 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile) } else { num_clauses = header->num_clauses; int dead_clauses = 0; - for (int i = 0; i < header->num_clauses; ++i) + for (unsigned int i = 0; i < header->num_clauses; ++i) if (cfg->clause_is_dead [i]) dead_clauses ++; num_clauses -= dead_clauses; @@ -2492,7 +2492,7 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile) memcpy (&jinfo->clauses [0], &cfg->llvm_ex_info [0], num_clauses * sizeof (MonoJitExceptionInfo)); } else { int eindex = 0; - for (int i = 0; i < header->num_clauses; i++) { + for (unsigned int i = 0; i < header->num_clauses; i++) { MonoExceptionClause *ec = &header->clauses [i]; MonoJitExceptionInfo *ei = &jinfo->clauses [eindex]; MonoBasicBlock *tblock; @@ -2878,7 +2878,7 @@ remove_empty_finally_pass (MonoCompile *cfg) if (!cfg->llvm_only) return; - for (int i = 0; i < cfg->header->num_clauses; ++i) { + for (unsigned int i = 0; i < cfg->header->num_clauses; ++i) { MonoExceptionClause *clause = &cfg->header->clauses [i]; if (clause->flags == MONO_EXCEPTION_CLAUSE_FINALLY) { @@ -2913,7 +2913,7 @@ remove_empty_finally_pass (MonoCompile *cfg) * Avoid doing this in nested clauses, because it might mess up the EH code generated by * the llvm backend. */ - for (int j = 0; j < cfg->header->num_clauses; ++j) { + for (unsigned int j = 0; j < cfg->header->num_clauses; ++j) { MonoExceptionClause *clause2 = &cfg->header->clauses [j]; if (i != j && MONO_OFFSET_IN_CLAUSE (clause2, clause->handler_offset)) @@ -3076,7 +3076,6 @@ mini_method_compile (MonoMethod *method, guint32 opts, JitFlags flags, int parts MonoMethodHeader *header; MonoMethodSignature *sig; MonoCompile *cfg; - int i; gboolean try_generic_shared, try_llvm = FALSE; MonoMethod *method_to_compile, *method_to_register; gboolean method_is_gshared = FALSE; @@ -3393,9 +3392,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, JitFlags flags, int parts verbose_method_inited = TRUE; } if (verbose_method_names) { - int i; - - for (i = 0; verbose_method_names [i] != NULL; i++){ + for (size_t i = 0; verbose_method_names [i] != NULL; i++){ const char *name = verbose_method_names [i]; if ((strchr (name, '.') > name) || strchr (name, ':') || strchr (name, '*')) { @@ -3463,7 +3460,8 @@ mini_method_compile (MonoMethod *method, guint32 opts, JitFlags flags, int parts mono_cfg_dump_create_context (cfg); mono_cfg_dump_begin_group (cfg); - MONO_TIME_TRACK (mono_jit_stats.jit_method_to_ir, i = mono_method_to_ir (cfg, method_to_compile, NULL, NULL, NULL, NULL, 0, FALSE)); + int inline_cost; + MONO_TIME_TRACK (mono_jit_stats.jit_method_to_ir, inline_cost = mono_method_to_ir (cfg, method_to_compile, NULL, NULL, NULL, NULL, 0, FALSE)); mono_cfg_dump_ir (cfg, "method-to-ir"); if (cfg->gdump_ctx != NULL) { @@ -3472,7 +3470,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, JitFlags flags, int parts mono_cfg_dump_ir (cfg, "mono_insert_nop_in_empty_bb"); } - if (i < 0) { + if (inline_cost < 0) { if (try_generic_shared && cfg->exception_type == MONO_EXCEPTION_GENERIC_SHARING_FAILED) { if (compile_aot) { if (MONO_METHOD_COMPILE_END_ENABLED ()) @@ -3597,7 +3595,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, JitFlags flags, int parts if (cfg->llvm_only && cfg->interp && !cfg->method->wrapper_type && !interp_entry_only && !cfg->deopt) { /* Disable llvm if there are still finally clauses left */ - for (int i = 0; i < cfg->header->num_clauses; ++i) { + for (unsigned int i = 0; i < cfg->header->num_clauses; ++i) { MonoExceptionClause *clause = &header->clauses [i]; if (clause->flags == MONO_EXCEPTION_CLAUSE_FINALLY && !cfg->clause_is_dead [i]) { cfg->exception_message = g_strdup ("finally clause."); @@ -3915,7 +3913,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, JitFlags flags, int parts if (cfg->extend_live_ranges) { /* Extend live ranges to cover the whole method */ - for (i = 0; i < cfg->num_varinfo; ++i) + for (guint i = 0; i < cfg->num_varinfo; ++i) MONO_VARINFO (cfg, i)->live_range_end = cfg->code_len; } diff --git a/src/mono/mono/mini/seq-points.c b/src/mono/mono/mini/seq-points.c index 4a6c2dbb3710e..62fbf12275255 100644 --- a/src/mono/mono/mini/seq-points.c +++ b/src/mono/mono/mini/seq-points.c @@ -62,10 +62,10 @@ recursively_make_pred_seq_points (MonoCompile *cfg, MonoBasicBlock *bb) recursively_make_pred_seq_points (cfg, in_bb); // Union sequence points with incoming bb's - for (int i=0; i < in_bb->num_pred_seq_points; i++) { - if (!g_hash_table_lookup (seen, in_bb->pred_seq_points [i])) { - g_array_append_val (predecessors, in_bb->pred_seq_points [i]); - g_hash_table_insert (seen, in_bb->pred_seq_points [i], (gpointer)&MONO_SEQ_SEEN_LOOP); + for (guint j = 0; j < in_bb->num_pred_seq_points; j++) { + if (!g_hash_table_lookup (seen, in_bb->pred_seq_points [j])) { + g_array_append_val (predecessors, in_bb->pred_seq_points [j]); + g_hash_table_insert (seen, in_bb->pred_seq_points [j], (gpointer)&MONO_SEQ_SEEN_LOOP); } } // predecessors = g_array_append_vals (predecessors, in_bb->pred_seq_points, in_bb->num_pred_seq_points); @@ -77,7 +77,7 @@ recursively_make_pred_seq_points (MonoCompile *cfg, MonoBasicBlock *bb) bb->pred_seq_points = (MonoInst **)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoInst *) * predecessors->len); bb->num_pred_seq_points = predecessors->len; - for (int newer = 0; newer < bb->num_pred_seq_points; newer++) { + for (guint newer = 0; newer < bb->num_pred_seq_points; newer++) { bb->pred_seq_points [newer] = g_array_index(predecessors, MonoInst*, newer); } } @@ -92,7 +92,7 @@ collect_pred_seq_points (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins, GS if (bb->pred_seq_points == NULL && bb != cfg->bb_entry) recursively_make_pred_seq_points (cfg, bb); - for (int i = 0; i < bb->num_pred_seq_points; i++) + for (guint i = 0; i < bb->num_pred_seq_points; i++) insert_pred_seq_point (bb->pred_seq_points [i], ins, next); return; @@ -171,8 +171,7 @@ mono_save_seq_point_info (MonoCompile *cfg, MonoJitInfo *jinfo) endfinally_seq_point = (MonoInst *)l->data; for (bb2 = bb->next_bb; bb2; bb2 = bb2->next_bb) { - GSList *l = g_slist_last (bb2->seq_points); - + l = g_slist_last (bb2->seq_points); if (l) { MonoInst *ins = (MonoInst *)l->data; @@ -189,7 +188,6 @@ mono_save_seq_point_info (MonoCompile *cfg, MonoJitInfo *jinfo) for (i = 0; i < cfg->seq_points->len; ++i) { SeqPoint *sp = &seq_points [i]; - GSList *l; if (!next [i]) continue; diff --git a/src/mono/mono/mini/simd-intrinsics.c b/src/mono/mono/mini/simd-intrinsics.c index d5ee25393c544..e4efe5cfc5357 100644 --- a/src/mono/mono/mini/simd-intrinsics.c +++ b/src/mono/mono/mini/simd-intrinsics.c @@ -1513,7 +1513,7 @@ emit_vector64_vector128_t (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign case SN_op_Subtraction: { if (fsig->param_count != 2 ) return NULL; - MonoTypeEnum arg0_type = fsig->param_count > 0 ? get_underlying_type (fsig->params [0]) : MONO_TYPE_VOID; + arg0_type = fsig->param_count > 0 ? get_underlying_type (fsig->params [0]) : MONO_TYPE_VOID; return emit_simd_ins_for_binary_op (cfg, klass, fsig, args, arg0_type, id); } @@ -1722,7 +1722,7 @@ emit_sys_numerics_vector_t (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSig MonoTypeEnum ty = etype->type; int opcode = type_to_xextract_op (ty); int src1 = load_simd_vreg (cfg, cmethod, args [0], NULL); - MonoInst *ins = emit_simd_ins (cfg, klass, opcode, src1, args [1]->dreg); + ins = emit_simd_ins (cfg, klass, opcode, src1, args [1]->dreg); ins->inst_c1 = ty; return ins; } @@ -3538,7 +3538,6 @@ emit_x86_intrinsics ( int ctlreg = args [1]->dreg; if (fsig->param_count == 2) { } else if (fsig->param_count == 3) { - MonoInst *ins = NULL; /* This intrinsic is also implemented in managed code. * TODO: remove this if cross-AOT-assembly inlining works */ diff --git a/src/mono/mono/mini/ssa.c b/src/mono/mono/mini/ssa.c index df1ac7fb78ccf..521c2f94375bb 100644 --- a/src/mono/mono/mini/ssa.c +++ b/src/mono/mono/mini/ssa.c @@ -613,7 +613,7 @@ mono_ssa_remove_gsharedvt (MonoCompile *cfg) void mono_ssa_remove (MonoCompile *cfg) { - MonoInst *ins, *var, *move; + MonoInst *ins, *move; int bbindex, i, j, first; g_assert (cfg->comp_done & MONO_COMP_SSA); @@ -627,7 +627,7 @@ mono_ssa_remove (MonoCompile *cfg) for (ins = bb->code; ins; ins = ins->next) { if (MONO_IS_PHI (ins)) { g_assert (ins->inst_phi_args [0] == bb->in_count); - var = get_vreg_to_inst (cfg, ins->dreg); + MonoInst *var = get_vreg_to_inst (cfg, ins->dreg); /* Check for PHI nodes where all the inputs are the same */ first = ins->inst_phi_args [1]; @@ -1484,8 +1484,7 @@ void mono_ssa_loop_invariant_code_motion (MonoCompile *cfg) { MonoBasicBlock *bb, *h, *idom; - MonoInst *ins, *n, *tins; - int i; + MonoInst *ins, *n; g_assert (cfg->comp_done & MONO_COMP_SSA); if (!(cfg->comp_done & MONO_COMP_LOOPS) || !(cfg->comp_done & MONO_COMP_SSA_DEF_USE)) @@ -1504,6 +1503,7 @@ mono_ssa_loop_invariant_code_motion (MonoCompile *cfg) * Try to move instructions out of loop headers into the preceeding bblock. */ if (ins->opcode == OP_LDLEN || ins->opcode == OP_STRLEN || ins->opcode == OP_CHECK_THIS || ins->opcode == OP_AOTCONST || ins->opcode == OP_GENERIC_CLASS_INIT) { + MonoInst *tins; gboolean skip; int sreg; @@ -1542,7 +1542,7 @@ mono_ssa_loop_invariant_code_motion (MonoCompile *cfg) else sreg = -1; if (sreg != -1) { - MonoInst *tins, *var; + MonoInst *var; skip = FALSE; for (tins = ins->prev; tins; tins = tins->prev) { @@ -1585,7 +1585,7 @@ mono_ssa_loop_invariant_code_motion (MonoCompile *cfg) } cfg->comp_done &= ~MONO_COMP_SSA_DEF_USE; - for (i = 0; i < cfg->num_varinfo; i++) { + for (guint i = 0; i < cfg->num_varinfo; i++) { MonoMethodVar *info = MONO_VARINFO (cfg, i); info->def = NULL; info->uses = NULL; diff --git a/src/mono/mono/mini/trace.c b/src/mono/mono/mini/trace.c index 7ba279e8488b8..ee25dad0e75d2 100644 --- a/src/mono/mono/mini/trace.c +++ b/src/mono/mono/mini/trace.c @@ -144,7 +144,6 @@ mono_trace_enter_method (MonoMethod *method, MonoJitInfo *ji, MonoProfilerCallCo { int i; MonoClass *klass; - MonoObject *o; MonoMethodSignature *sig; char *fname; MonoGenericSharingContext *gsctx = NULL; @@ -254,7 +253,7 @@ mono_trace_enter_method (MonoMethod *method, MonoJitInfo *ji, MonoProfilerCallCo } case MONO_TYPE_CLASS: case MONO_TYPE_OBJECT: { - o = *arg_in_stack_slot(buf, MonoObject *); + MonoObject *o = *arg_in_stack_slot(buf, MonoObject *); if (o) { klass = o->vtable->klass; diff --git a/src/mono/mono/mini/tramp-amd64-gsharedvt.c b/src/mono/mono/mini/tramp-amd64-gsharedvt.c index b8f45e7afe907..e995be5d306d7 100644 --- a/src/mono/mono/mini/tramp-amd64-gsharedvt.c +++ b/src/mono/mono/mini/tramp-amd64-gsharedvt.c @@ -27,6 +27,8 @@ #include "mini-amd64.h" #include "mini-amd64-gsharedvt.h" +MONO_PRAGMA_WARNING_DISABLE(4127) /* conditional expression is constant */ + #if defined (MONO_ARCH_GSHAREDVT_SUPPORTED) #define SRC_REG_SHIFT 0 diff --git a/src/mono/mono/mini/tramp-amd64.c b/src/mono/mono/mini/tramp-amd64.c index 6c4557a4da971..bd3ac516eade5 100644 --- a/src/mono/mono/mini/tramp-amd64.c +++ b/src/mono/mono/mini/tramp-amd64.c @@ -44,6 +44,8 @@ void mono_arch_patch_plt_entry_exec_only (gpointer amodule_info, guint8 *code, g #define IS_REX(inst) (((inst) >= 0x40) && ((inst) <= 0x4f)) +MONO_PRAGMA_WARNING_DISABLE(4127) /* conditional expression is constant */ + #ifndef DISABLE_JIT /* * mono_arch_get_unbox_trampoline: diff --git a/src/mono/mono/mini/tramp-arm-gsharedvt.c b/src/mono/mono/mini/tramp-arm-gsharedvt.c index 0fdb8d85a2bbe..f06b5e63561c0 100644 --- a/src/mono/mono/mini/tramp-arm-gsharedvt.c +++ b/src/mono/mono/mini/tramp-arm-gsharedvt.c @@ -219,9 +219,11 @@ mono_arch_get_gsharedvt_trampoline (MonoTrampInfo **info, gboolean aot) ARM_MOV_REG_REG (code, fp, ARMREG_SP); mono_add_unwind_op_def_cfa_reg (unwind_ops, code, buf, fp); /* Allocate stack frame */ - ARM_SUB_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, 32 + (16 * sizeof (double))); + ARM_SUB_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, (guint32)(32 + (16 * sizeof (double)))); +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ if (MONO_ARCH_FRAME_ALIGNMENT > 8) ARM_SUB_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, (MONO_ARCH_FRAME_ALIGNMENT - 8)); +MONO_RESTORE_WARNING offset = 4; info_offset = -offset; offset += 4; @@ -248,7 +250,7 @@ mono_arch_get_gsharedvt_trampoline (MonoTrampInfo **info, gboolean aot) /* Save caller fregs */ ARM_SUB_REG_IMM8 (code, ARMREG_IP, fp, -caller_freg_area_offset); for (i = 0; i < 8; ++i) - ARM_FSTD (code, i * 2, ARMREG_IP, (i * sizeof (double))); + ARM_FSTD (code, i * 2, ARMREG_IP, ((int)(i * sizeof (double)))); } /* @@ -307,7 +309,7 @@ mono_arch_get_gsharedvt_trampoline (MonoTrampInfo **info, gboolean aot) /* Load argument fregs */ ARM_SUB_REG_IMM8 (code, ARMREG_LR, fp, -callee_freg_area_offset); for (i = 0; i < 8; ++i) - ARM_FLDD (code, i * 2, ARMREG_LR, (i * sizeof (double))); + ARM_FLDD (code, i * 2, ARMREG_LR, ((int)(i * sizeof (double)))); } /* Pop callee register area */ ARM_ADD_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, 4 * TARGET_SIZEOF_VOID_P); diff --git a/src/mono/mono/mini/tramp-arm.c b/src/mono/mono/mini/tramp-arm.c index 4b12b2aab0bda..0ea6a306dcb95 100644 --- a/src/mono/mono/mini/tramp-arm.c +++ b/src/mono/mono/mini/tramp-arm.c @@ -1176,7 +1176,7 @@ mono_arch_get_gsharedvt_arg_trampoline (gpointer arg, gpointer addr) /* Similar to the specialized trampoline code */ ARM_PUSH (code, (1 << ARMREG_R0) | (1 << ARMREG_R1) | (1 << ARMREG_R2) | (1 << ARMREG_R3) | (1 << ARMREG_LR)); - ARM_LDR_IMM (code, ARMREG_IP, ARMREG_PC, 2 * sizeof (target_mgreg_t)); + ARM_LDR_IMM (code, ARMREG_IP, ARMREG_PC, (guint32)(2 * sizeof (target_mgreg_t))); /* arg is passed in LR */ ARM_LDR_IMM (code, ARMREG_LR, ARMREG_PC, 0); code = emit_bx (code, ARMREG_IP); diff --git a/src/mono/mono/mini/tramp-arm64-gsharedvt.c b/src/mono/mono/mini/tramp-arm64-gsharedvt.c index 3a735446a6b0a..e04cfd33805ea 100644 --- a/src/mono/mono/mini/tramp-arm64-gsharedvt.c +++ b/src/mono/mono/mini/tramp-arm64-gsharedvt.c @@ -51,6 +51,10 @@ mono_arch_get_gsharedvt_arg_trampoline (gpointer arg, gpointer addr) return buf; } +MONO_PRAGMA_WARNING_PUSH() +MONO_PRAGMA_WARNING_DISABLE(4701) /* potentially uninitialized local variable 'dst_ptr' used */ +MONO_PRAGMA_WARNING_DISABLE(4703) /* potentially uninitialized local pointer variable 'dst_ptr' used */ + gpointer mono_arm_start_gsharedvt_call (GSharedVtCallInfo *info, gpointer *caller, gpointer *callee, gpointer mrgctx_reg) { @@ -207,6 +211,8 @@ mono_arm_start_gsharedvt_call (GSharedVtCallInfo *info, gpointer *caller, gpoint } } +MONO_PRAGMA_WARNING_POP() + #ifndef DISABLE_JIT gpointer diff --git a/src/mono/mono/mini/tramp-x86-gsharedvt.c b/src/mono/mono/mini/tramp-x86-gsharedvt.c index 58eb280388ae1..ded0b1c2c1656 100644 --- a/src/mono/mono/mini/tramp-x86-gsharedvt.c +++ b/src/mono/mono/mini/tramp-x86-gsharedvt.c @@ -11,6 +11,8 @@ #include "mini.h" #include +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ + #ifdef MONO_ARCH_GSHAREDVT_SUPPORTED gpointer diff --git a/src/mono/mono/mini/tramp-x86.c b/src/mono/mono/mini/tramp-x86.c index b109c4f09bbf1..af10b329a0dd0 100644 --- a/src/mono/mono/mini/tramp-x86.c +++ b/src/mono/mono/mini/tramp-x86.c @@ -29,6 +29,8 @@ #include +MONO_PRAGMA_WARNING_DISABLE(4127) /* conditional expression is constant */ + /* * mono_arch_get_unbox_trampoline: * @m: method pointer @@ -109,13 +111,13 @@ mono_arch_patch_callsite (guint8 *method_start, guint8 *orig_code, guint8 *addr) code -= 6; orig_code -= 6; if (code [1] == 0xe8) { - mono_atomic_xchg_i32 ((gint32*)(orig_code + 2), (gsize)addr - ((gsize)orig_code + 1) - 5); + mono_atomic_xchg_i32 ((gint32*)(orig_code + 2), (gint32)((gsize)addr - ((gsize)orig_code + 1) - 5)); /* Tell valgrind to recompile the patched code */ VALGRIND_DISCARD_TRANSLATIONS (orig_code + 2, 4); } else if (code [1] == 0xe9) { /* A PLT entry: jmp */ - mono_atomic_xchg_i32 ((gint32*)(orig_code + 2), (gsize)addr - ((gsize)orig_code + 1) - 5); + mono_atomic_xchg_i32 ((gint32*)(orig_code + 2), (gint32)((gsize)addr - ((gsize)orig_code + 1) - 5)); } else { printf ("Invalid trampoline sequence: %x %x %x %x %x %x n", code [0], code [1], code [2], code [3], code [4], code [5]); @@ -783,8 +785,8 @@ mono_arch_get_interp_to_native_trampoline (MonoTrampInfo **info) x86_fst_membase (code, X86_ESI, MONO_STRUCT_OFFSET (CallContext, fret), TRUE, TRUE); /* restore ESI, EDI which were saved below rbp */ - x86_mov_reg_membase (code, X86_EDI, X86_EBP, - sizeof (target_mgreg_t), sizeof (target_mgreg_t)); - x86_mov_reg_membase (code, X86_ESI, X86_EBP, - 2 * sizeof (target_mgreg_t), sizeof (target_mgreg_t)); + x86_mov_reg_membase (code, X86_EDI, X86_EBP, - (gint32)sizeof (target_mgreg_t), sizeof (target_mgreg_t)); + x86_mov_reg_membase (code, X86_ESI, X86_EBP, - (gint32)(2 * sizeof (target_mgreg_t)), sizeof (target_mgreg_t)); x86_mov_reg_reg (code, X86_ESP, X86_EBP); x86_pop_reg (code, X86_EBP); diff --git a/src/mono/mono/mini/unwind.c b/src/mono/mono/mini/unwind.c index 554f38e83c3e2..3f4d33ba814b3 100644 --- a/src/mono/mono/mini/unwind.c +++ b/src/mono/mono/mini/unwind.c @@ -164,10 +164,12 @@ mono_hw_reg_to_dwarf_reg (int reg) if (!hw_reg_to_dwarf_reg_inited) init_hw_reg_map (); +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ if (NUM_HW_REGS == 0) { g_assert_not_reached (); return -1; } +MONO_RESTORE_WARNING return map_hw_reg_to_dwarf_reg [reg]; } diff --git a/src/mono/mono/sgen/gc-internal-agnostic.h b/src/mono/mono/sgen/gc-internal-agnostic.h index 581cdb4896e1b..eb2404cdd13aa 100644 --- a/src/mono/mono/sgen/gc-internal-agnostic.h +++ b/src/mono/mono/sgen/gc-internal-agnostic.h @@ -25,8 +25,8 @@ /* h indicates whether to hide or just tag. * (-!!h ^ p) is used instead of (h ? ~p : p) to avoid multiple mentions of p. */ -#define MONO_GC_HIDE_POINTER(p,t,h) ((gpointer)(((-(size_t)!!(h) ^ (size_t)(p)) & ~(size_t)3) | ((t) & (size_t)3))) -#define MONO_GC_REVEAL_POINTER(p,h) ((gpointer)((-(size_t)!!(h) ^ (size_t)(p)) & ~(size_t)3)) +#define MONO_GC_HIDE_POINTER(p,t,h) MONO_DISABLE_WARNING(4146) ((gpointer)(((-(size_t)!!(h) ^ (size_t)(p)) & ~(size_t)3) | ((t) & (size_t)3))) MONO_RESTORE_WARNING +#define MONO_GC_REVEAL_POINTER(p,h) MONO_DISABLE_WARNING(4146) ((gpointer)((-(size_t)!!(h) ^ (size_t)(p)) & ~(size_t)3)) MONO_RESTORE_WARNING #define MONO_GC_POINTER_TAG(p) ((size_t)(p) & (size_t)3) diff --git a/src/mono/mono/sgen/sgen-cardtable.c b/src/mono/mono/sgen/sgen-cardtable.c index a79924fa8eeca..c7dbad964a627 100644 --- a/src/mono/mono/sgen/sgen-cardtable.c +++ b/src/mono/mono/sgen/sgen-cardtable.c @@ -133,6 +133,8 @@ sgen_card_table_wbarrier_generic_nostore (gpointer ptr) sgen_card_table_mark_address ((mword)ptr); } +MONO_DISABLE_WARNING(4189) /* local variable is initialized but not referenced */ + static void sgen_card_table_wbarrier_range_copy (gpointer _dest, gconstpointer _src, int size) { @@ -163,6 +165,8 @@ sgen_card_table_wbarrier_range_copy (gpointer _dest, gconstpointer _src, int siz } } +MONO_RESTORE_WARNING + #ifdef SGEN_HAVE_OVERLAPPING_CARDS guint8 *sgen_shadow_cardtable; diff --git a/src/mono/mono/sgen/sgen-debug.c b/src/mono/mono/sgen/sgen-debug.c index 0a14b0ce0829c..7b54d0b0e5b65 100644 --- a/src/mono/mono/sgen/sgen-debug.c +++ b/src/mono/mono/sgen/sgen-debug.c @@ -177,9 +177,9 @@ static void check_consistency_callback (GCObject *obj, size_t size, void *dummy) { char *start = (char*)obj; - GCVTable vt = LOAD_VTABLE (obj); - SgenDescriptor desc = sgen_vtable_get_descriptor (vt); - SGEN_LOG (8, "Scanning object %p, vtable: %p (%s)", start, vt, sgen_client_vtable_get_name (vt)); + GCVTable vtable = LOAD_VTABLE (obj); + SgenDescriptor desc = sgen_vtable_get_descriptor (vtable); + SGEN_LOG (8, "Scanning object %p, vtable: %p (%s)", start, vtable, sgen_client_vtable_get_name (vtable)); #include "sgen-scan-object.h" } @@ -238,10 +238,10 @@ check_mod_union_callback (GCObject *obj, size_t size, void *dummy) { char *start = (char*)obj; gboolean in_los = (gboolean) (size_t) dummy; - GCVTable vt = LOAD_VTABLE (obj); - SgenDescriptor desc = sgen_vtable_get_descriptor (vt); + GCVTable vtable = LOAD_VTABLE (obj); + SgenDescriptor desc = sgen_vtable_get_descriptor (vtable); guint8 *cards; - SGEN_LOG (8, "Scanning object %p, vtable: %p (%s)", obj, vt, sgen_client_vtable_get_name (vt)); + SGEN_LOG (8, "Scanning object %p, vtable: %p (%s)", obj, vtable, sgen_client_vtable_get_name (vtable)); if (!is_major_or_los_object_marked (obj)) return; @@ -1002,9 +1002,9 @@ static void scan_object_for_xdomain_refs (GCObject *obj, mword size, void *data) { char *start = (char*)obj; - MonoVTable *vt = SGEN_LOAD_VTABLE (obj); - MonoDomain *domain = vt->domain; - SgenDescriptor desc = sgen_vtable_get_descriptor (vt); + MonoVTable *vtable = SGEN_LOAD_VTABLE (obj); + MonoDomain *domain = vtable->domain; + SgenDescriptor desc = sgen_vtable_get_descriptor (vtable); #include "sgen-scan-object.h" } diff --git a/src/mono/mono/sgen/sgen-descriptor.c b/src/mono/mono/sgen/sgen-descriptor.c index 195b13349bf52..b114eda4a2fa5 100644 --- a/src/mono/mono/sgen/sgen-descriptor.c +++ b/src/mono/mono/sgen/sgen-descriptor.c @@ -131,7 +131,7 @@ mono_gc_make_descr_for_object (gsize *bitmap, int numbits, size_t obj_size) if (first_set < 0) { SGEN_LOG (6, "Ptrfree descriptor %" PRIu64 ", size: %zu", (uint64_t)desc, stored_size); if (stored_size <= MAX_RUNLEN_OBJECT_SIZE && stored_size <= SGEN_MAX_SMALL_OBJ_SIZE) - return DESC_TYPE_SMALL_PTRFREE | stored_size; + return (SgenDescriptor)(DESC_TYPE_SMALL_PTRFREE | stored_size); return DESC_TYPE_COMPLEX_PTRFREE; } @@ -141,7 +141,7 @@ mono_gc_make_descr_for_object (gsize *bitmap, int numbits, size_t obj_size) /* we know the 2-word header is ptr-free */ if (last_set < BITMAP_NUM_BITS + OBJECT_HEADER_WORDS && stored_size <= SGEN_MAX_SMALL_OBJ_SIZE) { - desc = DESC_TYPE_BITMAP | ((*bitmap >> OBJECT_HEADER_WORDS) << LOW_TYPE_BITS); + desc = (SgenDescriptor)(DESC_TYPE_BITMAP | ((*bitmap >> OBJECT_HEADER_WORDS) << LOW_TYPE_BITS)); SGEN_LOG (6, "Largebitmap descriptor %" PRIu64 ", size: %zu, last set: %d", (uint64_t)desc, stored_size, last_set); return desc; } @@ -152,7 +152,7 @@ mono_gc_make_descr_for_object (gsize *bitmap, int numbits, size_t obj_size) * It may be better to use nibbles. */ if (first_set < 256 && num_set < 256 && (first_set + num_set == last_set + 1)) { - desc = DESC_TYPE_RUN_LENGTH | stored_size | (first_set << 16) | (num_set << 24); + desc = (SgenDescriptor)(DESC_TYPE_RUN_LENGTH | stored_size | (first_set << 16) | (num_set << 24)); SGEN_LOG (6, "Runlen descriptor %" PRIu64 ", size: %zu, first set: %d, num set: %d", (uint64_t)desc, stored_size, first_set, num_set); return desc; } @@ -180,7 +180,7 @@ mono_gc_make_descr_for_array (int vector, gsize *elem_bitmap, int numbits, size_ if (first_set < 0) { if (elem_size <= MAX_ELEMENT_SIZE) - return desc | VECTOR_SUBTYPE_PTRFREE | (elem_size << VECTOR_ELSIZE_SHIFT); + return (SgenDescriptor)(desc | VECTOR_SUBTYPE_PTRFREE | (elem_size << VECTOR_ELSIZE_SHIFT)); return DESC_TYPE_COMPLEX_PTRFREE; } @@ -196,7 +196,7 @@ mono_gc_make_descr_for_array (int vector, gsize *elem_bitmap, int numbits, size_ /* FIXME: try run-len first */ /* Note: we can't skip the object header here, because it's not present */ if (last_set < VECTOR_BITMAP_SIZE) { - return desc | VECTOR_SUBTYPE_BITMAP | (*elem_bitmap << 16); + return (SgenDescriptor)(desc | VECTOR_SUBTYPE_BITMAP | (*elem_bitmap << 16)); } } /* it's am array of complex structs ... */ @@ -270,7 +270,7 @@ mono_gc_make_descr_from_bitmap (gsize *bitmap, int numbits) if (numbits == 0) { return MAKE_ROOT_DESC (ROOT_DESC_BITMAP, 0); } else if (numbits < ((sizeof (*bitmap) * 8) - ROOT_DESC_TYPE_SHIFT)) { - return MAKE_ROOT_DESC (ROOT_DESC_BITMAP, bitmap [0]); + return (SgenDescriptor)(MAKE_ROOT_DESC (ROOT_DESC_BITMAP, bitmap [0])); } else { SgenDescriptor complex = alloc_complex_descriptor (bitmap, numbits); return MAKE_ROOT_DESC (ROOT_DESC_COMPLEX, complex); diff --git a/src/mono/mono/sgen/sgen-gc.h b/src/mono/mono/sgen/sgen-gc.h index 43e397727abdd..afc70a7e4357a 100644 --- a/src/mono/mono/sgen/sgen-gc.h +++ b/src/mono/mono/sgen/sgen-gc.h @@ -121,8 +121,10 @@ extern guint64 stat_objects_copied_major; #endif #define SGEN_ASSERT(level, a, ...) do { \ + MONO_DISABLE_WARNING(4127) \ if (G_UNLIKELY ((level) <= SGEN_MAX_ASSERT_LEVEL && !(a))) { \ g_error (__VA_ARGS__); \ + MONO_RESTORE_WARNING \ } } while (0) #ifdef HAVE_LOCALTIME_R @@ -146,10 +148,12 @@ extern guint64 stat_objects_copied_major; #endif #define SGEN_LOG(level, format, ...) do { \ + MONO_DISABLE_WARNING(4127) \ if (G_UNLIKELY ((level) <= SGEN_MAX_DEBUG_LEVEL && (level) <= sgen_gc_debug_level)) { \ char logTime[80]; \ LOG_TIMESTAMP; \ mono_gc_printf (sgen_gc_debug_file, "%s " format "\n", logTime, ##__VA_ARGS__); \ + MONO_RESTORE_WARNING \ } } while (0) #define SGEN_COND_LOG(level, cond, format, ...) do { \ diff --git a/src/mono/mono/sgen/sgen-los.c b/src/mono/mono/sgen/sgen-los.c index e181128b293fb..969b64429df65 100644 --- a/src/mono/mono/sgen/sgen-los.c +++ b/src/mono/mono/sgen/sgen-los.c @@ -275,7 +275,7 @@ static LOSObject* get_los_section_memory (size_t size) { LOSSection *section; - LOSFreeChunks *free_chunks; + LOSFreeChunks *free_chunks = NULL; size_t num_chunks; size_t obj_size = size; diff --git a/src/mono/mono/sgen/sgen-marksweep-drain-gray-stack.h b/src/mono/mono/sgen/sgen-marksweep-drain-gray-stack.h index 6bf3dc0a9ae3c..f926ee6d38ce1 100644 --- a/src/mono/mono/sgen/sgen-marksweep-drain-gray-stack.h +++ b/src/mono/mono/sgen/sgen-marksweep-drain-gray-stack.h @@ -49,7 +49,6 @@ COPY_OR_MARK_FUNCTION_NAME (GCObject **ptr, GCObject *obj, SgenGrayQueue *queue) #if !defined(COPY_OR_MARK_CONCURRENT) && !defined(COPY_OR_MARK_CONCURRENT_WITH_EVACUATION) int word, bit; gboolean first; - first = TRUE; GCObject *forwarded, *old_obj; mword vtable_word; vtable_word = *(mword*)obj; @@ -127,6 +126,7 @@ COPY_OR_MARK_FUNCTION_NAME (GCObject **ptr, GCObject *obj, SgenGrayQueue *queue) MS_SET_MARK_BIT_PAR (block, word, bit, first); #else MS_SET_MARK_BIT (block, word, bit); + first = TRUE; #endif if (first) sgen_binary_protocol_mark (obj, (gpointer)SGEN_LOAD_VTABLE (obj), sgen_safe_object_get_size (obj)); diff --git a/src/mono/mono/sgen/sgen-marksweep.c b/src/mono/mono/sgen/sgen-marksweep.c index c9434845f935c..e6a48fd4af861 100644 --- a/src/mono/mono/sgen/sgen-marksweep.c +++ b/src/mono/mono/sgen/sgen-marksweep.c @@ -1068,9 +1068,8 @@ major_dump_heap (FILE *heap_dump_file) MSBlockInfo *block; int *slots_available = g_newa (int, num_block_obj_sizes); int *slots_used = g_newa (int, num_block_obj_sizes); - int i; - for (i = 0; i < num_block_obj_sizes; ++i) + for (int i = 0; i < num_block_obj_sizes; ++i) slots_available [i] = slots_used [i] = 0; FOREACH_BLOCK_NO_LOCK (block) { @@ -1078,27 +1077,26 @@ major_dump_heap (FILE *heap_dump_file) int count = MS_BLOCK_FREE / block->obj_size; slots_available [index] += count; - for (i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { if (MS_OBJ_ALLOCED (MS_BLOCK_OBJ (block, i), block)) ++slots_used [index]; } } END_FOREACH_BLOCK_NO_LOCK; fprintf (heap_dump_file, "\n"); - for (i = 0; i < num_block_obj_sizes; ++i) { + for (int i = 0; i < num_block_obj_sizes; ++i) { fprintf (heap_dump_file, "\n", block_obj_sizes [i], slots_available [i], slots_used [i]); } fprintf (heap_dump_file, "\n"); FOREACH_BLOCK_NO_LOCK (block) { - int count = MS_BLOCK_FREE / block->obj_size; - int i; + int count = MS_BLOCK_FREE / block->obj_size;; int start = -1; fprintf (heap_dump_file, "
\n", "old", (size_t)MS_BLOCK_FREE); - for (i = 0; i <= count; ++i) { + for (int i = 0; i <= count; ++i) { if ((i < count) && MS_OBJ_ALLOCED (MS_BLOCK_OBJ (block, i), block)) { if (start < 0) start = i; @@ -1830,12 +1828,16 @@ sweep_job_func (void *thread_data_untyped, SgenThreadPoolJob *job) g_usleep (100); } +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ +MONO_DISABLE_WARNING(4189) /* local variable is initialized but not referenced */ if (SGEN_MAX_ASSERT_LEVEL >= 6) { for (block_index = num_blocks; block_index < allocated_blocks.next_slot; ++block_index) { MSBlockInfo *block = BLOCK_UNTAG (*sgen_array_list_get_slot (&allocated_blocks, block_index)); SGEN_ASSERT (6, block && block->state == BLOCK_STATE_SWEPT, "How did a new block to be swept get added while swept?"); } } +MONO_RESTORE_WARNING +MONO_RESTORE_WARNING /* * Concurrently sweep all the blocks to reduce workload during minor @@ -2224,7 +2226,7 @@ major_free_swept_blocks (size_t section_reserve) dest = 0; for (i = 0; i < arr_length; ++i) { int d = dest; - void *block = empty_block_arr [i]; + block = empty_block_arr [i]; SGEN_ASSERT (6, block, "we're not shifting correctly"); if (i != dest) { empty_block_arr [dest] = block; @@ -2284,7 +2286,7 @@ major_free_swept_blocks (size_t section_reserve) /* rebuild empty_blocks free list */ rebuild_next = (void**)&empty_blocks; for (i = 0; i < arr_length; ++i) { - void *block = empty_block_arr [i]; + block = empty_block_arr [i]; SGEN_ASSERT (6, block, "we're missing blocks"); *rebuild_next = block; rebuild_next = (void**)block; @@ -2700,6 +2702,7 @@ major_scan_card_table (CardTableScanType scan_type, ScanCopyContext ctx, int job sgen_binary_protocol_major_card_table_scan_start (sgen_timestamp (), scan_type & CARDTABLE_SCAN_MOD_UNION); FOREACH_BLOCK_RANGE_HAS_REFERENCES_NO_LOCK (block, first_block, last_block, index, has_references) { #ifdef PREFETCH_CARDS +MONO_DISABLE_WARNING(4189) /* local variable is initialized but not referenced */ int prefetch_index = index + 6; if (prefetch_index < allocated_blocks.next_slot) { MSBlockInfo *prefetch_block = BLOCK_UNTAG (*sgen_array_list_get_slot (&allocated_blocks, prefetch_index)); @@ -2709,7 +2712,8 @@ major_scan_card_table (CardTableScanType scan_type, ScanCopyContext ctx, int job PREFETCH_WRITE (prefetch_cards); PREFETCH_WRITE (prefetch_cards + 32); } - } + } +MONO_RESTORE_WARNING #endif if (!has_references) continue; diff --git a/src/mono/mono/sgen/sgen-scan-object.h b/src/mono/mono/sgen/sgen-scan-object.h index 334944f25bc5d..6098dd1a2ce3e 100644 --- a/src/mono/mono/sgen/sgen-scan-object.h +++ b/src/mono/mono/sgen/sgen-scan-object.h @@ -33,6 +33,8 @@ * collection, not for debugging scans. */ +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ + { #ifndef SCAN_OBJECT_NOVTABLE #if defined(SGEN_HEAVY_BINARY_PROTOCOL) && defined(SCAN_OBJECT_PROTOCOL) diff --git a/src/mono/mono/utils/checked-build.c b/src/mono/mono/utils/checked-build.c index 8dd5ca5b60b01..20bc248f6ecf6 100644 --- a/src/mono/mono/utils/checked-build.c +++ b/src/mono/mono/utils/checked-build.c @@ -30,6 +30,8 @@ // Selective-enable support +MONO_DISABLE_WARNING(4189) /* local variable is initialized but not referenced */ + // Returns true for check modes which are allowed by both the current DISABLE_ macros and the MONO_CHECK_MODE env var. // Argument may be a bitmask; if so, result is true if at least one specified mode is enabled. mono_bool @@ -69,6 +71,8 @@ mono_check_mode_enabled (MonoCheckMode query) return check_mode & query; } +MONO_RESTORE_WARNING + static int mono_check_transition_limit (void) { diff --git a/src/mono/mono/utils/mach-support-amd64.c b/src/mono/mono/utils/mach-support-amd64.c index e29f7c013ba99..efb7460da9e27 100644 --- a/src/mono/mono/utils/mach-support-amd64.c +++ b/src/mono/mono/utils/mach-support-amd64.c @@ -137,4 +137,10 @@ mono_mach_arch_set_thread_states (thread_port_t thread, thread_state_t state, ma #endif } +#else + +#include + +MONO_EMPTY_SOURCE_FILE (mach_support_amd64); + #endif diff --git a/src/mono/mono/utils/mach-support-unknown.c b/src/mono/mono/utils/mach-support-unknown.c index e6a929176be69..e2fc332191c93 100644 --- a/src/mono/mono/utils/mach-support-unknown.c +++ b/src/mono/mono/utils/mach-support-unknown.c @@ -64,5 +64,10 @@ mono_mach_arch_set_thread_states (thread_port_t thread, thread_state_t state, ma { g_assert_not_reached (); } +#else + +#include + +MONO_EMPTY_SOURCE_FILE (mach_support_unknown); #endif diff --git a/src/mono/mono/utils/mach-support-x86.c b/src/mono/mono/utils/mach-support-x86.c index 6dd775d2c0860..7810d39f42bab 100644 --- a/src/mono/mono/utils/mach-support-x86.c +++ b/src/mono/mono/utils/mach-support-x86.c @@ -119,4 +119,10 @@ mono_mach_arch_set_thread_states (thread_port_t thread, thread_state_t state, ma #endif } +#else + +#include + +MONO_EMPTY_SOURCE_FILE (mach_support_x86); + #endif diff --git a/src/mono/mono/utils/mono-conc-hashtable.c b/src/mono/mono/utils/mono-conc-hashtable.c index 0b4bd7bb0a0c8..f7665214e26aa 100644 --- a/src/mono/mono/utils/mono-conc-hashtable.c +++ b/src/mono/mono/utils/mono-conc-hashtable.c @@ -361,8 +361,7 @@ mono_conc_hashtable_insert (MonoConcurrentHashTable *hash_table, gpointer key, g return NULL; } if (key == kvs [i].key) { - gpointer value = kvs [i].value; - return value; + return kvs [i].value; } i = (i + 1) & table_mask; } @@ -381,8 +380,7 @@ mono_conc_hashtable_insert (MonoConcurrentHashTable *hash_table, gpointer key, g return NULL; } if (equal (key, kvs [i].key)) { - gpointer value = kvs [i].value; - return value; + return kvs [i].value; } i = (i + 1) & table_mask; } diff --git a/src/mono/mono/utils/mono-error.c b/src/mono/mono/utils/mono-error.c index 56af75d820a54..ae4f6b57d6261 100644 --- a/src/mono/mono/utils/mono-error.c +++ b/src/mono/mono/utils/mono-error.c @@ -26,7 +26,7 @@ #define set_error_message() do { \ va_list args; \ va_start (args, msg_format); \ - set_error_messagev(); \ + set_error_messagev(); \ va_end (args); \ } while (0) @@ -666,25 +666,25 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) break; case MONO_ERROR_TYPE_LOAD: { - MonoStringHandle assembly_name; - MonoStringHandle type_name; + MonoStringHandle assembly_name_str; + MonoStringHandle type_name_str; if ((error->type_name && error->assembly_name) || error->exn.klass) { - type_name = get_type_name_as_mono_string (error, error_out); + type_name_str = get_type_name_as_mono_string (error, error_out); if (!is_ok (error_out)) break; if (error->assembly_name) { - assembly_name = string_new_cleanup (error->assembly_name); - if (MONO_HANDLE_IS_NULL (assembly_name)) { + assembly_name_str = string_new_cleanup (error->assembly_name); + if (MONO_HANDLE_IS_NULL (assembly_name_str)) { mono_error_set_out_of_memory (error_out, "Could not allocate assembly name"); break; } } else { - assembly_name = mono_string_empty_handle (); + assembly_name_str = mono_string_empty_handle (); } - exception = mono_exception_from_name_two_strings_checked (mono_get_corlib (), "System", "TypeLoadException", type_name, assembly_name, error_out); + exception = mono_exception_from_name_two_strings_checked (mono_get_corlib (), "System", "TypeLoadException", type_name_str, assembly_name_str, error_out); if (!MONO_HANDLE_IS_NULL (exception)) { const char *full_message = error->full_message; if (full_message && full_message [0]) { diff --git a/src/mono/mono/utils/mono-log-posix.c b/src/mono/mono/utils/mono-log-posix.c index 094a9f1a5bd25..98337496c88b7 100644 --- a/src/mono/mono/utils/mono-log-posix.c +++ b/src/mono/mono/utils/mono-log-posix.c @@ -98,4 +98,11 @@ mono_log_close_syslog() closelog(); #endif } + +#else + +#include + +MONO_EMPTY_SOURCE_FILE (mono_log_posix); + #endif diff --git a/src/mono/mono/utils/mono-os-mutex.c b/src/mono/mono/utils/mono-os-mutex.c index aea54c4dd8fcb..b306c91e23545 100644 --- a/src/mono/mono/utils/mono-os-mutex.c +++ b/src/mono/mono/utils/mono-os-mutex.c @@ -80,5 +80,10 @@ mono_os_cond_timedwait (mono_cond_t *cond, mono_mutex_t *mutex, guint32 timeout_ return res != 0 ? -1 : 0; #endif /* !HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP */ } +#else + +#include + +MONO_EMPTY_SOURCE_FILE (mono_os_mutex); #endif /* HOST_WIN32 */ diff --git a/src/mono/mono/utils/mono-property-hash.c b/src/mono/mono/utils/mono-property-hash.c index 65b257d2e16f7..6f062c495e21a 100644 --- a/src/mono/mono/utils/mono-property-hash.c +++ b/src/mono/mono/utils/mono-property-hash.c @@ -8,6 +8,7 @@ * (C) 2008 Novell, Inc */ +#include #include "mono-property-hash.h" struct _MonoPropertyHash { diff --git a/src/mono/mono/utils/mono-threads.c b/src/mono/mono/utils/mono-threads.c index 06ff059c1f0f4..6b3f1f6c1b961 100644 --- a/src/mono/mono/utils/mono-threads.c +++ b/src/mono/mono/utils/mono-threads.c @@ -1659,7 +1659,7 @@ sleep_interrupt (gpointer data) static guint32 sleep_interruptable (guint32 ms, gboolean *alerted) { - gint64 now, end; + gint64 now = 0, end = 0; g_assert (MONO_INFINITE_WAIT == G_MAXUINT32); @@ -1845,7 +1845,6 @@ MonoNativeThreadHandle mono_threads_open_native_thread_handle (MonoNativeThreadHandle thread_handle) { #ifdef HOST_WIN32 - BOOL success = FALSE; HANDLE new_thread_handle = NULL; g_assert (thread_handle && thread_handle != INVALID_HANDLE_VALUE); diff --git a/src/mono/mono/utils/mono-time.c b/src/mono/mono/utils/mono-time.c index f544c3f9ca5c8..b0afff1f1c57b 100644 --- a/src/mono/mono/utils/mono-time.c +++ b/src/mono/mono/utils/mono-time.c @@ -90,8 +90,10 @@ mono_100ns_datetime (void) { ULARGE_INTEGER ft; +MONO_DISABLE_WARNING(4127) /* conditional expression is constant */ if (sizeof(ft) != sizeof(FILETIME)) g_assert_not_reached (); +MONO_RESTORE_WARNING GetSystemTimeAsFileTime ((FILETIME*) &ft); return ft.QuadPart; diff --git a/src/mono/mono/utils/mono-uri.c b/src/mono/mono/utils/mono-uri.c index ed49c4c96bdb4..9f7b551a1d7c1 100644 --- a/src/mono/mono/utils/mono-uri.c +++ b/src/mono/mono/utils/mono-uri.c @@ -19,9 +19,9 @@ mono_escape_uri_string (const gchar *string) while ((c = (guchar) *string) != 0){ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '-' && c <= ':') || (c >= '&' && c <= '*')) - g_string_append_c (str, c); + g_string_append_c (str, (gchar)c); else if (c == '!' || c == '=' || c == '?' || c == '_' || c == '~') - g_string_append_c (str, c); + g_string_append_c (str, (gchar)c); else { g_string_append_c (str, '%'); g_string_append_c (str, "0123456789ABCDEF" [c >> 4]); diff --git a/src/mono/mono/utils/monobitset.h b/src/mono/mono/utils/monobitset.h index 3b7698c23722e..b91bb7eafe90f 100644 --- a/src/mono/mono/utils/monobitset.h +++ b/src/mono/mono/utils/monobitset.h @@ -33,12 +33,12 @@ enum { #define MONO_BITSET_FOREACH(set,idx,/*stmt*/...) \ do \ { \ - MonoBitSet *set__ = (set); \ - for (int 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__++) { \ - if (set__->data [i__] & ((gsize) 1 << j__)) { \ - guint idx = j__ + i__ * MONO_BITSET_BITS_PER_CHUNK; \ + MonoBitSet *__set = (set); \ + for (int __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++) { \ + if (__set->data [__i] & ((gsize) 1 << __j)) { \ + guint idx = __j + __i * MONO_BITSET_BITS_PER_CHUNK; \ __VA_ARGS__; \ } \ } \ @@ -47,19 +47,19 @@ enum { } while (0) #define mono_bitset_union_fast(dest,src) do { \ - MonoBitSet *tmp_src = (src); \ - MonoBitSet *tmp_dest = (dest); \ - size_t size = (tmp_dest->size / MONO_BITSET_BITS_PER_CHUNK); \ - for (size_t i = 0; i < size; ++i) \ - tmp_dest->data [i] |= tmp_src->data [i]; \ + MonoBitSet *__tmp_src = (src); \ + MonoBitSet *__tmp_dest = (dest); \ + size_t size = (__tmp_dest->size / MONO_BITSET_BITS_PER_CHUNK); \ + for (size_t __i = 0; __i < size; ++__i) \ + __tmp_dest->data [__i] |= __tmp_src->data [__i]; \ } while (0) #define mono_bitset_sub_fast(dest,src) do { \ - MonoBitSet *tmp_src = (src); \ - MonoBitSet *tmp_dest = (dest); \ - size_t size = tmp_dest->size / MONO_BITSET_BITS_PER_CHUNK; \ - for (size_t i = 0; i < size; ++i) \ - tmp_dest->data [i] &= ~tmp_src->data [i]; \ + MonoBitSet *__tmp_src = (src); \ + MonoBitSet *__tmp_dest = (dest); \ + size_t size = __tmp_dest->size / MONO_BITSET_BITS_PER_CHUNK; \ + for (size_t __i = 0; __i < size; ++__i) \ + __tmp_dest->data [__i] &= ~__tmp_src->data [__i]; \ } while (0) /* @@ -67,59 +67,58 @@ enum { * Interface documentation by Dennis Haney. */ -MONO_API guint32 mono_bitset_alloc_size (guint32 max_size, guint32 flags); +MONO_API guint32 mono_bitset_alloc_size (guint32 max_size, guint32 flags); -MONO_API MonoBitSet* mono_bitset_new (guint32 max_size, guint32 flags); +MONO_API MonoBitSet* mono_bitset_new (guint32 max_size, guint32 flags); -MONO_API MonoBitSet* mono_bitset_mem_new (gpointer mem, guint32 max_size, guint32 flags); +MONO_API MonoBitSet* mono_bitset_mem_new (gpointer mem, guint32 max_size, guint32 flags); -MONO_API void mono_bitset_free (MonoBitSet *set); +MONO_API void mono_bitset_free (MonoBitSet *set); -MONO_API void mono_bitset_set (MonoBitSet *set, guint32 pos); +MONO_API void mono_bitset_set (MonoBitSet *set, guint32 pos); -MONO_API void mono_bitset_set_all (MonoBitSet *set); +MONO_API void mono_bitset_set_all (MonoBitSet *set); -MONO_API int mono_bitset_test (const MonoBitSet *set, guint32 pos); +MONO_API int mono_bitset_test (const MonoBitSet *set, guint32 pos); -MONO_API gsize mono_bitset_test_bulk (const MonoBitSet *set, guint32 pos); +MONO_API gsize mono_bitset_test_bulk (const MonoBitSet *set, guint32 pos); -MONO_API void mono_bitset_clear (MonoBitSet *set, guint32 pos); +MONO_API void mono_bitset_clear (MonoBitSet *set, guint32 pos); -MONO_API void mono_bitset_clear_all (MonoBitSet *set); +MONO_API void mono_bitset_clear_all (MonoBitSet *set); -MONO_API void mono_bitset_invert (MonoBitSet *set); +MONO_API void mono_bitset_invert (MonoBitSet *set); -MONO_API guint32 mono_bitset_size (const MonoBitSet *set); +MONO_API guint32 mono_bitset_size (const MonoBitSet *set); -MONO_API guint32 mono_bitset_count (const MonoBitSet *set); +MONO_API guint32 mono_bitset_count (const MonoBitSet *set); -MONO_API void mono_bitset_low_high (const MonoBitSet *set, guint32 *low, guint32 *high); +MONO_API void mono_bitset_low_high (const MonoBitSet *set, guint32 *low, guint32 *high); -MONO_API int mono_bitset_find_start (const MonoBitSet *set); +MONO_API int mono_bitset_find_start (const MonoBitSet *set); -MONO_API int mono_bitset_find_first (const MonoBitSet *set, gint pos); +MONO_API int mono_bitset_find_first (const MonoBitSet *set, gint pos); -MONO_API int mono_bitset_find_last (const MonoBitSet *set, gint pos); +MONO_API int mono_bitset_find_last (const MonoBitSet *set, gint pos); -MONO_API int mono_bitset_find_first_unset (const MonoBitSet *set, gint pos); +MONO_API int mono_bitset_find_first_unset (const MonoBitSet *set, gint pos); -MONO_API MonoBitSet* mono_bitset_clone (const MonoBitSet *set, guint32 new_size); +MONO_API MonoBitSet* mono_bitset_clone (const MonoBitSet *set, guint32 new_size); -MONO_API void mono_bitset_copyto (const MonoBitSet *src, MonoBitSet *dest); +MONO_API void mono_bitset_copyto (const MonoBitSet *src, MonoBitSet *dest); -MONO_API void mono_bitset_union (MonoBitSet *dest, const MonoBitSet *src); +MONO_API void mono_bitset_union (MonoBitSet *dest, const MonoBitSet *src); -MONO_API void mono_bitset_intersection (MonoBitSet *dest, const MonoBitSet *src); +MONO_API void mono_bitset_intersection (MonoBitSet *dest, const MonoBitSet *src); -MONO_API void mono_bitset_sub (MonoBitSet *dest, const MonoBitSet *src); +MONO_API void mono_bitset_sub (MonoBitSet *dest, const MonoBitSet *src); -MONO_API gboolean mono_bitset_equal (const MonoBitSet *src, const MonoBitSet *src1); +MONO_API gboolean mono_bitset_equal (const MonoBitSet *src, const MonoBitSet *src1); -MONO_API void mono_bitset_foreach (MonoBitSet *set, MonoBitSetFunc func, gpointer data); +MONO_API void mono_bitset_foreach (MonoBitSet *set, MonoBitSetFunc func, gpointer data); -MONO_API void mono_bitset_intersection_2 (MonoBitSet *dest, const MonoBitSet *src1, const MonoBitSet *src2); +MONO_API void mono_bitset_intersection_2 (MonoBitSet *dest, const MonoBitSet *src1, const MonoBitSet *src2); -gboolean -mono_bitset_test_safe (const MonoBitSet *set, guint32 pos); +gboolean mono_bitset_test_safe (const MonoBitSet *set, guint32 pos); #endif /* __MONO_BITSET_H__ */ diff --git a/src/mono/mono/utils/options.c b/src/mono/mono/utils/options.c index 044ab3cbdf47c..aff520fc93858 100644 --- a/src/mono/mono/utils/options.c +++ b/src/mono/mono/utils/options.c @@ -99,7 +99,6 @@ void mono_options_parse_options (const char **argv, int argc, int *out_argc, MonoError *error) { int aindex = 0; - int i; GHashTable *option_hash = NULL; while (aindex < argc) { @@ -114,7 +113,7 @@ mono_options_parse_options (const char **argv, int argc, int *out_argc, MonoErro if (option_hash == NULL) { /* Compute a hash to avoid n^2 behavior */ option_hash = g_hash_table_new (g_str_hash, g_str_equal); - for (i = 0; i < G_N_ELEMENTS (option_meta); ++i) { + for (size_t i = 0; i < G_N_ELEMENTS (option_meta); ++i) { g_hash_table_insert (option_hash, (gpointer)option_meta [i].cmd_name, &option_meta [i]); } } @@ -216,7 +215,7 @@ mono_options_parse_options (const char **argv, int argc, int *out_argc, MonoErro /* Remove processed arguments */ aindex = 0; - for (i = 0; i < argc; ++i) { + for (int i = 0; i < argc; ++i) { if (argv [i]) argv [aindex ++] = argv [i]; } diff --git a/src/native/eventpipe/ds-dump-protocol.c b/src/native/eventpipe/ds-dump-protocol.c index 790c4e38360fc..fad56800a5b34 100644 --- a/src/native/eventpipe/ds-dump-protocol.c +++ b/src/native/eventpipe/ds-dump-protocol.c @@ -158,7 +158,7 @@ ds_dump_protocol_helper_handle_ipc_message ( #endif /* !defined(DS_INCLUDE_SOURCE_FILES) || defined(DS_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef DS_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(DS_INCLUDE_SOURCE_FILES) && !defined(DS_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_diagnostics_dump_protocol; const char quiet_linker_empty_file_warning_diagnostics_dump_protocol = 0; #endif diff --git a/src/native/eventpipe/ds-eventpipe-protocol.c b/src/native/eventpipe/ds-eventpipe-protocol.c index 36c3588b2a3db..f5082bf994955 100644 --- a/src/native/eventpipe/ds-eventpipe-protocol.c +++ b/src/native/eventpipe/ds-eventpipe-protocol.c @@ -560,7 +560,7 @@ ds_eventpipe_protocol_helper_handle_ipc_message ( #endif /* !defined(DS_INCLUDE_SOURCE_FILES) || defined(DS_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef DS_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(DS_INCLUDE_SOURCE_FILES) && !defined(DS_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_diagnostics_eventpipe_protocol; const char quiet_linker_empty_file_warning_diagnostics_eventpipe_protocol = 0; #endif diff --git a/src/native/eventpipe/ds-ipc.c b/src/native/eventpipe/ds-ipc.c index b9c00030e69bf..a216a3e4c2bab 100644 --- a/src/native/eventpipe/ds-ipc.c +++ b/src/native/eventpipe/ds-ipc.c @@ -893,7 +893,7 @@ ds_listen_port_free (DiagnosticsListenPort *listen_port) #endif /* !defined(DS_INCLUDE_SOURCE_FILES) || defined(DS_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef DS_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(DS_INCLUDE_SOURCE_FILES) && !defined(DS_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_diagnostics_ipc; const char quiet_linker_empty_file_warning_diagnostics_ipc = 0; #endif diff --git a/src/native/eventpipe/ds-process-protocol.c b/src/native/eventpipe/ds-process-protocol.c index 75886a79ff3c2..6f97ac29078cf 100644 --- a/src/native/eventpipe/ds-process-protocol.c +++ b/src/native/eventpipe/ds-process-protocol.c @@ -796,7 +796,7 @@ ds_process_protocol_helper_handle_ipc_message ( #endif /* !defined(DS_INCLUDE_SOURCE_FILES) || defined(DS_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef DS_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(DS_INCLUDE_SOURCE_FILES) && !defined(DS_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_diagnostics_process_protocol; const char quiet_linker_empty_file_warning_diagnostics_process_protocol = 0; #endif diff --git a/src/native/eventpipe/ds-profiler-protocol.c b/src/native/eventpipe/ds-profiler-protocol.c index 56cc5a559fdc9..ea7035eb980c6 100644 --- a/src/native/eventpipe/ds-profiler-protocol.c +++ b/src/native/eventpipe/ds-profiler-protocol.c @@ -299,7 +299,7 @@ ds_profiler_protocol_helper_handle_ipc_message ( #endif /* !defined(DS_INCLUDE_SOURCE_FILES) || defined(DS_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef DS_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(DS_INCLUDE_SOURCE_FILES) && !defined(DS_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_diagnostics_profiler_protocol; const char quiet_linker_empty_file_warning_diagnostics_profiler_protocol = 0; #endif diff --git a/src/native/eventpipe/ds-protocol.c b/src/native/eventpipe/ds-protocol.c index a49b741013885..2ad6e7cca2130 100644 --- a/src/native/eventpipe/ds-protocol.c +++ b/src/native/eventpipe/ds-protocol.c @@ -239,7 +239,7 @@ ipc_message_try_parse ( uint16_t payload_len; payload_len = message->header.size - sizeof (message->header); if (payload_len != 0) { - uint8_t *buffer = ep_rt_byte_array_alloc (payload_len); + buffer = ep_rt_byte_array_alloc (payload_len); ep_raise_error_if_nok (buffer != NULL); result = ds_ipc_stream_read (stream, buffer, payload_len, &bytes_read, EP_INFINITE_WAIT); @@ -671,7 +671,7 @@ ds_ipc_header_get_generic_error (void) #endif /* !defined(DS_INCLUDE_SOURCE_FILES) || defined(DS_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef DS_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(DS_INCLUDE_SOURCE_FILES) && !defined(DS_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_diagnostics_protocol; const char quiet_linker_empty_file_warning_diagnostics_protocol = 0; #endif diff --git a/src/native/eventpipe/ds-server.c b/src/native/eventpipe/ds-server.c index 710b18465d7eb..6f1d694899d76 100644 --- a/src/native/eventpipe/ds-server.c +++ b/src/native/eventpipe/ds-server.c @@ -291,7 +291,7 @@ ds_server_is_paused_in_startup (void) #endif /* !defined(DS_INCLUDE_SOURCE_FILES) || defined(DS_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef DS_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(DS_INCLUDE_SOURCE_FILES) && !defined(DS_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_diagnostics_server; const char quiet_linker_empty_file_warning_diagnostics_server = 0; #endif diff --git a/src/native/eventpipe/ep-block.c b/src/native/eventpipe/ep-block.c index 0bd7d1e941a76..d684810933140 100644 --- a/src/native/eventpipe/ep-block.c +++ b/src/native/eventpipe/ep-block.c @@ -1095,7 +1095,7 @@ ep_stack_block_write_stack ( #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_block; const char quiet_linker_empty_file_warning_eventpipe_block = 0; #endif diff --git a/src/native/eventpipe/ep-buffer-manager.c b/src/native/eventpipe/ep-buffer-manager.c index 5b7c0592caf1b..5909370d82b73 100644 --- a/src/native/eventpipe/ep-buffer-manager.c +++ b/src/native/eventpipe/ep-buffer-manager.c @@ -1489,7 +1489,7 @@ ep_buffer_manager_ensure_consistency (EventPipeBufferManager *buffer_manager) #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_buffer_manager; const char quiet_linker_empty_file_warning_eventpipe_buffer_manager = 0; #endif diff --git a/src/native/eventpipe/ep-buffer.c b/src/native/eventpipe/ep-buffer.c index 50b951e55f95f..f13dc1e96aaa8 100644 --- a/src/native/eventpipe/ep-buffer.c +++ b/src/native/eventpipe/ep-buffer.c @@ -263,7 +263,7 @@ ep_buffer_ensure_consistency (const EventPipeBuffer *buffer) #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_buffer; const char quiet_linker_empty_file_warning_eventpipe_buffer = 0; #endif diff --git a/src/native/eventpipe/ep-config.c b/src/native/eventpipe/ep-config.c index 489127b4885cd..f2b24b215dadc 100644 --- a/src/native/eventpipe/ep-config.c +++ b/src/native/eventpipe/ep-config.c @@ -642,7 +642,7 @@ ep_event_metdata_event_free (EventPipeEventMetadataEvent *metadata_event) #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_configuration; const char quiet_linker_empty_file_warning_eventpipe_configuration = 0; #endif diff --git a/src/native/eventpipe/ep-event-instance.c b/src/native/eventpipe/ep-event-instance.c index 4266d2bbcf23b..70f9a9bcce8d1 100644 --- a/src/native/eventpipe/ep-event-instance.c +++ b/src/native/eventpipe/ep-event-instance.c @@ -289,7 +289,7 @@ ep_sequence_point_free (EventPipeSequencePoint *sequence_point) #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_event_instance; const char quiet_linker_empty_file_warning_eventpipe_event_instance = 0; #endif diff --git a/src/native/eventpipe/ep-event-payload.c b/src/native/eventpipe/ep-event-payload.c index b878fc1729bdc..f74e5844f6854 100644 --- a/src/native/eventpipe/ep-event-payload.c +++ b/src/native/eventpipe/ep-event-payload.c @@ -143,7 +143,7 @@ ep_event_payload_copy_data ( EventData *event_data = event_payload->event_data; for (uint32_t i = 0; i < event_payload->event_data_len; ++i) { EP_ASSERT ((offset + ep_event_data_get_size (&event_data[i])) <= event_payload->size); - memcpy (dst + offset, (uint8_t *)ep_event_data_get_ptr (&event_data[i]), ep_event_data_get_size (&event_data[i])); + memcpy (dst + offset, (uint8_t *)(uintptr_t)ep_event_data_get_ptr (&event_data[i]), ep_event_data_get_size (&event_data[i])); offset += ep_event_data_get_size (&event_data[i]); } } @@ -182,7 +182,7 @@ ep_event_payload_get_flat_data (EventPipeEventPayload *event_payload) #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_event_payload; const char quiet_linker_empty_file_warning_eventpipe_event_payload = 0; #endif diff --git a/src/native/eventpipe/ep-event-source.c b/src/native/eventpipe/ep-event-source.c index 0da7ebc50caad..2b631205116e7 100644 --- a/src/native/eventpipe/ep-event-source.c +++ b/src/native/eventpipe/ep-event-source.c @@ -235,7 +235,7 @@ ep_event_source_send_process_info ( #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_event_source; const char quiet_linker_empty_file_warning_eventpipe_event_source = 0; #endif diff --git a/src/native/eventpipe/ep-event.c b/src/native/eventpipe/ep-event.c index 68dc3e8fab73d..62934f40b2cb9 100644 --- a/src/native/eventpipe/ep-event.c +++ b/src/native/eventpipe/ep-event.c @@ -105,7 +105,7 @@ ep_event_free (EventPipeEvent *ep_event) #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_event_internals; const char quiet_linker_empty_file_warning_eventpipe_event_internals = 0; #endif diff --git a/src/native/eventpipe/ep-file.c b/src/native/eventpipe/ep-file.c index 1606d7a9c2fed..cfbcafa75c2a7 100644 --- a/src/native/eventpipe/ep-file.c +++ b/src/native/eventpipe/ep-file.c @@ -634,7 +634,7 @@ ep_stack_hash_key_equal (const void *key1, const void *key2) #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_file; const char quiet_linker_empty_file_warning_eventpipe_file = 0; #endif diff --git a/src/native/eventpipe/ep-json-file.c b/src/native/eventpipe/ep-json-file.c index 5340895424b03..a582bec2b7050 100644 --- a/src/native/eventpipe/ep-json-file.c +++ b/src/native/eventpipe/ep-json-file.c @@ -150,9 +150,7 @@ ep_json_file_write_event_data ( #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_CHECKED_BUILD -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_json_file; const char quiet_linker_empty_file_warning_eventpipe_json_file = 0; #endif -#endif diff --git a/src/native/eventpipe/ep-metadata-generator.c b/src/native/eventpipe/ep-metadata-generator.c index b347aa06d7248..25a8b647a291e 100644 --- a/src/native/eventpipe/ep-metadata-generator.c +++ b/src/native/eventpipe/ep-metadata-generator.c @@ -365,7 +365,7 @@ ep_parameter_desc_fini (EventPipeParameterDesc *parameter_desc) #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_metadata_generator; const char quiet_linker_empty_file_warning_eventpipe_metadata_generator = 0; #endif diff --git a/src/native/eventpipe/ep-provider.c b/src/native/eventpipe/ep-provider.c index b9077c8601eef..566b09270d3af 100644 --- a/src/native/eventpipe/ep-provider.c +++ b/src/native/eventpipe/ep-provider.c @@ -508,7 +508,7 @@ provider_add_event ( #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_provider; const char quiet_linker_empty_file_warning_eventpipe_provider = 0; #endif diff --git a/src/native/eventpipe/ep-sample-profiler.c b/src/native/eventpipe/ep-sample-profiler.c index 2459a51cf51ef..20ba42a764a33 100644 --- a/src/native/eventpipe/ep-sample-profiler.c +++ b/src/native/eventpipe/ep-sample-profiler.c @@ -336,7 +336,7 @@ ep_sample_profiler_get_sampling_rate (void) #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_sample_profiler; const char quiet_linker_empty_file_warning_eventpipe_sample_profiler = 0; #endif diff --git a/src/native/eventpipe/ep-session-provider.c b/src/native/eventpipe/ep-session-provider.c index a27ba4e52f938..99682b626016d 100644 --- a/src/native/eventpipe/ep-session-provider.c +++ b/src/native/eventpipe/ep-session-provider.c @@ -155,7 +155,7 @@ ep_session_provider_list_add_session_provider ( #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_session_provider; const char quiet_linker_empty_file_warning_eventpipe_session_provider = 0; #endif diff --git a/src/native/eventpipe/ep-session.c b/src/native/eventpipe/ep-session.c index 4f572f98b49b4..6f16f990d0e71 100644 --- a/src/native/eventpipe/ep-session.c +++ b/src/native/eventpipe/ep-session.c @@ -578,7 +578,7 @@ ep_session_resume (EventPipeSession *session) #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_session; const char quiet_linker_empty_file_warning_eventpipe_session = 0; #endif diff --git a/src/native/eventpipe/ep-stack-contents.c b/src/native/eventpipe/ep-stack-contents.c index a2e96e28f85b9..99a293e714f61 100644 --- a/src/native/eventpipe/ep-stack-contents.c +++ b/src/native/eventpipe/ep-stack-contents.c @@ -53,7 +53,7 @@ ep_stack_contents_free (EventPipeStackContents *stack_contents) #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_stack_contents; const char quiet_linker_empty_file_warning_eventpipe_stack_contents = 0; #endif diff --git a/src/native/eventpipe/ep-stream.c b/src/native/eventpipe/ep-stream.c index fafe72b06db1d..6ee479407f4ff 100644 --- a/src/native/eventpipe/ep-stream.c +++ b/src/native/eventpipe/ep-stream.c @@ -679,7 +679,7 @@ ep_stream_writer_write ( #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_stream; const char quiet_linker_empty_file_warning_eventpipe_stream = 0; #endif diff --git a/src/native/eventpipe/ep-thread.c b/src/native/eventpipe/ep-thread.c index 16d65388cf599..5146961a3a898 100644 --- a/src/native/eventpipe/ep-thread.c +++ b/src/native/eventpipe/ep-thread.c @@ -483,7 +483,7 @@ ep_thread_session_state_increment_sequence_number (EventPipeThreadSessionState * #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe_thread; const char quiet_linker_empty_file_warning_eventpipe_thread = 0; #endif diff --git a/src/native/eventpipe/ep.c b/src/native/eventpipe/ep.c index bdac36b3effe4..15e2811b2eb91 100644 --- a/src/native/eventpipe/ep.c +++ b/src/native/eventpipe/ep.c @@ -439,7 +439,7 @@ is_session_id_in_collection (EventPipeSessionID session_id) ep_requires_lock_held (); - const EventPipeSession *const session = (EventPipeSession *)session_id; + const EventPipeSession *const session = (EventPipeSession *)(uintptr_t)session_id; for (uint32_t i = 0; i < EP_MAX_NUMBER_OF_SESSIONS; ++i) { if (ep_volatile_load_session (i) == session) { EP_ASSERT (i == ep_session_get_index (session)); @@ -564,7 +564,7 @@ disable_holding_lock ( ep_requires_lock_held (); if (is_session_id_in_collection (id)) { - EventPipeSession *const session = (EventPipeSession *)id; + EventPipeSession *const session = (EventPipeSession *)(uintptr_t)id; if (session_requested_sampling (session)) { // Disable the profiler. @@ -1154,7 +1154,7 @@ ep_get_session (EventPipeSessionID session_id) ep_on_exit: ep_requires_lock_not_held (); - return (EventPipeSession *)session_id; + return (EventPipeSession *)(uintptr_t)session_id; ep_on_error: session_id = 0; @@ -1165,7 +1165,7 @@ bool ep_is_session_enabled (EventPipeSessionID session_id) { ep_return_false_if_nok (session_id != 0); - return ep_volatile_load_session (ep_session_get_index ((EventPipeSession *)session_id)) != NULL; + return ep_volatile_load_session (ep_session_get_index ((EventPipeSession *)(uintptr_t)session_id)) != NULL; } void @@ -1176,7 +1176,7 @@ ep_start_streaming (EventPipeSessionID session_id) EP_LOCK_ENTER (section1) ep_raise_error_if_nok_holding_lock (is_session_id_in_collection (session_id), section1); if (_ep_can_start_threads) - ep_session_start_streaming ((EventPipeSession *)session_id); + ep_session_start_streaming ((EventPipeSession *)(uintptr_t)session_id); else ep_rt_session_id_array_append (&_ep_deferred_enable_session_ids, session_id); EP_LOCK_EXIT (section1) @@ -1376,7 +1376,7 @@ ep_finish_init (void) while (!ep_rt_session_id_array_iterator_end (&_ep_deferred_enable_session_ids, &deferred_session_ids_iterator)) { EventPipeSessionID session_id = ep_rt_session_id_array_iterator_value (&deferred_session_ids_iterator); if (is_session_id_in_collection (session_id)) - ep_session_start_streaming ((EventPipeSession *)session_id); + ep_session_start_streaming ((EventPipeSession *)(uintptr_t)session_id); ep_rt_session_id_array_iterator_next (&deferred_session_ids_iterator); } ep_rt_session_id_array_clear (&_ep_deferred_enable_session_ids); @@ -1659,7 +1659,7 @@ ep_ipc_stream_factory_callback_set (EventPipeIpcStreamFactorySuspendedPortsCallb #endif /* !defined(EP_INCLUDE_SOURCE_FILES) || defined(EP_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ -#ifndef EP_INCLUDE_SOURCE_FILES +#if !defined(ENABLE_PERFTRACING) || (defined(EP_INCLUDE_SOURCE_FILES) && !defined(EP_FORCE_INCLUDE_SOURCE_FILES)) extern const char quiet_linker_empty_file_warning_eventpipe; const char quiet_linker_empty_file_warning_eventpipe = 0; #endif