summaryrefslogtreecommitdiff
path: root/src/reflect
Commit message (Collapse)AuthorAgeFilesLines
* all: power64 is now ppc64Russ Cox2014-12-051-1/+1
| | | | | | | | | Fixes issue 8654. LGTM=austin R=austin CC=golang-codereviews https://codereview.appspot.com/180600043
* [dev.cc] all: merge default (8d42099cdc23) into dev.ccdev.ccRuss Cox2014-12-053-2/+122
|\ | | | | | | | | | | TBR=austin CC=golang-codereviews https://codereview.appspot.com/178700044
| * reflect: Fix reflect.funcLayout. The GC bitmap has two bits perKeith Randall2014-12-013-2/+122
| | | | | | | | | | | | | | | | | | | | | | pointer, not one. Fixes issue 9179 LGTM=iant, rsc R=golang-codereviews, iant, rsc CC=golang-codereviews https://codereview.appspot.com/182160043
* | [dev.cc] all: merge dev.power64 (7667e41f3ced) into dev.ccRuss Cox2014-11-141-9/+4
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is to reduce the delta between dev.cc and dev.garbage to just garbage collector changes. These are the files that had merge conflicts and have been edited by hand: malloc.go mem_linux.go mgc.go os1_linux.go proc1.go panic1.go runtime1.go LGTM=austin R=austin CC=golang-codereviews https://codereview.appspot.com/174180043
| * | [dev.cc] reflect: interfaces contain only pointersRuss Cox2014-11-111-9/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | | | [This CL is part of the removal of C code from package runtime. See golang.org/s/dev.cc for an overview.] Adjustments for changes made in CL 169360043. This change is already present in the dev.garbage branch. LGTM=r R=r CC=austin, golang-codereviews, iant, khr https://codereview.appspot.com/167520044
* | [dev.power64] reflect: fix asm on power64xAustin Clements2014-10-311-2/+5
| | | | | | | | | | | | | | | | | | | | | | reflect/asm_power64x.s was missing changes made to other platforms for stack maps. This CL ports those changes. With this fix, the reflect test passes on power64x. LGTM=rsc R=rsc, dave CC=golang-codereviews https://codereview.appspot.com/170870043
* | [dev.power64] all: merge default into dev.power64Austin Clements2014-10-222-0/+34
|\ \ | |/ |/| | | | | | | | | | | | | | | | | This brings dev.power64 up-to-date with the current tip of default. go_bootstrap is still panicking with a bad defer when initializing the runtime (even on amd64). LGTM=rsc R=rsc CC=golang-codereviews https://codereview.appspot.com/152570049
| * build: merge the great pkg/ rename into dev.power64Austin Clements2014-10-223-1/+35
| | | | | | | | | | | | | | | | | | This also removes pkg/runtime/traceback_lr.c, which was ported to Go in an earlier commit and then moved to runtime/traceback.go. Reviewer: rsc@golang.org rsc: LGTM
* | reflect: fix TestAllocations now that interfaces hold only pointersIan Lance Taylor2014-10-201-3/+14
| | | | | | | | | | | | | | | | | | | | This test was failing but did not break the build because it was not run when -test.short was used. LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://codereview.appspot.com/157150043
* | reflect: allocate correct type in assignTo and cvtT2IIan Lance Taylor2014-10-201-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I came across this while debugging a GC problem in gccgo. There is code in assignTo and cvtT2I that handles assignment to all interface values. It allocates an empty interface even if the real type is a non-empty interface. The fields are then set for a non-empty interface, but the memory is recorded as holding an empty interface. This means that the GC has incorrect information. This is extremely unlikely to fail, because the code in the GC that handles empty interfaces looks like this: obj = nil; typ = eface->type; if(typ != nil) { if(!(typ->kind&KindDirectIface) || !(typ->kind&KindNoPointers)) obj = eface->data; In the current runtime the condition is always true--if KindDirectIface is set, then KindNoPointers is clear--and we always want to set obj = eface->data. So the question is what happens when we incorrectly store a non-empty interface value in memory marked as an empty interface. In that case eface->type will not be a *rtype as we expect, but will instead be a pointer to an Itab. We are going to use this pointer to look at a *rtype kind field. The *rtype struct starts out like this: type rtype struct { size uintptr hash uint32 // hash of type; avoids computation in hash tables _ uint8 // unused/padding align uint8 // alignment of variable with this type fieldAlign uint8 // alignment of struct field with this type kind uint8 // enumeration for C An Itab always has at least two pointers, so on a little-endian 64-bit system the kind field will be the high byte of the second pointer. This will normally be zero, so the test of typ->kind will succeed, which is what we want. On a 32-bit system it might be possible to construct a failing case by somehow getting the Itab for an interface with one method to be immediately followed by a word that is all ones. The effect would be that the test would sometimes fail and the GC would not mark obj, leading to an invalid dangling pointer. I have not tried to construct this test. I noticed this in gccgo, where this error is much more likely to cause trouble for a rather random reason: gccgo uses a different layout of rtype, and in gccgo the kind field happens to be the low byte of a pointer, not the high byte. LGTM=rsc R=rsc CC=golang-codereviews https://codereview.appspot.com/155450044
* | reflect: a few microoptimizationsRuss Cox2014-10-173-122/+91
| | | | | | | | | | | | | | | | | | | | | | Replace i < 0 || i >= x with uint(i) >= uint(x). Shorten a few other code sequences. Move the kind bits to the bottom of the flag word, to avoid shifts. LGTM=r R=r, bradfitz CC=golang-codereviews https://codereview.appspot.com/159020043
* | reflect: fix struct size calculation to include terminal paddingDamien Neil2014-10-162-0/+21
| | | | | | | | | | | | | | | | | | LGTM=r R=r CC=golang-codereviews https://codereview.appspot.com/160920045 Committer: Rob Pike <r@golang.org>
* | reflect: shorten value to 3 wordsRuss Cox2014-10-153-290/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | scalar is no longer needed, now that interfaces always hold pointers. Comparing best of 5 with TurboBoost turned off, on a 2012 Retina MacBook Pro Core i5. Still not completely confident in these numbers, but the gob and template improvements seem real. benchmark old ns/op new ns/op delta BenchmarkBinaryTree17 3819892491 3803008185 -0.44% BenchmarkFannkuch11 3623876405 3611776426 -0.33% BenchmarkFmtFprintfEmpty 119 118 -0.84% BenchmarkFmtFprintfString 294 292 -0.68% BenchmarkFmtFprintfInt 310 304 -1.94% BenchmarkFmtFprintfIntInt 513 507 -1.17% BenchmarkFmtFprintfPrefixedInt 427 426 -0.23% BenchmarkFmtFprintfFloat 562 554 -1.42% BenchmarkFmtManyArgs 1873 1832 -2.19% BenchmarkGobDecode 15824504 14746565 -6.81% BenchmarkGobEncode 14347378 14208743 -0.97% BenchmarkGzip 537229271 537973492 +0.14% BenchmarkGunzip 134996775 135406149 +0.30% BenchmarkHTTPClientServer 119065 116937 -1.79% BenchmarkJSONEncode 29134359 28928099 -0.71% BenchmarkJSONDecode 106867289 105770161 -1.03% BenchmarkMandelbrot200 5798475 5791433 -0.12% BenchmarkGoParse 5299169 5379201 +1.51% BenchmarkRegexpMatchEasy0_32 195 195 +0.00% BenchmarkRegexpMatchEasy0_1K 477 477 +0.00% BenchmarkRegexpMatchEasy1_32 170 170 +0.00% BenchmarkRegexpMatchEasy1_1K 1412 1397 -1.06% BenchmarkRegexpMatchMedium_32 336 337 +0.30% BenchmarkRegexpMatchMedium_1K 109025 108977 -0.04% BenchmarkRegexpMatchHard_32 5854 5856 +0.03% BenchmarkRegexpMatchHard_1K 184914 184748 -0.09% BenchmarkRevcomp 829233526 836598734 +0.89% BenchmarkTemplate 142055312 137016166 -3.55% BenchmarkTimeParse 598 597 -0.17% BenchmarkTimeFormat 564 568 +0.71% Fixes issue 7425. LGTM=r R=golang-codereviews, r CC=golang-codereviews, iant, khr https://codereview.appspot.com/158890043
* | reflect: add fast path for FieldByIndex with len(index) = 1Russ Cox2014-10-151-0/+3
| | | | | | | | | | | | | | LGTM=r R=r CC=golang-codereviews https://codereview.appspot.com/152640043
* | reflect: generated unrolled GC bitmask directlyIan Lance Taylor2014-10-132-19/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code for a generated type is already generating an unrolled GC bitmask. Rather than unrolling the the source type bitmasks and copying them, just generate the required bitmask directly. Don't mark it as an unrolled GC program, since there is no need to do so. Fixes issue 8917. LGTM=rsc R=dvyukov, rsc CC=golang-codereviews https://codereview.appspot.com/156930044
* | reflect: add direct call tests to TestMakeFuncVariadicMichael Hudson-Doyle2014-10-081-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | TestMakeFuncVariadic only called the variadic function via Call and CallSlice, not via a direct function call. I thought these tests would fail under gccgo tip, but they don't. Still seems worth having though. LGTM=iant R=golang-codereviews, gobot, iant CC=golang-codereviews https://codereview.appspot.com/152060043 Committer: Ian Lance Taylor <iant@golang.org>
* | reflect: add tests for variadic method callsIan Lance Taylor2014-10-081-5/+49
| | | | | | | | | | | | | | | | | | | | | | | | These tests fail when using gccgo. In gccgo using Interface on the value of a method function is implemented using a variant of MakeFunc. That approach did not correctly handle variadic functions. LGTM=r R=golang-codereviews, r CC=golang-codereviews https://codereview.appspot.com/151280043
* | runtime: remove type-punning for Type.gc[0], gc[1]Russ Cox2014-10-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Depending on flags&KindGCProg, gc[0] and gc[1] are either pointers or inlined bitmap bits. That's not compatible with a precise garbage collector: it needs to be always pointers or never pointers. Change the inlined bitmap case to store a pointer to an out-of-line bitmap in gc[0]. The out-of-line bitmaps are dedup'ed, so that for example all pointer types share the same out-of-line bitmap. Fixes issue 8864. LGTM=r R=golang-codereviews, dvyukov, r CC=golang-codereviews, iant, khr, rlh https://codereview.appspot.com/155820043
* | reflect: fix IsValid vs Kind mismatch after Elem of nil interfaceRuss Cox2014-10-012-1/+17
| | | | | | | | | | | | | | LGTM=r R=r CC=golang-codereviews https://codereview.appspot.com/151960044
* | reflect: adjust Value.String to give correct answer for methodsRuss Cox2014-09-182-1/+17
| | | | | | | | | | | | | | | | | | Fixes issue 7859. LGTM=r R=adonovan, r CC=golang-codereviews https://codereview.appspot.com/136710043
* | reflect: add Type.ComparableRuss Cox2014-09-162-1/+55
| | | | | | | | | | | | | | | | | | | | | | | | Like most of the Type methods, the definition of Comparable is what the Go spec says it is. Fixes issue 7911. LGTM=gri R=gri, r CC=golang-codereviews https://codereview.appspot.com/144020043
* | runtime: look up arg stackmap for makeFuncStub/methodValueStub during tracebackRuss Cox2014-09-128-41/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | makeFuncStub and methodValueStub are used by reflect as generic function implementations. Each call might have different arguments. Extract those arguments from the closure data instead of assuming it is the same each time. Because the argument map is now being extracted from the function itself, we don't need the special cases in reflect.Call anymore, so delete those. Fixes an occasional crash seen when stack copying does not update makeFuncStub's arguments correctly. Will also help make it safe to require stack maps in the garbage collector. Derived from CL 142000044 by khr. LGTM=khr R=khr CC=golang-codereviews https://codereview.appspot.com/143890044
* | reflect: use runtime's memmove instead of its ownKeith Randall2014-09-101-26/+3
|/ | | | | | | | | | They will both need write barriers at some point. But until then, no reason why we shouldn't share. LGTM=rsc R=golang-codereviews, rsc CC=golang-codereviews https://codereview.appspot.com/141330043
* build: move package sources from src/pkg to srcRuss Cox2014-09-0813-0/+9168
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.