summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTianon Gravi <admwiggin@gmail.com>2015-05-02 10:02:54 -0600
committerTianon Gravi <admwiggin@gmail.com>2015-05-02 10:02:54 -0600
commit839657a730bd3c82d1b7932f996dd87448eb7d38 (patch)
treed46006c2df507ba8cfd57a47169d326349b5c749 /src
parent90ad8a7e5881be7834909c649f994b6b5244c965 (diff)
downloadgolang-upstream-sid.tar.gz
Imported Upstream version 1.4.2upstream/1.4.2upstream-sid
Diffstat (limited to 'src')
-rw-r--r--src/cmd/5g/cgen.c11
-rw-r--r--src/cmd/gc/align.c5
-rw-r--r--src/cmd/gc/go.h1
-rw-r--r--src/cmd/gc/inl.c9
-rw-r--r--src/cmd/gc/subr.c9
-rw-r--r--src/cmd/gc/typecheck.c2
-rw-r--r--src/cmd/go/doc.go1
-rw-r--r--src/cmd/go/generate.go5
-rw-r--r--src/cmd/go/generate_test.go6
-rw-r--r--src/math/big/int.go2
-rw-r--r--src/math/big/int_test.go1
-rw-r--r--src/runtime/mgc0.c3
-rw-r--r--src/runtime/syscall_windows.go10
-rw-r--r--src/runtime/syscall_windows_test.go8
14 files changed, 58 insertions, 15 deletions
diff --git a/src/cmd/5g/cgen.c b/src/cmd/5g/cgen.c
index c535cfbef..87c64f6e8 100644
--- a/src/cmd/5g/cgen.c
+++ b/src/cmd/5g/cgen.c
@@ -236,18 +236,14 @@ cgen(Node *n, Node *res)
cgen(nl, &n1);
nodconst(&n2, nl->type, -1);
gins(a, &n2, &n1);
- gmove(&n1, res);
- regfree(&n1);
- goto ret;
+ goto norm;
case OMINUS:
regalloc(&n1, nl->type, N);
cgen(nl, &n1);
nodconst(&n2, nl->type, 0);
gins(optoas(OMINUS, nl->type), &n2, &n1);
- gmove(&n1, res);
- regfree(&n1);
- goto ret;
+ goto norm;
// symmetric binary
case OAND:
@@ -483,12 +479,15 @@ abop: // asymmetric binary
cgen(nl, &n1);
}
gins(a, &n2, &n1);
+norm:
// Normalize result for types smaller than word.
if(n->type->width < widthptr) {
switch(n->op) {
case OADD:
case OSUB:
case OMUL:
+ case OCOM:
+ case OMINUS:
gins(optoas(OAS, n->type), &n1, &n1);
break;
}
diff --git a/src/cmd/gc/align.c b/src/cmd/gc/align.c
index 6e5d149c7..63ed2e5af 100644
--- a/src/cmd/gc/align.c
+++ b/src/cmd/gc/align.c
@@ -128,6 +128,11 @@ dowidth(Type *t)
return;
}
+ // break infinite recursion if the broken recursive type
+ // is referenced again
+ if(t->broke && t->width == 0)
+ return;
+
// defer checkwidth calls until after we're done
defercalc++;
diff --git a/src/cmd/gc/go.h b/src/cmd/gc/go.h
index 965a0550d..bbb883513 100644
--- a/src/cmd/gc/go.h
+++ b/src/cmd/gc/go.h
@@ -974,6 +974,7 @@ EXTERN int funcdepth;
EXTERN int typecheckok;
EXTERN int compiling_runtime;
EXTERN int compiling_wrappers;
+EXTERN int inl_nonlocal;
EXTERN int use_writebarrier;
EXTERN int pure_go;
EXTERN char* flag_installsuffix;
diff --git a/src/cmd/gc/inl.c b/src/cmd/gc/inl.c
index cf89b0090..45e15bb9b 100644
--- a/src/cmd/gc/inl.c
+++ b/src/cmd/gc/inl.c
@@ -804,9 +804,12 @@ inlvar(Node *var)
n->curfn = curfn; // the calling function, not the called one
n->addrtaken = var->addrtaken;
- // esc pass wont run if we're inlining into a iface wrapper
- // luckily, we can steal the results from the target func
- if(var->esc == EscHeap)
+ // Esc pass wont run if we're inlining into a iface wrapper.
+ // Luckily, we can steal the results from the target func.
+ // If inlining a function defined in another package after
+ // escape analysis is done, treat all local vars as escaping.
+ // See issue 9537.
+ if(var->esc == EscHeap || (inl_nonlocal && var->op == ONAME))
addrescapes(n);
curfn->dcl = list(curfn->dcl, n);
diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c
index c3bc5af3b..26153d39b 100644
--- a/src/cmd/gc/subr.c
+++ b/src/cmd/gc/subr.c
@@ -2614,7 +2614,16 @@ genwrapper(Type *rcvr, Type *method, Sym *newnam, int iface)
fn->dupok = 1;
typecheck(&fn, Etop);
typechecklist(fn->nbody, Etop);
+
+ // Set inl_nonlocal to whether we are calling a method on a
+ // type defined in a different package. Checked in inlvar.
+ if(!methodrcvr->local)
+ inl_nonlocal = 1;
+
inlcalls(fn);
+
+ inl_nonlocal = 0;
+
curfn = nil;
funccompile(fn, 0);
}
diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c
index 714c66268..ce12f150a 100644
--- a/src/cmd/gc/typecheck.c
+++ b/src/cmd/gc/typecheck.c
@@ -1335,7 +1335,7 @@ reswitch:
goto error;
// Unpack multiple-return result before type-checking.
- if(istype(t, TSTRUCT)) {
+ if(istype(t, TSTRUCT) && t->funarg) {
t = t->type;
if(istype(t, TFIELD))
t = t->type;
diff --git a/src/cmd/go/doc.go b/src/cmd/go/doc.go
index d0d8a8a5b..7191ee0f3 100644
--- a/src/cmd/go/doc.go
+++ b/src/cmd/go/doc.go
@@ -308,6 +308,7 @@ The generator is run in the package's source directory.
Go generate accepts one specific flag:
-run=""
+ TODO: This flag is unimplemented.
if non-empty, specifies a regular expression to
select directives whose command matches the expression.
diff --git a/src/cmd/go/generate.go b/src/cmd/go/generate.go
index baf4d2b55..3c0af8760 100644
--- a/src/cmd/go/generate.go
+++ b/src/cmd/go/generate.go
@@ -106,6 +106,7 @@ The generator is run in the package's source directory.
Go generate accepts one specific flag:
-run=""
+ TODO: This flag is unimplemented.
if non-empty, specifies a regular expression to
select directives whose command matches the expression.
@@ -255,6 +256,10 @@ func (g *Generator) split(line string) []string {
// Parse line, obeying quoted strings.
var words []string
line = line[len("//go:generate ") : len(line)-1] // Drop preamble and final newline.
+ // There may still be a carriage return.
+ if len(line) > 0 && line[len(line)-1] == '\r' {
+ line = line[:len(line)-1]
+ }
// One (possibly quoted) word per iteration.
Words:
for {
diff --git a/src/cmd/go/generate_test.go b/src/cmd/go/generate_test.go
index 660ebabbe..2ec548630 100644
--- a/src/cmd/go/generate_test.go
+++ b/src/cmd/go/generate_test.go
@@ -40,9 +40,15 @@ func TestGenerateCommandParse(t *testing.T) {
}
g.setShorthand([]string{"-command", "yacc", "go", "tool", "yacc"})
for _, test := range splitTests {
+ // First with newlines.
got := g.split("//go:generate " + test.in + "\n")
if !reflect.DeepEqual(got, test.out) {
t.Errorf("split(%q): got %q expected %q", test.in, got, test.out)
}
+ // Then with CRLFs, thank you Windows.
+ got = g.split("//go:generate " + test.in + "\r\n")
+ if !reflect.DeepEqual(got, test.out) {
+ t.Errorf("split(%q): got %q expected %q", test.in, got, test.out)
+ }
}
}
diff --git a/src/math/big/int.go b/src/math/big/int.go
index d22e39e7c..ade5c2fc8 100644
--- a/src/math/big/int.go
+++ b/src/math/big/int.go
@@ -887,7 +887,7 @@ func (z *Int) AndNot(x, y *Int) *Int {
}
// x &^ (-y) == x &^ ^(y-1) == x & (y-1)
- y1 := nat(nil).add(y.abs, natOne)
+ y1 := nat(nil).sub(y.abs, natOne)
z.abs = z.abs.and(x.abs, y1)
z.neg = false
return z
diff --git a/src/math/big/int_test.go b/src/math/big/int_test.go
index 6070cf325..2d762dbc8 100644
--- a/src/math/big/int_test.go
+++ b/src/math/big/int_test.go
@@ -1201,6 +1201,7 @@ var bitwiseTests = []struct {
{"-0x01", "-0x01", "-0x01", "-0x01", "0x00", "0x00"},
{"0x07", "0x08", "0x00", "0x0f", "0x0f", "0x07"},
{"0x05", "0x0f", "0x05", "0x0f", "0x0a", "0x00"},
+ {"0xff", "-0x0a", "0xf6", "-0x01", "-0xf7", "0x09"},
{"0x013ff6", "0x9a4e", "0x1a46", "0x01bffe", "0x01a5b8", "0x0125b0"},
{"-0x013ff6", "0x9a4e", "0x800a", "-0x0125b2", "-0x01a5bc", "-0x01c000"},
{"-0x013ff6", "-0x9a4e", "-0x01bffe", "-0x1a46", "0x01a5b8", "0x8008"},
diff --git a/src/runtime/mgc0.c b/src/runtime/mgc0.c
index 7754bad89..083beec22 100644
--- a/src/runtime/mgc0.c
+++ b/src/runtime/mgc0.c
@@ -350,6 +350,9 @@ scanblock(byte *b, uintptr n, byte *ptrmask)
x -= (uintptr)arena_start>>PageShift;
s = runtime·mheap.spans[x];
if(s == nil || k < s->start || obj >= s->limit || s->state != MSpanInUse) {
+ // Sometimes 32-bit heaps have holes. See issue 9872
+ if(PtrSize == 4 && s == nil)
+ continue;
// Stack pointers lie within the arena bounds but are not part of the GC heap.
// Ignore them.
if(s != nil && s->state == MSpanStack)
diff --git a/src/runtime/syscall_windows.go b/src/runtime/syscall_windows.go
index 5b76ad573..51004b78a 100644
--- a/src/runtime/syscall_windows.go
+++ b/src/runtime/syscall_windows.go
@@ -54,11 +54,13 @@ func compileCallback(fn eface, cleanstack bool) (code uintptr) {
panic("compilecallback: output parameter size is wrong")
}
argsize := uintptr(0)
- for _, t := range (*[1024](*_type))(unsafe.Pointer(&ft.in[0]))[:len(ft.in)] {
- if (*t).size > uintptrSize {
- panic("compilecallback: input parameter size is wrong")
+ if len(ft.in) > 0 {
+ for _, t := range (*[1024](*_type))(unsafe.Pointer(&ft.in[0]))[:len(ft.in)] {
+ if (*t).size > uintptrSize {
+ panic("compilecallback: input parameter size is wrong")
+ }
+ argsize += uintptrSize
}
- argsize += uintptrSize
}
lock(&cbs.lock)
diff --git a/src/runtime/syscall_windows_test.go b/src/runtime/syscall_windows_test.go
index ce8a9ec1b..126bef62e 100644
--- a/src/runtime/syscall_windows_test.go
+++ b/src/runtime/syscall_windows_test.go
@@ -533,3 +533,11 @@ func main() {
println(z)
}
`
+
+func TestCallbackWithNoInputParameters(t *testing.T) {
+ // Test that NewCallback and NewCallbackCDecl can accept functions without
+ // input parameters, see issue 9871.
+ cb := func() uintptr { return 0 }
+ _ = syscall.NewCallback(cb)
+ _ = syscall.NewCallbackCDecl(cb)
+}