On 2014-07-17, 4:35 AM, Jan de Mooij wrote:
On Thu, Jul 17, 2014 at 8:34 AM, Nicholas Nethercote
<[email protected]> wrote:
Oh wait. It depends on the value of |length|. If it's 2050 or less,
then the right-sized array is allocated immediately. Otherwise, it
allocates 10 elements and then does the doubling thing. I guess
there's a limit to how much we'll pre-allocate.
ArrayObject::EagerAllocationMaxLength (currently 2048) determines when
|new Array(length)| will eagerly allocate. Maybe if it's > 2048 we
could allocate a bit more than 10 elements..

On Thu, Jul 17, 2014 at 8:40 AM, Nicholas Nethercote
<[email protected]> wrote:
On a related note: ObjectElements::VALUES_PER_HEADER is 2. Is this
because 2 * sizeof(HeapSlot) is 16 bytes, which is equal to
sizeof(ObjectElements)?
Yes that's correct.

Jan
_______________________________________________
dev-tech-js-engine-internals mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals
This certainly seems like something that Ion can help out with in common cases. Pattern matching these loops should be pretty straightforward.

If we pattern match the SSA graph for loop bodies which contain the following instruction:

SetElement(ArrayObject, Phi*(Constant(0), Add(Phi*, ConstantInt32(1))), SomeValue), and the loop exit is guarded on Phi* < Constant(N), then ion can hint that the array allocation should be eager.

If some developer cleverly writes code to trick us into allocating an eager array when really they're going to fill it sparsely, well good for them ;)

Kannan
_______________________________________________
dev-tech-js-engine-internals mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to