OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef V8_COMPILER_JS_GLOBAL_SPECIALIZATION_H_ | |
6 #define V8_COMPILER_JS_GLOBAL_SPECIALIZATION_H_ | |
7 | |
8 #include "src/base/flags.h" | |
9 #include "src/compiler/graph-reducer.h" | |
10 #include "src/compiler/simplified-operator.h" | |
11 | |
12 namespace v8 { | |
13 namespace internal { | |
14 | |
15 // Forward declarations. | |
16 class CompilationDependencies; | |
17 | |
18 | |
19 namespace compiler { | |
20 | |
21 // Forward declarations. | |
22 class CommonOperatorBuilder; | |
23 class JSGraph; | |
24 class JSOperatorBuilder; | |
25 class MachineOperatorBuilder; | |
26 | |
27 | |
28 // Specializes a given JSGraph to a given GlobalObject, potentially constant | |
29 // folding some {LoadGlobal} nodes or strength reducing some {StoreGlobal} | |
30 // nodes. | |
31 class JSGlobalSpecialization final : public AdvancedReducer { | |
32 public: | |
33 // Flags that control the mode of operation. | |
34 enum Flag { | |
35 kNoFlags = 0u, | |
36 kDeoptimizationEnabled = 1u << 0, | |
37 }; | |
38 typedef base::Flags<Flag> Flags; | |
39 | |
40 JSGlobalSpecialization(Editor* editor, JSGraph* jsgraph, Flags flags, | |
41 Handle<GlobalObject> global_object, | |
42 CompilationDependencies* dependencies, Zone* zone); | |
43 | |
44 Reduction Reduce(Node* node) final; | |
45 | |
46 private: | |
47 Reduction ReduceJSLoadGlobal(Node* node); | |
48 Reduction ReduceJSStoreGlobal(Node* node); | |
49 Reduction ReduceJSLoadNamed(Node* node); | |
50 | |
51 Reduction Replace(Node* node, Node* value, Node* effect = nullptr, | |
52 Node* control = nullptr) { | |
53 ReplaceWithValue(node, value, effect, control); | |
54 return Changed(value); | |
55 } | |
56 Reduction Replace(Node* node, Handle<Object> value); | |
57 | |
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; | |
65 bool LookupInScriptContextTable(Handle<Name> name, | |
66 ScriptContextTableLookupResult* result); | |
67 | |
68 Graph* graph() const; | |
69 JSGraph* jsgraph() const { return jsgraph_; } | |
70 Isolate* isolate() const; | |
71 CommonOperatorBuilder* common() const; | |
72 JSOperatorBuilder* javascript() const; | |
73 SimplifiedOperatorBuilder* simplified() const; | |
74 MachineOperatorBuilder* machine() const; | |
75 Flags flags() const { return flags_; } | |
76 Handle<GlobalObject> global_object() const { return global_object_; } | |
77 CompilationDependencies* dependencies() const { return dependencies_; } | |
78 Zone* zone() const { return zone_; } | |
79 | |
80 JSGraph* const jsgraph_; | |
81 Flags const flags_; | |
82 Handle<GlobalObject> global_object_; | |
83 CompilationDependencies* const dependencies_; | |
84 Zone* const zone_; | |
85 | |
86 DISALLOW_COPY_AND_ASSIGN(JSGlobalSpecialization); | |
87 }; | |
88 | |
89 DEFINE_OPERATORS_FOR_FLAGS(JSGlobalSpecialization::Flags) | |
90 | |
91 } // namespace compiler | |
92 } // namespace internal | |
93 } // namespace v8 | |
94 | |
95 #endif // V8_COMPILER_JS_GLOBAL_SPECIALIZATION_H_ | |
OLD | NEW |