v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-type-hint-lowering.h
Go to the documentation of this file.
1// Copyright 2017 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_COMPILER_JS_TYPE_HINT_LOWERING_H_
6#define V8_COMPILER_JS_TYPE_HINT_LOWERING_H_
7
8#include "src/base/flags.h"
11
12namespace v8 {
13namespace internal {
14
15// Forward declarations.
16class FeedbackSlot;
17
18namespace compiler {
19
20// Forward declarations.
21class JSGraph;
22class Node;
23class Operator;
24
25// The type-hint lowering consumes feedback about high-level operations in order
26// to potentially emit nodes using speculative simplified operators in favor of
27// the generic JavaScript operators.
28//
29// This lowering is implemented as an early reduction and can be applied before
30// nodes are placed into the initial graph. It provides the ability to shortcut
31// the JavaScript-level operators and directly emit simplified-level operators
32// even during initial graph building. This is the reason this lowering doesn't
33// follow the interface of the reducer framework used after graph construction.
34// The result of the lowering is encapsulated in
35// {the JSTypeHintLowering::LoweringResult} class.
37 public:
38 // Flags that control the mode of operation.
39 enum Flag { kNoFlags = 0u, kBailoutOnUninitialized = 1u << 1 };
41
46
47 // {LoweringResult} describes the result of lowering. The following outcomes
48 // are possible:
49 //
50 // - operation was lowered to a side-effect-free operation, the resulting
51 // value, effect and control can be obtained by the {value}, {effect} and
52 // {control} methods.
53 //
54 // - operation was lowered to a graph exit (deoptimization). The caller
55 // should connect {effect} and {control} nodes to the end.
56 //
57 // - no lowering happened. The caller needs to create the generic version
58 // of the operation.
60 public:
61 Node* value() const { return value_; }
62 Node* effect() const { return effect_; }
63 Node* control() const { return control_; }
64
65 bool Changed() const { return kind_ != LoweringResultKind::kNoChange; }
66 bool IsExit() const { return kind_ == LoweringResultKind::kExit; }
70
71 static LoweringResult SideEffectFree(Node* value, Node* effect,
72 Node* control) {
73 DCHECK_NOT_NULL(effect);
75 DCHECK(value->op()->HasProperty(Operator::kNoThrow));
77 control);
78 }
79
81 return LoweringResult(LoweringResultKind::kNoChange, nullptr, nullptr,
82 nullptr);
83 }
84
86 return LoweringResult(LoweringResultKind::kExit, nullptr, nullptr,
87 control);
88 }
89
90 private:
92
95 : kind_(kind), value_(value), effect_(effect), control_(control) {}
96
101 };
102
103 // Potential reduction of unary operations (e.g. negation).
105 Node* effect, Node* control,
106 FeedbackSlot slot) const;
107
108 // Potential reduction of binary (arithmetic, logical, shift and relational
109 // comparison) operations.
111 Node* right, Node* effect, Node* control,
112 FeedbackSlot slot) const;
113
114 // Potential reduction to for..in operations
116 Node* cache_type, Node* index,
117 Node* effect, Node* control,
118 FeedbackSlot slot) const;
120 Node* control,
121 FeedbackSlot slot) const;
122
123 // Potential reduction to ToNumber operations
125 Node* control,
126 FeedbackSlot slot) const;
127
128 // Potential reduction of call operations.
130 int arg_count, Node* effect, Node* control,
131 FeedbackSlot slot) const;
132
133 // Potential reduction of construct operations.
135 int arg_count, Node* effect,
136 Node* control,
137 FeedbackSlot slot) const;
138
139 // Potential reduction of property access and call operations.
141 Node* effect, Node* control,
142 FeedbackSlot load_slot,
143 FeedbackSlot call_slot) const;
144
145 // Potential reduction of property access operations.
147 Node* control,
148 FeedbackSlot slot) const;
150 Node* key, Node* effect,
151 Node* control,
152 FeedbackSlot slot) const;
154 Node* val, Node* effect,
155 Node* control,
156 FeedbackSlot slot) const;
158 Node* key, Node* val, Node* effect,
159 Node* control,
160 FeedbackSlot slot) const;
161
162 private:
164
168 Node* control,
169 DeoptimizeReason reson) const;
170
171 JSHeapBroker* broker() const { return broker_; }
172 JSGraph* jsgraph() const { return jsgraph_; }
173 Isolate* isolate() const;
174 Flags flags() const { return flags_; }
176
181};
182
183} // namespace compiler
184} // namespace internal
185} // namespace v8
186
187#endif // V8_COMPILER_JS_TYPE_HINT_LOWERING_H_
Builtins::Kind kind
Definition builtins.cc:40
LoweringResult(LoweringResultKind kind, Node *value, Node *effect, Node *control)
static LoweringResult SideEffectFree(Node *value, Node *effect, Node *control)
CompareOperationHint GetCompareOperationHint(FeedbackSlot slot) const
BinaryOperationHint GetBinaryOperationHint(FeedbackSlot slot) const
LoweringResult ReduceLoadNamedOperation(const Operator *op, Node *effect, Node *control, FeedbackSlot slot) const
LoweringResult ReduceConstructOperation(const Operator *op, Node *const *args, int arg_count, Node *effect, Node *control, FeedbackSlot slot) const
Node * BuildDeoptIfFeedbackIsInsufficient(FeedbackSlot slot, Node *effect, Node *control, DeoptimizeReason reson) const
LoweringResult ReduceForInPrepareOperation(Node *enumerator, Node *effect, Node *control, FeedbackSlot slot) const
LoweringResult ReduceLoadKeyedOperation(const Operator *op, Node *obj, Node *key, Node *effect, Node *control, FeedbackSlot slot) const
LoweringResult ReduceForInNextOperation(Node *receiver, Node *cache_array, Node *cache_type, Node *index, Node *effect, Node *control, FeedbackSlot slot) const
JSTypeHintLowering(JSHeapBroker *broker, JSGraph *jsgraph, FeedbackVectorRef feedback_vector, Flags flags)
JSTypeHintLowering & operator=(const JSTypeHintLowering &)=delete
LoweringResult ReduceToNumberOperation(Node *value, Node *effect, Node *control, FeedbackSlot slot) const
JSTypeHintLowering(const JSTypeHintLowering &)=delete
LoweringResult ReduceBinaryOperation(const Operator *op, Node *left, Node *right, Node *effect, Node *control, FeedbackSlot slot) const
LoweringResult ReduceGetIteratorOperation(const Operator *op, Node *obj, Node *effect, Node *control, FeedbackSlot load_slot, FeedbackSlot call_slot) const
LoweringResult ReduceUnaryOperation(const Operator *op, Node *operand, Node *effect, Node *control, FeedbackSlot slot) const
LoweringResult ReduceStoreKeyedOperation(const Operator *op, Node *obj, Node *key, Node *val, Node *effect, Node *control, FeedbackSlot slot) const
LoweringResult ReduceStoreNamedOperation(const Operator *op, Node *obj, Node *val, Node *effect, Node *control, FeedbackSlot slot) const
LoweringResult ReduceCallOperation(const Operator *op, Node *const *args, int arg_count, Node *effect, Node *control, FeedbackSlot slot) const
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
TNode< Object > receiver
#define DCHECK_NOT_NULL(val)
Definition logging.h:492
#define DCHECK(condition)
Definition logging.h:482