Revision: 23402
Author:   [email protected]
Date:     Tue Aug 26 13:09:08 2014 UTC
Log: Introduce subclass wrappers for STL containers that make them a lot easier
to use with Zone. For example, subclasses add constructors that wrap a Zone
in a zone_allocator to save clients this verbosity.

[email protected], [email protected]
BUG=

Review URL: https://codereview.chromium.org/505133003
https://code.google.com/p/v8/source/detail?r=23402

Modified:
 /branches/bleeding_edge/src/compiler/code-generator.cc
 /branches/bleeding_edge/src/compiler/code-generator.h
 /branches/bleeding_edge/src/compiler/generic-algorithm.h
 /branches/bleeding_edge/src/compiler/generic-node-inl.h
 /branches/bleeding_edge/src/compiler/generic-node.h
 /branches/bleeding_edge/src/compiler/graph-builder.cc
 /branches/bleeding_edge/src/compiler/graph-reducer.cc
 /branches/bleeding_edge/src/compiler/graph-reducer.h
 /branches/bleeding_edge/src/compiler/graph.cc
 /branches/bleeding_edge/src/compiler/graph.h
 /branches/bleeding_edge/src/compiler/instruction-selector.cc
 /branches/bleeding_edge/src/compiler/instruction-selector.h
 /branches/bleeding_edge/src/compiler/instruction.h
 /branches/bleeding_edge/src/compiler/js-inlining.cc
 /branches/bleeding_edge/src/compiler/node-aux-data-inl.h
 /branches/bleeding_edge/src/compiler/node-aux-data.h
 /branches/bleeding_edge/src/compiler/node.h
 /branches/bleeding_edge/src/compiler/raw-machine-assembler.h
 /branches/bleeding_edge/src/compiler/schedule.h
 /branches/bleeding_edge/src/compiler/scheduler.cc
 /branches/bleeding_edge/src/compiler/scheduler.h
 /branches/bleeding_edge/src/compiler/simplified-lowering.cc
 /branches/bleeding_edge/src/compiler/structured-machine-assembler.cc
 /branches/bleeding_edge/src/compiler/structured-machine-assembler.h
 /branches/bleeding_edge/src/compiler/verifier.cc
 /branches/bleeding_edge/src/zone-containers.h

=======================================
--- /branches/bleeding_edge/src/compiler/code-generator.cc Mon Aug 25 07:02:19 2014 UTC +++ /branches/bleeding_edge/src/compiler/code-generator.cc Tue Aug 26 13:09:08 2014 UTC
@@ -19,11 +19,9 @@
       masm_(code->zone()->isolate(), NULL, 0),
       resolver_(this),
       safepoints_(code->zone()),
-      lazy_deoptimization_entries_(
-          LazyDeoptimizationEntries::allocator_type(code->zone())),
-      deoptimization_states_(
-          DeoptimizationStates::allocator_type(code->zone())),
-      deoptimization_literals_(Literals::allocator_type(code->zone())),
+      lazy_deoptimization_entries_(code->zone()),
+      deoptimization_states_(code->zone()),
+      deoptimization_literals_(code->zone()),
       translations_(code->zone()) {
   deoptimization_states_.resize(code->GetDeoptimizationEntryCount(), NULL);
 }
=======================================
--- /branches/bleeding_edge/src/compiler/code-generator.h Mon Aug 25 07:02:19 2014 UTC +++ /branches/bleeding_edge/src/compiler/code-generator.h Tue Aug 26 13:09:08 2014 UTC
@@ -122,23 +122,15 @@
         : translation_id_(translation_id) {}
   };

-  typedef std::deque<LazyDeoptimizationEntry,
-                     zone_allocator<LazyDeoptimizationEntry> >
-      LazyDeoptimizationEntries;
-  typedef std::deque<DeoptimizationState*,
-                     zone_allocator<DeoptimizationState*> >
-      DeoptimizationStates;
- typedef std::deque<Handle<Object>, zone_allocator<Handle<Object> > > Literals;
-
   InstructionSequence* code_;
   BasicBlock* current_block_;
   SourcePosition current_source_position_;
   MacroAssembler masm_;
   GapResolver resolver_;
   SafepointTableBuilder safepoints_;
-  LazyDeoptimizationEntries lazy_deoptimization_entries_;
-  DeoptimizationStates deoptimization_states_;
-  Literals deoptimization_literals_;
+  ZoneDeque<LazyDeoptimizationEntry> lazy_deoptimization_entries_;
+  ZoneDeque<DeoptimizationState*> deoptimization_states_;
+  ZoneDeque<Handle<Object> > deoptimization_literals_;
   TranslationBuffer translations_;
 };

=======================================
--- /branches/bleeding_edge/src/compiler/generic-algorithm.h Wed Aug 13 12:36:09 2014 UTC +++ /branches/bleeding_edge/src/compiler/generic-algorithm.h Tue Aug 26 13:09:08 2014 UTC
@@ -5,7 +5,6 @@
 #ifndef V8_COMPILER_GENERIC_ALGORITHM_H_
 #define V8_COMPILER_GENERIC_ALGORITHM_H_

-#include <deque>
 #include <stack>

 #include "src/compiler/generic-graph.h"
@@ -45,10 +44,9 @@
     typedef typename Traits::Iterator Iterator;
     typedef std::pair<Iterator, Iterator> NodeState;
     typedef zone_allocator<NodeState> ZoneNodeStateAllocator;
-    typedef std::deque<NodeState, ZoneNodeStateAllocator> NodeStateDeque;
-    typedef std::stack<NodeState, NodeStateDeque> NodeStateStack;
-    NodeStateStack stack((NodeStateDeque(ZoneNodeStateAllocator(zone))));
- BoolVector visited(Traits::max_id(graph), false, ZoneBoolAllocator(zone));
+    typedef std::stack<NodeState, ZoneDeque<NodeState>> NodeStateStack;
+    NodeStateStack stack((ZoneDeque<NodeState>(zone)));
+    BoolVector visited(Traits::max_id(graph), false, zone);
     Node* current = *root_begin;
     while (true) {
       DCHECK(current != NULL);
=======================================
--- /branches/bleeding_edge/src/compiler/generic-node-inl.h Mon Aug 4 11:34:54 2014 UTC +++ /branches/bleeding_edge/src/compiler/generic-node-inl.h Tue Aug 26 13:09:08 2014 UTC
@@ -141,7 +141,7 @@
 void GenericNode<B, S>::EnsureAppendableInputs(Zone* zone) {
   if (!has_appendable_inputs_) {
     void* deque_buffer = zone->New(sizeof(InputDeque));
- InputDeque* deque = new (deque_buffer) InputDeque(ZoneInputAllocator(zone));
+    InputDeque* deque = new (deque_buffer) InputDeque(zone);
     for (int i = 0; i < input_count_; ++i) {
       deque->push_back(inputs_.static_[i]);
     }
=======================================
--- /branches/bleeding_edge/src/compiler/generic-node.h Mon Aug 25 06:57:13 2014 UTC +++ /branches/bleeding_edge/src/compiler/generic-node.h Tue Aug 26 13:09:08 2014 UTC
@@ -5,19 +5,14 @@
 #ifndef V8_COMPILER_GENERIC_NODE_H_
 #define V8_COMPILER_GENERIC_NODE_H_

-#include <deque>
-
 #include "src/v8.h"

-#include "src/compiler/operator.h"
-#include "src/zone.h"
-#include "src/zone-allocator.h"
+#include "src/zone-containers.h"

 namespace v8 {
 namespace internal {
 namespace compiler {

-class Operator;
 class GenericGraphBase;

 typedef int NodeId;
@@ -137,8 +132,7 @@
  private:
   void AssignUniqueID(GenericGraphBase* graph);

-  typedef zone_allocator<Input> ZoneInputAllocator;
-  typedef std::deque<Input, ZoneInputAllocator> InputDeque;
+  typedef ZoneDeque<Input> InputDeque;

   NodeId id_;
   int input_count_ : 31;
=======================================
--- /branches/bleeding_edge/src/compiler/graph-builder.cc Thu Aug 21 11:56:46 2014 UTC +++ /branches/bleeding_edge/src/compiler/graph-builder.cc Tue Aug 26 13:09:08 2014 UTC
@@ -104,7 +104,7 @@
     : builder_(builder),
       control_dependency_(control_dependency),
       effect_dependency_(control_dependency),
-      values_(NodeVector::allocator_type(zone())) {}
+      values_(zone()) {}


 StructuredGraphBuilder::Environment::Environment(const Environment& copy)
=======================================
--- /branches/bleeding_edge/src/compiler/graph-reducer.cc Wed Jul 30 13:54:45 2014 UTC +++ /branches/bleeding_edge/src/compiler/graph-reducer.cc Tue Aug 26 13:09:08 2014 UTC
@@ -13,7 +13,7 @@
 namespace compiler {

 GraphReducer::GraphReducer(Graph* graph)
-    : graph_(graph), reducers_(Reducers::allocator_type(graph->zone())) {}
+    : graph_(graph), reducers_(graph->zone()) {}


 static bool NodeIdIsLessThan(const Node* node, NodeId id) {
@@ -22,14 +22,15 @@


 void GraphReducer::ReduceNode(Node* node) {
-  Reducers::iterator skip = reducers_.end();
+  ZoneVector<Reducer*>::iterator skip = reducers_.end();
   static const unsigned kMaxAttempts = 16;
   bool reduce = true;
   for (unsigned attempts = 0; attempts <= kMaxAttempts; ++attempts) {
     if (!reduce) return;
     reduce = false;  // Assume we don't need to rerun any reducers.
     int before = graph_->NodeCount();
- for (Reducers::iterator i = reducers_.begin(); i != reducers_.end(); ++i) {
+    for (ZoneVector<Reducer*>::iterator i = reducers_.begin();
+         i != reducers_.end(); ++i) {
       if (i == skip) continue;  // Skip this reducer.
       Reduction reduction = (*i)->Reduce(node);
       Node* replacement = reduction.replacement();
=======================================
--- /branches/bleeding_edge/src/compiler/graph-reducer.h Fri Aug 22 04:47:55 2014 UTC +++ /branches/bleeding_edge/src/compiler/graph-reducer.h Tue Aug 26 13:09:08 2014 UTC
@@ -5,9 +5,7 @@
 #ifndef V8_COMPILER_GRAPH_REDUCER_H_
 #define V8_COMPILER_GRAPH_REDUCER_H_

-#include <list>
-
-#include "src/zone-allocator.h"
+#include "src/zone-containers.h"

 namespace v8 {
 namespace internal {
@@ -69,10 +67,8 @@
   void ReduceGraph();

  private:
-  typedef std::list<Reducer*, zone_allocator<Reducer*> > Reducers;
-
   Graph* graph_;
-  Reducers reducers_;
+  ZoneVector<Reducer*> reducers_;

   DISALLOW_COPY_AND_ASSIGN(GraphReducer);
 };
=======================================
--- /branches/bleeding_edge/src/compiler/graph.cc Mon Aug 4 11:34:54 2014 UTC +++ /branches/bleeding_edge/src/compiler/graph.cc Tue Aug 26 13:09:08 2014 UTC
@@ -18,16 +18,14 @@
 namespace internal {
 namespace compiler {

-Graph::Graph(Zone* zone)
-    : GenericGraph<Node>(zone),
-      decorators_(DecoratorVector::allocator_type(zone)) {}
+Graph::Graph(Zone* zone) : GenericGraph<Node>(zone), decorators_(zone) {}


 Node* Graph::NewNode(Operator* op, int input_count, Node** inputs) {
   DCHECK(op->InputCount() <= input_count);
   Node* result = Node::New(this, input_count, inputs);
   result->Initialize(op);
-  for (DecoratorVector::iterator i = decorators_.begin();
+  for (ZoneVector<GraphDecorator*>::iterator i = decorators_.begin();
        i != decorators_.end(); ++i) {
     (*i)->Decorate(result);
   }
=======================================
--- /branches/bleeding_edge/src/compiler/graph.h Tue Aug 26 09:19:24 2014 UTC +++ /branches/bleeding_edge/src/compiler/graph.h Tue Aug 26 13:09:08 2014 UTC
@@ -72,16 +72,14 @@
   }

   void RemoveDecorator(GraphDecorator* decorator) {
-    DecoratorVector::iterator it =
+    ZoneVector<GraphDecorator*>::iterator it =
         std::find(decorators_.begin(), decorators_.end(), decorator);
     DCHECK(it != decorators_.end());
     decorators_.erase(it, it + 1);
   }

  private:
-  typedef std::vector<GraphDecorator*, zone_allocator<GraphDecorator*> >
-      DecoratorVector;
-  DecoratorVector decorators_;
+  ZoneVector<GraphDecorator*> decorators_;
 };


=======================================
--- /branches/bleeding_edge/src/compiler/instruction-selector.cc Tue Aug 26 09:19:24 2014 UTC +++ /branches/bleeding_edge/src/compiler/instruction-selector.cc Tue Aug 26 13:09:08 2014 UTC
@@ -21,9 +21,9 @@
       source_positions_(source_positions),
       features_(features),
       current_block_(NULL),
-      instructions_(InstructionDeque::allocator_type(zone())),
- defined_(graph()->NodeCount(), false, BoolVector::allocator_type(zone())), - used_(graph()->NodeCount(), false, BoolVector::allocator_type(zone())) {}
+      instructions_(zone()),
+      defined_(graph()->NodeCount(), false, zone()),
+      used_(graph()->NodeCount(), false, zone()) {}


 void InstructionSelector::SelectInstructions() {
@@ -264,10 +264,10 @@
                        FrameStateDescriptor* frame_desc)
     : descriptor(d),
       frame_state_descriptor(frame_desc),
-      output_nodes(NodeVector::allocator_type(zone)),
-      outputs(InstructionOperandVector::allocator_type(zone)),
-      instruction_args(InstructionOperandVector::allocator_type(zone)),
-      pushed_nodes(NodeVector::allocator_type(zone)) {
+      output_nodes(zone),
+      outputs(zone),
+      instruction_args(zone),
+      pushed_nodes(zone) {
   output_nodes.reserve(d->ReturnCount());
   outputs.reserve(d->ReturnCount());
   pushed_nodes.reserve(input_count());
@@ -1083,8 +1083,7 @@
   Node* state = deopt->InputAt(0);
   FrameStateDescriptor* descriptor = GetFrameStateDescriptor(state);

-  InstructionOperandVector inputs(
-      (InstructionOperandVector::allocator_type(zone())));
+  InstructionOperandVector inputs(zone());
   inputs.reserve(descriptor->size());

   AddFrameStateInputs(state, &inputs, descriptor);
=======================================
--- /branches/bleeding_edge/src/compiler/instruction-selector.h Thu Aug 21 11:56:46 2014 UTC +++ /branches/bleeding_edge/src/compiler/instruction-selector.h Tue Aug 26 13:09:08 2014 UTC
@@ -197,15 +197,12 @@

// ===========================================================================

-  typedef zone_allocator<Instruction*> InstructionPtrZoneAllocator;
- typedef std::deque<Instruction*, InstructionPtrZoneAllocator> Instructions;
-
   Zone zone_;
   InstructionSequence* sequence_;
   SourcePositionTable* source_positions_;
   Features features_;
   BasicBlock* current_block_;
-  Instructions instructions_;
+  ZoneDeque<Instruction*> instructions_;
   BoolVector defined_;
   BoolVector used_;
 };
=======================================
--- /branches/bleeding_edge/src/compiler/instruction.h Mon Aug 25 10:35:38 2014 UTC +++ /branches/bleeding_edge/src/compiler/instruction.h Tue Aug 26 13:09:08 2014 UTC
@@ -89,8 +89,7 @@
   unsigned value_;
 };

-typedef std::vector<InstructionOperand*, zone_allocator<InstructionOperand*> >
-    InstructionOperandVector;
+typedef ZoneVector<InstructionOperand*> InstructionOperandVector;

 OStream& operator<<(OStream& os, const InstructionOperand& op);

@@ -725,18 +724,13 @@

 OStream& operator<<(OStream& os, const Constant& constant);

-typedef std::deque<Constant, zone_allocator<Constant> > ConstantDeque;
+typedef ZoneDeque<Constant> ConstantDeque;
 typedef std::map<int, Constant, std::less<int>,
                  zone_allocator<std::pair<int, Constant> > > ConstantMap;

-
-typedef std::deque<Instruction*, zone_allocator<Instruction*> >
-    InstructionDeque;
-typedef std::deque<PointerMap*, zone_allocator<PointerMap*> > PointerMapDeque;
-typedef std::vector<FrameStateDescriptor*,
-                    zone_allocator<FrameStateDescriptor*> >
-    DeoptimizationVector;
-
+typedef ZoneDeque<Instruction*> InstructionDeque;
+typedef ZoneDeque<PointerMap*> PointerMapDeque;
+typedef ZoneVector<FrameStateDescriptor*> DeoptimizationVector;

// Represents architecture-specific generated code before, during, and after
 // register allocation.
@@ -749,14 +743,14 @@
         schedule_(schedule),
         constants_(ConstantMap::key_compare(),
                    ConstantMap::allocator_type(zone())),
-        immediates_(ConstantDeque::allocator_type(zone())),
-        instructions_(InstructionDeque::allocator_type(zone())),
+        immediates_(zone()),
+        instructions_(zone()),
         next_virtual_register_(graph->NodeCount()),
-        pointer_maps_(PointerMapDeque::allocator_type(zone())),
+        pointer_maps_(zone()),
doubles_(std::less<int>(), VirtualRegisterSet::allocator_type(zone())),
         references_(std::less<int>(),
                     VirtualRegisterSet::allocator_type(zone())),
- deoptimization_entries_(DeoptimizationVector::allocator_type(zone())) {}
+        deoptimization_entries_(zone()) {}

   int NextVirtualRegister() { return next_virtual_register_++; }
   int VirtualRegisterCount() const { return next_virtual_register_; }
=======================================
--- /branches/bleeding_edge/src/compiler/js-inlining.cc Wed Aug 20 13:05:03 2014 UTC +++ /branches/bleeding_edge/src/compiler/js-inlining.cc Tue Aug 26 13:09:08 2014 UTC
@@ -152,8 +152,8 @@
   Operator* op_phi = jsgraph_->common()->Phi(predecessors);
   Operator* op_ephi = jsgraph_->common()->EffectPhi(predecessors);

-  NodeVector values(NodeVector::allocator_type(jsgraph_->zone()));
-  NodeVector effects(NodeVector::allocator_type(jsgraph_->zone()));
+  NodeVector values(jsgraph_->zone());
+  NodeVector effects(jsgraph_->zone());
   // Iterate over all control flow predecessors,
   // which must be return statements.
   InputIter iter = final_merge->inputs().begin();
=======================================
--- /branches/bleeding_edge/src/compiler/node-aux-data-inl.h Thu Aug 7 09:11:42 2014 UTC +++ /branches/bleeding_edge/src/compiler/node-aux-data-inl.h Tue Aug 26 13:09:08 2014 UTC
@@ -15,7 +15,7 @@

 template <class T>
 NodeAuxData<T>::NodeAuxData(Zone* zone)
-    : aux_data_(ZoneAllocator(zone)) {}
+    : aux_data_(zone) {}


 template <class T>
=======================================
--- /branches/bleeding_edge/src/compiler/node-aux-data.h Thu Aug 7 09:11:42 2014 UTC +++ /branches/bleeding_edge/src/compiler/node-aux-data.h Tue Aug 26 13:09:08 2014 UTC
@@ -5,9 +5,7 @@
 #ifndef V8_COMPILER_NODE_AUX_DATA_H_
 #define V8_COMPILER_NODE_AUX_DATA_H_

-#include <vector>
-
-#include "src/zone-allocator.h"
+#include "src/zone-containers.h"

 namespace v8 {
 namespace internal {
@@ -26,10 +24,7 @@
   inline T Get(Node* node);

  private:
-  typedef zone_allocator<T> ZoneAllocator;
-  typedef std::vector<T, ZoneAllocator> TZoneVector;
-
-  TZoneVector aux_data_;
+  ZoneVector<T> aux_data_;
 };
 }
 }
=======================================
--- /branches/bleeding_edge/src/compiler/node.h Thu Aug 21 11:56:46 2014 UTC
+++ /branches/bleeding_edge/src/compiler/node.h Tue Aug 26 13:09:08 2014 UTC
@@ -54,8 +54,7 @@

   void Initialize(Operator* op) { set_op(op); }

-  void CollectProjections(
-      std::vector<Node*, zone_allocator<Node*> >* projections);
+  void CollectProjections(ZoneVector<Node*>* projections);
   Node* FindProjection(int32_t projection_index);
 };

@@ -63,21 +62,15 @@

 typedef GenericGraphVisit::NullNodeVisitor<NodeData, Node> NullNodeVisitor;

-typedef zone_allocator<Node*> NodePtrZoneAllocator;
-
-typedef std::set<Node*, std::less<Node*>, NodePtrZoneAllocator> NodeSet;
+typedef std::set<Node*, std::less<Node*>, zone_allocator<Node*> > NodeSet;
 typedef NodeSet::iterator NodeSetIter;
 typedef NodeSet::reverse_iterator NodeSetRIter;

-typedef std::deque<Node*, NodePtrZoneAllocator> NodeDeque;
-typedef NodeDeque::iterator NodeDequeIter;
-
-typedef std::vector<Node*, NodePtrZoneAllocator> NodeVector;
+typedef ZoneVector<Node*> NodeVector;
 typedef NodeVector::iterator NodeVectorIter;
 typedef NodeVector::reverse_iterator NodeVectorRIter;

-typedef zone_allocator<NodeVector> ZoneNodeVectorAllocator;
-typedef std::vector<NodeVector, ZoneNodeVectorAllocator> NodeVectorVector;
+typedef ZoneVector<NodeVector> NodeVectorVector;
 typedef NodeVectorVector::iterator NodeVectorVectorIter;
 typedef NodeVectorVector::reverse_iterator NodeVectorVectorRIter;

=======================================
--- /branches/bleeding_edge/src/compiler/raw-machine-assembler.h Mon Aug 11 15:55:28 2014 UTC +++ /branches/bleeding_edge/src/compiler/raw-machine-assembler.h Tue Aug 26 13:09:08 2014 UTC
@@ -108,9 +108,6 @@
   BasicBlock* EnsureBlock(Label* label);
   BasicBlock* CurrentBlock();

-  typedef std::vector<MachineType, zone_allocator<MachineType> >
-      RepresentationVector;
-
   Schedule* schedule_;
   MachineOperatorBuilder machine_;
   CommonOperatorBuilder common_;
=======================================
--- /branches/bleeding_edge/src/compiler/schedule.h Mon Aug 18 13:28:10 2014 UTC +++ /branches/bleeding_edge/src/compiler/schedule.h Tue Aug 26 13:09:08 2014 UTC
@@ -63,7 +63,7 @@
         deferred_(false),
         control_(kNone),
         control_input_(NULL),
-        nodes_(NodeVector::allocator_type(zone)) {}
+        nodes_(zone) {}

   inline bool IsLoopHeader() const { return loop_end_ >= 0; }
   inline bool LoopContains(BasicBlockData* block) const {
@@ -145,8 +145,7 @@
 typedef GenericGraphVisit::NullNodeVisitor<BasicBlockData, BasicBlock>
     NullBasicBlockVisitor;

-typedef zone_allocator<BasicBlock*> BasicBlockPtrZoneAllocator;
-typedef std::vector<BasicBlock*, BasicBlockPtrZoneAllocator> BasicBlockVector;
+typedef ZoneVector<BasicBlock*> BasicBlockVector;
 typedef BasicBlockVector::iterator BasicBlockVectorIter;
 typedef BasicBlockVector::reverse_iterator BasicBlockVectorRIter;

@@ -159,10 +158,10 @@
   explicit Schedule(Zone* zone)
       : GenericGraph<BasicBlock>(zone),
         zone_(zone),
-        all_blocks_(BasicBlockVector::allocator_type(zone)),
-        nodeid_to_block_(BasicBlockVector::allocator_type(zone)),
-        rpo_order_(BasicBlockVector::allocator_type(zone)),
-        immediate_dominator_(BasicBlockVector::allocator_type(zone)) {
+        all_blocks_(zone),
+        nodeid_to_block_(zone),
+        rpo_order_(zone),
+        immediate_dominator_(zone) {
     SetStart(NewBasicBlock());  // entry.
     SetEnd(NewBasicBlock());    // exit.
   }
=======================================
--- /branches/bleeding_edge/src/compiler/scheduler.cc Wed Aug 20 08:56:57 2014 UTC +++ /branches/bleeding_edge/src/compiler/scheduler.cc Tue Aug 26 13:09:08 2014 UTC
@@ -207,10 +207,10 @@
     : zone_(zone),
       graph_(graph),
       schedule_(schedule),
-      unscheduled_uses_(IntVector::allocator_type(zone)),
-      scheduled_nodes_(NodeVectorVector::allocator_type(zone)),
-      schedule_root_nodes_(NodeVector::allocator_type(zone)),
-      schedule_early_rpo_index_(IntVector::allocator_type(zone)) {}
+      unscheduled_uses_(zone),
+      scheduled_nodes_(zone),
+      schedule_root_nodes_(zone),
+      schedule_early_rpo_index_(zone) {}


 Schedule* Scheduler::ComputeSchedule(Graph* graph) {
@@ -273,8 +273,7 @@

 void Scheduler::PrepareAuxiliaryBlockData() {
   Zone* zone = schedule_->zone();
-  scheduled_nodes_.resize(schedule_->BasicBlockCount(),
-                          NodeVector(NodeVector::allocator_type(zone)));
+  scheduled_nodes_.resize(schedule_->BasicBlockCount(), NodeVector(zone));
schedule_->immediate_dominator_.resize(schedule_->BasicBlockCount(), NULL);
 }

=======================================
--- /branches/bleeding_edge/src/compiler/scheduler.h Wed Aug 20 08:56:57 2014 UTC +++ /branches/bleeding_edge/src/compiler/scheduler.h Tue Aug 26 13:09:08 2014 UTC
@@ -5,13 +5,10 @@
 #ifndef V8_COMPILER_SCHEDULER_H_
 #define V8_COMPILER_SCHEDULER_H_

-#include <vector>
-
 #include "src/v8.h"

 #include "src/compiler/opcodes.h"
 #include "src/compiler/schedule.h"
-#include "src/zone-allocator.h"
 #include "src/zone-containers.h"

 namespace v8 {
=======================================
--- /branches/bleeding_edge/src/compiler/simplified-lowering.cc Tue Aug 26 08:29:12 2014 UTC +++ /branches/bleeding_edge/src/compiler/simplified-lowering.cc Tue Aug 26 13:09:08 2014 UTC
@@ -4,9 +4,6 @@

 #include "src/compiler/simplified-lowering.h"

-#include <deque>
-#include <queue>
-
 #include "src/compiler/common-operator.h"
 #include "src/compiler/graph-inl.h"
 #include "src/compiler/node-properties-inl.h"
@@ -65,13 +62,12 @@
       : jsgraph_(jsgraph),
         count_(jsgraph->graph()->NodeCount()),
         info_(zone->NewArray<NodeInfo>(count_)),
-        nodes_(NodeVector::allocator_type(zone)),
-        replacements_(NodeVector::allocator_type(zone)),
+        nodes_(zone),
+        replacements_(zone),
         contains_js_nodes_(false),
         phase_(PROPAGATE),
         changer_(changer),
-        queue_(std::deque<Node*, NodePtrZoneAllocator>(
-            NodePtrZoneAllocator(zone))) {
+        queue_(zone) {
     memset(info_, 0, sizeof(NodeInfo) * count_);
   }

@@ -704,8 +700,7 @@
   bool contains_js_nodes_;          // {true} if a JS operator was seen
   Phase phase_;                     // current phase of algorithm
   RepresentationChanger* changer_;  // for inserting representation changes
-
-  std::queue<Node*, std::deque<Node*, NodePtrZoneAllocator> > queue_;
+  ZoneQueue<Node*> queue_;          // queue for traversing the graph

   NodeInfo* GetInfo(Node* node) {
     DCHECK(node->id() >= 0);
=======================================
--- /branches/bleeding_edge/src/compiler/structured-machine-assembler.cc Mon Aug 18 13:28:10 2014 UTC +++ /branches/bleeding_edge/src/compiler/structured-machine-assembler.cc Tue Aug 26 13:09:08 2014 UTC
@@ -306,16 +306,14 @@
 StructuredMachineAssembler::Environment::Environment(Zone* zone,
                                                      BasicBlock* block,
                                                      bool is_dead)
-    : block_(block),
-      variables_(NodeVector::allocator_type(zone)),
-      is_dead_(is_dead) {}
+    : block_(block), variables_(zone), is_dead_(is_dead) {}


 StructuredMachineAssembler::IfBuilder::IfBuilder(
     StructuredMachineAssembler* smasm)
     : smasm_(smasm),
-      if_clauses_(IfClauses::allocator_type(smasm_->zone())),
- pending_exit_merges_(EnvironmentVector::allocator_type(smasm_->zone())) {
+      if_clauses_(smasm_->zone()),
+      pending_exit_merges_(smasm_->zone()) {
   DCHECK(smasm_->current_environment_ != NULL);
   PushNewIfClause();
   DCHECK(!IsDone());
@@ -394,9 +392,9 @@
     Zone* zone, int initial_environment_size)
     : unresolved_list_tail_(NULL),
       initial_environment_size_(initial_environment_size),
-      expression_states_(ExpressionStates::allocator_type(zone)),
-      pending_then_merges_(PendingMergeStack::allocator_type(zone)),
-      pending_else_merges_(PendingMergeStack::allocator_type(zone)),
+      expression_states_(zone),
+      pending_then_merges_(zone),
+      pending_else_merges_(zone),
       then_environment_(NULL),
       else_environment_(NULL) {
   PushNewExpressionState();
@@ -439,8 +437,7 @@
     smasm->current_environment_ =
         smasm->Copy(unresolved_list_tail_->environment_, truncate_at);
   } else {
-    EnvironmentVector environments(
-        EnvironmentVector::allocator_type(smasm->zone()));
+    EnvironmentVector environments(smasm->zone());
     environments.reserve(data.size_);
     CopyEnvironments(data, &environments);
     DCHECK(static_cast<int>(environments.size()) == data.size_);
@@ -610,8 +607,8 @@
     StructuredMachineAssembler* smasm)
     : smasm_(smasm),
       header_environment_(NULL),
- pending_header_merges_(EnvironmentVector::allocator_type(smasm_->zone())), - pending_exit_merges_(EnvironmentVector::allocator_type(smasm_->zone())) {
+      pending_header_merges_(smasm_->zone()),
+      pending_exit_merges_(smasm_->zone()) {
   DCHECK(smasm_->current_environment_ != NULL);
   // Create header environment.
header_environment_ = smasm_->CopyForLoopHeader(smasm_->current_environment_);
=======================================
--- /branches/bleeding_edge/src/compiler/structured-machine-assembler.h Mon Aug 11 15:55:28 2014 UTC +++ /branches/bleeding_edge/src/compiler/structured-machine-assembler.h Tue Aug 26 13:09:08 2014 UTC
@@ -101,8 +101,7 @@
  private:
   bool ScheduleValid() { return schedule_ != NULL; }

-  typedef std::vector<Environment*, zone_allocator<Environment*> >
-      EnvironmentVector;
+  typedef ZoneVector<Environment*> EnvironmentVector;

   NodeVector* CurrentVars() { return &current_environment_->variables_; }
   Node*& VariableAt(Environment* environment, int offset);
@@ -124,9 +123,6 @@
   void MergeBackEdgesToLoopHeader(Environment* header,
                                   EnvironmentVector* environments);

-  typedef std::vector<MachineType, zone_allocator<MachineType> >
-      RepresentationVector;
-
   Schedule* schedule_;
   MachineOperatorBuilder machine_;
   CommonOperatorBuilder common_;
@@ -214,12 +210,10 @@
     int pending_else_size_;
   };

-  typedef std::vector<ExpressionState, zone_allocator<ExpressionState> >
-      ExpressionStates;
- typedef std::vector<UnresolvedBranch*, zone_allocator<UnresolvedBranch*>

-      PendingMergeStack;
+  typedef ZoneVector<ExpressionState> ExpressionStates;
+  typedef ZoneVector<UnresolvedBranch*> PendingMergeStack;
   struct IfClause;
-  typedef std::vector<IfClause*, zone_allocator<IfClause*> > IfClauses;
+  typedef ZoneVector<IfClause*> IfClauses;

   struct PendingMergeStackRange {
     PendingMergeStack* merge_stack_;
=======================================
--- /branches/bleeding_edge/src/compiler/verifier.cc Fri Aug 22 13:14:44 2014 UTC +++ /branches/bleeding_edge/src/compiler/verifier.cc Tue Aug 26 13:09:08 2014 UTC
@@ -320,9 +320,9 @@
   }

   // Verify that all blocks reachable from start are in the RPO.
-  BoolVector marked(count, false, BoolVector::allocator_type(zone));
+  BoolVector marked(count, false, zone);
   {
-    std::queue<BasicBlock*> queue;
+    ZoneQueue<BasicBlock*> queue(zone);
     queue.push(start);
     marked[start->id()] = true;
     while (!queue.empty()) {
@@ -358,7 +358,7 @@

     // Compute a set of all the nodes that dominate a given node by using
     // a forward fixpoint. O(n^2).
-    std::queue<BasicBlock*> queue;
+    ZoneQueue<BasicBlock*> queue(zone);
     queue.push(start);
     dominators[start->id()] = new (zone) BitVector(count, zone);
     while (!queue.empty()) {
=======================================
--- /branches/bleeding_edge/src/zone-containers.h Wed Jul 30 13:54:45 2014 UTC +++ /branches/bleeding_edge/src/zone-containers.h Tue Aug 26 13:09:08 2014 UTC
@@ -5,6 +5,8 @@
 #ifndef V8_ZONE_CONTAINERS_H_
 #define V8_ZONE_CONTAINERS_H_

+#include <deque>
+#include <queue>
 #include <vector>

 #include "src/zone-allocator.h"
@@ -12,12 +14,44 @@
 namespace v8 {
 namespace internal {

-typedef std::vector<bool, ZoneBoolAllocator> BoolVector;
+// A wrapper subclass for std::vector to make it easy to construct one
+// that uses a zone allocator.
+template <typename T>
+class ZoneVector : public std::vector<T, zone_allocator<T>> {
+ public:
+  // Constructs an empty vector.
+  explicit ZoneVector(Zone* zone)
+      : std::vector<T, zone_allocator<T>>(zone_allocator<T>(zone)) {}

-typedef std::vector<int, ZoneIntAllocator> IntVector;
-typedef IntVector::iterator IntVectorIter;
-typedef IntVector::reverse_iterator IntVectorRIter;
+  // Constructs a new vector and fills it with {size} elements, each
+  // having the value {def}.
+  ZoneVector(int size, T def, Zone* zone)
+ : std::vector<T, zone_allocator<T>>(size, def, zone_allocator<T>(zone)) {}
+};

+// A wrapper subclass std::deque to make it easy to construct one
+// that uses a zone allocator.
+template <typename T>
+class ZoneDeque : public std::deque<T, zone_allocator<T>> {
+ public:
+  explicit ZoneDeque(Zone* zone)
+      : std::deque<T, zone_allocator<T>>(zone_allocator<T>(zone)) {}
+};
+
+// A wrapper subclass for std::queue to make it easy to construct one
+// that uses a zone allocator.
+template <typename T>
+class ZoneQueue : public std::queue<T, std::deque<T, zone_allocator<T>>> {
+ public:
+  // Constructs an empty queue.
+  explicit ZoneQueue(Zone* zone)
+      : std::queue<T, std::deque<T, zone_allocator<T>>>(
+            std::deque<T, zone_allocator<T>>(zone_allocator<T>(zone))) {}
+};
+
+// Typedefs to shorten commonly used vectors.
+typedef ZoneVector<bool> BoolVector;
+typedef ZoneVector<int> IntVector;
 } }  // namespace v8::internal

 #endif  // V8_ZONE_CONTAINERS_H_

--
--
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.

Reply via email to