module

bun:jsc

The 'bun:jsc' module is APIs for interacting with JavaScriptCore, the JavaScript engine that powers Bun. These APIs are mostly for advanced use cases, and are not needed for most applications.

Functions 28

  • callerSourceOrigin()

    Returns the URL of the source file containing the code that called this function, such as "file:///home/me/app/index.ts".

  • deserialize()

    Converts an ArrayBuffer or Buffer to a JavaScript value compatible with the HTML Structured Clone Algorithm.

  • drainMicrotasks()

    Runs every pending microtask right now: promise reactions,

  • edenGC()

    Runs an eden (young generation) garbage collection synchronously.

  • estimateShallowMemoryUsageOf()

    Non-recursively estimates the memory usage of an object, excluding the memory usage of properties or other objects it references.

  • fullGC()

    Runs a full garbage collection synchronously: every object in the heap is visited, and everything unreachable becomes garbage.

  • gcAndSweep()

    Runs a full garbage collection and then sweeps the heap, all synchronously, so the memory of every unreachable object has been freed by the time this returns.

  • getProtectedObjects()

    Returns objects that native code has explicitly protected from being garbage collected.

  • getRandomSeed()

    Returns the seed of the pseudo-random number generator behind

  • heapSize()

    Returns the size of the JavaScript heap in bytes: the objects that survived the most recent garbage collection, plus the memory they own outside the heap (string conte…

  • heapStats()

    Returns statistics about the JavaScript heap, including a count of the live objects of each type.

  • isRope()

    Returns whether a string is currently stored as a "rope".

  • jscDescribe()

    Returns JavaScriptCore's debug description of a value: how the value is represented (Int32, Double, String, Object, and so on) and, for values on the heap, its…

  • jscDescribeArray()

    Describes the storage behind an object's indexed elements: the address of its "butterfly" (the out-of-line buffer JavaScriptCore keeps elements in), the public `length…

  • memoryUsage()

    Returns memory statistics for the whole Bun process: resident set size, committed memory, and page faults.

  • noFTL()

    Prevents a function from ever being compiled by the FTL JIT,

  • noOSRExitFuzzing()

    Excludes a function from OSR exit fuzzing.

  • numberOfDFGCompiles()

    Returns how many times a function has been optimized: 1 if the function currently has DFG- or FTL-compiled code, plus one for each time its optimized code has been t…

  • optimizeNextInvocation()

    Makes JavaScriptCore start optimizing a function (compiling it with the

  • profile()

    Runs JavaScriptCore's sampling profiler on a function and returns the profile.

  • releaseWeakRefs()

    Releases the targets of WeakRefs so that a garbage collection can collect them immediately.

  • reoptimizationRetryCount()

    Returns how many times JavaScriptCore has thrown away a function's optimized code because the assumptions it was compiled with turned out to be wrong (for example, a f…

  • serialize()

    Serializes a JavaScript value into a binary representation that can be sent to another Bun instance.

  • setRandomSeed()

    Reseeds the pseudo-random number generator behind Math.random(), making the values it returns reproducible: after setting the same seed,

  • setTimeZone()

    Sets the time zone used by Intl, Date, and other date and time APIs.

  • startRemoteDebugger()

    Starts a remote debugging socket server on the given port.

  • startSamplingProfiler()

    Starts JavaScriptCore's sampling profiler and leaves it running for the rest of the process.

  • totalCompileTime()

    Returns the total time in milliseconds this process has spent

Interfaces 5