Changeset 80d9e49 for src/libcfa/concurrency/invoke.c
- Timestamp:
- Dec 7, 2016, 2:47:53 PM (8 years ago)
- 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:
- 550a3385
- Parents:
- a68caae
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/invoke.c
ra68caae r80d9e49 13 13 // Called from the kernel when starting a coroutine or task so must switch back to user mode. 14 14 15 void invokeCoroutine(covptr_t* vthis) 16 { 17 LIB_DEBUG_PRINTF("Invoke : Received %p (v %p)\n", vthis, *vthis); 15 extern void __suspend__F___1(void); 18 16 19 struct coroutine* cor = get_coroutine( vthis ); 17 void invokeCoroutine( 18 void (*main)(void *), 19 struct coroutine *(*get_coroutine)(void *), 20 void *this 21 ) { 22 LIB_DEBUG_PRINTF("Invoke : Received %p (main %p, get_c %p)\n", this, main, get_coroutine); 23 24 struct coroutine* cor = get_coroutine( this ); 25 26 if(cor->state == Primed) { 27 __suspend__F___1(); 28 } 20 29 21 30 cor->state = Active; 22 31 23 (*vthis)->main( get_object(vthis));32 main( this ); 24 33 } 25 34 26 35 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); 36 void startCoroutine( 37 void (*main)(void *), 38 struct coroutine *(*get_coroutine)(void *), 39 void *this, 40 void (*invoke)(void *) 41 ) { 42 LIB_DEBUG_PRINTF("StartCoroutine : Passing in %p (main %p, get_c %p) to %p\n", this, main, get_coroutine, invoke); 29 43 30 struct coroutine* this = get_coroutine( vthis ); 31 struct coStack_t* stack = &this->stack; 44 struct coStack_t* stack = &get_coroutine( this )->stack; 32 45 33 46 #if defined( __i386__ ) … … 37 50 void *rturn; // where to go on return from uSwitch 38 51 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 aligned52 void *argument[3]; // for 16-byte ABI, 16-byte alignment starts here 53 void *padding; // padding to force 16-byte alignment, as "base" is 16-byte aligned 41 54 }; 42 55 … … 45 58 46 59 ((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 invoke60 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->argument[0] = this; // argument to invoke 48 61 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->rturn = invoke; 49 62 … … 61 74 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->dummyReturn = NULL; 62 75 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->rturn = coInvokeStub; 63 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[0] = vthis;76 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[0] = this; 64 77 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[1] = invoke; 65 78 #else
Note: See TracChangeset
for help on using the changeset viewer.