dotnet / corert

This repo contains CoreRT, an experimental .NET Core runtime optimized for AOT (ahead of time compilation) scenarios, with the accompanying compiler toolchain.

Home Page:http://dot.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wasm: RhpNewFastMisalign

yowl opened this issue · comments

commented

@jkotas Did I get this right? I didn't do the fast path where there's a test something like advance <= acontext->alloc_limit so it always goes to RhpGcAlloc(pEEType, GC_ALLOC_ALIGN8_BIAS, size, NULL) . Looking at this path, I think it will go to

GCHeapUtilities::GetGCHeap()->Alloc(pThread->GetAllocContext(), cbSize, uFlags)

and then

hp->allocate (size + ComputeMaxStructAlignPad(requiredAlignment), acontext, flags)

and finally if there is enough space

        uint8_t*  result = acontext->alloc_ptr;
        acontext->alloc_ptr+=size;
        if (acontext->alloc_ptr <= acontext->alloc_limit)
        {
            CObjectHeader* obj = (CObjectHeader*)result;
            assert (obj != 0);
            return obj;
        }

And it won't be aligned. I take it from this that I have to implement the fast path in RhpNewFastMisalign?

I think that the problem is that GC_ALLOC_ALIGN8_BIAS flag expects to be passed in together with GC_ALLOC_ALIGN8 flag. This is how these flags are set in CoreCLR:

            flags |= GC_ALLOC_ALIGN8;
            if (pMT->IsValueType())
                flags |= GC_ALLOC_ALIGN8_BIAS;

So changing GC_ALLOC_ALIGN8_BIAS to GC_ALLOC_ALIGN8 | GC_ALLOC_ALIGN8_BIAS should make this work.