OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_JS_TYPED_LOWERING_H_ | 5 #ifndef V8_COMPILER_JS_TYPED_LOWERING_H_ |
6 #define V8_COMPILER_JS_TYPED_LOWERING_H_ | 6 #define V8_COMPILER_JS_TYPED_LOWERING_H_ |
7 | 7 |
8 #include "src/compiler/graph-reducer.h" | 8 #include "src/compiler/graph-reducer.h" |
9 #include "src/compiler/simplified-operator.h" | 9 #include "src/compiler/simplified-operator.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 namespace compiler { | 13 namespace compiler { |
14 | 14 |
15 // Forward declarations. | 15 // Forward declarations. |
16 class CommonOperatorBuilder; | 16 class CommonOperatorBuilder; |
17 class JSGraph; | 17 class JSGraph; |
18 class JSOperatorBuilder; | 18 class JSOperatorBuilder; |
19 class MachineOperatorBuilder; | 19 class MachineOperatorBuilder; |
20 | 20 |
21 | 21 |
22 // Lowers JS-level operators to simplified operators based on types. | 22 // Lowers JS-level operators to simplified operators based on types. |
23 class JSTypedLowering FINAL : public Reducer { | 23 class JSTypedLowering FINAL : public Reducer { |
24 public: | 24 public: |
25 explicit JSTypedLowering(JSGraph* jsgraph); | 25 JSTypedLowering(JSGraph* jsgraph, Zone* zone); |
26 ~JSTypedLowering() FINAL {} | 26 ~JSTypedLowering() FINAL {} |
27 | 27 |
28 Reduction Reduce(Node* node) FINAL; | 28 Reduction Reduce(Node* node) FINAL; |
29 | 29 |
30 private: | 30 private: |
31 friend class JSBinopReduction; | 31 friend class JSBinopReduction; |
32 | 32 |
33 Reduction ReplaceEagerly(Node* old, Node* node); | 33 Reduction ReplaceEagerly(Node* old, Node* node); |
34 Reduction ReduceJSAdd(Node* node); | 34 Reduction ReduceJSAdd(Node* node); |
35 Reduction ReduceJSBitwiseOr(Node* node); | 35 Reduction ReduceJSBitwiseOr(Node* node); |
36 Reduction ReduceJSMultiply(Node* node); | 36 Reduction ReduceJSMultiply(Node* node); |
37 Reduction ReduceJSComparison(Node* node); | 37 Reduction ReduceJSComparison(Node* node); |
38 Reduction ReduceJSLoadProperty(Node* node); | 38 Reduction ReduceJSLoadProperty(Node* node); |
39 Reduction ReduceJSStoreProperty(Node* node); | 39 Reduction ReduceJSStoreProperty(Node* node); |
40 Reduction ReduceJSLoadContext(Node* node); | 40 Reduction ReduceJSLoadContext(Node* node); |
41 Reduction ReduceJSStoreContext(Node* node); | 41 Reduction ReduceJSStoreContext(Node* node); |
42 Reduction ReduceJSEqual(Node* node, bool invert); | 42 Reduction ReduceJSEqual(Node* node, bool invert); |
43 Reduction ReduceJSStrictEqual(Node* node, bool invert); | 43 Reduction ReduceJSStrictEqual(Node* node, bool invert); |
44 Reduction ReduceJSToBooleanInput(Node* input); | 44 Reduction ReduceJSToBooleanInput(Node* input); |
45 Reduction ReduceJSToBoolean(Node* node); | 45 Reduction ReduceJSToBoolean(Node* node); |
46 Reduction ReduceJSToNumberInput(Node* input); | 46 Reduction ReduceJSToNumberInput(Node* input); |
47 Reduction ReduceJSToNumber(Node* node); | 47 Reduction ReduceJSToNumber(Node* node); |
48 Reduction ReduceJSToStringInput(Node* input); | 48 Reduction ReduceJSToStringInput(Node* input); |
49 Reduction ReduceJSToString(Node* node); | 49 Reduction ReduceJSToString(Node* node); |
50 Reduction ReduceNumberBinop(Node* node, const Operator* numberOp); | 50 Reduction ReduceNumberBinop(Node* node, const Operator* numberOp); |
51 Reduction ReduceInt32Binop(Node* node, const Operator* intOp); | 51 Reduction ReduceInt32Binop(Node* node, const Operator* intOp); |
52 Reduction ReduceUI32Shift(Node* node, Signedness left_signedness, | 52 Reduction ReduceUI32Shift(Node* node, Signedness left_signedness, |
53 const Operator* shift_op); | 53 const Operator* shift_op); |
54 | 54 |
| 55 Node* ConvertToBoolean(Node* input); |
| 56 Node* ConvertToNumber(Node* input); |
| 57 template <IrOpcode::Value> |
| 58 Node* FindConversion(Node* input); |
| 59 void InsertConversion(Node* conversion); |
| 60 |
55 Node* Word32Shl(Node* const lhs, int32_t const rhs); | 61 Node* Word32Shl(Node* const lhs, int32_t const rhs); |
56 | 62 |
57 Factory* factory() const; | 63 Factory* factory() const; |
58 Graph* graph() const; | 64 Graph* graph() const; |
59 JSGraph* jsgraph() const { return jsgraph_; } | 65 JSGraph* jsgraph() const { return jsgraph_; } |
60 JSOperatorBuilder* javascript() const; | 66 JSOperatorBuilder* javascript() const; |
61 CommonOperatorBuilder* common() const; | 67 CommonOperatorBuilder* common() const; |
62 SimplifiedOperatorBuilder* simplified() { return &simplified_; } | 68 SimplifiedOperatorBuilder* simplified() { return &simplified_; } |
63 MachineOperatorBuilder* machine() const; | 69 MachineOperatorBuilder* machine() const; |
64 | 70 |
65 JSGraph* jsgraph_; | 71 JSGraph* jsgraph_; |
66 SimplifiedOperatorBuilder simplified_; | 72 SimplifiedOperatorBuilder simplified_; |
| 73 ZoneVector<Node*> conversions_; // Cache inserted JSToXXX() conversions. |
67 Type* zero_range_; | 74 Type* zero_range_; |
68 Type* one_range_; | 75 Type* one_range_; |
69 Type* zero_thirtyone_range_; | 76 Type* zero_thirtyone_range_; |
70 Type* shifted_int32_ranges_[4]; | 77 Type* shifted_int32_ranges_[4]; |
71 }; | 78 }; |
72 | 79 |
73 } // namespace compiler | 80 } // namespace compiler |
74 } // namespace internal | 81 } // namespace internal |
75 } // namespace v8 | 82 } // namespace v8 |
76 | 83 |
77 #endif // V8_COMPILER_JS_TYPED_LOWERING_H_ | 84 #endif // V8_COMPILER_JS_TYPED_LOWERING_H_ |
OLD | NEW |