Commit 2442b097 authored by Shu-yu Guo's avatar Shu-yu Guo Committed by V8 LUCI CQ

[change-array-by-copy] Move some slow paths from macros to builtins

The slow paths of the Array.prototype methods in the
change-Array-by-copy proposal don't need to be inlined as macros. Make
them builtins where possible.

This CL also driveby fixes the fast path for toSpliced to only apply
when the returned copy's length is <= kMaxFastArrayLength.

Bug: v8:13035
Change-Id: I4034d5d40d7db14d86b33a6f1047e1b17781321a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3830287
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82465}
parent add25d73
......@@ -56,7 +56,7 @@ macro TryFastPackedArrayToReversed(implicit context: Context)(receiver: JSAny):
goto Slow;
}
transitioning macro GenericArrayToReversed(implicit context: Context)(
transitioning builtin GenericArrayToReversed(implicit context: Context)(
receiver: JSAny): JSAny {
// 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver);
......
......@@ -226,6 +226,7 @@ transitioning javascript builtin ArrayPrototypeToSpliced(
if (newLen == 0) return ArrayCreate(0);
try {
if (newLen > kMaxFastArrayLength) goto Slow;
return TryFastArrayToSpliced(
arguments, o, len, newLen, actualStart, insertCount, actualDeleteCount)
otherwise Slow;
......
......@@ -26,7 +26,7 @@ transitioning macro TryFastPackedArrayWith(implicit context: Context)(
goto Slow;
}
transitioning macro GenericArrayWith(
transitioning builtin GenericArrayWith(
context: Context, receiver: JSReceiver, len: Number, actualIndex: Number,
value: JSAny): JSArray {
// 7. Let A be ? ArrayCreate(𝔽(len)).
......
......@@ -480,6 +480,8 @@ const kObjectAlignmentMask: constexpr intptr
generates 'kObjectAlignmentMask';
const kMinAddedElementsCapacity:
constexpr int31 generates 'JSObject::kMinAddedElementsCapacity';
const kMaxFastArrayLength:
constexpr int31 generates 'JSArray::kMaxFastArrayLength';
const kMaxCopyElements:
constexpr int31 generates 'JSArray::kMaxCopyElements';
const kMaxRegularHeapObjectSize: constexpr int31
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment