Closed
Bug 1420172
Opened 6 years ago
Closed 6 years ago
Scalar Replacement: Allow writing to MNewArrayCopyOnWrite arrays
Categories
(Core :: JavaScript Engine: JIT, enhancement, P3)
Core
JavaScript Engine: JIT
Tracking
()
RESOLVED
FIXED
mozilla59
Tracking | Status | |
---|---|---|
firefox59 | --- | fixed |
People
(Reporter: evilpie, Assigned: jandem)
References
Details
Attachments
(1 file, 2 obsolete files)
13.79 KB,
patch
|
nbp
:
review+
|
Details | Diff | Splinter Review |
I didn't implement this in bug 1288392, because it seemed to make some things simpler. This might just work now however, or maybe initFromTemplateObject needs to be adjusted.
Updated•6 years ago
|
status-firefox59:
--- → fix-optional
Priority: -- → P3
Assignee | ||
Comment 1•6 years ago
|
||
This implements scalar replacement for stores to COW arrays. We now also support MConvertElementsToDoubles. With these changes the raytracer in bug 1425687 is > 2x faster.
Assignee: nobody → jdemooij
Status: NEW → ASSIGNED
Attachment #8938415 -
Flags: review?(nicolas.b.pierron)
Attachment #8938415 -
Flags: review?(evilpies)
Reporter | ||
Comment 2•6 years ago
|
||
Comment on attachment 8938415 [details] [diff] [review] Patch Review of attachment 8938415 [details] [diff] [review]: ----------------------------------------------------------------- Looks pretty good. Are writes guaranteed to be preceded by CopyElementsOnWrite?
Attachment #8938415 -
Flags: review?(evilpies) → feedback+
Comment 3•6 years ago
|
||
Comment on attachment 8938415 [details] [diff] [review] Patch Review of attachment 8938415 [details] [diff] [review]: ----------------------------------------------------------------- Everything looks good except for the next comment: ::: js/src/jit/ScalarReplacement.cpp @@ +1438,5 @@ > + oom_ = true; > + return; > + } > + > + state_->setCopyElementsForWrite(); This flag should be updated in ArrayMemoryView::mergeIntoSuccessorState, otherwise the following test case might fail: function arrayCopyWrite1(i) { // (block 0) var a = [1, 1]; if (i % 2 == 0) // (block 1) a[0] = a[0] + 1; // (block 2) assertEq(a[0], 1); assertEq(a[1], 2); assertRecoveredOnBailout(a, true); resumeHere(); return a.length; } The problem being that block 0, will create block 2, MArrayState without the copy flag. When the mutated data from block 1 is merged into block 2, the function mergeIntoSuccessorState will add the Phi nodes but forget to set the copy flag on block 2 MArrayState. Note, the same applies, if the array mutation is nested in a for-loop: function arrayCopyWrite2(i) { var a = [1, 1]; for (var x = 0; x < 2; x++) { if (x % 2 == 1) resumeHere(); // (MArrayState needs the Copy flag) else a[0] = a[0] + 1; } assertEq(a[0], 1); assertEq(a[1], 2); assertRecoveredOnBailout(a, true); return a.length; } The easiest way, would be to make the Copy flag be a boolean operand of the MArrayState vector which would then be merged as a Phi operand by mergeIntoSuccessorState, which should solve both issues seen above.
Attachment #8938415 -
Flags: review?(nicolas.b.pierron) → feedback+
Assignee | ||
Comment 4•6 years ago
|
||
Good catch! This adds the copyElementsForWrite flag as operand to MArrayState and adds some tests.
Attachment #8938415 -
Attachment is obsolete: true
Attachment #8940191 -
Flags: review?(nicolas.b.pierron)
Assignee | ||
Comment 5•6 years ago
|
||
Another option is to check in RArrayState::recover whether we have an element that's != the COW element and then call maybeCopyElementsForWrite. That way we don't have to track copyElementsForWrite at all. I can do that too..
Flags: needinfo?(nicolas.b.pierron)
Comment 6•6 years ago
|
||
(In reply to Jan de Mooij [:jandem] from comment #5) > Another option is to check in RArrayState::recover whether we have an > element that's != the COW element and then call maybeCopyElementsForWrite. > That way we don't have to track copyElementsForWrite at all. I can do that > too.. I guess this would work, and even do some de-duplication. I think this is even better than keeping track of the copy flag.
Flags: needinfo?(nicolas.b.pierron)
Assignee | ||
Comment 7•6 years ago
|
||
This works and is a much simpler patch.
Attachment #8940191 -
Attachment is obsolete: true
Attachment #8940191 -
Flags: review?(nicolas.b.pierron)
Attachment #8940213 -
Flags: review?(nicolas.b.pierron)
Updated•6 years ago
|
Attachment #8940213 -
Flags: review?(nicolas.b.pierron) → review+
Pushed by jandemooij@gmail.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/ceb61da04fd8 Make scalar replacement of arrays work in more cases (writes to COW elements, double elements). r=nbp
Comment 10•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/ceb61da04fd8
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
You need to log in
before you can comment on or make changes to this bug.
Description
•