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
adaec0c4
Commit
adaec0c4
authored
Sep 22, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vectors bug
R=r OCL=15664 CL=15664
parent
c14924bc
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
424 additions
and
353 deletions
+424
-353
src/cmd/6g/cgen.c
src/cmd/6g/cgen.c
+23
-12
src/cmd/6g/gg.h
src/cmd/6g/gg.h
+1
-1
src/cmd/gc/sys.go
src/cmd/gc/sys.go
+4
-2
src/cmd/gc/sysimport.c
src/cmd/gc/sysimport.c
+292
-289
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+21
-12
src/runtime/iface.c
src/runtime/iface.c
+83
-37
No files found.
src/cmd/6g/cgen.c
View file @
adaec0c4
...
...
@@ -667,21 +667,33 @@ ret:
int32
stkof
(
Node
*
n
)
{
Type
*
t
;
Iter
flist
;
switch
(
n
->
op
)
{
// case OS2I:
// return 2*widthptr;
// case OI2I:
// return 1*widthptr;
case
OINDREG
:
return
n
->
xoffset
;
case
OCALLMETH
:
case
OCALLINTER
:
case
OCALL
:
t
=
n
->
left
->
type
;
if
(
isptr
[
t
->
etype
])
t
=
t
->
type
;
t
=
structfirst
(
&
flist
,
getoutarg
(
t
));
if
(
t
!=
T
)
return
t
->
width
;
break
;
}
// botch - probably failing to recognize address
// arithmetic on the above. eg INDEX and DOT
return
-
1
;
return
-
1
000
;
}
void
sgen
(
Node
*
n
,
Node
*
ns
,
u
int32
w
)
sgen
(
Node
*
n
,
Node
*
ns
,
int32
w
)
{
Node
nodl
,
nodr
;
int32
c
,
q
,
odst
,
osrc
;
...
...
@@ -697,12 +709,11 @@ sgen(Node *n, Node *ns, uint32 w)
}
// offset on the stack
odst
=
stkof
(
ns
);
osrc
=
stkof
(
n
);
if
(
osrc
<
0
)
odst
=
odst
;
if
(
odst
<
0
)
osrc
=
odst
;
odst
=
stkof
(
ns
);
//print("\nnsrc=%N\n", n)
;
//print("ndst=%N\n", ns);
//print("osrc=%d odst=%d w=%d\n", osrc, odst, w)
;
nodreg
(
&
nodl
,
types
[
tptr
],
D_DI
);
nodreg
(
&
nodr
,
types
[
tptr
],
D_SI
);
...
...
@@ -720,7 +731,7 @@ sgen(Node *n, Node *ns, uint32 w)
// if we are copying forward on the stack and
// the src and dst overlap, then reverse direction
if
(
o
dst
>
osrc
&&
odst
-
osrc
<
w
)
{
if
(
o
src
<
odst
&&
odst
<
osrc
+
w
)
{
// reverse direction
gins
(
ASTD
,
N
,
N
);
// set direction flag
if
(
c
>
0
)
{
...
...
src/cmd/6g/gg.h
View file @
adaec0c4
...
...
@@ -153,7 +153,7 @@ void agen(Node*, Node*);
void
igen
(
Node
*
,
Node
*
,
Node
*
);
vlong
fieldoffset
(
Type
*
,
Node
*
);
void
bgen
(
Node
*
,
int
,
Prog
*
);
void
sgen
(
Node
*
,
Node
*
,
u
int32
);
void
sgen
(
Node
*
,
Node
*
,
int32
);
void
gmove
(
Node
*
,
Node
*
);
Prog
*
gins
(
int
,
Node
*
,
Node
*
);
int
samaddr
(
Node
*
,
Node
*
);
...
...
src/cmd/gc/sys.go
View file @
adaec0c4
...
...
@@ -16,6 +16,7 @@ func printfloat(double);
func
printint
(
int64
);
func
printstring
(
string
);
func
printpointer
(
*
any
);
func
printinter
(
any
);
func
catstring
(
string
,
string
)
string
;
func
cmpstring
(
string
,
string
)
int32
;
...
...
@@ -24,8 +25,8 @@ func indexstring(string, int32) byte;
func
intstring
(
int64
)
string
;
func
byteastring
(
*
byte
,
int32
)
string
;
func
ifaceT2I
(
sigi
*
byte
,
sigt
*
byte
,
elem
any
)
(
ret
interface
{}
);
func
ifaceI2T
(
sigt
*
byte
,
iface
interface
{}
)
(
ret
any
);
func
ifaceT2I
(
sigi
*
byte
,
sigt
*
byte
,
elem
any
)
(
ret
any
);
func
ifaceI2T
(
sigt
*
byte
,
iface
any
)
(
ret
any
);
func
ifaceI2I
(
sigi
*
byte
,
iface
any
)
(
ret
any
);
func
argc
()
int32
;
...
...
@@ -90,6 +91,7 @@ export
printint
printstring
printpointer
printinter
// op string
catstring
...
...
src/cmd/gc/sysimport.c
View file @
adaec0c4
This diff is collapsed.
Click to expand it.
src/cmd/gc/walk.c
View file @
adaec0c4
...
...
@@ -552,6 +552,7 @@ loop:
// interface and structure
et
=
isandss
(
n
->
type
,
l
);
if
(
et
!=
Inone
)
{
if
(
et
==
I2I
)
dump
(
"conv"
,
n
);
indir
(
n
,
ifaceop
(
n
->
type
,
l
,
et
));
goto
ret
;
}
...
...
@@ -1626,14 +1627,19 @@ loop:
default:
if
(
l
->
type
==
T
)
goto
out
;
if
(
!
isptr
[
l
->
type
->
etype
]
)
{
badtype
(
n
->
op
,
l
->
type
,
T
);
l
=
listnext
(
&
save
);
goto
loop
;
if
(
isinter
(
l
->
type
)
)
{
on
=
syslook
(
"printinter"
,
1
);
argtype
(
on
,
l
->
type
);
// any-1
break
;
}
on
=
syslook
(
"printpointer"
,
1
);
argtype
(
on
,
l
->
type
->
type
);
// any-1
break
;
if
(
isptr
[
l
->
type
->
etype
])
{
on
=
syslook
(
"printpointer"
,
1
);
argtype
(
on
,
l
->
type
->
type
);
// any-1
break
;
}
badtype
(
n
->
op
,
l
->
type
,
T
);
l
=
listnext
(
&
save
);
goto
loop
;
case
Wlitint
:
case
Wtint
:
...
...
@@ -2490,7 +2496,7 @@ ifaceop(Type *tl, Node *n, int op)
fatal
(
"ifaceop: unknown op %d
\n
"
,
op
);
case
I2T
:
// ifaceI2T(sigt *byte, iface
interface{}
) (ret any);
// ifaceI2T(sigt *byte, iface
any
) (ret any);
a
=
n
;
// interface
r
=
a
;
...
...
@@ -2503,12 +2509,13 @@ ifaceop(Type *tl, Node *n, int op)
r
=
list
(
a
,
r
);
on
=
syslook
(
"ifaceI2T"
,
1
);
argtype
(
on
,
tr
);
argtype
(
on
,
tl
);
break
;
case
T2I
:
// ifaceT2I(sigi *byte, sigt *byte, elem any) (ret
interface{}
);
// ifaceT2I(sigi *byte, sigt *byte, elem any) (ret
any
);
a
=
n
;
// elem
r
=
a
;
...
...
@@ -2530,6 +2537,7 @@ ifaceop(Type *tl, Node *n, int op)
on
=
syslook
(
"ifaceT2I"
,
1
);
argtype
(
on
,
tr
);
argtype
(
on
,
tl
);
break
;
...
...
@@ -2538,16 +2546,17 @@ ifaceop(Type *tl, Node *n, int op)
a
=
n
;
// interface
r
=
a
;
s
=
signame
(
tr
);
// sigi
s
=
signame
(
tl
);
// sigi
if
(
s
==
S
)
fatal
(
"ifaceop: signame I2I"
);
a
=
s
->
oname
;
a
=
nod
(
OADDR
,
a
,
N
);
r
=
list
(
a
,
r
);
on
=
syslook
(
"ifaceI2I"
,
1
);
argtype
(
on
,
n
->
type
);
argtype
(
on
,
tr
);
argtype
(
on
,
tl
);
break
;
}
...
...
src/runtime/iface.c
View file @
adaec0c4
...
...
@@ -4,6 +4,8 @@
#include "runtime.h"
static
int32
debug
=
0
;
typedef
struct
Sigt
Sigt
;
typedef
struct
Sigi
Sigi
;
typedef
struct
Map
Map
;
...
...
@@ -33,19 +35,79 @@ struct Map
};
static
Map
*
hash
[
1009
];
static
int32
debug
=
0
;
static
void
printsigi
(
Sigi
*
si
)
{
int32
i
,
n
;
byte
*
name
;
sys
·
printpointer
(
si
);
prints
(
"{"
);
n
=
si
[
0
].
offset
;
for
(
i
=
1
;
i
<
n
;
i
++
)
{
name
=
si
[
i
].
name
;
if
(
name
==
nil
)
{
prints
(
"<nil>"
);
break
;
}
prints
(
"["
);
sys
·
printint
(
i
);
prints
(
"]
\"
"
);
prints
((
int8
*
)
name
);
prints
(
"
\"
"
);
sys
·
printint
(
si
[
i
].
hash
);
prints
(
"/"
);
sys
·
printint
(
si
[
i
].
offset
);
}
prints
(
"}"
);
}
static
void
printsigt
(
Sigt
*
st
)
{
int32
i
;
byte
*
name
;
sys
·
printpointer
(
st
);
prints
(
"{"
);
for
(
i
=
0
;;
i
++
)
{
name
=
st
[
i
].
name
;
if
(
name
==
nil
)
break
;
prints
(
"["
);
sys
·
printint
(
i
);
prints
(
"]
\"
"
);
prints
((
int8
*
)
name
);
prints
(
"
\"
"
);
sys
·
printint
(
st
[
i
].
hash
);
prints
(
"/"
);
sys
·
printpointer
(
st
[
i
].
fun
);
}
prints
(
"}"
);
}
static
void
printiface
(
Map
*
im
,
void
*
it
)
{
prints
(
"("
);
sys
·
printpointer
(
im
);
prints
(
","
);
sys
·
printpointer
(
it
);
prints
(
")"
);
}
static
Map
*
hashmap
(
Sigi
*
si
,
Sigt
*
s
s
)
hashmap
(
Sigi
*
si
,
Sigt
*
s
t
)
{
int32
n
s
,
ni
;
int32
n
t
,
ni
;
uint32
ihash
,
h
;
byte
*
sname
,
*
iname
;
Map
*
m
;
h
=
((
uint32
)(
uint64
)
si
+
(
uint32
)(
uint64
)
s
s
)
%
nelem
(
hash
);
h
=
((
uint32
)(
uint64
)
si
+
(
uint32
)(
uint64
)
s
t
)
%
nelem
(
hash
);
for
(
m
=
hash
[
h
];
m
!=
nil
;
m
=
m
->
link
)
{
if
(
m
->
sigi
==
si
&&
m
->
sigt
==
s
s
)
{
if
(
m
->
sigi
==
si
&&
m
->
sigt
==
s
t
)
{
if
(
m
->
bad
)
{
throw
(
"bad hashmap"
);
m
=
nil
;
...
...
@@ -58,10 +120,10 @@ hashmap(Sigi *si, Sigt *ss)
ni
=
si
[
0
].
offset
;
// first word has size
m
=
mal
(
sizeof
(
*
m
)
+
ni
*
sizeof
(
m
->
fun
[
0
]));
m
->
sigi
=
si
;
m
->
sigt
=
s
s
;
m
->
sigt
=
s
t
;
ni
=
1
;
// skip first word
n
s
=
0
;
n
t
=
0
;
loop1:
// pick up next name from
...
...
@@ -78,7 +140,7 @@ loop1:
loop2:
// pick up and comapre next name
// from structure signature
sname
=
s
s
[
ns
].
name
;
sname
=
s
t
[
nt
].
name
;
if
(
sname
==
nil
)
{
prints
((
int8
*
)
iname
);
prints
(
": "
);
...
...
@@ -89,40 +151,18 @@ loop2:
return
nil
;
}
if
(
ihash
!=
s
s
[
ns
].
hash
||
if
(
ihash
!=
s
t
[
nt
].
hash
||
strcmp
(
sname
,
iname
)
!=
0
)
{
n
s
++
;
n
t
++
;
goto
loop2
;
}
m
->
fun
[
si
[
ni
].
offset
]
=
s
s
[
ns
].
fun
;
m
->
fun
[
si
[
ni
].
offset
]
=
s
t
[
nt
].
fun
;
ni
++
;
goto
loop1
;
}
static
void
printsigi
(
Sigi
*
si
)
{
sys
·
printpointer
(
si
);
}
static
void
printsigt
(
Sigt
*
st
)
{
sys
·
printpointer
(
st
);
}
static
void
printiface
(
Map
*
im
,
void
*
it
)
{
prints
(
"("
);
sys
·
printpointer
(
im
);
prints
(
","
);
sys
·
printpointer
(
it
);
prints
(
")"
);
}
// ifaceT2I(sigi *byte, sigt *byte, elem any) (ret interface{});
// ifaceT2I(sigi *byte, sigt *byte, elem any) (ret any);
void
sys
·
ifaceT2I
(
Sigi
*
si
,
Sigt
*
st
,
void
*
elem
,
Map
*
retim
,
void
*
retit
)
{
...
...
@@ -149,7 +189,7 @@ sys·ifaceT2I(Sigi *si, Sigt *st, void *elem, Map *retim, void *retit)
FLUSH
(
&
retim
);
}
// ifaceI2T(sigt *byte, iface
interface{}
) (ret any);
// ifaceI2T(sigt *byte, iface
any
) (ret any);
void
sys
·
ifaceI2T
(
Sigt
*
st
,
Map
*
im
,
void
*
it
,
void
*
ret
)
{
...
...
@@ -178,14 +218,14 @@ sys·ifaceI2T(Sigt *st, Map *im, void *it, void *ret)
FLUSH
(
&
ret
);
}
// ifaceI2I(sigi *byte, iface
interface{}) (ret interface{}
);
// ifaceI2I(sigi *byte, iface
any) (ret any
);
void
sys
·
ifaceI2I
(
Sigi
*
si
,
Map
*
im
,
void
*
it
,
Map
*
retim
,
void
*
retit
)
{
if
(
debug
)
{
prints
(
"I2I sigi="
);
sys
·
printpointer
(
si
);
printsigi
(
si
);
prints
(
" iface="
);
printiface
(
im
,
it
);
prints
(
"
\n
"
);
...
...
@@ -209,3 +249,9 @@ sys·ifaceI2I(Sigi *si, Map *im, void *it, Map *retim, void *retit)
FLUSH
(
&
retim
);
}
void
sys
·
printinter
(
Map
*
im
,
void
*
it
)
{
printiface
(
im
,
it
);
}
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