* configure.ac: New switch for disabling -O2 (--disable-optimizations).
[cacao.git] / doc / inlining_stacktrace.txt
1 Stacktraces with Inlined Methods
2 ================================
3
4 Author:  Edwin Steiner
5 Changes: -
6
7
8 The layout of the line number table looks like this:
9
10     +----------+----------------------+
11     | ln 1     | first PC of line 1   |
12     +----------+----------------------+
13     | ln 2     | first PC of line 2   |
14     +----------+----------------------+
15                        ...
16     +----------+----------------------+
17     | ln N     | first PC of line N   |
18     +----------+----------------------+
19
20 Note: "ln 1" means the line number of the first line of the method body,
21       and so on. The PC is always the start of the first instruction
22       belonging to the given line.
23
24
25 For inlined methods special entries are inserted into the table. The special
26 entries have negative line numbers.  If there is an inlined method call at line
27 X, the table looks like this:
28
29     +----------+----------------------+
30     | ln 1     | first PC of line 1   |
31     +----------+----------------------+
32     | ln 2     | first PC of line 2   |
33     +----------+----------------------+
34                       ...
35     +----------+----------------------+
36     | -2       | first PC of line X   |  <-- "-2" marks start of inlined method
37     +----------+----------------------+
38     | ln 1'    | first PC of line 1'  |  \
39     +----------+----------------------+  |
40     | ln 2'    | first PC of line 2'  |  |
41     +----------+----------------------+  |--- these refer to lines within the body of
42                       ...                    |    the inlined callee
43     +----------+----------------------+  |
44     | ln N'    | first PC of line N'  |  /
45     +----------+----------------------+
46     | -3-ln X  | methodinfo* to callee|  <-- methodinfo* instead of PC, -3 minus line number
47     +----------+----------------------+
48     | -1       | first PC of inlined  |  <-- NOTE THE PC! It's the first, not the last PC.
49     |          | method body          |
50     +----------+----------------------+
51     | ln X     | first PC of line X   |  for the rest of line X, after the inlined call
52     |          | after the call       |
53     +----------+----------------------+
54     | ln X+1   | first PC of line X+1 |
55     +----------+----------------------+
56                       ...
57     +----------+----------------------+
58     | ln N     | first PC of line N   |
59     +----------+----------------------+
60
61 CAUTION: line numbers are stored as unsigned ptrint! You need
62          to cast them (to s4) in order to test <0, etc.
63          (The ptrint values are created by casting a s4 to ptrint.)
64
65 Nesting
66 -------
67
68 For nested inline bodies, the entries of the inner inline body are inserted
69 between the entries of the outer inline body just the same as at the top level.
70
71
72 # vim: et sw=4 sts=4 ts=4
73