V8 Project
v8::internal::compiler::StructuredGraphBuilder Class Reference

#include <graph-builder.h>

+ Inheritance diagram for v8::internal::compiler::StructuredGraphBuilder:
+ Collaboration diagram for v8::internal::compiler::StructuredGraphBuilder:

Classes

class  Environment
 

Public Member Functions

 StructuredGraphBuilder (Graph *graph, CommonOperatorBuilder *common)
 
virtual ~StructuredGraphBuilder ()
 
Node * NewPhi (int count, Node *input, Node *control)
 
Node * NewEffectPhi (int count, Node *input, Node *control)
 
Node * MergeControl (Node *control, Node *other)
 
Node * MergeEffect (Node *value, Node *other, Node *control)
 
Node * MergeValue (Node *value, Node *other, Node *control)
 
Node * NewIfTrue ()
 
Node * NewIfFalse ()
 
Node * NewMerge ()
 
Node * NewLoop ()
 
Node * NewBranch (Node *condition)
 
- Public Member Functions inherited from v8::internal::compiler::GraphBuilder
 GraphBuilder (Graph *graph)
 
virtual ~GraphBuilder ()
 
Node * NewNode (const Operator *op)
 
Node * NewNode (const Operator *op, Node *n1)
 
Node * NewNode (const Operator *op, Node *n1, Node *n2)
 
Node * NewNode (const Operator *op, Node *n1, Node *n2, Node *n3)
 
Node * NewNode (const Operator *op, Node *n1, Node *n2, Node *n3, Node *n4)
 
Node * NewNode (const Operator *op, Node *n1, Node *n2, Node *n3, Node *n4, Node *n5)
 
Node * NewNode (const Operator *op, Node *n1, Node *n2, Node *n3, Node *n4, Node *n5, Node *n6)
 
Node * NewNode (const Operator *op, int value_input_count, Node **value_inputs)
 
Graphgraph () const
 

Protected Member Functions

virtual Node * MakeNode (const Operator *op, int value_input_count, Node **value_inputs) FINAL
 
Environmentenvironment () const
 
void set_environment (Environment *env)
 
Node * current_context () const
 
void set_current_context (Node *context)
 
Node * exit_control () const
 
void set_exit_control (Node *node)
 
Node * dead_control ()
 
Zonezone () const
 
Isolateisolate () const
 
CommonOperatorBuilder * common () const
 
template<class T >
Unique< TMakeUnique (Handle< T > object)
 
virtual EnvironmentCopyEnvironment (Environment *env)
 
void UpdateControlDependencyToLeaveFunction (Node *exit)
 

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (StructuredGraphBuilder)
 

Private Attributes

CommonOperatorBuilder * common_
 
Environmentenvironment_
 
SetOncePointer< Node > dead_control_
 
Node * current_context_
 
Node * exit_control_
 

Friends

class Environment
 
class ControlBuilder
 

Detailed Description

Definition at line 80 of file graph-builder.h.

Constructor & Destructor Documentation

◆ StructuredGraphBuilder()

v8::internal::compiler::StructuredGraphBuilder::StructuredGraphBuilder ( Graph graph,
CommonOperatorBuilder *  common 
)

Definition at line 22 of file graph-builder.cc.

25  common_(common),
CommonOperatorBuilder * common() const
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

◆ ~StructuredGraphBuilder()

virtual v8::internal::compiler::StructuredGraphBuilder::~StructuredGraphBuilder ( )
inlinevirtual

Definition at line 83 of file graph-builder.h.

83 {}

Member Function Documentation

◆ common()

◆ CopyEnvironment()

StructuredGraphBuilder::Environment * v8::internal::compiler::StructuredGraphBuilder::CopyEnvironment ( Environment env)
protectedvirtual

Reimplemented in v8::internal::compiler::AstGraphBuilder.

Definition at line 96 of file graph-builder.cc.

97  {
98  return new (zone()) Environment(*env);
99 }

References Environment, and zone().

Referenced by v8::internal::compiler::StructuredGraphBuilder::Environment::CopyAsUnreachable(), v8::internal::compiler::StructuredGraphBuilder::Environment::CopyForConditional(), and v8::internal::compiler::StructuredGraphBuilder::Environment::CopyForLoop().

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

◆ current_context()

Node* v8::internal::compiler::StructuredGraphBuilder::current_context ( ) const
inlineprotected

◆ dead_control()

Node * v8::internal::compiler::StructuredGraphBuilder::dead_control ( )
protected

Definition at line 239 of file graph-builder.cc.

239  {
240  if (!dead_control_.is_set()) {
241  Node* dead_node = graph()->NewNode(common_->Dead());
242  dead_control_.set(dead_node);
243  return dead_node;
244  }
245  return dead_control_.get();
246 }
void set(T *value)
Definition: utils.h:417
Node * NewNode(const Operator *op, int input_count, Node **inputs)
Definition: graph.cc:24

References common_, dead_control_, v8::internal::SetOncePointer< T >::get(), v8::internal::compiler::GraphBuilder::graph(), v8::internal::SetOncePointer< T >::is_set(), v8::internal::compiler::Graph::NewNode(), and v8::internal::SetOncePointer< T >::set().

Referenced by MakeNode(), and v8::internal::compiler::StructuredGraphBuilder::Environment::MarkAsUnreachable().

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

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::compiler::StructuredGraphBuilder::DISALLOW_COPY_AND_ASSIGN ( StructuredGraphBuilder  )
private

◆ environment()

Environment* v8::internal::compiler::StructuredGraphBuilder::environment ( ) const
inlineprotected

Definition at line 114 of file graph-builder.h.

114 { return environment_; }

References environment_.

Referenced by v8::internal::compiler::AstGraphBuilder::environment(), v8::internal::compiler::ControlBuilder::environment(), MakeNode(), and UpdateControlDependencyToLeaveFunction().

+ Here is the caller graph for this function:

◆ exit_control()

Node* v8::internal::compiler::StructuredGraphBuilder::exit_control ( ) const
inlineprotected

Definition at line 120 of file graph-builder.h.

120 { return exit_control_; }

References exit_control_.

Referenced by v8::internal::compiler::AstGraphBuilder::CreateGraph(), and UpdateControlDependencyToLeaveFunction().

+ Here is the caller graph for this function:

◆ isolate()

Isolate* v8::internal::compiler::StructuredGraphBuilder::isolate ( ) const
inlineprotected

Definition at line 127 of file graph-builder.h.

127 { return zone()->isolate(); }
Isolate * isolate() const
Definition: zone.h:68

References v8::internal::Zone::isolate(), and zone().

Referenced by v8::internal::compiler::AstGraphBuilder::VisitDeclarations().

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

◆ MakeNode()

Node * v8::internal::compiler::StructuredGraphBuilder::MakeNode ( const Operator op,
int  value_input_count,
Node **  value_inputs 
)
protectedvirtual

Implements v8::internal::compiler::GraphBuilder.

Definition at line 31 of file graph-builder.cc.

33  {
34  DCHECK(op->InputCount() == value_input_count);
35 
36  bool has_context = OperatorProperties::HasContextInput(op);
37  bool has_framestate = OperatorProperties::HasFrameStateInput(op);
38  bool has_control = OperatorProperties::GetControlInputCount(op) == 1;
39  bool has_effect = OperatorProperties::GetEffectInputCount(op) == 1;
40 
43 
44  Node* result = NULL;
45  if (!has_context && !has_framestate && !has_control && !has_effect) {
46  result = graph()->NewNode(op, value_input_count, value_inputs);
47  } else {
48  int input_count_with_deps = value_input_count;
49  if (has_context) ++input_count_with_deps;
50  if (has_framestate) ++input_count_with_deps;
51  if (has_control) ++input_count_with_deps;
52  if (has_effect) ++input_count_with_deps;
53  Node** buffer = zone()->NewArray<Node*>(input_count_with_deps);
54  memcpy(buffer, value_inputs, kPointerSize * value_input_count);
55  Node** current_input = buffer + value_input_count;
56  if (has_context) {
57  *current_input++ = current_context();
58  }
59  if (has_framestate) {
60  // The frame state will be inserted later. Here we misuse
61  // the dead_control node as a sentinel to be later overwritten
62  // with the real frame state.
63  *current_input++ = dead_control();
64  }
65  if (has_effect) {
66  *current_input++ = environment_->GetEffectDependency();
67  }
68  if (has_control) {
69  *current_input++ = environment_->GetControlDependency();
70  }
71  result = graph()->NewNode(op, input_count_with_deps, buffer);
72  if (has_effect) {
74  }
75  if (OperatorProperties::HasControlOutput(result->op()) &&
76  !environment()->IsMarkedAsUnreachable()) {
78  }
79  }
80 
81  return result;
82 }
T * NewArray(int length)
Definition: zone.h:46
static int GetEffectInputCount(const Operator *op)
static bool HasContextInput(const Operator *op)
static bool HasFrameStateInput(const Operator *op)
static int GetControlInputCount(const Operator *op)
static bool HasControlOutput(const Operator *op)
#define DCHECK(condition)
Definition: logging.h:205
const int kPointerSize
Definition: globals.h:129

References current_context(), DCHECK, dead_control(), environment(), environment_, v8::internal::compiler::StructuredGraphBuilder::Environment::GetControlDependency(), v8::internal::compiler::OperatorProperties::GetControlInputCount(), v8::internal::compiler::StructuredGraphBuilder::Environment::GetEffectDependency(), v8::internal::compiler::OperatorProperties::GetEffectInputCount(), v8::internal::compiler::GraphBuilder::graph(), v8::internal::compiler::OperatorProperties::HasContextInput(), v8::internal::compiler::OperatorProperties::HasControlOutput(), v8::internal::compiler::OperatorProperties::HasFrameStateInput(), v8::internal::compiler::Operator::InputCount(), v8::internal::kPointerSize, v8::internal::Zone::NewArray(), v8::internal::compiler::Graph::NewNode(), NULL, v8::internal::compiler::StructuredGraphBuilder::Environment::UpdateControlDependency(), v8::internal::compiler::StructuredGraphBuilder::Environment::UpdateEffectDependency(), and zone().

+ Here is the call graph for this function:

◆ MakeUnique()

template<class T >
Unique<T> v8::internal::compiler::StructuredGraphBuilder::MakeUnique ( Handle< T object)
inlineprotected

Definition at line 132 of file graph-builder.h.

132  {
133  return Unique<T>::CreateUninitialized(object);
134  }
static Unique< T > CreateUninitialized(Handle< T > handle)
Definition: unique.h:112

References v8::internal::Unique< T >::CreateUninitialized().

Referenced by v8::internal::compiler::AstGraphBuilder::BuildVariableAssignment(), v8::internal::compiler::AstGraphBuilder::BuildVariableLoad(), v8::internal::compiler::AstGraphBuilder::VisitCallJSRuntime(), and v8::internal::compiler::AstGraphBuilder::VisitForInAssignment().

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

◆ MergeControl()

Node * v8::internal::compiler::StructuredGraphBuilder::MergeControl ( Node *  control,
Node *  other 
)

Definition at line 184 of file graph-builder.cc.

184  {
185  int inputs = OperatorProperties::GetControlInputCount(control->op()) + 1;
186  if (control->opcode() == IrOpcode::kLoop) {
187  // Control node for loop exists, add input.
188  const Operator* op = common()->Loop(inputs);
189  control->AppendInput(zone(), other);
190  control->set_op(op);
191  } else if (control->opcode() == IrOpcode::kMerge) {
192  // Control node for merge exists, add input.
193  const Operator* op = common()->Merge(inputs);
194  control->AppendInput(zone(), other);
195  control->set_op(op);
196  } else {
197  // Control node is a singleton, introduce a merge.
198  const Operator* op = common()->Merge(inputs);
199  control = graph()->NewNode(op, control, other);
200  }
201  return control;
202 }

References common(), v8::internal::compiler::OperatorProperties::GetControlInputCount(), v8::internal::compiler::GraphBuilder::graph(), v8::internal::compiler::Graph::NewNode(), and zone().

Referenced by UpdateControlDependencyToLeaveFunction().

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

◆ MergeEffect()

Node * v8::internal::compiler::StructuredGraphBuilder::MergeEffect ( Node *  value,
Node *  other,
Node *  control 
)

Definition at line 205 of file graph-builder.cc.

206  {
207  int inputs = OperatorProperties::GetControlInputCount(control->op());
208  if (value->opcode() == IrOpcode::kEffectPhi &&
209  NodeProperties::GetControlInput(value) == control) {
210  // Phi already exists, add input.
211  value->set_op(common()->EffectPhi(inputs));
212  value->InsertInput(zone(), inputs - 1, other);
213  } else if (value != other) {
214  // Phi does not exist yet, introduce one.
215  value = NewEffectPhi(inputs, value, control);
216  value->ReplaceInput(inputs - 1, other);
217  }
218  return value;
219 }
static Node * GetControlInput(Node *node, int index=0)
Node * NewEffectPhi(int count, Node *input, Node *control)

References common(), v8::internal::compiler::NodeProperties::GetControlInput(), v8::internal::compiler::OperatorProperties::GetControlInputCount(), NewEffectPhi(), and zone().

+ Here is the call graph for this function:

◆ MergeValue()

Node * v8::internal::compiler::StructuredGraphBuilder::MergeValue ( Node *  value,
Node *  other,
Node *  control 
)

Definition at line 222 of file graph-builder.cc.

223  {
224  int inputs = OperatorProperties::GetControlInputCount(control->op());
225  if (value->opcode() == IrOpcode::kPhi &&
226  NodeProperties::GetControlInput(value) == control) {
227  // Phi already exists, add input.
228  value->set_op(common()->Phi(kMachAnyTagged, inputs));
229  value->InsertInput(zone(), inputs - 1, other);
230  } else if (value != other) {
231  // Phi does not exist yet, introduce one.
232  value = NewPhi(inputs, value, control);
233  value->ReplaceInput(inputs - 1, other);
234  }
235  return value;
236 }
Node * NewPhi(int count, Node *input, Node *control)

References common(), v8::internal::compiler::NodeProperties::GetControlInput(), v8::internal::compiler::OperatorProperties::GetControlInputCount(), v8::internal::compiler::kMachAnyTagged, NewPhi(), and zone().

+ Here is the call graph for this function:

◆ NewBranch()

Node* v8::internal::compiler::StructuredGraphBuilder::NewBranch ( Node *  condition)
inline

Definition at line 99 of file graph-builder.h.

99  {
100  return NewNode(common()->Branch(), condition);
101  }
Node * NewNode(const Operator *op)
Definition: graph-builder.h:27

References common(), and v8::internal::compiler::GraphBuilder::NewNode().

Referenced by v8::internal::compiler::SwitchBuilder::BeginLabel(), and v8::internal::compiler::IfBuilder::If().

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

◆ NewEffectPhi()

Node * v8::internal::compiler::StructuredGraphBuilder::NewEffectPhi ( int  count,
Node *  input,
Node *  control 
)

Definition at line 174 of file graph-builder.cc.

175  {
176  const Operator* phi_op = common()->EffectPhi(count);
177  Node** buffer = zone()->NewArray<Node*>(count + 1);
178  MemsetPointer(buffer, input, count);
179  buffer[count] = control;
180  return graph()->NewNode(phi_op, count + 1, buffer);
181 }
void MemsetPointer(T **dest, U *value, int counter)
Definition: utils.h:1183

References common(), v8::internal::compiler::GraphBuilder::graph(), v8::internal::MemsetPointer(), v8::internal::Zone::NewArray(), v8::internal::compiler::Graph::NewNode(), and zone().

Referenced by MergeEffect().

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

◆ NewIfFalse()

Node* v8::internal::compiler::StructuredGraphBuilder::NewIfFalse ( )
inline

Definition at line 96 of file graph-builder.h.

96 { return NewNode(common()->IfFalse()); }

References common(), and v8::internal::compiler::GraphBuilder::NewNode().

Referenced by v8::internal::compiler::IfBuilder::Else(), and v8::internal::compiler::SwitchBuilder::EndLabel().

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

◆ NewIfTrue()

Node* v8::internal::compiler::StructuredGraphBuilder::NewIfTrue ( )
inline

Definition at line 95 of file graph-builder.h.

95 { return NewNode(common()->IfTrue()); }

References common(), and v8::internal::compiler::GraphBuilder::NewNode().

Referenced by v8::internal::compiler::SwitchBuilder::BeginLabel(), and v8::internal::compiler::IfBuilder::Then().

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

◆ NewLoop()

Node* v8::internal::compiler::StructuredGraphBuilder::NewLoop ( )
inline

Definition at line 98 of file graph-builder.h.

98 { return NewNode(common()->Loop(1)); }

References common(), and v8::internal::compiler::GraphBuilder::NewNode().

Referenced by v8::internal::compiler::LoopBuilder::BeginLoop().

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

◆ NewMerge()

Node* v8::internal::compiler::StructuredGraphBuilder::NewMerge ( )
inline

Definition at line 97 of file graph-builder.h.

97 { return NewNode(common()->Merge(1)); }

References common(), and v8::internal::compiler::GraphBuilder::NewNode().

Referenced by v8::internal::compiler::IfBuilder::Else().

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

◆ NewPhi()

Node * v8::internal::compiler::StructuredGraphBuilder::NewPhi ( int  count,
Node *  input,
Node *  control 
)

Definition at line 164 of file graph-builder.cc.

164  {
165  const Operator* phi_op = common()->Phi(kMachAnyTagged, count);
166  Node** buffer = zone()->NewArray<Node*>(count + 1);
167  MemsetPointer(buffer, input, count);
168  buffer[count] = control;
169  return graph()->NewNode(phi_op, count + 1, buffer);
170 }

References common(), v8::internal::compiler::GraphBuilder::graph(), v8::internal::compiler::kMachAnyTagged, v8::internal::MemsetPointer(), v8::internal::Zone::NewArray(), v8::internal::compiler::Graph::NewNode(), and zone().

Referenced by MergeValue().

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

◆ set_current_context()

void v8::internal::compiler::StructuredGraphBuilder::set_current_context ( Node *  context)
inlineprotected

Definition at line 118 of file graph-builder.h.

118 { current_context_ = context; }

References current_context_.

Referenced by v8::internal::compiler::AstGraphBuilder::BuildLocalFunctionContext().

+ Here is the caller graph for this function:

◆ set_environment()

void v8::internal::compiler::StructuredGraphBuilder::set_environment ( Environment env)
inlineprotected

Definition at line 115 of file graph-builder.h.

115 { environment_ = env; }

References environment_.

Referenced by v8::internal::compiler::AstGraphBuilder::CreateGraph(), and v8::internal::compiler::ControlBuilder::set_environment().

+ Here is the caller graph for this function:

◆ set_exit_control()

void v8::internal::compiler::StructuredGraphBuilder::set_exit_control ( Node *  node)
inlineprotected

Definition at line 121 of file graph-builder.h.

121 { exit_control_ = node; }

References exit_control_.

Referenced by UpdateControlDependencyToLeaveFunction().

+ Here is the caller graph for this function:

◆ UpdateControlDependencyToLeaveFunction()

void v8::internal::compiler::StructuredGraphBuilder::UpdateControlDependencyToLeaveFunction ( Node *  exit)
protected

Definition at line 85 of file graph-builder.cc.

86  {
87  if (environment()->IsMarkedAsUnreachable()) return;
88  if (exit_control() != NULL) {
89  exit = MergeControl(exit_control(), exit);
90  }
92  set_exit_control(exit);
93 }
Node * MergeControl(Node *control, Node *other)

References environment(), exit_control(), v8::internal::compiler::StructuredGraphBuilder::Environment::MarkAsUnreachable(), MergeControl(), NULL, and set_exit_control().

Referenced by v8::internal::compiler::AstGraphBuilder::CreateGraph().

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

◆ zone()

Zone* v8::internal::compiler::StructuredGraphBuilder::zone ( ) const
inlineprotected

Definition at line 126 of file graph-builder.h.

126 { return graph()->zone(); }

References v8::internal::compiler::GraphBuilder::graph(), and v8::internal::compiler::GenericGraphBase::zone().

Referenced by v8::internal::compiler::AstGraphBuilder::CopyEnvironment(), CopyEnvironment(), isolate(), MakeNode(), MergeControl(), MergeEffect(), MergeValue(), NewEffectPhi(), NewPhi(), and v8::internal::compiler::ControlBuilder::zone().

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

Friends And Related Function Documentation

◆ ControlBuilder

friend class ControlBuilder
friend

Definition at line 106 of file graph-builder.h.

◆ Environment

friend class Environment
friend

Member Data Documentation

◆ common_

CommonOperatorBuilder* v8::internal::compiler::StructuredGraphBuilder::common_
private

Definition at line 144 of file graph-builder.h.

Referenced by common(), and dead_control().

◆ current_context_

Node* v8::internal::compiler::StructuredGraphBuilder::current_context_
private

Definition at line 151 of file graph-builder.h.

Referenced by current_context(), and set_current_context().

◆ dead_control_

SetOncePointer<Node> v8::internal::compiler::StructuredGraphBuilder::dead_control_
private

Definition at line 148 of file graph-builder.h.

Referenced by dead_control().

◆ environment_

Environment* v8::internal::compiler::StructuredGraphBuilder::environment_
private

Definition at line 145 of file graph-builder.h.

Referenced by environment(), MakeNode(), and set_environment().

◆ exit_control_

Node* v8::internal::compiler::StructuredGraphBuilder::exit_control_
private

Definition at line 154 of file graph-builder.h.

Referenced by exit_control(), and set_exit_control().


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