mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 13:22:07 +00:00
small fixes
This commit is contained in:
@@ -142,7 +142,7 @@ const { values: options, positionals: filters } = parseArgs({
|
||||
},
|
||||
["retries"]: {
|
||||
type: "string",
|
||||
default: isCI ? "1" : "0", // N retries = N+1 attempts
|
||||
default: isCI ? "0" : "0", // N retries = N+1 attempts
|
||||
},
|
||||
["junit"]: {
|
||||
type: "boolean",
|
||||
|
||||
@@ -70,13 +70,7 @@ export fn OPENSSL_memory_free(ptr: *anyopaque) void {
|
||||
}
|
||||
|
||||
export fn OPENSSL_memory_get_size(ptr: ?*const anyopaque) usize {
|
||||
if (!bun.use_mimalloc) return switch (bun.Environment.os) {
|
||||
.mac => std.c.malloc_size(ptr),
|
||||
.linux => std.c.malloc_usable_size(ptr),
|
||||
.windows => std.c._msize(@constCast(ptr)), // https://github.com/ziglang/zig/pull/24725
|
||||
.wasm => @compileError("unreachable"),
|
||||
};
|
||||
return bun.mimalloc.mi_usable_size(ptr);
|
||||
return bun.default_malloc_usable_size(ptr);
|
||||
}
|
||||
|
||||
const INET6_ADDRSTRLEN = if (bun.Environment.isWindows) 65 else 46;
|
||||
|
||||
@@ -282,7 +282,7 @@ pub fn ResolveInfoRequest(comptime cares_type: type, comptime type_name: []const
|
||||
globalThis: *jsc.JSGlobalObject,
|
||||
comptime cache_field: []const u8,
|
||||
) !*@This() {
|
||||
var request = try globalThis.allocator().create(@This());
|
||||
var request = try bun.default_allocator.create(@This());
|
||||
var hasher = std.hash.Wyhash.init(0);
|
||||
hasher.update(name);
|
||||
const hash = hasher.final();
|
||||
@@ -388,7 +388,7 @@ pub const GetHostByAddrInfoRequest = struct {
|
||||
globalThis: *jsc.JSGlobalObject,
|
||||
comptime cache_field: []const u8,
|
||||
) !*@This() {
|
||||
var request = try globalThis.allocator().create(@This());
|
||||
var request = try bun.default_allocator.create(@This());
|
||||
var hasher = std.hash.Wyhash.init(0);
|
||||
hasher.update(name);
|
||||
const hash = hasher.final();
|
||||
@@ -549,7 +549,7 @@ pub const GetNameInfoRequest = struct {
|
||||
globalThis: *jsc.JSGlobalObject,
|
||||
comptime cache_field: []const u8,
|
||||
) !*@This() {
|
||||
var request = try globalThis.allocator().create(@This());
|
||||
var request = try bun.default_allocator.create(@This());
|
||||
var hasher = std.hash.Wyhash.init(0);
|
||||
hasher.update(name);
|
||||
const hash = hasher.final();
|
||||
@@ -645,7 +645,7 @@ pub const GetAddrInfoRequest = struct {
|
||||
comptime cache_field: []const u8,
|
||||
) !*GetAddrInfoRequest {
|
||||
log("init", .{});
|
||||
var request = try globalThis.allocator().create(GetAddrInfoRequest);
|
||||
var request = try bun.default_allocator.create(GetAddrInfoRequest);
|
||||
var poll_ref = Async.KeepAlive.init();
|
||||
poll_ref.ref(globalThis.bunVM());
|
||||
if (resolver) |resolver_| resolver_.ref();
|
||||
|
||||
@@ -440,7 +440,7 @@ pub const MatchedRoute = struct {
|
||||
}
|
||||
if (this.needs_deinit) {
|
||||
if (this.route.pathname.len > 0 and bun.use_mimalloc and bun.mimalloc.mi_is_in_heap_region(this.route.pathname.ptr)) {
|
||||
bun.default_free(@constCast(this.route.pathname.ptr));
|
||||
bun.mimalloc.mi_free(@constCast(this.route.pathname.ptr));
|
||||
}
|
||||
|
||||
this.params_list_holder.deinit(bun.default_allocator);
|
||||
|
||||
@@ -3116,7 +3116,9 @@ JSC::EncodedJSValue ZigString__toExternalU16(const uint16_t* arg0, size_t len, J
|
||||
return JSC::JSValue::encode(JSC::jsEmptyString(global->vm()));
|
||||
}
|
||||
|
||||
#if !ENABLE_MIMALLOC
|
||||
ASSERT(!mi_is_in_heap_region(arg0));
|
||||
#endif
|
||||
auto ref = String(ExternalStringImpl::create({ reinterpret_cast<const char16_t*>(arg0), len }, reinterpret_cast<void*>(const_cast<uint16_t*>(arg0)), free_global_string));
|
||||
return JSC::JSValue::encode(JSC::jsString(global->vm(), WTFMove(ref)));
|
||||
}
|
||||
@@ -3129,8 +3131,10 @@ JSC::EncodedJSValue ZigString__toExternalValue(const ZigString* arg0, JSC::JSGlo
|
||||
return JSC::JSValue::encode(JSC::jsEmptyString(arg1->vm()));
|
||||
}
|
||||
|
||||
#if !ENABLE_MIMALLOC
|
||||
ASSERT(!mi_is_in_heap_region(str.ptr));
|
||||
ASSERT(!mi_is_in_heap_region(Zig::untag(str.ptr)));
|
||||
#endif
|
||||
if (Zig::isTaggedUTF16Ptr(str.ptr)) {
|
||||
auto ref = String(ExternalStringImpl::create({ reinterpret_cast<const char16_t*>(Zig::untag(str.ptr)), str.len }, Zig::untagVoid(str.ptr), free_global_string));
|
||||
return JSC::JSValue::encode(JSC::jsString(arg1->vm(), WTFMove(ref)));
|
||||
|
||||
@@ -84,8 +84,10 @@ static const WTF::String toString(ZigString str)
|
||||
}
|
||||
|
||||
if (isTaggedExternalPtr(str.ptr)) [[unlikely]] {
|
||||
#if !ENABLE_MIMALLOC
|
||||
ASSERT(!mi_is_in_heap_region(str.ptr));
|
||||
ASSERT(!mi_is_in_heap_region(untag(str.ptr)));
|
||||
#endif
|
||||
// This will fail if the string is too long. Let's make it explicit instead of an ASSERT.
|
||||
if (str.len > Bun__stringSyntheticAllocationLimit) [[unlikely]] {
|
||||
free_global_string(nullptr, reinterpret_cast<void*>(const_cast<unsigned char*>(untag(str.ptr))), static_cast<unsigned>(str.len));
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
#define ZIG_EXPORT(...)
|
||||
#define ZIG_NONNULL
|
||||
|
||||
#if ENABLE_ASAN
|
||||
#if ASAN_ENABLED
|
||||
#define ENABLE_MIMALLOC 0
|
||||
#else
|
||||
#define ENABLE_MIMALLOC 1
|
||||
|
||||
@@ -359,7 +359,6 @@ JSC_DECLARE_HOST_FUNCTION(functionCreateMemoryFootprint);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionCreateMemoryFootprint,
|
||||
(JSGlobalObject * globalObject, CallFrame*))
|
||||
{
|
||||
|
||||
size_t elapsed_msecs = 0;
|
||||
size_t user_msecs = 0;
|
||||
size_t system_msecs = 0;
|
||||
@@ -372,6 +371,10 @@ JSC_DEFINE_HOST_FUNCTION(functionCreateMemoryFootprint,
|
||||
#if ENABLE_MIMALLOC
|
||||
mi_process_info(&elapsed_msecs, &user_msecs, &system_msecs, ¤t_rss,
|
||||
&peak_rss, ¤t_commit, &peak_commit, &page_faults);
|
||||
#else
|
||||
(void)elapsed_msecs;
|
||||
(void)user_msecs;
|
||||
(void)system_msecs;
|
||||
#endif
|
||||
|
||||
// mi_process_info produces incorrect rss size on linux.
|
||||
|
||||
@@ -199,9 +199,9 @@ fn decodeSlice(this: *TextDecoder, globalThis: *jsc.JSGlobalObject, buffer_slice
|
||||
// It's unintuitive that we encode Latin1 as UTF16 even though the engine natively supports Latin1 strings...
|
||||
// However, this is also what WebKit seems to do.
|
||||
//
|
||||
// It's not clear why we couldn't jusst use Latin1 here, but tests failures proved it necessary.
|
||||
// It's not clear why we couldn't just use Latin1 here, but tests failures proved it necessary.
|
||||
const out_length = strings.elementLengthLatin1IntoUTF16([]const u8, buffer_slice);
|
||||
const bytes = try globalThis.allocator().alloc(u16, out_length);
|
||||
const bytes = try bun.default_allocator.alloc(u16, out_length);
|
||||
|
||||
const out = strings.copyLatin1IntoUTF16([]u16, bytes, []const u8, buffer_slice);
|
||||
return ZigString.toExternalU16(bytes.ptr, out.written, globalThis);
|
||||
|
||||
Reference in New Issue
Block a user