[Webkit-unassigned] [Bug 56168] Avoid slow-path for put() in Array.slice()

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Mar 12 21:29:24 PST 2011


https://bugs.webkit.org/show_bug.cgi?id=56168





--- Comment #5 from Oliver Hunt <oliver at apple.com>  2011-03-12 21:29:24 PST ---
> > Source/JavaScriptCore/runtime/ArrayPrototype.cpp:489
> > +    for (unsigned k = 0; k < sliceCount; k++)
> > +        resObj->uncheckedSetIndex(globalData, k, getProperty(exec, thisObj, k + begin));
> 
> Shouldn’t we also stop on the first exception we see?

Yes.  And apparently a test for this as well.
var proto =  { get 0() { throw "argh" }, get 1() { fail("called second getter") }, length: 2} 
Array.prototype.slice.call(proto, ...)
Array.prototype.slice.call(Object.create(proto), ...)
var array = [];
array.__proto__ = proto;
array.length = 2;
Array.prototype.slice.call(array, ...)

(In reply to comment #4)
> There is probably a great way to do this, but I think we’ll have to have different code for the rare case where there is a hole in the passed-in array. Or perhaps I missed something.

Then general implementation for all of the array functions is sadly unpleasant.  You query the length and then iterate through as long as you can do canGet(i) (or whatever the function is called, i can't remember off the top of my head).   And then you continue with a generic get() until you reach the length.

We do need a nicer way of doing this, but as yet we haven't come up with one.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list