* If it is a static P/Invoke method, we can just return the pointer
* to the method implementation.
*/
- if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL && method->addr) {
+ if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL && ((MonoMethodPInvoke*) method)->addr) {
ji = g_new0 (MonoJitInfo, 1);
ji->method = method;
ji->code_size = 1;
- ji->code_start = method->addr;
+ ji->code_start = addr = ((MonoMethodPInvoke*) method)->addr;
mono_jit_info_table_add (mono_get_root_domain (), ji);
-
- addr = method->addr;
}
else
addr = mono_arch_create_method_pointer (method);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CALLINT)
- ves_pinvoke_method (frame, frame->runtime_method->method->signature, frame->runtime_method->method->addr,
+ ves_pinvoke_method (frame, frame->runtime_method->method->signature, ((MonoMethodPInvoke*) frame->runtime_method->method)->addr,
frame->runtime_method->method->string_ctor, context);
if (frame->ex) {
rtm = NULL;
(!method->signature->hasthis || method->klass->rank == 0)) {
runtime_method->code = g_malloc(sizeof(short));
runtime_method->code[0] = MINT_CALLINT;
- if (method->addr == NULL)
- method->addr = mono_lookup_internal_call (method);
+ if (((MonoMethodPInvoke*) method)->addr == NULL)
+ ((MonoMethodPInvoke*) method)->addr = mono_lookup_internal_call (method);
runtime_method->func = mono_arch_create_trampoline (method->signature, method->string_ctor);
} else {
const char *name = method->name;
2004-11-07 Ben Maurer <bmaurer@ximian.com>
+ * class-internals.h (MonoMethod): Move addr to MonoMethodPInvoke
+ since most only those methods use it. the code member of
+ MonoMethodPInvoke was dead, so that can be removed too. Also,
+ remove inline_count (again, not used), and move slot so that it
+ can share bits with some other flags. This saves 8 bytes in the
+ structure and gives us about 50 kb back for mcs helloworld.cs
+
+ * *.[ch]: Do naming changes for the above.
+
* loader.c (mono_method_get_header): Lazily init the header
on first access.
(mono_get_method_from_token): don't init the header here
guint32 token;
MonoClass *klass;
MonoMethodSignature *signature;
- gpointer addr;
gpointer info; /* runtime info */
- gint slot;
/* name is useful mostly for debugging */
const char *name;
/* this is used by the inlining algorithm */
unsigned int string_ctor:1;
unsigned int save_lmf:1;
unsigned int dynamic:1; /* created & destroyed during runtime */
- gint16 inline_count;
+ gint slot : 22;
};
struct _MonoMethodNormal {
struct _MonoMethodPInvoke {
MonoMethod method;
- void (*code) (void);
+ gpointer addr;
/* add marshal info */
guint16 piflags; /* pinvoke flags */
guint16 implmap_idx; /* index into IMPLMAP */
if (!strcmp (mname, ".ctor")) {
/* we special-case this in the runtime. */
- result->addr = NULL;
return result;
}
g_assert (sig->hasthis);
g_assert (type->data.array->rank + 1 == sig->param_count);
result->iflags |= METHOD_IMPL_ATTRIBUTE_RUNTIME;
- result->addr = NULL;
return result;
}
g_assert (sig->hasthis);
g_assert (type->data.array->rank == sig->param_count);
result->iflags |= METHOD_IMPL_ATTRIBUTE_RUNTIME;
- result->addr = NULL;
return result;
}
g_assert (sig->hasthis);
g_assert (type->data.array->rank == sig->param_count);
result->iflags |= METHOD_IMPL_ATTRIBUTE_RUNTIME;
- result->addr = NULL;
return result;
}
g_assert (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL);
- if (method->addr)
- return method->addr;
+ if (piinfo->addr)
+ return piinfo->addr;
if (method->klass->image->dynamic) {
MonoReflectionMethodAux *method_aux =
}
if (piinfo->piflags & PINVOKE_ATTRIBUTE_NO_MANGLE) {
- g_module_symbol (gmodule, import, &method->addr);
+ g_module_symbol (gmodule, import, &piinfo->addr);
} else {
char *mangled_name;
switch (piinfo->piflags & PINVOKE_ATTRIBUTE_CHAR_SET_MASK) {
case PINVOKE_ATTRIBUTE_CHAR_SET_UNICODE:
mangled_name = g_strconcat (import, "W", NULL);
- g_module_symbol (gmodule, mangled_name, &method->addr);
+ g_module_symbol (gmodule, mangled_name, &piinfo->addr);
g_free (mangled_name);
- if (!method->addr)
- g_module_symbol (gmodule, import, &method->addr);
+ if (!piinfo->addr)
+ g_module_symbol (gmodule, import, &piinfo->addr);
break;
case PINVOKE_ATTRIBUTE_CHAR_SET_AUTO:
- g_module_symbol (gmodule, import, &method->addr);
+ g_module_symbol (gmodule, import, &piinfo->addr);
break;
case PINVOKE_ATTRIBUTE_CHAR_SET_ANSI:
default:
mangled_name = g_strconcat (import, "A", NULL);
- g_module_symbol (gmodule, mangled_name, &method->addr);
+ g_module_symbol (gmodule, mangled_name, &piinfo->addr);
g_free (mangled_name);
- if (!method->addr)
- g_module_symbol (gmodule, import, &method->addr);
+ if (!piinfo->addr)
+ g_module_symbol (gmodule, import, &piinfo->addr);
break;
}
#ifdef PLATFORM_WIN32
/* Try the stdcall mangled name */
- if (!method->addr) {
+ if (!piinfo->addr) {
/* FIX: Compute this correctly */
mangled_name = g_strdup_printf ("%s@%d", import, method->signature->param_count * sizeof (gpointer));
- g_module_symbol (gmodule, mangled_name, &method->addr);
+ g_module_symbol (gmodule, mangled_name, &piinfo->addr);
g_free (mangled_name);
}
- if (!method->addr) {
+ if (!piinfo->addr) {
mangled_name = g_strdup_printf ("_%s@%d", import, method->signature->param_count * sizeof (gpointer));
- g_module_symbol (gmodule, mangled_name, &method->addr);
+ g_module_symbol (gmodule, mangled_name, &piinfo->addr);
g_free (mangled_name);
}
#endif
}
- if (!method->addr) {
+ if (!piinfo->addr) {
if (exc_class) {
*exc_class = "EntryPointNotFoundException";
*exc_arg = import;
}
return NULL;
}
- return method->addr;
+ return piinfo->addr;
}
static MonoMethod *
mono_free_method (MonoMethod *method)
{
mono_metadata_free_method_signature (method->signature);
- if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
- MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)method;
- g_free (piinfo->code);
- } else if (!(method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) && ((MonoMethodNormal *)method)->header) {
+ if (!(method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) && ((MonoMethodNormal *)method)->header) {
mono_metadata_free_mh (((MonoMethodNormal *)method)->header);
}
m->klass = klass;
m->name = g_strdup (name);
m->inline_info = 1;
- m->inline_count = -1;
m->wrapper_type = type;
mb->code_size = 256;
* @method: The MonoMethod to wrap.
*
* generates IL code for the pinvoke wrapper (the generated method
- * calls the unmanaged code in method->addr)
+ * calls the unmanaged code in piinfo->addr)
*/
MonoMethod *
mono_marshal_get_native_wrapper (MonoMethod *method)
{
EmitMarshalContext m;
MonoMethodSignature *sig, *csig;
- MonoMethodPInvoke *piinfo;
+ MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *) method;
MonoMethodBuilder *mb;
MonoMarshalSpec **mspecs;
MonoMethod *res;
(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
pinvoke = TRUE;
- if (!method->addr) {
+ if (!piinfo->addr) {
if (pinvoke)
mono_lookup_pinvoke_call (method, &exc_class, &exc_arg);
else
- method->addr = mono_lookup_internal_call (method);
+ piinfo->addr = mono_lookup_internal_call (method);
}
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_MANAGED_TO_NATIVE);
mb->method->save_lmf = 1;
-
- piinfo = (MonoMethodPInvoke *)method;
-
- if (!method->addr) {
+
+ if (!piinfo->addr) {
mono_mb_emit_exception (mb, exc_class, exc_arg);
csig = mono_metadata_signature_dup (sig);
csig->pinvoke = 0;
for (i = 0; i < sig->param_count; i++)
mono_mb_emit_ldarg (mb, i + sig->hasthis);
- g_assert (method->addr);
- mono_mb_emit_native_call (mb, csig, method->addr);
+ g_assert (piinfo->addr);
+ mono_mb_emit_native_call (mb, csig, piinfo->addr);
emit_thread_interrupt_checkpoint (mb);
mono_mb_emit_byte (mb, CEE_RET);
}
/* call the native method */
- mono_mb_emit_native_call (mb, csig, method->addr);
+ mono_mb_emit_native_call (mb, csig, piinfo->addr);
/* Set LastError if needed */
if (piinfo->piflags & PINVOKE_ATTRIBUTE_SUPPORTS_LAST_ERROR) {
+2004-11-07 Ben Maurer <bmaurer@ximian.com>
+
+ * tramp-*.c: we no longer support icalls without wrappers, so
+ a bit of code can be removed here
+
2004-11-07 Zoltan Varga <vargaz@freemail.hu>
* exceptions-sparc.c (get_throw_exception): Fix more bugs in previous
gboolean
mono_arch_has_unwind_info (gconstpointer addr)
{
-#if 0
- struct frame_state state_in;
- struct frame_state *res;
-
- if (!inited)
- init_frame_state_for ();
-
- if (!frame_state_for)
- return FALSE;
-
- g_assert (method->addr);
-
- memset (&state_in, 0, sizeof (state_in));
-
- /* offset 10 is just a guess, but it works for all methods tested */
- if ((res = frame_state_for ((char *)method->addr + 10, &state_in))) {
-
- if (res->saved [X86_EBX] != 1 ||
- res->saved [X86_EDI] != 1 ||
- res->saved [X86_EBP] != 1 ||
- res->saved [X86_ESI] != 1) {
- return FALSE;
- }
- return TRUE;
- } else {
- return FALSE;
- }
-#else
return FALSE;
-#endif
}
/*========================= End of Function ========================*/
if ((method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)) {
MonoMethod *nm;
+ MonoMethodPInvoke* piinfo = (MonoMethodPInvoke *) method;
- if (!method->addr) {
+ if (!piinfo->addr) {
if (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)
- method->addr = mono_lookup_internal_call (method);
+ piinfo->addr = mono_lookup_internal_call (method);
else
if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
mono_lookup_pinvoke_call (method, NULL, NULL);
MonoJitInfo *target_ji =
mono_jit_info_table_find (mono_domain_get (), addr);
- /* The first part of the condition means an icall without a wrapper */
- if ((!target_ji && m->addr) || mono_method_same_domain (ji, target_ji)) {
+ if (mono_method_same_domain (ji, target_ji)) {
InterlockedExchangePointer ((gpointer*)(code - 11), addr);
}
}
MonoJitInfo *target_ji =
mono_jit_info_table_find (mono_domain_get (), addr);
- /* The first part of the condition means an icall without a wrapper */
- if ((!target_ji && m->addr) || mono_method_same_domain (ji, target_ji)) {
+ if (mono_method_same_domain (ji, target_ji)) {
sparc_call_simple (code, (guint8*)addr - (guint8*)code);
}
}
MonoJitInfo *target_ji =
mono_jit_info_table_find (mono_domain_get (), addr);
- /* The first part of the condition means an icall without a wrapper */
- if ((!target_ji && m->addr) || mono_method_same_domain (ji, target_ji)) {
+ if (mono_method_same_domain (ji, target_ji)) {
if (!mono_running_on_valgrind ()) {
InterlockedExchange ((gint32*)(code + 2), (guint)addr - ((guint)code + 1) - 5);