#endif
/* Allocate the code into a separate memory pool so it can be freed */
cfg->dynamic_info = g_new0 (MonoJitDynamicMethodInfo, 1);
- cfg->dynamic_info->code_mp = mono_code_manager_new_dynamic ();
+ cfg->dynamic_info->code_mp = mono_code_manager_new_dynamic (cfg->thunk_area);
mono_domain_lock (cfg->domain);
mono_dynamic_code_hash_insert (cfg->domain, cfg->method, cfg->dynamic_info);
mono_domain_unlock (cfg->domain);
struct _MonoCodeManager {
int dynamic;
int read_only;
+ int bind_size;
CodeChunk *current;
CodeChunk *full;
CodeChunk *last;
* Creates a new code manager suitable for holding native code that can be
* used for single or small methods that need to be deallocated independently
* of other native code.
+ * BIND_SIZE is the amount of memory reserved for storing thunks. If its 0,
+ * the default size is used.
*
* Returns: the new code manager
*/
MonoCodeManager*
-mono_code_manager_new_dynamic (void)
+mono_code_manager_new_dynamic (int bind_size)
{
MonoCodeManager *cman = mono_code_manager_new ();
cman->dynamic = 1;
+ cman->bind_size = bind_size;
return cman;
}
#endif
static CodeChunk*
-new_codechunk (CodeChunk *last, int dynamic, int size)
+new_codechunk (CodeChunk *last, int dynamic, int size, int bind_size)
{
int minsize, flags = CODE_FLAG_MMAP;
int chunk_size, bsize = 0;
}
}
#ifdef BIND_ROOM
- if (dynamic)
- /* Reserve more space since there are no other chunks we might use if this one gets full */
- bsize = (chunk_size * 2) / BIND_ROOM;
- else
- bsize = chunk_size / BIND_ROOM;
+ if (bind_size) {
+ bsize = bind_size;
+ } else {
+ if (dynamic)
+ /* Reserve more space since there are no other chunks we might use if this one gets full */
+ bsize = (chunk_size * 2) / BIND_ROOM;
+ else
+ bsize = chunk_size / BIND_ROOM;
+ }
if (bsize < MIN_BSIZE)
bsize = MIN_BSIZE;
bsize += MIN_ALIGN -1;
}
if (!cman->current) {
- cman->current = new_codechunk (cman->last, cman->dynamic, size);
+ cman->current = new_codechunk (cman->last, cman->dynamic, size, cman->bind_size);
if (!cman->current)
return NULL;
cman->last = cman->current;
cman->full = chunk;
break;
}
- chunk = new_codechunk (cman->last, cman->dynamic, size);
+ chunk = new_codechunk (cman->last, cman->dynamic, size, cman->bind_size);
if (!chunk)
return NULL;
chunk->next = cman->current;
typedef struct _MonoCodeManager MonoCodeManager;
MONO_API MonoCodeManager* mono_code_manager_new (void);
-MONO_API MonoCodeManager* mono_code_manager_new_dynamic (void);
+MONO_API MonoCodeManager* mono_code_manager_new_dynamic (int bind_size);
MONO_API void mono_code_manager_destroy (MonoCodeManager *cman);
MONO_API void mono_code_manager_invalidate (MonoCodeManager *cman);
MONO_API void mono_code_manager_set_read_only (MonoCodeManager *cman);