mirror of
https://github.com/golang/go
synced 2024-11-19 17:34:41 -07:00
runtime: add type algorithms for zero-sized types
BenchmarkChanSem old=127ns new=78.6ns R=golang-dev, bradfitz, sameer, rsc CC=golang-dev https://golang.org/cl/5558049
This commit is contained in:
parent
43b4db194a
commit
1ff1405cc7
@ -40,12 +40,14 @@ enum
|
|||||||
// These values are known by runtime.
|
// These values are known by runtime.
|
||||||
// The MEMx and NOEQx values must run in parallel. See algtype.
|
// The MEMx and NOEQx values must run in parallel. See algtype.
|
||||||
AMEM = 0,
|
AMEM = 0,
|
||||||
|
AMEM0,
|
||||||
AMEM8,
|
AMEM8,
|
||||||
AMEM16,
|
AMEM16,
|
||||||
AMEM32,
|
AMEM32,
|
||||||
AMEM64,
|
AMEM64,
|
||||||
AMEM128,
|
AMEM128,
|
||||||
ANOEQ,
|
ANOEQ,
|
||||||
|
ANOEQ0,
|
||||||
ANOEQ8,
|
ANOEQ8,
|
||||||
ANOEQ16,
|
ANOEQ16,
|
||||||
ANOEQ32,
|
ANOEQ32,
|
||||||
|
@ -586,6 +586,8 @@ algtype(Type *t)
|
|||||||
if(isslice(t))
|
if(isslice(t))
|
||||||
return ASLICE;
|
return ASLICE;
|
||||||
switch(t->width) {
|
switch(t->width) {
|
||||||
|
case 0:
|
||||||
|
return a + AMEM0 - AMEM;
|
||||||
case 1:
|
case 1:
|
||||||
return a + AMEM8 - AMEM;
|
return a + AMEM8 - AMEM;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -88,6 +88,23 @@ runtime·memcopy(uintptr s, void *a, void *b)
|
|||||||
runtime·memmove(a, b, s);
|
runtime·memmove(a, b, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
runtime·memequal0(bool *eq, uintptr s, void *a, void *b)
|
||||||
|
{
|
||||||
|
USED(s);
|
||||||
|
USED(a);
|
||||||
|
USED(b);
|
||||||
|
*eq = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
runtime·memcopy0(uintptr s, void *a, void *b)
|
||||||
|
{
|
||||||
|
USED(s);
|
||||||
|
USED(a);
|
||||||
|
USED(b);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
runtime·memequal8(bool *eq, uintptr s, void *a, void *b)
|
runtime·memequal8(bool *eq, uintptr s, void *a, void *b)
|
||||||
{
|
{
|
||||||
@ -332,11 +349,13 @@ runtime·algarray[] =
|
|||||||
[AINTER] { runtime·interhash, runtime·interequal, runtime·interprint, runtime·intercopy },
|
[AINTER] { runtime·interhash, runtime·interequal, runtime·interprint, runtime·intercopy },
|
||||||
[ANILINTER] { runtime·nilinterhash, runtime·nilinterequal, runtime·nilinterprint, runtime·nilintercopy },
|
[ANILINTER] { runtime·nilinterhash, runtime·nilinterequal, runtime·nilinterprint, runtime·nilintercopy },
|
||||||
[ASLICE] { runtime·nohash, runtime·noequal, runtime·memprint, runtime·slicecopy },
|
[ASLICE] { runtime·nohash, runtime·noequal, runtime·memprint, runtime·slicecopy },
|
||||||
|
[AMEM0] { runtime·memhash, runtime·memequal0, runtime·memprint, runtime·memcopy0 },
|
||||||
[AMEM8] { runtime·memhash, runtime·memequal8, runtime·memprint, runtime·memcopy8 },
|
[AMEM8] { runtime·memhash, runtime·memequal8, runtime·memprint, runtime·memcopy8 },
|
||||||
[AMEM16] { runtime·memhash, runtime·memequal16, runtime·memprint, runtime·memcopy16 },
|
[AMEM16] { runtime·memhash, runtime·memequal16, runtime·memprint, runtime·memcopy16 },
|
||||||
[AMEM32] { runtime·memhash, runtime·memequal32, runtime·memprint, runtime·memcopy32 },
|
[AMEM32] { runtime·memhash, runtime·memequal32, runtime·memprint, runtime·memcopy32 },
|
||||||
[AMEM64] { runtime·memhash, runtime·memequal64, runtime·memprint, runtime·memcopy64 },
|
[AMEM64] { runtime·memhash, runtime·memequal64, runtime·memprint, runtime·memcopy64 },
|
||||||
[AMEM128] { runtime·memhash, runtime·memequal128, runtime·memprint, runtime·memcopy128 },
|
[AMEM128] { runtime·memhash, runtime·memequal128, runtime·memprint, runtime·memcopy128 },
|
||||||
|
[ANOEQ0] { runtime·nohash, runtime·noequal, runtime·memprint, runtime·memcopy0 },
|
||||||
[ANOEQ8] { runtime·nohash, runtime·noequal, runtime·memprint, runtime·memcopy8 },
|
[ANOEQ8] { runtime·nohash, runtime·noequal, runtime·memprint, runtime·memcopy8 },
|
||||||
[ANOEQ16] { runtime·nohash, runtime·noequal, runtime·memprint, runtime·memcopy16 },
|
[ANOEQ16] { runtime·nohash, runtime·noequal, runtime·memprint, runtime·memcopy16 },
|
||||||
[ANOEQ32] { runtime·nohash, runtime·noequal, runtime·memprint, runtime·memcopy32 },
|
[ANOEQ32] { runtime·nohash, runtime·noequal, runtime·memprint, runtime·memcopy32 },
|
||||||
|
@ -371,3 +371,12 @@ func BenchmarkChanCreation(b *testing.B) {
|
|||||||
<-c
|
<-c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkChanSem(b *testing.B) {
|
||||||
|
type Empty struct{}
|
||||||
|
c := make(chan Empty, 1)
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
c <- Empty{}
|
||||||
|
<-c
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -358,12 +358,14 @@ enum {
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
AMEM,
|
AMEM,
|
||||||
|
AMEM0,
|
||||||
AMEM8,
|
AMEM8,
|
||||||
AMEM16,
|
AMEM16,
|
||||||
AMEM32,
|
AMEM32,
|
||||||
AMEM64,
|
AMEM64,
|
||||||
AMEM128,
|
AMEM128,
|
||||||
ANOEQ,
|
ANOEQ,
|
||||||
|
ANOEQ0,
|
||||||
ANOEQ8,
|
ANOEQ8,
|
||||||
ANOEQ16,
|
ANOEQ16,
|
||||||
ANOEQ32,
|
ANOEQ32,
|
||||||
|
Loading…
Reference in New Issue
Block a user