diff options
author | 2022-07-04 08:04:31 -0700 | |
---|---|---|
committer | 2022-07-04 08:04:31 -0700 | |
commit | 14846710c5f55f7ad4bfd0fcaa3c1878ea22f10d (patch) | |
tree | 6adf15d203326dbd3bcb3d9252e054462a322c65 /src | |
parent | 2ba3a6fbbcce3402884ccb6d3e93523782234b79 (diff) | |
download | bun-14846710c5f55f7ad4bfd0fcaa3c1878ea22f10d.tar.gz bun-14846710c5f55f7ad4bfd0fcaa3c1878ea22f10d.tar.zst bun-14846710c5f55f7ad4bfd0fcaa3c1878ea22f10d.zip |
Make log_protection dev_only
Diffstat (limited to 'src')
-rw-r--r-- | src/bun.js/javascript_core_c_api.zig | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/bun.js/javascript_core_c_api.zig b/src/bun.js/javascript_core_c_api.zig index aa9af2b7e..82145defc 100644 --- a/src/bun.js/javascript_core_c_api.zig +++ b/src/bun.js/javascript_core_c_api.zig @@ -102,15 +102,31 @@ pub extern fn JSValueToNumber(ctx: JSContextRef, value: JSValueRef, exception: E pub extern fn JSValueToStringCopy(ctx: JSContextRef, value: JSValueRef, exception: ExceptionRef) JSStringRef; pub extern fn JSValueToObject(ctx: JSContextRef, value: JSValueRef, exception: ExceptionRef) JSObjectRef; +const log_protection = @import("../global.zig").Environment.allow_assert; +pub inline fn JSValueUnprotect(ctx: JSContextRef, value: JSValueRef) void { + const Wrapped = struct { + pub extern fn JSValueUnprotect(ctx: JSContextRef, value: JSValueRef) void; + }; + if (comptime log_protection) { + const Output = @import("../global.zig").Output; + Output.debug("[unprotect] {d}\n", .{@ptrToInt(value)}); + } + // wrapper exists to make it easier to set a breakpoint + Wrapped.JSValueUnprotect(ctx, value); +} + pub inline fn JSValueProtect(ctx: JSContextRef, value: JSValueRef) void { const Wrapped = struct { pub extern fn JSValueProtect(ctx: JSContextRef, value: JSValueRef) void; }; + if (comptime log_protection) { + const Output = @import("../global.zig").Output; + Output.debug("[protect] {d}\n", .{@ptrToInt(value)}); + } // wrapper exists to make it easier to set a breakpoint Wrapped.JSValueProtect(ctx, value); } -pub extern fn JSValueUnprotect(ctx: JSContextRef, value: JSValueRef) void; pub const JSPropertyAttributes = enum(c_uint) { kJSPropertyAttributeNone = 0, kJSPropertyAttributeReadOnly = 2, |