1
0
mirror of https://github.com/golang/go synced 2024-11-13 18:20:32 -07:00

defined external registers g and m

SVN=126521
This commit is contained in:
Ken Thompson 2008-07-09 11:35:26 -07:00
parent 1e9adf8228
commit 7b454bb1d9
3 changed files with 20 additions and 14 deletions

View File

@ -36,11 +36,11 @@ traceback(uint8 *pc, uint8 *sp, void* r15)
int32 counter; int32 counter;
int32 i; int32 i;
int8* name; int8* name;
U u; G g;
Stktop *stktop; Stktop *stktop;
// store local copy of per-process data block that we can write as we unwind // store local copy of per-process data block that we can write as we unwind
mcpy((byte*)&u, (byte*)r15, sizeof(U)); mcpy((byte*)&g, (byte*)r15, sizeof(G));
counter = 0; counter = 0;
name = "panic"; name = "panic";
@ -48,9 +48,9 @@ traceback(uint8 *pc, uint8 *sp, void* r15)
callpc = pc; callpc = pc;
if((uint8*)_morestack < pc && pc < (uint8*)_endmorestack) { if((uint8*)_morestack < pc && pc < (uint8*)_endmorestack) {
// call site in _morestack(); pop to earlier stack block to get true caller // call site in _morestack(); pop to earlier stack block to get true caller
stktop = (Stktop*)u.stackbase; stktop = (Stktop*)g.stackbase;
u.stackbase = stktop->oldbase; g.stackbase = stktop->oldbase;
u.stackguard = stktop->oldguard; g.stackguard = stktop->oldguard;
sp = stktop->oldsp; sp = stktop->oldsp;
pc = ((uint8**)sp)[1]; pc = ((uint8**)sp)[1];
sp += 16; // two irrelevant calls on stack - morestack, plus the call morestack made sp += 16; // two irrelevant calls on stack - morestack, plus the call morestack made

View File

@ -571,9 +571,14 @@ check(void)
initsig(); initsig();
} }
extern register u;
uint32 a;
void void
_newproc(byte* fn, int32 siz, byte* args) _newproc(byte* fn, int32 siz, byte* args)
{ {
a = u;
prints("_newproc fn="); prints("_newproc fn=");
sys·printpointer(fn); sys·printpointer(fn);
prints("; siz="); prints("; siz=");

View File

@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
/* /*
* basic types * basic types
*/ */
@ -61,15 +60,15 @@ struct Map
int32 unused; int32 unused;
void (*fun[])(void); void (*fun[])(void);
}; };
typedef struct U U; typedef struct G G;
struct U struct G
{ {
byte* stackguard; // must not move byte* stackguard; // must not move
byte* stackbase; // must not move byte* stackbase; // must not move
U* ufor; // dbl ll of all u G* ufor; // dbl ll of all u
U* ubak; G* ubak;
U* runqfor; // dbl ll of runnable G* runqfor; // dbl ll of runnable
U* runqbak; G* runqbak;
}; };
typedef struct M M; typedef struct M M;
struct M struct M
@ -77,13 +76,15 @@ struct M
byte* istackguard; // must not move byte* istackguard; // must not move
byte* istackbase; // must not move byte* istackbase; // must not move
}; };
extern register G* g; // R15
extern register M* m; // R14
/* /*
* global variables * global variables
*/ */
U* allu;
M* allm; M* allm;
U* runq; G* allu;
G* runq;
/* /*
* defined constants * defined constants