Changeset ffc3b26 for src/libcfa


Ignore:
Timestamp:
Feb 1, 2017, 11:30:06 AM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
8761006c
Parents:
dd0b961
Message:

x86_64 now properly save x87 FPU and SSE control words on context switch

Location:
src/libcfa/concurrency
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/CtxSwitch-x86_64.S

    rdd0b961 rffc3b26  
    4949        // Save volatile registers on the stack.
    5050
     51        subq   $8,%rsp
     52        stmxcsr 0(%rsp)         // 4 bytes
     53        fnstcw  4(%rsp)         // 2 bytes
    5154        pushq %r15
    5255        pushq %r14
     
    7275        popq %r14
    7376        popq %r15
     77        fldcw   4(%rsp)
     78        ldmxcsr 0(%rsp)
     79        addq $8,%rsp
    7480
    7581        // Return to thread.
  • src/libcfa/concurrency/invoke.c

    rdd0b961 rffc3b26  
    109109      struct FakeStack {
    110110            void *fixedRegisters[5];                    // fixed registers rbx, r12, r13, r14, r15
    111             void *rturn;                                        // where to go on return from uSwitch
     111            uint32_t mxcr;                                  // SSE Status and Control bits (control bits are preserved across function calls)
     112            uint16_t fcw;                                   // X97 FPU control word (preserved across function calls)
     113            void *rturn;                                      // where to go on return from uSwitch
    112114            void *dummyReturn;                          // NULL return address to provide proper alignment
    113115      };
     
    120122      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[0] = this;
    121123      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[1] = invoke;
     124      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->mxcr = 0; //SSE control word must be zeroed out to be valid
     125      // ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fcw = 0x34;
     126      // ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->padding = 0x56;
    122127#else
    123128      #error Only __i386__ and __x86_64__ is supported for threads in cfa
Note: See TracChangeset for help on using the changeset viewer.