Commit e2a4515c authored by Georg Neis's avatar Georg Neis Committed by V8 LUCI CQ

[compiler] Fix a bug in GetOwnFastDataPropertyFromHeap

We can't create Refs inside a DisallowGarbageCollection scope since
the MapData constructor uses a parking mutex (which may park the local
heap and let GC run).

Bug: v8:11957, v8:7790
Change-Id: I300b76a15f0f63514ca049f78099e1e6125a6569
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3010281Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75609}
parent 3e97ebdc
...@@ -537,7 +537,7 @@ base::Optional<ObjectRef> GetOwnElementFromHeap(JSHeapBroker* broker, ...@@ -537,7 +537,7 @@ base::Optional<ObjectRef> GetOwnElementFromHeap(JSHeapBroker* broker,
base::Optional<ObjectRef> GetOwnFastDataPropertyFromHeap( base::Optional<ObjectRef> GetOwnFastDataPropertyFromHeap(
JSHeapBroker* broker, JSObjectRef holder, Representation representation, JSHeapBroker* broker, JSObjectRef holder, Representation representation,
FieldIndex field_index) { FieldIndex field_index) {
base::Optional<ObjectRef> value; base::Optional<Object> constant;
{ {
DisallowGarbageCollection no_gc; DisallowGarbageCollection no_gc;
...@@ -552,7 +552,6 @@ base::Optional<ObjectRef> GetOwnFastDataPropertyFromHeap( ...@@ -552,7 +552,6 @@ base::Optional<ObjectRef> GetOwnFastDataPropertyFromHeap(
return {}; return {};
} }
base::Optional<Object> constant;
if (field_index.is_inobject()) { if (field_index.is_inobject()) {
constant = holder.object()->RawInobjectPropertyAt(map, field_index); constant = holder.object()->RawInobjectPropertyAt(map, field_index);
if (!constant.has_value()) { if (!constant.has_value()) {
...@@ -585,27 +584,25 @@ base::Optional<ObjectRef> GetOwnFastDataPropertyFromHeap( ...@@ -585,27 +584,25 @@ base::Optional<ObjectRef> GetOwnFastDataPropertyFromHeap(
} }
// {constant} needs to pass the gc predicate before we can introspect on it. // {constant} needs to pass the gc predicate before we can introspect on it.
value = TryMakeRef(broker, constant.value()); if (broker->ObjectMayBeUninitialized(constant.value())) return {};
if (!value.has_value()) {
return {}; // Since we don't have a guarantee that {constant} is the correct value of
} // the property, we use the expected {representation} to weed out the most
// Since we don't have a guarantee that {value} is the correct value of the
// property, we use the expected {representation} to weed out the most
// egregious types of wrong values. // egregious types of wrong values.
if (!value->object()->FitsRepresentation(representation)) { if (!constant->FitsRepresentation(representation)) {
TRACE_BROKER_MISSING( TRACE_BROKER_MISSING(
broker, "Mismatch between representation and value in " << holder); broker, "Mismatch between representation and value in " << holder);
return {}; return {};
} }
} }
// Now that we can safely inspect the property, it may need to be wrapped. // Now that we can safely inspect the constant, it may need to be wrapped.
Handle<Object> value = broker->CanonicalPersistentHandle(constant.value());
Handle<Object> possibly_wrapped = Object::WrapForRead<AllocationType::kOld>( Handle<Object> possibly_wrapped = Object::WrapForRead<AllocationType::kOld>(
broker->local_isolate_or_isolate(), value->object(), representation); broker->local_isolate_or_isolate(), value, representation);
// MakeRef will always succeed, because all that happened was we either got // MakeRef will always succeed, because either {possibly_wrapped} is {value}
// back a handle identical to {constant} above, or we allocated a handle // or we allocated a HeapNumber via the local isolate, which is thus
// on the local isolate, and objects allocated on the background thread // guaranteed to pass the gc predicate.
// are guaranteed to pass the gc predicate.
return MakeRef(broker, *possibly_wrapped); return MakeRef(broker, *possibly_wrapped);
} }
......
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