Skip to content

Instantly share code, notes, and snippets.

@davecheney
Created July 15, 2012 09:48
Show Gist options
  • Save davecheney/3116118 to your computer and use it in GitHub Desktop.
Save davecheney/3116118 to your computer and use it in GitHub Desktop.
diff -r d2213960ade2 src/cmd/5l/asm.c
--- a/src/cmd/5l/asm.c Sat Jul 14 15:59:52 2012 +0400
+++ b/src/cmd/5l/asm.c Sun Jul 15 19:45:39 2012 +1000
@@ -33,6 +33,7 @@
#include "l.h"
#include "../ld/lib.h"
#include "../ld/elf.h"
+#include "../ld/dwarf.h"
static Prog *PP;
@@ -498,6 +499,7 @@
if(!debug['s']) {
elfstr[ElfStrSymtab] = addstring(shstrtab, ".symtab");
elfstr[ElfStrStrtab] = addstring(shstrtab, ".strtab");
+ dwarfaddshstrings(shstrtab);
}
elfstr[ElfStrShstrtab] = addstring(shstrtab, ".shstrtab");
@@ -712,12 +714,11 @@
cflush();
cwrite(elfstrdat, elfstrsize);
- // if(debug['v'])
- // Bprint(&bso, "%5.2f dwarf\n", cputime());
- // dwarfemitdebugsections();
+ if(debug['v'])
+ Bprint(&bso, "%5.2f dwarf\n", cputime());
+ dwarfemitdebugsections();
}
cflush();
-
}
cursym = nil;
@@ -978,7 +979,7 @@
sh->size = elfstrsize;
sh->addralign = 1;
- // dwarfaddelfheaders();
+ dwarfaddelfheaders();
}
/* Main header */
@@ -2192,7 +2193,9 @@
int
chipzero(Ieee *e)
{
- if(e->l != 0 || e->h != 0)
+ // if this procedure returns 0, then 5l will use the "vmov (imm)"
+ // instruction which only exists on VFPv3. We use GOARM=7 to gate it.
+ if(goarm < 7 || e->l != 0 || e->h != 0)
return -1;
return 0;
}
@@ -2203,6 +2206,11 @@
int n;
ulong h;
+ // if this procedure returns non-negative number 5l will use the "vmov (imm)"
+ // instruction which only exists on VFPv3. We use GOARM=7 to gate it.
+ if(goarm < 7)
+ goto no;
+
if(e->l != 0 || (e->h&0xffff) != 0)
goto no;
h = e->h & 0x7fc00000;
@@ -2304,9 +2312,3 @@
Bprint(&bso, "symsize = %ud\n", symsize);
Bflush(&bso);
}
-
-void
-setpersrc(Sym *s)
-{
- USED(s);
-}
diff -r d2213960ade2 src/cmd/5l/l.h
--- a/src/cmd/5l/l.h Sat Jul 14 15:59:52 2012 +0400
+++ b/src/cmd/5l/l.h Sun Jul 15 19:45:39 2012 +1000
@@ -315,6 +315,8 @@
EXTERN Prog* blitrl;
EXTERN Prog* elitrl;
+EXTERN int goarm; // default to 6
+
void initdiv(void);
EXTERN Prog* prog_div;
EXTERN Prog* prog_divu;
@@ -401,6 +403,9 @@
void strnput(char*, int);
int32 symaddr(Sym*);
void undef(void);
+void vputb(uint64);
+void vputl(uint64);
+void wputb(uint16);
void wput(int32);
void wputl(ushort w);
void xdefine(char*, int, int32);
@@ -428,3 +433,9 @@
#define VPUT(a) abort()
#endif
+
+/* Used by ../ld/dwarf.c */
+enum
+{
+ DWARFREGSP = 13
+};
diff -r d2213960ade2 src/cmd/5l/noop.c
--- a/src/cmd/5l/noop.c Sat Jul 14 15:59:52 2012 +0400
+++ b/src/cmd/5l/noop.c Sun Jul 15 19:45:39 2012 +1000
@@ -365,11 +365,7 @@
q1 = p;
/* MOV a,4(SP) */
- q = prg();
- q->link = p->link;
- p->link = q;
- p = q;
-
+ p = appendp(p);
p->as = AMOVW;
p->line = q1->line;
p->from.type = D_REG;
@@ -379,11 +375,7 @@
p->to.offset = 4;
/* MOV b,REGTMP */
- q = prg();
- q->link = p->link;
- p->link = q;
- p = q;
-
+ p = appendp(p);
p->as = AMOVW;
p->line = q1->line;
p->from.type = D_REG;
@@ -395,11 +387,7 @@
p->to.offset = 0;
/* CALL appropriate */
- q = prg();
- q->link = p->link;
- p->link = q;
- p = q;
-
+ p = appendp(p);
p->as = ABL;
p->line = q1->line;
p->to.type = D_BRANCH;
@@ -424,11 +412,7 @@
}
/* MOV REGTMP, b */
- q = prg();
- q->link = p->link;
- p->link = q;
- p = q;
-
+ p = appendp(p);
p->as = AMOVW;
p->line = q1->line;
p->from.type = D_REG;
@@ -438,12 +422,9 @@
p->to.reg = q1->to.reg;
/* ADD $8,SP */
- q = prg();
- q->link = p->link;
- p->link = q;
- p = q;
-
+ p = appendp(p);
p->as = AADD;
+ p->line = q1->line;
p->from.type = D_CONST;
p->from.reg = NREG;
p->from.offset = 8;
diff -r d2213960ade2 src/cmd/5l/obj.c
--- a/src/cmd/5l/obj.c Sat Jul 14 15:59:52 2012 +0400
+++ b/src/cmd/5l/obj.c Sun Jul 15 19:45:39 2012 +1000
@@ -34,6 +34,7 @@
#include "l.h"
#include "../ld/lib.h"
#include "../ld/elf.h"
+#include "../ld/dwarf.h"
#include <ar.h>
#ifndef DEFAULT
@@ -85,11 +86,18 @@
INITDAT = -1;
INITRND = -1;
INITENTRY = 0;
+ goarm = 6;
nuxiinit();
p = getenv("GOARM");
- if(p != nil && strcmp(p, "5") == 0)
- debug['F'] = 1;
+ if(p != nil) {
+ if(strcmp(p, "5") == 0) {
+ goarm = 5;
+ debug['F'] = 1;
+ } else if(strcmp(p, "7") == 0) {
+ goarm = 7;
+ }
+ }
ARGBEGIN {
default:
@@ -481,6 +489,7 @@
histfrogp++;
} else
collapsefrog(s);
+ dwarfaddfrag(s->value, s->name);
}
goto loop;
}
diff -r d2213960ade2 src/cmd/5l/softfloat.c
--- a/src/cmd/5l/softfloat.c Sat Jul 14 15:59:52 2012 +0400
+++ b/src/cmd/5l/softfloat.c Sun Jul 15 19:45:39 2012 +1000
@@ -74,6 +74,7 @@
p->to.type = D_BRANCH;
p->to.sym = symsfloat;
p->cond = psfloat;
+ p->line = next->line;
p = next;
wasfloat = 1;
diff -r d2213960ade2 src/cmd/5l/span.c
--- a/src/cmd/5l/span.c Sat Jul 14 15:59:52 2012 +0400
+++ b/src/cmd/5l/span.c Sun Jul 15 19:45:39 2012 +1000
@@ -288,12 +288,20 @@
q->to.type = D_BRANCH;
q->cond = p->link;
q->link = blitrl;
+ q->line = p->line;
blitrl = q;
}
else if(!force && (p->pc+pool.size-pool.start < 2048))
return 0;
elitrl->link = p->link;
p->link = blitrl;
+ // BUG(minux): how to correctly handle line number for constant pool entries?
+ // for now, we set line number to the last instruction preceding them at least
+ // this won't bloat the .debug_line tables
+ while(blitrl) {
+ blitrl->line = p->line;
+ blitrl = blitrl->link;
+ }
blitrl = 0; /* BUG: should refer back to values until out-of-range */
elitrl = 0;
pool.size = 0;
diff -r d2213960ade2 src/cmd/dist/build.c
--- a/src/cmd/dist/build.c Sat Jul 14 15:59:52 2012 +0400
+++ b/src/cmd/dist/build.c Sun Jul 15 19:45:39 2012 +1000
@@ -474,14 +474,7 @@
"$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a",
}},
{"cmd/5l", {
- "../ld/data.c",
- "../ld/elf.c",
- "../ld/go.c",
- "../ld/ldelf.c",
- "../ld/ldmacho.c",
- "../ld/ldpe.c",
- "../ld/lib.c",
- "../ld/symtab.c",
+ "../ld/*",
"enam.c",
}},
{"cmd/6l", {
diff -r d2213960ade2 src/pkg/math/all_test.go
--- a/src/pkg/math/all_test.go Sat Jul 14 15:59:52 2012 +0400
+++ b/src/pkg/math/all_test.go Sun Jul 15 19:45:39 2012 +1000
@@ -1693,6 +1693,17 @@
return false
}
+func TestNaN(t *testing.T) {
+ f64 := NaN()
+ if f64 == f64 {
+ t.Fatalf("NaN() returns %g, expected NaN", f64)
+ }
+ f32 := float32(f64)
+ if f32 == f32 {
+ t.Fatalf("float32(NaN()) is %g, expected NaN", f32)
+ }
+}
+
func TestAcos(t *testing.T) {
for i := 0; i < len(vf); i++ {
a := vf[i] / 10
diff -r d2213960ade2 src/pkg/math/bits.go
--- a/src/pkg/math/bits.go Sat Jul 14 15:59:52 2012 +0400
+++ b/src/pkg/math/bits.go Sun Jul 15 19:45:39 2012 +1000
@@ -5,7 +5,6 @@
package math
const (
- uvnan = 0x7FF0000000000001
uvinf = 0x7FF0000000000000
uvneginf = 0xFFF0000000000000
mask = 0x7FF
diff -r d2213960ade2 src/pkg/math/bits_arm.go
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pkg/math/bits_arm.go Sun Jul 15 19:45:39 2012 +1000
@@ -0,0 +1,9 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package math
+
+// Use signaling NaNs on ARM because at least on VFPv2 in
+// ARM1136JF-S, quiet NaNs are not preserved across conversion
+const uvnan = 0x7ff8000000000000
diff -r d2213960ade2 src/pkg/math/bits_other.go
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pkg/math/bits_other.go Sun Jul 15 19:45:39 2012 +1000
@@ -0,0 +1,9 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !arm
+
+package math
+
+const uvnan = 0x7ff0000000000001
diff -r d2213960ade2 src/pkg/math/pow10.go
--- a/src/pkg/math/pow10.go Sat Jul 14 15:59:52 2012 +0400
+++ b/src/pkg/math/pow10.go Sun Jul 15 19:45:39 2012 +1000
@@ -6,7 +6,13 @@
// This table might overflow 127-bit exponent representations.
// In that case, truncate it after 1.0e38.
-var pow10tab [70]float64
+var pow10tab = [70]float64{1.0e0, 1.0e1, 1.0e2, 1.0e3, 1.0e4, 1.0e5, 1.0e6, 1.0e7, 1.0e8, 1.0e9,
+ 1.0e10, 1.0e11, 1.0e12, 1.0e13, 1.0e14, 1.0e15, 1.0e16, 1.0e17, 1.0e18, 1.0e19,
+ 1.0e20, 1.0e21, 1.0e22, 1.0e23, 1.0e24, 1.0e25, 1.0e26, 1.0e27, 1.0e28, 1.0e29,
+ 1.0e30, 1.0e31, 1.0e32, 1.0e33, 1.0e34, 1.0e35, 1.0e36, 1.0e37, 1.0e38, 1.0e39,
+ 1.0e40, 1.0e41, 1.0e42, 1.0e43, 1.0e44, 1.0e45, 1.0e46, 1.0e47, 1.0e48, 1.0e49,
+ 1.0e50, 1.0e51, 1.0e52, 1.0e53, 1.0e54, 1.0e55, 1.0e56, 1.0e57, 1.0e58, 1.0e59,
+ 1.0e60, 1.0e61, 1.0e62, 1.0e63, 1.0e64, 1.0e65, 1.0e66, 1.0e67, 1.0e68, 1.0e69}
// Pow10 returns 10**e, the base-10 exponential of e.
//
@@ -29,12 +35,3 @@
m := e / 2
return Pow10(m) * Pow10(e-m)
}
-
-func init() {
- pow10tab[0] = 1.0e0
- pow10tab[1] = 1.0e1
- for i := 2; i < len(pow10tab); i++ {
- m := i / 2
- pow10tab[i] = pow10tab[m] * pow10tab[i-m]
- }
-}
diff -r d2213960ade2 src/pkg/runtime/float.c
--- a/src/pkg/runtime/float.c Sat Jul 14 15:59:52 2012 +0400
+++ b/src/pkg/runtime/float.c Sun Jul 15 19:45:39 2012 +1000
@@ -4,7 +4,13 @@
#include "runtime.h"
+#ifdef GOARCH_arm
+// Use signaling NaNs on ARM because at least on VFPv2 in
+// ARM1136JF-S, quiet NaNs are not preserved across conversion
+static uint64 uvnan = 0x7FF8000000000000ULL;
+#else
static uint64 uvnan = 0x7FF0000000000001ULL;
+#endif
static uint64 uvinf = 0x7FF0000000000000ULL;
static uint64 uvneginf = 0xFFF0000000000000ULL;
diff -r d2213960ade2 src/pkg/runtime/iface.c
--- a/src/pkg/runtime/iface.c Sat Jul 14 15:59:52 2012 +0400
+++ b/src/pkg/runtime/iface.c Sun Jul 15 19:45:39 2012 +1000
@@ -33,7 +33,7 @@
void (*fun[])(void);
};
-static Itab* hash[1009];
+static Itab* hash[1024];
static Lock ifacelock;
static Itab*
diff -r d2213960ade2 src/pkg/runtime/mcache.c
--- a/src/pkg/runtime/mcache.c Sat Jul 14 15:59:52 2012 +0400
+++ b/src/pkg/runtime/mcache.c Sun Jul 15 19:45:39 2012 +1000
@@ -24,7 +24,7 @@
n = runtime·MCentral_AllocList(&runtime·mheap.central[sizeclass],
runtime·class_to_transfercount[sizeclass], &first);
if(n == 0)
- runtime·throw("out of memory");
+ runtime·throw("runtime·MCache_Alloc: out of memory");
l->list = first;
l->nlist = n;
c->size += n*size;
diff -r d2213960ade2 src/pkg/runtime/mem_linux.c
--- a/src/pkg/runtime/mem_linux.c Sat Jul 14 15:59:52 2012 +0400
+++ b/src/pkg/runtime/mem_linux.c Sun Jul 15 19:45:39 2012 +1000
@@ -115,7 +115,7 @@
if(sizeof(void*) == 8 && (uintptr)v >= 0xffffffffU) {
p = mmap_fixed(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0);
if(p == (void*)ENOMEM)
- runtime·throw("runtime: out of memory");
+ runtime·throw("runtime: out of memory ENOMEM map_fixed");
if(p != v) {
runtime·printf("runtime: address space conflict: map(%p) = %p\n", v, p);
runtime·throw("runtime: address space conflict");
@@ -123,9 +123,10 @@
return;
}
+// runtime·printf("runtime.sysmap: %D bytes at fixed address %p\n", (uint64)n, v);
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
if(p == (void*)ENOMEM)
- runtime·throw("runtime: out of memory");
+ runtime·throw("runtime: out of memory - could not mmap fixed");
if(p != v)
runtime·throw("runtime: cannot map pages in arena address space");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment