Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 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_ESCAPE_ANALYSIS_REDUCER_H_ |
| 6 | #define V8_COMPILER_ESCAPE_ANALYSIS_REDUCER_H_ |
| 7 | |
| 8 | #include "src/bit-vector.h" |
| 9 | #include "src/compiler/escape-analysis.h" |
| 10 | #include "src/compiler/graph-reducer.h" |
| 11 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 12 | namespace v8 { |
| 13 | namespace internal { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 14 | namespace compiler { |
| 15 | |
| 16 | // Forward declarations. |
| 17 | class JSGraph; |
| 18 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 19 | class EscapeAnalysisReducer final : public AdvancedReducer { |
| 20 | public: |
| 21 | EscapeAnalysisReducer(Editor* editor, JSGraph* jsgraph, |
| 22 | EscapeAnalysis* escape_analysis, Zone* zone); |
| 23 | |
| 24 | Reduction Reduce(Node* node) final; |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 25 | |
| 26 | // Verifies that all virtual allocation nodes have been dealt with. Run it |
| 27 | // after this reducer has been applied. Has no effect in release mode. |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 28 | void VerifyReplacement() const; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 29 | |
| 30 | private: |
| 31 | Reduction ReduceLoad(Node* node); |
| 32 | Reduction ReduceStore(Node* node); |
| 33 | Reduction ReduceAllocate(Node* node); |
| 34 | Reduction ReduceFinishRegion(Node* node); |
| 35 | Reduction ReduceReferenceEqual(Node* node); |
| 36 | Reduction ReduceObjectIsSmi(Node* node); |
| 37 | Reduction ReduceFrameStateUses(Node* node); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 38 | Node* ReduceDeoptState(Node* node, Node* effect, bool multiple_users); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 39 | Node* ReduceStateValueInput(Node* node, int node_index, Node* effect, |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 40 | bool node_multiused, bool already_cloned, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 41 | bool multiple_users); |
| 42 | |
| 43 | JSGraph* jsgraph() const { return jsgraph_; } |
| 44 | EscapeAnalysis* escape_analysis() const { return escape_analysis_; } |
| 45 | Zone* zone() const { return zone_; } |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 46 | Isolate* isolate() const; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 47 | |
| 48 | JSGraph* const jsgraph_; |
| 49 | EscapeAnalysis* escape_analysis_; |
| 50 | Zone* const zone_; |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 51 | // This bit vector marks nodes we already processed (allocs, loads, stores) |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 52 | // and nodes that do not need a visit from ReduceDeoptState etc. |
| 53 | BitVector fully_reduced_; |
| 54 | bool exists_virtual_allocate_; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 55 | |
| 56 | DISALLOW_COPY_AND_ASSIGN(EscapeAnalysisReducer); |
| 57 | }; |
| 58 | |
| 59 | } // namespace compiler |
| 60 | } // namespace internal |
| 61 | } // namespace v8 |
| 62 | |
| 63 | #endif // V8_COMPILER_ESCAPE_ANALYSIS_REDUCER_H_ |