Skip to content

Commit

Permalink
Merge pull request #3791 from AndrewEdwards/2.066
Browse files Browse the repository at this point in the history
Cherry-picking commits from master to 2.066 branch (for beta5)
  • Loading branch information
AndrewEdwards committed Jul 21, 2014
2 parents 120cae6 + 2c4668b commit 0f27686
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 11 deletions.
9 changes: 7 additions & 2 deletions src/backend/cgcod.c
Expand Up @@ -1131,8 +1131,13 @@ void stackoffsets(int flags)
* but are 4 byte aligned on the OSX 32 stack.
*/
Para.offset = align(REGSIZE,Para.offset); /* align on word stack boundary */
if (I64 && alignsize == 16 && Para.offset & 8)
Para.offset += 8;
if (alignsize == 16 && (I64 || tyvector(s->ty())))
{
if (Para.offset & 4)
Para.offset += 4;
if (Para.offset & 8)
Para.offset += 8;
}
s->Soffset = Para.offset;
//printf("%s param offset = x%lx, alignsize = %d\n",s->Sident,(long)s->Soffset, (int)alignsize);
Para.offset += (s->Sflags & SFLdouble)
Expand Down
3 changes: 2 additions & 1 deletion src/backend/cod1.c
Expand Up @@ -2670,7 +2670,8 @@ code *cdfunc(elem *e,regm_t *pretregs)
parameters[i].reg = NOREG;
unsigned alignsize = el_alignsize(ep);
parameters[i].numalign = 0;
if (I64 && alignsize > stackalign)
if (alignsize > stackalign &&
(I64 || (alignsize == 16 && tyvector(ep->Ety))))
{ unsigned newnumpara = (numpara + (alignsize - 1)) & ~(alignsize - 1);
parameters[i].numalign = newnumpara - numpara;
numpara = newnumpara;
Expand Down
1 change: 1 addition & 0 deletions src/backend/rtlsym.h
Expand Up @@ -68,6 +68,7 @@ SYMBOL_MARS(MEMSET80, FLfunc,FREGSAVED,"_memset80", 0, t) \
SYMBOL_MARS(MEMSET160, FLfunc,FREGSAVED,"_memset160",0, t) \
SYMBOL_MARS(MEMSETFLOAT, FLfunc,FREGSAVED,"_memsetFloat", 0, t) \
SYMBOL_MARS(MEMSETDOUBLE, FLfunc,FREGSAVED,"_memsetDouble", 0, t) \
SYMBOL_MARS(MEMSETSIMD, FLfunc,FREGSAVED,"_memsetSIMD",0, t) \
SYMBOL_MARS(MEMSETN, FLfunc,FREGSAVED,"_memsetn", 0, t) \
SYMBOL_MARS(MODULO, FLfunc,FREGSAVED,"_modulo", 0, t) \
SYMBOL_MARS(MONITORENTER, FLfunc,FREGSAVED,"_d_monitorenter",0, t) \
Expand Down
20 changes: 16 additions & 4 deletions src/e2ir.c
Expand Up @@ -728,6 +728,10 @@ elem *setArray(elem *eptr, elem *edim, Type *tb, elem *evalue, IRState *irs, int
goto Ldefault;
}

case Tvector:
r = RTLSYM_MEMSETSIMD;
break;

default:
Ldefault:
switch (sz)
Expand Down Expand Up @@ -767,10 +771,18 @@ elem *setArray(elem *eptr, elem *edim, Type *tb, elem *evalue, IRState *irs, int
* register, but the argument pusher may have other ideas on I64.
* MEMSETN is inefficient, though.
*/
if (tybasic(evalue->ET->Tty) == TYstruct &&
!evalue->ET->Ttag->Sstruct->Sarg1type &&
!evalue->ET->Ttag->Sstruct->Sarg2type)
r = RTLSYM_MEMSETN;
if (tybasic(evalue->ET->Tty) == TYstruct)
{
type *t1 = evalue->ET->Ttag->Sstruct->Sarg1type;
type *t2 = evalue->ET->Ttag->Sstruct->Sarg2type;
if (!t1 && !t2)
r = RTLSYM_MEMSETN;
else if (config.exe != EX_WIN64 &&
r == RTLSYM_MEMSET128ii &&
t1->Tty == TYdouble &&
t2->Tty == TYdouble)
r = RTLSYM_MEMSET128;
}
}

if (r == RTLSYM_MEMSETN)
Expand Down
29 changes: 25 additions & 4 deletions src/func.c
Expand Up @@ -1471,9 +1471,20 @@ void FuncDeclaration::semantic3(Scope *sc)
}
if (inv)
{
e = new DsymbolExp(Loc(), inv);
//e = new DsymbolExp(Loc(), inv);
//e = new CallExp(Loc(), e);
//e = e->semantic(sc2);

/* Bugzilla 13113: Currently virtual invariant calls completely
* bypass attribute enforcement.
* Change the behavior of pre-invariant call by following it.
*/
e = new ThisExp(Loc());
e->type = vthis->type;
e = new DotVarExp(Loc(), e, inv, 0);
e->type = inv->type;
e = new CallExp(Loc(), e);
e = e->semantic(sc2);
e->type = Type::tvoid;
}
}
else
Expand Down Expand Up @@ -1512,9 +1523,19 @@ void FuncDeclaration::semantic3(Scope *sc)
}
if (inv)
{
e = new DsymbolExp(Loc(), inv);
//e = new DsymbolExp(Loc(), inv);
//e = new CallExp(Loc(), e);
//e = e->semantic(sc2);

/* Bugzilla 13113: As same as pre-invariant in destructor,
* change the behavior of post-invariant call.
*/
e = new ThisExp(Loc());
e->type = vthis->type;
e = new DotVarExp(Loc(), e, inv, 0);
e->type = inv->type;
e = new CallExp(Loc(), e);
e = e->semantic(sc2);
e->type = Type::tvoid;
}
}
else
Expand Down
16 changes: 16 additions & 0 deletions test/runnable/mars1.d
Expand Up @@ -1110,6 +1110,21 @@ void test12833()
test12833a(0x1_0000);
}

/***********************************************/

struct Point9449
{
double f = 3.0;
double g = 4.0;
}

void test9449()
{
Point9449[1] arr;
if (arr[0].f != 3.0) assert(0);
if (arr[0].g != 4.0) assert(0);
}

////////////////////////////////////////////////////////////////////////

int main()
Expand Down Expand Up @@ -1143,6 +1158,7 @@ int main()
test10678();
test7565();
test12833();
test9449();
printf("Success\n");
return 0;
}
34 changes: 34 additions & 0 deletions test/runnable/testinvariant.d
Expand Up @@ -106,10 +106,44 @@ void test6453()
}
}

/***************************************************/
// 13113

struct S13113
{
static int count;
invariant() // impure, throwable, system, and gc-able
{
++count; // impure
}

this(int) pure nothrow @safe @nogc {}
// post invaiant is called directly but doesn't interfere with constructor attributes

~this() pure nothrow @safe @nogc {}
// pre invaiant is called directly but doesn't interfere with destructor attributes

void foo() pure nothrow @safe @nogc {}
// pre & post invariant calls don't interfere with method attributes
}

void test13113()
{
assert(S13113.count == 0);
{
auto s = S13113(1);
assert(S13113.count == 1);
s.foo();
assert(S13113.count == 3);
}
assert(S13113.count == 4);
}

/***************************************************/

void main()
{
testinvariant();
test6453();
test13113();
}
8 changes: 8 additions & 0 deletions test/runnable/testxmm.d
Expand Up @@ -1186,6 +1186,13 @@ void test12852()

/*****************************************/

void test9449()
{
ubyte16 table[1];
}

/*****************************************/

int main()
{
test1();
Expand Down Expand Up @@ -1214,6 +1221,7 @@ int main()
test9304();
test9910();
test12852();
test9449();

return 0;
}
Expand Down

0 comments on commit 0f27686

Please sign in to comment.