google / starlark-go

Starlark in Go: the Starlark configuration language, implemented in Go
BSD 3-Clause "New" or "Revised" License
2.34k stars 212 forks source link

internal/compile: record column information for each PC offset #204

Closed alandonovan closed 5 years ago

alandonovan commented 5 years ago

Prior to this CL, the line-number table in the compiled code recorded only the line number for each program counter value. This change causes it to record columns too.

By stealing bits from the PC and line fields, we can encode the additional information in the same 16 bits of space, again using the same delta encoding approach for columns.

The field widths (uint4 for Δpc, int5 for Δline, and int6 for Δcol) were chosen after analysis of a large set of files to minimize the frequency of overflows, which are more common now but still account for only about 2.5% of all rows.

The decompressed LNTs are 50% bigger, but only a minority of functions' LNTs are materialized in a typical program due to calls to Funcode.Position via Thread.CallStack.

Fixes #176