Skip to content

Commit 04e360f

Browse files
committed
deps: V8: cherry-pick 06bf293610ef, 146962dda8d2 and e0fb10b5148c
Cherry-pick 06bf293610ef. Original commit message: [tagged] Make FreeSpace a HeapObjectLayout Bug: 42202654 Change-Id: I2c5d1a69d9bf0272b631e3fa7964026f3ccded11 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6596552 Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Auto-Submit: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/main@{#100564} Refs: v8/v8@06bf293 Cherry-pick 146962dda8d2. Original commit message: [heap] Store FreeSpace size in multiples of tagged words Since FreeSpace has to be aligned to Tagged words, we can support larger free spaces by storing the size in words rather than bytes. Bug: 417413670 Change-Id: I19ef4921e00a5ec23d39ff4aa5b379b36fc86e0a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6596680 Commit-Queue: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Auto-Submit: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/main@{#100590} Refs: v8/v8@146962d 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 <leszeks@chromium.org> Reviewed-by: Igor Sheludko <ishell@chromium.org> Cr-Commit-Position: refs/heads/main@{#100593} Refs: v8/v8@e0fb10b PR-URL: #60713 Reviewed-By: Richard Lau <richard.lau@ibm.com>
1 parent fcbd8db commit 04e360f

File tree

21 files changed

+77
-70
lines changed

21 files changed

+77
-70
lines changed

deps/v8/src/builtins/base.tq

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ type Zero extends PositiveSmi;
5858
// A tagged value represented by an all-zero bitpattern.
5959
type TaggedZeroPattern extends TaggedIndex;
6060

61-
// A value with the size of Tagged which may contain arbitrary data.
62-
type Uninitialized extends Tagged;
63-
6461
type BuiltinsName extends int31 constexpr 'Builtin';
6562

6663
type UseCounterFeature extends int31

deps/v8/src/compiler/access-builder.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -891,15 +891,6 @@ FieldAccess AccessBuilder::ForNameRawHashField() {
891891
return access;
892892
}
893893

894-
// static
895-
FieldAccess AccessBuilder::ForFreeSpaceSize() {
896-
FieldAccess access = {kTaggedBase, FreeSpace::kSizeOffset,
897-
MaybeHandle<Name>(), OptionalMapRef(),
898-
Type::SignedSmall(), MachineType::TaggedSigned(),
899-
kNoWriteBarrier};
900-
return access;
901-
}
902-
903894
// static
904895
FieldAccess AccessBuilder::ForStringLength() {
905896
FieldAccess access = {kTaggedBase,

deps/v8/src/compiler/access-builder.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,6 @@ class V8_EXPORT_PRIVATE AccessBuilder final
266266
// Provides access to Name::raw_hash_field() field.
267267
static FieldAccess ForNameRawHashField();
268268

269-
// Provides access to FreeSpace::size() field
270-
static FieldAccess ForFreeSpaceSize();
271-
272269
// Provides access to String::length() field.
273270
static FieldAccess ForStringLength();
274271

deps/v8/src/diagnostics/objects-debug.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ void HeapObject::HeapObjectVerify(Isolate* isolate) {
330330
Cast<BigIntBase>(*this)->BigIntBaseVerify(isolate);
331331
break;
332332

333+
case FREE_SPACE_TYPE:
334+
Cast<FreeSpace>(*this)->FreeSpaceVerify(isolate);
335+
break;
336+
333337
case JS_CLASS_CONSTRUCTOR_TYPE:
334338
case JS_PROMISE_CONSTRUCTOR_TYPE:
335339
case JS_REG_EXP_CONSTRUCTOR_TYPE:
@@ -362,6 +366,14 @@ void HeapObject::VerifyCodePointer(Isolate* isolate, Tagged<Object> p) {
362366
CHECK(IsInstructionStream(Cast<HeapObject>(p), cage_base));
363367
}
364368

369+
void FreeSpace::FreeSpaceVerify(Isolate* isolate) {
370+
CHECK(IsFreeSpace(this));
371+
{
372+
Tagged<Object> size_in_tagged = size_in_tagged_.Relaxed_Load();
373+
CHECK(IsSmi(size_in_tagged));
374+
}
375+
}
376+
365377
void Name::NameVerify(Isolate* isolate) {
366378
PrimitiveHeapObjectVerify(isolate);
367379
CHECK(IsName(this));

deps/v8/src/diagnostics/objects-printer.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@ void HeapObject::HeapObjectPrint(std::ostream& os) {
357357
case BIG_INT_BASE_TYPE:
358358
Cast<BigIntBase>(*this)->BigIntBasePrint(os);
359359
break;
360+
case FREE_SPACE_TYPE:
361+
Cast<FreeSpace>(*this)->FreeSpacePrint(os);
362+
break;
360363
case JS_CLASS_CONSTRUCTOR_TYPE:
361364
case JS_PROMISE_CONSTRUCTOR_TYPE:
362365
case JS_REG_EXP_CONSTRUCTOR_TYPE:

deps/v8/src/heap/free-list.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void FreeListCategory::Unlink(FreeList* owner) {
2828

2929
void FreeListCategory::Reset(FreeList* owner) {
3030
Unlink(owner);
31-
set_top(FreeSpace());
31+
set_top(Tagged<FreeSpace>());
3232
available_ = 0;
3333
}
3434

@@ -39,7 +39,7 @@ Tagged<FreeSpace> FreeListCategory::PickNodeFromList(size_t minimum_size,
3939
DCHECK(MemoryChunk::FromHeapObject(node)->CanAllocate());
4040
if (static_cast<size_t>(node->Size()) < minimum_size) {
4141
*node_size = 0;
42-
return FreeSpace();
42+
return Tagged<FreeSpace>();
4343
}
4444
set_top(node->next());
4545
*node_size = node->Size();
@@ -80,7 +80,7 @@ Tagged<FreeSpace> FreeListCategory::SearchForNodeInList(size_t minimum_size,
8080

8181
prev_non_evac_node = cur_node;
8282
}
83-
return FreeSpace();
83+
return Tagged<FreeSpace>();
8484
}
8585

8686
void FreeListCategory::Free(const WritableFreeSpace& writable_free_space,
@@ -140,7 +140,7 @@ Tagged<FreeSpace> FreeList::TryFindNodeIn(FreeListCategoryType type,
140140
size_t minimum_size,
141141
size_t* node_size) {
142142
FreeListCategory* category = categories_[type];
143-
if (category == nullptr) return FreeSpace();
143+
if (category == nullptr) return Tagged<FreeSpace>();
144144
Tagged<FreeSpace> node = category->PickNodeFromList(minimum_size, node_size);
145145
if (!node.is_null()) {
146146
DecreaseAvailableBytes(*node_size);

deps/v8/src/heap/heap.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6247,13 +6247,14 @@ void Heap::TearDown() {
62476247
}
62486248

62496249
// static
6250-
bool Heap::IsFreeSpaceValid(FreeSpace object) {
6250+
bool Heap::IsFreeSpaceValid(const FreeSpace* object) {
62516251
Heap* heap = HeapUtils::GetOwnerHeap(object);
62526252
Tagged<Object> free_space_map =
62536253
heap->isolate()->root(RootIndex::kFreeSpaceMap);
62546254
CHECK(!heap->deserialization_complete() ||
6255-
object.map_slot().contains_map_value(free_space_map.ptr()));
6256-
CHECK_LE(FreeSpace::kNextOffset + kTaggedSize, object.size(kRelaxedLoad));
6255+
object->map_slot().contains_map_value(free_space_map.ptr()));
6256+
CHECK_LE(offsetof(FreeSpace, next_) + kTaggedSize,
6257+
object->size(kRelaxedLoad));
62576258
return true;
62586259
}
62596260

deps/v8/src/heap/heap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class Heap final {
352352
collector == GarbageCollector::MINOR_MARK_SWEEPER;
353353
}
354354

355-
V8_EXPORT_PRIVATE static bool IsFreeSpaceValid(FreeSpace object);
355+
V8_EXPORT_PRIVATE static bool IsFreeSpaceValid(const FreeSpace* object);
356356

357357
static inline GarbageCollector YoungGenerationCollector() {
358358
return (v8_flags.minor_ms) ? GarbageCollector::MINOR_MARK_SWEEPER

deps/v8/src/heap/sweeper.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,11 +947,11 @@ std::optional<base::AddressRegion> Sweeper::ComputeDiscardMemoryArea(
947947

948948
void Sweeper::ZeroOrDiscardUnusedMemory(PageMetadata* page, Address addr,
949949
size_t size) {
950-
if (size < FreeSpace::kSize) {
950+
if (size < sizeof(FreeSpace)) {
951951
return;
952952
}
953953

954-
const Address unused_start = addr + FreeSpace::kSize;
954+
const Address unused_start = addr + sizeof(FreeSpace);
955955
DCHECK(page->ContainsLimit(unused_start));
956956
const Address unused_end = addr + size;
957957
DCHECK(page->ContainsLimit(unused_end));

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 =

0 commit comments

Comments
 (0)