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