Commit bbde91bf authored by dcarney's avatar dcarney Committed by Commit bot

add maps and sets to zone containers

R=bmeurer@chromium.org

BUG=

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

Cr-Commit-Position: refs/heads/master@{#26370}
parent 52d4d7de
......@@ -240,13 +240,9 @@ struct PhiData : public ZoneObject {
IntVector operands;
};
typedef std::map<int, PhiData*, std::less<int>,
zone_allocator<std::pair<int, PhiData*>>> PhiMapBase;
class PhiMap : public PhiMapBase, public ZoneObject {
class PhiMap : public ZoneMap<int, PhiData*>, public ZoneObject {
public:
explicit PhiMap(Zone* zone)
: PhiMapBase(key_compare(), allocator_type(zone)) {}
explicit PhiMap(Zone* zone) : ZoneMap<int, PhiData*>(zone) {}
};
struct OperandLess {
......@@ -271,13 +267,11 @@ class OperandMap : public ZoneObject {
int succ_vreg; // valid if propagated back from successor block.
};
typedef std::map<
const InstructionOperand*, MapValue*, OperandLess,
zone_allocator<std::pair<const InstructionOperand*, MapValue*>>> MapBase;
class Map : public MapBase {
class Map
: public ZoneMap<const InstructionOperand*, MapValue*, OperandLess> {
public:
explicit Map(Zone* zone) : MapBase(key_compare(), allocator_type(zone)) {}
explicit Map(Zone* zone)
: ZoneMap<const InstructionOperand*, MapValue*, OperandLess>(zone) {}
// Remove all entries with keys not in other.
void Intersect(const Map& other) {
......
......@@ -7,7 +7,9 @@
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
......@@ -83,6 +85,31 @@ class ZoneStack : public std::stack<T, ZoneDeque<T>> {
};
// A wrapper subclass for std::set to make it easy to construct one that uses
// a zone allocator.
template <typename K, typename Compare = std::less<K>>
class ZoneSet : public std::set<K, Compare, zone_allocator<K>> {
public:
// Constructs an empty set.
explicit ZoneSet(Zone* zone)
: std::set<K, Compare, zone_allocator<K>>(Compare(),
zone_allocator<K>(zone)) {}
};
// A wrapper subclass for std::map to make it easy to construct one that uses
// a zone allocator.
template <typename K, typename V, typename Compare = std::less<K>>
class ZoneMap
: public std::map<K, V, Compare, zone_allocator<std::pair<K, V>>> {
public:
// Constructs an empty map.
explicit ZoneMap(Zone* zone)
: std::map<K, V, Compare, zone_allocator<std::pair<K, V>>>(
Compare(), zone_allocator<std::pair<K, V>>(zone)) {}
};
// Typedefs to shorten commonly used vectors.
typedef ZoneVector<bool> BoolVector;
typedef ZoneVector<int> IntVector;
......
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