Closed Bug 1449541 Opened 2 years ago Closed 2 years ago

Reduce the lock scope when sharing script data

Categories

(Core :: JavaScript: GC, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox61 --- fixed

People

(Reporter: jonco, Assigned: jonco)

Details

Attachments

(1 file)

JSScript::shareScriptData() currently holds a lock while it calculates the script data hash and while it frees the script data if that happens.  It's only necessary to hold the lock while accessing the shared script data table.
Patch to add a ScriptBytecodeHasher::Lookup class which calculates the hash in its constructor and holds the script data alive with a reference count until its destructor, so that these happen outside the lock scope.
Attachment #8963088 - Flags: review?(jdemooij)
Comment on attachment 8963088 [details] [diff] [review]
bug1449541-reduce-script-lock-scope

Review of attachment 8963088 [details] [diff] [review]:
-----------------------------------------------------------------

Great!

::: js/src/vm/JSScript.h
@@ +862,5 @@
> +        SharedScriptData* scriptData;
> +        HashNumber hash;
> +
> +      public:
> +        Lookup(SharedScriptData* data);

Nit: explicit
Attachment #8963088 - Flags: review?(jdemooij) → review+
Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/4be93a2b5a92
Don't hold script data lock while calcuating hash r=jandem
Priority: -- → P3
https://hg.mozilla.org/mozilla-central/rev/4be93a2b5a92
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
You need to log in before you can comment on or make changes to this bug.