v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
late-escape-analysis-reducer.h
Go to the documentation of this file.
1// Copyright 2022 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_TURBOSHAFT_LATE_ESCAPE_ANALYSIS_REDUCER_H_
6#define V8_COMPILER_TURBOSHAFT_LATE_ESCAPE_ANALYSIS_REDUCER_H_
7
12#include "src/zone/zone.h"
13
15
16// LateEscapeAnalysis removes allocation that have no uses besides the stores
17// initializing the object.
18
20 public:
22 : graph_(graph), phase_zone_(zone), alloc_uses_(zone), allocs_(zone) {}
23
24 void Run();
25
26 private:
27 void RecordAllocateUse(OpIndex alloc, OpIndex use);
28
31 bool AllocationIsEscaping(OpIndex alloc);
32 bool EscapesThroughUse(OpIndex alloc, OpIndex using_op_idx);
33 void MarkToRemove(OpIndex alloc);
34
37
38 // {alloc_uses_} records all the uses of each AllocateOp.
40 // {allocs_} is filled with all of the AllocateOp of the graph, and then
41 // iterated upon to determine which allocations can be removed and which
42 // cannot.
44};
45
46template <class Next>
47class LateEscapeAnalysisReducer : public Next {
48 public:
50
51 void Analyze() {
52 analyzer_.Run();
53 Next::Analyze();
54 }
55
56 private:
57 LateEscapeAnalysisAnalyzer analyzer_{Asm().modifiable_input_graph(),
58 Asm().phase_zone()};
59};
60
61} // namespace v8::internal::compiler::turboshaft
62
63#endif // V8_COMPILER_TURBOSHAFT_LATE_ESCAPE_ANALYSIS_REDUCER_H_
ZoneAbslFlatHashMap< OpIndex, ZoneVector< OpIndex > > alloc_uses_
#define TURBOSHAFT_REDUCER_BOILERPLATE(Name)
Definition assembler.h:823