From 1f11ece67f8b4d329dcf98ca0b214e4da515e446 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 1 Feb 2010 15:20:19 -0800 Subject: [PATCH] nacl: fix build, finally fixed 8l convergence bug R=r CC=golang-dev https://golang.org/cl/199042 --- src/all-nacl.bash | 4 +++ src/cmd/8l/l.h | 1 + src/cmd/8l/span.c | 13 ++++--- src/cmd/ld/pe.c | 2 +- src/pkg/runtime/nacl/mem.c | 28 +++++++++++++++ test/nacl-pass.txt | 72 ++++++++++++++++++++++++++++++++++++-- test/run-nacl | 7 +++- 7 files changed, 119 insertions(+), 8 deletions(-) create mode 100644 src/pkg/runtime/nacl/mem.c diff --git a/src/all-nacl.bash b/src/all-nacl.bash index dce9e62545b..23107d25e34 100755 --- a/src/all-nacl.bash +++ b/src/all-nacl.bash @@ -18,18 +18,22 @@ xcd() { } (xcd pkg/exp/nacl/srpc +make clean make install ) || exit $? (xcd pkg/exp/nacl/av +make clean make install ) || exit $? (xcd pkg/exp/4s +make clean make ) || exit $? (xcd pkg/exp/spacewar +make clean make ) || exit $? diff --git a/src/cmd/8l/l.h b/src/cmd/8l/l.h index adc3f4dee1d..dd559e41959 100644 --- a/src/cmd/8l/l.h +++ b/src/cmd/8l/l.h @@ -102,6 +102,7 @@ struct Prog char tt; uchar mark; /* work on these */ uchar back; + uchar bigjmp; }; struct Auto diff --git a/src/cmd/8l/span.c b/src/cmd/8l/span.c index d46f86ff687..f649777ec39 100644 --- a/src/cmd/8l/span.c +++ b/src/cmd/8l/span.c @@ -73,8 +73,7 @@ start: if(debug['v']) Bprint(&bso, "%5.2f span %d\n", cputime(), n); Bflush(&bso); - if(n > 500) { - // TODO(rsc): figure out why nacl takes so long to converge. + if(n > 50) { print("span must be looping - %d\n", textsize); errorexit(); } @@ -1183,10 +1182,13 @@ found: q = p->pcond; if(q) { v = q->pc - p->pc - 2; - if(v >= -128 && v <= 127) { + if(q->pc == 0) + v = 0; + if(v >= -128 && v <= 127 && !p->bigjmp) { *andptr++ = op; *andptr++ = v; } else { + p->bigjmp = 1; v -= 6-2; *andptr++ = 0x0f; *andptr++ = o->op[z+1]; @@ -1230,10 +1232,13 @@ found: q = p->pcond; if(q) { v = q->pc - p->pc - 2; - if(v >= -128 && v <= 127) { + if(q->pc == 0) + v = 0; + if(v >= -128 && v <= 127 && !p->bigjmp) { *andptr++ = op; *andptr++ = v; } else { + p->bigjmp = 1; v -= 5-2; *andptr++ = o->op[z+1]; *andptr++ = v; diff --git a/src/cmd/ld/pe.c b/src/cmd/ld/pe.c index c225d0cd4ec..3a3099d0446 100644 --- a/src/cmd/ld/pe.c +++ b/src/cmd/ld/pe.c @@ -31,7 +31,7 @@ new_section(char *name, int size, int noraw) errorexit(); } h = &sh[nsect++]; - strncpy(h->Name, name, sizeof(h->Name)); + strncpy((char*)h->Name, name, sizeof(h->Name)); h->VirtualSize = size; if(!sect_virt_begin) sect_virt_begin = 0x1000; diff --git a/src/pkg/runtime/nacl/mem.c b/src/pkg/runtime/nacl/mem.c new file mode 100644 index 00000000000..52e351a7d7e --- /dev/null +++ b/src/pkg/runtime/nacl/mem.c @@ -0,0 +1,28 @@ +#include "runtime.h" +#include "defs.h" +#include "os.h" +#include "malloc.h" + +void* +SysAlloc(uintptr n) +{ + mstats.sys += n; + return runtime_mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0); +} + +void +SysUnused(void *v, uintptr n) +{ + USED(v); + USED(n); + // TODO(rsc): call madvise MADV_DONTNEED +} + +void +SysFree(void *v, uintptr n) +{ + USED(v); + USED(n); + // TODO(rsc): call munmap +} + diff --git a/test/nacl-pass.txt b/test/nacl-pass.txt index bd9654eb4ba..91a9cc8df98 100644 --- a/test/nacl-pass.txt +++ b/test/nacl-pass.txt @@ -18,12 +18,18 @@ ./convert3.go ./convlit.go ./convlit1.go +./copy.go +./ddd1.go +./ddd2.go +./ddd3.go ./decl.go ./declbad.go +./defer.go ./empty.go ./escape.go ./escape1.go ./float_lit.go +./floatcmp.go ./for.go ./func.go ./func1.go @@ -38,6 +44,8 @@ ./if1.go ./import.go ./import1.go +./import2.go +./import3.go ./indirect.go ./indirect1.go ./initcomma.go @@ -54,11 +62,13 @@ ./method2.go ./method3.go ./named.go +./named1.go ./nil.go ./parentype.go ./range.go ./rename.go ./rename1.go +./runtime.go ./sieve.go ./simassign.go ./string_lit.go @@ -68,6 +78,7 @@ ./test0.go ./typeswitch.go ./typeswitch1.go +./typeswitch2.go ./utf.go ./varinit.go ./vectors.go @@ -107,6 +118,8 @@ interface/convert.go interface/convert1.go interface/convert2.go interface/embed.go +interface/embed0.go +interface/embed1.go interface/explicit.go interface/fake.go interface/pointer.go @@ -114,6 +127,17 @@ interface/receiver.go interface/receiver1.go interface/recursive.go interface/struct.go +syntax/forvar.go +syntax/import.go +syntax/interface.go +syntax/semi1.go +syntax/semi2.go +syntax/semi3.go +syntax/semi4.go +syntax/semi5.go +syntax/semi6.go +syntax/semi7.go +syntax/slice.go fixedbugs/bug000.go fixedbugs/bug001.go fixedbugs/bug002.go @@ -156,6 +180,7 @@ fixedbugs/bug051.go fixedbugs/bug052.go fixedbugs/bug053.go fixedbugs/bug054.go +fixedbugs/bug055.go fixedbugs/bug056.go fixedbugs/bug057.go fixedbugs/bug058.go @@ -215,7 +240,6 @@ fixedbugs/bug120.go fixedbugs/bug121.go fixedbugs/bug122.go fixedbugs/bug123.go -fixedbugs/bug125.go fixedbugs/bug126.go fixedbugs/bug127.go fixedbugs/bug128.go @@ -225,6 +249,7 @@ fixedbugs/bug131.go fixedbugs/bug132.go fixedbugs/bug133.go fixedbugs/bug135.go +fixedbugs/bug136.go fixedbugs/bug137.go fixedbugs/bug139.go fixedbugs/bug140.go @@ -249,9 +274,9 @@ fixedbugs/bug161.go fixedbugs/bug163.go fixedbugs/bug164.go fixedbugs/bug165.go -fixedbugs/bug166.go fixedbugs/bug167.go fixedbugs/bug168.go +fixedbugs/bug169.go fixedbugs/bug170.go fixedbugs/bug171.go fixedbugs/bug172.go @@ -272,11 +297,15 @@ fixedbugs/bug186.go fixedbugs/bug187.go fixedbugs/bug188.go fixedbugs/bug189.go +fixedbugs/bug190.go fixedbugs/bug191.go fixedbugs/bug192.go +fixedbugs/bug193.go fixedbugs/bug194.go fixedbugs/bug195.go +fixedbugs/bug196.go fixedbugs/bug197.go +fixedbugs/bug198.go fixedbugs/bug199.go fixedbugs/bug200.go fixedbugs/bug201.go @@ -285,3 +314,42 @@ fixedbugs/bug203.go fixedbugs/bug204.go fixedbugs/bug205.go fixedbugs/bug206.go +fixedbugs/bug207.go +fixedbugs/bug208.go +fixedbugs/bug209.go +fixedbugs/bug211.go +fixedbugs/bug212.go +fixedbugs/bug213.go +fixedbugs/bug214.go +fixedbugs/bug215.go +fixedbugs/bug216.go +fixedbugs/bug217.go +fixedbugs/bug218.go +fixedbugs/bug219.go +fixedbugs/bug220.go +fixedbugs/bug221.go +fixedbugs/bug222.go +fixedbugs/bug223.go +fixedbugs/bug224.go +fixedbugs/bug225.go +fixedbugs/bug226.go +fixedbugs/bug227.go +fixedbugs/bug228.go +fixedbugs/bug229.go +fixedbugs/bug230.go +fixedbugs/bug231.go +fixedbugs/bug232.go +fixedbugs/bug233.go +fixedbugs/bug234.go +fixedbugs/bug235.go +fixedbugs/bug236.go +fixedbugs/bug237.go +fixedbugs/bug238.go +fixedbugs/bug239.go +fixedbugs/bug240.go +fixedbugs/bug241.go +fixedbugs/bug244.go +fixedbugs/bug245.go +fixedbugs/bug247.go +fixedbugs/bug248.go +fixedbugs/bug249.go diff --git a/test/run-nacl b/test/run-nacl index 7b477fc4120..2f5b7ba26f0 100755 --- a/test/run-nacl +++ b/test/run-nacl @@ -7,7 +7,12 @@ case X"$GOARCH" in X386) # After downloading the Native Client binary distribution, # copy build/native_client/scons-out/opt-*/obj/src/trusted/service_runtime/sel_ldr - # into your path as "nacl" + # into your path as "nacl". You might need to wrap it to get rid of the + # 'Exit syscall handler' print. To do that, install the binary as nacl.bin and + # make this script nacl: + # #!/bin/sh + # nacl.bin "$@" 2>&1 | grep -v 'Exit syscall handler: 0' + # exit 0 export A=8 export E=nacl ;;