https://codereview.chromium.org/1235153006/diff/20001/src/parser.cc
File src/parser.cc (right):
https://codereview.chromium.org/1235153006/diff/20001/src/parser.cc#newcode4333
src/parser.cc:4333: // let <rest_params> = [];
On 2015/07/15 18:57:39, Toon Verwaest wrote:
On 2015/07/15 11:32:11, Michael Starzinger wrote:
> Just throwing this out there, not saying we should do this (now):
>
> Would it be a valid desugaring to pre-allocate the array to the
correct length
> and then use ordinary [[Put]] operations to populate it? Or am I
missing some
> JavaScript magic that makes this observable? Basically have
something like the
> following:
>
> let <rest_length> = %_ArgumentsLength() - <rest_index>;
> let <rest_params> = new $PremordialArray(<rest_length>);
> for (int i = 0; i < <rest_length>; ++i) {
> <rest_params>[i] = %_Arguments(i + <rest_index>);
> }
>
> Again, not intended to be actionable feedback right now, just a
question.
When you preallocate an array of a specific length you just have a
holey array.
Any regular assignment will possibly trigger accessors up the
prototype chain
(of Array.prototype and its prototype chain, normally
Object.prototype); or fail
because there's a read-only element. %AddElement OTOH is a subset of
DefineProperty, which ignores the prototype chain.
Yes, you are right. I should have been more explicit in my pseudo-code.
Consider the following ...
let <rest_length> = %_ArgumentsLength() - <rest_index>;
let <rest_params> =
%_NewPrimordialArrayFilledWithUndefined(<rest_length>);
for (int i = 0; i < <rest_length>; ++i) {
<rest_params>[i] = %_Arguments(i + <rest_index>);
}
https://codereview.chromium.org/1235153006/
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.