Changeset d9c44c3 for src/libcfa/concurrency
- Timestamp:
- Dec 6, 2016, 4:16:47 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:
- fa66f4e
- Parents:
- e4745d7a
- Location:
- src/libcfa/concurrency
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/invoke.c
re4745d7a rd9c44c3 4 4 #include <stdio.h> 5 5 6 #include "libhdr.h" 6 7 #include "invoke.h" 7 8 … … 18 19 void __invokeCoroutine__F_P9scoVtablePv__1(struct coVtable *vtable, void* vthis) 19 20 { 20 printf("Invoke : Received %p (v %p)\n", vthis, vtable);21 LIB_DEBUG_PRINTF("Invoke : Received %p (v %p)\n", vthis, vtable); 21 22 22 23 struct coroutine* cor = vtable->this_coroutine(vthis); … … 34 35 void (*invoke)(struct coVtable *, void *) 35 36 ) { 36 37 #if ! defined( __x86_64__ ) && ! defined( __i386__ ) 38 #error Only __x86_64__ and __i386__ is supported for threads in cfa 39 #endif 40 41 #if defined( __U_SWAPCONTEXT__ ) 42 #error __U_SWAPCONTEXT__ should not be defined for __x86_64__ 43 #endif 37 LIB_DEBUG_PRINTF("StartCoroutine : Passing in %p (v %p) to %p\n", vthis, vtable, invoke); 44 38 45 39 struct coVtable * vtable = get_vtable( vthis ); … … 47 41 struct coStack_t* stack = &this->stack; 48 42 43 #if defined( __i386__ ) 44 45 struct FakeStack { 46 void *fixedRegisters[3]; // fixed registers ebx, edi, esi (popped on 1st uSwitch, values unimportant) 47 void *rturn; // where to go on return from uSwitch 48 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 51 }; 52 53 ((struct machine_context_t *)stack->context)->SP = (char *)stack->base - sizeof( struct FakeStack ); 54 ((struct machine_context_t *)stack->context)->FP = NULL; // terminate stack with NULL fp 55 56 ((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 59 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->rturn = invoke; 60 61 #elif defined( __x86_64__ ) 62 49 63 struct FakeStack { 50 64 void *fixedRegisters[5]; // fixed registers rbx, r12, r13, r14, r15 51 65 void *rturn; // where to go on return from uSwitch 52 66 void *dummyReturn; // NULL return address to provide proper alignment 53 }; // FakeStack67 }; 54 68 55 69 ((struct machine_context_t *)stack->context)->SP = (char *)stack->base - sizeof( struct FakeStack ); 56 70 ((struct machine_context_t *)stack->context)->FP = NULL; // terminate stack with NULL fp 57 58 fprintf(stderr, "StartCoroutine : Passing in %p (v %p) to %p\n", vthis, vtable, invoke);59 71 60 72 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->dummyReturn = NULL; … … 63 75 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[1] = vthis; 64 76 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[2] = invoke; 77 #else 78 #error Only __i386__ and __x86_64__ is supported for threads in cfa 79 #endif 65 80 } -
src/libcfa/concurrency/threads.c
re4745d7a rd9c44c3 166 166 coroutine* dst = this_coroutine(cor); 167 167 168 fprintf(stderr, "Resuming %p from %p\n", dst, src);169 168 if ( src != dst ) { // not resuming self ? 170 169 assertf( dst->notHalted , … … 172 171 "Possible cause is terminated coroutine's main routine has already returned.", 173 172 src->name, src, dst->name, dst ); 174 fprintf(stderr, "Assigning last pointer\n");175 173 dst->last = src; // set last resumer 176 174 } // if
Note: See TracChangeset
for help on using the changeset viewer.