-
Benedikt Meurer authored
In the KeyedLoadICGeneric case the engine previously immediately fell back to the %KeyedGetProperty runtime function if the key was not a Name or a valid array index. This turns out to be really slow if a program passes for example objects as keys. Since we already have all the logic in place to convert an arbitrary JavaScript value to a Name, we can just call into ToName first and then operate on the result of that, which is significantly faster since C++ usually doesn't need to call back into JavaScript then to convert a JSReceiver into a Name. This also changes the ToName builtin to use the existing builtin for NonPrimitiveToPrimitive, which stays in JavaScript land completely. Since there's not really a point in inlining ToName into the call sites, the other uses were also changed to call the builtin instead, which saves some space and might also help with instruction cache utilization (especially when the ToName logic is more involved now). This improves the performance on the microbenchmark ```js const n = 1e7; const obj = {}; const key = [1,2]; const start = Date.now(); for (let i = 0; i < n; ++i) { if (obj[key] === undefined) obj[key] = key; } print(`time: ${Date.now() - start} ms.`); ``` by up to 36%. On the ARES-6 ML benchmark the steady state improves by up to ~7% and the overall mean for ARES-6 ML improves by up to ~6%. Further improvements might be possible here if the GetProperty builtin could be made faster for common prototype lookups like Symbol.toPrimitive and the "valueOf" and "toString" functions. Bug: v8:6344, v8:6670 Change-Id: Ic3ac2bc4d4277836ef03039de4eda5c5f66a85da Reviewed-on: https://chromium-review.googlesource.com/1199022 Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#55540}
923127f8