Bug 200192 - [JSC] Make StructureChain less-tricky by using Auxiliary Buffer
Summary: [JSC] Make StructureChain less-tricky by using Auxiliary Buffer
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-07-26 22:17 PDT by Yusuke Suzuki
Modified: 2019-07-30 18:24 PDT (History)
7 users (show)

See Also:


Attachments
Patch (5.93 KB, patch)
2019-07-26 22:20 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (5.92 KB, patch)
2019-07-26 22:21 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (6.12 KB, patch)
2019-07-27 00:31 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (7.97 KB, patch)
2019-07-27 02:33 PDT, Yusuke Suzuki
saam: review+
ews-watchlist: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2019-07-26 22:17:48 PDT
[JSC] Make StructureChain less-tricky by using Auxiliary Buffer
Comment 1 Yusuke Suzuki 2019-07-26 22:20:07 PDT
Created attachment 375015 [details]
Patch
Comment 2 Yusuke Suzuki 2019-07-26 22:21:34 PDT
Created attachment 375016 [details]
Patch
Comment 3 Yusuke Suzuki 2019-07-27 00:31:29 PDT
Created attachment 375019 [details]
Patch
Comment 4 Yusuke Suzuki 2019-07-27 02:33:52 PDT
Created attachment 375024 [details]
Patch
Comment 5 EWS Watchlist 2019-07-27 04:40:07 PDT
Comment on attachment 375024 [details]
Patch

Attachment 375024 [details] did not pass jsc-ews (mac):
Output: https://webkit-queues.webkit.org/results/12821145

New failing tests:
mozilla-tests.yaml/js1_5/Array/regress-101964.js.mozilla-dfg-eager-no-cjit-validate-phases
Comment 6 Saam Barati 2019-07-30 17:27:22 PDT
Comment on attachment 375024 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=375024&action=review

r=me

> Source/JavaScriptCore/runtime/StructureChain.cpp:48
> +    ++size; // Sentinel nullptr.

is it worth just having a size field? (Or we could also be terrible people and encode the size in the auxiliary pointer itself, since the size of a prototype chain is usually low. And if we exceed 16 bits we can OOM.)

> Source/JavaScriptCore/runtime/StructureChain.cpp:49
> +    WriteBarrier<Structure>* vector = static_cast<WriteBarrier<Structure>*>(vm.jsValueGigacageAuxiliarySpace.allocateNonVirtual(vm, (Checked<size_t>(size) * sizeof(WriteBarrier<Structure>)).unsafeGet(), nullptr, AllocationFailureMode::Assert));

What about OOM? Seems easy to just make this an allocation that can fail?
Comment 7 Saam Barati 2019-07-30 17:27:35 PDT
(In reply to Build Bot from comment #5)
> Comment on attachment 375024 [details]
> Patch
> 
> Attachment 375024 [details] did not pass jsc-ews (mac):
> Output: https://webkit-queues.webkit.org/results/12821145
> 
> New failing tests:
> mozilla-tests.yaml/js1_5/Array/regress-101964.js.mozilla-dfg-eager-no-cjit-
> validate-phases

Is this real?
Comment 8 Yusuke Suzuki 2019-07-30 17:50:36 PDT
(In reply to Saam Barati from comment #7)
> (In reply to Build Bot from comment #5)
> > Comment on attachment 375024 [details]
> > Patch
> > 
> > Attachment 375024 [details] did not pass jsc-ews (mac):
> > Output: https://webkit-queues.webkit.org/results/12821145
> > 
> > New failing tests:
> > mozilla-tests.yaml/js1_5/Array/regress-101964.js.mozilla-dfg-eager-no-cjit-
> > validate-phases
> 
> Is this real?

This test is known as flaky these days, and it is not a real issue with this patch.
Comment 9 Yusuke Suzuki 2019-07-30 17:59:09 PDT
Comment on attachment 375024 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=375024&action=review

Thanks!

>> Source/JavaScriptCore/runtime/StructureChain.cpp:48
>> +    ++size; // Sentinel nullptr.
> 
> is it worth just having a size field? (Or we could also be terrible people and encode the size in the auxiliary pointer itself, since the size of a prototype chain is usually low. And if we exceed 16 bits we can OOM.)

The current callers of StructureChain is now assuming that StructureChain allocation never fails. I think just crashing if OOM happens is OK here, as we did by allocating array with makeUniqueArray.
Since caching such a large StructureChain may not be profitable, it would be nice if we can make the caller allocation-failure-aware, and limit the size of StructureChain like <= UINT16_MAX.
I'll note it as FIXME with bugzilla link.

>> Source/JavaScriptCore/runtime/StructureChain.cpp:49
>> +    WriteBarrier<Structure>* vector = static_cast<WriteBarrier<Structure>*>(vm.jsValueGigacageAuxiliarySpace.allocateNonVirtual(vm, (Checked<size_t>(size) * sizeof(WriteBarrier<Structure>)).unsafeGet(), nullptr, AllocationFailureMode::Assert));
> 
> What about OOM? Seems easy to just make this an allocation that can fail?

I added the FIXME about allocation-failure-aware callers.
Comment 10 Yusuke Suzuki 2019-07-30 18:22:24 PDT
Committed r248026: <https://trac.webkit.org/changeset/248026>
Comment 11 Radar WebKit Bug Importer 2019-07-30 18:24:19 PDT
<rdar://problem/53738987>