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 8 #include "src/base/compiler-specific.h" 9 #include "src/base/flags.h" 10 #include "src/compiler/graph-reducer.h" 11 #include "src/compiler/opcodes.h" 12 #include "src/globals.h" 13 14 namespace v8 { 15 namespace internal { 16 17 // Forward declarations. 18 class CompilationDependencies; 19 class Factory; 20 21 namespace compiler { 22 23 // Forward declarations. 24 class CommonOperatorBuilder; 25 class JSGraph; 26 class JSOperatorBuilder; 27 class SimplifiedOperatorBuilder; 28 class TypeCache; 29 30 // Lowers JS-level operators to simplified operators based on types. 31 class V8_EXPORT_PRIVATE JSTypedLowering final 32 : public NON_EXPORTED_BASE(AdvancedReducer) { 33 public: 34 // Flags that control the mode of operation. 35 enum Flag { 36 kNoFlags = 0u, 37 kDeoptimizationEnabled = 1u << 0, 38 }; 39 typedef base::Flags<Flag> Flags; 40 41 JSTypedLowering(Editor* editor, CompilationDependencies* dependencies, 42 Flags flags, JSGraph* jsgraph, Zone* zone); 43 ~JSTypedLowering() final {} 44 45 Reduction Reduce(Node* node) final; 46 47 private: 48 friend class JSBinopReduction; 49 50 Reduction ReduceJSAdd(Node* node); 51 Reduction ReduceJSComparison(Node* node); 52 Reduction ReduceJSLoadNamed(Node* node); 53 Reduction ReduceJSLoadProperty(Node* node); 54 Reduction ReduceJSStoreProperty(Node* node); 55 Reduction ReduceJSOrdinaryHasInstance(Node* node); 56 Reduction ReduceJSLoadContext(Node* node); 57 Reduction ReduceJSStoreContext(Node* node); 58 Reduction ReduceJSLoadModule(Node* node); 59 Reduction ReduceJSStoreModule(Node* node); 60 Reduction ReduceJSEqualTypeOf(Node* node, bool invert); 61 Reduction ReduceJSEqual(Node* node, bool invert); 62 Reduction ReduceJSStrictEqual(Node* node, bool invert); 63 Reduction ReduceJSToBoolean(Node* node); 64 Reduction ReduceJSToInteger(Node* node); 65 Reduction ReduceJSToLength(Node* node); 66 Reduction ReduceJSToName(Node* node); 67 Reduction ReduceJSToNumberInput(Node* input); 68 Reduction ReduceJSToNumber(Node* node); 69 Reduction ReduceJSToStringInput(Node* input); 70 Reduction ReduceJSToString(Node* node); 71 Reduction ReduceJSToObject(Node* node); 72 Reduction ReduceJSConvertReceiver(Node* node); 73 Reduction ReduceJSConstruct(Node* node); 74 Reduction ReduceJSCallForwardVarargs(Node* node); 75 Reduction ReduceJSCall(Node* node); 76 Reduction ReduceJSForInNext(Node* node); 77 Reduction ReduceJSLoadMessage(Node* node); 78 Reduction ReduceJSStoreMessage(Node* node); 79 Reduction ReduceJSGeneratorStore(Node* node); 80 Reduction ReduceJSGeneratorRestoreContinuation(Node* node); 81 Reduction ReduceJSGeneratorRestoreRegister(Node* node); 82 Reduction ReduceJSTypeOf(Node* node); 83 Reduction ReduceNumberBinop(Node* node); 84 Reduction ReduceInt32Binop(Node* node); 85 Reduction ReduceUI32Shift(Node* node, Signedness signedness); 86 Reduction ReduceCreateConsString(Node* node); 87 Reduction ReduceSpeculativeNumberAdd(Node* node); 88 Reduction ReduceSpeculativeNumberBinop(Node* node); 89 90 Factory* factory() const; 91 Graph* graph() const; 92 JSGraph* jsgraph() const { return jsgraph_; } 93 Isolate* isolate() const; 94 JSOperatorBuilder* javascript() const; 95 CommonOperatorBuilder* common() const; 96 SimplifiedOperatorBuilder* simplified() const; 97 CompilationDependencies* dependencies() const; 98 Flags flags() const { return flags_; } 99 100 CompilationDependencies* dependencies_; 101 Flags flags_; 102 JSGraph* jsgraph_; 103 Type* shifted_int32_ranges_[4]; 104 Type* pointer_comparable_type_; 105 TypeCache const& type_cache_; 106 }; 107 108 DEFINE_OPERATORS_FOR_FLAGS(JSTypedLowering::Flags) 109 110 } // namespace compiler 111 } // namespace internal 112 } // namespace v8 113 114 #endif // V8_COMPILER_JS_TYPED_LOWERING_H_ 115