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/base/flags.h" 10 #include "src/compiler/graph-reducer.h" 11 #include "src/globals.h" 12 13 namespace v8 { 14 namespace internal { 15 16 // Forward declarations. 17 class CompilationDependencies; 18 class Factory; 19 class Isolate; 20 21 namespace compiler { 22 23 // Forward declarations. 24 class JSGraph; 25 class SimplifiedOperatorBuilder; 26 class TypeCache; 27 28 class V8_EXPORT_PRIVATE TypedOptimization final 29 : public NON_EXPORTED_BASE(AdvancedReducer) { 30 public: 31 // Flags that control the mode of operation. 32 enum Flag { 33 kNoFlags = 0u, 34 kDeoptimizationEnabled = 1u << 0, 35 }; 36 typedef base::Flags<Flag> Flags; 37 38 TypedOptimization(Editor* editor, CompilationDependencies* dependencies, 39 Flags flags, JSGraph* jsgraph); 40 ~TypedOptimization(); 41 42 Reduction Reduce(Node* node) final; 43 44 private: 45 Reduction ReduceCheckHeapObject(Node* node); 46 Reduction ReduceCheckMaps(Node* node); 47 Reduction ReduceCheckString(Node* node); 48 Reduction ReduceLoadField(Node* node); 49 Reduction ReduceNumberRoundop(Node* node); 50 Reduction ReduceNumberToUint8Clamped(Node* node); 51 Reduction ReducePhi(Node* node); 52 Reduction ReduceSelect(Node* node); 53 54 CompilationDependencies* dependencies() const { return dependencies_; } 55 Factory* factory() const; 56 Flags flags() const { return flags_; } 57 Graph* graph() const; 58 Isolate* isolate() const; 59 JSGraph* jsgraph() const { return jsgraph_; } 60 SimplifiedOperatorBuilder* simplified() const; 61 62 CompilationDependencies* const dependencies_; 63 Flags const flags_; 64 JSGraph* const jsgraph_; 65 Type* const true_type_; 66 Type* const false_type_; 67 TypeCache const& type_cache_; 68 69 DISALLOW_COPY_AND_ASSIGN(TypedOptimization); 70 }; 71 72 DEFINE_OPERATORS_FOR_FLAGS(TypedOptimization::Flags) 73 74 } // namespace compiler 75 } // namespace internal 76 } // namespace v8 77 78 #endif // V8_COMPILER_TYPED_OPTIMIZATION_H_ 79