Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Unified Diff: src/hydrogen.cc

Issue 14796012: Turn polymorphic stores monomorphic if store sequence matches. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/property-details.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 58a9b78750bb7401bfdc9e167800f8f01d3ef078..541e9b90dfa5ac658f3ed99f197e14646819f4e7 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -7192,6 +7192,51 @@ void HOptimizedGraphBuilder::HandlePolymorphicStoreNamedField(
HValue* value,
SmallMapList* types,
Handle<String> name) {
+ if (types->length() <= kMaxStorePolymorphism) {
+ int previous_field_offset = 0;
+ bool previous_field_is_in_object = false;
+ Representation previous_representation = Representation::None();
+
+ Handle<Map> map;
+ LookupResult lookup(isolate());
+ int count;
+ for (count = 0; count < types->length(); ++count) {
+ map = types->at(count);
+ if (!ComputeLoadStoreField(map, name, &lookup, false) ||
+ lookup.IsTransition()) {
+ break;
+ }
+ Representation representation = lookup.representation();
+ int index = ComputeLoadStoreFieldIndex(map, &lookup);
+ bool is_in_object = index < 0;
+ int offset = index * kPointerSize;
+ if (index < 0) {
+ offset += map->instance_size();
+ } else {
+ offset += FixedArray::kHeaderSize;
+ }
+ if (count == 0) {
+ previous_field_offset = offset;
+ previous_field_is_in_object = is_in_object;
+ previous_representation = representation;
+ } else if (offset != previous_field_offset ||
+ is_in_object != previous_field_is_in_object ||
+ !representation.IsCompatibleForStore(
+ previous_representation)) {
+ break;
+ }
+ }
+
+ if (types->length() == count) {
+ AddInstruction(new(zone()) HCheckNonSmi(object));
+ AddInstruction(HCheckMaps::New(object, types, zone()));
+ HInstruction* instr = BuildStoreNamedField(
+ object, name, value, map, &lookup);
+ instr->set_position(expr->position());
+ return ast_context()->ReturnInstruction(instr, expr->id());
+ }
+ }
+
// TODO(ager): We should recognize when the prototype chains for different
// maps are identical. In that case we can avoid repeatedly generating the
// same prototype map checks.
« no previous file with comments | « no previous file | src/property-details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698