experiments/little-smalltalk/jit-SmallWorld-2015.rkt
changeset 415 3d1ae8f1b0d7
parent 414 5e5c61ed2e7d
child 416 9be895de88d6
equal deleted inserted replaced
414:5e5c61ed2e7d 415:3d1ae8f1b0d7
    49 
    49 
    50 (struct compiled-method-info (bytecode-method pics stable?))
    50 (struct compiled-method-info (bytecode-method pics stable?))
    51 
    51 
    52 (struct cached-method (class name-bytes [bytecode-method #:mutable] [proc #:mutable]))
    52 (struct cached-method (class name-bytes [bytecode-method #:mutable] [proc #:mutable]))
    53 
    53 
    54 (define (build-jit-context vm previous-context args method ip stack-top temporaries stack)
    54 (define (build-jit-context vm previous-context args method ip temporaries stack)
    55   ;; TODO: build block contexts instead of just pretending everything is a method...
    55   ;; TODO: build block contexts instead of just pretending everything is a method...
    56   (define max-stack (slotAt method 3))
    56   (define max-stack (slotAt method 3))
    57   (mkobj (VM-Context vm)
    57   (mkobj (VM-Context vm)
    58          method
    58          method
    59          (obj (VM-Array vm) args)
    59          (obj (VM-Array vm) args)
    60          (obj (VM-Array vm) temporaries)
    60          (obj (VM-Array vm) temporaries)
    61          (obj (VM-Array vm) (vector-append stack (make-vector (- max-stack (vector-length stack))
    61          (obj (VM-Array vm) (vector-append stack (make-vector (- max-stack (vector-length stack))
    62                                                               (VM-nil vm))))
    62                                                               (VM-nil vm))))
    63          ip
    63          ip
    64          stack-top
    64          (vector-length stack)
    65          previous-context))
    65          previous-context))
    66 
    66 
    67 (define (selector-string-arity str)
    67 (define (selector-string-arity str)
    68   (define colon-count (for/sum [(c str)] (if (eqv? c #\:) 1 0)))
    68   (define colon-count (for/sum [(c str)] (if (eqv? c #\:) 1 0)))
    69   (cond [(positive? colon-count) (+ colon-count 1)]
    69   (cond [(positive? colon-count) (+ colon-count 1)]
   153   `(build-jit-context vm
   153   `(build-jit-context vm
   154                       (k)
   154                       (k)
   155                       (vector ,@(vector->list (compilation-argnames c)))
   155                       (vector ,@(vector->list (compilation-argnames c)))
   156                       method
   156                       method
   157                       ,ip
   157                       ,ip
   158                       ,(length stack)
       
   159                       temporaries
   158                       temporaries
   160                       (vector ,@(reverse stack))))
   159                       (vector ,@(reverse stack))))
   161 
   160 
   162 (define (gen-send-k c ip stack)
   161 (define (gen-send-k c ip stack)
   163   (define result (gensym 'result))
   162   (define result (gensym 'result))