Optimize testing for an index's existence in packed Arrays
authoradamk <adamk@chromium.org>
Thu, 4 Dec 2014 18:46:33 +0000 (10:46 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 4 Dec 2014 18:46:46 +0000 (18:46 +0000)
commit6230641b83870c8659019ed0c2d907a79fff0200
treea785aa33cd04441940419e47dcf7b3eb616f3ffe
parentf62ab8d061f3dc61f24252c9676ff4446dc07b1b
Optimize testing for an index's existence in packed Arrays

This patch introduces a new inline runtime function,
%_HasFastPackedElements(), and uses it both in the implementation
of the 'in' operator and in the array builtins to speed
up testing for the existence of an index in an array.

In testing with the microbenchmark on the attached bug,
for example, the runtime goes from 326ms to 66ms.

A reviewer might ask whether the HAS_INDEX macro is worthwhile,
and I tried the same example without it, which pushed the
microbenchmark up to 157ms. So it seems it's worth it to
avoid the function call to IN() if we know we're dealing
with arrays and numbers.

BUG=v8:3701
LOG=n

Review URL: https://codereview.chromium.org/754863002

Cr-Commit-Position: refs/heads/master@{#25665}
src/array.js
src/hydrogen.cc
src/macros.py
src/runtime.js
src/runtime/runtime-object.cc
src/runtime/runtime.h