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

#include <js-generic-lowering.h>

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

Public Member Functions

 JSGenericLowering (CompilationInfo *info, JSGraph *graph)
 
virtual ~JSGenericLowering ()
 
virtual Reduction Reduce (Node *node)
 
- Public Member Functions inherited from v8::internal::compiler::Reducer
 Reducer ()
 
virtual ~Reducer ()
 

Protected Member Functions

Node * SmiConstant (int immediate)
 
Node * Int32Constant (int immediate)
 
Node * CodeConstant (Handle< Code > code)
 
Node * FunctionConstant (Handle< JSFunction > function)
 
Node * ExternalConstant (ExternalReference ref)
 
void PatchOperator (Node *node, const Operator *new_op)
 
void PatchInsertInput (Node *node, int index, Node *input)
 
void ReplaceWithCompareIC (Node *node, Token::Value token, bool pure)
 
void ReplaceWithStubCall (Node *node, Callable c, CallDescriptor::Flags flags)
 
void ReplaceWithBuiltinCall (Node *node, Builtins::JavaScript id, int args)
 
void ReplaceWithRuntimeCall (Node *node, Runtime::FunctionId f, int args=-1)
 
Zonezone () const
 
Isolateisolate () const
 
JSGraphjsgraph () const
 
Graphgraph () const
 
Linkagelinkage () const
 
CompilationInfoinfo () const
 
CommonOperatorBuilder * common () const
 
MachineOperatorBuilder * machine () const
 

Private Attributes

CompilationInfoinfo_
 
JSGraphjsgraph_
 
Linkagelinkage_
 
SetOncePointer< Node > centrystub_constant_
 

Additional Inherited Members

- Static Public Member Functions inherited from v8::internal::compiler::Reducer
static Reduction NoChange ()
 
static Reduction Replace (Node *node)
 
static Reduction Changed (Node *node)
 

Detailed Description

Definition at line 27 of file js-generic-lowering.h.

Constructor & Destructor Documentation

◆ JSGenericLowering()

v8::internal::compiler::JSGenericLowering::JSGenericLowering ( CompilationInfo info,
JSGraph graph 
)

◆ ~JSGenericLowering()

virtual v8::internal::compiler::JSGenericLowering::~JSGenericLowering ( )
inlinevirtual

Definition at line 30 of file js-generic-lowering.h.

30 {}

Member Function Documentation

◆ CodeConstant()

Node * v8::internal::compiler::JSGenericLowering::CodeConstant ( Handle< Code code)
protected

Definition at line 45 of file js-generic-lowering.cc.

45  {
46  return jsgraph()->HeapConstant(code);
47 }
Node * HeapConstant(Unique< Object > value)
Definition: js-graph.cc:96

References v8::internal::compiler::JSGraph::HeapConstant(), and jsgraph().

Referenced by ReplaceWithBuiltinCall(), ReplaceWithCompareIC(), ReplaceWithRuntimeCall(), and ReplaceWithStubCall().

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

◆ common()

CommonOperatorBuilder* v8::internal::compiler::JSGenericLowering::common ( ) const
inlineprotected

Definition at line 63 of file js-generic-lowering.h.

63 { return jsgraph()->common(); }
CommonOperatorBuilder * common()
Definition: js-graph.h:87

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

Referenced by ReplaceWithBuiltinCall(), ReplaceWithCompareIC(), ReplaceWithRuntimeCall(), and ReplaceWithStubCall().

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

◆ ExternalConstant()

Node * v8::internal::compiler::JSGenericLowering::ExternalConstant ( ExternalReference  ref)
protected

Definition at line 55 of file js-generic-lowering.cc.

55  {
56  return jsgraph()->ExternalConstant(ref);
57 }
Node * ExternalConstant(ExternalReference ref)
Definition: js-graph.cc:183

References v8::internal::compiler::JSGraph::ExternalConstant(), and jsgraph().

Referenced by ReplaceWithRuntimeCall().

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

◆ FunctionConstant()

Node * v8::internal::compiler::JSGenericLowering::FunctionConstant ( Handle< JSFunction function)
protected

Definition at line 50 of file js-generic-lowering.cc.

50  {
51  return jsgraph()->HeapConstant(function);
52 }

References v8::internal::compiler::JSGraph::HeapConstant(), and jsgraph().

Referenced by ReplaceWithBuiltinCall().

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

◆ graph()

Graph* v8::internal::compiler::JSGenericLowering::graph ( ) const
inlineprotected

Definition at line 60 of file js-generic-lowering.h.

60 { return jsgraph()->graph(); }

References v8::internal::compiler::JSGraph::graph(), and jsgraph().

Referenced by ReplaceWithCompareIC(), and zone().

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

◆ info()

CompilationInfo* v8::internal::compiler::JSGenericLowering::info ( ) const
inlineprotected

Definition at line 62 of file js-generic-lowering.h.

62 { return info_; }

References info_.

Referenced by ReplaceWithBuiltinCall().

+ Here is the caller graph for this function:

◆ Int32Constant()

Node * v8::internal::compiler::JSGenericLowering::Int32Constant ( int  immediate)
protected

Definition at line 40 of file js-generic-lowering.cc.

40  {
41  return jsgraph()->Int32Constant(immediate);
42 }
Node * Int32Constant(int32_t value)
Definition: js-graph.cc:150

References v8::internal::compiler::JSGraph::Int32Constant(), and jsgraph().

Referenced by ReplaceWithRuntimeCall().

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

◆ isolate()

Isolate* v8::internal::compiler::JSGenericLowering::isolate ( ) const
inlineprotected

Definition at line 58 of file js-generic-lowering.h.

58 { return zone()->isolate(); }
Isolate * isolate() const
Definition: zone.h:68

References v8::internal::Zone::isolate(), and zone().

Referenced by ReplaceWithBuiltinCall(), ReplaceWithCompareIC(), and ReplaceWithRuntimeCall().

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

◆ jsgraph()

JSGraph* v8::internal::compiler::JSGenericLowering::jsgraph ( ) const
inlineprotected

Definition at line 59 of file js-generic-lowering.h.

59 { return jsgraph_; }

References jsgraph_.

Referenced by CodeConstant(), common(), ExternalConstant(), FunctionConstant(), graph(), Int32Constant(), machine(), and SmiConstant().

+ Here is the caller graph for this function:

◆ linkage()

Linkage* v8::internal::compiler::JSGenericLowering::linkage ( ) const
inlineprotected

Definition at line 61 of file js-generic-lowering.h.

61 { return linkage_; }

References linkage_.

Referenced by ReplaceWithBuiltinCall(), ReplaceWithCompareIC(), ReplaceWithRuntimeCall(), and ReplaceWithStubCall().

+ Here is the caller graph for this function:

◆ machine()

MachineOperatorBuilder* v8::internal::compiler::JSGenericLowering::machine ( ) const
inlineprotected

Definition at line 64 of file js-generic-lowering.h.

64 { return jsgraph()->machine(); }
MachineOperatorBuilder * machine()
Definition: js-graph.h:88

References jsgraph(), and v8::internal::compiler::JSGraph::machine().

+ Here is the call graph for this function:

◆ PatchInsertInput()

void v8::internal::compiler::JSGenericLowering::PatchInsertInput ( Node *  node,
int  index,
Node *  input 
)
protected

Definition at line 30 of file js-generic-lowering.cc.

30  {
31  node->InsertInput(zone(), index, input);
32 }

References zone().

Referenced by ReplaceWithBuiltinCall(), ReplaceWithRuntimeCall(), and ReplaceWithStubCall().

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

◆ PatchOperator()

void v8::internal::compiler::JSGenericLowering::PatchOperator ( Node *  node,
const Operator new_op 
)
protected

Definition at line 25 of file js-generic-lowering.cc.

25  {
26  node->set_op(op);
27 }

Referenced by ReplaceWithBuiltinCall(), ReplaceWithRuntimeCall(), and ReplaceWithStubCall().

+ Here is the caller graph for this function:

◆ Reduce()

Reduction v8::internal::compiler::JSGenericLowering::Reduce ( Node *  node)
virtual

Implements v8::internal::compiler::Reducer.

Definition at line 60 of file js-generic-lowering.cc.

60  {
61  switch (node->opcode()) {
62 #define DECLARE_CASE(x) \
63  case IrOpcode::k##x: \
64  Lower##x(node); \
65  break;
66  DECLARE_CASE(Branch)
68 #undef DECLARE_CASE
69  default:
70  // Nothing to see.
71  return NoChange();
72  }
73  return Changed(node);
74 }
static Reduction Changed(Node *node)
Definition: graph-reducer.h:48
#define DECLARE_CASE(x)
#define JS_OP_LIST(V)
Definition: opcodes.h:125

References v8::internal::compiler::Reducer::Changed(), DECLARE_CASE, JS_OP_LIST, and v8::internal::compiler::Reducer::NoChange().

+ Here is the call graph for this function:

◆ ReplaceWithBuiltinCall()

void v8::internal::compiler::JSGenericLowering::ReplaceWithBuiltinCall ( Node *  node,
Builtins::JavaScript  id,
int  args 
)
protected

Definition at line 196 of file js-generic-lowering.cc.

198  {
199  Callable callable =
200  CodeFactory::CallFunction(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS);
201  CallDescriptor* desc =
202  linkage()->GetStubCallDescriptor(callable.descriptor(), nargs);
203  // TODO(mstarzinger): Accessing the builtins object this way prevents sharing
204  // of code across native contexts. Fix this by loading from given context.
205  Handle<JSFunction> function(
206  JSFunction::cast(info()->context()->builtins()->javascript_builtin(id)));
207  Node* stub_code = CodeConstant(callable.code());
208  Node* function_node = FunctionConstant(function);
209  PatchInsertInput(node, 0, stub_code);
210  PatchInsertInput(node, 1, function_node);
211  PatchOperator(node, common()->Call(desc));
212 }
Node * FunctionConstant(Handle< JSFunction > function)
void PatchOperator(Node *node, const Operator *new_op)
CommonOperatorBuilder * common() const
void PatchInsertInput(Node *node, int index, Node *input)
CallDescriptor * GetStubCallDescriptor(CallInterfaceDescriptor descriptor, int stack_parameter_count=0, CallDescriptor::Flags flags=CallDescriptor::kNoFlags)
Definition: linkage.cc:103
@ NO_CALL_FUNCTION_FLAGS
Definition: globals.h:469

References CodeConstant(), common(), FunctionConstant(), v8::internal::compiler::Linkage::GetStubCallDescriptor(), info(), isolate(), linkage(), v8::internal::NO_CALL_FUNCTION_FLAGS, PatchInsertInput(), and PatchOperator().

+ Here is the call graph for this function:

◆ ReplaceWithCompareIC()

void v8::internal::compiler::JSGenericLowering::ReplaceWithCompareIC ( Node *  node,
Token::Value  token,
bool  pure 
)
protected

Definition at line 143 of file js-generic-lowering.cc.

144  {
145  Callable callable = CodeFactory::CompareIC(isolate(), token);
146  bool has_frame_state = OperatorProperties::HasFrameStateInput(node->op());
147  CallDescriptor* desc_compare = linkage()->GetStubCallDescriptor(
148  callable.descriptor(), 0,
149  CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node));
150  NodeVector inputs(zone());
151  inputs.reserve(node->InputCount() + 1);
152  inputs.push_back(CodeConstant(callable.code()));
153  inputs.push_back(NodeProperties::GetValueInput(node, 0));
154  inputs.push_back(NodeProperties::GetValueInput(node, 1));
155  inputs.push_back(NodeProperties::GetContextInput(node));
156  if (pure) {
157  // A pure (strict) comparison doesn't have an effect, control or frame
158  // state. But for the graph, we need to add control and effect inputs.
159  DCHECK(!has_frame_state);
160  inputs.push_back(graph()->start());
161  inputs.push_back(graph()->start());
162  } else {
163  DCHECK(has_frame_state == FLAG_turbo_deoptimization);
164  if (FLAG_turbo_deoptimization) {
165  inputs.push_back(NodeProperties::GetFrameStateInput(node));
166  }
167  inputs.push_back(NodeProperties::GetEffectInput(node));
168  inputs.push_back(NodeProperties::GetControlInput(node));
169  }
170  Node* compare =
171  graph()->NewNode(common()->Call(desc_compare),
172  static_cast<int>(inputs.size()), &inputs.front());
173 
174  node->ReplaceInput(0, compare);
175  node->ReplaceInput(1, SmiConstant(token));
176 
177  if (has_frame_state) {
178  // Remove the frame state from inputs.
179  node->RemoveInput(NodeProperties::FirstFrameStateIndex(node));
180  }
181 
182  ReplaceWithRuntimeCall(node, Runtime::kBooleanize);
183 }
Node * NewNode(const Operator *op, int input_count, Node **inputs)
Definition: graph.cc:24
void ReplaceWithRuntimeCall(Node *node, Runtime::FunctionId f, int args=-1)
static Node * GetContextInput(Node *node)
static Node * GetValueInput(Node *node, int index)
static Node * GetFrameStateInput(Node *node)
static Node * GetEffectInput(Node *node, int index=0)
static Node * GetControlInput(Node *node, int index=0)
static bool HasFrameStateInput(const Operator *op)
#define DCHECK(condition)
Definition: logging.h:205
ZoneVector< Node * > NodeVector
Definition: node.h:72
static CallDescriptor::Flags FlagsForNode(Node *node)

References CodeConstant(), common(), DCHECK, v8::internal::compiler::NodeProperties::FirstFrameStateIndex(), v8::internal::compiler::FlagsForNode(), v8::internal::compiler::NodeProperties::GetContextInput(), v8::internal::compiler::NodeProperties::GetControlInput(), v8::internal::compiler::NodeProperties::GetEffectInput(), v8::internal::compiler::NodeProperties::GetFrameStateInput(), v8::internal::compiler::Linkage::GetStubCallDescriptor(), v8::internal::compiler::NodeProperties::GetValueInput(), graph(), v8::internal::compiler::OperatorProperties::HasFrameStateInput(), isolate(), linkage(), v8::internal::compiler::Graph::NewNode(), ReplaceWithRuntimeCall(), SmiConstant(), and zone().

+ Here is the call graph for this function:

◆ ReplaceWithRuntimeCall()

void v8::internal::compiler::JSGenericLowering::ReplaceWithRuntimeCall ( Node *  node,
Runtime::FunctionId  f,
int  args = -1 
)
protected

Definition at line 215 of file js-generic-lowering.cc.

217  {
218  Operator::Properties properties = node->op()->properties();
219  const Runtime::Function* fun = Runtime::FunctionForId(f);
220  int nargs = (nargs_override < 0) ? fun->nargs : nargs_override;
221  CallDescriptor* desc =
222  linkage()->GetRuntimeCallDescriptor(f, nargs, properties);
223  Node* ref = ExternalConstant(ExternalReference(f, isolate()));
224  Node* arity = Int32Constant(nargs);
225  if (!centrystub_constant_.is_set()) {
226  centrystub_constant_.set(CodeConstant(CEntryStub(isolate(), 1).GetCode()));
227  }
229  PatchInsertInput(node, nargs + 1, ref);
230  PatchInsertInput(node, nargs + 2, arity);
231  PatchOperator(node, common()->Call(desc));
232 }
static const Function * FunctionForId(FunctionId id)
Definition: runtime.cc:9312
void set(T *value)
Definition: utils.h:417
Node * ExternalConstant(ExternalReference ref)
CallDescriptor * GetRuntimeCallDescriptor(Runtime::FunctionId function, int parameter_count, Operator::Properties properties)
Definition: linkage.cc:95
base::Flags< Property, uint8_t > Properties
Definition: operator.h:48

References centrystub_constant_, CodeConstant(), common(), ExternalConstant(), v8::internal::Runtime::FunctionForId(), v8::internal::SetOncePointer< T >::get(), v8::internal::compiler::Linkage::GetRuntimeCallDescriptor(), Int32Constant(), v8::internal::SetOncePointer< T >::is_set(), isolate(), linkage(), v8::internal::Runtime::Function::nargs, PatchInsertInput(), PatchOperator(), and v8::internal::SetOncePointer< T >::set().

Referenced by ReplaceWithCompareIC().

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

◆ ReplaceWithStubCall()

void v8::internal::compiler::JSGenericLowering::ReplaceWithStubCall ( Node *  node,
Callable  c,
CallDescriptor::Flags  flags 
)
protected

Definition at line 186 of file js-generic-lowering.cc.

187  {
188  CallDescriptor* desc = linkage()->GetStubCallDescriptor(
189  callable.descriptor(), 0, flags | FlagsForNode(node));
190  Node* stub_code = CodeConstant(callable.code());
191  PatchInsertInput(node, 0, stub_code);
192  PatchOperator(node, common()->Call(desc));
193 }

References CodeConstant(), common(), v8::internal::anonymous_namespace{flags.cc}::flags, v8::internal::compiler::FlagsForNode(), v8::internal::compiler::Linkage::GetStubCallDescriptor(), linkage(), PatchInsertInput(), and PatchOperator().

+ Here is the call graph for this function:

◆ SmiConstant()

Node * v8::internal::compiler::JSGenericLowering::SmiConstant ( int  immediate)
protected

Definition at line 35 of file js-generic-lowering.cc.

35  {
36  return jsgraph()->SmiConstant(immediate);
37 }
Node * SmiConstant(int32_t immediate)
Definition: js-graph.h:81

References jsgraph(), and v8::internal::compiler::JSGraph::SmiConstant().

Referenced by ReplaceWithCompareIC().

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

◆ zone()

Zone* v8::internal::compiler::JSGenericLowering::zone ( ) const
inlineprotected

Definition at line 57 of file js-generic-lowering.h.

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

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

Referenced by isolate(), PatchInsertInput(), and ReplaceWithCompareIC().

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

Member Data Documentation

◆ centrystub_constant_

SetOncePointer<Node> v8::internal::compiler::JSGenericLowering::centrystub_constant_
private

Definition at line 70 of file js-generic-lowering.h.

Referenced by ReplaceWithRuntimeCall().

◆ info_

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

Definition at line 67 of file js-generic-lowering.h.

Referenced by info().

◆ jsgraph_

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

Definition at line 68 of file js-generic-lowering.h.

Referenced by jsgraph().

◆ linkage_

Linkage* v8::internal::compiler::JSGenericLowering::linkage_
private

Definition at line 69 of file js-generic-lowering.h.

Referenced by linkage().


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