News for hackers. Stuff that matters.
Re:Why the New V8 Is So Damn Fast by thlorenz on Monday July 30, 2018 @06:55PM (#17648946)
I agree that this is unexpected for most of us, but if you read this section in my v8-perf repo (https://github.com/thlorenz/v8-perf/blob/master/data-types.m...) you'll understand better why that is.

However it doesn't necessarily cause a large slowdown, just makes your function polymorphic and the resulting optimized code larger and a bit slower.

To avoid this entirely I recommend using a JavaScript `class` when passing objects to a function that has to run at peak speed.

Re:Why the New V8 Is So Damn Fast by pygy_ on Tuesday July 31, 2018 @03:25AM (#17651207)
A factory function will also give the objects it returns the same hidden class, resulting in monomorphic code that can be optimized.

    function vec3 (x, y, z) { return {x, y, z} }
Re:Why the New V8 Is So Damn Fast by axilmar on Tuesday July 31, 2018 @05:06AM (#17651630)
Why does it have to be that the order of members matters? shouldn't both {x,y,z} and {z,x,y} compile down to {x,y,z}?
Re:Why the New V8 Is So Damn Fast by fpoling on Tuesday July 31, 2018 @06:58AM (#17652102)
In JS for-in loop enumerates keys in the insert order. So {x,y,z} is different from {z,x,y}
Re:Why the New V8 Is So Damn Fast by mort96 on Tuesday July 31, 2018 @08:21AM (#17652554)
AFAIK, that's not true; the spec doesn't guarantee that it iterates in insertion order, it's just how it's commonly implemented in browsers.
Re:Why the New V8 Is So Damn Fast by topaxi on Tuesday July 31, 2018 @10:23AM (#17653358)
Nope, they should be iterated in their defined order: https://tc39.github.io/ecma262/#sec-ordinaryownpropertykeys

I think they added this with ES2015.