-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjit.c
executable file
·73 lines (55 loc) · 1.33 KB
/
jit.c
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
#include <stdio.h>
#include "virtual.h"
#include "jit.h"
jit_context_t *create_jit_context(uint8_t *bytecode, unsigned int bytecode_size)
{
jit_context_t *n = malloc(sizeof(jit_context_t));
n->bytecode = bytecode;
n->bytecode_size = bytecode_size;
n->memory = malloc(1024 * 1024);
n->memory_offset = 0;
n->entries = NULL;
n->last_entry = NULL;
n->relocs = NULL;
n->last_reloc = NULL;
jit_entry_t *first_entry = create_jit_entry(bytecode);
add_entry(n, first_entry);
return n;
}
void release_jit_context(jit_context_t *context)
{
}
void add_entry(jit_context_t *context, jit_entry_t *entry)
{
if(context->last_entry == NULL) {
context->entries = entry;
context->last_entry = entry;
} else {
context->last_entry->next = entry;
context->last_entry = entry;
}
}
void add_reloc(jit_context_t *context, jit_reloc_t *reloc)
{
if(context->last_reloc == NULL) {
context->relocs = reloc;
context->last_reloc = reloc;
} else {
context->last_reloc->next = reloc;
context->last_reloc = reloc;
}
}
jit_entry_t *create_jit_entry(uint8_t *bytecode)
{
jit_entry_t *n = malloc(sizeof(jit_entry_t));
n->bytecode = bytecode;
n->jitted_addr = NULL;
n->next = NULL;
return n;
}
void do_jit(jit_context_t *context)
{
}
void run_jit(jit_context_t *context)
{
}