Lower @returnAddress to a constant 0 in Emscripten release builds
Emscripten currently implements `emscripten_return_address()` by calling out into JavaScript and parsing a stack trace, which introduces significant overhead that we would prefer to avoid in release builds. This is especially problematic for allocators because the generic parts of `std.mem.Allocator` make frequent use of `@returnAddress`, even though very few allocator implementations even observe the return address, which makes allocators nigh unusable for performance-critical applications like games if the compiler is unable to devirtualize the allocator calls.
This commit is contained in:
committed by
Andrew Kelley
parent
9f235a105b
commit
f45f9649e3
@@ -9525,7 +9525,7 @@ pub const FuncGen = struct {
|
||||
_ = inst;
|
||||
const o = self.ng.object;
|
||||
const llvm_usize = try o.lowerType(Type.usize);
|
||||
if (!target_util.supportsReturnAddress(o.pt.zcu.getTarget())) {
|
||||
if (!target_util.supportsReturnAddress(o.pt.zcu.getTarget(), self.ng.ownerModule().optimize_mode)) {
|
||||
// https://github.com/ziglang/zig/issues/11946
|
||||
return o.builder.intValue(llvm_usize, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user