VM: change type of callstack_top and callstack_bottom from void* to cell
cell and void* is always the same size, but now you can remove lots of redundant type casts from void* to cell.db4
parent
a6e191a490
commit
e47181e87a
|
@ -17,10 +17,10 @@ This means that if 'callstack' is called in tail position, we
|
|||
will have popped a necessary frame... however this word is only
|
||||
called by continuation implementation, and user code shouldn't
|
||||
be calling it at all, so we leave it as it is for now. */
|
||||
void* factor_vm::second_from_top_stack_frame(context* ctx) {
|
||||
void* frame_top = ctx->callstack_top;
|
||||
cell factor_vm::second_from_top_stack_frame(context* ctx) {
|
||||
cell frame_top = ctx->callstack_top;
|
||||
for (cell i = 0; i < 2; ++i) {
|
||||
void* pred = frame_predecessor(frame_top);
|
||||
cell pred = frame_predecessor(frame_top);
|
||||
if (pred >= ctx->callstack_bottom)
|
||||
return frame_top;
|
||||
frame_top = pred;
|
||||
|
@ -30,13 +30,13 @@ void* factor_vm::second_from_top_stack_frame(context* ctx) {
|
|||
|
||||
/* Allocates memory (allot_callstack) */
|
||||
cell factor_vm::capture_callstack(context* ctx) {
|
||||
void* top = second_from_top_stack_frame(ctx);
|
||||
void* bottom = ctx->callstack_bottom;
|
||||
cell top = second_from_top_stack_frame(ctx);
|
||||
cell bottom = ctx->callstack_bottom;
|
||||
|
||||
fixnum size = std::max((fixnum)0, (fixnum)bottom - (fixnum)top);
|
||||
fixnum size = std::max((cell)0, bottom - top);
|
||||
|
||||
callstack* stack = allot_callstack(size);
|
||||
memcpy(stack->top(), top, size);
|
||||
memcpy(stack->top(), (void *)top, size);
|
||||
return tag<callstack>(stack);
|
||||
}
|
||||
|
||||
|
@ -49,12 +49,12 @@ void factor_vm::primitive_callstack_for() {
|
|||
ctx->replace(capture_callstack(other_ctx));
|
||||
}
|
||||
|
||||
void* factor_vm::frame_predecessor(void* frame_top) {
|
||||
void* addr = *(void**)frame_top;
|
||||
cell factor_vm::frame_predecessor(cell frame_top) {
|
||||
cell addr = *(cell*)frame_top;
|
||||
FACTOR_ASSERT(addr != 0);
|
||||
code_block* owner = code->code_block_for_address((cell)addr);
|
||||
cell frame_size = owner->stack_frame_size_for_address((cell)addr);
|
||||
return (void*)((char*)frame_top + frame_size);
|
||||
code_block* owner = code->code_block_for_address(addr);
|
||||
cell frame_size = owner->stack_frame_size_for_address(addr);
|
||||
return frame_top + frame_size;
|
||||
}
|
||||
|
||||
struct stack_frame_accumulator {
|
||||
|
|
|
@ -43,9 +43,9 @@ template <typename Iterator, typename Fixup>
|
|||
inline void factor_vm::iterate_callstack(context* ctx, Iterator& iterator,
|
||||
Fixup& fixup) {
|
||||
|
||||
char* frame_top = (char*)ctx->callstack_top;
|
||||
cell frame_top = ctx->callstack_top;
|
||||
|
||||
while (frame_top < (char*)ctx->callstack_bottom) {
|
||||
while (frame_top < ctx->callstack_bottom) {
|
||||
void* addr = *(void**)frame_top;
|
||||
FACTOR_ASSERT(addr != 0);
|
||||
void* fixed_addr = Fixup::translated_code_block_map
|
||||
|
@ -62,7 +62,7 @@ inline void factor_vm::iterate_callstack(context* ctx, Iterator& iterator,
|
|||
void* fixed_addr_for_iter =
|
||||
Fixup::translated_code_block_map ? fixed_addr : addr;
|
||||
|
||||
iterator(frame_top, frame_size, owner, fixed_addr_for_iter);
|
||||
iterator((void*)frame_top, frame_size, owner, fixed_addr_for_iter);
|
||||
frame_top += frame_size;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -473,14 +473,13 @@ struct find_symbol_at_address_visitor {
|
|||
/* References to undefined symbols are patched up to call this function on
|
||||
image load. It finds the symbol and library, and throws an error. */
|
||||
void factor_vm::undefined_symbol() {
|
||||
void* frame = ctx->callstack_top;
|
||||
void* return_address = *(void**)frame;
|
||||
code_block* compiled = code->code_block_for_address((cell)return_address);
|
||||
find_symbol_at_address_visitor visitor(this, (cell)return_address);
|
||||
cell frame = ctx->callstack_top;
|
||||
cell return_address = *(cell*)frame;
|
||||
code_block* compiled = code->code_block_for_address(return_address);
|
||||
find_symbol_at_address_visitor visitor(this, return_address);
|
||||
compiled->each_instruction_operand(visitor);
|
||||
if (!to_boolean(visitor.symbol))
|
||||
critical_error("Can't find RT_DLSYM at return address",
|
||||
(cell)return_address);
|
||||
critical_error("Can't find RT_DLSYM at return address", return_address);
|
||||
else
|
||||
general_error(ERROR_UNDEFINED_SYMBOL, visitor.symbol, visitor.library);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ namespace factor {
|
|||
|
||||
context::context(cell datastack_size, cell retainstack_size,
|
||||
cell callstack_size)
|
||||
: callstack_top(NULL),
|
||||
callstack_bottom(NULL),
|
||||
: callstack_top(0),
|
||||
callstack_bottom(0),
|
||||
datastack(0),
|
||||
retainstack(0),
|
||||
callstack_save(0),
|
||||
|
|
|
@ -19,8 +19,8 @@ struct context {
|
|||
// First 4 fields accessed directly by compiler. See basis/vm/vm.factor
|
||||
|
||||
/* Factor callstack pointers */
|
||||
void* callstack_top;
|
||||
void* callstack_bottom;
|
||||
cell callstack_top;
|
||||
cell callstack_bottom;
|
||||
|
||||
/* current datastack top pointer */
|
||||
cell datastack;
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace factor {
|
|||
#define FACTOR_CPU_STRING "ppc.32"
|
||||
#endif
|
||||
|
||||
#define CALLSTACK_BOTTOM(ctx) (void*)(ctx->callstack_seg->end - 32)
|
||||
#define CALLSTACK_BOTTOM(ctx) (ctx->callstack_seg->end - 32)
|
||||
|
||||
/* In the instruction sequence:
|
||||
|
||||
|
|
|
@ -12,14 +12,15 @@ void factor_vm::dispatch_signal_handler(cell* sp, cell* pc, cell handler) {
|
|||
and launch the handler without going through the resumable
|
||||
subprimitive. */
|
||||
signal_resumable = false;
|
||||
void* frame_top = (void*)ctx->callstack_top;
|
||||
|
||||
cell frame_top = ctx->callstack_top;
|
||||
|
||||
while (frame_top < ctx->callstack_bottom &&
|
||||
(cell)frame_top < ctx->callstack_seg->start + stack_reserved) {
|
||||
frame_top < ctx->callstack_seg->start + stack_reserved) {
|
||||
frame_top = frame_predecessor(frame_top);
|
||||
}
|
||||
|
||||
*sp = (cell)frame_top;
|
||||
*sp = frame_top;
|
||||
ctx->callstack_top = frame_top;
|
||||
*pc = handler;
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
namespace factor {
|
||||
|
||||
#define CALLSTACK_BOTTOM(ctx) \
|
||||
(void*)(ctx->callstack_seg->end - sizeof(cell) * 5)
|
||||
(ctx->callstack_seg->end - sizeof(cell) * 5)
|
||||
|
||||
inline static void flush_icache(cell start, cell len) {}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ template <typename Func> Func factor_vm::get_entry_point(cell n) {
|
|||
return (Func) entry_point_word->entry_point;
|
||||
}
|
||||
|
||||
void factor_vm::unwind_native_frames(cell quot, void* to) {
|
||||
void factor_vm::unwind_native_frames(cell quot, cell to) {
|
||||
tagged<word> entry_point_word(special_objects[UNWIND_NATIVE_FRAMES_WORD]);
|
||||
void* func = entry_point_word->entry_point;
|
||||
CODE_TO_FUNCTION_POINTER(func);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
namespace factor {
|
||||
|
||||
typedef void (*c_to_factor_func_type)(cell quot);
|
||||
typedef void (*unwind_native_frames_func_type)(cell quot, void* to);
|
||||
typedef void (*unwind_native_frames_func_type)(cell quot, cell to);
|
||||
typedef cell (*get_fpu_state_func_type)();
|
||||
typedef void (*set_fpu_state_func_type)(cell state);
|
||||
|
||||
|
|
|
@ -638,11 +638,11 @@ struct factor_vm {
|
|||
void iterate_callstack_object(callstack* stack_, Iterator& iterator);
|
||||
|
||||
callstack* allot_callstack(cell size);
|
||||
void* second_from_top_stack_frame(context* ctx);
|
||||
cell second_from_top_stack_frame(context* ctx);
|
||||
cell capture_callstack(context* ctx);
|
||||
void primitive_callstack();
|
||||
void primitive_callstack_for();
|
||||
void* frame_predecessor(void* frame);
|
||||
cell frame_predecessor(cell frame_top);
|
||||
void primitive_callstack_to_array();
|
||||
void primitive_innermost_stack_frame_executing();
|
||||
void primitive_innermost_stack_frame_scan();
|
||||
|
@ -716,7 +716,7 @@ struct factor_vm {
|
|||
// entry points
|
||||
void c_to_factor(cell quot);
|
||||
template <typename Func> Func get_entry_point(cell n);
|
||||
void unwind_native_frames(cell quot, void* to);
|
||||
void unwind_native_frames(cell quot, cell to);
|
||||
cell get_fpu_state();
|
||||
void set_fpu_state(cell state);
|
||||
|
||||
|
|
Loading…
Reference in New Issue