Changes in src/libcfa/concurrency/invoke.c [d9c44c3:5c81105]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/invoke.c
rd9c44c3 r5c81105 7 7 #include "invoke.h" 8 8 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" 16 11 17 12 // magically invoke the "main" of the most derived class 18 13 // 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 15 void invokeCoroutine(covptr_t* vthis) 20 16 { 21 LIB_DEBUG_PRINTF("Invoke : Received %p (v %p)\n", vthis, vtable);17 LIB_DEBUG_PRINTF("Invoke : Received %p (v %p)\n", vthis, *vthis); 22 18 23 struct coroutine* cor = vtable->this_coroutine(vthis);19 struct coroutine* cor = get_coroutine( vthis ); 24 20 25 21 cor->state = Active; 26 22 27 vtable->main(vthis);23 (*vthis)->main( get_object(vthis) ); 28 24 } 29 25 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);38 26 39 struct coVtable * vtable = get_vtable( vthis ); 40 struct coroutine* this = this_coroutine( vthis ); 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 ); 41 31 struct coStack_t* stack = &this->stack; 42 32 … … 47 37 void *rturn; // where to go on return from uSwitch 48 38 void *dummyReturn; // fake return compiler would have pushed on call to uInvoke 49 void *argument [2]; // for 16-byte ABI, 16-byte alignment starts here50 void *padding[ 2]; // padding to force 16-byte alignment, as "base" is 16-byte aligned39 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 51 41 }; 52 42 … … 55 45 56 46 ((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 59 48 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->rturn = invoke; 60 49 … … 72 61 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->dummyReturn = NULL; 73 62 ((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; 77 65 #else 78 66 #error Only __i386__ and __x86_64__ is supported for threads in cfa
Note: See TracChangeset
for help on using the changeset viewer.