v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
common-operator-reducer.h
Go to the documentation of this file.
1// Copyright 2014 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_COMMON_OPERATOR_REDUCER_H_
6#define V8_COMPILER_COMMON_OPERATOR_REDUCER_H_
7
11
12namespace v8 {
13namespace internal {
14namespace compiler {
15
16// Forward declarations.
17class CommonOperatorBuilder;
18class TFGraph;
19class MachineOperatorBuilder;
20class Operator;
21
22
23// Performs strength reduction on nodes that have common operators.
25 : public NON_EXPORTED_BASE(AdvancedReducer) {
26 public:
27 CommonOperatorReducer(Editor* editor, TFGraph* graph, JSHeapBroker* broker,
29 MachineOperatorBuilder* machine, Zone* temp_zone,
30 BranchSemantics default_branch_semantics);
31 ~CommonOperatorReducer() final = default;
32
33 const char* reducer_name() const override { return "CommonOperatorReducer"; }
34
35 Reduction Reduce(Node* node) final;
36
37 private:
38 Reduction ReduceBranch(Node* node);
39 Reduction ReduceDeoptimizeConditional(Node* node);
40 Reduction ReduceMerge(Node* node);
41 Reduction ReduceEffectPhi(Node* node);
42 Reduction ReducePhi(Node* node);
43 Reduction ReduceReturn(Node* node);
44 Reduction ReduceSelect(Node* node);
45 Reduction ReduceSwitch(Node* node);
46 Reduction ReduceStaticAssert(Node* node);
47 Reduction ReduceTrapConditional(Node* node);
48
49 Reduction Change(Node* node, Operator const* op, Node* a);
50 Reduction Change(Node* node, Operator const* op, Node* a, Node* b);
51
52 // Helper to determine if conditions are true or false.
53 Decision DecideCondition(Node* const cond, BranchSemantics branch_semantics);
55 BranchSemantics bs = BranchParametersOf(branch->op()).semantics();
56 if (bs != BranchSemantics::kUnspecified) return bs;
57 return default_branch_semantics_;
58 }
59
60 TFGraph* graph() const { return graph_; }
61 JSHeapBroker* broker() const { return broker_; }
62 CommonOperatorBuilder* common() const { return common_; }
63 MachineOperatorBuilder* machine() const { return machine_; }
64 Node* dead() const { return dead_; }
65
70 Node* const dead_;
73};
74
75} // namespace compiler
76} // namespace internal
77} // namespace v8
78
79#endif // V8_COMPILER_COMMON_OPERATOR_REDUCER_H_
BranchSemantics BranchSemanticsOf(const Node *branch)
const Operator * op() const
Definition node.h:50
JSHeapBroker *const broker_
JSHeapBroker * broker
const BranchParameters & BranchParametersOf(const Operator *const op)
#define NON_EXPORTED_BASE(code)
#define V8_EXPORT_PRIVATE
Definition macros.h:460
TFGraph * graph_