-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
wasm - fix debug info & misc #96
Commits on Jan 3, 2024
-
wasm: deduplicate aliased function symbols
When one or more symbols point to the same function (and body), we would previously write the same function body multiple times. Now we instead deduplicate them and point all aliased symbols to the same atom to ensure we emit a function and its body just once.
Configuration menu - View commit details
-
Copy full SHA for e0ac0f9 - Browse repository at this point
Copy the full SHA e0ac0f9View commit details -
wasm: fix atom allocation and remove firstAtom
Rather than expensively iterating to te first atom to then iterate over all the atoms back to the end, we now simply start from the end and allocate the last atom as the first atom onwards. This simplifies the logic and we do not have to iterate atoms twice.
Configuration menu - View commit details
-
Copy full SHA for 6c8b515 - Browse repository at this point
Copy the full SHA 6c8b515View commit details -
wasm: ensure debug sections are parsed and emit
Previously we would only mark debug sections if they contained relocations that targeted a marked symbol. However, no debug sections would get parsed as they wouldn't be represented by exported symbols and therefore not get marked and parsed themselves. Now, we create synthetic symbols for all debug sections and ensure custom sections always get marked alive to ensure we emit them correctly.
Configuration menu - View commit details
-
Copy full SHA for f8b4e1d - Browse repository at this point
Copy the full SHA f8b4e1dView commit details -
wasm: sort code section pre-allocation
The code -and function sections must match in order within the binary. Previously we would order the code section before writing them to disk. However, this meant they were already allocated and the offsets were based on the previous order. This meant that debug info was incorrect. We now order the atoms before allocation, and ensure synthetic functions are created after allocation, but appended correctly to the code section to ensure they are emit last, and therefore have correct offsets.
Configuration menu - View commit details
-
Copy full SHA for 89e697c - Browse repository at this point
Copy the full SHA 89e697cView commit details -
wasm: fix function offset relocations
When calculating the function offset for its relocation we would previously use atom's offset with a fixed additional offset. However, we must include the size of the previous function's body which is LEB128- encoded. This means we cannot use a fixed-size offset to calculate the function body offset within the code section unless we use a fixed-size LEB size, which would increase the binary size. Instead, we simply re- calculate the atom's offset based on the currently written bytes during atom writing as we will not need this offset until we perform relocations for the debug section anyway.
Configuration menu - View commit details
-
Copy full SHA for 0068513 - Browse repository at this point
Copy the full SHA 0068513View commit details -
wasm: order and allocate code atoms on write
Rather than ordering the atoms of the code section earlier, we simply skip it until we write the actual code section. This is possible because we don't need the know the offset of each atom until we perform the relocations of the debug sections, which we already delay to writing of those sections. Debug sections *must* always come after the module, including the code section. Therefore this is fine to relay on. We now do a lot less work and make the codebase simpler as well. This also allows us to remove the `next` field on atoms, reducing the memory usage every so slightly.
Configuration menu - View commit details
-
Copy full SHA for 5d536e6 - Browse repository at this point
Copy the full SHA 5d536e6View commit details