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/compiler/graph-reducer.h" 10 #include "src/globals.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* js_heap_broker); 32 ~TypedOptimization(); 33 34 const char* reducer_name() const override { return "TypedOptimization"; } 35 36 Reduction Reduce(Node* node) final; 37 38 private: 39 Reduction ReduceConvertReceiver(Node* node); 40 Reduction ReduceCheckHeapObject(Node* node); 41 Reduction ReduceCheckMaps(Node* node); 42 Reduction ReduceCheckNumber(Node* node); 43 Reduction ReduceCheckString(Node* node); 44 Reduction ReduceCheckEqualsInternalizedString(Node* node); 45 Reduction ReduceCheckEqualsSymbol(Node* node); 46 Reduction ReduceLoadField(Node* node); 47 Reduction ReduceNumberFloor(Node* node); 48 Reduction ReduceNumberRoundop(Node* node); 49 Reduction ReduceNumberToUint8Clamped(Node* node); 50 Reduction ReducePhi(Node* node); 51 Reduction ReduceReferenceEqual(Node* node); 52 Reduction ReduceStringComparison(Node* node); 53 Reduction ReduceSameValue(Node* node); 54 Reduction ReduceSelect(Node* node); 55 Reduction ReduceSpeculativeToNumber(Node* node); 56 Reduction ReduceCheckNotTaggedHole(Node* node); 57 Reduction ReduceTypeOf(Node* node); 58 Reduction ReduceToBoolean(Node* node); 59 60 Reduction TryReduceStringComparisonOfStringFromSingleCharCode( 61 Node* comparison, Node* from_char_code, Type constant_type, 62 bool inverted); 63 Reduction TryReduceStringComparisonOfStringFromSingleCharCodeToConstant( 64 Node* comparison, const StringRef& string, bool inverted); 65 const Operator* NumberComparisonFor(const Operator* op); 66 67 SimplifiedOperatorBuilder* simplified() const; 68 Factory* factory() const; 69 Graph* graph() const; 70 Isolate* isolate() const; 71 72 CompilationDependencies* dependencies() const { return dependencies_; } 73 JSGraph* jsgraph() const { return jsgraph_; } 74 JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } 75 76 CompilationDependencies* const dependencies_; 77 JSGraph* const jsgraph_; 78 JSHeapBroker* js_heap_broker_; 79 Type const true_type_; 80 Type const false_type_; 81 TypeCache const& type_cache_; 82 83 DISALLOW_COPY_AND_ASSIGN(TypedOptimization); 84 }; 85 86 } // namespace compiler 87 } // namespace internal 88 } // namespace v8 89 90 #endif // V8_COMPILER_TYPED_OPTIMIZATION_H_ 91