diff options
| author | 2022-11-19 22:21:35 -0800 | |
|---|---|---|
| committer | 2022-11-19 22:21:35 -0800 | |
| commit | 17fa4211ac8676a04a2dc944f24dddd287c2b1fd (patch) | |
| tree | c7861e771b7645c9759995ecdb79836aee6a931b /src | |
| parent | 81a1d8f5896d7f627ec70f9896afe4b17bc4d189 (diff) | |
| download | bun-17fa4211ac8676a04a2dc944f24dddd287c2b1fd.tar.gz bun-17fa4211ac8676a04a2dc944f24dddd287c2b1fd.tar.zst bun-17fa4211ac8676a04a2dc944f24dddd287c2b1fd.zip | |
Introduce `Bun.unsafe.gcAggressionLevel` API
Diffstat (limited to 'src')
| -rw-r--r-- | src/bun.js/api/bun.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index 131e08b6e..a56d4f79f 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -1990,10 +1990,30 @@ pub const Unsafe = struct { .arrayBufferToString = .{ .rfn = arrayBufferToString, }, + .gcAggressionLevel = .{ + .rfn = JSC.wrapWithHasContainer(Unsafe, "gcAggressionLevel", false, false, false), + }, }, .{}, ); + pub fn gcAggressionLevel( + globalThis: *JSC.JSGlobalObject, + value_: ?JSValue, + ) JSValue { + const ret = JSValue.jsNumber(@as(i32, @enumToInt(globalThis.bunVM().aggressive_garbage_collection))); + + if (value_) |value| { + switch (value.coerce(i32, globalThis)) { + 1 => globalThis.bunVM().aggressive_garbage_collection = .mild, + 2 => globalThis.bunVM().aggressive_garbage_collection = .aggressive, + 0 => globalThis.bunVM().aggressive_garbage_collection = .none, + else => {}, + } + } + return ret; + } + // For testing the segfault handler pub fn __debug__doSegfault( _: void, |
