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