Skip to content

Commit 5bdd917

Browse files
LeszekSwirskitargos
authored andcommitted
deps: V8: cherry-pick e0fb10b5148c
Original commit message: [array] Increase the maximum size of FixedArrays Use the newly increased maximum FreeSpace size to allow a larger upper bound for FixedArray/FixedDoubleArray size. Bug: 417413670 Change-Id: I655c98bb68dfe033ae62f2b16441c62bc4403058 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6597277 Commit-Queue: Leszek Swirski <[email protected]> Reviewed-by: Igor Sheludko <[email protected]> Cr-Commit-Position: refs/heads/main@{#100593} Refs: v8/v8@e0fb10b
1 parent 3cac85b commit 5bdd917

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.30',
41+
'v8_embedder_string': '-node.31',
4242

4343
##### V8 defaults for Node.js #####
4444

deps/v8/src/objects/fixed-array.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "src/common/globals.h"
1111
#include "src/handles/maybe-handles.h"
12+
#include "src/objects/free-space.h"
1213
#include "src/objects/heap-object.h"
1314
#include "src/objects/instance-type.h"
1415
#include "src/objects/maybe-object.h"
@@ -29,8 +30,10 @@ namespace v8::internal {
2930
// Limit all fixed arrays to the same max capacity, so that non-resizing
3031
// transitions between different elements kinds (like Smi to Double) will not
3132
// error.
33+
// This could be larger, but the next power of two up would push the maximum
34+
// byte size of FixedDoubleArray out of int32 range.
3235
static constexpr int kMaxFixedArrayCapacity =
33-
V8_LOWER_LIMITS_MODE_BOOL ? (16 * 1024 * 1024) : (64 * 1024 * 1024);
36+
V8_LOWER_LIMITS_MODE_BOOL ? (16 * 1024 * 1024) : (128 * 1024 * 1024);
3437

3538
namespace detail {
3639
template <class Super, bool kLengthEqualsCapacity>
@@ -181,11 +184,8 @@ class TaggedArrayBase : public detail::TaggedArrayHeader<ShapeT, Super> {
181184
// Maximal allowed capacity, in number of elements. Chosen s.t. the byte size
182185
// fits into a Smi which is necessary for being able to create a free space
183186
// filler.
184-
// TODO(jgruber): The kMaxCapacity could be larger (`(Smi::kMaxValue -
185-
// Shape::kHeaderSize) / kElementSize`), but our tests rely on a
186-
// smaller maximum to avoid timeouts.
187187
static constexpr int kMaxCapacity = kMaxFixedArrayCapacity;
188-
static_assert(Smi::IsValid(SizeFor(kMaxCapacity)));
188+
static_assert(SizeFor(kMaxCapacity) <= FreeSpace::kMaxSizeInBytes);
189189

190190
// Maximally allowed length for regular (non large object space) object.
191191
static constexpr int kMaxRegularCapacity =
@@ -425,11 +425,8 @@ class PrimitiveArrayBase : public detail::ArrayHeaderBase<Super, true> {
425425
// Maximal allowed length, in number of elements. Chosen s.t. the byte size
426426
// fits into a Smi which is necessary for being able to create a free space
427427
// filler.
428-
// TODO(jgruber): The kMaxLength could be larger (`(Smi::kMaxValue -
429-
// sizeof(Header)) / kElementSize`), but our tests rely on a
430-
// smaller maximum to avoid timeouts.
431428
static constexpr int kMaxLength = kMaxFixedArrayCapacity;
432-
static_assert(Smi::IsValid(SizeFor(kMaxLength)));
429+
static_assert(SizeFor(kMaxLength) <= FreeSpace::kMaxSizeInBytes);
433430

434431
// Maximally allowed length for regular (non large object space) object.
435432
static constexpr int kMaxRegularLength =

deps/v8/src/objects/free-space.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
#ifndef V8_OBJECTS_FREE_SPACE_H_
66
#define V8_OBJECTS_FREE_SPACE_H_
77

8+
#include "src/common/globals.h"
89
#include "src/objects/heap-object.h"
10+
#include "src/objects/smi.h"
911

1012
// Has to be the last include (doesn't have include guards):
1113
#include "src/objects/object-macros.h"
@@ -32,6 +34,9 @@ namespace internal {
3234
// scheme.
3335
class FreeSpace : public TorqueGeneratedFreeSpace<FreeSpace, HeapObject> {
3436
public:
37+
static constexpr uint32_t kMaxSizeInBytes =
38+
uint32_t{Smi::kMaxValue} * kTaggedSize;
39+
3540
// [size]: size of the free space including the header.
3641
DECL_RELAXED_INT_ACCESSORS(size)
3742
static inline void SetSize(const WritableFreeSpace& writable_free_space,

deps/v8/test/mjsunit/regress/regress-crbug-1057653.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
// found in the LICENSE file.
44

55
Object.prototype.length = 3642395160;
6-
const array = new Float32Array(2**27);
6+
const array = new Float32Array(2**28);
77

88
assertThrows(() => {for (const key in array) {}}, RangeError);

0 commit comments

Comments
 (0)