v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
local-decl-encoder.h
Go to the documentation of this file.
1// Copyright 2017 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_WASM_LOCAL_DECL_ENCODER_H_
6#define V8_WASM_LOCAL_DECL_ENCODER_H_
7
8#if !V8_ENABLE_WEBASSEMBLY
9#error This header should only be included if WebAssembly is enabled.
10#endif // !V8_ENABLE_WEBASSEMBLY
11
12#include "src/common/globals.h"
15#include "src/zone/zone.h"
16
17namespace v8 {
18namespace internal {
19namespace wasm {
20
21// A helper for encoding local declarations prepended to the body of a function.
23 public:
24 explicit LocalDeclEncoder(Zone* zone, const FunctionSig* s = nullptr)
25 : sig(s), local_decls(zone), total(0) {}
26
27 // Prepend local declarations by creating a new buffer and copying data
28 // over. The new buffer must be delete[]'d by the caller.
29 void Prepend(Zone* zone, const uint8_t** start, const uint8_t** end) const;
30
31 size_t Emit(uint8_t* buffer) const;
32
33 // Add locals declarations to this helper. Return the index of the newly added
34 // local(s), with an optional adjustment for the parameters.
35 uint32_t AddLocals(uint32_t count, ValueType type);
36
37 size_t Size() const;
38
39 bool has_sig() const { return sig != nullptr; }
40 const FunctionSig* get_sig() const { return sig; }
41 void set_sig(const FunctionSig* s) { sig = s; }
42
43 private:
46 size_t total;
47};
48
49} // namespace wasm
50} // namespace internal
51} // namespace v8
52
53#endif // V8_WASM_LOCAL_DECL_ENCODER_H_
LocalDeclEncoder(Zone *zone, const FunctionSig *s=nullptr)
const FunctionSig * get_sig() const
ZoneVector< std::pair< uint32_t, ValueType > > local_decls
int start
int end
int s
Definition mul-fft.cc:297
kWasmInternalFunctionIndirectPointerTag kProtectedInstanceDataOffset sig
Definition c-api.cc:87
#define V8_EXPORT_PRIVATE
Definition macros.h:460