gecko-dev/js
Jason Orendorff adc7298478 Bug 1445854 - Part 1: Make GenericCreatePrototype use protoClass_. r=jwalden
Originally, long ago, the builtin prototype object of a class was always an
actual instance of that class. For many of the oldest classes, this is still
true. Array.isArray(Array.prototype) is true; Function.prototype is callable;
and so on.

As it turns out, this is a bad idea. Prototypes are a lot like uninitialized
objects; thus it was a common bug to have code like

    if (!obj->is<WidgetObject>()) {  // safety check
        return ThrowTypeError(cx, ...);
    }
    obj->as<WidgetObject>().getWidgetPrivateData()->doThings();  // BUG

This would crash when obj happened to be Widget.prototype, because that would
sneak past the safety check, and then `getWidgetPrivateData()` would typically
return null. Extra checks everywhere. The solution is for each builtin class to
have a class_ (for instances) and a protoClass_ (for the prototype object) that
share a single ClassSpec (for the benefit of the X-ray wrapper machinery).

(This problem was a pain for the spec, too. The standard committee has stopped
making prototype objects special in this way. The newer ones are just plain
objects with no internal slots, and where possible, old stuff like
Date.prototype was retroactively changed.)

GenericCreatePrototype never got the memo. This patch fixes it.

Differential Revision: https://phabricator.services.mozilla.com/D7666

--HG--
extra : moz-landing-system : lando
2018-10-06 12:22:35 +00:00
..
ductwork/debugger Bug 1489147 - Remove the XPCOM component registration for nsXPConnect; r=mccr8 2018-09-06 16:39:35 -04:00
examples
ipc Bug 1490632 - Always use braces for if/for/while statements in js/ipc. r=evilpie 2018-09-12 20:04:14 +00:00
public Bug 1496623 - Rename and comment GeckoProfilerThread::installed() r=njn 2018-10-05 10:52:43 +10:00
rust Bug 1491137 - Rename JS::CompileFunction that takes const char*/size_t for function text to JS::CompileFunctionUtf8 that asserts consistent |options.utf8|. r=jandem 2018-09-17 11:24:41 -07:00
src Bug 1445854 - Part 1: Make GenericCreatePrototype use protoClass_. r=jwalden 2018-10-06 12:22:35 +00:00
xpconnect Merge inbound to mozilla-central. a=merge 2018-10-05 01:29:38 +03:00
app.mozbuild
ffi.configure
moz.build
moz.configure Bug 1490948: Compile Cranelift on Nightlies except for Win32 static analysis builds; r=chmanchester 2018-09-25 19:05:08 +02:00