]> gitweb.factorcode.org Git - factor.git/commitdiff
added vm-ptr primitive
authorPhil Dawes <phil@phildawes.net>
Wed, 2 Sep 2009 09:43:21 +0000 (10:43 +0100)
committerPhil Dawes <phil@phildawes.net>
Wed, 16 Sep 2009 07:20:50 +0000 (08:20 +0100)
core/bootstrap/primitives.factor
vm/alien.cpp
vm/alien.hpp
vm/primitives.cpp
vm/vm.hpp

index 355fa8ed58ea954e85e324cbe33df62866da052a..fc071cc5669767849d8391c2fdad4ceed11244dd 100644 (file)
@@ -103,6 +103,7 @@ bootstrapping? on
     "words"
     "vectors"
     "vectors.private"
+    "vm"
 } [ create-vocab drop ] each
 
 ! Builtin classes
@@ -518,6 +519,7 @@ tuple
     { "inline-cache-stats" "generic.single" (( -- stats )) }
     { "optimized?" "words" (( word -- ? )) }
     { "quot-compiled?" "quotations" (( quot -- ? )) }
+    { "vm-ptr" "vm" (( -- ptr )) }
 } [ [ first3 ] dip swap make-primitive ] each-index
 
 ! Bump build number
index 829a7efeb62d099ba2d8b7a09453694255b6c303..ea8d0a60264175c1e1c7e4fde32cd380e0b20466 100755 (executable)
@@ -303,4 +303,14 @@ VM_C_API void box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size, f
        return VM_PTR->box_medium_struct(x1, x2, x3, x4, size);
 }
 
+inline void factorvm::vmprim_vm_ptr()
+{
+       box_alien(this);
+}
+
+PRIMITIVE(vm_ptr)
+{
+       PRIMITIVE_GETVM()->vmprim_vm_ptr();
+}
+
 }
index 7b537146fd0fa2c5be486e20b48570492fa39cad..ca3601f51e09a3da4153ed8568bc09fb72d23671 100755 (executable)
@@ -36,6 +36,8 @@ PRIMITIVE(dlsym);
 PRIMITIVE(dlclose);
 PRIMITIVE(dll_validp);
 
+PRIMITIVE(vm_ptr);
+
 VM_C_API char *alien_offset(cell object, factorvm *vm);
 VM_C_API char *unbox_alien(factorvm *vm);
 VM_C_API void box_alien(void *ptr, factorvm *vm);
index 6dbe281d0cff226ba69370aab147df57e0694aa1..1cbad03001d811d20ab0df6650a6989346c801a8 100644 (file)
@@ -162,6 +162,7 @@ const primitive_type primitives[] = {
        primitive_inline_cache_stats,
        primitive_optimized_p,
        primitive_quot_compiled_p,
+       primitive_vm_ptr,
 };
 
 }
index c30af505f93cc806ab3a6025fc5c022673f61e66..a16ff21121fc5e1fd024fa30e789107dbe5dbde0 100644 (file)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -585,6 +585,7 @@ struct factorvm {
        inline void vmprim_dlsym();
        inline void vmprim_dlclose();
        inline void vmprim_dll_validp();
+       inline void vmprim_vm_ptr();
        char *alien_offset(cell obj);
        char *unbox_alien();
        void box_alien(void *ptr);