static void
mono_array_to_byvalarray (gpointer native_arr, MonoArray *arr, MonoClass *eltype, guint32 elnum);
-static MonoObject *
-mono_remoting_wrapper (MonoMethod *method, gpointer *params);
static MonoAsyncResult *
mono_delegate_begin_invoke (MonoDelegate *delegate, gpointer *params);
static gboolean
mono_marshal_check_domain_image (gint32 domain_id, MonoImage *image);
+#ifndef DISABLE_REMOTING
+static MonoObject *
+mono_remoting_wrapper (MonoMethod *method, gpointer *params);
+
void
mono_upgrade_remote_class_wrapper (MonoReflectionType *rtype, MonoTransparentProxy *tproxy);
+#endif
+
static MonoReflectionType *
type_from_handle (MonoType *handle);
register_icall (g_free, "g_free", "void ptr", FALSE);
register_icall (mono_object_isinst, "mono_object_isinst", "object object ptr", FALSE);
register_icall (mono_struct_delete_old, "mono_struct_delete_old", "void ptr ptr", FALSE);
- register_icall (mono_remoting_wrapper, "mono_remoting_wrapper", "object ptr ptr", FALSE);
register_icall (mono_delegate_begin_invoke, "mono_delegate_begin_invoke", "object object ptr", FALSE);
register_icall (mono_delegate_end_invoke, "mono_delegate_end_invoke", "object object ptr", FALSE);
register_icall (mono_marshal_xdomain_copy_value, "mono_marshal_xdomain_copy_value", "object object", FALSE);
register_icall (mono_compile_method, "mono_compile_method", "ptr ptr", FALSE);
register_icall (mono_context_get, "mono_context_get", "object", FALSE);
register_icall (mono_context_set, "mono_context_set", "void object", FALSE);
- register_icall (mono_upgrade_remote_class_wrapper, "mono_upgrade_remote_class_wrapper", "void object object", FALSE);
register_icall (type_from_handle, "type_from_handle", "object ptr", FALSE);
register_icall (mono_gc_wbarrier_generic_nostore, "wb_generic", "void ptr", FALSE);
register_icall (mono_gchandle_get_target, "mono_gchandle_get_target", "object int32", TRUE);
+#ifndef DISABLE_REMOTING
+ register_icall (mono_remoting_wrapper, "mono_remoting_wrapper", "object ptr ptr", FALSE);
+ register_icall (mono_upgrade_remote_class_wrapper, "mono_upgrade_remote_class_wrapper", "void object object", FALSE);
+#endif
mono_cominterop_init ();
}
}
marshal_mutex_initialized = FALSE;
}
-MonoClass *byte_array_class;
+#ifndef DISABLE_REMOTING
+static MonoClass *byte_array_class;
static MonoMethod *method_rs_serialize, *method_rs_deserialize, *method_exc_fixexc, *method_rs_appdomain_target;
-static MonoMethod *method_set_context, *method_get_context;
static MonoMethod *method_set_call_context, *method_needs_context_sink, *method_rs_serialize_exc;
static void
klass = mono_defaults.exception_class;
method_exc_fixexc = mono_class_get_method_from_name (klass, "FixRemotingException", -1);
- klass = mono_defaults.thread_class;
- method_get_context = mono_class_get_method_from_name (klass, "get_CurrentContext", -1);
-
- klass = mono_defaults.appdomain_class;
- method_set_context = mono_class_get_method_from_name (klass, "InternalSetContext", -1);
byte_array_class = mono_array_class_get (mono_defaults.byte_class, 1);
klass = mono_class_from_name (mono_defaults.corlib, "System.Runtime.Remoting.Messaging", "CallContext");
module_initialized = TRUE;
}
}
+#endif
gpointer
mono_delegate_to_ftnptr (MonoDelegate *delegate)
return mono_string_new_len (mono_domain_get (), text, length);
}
+#ifndef DISABLE_JIT
+#ifndef DISABLE_REMOTING
static int
mono_mb_emit_proxy_check (MonoMethodBuilder *mb, int branch_code)
{
mono_mb_emit_icon (mb, 0);
return mono_mb_emit_branch (mb, branch_code);
}
+#endif /* DISABLE_REMOTING */
/*
* mono_mb_emit_exception_marshal_directive:
mono_mb_emit_exception_full (mb, "System.Runtime.InteropServices", "MarshalDirectiveException", s);
}
+#endif /* !DISABLE_JIT */
+
guint
mono_type_to_ldind (MonoType *type)
{
return -1;
}
+#ifndef DISABLE_JIT
+
static void
emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv conv, MonoMarshalSpec *mspec)
{
emit_thread_interrupt_checkpoint (mb);
}
+#endif /* DISABLE_JIT */
+
static MonoAsyncResult *
mono_delegate_begin_invoke (MonoDelegate *delegate, gpointer *params)
{
if (mcast_delegate->prev != NULL)
mono_raise_exception (mono_get_exception_argument (NULL, "The delegate must have only one target"));
+#ifndef DISABLE_REMOTING
if (delegate->target && mono_object_class (delegate->target) == mono_defaults.transparent_proxy_class) {
MonoTransparentProxy* tp = (MonoTransparentProxy *)delegate->target;
- if (!tp->remote_class->proxy_class->contextbound || tp->rp->context != (MonoObject *) mono_context_get ()) {
+ if (!mono_class_is_contextbound (tp->remote_class->proxy_class) || tp->rp->context != (MonoObject *) mono_context_get ()) {
/* If the target is a proxy, make a direct call. Is proxy's work
// to make the call asynchronous.
return ares;
}
}
+#endif
klass = delegate->object.vtable->klass;
return mono_thread_pool_add ((MonoObject *)delegate, msg, async_callback, state);
}
+#ifndef DISABLE_JIT
+
static int
mono_mb_emit_save_args (MonoMethodBuilder *mb, MonoMethodSignature *sig, gboolean save_this)
{
return params_var;
}
+#endif /* DISABLE_JIT */
+
static char*
mono_signature_to_name (MonoMethodSignature *sig, const char *prefix)
{
return klass;
}
+static MonoMethod*
+check_generic_delegate_wrapper_cache (GHashTable *cache, MonoMethod *orig_method, MonoMethod *def_method, MonoGenericContext *ctx)
+{
+ MonoMethod *res;
+ MonoMethod *inst, *def;
+
+ /*
+ * Look for the instance
+ */
+ res = mono_marshal_find_in_cache (cache, orig_method->klass);
+ if (res)
+ return res;
+
+ /*
+ * Look for the definition
+ */
+ def = mono_marshal_find_in_cache (cache, def_method->klass);
+ if (def) {
+ inst = mono_class_inflate_generic_method (def, ctx);
+ /* Cache it */
+ mono_memory_barrier ();
+ mono_marshal_lock ();
+ res = g_hash_table_lookup (cache, orig_method->klass);
+ if (!res) {
+ g_hash_table_insert (cache, orig_method->klass, inst);
+ res = inst;
+ }
+ mono_marshal_unlock ();
+ return res;
+ }
+ return NULL;
+}
+
+static MonoMethod*
+cache_generic_delegate_wrapper (GHashTable *cache, MonoMethod *orig_method, MonoMethod *def, MonoGenericContext *ctx)
+{
+ MonoMethod *inst, *res;
+
+ /*
+ * We use the same cache for the generic definition and the instances.
+ */
+ inst = mono_class_inflate_generic_method (def, ctx);
+ mono_memory_barrier ();
+ mono_marshal_lock ();
+ res = g_hash_table_lookup (cache, orig_method->klass);
+ if (!res) {
+ g_hash_table_insert (cache, orig_method->klass, inst);
+ res = inst;
+ }
+ mono_marshal_unlock ();
+ return res;
+}
+
MonoMethod *
mono_marshal_get_delegate_begin_invoke (MonoMethod *method)
{
GHashTable *cache;
int params_var;
char *name;
+ MonoGenericContext *ctx = NULL;
+ MonoMethod *orig_method = NULL;
g_assert (method && method->klass->parent == mono_defaults.multicastdelegate_class &&
!strcmp (method->name, "BeginInvoke"));
+ /*
+ * For generic delegates, create a generic wrapper, and returns an instance to help AOT.
+ */
+ if (method->is_inflated) {
+ orig_method = method;
+ ctx = &((MonoMethodInflated*)method)->context;
+ method = ((MonoMethodInflated*)method)->declaring;
+ }
+
sig = mono_signature_no_pinvoke (method);
- cache = get_cache (&method->klass->image->delegate_begin_invoke_cache,
- (GHashFunc)mono_signature_hash,
- (GCompareFunc)mono_metadata_signature_equal);
- if ((res = mono_marshal_find_in_cache (cache, sig)))
- return res;
+ /*
+ * Check cache
+ */
+ if (ctx) {
+ cache = get_cache (&method->klass->image->delegate_begin_invoke_generic_cache, mono_aligned_addr_hash, NULL);
+ res = check_generic_delegate_wrapper_cache (cache, orig_method, method, ctx);
+ if (res)
+ return res;
+ } else {
+ cache = get_cache (&method->klass->image->delegate_begin_invoke_cache,
+ (GHashFunc)mono_signature_hash,
+ (GCompareFunc)mono_metadata_signature_equal);
+ if ((res = mono_marshal_find_in_cache (cache, sig)))
+ return res;
+ }
g_assert (sig->hasthis);
name = mono_signature_to_name (sig, "begin_invoke");
- mb = mono_mb_new (get_wrapper_target_class (method->klass->image), name, MONO_WRAPPER_DELEGATE_BEGIN_INVOKE);
+ if (ctx)
+ mb = mono_mb_new (method->klass, name, MONO_WRAPPER_DELEGATE_BEGIN_INVOKE);
+ else
+ mb = mono_mb_new (get_wrapper_target_class (method->klass->image), name, MONO_WRAPPER_DELEGATE_BEGIN_INVOKE);
g_free (name);
+#ifndef DISABLE_JIT
params_var = mono_mb_emit_save_args (mb, sig, FALSE);
mono_mb_emit_ldarg (mb, 0);
mono_mb_emit_ldloc (mb, params_var);
mono_mb_emit_icall (mb, mono_delegate_begin_invoke);
mono_mb_emit_byte (mb, CEE_RET);
+#endif
+
+ if (ctx) {
+ MonoMethod *def;
+ def = mono_mb_create_and_cache (cache, method->klass, mb, sig, sig->param_count + 16);
+ res = cache_generic_delegate_wrapper (cache, orig_method, def, ctx);
+ } else {
+ res = mono_mb_create_and_cache (cache, sig, mb, sig, sig->param_count + 16);
+ }
- res = mono_mb_create_and_cache (cache, sig, mb, sig, sig->param_count + 16);
mono_mb_free (mb);
return res;
}
return NULL;
}
- if (delegate->target && mono_object_class (delegate->target) == mono_defaults.transparent_proxy_class) {
+#ifndef DISABLE_REMOTING
+ if (delegate->target && mono_object_is_transparent_proxy (delegate->target)) {
MonoTransparentProxy* tp = (MonoTransparentProxy *)delegate->target;
msg = (MonoMethodMessage *)mono_object_new (domain, mono_defaults.mono_method_message_class);
mono_message_init (domain, msg, delegate->method_info, NULL);
msg->call_type = CallType_EndInvoke;
MONO_OBJECT_SETREF (msg, async_result, ares);
res = mono_remoting_invoke ((MonoObject *)tp->rp, msg, &exc, &out_args);
- } else {
+ } else
+#endif
+ {
res = mono_thread_pool_finish (ares, &out_args, &exc);
}
return res;
}
+#ifndef DISABLE_JIT
+
static void
mono_mb_emit_restore_result (MonoMethodBuilder *mb, MonoType *return_type)
{
mono_mb_emit_op (mb, CEE_LDOBJ, klass);
break;
}
+ case MONO_TYPE_VAR:
+ case MONO_TYPE_MVAR: {
+ MonoClass *klass = mono_class_from_mono_type (return_type);
+ mono_mb_emit_op (mb, CEE_UNBOX_ANY, klass);
+ break;
+ }
default:
g_warning ("type 0x%x not handled", return_type->type);
g_assert_not_reached ();
mono_mb_emit_byte (mb, CEE_RET);
}
+#endif /* DISABLE_JIT */
+
MonoMethod *
mono_marshal_get_delegate_end_invoke (MonoMethod *method)
{
GHashTable *cache;
int params_var;
char *name;
+ MonoGenericContext *ctx = NULL;
+ MonoMethod *orig_method = NULL;
g_assert (method && method->klass->parent == mono_defaults.multicastdelegate_class &&
!strcmp (method->name, "EndInvoke"));
+ /*
+ * For generic delegates, create a generic wrapper, and returns an instance to help AOT.
+ */
+ if (method->is_inflated) {
+ orig_method = method;
+ ctx = &((MonoMethodInflated*)method)->context;
+ method = ((MonoMethodInflated*)method)->declaring;
+ }
+
sig = mono_signature_no_pinvoke (method);
- cache = get_cache (&method->klass->image->delegate_end_invoke_cache,
- (GHashFunc)mono_signature_hash,
- (GCompareFunc)mono_metadata_signature_equal);
- if ((res = mono_marshal_find_in_cache (cache, sig)))
- return res;
+ /*
+ * Check cache
+ */
+ if (ctx) {
+ cache = get_cache (&method->klass->image->delegate_end_invoke_generic_cache, mono_aligned_addr_hash, NULL);
+ res = check_generic_delegate_wrapper_cache (cache, orig_method, method, ctx);
+ if (res)
+ return res;
+ } else {
+ cache = get_cache (&method->klass->image->delegate_end_invoke_cache,
+ (GHashFunc)mono_signature_hash,
+ (GCompareFunc)mono_metadata_signature_equal);
+ if ((res = mono_marshal_find_in_cache (cache, sig)))
+ return res;
+ }
g_assert (sig->hasthis);
name = mono_signature_to_name (sig, "end_invoke");
- mb = mono_mb_new (get_wrapper_target_class (method->klass->image), name, MONO_WRAPPER_DELEGATE_END_INVOKE);
+ if (ctx)
+ mb = mono_mb_new (method->klass, name, MONO_WRAPPER_DELEGATE_END_INVOKE);
+ else
+ mb = mono_mb_new (get_wrapper_target_class (method->klass->image), name, MONO_WRAPPER_DELEGATE_END_INVOKE);
g_free (name);
+#ifndef DISABLE_JIT
params_var = mono_mb_emit_save_args (mb, sig, FALSE);
mono_mb_emit_ldarg (mb, 0);
mono_mb_emit_byte (mb, CEE_RET);
} else
mono_mb_emit_restore_result (mb, sig->ret);
+#endif
- res = mono_mb_create_and_cache (cache, sig,
- mb, sig, sig->param_count + 16);
+ if (ctx) {
+ MonoMethod *def;
+ def = mono_mb_create_and_cache (cache, method->klass, mb, sig, sig->param_count + 16);
+ res = cache_generic_delegate_wrapper (cache, orig_method, def, ctx);
+ } else {
+ res = mono_mb_create_and_cache (cache, sig,
+ mb, sig, sig->param_count + 16);
+ }
mono_mb_free (mb);
return res;
}
+#ifndef DISABLE_REMOTING
+
static MonoObject *
mono_remoting_wrapper (MonoMethod *method, gpointer *params)
{
/* skip the this pointer */
params++;
- if (this->remote_class->proxy_class->contextbound && this->rp->context == (MonoObject *) mono_context_get ())
+ if (mono_class_is_contextbound (this->remote_class->proxy_class) && this->rp->context == (MonoObject *) mono_context_get ())
{
int i;
MonoMethodSignature *sig = mono_method_signature (method);
/* this seems to be the best plase to put this, as all remoting invokes seem to get filtered through here */
#ifndef DISABLE_COM
- if (method->klass->is_com_object || method->klass == mono_defaults.com_object_class) {
+ if (mono_class_is_com_object (method->klass) || method->klass == mono_defaults.com_object_class) {
MonoVTable *vtable = mono_class_vtable (mono_domain_get (), method->klass);
g_assert (vtable); /*FIXME do proper error handling*/
- if (!vtable->remote) {
+ if (!mono_vtable_is_remote (vtable)) {
return mono_cominterop_get_invoke (method);
}
}
return res;
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_REMOTING_INVOKE);
+
+#ifndef DISABLE_JIT
mb->method->save_lmf = 1;
params_var = mono_mb_emit_save_args (mb, sig, TRUE);
} else {
mono_mb_emit_restore_result (mb, sig->ret);
}
+#endif
res = mono_remoting_mb_create_and_cache (method, mb, sig, sig->param_count + 16);
mono_mb_free (mb);
return res;
}
+#endif /* DISABLE_REMOTING */
+
+
/* mono_get_xdomain_marshal_type()
* Returns the kind of marshalling that a type needs for cross domain calls.
*/
}
}
+
+#if !(defined (DISABLE_JIT) || defined (DISABLE_REMOTING))
+
static void
mono_marshal_emit_xdomain_copy_value (MonoMethodBuilder *mb, MonoClass *pclass)
{
{
mono_mb_emit_icall (mb, mono_marshal_xdomain_copy_out_value);
}
+#endif
+#ifndef DISABLE_REMOTING
/* mono_marshal_supports_fast_xdomain()
* Returns TRUE if the method can use the fast xdomain wrapper.
*/
static gboolean
mono_marshal_supports_fast_xdomain (MonoMethod *method)
{
- return !method->klass->contextbound &&
+ return !mono_class_is_contextbound (method->klass) &&
!((method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) && (strcmp (".ctor", method->name) == 0));
}
+#endif
static gint32
mono_marshal_set_domain_by_id (gint32 id, MonoBoolean push)
return current_domain->domain_id;
}
+#if !(defined (DISABLE_JIT) || defined (DISABLE_REMOTING))
static void
mono_marshal_emit_switch_domain (MonoMethodBuilder *mb)
{
mono_mb_emit_ptr (mb, method);
mono_mb_emit_icall (mb, mono_compile_method);
}
+#endif
/* mono_marshal_check_domain_image ()
* Returns TRUE if the image is loaded in the specified
return tmp != NULL;
}
+#ifndef DISABLE_REMOTING
+
/* mono_marshal_get_xappdomain_dispatch ()
* Generates a method that dispatches a method call from another domain into
* the current domain.
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_XDOMAIN_DISPATCH);
mb->method->save_lmf = 1;
+#ifndef DISABLE_JIT
/* Locals */
loc_serialized_exc = mono_mb_add_local (mb, &byte_array_class->byval_arg);
mono_mb_emit_byte (mb, CEE_RET);
mono_mb_set_clauses (mb, 1, main_clause);
+#endif
res = mono_remoting_mb_create_and_cache (method, mb, csig, csig->param_count + 16);
mono_mb_free (mb);
/* Locals */
+#ifndef DISABLE_JIT
if (complex_count > 0)
loc_array = mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
loc_serialized_data = mono_mb_add_local (mb, &byte_array_class->byval_arg);
}
mono_mb_emit_byte (mb, CEE_RET);
+#endif /* DISABLE_JIT */
res = mono_remoting_mb_create_and_cache (method, mb, sig, sig->param_count + 16);
mono_mb_free (mb);
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK);
+#ifndef DISABLE_JIT
for (i = 0; i <= sig->param_count; i++)
mono_mb_emit_ldarg (mb, i);
mono_mb_patch_branch (mb, pos);
mono_mb_emit_managed_call (mb, method, mono_method_signature (method));
mono_mb_emit_byte (mb, CEE_RET);
+#endif
res = mono_remoting_mb_create_and_cache (method, mb, sig, sig->param_count + 16);
mono_mb_free (mb);
return res;
}
+#endif /* DISABLE_REMOTING */
+
typedef struct
{
MonoMethodSignature *sig;
* Check cache
*/
if (ctx) {
- MonoMethod *def, *inst;
-
- /*
- * Look for the instance
- */
cache = get_cache (&method->klass->image->delegate_invoke_generic_cache, mono_aligned_addr_hash, NULL);
- res = mono_marshal_find_in_cache (cache, orig_method->klass);
+ res = check_generic_delegate_wrapper_cache (cache, orig_method, method, ctx);
if (res)
return res;
-
- /*
- * Look for the definition
- */
- def = mono_marshal_find_in_cache (cache, method->klass);
- if (def) {
- inst = mono_class_inflate_generic_method (def, ctx);
- /* Cache it */
- mono_memory_barrier ();
- mono_marshal_lock ();
- res = g_hash_table_lookup (cache, orig_method->klass);
- if (!res) {
- g_hash_table_insert (cache, orig_method->klass, inst);
- res = inst;
- }
- mono_marshal_unlock ();
- return res;
- }
} else if (callvirt || static_method_with_first_arg_bound) {
GHashTable **cache_ptr;
if (static_method_with_first_arg_bound)
mb = mono_mb_new (get_wrapper_target_class (method->klass->image), name, MONO_WRAPPER_DELEGATE_INVOKE);
g_free (name);
+#ifndef DISABLE_JIT
/* allocate local 0 (object) */
local_target = mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
local_prev = mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
mono_mb_emit_byte (mb, CEE_RET);
mb->skip_visibility = 1;
+#endif /* DISABLE_JIT */
if (ctx) {
- MonoMethod *def, *inst;
+ MonoMethod *def;
- /*
- * We use the same cache for the generic definition and the instances.
- */
def = mono_mb_create_and_cache (cache, method->klass, mb, sig, sig->param_count + 16);
-
- inst = mono_class_inflate_generic_method (def, ctx);
- mono_memory_barrier ();
- mono_marshal_lock ();
- res = g_hash_table_lookup (cache, orig_method->klass);
- if (!res) {
- g_hash_table_insert (cache, orig_method->klass, inst);
- res = inst;
- }
- mono_marshal_unlock ();
+ res = cache_generic_delegate_wrapper (cache, orig_method, def, ctx);
} else if (static_method_with_first_arg_bound || callvirt) {
// From mono_mb_create_and_cache
newm = mono_mb_create_method (mb, sig, sig->param_count + 16);
return mono_metadata_signature_equal (sig1, sig2);
}
+#ifndef DISABLE_JIT
+
/*
* emit_invoke_call:
*
if (sig->hasthis) {
if (method->string_ctor) {
- mono_mb_emit_ptr (mb, string_dummy);
+ if (mono_gc_is_moving ()) {
+ mono_mb_emit_ptr (mb, &string_dummy);
+ mono_mb_emit_byte (mb, CEE_LDIND_REF);
+ } else {
+ mono_mb_emit_ptr (mb, string_dummy);
+ }
} else {
mono_mb_emit_ldarg (mb, 0);
}
mono_mb_emit_ldloc (mb, 0);
mono_mb_emit_byte (mb, CEE_RET);
}
+#endif
/*
* generates IL code for the runtime invoke function
mb = mono_mb_new (target_klass, name, MONO_WRAPPER_RUNTIME_INVOKE);
g_free (name);
+#ifndef DISABLE_JIT
param_names [0] = "this";
param_names [1] = "params";
param_names [2] = "exc";
mono_mb_set_param_names (mb, param_names);
emit_runtime_invoke_body (mb, target_klass, method, sig, callsig, virtual, need_direct_wrapper);
+#endif
if (need_direct_wrapper) {
+#ifndef DISABLE_JIT
mb->skip_visibility = 1;
+#endif
res = mono_mb_create_and_cache (cache, method, mb, csig, sig->param_count + 16);
info = mono_wrapper_info_create (res, virtual ? WRAPPER_SUBTYPE_RUNTIME_INVOKE_VIRTUAL : WRAPPER_SUBTYPE_RUNTIME_INVOKE_DIRECT);
info->d.runtime_invoke.method = method;
g_hash_table_insert (cache, callsig, res);
/* Can't insert it into wrapper_hash since the key is a signature */
g_hash_table_insert (method->klass->image->runtime_invoke_direct_cache, method, res);
+ info = mono_wrapper_info_create (res, WRAPPER_SUBTYPE_RUNTIME_INVOKE_NORMAL);
+ info->d.runtime_invoke.sig = callsig;
+ mono_marshal_set_wrapper_info (res, info);
} else {
mono_free_method (newm);
}
mb = mono_mb_new (mono_defaults.object_class, name, MONO_WRAPPER_RUNTIME_INVOKE);
g_free (name);
+#ifndef DISABLE_JIT
/* allocate local 0 (object) tmp */
mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
/* allocate local 1 (object) exc */
mono_mb_patch_branch (mb, pos);
//mono_mb_emit_ldloc (mb, 0);
mono_mb_emit_byte (mb, CEE_RET);
+#endif /* DISABLE_JIT */
mono_loader_lock ();
/* double-checked locking */
return method;
}
+#ifndef DISABLE_JIT
static void
mono_mb_emit_auto_layout_exception (MonoMethodBuilder *mb, MonoClass *klass)
{
mono_mb_emit_exception_marshal_directive (mb, msg);
}
+#endif
+#ifndef DISABLE_REMOTING
/*
* mono_marshal_get_ldfld_remote_wrapper:
* @klass: The return type
sig->params [2] = &mono_defaults.int_class->byval_arg;
sig->ret = &mono_defaults.object_class->byval_arg;
+#ifndef DISABLE_JIT
mono_mb_emit_ldarg (mb, 0);
mono_mb_emit_ldarg (mb, 1);
mono_mb_emit_ldarg (mb, 2);
emit_thread_interrupt_checkpoint (mb);
mono_mb_emit_byte (mb, CEE_RET);
-
+#endif
+
mono_marshal_lock ();
res = cached;
mono_marshal_unlock ();
sig->params [3] = &mono_defaults.int_class->byval_arg;
sig->ret = &klass->byval_arg;
+#ifndef DISABLE_JIT
mono_mb_emit_ldarg (mb, 0);
pos0 = mono_mb_emit_proxy_check (mb, CEE_BNE_UN);
}
mono_mb_emit_byte (mb, CEE_RET);
-
+#endif /* DISABLE_JIT */
+
res = mono_mb_create_and_cache (cache, klass,
mb, sig, sig->param_count + 16);
mono_mb_free (mb);
sig->params [3] = &mono_defaults.int_class->byval_arg;
sig->ret = &mono_defaults.int_class->byval_arg;
+#ifndef DISABLE_JIT
/* if typeof (this) != transparent_proxy goto pos0 */
mono_mb_emit_ldarg (mb, 0);
pos0 = mono_mb_emit_proxy_check (mb, CEE_BNE_UN);
mono_mb_emit_byte (mb, CEE_ADD);
mono_mb_emit_byte (mb, CEE_RET);
-
+#endif
+
res = mono_mb_create_and_cache (cache, klass,
mb, sig, sig->param_count + 16);
mono_mb_free (mb);
sig->params [3] = &mono_defaults.object_class->byval_arg;
sig->ret = &mono_defaults.void_class->byval_arg;
+#ifndef DISABLE_JIT
mono_mb_emit_ldarg (mb, 0);
mono_mb_emit_ldarg (mb, 1);
mono_mb_emit_ldarg (mb, 2);
emit_thread_interrupt_checkpoint (mb);
mono_mb_emit_byte (mb, CEE_RET);
-
+#endif
+
mono_marshal_lock ();
res = cached;
mono_marshal_unlock ();
sig->params [4] = &klass->byval_arg;
sig->ret = &mono_defaults.void_class->byval_arg;
+#ifndef DISABLE_JIT
mono_mb_emit_ldarg (mb, 0);
pos = mono_mb_emit_proxy_check (mb, CEE_BNE_UN);
}
mono_mb_emit_byte (mb, CEE_RET);
-
+#endif
+
res = mono_mb_create_and_cache (cache, klass,
mb, sig, sig->param_count + 16);
mono_mb_free (mb);
return res;
}
+#endif /* DISABLE_REMOTING */
/*
* generates IL code for the icall wrapper (the generated method
else
csig2 = signature_dup (mono_defaults.corlib, sig);
+#ifndef DISABLE_JIT
if (sig->hasthis)
mono_mb_emit_byte (mb, CEE_LDARG_0);
for (i = 0; i < sig->param_count; i++)
mono_mb_emit_ldarg (mb, i + sig->hasthis);
- mono_mb_emit_native_call (mb, csig2, (gpointer) func);
+ mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
+ mono_mb_emit_op (mb, CEE_MONO_JIT_ICALL_ADDR, (gpointer)func);
+ mono_mb_emit_calli (mb, csig2);
if (check_exceptions)
emit_thread_interrupt_checkpoint (mb);
mono_mb_emit_byte (mb, CEE_RET);
+#endif
csig = signature_dup (mono_defaults.corlib, sig);
csig->pinvoke = 0;
mono_mb_free (mb);
info = mono_wrapper_info_create (res, WRAPPER_SUBTYPE_ICALL_WRAPPER);
+ info->d.icall.func = (gpointer)func;
mono_marshal_set_wrapper_info (res, info);
return res;
int conv_arg, MonoType **conv_arg_type,
MarshalAction action)
{
+#ifdef DISABLE_JIT
+ if (action == MARSHAL_ACTION_CONV_IN && t->type == MONO_TYPE_VALUETYPE)
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+ return conv_arg;
+#else
MonoType *mtype;
MonoClass *mklass;
static MonoClass *ICustomMarshaler = NULL;
default:
g_assert_not_reached ();
}
-
return conv_arg;
+#endif
+
}
static int
int conv_arg, MonoType **conv_arg_type,
MarshalAction action)
{
+#ifndef DISABLE_JIT
MonoMethodBuilder *mb = m->mb;
switch (action) {
default:
g_assert_not_reached ();
}
-
+#endif
return conv_arg;
}
int conv_arg, MonoType **conv_arg_type,
MarshalAction action)
{
+#ifndef DISABLE_JIT
MonoMethodBuilder *mb = m->mb;
MonoClass *klass, *date_time_class;
int pos = 0, pos2;
default:
g_assert_not_reached ();
}
-
+#endif
return conv_arg;
}
int conv_arg, MonoType **conv_arg_type,
MarshalAction action)
{
+#ifdef DISABLE_JIT
+ switch (action) {
+ case MARSHAL_ACTION_CONV_IN:
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+ break;
+ case MARSHAL_ACTION_MANAGED_CONV_IN:
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+ break;
+ }
+#else
MonoMethodBuilder *mb = m->mb;
MonoMarshalNative encoding = mono_marshal_get_string_encoding (m->piinfo, spec);
MonoMarshalConv conv = mono_marshal_get_string_to_ptr_conv (m->piinfo, spec);
default:
g_assert_not_reached ();
}
-
+#endif
return conv_arg;
}
+
static int
emit_marshal_safehandle (EmitMarshalContext *m, int argnum, MonoType *t,
MonoMarshalSpec *spec, int conv_arg,
MonoType **conv_arg_type, MarshalAction action)
{
+#ifdef DISABLE_JIT
+ if (action == MARSHAL_ACTION_CONV_IN)
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+#else
MonoMethodBuilder *mb = m->mb;
switch (action){
default:
printf ("Unhandled case for MarshalAction: %d\n", action);
}
-
+#endif
return conv_arg;
}
+
static int
emit_marshal_handleref (EmitMarshalContext *m, int argnum, MonoType *t,
MonoMarshalSpec *spec, int conv_arg,
MonoType **conv_arg_type, MarshalAction action)
{
+#ifdef DISABLE_JIT
+ if (action == MARSHAL_ACTION_CONV_IN)
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+#else
MonoMethodBuilder *mb = m->mb;
switch (action){
default:
fprintf (stderr, "Unhandled case for MarshalAction: %d\n", action);
}
-
+#endif
return conv_arg;
}
+
static int
emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
MonoMarshalSpec *spec,
int conv_arg, MonoType **conv_arg_type,
MarshalAction action)
{
+#ifdef DISABLE_JIT
+ if (action == MARSHAL_ACTION_CONV_IN)
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+#else
MonoMethodBuilder *mb = m->mb;
MonoClass *klass = mono_class_from_mono_type (t);
int pos, pos2, loc;
default:
g_assert_not_reached ();
}
-
+#endif
return conv_arg;
}
+#ifndef DISABLE_JIT
#ifndef DISABLE_COM
}
#endif /* DISABLE_COM */
+#endif /* DISABLE_JIT */
static gboolean
mono_pinvoke_is_unicode (MonoMethodPInvoke *piinfo)
}
}
+
static int
emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
MonoMarshalSpec *spec,
int conv_arg, MonoType **conv_arg_type,
MarshalAction action)
{
+#ifdef DISABLE_JIT
+ switch (action) {
+ case MARSHAL_ACTION_CONV_IN:
+ *conv_arg_type = &mono_defaults.object_class->byval_arg;
+ break;
+ case MARSHAL_ACTION_MANAGED_CONV_IN:
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+ break;
+ }
+#else
MonoMethodBuilder *mb = m->mb;
MonoClass *klass = mono_class_from_mono_type (t);
gboolean need_convert, need_free;
default:
g_assert_not_reached ();
}
-
+#endif
return conv_arg;
}
+static MonoType*
+marshal_boolean_conv_in_get_local_type (MonoMarshalSpec *spec, guint8 *ldc_op /*out*/)
+{
+ if (spec == NULL) {
+ return &mono_defaults.int32_class->byval_arg;
+ } else {
+ switch (spec->native) {
+ case MONO_NATIVE_I1:
+ case MONO_NATIVE_U1:
+ return &mono_defaults.byte_class->byval_arg;
+ case MONO_NATIVE_VARIANTBOOL:
+ if (ldc_op) *ldc_op = CEE_LDC_I4_M1;
+ return &mono_defaults.int16_class->byval_arg;
+ case MONO_NATIVE_BOOLEAN:
+ return &mono_defaults.int32_class->byval_arg;
+ default:
+ g_warning ("marshalling bool as native type %x is currently not supported", spec->native);
+ return &mono_defaults.int32_class->byval_arg;
+ }
+ }
+}
+
+static MonoClass*
+marshal_boolean_managed_conv_in_get_conv_arg_class (MonoMarshalSpec *spec, guint8 *ldop/*out*/)
+{
+ MonoClass* conv_arg_class = mono_defaults.int32_class;
+ if (spec) {
+ switch (spec->native) {
+ case MONO_NATIVE_I1:
+ case MONO_NATIVE_U1:
+ conv_arg_class = mono_defaults.byte_class;
+ if (ldop) *ldop = CEE_LDIND_I1;
+ break;
+ case MONO_NATIVE_VARIANTBOOL:
+ conv_arg_class = mono_defaults.int16_class;
+ if (ldop) *ldop = CEE_LDIND_I2;
+ break;
+ case MONO_NATIVE_BOOLEAN:
+ break;
+ default:
+ g_warning ("marshalling bool as native type %x is currently not supported", spec->native);
+ }
+ }
+ return conv_arg_class;
+}
+
static int
emit_marshal_boolean (EmitMarshalContext *m, int argnum, MonoType *t,
MonoMarshalSpec *spec,
int conv_arg, MonoType **conv_arg_type,
MarshalAction action)
{
+#ifdef DISABLE_JIT
+ switch (action) {
+ case MARSHAL_ACTION_CONV_IN:
+ if (t->byref)
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+ else
+ *conv_arg_type = marshal_boolean_conv_in_get_local_type (spec, NULL);
+ break;
+
+ case MARSHAL_ACTION_MANAGED_CONV_IN: {
+ MonoClass* conv_arg_class = marshal_boolean_managed_conv_in_get_conv_arg_class (spec, NULL);
+ if (t->byref)
+ *conv_arg_type = &conv_arg_class->this_arg;
+ else
+ *conv_arg_type = &conv_arg_class->byval_arg;
+ break;
+ }
+
+ }
+#else
MonoMethodBuilder *mb = m->mb;
switch (action) {
int label_false;
guint8 ldc_op = CEE_LDC_I4_1;
- if (spec == NULL) {
- local_type = &mono_defaults.int32_class->byval_arg;
- } else {
- switch (spec->native) {
- case MONO_NATIVE_I1:
- case MONO_NATIVE_U1:
- local_type = &mono_defaults.byte_class->byval_arg;
- break;
- case MONO_NATIVE_VARIANTBOOL:
- local_type = &mono_defaults.int16_class->byval_arg;
- ldc_op = CEE_LDC_I4_M1;
- break;
- case MONO_NATIVE_BOOLEAN:
- local_type = &mono_defaults.int32_class->byval_arg;
- break;
- default:
- g_warning ("marshalling bool as native type %x is currently not supported", spec->native);
- local_type = &mono_defaults.int32_class->byval_arg;
- break;
- }
- }
+ local_type = marshal_boolean_conv_in_get_local_type (spec, &ldc_op);
if (t->byref)
*conv_arg_type = &mono_defaults.int_class->byval_arg;
else
guint8 ldop = CEE_LDIND_I4;
int label_null, label_false;
+ conv_arg_class = marshal_boolean_managed_conv_in_get_conv_arg_class (spec, &ldop);
conv_arg = mono_mb_add_local (mb, &mono_defaults.boolean_class->byval_arg);
- if (spec) {
- switch (spec->native) {
- case MONO_NATIVE_I1:
- case MONO_NATIVE_U1:
- conv_arg_class = mono_defaults.byte_class;
- ldop = CEE_LDIND_I1;
- break;
- case MONO_NATIVE_VARIANTBOOL:
- conv_arg_class = mono_defaults.int16_class;
- ldop = CEE_LDIND_I2;
- break;
- case MONO_NATIVE_BOOLEAN:
- break;
- default:
- g_warning ("marshalling bool as native type %x is currently not supported", spec->native);
- }
- }
-
if (t->byref)
*conv_arg_type = &conv_arg_class->this_arg;
else
default:
g_assert_not_reached ();
}
-
+#endif
return conv_arg;
}
MonoMarshalSpec *spec, int conv_arg,
MonoType **conv_arg_type, MarshalAction action)
{
+#ifndef DISABLE_JIT
MonoMethodBuilder *mb = m->mb;
switch (action) {
default:
break;
}
-
+#endif
return conv_arg;
}
MonoMarshalSpec *spec, int conv_arg,
MonoType **conv_arg_type, MarshalAction action)
{
+#ifndef DISABLE_JIT
MonoMethodBuilder *mb = m->mb;
switch (action) {
default:
break;
}
-
+#endif
return conv_arg;
}
MonoMarshalSpec *spec, int conv_arg,
MonoType **conv_arg_type, MarshalAction action)
{
+#ifndef DISABLE_JIT
MonoMethodBuilder *mb = m->mb;
switch (action) {
default:
break;
}
-
+#endif
return conv_arg;
}
else
return emit_marshal_object (m, argnum, t, spec, conv_arg, conv_arg_type, action);
}
-
return conv_arg;
}
+#ifndef DISABLE_JIT
/**
* mono_marshal_emit_native_wrapper:
* @image: the image to use for looking up custom marshallers
mono_mb_emit_byte (mb, CEE_RET);
}
+#endif /* DISABLE_JIT */
+
G_GNUC_UNUSED static void
code_for (MonoMethod *method) {
/* create a wrapper to preserve .ctor in stack trace */
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_MANAGED_TO_MANAGED);
+#ifndef DISABLE_JIT
mono_mb_emit_byte (mb, CEE_LDARG_0);
for (i = 1; i <= csig->param_count; i++)
mono_mb_emit_ldarg (mb, i);
mono_mb_emit_managed_call (mb, res, NULL);
mono_mb_emit_byte (mb, CEE_RET);
+#endif
/* use native_wrapper_cache because internal calls are looked up there */
res = mono_mb_create_and_cache (cache, method,
* registered in the runtime doing the AOT compilation.
*/
if (!piinfo->addr && !aot) {
+#ifndef DISABLE_JIT
mono_mb_emit_exception (mb, exc_class, exc_arg);
+#endif
csig = signature_dup (method->klass->image, sig);
csig->pinvoke = 0;
res = mono_mb_create_and_cache (cache, method,
mb, csig, csig->param_count + 16);
mono_mb_free (mb);
+
+ info = mono_wrapper_info_create (res, WRAPPER_SUBTYPE_NONE);
+ info->d.managed_to_native.method = method;
+ mono_marshal_set_wrapper_info (res, info);
+
return res;
}
if (method->string_ctor)
csig->ret = &mono_defaults.string_class->byval_arg;
+#ifndef DISABLE_JIT
if (sig->hasthis) {
int pos;
if (check_exceptions)
emit_thread_interrupt_checkpoint (mb);
mono_mb_emit_byte (mb, CEE_RET);
+#endif
csig = signature_dup (method->klass->image, csig);
csig->pinvoke = 0;
if (!aot)
g_assert (piinfo->addr);
+#ifndef DISABLE_JIT
mspecs = g_new (MonoMarshalSpec*, sig->param_count + 1);
mono_method_get_marshal_info (method, mspecs);
mono_marshal_emit_native_wrapper (mb->method->klass->image, mb, sig, piinfo, mspecs, piinfo->addr, aot, check_exceptions, FALSE);
+#endif
csig = signature_dup (method->klass->image, sig);
csig->pinvoke = 0;
info->d.managed_to_native.method = method;
mono_marshal_set_wrapper_info (res, info);
+#ifndef DISABLE_JIT
for (i = sig->param_count; i >= 0; i--)
if (mspecs [i])
mono_metadata_free_marshal_spec (mspecs [i]);
g_free (mspecs);
+#endif
/* code_for (res); */
mb = mono_mb_new (mono_defaults.object_class, name, MONO_WRAPPER_MANAGED_TO_NATIVE);
mb->method->save_lmf = 1;
+#ifndef DISABLE_JIT
mono_marshal_emit_native_wrapper (image, mb, sig, piinfo, mspecs, func, FALSE, TRUE, FALSE);
+#endif
csig = signature_dup (image, sig);
csig->pinvoke = 0;
mb = mono_mb_new (invoke->klass, name, MONO_WRAPPER_MANAGED_TO_NATIVE);
mb->method->save_lmf = 1;
+#ifndef DISABLE_JIT
mono_marshal_emit_native_wrapper (image, mb, sig, piinfo, mspecs, NULL, FALSE, TRUE, TRUE);
+#endif
g_assert (!sig->hasthis);
csig = signature_dup_add_this (image, sig, mono_defaults.int_class);
return res;
}
-
+
/*
* mono_marshal_emit_managed_wrapper:
*
void
mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle)
{
+#ifdef DISABLE_JIT
+ MonoMethodSignature *sig, *csig;
+ int i;
+
+ sig = m->sig;
+ csig = m->csig;
+
+ /* we first do all conversions */
+ for (i = 0; i < sig->param_count; i ++) {
+ MonoType *t = sig->params [i];
+
+ switch (t->type) {
+ case MONO_TYPE_OBJECT:
+ case MONO_TYPE_CLASS:
+ case MONO_TYPE_VALUETYPE:
+ case MONO_TYPE_ARRAY:
+ case MONO_TYPE_SZARRAY:
+ case MONO_TYPE_STRING:
+ case MONO_TYPE_BOOLEAN:
+ emit_marshal (m, i, sig->params [i], mspecs [i + 1], 0, &csig->params [i], MARSHAL_ACTION_MANAGED_CONV_IN);
+ }
+ }
+#else
MonoMethodSignature *sig, *csig;
int i, *tmp_locals;
gboolean closed = FALSE;
if (closed)
g_free (sig);
+#endif
}
-
static void
mono_marshal_set_callconv_from_modopt (MonoMethod *method, MonoMethodSignature *csig)
{
info->d.native_to_managed.klass = delegate_klass;
mono_marshal_set_wrapper_info (res, info);
} else {
+#ifndef DISABLE_JIT
mb->dynamic = 1;
+#endif
res = mono_mb_create_method (mb, csig, sig->param_count + 16);
}
mono_mb_free (mb);
mono_marshal_emit_managed_wrapper (mb, sig, mspecs, &m, method, 0);
+#ifndef DISABLE_JIT
mb->dynamic = 1;
+#endif
method = mono_mb_create_method (mb, csig, sig->param_count + 16);
mono_mb_free (mb);
sig = mono_method_signature (method);
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_MANAGED_TO_MANAGED);
+#ifndef DISABLE_JIT
param_count = sig->param_count + sig->hasthis;
for (i = 0; i < param_count; i++)
mono_mb_emit_ldarg (mb, i);
mono_mb_emit_byte (mb, CEE_RET);
mb->dynamic = 1;
+#endif
+
method = mono_mb_create_method (mb, sig, param_count);
mono_mb_free (mb);
sig->ret = &mono_defaults.object_class->byval_arg;
sig->pinvoke = 0;
+#ifndef DISABLE_JIT
/* allocate local 0 (pointer) obj_vtable */
mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
mono_mb_patch_branch (mb, return_null_pos);
mono_mb_emit_byte (mb, CEE_LDNULL);
mono_mb_emit_byte (mb, CEE_RET);
+#endif /* DISABLE_JIT */
res = mono_mb_create_method (mb, sig, 8);
info = mono_wrapper_info_create (res, WRAPPER_SUBTYPE_CASTCLASS_WITH_CACHE);
sig->ret = &mono_defaults.object_class->byval_arg;
sig->pinvoke = 0;
+#ifndef DISABLE_JIT
/* allocate local 0 (pointer) obj_vtable */
mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
/* allocate local 1 (pointer) cached_vtable */
mono_mb_patch_branch (mb, return_null_pos);
mono_mb_emit_byte (mb, CEE_LDNULL);
mono_mb_emit_byte (mb, CEE_RET);
+#endif
res = mono_mb_create_method (mb, sig, 8);
info = mono_wrapper_info_create (res, WRAPPER_SUBTYPE_ISINST_WITH_CACHE);
mb->method->save_lmf = 1;
+#ifndef DISABLE_JIT
/* check if the object is a proxy that needs special cast */
mono_mb_emit_ldarg (mb, 0);
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
mono_mb_emit_op (mb, CEE_MONO_CISINST, klass);
- /* The result of MONO_ISINST can be:
+ /* The result of MONO_CISINST can be:
0) the type check succeeded
1) the type check did not succeed
2) a CanCastTo call is needed */
-
+#ifndef DISABLE_REMOTING
mono_mb_emit_byte (mb, CEE_DUP);
pos_was_ok = mono_mb_emit_branch (mb, CEE_BRFALSE);
mono_mb_patch_branch (mb, pos_end);
mono_mb_patch_branch (mb, pos_end2);
mono_mb_emit_byte (mb, CEE_RET);
+#else
+ pos_was_ok = mono_mb_emit_branch (mb, CEE_BRFALSE);
+
+ /* fail */
+
+ mono_mb_emit_byte (mb, CEE_LDNULL);
+ pos_end = mono_mb_emit_branch (mb, CEE_BR);
+
+ /* success */
+
+ mono_mb_patch_branch (mb, pos_was_ok);
+ mono_mb_emit_ldarg (mb, 0);
+
+ /* the end */
+
+ mono_mb_patch_branch (mb, pos_end);
+ mono_mb_emit_byte (mb, CEE_RET);
+#endif /* DISABLE_REMOTING */
+#endif /* DISABLE_JIT */
res = mono_mb_create_and_cache (cache, klass, mb, isint_sig, isint_sig->param_count + 16);
mono_mb_free (mb);
mb->method->save_lmf = 1;
+#ifndef DISABLE_JIT
/* check if the object is a proxy that needs special cast */
mono_mb_emit_ldarg (mb, 0);
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
mono_mb_emit_op (mb, CEE_MONO_CCASTCLASS, klass);
- /* The result of MONO_ISINST can be:
+ /* The result of MONO_CCASTCLASS can be:
0) the cast is valid
1) cast of unknown proxy type
or an exception if the cast is is invalid
*/
-
+#ifndef DISABLE_REMOTING
pos_was_ok = mono_mb_emit_branch (mb, CEE_BRFALSE);
/* get the real proxy from the transparent proxy*/
/* success */
mono_mb_patch_branch (mb, pos_was_ok);
mono_mb_patch_branch (mb, pos_was_ok2);
+#else
+ /* MONO_CCASTCLASS leaves an int in the stack with the result, pop it. */
+ mono_mb_emit_byte (mb, CEE_POP);
+#endif /* DISABLE_REMOTING */
+
mono_mb_emit_ldarg (mb, 0);
/* the end */
mono_mb_emit_byte (mb, CEE_RET);
+#endif /* DISABLE_JIT */
res = mono_mb_create_and_cache (cache, klass, mb, castclass_sig, castclass_sig->param_count + 16);
mono_mb_free (mb);
return res;
}
+#ifndef DISABLE_REMOTING
MonoMethod *
mono_marshal_get_proxy_cancast (MonoClass *klass)
{
mb->method->save_lmf = 1;
+#ifndef DISABLE_JIT
/* get the real proxy from the transparent proxy*/
mono_mb_emit_ldarg (mb, 0);
mono_mb_emit_ldflda (mb, G_STRUCT_OFFSET (MonoTransparentProxy, rp));
mono_mb_patch_branch (mb, pos_end);
mono_mb_emit_byte (mb, CEE_RET);
+#endif
res = mono_mb_create_and_cache (cache, klass, mb, isint_sig, isint_sig->param_count + 16);
mono_mb_free (mb);
klass = mono_class_from_mono_type (rtype->type);
mono_upgrade_remote_class (domain, (MonoObject*)tproxy, klass);
}
+#endif /*DISABLE_REMOTING */
/**
* mono_marshal_get_struct_to_ptr:
mb = mono_mb_new (klass, stoptr->name, MONO_WRAPPER_UNKNOWN);
+#ifndef DISABLE_JIT
if (klass->blittable) {
mono_mb_emit_byte (mb, CEE_LDARG_1);
mono_mb_emit_byte (mb, CEE_LDARG_0);
}
mono_mb_emit_byte (mb, CEE_RET);
+#endif
res = mono_mb_create_method (mb, mono_signature_no_pinvoke (stoptr), 0);
mono_mb_free (mb);
mb = mono_mb_new (klass, "PtrToStructure", MONO_WRAPPER_UNKNOWN);
+#ifndef DISABLE_JIT
if (klass->blittable) {
mono_mb_emit_byte (mb, CEE_LDARG_1);
mono_mb_emit_ldflda (mb, sizeof (MonoObject));
}
mono_mb_emit_byte (mb, CEE_RET);
+#endif
res = mono_mb_create_method (mb, ptostr, 0);
mono_mb_free (mb);
MonoMethod *res;
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_UNKNOWN);
+#ifndef DISABLE_JIT
mono_mb_emit_exception_full (mb, "System", "ExecutionEngineException", "Shouldn't be called.");
mono_mb_emit_byte (mb, CEE_RET);
+#endif
sig = signature_dup (method->klass->image, mono_method_signature (method));
res = mono_mb_create_method (mb, sig, 0);
mono_mb_free (mb);
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_SYNCHRONIZED);
+#ifndef DISABLE_JIT
/* result */
if (!MONO_TYPE_IS_VOID (sig->ret))
ret_local = mono_mb_add_local (mb, sig->ret);
+#endif
if (method->klass->valuetype && !(method->flags & MONO_METHOD_ATTR_STATIC)) {
mono_class_set_failure (method->klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
+#ifndef DISABLE_JIT
/* This will throw the type load exception when the wrapper is compiled */
mono_mb_emit_byte (mb, CEE_LDNULL);
mono_mb_emit_op (mb, CEE_ISINST, method->klass);
if (!MONO_TYPE_IS_VOID (sig->ret))
mono_mb_emit_ldloc (mb, ret_local);
mono_mb_emit_byte (mb, CEE_RET);
+#endif
res = mono_mb_create_and_cache (cache, method,
mb, sig, sig->param_count + 16);
return res;
}
+#ifndef DISABLE_JIT
/* this */
this_local = mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
clause = mono_image_alloc0 (method->klass->image, sizeof (MonoExceptionClause));
clause->flags = MONO_EXCEPTION_CLAUSE_FINALLY;
+#endif
mono_loader_lock ();
mono_loader_unlock ();
+#ifndef DISABLE_JIT
/* Push this or the type object */
if (method->flags & METHOD_ATTRIBUTE_STATIC) {
/* We have special handling for this in the JIT */
mono_mb_emit_byte (mb, CEE_RET);
mono_mb_set_clauses (mb, 1, clause);
+#endif
res = mono_mb_create_and_cache (cache, method,
mb, sig, sig->param_count + 16);
g_assert (sig->hasthis);
+#ifndef DISABLE_JIT
mono_mb_emit_ldarg (mb, 0);
mono_mb_emit_icon (mb, sizeof (MonoObject));
mono_mb_emit_byte (mb, CEE_ADD);
mono_mb_emit_ldarg (mb, i + 1);
mono_mb_emit_managed_call (mb, method, NULL);
mono_mb_emit_byte (mb, CEE_RET);
+#endif
res = mono_mb_create_and_cache (cache, method,
mb, sig, sig->param_count + 16);
return STELEMREF_INTERFACE;
#endif
/*Arrays are sealed but are covariant on their element type, We can't use any of the fast paths.*/
- if (element_class->marshalbyref || element_class->rank || mono_class_has_variant_generic_params (element_class))
+ if (mono_class_is_marshalbyref (element_class) || element_class->rank || mono_class_has_variant_generic_params (element_class))
return STELEMREF_COMPLEX;
if (element_class->flags & TYPE_ATTRIBUTE_SEALED)
return STELEMREF_SEALED_CLASS;
return STELEMREF_CLASS;
}
+#ifndef DISABLE_JIT
+
static void
load_array_element_address (MonoMethodBuilder *mb)
{
mono_mb_emit_byte (mb, CEE_LDIND_I);
mono_mb_emit_stloc (mb, vklass);
}
+#endif
#if 0
static void
* - Maybe mve some MonoClass field into the vtable to reduce the number of loads
* - Add a case for arrays of arrays.
*/
-MonoMethod*
-mono_marshal_get_virtual_stelemref (MonoClass *array_class)
+static MonoMethod*
+get_virtual_stelemref_wrapper (int kind)
{
static MonoMethod *cached_methods [STELEMREF_KIND_COUNT] = { NULL }; /*object iface sealed regular*/
static MonoMethodSignature *signature;
MonoMethodBuilder *mb;
MonoMethod *res;
- int kind;
char *name;
const char *param_names [16];
guint32 b1, b2, b3;
int array_slot_addr;
WrapperInfo *info;
- g_assert (array_class->rank == 1);
- kind = get_virtual_stelemref_kind (array_class->element_class);
-
if (cached_methods [kind])
return cached_methods [kind];
mb = mono_mb_new (mono_defaults.object_class, name, MONO_WRAPPER_STELEMREF);
g_free (name);
- param_names [0] = "index";
- param_names [1] = "value";
- mono_mb_set_param_names (mb, param_names);
-
if (!signature) {
MonoMethodSignature *sig = mono_metadata_signature_alloc (mono_defaults.corlib, 2);
signature = sig;
}
+#ifndef DISABLE_JIT
+ param_names [0] = "index";
+ param_names [1] = "value";
+ mono_mb_set_param_names (mb, param_names);
+
/*For now simply call plain old stelemref*/
switch (kind) {
case STELEMREF_OBJECT:
mono_mb_emit_byte (mb, CEE_RET);
g_assert (0);
}
+#endif /* DISABLE_JIT */
res = mono_mb_create_method (mb, signature, 4);
res->flags |= METHOD_ATTRIBUTE_VIRTUAL;
return cached_methods [kind];
}
+MonoMethod*
+mono_marshal_get_virtual_stelemref (MonoClass *array_class)
+{
+ int kind;
+
+ g_assert (array_class->rank == 1);
+ kind = get_virtual_stelemref_kind (array_class->element_class);
+
+ return get_virtual_stelemref_wrapper (kind);
+}
+
+MonoMethod**
+mono_marshal_get_virtual_stelemref_wrappers (int *nwrappers)
+{
+ MonoMethod **res;
+ int i;
+
+ *nwrappers = STELEMREF_KIND_COUNT;
+ res = g_malloc0 (STELEMREF_KIND_COUNT * sizeof (MonoMethod*));
+ for (i = 0; i < STELEMREF_KIND_COUNT; ++i)
+ res [i] = get_virtual_stelemref_wrapper (i);
+ return res;
+}
+
/*
* The wrapper info for the wrapper is a WrapperInfo structure.
*/
sig->params [0] = &mono_defaults.object_class->byval_arg;
sig->params [1] = &mono_defaults.int_class->byval_arg; /* this is a natural sized int */
sig->params [2] = &mono_defaults.object_class->byval_arg;
-
+
+#ifndef DISABLE_JIT
aklass = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
vklass = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
array_slot_addr = mono_mb_add_local (mb, &mono_defaults.object_class->this_arg);
mono_mb_emit_exception (mb, "ArrayTypeMismatchException", NULL);
mono_mb_emit_byte (mb, CEE_RET);
+#endif
+
ret = mono_mb_create_method (mb, sig, 4);
mono_mb_free (mb);
sig = mono_metadata_signature_alloc (mono_defaults.corlib, 0);
sig->ret = &mono_defaults.void_class->byval_arg;
+#ifndef DISABLE_JIT
/*
* The body is generated by the JIT, we use a wrapper instead of a trampoline so EH works.
*/
mono_mb_emit_byte (mb, CEE_RET);
+#endif
ret = mono_mb_create_method (mb, sig, 4);
mono_mb_free (mb);
sig = mono_metadata_signature_alloc (mono_defaults.corlib, 0);
sig->ret = &mono_defaults.void_class->byval_arg;
+#ifndef DISABLE_JIT
/*
* The body is generated by the JIT, we use a wrapper instead of a trampoline so EH works.
*/
mono_mb_emit_byte (mb, CEE_RET);
+#endif
ret = mono_mb_create_method (mb, sig, 4);
mono_mb_free (mb);
mb = mono_mb_new (mono_defaults.object_class, "ElementAddr", MONO_WRAPPER_MANAGED_TO_MANAGED);
+#ifndef DISABLE_JIT
bounds = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
ind = mono_mb_add_local (mb, &mono_defaults.int32_class->byval_arg);
realidx = mono_mb_add_local (mb, &mono_defaults.int32_class->byval_arg);
mono_mb_emit_exception (mb, "IndexOutOfRangeException", NULL);
g_free (branch_positions);
+#endif /* DISABLE_JIT */
+
ret = mono_mb_create_method (mb, sig, 4);
mono_mb_free (mb);
csig = signature_dup (method->klass->image, sig);
csig->generic_param_count = 0;
+#ifndef DISABLE_JIT
mono_mb_emit_ldarg (mb, 0);
for (i = 0; i < csig->param_count; i++)
mono_mb_emit_ldarg (mb, i + 1);
/* We can corlib internal methods */
mb->skip_visibility = TRUE;
+#endif
res = mono_mb_create_method (mb, csig, csig->param_count + 16);
if (MONO_TYPE_ISSTRUCT (sig->ret))
csig->ret = &mono_defaults.object_class->byval_arg;
+#ifndef DISABLE_JIT
/* local 0 (temp for exception object) */
mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
}
mono_mb_emit_byte (mb, CEE_RET);
+#endif
res = mono_mb_create_and_cache (cache, method, mb, csig, param_count + 16);
mono_mb_free (mb);