Changeset 15064


Ignore:
Timestamp:
06/09/17 08:50:50 (6 years ago)
Author:
Mark Evenson
Message:

Add jss hook and test
(Alan Ruttenberg)

From <https://github.com/armedbear/abcl/pull/52/commits/155db3e3fbb19a2969221edce465bf45f1560abe>.

Part of merge <https://github.com/armedbear/abcl/pull/52>.

Location:
trunk/abcl/contrib/jss
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/contrib/jss/invoke.lisp

    r14962 r15064  
    206206(eval-when (:compile-toplevel :load-toplevel :execute)
    207207  (defun read-invoke (stream char arg)
    208     (unread-char char stream)
    209     (let ((name (read stream)))
    210       (if (or (find #\. name) (find #\{ name))
    211     (jss-transform-to-field name)
    212     (let ((object-var (gensym))
    213     (args-var (gensym)))
    214       `(lambda (,object-var &rest ,args-var)
    215          (invoke-restargs ,name  ,object-var ,args-var ,(eql arg 0)))))))
     208    (if (eql arg 1)
     209  (progn (require 'javaparser)
     210         (read-sharp-java-expression stream))
     211  (progn
     212    (unread-char char stream)
     213    (let ((name (read stream)))
     214      (if (or (find #\. name) (find #\{ name))
     215    (jss-transform-to-field name)
     216    (let ((object-var (gensym))
     217          (args-var (gensym)))
     218      `(lambda (,object-var &rest ,args-var)
     219         (invoke-restargs ,name  ,object-var ,args-var ,(eql arg 0)))))))))
    216220  (set-dispatch-macro-character #\# #\" 'read-invoke))
    217221
  • trunk/abcl/contrib/jss/jss-tests.lisp

    r15046 r15064  
    2424  (loop repeat count do (#"compile" 'regex.Pattern ".*")))
    2525
    26 (defun unoptimized-jss (count)
    27   (loop repeat count do (#"compile" 'regex.Pattern ".*")))
     26(let ((jss::*inhibit-jss-optimization* t))
     27  (defun unoptimized-jss (count)
     28  (loop repeat count do (#"compile" 'regex.Pattern ".*"))))
    2829
    2930(defun just-loop (count)
     
    4546(is-type (let ((just-loop (timeit (just-loop 10000))))
    4647     (+ 0.0
    47         (print (/ (-  (timeit (optimized-jss 10000)) just-loop)
    48       (-  (timeit (unoptimized-jss 10000)) just-loop)))))
     48        (/ (-  (timeit (optimized-jss 10000)) just-loop)
     49      (-  (timeit (unoptimized-jss 10000)) just-loop))))
    4950   '(float 0 0.1))
    5051
     
    5960(finalize)
    6061
     62(plan 1)
    6163
     64(in-package :jss)
     65(defparameter expanded '(let ((jss::this jss::*object-for-this*))
     66      (jcall "getLoaded"
     67       (jcall "load"
     68        (jcall "make"
     69         (jcall "intercept"
     70          (jcall "method"
     71           (jcall "subclass"
     72            (new '|ByteBuddy|)
     73            (find-java-class '|Object|)
     74            t)
     75           (jstatic "named"
     76              '|ElementMatchers|
     77              "toString"))
     78          (jstatic "value"
     79             '|FixedValue|
     80             "Hello World!")))
     81        (jcall "getClassLoader"
     82         (jcall "getClass" jss::this))))))
     83
     84(defparameter source '#1"new ByteBuddy().subclass(Object.class,t)
     85   .method(ElementMatchers.named("toString"))
     86   .intercept(FixedValue.value("Hello World!"))
     87   .make()
     88   .load(getClass().getClassLoader())
     89   .getLoaded()" )
     90
     91(in-package :jss-test)
     92
     93(is jss::source
     94    jss::expanded)
     95
     96(finalize)
Note: See TracChangeset for help on using the changeset viewer.