| 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" | 9 #include "src/compiler/access-info.h" |
| 10 #include "src/compiler/graph-reducer.h" | 10 #include "src/compiler/graph-reducer.h" |
| 11 #include "src/compiler/simplified-operator.h" | |
| 12 | 11 |
| 13 namespace v8 { | 12 namespace v8 { |
| 14 namespace internal { | 13 namespace internal { |
| 15 | 14 |
| 16 // Forward declarations. | 15 // Forward declarations. |
| 17 class CompilationDependencies; | 16 class CompilationDependencies; |
| 18 class Factory; | 17 class Factory; |
| 19 class FeedbackNexus; | 18 class FeedbackNexus; |
| 20 class TypeCache; | 19 class TypeCache; |
| 21 | 20 |
| 22 | 21 |
| 23 namespace compiler { | 22 namespace compiler { |
| 24 | 23 |
| 25 // Forward declarations. | 24 // Forward declarations. |
| 26 class CommonOperatorBuilder; | 25 class CommonOperatorBuilder; |
| 27 class JSGraph; | 26 class JSGraph; |
| 28 class JSOperatorBuilder; | 27 class JSOperatorBuilder; |
| 29 class MachineOperatorBuilder; | 28 class MachineOperatorBuilder; |
| 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<JSGlobalObject> global_object, | 46 Handle<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 ReduceJSCallFunction(Node* node); | 53 Reduction ReduceJSCallFunction(Node* node); |
| 54 Reduction ReduceJSLoadGlobal(Node* node); | |
| 55 Reduction ReduceJSStoreGlobal(Node* node); | |
| 56 Reduction ReduceJSLoadNamed(Node* node); | 54 Reduction ReduceJSLoadNamed(Node* node); |
| 57 Reduction ReduceJSStoreNamed(Node* node); | 55 Reduction ReduceJSStoreNamed(Node* node); |
| 58 Reduction ReduceJSLoadProperty(Node* node); | 56 Reduction ReduceJSLoadProperty(Node* node); |
| 59 Reduction ReduceJSStoreProperty(Node* node); | 57 Reduction ReduceJSStoreProperty(Node* node); |
| 60 | 58 |
| 61 Reduction Replace(Node* node, Node* value, Node* effect = nullptr, | |
| 62 Node* control = nullptr) { | |
| 63 ReplaceWithValue(node, value, effect, control); | |
| 64 return Changed(value); | |
| 65 } | |
| 66 Reduction Replace(Node* node, Handle<Object> value); | |
| 67 | |
| 68 Reduction ReduceElementAccess(Node* node, Node* index, Node* value, | 59 Reduction ReduceElementAccess(Node* node, Node* index, Node* value, |
| 69 MapHandleList const& receiver_maps, | 60 MapHandleList const& receiver_maps, |
| 70 AccessMode access_mode, | 61 AccessMode access_mode, |
| 71 LanguageMode language_mode); | 62 LanguageMode language_mode); |
| 72 Reduction ReduceKeyedAccess(Node* node, Node* index, Node* value, | 63 Reduction ReduceKeyedAccess(Node* node, Node* index, Node* value, |
| 73 FeedbackNexus const& nexus, | 64 FeedbackNexus const& nexus, |
| 74 AccessMode access_mode, | 65 AccessMode access_mode, |
| 75 LanguageMode language_mode); | 66 LanguageMode language_mode); |
| 76 Reduction ReduceNamedAccess(Node* node, Node* value, | 67 Reduction ReduceNamedAccess(Node* node, Node* value, |
| 77 MapHandleList const& receiver_maps, | 68 MapHandleList const& receiver_maps, |
| 78 Handle<Name> name, AccessMode access_mode, | 69 Handle<Name> name, AccessMode access_mode, |
| 79 LanguageMode language_mode, | 70 LanguageMode language_mode, |
| 80 Node* index = nullptr); | 71 Node* index = nullptr); |
| 81 | 72 |
| 82 struct ScriptContextTableLookupResult; | |
| 83 bool LookupInScriptContextTable(Handle<Name> name, | |
| 84 ScriptContextTableLookupResult* result); | |
| 85 | |
| 86 // Adds stability dependencies on all prototypes of every class in | 73 // Adds stability dependencies on all prototypes of every class in |
| 87 // {receiver_type} up to (and including) the {holder}. | 74 // {receiver_type} up to (and including) the {holder}. |
| 88 void AssumePrototypesStable(Type* receiver_type, Handle<JSObject> holder); | 75 void AssumePrototypesStable(Type* receiver_type, Handle<JSObject> holder); |
| 89 | 76 |
| 90 // Assuming that {if_projection} is either IfTrue or IfFalse, adds a hint on | 77 // Assuming that {if_projection} is either IfTrue or IfFalse, adds a hint on |
| 91 // the dominating Branch that {if_projection} is the unlikely (deferred) case. | 78 // the dominating Branch that {if_projection} is the unlikely (deferred) case. |
| 92 void MarkAsDeferred(Node* if_projection); | 79 void MarkAsDeferred(Node* if_projection); |
| 93 | 80 |
| 94 Graph* graph() const; | 81 Graph* graph() const; |
| 95 JSGraph* jsgraph() const { return jsgraph_; } | 82 JSGraph* jsgraph() const { return jsgraph_; } |
| 96 Isolate* isolate() const; | 83 Isolate* isolate() const; |
| 97 Factory* factory() const; | 84 Factory* factory() const; |
| 98 CommonOperatorBuilder* common() const; | 85 CommonOperatorBuilder* common() const; |
| 99 JSOperatorBuilder* javascript() const; | 86 JSOperatorBuilder* javascript() const; |
| 100 SimplifiedOperatorBuilder* simplified() const; | 87 SimplifiedOperatorBuilder* simplified() const; |
| 101 MachineOperatorBuilder* machine() const; | 88 MachineOperatorBuilder* machine() const; |
| 102 Flags flags() const { return flags_; } | 89 Flags flags() const { return flags_; } |
| 103 Handle<JSGlobalObject> global_object() const { return global_object_; } | |
| 104 Handle<Context> native_context() const { return native_context_; } | 90 Handle<Context> native_context() const { return native_context_; } |
| 105 CompilationDependencies* dependencies() const { return dependencies_; } | 91 CompilationDependencies* dependencies() const { return dependencies_; } |
| 106 Zone* zone() const { return zone_; } | 92 Zone* zone() const { return zone_; } |
| 107 AccessInfoFactory& access_info_factory() { return access_info_factory_; } | 93 AccessInfoFactory& access_info_factory() { return access_info_factory_; } |
| 108 | 94 |
| 109 JSGraph* const jsgraph_; | 95 JSGraph* const jsgraph_; |
| 110 Flags const flags_; | 96 Flags const flags_; |
| 111 Handle<JSGlobalObject> global_object_; | |
| 112 Handle<Context> native_context_; | 97 Handle<Context> native_context_; |
| 113 CompilationDependencies* const dependencies_; | 98 CompilationDependencies* const dependencies_; |
| 114 Zone* const zone_; | 99 Zone* const zone_; |
| 115 TypeCache const& type_cache_; | 100 TypeCache const& type_cache_; |
| 116 AccessInfoFactory access_info_factory_; | 101 AccessInfoFactory access_info_factory_; |
| 117 | 102 |
| 118 DISALLOW_COPY_AND_ASSIGN(JSNativeContextSpecialization); | 103 DISALLOW_COPY_AND_ASSIGN(JSNativeContextSpecialization); |
| 119 }; | 104 }; |
| 120 | 105 |
| 121 DEFINE_OPERATORS_FOR_FLAGS(JSNativeContextSpecialization::Flags) | 106 DEFINE_OPERATORS_FOR_FLAGS(JSNativeContextSpecialization::Flags) |
| 122 | 107 |
| 123 } // namespace compiler | 108 } // namespace compiler |
| 124 } // namespace internal | 109 } // namespace internal |
| 125 } // namespace v8 | 110 } // namespace v8 |
| 126 | 111 |
| 127 #endif // V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_ | 112 #endif // V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_ |
| OLD | NEW |