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

#include <ast-graph-builder.h>

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

Classes

class  Environment
 

Public Member Functions

 AstGraphBuilder (CompilationInfo *info, JSGraph *jsgraph)
 
bool CreateGraph ()
 
- Public Member Functions inherited from v8::internal::compiler::StructuredGraphBuilder
 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 Types

typedef StructuredGraphBuilder::Environment BaseEnvironment
 

Protected Member Functions

Environmentenvironment ()
 
AstContextast_context () const
 
BreakableScope * breakable () const
 
ContextScope * execution_context () const
 
void set_ast_context (AstContext *ctx)
 
void set_breakable (BreakableScope *brk)
 
void set_execution_context (ContextScope *ctx)
 
virtual BaseEnvironmentCopyEnvironment (BaseEnvironment *env)
 
Node * GetFunctionClosure ()
 
Node * GetFunctionContext ()
 
Node * BuildLocalFunctionContext (Node *context, Node *closure)
 
Node * BuildArgumentsObject (Variable *arguments)
 
Node * BuildVariableAssignment (Variable *var, Node *value, Token::Value op, BailoutId bailout_id)
 
Node * BuildVariableDelete (Variable *var)
 
Node * BuildVariableLoad (Variable *var, BailoutId bailout_id, ContextualMode mode=CONTEXTUAL)
 
Node * BuildLoadBuiltinsObject ()
 
Node * BuildLoadGlobalObject ()
 
Node * BuildLoadClosure ()
 
Node * BuildLoadObjectField (Node *object, int offset)
 
Node * BuildToBoolean (Node *value)
 
Node * BuildThrowReferenceError (Variable *var)
 
Node * BuildHoleCheckSilent (Node *value, Node *for_hole, Node *not_hole)
 
Node * BuildHoleCheckThrow (Node *value, Variable *var, Node *not_hole)
 
Node * BuildBinaryOp (Node *left, Node *right, Token::Value op)
 
virtual void VisitDeclarations (ZoneList< Declaration * > *declarations)
 
- Protected Member Functions inherited from v8::internal::compiler::StructuredGraphBuilder
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)
 
void UpdateControlDependencyToLeaveFunction (Node *exit)
 

Private Member Functions

CompilationInfoinfo ()
 
StrictMode strict_mode ()
 
JSGraphjsgraph ()
 
JSOperatorBuilderjavascript ()
 
ZoneList< Handle< Object > > * globals ()
 
Scopecurrent_scope () const
 
Node * ProcessArguments (const Operator *op, int arity)
 
void VisitIfNotNull (Statement *stmt)
 
void VisitForTest (Expression *expr)
 
void VisitForEffect (Expression *expr)
 
void VisitForValue (Expression *expr)
 
void VisitForValueOrNull (Expression *expr)
 
void VisitForValues (ZoneList< Expression * > *exprs)
 
void VisitIterationBody (IterationStatement *stmt, LoopBuilder *loop, int)
 
void VisitCallJSRuntime (CallRuntime *expr)
 
void VisitDelete (UnaryOperation *expr)
 
void VisitVoid (UnaryOperation *expr)
 
void VisitTypeof (UnaryOperation *expr)
 
void VisitNot (UnaryOperation *expr)
 
void VisitComma (BinaryOperation *expr)
 
void VisitLogicalExpression (BinaryOperation *expr)
 
void VisitArithmeticExpression (BinaryOperation *expr)
 
void VisitForInAssignment (Expression *expr, Node *value)
 
void PrepareFrameState (Node *node, BailoutId ast_id, OutputFrameStateCombine combine=kIgnoreOutput)
 
OutputFrameStateCombine StateCombineFromAstContext ()
 
 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS ()
 
 DISALLOW_COPY_AND_ASSIGN (AstGraphBuilder)
 

Private Attributes

CompilationInfoinfo_
 
AstContextast_context_
 
JSGraphjsgraph_
 
ZoneList< Handle< Object > > globals_
 
BreakableScope * breakable_
 
ContextScope * execution_context_
 
SetOncePointer< Node > function_closure_
 
SetOncePointer< Node > function_context_
 

Friends

class Pipeline
 

Detailed Description

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

Member Typedef Documentation

◆ BaseEnvironment

Constructor & Destructor Documentation

◆ AstGraphBuilder()

v8::internal::compiler::AstGraphBuilder::AstGraphBuilder ( CompilationInfo info,
JSGraph jsgraph 
)

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

22  info_(info),
24  globals_(0, info->zone()),
27  InitializeAstVisitor(info->zone());
28 }
ZoneList< Handle< Object > > globals_
CommonOperatorBuilder * common()
Definition: js-graph.h:87
StructuredGraphBuilder(Graph *graph, CommonOperatorBuilder *common)
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

References info(), and v8::internal::CompilationInfo::zone().

+ Here is the call graph for this function:

Member Function Documentation

◆ ast_context()

AstContext* v8::internal::compiler::AstGraphBuilder::ast_context ( ) const
inlineprotected

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

References ast_context_.

Referenced by VisitCallJSRuntime(), VisitComma(), VisitDelete(), VisitLogicalExpression(), VisitNot(), VisitTypeof(), and VisitVoid().

+ Here is the caller graph for this function:

◆ breakable()

BreakableScope* v8::internal::compiler::AstGraphBuilder::breakable ( ) const
inlineprotected

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

48 { return breakable_; }

References breakable_.

◆ BuildArgumentsObject()

Node * v8::internal::compiler::AstGraphBuilder::BuildArgumentsObject ( Variable arguments)
protected

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

1706  {
1707  if (arguments == NULL) return NULL;
1708 
1709  // Allocate and initialize a new arguments object.
1710  Node* callee = GetFunctionClosure();
1711  const Operator* op = javascript()->Runtime(Runtime::kNewArguments, 1);
1712  Node* object = NewNode(op, callee);
1713 
1714  // Assign the object to the arguments variable.
1715  DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated());
1716  // This should never lazy deopt, so it is fine to send invalid bailout id.
1717  BuildVariableAssignment(arguments, object, Token::ASSIGN, BailoutId::None());
1718 
1719  return object;
1720 }
static BailoutId None()
Definition: utils.h:960
Node * BuildVariableAssignment(Variable *var, Node *value, Token::Value op, BailoutId bailout_id)
Node * NewNode(const Operator *op)
Definition: graph-builder.h:27
const Operator * Runtime(Runtime::FunctionId function, int arguments)
Definition: js-operator.h:183
#define DCHECK(condition)
Definition: logging.h:205

References BuildVariableAssignment(), DCHECK, GetFunctionClosure(), v8::internal::Variable::IsContextSlot(), v8::internal::Variable::IsStackAllocated(), javascript(), v8::internal::compiler::GraphBuilder::NewNode(), v8::internal::BailoutId::None(), NULL, and v8::internal::compiler::JSOperatorBuilder::Runtime().

Referenced by CreateGraph().

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

◆ BuildBinaryOp()

Node * v8::internal::compiler::AstGraphBuilder::BuildBinaryOp ( Node *  left,
Node *  right,
Token::Value  op 
)
protected

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

1976  {
1977  const Operator* js_op;
1978  switch (op) {
1979  case Token::BIT_OR:
1980  js_op = javascript()->BitwiseOr();
1981  break;
1982  case Token::BIT_AND:
1983  js_op = javascript()->BitwiseAnd();
1984  break;
1985  case Token::BIT_XOR:
1986  js_op = javascript()->BitwiseXor();
1987  break;
1988  case Token::SHL:
1989  js_op = javascript()->ShiftLeft();
1990  break;
1991  case Token::SAR:
1992  js_op = javascript()->ShiftRight();
1993  break;
1994  case Token::SHR:
1995  js_op = javascript()->ShiftRightLogical();
1996  break;
1997  case Token::ADD:
1998  js_op = javascript()->Add();
1999  break;
2000  case Token::SUB:
2001  js_op = javascript()->Subtract();
2002  break;
2003  case Token::MUL:
2004  js_op = javascript()->Multiply();
2005  break;
2006  case Token::DIV:
2007  js_op = javascript()->Divide();
2008  break;
2009  case Token::MOD:
2010  js_op = javascript()->Modulus();
2011  break;
2012  default:
2013  UNREACHABLE();
2014  js_op = NULL;
2015  }
2016  return NewNode(js_op, left, right);
2017 }
#define UNREACHABLE()
Definition: logging.h:30

References v8::internal::ADD, v8::internal::compiler::JSOperatorBuilder::Add(), v8::internal::compiler::JSOperatorBuilder::BitwiseAnd(), v8::internal::compiler::JSOperatorBuilder::BitwiseOr(), v8::internal::compiler::JSOperatorBuilder::BitwiseXor(), v8::internal::DIV, v8::internal::compiler::JSOperatorBuilder::Divide(), javascript(), v8::internal::compiler::JSOperatorBuilder::Modulus(), v8::internal::MUL, v8::internal::compiler::JSOperatorBuilder::Multiply(), v8::internal::compiler::GraphBuilder::NewNode(), NULL, v8::internal::compiler::JSOperatorBuilder::ShiftLeft(), v8::internal::compiler::JSOperatorBuilder::ShiftRight(), v8::internal::compiler::JSOperatorBuilder::ShiftRightLogical(), v8::internal::SUB, v8::internal::compiler::JSOperatorBuilder::Subtract(), and UNREACHABLE.

+ Here is the call graph for this function:

◆ BuildHoleCheckSilent()

Node * v8::internal::compiler::AstGraphBuilder::BuildHoleCheckSilent ( Node *  value,
Node *  for_hole,
Node *  not_hole 
)
protected

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

1724  {
1725  IfBuilder hole_check(this);
1726  Node* the_hole = jsgraph()->TheHoleConstant();
1727  Node* check = NewNode(javascript()->StrictEqual(), value, the_hole);
1728  hole_check.If(check);
1729  hole_check.Then();
1730  environment()->Push(for_hole);
1731  hole_check.Else();
1732  environment()->Push(not_hole);
1733  hole_check.End();
1734  return environment()->Pop();
1735 }

References v8::internal::compiler::IfBuilder::Else(), v8::internal::compiler::IfBuilder::End(), environment(), v8::internal::compiler::IfBuilder::If(), javascript(), jsgraph(), v8::internal::compiler::GraphBuilder::NewNode(), v8::internal::compiler::AstGraphBuilder::Environment::Pop(), v8::internal::compiler::AstGraphBuilder::Environment::Push(), v8::internal::compiler::JSGraph::TheHoleConstant(), and v8::internal::compiler::IfBuilder::Then().

Referenced by BuildVariableAssignment(), and BuildVariableLoad().

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

◆ BuildHoleCheckThrow()

Node * v8::internal::compiler::AstGraphBuilder::BuildHoleCheckThrow ( Node *  value,
Variable var,
Node *  not_hole 
)
protected

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

1739  {
1740  IfBuilder hole_check(this);
1741  Node* the_hole = jsgraph()->TheHoleConstant();
1742  Node* check = NewNode(javascript()->StrictEqual(), value, the_hole);
1743  hole_check.If(check);
1744  hole_check.Then();
1746  hole_check.Else();
1747  environment()->Push(not_hole);
1748  hole_check.End();
1749  return environment()->Pop();
1750 }

References BuildThrowReferenceError(), v8::internal::compiler::IfBuilder::Else(), v8::internal::compiler::IfBuilder::End(), environment(), v8::internal::compiler::IfBuilder::If(), javascript(), jsgraph(), v8::internal::compiler::GraphBuilder::NewNode(), v8::internal::compiler::AstGraphBuilder::Environment::Pop(), v8::internal::compiler::AstGraphBuilder::Environment::Push(), v8::internal::compiler::JSGraph::TheHoleConstant(), and v8::internal::compiler::IfBuilder::Then().

Referenced by BuildVariableAssignment(), and BuildVariableLoad().

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

◆ BuildLoadBuiltinsObject()

Node * v8::internal::compiler::AstGraphBuilder::BuildLoadBuiltinsObject ( )
protected

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

1946  {
1947  Node* global = BuildLoadGlobalObject();
1948  Node* builtins =
1950  return builtins;
1951 }
static const int kBuiltinsOffset
Definition: objects.h:7458
Node * BuildLoadObjectField(Node *object, int offset)

References BuildLoadGlobalObject(), BuildLoadObjectField(), and v8::internal::GlobalObject::kBuiltinsOffset.

Referenced by VisitCallJSRuntime().

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

◆ BuildLoadClosure()

Node* v8::internal::compiler::AstGraphBuilder::BuildLoadClosure ( )
protected

◆ BuildLoadGlobalObject()

Node * v8::internal::compiler::AstGraphBuilder::BuildLoadGlobalObject ( )
protected

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

1954  {
1955  Node* context = GetFunctionContext();
1956  const Operator* load_op =
1958  return NewNode(load_op, context);
1959 }
const Operator * LoadContext(uint16_t depth, uint32_t index, bool immutable)
Definition: js-operator.h:152

References GetFunctionContext(), v8::internal::Context::GLOBAL_OBJECT_INDEX, javascript(), v8::internal::compiler::JSOperatorBuilder::LoadContext(), and v8::internal::compiler::GraphBuilder::NewNode().

Referenced by BuildLoadBuiltinsObject(), BuildVariableAssignment(), BuildVariableDelete(), and BuildVariableLoad().

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

◆ BuildLoadObjectField()

Node * v8::internal::compiler::AstGraphBuilder::BuildLoadObjectField ( Node *  object,
int  offset 
)
protected

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

1938  {
1939  // TODO(sigurds) Use simplified load here once it is ready.
1940  Node* field_load = NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object,
1941  jsgraph()->Int32Constant(offset - kHeapObjectTag));
1942  return field_load;
1943 }
const int kHeapObjectTag
Definition: v8.h:5737

References jsgraph(), v8::internal::kHeapObjectTag, v8::internal::compiler::kMachAnyTagged, and v8::internal::compiler::GraphBuilder::NewNode().

Referenced by BuildLoadBuiltinsObject().

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

◆ BuildLocalFunctionContext()

Node * v8::internal::compiler::AstGraphBuilder::BuildLocalFunctionContext ( Node *  context,
Node *  closure 
)
protected

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

1678  {
1679  int heap_slots = info()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
1680  if (heap_slots <= 0) return context;
1681  set_current_context(context);
1682 
1683  // Allocate a new local context.
1684  const Operator* op = javascript()->CreateFunctionContext();
1685  Node* local_context = NewNode(op, closure);
1686  set_current_context(local_context);
1687 
1688  // Copy parameters into context if necessary.
1689  int num_parameters = info()->scope()->num_parameters();
1690  for (int i = 0; i < num_parameters; i++) {
1691  Variable* variable = info()->scope()->parameter(i);
1692  if (!variable->IsContextSlot()) continue;
1693  // Temporary parameter node. The parameter indices are shifted by 1
1694  // (receiver is parameter index -1 but environment index 0).
1695  Node* parameter = NewNode(common()->Parameter(i + 1), graph()->start());
1696  // Context variable (at bottom of the context chain).
1697  DCHECK_EQ(0, info()->scope()->ContextChainLength(variable->scope()));
1698  const Operator* op = javascript()->StoreContext(0, variable->index());
1699  NewNode(op, local_context, parameter);
1700  }
1701 
1702  return local_context;
1703 }
int num_parameters() const
Definition: scopes.h:321
Variable * parameter(int index) const
Definition: scopes.h:316
const Operator * StoreContext(uint16_t depth, uint32_t index)
Definition: js-operator.h:157
CommonOperatorBuilder * common() const
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206

References v8::internal::compiler::StructuredGraphBuilder::common(), v8::internal::compiler::JSOperatorBuilder::CreateFunctionContext(), DCHECK_EQ, v8::internal::compiler::GraphBuilder::graph(), v8::internal::Variable::index(), info(), v8::internal::Variable::IsContextSlot(), javascript(), v8::internal::Context::MIN_CONTEXT_SLOTS, v8::internal::compiler::GraphBuilder::NewNode(), v8::internal::CompilationInfo::num_heap_slots(), v8::internal::Scope::num_parameters(), v8::internal::Scope::parameter(), v8::internal::CompilationInfo::scope(), v8::internal::Variable::scope(), v8::internal::compiler::StructuredGraphBuilder::set_current_context(), and v8::internal::compiler::JSOperatorBuilder::StoreContext().

Referenced by CreateGraph().

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

◆ BuildThrowReferenceError()

Node * v8::internal::compiler::AstGraphBuilder::BuildThrowReferenceError ( Variable var)
protected

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

1968  {
1969  // TODO(mstarzinger): Should be unified with the VisitThrow implementation.
1970  Node* variable_name = jsgraph()->Constant(variable->name());
1971  const Operator* op = javascript()->Runtime(Runtime::kThrowReferenceError, 1);
1972  return NewNode(op, variable_name);
1973 }
Node * Constant(Handle< Object > value)
Definition: js-graph.cc:115

References v8::internal::compiler::JSGraph::Constant(), javascript(), jsgraph(), v8::internal::Variable::name(), v8::internal::compiler::GraphBuilder::NewNode(), and v8::internal::compiler::JSOperatorBuilder::Runtime().

Referenced by BuildHoleCheckThrow(), BuildVariableAssignment(), and BuildVariableLoad().

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

◆ BuildToBoolean()

Node * v8::internal::compiler::AstGraphBuilder::BuildToBoolean ( Node *  value)
protected

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

1962  {
1963  // TODO(mstarzinger): Possible optimization is to NOP for boolean values.
1964  return NewNode(javascript()->ToBoolean(), value);
1965 }

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

Referenced by VisitLogicalExpression().

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

◆ BuildVariableAssignment()

Node * v8::internal::compiler::AstGraphBuilder::BuildVariableAssignment ( Variable var,
Node *  value,
Token::Value  op,
BailoutId  bailout_id 
)
protected

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

1856  {
1857  Node* the_hole = jsgraph()->TheHoleConstant();
1858  VariableMode mode = variable->mode();
1859  switch (variable->location()) {
1860  case Variable::UNALLOCATED: {
1861  // Global var, const, or let variable.
1862  Node* global = BuildLoadGlobalObject();
1863  Unique<Name> name = MakeUnique(variable->name());
1864  const Operator* op = javascript()->StoreNamed(strict_mode(), name);
1865  Node* store = NewNode(op, global, value);
1866  PrepareFrameState(store, bailout_id);
1867  return store;
1868  }
1869  case Variable::PARAMETER:
1870  case Variable::LOCAL:
1871  // Local var, const, or let variable.
1872  if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) {
1873  // Perform an initialization check for legacy const variables.
1874  Node* current = environment()->Lookup(variable);
1875  if (current->op() != the_hole->op()) {
1876  value = BuildHoleCheckSilent(current, value, current);
1877  }
1878  } else if (mode == CONST_LEGACY && op != Token::INIT_CONST_LEGACY) {
1879  // Non-initializing assignments to legacy const is ignored.
1880  return value;
1881  } else if (mode == LET && op != Token::INIT_LET) {
1882  // Perform an initialization check for let declared variables.
1883  // Also note that the dynamic hole-check is only done to ensure that
1884  // this does not break in the presence of do-expressions within the
1885  // temporal dead zone of a let declared variable.
1886  Node* current = environment()->Lookup(variable);
1887  if (current->op() == the_hole->op()) {
1888  value = BuildThrowReferenceError(variable);
1889  } else if (value->opcode() == IrOpcode::kPhi) {
1890  value = BuildHoleCheckThrow(current, variable, value);
1891  }
1892  } else if (mode == CONST && op != Token::INIT_CONST) {
1893  // All assignments to const variables are early errors.
1894  UNREACHABLE();
1895  }
1896  environment()->Bind(variable, value);
1897  return value;
1898  case Variable::CONTEXT: {
1899  // Context variable (potentially up the context chain).
1900  int depth = current_scope()->ContextChainLength(variable->scope());
1901  if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) {
1902  // Perform an initialization check for legacy const variables.
1903  const Operator* op =
1904  javascript()->LoadContext(depth, variable->index(), false);
1905  Node* current = NewNode(op, current_context());
1906  value = BuildHoleCheckSilent(current, value, current);
1907  } else if (mode == CONST_LEGACY && op != Token::INIT_CONST_LEGACY) {
1908  // Non-initializing assignments to legacy const is ignored.
1909  return value;
1910  } else if (mode == LET && op != Token::INIT_LET) {
1911  // Perform an initialization check for let declared variables.
1912  const Operator* op =
1913  javascript()->LoadContext(depth, variable->index(), false);
1914  Node* current = NewNode(op, current_context());
1915  value = BuildHoleCheckThrow(current, variable, value);
1916  } else if (mode == CONST && op != Token::INIT_CONST) {
1917  // All assignments to const variables are early errors.
1918  UNREACHABLE();
1919  }
1920  const Operator* op = javascript()->StoreContext(depth, variable->index());
1921  return NewNode(op, current_context(), value);
1922  }
1923  case Variable::LOOKUP: {
1924  // Dynamic lookup of context variable (anywhere in the chain).
1925  Node* name = jsgraph()->Constant(variable->name());
1926  Node* strict = jsgraph()->Constant(strict_mode());
1927  // TODO(mstarzinger): Use Runtime::kInitializeLegacyConstLookupSlot for
1928  // initializations of const declarations.
1929  const Operator* op = javascript()->Runtime(Runtime::kStoreLookupSlot, 4);
1930  return NewNode(op, value, current_context(), name, strict);
1931  }
1932  }
1933  UNREACHABLE();
1934  return NULL;
1935 }
int ContextChainLength(Scope *scope)
Definition: scopes.cc:715
Node * BuildHoleCheckSilent(Node *value, Node *for_hole, Node *not_hole)
Node * BuildHoleCheckThrow(Node *value, Variable *var, Node *not_hole)
void PrepareFrameState(Node *node, BailoutId ast_id, OutputFrameStateCombine combine=kIgnoreOutput)
const Operator * StoreNamed(StrictMode strict_mode, Unique< Name > name)
Definition: js-operator.h:139
Unique< T > MakeUnique(Handle< T > object)
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 expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
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 mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
@ CONST_LEGACY
Definition: globals.h:671

References v8::internal::compiler::AstGraphBuilder::Environment::Bind(), BuildHoleCheckSilent(), BuildHoleCheckThrow(), BuildLoadGlobalObject(), BuildThrowReferenceError(), v8::internal::CONST, v8::internal::CONST_LEGACY, v8::internal::compiler::JSGraph::Constant(), v8::internal::Variable::CONTEXT, v8::internal::Scope::ContextChainLength(), v8::internal::compiler::StructuredGraphBuilder::current_context(), current_scope(), environment(), v8::internal::Variable::index(), javascript(), jsgraph(), v8::internal::LET, v8::internal::compiler::JSOperatorBuilder::LoadContext(), v8::internal::Variable::LOCAL, v8::internal::Variable::location(), v8::internal::compiler::AstGraphBuilder::Environment::Lookup(), v8::internal::Variable::LOOKUP, v8::internal::compiler::StructuredGraphBuilder::MakeUnique(), v8::internal::Variable::mode(), mode(), name, v8::internal::Variable::name(), v8::internal::compiler::GraphBuilder::NewNode(), NULL, v8::internal::Variable::PARAMETER, PrepareFrameState(), v8::internal::compiler::JSOperatorBuilder::Runtime(), v8::internal::Variable::scope(), v8::internal::compiler::JSOperatorBuilder::StoreContext(), v8::internal::compiler::JSOperatorBuilder::StoreNamed(), strict_mode(), v8::internal::compiler::JSGraph::TheHoleConstant(), v8::internal::Variable::UNALLOCATED, and UNREACHABLE.

Referenced by BuildArgumentsObject(), and VisitForInAssignment().

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

◆ BuildVariableDelete()

Node * v8::internal::compiler::AstGraphBuilder::BuildVariableDelete ( Variable var)
protected

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

1827  {
1828  switch (variable->location()) {
1829  case Variable::UNALLOCATED: {
1830  // Global var, const, or let variable.
1831  Node* global = BuildLoadGlobalObject();
1832  Node* name = jsgraph()->Constant(variable->name());
1833  const Operator* op = javascript()->DeleteProperty(strict_mode());
1834  return NewNode(op, global, name);
1835  }
1836  case Variable::PARAMETER:
1837  case Variable::LOCAL:
1838  case Variable::CONTEXT:
1839  // Local var, const, or let variable or context variable.
1840  return variable->is_this() ? jsgraph()->TrueConstant()
1841  : jsgraph()->FalseConstant();
1842  case Variable::LOOKUP: {
1843  // Dynamic lookup of context variable (anywhere in the chain).
1844  Node* name = jsgraph()->Constant(variable->name());
1845  const Operator* op = javascript()->Runtime(Runtime::kDeleteLookupSlot, 2);
1846  return NewNode(op, current_context(), name);
1847  }
1848  }
1849  UNREACHABLE();
1850  return NULL;
1851 }
const Operator * DeleteProperty(StrictMode strict_mode)
Definition: js-operator.h:145

References BuildLoadGlobalObject(), v8::internal::compiler::JSGraph::Constant(), v8::internal::Variable::CONTEXT, v8::internal::compiler::StructuredGraphBuilder::current_context(), v8::internal::compiler::JSOperatorBuilder::DeleteProperty(), v8::internal::compiler::JSGraph::FalseConstant(), v8::internal::Variable::is_this(), javascript(), jsgraph(), v8::internal::Variable::LOCAL, v8::internal::Variable::location(), v8::internal::Variable::LOOKUP, name, v8::internal::Variable::name(), v8::internal::compiler::GraphBuilder::NewNode(), NULL, v8::internal::Variable::PARAMETER, v8::internal::compiler::JSOperatorBuilder::Runtime(), strict_mode(), v8::internal::compiler::JSGraph::TrueConstant(), v8::internal::Variable::UNALLOCATED, and UNREACHABLE.

Referenced by VisitDelete().

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

◆ BuildVariableLoad()

Node * v8::internal::compiler::AstGraphBuilder::BuildVariableLoad ( Variable var,
BailoutId  bailout_id,
ContextualMode  mode = CONTEXTUAL 
)
protected

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

1755  {
1756  Node* the_hole = jsgraph()->TheHoleConstant();
1757  VariableMode mode = variable->mode();
1758  switch (variable->location()) {
1759  case Variable::UNALLOCATED: {
1760  // Global var, const, or let variable.
1761  Node* global = BuildLoadGlobalObject();
1762  Unique<Name> name = MakeUnique(variable->name());
1763  const Operator* op = javascript()->LoadNamed(name, contextual_mode);
1764  Node* node = NewNode(op, global);
1765  PrepareFrameState(node, bailout_id, kPushOutput);
1766  return node;
1767  }
1768  case Variable::PARAMETER:
1769  case Variable::LOCAL: {
1770  // Local var, const, or let variable.
1771  Node* value = environment()->Lookup(variable);
1772  if (mode == CONST_LEGACY) {
1773  // Perform check for uninitialized legacy const variables.
1774  if (value->op() == the_hole->op()) {
1775  value = jsgraph()->UndefinedConstant();
1776  } else if (value->opcode() == IrOpcode::kPhi) {
1777  Node* undefined = jsgraph()->UndefinedConstant();
1778  value = BuildHoleCheckSilent(value, undefined, value);
1779  }
1780  } else if (mode == LET || mode == CONST) {
1781  // Perform check for uninitialized let/const variables.
1782  if (value->op() == the_hole->op()) {
1783  value = BuildThrowReferenceError(variable);
1784  } else if (value->opcode() == IrOpcode::kPhi) {
1785  value = BuildHoleCheckThrow(value, variable, value);
1786  }
1787  }
1788  return value;
1789  }
1790  case Variable::CONTEXT: {
1791  // Context variable (potentially up the context chain).
1792  int depth = current_scope()->ContextChainLength(variable->scope());
1793  bool immutable = variable->maybe_assigned() == kNotAssigned;
1794  const Operator* op =
1795  javascript()->LoadContext(depth, variable->index(), immutable);
1796  Node* value = NewNode(op, current_context());
1797  // TODO(titzer): initialization checks are redundant for already
1798  // initialized immutable context loads, but only specialization knows.
1799  // Maybe specializer should be a parameter to the graph builder?
1800  if (mode == CONST_LEGACY) {
1801  // Perform check for uninitialized legacy const variables.
1802  Node* undefined = jsgraph()->UndefinedConstant();
1803  value = BuildHoleCheckSilent(value, undefined, value);
1804  } else if (mode == LET || mode == CONST) {
1805  // Perform check for uninitialized let/const variables.
1806  value = BuildHoleCheckThrow(value, variable, value);
1807  }
1808  return value;
1809  }
1810  case Variable::LOOKUP: {
1811  // Dynamic lookup of context variable (anywhere in the chain).
1812  Node* name = jsgraph()->Constant(variable->name());
1813  Runtime::FunctionId function_id =
1814  (contextual_mode == CONTEXTUAL)
1815  ? Runtime::kLoadLookupSlot
1816  : Runtime::kLoadLookupSlotNoReferenceError;
1817  const Operator* op = javascript()->Runtime(function_id, 2);
1818  Node* pair = NewNode(op, current_context(), name);
1819  return NewNode(common()->Projection(0), pair);
1820  }
1821  }
1822  UNREACHABLE();
1823  return NULL;
1824 }
const Operator * LoadNamed(Unique< Name > name, ContextualMode contextual_mode=NOT_CONTEXTUAL)
Definition: js-operator.h:127
@ kNotAssigned
Definition: globals.h:757

References BuildHoleCheckSilent(), BuildHoleCheckThrow(), BuildLoadGlobalObject(), BuildThrowReferenceError(), v8::internal::compiler::StructuredGraphBuilder::common(), v8::internal::CONST, v8::internal::CONST_LEGACY, v8::internal::compiler::JSGraph::Constant(), v8::internal::Variable::CONTEXT, v8::internal::Scope::ContextChainLength(), v8::internal::CONTEXTUAL, v8::internal::compiler::StructuredGraphBuilder::current_context(), current_scope(), environment(), v8::internal::Variable::index(), javascript(), jsgraph(), v8::internal::kNotAssigned, v8::internal::compiler::kPushOutput, v8::internal::LET, v8::internal::compiler::JSOperatorBuilder::LoadContext(), v8::internal::compiler::JSOperatorBuilder::LoadNamed(), v8::internal::Variable::LOCAL, v8::internal::Variable::location(), v8::internal::compiler::AstGraphBuilder::Environment::Lookup(), v8::internal::Variable::LOOKUP, v8::internal::compiler::StructuredGraphBuilder::MakeUnique(), v8::internal::Variable::maybe_assigned(), v8::internal::Variable::mode(), mode(), name, v8::internal::Variable::name(), v8::internal::compiler::GraphBuilder::NewNode(), NULL, v8::internal::Variable::PARAMETER, PrepareFrameState(), v8::internal::compiler::JSOperatorBuilder::Runtime(), v8::internal::Variable::scope(), v8::internal::compiler::JSGraph::TheHoleConstant(), v8::internal::Variable::UNALLOCATED, v8::internal::compiler::JSGraph::UndefinedConstant(), and UNREACHABLE.

Referenced by VisitTypeof().

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

◆ CopyEnvironment()

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

Reimplemented from v8::internal::compiler::StructuredGraphBuilder.

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

153  {
154  return new (zone()) Environment(*reinterpret_cast<Environment*>(env));
155 }

References v8::internal::compiler::StructuredGraphBuilder::Environment, and v8::internal::compiler::StructuredGraphBuilder::zone().

+ Here is the call graph for this function:

◆ CreateGraph()

bool v8::internal::compiler::AstGraphBuilder::CreateGraph ( )

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

53  {
54  Scope* scope = info()->scope();
55  DCHECK(graph() != NULL);
56 
57  // Set up the basic structure of the graph.
58  int parameter_count = info()->num_parameters();
59  graph()->SetStart(graph()->NewNode(common()->Start(parameter_count)));
60 
61  // Initialize the top-level environment.
62  Environment env(this, scope, graph()->start());
63  set_environment(&env);
64 
65  // Build node to initialize local function context.
66  Node* closure = GetFunctionClosure();
67  Node* outer = GetFunctionContext();
68  Node* inner = BuildLocalFunctionContext(outer, closure);
69 
70  // Push top-level function scope for the function body.
71  ContextScope top_context(this, scope, inner);
72 
73  // Build the arguments object if it is used.
74  BuildArgumentsObject(scope->arguments());
75 
76  // Emit tracing call if requested to do so.
77  if (FLAG_trace) {
78  NewNode(javascript()->Runtime(Runtime::kTraceEnter, 0));
79  }
80 
81  // Visit implicit declaration of the function name.
82  if (scope->is_function_scope() && scope->function() != NULL) {
83  VisitVariableDeclaration(scope->function());
84  }
85 
86  // Visit declarations within the function scope.
87  VisitDeclarations(scope->declarations());
88 
89  // TODO(mstarzinger): This should do an inlined stack check.
90  Node* node = NewNode(javascript()->Runtime(Runtime::kStackGuard, 0));
92 
93  // Visit statements in the function body.
94  VisitStatements(info()->function()->body());
95  if (HasStackOverflow()) return false;
96 
97  // Emit tracing call if requested to do so.
98  if (FLAG_trace) {
99  // TODO(mstarzinger): Only traces implicit return.
100  Node* return_value = jsgraph()->UndefinedConstant();
101  NewNode(javascript()->Runtime(Runtime::kTraceExit, 1), return_value);
102  }
103 
104  // Return 'undefined' in case we can fall off the end.
105  Node* control = NewNode(common()->Return(), jsgraph()->UndefinedConstant());
107 
108  // Finish the basic structure of the graph.
110  graph()->SetEnd(NewNode(common()->End()));
111 
112  return true;
113 }
static BailoutId FunctionEntry()
Definition: utils.h:961
Node * BuildArgumentsObject(Variable *arguments)
virtual void VisitDeclarations(ZoneList< Declaration * > *declarations)
Node * BuildLocalFunctionContext(Node *context, Node *closure)

References v8::internal::Scope::arguments(), BuildArgumentsObject(), BuildLocalFunctionContext(), v8::internal::compiler::StructuredGraphBuilder::common(), DCHECK, v8::internal::Scope::declarations(), environment(), v8::internal::compiler::StructuredGraphBuilder::exit_control(), v8::internal::Scope::function(), v8::internal::BailoutId::FunctionEntry(), GetFunctionClosure(), GetFunctionContext(), v8::internal::compiler::GraphBuilder::graph(), info(), v8::internal::Scope::is_function_scope(), javascript(), jsgraph(), v8::internal::compiler::GraphBuilder::NewNode(), NULL, v8::internal::CompilationInfo::num_parameters(), PrepareFrameState(), v8::internal::CompilationInfo::scope(), v8::internal::compiler::StructuredGraphBuilder::set_environment(), v8::internal::compiler::GenericGraph< V >::SetEnd(), v8::internal::compiler::GenericGraph< V >::SetStart(), v8::internal::compiler::JSGraph::UndefinedConstant(), v8::internal::compiler::StructuredGraphBuilder::Environment::UpdateControlDependency(), v8::internal::compiler::StructuredGraphBuilder::UpdateControlDependencyToLeaveFunction(), and VisitDeclarations().

Referenced by v8::internal::compiler::AstGraphBuilderWithPositions::CreateGraph(), and v8::internal::compiler::JSInliner::TryInlineCall().

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

◆ current_scope()

Scope * v8::internal::compiler::AstGraphBuilder::current_scope ( ) const
inlineprivate

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

423  {
424  return execution_context_->scope();
425 }

References execution_context_.

Referenced by BuildVariableAssignment(), and BuildVariableLoad().

+ Here is the caller graph for this function:

◆ DEFINE_AST_VISITOR_SUBCLASS_MEMBERS()

v8::internal::compiler::AstGraphBuilder::DEFINE_AST_VISITOR_SUBCLASS_MEMBERS ( )
private

◆ DISALLOW_COPY_AND_ASSIGN()

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

◆ environment()

Environment* v8::internal::compiler::AstGraphBuilder::environment ( )
inlineprotected

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

42  {
43  return reinterpret_cast<Environment*>(
45  }

References v8::internal::compiler::StructuredGraphBuilder::environment().

Referenced by BuildHoleCheckSilent(), BuildHoleCheckThrow(), BuildVariableAssignment(), BuildVariableLoad(), CreateGraph(), PrepareFrameState(), ProcessArguments(), VisitCallJSRuntime(), VisitDelete(), VisitForInAssignment(), VisitForValueOrNull(), VisitLogicalExpression(), VisitNot(), and VisitTypeof().

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

◆ execution_context()

ContextScope* v8::internal::compiler::AstGraphBuilder::execution_context ( ) const
inlineprotected

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

49 { return execution_context_; }

References execution_context_.

◆ GetFunctionClosure()

Node * v8::internal::compiler::AstGraphBuilder::GetFunctionClosure ( )
protected

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

31  {
32  if (!function_closure_.is_set()) {
33  // Parameter -1 is special for the function closure
34  const Operator* op = common()->Parameter(-1);
35  Node* node = NewNode(op, graph()->start());
36  function_closure_.set(node);
37  }
38  return function_closure_.get();
39 }
void set(T *value)
Definition: utils.h:417

References v8::internal::compiler::StructuredGraphBuilder::common(), function_closure_, v8::internal::SetOncePointer< T >::get(), v8::internal::compiler::GraphBuilder::graph(), v8::internal::SetOncePointer< T >::is_set(), v8::internal::compiler::GraphBuilder::NewNode(), and v8::internal::SetOncePointer< T >::set().

Referenced by BuildArgumentsObject(), and CreateGraph().

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

◆ GetFunctionContext()

Node * v8::internal::compiler::AstGraphBuilder::GetFunctionContext ( )
protected

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

42  {
43  if (!function_context_.is_set()) {
44  // Parameter (arity + 1) is special for the outer context of the function
45  const Operator* op = common()->Parameter(info()->num_parameters() + 1);
46  Node* node = NewNode(op, graph()->start());
47  function_context_.set(node);
48  }
49  return function_context_.get();
50 }

References v8::internal::compiler::StructuredGraphBuilder::common(), function_context_, v8::internal::SetOncePointer< T >::get(), v8::internal::compiler::GraphBuilder::graph(), info(), v8::internal::SetOncePointer< T >::is_set(), v8::internal::compiler::GraphBuilder::NewNode(), and v8::internal::SetOncePointer< T >::set().

Referenced by BuildLoadGlobalObject(), CreateGraph(), and v8::internal::compiler::Pipeline::GenerateCode().

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

◆ globals()

ZoneList<Handle<Object> >* v8::internal::compiler::AstGraphBuilder::globals ( )
inlineprivate

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

136 { return &globals_; }

References globals_.

Referenced by VisitDeclarations().

+ Here is the caller graph for this function:

◆ info()

CompilationInfo* v8::internal::compiler::AstGraphBuilder::info ( )
inlineprivate

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

132 { return info_; }

References info_.

Referenced by AstGraphBuilder(), BuildLocalFunctionContext(), CreateGraph(), GetFunctionContext(), ProcessArguments(), strict_mode(), and VisitDeclarations().

+ Here is the caller graph for this function:

◆ javascript()

JSOperatorBuilder* v8::internal::compiler::AstGraphBuilder::javascript ( )
inlineprivate

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

135 { return jsgraph_->javascript(); }
JSOperatorBuilder * javascript()
Definition: js-graph.h:86

References v8::internal::compiler::JSGraph::javascript(), and jsgraph_.

Referenced by BuildArgumentsObject(), BuildBinaryOp(), BuildHoleCheckSilent(), BuildHoleCheckThrow(), BuildLoadGlobalObject(), BuildLocalFunctionContext(), BuildThrowReferenceError(), BuildToBoolean(), BuildVariableAssignment(), BuildVariableDelete(), BuildVariableLoad(), CreateGraph(), VisitCallJSRuntime(), VisitDeclarations(), VisitDelete(), VisitForInAssignment(), VisitNot(), and VisitTypeof().

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

◆ jsgraph()

JSGraph* v8::internal::compiler::AstGraphBuilder::jsgraph ( )
inlineprivate

◆ PrepareFrameState()

void v8::internal::compiler::AstGraphBuilder::PrepareFrameState ( Node *  node,
BailoutId  ast_id,
OutputFrameStateCombine  combine = kIgnoreOutput 
)
private

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

2021  {
2022  if (OperatorProperties::HasFrameStateInput(node->op())) {
2023  DCHECK(NodeProperties::GetFrameStateInput(node)->opcode() ==
2024  IrOpcode::kDead);
2026  node, environment()->Checkpoint(ast_id, combine));
2027  }
2028 }
static Node * GetFrameStateInput(Node *node)
static void ReplaceFrameStateInput(Node *node, Node *frame_state)
static bool HasFrameStateInput(const Operator *op)

References DCHECK, environment(), v8::internal::compiler::NodeProperties::GetFrameStateInput(), v8::internal::compiler::OperatorProperties::HasFrameStateInput(), and v8::internal::compiler::NodeProperties::ReplaceFrameStateInput().

Referenced by BuildVariableAssignment(), BuildVariableLoad(), CreateGraph(), VisitCallJSRuntime(), and VisitForInAssignment().

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

◆ ProcessArguments()

Node * v8::internal::compiler::AstGraphBuilder::ProcessArguments ( const Operator op,
int  arity 
)
private

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

1667  {
1668  DCHECK(environment()->stack_height() >= arity);
1669  Node** all = info()->zone()->NewArray<Node*>(arity);
1670  for (int i = arity - 1; i >= 0; --i) {
1671  all[i] = environment()->Pop();
1672  }
1673  Node* value = NewNode(op, arity, all);
1674  return value;
1675 }
T * NewArray(int length)
Definition: zone.h:46

References DCHECK, environment(), info(), v8::internal::Zone::NewArray(), v8::internal::compiler::GraphBuilder::NewNode(), v8::internal::compiler::AstGraphBuilder::Environment::Pop(), and v8::internal::CompilationInfo::zone().

Referenced by VisitCallJSRuntime().

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

◆ set_ast_context()

void v8::internal::compiler::AstGraphBuilder::set_ast_context ( AstContext ctx)
inlineprotected

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

51 { ast_context_ = ctx; }

References ast_context_.

◆ set_breakable()

void v8::internal::compiler::AstGraphBuilder::set_breakable ( BreakableScope *  brk)
inlineprotected

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

52 { breakable_ = brk; }

References breakable_.

◆ set_execution_context()

void v8::internal::compiler::AstGraphBuilder::set_execution_context ( ContextScope *  ctx)
inlineprotected

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

53 { execution_context_ = ctx; }

References execution_context_.

◆ StateCombineFromAstContext()

OutputFrameStateCombine v8::internal::compiler::AstGraphBuilder::StateCombineFromAstContext ( )
private

◆ strict_mode()

StrictMode v8::internal::compiler::AstGraphBuilder::strict_mode ( )
inlineprivate

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

133 { return info()->strict_mode(); }
StrictMode strict_mode() const
Definition: compiler.h:104

References info(), and v8::internal::CompilationInfo::strict_mode().

Referenced by BuildVariableAssignment(), BuildVariableDelete(), VisitDeclarations(), VisitDelete(), and VisitForInAssignment().

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

◆ VisitArithmeticExpression()

void v8::internal::compiler::AstGraphBuilder::VisitArithmeticExpression ( BinaryOperation *  expr)
private

◆ VisitCallJSRuntime()

void v8::internal::compiler::AstGraphBuilder::VisitCallJSRuntime ( CallRuntime *  expr)
private

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

1305  {
1306  Handle<String> name = expr->name();
1307 
1308  // The callee and the receiver both have to be pushed onto the operand stack
1309  // before arguments are being evaluated.
1311  Node* receiver_value = BuildLoadBuiltinsObject();
1312  Unique<String> unique = MakeUnique(name);
1313  Node* callee_value = NewNode(javascript()->LoadNamed(unique), receiver_value);
1314  // TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft
1315  // refuses to optimize functions with jsruntime calls).
1316  PrepareFrameState(callee_value, BailoutId::None(), kPushOutput);
1317  environment()->Push(callee_value);
1318  environment()->Push(receiver_value);
1319 
1320  // Evaluate all arguments to the JS runtime call.
1321  ZoneList<Expression*>* args = expr->arguments();
1322  VisitForValues(args);
1323 
1324  // Create node to perform the JS runtime call.
1325  const Operator* call = javascript()->Call(args->length() + 2, flags);
1326  Node* value = ProcessArguments(call, args->length() + 2);
1327  PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
1328  ast_context()->ProduceValue(value);
1329 }
Node * ProcessArguments(const Operator *op, int arity)
void VisitForValues(ZoneList< Expression * > *exprs)
const Operator * Call(int arguments, CallFunctionFlags flags)
Definition: js-operator.h:114
@ NO_CALL_FUNCTION_FLAGS
Definition: globals.h:469

References ast_context(), BuildLoadBuiltinsObject(), v8::internal::compiler::JSOperatorBuilder::Call(), environment(), v8::internal::anonymous_namespace{flags.cc}::flags, javascript(), v8::internal::compiler::kPushOutput, v8::internal::compiler::StructuredGraphBuilder::MakeUnique(), name, v8::internal::compiler::GraphBuilder::NewNode(), v8::internal::NO_CALL_FUNCTION_FLAGS, v8::internal::BailoutId::None(), PrepareFrameState(), ProcessArguments(), v8::internal::compiler::AstGraphBuilder::Environment::Push(), and VisitForValues().

+ Here is the call graph for this function:

◆ VisitComma()

void v8::internal::compiler::AstGraphBuilder::VisitComma ( BinaryOperation *  expr)
private

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

1635  {
1636  VisitForEffect(expr->left());
1637  Visit(expr->right());
1638  ast_context()->ReplaceValue();
1639 }

References ast_context(), and VisitForEffect().

+ Here is the call graph for this function:

◆ VisitDeclarations()

void v8::internal::compiler::AstGraphBuilder::VisitDeclarations ( ZoneList< Declaration * > *  declarations)
protectedvirtual

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

1548  {
1549  DCHECK(globals()->is_empty());
1550  AstVisitor::VisitDeclarations(declarations);
1551  if (globals()->is_empty()) return;
1552  Handle<FixedArray> data =
1553  isolate()->factory()->NewFixedArray(globals()->length(), TENURED);
1554  for (int i = 0; i < globals()->length(); ++i) data->set(i, *globals()->at(i));
1555  int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval()) |
1556  DeclareGlobalsNativeFlag::encode(info()->is_native()) |
1558  Node* flags = jsgraph()->Constant(encoded_flags);
1559  Node* pairs = jsgraph()->Constant(data);
1560  const Operator* op = javascript()->Runtime(Runtime::kDeclareGlobals, 3);
1562  globals()->Rewind(0);
1563 }
static U encode(T value)
Definition: utils.h:217
Factory * factory()
Definition: isolate.h:982
ZoneList< Handle< Object > > * globals()
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 pairs(ARM only)") DEFINE_BOOL(enable_unaligned_accesses

References v8::internal::compiler::JSGraph::Constant(), v8::internal::compiler::StructuredGraphBuilder::current_context(), DCHECK, v8::internal::BitFieldBase< T, shift, size, U >::encode(), v8::internal::Isolate::factory(), v8::internal::anonymous_namespace{flags.cc}::flags, globals(), info(), v8::internal::compiler::StructuredGraphBuilder::isolate(), javascript(), jsgraph(), v8::internal::compiler::GraphBuilder::NewNode(), pairs(), v8::internal::compiler::JSOperatorBuilder::Runtime(), strict_mode(), and v8::internal::TENURED.

Referenced by CreateGraph().

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

◆ VisitDelete()

void v8::internal::compiler::AstGraphBuilder::VisitDelete ( UnaryOperation *  expr)
private

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

1579  {
1580  Node* value;
1581  if (expr->expression()->IsVariableProxy()) {
1582  // Delete of an unqualified identifier is only allowed in classic mode but
1583  // deleting "this" is allowed in all language modes.
1584  Variable* variable = expr->expression()->AsVariableProxy()->var();
1585  DCHECK(strict_mode() == SLOPPY || variable->is_this());
1586  value = BuildVariableDelete(variable);
1587  } else if (expr->expression()->IsProperty()) {
1588  Property* property = expr->expression()->AsProperty();
1589  VisitForValue(property->obj());
1590  VisitForValue(property->key());
1591  Node* key = environment()->Pop();
1592  Node* object = environment()->Pop();
1593  value = NewNode(javascript()->DeleteProperty(strict_mode()), object, key);
1594  } else {
1595  VisitForEffect(expr->expression());
1596  value = jsgraph()->TrueConstant();
1597  }
1598  ast_context()->ProduceValue(value);
1599 }

References ast_context(), BuildVariableDelete(), DCHECK, environment(), v8::internal::Variable::is_this(), javascript(), jsgraph(), v8::internal::compiler::GraphBuilder::NewNode(), v8::internal::compiler::AstGraphBuilder::Environment::Pop(), v8::internal::SLOPPY, strict_mode(), v8::internal::compiler::JSGraph::TrueConstant(), VisitForEffect(), and VisitForValue().

+ Here is the call graph for this function:

◆ VisitForEffect()

void v8::internal::compiler::AstGraphBuilder::VisitForEffect ( Expression expr)
private

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

338  {
339  AstEffectContext for_effect(this);
340  if (!HasStackOverflow()) {
341  expr->Accept(this);
342  }
343 }

References v8::internal::AstNode::Accept().

Referenced by VisitComma(), VisitDelete(), and VisitVoid().

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

◆ VisitForInAssignment()

void v8::internal::compiler::AstGraphBuilder::VisitForInAssignment ( Expression expr,
Node *  value 
)
private

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

1016  {
1017  DCHECK(expr->IsValidReferenceExpression());
1018 
1019  // Left-hand side can only be a property, a global or a variable slot.
1020  Property* property = expr->AsProperty();
1021  LhsKind assign_type = DetermineLhsKind(expr);
1022 
1023  // Evaluate LHS expression and store the value.
1024  switch (assign_type) {
1025  case VARIABLE: {
1026  Variable* var = expr->AsVariableProxy()->var();
1027  // TODO(jarin) Fill in the correct bailout id.
1028  BuildVariableAssignment(var, value, Token::ASSIGN, BailoutId::None());
1029  break;
1030  }
1031  case NAMED_PROPERTY: {
1032  environment()->Push(value);
1033  VisitForValue(property->obj());
1034  Node* object = environment()->Pop();
1035  value = environment()->Pop();
1036  Unique<Name> name =
1037  MakeUnique(property->key()->AsLiteral()->AsPropertyName());
1038  Node* store =
1039  NewNode(javascript()->StoreNamed(strict_mode(), name), object, value);
1040  // TODO(jarin) Fill in the correct bailout id.
1042  break;
1043  }
1044  case KEYED_PROPERTY: {
1045  environment()->Push(value);
1046  VisitForValue(property->obj());
1047  VisitForValue(property->key());
1048  Node* key = environment()->Pop();
1049  Node* object = environment()->Pop();
1050  value = environment()->Pop();
1051  Node* store = NewNode(javascript()->StoreProperty(strict_mode()), object,
1052  key, value);
1053  // TODO(jarin) Fill in the correct bailout id.
1055  break;
1056  }
1057  }
1058 }
static LhsKind DetermineLhsKind(Expression *expr)

References BuildVariableAssignment(), DCHECK, v8::internal::compiler::DetermineLhsKind(), environment(), v8::internal::Expression::IsValidReferenceExpression(), javascript(), v8::internal::compiler::KEYED_PROPERTY, v8::internal::compiler::StructuredGraphBuilder::MakeUnique(), name, v8::internal::compiler::NAMED_PROPERTY, v8::internal::compiler::GraphBuilder::NewNode(), v8::internal::BailoutId::None(), v8::internal::compiler::AstGraphBuilder::Environment::Pop(), PrepareFrameState(), v8::internal::compiler::AstGraphBuilder::Environment::Push(), strict_mode(), v8::internal::compiler::VARIABLE, and VisitForValue().

+ Here is the call graph for this function:

◆ VisitForTest()

void v8::internal::compiler::AstGraphBuilder::VisitForTest ( Expression expr)
private

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

346  {
347  AstTestContext for_condition(this);
348  if (!HasStackOverflow()) {
349  expr->Accept(this);
350  }
351 }

References v8::internal::AstNode::Accept().

+ Here is the call graph for this function:

◆ VisitForValue()

void v8::internal::compiler::AstGraphBuilder::VisitForValue ( Expression expr)
private

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

330  {
331  AstValueContext for_value(this);
332  if (!HasStackOverflow()) {
333  expr->Accept(this);
334  }
335 }

References v8::internal::AstNode::Accept().

Referenced by VisitDelete(), VisitForInAssignment(), VisitForValueOrNull(), VisitForValues(), VisitLogicalExpression(), VisitNot(), and VisitTypeof().

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

◆ VisitForValueOrNull()

void v8::internal::compiler::AstGraphBuilder::VisitForValueOrNull ( Expression expr)
private

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

315  {
316  if (expr == NULL) {
317  return environment()->Push(jsgraph()->NullConstant());
318  }
319  VisitForValue(expr);
320 }

References environment(), jsgraph(), NULL, v8::internal::compiler::AstGraphBuilder::Environment::Push(), and VisitForValue().

+ Here is the call graph for this function:

◆ VisitForValues()

void v8::internal::compiler::AstGraphBuilder::VisitForValues ( ZoneList< Expression * > *  exprs)
private

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

323  {
324  for (int i = 0; i < exprs->length(); ++i) {
325  VisitForValue(exprs->at(i));
326  }
327 }

References v8::internal::List< T, AllocationPolicy >::at(), and VisitForValue().

Referenced by VisitCallJSRuntime().

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

◆ VisitIfNotNull()

void v8::internal::compiler::AstGraphBuilder::VisitIfNotNull ( Statement stmt)
private

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

1566  {
1567  if (stmt == NULL) return;
1568  Visit(stmt);
1569 }

References NULL.

◆ VisitIterationBody()

void v8::internal::compiler::AstGraphBuilder::VisitIterationBody ( IterationStatement stmt,
LoopBuilder loop,
int  drop_extra 
)
private

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

1573  {
1574  BreakableScope scope(this, stmt, loop, drop_extra);
1575  Visit(stmt->body());
1576 }

References v8::internal::IterationStatement::body().

+ Here is the call graph for this function:

◆ VisitLogicalExpression()

void v8::internal::compiler::AstGraphBuilder::VisitLogicalExpression ( BinaryOperation *  expr)
private

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

1642  {
1643  bool is_logical_and = expr->op() == Token::AND;
1644  IfBuilder compare_if(this);
1645  VisitForValue(expr->left());
1646  Node* condition = environment()->Top();
1647  compare_if.If(BuildToBoolean(condition));
1648  compare_if.Then();
1649  if (is_logical_and) {
1650  environment()->Pop();
1651  Visit(expr->right());
1652  } else if (ast_context()->IsEffect()) {
1653  environment()->Pop();
1654  }
1655  compare_if.Else();
1656  if (!is_logical_and) {
1657  environment()->Pop();
1658  Visit(expr->right());
1659  } else if (ast_context()->IsEffect()) {
1660  environment()->Pop();
1661  }
1662  compare_if.End();
1663  ast_context()->ReplaceValue();
1664 }

References v8::internal::AND, ast_context(), BuildToBoolean(), v8::internal::compiler::IfBuilder::Else(), v8::internal::compiler::IfBuilder::End(), environment(), v8::internal::compiler::IfBuilder::If(), v8::internal::compiler::AstGraphBuilder::Environment::Pop(), v8::internal::compiler::IfBuilder::Then(), v8::internal::compiler::AstGraphBuilder::Environment::Top(), and VisitForValue().

+ Here is the call graph for this function:

◆ VisitNot()

void v8::internal::compiler::AstGraphBuilder::VisitNot ( UnaryOperation *  expr)
private

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

1626  {
1627  VisitForValue(expr->expression());
1628  Node* operand = environment()->Pop();
1629  // TODO(mstarzinger): Possible optimization when we are in effect context.
1630  Node* value = NewNode(javascript()->UnaryNot(), operand);
1631  ast_context()->ProduceValue(value);
1632 }

References ast_context(), environment(), javascript(), v8::internal::compiler::GraphBuilder::NewNode(), v8::internal::compiler::AstGraphBuilder::Environment::Pop(), and VisitForValue().

+ Here is the call graph for this function:

◆ VisitTypeof()

void v8::internal::compiler::AstGraphBuilder::VisitTypeof ( UnaryOperation *  expr)
private

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

1609  {
1610  Node* operand;
1611  if (expr->expression()->IsVariableProxy()) {
1612  // Typeof does not throw a reference error on global variables, hence we
1613  // perform a non-contextual load in case the operand is a variable proxy.
1614  Variable* variable = expr->expression()->AsVariableProxy()->var();
1615  operand =
1616  BuildVariableLoad(variable, expr->expression()->id(), NOT_CONTEXTUAL);
1617  } else {
1618  VisitForValue(expr->expression());
1619  operand = environment()->Pop();
1620  }
1621  Node* value = NewNode(javascript()->TypeOf(), operand);
1622  ast_context()->ProduceValue(value);
1623 }
Node * BuildVariableLoad(Variable *var, BailoutId bailout_id, ContextualMode mode=CONTEXTUAL)
MachineType TypeOf(MachineType machine_type)
Definition: machine-type.h:70
@ NOT_CONTEXTUAL
Definition: objects.h:174

References ast_context(), BuildVariableLoad(), environment(), javascript(), v8::internal::compiler::GraphBuilder::NewNode(), v8::internal::NOT_CONTEXTUAL, v8::internal::compiler::AstGraphBuilder::Environment::Pop(), v8::internal::compiler::TypeOf(), and VisitForValue().

+ Here is the call graph for this function:

◆ VisitVoid()

void v8::internal::compiler::AstGraphBuilder::VisitVoid ( UnaryOperation *  expr)
private

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

1602  {
1603  VisitForEffect(expr->expression());
1604  Node* value = jsgraph()->UndefinedConstant();
1605  ast_context()->ProduceValue(value);
1606 }

References ast_context(), jsgraph(), v8::internal::compiler::JSGraph::UndefinedConstant(), and VisitForEffect().

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ Pipeline

friend class Pipeline
friend

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

Member Data Documentation

◆ ast_context_

AstContext* v8::internal::compiler::AstGraphBuilder::ast_context_
private

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

Referenced by ast_context(), and set_ast_context().

◆ breakable_

BreakableScope* v8::internal::compiler::AstGraphBuilder::breakable_
private

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

Referenced by breakable(), and set_breakable().

◆ execution_context_

ContextScope* v8::internal::compiler::AstGraphBuilder::execution_context_
private

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

Referenced by current_scope(), execution_context(), and set_execution_context().

◆ function_closure_

SetOncePointer<Node> v8::internal::compiler::AstGraphBuilder::function_closure_
private

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

Referenced by GetFunctionClosure().

◆ function_context_

SetOncePointer<Node> v8::internal::compiler::AstGraphBuilder::function_context_
private

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

Referenced by GetFunctionContext().

◆ globals_

ZoneList<Handle<Object> > v8::internal::compiler::AstGraphBuilder::globals_
private

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

Referenced by globals().

◆ info_

CompilationInfo* v8::internal::compiler::AstGraphBuilder::info_
private

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

Referenced by info().

◆ jsgraph_

JSGraph* v8::internal::compiler::AstGraphBuilder::jsgraph_
private

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

Referenced by javascript(), and jsgraph().


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