[runtime] Change return type of TransitionsAccessor::FindTransitionToField().

... to MaybeHandle<Map> and add TransitionsAccessor::FindTransitionToDataProperty()
which will be used in follow-up CLs.

Bug: v8:7310
Change-Id: I98cc4fe16dc1ef335885101aa457f27c90ecf1a4
Reviewed-on: https://chromium-review.googlesource.com/968222
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52018}
This commit is contained in:
Igor Sheludko 2018-03-19 09:44:44 +01:00 committed by Commit Bot
parent 9b07e2ee3f
commit 65c54c7ac8
4 changed files with 22 additions and 11 deletions

View File

@ -419,9 +419,10 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() {
key = ParseJsonString();
if (key.is_null()) return ReportUnexpectedCharacter();
target = TransitionsAccessor(map).FindTransitionToField(key);
// If a transition was found, follow it and continue.
transitioning = !target.is_null();
transitioning =
TransitionsAccessor(map).FindTransitionToField(key).ToHandle(
&target);
}
if (c0_ != ':') return ReportUnexpectedCharacter();

View File

@ -303,15 +303,19 @@ bool TransitionsAccessor::IsSpecialTransition(Name* name) {
name == heap->strict_function_transition_symbol();
}
Handle<Map> TransitionsAccessor::FindTransitionToField(Handle<Name> name) {
MaybeHandle<Map> TransitionsAccessor::FindTransitionToDataProperty(
Handle<Name> name, RequestedLocation requested_location) {
DCHECK(name->IsUniqueName());
DisallowHeapAllocation no_gc;
Map* target = SearchTransition(*name, kData, NONE);
if (target == nullptr) return Handle<Map>::null();
PropertyAttributes attributes = name->IsPrivate() ? DONT_ENUM : NONE;
Map* target = SearchTransition(*name, kData, attributes);
if (target == nullptr) return MaybeHandle<Map>();
PropertyDetails details = target->GetLastDescriptorDetails();
DCHECK_EQ(NONE, details.attributes());
if (details.location() != kField) return Handle<Map>::null();
DCHECK_EQ(attributes, details.attributes());
DCHECK_EQ(kData, details.kind());
if (requested_location == kFieldOnly && details.location() != kField) {
return MaybeHandle<Map>();
}
return Handle<Map>(target);
}

View File

@ -67,7 +67,13 @@ class TransitionsAccessor {
// or frozen/sealed transitions.
static bool IsSpecialTransition(Name* name);
Handle<Map> FindTransitionToField(Handle<Name> name);
enum RequestedLocation { kAnyLocation, kFieldOnly };
MaybeHandle<Map> FindTransitionToDataProperty(
Handle<Name> name, RequestedLocation requested_location = kAnyLocation);
MaybeHandle<Map> FindTransitionToField(Handle<Name> name) {
return FindTransitionToDataProperty(name, kFieldOnly);
}
Handle<String> ExpectedTransitionKey();
Handle<Map> ExpectedTransitionTarget();

View File

@ -1913,9 +1913,9 @@ Maybe<uint32_t> ValueDeserializer::ReadJSObjectProperties(
key =
isolate_->factory()->InternalizeString(Handle<String>::cast(key));
// Don't reuse |transitions| because it could be stale.
target = TransitionsAccessor(map).FindTransitionToField(
Handle<String>::cast(key));
transitioning = !target.is_null();
transitioning = TransitionsAccessor(map)
.FindTransitionToField(Handle<String>::cast(key))
.ToHandle(&target);
} else {
transitioning = false;
}