mono_network_cleanup ();
mono_thread_cleanup ();
- //mono_domain_unload (domain);
+ mono_domain_unload (domain, TRUE);
#if DEBUG_INTERP
if (ocount) {
regset.c \
debug.h \
debug.c \
- mempool.h \
- mempool.c \
jit.c
mono_LDADD = \
fprintf (info->f, ".stabs \"%s:F(0,%d)\",36,0,%d,%p\n", name, sig->ret->type, line, cfg->start);
/* params */
- mono_method_get_param_names (cfg->method, names);
+ mono_method_get_param_names (cfg->method, (const char **)names);
if (sig->hasthis)
fprintf (info->f, ".stabs \"this:p(0,%d)=(0,%d)\",160,0,%d,%d\n", info->next_idx++, klass->byval_arg.type, line, 8); /* FIXME */
for (i = 0; i < sig->param_count; ++i) {
mono_network_cleanup();
mono_thread_cleanup();
- // mono_domain_unload (domain);
+ mono_domain_unload (domain, TRUE);
return retval;
}
#include <mono/metadata/loader.h>
#include <mono/metadata/object.h>
#include <mono/metadata/exception.h>
+#include <mono/metadata/mempool.h>
#include "regset.h"
-#include "mempool.h"
#define ISSTRUCT(t) (!t->byref && t->type == MONO_TYPE_VALUETYPE && !t->data.klass->enumtype)
guint32 used_regs;
unsigned num_clauses;
MonoJitExceptionInfo *clauses;
-
} MonoJitInfo;
typedef GArray MonoJitInfoTable;
+++ /dev/null
-/*
- * mempool.c: efficient memory allocation
- *
- * MonoMemPool is for fast allocation of memory. We free
- * all memory when the pool is destroyed.
- *
- * Author:
- * Dietmar Maurer (dietmar@ximian.com)
- *
- * (C) 2001 Ximian, Inc.
- */
-
-#include <config.h>
-#include <glib.h>
-#include <string.h>
-
-#include "jit.h"
-
-/*
- * MonoMemPool is for fast allocation of memory. We free
- * all memory when the pool is destroyed.
- */
-
-#if SIZEOF_VOID_P > SIZEOF_LONG
-#define MEM_ALIGN SIZEOF_VOID_P
-#else
-#define MEM_ALIGN SIZEOF_LONG
-#endif
-
-#define MONO_MEMPOOL_PAGESIZE 8192
-
-struct _MonoMemPool {
- MonoMemPool *next;
- gint rest;
- gpointer pos;
-};
-
-/**
- * mono_mempool_new:
- *
- * Returns: a new memory pool.
- */
-MonoMemPool *
-mono_mempool_new ()
-{
-
- MonoMemPool *pool = g_malloc (MONO_MEMPOOL_PAGESIZE);
- pool->next = NULL;
- pool->pos = (gpointer)pool + sizeof (MonoMemPool);
- pool->rest = MONO_MEMPOOL_PAGESIZE - sizeof (MonoMemPool);
- return pool;
-}
-
-/**
- * mono_mempool_destroy:
- * @pool: the momory pool to destroy
- *
- * Free all memory associated with this pool.
- */
-void
-mono_mempool_destroy (MonoMemPool *pool)
-{
- MonoMemPool *p, *n;
-
- p = pool;
- while (p) {
- n = p->next;
- g_free (p);
- p = n;
- }
-}
-
-/**
- * mono_mempool_alloc:
- * @pool: the momory pool to destroy
- * @size: size of the momory block
- *
- * Allocates a new block of memory in @pool. @size must
- * be smaller than 256.
- *
- * Returns: the address of a newly allocated memory block.
- */
-gpointer
-mono_mempool_alloc (MonoMemPool *pool, guint size)
-{
- gpointer rval;
-
- g_assert (pool != NULL);
-
- if (size >= 4096) {
- MonoMemPool *np = g_malloc (sizeof (MonoMemPool) + size);
- np->next = pool->next;
- pool->next = np;
- return (gpointer)np + sizeof (MonoMemPool);
- }
-
- size = (size + MEM_ALIGN - 1) & ~(MEM_ALIGN - 1);
-
- if (pool->rest < size) {
- MonoMemPool *np = g_malloc (MONO_MEMPOOL_PAGESIZE);
- np->next = pool->next;
- pool->next = np;
- pool->pos = (gpointer)np + sizeof (MonoMemPool);
- pool->rest = MONO_MEMPOOL_PAGESIZE - sizeof (MonoMemPool);
- }
-
- rval = pool->pos;
- pool->rest -= size;
- pool->pos += size;
-
- return rval;
-}
-
-/**
- * mono_mempool_alloc0:
- *
- * same as mono_mempool_alloc, but fills memory with zero.
- */
-gpointer
-mono_mempool_alloc0 (MonoMemPool *pool, guint size)
-{
- gpointer rval = mono_mempool_alloc (pool, size);
- memset (rval, 0, size);
- return rval;
-}
-
+++ /dev/null
-#ifndef _MONO_MEMPOOL_H_
-#define _MONO_MEMPOOL_H_
-
-typedef struct _MonoMemPool MonoMemPool;
-
-MonoMemPool *
-mono_mempool_new (void);
-
-void
-mono_mempool_destroy (MonoMemPool *pool);
-
-gpointer
-mono_mempool_alloc (MonoMemPool *pool, guint size);
-
-gpointer
-mono_mempool_alloc0 (MonoMemPool *pool, guint size);
-
-#endif
#include <mono/arch/x86/x86-codegen.h>
#include "regset.h"
-#include "mempool.h"
#include "jit.h"
#define MBTREE_TYPE MBTree
+2002-02-19 Dietmar Maurer <dietmar@ximian.com>
+
+ * appdomain.c (mono_domain_transfer_object): impl. hack for Arrays
+ and String - but we will need generic marshalling support in the
+ future.
+
+ * object.c (mono_string_new_utf16): bug fix: use char[] instead of
+ String[].
+
+2002-02-18 Dietmar Maurer <dietmar@ximian.com>
+
+ * object.c (mono_array_clone): use alloca() instead of g_malloc
+ for sizes
+
+ * appdomain.c (mono_domain_unload): impl.
Mon Feb 18 15:52:20 CET 2002 Paolo Molaro <lupus@ximian.com>
exception.h \
unicode.c \
unicode.h \
+ mempool.h \
+ mempool.c \
appdomain.h \
appdomain.c
domain->setup = NULL;
domain->friendly_name = NULL;
+ domain->mp = mono_mempool_new ();
domain->env = g_hash_table_new (g_str_hash, g_str_equal);
domain->assemblies = g_hash_table_new (g_str_hash, g_str_equal);
domain->class_vtable_hash = g_hash_table_new (NULL, NULL);
return domain;
}
+MonoDomain *mono_root_domain = NULL;
+
/**
* mono_init:
*
appdomain_thread_id = TlsAlloc ();
domain = mono_create_domain ();
+ mono_root_domain = domain;
TlsSetValue (appdomain_thread_id, domain);
static MonoObject *
mono_domain_transfer_object (MonoDomain *src, MonoDomain *dst, MonoObject *obj)
{
+ MonoClass *klass;
+ MonoObject *res;
+
+ if (!obj)
+ return NULL;
+
+ g_assert (obj->vtable->domain == src);
+
/* fixme: transfer an object from one domain into another */
- g_assert_not_reached ();
- return obj;
+
+ klass = obj->vtable->klass;
+
+ if (MONO_CLASS_IS_ARRAY (klass)) {
+ MonoArray *ao = (MonoArray *)obj;
+ int esize, ecount, i;
+ guint32 *sizes;
+
+ sizes = alloca (klass->rank * sizeof(guint32) * 2);
+ esize = mono_array_element_size (klass);
+ ecount = 1;
+ for (i = 0; i < klass->rank; ++i) {
+ sizes [i] = ao->bounds [i].length;
+ ecount *= ao->bounds [i].length;
+ sizes [i + klass->rank] = ao->bounds [i].lower_bound;
+ }
+ res = (MonoObject *)mono_array_new_full (dst, klass, sizes, sizes + klass->rank);
+ if (klass->element_class->valuetype) {
+ memcpy (res, (char *)ao + sizeof(MonoArray), esize * ecount);
+ } else {
+ g_assert (esize == sizeof (gpointer));
+ for (i = 0; i < ecount; i++) {
+ int offset = sizeof (MonoArray) + esize * i;
+ gpointer *src_ea = (gpointer *)((char *)ao + offset);
+ gpointer *dst_ea = (gpointer *)((char *)res + offset);
+
+ *dst_ea = mono_domain_transfer_object (src, dst, *src_ea);
+ }
+ }
+ } else if (klass == mono_defaults.string_class) {
+ MonoString *str = (MonoString *)obj;
+ res = (MonoObject *)mono_string_new_utf16 (dst,
+ (const guint16 *)str->c_str->vector, str->length);
+ } else {
+ // fixme: we need generic marshalling code here */
+ g_assert_not_reached ();
+ }
+
+ return res;
}
MonoObject *
void
ves_icall_System_AppDomain_Unload (MonoAppDomain *ad)
{
- mono_domain_unload (ad->data);
+ mono_domain_unload (ad->data, FALSE);
}
/**
return ass;
}
+static void
+remove_assembly (gpointer key, gpointer value, gpointer user_data)
+{
+ mono_assembly_close ((MonoAssembly *)value);
+}
+
void
-mono_domain_unload (MonoDomain *domain)
+mono_domain_unload (MonoDomain *domain, gboolean force)
{
- g_warning ("Domain unloading not yet implemented");
+ if ((domain == mono_root_domain) && !force) {
+ g_warning ("cant unload root domain");
+ return;
+ }
+
+ g_hash_table_foreach (domain->assemblies, remove_assembly, NULL);
+
+ g_hash_table_destroy (domain->env);
+ g_hash_table_destroy (domain->assemblies);
+ g_hash_table_destroy (domain->class_vtable_hash);
+ g_hash_table_destroy (domain->jit_code_hash);
+ g_hash_table_destroy (domain->ldstr_table);
+ mono_mempool_destroy (domain->mp);
+
+ // fixme: anything else required ? */
+
+ g_free (domain);
+
+ if ((domain == mono_root_domain))
+ mono_root_domain = NULL;
}
gint32
MonoImage *image;
MonoCLIImageInfo *iinfo;
MonoMethod *method;
+ MonoObject *margs;
char *filename;
gint32 res;
if (!method)
g_error ("No entry point method found in %s", image->name);
- res = mono_runtime_exec_main (method, args);
+ margs = mono_domain_transfer_object (cdom, ad->data, (MonoObject *)args);
+ res = mono_runtime_exec_main (method, (MonoArray *)margs);
mono_domain_set (cdom);
#include <mono/metadata/object.h>
#include <mono/metadata/reflection.h>
+#include <mono/metadata/mempool.h>
/* This is a copy of System.AppDomainSetup */
typedef struct {
struct _MonoDomain {
MonoAppDomain *domain;
- GHashTable *env;
- GHashTable *assemblies;
+ MonoMemPool *mp;
+ GHashTable *env;
+ GHashTable *assemblies;
MonoAppDomainSetup *setup;
- MonoString *friendly_name;
- GHashTable *ldstr_table;
- GHashTable *class_vtable_hash;
- GHashTable *jit_code_hash;
+ MonoString *friendly_name;
+ GHashTable *ldstr_table;
+ GHashTable *class_vtable_hash;
+ GHashTable *jit_code_hash;
};
/* This is a copy of System.AppDomain */
MonoDomain *data;
};
+extern MonoDomain *mono_root_domain;
+
MonoDomain *
mono_init (void);
mono_domain_assembly_open (MonoDomain *domain, char *name);
void
-mono_domain_unload (MonoDomain *domain);
+mono_domain_unload (MonoDomain *domain, gboolean force);
void
ves_icall_System_AppDomainSetup_InitAppDomainSetup (MonoAppDomainSetup *setup);
}
static void
-ves_icall_System_Array_CreateInstance ()
+ves_icall_System_Array_CreateInstanceImpl ()
{
g_warning ("not implemented");
g_assert_not_reached ();
static MonoObject*
ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoArray *params) {
- MonoMethodSignature *sig = method->method->signature;
+ //MonoMethodSignature *sig = method->method->signature;
/*
* Do we need to copy the values so that the called method can't change them?
"System.Array::GetRank", ves_icall_System_Array_GetRank,
"System.Array::GetLength", ves_icall_System_Array_GetLength,
"System.Array::GetLowerBound", ves_icall_System_Array_GetLowerBound,
- "System.Array::CreateInstance", ves_icall_System_Array_CreateInstance,
+ "System.Array::CreateInstanceImpl", ves_icall_System_Array_CreateInstanceImpl,
"System.Array::FastCopy", ves_icall_System_Array_FastCopy,
"System.Array::Clone", mono_array_clone,
#include <glib.h>
#include <string.h>
-#include "jit.h"
+#include "mempool.h"
/*
* MonoMemPool is for fast allocation of memory. We free
guint32 *sizes;
MonoClass *klass = array->obj.vtable->klass;
- sizes = g_malloc (klass->rank * sizeof(guint32) * 2);
+ sizes = alloca (klass->rank * sizeof(guint32) * 2);
size = mono_array_element_size (klass);
for (i = 0; i < klass->rank; ++i) {
sizes [i] = array->bounds [i].length;
s = (MonoString*)mono_object_new (domain, mono_defaults.string_class);
g_assert (s != NULL);
- ca = (MonoArray *)mono_array_new (domain, mono_defaults.string_class, len);
+ ca = (MonoArray *)mono_array_new (domain, mono_defaults.char_class, len);
g_assert (ca != NULL);
s->c_str = ca;
string[] args = { "test0", "test1" };
- newDomain.ExecuteAssembly ("jit-int.exe");
+ newDomain.ExecuteAssembly ("jit-int.exe", null, args);
Console.WriteLine ("Ready");
}