Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(819)

Unified Diff: src/pkg/runtime/iface.c

Issue 6337058: code review 6337058: cmd/gc: cache itab lookup in convT2I. (Closed)
Patch Set: diff -r c533f48701cb https://go.googlecode.com/hg/ Created 12 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/cmd/gc/walk.c ('k') | src/pkg/runtime/iface_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/runtime/iface.c
===================================================================
--- a/src/pkg/runtime/iface.c
+++ b/src/pkg/runtime/iface.c
@@ -183,19 +183,25 @@
alg->copy(size, dst, *src);
}
-// func convT2I(typ *byte, typ2 *byte, elem any) (ret any)
+// func convT2I(typ *byte, typ2 *byte, cache **byte, elem any) (ret any)
#pragma textflag 7
void
-runtime·convT2I(Type *t, InterfaceType *inter, ...)
+runtime·convT2I(Type *t, InterfaceType *inter, Itab **cache, ...)
{
byte *elem;
Iface *ret;
+ Itab *tab;
int32 wid;
- elem = (byte*)(&inter+1);
+ elem = (byte*)(&cache+1);
wid = t->size;
ret = (Iface*)(elem + ROUND(wid, Structrnd));
- ret->tab = itab(inter, t, 0);
+ tab = runtime·atomicloadp(cache);
+ if(!tab) {
+ tab = itab(inter, t, 0);
+ runtime·atomicstorep(cache, tab);
+ }
+ ret->tab = tab;
copyin(t, elem, &ret->data);
}
« no previous file with comments | « src/cmd/gc/walk.c ('k') | src/pkg/runtime/iface_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b