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
8877d27b
Commit
8877d27b
authored
Oct 03, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
interfaces of all types
R=r OCL=16462 CL=16462
parent
bbb908fe
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
72 deletions
+72
-72
align.c
src/cmd/6g/align.c
+1
-1
gg.h
src/cmd/6g/gg.h
+0
-2
obj.c
src/cmd/6g/obj.c
+42
-32
go.h
src/cmd/gc/go.h
+1
-1
subr.c
src/cmd/gc/subr.c
+11
-23
iface.c
src/runtime/iface.c
+17
-13
No files found.
src/cmd/6g/align.c
View file @
8877d27b
...
@@ -170,7 +170,7 @@ dowidth(Type *t)
...
@@ -170,7 +170,7 @@ dowidth(Type *t)
case
TFUNC
:
case
TFUNC
:
// function is 3 cated structures
// function is 3 cated structures
w
=
widstruct
(
*
getthis
(
t
),
0
,
0
);
w
=
widstruct
(
*
getthis
(
t
),
0
,
1
);
w
=
widstruct
(
*
getinarg
(
t
),
w
,
0
);
w
=
widstruct
(
*
getinarg
(
t
),
w
,
0
);
w
=
widstruct
(
*
getoutarg
(
t
),
w
,
1
);
w
=
widstruct
(
*
getoutarg
(
t
),
w
,
1
);
t
->
argwid
=
w
;
t
->
argwid
=
w
;
...
...
src/cmd/6g/gg.h
View file @
8877d27b
...
@@ -60,8 +60,6 @@ struct Sig
...
@@ -60,8 +60,6 @@ struct Sig
uint32
hash
;
uint32
hash
;
int32
perm
;
int32
perm
;
int32
offset
;
int32
offset
;
int32
width
;
int32
elemalg
;
Sig
*
link
;
Sig
*
link
;
};
};
...
...
src/cmd/6g/obj.c
View file @
8877d27b
...
@@ -485,6 +485,7 @@ dumpsignatures(void)
...
@@ -485,6 +485,7 @@ dumpsignatures(void)
x
->
dtype
=
d
->
dtype
;
x
->
dtype
=
d
->
dtype
;
x
->
forw
=
signatlist
;
x
->
forw
=
signatlist
;
signatlist
=
x
;
signatlist
=
x
;
//print("SIG = %lS %lS %lT\n", d->dsym, s, t);
}
}
/*
/*
...
@@ -585,8 +586,6 @@ dumpsignatures(void)
...
@@ -585,8 +586,6 @@ dumpsignatures(void)
at
.
sym
->
name
+
5
,
f
->
sym
->
name
);
at
.
sym
->
name
+
5
,
f
->
sym
->
name
);
a
->
sym
=
lookup
(
namebuf
);
a
->
sym
=
lookup
(
namebuf
);
a
->
offset
=
0
;
a
->
offset
=
0
;
a
->
elemalg
=
0
;
a
->
width
=
0
;
o
++
;
o
++
;
}
}
...
@@ -594,13 +593,6 @@ dumpsignatures(void)
...
@@ -594,13 +593,6 @@ dumpsignatures(void)
a
=
lsort
(
a
,
sigcmp
);
a
=
lsort
(
a
,
sigcmp
);
ot
=
0
;
ot
=
0
;
// first field of an interface signature
// contains the count and is not a real entry
if
(
et
==
TINTER
)
{
o
=
0
;
for
(
b
=
a
;
b
!=
nil
;
b
=
b
->
link
)
o
++
;
// sigi[0].name = ""
// sigi[0].name = ""
ot
=
rnd
(
ot
,
maxround
);
// array of structures
ot
=
rnd
(
ot
,
maxround
);
// array of structures
p
=
pc
;
p
=
pc
;
...
@@ -612,6 +604,15 @@ dumpsignatures(void)
...
@@ -612,6 +604,15 @@ dumpsignatures(void)
p
->
to
.
offset
=
stringo
;
p
->
to
.
offset
=
stringo
;
ot
+=
widthptr
;
ot
+=
widthptr
;
datastring
(
""
,
1
);
if
(
et
==
TINTER
)
{
// first field of an interface signature
// contains the count and is not a real entry
o
=
0
;
for
(
b
=
a
;
b
!=
nil
;
b
=
b
->
link
)
o
++
;
// sigi[0].hash = 0
// sigi[0].hash = 0
ot
=
rnd
(
ot
,
wi
);
ot
=
rnd
(
ot
,
wi
);
p
=
pc
;
p
=
pc
;
...
@@ -634,8 +635,39 @@ dumpsignatures(void)
...
@@ -634,8 +635,39 @@ dumpsignatures(void)
p
->
to
.
offset
=
o
;
p
->
to
.
offset
=
o
;
ot
+=
wi
;
ot
+=
wi
;
datastring
(
""
,
1
);
}
else
{
// first field of an type signature contains
// the element parameters and is not a real entry
t
=
d
->
dtype
;
if
(
t
->
methptr
&
2
)
t
=
types
[
tptr
];
// sigi[0].hash = elemalg
ot
=
rnd
(
ot
,
wi
);
p
=
pc
;
gins
(
ADATA
,
N
,
N
);
p
->
from
=
at
;
p
->
from
.
offset
=
ot
;
p
->
from
.
scale
=
wi
;
p
->
to
=
ac
;
p
->
to
.
offset
=
algtype
(
t
);
ot
+=
wi
;
// sigi[0].offset = width
ot
=
rnd
(
ot
,
wi
);
p
=
pc
;
gins
(
ADATA
,
N
,
N
);
p
->
from
=
at
;
p
->
from
.
offset
=
ot
;
p
->
from
.
scale
=
wi
;
p
->
to
=
ac
;
p
->
to
.
offset
=
t
->
width
;
ot
+=
wi
;
// skip the function
ot
=
rnd
(
ot
,
widthptr
);
ot
+=
widthptr
;
}
}
for
(
b
=
a
;
b
!=
nil
;
b
=
b
->
link
)
{
for
(
b
=
a
;
b
!=
nil
;
b
=
b
->
link
)
{
...
@@ -685,28 +717,6 @@ dumpsignatures(void)
...
@@ -685,28 +717,6 @@ dumpsignatures(void)
p
->
to
.
offset
=
b
->
offset
;
p
->
to
.
offset
=
b
->
offset
;
ot
+=
wi
;
ot
+=
wi
;
// sigt[++].width = type size
ot
=
rnd
(
ot
,
wi
);
p
=
pc
;
gins
(
ADATA
,
N
,
N
);
p
->
from
=
at
;
p
->
from
.
offset
=
ot
;
p
->
from
.
scale
=
wi
;
p
->
to
=
ac
;
p
->
to
.
offset
=
b
->
width
;
ot
+=
wi
;
// sigt[++].elemalg = type algorithm
ot
=
rnd
(
ot
,
wi
);
p
=
pc
;
gins
(
ADATA
,
N
,
N
);
p
->
from
=
at
;
p
->
from
.
offset
=
ot
;
p
->
from
.
scale
=
wi
;
p
->
to
=
ac
;
p
->
to
.
offset
=
b
->
elemalg
;
ot
+=
wi
;
// sigt[++].fun = &method
// sigt[++].fun = &method
ot
=
rnd
(
ot
,
widthptr
);
ot
=
rnd
(
ot
,
widthptr
);
p
=
pc
;
p
=
pc
;
...
...
src/cmd/gc/go.h
View file @
8877d27b
...
@@ -122,7 +122,7 @@ struct Type
...
@@ -122,7 +122,7 @@ struct Type
uchar
chan
;
uchar
chan
;
uchar
recur
;
// to detect loops
uchar
recur
;
// to detect loops
uchar
trecur
;
// to detect loops
uchar
trecur
;
// to detect loops
uchar
methptr
;
//
all methods are pointers to this type
uchar
methptr
;
//
1=direct 2=pointer
// TFUNCT
// TFUNCT
uchar
thistuple
;
uchar
thistuple
;
...
...
src/cmd/gc/subr.c
View file @
8877d27b
...
@@ -1418,37 +1418,25 @@ signame(Type *t)
...
@@ -1418,37 +1418,25 @@ signame(Type *t)
Sym
*
s
,
*
ss
;
Sym
*
s
,
*
ss
;
char
*
e
;
char
*
e
;
loop:
if
(
t
==
T
)
if
(
t
==
T
)
{
// print("signame: nil type\n");
goto
bad
;
goto
bad
;
}
switch
(
t
->
etype
)
{
default:
e
=
"sigs"
;
break
;
case
TPTR32
:
case
TPTR64
:
t
=
t
->
type
;
goto
loop
;
case
TINTER
:
e
=
"sigi"
;
break
;
}
s
=
t
->
sym
;
s
=
t
->
sym
;
if
(
s
==
S
)
{
if
(
s
==
S
||
s
->
name
[
0
]
==
'_'
)
{
// print("signame: no type name\n");
if
(
isptr
[
t
->
etype
])
{
t
=
t
->
type
;
if
(
t
==
T
)
goto
bad
;
goto
bad
;
}
}
if
(
s
->
name
[
0
]
==
'_'
)
{
s
=
t
->
sym
;
// print("signame: temp type name %S\n", s);
if
(
s
==
S
||
s
->
name
[
0
]
==
'_'
)
goto
bad
;
goto
bad
;
}
}
e
=
"sigt"
;
if
(
t
->
etype
==
TINTER
)
e
=
"sigi"
;
snprint
(
namebuf
,
sizeof
(
namebuf
),
"%s_%s"
,
e
,
s
->
name
);
snprint
(
namebuf
,
sizeof
(
namebuf
),
"%s_%s"
,
e
,
s
->
name
);
ss
=
pkglookup
(
namebuf
,
s
->
opackage
);
ss
=
pkglookup
(
namebuf
,
s
->
opackage
);
if
(
ss
->
oname
==
N
)
{
if
(
ss
->
oname
==
N
)
{
...
...
src/runtime/iface.c
View file @
8877d27b
...
@@ -15,8 +15,6 @@ struct Sigt
...
@@ -15,8 +15,6 @@ struct Sigt
byte
*
name
;
byte
*
name
;
uint32
hash
;
uint32
hash
;
uint32
offset
;
// offset of substruct
uint32
offset
;
// offset of substruct
uint32
width
;
// width of type
uint32
elemalg
;
// algorithm of type
void
(
*
fun
)(
void
);
void
(
*
fun
)(
void
);
};
};
...
@@ -47,13 +45,10 @@ printsigi(Sigi *si)
...
@@ -47,13 +45,10 @@ printsigi(Sigi *si)
sys
·
printpointer
(
si
);
sys
·
printpointer
(
si
);
prints
(
"{"
);
prints
(
"{"
);
n
=
si
[
0
].
perm
;
// first entry has size
for
(
i
=
1
;;
i
++
)
{
for
(
i
=
1
;
i
<
n
;
i
++
)
{
name
=
si
[
i
].
name
;
name
=
si
[
i
].
name
;
if
(
name
==
nil
)
{
if
(
name
==
nil
)
prints
(
"<nil>"
);
break
;
break
;
}
prints
(
"["
);
prints
(
"["
);
sys
·
printint
(
i
);
sys
·
printint
(
i
);
prints
(
"]
\"
"
);
prints
(
"]
\"
"
);
...
@@ -74,7 +69,10 @@ printsigt(Sigt *st)
...
@@ -74,7 +69,10 @@ printsigt(Sigt *st)
sys
·
printpointer
(
st
);
sys
·
printpointer
(
st
);
prints
(
"{"
);
prints
(
"{"
);
for
(
i
=
0
;;
i
++
)
{
sys
·
printint
(
st
[
0
].
hash
);
// first element has alg
prints
(
","
);
sys
·
printint
(
st
[
0
].
offset
);
// first element has width
for
(
i
=
1
;;
i
++
)
{
name
=
st
[
i
].
name
;
name
=
st
[
i
].
name
;
if
(
name
==
nil
)
if
(
name
==
nil
)
break
;
break
;
...
@@ -86,10 +84,6 @@ printsigt(Sigt *st)
...
@@ -86,10 +84,6 @@ printsigt(Sigt *st)
sys
·
printint
(
st
[
i
].
hash
%
999
);
sys
·
printint
(
st
[
i
].
hash
%
999
);
prints
(
"/"
);
prints
(
"/"
);
sys
·
printint
(
st
[
i
].
offset
);
sys
·
printint
(
st
[
i
].
offset
);
prints
(
","
);
sys
·
printint
(
st
[
i
].
width
);
prints
(
","
);
sys
·
printint
(
st
[
i
].
elemalg
);
prints
(
"/"
);
prints
(
"/"
);
sys
·
printpointer
(
st
[
i
].
fun
);
sys
·
printpointer
(
st
[
i
].
fun
);
}
}
...
@@ -165,6 +159,7 @@ hashmap(Sigi *si, Sigt *st)
...
@@ -165,6 +159,7 @@ hashmap(Sigi *si, Sigt *st)
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
)
{
{
// int32 alg, wid;
if
(
debug
)
{
if
(
debug
)
{
prints
(
"T2I sigi="
);
prints
(
"T2I sigi="
);
...
@@ -177,7 +172,11 @@ sys·ifaceT2I(Sigi *si, Sigt *st, void *elem, Map *retim, void *retit)
...
@@ -177,7 +172,11 @@ sys·ifaceT2I(Sigi *si, Sigt *st, void *elem, Map *retim, void *retit)
}
}
retim
=
hashmap
(
si
,
st
);
retim
=
hashmap
(
si
,
st
);
retit
=
elem
;
// alg = st->hash;
// wid = st->offset;
// algarray[alg].copy(wid, &retit, &elem);
retit
=
elem
;
// for speed could do this
if
(
debug
)
{
if
(
debug
)
{
prints
(
"T2I ret="
);
prints
(
"T2I ret="
);
...
@@ -193,6 +192,7 @@ sys·ifaceT2I(Sigi *si, Sigt *st, void *elem, Map *retim, void *retit)
...
@@ -193,6 +192,7 @@ sys·ifaceT2I(Sigi *si, Sigt *st, void *elem, Map *retim, void *retit)
void
void
sys
·
ifaceI2T
(
Sigt
*
st
,
Map
*
im
,
void
*
it
,
void
*
ret
)
sys
·
ifaceI2T
(
Sigt
*
st
,
Map
*
im
,
void
*
it
,
void
*
ret
)
{
{
// int32 alg, wid;
if
(
debug
)
{
if
(
debug
)
{
prints
(
"I2T sigt="
);
prints
(
"I2T sigt="
);
...
@@ -208,7 +208,11 @@ sys·ifaceI2T(Sigt *st, Map *im, void *it, void *ret)
...
@@ -208,7 +208,11 @@ sys·ifaceI2T(Sigt *st, Map *im, void *it, void *ret)
if
(
im
->
sigt
!=
st
)
if
(
im
->
sigt
!=
st
)
throw
(
"ifaceI2T: wrong type"
);
throw
(
"ifaceI2T: wrong type"
);
// alg = st->hash;
// wid = st->offset;
// algarray[alg].copy(wid, &ret, &it);
ret
=
it
;
ret
=
it
;
if
(
debug
)
{
if
(
debug
)
{
prints
(
"I2T ret="
);
prints
(
"I2T ret="
);
sys
·
printpointer
(
ret
);
sys
·
printpointer
(
ret
);
...
...
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