From 21b9394c41090f11ca757a3b9f4fff7096db1b08 Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Wed, 20 Aug 2014 15:08:20 +0000 Subject: [PATCH] Further reduce LookupResult usage BUG= R=yangguo@chromium.org Review URL: https://codereview.chromium.org/488073002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23245 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/bootstrapper.cc | 12 +++++------- src/hydrogen-instructions.cc | 19 ++----------------- src/hydrogen-instructions.h | 5 +++-- src/hydrogen.cc | 13 +++++++++++-- src/ic.cc | 9 ++++----- 5 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 8715f66..dbbe0ea 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -2447,11 +2447,10 @@ void Genesis::TransferNamedProperties(Handle from, break; } case CALLBACKS: { - LookupResult result(isolate()); - Handle key(Name::cast(descs->GetKey(i)), isolate()); - to->LookupOwn(key, &result); + Handle key(descs->GetKey(i)); + LookupIterator it(to, key, LookupIterator::CHECK_PROPERTY); // If the property is already there we skip it - if (result.IsFound()) continue; + if (it.IsFound() && it.HasProperty()) continue; HandleScope inner(isolate()); DCHECK(!to->HasFastProperties()); // Add to dictionary. @@ -2480,10 +2479,9 @@ void Genesis::TransferNamedProperties(Handle from, if (properties->IsKey(raw_key)) { DCHECK(raw_key->IsName()); // If the property is already there we skip it. - LookupResult result(isolate()); Handle key(Name::cast(raw_key)); - to->LookupOwn(key, &result); - if (result.IsFound()) continue; + LookupIterator it(to, key, LookupIterator::CHECK_PROPERTY); + if (it.IsFound() && it.HasProperty()) continue; // Set the property. Handle value = Handle(properties->ValueAt(i), isolate()); diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 6eb7306..5b5386b 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -4642,24 +4642,9 @@ HObjectAccess HObjectAccess::ForBackingStoreOffset(int offset, } -HObjectAccess HObjectAccess::ForField(Handle map, - LookupResult* lookup, +HObjectAccess HObjectAccess::ForField(Handle map, int index, + Representation representation, Handle name) { - DCHECK(lookup->IsField() || lookup->IsTransitionToField()); - int index; - Representation representation; - if (lookup->IsField()) { - index = lookup->GetLocalFieldIndexFromMap(*map); - representation = lookup->representation(); - } else { - Map* transition = lookup->GetTransitionTarget(); - int descriptor = transition->LastAdded(); - index = transition->instance_descriptors()->GetFieldIndex(descriptor) - - map->inobject_properties(); - PropertyDetails details = - transition->instance_descriptors()->GetDetails(descriptor); - representation = details.representation(); - } if (index < 0) { // Negative property indices are in-object properties, indexed // from the end of the fixed part of the object. diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index ed12435..4c29e34 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -6192,8 +6192,9 @@ class HObjectAccess V8_FINAL { Representation representation = Representation::Tagged()); // Create an access to a resolved field (in-object or backing store). - static HObjectAccess ForField(Handle map, - LookupResult *lookup, Handle name = Handle::null()); + static HObjectAccess ForField(Handle map, int index, + Representation representation, + Handle name); // Create an access for the payload of a Cell or JSGlobalPropertyCell. static HObjectAccess ForCellPayload(Isolate* isolate); diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 6096c24..59d3bb9 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -5977,7 +5977,9 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadResult(Handle map) { if (lookup_.IsField()) { // Construct the object field access. - access_ = HObjectAccess::ForField(map, &lookup_, name_); + int index = lookup_.GetLocalFieldIndexFromMap(*map); + Representation representation = lookup_.representation(); + access_ = HObjectAccess::ForField(map, index, representation, name_); // Load field map for heap objects. LoadFieldMaps(map); @@ -6087,7 +6089,14 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::CanAccessMonomorphic() { map->LookupTransition(NULL, *name_, &lookup_); if (lookup_.IsTransitionToField() && map->unused_property_fields() > 0) { // Construct the object field access. - access_ = HObjectAccess::ForField(map, &lookup_, name_); + int descriptor = transition()->LastAdded(); + int index = + transition()->instance_descriptors()->GetFieldIndex(descriptor) - + map->inobject_properties(); + PropertyDetails details = + transition()->instance_descriptors()->GetDetails(descriptor); + Representation representation = details.representation(); + access_ = HObjectAccess::ForField(map, index, representation, name_); // Load field map for heap objects. LoadFieldMaps(transition()); diff --git a/src/ic.cc b/src/ic.cc index b080a31..fdad0ca 100644 --- a/src/ic.cc +++ b/src/ic.cc @@ -278,11 +278,10 @@ bool IC::TryRemoveInvalidPrototypeDependentStub(Handle receiver, } if (receiver->IsGlobalObject()) { - LookupResult lookup(isolate()); - GlobalObject* global = GlobalObject::cast(*receiver); - global->LookupOwnRealNamedProperty(name, &lookup); - if (!lookup.IsFound()) return false; - PropertyCell* cell = global->GetPropertyCell(&lookup); + Handle global = Handle::cast(receiver); + LookupIterator it(global, name, LookupIterator::CHECK_PROPERTY); + if (!it.IsFound() || !it.HasProperty()) return false; + Handle cell = it.GetPropertyCell(); return cell->type()->IsConstant(); } -- 2.7.4