Changes

Jump to: navigation, search

Gecko:Overview

1,069 bytes added, 18:22, 9 May 2019
Add section on reflectors
The '''WebIDL bindings''' are a separate bridge between C++ and JS that is specifically designed for use by DOM code. We intend to replace all uses of XPConnect to interface with content JavaScript with the WebIDL bindings. [https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bindings Extensive documentation] on the WebIDL bindings is available, but the basic idea is that a binding generator takes WebIDL files from web standards and some configuration data provided by us and generates at build time C++ glue code that sits between the JS engine and the DOM object. This setup allows us to produce faster, more specialized code for better performance at the cost of increased codesize.
The WebIDL bindings also implement all of the behavior specified in WebIDL, making it possible for new additions to the DOM to behave correctly "out of the box". The binding layer also provides C++ abstractions for types that would otherwise require direct JSAPI calls to handle, such as typed arrays. === Reflectors ===Whether using [https://wiki.mozilla.org/Gecko:Overview#XPConnect XPConnect] or [https://wiki.mozilla.org/Gecko:Overview#WebIDL_Bindings Web IDL], the basic idea is that there is a JSObject called a '''reflector''' that represents some C++ object. The JSObject ensures that the C++ object remains alive while the JSObject is alive. The C++ object does ''not'' necessarily keep the JSObject alive; this allows the JSObject to be garbage-collected as needed. If this happens, the next time JS needs access to that C++ object a new reflector is created. If something happens that requires that the actual object identity of the JSObject be preserved even though it's not explicitly reachable, the C++ object will start keeping the JSObject alive as well. After this point, the cycle collector would be the only way for the pair of objects to be deallocated. Examples of operations that require identity-preservation are adding a property to the object, giving the object a non-default prototype, using the object as a weakmap key or weakset member.
=== Security ===
308
edits

Navigation menu