Permalink
Browse files

Disable the native method-builder under DISABLE_JIT.

	* method-builder.c: Disable all code related to producing IL under DISABLE_JIT.
	This has the side effect of crippling wrapper debugging on device, but given this
	feature (IL debugging of wrappers) has almost no users, we're ok.
  • Loading branch information...
1 parent 7396c0a commit 1643364ee8772c47876b96e7ea6ac3cc452ae449 @kumpera kumpera committed Feb 22, 2013
@@ -64,8 +64,10 @@ mono_mb_new_base (MonoClass *klass, MonoWrapperType type)
m->inline_info = 1;
m->wrapper_type = type;
+#ifndef DISABLE_JIT
mb->code_size = 40;
mb->code = g_malloc (mb->code_size);
+#endif
/* placeholder for the wrapper always at index 1 */
mono_mb_add_data (mb, NULL);
@@ -92,31 +94,22 @@ mono_mb_new (MonoClass *klass, const char *name, MonoWrapperType type)
void
mono_mb_free (MonoMethodBuilder *mb)
{
+#ifndef DISABLE_JIT
g_list_free (mb->locals_list);
if (!mb->dynamic) {
g_free (mb->method);
if (!mb->no_dup_name)
g_free (mb->name);
g_free (mb->code);
}
+#else
+ g_free (mb->method);
+ if (!mb->no_dup_name)
+ g_free (mb->name);
+#endif
g_free (mb);
}
-int
-mono_mb_add_local (MonoMethodBuilder *mb, MonoType *type)
-{
- int res;
-
- g_assert (mb != NULL);
- g_assert (type != NULL);
-
- res = mb->locals;
- mb->locals_list = g_list_append (mb->locals_list, type);
- mb->locals++;
-
- return res;
-}
-
/**
* mono_mb_create_method:
*
@@ -128,7 +121,9 @@ mono_mb_add_local (MonoMethodBuilder *mb, MonoType *type)
MonoMethod *
mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, int max_stack)
{
+#ifndef DISABLE_JIT
MonoMethodHeader *header;
+#endif
MonoMethodWrapper *mw;
MonoImage *image;
MonoMethod *method;
@@ -140,6 +135,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
image = mb->method->klass->image;
mono_loader_lock (); /*FIXME I think this lock can go.*/
+#ifndef DISABLE_JIT
if (mb->dynamic) {
method = mb->method;
mw = (MonoMethodWrapper*)method;
@@ -155,7 +151,9 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
for (i = 0, l = mb->locals_list; l; l = l->next, i++) {
header->locals [i] = mono_metadata_type_dup (NULL, (MonoType*)l->data);
}
- } else {
+ } else
+#endif
+ {
/* Realloc the method info into a mempool */
method = mono_image_alloc0 (image, sizeof (MonoMethodWrapper));
@@ -167,6 +165,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
else
method->name = mono_image_strdup (image, mb->name);
+#ifndef DISABLE_JIT
mw->header = header = (MonoMethodHeader *)
mono_image_alloc0 (image, MONO_SIZEOF_METHOD_HEADER + mb->locals * sizeof (MonoType *));
@@ -176,15 +175,17 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
for (i = 0, l = mb->locals_list; l; l = l->next, i++) {
header->locals [i] = (MonoType *)l->data;
}
+#endif
}
+ method->signature = signature;
+
+#ifndef DISABLE_JIT
if (max_stack < 8)
max_stack = 8;
header->max_stack = max_stack;
- method->signature = signature;
-
header->code_size = mb->pos;
header->num_locals = mb->locals;
header->init_locals = TRUE;
@@ -193,6 +194,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
header->clauses = mb->clauses;
method->skip_visibility = mb->skip_visibility;
+#endif
i = g_list_length (mw->method_data);
if (i) {
@@ -213,6 +215,8 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
mw->method_data = data;
}
+
+#ifndef DISABLE_JIT
/*{
static int total_code = 0;
static int total_alloc = 0;
@@ -237,6 +241,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
g_hash_table_insert (image->wrapper_param_names, method, param_names);
mono_image_unlock (image);
}
+#endif
mono_loader_unlock ();
return method;
@@ -257,6 +262,23 @@ mono_mb_add_data (MonoMethodBuilder *mb, gpointer data)
return g_list_length (mw->method_data);
}
+#ifndef DISABLE_JIT
+
+int
+mono_mb_add_local (MonoMethodBuilder *mb, MonoType *type)
+{
+ int res;
+
+ g_assert (mb != NULL);
+ g_assert (type != NULL);
+
+ res = mb->locals;
+ mb->locals_list = g_list_append (mb->locals_list, type);
+ mb->locals++;
+
+ return res;
+}
+
void
mono_mb_patch_addr (MonoMethodBuilder *mb, int pos, int value)
{
@@ -555,3 +577,5 @@ mono_mb_set_param_names (MonoMethodBuilder *mb, const char **param_names)
{
mb->param_names = param_names;
}
+
+#endif /* DISABLE_JIT */
@@ -11,6 +11,7 @@
#ifndef __MONO_METHOD_BUILDER_H__
#define __MONO_METHOD_BUILDER_H__
+#include "config.h"
#include <mono/metadata/class.h>
#include <mono/metadata/object-internals.h>
#include <mono/metadata/class-internals.h>
@@ -22,16 +23,18 @@ G_BEGIN_DECLS
typedef struct _MonoMethodBuilder {
MonoMethod *method;
char *name;
+ gboolean no_dup_name;
+#ifndef DISABLE_JIT
GList *locals_list;
int locals;
gboolean dynamic;
- gboolean no_dup_name;
gboolean skip_visibility;
guint32 code_size, pos;
unsigned char *code;
int num_clauses;
MonoExceptionClause *clauses;
const char **param_names;
+#endif
} MonoMethodBuilder;
MonoMethodBuilder *
@@ -43,6 +46,13 @@ mono_mb_new_no_dup_name (MonoClass *klass, const char *name, MonoWrapperType typ
void
mono_mb_free (MonoMethodBuilder *mb) MONO_INTERNAL;
+MonoMethod *
+mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, int max_stack) MONO_INTERNAL;
+
+guint32
+mono_mb_add_data (MonoMethodBuilder *mb, gpointer data) MONO_INTERNAL;
+
+#ifndef DISABLE_JIT
void
mono_mb_patch_addr (MonoMethodBuilder *mb, int pos, int value) MONO_INTERNAL;
@@ -61,9 +71,6 @@ mono_mb_get_label (MonoMethodBuilder *mb) MONO_INTERNAL;
int
mono_mb_get_pos (MonoMethodBuilder *mb) MONO_INTERNAL;
-guint32
-mono_mb_add_data (MonoMethodBuilder *mb, gpointer data) MONO_INTERNAL;
-
void
mono_mb_emit_ptr (MonoMethodBuilder *mb, gpointer ptr) MONO_INTERNAL;
@@ -82,9 +89,6 @@ mono_mb_emit_icall (MonoMethodBuilder *mb, gpointer func) MONO_INTERNAL;
int
mono_mb_add_local (MonoMethodBuilder *mb, MonoType *type) MONO_INTERNAL;
-MonoMethod *
-mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, int max_stack) MONO_INTERNAL;
-
void
mono_mb_emit_ldarg (MonoMethodBuilder *mb, guint argnum) MONO_INTERNAL;
@@ -145,6 +149,8 @@ mono_mb_set_clauses (MonoMethodBuilder *mb, int num_clauses, MonoExceptionClause
void
mono_mb_set_param_names (MonoMethodBuilder *mb, const char **param_names) MONO_INTERNAL;
+#endif
+
G_END_DECLS
#endif /* __MONO_METHOD_BUILDER_H__ */
@@ -784,6 +784,8 @@ mono_monitor_get_object_monitor_weak_link (MonoObject *object)
return NULL;
}
+#ifndef DISABLE_JIT
+
static void
emit_obj_syncp_check (MonoMethodBuilder *mb, int syncp_loc, int *obj_null_branch, int *true_locktaken_branch, int *syncp_true_false_branch,
int *thin_hash_branch, gboolean branch_on_true)
@@ -848,6 +850,8 @@ emit_obj_syncp_check (MonoMethodBuilder *mb, int syncp_loc, int *obj_null_branch
*syncp_true_false_branch = mono_mb_emit_short_branch (mb, branch_on_true ? CEE_BRTRUE_S : CEE_BRFALSE_S);
}
+#endif
+
static MonoMethod* monitor_il_fastpaths[3];
gboolean
@@ -918,6 +922,7 @@ mono_monitor_get_fast_enter_method (MonoMethod *monitor_enter_method)
mb->method->flags = METHOD_ATTRIBUTE_PUBLIC | METHOD_ATTRIBUTE_STATIC |
METHOD_ATTRIBUTE_HIDE_BY_SIG | METHOD_ATTRIBUTE_FINAL;
+#ifndef DISABLE_JIT
tid_loc = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
syncp_loc = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
owner_loc = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
@@ -1037,6 +1042,7 @@ mono_monitor_get_fast_enter_method (MonoMethod *monitor_enter_method)
mono_mb_emit_byte (mb, CEE_LDARG_1);
mono_mb_emit_managed_call (mb, monitor_enter_method, NULL);
mono_mb_emit_byte (mb, CEE_RET);
+#endif
res = register_fastpath (mono_mb_create_method (mb, mono_signature_no_pinvoke (monitor_enter_method), 5), fast_path_idx);
@@ -1071,6 +1077,7 @@ mono_monitor_get_fast_exit_method (MonoMethod *monitor_exit_method)
mb->method->flags = METHOD_ATTRIBUTE_PUBLIC | METHOD_ATTRIBUTE_STATIC |
METHOD_ATTRIBUTE_HIDE_BY_SIG | METHOD_ATTRIBUTE_FINAL;
+#ifndef DISABLE_JIT
syncp_loc = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
emit_obj_syncp_check (mb, syncp_loc, &obj_null_branch, NULL, &has_syncp_branch, &thin_hash_branch, TRUE);
@@ -1197,6 +1204,7 @@ mono_monitor_get_fast_exit_method (MonoMethod *monitor_exit_method)
mono_mb_emit_byte (mb, CEE_LDARG_0);
mono_mb_emit_managed_call (mb, monitor_exit_method, NULL);
mono_mb_emit_byte (mb, CEE_RET);
+#endif
res = register_fastpath (mono_mb_create_method (mb, mono_signature_no_pinvoke (monitor_exit_method), 5), FASTPATH_EXIT);
mono_mb_free (mb);
@@ -714,6 +714,8 @@ create_allocator (int atype)
csig->params [i] = &mono_defaults.int_class->byval_arg;
mb = mono_mb_new (mono_defaults.object_class, name, MONO_WRAPPER_ALLOC);
+
+#ifndef DISABLE_JIT
size_var = mono_mb_add_local (mb, &mono_defaults.int32_class->byval_arg);
if (atype == ATYPE_NORMAL || atype == ATYPE_SMALL) {
/* size = vtable->klass->instance_size; */
@@ -892,6 +894,7 @@ create_allocator (int atype)
/* return p */
mono_mb_emit_ldloc (mb, p_var);
mono_mb_emit_byte (mb, CEE_RET);
+#endif
res = mono_mb_create_method (mb, csig, 8);
mono_mb_free (mb);
@@ -5273,6 +5273,8 @@ sgen_has_critical_method (void)
return write_barrier_method || sgen_has_managed_allocator ();
}
+#ifndef DISABLE_JIT
+
static void
emit_nursery_check (MonoMethodBuilder *mb, int *nursery_check_return_labels)
{
@@ -5338,6 +5340,7 @@ emit_nursery_check (MonoMethodBuilder *mb, int *nursery_check_return_labels)
}
#endif
}
+#endif
MonoMethod*
mono_gc_get_write_barrier (void)
@@ -5377,6 +5380,7 @@ mono_gc_get_write_barrier (void)
mb = mono_mb_new (mono_defaults.object_class, "wbarrier", MONO_WRAPPER_WRITE_BARRIER);
+#ifndef DISABLE_JIT
#ifdef MANAGED_WBARRIER
if (use_cardtable) {
emit_nursery_check (mb, nursery_check_labels);
@@ -5504,6 +5508,7 @@ mono_gc_get_write_barrier (void)
mono_mb_emit_byte (mb, CEE_RET);
}
+#endif
res = mono_mb_create_method (mb, sig, 16);
mono_mb_free (mb);

0 comments on commit 1643364

Please sign in to comment.