The hotspot here is this function, with 20% of the samples: ``` forEachNeighbour(f) { for (var nx = 0; nx < this.neighbours.length; nx++) { if (this.neighbours[nx] !== undefined) { for (var ny = 0; ny < this.neighbours[nx].length; ny++) { if (this.neighbours[nx][ny] !== undefined) { f(this.neighbours[nx][ny], nx - 1, ny - 1); } } } } } ``` This doesn't seem like it should be that slow. ```
Bug 1805709 Comment 1 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
The hotspot here is this function, with 20% of the samples: ``` forEachNeighbour(f) { for (var nx = 0; nx < this.neighbours.length; nx++) { if (this.neighbours[nx] !== undefined) { for (var ny = 0; ny < this.neighbours[nx].length; ny++) { if (this.neighbours[nx][ny] !== undefined) { f(this.neighbours[nx][ny], nx - 1, ny - 1); } } } } } ``` This doesn't seem like it should be that slow. It was relatively easy to pull out the code and shim the graphics code to run in the shell. Things I noticed: 1. We don't inline `forEachNeighbour` because it's slightly too big. We don't inline `f` into `forEachNeighbour` because it's polymorphic. This might be a case where our idea of inlining more aggressively if the candidate has polymorphic ICs would help. 2. We're doing `GuardNoDenseElements` on Array.prototype and Object.prototype in the inner loop. Fuses might help here.