]> gitweb.factorcode.org Git - factor.git/commitdiff
quick test vocab for mt stuff
authorPhil Dawes <phil@phildawes.net>
Tue, 25 Aug 2009 17:29:28 +0000 (18:29 +0100)
committerPhil Dawes <phil@phildawes.net>
Wed, 16 Sep 2009 07:20:50 +0000 (08:20 +0100)
basis/cpu/x86/64/64.factor
extra/mttest/mttest.factor [new file with mode: 0644]
vm/errors.cpp
vm/math.cpp
vm/os-unix.cpp
vm/tagged.hpp
vm/vm.hpp

index a0ca3d17c70fb6127b0878798d7c76d5182e5b6c..925de44c23409d7ef5b7fd1b5ccc3947e524b50b 100644 (file)
@@ -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 (file)
index 0000000..90a398c
--- /dev/null
@@ -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
index f483fb4a0919a01c887f5903c584c5393a74847f..154237a8f2cb35606dd1914a0eadcbbe1e787fb5 100755 (executable)
@@ -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()
index d6d824f7c03f7e5df33ed296bc758079ffb77efe..40a0c20a3b84298cd0ff6450bd4ea837433ef95b 100755 (executable)
@@ -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);
index 268469a8753b6d1d0350577c534d7c9ff58d76da..4cee04a11bfc6ab82fdcd2f4ab0112f70b251aa6 100644 (file)
@@ -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;
index 13ddf4a0474c47312c96d057cbabb1cffde7fb35..8eb492a140c387c4c1d1606ea982b847c6acf4c2 100755 (executable)
@@ -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
        }
 
index 35011171eeb9f6aebaa32b7fc701292d0b91556c..c30af505f93cc806ab3a6025fc5c022673f61e66 100644 (file)
--- 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
 
 }