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. R=bmeurer@chromium.org, mstarzinger@chromium.org BUG= Review URL: https://codereview.chromium.org/505133003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23402 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
88a842d628
commit
261b142fc0
@ -19,11 +19,9 @@ CodeGenerator::CodeGenerator(InstructionSequence* code)
|
||||
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);
|
||||
}
|
||||
|
@ -122,23 +122,15 @@ class CodeGenerator V8_FINAL : public GapResolver::Assembler {
|
||||
: 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_;
|
||||
};
|
||||
|
||||
|
@ -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 @@ class GenericGraphVisit {
|
||||
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);
|
||||
|
@ -141,7 +141,7 @@ template <class B, class S>
|
||||
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]);
|
||||
}
|
||||
|
@ -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 @@ class GenericNode : public B {
|
||||
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;
|
||||
|
@ -104,7 +104,7 @@ StructuredGraphBuilder::Environment::Environment(
|
||||
: builder_(builder),
|
||||
control_dependency_(control_dependency),
|
||||
effect_dependency_(control_dependency),
|
||||
values_(NodeVector::allocator_type(zone())) {}
|
||||
values_(zone()) {}
|
||||
|
||||
|
||||
StructuredGraphBuilder::Environment::Environment(const Environment& copy)
|
||||
|
@ -13,7 +13,7 @@ namespace internal {
|
||||
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 @@ static bool NodeIdIsLessThan(const Node* node, NodeId id) {
|
||||
|
||||
|
||||
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();
|
||||
|
@ -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 @@ class GraphReducer V8_FINAL {
|
||||
void ReduceGraph();
|
||||
|
||||
private:
|
||||
typedef std::list<Reducer*, zone_allocator<Reducer*> > Reducers;
|
||||
|
||||
Graph* graph_;
|
||||
Reducers reducers_;
|
||||
ZoneVector<Reducer*> reducers_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(GraphReducer);
|
||||
};
|
||||
|
@ -18,16 +18,14 @@ namespace v8 {
|
||||
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);
|
||||
}
|
||||
|
@ -72,16 +72,14 @@ class Graph : public GenericGraph<Node> {
|
||||
}
|
||||
|
||||
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_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -21,9 +21,9 @@ InstructionSelector::InstructionSelector(InstructionSequence* sequence,
|
||||
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 @@ CallBuffer::CallBuffer(Zone* zone, CallDescriptor* d,
|
||||
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 @@ void InstructionSelector::VisitDeoptimize(Node* deopt) {
|
||||
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);
|
||||
|
@ -197,15 +197,12 @@ class InstructionSelector V8_FINAL {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
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_;
|
||||
};
|
||||
|
@ -89,8 +89,7 @@ class InstructionOperand : public ZoneObject {
|
||||
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 @@ class FrameStateDescriptor : public ZoneObject {
|
||||
|
||||
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 @@ class InstructionSequence V8_FINAL {
|
||||
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_; }
|
||||
|
@ -152,8 +152,8 @@ void Inlinee::UnifyReturn() {
|
||||
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();
|
||||
|
@ -15,7 +15,7 @@ namespace compiler {
|
||||
|
||||
template <class T>
|
||||
NodeAuxData<T>::NodeAuxData(Zone* zone)
|
||||
: aux_data_(ZoneAllocator(zone)) {}
|
||||
: aux_data_(zone) {}
|
||||
|
||||
|
||||
template <class T>
|
||||
|
@ -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 @@ class NodeAuxData {
|
||||
inline T Get(Node* node);
|
||||
|
||||
private:
|
||||
typedef zone_allocator<T> ZoneAllocator;
|
||||
typedef std::vector<T, ZoneAllocator> TZoneVector;
|
||||
|
||||
TZoneVector aux_data_;
|
||||
ZoneVector<T> aux_data_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -54,8 +54,7 @@ class Node : public GenericNode<NodeData, Node> {
|
||||
|
||||
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 @@ OStream& operator<<(OStream& os, const Node& n);
|
||||
|
||||
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;
|
||||
|
||||
|
@ -108,9 +108,6 @@ class RawMachineAssembler : public GraphBuilder,
|
||||
BasicBlock* EnsureBlock(Label* label);
|
||||
BasicBlock* CurrentBlock();
|
||||
|
||||
typedef std::vector<MachineType, zone_allocator<MachineType> >
|
||||
RepresentationVector;
|
||||
|
||||
Schedule* schedule_;
|
||||
MachineOperatorBuilder machine_;
|
||||
CommonOperatorBuilder common_;
|
||||
|
@ -63,7 +63,7 @@ class BasicBlockData {
|
||||
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 @@ class BasicBlock V8_FINAL : public GenericNode<BasicBlockData, BasicBlock> {
|
||||
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 @@ class Schedule : public GenericGraph<BasicBlock> {
|
||||
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.
|
||||
}
|
||||
|
@ -207,10 +207,10 @@ Scheduler::Scheduler(Zone* zone, Graph* graph, Schedule* schedule)
|
||||
: 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::PrepareAuxiliaryNodeData() {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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 @@ class RepresentationSelector {
|
||||
: 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 @@ class RepresentationSelector {
|
||||
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);
|
||||
|
@ -306,16 +306,14 @@ void StructuredMachineAssembler::AddBranch(Environment* environment,
|
||||
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 @@ StructuredMachineAssembler::IfBuilder::IfClause::IfClause(
|
||||
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 @@ void StructuredMachineAssembler::IfBuilder::IfClause::ResolvePendingMerges(
|
||||
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::LoopBuilder::LoopBuilder(
|
||||
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_);
|
||||
|
@ -101,8 +101,7 @@ class StructuredMachineAssembler
|
||||
private:
|
||||
bool ScheduleValid() { return schedule_ != NULL; }
|
||||
|
||||
typedef std::vector<Environment*, zone_allocator<Environment*> >
|
||||
EnvironmentVector;
|
||||
typedef ZoneVector<Environment*> EnvironmentVector;
|
||||
|
||||
NodeVector* CurrentVars() { return ¤t_environment_->variables_; }
|
||||
Node*& VariableAt(Environment* environment, int offset);
|
||||
@ -124,9 +123,6 @@ class StructuredMachineAssembler
|
||||
void MergeBackEdgesToLoopHeader(Environment* header,
|
||||
EnvironmentVector* environments);
|
||||
|
||||
typedef std::vector<MachineType, zone_allocator<MachineType> >
|
||||
RepresentationVector;
|
||||
|
||||
Schedule* schedule_;
|
||||
MachineOperatorBuilder machine_;
|
||||
CommonOperatorBuilder common_;
|
||||
@ -214,12 +210,10 @@ class StructuredMachineAssembler::IfBuilder {
|
||||
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_;
|
||||
|
@ -320,9 +320,9 @@ void ScheduleVerifier::Run(Schedule* schedule) {
|
||||
}
|
||||
|
||||
// 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 @@ void ScheduleVerifier::Run(Schedule* schedule) {
|
||||
|
||||
// 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()) {
|
||||
|
@ -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_
|
||||
|
Loading…
Reference in New Issue
Block a user