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

#include <ast-graph-builder.h>

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

Public Member Functions

 Environment (AstGraphBuilder *builder, Scope *scope, Node *control_dependency)
 
 Environment (const Environment &copy)
 
int parameters_count () const
 
int locals_count () const
 
int stack_height ()
 
void Bind (Variable *variable, Node *node)
 
Node * Lookup (Variable *variable)
 
void Push (Node *node)
 
Node * Top ()
 
Node * Pop ()
 
void Poke (int depth, Node *node)
 
Node * Peek (int depth)
 
void Drop (int depth)
 
Node * Checkpoint (BailoutId ast_id, OutputFrameStateCombine combine)
 
- Public Member Functions inherited from v8::internal::compiler::StructuredGraphBuilder::Environment
 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

AstGraphBuilderbuilder () const
 
- Protected Member Functions inherited from v8::internal::compiler::StructuredGraphBuilder::Environment
Zonezone () const
 
Graphgraph () const
 
StructuredGraphBuilderbuilder () const
 
CommonOperatorBuilder * common ()
 
NodeVectorvalues ()
 
void PrepareForLoop ()
 

Private Member Functions

void UpdateStateValues (Node **state_values, int offset, int count)
 

Private Attributes

int parameters_count_
 
int locals_count_
 
Node * parameters_node_
 
Node * locals_node_
 
Node * stack_node_
 

Detailed Description

Definition at line 194 of file ast-graph-builder.h.

Constructor & Destructor Documentation

◆ Environment() [1/2]

v8::internal::compiler::AstGraphBuilder::Environment::Environment ( AstGraphBuilder builder,
Scope scope,
Node *  control_dependency 
)

Definition at line 158 of file ast-graph-builder.cc.

161  : StructuredGraphBuilder::Environment(builder, control_dependency),
162  parameters_count_(scope->num_parameters() + 1),
163  locals_count_(scope->num_stack_slots()),
166  stack_node_(NULL) {
167  DCHECK_EQ(scope->num_parameters() + 1, parameters_count());
168 
169  // Bind the receiver variable.
170  Node* receiver = builder->graph()->NewNode(common()->Parameter(0),
171  builder->graph()->start());
172  values()->push_back(receiver);
173 
174  // Bind all parameter variables. The parameter indices are shifted by 1
175  // (receiver is parameter index -1 but environment index 0).
176  for (int i = 0; i < scope->num_parameters(); ++i) {
177  Node* parameter = builder->graph()->NewNode(common()->Parameter(i + 1),
178  builder->graph()->start());
179  values()->push_back(parameter);
180  }
181 
182  // Bind all local variables to undefined.
183  Node* undefined_constant = builder->jsgraph()->UndefinedConstant();
184  values()->insert(values()->end(), locals_count(), undefined_constant);
185 }
Node * NewNode(const Operator *op, int input_count, Node **inputs)
Definition: graph.cc:24
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
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206

References builder(), v8::internal::compiler::StructuredGraphBuilder::Environment::common(), DCHECK_EQ, v8::internal::compiler::GraphBuilder::graph(), v8::internal::compiler::AstGraphBuilder::jsgraph(), locals_count(), v8::internal::compiler::Graph::NewNode(), v8::internal::Scope::num_parameters(), parameters_count(), v8::internal::compiler::GenericGraph< V >::start(), v8::internal::compiler::JSGraph::UndefinedConstant(), and v8::internal::compiler::StructuredGraphBuilder::Environment::values().

+ Here is the call graph for this function:

◆ Environment() [2/2]

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

Definition at line 188 of file ast-graph-builder.cc.

190  static_cast<StructuredGraphBuilder::Environment>(copy)),
191  parameters_count_(copy.parameters_count_),
192  locals_count_(copy.locals_count_),
193  parameters_node_(copy.parameters_node_),
194  locals_node_(copy.locals_node_),
195  stack_node_(copy.stack_node_) {}

Member Function Documentation

◆ Bind()

void v8::internal::compiler::AstGraphBuilder::Environment::Bind ( Variable variable,
Node *  node 
)
inline

Definition at line 209 of file ast-graph-builder.h.

209  {
210  DCHECK(variable->IsStackAllocated());
211  if (variable->IsParameter()) {
212  values()->at(variable->index() + 1) = node;
213  } else {
214  DCHECK(variable->IsStackLocal());
215  values()->at(variable->index() + parameters_count_) = node;
216  }
217  }
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, v8::internal::Variable::index(), v8::internal::Variable::IsParameter(), v8::internal::Variable::IsStackAllocated(), v8::internal::Variable::IsStackLocal(), parameters_count_, and v8::internal::compiler::StructuredGraphBuilder::Environment::values().

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

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

◆ builder()

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

Definition at line 264 of file ast-graph-builder.h.

264  {
265  return reinterpret_cast<AstGraphBuilder*>(
267  }
AstGraphBuilder(CompilationInfo *info, JSGraph *jsgraph)

References v8::internal::compiler::StructuredGraphBuilder::Environment::builder().

Referenced by Environment().

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

◆ Checkpoint()

Node * v8::internal::compiler::AstGraphBuilder::Environment::Checkpoint ( BailoutId  ast_id,
OutputFrameStateCombine  combine 
)

Definition at line 220 of file ast-graph-builder.cc.

References v8::internal::compiler::StructuredGraphBuilder::common(), v8::internal::compiler::GraphBuilder::graph(), v8::internal::compiler::JS_FRAME, v8::internal::compiler::AstGraphBuilder::jsgraph(), and v8::internal::compiler::Graph::NewNode().

+ Here is the call graph for this function:

◆ Drop()

void v8::internal::compiler::AstGraphBuilder::Environment::Drop ( int  depth)
inline

Definition at line 254 of file ast-graph-builder.h.

254  {
255  DCHECK(depth >= 0 && depth <= stack_height());
256  values()->erase(values()->end() - depth, values()->end());
257  }

References DCHECK, stack_height(), and v8::internal::compiler::StructuredGraphBuilder::Environment::values().

+ Here is the call graph for this function:

◆ locals_count()

int v8::internal::compiler::AstGraphBuilder::Environment::locals_count ( ) const
inline

Definition at line 201 of file ast-graph-builder.h.

201 { return locals_count_; }

References locals_count_.

Referenced by Environment().

+ Here is the caller graph for this function:

◆ Lookup()

Node* v8::internal::compiler::AstGraphBuilder::Environment::Lookup ( Variable variable)
inline

Definition at line 218 of file ast-graph-builder.h.

218  {
219  DCHECK(variable->IsStackAllocated());
220  if (variable->IsParameter()) {
221  return values()->at(variable->index() + 1);
222  } else {
223  DCHECK(variable->IsStackLocal());
224  return values()->at(variable->index() + parameters_count_);
225  }
226  }

References DCHECK, v8::internal::Variable::index(), v8::internal::Variable::IsParameter(), v8::internal::Variable::IsStackAllocated(), v8::internal::Variable::IsStackLocal(), parameters_count_, and v8::internal::compiler::StructuredGraphBuilder::Environment::values().

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

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

◆ parameters_count()

int v8::internal::compiler::AstGraphBuilder::Environment::parameters_count ( ) const
inline

Definition at line 200 of file ast-graph-builder.h.

200 { return parameters_count_; }

References parameters_count_.

Referenced by Environment().

+ Here is the caller graph for this function:

◆ Peek()

Node* v8::internal::compiler::AstGraphBuilder::Environment::Peek ( int  depth)
inline

Definition at line 249 of file ast-graph-builder.h.

249  {
250  DCHECK(depth >= 0 && depth < stack_height());
251  int index = static_cast<int>(values()->size()) - depth - 1;
252  return values()->at(index);
253  }

References DCHECK, stack_height(), and v8::internal::compiler::StructuredGraphBuilder::Environment::values().

+ Here is the call graph for this function:

◆ Poke()

void v8::internal::compiler::AstGraphBuilder::Environment::Poke ( int  depth,
Node *  node 
)
inline

Definition at line 244 of file ast-graph-builder.h.

244  {
245  DCHECK(depth >= 0 && depth < stack_height());
246  int index = static_cast<int>(values()->size()) - depth - 1;
247  values()->at(index) = node;
248  }

References DCHECK, stack_height(), and v8::internal::compiler::StructuredGraphBuilder::Environment::values().

+ Here is the call graph for this function:

◆ Pop()

Node* v8::internal::compiler::AstGraphBuilder::Environment::Pop ( )
inline

Definition at line 236 of file ast-graph-builder.h.

236  {
237  DCHECK(stack_height() > 0);
238  Node* back = values()->back();
239  values()->pop_back();
240  return back;
241  }

References DCHECK, stack_height(), and v8::internal::compiler::StructuredGraphBuilder::Environment::values().

Referenced by v8::internal::compiler::AstGraphBuilder::BuildHoleCheckSilent(), v8::internal::compiler::AstGraphBuilder::BuildHoleCheckThrow(), v8::internal::compiler::AstGraphBuilder::ProcessArguments(), v8::internal::compiler::AstGraphBuilder::VisitDelete(), v8::internal::compiler::AstGraphBuilder::VisitForInAssignment(), v8::internal::compiler::AstGraphBuilder::VisitLogicalExpression(), v8::internal::compiler::AstGraphBuilder::VisitNot(), and v8::internal::compiler::AstGraphBuilder::VisitTypeof().

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

◆ Push()

void v8::internal::compiler::AstGraphBuilder::Environment::Push ( Node *  node)
inline

Definition at line 229 of file ast-graph-builder.h.

229  {
230  values()->push_back(node);
231  }

References v8::internal::compiler::StructuredGraphBuilder::Environment::values().

Referenced by v8::internal::compiler::AstGraphBuilder::BuildHoleCheckSilent(), v8::internal::compiler::AstGraphBuilder::BuildHoleCheckThrow(), v8::internal::compiler::AstGraphBuilder::VisitCallJSRuntime(), v8::internal::compiler::AstGraphBuilder::VisitForInAssignment(), and v8::internal::compiler::AstGraphBuilder::VisitForValueOrNull().

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

◆ stack_height()

int v8::internal::compiler::AstGraphBuilder::Environment::stack_height ( )
inline

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

202  {
203  return static_cast<int>(values()->size()) - parameters_count_ -
205  }

References locals_count_, parameters_count_, and v8::internal::compiler::StructuredGraphBuilder::Environment::values().

Referenced by Drop(), Peek(), Poke(), Pop(), and Top().

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

◆ Top()

Node* v8::internal::compiler::AstGraphBuilder::Environment::Top ( )
inline

Definition at line 232 of file ast-graph-builder.h.

232  {
233  DCHECK(stack_height() > 0);
234  return values()->back();
235  }

References DCHECK, stack_height(), and v8::internal::compiler::StructuredGraphBuilder::Environment::values().

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

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

◆ UpdateStateValues()

void v8::internal::compiler::AstGraphBuilder::Environment::UpdateStateValues ( Node **  state_values,
int  offset,
int  count 
)
private

Definition at line 198 of file ast-graph-builder.cc.

199  {
200  bool should_update = false;
201  Node** env_values = (count == 0) ? NULL : &values()->at(offset);
202  if (*state_values == NULL || (*state_values)->InputCount() != count) {
203  should_update = true;
204  } else {
205  DCHECK(static_cast<size_t>(offset + count) <= values()->size());
206  for (int i = 0; i < count; i++) {
207  if ((*state_values)->InputAt(i) != env_values[i]) {
208  should_update = true;
209  break;
210  }
211  }
212  }
213  if (should_update) {
214  const Operator* op = common()->StateValues(count);
215  (*state_values) = graph()->NewNode(op, count, env_values);
216  }
217 }
enable harmony numeric enable harmony object literal extensions Optimize object size

References v8::internal::compiler::StructuredGraphBuilder::common(), DCHECK, v8::internal::compiler::GraphBuilder::graph(), v8::internal::compiler::Graph::NewNode(), NULL, and size.

+ Here is the call graph for this function:

Member Data Documentation

◆ locals_count_

int v8::internal::compiler::AstGraphBuilder::Environment::locals_count_
private

Definition at line 273 of file ast-graph-builder.h.

Referenced by locals_count(), and stack_height().

◆ locals_node_

Node* v8::internal::compiler::AstGraphBuilder::Environment::locals_node_
private

Definition at line 275 of file ast-graph-builder.h.

◆ parameters_count_

int v8::internal::compiler::AstGraphBuilder::Environment::parameters_count_
private

Definition at line 272 of file ast-graph-builder.h.

Referenced by Bind(), Lookup(), parameters_count(), and stack_height().

◆ parameters_node_

Node* v8::internal::compiler::AstGraphBuilder::Environment::parameters_node_
private

Definition at line 274 of file ast-graph-builder.h.

◆ stack_node_

Node* v8::internal::compiler::AstGraphBuilder::Environment::stack_node_
private

Definition at line 276 of file ast-graph-builder.h.


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