* Removed all Id tags.
[cacao.git] / src / vm / jit / dseg.c
index 47ca107d4574286231acad8de4f3c992e4abde89..f6079d09aded9b3d8174a99e16aaa321875054b4 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/jit/dseg.c - data segment handling stuff
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   Copyright (C) 1996-2005, 2006, 2007 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
@@ -30,7 +30,6 @@
             Joseph Wenninger
             Edwin Steiner
 
-   $Id: dseg.c 6066 2006-11-27 15:29:40Z edwin $
 
 */
 
 
 #include <assert.h>
 
-#include "vm/options.h"
 #include "vm/types.h"
 
 #include "mm/memory.h"
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/methodheader.h"
+#include "vmcore/options.h"
 
 
 /* dseg_finish *****************************************************************
@@ -755,8 +754,6 @@ static s4 dseg_get_linenumber_from_pc_intern(methodinfo **pm, linenumbertable_en
        linenumbertable_entry *lntinline;     /* special entry for inlined method */
 
        for (; lntsize > 0; lntsize--, lntentry--) {
-               /* did we reach the current line? */
-
                /* Note: In case of inlining this may actually compare the pc
                   against a methodinfo *, yielding a non-sensical
                   result. This is no problem, however, as we ignore such
@@ -764,55 +761,50 @@ static s4 dseg_get_linenumber_from_pc_intern(methodinfo **pm, linenumbertable_en
                   common case (ie. a real pc in lntentry->pc). */
 
                if (pc >= lntentry->pc) {
-                       /* check for special inline entries (see
-                          doc/inlining_stacktrace.txt for details */
+                       /* did we reach the current line? */
 
-                       if ((s4) lntentry->line < 0) {
-                               switch (lntentry->line) {
-                               case -1: 
-                                       /* begin of inlined method (ie. INLINE_END
-                                          instruction) */
+                       if ((s4) lntentry->line >= 0)
+                               return (s4) lntentry->line;
 
-                                       lntinline = --lntentry;/* get entry with methodinfo * */
-                                       lntentry--;            /* skip the special entry      */
-                                       lntsize -= 2;
+                       /* we found a special inline entry (see
+                          doc/inlining_stacktrace.txt for details */
 
-                                       /* search inside the inlined method */
+                       switch (lntentry->line) {
+                       case -1: 
+                               /* begin of inlined method (ie. INLINE_END
+                                  instruction) */
 
-                                       if (dseg_get_linenumber_from_pc_intern(pm, 
-                                                                                                                  lntentry,
-                                                                                                                  lntsize,
-                                                                                                                  pc))
-                                               {
-                                                       /* the inlined method contained the pc */
+                               lntinline = --lntentry;/* get entry with methodinfo * */
+                               lntentry--;            /* skip the special entry      */
+                               lntsize -= 2;
 
-                                                       *pm = (methodinfo *) lntinline->pc;
+                               /* search inside the inlined method */
 
-                                                       assert(lntinline->line <= -3);
+                               if (dseg_get_linenumber_from_pc_intern(pm, lntentry, lntsize,
+                                                                                                          pc))
+                               {
+                                       /* the inlined method contained the pc */
 
-                                                       return (-3) - lntinline->line;
-                                               }
+                                       *pm = (methodinfo *) lntinline->pc;
 
-                                       /* pc was not in inlined method, continue
-                                          search.  Entries inside the inlined method
-                                          will be skipped because their lntentry->pc
-                                          is higher than pc.  */
-                                       break;
+                                       assert(lntinline->line <= -3);
 
-                               case -2: 
-                                       /* end of inlined method */
+                                       return (-3) - lntinline->line;
+                               }
 
-                                       return 0;
+                               /* pc was not in inlined method, continue search.
+                                  Entries inside the inlined method will be skipped
+                                  because their lntentry->pc is higher than pc.  */
+                               break;
 
-                                       /* default: is only reached for an -3-line entry
-                                          after a skipped -2 entry. We can safely ignore
-                                          it and continue searching.  */
-                               }
-                       }
-                       else {
-                               /* found a normal entry */
+                       case -2: 
+                               /* end of inlined method */
 
-                               return (s4) lntentry->line;
+                               return 0;
+
+                               /* default: is only reached for an -3-line entry after
+                                  a skipped -2 entry. We can safely ignore it and
+                                  continue searching.  */
                        }
                }
        }
@@ -837,6 +829,10 @@ s4 dseg_get_linenumber_from_pc(methodinfo **pm, u1 *pv, u1 *pc)
        linenumbertable_entry *lntentry;    /* points to last entry in the table  */
        s4                     linenumber;
 
+#if defined(__S390__)
+       pc = (u1 *)((intptr_t)pc & 0x7FFFFFFF);
+#endif
+
        /* get size of line number table */
 
        lntsize  = *((ptrint *) (pv + LineNumberTableSize));
@@ -861,7 +857,7 @@ s4 dseg_get_linenumber_from_pc(methodinfo **pm, u1 *pv, u1 *pc)
 
 *******************************************************************************/
 
-#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(ENABLE_INTRP)
+#if defined(__I386__) || defined(__X86_64__) || defined(__S390__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
 void dseg_adddata(codegendata *cd)
 {
        dataref *dr;
@@ -882,7 +878,7 @@ void dseg_adddata(codegendata *cd)
 
 *******************************************************************************/
 
-#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(ENABLE_INTRP)
+#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
 void dseg_resolve_datareferences(jitdata *jd)
 {
        codeinfo    *code;