From 380200953aabe163ab55ac53afdbd62435eb4aba Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 17 Jun 2009 16:31:02 -0700 Subject: [PATCH] Forgot to check in 386/asm.h. Rather than do that, fix build by generating asm.h automatically. R=r DELTA=97 (48 added, 36 deleted, 13 changed) OCL=30449 CL=30452 --- src/pkg/runtime/Makefile | 6 ++++- src/pkg/runtime/amd64/asm.h | 26 -------------------- src/pkg/runtime/amd64/asm.s | 10 ++++---- src/pkg/runtime/mkasmh | 47 +++++++++++++++++++++++++++++++++++++ src/pkg/runtime/runtime.h | 24 ++++++------------- 5 files changed, 64 insertions(+), 49 deletions(-) delete mode 100644 src/pkg/runtime/amd64/asm.h create mode 100755 src/pkg/runtime/mkasmh diff --git a/src/pkg/runtime/Makefile b/src/pkg/runtime/Makefile index 498bf0bef1..78e3cbffd9 100644 --- a/src/pkg/runtime/Makefile +++ b/src/pkg/runtime/Makefile @@ -93,7 +93,7 @@ nuke: rm -f *.[568] *.a $(GOROOT)/lib/$(LIB) clean: - rm -f *.[568] *.a runtime.acid cgo2c + rm -f *.[568] *.a runtime.acid cgo2c */asm.h %.$O: %.go $(GC) $< @@ -129,3 +129,7 @@ runtime.acid: runtime.h proc.c chan.acid: runtime.h chan.c $(CC) -a chan.c >chan.acid +$(GOARCH)/asm.h: runtime.acid mkasmh + mkasmh >$@.x + mv -f $@.x $@ + diff --git a/src/pkg/runtime/amd64/asm.h b/src/pkg/runtime/amd64/asm.h deleted file mode 100644 index c32da75445..0000000000 --- a/src/pkg/runtime/amd64/asm.h +++ /dev/null @@ -1,26 +0,0 @@ -// Assembly constants - -#define g R15 -#define m R14 - -// offsets in m -#define m_g0 0 -#define m_morepc 8 -#define m_morebuf 16 -#define m_morearg 40 -#define m_cret 48 -#define m_procid 56 -#define m_gsignal 64 -#define m_tls 72 -#define m_sched 104 - -// offsets in gobuf -#define gobuf_sp 0 -#define gobuf_pc 8 -#define gobuf_g 16 - -// offsets in g -#define g_stackguard 0 -#define g_stackbase 8 -#define g_defer 16 -#define g_sched 24 diff --git a/src/pkg/runtime/amd64/asm.s b/src/pkg/runtime/amd64/asm.s index 825acc4657..539b1ab2af 100644 --- a/src/pkg/runtime/amd64/asm.s +++ b/src/pkg/runtime/amd64/asm.s @@ -143,24 +143,24 @@ TEXT sys·lessstack(SB), 7, $0 // morestack trampolines TEXT sys·morestack00+0(SB),7,$0 MOVQ $0, AX - MOVQ AX, m_morearg(m) + MOVQ AX, m_moreframe(m) MOVQ $sys·morestack+0(SB), AX JMP AX TEXT sys·morestack01+0(SB),7,$0 SHLQ $32, AX - MOVQ AX, m_morearg(m) + MOVQ AX, m_moreframe(m) MOVQ $sys·morestack+0(SB), AX JMP AX TEXT sys·morestack10+0(SB),7,$0 MOVLQZX AX, AX - MOVQ AX, m_morearg(m) + MOVQ AX, m_moreframe(m) MOVQ $sys·morestack+0(SB), AX JMP AX TEXT sys·morestack11+0(SB),7,$0 - MOVQ AX, m_morearg(m) + MOVQ AX, m_moreframe(m) MOVQ $sys·morestack+0(SB), AX JMP AX @@ -199,7 +199,7 @@ TEXT sys·morestack48(SB),7,$0 TEXT sys·morestackx(SB),7,$0 POPQ AX SHLQ $35, AX - MOVQ AX, m_morearg(m) + MOVQ AX, m_moreframe(m) MOVQ $sys·morestack(SB), AX JMP AX diff --git a/src/pkg/runtime/mkasmh b/src/pkg/runtime/mkasmh new file mode 100755 index 0000000000..02f73ca79c --- /dev/null +++ b/src/pkg/runtime/mkasmh @@ -0,0 +1,47 @@ +#!/bin/sh +# Copyright 2009 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. + +set -e + +cat <<'EOF' +// Assembly constants. +// AUTOMATICALLY GENERATED BY mkasmh DURING BUILD + +EOF + +case "$GOARCH" in +386) + echo '#define g 0(FS)' + echo '#define m 4(FS)' + ;; +amd64) + echo '#define g R15' + echo '#define m R14' + ;; +*) + echo 'unknown $GOARCH: '$GOARCH 1>&2 + exit 1 + ;; +esac +echo + +awk ' +/^aggr G$/ { aggr="g" } +/^aggr M$/ { aggr = "m" } +/^aggr Gobuf$/ { aggr = "gobuf" } +/^}/ { aggr = "" } + +# Gobuf 24 sched; +# 'Y' 48 stack0; +# 'Y' 56 entry; +# 'A' G 64 alllink; +aggr != "" && /^ / { + name=$NF; + sub(/;/, "", name); + offset=$(NF-1); + printf("#define %s_%s %s\n", aggr, name, offset); +} +' runtime.acid + diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h index 59dba49d84..662fde7593 100644 --- a/src/pkg/runtime/runtime.h +++ b/src/pkg/runtime/runtime.h @@ -134,23 +134,17 @@ struct Array }; struct Gobuf { - // Offsets of fields in this struct are known to assembly. - // Any changes made here must be reflected in */asm.h. - // The debuggers also know the layout of this struct. + // The offsets of these fields are known to (hard-coded in) libmach. byte* sp; byte* pc; G* g; }; struct G { - // Offsets of fields in this block are known to assembly. - // Any changes made here must be reflected in */asm.h. - byte* stackguard; // cannot move - also known to linker, debuggers - byte* stackbase; // cannot move - also known to debuggers + byte* stackguard; // cannot move - also known to linker, libmach + byte* stackbase; // cannot move - also known to libmach Defer* defer; - Gobuf sched; // cannot move - also known to debuggers - - // Fields not known to assembly. + Gobuf sched; // cannot move - also known to libmach byte* stack0; // first stack segment byte* entry; // initial function G* alllink; // on allg @@ -171,14 +165,12 @@ struct Mem }; struct M { - // Offsets of fields in this block are known to assembly. - // Any changes made here must be reflected in */asm.h. - // These are known to debuggers. + // The offsets of these fields are known to (hard-coded in) libmach. G* g0; // goroutine with scheduling stack void (*morepc)(void); Gobuf morebuf; // gobuf arg to morestack - // Known to assembly, but not to debuggers. + // Fields not known to debuggers. uint32 moreframe; // size arguments to morestack uint32 moreargs; uintptr cret; // return value from C @@ -187,8 +179,6 @@ struct M uint32 tls[8]; // thread-local storage (for 386 extern register) Gobuf sched; // scheduling stack G* curg; // current running goroutine - - // Fields not known to assembly. int32 id; int32 mallocing; int32 gcing; @@ -202,7 +192,7 @@ struct M }; struct Stktop { - // The debuggers know the layout of this struct. + // The offsets of these fields are known to (hard-coded in) libmach. uint8* stackguard; uint8* stackbase; Gobuf gobuf; -- 2.48.1