Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
1d31a25d
Commit
1d31a25d
authored
Jul 07, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more coroutine
fixed a,b,c := x,x,x SVN=126250
parent
f86c6f67
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
173 additions
and
149 deletions
+173
-149
src/cmd/6g/cgen.c
src/cmd/6g/cgen.c
+6
-6
src/cmd/6g/gen.c
src/cmd/6g/gen.c
+65
-16
src/cmd/6g/gg.h
src/cmd/6g/gg.h
+4
-3
src/cmd/6g/gsubr.c
src/cmd/6g/gsubr.c
+0
-1
src/cmd/gc/go.h
src/cmd/gc/go.h
+0
-1
src/cmd/gc/sys.go
src/cmd/gc/sys.go
+0
-5
src/cmd/gc/sysimport.c
src/cmd/gc/sysimport.c
+89
-94
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+3
-22
src/runtime/rt0_amd64.s
src/runtime/rt0_amd64.s
+6
-1
No files found.
src/cmd/6g/cgen.c
View file @
1d31a25d
...
...
@@ -172,17 +172,17 @@ cgen(Node *n, Node *res)
break
;
case
OCALLMETH
:
cgen_callmeth
(
n
);
cgen_callmeth
(
n
,
0
);
cgen_callret
(
n
,
res
);
break
;
case
OCALLINTER
:
cgen_callinter
(
n
,
res
);
cgen_callinter
(
n
,
res
,
0
);
cgen_callret
(
n
,
res
);
break
;
case
OCALL
:
cgen_call
(
n
);
cgen_call
(
n
,
0
);
cgen_callret
(
n
,
res
);
break
;
...
...
@@ -281,17 +281,17 @@ agen(Node *n, Node *res)
// break;
case
OCALLMETH
:
cgen_callmeth
(
n
);
cgen_callmeth
(
n
,
0
);
cgen_aret
(
n
,
res
);
break
;
case
OCALLINTER
:
cgen_callinter
(
n
,
res
);
cgen_callinter
(
n
,
res
,
0
);
cgen_aret
(
n
,
res
);
break
;
case
OCALL
:
cgen_call
(
n
);
cgen_call
(
n
,
0
);
cgen_aret
(
n
,
res
);
break
;
...
...
src/cmd/6g/gen.c
View file @
1d31a25d
...
...
@@ -14,6 +14,7 @@ enum
};
static
Node
*
curfn
;
static
Node
*
newproc
;
void
compile
(
Node
*
fn
)
...
...
@@ -23,6 +24,16 @@ compile(Node *fn)
Prog
*
ptxt
;
long
lno
;
if
(
newproc
==
N
)
{
newproc
=
nod
(
ONAME
,
N
,
N
);
memset
(
newproc
,
0
,
sizeof
(
*
newproc
));
newproc
->
op
=
ONAME
;
newproc
->
sym
=
pkglookup
(
"_newproc"
,
"sys"
);
newproc
->
class
=
PEXTERN
;
newproc
->
addable
=
1
;
newproc
->
ullman
=
0
;
}
if
(
fn
->
nbody
==
N
)
return
;
lno
=
setlineno
(
fn
);
...
...
@@ -298,15 +309,19 @@ loop:
break
;
case
OCALLMETH
:
cgen_callmeth
(
n
);
cgen_callmeth
(
n
,
0
);
break
;
case
OCALLINTER
:
cgen_callinter
(
n
,
N
);
cgen_callinter
(
n
,
N
,
0
);
break
;
case
OCALL
:
cgen_call
(
n
);
cgen_call
(
n
,
0
);
break
;
case
OPROC
:
cgen_proc
(
n
);
break
;
case
ORETURN
:
...
...
@@ -552,7 +567,21 @@ genpanic(void)
}
void
cgen_callinter
(
Node
*
n
,
Node
*
res
)
ginscall
(
Node
*
f
,
int
proc
)
{
Node
regax
;
if
(
proc
)
{
nodreg
(
&
regax
,
types
[
TINT64
],
D_AX
);
gins
(
ALEAQ
,
f
,
&
regax
);
gins
(
ACALL
,
N
,
newproc
);
return
;
}
gins
(
ACALL
,
N
,
f
);
}
void
cgen_callinter
(
Node
*
n
,
Node
*
res
,
int
proc
)
{
Node
*
i
,
*
f
;
Node
tmpi
,
nodo
,
nodr
,
nodsp
;
...
...
@@ -588,21 +617,19 @@ cgen_callinter(Node *n, Node *res)
nodo
.
xoffset
-=
widthptr
;
cgen
(
&
nodo
,
&
nodr
);
// REG = 0(REG) -- i.m
//print("field = %N\n", f);
//print("offset = %ld\n", n->left->xoffset);
nodo
.
xoffset
=
n
->
left
->
xoffset
+
4
*
widthptr
;
cgen
(
&
nodo
,
&
nodr
);
// REG = 32+offset(REG) -- i.m->fun[f]
gins
(
ACALL
,
N
,
&
nodr
);
regfree
(
&
nodr
);
gins
call
(
&
nodr
,
proc
);
regfree
(
&
nodr
);
regfree
(
&
nodo
);
setmaxarg
(
n
->
left
->
type
);
}
void
cgen_callmeth
(
Node
*
n
)
cgen_callmeth
(
Node
*
n
,
int
proc
)
{
Node
*
l
;
...
...
@@ -619,14 +646,14 @@ cgen_callmeth(Node *n)
if
(
n
->
left
->
op
==
ONAME
)
n
->
left
->
class
=
PEXTERN
;
cgen_call
(
n
);
cgen_call
(
n
,
proc
);
}
void
cgen_call
(
Node
*
n
)
cgen_call
(
Node
*
n
,
int
proc
)
{
Type
*
t
;
Node
nod
,
afun
;
Node
nod
,
afun
,
regax
;
if
(
n
==
N
)
return
;
...
...
@@ -652,7 +679,7 @@ cgen_call(Node *n)
if
(
n
->
left
->
ullman
>=
UINF
)
{
regalloc
(
&
nod
,
types
[
tptr
],
N
);
cgen_as
(
&
nod
,
&
afun
,
0
);
gins
(
ACALL
,
N
,
&
nod
);
gins
call
(
&
nod
,
proc
);
regfree
(
&
nod
);
goto
ret
;
}
...
...
@@ -661,19 +688,41 @@ cgen_call(Node *n)
if
(
isptr
[
n
->
left
->
type
->
etype
])
{
regalloc
(
&
nod
,
types
[
tptr
],
N
);
cgen_as
(
&
nod
,
n
->
left
,
0
);
gins
(
ACALL
,
N
,
&
nod
);
gins
call
(
&
nod
,
proc
);
regfree
(
&
nod
);
goto
ret
;
}
// call direct
n
->
left
->
method
=
1
;
gins
(
ACALL
,
N
,
n
->
left
);
gins
call
(
n
->
left
,
proc
);
ret:
;
}
void
cgen_proc
(
Node
*
n
)
{
switch
(
n
->
left
->
op
)
{
default:
fatal
(
"cgen_proc: unknown call %O"
,
n
->
left
->
op
);
case
OCALLMETH
:
cgen_callmeth
(
n
->
left
,
1
);
break
;
case
OCALLINTER
:
cgen_callinter
(
n
->
left
,
N
,
1
);
break
;
case
OCALL
:
cgen_call
(
n
->
left
,
1
);
break
;
}
}
void
cgen_callret
(
Node
*
n
,
Node
*
res
)
{
...
...
src/cmd/6g/gg.h
View file @
1d31a25d
...
...
@@ -113,9 +113,10 @@ void agen_inter(Node*, Node*);
void
cgen_as
(
Node
*
,
Node
*
,
int
);
void
cgen_asop
(
Node
*
);
void
cgen_ret
(
Node
*
);
void
cgen_call
(
Node
*
);
void
cgen_callmeth
(
Node
*
);
void
cgen_callinter
(
Node
*
,
Node
*
);
void
cgen_call
(
Node
*
,
int
);
void
cgen_callmeth
(
Node
*
,
int
);
void
cgen_callinter
(
Node
*
,
Node
*
,
int
);
void
cgen_proc
(
Node
*
);
void
cgen_callret
(
Node
*
,
Node
*
);
void
cgen_div
(
int
,
Node
*
,
Node
*
,
Node
*
);
void
cgen_shift
(
int
,
Node
*
,
Node
*
,
Node
*
);
...
...
src/cmd/6g/gsubr.c
View file @
1d31a25d
...
...
@@ -1673,7 +1673,6 @@ tempname(Node *n, Type *t)
n
->
op
=
ONAME
;
n
->
sym
=
s
;
n
->
type
=
t
;
n
->
sym
=
s
;
n
->
etype
=
t
->
etype
;
n
->
class
=
PAUTO
;
n
->
addable
=
1
;
...
...
src/cmd/gc/go.h
View file @
1d31a25d
...
...
@@ -581,7 +581,6 @@ Node* nodpanic(long);
Node
*
newcompat
(
Node
*
);
Node
*
stringop
(
Node
*
,
int
);
Node
*
mapop
(
Node
*
,
int
);
Node
*
procop
(
Node
*
);
Node
*
convas
(
Node
*
);
void
arrayconv
(
Type
*
,
Node
*
);
Node
*
colas
(
Node
*
,
Node
*
);
...
...
src/cmd/gc/sys.go
View file @
1d31a25d
...
...
@@ -44,8 +44,6 @@ func mapaccess2(hmap *map[any]any, key any) (val any, pres bool);
func
mapassign1
(
hmap
*
map
[
any
]
any
,
key
any
,
val
any
);
func
mapassign2
(
hmap
*
map
[
any
]
any
,
key
any
,
val
any
,
pres
bool
);
func
newproc
()
bool
;
// create a new coroutine; true is child
func
readfile
(
string
)
(
string
,
bool
);
// read file into string; boolean status
func
exit
(
int32
);
...
...
@@ -93,9 +91,6 @@ export
mapassign1
mapassign2
// threads/coroutines
newproc
// files
readfile
...
...
src/cmd/gc/sysimport.c
View file @
1d31a25d
This diff is collapsed.
Click to expand it.
src/cmd/gc/walk.c
View file @
1d31a25d
...
...
@@ -159,7 +159,7 @@ loop:
case
OPROC
:
if
(
top
!=
Etop
)
goto
nottop
;
*
n
=
*
procop
(
n
);
walktype
(
n
->
left
,
Etop
);
goto
ret
;
case
OCALLMETH
:
...
...
@@ -1594,27 +1594,6 @@ nottop:
return
N
;
}
Node
*
procop
(
Node
*
n
)
{
Node
*
r
,
*
on
;
switch
(
n
->
op
)
{
default:
fatal
(
"mapop: unknown op %E"
,
n
->
op
);
case
OPROC
:
// rewrite if(sys.newproc()) (n->left)
on
=
syslook
(
"newproc"
,
0
);
r
=
nod
(
OIF
,
N
,
N
);
r
->
ntest
=
nod
(
OCALL
,
on
,
N
);
r
->
nbody
=
n
->
left
;
dump
(
"newproc"
,
r
);
walktype
(
r
,
Etop
);
break
;
}
return
r
;
}
void
diagnamed
(
Type
*
t
)
{
...
...
@@ -1772,6 +1751,7 @@ colas(Node *nl, Node *nr)
l
=
listnext
(
&
savel
);
r
=
listnext
(
&
saver
);
}
n
=
rev
(
n
);
return
n
;
multi:
...
...
@@ -1827,6 +1807,7 @@ multi:
n
=
nod
(
OLIST
,
n
,
a
);
break
;
}
n
=
rev
(
n
);
return
n
;
badt:
...
...
src/runtime/rt0_amd64.s
View file @
1d31a25d
...
...
@@ -179,6 +179,12 @@ easy:
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
TEXT
sys
·
_newproc
(
SB
),
7
,
$
0
JMP
AX
RET
TEXT
FLUSH
(
SB
),7,$-8
RET
...
...
@@ -186,5 +192,4 @@ TEXT getu(SB),7,$-8
MOVQ
R15
,
AX
RET
GLOBL
peruser
<>(
SB
),$64
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment