Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1 | // Copyright 2014 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_CONTEXT_SPECIALIZATION_H_ |
| 6 | #define V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_ |
| 7 | |
| 8 | #include "src/compiler/graph-reducer.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 9 | |
| 10 | namespace v8 { |
| 11 | namespace internal { |
| 12 | namespace compiler { |
| 13 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 14 | // Forward declarations. |
| 15 | class JSGraph; |
| 16 | class JSOperatorBuilder; |
| 17 | |
| 18 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 19 | // Specializes a given JSGraph to a given context, potentially constant folding |
| 20 | // some {LoadContext} nodes or strength reducing some {StoreContext} nodes. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 21 | class JSContextSpecialization final : public AdvancedReducer { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 22 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 23 | JSContextSpecialization(Editor* editor, JSGraph* jsgraph, |
| 24 | MaybeHandle<Context> context) |
| 25 | : AdvancedReducer(editor), jsgraph_(jsgraph), context_(context) {} |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 26 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 27 | Reduction Reduce(Node* node) final; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 28 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 29 | private: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 30 | Reduction ReduceJSLoadContext(Node* node); |
| 31 | Reduction ReduceJSStoreContext(Node* node); |
| 32 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 33 | // Returns the {Context} to specialize {node} to (if any). |
| 34 | MaybeHandle<Context> GetSpecializationContext(Node* node); |
| 35 | |
| 36 | Isolate* isolate() const; |
| 37 | JSOperatorBuilder* javascript() const; |
| 38 | JSGraph* jsgraph() const { return jsgraph_; } |
| 39 | MaybeHandle<Context> context() const { return context_; } |
| 40 | |
| 41 | JSGraph* const jsgraph_; |
| 42 | MaybeHandle<Context> context_; |
| 43 | |
| 44 | DISALLOW_COPY_AND_ASSIGN(JSContextSpecialization); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 45 | }; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 46 | |
| 47 | } // namespace compiler |
| 48 | } // namespace internal |
| 49 | } // namespace v8 |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 50 | |
| 51 | #endif // V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_ |