vm: minor fixes after code review

db4
Slava Pestov 2009-11-03 04:56:58 -06:00
parent 51e9a891a8
commit ed3ab1335e
5 changed files with 24 additions and 23 deletions

View File

@ -39,6 +39,7 @@ void factor_vm::throw_error(cell error, stack_frame *callstack_top)
/* Reset local roots */ /* Reset local roots */
data_roots.clear(); data_roots.clear();
bignum_roots.clear(); bignum_roots.clear();
code_roots.clear();
/* If we had an underflow or overflow, stack pointers might be /* If we had an underflow or overflow, stack pointers might be
out of bounds */ out of bounds */

View File

@ -139,7 +139,7 @@ code_block *factor_vm::compile_inline_cache(fixnum index,
return code; return code;
} }
/* A generic word's definition performs general method lookup. Allocates memory */ /* A generic word's definition performs general method lookup. */
void *factor_vm::megamorphic_call_stub(cell generic_word) void *factor_vm::megamorphic_call_stub(cell generic_word)
{ {
return untag<word>(generic_word)->xt; return untag<word>(generic_word)->xt;
@ -174,7 +174,7 @@ void factor_vm::update_pic_transitions(cell pic_size)
ic_to_pic_transitions++; ic_to_pic_transitions++;
} }
/* The cache_entries parameter is either f (on cold call site) or an array /* The cache_entries parameter is empty (on cold call site) or has entries
(on cache miss). Called from assembly with the actual return address. (on cache miss). Called from assembly with the actual return address.
Compilation of the inline cache may trigger a GC, which may trigger a compaction; Compilation of the inline cache may trigger a GC, which may trigger a compaction;
also, the block containing the return address may now be dead. Use a code_root also, the block containing the return address may now be dead. Use a code_root

View File

@ -379,7 +379,7 @@ fixnum factor_vm::to_fixnum(cell tagged)
} }
} }
VM_C_API fixnum to_fixnum(cell tagged,factor_vm *parent) VM_C_API fixnum to_fixnum(cell tagged, factor_vm *parent)
{ {
return parent->to_fixnum(tagged); return parent->to_fixnum(tagged);
} }
@ -399,7 +399,7 @@ void factor_vm::box_signed_1(s8 n)
dpush(tag_fixnum(n)); dpush(tag_fixnum(n));
} }
VM_C_API void box_signed_1(s8 n,factor_vm *parent) VM_C_API void box_signed_1(s8 n, factor_vm *parent)
{ {
return parent->box_signed_1(n); return parent->box_signed_1(n);
} }
@ -409,7 +409,7 @@ void factor_vm::box_unsigned_1(u8 n)
dpush(tag_fixnum(n)); dpush(tag_fixnum(n));
} }
VM_C_API void box_unsigned_1(u8 n,factor_vm *parent) VM_C_API void box_unsigned_1(u8 n, factor_vm *parent)
{ {
return parent->box_unsigned_1(n); return parent->box_unsigned_1(n);
} }
@ -419,7 +419,7 @@ void factor_vm::box_signed_2(s16 n)
dpush(tag_fixnum(n)); dpush(tag_fixnum(n));
} }
VM_C_API void box_signed_2(s16 n,factor_vm *parent) VM_C_API void box_signed_2(s16 n, factor_vm *parent)
{ {
return parent->box_signed_2(n); return parent->box_signed_2(n);
} }
@ -429,7 +429,7 @@ void factor_vm::box_unsigned_2(u16 n)
dpush(tag_fixnum(n)); dpush(tag_fixnum(n));
} }
VM_C_API void box_unsigned_2(u16 n,factor_vm *parent) VM_C_API void box_unsigned_2(u16 n, factor_vm *parent)
{ {
return parent->box_unsigned_2(n); return parent->box_unsigned_2(n);
} }
@ -439,7 +439,7 @@ void factor_vm::box_signed_4(s32 n)
dpush(allot_integer(n)); dpush(allot_integer(n));
} }
VM_C_API void box_signed_4(s32 n,factor_vm *parent) VM_C_API void box_signed_4(s32 n, factor_vm *parent)
{ {
return parent->box_signed_4(n); return parent->box_signed_4(n);
} }
@ -449,7 +449,7 @@ void factor_vm::box_unsigned_4(u32 n)
dpush(allot_cell(n)); dpush(allot_cell(n));
} }
VM_C_API void box_unsigned_4(u32 n,factor_vm *parent) VM_C_API void box_unsigned_4(u32 n, factor_vm *parent)
{ {
return parent->box_unsigned_4(n); return parent->box_unsigned_4(n);
} }
@ -459,7 +459,7 @@ void factor_vm::box_signed_cell(fixnum integer)
dpush(allot_integer(integer)); dpush(allot_integer(integer));
} }
VM_C_API void box_signed_cell(fixnum integer,factor_vm *parent) VM_C_API void box_signed_cell(fixnum integer, factor_vm *parent)
{ {
return parent->box_signed_cell(integer); return parent->box_signed_cell(integer);
} }
@ -469,7 +469,7 @@ void factor_vm::box_unsigned_cell(cell cell)
dpush(allot_cell(cell)); dpush(allot_cell(cell));
} }
VM_C_API void box_unsigned_cell(cell cell,factor_vm *parent) VM_C_API void box_unsigned_cell(cell cell, factor_vm *parent)
{ {
return parent->box_unsigned_cell(cell); return parent->box_unsigned_cell(cell);
} }
@ -482,7 +482,7 @@ void factor_vm::box_signed_8(s64 n)
dpush(tag_fixnum(n)); dpush(tag_fixnum(n));
} }
VM_C_API void box_signed_8(s64 n,factor_vm *parent) VM_C_API void box_signed_8(s64 n, factor_vm *parent)
{ {
return parent->box_signed_8(n); return parent->box_signed_8(n);
} }
@ -501,7 +501,7 @@ s64 factor_vm::to_signed_8(cell obj)
} }
} }
VM_C_API s64 to_signed_8(cell obj,factor_vm *parent) VM_C_API s64 to_signed_8(cell obj, factor_vm *parent)
{ {
return parent->to_signed_8(obj); return parent->to_signed_8(obj);
} }
@ -514,7 +514,7 @@ void factor_vm::box_unsigned_8(u64 n)
dpush(tag_fixnum(n)); dpush(tag_fixnum(n));
} }
VM_C_API void box_unsigned_8(u64 n,factor_vm *parent) VM_C_API void box_unsigned_8(u64 n, factor_vm *parent)
{ {
return parent->box_unsigned_8(n); return parent->box_unsigned_8(n);
} }
@ -533,7 +533,7 @@ u64 factor_vm::to_unsigned_8(cell obj)
} }
} }
VM_C_API u64 to_unsigned_8(cell obj,factor_vm *parent) VM_C_API u64 to_unsigned_8(cell obj, factor_vm *parent)
{ {
return parent->to_unsigned_8(obj); return parent->to_unsigned_8(obj);
} }
@ -553,7 +553,7 @@ float factor_vm::to_float(cell value)
return untag_float_check(value); return untag_float_check(value);
} }
VM_C_API float to_float(cell value,factor_vm *parent) VM_C_API float to_float(cell value, factor_vm *parent)
{ {
return parent->to_float(value); return parent->to_float(value);
} }
@ -563,7 +563,7 @@ void factor_vm::box_double(double flo)
dpush(allot_float(flo)); dpush(allot_float(flo));
} }
VM_C_API void box_double(double flo,factor_vm *parent) VM_C_API void box_double(double flo, factor_vm *parent)
{ {
return parent->box_double(flo); return parent->box_double(flo);
} }
@ -573,7 +573,7 @@ double factor_vm::to_double(cell value)
return untag_float_check(value); return untag_float_check(value);
} }
VM_C_API double to_double(cell value,factor_vm *parent) VM_C_API double to_double(cell value, factor_vm *parent)
{ {
return parent->to_double(value); return parent->to_double(value);
} }

View File

@ -6,11 +6,11 @@ namespace factor
/* Simple non-optimizing compiler. /* Simple non-optimizing compiler.
This is one of the two compilers implementing Factor; the second one is written This is one of the two compilers implementing Factor; the second one is written
in Factor and performs advanced optimizations. See core/compiler/compiler.factor. in Factor and performs advanced optimizations. See basis/compiler/compiler.factor.
The non-optimizing compiler compiles a quotation at a time by concatenating The non-optimizing compiler compiles a quotation at a time by concatenating
machine code chunks; prolog, epilog, call word, jump to word, etc. These machine machine code chunks; prolog, epilog, call word, jump to word, etc. These machine
code chunks are generated from Factor code in core/cpu/.../bootstrap.factor. code chunks are generated from Factor code in basis/cpu/.../bootstrap.factor.
Calls to words and constant quotations (referenced by conditionals and dips) Calls to words and constant quotations (referenced by conditionals and dips)
are direct jumps to machine code blocks. Literals are also referenced directly are direct jumps to machine code blocks. Literals are also referenced directly

View File

@ -67,9 +67,9 @@ void factor_vm::update_word_xt(word *w_)
{ {
if(!w->profiling) if(!w->profiling)
{ {
/* Note: can't do w->profiling = ... since if LHS /* Note: can't do w->profiling = ... since LHS evaluates
evaluates before RHS, since in that case if RHS does a before RHS, and if RHS does a GC, we will have an
GC, we will have an invalid pointer on the LHS */ invalid pointer on the LHS */
code_block *profiling = compile_profiling_stub(w.value()); code_block *profiling = compile_profiling_stub(w.value());
w->profiling = profiling; w->profiling = profiling;
} }