v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
builtin-jump-table-info-x64.h
Go to the documentation of this file.
1// Copyright 2024 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_CODEGEN_X64_BUILTIN_JUMP_TABLE_INFO_X64_H_
6#define V8_CODEGEN_X64_BUILTIN_JUMP_TABLE_INFO_X64_H_
7
8#include <vector>
9
10#include "include/v8-internal.h"
11#include "src/base/macros.h"
12#include "src/common/globals.h"
13
14namespace v8 {
15namespace internal {
16
17class Assembler;
18
19// The builtin jump table info is a part of code metadata, used by the
20// disassembler. The layout is:
21//
22// byte count content
23// ----------------------------------------------------------------
24// [Inline array of BuiltinJumpTableInfoEntry in increasing pc_offset order]
25// ┌ 4 pc_offset of entry as uint32_t
26// └ 4 target of entry as int32_t
27
29 constexpr BuiltinJumpTableInfoEntry(uint32_t pc_offset, int32_t target)
30 : pc_offset(pc_offset), target(target) {}
31 uint32_t pc_offset;
32 int32_t target;
33
34 static constexpr int kPCOffsetSize = kUInt32Size;
35 static constexpr int kTargetSize = kInt32Size;
36 static constexpr int kSize = kPCOffsetSize + kTargetSize;
37};
38static_assert(sizeof(BuiltinJumpTableInfoEntry) ==
40
41// Used during codegen.
43 public:
44 V8_EXPORT_PRIVATE void Add(uint32_t pc_offset, int32_t target);
45 void Emit(Assembler* assm);
46
47 size_t entry_count() const;
48 uint32_t size_in_bytes() const;
49
50 private:
51 std::vector<BuiltinJumpTableInfoEntry> entries_;
52};
53
54// Used during disassembly.
56 public:
57 BuiltinJumpTableInfoIterator(Address start, uint32_t size);
58 uint32_t GetPCOffset() const;
59 int32_t GetTarget() const;
60 void Next();
61 bool HasCurrent() const;
62
63 private:
64 const Address start_;
65 const uint32_t size_;
66 Address cursor_;
67};
68
69} // namespace internal
70} // namespace v8
71
72#endif // V8_CODEGEN_X64_BUILTIN_JUMP_TABLE_INFO_X64_H_
std::vector< BuiltinJumpTableInfoEntry > entries_
V8_EXPORT_PRIVATE void Add(uint32_t pc_offset, int32_t target)
int start
int pc_offset
constexpr int kInt32Size
Definition globals.h:401
constexpr int kUInt32Size
Definition globals.h:403
#define V8_EXPORT_PRIVATE
Definition macros.h:460
constexpr BuiltinJumpTableInfoEntry(uint32_t pc_offset, int32_t target)