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