Changeset 15191


Ignore:
Timestamp:
Feb 3, 2012, 1:53:24 PM (7 years ago)
Author:
gb
Message:

Use a cast in the code that sets up errno_loc in the TCR.
Revive jvm_init(), since Apple's JVM still/again clobbers Mach exception
ports.

Add kernel-import info for jvm-init for all architectures. (The kernel
import table isn't architecture-specific, though some entries effectively
are.)

Tweak jni.lisp a bit; still needs lots of work.

Location:
trunk/source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/compiler/ARM/arm-arch.lisp

    r15111 r15191  
    10051005  lisp-gettimeofday
    10061006  lisp-sigexit
     1007  jvm-init
    10071008)
    10081009
  • trunk/source/compiler/PPC/PPC32/ppc32-arch.lisp

    r15093 r15191  
    630630  lisp-gettimeofday
    631631  lisp-sigexit
     632  jvm-init
    632633)
    633634
  • trunk/source/compiler/PPC/PPC64/ppc64-arch.lisp

    r15093 r15191  
    700700  lisp-gettimeofday
    701701  lisp-sigexit
     702  jvm-init
    702703)
    703704
  • trunk/source/compiler/X86/X8632/x8632-arch.lisp

    r15094 r15191  
    836836  lisp-gettimeofday
    837837  lisp-sigexit
     838  jvm-init
    838839)
    839840
  • trunk/source/compiler/X86/X8664/x8664-arch.lisp

    r15094 r15191  
    851851  lisp-gettimeofday
    852852  lisp-sigexit
     853  jvm-init
    853854)
    854855
  • trunk/source/library/jni.lisp

    r15189 r15191  
    6363    ())
    6464
     65(defmethod print-object ((object java-object) stream)
     66  (print-unreadable-object (object stream :type t :identity t)
     67    (format stream "@#x~x" (ccl::%ptr-to-int object))))
     68
    6569(ccl::defloadvar *java-object-domain* nil)
    6670
     
    106110#+:darwin-target "/System/Library/Frameworks/JavaVM.framework/JavaVM"
    107111#+:win32-target "C:/Program Files/Java/jre6/bin/client/jvm.dll"
     112#+android-target "libdvm.so"
     113#-(or darwin-target win32-target android-target)
     114"need to define *jni-lib-path*"
    108115"Set this to point to your jvm dll prior to calling create-jvm")
    109116
     
    140147(defun load-jni-lib (&optional (libpath *jni-lib-path*))
    141148  (ccl:open-shared-library libpath))
     149
    142150
    143151(defun current-env ()
     
    152160                            :jint jni-version-1-4
    153161                            :jint))
    154         ;; On Darwin, attaching the current thread to a JVM instance
    155         ;; overwrites the thread's Mach exception ports, which CCL
    156         ;; happens to be using.  We can work around this by calling
    157         ;; a function in the CCL kernel and having that function
    158         ;; call the vm's AttachCurrentThread function and then restore
    159         ;; the thread's exception ports before returning.  Yes, that
    160         ;; -is- total nonsense.
    161162        (unless (eql jni-ok
    162163                     (ff-call
     
    166167                      :address (ccl::%null-ptr)
    167168                      :jint))
    168           (error "Can't attach thread to JVM ~s" jvm)))
    169       (let* ((result (pref pjnienv :address)))
    170         (ccl::%set-macptr-type result (load-time-value (ccl::foreign-type-ordinal (ccl::foreign-pointer-type-to (ccl::parse-foreign-type #>JNIEnv)))))
    171         result))))
     169          (error "Can't attach thread to JVM ~s" jvm))))
     170    (let* ((result (pref pjnienv :address)))
     171      (ccl::%set-macptr-type result (load-time-value (ccl::foreign-type-ordinal (ccl::foreign-pointer-type-to (ccl::parse-foreign-type #>JNIEnv)))))
     172      result)))
    172173
    173174
     
    228229
    229230(defun to-reflected-method (cls method-id is-static)
    230  
    231231  (jnienv-call ("ToReflectedMethod" :jobject)
    232232               :jclass cls
     
    241241  (jnienv-call ("IsAssignableFrom" :jboolean) :jclass sub :jclass sup))
    242242
    243 (defun to-reflected-field (cls field-id is-static)
    244  
     243(defun to-reflected-field (cls field-id is-static) 
    245244  (jnienv-call ("ToReflectedField" :jobject)
    246245               :jclass cls
     
    11521151           ;; JNI_CreateJavaVM for us.
    11531152           (let* ((result
    1154                    (ff-call (foreign-symbol-address "JNI_CreateJavaVM")
     1153                   (ff-call #+darwin-target (ccl::%kernel-import target::kernel-import-jvm-init)
     1154                            #+darwin-target :address
     1155                            (foreign-symbol-address "JNI_CreateJavaVM")
    11551156                            :address vm
    11561157                            :address env
  • trunk/source/lisp-kernel/imports.s

    r14431 r15191  
    101101        defimport(lisp_gettimeofday)
    102102        defimport(lisp_sigexit)
     103        defimport(jvm_init)
    103104   
    104105        .globl C(import_ptrs_base)
  • trunk/source/lisp-kernel/pmcl-kernel.c

    r15187 r15191  
    23052305}
    23062306
    2307 
     2307/* A horrible hack to allow us to initialize a JVM instance from lisp.
     2308   On Darwin, creating a JVM instance clobbers the thread's existing
     2309   Mach exception infrastructure, so we save and restore it here.
     2310*/
     2311
     2312typedef int (*jvm_initfunc)(void*,void*,void*);
     2313
     2314int
     2315jvm_init(jvm_initfunc f,void*arg0,void*arg1,void*arg2)
     2316{
     2317  int result = -1;
     2318  TCR *tcr = get_tcr(1);
     2319#ifdef DARWIN
     2320  extern kern_return_t tcr_establish_lisp_exception_port(TCR *);
     2321#endif
     2322 
     2323  result = f(arg0,arg1,arg2);
     2324#ifdef DARWIN
     2325  tcr_establish_lisp_exception_port(tcr);
     2326#endif
     2327  return result;
     2328}
    23082329
    23092330
  • trunk/source/lisp-kernel/thread_manager.c

    r15148 r15191  
    15471547#endif
    15481548#endif
    1549   TCR_AUX(tcr)->errno_loc = &errno;
     1549  TCR_AUX(tcr)->errno_loc = (int *)(&errno);
    15501550  tsd_set(lisp_global(TCR_KEY), TCR_TO_TSD(tcr));
    15511551#ifdef DARWIN
Note: See TracChangeset for help on using the changeset viewer.