diff options
author | Zoltan Varga <vargaz@gmail.com> | 2009-10-07 00:25:22 +0400 |
---|---|---|
committer | Zoltan Varga <vargaz@gmail.com> | 2009-10-07 00:25:22 +0400 |
commit | 51a238609c4c196985d2fcc3c1edf10442ff94de (patch) | |
tree | c9981cf6a8b7fc27079e66191ab31ef8bdf80320 | |
parent | d6e27776a9d3c50e40dfc5be8cb42aaf5cb94a18 (diff) |
Revert "Merge branch 'master-2.6' into mt-1.0-master"monotouch-1.0
This reverts commit f5302c64d9074f8250bb7e372a5faa3ba515767d, reversing
changes made to a04667db95c879584ec3a83d902ea61c1584ec27.
svn path=/tags/monotouch-1-0/mono/; revision=143559
118 files changed, 1016 insertions, 3947 deletions
diff --git a/ChangeLog b/ChangeLog index 59e1f054938..7af9bdffe0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,3 @@ -2009-09-29 Ankit Jain <jankit@novell.com> - - * mono-core.spec.in: Add Microsoft.WebApplication.targets - -2009-08-29 Jonathan Pryor <jpryor@novell.com> - - * man/mdoc-export-html.1: Document --with-profile, --with-version. - 2009-09-08 Zoltan Varga <vargaz@gmail.com> * acinclude.m4 (dolt_supported): Enable this for mips. diff --git a/configure.in b/configure.in index dafbb9b8609..9e38702b2eb 100644 --- a/configure.in +++ b/configure.in @@ -6,7 +6,7 @@ AC_CANONICAL_SYSTEM m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])]) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(mono,2.6) +AM_INIT_AUTOMAKE(mono,2.5) AM_MAINTAINER_MODE API_VER=1.0 diff --git a/eglib/ChangeLog b/eglib/ChangeLog index e1d53d58fd4..0b2b96b182d 100644 --- a/eglib/ChangeLog +++ b/eglib/ChangeLog @@ -1,12 +1,3 @@ -2009-09-26 Gonzalo Paniagua Javier <gonzalo@novell.com> - - * test/queue.c: new tests. - * src/gqueue.c: fixed pop_head. - -2009-09-26 Gonzalo Paniagua Javier <gonzalo@novell.com> - - * src/gqueue.c: add g_queue_push_tail. - 2009-06-20 Zoltan Varga <vargaz@gmail.com> * src/glib.h: Add GUINT32_FROM/TO_BE macros. diff --git a/eglib/src/glib.h b/eglib/src/glib.h index bd4e80e6b7c..a8a98192a8c 100644 --- a/eglib/src/glib.h +++ b/eglib/src/glib.h @@ -469,8 +469,6 @@ typedef struct { gpointer g_queue_pop_head (GQueue *queue); void g_queue_push_head (GQueue *queue, gpointer data); -void g_queue_push_tail (GQueue *queue, - gpointer data); gboolean g_queue_is_empty (GQueue *queue); GQueue *g_queue_new (void); void g_queue_free (GQueue *queue); diff --git a/eglib/src/gqueue.c b/eglib/src/gqueue.c index 2eedbf6f9f3..fb7083fc6b9 100644 --- a/eglib/src/gqueue.c +++ b/eglib/src/gqueue.c @@ -3,7 +3,6 @@ * * Author: * Duncan Mak (duncan@novell.com) - * Gonzalo Paniagua Javier (gonzalo@novell.com) * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -24,7 +23,7 @@ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * Copyright (c) 2006-2009 Novell, Inc. + * (C) 2006 Novell, Inc. * */ @@ -34,23 +33,19 @@ gpointer g_queue_pop_head (GQueue *queue) { - gpointer result; - GList *old_head; + gpointer head = NULL; - if (!queue || queue->length == 0) - return NULL; + if (queue->length != 0){ + GList *old_head; - result = queue->head->data; - old_head = queue->head; - queue->head = old_head->next; - g_list_free_1 (old_head); + old_head = queue->head; + head = old_head->data; + queue->head = old_head->next; + queue->length--; + g_list_free_1 (old_head); + } - if (--queue->length) - queue->head->prev = NULL; - else - queue->tail = NULL; - - return result; + return head; } gboolean @@ -76,24 +71,13 @@ g_queue_push_head (GQueue *queue, gpointer head) queue->length ++; } -void -g_queue_push_tail (GQueue *queue, gpointer data) -{ - if (!queue) - return; - - queue->tail = g_list_append (queue->tail, data); - if (queue->head == NULL) - queue->head = queue->tail; - else - queue->tail = queue->tail->next; - queue->length++; -} - GQueue * g_queue_new (void) { - return g_new0 (GQueue, 1); + GQueue *queue = g_new0 (GQueue, 1); + queue->length = 0; + + return queue; } void diff --git a/eglib/test/queue.c b/eglib/test/queue.c index b12ddec13d4..2855e19d20f 100644 --- a/eglib/test/queue.c +++ b/eglib/test/queue.c @@ -15,66 +15,6 @@ test_queue_push () if (queue->length != 3) return FAILED ("push failed"); - if (NULL != queue->head->prev) - return FAILED ("HEAD: prev is wrong"); - if (strcmp ("baz", queue->head->data)) - return FAILED ("HEAD: First element is wrong"); - if (strcmp ("bar", queue->head->next->data)) - return FAILED ("HEAD: Second element is wrong"); - if (strcmp ("foo", queue->head->next->next->data)) - return FAILED ("HEAD: Third element is wrong"); - if (NULL != queue->head->next->next->next) - return FAILED ("HEAD: End is wrong"); - - if (NULL != queue->tail->next) - return FAILED ("TAIL: next is wrong"); - if (strcmp ("foo", queue->tail->data)) - return FAILED ("TAIL: Third element is wrong"); - if (strcmp ("bar", queue->tail->prev->data)) - return FAILED ("TAIL: Second element is wrong"); - if (strcmp ("baz", queue->tail->prev->prev->data)) - return FAILED ("TAIL: First element is wrong"); - if (NULL != queue->tail->prev->prev->prev) - return FAILED ("TAIL: End is wrong"); - - g_queue_free (queue); - return OK; -} - -RESULT -test_queue_push_tail () -{ - GQueue *queue = g_queue_new (); - - g_queue_push_tail (queue, "baz"); - g_queue_push_tail (queue, "bar"); - g_queue_push_tail (queue, "foo"); - - if (queue->length != 3) - return FAILED ("push failed"); - - if (NULL != queue->head->prev) - return FAILED ("HEAD: prev is wrong"); - if (strcmp ("baz", queue->head->data)) - return FAILED ("HEAD: First element is wrong"); - if (strcmp ("bar", queue->head->next->data)) - return FAILED ("HEAD: Second element is wrong"); - if (strcmp ("foo", queue->head->next->next->data)) - return FAILED ("HEAD: Third element is wrong"); - if (NULL != queue->head->next->next->next) - return FAILED ("HEAD: End is wrong"); - - if (NULL != queue->tail->next) - return FAILED ("TAIL: next is wrong"); - if (strcmp ("foo", queue->tail->data)) - return FAILED ("TAIL: Third element is wrong"); - if (strcmp ("bar", queue->tail->prev->data)) - return FAILED ("TAIL: Second element is wrong"); - if (strcmp ("baz", queue->tail->prev->prev->data)) - return FAILED ("TAIL: First element is wrong"); - if (NULL != queue->tail->prev->prev->prev) - return FAILED ("TAIL: End is wrong"); - g_queue_free (queue); return OK; } @@ -107,30 +47,6 @@ test_queue_pop () if (queue->length != 0) return FAILED ("expect 0 length ."); - g_queue_push_head (queue, "foo"); - g_queue_push_head (queue, "bar"); - g_queue_push_head (queue, "baz"); - - g_queue_pop_head (queue); - - if (NULL != queue->head->prev) - return FAILED ("HEAD: prev is wrong"); - if (strcmp ("bar", queue->head->data)) - return FAILED ("HEAD: Second element is wrong"); - if (strcmp ("foo", queue->head->next->data)) - return FAILED ("HEAD: Third element is wrong"); - if (NULL != queue->head->next->next) - return FAILED ("HEAD: End is wrong"); - - if (NULL != queue->tail->next) - return FAILED ("TAIL: next is wrong"); - if (strcmp ("foo", queue->tail->data)) - return FAILED ("TAIL: Second element is wrong"); - if (strcmp ("bar", queue->tail->prev->data)) - return FAILED ("TAIL: First element is wrong"); - if (NULL != queue->tail->prev->prev) - return FAILED ("TAIL: End is wrong"); - g_queue_free (queue); return OK; } @@ -173,7 +89,6 @@ test_queue_is_empty () static Test queue_tests [] = { { "push", test_queue_push}, - {"push_tail", test_queue_push_tail}, { "pop", test_queue_pop}, { "new", test_queue_new}, {"is_empty", test_queue_is_empty}, diff --git a/man/ChangeLog b/man/ChangeLog index 2368a6964e4..0b6942c557e 100644 --- a/man/ChangeLog +++ b/man/ChangeLog @@ -1,13 +1,3 @@ -2009-09-24 Ankit Jain <jankit@novell.com> - - * xbuild.1: Add info about env var XBUILD_EMIT_SOLUTION. - -2009-09-14 Massimiliano Mantione <massi@ximian.com> - - * mono.1: Updated the profiler documentation, removing the obsolete - signal related options and adding the description of the new socket - based command interface. - 2009-08-21 Ankit Jain <jankit@novell.com> * Makefile.am (man_MANS): Add xbuild.1 diff --git a/man/mdoc-export-html.1 b/man/mdoc-export-html.1 index 130381c1c7e..c7597fe8728 100644 --- a/man/mdoc-export-html.1 +++ b/man/mdoc-export-html.1 @@ -41,30 +41,6 @@ If not specified, uses the template produced by \fI\-\-dump\-template\fR. .Sp See the \fITEMPLATE FORMAT\fR section below for more information. .TP -\fB\-\-with\-profile\fR=\fIPROFILE\fR -Only process types and members within the .NET profile \fIPROFILE\fR. -May be specified multiple times. If not specified, all types and members, -regardless of version, are processed. -.Sp -Valid profiles are: -.nf - monotouch - net_1_0 - net_1_1 - net_2_0 - net_3_0 - net_3_5 - net_4_0 - silverlight -.fi -.TP -\fB\-\-with\-version\fR=\fIVERSION\fR -Only process types and members within the assembly version \fIVERSION\fR. -May be specified multiple times. If not specified, all types and members, -regardless of version, are processed. -.Sp -\fIVERSION\fR is an assembly version, e.g. 2.0.5.0. -.TP \fB\-h\fR, \fB\-?\fR, \fB\-\-help\fR Display a help message and exit. .SH TEMPLATE FORMAT diff --git a/man/mono.1 b/man/mono.1 index f002cc06ee6..74de0e86b4f 100644 --- a/man/mono.1 +++ b/man/mono.1 @@ -711,17 +711,12 @@ If the value of ARG is .B all, a heap snapshot is taken at each collection. .PP -If the value is an integer -.B n, -a snapshot will be taken at the first -.B n -collections (like setting -.B gcd=n -); -.PP -If no additional argument is given to the heap option, the only way to take -heap snapshots is to requeste them using the runtime socket based command -interface described below (see "Profiler activity control"). +If the value is signal name or a number (one of SIGUSR1, SIGUSR2 and +SIGPROF, remembering that SIGPROF is not compatible with the +statistical profiler), every time the application receives this signal +a garbage collection is forced and a snapshot is taken. The natural way +to take a heap snapshot is then using the kill command to deliver the +appropriate signal to the application. .PP Heap profiling also enables full allocation profiling (with call stacks), and each allocation can be related to its corresponding @@ -739,9 +734,18 @@ can be further customized with the following options: states the number of snapshots that must be dumped (since the application starts). Zero means no dumps at all, -1 means dump at all collections. .TP +\fIgc-commands=FILE\fR, \fIgc-c=FILE\fR or \fIgcc=FILE\fR +specify a "command file". The file must contain an integer value in ASCII +form, and the profiler will stat it at every collection. +If it has been modified it will interpret its contents as a \fIgcd=N\fR +option value, and dump the required number of snapshots from that moment +onwards. +If the file is present at application startup it takes precedence over an +eventual \fIgcd=N\fR option. +.TP These options exist because it can happen that the user wants to investigate -what happens during collections but without forcing a collection using the -command interface, because forcing a collection alters the program behavior. +what happens during collections but without forcing a collection using a +signal, because forcing a collection alters the program behavior. Of course it is possible to simply take a snapshot at every collection, but in some workloads this is could not be feasible (too much data). So we have this "garbage collection dumps" counter to control how many @@ -765,33 +769,17 @@ the output file name equals to "<program-name>-SUFFIX.mprof". .TP \fIstart-disabled\fR or \fIsd\fR: start with the profiler inactive. .TP +\fItoggle-signal=<SIGNAL>\fR or \fIts=<SIGNAL>\fR (where <SIGNAL> +is one of SIGUSR1, SIGUSR2 or SIGPROF): Choose a signal that will be used to +toggle the profiler activity on and off. This way you can decide to profile +only portions of the applicatopn lifetime (for instance, you can decide to +avoid profiling an initial setup phase using \fIsd\fR, and enable the +profiler later delivering the signal to the application). +.TP \fIforce-accurate-timer\fR (or \fIfac\fR): the profiler by default uses rtdsc to acquire timestamps for frequent events, but this can be imprecise; using this option you force the use of "gettimeofday" at every event, which is more accurate but much slower. -.TP -\fIcommand-port=port\fR or \fIcp=port\fR (where port is an integer between -1024 nd 65535): -Choose a TCP port where the profiler will listen for user commands. -The protocol is ASCII based and line oriented (one line per command), and the -profiler answers with one line containing either "OK" or "ERROR" to each -received command. -.PP -The user can telnet to this port and give commands manually, or a GUI can -use this facility to control the profiler at runtime. -.PP -The available commands are: -.TP -\fIenable\fR: Enables the profiler. -.TP -\fIdisable\fR: Disables the profiler. -.TP -\fIheap-snapshot\fR: Takes a heap snapshot now (forces a full garbage collection). -.TP -\fIheap-snapshot-counter=arg\fR: Set the counter of the next heap snapshots -that must be taken, where arg can be "all" (take a snapshot at every -collection), "none" (do not take snapshots), or an integer "n" (take a heap -snapshot for the next "n" collections). .ne .RE .PP diff --git a/man/xbuild.1 b/man/xbuild.1 index 3dba6c5667a..5dfca3f40e9 100644 --- a/man/xbuild.1 +++ b/man/xbuild.1 @@ -10,8 +10,8 @@ Environments like MonoDevelop and "Microsoft Visual Studio .NET" use msbuild project file format. xbuild takes the path of the project or solution file to build, as the main argument. -If no file is specified then it tries to build any solution file or project file in -the current directory, that has a *proj extension. +If no file is specified then it tries to build any project file in the current +directory, that has a *proj extension. .SH OPTIONS .TP .B \//target:T1[,TN] @@ -43,11 +43,6 @@ Show xbuild usage .TP .B \//version Display xbuild version -.SH ENVIRONMENT VARIABLES -.TP -.I "XBUILD_EMIT_SOLUTION" -If this variable is set, then the project file generated from a solution -file is emitted. .SH SEE ALSO .BR mono(1), mcs(1) .SH COPYRIGHT diff --git a/mono-core.spec.in b/mono-core.spec.in index 2198f138142..9d41378f4f6 100644 --- a/mono-core.spec.in +++ b/mono-core.spec.in @@ -616,7 +616,8 @@ Authors: %_prefix/lib/mono/2.0/System.ServiceModel.dll %_prefix/lib/mono/gac/System.ServiceModel.Web %_prefix/lib/mono/2.0/System.ServiceModel.Web.dll -%_prefix/lib/mono/2.0/svcutil.exe* +%_prefix/lib/mono/2.0/svcutil.exe +%_prefix/lib/mono/2.0/svcutil.exe.mdb %_libdir/pkgconfig/wcf.pc %package -n mono-winfxcore @@ -1005,7 +1006,6 @@ fi %_prefix/lib/mono/2.0/Microsoft.VisualBasic.targets %_prefix/lib/mono/2.0/MSBuild %_prefix/lib/mono/2.0/xbuild.rsp -%_prefix/lib/mono/xbuild # man pages %_mandir/man1/cert2spc.1%ext_man %_mandir/man1/mono-cil-strip.1%ext_man @@ -1212,7 +1212,7 @@ export CFLAGS=" $RPM_OPT_FLAGS -DKDE_ASSEMBLIES='\"/opt/kde3/%{_lib}\"' -fno-str %configure \ --with-jit=yes \ --with-ikvm=yes \ - --with-moonlight=no + --with-moonlight=yes make %install diff --git a/mono/cil/ChangeLog b/mono/cil/ChangeLog index 3fba50961f4..17123e0fb81 100644 --- a/mono/cil/ChangeLog +++ b/mono/cil/ChangeLog @@ -1,7 +1,3 @@ -2009-09-20 Zoltan Varga <vargaz@gmail.com> - - * cil-opcodes.xml: Add mono_dyn_call opcode. - 2009-07-30 Rodrigo Kumpera <rkumpera@novell.com> cil-opcodes.xml: Fix naming of stelem and ldelem to be diff --git a/mono/cil/cil-opcodes.xml b/mono/cil/cil-opcodes.xml index ba735a8b681..25c0e4a330e 100644 --- a/mono/cil/cil-opcodes.xml +++ b/mono/cil/cil-opcodes.xml @@ -307,5 +307,4 @@ <opcode name="mono_not_taken" input="Pop0" output="Push0" args="InlineNone" o1="0xF0" o2="0x0C" flow="next" /> <opcode name="mono_tls" input="Pop0" output="PushI" args="InlineI" o1="0xF0" o2="0x0D" flow="next" /> <opcode name="mono_icall_addr" input="Pop0" output="PushI" args="InlineI" o1="0xF0" o2="0x0E" flow="next" /> -<opcode name="mono_dyn_call" input="Pop0" output="PushI" args="InlineI" o1="0xF0" o2="0x0F" flow="next" /> </opdesc> diff --git a/mono/cil/opcode.def b/mono/cil/opcode.def index c23e6978a58..4eef979fa83 100644 --- a/mono/cil/opcode.def +++ b/mono/cil/opcode.def @@ -306,7 +306,6 @@ OPDEF(CEE_MONO_CLASSCONST, "mono_classconst", Pop0, PushI, InlineI, X, 2, 0xF0, OPDEF(CEE_MONO_NOT_TAKEN, "mono_not_taken", Pop0, Push0, InlineNone, X, 2, 0xF0, 0x0C, NEXT) OPDEF(CEE_MONO_TLS, "mono_tls", Pop0, PushI, InlineI, X, 2, 0xF0, 0x0D, NEXT) OPDEF(CEE_MONO_ICALL_ADDR, "mono_icall_addr", Pop0, PushI, InlineI, X, 2, 0xF0, 0x0E, NEXT) -OPDEF(CEE_MONO_DYN_CALL, "mono_dyn_call", Pop0, PushI, InlineI, X, 2, 0xF0, 0x0F, NEXT) #ifndef OPALIAS #define _MONO_CIL_OPALIAS_DEFINED_ #define OPALIAS(a,s,r) diff --git a/mono/dis/declsec.c b/mono/dis/declsec.c index 93300c2b991..ff5ca5a5941 100644 --- a/mono/dis/declsec.c +++ b/mono/dis/declsec.c @@ -37,10 +37,10 @@ declsec_20_get_classname (const char* p, const char **rptr) while ((*a++ != ',') && (apos++ < len)); if (apos - cpos > 1) { - g_string_append_printf (res, "[%.*s]%.*s", apos - cpos, c, cpos, p); + g_string_sprintfa (res, "[%.*s]%.*s", apos - cpos, c, cpos, p); } else { /* in-assembly type aren't fully qualified (no comma) */ - g_string_append_printf (res, "%.*s", cpos - 1, p); + g_string_sprintfa (res, "%.*s", cpos - 1, p); } p += len; @@ -80,34 +80,34 @@ declsec_20_write_value (GString *str, char type, const char *value) { switch (type) { case MONO_TYPE_U1: - g_string_append_printf (str, "%d", (unsigned char)*value); + g_string_sprintfa (str, "%d", (unsigned char)*value); return value + 1; case MONO_TYPE_I1: - g_string_append_printf (str, "%d", *value); + g_string_sprintfa (str, "%d", *value); return value + 1; case MONO_TYPE_BOOLEAN: - g_string_append_printf (str, "%s", *value ? "true" : "false"); + g_string_sprintfa (str, "%s", *value ? "true" : "false"); return value + 1; case MONO_TYPE_CHAR: - g_string_append_printf (str, "0x%04X", read16 (value)); + g_string_sprintfa (str, "0x%04X", read16 (value)); return value + 2; case MONO_TYPE_U2: - g_string_append_printf (str, "%d", read16 (value)); + g_string_sprintfa (str, "%d", read16 (value)); return value + 2; case MONO_TYPE_I2: - g_string_append_printf (str, "%d", (gint16)read16 (value)); + g_string_sprintfa (str, "%d", (gint16)read16 (value)); return value + 2; case MONO_TYPE_U4: - g_string_append_printf (str, "%d", read32 (value)); + g_string_sprintfa (str, "%d", read32 (value)); return value + 4; case MONO_TYPE_I4: - g_string_append_printf (str, "%d", (gint32)read32 (value)); + g_string_sprintfa (str, "%d", (gint32)read32 (value)); return value + 4; case MONO_TYPE_U8: - g_string_append_printf (str, "%lld", (long long)read64 (value)); + g_string_sprintfa (str, "%lld", (long long)read64 (value)); return value + 8; case MONO_TYPE_I8: - g_string_append_printf (str, "%lld", (long long)read64 (value)); + g_string_sprintfa (str, "%lld", (long long)read64 (value)); return value + 8; case MONO_TYPE_R4: { float val; @@ -115,13 +115,13 @@ declsec_20_write_value (GString *str, char type, const char *value) readr4 (value, &val); inf = isinf (val); if (inf == -1) - g_string_append_printf (str, "0xFF800000"); /* negative infinity */ + g_string_sprintfa (str, "0xFF800000"); /* negative infinity */ else if (inf == 1) - g_string_append_printf (str, "0x7F800000"); /* positive infinity */ + g_string_sprintfa (str, "0x7F800000"); /* positive infinity */ else if (isnan (val)) - g_string_append_printf (str, "0xFFC00000"); /* NaN */ + g_string_sprintfa (str, "0xFFC00000"); /* NaN */ else - g_string_append_printf (str, "%.8g", val); + g_string_sprintfa (str, "%.8g", val); return value + 4; } case MONO_TYPE_R8: { @@ -130,13 +130,13 @@ declsec_20_write_value (GString *str, char type, const char *value) readr8 (value, &val); inf = isinf (val); if (inf == -1) - g_string_append_printf (str, "0xFFF00000000000000"); /* negative infinity */ + g_string_sprintfa (str, "0xFFF00000000000000"); /* negative infinity */ else if (inf == 1) - g_string_append_printf (str, "0x7FFF0000000000000"); /* positive infinity */ + g_string_sprintfa (str, "0x7FFF0000000000000"); /* positive infinity */ else if (isnan (val)) - g_string_append_printf (str, "0xFFF80000000000000"); /* NaN */ + g_string_sprintfa (str, "0xFFF80000000000000"); /* NaN */ else - g_string_append_printf (str, "%.17g", val); + g_string_sprintfa (str, "%.17g", val); return value + 8; } case MONO_TYPE_STRING: @@ -145,7 +145,7 @@ declsec_20_write_value (GString *str, char type, const char *value) return value + 1; } else { int len = mono_metadata_decode_value (value, &value); - g_string_append_printf (str, "'%.*s'", len, value); + g_string_sprintfa (str, "'%.*s'", len, value); return value + len; } case MONO_TYPE_SYSTEM_TYPE: { @@ -178,7 +178,7 @@ dump_declsec_entry20 (MonoImage *m, const char* p, const char *indent) int len, j, pos = 0, param_len; char *param_start; char *s = declsec_20_get_classname (p, &p); - g_string_append_printf (res, "%s = {", s); + g_string_sprintfa (res, "%s = {", s); g_free (s); /* optional parameters length */ @@ -209,13 +209,13 @@ dump_declsec_entry20 (MonoImage *m, const char* p, const char *indent) if (type == MONO_DECLSEC_ENUM) { s = declsec_20_get_classname (p, &p); len = mono_metadata_decode_value (p, &p); - g_string_append_printf (res, "enum %s '%.*s' = ", s, len, p); + g_string_sprintfa (res, "enum %s '%.*s' = ", s, len, p); g_free (s); p += len; /* TODO: we must detect the size of the enum element (from the type ? length ?) * note: ildasm v2 has some problem decoding them too and doesn't * seems to rely on the type (as the other assembly isn't loaded) */ - g_string_append_printf (res, "int32(%d)", read32 (p)); + g_string_sprintfa (res, "int32(%d)", read32 (p)); p += 4; } else { int arraytype = 0; @@ -226,7 +226,7 @@ dump_declsec_entry20 (MonoImage *m, const char* p, const char *indent) declsec_20_write_type (res, type); len = mono_metadata_decode_value (p, &p); - g_string_append_printf (res, " '%.*s' = ", len, p); + g_string_sprintfa (res, " '%.*s' = ", len, p); p += len; if (type == MONO_TYPE_SZARRAY) { @@ -234,7 +234,7 @@ dump_declsec_entry20 (MonoImage *m, const char* p, const char *indent) declsec_20_write_type (res, type); elem = read32 (p); p += 4; - g_string_append_printf (res, "[%d]", elem); + g_string_sprintfa (res, "[%d]", elem); } else { declsec_20_write_type (res, type); elem = 1; @@ -250,7 +250,7 @@ dump_declsec_entry20 (MonoImage *m, const char* p, const char *indent) } if (j < pos - 1) - g_string_append_printf (res, ")\n%s", indent); + g_string_sprintfa (res, ")\n%s", indent); else g_string_append (res, ")"); } @@ -258,7 +258,7 @@ dump_declsec_entry20 (MonoImage *m, const char* p, const char *indent) } if (i < num - 1) - g_string_append_printf (res, "},\n%s", indent); + g_string_sprintfa (res, "},\n%s", indent); else g_string_append (res, "}"); diff --git a/mono/dis/dump.c b/mono/dis/dump.c index 88ec39a4118..1171949a3c9 100644 --- a/mono/dis/dump.c +++ b/mono/dis/dump.c @@ -820,43 +820,43 @@ custom_attr_params (MonoImage *m, MonoMethodSignature* sig, const char* value) handle_enum: switch (type) { case MONO_TYPE_U1: - g_string_append_printf (res, "%d", (unsigned int)*p); + g_string_sprintfa (res, "%d", (unsigned int)*p); ++p; break; case MONO_TYPE_I1: - g_string_append_printf (res, "%d", *p); + g_string_sprintfa (res, "%d", *p); ++p; break; case MONO_TYPE_BOOLEAN: - g_string_append_printf (res, "%s", *p?"true":"false"); + g_string_sprintfa (res, "%s", *p?"true":"false"); ++p; break; case MONO_TYPE_CHAR: - g_string_append_printf (res, "'%c'", read16 (p)); + g_string_sprintfa (res, "'%c'", read16 (p)); p += 2; break; case MONO_TYPE_U2: - g_string_append_printf (res, "%d", read16 (p)); + g_string_sprintfa (res, "%d", read16 (p)); p += 2; break; case MONO_TYPE_I2: - g_string_append_printf (res, "%d", (gint16)read16 (p)); + g_string_sprintfa (res, "%d", (gint16)read16 (p)); p += 2; break; case MONO_TYPE_U4: - g_string_append_printf (res, "%d", read32 (p)); + g_string_sprintfa (res, "%d", read32 (p)); p += 4; break; case MONO_TYPE_I4: - g_string_append_printf (res, "%d", (gint32)read32 (p)); + g_string_sprintfa (res, "%d", (gint32)read32 (p)); p += 4; break; case MONO_TYPE_U8: - g_string_append_printf (res, "%lld", (long long)read64 (p)); + g_string_sprintfa (res, "%lld", (long long)read64 (p)); p += 8; break; case MONO_TYPE_I8: - g_string_append_printf (res, "%lld", (long long)read64 (p)); + g_string_sprintfa (res, "%lld", (long long)read64 (p)); p += 8; break; case MONO_TYPE_R4: { @@ -865,13 +865,13 @@ handle_enum: readr4 (p, &val); inf = isinf (val); if (inf == -1) - g_string_append_printf (res, "(00 00 80 ff)"); /* negative infinity */ + g_string_sprintfa (res, "(00 00 80 ff)"); /* negative infinity */ else if (inf == 1) - g_string_append_printf (res, "(00 00 80 7f)"); /* positive infinity */ + g_string_sprintfa (res, "(00 00 80 7f)"); /* positive infinity */ else if (isnan (val)) - g_string_append_printf (res, "(00 00 c0 ff)"); /* NaN */ + g_string_sprintfa (res, "(00 00 c0 ff)"); /* NaN */ else - g_string_append_printf (res, "%g", val); + g_string_sprintfa (res, "%g", val); p += 4; break; } @@ -882,13 +882,13 @@ handle_enum: readr8 (p, &val); inf = isinf (val); if (inf == -1) - g_string_append_printf (res, "(00 00 00 00 00 00 f0 ff)"); /* negative infinity */ + g_string_sprintfa (res, "(00 00 00 00 00 00 f0 ff)"); /* negative infinity */ else if (inf == 1) - g_string_append_printf (res, "(00 00 00 00 00 00 f0 7f)"); /* positive infinity */ + g_string_sprintfa (res, "(00 00 00 00 00 00 f0 7f)"); /* positive infinity */ else if (isnan (val)) - g_string_append_printf (res, "(00 00 00 00 00 00 f8 ff)"); /* NaN */ + g_string_sprintfa (res, "(00 00 00 00 00 00 f8 ff)"); /* NaN */ else - g_string_append_printf (res, "%g", val); + g_string_sprintfa (res, "%g", val); p += 8; break; } @@ -920,10 +920,10 @@ handle_enum: } slen = read16 (p); if (slen) { - g_string_append_printf (res, " %d named args: (", slen); + g_string_sprintfa (res, " %d named args: (", slen); slen = len - (p - value) + 1; for (i = 0; i < slen; ++i) { - g_string_append_printf (res, " %02X", (p [i] & 0xff)); + g_string_sprintfa (res, " %02X", (p [i] & 0xff)); } g_string_append_c (res, ')'); } diff --git a/mono/dis/get.c b/mono/dis/get.c index 47da3ecda36..0651772fc34 100644 --- a/mono/dis/get.c +++ b/mono/dis/get.c @@ -125,12 +125,12 @@ stringify_array (guint32 rank, guint32 num_sizes, guint32 num_lo_bounds, gint32 if (i) g_string_append_c (res, ','); if (i < num_lo_bounds) - g_string_append_printf (res, "%d...", lo_bounds [i]); + g_string_sprintfa (res, "%d...", lo_bounds [i]); if (i < num_sizes) { if (i < num_lo_bounds) - g_string_append_printf (res, "%d", lo_bounds [i] + sizes [i] - 1); + g_string_sprintfa (res, "%d", lo_bounds [i] + sizes [i] - 1); else - g_string_append_printf (res, "%d", sizes [i]); + g_string_sprintfa (res, "%d", sizes [i]); } } @@ -511,8 +511,8 @@ dis_stringify_modifiers (MonoImage *m, int n, MonoCustomMod *mod) for (i = 0; i < n; ++i) { char *tok = dis_stringify_token (m, mod[i].token); if (i > 0) - g_string_append_printf (s, " "); - g_string_append_printf (s, " %s (%s)", mod[i].required ? "modreq": "modopt", tok); + g_string_sprintfa (s, " "); + g_string_sprintfa (s, " %s (%s)", mod[i].required ? "modreq": "modopt", tok); g_free (tok); } g_string_append_c (s, ' '); @@ -968,11 +968,11 @@ dis_stringify_method_signature_full (MonoImage *m, MonoMethodSignature *method, if (method->hasthis) g_string_append (result_ret, "instance "); g_string_append (result_ret, map (method->call_convention, call_conv_type_map)); - g_string_append_printf (result_ret, " %s%s ", retval, ret_marshal_info ? ret_marshal_info :""); + g_string_sprintfa (result_ret, " %s%s ", retval, ret_marshal_info ? ret_marshal_info :""); g_free (ret_marshal_info); if (type) { char *estype = get_escaped_name (type); - g_string_append_printf (result_ret, "%s::", estype); + g_string_sprintfa (result_ret, "%s::", estype); g_free (estype); g_free (type); } @@ -1013,7 +1013,7 @@ dis_stringify_function_ptr (MonoImage *m, MonoMethodSignature *method) g_string_append (result, map (method->call_convention, call_conv_type_map)); retval = dis_stringify_param (m, method->ret); - g_string_append_printf (result, " %s ", retval); + g_string_sprintfa (result, " %s ", retval); g_free (retval); g_string_append (result, " *("); @@ -2527,7 +2527,7 @@ dis_get_custom_attrs (MonoImage *m, guint32 token) len = mono_metadata_decode_value (val, &val); attr = g_string_new (".custom "); dump = data_dump (val, len, "\t\t"); - g_string_append_printf (attr, "%s = %s", method, dump); + g_string_sprintfa (attr, "%s = %s", method, dump); g_free (dump); list = g_list_append (list, attr->str); g_string_free (attr, FALSE); diff --git a/mono/dis/main.c b/mono/dis/main.c index c45a40774f3..64af63db2dd 100644 --- a/mono/dis/main.c +++ b/mono/dis/main.c @@ -1016,7 +1016,7 @@ dis_property_signature (MonoImage *m, guint32 prop_idx, MonoGenericContainer *co if (prop_flags & 0x0400) g_string_append (res, "rtspecialname "); qk = get_escaped_name (name); - g_string_append_printf (res, "%s %s (", blurb, qk); + g_string_sprintfa (res, "%s %s (", blurb, qk); g_free (qk); g_free (blurb); for (i = 0; i < pcount; i++) { @@ -1068,7 +1068,7 @@ dis_event_signature (MonoImage *m, guint32 event_idx, MonoGenericContainer *cont g_string_append (res, "specialname "); if (event_flags & 0x0400) g_string_append (res, "rtspecialname "); - g_string_append_printf (res, "%s %s", type, esname); + g_string_sprintfa (res, "%s %s", type, esname); g_free (type); g_free (esname); diff --git a/mono/dis/util.c b/mono/dis/util.c index e5e467d09ff..9357ef994c2 100644 --- a/mono/dis/util.c +++ b/mono/dis/util.c @@ -91,32 +91,32 @@ data_dump (const char *data, int len, const char* prefix) { str = g_string_new (" ("); for (i = 0; i + 15 < len; i += 16) { if (i == 0) - g_string_append_printf (str, "\n"); - g_string_append_printf (str, "%s", prefix); + g_string_sprintfa (str, "\n"); + g_string_sprintfa (str, "%s", prefix); for (j = 0; j < 16; ++j) - g_string_append_printf (str, "%02X ", (unsigned char) (data [i + j])); - g_string_append_printf (str, i == len - 16? ") // ": " // "); + g_string_sprintfa (str, "%02X ", (unsigned char) (data [i + j])); + g_string_sprintfa (str, i == len - 16? ") // ": " // "); for (j = 0; j < 16; ++j) - g_string_append_printf (str, "%c", data [i + j] >= 32 && data [i + j] <= 126? data [i + j]: '.'); - g_string_append_printf (str, "\n"); + g_string_sprintfa (str, "%c", data [i + j] >= 32 && data [i + j] <= 126? data [i + j]: '.'); + g_string_sprintfa (str, "\n"); } if (i == len) return g_string_free (str, FALSE); if (len > 16) - g_string_append_printf (str, "%s", prefix); + g_string_sprintfa (str, "%s", prefix); j = i; for (; i < len; ++i) - g_string_append_printf (str, "%02X ", (unsigned char) (data [i])); + g_string_sprintfa (str, "%02X ", (unsigned char) (data [i])); if (len > 16) { /* align */ int count = 16 - (len % 16); for (i = 0; i < count; ++i) - g_string_append_printf (str, " "); + g_string_sprintfa (str, " "); } - g_string_append_printf (str, ") // "); + g_string_sprintfa (str, ") // "); for (i = j; i < len; ++i) - g_string_append_printf (str, "%c", data [i] >= 32 && data [i] <= 126? data [i]: '.'); - g_string_append_printf (str, "\n"); + g_string_sprintfa (str, "%c", data [i] >= 32 && data [i] <= 126? data [i]: '.'); + g_string_sprintfa (str, "\n"); return g_string_free (str, FALSE); } diff --git a/mono/interpreter/interp.c b/mono/interpreter/interp.c index fb437d0ccb9..2cc5b159860 100644 --- a/mono/interpreter/interp.c +++ b/mono/interpreter/interp.c @@ -833,7 +833,7 @@ dump_stack (stackval *stack, stackval *sp) return g_string_free (str, FALSE); while (s < sp) { - g_string_append_printf (str, "[%lld/0x%0llx] ", s->data.l, s->data.l); + g_string_sprintfa (str, "[%lld/0x%0llx] ", s->data.l, s->data.l); ++s; } return g_string_free (str, FALSE); @@ -851,7 +851,7 @@ dump_stackval (GString *str, stackval *s, MonoType *type) case MONO_TYPE_U4: case MONO_TYPE_CHAR: case MONO_TYPE_BOOLEAN: - g_string_append_printf (str, "[%d] ", s->data.i); + g_string_sprintfa (str, "[%d] ", s->data.i); break; case MONO_TYPE_STRING: case MONO_TYPE_SZARRAY: @@ -861,22 +861,22 @@ dump_stackval (GString *str, stackval *s, MonoType *type) case MONO_TYPE_PTR: case MONO_TYPE_I: case MONO_TYPE_U: - g_string_append_printf (str, "[%p] ", s->data.p); + g_string_sprintfa (str, "[%p] ", s->data.p); break; case MONO_TYPE_VALUETYPE: if (type->data.klass->enumtype) - g_string_append_printf (str, "[%d] ", s->data.i); + g_string_sprintfa (str, "[%d] ", s->data.i); else - g_string_append_printf (str, "[vt:%p] ", s->data.p); + g_string_sprintfa (str, "[vt:%p] ", s->data.p); break; case MONO_TYPE_R4: case MONO_TYPE_R8: - g_string_append_printf (str, "[%g] ", s->data.f); + g_string_sprintfa (str, "[%g] ", s->data.f); break; case MONO_TYPE_I8: case MONO_TYPE_U8: default: - g_string_append_printf (str, "[%lld/0x%0llx] ", s->data.l, s->data.l); + g_string_sprintfa (str, "[%lld/0x%0llx] ", s->data.l, s->data.l); break; } } @@ -892,7 +892,7 @@ dump_args (MonoInvocation *inv) return g_string_free (str, FALSE); if (signature->hasthis) - g_string_append_printf (str, "%p ", inv->obj); + g_string_sprintfa (str, "%p ", inv->obj); for (i = 0; i < signature->param_count; ++i) dump_stackval (str, inv->stack_args + i, signature->params [i]); @@ -947,10 +947,10 @@ dump_frame (MonoInvocation *inv) args = dump_args (inv); name = mono_method_full_name (method, TRUE); if (source) - g_string_append_printf (str, "#%d: 0x%05x %-10s in %s (%s) at %s\n", i, codep, opname, + g_string_sprintfa (str, "#%d: 0x%05x %-10s in %s (%s) at %s\n", i, codep, opname, name, args, source); else - g_string_append_printf (str, "#%d: 0x%05x %-10s in %s (%s)\n", i, codep, opname, + g_string_sprintfa (str, "#%d: 0x%05x %-10s in %s (%s)\n", i, codep, opname, name, args); g_free (name); g_free (args); diff --git a/mono/io-layer/ChangeLog b/mono/io-layer/ChangeLog index d814b6faea1..85b66f58ab2 100644 --- a/mono/io-layer/ChangeLog +++ b/mono/io-layer/ChangeLog @@ -1,21 +1,3 @@ -2009-10-04 Zoltan Varga <vargaz@gmail.com> - - * processes.c: Implement get_process_name_from_proc () on solaris. - -2009-09-24 Zoltan Varga <vargaz@gmail.com> - - * processes.c (load_modules): Applied patch from Thomas Philpot - (tom.philpot@logos.com). Fixes #533893. - -2009-09-15 Jeffrey Stedfast <fejj@novell.com> - - * io.c (CreateFile): In the directory fallback case, use - _wapi_open() again so that IOMAP magic happens. - (CopyFile): Need to consistently use _wapi_open() here too. - (ReplaceFile): Use _wapi_open() here too and get rid of the - fallback code that tried re-opening the file w/o O_TRUNC since - there's no reason to do that. - 2009-09-05 Zoltan Varga <vargaz@gmail.com> * handles.c (_wapi_handle_real_new): Call _wapi_process_reap () when running diff --git a/mono/io-layer/daemon-messages.c b/mono/io-layer/daemon-messages.c index 812d435de5b..fdafc17c0b0 100644 --- a/mono/io-layer/daemon-messages.c +++ b/mono/io-layer/daemon-messages.c @@ -94,10 +94,10 @@ static void _wapi_daemon_request_response_internal (int fd, if(ret!=sizeof(WapiHandleRequest)) { if(errno==EPIPE) { - g_critical ("%s: The handle daemon vanished!", __func__); + g_critical (G_GNUC_PRETTY_FUNCTION ": The handle daemon vanished!"); exit (-1); } else { - g_warning ("%s: Send error: %s", __func__, + g_warning (G_GNUC_PRETTY_FUNCTION ": Send error: %s", strerror (errno)); g_assert_not_reached (); } @@ -118,10 +118,11 @@ static void _wapi_daemon_request_response_internal (int fd, if(ret==-1) { if(errno==EPIPE) { - g_critical ("%s: The handle daemon vanished!", __func__); + g_critical (G_GNUC_PRETTY_FUNCTION ": The handle daemon vanished!"); exit (-1); } else { - g_warning ("%s: Send error: %s", __func__, strerror (errno)); + g_warning (G_GNUC_PRETTY_FUNCTION ": Send error: %s", + strerror (errno)); g_assert_not_reached (); } } @@ -226,32 +227,34 @@ int _wapi_daemon_request (int fd, WapiHandleRequest *req, int *fds, /* Make sure we dont do anything with this response */ req->type=WapiHandleRequestType_Error; - g_warning ("%s: Recv error: %s", __func__, strerror (errno)); + g_warning (G_GNUC_PRETTY_FUNCTION ": Recv error: %s", + strerror (errno)); /* The next loop around poll() should tidy up */ } #ifdef DEBUG if(msg.msg_flags & MSG_OOB) { - g_message ("%s: OOB data received", __func__); + g_message (G_GNUC_PRETTY_FUNCTION ": OOB data received"); } if(msg.msg_flags & MSG_CTRUNC) { - g_message ("%s: ancillary data was truncated", __func__); + g_message (G_GNUC_PRETTY_FUNCTION ": ancillary data was truncated"); } - g_message ("%s: msg.msg_controllen=%d", __func__, msg.msg_controllen); + g_message (G_GNUC_PRETTY_FUNCTION ": msg.msg_controllen=%d", + msg.msg_controllen); #endif cmsg=CMSG_FIRSTHDR (&msg); if(cmsg!=NULL && cmsg->cmsg_level==SOL_SOCKET && cmsg->cmsg_type==SCM_RIGHTS) { - LOGDEBUG ("%s: cmsg->cmsg_len=%d", __func__, cmsg->cmsg_len); - LOGDEBUG ("%s: cmsg->level=%d cmsg->type=%d", __func__, cmsg->cmsg_level, cmsg->cmsg_type); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": cmsg->cmsg_len=%d", cmsg->cmsg_len); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": cmsg->level=%d cmsg->type=%d", cmsg->cmsg_level, cmsg->cmsg_type); memcpy (fds, (int *)CMSG_DATA (cmsg), sizeof(int)*3); *has_fds=TRUE; - LOGDEBUG ("%s: fd[0]=%d, fd[1]=%d, fd[2]=%d", __func__, fds[0], fds[1], fds[2]); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": fd[0]=%d, fd[1]=%d, fd[2]=%d", fds[0], fds[1], fds[2]); } else { - LOGDEBUG ("%s: no ancillary data", __func__); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": no ancillary data"); *has_fds=FALSE; } @@ -274,7 +277,8 @@ int _wapi_daemon_response (int fd, WapiHandleResponse *resp) #ifdef DEBUG if(ret==-1 || ret != sizeof(WapiHandleResponse)) { - g_warning ("%s: Send error: %s", __func__, strerror (errno)); + g_warning (G_GNUC_PRETTY_FUNCTION ": Send error: %s", + strerror (errno)); /* The next loop around poll() should tidy up */ } #endif diff --git a/mono/io-layer/daemon.c b/mono/io-layer/daemon.c index b5ff32afc11..bf4d54fea61 100644 --- a/mono/io-layer/daemon.c +++ b/mono/io-layer/daemon.c @@ -110,10 +110,10 @@ static void maybe_exit (void) { guint32 i; - LOGDEBUG ("%s: Seeing if we should exit", __func__); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Seeing if we should exit"); if(nfds>1) { - LOGDEBUG ("%s: Still got clients", __func__); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Still got clients"); return; } @@ -124,7 +124,7 @@ static void maybe_exit (void) i<_wapi_shared_data[0]->num_segments * _WAPI_HANDLES_PER_SEGMENT; i++) { if(daemon_channel_data->open_handles[i]>0) { - LOGDEBUG ("%s: Still got handle references", __func__); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Still got handle references"); _wapi_shared_data[0]->daemon_running=DAEMON_RUNNING; return; } @@ -150,11 +150,11 @@ static void maybe_exit (void) fds[0].events=POLLIN; fds[0].revents=0; - LOGDEBUG ("%s: Last connect check", __func__); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Last connect check"); if(poll (fds, 1, 0)>0) { /* Someone did connect, so carry on running */ - LOGDEBUG ("%s: Someone connected", __func__); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Someone connected"); _wapi_shared_data[0]->daemon_running=DAEMON_RUNNING; return; @@ -162,7 +162,7 @@ static void maybe_exit (void) } #endif - LOGDEBUG ("%s: Byebye", __func__); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Byebye"); cleanup (); exit (0); @@ -176,7 +176,7 @@ static void maybe_exit (void) */ static void signal_handler (int signo) { - LOGDEBUG ("%s: daemon received signal %d", __func__, signo); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": daemon received signal %d", signo); cleanup (); exit (-1); @@ -286,7 +286,7 @@ static void ref_handle (ChannelData *channel_data, guint32 handle) _wapi_shared_data[segment]->handles[idx].ref++; channel_data->open_handles[handle]++; - LOGDEBUG ("%s: handle 0x%x ref now %d (%d this process)", __func__, handle, + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": handle 0x%x ref now %d (%d this process)", handle, _wapi_shared_data[segment]->handles[idx].ref, channel_data->open_handles[handle]); } @@ -310,7 +310,9 @@ static gboolean unref_handle (ChannelData *channel_data, guint32 handle) } if (channel_data->open_handles[handle] == 0) { - g_warning("%s: unref on %d called when ref was already 0", __func__, handle); + g_warning(G_GNUC_PRETTY_FUNCTION + ": unref on %d called when ref was already 0", + handle); return TRUE; } @@ -319,7 +321,8 @@ static gboolean unref_handle (ChannelData *channel_data, guint32 handle) _wapi_shared_data[segment]->handles[idx].ref--; channel_data->open_handles[handle]--; - LOGDEBUG ("%s: handle 0x%x ref now %d (%d this process)", __func__, handle, + LOGDEBUG (G_GNUC_PRETTY_FUNCTION + ": handle 0x%x ref now %d (%d this process)", handle, _wapi_shared_data[segment]->handles[idx].ref, channel_data->open_handles[handle]); @@ -332,10 +335,12 @@ static gboolean unref_handle (ChannelData *channel_data, guint32 handle) destroy=TRUE; if (channel_data->open_handles[handle]!=0) { - g_warning ("%s: per-process open_handles mismatch, set to %d, should be 0",__func__, channel_data->open_handles[handle]); + g_warning (G_GNUC_PRETTY_FUNCTION ": per-process open_handles mismatch, set to %d, should be 0", + channel_data->open_handles[handle]); } - LOGDEBUG ("%s: Destroying handle 0x%x", __func__, handle); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Destroying handle 0x%x", + handle); /* if this was a file handle, save the device and * inode numbers so we can scan the share info data @@ -352,7 +357,9 @@ static gboolean unref_handle (ChannelData *channel_data, guint32 handle) (gpointer *)&file_handle, NULL); if (ok == FALSE) { - g_warning ("%s: error looking up file handle %x", __func__, handle); + g_warning (G_GNUC_PRETTY_FUNCTION + ": error looking up file handle %x", + handle); } else { device = file_handle->device; inode = file_handle->inode; @@ -459,15 +466,15 @@ static void rem_fd(GIOChannel *channel, ChannelData *channel_data) if(fd == main_sock) { /* We shouldn't be deleting the daemon's fd */ - g_warning ("%s: Deleting daemon fd!", __func__); + g_warning (G_GNUC_PRETTY_FUNCTION ": Deleting daemon fd!"); cleanup (); exit (-1); } - LOGDEBUG ("%s: Removing client fd %d", __func__, fd); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Removing client fd %d", fd); if (channel_data->io_source == 0) { - LOGDEBUG ("%s: channel already closed for fd %d", __func__, fd); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": channel already closed for fd %d", fd); return; } @@ -482,7 +489,7 @@ static void rem_fd(GIOChannel *channel, ChannelData *channel_data) handle_count=channel_data->open_handles[i]; for(j=0; j<handle_count; j++) { - LOGDEBUG ("%s: closing handle 0x%x for client at index %d", __func__, i, g_io_channel_unix_get_fd (channel)); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": closing handle 0x%x for client at index %d", i, g_io_channel_unix_get_fd (channel)); /* Ignore the hint to the client to destroy * the handle private data */ @@ -557,13 +564,15 @@ static gboolean share_compare (gpointer handle, gpointer user_data) ok = _wapi_lookup_handle (handle, WAPI_HANDLE_FILE, (gpointer *)&file_handle, NULL); if (ok == FALSE) { - g_warning ("%s: error looking up file handle %p", __func__, handle); + g_warning (G_GNUC_PRETTY_FUNCTION + ": error looking up file handle %p", handle); return(FALSE); } if (file_handle->device == sharekey->device && file_handle->inode == sharekey->inode) { - LOGDEBUG ("%s: found one, handle %p", __func__, handle); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": found one, handle %p", + handle); return(TRUE); } else { return(FALSE); @@ -575,7 +584,7 @@ static void check_sharing (dev_t device, ino_t inode) ShareKey sharekey; gpointer file_handle; - LOGDEBUG ("%s: Checking if anything has (dev 0x%llx, inode %lld) still open", __func__, device, inode); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Checking if anything has (dev 0x%llx, inode %lld) still open", device, inode); sharekey.device = device; sharekey.inode = inode; @@ -587,7 +596,7 @@ static void check_sharing (dev_t device, ino_t inode) /* Delete this share info, as the last handle to it * has been closed */ - LOGDEBUG ("%s: Deleting share data for (dev 0x%llx inode %lld)", __func__, device, inode); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Deleting share data for (dev 0x%llx inode %lld)", device, inode); g_hash_table_remove (file_share_hash, &sharekey); } @@ -603,7 +612,8 @@ static gboolean process_compare (gpointer handle, gpointer user_data) ok=_wapi_lookup_handle (handle, WAPI_HANDLE_PROCESS, (gpointer *)&process_handle, NULL); if(ok==FALSE) { - g_warning ("%s: error looking up process handle %p", __func__, handle); + g_warning (G_GNUC_PRETTY_FUNCTION + ": error looking up process handle %p", handle); return(FALSE); } @@ -629,7 +639,8 @@ static gboolean process_thread_compare (gpointer handle, gpointer user_data) ok=_wapi_lookup_handle (handle, WAPI_HANDLE_THREAD, (gpointer *)&thread_handle, NULL); if(ok==FALSE) { - g_warning ("%s: error looking up thread handle %p", __func__, handle); + g_warning (G_GNUC_PRETTY_FUNCTION + ": error looking up thread handle %p", handle); return(FALSE); } @@ -638,7 +649,7 @@ static gboolean process_thread_compare (gpointer handle, gpointer user_data) * _wapi_handle_set_signal_state() unless we have * process-shared pthread support. */ - LOGDEBUG ("%s: Set thread handle %p signalled, because its process died", __func__, handle); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Set thread handle %p signalled, because its process died", handle); thread_handle->exitstatus=0; @@ -685,7 +696,7 @@ static void process_post_mortem (pid_t pid, int status) * This may happen if we use Process.EnableRaisingEvents + * process.Exited event and the parent has finished. */ - LOGDEBUG ("%s: Couldn't find handle for process %d!", __func__, pid); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Couldn't find handle for process %d!", pid); } else { /* Signal the handle. Don't use * _wapi_handle_set_signal_state() unless we have @@ -693,7 +704,8 @@ static void process_post_mortem (pid_t pid, int status) */ struct timeval tv; - LOGDEBUG ("%s: Set process %d exitstatus to %d", __func__, pid, + LOGDEBUG (G_GNUC_PRETTY_FUNCTION + ": Set process %d exitstatus to %d", pid, WEXITSTATUS (status)); /* If the child terminated due to the receipt of a signal, @@ -746,7 +758,7 @@ static void process_died (void) check_processes=FALSE; - LOGDEBUG ("%s: Reaping processes", __func__); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Reaping processes"); while(TRUE) { pid=waitpid (-1, &status, WNOHANG); @@ -759,7 +771,7 @@ static void process_died (void) return; } else { /* pid contains the ID of a dead process */ - LOGDEBUG ( "%s: process %d reaped", __func__, pid); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": process %d reaped", pid); process_post_mortem (pid, status); } } @@ -842,7 +854,7 @@ static void process_new (GIOChannel *channel, ChannelData *channel_data, ref_handle (channel_data, handle); - LOGDEBUG ("%s: returning new handle 0x%x", __func__, handle); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": returning new handle 0x%x", handle); resp.type=WapiHandleResponseType_New; resp.u.new.type=type; @@ -873,7 +885,7 @@ static void process_open (GIOChannel *channel, ChannelData *channel_data, if(shared->type!=WAPI_HANDLE_UNUSED && handle!=0) { ref_handle (channel_data, handle); - LOGDEBUG ("%s: returning new handle 0x%x", __func__, handle); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": returning new handle 0x%x", handle); resp.type=WapiHandleResponseType_Open; resp.u.new.type=shared->type; @@ -907,7 +919,7 @@ static void process_close (GIOChannel *channel, ChannelData *channel_data, resp.type=WapiHandleResponseType_Close; resp.u.close.destroy=unref_handle (channel_data, handle); - LOGDEBUG ("%s: unreffing handle 0x%x", __func__, handle); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": unreffing handle 0x%x", handle); send_reply (channel, &resp); } @@ -926,7 +938,8 @@ static void process_scratch (GIOChannel *channel, guint32 length) resp.type=WapiHandleResponseType_Scratch; resp.u.scratch.idx=_wapi_handle_scratch_store_internal (length, &resp.u.scratch.remap); - LOGDEBUG ("%s: allocating scratch index 0x%x", __func__, resp.u.scratch.idx); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": allocating scratch index 0x%x", + resp.u.scratch.idx); send_reply (channel, &resp); } @@ -945,7 +958,8 @@ static void process_scratch_free (GIOChannel *channel, guint32 scratch_idx) resp.type=WapiHandleResponseType_ScratchFree; _wapi_handle_scratch_delete_internal (scratch_idx); - LOGDEBUG ("%s: deleting scratch index 0x%x", __func__, scratch_idx); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": deleting scratch index 0x%x", + scratch_idx); send_reply (channel, &resp); } @@ -965,11 +979,12 @@ process_process_kill (GIOChannel *channel, resp.type = WapiHandleResponseType_ProcessKill; - LOGDEBUG ("%s: kill (%d, %d)", __func__, process_kill.pid, process_kill.signo); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": kill (%d, %d)", + process_kill.pid, process_kill.signo); if (kill (process_kill.pid, process_kill.signo) == -1) { resp.u.process_kill.err = errno; - LOGDEBUG ("%s: kill (%d, %d) failed: %d", __func__, process_kill.pid, process_kill.signo, resp.u.process_kill.err); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": kill (%d, %d) failed: %d", process_kill.pid, process_kill.signo, resp.u.process_kill.err); } send_reply (channel, &resp); @@ -1053,7 +1068,7 @@ static void process_process_fork (GIOChannel *channel, ChannelData *channel_data */ process_handle_data->exec_errno=gerr->code; } else { - LOGDEBUG ("%s: forking", __func__); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": forking"); /* Fork, exec cmd with args and optional env, * and return the handles with pid and blank @@ -1105,7 +1120,9 @@ static void process_process_fork (GIOChannel *channel, ChannelData *channel_data } #ifdef DEBUG - LOGDEBUG ("%s: exec()ing [%s] in dir [%s]", __func__, cmd, dir); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION + ": exec()ing [%s] in dir [%s]", + cmd, dir); { i=0; while(argv[i]!=NULL) { @@ -1208,7 +1225,7 @@ static void process_set_share (GIOChannel *channel, ChannelData *channel_data, resp.type = WapiHandleResponseType_SetShare; - LOGDEBUG ("%s: Setting share for file (dev:0x%llx, ino:%lld) mode 0x%x access 0x%x", __func__, set_share.device, set_share.inode, set_share.sharemode, set_share.access); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Setting share for file (dev:0x%llx, ino:%lld) mode 0x%x access 0x%x", set_share.device, set_share.inode, set_share.sharemode, set_share.access); sharemode_set (set_share.device, set_share.inode, set_share.sharemode, set_share.access); @@ -1233,14 +1250,18 @@ static void process_get_or_set_share (GIOChannel *channel, resp.type = WapiHandleResponseType_GetOrSetShare; - LOGDEBUG ("%s: Getting share status for file (dev:0x%llx, ino:%lld)", __func__, get_share.device, get_share.inode); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION + ": Getting share status for file (dev:0x%llx, ino:%lld)", + get_share.device, get_share.inode); resp.u.get_or_set_share.exists = sharemode_get (get_share.device, get_share.inode, &resp.u.get_or_set_share.sharemode, &resp.u.get_or_set_share.access); if (resp.u.get_or_set_share.exists) { - LOGDEBUG ("%s: Share mode: 0x%x", __func__, resp.u.get_or_set_share.sharemode); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": Share mode: 0x%x", + resp.u.get_or_set_share.sharemode); } else { - LOGDEBUG ("%s: file share info not already known, setting", __func__); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION + ": file share info not already known, setting"); sharemode_set (get_share.device, get_share.inode, get_share.new_sharemode, get_share.new_access); } @@ -1321,9 +1342,9 @@ static gboolean read_message (GIOChannel *channel, ChannelData *channel_data) } if(has_fds==TRUE) { - LOGDEBUG ("%s: closing %d", __func__, fds[0]); - LOGDEBUG ("%s: closing %d", __func__, fds[1]); - LOGDEBUG ("%s: closing %d", __func__, fds[2]); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": closing %d", fds[0]); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": closing %d", fds[1]); + LOGDEBUG (G_GNUC_PRETTY_FUNCTION ": closing %d", fds[2]); close (fds[0]); close (fds[1]); @@ -1355,7 +1376,7 @@ static gboolean fd_activity (GIOChannel *channel, GIOCondition condition, return(FALSE); } - if(condition & (_IO_PRI)) { + if(condition & (G_IO_IN | G_IO_PRI)) { if(fd==main_sock) { int newsock; struct sockaddr addr; @@ -1363,7 +1384,8 @@ static gboolean fd_activity (GIOChannel *channel, GIOCondition condition, newsock=accept (main_sock, &addr, &addrlen); if(newsock==-1) { - g_critical ("%s accept error: %s", __func__, g_strerror (errno)); + g_critical ("accept error: %s", + g_strerror (errno)); cleanup (); exit (-1); } diff --git a/mono/io-layer/io.c b/mono/io-layer/io.c index 1d1b784f906..120ef4c03ee 100644 --- a/mono/io-layer/io.c +++ b/mono/io-layer/io.c @@ -1547,7 +1547,7 @@ gpointer CreateFile(const gunichar2 *name, guint32 fileaccess, if (fd == -1 && errno == EISDIR) { /* Try again but don't try to make it writable */ - fd = _wapi_open (filename, flags & ~(O_RDWR|O_WRONLY), perms); + fd = open(filename, flags & ~(O_RDWR|O_WRONLY), perms); } if (fd == -1) { @@ -1979,7 +1979,7 @@ gboolean CopyFile (const gunichar2 *name, const gunichar2 *dest_name, if(dest_name==NULL) { #ifdef DEBUG - g_message("%s: dest is NULL", __func__); + g_message("%s: name is NULL", __func__); #endif g_free (utf8_src); @@ -2022,15 +2022,16 @@ gboolean CopyFile (const gunichar2 *name, const gunichar2 *dest_name, } if (fail_if_exists) { - dest_fd = _wapi_open (utf8_dest, O_WRONLY | O_CREAT | O_EXCL, st.st_mode); + dest_fd = open (utf8_dest, O_WRONLY | O_CREAT | O_EXCL, + st.st_mode); } else { - /* FIXME: it kinda sucks that this code path potentially scans - * the directory twice due to the weird SetLastError() - * behavior. */ - dest_fd = _wapi_open (utf8_dest, O_WRONLY | O_TRUNC, st.st_mode); + dest_fd = open (utf8_dest, O_WRONLY | O_TRUNC, st.st_mode); if (dest_fd < 0) { - /* The file does not exist, try creating it */ - dest_fd = _wapi_open (utf8_dest, O_WRONLY | O_CREAT | O_TRUNC, st.st_mode); + /* O_TRUNC might cause a fail if the file + * doesn't exist + */ + dest_fd = open (utf8_dest, O_WRONLY | O_CREAT, + st.st_mode); } else { /* Apparently this error is set if we * overwrite the dest file @@ -2119,9 +2120,12 @@ ReplaceFile (const gunichar2 *replacedFileName, const gunichar2 *replacementFile _wapi_set_last_path_error_from_errno (NULL, utf8_replacementFileName); _wapi_rename (utf8_backupFileName, utf8_replacedFileName); if (backup_fd != -1 && !fstat (backup_fd, &stBackup)) { - replaced_fd = _wapi_open (utf8_backupFileName, O_WRONLY | O_CREAT | O_TRUNC, - stBackup.st_mode); - + replaced_fd = open (utf8_backupFileName, O_WRONLY | O_CREAT | O_TRUNC, + stBackup.st_mode); + if (replaced_fd == -1) { + replaced_fd = open (utf8_backupFileName, O_WRONLY | O_CREAT, + stBackup.st_mode); + } if (replaced_fd == -1) goto replace_cleanup; diff --git a/mono/io-layer/processes.c b/mono/io-layer/processes.c index c71c458dea7..c5849beb6fe 100644 --- a/mono/io-layer/processes.c +++ b/mono/io-layer/processes.c @@ -35,17 +35,6 @@ #include <sys/resource.h> #endif -#ifdef PLATFORM_SOLARIS -/* procfs.h cannot be included if this define is set, but it seems to work fine if it is undefined */ -#if _FILE_OFFSET_BITS == 64 -#undef _FILE_OFFSET_BITS -#include <procfs.h> -#define _FILE_OFFSET_BITS 64 -#else -#include <procfs.h> -#endif -#endif - #include <mono/io-layer/wapi.h> #include <mono/io-layer/wapi-private.h> #include <mono/io-layer/handles-private.h> @@ -1759,11 +1748,6 @@ static GSList *load_modules (void) hdr = _dyld_get_image_header (i); sec = getsectbynamefromheader (hdr, SEG_DATA, SECT_DATA); - /* Some dynlibs do not have data sections on osx (#533893) */ - if (sec == 0) { - continue; - } - mod = g_new0 (WapiProcModule, 1); mod->address_start = GINT_TO_POINTER (sec->addr); mod->address_end = GINT_TO_POINTER (sec->addr+sec->size); @@ -2091,26 +2075,6 @@ static gchar *get_process_name_from_proc (pid_t pid) return(ret); } -#ifdef PLATFORM_SOLARIS - filename = g_strdup_printf ("/proc/%d/psinfo", pid); - if ((fp = fopen (filename, "r")) != NULL) { - struct psinfo info; - int nread; - - nread = fread (&info, sizeof (info), 1, fp); - if (nread == 1) { - ret = g_strdup (info.pr_fname); - } - - fclose (fp); - } - g_free (filename); -#endif - - if (ret != NULL) { - return(ret); - } - return(NULL); } diff --git a/mono/metadata/ChangeLog b/mono/metadata/ChangeLog index efe1742294f..b36a6f31a79 100644 --- a/mono/metadata/ChangeLog +++ b/mono/metadata/ChangeLog @@ -1,198 +1,3 @@ -2009-10-06 Mark Probst <mark.probst@gmail.com> - - * object.c (mono_method_return_message_restore): Handle the case - where the argument is an instance of a generic type. Fixes - #544446. - - Backport of r143506. - -2009-09-30 Zoltan Varga <vargaz@gmail.com> - - * marshal.c (emit_marshal_object): Emit out marshalling of stringbuilders. - Fixes #543133. - -2009-09-29 Rolf Bjarne Kvinge <RKvinge@novell.com> - - * appdomain.c|h: Add a mono_domain_try_unload method which is - equivalent to mono_domain_unload, except that it returns an exception - instead of throwing it. Make mono_domain_unload use the - mono_domain_try_unload method to avoid code-duplication. - - Backport of r142658. - -2009-09-27 Gonzalo Paniagua Javier <gonzalo@novell.com> - - * marshal.c: don't create the handle when calling. It is created later - if needed. - -2009-09-24 Zoltan Varga <vargaz@gmail.com> - - * marshal.c (emit_ptr_to_object_conv): Generate an exception instead of - aborting when a conversion is not implemented. - -2009-09-23 Miguel de Icaza <miguel@novell.com> - - * verify.c: when comparing culture strings, use g_ascii_strcmp - - * assembly.c (mono_public_tokens_are_equal): Change g_strcasecmp - when comparing public key tokens to use memcmp on 16 bytes. I do - not believe this ever worked as advertised in the past. - - The standard Public Key is 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 - which would have always failed earlier. - -2009-06-25 Miguel de Icaza <miguel@novell.com> - - * gc.c: Raise a NullArgumentException if the object passed is - null. - -2009-09-22 Zoltan Varga <vargaz@gmail.com> - - * image.c (mono_image_close): Atomically decrement the reference count and - remove the image from the hash tables, to prevent another thread from seeing a - dying MonoImage. Fixes #541194. - -2009-09-22 Gonzalo Paniagua Javier <gonzalo@novell.com> - - * threadpool.c: actually use the minimum number of 'completion ports' - (for us is just a potential worker thread). - -2009-09-22 Gonzalo Paniagua Javier <gonzalo@novell.com> - - * threadpool.c: remove ares_htable. It does not make sense any more - since the same objects are now stored in GC-tracked arrays while they are - in the queue. - -2009-09-22 Gonzalo Paniagua Javier <gonzalo@novell.com> - - * threadpool.c: increase the minimum length of the queues to 128. - Remove warning. - -2009-09-21 Zoltan Varga <vargaz@gmail.com> - - * marshal.c (mono_marshal_get_string_ctor_signature): New internal function to - return the modified signature used by string ctors. - -2009-09-20 Zoltan Varga <vargaz@gmail.com> - - * marshal.c (mono_marshal_get_runtime_invoke_dynamic): New internal function - to return a runtime-invoke wrapper which uses DYN_CALL to call the wrapped - method, to be used by full-aot. - -2009-09-18 Rodrigo Kumpera <rkumpera@novell.com> - - Since the runtime supports lazy initialization of a type's vtable and this can cause a type - to fail, we need to ensure that the vtable is properly initialized at spots were the type must - be known to be good. - - * class.c (mono_class_init): Fail array types if their element type fails initialization - as well. - - * object.c (mono_class_create_runtime_vtable): Fail array types if their element type fails - initialization, additionally we request the element_type vtable to be initialized as well. - - This is fine and should not increase the working set in any meaningful way since it's reasonable - to assume that most code will create an array and eventually populate it, which will require the - type's vtable to be initialized. - - * loader.c (field_from_memberref): Add a comment for a possibly useless mono_class_init call. - -2009-09-17 Atsushi Enomoto <atsushi@ximian.com> - - * normalization-tables.h : regenerated. - -2009-09-16 Zoltan Varga <vargaz@gmail.com> - - * mono-debug.c (mono_debug_add_method): Increase the size of the buffer, - a leb128 encoding can take up to 5 bytes. - -2009-09-15 Rodrigo Kumpera <rkumpera@novell.com> - - * class.c (verify_class_overrides): Remove useless argument. - - * class.c (mono_class_setup_vtable_general): Move the overrides check to happen - before interface enumeration as this is no longer required. - -2009-09-15 Rodrigo Kumpera <rkumpera@novell.com> - - * class.c: New function mono_class_is_assignable_from_slow that is safe to be - used under mono_class_init context. This functions avoid any code path that - calls mono_class_init, which leads it to be slow as some things like the interface - bitmap are not available. - - * class.c (verify_class_overrides): Use mono_class_is_assignable_from_slow instead - of it's own broken version. Fixes the verifier part of #538588. - - * class-internals.h: Export mono_class_is_assignable_from_slow as part of the internal - API. - -2009-09-15 Mark Probst <mark.probst@gmail.com> - - * class.c (mono_class_init): Always set an exception in a class if - vtable setup fails. Fixes #538577. - - * generic-sharing.c: Raise an exception if mono_class_vtable() - returns NULL. - -2009-09-13 Zoltan Varga <vargaz@gmail.com> - - * marshal.c (mono_marshal_get_runtime_invoke): Don't share instance - methods of vtypes, as they could be incorrectly shared with static methods - taking an IntPtr argument. - -2009-09-12 Gonzalo Paniagua Javier <gonzalo@novell.com> - - * domain.c: - * object.c: - * class-internals.h: renamed waithandle_class to - manualresetevent_class. - * marshal.c: propagate the exception if a remoting BeginInvoke call - fails. - -2009-09-11 Rodrigo Kumpera <rkumpera@novell.com> - - * object.c: Properly handle vtable failures. - -2009-09-11 Rodrigo Kumpera <rkumpera@novell.com> - - * socket-io.c: Assert on vtable failure. - - * mono-mlist.c: Assert on vtable failure. - -2009-09-11 Rodrigo Kumpera <rkumpera@novell.com> - - * marshal.c: Assert on vtable failure. - -2009-09-11 Rodrigo Kumpera <rkumpera@novell.com> - - * icall.c: Properly handle vtable failures. - -2009-09-11 Rodrigo Kumpera <rkumpera@novell.com> - - * debug-helpers.c (mono_class_describe_statics): Properly handle vtable failures. - -2009-09-11 Rodrigo Kumpera <rkumpera@novell.com> - - * cominterop.c (ves_icall_System_ComObject_CreateRCW): Property handle vtable failures. - - * console-unix.c (do_console_cancel_event): Same. - -2009-09-11 Rodrigo Kumpera <rkumpera@novell.com> - - * class-internals.h: Add mono_class_vtable_full function that allows control - if an exception should be raised or not. - - * object.c (mono_class_vtable): Call into mono_class_vtable_full. Fix this function - to do what its documentation say, that is to return NULL and set exception_type on - failure. - - * object.c (mono_class_create_runtime_vtable): Add new raise_on_error parameter - and change the code to honor it. - -2009-09-11 Rodrigo Kumpera <rkumpera@novell.com> - - * verify.c: Fix typo in error message. - 2009-09-10 Sebastien Pouliot <sebastien@ximian.com> * security-core-clr.c: Fix default_platform_check so it can run diff --git a/mono/metadata/appdomain.c b/mono/metadata/appdomain.c index c4a3b31be75..2858dd77e41 100644 --- a/mono/metadata/appdomain.c +++ b/mono/metadata/appdomain.c @@ -2103,45 +2103,22 @@ unload_thread_main (void *arg) * mono_domain_unload: * @domain: The domain to unload * - * Unloads an appdomain. Follows the process outlined in the comment - * for mono_domain_try_unload. - */ -void -mono_domain_unload (MonoDomain *domain) -{ - MonoObject *exc = NULL; - mono_domain_try_unload (domain, &exc); - if (exc) - mono_raise_exception ((MonoException*)exc); -} - -/* - * mono_domain_unload: - * @domain: The domain to unload - * @exc: Exception information - * * Unloads an appdomain. Follows the process outlined in: * http://blogs.gotdotnet.com/cbrumme * * If doing things the 'right' way is too hard or complex, we do it the * 'simple' way, which means do everything needed to avoid crashes and * memory leaks, but not much else. - * - * It is required to pass a valid reference to the exc argument, upon return - * from this function *exc will be set to the exception thrown, if any. - * - * If this method is not called from an icall (embedded scenario for instance), - * it must not be called with any managed frames on the stack, since the unload - * process could end up trying to abort the current thread. */ void -mono_domain_try_unload (MonoDomain *domain, MonoObject **exc) +mono_domain_unload (MonoDomain *domain) { HANDLE thread_handle; gsize tid; guint32 res; MonoAppDomainState prev_state; MonoMethod *method; + MonoObject *exc; unload_data thread_data; MonoDomain *caller_domain = mono_domain_get (); @@ -2155,11 +2132,11 @@ mono_domain_try_unload (MonoDomain *domain, MonoObject **exc) switch (prev_state) { case MONO_APPDOMAIN_UNLOADING_START: case MONO_APPDOMAIN_UNLOADING: - *exc = (MonoObject *) mono_get_exception_cannot_unload_appdomain ("Appdomain is already being unloaded."); - return; + mono_raise_exception (mono_get_exception_cannot_unload_appdomain ("Appdomain is already being unloaded.")); + break; case MONO_APPDOMAIN_UNLOADED: - *exc = (MonoObject *) mono_get_exception_cannot_unload_appdomain ("Appdomain is already unloaded."); - return; + mono_raise_exception (mono_get_exception_cannot_unload_appdomain ("Appdomain is already unloaded.")); + break; default: g_warning ("Incalid appdomain state %d", prev_state); g_assert_not_reached (); @@ -2173,12 +2150,13 @@ mono_domain_try_unload (MonoDomain *domain, MonoObject **exc) method = mono_class_get_method_from_name (domain->domain->mbr.obj.vtable->klass, "DoDomainUnload", -1); g_assert (method); - mono_runtime_invoke (method, domain->domain, NULL, exc); - if (*exc) { + exc = NULL; + mono_runtime_invoke (method, domain->domain, NULL, &exc); + if (exc) { /* Roll back the state change */ domain->state = MONO_APPDOMAIN_CREATED; mono_domain_set (caller_domain, FALSE); - return; + mono_raise_exception ((MonoException*)exc); } mono_domain_set (caller_domain, FALSE); @@ -2217,14 +2195,18 @@ mono_domain_try_unload (MonoDomain *domain, MonoObject **exc) CloseHandle (thread_handle); if (thread_data.failure_reason) { + MonoException *ex; + /* Roll back the state change */ domain->state = MONO_APPDOMAIN_CREATED; g_warning ("%s", thread_data.failure_reason); - *exc = (MonoObject *) mono_get_exception_cannot_unload_appdomain (thread_data.failure_reason); + ex = mono_get_exception_cannot_unload_appdomain (thread_data.failure_reason); g_free (thread_data.failure_reason); thread_data.failure_reason = NULL; + + mono_raise_exception (ex); } } diff --git a/mono/metadata/appdomain.h b/mono/metadata/appdomain.h index 4ec0cc28764..e4da4e4404b 100644 --- a/mono/metadata/appdomain.h +++ b/mono/metadata/appdomain.h @@ -85,9 +85,6 @@ mono_domain_set_internal (MonoDomain *domain); void mono_domain_unload (MonoDomain *domain); -void -mono_domain_try_unload (MonoDomain *domain, MonoObject **exc); - gboolean mono_domain_is_unloading (MonoDomain *domain); diff --git a/mono/metadata/assembly.c b/mono/metadata/assembly.c index 538767850fc..f431649c9fc 100644 --- a/mono/metadata/assembly.c +++ b/mono/metadata/assembly.c @@ -159,7 +159,7 @@ encode_public_tok (const guchar *token, gint32 len) gboolean mono_public_tokens_are_equal (const unsigned char *pubt1, const unsigned char *pubt2) { - return memcmp (pubt1, pubt2, 16) == 0; + return g_strcasecmp ((char*)pubt1, (char*)pubt2) == 0; } static void diff --git a/mono/metadata/class-internals.h b/mono/metadata/class-internals.h index 7b81aa88505..ea2505981bd 100644 --- a/mono/metadata/class-internals.h +++ b/mono/metadata/class-internals.h @@ -973,7 +973,7 @@ typedef struct { MonoClass *delegate_class; MonoClass *multicastdelegate_class; MonoClass *asyncresult_class; - MonoClass *manualresetevent_class; + MonoClass *waithandle_class; MonoClass *typehandle_class; MonoClass *fieldhandle_class; MonoClass *methodhandle_class; @@ -1239,10 +1239,4 @@ mono_class_setup_interfaces (MonoClass *klass) MONO_INTERNAL; MonoClassField* mono_class_get_field_from_name_full (MonoClass *klass, const char *name, MonoType *type) MONO_INTERNAL; -MonoVTable* -mono_class_vtable_full (MonoDomain *domain, MonoClass *class, gboolean raise_on_error) MONO_INTERNAL; - -gboolean -mono_class_is_assignable_from_slow (MonoClass *target, MonoClass *candidate) MONO_INTERNAL; - #endif /* __MONO_METADATA_CLASS_INTERBALS_H__ */ diff --git a/mono/metadata/class.c b/mono/metadata/class.c index 4521e49c4aa..2e14c7232ed 100644 --- a/mono/metadata/class.c +++ b/mono/metadata/class.c @@ -39,7 +39,6 @@ #include <mono/metadata/verify-internals.h> #include <mono/metadata/mono-debug.h> #include <mono/utils/mono-counters.h> -#include <mono/utils/mono-string.h> MonoStats mono_stats; @@ -3105,9 +3104,10 @@ print_unimplemented_interface_method_info (MonoClass *class, MonoClass *ic, Mono } static gboolean -verify_class_overrides (MonoClass *class, MonoMethod **overrides, int onum) +verify_class_overrides (MonoClass *class, GPtrArray *ifaces, MonoMethod **overrides, int onum) { int i; + gboolean found; for (i = 0; i < onum; ++i) { MonoMethod *decl = overrides [i * 2]; @@ -3127,14 +3127,38 @@ verify_class_overrides (MonoClass *class, MonoMethod **overrides, int onum) } if (!(decl->flags & METHOD_ATTRIBUTE_VIRTUAL) || (decl->flags & METHOD_ATTRIBUTE_STATIC)) { - if (body->flags & METHOD_ATTRIBUTE_STATIC) - mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Cannot override a static method in a base type")); - else - mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Cannot override a non virtual method in a base type")); - return FALSE; + if (body->flags & METHOD_ATTRIBUTE_STATIC) + mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Cannot override a static method in a base type")); + else + mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Cannot override a non virtual method in a base type")); + return FALSE; + } + + found = FALSE; + /*We can't use mono_class_is_assignable_from since it requires the class to be fully initialized*/ + if (ifaces) { + int j; + for (j = 0; j < ifaces->len; j++) { + MonoClass *ic = g_ptr_array_index (ifaces, j); + if (decl->klass == ic) { + found = TRUE; + break; + } + } + } + + if (!found) { + MonoClass *parent = class; + while (parent) { + if (decl->klass == parent) { + found = TRUE; + break; + } + parent = parent->parent; + } } - if (!mono_class_is_assignable_from_slow (decl->klass, class)) { + if (!found) { mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Method overrides a class or interface that extended or implemented by this type")); return FALSE; } @@ -3162,11 +3186,14 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o if (class->vtable) return; - if (overrides && !verify_class_overrides (class, overrides, onum)) - return; - ifaces = mono_class_get_implemented_interfaces (class); + if (overrides && !verify_class_overrides (class, ifaces, overrides, onum)) { + if (ifaces) + g_ptr_array_free (ifaces, TRUE); + return; + } + if (ifaces) { for (i = 0; i < ifaces->len; i++) { MonoClass *ic = g_ptr_array_index (ifaces, i); @@ -3824,16 +3851,6 @@ mono_class_init (MonoClass *class) class->init_pending = 1; - if (class->byval_arg.type == MONO_TYPE_ARRAY || class->byval_arg.type == MONO_TYPE_SZARRAY) { - MonoClass *element_class = class->element_class; - if (!element_class->inited) - mono_class_init (element_class); - if (element_class->exception_type != MONO_EXCEPTION_NONE) { - mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL); - goto fail; - } - } - /* CAS - SecurityAction.InheritanceDemand */ if (mono_is_security_manager_active () && class->parent && (class->parent->flags & TYPE_ATTRIBUTE_HAS_SECURITY)) { mono_secman_inheritancedemand_class (class, class->parent); @@ -3935,10 +3952,8 @@ mono_class_init (MonoClass *class) class->has_cctor = gklass->has_cctor; mono_class_setup_vtable (gklass); - if (gklass->exception_type) { - mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL); + if (gklass->exception_type) goto fail; - } class->vtable_size = gklass->vtable_size; } else { @@ -4026,20 +4041,12 @@ mono_class_init (MonoClass *class) if (class->parent) { /* This will compute class->parent->vtable_size for some classes */ mono_class_init (class->parent); - if (class->parent->exception_type) { - mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL); - goto fail; - } - if (mono_loader_get_last_error ()) + if (class->parent->exception_type || mono_loader_get_last_error ()) goto fail; if (!class->parent->vtable_size) { /* FIXME: Get rid of this somehow */ mono_class_setup_vtable (class->parent); - if (class->parent->exception_type) { - mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL); - goto fail; - } - if (mono_loader_get_last_error ()) + if (class->parent->exception_type || mono_loader_get_last_error ()) goto fail; } setup_interface_offsets (class, class->parent->vtable_size); @@ -5835,7 +5842,7 @@ find_nocase (gpointer key, gpointer value, gpointer user_data) char *name = (char*)key; FindUserData *data = (FindUserData*)user_data; - if (!data->value && (mono_utf8_strcasecmp (name, (char*)data->key) == 0)) + if (!data->value && (g_strcasecmp (name, (char*)data->key) == 0)) data->value = value; } @@ -5904,7 +5911,7 @@ mono_class_from_name_case (MonoImage *image, const char* name_space, const char continue; n = mono_metadata_string_heap (image, cols [MONO_TYPEDEF_NAME]); nspace = mono_metadata_string_heap (image, cols [MONO_TYPEDEF_NAMESPACE]); - if (mono_utf8_strcasecmp (n, name) == 0 && mono_utf8_strcasecmp (nspace, name_space) == 0) + if (g_strcasecmp (n, name) == 0 && g_strcasecmp (nspace, name_space) == 0) return mono_class_get (image, MONO_TOKEN_TYPE_DEF | i); } return NULL; @@ -6255,67 +6262,6 @@ mono_class_is_assignable_from (MonoClass *klass, MonoClass *oklass) return mono_class_has_parent (oklass, klass); } -/*Check if @candidate implements the interface @target*/ -static gboolean -mono_class_implement_interface_slow (MonoClass *target, MonoClass *candidate) -{ - int i; - - do { - if (candidate == target) - return TRUE; - - /*A TypeBuilder can have more interfaces on tb->interfaces than on candidate->interfaces*/ - if (candidate->image->dynamic && !candidate->wastypebuilder) { - MonoReflectionTypeBuilder *tb = candidate->reflection_info; - int j; - if (tb->interfaces) { - for (j = mono_array_length (tb->interfaces) - 1; j >= 0; --j) { - MonoReflectionType *iface = mono_array_get (tb->interfaces, MonoReflectionType*, j); - MonoClass *iface_class = mono_class_from_mono_type (iface->type); - if (iface_class == target || mono_class_implement_interface_slow (target, iface_class)) - return TRUE; - } - } - } else { - /*setup_interfaces don't mono_class_init anything*/ - mono_class_setup_interfaces (candidate); - for (i = 0; i < candidate->interface_count; ++i) { - if (candidate->interfaces [i] == target || mono_class_implement_interface_slow (target, candidate->interfaces [i])) - return TRUE; - } - } - candidate = candidate->parent; - } while (candidate); - - return FALSE; -} - -/* - * Check if @oklass can be assigned to @klass. - * This function does the same as mono_class_is_assignable_from but is safe to be used from mono_class_init context. - */ -gboolean -mono_class_is_assignable_from_slow (MonoClass *target, MonoClass *candidate) -{ - if (candidate == target) - return TRUE; - if (target == mono_defaults.object_class) - return TRUE; - - /*setup_supertypes don't mono_class_init anything */ - mono_class_setup_supertypes (candidate); - mono_class_setup_supertypes (target); - - if (mono_class_has_parent (candidate, target)) - return TRUE; - - /*If target is not an interface there is no need to check them.*/ - if (!MONO_CLASS_IS_INTERFACE (target)) - return FALSE; - return mono_class_implement_interface_slow (target, candidate); -} - /** * mono_class_get_cctor: * @klass: A MonoClass pointer diff --git a/mono/metadata/cominterop.c b/mono/metadata/cominterop.c index 4471644294c..7b33401a9a2 100644 --- a/mono/metadata/cominterop.c +++ b/mono/metadata/cominterop.c @@ -1571,7 +1571,7 @@ ves_icall_System_ComObject_CreateRCW (MonoReflectionType *type) * is called by the corresponding real proxy to create the real RCW. * Constructor does not need to be called. Will be called later. */ - obj = mono_object_new_alloc_specific (mono_class_vtable_full (domain, klass, TRUE)); + obj = mono_object_new_alloc_specific (mono_class_vtable (domain, klass)); return obj; } diff --git a/mono/metadata/console-unix.c b/mono/metadata/console-unix.c index d7ce7348d23..ecb3a3f524d 100644 --- a/mono/metadata/console-unix.c +++ b/mono/metadata/console-unix.c @@ -219,7 +219,6 @@ do_console_cancel_event (void) MonoMethod *method; MonoMethodMessage *msg; MonoMethod *im; - MonoVTable *vtable; if (!domain->domain) return; @@ -233,10 +232,7 @@ do_console_cancel_event (void) g_assert (cancel_handler_field); } - vtable = mono_class_vtable_full (domain, klass, FALSE); - if (vtable == NULL) - return; - mono_field_static_get_value (vtable, cancel_handler_field, &load_value); + mono_field_static_get_value (mono_class_vtable (domain, klass), cancel_handler_field, &load_value); if (load_value == NULL) return; diff --git a/mono/metadata/debug-helpers.c b/mono/metadata/debug-helpers.c index 61883ed13d0..79f5296af8e 100644 --- a/mono/metadata/debug-helpers.c +++ b/mono/metadata/debug-helpers.c @@ -82,8 +82,8 @@ append_class_name (GString *res, MonoClass *class, gboolean include_namespace) g_string_append_c (res, '/'); } if (include_namespace && *(class->name_space)) - g_string_append_printf (res, "%s.", class->name_space); - g_string_append_printf (res, "%s", class->name); + g_string_sprintfa (res, "%s.", class->name_space); + g_string_sprintfa (res, "%s", class->name); } void @@ -134,7 +134,7 @@ mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace) break; case MONO_TYPE_ARRAY: mono_type_get_desc (res, &type->data.array->eklass->byval_arg, include_namespace); - g_string_append_printf (res, "[%d]", type->data.array->rank); + g_string_sprintfa (res, "[%d]", type->data.array->rank); break; case MONO_TYPE_SZARRAY: mono_type_get_desc (res, &type->data.klass->byval_arg, include_namespace); @@ -502,12 +502,12 @@ dis_one (GString *str, MonoDisHelper *dh, MonoMethod *method, const unsigned cha g_free (tmp); } if (dh->label_format) - g_string_append_printf (str, dh->label_format, label); + g_string_sprintfa (str, dh->label_format, label); i = mono_opcode_value (&ip, end); ip++; opcode = &mono_opcodes [i]; - g_string_append_printf (str, "%-10s", mono_opcode_name (i)); + g_string_sprintfa (str, "%-10s", mono_opcode_name (i)); switch (opcode->argument) { case MonoInlineNone: @@ -523,7 +523,7 @@ dis_one (GString *str, MonoDisHelper *dh, MonoMethod *method, const unsigned cha g_string_append (str, tmp); g_free (tmp); } else { - g_string_append_printf (str, "0x%08x", token); + g_string_sprintfa (str, "0x%08x", token); } ip += 4; break; @@ -553,35 +553,35 @@ dis_one (GString *str, MonoDisHelper *dh, MonoMethod *method, const unsigned cha s = g_utf16_to_utf8 ((gunichar2*)blob, len2, NULL, NULL, NULL); #endif - g_string_append_printf (str, "\"%s\"", s); + g_string_sprintfa (str, "\"%s\"", s); g_free (s); } ip += 4; break; } case MonoInlineVar: - g_string_append_printf (str, "%d", read16 (ip)); + g_string_sprintfa (str, "%d", read16 (ip)); ip += 2; break; case MonoShortInlineVar: - g_string_append_printf (str, "%d", (*ip)); + g_string_sprintfa (str, "%d", (*ip)); ip ++; break; case MonoInlineBrTarget: sval = read32 (ip); ip += 4; if (dh->label_target) - g_string_append_printf (str, dh->label_target, ip + sval - il_code); + g_string_sprintfa (str, dh->label_target, ip + sval - il_code); else - g_string_append_printf (str, "%d", sval); + g_string_sprintfa (str, "%d", sval); break; case MonoShortInlineBrTarget: sval = *(const signed char*)ip; ip ++; if (dh->label_target) - g_string_append_printf (str, dh->label_target, ip + sval - il_code); + g_string_sprintfa (str, dh->label_target, ip + sval - il_code); else - g_string_append_printf (str, "%d", sval); + g_string_sprintfa (str, "%d", sval); break; case MonoInlineSwitch: { const unsigned char *end; @@ -594,9 +594,9 @@ dis_one (GString *str, MonoDisHelper *dh, MonoMethod *method, const unsigned cha g_string_append (str, ", "); label = read32 (ip); if (dh->label_target) - g_string_append_printf (str, dh->label_target, end + label - il_code); + g_string_sprintfa (str, dh->label_target, end + label - il_code); else - g_string_append_printf (str, "%d", label); + g_string_sprintfa (str, "%d", label); ip += 4; } g_string_append_c (str, ')'); @@ -605,23 +605,23 @@ dis_one (GString *str, MonoDisHelper *dh, MonoMethod *method, const unsigned cha case MonoInlineR: { double r; readr8 (ip, &r); - g_string_append_printf (str, "%g", r); + g_string_sprintfa (str, "%g", r); ip += 8; break; } case MonoShortInlineR: { float r; readr4 (ip, &r); - g_string_append_printf (str, "%g", r); + g_string_sprintfa (str, "%g", r); ip += 4; break; } case MonoInlineI: - g_string_append_printf (str, "%d", (gint32)read32 (ip)); + g_string_sprintfa (str, "%d", (gint32)read32 (ip)); ip += 4; break; case MonoShortInlineI: - g_string_append_printf (str, "%d", *(const signed char*)ip); + g_string_sprintfa (str, "%d", *(const signed char*)ip); ip ++; break; case MonoInlineI8: @@ -946,12 +946,8 @@ mono_class_describe_statics (MonoClass* klass) MonoClassField *field; MonoClass *p; const char *field_ptr; - MonoVTable *vtable = mono_class_vtable_full (mono_domain_get (), klass, FALSE); - const char *addr; - - if (!vtable) - return; - if (!(addr = vtable->data)) + const char *addr = mono_class_vtable (mono_domain_get (), klass)->data; + if (!addr) return; for (p = klass; p != NULL; p = p->parent) { diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c index b221c6d31f3..6a8d599b82d 100644 --- a/mono/metadata/domain.c +++ b/mono/metadata/domain.c @@ -1445,9 +1445,9 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * "AsyncResult"); g_assert (mono_defaults.asyncresult_class != 0 ); - mono_defaults.manualresetevent_class = mono_class_from_name ( - mono_defaults.corlib, "System.Threading", "ManualResetEvent"); - g_assert (mono_defaults.manualresetevent_class != 0 ); + mono_defaults.waithandle_class = mono_class_from_name ( + mono_defaults.corlib, "System.Threading", "WaitHandle"); + g_assert (mono_defaults.waithandle_class != 0 ); mono_defaults.typehandle_class = mono_class_from_name ( mono_defaults.corlib, "System", "RuntimeTypeHandle"); diff --git a/mono/metadata/file-io.c b/mono/metadata/file-io.c index 53eb7378cf8..3af39d93661 100644 --- a/mono/metadata/file-io.c +++ b/mono/metadata/file-io.c @@ -1043,7 +1043,8 @@ ves_icall_System_IO_MonoIO_GetTempPath (MonoString **mono_name) if(ret>0) { #ifdef DEBUG - g_message ("%s: Temp path is [%s] (len %d)", __func__, name, ret); + g_message (G_GNUC_PRETTY_FUNCTION + ": Temp path is [%s] (len %d)", name, ret); #endif mono_gc_wbarrier_generic_store ((gpointer) mono_name, diff --git a/mono/metadata/gc.c b/mono/metadata/gc.c index edbd47dfd18..54dffb3865c 100644 --- a/mono/metadata/gc.c +++ b/mono/metadata/gc.c @@ -266,12 +266,7 @@ object_register_finalizer (MonoObject *obj, void (*callback)(void *, void*)) { #if HAVE_BOEHM_GC guint offset = 0; - MonoDomain *domain; - - if (obj == NULL) - mono_raise_exception (mono_get_exception_argument_null ("obj")); - - domain = obj->vtable->domain; + MonoDomain *domain = obj->vtable->domain; #ifndef GC_DEBUG /* This assertion is not valid when GC_DEBUG is defined */ @@ -296,9 +291,6 @@ object_register_finalizer (MonoObject *obj, void (*callback)(void *, void*)) GC_REGISTER_FINALIZER_NO_ORDER ((char*)obj - offset, callback, GUINT_TO_POINTER (offset), NULL, NULL); #elif defined(HAVE_SGEN_GC) - if (obj == NULL) - mono_raise_exception (mono_get_exception_argument_null ("obj")); - mono_gc_register_for_finalization (obj, callback); #endif } @@ -934,7 +926,7 @@ void mono_gc_finalize_notify (void) { #ifdef DEBUG - g_message ( "%s: prodding finalizer", __func__); + g_message (G_GNUC_PRETTY_FUNCTION ": prodding finalizer"); #endif #ifdef MONO_HAS_SEMAPHORES @@ -1093,7 +1085,7 @@ void mono_gc_cleanup (void) { #ifdef DEBUG - g_message ("%s: cleaning up finalizer", __func__); + g_message (G_GNUC_PRETTY_FUNCTION ": cleaning up finalizer"); #endif if (!gc_disabled) { diff --git a/mono/metadata/generic-sharing.c b/mono/metadata/generic-sharing.c index 690c87ed70f..47b5a370f9c 100644 --- a/mono/metadata/generic-sharing.c +++ b/mono/metadata/generic-sharing.c @@ -722,20 +722,12 @@ static gpointer class_type_info (MonoDomain *domain, MonoClass *class, int info_type) { switch (info_type) { - case MONO_RGCTX_INFO_STATIC_DATA: { - MonoVTable *vtable = mono_class_vtable (domain, class); - if (!vtable) - mono_raise_exception (mono_class_get_exception_for_failure (class)); - return vtable->data; - } + case MONO_RGCTX_INFO_STATIC_DATA: + return mono_class_vtable (domain, class)->data; case MONO_RGCTX_INFO_KLASS: return class; - case MONO_RGCTX_INFO_VTABLE: { - MonoVTable *vtable = mono_class_vtable (domain, class); - if (!vtable) - mono_raise_exception (mono_class_get_exception_for_failure (class)); - return vtable; - } + case MONO_RGCTX_INFO_VTABLE: + return mono_class_vtable (domain, class); default: g_assert_not_reached (); } @@ -799,16 +791,12 @@ instantiate_other_info (MonoDomain *domain, MonoRuntimeGenericContextOtherInfoTe return data; case MONO_RGCTX_INFO_METHOD_RGCTX: { MonoMethodInflated *method = data; - MonoVTable *vtable; g_assert (method->method.method.is_inflated); g_assert (method->context.method_inst); - vtable = mono_class_vtable (domain, method->method.method.klass); - if (!vtable) - mono_raise_exception (mono_class_get_exception_for_failure (method->method.method.klass)); - - return mono_method_lookup_rgctx (vtable, method->context.method_inst); + return mono_method_lookup_rgctx (mono_class_vtable (domain, method->method.method.klass), + method->context.method_inst); } case MONO_RGCTX_INFO_METHOD_CONTEXT: { MonoMethodInflated *method = data; diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index 7c778759b5c..1bb7b7c2a42 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -72,7 +72,6 @@ #include <mono/utils/monobitset.h> #include <mono/utils/mono-time.h> #include <mono/utils/mono-proclib.h> -#include <mono/utils/mono-string.h> #if defined (PLATFORM_WIN32) #include <windows.h> @@ -949,7 +948,11 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor (Mo klass = mono_class_from_mono_type (handle); MONO_CHECK_ARG (handle, klass); - vtable = mono_class_vtable_full (mono_domain_get (), klass, TRUE); + vtable = mono_class_vtable (mono_domain_get (), klass); + if (klass->exception_type != MONO_EXCEPTION_NONE) + mono_raise_exception (mono_class_get_exception_for_failure (klass)); + + MONO_CHECK_ARG (handle, vtable); /* This will call the type constructor */ mono_runtime_class_init (vtable); @@ -963,8 +966,7 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunModuleConstructor (M mono_image_check_for_module_cctor (image); if (image->has_module_cctor) { MonoClass *module_klass = mono_class_get (image, MONO_TOKEN_TYPE_DEF | 1); - /*It's fine to raise the exception here*/ - mono_runtime_class_init (mono_class_vtable_full (mono_domain_get (), module_klass, TRUE)); + mono_runtime_class_init (mono_class_vtable (mono_domain_get (), module_klass)); } } @@ -1801,7 +1803,7 @@ ves_icall_MonoField_GetValueInternal (MonoReflectionField *field, MonoObject *ob vtable = NULL; if (is_static) { - vtable = mono_class_vtable_full (domain, cf->parent, TRUE); + vtable = mono_class_vtable (domain, cf->parent); if (!vtable->initialized && !(cf->type->attrs & FIELD_ATTRIBUTE_LITERAL)) mono_runtime_class_init (vtable); } @@ -1916,7 +1918,7 @@ ves_icall_MonoField_SetValueInternal (MonoReflectionField *field, MonoObject *ob } if (cf->type->attrs & FIELD_ATTRIBUTE_STATIC) { - MonoVTable *vtable = mono_class_vtable_full (mono_object_domain (field), cf->parent, TRUE); + MonoVTable *vtable = mono_class_vtable (mono_object_domain (field), cf->parent); if (!vtable->initialized) mono_runtime_class_init (vtable); mono_field_static_set_value (vtable, cf, v); @@ -2354,7 +2356,7 @@ ves_icall_MonoType_GetGenericArguments (MonoReflectionType *type) MonoArray *res; MonoClass *klass, *pklass; MonoDomain *domain = mono_object_domain (type); - MonoVTable *array_vtable = mono_class_vtable_full (domain, mono_array_class_get_cached (mono_defaults.systemtype_class, 1), TRUE); + MonoVTable *array_vtable = mono_class_vtable (domain, mono_array_class_get_cached (mono_defaults.systemtype_class, 1)); int i; MONO_ARCH_SAVE_REGS; @@ -3264,7 +3266,7 @@ ves_icall_Type_GetField (MonoReflectionType *type, MonoString *name, guint32 bfl if (type->type->byref) return NULL; - compare_func = (bflags & BFLAGS_IgnoreCase) ? mono_utf8_strcasecmp : strcmp; + compare_func = (bflags & BFLAGS_IgnoreCase) ? g_strcasecmp : strcmp; handle_parent: if (klass->exception_type != MONO_EXCEPTION_NONE) @@ -3432,7 +3434,7 @@ ves_icall_Type_GetMethodsByName (MonoReflectionType *type, MonoString *name, gui } domain = ((MonoObject *)type)->vtable->domain; - array_vtable = mono_class_vtable_full (domain, MethodInfo_array, TRUE); + array_vtable = mono_class_vtable (domain, MethodInfo_array); if (type->type->byref) return mono_array_new_specific (array_vtable, 0); klass = startklass = mono_class_from_mono_type (type->type); @@ -3440,7 +3442,7 @@ ves_icall_Type_GetMethodsByName (MonoReflectionType *type, MonoString *name, gui len = 0; if (name != NULL) { mname = mono_string_to_utf8 (name); - compare_func = (ignore_case) ? mono_utf8_strcasecmp : strcmp; + compare_func = (ignore_case) ? g_strcasecmp : strcmp; } /* An optimization for calls made from Delegate:CreateDelegate () */ @@ -3683,7 +3685,7 @@ ves_icall_Type_GetPropertiesByName (MonoReflectionType *type, MonoString *name, klass = startklass = mono_class_from_mono_type (type->type); if (name != NULL) { propname = mono_string_to_utf8 (name); - compare_func = (ignore_case) ? mono_utf8_strcasecmp : strcmp; + compare_func = (ignore_case) ? g_strcasecmp : strcmp; } mono_class_setup_vtable (klass); @@ -6675,7 +6677,7 @@ ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (Mo MONO_ARCH_SAVE_REGS; klass = mono_class_from_mono_type (type->type); - vtable = mono_class_vtable_full (mono_domain_get (), klass, TRUE); + vtable = mono_class_vtable (mono_domain_get (), klass); if (enable) vtable->remote = 1; else vtable->remote = 0; @@ -6697,7 +6699,7 @@ ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClas return (MonoObject *) mono_array_new (domain, klass->element_class, 0); } else { /* Bypass remoting object creation check */ - return mono_object_new_alloc_specific (mono_class_vtable_full (domain, klass, TRUE)); + return mono_object_new_alloc_specific (mono_class_vtable (domain, klass)); } } diff --git a/mono/metadata/image.c b/mono/metadata/image.c index 4e039adc681..693ab223c65 100644 --- a/mono/metadata/image.c +++ b/mono/metadata/image.c @@ -52,9 +52,8 @@ static GHashTable *loaded_images_refonly_hash; static gboolean debug_assembly_unload = FALSE; -#define mono_images_lock() if (mutex_inited) EnterCriticalSection (&images_mutex) -#define mono_images_unlock() if (mutex_inited) LeaveCriticalSection (&images_mutex) -static gboolean mutex_inited; +#define mono_images_lock() EnterCriticalSection (&images_mutex) +#define mono_images_unlock() LeaveCriticalSection (&images_mutex) static CRITICAL_SECTION images_mutex; /* returns offset relative to image->raw_data */ @@ -132,8 +131,6 @@ mono_images_init (void) loaded_images_refonly_hash = g_hash_table_new (g_str_hash, g_str_equal); debug_assembly_unload = g_getenv ("MONO_DEBUG_ASSEMBLY_UNLOAD") != NULL; - - mutex_inited = TRUE; } /** @@ -148,8 +145,6 @@ mono_images_cleanup (void) g_hash_table_destroy (loaded_images_hash); g_hash_table_destroy (loaded_images_refonly_hash); - - mutex_inited = FALSE; } /** @@ -1413,27 +1408,8 @@ mono_image_close (MonoImage *image) g_return_if_fail (image != NULL); - /* - * Atomically decrement the refcount and remove ourselves from the hash tables, so - * register_image () can't grab an image which is being closed. - */ - mono_images_lock (); - - if (InterlockedDecrement (&image->ref_count) > 0) { - mono_images_unlock (); + if (InterlockedDecrement (&image->ref_count) > 0) return; - } - - loaded_images = image->ref_only ? loaded_images_refonly_hash : loaded_images_hash; - image2 = g_hash_table_lookup (loaded_images, image->name); - if (image == image2) { - /* This is not true if we are called from mono_image_open () */ - g_hash_table_remove (loaded_images, image->name); - } - if (image->assembly_name && (g_hash_table_lookup (loaded_images, image->assembly_name) == image)) - g_hash_table_remove (loaded_images, (char *) image->assembly_name); - - mono_images_unlock (); #ifdef PLATFORM_WIN32 if (image->is_module_handle && image->has_entry_point) { @@ -1472,13 +1448,23 @@ mono_image_close (MonoImage *image) image->references = NULL; } -#ifdef PLATFORM_WIN32 mono_images_lock (); + loaded_images = image->ref_only ? loaded_images_refonly_hash : loaded_images_hash; + image2 = g_hash_table_lookup (loaded_images, image->name); + if (image == image2) { + /* This is not true if we are called from mono_image_open () */ + g_hash_table_remove (loaded_images, image->name); + } + if (image->assembly_name && (g_hash_table_lookup (loaded_images, image->assembly_name) == image)) + g_hash_table_remove (loaded_images, (char *) image->assembly_name); + +#ifdef PLATFORM_WIN32 if (image->is_module_handle && !image->has_entry_point) FreeLibrary ((HMODULE) image->raw_data); - mono_images_unlock (); #endif + mono_images_unlock (); + if (image->raw_buffer_used) { if (image->raw_data != NULL) mono_file_unmap (image->raw_data, image->raw_data_handle); diff --git a/mono/metadata/loader.c b/mono/metadata/loader.c index ec11c8f494a..13efb16d6f4 100644 --- a/mono/metadata/loader.c +++ b/mono/metadata/loader.c @@ -485,7 +485,7 @@ field_from_memberref (MonoImage *image, guint32 token, MonoClass **retklass, g_free (name); return NULL; } - mono_class_init (klass); /*FIXME is this really necessary?*/ + mono_class_init (klass); if (retklass) *retklass = klass; field = mono_class_get_field_from_name_full (klass, fname, sig_type); diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c index 92e6041885a..7952ca9b959 100644 --- a/mono/metadata/marshal.c +++ b/mono/metadata/marshal.c @@ -101,9 +101,6 @@ mono_string_to_lpstr (MonoString *string_obj); static MonoStringBuilder * mono_string_utf8_to_builder2 (char *text); -static MonoStringBuilder * -mono_string_utf16_to_builder2 (gunichar2 *text); - static void mono_byvalarray_to_array (MonoArray *arr, gpointer native_arr, MonoClass *eltype, guint32 elnum); @@ -230,7 +227,6 @@ mono_marshal_init (void) register_icall (mono_string_utf8_to_builder, "mono_string_utf8_to_builder", "void ptr ptr", FALSE); register_icall (mono_string_utf8_to_builder2, "mono_string_utf8_to_builder2", "object ptr", FALSE); register_icall (mono_string_utf16_to_builder, "mono_string_utf16_to_builder", "void ptr ptr", FALSE); - register_icall (mono_string_utf16_to_builder2, "mono_string_utf16_to_builder2", "object ptr", FALSE); register_icall (mono_marshal_free_array, "mono_marshal_free_array", "void ptr int32", FALSE); register_icall (mono_string_to_byvalstr, "mono_string_to_byvalstr", "void ptr ptr int32", FALSE); register_icall (mono_string_to_byvalwstr, "mono_string_to_byvalwstr", "void ptr ptr int32", FALSE); @@ -762,45 +758,6 @@ mono_string_utf16_to_builder (MonoStringBuilder *sb, gunichar2 *text) sb->length = len; } -MonoStringBuilder * -mono_string_utf16_to_builder2 (gunichar2 *text) -{ - int len; - MonoStringBuilder *sb; - static MonoClass *string_builder_class; - static MonoMethod *sb_ctor; - void *args [1]; - MonoObject *exc; - - if (!text) - return NULL; - - if (!string_builder_class) { - MonoMethodDesc *desc; - - string_builder_class = mono_class_from_name (mono_defaults.corlib, "System.Text", "StringBuilder"); - g_assert (string_builder_class); - desc = mono_method_desc_new (":.ctor(int)", FALSE); - sb_ctor = mono_method_desc_search_in_class (desc, string_builder_class); - g_assert (sb_ctor); - mono_method_desc_free (desc); - } - - for (len = 0; text [len] != 0; ++len) - ; - - sb = (MonoStringBuilder*)mono_object_new (mono_domain_get (), string_builder_class); - g_assert (sb); - args [0] = &len; - mono_runtime_invoke (sb_ctor, sb, args, &exc); - g_assert (!exc); - - sb->length = len; - memcpy (mono_string_chars (sb->str), text, len * 2); - - return sb; -} - /** * mono_string_builder_to_utf8: * @sb: the string builder @@ -1407,13 +1364,9 @@ emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv case MONO_MARSHAL_CONV_STR_ANSIBSTR: case MONO_MARSHAL_CONV_STR_TBSTR: case MONO_MARSHAL_CONV_ARRAY_SAVEARRAY: - default: { - char *msg = g_strdup_printf ("marshaling conversion %d not implemented", conv); - - mono_mb_emit_exception_marshal_directive (mb, msg); - g_free (msg); - break; - } + default: + g_warning ("marshaling conversion %d not implemented", conv); + g_assert_not_reached (); } } @@ -2030,19 +1983,19 @@ mono_delegate_begin_invoke (MonoDelegate *delegate, gpointer *params) MonoAsyncResult *ares; MonoObject *exc; MonoArray *out_args; + HANDLE handle; method = delegate->method; msg = mono_method_call_message_new (mono_marshal_method_from_wrapper (method), params, NULL, &async_callback, &state); - ares = mono_async_result_new (mono_domain_get (), NULL, state, NULL, NULL); + handle = CreateEvent (NULL, TRUE, FALSE, NULL); + g_assert(handle != NULL); + ares = mono_async_result_new (mono_domain_get (), handle, state, handle, NULL); MONO_OBJECT_SETREF (ares, async_delegate, (MonoObject *)delegate); MONO_OBJECT_SETREF (ares, async_callback, (MonoObject *)async_callback); MONO_OBJECT_SETREF (msg, async_result, ares); msg->call_type = CallType_BeginInvoke; - exc = NULL; mono_remoting_invoke ((MonoObject *)tp->rp, msg, &exc, &out_args); - if (exc) - mono_raise_exception ((MonoException *) exc); return ares; } } @@ -2728,17 +2681,12 @@ mono_marshal_get_remoting_invoke (MonoMethod *method) return method; /* this seems to be the best plase to put this, as all remoting invokes seem to get filtered through here */ - if (method->klass->is_com_object || 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 ((method->klass->is_com_object || method->klass == mono_defaults.com_object_class) && !mono_class_vtable (mono_domain_get (), method->klass)->remote) { #ifndef DISABLE_COM - return mono_cominterop_get_invoke (method); + return mono_cominterop_get_invoke (method); #else - g_assert_not_reached (); + g_assert_not_reached (); #endif - } } sig = mono_signature_no_pinvoke (method); @@ -3946,22 +3894,6 @@ add_string_ctor_signature (MonoMethod *method) return callsig; } -/* - * mono_marshal_get_string_ctor_signature: - * - * Return the modified signature used by string ctors (they return the newly created - * string). - */ -MonoMethodSignature* -mono_marshal_get_string_ctor_signature (MonoMethod *method) -{ - MonoMethodSignature *sig = lookup_string_ctor_signature (mono_method_signature (method)); - if (!sig) - sig = add_string_ctor_signature (method); - - return sig; -} - static MonoType* get_runtime_invoke_type (MonoType *t, gboolean ret) { @@ -4150,8 +4082,6 @@ mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual) * Create a new signature to reflect this. */ callsig = signature_dup_add_this (mono_method_signature (method), method->klass); - /* Can't share this as it would be shared with static methods taking an IntPtr argument */ - need_direct_wrapper = TRUE; } else { if (method->dynamic) callsig = signature_dup (method->klass->image, mono_method_signature (method)); @@ -4508,127 +4438,6 @@ handle_enum: return res; } -/* - * mono_marshal_get_runtime_invoke_dynamic: - * - * Return a method which can be used to invoke managed methods from native code - * dynamically. - * The signature of the returned method is given by RuntimeInvokeDynamicFunction: - * void runtime_invoke (void *args, MonoObject **exc, void *compiled_method) - * ARGS should point to an architecture specific structure containing - * the arguments and space for the return value. - * The other arguments are the same as for runtime_invoke (), except that - * ARGS should contain the this argument too. - * This wrapper serves the same purpose as the runtime-invoke wrappers, but there - * is only one copy of it, which is useful in full-aot. - */ -MonoMethod* -mono_marshal_get_runtime_invoke_dynamic (void) -{ - static MonoMethod *method; - MonoMethodSignature *csig; - MonoExceptionClause *clause; - MonoMethodBuilder *mb; - int pos, posna; - char *name; - - if (method) - return method; - - csig = mono_metadata_signature_alloc (mono_defaults.corlib, 4); - - csig->ret = &mono_defaults.void_class->byval_arg; - csig->params [0] = &mono_defaults.int_class->byval_arg; - csig->params [1] = &mono_defaults.int_class->byval_arg; - csig->params [2] = &mono_defaults.int_class->byval_arg; - csig->params [3] = &mono_defaults.int_class->byval_arg; - - name = g_strdup ("runtime_invoke_dynamic"); - mb = mono_mb_new (mono_defaults.object_class, name, MONO_WRAPPER_RUNTIME_INVOKE); - g_free (name); - - /* allocate local 0 (object) tmp */ - mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg); - /* allocate local 1 (object) exc */ - mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg); - - /* cond set *exc to null */ - mono_mb_emit_byte (mb, CEE_LDARG_1); - mono_mb_emit_byte (mb, CEE_BRFALSE_S); - mono_mb_emit_byte (mb, 3); - mono_mb_emit_byte (mb, CEE_LDARG_1); - mono_mb_emit_byte (mb, CEE_LDNULL); - mono_mb_emit_byte (mb, CEE_STIND_REF); - - emit_thread_force_interrupt_checkpoint (mb); - - mono_mb_emit_byte (mb, CEE_LDARG_0); - mono_mb_emit_byte (mb, CEE_LDARG_2); - mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX); - mono_mb_emit_byte (mb, CEE_MONO_DYN_CALL); - - pos = mono_mb_emit_branch (mb, CEE_LEAVE); - - clause = mono_image_alloc0 (mono_defaults.corlib, sizeof (MonoExceptionClause)); - clause->flags = MONO_EXCEPTION_CLAUSE_FILTER; - clause->try_len = mono_mb_get_label (mb); - - /* filter code */ - clause->data.filter_offset = mono_mb_get_label (mb); - - mono_mb_emit_byte (mb, CEE_POP); - mono_mb_emit_byte (mb, CEE_LDARG_1); - mono_mb_emit_byte (mb, CEE_LDC_I4_0); - mono_mb_emit_byte (mb, CEE_PREFIX1); - mono_mb_emit_byte (mb, CEE_CGT_UN); - mono_mb_emit_byte (mb, CEE_PREFIX1); - mono_mb_emit_byte (mb, CEE_ENDFILTER); - - clause->handler_offset = mono_mb_get_label (mb); - - /* handler code */ - /* store exception */ - mono_mb_emit_stloc (mb, 1); - - mono_mb_emit_byte (mb, CEE_LDARG_1); - mono_mb_emit_ldloc (mb, 1); - mono_mb_emit_byte (mb, CEE_STIND_REF); - - mono_mb_emit_byte (mb, CEE_LDNULL); - mono_mb_emit_stloc (mb, 0); - - /* Check for the abort exception */ - mono_mb_emit_ldloc (mb, 1); - mono_mb_emit_op (mb, CEE_ISINST, mono_defaults.threadabortexception_class); - posna = mono_mb_emit_short_branch (mb, CEE_BRFALSE_S); - - /* Delay the abort exception */ - mono_mb_emit_icall (mb, ves_icall_System_Threading_Thread_ResetAbort); - - mono_mb_patch_short_branch (mb, posna); - mono_mb_emit_branch (mb, CEE_LEAVE); - - clause->handler_len = mono_mb_get_pos (mb) - clause->handler_offset; - - mono_mb_set_clauses (mb, 1, clause); - - /* return result */ - mono_mb_patch_branch (mb, pos); - //mono_mb_emit_ldloc (mb, 0); - mono_mb_emit_byte (mb, CEE_RET); - - mono_loader_lock (); - /* double-checked locking */ - if (!method) { - method = mono_mb_create_method (mb, csig, 16); - } - mono_loader_unlock (); - - mono_mb_free (mb); - - return method; -} - static void mono_mb_emit_auto_layout_exception (MonoMethodBuilder *mb, MonoClass *klass) { @@ -6191,14 +6000,7 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalNative encoding = mono_marshal_get_string_encoding (m->piinfo, spec); MonoMarshalConv conv = mono_marshal_get_stringbuilder_to_ptr_conv (m->piinfo, spec); - if (t->byref) { - if (!(t->attrs & PARAM_ATTRIBUTE_OUT)) { - char *msg = g_strdup_printf ("Byref marshalling of stringbuilders is not implemented."); - mono_mb_emit_exception_marshal_directive (mb, msg); - } - break; - } - + g_assert (!t->byref); mono_mb_emit_ldarg (mb, argnum); if (conv != -1) @@ -6286,34 +6088,13 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t, encoding = mono_marshal_get_string_encoding (m->piinfo, spec); conv = mono_marshal_get_ptr_to_stringbuilder_conv (m->piinfo, spec, &need_free); + g_assert (!t->byref); g_assert (encoding != -1); - if (t->byref) { - g_assert ((t->attrs & PARAM_ATTRIBUTE_OUT)); - - need_free = TRUE; - - mono_mb_emit_ldarg (mb, argnum); - mono_mb_emit_ldloc (mb, conv_arg); - - switch (encoding) { - case MONO_NATIVE_LPWSTR: - mono_mb_emit_icall (mb, mono_string_utf16_to_builder2); - break; - case MONO_NATIVE_LPSTR: - mono_mb_emit_icall (mb, mono_string_utf8_to_builder2); - break; - default: - g_assert_not_reached (); - } - - mono_mb_emit_byte (mb, CEE_STIND_REF); - } else { - mono_mb_emit_ldarg (mb, argnum); - mono_mb_emit_ldloc (mb, conv_arg); + mono_mb_emit_ldarg (mb, argnum); + mono_mb_emit_ldloc (mb, conv_arg); - mono_mb_emit_icall (mb, conv_to_icall (conv)); - } + mono_mb_emit_icall (mb, conv_to_icall (conv)); if (need_free) { mono_mb_emit_ldloc (mb, conv_arg); diff --git a/mono/metadata/marshal.h b/mono/metadata/marshal.h index e637291f56e..852df0df682 100644 --- a/mono/metadata/marshal.h +++ b/mono/metadata/marshal.h @@ -81,8 +81,6 @@ G_BEGIN_DECLS /*type of the function pointer of methods returned by mono_marshal_get_runtime_invoke*/ typedef MonoObject *(*RuntimeInvokeFunction) (MonoObject *this, void **params, MonoObject **exc, void* compiled_method); -typedef void (*RuntimeInvokeDynamicFunction) (void *args, MonoObject **exc, void* compiled_method); - /* marshaling helper functions */ void @@ -189,12 +187,6 @@ mono_marshal_get_delegate_invoke (MonoMethod *method, MonoDelegate *del) MONO_IN MonoMethod * mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual) MONO_INTERNAL; -MonoMethod* -mono_marshal_get_runtime_invoke_dynamic (void) MONO_INTERNAL; - -MonoMethodSignature* -mono_marshal_get_string_ctor_signature (MonoMethod *method) MONO_INTERNAL; - MonoMethod * mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, MonoObject **this_loc) MONO_INTERNAL; diff --git a/mono/metadata/monitor.c b/mono/metadata/monitor.c index 29182194ceb..56981a59518 100644 --- a/mono/metadata/monitor.c +++ b/mono/metadata/monitor.c @@ -202,7 +202,7 @@ mono_locks_dump (gboolean include_untaken) static void mon_finalize (MonoThreadsSync *mon) { - LOCK_DEBUG (g_message ("%s: Finalizing sync %p", __func__, mon)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": Finalizing sync %p", mon)); if (mon->entry_sem != NULL) { CloseHandle (mon->entry_sem); @@ -248,7 +248,7 @@ mon_new (gsize id) /* need to allocate a new array of monitors */ if (!monitor_freelist) { MonitorArray *last; - LOCK_DEBUG (g_message ("%s: allocating more monitors: %d", __func__, array_size)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": allocating more monitors: %d", array_size)); marray = g_malloc0 (sizeof (MonoArray) + array_size * sizeof (MonoThreadsSync)); marray->num_monitors = array_size; array_size *= 2; @@ -386,7 +386,8 @@ mono_monitor_try_enter_internal (MonoObject *obj, guint32 ms, gboolean allow_int guint32 ret; MonoThread *thread; - LOCK_DEBUG (g_message("%s: (%d) Trying to lock object %p (%d ms)", __func__, id, obj, ms)); + LOCK_DEBUG (g_message(G_GNUC_PRETTY_FUNCTION + ": (%d) Trying to lock object %p (%d ms)", id, obj, ms)); if (G_UNLIKELY (!obj)) { mono_raise_exception (mono_get_exception_argument_null ("obj")); @@ -508,7 +509,7 @@ retry: /* If ms is 0 we don't block, but just fail straight away */ if (ms == 0) { - LOCK_DEBUG (g_message ("%s: (%d) timed out, returning FALSE", __func__, id)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": (%d) timed out, returning FALSE", id)); return 0; } @@ -602,12 +603,13 @@ retry_contended: if (now < then) { /* The counter must have wrapped around */ - LOCK_DEBUG (g_message ("%s: wrapped around! now=0x%x then=0x%x", __func__, now, then)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION + ": wrapped around! now=0x%x then=0x%x", now, then)); now += (0xffffffff - then); then = 0; - LOCK_DEBUG (g_message ("%s: wrap rejig: now=0x%x then=0x%x delta=0x%x", __func__, now, then, now-then)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": wrap rejig: now=0x%x then=0x%x delta=0x%x", now, then, now-then)); } delta = now - then; @@ -642,7 +644,7 @@ retry_contended: } /* We must have timed out */ - LOCK_DEBUG (g_message ("%s: (%d) timed out waiting, returning FALSE", __func__, id)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": (%d) timed out waiting, returning FALSE", id)); mono_profiler_monitor_event (obj, MONO_PROFILER_MONITOR_FAIL); @@ -670,7 +672,7 @@ mono_monitor_exit (MonoObject *obj) MonoThreadsSync *mon; guint32 nest; - LOCK_DEBUG (g_message ("%s: (%d) Unlocking %p", __func__, GetCurrentThreadId (), obj)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": (%d) Unlocking %p", GetCurrentThreadId (), obj)); if (G_UNLIKELY (!obj)) { mono_raise_exception (mono_get_exception_argument_null ("obj")); @@ -699,7 +701,8 @@ mono_monitor_exit (MonoObject *obj) nest = mon->nest - 1; if (nest == 0) { - LOCK_DEBUG (g_message ("%s: (%d) Object %p is now unlocked", __func__, GetCurrentThreadId (), obj)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION + ": (%d) Object %p is now unlocked", GetCurrentThreadId (), obj)); /* object is now unlocked, leave nest==1 so we don't * need to set it when the lock is reacquired @@ -717,7 +720,8 @@ mono_monitor_exit (MonoObject *obj) ReleaseSemaphore (mon->entry_sem, 1, NULL); } } else { - LOCK_DEBUG (g_message ("%s: (%d) Object %p is now locked %d times", __func__, GetCurrentThreadId (), obj, nest)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION + ": (%d) Object %p is now locked %d times", GetCurrentThreadId (), obj, nest)); mon->nest = nest; } } @@ -1131,7 +1135,8 @@ ves_icall_System_Threading_Monitor_Monitor_test_owner (MonoObject *obj) { MonoThreadsSync *mon; - LOCK_DEBUG (g_message ("%s: Testing if %p is owned by thread %d", __func__, obj, GetCurrentThreadId())); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION + ": Testing if %p is owned by thread %d", obj, GetCurrentThreadId())); mon = obj->synchronisation; #ifdef HAVE_MOVING_COLLECTOR @@ -1160,7 +1165,8 @@ ves_icall_System_Threading_Monitor_Monitor_test_synchronised (MonoObject *obj) { MonoThreadsSync *mon; - LOCK_DEBUG (g_message("%s: (%d) Testing if %p is owned by any thread", __func__, GetCurrentThreadId (), obj)); + LOCK_DEBUG (g_message(G_GNUC_PRETTY_FUNCTION + ": (%d) Testing if %p is owned by any thread", GetCurrentThreadId (), obj)); mon = obj->synchronisation; #ifdef HAVE_MOVING_COLLECTOR @@ -1194,7 +1200,8 @@ ves_icall_System_Threading_Monitor_Monitor_pulse (MonoObject *obj) { MonoThreadsSync *mon; - LOCK_DEBUG (g_message ("%s: (%d) Pulsing %p", __func__, GetCurrentThreadId (), obj)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": (%d) Pulsing %p", + GetCurrentThreadId (), obj)); mon = obj->synchronisation; #ifdef HAVE_MOVING_COLLECTOR @@ -1218,10 +1225,13 @@ ves_icall_System_Threading_Monitor_Monitor_pulse (MonoObject *obj) return; } - LOCK_DEBUG (g_message ("%s: (%d) %d threads waiting", __func__, GetCurrentThreadId (), g_slist_length (mon->wait_list))); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": (%d) %d threads waiting", + GetCurrentThreadId (), g_slist_length (mon->wait_list))); if (mon->wait_list != NULL) { - LOCK_DEBUG (g_message ("%s: (%d) signalling and dequeuing handle %p", __func__, GetCurrentThreadId (), mon->wait_list->data)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION + ": (%d) signalling and dequeuing handle %p", + GetCurrentThreadId (), mon->wait_list->data)); SetEvent (mon->wait_list->data); mon->wait_list = g_slist_remove (mon->wait_list, mon->wait_list->data); @@ -1233,7 +1243,8 @@ ves_icall_System_Threading_Monitor_Monitor_pulse_all (MonoObject *obj) { MonoThreadsSync *mon; - LOCK_DEBUG (g_message("%s: (%d) Pulsing all %p", __func__, GetCurrentThreadId (), obj)); + LOCK_DEBUG (g_message(G_GNUC_PRETTY_FUNCTION ": (%d) Pulsing all %p", + GetCurrentThreadId (), obj)); mon = obj->synchronisation; #ifdef HAVE_MOVING_COLLECTOR @@ -1257,10 +1268,13 @@ ves_icall_System_Threading_Monitor_Monitor_pulse_all (MonoObject *obj) return; } - LOCK_DEBUG (g_message ("%s: (%d) %d threads waiting", __func__, GetCurrentThreadId (), g_slist_length (mon->wait_list))); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": (%d) %d threads waiting", + GetCurrentThreadId (), g_slist_length (mon->wait_list))); while (mon->wait_list != NULL) { - LOCK_DEBUG (g_message ("%s: (%d) signalling and dequeuing handle %p", __func__, GetCurrentThreadId (), mon->wait_list->data)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION + ": (%d) signalling and dequeuing handle %p", + GetCurrentThreadId (), mon->wait_list->data)); SetEvent (mon->wait_list->data); mon->wait_list = g_slist_remove (mon->wait_list, mon->wait_list->data); @@ -1278,7 +1292,9 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms) gint32 regain; MonoThread *thread = mono_thread_current (); - LOCK_DEBUG (g_message ("%s: (%d) Trying to wait for %p with timeout %dms", __func__, GetCurrentThreadId (), obj, ms)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION + ": (%d) Trying to wait for %p with timeout %dms", + GetCurrentThreadId (), obj, ms)); mon = obj->synchronisation; #ifdef HAVE_MOVING_COLLECTOR @@ -1311,7 +1327,8 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms) return FALSE; } - LOCK_DEBUG (g_message ("%s: (%d) queuing handle %p", __func__, GetCurrentThreadId (), event)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": (%d) queuing handle %p", + GetCurrentThreadId (), event)); mono_thread_current_check_pending_interrupt (); @@ -1324,7 +1341,8 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms) mon->nest = 1; mono_monitor_exit (obj); - LOCK_DEBUG (g_message ("%s: (%d) Unlocked %p lock %p", __func__, GetCurrentThreadId (), obj, mon)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": (%d) Unlocked %p lock %p", + GetCurrentThreadId (), obj, mon)); /* There's no race between unlocking mon and waiting for the * event, because auto reset events are sticky, and this event @@ -1361,7 +1379,8 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms) mon->nest = nest; - LOCK_DEBUG (g_message ("%s: (%d) Regained %p lock %p", __func__, GetCurrentThreadId (), obj, mon)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": (%d) Regained %p lock %p", + GetCurrentThreadId (), obj, mon)); if (ret == WAIT_TIMEOUT) { /* Poll the event again, just in case it was signalled @@ -1381,10 +1400,12 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms) */ if (ret == WAIT_OBJECT_0) { - LOCK_DEBUG (g_message ("%s: (%d) Success", __func__, GetCurrentThreadId ())); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": (%d) Success", + GetCurrentThreadId ())); success = TRUE; } else { - LOCK_DEBUG (g_message ("%s: (%d) Wait failed, dequeuing handle %p", __func__, GetCurrentThreadId (), event)); + LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": (%d) Wait failed, dequeuing handle %p", + GetCurrentThreadId (), event)); /* No pulse, so we have to remove ourself from the * wait queue */ diff --git a/mono/metadata/mono-config.c b/mono/metadata/mono-config.c index 141b594766d..7f2a3ebe193 100644 --- a/mono/metadata/mono-config.c +++ b/mono/metadata/mono-config.c @@ -326,7 +326,7 @@ legacyUEP_start (gpointer user_data, (attribute_names [0] != NULL) && (strcmp (attribute_names [0], "enabled") == 0)) { if ((strcmp (attribute_values [0], "1") == 0) || - (g_ascii_strcasecmp (attribute_values [0], "true") == 0)) { + (g_strcasecmp (attribute_values [0], "true") == 0)) { mono_runtime_unhandled_exception_policy_set (MONO_UNHANDLED_POLICY_LEGACY); } } diff --git a/mono/metadata/mono-debug.c b/mono/metadata/mono-debug.c index 82722ca453f..9e38dd22531 100644 --- a/mono/metadata/mono-debug.c +++ b/mono/metadata/mono-debug.c @@ -595,8 +595,8 @@ mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDoma is_wrapper = TRUE; } - max_size = (5 * 5) + 1 + (10 * jit->num_line_numbers) + - (25 + sizeof (gpointer)) * (1 + jit->num_params + jit->num_locals); + max_size = 24 + 8 * jit->num_line_numbers + + (20 + sizeof (gpointer)) * (1 + jit->num_params + jit->num_locals); if (max_size > BUFSIZ) ptr = oldptr = g_malloc (max_size); diff --git a/mono/metadata/mono-mlist.c b/mono/metadata/mono-mlist.c index e0fda55dd90..25405fa1240 100644 --- a/mono/metadata/mono-mlist.c +++ b/mono/metadata/mono-mlist.c @@ -41,7 +41,6 @@ mono_mlist_alloc (MonoObject *data) if (!monolist_item_vtable) { MonoClass *klass = mono_class_from_name (mono_defaults.corlib, "System", "MonoListItem"); monolist_item_vtable = mono_class_vtable (mono_get_root_domain (), klass); - g_assert (monolist_item_vtable); } res = (MonoMList*)mono_object_new_fast (monolist_item_vtable); MONO_OBJECT_SETREF (res, data, data); diff --git a/mono/metadata/normalization-tables.h b/mono/metadata/normalization-tables.h index c8ecc8ec4a1..82c36d3d7ea 100644 --- a/mono/metadata/normalization-tables.h +++ b/mono/metadata/normalization-tables.h @@ -3624,10 +3624,10 @@ static const guint16 mapIdxToComposite [] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,1570,0,0,1571,0,
0,1573,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,1572,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,1574,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -3647,12 +3647,11 @@ static const guint16 mapIdxToComposite [] = { 0,0,3955,0,0,3957,0,0,3969,0,0,4025,0,0,3987,0,
0,3997,0,0,4002,0,0,4007,0,0,4012,0,0,3958,0,0,
0,0,0,3960,0,0,0,0,0,4134,0,0,0,0,0,0,
-0,0,6918,0,0,6920,0,0,6922,0,0,6924,0,0,6926,0,
-0,6930,0,0,6971,0,0,6973,0,0,6976,0,0,6977,0,0,
-6979,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,7736,0,0,7737,0,0,7772,0,0,7773,0,0,7784,
-0,0,7785,0,0,7852,0,0,7862,0,0,7853,0,0,7863,0,
-0,7878,0,0,7879,0,0,7896,0,0,7897,0,0,7938,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
7940,0,0,7942,0,0,8064,0,0,7939,0,0,7941,0,0,7943,
0,0,8065,0,0,8066,0,0,8067,0,0,8068,0,0,8069,0,
0,8070,0,0,8071,0,0,7946,0,0,7948,0,0,7950,0,0,
@@ -3825,8 +3824,6 @@ static const guint16 mapIdxToComposite [] = { 0,64045,0,63802,0,63776,0,0,0,63808,0,63880,0,63987,0,0,
0,0,0,0,0,0,0,63881,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,64216,0,0,0,0,0,63940,0,64217,
-0,63752,0,0,0,0,0,0,0,64300,0,0,64301,0,0,64208,
-0,64207,0,64209,0,64213,0,64214,0,64215,0,0,0,0,0,0,
0};
static const guint8 combiningClass [] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
diff --git a/mono/metadata/object.c b/mono/metadata/object.c index 36a91ca2427..54183842e9e 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -262,10 +262,7 @@ mono_runtime_class_init_full (MonoVTable *vtable, gboolean raise_exception) mono_image_check_for_module_cctor (klass->image); if (klass->image->has_module_cctor) { MonoClass *module_klass = mono_class_get (klass->image, MONO_TOKEN_TYPE_DEF | 1); - MonoVTable *module_vtable = mono_class_vtable_full (vtable->domain, module_klass, raise_exception); - if (!module_vtable) - return NULL; - mono_runtime_class_init (module_vtable); + mono_runtime_class_init (mono_class_vtable (vtable->domain, module_klass)); } } method = mono_class_get_cctor (klass); @@ -1663,7 +1660,7 @@ mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtab mono_domain_unlock (domain); } -static MonoVTable *mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean raise_on_error); +static MonoVTable *mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class); /** * mono_class_vtable: @@ -1677,36 +1674,17 @@ static MonoVTable *mono_class_create_runtime_vtable (MonoDomain *domain, MonoCla MonoVTable * mono_class_vtable (MonoDomain *domain, MonoClass *class) { - return mono_class_vtable_full (domain, class, FALSE); -} - -/** - * mono_class_vtable_full: - * @domain: the application domain - * @class: the class to initialize - * @raise_on_error if an exception should be raised on failure or not - * - * VTables are domain specific because we create domain specific code, and - * they contain the domain specific static class data. - */ -MonoVTable * -mono_class_vtable_full (MonoDomain *domain, MonoClass *class, gboolean raise_on_error) -{ MonoClassRuntimeInfo *runtime_info; g_assert (class); - if (class->exception_type) { - if (raise_on_error) - mono_raise_exception (mono_class_get_exception_for_failure (class)); - return NULL; - } - /* this check can be inlined in jitted code, too */ runtime_info = class->runtime_info; if (runtime_info && runtime_info->max_domain >= domain->domain_id && runtime_info->domain_vtables [domain->domain_id]) return runtime_info->domain_vtables [domain->domain_id]; - return mono_class_create_runtime_vtable (domain, class, raise_on_error); + if (class->exception_type) + return NULL; + return mono_class_create_runtime_vtable (domain, class); } /** @@ -1731,7 +1709,7 @@ mono_class_try_get_vtable (MonoDomain *domain, MonoClass *class) } static MonoVTable * -mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean raise_on_error) +mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class) { MonoVTable *vt; MonoClassRuntimeInfo *runtime_info, *old_info; @@ -1753,36 +1731,17 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean return runtime_info->domain_vtables [domain->domain_id]; } if (!class->inited || class->exception_type) { - if (!mono_class_init (class) || class->exception_type) { + if (!mono_class_init (class) || class->exception_type){ + MonoException *exc; mono_domain_unlock (domain); mono_loader_unlock (); - if (raise_on_error) - mono_raise_exception (mono_class_get_exception_for_failure (class)); - return NULL; + exc = mono_class_get_exception_for_failure (class); + g_assert (exc); + mono_raise_exception (exc); } } - /* Array types require that their element type be valid*/ - if (class->byval_arg.type == MONO_TYPE_ARRAY || class->byval_arg.type == MONO_TYPE_SZARRAY) { - MonoClass *element_class = class->element_class; - if (!element_class->inited) - mono_class_init (element_class); - - /*mono_class_init can leave the vtable layout to be lazily done and we can't afford this here*/ - if (element_class->exception_type == MONO_EXCEPTION_NONE && !element_class->vtable_size) - mono_class_setup_vtable (element_class); - - if (element_class->exception_type != MONO_EXCEPTION_NONE) { - /*Can happen if element_class only got bad after mono_class_setup_vtable*/ - if (class->exception_type == MONO_EXCEPTION_NONE) - mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL); - mono_domain_unlock (domain); - mono_loader_unlock (); - if (raise_on_error) - mono_raise_exception (mono_class_get_exception_for_failure (class)); - return NULL; - } - } + mono_class_init (class); /* * For some classes, mono_class_init () already computed class->vtable_size, and @@ -1794,8 +1753,6 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean if (class->exception_type) { mono_domain_unlock (domain); mono_loader_unlock (); - if (raise_on_error) - mono_raise_exception (mono_class_get_exception_for_failure (class)); return NULL; } @@ -1995,15 +1952,16 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean mono_loader_unlock (); /* Initialization is now complete, we can throw if the InheritanceDemand aren't satisfied */ - if (mono_is_security_manager_active () && (class->exception_type == MONO_EXCEPTION_SECURITY_INHERITANCEDEMAND) && raise_on_error) - mono_raise_exception (mono_class_get_exception_for_failure (class)); + if (mono_is_security_manager_active () && (class->exception_type == MONO_EXCEPTION_SECURITY_INHERITANCEDEMAND)) { + MonoException *exc = mono_class_get_exception_for_failure (class); + g_assert (exc); + mono_raise_exception (exc); + } /* make sure the parent is initialized */ - /*FIXME shouldn't this fail the current type?*/ if (class->parent) - mono_class_vtable_full (domain, class->parent, raise_on_error); + mono_class_vtable (domain, class->parent); - /*FIXME check for OOM*/ vt->type = mono_type_get_object (domain, &class->byval_arg); if (class->contextbound) vt->remote = 1; @@ -2034,7 +1992,6 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono gpointer *interface_offsets; vt = mono_class_vtable (domain, class); - g_assert (vt); /*FIXME property handle failure*/ max_interface_id = vt->max_interface_id; /* Calculate vtable space for extra interfaces */ @@ -2882,12 +2839,6 @@ mono_field_get_value_object (MonoDomain *domain, MonoClassField *field, MonoObje if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) { is_static = TRUE; vtable = mono_class_vtable (domain, field->parent); - if (!vtable) { - char *name = mono_type_get_full_name (field->parent); - g_warning ("Could not retrieve the vtable for type %s in mono_field_get_value_object", name); - g_free (name); - return NULL; - } if (!vtable->initialized) mono_runtime_class_init (vtable); } @@ -3815,19 +3766,12 @@ mono_object_allocate_spec (size_t size, MonoVTable *vtable) * looked up using @klass. This will not invoke any constructors, * so the consumer of this routine has to invoke any constructors on * its own to initialize the object. - * - * It returns NULL on failure. */ MonoObject * mono_object_new (MonoDomain *domain, MonoClass *klass) { - MonoVTable *vtable; - MONO_ARCH_SAVE_REGS; - vtable = mono_class_vtable (domain, klass); - if (!vtable) - return NULL; - return mono_object_new_specific (vtable); + return mono_object_new_specific (mono_class_vtable (domain, klass)); } /** @@ -4217,7 +4161,7 @@ mono_array_new_full (MonoDomain *domain, MonoClass *array_class, mono_array_size * Following three lines almost taken from mono_object_new (): * they need to be kept in sync. */ - vtable = mono_class_vtable_full (domain, array_class, TRUE); + vtable = mono_class_vtable (domain, array_class); if (!array_class->has_references) { o = mono_object_allocate_ptrfree (byte_len, vtable); #if NEED_TO_ZERO_PTRFREE @@ -4266,7 +4210,7 @@ mono_array_new (MonoDomain *domain, MonoClass *eclass, mono_array_size_t n) ac = mono_array_class_get (eclass, 1); g_assert (ac); - return mono_array_new_specific (mono_class_vtable_full (domain, ac, TRUE), n); + return mono_array_new_specific (mono_class_vtable (domain, ac), n); } /** @@ -4362,7 +4306,6 @@ mono_string_new_size (MonoDomain *domain, gint32 len) mono_gc_out_of_memory (-1); vtable = mono_class_vtable (domain, mono_defaults.string_class); - g_assert (vtable); s = mono_object_allocate_ptrfree (size, vtable); @@ -4488,8 +4431,6 @@ mono_value_box (MonoDomain *domain, MonoClass *class, gpointer value) return mono_nullable_box (value, class); vtable = mono_class_vtable (domain, class); - if (!vtable) - return NULL; size = mono_class_instance_size (class); res = mono_object_new_alloc_specific (vtable); if (G_UNLIKELY (profile_allocs)) @@ -5084,11 +5025,11 @@ mono_wait_handle_new (MonoDomain *domain, HANDLE handle) gpointer params [1]; static MonoMethod *handle_set; - res = (MonoWaitHandle *)mono_object_new (domain, mono_defaults.manualresetevent_class); + res = (MonoWaitHandle *)mono_object_new (domain, mono_defaults.waithandle_class); /* Even though this method is virtual, it's safe to invoke directly, since the object type matches. */ if (!handle_set) - handle_set = mono_class_get_property_from_name (mono_defaults.manualresetevent_class, "Handle")->set; + handle_set = mono_class_get_property_from_name (mono_defaults.waithandle_class, "Handle")->set; params [0] = &handle; mono_runtime_invoke (handle_set, res, params, NULL); @@ -5103,8 +5044,8 @@ mono_wait_handle_get_handle (MonoWaitHandle *handle) static MonoClassField *f_safe_handle; if (!f_os_handle && !f_safe_handle) { - f_os_handle = mono_class_get_field_from_name (mono_defaults.manualresetevent_class, "os_handle"); - f_safe_handle = mono_class_get_field_from_name (mono_defaults.manualresetevent_class, "safe_wait_handle"); + f_os_handle = mono_class_get_field_from_name (mono_defaults.waithandle_class, "os_handle"); + f_safe_handle = mono_class_get_field_from_name (mono_defaults.waithandle_class, "safe_wait_handle"); } if (f_os_handle) { @@ -5539,21 +5480,42 @@ mono_method_return_message_restore (MonoMethod *method, gpointer *params, MonoAr arg = mono_array_get (out_args, gpointer, j); type = pt->type; - g_assert (type != MONO_TYPE_VOID); - - if (MONO_TYPE_IS_REFERENCE (pt)) { - mono_gc_wbarrier_generic_store (*((MonoObject ***)params [i]), (MonoObject *)arg); - } else { + switch (type) { + case MONO_TYPE_VOID: + g_assert_not_reached (); + break; + case MONO_TYPE_U1: + case MONO_TYPE_I1: + case MONO_TYPE_BOOLEAN: + case MONO_TYPE_U2: + case MONO_TYPE_I2: + case MONO_TYPE_CHAR: + case MONO_TYPE_U4: + case MONO_TYPE_I4: + case MONO_TYPE_I8: + case MONO_TYPE_U8: + case MONO_TYPE_R4: + case MONO_TYPE_R8: + case MONO_TYPE_VALUETYPE: { if (arg) { - MonoClass *class = ((MonoObject*)arg)->vtable->klass; - size = mono_class_value_size (class, NULL); + size = mono_class_value_size (((MonoObject*)arg)->vtable->klass, NULL); memcpy (*((gpointer *)params [i]), arg + sizeof (MonoObject), size); - if (class->has_references) - mono_gc_wbarrier_value_copy (*((gpointer *)params [i]), arg + sizeof (MonoObject), 1, class); - } else { + } + else { size = mono_class_value_size (mono_class_from_mono_type (pt), NULL); memset (*((gpointer *)params [i]), 0, size); } + break; + } + case MONO_TYPE_STRING: + case MONO_TYPE_CLASS: + case MONO_TYPE_ARRAY: + case MONO_TYPE_SZARRAY: + case MONO_TYPE_OBJECT: + **((MonoObject ***)params [i]) = (MonoObject *)arg; + break; + default: + g_assert_not_reached (); } j++; diff --git a/mono/metadata/process.c b/mono/metadata/process.c index 0532b7a0334..ab6ed49a3ad 100644 --- a/mono/metadata/process.c +++ b/mono/metadata/process.c @@ -26,9 +26,7 @@ /* FIXME: fix this code to not depend so much on the inetrnals */ #include <mono/metadata/class-internals.h> -#define LOGDEBUG(...) -/* define LOGDEBUG(...) g_message(__VA_ARGS__) */ - +#undef DEBUG HANDLE ves_icall_System_Diagnostics_Process_GetProcess_internal (guint32 pid) { @@ -62,7 +60,8 @@ void ves_icall_System_Diagnostics_Process_Process_free_internal (MonoObject *thi MONO_ARCH_SAVE_REGS; #ifdef THREAD_DEBUG - g_message ("%s: Closing process %p, handle %p", __func__, this, process); + g_message (G_GNUC_PRETTY_FUNCTION ": Closing process %p, handle %p", + this, process); #endif CloseHandle (process); @@ -92,7 +91,10 @@ static void process_set_field_object (MonoObject *obj, const gchar *fieldname, { MonoClassField *field; - LOGDEBUG (g_message ("%s: Setting field %s to object at %p", __func__, fieldname, data)); +#ifdef DEBUG + g_message (G_GNUC_PRETTY_FUNCTION ": Setting field %s to object at %p", + fieldname, data); +#endif field=mono_class_get_field_from_name (mono_object_class (obj), fieldname); @@ -106,7 +108,10 @@ static void process_set_field_string (MonoObject *obj, const gchar *fieldname, MonoClassField *field; MonoString *string; - LOGDEBUG (g_message ("%s: Setting field %s to [%s]", __func__, fieldname, g_utf16_to_utf8 (val, len, NULL, NULL, NULL))); +#ifdef DEBUG + g_message (G_GNUC_PRETTY_FUNCTION ": Setting field %s to [%s]", + fieldname, g_utf16_to_utf8 (val, len, NULL, NULL, NULL)); +#endif string=mono_string_new_utf16 (mono_object_domain (obj), val, len); @@ -121,7 +126,10 @@ static void process_set_field_int (MonoObject *obj, const gchar *fieldname, { MonoClassField *field; - LOGDEBUG (g_message ("%s: Setting field %s to %d", __func__,fieldname, val)); +#ifdef DEBUG + g_message (G_GNUC_PRETTY_FUNCTION ": Setting field %s to %d", + fieldname, val); +#endif field=mono_class_get_field_from_name (mono_object_class (obj), fieldname); @@ -133,7 +141,9 @@ static void process_set_field_intptr (MonoObject *obj, const gchar *fieldname, { MonoClassField *field; - LOGDEBUG (g_message ("%s: Setting field %s to %p", __func__, fieldname, val)); +#ifdef DEBUG + g_message ("%s: Setting field %s to %p", __func__, fieldname, val); +#endif field=mono_class_get_field_from_name (mono_object_class (obj), fieldname); @@ -145,7 +155,10 @@ static void process_set_field_bool (MonoObject *obj, const gchar *fieldname, { MonoClassField *field; - LOGDEBUG (g_message ("%s: Setting field %s to %s", __func__, fieldname, val?"TRUE":"FALSE")); +#ifdef DEBUG + g_message (G_GNUC_PRETTY_FUNCTION ": Setting field %s to %s", + fieldname, val?"TRUE":"FALSE"); +#endif field=mono_class_get_field_from_name (mono_object_class (obj), fieldname); @@ -177,12 +190,17 @@ static void process_module_string_read (MonoObject *filever, gpointer data, lang_key_utf8 = g_strdup_printf (key, lang_lo, lang_hi, 0x04, 0xb0); - LOGDEBUG (g_message ("%s: asking for [%s]", __func__, lang_key_utf8)); +#ifdef DEBUG + g_message ("%s: asking for [%s]", __func__, lang_key_utf8); +#endif lang_key = g_utf8_to_utf16 (lang_key_utf8, -1, NULL, NULL, NULL); if (VerQueryValue (data, lang_key, (gpointer *)&buffer, &chars) && chars > 0) { - LOGDEBUG (g_message ("%s: found %d chars of [%s]", __func__, chars, g_utf16_to_utf8 (buffer, chars, NULL, NULL, NULL))); +#ifdef DEBUG + g_message ("%s: found %d chars of [%s]", __func__, chars, + g_utf16_to_utf8 (buffer, chars, NULL, NULL, NULL)); +#endif /* chars includes trailing null */ process_set_field_string (filever, fieldname, buffer, chars - 1); } else { @@ -249,7 +267,9 @@ static void process_get_fileversion (MonoObject *filever, gunichar2 *filename) if (VerQueryValue (data, query, (gpointer *)&ffi, &ffi_size)) { - LOGDEBUG (g_message ("%s: recording assembly: FileName [%s] FileVersionInfo [%d.%d.%d.%d]", __func__, g_utf16_to_utf8 (filename, -1, NULL, NULL, NULL), HIWORD (ffi->dwFileVersionMS), LOWORD (ffi->dwFileVersionMS), HIWORD (ffi->dwFileVersionLS), LOWORD (ffi->dwFileVersionLS))); +#ifdef DEBUG + g_message (G_GNUC_PRETTY_FUNCTION ": recording assembly: FileName [%s] FileVersionInfo [%d.%d.%d.%d]", g_utf16_to_utf8 (filename, -1, NULL, NULL, NULL), HIWORD (ffi->dwFileVersionMS), LOWORD (ffi->dwFileVersionMS), HIWORD (ffi->dwFileVersionLS), LOWORD (ffi->dwFileVersionLS)); +#endif process_set_field_int (filever, "filemajorpart", HIWORD (ffi->dwFileVersionMS)); process_set_field_int (filever, "fileminorpart", LOWORD (ffi->dwFileVersionMS)); @@ -281,7 +301,9 @@ static void process_get_fileversion (MonoObject *filever, gunichar2 *filename) /* use the first language ID we see */ if (trans_size >= 4) { - LOGDEBUG (g_message("%s: %s has 0x%0x 0x%0x 0x%0x 0x%0x", __func__, g_utf16_to_utf8 (filename, -1, NULL, NULL, NULL), trans_data[0], trans_data[1], trans_data[2], trans_data[3])); +#ifdef DEBUG + g_message("%s: %s has 0x%0x 0x%0x 0x%0x 0x%0x", __func__, g_utf16_to_utf8 (filename, -1, NULL, NULL, NULL), trans_data[0], trans_data[1], trans_data[2], trans_data[3]); +#endif lang = (trans_data[0]) | (trans_data[1] << 8) | (trans_data[2] << 16) | @@ -850,7 +872,9 @@ gint32 ves_icall_System_Diagnostics_Process_ExitCode_internal (HANDLE process) GetExitCodeProcess (process, &code); - LOGDEBUG (g_message ("%s: process exit code is %d", __func__, code)); +#ifdef DEBUG + g_message (G_GNUC_PRETTY_FUNCTION ": process exit code is %d", code); +#endif return(code); } @@ -876,7 +900,10 @@ MonoString *ves_icall_System_Diagnostics_Process_ProcessName_internal (HANDLE pr return(NULL); } - LOGDEBUG (g_message ("%s: process name is [%s]", __func__, g_utf16_to_utf8 (name, -1, NULL, NULL, NULL))); +#ifdef DEBUG + g_message (G_GNUC_PRETTY_FUNCTION ": process name is [%s]", + g_utf16_to_utf8 (name, -1, NULL, NULL, NULL)); +#endif string=mono_string_new_utf16 (mono_domain_get (), name, len); @@ -997,7 +1024,9 @@ ves_icall_System_Diagnostics_Process_ProcessHandle_duplicate (HANDLE process) MONO_ARCH_SAVE_REGS; - LOGDEBUG (g_message ("%s: Duplicating process handle %p", __func__, process)); +#ifdef DEBUG + g_message ("%s: Duplicating process handle %p", __func__, process); +#endif DuplicateHandle (GetCurrentProcess (), process, GetCurrentProcess (), &ret, THREAD_ALL_ACCESS, TRUE, 0); @@ -1010,7 +1039,9 @@ ves_icall_System_Diagnostics_Process_ProcessHandle_close (HANDLE process) { MONO_ARCH_SAVE_REGS; - LOGDEBUG (g_message ("%s: Closing process handle %p", __func__, process)); +#ifdef DEBUG + g_message ("%s: Closing process handle %p", __func__, process); +#endif CloseHandle (process); } diff --git a/mono/metadata/reflection.c b/mono/metadata/reflection.c index 9722a02cfad..e472ed31d38 100644 --- a/mono/metadata/reflection.c +++ b/mono/metadata/reflection.c @@ -38,7 +38,6 @@ #include <mono/metadata/mempool-internals.h> #include <mono/metadata/security-core-clr.h> #include <mono/metadata/debug-helpers.h> -#include <mono/utils/mono-string.h> #if HAVE_SGEN_GC static void* reflection_info_desc = NULL; @@ -7236,7 +7235,7 @@ mono_reflection_get_type_internal (MonoImage *rootimage, MonoImage* image, MonoT while ((klass = mono_class_get_nested_types (parent, &iter))) { if (ignorecase) { - if (mono_utf8_strcasecmp (klass->name, mod->data) == 0) + if (g_strcasecmp (klass->name, mod->data) == 0) break; } else { if (strcmp (klass->name, mod->data) == 0) diff --git a/mono/metadata/socket-io.c b/mono/metadata/socket-io.c index a1856b151d9..7c541783388 100644 --- a/mono/metadata/socket-io.c +++ b/mono/metadata/socket-io.c @@ -83,8 +83,7 @@ #undef AF_INET6 #endif -#define LOGDEBUG(...) -/* define LOGDEBUG(...) g_message(__VA_ARGS__) */ +#undef DEBUG static gint32 convert_family(MonoAddressFamily mono_family) { @@ -689,7 +688,6 @@ static gint32 get_family_hint(void) ipv4_field = mono_class_get_field_from_name (socket_class, "ipv4Supported"); ipv6_field = mono_class_get_field_from_name (socket_class, "ipv6Supported"); vtable = mono_class_vtable (mono_domain_get (), socket_class); - g_assert (vtable); mono_runtime_class_init (vtable); mono_field_static_get_value (vtable, ipv4_field, &ipv4_enabled); @@ -773,7 +771,9 @@ void ves_icall_System_Net_Sockets_Socket_Close_internal(SOCKET sock, { MONO_ARCH_SAVE_REGS; - LOGDEBUG (g_message ("%s: closing 0x%x", __func__, sock)); +#ifdef DEBUG + g_message (G_GNUC_PRETTY_FUNCTION ": closing 0x%x", sock); +#endif *error = 0; @@ -787,7 +787,9 @@ gint32 ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal(voi { MONO_ARCH_SAVE_REGS; - LOGDEBUG (g_message("%s: returning %d", __func__, WSAGetLastError())); +#ifdef DEBUG + g_message(G_GNUC_PRETTY_FUNCTION ": returning %d", WSAGetLastError()); +#endif return(WSAGetLastError()); } @@ -1009,7 +1011,9 @@ extern MonoObject *ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal(SO return(NULL); } - LOGDEBUG (g_message("%s: bound to %s port %d", __func__, inet_ntoa(((struct sockaddr_in *)&sa)->sin_addr), ntohs(((struct sockaddr_in *)&sa)->sin_port))); +#ifdef DEBUG + g_message(G_GNUC_PRETTY_FUNCTION ": bound to %s port %d", inet_ntoa(((struct sockaddr_in *)&sa)->sin_addr), ntohs(((struct sockaddr_in *)&sa)->sin_port)); +#endif return(create_object_from_sockaddr((struct sockaddr *)sa, salen, error)); @@ -1033,7 +1037,9 @@ extern MonoObject *ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal(S return(NULL); } - LOGDEBUG (g_message("%s: connected to %s port %d", __func__, inet_ntoa(((struct sockaddr_in *)&sa)->sin_addr), ntohs(((struct sockaddr_in *)&sa)->sin_port))); +#ifdef DEBUG + g_message(G_GNUC_PRETTY_FUNCTION ": connected to %s port %d", inet_ntoa(((struct sockaddr_in *)&sa)->sin_addr), ntohs(((struct sockaddr_in *)&sa)->sin_port)); +#endif return(create_object_from_sockaddr((struct sockaddr *)sa, salen, error)); @@ -1166,7 +1172,9 @@ extern void ves_icall_System_Net_Sockets_Socket_Bind_internal(SOCKET sock, MonoO return; } - LOGDEBUG (g_message("%s: binding to %s port %d", __func__, inet_ntoa(((struct sockaddr_in *)sa)->sin_addr), ntohs (((struct sockaddr_in *)sa)->sin_port))); +#ifdef DEBUG + g_message(G_GNUC_PRETTY_FUNCTION ": binding to %s port %d", inet_ntoa(((struct sockaddr_in *)sa)->sin_addr), ntohs (((struct sockaddr_in *)sa)->sin_port)); +#endif ret = _wapi_bind (sock, sa, sa_size); if(ret==SOCKET_ERROR) { @@ -1272,7 +1280,9 @@ extern void ves_icall_System_Net_Sockets_Socket_Connect_internal(SOCKET sock, Mo return; } - LOGDEBUG (g_message("%s: connecting to %s port %d", __func__, inet_ntoa(((struct sockaddr_in *)sa)->sin_addr), ntohs (((struct sockaddr_in *)sa)->sin_port))); +#ifdef DEBUG + g_message(G_GNUC_PRETTY_FUNCTION ": connecting to %s port %d", inet_ntoa(((struct sockaddr_in *)sa)->sin_addr), ntohs (((struct sockaddr_in *)sa)->sin_port)); +#endif ret = _wapi_connect (sock, sa, sa_size); if(ret==SOCKET_ERROR) { @@ -1310,7 +1320,10 @@ extern void ves_icall_System_Net_Sockets_Socket_Disconnect_internal(SOCKET sock, *error = 0; - LOGDEBUG (g_message("%s: disconnecting from socket %p (reuse %d)", __func__, sock, reuse)); +#ifdef DEBUG + g_message("%s: disconnecting from socket %p (reuse %d)", __func__, + sock, reuse); +#endif /* I _think_ the extension function pointers need to be looked * up for each socket. FIXME: check the best way to store @@ -1505,11 +1518,15 @@ gint32 ves_icall_System_Net_Sockets_Socket_Send_internal(SOCKET sock, MonoArray return(0); } - LOGDEBUG (g_message("%s: alen: %d", __func__, alen)); +#ifdef DEBUG + g_message(G_GNUC_PRETTY_FUNCTION ": alen: %d", alen); +#endif buf=mono_array_addr(buffer, guchar, offset); - LOGDEBUG (g_message("%s: Sending %d bytes", __func__, count)); +#ifdef DEBUG + g_message(G_GNUC_PRETTY_FUNCTION ": Sending %d bytes", count); +#endif sendflags = convert_socketflags (flags); if (sendflags == -1) { @@ -1578,11 +1595,15 @@ gint32 ves_icall_System_Net_Sockets_Socket_SendTo_internal(SOCKET sock, MonoArra return(0); } - LOGDEBUG (g_message("%s: alen: %d", __func__, alen)); +#ifdef DEBUG + g_message(G_GNUC_PRETTY_FUNCTION ": alen: %d", alen); +#endif buf=mono_array_addr(buffer, guchar, offset); - LOGDEBUG (g_message("%s: Sending %d bytes", __func__, count)); +#ifdef DEBUG + g_message(G_GNUC_PRETTY_FUNCTION ": Sending %d bytes", count); +#endif sendflags = convert_socketflags (flags); if (sendflags == -1) { @@ -3014,12 +3035,14 @@ void mono_network_init(void) err=WSAStartup(MAKEWORD(2,0), &wsadata); if(err!=0) { - g_error("%s: Couldn't initialise networking", __func__); + g_error(G_GNUC_PRETTY_FUNCTION ": Couldn't initialise networking"); exit(-1); } - LOGDEBUG (g_message("%s: Using socket library: %s", __func__, wsadata.szDescription)); - LOGDEBUG (g_message("%s: Socket system status: %s", __func__, wsadata.szSystemStatus)); +#ifdef DEBUG + g_message(G_GNUC_PRETTY_FUNCTION ": Using socket library: %s", wsadata.szDescription); + g_message(G_GNUC_PRETTY_FUNCTION ": Socket system status: %s", wsadata.szSystemStatus); +#endif } void mono_network_cleanup(void) diff --git a/mono/metadata/threadpool.c b/mono/metadata/threadpool.c index 71250c1fa78..002726d9019 100644 --- a/mono/metadata/threadpool.c +++ b/mono/metadata/threadpool.c @@ -14,7 +14,6 @@ #define THREADS_PER_CPU 10 /* 20 + THREADS_PER_CPU * number of CPUs */ #define THREAD_EXIT_TIMEOUT 1000 -#define INITIAL_QUEUE_LENGTH 128 #include <mono/metadata/domain-internals.h> #include <mono/metadata/tabledefs.h> @@ -79,6 +78,10 @@ static int tp_inited; /* started idle threads */ static int tp_idle_started; + +/* we use this to store a reference to the AsyncResult to avoid GC */ +static MonoGHashTable *ares_htable = NULL; + static CRITICAL_SECTION ares_lock; static CRITICAL_SECTION io_queue_lock; static int pending_io_items; @@ -240,6 +243,9 @@ get_events_from_list (MonoMList *list) static void unregister_job (MonoAsyncResult *obj) { + EnterCriticalSection (&ares_lock); + mono_g_hash_table_remove (ares_htable, obj); + LeaveCriticalSection (&ares_lock); } static void @@ -268,7 +274,6 @@ async_invoke_io_thread (gpointer data) MonoDomain *domain; MonoThread *thread; const gchar *version; - int workers_io, min_io; thread = mono_thread_current (); @@ -348,22 +353,13 @@ async_invoke_io_thread (gpointer data) } if (!data) { - workers_io = (int) InterlockedCompareExchange (&io_worker_threads, 0, -1); - min_io = (int) InterlockedCompareExchange (&mono_io_min_worker_threads, 0, -1); - - while (!data && workers_io <= min_io) { - WaitForSingleObjectEx (io_job_added, INFINITE, TRUE); - if (THREAD_WANTS_A_BREAK (thread)) - mono_thread_interruption_checkpoint (); - - data = dequeue_job (&io_queue_lock, &async_io_queue); - workers_io = (int) InterlockedCompareExchange (&io_worker_threads, 0, -1); - min_io = (int) InterlockedCompareExchange (&mono_io_min_worker_threads, 0, -1); + if (InterlockedDecrement (&io_worker_threads) < 2) { + /* If we have pending items, keep the thread alive */ + if (InterlockedCompareExchange (&pending_io_items, 0, 0) != 0) { + InterlockedIncrement (&io_worker_threads); + continue; + } } - } - - if (!data) { - InterlockedDecrement (&io_worker_threads); return; } @@ -807,6 +803,10 @@ socket_io_init (SocketIOData *data) g_assert (data->pipe [0] != INVALID_SOCKET); closesocket (srv); #endif + mono_io_max_worker_threads = mono_max_worker_threads / 2; + if (mono_io_max_worker_threads < 10) + mono_io_max_worker_threads = 10; + data->sock_to_state = mono_g_hash_table_new_type (g_direct_hash, g_direct_equal, MONO_HASH_VALUE_GC); if (data->epoll_disabled) { @@ -834,7 +834,6 @@ socket_io_add_poll (MonoSocketAsyncResult *state) char msg [1]; MonoMList *list; SocketIOData *data = &socket_io_data; - int w; #if defined(PLATFORM_MACOSX) || defined(PLATFORM_BSD) || defined(PLATFORM_WIN32) || defined(PLATFORM_SOLARIS) /* select() for connect() does not work well on the Mac. Bug #75436. */ @@ -864,8 +863,7 @@ socket_io_add_poll (MonoSocketAsyncResult *state) LeaveCriticalSection (&data->io_lock); *msg = (char) state->operation; #ifndef PLATFORM_WIN32 - w = write (data->pipe [1], msg, 1); - w = w; + write (data->pipe [1], msg, 1); #else send ((SOCKET) data->pipe [1], msg, 1, 0); #endif @@ -1027,6 +1025,10 @@ mono_async_invoke (MonoAsyncResult *ares) SetEvent ((gpointer)(gsize)ac->wait_event); } mono_monitor_exit ((MonoObject *) ares); + + EnterCriticalSection (&ares_lock); + mono_g_hash_table_remove (ares_htable, ares); + LeaveCriticalSection (&ares_lock); } static void @@ -1072,10 +1074,12 @@ mono_thread_pool_init () if ((int) InterlockedCompareExchange (&tp_inited, 1, 0) == 1) return; + MONO_GC_REGISTER_ROOT (ares_htable); MONO_GC_REGISTER_ROOT (socket_io_data.sock_to_state); InitializeCriticalSection (&socket_io_data.io_lock); InitializeCriticalSection (&ares_lock); InitializeCriticalSection (&io_queue_lock); + ares_htable = mono_g_hash_table_new_type ((GHashFunc)mono_object_hash, NULL, MONO_HASH_KEY_VALUE_GC); job_added = CreateSemaphore (NULL, 0, 0x7fffffff, NULL); g_assert (job_added != NULL); if (g_getenv ("MONO_THREADS_PER_CPU") != NULL) { @@ -1087,10 +1091,6 @@ mono_thread_pool_init () cpu_count = mono_cpu_count (); mono_max_worker_threads = 20 + threads_per_cpu * cpu_count; mono_min_worker_threads = cpu_count; /* 1 idle thread per cpu */ - mono_io_max_worker_threads = mono_max_worker_threads / 2; - if (mono_io_max_worker_threads < 16) - mono_io_max_worker_threads = 16; - mono_io_min_worker_threads = cpu_count; async_call_klass = mono_class_from_name (mono_defaults.corlib, "System", "MonoAsyncCall"); g_assert (async_call_klass); @@ -1121,6 +1121,7 @@ mono_thread_pool_add (MonoObject *target, MonoMethodMessage *msg, MonoDelegate * LeaveCriticalSection (&ares_lock); return ares; } + mono_g_hash_table_insert (ares_htable, ares, ares); LeaveCriticalSection (&ares_lock); #ifndef DISABLE_SOCKETS @@ -1242,7 +1243,7 @@ append_job (CRITICAL_SECTION *cs, TPQueue *list, MonoObject *ar) } if (!list->array) { MONO_GC_REGISTER_ROOT (list->array); - list->array = mono_array_new_cached (mono_get_root_domain (), mono_defaults.object_class, INITIAL_QUEUE_LENGTH); + list->array = mono_array_new_cached (mono_get_root_domain (), mono_defaults.object_class, 16); } else { int count = list->next_elem - list->first_elem; /* slide the array or create a larger one if it's full */ @@ -1295,6 +1296,19 @@ clear_queue (CRITICAL_SECTION *cs, TPQueue *list, MonoDomain *domain) LeaveCriticalSection (cs); } +static GSList *clear_ares_htable_entries = NULL; + +static void +check_ares_htable_entry_for_domain (gpointer key, gpointer value, gpointer user_data) +{ + MonoObject *obj = key; + MonoDomain *domain = user_data; + + g_assert (key == value); + if (obj->vtable->domain == domain) + clear_ares_htable_entries = g_slist_prepend (clear_ares_htable_entries, obj); +} + /* * Clean up the threadpool of all domain jobs. * Can only be called as part of the domain unloading process as @@ -1306,6 +1320,7 @@ mono_thread_pool_remove_domain_jobs (MonoDomain *domain, int timeout) HANDLE sem_handle; int result = TRUE; guint32 start_time = 0; + GSList *list; g_assert (domain->state == MONO_APPDOMAIN_UNLOADING); @@ -1338,6 +1353,16 @@ mono_thread_pool_remove_domain_jobs (MonoDomain *domain, int timeout) domain->cleanup_semaphore = NULL; CloseHandle (sem_handle); + + EnterCriticalSection (&ares_lock); + g_assert (!clear_ares_htable_entries); + mono_g_hash_table_foreach (ares_htable, check_ares_htable_entry_for_domain, domain); + for (list = clear_ares_htable_entries; list; list = list->next) + mono_g_hash_table_remove (ares_htable, list->data); + g_slist_free (clear_ares_htable_entries); + clear_ares_htable_entries = NULL; + LeaveCriticalSection (&ares_lock); + return result; } @@ -1358,7 +1383,7 @@ dequeue_job (CRITICAL_SECTION *cs, TPQueue *list) list->first_elem++; count = list->next_elem - list->first_elem; /* reduce the size of the array if it's mostly empty */ - if (mono_array_length (list->array) > INITIAL_QUEUE_LENGTH && count < (mono_array_length (list->array) / 3)) { + if (mono_array_length (list->array) > 16 && count < (mono_array_length (list->array) / 3)) { MonoArray *olda = list->array; MonoArray *newa = mono_array_new_cached (mono_get_root_domain (), mono_defaults.object_class, mono_array_length (list->array) / 2); mono_array_memcpy_refs (newa, 0, list->array, list->first_elem, count); diff --git a/mono/metadata/verify.c b/mono/metadata/verify.c index 15c427d18ef..a271c05bcf3 100644 --- a/mono/metadata/verify.c +++ b/mono/metadata/verify.c @@ -808,7 +808,7 @@ verifier_load_field (VerifyContext *ctx, int token, MonoClass **out_klass, const MonoClass *klass = NULL; if (!IS_FIELD_DEF_OR_REF (token) || !token_bounds_check (ctx->image, token)) { - ADD_VERIFY_ERROR2 (ctx, g_strdup_printf ("Invalid field token 0x%08x for %s at 0x%04x", token, opcode, ctx->ip_offset), MONO_EXCEPTION_BAD_IMAGE); + ADD_VERIFY_ERROR2 (ctx, g_strdup_printf ("Invalid field token 0x%x08x for %s at 0x%04x", token, opcode, ctx->ip_offset), MONO_EXCEPTION_BAD_IMAGE); return NULL; } @@ -1072,7 +1072,7 @@ is_valid_culture (const char *cname) found = *cname == 0; for (i = 0; i < G_N_ELEMENTS (valid_cultures); ++i) { - if (g_ascii_strcasecmp (valid_cultures [i], cname)) { + if (g_strcasecmp (valid_cultures [i], cname)) { found = 1; break; } diff --git a/mono/mini/ChangeLog b/mono/mini/ChangeLog index 66f16c78526..9d6aeff1180 100644 --- a/mono/mini/ChangeLog +++ b/mono/mini/ChangeLog @@ -1,214 +1,3 @@ -2009-10-06 Zoltan Varga <vargaz@gmail.com> - - * aot-compiler.c (add_generic_class): Add an instance of GenericComparer<T> for - each instance of Comparer<T>. - - * generics.cs: Add a new test. - -2009-10-04 Zoltan Varga <vargaz@gmail.com> - - * aot-compiler.c (add_generic_class): Only add GetGenericValueImpl wrappers - when using full-aot. - -2009-09-25 Zoltan Varga <vargaz@gmail.com> - - * mini-sparc.c (mono_arch_create_vars): Make the component vars of a long ret - variable volatile. Fixes #541577. - - * basic-calls.cs: Add a new test. - - * basic-long.cs: Remove tests which are now in basic-calls.cs. - -2009-10-02 Zoltan Varga <vargaz@gmail.com> - - * mini-sparc.c (mono_arch_emit_setret): Emit long return values using OP_LMOVE. - (mono_arch_create_vars): Instead of allocating a stack slot by hand, allocate - a variable to hold the stack slot used by the int<->float conversion opcodes. - - * mini-sparc.c (mono_arch_build_imt_thunk): Implement support for fail_tramp. - -2009-09-29 Zoltan Varga <vargaz@gmail.com> - - * mini-sparc.c (mono_arch_allocate_vars): Use mono_class_from_mono_type () - instead of using type->data.klass as the later doesn't work with generics. - -2009-09-29 Zoltan Varga <vargaz@gmail.com> - - * mini-sparc.c: Fix the handling of enums with base type long. - - * mini-sparc.c (mono_arch_output_basic_block): Fix IREM_UN_IMM. - - * mini-sparc.c (mono_arch_allocate_vars): Use mono_class_from_mono_type () - instead of using type->data.klass as the later doesn't work with generics. - -2009-09-30 Zoltan Varga <vargaz@gmail.com> - - * aot-compiler.c (add_wrappers): Add a runtime invoke wrapper which is used by - mono_runtime_capture_context () without calling mono_runtime_invoke (). - (can_marshal_struct): Skip structures with auto layout. - - * tramp-arm.c (GEN_TRAMP_SIZE): Increase this by 4. - -2009-09-24 Zoltan Varga <vargaz@gmail.com> - - * dwarfwriter.c (emit_debug_info_end): Disable this as it doesn't seem to - work/required with recent iphone sdk versions. - - * aot-compiler.c (add_wrappers): Generate PtrToStructure wrappers for more - structures. - - * decompose.c (mono_decompose_vtype_opts): Avoid reading uninitialized memory - in the VCALL decomposition code. - -2009-09-22 Zoltan Varga <vargaz@gmail.com> - - * mini-ia64.c (mono_arch_output_basic_block): Fix ISHR/ISHR_IMM. - - * basic.cs: Add a test. - - * mini-ia64.c (mono_arch_build_imt_thunk): Implement support the virtual - generic invokes. - - * mini-exceptions.c (mini_jit_info_table_find): New helper function which - searches all the domains of the current thread. - - * exceptions-<ARCH>.c: Use it. Fixes #539394. - -2009-09-21 Zoltan Varga <vargaz@gmail.com> - - * exceptions-arm.c (mono_arm_throw_exception): Set ctx->ebp to fp instead of sp - so catching exceptions thrown in the same method works. Fixes exception17.exe. - - * tramp-arm.c (mono_arch_create_trampoline_code_full): Store NULL into lmf->method - for non-jit trampolines. - - * mini.c (mono_jit_runtime_invoke): Allow string ctors with dyn runtime invoke. - - * aot-compiler.c (add_wrappers): Ditto. - - * mini-arm.c: Implement support for passing vtypes and floats, and increase - the size of the param area used by dyn_call to 6 which covers the majority of - methods. - - * mini.c aot-compiler.c: Allow dyn_call for string methods except ctors. - - * mini-arm.c: Implement support for passing/receiving - longs and receiving floats in the dyn_call code. - - * mini-amd64.c: Implement support for receiving vtypes in registers in - the dyn_call code. - - * mini.c mini-amd64.c: Implement partial support for passing vtypes in - the dyn_call code. - -2009-09-20 Zoltan Varga <vargaz@gmail.com> - - * mini-arm.c (get_call_info): Return more precise information in - ArgInfo->regtype. - (dyn_call_supported): Use the information in CallInfo. - - * mini-arm.c: Enable support for returning vtypes in the dyn_call code. - - * mini.c mini-amd64.c: Enable support for returning vtypes in the dyn_call - code. - - * mini-arm.c: Update after the dyn_call api changes. - - * mini.c (mini_create_jit_domain_info): Register a destructor function - for the runtime_invoke_hash. - - * mini-amd64.c (mono_arch_get_dyn_call_args): Rename this to - 'mono_arch_dyn_call_start'. Pass the pointer to the return value buffer to - this function. - (mono_arch_get_dyn_call_ret): Rename this to 'mono_arch_dyn_call_finish'. - (dyn_call_supported): Simplify this by using get_call_info (). - (mono_arch_dyn_call_free): New destructor function. - - * generics.cs: Remove a printf. - - * method-to-ir.c (mono_method_to_ir): Allocate some param area for DYN_CALL. - - * mini-arm.c: Add support for enum return values and passing a few arguments - on the stack. - - * mini.c (mono_jit_runtime_invoke): Add support for enum return values to - dyn invoke. - - * mini-amd64.c (mono_arch_get_dyn_call_ret): Ditto. - - * aot-compiler.c (add_wrappers): Add a few restrictions for the use of - the dynamic invoke wrappers. - - * mini-arm.c: Implement OP_DYN_CALL for arm. - - * aot-compiler.c (add_wrappers): Avoid aot-ing runtime invoke wrappers - supported by the dynamic runtime invoke wrapper. - - * aot-compiler.c aot-runtime.c: Add support for encoding the dynamic - runtime invoke wrapper. - - * mini.c (mono_jit_runtime_invoke): Use the dynamic runtime invoke wrappers - if possible when running with full-aot. - - * mini-ops.h: Add OP_DYN_CALL opcode. - - * mini-amd64.c method-to-ir.c: Add infrastructure for making method calls - with dynamic arguments lists similar to libffi. - -2009-09-19 Zoltan Varga <vargaz@gmail.com> - - * method-to-ir.c: Fix the previous change on 64 bit platforms. - - * method-to-ir.c: Applied patch from Rodrigo Kumpera. Allow an i8 argument - to NEWARR. - - * iltests.il.in: Add a new test. - -2009-09-18 Zoltan Varga <vargaz@gmail.com> - - * aot-compiler.c (add_generic_instances): Add more instances of - GenericEqualityComparer. - -2009-09-18 Rodrigo Kumpera <rkumpera@novell.com> - - * mini.c: Add asserts for mono_class_vtable calls that are not meant to fail. - -2009-09-18 Rodrigo Kumpera <rkumpera@novell.com> - - * method-to-ir.c: Handle failures from mono_class_vtable. Added some - comments on some functions that now can fail. - -2009-09-17 Andrew Jorgensen <ajorgensen@novell.com> - - * Makefile.am: Add Info.plist to EXTRA_DIST - -2009-09-16 Zoltan Varga <vargaz@gmail.com> - - * method-to-ir.c (mono_method_to_ir): Allow AOT for CEE_LDTOKEN in - static synchronized wrappers. Fixes #539500. - -2009-09-14 Rodrigo Kumpera <rkumpera@novell.com> - - * jit-icalls.c (mono_class_static_field_address): handle vtable failure - properly. - -2009-09-16 Zoltan Varga <vargaz@gmail.com> - - * mini-exceptions.c (mono_handle_exception_internal): Store the computed - lmf before calling filter clauses as well. Fixes #539550. - - * exceptions.cs: Add a test. - -2009-09-14 Zoltan Varga <vargaz@gmail.com> - - * aot-compiler.c (add_generic_class): Add instances of - Array.GetGenericValueImpl as well. - - * Makefile.am (fullaotcheck): Copy and aot more assemblies so linq - can be tested too. - - * generics.cs: Add a fullaot linq test. - 2009-09-10 Zoltan Varga <vargaz@gmail.com> * aot-compiler.c (arch_emit_static_rgctx_trampoline): Don't clobber argument diff --git a/mono/mini/Makefile.am b/mono/mini/Makefile.am index c94bfb7685f..4c73518876b 100644 --- a/mono/mini/Makefile.am +++ b/mono/mini/Makefile.am @@ -523,7 +523,7 @@ aotcheck: mono $(regtests) fullaotcheck: mono $(regtests) rm -rf fullaot-tmp mkdir fullaot-tmp - cp $(CLASS)/mscorlib.dll $(CLASS)/System.Core.dll $(CLASS)/System.dll $(CLASS)/Mono.Posix.dll $(CLASS)/System.Configuration.dll $(CLASS)/System.Security.dll $(CLASS)/System.Xml.dll $(CLASS)/Mono.Security.dll $(CLASS)/Mono.Simd.dll $(regtests) generics-variant-types.dll TestDriver.dll fullaot-tmp/ + cp $(CLASS)/mscorlib.dll $(CLASS)/Mono.Simd.dll $(regtests) generics-variant-types.dll TestDriver.dll fullaot-tmp/ cp $(regtests) fullaot-tmp/ MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper --aot=full fullaot-tmp/* || exit 1 for i in $(regtests); do echo $$i; MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper --full-aot fullaot-tmp/$$i --exclude '!FULLAOT' || exit 1; done @@ -578,7 +578,7 @@ EXTRA_DIST = $(common_BURGSRC) cprop.c TestDriver.cs ldscript ldscript.mono \ $(alpha_sources) cpu-alpha.md \ $(hppa_sources) cpu-hppa.md \ $(windows_sources) \ - $(darwin_sources) Info.plist \ + $(darwin_sources) \ $(posix_sources) version.h: Makefile diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c index f6ce0fcfe05..6e7641dbba3 100644 --- a/mono/mini/aot-compiler.c +++ b/mono/mini/aot-compiler.c @@ -1355,9 +1355,7 @@ encode_method_ref (MonoAotCompile *acfg, MonoMethod *method, guint8 *buf, guint8 if (method->wrapper_type) { if (method->wrapper_type == MONO_WRAPPER_RUNTIME_INVOKE) { char *tmpsig = mono_signature_get_desc (mono_method_signature (method), TRUE); - if (strcmp (method->name, "runtime_invoke_dynamic")) { - name = mono_aot_wrapper_name (method); - } else if (mono_marshal_method_from_wrapper (method) != method) { + if (mono_marshal_method_from_wrapper (method) != method) { /* Direct wrapper, encode it normally */ } else { name = g_strdup_printf ("(wrapper runtime-invoke):%s (%s)", method->name, tmpsig); @@ -1708,52 +1706,6 @@ get_runtime_invoke_sig (MonoMethodSignature *sig) return mono_marshal_get_runtime_invoke (m, FALSE); } -static gboolean -can_marshal_struct (MonoClass *klass) -{ - MonoClassField *field; - gboolean can_marshal = TRUE; - gpointer iter = NULL; - - if ((klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK) == TYPE_ATTRIBUTE_AUTO_LAYOUT) - return FALSE; - - /* Only allow a few field types to avoid asserts in the marshalling code */ - while ((field = mono_class_get_fields (klass, &iter))) { - if ((field->type->attrs & FIELD_ATTRIBUTE_STATIC)) - continue; - - switch (field->type->type) { - case MONO_TYPE_I4: - case MONO_TYPE_U4: - case MONO_TYPE_I1: - case MONO_TYPE_U1: - case MONO_TYPE_BOOLEAN: - case MONO_TYPE_I2: - case MONO_TYPE_U2: - case MONO_TYPE_CHAR: - case MONO_TYPE_I8: - case MONO_TYPE_U8: - case MONO_TYPE_I: - case MONO_TYPE_U: - case MONO_TYPE_PTR: - case MONO_TYPE_R4: - case MONO_TYPE_R8: - case MONO_TYPE_STRING: - break; - case MONO_TYPE_VALUETYPE: - if (!can_marshal_struct (mono_class_from_mono_type (field->type))) - can_marshal = FALSE; - break; - default: - can_marshal = FALSE; - break; - } - } - - return can_marshal; -} - static void add_wrappers (MonoAotCompile *acfg) { @@ -1799,23 +1751,9 @@ add_wrappers (MonoAotCompile *acfg) skip = TRUE; } -#ifdef MONO_ARCH_DYN_CALL_SUPPORTED - if (!method->klass->contextbound) { - MonoDynCallInfo *info = mono_arch_dyn_call_prepare (sig); - - if (info) { - /* Supported by the dynamic runtime-invoke wrapper */ - skip = TRUE; - g_free (info); - } - } -#endif - - if (!skip) { - //printf ("%s\n", mono_method_full_name (method, TRUE)); + if (!skip) add_method (acfg, mono_marshal_get_runtime_invoke (method, FALSE)); - } - } + } if (strcmp (acfg->image->assembly->aname.name, "mscorlib") == 0) { #ifdef MONO_ARCH_HAVE_TLS_GET @@ -1878,15 +1816,6 @@ add_wrappers (MonoAotCompile *acfg) /* runtime-invoke used by finalizers */ add_method (acfg, mono_marshal_get_runtime_invoke (mono_class_get_method_from_name_flags (mono_defaults.object_class, "Finalize", 0, 0), TRUE)); - /* This is used by mono_runtime_capture_context () */ - method = mono_get_context_capture_method (); - if (method) - add_method (acfg, mono_marshal_get_runtime_invoke (method, FALSE)); - -#ifdef MONO_ARCH_DYN_CALL_SUPPORTED - add_method (acfg, mono_marshal_get_runtime_invoke_dynamic ()); -#endif - /* JIT icall wrappers */ /* FIXME: locking */ g_hash_table_foreach (mono_get_jit_icall_info (), add_jit_icall_wrapper, acfg); @@ -1996,9 +1925,38 @@ add_wrappers (MonoAotCompile *acfg) token = MONO_TOKEN_TYPE_DEF | (i + 1); klass = mono_class_get (acfg->image, token); - if (klass->valuetype && !klass->generic_container && can_marshal_struct (klass)) { - add_method (acfg, mono_marshal_get_struct_to_ptr (klass)); - add_method (acfg, mono_marshal_get_ptr_to_struct (klass)); + if (klass->valuetype && !klass->generic_container && ((klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK) != TYPE_ATTRIBUTE_AUTO_LAYOUT)) { + gboolean can_marshal = TRUE; + gpointer iter = NULL; + MonoClassField *field; + + /* Only allow a few field types to avoid asserts in the marshalling code */ + while ((field = mono_class_get_fields (klass, &iter))) { + switch (field->type->type) { + case MONO_TYPE_I4: + case MONO_TYPE_U4: + case MONO_TYPE_I1: + case MONO_TYPE_U1: + case MONO_TYPE_BOOLEAN: + case MONO_TYPE_I2: + case MONO_TYPE_U2: + case MONO_TYPE_CHAR: + case MONO_TYPE_I8: + case MONO_TYPE_U8: + case MONO_TYPE_PTR: + case MONO_TYPE_R4: + case MONO_TYPE_R8: + break; + default: + can_marshal = FALSE; + break; + } + } + + if (can_marshal) { + add_method (acfg, mono_marshal_get_struct_to_ptr (klass)); + add_method (acfg, mono_marshal_get_ptr_to_struct (klass)); + } } } } @@ -2090,11 +2048,12 @@ add_generic_class (MonoAotCompile *acfg, MonoClass *klass) } /* - * For ICollection<T>, add instances of the helper methods + * For ICollection<T>, where T is a vtype, add instances of the helper methods * in Array, since a T[] could be cast to ICollection<T>. */ if (klass->image == mono_defaults.corlib && !strcmp (klass->name_space, "System.Collections.Generic") && - (!strcmp(klass->name, "ICollection`1") || !strcmp (klass->name, "IEnumerable`1") || !strcmp (klass->name, "IList`1") || !strcmp (klass->name, "IEnumerator`1"))) { + (!strcmp(klass->name, "ICollection`1") || !strcmp (klass->name, "IEnumerable`1") || !strcmp (klass->name, "IList`1") || !strcmp (klass->name, "IEnumerator`1")) && + MONO_TYPE_ISSTRUCT (klass->generic_class->context.class_inst->type_argv [0])) { MonoClass *tclass = mono_class_from_mono_type (klass->generic_class->context.class_inst->type_argv [0]); MonoClass *array_class = mono_bounded_array_class_get (tclass, 1, FALSE); gpointer iter; @@ -2126,51 +2085,6 @@ add_generic_class (MonoAotCompile *acfg, MonoClass *klass) } g_free (name_prefix); - - /* - * Add instance of Array.GetGenericValueImpl, which is called by the - * array helper methods. - * managed-to-native wrappers are not shared, so have to generate - * these for ref types too. - */ - if (acfg->aot_opts.full_aot) { - MonoGenericContext ctx; - MonoType *args [16]; - static MonoMethod *get_method; - - if (get_method == NULL) { - MonoClass *array_klass = mono_array_class_get (mono_defaults.int_class, 1)->parent; - get_method = mono_class_get_method_from_name (array_klass, "GetGenericValueImpl", 2); - } - - if (get_method) { - memset (&ctx, 0, sizeof (ctx)); - args [0] = &tclass->byval_arg; - ctx.method_inst = mono_metadata_get_generic_inst (1, args); - add_extra_method (acfg, mono_marshal_get_native_wrapper (mono_class_inflate_generic_method (get_method, &ctx), TRUE, TRUE)); - } - } - } - - /* Add an instance of GenericComparer<T> which is created dynamically by Comparer<T> */ - if (klass->image == mono_defaults.corlib && !strcmp (klass->name_space, "System.Collections.Generic") && !strcmp (klass->name, "Comparer`1")) { - MonoClass *tclass = mono_class_from_mono_type (klass->generic_class->context.class_inst->type_argv [0]); - MonoClass *icomparable, *gcomparer; - MonoGenericContext ctx; - MonoType *args [16]; - - memset (&ctx, 0, sizeof (ctx)); - - icomparable = mono_class_from_name (mono_defaults.corlib, "System", "IComparable`1"); - g_assert (icomparable); - args [0] = &tclass->byval_arg; - ctx.class_inst = mono_metadata_get_generic_inst (1, args); - - if (mono_class_is_assignable_from (mono_class_inflate_generic_class (icomparable, &ctx), tclass)) { - gcomparer = mono_class_from_name (mono_defaults.corlib, "System.Collections.Generic", "GenericComparer`1"); - g_assert (gcomparer); - add_generic_class (acfg, mono_class_inflate_generic_class (gcomparer, &ctx)); - } } } @@ -2338,23 +2252,6 @@ add_generic_instances (MonoAotCompile *acfg) args [0] = &mono_defaults.uint64_class->byval_arg; ctx.class_inst = mono_metadata_get_generic_inst (1, args); add_generic_class (acfg, mono_class_inflate_generic_class (klass, &ctx)); - - args [0] = &mono_defaults.char_class->byval_arg; - ctx.class_inst = mono_metadata_get_generic_inst (1, args); - add_generic_class (acfg, mono_class_inflate_generic_class (klass, &ctx)); - - args [0] = &mono_defaults.boolean_class->byval_arg; - ctx.class_inst = mono_metadata_get_generic_inst (1, args); - add_generic_class (acfg, mono_class_inflate_generic_class (klass, &ctx)); - - args [0] = &mono_defaults.single_class->byval_arg; - ctx.class_inst = mono_metadata_get_generic_inst (1, args); - add_generic_class (acfg, mono_class_inflate_generic_class (klass, &ctx)); - - args [0] = &mono_defaults.double_class->byval_arg; - ctx.class_inst = mono_metadata_get_generic_inst (1, args); - add_generic_class (acfg, mono_class_inflate_generic_class (klass, &ctx)); - } /* Emit the array wrapper methods for arrays of primitive types */ @@ -4262,15 +4159,10 @@ mono_aot_wrapper_name (MonoMethod *method) switch (method->wrapper_type) { case MONO_WRAPPER_RUNTIME_INVOKE: - if (!strcmp (method->name, "runtime_invoke_dynamic")) - name = g_strdup_printf ("(wrapper runtime-invoke-dynamic)"); - else - name = g_strdup_printf ("%s (%s)", method->name, tmpsig); - break; case MONO_WRAPPER_DELEGATE_INVOKE: case MONO_WRAPPER_DELEGATE_BEGIN_INVOKE: case MONO_WRAPPER_DELEGATE_END_INVOKE: - /* This is a hack to work around the fact that these wrappers get assigned to some random class */ + /* This is a hack to work around the fact that runtime invoke wrappers get assigned to some random class */ name = g_strdup_printf ("%s (%s)", method->name, tmpsig); break; default: diff --git a/mono/mini/aot-runtime.c b/mono/mini/aot-runtime.c index 3179b87a7c1..7dd8523e38d 100644 --- a/mono/mini/aot-runtime.c +++ b/mono/mini/aot-runtime.c @@ -431,8 +431,6 @@ can_method_ref_match_method (MonoAotModule *module, guint8 *buf, MonoMethod *met if (method->wrapper_type != wrapper_type) return FALSE; - } else if (image_index == MONO_AOT_METHODREF_WRAPPER_NAME) { - return FALSE; } else if (image_index < MONO_AOT_METHODREF_MIN || image_index == MONO_AOT_METHODREF_METHODSPEC || image_index == MONO_AOT_METHODREF_GINST) { if (method->wrapper_type) return FALSE; diff --git a/mono/mini/basic-calls.cs b/mono/mini/basic-calls.cs index 5ad874b3dfa..2fd603db910 100644 --- a/mono/mini/basic-calls.cs +++ b/mono/mini/basic-calls.cs @@ -276,29 +276,6 @@ class Tests { return 0; } - public static void use_long_arg (ulong l) { - for (int i = 0; i < 10; ++i) - l ++; - } - - public static ulong return_long_arg (object o, ulong perm) { - use_long_arg (perm); - - perm = 0x8000000000000FFF; - - use_long_arg (perm); - - return perm; - } - - public static int test_0_sparc_long_ret_regress_541577 () { - ulong perm = 0x8000000000000FFF; - - ulong work = return_long_arg (null, perm); - - return work == perm ? 0 : 1; - } - static void doit (double value, out long m) { m = (long) value; } diff --git a/mono/mini/basic-long.cs b/mono/mini/basic-long.cs index 5373a5ed92d..dde9d3ae9bc 100644 --- a/mono/mini/basic-long.cs +++ b/mono/mini/basic-long.cs @@ -1014,6 +1014,26 @@ class Tests { return 0; } + static long return_5low () { + return 5; + } + + static long return_5high () { + return 0x500000000; + } + + public static int test_3_long_ret () { + long val = return_5low (); + return (int) (val - 2); + } + + public static int test_1_long_ret2 () { + long val = return_5high (); + if (val > 0xffffffff) + return 1; + return 0; + } + public static int test_3_byte_cast () { ulong val = 0xff00ff00f0f0f0f0; byte b; diff --git a/mono/mini/basic.cs b/mono/mini/basic.cs index a04aff87611..74d1ede1fad 100644 --- a/mono/mini/basic.cs +++ b/mono/mini/basic.cs @@ -1325,26 +1325,4 @@ class Tests { return 2; return 0; } - - public static unsafe int test_0_ishr_sign_extend () { - // Check that ishr does sign extension from bit 31 on 64 bit platforms - uint val = 0xF0000000u; - - uint *a = &val; - uint ui = (uint)((int)(*a) >> 2); - - if (ui != 0xfc000000) - return 1; - - // Same with non-immediates - int amount = 2; - - ui = (uint)((int)(*a) >> amount); - - if (ui != 0xfc000000) - return 2; - - return 0; - } - } diff --git a/mono/mini/cpu-amd64.md b/mono/mini/cpu-amd64.md index c32611eea3f..f0bc53e74bb 100644 --- a/mono/mini/cpu-amd64.md +++ b/mono/mini/cpu-amd64.md @@ -483,8 +483,6 @@ vcall2: len:64 clob:c vcall2_reg: src1:i len:64 clob:c vcall2_membase: src1:b len:64 clob:c -dyn_call: src1:i src2:i len:64 clob:c - localloc_imm: dest:i len:84 load_mem: dest:i len:16 diff --git a/mono/mini/cpu-arm.md b/mono/mini/cpu-arm.md index 902017c395f..95db0663908 100644 --- a/mono/mini/cpu-arm.md +++ b/mono/mini/cpu-arm.md @@ -308,7 +308,6 @@ long_conv_to_ovf_i4_2: dest:i src1:i src2:i len:36 vcall2: len:20 clob:c vcall2_reg: src1:i len:8 clob:c vcall2_membase: src1:b len:12 clob:c -dyn_call: src1:i src2:i len:128 clob:c # This is different from the original JIT opcodes float_beq: len:20 diff --git a/mono/mini/decompose.c b/mono/mini/decompose.c index f6f51b08aa7..5d244c1ec29 100644 --- a/mono/mini/decompose.c +++ b/mono/mini/decompose.c @@ -1148,7 +1148,7 @@ mono_decompose_vtype_opts (MonoCompile *cfg) /* Save the result */ if (dest_var->backend.is_pinvoke) - size = mono_class_native_size (mono_class_from_mono_type (dest_var->inst_vtype), NULL); + size = mono_class_native_size (dest->inst_vtype->data.klass, NULL); else size = mono_type_size (dest_var->inst_vtype, NULL); switch (size) { diff --git a/mono/mini/dwarfwriter.c b/mono/mini/dwarfwriter.c index 66bed76adfc..a7530ac22b7 100644 --- a/mono/mini/dwarfwriter.c +++ b/mono/mini/dwarfwriter.c @@ -657,11 +657,8 @@ emit_line_number_info_begin (MonoDwarfWriter *w) static void emit_debug_info_end (MonoDwarfWriter *w) { - /* This doesn't seem to work/required with recent iphone sdk versions */ -#if 0 if (!img_writer_subsections_supported (w->w)) fprintf (w->fp, "\n.set %sdebug_info_end,.\n", w->temp_prefix); -#endif } void diff --git a/mono/mini/exceptions-alpha.c b/mono/mini/exceptions-alpha.c index 97a245a3fa8..4a3a5bbcdd4 100644 --- a/mono/mini/exceptions-alpha.c +++ b/mono/mini/exceptions-alpha.c @@ -796,7 +796,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, ((guint8*)ip < ((guint8*)prev_ji->code_start) + prev_ji->code_size))) ji = prev_ji; else - ji = mini_jit_info_table_find (domain, ip); + ji = mono_jit_info_table_find (domain, ip); if (managed) *managed = FALSE; @@ -975,7 +975,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, if (!(*lmf)->method) return (gpointer)-1; - if ((ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { + if ((ji = mono_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { } else { memset (res, 0, MONO_SIZEOF_JIT_INFO); res->method = (*lmf)->method; diff --git a/mono/mini/exceptions-amd64.c b/mono/mini/exceptions-amd64.c index c9d111687f8..c48cbef3c4b 100644 --- a/mono/mini/exceptions-amd64.c +++ b/mono/mini/exceptions-amd64.c @@ -548,7 +548,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf if (prev_ji && (ip > prev_ji->code_start && ((guint8*)ip < ((guint8*)prev_ji->code_start) + prev_ji->code_size))) ji = prev_ji; else - ji = mini_jit_info_table_find (domain, ip); + ji = mono_jit_info_table_find (domain, ip); if (managed) *managed = FALSE; @@ -641,7 +641,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf rip = *(guint64*)((*lmf)->rsp - sizeof (gpointer)); } - ji = mini_jit_info_table_find (domain, (gpointer)rip); + ji = mono_jit_info_table_find (domain, (gpointer)rip); if (!ji) { // FIXME: This can happen with multiple appdomains (bug #444383) return (gpointer)-1; @@ -850,7 +850,7 @@ mono_arch_handle_altstack_exception (void *sigctx, gpointer fault_addr, gboolean MonoException *exc = NULL; ucontext_t *ctx = (ucontext_t*)sigctx; guint64 *gregs = gregs_from_ucontext (ctx); - MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), (gpointer)gregs [REG_RIP]); + MonoJitInfo *ji = mono_jit_info_table_find (mono_domain_get (), (gpointer)gregs [REG_RIP]); gpointer *sp; int frame_size; @@ -1247,7 +1247,7 @@ MONO_GET_RUNTIME_FUNCTION_CALLBACK ( DWORD64 ControlPc, IN PVOID Context ) PMonoUnwindInfo targetinfo; MonoDomain *domain = mono_domain_get (); - ji = mini_jit_info_table_find (domain, (char*)ControlPc); + ji = mono_jit_info_table_find (domain, (char*)ControlPc); if (!ji) return 0; diff --git a/mono/mini/exceptions-arm.c b/mono/mini/exceptions-arm.c index 4d527eb6e40..280a5aab58f 100644 --- a/mono/mini/exceptions-arm.c +++ b/mono/mini/exceptions-arm.c @@ -200,7 +200,7 @@ mono_arm_throw_exception (MonoObject *exc, unsigned long eip, unsigned long esp, setup_context (&ctx); /*printf ("stack in throw: %p\n", esp);*/ - MONO_CONTEXT_SET_BP (&ctx, int_regs [ARMREG_FP - 4]); + MONO_CONTEXT_SET_BP (&ctx, esp); MONO_CONTEXT_SET_SP (&ctx, esp); MONO_CONTEXT_SET_IP (&ctx, eip); memcpy (&ctx.regs, int_regs, sizeof (gulong) * 8); @@ -371,7 +371,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf if (prev_ji && (ip > prev_ji->code_start && ((guint8*)ip < ((guint8*)prev_ji->code_start) + prev_ji->code_size))) ji = prev_ji; else - ji = mini_jit_info_table_find (domain, ip); + ji = mono_jit_info_table_find (domain, ip); if (managed) *managed = FALSE; @@ -430,7 +430,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf *new_ctx = *ctx; - if ((ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { + if ((ji = mono_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { } else { if (!(*lmf)->method) return (gpointer)-1; diff --git a/mono/mini/exceptions-hppa.c b/mono/mini/exceptions-hppa.c index ddac5aea58e..4b3f191fab1 100644 --- a/mono/mini/exceptions-hppa.c +++ b/mono/mini/exceptions-hppa.c @@ -545,7 +545,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf if (prev_ji && (ip > prev_ji->code_start && ((guint8*)ip < ((guint8*)prev_ji->code_start) + prev_ji->code_size))) ji = prev_ji; else - ji = mini_jit_info_table_find (domain, ip); + ji = mono_jit_info_table_find (domain, ip); if (managed) *managed = FALSE; @@ -577,7 +577,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf if (!(*lmf)->method) return (gpointer)-1; - if ((ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { + if ((ji = mono_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { } else { memset (res, 0, MONO_SIZEOF_JIT_INFO); res->method = (*lmf)->method; diff --git a/mono/mini/exceptions-ia64.c b/mono/mini/exceptions-ia64.c index d60c01abd63..87372e0b07a 100644 --- a/mono/mini/exceptions-ia64.c +++ b/mono/mini/exceptions-ia64.c @@ -256,7 +256,7 @@ throw_exception (MonoObject *exc, guint64 rethrow) res = unw_get_reg (&ctx.cursor, UNW_IA64_SP, &sp); g_assert (res == 0); - ji = mini_jit_info_table_find (mono_domain_get (), (gpointer)ip); + ji = mono_jit_info_table_find (mono_domain_get (), (gpointer)ip); //printf ("UN: %s %lx %lx\n", ji ? ji->method->name : "", ip, sp); @@ -535,7 +535,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf if (prev_ji && ((guint8*)ip > (guint8*)prev_ji->code_start && ((guint8*)ip < ((guint8*)prev_ji->code_start) + prev_ji->code_size))) ji = prev_ji; else - ji = mini_jit_info_table_find (domain, (gpointer)ip); + ji = mono_jit_info_table_find (domain, (gpointer)ip); if (managed) *managed = FALSE; @@ -611,7 +611,7 @@ mono_arch_handle_exception (void *sigctx, gpointer obj, gboolean test_only) res = unw_get_reg (&ctx.cursor, UNW_IA64_IP, &ip); g_assert (res == 0); - ji = mini_jit_info_table_find (mono_domain_get (), (gpointer)ip); + ji = mono_jit_info_table_find (mono_domain_get (), (gpointer)ip); if (ji) break; diff --git a/mono/mini/exceptions-mips.c b/mono/mini/exceptions-mips.c index 4cbbc1224a1..13aff78f9de 100644 --- a/mono/mini/exceptions-mips.c +++ b/mono/mini/exceptions-mips.c @@ -421,7 +421,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, if (prev_ji && (ip > prev_ji->code_start && ((guint8*)ip < ((guint8*)prev_ji->code_start) + prev_ji->code_size))) ji = prev_ji; else - ji = mini_jit_info_table_find (domain, ip); + ji = mono_jit_info_table_find (domain, ip); if (managed) *managed = FALSE; @@ -508,7 +508,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, } g_assert (((*lmf)->magic == MIPS_LMF_MAGIC1) || ((*lmf)->magic == MIPS_LMF_MAGIC2)); - if ((ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { + if ((ji = mono_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { } else { memset (res, 0, MONO_SIZEOF_JIT_INFO); res->method = (*lmf)->method; diff --git a/mono/mini/exceptions-ppc.c b/mono/mini/exceptions-ppc.c index 78eed6d8581..4dc0c6050c9 100644 --- a/mono/mini/exceptions-ppc.c +++ b/mono/mini/exceptions-ppc.c @@ -548,7 +548,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf if (prev_ji && (ip > prev_ji->code_start && ((guint8*)ip < ((guint8*)prev_ji->code_start) + prev_ji->code_size))) ji = prev_ji; else - ji = mini_jit_info_table_find (domain, ip); + ji = mono_jit_info_table_find (domain, ip); if (managed) *managed = FALSE; @@ -604,7 +604,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf *new_ctx = *ctx; setup_context (new_ctx); - if ((ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { + if ((ji = mono_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { } else { if (!(*lmf)->method) return (gpointer)-1; @@ -696,7 +696,7 @@ mono_arch_handle_altstack_exception (void *sigctx, gpointer fault_addr, gboolean #ifdef MONO_ARCH_USE_SIGACTION os_ucontext *uc = (ucontext_t*)sigctx; os_ucontext *uc_copy; - MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), mono_arch_ip_from_context (sigctx)); + MonoJitInfo *ji = mono_jit_info_table_find (mono_domain_get (), mono_arch_ip_from_context (sigctx)); gpointer *sp; int frame_size; diff --git a/mono/mini/exceptions-s390.c b/mono/mini/exceptions-s390.c index 85d35a5e809..c2466f9784d 100644 --- a/mono/mini/exceptions-s390.c +++ b/mono/mini/exceptions-s390.c @@ -447,7 +447,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, ((guint8 *) ip <= ((guint8 *) prev_ji->code_start) + prev_ji->code_size))) ji = prev_ji; else - ji = mini_jit_info_table_find (domain, ip); + ji = mono_jit_info_table_find (domain, ip); if (managed) *managed = FALSE; @@ -481,7 +481,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, if (!(*lmf)->method) return (gpointer)-1; - if ((ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { + if ((ji = mono_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { } else { memset (res, 0, MONO_SIZEOF_JIT_INFO); res->method = (*lmf)->method; diff --git a/mono/mini/exceptions-s390x.c b/mono/mini/exceptions-s390x.c index 2931132aa68..5891e0ff6ec 100644 --- a/mono/mini/exceptions-s390x.c +++ b/mono/mini/exceptions-s390x.c @@ -452,7 +452,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, ((guint8 *) ip <= ((guint8 *) prev_ji->code_start) + prev_ji->code_size))) ji = prev_ji; else - ji = mini_jit_info_table_find (domain, ip); + ji = mono_jit_info_table_find (domain, ip); if (managed) *managed = FALSE; @@ -487,7 +487,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, if (!(*lmf)->method) return (gpointer)-1; - if ((ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { + if ((ji = mono_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { } else { memset (res, 0, MONO_SIZEOF_JIT_INFO); res->method = (*lmf)->method; diff --git a/mono/mini/exceptions-sparc.c b/mono/mini/exceptions-sparc.c index c60c167bdfd..4f7640b5ce0 100644 --- a/mono/mini/exceptions-sparc.c +++ b/mono/mini/exceptions-sparc.c @@ -378,7 +378,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf if (prev_ji && (ip > prev_ji->code_start && ((guint8*)ip < ((guint8*)prev_ji->code_start) + prev_ji->code_size))) ji = prev_ji; else - ji = mini_jit_info_table_find (domain, ip); + ji = mono_jit_info_table_find (domain, ip); if (managed) *managed = FALSE; @@ -412,7 +412,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf if (!(*lmf)->method) return (gpointer)-1; - if ((ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->ip))) { + if ((ji = mono_jit_info_table_find (domain, (gpointer)(*lmf)->ip))) { } else { memset (res, 0, MONO_SIZEOF_JIT_INFO); res->method = (*lmf)->method; diff --git a/mono/mini/exceptions-x86.c b/mono/mini/exceptions-x86.c index 9810bb6bc9d..1388538e95e 100644 --- a/mono/mini/exceptions-x86.c +++ b/mono/mini/exceptions-x86.c @@ -602,7 +602,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf if (prev_ji && (ip > prev_ji->code_start && ((guint8*)ip < ((guint8*)prev_ji->code_start) + prev_ji->code_size))) ji = prev_ji; else - ji = mini_jit_info_table_find (domain, ip); + ji = mono_jit_info_table_find (domain, ip); if (managed) *managed = FALSE; @@ -672,7 +672,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf *new_ctx = *ctx; - if ((ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { + if ((ji = mono_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { } else { if (!((guint32)((*lmf)->previous_lmf) & 1)) /* Top LMF entry */ @@ -871,7 +871,7 @@ mono_arch_handle_altstack_exception (void *sigctx, gpointer fault_addr, gboolean #ifdef MONO_ARCH_USE_SIGACTION MonoException *exc = NULL; ucontext_t *ctx = (ucontext_t*)sigctx; - MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), (gpointer)UCONTEXT_REG_EIP (ctx)); + MonoJitInfo *ji = mono_jit_info_table_find (mono_domain_get (), (gpointer)UCONTEXT_REG_EIP (ctx)); gpointer *sp; int frame_size; @@ -881,7 +881,7 @@ mono_arch_handle_altstack_exception (void *sigctx, gpointer fault_addr, gboolean */ if (!ji && fault_addr == (gpointer)UCONTEXT_REG_EIP (ctx)) { glong *sp = (gpointer)UCONTEXT_REG_ESP (ctx); - ji = mini_jit_info_table_find (mono_domain_get (), (gpointer)sp [0]); + ji = mono_jit_info_table_find (mono_domain_get (), (gpointer)sp [0]); if (ji) UCONTEXT_REG_EIP (ctx) = sp [0]; } diff --git a/mono/mini/exceptions.cs b/mono/mini/exceptions.cs index fefe52dc5fb..99d2e7a72ee 100644 --- a/mono/mini/exceptions.cs +++ b/mono/mini/exceptions.cs @@ -2497,37 +2497,5 @@ class Tests { public static int inline_throw2 (int i) { throw new Exception (); } - - // bug #539550 - public static int test_0_lmf_filter () { - try { - // The invoke calls a runtime-invoke wrapper which has a filter clause - typeof (Tests).GetMethod ("lmf_filter").Invoke (null, new object [] { }); - } catch (TargetInvocationException) { - } - return 0; - } - - public static void lmf_filter () { - try { - Connect (); - } - catch { - throw new NotImplementedException (); - } - } - - public static void Connect () { - Stop (); - throw new Exception(); - } - - public static void Stop () { - try { - lock (null) {} - } - catch { - } - } } diff --git a/mono/mini/generics.cs b/mono/mini/generics.cs index 15fc3afc63f..dab0f785e37 100644 --- a/mono/mini/generics.cs +++ b/mono/mini/generics.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; class Tests { @@ -445,23 +444,6 @@ class Tests { return idx; } - public class XElement { - public string Value { - get; set; - } - } - - public static int test_0_fullaot_linq () { - var allWords = new XElement [] { new XElement { Value = "one" } }; - var filteredWords = allWords.Where(kw => kw.Value.StartsWith("T")); - return filteredWords.Count (); - } - - public static int test_0_fullaot_comparer_t () { - var l = new SortedList <TimeSpan, int> (); - return l.Count; - } - static int cctor_count = 0; public abstract class Beta<TChanged> diff --git a/mono/mini/iltests.il.in b/mono/mini/iltests.il.in index 7618fa65bf8..46171b740bf 100644 --- a/mono/mini/iltests.il.in +++ b/mono/mini/iltests.il.in @@ -2354,14 +2354,5 @@ OK_2: ldc.i4.0 ret } - - .method public static default int32 test_0_newarr_i8 () cil managed - { - ldc.i4 1000 - conv.i8 - newarr [mscorlib]System.Boolean - pop - ldc.i4 0 - ret - } + } diff --git a/mono/mini/jit-icalls.c b/mono/mini/jit-icalls.c index 6accfcbe0fd..f16c4140204 100644 --- a/mono/mini/jit-icalls.c +++ b/mono/mini/jit-icalls.c @@ -743,7 +743,7 @@ mono_class_static_field_address (MonoDomain *domain, MonoClassField *field) mono_class_init (field->parent); - vtable = mono_class_vtable_full (domain, field->parent, TRUE); + vtable = mono_class_vtable (domain, field->parent); if (!vtable->initialized) mono_runtime_class_init (vtable); diff --git a/mono/mini/mdb-debug-info32-darwin.s b/mono/mini/mdb-debug-info32-darwin.s index 5d80af79fd5..d7cb2cbc82d 100644 --- a/mono/mini/mdb-debug-info32-darwin.s +++ b/mono/mini/mdb-debug-info32-darwin.s @@ -10,5 +10,4 @@ _MONO_DEBUGGER__notification_function: _MONO_DEBUGGER__debugger_info_ptr: .long _MONO_DEBUGGER__debugger_info _MONO_DEBUGGER__using_debugger: - .long 0 - .long 0 + .quad 0 diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c index c7ae9963297..83b314f52ee 100644 --- a/mono/mini/method-to-ir.c +++ b/mono/mini/method-to-ir.c @@ -2719,9 +2719,6 @@ emit_get_rgctx_field (MonoCompile *cfg, int context_used, return emit_rgctx_fetch (cfg, rgctx, entry); } -/* - * On return the caller must check @klass for load errors. - */ static void emit_generic_class_init (MonoCompile *cfg, MonoClass *klass) { @@ -2752,9 +2749,6 @@ emit_generic_class_init (MonoCompile *cfg, MonoClass *klass) #endif } -/* - * On return the caller must check @array_class for load errors - */ static void mini_emit_check_array_type (MonoCompile *cfg, MonoInst *obj, MonoClass *array_class) { @@ -2783,19 +2777,11 @@ mini_emit_check_array_type (MonoCompile *cfg, MonoInst *obj, MonoClass *array_cl MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, vtable_reg, vtable_ins->dreg); } else { if (cfg->compile_aot) { - int vt_reg; - MonoVTable *vtable; - - if (!(vtable = mono_class_vtable (cfg->domain, array_class))) - return; - vt_reg = alloc_preg (cfg); - MONO_EMIT_NEW_VTABLECONST (cfg, vt_reg, vtable); + int vt_reg = alloc_preg (cfg); + MONO_EMIT_NEW_VTABLECONST (cfg, vt_reg, mono_class_vtable (cfg->domain, array_class)); MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, vtable_reg, vt_reg); } else { - MonoVTable *vtable; - if (!(vtable = mono_class_vtable (cfg->domain, array_class))) - return; - MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, vtable_reg, vtable); + MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, vtable_reg, mono_class_vtable (cfg->domain, array_class)); } } @@ -2914,9 +2900,6 @@ handle_unbox (MonoCompile *cfg, MonoClass *klass, MonoInst **sp, int context_use return add; } -/* - * Returns NULL and set the cfg exception on error. - */ static MonoInst* handle_alloc (MonoCompile *cfg, MonoClass *klass, gboolean for_box) { @@ -2935,18 +2918,12 @@ handle_alloc (MonoCompile *cfg, MonoClass *klass, gboolean for_box) return mono_emit_jit_icall (cfg, mono_helper_newobj_mscorlib, iargs); } else { MonoVTable *vtable = mono_class_vtable (cfg->domain, klass); +#ifdef MONO_CROSS_COMPILE MonoMethod *managed_alloc = NULL; - gboolean pass_lw; - - if (!vtable) { - cfg->exception_type = MONO_EXCEPTION_TYPE_LOAD; - cfg->exception_ptr = klass; - return NULL; - } - -#ifndef MONO_CROSS_COMPILE - managed_alloc = mono_gc_get_managed_allocator (vtable, for_box); +#else + MonoMethod *managed_alloc = mono_gc_get_managed_allocator (vtable, for_box); #endif + gboolean pass_lw; if (managed_alloc) { EMIT_NEW_VTABLECONST (cfg, iargs [0], vtable); @@ -3000,9 +2977,6 @@ handle_alloc_from_inst (MonoCompile *cfg, MonoClass *klass, MonoInst *data_inst, return mono_emit_jit_icall (cfg, alloc_ftn, iargs); } -/* - * Returns NULL and set the cfg exception on error. - */ static MonoInst* handle_box (MonoCompile *cfg, MonoInst *val, MonoClass *klass) { @@ -3014,8 +2988,6 @@ handle_box (MonoCompile *cfg, MonoInst *val, MonoClass *klass) } alloc = handle_alloc (cfg, klass, TRUE); - if (!alloc) - return NULL; EMIT_NEW_STORE_MEMBASE_TYPE (cfg, ins, &klass->byval_arg, alloc->dreg, sizeof (MonoObject), val->dreg); @@ -3045,9 +3017,6 @@ handle_box_from_inst (MonoCompile *cfg, MonoInst *val, MonoClass *klass, int con } } -/* - * Returns NULL and set the cfg exception on error. - */ static MonoInst* handle_castclass (MonoCompile *cfg, MonoClass *klass, MonoInst *src) { @@ -3072,13 +3041,8 @@ handle_castclass (MonoCompile *cfg, MonoClass *klass, MonoInst *src) if (!klass->rank && !cfg->compile_aot && !(cfg->opt & MONO_OPT_SHARED) && (klass->flags & TYPE_ATTRIBUTE_SEALED)) { /* the remoting code is broken, access the class for now */ - if (0) { /*FIXME what exactly is broken? This change refers to r39380 from 2005 and mention some remoting fixes were due.*/ + if (0) { MonoVTable *vt = mono_class_vtable (cfg->domain, klass); - if (!vt) { - cfg->exception_type = MONO_EXCEPTION_TYPE_LOAD; - cfg->exception_ptr = klass; - return NULL; - } MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, vtable_reg, vt); } else { MONO_EMIT_NEW_LOAD_MEMBASE (cfg, klass_reg, vtable_reg, G_STRUCT_OFFSET (MonoVTable, klass)); @@ -3098,9 +3062,6 @@ handle_castclass (MonoCompile *cfg, MonoClass *klass, MonoInst *src) return src; } -/* - * Returns NULL and set the cfg exception on error. - */ static MonoInst* handle_isinst (MonoCompile *cfg, MonoClass *klass, MonoInst *src) { @@ -3174,13 +3135,8 @@ handle_isinst (MonoCompile *cfg, MonoClass *klass, MonoInst *src) } else { if (!cfg->compile_aot && !(cfg->opt & MONO_OPT_SHARED) && (klass->flags & TYPE_ATTRIBUTE_SEALED)) { /* the remoting code is broken, access the class for now */ - if (0) {/*FIXME what exactly is broken? This change refers to r39380 from 2005 and mention some remoting fixes were due.*/ + if (0) { MonoVTable *vt = mono_class_vtable (cfg->domain, klass); - if (!vt) { - cfg->exception_type = MONO_EXCEPTION_TYPE_LOAD; - cfg->exception_ptr = klass; - return NULL; - } MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, vtable_reg, vt); } else { MONO_EMIT_NEW_LOAD_MEMBASE (cfg, klass_reg, vtable_reg, G_STRUCT_OFFSET (MonoVTable, klass)); @@ -3377,9 +3333,6 @@ handle_ccastclass (MonoCompile *cfg, MonoClass *klass, MonoInst *src) return ins; } -/* - * Returns NULL and set the cfg exception on error. - */ static G_GNUC_UNUSED MonoInst* handle_delegate_ctor (MonoCompile *cfg, MonoClass *klass, MonoInst *target, MonoMethod *method) { @@ -3389,8 +3342,6 @@ handle_delegate_ctor (MonoCompile *cfg, MonoClass *klass, MonoInst *target, Mono guint8 **code_slot; obj = handle_alloc (cfg, klass, FALSE); - if (!obj) - return NULL; /* Inline the contents of mono_delegate_ctor */ @@ -3550,7 +3501,6 @@ mono_method_check_inlining (MonoCompile *cfg, MonoMethod *method) if (!(cfg->opt & MONO_OPT_SHARED)) { if (method->klass->flags & TYPE_ATTRIBUTE_BEFORE_FIELD_INIT) { if (cfg->run_cctors && method->klass->has_cctor) { - /*FIXME it would easier and lazier to just use mono_class_try_get_vtable */ if (!method->klass->runtime_info) /* No vtable created yet */ return FALSE; @@ -4162,11 +4112,10 @@ mini_redirect_call (MonoCompile *cfg, MonoMethod *method, if (strcmp (method->name, "InternalAllocateStr") == 0) { MonoInst *iargs [2]; MonoVTable *vtable = mono_class_vtable (cfg->domain, method->klass); +#ifdef MONO_CROSS_COMPILE MonoMethod *managed_alloc = NULL; - - g_assert (vtable); /*Should not fail since it System.String*/ -#ifndef MONO_CROSS_COMPILE - managed_alloc = mono_gc_get_managed_allocator (vtable, FALSE); +#else + MonoMethod *managed_alloc = mono_gc_get_managed_allocator (vtable, FALSE); #endif if (!managed_alloc) return NULL; @@ -4914,7 +4863,7 @@ mono_decompose_array_access_opts (MonoCompile *cfg) } else { MonoVTable *vtable = mono_class_vtable (cfg->domain, mono_array_class_get (ins->inst_newa_class, 1)); - g_assert (vtable); /*This shall not fail since we check for this condition on OP_NEWARR creation*/ + g_assert (vtable); NEW_VTABLECONST (cfg, iargs [0], vtable); MONO_ADD_INS (cfg->cbb, iargs [0]); MONO_INST_NEW (cfg, iargs [1], OP_MOVE); @@ -6274,7 +6223,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b EMIT_NEW_LOAD_MEMBASE (cfg, ins, OP_LOADV_MEMBASE, dreg, sp [0]->dreg, 0); ins->klass = constrained_call; sp [0] = handle_box (cfg, ins, constrained_call); - CHECK_CFG_EXCEPTION; } else if (!constrained_call->valuetype) { int dreg = alloc_preg (cfg); @@ -6300,7 +6248,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b */ if (cfg->generic_sharing_context && cmethod && cmethod->klass != method->klass && cmethod->klass->generic_class && mono_method_is_generic_sharable_impl (cmethod, TRUE) && mono_class_needs_cctor_run (cmethod->klass, method)) { emit_generic_class_init (cfg, cmethod->klass); - CHECK_TYPELOAD (cmethod->klass); } if (cmethod && ((cmethod->flags & METHOD_ATTRIBUTE_STATIC) || cmethod->klass->valuetype) && @@ -6698,7 +6645,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b } else if (strcmp (cmethod->name, "Address") == 0) { /* array Address */ if (!cmethod->klass->element_class->valuetype && !readonly) mini_emit_check_array_type (cfg, sp [0], cmethod->klass); - CHECK_TYPELOAD (cmethod->klass); readonly = FALSE; addr = mini_emit_ldelema_ins (cfg, cmethod, sp, ip, FALSE); @@ -7620,7 +7566,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b alloc = handle_alloc (cfg, cmethod->klass, FALSE); *sp = alloc; } - CHECK_CFG_EXCEPTION; /*for handle_alloc*/ if (alloc) MONO_EMIT_NEW_UNALU (cfg, OP_NOT_NULL, -1, alloc->dreg); @@ -7723,7 +7668,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b } else { ins = handle_castclass (cfg, klass, *sp); - CHECK_CFG_EXCEPTION; bblock = cfg->cbb; *sp ++ = ins; ip += 5; @@ -7777,7 +7721,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b } else { ins = handle_isinst (cfg, klass, *sp); - CHECK_CFG_EXCEPTION; bblock = cfg->cbb; *sp ++ = ins; ip += 5; @@ -7798,7 +7741,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b context_used = mono_class_check_context_used (klass); if (generic_class_is_reference_type (cfg, klass)) { - /* CASTCLASS FIXME kill this huge slice of duplicated code*/ + /* CASTCLASS */ if (context_used) { MonoInst *iargs [2]; @@ -7831,7 +7774,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b inline_costs += costs; } else { ins = handle_castclass (cfg, klass, *sp); - CHECK_CFG_EXCEPTION; bblock = cfg->cbb; *sp ++ = ins; ip += 5; @@ -7938,7 +7880,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b *sp++ = handle_box (cfg, val, klass); } - CHECK_CFG_EXCEPTION; ip += 5; inline_costs += 1; break; @@ -8425,15 +8366,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b if (cfg->generic_sharing_context) context_used = mono_class_check_context_used (klass); - if (sp [0]->type == STACK_I8 || (SIZEOF_VOID_P == 8 && sp [0]->type == STACK_PTR)) { - MONO_INST_NEW (cfg, ins, OP_LCONV_TO_I4); - ins->sreg1 = sp [0]->dreg; - ins->type = STACK_I4; - ins->dreg = alloc_ireg (cfg); - MONO_ADD_INS (cfg->cbb, ins); - *sp = mono_decompose_opcode (cfg, ins); - } - if (context_used) { MonoInst *args [2]; @@ -8459,10 +8391,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b ins = mono_emit_jit_icall (cfg, mono_array_new, iargs); } else { /* Decompose later since it is needed by abcrem */ - MonoClass *array_type = mono_array_class_get (klass, 1); - mono_class_vtable (cfg->domain, array_type); - CHECK_TYPELOAD (array_type); - MONO_INST_NEW (cfg, ins, OP_NEWARR); ins->dreg = alloc_preg (cfg); ins->sreg1 = sp [0]->dreg; @@ -8539,11 +8467,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b * to be for correctness. the wrappers are lax with their usage * so we need to ignore them here */ - if (!klass->valuetype && method->wrapper_type == MONO_WRAPPER_NONE && !readonly) { - MonoClass *array_class = mono_array_class_get (klass, 1); - mini_emit_check_array_type (cfg, sp [0], array_class); - CHECK_TYPELOAD (array_class); - } + if (!klass->valuetype && method->wrapper_type == MONO_WRAPPER_NONE && !readonly) + mini_emit_check_array_type (cfg, sp [0], mono_array_class_get (klass, 1)); readonly = FALSE; ins = mini_emit_ldelema_1_ins (cfg, klass, sp [0], sp [1]); @@ -8857,14 +8782,9 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b tclass, MONO_RGCTX_INFO_REFLECTION_TYPE); } else if (cfg->compile_aot) { if (method->wrapper_type) { - if (mono_class_get (tclass->image, tclass->type_token) == tclass && !generic_context) { - /* Special case for static synchronized wrappers */ - EMIT_NEW_TYPE_FROM_HANDLE_CONST (cfg, ins, tclass->image, tclass->type_token, generic_context); - } else { - /* FIXME: n is not a normal token */ - cfg->disable_aot = TRUE; - EMIT_NEW_PCONST (cfg, ins, NULL); - } + /* FIXME: n is not a normal token */ + cfg->disable_aot = TRUE; + EMIT_NEW_PCONST (cfg, ins, NULL); } else { EMIT_NEW_TYPE_FROM_HANDLE_CONST (cfg, ins, image, n, generic_context); } @@ -9270,37 +9190,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b *sp++ = ins; ip += 6; break; - case CEE_MONO_DYN_CALL: { - MonoCallInst *call; - - /* It would be easier to call a trampoline, but that would put an - * extra frame on the stack, confusing exception handling. So - * implement it inline using an opcode for now. - */ - - if (!cfg->dyn_call_var) { - cfg->dyn_call_var = mono_compile_create_var (cfg, &mono_defaults.int_class->byval_arg, OP_LOCAL); - /* prevent it from being register allocated */ - cfg->dyn_call_var->flags |= MONO_INST_INDIRECT; - } - - /* Has to use a call inst since it local regalloc expects it */ - MONO_INST_NEW_CALL (cfg, call, OP_DYN_CALL); - ins = (MonoInst*)call; - sp -= 2; - ins->sreg1 = sp [0]->dreg; - ins->sreg2 = sp [1]->dreg; - MONO_ADD_INS (bblock, ins); - -#ifdef MONO_ARCH_DYN_CALL_PARAM_AREA - cfg->param_area = MAX (cfg->param_area, MONO_ARCH_DYN_CALL_PARAM_AREA); -#endif - - ip += 2; - inline_costs += 10 * num_calls++; - - break; - } default: g_error ("opcode 0x%02x 0x%02x not handled", MONO_CUSTOM_PREFIX, ip [1]); break; @@ -9430,7 +9319,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b target_ins = sp [-1]; sp --; *sp = handle_delegate_ctor (cfg, ctor_method->klass, target_ins, cmethod); - CHECK_CFG_EXCEPTION; ip += 5; sp ++; break; diff --git a/mono/mini/mini-amd64.c b/mono/mini/mini-amd64.c index bdb33ca23f8..695379f4bef 100644 --- a/mono/mini/mini-amd64.c +++ b/mono/mini/mini-amd64.c @@ -255,7 +255,6 @@ typedef struct { guint32 reg_usage; guint32 freg_usage; gboolean need_stack_align; - gboolean vtype_retaddr; ArgInfo ret; ArgInfo sig_cookie; ArgInfo args [1]; @@ -619,8 +618,6 @@ get_call_info (MonoGenericSharingContext *gsctx, MonoMemPool *mp, MonoMethodSign else cinfo = g_malloc0 (sizeof (CallInfo) + (sizeof (ArgInfo) * n)); - cinfo->nargs = n; - gr = 0; fr = 0; @@ -672,11 +669,9 @@ get_call_info (MonoGenericSharingContext *gsctx, MonoMemPool *mp, MonoMethodSign guint32 tmp_gr = 0, tmp_fr = 0, tmp_stacksize = 0; add_valuetype (gsctx, sig, &cinfo->ret, sig->ret, TRUE, &tmp_gr, &tmp_fr, &tmp_stacksize); - if (cinfo->ret.storage == ArgOnStack) { - cinfo->vtype_retaddr = TRUE; + if (cinfo->ret.storage == ArgOnStack) /* The caller passes the address where the value is stored */ add_general (&gr, &stack_size, &cinfo->ret); - } break; } case MONO_TYPE_TYPEDBYREF: @@ -2131,299 +2126,6 @@ mono_arch_emit_setret (MonoCompile *cfg, MonoMethod *method, MonoInst *val) x86_branch32 (code, cond, 0, sign); \ } -typedef struct { - MonoMethodSignature *sig; - CallInfo *cinfo; -} ArchDynCallInfo; - -typedef struct { - mgreg_t regs [PARAM_REGS]; - mgreg_t res; - guint8 *ret; -} DynCallArgs; - -static gboolean -dyn_call_supported (MonoMethodSignature *sig, CallInfo *cinfo) -{ - int i; - -#ifdef PLATFORM_WIN32 - return FALSE; -#endif - - switch (cinfo->ret.storage) { - case ArgNone: - case ArgInIReg: - break; - case ArgValuetypeInReg: { - ArgInfo *ainfo = &cinfo->ret; - - if (ainfo->pair_storage [0] != ArgNone && ainfo->pair_storage [0] != ArgInIReg) - return FALSE; - if (ainfo->pair_storage [1] != ArgNone && ainfo->pair_storage [1] != ArgInIReg) - return FALSE; - break; - } - default: - return FALSE; - } - - for (i = 0; i < cinfo->nargs; ++i) { - ArgInfo *ainfo = &cinfo->args [i]; - switch (ainfo->storage) { - case ArgInIReg: - break; - case ArgValuetypeInReg: - if (ainfo->pair_storage [0] != ArgNone && ainfo->pair_storage [0] != ArgInIReg) - return FALSE; - if (ainfo->pair_storage [1] != ArgNone && ainfo->pair_storage [1] != ArgInIReg) - return FALSE; - break; - default: - return FALSE; - } - } - - return TRUE; -} - -/* - * mono_arch_dyn_call_prepare: - * - * Return a pointer to an arch-specific structure which contains information - * needed by mono_arch_get_dyn_call_args (). Return NULL if OP_DYN_CALL is not - * supported for SIG. - * This function is equivalent to ffi_prep_cif in libffi. - */ -MonoDynCallInfo* -mono_arch_dyn_call_prepare (MonoMethodSignature *sig) -{ - ArchDynCallInfo *info; - CallInfo *cinfo; - - cinfo = get_call_info (NULL, NULL, sig, FALSE); - - if (!dyn_call_supported (sig, cinfo)) { - g_free (cinfo); - return NULL; - } - - info = g_new0 (ArchDynCallInfo, 1); - // FIXME: Preprocess the info to speed up get_dyn_call_args (). - info->sig = sig; - info->cinfo = cinfo; - - return (MonoDynCallInfo*)info; -} - -/* - * mono_arch_dyn_call_free: - * - * Free a MonoDynCallInfo structure. - */ -void -mono_arch_dyn_call_free (MonoDynCallInfo *info) -{ - ArchDynCallInfo *ainfo = (ArchDynCallInfo*)info; - - g_free (ainfo->cinfo); - g_free (ainfo); -} - -/* - * mono_arch_get_start_dyn_call: - * - * Convert the arguments ARGS to a format which can be passed to OP_DYN_CALL, and - * store the result into BUF. - * ARGS should be an array of pointers pointing to the arguments. - * RET should point to a memory buffer large enought to hold the result of the - * call. - * This function should be as fast as possible, any work which does not depend - * on the actual values of the arguments should be done in - * mono_arch_dyn_call_prepare (). - * start_dyn_call + OP_DYN_CALL + finish_dyn_call is equivalent to ffi_call in - * libffi. - */ -void -mono_arch_start_dyn_call (MonoDynCallInfo *info, gpointer **args, guint8 *ret, guint8 *buf, int buf_len) -{ - ArchDynCallInfo *dinfo = (ArchDynCallInfo*)info; - DynCallArgs *p = (DynCallArgs*)buf; - int arg_index, greg, i; - MonoMethodSignature *sig = dinfo->sig; - - g_assert (buf_len >= sizeof (DynCallArgs)); - - p->res = 0; - p->ret = ret; - - arg_index = 0; - greg = 0; - - if (dinfo->cinfo->vtype_retaddr) - p->regs [greg ++] = (mgreg_t)ret; - - if (sig->hasthis) { - p->regs [greg ++] = (mgreg_t)*(args [arg_index ++]); - } - - for (i = 0; i < sig->param_count; i++) { - MonoType *t = mono_type_get_underlying_type (sig->params [i]); - gpointer *arg = args [arg_index ++]; - - if (t->byref) { - p->regs [greg ++] = (mgreg_t)*(arg); - continue; - } - - switch (t->type) { - case MONO_TYPE_STRING: - case MONO_TYPE_CLASS: - case MONO_TYPE_ARRAY: - case MONO_TYPE_SZARRAY: - case MONO_TYPE_OBJECT: - case MONO_TYPE_PTR: - case MONO_TYPE_I: - case MONO_TYPE_U: - case MONO_TYPE_I8: - case MONO_TYPE_U8: - g_assert (dinfo->cinfo->args [i + sig->hasthis].reg == param_regs [greg]); - p->regs [greg ++] = (mgreg_t)*(arg); - break; - case MONO_TYPE_BOOLEAN: - case MONO_TYPE_U1: - p->regs [greg ++] = *(guint8*)(arg); - break; - case MONO_TYPE_I1: - p->regs [greg ++] = *(gint8*)(arg); - break; - case MONO_TYPE_I2: - p->regs [greg ++] = *(gint16*)(arg); - break; - case MONO_TYPE_U2: - case MONO_TYPE_CHAR: - p->regs [greg ++] = *(guint16*)(arg); - break; - case MONO_TYPE_I4: - p->regs [greg ++] = *(gint32*)(arg); - break; - case MONO_TYPE_U4: - p->regs [greg ++] = *(guint32*)(arg); - break; - case MONO_TYPE_GENERICINST: - if (MONO_TYPE_IS_REFERENCE (t)) { - p->regs [greg ++] = (mgreg_t)*(arg); - break; - } else { - /* Fall through */ - } - case MONO_TYPE_VALUETYPE: { - ArgInfo *ainfo = &dinfo->cinfo->args [i + sig->hasthis]; - - g_assert (ainfo->storage == ArgValuetypeInReg); - if (ainfo->pair_storage [0] != ArgNone) { - g_assert (ainfo->pair_storage [0] == ArgInIReg); - p->regs [greg ++] = ((mgreg_t*)(arg))[0]; - } - if (ainfo->pair_storage [1] != ArgNone) { - g_assert (ainfo->pair_storage [1] == ArgInIReg); - p->regs [greg ++] = ((mgreg_t*)(arg))[1]; - } - break; - } - default: - g_assert_not_reached (); - } - } - - g_assert (greg <= PARAM_REGS); -} - -/* - * mono_arch_finish_dyn_call: - * - * Store the result of a dyn call into the return value buffer passed to - * start_dyn_call (). - * This function should be as fast as possible, any work which does not depend - * on the actual values of the arguments should be done in - * mono_arch_dyn_call_prepare (). - */ -void -mono_arch_finish_dyn_call (MonoDynCallInfo *info, guint8 *buf) -{ - ArchDynCallInfo *dinfo = (ArchDynCallInfo*)info; - MonoMethodSignature *sig = dinfo->sig; - guint8 *ret = ((DynCallArgs*)buf)->ret; - mgreg_t res = ((DynCallArgs*)buf)->res; - - switch (mono_type_get_underlying_type (sig->ret)->type) { - case MONO_TYPE_VOID: - *(gpointer*)ret = NULL; - break; - case MONO_TYPE_STRING: - case MONO_TYPE_CLASS: - case MONO_TYPE_ARRAY: - case MONO_TYPE_SZARRAY: - case MONO_TYPE_OBJECT: - case MONO_TYPE_I: - case MONO_TYPE_U: - case MONO_TYPE_PTR: - *(gpointer*)ret = (gpointer)res; - break; - case MONO_TYPE_I1: - *(gint8*)ret = res; - break; - case MONO_TYPE_U1: - case MONO_TYPE_BOOLEAN: - *(guint8*)ret = res; - break; - case MONO_TYPE_I2: - *(gint16*)ret = res; - break; - case MONO_TYPE_U2: - case MONO_TYPE_CHAR: - *(guint16*)ret = res; - break; - case MONO_TYPE_I4: - *(gint32*)ret = res; - break; - case MONO_TYPE_U4: - *(guint32*)ret = res; - break; - case MONO_TYPE_I8: - *(gint64*)ret = res; - break; - case MONO_TYPE_U8: - *(guint64*)ret = res; - break; - case MONO_TYPE_GENERICINST: - if (MONO_TYPE_IS_REFERENCE (sig->ret)) { - *(gpointer*)ret = (gpointer)res; - break; - } else { - /* Fall through */ - } - case MONO_TYPE_VALUETYPE: - if (dinfo->cinfo->vtype_retaddr) { - /* Nothing to do */ - } else { - ArgInfo *ainfo = &dinfo->cinfo->ret; - - g_assert (ainfo->storage == ArgValuetypeInReg); - - if (ainfo->pair_storage [0] != ArgNone) { - g_assert (ainfo->pair_storage [0] == ArgInIReg); - ((mgreg_t*)ret)[0] = res; - } - - g_assert (ainfo->pair_storage [1] == ArgNone); - } - break; - default: - g_assert_not_reached (); - } -} - /* emit an exception if condition is fail */ #define EMIT_COND_SYSTEM_EXCEPTION(cond,signed,exc_name) \ do { \ @@ -4076,32 +3778,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) amd64_alu_reg_imm (code, X86_ADD, AMD64_RSP, call->stack_usage); code = emit_move_return_value (cfg, ins, code); break; - case OP_DYN_CALL: { - int i; - MonoInst *var = cfg->dyn_call_var; - - g_assert (var->opcode == OP_REGOFFSET); - - /* r11 = args buffer filled by mono_arch_get_dyn_call_args () */ - amd64_mov_reg_reg (code, AMD64_R11, ins->sreg1, 8); - /* r10 = ftn */ - amd64_mov_reg_reg (code, AMD64_R10, ins->sreg2, 8); - - /* Save args buffer */ - amd64_mov_membase_reg (code, var->inst_basereg, var->inst_offset, AMD64_R11, 8); - - /* Set argument registers */ - for (i = 0; i < PARAM_REGS; ++i) - amd64_mov_reg_membase (code, param_regs [i], AMD64_R11, i * sizeof (gpointer), 8); - - /* Make the call */ - amd64_call_reg (code, AMD64_R10); - - /* Save result */ - amd64_mov_reg_membase (code, AMD64_R11, var->inst_basereg, var->inst_offset, 8); - amd64_mov_membase_reg (code, AMD64_R11, G_STRUCT_OFFSET (DynCallArgs, res), AMD64_RAX, 8); - break; - } case OP_AMD64_SAVE_SP_TO_LMF: amd64_mov_membase_reg (code, cfg->frame_reg, cfg->arch.lmf_offset + G_STRUCT_OFFSET (MonoLMF, rsp), AMD64_RSP, 8); break; diff --git a/mono/mini/mini-amd64.h b/mono/mini/mini-amd64.h index 73e91616ea7..4342ca8fadc 100644 --- a/mono/mini/mini-amd64.h +++ b/mono/mini/mini-amd64.h @@ -355,8 +355,6 @@ typedef struct { #endif #define MONO_ARCH_GSHARED_SUPPORTED 1 -#define MONO_ARCH_DYN_CALL_SUPPORTED 1 -#define MONO_ARCH_DYN_CALL_PARAM_AREA 0 #define MONO_ARCH_USE_OP_TAIL_CALL(caller_sig, callee_sig) mono_metadata_signature_equal ((caller_sig), (callee_sig)) diff --git a/mono/mini/mini-arm.c b/mono/mini/mini-arm.c index 2d34faa2dc8..beb0317c404 100644 --- a/mono/mini/mini-arm.c +++ b/mono/mini/mini-arm.c @@ -678,9 +678,7 @@ mono_arch_flush_icache (guint8 *code, gint size) } enum { - RegTypeNone, RegTypeGeneral, - RegTypeIRegPair, RegTypeBase, RegTypeBaseGen, RegTypeFP, @@ -700,7 +698,6 @@ typedef struct { int nargs; guint32 stack_usage; guint32 struct_ret; - gboolean vtype_retaddr; ArgInfo ret; ArgInfo sig_cookie; ArgInfo args [1]; @@ -713,8 +710,6 @@ typedef struct { #define __alignof__(type) G_STRUCT_OFFSET(struct { char c; type x; }, x) #endif -#define PARAM_REGS 4 - static void inline add_general (guint *gr, guint *stack_size, ArgInfo *ainfo, gboolean simple) { @@ -725,7 +720,6 @@ add_general (guint *gr, guint *stack_size, ArgInfo *ainfo, gboolean simple) ainfo->regtype = RegTypeBase; *stack_size += 4; } else { - ainfo->regtype = RegTypeGeneral; ainfo->reg = *gr; } } else { @@ -764,7 +758,6 @@ add_general (guint *gr, guint *stack_size, ArgInfo *ainfo, gboolean simple) if (i8_align == 8 && ((*gr) & 1)) (*gr) ++; #endif - ainfo->regtype = RegTypeIRegPair; ainfo->reg = *gr; } (*gr) ++; @@ -781,14 +774,12 @@ get_call_info (MonoMethodSignature *sig, gboolean is_pinvoke) guint32 stack_size = 0; CallInfo *cinfo = g_malloc0 (sizeof (CallInfo) + sizeof (ArgInfo) * n); - cinfo->nargs = n; gr = ARMREG_R0; /* FIXME: handle returning a struct */ if (MONO_TYPE_ISSTRUCT (sig->ret)) { add_general (&gr, &stack_size, &cinfo->ret, TRUE); cinfo->struct_ret = ARMREG_R0; - cinfo->vtype_retaddr = TRUE; } n = 0; @@ -937,35 +928,27 @@ get_call_info (MonoMethodSignature *sig, gboolean is_pinvoke) case MONO_TYPE_SZARRAY: case MONO_TYPE_ARRAY: case MONO_TYPE_STRING: - cinfo->ret.regtype = RegTypeGeneral; cinfo->ret.reg = ARMREG_R0; break; case MONO_TYPE_U8: case MONO_TYPE_I8: - cinfo->ret.regtype = RegTypeIRegPair; cinfo->ret.reg = ARMREG_R0; break; case MONO_TYPE_R4: case MONO_TYPE_R8: - cinfo->ret.regtype = RegTypeFP; cinfo->ret.reg = ARMREG_R0; /* FIXME: cinfo->ret.reg = ???; cinfo->ret.regtype = RegTypeFP;*/ break; case MONO_TYPE_GENERICINST: if (!mono_type_generic_inst_is_valuetype (sig->ret)) { - cinfo->ret.regtype = RegTypeGeneral; cinfo->ret.reg = ARMREG_R0; break; } - cinfo->ret.regtype = RegTypeStructByAddr; break; case MONO_TYPE_VALUETYPE: - cinfo->ret.regtype = RegTypeStructByAddr; break; case MONO_TYPE_TYPEDBYREF: - cinfo->ret.regtype = RegTypeStructByAddr; - break; case MONO_TYPE_VOID: break; default: @@ -1205,7 +1188,6 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call) switch (ainfo->regtype) { case RegTypeGeneral: - case RegTypeIRegPair: if (!t->byref && ((t->type == MONO_TYPE_I8) || (t->type == MONO_TYPE_U8))) { MONO_INST_NEW (cfg, ins, OP_MOVE); ins->dreg = mono_alloc_ireg (cfg); @@ -1451,308 +1433,6 @@ mono_arch_is_inst_imm (gint64 imm) return TRUE; } -#define DYN_CALL_STACK_ARGS 6 - -typedef struct { - MonoMethodSignature *sig; - CallInfo *cinfo; -} ArchDynCallInfo; - -typedef struct { - mgreg_t regs [PARAM_REGS + DYN_CALL_STACK_ARGS]; - mgreg_t res, res2; - guint8 *ret; -} DynCallArgs; - -static gboolean -dyn_call_supported (CallInfo *cinfo, MonoMethodSignature *sig) -{ - int i; - - if (sig->hasthis + sig->param_count > PARAM_REGS + DYN_CALL_STACK_ARGS) - return FALSE; - - switch (cinfo->ret.regtype) { - case RegTypeNone: - case RegTypeGeneral: - case RegTypeIRegPair: - case RegTypeStructByAddr: - break; - case RegTypeFP: -#ifdef ARM_FPU_FPA - return FALSE; -#elif defined(ARM_FPU_VFP) - break; -#else - return FALSE; -#endif - default: - return FALSE; - } - - for (i = 0; i < cinfo->nargs; ++i) { - switch (cinfo->args [i].regtype) { - case RegTypeGeneral: - break; - case RegTypeIRegPair: - break; - case RegTypeBase: - if (cinfo->args [i].offset >= (DYN_CALL_STACK_ARGS * sizeof (gpointer))) - return FALSE; - break; - case RegTypeStructByVal: - if (cinfo->args [i].reg + cinfo->args [i].vtsize >= PARAM_REGS + DYN_CALL_STACK_ARGS) - return FALSE; - break; - default: - return FALSE; - } - } - - // FIXME: Can't use cinfo only as it doesn't contain info about I8/float */ - for (i = 0; i < sig->param_count; ++i) { - MonoType *t = sig->params [i]; - - if (t->byref) - continue; - - switch (t->type) { - case MONO_TYPE_R4: - case MONO_TYPE_R8: -#ifdef MONO_ARCH_SOFT_FLOAT - return FALSE; -#else - break; -#endif - /* - case MONO_TYPE_I8: - case MONO_TYPE_U8: - return FALSE; - */ - default: - break; - } - } - - return TRUE; -} - -MonoDynCallInfo* -mono_arch_dyn_call_prepare (MonoMethodSignature *sig) -{ - ArchDynCallInfo *info; - CallInfo *cinfo; - - cinfo = get_call_info (sig, FALSE); - - if (!dyn_call_supported (cinfo, sig)) { - g_free (cinfo); - return NULL; - } - - info = g_new0 (ArchDynCallInfo, 1); - // FIXME: Preprocess the info to speed up start_dyn_call () - info->sig = sig; - info->cinfo = cinfo; - - return (MonoDynCallInfo*)info; -} - -void -mono_arch_dyn_call_free (MonoDynCallInfo *info) -{ - ArchDynCallInfo *ainfo = (ArchDynCallInfo*)info; - - g_free (ainfo->cinfo); - g_free (ainfo); -} - -void -mono_arch_start_dyn_call (MonoDynCallInfo *info, gpointer **args, guint8 *ret, guint8 *buf, int buf_len) -{ - ArchDynCallInfo *dinfo = (ArchDynCallInfo*)info; - DynCallArgs *p = (DynCallArgs*)buf; - int arg_index, greg, i, j; - MonoMethodSignature *sig = dinfo->sig; - - g_assert (buf_len >= sizeof (DynCallArgs)); - - p->res = 0; - p->ret = ret; - - arg_index = 0; - greg = 0; - - if (dinfo->cinfo->vtype_retaddr) - p->regs [greg ++] = (mgreg_t)ret; - - if (sig->hasthis) - p->regs [greg ++] = (mgreg_t)*(args [arg_index ++]); - - for (i = 0; i < sig->param_count; i++) { - MonoType *t = mono_type_get_underlying_type (sig->params [i]); - gpointer *arg = args [arg_index ++]; - ArgInfo *ainfo = &dinfo->cinfo->args [i + sig->hasthis]; - int slot = -1; - - if (ainfo->regtype == RegTypeGeneral || ainfo->regtype == RegTypeIRegPair || ainfo->regtype == RegTypeStructByVal) - slot = ainfo->reg; - else if (ainfo->regtype == RegTypeBase) - slot = PARAM_REGS + (ainfo->offset / 4); - else - g_assert_not_reached (); - - if (t->byref) { - p->regs [slot] = (mgreg_t)*arg; - continue; - } - - switch (t->type) { - case MONO_TYPE_STRING: - case MONO_TYPE_CLASS: - case MONO_TYPE_ARRAY: - case MONO_TYPE_SZARRAY: - case MONO_TYPE_OBJECT: - case MONO_TYPE_PTR: - case MONO_TYPE_I: - case MONO_TYPE_U: - p->regs [slot] = (mgreg_t)*arg; - break; - case MONO_TYPE_BOOLEAN: - case MONO_TYPE_U1: - p->regs [slot] = *(guint8*)arg; - break; - case MONO_TYPE_I1: - p->regs [slot] = *(gint8*)arg; - break; - case MONO_TYPE_I2: - p->regs [slot] = *(gint16*)arg; - break; - case MONO_TYPE_U2: - case MONO_TYPE_CHAR: - p->regs [slot] = *(guint16*)arg; - break; - case MONO_TYPE_I4: - p->regs [slot] = *(gint32*)arg; - break; - case MONO_TYPE_U4: - p->regs [slot] = *(guint32*)arg; - break; - case MONO_TYPE_I8: - case MONO_TYPE_U8: - p->regs [slot ++] = (mgreg_t)arg [0]; - p->regs [slot] = (mgreg_t)arg [1]; - break; - case MONO_TYPE_R4: - p->regs [slot] = *(mgreg_t*)arg; - break; - case MONO_TYPE_R8: - p->regs [slot ++] = (mgreg_t)arg [0]; - p->regs [slot] = (mgreg_t)arg [1]; - break; - case MONO_TYPE_GENERICINST: - if (MONO_TYPE_IS_REFERENCE (t)) { - p->regs [slot] = (mgreg_t)*arg; - break; - } else { - /* Fall though */ - } - case MONO_TYPE_VALUETYPE: - g_assert (ainfo->regtype == RegTypeStructByVal); - - if (ainfo->size == 0) - slot = PARAM_REGS + (ainfo->offset / 4); - else - slot = ainfo->reg; - - for (j = 0; j < ainfo->size + ainfo->vtsize; ++j) - p->regs [slot ++] = ((mgreg_t*)arg) [j]; - break; - default: - g_assert_not_reached (); - } - } -} - -void -mono_arch_finish_dyn_call (MonoDynCallInfo *info, guint8 *buf) -{ - ArchDynCallInfo *ainfo = (ArchDynCallInfo*)info; - MonoMethodSignature *sig = ((ArchDynCallInfo*)info)->sig; - guint8 *ret = ((DynCallArgs*)buf)->ret; - mgreg_t res = ((DynCallArgs*)buf)->res; - mgreg_t res2 = ((DynCallArgs*)buf)->res2; - - switch (mono_type_get_underlying_type (sig->ret)->type) { - case MONO_TYPE_VOID: - *(gpointer*)ret = NULL; - break; - case MONO_TYPE_STRING: - case MONO_TYPE_CLASS: - case MONO_TYPE_ARRAY: - case MONO_TYPE_SZARRAY: - case MONO_TYPE_OBJECT: - case MONO_TYPE_I: - case MONO_TYPE_U: - case MONO_TYPE_PTR: - *(gpointer*)ret = (gpointer)res; - break; - case MONO_TYPE_I1: - *(gint8*)ret = res; - break; - case MONO_TYPE_U1: - case MONO_TYPE_BOOLEAN: - *(guint8*)ret = res; - break; - case MONO_TYPE_I2: - *(gint16*)ret = res; - break; - case MONO_TYPE_U2: - case MONO_TYPE_CHAR: - *(guint16*)ret = res; - break; - case MONO_TYPE_I4: - *(gint32*)ret = res; - break; - case MONO_TYPE_U4: - *(guint32*)ret = res; - break; - case MONO_TYPE_I8: - case MONO_TYPE_U8: - /* This handles endianness as well */ - ((gint32*)ret) [0] = res; - ((gint32*)ret) [1] = res2; - break; - case MONO_TYPE_GENERICINST: - if (MONO_TYPE_IS_REFERENCE (sig->ret)) { - *(gpointer*)ret = (gpointer)res; - break; - } else { - /* Fall though */ - } - case MONO_TYPE_VALUETYPE: - g_assert (ainfo->cinfo->vtype_retaddr); - /* Nothing to do */ - break; -#if defined(ARM_FPU_VFP) - case MONO_TYPE_R4: - *(float*)ret = *(float*)&res; - break; - case MONO_TYPE_R8: { - mgreg_t regs [2]; - - regs [0] = res; - regs [1] = res2; - - *(double*)ret = *(double*)®s; - break; - } -#endif - default: - g_assert_not_reached (); - } -} - /* * Allow tracing to work with this interface (with an optional argument) */ @@ -2757,7 +2437,7 @@ emit_load_volatile_arguments (MonoCompile *cfg, guint8 *code) } else g_assert_not_reached (); } else { - if (ainfo->regtype == RegTypeGeneral || ainfo->regtype == RegTypeIRegPair) { + if (ainfo->regtype == RegTypeGeneral) { switch (ainfo->size) { case 1: case 2: @@ -3384,42 +3064,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) ARM_ADD_REG_IMM8 (code, ins->dreg, ARMREG_SP, alloca_waste); break; } - case OP_DYN_CALL: { - int i; - MonoInst *var = cfg->dyn_call_var; - - g_assert (var->opcode == OP_REGOFFSET); - g_assert (arm_is_imm12 (var->inst_offset)); - - /* lr = args buffer filled by mono_arch_get_dyn_call_args () */ - ARM_MOV_REG_REG( code, ARMREG_LR, ins->sreg1); - /* ip = ftn */ - ARM_MOV_REG_REG( code, ARMREG_IP, ins->sreg2); - - /* Save args buffer */ - ARM_STR_IMM (code, ARMREG_LR, var->inst_basereg, var->inst_offset); - - /* Set stack slots using R0 as scratch reg */ - /* MONO_ARCH_DYN_CALL_PARAM_AREA gives the size of stack space available */ - for (i = 0; i < DYN_CALL_STACK_ARGS; ++i) { - ARM_LDR_IMM (code, ARMREG_R0, ARMREG_LR, (PARAM_REGS + i) * sizeof (gpointer)); - ARM_STR_IMM (code, ARMREG_R0, ARMREG_SP, i * sizeof (gpointer)); - } - - /* Set argument registers */ - for (i = 0; i < PARAM_REGS; ++i) - ARM_LDR_IMM (code, i, ARMREG_LR, i * sizeof (gpointer)); - - /* Make the call */ - ARM_MOV_REG_REG (code, ARMREG_LR, ARMREG_PC); - ARM_MOV_REG_REG (code, ARMREG_PC, ARMREG_IP); - - /* Save result */ - ARM_LDR_IMM (code, ARMREG_IP, var->inst_basereg, var->inst_offset); - ARM_STR_IMM (code, ARMREG_R0, ARMREG_IP, G_STRUCT_OFFSET (DynCallArgs, res)); - ARM_STR_IMM (code, ARMREG_R1, ARMREG_IP, G_STRUCT_OFFSET (DynCallArgs, res2)); - break; - } case OP_THROW: { if (ins->sreg1 != ARMREG_R0) ARM_MOV_REG_REG (code, ARMREG_R0, ins->sreg1); @@ -4281,7 +3925,7 @@ mono_arch_emit_prolog (MonoCompile *cfg) g_print ("Argument %d assigned to register %s\n", pos, mono_arch_regname (inst->dreg)); } else { /* the argument should be put on the stack: FIXME handle size != word */ - if (ainfo->regtype == RegTypeGeneral || ainfo->regtype == RegTypeIRegPair) { + if (ainfo->regtype == RegTypeGeneral) { switch (ainfo->size) { case 1: if (arm_is_imm12 (inst->inst_offset)) diff --git a/mono/mini/mini-arm.h b/mono/mini/mini-arm.h index 7eca9ea4af6..b34e1fb027b 100644 --- a/mono/mini/mini-arm.h +++ b/mono/mini/mini-arm.h @@ -155,8 +155,6 @@ typedef struct MonoCompileArch { #define MONO_ARCH_AOT_SUPPORTED 1 #define MONO_ARCH_GSHARED_SUPPORTED 1 -#define MONO_ARCH_DYN_CALL_SUPPORTED 1 -#define MONO_ARCH_DYN_CALL_PARAM_AREA 24 /* ARM doesn't have too many registers, so we have to use a callee saved one */ #define MONO_ARCH_RGCTX_REG ARMREG_V5 diff --git a/mono/mini/mini-exceptions.c b/mono/mini/mini-exceptions.c index 2f50abfa0c7..1dc3ab9232d 100644 --- a/mono/mini/mini-exceptions.c +++ b/mono/mini/mini-exceptions.c @@ -851,34 +851,6 @@ get_exception_catch_class (MonoJitExceptionInfo *ei, MonoJitInfo *ji, MonoContex return catch_class; } -/* - * mini_jit_info_table_find: - * - * Same as mono_jit_info_table_find, but search all the domains of the current thread - * if ADDR is not found in DOMAIN. - */ -MonoJitInfo* -mini_jit_info_table_find (MonoDomain *domain, char *addr) -{ - MonoJitInfo *ji; - MonoThread *t = mono_thread_current (); - GSList *l; - - ji = mono_jit_info_table_find (domain, addr); - if (ji) - return ji; - - for (l = t->appdomain_refs; l; l = l->next) { - if (l->data != domain) { - ji = mono_jit_info_table_find ((MonoDomain*)l->data, addr); - if (ji) - return ji; - } - } - - return NULL; -} - /** * mono_handle_exception_internal: * @ctx: saved processor state @@ -1116,7 +1088,6 @@ mono_handle_exception_internal (MonoContext *ctx, gpointer obj, gpointer origina mono_profiler_exception_clause_handler (ji->method, ei->flags, i); mono_debugger_call_exception_handler (ei->handler_start, MONO_CONTEXT_GET_SP (ctx), obj); mono_perfcounters->exceptions_finallys++; - *(mono_get_lmf_addr ()) = lmf; call_filter (ctx, ei->handler_start); } diff --git a/mono/mini/mini-ia64.c b/mono/mini/mini-ia64.c index e2a92592d7b..c44af5c899b 100644 --- a/mono/mini/mini-ia64.c +++ b/mono/mini/mini-ia64.c @@ -2128,9 +2128,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) ia64_shl (code, ins->dreg, ins->sreg1, ins->sreg2); break; case OP_ISHR: - ia64_sxt4 (code, GP_SCRATCH_REG, ins->sreg1); - ia64_shr (code, ins->dreg, GP_SCRATCH_REG, ins->sreg2); - break; case OP_LSHR: ia64_shr (code, ins->dreg, ins->sreg1, ins->sreg2); break; @@ -2230,13 +2227,10 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) ia64_shl_imm (code, ins->dreg, ins->sreg1, ins->inst_imm); break; case OP_SHR_IMM: + case OP_ISHR_IMM: case OP_LSHR_IMM: ia64_shr_imm (code, ins->dreg, ins->sreg1, ins->inst_imm); break; - case OP_ISHR_IMM: - g_assert (ins->inst_imm <= 64); - ia64_extr (code, ins->dreg, ins->sreg1, ins->inst_imm, 32 - ins->inst_imm); - break; case OP_ISHR_UN_IMM: ia64_zxt4 (code, GP_SCRATCH_REG, ins->sreg1); ia64_shr_u_imm (code, ins->dreg, GP_SCRATCH_REG, ins->inst_imm); @@ -4557,7 +4551,7 @@ mono_arch_get_vcall_slot (guint8* code, mgreg_t *regs, int *displacement) *displacement = (gssize)regs [IA64_R8] - (gssize)regs [IA64_R11]; - return (gpointer)regs [IA64_R11]; + return regs [IA64_R11]; } return NULL; @@ -4595,6 +4589,8 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI guint8 *start, *buf; Ia64CodegenState code; + g_assert (!fail_tramp); + size = count * 256; buf = g_malloc0 (size); ia64_codegen_init (code, buf); @@ -4606,10 +4602,8 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI ia64_begin_bundle (code); item->code_target = (guint8*)code.buf + code.nins; if (item->is_equals) { - gboolean fail_case = !item->check_target_idx && fail_tramp; - - if (item->check_target_idx || fail_case) { - if (!item->compare_done || fail_case) { + if (item->check_target_idx) { + if (!item->compare_done) { ia64_movl (code, GP_SCRATCH_REG, item->key); ia64_cmp_eq (code, 6, 7, IA64_R9, GP_SCRATCH_REG); } @@ -4620,15 +4614,6 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI ia64_ld8 (code, GP_SCRATCH_REG, GP_SCRATCH_REG); ia64_mov_to_br (code, IA64_B6, GP_SCRATCH_REG); ia64_br_cond_reg (code, IA64_B6); - - if (fail_case) { - ia64_patch (item->jmp_code, (guint8*)code.buf + code.nins); - ia64_movl (code, GP_SCRATCH_REG, fail_tramp); - ia64_ld8 (code, GP_SCRATCH_REG, GP_SCRATCH_REG); - ia64_mov_to_br (code, IA64_B6, GP_SCRATCH_REG); - ia64_br_cond_reg (code, IA64_B6); - item->jmp_code = NULL; - } } else { /* enable the commented code to assert on wrong method */ #if ENABLE_WRONG_METHOD_CHECK @@ -4663,12 +4648,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI g_assert (code.buf - buf <= size); size = code.buf - buf; - if (fail_tramp) { - start = mono_method_alloc_generic_virtual_thunk (domain, size + 16); - start = (gpointer)ALIGN_TO (start, 16); - } else { - start = mono_domain_code_reserve (domain, size); - } + start = mono_domain_code_reserve (domain, size); memcpy (start, buf, size); mono_arch_flush_icache (start, size); @@ -4681,7 +4661,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI MonoMethod* mono_arch_find_imt_method (mgreg_t *regs, guint8 *code) { - return (MonoMethod*)regs [IA64_R9]; + return regs [IA64_R9]; } void diff --git a/mono/mini/mini-ops.h b/mono/mini/mini-ops.h index b23d8bf1d2b..163e074350b 100644 --- a/mono/mini/mini-ops.h +++ b/mono/mini/mini-ops.h @@ -51,7 +51,6 @@ MINI_OP(OP_VCALL_MEMBASE, "vcall_membase", VREG, IREG, NONE) MINI_OP(OP_VCALL2, "vcall2", NONE, NONE, NONE) MINI_OP(OP_VCALL2_REG, "vcall2_reg", NONE, IREG, NONE) MINI_OP(OP_VCALL2_MEMBASE, "vcall2_membase", NONE, IREG, NONE) -MINI_OP(OP_DYN_CALL, "dyn_call", NONE, IREG, IREG) MINI_OP(OP_ICONST, "iconst", IREG, NONE, NONE) MINI_OP(OP_I8CONST, "i8const", LREG, NONE, NONE) diff --git a/mono/mini/mini-sparc.c b/mono/mini/mini-sparc.c index f98bf48e9e6..0f5356dce5d 100644 --- a/mono/mini/mini-sparc.c +++ b/mono/mini/mini-sparc.c @@ -811,9 +811,8 @@ mono_arch_allocate_vars (MonoCompile *cfg) cfg->ret->opcode = OP_REGVAR; cfg->ret->inst_c0 = cinfo->ret.reg; break; - case ArgInIRegPair: { - MonoType *t = mono_type_get_underlying_type (sig->ret); - if (((t->type == MONO_TYPE_I8) || (t->type == MONO_TYPE_U8))) { + case ArgInIRegPair: + if (((sig->ret->type == MONO_TYPE_I8) || (sig->ret->type == MONO_TYPE_U8))) { MonoInst *low = get_vreg_to_inst (cfg, cfg->ret->dreg + 1); MonoInst *high = get_vreg_to_inst (cfg, cfg->ret->dreg + 2); @@ -825,7 +824,6 @@ mono_arch_allocate_vars (MonoCompile *cfg) cfg->ret->opcode = OP_REGVAR; cfg->ret->inst_c0 = cinfo->ret.reg; break; - } case ArgOnStack: #ifdef SPARCV9 g_assert_not_reached (); @@ -879,7 +877,7 @@ mono_arch_allocate_vars (MonoCompile *cfg) /* inst->backend.is_pinvoke indicates native sized value types, this is used by the * pinvoke wrappers when they call functions returning structure */ if (inst->backend.is_pinvoke && MONO_TYPE_ISSTRUCT (inst->inst_vtype) && inst->inst_vtype->type != MONO_TYPE_TYPEDBYREF) - size = mono_class_native_size (mono_class_from_mono_type (inst->inst_vtype), &align); + size = mono_class_native_size (inst->inst_vtype->data.klass, &align); else size = mini_type_stack_size (cfg->generic_sharing_context, inst->inst_vtype, &align); @@ -965,7 +963,7 @@ mono_arch_allocate_vars (MonoCompile *cfg) high->dreg = sparc_i0 + ainfo->reg; } inst->opcode = OP_REGVAR; - inst->dreg = sparc_i0 + ainfo->reg; + inst->dreg = sparc_i0 + ainfo->reg; break; case ArgInFloatReg: case ArgInDoubleReg: @@ -1019,6 +1017,11 @@ mono_arch_allocate_vars (MonoCompile *cfg) } } + /* Add a properly aligned dword for use by int<->float conversion opcodes */ + offset += 8; + offset = ALIGN_TO (offset, 8); + cfg->arch.float_spill_slot_offset = offset; + /* * spillvars are stored between the normal locals and the storage reserved * by the ABI. @@ -1043,18 +1046,6 @@ mono_arch_create_vars (MonoCompile *cfg) mono_print_ins (cfg->vret_addr); } } - - if (!sig->ret->byref && (sig->ret->type == MONO_TYPE_I8 || sig->ret->type == MONO_TYPE_U8)) { - MonoInst *low = get_vreg_to_inst (cfg, cfg->ret->dreg + 1); - MonoInst *high = get_vreg_to_inst (cfg, cfg->ret->dreg + 2); - - low->flags |= MONO_INST_VOLATILE; - high->flags |= MONO_INST_VOLATILE; - } - - /* Add a properly aligned dword for use by int<->float conversion opcodes */ - cfg->arch.float_spill_slot = mono_compile_create_var (cfg, &mono_defaults.double_class->byval_arg, OP_ARG); - ((MonoInst*)cfg->arch.float_spill_slot)->flags |= MONO_INST_VOLATILE; } static void @@ -1314,7 +1305,6 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call) else arg_type = sig->params [i - sig->hasthis]; - arg_type = mono_type_get_underlying_type (arg_type); if ((i >= sig->hasthis) && (MONO_TYPE_ISSTRUCT(sig->params [i - sig->hasthis]))) emit_pass_vtype (cfg, call, cinfo, ainfo, arg_type, in, sig->pinvoke); else if (!arg_type->byref && ((arg_type->type == MONO_TYPE_I8) || (arg_type->type == MONO_TYPE_U8))) @@ -1350,22 +1340,17 @@ void mono_arch_emit_setret (MonoCompile *cfg, MonoMethod *method, MonoInst *val) { CallInfo *cinfo = get_call_info (cfg, mono_method_signature (method), FALSE); - MonoType *ret = mini_type_get_underlying_type (cfg->generic_sharing_context, mono_method_signature (method)->ret); switch (cinfo->ret.storage) { case ArgInIReg: MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, cfg->ret->dreg, val->dreg); break; case ArgInIRegPair: - if (ret->type == MONO_TYPE_I8 || ret->type == MONO_TYPE_U8) { - MONO_EMIT_NEW_UNALU (cfg, OP_LMOVE, cfg->ret->dreg, val->dreg); - } else { - MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, cfg->ret->dreg + 2, val->dreg + 2); - MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, cfg->ret->dreg + 1, val->dreg + 1); - } + MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, cfg->ret->dreg, val->dreg + 2); + MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, cfg->ret->dreg + 1, val->dreg + 1); break; case ArgInFReg: - if (ret->type == MONO_TYPE_R4) + if (mono_method_signature (method)->ret->type == MONO_TYPE_R4) MONO_EMIT_NEW_UNALU (cfg, OP_SETFRET, cfg->ret->dreg, val->dreg); else MONO_EMIT_NEW_UNALU (cfg, OP_FMOVE, cfg->ret->dreg, val->dreg); @@ -2352,6 +2337,8 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI int size = 0; guint32 *code, *start; + g_assert (!fail_tramp); + for (i = 0; i < count; ++i) { MonoIMTCheckItem *item = imt_entries [i]; if (item->is_equals) { @@ -2360,8 +2347,6 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI item->chunk_size += CMP_SIZE; item->chunk_size += BR_SMALL_SIZE + JUMP_IMM_SIZE; } else { - if (fail_tramp) - item->chunk_size += 16; item->chunk_size += JUMP_IMM_SIZE; #if ENABLE_WRONG_METHOD_CHECK item->chunk_size += CMP_SIZE + BR_SMALL_SIZE + 1; @@ -2373,19 +2358,15 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI } size += item->chunk_size; } - if (fail_tramp) - code = mono_method_alloc_generic_virtual_thunk (domain, size * 4); - else - code = mono_domain_code_reserve (domain, size * 4); + code = mono_domain_code_reserve (domain, size * 4); start = code; + for (i = 0; i < count; ++i) { MonoIMTCheckItem *item = imt_entries [i]; item->code_target = (guint8*)code; if (item->is_equals) { - gboolean fail_case = !item->check_target_idx && fail_tramp; - - if (item->check_target_idx || fail_case) { - if (!item->compare_done || fail_case) { + if (item->check_target_idx) { + if (!item->compare_done) { sparc_set (code, (guint32)item->key, sparc_g5); sparc_cmp (code, MONO_ARCH_IMT_REG, sparc_g5); } @@ -2396,14 +2377,6 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI sparc_ld (code, sparc_g5, 0, sparc_g5); sparc_jmpl (code, sparc_g5, sparc_g0, sparc_g0); sparc_nop (code); - - if (fail_case) { - sparc_patch (item->jmp_code, code); - sparc_set (code, fail_tramp, sparc_g5); - sparc_jmpl (code, sparc_g5, sparc_g0, sparc_g0); - sparc_nop (code); - item->jmp_code = NULL; - } } else { /* enable the commented code to assert on wrong method */ #if ENABLE_WRONG_METHOD_CHECK @@ -2784,7 +2757,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) sparc_set (code, ins->inst_imm, GP_SCRATCH_REG); sparc_wry (code, sparc_g0, sparc_g0); sparc_udiv (code, FALSE, ins->sreg1, GP_SCRATCH_REG, sparc_o7); - sparc_umul (code, FALSE, GP_SCRATCH_REG, sparc_o7, sparc_o7); + sparc_umul (code, FALSE, ins->sreg2, sparc_o7, sparc_o7); sparc_sub (code, FALSE, ins->sreg1, sparc_o7, ins->dreg); break; case OP_IOR: @@ -3435,29 +3408,25 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) break; } case OP_ICONV_TO_R4: { - MonoInst *spill = cfg->arch.float_spill_slot; - gint32 reg = spill->inst_basereg; - gint32 offset = spill->inst_offset; - - g_assert (spill->opcode == OP_REGOFFSET); + gint32 offset = cfg->arch.float_spill_slot_offset; #ifdef SPARCV9 if (!sparc_is_imm13 (offset)) { sparc_set (code, offset, sparc_o7); - sparc_stx (code, ins->sreg1, reg, offset); - sparc_lddf (code, reg, offset, FP_SCRATCH_REG); + sparc_stx (code, ins->sreg1, sparc_sp, offset); + sparc_lddf (code, sparc_sp, offset, FP_SCRATCH_REG); } else { - sparc_stx_imm (code, ins->sreg1, reg, offset); - sparc_lddf_imm (code, reg, offset, FP_SCRATCH_REG); + sparc_stx_imm (code, ins->sreg1, sparc_sp, offset); + sparc_lddf_imm (code, sparc_sp, offset, FP_SCRATCH_REG); } sparc_fxtos (code, FP_SCRATCH_REG, FP_SCRATCH_REG); #else if (!sparc_is_imm13 (offset)) { sparc_set (code, offset, sparc_o7); - sparc_st (code, ins->sreg1, reg, sparc_o7); - sparc_ldf (code, reg, sparc_o7, FP_SCRATCH_REG); + sparc_st (code, ins->sreg1, sparc_sp, sparc_o7); + sparc_ldf (code, sparc_sp, sparc_o7, FP_SCRATCH_REG); } else { - sparc_st_imm (code, ins->sreg1, reg, offset); - sparc_ldf_imm (code, reg, offset, FP_SCRATCH_REG); + sparc_st_imm (code, ins->sreg1, sparc_sp, offset); + sparc_ldf_imm (code, sparc_sp, offset, FP_SCRATCH_REG); } sparc_fitos (code, FP_SCRATCH_REG, FP_SCRATCH_REG); #endif @@ -3465,30 +3434,25 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) break; } case OP_ICONV_TO_R8: { - MonoInst *spill = cfg->arch.float_spill_slot; - gint32 reg = spill->inst_basereg; - gint32 offset = spill->inst_offset; - - g_assert (spill->opcode == OP_REGOFFSET); - + gint32 offset = cfg->arch.float_spill_slot_offset; #ifdef SPARCV9 if (!sparc_is_imm13 (offset)) { sparc_set (code, offset, sparc_o7); - sparc_stx (code, ins->sreg1, reg, sparc_o7); - sparc_lddf (code, reg, sparc_o7, FP_SCRATCH_REG); + sparc_stx (code, ins->sreg1, sparc_sp, sparc_o7); + sparc_lddf (code, sparc_sp, sparc_o7, FP_SCRATCH_REG); } else { - sparc_stx_imm (code, ins->sreg1, reg, offset); - sparc_lddf_imm (code, reg, offset, FP_SCRATCH_REG); + sparc_stx_imm (code, ins->sreg1, sparc_sp, offset); + sparc_lddf_imm (code, sparc_sp, offset, FP_SCRATCH_REG); } sparc_fxtod (code, FP_SCRATCH_REG, ins->dreg); #else if (!sparc_is_imm13 (offset)) { sparc_set (code, offset, sparc_o7); - sparc_st (code, ins->sreg1, reg, sparc_o7); - sparc_ldf (code, reg, sparc_o7, FP_SCRATCH_REG); + sparc_st (code, ins->sreg1, sparc_sp, sparc_o7); + sparc_ldf (code, sparc_sp, sparc_o7, FP_SCRATCH_REG); } else { - sparc_st_imm (code, ins->sreg1, reg, offset); - sparc_ldf_imm (code, reg, offset, FP_SCRATCH_REG); + sparc_st_imm (code, ins->sreg1, sparc_sp, offset); + sparc_ldf_imm (code, sparc_sp, offset, FP_SCRATCH_REG); } sparc_fitod (code, FP_SCRATCH_REG, ins->dreg); #endif @@ -3504,20 +3468,15 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) #endif case OP_FCONV_TO_I4: case OP_FCONV_TO_U4: { - MonoInst *spill = cfg->arch.float_spill_slot; - gint32 reg = spill->inst_basereg; - gint32 offset = spill->inst_offset; - - g_assert (spill->opcode == OP_REGOFFSET); - + gint32 offset = cfg->arch.float_spill_slot_offset; sparc_fdtoi (code, ins->sreg1, FP_SCRATCH_REG); if (!sparc_is_imm13 (offset)) { sparc_set (code, offset, sparc_o7); - sparc_stdf (code, FP_SCRATCH_REG, reg, sparc_o7); - sparc_ld (code, reg, sparc_o7, ins->dreg); + sparc_stdf (code, FP_SCRATCH_REG, sparc_sp, sparc_o7); + sparc_ld (code, sparc_sp, sparc_o7, ins->dreg); } else { - sparc_stdf_imm (code, FP_SCRATCH_REG, reg, offset); - sparc_ld_imm (code, reg, offset, ins->dreg); + sparc_stdf_imm (code, FP_SCRATCH_REG, sparc_sp, offset); + sparc_ld_imm (code, sparc_sp, offset, ins->dreg); } switch (ins->opcode) { @@ -3690,19 +3649,14 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) EMIT_FLOAT_COND_BRANCH (ins, sparc_fbu, 1, 1); break; case OP_CKFINITE: { - MonoInst *spill = cfg->arch.float_spill_slot; - gint32 reg = spill->inst_basereg; - gint32 offset = spill->inst_offset; - - g_assert (spill->opcode == OP_REGOFFSET); - + gint32 offset = cfg->arch.float_spill_slot_offset; if (!sparc_is_imm13 (offset)) { sparc_set (code, offset, sparc_o7); - sparc_stdf (code, ins->sreg1, reg, sparc_o7); - sparc_lduh (code, reg, sparc_o7, sparc_o7); + sparc_stdf (code, ins->sreg1, sparc_sp, sparc_o7); + sparc_lduh (code, sparc_sp, sparc_o7, sparc_o7); } else { - sparc_stdf_imm (code, ins->sreg1, reg, offset); - sparc_lduh_imm (code, reg, offset, sparc_o7); + sparc_stdf_imm (code, ins->sreg1, sparc_sp, offset); + sparc_lduh_imm (code, sparc_sp, offset, sparc_o7); } sparc_srl_imm (code, sparc_o7, 4, sparc_o7); sparc_and_imm (code, FALSE, sparc_o7, 2047, sparc_o7); diff --git a/mono/mini/mini-sparc.h b/mono/mini/mini-sparc.h index 5cc2ec47a61..6d1c171bf0c 100644 --- a/mono/mini/mini-sparc.h +++ b/mono/mini/mini-sparc.h @@ -82,7 +82,7 @@ typedef struct MonoContext { typedef struct MonoCompileArch { gint32 lmf_offset; gint32 localloc_offset; - void *float_spill_slot; + gint32 float_spill_slot_offset; } MonoCompileArch; #define MONO_CONTEXT_SET_IP(ctx,eip) do { (ctx)->ip = (gpointer)(eip); } while (0); diff --git a/mono/mini/mini.c b/mono/mini/mini.c index 15007eb8b67..da9fa3c267f 100644 --- a/mono/mini/mini.c +++ b/mono/mini/mini.c @@ -2716,13 +2716,9 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code, case MONO_PATCH_INFO_INTERRUPTION_REQUEST_FLAG: target = mono_thread_interruption_request_flag (); break; - case MONO_PATCH_INFO_METHOD_RGCTX: { - MonoVTable *vtable = mono_class_vtable (domain, patch_info->data.method->klass); - g_assert (vtable); - - target = mono_method_lookup_rgctx (vtable, mini_method_get_context (patch_info->data.method)->method_inst); + case MONO_PATCH_INFO_METHOD_RGCTX: + target = mono_method_lookup_rgctx (mono_class_vtable (domain, patch_info->data.method->klass), mini_method_get_context (patch_info->data.method)->method_inst); break; - } case MONO_PATCH_INFO_BB_OVF: case MONO_PATCH_INFO_EXC_OVF: case MONO_PATCH_INFO_GOT_OFFSET: @@ -4260,7 +4256,6 @@ mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, MonoException mono_jit_stats.methods_lookups++; vtable = mono_class_vtable (domain, method->klass); - g_assert (vtable); mono_runtime_class_init (vtable); return mono_create_ftnptr (target_domain, info->code_start); } @@ -4401,8 +4396,6 @@ typedef struct { gpointer compiled_method; gpointer runtime_invoke; MonoVTable *vtable; - MonoDynCallInfo *dyn_call_info; - MonoClass *ret_box_class; } RuntimeInvokeInfo; /** @@ -4445,6 +4438,7 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec info = g_new0 (RuntimeInvokeInfo, 1); invoke = mono_marshal_get_runtime_invoke (method, FALSE); + info->runtime_invoke = mono_jit_compile_method (invoke); info->vtable = mono_class_vtable (domain, method->klass); g_assert (info->vtable); @@ -4474,80 +4468,6 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec info->compiled_method = mono_create_static_rgctx_trampoline (method, info->compiled_method); } - /* - * We want to avoid AOTing 1000s of runtime-invoke wrappers when running - * in full-aot mode, so we use a slower, but more generic wrapper if - * possible, built on top of the OP_DYN_CALL opcode provided by the JIT. - */ -#ifdef MONO_ARCH_DYN_CALL_SUPPORTED - if (mono_aot_only || debug_options.dyn_runtime_invoke) { - MonoMethodSignature *sig = mono_method_signature (method); - gboolean supported = TRUE; - int i; - - if (method->string_ctor) - sig = mono_marshal_get_string_ctor_signature (method); - - for (i = 0; i < sig->param_count; ++i) { - MonoType *t = sig->params [i]; - - if (t->type == MONO_TYPE_GENERICINST && mono_class_is_nullable (mono_class_from_mono_type (t))) - supported = FALSE; - } - - if (method->klass->contextbound || !info->compiled_method) - supported = FALSE; - - if (supported) - info->dyn_call_info = mono_arch_dyn_call_prepare (sig); - - if (info->dyn_call_info) { - switch (sig->ret->type) { - case MONO_TYPE_VOID: - break; - case MONO_TYPE_I1: - case MONO_TYPE_U1: - case MONO_TYPE_I2: - case MONO_TYPE_U2: - case MONO_TYPE_I4: - case MONO_TYPE_U4: - case MONO_TYPE_I: - case MONO_TYPE_U: - case MONO_TYPE_I8: - case MONO_TYPE_U8: - case MONO_TYPE_BOOLEAN: - case MONO_TYPE_CHAR: - case MONO_TYPE_R4: - case MONO_TYPE_R8: - info->ret_box_class = mono_class_from_mono_type (sig->ret); - break; - case MONO_TYPE_PTR: - info->ret_box_class = mono_defaults.int_class; - break; - case MONO_TYPE_STRING: - case MONO_TYPE_CLASS: - case MONO_TYPE_ARRAY: - case MONO_TYPE_SZARRAY: - case MONO_TYPE_OBJECT: - break; - case MONO_TYPE_GENERICINST: - if (!MONO_TYPE_IS_REFERENCE (sig->ret)) - info->ret_box_class = mono_class_from_mono_type (sig->ret); - break; - case MONO_TYPE_VALUETYPE: - info->ret_box_class = mono_class_from_mono_type (sig->ret); - break; - default: - g_assert_not_reached (); - break; - } - } - } -#endif - - if (!info->dyn_call_info) - info->runtime_invoke = mono_jit_compile_method (invoke); - mono_domain_lock (domain); info2 = g_hash_table_lookup (domain_info->runtime_invoke_hash, method); if (info2) { @@ -4556,7 +4476,7 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec } else { g_hash_table_insert (domain_info->runtime_invoke_hash, method, info); } - mono_domain_unlock (domain); + mono_domain_unlock (domain); } runtime_invoke = info->runtime_invoke; @@ -4567,52 +4487,6 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec */ mono_runtime_class_init (info->vtable); -#ifdef MONO_ARCH_DYN_CALL_SUPPORTED - if (info->dyn_call_info) { - MonoMethodSignature *sig = mono_method_signature (method); - gpointer *args; - static RuntimeInvokeDynamicFunction dyn_runtime_invoke; - int i, pindex; - guint8 buf [128]; - guint8 retval [128]; - - if (!dyn_runtime_invoke) { - invoke = mono_marshal_get_runtime_invoke_dynamic (); - dyn_runtime_invoke = mono_jit_compile_method (invoke); - } - - /* Convert the arguments to the format expected by start_dyn_call () */ - args = g_alloca ((sig->param_count + sig->hasthis) * sizeof (gpointer)); - pindex = 0; - if (sig->hasthis) - args [pindex ++] = &obj; - for (i = 0; i < sig->param_count; ++i) { - MonoType *t = sig->params [i]; - - if (t->byref) { - args [pindex ++] = ¶ms [i]; - } else if (MONO_TYPE_IS_REFERENCE (t) || t->type == MONO_TYPE_PTR) { - args [pindex ++] = ¶ms [i]; - } else { - args [pindex ++] = params [i]; - } - } - - //printf ("M: %s\n", mono_method_full_name (method, TRUE)); - - mono_arch_start_dyn_call (info->dyn_call_info, (gpointer**)args, retval, buf, sizeof (buf)); - - dyn_runtime_invoke (buf, exc, info->compiled_method); - - mono_arch_finish_dyn_call (info->dyn_call_info, buf); - - if (info->ret_box_class) - return mono_value_box (domain, info->ret_box_class, retval); - else - return *(MonoObject**)retval; - } -#endif - return runtime_invoke (obj, params, exc, info->compiled_method); } @@ -4804,11 +4678,9 @@ mini_parse_debug_options (void) debug_options.suspend_on_sigsegv = TRUE; else if (!strcmp (arg, "dont-free-domains")) mono_dont_free_domains = TRUE; - else if (!strcmp (arg, "dyn-runtime-invoke")) - debug_options.dyn_runtime_invoke = TRUE; else { fprintf (stderr, "Invalid option for the MONO_DEBUG env variable: %s\n", arg); - fprintf (stderr, "Available options: 'handle-sigint', 'keep-delegates', 'collect-pagefault-stats', 'break-on-unverified', 'no-gdb-backtrace', 'dont-free-domains', 'suspend-on-sigsegv', 'dyn-runtime-invoke'\n"); + fprintf (stderr, "Available options: 'handle-sigint', 'keep-delegates', 'collect-pagefault-stats', 'break-on-unverified', 'no-gdb-backtrace', 'dont-free-domains', 'suspend-on-sigsegv'\n"); exit (1); } } @@ -4858,8 +4730,6 @@ mini_get_addr_from_ftnptr (gpointer descr) return descr; #endif } - -static void runtime_invoke_info_free (gpointer value); static void mini_create_jit_domain_info (MonoDomain *domain) @@ -4872,7 +4742,7 @@ mini_create_jit_domain_info (MonoDomain *domain) info->delegate_trampoline_hash = g_hash_table_new (mono_aligned_addr_hash, NULL); info->static_rgctx_trampoline_hash = g_hash_table_new (mono_aligned_addr_hash, NULL); info->llvm_vcall_trampoline_hash = g_hash_table_new (mono_aligned_addr_hash, NULL); - info->runtime_invoke_hash = g_hash_table_new_full (mono_aligned_addr_hash, NULL, NULL, runtime_invoke_info_free); + info->runtime_invoke_hash = g_hash_table_new_full (mono_aligned_addr_hash, NULL, NULL, g_free); domain->runtime_info = info; } @@ -4892,18 +4762,6 @@ dynamic_method_info_free (gpointer key, gpointer value, gpointer user_data) } static void -runtime_invoke_info_free (gpointer value) -{ - RuntimeInvokeInfo *info = (RuntimeInvokeInfo*)value; - -#ifdef MONO_ARCH_DYN_CALL_SUPPORTED - if (info->dyn_call_info) - mono_arch_dyn_call_free (info->dyn_call_info); -#endif - g_free (info); -} - -static void mini_free_jit_domain_info (MonoDomain *domain) { MonoJitDomainInfo *info = domain_jit_info (domain); diff --git a/mono/mini/mini.h b/mono/mini/mini.h index aeff2762577..e7b08bcf080 100644 --- a/mono/mini/mini.h +++ b/mono/mini/mini.h @@ -158,11 +158,6 @@ typedef struct { #define domain_jit_info(domain) ((MonoJitDomainInfo*)((domain)->runtime_info)) -/* Arch-specific */ -typedef struct { - int dummy; -} MonoDynCallInfo; - #if 0 #define mono_bitset_foreach_bit(set,b,n) \ for (b = 0; b < n; b++)\ @@ -1033,9 +1028,6 @@ typedef struct { /*Use to implement simd constructors. This is a vector (16 bytes) var.*/ MonoInst *simd_ctor_var; - /* Used to implement dyn_call */ - MonoInst *dyn_call_var; - /* Used by AOT */ guint32 got_offset; } MonoCompile; @@ -1239,7 +1231,6 @@ typedef struct { gboolean mdb_optimizations; gboolean no_gdb_backtrace; gboolean suspend_on_sigsegv; - gboolean dyn_runtime_invoke; } MonoDebugOptions; enum { @@ -1591,10 +1582,6 @@ gboolean mono_arch_print_tree (MonoInst *tree, int arity) MONO_INTERNAL; void mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call) MONO_INTERNAL; void mono_arch_emit_outarg_vt (MonoCompile *cfg, MonoInst *ins, MonoInst *src) MONO_INTERNAL; void mono_arch_emit_setret (MonoCompile *cfg, MonoMethod *method, MonoInst *val) MONO_INTERNAL; -MonoDynCallInfo *mono_arch_dyn_call_prepare (MonoMethodSignature *sig) MONO_INTERNAL; -void mono_arch_dyn_call_free (MonoDynCallInfo *info) MONO_INTERNAL; -void mono_arch_start_dyn_call (MonoDynCallInfo *info, gpointer **args, guint8 *ret, guint8 *buf, int buf_len) MONO_INTERNAL; -void mono_arch_finish_dyn_call (MonoDynCallInfo *info, guint8 *buf) MONO_INTERNAL; MonoInst *mono_arch_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) MONO_INTERNAL; void mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) MONO_INTERNAL; void mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *ins) MONO_INTERNAL; @@ -1667,7 +1654,6 @@ void mono_jit_walk_stack_from_ctx (MonoStackWalk func, MonoContext void mono_setup_altstack (MonoJitTlsData *tls) MONO_INTERNAL; void mono_free_altstack (MonoJitTlsData *tls) MONO_INTERNAL; gpointer mono_altstack_restore_prot (mgreg_t *regs, guint8 *code, gpointer *tramp_data, guint8* tramp) MONO_INTERNAL; -MonoJitInfo* mini_jit_info_table_find (MonoDomain *domain, char *addr) MONO_INTERNAL; MonoJitInfo * mono_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInfo *res, MonoJitInfo *prev_ji, MonoContext *ctx, MonoContext *new_ctx, char **trace, MonoLMF **lmf, int *native_offset, gboolean *managed) MONO_INTERNAL; diff --git a/mono/mini/tramp-arm.c b/mono/mini/tramp-arm.c index b779b44f928..1a6d5bde32c 100644 --- a/mono/mini/tramp-arm.c +++ b/mono/mini/tramp-arm.c @@ -172,7 +172,7 @@ mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs) /* Jump-specific trampoline code fragment size */ #define JUMP_TRAMPOLINE_SIZE 64 -#define GEN_TRAMP_SIZE 196 +#define GEN_TRAMP_SIZE 192 /* * Stack frame description when the generic trampoline is called. @@ -286,10 +286,6 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c /* save method info (it's in v2) */ if ((tramp_type == MONO_TRAMPOLINE_JIT) || (tramp_type == MONO_TRAMPOLINE_JUMP)) ARM_STR_IMM (code, ARMREG_V2, ARMREG_R1, G_STRUCT_OFFSET (MonoLMF, method)); - else { - ARM_MOV_REG_IMM8 (code, ARMREG_R2, 0); - ARM_STR_IMM (code, ARMREG_R2, ARMREG_R1, G_STRUCT_OFFSET (MonoLMF, method)); - } ARM_STR_IMM (code, ARMREG_SP, ARMREG_R1, G_STRUCT_OFFSET (MonoLMF, ebp)); /* save the IP (caller ip) */ if (tramp_type == MONO_TRAMPOLINE_JUMP) { diff --git a/mono/monograph/monograph.c b/mono/monograph/monograph.c index 58e25335c61..5451b8b54f3 100644 --- a/mono/monograph/monograph.c +++ b/mono/monograph/monograph.c @@ -550,9 +550,9 @@ get_signature (MonoMethod *method) { res = g_string_new (""); if (include_namespace && *(method->klass->name_space)) - g_string_append_printf (res, "%s.", method->klass->name_space); + g_string_sprintfa (res, "%s.", method->klass->name_space); result = mono_signature_get_desc (mono_method_signature (method), include_namespace); - g_string_append_printf (res, "%s:%s(%s)", method->klass->name, method->name, result); + g_string_sprintfa (res, "%s:%s(%s)", method->klass->name, method->name, result); g_free (result); g_hash_table_insert (hash, method, res->str); @@ -1147,10 +1147,10 @@ main (int argc, char *argv[]) { if (outputfile) { type = strrchr (outputfile, '.'); - g_string_append_printf (command, " -o %s", outputfile); + g_string_sprintfa (command, " -o %s", outputfile); } if (type) - g_string_append_printf (command, " -T%s", type + 1); + g_string_sprintfa (command, " -T%s", type + 1); output = popen (command->str, "w"); if (!output) { g_print ("Cannot run neato: you may need to install the graphviz package.\n"); diff --git a/mono/profiler/ChangeLog b/mono/profiler/ChangeLog index 1a31fbce2b6..b84fa61c9fd 100644 --- a/mono/profiler/ChangeLog +++ b/mono/profiler/ChangeLog @@ -1,8 +1,3 @@ -2009-09-14 Massimiliano Mantione <massi@ximian.com> - * mono-profiler-logging.c: Removed the use of signals to control the - profiler and extended the socket based interface to control also - heap snapshots. - 2009-08-21 Massimiliano Mantione <massi@ximian.com> * mono-profiler-logging.c: Changed max depth of call chains to 128. diff --git a/mono/profiler/mono-profiler-logging.c b/mono/profiler/mono-profiler-logging.c index 05ac38c8ad6..e241bc954f2 100644 --- a/mono/profiler/mono-profiler-logging.c +++ b/mono/profiler/mono-profiler-logging.c @@ -416,7 +416,7 @@ typedef struct _ProfilerHeapShotWriteJob { ProfilerHeapShotWriteBuffer *buffers; ProfilerHeapShotWriteBuffer **last_next; guint32 full_buffers; - gboolean heap_shot_was_requested; + gboolean heap_shot_was_signalled; guint64 start_counter; guint64 start_time; guint64 end_counter; @@ -900,8 +900,10 @@ struct _MonoProfiler { int command_port; + char *heap_shot_command_file_name; int dump_next_heap_snapshots; - gboolean heap_shot_was_requested; + guint64 heap_shot_command_file_access_time; + gboolean heap_shot_was_signalled; guint32 garbage_collection_counter; ProfilerExecutableMemoryRegions *executable_regions; @@ -925,6 +927,47 @@ struct _MonoProfiler { }; static MonoProfiler *profiler; +#ifndef PLATFORM_WIN32 +#include <signal.h> + +#ifdef MONO_ARCH_USE_SIGACTION +#define SIG_HANDLER_SIGNATURE(ftn) ftn (int _dummy, siginfo_t *info, void *context) +#elif defined(__sparc__) +#define SIG_HANDLER_SIGNATURE(ftn) ftn (int _dummy, void *sigctx) +#else +#define SIG_HANDLER_SIGNATURE(ftn) ftn (int _dummy) +#endif + +static void +request_heap_snapshot (void) { + profiler->heap_shot_was_signalled = TRUE; + mono_gc_collect (mono_gc_max_generation ()); +} + +static void +SIG_HANDLER_SIGNATURE (gc_request_handler) { + profiler->heap_shot_was_signalled = TRUE; + WRITER_EVENT_RAISE (); +} + +static void +add_gc_request_handler (int signal_number) +{ + struct sigaction sa; + +#ifdef MONO_ARCH_USE_SIGACTION + sa.sa_sigaction = gc_request_handler; + sigemptyset (&sa.sa_mask); + sa.sa_flags = SA_SIGINFO; +#else + sa.sa_handler = gc_request_handler; + sigemptyset (&sa.sa_mask); + sa.sa_flags = 0; +#endif + + g_assert (sigaction (signal_number, &sa, NULL) != -1); +} + static void enable_profiler (void) { profiler->profiler_enabled = TRUE; @@ -938,12 +981,38 @@ disable_profiler (void) { flush_everything (); } + + static void -request_heap_snapshot (void) { - profiler->heap_shot_was_requested = TRUE; - mono_gc_collect (mono_gc_max_generation ()); +SIG_HANDLER_SIGNATURE (toggle_handler) { + if (profiler->profiler_enabled) { + profiler->profiler_enabled = FALSE; + } else { + profiler->profiler_enabled = TRUE; + } } +static void +add_toggle_handler (int signal_number) +{ + struct sigaction sa; + +#ifdef MONO_ARCH_USE_SIGACTION + sa.sa_sigaction = toggle_handler; + sigemptyset (&sa.sa_mask); + sa.sa_flags = SA_SIGINFO; +#else + sa.sa_handler = toggle_handler; + sigemptyset (&sa.sa_mask); + sa.sa_flags = 0; +#endif + + g_assert (sigaction (signal_number, &sa, NULL) != -1); +} +#endif + + + #define DEBUG_LOAD_EVENTS 0 #define DEBUG_MAPPING_EVENTS 0 #define DEBUG_LOGGING_PROFILER 0 @@ -1633,7 +1702,7 @@ profiler_heap_shot_object_buffer_new (ProfilerPerThreadData *data) { } static ProfilerHeapShotWriteJob* -profiler_heap_shot_write_job_new (gboolean heap_shot_was_requested, gboolean dump_heap_data, guint32 collection) { +profiler_heap_shot_write_job_new (gboolean heap_shot_was_signalled, gboolean dump_heap_data, guint32 collection) { ProfilerHeapShotWriteJob *job = g_new (ProfilerHeapShotWriteJob, 1); job->next = NULL; job->next_unwritten = NULL; @@ -1662,7 +1731,7 @@ profiler_heap_shot_write_job_new (gboolean heap_shot_was_requested, gboolean dum job->summary.per_class_data = NULL; } - job->heap_shot_was_requested = heap_shot_was_requested; + job->heap_shot_was_signalled = heap_shot_was_signalled; job->collection = collection; job->dump_heap_data = dump_heap_data; #if DEBUG_HEAP_PROFILER @@ -4736,13 +4805,46 @@ gc_event_kind_from_profiler_event (MonoGCEvent event) { } } +#define HEAP_SHOT_COMMAND_FILE_MAX_LENGTH 64 +static void +profiler_heap_shot_process_command_file (void) { + //FIXME: Port to Windows as well + struct stat stat_buf; + int fd; + char buffer [HEAP_SHOT_COMMAND_FILE_MAX_LENGTH + 1]; + + if (profiler->heap_shot_command_file_name == NULL) + return; + if (stat (profiler->heap_shot_command_file_name, &stat_buf) != 0) + return; + if (stat_buf.st_size > HEAP_SHOT_COMMAND_FILE_MAX_LENGTH) + return; + if ((stat_buf.st_mtim.tv_sec * 1000000) < profiler->heap_shot_command_file_access_time) + return; + + fd = open (profiler->heap_shot_command_file_name, O_RDONLY); + if (fd < 0) { + return; + } else { + if (read (fd, &(buffer [0]), stat_buf.st_size) != stat_buf.st_size) { + return; + } else { + buffer [stat_buf.st_size] = 0; + profiler->dump_next_heap_snapshots = atoi (buffer); + MONO_PROFILER_GET_CURRENT_TIME (profiler->heap_shot_command_file_access_time); + } + close (fd); + } +} + static gboolean dump_current_heap_snapshot (void) { gboolean result; - if (profiler->heap_shot_was_requested) { + if (profiler->heap_shot_was_signalled) { result = TRUE; } else { + profiler_heap_shot_process_command_file (); if (profiler->dump_next_heap_snapshots > 0) { profiler->dump_next_heap_snapshots--; result = TRUE; @@ -5039,8 +5141,8 @@ process_gc_event (MonoProfiler *profiler, gboolean do_heap_profiling, MonoGCEven ProfilerPerThreadData *data; if (heap_shot_write_job_should_be_created (dump_heap_data)) { - job = profiler_heap_shot_write_job_new (profiler->heap_shot_was_requested, dump_heap_data, profiler->garbage_collection_counter); - profiler->heap_shot_was_requested = FALSE; + job = profiler_heap_shot_write_job_new (profiler->heap_shot_was_signalled, dump_heap_data, profiler->garbage_collection_counter); + profiler->heap_shot_was_signalled = FALSE; MONO_PROFILER_GET_CURRENT_COUNTER (job->start_counter); MONO_PROFILER_GET_CURRENT_TIME (job->start_time); } else { @@ -5177,31 +5279,6 @@ execute_user_command (char *command) { LOG_USER_THREAD ("execute_user_command: disabling profiler"); disable_profiler (); write_user_response ("DONE\n"); - } else if (strcmp (command, "heap-snapshot") == 0) { - LOG_USER_THREAD ("execute_user_command: taking heap snapshot"); - profiler->heap_shot_was_requested = TRUE; - WRITER_EVENT_RAISE (); - write_user_response ("DONE\n"); - } else if (strstr (command, "heap-snapshot-counter") == 0) { - char *equals; - LOG_USER_THREAD ("execute_user_command: changing heap counter"); - equals = strstr (command, "="); - if (equals != NULL) { - equals ++; - if (strcmp (equals, "all") == 0) { - LOG_USER_THREAD ("execute_user_command: heap counter is \"all\""); - profiler->garbage_collection_counter = -1; - } else if (strcmp (equals, "none") == 0) { - LOG_USER_THREAD ("execute_user_command: heap counter is \"none\""); - profiler->garbage_collection_counter = 0; - } else { - profiler->garbage_collection_counter = atoi (equals); - } - write_user_response ("DONE\n"); - } else { - write_user_response ("ERROR\n"); - } - profiler->heap_shot_was_requested = TRUE; } else { LOG_USER_THREAD ("execute_user_command: command not recognized"); write_user_response ("ERROR\n"); @@ -5372,6 +5449,9 @@ profiler_shutdown (MonoProfiler *prof) } profiler_heap_buffers_free (&(profiler->heap)); + if (profiler->heap_shot_command_file_name != NULL) { + g_free (profiler->heap_shot_command_file_name); + } profiler_free_write_buffers (); profiler_destroy_heap_shot_write_jobs (); @@ -5388,6 +5468,31 @@ profiler_shutdown (MonoProfiler *prof) profiler = NULL; } +#ifndef PLATFORM_WIN32 +static int +parse_signal_name (const char *signal_name) { + if (! strcasecmp (signal_name, "SIGUSR1")) { + return SIGUSR1; + } else if (! strcasecmp (signal_name, "SIGUSR2")) { + return SIGUSR2; + } else if (! strcasecmp (signal_name, "SIGPROF")) { + return SIGPROF; + } else { + return atoi (signal_name); + } +} +static gboolean +check_signal_number (int signal_number) { + if (((signal_number == SIGPROF) && ! (profiler->flags & MONO_PROFILE_STATISTICAL)) || + (signal_number == SIGUSR1) || + (signal_number == SIGUSR2)) { + return TRUE; + } else { + return FALSE; + } +} +#endif + #define FAIL_ARGUMENT_CHECK(message) do {\ failure_message = (message);\ goto failure_handling;\ @@ -5407,6 +5512,10 @@ profiler_shutdown (MonoProfiler *prof) static void setup_user_options (const char *arguments) { gchar **arguments_array, **current_argument; +#ifndef PLATFORM_WIN32 + int gc_request_signal_number = 0; + int toggle_signal_number = 0; +#endif detect_fast_timer (); profiler->file_name = NULL; @@ -5415,8 +5524,10 @@ setup_user_options (const char *arguments) { profiler->statistical_buffer_size = 10000; profiler->statistical_call_chain_depth = 0; profiler->write_buffer_size = 1024; + profiler->heap_shot_command_file_name = NULL; profiler->dump_next_heap_snapshots = 0; - profiler->heap_shot_was_requested = FALSE; + profiler->heap_shot_command_file_access_time = 0; + profiler->heap_shot_was_signalled = FALSE; profiler->flags = MONO_PROFILE_APPDOMAIN_EVENTS| MONO_PROFILE_ASSEMBLY_EVENTS| MONO_PROFILE_MODULE_EVENTS| @@ -5502,7 +5613,7 @@ setup_user_options (const char *arguments) { if (! strcmp (parameter, "all")) { profiler->dump_next_heap_snapshots = -1; } else { - profiler->dump_next_heap_snapshots = atoi (parameter); + gc_request_signal_number = parse_signal_name (parameter); } FAIL_IF_HAS_MINUS; if (! has_plus) { @@ -5511,6 +5622,11 @@ setup_user_options (const char *arguments) { profiler->action_flags.allocations_carry_id = TRUE_IF_NOT_MINUS; } profiler->action_flags.heap_shot = TRUE_IF_NOT_MINUS; + } else if (! (strncmp (argument, "gc-commands", equals_position) && strncmp (argument, "gc-c", equals_position) && strncmp (argument, "gcc", equals_position))) { + FAIL_IF_HAS_MINUS; + if (strlen (equals + 1) > 0) { + profiler->heap_shot_command_file_name = g_strdup (equals + 1); + } } else if (! (strncmp (argument, "gc-dumps", equals_position) && strncmp (argument, "gc-d", equals_position) && strncmp (argument, "gcd", equals_position))) { FAIL_IF_HAS_MINUS; if (strlen (equals + 1) > 0) { @@ -5521,6 +5637,14 @@ setup_user_options (const char *arguments) { if (strlen (equals + 1) > 0) { profiler->command_port = atoi (equals + 1); } +#ifndef PLATFORM_WIN32 + } else if (! (strncmp (argument, "toggle-signal", equals_position) && strncmp (argument, "ts", equals_position))) { + FAIL_IF_HAS_MINUS; + if (strlen (equals + 1) > 0) { + char *signal_name = equals + 1; + toggle_signal_number = parse_signal_name (signal_name); + } +#endif } else { FAIL_PARSING_VALUED_ARGUMENT; } @@ -5607,6 +5731,23 @@ failure_handling: g_free (arguments_array); +#ifndef PLATFORM_WIN32 + if (gc_request_signal_number != 0) { + if (check_signal_number (gc_request_signal_number) && (gc_request_signal_number != toggle_signal_number)) { + add_gc_request_handler (gc_request_signal_number); + } else { + g_error ("Cannot use signal %d", gc_request_signal_number); + } + } + if (toggle_signal_number != 0) { + if (check_signal_number (toggle_signal_number) && (toggle_signal_number != gc_request_signal_number)) { + add_toggle_handler (toggle_signal_number); + } else { + g_error ("Cannot use signal %d", gc_request_signal_number); + } + } +#endif + /* Ensure that the profiler flags needed to support required action flags are active */ if (profiler->action_flags.jit_time) { profiler->flags |= MONO_PROFILE_JIT_COMPILATION; @@ -5702,7 +5843,7 @@ data_writer_thread (gpointer nothing) { WRITER_EVENT_WAIT (); LOG_WRITER_THREAD ("data_writer_thread: just woke up"); - if (profiler->heap_shot_was_requested) { + if (profiler->heap_shot_was_signalled) { MonoDomain * root_domain = mono_get_root_domain (); if (root_domain != NULL) { diff --git a/mono/tests/ChangeLog b/mono/tests/ChangeLog index 2ad2980ba5b..f823ee48129 100644 --- a/mono/tests/ChangeLog +++ b/mono/tests/ChangeLog @@ -1,66 +1,6 @@ -2009-10-06 Mark Probst <mark.probst@gmail.com> - - * bug-544445.cs: New test. - - * Makefile.am: Test added. - - Backport of r143506. - -2009-09-30 Zoltan Varga <vargaz@gmail.com> - - * pinvoke2.cs libtest.c: Add a test for #543133. - -2009-09-22 Zoltan Varga <vargaz@gmail.com> - - * assembly-load-stress.cs: New stress test. - - * Makefile.am: Disable filter-stack.cs on ia64. - - * appdomain-thread-abort.cs: Add a new test. - -2009-09-21 Zoltan Varga <vargaz@gmail.com> - - * runtime-invoke.cs: Add a test for invoking string ctors. Remove tests which - are auto-generated now by gen-runtime-invoke.cs. - -2009-09-21 Rodrigo Kumpera <rkumpera@novell.com> - - * array_load_exception.il: Test for broken arrays. - -2009-09-21 Zoltan Varga <vargaz@gmail.com> - - * gen-runtime-invoke.cs: New test generator for runtime invoke tests. - - * Makefile.am (test-runtime-invoke): New test target. - - * runtime-invoke.cs: Add more tests. - - * runtime-invoke.cs: Add tests for passing/receiving generic instances of - vtypes. - -2009-09-20 Zoltan Varga <vargaz@gmail.com> - - * runtime-invoke.cs: Add more tests. - -2009-09-17 Sebastien Pouliot <sebastien@ximian.com> - - * coreclr-security.cs: Add test cases for arrays (one dimension, - multidimentional and jagged) creation. - -2009-09-15 Mark Probst <mark.probst@gmail.com> - - * generic-type-load-exception.2.il: Test case for vtable setup - failure in shared generic code. - - * Makefile.am: Test added. - -2009-09-13 Zoltan Varga <vargaz@gmail.com> - - * runtime-invoke.cs: Add a test. - 2009-09-10 Bill Holmes <billholmes54@gmail.com> - * cominterop.cs : Adding a test for invoking delegates that + * cominterop.cs : Adding a test for invoking delegates that target COM methods. Contributed under MIT/X11 license. diff --git a/mono/tests/Makefile.am b/mono/tests/Makefile.am index 1859c954e4f..9759fb4dad5 100644 --- a/mono/tests/Makefile.am +++ b/mono/tests/Makefile.am @@ -45,8 +45,7 @@ STRESS_TESTS_SRC= \ thread-stress.cs \ gc-stress.cs \ exit-stress.cs \ - process-stress.cs \ - assembly-load-stress.cs + process-stress.cs BASE_TEST_CS_SRC= \ array-init.cs \ @@ -359,8 +358,7 @@ BASE_TEST_CS_SRC= \ finalizer-wait.cs \ critical-finalizers.cs \ appdomain-thread-abort.cs \ - w32message.cs \ - bug-544446.cs + w32message.cs if AMD64 TEST_CS_SRC = $(BASE_TEST_CS_SRC) async-exc-compilation.cs @@ -373,7 +371,7 @@ endif endif if IA64 -TEST_CS_SRC+=async-exc-compilation.cs filter-stack.cs +TEST_CS_SRC+=async-exc-compilation.cs # bug #319249 PLATFORM_DISABLED_TESTS=exception17.exe PLATFORM_DISABLED_TESTS+=winx64structs.exe @@ -457,7 +455,6 @@ TEST_IL_SRC= \ generic-valuetype-newobj2.2.il \ generic-valuetype-newobj.2.il \ generic-constrained.2.il \ - generic-type-load-exception.2.il \ bug-81466.il \ bug457574.il \ bug445361.il \ @@ -465,7 +462,6 @@ TEST_IL_SRC= \ bug469742.2.il \ bug-528055.il \ constraints-load.il \ - array_load_exception.il \ bug-481403.il # bug-318677.il @@ -522,7 +518,7 @@ endif # test_messages fails on the buildbots #test: assemblyresolve/test/asm.dll testjit test-type-load test-generic-sharing test_platform test_2_1 test_messages -test: assemblyresolve/test/asm.dll testjit test-type-load test-generic-sharing test_platform test-runtime-invoke test_2_1 +test: assemblyresolve/test/asm.dll testjit test-type-load test-generic-sharing test_platform test_2_1 assemblyresolve/test/asm.dll: $(MAKE) -C assemblyresolve prereq @@ -642,14 +638,6 @@ test-type-load: TestDriver.dll @echo "Testing load-exception.exe..." @$(RUNTIME) load-exceptions.exe > load-exceptions.exe.stdout 2> load-exceptions.exe.stderr -# Generated tests for runtime invoke -EXTRA_DIST += gen-runtime-invoke.cs -test-runtime-invoke: TestDriver.dll gen-runtime-invoke.exe - @$(RUNTIME) gen-runtime-invoke.exe > runtime-invoke.gen.cs - @$(MCS) -out:runtime-invoke.gen.exe -r:TestDriver.dll runtime-invoke.gen.cs - @echo "Testing runtime-invoke.gen.exe..." - @$(RUNTIME) runtime-invoke.gen.exe > runtime-invoke.gen.exe.stdout 2> runtime-invoke.gen.exe.stderr - EXTRA_DIST += test-inline-call-stack-library.cs test-inline-call-stack.cs test-inline-call-stack-library.dll: TestDriver.dll $(srcdir)/test-inline-call-stack-library.cs $(MCS) -t:library -out:test-inline-call-stack-library.dll $(srcdir)/test-inline-call-stack-library.cs @@ -792,8 +780,7 @@ test-generic-sharing : generics-sharing.2.exe shared-generic-methods.2.exe \ generic-sealed-virtual.2.exe generic-system-arrays.2.exe \ generic-stack-traces.2.exe generic-stack-traces2.2.exe \ bug-472600.2.exe bug-473482.2.exe bug-473999.2.exe \ - bug-479763.2.exe generic-xdomain.2.exe \ - generic-type-load-exception.2.exe + bug-479763.2.exe generic-xdomain.2.exe @for fn in $+ ; do \ echo "Testing $$fn ..."; \ MONO_GENERIC_SHARING=all $(RUNTIME) -O=gshared $$fn > $$fn.stdout || exit 1; \ diff --git a/mono/tests/appdomain-thread-abort.cs b/mono/tests/appdomain-thread-abort.cs index 77015fb7b49..c4fa9ea0286 100644 --- a/mono/tests/appdomain-thread-abort.cs +++ b/mono/tests/appdomain-thread-abort.cs @@ -1,36 +1,10 @@ using System; using System.Threading; using System.Runtime.Remoting; -using System.Reflection; public class JustSomeClass { } -public class Test2 : ContextBoundObject -{ - public void Run () { - Thread.CurrentThread.Abort (); - } -} - -public class Test1 : MarshalByRefObject -{ - public bool Run () { - AppDomain d = AppDomain.CreateDomain ("foo2"); - - var t2 = (Test2)d.CreateInstanceAndUnwrap (Assembly.GetExecutingAssembly().FullName, - "Test2"); - try { - t2.Run (); - } catch (ThreadAbortException ex) { - Thread.ResetAbort (); - return true; - } - - return false; - } -} - public class Test : MarshalByRefObject { ThreadAbortException exc; public JustSomeClass other; @@ -194,26 +168,6 @@ public class main { return 11; } - // #539394 - // Calling Thread.Abort () from a remoting call throws a ThreadAbortException which - // cannot be caught because the exception handling code is confused by the domain - // transitions - bool res = false; - - Thread thread = new Thread (delegate () { - AppDomain d = AppDomain.CreateDomain ("foo"); - - var t = (Test1)d.CreateInstanceAndUnwrap (Assembly.GetExecutingAssembly().FullName, - "Test1"); - res = t.Run (); - }); - - thread.Start (); - thread.Join (); - - if (!res) - return 12; - Console.WriteLine ("done"); return 0; diff --git a/mono/tests/array_load_exception.il b/mono/tests/array_load_exception.il deleted file mode 100644 index 7df0cf739cf..00000000000 --- a/mono/tests/array_load_exception.il +++ /dev/null @@ -1,235 +0,0 @@ -.assembly extern mscorlib -{ - .ver 2:0:0:0 - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. -} -.assembly extern TestDriver -{ - .ver 0:0:0:0 -} - -.assembly 'test' -{ - .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = ( - 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx - 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. - - .hash algorithm 0x00008004 - .ver 0:0:0:0 -} -.module test.exe // GUID = {36476DF0-2B03-45C8-B512-E12B67C7C094} - - - .class interface private auto ansi abstract IFoo - { - - // method line 1 - .method public virtual hidebysig newslot abstract - instance default int32 A () cil managed - { - // Method begins at RVA 0x0 - } // end of method IFoo::A - - } // end of class IFoo - - - .class public auto ansi sealed Dele - extends [mscorlib]System.MulticastDelegate implements IFoo - { - - // method line 5 - .method public hidebysig specialname rtspecialname - instance default void '.ctor' (object 'object', native int 'method') runtime managed - { - // Method begins at RVA 0x0 - // Disassembly of native methods is not supported - } // end of method Dele::.ctor - - // method line 6 - .method public virtual hidebysig newslot - instance default void Invoke () runtime managed - { - // Method begins at RVA 0x0 - // Disassembly of native methods is not supported - } // end of method Dele::Invoke - - // method line 7 - .method public virtual hidebysig newslot - instance default class [mscorlib]System.IAsyncResult BeginInvoke (class [mscorlib]System.AsyncCallback callback, object 'object') runtime managed - { - // Method begins at RVA 0x0 - // Disassembly of native methods is not supported - } // end of method Dele::BeginInvoke - - // method line 8 - .method public virtual hidebysig newslot - instance default void EndInvoke (class [mscorlib]System.IAsyncResult result) runtime managed - { - // Method begins at RVA 0x0 - // Disassembly of native methods is not supported - } // end of method Dele::EndInvoke - - } // end of class Dele - - - .class private auto ansi beforefieldinit Foo - extends [mscorlib]System.Object - implements IFoo { - - // method line 2 - .method public hidebysig specialname rtspecialname - instance default void '.ctor' () cil managed - { - // Method begins at RVA 0x20ec - // Code size 7 (0x7) - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void object::'.ctor'() - IL_0006: ret - } // end of method Foo::.ctor - - - // method line 4 - .method public hidebysig - instance default int32 SSS () cil managed - { - // Method begins at RVA 0x20f8 - // Code size 3 (0x3) - .maxstack 8 - IL_0000: ldc.i4.s 0x14 - IL_0002: ret - } // end of method Foo::SSS - - } // end of class Foo - - .class public sequential ansi sealed beforefieldinit FooStruct extends [mscorlib]System.ValueType implements IFoo { - .field public int32 blarg - - } // end of class FooStruct - - .class public auto ansi beforefieldinit Tests - extends [mscorlib]System.Object - { - .method private static hidebysig - default void array_ldelema (class Foo& f) cil managed - { - .maxstack 8 - ldarg.0 - ldind.ref - callvirt instance int32 class Foo::SSS() - pop - ret - } - - .method private static hidebysig - default void array_ldelema (class Foo[] arr) cil managed - { - .maxstack 8 - ldarg.0 - ldc.i4.0 - ldelema Foo - call void class Tests::array_ldelema([out] class Foo&) - ret - } - - .method public static hidebysig default int32 test_0_ldelema_type_check () cil managed - { - .maxstack 2 - .try { - ldnull - call void class Tests::array_ldelema(class Foo[]) - leave BAD - } - catch class [mscorlib]System.TypeLoadException { // 0 - call void class [mscorlib]System.Console::WriteLine(object) - leave GOOD - } - BAD: - ldc.i4.1 - ret - GOOD: - ldc.i4.0 - ret - } - - .method public static hidebysig default void delegate_ctor () cil managed - { - .maxstack 4 - .locals init (object V_0) - ldnull - ldftn void class Tests::delegate_ctor() - newobj instance void class Dele::'.ctor'(object, native int) - stloc.0 - ret - } - - - // method line 3 - .method private static hidebysig default int32 test_0_delegate_ctor () cil managed - { - .maxstack 2 - .try { - ldnull - call void class Tests::delegate_ctor() - leave BAD - } - catch class [mscorlib]System.TypeLoadException { // 0 - call void class [mscorlib]System.Console::WriteLine(object) - leave GOOD - } - BAD: - ldc.i4.1 - ret - GOOD: - ldc.i4.0 - ret - } - - .method private static hidebysig default void generic_box<(class IFoo) T> () cil managed - { - .maxstack 3 - .locals init (!!T V_0, !!T V_1) - ldloca.s 1 - initobj !!0 - ldloc.1 - stloc.0 - ldloca.s 0 - constrained. !!0 - callvirt instance int32 class IFoo::A() - pop - ret - } - - .method private static hidebysig default int32 test_0_generic_box () cil managed - { - .maxstack 2 - .try { - ldnull - call void class Tests::generic_box<valuetype FooStruct> () - leave BAD - } - catch class [mscorlib]System.TypeLoadException { // 0 - call void class [mscorlib]System.Console::WriteLine(object) - leave GOOD - } - BAD: - ldc.i4.1 - ret - GOOD: - ldc.i4.0 - ret - } - - .method private static hidebysig - default int32 Main () cil managed - { - .entrypoint - - ldtoken Tests - call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) - call int32 class [TestDriver]TestDriver::RunTests(class [mscorlib]System.Type) - ret - - } -} - diff --git a/mono/tests/assembly-load-stress.cs b/mono/tests/assembly-load-stress.cs deleted file mode 100644 index ceba7ccf9fd..00000000000 --- a/mono/tests/assembly-load-stress.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Text; -using System.Globalization; -using System.Collections.Generic; -using System.Reflection; -using System.Threading; -using System.IO; - -public class Tests -{ - static int nloops = 1; - static int nthreads = 10; - - public static void Main (String[] args) { - if (args.Length > 0) - nloops = int.Parse (args [0]); - if (args.Length > 1) - nthreads = int.Parse (args [1]); - - for (int li = 0; li < nloops; ++li) { - Thread[] threads = new Thread [nthreads]; - for (int i = 0; i < nthreads; ++i) { - threads [i] = new Thread (delegate () { - foreach (string s in Directory.GetFiles ("/usr/local/lib/mono/2.0", "*.dll")) { - AssemblyName.GetAssemblyName (s); - } - }); - } - for (int i = 0; i < 10; ++i) - threads [i].Start (); - } - } -} diff --git a/mono/tests/bug-544446.cs b/mono/tests/bug-544446.cs deleted file mode 100644 index 80b8fe48ea8..00000000000 --- a/mono/tests/bug-544446.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Messaging; -using System.Runtime.Remoting.Proxies; -using System.Collections.Generic; - -class MyProxy : RealProxy { - readonly MarshalByRefObject target; - - public MyProxy (MarshalByRefObject target) : base (target.GetType()) - { - this.target = target; - } - - public override IMessage Invoke (IMessage request) { - IMethodCallMessage call = (IMethodCallMessage)request; - return RemotingServices.ExecuteMessage (target, call); - } -} - -class R1 : MarshalByRefObject { - - public void foo (out Dictionary<string, int> paramAssignmentStatus) { - - paramAssignmentStatus = new Dictionary<string, int> (); - paramAssignmentStatus.Add ("One", 1); - } -} - -class Test { - static int Main () { - MyProxy real_proxy = new MyProxy (new R1 ()); - R1 o = (R1)real_proxy.GetTransparentProxy (); - - Dictionary<string, int> i; - o.foo (out i); - if (1 == i["One"]) - return 0; - return 1; - } -} diff --git a/mono/tests/coreclr-security.cs b/mono/tests/coreclr-security.cs index 89ad2c1a3f8..93796c9880a 100644 --- a/mono/tests/coreclr-security.cs +++ b/mono/tests/coreclr-security.cs @@ -273,68 +273,6 @@ public class Test [DllImport ("/lib64/libc.so.6")] static extern int getpid (); - - static void ArraysCreatedByTransparentCaller () - { - // Transparent creating an array of a Critical type - // using Class[] (rank == 1) throws a TypeLoadException on SL2 - but that looks like a bug - // reported as https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=490406 - CClass[] c_array = new CClass [0]; - // Transparent creating an array of a SafeCritical type - SCClass[] sc_array = new SCClass [0]; - - // Transparent creating a multidimentional array of a Critical type - CClass[,] c_multi = new CClass [0,0]; - // Transparent creating a multidimentional array of a SafeCritical type - SCClass[,] sc_multi = new SCClass [0,0]; - - // Transparent creating a jagged array of a Critical type - CClass[][] c_jagged = new CClass [0][]; - // Transparent creating a jagged array of a Critical type - SCClass[][] sc_jagged = new SCClass [0][]; - } - - [SecuritySafeCritical] - static void ArraysCreatedBySafeCriticalCaller () - { - // SafeCritical creating an array of a Critical type - CClass[] c_array = new CClass [0]; - // SafeCritical creating an array of a SafeCritical type - SCClass[] sc_array = new SCClass [0]; - - // SafeCritical creating a multidimentional array of a Critical type - CClass[,] c_multi = new CClass [0,0]; - // SafeCritical creating a multidimentional array of a SafeCritical type - SCClass[,] sc_multi = new SCClass [0,0]; - - // SafeCritical creating a jagged array of a Critical type - CClass[][] c_jagged = new CClass [0][]; - // SafeCritical creating a jagged array of a Critical type - SCClass[][] sc_jagged = new SCClass [0][]; - - // Transparent Main could not call a critical method by itself - ArraysCreatedByCriticalCaller (); - } - - [SecurityCritical] - static void ArraysCreatedByCriticalCaller () - { - // Critical creating an array of a Critical type - CClass[] c_array = new CClass [0]; - // Critical creating an array of a SafeCritical type - SCClass[] sc_array = new SCClass [0]; - - // Critical creating a multidimentional array of a Critical type - CClass[,] c_multi = new CClass [0,0]; - // Critical creating a multidimentional array of a SafeCritical type - SCClass[,] sc_multi = new SCClass [0,0]; - - // Critical creating a jagged array of a Critical type - CClass[][] c_jagged = new CClass [0][]; - // Critical creating a jagged array of a Critical type - SCClass[][] sc_jagged = new SCClass [0][]; - } - public static int Main () { SCMethod (); @@ -466,11 +404,6 @@ public class Test } new SafeInheritFromSafeCriticalDefaultConstructor (); - // arrays creation tests - ArraysCreatedByTransparentCaller (); - ArraysCreatedBySafeCriticalCaller (); - // the above also calls ArraysCreatedBySafeCriticalCaller since (Transparent) Main cannot call it directly - if (haveError) return 1; diff --git a/mono/tests/gen-runtime-invoke.cs b/mono/tests/gen-runtime-invoke.cs deleted file mode 100644 index f73da35c714..00000000000 --- a/mono/tests/gen-runtime-invoke.cs +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Test generator for runtime invoke tests. - */ -using System; -using System.IO; - -public class Tests -{ - public static void Main (String[] args) { - /* There are multiple approaches, we generate c# directly */ - - using (var w = new StreamWriter (Console.OpenStandardOutput ())) { - w.WriteLine ("using System;"); - w.WriteLine ("using System.Reflection;"); - w.WriteLine (); - - // Struct with 2 int fields - w.WriteLine ("public struct FooStruct { public int i, j; public static bool operator == (FooStruct f1, FooStruct f2) { return f1.i == f2.i && f1.j == f2.j; } public static bool operator != (FooStruct f1, FooStruct f2) { return f1.i != f2.i || f1.j != f2.j; } public override bool Equals (object obj) { return this == (FooStruct)obj; } public override int GetHashCode () { return 0; } }"); - - // Struct with 1 long field - w.WriteLine ("public struct FooStruct2 { public long i; public static bool operator == (FooStruct2 f1, FooStruct2 f2) { return f1.i == f2.i; } public static bool operator != (FooStruct2 f1, FooStruct2 f2) { return f1.i != f2.i; } public override bool Equals (object obj) { return this == (FooStruct2)obj; } public override int GetHashCode () { return 0; } }"); - - w.WriteLine ("public class Tests {"); - w.WriteLine (" public static int Main (String[] args) {"); - w.WriteLine (" return TestDriver.RunTests (typeof (Tests), args);"); - w.WriteLine (" }"); - - // int - GenCase (w, "int", "42", new string [] { "int", "uint" }, new string [] { "Int32.MinValue", "UInt32.MaxValue" }); - - // byref int - GenCase (w, "int", "42", new string [] { "ref int" }, new string [] { "Int32.MinValue" }); - - // short - GenCase (w, "short", "42", new string [] { "short", "ushort" }, new string [] { "Int16.MinValue", "UInt16.MaxValue" }); - - // bool - GenCase (w, "bool", "true", new string [] { "bool", "bool", "bool" }, new string [] { "true", "false", "true" }); - - // char - GenCase (w, "char", "'A'", new string [] { "char", "char", "char" }, new string [] { "'A'", "'B'", "'C'" }); - - // long - GenCase (w, "long", "0x12345678AL", new string [] { "long", "long" }, new string [] { "0x123456789L", "0x123456789L" }); - - // long in an odd numbered register - GenCase (w, "long", "0x12345678AL", new string [] { "int", "long", "long" }, new string [] { "1", "0x123456789L", "0x123456789L" }); - - // long in split reg/stack on arm - GenCase (w, "void", "", new string [] { "int", "int", "int", "long" }, new string [] { "1", "2", "3", "0x123456789L" }); - - // vtype in split reg/stack on arm - GenCase (w, "void", "", new string [] { "int", "int", "int", "FooStruct" }, new string [] { "1", "2", "3", "new FooStruct () { i = 1, j = 2 }" }); - - // 8 aligned vtype in split reg/stack on arm - GenCase (w, "void", "", new string [] { "int", "int", "int", "FooStruct2" }, new string [] { "1", "2", "3", "new FooStruct2 () { i = 0x123456789L }" }); - - // vtype entirely on the stack on arm - GenCase (w, "void", "", new string [] { "int", "int", "int", "int", "FooStruct" }, new string [] { "1", "2", "3", "4", "new FooStruct () { i = 1, j = 2 }" }); - - // float - GenCase (w, "void", "", new string [] { "float" }, new string [] { "0.123f" }); - - // float on the stack on arm - GenCase (w, "void", "", new string [] { "int", "int", "int", "int", "float" }, new string [] { "1", "2", "3", "4", "0.123f" }); - - // float ret - GenCase (w, "float", "0.123f", new string [] { }, new string [] { }); - - // double - GenCase (w, "void", "", new string [] { "double" }, new string [] { "0.123f" }); - - // double in split reg/stack on arm - GenCase (w, "void", "", new string [] { "int", "int", "int", "double" }, new string [] { "1", "2", "3", "0.123f" }); - - // double ret - GenCase (w, "double", "0.123f", new string [] { }, new string [] { }); - - w.WriteLine ("}"); - } - } - - static int testid_gen; - - static void WriteList (StreamWriter w, string[] values) { - int i = 0; - foreach (string v in values) { - if (i > 0) - w.Write (", "); - w.Write (v); - i ++; - } - } - - public static void GenCase (StreamWriter w, string retType, string retVal, string[] types, string[] values) { - testid_gen ++; - - string callee_name = "meth_" + testid_gen; - - /* The caller */ - w.WriteLine ("\tpublic static int test_0_" + testid_gen + " () {"); - w.Write ("\t\t"); - if (retType != "void") - w.Write (retType + " res = (" + retType + ")"); - w.Write ("typeof (Tests).GetMethod (\"" + callee_name + "\").Invoke (null, new object [] { "); - WriteList (w, values); - w.WriteLine ("});"); - if (retType != "void") - w.WriteLine ("\t\tif (res != " + retVal + ") return 1;"); - w.WriteLine ("\t\treturn 0;"); - w.WriteLine ("\t}"); - - /* The callee */ - w.Write ("\tpublic static " + retType + " meth_" + testid_gen + " ("); - - string[] arg_decl = new string [types.Length]; - for (int i = 0; i < types.Length; ++i) - arg_decl [i] = types [i] + " arg" + i; - - WriteList (w, arg_decl); - w.WriteLine (") {"); - - for (int i = 0; i < values.Length; ++i) - w.WriteLine ("\t\tif (arg" + i + " != " + values [i] + ") throw new Exception ();"); - - if (retType != "void") - w.WriteLine ("\t\treturn " + retVal + ";"); - - w.WriteLine ("\t}"); - } -}
\ No newline at end of file diff --git a/mono/tests/generic-type-load-exception.2.il b/mono/tests/generic-type-load-exception.2.il deleted file mode 100644 index 2bfd8e54d81..00000000000 --- a/mono/tests/generic-type-load-exception.2.il +++ /dev/null @@ -1,154 +0,0 @@ -.assembly extern mscorlib -{ - .ver 2:0:0:0 - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. -} -.assembly 'typeloadexcgeneric' -{ - .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = ( - 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx - 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. - - .hash algorithm 0x00008004 - .ver 0:0:0:0 -} -.module typeloadexcgeneric.exe // GUID = {877F6CE7-B3D8-4CC7-AEB0-DA6A9DB96059} - - - .class interface private auto ansi abstract IFoo - { - - // method line 1 - .method public virtual hidebysig newslot abstract - instance default int32 A () cil managed - { - // Method begins at RVA 0x0 - } // end of method IFoo::A - - // method line 2 - .method public virtual hidebysig newslot abstract - instance default int32 B () cil managed - { - // Method begins at RVA 0x0 - } // end of method IFoo::B - - } // end of class IFoo - - .class private auto ansi beforefieldinit Foo`1<T> - extends [mscorlib]System.Object - implements IFoo { - - // method line 3 - .method public hidebysig specialname rtspecialname - instance default void '.ctor' () cil managed - { - // Method begins at RVA 0x20ec - // Code size 7 (0x7) - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void object::'.ctor'() - IL_0006: ret - } // end of method Foo`1::.ctor - - // method line 4 - .method public final virtual hidebysig newslot - instance default int32 A () cil managed - { - // Method begins at RVA 0x20f4 - // Code size 2 (0x2) - .maxstack 8 - IL_0000: ldc.i4.1 - IL_0001: ret - } // end of method Foo`1::A - } // end of class Foo`1 - - .class private auto ansi beforefieldinit Bar`1<T> - extends [mscorlib]System.Object - { - - // method line 6 - .method public hidebysig specialname rtspecialname - instance default void '.ctor' () cil managed - { - // Method begins at RVA 0x20fc - // Code size 7 (0x7) - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void object::'.ctor'() - IL_0006: ret - } // end of method Bar`1::.ctor - - // method line 7 - .method public hidebysig - instance default void work () cil managed - { - // Method begins at RVA 0x2104 - // Code size 33 (0x21) - .maxstack 5 - .locals init ( - class Foo`1<!T> V_0) - IL_0000: newobj instance void class Foo`1<!T>::'.ctor'() - IL_0005: stloc.0 - IL_0006: ldstr "A " - IL_000b: ldloc.0 - IL_000c: callvirt instance int32 class Foo`1<!T>::A() - IL_0011: box [mscorlib]System.Int32 - IL_0016: call string string::Concat(object, object) - IL_001b: call void class [mscorlib]System.Console::WriteLine(string) - IL_0020: ret - } // end of method Bar`1::work - - } // end of class Bar`1 - - .class public auto ansi beforefieldinit main - extends [mscorlib]System.Object - { - - // method line 8 - .method public hidebysig specialname rtspecialname - instance default void '.ctor' () cil managed - { - // Method begins at RVA 0x2134 - // Code size 7 (0x7) - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void object::'.ctor'() - IL_0006: ret - } // end of method main::.ctor - - // method line 9 - .method public static hidebysig - default int32 Main () cil managed - { - // Method begins at RVA 0x213c - .entrypoint - // Code size 34 (0x22) - .maxstack 4 - .locals init ( - class Bar`1<string> V_0, - int32 V_1) - IL_0000: newobj instance void class Bar`1<string>::'.ctor'() - IL_0005: stloc.0 - .try { // 0 - IL_0006: ldloc.0 - IL_0007: callvirt instance void class Bar`1<string>::work() - IL_000c: leave IL_001e - - } // end .try 0 - catch class [mscorlib]System.TypeLoadException { // 0 - IL_0011: pop - IL_0012: ldc.i4.0 - IL_0013: stloc.1 - IL_0014: leave IL_0020 - - IL_0019: leave IL_001e - - } // end handler 0 - IL_001e: ldc.i4.1 - IL_001f: ret - IL_0020: ldloc.1 - IL_0021: ret - } // end of method main::Main - - } // end of class main - diff --git a/mono/tests/libtest.c b/mono/tests/libtest.c index cc14592afa3..ce8d9982566 100644 --- a/mono/tests/libtest.c +++ b/mono/tests/libtest.c @@ -82,7 +82,7 @@ static gunichar2* marshal_bstr_alloc(const gchar* str) } LIBTEST_API int STDCALL -mono_cominterop_is_supported (void) +mono_cominterop_is_supported () { #if defined(TARGET_X86) || defined(TARGET_AMD64) return 1; @@ -996,36 +996,6 @@ mono_test_marshal_stringbuilder_unicode (gunichar2 *s, int n) return 0; } -LIBTEST_API void STDCALL -mono_test_marshal_stringbuilder_out (char **s) -{ - const char m[] = "This is my message. Isn't it nice?"; - char *str; - - str = g_malloc (strlen (m) + 1); - memcpy (str, m, strlen (m) + 1); - - *s = str; -} - -LIBTEST_API int STDCALL -mono_test_marshal_stringbuilder_out_unicode (gunichar2 **s) -{ - const char m[] = "This is my message. Isn't it nice?"; - gunichar2 *s2; - glong len; - - s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL); - - len = (len * 2) + 2; - *s = g_malloc (len); - memcpy (*s, s2, len); - - g_free (s2); - - return 0; -} - typedef struct { #ifndef __GNUC__ char a; diff --git a/mono/tests/pinvoke2.cs b/mono/tests/pinvoke2.cs index 10acef74572..e24380a199c 100644 --- a/mono/tests/pinvoke2.cs +++ b/mono/tests/pinvoke2.cs @@ -280,12 +280,6 @@ public class Tests { [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_unicode", CharSet=CharSet.Unicode)] public static extern void mono_test_marshal_stringbuilder_unicode (StringBuilder sb, int len); - [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_out")] - public static extern void mono_test_marshal_stringbuilder_out (out StringBuilder sb); - - [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_out_unicode", CharSet=CharSet.Unicode)] - public static extern void mono_test_marshal_stringbuilder_out_unicode (out StringBuilder sb); - [DllImport ("libtest", EntryPoint="mono_test_last_error", SetLastError=true)] public static extern void mono_test_last_error (int err); @@ -793,24 +787,6 @@ public class Tests { return 0; } - public static int test_0_marshal_stringbuilder_out () { - StringBuilder sb; - mono_test_marshal_stringbuilder_out (out sb); - - if (sb.ToString () != "This is my message. Isn't it nice?") - return 1; - return 0; - } - - public static int test_0_marshal_stringbuilder_out_unicode () { - StringBuilder sb; - mono_test_marshal_stringbuilder_out_unicode (out sb); - - if (sb.ToString () != "This is my message. Isn't it nice?") - return 1; - return 0; - } - public static int test_0_marshal_empty_string_array () { return mono_test_marshal_empty_string_array (null); } diff --git a/mono/tests/runtime-invoke.cs b/mono/tests/runtime-invoke.cs index d0244a26c1c..eafe3104708 100644 --- a/mono/tests/runtime-invoke.cs +++ b/mono/tests/runtime-invoke.cs @@ -93,37 +93,15 @@ class Tests return 0; } - public struct Foo - { - public string ToString2 () { - return "FOO"; - } - } - - public static object GetNSObject (IntPtr i) { - return i; - } - - public static int test_0_vtype_method_sharing () { - /* Check sharing of wrappers of vtype methods with static methods having an IntPtr argument */ - if ((string)(typeof (Foo).GetMethod ("ToString2").Invoke (new Foo (), null)) != "FOO") - return 3; - object o = typeof (Tests).GetMethod ("GetNSObject").Invoke (null, new object [] { new IntPtr (42) }); - if (!(o is IntPtr) || ((IntPtr)o != new IntPtr (42))) - return 4; - - return 0; - } - public static unsafe int test_0_ptr () { int[] arr = new int [10]; fixed (void *p = &arr [5]) { - object o = typeof (Tests).GetMethod ("data_types_ptr").Invoke (null, new object [1] { new IntPtr (p) }); + object o = typeof (Tests).GetMethod ("Test").Invoke (null, new object [1] { new IntPtr (p) }); void *p2 = Pointer.Unbox (o); if (new IntPtr (p) != new IntPtr (p2)) return 1; - o = typeof (Tests).GetMethod ("data_types_ptr").Invoke (null, new object [1] { null }); + o = typeof (Tests).GetMethod ("Test").Invoke (null, new object [1] { null }); p2 = Pointer.Unbox (o); if (new IntPtr (p2) != IntPtr.Zero) return 1; @@ -132,50 +110,8 @@ class Tests return 0; } - public static int test_0_string_ctor () { - string res = (string)typeof (String).GetConstructor (new Type [] { typeof (char[]) }).Invoke (null, new object [] { new char [] { 'A', 'B', 'C' } }); - if (res == "ABC") - return 0; - else - return 1; - } - - public class Foo<T> { - public T t; - } - - public static int test_0_ginst_ref () { - Foo<string> f = new Foo<string> { t = "A" }; - Foo<string> f2 = (Foo<string>)typeof (Tests).GetMethod ("data_types_ginst_ref").MakeGenericMethod (new Type [] { typeof (string) }).Invoke (null, new object [] { f }); - if (f2.t != "A") - return 1; - else - return 0; - } - - public static int test_0_ginst_vtype () { - FooStruct<string> f = new FooStruct<string> { t = "A" }; - FooStruct<string> f2 = (FooStruct<string>)typeof (Tests).GetMethod ("data_types_ginst_vtype").MakeGenericMethod (new Type [] { typeof (string) }).Invoke (null, new object [] { f }); - if (f2.t != "A") - return 1; - else - return 0; - } - - public static Foo<T> data_types_ginst_ref<T> (Foo<T> f) { - return f; - } - - public struct FooStruct<T> { - public T t; - } - - public static FooStruct<T> data_types_ginst_vtype<T> (FooStruct<T> f) { - return f; - } - - public static unsafe int* data_types_ptr (int *val) { - //Console.WriteLine (new IntPtr (val)); + public static unsafe int* Test (int *val) { + Console.WriteLine (new IntPtr (val)); return val; } } diff --git a/mono/utils/ChangeLog b/mono/utils/ChangeLog index 740326f07ad..63615611eeb 100644 --- a/mono/utils/ChangeLog +++ b/mono/utils/ChangeLog @@ -1,8 +1,3 @@ -2009-09-29 Zoltan Varga <vargaz@gmail.com> - - * mono-compiler.h (MONO_INTERNAL): Disable this on solaris as it produces a - millions of warnings during compilation. - 2009-09-02 Rodrigo Kumpera <rkumpera@novell.com> * mono-sha1.c: Update documentation. diff --git a/mono/utils/Makefile.am b/mono/utils/Makefile.am index 519b95f7161..4af317d78e6 100644 --- a/mono/utils/Makefile.am +++ b/mono/utils/Makefile.am @@ -40,7 +40,6 @@ libmonoutils_la_SOURCES = \ mono-mmap.h \ mono-proclib.c \ mono-proclib.h \ - mono-string.h \ mono-time.c \ mono-time.h \ strtod.h \ diff --git a/mono/utils/mono-compiler.h b/mono/utils/mono-compiler.h index 3cbed14bba2..b5449621904 100644 --- a/mono/utils/mono-compiler.h +++ b/mono/utils/mono-compiler.h @@ -153,7 +153,7 @@ #endif /* _MSC_VER */ -#if !defined(PLATFORM_WIN32) && !defined(PLATFORM_SOLARIS) && HAVE_VISIBILITY_HIDDEN +#if !defined(PLATFORM_WIN32) && HAVE_VISIBILITY_HIDDEN #define MONO_INTERNAL __attribute__ ((visibility ("hidden"))) #else #define MONO_INTERNAL diff --git a/mono/utils/mono-logger.c b/mono/utils/mono-logger.c index fd4f613e98f..11162fc19fd 100644 --- a/mono/utils/mono-logger.c +++ b/mono/utils/mono-logger.c @@ -141,7 +141,7 @@ void mono_trace_push (GLogLevelFlags level, MonoTraceMask mask) { if(level_stack == NULL) - g_error("%s: cannot use mono_trace_push without calling mono_trace_init first.", __func__); + g_error(G_GNUC_PRETTY_FUNCTION ": cannot use mono_trace_push without calling mono_trace_init first."); else { MonoLogLevelEntry *entry = g_malloc(sizeof(MonoLogLevelEntry)); entry->level = current_level; @@ -165,7 +165,7 @@ void mono_trace_pop (void) { if(level_stack == NULL) - g_error("%s: cannot use mono_trace_pop without calling mono_trace_init first.", __func__); + g_error(G_GNUC_PRETTY_FUNCTION ": cannot use mono_trace_pop without calling mono_trace_init first."); else { if(!g_queue_is_empty (level_stack)) { MonoLogLevelEntry *entry = (MonoLogLevelEntry*)g_queue_pop_head (level_stack); diff --git a/mono/utils/mono-string.h b/mono/utils/mono-string.h deleted file mode 100644 index 6e2daade7a5..00000000000 --- a/mono/utils/mono-string.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef __UTILS_MONO_STRING_H__ -#define __UTILS_MONO_STRING_H__ -#include <glib.h> -/* - * This definition is used to we remember later to implement this properly - * - * Currently we merely call into the ascii comparison, but we should be - * instead doing case folding and comparing the result. - */ -#define mono_utf8_strcasecmp g_ascii_strcasecmp - -#endif /* __UTILS_MONO_STRING_H__ */ diff --git a/mono/utils/strenc.c b/mono/utils/strenc.c index ca5423cfbab..23169b37520 100644 --- a/mono/utils/strenc.c +++ b/mono/utils/strenc.c @@ -13,6 +13,8 @@ #include "strenc.h" +#undef DEBUG + static const char trailingBytesForUTF8[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -60,6 +62,10 @@ mono_unicode_from_external (const gchar *in, gsize *bytes) encodings=g_strsplit (encoding_list, ":", 0); for(i=0;encodings[i]!=NULL; i++) { +#ifdef DEBUG + g_message (G_GNUC_PRETTY_FUNCTION ": Trying encoding [%s]", + encodings[i]); +#endif /* "default_locale" is a special case encoding */ if(!strcmp (encodings[i], "default_locale")) { gchar *utf8=g_locale_to_utf8 (in, -1, NULL, NULL, NULL); @@ -133,6 +139,10 @@ gchar *mono_utf8_from_external (const gchar *in) encodings=g_strsplit (encoding_list, ":", 0); for(i=0;encodings[i]!=NULL; i++) { +#ifdef DEBUG + g_message (G_GNUC_PRETTY_FUNCTION ": Trying encoding [%s]", + encodings[i]); +#endif /* "default_locale" is a special case encoding */ if(!strcmp (encodings[i], "default_locale")) { diff --git a/support/ChangeLog b/support/ChangeLog index 4c8755d4fc7..86e1c9536a1 100644 --- a/support/ChangeLog +++ b/support/ChangeLog @@ -1,11 +1,3 @@ -2009-09-21 Leszek Ciesielski <skolima@gmail.com> - - * serial.c: return -1 from close() on error - -2009-09-14 Jonathan Pryor <jpryor@novell.com> - - * zlib-helper.c: support reverse callbacks within MonoTouch. - 2009-09-09 Gonzalo Paniagua Javier <gonzalo@novell.com> * zconf.h: diff --git a/support/serial.c b/support/serial.c index 0c393a75694..c0708a11929 100644 --- a/support/serial.c +++ b/support/serial.c @@ -72,11 +72,10 @@ open_serial (char* devfile) return fd; } -int +void close_serial (int unix_fd) { - // Linus writes: do not retry close after EINTR - return close (unix_fd); + close (unix_fd); } guint32 diff --git a/support/zlib-helper.c b/support/zlib-helper.c index 98fd6879e6b..9a692792b10 100644 --- a/support/zlib-helper.c +++ b/support/zlib-helper.c @@ -26,18 +26,17 @@ #define ARGUMENT_ERROR -10 #define IO_ERROR -11 -typedef gint (*read_write_func) (guchar *buffer, gint length, void *gchandle); +typedef gint (*read_write_func) (guchar *buffer, gint length); struct _ZStream { z_stream *stream; guchar *buffer; read_write_func func; - void *gchandle; guchar compress; guchar eof; }; typedef struct _ZStream ZStream; -ZStream *CreateZStream (gint compress, guchar gzip, read_write_func func, void *gchandle); +ZStream *CreateZStream (gint compress, guchar gzip, read_write_func func); gint CloseZStream (ZStream *zstream); gint Flush (ZStream *stream); gint ReadZStream (ZStream *stream, guchar *buffer, gint length); @@ -56,7 +55,7 @@ z_free (void *opaque, void *ptr) } ZStream * -CreateZStream (gint compress, guchar gzip, read_write_func func, void *gchandle) +CreateZStream (gint compress, guchar gzip, read_write_func func) { z_stream *z; gint retval; @@ -86,7 +85,6 @@ CreateZStream (gint compress, guchar gzip, read_write_func func, void *gchandle) result = g_new0 (ZStream, 1); result->stream = z; result->func = func; - result->gchandle = gchandle; result->compress = compress; result->buffer = g_new (guchar, BUFFER_SIZE); return result; @@ -128,7 +126,7 @@ write_to_managed (ZStream *stream) zs = stream->stream; if (zs->avail_out != BUFFER_SIZE) { - n = stream->func (stream->buffer, BUFFER_SIZE - zs->avail_out, stream->gchandle); + n = stream->func (stream->buffer, BUFFER_SIZE - zs->avail_out); zs->next_out = stream->buffer; zs->avail_out = BUFFER_SIZE; if (n < 0) @@ -164,7 +162,7 @@ ReadZStream (ZStream *stream, guchar *buffer, gint length) zs->avail_out = length; while (zs->avail_out > 0) { if (zs->avail_in == 0) { - n = stream->func (stream->buffer, BUFFER_SIZE, stream->gchandle); + n = stream->func (stream->buffer, BUFFER_SIZE); if (n <= 0) { stream->eof = TRUE; break; |