V8 Project
v8::internal::compiler::CFGBuilder Class Reference
+ Collaboration diagram for v8::internal::compiler::CFGBuilder:

Public Member Functions

 CFGBuilder (Zone *zone, Scheduler *scheduler)
 
void Run ()
 
void FixNode (BasicBlock *block, Node *node)
 
void Queue (Node *node)
 
void BuildBlocks (Node *node)
 
void ConnectBlocks (Node *node)
 
void BuildBlockForNode (Node *node)
 
void BuildBlocksForSuccessors (Node *node, IrOpcode::Value a, IrOpcode::Value b)
 
void CollectSuccessorProjections (Node *node, Node **buffer, IrOpcode::Value true_opcode, IrOpcode::Value false_opcode)
 
void CollectSuccessorBlocks (Node *node, BasicBlock **buffer, IrOpcode::Value true_opcode, IrOpcode::Value false_opcode)
 
void ConnectBranch (Node *branch)
 
void ConnectMerge (Node *merge)
 
void ConnectReturn (Node *ret)
 
void TraceConnect (Node *node, BasicBlock *block, BasicBlock *succ)
 

Public Attributes

Schedulerscheduler_
 
Scheduleschedule_
 
ZoneQueue< Node * > queue_
 
NodeVector control_
 

Detailed Description

Definition at line 35 of file scheduler.cc.

Constructor & Destructor Documentation

◆ CFGBuilder()

v8::internal::compiler::CFGBuilder::CFGBuilder ( Zone zone,
Scheduler scheduler 
)
inline

Definition at line 42 of file scheduler.cc.

43  : scheduler_(scheduler),
44  schedule_(scheduler->schedule_),
45  queue_(zone),
46  control_(zone) {}
ZoneQueue< Node * > queue_
Definition: scheduler.cc:39

Member Function Documentation

◆ BuildBlockForNode()

void v8::internal::compiler::CFGBuilder::BuildBlockForNode ( Node *  node)
inline

Definition at line 122 of file scheduler.cc.

122  {
123  if (schedule_->block(node) == NULL) {
124  BasicBlock* block = schedule_->NewBasicBlock();
125  Trace("Create block B%d for #%d:%s\n", block->id(), node->id(),
126  node->op()->mnemonic());
127  FixNode(block, node);
128  }
129  }
void FixNode(BasicBlock *block, Node *node)
Definition: scheduler.cc:72
BasicBlock * block(Node *node) const
Definition: schedule.h:171
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
static void Trace(const char *msg,...)
Definition: scheduler.cc:21

References v8::internal::compiler::Schedule::block(), FixNode(), v8::internal::compiler::Schedule::NewBasicBlock(), NULL, schedule_, and v8::internal::compiler::Trace().

Referenced by BuildBlocks(), and BuildBlocksForSuccessors().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BuildBlocks()

void v8::internal::compiler::CFGBuilder::BuildBlocks ( Node *  node)
inline

Definition at line 89 of file scheduler.cc.

89  {
90  switch (node->opcode()) {
91  case IrOpcode::kLoop:
92  case IrOpcode::kMerge:
93  BuildBlockForNode(node);
94  break;
95  case IrOpcode::kBranch:
96  BuildBlocksForSuccessors(node, IrOpcode::kIfTrue, IrOpcode::kIfFalse);
97  break;
98  default:
99  break;
100  }
101  }
void BuildBlockForNode(Node *node)
Definition: scheduler.cc:122
void BuildBlocksForSuccessors(Node *node, IrOpcode::Value a, IrOpcode::Value b)
Definition: scheduler.cc:131

References BuildBlockForNode(), and BuildBlocksForSuccessors().

Referenced by Queue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BuildBlocksForSuccessors()

void v8::internal::compiler::CFGBuilder::BuildBlocksForSuccessors ( Node *  node,
IrOpcode::Value  a,
IrOpcode::Value  b 
)
inline

Definition at line 131 of file scheduler.cc.

132  {
133  Node* successors[2];
134  CollectSuccessorProjections(node, successors, a, b);
135  BuildBlockForNode(successors[0]);
136  BuildBlockForNode(successors[1]);
137  }
void CollectSuccessorProjections(Node *node, Node **buffer, IrOpcode::Value true_opcode, IrOpcode::Value false_opcode)
Definition: scheduler.cc:142

References BuildBlockForNode(), and CollectSuccessorProjections().

Referenced by BuildBlocks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CollectSuccessorBlocks()

void v8::internal::compiler::CFGBuilder::CollectSuccessorBlocks ( Node *  node,
BasicBlock **  buffer,
IrOpcode::Value  true_opcode,
IrOpcode::Value  false_opcode 
)
inline

Definition at line 161 of file scheduler.cc.

163  {
164  Node* successors[2];
165  CollectSuccessorProjections(node, successors, true_opcode, false_opcode);
166  buffer[0] = schedule_->block(successors[0]);
167  buffer[1] = schedule_->block(successors[1]);
168  }

References v8::internal::compiler::Schedule::block(), CollectSuccessorProjections(), and schedule_.

Referenced by ConnectBranch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CollectSuccessorProjections()

void v8::internal::compiler::CFGBuilder::CollectSuccessorProjections ( Node *  node,
Node **  buffer,
IrOpcode::Value  true_opcode,
IrOpcode::Value  false_opcode 
)
inline

Definition at line 142 of file scheduler.cc.

144  {
145  buffer[0] = NULL;
146  buffer[1] = NULL;
147  for (UseIter i = node->uses().begin(); i != node->uses().end(); ++i) {
148  if ((*i)->opcode() == true_opcode) {
149  DCHECK_EQ(NULL, buffer[0]);
150  buffer[0] = *i;
151  }
152  if ((*i)->opcode() == false_opcode) {
153  DCHECK_EQ(NULL, buffer[1]);
154  buffer[1] = *i;
155  }
156  }
157  DCHECK_NE(NULL, buffer[0]);
158  DCHECK_NE(NULL, buffer[1]);
159  }
#define DCHECK_NE(v1, v2)
Definition: logging.h:207
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206
Node::Uses::iterator UseIter
Definition: node.h:81

References DCHECK_EQ, DCHECK_NE, and NULL.

Referenced by BuildBlocksForSuccessors(), and CollectSuccessorBlocks().

+ Here is the caller graph for this function:

◆ ConnectBlocks()

void v8::internal::compiler::CFGBuilder::ConnectBlocks ( Node *  node)
inline

Definition at line 103 of file scheduler.cc.

103  {
104  switch (node->opcode()) {
105  case IrOpcode::kLoop:
106  case IrOpcode::kMerge:
107  ConnectMerge(node);
108  break;
109  case IrOpcode::kBranch:
110  scheduler_->schedule_root_nodes_.push_back(node);
111  ConnectBranch(node);
112  break;
113  case IrOpcode::kReturn:
114  scheduler_->schedule_root_nodes_.push_back(node);
115  ConnectReturn(node);
116  break;
117  default:
118  break;
119  }
120  }
void ConnectBranch(Node *branch)
Definition: scheduler.cc:170

References ConnectBranch(), ConnectMerge(), ConnectReturn(), v8::internal::compiler::Scheduler::schedule_root_nodes_, and scheduler_.

Referenced by Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConnectBranch()

void v8::internal::compiler::CFGBuilder::ConnectBranch ( Node *  branch)
inline

Definition at line 170 of file scheduler.cc.

170  {
171  Node* branch_block_node = NodeProperties::GetControlInput(branch);
172  BasicBlock* branch_block = schedule_->block(branch_block_node);
173  DCHECK(branch_block != NULL);
174 
175  BasicBlock* successor_blocks[2];
176  CollectSuccessorBlocks(branch, successor_blocks, IrOpcode::kIfTrue,
177  IrOpcode::kIfFalse);
178 
179  TraceConnect(branch, branch_block, successor_blocks[0]);
180  TraceConnect(branch, branch_block, successor_blocks[1]);
181 
182  schedule_->AddBranch(branch_block, branch, successor_blocks[0],
183  successor_blocks[1]);
184  }
void TraceConnect(Node *node, BasicBlock *block, BasicBlock *succ)
Definition: scheduler.cc:208
void CollectSuccessorBlocks(Node *node, BasicBlock **buffer, IrOpcode::Value true_opcode, IrOpcode::Value false_opcode)
Definition: scheduler.cc:161
static Node * GetControlInput(Node *node, int index=0)
void AddBranch(BasicBlock *block, Node *branch, BasicBlock *tblock, BasicBlock *fblock)
Definition: schedule.h:238
#define DCHECK(condition)
Definition: logging.h:205

References v8::internal::compiler::Schedule::AddBranch(), v8::internal::compiler::Schedule::block(), CollectSuccessorBlocks(), DCHECK, v8::internal::compiler::NodeProperties::GetControlInput(), NULL, schedule_, and TraceConnect().

Referenced by ConnectBlocks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConnectMerge()

void v8::internal::compiler::CFGBuilder::ConnectMerge ( Node *  merge)
inline

Definition at line 186 of file scheduler.cc.

186  {
187  BasicBlock* block = schedule_->block(merge);
188  DCHECK(block != NULL);
189  // For all of the merge's control inputs, add a goto at the end to the
190  // merge's basic block.
191  for (InputIter j = merge->inputs().begin(); j != merge->inputs().end();
192  ++j) {
193  BasicBlock* predecessor_block = schedule_->block(*j);
194  if ((*j)->opcode() != IrOpcode::kReturn) {
195  TraceConnect(merge, predecessor_block, block);
196  schedule_->AddGoto(predecessor_block, block);
197  }
198  }
199  }
void AddGoto(BasicBlock *block, BasicBlock *succ)
Definition: schedule.h:231
Node::Inputs::iterator InputIter
Definition: node.h:82

References v8::internal::compiler::Schedule::AddGoto(), v8::internal::compiler::Schedule::block(), DCHECK, NULL, schedule_, and TraceConnect().

Referenced by ConnectBlocks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConnectReturn()

void v8::internal::compiler::CFGBuilder::ConnectReturn ( Node *  ret)
inline

Definition at line 201 of file scheduler.cc.

201  {
202  Node* return_block_node = NodeProperties::GetControlInput(ret);
203  BasicBlock* return_block = schedule_->block(return_block_node);
204  TraceConnect(ret, return_block, NULL);
205  schedule_->AddReturn(return_block, ret);
206  }
void AddReturn(BasicBlock *block, Node *input)
Definition: schedule.h:253

References v8::internal::compiler::Schedule::AddReturn(), v8::internal::compiler::Schedule::block(), v8::internal::compiler::NodeProperties::GetControlInput(), NULL, schedule_, and TraceConnect().

Referenced by ConnectBlocks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FixNode()

void v8::internal::compiler::CFGBuilder::FixNode ( BasicBlock *  block,
Node *  node 
)
inline

Definition at line 72 of file scheduler.cc.

References v8::internal::compiler::Schedule::AddNode(), v8::internal::compiler::Scheduler::GetData(), v8::internal::compiler::Scheduler::SchedulerData::is_connected_control_, v8::internal::compiler::Scheduler::kFixed, v8::internal::compiler::Scheduler::SchedulerData::placement_, schedule_, and scheduler_.

Referenced by BuildBlockForNode(), and Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Queue()

void v8::internal::compiler::CFGBuilder::Queue ( Node *  node)
inline

Definition at line 78 of file scheduler.cc.

78  {
79  // Mark the connected control nodes as they queued.
80  Scheduler::SchedulerData* data = scheduler_->GetData(node);
81  if (!data->is_connected_control_) {
82  BuildBlocks(node);
83  queue_.push(node);
84  control_.push_back(node);
85  data->is_connected_control_ = true;
86  }
87  }

References BuildBlocks(), control_, v8::internal::compiler::Scheduler::GetData(), v8::internal::compiler::Scheduler::SchedulerData::is_connected_control_, queue_, and scheduler_.

Referenced by Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Run()

void v8::internal::compiler::CFGBuilder::Run ( )
inline

Definition at line 51 of file scheduler.cc.

51  {
52  Graph* graph = scheduler_->graph_;
53  FixNode(schedule_->start(), graph->start());
54  Queue(graph->end());
55 
56  while (!queue_.empty()) { // Breadth-first backwards traversal.
57  Node* node = queue_.front();
58  queue_.pop();
59  int max = NodeProperties::PastControlIndex(node);
60  for (int i = NodeProperties::FirstControlIndex(node); i < max; i++) {
61  Queue(node->InputAt(i));
62  }
63  }
64 
65  for (NodeVector::iterator i = control_.begin(); i != control_.end(); ++i) {
66  ConnectBlocks(*i); // Connect block to its predecessor/successors.
67  }
68 
69  FixNode(schedule_->end(), graph->end());
70  }

References ConnectBlocks(), control_, v8::internal::compiler::GenericGraph< V >::end(), v8::internal::compiler::NodeProperties::FirstControlIndex(), FixNode(), v8::internal::compiler::Scheduler::graph_, v8::internal::compiler::NodeProperties::PastControlIndex(), Queue(), queue_, schedule_, scheduler_, and v8::internal::compiler::GenericGraph< V >::start().

Referenced by v8::internal::compiler::Scheduler::BuildCFG().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TraceConnect()

void v8::internal::compiler::CFGBuilder::TraceConnect ( Node *  node,
BasicBlock *  block,
BasicBlock *  succ 
)
inline

Definition at line 208 of file scheduler.cc.

208  {
209  DCHECK_NE(NULL, block);
210  if (succ == NULL) {
211  Trace("Connect #%d:%s, B%d -> end\n", node->id(), node->op()->mnemonic(),
212  block->id());
213  } else {
214  Trace("Connect #%d:%s, B%d -> B%d\n", node->id(), node->op()->mnemonic(),
215  block->id(), succ->id());
216  }
217  }

References DCHECK_NE, NULL, and v8::internal::compiler::Trace().

Referenced by ConnectBranch(), ConnectMerge(), and ConnectReturn().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ control_

NodeVector v8::internal::compiler::CFGBuilder::control_

Definition at line 40 of file scheduler.cc.

Referenced by Queue(), and Run().

◆ queue_

ZoneQueue<Node*> v8::internal::compiler::CFGBuilder::queue_

Definition at line 39 of file scheduler.cc.

Referenced by Queue(), and Run().

◆ schedule_

Schedule* v8::internal::compiler::CFGBuilder::schedule_

◆ scheduler_

Scheduler* v8::internal::compiler::CFGBuilder::scheduler_

Definition at line 37 of file scheduler.cc.

Referenced by ConnectBlocks(), FixNode(), Queue(), and Run().


The documentation for this class was generated from the following file: