From 4382b4d89044902b592a833f1e404fde61304bd3 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Tue, 19 Aug 2008 00:00:55 +0000 Subject: [PATCH] 2008-08-19 Zoltan Varga * aot-runtime.c (decode_klass_ref): Add support for VARs/MVARs. * aot-compiler.c (encode_klass_ref): Encode is_method too for VARs/MVARs. * method-to-ir.c (emit_get_rgctx_method): Use MONO_PATCH_INFO_METHODCONST as the patch type. * mini.c (mono_resolve_patch_target): Ditto. svn path=/trunk/mono/; revision=110887 --- mono/mini/ChangeLog | 9 +++++++++ mono/mini/aot-compiler.c | 1 + mono/mini/aot-runtime.c | 35 +++++++++++++++++++++++++++++++++-- mono/mini/mini.c | 2 +- 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/mono/mini/ChangeLog b/mono/mini/ChangeLog index 52e79c04526..7ca52980d2a 100644 --- a/mono/mini/ChangeLog +++ b/mono/mini/ChangeLog @@ -1,5 +1,14 @@ 2008-08-19 Zoltan Varga + * aot-runtime.c (decode_klass_ref): Add support for VARs/MVARs. + + * aot-compiler.c (encode_klass_ref): Encode is_method too for VARs/MVARs. + + * method-to-ir.c (emit_get_rgctx_method): Use MONO_PATCH_INFO_METHODCONST + as the patch type. + + * mini.c (mono_resolve_patch_target): Ditto. + * aot-compiler.c (encode_patch): Add support for RGCTX_FETCH. (encode_klass_ref): Add support for encoding VARs/MVARs. diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c index f84f0689da6..89378abe3ce 100644 --- a/mono/mini/aot-compiler.c +++ b/mono/mini/aot-compiler.c @@ -1741,6 +1741,7 @@ encode_klass_ref (MonoAotCompile *acfg, MonoClass *klass, guint8 *buf, guint8 ** encode_value (param->num, p, &p); g_assert (param->owner); + encode_value (param->owner->is_method, p, &p); if (param->owner->is_method) encode_method_ref (acfg, param->owner->owner.method, p, &p); else diff --git a/mono/mini/aot-runtime.c b/mono/mini/aot-runtime.c index e619ed21298..5918bcd11e1 100644 --- a/mono/mini/aot-runtime.c +++ b/mono/mini/aot-runtime.c @@ -239,6 +239,9 @@ decode_value (guint8 *ptr, guint8 **rptr) return len; } +static MonoMethod* +decode_method_ref_2 (MonoAotModule *module, guint8 *buf, guint8 **endbuf); + static MonoClass* decode_klass_ref (MonoAotModule *module, guint8 *buf, guint8 **endbuf) { @@ -288,7 +291,35 @@ decode_klass_ref (MonoAotModule *module, guint8 *buf, guint8 **endbuf) klass = mono_class_from_mono_type (type); mono_metadata_free_type (type); } else if ((type == MONO_TYPE_VAR) || (type == MONO_TYPE_MVAR)) { - g_assert_not_reached (); + MonoType *t; + gboolean is_method; + + // FIXME: Maybe use types directly to avoid + // the overhead of creating MonoClass-es + + // FIXME: Memory management + t = g_new0 (MonoType, 1); + t->type = type; + t->data.generic_param = g_new0 (MonoGenericParam, 1); + t->data.generic_param->num = decode_value (p, &p); + + is_method = decode_value (p, &p); + if (is_method) { + g_assert_not_reached (); + } else { + MonoClass *class_def = decode_klass_ref (module, p, &p); + + if (!class_def) { + g_free (t->data.generic_param); + g_free (t); + return NULL; + } + + g_assert (class_def->generic_container); + t->data.generic_param->owner = class_def->generic_container; + } + + klass = mono_class_from_mono_type (t); } else { g_assert_not_reached (); } @@ -408,7 +439,7 @@ decode_method_ref (MonoAotModule *module, guint32 *token, MonoMethod **method, g * * Similar to decode_method_ref, but resolve and return the method itself. */ -static inline MonoMethod* +static MonoMethod* decode_method_ref_2 (MonoAotModule *module, guint8 *buf, guint8 **endbuf) { MonoMethod *method; diff --git a/mono/mini/mini.c b/mono/mini/mini.c index c613ce8859b..9574bc14f96 100644 --- a/mono/mini/mini.c +++ b/mono/mini/mini.c @@ -11535,7 +11535,7 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code, case MONO_PATCH_INFO_CLASS: slot = mono_method_lookup_or_register_other_info (entry->method, entry->in_mrgctx, &entry->data->data.klass->byval_arg, entry->info_type, mono_method_get_context (entry->method)); break; - case MONO_PATCH_INFO_METHOD: + case MONO_PATCH_INFO_METHODCONST: slot = mono_method_lookup_or_register_other_info (entry->method, entry->in_mrgctx, entry->data->data.method, entry->info_type, mono_method_get_context (entry->method)); break; case MONO_PATCH_INFO_FIELD: -- 2.25.1