VM: change the definition of entry_point in word and quotation from void* to cell
this gets rid of lots of redundant casts from void* to celldb4
parent
f0bf693beb
commit
fb9fa12cdd
|
@ -60,7 +60,7 @@ void callback_heap::store_callback_operand(code_block* stub, cell index,
|
|||
|
||||
void callback_heap::update(code_block* stub) {
|
||||
store_callback_operand(stub, setup_seh_p() ? 2 : 1,
|
||||
(cell)callback_entry_point(stub));
|
||||
callback_entry_point(stub));
|
||||
stub->flush_icache();
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ code_block* callback_heap::add(cell owner, cell return_rewind) {
|
|||
stub->parameters = false_object;
|
||||
stub->relocation = false_object;
|
||||
|
||||
memcpy(stub->entry_point(), insns->data<void>(), size);
|
||||
memcpy((void*)stub->entry_point(), insns->data<void>(), size);
|
||||
|
||||
/* Store VM pointer */
|
||||
store_callback_operand(stub, 0, (cell)parent);
|
||||
|
@ -131,9 +131,9 @@ void factor_vm::primitive_callback() {
|
|||
|
||||
w.untag_check(this);
|
||||
|
||||
void* func = callbacks->add(w.value(), return_rewind)->entry_point();
|
||||
cell func = callbacks->add(w.value(), return_rewind)->entry_point();
|
||||
CODE_TO_FUNCTION_POINTER_CALLBACK(this, func);
|
||||
ctx->push(allot_alien(func));
|
||||
ctx->push(allot_alien((void*)func));
|
||||
}
|
||||
|
||||
void factor_vm::primitive_free_callback() {
|
||||
|
|
|
@ -31,7 +31,7 @@ struct callback_heap {
|
|||
callback_heap(cell size, factor_vm* parent);
|
||||
~callback_heap();
|
||||
|
||||
void* callback_entry_point(code_block* stub) {
|
||||
cell callback_entry_point(code_block* stub) {
|
||||
word* w = (word*)UNTAG(stub->owner);
|
||||
return w->entry_point;
|
||||
}
|
||||
|
|
|
@ -105,15 +105,15 @@ Used by the single stepper. */
|
|||
void factor_vm::primitive_innermost_stack_frame_executing() {
|
||||
callstack* stack = untag_check<callstack>(ctx->peek());
|
||||
void* frame = stack->top();
|
||||
void* addr = *(void**)frame;
|
||||
ctx->replace(code->code_block_for_address((cell)addr)->owner_quot());
|
||||
cell addr = *(cell*)frame;
|
||||
ctx->replace(code->code_block_for_address(addr)->owner_quot());
|
||||
}
|
||||
|
||||
void factor_vm::primitive_innermost_stack_frame_scan() {
|
||||
callstack* stack = untag_check<callstack>(ctx->peek());
|
||||
void* frame = stack->top();
|
||||
cell addr = *(cell*)frame;
|
||||
ctx->replace(code->code_block_for_address((cell)addr)->scan(this, addr));
|
||||
ctx->replace(code->code_block_for_address(addr)->scan(this, addr));
|
||||
}
|
||||
|
||||
/* Allocates memory (jit_compile_quot) */
|
||||
|
@ -130,7 +130,7 @@ void factor_vm::primitive_set_innermost_stack_frame_quot() {
|
|||
cell addr = *(cell*)inner;
|
||||
code_block* block = code->code_block_for_address(addr);
|
||||
cell offset = block->offset(addr);
|
||||
*(void**)inner = (char*)quot->entry_point + offset;
|
||||
*(cell*)inner = quot->entry_point + offset;
|
||||
}
|
||||
|
||||
/* Allocates memory (allot_alien) */
|
||||
|
|
|
@ -29,9 +29,9 @@ cell code_block::scan(factor_vm* vm, cell addr) const {
|
|||
cell factor_vm::compute_entry_point_address(cell obj) {
|
||||
switch (tagged<object>(obj).type()) {
|
||||
case WORD_TYPE:
|
||||
return (cell)untag<word>(obj)->entry_point;
|
||||
return untag<word>(obj)->entry_point;
|
||||
case QUOTATION_TYPE:
|
||||
return (cell)untag<quotation>(obj)->entry_point;
|
||||
return untag<quotation>(obj)->entry_point;
|
||||
default:
|
||||
critical_error("Expected word or quotation", obj);
|
||||
return 0;
|
||||
|
@ -40,13 +40,13 @@ cell factor_vm::compute_entry_point_address(cell obj) {
|
|||
|
||||
cell factor_vm::compute_entry_point_pic_address(word* w, cell tagged_quot) {
|
||||
if (!to_boolean(tagged_quot) || max_pic_size == 0)
|
||||
return (cell)w->entry_point;
|
||||
return w->entry_point;
|
||||
else {
|
||||
quotation* quot = untag<quotation>(tagged_quot);
|
||||
if (quot_compiled_p(quot))
|
||||
return (cell)quot->entry_point;
|
||||
return quot->entry_point;
|
||||
else
|
||||
return (cell)w->entry_point;
|
||||
return w->entry_point;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ void factor_vm::store_external_address(instruction_operand op) {
|
|||
op.store_value(compute_dlsym_address(parameters, index));
|
||||
break;
|
||||
case RT_THIS:
|
||||
op.store_value((cell)compiled->entry_point());
|
||||
op.store_value(compiled->entry_point());
|
||||
break;
|
||||
case RT_MEGAMORPHIC_CACHE_HITS:
|
||||
op.store_value((cell)&dispatch_stats.megamorphic_cache_hits);
|
||||
|
@ -281,9 +281,9 @@ cell factor_vm::compute_here_address(cell arg, cell offset,
|
|||
code_block* compiled) {
|
||||
fixnum n = untag_fixnum(arg);
|
||||
if (n >= 0)
|
||||
return (cell)compiled->entry_point() + offset + n;
|
||||
return compiled->entry_point() + offset + n;
|
||||
else
|
||||
return (cell)compiled->entry_point() - n;
|
||||
return compiled->entry_point() - n;
|
||||
}
|
||||
|
||||
struct initial_code_block_visitor {
|
||||
|
@ -359,7 +359,7 @@ void factor_vm::fixup_labels(array* labels, code_block* compiled) {
|
|||
relocation_entry new_entry(RT_HERE, rel_class, offset);
|
||||
|
||||
instruction_operand op(new_entry, compiled, 0);
|
||||
op.store_value(target + (cell)compiled->entry_point());
|
||||
op.store_value(target + compiled->entry_point());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ struct code_block {
|
|||
and a leaf procedure code block will record a frame size of zero.
|
||||
If we're seeing a stack frame in either of these cases, it's a
|
||||
fake "leaf frame" set up by the signal handler. */
|
||||
if (natural_frame_size == 0 || (void*)addr == entry_point())
|
||||
if (natural_frame_size == 0 || addr == entry_point())
|
||||
return LEAF_FRAME_SIZE;
|
||||
else
|
||||
return natural_frame_size;
|
||||
|
@ -68,7 +68,7 @@ struct code_block {
|
|||
|
||||
template <typename Fixup> cell size(Fixup fixup) const { return size(); }
|
||||
|
||||
void* entry_point() const { return (void*)(this + 1); }
|
||||
cell entry_point() const { return (cell)(this + 1); }
|
||||
|
||||
/* GC info is stored at the end of the block */
|
||||
gc_info* block_gc_info() const {
|
||||
|
@ -92,10 +92,10 @@ struct code_block {
|
|||
}
|
||||
}
|
||||
|
||||
cell offset(cell addr) const { return addr - (cell)entry_point(); }
|
||||
cell offset(cell addr) const { return addr - entry_point(); }
|
||||
|
||||
cell address_for_offset(cell offset) const {
|
||||
return (cell)((char*)entry_point() + offset);
|
||||
return entry_point() + offset;
|
||||
}
|
||||
|
||||
cell scan(factor_vm* vm, cell addr) const;
|
||||
|
@ -105,12 +105,12 @@ struct code_block {
|
|||
VM_C_API void undefined_symbol(void);
|
||||
|
||||
inline code_block* word::code() const {
|
||||
FACTOR_ASSERT(entry_point != NULL);
|
||||
FACTOR_ASSERT(entry_point != 0);
|
||||
return (code_block*)entry_point - 1;
|
||||
}
|
||||
|
||||
inline code_block* quotation::code() const {
|
||||
FACTOR_ASSERT(entry_point != NULL);
|
||||
FACTOR_ASSERT(entry_point != 0);
|
||||
return (code_block*)entry_point - 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,10 +103,10 @@ code_block* code_heap::code_block_for_address(cell address) {
|
|||
FACTOR_ASSERT(blocki != all_blocks.begin());
|
||||
--blocki;
|
||||
code_block* found_block = (code_block*)*blocki;
|
||||
FACTOR_ASSERT((cell)found_block->entry_point() <=
|
||||
FACTOR_ASSERT(found_block->entry_point() <=
|
||||
address /* XXX this isn't valid during fixup. should store the
|
||||
size in the map
|
||||
&& address - (cell)found_block->entry_point() <
|
||||
&& address - found_block->entry_point() <
|
||||
found_block->size()*/);
|
||||
return found_block;
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ struct code_block_accumulator {
|
|||
from_unsigned_cell() here. It is OK, however, to add it as
|
||||
if it were a fixnum, and have library code shift it to the
|
||||
left by 4. */
|
||||
cell entry_point = (cell)compiled->entry_point();
|
||||
cell entry_point = compiled->entry_point();
|
||||
FACTOR_ASSERT((entry_point & (data_alignment - 1)) == 0);
|
||||
FACTOR_ASSERT((entry_point & TAG_MASK) == FIXNUM_TYPE);
|
||||
objects.push_back(entry_point);
|
||||
|
|
|
@ -88,7 +88,7 @@ template <typename Fixup> struct code_block_compaction_relocation_visitor {
|
|||
: parent(parent), old_address(old_address), fixup(fixup) {}
|
||||
|
||||
void operator()(instruction_operand op) {
|
||||
cell old_offset = op.rel_offset() + (cell)old_address->entry_point();
|
||||
cell old_offset = op.rel_offset() + old_address->entry_point();
|
||||
|
||||
switch (op.rel_type()) {
|
||||
case RT_LITERAL: {
|
||||
|
|
|
@ -37,13 +37,13 @@ inline static void* get_call_target(cell return_address) {
|
|||
return (void*)(signed_addr + return_address);
|
||||
}
|
||||
|
||||
inline static void set_call_target(cell return_address, void* target) {
|
||||
inline static void set_call_target(cell return_address, cell target) {
|
||||
return_address -= 4;
|
||||
check_call_site(return_address);
|
||||
|
||||
uint32_t insn = *(uint32_t*)return_address;
|
||||
|
||||
fixnum relative_address = ((cell)target - return_address);
|
||||
fixnum relative_address = target - return_address;
|
||||
insn = ((insn & ~b_mask) | (relative_address & b_mask));
|
||||
*(uint32_t*)return_address = insn;
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@ inline static void* get_call_target(cell return_address) {
|
|||
return (void*)(*(int*)(return_address - 4) + return_address);
|
||||
}
|
||||
|
||||
inline static void set_call_target(cell return_address, void* target) {
|
||||
inline static void set_call_target(cell return_address, cell target) {
|
||||
check_call_site(return_address);
|
||||
*(int*)(return_address - 4) = (uint32_t)((cell)target - return_address);
|
||||
*(int*)(return_address - 4) = (uint32_t)(target - return_address);
|
||||
}
|
||||
|
||||
inline static bool tail_call_site_p(cell return_address) {
|
||||
|
|
|
@ -200,10 +200,10 @@ struct stack_frame_printer {
|
|||
parent->print_obj(owner->scan(parent, addr));
|
||||
std::cout << std::endl;
|
||||
std::cout << "word/quot addr: ";
|
||||
std::cout << std::hex << (cell)owner->owner << std::dec;
|
||||
std::cout << std::hex << owner->owner << std::dec;
|
||||
std::cout << std::endl;
|
||||
std::cout << "word/quot xt: ";
|
||||
std::cout << std::hex << (cell)owner->entry_point() << std::dec;
|
||||
std::cout << std::hex << owner->entry_point() << std::dec;
|
||||
std::cout << std::endl;
|
||||
std::cout << "return address: ";
|
||||
std::cout << std::hex << addr << std::dec;
|
||||
|
|
|
@ -10,7 +10,7 @@ void factor_vm::c_to_factor(cell quot) {
|
|||
if (!c_to_factor_func) {
|
||||
tagged<word> c_to_factor_word(special_objects[C_TO_FACTOR_WORD]);
|
||||
code_block* c_to_factor_block = callbacks->add(c_to_factor_word.value(), 0);
|
||||
void* func = c_to_factor_block->entry_point();
|
||||
cell func = c_to_factor_block->entry_point();
|
||||
CODE_TO_FUNCTION_POINTER_CALLBACK(this, func);
|
||||
c_to_factor_func = (c_to_factor_func_type) func;
|
||||
}
|
||||
|
@ -24,21 +24,21 @@ template <typename Func> Func factor_vm::get_entry_point(cell n) {
|
|||
|
||||
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;
|
||||
cell func = entry_point_word->entry_point;
|
||||
CODE_TO_FUNCTION_POINTER(func);
|
||||
((unwind_native_frames_func_type) func)(quot, to);
|
||||
}
|
||||
|
||||
cell factor_vm::get_fpu_state() {
|
||||
tagged<word> entry_point_word(special_objects[GET_FPU_STATE_WORD]);
|
||||
void* func = entry_point_word->entry_point;
|
||||
cell func = entry_point_word->entry_point;
|
||||
CODE_TO_FUNCTION_POINTER(func);
|
||||
return ((get_fpu_state_func_type) func)();
|
||||
}
|
||||
|
||||
void factor_vm::set_fpu_state(cell state) {
|
||||
tagged<word> entry_point_word(special_objects[SET_FPU_STATE_WORD]);
|
||||
void* func = entry_point_word->entry_point;
|
||||
cell func = entry_point_word->entry_point;
|
||||
CODE_TO_FUNCTION_POINTER(func);
|
||||
((set_fpu_state_func_type) func)(state);
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ struct startup_code_block_relocation_visitor {
|
|||
void operator()(instruction_operand op) {
|
||||
code_block* compiled = op.compiled;
|
||||
cell old_offset =
|
||||
op.rel_offset() + (cell)compiled->entry_point() - fixup.code_offset;
|
||||
op.rel_offset() + compiled->entry_point() - fixup.code_offset;
|
||||
|
||||
switch (op.rel_type()) {
|
||||
case RT_LITERAL: {
|
||||
|
|
|
@ -164,7 +164,7 @@ void factor_vm::update_pic_transitions(cell pic_size) {
|
|||
also, the block containing the return address may now be dead. Use a
|
||||
code_root to take care of the details. */
|
||||
/* Allocates memory */
|
||||
void* factor_vm::inline_cache_miss(cell return_address_) {
|
||||
cell factor_vm::inline_cache_miss(cell return_address_) {
|
||||
code_root return_address(return_address_, this);
|
||||
bool tail_call_site = tail_call_site_p(return_address.value);
|
||||
|
||||
|
@ -185,7 +185,7 @@ void* factor_vm::inline_cache_miss(cell return_address_) {
|
|||
|
||||
update_pic_transitions(pic_size);
|
||||
|
||||
void* xt;
|
||||
cell xt;
|
||||
|
||||
if (pic_size >= max_pic_size)
|
||||
xt = generic_word->entry_point;
|
||||
|
@ -221,7 +221,7 @@ void* factor_vm::inline_cache_miss(cell return_address_) {
|
|||
}
|
||||
|
||||
/* Allocates memory */
|
||||
VM_C_API void* inline_cache_miss(cell return_address, factor_vm* parent) {
|
||||
VM_C_API cell inline_cache_miss(cell return_address, factor_vm* parent) {
|
||||
return parent->inline_cache_miss(return_address);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
namespace factor {
|
||||
|
||||
VM_C_API void* inline_cache_miss(cell return_address, factor_vm* vm);
|
||||
VM_C_API cell inline_cache_miss(cell return_address, factor_vm* vm);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ instruction_operand::instruction_operand(relocation_entry rel,
|
|||
: rel(rel),
|
||||
compiled(compiled),
|
||||
index(index),
|
||||
pointer((cell)compiled->entry_point() + rel.rel_offset()) {}
|
||||
pointer(compiled->entry_point() + rel.rel_offset()) {}
|
||||
|
||||
/* Load a 32-bit value from a PowerPC LIS/ORI sequence */
|
||||
fixnum instruction_operand::load_value_2_2() {
|
||||
|
@ -159,7 +159,7 @@ void instruction_operand::store_value(fixnum absolute_value) {
|
|||
}
|
||||
|
||||
void instruction_operand::store_code_block(code_block* compiled) {
|
||||
store_value((cell)compiled->entry_point());
|
||||
store_value(compiled->entry_point());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ struct word : public object {
|
|||
/* TAGGED machine code for sub-primitive */
|
||||
cell subprimitive;
|
||||
/* UNTAGGED entry point: jump here to execute word */
|
||||
void* entry_point;
|
||||
cell entry_point;
|
||||
/* UNTAGGED compiled code block */
|
||||
|
||||
/* defined in code_blocks.hpp */
|
||||
|
@ -266,7 +266,7 @@ struct quotation : public object {
|
|||
/* tagged */
|
||||
cell cache_counter;
|
||||
/* UNTAGGED entry point; jump here to call quotation */
|
||||
void* entry_point;
|
||||
cell entry_point;
|
||||
|
||||
/* defined in code_blocks.hpp */
|
||||
code_block* code() const;
|
||||
|
|
|
@ -331,7 +331,7 @@ void factor_vm::jit_compile_quot(cell quot_, bool relocating) {
|
|||
/* Allocates memory */
|
||||
void factor_vm::primitive_jit_compile() { jit_compile_quot(ctx->pop(), true); }
|
||||
|
||||
void* factor_vm::lazy_jit_compile_entry_point() {
|
||||
cell factor_vm::lazy_jit_compile_entry_point() {
|
||||
return untag<word>(special_objects[LAZY_JIT_COMPILE_WORD])->entry_point;
|
||||
}
|
||||
|
||||
|
@ -352,7 +352,7 @@ void factor_vm::primitive_array_to_quotation() {
|
|||
void factor_vm::primitive_quotation_code() {
|
||||
data_root<quotation> quot(ctx->pop(), this);
|
||||
|
||||
ctx->push(from_unsigned_cell((cell)quot->entry_point));
|
||||
ctx->push(from_unsigned_cell(quot->entry_point));
|
||||
ctx->push(from_unsigned_cell((cell)quot->code() + quot->code()->size()));
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ VM_C_API cell lazy_jit_compile(cell quot, factor_vm* parent) {
|
|||
}
|
||||
|
||||
bool factor_vm::quot_compiled_p(quotation* quot) {
|
||||
return quot->entry_point != NULL &&
|
||||
return quot->entry_point != 0 &&
|
||||
quot->entry_point != lazy_jit_compile_entry_point();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ void safepoint_state::handle_safepoint(factor_vm* parent, cell pc) volatile {
|
|||
} else if (atomic::load(&parent->sampling_profiler_p)) {
|
||||
FACTOR_ASSERT(parent->code->seg->in_segment_p(pc));
|
||||
code_block* block = parent->code->code_block_for_address(pc);
|
||||
bool prolog_p = (cell)block->entry_point() == pc;
|
||||
bool prolog_p = block->entry_point() == pc;
|
||||
|
||||
parent->record_sample(prolog_p);
|
||||
}
|
||||
|
|
|
@ -673,7 +673,7 @@ struct factor_vm {
|
|||
|
||||
// quotations
|
||||
void primitive_jit_compile();
|
||||
void* lazy_jit_compile_entry_point();
|
||||
cell lazy_jit_compile_entry_point();
|
||||
void primitive_array_to_quotation();
|
||||
void primitive_quotation_code();
|
||||
code_block* jit_compile_quot(cell owner_, cell quot_, bool relocating);
|
||||
|
@ -711,7 +711,7 @@ struct factor_vm {
|
|||
cell inline_cache_size(cell cache_entries);
|
||||
cell add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_);
|
||||
void update_pic_transitions(cell pic_size);
|
||||
void* inline_cache_miss(cell return_address);
|
||||
cell inline_cache_miss(cell return_address);
|
||||
|
||||
// entry points
|
||||
void c_to_factor(cell quot);
|
||||
|
|
|
@ -55,7 +55,7 @@ word* factor_vm::allot_word(cell name_, cell vocab_, cell hashcode_) {
|
|||
new_word->pic_def = false_object;
|
||||
new_word->pic_tail_def = false_object;
|
||||
new_word->subprimitive = false_object;
|
||||
new_word->entry_point = NULL;
|
||||
new_word->entry_point = 0;
|
||||
|
||||
jit_compile_word(new_word.value(), new_word->def, true);
|
||||
|
||||
|
@ -77,7 +77,7 @@ void factor_vm::primitive_word_code() {
|
|||
data_root<word> w(ctx->pop(), this);
|
||||
w.untag_check(this);
|
||||
|
||||
ctx->push(from_unsigned_cell((cell)w->entry_point));
|
||||
ctx->push(from_unsigned_cell(w->entry_point));
|
||||
ctx->push(from_unsigned_cell((cell)w->code() + w->code()->size()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue