Improve computation of effects for load elimination.

R=ishell@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19322 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
bmeurer@chromium.org 2014-02-12 12:34:14 +00:00
parent b0fcc801e9
commit 9ef9c4cd49

View File

@ -453,11 +453,7 @@ class HLoadEliminationTable : public ZoneObject {
class HLoadEliminationEffects : public ZoneObject { class HLoadEliminationEffects : public ZoneObject {
public: public:
explicit HLoadEliminationEffects(Zone* zone) explicit HLoadEliminationEffects(Zone* zone)
: zone_(zone), : zone_(zone), stores_(5, zone) { }
maps_stored_(false),
fields_stored_(false),
elements_stored_(false),
stores_(5, zone) { }
inline bool Disabled() { inline bool Disabled() {
return false; // Effects are _not_ disabled. return false; // Effects are _not_ disabled.
@ -465,37 +461,25 @@ class HLoadEliminationEffects : public ZoneObject {
// Process a possibly side-effecting instruction. // Process a possibly side-effecting instruction.
void Process(HInstruction* instr, Zone* zone) { void Process(HInstruction* instr, Zone* zone) {
switch (instr->opcode()) { if (instr->IsStoreNamedField()) {
case HValue::kStoreNamedField: { stores_.Add(HStoreNamedField::cast(instr), zone_);
stores_.Add(HStoreNamedField::cast(instr), zone_); } else {
break; flags_.Add(instr->ChangesFlags());
}
case HValue::kOsrEntry: {
// Kill everything. Loads must not be hoisted past the OSR entry.
maps_stored_ = true;
fields_stored_ = true;
elements_stored_ = true;
}
default: {
fields_stored_ |= instr->CheckChangesFlag(kInobjectFields);
maps_stored_ |= instr->CheckChangesFlag(kMaps);
maps_stored_ |= instr->CheckChangesFlag(kElementsKind);
elements_stored_ |= instr->CheckChangesFlag(kElementsKind);
elements_stored_ |= instr->CheckChangesFlag(kElementsPointer);
}
} }
} }
// Apply these effects to the given load elimination table. // Apply these effects to the given load elimination table.
void Apply(HLoadEliminationTable* table) { void Apply(HLoadEliminationTable* table) {
if (fields_stored_) { // Loads must not be hoisted past the OSR entry, therefore we kill
// everything if we see an OSR entry.
if (flags_.Contains(kInobjectFields) || flags_.Contains(kOsrEntries)) {
table->Kill(); table->Kill();
return; return;
} }
if (maps_stored_) { if (flags_.Contains(kElementsKind) || flags_.Contains(kMaps)) {
table->KillOffset(JSObject::kMapOffset); table->KillOffset(JSObject::kMapOffset);
} }
if (elements_stored_) { if (flags_.Contains(kElementsKind) || flags_.Contains(kElementsPointer)) {
table->KillOffset(JSObject::kElementsOffset); table->KillOffset(JSObject::kElementsOffset);
} }
@ -507,9 +491,7 @@ class HLoadEliminationEffects : public ZoneObject {
// Union these effects with the other effects. // Union these effects with the other effects.
void Union(HLoadEliminationEffects* that, Zone* zone) { void Union(HLoadEliminationEffects* that, Zone* zone) {
maps_stored_ |= that->maps_stored_; flags_.Add(that->flags_);
fields_stored_ |= that->fields_stored_;
elements_stored_ |= that->elements_stored_;
for (int i = 0; i < that->stores_.length(); i++) { for (int i = 0; i < that->stores_.length(); i++) {
stores_.Add(that->stores_[i], zone); stores_.Add(that->stores_[i], zone);
} }
@ -517,9 +499,7 @@ class HLoadEliminationEffects : public ZoneObject {
private: private:
Zone* zone_; Zone* zone_;
bool maps_stored_ : 1; GVNFlagSet flags_;
bool fields_stored_ : 1;
bool elements_stored_ : 1;
ZoneList<HStoreNamedField*> stores_; ZoneList<HStoreNamedField*> stores_;
}; };