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
3856e45e
Commit
3856e45e
authored
Jul 12, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more on channels
arg space magic number for morestack SVN=126936
parent
2da9783e
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
271 additions
and
115 deletions
+271
-115
src/cmd/6g/gen.c
src/cmd/6g/gen.c
+9
-2
src/cmd/6g/list.c
src/cmd/6g/list.c
+20
-4
src/cmd/gc/export.c
src/cmd/gc/export.c
+32
-0
src/cmd/gc/go.h
src/cmd/gc/go.h
+5
-3
src/cmd/gc/go.y
src/cmd/gc/go.y
+13
-0
src/cmd/gc/subr.c
src/cmd/gc/subr.c
+1
-0
src/cmd/gc/sys.go
src/cmd/gc/sys.go
+6
-1
src/cmd/gc/sysimport.c
src/cmd/gc/sysimport.c
+112
-105
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+73
-0
No files found.
src/cmd/6g/gen.c
View file @
3856e45e
...
...
@@ -22,7 +22,7 @@ compile(Node *fn)
Plist
*
pl
;
Node
nod1
;
Prog
*
ptxt
;
long
lno
;
long
lno
,
argsiz
;
if
(
newproc
==
N
)
{
newproc
=
nod
(
ONAME
,
N
,
N
);
...
...
@@ -69,8 +69,15 @@ if(newproc == N) {
pc
->
as
=
ARET
;
// overwrite AEND
pc
->
lineno
=
lineno
;
// fill in argument size
argsiz
=
getthisx
(
curfn
->
type
)
->
width
;
argsiz
+=
getinargx
(
curfn
->
type
)
->
width
;
argsiz
+=
getoutargx
(
curfn
->
type
)
->
width
;
ptxt
->
to
.
offset
=
rnd
(
argsiz
,
maxround
);
// fill in final stack size
ptxt
->
to
.
offset
=
rnd
(
stksize
+
maxarg
,
maxround
);
ptxt
->
to
.
offset
<<=
32
;
ptxt
->
to
.
offset
|=
rnd
(
stksize
+
maxarg
,
maxround
);
if
(
debug
[
'f'
])
frame
(
0
);
...
...
src/cmd/6g/list.c
View file @
3856e45e
...
...
@@ -50,14 +50,23 @@ Pconv(Fmt *fp)
p
=
va_arg
(
fp
->
args
,
Prog
*
);
sconsize
=
8
;
if
(
p
->
as
==
ADATA
)
{
switch
(
p
->
as
)
{
default:
snprint
(
str
,
sizeof
(
str
),
"%.4ld (%4ld) %-7A %D,%D"
,
p
->
loc
,
p
->
lineno
,
p
->
as
,
&
p
->
from
,
&
p
->
to
);
break
;
case
ADATA
:
sconsize
=
p
->
from
.
scale
;
snprint
(
str
,
sizeof
(
str
),
"%.4ld (%4ld) %-7A %D/%d,%D"
,
p
->
loc
,
p
->
lineno
,
p
->
as
,
&
p
->
from
,
sconsize
,
&
p
->
to
);
return
fmtstrcpy
(
fp
,
str
);
}
snprint
(
str
,
sizeof
(
str
),
"%.4ld (%4ld) %-7A %D,%D"
,
break
;
case
ATEXT
:
snprint
(
str
,
sizeof
(
str
),
"%.4ld (%4ld) %-7A %D,%lD"
,
p
->
loc
,
p
->
lineno
,
p
->
as
,
&
p
->
from
,
&
p
->
to
);
break
;
}
return
fmtstrcpy
(
fp
,
str
);
}
...
...
@@ -67,6 +76,7 @@ Dconv(Fmt *fp)
char
str
[
40
],
s
[
20
];
Addr
*
a
;
int
i
;
ulong
d1
,
d2
;
a
=
va_arg
(
fp
->
args
,
Addr
*
);
i
=
a
->
type
;
...
...
@@ -111,6 +121,12 @@ Dconv(Fmt *fp)
break
;
case
D_CONST
:
if
(
fp
->
flags
&
FmtLong
)
{
d1
=
a
->
offset
&
0xffffffffLL
;
d2
=
(
a
->
offset
>>
32
)
&
0xffffffffLL
;
sprint
(
str
,
"$%lud-%lud"
,
d1
,
d2
);
break
;
}
sprint
(
str
,
"$%lld"
,
a
->
offset
);
break
;
...
...
src/cmd/gc/export.c
View file @
3856e45e
...
...
@@ -233,6 +233,16 @@ dumpexporttype(Sym *s)
Bprint
(
bout
,
"!"
);
Bprint
(
bout
,
"%lS [%lS] %lS
\n
"
,
s
,
t
->
down
->
sym
,
t
->
type
->
sym
);
break
;
case
TCHAN
:
reexport
(
t
->
type
);
/* type 8 */
Bprint
(
bout
,
"
\t
type "
);
if
(
s
->
export
!=
0
)
Bprint
(
bout
,
"!"
);
Bprint
(
bout
,
"%lS %d %lS
\n
"
,
s
,
t
->
chan
,
t
->
type
->
sym
);
break
;
}
}
...
...
@@ -624,3 +634,25 @@ doimport7(Node *ss, Node *n)
importaddtyp
(
ss
,
t
);
}
/*
* LTYPE importsym chdir importsym
* interface type
*/
void
doimport8
(
Node
*
ss
,
Val
*
v
,
Node
*
st
)
{
Type
*
t
;
Sym
*
s
;
int
dir
;
s
=
pkglookup
(
st
->
sym
->
name
,
st
->
psym
->
name
);
dir
=
v
->
vval
;
t
=
typ
(
TCHAN
);
s
=
pkglookup
(
st
->
sym
->
name
,
st
->
psym
->
name
);
t
->
type
=
s
->
otype
;
t
->
chan
=
dir
;
importaddtyp
(
ss
,
t
);
}
src/cmd/gc/go.h
View file @
3856e45e
...
...
@@ -96,9 +96,9 @@ struct Type
Type
*
nforw
;
// TFUNCT
Type
*
this
;
Type
*
argout
;
Type
*
argin
;
//
Type* this;
//
Type* argout;
//
Type* argin;
Node
*
nname
;
// TARRAY
...
...
@@ -563,6 +563,7 @@ void doimport4(Node*, Node*);
void
doimport5
(
Node
*
,
Val
*
);
void
doimport6
(
Node
*
,
Node
*
);
void
doimport7
(
Node
*
,
Node
*
);
void
doimport8
(
Node
*
,
Val
*
,
Node
*
);
/*
* walk.c
...
...
@@ -583,6 +584,7 @@ Node* nodpanic(long);
Node
*
newcompat
(
Node
*
);
Node
*
stringop
(
Node
*
,
int
);
Node
*
mapop
(
Node
*
,
int
);
Node
*
chanop
(
Node
*
,
int
);
Node
*
convas
(
Node
*
);
void
arrayconv
(
Type
*
,
Node
*
);
Node
*
colas
(
Node
*
,
Node
*
);
...
...
src/cmd/gc/go.y
View file @
3856e45e
...
...
@@ -910,6 +910,14 @@ chandir:
{
$$
=
Csend
;
}
|
LLT
LGT
{
$$
=
Cboth
;
}
|
LGT
LLT
{
$$
=
0
;
}
keyval
:
expr
':'
expr
...
...
@@ -1481,6 +1489,11 @@ hidden_import:
//
type
interface
doimport7
($
2
,
$
4
);
}
|
LTYPE
hidden_importsym
LLITERAL
hidden_importsym
{
//
type
interface
doimport8
($
2
,
&$
3
,
$
4
);
}
isym
:
sym
'.'
sym
...
...
src/cmd/gc/subr.c
View file @
3856e45e
...
...
@@ -1295,6 +1295,7 @@ loop:
case
TPTR32
:
case
TPTR64
:
case
TCHAN
:
stp
=
&
st
->
type
;
goto
loop
;
...
...
src/cmd/gc/sys.go
View file @
3856e45e
...
...
@@ -44,6 +44,8 @@ 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
newchan
(
elemsize
uint32
,
elemalg
uint32
,
hint
uint32
)
(
hchan
*
chan
any
);
func
gosched
();
func
goexit
();
...
...
@@ -89,13 +91,16 @@ export
Inf
,
NaN
,
//
op
map
// map
newmap
mapaccess1
mapaccess2
mapassign1
mapassign2
// chan
newchan
// go routines
gosched
goexit
...
...
src/cmd/gc/sysimport.c
View file @
3856e45e
This diff is collapsed.
Click to expand it.
src/cmd/gc/walk.c
View file @
3856e45e
...
...
@@ -1219,6 +1219,10 @@ newcompat(Node *n)
r
=
mapop
(
n
,
Erv
);
return
r
;
}
if
(
t
->
etype
==
TCHAN
)
{
r
=
chanop
(
n
,
Erv
);
return
r
;
}
if
(
n
->
left
!=
N
)
yyerror
(
"dont know what new(,e) means"
);
...
...
@@ -1371,6 +1375,32 @@ fixmap(Type *tm)
return
t
;
}
Type
*
fixchan
(
Type
*
tm
)
{
Type
*
t
;
t
=
tm
->
type
;
if
(
t
==
T
)
{
fatal
(
"fixchan: t nil"
);
return
T
;
}
if
(
t
->
etype
!=
TCHAN
)
{
fatal
(
"fixchan: %O not map"
);
return
T
;
}
if
(
t
->
type
==
T
)
{
fatal
(
"fixchan: chan element type is nil"
);
return
T
;
}
dowidth
(
t
->
type
);
return
t
;
}
static
int
algtype
(
Type
*
t
)
{
...
...
@@ -1593,6 +1623,49 @@ nottop:
return
N
;
}
Node
*
chanop
(
Node
*
n
,
int
top
)
{
Node
*
r
,
*
a
;
Type
*
t
;
Node
*
on
;
int
alg
,
cl
,
cr
;
//dump("chanop", n);
r
=
n
;
switch
(
n
->
op
)
{
default:
fatal
(
"mapop: unknown op %E"
,
n
->
op
);
case
ONEW
:
// newchan(elemsize uint32, elemalg uint32,
// hint uint32) (hmap *chan[any-1]);
t
=
fixchan
(
n
->
type
);
if
(
t
==
T
)
break
;
a
=
n
->
left
;
// hint
if
(
n
->
left
==
N
)
a
=
nodintconst
(
0
);
r
=
a
;
a
=
nodintconst
(
algtype
(
t
->
type
));
// elem algorithm
r
=
nod
(
OLIST
,
a
,
r
);
a
=
nodintconst
(
t
->
type
->
width
);
// elem width
r
=
nod
(
OLIST
,
a
,
r
);
on
=
syslook
(
"newchan"
,
1
);
argtype
(
on
,
t
->
type
);
// any-1
r
=
nod
(
OCALL
,
on
,
r
);
walktype
(
r
,
top
);
r
->
type
=
n
->
type
;
break
;
}
return
r
;
}
void
diagnamed
(
Type
*
t
)
{
...
...
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