Update Win64 support
parent
af96673458
commit
942f6e0943
11
Nmakefile
11
Nmakefile
|
@ -1,5 +1,10 @@
|
|||
!IF DEFINED(DEBUG)
|
||||
LINK_FLAGS = /nologo /DEBUG shell32.lib
|
||||
CL_FLAGS = /nologo /Zi /O2 /W3 /DFACTOR_DEBUG
|
||||
!ELSE
|
||||
LINK_FLAGS = /nologo shell32.lib
|
||||
CL_FLAGS = /nologo /O2 /W3
|
||||
!ENDIF
|
||||
|
||||
EXE_OBJS = factor.dll.lib vm\main-windows-nt.obj vm\factor.res
|
||||
|
||||
|
@ -50,11 +55,17 @@ DLL_OBJS = vm\os-windows-nt.obj \
|
|||
.cpp.obj:
|
||||
cl /EHsc $(CL_FLAGS) /Fo$@ /c $<
|
||||
|
||||
.c.obj:
|
||||
cl $(CL_FLAGS) /Fo$@ /c $<
|
||||
|
||||
.rs.res:
|
||||
rc $<
|
||||
|
||||
all: factor.com factor.exe
|
||||
|
||||
libfactor-ffi-test.dll: vm/ffi_test.obj
|
||||
link $(LINK_FLAGS) /out:libfactor-ffi-test.dll /dll vm/ffi_test.obj
|
||||
|
||||
factor.dll.lib: $(DLL_OBJS)
|
||||
link $(LINK_FLAGS) /implib:factor.dll.lib /out:factor.dll /dll $(DLL_OBJS)
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2005, 2010 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors arrays kernel math namespaces make sequences
|
||||
system layouts alien alien.c-types alien.accessors slots
|
||||
splitting assocs combinators locals compiler.constants
|
||||
system layouts alien alien.c-types alien.accessors alien.libraries
|
||||
slots splitting assocs combinators locals compiler.constants
|
||||
compiler.codegen compiler.codegen.fixup
|
||||
compiler.cfg.instructions compiler.cfg.builder
|
||||
compiler.cfg.intrinsics compiler.cfg.stack-frame
|
||||
|
@ -118,9 +118,6 @@ M:: x86.64 %unbox ( n rep func -- )
|
|||
! this is the end of alien-callback
|
||||
n [ n rep reg-class-of return-reg rep %save-param-reg ] when ;
|
||||
|
||||
M: x86.64 %unbox-long-long ( n func -- )
|
||||
[ int-rep ] dip %unbox ;
|
||||
|
||||
: %unbox-struct-field ( c-type i -- )
|
||||
! Alien must be in param-reg-0.
|
||||
R11 swap cells [+] swap rep>> reg-class-of {
|
||||
|
@ -163,12 +160,11 @@ M:: x86.64 %box ( n rep func -- )
|
|||
] [
|
||||
rep load-return-value
|
||||
] if
|
||||
rep int-rep? [ param-reg-1 ] [ param-reg-0 ] if %mov-vm-ptr
|
||||
rep int-rep?
|
||||
cpu x86.64? os windows? and or
|
||||
param-reg-1 param-reg-0 ? %mov-vm-ptr
|
||||
func f %alien-invoke ;
|
||||
|
||||
M: x86.64 %box-long-long ( n func -- )
|
||||
[ int-rep ] dip %box ;
|
||||
|
||||
: box-struct-field@ ( i -- operand ) 1 + cells param@ ;
|
||||
|
||||
: %box-struct-field ( c-type i -- )
|
||||
|
@ -258,7 +254,7 @@ M: x86.64 %callback-value ( ctype -- )
|
|||
|
||||
M:: x86.64 %unary-float-function ( dst src func -- )
|
||||
0 src float-function-param
|
||||
func f %alien-invoke
|
||||
func "libm" load-library %alien-invoke
|
||||
dst float-function-return ;
|
||||
|
||||
M:: x86.64 %binary-float-function ( dst src1 src2 func -- )
|
||||
|
@ -266,7 +262,7 @@ M:: x86.64 %binary-float-function ( dst src1 src2 func -- )
|
|||
! src2 is always a spill slot
|
||||
0 src1 float-function-param
|
||||
1 src2 float-function-param
|
||||
func f %alien-invoke
|
||||
func "libm" load-library %alien-invoke
|
||||
dst float-function-return ;
|
||||
|
||||
M:: x86.64 %call-gc ( gc-root-count temp -- )
|
||||
|
|
|
@ -22,5 +22,5 @@ M: x86.64 dummy-int-params? t ;
|
|||
|
||||
M: x86.64 dummy-fp-params? t ;
|
||||
|
||||
M: x86.64 temp-reg RAX ;
|
||||
M: x86.64 temp-reg R11 ;
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#error "lol"
|
||||
DLL_PATH=http://factorcode.org/dlls/64
|
||||
CC=$(WIN64_PATH)-gcc.exe
|
||||
WINDRES=$(WIN64_PATH)-windres.exe
|
||||
|
|
|
@ -12,7 +12,8 @@ inline cell log2(cell x)
|
|||
#endif
|
||||
#elif defined(FACTOR_AMD64)
|
||||
#if defined(_MSC_VER)
|
||||
_BitScanReverse64(&n,x);
|
||||
n = 0;
|
||||
_BitScanReverse64((DWORD *)&n,x);
|
||||
#else
|
||||
asm ("bsr %1, %0;":"=r"(n):"r"(x));
|
||||
#endif
|
||||
|
|
|
@ -129,13 +129,6 @@ void factor_vm::update_word_references(code_block *compiled)
|
|||
}
|
||||
}
|
||||
|
||||
void factor_vm::check_code_address(cell address)
|
||||
{
|
||||
#ifdef FACTOR_DEBUG
|
||||
assert(address >= code->seg->start && address < code->seg->end);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* References to undefined symbols are patched up to call this function on
|
||||
image load */
|
||||
void factor_vm::undefined_symbol()
|
||||
|
|
|
@ -42,7 +42,7 @@ inline static void *get_call_target(cell return_address)
|
|||
inline static void set_call_target(cell return_address, void *target)
|
||||
{
|
||||
check_call_site(return_address);
|
||||
*(int *)(return_address - 4) = ((cell)target - return_address);
|
||||
*(int *)(return_address - 4) = (u32)((cell)target - return_address);
|
||||
}
|
||||
|
||||
inline static bool tail_call_site_p(cell return_address)
|
||||
|
|
|
@ -113,7 +113,7 @@ void factor_vm::memory_protection_error(cell addr, stack_frame *native_stack)
|
|||
general_error(ERROR_MEMORY,allot_cell(addr),false_object,native_stack);
|
||||
}
|
||||
|
||||
void factor_vm::signal_error(int signal, stack_frame *native_stack)
|
||||
void factor_vm::signal_error(cell signal, stack_frame *native_stack)
|
||||
{
|
||||
general_error(ERROR_SIGNAL,allot_cell(signal),false_object,native_stack);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
#ifdef _MSC_VER
|
||||
#define WINDOWS
|
||||
#else
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#if defined(i386) || defined(__i386) || defined(__i386__) || defined(WIN32)
|
||||
#define F_STDCALL __attribute__((stdcall))
|
||||
|
|
|
@ -51,7 +51,7 @@ void factor_vm::update_code_roots_for_sweep()
|
|||
for(; iter < end; iter++)
|
||||
{
|
||||
code_root *root = *iter;
|
||||
code_block *block = (code_block *)(root->value & -data_alignment);
|
||||
code_block *block = (code_block *)(root->value & (~data_alignment - 1));
|
||||
if(root->valid && !state->marked_p(block))
|
||||
root->valid = false;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ void instruction_operand::store_value_2_2(fixnum value)
|
|||
void instruction_operand::store_value_masked(fixnum value, cell mask, cell shift)
|
||||
{
|
||||
u32 *ptr = (u32 *)(pointer - sizeof(u32));
|
||||
*ptr = ((*ptr & ~mask) | ((value >> shift) & mask));
|
||||
*ptr = (u32)((*ptr & ~mask) | ((value >> shift) & mask));
|
||||
}
|
||||
|
||||
void instruction_operand::store_value(fixnum absolute_value)
|
||||
|
@ -95,10 +95,10 @@ void instruction_operand::store_value(fixnum absolute_value)
|
|||
*(cell *)(pointer - sizeof(cell)) = absolute_value;
|
||||
break;
|
||||
case RC_ABSOLUTE:
|
||||
*(u32 *)(pointer - sizeof(u32)) = absolute_value;
|
||||
*(u32 *)(pointer - sizeof(u32)) = (u32)absolute_value;
|
||||
break;
|
||||
case RC_RELATIVE:
|
||||
*(s32 *)(pointer - sizeof(s32)) = relative_value;
|
||||
*(s32 *)(pointer - sizeof(s32)) = (s32)relative_value;
|
||||
break;
|
||||
case RC_ABSOLUTE_PPC_2_2:
|
||||
store_value_2_2(absolute_value);
|
||||
|
|
|
@ -69,7 +69,7 @@ struct relocation_entry {
|
|||
relocation_class rel_class,
|
||||
cell offset)
|
||||
{
|
||||
value = (rel_type << 28) | (rel_class << 24) | offset;
|
||||
value = (u32)((rel_type << 28) | (rel_class << 24) | offset);
|
||||
}
|
||||
|
||||
relocation_type rel_type()
|
||||
|
|
|
@ -32,10 +32,10 @@
|
|||
/* Detect target CPU type */
|
||||
#if defined(__arm__)
|
||||
#define FACTOR_ARM
|
||||
#elif defined(__amd64__) || defined(__x86_64__)
|
||||
#elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64)
|
||||
#define FACTOR_AMD64
|
||||
#define FACTOR_64
|
||||
#elif defined(i386) || defined(__i386) || defined(__i386__) || defined(WIN32) || defined(_MSC_VER)
|
||||
#elif defined(i386) || defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
||||
#define FACTOR_X86
|
||||
#elif defined(__POWERPC__) || defined(__ppc__) || defined(_ARCH_PPC)
|
||||
#define FACTOR_PPC
|
||||
|
@ -50,10 +50,6 @@
|
|||
#define WINDOWS
|
||||
#endif
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
/* Forward-declare this since it comes up in function prototypes */
|
||||
namespace factor
|
||||
{
|
||||
|
|
|
@ -203,7 +203,7 @@ void factor_vm::primitive_bignum_not()
|
|||
|
||||
void factor_vm::primitive_bignum_bitp()
|
||||
{
|
||||
fixnum bit = to_fixnum(ctx->pop());
|
||||
int bit = (int)to_fixnum(ctx->pop());
|
||||
bignum *x = untag<bignum>(ctx->pop());
|
||||
ctx->push(tag_boolean(bignum_logbitp(bit,x)));
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ unsigned int bignum_producer(unsigned int digit, factor_vm *parent)
|
|||
|
||||
void factor_vm::primitive_byte_array_to_bignum()
|
||||
{
|
||||
cell n_digits = array_capacity(untag_check<byte_array>(ctx->peek()));
|
||||
unsigned int n_digits = (unsigned int)array_capacity(untag_check<byte_array>(ctx->peek()));
|
||||
bignum * result = digit_stream_to_bignum(n_digits,factor::bignum_producer,0x100,0);
|
||||
ctx->replace(tag<bignum>(result));
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ void factor_vm::primitive_float_bits()
|
|||
|
||||
void factor_vm::primitive_bits_float()
|
||||
{
|
||||
ctx->push(allot_float(bits_float(to_cell(ctx->pop()))));
|
||||
ctx->push(allot_float(bits_float((u32)to_cell(ctx->pop()))));
|
||||
}
|
||||
|
||||
void factor_vm::primitive_double_bits()
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace factor
|
|||
#define ESP Rsp
|
||||
#define EIP Rip
|
||||
|
||||
#define X87SW(ctx) (ctx)->FloatSave.StatusWord
|
||||
#define MXCSR(ctx) (ctx)->MxCsr
|
||||
|
||||
}
|
||||
|
|
|
@ -91,8 +91,12 @@ LONG factor_vm::exception_handler(PEXCEPTION_POINTERS pe)
|
|||
case STATUS_FLOAT_UNDERFLOW:
|
||||
case STATUS_FLOAT_MULTIPLE_FAULTS:
|
||||
case STATUS_FLOAT_MULTIPLE_TRAPS:
|
||||
#ifdef FACTOR_AMD64
|
||||
signal_fpu_status = fpu_status(MXCSR(c));
|
||||
#else
|
||||
signal_fpu_status = fpu_status(X87SW(c) | MXCSR(c));
|
||||
X87SW(c) = 0;
|
||||
#endif
|
||||
MXCSR(c) &= 0xffffffc0;
|
||||
c->EIP = (cell)factor::fp_signal_handler_impl;
|
||||
break;
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace factor
|
|||
|
||||
void factor_vm::primitive_exit()
|
||||
{
|
||||
exit(to_fixnum(ctx->pop()));
|
||||
exit((int)to_fixnum(ctx->pop()));
|
||||
}
|
||||
|
||||
void factor_vm::primitive_system_micros()
|
||||
|
|
|
@ -81,7 +81,7 @@ void factor_vm::fill_string(string *str_, cell start, cell capacity, cell fill)
|
|||
data_root<string> str(str_,this);
|
||||
|
||||
if(fill <= 0x7f)
|
||||
memset(&str->data()[start],fill,capacity - start);
|
||||
memset(&str->data()[start],(int)fill,capacity - start);
|
||||
else
|
||||
{
|
||||
cell i;
|
||||
|
|
|
@ -149,7 +149,7 @@ struct factor_vm
|
|||
void not_implemented_error();
|
||||
bool in_page(cell fault, cell area, cell area_size, int offset);
|
||||
void memory_protection_error(cell addr, stack_frame *native_stack);
|
||||
void signal_error(int signal, stack_frame *native_stack);
|
||||
void signal_error(cell signal, stack_frame *native_stack);
|
||||
void divide_by_zero_error();
|
||||
void fp_trap_error(unsigned int fpu_status, stack_frame *signal_callstack_top);
|
||||
void primitive_call_clear();
|
||||
|
@ -509,7 +509,6 @@ struct factor_vm
|
|||
cell compute_entry_point_pic_tail_address(cell w_);
|
||||
cell code_block_owner(code_block *compiled);
|
||||
void update_word_references(code_block *compiled);
|
||||
void check_code_address(cell address);
|
||||
void undefined_symbol();
|
||||
cell compute_dlsym_address(array *literals, cell index);
|
||||
cell compute_vm_address(cell arg);
|
||||
|
@ -524,7 +523,7 @@ struct factor_vm
|
|||
inline void check_code_pointer(cell ptr)
|
||||
{
|
||||
#ifdef FACTOR_DEBUG
|
||||
assert(in_code_heap_p(ptr));
|
||||
//assert(in_code_heap_p(ptr));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue