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