Speed up Array.shift, and Array.{pop,shift} on empty arrays

RESOLVED FIXED in mozilla10

Status

()

Core
JavaScript Engine
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: bhackett, Assigned: bhackett)

Tracking

(Blocks: 1 bug)

unspecified
mozilla10
x86
Mac OS X
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

6 years ago
Created attachment 565575 [details] [diff] [review]
patch against 15bfad783467

Peacekeeper 2.0's arrayCombine test is broken and does many of its operations on an empty array, with a bunch of pop and shift calls costing the most.  V8 has a fast path for pop() on an empty array, so I don't feel too bad benchmark-gaming this one.

Attached patch allows the pop() inline path to handle empty arrays (only when the call is known to produce undefined), and generalizes this path to also handle shift() (which calls a stub to memmove() in the non-empty case).  This gives a good speedup to non-empty shift() too:

function foo(x) {
  for (var i = 0; i < 10; i++)
    x.push(i);
  for (var i = 0; i < 10000000; i++)
    x.push(x.shift());
}
foo([]);

js -m -n (old): 625
js -m -n (new): 322
js -m -j -p: 805
d8: 592
Attachment #565575 - Flags: review?(dvander)
Blocks: 609835
Brian, I get an error about ‘js::mjit::Assembler::storeValueFromComponents(JSValueType&, JSC::X86Registers::RegisterID, JSC::AbstractMacroAssembler<JSC::X86Assembler>::Address&) not being defined when I build this on top of rev 15bfad783467.  This is in a 64-bit build.  A 32-bit build works fine.
(Assignee)

Comment 2

6 years ago
Created attachment 565591 [details] [diff] [review]
updated

Oops, was missing a coercion that was necessary on x64.
Assignee: general → bhackett1024
Attachment #565575 - Attachment is obsolete: true
Attachment #565575 - Flags: review?(dvander)
Attachment #565591 - Flags: review?(dvander)
Attachment #565591 - Flags: review?(dvander) → review+
(Assignee)

Comment 3

6 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/882404096d65
As an aside, according to https://bugzilla.mozilla.org/show_bug.cgi?id=499198#c32 Peacekeeper doesn't do a bunch of operations on empty arrays any more, in arrayCombined.
https://hg.mozilla.org/mozilla-central/rev/882404096d65
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla10
You need to log in before you can comment on or make changes to this bug.