Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
949ab5c7
Commit
949ab5c7
authored
Jul 26, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
select
R=r APPROVED=r DELTA=41 (24 added, 13 deleted, 4 changed) OCL=13480 CL=13480
parent
e963cba8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
17 deletions
+28
-17
walk.c
src/cmd/gc/walk.c
+27
-9
chan.c
src/runtime/chan.c
+1
-8
No files found.
src/cmd/gc/walk.c
View file @
949ab5c7
...
...
@@ -20,6 +20,23 @@ walk(Node *fn)
dump
(
"fn"
,
fn
->
nbody
);
}
int
isselect
(
Node
*
n
)
{
Sym
*
s
;
if
(
n
==
N
)
return
0
;
n
=
n
->
left
;
s
=
pkglookup
(
"selectsend"
,
"sys"
);
if
(
s
==
n
->
sym
)
return
1
;
s
=
pkglookup
(
"selectrecv"
,
"sys"
);
if
(
s
==
n
->
sym
)
return
1
;
return
0
;
}
void
walktype
(
Node
*
n
,
int
top
)
{
...
...
@@ -227,16 +244,20 @@ loop:
case
OCALL
:
l
=
ascompatte
(
n
->
op
,
getinarg
(
t
),
&
n
->
right
,
0
);
n
->
right
=
reorder1
(
l
);
if
(
isselect
(
n
))
{
// clear output bool - special prob with selectsend
r
=
ascompatte
(
n
->
op
,
getoutarg
(
t
),
&
boolfalse
,
0
);
n
->
right
=
list
(
n
->
right
,
r
);
}
break
;
case
OCALLMETH
:
l
=
ascompatte
(
n
->
op
,
getinarg
(
t
),
&
n
->
right
,
0
);
r
=
ascompatte
(
n
->
op
,
getthis
(
t
),
&
n
->
left
->
left
,
0
);
if
(
l
!=
N
)
r
=
list
(
r
,
l
);
l
=
list
(
r
,
l
);
n
->
left
->
left
=
N
;
ullmancalc
(
n
->
left
);
n
->
right
=
reorder1
(
r
);
n
->
right
=
reorder1
(
l
);
break
;
}
goto
ret
;
...
...
@@ -919,6 +940,7 @@ selcase(Node *n, Node *var)
{
Node
*
a
,
*
r
,
*
on
,
*
c
;
Type
*
t
;
Iter
iter
;
c
=
n
->
left
;
if
(
c
->
op
==
ORECV
)
...
...
@@ -949,11 +971,7 @@ selcase(Node *n, Node *var)
a
=
var
;
// sel-var
r
=
list
(
a
,
r
);
a
=
nod
(
OCALL
,
on
,
r
);
r
=
nod
(
OIF
,
N
,
N
);
r
->
ntest
=
a
;
return
r
;
goto
out
;
recv:
walktype
(
c
->
left
,
Elv
);
// elem
...
...
@@ -982,12 +1000,12 @@ recv:
a
=
var
;
// sel-var
r
=
list
(
a
,
r
);
out:
a
=
nod
(
OCALL
,
on
,
r
);
r
=
nod
(
OIF
,
N
,
N
);
r
->
ntest
=
a
;
return
r
;
}
void
...
...
src/runtime/chan.c
View file @
949ab5c7
...
...
@@ -377,7 +377,7 @@ sys·selectsend(Select *sel, Hchan *c, ...)
{
int32
i
,
eo
;
Scase
*
cas
;
byte
*
a
s
,
*
a
e
;
byte
*
ae
;
// nil cases do not compete
if
(
c
==
nil
)
...
...
@@ -400,9 +400,6 @@ sys·selectsend(Select *sel, Hchan *c, ...)
ae
=
(
byte
*
)
&
sel
+
eo
;
c
->
elemalg
->
copy
(
c
->
elemsize
,
cas
->
u
.
elem
,
ae
);
as
=
(
byte
*
)
&
sel
+
cas
->
so
;
*
as
=
false
;
if
(
debug
)
{
prints
(
"newselect s="
);
sys
·
printpointer
(
sel
);
...
...
@@ -424,7 +421,6 @@ sys·selectrecv(Select *sel, Hchan *c, ...)
{
int32
i
,
epo
;
Scase
*
cas
;
byte
*
as
;
// nil cases do not compete
if
(
c
==
nil
)
...
...
@@ -445,9 +441,6 @@ sys·selectrecv(Select *sel, Hchan *c, ...)
cas
->
send
=
0
;
cas
->
u
.
elemp
=
*
(
byte
**
)((
byte
*
)
&
sel
+
epo
);
as
=
(
byte
*
)
&
sel
+
cas
->
so
;
*
as
=
false
;
if
(
debug
)
{
prints
(
"newselect s="
);
sys
·
printpointer
(
sel
);
...
...
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