1 // Copyright 2016 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_TYPED_OPTIMIZATION_H_ 6 #define V8_COMPILER_TYPED_OPTIMIZATION_H_ 7 8 #include "src/base/compiler-specific.h" 9 #include "src/common/globals.h" 10 #include "src/compiler/graph-reducer.h" 11 12 namespace v8 { 13 namespace internal { 14 15 // Forward declarations. 16 class Factory; 17 class Isolate; 18 19 namespace compiler { 20 21 // Forward declarations. 22 class CompilationDependencies; 23 class JSGraph; 24 class SimplifiedOperatorBuilder; 25 class TypeCache; 26 27 class V8_EXPORT_PRIVATE TypedOptimization final NON_EXPORTED_BASE(AdvancedReducer)28 : public NON_EXPORTED_BASE(AdvancedReducer) { 29 public: 30 TypedOptimization(Editor* editor, CompilationDependencies* dependencies, 31 JSGraph* jsgraph, JSHeapBroker* broker); 32 ~TypedOptimization() override; 33 TypedOptimization(const TypedOptimization&) = delete; 34 TypedOptimization& operator=(const TypedOptimization&) = delete; 35 36 const char* reducer_name() const override { return "TypedOptimization"; } 37 38 Reduction Reduce(Node* node) final; 39 40 private: 41 Reduction ReduceConvertReceiver(Node* node); 42 Reduction ReduceMaybeGrowFastElements(Node* node); 43 Reduction ReduceCheckBounds(Node* node); 44 Reduction ReduceCheckHeapObject(Node* node); 45 Reduction ReduceCheckMaps(Node* node); 46 Reduction ReduceCheckNumber(Node* node); 47 Reduction ReduceCheckString(Node* node); 48 Reduction ReduceCheckEqualsInternalizedString(Node* node); 49 Reduction ReduceCheckEqualsSymbol(Node* node); 50 Reduction ReduceLoadField(Node* node); 51 Reduction ReduceNumberFloor(Node* node); 52 Reduction ReduceNumberRoundop(Node* node); 53 Reduction ReduceNumberSilenceNaN(Node* node); 54 Reduction ReduceNumberToUint8Clamped(Node* node); 55 Reduction ReducePhi(Node* node); 56 Reduction ReduceReferenceEqual(Node* node); 57 Reduction ReduceStringComparison(Node* node); 58 Reduction ReduceStringLength(Node* node); 59 Reduction ReduceSameValue(Node* node); 60 Reduction ReduceSelect(Node* node); 61 Reduction ReduceSpeculativeToNumber(Node* node); 62 Reduction ReduceCheckNotTaggedHole(Node* node); 63 Reduction ReduceTypeOf(Node* node); 64 Reduction ReduceToBoolean(Node* node); 65 Reduction ReduceSpeculativeNumberAdd(Node* node); 66 Reduction ReduceSpeculativeNumberMultiply(Node* node); 67 Reduction ReduceSpeculativeNumberPow(Node* node); 68 Reduction ReduceSpeculativeNumberBinop(Node* node); 69 Reduction ReduceSpeculativeNumberComparison(Node* node); 70 71 Reduction TryReduceStringComparisonOfStringFromSingleCharCode( 72 Node* comparison, Node* from_char_code, Type constant_type, 73 bool inverted); 74 Reduction TryReduceStringComparisonOfStringFromSingleCharCodeToConstant( 75 Node* comparison, const StringRef& string, bool inverted); 76 const Operator* NumberComparisonFor(const Operator* op); 77 78 Node* ConvertPlainPrimitiveToNumber(Node* node); 79 Reduction ReduceJSToNumberInput(Node* input); 80 81 SimplifiedOperatorBuilder* simplified() const; 82 Factory* factory() const; 83 Graph* graph() const; 84 85 CompilationDependencies* dependencies() const { return dependencies_; } 86 JSGraph* jsgraph() const { return jsgraph_; } 87 JSHeapBroker* broker() const { return broker_; } 88 89 CompilationDependencies* const dependencies_; 90 JSGraph* const jsgraph_; 91 JSHeapBroker* broker_; 92 Type const true_type_; 93 Type const false_type_; 94 TypeCache const* type_cache_; 95 }; 96 97 } // namespace compiler 98 } // namespace internal 99 } // namespace v8 100 101 #endif // V8_COMPILER_TYPED_OPTIMIZATION_H_ 102