v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
memory-optimizer.h
Go to the documentation of this file.
1// Copyright 2016 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_MEMORY_OPTIMIZER_H_
6#define V8_COMPILER_MEMORY_OPTIMIZER_H_
7
11
12#ifdef V8_ENABLE_WEBASSEMBLY
14#else
15namespace v8 {
16namespace internal {
17namespace compiler {
18
19class V8_EXPORT_PRIVATE WasmAddressReassociation final {
20 public:
22 void Optimize() {}
23 void VisitProtectedMemOp(Node* node, uint32_t effect_chain) {}
24};
25
26} // namespace compiler
27} // namespace internal
28} // namespace v8
29#endif
30
31namespace v8 {
32namespace internal {
33
34class TickCounter;
35
36namespace compiler {
37
38class JSGraph;
39class TFGraph;
40
41// NodeIds are identifying numbers for nodes that can be used to index auxiliary
42// out-of-line data associated with each node.
43using NodeId = uint32_t;
44
45// Performs allocation folding and store write barrier elimination
46// implicitly, while lowering all simplified memory access and allocation
47// related nodes (i.e. Allocate, LoadField, StoreField and friends) to machine
48// operators.
49class MemoryOptimizer final {
50 public:
52 MemoryLowering::AllocationFolding allocation_folding,
53 const char* function_debug_name, TickCounter* tick_counter,
54 bool is_wasm);
55 ~MemoryOptimizer() = default;
56
57 void Optimize();
58
59 private:
61
62 // An array of allocation states used to collect states on merges.
64
65 // We thread through tokens to represent the current state on a given effect
66 // path through the graph.
67 struct Token {
70 // The most recent EffectPhi in the chain, which is used as a heuristic by
71 // address reassociation.
73 };
74
75 void VisitNode(Node*, AllocationState const*, NodeId);
77 void VisitCall(Node*, AllocationState const*, NodeId);
86 void VisitStore(Node*, AllocationState const*, NodeId);
88
89 AllocationState const* MergeStates(AllocationStates const& states);
90
91 void EnqueueMerge(Node*, int, AllocationState const*);
92 void EnqueueUses(Node*, AllocationState const*, NodeId);
93 void EnqueueUse(Node*, int, AllocationState const*, NodeId);
94
95 void ReplaceUsesAndKillNode(Node* node, Node* replacement);
96
97 // Returns true if the AllocationType of the current AllocateRaw node that we
98 // are visiting needs to be updated to kOld, due to propagation of tenuring
99 // from outer to inner allocations.
100 bool AllocationTypeNeedsUpdateToOld(Node* const user, const Edge edge);
101
102 AllocationState const* empty_state() const { return empty_state_; }
107 TFGraph* graph() const;
108 JSGraph* jsgraph() const { return jsgraph_; }
109 Zone* zone() const { return zone_; }
110
118 Zone* const zone_;
120
122};
123
124} // namespace compiler
125} // namespace internal
126} // namespace v8
127
128#endif // V8_COMPILER_MEMORY_OPTIMIZER_H_
JSGraph * jsgraph
void EnqueueMerge(Node *, int, AllocationState const *)
void VisitOtherEffect(Node *, AllocationState const *, NodeId)
void VisitAllocateRaw(Node *, AllocationState const *, NodeId)
ZoneMap< NodeId, AllocationStates > pending_
AllocationState const * MergeStates(AllocationStates const &states)
void VisitNode(Node *, AllocationState const *, NodeId)
void VisitProtectedLoad(Node *, AllocationState const *, NodeId)
void VisitStoreToObject(Node *, AllocationState const *, NodeId)
MemoryOptimizer(JSHeapBroker *broker, JSGraph *jsgraph, Zone *zone, MemoryLowering::AllocationFolding allocation_folding, const char *function_debug_name, TickCounter *tick_counter, bool is_wasm)
void VisitLoadElement(Node *, AllocationState const *, NodeId)
void VisitLoadField(Node *, AllocationState const *, NodeId)
void EnqueueUses(Node *, AllocationState const *, NodeId)
WasmAddressReassociation wasm_address_reassociation_
AllocationState const *const empty_state_
void VisitLoadFromObject(Node *, AllocationState const *, NodeId)
AllocationState const * empty_state() const
void VisitCall(Node *, AllocationState const *, NodeId)
void VisitStore(Node *, AllocationState const *, NodeId)
WasmAddressReassociation * wasm_address_reassociation()
void VisitProtectedStore(Node *, AllocationState const *, NodeId)
void EnqueueUse(Node *, int, AllocationState const *, NodeId)
void VisitStoreElement(Node *, AllocationState const *, NodeId)
void ReplaceUsesAndKillNode(Node *node, Node *replacement)
void VisitStoreField(Node *, AllocationState const *, NodeId)
bool AllocationTypeNeedsUpdateToOld(Node *const user, const Edge edge)
void VisitProtectedMemOp(Node *node, uint32_t effect_chain)
WasmAddressReassociation(JSGraph *jsgraph, Zone *zone)
JSHeapBroker * broker
#define V8_EXPORT_PRIVATE
Definition macros.h:460