From 3345922330a8925c0ffe21815eb09a2e5d732418 Mon Sep 17 00:00:00 2001 From: Phil Dawes Date: Tue, 25 Aug 2009 18:29:28 +0100 Subject: [PATCH] quick test vocab for mt stuff --- basis/cpu/x86/64/64.factor | 4 +++- extra/mttest/mttest.factor | 25 +++++++++++++++++++++++++ vm/errors.cpp | 4 ++-- vm/math.cpp | 2 +- vm/os-unix.cpp | 4 ++-- vm/tagged.hpp | 4 ++-- vm/vm.hpp | 6 +++--- 7 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 extra/mttest/mttest.factor diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index a0ca3d17c7..925de44c23 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -123,6 +123,8 @@ M:: x86.64 %unbox-large-struct ( n c-type -- ) [ ] tri copy-register ; + + M:: x86.64 %box ( n rep func -- ) n [ n @@ -131,7 +133,7 @@ M:: x86.64 %box ( n rep func -- ) ] [ rep load-return-value ] if - func %vm-invoke-2nd-arg ; + rep int-rep? [ func %vm-invoke-2nd-arg ] [ func %vm-invoke-1st-arg ] if ; M: x86.64 %box-long-long ( n func -- ) [ int-rep ] dip %box ; diff --git a/extra/mttest/mttest.factor b/extra/mttest/mttest.factor new file mode 100644 index 0000000000..90a398c59a --- /dev/null +++ b/extra/mttest/mttest.factor @@ -0,0 +1,25 @@ +USING: alien.syntax io io.encodings.utf16n io.encodings.utf8 io.files +kernel namespaces sequences system threads unix.utilities ; +IN: mttest + +FUNCTION: void* start_standalone_factor_in_new_thread ( int argc, char** argv ) ; + +HOOK: native-string-encoding os ( -- encoding ) +M: windows native-string-encoding utf16n ; +M: unix native-string-encoding utf8 ; + +: start-vm-in-os-thread ( args -- threadhandle ) + \ vm get-global prefix + [ length ] [ native-string-encoding strings>alien ] bi + start_standalone_factor_in_new_thread ; + +: start-tetris-in-os-thread ( -- ) + { "-run=tetris" } start-vm-in-os-thread drop ; + +: start-testthread-in-os-thread ( -- ) + { "-run=mttest" } start-vm-in-os-thread drop ; + +: testthread ( -- ) + "/tmp/hello" utf8 [ "hello!\n" write ] with-file-appender 5000000 sleep ; + +MAIN: testthread \ No newline at end of file diff --git a/vm/errors.cpp b/vm/errors.cpp index f483fb4a09..154237a8f2 100755 --- a/vm/errors.cpp +++ b/vm/errors.cpp @@ -165,7 +165,7 @@ void factorvm::memory_signal_handler_impl() void memory_signal_handler_impl() { - SIGNAL_VM_PTR->misc_signal_handler_impl(); + SIGNAL_VM_PTR()->misc_signal_handler_impl(); } void factorvm::misc_signal_handler_impl() @@ -175,7 +175,7 @@ void factorvm::misc_signal_handler_impl() void misc_signal_handler_impl() { - SIGNAL_VM_PTR->misc_signal_handler_impl(); + SIGNAL_VM_PTR()->misc_signal_handler_impl(); } void factorvm::fp_signal_handler_impl() diff --git a/vm/math.cpp b/vm/math.cpp index d6d824f7c0..40a0c20a3b 100755 --- a/vm/math.cpp +++ b/vm/math.cpp @@ -818,7 +818,7 @@ void factorvm::box_double(double flo) dpush(allot_float(flo)); } -VM_C_API void box_double(double flo,factorvm *myvm) // not sure if this is ever called +VM_C_API void box_double(double flo,factorvm *myvm) { ASSERTVM(); return VM_PTR->box_double(flo); diff --git a/vm/os-unix.cpp b/vm/os-unix.cpp index 268469a875..4cee04a11b 100644 --- a/vm/os-unix.cpp +++ b/vm/os-unix.cpp @@ -133,7 +133,7 @@ stack_frame *factorvm::uap_stack_pointer(void *uap) void memory_signal_handler(int signal, siginfo_t *siginfo, void *uap) { - factorvm *myvm = lookup_vm(thread_id()); + factorvm *myvm = SIGNAL_VM_PTR(); myvm->signal_fault_addr = (cell)siginfo->si_addr; myvm->signal_callstack_top = myvm->uap_stack_pointer(uap); UAP_PROGRAM_COUNTER(uap) = (cell)memory_signal_handler_impl; @@ -141,7 +141,7 @@ void memory_signal_handler(int signal, siginfo_t *siginfo, void *uap) void misc_signal_handler(int signal, siginfo_t *siginfo, void *uap) { - factorvm *myvm = lookup_vm(thread_id()); + factorvm *myvm = SIGNAL_VM_PTR(); myvm->signal_number = signal; myvm->signal_callstack_top = myvm->uap_stack_pointer(uap); UAP_PROGRAM_COUNTER(uap) = (cell)misc_signal_handler_impl; diff --git a/vm/tagged.hpp b/vm/tagged.hpp index 13ddf4a047..8eb492a140 100755 --- a/vm/tagged.hpp +++ b/vm/tagged.hpp @@ -37,13 +37,13 @@ struct tagged explicit tagged(cell tagged) : value_(tagged) { #ifdef FACTOR_DEBUG - untag_check(SIGNAL_VM_PTR); + untag_check(SIGNAL_VM_PTR()); #endif } explicit tagged(TYPE *untagged) : value_(factor::tag(untagged)) { #ifdef FACTOR_DEBUG - untag_check(SIGNAL_VM_PTR); + untag_check(SIGNAL_VM_PTR()); #endif } diff --git a/vm/vm.hpp b/vm/vm.hpp index 35011171ee..c30af505f9 100644 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -700,7 +700,7 @@ extern void register_vm(unsigned long threadid,factorvm *vm); #define PRIMITIVE_OVERFLOW_GETVM() vm #define VM_PTR vm #define ASSERTVM() - #define SIGNAL_VM_PTR vm + #define SIGNAL_VM_PTR() vm #endif #ifdef FACTOR_TESTING_MULTITHREADED @@ -709,7 +709,7 @@ extern void register_vm(unsigned long threadid,factorvm *vm); #define PRIMITIVE_OVERFLOW_GETVM() vm #define VM_PTR myvm #define ASSERTVM() assert(vm==myvm) - #define SIGNAL_VM_PTR lookup_vm(thread_id()) + #define SIGNAL_VM_PTR() lookup_vm(thread_id()) #endif #ifdef FACTOR_MULTITHREADED @@ -717,7 +717,7 @@ extern void register_vm(unsigned long threadid,factorvm *vm); #define PRIMITIVE_OVERFLOW_GETVM() ((factorvm*)myvm) #define VM_PTR myvm #define ASSERTVM() - #define SIGNAL_VM_PTR lookup_vm(thread_id()) + #define SIGNAL_VM_PTR() lookup_vm(thread_id()) #endif } -- 2.34.1