diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-06-27 08:35:31 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-06-27 08:35:31 -0300 |
commit | b42430fd3a6200eaaf4020be90c4d47f7e251b67 (patch) | |
tree | c47c23ac9d461b79554986769375019dc6dc469c /lobject.h | |
parent | 60a7492d249860d20098ac2f0b9d863606c38450 (diff) | |
download | lua-b42430fd3a6200eaaf4020be90c4d47f7e251b67.tar.gz lua-b42430fd3a6200eaaf4020be90c4d47f7e251b67.tar.bz2 lua-b42430fd3a6200eaaf4020be90c4d47f7e251b67.zip |
'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.h | 25 |
1 files changed, 21 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.h,v 2.122 2017/06/09 16:48:44 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 2.123 2017/06/12 14:21:44 roberto Exp roberto $ |
3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -418,6 +418,21 @@ typedef struct LocVar { | |||
418 | 418 | ||
419 | 419 | ||
420 | /* | 420 | /* |
421 | ** Associates the absolute line source for a given instruction ('pc'). | ||
422 | ** The array 'lineinfo' gives, for each instruction, the difference in | ||
423 | ** lines from the previous instruction. When that difference does not | ||
424 | ** fit into a byte, Lua saves the absolute line for that instruction. | ||
425 | ** (Lua also saves the absolute line periodically, to speed up the | ||
426 | ** computation of a line number: we can use binary search in the | ||
427 | ** absolute-line array, but we must traverse the 'lineinfo' array | ||
428 | ** linearly to compute a line.) | ||
429 | */ | ||
430 | typedef struct AbsLineInfo { | ||
431 | int pc; | ||
432 | int line; | ||
433 | } AbsLineInfo; | ||
434 | |||
435 | /* | ||
421 | ** Function Prototypes | 436 | ** Function Prototypes |
422 | */ | 437 | */ |
423 | typedef struct Proto { | 438 | typedef struct Proto { |
@@ -432,15 +447,17 @@ typedef struct Proto { | |||
432 | int sizelineinfo; | 447 | int sizelineinfo; |
433 | int sizep; /* size of 'p' */ | 448 | int sizep; /* size of 'p' */ |
434 | int sizelocvars; | 449 | int sizelocvars; |
450 | int sizeabslineinfo; /* size of 'abslineinfo' */ | ||
435 | int linedefined; /* debug information */ | 451 | int linedefined; /* debug information */ |
436 | int lastlinedefined; /* debug information */ | 452 | int lastlinedefined; /* debug information */ |
437 | TValue *k; /* constants used by the function */ | 453 | TValue *k; /* constants used by the function */ |
454 | struct LClosure *cache; /* last-created closure with this prototype */ | ||
438 | Instruction *code; /* opcodes */ | 455 | Instruction *code; /* opcodes */ |
439 | struct Proto **p; /* functions defined inside the function */ | 456 | struct Proto **p; /* functions defined inside the function */ |
440 | int *lineinfo; /* map from opcodes to source lines (debug information) */ | ||
441 | LocVar *locvars; /* information about local variables (debug information) */ | ||
442 | Upvaldesc *upvalues; /* upvalue information */ | 457 | Upvaldesc *upvalues; /* upvalue information */ |
443 | struct LClosure *cache; /* last-created closure with this prototype */ | 458 | ls_byte *lineinfo; /* information about source lines (debug information) */ |
459 | AbsLineInfo *abslineinfo; /* idem */ | ||
460 | LocVar *locvars; /* information about local variables (debug information) */ | ||
444 | TString *source; /* used for debug information */ | 461 | TString *source; /* used for debug information */ |
445 | GCObject *gclist; | 462 | GCObject *gclist; |
446 | } Proto; | 463 | } Proto; |