Skip to content

Commit

Permalink
Merge pull request #3613 from WalterBright/hpohl-opt
Browse files Browse the repository at this point in the history
Increase allocation chunk size + minor refactoring
  • Loading branch information
andralex authored and 9rnsr committed Jul 16, 2014
1 parent c823855 commit a35eec5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
31 changes: 6 additions & 25 deletions src/declaration.c
Expand Up @@ -2072,25 +2072,7 @@ Expression *VarDeclaration::getConstInitializer(bool needFullType)

bool VarDeclaration::canTakeAddressOf()
{
#if 0
/* Global variables and struct/class fields of the form:
* const int x = 3;
* are not stored and hence cannot have their address taken.
*/
if ((isConst() || isImmutable()) &&
storage_class & STCinit &&
(!(storage_class & (STCstatic | STCextern)) || isField()) &&
(!parent || toParent()->isModule() || toParent()->isTemplateInstance()) &&
type->toBasetype()->isTypeBasic()
)
{
return false;
}
#else
if (storage_class & STCmanifest)
return false;
#endif
return true;
return !(storage_class & STCmanifest);
}


Expand All @@ -2106,19 +2088,18 @@ bool VarDeclaration::isDataseg()
printf("%llx, isModule: %p, isTemplateInstance: %p\n", storage_class & (STCstatic | STCconst), parent->isModule(), parent->isTemplateInstance());
printf("parent = '%s'\n", parent->toChars());
#endif
if (storage_class & STCmanifest)
if (!canTakeAddressOf())
return false;
Dsymbol *parent = this->toParent();
Dsymbol *parent = toParent();
if (!parent && !(storage_class & STCstatic))
{
error("forward referenced");
type = Type::terror;
return false;
}
return canTakeAddressOf() &&
(storage_class & (STCstatic | STCextern | STCtls | STCgshared) ||
toParent()->isModule() ||
toParent()->isTemplateInstance());
return (storage_class & (STCstatic | STCextern | STCtls | STCgshared) ||
parent->isModule() ||
parent->isTemplateInstance());
}

/************************************
Expand Down
8 changes: 3 additions & 5 deletions src/root/rmem.c
Expand Up @@ -129,11 +129,9 @@ void Mem::error()
/* Allocate, but never release
*/

// Allocate a little less than 64kB because the C runtime adds some overhead that
// causes the actual memory block to be larger than 64kB otherwise. E.g. the dmc
// runtime rounds the size up to 128kB, but the remaining space in the chunk is less
// than 64kB, so it cannot be used by another chunk.
#define CHUNK_SIZE (4096 * 16 - 64)
// Allocate a little less than 1Mb because the C runtime adds some overhead that
// causes the actual memory block to be larger than 1Mb otherwise.
#define CHUNK_SIZE (256 * 4096 - 64)

static size_t heapleft = 0;
static void *heapp;
Expand Down

0 comments on commit a35eec5

Please sign in to comment.