Use single int for file pos
commitd6eb17bb3f595fb4eb5e6c894468c6f21899a981
authorAndrew Kennedy <akenn@fb.com>
Mon, 30 Apr 2018 14:58:55 +0000 (30 07:58 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Mon, 30 Apr 2018 15:25:05 +0000 (30 08:25 -0700)
tree6fad869d86ca27ba7bd3d7905b0f0bad319ce544
parent1f7c6694b2c29ad38776930b1ad872aa704593a3
Use single int for file pos

Summary:
The `File_pos.t` type is currently a record of three Caml integers. Let's pack it into a single Caml integer to improve space usage for both `hh_single_compile` and `hh_server`.

We can do this and still provide very large ranges for the values:

* Use 30 bits for the "beginning of line offset", so max file size is 1G
* Use 24 bits for the line number, so max line number is 16M
* Use 9 bits for the column position, so max column position is 511

For the line and column, we can max out rather than wrap round or assert; it simply means that error messages degrade in these cases.

Differential Revision: D7774295

fbshipit-source-id: ca234d516853601b3fcc318b89ac3b58c7e540c7
hphp/hack/src/utils/file_pos.ml
hphp/hack/src/utils/file_pos_64.ml [new file with mode: 0644]