Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/invoke.c

    r5c81105 rd9c44c3  
    77#include "invoke.h"
    88
    9 #define __CFA_INVOKE_PRIVATE__
    10 #include "invoke.h"
     9struct machine_context_t {
     10        void *SP;
     11        void *FP;
     12        void *PC;
     13};
     14
     15extern void coInvokeStub( void );
    1116
    1217// magically invoke the "main" of the most derived class
    1318// Called from the kernel when starting a coroutine or task so must switch back to user mode.
     19void __invokeCoroutine__F_P9scoVtablePv__1(struct coVtable *vtable, void* vthis)
     20{
     21      LIB_DEBUG_PRINTF("Invoke : Received %p (v %p)\n", vthis, vtable);
    1422
    15 void invokeCoroutine(covptr_t* vthis)
    16 {
    17       LIB_DEBUG_PRINTF("Invoke : Received %p (v %p)\n", vthis, *vthis);
    18 
    19       struct coroutine* cor = get_coroutine( vthis );
     23      struct coroutine* cor = vtable->this_coroutine(vthis);
    2024
    2125      cor->state = Active;
    2226
    23       (*vthis)->main( get_object(vthis) );
     27      vtable->main(vthis);
    2428}
    2529
     30void __startCoroutine__A0_1_0___this_coroutine__PFP10scoroutine_Pd0___co_main__PF_Pd0___vtable__PFP9scoVtable_Pd0__F_Pd0PF_P9scoVtablePv___1(
     31      struct coroutine *(*this_coroutine)(void * ),
     32      void (*co_main)(void *),
     33      struct coVtable *(*get_vtable)(void *),
     34      void *vthis,
     35      void (*invoke)(struct coVtable *, void *)
     36) {
     37      LIB_DEBUG_PRINTF("StartCoroutine : Passing in %p (v %p) to %p\n", vthis, vtable, invoke);
    2638
    27 void startCoroutine(covptr_t* vthis, void (*invoke)(covptr_t*)) {
    28       LIB_DEBUG_PRINTF("StartCoroutine : Passing in %p (v %p) to %p\n", vthis, *vthis, invoke);
    29 
    30       struct coroutine* this = get_coroutine( vthis );
     39      struct coVtable * vtable = get_vtable( vthis );
     40      struct coroutine* this = this_coroutine( vthis );
    3141      struct coStack_t* stack = &this->stack;
    3242
     
    3747            void *rturn;                                      // where to go on return from uSwitch
    3848            void *dummyReturn;                          // fake return compiler would have pushed on call to uInvoke
    39             void *argument;                             // for 16-byte ABI, 16-byte alignment starts here
    40             void *padding[3];                           // padding to force 16-byte alignment, as "base" is 16-byte aligned
     49            void *argument[2];                          // for 16-byte ABI, 16-byte alignment starts here
     50            void *padding[2];                           // padding to force 16-byte alignment, as "base" is 16-byte aligned
    4151        };
    4252
     
    4555
    4656        ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->dummyReturn = NULL;
    47         ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->argument = vthis;     // argument to invoke
     57        ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->argument[0] = vtable; // argument to invoke
     58      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->argument[1] = vthis;  // argument to invoke
    4859        ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->rturn = invoke;
    4960
     
    6172      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->dummyReturn = NULL;
    6273      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->rturn = coInvokeStub;
    63       ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[0] = vthis;
    64       ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[1] = invoke;
     74      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[0] = vtable;
     75      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[1] = vthis;
     76      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[2] = invoke;
    6577#else
    6678      #error Only __i386__ and __x86_64__ is supported for threads in cfa
Note: See TracChangeset for help on using the changeset viewer.