Revision: 15569
Author: [email protected]
Date: Tue Jul 9 02:59:23 2013
Log: Add support to turn polymorphic loads from the same prototype
into a monomorphic load.
[email protected]
Review URL: https://chromiumcodereview.appspot.com/18887002
http://code.google.com/p/v8/source/detail?r=15569
Modified:
/branches/bleeding_edge/src/hydrogen.cc
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Mon Jul 8 08:00:12 2013
+++ /branches/bleeding_edge/src/hydrogen.cc Tue Jul 9 02:59:23 2013
@@ -4978,12 +4978,45 @@
representation = representation.generalize(new_representation);
}
- if (count != types->length()) return NULL;
+ if (count == types->length()) {
+ // Everything matched; can use monomorphic load.
+ BuildCheckHeapObject(object);
+ AddInstruction(HCheckMaps::New(object, types, zone()));
+ return BuildLoadNamedField(object, access, representation);
+ }
- // Everything matched; can use monomorphic load.
+ if (count != 0) return NULL;
+
+ // Second chance: the property is on the prototype and all maps have the
+ // same prototype.
+ Handle<Map> map(types->at(0));
+ if (map->has_named_interceptor()) return NULL;
+ if (map->is_dictionary_map()) return NULL;
+
+ Handle<Object> prototype(map->prototype(), isolate());
+ for (count = 1; count < types->length(); ++count) {
+ Handle<Map> test_map(types->at(count));
+ // Ensure the property is on the prototype, not the object itself.
+ if (map->has_named_interceptor()) return NULL;
+ if (test_map->is_dictionary_map()) return NULL;
+ test_map->LookupDescriptor(NULL, *name, &lookup);
+ if (lookup.IsFound()) return NULL;
+ if (test_map->prototype() != *prototype) return NULL;
+ }
+
+ LookupInPrototypes(map, name, &lookup);
+ if (!lookup.IsField()) return NULL;
+
BuildCheckHeapObject(object);
AddInstruction(HCheckMaps::New(object, types, zone()));
- return BuildLoadNamedField(object, access, representation);
+ Handle<JSObject> holder(lookup.holder());
+ Handle<Map> holder_map(holder->map());
+ AddInstruction(new(zone()) HCheckPrototypeMaps(
+ Handle<JSObject>::cast(prototype), holder, zone(), top_info()));
+ HValue* holder_value = AddInstruction(new(zone()) HConstant(holder));
+ return BuildLoadNamedField(holder_value,
+ HObjectAccess::ForField(holder_map, &lookup, name),
+ ComputeLoadStoreRepresentation(map, &lookup));
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.