* mini.h (MONO_AOT_FILE_VERSION): Bump aot file format version.
* aot-runtime.c aot-compiler.c patch-info.h mini.c: Get rid of
MONO_PATCH_INFO_WRAPPER, encode/decode wrapper methods like the others in
encode/decode_method_ref ().
svn path=/trunk/mono/; revision=111156
2008-08-20 Zoltan Varga <vargaz@gmail.com>
+ * mini.h (MONO_AOT_FILE_VERSION): Bump aot file format version.
+
+ * aot-runtime.c aot-compiler.c patch-info.h mini.c: Get rid of
+ MONO_PATCH_INFO_WRAPPER, encode/decode wrapper methods like the others in
+ encode/decode_method_ref ().
+
* aot-compiler.c (encode_patch): Handle STATIC_RGCTX_INVOKE wrappers.
* aot-runtime.c (decode_patch): Ditto.
g_assert (image_index < MAX_IMAGE_INDEX);
- if (mono_method_signature (method)->is_inflated) {
+ if (method->wrapper_type) {
+ /* Marker */
+ encode_value ((253 << 24), p, &p);
+
+ encode_value (method->wrapper_type, p, &p);
+
+ switch (method->wrapper_type) {
+ case MONO_WRAPPER_REMOTING_INVOKE:
+ case MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK:
+ case MONO_WRAPPER_XDOMAIN_INVOKE: {
+ MonoMethod *m;
+
+ m = mono_marshal_method_from_wrapper (method);
+ g_assert (m);
+ encode_method_ref (acfg, m, p, &p);
+ break;
+ }
+ case MONO_WRAPPER_PROXY_ISINST:
+ case MONO_WRAPPER_LDFLD:
+ case MONO_WRAPPER_LDFLDA:
+ case MONO_WRAPPER_STFLD:
+ case MONO_WRAPPER_ISINST: {
+ MonoClass *proxy_class = (MonoClass*)mono_marshal_method_from_wrapper (method);
+ encode_klass_ref (acfg, proxy_class, p, &p);
+ break;
+ }
+ case MONO_WRAPPER_LDFLD_REMOTE:
+ case MONO_WRAPPER_STFLD_REMOTE:
+ break;
+ case MONO_WRAPPER_ALLOC: {
+ int alloc_type = mono_gc_get_managed_allocator_type (method);
+ g_assert (alloc_type != -1);
+ encode_value (alloc_type, p, &p);
+ break;
+ }
+ case MONO_WRAPPER_STELEMREF:
+ break;
+ case MONO_WRAPPER_STATIC_RGCTX_INVOKE: {
+ MonoMethod *m;
+
+ m = mono_marshal_method_from_wrapper (method);
+ g_assert (m);
+ encode_method_ref (acfg, m, p, &p);
+ break;
+ }
+ default:
+ g_assert_not_reached ();
+ }
+ } else if (mono_method_signature (method)->is_inflated) {
/*
* This is a generic method, find the original token which referenced it and
* encode that.
{
switch (patch_info->type) {
case MONO_PATCH_INFO_METHOD:
- case MONO_PATCH_INFO_WRAPPER:
case MONO_PATCH_INFO_INTERNAL_METHOD:
case MONO_PATCH_INFO_JIT_ICALL_ADDR:
case MONO_PATCH_INFO_CLASS_INIT:
break;
case MONO_PATCH_INFO_INTERRUPTION_REQUEST_FLAG:
break;
- case MONO_PATCH_INFO_WRAPPER:
- encode_value (patch_info->data.method->wrapper_type, p, &p);
-
- switch (patch_info->data.method->wrapper_type) {
- case MONO_WRAPPER_REMOTING_INVOKE:
- case MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK:
- case MONO_WRAPPER_XDOMAIN_INVOKE: {
- MonoMethod *m;
- guint32 image_index;
- guint32 token;
-
- m = mono_marshal_method_from_wrapper (patch_info->data.method);
- image_index = get_image_index (acfg, m->klass->image);
- token = m->token;
- g_assert (image_index < 256);
- g_assert (mono_metadata_token_table (token) == MONO_TABLE_METHOD);
-
- encode_value ((image_index << 24) + (mono_metadata_token_index (token)), p, &p);
- break;
- }
- case MONO_WRAPPER_PROXY_ISINST:
- case MONO_WRAPPER_LDFLD:
- case MONO_WRAPPER_LDFLDA:
- case MONO_WRAPPER_STFLD:
- case MONO_WRAPPER_ISINST: {
- MonoClass *proxy_class = (MonoClass*)mono_marshal_method_from_wrapper (patch_info->data.method);
- encode_klass_ref (acfg, proxy_class, p, &p);
- break;
- }
- case MONO_WRAPPER_LDFLD_REMOTE:
- case MONO_WRAPPER_STFLD_REMOTE:
- break;
- case MONO_WRAPPER_ALLOC: {
- int alloc_type = mono_gc_get_managed_allocator_type (patch_info->data.method);
- g_assert (alloc_type != -1);
- encode_value (alloc_type, p, &p);
- break;
- }
- case MONO_WRAPPER_STELEMREF:
- break;
- case MONO_WRAPPER_STATIC_RGCTX_INVOKE: {
- MonoMethod *m;
-
- m = mono_marshal_method_from_wrapper (patch_info->data.method);
- g_assert (m);
- encode_method_ref (acfg, m, p, &p);
- break;
- }
- default:
- g_assert_not_reached ();
- }
- break;
case MONO_PATCH_INFO_RGCTX_FETCH: {
MonoJumpInfoRgctxEntry *entry = patch_info->data.rgctx_entry;
/* Collect method->token associations from the cfg */
g_hash_table_foreach (cfg->token_info_hash, add_token_info_hash, acfg);
+ /*
+ * Check for absolute addresses.
+ */
skip = FALSE;
for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
switch (patch_info->type) {
return;
}
- /* Convert method patches referring to wrapper methods to MONO_PATCH_INFO_WRAPPER */
+ /*
+ * Check for wrapper methods we can't encode.
+ */
skip = FALSE;
for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
if ((patch_info->type == MONO_PATCH_INFO_METHODCONST) || (patch_info->type == MONO_PATCH_INFO_METHOD)) {
switch (patch_info->data.method->wrapper_type) {
case MONO_WRAPPER_NONE:
- break;
case MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK:
case MONO_WRAPPER_XDOMAIN_INVOKE:
case MONO_WRAPPER_STFLD:
case MONO_WRAPPER_ALLOC:
case MONO_WRAPPER_REMOTING_INVOKE:
case MONO_WRAPPER_STATIC_RGCTX_INVOKE:
- patch_info->type = MONO_PATCH_INFO_WRAPPER;
break;
default:
/* unable to handle this */
} else if (patch_info->type == MONO_PATCH_INFO_RGCTX_FETCH) {
MonoJumpInfo *child = patch_info->data.rgctx_entry->data;
- if (child->type == MONO_PATCH_INFO_METHODCONST && child->data.method->wrapper_type == MONO_WRAPPER_STATIC_RGCTX_INVOKE)
- child->type = MONO_PATCH_INFO_WRAPPER;
+ if (child->type == MONO_PATCH_INFO_METHODCONST) {
+ switch (child->data.method->wrapper_type) {
+ case MONO_WRAPPER_NONE:
+ case MONO_WRAPPER_STATIC_RGCTX_INVOKE:
+ break;
+ default:
+ skip = TRUE;
+ }
+ }
}
}
return;
}
+ /*
+ * Check for methods/klasses we can't encode.
+ */
skip = FALSE;
for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
switch (patch_info->type) {
case MONO_PATCH_INFO_METHOD:
case MONO_PATCH_INFO_METHODCONST:
+ if (patch_info->data.method->wrapper_type)
+ break;
if (!patch_info->data.method->token) {
/* The method is part of a constructed type like Int[,].Set (). */
if (!g_hash_table_lookup (acfg->token_info_hash, patch_info->data.method))
value = decode_value (p, &p);
image_index = value >> 24;
- if (image_index == 255) {
+ if (image_index == 253) {
+ /* Wrapper */
+ guint32 wrapper_type;
+
+ wrapper_type = decode_value (p, &p);
+
+ /* Doesn't matter */
+ image = mono_defaults.corlib;
+
+ switch (wrapper_type) {
+ case MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK: {
+ MonoMethod *m = decode_method_ref_2 (module, p, &p);
+
+ if (!m)
+ return NULL;
+ mono_class_init (m->klass);
+ *method = mono_marshal_get_remoting_invoke_with_check (m);
+ break;
+ }
+ case MONO_WRAPPER_PROXY_ISINST: {
+ MonoClass *klass = decode_klass_ref (module, p, &p);
+ if (!klass)
+ return NULL;
+ *method = mono_marshal_get_proxy_cancast (klass);
+ break;
+ }
+ case MONO_WRAPPER_LDFLD:
+ case MONO_WRAPPER_LDFLDA:
+ case MONO_WRAPPER_STFLD:
+ case MONO_WRAPPER_ISINST: {
+ MonoClass *klass = decode_klass_ref (module, p, &p);
+ if (!klass)
+ return NULL;
+ if (wrapper_type == MONO_WRAPPER_LDFLD)
+ *method = mono_marshal_get_ldfld_wrapper (&klass->byval_arg);
+ else if (wrapper_type == MONO_WRAPPER_LDFLDA)
+ *method = mono_marshal_get_ldflda_wrapper (&klass->byval_arg);
+ else if (wrapper_type == MONO_WRAPPER_STFLD)
+ *method = mono_marshal_get_stfld_wrapper (&klass->byval_arg);
+ else if (wrapper_type == MONO_WRAPPER_ISINST)
+ *method = mono_marshal_get_isinst (klass);
+ else
+ g_assert_not_reached ();
+ break;
+ }
+ case MONO_WRAPPER_LDFLD_REMOTE:
+ *method = mono_marshal_get_ldfld_remote_wrapper (NULL);
+ break;
+ case MONO_WRAPPER_STFLD_REMOTE:
+ *method = mono_marshal_get_stfld_remote_wrapper (NULL);
+ break;
+ case MONO_WRAPPER_ALLOC: {
+ int atype = decode_value (p, &p);
+
+ *method = mono_gc_get_managed_allocator_by_type (atype);
+ break;
+ }
+ case MONO_WRAPPER_STELEMREF:
+ *method = mono_marshal_get_stelemref ();
+ break;
+ case MONO_WRAPPER_STATIC_RGCTX_INVOKE: {
+ MonoMethod *m = decode_method_ref_2 (module, p, &p);
+
+ if (!m)
+ return NULL;
+ *method = mono_marshal_get_static_rgctx_invoke (m);
+ break;
+ }
+ default:
+ g_assert_not_reached ();
+ }
+ } else if (image_index == 255) {
/* Methodspec */
image_index = decode_value (p, &p);
*token = decode_value (p, &p);
break;
}
- case MONO_PATCH_INFO_WRAPPER: {
- guint32 wrapper_type;
-
- wrapper_type = decode_value (p, &p);
-
- ji->type = MONO_PATCH_INFO_METHOD;
-
- switch (wrapper_type) {
- case MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK: {
- guint32 image_index, token, value;
-
- value = decode_value (p, &p);
- image_index = value >> 24;
- token = MONO_TOKEN_METHOD_DEF | (value & 0xffffff);
-
- image = load_image (aot_module, image_index);
- if (!image)
- goto cleanup;
- ji->data.method = mono_get_method (image, token, NULL);
- g_assert (ji->data.method);
- mono_class_init (ji->data.method->klass);
-
- ji->data.method = mono_marshal_get_remoting_invoke_with_check (ji->data.method);
- break;
- }
- case MONO_WRAPPER_PROXY_ISINST: {
- MonoClass *klass = decode_klass_ref (aot_module, p, &p);
- if (!klass)
- goto cleanup;
- ji->data.method = mono_marshal_get_proxy_cancast (klass);
- break;
- }
- case MONO_WRAPPER_LDFLD:
- case MONO_WRAPPER_LDFLDA:
- case MONO_WRAPPER_STFLD:
- case MONO_WRAPPER_ISINST: {
- MonoClass *klass = decode_klass_ref (aot_module, p, &p);
- if (!klass)
- goto cleanup;
- if (wrapper_type == MONO_WRAPPER_LDFLD)
- ji->data.method = mono_marshal_get_ldfld_wrapper (&klass->byval_arg);
- else if (wrapper_type == MONO_WRAPPER_LDFLDA)
- ji->data.method = mono_marshal_get_ldflda_wrapper (&klass->byval_arg);
- else if (wrapper_type == MONO_WRAPPER_STFLD)
- ji->data.method = mono_marshal_get_stfld_wrapper (&klass->byval_arg);
- else if (wrapper_type == MONO_WRAPPER_ISINST)
- ji->data.method = mono_marshal_get_isinst (klass);
- else
- g_assert_not_reached ();
- break;
- }
- case MONO_WRAPPER_LDFLD_REMOTE:
- ji->data.method = mono_marshal_get_ldfld_remote_wrapper (NULL);
- break;
- case MONO_WRAPPER_STFLD_REMOTE:
- ji->data.method = mono_marshal_get_stfld_remote_wrapper (NULL);
- break;
- case MONO_WRAPPER_ALLOC: {
- int atype = decode_value (p, &p);
-
- ji->data.method = mono_gc_get_managed_allocator_by_type (atype);
- break;
- }
- case MONO_WRAPPER_STELEMREF:
- ji->data.method = mono_marshal_get_stelemref ();
- break;
- case MONO_WRAPPER_STATIC_RGCTX_INVOKE: {
- MonoMethod *m = decode_method_ref_2 (aot_module, p, &p);
-
- if (!m)
- goto cleanup;
- ji->data.method = mono_marshal_get_static_rgctx_invoke (m);
- break;
- }
- default:
- g_assert_not_reached ();
- }
- break;
- }
case MONO_PATCH_INFO_INTERNAL_METHOD:
case MONO_PATCH_INFO_JIT_ICALL_ADDR: {
guint32 len = decode_value (p, &p);
case MONO_PATCH_INFO_IMAGE:
case MONO_PATCH_INFO_INTERNAL_METHOD:
case MONO_PATCH_INFO_JIT_ICALL_ADDR:
- case MONO_PATCH_INFO_WRAPPER:
case MONO_PATCH_INFO_FIELD:
case MONO_PATCH_INFO_SFLDA:
return (ji->type << 8) | (gssize)ji->data.target;
#define MONO_FAKE_VTABLE_METHOD ((MonoMethod*)GINT_TO_POINTER(-2))
/* Version number of the AOT file format */
-#define MONO_AOT_FILE_VERSION "37"
+#define MONO_AOT_FILE_VERSION "38"
/* Per-domain information maintained by the JIT */
typedef struct
PATCH_INFO(ADJUSTED_IID, "adjusted_iid")
PATCH_INFO(BB_OVF, "bb_ovf")
PATCH_INFO(EXC_OVF, "exc_ovf")
-PATCH_INFO(WRAPPER, "wrapper")
PATCH_INFO(GOT_OFFSET, "got_offset")
PATCH_INFO(DECLSEC, "declsec")
PATCH_INFO(RVA, "rva")