Open Bug 1475700 Opened 6 years ago Updated 2 years ago

Consider making WebIDL prototypes lazy

Categories

(Core :: DOM: Bindings (WebIDL), enhancement, P3)

enhancement

Tracking

()

People

(Reporter: kmag, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [overhead:50K])

We might need to only do this for chrome globals, or take separate approaches for chrome globals than we do for content globals.

Essentially, the problem we need to solve is: In content processes, we currently create a lot of WebIDL prototypes that use a lot of memory, but are essentially unused.

A lot of this has to do with the way we create some bindings in system globals, particularly with Cu.importGlobalProperties. Often, we import those properties only for the sake of static isInstance method checks, and wind up reifying dozens of large prototype objects that are never used. Or, for instance, importing "indexedDB", and creating the constructors and prototypes for all of the many interfaces in the API.

The simplest approach that we discussed was just making the prototype property of the constructor lazy. Since that property is defined to be immutable, that would require a resolve hook, and it's unclear whether we'd want to do that in web compartments.

The ideal approach would be to also make all of the prototype properties lazy in chrome compartments, since even when we need the prototypes, many of their properties are never touched. I don't think we can do that in web compartments, for the sake of preserving enumeration order. But if we can do it only in chrome compartments without adding too much complexity to the binding code, that would probably be ideal.
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.