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