Commit 1725efdc authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[lookup] Optimize TryLookupCachedProperty

If the accessor pair is available, thread it through to the
TryLookupCachedProperty function rather than looking it up again.

On a simple microbenchmark[0] with --no-opt and --no-use-ic this
provides a 5-10% improvement.

[0]: https://gist.github.com/gsathya/c47da0a15be08062c12cda9b0887de3d

Bug: v8:9805
Change-Id: I5b2d0c5e27c49a1d39a99dc63c3b0809bca4d6a7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2685178Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Sathya Gunasekaran  <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72675}
parent 1b81ffb1
......@@ -862,13 +862,14 @@ Handle<Object> LoadIC::ComputeHandler(LookupIterator* lookup) {
Handle<Object> accessors = lookup->GetAccessors();
if (accessors->IsAccessorPair()) {
if (lookup->TryLookupCachedProperty()) {
Handle<AccessorPair> accessor_pair =
Handle<AccessorPair>::cast(accessors);
if (lookup->TryLookupCachedProperty(accessor_pair)) {
DCHECK_EQ(LookupIterator::DATA, lookup->state());
return ComputeHandler(lookup);
}
Handle<Object> getter(AccessorPair::cast(*accessors).getter(),
isolate());
Handle<Object> getter(accessor_pair->getter(), isolate());
if (!getter->IsJSFunction() && !getter->IsFunctionTemplateInfo()) {
TRACE_HANDLER_STATS(isolate(), LoadIC_SlowStub);
return LoadHandler::LoadSlow(isolate());
......
......@@ -1234,17 +1234,24 @@ Handle<InterceptorInfo> LookupIterator::GetInterceptorForFailedAccessCheck()
return Handle<InterceptorInfo>();
}
bool LookupIterator::TryLookupCachedProperty(Handle<AccessorPair> accessor) {
DCHECK_EQ(state(), LookupIterator::ACCESSOR);
return LookupCachedProperty(accessor);
}
bool LookupIterator::TryLookupCachedProperty() {
return state() == LookupIterator::ACCESSOR &&
GetAccessors()->IsAccessorPair(isolate_) && LookupCachedProperty();
if (state() != LookupIterator::ACCESSOR) return false;
Handle<Object> accessor_pair = GetAccessors();
return accessor_pair->IsAccessorPair(isolate_) &&
LookupCachedProperty(Handle<AccessorPair>::cast(accessor_pair));
}
bool LookupIterator::LookupCachedProperty() {
bool LookupIterator::LookupCachedProperty(Handle<AccessorPair> accessor_pair) {
DCHECK_EQ(state(), LookupIterator::ACCESSOR);
DCHECK(GetAccessors()->IsAccessorPair(isolate_));
AccessorPair accessor_pair = AccessorPair::cast(*GetAccessors());
Handle<Object> getter(accessor_pair.getter(isolate_), isolate());
Handle<Object> getter(accessor_pair->getter(isolate_), isolate());
MaybeHandle<Name> maybe_name =
FunctionTemplateInfo::TryGetCachedPropertyName(isolate(), getter);
if (maybe_name.is_null()) return false;
......
......@@ -190,12 +190,13 @@ class V8_EXPORT_PRIVATE LookupIterator final {
// Lookup a 'cached' private property for an accessor.
// If not found returns false and leaves the LookupIterator unmodified.
bool TryLookupCachedProperty(Handle<AccessorPair> accessor);
bool TryLookupCachedProperty();
bool LookupCachedProperty();
private:
static const size_t kInvalidIndex = std::numeric_limits<size_t>::max();
bool LookupCachedProperty(Handle<AccessorPair> accessor);
inline LookupIterator(Isolate* isolate, Handle<Object> receiver,
Handle<Name> name, size_t index,
Handle<Object> lookup_start_object,
......
......@@ -1482,13 +1482,14 @@ MaybeHandle<Object> Object::GetPropertyWithAccessor(LookupIterator* it) {
return reboxed_result;
}
Handle<AccessorPair> accessor_pair = Handle<AccessorPair>::cast(structure);
// AccessorPair with 'cached' private property.
if (it->TryLookupCachedProperty()) {
if (it->TryLookupCachedProperty(accessor_pair)) {
return Object::GetProperty(it);
}
// Regular accessor.
Handle<Object> getter(AccessorPair::cast(*structure).getter(), isolate);
Handle<Object> getter(accessor_pair->getter(), isolate);
if (getter->IsFunctionTemplateInfo()) {
SaveAndSwitchContext save(isolate, *holder->GetCreationContext());
return Builtins::InvokeApiFunction(
......
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