Reviewers: Benedikt Meurer,
Message:
ptal
cq if you like
Description:
add maps and sets to zone containers
[email protected]
BUG=
Please review this at https://codereview.chromium.org/889963002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+33, -12 lines):
M src/compiler/register-allocator-verifier.cc
M src/zone-containers.h
Index: src/compiler/register-allocator-verifier.cc
diff --git a/src/compiler/register-allocator-verifier.cc
b/src/compiler/register-allocator-verifier.cc
index
0f053331a6a998d3748deba3099b8544ce394ea4..276aa8806defbab34351e47ca134749982bd3d2a
100644
--- a/src/compiler/register-allocator-verifier.cc
+++ b/src/compiler/register-allocator-verifier.cc
@@ -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) {
Index: src/zone-containers.h
diff --git a/src/zone-containers.h b/src/zone-containers.h
index
de635fde05dda6ef0d4058c63552809a86a0469d..0a599bcf2b0501500fc4a17369728a7660cc8107
100644
--- a/src/zone-containers.h
+++ b/src/zone-containers.h
@@ -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;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.