Skip to content

Commit 5c0fcc1

Browse files
targosdanielleadams
authored andcommitted
deps: patch V8 to 10.2.154.19
Refs: v8/v8@10.2.154.15...10.2.154.19 PR-URL: #45229 Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
1 parent 39cf8b4 commit 5c0fcc1

9 files changed

+148
-13
lines changed

deps/v8/include/v8-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 10
1212
#define V8_MINOR_VERSION 2
1313
#define V8_BUILD_NUMBER 154
14-
#define V8_PATCH_LEVEL 15
14+
#define V8_PATCH_LEVEL 19
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,15 @@ PropertyAccessInfo AccessInfoFactory::ComputeDataFieldAccessInfo(
454454
map, descriptor, details_representation));
455455
} else if (details_representation.IsHeapObject()) {
456456
if (descriptors_field_type->IsNone()) {
457-
// Store is not safe if the field type was cleared.
458-
if (access_mode == AccessMode::kStore) {
459-
return Invalid();
457+
switch (access_mode) {
458+
case AccessMode::kStore:
459+
case AccessMode::kStoreInLiteral:
460+
case AccessMode::kDefine:
461+
// Store is not safe if the field type was cleared.
462+
return Invalid();
463+
case AccessMode::kLoad:
464+
case AccessMode::kHas:
465+
break;
460466
}
461467

462468
// The field type was cleared by the GC, so we don't know anything

deps/v8/src/compiler/compilation-dependencies.cc

+44-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ namespace compiler {
3535
V(Protector) \
3636
V(PrototypeProperty) \
3737
V(StableMap) \
38-
V(Transition)
38+
V(Transition) \
39+
V(ObjectSlotValue)
3940

4041
CompilationDependencies::CompilationDependencies(JSHeapBroker* broker,
4142
Zone* zone)
@@ -863,6 +864,42 @@ class ProtectorDependency final : public CompilationDependency {
863864
const PropertyCellRef cell_;
864865
};
865866

867+
// Check that an object slot will not change during compilation.
868+
class ObjectSlotValueDependency final : public CompilationDependency {
869+
public:
870+
explicit ObjectSlotValueDependency(const HeapObjectRef& object, int offset,
871+
const ObjectRef& value)
872+
: CompilationDependency(kObjectSlotValue),
873+
object_(object.object()),
874+
offset_(offset),
875+
value_(value.object()) {}
876+
877+
bool IsValid() const override {
878+
PtrComprCageBase cage_base = GetPtrComprCageBase(*object_);
879+
Object current_value =
880+
offset_ == HeapObject::kMapOffset
881+
? object_->map()
882+
: TaggedField<Object>::Relaxed_Load(cage_base, *object_, offset_);
883+
return *value_ == current_value;
884+
}
885+
void Install(PendingDependencies* deps) const override {}
886+
887+
private:
888+
size_t Hash() const override {
889+
return base::hash_combine(object_.address(), offset_, value_.address());
890+
}
891+
892+
bool Equals(const CompilationDependency* that) const override {
893+
const ObjectSlotValueDependency* const zat = that->AsObjectSlotValue();
894+
return object_->address() == zat->object_->address() &&
895+
offset_ == zat->offset_ && value_.address() == zat->value_.address();
896+
}
897+
898+
Handle<HeapObject> object_;
899+
int offset_;
900+
Handle<Object> value_;
901+
};
902+
866903
class ElementsKindDependency final : public CompilationDependency {
867904
public:
868905
ElementsKindDependency(const AllocationSiteRef& site, ElementsKind kind)
@@ -1110,6 +1147,12 @@ void CompilationDependencies::DependOnElementsKind(
11101147
}
11111148
}
11121149

1150+
void CompilationDependencies::DependOnObjectSlotValue(
1151+
const HeapObjectRef& object, int offset, const ObjectRef& value) {
1152+
RecordDependency(
1153+
zone_->New<ObjectSlotValueDependency>(object, offset, value));
1154+
}
1155+
11131156
void CompilationDependencies::DependOnOwnConstantElement(
11141157
const JSObjectRef& holder, uint32_t index, const ObjectRef& element) {
11151158
RecordDependency(

deps/v8/src/compiler/compilation-dependencies.h

+4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ class V8_EXPORT_PRIVATE CompilationDependencies : public ZoneObject {
9393
// Record the assumption that {site}'s {ElementsKind} doesn't change.
9494
void DependOnElementsKind(const AllocationSiteRef& site);
9595

96+
// Check that an object slot will not change during compilation.
97+
void DependOnObjectSlotValue(const HeapObjectRef& object, int offset,
98+
const ObjectRef& value);
99+
96100
void DependOnOwnConstantElement(const JSObjectRef& holder, uint32_t index,
97101
const ObjectRef& element);
98102

deps/v8/src/compiler/js-create-lowering.cc

+12
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,10 @@ base::Optional<Node*> JSCreateLowering::TryAllocateFastLiteral(
16771677

16781678
// Now that we hold the migration lock, get the current map.
16791679
MapRef boilerplate_map = boilerplate.map();
1680+
// Protect against concurrent changes to the boilerplate object by checking
1681+
// for an identical value at the end of the compilation.
1682+
dependencies()->DependOnObjectSlotValue(boilerplate, HeapObject::kMapOffset,
1683+
boilerplate_map);
16801684
{
16811685
base::Optional<MapRef> current_boilerplate_map =
16821686
boilerplate.map_direct_read();
@@ -1841,10 +1845,18 @@ base::Optional<Node*> JSCreateLowering::TryAllocateFastLiteralElements(
18411845
boilerplate.elements(kRelaxedLoad);
18421846
if (!maybe_boilerplate_elements.has_value()) return {};
18431847
FixedArrayBaseRef boilerplate_elements = maybe_boilerplate_elements.value();
1848+
// Protect against concurrent changes to the boilerplate object by checking
1849+
// for an identical value at the end of the compilation.
1850+
dependencies()->DependOnObjectSlotValue(
1851+
boilerplate, JSObject::kElementsOffset, boilerplate_elements);
18441852

18451853
// Empty or copy-on-write elements just store a constant.
18461854
int const elements_length = boilerplate_elements.length();
18471855
MapRef elements_map = boilerplate_elements.map();
1856+
// Protect against concurrent changes to the boilerplate object by checking
1857+
// for an identical value at the end of the compilation.
1858+
dependencies()->DependOnObjectSlotValue(boilerplate_elements,
1859+
HeapObject::kMapOffset, elements_map);
18481860
if (boilerplate_elements.length() == 0 || elements_map.IsFixedCowArrayMap()) {
18491861
if (allocation == AllocationType::kOld &&
18501862
!boilerplate.IsElementsTenured(boilerplate_elements)) {

deps/v8/src/objects/value-serializer.cc

+50-4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ static const uint32_t kLatestVersion = 15;
6464
static_assert(kLatestVersion == v8::CurrentValueSerializerFormatVersion(),
6565
"Exported format version must match latest version.");
6666

67+
namespace {
68+
// For serializing JSArrayBufferView flags. Instead of serializing /
69+
// deserializing the flags directly, we serialize them bit by bit. This is for
70+
// ensuring backwards compatilibity in the case where the representation
71+
// changes. Note that the ValueSerializer data can be stored on disk.
72+
using JSArrayBufferViewIsLengthTracking = base::BitField<bool, 0, 1>;
73+
using JSArrayBufferViewIsBackedByRab =
74+
JSArrayBufferViewIsLengthTracking::Next<bool, 1>;
75+
76+
} // namespace
77+
6778
template <typename T>
6879
static size_t BytesNeededForVarint(T value) {
6980
static_assert(std::is_integral<T>::value && std::is_unsigned<T>::value,
@@ -922,6 +933,8 @@ Maybe<bool> ValueSerializer::WriteJSArrayBuffer(
922933
if (byte_length > std::numeric_limits<uint32_t>::max()) {
923934
return ThrowDataCloneError(MessageTemplate::kDataCloneError, array_buffer);
924935
}
936+
// TODO(v8:11111): Support RAB / GSAB. The wire version will need to be
937+
// bumped.
925938
WriteTag(SerializationTag::kArrayBuffer);
926939
WriteVarint<uint32_t>(byte_length);
927940
WriteRawBytes(array_buffer->backing_store(), byte_length);
@@ -950,7 +963,10 @@ Maybe<bool> ValueSerializer::WriteJSArrayBufferView(JSArrayBufferView view) {
950963
WriteVarint(static_cast<uint8_t>(tag));
951964
WriteVarint(static_cast<uint32_t>(view.byte_offset()));
952965
WriteVarint(static_cast<uint32_t>(view.byte_length()));
953-
WriteVarint(static_cast<uint32_t>(view.bit_field()));
966+
uint32_t flags =
967+
JSArrayBufferViewIsLengthTracking::encode(view.is_length_tracking()) |
968+
JSArrayBufferViewIsBackedByRab::encode(view.is_backed_by_rab());
969+
WriteVarint(flags);
954970
return ThrowIfOutOfMemory();
955971
}
956972

@@ -1979,7 +1995,7 @@ MaybeHandle<JSArrayBuffer> ValueDeserializer::ReadTransferredJSArrayBuffer() {
19791995

19801996
MaybeHandle<JSArrayBufferView> ValueDeserializer::ReadJSArrayBufferView(
19811997
Handle<JSArrayBuffer> buffer) {
1982-
uint32_t buffer_byte_length = static_cast<uint32_t>(buffer->byte_length());
1998+
uint32_t buffer_byte_length = static_cast<uint32_t>(buffer->GetByteLength());
19831999
uint8_t tag = 0;
19842000
uint32_t byte_offset = 0;
19852001
uint32_t byte_length = 0;
@@ -2004,7 +2020,9 @@ MaybeHandle<JSArrayBufferView> ValueDeserializer::ReadJSArrayBufferView(
20042020
Handle<JSDataView> data_view =
20052021
isolate_->factory()->NewJSDataView(buffer, byte_offset, byte_length);
20062022
AddObjectWithID(id, data_view);
2007-
data_view->set_bit_field(flags);
2023+
if (!ValidateAndSetJSArrayBufferViewFlags(*data_view, *buffer, flags)) {
2024+
return MaybeHandle<JSArrayBufferView>();
2025+
}
20082026
return data_view;
20092027
}
20102028
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype) \
@@ -2021,11 +2039,39 @@ MaybeHandle<JSArrayBufferView> ValueDeserializer::ReadJSArrayBufferView(
20212039
}
20222040
Handle<JSTypedArray> typed_array = isolate_->factory()->NewJSTypedArray(
20232041
external_array_type, buffer, byte_offset, byte_length / element_size);
2024-
typed_array->set_bit_field(flags);
2042+
if (!ValidateAndSetJSArrayBufferViewFlags(*typed_array, *buffer, flags)) {
2043+
return MaybeHandle<JSArrayBufferView>();
2044+
}
20252045
AddObjectWithID(id, typed_array);
20262046
return typed_array;
20272047
}
20282048

2049+
bool ValueDeserializer::ValidateAndSetJSArrayBufferViewFlags(
2050+
JSArrayBufferView view, JSArrayBuffer buffer, uint32_t serialized_flags) {
2051+
bool is_length_tracking =
2052+
JSArrayBufferViewIsLengthTracking::decode(serialized_flags);
2053+
bool is_backed_by_rab =
2054+
JSArrayBufferViewIsBackedByRab::decode(serialized_flags);
2055+
2056+
// TODO(marja): When the version number is bumped the next time, check that
2057+
// serialized_flags doesn't contain spurious 1-bits.
2058+
2059+
if (is_backed_by_rab || is_length_tracking) {
2060+
if (!FLAG_harmony_rab_gsab) {
2061+
return false;
2062+
}
2063+
if (!buffer.is_resizable()) {
2064+
return false;
2065+
}
2066+
if (is_backed_by_rab && buffer.is_shared()) {
2067+
return false;
2068+
}
2069+
}
2070+
view.set_is_length_tracking(is_length_tracking);
2071+
view.set_is_backed_by_rab(is_backed_by_rab);
2072+
return true;
2073+
}
2074+
20292075
MaybeHandle<Object> ValueDeserializer::ReadJSError() {
20302076
uint32_t id = next_id_++;
20312077

deps/v8/src/objects/value-serializer.h

+3
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ class ValueDeserializer {
295295
V8_WARN_UNUSED_RESULT;
296296
MaybeHandle<JSArrayBufferView> ReadJSArrayBufferView(
297297
Handle<JSArrayBuffer> buffer) V8_WARN_UNUSED_RESULT;
298+
bool ValidateAndSetJSArrayBufferViewFlags(
299+
JSArrayBufferView view, JSArrayBuffer buffer,
300+
uint32_t serialized_flags) V8_WARN_UNUSED_RESULT;
298301
MaybeHandle<Object> ReadJSError() V8_WARN_UNUSED_RESULT;
299302
#if V8_ENABLE_WEBASSEMBLY
300303
MaybeHandle<JSObject> ReadWasmModuleTransfer() V8_WARN_UNUSED_RESULT;

deps/v8/src/wasm/baseline/liftoff-compiler.cc

+8-4
Original file line numberDiff line numberDiff line change
@@ -1417,9 +1417,11 @@ class LiftoffCompiler {
14171417
__ MergeFullStackWith(c->label_state, *__ cache_state());
14181418
__ emit_jump(c->label.get());
14191419
}
1420-
// Merge the else state into the end state.
1420+
// Merge the else state into the end state. Set this state as the current
1421+
// state first so helper functions know which registers are in use.
14211422
__ bind(c->else_state->label.get());
1422-
__ MergeFullStackWith(c->label_state, c->else_state->state);
1423+
__ cache_state()->Steal(c->else_state->state);
1424+
__ MergeFullStackWith(c->label_state, *__ cache_state());
14231425
__ cache_state()->Steal(c->label_state);
14241426
} else if (c->reachable()) {
14251427
// No merge yet at the end of the if, but we need to create a merge for
@@ -1431,9 +1433,11 @@ class LiftoffCompiler {
14311433
c->stack_depth + c->num_exceptions);
14321434
__ MergeFullStackWith(c->label_state, *__ cache_state());
14331435
__ emit_jump(c->label.get());
1434-
// Merge the else state into the end state.
1436+
// Merge the else state into the end state. Set this state as the current
1437+
// state first so helper functions know which registers are in use.
14351438
__ bind(c->else_state->label.get());
1436-
__ MergeFullStackWith(c->label_state, c->else_state->state);
1439+
__ cache_state()->Steal(c->else_state->state);
1440+
__ MergeFullStackWith(c->label_state, *__ cache_state());
14371441
__ cache_state()->Steal(c->label_state);
14381442
} else {
14391443
// No merge needed, just continue with the else state.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2022 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --harmony-rab-gsab
6+
7+
"use strict";
8+
9+
(function FlagMismatch() {
10+
// Length tracking TA, buffer not resizable.
11+
const data1 = new Uint8Array([255, 15, 66, 4, 3, 5, 7, 11, 86, 66, 1, 2, 1]);
12+
assertThrows(() => { d8.serializer.deserialize(data1.buffer); });
13+
14+
// RAB backed TA, buffer not resizable.
15+
const data2 = new Uint8Array([255, 15, 66, 4, 3, 5, 7, 11, 86, 66, 1, 2, 2]);
16+
assertThrows(() => { d8.serializer.deserialize(data2.buffer); });
17+
})();

0 commit comments

Comments
 (0)