* src/vm/jit/linenumbertable.c: Moved to .cpp.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Wed, 27 Aug 2008 18:35:50 +0000 (14:35 -0400)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Wed, 27 Aug 2008 18:35:50 +0000 (14:35 -0400)
* src/vm/jit/linenumbertable.h: Likewise.
* src/vm/jit/linenumbertable.cpp: New file.
* src/vm/jit/linenumbertable.hpp: Likewise.
* src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp,
src/vm/jit/Makefile.am,
src/vm/jit/alpha/codegen.c,
src/vm/jit/arm/codegen.c,
src/vm/jit/code.hpp,
src/vm/jit/codegen-common.cpp,
src/vm/jit/i386/codegen.c,
src/vm/jit/m68k/codegen.c,
src/vm/jit/mips/codegen.c,
src/vm/jit/powerpc/codegen.c,
src/vm/jit/powerpc64/codegen.c,
src/vm/jit/s390/codegen.c,
src/vm/jit/sparc64/codegen.c,
src/vm/jit/stacktrace.cpp,
src/vm/jit/x86_64/codegen.c: Related changes.

--HG--
rename : src/vm/jit/linenumbertable.c => src/vm/jit/linenumbertable.cpp
rename : src/vm/jit/linenumbertable.h => src/vm/jit/linenumbertable.hpp

19 files changed:
src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp
src/vm/jit/Makefile.am
src/vm/jit/alpha/codegen.c
src/vm/jit/arm/codegen.c
src/vm/jit/code.hpp
src/vm/jit/codegen-common.cpp
src/vm/jit/i386/codegen.c
src/vm/jit/linenumbertable.c [deleted file]
src/vm/jit/linenumbertable.cpp [new file with mode: 0644]
src/vm/jit/linenumbertable.h [deleted file]
src/vm/jit/linenumbertable.hpp [new file with mode: 0644]
src/vm/jit/m68k/codegen.c
src/vm/jit/mips/codegen.c
src/vm/jit/powerpc/codegen.c
src/vm/jit/powerpc64/codegen.c
src/vm/jit/s390/codegen.c
src/vm/jit/sparc64/codegen.c
src/vm/jit/stacktrace.cpp
src/vm/jit/x86_64/codegen.c

index a3c26cf1b829cd1ed558849302c5916f831c90a9..9a6a69f88bf362e4c63aa944d0a946abb6f5aa5b 100644 (file)
@@ -47,7 +47,7 @@
 #include "vm/string.hpp"
 
 #include "vm/jit/code.hpp"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/stacktrace.hpp"
 
 
index e6eab136d39025568eb93d1115d27be14377eb59..ad7d6524ff33d87d6836d6161707a96fc9cd5c18 100644 (file)
@@ -169,8 +169,8 @@ libjit_la_SOURCES = \
        executionstate.h \
        jit.cpp \
        jit.hpp \
-       linenumbertable.c \
-       linenumbertable.h \
+       linenumbertable.cpp \
+       linenumbertable.hpp \
        methodtree.c \
        methodtree.h \
        parse.c \
index 72f5dae71ee413a5dabc391f27fddf4891f1c81a..08d17b8ce4d00922f3eb944bddec44b7ef5653db 100644 (file)
@@ -56,7 +56,7 @@
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher-common.hpp"
 #include "vm/jit/reg.h"
index 5c30df214d07ac05707a82a95fad12793d694d8c..8b8ed93caf5c10bea905a57f4c2423c7c80a2fb2 100644 (file)
@@ -55,7 +55,7 @@
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher-common.hpp"
index deac0e15e765f60d4fb85b22c9f2c597e2b9a92d..3d6f4c00987e1de7452de9d1811da5c301c6ed93 100644 (file)
@@ -39,7 +39,7 @@
 #include "vm/method.h"
 
 #include "vm/jit/exceptiontable.h"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/replace.hpp"
 
index 0efaad8af10caedc3b57697dd9f21f48fccf86ab..a9ca3fde92f762d849f2de1cd5a6a06e367eed6c 100644 (file)
@@ -84,7 +84,7 @@
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/methodtree.h"
 #include "vm/jit/patcher-common.hpp"
index 5b0cd8a7f11e000b3c6a7d71179dcd0f91766fd7..1a8e1c84c54b2e29f3265d547ccf270e6f81f951 100644 (file)
@@ -58,7 +58,7 @@
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher-common.hpp"
 #include "vm/jit/reg.h"
diff --git a/src/vm/jit/linenumbertable.c b/src/vm/jit/linenumbertable.c
deleted file mode 100644 (file)
index e906a06..0000000
+++ /dev/null
@@ -1,340 +0,0 @@
-/* src/vm/jit/linenumbertable.c - linenumber handling stuff
-
-   Copyright (C) 2007
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   This file is part of CACAO.
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2, or (at
-   your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdint.h>
-
-#include "mm/memory.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vm/options.h"
-# include "vm/statistics.h"
-#endif
-
-#include "vm/jit/code.hpp"
-#include "vm/jit/codegen-common.hpp"
-#include "vm/jit/linenumbertable.h"
-
-
-#if defined(__S390__)
-#  define ADDR_MASK(type, x) ((type)((uintptr_t)(x) & 0x7FFFFFFF))
-#else
-#  define ADDR_MASK(type, x) (x)
-#endif
-
-/* linenumbertable_create ******************************************************
-
-   Creates the linenumber table.  We allocate an array and store the
-   linenumber entry in reverse-order, so we can search the correct
-   linenumber more easily.
-
-*******************************************************************************/
-
-void linenumbertable_create(jitdata *jd)
-{
-       codeinfo                     *code;
-       codegendata                  *cd;
-       linenumbertable_t            *lnt;
-       linenumbertable_entry_t      *lnte;
-       list_t                       *l;
-       linenumbertable_list_entry_t *le;
-       uint8_t                      *pv;
-       void                         *pc;
-
-       /* Get required compiler data. */
-
-       code = jd->code;
-       cd   = jd->cd;
-
-       /* Don't allocate a linenumber table if we don't need one. */
-
-       l = cd->linenumbers;
-
-       if (l->size == 0)
-               return;
-
-       /* Allocate the linenumber table and the entries array. */
-
-       lnt  = NEW(linenumbertable_t);
-       lnte = MNEW(linenumbertable_entry_t, l->size);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat) {
-               count_linenumbertable++;
-
-               size_linenumbertable +=
-                       sizeof(linenumbertable_t) +
-                       sizeof(linenumbertable_entry_t) * l->size;
-       }
-#endif
-
-       /* Fill the linenumber table. */
-
-       lnt->length  = l->size;
-       lnt->entries = lnte;
-
-       /* Fill the linenumber table entries in reverse order, so the
-          search can be forward. */
-
-       /* FIXME I only made this change to prevent a problem when moving
-          to C++. This should be changed back when this file has
-          converted to C++. */
-
-       pv = ADDR_MASK(uint8_t *, code->entrypoint);
-
-       for (le = list_first(l); le != NULL; le = list_next(l, le), lnte++) {
-               /* If the entry contains an mcode pointer (normal case),
-                  resolve it (see doc/inlining_stacktrace.txt for
-                  details). */
-
-               if (le->linenumber >= -2)
-                       pc = pv + le->mpc;
-               else
-                       pc = (void *) le->mpc;
-
-               /* Fill the linenumber table entry. */
-
-               lnte->linenumber = le->linenumber;
-               lnte->pc         = pc;
-       }
-
-       /* Store the linenumber table in the codeinfo. */
-
-       code->linenumbertable = lnt;
-}
-
-
-/* linenumbertable_list_entry_add **********************************************
-
-   Add a line number reference.
-
-   IN:
-      cd.............current codegen data
-      linenumber.....number of line that starts with the given mcodeptr
-
-*******************************************************************************/
-
-void linenumbertable_list_entry_add(codegendata *cd, int32_t linenumber)
-{
-       linenumbertable_list_entry_t *le;
-
-       le = DNEW(linenumbertable_list_entry_t);
-
-       le->linenumber = linenumber;
-       le->mpc        = cd->mcodeptr - cd->mcodebase;
-
-       list_add_first(cd->linenumbers, le);
-}
-
-
-/* linenumbertable_list_entry_add_inline_start *********************************
-
-   Add a marker to the line number table indicating the start of an
-   inlined method body. (see doc/inlining_stacktrace.txt)
-
-   IN:
-      cd ..... current codegen data
-      iptr ... the ICMD_INLINE_BODY instruction
-
-*******************************************************************************/
-
-void linenumbertable_list_entry_add_inline_start(codegendata *cd, instruction *iptr)
-{
-       linenumbertable_list_entry_t *le;
-       insinfo_inline               *insinfo;
-       uintptr_t                     mpc;
-
-       le = DNEW(linenumbertable_list_entry_t);
-
-       le->linenumber = (-2); /* marks start of inlined method */
-       le->mpc        = (mpc = cd->mcodeptr - cd->mcodebase);
-
-       list_add_first(cd->linenumbers, le);
-
-       insinfo = iptr->sx.s23.s3.inlineinfo;
-
-       insinfo->startmpc = mpc; /* store for corresponding INLINE_END */
-}
-
-
-/* linenumbertable_list_entry_add_inline_end ***********************************
-
-   Add a marker to the line number table indicating the end of an
-   inlined method body. (see doc/inlining_stacktrace.txt)
-
-   IN:
-      cd ..... current codegen data
-      iptr ... the ICMD_INLINE_END instruction
-
-   Note:
-      iptr->method must point to the inlined callee.
-
-*******************************************************************************/
-
-void linenumbertable_list_entry_add_inline_end(codegendata *cd, instruction *iptr)
-{
-       linenumbertable_list_entry_t *le;
-       insinfo_inline               *insinfo;
-
-       insinfo = iptr->sx.s23.s3.inlineinfo;
-
-       assert(insinfo);
-
-       le = DNEW(linenumbertable_list_entry_t);
-
-       /* special entry containing the methodinfo * */
-       le->linenumber = (-3) - iptr->line;
-       le->mpc        = (uintptr_t) insinfo->method;
-
-       list_add_first(cd->linenumbers, le);
-
-       le = DNEW(linenumbertable_list_entry_t);
-
-       /* end marker with PC of start of body */
-       le->linenumber = (-1);
-       le->mpc        = insinfo->startmpc;
-
-       list_add_first(cd->linenumbers, le);
-}
-
-
-/* linenumbertable_linenumber_for_pc_intern ************************************
-
-   This function search the line number table for the line
-   corresponding to a given pc. The function recurses for inlined
-   methods.
-
-*******************************************************************************/
-
-static s4 linenumbertable_linenumber_for_pc_intern(methodinfo **pm, linenumbertable_entry_t *lnte, int32_t lntsize, void *pc)
-{
-       linenumbertable_entry_t *lntinline;   /* special entry for inlined method */
-
-       pc = ADDR_MASK(void *, pc);
-
-       for (; lntsize > 0; lntsize--, lnte++) {
-               /* 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
-                  entries in the switch below. This way we optimize for the
-                  common case (ie. a real pc in lntentry->pc). */
-
-               if (pc >= lnte->pc) {
-                       /* did we reach the current line? */
-
-                       if (lnte->linenumber >= 0)
-                               return lnte->linenumber;
-
-                       /* we found a special inline entry (see
-                          doc/inlining_stacktrace.txt for details */
-
-                       switch (lnte->linenumber) {
-                       case -1: 
-                               /* begin of inlined method (ie. INLINE_END
-                                  instruction) */
-
-                               lntinline = --lnte;            /* get entry with methodinfo * */
-                               lnte--;                        /* skip the special entry      */
-                               lntsize -= 2;
-
-                               /* search inside the inlined method */
-
-                               if (linenumbertable_linenumber_for_pc_intern(pm, lnte, lntsize, pc)) {
-                                       /* the inlined method contained the pc */
-
-                                       *pm = (methodinfo *) lntinline->pc;
-
-                                       assert(lntinline->linenumber <= -3);
-
-                                       return (-3) - lntinline->linenumber;
-                               }
-
-                               /* 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;
-
-                       case -2: 
-                               /* end of inlined method */
-
-                               return 0;
-
-                               /* default: is only reached for an -3-line entry after
-                                  a skipped -2 entry. We can safely ignore it and
-                                  continue searching.  */
-                       }
-               }
-       }
-
-       /* PC not found. */
-
-       return 0;
-}
-
-
-/* linenumbertable_linenumber_for_pc *******************************************
-
-   A wrapper for linenumbertable_linenumber_for_pc_intern.
-
-   NOTE: We have a intern version because the function is called
-   recursively for inlined methods.
-
-*******************************************************************************/
-
-int32_t linenumbertable_linenumber_for_pc(methodinfo **pm, codeinfo *code, void *pc)
-{
-       linenumbertable_t *lnt;
-       int32_t            linenumber;
-
-       /* Get line number table. */
-
-       lnt = code->linenumbertable;
-
-       if (lnt == NULL)
-               return 0;
-
-       /* Get the line number. */
-
-       linenumber = linenumbertable_linenumber_for_pc_intern(pm, lnt->entries, lnt->length, pc);
-
-       return linenumber;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/vm/jit/linenumbertable.cpp b/src/vm/jit/linenumbertable.cpp
new file mode 100644 (file)
index 0000000..8bdc288
--- /dev/null
@@ -0,0 +1,340 @@
+/* src/vm/jit/linenumbertable.cpp - linenumber handling stuff
+
+   Copyright (C) 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "mm/memory.h"
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/options.h"
+# include "vm/statistics.h"
+#endif
+
+#include "vm/jit/code.hpp"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/linenumbertable.hpp"
+
+
+#if defined(__S390__)
+#  define ADDR_MASK(type, x) ((type)((uintptr_t)(x) & 0x7FFFFFFF))
+#else
+#  define ADDR_MASK(type, x) (x)
+#endif
+
+/* linenumbertable_create ******************************************************
+
+   Creates the linenumber table.  We allocate an array and store the
+   linenumber entry in reverse-order, so we can search the correct
+   linenumber more easily.
+
+*******************************************************************************/
+
+void linenumbertable_create(jitdata *jd)
+{
+       codeinfo                     *code;
+       codegendata                  *cd;
+       linenumbertable_t            *lnt;
+       linenumbertable_entry_t      *lnte;
+       list_t                       *l;
+       linenumbertable_list_entry_t *le;
+       uint8_t                      *pv;
+       void                         *pc;
+
+       /* Get required compiler data. */
+
+       code = jd->code;
+       cd   = jd->cd;
+
+       /* Don't allocate a linenumber table if we don't need one. */
+
+       l = cd->linenumbers;
+
+       if (l->size == 0)
+               return;
+
+       /* Allocate the linenumber table and the entries array. */
+
+       lnt  = NEW(linenumbertable_t);
+       lnte = MNEW(linenumbertable_entry_t, l->size);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat) {
+               count_linenumbertable++;
+
+               size_linenumbertable +=
+                       sizeof(linenumbertable_t) +
+                       sizeof(linenumbertable_entry_t) * l->size;
+       }
+#endif
+
+       /* Fill the linenumber table. */
+
+       lnt->length  = l->size;
+       lnt->entries = lnte;
+
+       /* Fill the linenumber table entries in reverse order, so the
+          search can be forward. */
+
+       /* FIXME I only made this change to prevent a problem when moving
+          to C++. This should be changed back when this file has
+          converted to C++. */
+
+       pv = ADDR_MASK(uint8_t *, code->entrypoint);
+
+       for (le = (linenumbertable_list_entry_t*) list_first(l); le != NULL; le = (linenumbertable_list_entry_t*) list_next(l, le), lnte++) {
+               /* If the entry contains an mcode pointer (normal case),
+                  resolve it (see doc/inlining_stacktrace.txt for
+                  details). */
+
+               if (le->linenumber >= -2)
+                       pc = pv + le->mpc;
+               else
+                       pc = (void *) le->mpc;
+
+               /* Fill the linenumber table entry. */
+
+               lnte->linenumber = le->linenumber;
+               lnte->pc         = pc;
+       }
+
+       /* Store the linenumber table in the codeinfo. */
+
+       code->linenumbertable = lnt;
+}
+
+
+/* linenumbertable_list_entry_add **********************************************
+
+   Add a line number reference.
+
+   IN:
+      cd.............current codegen data
+      linenumber.....number of line that starts with the given mcodeptr
+
+*******************************************************************************/
+
+void linenumbertable_list_entry_add(codegendata *cd, int32_t linenumber)
+{
+       linenumbertable_list_entry_t *le;
+
+       le = (linenumbertable_list_entry_t*) DumpMemory::allocate(sizeof(linenumbertable_list_entry_t));
+
+       le->linenumber = linenumber;
+       le->mpc        = cd->mcodeptr - cd->mcodebase;
+
+       list_add_first(cd->linenumbers, le);
+}
+
+
+/* linenumbertable_list_entry_add_inline_start *********************************
+
+   Add a marker to the line number table indicating the start of an
+   inlined method body. (see doc/inlining_stacktrace.txt)
+
+   IN:
+      cd ..... current codegen data
+      iptr ... the ICMD_INLINE_BODY instruction
+
+*******************************************************************************/
+
+void linenumbertable_list_entry_add_inline_start(codegendata *cd, instruction *iptr)
+{
+       linenumbertable_list_entry_t *le;
+       insinfo_inline               *insinfo;
+       uintptr_t                     mpc;
+
+       le = (linenumbertable_list_entry_t*) DumpMemory::allocate(sizeof(linenumbertable_list_entry_t));
+
+       le->linenumber = (-2); /* marks start of inlined method */
+       le->mpc        = (mpc = cd->mcodeptr - cd->mcodebase);
+
+       list_add_first(cd->linenumbers, le);
+
+       insinfo = iptr->sx.s23.s3.inlineinfo;
+
+       insinfo->startmpc = mpc; /* store for corresponding INLINE_END */
+}
+
+
+/* linenumbertable_list_entry_add_inline_end ***********************************
+
+   Add a marker to the line number table indicating the end of an
+   inlined method body. (see doc/inlining_stacktrace.txt)
+
+   IN:
+      cd ..... current codegen data
+      iptr ... the ICMD_INLINE_END instruction
+
+   Note:
+      iptr->method must point to the inlined callee.
+
+*******************************************************************************/
+
+void linenumbertable_list_entry_add_inline_end(codegendata *cd, instruction *iptr)
+{
+       linenumbertable_list_entry_t *le;
+       insinfo_inline               *insinfo;
+
+       insinfo = iptr->sx.s23.s3.inlineinfo;
+
+       assert(insinfo);
+
+       le = (linenumbertable_list_entry_t*) DumpMemory::allocate(sizeof(linenumbertable_list_entry_t));
+
+       /* special entry containing the methodinfo * */
+       le->linenumber = (-3) - iptr->line;
+       le->mpc        = (uintptr_t) insinfo->method;
+
+       list_add_first(cd->linenumbers, le);
+
+       le = (linenumbertable_list_entry_t*) DumpMemory::allocate(sizeof(linenumbertable_list_entry_t));
+
+       /* end marker with PC of start of body */
+       le->linenumber = (-1);
+       le->mpc        = insinfo->startmpc;
+
+       list_add_first(cd->linenumbers, le);
+}
+
+
+/* linenumbertable_linenumber_for_pc_intern ************************************
+
+   This function search the line number table for the line
+   corresponding to a given pc. The function recurses for inlined
+   methods.
+
+*******************************************************************************/
+
+static s4 linenumbertable_linenumber_for_pc_intern(methodinfo **pm, linenumbertable_entry_t *lnte, int32_t lntsize, void *pc)
+{
+       linenumbertable_entry_t *lntinline;   /* special entry for inlined method */
+
+       pc = ADDR_MASK(void *, pc);
+
+       for (; lntsize > 0; lntsize--, lnte++) {
+               /* 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
+                  entries in the switch below. This way we optimize for the
+                  common case (ie. a real pc in lntentry->pc). */
+
+               if (pc >= lnte->pc) {
+                       /* did we reach the current line? */
+
+                       if (lnte->linenumber >= 0)
+                               return lnte->linenumber;
+
+                       /* we found a special inline entry (see
+                          doc/inlining_stacktrace.txt for details */
+
+                       switch (lnte->linenumber) {
+                       case -1: 
+                               /* begin of inlined method (ie. INLINE_END
+                                  instruction) */
+
+                               lntinline = --lnte;            /* get entry with methodinfo * */
+                               lnte--;                        /* skip the special entry      */
+                               lntsize -= 2;
+
+                               /* search inside the inlined method */
+
+                               if (linenumbertable_linenumber_for_pc_intern(pm, lnte, lntsize, pc)) {
+                                       /* the inlined method contained the pc */
+
+                                       *pm = (methodinfo *) lntinline->pc;
+
+                                       assert(lntinline->linenumber <= -3);
+
+                                       return (-3) - lntinline->linenumber;
+                               }
+
+                               /* 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;
+
+                       case -2: 
+                               /* end of inlined method */
+
+                               return 0;
+
+                               /* default: is only reached for an -3-line entry after
+                                  a skipped -2 entry. We can safely ignore it and
+                                  continue searching.  */
+                       }
+               }
+       }
+
+       /* PC not found. */
+
+       return 0;
+}
+
+
+/* linenumbertable_linenumber_for_pc *******************************************
+
+   A wrapper for linenumbertable_linenumber_for_pc_intern.
+
+   NOTE: We have a intern version because the function is called
+   recursively for inlined methods.
+
+*******************************************************************************/
+
+int32_t linenumbertable_linenumber_for_pc(methodinfo **pm, codeinfo *code, void *pc)
+{
+       linenumbertable_t *lnt;
+       int32_t            linenumber;
+
+       /* Get line number table. */
+
+       lnt = code->linenumbertable;
+
+       if (lnt == NULL)
+               return 0;
+
+       /* Get the line number. */
+
+       linenumber = linenumbertable_linenumber_for_pc_intern(pm, lnt->entries, lnt->length, pc);
+
+       return linenumber;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/vm/jit/linenumbertable.h b/src/vm/jit/linenumbertable.h
deleted file mode 100644 (file)
index 94ede9b..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/* src/vm/jit/linenumbertable.h - linenumber table
-
-   Copyright (C) 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   This file is part of CACAO.
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2, or (at
-   your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-*/
-
-
-#ifndef _LINENUMBERTABLE_H
-#define _LINENUMBERTABLE_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct linenumbertable_t            linenumbertable_t;
-typedef struct linenumbertable_entry_t      linenumbertable_entry_t;
-typedef struct linenumbertable_list_entry_t linenumbertable_list_entry_t;
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "toolbox/list.h"
-
-#include "vm/method.h"
-
-#include "vm/jit/jit.hpp"
-#include "vm/jit/code.hpp"
-#include "vm/jit/codegen-common.hpp"
-
-#include "vm/jit/ir/instruction.hpp"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* linenumbertable_t **********************************************************/
-
-struct linenumbertable_t {
-       int32_t                  length;    /* length of the entries array        */
-       linenumbertable_entry_t *entries;   /* actual linenumber entries          */
-};
-
-
-/* linenumbertable_entry_t *****************************************************
-
-   NOTE: See doc/inlining_stacktrace.txt for special meanings of line
-   and pc.
-
-*******************************************************************************/
-
-struct linenumbertable_entry_t {
-       int32_t  linenumber;                /* linenumber of this entry           */
-       void    *pc;                        /* PC where this linenumber starts    */
-};
-
-
-/* linenumbertable_list_entry_t ***********************************************/
-
-struct linenumbertable_list_entry_t {
-       int32_t    linenumber;      /* line number, used for inserting into the   */
-                                   /* table and for validity checking            */
-                                   /* -1......start of inlined body              */
-                                   /* -2......end of inlined body                */
-                                   /* <= -3...special entry with methodinfo *    */
-                                                               /* (see doc/inlining_stacktrace.txt)          */
-       ptrint     mpc;             /* machine code program counter of first      */
-                                   /* instruction for given line                 */
-                                   /* NOTE: for linenumber <= -3 this is a the   */
-                                   /* (methodinfo *) of the inlined method       */
-       listnode_t linkage;
-};
-
-
-/* function prototypes ********************************************************/
-
-void    linenumbertable_create(jitdata *jd);
-
-void    linenumbertable_list_entry_add(codegendata *cd, int32_t linenumber);
-void    linenumbertable_list_entry_add_inline_start(codegendata *cd, instruction *iptr);
-void    linenumbertable_list_entry_add_inline_end(codegendata *cd, instruction *iptr);
-
-int32_t linenumbertable_linenumber_for_pc(methodinfo **pm, codeinfo *code, void *pc);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LINENUMBERTABLE_H */
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/vm/jit/linenumbertable.hpp b/src/vm/jit/linenumbertable.hpp
new file mode 100644 (file)
index 0000000..b652198
--- /dev/null
@@ -0,0 +1,122 @@
+/* src/vm/jit/linenumbertable.hpp - linenumber table
+
+   Copyright (C) 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#ifndef _LINENUMBERTABLE_HPP
+#define _LINENUMBERTABLE_HPP
+
+/* forward typedefs ***********************************************************/
+
+typedef struct linenumbertable_t            linenumbertable_t;
+typedef struct linenumbertable_entry_t      linenumbertable_entry_t;
+typedef struct linenumbertable_list_entry_t linenumbertable_list_entry_t;
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "toolbox/list.h"
+
+#include "vm/method.h"
+
+#include "vm/jit/jit.hpp"
+#include "vm/jit/code.hpp"
+#include "vm/jit/codegen-common.hpp"
+
+#include "vm/jit/ir/instruction.hpp"
+
+
+/* linenumbertable_t **********************************************************/
+
+struct linenumbertable_t {
+       int32_t                  length;    /* length of the entries array        */
+       linenumbertable_entry_t *entries;   /* actual linenumber entries          */
+};
+
+
+/* linenumbertable_entry_t *****************************************************
+
+   NOTE: See doc/inlining_stacktrace.txt for special meanings of line
+   and pc.
+
+*******************************************************************************/
+
+struct linenumbertable_entry_t {
+       int32_t  linenumber;                /* linenumber of this entry           */
+       void    *pc;                        /* PC where this linenumber starts    */
+};
+
+
+/* linenumbertable_list_entry_t ***********************************************/
+
+struct linenumbertable_list_entry_t {
+       int32_t    linenumber;      /* line number, used for inserting into the   */
+                                   /* table and for validity checking            */
+                                   /* -1......start of inlined body              */
+                                   /* -2......end of inlined body                */
+                                   /* <= -3...special entry with methodinfo *    */
+                                                               /* (see doc/inlining_stacktrace.txt)          */
+       ptrint     mpc;             /* machine code program counter of first      */
+                                   /* instruction for given line                 */
+                                   /* NOTE: for linenumber <= -3 this is a the   */
+                                   /* (methodinfo *) of the inlined method       */
+       listnode_t linkage;
+};
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void    linenumbertable_create(jitdata *jd);
+
+void    linenumbertable_list_entry_add(codegendata *cd, int32_t linenumber);
+void    linenumbertable_list_entry_add_inline_start(codegendata *cd, instruction *iptr);
+void    linenumbertable_list_entry_add_inline_end(codegendata *cd, instruction *iptr);
+
+int32_t linenumbertable_linenumber_for_pc(methodinfo **pm, codeinfo *code, void *pc);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _LINENUMBERTABLE_HPP
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index 5d38065b9203da7afb57ed022e0be60bd3943361..51cf7ea2554162761681bd7135fdffa7098d5b07 100644 (file)
@@ -53,7 +53,7 @@
 #include "vm/jit/codegen-common.hpp"
 #include "vm/jit/patcher-common.hpp"
 #include "vm/jit/dseg.h"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
 #include "vm/jit/abi.h"
index f77101c5f0a4031fe2d21091dd6b2faa239465f1..822c5155a8335930e57127b8c421e4e4e9866ef3 100644 (file)
@@ -54,7 +54,7 @@
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/patcher-common.hpp"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.hpp"
index 5d296e8df75b832a6e6979ba3c9ab63d30064aab..90cff25f01c1394a65052d24c0e2fcd3a5d8320f 100644 (file)
@@ -57,7 +57,7 @@
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher-common.hpp"
index 69fe64073e17b5f8e987c7782d9b4a91fa76c47b..d5d7be35493b2f37b62f26df0e580565a28dcdca 100644 (file)
@@ -58,7 +58,7 @@
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher-common.hpp"
 #include "vm/jit/reg.h"
index 15754e1dbeb7571cac1563b637b6a1d72590411c..64610f6aaae4de45c23de2f2da35324f2d7c73aa 100644 (file)
@@ -59,7 +59,7 @@
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher-common.hpp"
index 87e3084cd7129e77932d72dd1a93b7f164b0ec50..8534103202f024cfd4ba90c405aa7c481df35a18 100644 (file)
@@ -54,7 +54,7 @@
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher.h"
 #include "vm/jit/reg.h"
index 8f6f4fca77cb273b68509590b6ee5404497fee83..1f48083785c4d6a67ae72ed53766615f05f947bd 100644 (file)
@@ -60,7 +60,7 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/codegen-common.hpp"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/methodtree.h"
 
index 900780064d5195e64c9dca785e6d992e903f5f44..ad0252f4a7ee3ee9d11d998ccef9187af55859d5 100644 (file)
@@ -61,7 +61,7 @@
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher-common.hpp"