disable runtime safety in std.io.InStream

Let's not be writing 0xaa in safe modes for upwards of 4 MiB for every
stream read. This is equivalent to the fact that we don't memset the
entire call stack to 0xaa for every function call.
This commit is contained in:
Andrew Kelley 2019-09-11 15:01:21 -04:00
parent c9b2210fcf
commit 67491a4222
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9

View File

@ -32,10 +32,10 @@ pub fn InStream(comptime ReadError: type) type {
/// End of stream is not an error condition.
pub fn read(self: *Self, buffer: []u8) Error!usize {
if (std.io.is_async) {
// Let's not be writing 0xaa in safe modes for upwards of 4 MiB for every stream read.
@setRuntimeSafety(false);
var stack_frame: [stack_size]u8 align(stack_align) = undefined;
// TODO https://github.com/ziglang/zig/issues/3068
var result: Error!usize = undefined;
return await @asyncCall(&stack_frame, &result, self.readFn, self, buffer);
return await @asyncCall(&stack_frame, {}, self.readFn, self, buffer);
} else {
return self.readFn(self, buffer);
}