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

Unified Diff: src/hydrogen.cc

Issue 239923004: Allow merging of monomorphic accesses to tracked fields. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 6 years, 8 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 | « src/hydrogen.h ('k') | src/hydrogen-check-elimination.cc » ('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 1b70767eee39444a8d7cecfd6c8b9775b09110e6..7a9dc90cc43e18d317324fcab7a35600edc2c77a 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -5370,7 +5370,7 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedField(
access = HObjectAccess::ForHeapNumberValue();
}
return New<HLoadNamedField>(
- checked_object, static_cast<HValue*>(NULL), access, info->field_map());
+ checked_object, checked_object, access, info->field_maps(), top_info());
}
@@ -5414,10 +5414,15 @@ HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField(
value, STORE_TO_INITIALIZED_ENTRY);
}
} else {
- if (!info->field_map().is_null()) {
+ if (!info->field_maps()->is_empty()) {
ASSERT(field_access.representation().IsHeapObject());
BuildCheckHeapObject(value);
- value = BuildCheckMap(value, info->field_map());
+ if (info->field_maps()->length() == 1) {
+ // TODO(bmeurer): Also apply stable maps optimization to the else case!
+ value = BuildCheckMap(value, info->field_maps()->first());
+ } else {
+ value = Add<HCheckMaps>(value, info->field_maps());
+ }
// TODO(bmeurer): This is a dirty hack to avoid repeating the smi check
// that was already performed by the HCheckHeapObject above in the
@@ -5489,11 +5494,24 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::IsCompatible(
}
if (info->access_.offset() != access_.offset()) return false;
if (info->access_.IsInobject() != access_.IsInobject()) return false;
- if (!field_map_.is_identical_to(info->field_map_)) {
- if (!IsLoad()) return false;
-
- // Throw away type information for merging polymorphic loads.
- info->field_map_ = Handle<Map>::null();
+ if (IsLoad()) {
+ if (field_maps_.is_empty()) {
+ info->field_maps_.Clear();
+ } else if (!info->field_maps_.is_empty()) {
+ for (int i = 0; i < field_maps_.length(); ++i) {
+ info->field_maps_.AddMapIfMissing(field_maps_.at(i), info->zone());
+ }
+ info->field_maps_.Sort();
+ }
+ } else {
+ // We can only merge stores that agree on their field maps. The comparison
+ // below is safe, since we keep the field maps sorted.
+ if (field_maps_.length() != info->field_maps_.length()) return false;
+ for (int i = 0; i < field_maps_.length(); ++i) {
+ if (!field_maps_.at(i).is_identical_to(info->field_maps_.at(i))) {
+ return false;
+ }
+ }
}
info->GeneralizeRepresentation(r);
return true;
@@ -5518,7 +5536,7 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadResult(Handle<Map> map) {
access_ = HObjectAccess::ForField(map, &lookup_, name_);
// Load field map for heap objects.
- LoadFieldMap(map);
+ LoadFieldMaps(map);
} else if (lookup_.IsPropertyCallbacks()) {
Handle<Object> callback(lookup_.GetValueFromMap(*map), isolate());
if (!callback->IsAccessorPair()) return false;
@@ -5545,26 +5563,36 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadResult(Handle<Map> map) {
}
-void HOptimizedGraphBuilder::PropertyAccessInfo::LoadFieldMap(Handle<Map> map) {
- // Clear any previous field map.
- field_map_ = Handle<Map>::null();
-
+void HOptimizedGraphBuilder::PropertyAccessInfo::LoadFieldMaps(
+ Handle<Map> map) {
// Figure out the field type from the accessor map.
- HeapType* field_type = lookup_.GetFieldTypeFromMap(*map);
- if (field_type->IsClass()) {
- ASSERT(access_.representation().IsHeapObject());
- Handle<Map> field_map = field_type->AsClass();
- if (field_map->is_stable()) {
- field_map_ = field_map;
- Map::AddDependentCompilationInfo(
- field_map_, DependentCode::kPrototypeCheckGroup, top_info());
+ Handle<HeapType> field_type(lookup_.GetFieldTypeFromMap(*map), isolate());
- // Add dependency on the map that introduced the field.
- Map::AddDependentCompilationInfo(
- handle(lookup_.GetFieldOwnerFromMap(*map), isolate()),
- DependentCode::kFieldTypeGroup, top_info());
+ // Collect the (stable) maps from the field type.
+ int num_field_maps = field_type->NumClasses();
+ if (num_field_maps == 0) {
+ field_maps_.Clear();
+ return;
+ }
+ ASSERT(access_.representation().IsHeapObject());
+ field_maps_.Reserve(num_field_maps, zone());
+ HeapType::Iterator<Map> it = field_type->Classes();
+ while (!it.Done()) {
+ Handle<Map> field_map = it.Current();
+ if (!field_map->is_stable()) {
+ field_maps_.Clear();
+ return;
}
+ field_maps_.Add(field_map, zone());
+ it.Advance();
}
+ field_maps_.Sort();
+ ASSERT_EQ(num_field_maps, field_maps_.length());
+
+ // Add dependency on the map that introduced the field.
+ Map::AddDependentCompilationInfo(
+ handle(lookup_.GetFieldOwnerFromMap(*map), isolate()),
+ DependentCode::kFieldTypeGroup, top_info());
}
@@ -5608,7 +5636,7 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::CanAccessMonomorphic() {
access_ = HObjectAccess::ForField(map, &lookup_, name_);
// Load field map for heap objects.
- LoadFieldMap(transition());
+ LoadFieldMaps(transition());
return true;
}
return false;
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-check-elimination.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698