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" |
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; | |
26 | 25 |
27 | 26 |
28 // Specializes a given JSGraph to a given GlobalObject, potentially constant | 27 // Specializes a given JSGraph to a given GlobalObject, potentially constant |
29 // folding some {LoadGlobal} nodes or strength reducing some {StoreGlobal} | 28 // folding some {LoadGlobal} nodes or strength reducing some {StoreGlobal} |
30 // nodes. | 29 // nodes. |
31 class JSGlobalSpecialization final : public AdvancedReducer { | 30 class JSGlobalSpecialization final : public AdvancedReducer { |
32 public: | 31 public: |
33 // Flags that control the mode of operation. | 32 // Flags that control the mode of operation. |
34 enum Flag { | 33 enum Flag { |
35 kNoFlags = 0u, | 34 kNoFlags = 0u, |
36 kDeoptimizationEnabled = 1u << 0, | 35 kDeoptimizationEnabled = 1u << 0, |
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, Zone* zone); | 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 ReduceJSLoadNamed(Node* node); | |
50 | 48 |
51 Reduction Replace(Node* node, Node* value, Node* effect = nullptr, | 49 Reduction Replace(Node* node, Node* value, Node* effect = nullptr, |
52 Node* control = nullptr) { | 50 Node* control = nullptr) { |
53 ReplaceWithValue(node, value, effect, control); | 51 ReplaceWithValue(node, value, effect, control); |
54 return Changed(value); | 52 return Changed(value); |
55 } | 53 } |
56 Reduction Replace(Node* node, Handle<Object> value); | 54 Reduction Replace(Node* node, Handle<Object> value); |
57 | 55 |
58 class PropertyAccessInfo; | |
59 bool ComputePropertyAccessInfo(Handle<Map> map, Handle<Name> name, | |
60 PropertyAccessInfo* access_info); | |
61 bool ComputePropertyAccessInfos(MapHandleList const& maps, Handle<Name> name, | |
62 ZoneVector<PropertyAccessInfo>* access_infos); | |
63 | |
64 struct ScriptContextTableLookupResult; | 56 struct ScriptContextTableLookupResult; |
65 bool LookupInScriptContextTable(Handle<Name> name, | 57 bool LookupInScriptContextTable(Handle<Name> name, |
66 ScriptContextTableLookupResult* result); | 58 ScriptContextTableLookupResult* result); |
67 | 59 |
68 Graph* graph() const; | 60 Graph* graph() const; |
69 JSGraph* jsgraph() const { return jsgraph_; } | 61 JSGraph* jsgraph() const { return jsgraph_; } |
70 Isolate* isolate() const; | 62 Isolate* isolate() const; |
71 CommonOperatorBuilder* common() const; | 63 CommonOperatorBuilder* common() const; |
72 JSOperatorBuilder* javascript() const; | 64 JSOperatorBuilder* javascript() const; |
73 SimplifiedOperatorBuilder* simplified() const; | 65 SimplifiedOperatorBuilder* simplified() const; |
74 MachineOperatorBuilder* machine() const; | |
75 Flags flags() const { return flags_; } | 66 Flags flags() const { return flags_; } |
76 Handle<GlobalObject> global_object() const { return global_object_; } | 67 Handle<GlobalObject> global_object() const { return global_object_; } |
77 CompilationDependencies* dependencies() const { return dependencies_; } | 68 CompilationDependencies* dependencies() const { return dependencies_; } |
78 Zone* zone() const { return zone_; } | |
79 | 69 |
80 JSGraph* const jsgraph_; | 70 JSGraph* const jsgraph_; |
81 Flags const flags_; | 71 Flags const flags_; |
82 Handle<GlobalObject> global_object_; | 72 Handle<GlobalObject> global_object_; |
83 CompilationDependencies* const dependencies_; | 73 CompilationDependencies* const dependencies_; |
84 Zone* const zone_; | |
85 | 74 |
86 DISALLOW_COPY_AND_ASSIGN(JSGlobalSpecialization); | 75 DISALLOW_COPY_AND_ASSIGN(JSGlobalSpecialization); |
87 }; | 76 }; |
88 | 77 |
89 DEFINE_OPERATORS_FOR_FLAGS(JSGlobalSpecialization::Flags) | 78 DEFINE_OPERATORS_FOR_FLAGS(JSGlobalSpecialization::Flags) |
90 | 79 |
91 } // namespace compiler | 80 } // namespace compiler |
92 } // namespace internal | 81 } // namespace internal |
93 } // namespace v8 | 82 } // namespace v8 |
94 | 83 |
95 #endif // V8_COMPILER_JS_GLOBAL_SPECIALIZATION_H_ | 84 #endif // V8_COMPILER_JS_GLOBAL_SPECIALIZATION_H_ |
OLD | NEW |