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_NATIVE_CONTEXT_SPECIALIZATION_H_ | 5 #ifndef V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_ |
6 #define V8_COMPILER_JS_NATIVE_CONTEXT_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/access-info.h" | |
10 #include "src/compiler/graph-reducer.h" | 9 #include "src/compiler/graph-reducer.h" |
11 | 10 |
12 namespace v8 { | 11 namespace v8 { |
13 namespace internal { | 12 namespace internal { |
14 | 13 |
15 // Forward declarations. | 14 // Forward declarations. |
16 class CompilationDependencies; | 15 class CompilationDependencies; |
17 class Factory; | 16 class Factory; |
18 class FeedbackNexus; | 17 class FeedbackNexus; |
19 class TypeCache; | 18 class TypeCache; |
20 | 19 |
21 | 20 |
22 namespace compiler { | 21 namespace compiler { |
23 | 22 |
24 // Forward declarations. | 23 // Forward declarations. |
| 24 enum class AccessMode; |
25 class CommonOperatorBuilder; | 25 class CommonOperatorBuilder; |
26 class JSGraph; | 26 class JSGraph; |
27 class JSOperatorBuilder; | 27 class JSOperatorBuilder; |
28 class MachineOperatorBuilder; | 28 class MachineOperatorBuilder; |
29 class SimplifiedOperatorBuilder; | 29 class SimplifiedOperatorBuilder; |
30 | 30 |
31 | 31 |
32 // Specializes a given JSGraph to a given native context, potentially constant | 32 // Specializes a given JSGraph to a given native context, potentially constant |
33 // folding some {LoadGlobal} nodes or strength reducing some {StoreGlobal} | 33 // folding some {LoadGlobal} nodes or strength reducing some {StoreGlobal} |
34 // nodes. And also specializes {LoadNamed} and {StoreNamed} nodes according | 34 // nodes. And also specializes {LoadNamed} and {StoreNamed} nodes according |
35 // to type feedback (if available). | 35 // to type feedback (if available). |
36 class JSNativeContextSpecialization final : public AdvancedReducer { | 36 class JSNativeContextSpecialization final : public AdvancedReducer { |
37 public: | 37 public: |
38 // Flags that control the mode of operation. | 38 // Flags that control the mode of operation. |
39 enum Flag { | 39 enum Flag { |
40 kNoFlags = 0u, | 40 kNoFlags = 0u, |
41 kDeoptimizationEnabled = 1u << 0, | 41 kDeoptimizationEnabled = 1u << 0, |
42 }; | 42 }; |
43 typedef base::Flags<Flag> Flags; | 43 typedef base::Flags<Flag> Flags; |
44 | 44 |
45 JSNativeContextSpecialization(Editor* editor, JSGraph* jsgraph, Flags flags, | 45 JSNativeContextSpecialization(Editor* editor, JSGraph* jsgraph, Flags flags, |
46 Handle<Context> native_context, | 46 MaybeHandle<Context> native_context, |
47 CompilationDependencies* dependencies, | 47 CompilationDependencies* dependencies, |
48 Zone* zone); | 48 Zone* zone); |
49 | 49 |
50 Reduction Reduce(Node* node) final; | 50 Reduction Reduce(Node* node) final; |
51 | 51 |
52 private: | 52 private: |
53 Reduction ReduceJSLoadNamed(Node* node); | 53 Reduction ReduceJSLoadNamed(Node* node); |
54 Reduction ReduceJSStoreNamed(Node* node); | 54 Reduction ReduceJSStoreNamed(Node* node); |
55 Reduction ReduceJSLoadProperty(Node* node); | 55 Reduction ReduceJSLoadProperty(Node* node); |
56 Reduction ReduceJSStoreProperty(Node* node); | 56 Reduction ReduceJSStoreProperty(Node* node); |
57 | 57 |
58 Reduction ReduceElementAccess(Node* node, Node* index, Node* value, | 58 Reduction ReduceElementAccess(Node* node, Node* index, Node* value, |
59 MapHandleList const& receiver_maps, | 59 MapHandleList const& receiver_maps, |
60 AccessMode access_mode, | 60 AccessMode access_mode, |
61 LanguageMode language_mode, | 61 LanguageMode language_mode, |
62 KeyedAccessStoreMode store_mode); | 62 KeyedAccessStoreMode store_mode); |
63 Reduction ReduceKeyedAccess(Node* node, Node* index, Node* value, | 63 Reduction ReduceKeyedAccess(Node* node, Node* index, Node* value, |
64 FeedbackNexus const& nexus, | 64 FeedbackNexus const& nexus, |
65 AccessMode access_mode, | 65 AccessMode access_mode, |
66 LanguageMode language_mode, | 66 LanguageMode language_mode, |
67 KeyedAccessStoreMode store_mode); | 67 KeyedAccessStoreMode store_mode); |
68 Reduction ReduceNamedAccess(Node* node, Node* value, | 68 Reduction ReduceNamedAccess(Node* node, Node* value, |
69 MapHandleList const& receiver_maps, | 69 MapHandleList const& receiver_maps, |
70 Handle<Name> name, AccessMode access_mode, | 70 Handle<Name> name, AccessMode access_mode, |
71 LanguageMode language_mode, | 71 LanguageMode language_mode, |
72 Node* index = nullptr); | 72 Node* index = nullptr); |
73 | 73 |
74 // Adds stability dependencies on all prototypes of every class in | 74 // Adds stability dependencies on all prototypes of every class in |
75 // {receiver_type} up to (and including) the {holder}. | 75 // {receiver_type} up to (and including) the {holder}. |
76 void AssumePrototypesStable(Type* receiver_type, Handle<JSObject> holder); | 76 void AssumePrototypesStable(Type* receiver_type, |
| 77 Handle<Context> native_context, |
| 78 Handle<JSObject> holder); |
77 | 79 |
78 // Assuming that {if_projection} is either IfTrue or IfFalse, adds a hint on | 80 // Assuming that {if_projection} is either IfTrue or IfFalse, adds a hint on |
79 // the dominating Branch that {if_projection} is the unlikely (deferred) case. | 81 // the dominating Branch that {if_projection} is the unlikely (deferred) case. |
80 void MarkAsDeferred(Node* if_projection); | 82 void MarkAsDeferred(Node* if_projection); |
81 | 83 |
| 84 // Retrieve the native context from the given {node} if known. |
| 85 MaybeHandle<Context> GetNativeContext(Node* node); |
| 86 |
82 Graph* graph() const; | 87 Graph* graph() const; |
83 JSGraph* jsgraph() const { return jsgraph_; } | 88 JSGraph* jsgraph() const { return jsgraph_; } |
84 Isolate* isolate() const; | 89 Isolate* isolate() const; |
85 Factory* factory() const; | 90 Factory* factory() const; |
86 CommonOperatorBuilder* common() const; | 91 CommonOperatorBuilder* common() const; |
87 JSOperatorBuilder* javascript() const; | 92 JSOperatorBuilder* javascript() const; |
88 SimplifiedOperatorBuilder* simplified() const; | 93 SimplifiedOperatorBuilder* simplified() const; |
89 MachineOperatorBuilder* machine() const; | 94 MachineOperatorBuilder* machine() const; |
90 Flags flags() const { return flags_; } | 95 Flags flags() const { return flags_; } |
91 Handle<Context> native_context() const { return native_context_; } | 96 MaybeHandle<Context> native_context() const { return native_context_; } |
92 CompilationDependencies* dependencies() const { return dependencies_; } | 97 CompilationDependencies* dependencies() const { return dependencies_; } |
93 Zone* zone() const { return zone_; } | 98 Zone* zone() const { return zone_; } |
94 AccessInfoFactory& access_info_factory() { return access_info_factory_; } | |
95 | 99 |
96 JSGraph* const jsgraph_; | 100 JSGraph* const jsgraph_; |
97 Flags const flags_; | 101 Flags const flags_; |
98 Handle<Context> native_context_; | 102 MaybeHandle<Context> native_context_; |
99 CompilationDependencies* const dependencies_; | 103 CompilationDependencies* const dependencies_; |
100 Zone* const zone_; | 104 Zone* const zone_; |
101 TypeCache const& type_cache_; | 105 TypeCache const& type_cache_; |
102 AccessInfoFactory access_info_factory_; | |
103 | 106 |
104 DISALLOW_COPY_AND_ASSIGN(JSNativeContextSpecialization); | 107 DISALLOW_COPY_AND_ASSIGN(JSNativeContextSpecialization); |
105 }; | 108 }; |
106 | 109 |
107 DEFINE_OPERATORS_FOR_FLAGS(JSNativeContextSpecialization::Flags) | 110 DEFINE_OPERATORS_FOR_FLAGS(JSNativeContextSpecialization::Flags) |
108 | 111 |
109 } // namespace compiler | 112 } // namespace compiler |
110 } // namespace internal | 113 } // namespace internal |
111 } // namespace v8 | 114 } // namespace v8 |
112 | 115 |
113 #endif // V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_ | 116 #endif // V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_ |
OLD | NEW |