Commit 8dcc6f81 authored by Marja Hölttä's avatar Marja Hölttä Committed by V8 LUCI CQ

[web snap] More consistently allow frozen / sealed elements

The frozenness / sealednes is not yet serialized & deserialized, but
this allows prototyping web snap in contexts where frozen / sealed
elements occur.

Bug: v8:11525, v8:12820
Change-Id: I8fb788bd3d1a1ec3e6b47610c69230cc900033b2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3652779
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80630}
parent bc00836e
......@@ -1022,16 +1022,17 @@ void WebSnapshotSerializer::DiscoverArray(Handle<JSArray> array) {
DisallowGarbageCollection no_gc;
// TODO(v8:11525): Support sparse arrays & arrays with holes.
// TODO(v8:11525): Handle sealed & frozen elements correctly. (Also: handle
// sealed & frozen objects.)
switch (elements_kind) {
case PACKED_SMI_ELEMENTS:
case PACKED_ELEMENTS:
case HOLEY_SMI_ELEMENTS:
case HOLEY_ELEMENTS:
case PACKED_SEALED_ELEMENTS:
case PACKED_FROZEN_ELEMENTS:
case HOLEY_SMI_ELEMENTS:
case HOLEY_ELEMENTS: {
case HOLEY_SEALED_ELEMENTS:
case HOLEY_FROZEN_ELEMENTS: {
FixedArray elements = FixedArray::cast(array->elements());
for (int i = 0; i < elements.length(); ++i) {
Object object = elements.get(i);
......@@ -1406,12 +1407,17 @@ void WebSnapshotSerializer::SerializeObject(Handle<JSObject> object) {
// - Serialized value
void WebSnapshotSerializer::SerializeArray(Handle<JSArray> array) {
auto elements_kind = array->GetElementsKind();
// TODO(v8:11525): Support double arrays.
// TODO(v8:11525): Handle sealed & frozen elements correctly. (Also: handle
// sealed & frozen objects.)
switch (elements_kind) {
case PACKED_SMI_ELEMENTS:
case PACKED_ELEMENTS:
case HOLEY_SMI_ELEMENTS:
case HOLEY_ELEMENTS: {
case HOLEY_ELEMENTS:
case PACKED_FROZEN_ELEMENTS:
case PACKED_SEALED_ELEMENTS:
case HOLEY_FROZEN_ELEMENTS:
case HOLEY_SEALED_ELEMENTS: {
array_serializer_.WriteUint32(ArrayType::kDense);
uint32_t length = static_cast<uint32_t>(array->length().ToSmi().value());
array_serializer_.WriteUint32(length);
......
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