diff options
author | 2022-07-12 22:56:09 -0700 | |
---|---|---|
committer | 2022-07-12 22:56:09 -0700 | |
commit | b37ffde4ed6852749545607fe7521449b52ed4ef (patch) | |
tree | 6fa06a22e391c54aefc2ada8a4941ae725a98c41 | |
parent | dd7a346ac83348c22512ba37f041725265015089 (diff) | |
download | bun-b37ffde4ed6852749545607fe7521449b52ed4ef.tar.gz bun-b37ffde4ed6852749545607fe7521449b52ed4ef.tar.zst bun-b37ffde4ed6852749545607fe7521449b52ed4ef.zip |
[bun.js] GC more strings
-rw-r--r-- | src/bun.js/bindings/bindings.cpp | 4 | ||||
-rw-r--r-- | src/bun.js/bindings/bindings.zig | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 443edd873..a7b0e5bdc 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -1261,11 +1261,11 @@ JSC__JSValue ZigString__external(const ZigString* arg0, JSC__JSGlobalObject* arg ZigString str = *arg0; if (Zig::isTaggedUTF16Ptr(str.ptr)) { - return JSC::JSValue::encode(JSC::JSValue(JSC::jsOwnedString( + return JSC::JSValue::encode(JSC::JSValue(JSC::jsString( arg1->vm(), WTF::String(ExternalStringImpl::create(reinterpret_cast<const UChar*>(Zig::untag(str.ptr)), str.len, arg2, ArgFn3))))); } else { - return JSC::JSValue::encode(JSC::JSValue(JSC::jsOwnedString( + return JSC::JSValue::encode(JSC::JSValue(JSC::jsString( arg1->vm(), WTF::String(ExternalStringImpl::create(reinterpret_cast<const LChar*>(Zig::untag(str.ptr)), str.len, arg2, ArgFn3))))); } diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 89d9ad3a5..7fd20081e 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -2247,7 +2247,7 @@ pub const JSValue = enum(JSValueReprInt) { return JSC.C.JSObjectCallAsFunctionReturnValue( globalThis.ref(), this.asObjectRef(), - thisValue.asObjectRef(), + @ptrCast(JSC.C.JSValueRef, thisValue.asNullableVoid()), args.len, @ptrCast([*]const JSC.C.JSValueRef, args.ptr), ); @@ -2905,13 +2905,17 @@ pub const JSValue = enum(JSValueReprInt) { std.mem.doNotOptimizeAway(@ptrCast(C_API.JSObjectRef, this.asVoid())); } + pub inline fn asNullableVoid(this: JSValue) ?*anyopaque { + return @intToPtr(?*anyopaque, @bitCast(usize, @enumToInt(this))); + } + pub inline fn asVoid(this: JSValue) *anyopaque { if (comptime bun.Environment.allow_assert) { if (@enumToInt(this) == 0) { @panic("JSValue is null"); } } - return @intToPtr(*anyopaque, @bitCast(usize, @enumToInt(this))); + return this.asNullableVoid().?; } pub const Extern = [_][]const u8{ "createUninitializedUint8Array", "fromInt64NoTruncate", "fromUInt64NoTruncate", "toUInt64NoTruncate", "asPromise", "toInt64", "_then", "put", "makeWithNameAndPrototype", "parseJSON", "symbolKeyFor", "symbolFor", "getSymbolDescription", "createInternalPromise", "asInternalPromise", "asArrayBuffer_", "fromEntries", "createTypeError", "createRangeError", "createObject2", "getIfPropertyExistsImpl", "jsType", "jsonStringify", "kind_", "isTerminationException", "isSameValue", "getLengthOfArray", "toZigString", "createStringArray", "createEmptyObject", "putRecord", "asPromise", "isClass", "getNameProperty", "getClassName", "getErrorsProperty", "toInt32", "toBoolean", "isInt32", "isIterable", "forEach", "isAggregateError", "toZigException", "isException", "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "getIfExists", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt64", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKey", "toPropertyKeyValue", "toObject", "toString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell", "isCallable" }; |