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
47c56888
Commit
47c56888
authored
Aug 28, 2009
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug in sliceslice
R=rsc OCL=34047 CL=34047
parent
c6540d31
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
13 deletions
+24
-13
ggen.c
src/cmd/6g/ggen.c
+24
-13
No files found.
src/cmd/6g/ggen.c
View file @
47c56888
...
...
@@ -1236,6 +1236,17 @@ cmpandthrow(Node *nl, Node *nr)
patch
(
p1
,
pc
);
}
int
sleasy
(
Node
*
n
)
{
if
(
n
->
op
!=
ONAME
)
return
0
;
if
(
!
n
->
addable
)
return
0
;
return
0
;
return
1
;
}
// generate inline code for
// slicearray
// sliceslice
...
...
@@ -1252,7 +1263,7 @@ cgen_inline(Node *n, Node *res)
goto
no
;
if
(
!
n
->
left
->
addable
)
goto
no
;
if
(
!
res
->
addable
)
if
(
!
sleasy
(
res
)
)
goto
no
;
if
(
strcmp
(
n
->
left
->
sym
->
package
,
"sys"
)
!=
0
)
goto
no
;
...
...
@@ -1338,42 +1349,42 @@ slicearray:
sliceslice:
getargs
(
n
->
list
,
nodes
,
4
);
if
(
!
(
nodes
+
0
)
->
addable
)
{
if
(
!
sleasy
(
&
nodes
[
0
])
)
{
for
(
i
=
0
;
i
<
4
;
i
++
)
{
if
(
(
nodes
+
i
)
->
op
==
OREGISTER
)
regfree
(
nodes
+
i
);
if
(
nodes
[
i
].
op
==
OREGISTER
)
regfree
(
&
nodes
[
i
]
);
}
goto
no
;
}
// if(hb[2] > old.cap[0]) goto throw;
n2
=
*
(
nodes
+
0
)
;
n2
=
nodes
[
0
]
;
n2
.
xoffset
+=
Array_cap
;
cmpandthrow
(
nodes
+
2
,
&
n2
);
// if(lb[1] > hb[2]) goto throw;
cmpandthrow
(
nodes
+
1
,
nodes
+
2
);
cmpandthrow
(
&
nodes
[
1
],
&
nodes
[
2
]
);
// ret.len = hb[2]-lb[1]; (destroys hb[2])
n2
=
*
res
;
n2
.
xoffset
+=
Array_nel
;
if
(
smallintconst
(
nodes
+
2
)
&&
smallintconst
(
nodes
+
1
))
{
if
(
smallintconst
(
&
nodes
[
2
])
&&
smallintconst
(
&
nodes
[
1
]
))
{
v
=
mpgetfix
((
nodes
+
2
)
->
val
.
u
.
xval
)
-
mpgetfix
(
(
nodes
+
1
)
->
val
.
u
.
xval
);
mpgetfix
(
nodes
[
2
].
val
.
u
.
xval
);
nodconst
(
&
n1
,
types
[
TUINT32
],
v
);
gins
(
optoas
(
OAS
,
types
[
TUINT32
]),
&
n1
,
&
n2
);
}
else
{
regalloc
(
&
n1
,
types
[
TUINT32
],
nodes
+
2
);
gmove
(
nodes
+
2
,
&
n1
);
if
(
!
smallintconst
(
nodes
+
1
)
||
mpgetfix
((
nodes
+
1
)
->
val
.
u
.
xval
)
!=
0
)
gins
(
optoas
(
OSUB
,
types
[
TUINT32
]),
nodes
+
1
,
&
n1
);
if
(
!
smallintconst
(
&
nodes
[
1
])
||
mpgetfix
(
nodes
[
1
].
val
.
u
.
xval
)
!=
0
)
gins
(
optoas
(
OSUB
,
types
[
TUINT32
]),
&
nodes
[
1
]
,
&
n1
);
gins
(
optoas
(
OAS
,
types
[
TUINT32
]),
&
n1
,
&
n2
);
regfree
(
&
n1
);
}
// ret.cap = old.cap[0]-lb[1]; (uses hb[2])
n2
=
*
(
nodes
+
0
)
;
n2
=
nodes
[
0
]
;
n2
.
xoffset
+=
Array_cap
;
regalloc
(
&
n1
,
types
[
TUINT32
],
nodes
+
2
);
...
...
@@ -1387,12 +1398,12 @@ sliceslice:
regfree
(
&
n1
);
// ret.array = old.array[0]+lb[1]*width[3]; (uses lb)
n2
=
*
(
nodes
+
0
)
;
n2
=
nodes
[
0
]
;
n2
.
xoffset
+=
Array_array
;
regalloc
(
&
n1
,
types
[
tptr
],
nodes
+
1
);
if
(
smallintconst
(
nodes
+
1
)
&&
smallintconst
(
nodes
+
3
))
{
gins
(
optoas
(
OAS
,
types
[
TUINT32
]),
&
n2
,
&
n1
);
gins
(
optoas
(
OAS
,
types
[
tptr
]),
&
n2
,
&
n1
);
v
=
mpgetfix
((
nodes
+
1
)
->
val
.
u
.
xval
)
*
mpgetfix
((
nodes
+
3
)
->
val
.
u
.
xval
);
if
(
v
!=
0
)
{
...
...
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