Repository navigation
wasm32: the interface accessor cell tag is bit 30, so the vtable's relocation fits - #813
Merged
Merged
Conversation
…location fits A field a class fills with accessors has, in an interface's vtable, the address of a cell of accessors plus a tag - the sign bit, which an offset never has. A wasm object keeps a relocation's addend as a signed 32-bit LEB, and an address plus 2^31 is out of its range: wasm-ld (and any reader of the object, llvm-objdump too) stopped with "LEB is outside Varint32 range". On wasm32 the tag is now bit 30: a wasm32 program's static data is at the bottom of its linear memory, far below 1 GB, and no offset into an object reaches 1 GB either. A slot is a cell when the tag bit is set - on every other target the sign bit, as before. 00class_accessor_implements_field, 00interface_field_getter_owned, 00class_accessor_increment and 00class_redeclared_field now run on wasm32. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the "LEB is outside Varint32 range" error that stopped wasm32 programs from linking when a class fills an interface field with accessors.
What went wrong
get/setholds the address of a cell of accessors, plus a tag that marks it as a cell. The tag was the sign bit, which an offset never has.@cell + 0x80000000. A wasm object stores a relocation's addend as a signed 32-bit LEB, and an address plus 2^31 is out of that range.llvm-objdump.The fix
INTERFACE_ACCESSOR_CELL_TAG(sizeBits, isWasm)inDefines.h).LowerToLLVM.cpp,InterfaceAccessorCell). On every other target that's still the sign bit, so it's the same test as before.Tests
00class_accessor_implements_field,00interface_field_getter_owned,00class_accessor_incrementand00class_redeclared_fieldare removed fromwasm_skips.txt. They now run on wasm32, including the--di --opt_level=0builds.🤖 Generated with Claude Code