• Gabriel Ivăncescu's avatar
    jscript: Create the source function's 'prototype' prop object on demand. · 27ceb62e
    Gabriel Ivăncescu authored
    The 'prototype' prop of a source function is, by default, an empty object with
    a 'constructor' prop pointing back to the function. Currently, every source
    function is created in this fashion, which makes it a circular reference
    and thus prevents it from being freed until the Garbage Collector kicks in.
    
    The performance impact comes from the function keeping a ref to the
    enclosing scope, and since the scope is being held by it, the engine will
    detach the scope, believing it to be used for the time being (until the
    GC cleans it). This can cause substantial performance issues for such a
    common case. The FFXIV Launcher, for example, leaks a large amount of such
    short-lived functions and the enclosing scopes.
    Signed-off-by: 's avatarGabriel Ivăncescu <gabrielopcode@gmail.com>
    27ceb62e
function.c 34.6 KB