From f860bc0f4e8cc8f7e9e7b00c4a2cff0f08370ba1 Mon Sep 17 00:00:00 2001 From: Kai Backman Date: Fri, 23 Oct 2009 20:31:03 -0700 Subject: [PATCH] fixed len/cap for chan. disable gc for now. go/test: passes 93% (323/345) R=rsc http://go/go-review/1015006 --- src/all-arm.bash | 4 ++++ src/cmd/5g/cgen.c | 27 ++++++++++++++++++++++++++- test/arm-pass.txt | 6 ++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/all-arm.bash b/src/all-arm.bash index 81cba295e9..0bf9927af2 100755 --- a/src/all-arm.bash +++ b/src/all-arm.bash @@ -17,6 +17,10 @@ xcd() { builtin cd $1 } +# temporarily turn GC off +# TODO(kaib): reenable GC once everything else works +export GOGC=off + (xcd ../test ./run-arm ) || exit $? diff --git a/src/cmd/5g/cgen.c b/src/cmd/5g/cgen.c index 347a530f00..b6190c256d 100644 --- a/src/cmd/5g/cgen.c +++ b/src/cmd/5g/cgen.c @@ -271,7 +271,7 @@ cgen(Node *n, Node *res) break; case OLEN: - if(istype(nl->type, TMAP)) { + if(istype(nl->type, TMAP) || istype(nl->type, TCHAN)) { // map has len in the first 32-bit word. // a zero pointer means zero length regalloc(&n1, types[tptr], res); @@ -313,6 +313,31 @@ cgen(Node *n, Node *res) break; case OCAP: + if(istype(nl->type, TCHAN)) { + // chan has cap in the second 32-bit word. + // a zero pointer means zero length + regalloc(&n1, types[tptr], res); + cgen(nl, &n1); + + nodconst(&n2, types[tptr], 0); + regalloc(&n3, n2.type, N); + gmove(&n2, &n3); + gcmp(optoas(OCMP, types[tptr]), &n1, &n3); + regfree(&n3); + p1 = gbranch(optoas(OEQ, types[tptr]), T); + + n2 = n1; + n2.op = OINDREG; + n2.xoffset = 4; + n2.type = types[TINT32]; + gmove(&n2, &n1); + + patch(p1, pc); + + gmove(&n1, res); + regfree(&n1); + break; + } if(isslice(nl->type)) { regalloc(&n1, types[tptr], res); agen(nl, &n1); diff --git a/test/arm-pass.txt b/test/arm-pass.txt index e0d2822fe7..64f4b544be 100644 --- a/test/arm-pass.txt +++ b/test/arm-pass.txt @@ -1,3 +1,4 @@ +235.go 64bit.go args.go assign.go @@ -7,8 +8,11 @@ blank1.go chan/fifo.go chan/goroutines.go chan/perm.go +chan/powser1.go +chan/powser2.go chan/select.go chan/sieve.go +chancap.go char_lit.go closedchan.go closure.go @@ -256,6 +260,7 @@ interface/returntype.go interface/struct.go iota.go ken/array.go +ken/chan.go ken/chan1.go ken/complit.go ken/divconst.go @@ -297,6 +302,7 @@ named.go named1.go nil.go parentype.go +peano.go printbig.go range.go rename.go -- 2.50.0