Line data Source code
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_CODE_DESC_H_
6 : #define V8_CODE_DESC_H_
7 :
8 : #include "src/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 2515379 : 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 reloc_info_offset);
36 :
37 : #ifdef DEBUG
38 : static void Verify(const CodeDesc* desc);
39 : #else
40 : inline static void Verify(const CodeDesc* desc) {}
41 : #endif
42 :
43 : public:
44 : byte* buffer = nullptr;
45 : int buffer_size = 0;
46 :
47 : // The instruction area contains executable code plus inlined metadata.
48 :
49 : int instr_size = 0;
50 :
51 : // Metadata packed into the instructions area.
52 :
53 : int safepoint_table_offset = 0;
54 : int safepoint_table_size = 0;
55 :
56 : int handler_table_offset = 0;
57 : int handler_table_size = 0;
58 :
59 : int constant_pool_offset = 0;
60 : int constant_pool_size = 0;
61 :
62 : int code_comments_offset = 0;
63 : int code_comments_size = 0;
64 :
65 : // Relocation info is located at the end of the buffer and not part of the
66 : // instructions area.
67 :
68 : int reloc_offset = 0;
69 : int reloc_size = 0;
70 :
71 : // Unwinding information.
72 : // TODO(jgruber,mstarzinger): Pack this into the inlined metadata section.
73 :
74 : byte* unwinding_info = nullptr;
75 : int unwinding_info_size = 0;
76 :
77 : Assembler* origin = nullptr;
78 : };
79 :
80 : } // namespace internal
81 : } // namespace v8
82 :
83 : #endif // V8_CODE_DESC_H_
|