// Copyright 2023 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #if !V8_ENABLE_WEBASSEMBLY #error This header should only be included if WebAssembly is enabled. #endif // !V8_ENABLE_WEBASSEMBLY #ifndef V8_WASM_INLINING_TREE_H_ #define V8_WASM_INLINING_TREE_H_ #include <cstdint> #include <queue> #include <vector> #include "src/utils/utils.h" #include "src/wasm/compilation-environment.h" #include "src/wasm/wasm-module.h" namespace v8::internal::wasm { // Represents a tree of inlining decisions. // A node in the tree represents a function frame, and `function_calls_` // represent all direct/call_ref/call_indirect function calls in this frame. // Each element of `function_calls_` is itself a `Vector` of `InliningTree`s, // corresponding to the different speculative candidates for a // call_ref/call_indirect; for a direct call, it has a single element. // If a transitive element of `function_calls_` has its `is_inlined_` field set, // it should be inlined into the caller. // We have this additional datastructure for Turboshaft, since nodes in the // Turboshaft IR aren't easily expanded incrementally, so all the inlining // decisions are already made before graph building on this abstracted form of // the code. class InliningTree : public ZoneObject { … }; void InliningTree::Inline() { … } struct TreeNodeOrdering { … }; void InliningTree::FullyExpand() { … } // Returns true if there is still enough budget left to inline the current // candidate given the initial graph size and the already inlined wire bytes. bool InliningTree::SmallEnoughToInline(size_t initial_wire_byte_size, size_t inlined_wire_byte_count) { … } } // namespace v8::internal::wasm #endif // V8_WASM_INLINING_TREE_H_