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/compiler/graph-reducer.h" 10 #include "src/compiler/opcodes.h" 11 #include "src/globals.h" 12 13 namespace v8 { 14 namespace internal { 15 16 // Forward declarations. 17 class Factory; 18 19 namespace compiler { 20 21 // Forward declarations. 22 class CommonOperatorBuilder; 23 class JSGraph; 24 class JSOperatorBuilder; 25 class SimplifiedOperatorBuilder; 26 class TypeCache; 27 28 enum Signedness { kSigned, kUnsigned }; 29 30 // Lowers JS-level operators to simplified operators based on types. 31 class V8_EXPORT_PRIVATE JSTypedLowering final NON_EXPORTED_BASE(AdvancedReducer)32 : public NON_EXPORTED_BASE(AdvancedReducer) { 33 public: 34 JSTypedLowering(Editor* editor, JSGraph* jsgraph, 35 JSHeapBroker* js_heap_broker, Zone* zone); 36 ~JSTypedLowering() final {} 37 38 const char* reducer_name() const override { return "JSTypedLowering"; } 39 40 Reduction Reduce(Node* node) final; 41 42 private: 43 friend class JSBinopReduction; 44 45 Reduction ReduceJSAdd(Node* node); 46 Reduction ReduceJSBitwiseNot(Node* node); 47 Reduction ReduceJSDecrement(Node* node); 48 Reduction ReduceJSIncrement(Node* node); 49 Reduction ReduceJSNegate(Node* node); 50 Reduction ReduceJSComparison(Node* node); 51 Reduction ReduceJSLoadNamed(Node* node); 52 Reduction ReduceJSHasInPrototypeChain(Node* node); 53 Reduction ReduceJSOrdinaryHasInstance(Node* node); 54 Reduction ReduceJSLoadContext(Node* node); 55 Reduction ReduceJSStoreContext(Node* node); 56 Reduction ReduceJSLoadModule(Node* node); 57 Reduction ReduceJSStoreModule(Node* node); 58 Reduction ReduceJSEqual(Node* node); 59 Reduction ReduceJSStrictEqual(Node* node); 60 Reduction ReduceJSToInteger(Node* node); 61 Reduction ReduceJSToLength(Node* node); 62 Reduction ReduceJSToName(Node* node); 63 Reduction ReduceJSToNumberOrNumericInput(Node* input); 64 Reduction ReduceJSToNumberOrNumeric(Node* node); 65 Reduction ReduceJSToStringInput(Node* input); 66 Reduction ReduceJSToString(Node* node); 67 Reduction ReduceJSToObject(Node* node); 68 Reduction ReduceJSConstructForwardVarargs(Node* node); 69 Reduction ReduceJSConstruct(Node* node); 70 Reduction ReduceJSCallForwardVarargs(Node* node); 71 Reduction ReduceJSCall(Node* node); 72 Reduction ReduceJSForInNext(Node* node); 73 Reduction ReduceJSForInPrepare(Node* node); 74 Reduction ReduceJSLoadMessage(Node* node); 75 Reduction ReduceJSStoreMessage(Node* node); 76 Reduction ReduceJSGeneratorStore(Node* node); 77 Reduction ReduceJSGeneratorRestoreContinuation(Node* node); 78 Reduction ReduceJSGeneratorRestoreContext(Node* node); 79 Reduction ReduceJSGeneratorRestoreRegister(Node* node); 80 Reduction ReduceJSGeneratorRestoreInputOrDebugPos(Node* node); 81 Reduction ReduceNumberBinop(Node* node); 82 Reduction ReduceInt32Binop(Node* node); 83 Reduction ReduceUI32Shift(Node* node, Signedness signedness); 84 Reduction ReduceCreateConsString(Node* node); 85 Reduction ReduceSpeculativeNumberAdd(Node* node); 86 Reduction ReduceSpeculativeNumberMultiply(Node* node); 87 Reduction ReduceSpeculativeNumberBinop(Node* node); 88 Reduction ReduceSpeculativeNumberComparison(Node* node); 89 Reduction ReduceObjectIsArray(Node* node); 90 Reduction ReduceJSParseInt(Node* node); 91 92 // Helper for ReduceJSLoadModule and ReduceJSStoreModule. 93 Node* BuildGetModuleCell(Node* node); 94 95 // Helpers for ReduceJSCreateConsString. 96 Node* BuildGetStringLength(Node* value); 97 98 Factory* factory() const; 99 Graph* graph() const; 100 JSGraph* jsgraph() const { return jsgraph_; } 101 JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } 102 Isolate* isolate() const; 103 JSOperatorBuilder* javascript() const; 104 CommonOperatorBuilder* common() const; 105 SimplifiedOperatorBuilder* simplified() const; 106 107 JSGraph* jsgraph_; 108 JSHeapBroker* js_heap_broker_; 109 Type empty_string_type_; 110 Type pointer_comparable_type_; 111 TypeCache const& type_cache_; 112 }; 113 114 } // namespace compiler 115 } // namespace internal 116 } // namespace v8 117 118 #endif // V8_COMPILER_JS_TYPED_LOWERING_H_ 119