Reviewers: Jakob,

Description:
Improve handling of property loads on the proto chain.

Previously Crankshaft emitted a generic load for these, now we emit a
load of a named field, guarded by a proto chain check.


Please review this at http://codereview.chromium.org/11338030/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/hydrogen.cc


Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index b705a24686f84dd1d447fab459098616a0124b05..e24831dae6d27d1fca10afadd2c6678597dff479 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -6009,7 +6009,7 @@ HInstruction* HGraphBuilder::BuildLoadNamedMonomorphic(HValue* object,
                                                        Handle<String> name,
                                                        Property* expr,
                                                        Handle<Map> map) {
-  // Handle a load from a known field.
+  // Handle a load from a known field in the receiver.
   ASSERT(!map->is_dictionary_map());
   LookupResult lookup(isolate());
   map->LookupDescriptor(NULL, *name, &lookup);
@@ -6025,6 +6025,16 @@ HInstruction* HGraphBuilder::BuildLoadNamedMonomorphic(HValue* object,
     return new(zone()) HConstant(function, Representation::Tagged());
   }

+  // Handle a load from a known field somewhere in the protoype chain.
+  LookupInPrototypes(map, name, &lookup);
+  if (lookup.IsField()) {
+    Handle<JSObject> holder(lookup.holder());
+    AddCheckMapsWithTransitions(object, map);
+    AddInstruction(new(zone()) HCheckPrototypeMaps(
+        Handle<JSObject>(JSObject::cast(map->prototype())), holder));
+    return BuildLoadNamedField(object, map, &lookup);
+  }
+
   // No luck, do a generic load.
   return BuildLoadNamedGeneric(object, name, expr);
 }


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to