Ignore:
File:
1 edited

Legend:

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

    rd9c44c3 r5c81105  
    77#include "invoke.h"
    88
    9 struct machine_context_t {
    10         void *SP;
    11         void *FP;
    12         void *PC;
    13 };
    14 
    15 extern void coInvokeStub( void );
     9#define __CFA_INVOKE_PRIVATE__
     10#include "invoke.h"
    1611
    1712// magically invoke the "main" of the most derived class
    1813// Called from the kernel when starting a coroutine or task so must switch back to user mode.
    19 void __invokeCoroutine__F_P9scoVtablePv__1(struct coVtable *vtable, void* vthis)
     14
     15void invokeCoroutine(covptr_t* vthis)
    2016{
    21       LIB_DEBUG_PRINTF("Invoke : Received %p (v %p)\n", vthis, vtable);
     17      LIB_DEBUG_PRINTF("Invoke : Received %p (v %p)\n", vthis, *vthis);
    2218
    23       struct coroutine* cor = vtable->this_coroutine(vthis);
     19      struct coroutine* cor = get_coroutine( vthis );
    2420
    2521      cor->state = Active;
    2622
    27       vtable->main(vthis);
     23      (*vthis)->main( get_object(vthis) );
    2824}
    2925
    30 void __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);
    3826
    39       struct coVtable * vtable = get_vtable( vthis );
    40       struct coroutine* this = this_coroutine( vthis );
     27void 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 );
    4131      struct coStack_t* stack = &this->stack;
    4232
     
    4737            void *rturn;                                      // where to go on return from uSwitch
    4838            void *dummyReturn;                          // fake return compiler would have pushed on call to uInvoke
    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
     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
    5141        };
    5242
     
    5545
    5646        ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->dummyReturn = NULL;
    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
     47        ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->argument = vthis;     // argument to invoke
    5948        ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->rturn = invoke;
    6049
     
    7261      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->dummyReturn = NULL;
    7362      ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->rturn = coInvokeStub;
    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;
     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;
    7765#else
    7866      #error Only __i386__ and __x86_64__ is supported for threads in cfa
Note: See TracChangeset for help on using the changeset viewer.