Closed Bug 1592352 Opened 5 years ago Closed 4 years ago

Preallocate ModuleObject before starting offthread compilation

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: mgaudet, Unassigned)

References

Details

Attachments

(1 obsolete file)

While trying to defer the allocation of Scopes in Bug 1592102, I realized that ModuleScopes currently are created from the pre-existing ModuleObject.

To get to a GC-Free parse and bytecode emission, that will have to change, so following in the footsteps of other deferrals, we'll need to avoid allocating the ModuleObject until the last minute.

Priority: -- → P2

Re-using this bug: a better answer for ModuleObject itself is to instead allocate it in on the main thread before the offthread parse starts.

Summary: Defer GC allocation of ModuleObject until after BytecodeEmission → Preallocate ModuleObject before starting offthread compilation

This patch is currently broken due to unwrapped cross-compartment pointers
being created (and caught by IsObjectValueInCompartment)

../jit-test/jit_test.py ./dist/bin/js modules/bug-1372258.js
Assertion failure: IsObjectValueInCompartment(v, compartment()), at /home/matthew/unified/js/src/vm/NativeObject.h:1002
Exit code: -11
FAIL - modules/bug-1372258.js
Assignee: nobody → mgaudet

So, the above patch is a rough cut, but reveals something a touch unexpected (to me at least): We end up in a situation where we are creating a cross-compartment edge from the main-thread compartment to the parser-realm compartment (I believe) when we attach the parser-realm created script to the main-thread-compartment created ModuleObject.

Does this imply we'll have to rework a bit of this code effectively apply a CCW to the module object when we pass it in (or, wrap the reference to script, and hope that MergeRealms is smart enough to do the right kind of unwrapping?)

Flags: needinfo?(tcampbell)

This is a good question. I think I hand-waved over how the ScriptSourceObject is handled. I'll give it more thought next week and get back to you. I'm slightly concerned about what cross-compartment edges between threads would mean, because that sounds bad.

Blocks: 1614041
Assignee: mgaudet → nobody

This is probably no longer the right approach so let's close this.

Status: NEW → RESOLVED
Closed: 4 years ago
Flags: needinfo?(tcampbell)
Resolution: --- → INCOMPLETE
Attachment #9110960 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: