Merge pull request #4967 from kumpera/profiler-arg-cleanup
authorRodrigo Kumpera <kumpera@users.noreply.github.com>
Mon, 12 Jun 2017 17:07:24 +0000 (10:07 -0700)
committerGitHub <noreply@github.com>
Mon, 12 Jun 2017 17:07:24 +0000 (10:07 -0700)
Rework profiler argument handling.

1  2 
mono/mini/aot-compiler.c
mono/profiler/Makefile.am
mono/profiler/mprof-report.c

diff --combined mono/mini/aot-compiler.c
index fb372baa5e1b39852f89994e24211c5ea36fb2dd,626473c8d0b846c2f271127a88be0c10ad5cd1f2..3c4e3aa899f535656ae0429158f5bf8af40dec6c
@@@ -56,7 -56,7 +56,7 @@@
  #include <mono/utils/mono-rand.h>
  #include <mono/utils/json.h>
  #include <mono/utils/mono-threads-coop.h>
- #include <mono/profiler/mono-profiler-aot.h>
+ #include <mono/profiler/aot.h>
  #include <mono/utils/w32api.h>
  
  #include "aot-compiler.h"
@@@ -78,7 -78,7 +78,7 @@@
  #define TARGET_WIN32_MSVC
  #endif
  
 -#if defined(__linux__) || defined(__native_client_codegen__)
 +#if defined(__linux__)
  #define RODATA_SECT ".rodata"
  #elif defined(TARGET_MACH)
  #define RODATA_SECT ".section __TEXT, __const"
@@@ -953,8 -953,10 +953,8 @@@ emit_code_bytes (MonoAotCompile *acfg, 
  #ifdef TARGET_X86
  #ifdef TARGET_WIN32
  #define AOT_TARGET_STR "X86 (WIN32)"
 -#elif defined(__native_client_codegen__)
 -#define AOT_TARGET_STR "X86 (native client codegen)"
  #else
 -#define AOT_TARGET_STR "X86 (!native client codegen)"
 +#define AOT_TARGET_STR "X86"
  #endif
  #endif
  
@@@ -4427,13 -4429,7 +4427,13 @@@ method_has_type_vars (MonoMethod *metho
  static
  gboolean mono_aot_mode_is_full (MonoAotOptions *opts)
  {
 -      return opts->mode == MONO_AOT_MODE_FULL;
 +      return opts->mode == MONO_AOT_MODE_FULL || opts->mode == MONO_AOT_MODE_INTERP;
 +}
 +
 +static
 +gboolean mono_aot_mode_is_interp (MonoAotOptions *opts)
 +{
 +      return opts->mode == MONO_AOT_MODE_INTERP;
  }
  
  static
@@@ -6827,11 -6823,6 +6827,11 @@@ emit_trampolines (MonoAotCompile *acfg
  
  #endif /* #ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES */
  
 +              if (mono_aot_mode_is_interp (&acfg->aot_opts)) {
 +                      mono_arch_get_enter_icall_trampoline (&info);
 +                      emit_trampoline (acfg, acfg->got_offset, info);
 +              }
 +
                /* Emit trampolines which are numerous */
  
                /*
@@@ -7172,8 -7163,6 +7172,8 @@@ mono_aot_parse_options (const char *aot
                        opts->mode = MONO_AOT_MODE_FULL;
                } else if (str_begins_with (arg, "hybrid")) {
                        opts->mode = MONO_AOT_MODE_HYBRID;                      
 +              } else if (str_begins_with (arg, "interp")) {
 +                      opts->mode = MONO_AOT_MODE_INTERP;
                } else if (str_begins_with (arg, "threads=")) {
                        opts->nthreads = atoi (arg + strlen ("threads="));
                } else if (str_begins_with (arg, "static")) {
@@@ -8650,7 -8639,7 +8650,7 @@@ execute_system (const char * command
  {
        int status = 0;
  
 -#if defined(HOST_WIN32) && defined(HAVE_SYSTEM)
 +#if defined(HOST_WIN32)
        // We need an extra set of quotes around the whole command to properly handle commands 
        // with spaces since internally the command is called through "cmd /c.
        char * quoted_command = g_strdup_printf ("\"%s\"", command);
@@@ -10372,13 -10361,19 +10372,13 @@@ compile_asm (MonoAotCompile *acfg
  #define AS_OPTIONS "-a64 -mppc64"
  #elif defined(sparc) && SIZEOF_VOID_P == 8
  #define AS_OPTIONS "-xarch=v9"
 -#elif defined(TARGET_X86) && defined(TARGET_MACH) && !defined(__native_client_codegen__)
 +#elif defined(TARGET_X86) && defined(TARGET_MACH)
  #define AS_OPTIONS "-arch i386"
  #else
  #define AS_OPTIONS ""
  #endif
  
 -#ifdef __native_client_codegen__
 -#if defined(TARGET_AMD64)
 -#define AS_NAME "nacl64-as"
 -#else
 -#define AS_NAME "nacl-as"
 -#endif
 -#elif defined(TARGET_OSX)
 +#if defined(TARGET_OSX)
  #define AS_NAME "clang"
  #elif defined(TARGET_WIN32_MSVC)
  #define AS_NAME "clang.exe"
  #elif defined(TARGET_WIN32) && !defined(TARGET_ANDROID)
  #define LD_NAME "gcc"
  #define LD_OPTIONS "-shared"
 -#elif defined(TARGET_X86) && defined(TARGET_MACH) && !defined(__native_client_codegen__)
 +#elif defined(TARGET_X86) && defined(TARGET_MACH)
  #define LD_NAME "clang"
  #define LD_OPTIONS "-m32 -dynamiclib"
  #elif defined(TARGET_ARM) && !defined(TARGET_ANDROID)
@@@ -11530,7 -11525,7 +11530,7 @@@ mono_compile_assembly (MonoAssembly *as
                }
        }
  
 -      {
 +      if (!mono_aot_mode_is_interp (&acfg->aot_opts)) {
                int method_index;
  
         for (method_index = 0; method_index < acfg->image->tables [MONO_TABLE_METHOD].rows; ++method_index) {
        if (mono_aot_mode_is_full (&acfg->aot_opts) || mono_aot_mode_is_hybrid (&acfg->aot_opts))
                mono_set_partial_sharing_supported (TRUE);
  
 -      res = collect_methods (acfg);
 -      if (!res)
 -              return 1;
 +      if (!mono_aot_mode_is_interp (&acfg->aot_opts)) {
 +              res = collect_methods (acfg);
 +
 +              if (!res)
 +                      return 1;
 +      }
  
        {
                GList *l;
        }
  #endif
  
 +      if (mono_aot_mode_is_interp (&acfg->aot_opts)) {
 +              MonoMethod *wrapper;
 +              MonoMethodSignature *sig;
 +
 +              /* object object:interp_in_static (object,intptr,intptr,intptr) */
 +              sig = mono_create_icall_signature ("object object ptr ptr ptr");
 +              wrapper = mini_get_interp_in_wrapper (sig);
 +              add_method (acfg, wrapper);
 +
 +              /* int object:interp_in_static (intptr,int,intptr) */
 +              sig = mono_create_icall_signature ("int32 ptr int32 ptr");
 +              wrapper = mini_get_interp_in_wrapper (sig);
 +              add_method (acfg, wrapper);
 +
 +              /* void object:interp_in_static (object,intptr,intptr,intptr) */
 +              sig = mono_create_icall_signature ("void object ptr ptr ptr");
 +              wrapper = mini_get_interp_in_wrapper (sig);
 +              add_method (acfg, wrapper);
 +      }
 +
        TV_GETTIME (atv);
  
        compile_methods (acfg);
index d3dd15c3b2922cd7ebe7aeb3f229a26358962e59,f962de50f3a4bce1af1b243626fe27253982edab..f96c8a3fcccfba10337d1c2c3597139df56c46c5
@@@ -50,8 -50,10 +50,8 @@@ endi
  
  # FIXME fix the profiler tests to work with coop.
  if !ENABLE_COOP
 -if !NACL_CODEGEN
  check_targets = testlog
  endif
 -endif
  
  endif
  endif
@@@ -65,30 -67,30 +65,30 @@@ monodir=$(top_builddir
  # also uses eglib (e.g. the runtime). Automake doesn't support this
  # functionality, so create a separate static version of the library.
  
- libmono_profiler_aot_la_SOURCES = mono-profiler-aot.c
+ libmono_profiler_aot_la_SOURCES = aot.c
  libmono_profiler_aot_la_LIBADD =  $(libmono_dep) $(GLIB_LIBS) $(LIBICONV)
  libmono_profiler_aot_la_LDFLAGS = $(prof_ldflags)
- libmono_profiler_aot_static_la_SOURCES = mono-profiler-aot.c
+ libmono_profiler_aot_static_la_SOURCES = aot.c
  libmono_profiler_aot_static_la_LDFLAGS = -static
  
- libmono_profiler_iomap_la_SOURCES = mono-profiler-iomap.c
+ libmono_profiler_iomap_la_SOURCES = iomap.c
  libmono_profiler_iomap_la_LIBADD = $(libmono_dep) $(GLIB_LIBS) $(LIBICONV)
  libmono_profiler_iomap_la_LDFLAGS = $(prof_ldflags)
- libmono_profiler_iomap_static_la_SOURCES = mono-profiler-iomap.c
+ libmono_profiler_iomap_static_la_SOURCES = iomap.c
  libmono_profiler_iomap_static_la_LDFLAGS = -static
  
- libmono_profiler_log_la_SOURCES = mono-profiler-log.c
+ libmono_profiler_log_la_SOURCES = log.c log-args.c
  libmono_profiler_log_la_LIBADD = $(libmono_dep) $(GLIB_LIBS) $(Z_LIBS)
  libmono_profiler_log_la_LDFLAGS = $(prof_ldflags)
- libmono_profiler_log_static_la_SOURCES = mono-profiler-log.c
+ libmono_profiler_log_static_la_SOURCES = log.c log-args.c
  libmono_profiler_log_static_la_LDFLAGS = -static
  
  if HAVE_VTUNE
- libmono_profiler_vtune_la_SOURCES = mono-profiler-vtune.c
+ libmono_profiler_vtune_la_SOURCES = vtune.c
  libmono_profiler_vtune_la_CFLAGS = $(VTUNE_CFLAGS)
  libmono_profiler_vtune_la_LIBADD = $(VTUNE_LIBS) $(LIBMONO) $(GLIB_LIBS) $(LIBICONV)
  libmono_profiler_vtune_la_LDFLAGS = $(prof_ldflags)
- libmono_profiler_vtune_static_la_SOURCES = mono-profiler-vtune.c
+ libmono_profiler_vtune_static_la_SOURCES = vtune.c
  libmono_profiler_vtune_static_la_LDFLAGS = -static
  libmono_profiler_vtune_static_la_CFLAGS = $(VTUNE_CFLAGS)
  libmono_profiler_vtune_static_la_LIBADD = $(VTUNE_LIBS)
@@@ -114,8 -116,8 +114,8 @@@ testlog: $(PLOG_TESTS
  
  check-local: $(check_targets)
  
- EXTRA_DIST=mono-profiler-log.h \
-       mono-profiler-aot.h \
+ EXTRA_DIST=log.h \
+       aot.h \
        $(PLOG_TESTS_SRC) \
        ptestrunner.pl \
        $(suppression_DATA)
index 3b5d170a694ac1385491fcb43d427c7ae48a33b9,f98fd353e378c0dfa7cb9baa2225b2b8a48e20b6..fb6a40bc75133bb2ec224ad7e2d1b1e8c90e7102
@@@ -54,7 -54,7 +54,7 @@@
   *                    - column: The column on the line
   */
  #include <config.h>
- #include "mono-profiler-log.h"
+ #include "log.h"
  #include <string.h>
  #include <assert.h>
  #include <stdio.h>
  #define HASH_SIZE 9371
  #define SMALL_HASH_SIZE 31
  
 -#if defined(__native_client__) || defined(__native_client_codegen__)
 -volatile int __nacl_thread_suspension_needed = 0;
 -void __nacl_suspend_thread_if_needed() {}
 -#endif
 -
  static int debug = 0;
  static int collect_traces = 0;
  static int show_traces = 0;