aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js')
-rw-r--r--src/bun.js/api/bun.zig4
-rw-r--r--src/bun.js/base.zig2
-rw-r--r--src/bun.js/bindings/bindings.zig26
-rw-r--r--src/bun.js/javascript.zig2
-rw-r--r--src/bun.js/webcore/streams.zig2
5 files changed, 19 insertions, 17 deletions
diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig
index b6abde2b0..49143ec5c 100644
--- a/src/bun.js/api/bun.zig
+++ b/src/bun.js/api/bun.zig
@@ -3408,7 +3408,9 @@ pub const EnvironmentVariables = struct {
entry.value_ptr.* = value_str.slice();
} else {
- allocator.free(bun.constStrToU8(entry.value_ptr.*));
+ // this can be a statically allocated string
+ if (bun.isHeapMemory(entry.value_ptr.*))
+ allocator.free(bun.constStrToU8(entry.value_ptr.*));
const cloned_value = value.?.value().toSlice(globalThis, allocator).cloneIfNeeded(allocator) catch return false;
entry.value_ptr.* = cloned_value.slice();
}
diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig
index 3d1233589..663861547 100644
--- a/src/bun.js/base.zig
+++ b/src/bun.js/base.zig
@@ -2481,7 +2481,7 @@ pub const ArrayBuffer = extern struct {
}
// If it's not a mimalloc heap buffer, we're not going to call a deallocator
- if (this.len > 0 and !bun.Global.Mimalloc.mi_is_in_heap_region(this.ptr)) {
+ if (this.len > 0 and !bun.Mimalloc.mi_is_in_heap_region(this.ptr)) {
if (this.typed_array_type == .ArrayBuffer) {
return JSC.JSValue.fromRef(JSC.C.JSObjectMakeArrayBufferWithBytesNoCopy(
ctx,
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig
index 509138cf2..e9e4d5cbf 100644
--- a/src/bun.js/bindings/bindings.zig
+++ b/src/bun.js/bindings/bindings.zig
@@ -541,7 +541,7 @@ pub const ZigString = extern struct {
inline fn assertGlobal(this: *const ZigString) void {
if (comptime bun.Environment.allow_assert) {
- std.debug.assert(bun.Global.Mimalloc.mi_is_in_heap_region(untagged(this.ptr)) or bun.Global.Mimalloc.mi_check_owned(untagged(this.ptr)));
+ std.debug.assert(bun.Mimalloc.mi_is_in_heap_region(untagged(this.ptr)) or bun.Mimalloc.mi_check_owned(untagged(this.ptr)));
}
}
@@ -2889,7 +2889,7 @@ pub const JSValue = enum(JSValueReprInt) {
extern fn JSBuffer__isBuffer(*JSGlobalObject, JSValue) bool;
pub fn isBuffer(value: JSValue, global: *JSGlobalObject) bool {
- if (comptime JSC.is_bindgen) unreachable;
+ JSC.markBinding(@src());
return JSBuffer__isBuffer(global, value);
}
@@ -2938,7 +2938,7 @@ pub const JSValue = enum(JSValueReprInt) {
/// Must come from globally-allocated memory if allocator is not null
pub fn createBuffer(globalObject: *JSGlobalObject, slice: []u8, allocator: ?std.mem.Allocator) JSValue {
- if (comptime JSC.is_bindgen) unreachable;
+ JSC.markBinding(@src());
@setRuntimeSafety(false);
if (allocator) |alloc| {
return JSBuffer__bufferFromPointerAndLengthAndDeinit(globalObject, slice.ptr, slice.len, alloc.ptr, JSC.MarkedArrayBuffer_deallocator);
@@ -2948,12 +2948,12 @@ pub const JSValue = enum(JSValueReprInt) {
}
pub fn createUninitializedUint8Array(globalObject: *JSGlobalObject, len: usize) JSValue {
- if (comptime JSC.is_bindgen) unreachable;
+ JSC.markBinding(@src());
return shim.cppFn("createUninitializedUint8Array", .{ globalObject, len });
}
pub fn createBufferWithCtx(globalObject: *JSGlobalObject, slice: []u8, ptr: ?*anyopaque, func: JSC.C.JSTypedArrayBytesDeallocator) JSValue {
- if (comptime JSC.is_bindgen) unreachable;
+ JSC.markBinding(@src());
@setRuntimeSafety(false);
return JSBuffer__bufferFromPointerAndLengthAndDeinit(globalObject, slice.ptr, slice.len, ptr, func);
}
@@ -4252,7 +4252,7 @@ const private = struct {
};
pub fn NewFunctionPtr(globalObject: *JSGlobalObject, symbolName: ?*const ZigString, argCount: u32, functionPointer: anytype, strong: bool) *anyopaque {
- if (comptime JSC.is_bindgen) unreachable;
+ JSC.markBinding(@src());
return private.Bun__CreateFFIFunction(globalObject, symbolName, argCount, @ptrCast(*const anyopaque, functionPointer), strong);
}
@@ -4263,17 +4263,17 @@ pub fn NewFunction(
functionPointer: anytype,
strong: bool,
) JSValue {
- if (comptime JSC.is_bindgen) unreachable;
+ JSC.markBinding(@src());
return private.Bun__CreateFFIFunctionValue(globalObject, symbolName, argCount, @ptrCast(*const anyopaque, functionPointer), strong);
}
pub fn getFunctionData(function: JSValue) ?*anyopaque {
- if (comptime JSC.is_bindgen) unreachable;
+ JSC.markBinding(@src());
return private.Bun__FFIFunction_getDataPtr(function);
}
pub fn setFunctionData(function: JSValue, value: ?*anyopaque) void {
- if (comptime JSC.is_bindgen) unreachable;
+ JSC.markBinding(@src());
return private.Bun__FFIFunction_setDataPtr(function, value);
}
@@ -4285,7 +4285,7 @@ pub fn NewFunctionWithData(
strong: bool,
data: *anyopaque,
) JSValue {
- if (comptime JSC.is_bindgen) unreachable;
+ JSC.markBinding(@src());
return private.Bun__CreateFFIFunctionWithDataValue(
globalObject,
symbolName,
@@ -4300,7 +4300,7 @@ pub fn untrackFunction(
globalObject: *JSGlobalObject,
value: JSValue,
) bool {
- if (comptime JSC.is_bindgen) unreachable;
+ JSC.markBinding(@src());
return private.Bun__untrackFFIFunction(globalObject, value);
}
@@ -4394,7 +4394,7 @@ pub const WTF = struct {
/// This uses SSE2 instructions and/or ARM NEON to copy 16-bit characters efficiently
/// See wtf/Text/ASCIIFastPath.h for details
pub fn copyLCharsFromUCharSource(destination: [*]u8, comptime Source: type, source: Source) void {
- if (comptime JSC.is_bindgen) unreachable;
+ JSC.markBinding(@src());
// This is any alignment
WTF__copyLCharsFromUCharSource(destination, source.ptr, source.len);
@@ -4403,7 +4403,7 @@ pub const WTF = struct {
/// Encode a byte array to a URL-safe base64 string for use with JS
/// Memory is managed by JavaScriptCore instead of us
pub fn toBase64URLStringValue(bytes: []const u8, globalObject: *JSGlobalObject) JSValue {
- if (comptime JSC.is_bindgen) unreachable;
+ JSC.markBinding(@src());
return WTF__toBase64URLStringValue(bytes.ptr, bytes.len, globalObject);
}
diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig
index 260aca28e..fe559fac8 100644
--- a/src/bun.js/javascript.zig
+++ b/src/bun.js/javascript.zig
@@ -1950,7 +1950,7 @@ pub const EventListenerMixin = struct {
ctx: *CtxType,
comptime onError: fn (ctx: *CtxType, err: anyerror, value: JSValue, request_ctx: *http.RequestContext) anyerror!void,
) !void {
- if (comptime JSC.is_bindgen) unreachable;
+ JSC.markBinding(@src());
var listeners = vm.event_listeners.get(EventType.fetch) orelse (return onError(ctx, error.NoListeners, JSValue.jsUndefined(), request_context) catch {});
if (listeners.items.len == 0) return onError(ctx, error.NoListeners, JSValue.jsUndefined(), request_context) catch {};
diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig
index cac5fbafd..7a20b8562 100644
--- a/src/bun.js/webcore/streams.zig
+++ b/src/bun.js/webcore/streams.zig
@@ -2820,7 +2820,7 @@ pub fn ReadableStreamSource(
}
pub fn load(globalThis: *JSGlobalObject) callconv(.C) JSC.JSValue {
- if (comptime JSC.is_bindgen) unreachable;
+ JSC.markBinding(@src());
// This is used also in Node.js streams
return JSC.JSArray.from(globalThis, &.{
JSC.NewFunction(globalThis, null, 2, JSReadableStreamSource.pull, true),