v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
code-desc.h
Go to the documentation of this file.
1// Copyright 2019 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_CODE_DESC_H_
6#define V8_CODEGEN_CODE_DESC_H_
7
9
10namespace v8 {
11namespace internal {
12
13// A CodeDesc describes a buffer holding instructions and relocation
14// information. The instructions start at the beginning of the buffer
15// and grow forward, the relocation information starts at the end of
16// the buffer and grows backward. Inlined metadata sections may exist
17// at the end of the instructions.
18//
19// |<--------------- buffer_size ----------------------------------->|
20// |<---------------- instr_size ------------->| |<-reloc_size->|
21// |--------------+----------------------------+------+--------------|
22// | instructions | data | free | reloc info |
23// +--------------+----------------------------+------+--------------+
24
25// TODO(jgruber): Add a single chokepoint for specifying the instruction area
26// layout (i.e. the order of inlined metadata fields).
27// TODO(jgruber): Systematically maintain inlined metadata offsets and sizes
28// to simplify CodeDesc initialization.
29
30class CodeDesc {
31 public:
32 static void Initialize(CodeDesc* desc, Assembler* assembler,
36 int reloc_info_offset);
37
38#ifdef DEBUG
39 static void Verify(const CodeDesc* desc);
40#else
41 inline static void Verify(const CodeDesc* desc) {}
42#endif
43
44 public:
45 uint8_t* buffer = nullptr;
46 int buffer_size = 0;
47
48 // The instruction area contains executable code plus inlined metadata.
49
50 int instr_size = 0;
51
52 // Metadata packed into the instructions area.
53
56
59
62
65
68
69 // TODO(jgruber,v8:11036): Remove these functions once CodeDesc fields have
70 // been made consistent with InstructionStream layout.
71 int body_size() const { return instr_size + unwinding_info_size; }
73 int metadata_size() const { return body_size() - instruction_size(); }
89
90 // Relocation info is located at the end of the buffer and not part of the
91 // instructions area.
92
93 int reloc_offset = 0;
94 int reloc_size = 0;
95
96 // Unwinding information.
97
98 uint8_t* unwinding_info = nullptr;
101 // TODO(jgruber,v8:11036): Remove this function once unwinding_info setup
102 // is more consistent with other metadata tables.
105 }
106
107 Assembler* origin = nullptr;
108};
109
110} // namespace internal
111} // namespace v8
112
113#endif // V8_CODEGEN_CODE_DESC_H_
int instruction_size() const
Definition code-desc.h:72
int handler_table_offset_relative() const
Definition code-desc.h:77
int unwinding_info_offset_relative() const
Definition code-desc.h:100
int code_comments_offset_relative() const
Definition code-desc.h:83
static void Initialize(CodeDesc *desc, Assembler *assembler, int safepoint_table_offset, int handler_table_offset, int constant_pool_offset, int code_comments_offset, int builtin_jump_table_info_offset, int reloc_info_offset)
Definition code-desc.cc:13
uint8_t * unwinding_info
Definition code-desc.h:98
static void Verify(const CodeDesc *desc)
Definition code-desc.h:41
int metadata_size() const
Definition code-desc.h:73
int safepoint_table_offset_relative() const
Definition code-desc.h:74
int body_size() const
Definition code-desc.h:71
int builtin_jump_table_info_offset_relative() const
Definition code-desc.h:86
int constant_pool_offset_relative() const
Definition code-desc.h:80