Further reduce LookupResult usage
authorverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 20 Aug 2014 15:08:20 +0000 (15:08 +0000)
committerverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 20 Aug 2014 15:08:20 +0000 (15:08 +0000)
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
src/hydrogen-instructions.cc
src/hydrogen-instructions.h
src/hydrogen.cc
src/ic.cc

index 8715f66..dbbe0ea 100644 (file)
@@ -2447,11 +2447,10 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
           break;
         }
         case CALLBACKS: {
-          LookupResult result(isolate());
-          Handle<Name> key(Name::cast(descs->GetKey(i)), isolate());
-          to->LookupOwn(key, &result);
+          Handle<Name> 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<JSObject> from,
       if (properties->IsKey(raw_key)) {
         DCHECK(raw_key->IsName());
         // If the property is already there we skip it.
-        LookupResult result(isolate());
         Handle<Name> 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<Object> value = Handle<Object>(properties->ValueAt(i),
                                               isolate());
index 6eb7306..5b5386b 100644 (file)
@@ -4642,24 +4642,9 @@ HObjectAccess HObjectAccess::ForBackingStoreOffset(int offset,
 }
 
 
-HObjectAccess HObjectAccess::ForField(Handle<Map> map,
-                                      LookupResult* lookup,
+HObjectAccess HObjectAccess::ForField(Handle<Map> map, int index,
+                                      Representation representation,
                                       Handle<String> 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.
index ed12435..4c29e34 100644 (file)
@@ -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> map,
-      LookupResult *lookup, Handle<String> name = Handle<String>::null());
+  static HObjectAccess ForField(Handle<Map> map, int index,
+                                Representation representation,
+                                Handle<String> name);
 
   // Create an access for the payload of a Cell or JSGlobalPropertyCell.
   static HObjectAccess ForCellPayload(Isolate* isolate);
index 6096c24..59d3bb9 100644 (file)
@@ -5977,7 +5977,9 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadResult(Handle<Map> 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());
index b080a31..fdad0ca 100644 (file)
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -278,11 +278,10 @@ bool IC::TryRemoveInvalidPrototypeDependentStub(Handle<Object> 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<GlobalObject> global = Handle<GlobalObject>::cast(receiver);
+    LookupIterator it(global, name, LookupIterator::CHECK_PROPERTY);
+    if (!it.IsFound() || !it.HasProperty()) return false;
+    Handle<PropertyCell> cell = it.GetPropertyCell();
     return cell->type()->IsConstant();
   }