Implement more of System.Net.Http
[mono.git] / mono / utils / mono-codeman.c
index 33dc025df3ea6d33a37223627df72bbc48aac4fa..4efcea0ae25500addaca763aaa9bb3721d495734 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "mono-codeman.h"
 #include "mono-mmap.h"
+#include "mono-counters.h"
 #include "dlmalloc.h"
 #include <mono/metadata/class-internals.h>
 #include <mono/metadata/profiler-private.h>
@@ -25,6 +26,8 @@
 #include <nacl/nacl_dyncode.h>
 #endif
 
+static uintptr_t code_memory_used = 0;
+
 /*
  * AMD64 processors maintain icache coherency only for pages which are 
  * marked executable. Also, windows DEP requires us to obtain executable memory from
@@ -284,6 +287,7 @@ free_chunklist (CodeChunk *chunk)
                } else if (dead->flags == CODE_FLAG_MALLOC) {
                        dlfree (dead->data);
                }
+               code_memory_used -= dead->size;
                free (dead);
        }
 }
@@ -451,6 +455,8 @@ new_codechunk (int dynamic, int size)
        chunk->bsize = bsize;
        mono_profiler_code_chunk_new((gpointer) chunk->data, chunk->size);
 
+       code_memory_used += chunk_size;
+       mono_runtime_resource_check_limit (MONO_RESOURCE_JIT_CODE, code_memory_used);
        /*printf ("code chunk at: %p\n", ptr);*/
        return chunk;
 }