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

#include <graph-builder.h>

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

Public Member Functions

 Environment (StructuredGraphBuilder *builder, Node *control_dependency)
 
 Environment (const Environment &copy)
 
Node * GetControlDependency ()
 
void UpdateControlDependency (Node *dependency)
 
Node * GetEffectDependency ()
 
void UpdateEffectDependency (Node *dependency)
 
void MarkAsUnreachable ()
 
bool IsMarkedAsUnreachable ()
 
void Merge (Environment *other)
 
EnvironmentCopyForConditional ()
 
EnvironmentCopyAsUnreachable ()
 
EnvironmentCopyForLoop ()
 
Node * GetContext ()
 
- Public Member Functions inherited from v8::internal::ZoneObject
 INLINE (void *operator new(size_t size, Zone *zone))
 
void operator delete (void *, size_t)
 
void operator delete (void *pointer, Zone *zone)
 

Protected Member Functions

Zonezone () const
 
Graphgraph () const
 
StructuredGraphBuilderbuilder () const
 
CommonOperatorBuilder * common ()
 
NodeVectorvalues ()
 
void PrepareForLoop ()
 

Private Attributes

StructuredGraphBuilderbuilder_
 
Node * control_dependency_
 
Node * effect_dependency_
 
NodeVector values_
 

Detailed Description

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

Constructor & Destructor Documentation

◆ Environment() [1/2]

v8::internal::compiler::StructuredGraphBuilder::Environment::Environment ( StructuredGraphBuilder builder,
Node *  control_dependency 
)

◆ Environment() [2/2]

v8::internal::compiler::StructuredGraphBuilder::Environment::Environment ( const Environment copy)

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

111  : builder_(copy.builder()),
112  control_dependency_(copy.control_dependency_),
113  effect_dependency_(copy.effect_dependency_),
114  values_(copy.values_) {}

Member Function Documentation

◆ builder()

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

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

213 { return builder_; }

References builder_.

Referenced by v8::internal::compiler::AstGraphBuilder::Environment::builder(), CopyAsUnreachable(), CopyForConditional(), CopyForLoop(), and MarkAsUnreachable().

+ Here is the caller graph for this function:

◆ common()

CommonOperatorBuilder* v8::internal::compiler::StructuredGraphBuilder::Environment::common ( )
inlineprotected

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

214 { return builder_->common(); }
CommonOperatorBuilder * common() const

References builder_, and v8::internal::compiler::StructuredGraphBuilder::common().

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

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

◆ CopyAsUnreachable()

Environment* v8::internal::compiler::StructuredGraphBuilder::Environment::CopyAsUnreachable ( )
inline

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

195  {
196  Environment* env = builder()->CopyEnvironment(this);
197  env->MarkAsUnreachable();
198  return env;
199  }
Environment(StructuredGraphBuilder *builder, Node *control_dependency)
virtual Environment * CopyEnvironment(Environment *env)

References builder(), v8::internal::compiler::StructuredGraphBuilder::CopyEnvironment(), and MarkAsUnreachable().

Referenced by v8::internal::compiler::BlockBuilder::BeginBlock(), v8::internal::compiler::LoopBuilder::BeginLoop(), v8::internal::compiler::SwitchBuilder::BeginSwitch(), and v8::internal::compiler::SwitchBuilder::DefaultAt().

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

◆ CopyForConditional()

Environment* v8::internal::compiler::StructuredGraphBuilder::Environment::CopyForConditional ( )
inline

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

192 { return builder()->CopyEnvironment(this); }

References builder(), and v8::internal::compiler::StructuredGraphBuilder::CopyEnvironment().

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:

◆ CopyForLoop()

Environment* v8::internal::compiler::StructuredGraphBuilder::Environment::CopyForLoop ( )
inline

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

References builder(), v8::internal::compiler::StructuredGraphBuilder::CopyEnvironment(), and PrepareForLoop().

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

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

◆ GetContext()

Node* v8::internal::compiler::StructuredGraphBuilder::Environment::GetContext ( )
inline

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

References builder_, and v8::internal::compiler::StructuredGraphBuilder::current_context().

+ Here is the call graph for this function:

◆ GetControlDependency()

Node* v8::internal::compiler::StructuredGraphBuilder::Environment::GetControlDependency ( )
inline

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

169 { return control_dependency_; }

References control_dependency_.

Referenced by IsMarkedAsUnreachable(), v8::internal::compiler::StructuredGraphBuilder::MakeNode(), and Merge().

+ Here is the caller graph for this function:

◆ GetEffectDependency()

Node* v8::internal::compiler::StructuredGraphBuilder::Environment::GetEffectDependency ( )
inline

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

175 { return effect_dependency_; }

References effect_dependency_.

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

+ Here is the caller graph for this function:

◆ graph()

Graph* v8::internal::compiler::StructuredGraphBuilder::Environment::graph ( ) const
inlineprotected

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

212 { return builder_->graph(); }

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

Referenced by zone().

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

◆ IsMarkedAsUnreachable()

bool v8::internal::compiler::StructuredGraphBuilder::Environment::IsMarkedAsUnreachable ( )
inline

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

184  {
185  return GetControlDependency()->opcode() == IrOpcode::kDead;
186  }

References GetControlDependency().

Referenced by Merge().

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

◆ MarkAsUnreachable()

void v8::internal::compiler::StructuredGraphBuilder::Environment::MarkAsUnreachable ( )
inline

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

References builder(), v8::internal::compiler::StructuredGraphBuilder::dead_control(), and UpdateControlDependency().

Referenced by v8::internal::compiler::LoopBuilder::Break(), v8::internal::compiler::SwitchBuilder::Break(), v8::internal::compiler::BlockBuilder::Break(), v8::internal::compiler::LoopBuilder::Continue(), CopyAsUnreachable(), and v8::internal::compiler::StructuredGraphBuilder::UpdateControlDependencyToLeaveFunction().

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

◆ Merge()

void v8::internal::compiler::StructuredGraphBuilder::Environment::Merge ( Environment other)

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

117  {
118  DCHECK(values_.size() == other->values_.size());
119 
120  // Nothing to do if the other environment is dead.
121  if (other->IsMarkedAsUnreachable()) return;
122 
123  // Resurrect a dead environment by copying the contents of the other one and
124  // placing a singleton merge as the new control dependency.
125  if (this->IsMarkedAsUnreachable()) {
126  Node* other_control = other->control_dependency_;
127  control_dependency_ = graph()->NewNode(common()->Merge(1), other_control);
128  effect_dependency_ = other->effect_dependency_;
129  values_ = other->values_;
130  return;
131  }
132 
133  // Create a merge of the control dependencies of both environments and update
134  // the current environment's control dependency accordingly.
135  Node* control = builder_->MergeControl(this->GetControlDependency(),
136  other->GetControlDependency());
137  UpdateControlDependency(control);
138 
139  // Create a merge of the effect dependencies of both environments and update
140  // the current environment's effect dependency accordingly.
141  Node* effect = builder_->MergeEffect(this->GetEffectDependency(),
142  other->GetEffectDependency(), control);
143  UpdateEffectDependency(effect);
144 
145  // Introduce Phi nodes for values that have differing input at merge points,
146  // potentially extending an existing Phi node if possible.
147  for (int i = 0; i < static_cast<int>(values_.size()); ++i) {
148  values_[i] = builder_->MergeValue(values_[i], other->values_[i], control);
149  }
150 }
Node * NewNode(const Operator *op, int input_count, Node **inputs)
Definition: graph.cc:24
Node * MergeControl(Node *control, Node *other)
Node * MergeEffect(Node *value, Node *other, Node *control)
Node * MergeValue(Node *value, Node *other, Node *control)
#define DCHECK(condition)
Definition: logging.h:205

References v8::internal::compiler::StructuredGraphBuilder::common(), control_dependency_, DCHECK, effect_dependency_, GetControlDependency(), GetEffectDependency(), v8::internal::compiler::GraphBuilder::graph(), IsMarkedAsUnreachable(), v8::internal::compiler::Graph::NewNode(), and values_.

Referenced by v8::internal::compiler::SwitchBuilder::BeginCase(), v8::internal::compiler::LoopBuilder::Break(), v8::internal::compiler::SwitchBuilder::Break(), v8::internal::compiler::BlockBuilder::Break(), v8::internal::compiler::LoopBuilder::Continue(), v8::internal::compiler::IfBuilder::End(), v8::internal::compiler::BlockBuilder::EndBlock(), v8::internal::compiler::LoopBuilder::EndBody(), v8::internal::compiler::LoopBuilder::EndLoop(), and v8::internal::compiler::SwitchBuilder::EndSwitch().

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

◆ PrepareForLoop()

void v8::internal::compiler::StructuredGraphBuilder::Environment::PrepareForLoop ( )
protected

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

153  {
154  Node* control = GetControlDependency();
155  for (int i = 0; i < static_cast<int>(values()->size()); ++i) {
156  Node* phi = builder_->NewPhi(1, values()->at(i), control);
157  values()->at(i) = phi;
158  }
159  Node* effect = builder_->NewEffectPhi(1, GetEffectDependency(), control);
160  UpdateEffectDependency(effect);
161 }
Node * NewPhi(int count, Node *input, Node *control)
Node * NewEffectPhi(int count, Node *input, Node *control)
enable harmony numeric enable harmony object literal extensions Optimize object size

References size.

Referenced by CopyForLoop().

+ Here is the caller graph for this function:

◆ UpdateControlDependency()

void v8::internal::compiler::StructuredGraphBuilder::Environment::UpdateControlDependency ( Node *  dependency)
inline

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

170  {
171  control_dependency_ = dependency;
172  }

References control_dependency_.

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

+ Here is the caller graph for this function:

◆ UpdateEffectDependency()

void v8::internal::compiler::StructuredGraphBuilder::Environment::UpdateEffectDependency ( Node *  dependency)
inline

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

176  {
177  effect_dependency_ = dependency;
178  }

References effect_dependency_.

Referenced by v8::internal::compiler::StructuredGraphBuilder::MakeNode().

+ Here is the caller graph for this function:

◆ values()

◆ zone()

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

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

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

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

+ Here is the call graph for this function:

Member Data Documentation

◆ builder_

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

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

Referenced by builder(), common(), GetContext(), and graph().

◆ control_dependency_

Node* v8::internal::compiler::StructuredGraphBuilder::Environment::control_dependency_
private

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

Referenced by GetControlDependency(), Merge(), and UpdateControlDependency().

◆ effect_dependency_

Node* v8::internal::compiler::StructuredGraphBuilder::Environment::effect_dependency_
private

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

Referenced by GetEffectDependency(), Merge(), and UpdateEffectDependency().

◆ values_

NodeVector v8::internal::compiler::StructuredGraphBuilder::Environment::values_
private

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

Referenced by Merge(), and values().


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