Changeset 4651


Ignore:
Timestamp:
11/05/03 17:20:31 (18 years ago)
Author:
piso
Message:

EMIT-CLEAR-VALUES

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/jvm.lisp

    r4642 r4651  
    22;;;
    33;;; Copyright (C) 2003 Peter Graves
    4 ;;; $Id: jvm.lisp,v 1.6 2003-11-04 18:35:30 piso Exp $
     4;;; $Id: jvm.lisp,v 1.7 2003-11-05 17:20:31 piso Exp $
    55;;;
    66;;; This program is free software; you can redistribute it and/or
     
    304304(defvar *max-locals* 0)
    305305
     306(defun allocate-local ()
     307  (let ((index (fill-pointer *locals*)))
     308    (incf (fill-pointer *locals*))
     309    (setf *max-locals* (fill-pointer *locals*))
     310    index))
     311
    306312(defvar *args* nil)
    307313(defvar *using-arg-array* nil)
    308314(defvar *hairy-arglist-p* nil)
    309315
    310 (defvar *val* ()) ; index of value register
     316(defvar *val* nil) ; index of value register
    311317
    312318(defun clear ()
     
    478484        "Lorg/armedbear/lisp/Symbol;"))
    479485
     486;; Index of local variable used to hold the current thread.
     487(defvar *thread* nil)
     488
    480489(defun emit-clear-values ()
    481   (emit 'invokestatic
    482         +lisp-thread-class+
    483         "currentThread"
    484         "()Lorg/armedbear/lisp/LispThread;")
     490  (unless *thread*
     491    ;; Allocate a local variable to hold the current thread.
     492    (setf *thread* (allocate-local))
     493    ;; Put the code to initialize the local at the very beginning of the
     494    ;; function, to guarantee that the local gets initialized even if the code
     495    ;; at our current location is never executed, since the local may be
     496    ;; referenced elsewhere too.
     497    (let ((code *code*))
     498      (setf *code* ())
     499      (emit 'invokestatic
     500            +lisp-thread-class+
     501            "currentThread"
     502            "()Lorg/armedbear/lisp/LispThread;")
     503      (emit 'astore *thread*)
     504      (setf *code* (append code *code*))))
     505  (emit 'aload *thread*)
    485506  (emit 'invokevirtual
    486507        +lisp-thread-class+
     
    17311752    (return-from compile-variable-ref)))
    17321753
    1733 
    17341754;; If for-effect is true, no value needs to be left on the stack.
    17351755(defun compile-form (form &optional for-effect)
     
    18181838         (*pool* ())
    18191839         (*pool-count* 1)
    1820          (*val* 0))
     1840         (*val* nil)
     1841         (*thread* nil))
    18211842    (setf (method-name-index execute-method)
    18221843          (pool-name (method-name execute-method)))
     
    18381859        (setf (fill-pointer *locals*) (1+ (length args))))
    18391860    ;; Reserve the next available slot for the value register.
    1840     (setq *val* (fill-pointer *locals*))
    1841     (incf (fill-pointer *locals*))
    1842     (setf *max-locals* (fill-pointer *locals*))
     1861    (setf *val* (allocate-local))
    18431862    (when *hairy-arglist-p*
    18441863      (emit 'aload_0)
Note: See TracChangeset for help on using the changeset viewer.