Extend cp for more than 255 modules - #2351
Conversation
a818398 to
23adbb9
Compare
23adbb9 to
c685766
Compare
Make the cp a fixed-width 64-bit cp_t that occupies one stack term on 64-bit and two on 32-bit. Signed-off-by: Paul Guyot <pguyot@kallisys.net>
c685766 to
f30581b
Compare
|
AMP: PR Review: widen continuation pointers beyond 256 modulesRecommendation: request changesThe continuation-pointer migration itself is internally consistent across the interpreter, stack storage, stacktrace scanning, and the reviewed 32-bit JIT backends. However, exception handlers still encode their module identity with the old 8-bit module-index layout. As a result, the stated support for more than 256 modules remains incomplete and can dispatch an exception to the wrong module. Oracle was consulted to stress-test the review, with emphasis on stack layout, GC traversal, exception flow, 32-bit alignment, and JIT ABI offsets. Finding 1 — High: catch labels still truncate module indexes above 255Affected code:
return (term) ((module_index << 24) | (label << 6) | TERM_IMMED2_CATCH);On a 32-bit build, only eight module-index bits fit above bit 23. The generic JIT emits the same Trigger: load at least 256 modules, then execute a Impact: The new Required fix: redesign catch-label module resolution for 32-bit terms rather than widening only continuation pointers. A practical approach is to store only the catch label in the catch term and derive its module while scanning frames:
A cast before the shift would repair only the 64-bit C path and is not a complete fix: - return (term) ((module_index << 24) | (label << 6) | TERM_IMMED2_CATCH);
+ return ((term) module_index << 24) | ((term) label << 6) | TERM_IMMED2_CATCH;The 32-bit representation still has no room for more than eight module-index bits, so this partial diff should not be merged on its own. Suggestion 1 — ARMv6-M
|
Continuation of:
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later