Revert "Revert "Merge branch 'master' of https://github.com/mono/mono""
[mono.git] / mono / utils / mono-codeman.c
index ac9295779dabf2f1c403a7b07251fd60db86af22..9e468bfd6e098c36d53e81d51f0c181d19b4a2ca 100644 (file)
@@ -15,7 +15,7 @@
 #include "mono-mmap.h"
 #include "mono-counters.h"
 #include "dlmalloc.h"
-#include <mono/metadata/class-internals.h>
+#include <mono/io-layer/io-layer.h>
 #include <mono/metadata/profiler-private.h>
 #ifdef HAVE_VALGRIND_MEMCHECK_H
 #include <valgrind/memcheck.h>
@@ -28,6 +28,9 @@
 #endif
 
 static uintptr_t code_memory_used = 0;
+static size_t dynamic_code_alloc_count;
+static size_t dynamic_code_bytes_count;
+static size_t dynamic_code_frees_count;
 
 /*
  * AMD64 processors maintain icache coherency only for pages which are 
@@ -39,7 +42,7 @@ static uintptr_t code_memory_used = 0;
 
 #define MIN_PAGES 16
 
-#if defined(__ia64__) || defined(__x86_64__)
+#if defined(__ia64__) || defined(__x86_64__) || defined (_WIN64)
 /*
  * We require 16 byte alignment on amd64 so the fp literals embedded in the code are 
  * properly aligned for SSE2.
@@ -301,6 +304,9 @@ codechunk_cleanup (void)
 void
 mono_code_manager_init (void)
 {
+       mono_counters_register ("Dynamic code allocs", MONO_COUNTER_JIT | MONO_COUNTER_WORD, &dynamic_code_alloc_count);
+       mono_counters_register ("Dynamic code bytes", MONO_COUNTER_JIT | MONO_COUNTER_WORD, &dynamic_code_bytes_count);
+       mono_counters_register ("Dynamic code frees", MONO_COUNTER_JIT | MONO_COUNTER_WORD, &dynamic_code_frees_count);
 }
 
 void
@@ -483,6 +489,9 @@ mono_code_manager_foreach (MonoCodeManager *cman, MonoCodeManagerFunc func, void
 #if defined(__arm__)
 #define BIND_ROOM 8
 #endif
+#if defined(TARGET_ARM64)
+#define BIND_ROOM 8
+#endif
 
 static CodeChunk*
 new_codechunk (CodeChunk *last, int dynamic, int size)
@@ -599,8 +608,8 @@ mono_code_manager_reserve_align (MonoCodeManager *cman, int size, int alignment)
        g_assert (alignment <= MIN_ALIGN);
 
        if (cman->dynamic) {
-               ++mono_stats.dynamic_code_alloc_count;
-               mono_stats.dynamic_code_bytes_count += size;
+               ++dynamic_code_alloc_count;
+               dynamic_code_bytes_count += size;
        }
 
        if (!cman->current) {