Ignore:
Timestamp:
Apr 4, 2019, 3:37:55 PM (3 years ago)
Author:
tdelisle <tdelisle@…>
Branches:
arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
8c01e1b
Parents:
2fabdc02
Message:

Swapped memory storage for context and stack information inside the coroutine implementation

File:
1 edited

Legend:

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

    r2fabdc02 rb2f6113  
    122122        void (*invoke)(void *)
    123123) {
    124         struct coStack_t* stack = &get_coroutine( this )->stack;
     124        struct coroutine_desc * cor = get_coroutine( this );
     125        struct __stack_t * stack = cor->stack.storage;
    125126
    126127#if defined( __i386 )
     
    136137        };
    137138
    138         ((struct machine_context_t *)stack->context)->SP = (char *)stack->base - sizeof( struct FakeStack );
    139         ((struct machine_context_t *)stack->context)->FP = NULL;                // terminate stack with NULL fp
     139        cor->context.SP = (char *)stack->base - sizeof( struct FakeStack );
     140        cor->context.FP = NULL;         // terminate stack with NULL fp
    140141
    141         ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->dummyReturn = NULL;
    142         ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->argument[0] = this;     // argument to invoke
    143         ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->rturn = invoke;
    144         ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->mxcr = 0x1F80; //Vol. 2A 3-520
    145         ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fcw = 0x037F;  //Vol. 1 8-7
     142        struct FakeStack *fs = (struct FakeStack *)cor->context.SP;
     143
     144        fs->dummyReturn = NULL;
     145        fs->argument[0] = this;     // argument to invoke
     146        fs->rturn = invoke;
     147        fs->mxcr = 0x1F80; //Vol. 2A 3-520
     148        fs->fcw = 0x037F;  //Vol. 1 8-7
    146149
    147150#elif defined( __x86_64 )
     
    155158        };
    156159
    157         ((struct machine_context_t *)stack->context)->SP = (char *)stack->base - sizeof( struct FakeStack );
    158         ((struct machine_context_t *)stack->context)->FP = NULL;                // terminate stack with NULL fp
     160        cor->context.SP = (char *)stack->base - sizeof( struct FakeStack );
     161        cor->context.FP = NULL;         // terminate stack with NULL fp
    159162
    160         ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->dummyReturn = NULL;
    161         ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->rturn = CtxInvokeStub;
    162         ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[0] = this;
    163         ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[1] = invoke;
    164         ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->mxcr = 0x1F80; //Vol. 2A 3-520
    165         ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fcw = 0x037F;  //Vol. 1 8-7
     163        struct FakeStack *fs = (struct FakeStack *)cor->context.SP;
     164
     165        fs->dummyReturn = NULL;
     166        fs->rturn = CtxInvokeStub;
     167        fs->fixedRegisters[0] = this;
     168        fs->fixedRegisters[1] = invoke;
     169        fs->mxcr = 0x1F80; //Vol. 2A 3-520
     170        fs->fcw = 0x037F;  //Vol. 1 8-7
    166171
    167172#elif defined( __ARM_ARCH )
     
    173178        };
    174179
    175         ((struct machine_context_t *)stack->context)->SP = (char *)stack->base - sizeof( struct FakeStack );
    176         ((struct machine_context_t *)stack->context)->FP = NULL;
     180        cor->context.SP = (char *)stack->base - sizeof( struct FakeStack );
     181        cor->context.FP = NULL;
    177182
    178         struct FakeStack *fs = (struct FakeStack *)((struct machine_context_t *)stack->context)->SP;
     183        struct FakeStack *fs = (struct FakeStack *)cor->context.SP;
    179184
    180185        fs->intRegs[8] = CtxInvokeStub;
Note: See TracChangeset for help on using the changeset viewer.