blob: 819553ca543db604f02426163c22c88f9d345a36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*
* %CopyrightBegin%
*
* Copyright Ericsson AB 2020-2021. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* %CopyrightEnd%
*/
#ifndef _ASM_LOAD_H
#define _ASM_LOAD_H
/*
* Type for a label.
*/
typedef struct {
Uint value; /* Value of label (0 if not known yet). */
int looprec_targeted; /* Non-zero if this label is the target of a
* loop_rec instruction. */
int lambda_index; /* The lambda index of this label, or -1 if not
* a target of a lambda. */
} Label;
/*
* This structure associates a code offset with a source code location.
*/
typedef struct {
int pos; /* Position in code */
int loc; /* Location in source code */
} LineInstr;
/* This structure contains all information about the module being loaded. */
struct LoaderState_ {
/*
* The following are used mainly for diagnostics.
*/
Eterm group_leader; /* Group leader (for diagnostics). */
Eterm module; /* Tagged atom for module name. */
Eterm function; /* Tagged atom for current function (or 0 if none). */
unsigned arity; /* Arity for current function. */
/*
* Used for code loading (mainly).
*/
int specific_op; /* Specific opcode (-1 if not found). */
const BeamCodeHeader *code_hdr; /* Actual code header */
BeamCodeHeader *load_hdr; /* Code header during load */
int codev_size; /* Size of code buffer in words. */
int ci; /* Current index into loaded code buffer. */
Label *labels;
unsigned loaded_size; /* Final size of code when loaded. */
int may_load_nif; /* true if NIFs may later be loaded for this module */
const ErtsCodeInfo *on_load; /* Pointer to the on_load function, if any */
unsigned max_opcode; /* Highest opcode used in module */
/*
* Generic instructions.
*/
BeamOp *genop; /* The last generic instruction seen. */
BifEntry **bif_imports;
/*
* Line table.
*/
LineInstr *line_instr; /* Line instructions */
unsigned int current_li; /* Current line instruction */
unsigned int *func_line; /* Mapping from function to first line instr */
void *ba; /* Assembler used to create x86 assembly */
const void *native_module_exec; /* Native module after codegen */
void *native_module_rw; /* Native module after codegen, writable mapping */
int function_number;
int last_label;
BeamOpAllocator op_allocator;
BeamFile beam;
};
#endif
|