]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/6g, cmd/8g: disable Duff's device on NaCl.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Fri, 4 Apr 2014 06:42:35 +0000 (08:42 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Fri, 4 Apr 2014 06:42:35 +0000 (08:42 +0200)
Native Client forbids jumps/calls to arbitrary locations and
enforces a particular alignement, which makes the Duff's device
ineffective.

LGTM=khr
R=rsc, dave, khr
CC=golang-codereviews
https://golang.org/cl/84400043

src/cmd/6g/cgen.c
src/cmd/6g/ggen.c
src/cmd/8g/cgen.c
src/cmd/8g/ggen.c

index 9509232dc9af1aff001fd41da6f2cd5e122fe009..eb45b29ea18319368684e28686f18ea1deb40d05 100644 (file)
@@ -1448,7 +1448,7 @@ sgen(Node *n, Node *ns, int64 w)
                gins(ACLD, N, N);
        } else {
                // normal direction
-               if(q > 128) {
+               if(q > 128 || (nacl && q >= 4)) {
                        gconreg(movptr, q, D_CX);
                        gins(AREP, N, N);       // repeat
                        gins(AMOVSQ, N, N);     // MOVQ *(SI)+,*(DI)+
index b980a78c258722c04e9690e4923ec2f40915bcb4..2633b19e4d1e98612a165efb4a617f2ac0f091c4 100644 (file)
@@ -77,7 +77,7 @@ zerorange(Prog *p, vlong frame, vlong lo, vlong hi, uint32 *ax)
                for(i = 0; i < cnt; i += widthreg) {
                        p = appendpp(p, AMOVQ, D_AX, 0, D_SP+D_INDIR, frame+lo+i);
                }
-       } else if(cnt <= 128*widthreg) {
+       } else if(!nacl && (cnt <= 128*widthreg)) {
                p = appendpp(p, leaptr, D_SP+D_INDIR, frame+lo, D_DI, 0);
                p = appendpp(p, ADUFFZERO, D_NONE, 0, D_ADDR, 2*(128-cnt/widthreg));
                p->to.sym = linksym(pkglookup("duffzero", runtimepkg));
@@ -1119,7 +1119,7 @@ clearfat(Node *nl)
        savex(D_AX, &ax, &oldax, N, types[tptr]);
        gconreg(AMOVL, 0, D_AX);
 
-       if(q > 128) {
+       if(q > 128 || (q >= 4 && nacl)) {
                gconreg(movptr, q, D_CX);
                gins(AREP, N, N);       // repeat
                gins(ASTOSQ, N, N);     // STOQ AL,*(DI)+
index 85daeb97e698451b7adb05886cdc7a0080890647..042997a8beb5a0ea8ebfa90b7d080acc384809e8 100644 (file)
@@ -1315,7 +1315,7 @@ sgen(Node *n, Node *res, int64 w)
        } else {
                gins(ACLD, N, N);       // paranoia.  TODO(rsc): remove?
                // normal direction
-               if(q > 128) {
+               if(q > 128 || (q >= 4 && nacl)) {
                        gconreg(AMOVL, q, D_CX);
                        gins(AREP, N, N);       // repeat
                        gins(AMOVSL, N, N);     // MOVL *(SI)+,*(DI)+
index 1b7d81dee60bc0168c7daa50f0c36104b29a79d9..2285a04e61cb38c6d8f8beefa9be1e91bf834b18 100644 (file)
@@ -75,7 +75,7 @@ zerorange(Prog *p, vlong frame, vlong lo, vlong hi, uint32 *ax)
                for(i = 0; i < cnt; i += widthreg) {
                        p = appendpp(p, AMOVL, D_AX, 0, D_SP+D_INDIR, frame+lo+i);
                }
-       } else if(cnt <= 128*widthreg) {
+       } else if(!nacl && cnt <= 128*widthreg) {
                p = appendpp(p, ALEAL, D_SP+D_INDIR, frame+lo, D_DI, 0);
                p = appendpp(p, ADUFFZERO, D_NONE, 0, D_ADDR, 1*(128-cnt/widthreg));
                p->to.sym = linksym(pkglookup("duffzero", runtimepkg));
@@ -176,7 +176,7 @@ clearfat(Node *nl)
        agen(nl, &n1);
        gconreg(AMOVL, 0, D_AX);
 
-       if(q > 128) {
+       if(q > 128 || (q >= 4 && nacl)) {
                gconreg(AMOVL, q, D_CX);
                gins(AREP, N, N);       // repeat
                gins(ASTOSL, N, N);     // STOL AL,*(DI)+