GNU header update.
[cacao.git] / src / vm / jit / stack.c
index 809e69183e4fcf7524fa548a9991fc100d994b20..814b3faaa05b86fcb5dab891d8c96b7f957a2bb3 100644 (file)
@@ -1,9 +1,9 @@
-/* jit/stack.c - stack analysis
+/* vm/jit/stack.c - stack analysis
 
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
-   R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
-   M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
-   P. Tomsich, J. Wenninger
+   Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
+   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
+   Institut f. Computersprachen - TU Wien
 
    This file is part of CACAO.
 
 
    Changes: Edwin Steiner
 
-   $Id: stack.c 1456 2004-11-05 14:33:14Z twisti $
+   $Id: stack.c 1735 2004-12-07 14:33:27Z twisti $
 
 */
 
 
 #include <stdio.h>
 #include <string.h>
-#include "global.h"
-#include "native.h"
-#include "builtin.h"
+
 #include "disass.h"
-#include "tables.h"
 #include "types.h"
-#include "options.h"
-#include "statistics.h"
-#include "jit/codegen.inc.h"
-#include "jit/jit.h"
-#include "jit/stack.h"
-#include "jit/reg.h"
+#include "mm/memory.h"
+#include "native/native.h"
 #include "toolbox/logging.h"
-#include "toolbox/memory.h"
+#include "vm/global.h"
+#include "vm/builtin.h"
+#include "vm/options.h"
+#include "vm/statistics.h"
+#include "vm/tables.h"
+#include "vm/jit/codegen.inc.h"
+#include "vm/jit/jit.h"
+#include "vm/jit/reg.h"
+#include "vm/jit/stack.h"
 
 
 /**********************************************************************/
@@ -209,7 +210,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                                }
                                else if (bptr->indepth != stackdepth) {
                                        show_icmd_method(m, cd, rd);
-                                       printf("Block: %ld, required depth:%ld, current depth:%ld\n",bptr->debug_nr,bptr->indepth,stackdepth);
+                                       printf("Block: %d, required depth: %d, current depth: %d\n", bptr->debug_nr, bptr->indepth, stackdepth);
                                        panic("Stack depth mismatch");
                                        
                                }
@@ -235,7 +236,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                                                if (breplace && opcode == breplace->opcode) {
                                                        iptr[0].opc = breplace->icmd;
                                                        iptr[0].op1 = breplace->type_d;
-                                                       iptr[0].val.a = breplace->builtin;
+                                                       iptr[0].val.fp = breplace->builtin;
                                                        m->isleafmethod = false;
                                                        switch (breplace->icmd) {
                                                        case ICMD_BUILTIN1:
@@ -251,7 +252,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                                                if (breplace && opcode == breplace->opcode) {
                                                        iptr[0].opc = breplace->icmd;
                                                        iptr[0].op1 = breplace->type_d;
-                                                       iptr[0].val.a = breplace->builtin;
+                                                       iptr[0].val.fp = breplace->builtin;
                                                        m->isleafmethod = false;
                                                        switch (breplace->icmd) {
                                                        case ICMD_BUILTIN1:
@@ -769,7 +770,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
 #if SUPPORT_CONST_ASTORE
                                                if (len > 0 && iptr->val.a == 0) {
                                                        if (iptr[1].opc == ICMD_BUILTIN3 &&
-                                                               iptr[1].val.a == BUILTIN_aastore) {
+                                                               iptr[1].val.fp == BUILTIN_aastore) {
                                                                iptr[0].opc = ICMD_AASTORECONST;
                                                                iptr[1].opc = ICMD_NOP;
                                                                OPTT2_0(TYPE_INT, TYPE_ADR);
@@ -1396,7 +1397,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
 #if !SUPPORT_DIVISION
                                                iptr[0].opc = ICMD_BUILTIN2;
                                                iptr[0].op1 = TYPE_INT;
-                                               iptr[0].val.a = BUILTIN_idiv;
+                                               iptr[0].val.fp = BUILTIN_idiv;
                                                m->isleafmethod = false;
                                                goto builtin2;
 #endif
@@ -1405,7 +1406,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
 #if !SUPPORT_DIVISION
                                                iptr[0].opc = ICMD_BUILTIN2;
                                                iptr[0].op1 = TYPE_INT;
-                                               iptr[0].val.a = BUILTIN_irem;
+                                               iptr[0].val.fp = BUILTIN_irem;
                                                m->isleafmethod = false;
                                                goto builtin2;
 #endif
@@ -1434,7 +1435,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
                                                iptr[0].opc = ICMD_BUILTIN2;
                                                iptr[0].op1 = TYPE_LNG;
-                                               iptr[0].val.a = BUILTIN_ldiv;
+                                               iptr[0].val.fp = BUILTIN_ldiv;
                                                m->isleafmethod = false;
                                                goto builtin2;
 #endif
@@ -1443,7 +1444,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
                                                iptr[0].opc = ICMD_BUILTIN2;
                                                iptr[0].op1 = TYPE_LNG;
-                                               iptr[0].val.a = BUILTIN_lrem;
+                                               iptr[0].val.fp = BUILTIN_lrem;
                                                m->isleafmethod = false;
                                                goto builtin2;
 #endif
@@ -1778,6 +1779,10 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                                                        }
                                                        break;
                                                }
+                                       case ICMD_INLINE_START:
+                                       case ICMD_INLINE_END:
+                                               SETDST;
+                                               break;
 
                                        case ICMD_BUILTIN3:
                                                /* DEBUG */ /*dolog("builtin3");*/
@@ -1898,8 +1903,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                if (m->basicblockcount > count_max_basic_blocks)
                        count_max_basic_blocks = m->basicblockcount;
                count_basic_blocks += m->basicblockcount;
-               if (m->instructioncount > count_max_javainstr)
-                       count_max_javainstr = m->instructioncount;
+               if (m->instructioncount > count_max_javainstr)                  count_max_javainstr = m->instructioncount;
                count_javainstr += m->instructioncount;
                if (m->stackcount > count_upper_bound_new_stack)
                        count_upper_bound_new_stack = m->stackcount;
@@ -2157,7 +2161,9 @@ void show_icmd_method(methodinfo *m, codegendata *cd, registerdata *rd)
                printf("\n");
        }
        printf("\n");
-
+#ifdef LSRA
+       if (!opt_lsra) {
+#endif
        printf("Interface Table:\n");
        for (i = 0; i < cd->maxstack; i++) {
                if ((rd->interfaces[i][0].type >= 0) ||
@@ -2192,13 +2198,15 @@ void show_icmd_method(methodinfo *m, codegendata *cd, registerdata *rd)
                }
        }
        printf("\n");
-
+#ifdef LSRA
+       }
+#endif
        if (showdisassemble) {
 #if defined(__I386__) || defined(__X86_64__)
                u1 *u1ptr;
                s4 a;
 
-               u1ptr = m->mcode + cd->dseglen;
+               u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen);
                for (i = 0; i < m->basicblocks[0].mpc; i++, u1ptr++) {
                        a = disassinstr(u1ptr, i);
                        i += a;
@@ -2208,7 +2216,7 @@ void show_icmd_method(methodinfo *m, codegendata *cd, registerdata *rd)
 #else
                s4 *s4ptr;
 
-               s4ptr = (s4 *) (m->mcode + cd->dseglen);
+               s4ptr = (s4 *) ((ptrint) m->mcode + cd->dseglen);
                for (i = 0; i < m->basicblocks[0].mpc; i += 4, s4ptr++) {
                        disassinstr(s4ptr, i); 
                }
@@ -2259,7 +2267,7 @@ void show_icmd_block(methodinfo *m, codegendata *cd, basicblock *bptr)
 
                        printf("\n");
                        i = bptr->mpc;
-                       u1ptr = m->mcode + cd->dseglen + i;
+                       u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen + i);
 
                        if (bptr->next != NULL) {
                                for (; i < bptr->next->mpc; i++, u1ptr++) {
@@ -2270,7 +2278,7 @@ void show_icmd_block(methodinfo *m, codegendata *cd, basicblock *bptr)
                                printf("\n");
 
                        } else {
-                               for (; u1ptr < (u1 *) (m->mcode + m->mcodelength); i++, u1ptr++) {
+                               for (; u1ptr < (u1 *) ((ptrint) m->mcode + m->mcodelength); i++, u1ptr++) {
                                        a = disassinstr(u1ptr, i); 
                                        i += a;
                                        u1ptr += a;
@@ -2282,7 +2290,7 @@ void show_icmd_block(methodinfo *m, codegendata *cd, basicblock *bptr)
 
                        printf("\n");
                        i = bptr->mpc;
-                       s4ptr = (s4 *) (m->mcode + cd->dseglen + i);
+                       s4ptr = (s4 *) ((ptrint) m->mcode + cd->dseglen + i);
 
                        if (bptr->next != NULL) {
                                for (; i < bptr->next->mpc; i += 4, s4ptr++) {
@@ -2291,7 +2299,7 @@ void show_icmd_block(methodinfo *m, codegendata *cd, basicblock *bptr)
                                printf("\n");
 
                        } else {
-                               for (; s4ptr < (s4 *) (m->mcode + m->mcodelength); i += 4, s4ptr++) {
+                               for (; s4ptr < (s4 *) ((ptrint) m->mcode + m->mcodelength); i += 4, s4ptr++) {
                                        disassinstr(s4ptr, i); 
                                }
                                printf("\n");
@@ -2490,10 +2498,16 @@ void show_icmd(instruction *iptr, bool deadcode)
                }
                break;
 
+       case ICMD_INLINE_START:
+               printf("\t\t\t%s.%s%s depth=%i",iptr->method->class->name->text,iptr->method->name->text,iptr->method->descriptor->text, iptr->op1);
+               break;
+       case ICMD_INLINE_END:
+               break;
+
        case ICMD_BUILTIN3:
        case ICMD_BUILTIN2:
        case ICMD_BUILTIN1:
-               printf(" %s", icmd_builtin_name((functionptr) iptr->val.a));
+               printf(" %s", icmd_builtin_name((functionptr) iptr->val.fp));
                break;
 
        case ICMD_INVOKEVIRTUAL:
@@ -2616,11 +2630,11 @@ void show_icmd(instruction *iptr, bool deadcode)
                }
                break;
        }
-/*     printf(" Line number: %d, method:",iptr->line); */
-        printf("\t\t");
+       printf(" Line number: %d, method:",iptr->line);
+/*        printf("\t\t");
        utf_display(iptr->method->class->name); 
        printf("."); 
-       utf_display(iptr->method->name); 
+       utf_display(iptr->method->name); */
 }