Commit bb000027 authored by Manos Koukoutos's avatar Manos Koukoutos Committed by V8 LUCI CQ

[turbofan] Optimize CsaLoadElimination

Design doc: https://bit.ly/36MfD6Y, section "Improving Computational
Complexity of CSALoadElimination".

We optimize CsaLoadElimination::AbstractState::KillField() by
fine-graining AbstractState. We now represent it with 6 maps
corresponding to (object kind, offset kind) pairs. This makes it
possible for KillField() to manipulate the state faster. For more
information consult the above design doc.

Bug: v8:11510
Change-Id: I7d991cd47f946edb20e746bc7e6792ae3c70004f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3038521
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76165}
parent d9c06ed1
......@@ -358,6 +358,15 @@ V8_EXPORT_PRIVATE inline constexpr int ElementSizeLog2Of(
}
}
constexpr int kMaximumReprSizeLog2 =
ElementSizeLog2Of(MachineRepresentation::kSimd128);
constexpr int kMaximumReprSizeInBytes = 1 << kTaggedSizeLog2;
STATIC_ASSERT(kMaximumReprSizeLog2 >=
ElementSizeLog2Of(MachineRepresentation::kTagged));
STATIC_ASSERT(kMaximumReprSizeLog2 >=
ElementSizeLog2Of(MachineRepresentation::kWord64));
V8_EXPORT_PRIVATE inline constexpr int ElementSizeInBytes(
MachineRepresentation rep) {
return 1 << ElementSizeLog2Of(rep);
......
This diff is collapsed.
......@@ -61,28 +61,74 @@ class V8_EXPORT_PRIVATE CsaLoadElimination final
MachineRepresentation representation = MachineRepresentation::kNone;
};
// Design doc: https://bit.ly/36MfD6Y
class AbstractState final : public ZoneObject {
public:
explicit AbstractState(Zone* zone) : field_infos_(zone) {}
explicit AbstractState(Zone* zone)
: zone_(zone),
fresh_entries_(zone, InnerMap(zone)),
constant_entries_(zone, InnerMap(zone)),
arbitrary_entries_(zone, InnerMap(zone)),
fresh_unknown_entries_(zone, InnerMap(zone)),
constant_unknown_entries_(zone, InnerMap(zone)),
arbitrary_unknown_entries_(zone, InnerMap(zone)) {}
bool Equals(AbstractState const* that) const {
return field_infos_ == that->field_infos_;
return fresh_entries_ == that->fresh_entries_ &&
constant_entries_ == that->constant_entries_ &&
arbitrary_entries_ == that->arbitrary_entries_ &&
fresh_unknown_entries_ == that->fresh_unknown_entries_ &&
constant_unknown_entries_ == that->constant_unknown_entries_ &&
arbitrary_unknown_entries_ == that->arbitrary_unknown_entries_;
}
void Merge(AbstractState const* that, Zone* zone);
void IntersectWith(AbstractState const* that);
AbstractState const* KillField(Node* object, Node* offset,
MachineRepresentation repr,
Zone* zone) const;
AbstractState const* AddField(Node* object, Node* offset, FieldInfo info,
Zone* zone) const;
MachineRepresentation repr) const;
AbstractState const* AddField(Node* object, Node* offset, Node* value,
MachineRepresentation repr) const;
FieldInfo Lookup(Node* object, Node* offset) const;
void Print() const;
private:
using Field = std::pair<Node*, Node*>;
using FieldInfos = PersistentMap<Field, FieldInfo>;
FieldInfos field_infos_;
Zone* zone_;
using InnerMap = PersistentMap<Node*, FieldInfo>;
template <typename OuterKey>
using OuterMap = PersistentMap<OuterKey, InnerMap>;
// offset -> object -> info
using ConstantOffsetInfos = OuterMap<uint32_t>;
ConstantOffsetInfos fresh_entries_;
ConstantOffsetInfos constant_entries_;
ConstantOffsetInfos arbitrary_entries_;
// object -> offset -> info
using UnknownOffsetInfos = OuterMap<Node*>;
UnknownOffsetInfos fresh_unknown_entries_;
UnknownOffsetInfos constant_unknown_entries_;
UnknownOffsetInfos arbitrary_unknown_entries_;
// Update {map} so that {map.Get(outer_key).Get(inner_key)} returns {info}.
template <typename OuterKey>
static void Update(OuterMap<OuterKey>& map, OuterKey outer_key,
Node* inner_key, FieldInfo info) {
InnerMap map_copy(map.Get(outer_key));
map_copy.Set(inner_key, info);
map.Set(outer_key, map_copy);
}
// Kill all elements in {infos} which may alias with offset.
static void KillOffset(ConstantOffsetInfos& infos, uint32_t offset,
MachineRepresentation repr, Zone* zone);
void KillOffsetInFresh(Node* object, uint32_t offset,
MachineRepresentation repr);
template <typename OuterKey>
static void IntersectWith(OuterMap<OuterKey>& to,
const OuterMap<OuterKey>& from);
static void Print(const ConstantOffsetInfos& infos);
static void Print(const UnknownOffsetInfos& infos);
};
Reduction ReduceLoadFromObject(Node* node, ObjectAccess const& access);
......
......@@ -387,9 +387,11 @@ void PersistentMap<Key, Value, Hasher>::Set(Key key, Value value) {
if (old->more) {
*more = *old->more;
} else {
(*more)[old->key_value.key()] = old->key_value.value();
more->erase(old->key_value.key());
more->emplace(old->key_value.key(), old->key_value.value());
}
(*more)[key] = value;
more->erase(key);
more->emplace(key, value);
}
size_t size = sizeof(FocusedTree) +
std::max(0, length - 1) * sizeof(const FocusedTree*);
......
This diff is collapsed.
......@@ -202,6 +202,10 @@ function makeSig_v_x(x) {
return makeSig([x], []);
}
function makeSig_x_v(x) {
return makeSig([], [x]);
}
function makeSig_v_xx(x) {
return makeSig([x, x], []);
}
......
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