v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
wasm-address-reassociation.h
Go to the documentation of this file.
1// Copyright 2023 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_WASM_ADDRESS_REASSOCIATION_H_
6#define V8_COMPILER_WASM_ADDRESS_REASSOCIATION_H_
7
10
11namespace v8 {
12namespace internal {
13
14namespace compiler {
15
16// Forward declarations.
17class CommonOperatorBuilder;
18class TFGraph;
19class JSGraph;
20class MachineOperatorBuilder;
21class Node;
22
24 public:
28
29 void Optimize();
30 void VisitProtectedMemOp(Node* node, NodeId effect_chain);
31
32 private:
33 // Use the ids of nodes that represent a base and offset, together with an
34 // effect-chain root node id, to create a key for our candidate maps.
35 using CandidateAddressKey = std::tuple<NodeId, NodeId, NodeId>;
36
37 // Holds two nodes that could be summed to create a new base address. We
38 // store these in a map accessed with the above key.
40 public:
42 : base_reg_(base), offset_reg_(offset) {}
43 Node* base() const { return base_reg_; }
44 Node* offset() const { return offset_reg_; }
45
46 private:
49 };
50
51 // For a given CandidateBaseAddr, collect loads and stores that could use the
52 // shared object along an immediate index. These are collected in a map which
53 // is accessed with a CandidateAddressKey.
55 public:
56 explicit CandidateMemOps(Zone* zone) : mem_ops_(zone), imm_offsets_(zone) {}
57 void AddCandidate(Node* mem_op, int64_t imm_offset);
58 size_t GetNumNodes() const;
59 Node* mem_op(size_t i) const;
60 int64_t imm_offset(size_t i) const;
61
62 private:
65 };
66
67 bool ShouldTryOptimize(const CandidateAddressKey& key) const;
68 Node* CreateNewBase(const CandidateAddressKey& key);
69 bool HasCandidateBaseAddr(const CandidateAddressKey& key) const;
70 void AddCandidate(Node* mem_op, Node* base, Node* reg_offset,
71 int64_t imm_offset, NodeId effect_chain);
72 void ReplaceInputs(Node* mem_op, Node* object, Node* index);
73
79 Zone* const zone_;
80};
81
82} // namespace compiler
83} // namespace internal
84} // namespace v8
85
86#endif // V8_COMPILER_WASM_ADDRESS_REASSOCIATION_H_
JSGraph * jsgraph
void VisitProtectedMemOp(Node *node, NodeId effect_chain)
std::tuple< NodeId, NodeId, NodeId > CandidateAddressKey
WasmAddressReassociation(const WasmAddressReassociation &)=delete
ZoneMap< CandidateAddressKey, CandidateMemOps > candidates_
ZoneMap< CandidateAddressKey, CandidateBaseAddr > candidate_base_addrs_
WasmAddressReassociation & operator=(const WasmAddressReassociation &)=delete
WasmAddressReassociation(JSGraph *jsgraph, Zone *zone)
int32_t offset
#define V8_EXPORT_PRIVATE
Definition macros.h:460
std::unique_ptr< ValueMirror > key