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_NATIVE_CONTEXT_SPECIALIZATION_H_ |
6 #define V8_COMPILER_JS_GLOBAL_SPECIALIZATION_H_ | 6 #define V8_COMPILER_JS_NATIVE_CONTEXT_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" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 // Forward declarations. | 15 // Forward declarations. |
16 class CompilationDependencies; | 16 class CompilationDependencies; |
17 | 17 |
18 | 18 |
19 namespace compiler { | 19 namespace compiler { |
20 | 20 |
21 // Forward declarations. | 21 // Forward declarations. |
22 class CommonOperatorBuilder; | 22 class CommonOperatorBuilder; |
23 class JSGraph; | 23 class JSGraph; |
24 class JSOperatorBuilder; | 24 class JSOperatorBuilder; |
25 class MachineOperatorBuilder; | 25 class MachineOperatorBuilder; |
26 | 26 |
27 | 27 |
28 // Specializes a given JSGraph to a given GlobalObject, potentially constant | 28 // Specializes a given JSGraph to a given native context, potentially constant |
29 // folding some {LoadGlobal} nodes or strength reducing some {StoreGlobal} | 29 // folding some {LoadGlobal} nodes or strength reducing some {StoreGlobal} |
30 // nodes. | 30 // nodes. And also specializes {LoadNamed} and {StoreNamed} nodes according |
31 class JSGlobalSpecialization final : public AdvancedReducer { | 31 // to type feedback (if available). |
| 32 class JSNativeContextSpecialization final : public AdvancedReducer { |
32 public: | 33 public: |
33 // Flags that control the mode of operation. | 34 // Flags that control the mode of operation. |
34 enum Flag { | 35 enum Flag { |
35 kNoFlags = 0u, | 36 kNoFlags = 0u, |
36 kDeoptimizationEnabled = 1u << 0, | 37 kDeoptimizationEnabled = 1u << 0, |
37 }; | 38 }; |
38 typedef base::Flags<Flag> Flags; | 39 typedef base::Flags<Flag> Flags; |
39 | 40 |
40 JSGlobalSpecialization(Editor* editor, JSGraph* jsgraph, Flags flags, | 41 JSNativeContextSpecialization(Editor* editor, JSGraph* jsgraph, Flags flags, |
41 Handle<GlobalObject> global_object, | 42 Handle<GlobalObject> global_object, |
42 CompilationDependencies* dependencies, Zone* zone); | 43 CompilationDependencies* dependencies, |
| 44 Zone* zone); |
43 | 45 |
44 Reduction Reduce(Node* node) final; | 46 Reduction Reduce(Node* node) final; |
45 | 47 |
46 private: | 48 private: |
47 Reduction ReduceJSLoadGlobal(Node* node); | 49 Reduction ReduceJSLoadGlobal(Node* node); |
48 Reduction ReduceJSStoreGlobal(Node* node); | 50 Reduction ReduceJSStoreGlobal(Node* node); |
49 Reduction ReduceJSLoadNamed(Node* node); | 51 Reduction ReduceJSLoadNamed(Node* node); |
50 | 52 |
51 Reduction Replace(Node* node, Node* value, Node* effect = nullptr, | 53 Reduction Replace(Node* node, Node* value, Node* effect = nullptr, |
52 Node* control = nullptr) { | 54 Node* control = nullptr) { |
(...skipping 23 matching lines...) Expand all Loading... |
76 Handle<GlobalObject> global_object() const { return global_object_; } | 78 Handle<GlobalObject> global_object() const { return global_object_; } |
77 CompilationDependencies* dependencies() const { return dependencies_; } | 79 CompilationDependencies* dependencies() const { return dependencies_; } |
78 Zone* zone() const { return zone_; } | 80 Zone* zone() const { return zone_; } |
79 | 81 |
80 JSGraph* const jsgraph_; | 82 JSGraph* const jsgraph_; |
81 Flags const flags_; | 83 Flags const flags_; |
82 Handle<GlobalObject> global_object_; | 84 Handle<GlobalObject> global_object_; |
83 CompilationDependencies* const dependencies_; | 85 CompilationDependencies* const dependencies_; |
84 Zone* const zone_; | 86 Zone* const zone_; |
85 | 87 |
86 DISALLOW_COPY_AND_ASSIGN(JSGlobalSpecialization); | 88 DISALLOW_COPY_AND_ASSIGN(JSNativeContextSpecialization); |
87 }; | 89 }; |
88 | 90 |
89 DEFINE_OPERATORS_FOR_FLAGS(JSGlobalSpecialization::Flags) | 91 DEFINE_OPERATORS_FOR_FLAGS(JSNativeContextSpecialization::Flags) |
90 | 92 |
91 } // namespace compiler | 93 } // namespace compiler |
92 } // namespace internal | 94 } // namespace internal |
93 } // namespace v8 | 95 } // namespace v8 |
94 | 96 |
95 #endif // V8_COMPILER_JS_GLOBAL_SPECIALIZATION_H_ | 97 #endif // V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_ |
OLD | NEW |