* doc/inlining_stacktrace.txt: Added.
authoredwin <none@none>
Sun, 5 Feb 2006 15:26:34 +0000 (15:26 +0000)
committeredwin <none@none>
Sun, 5 Feb 2006 15:26:34 +0000 (15:26 +0000)
* src/vm/jit/dseg.c (dseg_addlinenumber_inline_start): Added.
(dseg_addlinenumber_inline_end): Added.
(dseg_addlinenumber): Commented.
(vim boilerplate): Added.

* src/vm/jit/dseg.h (linenumberref): Changed for inlining stacktraces.
Made targetmpc a ptrint, made linenumber s4, reordered fields.
(dseg_addlinenumber_inline_start): Added.
(dseg_addlinenumber_inline_end): Added.
(vim boilerplate): Added.

doc/inlining_stacktrace.txt [new file with mode: 0644]
src/vm/jit/dseg.c
src/vm/jit/dseg.h

diff --git a/doc/inlining_stacktrace.txt b/doc/inlining_stacktrace.txt
new file mode 100644 (file)
index 0000000..234e8ea
--- /dev/null
@@ -0,0 +1,58 @@
+Stacktraces with Inlined Methods
+================================
+
+Author:  Edwin Steiner
+Changes: -
+
+
+The layout of the line number table looks like this:
+
+    +----------+----------------------+
+    | ln 1     | start PC of line 1   |
+    +----------+----------------------+
+    | ln 2     | start PC of line 2   |
+    +----------+----------------------+
+                      ...
+    +----------+----------------------+
+    | ln N     | start PC of line N   |
+    +----------+----------------------+
+
+Note: "ln 1" means the line number of the first line of the method body,
+      and so on.
+
+
+For inlined methods special entries are inserted into the table. The special
+entries have negative line numbers.  If there is an inlined method call at line
+X, the table looks like this:
+
+    +----------+----------------------+
+    | ln 1     | start PC of line 1   |
+    +----------+----------------------+
+    | ln 2     | start PC of line 1   |
+    +----------+----------------------+
+                     ...
+    +----------+----------------------+
+    | -2       | start PC of line X   |  <-- "-2" marks start of inlined method
+    +----------+----------------------+
+    | ln 1'    | start PC of line 1'  |  \
+    +----------+----------------------+  |
+    | ln 2'    | start PC of line 1'  |  |
+    +----------+----------------------+  |--- these refer to lines within the body of
+                     ...                    |    the inlined callee
+    +----------+----------------------+  |
+    | ln N'    | start PC of line N'  |  /
+    +----------+----------------------+
+    | -3-ln X  | methodinfo* to callee|  <-- methodinfo* instead of PC, -3 minus line number
+    +----------+----------------------+
+    | -1       | start PC of line X   |  <-- NOTE THE PC!
+    +----------+----------------------+
+    | ln X+1   | start PC of line X+1 |
+    +----------+----------------------+
+                     ...
+    +----------+----------------------+
+    | ln N     | start PC of line N   |
+    +----------+----------------------+
+
+
+# vim: et sw=4 sts=4 ts=4
+
index 39a27065bb6fc2ec6a5bfaf978c318079ebfd9a0..6149681e4f5bd2f578e5cb9c924423e0badec6f3 100644 (file)
@@ -30,7 +30,7 @@
    Changes: Christian Thalinger
             Joseph Wenninger
 
-   $Id: dseg.c 4357 2006-01-22 23:33:38Z twisti $
+   $Id: dseg.c 4445 2006-02-05 15:26:34Z edwin $
 
 */
 
@@ -39,6 +39,7 @@
 
 #include "vm/types.h"
 
+#include <assert.h>
 #include "mm/memory.h"
 #include "vm/jit/codegen-common.h"
 
@@ -207,6 +208,17 @@ void dseg_addlinenumbertablesize(codegendata *cd)
 }
 
 
+/* dseg_addlinenumber **********************************************************
+
+   Add a line number reference.
+
+   IN:
+      cd.............current codegen data
+      linenumber.....number of line that starts with the given mcodeptr
+      mcodeptr.......start mcodeptr of line
+
+*******************************************************************************/
+
 void dseg_addlinenumber(codegendata *cd, u2 linenumber, u1 *mcodeptr)
 {
        linenumberref *lr;
@@ -222,6 +234,84 @@ void dseg_addlinenumber(codegendata *cd, u2 linenumber, u1 *mcodeptr)
 }
 
 
+/* dseg_addlinenumber_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_START instruction
+      mcodeptr.......start mcodeptr of inlined body
+
+*******************************************************************************/
+
+void dseg_addlinenumber_inline_start(codegendata *cd, 
+                                                                        instruction *iptr, 
+                                                                        u1 *mcodeptr)
+{
+       linenumberref *lr;
+
+       lr = DNEW(linenumberref);
+
+       lr->linenumber = (-2); /* marks start of inlined method */
+       lr->tablepos   = 0;
+       lr->targetmpc  = mcodeptr - cd->mcodebase;
+       lr->next       = cd->linenumberreferences;
+
+       cd->linenumberreferences = lr;
+
+       iptr->target = mcodeptr; /* store for corresponding INLINE_END */
+}
+
+
+/* dseg_addlinenumber_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 dseg_addlinenumber_inline_end(codegendata *cd, instruction *iptr)
+{
+       linenumberref *lr;
+       linenumberref *prev;
+       instruction *inlinestart;
+
+       /* get the pointer to the corresponding ICMD_INLINE_START */
+       inlinestart = (instruction *)iptr->target;
+
+       assert(inlinestart);
+       assert(iptr->method);
+
+       lr = DNEW(linenumberref);
+
+       /* special entry containing the methodinfo * */
+       lr->linenumber = (-3) - iptr->line;
+       lr->tablepos   = 0;
+       lr->targetmpc  = (ptrint) iptr->method;
+       lr->next       = cd->linenumberreferences;
+
+       prev = lr;
+       lr = DNEW(linenumberref);
+
+       /* end marker with PC of start of body */
+       lr->linenumber = (-1);
+       lr->tablepos   = 0;
+       lr->targetmpc  = (u1*)inlinestart->target - cd->mcodebase;
+       lr->next       = prev;
+
+       cd->linenumberreferences = lr;
+}
+
+
 /* dseg_createlinenumbertable **************************************************
 
    Creates a line number table in the data segment from the created
@@ -327,4 +417,5 @@ void dseg_display(methodinfo *m, codegendata *cd)
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */
index 6bae3834ac058e6744e91cd5a4fb73639aec3cee..0b567704118b3ae9b9ace1911ea6e8a8186fb447 100644 (file)
@@ -30,7 +30,7 @@
    Changes: Christian Thalinger
             Joseph Wenninger
 
-   $Id: dseg.h 4357 2006-01-22 23:33:38Z twisti $
+   $Id: dseg.h 4445 2006-02-05 15:26:34Z edwin $
 
 */
 
@@ -95,10 +95,16 @@ struct patchref {
 
 struct linenumberref {
        s4             tablepos;    /* patching position in data segment          */
-       s4             targetmpc;   /* machine code program counter of first      */
+       s4             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         targetmpc;   /* machine code program counter of first      */
                                    /* instruction for given line                 */
-       u2             linenumber;  /* line number, used for inserting into the   */
-                                   /* table and for validty checking             */
+                                                               /* NOTE: for linenumber <= -3 this is a the   */
+                                   /* (methodinfo *) of the inlined method       */
        linenumberref *next;        /* next element in linenumberref list         */
 };
 
@@ -123,6 +129,8 @@ void dseg_addtarget(codegendata *cd, basicblock *target);
 
 void dseg_addlinenumbertablesize(codegendata *cd);
 void dseg_addlinenumber(codegendata *cd, u2 linenumber, u1 *ptr);
+void dseg_addlinenumber_inline_start(codegendata *cd, instruction *iptr, u1 *ptr);
+void dseg_addlinenumber_inline_end(codegendata *cd, instruction *iptr);
 
 void dseg_createlinenumbertable(codegendata *cd);
 
@@ -149,4 +157,5 @@ void dseg_display(methodinfo *m, codegendata *cd);
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */