[Scheduler] Fix de-opt caused by out-of-bounds access (#21147)
[Scheduler] Fix de-opt caused by out-of-bounds access (#21147)

Scheduler's heap implementation sometimes accesses indices that are out
of bounds (larger than the size of the array). This causes a VM de-opt.

This change fixes the de-opt by always checking the index before
accessing the array. In exchange, we can remove the typecheck on the
returned element.

Background: https://v8.dev/blog/elements-kinds#avoid-reading-beyond-the-length-of-the-array

Co-authored-by: Andrew Clark <46f1a0bd5592a2f9244ca321b129902a06b53e03@andrewclark.io>
yungsters/react,acdlite/react,tomocchino/react,acdlite/react,tomocchino/react,yungsters/react,facebook/react,yungsters/react,camsong/react,acdlite/react,acdlite/react,camsong/react,tomocchino/react,mosoft521/react,acdlite/react,camsong/react,mosoft521/react,tomocchino/react,facebook/react,yungsters/react,mosoft521/react,yungsters/react,acdlite/react,mosoft521/react,mosoft521/react,tomocchino/react,camsong/react,yungsters/react,mosoft521/react,tomocchino/react,mosoft521/react,facebook/react,facebook/react,facebook/react,facebook/react,yungsters/react,facebook/react,acdlite/react,camsong/react,camsong/react,tomocchino/react,camsong/react