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
8
#include "
src/common/globals.h
"
9
10
namespace
v8
{
11
namespace
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
30
class
CodeDesc
{
31
public
:
32
static
void
Initialize
(
CodeDesc
* desc,
Assembler
* assembler,
33
int
safepoint_table_offset
,
int
handler_table_offset
,
34
int
constant_pool_offset
,
int
code_comments_offset
,
35
int
builtin_jump_table_info_offset
,
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
54
int
safepoint_table_offset
= 0;
55
int
safepoint_table_size
= 0;
56
57
int
handler_table_offset
= 0;
58
int
handler_table_size
= 0;
59
60
int
constant_pool_offset
= 0;
61
int
constant_pool_size
= 0;
62
63
int
code_comments_offset
= 0;
64
int
code_comments_size
= 0;
65
66
int
builtin_jump_table_info_offset
= 0;
67
int
builtin_jump_table_info_size
= 0;
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
; }
72
int
instruction_size
()
const
{
return
safepoint_table_offset
; }
73
int
metadata_size
()
const
{
return
body_size
() -
instruction_size
(); }
74
int
safepoint_table_offset_relative
()
const
{
75
return
safepoint_table_offset
-
instruction_size
();
76
}
77
int
handler_table_offset_relative
()
const
{
78
return
handler_table_offset
-
instruction_size
();
79
}
80
int
constant_pool_offset_relative
()
const
{
81
return
constant_pool_offset
-
instruction_size
();
82
}
83
int
code_comments_offset_relative
()
const
{
84
return
code_comments_offset
-
instruction_size
();
85
}
86
int
builtin_jump_table_info_offset_relative
()
const
{
87
return
builtin_jump_table_info_offset
-
instruction_size
();
88
}
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
;
99
int
unwinding_info_size
= 0;
100
int
unwinding_info_offset_relative
()
const
{
101
// TODO(jgruber,v8:11036): Remove this function once unwinding_info setup
102
// is more consistent with other metadata tables.
103
return
builtin_jump_table_info_offset_relative
() +
104
builtin_jump_table_info_size
;
105
}
106
107
Assembler
*
origin
=
nullptr
;
108
};
109
110
}
// namespace internal
111
}
// namespace v8
112
113
#endif
// V8_CODEGEN_CODE_DESC_H_
v8::internal::Assembler
Definition
assembler-x64.h:484
v8::internal::CodeDesc
Definition
code-desc.h:30
v8::internal::CodeDesc::instruction_size
int instruction_size() const
Definition
code-desc.h:72
v8::internal::CodeDesc::buffer
uint8_t * buffer
Definition
code-desc.h:45
v8::internal::CodeDesc::handler_table_offset_relative
int handler_table_offset_relative() const
Definition
code-desc.h:77
v8::internal::CodeDesc::safepoint_table_size
int safepoint_table_size
Definition
code-desc.h:55
v8::internal::CodeDesc::unwinding_info_offset_relative
int unwinding_info_offset_relative() const
Definition
code-desc.h:100
v8::internal::CodeDesc::code_comments_offset_relative
int code_comments_offset_relative() const
Definition
code-desc.h:83
v8::internal::CodeDesc::unwinding_info_size
int unwinding_info_size
Definition
code-desc.h:99
v8::internal::CodeDesc::Initialize
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
v8::internal::CodeDesc::reloc_size
int reloc_size
Definition
code-desc.h:94
v8::internal::CodeDesc::origin
Assembler * origin
Definition
code-desc.h:107
v8::internal::CodeDesc::unwinding_info
uint8_t * unwinding_info
Definition
code-desc.h:98
v8::internal::CodeDesc::handler_table_offset
int handler_table_offset
Definition
code-desc.h:57
v8::internal::CodeDesc::builtin_jump_table_info_size
int builtin_jump_table_info_size
Definition
code-desc.h:67
v8::internal::CodeDesc::handler_table_size
int handler_table_size
Definition
code-desc.h:58
v8::internal::CodeDesc::Verify
static void Verify(const CodeDesc *desc)
Definition
code-desc.h:41
v8::internal::CodeDesc::metadata_size
int metadata_size() const
Definition
code-desc.h:73
v8::internal::CodeDesc::safepoint_table_offset_relative
int safepoint_table_offset_relative() const
Definition
code-desc.h:74
v8::internal::CodeDesc::constant_pool_offset
int constant_pool_offset
Definition
code-desc.h:60
v8::internal::CodeDesc::buffer_size
int buffer_size
Definition
code-desc.h:46
v8::internal::CodeDesc::body_size
int body_size() const
Definition
code-desc.h:71
v8::internal::CodeDesc::reloc_offset
int reloc_offset
Definition
code-desc.h:93
v8::internal::CodeDesc::code_comments_size
int code_comments_size
Definition
code-desc.h:64
v8::internal::CodeDesc::builtin_jump_table_info_offset_relative
int builtin_jump_table_info_offset_relative() const
Definition
code-desc.h:86
v8::internal::CodeDesc::builtin_jump_table_info_offset
int builtin_jump_table_info_offset
Definition
code-desc.h:66
v8::internal::CodeDesc::safepoint_table_offset
int safepoint_table_offset
Definition
code-desc.h:54
v8::internal::CodeDesc::instr_size
int instr_size
Definition
code-desc.h:50
v8::internal::CodeDesc::constant_pool_size
int constant_pool_size
Definition
code-desc.h:61
v8::internal::CodeDesc::constant_pool_offset_relative
int constant_pool_offset_relative() const
Definition
code-desc.h:80
v8::internal::CodeDesc::code_comments_offset
int code_comments_offset
Definition
code-desc.h:63
globals.h
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
src
codegen
code-desc.h
Generated on Sun Apr 6 2025 21:08:50 for v8 by
1.12.0