Commit 639288e1 authored by jarin's avatar jarin Committed by Commit bot

Remove FieldType::Iterator.

Field types can contain at most one map, so we can just use IsClass().

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

Cr-Commit-Position: refs/heads/master@{#33533}
parent a5451ec6
...@@ -6363,19 +6363,11 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadFieldMaps( ...@@ -6363,19 +6363,11 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadFieldMaps(
Handle<FieldType> field_type = GetFieldTypeFromMap(map); Handle<FieldType> field_type = GetFieldTypeFromMap(map);
// Collect the (stable) maps from the field type. // Collect the (stable) maps from the field type.
int num_field_maps = field_type->ClassCount(); if (field_type->IsClass()) {
if (num_field_maps > 0) {
DCHECK(access_.representation().IsHeapObject()); DCHECK(access_.representation().IsHeapObject());
field_maps_.Reserve(num_field_maps, zone()); Handle<Map> field_map = field_type->AsClass();
FieldType::Iterator it = field_type->Classes(); if (field_map->is_stable()) {
while (!it.Done()) {
Handle<Map> field_map = it.Current();
if (!field_map->is_stable()) {
field_maps_.Clear();
break;
}
field_maps_.Add(field_map, zone()); field_maps_.Add(field_map, zone());
it.Advance();
} }
} }
...@@ -6384,9 +6376,6 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadFieldMaps( ...@@ -6384,9 +6376,6 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadFieldMaps(
return IsLoad() || !field_type->IsNone(); return IsLoad() || !field_type->IsNone();
} }
field_maps_.Sort();
DCHECK_EQ(num_field_maps, field_maps_.length());
// Determine field HType from field type. // Determine field HType from field type.
field_type_ = HType::FromFieldType(field_type, zone()); field_type_ = HType::FromFieldType(field_type, zone());
DCHECK(field_type_.IsHeapObject()); DCHECK(field_type_.IsHeapObject());
......
...@@ -402,20 +402,11 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type, ...@@ -402,20 +402,11 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type,
DCHECK(!value_reg.is(map_reg)); DCHECK(!value_reg.is(map_reg));
DCHECK(!value_reg.is(scratch)); DCHECK(!value_reg.is(scratch));
__ JumpIfSmi(value_reg, miss_label); __ JumpIfSmi(value_reg, miss_label);
FieldType::Iterator it = field_type->Classes(); if (field_type->IsClass()) {
if (!it.Done()) {
__ ldr(map_reg, FieldMemOperand(value_reg, HeapObject::kMapOffset)); __ ldr(map_reg, FieldMemOperand(value_reg, HeapObject::kMapOffset));
Label do_store; __ CmpWeakValue(map_reg, Map::WeakCellForMap(field_type->AsClass()),
while (true) { scratch);
__ CmpWeakValue(map_reg, Map::WeakCellForMap(it.Current()), scratch); __ b(ne, miss_label);
it.Advance();
if (it.Done()) {
__ b(ne, miss_label);
break;
}
__ b(eq, &do_store);
}
__ bind(&do_store);
} }
} }
......
...@@ -449,20 +449,11 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type, ...@@ -449,20 +449,11 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type,
DCHECK(!value_reg.is(map_reg)); DCHECK(!value_reg.is(map_reg));
DCHECK(!value_reg.is(scratch)); DCHECK(!value_reg.is(scratch));
__ JumpIfSmi(value_reg, miss_label); __ JumpIfSmi(value_reg, miss_label);
FieldType::Iterator it = field_type->Classes(); if (field_type->IsClass()) {
if (!it.Done()) {
__ Ldr(map_reg, FieldMemOperand(value_reg, HeapObject::kMapOffset)); __ Ldr(map_reg, FieldMemOperand(value_reg, HeapObject::kMapOffset));
Label do_store; __ CmpWeakValue(map_reg, Map::WeakCellForMap(field_type->AsClass()),
while (true) { scratch);
__ CmpWeakValue(map_reg, Map::WeakCellForMap(it.Current()), scratch); __ B(ne, miss_label);
it.Advance();
if (it.Done()) {
__ B(ne, miss_label);
break;
}
__ B(eq, &do_store);
}
__ Bind(&do_store);
} }
} }
......
...@@ -511,7 +511,7 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreTransition( ...@@ -511,7 +511,7 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreTransition(
bool NamedStoreHandlerCompiler::RequiresFieldTypeChecks( bool NamedStoreHandlerCompiler::RequiresFieldTypeChecks(
FieldType* field_type) const { FieldType* field_type) const {
return !field_type->Classes().Done(); return field_type->IsClass();
} }
......
...@@ -407,20 +407,11 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type, ...@@ -407,20 +407,11 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type,
DCHECK(!value_reg.is(map_reg)); DCHECK(!value_reg.is(map_reg));
DCHECK(!value_reg.is(scratch)); DCHECK(!value_reg.is(scratch));
__ JumpIfSmi(value_reg, miss_label); __ JumpIfSmi(value_reg, miss_label);
FieldType::Iterator it = field_type->Classes(); if (field_type->IsClass()) {
if (!it.Done()) {
Label do_store;
__ mov(map_reg, FieldOperand(value_reg, HeapObject::kMapOffset)); __ mov(map_reg, FieldOperand(value_reg, HeapObject::kMapOffset));
while (true) { __ CmpWeakValue(map_reg, Map::WeakCellForMap(field_type->AsClass()),
__ CmpWeakValue(map_reg, Map::WeakCellForMap(it.Current()), scratch); scratch);
it.Advance(); __ j(not_equal, miss_label);
if (it.Done()) {
__ j(not_equal, miss_label);
break;
}
__ j(equal, &do_store, Label::kNear);
}
__ bind(&do_store);
} }
} }
......
...@@ -1798,8 +1798,7 @@ Handle<Code> StoreIC::CompileHandler(LookupIterator* lookup, ...@@ -1798,8 +1798,7 @@ Handle<Code> StoreIC::CompileHandler(LookupIterator* lookup,
if (lookup->representation().IsHeapObject()) { if (lookup->representation().IsHeapObject()) {
// Only use a generic stub if no types need to be tracked. // Only use a generic stub if no types need to be tracked.
Handle<FieldType> field_type = lookup->GetFieldType(); Handle<FieldType> field_type = lookup->GetFieldType();
FieldType::Iterator it = field_type->Classes(); use_stub = !field_type->IsClass();
use_stub = it.Done();
} }
if (use_stub) { if (use_stub) {
StoreFieldStub stub(isolate(), lookup->GetFieldIndex(), StoreFieldStub stub(isolate(), lookup->GetFieldIndex(),
......
...@@ -391,21 +391,11 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type, ...@@ -391,21 +391,11 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type,
DCHECK(!value_reg.is(map_reg)); DCHECK(!value_reg.is(map_reg));
DCHECK(!value_reg.is(scratch)); DCHECK(!value_reg.is(scratch));
__ JumpIfSmi(value_reg, miss_label); __ JumpIfSmi(value_reg, miss_label);
FieldType::Iterator it = field_type->Classes(); if (field_type->IsClass()) {
if (!it.Done()) {
__ lw(map_reg, FieldMemOperand(value_reg, HeapObject::kMapOffset)); __ lw(map_reg, FieldMemOperand(value_reg, HeapObject::kMapOffset));
Label do_store; // Compare map directly within the Branch() functions.
while (true) { __ GetWeakValue(scratch, Map::WeakCellForMap(field_type->AsClass()));
// Compare map directly within the Branch() functions. __ Branch(miss_label, ne, map_reg, Operand(scratch));
__ GetWeakValue(scratch, Map::WeakCellForMap(it.Current()));
it.Advance();
if (it.Done()) {
__ Branch(miss_label, ne, map_reg, Operand(scratch));
break;
}
__ Branch(&do_store, eq, map_reg, Operand(scratch));
}
__ bind(&do_store);
} }
} }
......
...@@ -391,21 +391,11 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type, ...@@ -391,21 +391,11 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type,
DCHECK(!value_reg.is(map_reg)); DCHECK(!value_reg.is(map_reg));
DCHECK(!value_reg.is(scratch)); DCHECK(!value_reg.is(scratch));
__ JumpIfSmi(value_reg, miss_label); __ JumpIfSmi(value_reg, miss_label);
FieldType::Iterator it = field_type->Classes(); if (field_type->IsClass()) {
if (!it.Done()) {
__ ld(map_reg, FieldMemOperand(value_reg, HeapObject::kMapOffset)); __ ld(map_reg, FieldMemOperand(value_reg, HeapObject::kMapOffset));
Label do_store; // Compare map directly within the Branch() functions.
while (true) { __ GetWeakValue(scratch, Map::WeakCellForMap(field_type->AsClass()));
// Compare map directly within the Branch() functions. __ Branch(miss_label, ne, map_reg, Operand(scratch));
__ GetWeakValue(scratch, Map::WeakCellForMap(it.Current()));
it.Advance();
if (it.Done()) {
__ Branch(miss_label, ne, map_reg, Operand(scratch));
break;
}
__ Branch(&do_store, eq, map_reg, Operand(scratch));
}
__ bind(&do_store);
} }
} }
......
...@@ -401,20 +401,11 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type, ...@@ -401,20 +401,11 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type,
DCHECK(!value_reg.is(map_reg)); DCHECK(!value_reg.is(map_reg));
DCHECK(!value_reg.is(scratch)); DCHECK(!value_reg.is(scratch));
__ JumpIfSmi(value_reg, miss_label); __ JumpIfSmi(value_reg, miss_label);
FieldType::Iterator it = field_type->Classes(); if (field_type->IsClass()) {
if (!it.Done()) {
__ LoadP(map_reg, FieldMemOperand(value_reg, HeapObject::kMapOffset)); __ LoadP(map_reg, FieldMemOperand(value_reg, HeapObject::kMapOffset));
Label do_store; __ CmpWeakValue(map_reg, Map::WeakCellForMap(field_type->AsClass()),
while (true) { scratch);
__ CmpWeakValue(map_reg, Map::WeakCellForMap(it.Current()), scratch); __ bne(miss_label);
it.Advance();
if (it.Done()) {
__ bne(miss_label);
break;
}
__ beq(&do_store);
}
__ bind(&do_store);
} }
} }
......
...@@ -403,20 +403,12 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type, ...@@ -403,20 +403,12 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type,
DCHECK(!value_reg.is(map_reg)); DCHECK(!value_reg.is(map_reg));
DCHECK(!value_reg.is(scratch)); DCHECK(!value_reg.is(scratch));
__ JumpIfSmi(value_reg, miss_label); __ JumpIfSmi(value_reg, miss_label);
FieldType::Iterator it = field_type->Classes(); if (field_type->IsClass()) {
if (!it.Done()) {
Label do_store; Label do_store;
__ movp(map_reg, FieldOperand(value_reg, HeapObject::kMapOffset)); __ movp(map_reg, FieldOperand(value_reg, HeapObject::kMapOffset));
while (true) { __ CmpWeakValue(map_reg, Map::WeakCellForMap(field_type->AsClass()),
__ CmpWeakValue(map_reg, Map::WeakCellForMap(it.Current()), scratch); scratch);
it.Advance(); __ j(not_equal, miss_label);
if (it.Done()) {
__ j(not_equal, miss_label);
break;
}
__ j(equal, &do_store, Label::kNear);
}
__ bind(&do_store);
} }
} }
......
...@@ -407,20 +407,11 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type, ...@@ -407,20 +407,11 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(FieldType* field_type,
DCHECK(!value_reg.is(map_reg)); DCHECK(!value_reg.is(map_reg));
DCHECK(!value_reg.is(scratch)); DCHECK(!value_reg.is(scratch));
__ JumpIfSmi(value_reg, miss_label); __ JumpIfSmi(value_reg, miss_label);
FieldType::Iterator it = field_type->Classes(); if (field_type->IsClass()) {
if (!it.Done()) {
Label do_store;
__ mov(map_reg, FieldOperand(value_reg, HeapObject::kMapOffset)); __ mov(map_reg, FieldOperand(value_reg, HeapObject::kMapOffset));
while (true) { __ CmpWeakValue(map_reg, Map::WeakCellForMap(field_type->AsClass()),
__ CmpWeakValue(map_reg, Map::WeakCellForMap(it.Current()), scratch); scratch);
it.Advance(); __ j(not_equal, miss_label);
if (it.Done()) {
__ j(not_equal, miss_label);
break;
}
__ j(equal, &do_store, Label::kNear);
}
__ bind(&do_store);
} }
} }
......
...@@ -1429,11 +1429,6 @@ Type* FieldType::Convert(Zone* zone) { ...@@ -1429,11 +1429,6 @@ Type* FieldType::Convert(Zone* zone) {
return Type::Class(AsClass(), zone); return Type::Class(AsClass(), zone);
} }
FieldType::Iterator FieldType::Classes() {
if (IsClass()) return Iterator(this->AsClass());
return Iterator();
}
void FieldType::PrintTo(std::ostream& os) { void FieldType::PrintTo(std::ostream& os) {
if (IsAny()) { if (IsAny()) {
os << "Any"; os << "Any";
......
...@@ -1142,9 +1142,6 @@ typedef BoundsImpl<ZoneTypeConfig> Bounds; ...@@ -1142,9 +1142,6 @@ typedef BoundsImpl<ZoneTypeConfig> Bounds;
class FieldType : public Object { class FieldType : public Object {
public: public:
class Iterator;
// static Handle<FieldType> Create(Isolate* isolate, int length);
static FieldType* None(); static FieldType* None();
static FieldType* Any(); static FieldType* Any();
static Handle<FieldType> None(Isolate* isolate); static Handle<FieldType> None(Isolate* isolate);
...@@ -1163,34 +1160,10 @@ class FieldType : public Object { ...@@ -1163,34 +1160,10 @@ class FieldType : public Object {
bool NowIs(FieldType* other); bool NowIs(FieldType* other);
bool NowIs(Handle<FieldType> other); bool NowIs(Handle<FieldType> other);
Type* Convert(Zone* zone); Type* Convert(Zone* zone);
Iterator Classes();
int ClassCount() { return IsClass() ? 1 : 0; }
void PrintTo(std::ostream& os); void PrintTo(std::ostream& os);
}; };
class FieldType::Iterator {
public:
bool Done() const { return done_; }
i::Handle<i::Map> Current() {
DCHECK(!Done());
return map_.ToHandleChecked();
}
void Advance() {
if (!done_) done_ = true;
}
private:
friend FieldType;
Iterator() : done_(true) {}
explicit Iterator(MaybeHandle<i::Map> map)
: done_(map.is_null()), map_(map) {}
bool done_;
MaybeHandle<i::Map> map_;
};
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment