Core: Fixed issue with CoWork, removed HEAP256 option

git-svn-id: svn://ultimatepp.org/upp/trunk@11656 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2018-01-03 08:06:45 +00:00
parent 8255e39818
commit 545403c24b
5 changed files with 3 additions and 35 deletions

View file

@ -4,7 +4,7 @@ namespace Upp {
#ifdef _MULTITHREADED
#define LLOG(x) // DLOG(x)
#define LLOG(x) // RLOG(x)
#define LDUMP(x) // DDUMP(x)
#define LHITCOUNT(x) // RHITCOUNT(x)
@ -193,12 +193,13 @@ void CoWork::Do0(Function<void ()>&& fn, bool looper)
LLOG("Stack full: running in the originating thread");
LHITCOUNT("CoWork: Stack full: Running in originating thread");
p.lock.Leave();
Pool::finlock = false;
fn();
if(Pool::finlock)
p.lock.Leave();
return;
}
p.PushJob(pick(fn), this);
p.PushJob(pick(fn), this, looper);
todo++;
p.lock.Leave();
}

View file

@ -1,7 +1,5 @@
#ifdef UPP_HEAP
#define HEAP256
void *MemoryAllocPermanent(size_t size);
void *MemoryAllocSz(size_t& size);

View file

@ -4,11 +4,7 @@ void *SysAllocRaw(size_t size, size_t reqsize);
void SysFreeRaw(void *ptr, size_t size);
void *AllocRaw4KB(int reqsize);
#ifdef HEAP256
void *AllocRaw256KB(int reqsize);
#else
void *AllocRaw64KB(int reqsize);
#endif
void *LAlloc(size_t& size);
void LFree(void *ptr);
@ -73,16 +69,10 @@ struct Heap {
};
struct Header { // Large block header
#ifdef HEAP256
dword prev:31;
dword free:1;
dword size;
#else
byte free;
byte filler1, filler2, filler3;
word size;
word prev;
#endif
Heap *heap;
#ifdef CPU_32
dword filler4;
@ -103,13 +93,8 @@ struct Heap {
BIGHDRSZ = 48, // size of huge block header
REMOTE_OUT_SZ = 2000, // maximum size of remote frees to be buffered to flush at once
#ifdef HEAP256
MAXBLOCK = 256*1024 - 2 * sizeof(Header) - LARGEHDRSZ, // maximum size of large block
LBINS = 95, // number of large size bins
#else
MAXBLOCK = 65536 - 2 * sizeof(Header) - LARGEHDRSZ, // maximum size of large block
LBINS = 77, // number of large size bins
#endif
};
static_assert(sizeof(Header) == 16, "Wrong sizeof(Header)");
@ -126,11 +111,7 @@ struct Heap {
bool initialized;
#ifdef HEAP256
static int BinSz[LBINS]; // block size for bin
#else
static word BinSz[LBINS]; // block size for bin
#endif
static byte SzBin[MAXBLOCK / 8 + 1]; // maps size/8 to bin
static byte BlBin[MAXBLOCK / 8 + 1]; // Largest bin less or equal to size/8 (free -> bin)

View file

@ -161,11 +161,7 @@ void Heap::Check() {
while(l != large) {
Header *bh = (Header *)((byte *)l + LARGEHDRSZ);
while(bh->size) {
#ifdef HEAP256
Assert((byte *)bh >= (byte *)l + LARGEHDRSZ && (byte *)bh < (byte *)l + 256*1024);
#else
Assert((byte *)bh >= (byte *)l + LARGEHDRSZ && (byte *)bh < (byte *)l + 65536);
#endif
if(bh->free)
DbgFreeCheck(bh->GetBlock() + 1, bh->size - sizeof(DLink));
bh = bh->Next();

View file

@ -8,11 +8,7 @@ namespace Upp {
#include "HeapImp.h"
#ifdef HEAP256
int Heap::BinSz[LBINS];
#else
word Heap::BinSz[LBINS];
#endif
byte Heap::SzBin[MAXBLOCK / 8 + 1]; // Minimal bin for size (request -> bin)
byte Heap::BlBin[MAXBLOCK / 8 + 1]; // Largest bin less or equal to size (free -> bin)
@ -73,11 +69,7 @@ Heap::DLink *Heap::AddChunk(int reqsize)
LLOG("Retrieved empty large " << (void *)ml);
}
else {
#ifdef HEAP256
ml = (DLink *)AllocRaw256KB(reqsize);
#else
ml = (DLink *)AllocRaw64KB(reqsize);
#endif
LLOG("AllocRaw64KB " << (void *)ml);
}
lcount++;