39 lines
939 B
C
39 lines
939 B
C
|
|
#ifndef MEMORY_H
|
||
|
|
#define MEMORY_H
|
||
|
|
|
||
|
|
#include "types.h"
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
int sp_high_water;
|
||
|
|
int loc_cnt_high_water;
|
||
|
|
int call_depth;
|
||
|
|
int max_call_depth;
|
||
|
|
int total_allocations;
|
||
|
|
int total_deallocations;
|
||
|
|
} MemoryStats;
|
||
|
|
|
||
|
|
extern MemoryStats mem_stats;
|
||
|
|
|
||
|
|
void mem_init(void);
|
||
|
|
void mem_dump_stats(void);
|
||
|
|
|
||
|
|
int mem_check_sp(int required_sp, const char *context);
|
||
|
|
int mem_check_addr(int addr, const char *context);
|
||
|
|
int mem_check_loc_cnt(int required_cnt, const char *context);
|
||
|
|
|
||
|
|
long mem_read(int addr, const char *context);
|
||
|
|
void mem_write(int addr, long value, const char *context);
|
||
|
|
|
||
|
|
int mem_push(long value, const char *context);
|
||
|
|
long mem_pop(const char *context);
|
||
|
|
|
||
|
|
void mem_alloc_var(int size, const char *var_name);
|
||
|
|
void mem_free_frame(int old_sp, int old_loc_cnt, const char *context);
|
||
|
|
|
||
|
|
void mem_enter_call(const char *func_name);
|
||
|
|
void mem_exit_call(const char *func_name);
|
||
|
|
|
||
|
|
void mem_trace_state(const char *label);
|
||
|
|
|
||
|
|
#endif
|