More VM fixes

db4
Slava Pestov 2009-05-02 10:17:05 -05:00
parent 58512cbbdb
commit 7c12b5578f
7 changed files with 17 additions and 18 deletions

View File

@ -347,7 +347,7 @@ bignum_remainder(F_BIGNUM * numerator, F_BIGNUM * denominator)
if (n == 1) return (BIGNUM_ONE (0)); \ if (n == 1) return (BIGNUM_ONE (0)); \
if (n < (type)0 && n == (type)-1) return (BIGNUM_ONE (1)); \ if (n < (type)0 && n == (type)-1) return (BIGNUM_ONE (1)); \
{ \ { \
utype accumulator = ((negative_p = (n < (utype)0)) ? (-n) : n); \ utype accumulator = ((negative_p = (n < (type)0)) ? (-n) : n); \
do \ do \
{ \ { \
(*end_digits++) = (accumulator & BIGNUM_DIGIT_MASK); \ (*end_digits++) = (accumulator & BIGNUM_DIGIT_MASK); \

View File

@ -1,15 +1,15 @@
#define FREE_LIST_COUNT 16 #define FREE_LIST_COUNT 16
#define BLOCK_SIZE_INCREMENT 32 #define BLOCK_SIZE_INCREMENT 32
typedef struct { struct F_HEAP_FREE_LIST {
F_FREE_BLOCK *small_blocks[FREE_LIST_COUNT]; F_FREE_BLOCK *small_blocks[FREE_LIST_COUNT];
F_FREE_BLOCK *large_blocks; F_FREE_BLOCK *large_blocks;
} F_HEAP_FREE_LIST; };
typedef struct { struct F_HEAP {
F_SEGMENT *segment; F_SEGMENT *segment;
F_HEAP_FREE_LIST free; F_HEAP_FREE_LIST free;
} F_HEAP; };
typedef void (*HEAP_ITERATOR)(F_BLOCK *compiled); typedef void (*HEAP_ITERATOR)(F_BLOCK *compiled);

View File

@ -4,13 +4,13 @@ void gc(void);
DLLEXPORT void minor_gc(void); DLLEXPORT void minor_gc(void);
/* statistics */ /* statistics */
typedef struct { struct F_GC_STATS {
CELL collections; CELL collections;
u64 gc_time; u64 gc_time;
u64 max_gc_time; u64 max_gc_time;
CELL object_count; CELL object_count;
u64 bytes_copied; u64 bytes_copied;
} F_GC_STATS; };
extern F_ZONE *newspace; extern F_ZONE *newspace;

View File

@ -1,7 +1,7 @@
#define IMAGE_MAGIC 0x0f0e0d0c #define IMAGE_MAGIC 0x0f0e0d0c
#define IMAGE_VERSION 4 #define IMAGE_VERSION 4
typedef struct { struct F_HEADER {
CELL magic; CELL magic;
CELL version; CELL version;
/* all pointers in the image file are relocated from /* all pointers in the image file are relocated from
@ -23,9 +23,9 @@ typedef struct {
CELL bignum_neg_one; CELL bignum_neg_one;
/* Initial user environment */ /* Initial user environment */
CELL userenv[USER_ENV]; CELL userenv[USER_ENV];
} F_HEADER; };
typedef struct { struct F_PARAMETERS {
const F_CHAR *image_path; const F_CHAR *image_path;
const F_CHAR *executable_path; const F_CHAR *executable_path;
CELL ds_size, rs_size; CELL ds_size, rs_size;
@ -36,7 +36,7 @@ typedef struct {
bool console; bool console;
bool stack_traces; bool stack_traces;
CELL max_pic_size; CELL max_pic_size;
} F_PARAMETERS; };
void load_image(F_PARAMETERS *p); void load_image(F_PARAMETERS *p);
bool save_image(const F_CHAR *file); bool save_image(const F_CHAR *file);

View File

@ -82,7 +82,7 @@ void primitive_fixnum_divmod(void)
else else
{ {
put(ds - CELLS,tag_fixnum(untag_fixnum_fast(x) / untag_fixnum_fast(y))); put(ds - CELLS,tag_fixnum(untag_fixnum_fast(x) / untag_fixnum_fast(y)));
put(ds,x % y); put(ds,(F_FIXNUM)x % (F_FIXNUM)y);
} }
} }

View File

@ -90,7 +90,6 @@ const F_CHAR *vm_executable_path(void)
void primitive_existsp(void) void primitive_existsp(void)
{ {
F_CHAR *path = unbox_u16_string(); F_CHAR *path = unbox_u16_string();
box_boolean(windows_stat(path)); box_boolean(windows_stat(path));
} }

View File

@ -200,18 +200,18 @@ INLINE CELL type_of(CELL tagged)
DEFPUSHPOP(d,ds) DEFPUSHPOP(d,ds)
DEFPUSHPOP(r,rs) DEFPUSHPOP(r,rs)
typedef struct { struct F_SEGMENT {
CELL start; CELL start;
CELL size; CELL size;
CELL end; CELL end;
} F_SEGMENT; };
/* Assembly code makes assumptions about the layout of this struct: /* Assembly code makes assumptions about the layout of this struct:
- callstack_top field is 0 - callstack_top field is 0
- callstack_bottom field is 1 - callstack_bottom field is 1
- datastack field is 2 - datastack field is 2
- retainstack field is 3 */ - retainstack field is 3 */
typedef struct _F_CONTEXT { struct F_CONTEXT {
/* C stack pointer on entry */ /* C stack pointer on entry */
F_STACK_FRAME *callstack_top; F_STACK_FRAME *callstack_top;
F_STACK_FRAME *callstack_bottom; F_STACK_FRAME *callstack_bottom;
@ -238,8 +238,8 @@ typedef struct _F_CONTEXT {
CELL catchstack_save; CELL catchstack_save;
CELL current_callback_save; CELL current_callback_save;
struct _F_CONTEXT *next; F_CONTEXT *next;
} F_CONTEXT; };
extern F_CONTEXT *stack_chain; extern F_CONTEXT *stack_chain;