aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorKen Thompson <ken@golang.org>2008-07-08 17:19:17 -0700
committerKen Thompson <ken@golang.org>2008-07-08 17:19:17 -0700
commit4528854308cfe80fb840aa7a210495e31b16b000 (patch)
treef01c661bf9b8474ad0bfb57472ffb52bf8af3327 /src/runtime
parentc40be3b1e7288b594b6134f6bfcd7f71760445ab (diff)
downloadgo-4528854308cfe80fb840aa7a210495e31b16b000.tar.xz
unique import/export names
more on go statement SVN=126421
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/rt0_amd64.s40
-rw-r--r--src/runtime/rt2_amd64.c14
-rw-r--r--src/runtime/runtime.c13
-rw-r--r--src/runtime/runtime.h23
4 files changed, 76 insertions, 14 deletions
diff --git a/src/runtime/rt0_amd64.s b/src/runtime/rt0_amd64.s
index edc40dfe10..13883ebff9 100644
--- a/src/runtime/rt0_amd64.s
+++ b/src/runtime/rt0_amd64.s
@@ -14,9 +14,10 @@ TEXT _rt0_amd64(SB),7,$-8
MOVQ AX, 16(SP)
MOVQ BX, 24(SP)
- // allocate the per-user block
+ // allocate the per-user and per-mach blocks
LEAQ peruser<>(SB), R15 // dedicated u. register
+ LEAQ permach<>(SB), R14 // dedicated m. register
LEAQ (-4096+104+4*8)(SP), AX
MOVQ AX, 0(R15) // 0(R15) is stack limit (w 104b guard)
@@ -26,11 +27,11 @@ TEXT _rt0_amd64(SB),7,$-8
CALL mal(SB)
LEAQ 104(AX), BX
- MOVQ BX, 16(R15) // 16(R15) is limit of istack (w 104b guard)
+ MOVQ BX, 0(R14) // 0(R14) is limit of istack (w 104b guard)
ADDQ 0(SP), AX
LEAQ (-4*8)(AX), BX
- MOVQ BX, 24(R15) // 24(R15) is base of istack (w auto*4)
+ MOVQ BX, 8(R14) // 8(R14) is base of istack (w auto*4)
CALL check(SB)
@@ -75,7 +76,7 @@ TEXT _rt0_amd64(SB),7,$-8
TEXT _morestack(SB), 7, $0
// save stuff on interrupt stack
- MOVQ 24(R15), BX // istack
+ MOVQ 8(R14), BX // istack
MOVQ SP, 8(BX) // old SP
MOVQ AX, 16(BX) // magic number
MOVQ 0(R15), AX // old limit
@@ -84,7 +85,7 @@ TEXT _morestack(SB), 7, $0
// switch and set up new limit
MOVQ BX, SP
- MOVQ 16(R15), AX // istack limit
+ MOVQ 0(R14), AX // istack limit
MOVQ AX, 0(R15)
// allocate a new stack max of request and 4k
@@ -180,9 +181,33 @@ TEXT _endmorestack(SB), 7, $-8
RET
// call a subroutine in a new coroutine
-// argument list is on the stack addr of fn is in AX
+// argument list is on the stack
+// addr of fn is in AX
TEXT sys·_newproc(SB), 7, $0
- JMP AX
+ // save stuff on interrupt stack
+
+ MOVQ 8(R14), CX // istack
+ MOVQ AX, 0(CX) // fn pointer
+ MOVQ BX, 8(CX) // arg size
+ MOVQ SP, 16(CX) // old SP
+ MOVQ 0(R15), AX // old limit
+ MOVQ AX, 24(CX)
+
+ // switch and set up new limit
+
+ MOVQ CX, SP
+ MOVQ 0(R14), AX // istack limit
+ MOVQ AX, 0(R15)
+
+ CALL _newproc(SB)
+
+ // restore old SP and limit
+
+ MOVQ 24(SP), AX // old limit
+ MOVQ AX, 0(R15)
+ MOVQ 16(SP), AX // old SP
+ MOVQ AX, SP
+
RET
TEXT FLUSH(SB),7,$-8
@@ -192,4 +217,5 @@ TEXT getu(SB),7,$-8
MOVQ R15, AX
RET
+GLOBL permach<>(SB),$64
GLOBL peruser<>(SB),$64
diff --git a/src/runtime/rt2_amd64.c b/src/runtime/rt2_amd64.c
index 795285d7de..632ca9f15f 100644
--- a/src/runtime/rt2_amd64.c
+++ b/src/runtime/rt2_amd64.c
@@ -8,13 +8,13 @@ extern int32 debug;
static int8 spmark[] = "\xa7\xf1\xd9\x2a\x82\xc8\xd8\xfe";
-typedef struct U U;
-struct U {
- uint8* stackguard;
- uint8* stackbase;
- uint8* istackguard;
- uint8* istackbase;
-};
+//typedef struct U U;
+//struct U {
+// uint8* stackguard;
+// uint8* stackbase;
+// uint8* istackguard;
+// uint8* istackbase;
+//};
typedef struct Stktop Stktop;
struct Stktop {
diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c
index c4ff5f245d..9d79fa5312 100644
--- a/src/runtime/runtime.c
+++ b/src/runtime/runtime.c
@@ -570,3 +570,16 @@ check(void)
// prints(1"check ok\n");
initsig();
}
+
+void
+_newproc(byte* fn, int32 siz, byte* args)
+{
+ prints("_newproc fn=");
+ sys·printpointer(fn);
+ prints("; siz=");
+ sys·printint(siz);
+ prints("; args=");
+ sys·printpointer(args);
+ prints("\n");
+ dump(args, 32);
+}
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h
index 14e8f177be..ff9a4e57b6 100644
--- a/src/runtime/runtime.h
+++ b/src/runtime/runtime.h
@@ -61,6 +61,29 @@ struct Map
int32 unused;
void (*fun[])(void);
};
+typedef struct U U;
+struct U
+{
+ byte* stackguard; // must not move
+ byte* stackbase; // must not move
+ U* ufor; // dbl ll of all u
+ U* ubak;
+ U* runqfor; // dbl ll of runnable
+ U* runqbak;
+};
+typedef struct M M;
+struct M
+{
+ byte* istackguard; // must not move
+ byte* istackbase; // must not move
+};
+
+/*
+ * global variables
+ */
+U* allu;
+M* allm;
+U* runq;
/*
* defined constants