summaryrefslogtreecommitdiff
path: root/lobject.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-06-27 08:35:31 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-06-27 08:35:31 -0300
commitb42430fd3a6200eaaf4020be90c4d47f7e251b67 (patch)
treec47c23ac9d461b79554986769375019dc6dc469c /lobject.h
parent60a7492d249860d20098ac2f0b9d863606c38450 (diff)
downloadlua-github-b42430fd3a6200eaaf4020be90c4d47f7e251b67.tar.gz
'lineinfo' in prototypes saved as differences instead of absolute
values, so that the array can use bytes instead of ints, reducing its size. (A new array 'abslineinfo' is used when line differences do not fit in a byte.)
Diffstat (limited to 'lobject.h')
-rw-r--r--lobject.h25
1 files changed, 21 insertions, 4 deletions
diff --git a/lobject.h b/lobject.h
index e245f306..9af501af 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.h,v 2.122 2017/06/09 16:48:44 roberto Exp roberto $
+** $Id: lobject.h,v 2.123 2017/06/12 14:21:44 roberto Exp roberto $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@@ -418,6 +418,21 @@ typedef struct LocVar {
/*
+** Associates the absolute line source for a given instruction ('pc').
+** The array 'lineinfo' gives, for each instruction, the difference in
+** lines from the previous instruction. When that difference does not
+** fit into a byte, Lua saves the absolute line for that instruction.
+** (Lua also saves the absolute line periodically, to speed up the
+** computation of a line number: we can use binary search in the
+** absolute-line array, but we must traverse the 'lineinfo' array
+** linearly to compute a line.)
+*/
+typedef struct AbsLineInfo {
+ int pc;
+ int line;
+} AbsLineInfo;
+
+/*
** Function Prototypes
*/
typedef struct Proto {
@@ -432,15 +447,17 @@ typedef struct Proto {
int sizelineinfo;
int sizep; /* size of 'p' */
int sizelocvars;
+ int sizeabslineinfo; /* size of 'abslineinfo' */
int linedefined; /* debug information */
int lastlinedefined; /* debug information */
TValue *k; /* constants used by the function */
+ struct LClosure *cache; /* last-created closure with this prototype */
Instruction *code; /* opcodes */
struct Proto **p; /* functions defined inside the function */
- int *lineinfo; /* map from opcodes to source lines (debug information) */
- LocVar *locvars; /* information about local variables (debug information) */
Upvaldesc *upvalues; /* upvalue information */
- struct LClosure *cache; /* last-created closure with this prototype */
+ ls_byte *lineinfo; /* information about source lines (debug information) */
+ AbsLineInfo *abslineinfo; /* idem */
+ LocVar *locvars; /* information about local variables (debug information) */
TString *source; /* used for debug information */
GCObject *gclist;
} Proto;