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