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();
}
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);
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() {
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;
}
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) */
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) */
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;
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;
}
}
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);
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 {
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());
}
}
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;
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 {
}
}
- 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;
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;
}
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;
}
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);
: 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: {
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;
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) {
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;
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;
}
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);
}
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: {
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);
update_pic_transitions(pic_size);
- void* xt;
+ cell xt;
if (pic_size >= max_pic_size)
xt = generic_word->entry_point;
}
/* 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);
}
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);
}
: 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() {
}
void instruction_operand::store_code_block(code_block* compiled) {
- store_value((cell)compiled->entry_point());
+ store_value(compiled->entry_point());
}
}
/* 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 */
/* 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;
/* 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;
}
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()));
}
}
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();
}
} 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);
}
// 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);
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);
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);
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()));
}