2004-04-13 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Tue, 13 Apr 2004 20:15:05 +0000 (20:15 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Tue, 13 Apr 2004 20:15:05 +0000 (20:15 -0000)
* appdomain.c: Pass arguments to the bootstraping exceptions to
minimize JITed methods at boot

* metadata.c (mono_exception_from_name_two_strings): Allow for the
second string to be null.

* icall.c (ves_icall_System_Text_Encoding_InternalCodePage):
Change the protocol to minimize the JIT methods at startup.  Now
it Returns the internal codepage, if the value of "int_code_page"
is 1 at entry, and we can not compute a suitable code page
number, returns the code page as a string.

2004-04-13  Miguel de Icaza  <miguel@ximian.com>

* inssel-x86.brg (reg): Add new rules for add, sub and mul that
can use the memory directly.

* cpu-pentium.md: Update documentation from a post from Zoltan.

add x86_add_membase, x86_sub_membase, x86_mul_membase

svn path=/trunk/mono/; revision=25433

14 files changed:
mono/metadata/ChangeLog
mono/metadata/appdomain.c
mono/metadata/exception.c
mono/metadata/exception.h
mono/metadata/icall.c
mono/metadata/loader.c
mono/mini/ChangeLog
mono/mini/cpu-pentium.md
mono/mini/driver.c
mono/mini/helpers.c
mono/mini/inssel-x86.brg
mono/mini/inssel.brg
mono/mini/mini-ops.h
mono/mini/mini-x86.c

index 5d5b9ba4fd45e6df62ca70a079b46d4f55f92bd7..dd25b3ac66281b6769ace1ab947c9e1556ae2c83 100644 (file)
@@ -1,3 +1,17 @@
+2004-04-13  Miguel de Icaza  <miguel@ximian.com>
+
+       * appdomain.c: Pass arguments to the bootstraping exceptions to
+       minimize JITed methods at boot
+
+       * metadata.c (mono_exception_from_name_two_strings): Allow for the
+       second string to be null.
+
+       * icall.c (ves_icall_System_Text_Encoding_InternalCodePage):
+       Change the protocol to minimize the JIT methods at startup.  Now
+       it Returns the internal codepage, if the value of "int_code_page"
+       is 1 at entry, and we can not compute a suitable code page
+       number, returns the code page as a string.
+
 2004-04-13  Jackson Harper  <jackson@ximian.com>
 
        * culture-info-tables.h: Fix number of decimal digits for all
index 131622a0468241593554751b1e2b2e7dca0ecef4..05a8180c5ca912c3cdabdd30313217fed64bb6ce 100644 (file)
@@ -26,7 +26,7 @@
 #include <mono/metadata/marshal.h>
 #include <mono/utils/mono-uri.h>
 
-#define MONO_CORLIB_VERSION 15
+#define MONO_CORLIB_VERSION 16
 
 CRITICAL_SECTION mono_delegate_section;
 
@@ -68,7 +68,8 @@ mono_runtime_init (MonoDomain *domain, MonoThreadStartCB start_cb,
        MonoAppDomainSetup *setup;
        MonoAppDomain *ad;
        MonoClass *class;
-
+       MonoString *arg;
+       
        mono_marshal_init ();
        
        mono_install_assembly_preload_hook (mono_domain_assembly_preload, NULL);
@@ -93,16 +94,21 @@ mono_runtime_init (MonoDomain *domain, MonoThreadStartCB start_cb,
 
        mono_type_initialization_init ();
 
+       
        /*
         * Create an instance early since we can't do it when there is no memory.
         */
-       domain->out_of_memory_ex = mono_exception_from_name (mono_defaults.corlib, "System", "OutOfMemoryException");
+       arg = mono_string_new (domain, "Out of memory");
+       domain->out_of_memory_ex = mono_exception_from_name_two_strings (mono_defaults.corlib, "System", "OutOfMemoryException", arg, NULL);
+       
        /* 
         * These two are needed because the signal handlers might be executing on
         * an alternate stack, and Boehm GC can't handle that.
         */
-       domain->null_reference_ex = mono_exception_from_name (mono_defaults.corlib, "System", "NullReferenceException");
-       domain->stack_overflow_ex = mono_exception_from_name (mono_defaults.corlib, "System", "StackOverflowException");
+       arg = mono_string_new (domain, "A null value was found where an object instance was required");
+       domain->null_reference_ex = mono_exception_from_name_two_strings (mono_defaults.corlib, "System", "NullReferenceException", arg, NULL);
+       arg = mono_string_new (domain, "The requested operation caused a stack overflow.");
+       domain->stack_overflow_ex = mono_exception_from_name_two_strings (mono_defaults.corlib, "System", "StackOverflowException", arg, NULL);
        
        /* GC init has to happen after thread init */
        mono_gc_init ();
index bc9be450cb28c4730222a59702ccfecd12cc107c..ce7d81cbf769509f196286c8bbdf897dd8dfa46a 100644 (file)
@@ -33,10 +33,8 @@ mono_exception_from_name (MonoImage *image, const char *name_space,
 }
 
 MonoException *
-mono_exception_from_name_domain (MonoDomain *domain,
-                                                                MonoImage *image, 
-                                                                const char* name_space, 
-                                                                const char *name)
+mono_exception_from_name_domain (MonoDomain *domain, MonoImage *image, 
+                                const char* name_space, const char *name)
 {
        MonoClass *klass;
        MonoObject *o;
@@ -64,16 +62,19 @@ mono_exception_from_name_domain (MonoDomain *domain,
  *
  * Returns: the initialized exception instance.
  */
-static MonoException *
+MonoException *
 mono_exception_from_name_two_strings (MonoImage *image, const char *name_space,
-                                                                         const char *name, MonoString *a1, MonoString *a2)
+                                     const char *name, MonoString *a1, MonoString *a2)
 {
        MonoDomain *domain = mono_domain_get ();
        MonoClass *klass;
        MonoMethod *method = NULL;
        MonoObject *o;
-       int i;
+       int i, count = 1;
        gpointer args [2];
+
+       if (a2 != NULL)
+               count++;
        
        klass = mono_class_from_name (image, name_space, name);
        o = mono_object_new (domain, klass);
@@ -84,11 +85,12 @@ mono_exception_from_name_two_strings (MonoImage *image, const char *name_space,
                if (strcmp (".ctor", klass->methods [i]->name))
                        continue;
                sig = klass->methods [i]->signature;
-               if (sig->param_count != 2)
+               if (sig->param_count != count)
                        continue;
 
-               if (sig->params [0]->type != MONO_TYPE_STRING ||
-                   sig->params [1]->type != MONO_TYPE_STRING)
+               if (sig->params [0]->type != MONO_TYPE_STRING)
+                       continue;
+               if (count == 2 && sig->params [1]->type != MONO_TYPE_STRING)
                        continue;
                method = klass->methods [i];
        }
@@ -112,12 +114,12 @@ mono_exception_from_name_two_strings (MonoImage *image, const char *name_space,
  */
 MonoException *
 mono_exception_from_name_msg (MonoImage *image, const char *name_space,
-                                 const char *name, const guchar *msg)
+                             const char *name, const guchar *msg)
 {
        MonoException *ex;
        MonoDomain *domain;
 
-    ex = mono_exception_from_name (image, name_space, name);
+       ex = mono_exception_from_name (image, name_space, name);
 
        domain = ((MonoObject *)ex)->vtable->domain;
 
@@ -297,9 +299,8 @@ mono_get_exception_argument_out_of_range (const guchar *arg)
 MonoException *
 mono_get_exception_thread_state (const guchar *msg)
 {
-       return mono_exception_from_name_msg (mono_defaults.corlib, 
-                                                                                "System.Threading", "ThreadStateException",
-                                                                                msg);
+       return mono_exception_from_name_msg (
+               mono_defaults.corlib, "System.Threading", "ThreadStateException", msg);
 }
 
 MonoException *
index a03e9342805c4cd160b3c71c46bb6a84d226fff0..f9aef3a0ef9424abf39af6622e19c62c8b35fb37 100644 (file)
@@ -22,6 +22,10 @@ mono_exception_from_name               (MonoImage *image,
                                        const char* name_space, 
                                        const char *name);
 
+MonoException *
+mono_exception_from_name_two_strings (MonoImage *image, const char *name_space,
+                                     const char *name, MonoString *a1, MonoString *a2);
+
 MonoException *
 mono_exception_from_name_msg          (MonoImage *image, const char *name_space,
                                        const char *name, const guchar *msg);
index 378c4d6c5e8cd8dcf08806b56b7ab7847ceaa39f..50d868bf264af343adca08760a966b97ee1ccb4b 100644 (file)
@@ -13,6 +13,7 @@
 #include <glib.h>
 #include <stdarg.h>
 #include <string.h>
+#include <ctype.h>
 #include <sys/time.h>
 #include <unistd.h>
 #if defined (PLATFORM_WIN32)
@@ -4329,23 +4330,82 @@ ves_icall_System_Environment_GetGacPath (void)
        return mono_string_new (mono_domain_get (), MONO_ASSEMBLIES);
 }
 
+static const char *encodings [] = {
+       (char *) 1,
+               "ascii", "us_ascii", "us", "ansi_x3.4_1968",
+               "ansi_x3.4_1986", "cp367", "csascii", "ibm367",
+               "iso_ir_6", "iso646_us", "iso_646.irv:1991",
+       (char *) 2,
+               "utf_7", "csunicode11utf7", "unicode_1_1_utf_7",
+               "unicode_2_0_utf_7", "x_unicode_1_1_utf_7",
+               "x_unicode_2_0_utf_7",
+       (char *) 3,
+               "utf_8", "unicode_1_1_utf_8", "unicode_2_0_utf_8",
+               "x_unicode_1_1_utf_8", "x_unicode_2_0_utf_8",
+       (char *) 4,
+               "utf_16", "UTF_16LE", "ucs_2", "unicode",
+               "iso_10646_ucs2",
+       (char *) 5,
+               "unicodefffe", "utf_16be",
+       (char *) 6,
+               "iso_8859_1",
+       (char *) 0
+};
+
+/*
+ * Returns the internal codepage, if the value of "int_code_page" is
+ * 1 at entry, and we can not compute a suitable code page number,
+ * returns the code page as a string
+ */
 static MonoString*
-ves_icall_System_Text_Encoding_InternalCodePage (void
+ves_icall_System_Text_Encoding_InternalCodePage (gint32 *int_code_page
 {
        const char *cset;
-
+       char *p;
+       char *codepage = NULL;
+       int code;
+       int want_name = *int_code_page;
+       int i;
+       
+       *int_code_page = -1;
        MONO_ARCH_SAVE_REGS;
 
        g_get_charset (&cset);
+       p = codepage = strdup (cset);
+       for (p = codepage; *p; p++){
+               if (isascii (*p) && isalpha (*p))
+                       *p = tolower (*p);
+               if (*p == '-')
+                       *p = '_';
+       }
        /* g_print ("charset: %s\n", cset); */
+       
        /* handle some common aliases */
-       switch (*cset) {
-       case 'A':
-               if (strcmp (cset, "ANSI_X3.4-1968") == 0)
-                       cset = "us-ascii";
-               break;
+       p = encodings [0];
+       code = 0;
+       for (i = 0; p != 0; ){
+               if ((int) p < 7){
+                       code = (int) p;
+                       p = encodings [++i];
+                       continue;
+               }
+               if (strcmp (p, codepage) == 0){
+                       *int_code_page = code;
+                       break;
+               }
+               p = encodings [++i];
        }
-       return mono_string_new (mono_domain_get (), cset);
+       
+       if (p - codepage > 5){
+               if (strstr (codepage, "utf_8") != -1)
+                       *int_code_page |= 0x10000000;
+       }
+       free (codepage);
+       
+       if (want_name && *int_code_page == -1)
+               return mono_string_new (mono_domain_get (), cset);
+       else
+               return NULL;
 }
 
 static MonoBoolean
index 731f466e18d2f154bd4bfbc8a868fe408f4be6d1..9b6c3575b2d1c56a0dfd1b62840bc45d43cf28dd 100644 (file)
@@ -1093,5 +1093,10 @@ mono_loader_wine_init ()
        }
 
        g_module_symbol (module, "SharedWineInit", &shared_wine_init);
+       if (shared_wine_init == NULL)
+               return;
+
        shared_wine_init ();
+
+       return;
 }
index be4a6a99ef935bcc397d98cd0bcc6011f59a6223..639427b1e576ffdb546dd405b771ce993b675948 100644 (file)
@@ -1,3 +1,12 @@
+2004-04-13  Miguel de Icaza  <miguel@ximian.com>
+
+       * inssel-x86.brg (reg): Add new rules for add, sub and mul that
+       can use the memory directly.
+
+       * cpu-pentium.md: Update documentation from a post from Zoltan. 
+
+       add x86_add_membase, x86_sub_membase, x86_mul_membase
+
 2004-04-13  Miguel de Icaza  <miguel@ximian.com>
 
        * mini-ppc.c: Remove unused definitions FLOAT_REGS and
index 19a2bb749b2787fe77cbc03bc257f5e5ed6cb05a..c6197c0d695ed7ddf0df6da2b1f83675efd62b33 100644 (file)
 #       d  EDX register
 #
 # len:number         describe the maximun length in bytes of the instruction
-# number is a positive integer
+#                   number is a positive integer.  If the length is not specified
+#                    it defaults to zero.   But lengths are only checked if the given opcode 
+#                    is encountered during compilation. Some opcodes, like CONV_U4 are 
+#                    transformed into other opcodes in the brg files, so they do not show up 
+#                    during code generation.
 #
 # cost:number        describe how many cycles are needed to complete the instruction (unused)
 #
@@ -537,6 +541,9 @@ x86_fpop: src1:f len:2
 x86_fp_load_i8: dest:f src1:b len:7
 x86_fp_load_i4: dest:f src1:b len:7
 x86_seteq_membase: src1:b len:7
+x86_add_membase: dest:i src1:i src2:b clob:1 len:11
+x86_sub_membase: dest:i src1:i src2:b clob:1 len:11
+x86_mul_membase: dest:i src1:i src2:b clob:1 len:13
 adc: dest:i src1:i src2:i len:2 clob:1
 addcc: dest:i src1:i src2:i len:2 clob:1
 subcc: dest:i src1:i src2:i len:2 clob:1
index 230848c51301c1f9e5a3ef2ac706c9b857db9647..03ffb77b6e95f67ccba29e33d7eda89e999d61ad 100644 (file)
@@ -88,6 +88,7 @@ opt_names [] = {
        MONO_OPT_INTRINS |  \
     MONO_OPT_AOT)
 
+
 static guint32
 parse_optimizations (const char* p)
 {
index dea81fc1907ba256d6323bfe189596ae8b01d25e..1cbc5792eafb1007f7f95a7d00fc63047122a7a5 100644 (file)
@@ -96,7 +96,11 @@ mono_disassemble_code (guint8 *code, int size, char *id)
        system (cmd); 
        g_free (cmd);
        cmd = g_strdup_printf (DIS_CMD " %s", o_file);
-       system (cmd); 
+       system (cmd);
+       g_free (cmd);
+
+       cmd = g_strdup_printf ("objdump -d -M intel %s", o_file);
+       system (cmd);
        g_free (cmd);
        g_free (o_file);
        g_free (as_file);
index b0e5bd3b37cc44ab8b2f9214fd2982520bb35b9e..da1620ad7d6dc9262cc2f2115f8dc0e667490292 100644 (file)
@@ -616,4 +616,36 @@ freg: OP_FCONV_TO_R4 (freg) "0" {
        /* fixme: nothing to do ??*/
 }
 
+reg: CEE_ADD(reg, CEE_LDIND_I4 (base)) {
+       MonoInst *base = state->right->left->tree;
+
+       tree->dreg = state->reg1;
+       tree->sreg1 = state->left->reg1;
+       tree->sreg2 = base->inst_basereg; 
+       tree->inst_offset = base->inst_offset; 
+       tree->opcode = OP_X86_ADD_MEMBASE; 
+       mono_bblock_add_inst (s->cbb, tree);
+} 
+
+reg: CEE_SUB(reg, CEE_LDIND_I4 (base)) {
+       MonoInst *base = state->right->left->tree;
+
+       tree->dreg = state->reg1;
+       tree->sreg1 = state->left->reg1;
+       tree->sreg2 = base->inst_basereg; 
+       tree->inst_offset = base->inst_offset; 
+       tree->opcode = OP_X86_SUB_MEMBASE; 
+       mono_bblock_add_inst (s->cbb, tree);
+} 
+
+reg: CEE_MUL(reg, CEE_LDIND_I4 (base)) {
+       MonoInst *base = state->right->left->tree;
+
+       tree->dreg = state->reg1;
+       tree->sreg1 = state->left->reg1;
+       tree->sreg2 = base->inst_basereg; 
+       tree->inst_offset = base->inst_offset; 
+       tree->opcode = OP_X86_MUL_MEMBASE; 
+       mono_bblock_add_inst (s->cbb, tree);
+} 
 %%
index 7351fc7550e9b80bd85363d9730e1694fb8ae837..b681922f8c4716202832627cb81b3ada024d1085 100644 (file)
@@ -8,7 +8,6 @@
  * (C) 2002 Ximian, Inc.
  *
  */
-
 #include <config.h>
 #include <string.h>
 
index 329a96181564576ff2efa9d8d4afde9425745ea7..90a57f938f9847da2f0a13dc84dc7a3baf01d4f8 100644 (file)
@@ -4,14 +4,14 @@ MINI_OP(OP_LDADDR,    "ldaddr")
 MINI_OP(OP_STORE,      "store")
 MINI_OP(OP_OBJADDR,    "objaddr")
 MINI_OP(OP_VTADDR,     "vtaddr")
-MINI_OP(OP_PHI,        "phi")
+MINI_OP(OP_PHI,                "phi")
 MINI_OP(OP_RENAME,     "rename")
 MINI_OP(OP_COMPARE,    "compare")
 MINI_OP(OP_COMPARE_IMM,        "compare_imm")
 MINI_OP(OP_FCOMPARE,   "fcompare")
 MINI_OP(OP_LCOMPARE,   "lcompare")
 MINI_OP(OP_LOCAL,      "local")
-MINI_OP(OP_ARG,        "arg")
+MINI_OP(OP_ARG,                "arg")
 MINI_OP(OP_ARGLIST,    "oparglist")
 MINI_OP(OP_OUTARG,     "outarg")
 MINI_OP(OP_OUTARG_IMM, "outarg_imm")
@@ -344,7 +344,10 @@ MINI_OP(OP_X86_FPOP,               "x86_fpop")
 MINI_OP(OP_X86_FP_LOAD_I8,         "x86_fp_load_i8")
 MINI_OP(OP_X86_FP_LOAD_I4,         "x86_fp_load_i4")
 MINI_OP(OP_X86_SETEQ_MEMBASE,      "x86_seteq_membase")
-
+MINI_OP(OP_X86_ADD_MEMBASE,        "x86_add_membase")
+MINI_OP(OP_X86_SUB_MEMBASE,        "x86_sub_membase")
+MINI_OP(OP_X86_MUL_MEMBASE,        "x86_mul_membase")
+       
 MINI_OP(OP_PPC_SUBFIC,             "ppc_subfic")
 MINI_OP(OP_PPC_SUBFZE,             "ppc_subfze")
 
index 4274473341f804df0b88497b0b3c41e7cb507b69..688f3ed48d03595c94b230f5cd29a92dca70b388 100644 (file)
@@ -1308,6 +1308,7 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
        /* forward pass on the instructions to collect register liveness info */
        while (ins) {
                spec = ins_spec [ins->opcode];
+               
                DEBUG (print_ins (i, ins));
 
                if (spec [MONO_INST_SRC1]) {
@@ -2086,9 +2087,15 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                case OP_X86_ADD_MEMBASE_IMM:
                        x86_alu_membase_imm (code, X86_ADD, ins->inst_basereg, ins->inst_offset, ins->inst_imm);
                        break;
+               case OP_X86_ADD_MEMBASE:
+                       x86_alu_reg_membase (code, X86_ADD, ins->sreg1, ins->sreg2, ins->inst_offset);
+                       break;
                case OP_X86_SUB_MEMBASE_IMM:
                        x86_alu_membase_imm (code, X86_SUB, ins->inst_basereg, ins->inst_offset, ins->inst_imm);
                        break;
+               case OP_X86_SUB_MEMBASE:
+                       x86_alu_reg_membase (code, X86_SUB, ins->sreg1, ins->sreg2, ins->inst_offset);
+                       break;
                case OP_X86_INC_MEMBASE:
                        x86_inc_membase (code, ins->inst_basereg, ins->inst_offset);
                        break;
@@ -2101,6 +2108,9 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                case OP_X86_DEC_REG:
                        x86_dec_reg (code, ins->dreg);
                        break;
+               case OP_X86_MUL_MEMBASE:
+                       x86_imul_reg_membase (code, ins->sreg1, ins->sreg2, ins->inst_offset);
+                       break;
                case CEE_BREAK:
                        x86_breakpoint (code);
                        break;
@@ -3307,15 +3317,13 @@ mono_arch_emit_epilog (MonoCompile *cfg)
        x86_leave (code);
 
        if (CALLCONV_IS_STDCALL (sig->call_convention)) {
-         MonoJitArgumentInfo *arg_info = alloca (sizeof (MonoJitArgumentInfo) * (sig->param_count + 1));
+               MonoJitArgumentInfo *arg_info = alloca (sizeof (MonoJitArgumentInfo) * (sig->param_count + 1));
 
-         stack_to_pop = mono_arch_get_argument_info (sig, sig->param_count, arg_info);
-       }
-       else
-       if (MONO_TYPE_ISSTRUCT (cfg->method->signature->ret))
-         stack_to_pop = 4;
+               stack_to_pop = mono_arch_get_argument_info (sig, sig->param_count, arg_info);
+       } else if (MONO_TYPE_ISSTRUCT (cfg->method->signature->ret))
+               stack_to_pop = 4;
        else
-         stack_to_pop = 0;
+               stack_to_pop = 0;
 
        if (stack_to_pop)
                x86_ret_imm (code, stack_to_pop);