• Philip Chimento's avatar
    js: Workaround for function with custom prototype · 72c0298c
    Philip Chimento authored
    It's not possible in JS to directly create a function object with a
    custom prototype. We previously got around this by directly altering the
    prototype by setting the __proto__ property, but SpiderMonkey now
    conspicuously warns that this will make your code slow.
    It would be possible to do this with ES6 Proxy objects, although
    SpiderMonkey 31 doesn't support the particular getPrototypeOf() proxy
    trap that we would need in order to implement this correctly --- at
    least not in JS. Therefore we implement the proxy in C++.
    We add a debug topic for proxies and a memory counter.
    All in all, the proxy is probably still slower than a function object
    with a real prototype would be, but hopefully faster than direct
    alteration of the prototype. At the very least we can avoid printing a
    big warning every time our class framework is used.
Makefile.am 6.79 KB