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
a52fb815
Commit
a52fb815
authored
Jun 05, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
386-related fixes and guards
R=r DELTA=44 (19 added, 1 deleted, 24 changed) OCL=29912 CL=29915
parent
6739b8d6
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
41 additions
and
23 deletions
+41
-23
type.go
src/lib/reflect/type.go
+2
-2
value.go
src/lib/reflect/value.go
+10
-3
asm.s
src/runtime/386/asm.s
+1
-1
hashmap.h
src/runtime/hashmap.h
+1
-1
iface.c
src/runtime/iface.c
+3
-3
malloc.c
src/runtime/malloc.c
+8
-3
runtime.c
src/runtime/runtime.c
+12
-6
runtime.h
src/runtime/runtime.h
+4
-4
No files found.
src/lib/reflect/type.go
View file @
a52fb815
...
...
@@ -91,8 +91,8 @@ const (
interfacesize
=
unsafe
.
Sizeof
(
x
.
xinterface
);
)
var
missingString
=
"$missing$"
// syntactic name for undefined type names
var
dotDotDotString
=
"..."
const
missingString
=
"$missing$"
// syntactic name for undefined type names
const
dotDotDotString
=
"..."
// Type is the generic interface to reflection types. Once its Kind is known,
// such as ArrayKind, the Type can be narrowed to the appropriate, more
...
...
src/lib/reflect/value.go
View file @
a52fb815
...
...
@@ -61,7 +61,7 @@ func (c *commonValue) Interface() interface {} {
switch
{
case
c
.
typ
.
Kind
()
==
InterfaceKind
:
panic
(
"not reached"
);
// InterfaceValue overrides this method
case
c
.
typ
.
Size
()
>
8
:
// TODO(rsc): how do we know it is 8?
case
c
.
typ
.
Size
()
>
unsafe
.
Sizeof
(
uintptr
(
0
))
:
i
=
unsafe
.
Unreflect
(
uint64
(
uintptr
(
c
.
addr
)),
c
.
typ
.
String
(),
true
);
default
:
if
uintptr
(
c
.
addr
)
==
0
{
...
...
@@ -872,7 +872,7 @@ var typecache = make(map[string] Type);
func
newValueAddr
(
typ
Type
,
addr
Addr
)
Value
{
c
,
ok
:=
creator
[
typ
.
Kind
()];
if
!
ok
{
panicln
(
"no creator for type"
,
typ
.
Kind
());
panicln
(
"no creator for type"
,
typ
.
String
());
}
return
c
(
typ
,
addr
);
}
...
...
@@ -945,9 +945,16 @@ func NewValue(e interface {}) Value {
typ
,
ok
:=
typecache
[
typestring
];
if
!
ok
{
typ
=
ParseTypeString
(
""
,
typestring
);
if
typ
.
Kind
()
==
MissingKind
{
// This can not happen: unsafe.Reflect should only
// ever tell us the names of types that exist.
// Of course it does happen, and when it does
// it is more helpful to catch it in action here than
// to see $missing$ in a later print.
panicln
(
"missing type for"
,
typestring
);
}
typecache
[
typestring
]
=
typ
;
}
var
ap
Addr
;
if
indir
{
// Content of interface is large and didn't
...
...
src/runtime/386/asm.s
View file @
a52fb815
...
...
@@ -116,7 +116,7 @@ TEXT gosave(SB), 7, $0
// save AX, jmp to lesstack to switch back
TEXT retfromnewstack(SB),7,$0
MOVL 4(FS), BX // m
MOVL AX,
8
(BX) // save AX in m->cret
MOVL AX,
12
(BX) // save AX in m->cret
JMP lessstack(SB)
// gogo, returning 2nd arg instead of 1
...
...
src/runtime/hashmap.h
View file @
a52fb815
...
...
@@ -76,7 +76,7 @@ struct hash; /* opaque */
struct
hash_subtable
;
/* opaque */
struct
hash_entry
;
/* opaque */
typedef
uint64
uintptr_t
;
typedef
uintptr
uintptr_t
;
typedef
uintptr_t
hash_hash_t
;
struct
hash_iter
{
...
...
src/runtime/iface.c
View file @
a52fb815
...
...
@@ -542,7 +542,7 @@ sys·ifaceE2I2(Sigi *si, Eface e, Iface ret, bool ok)
FLUSH
(
&
ok
);
}
static
uint
64
static
uint
ptr
ifacehash1
(
void
*
data
,
Sigt
*
sigt
)
{
int32
alg
,
wid
;
...
...
@@ -565,7 +565,7 @@ ifacehash1(void *data, Sigt *sigt)
return
algarray
[
alg
].
hash
(
wid
,
data
);
}
uint
64
uint
ptr
ifacehash
(
Iface
a
)
{
if
(
a
.
type
==
nil
)
...
...
@@ -573,7 +573,7 @@ ifacehash(Iface a)
return
ifacehash1
(
a
.
data
,
a
.
type
->
sigt
);
}
uint
64
uint
ptr
efacehash
(
Eface
a
)
{
return
ifacehash1
(
a
.
data
,
a
.
type
);
...
...
src/runtime/malloc.c
View file @
a52fb815
...
...
@@ -58,7 +58,10 @@ malloc(uintptr size)
}
// setup for mark sweep
mlookup
(
v
,
nil
,
nil
,
&
ref
);
if
(
!
mlookup
(
v
,
nil
,
nil
,
&
ref
))
{
printf
(
"malloc %D; mlookup failed
\n
"
,
(
uint64
)
size
);
throw
(
"malloc mlookup"
);
}
*
ref
=
RefNone
;
m
->
mallocing
=
0
;
...
...
@@ -93,7 +96,8 @@ free(void *v)
throw
(
"malloc/free - deadlock"
);
m
->
mallocing
=
1
;
mlookup
(
v
,
nil
,
nil
,
&
ref
);
if
(
!
mlookup
(
v
,
nil
,
nil
,
&
ref
))
throw
(
"free mlookup"
);
*
ref
=
RefFree
;
// Find size class for v.
...
...
@@ -283,7 +287,8 @@ stackalloc(uint32 n)
return
v
;
}
v
=
malloc
(
n
);
mlookup
(
v
,
nil
,
nil
,
&
ref
);
if
(
!
mlookup
(
v
,
nil
,
nil
,
&
ref
))
throw
(
"stackalloc mlookup"
);
*
ref
=
RefStack
;
return
v
;
}
...
...
src/runtime/runtime.c
View file @
a52fb815
...
...
@@ -267,15 +267,21 @@ check(void)
* map and chan helpers for
* dealing with unknown types
*/
static
uint
64
static
uint
ptr
memhash
(
uint32
s
,
void
*
a
)
{
byte
*
b
;
uint
64
hash
;
uint
ptr
hash
;
b
=
a
;
if
(
sizeof
(
hash
)
==
4
)
hash
=
2860486313U
;
else
hash
=
33054211828000289ULL
;
while
(
s
>
0
)
{
if
(
sizeof
(
hash
)
==
4
)
hash
=
(
hash
^
*
b
)
*
3267000013UL
;
else
hash
=
(
hash
^
*
b
)
*
23344194077549503ULL
;
b
++
;
s
--
;
...
...
@@ -337,7 +343,7 @@ memcopy(uint32 s, void *a, void *b)
ba
[
i
]
=
bb
[
i
];
}
static
uint
64
static
uint
ptr
strhash
(
uint32
s
,
String
*
a
)
{
USED
(
s
);
...
...
@@ -358,7 +364,7 @@ strprint(uint32 s, String *a)
sys
·
printstring
(
*
a
);
}
static
uint
64
static
uint
ptr
interhash
(
uint32
s
,
Iface
*
a
)
{
USED
(
s
);
...
...
@@ -379,7 +385,7 @@ interequal(uint32 s, Iface *a, Iface *b)
return
ifaceeq
(
*
a
,
*
b
);
}
static
uint
64
static
uint
ptr
nilinterhash
(
uint32
s
,
Eface
*
a
)
{
USED
(
s
);
...
...
@@ -400,7 +406,7 @@ nilinterequal(uint32 s, Eface *a, Eface *b)
return
efaceeq
(
*
a
,
*
b
);
}
uint
64
uint
ptr
nohash
(
uint32
s
,
void
*
a
)
{
USED
(
s
);
...
...
src/runtime/runtime.h
View file @
a52fb815
...
...
@@ -194,7 +194,7 @@ struct Stktop
};
struct
Alg
{
uint
64
(
*
hash
)(
uint32
,
void
*
);
uint
ptr
(
*
hash
)(
uint32
,
void
*
);
uint32
(
*
equal
)(
uint32
,
void
*
,
void
*
);
void
(
*
print
)(
uint32
,
void
*
);
void
(
*
copy
)(
uint32
,
void
*
,
void
*
);
...
...
@@ -333,9 +333,9 @@ MCache* allocmcache(void);
void
mallocinit
(
void
);
bool
ifaceeq
(
Iface
,
Iface
);
bool
efaceeq
(
Eface
,
Eface
);
uint
64
ifacehash
(
Iface
);
uint
64
efacehash
(
Eface
);
uint
64
nohash
(
uint32
,
void
*
);
uint
ptr
ifacehash
(
Iface
);
uint
ptr
efacehash
(
Eface
);
uint
ptr
nohash
(
uint32
,
void
*
);
uint32
noequal
(
uint32
,
void
*
,
void
*
);
void
*
malloc
(
uintptr
size
);
void
*
mallocgc
(
uintptr
size
);
...
...
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