| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COMPILER_JS_GLOBAL_SPECIALIZATION_H_ | 5 #ifndef V8_COMPILER_JS_GLOBAL_SPECIALIZATION_H_ |
| 6 #define V8_COMPILER_JS_GLOBAL_SPECIALIZATION_H_ | 6 #define V8_COMPILER_JS_GLOBAL_SPECIALIZATION_H_ |
| 7 | 7 |
| 8 #include "src/base/flags.h" | 8 #include "src/base/flags.h" |
| 9 #include "src/compiler/graph-reducer.h" | 9 #include "src/compiler/graph-reducer.h" |
| 10 #include "src/compiler/simplified-operator.h" | 10 #include "src/compiler/simplified-operator.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 // Specializes a given JSGraph to a given GlobalObject, potentially constant | 27 // Specializes a given JSGraph to a given GlobalObject, potentially constant |
| 28 // folding some {LoadGlobal} nodes or strength reducing some {StoreGlobal} | 28 // folding some {LoadGlobal} nodes or strength reducing some {StoreGlobal} |
| 29 // nodes. | 29 // nodes. |
| 30 class JSGlobalSpecialization final : public AdvancedReducer { | 30 class JSGlobalSpecialization final : public AdvancedReducer { |
| 31 public: | 31 public: |
| 32 // Flags that control the mode of operation. | 32 // Flags that control the mode of operation. |
| 33 enum Flag { | 33 enum Flag { |
| 34 kNoFlags = 0u, | 34 kNoFlags = 0u, |
| 35 kDeoptimizationEnabled = 1u << 0, | 35 kDeoptimizationEnabled = 1u << 0, |
| 36 kTypingEnabled = 1u << 1 | |
| 37 }; | 36 }; |
| 38 typedef base::Flags<Flag> Flags; | 37 typedef base::Flags<Flag> Flags; |
| 39 | 38 |
| 40 JSGlobalSpecialization(Editor* editor, JSGraph* jsgraph, Flags flags, | 39 JSGlobalSpecialization(Editor* editor, JSGraph* jsgraph, Flags flags, |
| 41 Handle<GlobalObject> global_object, | 40 Handle<GlobalObject> global_object, |
| 42 CompilationDependencies* dependencies); | 41 CompilationDependencies* dependencies); |
| 43 | 42 |
| 44 Reduction Reduce(Node* node) final; | 43 Reduction Reduce(Node* node) final; |
| 45 | 44 |
| 46 private: | 45 private: |
| 47 Reduction ReduceJSLoadGlobal(Node* node); | 46 Reduction ReduceJSLoadGlobal(Node* node); |
| 48 Reduction ReduceJSStoreGlobal(Node* node); | 47 Reduction ReduceJSStoreGlobal(Node* node); |
| 49 Reduction ReduceLoadFromPropertyCell(Node* node, | |
| 50 Handle<PropertyCell> property_cell); | |
| 51 Reduction ReduceStoreToPropertyCell(Node* node, | |
| 52 Handle<PropertyCell> property_cell); | |
| 53 | 48 |
| 54 Reduction Replace(Node* node, Node* value, Node* effect = nullptr, | 49 Reduction Replace(Node* node, Node* value, Node* effect = nullptr, |
| 55 Node* control = nullptr) { | 50 Node* control = nullptr) { |
| 56 ReplaceWithValue(node, value, effect, control); | 51 ReplaceWithValue(node, value, effect, control); |
| 57 return Changed(value); | 52 return Changed(value); |
| 58 } | 53 } |
| 59 Reduction Replace(Node* node, Handle<Object> value); | 54 Reduction Replace(Node* node, Handle<Object> value); |
| 60 | 55 |
| 56 struct ScriptContextTableLookupResult; |
| 57 bool LookupInScriptContextTable(Handle<Name> name, |
| 58 ScriptContextTableLookupResult* result); |
| 59 |
| 61 Graph* graph() const; | 60 Graph* graph() const; |
| 62 JSGraph* jsgraph() const { return jsgraph_; } | 61 JSGraph* jsgraph() const { return jsgraph_; } |
| 63 Isolate* isolate() const; | 62 Isolate* isolate() const; |
| 64 CommonOperatorBuilder* common() const; | 63 CommonOperatorBuilder* common() const; |
| 65 JSOperatorBuilder* javascript() const; | 64 JSOperatorBuilder* javascript() const; |
| 66 SimplifiedOperatorBuilder* simplified() { return &simplified_; } | 65 SimplifiedOperatorBuilder* simplified() { return &simplified_; } |
| 67 Flags flags() const { return flags_; } | 66 Flags flags() const { return flags_; } |
| 68 Handle<GlobalObject> global_object() const { return global_object_; } | 67 Handle<GlobalObject> global_object() const { return global_object_; } |
| 69 CompilationDependencies* dependencies() const { return dependencies_; } | 68 CompilationDependencies* dependencies() const { return dependencies_; } |
| 70 | 69 |
| 71 JSGraph* const jsgraph_; | 70 JSGraph* const jsgraph_; |
| 72 Flags const flags_; | 71 Flags const flags_; |
| 73 Handle<GlobalObject> global_object_; | 72 Handle<GlobalObject> global_object_; |
| 74 CompilationDependencies* const dependencies_; | 73 CompilationDependencies* const dependencies_; |
| 75 SimplifiedOperatorBuilder simplified_; | 74 SimplifiedOperatorBuilder simplified_; |
| 76 | 75 |
| 77 DISALLOW_COPY_AND_ASSIGN(JSGlobalSpecialization); | 76 DISALLOW_COPY_AND_ASSIGN(JSGlobalSpecialization); |
| 78 }; | 77 }; |
| 79 | 78 |
| 80 DEFINE_OPERATORS_FOR_FLAGS(JSGlobalSpecialization::Flags) | 79 DEFINE_OPERATORS_FOR_FLAGS(JSGlobalSpecialization::Flags) |
| 81 | 80 |
| 82 } // namespace compiler | 81 } // namespace compiler |
| 83 } // namespace internal | 82 } // namespace internal |
| 84 } // namespace v8 | 83 } // namespace v8 |
| 85 | 84 |
| 86 #endif // V8_COMPILER_JS_GLOBAL_SPECIALIZATION_H_ | 85 #endif // V8_COMPILER_JS_GLOBAL_SPECIALIZATION_H_ |
| OLD | NEW |