Closed
Bug 1356315
Opened 7 years ago
Closed 6 years ago
More Object.hasOwnProperty optimizations
Categories
(Core :: JavaScript Engine: JIT, enhancement)
Core
JavaScript Engine: JIT
Tracking
()
RESOLVED
WONTFIX
Performance Impact | none |
People
(Reporter: evilpie, Assigned: evilpie)
References
(Blocks 3 open bugs)
Details
Attachments
(1 file)
25.98 KB,
patch
|
Details | Diff | Splinter Review |
There is still some stuff we should do: 1) Optimize dense element holes in CacheIR 2) More constant folding in Ion, e.g. something using the definite property analysis. 3) Use baseline IC data in Ion to inline? 4) Optimize the following pattern, found in react, ember, pdf.js etc. for (var x in obj) { if (obj.hasOwnProperty(x)) break; } We can just look at the iterator object to decide if x is an own property of obj.
Comment 1•7 years ago
|
||
For what it's worth, the pattern in 4) is part of a style rule of eslint, a linter for JS commonly used in the wild, so it might be very useful to optimize in general: http://eslint.org/docs/rules/guard-for-in
Assignee | ||
Comment 2•7 years ago
|
||
This improves a simple benchmark from 61ms to 37ms.
Assignee: nobody → evilpies
Assignee | ||
Comment 3•7 years ago
|
||
I thought we could get away with not shape-checking the object, because we would only call hasOwnProperty on ids that we iterated over. And deletions would be handled by the suppression mechanism. However it's possible define a property on the object during the iteration, which was previously only on the proto. var o = {x: 1, __proto__: {y: 2}}; for (var id in o) { print(o.hasOwnProperty(id)); o.y = 1; } This should print true, twice.
Assignee | ||
Comment 4•7 years ago
|
||
Ember seems to never hit fallback path \o/. But React does 1. Iterating over an array: https://github.com/WebKit/webkit/blob/master/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/react/JSXTransformer.js#L5913 2. Shape change during iteration: https://github.com/WebKit/webkit/blob/master/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/react/react.js#L7179
Assignee | ||
Comment 5•7 years ago
|
||
Try push for the for..in hasOwnProperty optimization looks quite good: https://treeherder.mozilla.org/#/jobs?repo=try&revision=61e1b526a238ab4a4451ea1abad3a8af1a894fa6 I need to do some analysis on speedometer to figure out if this is actually a win.
Updated•7 years ago
|
Whiteboard: [qf]
Comment 6•7 years ago
|
||
This pattern is common in many places including Speedometer.
Whiteboard: [qf] → [qf:p1]
Updated•7 years ago
|
Blocks: Speedometer_V2
Assignee | ||
Comment 7•7 years ago
|
||
Fwiw, I didn't see any improvements on Speedometer with this patch. I think v8 removed this optimization after moving to Turbofan.
Updated•6 years ago
|
Blocks: TimeToFirstPaint_FB
Updated•6 years ago
|
No longer blocks: TimeToFirstPaint_FB
Comment 8•6 years ago
|
||
Changing to qf- because of negative results reported by evilpie.
Whiteboard: [qf:p1] → [qf-]
Assignee | ||
Comment 10•6 years ago
|
||
Yeah let's close this.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
Updated•2 years ago
|
Performance Impact: --- → -
Whiteboard: [qf-]
You need to log in
before you can comment on or make changes to this bug.
Description
•