Ignore:
Timestamp:
Jan 31, 2011, 11:17:18 PM (9 years ago)
Author:
rme
Message:

Merge shrink-tcr branch. This enables the 32-bit Windows lisp to run
on 64-bit Windows.

On 32-bit x86 ports, we expect to use a segment register to point to a
block of thread-local data called the TCR (thread context record).
This has always been kind of a bother on 32-bit Windows: we have been
using a kludge that allows us to use the %es segment register
(conditionalized on WIN32_ES_HACK).

Unfortunately, 64-bit Windows doesn't support using an LDT. This is
why the 32-bit lisp wouldn't run on 64-bit Windows.

The new scheme is to use some of the TlsSlots? (part of the Windows
TEB) for the most important parts of the TCR, and to introduce an "aux
vector" for the remaining TCR slots. Since %fs points to the TEB, we
can make this work. We reserve the last 34 (of 64) slots for our use,
and will die if we don't get them.

Microsoft's documentation says not to access the TlsSlots? directly
(you're supposed to use TlsGetValue/TlsSetValue?), so we're treading on
undocumented ground. Frankly, we've done worse.

This change introduces some ugliness. In lisp kernel C files, there's
a TCR_AUX(tcr) macro that expands to "tcr->aux" on win32, and to "tcr"
elsewhere.

If lisp or lap code has a pointer to a TCR, it's necessary to subtract
off target::tcr-bias (which on Windows/x86 is #xe10, the offset from
%fs to the TlsSlots? in the Windows TEB). We also sometimes have to load
target::tcr.aux to get at data which has been moved there.

These changes should only affect Windows/x86. The story on the other
platforms is just the same as before.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-1/l1-processes.lisp

    r14362 r14619  
    317317(defmethod process-tcr-enable ((process process) tcr)
    318318  (when (and tcr (not (eql 0 tcr)))
     319    #+(and windows-target x8632-target)
     320    (let ((aux (%fixnum-ref tcr (- target::tcr.aux target::tcr-bias))))
     321      (%signal-semaphore-ptr (%fixnum-ref-macptr aux target::tcr-aux.activate)))
     322    #-(and windows-target x8632-target)
    319323    (%signal-semaphore-ptr (%fixnum-ref-macptr tcr target::tcr.activate))
    320324    ))
     
    695699    (with-macptrs (tcrp)
    696700      (%setf-macptr-to-object tcrp (%current-tcr))
    697       (setf (slot-value *current-process* 'allocation-quantum) new
    698             (%get-natural tcrp target::tcr.log2-allocation-quantum)
     701      #+(and windows-target x8632-target)
     702      (let ((aux (%get-ptr tcrp (- target::tcr.aux target::tcr-bias))))
     703        (setf (%get-natural aux target::tcr-aux.log2-allocation-quantum)
     704              (1- (integer-length new))))
     705      #-(and windows-target x8632-target)
     706      (setf (%get-natural tcrp target::tcr.log2-allocation-quantum)
    699707            (1- (integer-length new)))
     708      (setf (slot-value *current-process* 'allocation-quantum) new)
    700709      new)
    701710    (report-bad-arg new '(satisfies valid-allocation-quantum-p))))
Note: See TracChangeset for help on using the changeset viewer.