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_OBJECT_SPECIALIZATION_H_ | 5 #ifndef V8_COMPILER_JS_GLOBAL_OBJECT_SPECIALIZATION_H_ |
6 #define V8_COMPILER_JS_GLOBAL_OBJECT_SPECIALIZATION_H_ | 6 #define V8_COMPILER_JS_GLOBAL_OBJECT_SPECIALIZATION_H_ |
7 | 7 |
8 #include "src/base/flags.h" | |
9 #include "src/compiler/graph-reducer.h" | 8 #include "src/compiler/graph-reducer.h" |
10 | 9 |
11 namespace v8 { | 10 namespace v8 { |
12 namespace internal { | 11 namespace internal { |
13 | 12 |
14 // Forward declarations. | 13 // Forward declarations. |
15 class CompilationDependencies; | 14 class CompilationDependencies; |
16 class TypeCache; | 15 class TypeCache; |
17 | 16 |
18 | 17 |
19 namespace compiler { | 18 namespace compiler { |
20 | 19 |
21 // Forward declarations. | 20 // Forward declarations. |
22 class CommonOperatorBuilder; | 21 class CommonOperatorBuilder; |
23 class JSGraph; | 22 class JSGraph; |
24 class JSOperatorBuilder; | 23 class JSOperatorBuilder; |
25 class SimplifiedOperatorBuilder; | 24 class SimplifiedOperatorBuilder; |
26 | 25 |
27 | 26 |
28 // Specializes a given JSGraph to a given global object, potentially constant | 27 // Specializes a given JSGraph to a given global object, potentially constant |
29 // folding some {JSLoadGlobal} nodes or strength reducing some {JSStoreGlobal} | 28 // folding some {JSLoadGlobal} nodes or strength reducing some {JSStoreGlobal} |
30 // nodes. | 29 // nodes. |
31 class JSGlobalObjectSpecialization final : public AdvancedReducer { | 30 class JSGlobalObjectSpecialization final : public AdvancedReducer { |
32 public: | 31 public: |
33 // Flags that control the mode of operation. | 32 JSGlobalObjectSpecialization(Editor* editor, JSGraph* jsgraph, |
34 enum Flag { | |
35 kNoFlags = 0u, | |
36 kDeoptimizationEnabled = 1u << 0, | |
37 }; | |
38 typedef base::Flags<Flag> Flags; | |
39 | |
40 JSGlobalObjectSpecialization(Editor* editor, JSGraph* jsgraph, Flags flags, | |
41 MaybeHandle<Context> native_context, | 33 MaybeHandle<Context> native_context, |
42 CompilationDependencies* dependencies); | 34 CompilationDependencies* dependencies); |
43 | 35 |
44 Reduction Reduce(Node* node) final; | 36 Reduction Reduce(Node* node) final; |
45 | 37 |
46 private: | 38 private: |
47 Reduction ReduceJSLoadGlobal(Node* node); | 39 Reduction ReduceJSLoadGlobal(Node* node); |
48 Reduction ReduceJSStoreGlobal(Node* node); | 40 Reduction ReduceJSStoreGlobal(Node* node); |
49 | 41 |
50 // Retrieve the global object from the given {node} if known. | 42 // Retrieve the global object from the given {node} if known. |
51 MaybeHandle<JSGlobalObject> GetGlobalObject(Node* node); | 43 MaybeHandle<JSGlobalObject> GetGlobalObject(Node* node); |
52 | 44 |
53 struct ScriptContextTableLookupResult; | 45 struct ScriptContextTableLookupResult; |
54 bool LookupInScriptContextTable(Handle<JSGlobalObject> global_object, | 46 bool LookupInScriptContextTable(Handle<JSGlobalObject> global_object, |
55 Handle<Name> name, | 47 Handle<Name> name, |
56 ScriptContextTableLookupResult* result); | 48 ScriptContextTableLookupResult* result); |
57 | 49 |
58 Graph* graph() const; | 50 Graph* graph() const; |
59 JSGraph* jsgraph() const { return jsgraph_; } | 51 JSGraph* jsgraph() const { return jsgraph_; } |
60 Isolate* isolate() const; | 52 Isolate* isolate() const; |
61 CommonOperatorBuilder* common() const; | 53 CommonOperatorBuilder* common() const; |
62 JSOperatorBuilder* javascript() const; | 54 JSOperatorBuilder* javascript() const; |
63 SimplifiedOperatorBuilder* simplified() const; | 55 SimplifiedOperatorBuilder* simplified() const; |
64 Flags flags() const { return flags_; } | |
65 MaybeHandle<Context> native_context() const { return native_context_; } | 56 MaybeHandle<Context> native_context() const { return native_context_; } |
66 CompilationDependencies* dependencies() const { return dependencies_; } | 57 CompilationDependencies* dependencies() const { return dependencies_; } |
67 | 58 |
68 JSGraph* const jsgraph_; | 59 JSGraph* const jsgraph_; |
69 Flags const flags_; | |
70 MaybeHandle<Context> native_context_; | 60 MaybeHandle<Context> native_context_; |
71 CompilationDependencies* const dependencies_; | 61 CompilationDependencies* const dependencies_; |
72 TypeCache const& type_cache_; | 62 TypeCache const& type_cache_; |
73 | 63 |
74 DISALLOW_COPY_AND_ASSIGN(JSGlobalObjectSpecialization); | 64 DISALLOW_COPY_AND_ASSIGN(JSGlobalObjectSpecialization); |
75 }; | 65 }; |
76 | 66 |
77 DEFINE_OPERATORS_FOR_FLAGS(JSGlobalObjectSpecialization::Flags) | |
78 | |
79 } // namespace compiler | 67 } // namespace compiler |
80 } // namespace internal | 68 } // namespace internal |
81 } // namespace v8 | 69 } // namespace v8 |
82 | 70 |
83 #endif // V8_COMPILER_JS_GLOBAL_OBJECT_SPECIALIZATION_H_ | 71 #endif // V8_COMPILER_JS_GLOBAL_OBJECT_SPECIALIZATION_H_ |
OLD | NEW |