mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 11:29:02 +00:00
Tags on pointers need to be cleared on Linux
This commit is contained in:
@@ -203,13 +203,11 @@ pub const TransformTask = struct {
|
||||
|
||||
if (printed > 0) {
|
||||
buffer_writer = printer.ctx;
|
||||
buffer_writer.buffer.list.expandToCapacity();
|
||||
buffer_writer.buffer.list.items = buffer_writer.written;
|
||||
|
||||
// This works around a mimalloc and/or Zig allocator bug
|
||||
buffer_writer.buffer.list.items = buffer_writer.buffer.list.items[0..printed];
|
||||
var output_code = JSC.ZigString.init(buffer_writer.buffer.toOwnedSlice());
|
||||
output_code.mark();
|
||||
this.output_code = output_code;
|
||||
this.output_code = JSC.ZigString.init(buffer_writer.written);
|
||||
this.output_code.mark();
|
||||
} else {
|
||||
this.output_code = ZigString.init("");
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ pub const ZigString = extern struct {
|
||||
}
|
||||
|
||||
pub inline fn utf16Slice(this: *const ZigString) []align(1) const u16 {
|
||||
return @ptrCast([*]align(1) const u16, this.ptr)[0..this.len];
|
||||
return @ptrCast([*]align(1) const u16, untagged(this.ptr))[0..this.len];
|
||||
}
|
||||
|
||||
pub fn fromStringPointer(ptr: StringPointer, buf: string, to: *ZigString) void {
|
||||
@@ -163,8 +163,14 @@ pub const ZigString = extern struct {
|
||||
|
||||
pub const Empty = ZigString{ .ptr = "", .len = 0 };
|
||||
|
||||
inline fn untagged(ptr: [*]const u8) [*]const u8 {
|
||||
// this can be null ptr, so long as it's also a 0 length string
|
||||
@setRuntimeSafety(false);
|
||||
return @intToPtr([*]const u8, @truncate(u53, @ptrToInt(ptr)));
|
||||
}
|
||||
|
||||
pub fn slice(this: *const ZigString) []const u8 {
|
||||
return this.ptr[0..@minimum(this.len, std.math.maxInt(u32))];
|
||||
return untagged(this.ptr)[0..@minimum(this.len, std.math.maxInt(u32))];
|
||||
}
|
||||
|
||||
pub fn sliceZBuf(this: ZigString, buf: *[std.fs.MAX_PATH_BYTES]u8) ![:0]const u8 {
|
||||
@@ -172,7 +178,7 @@ pub const ZigString = extern struct {
|
||||
}
|
||||
|
||||
pub inline fn full(this: *const ZigString) []const u8 {
|
||||
return this.ptr[0..this.len];
|
||||
return untagged(this.ptr)[0..this.len];
|
||||
}
|
||||
|
||||
pub fn trimmedSlice(this: *const ZigString) []const u8 {
|
||||
|
||||
@@ -90,19 +90,11 @@ static const WTF::String toString(ZigString str) {
|
||||
}
|
||||
|
||||
static const WTF::String toStringCopy(ZigString str) {
|
||||
if (str.len == 0 || str.ptr == nullptr) { return WTF::String(); }
|
||||
|
||||
return !isTaggedUTF16Ptr(str.ptr) ? WTF::String(WTF::StringImpl::create(str.ptr, str.len))
|
||||
: WTF::String(WTF::StringImpl::create(
|
||||
reinterpret_cast<const UChar *>(str.ptr), str.len));
|
||||
return toString(str).isolatedCopy();
|
||||
}
|
||||
|
||||
static WTF::String toStringNotConst(ZigString str) {
|
||||
if (str.len == 0 || str.ptr == nullptr) { return WTF::String(); }
|
||||
|
||||
return !isTaggedUTF16Ptr(str.ptr) ? WTF::String(WTF::StringImpl::create(str.ptr, str.len))
|
||||
: WTF::String(WTF::StringImpl::create(
|
||||
reinterpret_cast<const UChar *>(str.ptr), str.len));
|
||||
return toString(str).isolatedCopy();
|
||||
}
|
||||
|
||||
static const JSC::JSString *toJSString(ZigString str, JSC::JSGlobalObject *global) {
|
||||
|
||||
Reference in New Issue
Block a user