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
82ee481d
Commit
82ee481d
authored
Sep 10, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc: remove &[10]int -> []int conversion
Fixes #829. R=ken2 CC=golang-dev
https://golang.org/cl/2124044
parent
58019288
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
41 deletions
+35
-41
src/cmd/gc/go.h
src/cmd/gc/go.h
+2
-2
src/cmd/gc/print.c
src/cmd/gc/print.c
+4
-3
src/cmd/gc/sinit.c
src/cmd/gc/sinit.c
+16
-6
src/cmd/gc/subr.c
src/cmd/gc/subr.c
+0
-7
src/cmd/gc/typecheck.c
src/cmd/gc/typecheck.c
+4
-7
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+9
-16
No files found.
src/cmd/gc/go.h
View file @
82ee481d
...
@@ -262,7 +262,7 @@ struct Node
...
@@ -262,7 +262,7 @@ struct Node
Sym
*
sym
;
// various
Sym
*
sym
;
// various
int32
vargen
;
// unique name for OTYPE/ONAME
int32
vargen
;
// unique name for OTYPE/ONAME
int32
lineno
;
int32
lineno
;
int32
endlineno
;
int32
endlineno
;
vlong
xoffset
;
vlong
xoffset
;
int32
ostk
;
int32
ostk
;
int32
iota
;
int32
iota
;
...
@@ -358,7 +358,7 @@ enum
...
@@ -358,7 +358,7 @@ enum
OCLOSURE
,
OCLOSURE
,
OCMPIFACE
,
OCMPSTR
,
OCMPIFACE
,
OCMPSTR
,
OCOMPLIT
,
OMAPLIT
,
OSTRUCTLIT
,
OARRAYLIT
,
OCOMPLIT
,
OMAPLIT
,
OSTRUCTLIT
,
OARRAYLIT
,
OCONV
,
OCONVIFACE
,
OCONVNOP
,
OCONVSLICE
,
OCONV
,
OCONVIFACE
,
OCONVNOP
,
OCOPY
,
OCOPY
,
ODCL
,
ODCLFUNC
,
ODCLFIELD
,
ODCLCONST
,
ODCLTYPE
,
ODCL
,
ODCLFUNC
,
ODCLFIELD
,
ODCLCONST
,
ODCLTYPE
,
ODOT
,
ODOTPTR
,
ODOTMETH
,
ODOTINTER
,
OXDOT
,
ODOT
,
ODOTPTR
,
ODOTMETH
,
ODOTINTER
,
OXDOT
,
...
...
src/cmd/gc/print.c
View file @
82ee481d
...
@@ -55,7 +55,6 @@ exprfmt(Fmt *f, Node *n, int prec)
...
@@ -55,7 +55,6 @@ exprfmt(Fmt *f, Node *n, int prec)
case
OCALL
:
case
OCALL
:
case
OCONV
:
case
OCONV
:
case
OCONVNOP
:
case
OCONVNOP
:
case
OCONVSLICE
:
case
OMAKESLICE
:
case
OMAKESLICE
:
case
ORUNESTR
:
case
ORUNESTR
:
case
OADDR
:
case
OADDR
:
...
@@ -319,9 +318,12 @@ exprfmt(Fmt *f, Node *n, int prec)
...
@@ -319,9 +318,12 @@ exprfmt(Fmt *f, Node *n, int prec)
break
;
break
;
case
OSLICE
:
case
OSLICE
:
case
OSLICESTR
:
case
OSLICEARR
:
exprfmt
(
f
,
n
->
left
,
7
);
exprfmt
(
f
,
n
->
left
,
7
);
fmtprint
(
f
,
"["
);
fmtprint
(
f
,
"["
);
exprfmt
(
f
,
n
->
right
->
left
,
0
);
if
(
n
->
right
->
left
!=
N
)
exprfmt
(
f
,
n
->
right
->
left
,
0
);
fmtprint
(
f
,
":"
);
fmtprint
(
f
,
":"
);
if
(
n
->
right
->
right
!=
N
)
if
(
n
->
right
->
right
!=
N
)
exprfmt
(
f
,
n
->
right
->
right
,
0
);
exprfmt
(
f
,
n
->
right
->
right
,
0
);
...
@@ -361,7 +363,6 @@ exprfmt(Fmt *f, Node *n, int prec)
...
@@ -361,7 +363,6 @@ exprfmt(Fmt *f, Node *n, int prec)
case
OCONV
:
case
OCONV
:
case
OCONVIFACE
:
case
OCONVIFACE
:
case
OCONVNOP
:
case
OCONVNOP
:
case
OCONVSLICE
:
case
OARRAYBYTESTR
:
case
OARRAYBYTESTR
:
case
ORUNESTR
:
case
ORUNESTR
:
if
(
n
->
type
==
T
||
n
->
type
->
sym
==
S
)
if
(
n
->
type
==
T
||
n
->
type
->
sym
==
S
)
...
...
src/cmd/gc/sinit.c
View file @
82ee481d
...
@@ -401,7 +401,7 @@ slicelit(int ctxt, Node *n, Node *var, NodeList **init)
...
@@ -401,7 +401,7 @@ slicelit(int ctxt, Node *n, Node *var, NodeList **init)
arraylit
(
ctxt
,
2
,
n
,
vstat
,
init
);
arraylit
(
ctxt
,
2
,
n
,
vstat
,
init
);
// copy static to slice
// copy static to slice
a
=
nod
(
O
ADDR
,
vstat
,
N
);
a
=
nod
(
O
SLICE
,
vstat
,
nod
(
OKEY
,
N
,
N
)
);
a
=
nod
(
OAS
,
var
,
a
);
a
=
nod
(
OAS
,
var
,
a
);
typecheck
(
&
a
,
Etop
);
typecheck
(
&
a
,
Etop
);
a
->
dodata
=
2
;
a
->
dodata
=
2
;
...
@@ -459,7 +459,7 @@ slicelit(int ctxt, Node *n, Node *var, NodeList **init)
...
@@ -459,7 +459,7 @@ slicelit(int ctxt, Node *n, Node *var, NodeList **init)
}
}
// make slice out of heap (5)
// make slice out of heap (5)
a
=
nod
(
OAS
,
var
,
vauto
);
a
=
nod
(
OAS
,
var
,
nod
(
OSLICE
,
vauto
,
nod
(
OKEY
,
N
,
N
))
);
typecheck
(
&
a
,
Etop
);
typecheck
(
&
a
,
Etop
);
walkexpr
(
&
a
,
init
);
walkexpr
(
&
a
,
init
);
*
init
=
list
(
*
init
,
a
);
*
init
=
list
(
*
init
,
a
);
...
@@ -864,8 +864,18 @@ gen_as_init(Node *n)
...
@@ -864,8 +864,18 @@ gen_as_init(Node *n)
default:
default:
goto
no
;
goto
no
;
case
OCONVSLICE
:
case
OCONVNOP
:
goto
slice
;
nr
=
nr
->
left
;
if
(
nr
==
N
||
nr
->
op
!=
OSLICEARR
)
goto
no
;
// fall through
case
OSLICEARR
:
if
(
nr
->
right
->
op
==
OKEY
&&
nr
->
right
->
left
==
N
&&
nr
->
right
->
right
==
N
)
{
nr
=
nr
->
left
;
goto
slice
;
}
goto
no
;
case
OLITERAL
:
case
OLITERAL
:
break
;
break
;
...
@@ -914,7 +924,7 @@ yes:
...
@@ -914,7 +924,7 @@ yes:
slice:
slice:
gused
(
N
);
// in case the data is the dest of a goto
gused
(
N
);
// in case the data is the dest of a goto
n
r
=
n
->
right
->
left
;
n
l
=
nr
;
if
(
nr
==
N
||
nr
->
op
!=
OADDR
)
if
(
nr
==
N
||
nr
->
op
!=
OADDR
)
goto
no
;
goto
no
;
nr
=
nr
->
left
;
nr
=
nr
->
left
;
...
@@ -926,7 +936,7 @@ slice:
...
@@ -926,7 +936,7 @@ slice:
goto
no
;
goto
no
;
nam
.
xoffset
+=
Array_array
;
nam
.
xoffset
+=
Array_array
;
gdata
(
&
nam
,
n
->
right
->
left
,
types
[
tptr
]
->
width
);
gdata
(
&
nam
,
n
l
,
types
[
tptr
]
->
width
);
nam
.
xoffset
+=
Array_nel
-
Array_array
;
nam
.
xoffset
+=
Array_nel
-
Array_array
;
nodconst
(
&
nod1
,
types
[
TINT32
],
nr
->
type
->
bound
);
nodconst
(
&
nod1
,
types
[
TINT32
],
nr
->
type
->
bound
);
...
...
src/cmd/gc/subr.c
View file @
82ee481d
...
@@ -1924,13 +1924,6 @@ assignop(Type *src, Type *dst, char **why)
...
@@ -1924,13 +1924,6 @@ assignop(Type *src, Type *dst, char **why)
// 7. Any typed value can be assigned to the blank identifier.
// 7. Any typed value can be assigned to the blank identifier.
if
(
dst
->
etype
==
TBLANK
)
if
(
dst
->
etype
==
TBLANK
)
return
OCONVNOP
;
return
OCONVNOP
;
// 8. Array to slice.
// TODO(rsc): Not for long.
if
(
!
src
->
sym
||
!
dst
->
sym
)
if
(
isptr
[
src
->
etype
]
&&
isfixedarray
(
src
->
type
)
&&
isslice
(
dst
))
if
(
eqtype
(
src
->
type
->
type
,
dst
->
type
))
return
OCONVSLICE
;
return
0
;
return
0
;
}
}
...
...
src/cmd/gc/typecheck.c
View file @
82ee481d
...
@@ -648,19 +648,16 @@ reswitch:
...
@@ -648,19 +648,16 @@ reswitch:
defaultlit
(
&
n
->
right
->
left
,
T
);
defaultlit
(
&
n
->
right
->
left
,
T
);
defaultlit
(
&
n
->
right
->
right
,
T
);
defaultlit
(
&
n
->
right
->
right
,
T
);
if
(
isfixedarray
(
n
->
left
->
type
))
{
if
(
isfixedarray
(
n
->
left
->
type
))
{
// Insert explicit & before fixed array
// so that back end knows to move to heap.
n
->
left
=
nod
(
OADDR
,
n
->
left
,
N
);
n
->
left
=
nod
(
OADDR
,
n
->
left
,
N
);
typecheck
(
&
n
->
left
,
top
);
typecheck
(
&
n
->
left
,
top
);
}
}
implicitstar
(
&
n
->
left
);
if
(
n
->
right
->
left
!=
N
)
{
if
(
n
->
right
->
left
!=
N
)
{
if
((
t
=
n
->
right
->
left
->
type
)
==
T
)
if
((
t
=
n
->
right
->
left
->
type
)
==
T
)
goto
error
;
goto
error
;
if
(
!
isint
[
t
->
etype
])
{
if
(
!
isint
[
t
->
etype
])
{
yyerror
(
"invalid slice index %#N (type %T)"
,
n
->
right
->
left
,
t
);
yyerror
(
"invalid slice index %#N (type %T)"
,
n
->
right
->
left
,
t
);
goto
error
;
goto
error
;
}
}
}
}
if
(
n
->
right
->
right
!=
N
)
{
if
(
n
->
right
->
right
!=
N
)
{
if
((
t
=
n
->
right
->
right
->
type
)
==
T
)
if
((
t
=
n
->
right
->
right
->
type
)
==
T
)
...
@@ -678,9 +675,9 @@ reswitch:
...
@@ -678,9 +675,9 @@ reswitch:
n
->
op
=
OSLICESTR
;
n
->
op
=
OSLICESTR
;
goto
ret
;
goto
ret
;
}
}
if
(
is
fixedarray
(
t
))
{
if
(
is
ptr
[
t
->
etype
]
&&
isfixedarray
(
t
->
type
))
{
n
->
type
=
typ
(
TARRAY
);
n
->
type
=
typ
(
TARRAY
);
n
->
type
->
type
=
t
->
type
;
n
->
type
->
type
=
t
->
type
->
type
;
n
->
type
->
bound
=
-
1
;
n
->
type
->
bound
=
-
1
;
dowidth
(
n
->
type
);
dowidth
(
n
->
type
);
n
->
op
=
OSLICEARR
;
n
->
op
=
OSLICEARR
;
...
@@ -1269,7 +1266,7 @@ implicitstar(Node **nn)
...
@@ -1269,7 +1266,7 @@ implicitstar(Node **nn)
Type
*
t
;
Type
*
t
;
Node
*
n
;
Node
*
n
;
// insert implicit * if needed
// insert implicit * if needed
for fixed array
n
=
*
nn
;
n
=
*
nn
;
t
=
n
->
type
;
t
=
n
->
type
;
if
(
t
==
T
||
!
isptr
[
t
->
etype
])
if
(
t
==
T
||
!
isptr
[
t
->
etype
])
...
...
src/cmd/gc/walk.c
View file @
82ee481d
...
@@ -1124,35 +1124,23 @@ walkexpr(Node **np, NodeList **init)
...
@@ -1124,35 +1124,23 @@ walkexpr(Node **np, NodeList **init)
// slicearray(old *any, uint64 nel, lb uint64, hb uint64, width uint64) (ary []any)
// slicearray(old *any, uint64 nel, lb uint64, hb uint64, width uint64) (ary []any)
t
=
n
->
type
;
t
=
n
->
type
;
fn
=
syslook
(
"slicearray"
,
1
);
fn
=
syslook
(
"slicearray"
,
1
);
argtype
(
fn
,
n
->
left
->
type
);
// any-1
argtype
(
fn
,
n
->
left
->
type
->
type
);
// any-1
argtype
(
fn
,
t
->
type
);
// any-2
argtype
(
fn
,
t
->
type
);
// any-2
if
(
n
->
right
->
left
==
N
)
if
(
n
->
right
->
left
==
N
)
l
=
nodintconst
(
0
);
l
=
nodintconst
(
0
);
else
else
l
=
conv
(
n
->
right
->
left
,
types
[
TUINT64
]);
l
=
conv
(
n
->
right
->
left
,
types
[
TUINT64
]);
if
(
n
->
right
->
right
==
N
)
if
(
n
->
right
->
right
==
N
)
r
=
nodintconst
(
n
->
left
->
type
->
bound
);
r
=
nodintconst
(
n
->
left
->
type
->
type
->
bound
);
else
else
r
=
conv
(
n
->
right
->
right
,
types
[
TUINT64
]);
r
=
conv
(
n
->
right
->
right
,
types
[
TUINT64
]);
n
=
mkcall1
(
fn
,
t
,
init
,
n
=
mkcall1
(
fn
,
t
,
init
,
n
od
(
OADDR
,
n
->
left
,
N
),
nodintconst
(
n
->
left
->
type
->
bound
),
n
->
left
,
nodintconst
(
n
->
left
->
type
->
type
->
bound
),
l
,
l
,
r
,
r
,
nodintconst
(
t
->
type
->
width
));
nodintconst
(
t
->
type
->
width
));
goto
ret
;
goto
ret
;
case
OCONVSLICE
:
// slicearray(old *any, uint64 nel, lb uint64, hb uint64, width uint64) (ary []any)
fn
=
syslook
(
"slicearray"
,
1
);
argtype
(
fn
,
n
->
left
->
type
->
type
);
// any-1
argtype
(
fn
,
n
->
type
->
type
);
// any-2
n
=
mkcall1
(
fn
,
n
->
type
,
init
,
n
->
left
,
nodintconst
(
n
->
left
->
type
->
type
->
bound
),
nodintconst
(
0
),
nodintconst
(
n
->
left
->
type
->
type
->
bound
),
nodintconst
(
n
->
type
->
type
->
width
));
goto
ret
;
case
OADDR
:;
case
OADDR
:;
Node
*
nvar
,
*
nstar
;
Node
*
nvar
,
*
nstar
;
...
@@ -2140,12 +2128,17 @@ static void
...
@@ -2140,12 +2128,17 @@ static void
heapmoves
(
void
)
heapmoves
(
void
)
{
{
NodeList
*
nn
;
NodeList
*
nn
;
int32
lno
;
lno
=
lineno
;
lineno
=
curfn
->
lineno
;
nn
=
paramstoheap
(
getthis
(
curfn
->
type
),
0
);
nn
=
paramstoheap
(
getthis
(
curfn
->
type
),
0
);
nn
=
concat
(
nn
,
paramstoheap
(
getinarg
(
curfn
->
type
),
0
));
nn
=
concat
(
nn
,
paramstoheap
(
getinarg
(
curfn
->
type
),
0
));
nn
=
concat
(
nn
,
paramstoheap
(
getoutarg
(
curfn
->
type
),
1
));
nn
=
concat
(
nn
,
paramstoheap
(
getoutarg
(
curfn
->
type
),
1
));
curfn
->
enter
=
concat
(
curfn
->
enter
,
nn
);
curfn
->
enter
=
concat
(
curfn
->
enter
,
nn
);
lineno
=
curfn
->
endlineno
;
curfn
->
exit
=
returnsfromheap
(
getoutarg
(
curfn
->
type
));
curfn
->
exit
=
returnsfromheap
(
getoutarg
(
curfn
->
type
));
lineno
=
lno
;
}
}
static
Node
*
static
Node
*
...
...
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