Reduce field type tracking to a single stable map per field.

BUG=

Review URL: https://codereview.chromium.org/930983003

Cr-Commit-Position: refs/heads/master@{#26679}
This commit is contained in:
verwaest 2015-02-17 00:57:54 -08:00 committed by Commit bot
parent 305c73477c
commit 839efa2e26
3 changed files with 3 additions and 16 deletions

View File

@ -2326,18 +2326,8 @@ void Map::UpdateFieldType(int descriptor, Handle<Name> name,
Handle<HeapType> Map::GeneralizeFieldType(Handle<HeapType> type1, Handle<HeapType> Map::GeneralizeFieldType(Handle<HeapType> type1,
Handle<HeapType> type2, Handle<HeapType> type2,
Isolate* isolate) { Isolate* isolate) {
static const int kMaxClassesPerFieldType = 5;
if (type1->NowIs(type2)) return type2; if (type1->NowIs(type2)) return type2;
if (type2->NowIs(type1)) return type1; if (type2->NowIs(type1)) return type1;
if (type1->NowStable() && type2->NowStable()) {
Handle<HeapType> type = HeapType::Union(type1, type2, isolate);
if (type->NumClasses() <= kMaxClassesPerFieldType) {
DCHECK(type->NowStable());
DCHECK(type1->NowIs(type));
DCHECK(type2->NowIs(type));
return type;
}
}
return HeapType::Any(isolate); return HeapType::Any(isolate);
} }

View File

@ -575,10 +575,7 @@ bool TypeImpl<Config>::NowIs(TypeImpl* that) {
template<class Config> template<class Config>
bool TypeImpl<Config>::NowStable() { bool TypeImpl<Config>::NowStable() {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
for (Iterator<i::Map> it = this->Classes(); !it.Done(); it.Advance()) { return !this->IsClass() || this->AsClass()->Map()->is_stable();
if (!it.Current()->is_stable()) return false;
}
return true;
} }

View File

@ -694,7 +694,7 @@ TEST(GeneralizeRepresentationHeapObjectToHeapObject) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Handle<HeapType> any_type = HeapType::Any(isolate); Handle<HeapType> any_type = HeapType::Any(isolate);
const int kMaxClassesPerFieldType = 5; const int kMaxClassesPerFieldType = 1;
Handle<HeapType> current_type = Handle<HeapType> current_type =
HeapType::Class(Map::Create(isolate, 0), isolate); HeapType::Class(Map::Create(isolate, 0), isolate);
@ -1070,7 +1070,7 @@ TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjToHeapObj) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Handle<HeapType> any_type = HeapType::Any(isolate); Handle<HeapType> any_type = HeapType::Any(isolate);
const int kMaxClassesPerFieldType = 5; const int kMaxClassesPerFieldType = 1;
Handle<HeapType> current_type = Handle<HeapType> current_type =
HeapType::Class(Map::Create(isolate, 0), isolate); HeapType::Class(Map::Create(isolate, 0), isolate);