Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
46311016
Commit
46311016
authored
Feb 04, 2012
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiler, reflect: Fix hash codes of named types, fix PtrTo hash.
From-SVN: r183889
parent
5007a7a8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
3 deletions
+34
-3
gcc/go/gofrontend/types.cc
+6
-1
libgo/go/reflect/all_test.go
+12
-0
libgo/go/reflect/type.go
+16
-2
No files found.
gcc/go/gofrontend/types.cc
View file @
46311016
...
...
@@ -1658,7 +1658,12 @@ Type::type_descriptor_constructor(Gogo* gogo, int runtime_type_kind,
++
p
;
go_assert
(
p
->
is_field_name
(
"hash"
));
mpz_set_ui
(
iv
,
this
->
hash_for_method
(
gogo
));
unsigned
int
h
;
if
(
name
!=
NULL
)
h
=
name
->
hash_for_method
(
gogo
);
else
h
=
this
->
hash_for_method
(
gogo
);
mpz_set_ui
(
iv
,
h
);
vals
->
push_back
(
Expression
::
make_integer
(
&
iv
,
p
->
type
(),
bloc
));
++
p
;
...
...
libgo/go/reflect/all_test.go
View file @
46311016
...
...
@@ -1528,6 +1528,18 @@ func TestAddr(t *testing.T) {
if
p
.
X
!=
4
{
t
.
Errorf
(
"Addr.Elem.Set valued to set value in top value"
)
}
// Verify that taking the address of a type gives us a pointer
// which we can convert back using the usual interface
// notation.
var
s
struct
{
B
*
bool
}
ps
:=
ValueOf
(
&
s
)
.
Elem
()
.
Field
(
0
)
.
Addr
()
.
Interface
()
*
(
ps
.
(
**
bool
))
=
new
(
bool
)
if
s
.
B
==
nil
{
t
.
Errorf
(
"Addr.Interface direct assignment failed"
)
}
}
/* gccgo does do allocations here.
...
...
libgo/go/reflect/type.go
View file @
46311016
...
...
@@ -999,6 +999,17 @@ func (ct *commonType) ptrTo() *commonType {
return
&
p
.
commonType
}
s
:=
"*"
+
*
ct
.
string
canonicalTypeLock
.
RLock
()
r
,
ok
:=
canonicalType
[
s
]
canonicalTypeLock
.
RUnlock
()
if
ok
{
ptrMap
.
m
[
ct
]
=
(
*
ptrType
)(
unsafe
.
Pointer
(
r
.
(
*
commonType
)))
ptrMap
.
Unlock
()
return
r
.
(
*
commonType
)
}
rp
:=
new
(
runtime
.
PtrType
)
// initialize p using *byte's ptrType as a prototype.
...
...
@@ -1008,7 +1019,6 @@ func (ct *commonType) ptrTo() *commonType {
bp
:=
(
*
ptrType
)(
unsafe
.
Pointer
(
unsafe
.
Typeof
((
*
byte
)(
nil
))
.
(
*
runtime
.
PtrType
)))
*
p
=
*
bp
s
:=
"*"
+
*
ct
.
string
p
.
string
=
&
s
// For the type structures linked into the binary, the
...
...
@@ -1016,12 +1026,16 @@ func (ct *commonType) ptrTo() *commonType {
// Create a good hash for the new string by using
// the FNV-1 hash's mixing function to combine the
// old hash and the new "*".
p
.
hash
=
ct
.
hash
*
16777619
^
'*'
// p.hash = ct.hash*16777619 ^ '*'
// This is the gccgo version.
p
.
hash
=
(
ct
.
hash
<<
4
)
+
9
p
.
uncommonType
=
nil
p
.
ptrToThis
=
nil
p
.
elem
=
(
*
runtime
.
Type
)(
unsafe
.
Pointer
(
ct
))
p
=
canonicalize
(
p
)
.
(
*
ptrType
)
ptrMap
.
m
[
ct
]
=
p
ptrMap
.
Unlock
()
return
&
p
.
commonType
...
...
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