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

#include <js-inlining.h>

+ Collaboration diagram for v8::internal::compiler::JSInliner:

Public Member Functions

 JSInliner (CompilationInfo *info, JSGraph *jsgraph)
 
void Inline ()
 
void TryInlineCall (Node *node)
 

Private Member Functions

Node * CreateArgumentsAdaptorFrameState (JSCallFunctionAccessor *call, Handle< JSFunction > jsfunction, Zone *temp_zone)
 
void AddClosureToFrameState (Node *frame_state, Handle< JSFunction > jsfunction)
 

Static Private Member Functions

static void UnifyReturn (Graph *graph)
 

Private Attributes

CompilationInfoinfo_
 
JSGraphjsgraph_
 

Friends

class InlinerVisitor
 

Detailed Description

Definition at line 17 of file js-inlining.h.

Constructor & Destructor Documentation

◆ JSInliner()

v8::internal::compiler::JSInliner::JSInliner ( CompilationInfo info,
JSGraph jsgraph 
)
inline

Definition at line 19 of file js-inlining.h.

20  : info_(info), jsgraph_(jsgraph) {}

Member Function Documentation

◆ AddClosureToFrameState()

void v8::internal::compiler::JSInliner::AddClosureToFrameState ( Node *  frame_state,
Handle< JSFunction jsfunction 
)
private

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

339  {
340  FrameStateCallInfo call_info = OpParameter<FrameStateCallInfo>(frame_state);
341  const Operator* op = jsgraph_->common()->FrameState(
342  FrameStateType::JS_FRAME, call_info.bailout_id(),
343  call_info.state_combine(), jsfunction);
344  frame_state->set_op(op);
345 }
CommonOperatorBuilder * common()
Definition: js-graph.h:87

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

Referenced by TryInlineCall().

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

◆ CreateArgumentsAdaptorFrameState()

Node * v8::internal::compiler::JSInliner::CreateArgumentsAdaptorFrameState ( JSCallFunctionAccessor call,
Handle< JSFunction jsfunction,
Zone temp_zone 
)
private

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

350  {
351  const Operator* op =
353  BailoutId(-1), kIgnoreOutput, jsfunction);
354  const Operator* op0 = jsgraph_->common()->StateValues(0);
355  Node* node0 = jsgraph_->graph()->NewNode(op0);
356  NodeVector params(temp_zone);
357  params.push_back(call->receiver());
358  for (size_t argument = 0; argument != call->formal_arguments(); ++argument) {
359  params.push_back(call->formal_argument(argument));
360  }
361  const Operator* op_param =
362  jsgraph_->common()->StateValues(static_cast<int>(params.size()));
363  Node* params_node = jsgraph_->graph()->NewNode(
364  op_param, static_cast<int>(params.size()), &params.front());
365  return jsgraph_->graph()->NewNode(op, params_node, node0, node0,
367  call->frame_state());
368 }
Node * NewNode(const Operator *op, int input_count, Node **inputs)
Definition: graph.cc:24
ZoneVector< Node * > NodeVector
Definition: node.h:72

References v8::internal::compiler::ARGUMENTS_ADAPTOR, v8::internal::compiler::JSGraph::common(), v8::internal::compiler::JSCallFunctionAccessor::formal_argument(), v8::internal::compiler::JSCallFunctionAccessor::formal_arguments(), v8::internal::compiler::JSCallFunctionAccessor::frame_state(), v8::internal::compiler::JSGraph::graph(), jsgraph_, v8::internal::compiler::kIgnoreOutput, v8::internal::compiler::Graph::NewNode(), v8::internal::compiler::JSCallFunctionAccessor::receiver(), and v8::internal::compiler::JSGraph::UndefinedConstant().

Referenced by TryInlineCall().

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

◆ Inline()

void v8::internal::compiler::JSInliner::Inline ( )

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

48  {
49  InlinerVisitor visitor(this);
51 }
void VisitNodeInputsFromEnd(Visitor *visitor)
Definition: graph-inl.h:30

References v8::internal::compiler::JSGraph::graph(), jsgraph_, and v8::internal::compiler::Graph::VisitNodeInputsFromEnd().

Referenced by v8::internal::compiler::Pipeline::GenerateCode().

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

◆ TryInlineCall()

void v8::internal::compiler::JSInliner::TryInlineCall ( Node *  node)

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

371  {
372  JSCallFunctionAccessor call(call_node);
373 
374  HeapObjectMatcher<JSFunction> match(call.jsfunction());
375  if (!match.HasValue()) {
376  return;
377  }
378 
379  Handle<JSFunction> function = match.Value().handle();
380 
381  if (function->shared()->native()) {
382  if (FLAG_trace_turbo_inlining) {
383  SmartArrayPointer<char> name =
384  function->shared()->DebugName()->ToCString();
385  PrintF("Not Inlining %s into %s because inlinee is native\n", name.get(),
386  info_->shared_info()->DebugName()->ToCString().get());
387  }
388  return;
389  }
390 
391  CompilationInfoWithZone info(function);
392  Parse(function, &info);
393 
394  if (info.scope()->arguments() != NULL) {
395  // For now do not inline functions that use their arguments array.
396  SmartArrayPointer<char> name = function->shared()->DebugName()->ToCString();
397  if (FLAG_trace_turbo_inlining) {
398  PrintF(
399  "Not Inlining %s into %s because inlinee uses arguments "
400  "array\n",
401  name.get(), info_->shared_info()->DebugName()->ToCString().get());
402  }
403  return;
404  }
405 
406  if (FLAG_trace_turbo_inlining) {
407  SmartArrayPointer<char> name = function->shared()->DebugName()->ToCString();
408  PrintF("Inlining %s into %s\n", name.get(),
409  info_->shared_info()->DebugName()->ToCString().get());
410  }
411 
412  Graph graph(info.zone());
413  Typer typer(info.zone());
414  JSGraph jsgraph(&graph, jsgraph_->common(), jsgraph_->javascript(), &typer,
415  jsgraph_->machine());
416 
417  AstGraphBuilder graph_builder(&info, &jsgraph);
418  graph_builder.CreateGraph();
419  Inlinee::UnifyReturn(&jsgraph);
420 
421  CopyVisitor visitor(&graph, jsgraph_->graph(), info.zone());
422  visitor.CopyGraph();
423 
424  Inlinee inlinee(visitor.GetCopy(graph.start()), visitor.GetCopy(graph.end()));
425 
426  Node* outer_frame_state = call.frame_state();
427  // Insert argument adaptor frame if required.
428  if (call.formal_arguments() != inlinee.formal_parameters()) {
429  outer_frame_state =
430  CreateArgumentsAdaptorFrameState(&call, function, info.zone());
431  }
432 
433  for (NodeVectorConstIter it = visitor.copies().begin();
434  it != visitor.copies().end(); ++it) {
435  Node* node = *it;
436  if (node != NULL && node->opcode() == IrOpcode::kFrameState) {
437  AddClosureToFrameState(node, function);
438  NodeProperties::ReplaceFrameStateInput(node, outer_frame_state);
439  }
440  }
441 
442  inlinee.InlineAtCall(jsgraph_, call_node);
443 }
Handle< SharedFunctionInfo > shared_info() const
Definition: compiler.h:112
static void UnifyReturn(JSGraph *jsgraph)
Definition: js-inlining.cc:114
JSOperatorBuilder * javascript()
Definition: js-graph.h:86
MachineOperatorBuilder * machine()
Definition: js-graph.h:88
Node * CreateArgumentsAdaptorFrameState(JSCallFunctionAccessor *call, Handle< JSFunction > jsfunction, Zone *temp_zone)
Definition: js-inlining.cc:348
void AddClosureToFrameState(Node *frame_state, Handle< JSFunction > jsfunction)
Definition: js-inlining.cc:338
static void ReplaceFrameStateInput(Node *node, Node *frame_state)
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 enable alignment of csp to bytes on platforms which prefer the register to always be NULL
NodeVector::const_iterator NodeVectorConstIter
Definition: node.h:74
static void Parse(Handle< JSFunction > function, CompilationInfoWithZone *info)
Definition: js-inlining.cc:56
void PrintF(const char *format,...)
Definition: utils.cc:80

References AddClosureToFrameState(), v8::internal::Scope::arguments(), v8::internal::compiler::JSGraph::common(), v8::internal::compiler::CopyVisitor::copies(), v8::internal::compiler::CopyVisitor::CopyGraph(), CreateArgumentsAdaptorFrameState(), v8::internal::compiler::AstGraphBuilder::CreateGraph(), v8::internal::compiler::GenericGraph< V >::end(), v8::internal::compiler::JSCallFunctionAccessor::formal_arguments(), v8::internal::compiler::Inlinee::formal_parameters(), v8::internal::compiler::JSCallFunctionAccessor::frame_state(), v8::internal::compiler::CopyVisitor::GetCopy(), v8::internal::compiler::JSGraph::graph(), info_, v8::internal::compiler::Inlinee::InlineAtCall(), v8::internal::compiler::JSGraph::javascript(), v8::internal::compiler::JSCallFunctionAccessor::jsfunction(), jsgraph_, v8::internal::compiler::JSGraph::machine(), name, NULL, v8::internal::compiler::Parse(), v8::internal::PrintF(), v8::internal::compiler::NodeProperties::ReplaceFrameStateInput(), v8::internal::CompilationInfo::scope(), v8::internal::CompilationInfo::shared_info(), v8::internal::compiler::GenericGraph< V >::start(), v8::internal::compiler::Inlinee::UnifyReturn(), and v8::internal::CompilationInfo::zone().

Referenced by v8::internal::compiler::InlinerVisitor::Post().

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

◆ UnifyReturn()

static void v8::internal::compiler::JSInliner::UnifyReturn ( Graph graph)
staticprivate

Friends And Related Function Documentation

◆ InlinerVisitor

friend class InlinerVisitor
friend

Definition at line 26 of file js-inlining.h.

Member Data Documentation

◆ info_

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

Definition at line 27 of file js-inlining.h.

Referenced by TryInlineCall().

◆ jsgraph_

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

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