v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
wasm-assembler-helpers.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_TURBOSHAFT_WASM_ASSEMBLER_HELPERS_H_
6#define V8_COMPILER_TURBOSHAFT_WASM_ASSEMBLER_HELPERS_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
13#include "src/roots/roots.h"
14
16
17struct RootTypes {
18#define DEFINE_TYPE(type, name, CamelName) using k##CamelName##Type = type;
20#undef DEFINE_TYPE
21};
22
23template <typename AssemblerT>
24OpIndex LoadRootHelper(AssemblerT&& assembler, RootIndex index) {
26 // Note that we skip the bit cast here as the value does not need to be
27 // tagged as the object will never be collected / moved.
28 return assembler.Load(
29 assembler.LoadRootRegister(), LoadOp::Kind::RawAligned().Immutable(),
31 } else {
32 return assembler.BitcastWordPtrToTagged(assembler.Load(
33 assembler.LoadRootRegister(), LoadOp::Kind::RawAligned(),
35 }
36}
37
38#define LOAD_INSTANCE_FIELD(instance, name, representation) \
39 __ Load(instance, LoadOp::Kind::TaggedBase(), representation, \
40 WasmTrustedInstanceData::k##name##Offset)
41
42#define LOAD_PROTECTED_INSTANCE_FIELD(instance, name, type) \
43 V<type>::Cast(__ LoadProtectedPointerField( \
44 instance, LoadOp::Kind::TaggedBase(), \
45 WasmTrustedInstanceData::kProtected##name##Offset))
46
47#define LOAD_IMMUTABLE_PROTECTED_INSTANCE_FIELD(instance, name, type) \
48 V<type>::Cast(__ LoadProtectedPointerField( \
49 instance, LoadOp::Kind::TaggedBase().Immutable(), \
50 WasmTrustedInstanceData::kProtected##name##Offset))
51
52#define LOAD_IMMUTABLE_INSTANCE_FIELD(instance, name, representation) \
53 __ Load(instance, LoadOp::Kind::TaggedBase().Immutable(), representation, \
54 WasmTrustedInstanceData::k##name##Offset)
55
56#define LOAD_ROOT(name) \
57 V<compiler::turboshaft::RootTypes::k##name##Type>::Cast( \
58 LoadRootHelper(Asm(), RootIndex::k##name))
59
60} // namespace v8::internal::compiler::turboshaft
61
62#endif // V8_COMPILER_TURBOSHAFT_WASM_ASSEMBLER_HELPERS_H_
static constexpr int root_slot_offset(RootIndex root_index)
static constexpr bool IsImmortalImmovable(RootIndex root_index)
Definition roots.h:616
static constexpr MemoryRepresentation UintPtr()
OpIndex LoadRootHelper(AssemblerT &&assembler, RootIndex index)
#define ROOT_LIST(V)
Definition roots.h:488
#define DEFINE_TYPE(type, name, CamelName)