New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pointer alignment hack setting #209
Comments
|
Hm. |
|
It's very hard. But it'd be pretty nice to have. |
Point 2 rules this out for technical reasons, and point 3 rules it out for effort and maintenance reasons. |
|
Can you explain point 2? |
|
Not considering continuation frames, the metadata for a call frame contains three things:
This metadata has to fit into a number of TValues; when LJ_FR2=0, it fits into one TValue, and when LJ_FR2=1, it fits into two TValues. Fitting it into one TValue is a squeeze: at first sight, a TValue is 64 bits, and items 1 and 3i are both 32 bits, leaving no space for item 2. Space for item 2 is found by exploiting alignment of item 3: item 3i is 4-byte aligned, and item 3ii is a multiple of 8. This leaves two or three bits to re-purpose, which is precisely enough to fit item 2. |
|
So why's that encoded in the bytecode? |
|
Because the bytecode constructs the frame: when FR2=0, In this case, as part of the function call, When FR2=1, In this case, as part of the function call, |
|
Well can you add another IR that optimizes for the specific system it's running on and cannot be turned off/compiled without? And then redesign the bytecode entirely so it can stay the same between 32-bit mode and 64-bit mode. |
|
Such things would come with a maintenance cost and a performance cost, which nobody is prepared to pay. |
|
Slower code loading is fine by me (because you shouldn't be loading code all the time). Slower first run is also fine by me (because after the first run it'll run like a charm). Incompatibilities are not fine by me because I rely on bytecode compatibility for my thing. |
LuaJIT can be made RAM-hungry by adding a pointer alignment config, like JVMs do. This would allow LuaJIT to use more RAM by tricking the VM into not using lower N bits (e.g. shifting them out) for pointers.
Pointers and offsets are separate so by using e.g. 16-byte alignment you free up 4 bits, letting you use up to 2^35 bytes (32 GB) of RAM instead of 2^31 bytes (2 GB).
Strings and stuff would still be limited to a max size of 2 GB but that's a non-issue I think.
This is one way to maintain bytecode compatibility between 32-bit and 64-bit modes (would be really nice to have bytecode compatibility between them).
The text was updated successfully, but these errors were encountered: