Commit 200fd550 authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[builtins] FastJSArrayForConcat as subtype of FastJSArrayForCopy

This fixes 2 cluster fuzz bugs.

Bug: chromium:1229885, chromium:1229813
Change-Id: Icc2738d7fac35f36f50bd2e723ac8ab4add40068
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3034742
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75751}
parent 8b48c59d
...@@ -12,7 +12,7 @@ ArrayPrototypeConcat( ...@@ -12,7 +12,7 @@ ArrayPrototypeConcat(
// Fast path if we invoke as `x.concat()`. // Fast path if we invoke as `x.concat()`.
if (arguments.length == 0) { if (arguments.length == 0) {
typeswitch (receiver) { typeswitch (receiver) {
case (a: FastJSArrayForCopy): { case (a: FastJSArrayForConcat): {
return CloneFastJSArray(context, a); return CloneFastJSArray(context, a);
} }
case (JSAny): { case (JSAny): {
......
...@@ -547,6 +547,7 @@ Cast<FastJSArrayForCopy>(implicit context: Context)(o: HeapObject): ...@@ -547,6 +547,7 @@ Cast<FastJSArrayForCopy>(implicit context: Context)(o: HeapObject):
FastJSArrayForCopy FastJSArrayForCopy
labels CastError { labels CastError {
if (IsArraySpeciesProtectorCellInvalid()) goto CastError; if (IsArraySpeciesProtectorCellInvalid()) goto CastError;
// TODO(victorgomes): Check if we can cast from FastJSArrayForRead instead.
const a = Cast<FastJSArray>(o) otherwise CastError; const a = Cast<FastJSArray>(o) otherwise CastError;
return %RawDownCast<FastJSArrayForCopy>(a); return %RawDownCast<FastJSArrayForCopy>(a);
} }
...@@ -554,9 +555,8 @@ Cast<FastJSArrayForCopy>(implicit context: Context)(o: HeapObject): ...@@ -554,9 +555,8 @@ Cast<FastJSArrayForCopy>(implicit context: Context)(o: HeapObject):
Cast<FastJSArrayForConcat>(implicit context: Context)(o: HeapObject): Cast<FastJSArrayForConcat>(implicit context: Context)(o: HeapObject):
FastJSArrayForConcat FastJSArrayForConcat
labels CastError { labels CastError {
if (IsArraySpeciesProtectorCellInvalid()) goto CastError;
if (IsIsConcatSpreadableProtectorCellInvalid()) goto CastError; if (IsIsConcatSpreadableProtectorCellInvalid()) goto CastError;
const a = Cast<FastJSArrayForRead>(o) otherwise CastError; const a = Cast<FastJSArrayForCopy>(o) otherwise CastError;
return %RawDownCast<FastJSArrayForConcat>(a); return %RawDownCast<FastJSArrayForConcat>(a);
} }
......
...@@ -66,9 +66,9 @@ transient type FastJSArrayForRead extends JSArray; ...@@ -66,9 +66,9 @@ transient type FastJSArrayForRead extends JSArray;
// A FastJSArray when the global ArraySpeciesProtector is not invalidated. // A FastJSArray when the global ArraySpeciesProtector is not invalidated.
transient type FastJSArrayForCopy extends FastJSArray; transient type FastJSArrayForCopy extends FastJSArray;
// A FastJSArray when the global ArraySpeciesProtector and // A FastJSArrayForCopy when the global IsConcatSpreadableProtector is not
// IsConcatSpreadableProtector are not invalidated. // invalidated.
transient type FastJSArrayForConcat extends FastJSArrayForRead; transient type FastJSArrayForConcat extends FastJSArrayForCopy;
// A FastJSArray when the global ArrayIteratorProtector is not invalidated. // A FastJSArray when the global ArrayIteratorProtector is not invalidated.
transient type FastJSArrayWithNoCustomIteration extends FastJSArray; transient type FastJSArrayWithNoCustomIteration extends FastJSArray;
......
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --force-slow-path
let obj = [1, 2, 3];
obj[Symbol.isConcatSpreadable] = false;
assertEquals([obj], obj.concat());
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