Chromium Code Reviews| Index: src/hydrogen-instructions.cc |
| =================================================================== |
| --- src/hydrogen-instructions.cc (revision 7299) |
| +++ src/hydrogen-instructions.cc (working copy) |
| @@ -1156,6 +1156,61 @@ |
| } |
| +HLoadNamedFieldPolymorphic::HLoadNamedFieldPolymorphic(HValue* object, |
| + ZoneMapList* types, |
| + Handle<String> name) |
| + : HUnaryOperation(object), |
| + types_(types->length()), |
|
Kevin Millikin (Chromium)
2011/03/23 15:37:29
You could initialize the list to have capacity Min
fschneider
2011/03/24 08:43:30
Done.
|
| + name_(name), |
| + need_generic_(false) { |
| + set_representation(Representation::Tagged()); |
| + SetFlag(kDependsOnMaps); |
| + const int kMaxLoadPolymorphism = 4; |
| + for (int i = 0; |
| + i < types->length() && types_.length() < kMaxLoadPolymorphism; |
| + ++i) { |
| + Handle<Map> map = types->at(i); |
| + LookupResult lookup; |
| + map->LookupInDescriptors(NULL, *name, &lookup); |
| + if (lookup.IsProperty() && lookup.type() == FIELD) { |
| + types_.Add(types->at(i)); |
| + int index = lookup.GetLocalFieldIndexFromMap(*map); |
| + if (index < 0) { |
| + SetFlag(kDependsOnInobjectFields); |
| + } else { |
| + SetFlag(kDependsOnBackingStoreFields); |
| + } |
| + } |
| + } |
| + |
| + if (types_.length() == types->length() && FLAG_deoptimize_uncommon_cases) { |
| + SetFlag(kUseGVN); |
| + } else { |
| + SetAllSideEffects(); |
| + need_generic_ = true; |
| + } |
| +} |
| + |
| + |
| +bool HLoadNamedFieldPolymorphic::DataEquals(HValue* value) { |
| + HLoadNamedFieldPolymorphic* other = HLoadNamedFieldPolymorphic::cast(value); |
| + if (types_.length() != other->types()->length()) return false; |
| + if (!name_.is_identical_to(other->name())) return false; |
| + if (need_generic_ != other->need_generic_) return false; |
| + for (int i = 0; i < types_.length(); i++) { |
| + bool found = false; |
| + for (int j = 0; j < types_.length(); j++) { |
| + if (!types_.at(j).is_identical_to(other->types()->at(i))) { |
|
Kevin Millikin (Chromium)
2011/03/23 15:37:29
Should not be negated.
fschneider
2011/03/24 08:43:30
Of course. Thanks.
|
| + found = true; |
| + break; |
| + } |
| + } |
| + if (!found) return false; |
| + } |
| + return true; |
| +} |
| + |
| + |
| void HLoadKeyedFastElement::PrintDataTo(StringStream* stream) { |
| object()->PrintNameTo(stream); |
| stream->Add("["); |