Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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_JS_TYPED_LOWERING_H_ |
| 6 | #define V8_COMPILER_JS_TYPED_LOWERING_H_ |
| 7 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 8 | #include "src/base/flags.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 9 | #include "src/compiler/graph-reducer.h" |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 10 | #include "src/compiler/opcodes.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 11 | |
| 12 | namespace v8 { |
| 13 | namespace internal { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 14 | |
| 15 | // Forward declarations. |
| 16 | class CompilationDependencies; |
| 17 | class Factory; |
| 18 | class TypeCache; |
| 19 | |
| 20 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 21 | namespace compiler { |
| 22 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 23 | // Forward declarations. |
| 24 | class CommonOperatorBuilder; |
| 25 | class JSGraph; |
| 26 | class JSOperatorBuilder; |
| 27 | class MachineOperatorBuilder; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 28 | class SimplifiedOperatorBuilder; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 29 | |
| 30 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 31 | // Lowers JS-level operators to simplified operators based on types. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 32 | class JSTypedLowering final : public AdvancedReducer { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 33 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 34 | // Flags that control the mode of operation. |
| 35 | enum Flag { |
| 36 | kNoFlags = 0u, |
| 37 | kDeoptimizationEnabled = 1u << 0, |
| 38 | kDisableBinaryOpReduction = 1u << 1, |
| 39 | }; |
| 40 | typedef base::Flags<Flag> Flags; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 41 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 42 | JSTypedLowering(Editor* editor, CompilationDependencies* dependencies, |
| 43 | Flags flags, JSGraph* jsgraph, Zone* zone); |
| 44 | ~JSTypedLowering() final {} |
| 45 | |
| 46 | Reduction Reduce(Node* node) final; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 47 | |
| 48 | private: |
| 49 | friend class JSBinopReduction; |
| 50 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 51 | Reduction ReduceJSAdd(Node* node); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 52 | Reduction ReduceJSModulus(Node* node); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 53 | Reduction ReduceJSBitwiseOr(Node* node); |
| 54 | Reduction ReduceJSMultiply(Node* node); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 55 | Reduction ReduceJSComparison(Node* node); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 56 | Reduction ReduceJSLoadNamed(Node* node); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 57 | Reduction ReduceJSLoadProperty(Node* node); |
| 58 | Reduction ReduceJSStoreProperty(Node* node); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 59 | Reduction ReduceJSInstanceOf(Node* node); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 60 | Reduction ReduceJSLoadContext(Node* node); |
| 61 | Reduction ReduceJSStoreContext(Node* node); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 62 | Reduction ReduceJSEqual(Node* node, bool invert); |
| 63 | Reduction ReduceJSStrictEqual(Node* node, bool invert); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 64 | Reduction ReduceJSToBoolean(Node* node); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 65 | Reduction ReduceJSToInteger(Node* node); |
| 66 | Reduction ReduceJSToLength(Node* node); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 67 | Reduction ReduceJSToNumberInput(Node* input); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 68 | Reduction ReduceJSToNumber(Node* node); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 69 | Reduction ReduceJSToStringInput(Node* input); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 70 | Reduction ReduceJSToString(Node* node); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 71 | Reduction ReduceJSToObject(Node* node); |
| 72 | Reduction ReduceJSConvertReceiver(Node* node); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 73 | Reduction ReduceJSCallConstruct(Node* node); |
| 74 | Reduction ReduceJSCallFunction(Node* node); |
| 75 | Reduction ReduceJSForInDone(Node* node); |
| 76 | Reduction ReduceJSForInNext(Node* node); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 77 | Reduction ReduceJSForInStep(Node* node); |
| 78 | Reduction ReduceSelect(Node* node); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 79 | Reduction ReduceNumberBinop(Node* node, const Operator* numberOp); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 80 | Reduction ReduceInt32Binop(Node* node, const Operator* intOp); |
| 81 | Reduction ReduceUI32Shift(Node* node, Signedness left_signedness, |
| 82 | const Operator* shift_op); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 83 | |
| 84 | Node* Word32Shl(Node* const lhs, int32_t const rhs); |
| 85 | |
| 86 | Factory* factory() const; |
| 87 | Graph* graph() const; |
| 88 | JSGraph* jsgraph() const { return jsgraph_; } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 89 | Isolate* isolate() const; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 90 | JSOperatorBuilder* javascript() const; |
| 91 | CommonOperatorBuilder* common() const; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 92 | SimplifiedOperatorBuilder* simplified() const; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 93 | MachineOperatorBuilder* machine() const; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 94 | CompilationDependencies* dependencies() const; |
| 95 | Flags flags() const { return flags_; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 96 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 97 | CompilationDependencies* dependencies_; |
| 98 | Flags flags_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 99 | JSGraph* jsgraph_; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 100 | Type* shifted_int32_ranges_[4]; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 101 | Type* const true_type_; |
| 102 | Type* const false_type_; |
| 103 | Type* const the_hole_type_; |
| 104 | TypeCache const& type_cache_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 105 | }; |
| 106 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 107 | DEFINE_OPERATORS_FOR_FLAGS(JSTypedLowering::Flags) |
| 108 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 109 | } // namespace compiler |
| 110 | } // namespace internal |
| 111 | } // namespace v8 |
| 112 | |
| 113 | #endif // V8_COMPILER_JS_TYPED_LOWERING_H_ |