mem.h 859 Bytes
Newer Older
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
1
2
3
#ifndef __MEM_H
#define __MEM_H

Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
4
5
#include "thunk.h"

Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
6
7
#define STACK_SIZE_A 10240*50
#define STACK_SIZE_B 10240*50
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
8

9
extern int stack_top_a;
10
extern int stack_top_b;
11
extern Thunk* stack_a[STACK_SIZE_A];
12
extern Thunk  stack_b[STACK_SIZE_B];
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
13

14
15
extern char* heap_curr;

16
17
18
19
#define peek_a() stack_a[stack_top_a-1]
#define pop_a() stack_a[--stack_top_a]
#define push_a(r) stack_a[stack_top_a++]=(r)

20
#define local(base, idx) stack_a[base+idx]
21
22
#define set_return(base, r) stack_a[base-1]=(r)
#define destroy_stack_frame(base) stack_top_a = base
23
#define get_dst(base) stack_a[base-1]
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
24

25
#define alloc_b() &stack_b[stack_top_b++]
26
27
28

#define destroy_stack_frame_b(base) stack_top_b = base

Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
29
void init_mem();
30
void print_stat();
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
31
32

// TODO: inline
33
void* alloc_desc(int size);
Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
34

35
36
37
// TODO: inline
void* alloc_code(int size);

38
39
40
// TODO: inline
void* alloc_heap(int size);

Laszlo Domoszlai's avatar
Laszlo Domoszlai committed
41
#endif // __MEM_H