summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/386
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/386')
-rw-r--r--src/pkg/runtime/386/asm.s90
-rw-r--r--src/pkg/runtime/386/closure.c17
-rw-r--r--src/pkg/runtime/386/memmove.s3
-rw-r--r--src/pkg/runtime/386/vlop.s4
-rw-r--r--src/pkg/runtime/386/vlrt.c12
5 files changed, 60 insertions, 66 deletions
diff --git a/src/pkg/runtime/386/asm.s b/src/pkg/runtime/386/asm.s
index 614c026ea..84f5367e5 100644
--- a/src/pkg/runtime/386/asm.s
+++ b/src/pkg/runtime/386/asm.s
@@ -23,21 +23,23 @@ TEXT _rt0_386(SB),7,$0
JMP ok
// set up %gs
- CALL ldt0setup(SB)
+ CALL runtime·ldt0setup(SB)
// store through it, to make sure it works
+ CMPL runtime·isplan9(SB), $1
+ JEQ ok
get_tls(BX)
MOVL $0x123, g(BX)
- MOVL tls0(SB), AX
+ MOVL runtime·tls0(SB), AX
CMPL AX, $0x123
JEQ ok
MOVL AX, 0 // abort
ok:
// set up m and g "registers"
get_tls(BX)
- LEAL g0(SB), CX
+ LEAL runtime·g0(SB), CX
MOVL CX, g(BX)
- LEAL m0(SB), AX
+ LEAL runtime·m0(SB), AX
MOVL AX, m(BX)
// save m->g0 = g0
@@ -47,46 +49,46 @@ ok:
LEAL (-8192+104)(SP), AX // TODO: 104?
MOVL AX, g_stackguard(CX)
MOVL SP, g_stackbase(CX)
- CALL emptyfunc(SB) // fault if stack check is wrong
+ CALL runtime·emptyfunc(SB) // fault if stack check is wrong
// convention is D is always cleared
CLD
- CALL check(SB)
+ CALL runtime·check(SB)
// saved argc, argv
MOVL 120(SP), AX
MOVL AX, 0(SP)
MOVL 124(SP), AX
MOVL AX, 4(SP)
- CALL args(SB)
- CALL osinit(SB)
- CALL schedinit(SB)
+ CALL runtime·args(SB)
+ CALL runtime·osinit(SB)
+ CALL runtime·schedinit(SB)
// create a new goroutine to start program
- PUSHL $mainstart(SB) // entry
+ PUSHL $runtime·mainstart(SB) // entry
PUSHL $0 // arg size
- CALL ·newproc(SB)
+ CALL runtime·newproc(SB)
POPL AX
POPL AX
// start this M
- CALL mstart(SB)
+ CALL runtime·mstart(SB)
INT $3
RET
-TEXT mainstart(SB),7,$0
+TEXT runtime·mainstart(SB),7,$0
CALL main·init(SB)
- CALL initdone(SB)
+ CALL runtime·initdone(SB)
CALL main·main(SB)
PUSHL $0
- CALL exit(SB)
+ CALL runtime·exit(SB)
POPL AX
INT $3
RET
-TEXT breakpoint(SB),7,$0
+TEXT runtime·breakpoint(SB),7,$0
INT $3
RET
@@ -96,7 +98,7 @@ TEXT breakpoint(SB),7,$0
// uintptr gosave(Gobuf*)
// save state in Gobuf; setjmp
-TEXT gosave(SB), 7, $0
+TEXT runtime·gosave(SB), 7, $0
MOVL 4(SP), AX // gobuf
LEAL 4(SP), BX // caller's SP
MOVL BX, gobuf_sp(AX)
@@ -110,7 +112,7 @@ TEXT gosave(SB), 7, $0
// void gogo(Gobuf*, uintptr)
// restore state from Gobuf; longjmp
-TEXT gogo(SB), 7, $0
+TEXT runtime·gogo(SB), 7, $0
MOVL 8(SP), AX // return 2nd arg
MOVL 4(SP), BX // gobuf
MOVL gobuf_g(BX), DX
@@ -124,7 +126,7 @@ TEXT gogo(SB), 7, $0
// void gogocall(Gobuf*, void (*fn)(void))
// restore state from Gobuf but then call fn.
// (call fn, returning to state in Gobuf)
-TEXT gogocall(SB), 7, $0
+TEXT runtime·gogocall(SB), 7, $0
MOVL 8(SP), AX // fn
MOVL 4(SP), BX // gobuf
MOVL gobuf_g(BX), DX
@@ -142,7 +144,7 @@ TEXT gogocall(SB), 7, $0
*/
// Called during function prolog when more stack is needed.
-TEXT ·morestack(SB),7,$0
+TEXT runtime·morestack(SB),7,$0
// Cannot grow scheduler stack (m->g0).
get_tls(CX)
MOVL m(CX), BX
@@ -175,8 +177,10 @@ TEXT ·morestack(SB),7,$0
// Call newstack on m's scheduling stack.
MOVL m_g0(BX), BP
MOVL BP, g(CX)
- MOVL (m_sched+gobuf_sp)(BX), SP
- CALL newstack(SB)
+ MOVL (m_sched+gobuf_sp)(BX), AX
+ MOVL -4(AX), BX // fault if CALL would, before smashing SP
+ MOVL AX, SP
+ CALL runtime·newstack(SB)
MOVL $0, 0x1003 // crash if newstack returns
RET
@@ -218,13 +222,13 @@ TEXT reflect·call(SB), 7, $0
get_tls(CX)
MOVL BP, g(CX)
MOVL (m_sched+gobuf_sp)(BX), SP
- CALL newstack(SB)
+ CALL runtime·newstack(SB)
MOVL $0, 0x1103 // crash if newstack returns
RET
// Return point when leaving stack.
-TEXT ·lessstack(SB), 7, $0
+TEXT runtime·lessstack(SB), 7, $0
// Save return value in m->cret
get_tls(CX)
MOVL m(CX), BX
@@ -234,7 +238,7 @@ TEXT ·lessstack(SB), 7, $0
MOVL m_g0(BX), DX
MOVL DX, g(CX)
MOVL (m_sched+gobuf_sp)(BX), SP
- CALL oldstack(SB)
+ CALL runtime·oldstack(SB)
MOVL $0, 0x1004 // crash if oldstack returns
RET
@@ -246,7 +250,7 @@ TEXT ·lessstack(SB), 7, $0
// return 1;
// }else
// return 0;
-TEXT cas(SB), 7, $0
+TEXT runtime·cas(SB), 7, $0
MOVL 4(SP), BX
MOVL 8(SP), AX
MOVL 12(SP), CX
@@ -265,7 +269,7 @@ TEXT cas(SB), 7, $0
// return 1;
// }else
// return 0;
-TEXT casp(SB), 7, $0
+TEXT runtime·casp(SB), 7, $0
MOVL 4(SP), BX
MOVL 8(SP), AX
MOVL 12(SP), CX
@@ -282,14 +286,14 @@ TEXT casp(SB), 7, $0
// 1. pop the caller
// 2. sub 5 bytes from the callers return
// 3. jmp to the argument
-TEXT jmpdefer(SB), 7, $0
+TEXT runtime·jmpdefer(SB), 7, $0
MOVL 4(SP), AX // fn
MOVL 8(SP), BX // caller sp
LEAL -4(BX), SP // caller sp after CALL
SUBL $5, (SP) // return to CALL again
JMP AX // but first run the deferred function
-TEXT ·memclr(SB),7,$0
+TEXT runtime·memclr(SB),7,$0
MOVL 4(SP), DI // arg 1 addr
MOVL 8(SP), CX // arg 2 count
ADDL $3, CX
@@ -300,42 +304,42 @@ TEXT ·memclr(SB),7,$0
STOSL
RET
-TEXT ·getcallerpc+0(SB),7,$0
+TEXT runtime·getcallerpc(SB),7,$0
MOVL x+0(FP),AX // addr of first arg
MOVL -4(AX),AX // get calling pc
RET
-TEXT ·setcallerpc+0(SB),7,$0
+TEXT runtime·setcallerpc(SB),7,$0
MOVL x+0(FP),AX // addr of first arg
MOVL x+4(FP), BX
MOVL BX, -4(AX) // set calling pc
RET
-TEXT getcallersp(SB), 7, $0
+TEXT runtime·getcallersp(SB), 7, $0
MOVL sp+0(FP), AX
RET
-TEXT ldt0setup(SB),7,$16
+TEXT runtime·ldt0setup(SB),7,$16
// set up ldt 7 to point at tls0
// ldt 1 would be fine on Linux, but on OS X, 7 is as low as we can go.
// the entry number is just a hint. setldt will set up GS with what it used.
MOVL $7, 0(SP)
- LEAL tls0(SB), AX
+ LEAL runtime·tls0(SB), AX
MOVL AX, 4(SP)
MOVL $32, 8(SP) // sizeof(tls array)
- CALL setldt(SB)
+ CALL runtime·setldt(SB)
RET
-TEXT emptyfunc(SB),0,$0
+TEXT runtime·emptyfunc(SB),0,$0
RET
-TEXT abort(SB),7,$0
+TEXT runtime·abort(SB),7,$0
INT $0x3
// runcgo(void(*fn)(void*), void *arg)
// Call fn(arg) on the scheduler stack,
// aligned appropriately for the gcc ABI.
-TEXT runcgo(SB),7,$16
+TEXT runtime·runcgo(SB),7,$16
MOVL fn+0(FP), AX
MOVL arg+4(FP), BX
MOVL SP, CX
@@ -370,7 +374,7 @@ TEXT runcgo(SB),7,$16
// runcgocallback(G *g1, void* sp, void (*fn)(void))
// Switch to g1 and sp, call fn, switch back. fn's arguments are on
// the new stack.
-TEXT runcgocallback(SB),7,$32
+TEXT runtime·runcgocallback(SB),7,$32
MOVL g1+0(FP), DX
MOVL sp+4(FP), AX
MOVL fn+8(FP), BX
@@ -399,7 +403,7 @@ TEXT runcgocallback(SB),7,$32
RET
// check that SP is in range [g->stackbase, g->stackguard)
-TEXT stackcheck(SB), 7, $0
+TEXT runtime·stackcheck(SB), 7, $0
get_tls(CX)
MOVL g(CX), AX
CMPL g_stackbase(AX), SP
@@ -410,8 +414,4 @@ TEXT stackcheck(SB), 7, $0
INT $3
RET
-GLOBL m0(SB), $1024
-GLOBL g0(SB), $1024
-GLOBL tls0(SB), $32
-GLOBL initcgo(SB), $4
-
+GLOBL runtime·tls0(SB), $32
diff --git a/src/pkg/runtime/386/closure.c b/src/pkg/runtime/386/closure.c
index 9f639c472..b0d4cc41a 100644
--- a/src/pkg/runtime/386/closure.c
+++ b/src/pkg/runtime/386/closure.c
@@ -9,23 +9,20 @@
// fn func(arg0, arg1, arg2 *ptr, callerpc uintptr, xxx) yyy,
// arg0, arg1, arg2 *ptr) (func(xxx) yyy)
void
-·closure(int32 siz, byte *fn, byte *arg0)
+runtime·closure(int32 siz, byte *fn, byte *arg0)
{
byte *p, *q, **ret;
int32 i, n;
int32 pcrel;
- if(goos != nil && strcmp((uint8*)goos, (uint8*)"nacl") == 0)
- throw("no closures in native client yet");
-
if(siz < 0 || siz%4 != 0)
- throw("bad closure size");
+ runtime·throw("bad closure size");
ret = (byte**)((byte*)&arg0 + siz);
if(siz > 100) {
// TODO(rsc): implement stack growth preamble?
- throw("closure too big");
+ runtime·throw("closure too big");
}
// compute size of new fn.
@@ -43,12 +40,12 @@ void
if(n%4)
n += 4 - n%4;
- p = mal(n);
+ p = runtime·mal(n);
*ret = p;
q = p + n - siz;
if(siz > 0) {
- mcpy(q, (byte*)&arg0, siz);
+ runtime·mcpy(q, (byte*)&arg0, siz);
// SUBL $siz, SP
*p++ = 0x81;
@@ -104,7 +101,5 @@ void
*p++ = 0xc3;
if(p > q)
- throw("bad math in sys.closure");
+ runtime·throw("bad math in sys.closure");
}
-
-
diff --git a/src/pkg/runtime/386/memmove.s b/src/pkg/runtime/386/memmove.s
index 8adb687c5..38a0652b5 100644
--- a/src/pkg/runtime/386/memmove.s
+++ b/src/pkg/runtime/386/memmove.s
@@ -23,8 +23,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
- TEXT memmove(SB), 7, $0
-
+TEXT runtime·memmove(SB), 7, $0
MOVL to+0(FP), DI
MOVL fr+4(FP), SI
MOVL n+8(FP), BX
diff --git a/src/pkg/runtime/386/vlop.s b/src/pkg/runtime/386/vlop.s
index 803276ce2..28f6da82d 100644
--- a/src/pkg/runtime/386/vlop.s
+++ b/src/pkg/runtime/386/vlop.s
@@ -27,7 +27,7 @@
* C runtime for 64-bit divide.
*/
-TEXT _mul64by32(SB), 7, $0
+TEXT _mul64by32(SB), 7, $0
MOVL r+0(FP), CX
MOVL a+4(FP), AX
MULL b+12(FP)
@@ -39,7 +39,7 @@ TEXT _mul64by32(SB), 7, $0
MOVL BX, 4(CX)
RET
-TEXT _div64by32(SB), 7, $0
+TEXT _div64by32(SB), 7, $0
MOVL r+12(FP), CX
MOVL a+0(FP), AX
MOVL a+4(FP), DX
diff --git a/src/pkg/runtime/386/vlrt.c b/src/pkg/runtime/386/vlrt.c
index 10417f596..1631dbe10 100644
--- a/src/pkg/runtime/386/vlrt.c
+++ b/src/pkg/runtime/386/vlrt.c
@@ -59,7 +59,7 @@ struct Vlong
};
};
-void abort(void);
+void runtime·abort(void);
void
_d2v(Vlong *y, double d)
@@ -270,7 +270,7 @@ _divvu(Vlong *q, Vlong n, Vlong d)
}
void
-·uint64div(Vlong n, Vlong d, Vlong q)
+runtime·uint64div(Vlong n, Vlong d, Vlong q)
{
_divvu(&q, n, d);
}
@@ -288,7 +288,7 @@ _modvu(Vlong *r, Vlong n, Vlong d)
}
void
-·uint64mod(Vlong n, Vlong d, Vlong q)
+runtime·uint64mod(Vlong n, Vlong d, Vlong q)
{
_modvu(&q, n, d);
}
@@ -334,7 +334,7 @@ _divv(Vlong *q, Vlong n, Vlong d)
}
void
-·int64div(Vlong n, Vlong d, Vlong q)
+runtime·int64div(Vlong n, Vlong d, Vlong q)
{
_divv(&q, n, d);
}
@@ -368,7 +368,7 @@ _modv(Vlong *r, Vlong n, Vlong d)
}
void
-·int64mod(Vlong n, Vlong d, Vlong q)
+runtime·int64mod(Vlong n, Vlong d, Vlong q)
{
_modv(&q, n, d);
}
@@ -522,7 +522,7 @@ _vasop(Vlong *ret, void *lv, void fn(Vlong*, Vlong, Vlong), int type, Vlong rv)
u.hi = 0;
switch(type) {
default:
- abort();
+ runtime·abort();
break;
case 1: /* schar */