Commit bd6450e6 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[compiler] Fix JSHeapBroker::GetOrCreateData()

... which might use an outdated result of a lookup.
Currently it's not an issue, since we don't reuse container's backing
stores allocated in zone memory.

Bug: v8:7790
Change-Id: I30cc0ba747fd704403422711d1f1a5952fe6d68c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2301931
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68894}
parent 4d4cdaf4
...@@ -2708,28 +2708,34 @@ void JSHeapBroker::InitializeAndStartSerializing( ...@@ -2708,28 +2708,34 @@ void JSHeapBroker::InitializeAndStartSerializing(
// clang-format off // clang-format off
ObjectData* JSHeapBroker::GetOrCreateData(Handle<Object> object) { ObjectData* JSHeapBroker::GetOrCreateData(Handle<Object> object) {
RefsMap::Entry* entry = refs_->LookupOrInsert(object.address()); RefsMap::Entry* entry = refs_->LookupOrInsert(object.address());
ObjectData** data_storage = &(entry->value); ObjectData* object_data = entry->value;
if (*data_storage == nullptr) {
if (object_data == nullptr) {
ObjectData** data_storage = &(entry->value);
// TODO(neis): Remove these Allow* once we serialize everything upfront. // TODO(neis): Remove these Allow* once we serialize everything upfront.
AllowHandleDereference handle_dereference; AllowHandleDereference handle_dereference;
if (object->IsSmi()) { if (object->IsSmi()) {
zone()->New<ObjectData>(this, data_storage, object, kSmi); object_data = zone()->New<ObjectData>(this, data_storage, object, kSmi);
} else if (IsReadOnlyHeapObject(*object)) { } else if (IsReadOnlyHeapObject(*object)) {
zone()->New<ObjectData>(this, data_storage, object, object_data = zone()->New<ObjectData>(this, data_storage, object,
kUnserializedReadOnlyHeapObject); kUnserializedReadOnlyHeapObject);
#define CREATE_DATA_IF_MATCH(name) \ #define CREATE_DATA_IF_MATCH(name) \
} else if (object->Is##name()) { \ } else if (object->Is##name()) { \
CHECK(SerializingAllowed()); \ CHECK(SerializingAllowed()); \
AllowHandleAllocation handle_allocation; \ AllowHandleAllocation handle_allocation; \
zone()->New<name##Data>(this, data_storage, Handle<name>::cast(object)); object_data = zone()->New<name##Data>(this, data_storage, \
HEAP_BROKER_OBJECT_LIST(CREATE_DATA_IF_MATCH) Handle<name>::cast(object));
HEAP_BROKER_OBJECT_LIST(CREATE_DATA_IF_MATCH)
#undef CREATE_DATA_IF_MATCH #undef CREATE_DATA_IF_MATCH
} else { } else {
UNREACHABLE(); UNREACHABLE();
} }
// At this point the entry pointer is not guaranteed to be valid as
// the refs_ hash hable could be resized by one of the constructors above.
DCHECK_EQ(object_data, refs_->Lookup(object.address())->value);
} }
CHECK_NOT_NULL(*data_storage); return object_data;
return (*data_storage);
} }
// clang-format on // clang-format on
......
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