Improve handling of property loads on the proto chain. (issue 11338030)

10 views
Skip to first unread message

sven...@chromium.org

unread,
Oct 30, 2012, 3:49:37 AM10/30/12
to jkum...@chromium.org, v8-...@googlegroups.com
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);
}


sven...@chromium.org

unread,
Oct 31, 2012, 6:13:41 AM10/31/12
to jkum...@chromium.org, v8-...@googlegroups.com
Shiny new version of this CL, now with improved holder handling! :-P

http://codereview.chromium.org/11338030/

jkum...@chromium.org

unread,
Oct 31, 2012, 9:44:28 AM10/31/12
to sven...@chromium.org, v8-...@googlegroups.com
LGTM.

I'm not too happy with the fact that "{H,L}CheckPrototypeMaps" are now doing
more than just checking something, but I don't have a good proposal for a
better
name -- HCheckPrototypeMapsAndReturnHolder would be a bit clunky.

http://codereview.chromium.org/11338030/
Reply all
Reply to author
Forward
0 new messages