summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/load-elimination.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/compiler/load-elimination.h')
-rw-r--r--deps/v8/src/compiler/load-elimination.h75
1 files changed, 58 insertions, 17 deletions
diff --git a/deps/v8/src/compiler/load-elimination.h b/deps/v8/src/compiler/load-elimination.h
index 4ad1fa64a2..b97fd7b883 100644
--- a/deps/v8/src/compiler/load-elimination.h
+++ b/deps/v8/src/compiler/load-elimination.h
@@ -9,6 +9,7 @@
#include "src/codegen/machine-type.h"
#include "src/common/globals.h"
#include "src/compiler/graph-reducer.h"
+#include "src/compiler/simplified-operator.h"
#include "src/handles/maybe-handles.h"
#include "src/zone/zone-handle-set.h"
@@ -100,20 +101,25 @@ class V8_EXPORT_PRIVATE LoadElimination final
struct FieldInfo {
FieldInfo() = default;
- FieldInfo(Node* value, MachineRepresentation representation)
- : value(value), name(), representation(representation) {}
- FieldInfo(Node* value, MaybeHandle<Name> name,
- MachineRepresentation representation)
- : value(value), name(name), representation(representation) {}
+ FieldInfo(Node* value, MachineRepresentation representation,
+ MaybeHandle<Name> name = {},
+ ConstFieldInfo const_field_info = ConstFieldInfo::None())
+ : value(value),
+ representation(representation),
+ name(name),
+ const_field_info(const_field_info) {}
bool operator==(const FieldInfo& other) const {
- return value == other.value && name.address() == other.name.address() &&
- representation == other.representation;
+ return value == other.value && representation == other.representation &&
+ name.address() == other.name.address() &&
+ const_field_info == other.const_field_info;
}
+ bool operator!=(const FieldInfo& other) const { return !(*this == other); }
Node* value = nullptr;
- MaybeHandle<Name> name;
MachineRepresentation representation = MachineRepresentation::kNone;
+ MaybeHandle<Name> name;
+ ConstFieldInfo const_field_info;
};
// Abstract state to approximate the current state of a certain field along
@@ -134,6 +140,7 @@ class V8_EXPORT_PRIVATE LoadElimination final
return that;
}
FieldInfo const* Lookup(Node* object) const;
+ AbstractField const* KillConst(Node* object, Zone* zone) const;
AbstractField const* Kill(const AliasStateInfo& alias_info,
MaybeHandle<Name> name, Zone* zone) const;
bool Equals(AbstractField const* that) const {
@@ -186,6 +193,39 @@ class V8_EXPORT_PRIVATE LoadElimination final
ZoneMap<Node*, ZoneHandleSet<Map>> info_for_node_;
};
+ class IndexRange {
+ public:
+ IndexRange(int begin, int size) : begin_(begin), end_(begin + size) {
+ DCHECK_LE(0, begin);
+ DCHECK_LE(1, size);
+ if (end_ > static_cast<int>(kMaxTrackedFields)) {
+ *this = IndexRange::Invalid();
+ }
+ }
+ static IndexRange Invalid() { return IndexRange(); }
+
+ bool operator==(const IndexRange& other) {
+ return begin_ == other.begin_ && end_ == other.end_;
+ }
+ bool operator!=(const IndexRange& other) { return !(*this == other); }
+
+ struct Iterator {
+ int i;
+ int operator*() { return i; }
+ void operator++() { ++i; }
+ bool operator!=(Iterator other) { return i != other.i; }
+ };
+
+ Iterator begin() { return {begin_}; }
+ Iterator end() { return {end_}; }
+
+ private:
+ int begin_;
+ int end_;
+
+ IndexRange() : begin_(-1), end_(-1) {}
+ };
+
class AbstractState final : public ZoneObject {
public:
AbstractState() {}
@@ -200,19 +240,20 @@ class V8_EXPORT_PRIVATE LoadElimination final
Zone* zone) const;
bool LookupMaps(Node* object, ZoneHandleSet<Map>* object_maps) const;
- AbstractState const* AddField(Node* object, size_t index, FieldInfo info,
- PropertyConstness constness,
- Zone* zone) const;
+ AbstractState const* AddField(Node* object, IndexRange index,
+ FieldInfo info, Zone* zone) const;
+ AbstractState const* KillConstField(Node* object, IndexRange index_range,
+ Zone* zone) const;
AbstractState const* KillField(const AliasStateInfo& alias_info,
- size_t index, MaybeHandle<Name> name,
+ IndexRange index, MaybeHandle<Name> name,
Zone* zone) const;
- AbstractState const* KillField(Node* object, size_t index,
+ AbstractState const* KillField(Node* object, IndexRange index,
MaybeHandle<Name> name, Zone* zone) const;
AbstractState const* KillFields(Node* object, MaybeHandle<Name> name,
Zone* zone) const;
AbstractState const* KillAll(Zone* zone) const;
- FieldInfo const* LookupField(Node* object, size_t index,
- PropertyConstness constness) const;
+ FieldInfo const* LookupField(Node* object, IndexRange index,
+ ConstFieldInfo const_field_info) const;
AbstractState const* AddElement(Node* object, Node* index, Node* value,
MachineRepresentation representation,
@@ -280,8 +321,8 @@ class V8_EXPORT_PRIVATE LoadElimination final
AbstractState const* UpdateStateForPhi(AbstractState const* state,
Node* effect_phi, Node* phi);
- static int FieldIndexOf(int offset);
- static int FieldIndexOf(FieldAccess const& access);
+ static IndexRange FieldIndexOf(int offset, int representation_size);
+ static IndexRange FieldIndexOf(FieldAccess const& access);
static AbstractState const* empty_state() {
return AbstractState::empty_state();