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

Public Member Functions

 Inlinee (Node *start, Node *end)
 
Node * end_block ()
 
Node * effect_output ()
 
Node * value_output ()
 
Node * unique_return ()
 
size_t total_parameters ()
 
size_t formal_parameters ()
 
void InlineAtCall (JSGraph *jsgraph, Node *call)
 

Static Public Member Functions

static void UnifyReturn (JSGraph *jsgraph)
 

Private Attributes

Node * start_
 
Node * end_
 

Detailed Description

Definition at line 67 of file js-inlining.cc.

Constructor & Destructor Documentation

◆ Inlinee()

v8::internal::compiler::Inlinee::Inlinee ( Node *  start,
Node *  end 
)
inline

Definition at line 69 of file js-inlining.cc.

Member Function Documentation

◆ effect_output()

Node* v8::internal::compiler::Inlinee::effect_output ( )
inline

Definition at line 77 of file js-inlining.cc.

77  {
79  }
static Node * GetEffectInput(Node *node, int index=0)

References v8::internal::compiler::NodeProperties::GetEffectInput(), and unique_return().

Referenced by InlineAtCall().

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

◆ end_block()

Node* v8::internal::compiler::Inlinee::end_block ( )
inline

Definition at line 73 of file js-inlining.cc.

static Node * GetControlInput(Node *node, int index=0)

References v8::internal::compiler::NodeProperties::GetControlInput(), and unique_return().

+ Here is the call graph for this function:

◆ formal_parameters()

size_t v8::internal::compiler::Inlinee::formal_parameters ( )
inline

Definition at line 96 of file js-inlining.cc.

96  {
98  return total_parameters() - 3;
99  }
#define DCHECK_GE(v1, v2)
Definition: logging.h:208

References DCHECK_GE, and total_parameters().

Referenced by v8::internal::compiler::JSInliner::TryInlineCall().

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

◆ InlineAtCall()

void v8::internal::compiler::Inlinee::InlineAtCall ( JSGraph jsgraph,
Node *  call 
)

Definition at line 233 of file js-inlining.cc.

233  {
234  // The scheduler is smart enough to place our code; we just ensure {control}
235  // becomes the control input of the start of the inlinee.
236  Node* control = NodeProperties::GetControlInput(call);
237 
238  // The inlinee uses the context from the JSFunction object. This will
239  // also be the effect dependency for the inlinee as it produces an effect.
240  SimplifiedOperatorBuilder simplified(jsgraph->zone());
241  Node* context = jsgraph->graph()->NewNode(
242  simplified.LoadField(AccessBuilder::ForJSFunctionContext()),
245 
246  // Context is last argument.
247  int inlinee_context_index = static_cast<int>(total_parameters()) - 1;
248  // {inliner_inputs} counts JSFunction, Receiver, arguments, but not
249  // context, effect, control.
250  int inliner_inputs = OperatorProperties::GetValueInputCount(call->op());
251  // Iterate over all uses of the start node.
252  UseIter iter = start_->uses().begin();
253  while (iter != start_->uses().end()) {
254  Node* use = *iter;
255  switch (use->opcode()) {
256  case IrOpcode::kParameter: {
257  int index = 1 + OpParameter<int>(use->op());
258  if (index < inliner_inputs && index < inlinee_context_index) {
259  // There is an input from the call, and the index is a value
260  // projection but not the context, so rewire the input.
261  NodeProperties::ReplaceWithValue(*iter, call->InputAt(index));
262  } else if (index == inlinee_context_index) {
263  // This is the context projection, rewire it to the context from the
264  // JSFunction object.
265  NodeProperties::ReplaceWithValue(*iter, context);
266  } else if (index < inlinee_context_index) {
267  // Call has fewer arguments than required, fill with undefined.
268  NodeProperties::ReplaceWithValue(*iter, jsgraph->UndefinedConstant());
269  } else {
270  // We got too many arguments, discard for now.
271  // TODO(sigurds): Fix to treat arguments array correctly.
272  }
273  ++iter;
274  break;
275  }
276  default:
277  if (NodeProperties::IsEffectEdge(iter.edge())) {
278  iter.UpdateToAndIncrement(context);
279  } else if (NodeProperties::IsControlEdge(iter.edge())) {
280  iter.UpdateToAndIncrement(control);
281  } else {
282  UNREACHABLE();
283  }
284  break;
285  }
286  }
287 
288  // Iterate over all uses of the call node.
289  iter = call->uses().begin();
290  while (iter != call->uses().end()) {
291  if (NodeProperties::IsEffectEdge(iter.edge())) {
292  iter.UpdateToAndIncrement(effect_output());
293  } else if (NodeProperties::IsControlEdge(iter.edge())) {
294  UNREACHABLE();
295  } else {
296  DCHECK(NodeProperties::IsValueEdge(iter.edge()));
297  iter.UpdateToAndIncrement(value_output());
298  }
299  }
300  call->RemoveAllInputs();
301  DCHECK_EQ(0, call->UseCount());
302  // TODO(sigurds) Remove this once we copy.
303  unique_return()->RemoveAllInputs();
304 }
static void ReplaceWithValue(Node *node, Node *value, Node *effect=NULL)
static Node * GetValueInput(Node *node, int index)
static bool IsControlEdge(Node::Edge edge)
static bool IsEffectEdge(Node::Edge edge)
static bool IsValueEdge(Node::Edge edge)
static int GetValueInputCount(const Operator *op)
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 use(in kBytes)") DEFINE_INT(max_stack_trace_source_length
#define UNREACHABLE()
Definition: logging.h:30
#define DCHECK(condition)
Definition: logging.h:205
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206
Node::Uses::iterator UseIter
Definition: node.h:81

References DCHECK, DCHECK_EQ, effect_output(), v8::internal::compiler::NodeProperties::GetControlInput(), v8::internal::compiler::NodeProperties::GetEffectInput(), v8::internal::compiler::NodeProperties::GetValueInput(), v8::internal::compiler::OperatorProperties::GetValueInputCount(), v8::internal::compiler::JSGraph::graph(), v8::internal::compiler::NodeProperties::IsControlEdge(), v8::internal::compiler::NodeProperties::IsEffectEdge(), v8::internal::compiler::NodeProperties::IsValueEdge(), v8::internal::compiler::Graph::NewNode(), v8::internal::compiler::NodeProperties::ReplaceWithValue(), start_, total_parameters(), v8::internal::compiler::JSGraph::UndefinedConstant(), unique_return(), UNREACHABLE, use(), value_output(), and v8::internal::compiler::JSGraph::zone().

Referenced by v8::internal::compiler::JSInliner::TryInlineCall().

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

◆ total_parameters()

size_t v8::internal::compiler::Inlinee::total_parameters ( )
inline

Definition at line 93 of file js-inlining.cc.

93 { return start_->op()->OutputCount(); }

References start_.

Referenced by formal_parameters(), and InlineAtCall().

+ Here is the caller graph for this function:

◆ UnifyReturn()

void v8::internal::compiler::Inlinee::UnifyReturn ( JSGraph jsgraph)
static

Definition at line 114 of file js-inlining.cc.

114  {
115  Graph* graph = jsgraph->graph();
116 
117  Node* final_merge = NodeProperties::GetControlInput(graph->end(), 0);
118  if (final_merge->opcode() == IrOpcode::kReturn) {
119  // nothing to do
120  return;
121  }
122  DCHECK_EQ(IrOpcode::kMerge, final_merge->opcode());
123 
124  int predecessors =
125  OperatorProperties::GetControlInputCount(final_merge->op());
126 
127  const Operator* op_phi = jsgraph->common()->Phi(kMachAnyTagged, predecessors);
128  const Operator* op_ephi = jsgraph->common()->EffectPhi(predecessors);
129 
130  NodeVector values(jsgraph->zone());
131  NodeVector effects(jsgraph->zone());
132  // Iterate over all control flow predecessors,
133  // which must be return statements.
134  InputIter iter = final_merge->inputs().begin();
135  while (iter != final_merge->inputs().end()) {
136  Node* input = *iter;
137  switch (input->opcode()) {
138  case IrOpcode::kReturn:
139  values.push_back(NodeProperties::GetValueInput(input, 0));
140  effects.push_back(NodeProperties::GetEffectInput(input));
141  iter.UpdateToAndIncrement(NodeProperties::GetControlInput(input));
142  input->RemoveAllInputs();
143  break;
144  default:
145  UNREACHABLE();
146  ++iter;
147  break;
148  }
149  }
150  values.push_back(final_merge);
151  effects.push_back(final_merge);
152  Node* phi =
153  graph->NewNode(op_phi, static_cast<int>(values.size()), &values.front());
154  Node* ephi = graph->NewNode(op_ephi, static_cast<int>(effects.size()),
155  &effects.front());
156  Node* new_return =
157  graph->NewNode(jsgraph->common()->Return(), phi, ephi, final_merge);
158  graph->end()->ReplaceInput(0, new_return);
159 }
static int GetControlInputCount(const Operator *op)
ZoneVector< Node * > NodeVector
Definition: node.h:72
Node::Inputs::iterator InputIter
Definition: node.h:82

References v8::internal::compiler::JSGraph::common(), DCHECK_EQ, v8::internal::compiler::GenericGraph< V >::end(), v8::internal::compiler::NodeProperties::GetControlInput(), v8::internal::compiler::OperatorProperties::GetControlInputCount(), v8::internal::compiler::NodeProperties::GetEffectInput(), v8::internal::compiler::NodeProperties::GetValueInput(), v8::internal::compiler::JSGraph::graph(), v8::internal::compiler::kMachAnyTagged, v8::internal::compiler::Graph::NewNode(), UNREACHABLE, and v8::internal::compiler::JSGraph::zone().

Referenced by v8::internal::compiler::JSInliner::TryInlineCall().

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

◆ unique_return()

Node* v8::internal::compiler::Inlinee::unique_return ( )
inline

Definition at line 86 of file js-inlining.cc.

86  {
88  DCHECK_EQ(IrOpcode::kReturn, unique_return->opcode());
89  return unique_return;
90  }

References DCHECK_EQ, end_, and v8::internal::compiler::NodeProperties::GetControlInput().

Referenced by effect_output(), end_block(), InlineAtCall(), and value_output().

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

◆ value_output()

Node* v8::internal::compiler::Inlinee::value_output ( )
inline

Definition at line 82 of file js-inlining.cc.

82  {
84  }

References v8::internal::compiler::NodeProperties::GetValueInput(), and unique_return().

Referenced by InlineAtCall().

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

Member Data Documentation

◆ end_

Node* v8::internal::compiler::Inlinee::end_
private

Definition at line 110 of file js-inlining.cc.

Referenced by unique_return().

◆ start_

Node* v8::internal::compiler::Inlinee::start_
private

Definition at line 109 of file js-inlining.cc.

Referenced by InlineAtCall(), and total_parameters().


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