Better BUILTINTABLE
authorstefan <none@none>
Sat, 15 Nov 2003 12:14:05 +0000 (12:14 +0000)
committerstefan <none@none>
Sat, 15 Nov 2003 12:14:05 +0000 (12:14 +0000)
jit/jit.c
jit/stack.c
src/vm/jit/jit.c
src/vm/jit/stack.c

index a61efd25d39fa085e18ab60e1208da20d216f7a3..69b3a885fea884731f3d8cd31d79acab1ca56341 100644 (file)
--- a/jit/jit.c
+++ b/jit/jit.c
@@ -27,7 +27,7 @@
    Authors: Andreas Krall
             Reinhard Grafl
 
-   $Id: jit.c 638 2003-11-14 23:51:34Z stefan $
+   $Id: jit.c 640 2003-11-15 12:14:05Z stefan $
 
 */
 
@@ -1283,10 +1283,6 @@ stdopdescriptor builtintable[] = {
          (functionptr) builtin_lneg, SUPPORT_LONG && SUPPORT_LONG_ADD, true },
        { ICMD_LMUL,   TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2,
          (functionptr) builtin_lmul , SUPPORT_LONG && SUPPORT_LONG_MUL, false },
-       { ICMD_FREM,   TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT, ICMD_BUILTIN2,
-         (functionptr) builtin_frem, SUPPORT_FLOAT && SUPPORT_FMOD, true },
-       { ICMD_DREM,   TYPE_DOUBLE, TYPE_DOUBLE, TYPE_DOUBLE, ICMD_BUILTIN2,
-         (functionptr) builtin_drem, SUPPORT_DOUBLE && SUPPORT_FMOD, true },
        { ICMD_I2F,    TYPE_INT, TYPE_VOID, TYPE_FLOAT, ICMD_BUILTIN1,
          (functionptr) builtin_i2f, SUPPORT_FLOAT && SUPPORT_IFCVT, true },
        { ICMD_I2D,    TYPE_INT, TYPE_VOID, TYPE_DOUBLE, ICMD_BUILTIN1, 
@@ -1306,6 +1302,8 @@ stdopdescriptor builtintable[] = {
        { 255, 0, 0, 0, 0, NULL, true, false },
 };
 
+static int builtintablelen;
+
 #endif /* USEBUILTINTABLE */
 
 
@@ -1492,6 +1490,10 @@ static int stdopcompare(const void *a, const void *b)
 {
        stdopdescriptor *o1 = (stdopdescriptor *) a;
        stdopdescriptor *o2 = (stdopdescriptor *) b;
+       if (!o1->supported && o2->supported)
+               return -1;
+       if (o1->supported && !o2->supported)
+               return 1;
        return (o1->opcode < o2->opcode) ? -1 : (o1->opcode > o2->opcode);
 }
 
@@ -1503,6 +1505,9 @@ static inline void sort_builtintable()
        len = sizeof(builtintable) / sizeof(stdopdescriptor);
        qsort(builtintable, len, sizeof(stdopdescriptor), stdopcompare);
 
+       for (--len; len>=0 && builtintable[len].supported; len--);
+       builtintablelen = ++len;
+
 #if 0
        {
                int i;
@@ -1517,7 +1522,7 @@ static inline void sort_builtintable()
 stdopdescriptor *find_builtin(int icmd)
 {
        stdopdescriptor *first = builtintable;
-       stdopdescriptor *last = builtintable + sizeof(builtintable) / sizeof(stdopdescriptor);
+       stdopdescriptor *last = builtintable + builtintablelen;
        int len = last - first;
        int half;
        stdopdescriptor *middle;
@@ -1531,7 +1536,7 @@ stdopdescriptor *find_builtin(int icmd)
                } else
                        len = half;
        }
-       return first;
+       return first != last ? first : NULL;
 }
 
 #endif
index 43a71bf1a238216455138745bf06361e983f79de..b12cbfe48328ca7050ae5cf15204712c91162674 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Andreas Krall
 
-   $Id: stack.c 624 2003-11-13 14:06:52Z twisti $
+   $Id: stack.c 640 2003-11-15 12:14:05Z stefan $
 
 */
 
@@ -340,8 +340,7 @@ void analyse_stack()
                                                stdopdescriptor *breplace;
                                                breplace = find_builtin(opcode);
 
-/*                                             if (breplace != blast && opcode == breplace->opcode && !breplace->supported) { */
-                                               if (opcode == breplace->opcode && !breplace->supported) {
+                                               if (breplace && opcode == breplace->opcode) {
                                                        iptr[0].opc = breplace->icmd;
                                                        iptr[0].op1 = breplace->type_d;
                                                        iptr[0].val.a = breplace->builtin;
index a61efd25d39fa085e18ab60e1208da20d216f7a3..69b3a885fea884731f3d8cd31d79acab1ca56341 100644 (file)
@@ -27,7 +27,7 @@
    Authors: Andreas Krall
             Reinhard Grafl
 
-   $Id: jit.c 638 2003-11-14 23:51:34Z stefan $
+   $Id: jit.c 640 2003-11-15 12:14:05Z stefan $
 
 */
 
@@ -1283,10 +1283,6 @@ stdopdescriptor builtintable[] = {
          (functionptr) builtin_lneg, SUPPORT_LONG && SUPPORT_LONG_ADD, true },
        { ICMD_LMUL,   TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2,
          (functionptr) builtin_lmul , SUPPORT_LONG && SUPPORT_LONG_MUL, false },
-       { ICMD_FREM,   TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT, ICMD_BUILTIN2,
-         (functionptr) builtin_frem, SUPPORT_FLOAT && SUPPORT_FMOD, true },
-       { ICMD_DREM,   TYPE_DOUBLE, TYPE_DOUBLE, TYPE_DOUBLE, ICMD_BUILTIN2,
-         (functionptr) builtin_drem, SUPPORT_DOUBLE && SUPPORT_FMOD, true },
        { ICMD_I2F,    TYPE_INT, TYPE_VOID, TYPE_FLOAT, ICMD_BUILTIN1,
          (functionptr) builtin_i2f, SUPPORT_FLOAT && SUPPORT_IFCVT, true },
        { ICMD_I2D,    TYPE_INT, TYPE_VOID, TYPE_DOUBLE, ICMD_BUILTIN1, 
@@ -1306,6 +1302,8 @@ stdopdescriptor builtintable[] = {
        { 255, 0, 0, 0, 0, NULL, true, false },
 };
 
+static int builtintablelen;
+
 #endif /* USEBUILTINTABLE */
 
 
@@ -1492,6 +1490,10 @@ static int stdopcompare(const void *a, const void *b)
 {
        stdopdescriptor *o1 = (stdopdescriptor *) a;
        stdopdescriptor *o2 = (stdopdescriptor *) b;
+       if (!o1->supported && o2->supported)
+               return -1;
+       if (o1->supported && !o2->supported)
+               return 1;
        return (o1->opcode < o2->opcode) ? -1 : (o1->opcode > o2->opcode);
 }
 
@@ -1503,6 +1505,9 @@ static inline void sort_builtintable()
        len = sizeof(builtintable) / sizeof(stdopdescriptor);
        qsort(builtintable, len, sizeof(stdopdescriptor), stdopcompare);
 
+       for (--len; len>=0 && builtintable[len].supported; len--);
+       builtintablelen = ++len;
+
 #if 0
        {
                int i;
@@ -1517,7 +1522,7 @@ static inline void sort_builtintable()
 stdopdescriptor *find_builtin(int icmd)
 {
        stdopdescriptor *first = builtintable;
-       stdopdescriptor *last = builtintable + sizeof(builtintable) / sizeof(stdopdescriptor);
+       stdopdescriptor *last = builtintable + builtintablelen;
        int len = last - first;
        int half;
        stdopdescriptor *middle;
@@ -1531,7 +1536,7 @@ stdopdescriptor *find_builtin(int icmd)
                } else
                        len = half;
        }
-       return first;
+       return first != last ? first : NULL;
 }
 
 #endif
index 43a71bf1a238216455138745bf06361e983f79de..b12cbfe48328ca7050ae5cf15204712c91162674 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Andreas Krall
 
-   $Id: stack.c 624 2003-11-13 14:06:52Z twisti $
+   $Id: stack.c 640 2003-11-15 12:14:05Z stefan $
 
 */
 
@@ -340,8 +340,7 @@ void analyse_stack()
                                                stdopdescriptor *breplace;
                                                breplace = find_builtin(opcode);
 
-/*                                             if (breplace != blast && opcode == breplace->opcode && !breplace->supported) { */
-                                               if (opcode == breplace->opcode && !breplace->supported) {
+                                               if (breplace && opcode == breplace->opcode) {
                                                        iptr[0].opc = breplace->icmd;
                                                        iptr[0].op1 = breplace->type_d;
                                                        iptr[0].val.a = breplace->builtin;