aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/slice.c
AgeCommit message (Collapse)Author
2014-07-31runtime: move built-in print routines to go.Keith Randall
Fixes #8297 LGTM=bradfitz R=golang-codereviews, bradfitz, khr, dave, dvyukov CC=golang-codereviews https://golang.org/cl/119240043
2014-07-31runtime: convert slice operations to Go.Keith Randall
LGTM=bradfitz, dvyukov R=golang-codereviews, bradfitz, dvyukov CC=golang-codereviews https://golang.org/cl/120190044
2014-02-20runtime: use goc2c as much as possibleRuss Cox
Package runtime's C functions written to be called from Go started out written in C using carefully constructed argument lists and the FLUSH macro to write a result back to memory. For some functions, the appropriate parameter list ended up being architecture-dependent due to differences in alignment, so we added 'goc2c', which takes a .goc file containing Go func declarations but C bodies, rewrites the Go func declaration to equivalent C declarations for the target architecture, adds the needed FLUSH statements, and writes out an equivalent C file. That C file is compiled as part of package runtime. Native Client's x86-64 support introduces the most complex alignment rules yet, breaking many functions that could until now be portably written in C. Using goc2c for those avoids the breakage. Separately, Keith's work on emitting stack information from the C compiler would require the hand-written functions to add #pragmas specifying how many arguments are result parameters. Using goc2c for those avoids maintaining #pragmas. For both reasons, use goc2c for as many Go-called C functions as possible. This CL is a replay of the bulk of CL 15400047 and CL 15790043, both of which were reviewed as part of the NaCl port and are checked in to the NaCl branch. This CL is part of bringing the NaCl code into the main tree. No new code here, just reformatting and occasional movement into .h files. LGTM=r R=dave, alex.brainman, r CC=golang-codereviews https://golang.org/cl/65220044
2014-01-27runtime: smarter slice growDmitriy Vyukov
When growing slice take into account size of the allocated memory block. Also apply the same optimization to string->[]byte conversion. Fixes #6307. benchmark old ns/op new ns/op delta BenchmarkAppendGrowByte 4541036 4434108 -2.35% BenchmarkAppendGrowString 59885673 44813604 -25.17% LGTM=khr R=khr CC=golang-codereviews, iant, rsc https://golang.org/cl/53340044
2013-09-16cmd/gc, runtime: inline append in frontend.Rémy Oudompheng
A new transformation during walk turns append calls into a combination of growslice and memmove. benchmark old ns/op new ns/op delta BenchmarkAppend 141 141 +0.00% BenchmarkAppend1Byte 18 11 -39.56% BenchmarkAppend4Bytes 19 10 -42.63% BenchmarkAppend7Bytes 18 10 -42.16% BenchmarkAppend8Bytes 18 10 -40.44% BenchmarkAppend15Bytes 19 11 -41.67% BenchmarkAppend16Bytes 19 11 -41.97% BenchmarkAppend32Bytes 23 14 -38.82% BenchmarkAppendStr1Byte 14 10 -23.78% BenchmarkAppendStr4Bytes 14 11 -21.13% BenchmarkAppendStr8Bytes 14 10 -25.17% BenchmarkAppendStr16Bytes 19 11 -41.45% BenchmarkAppendStr32Bytes 18 14 -19.44% BenchmarkAppendSpecialCase 62 63 +1.77% R=golang-dev, khr, cshapiro, rsc, dave CC=golang-dev https://golang.org/cl/12815046
2013-08-12runtime: change textflags from numbers to symbolsKeith Randall
R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/12798043
2013-08-06runtime: tune append crossover on amd64 and 386Dave Cheney
Fixes #4963. Sets the append crossover to 0 on intel platforms. Results for linux/amd64 Core i5 SNB benchmark old ns/op new ns/op delta BenchmarkAppend 102 104 +1.96% BenchmarkAppend1Byte 10 11 +0.92% BenchmarkAppend4Bytes 15 11 -28.10% BenchmarkAppend7Bytes 17 12 -32.58% BenchmarkAppend8Bytes 18 12 -36.17% BenchmarkAppend15Bytes 24 11 -55.02% BenchmarkAppend16Bytes 25 11 -56.03% BenchmarkAppend32Bytes 11 12 +4.31% BenchmarkAppendStr1Byte 8 9 +13.99% BenchmarkAppendStr4Bytes 11 9 -17.52% BenchmarkAppendStr8Bytes 14 9 -35.70% BenchmarkAppendStr16Bytes 21 9 -55.19% BenchmarkAppendStr32Bytes 10 10 -5.66% BenchmarkAppendSpecialCase 49 52 +7.96% Results for linux/386 Atom(TM) CPU 330 @ 1.60GHz benchmark old ns/op new ns/op delta BenchmarkAppend 219 218 -0.46% BenchmarkAppend1Byte 75 72 -3.44% BenchmarkAppend4Bytes 92 73 -19.87% BenchmarkAppend7Bytes 108 74 -31.20% BenchmarkAppend8Bytes 116 74 -35.95% BenchmarkAppend15Bytes 162 77 -52.22% BenchmarkAppend16Bytes 169 77 -54.20% BenchmarkAppend32Bytes 88 86 -2.38% BenchmarkAppendStr1Byte 57 59 +3.32% BenchmarkAppendStr4Bytes 72 59 -17.40% BenchmarkAppendStr8Bytes 92 60 -34.70% BenchmarkAppendStr16Bytes 141 63 -54.89% BenchmarkAppendStr32Bytes 75 73 -2.64% BenchmarkAppendSpecialCase 270 270 +0.00% R=golang-dev, r CC=golang-dev https://golang.org/cl/12440044
2013-06-13runtime/race: remove now unused step parameter from range access functionsDmitriy Vyukov
R=golang-dev, dave CC=golang-dev https://golang.org/cl/10259043
2013-05-27runtime: introduce cnewarray() to simplify allocation of typed arraysDmitriy Vyukov
R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/9648044
2013-05-15runtime: use enums instead static vars for debuggingDmitriy Vyukov
Compiler can detect and delete dead code with enums, but can not with static vars. R=golang-dev, dave, r CC=golang-dev https://golang.org/cl/9377043
2013-03-01runtime: special-case append([]byte, string) for small stringsRob Pike
Also make the crossover point an architecture-dependent constant, although it's the same everywhere for now. BenchmarkAppendStr1Byte 416 145 -65.14% BenchmarkAppendStr4Bytes 743 217 -70.79% BenchmarkAppendStr8Bytes 421 270 -35.87% BenchmarkAppendStr16Bytes 415 403 -2.89% BenchmarkAppendStr32Bytes 415 391 -5.78% R=golang-dev, iant CC=golang-dev https://golang.org/cl/7459044
2013-03-01runtime: special-case small byte appends.Rob Pike
Update #3679. BenchmarkAppend1Byte 484 199 -58.88% BenchmarkAppend4Bytes 829 286 -65.50% BenchmarkAppend8Bytes 484 365 -24.59% BenchmarkAppend16Bytes 484 498 +2.89% BenchmarkAppend32Bytes 486 484 -0.41% R=iant, dave, rsc CC=golang-dev https://golang.org/cl/7443047
2013-02-03cmd/gc: implement latest rules for checking make sizesRuss Cox
Fixes #4085. R=ken2 CC=golang-dev https://golang.org/cl/7277047
2013-01-30runtime: implement range access functions in race detector.Rémy Oudompheng
Range access functions are already available in TSan library but were not yet used. Time for go test -race -short: Before: compress/flate 24.244s exp/norm >200s go/printer 78.268s After: compress/flate 17.760s exp/norm 5.537s go/printer 5.738s Fixes #4250. R=dvyukov, golang-dev, fullung CC=golang-dev https://golang.org/cl/7229044
2012-11-30runtime: better stack traces in race reportsDmitriy Vyukov
When a race happens inside of runtime (chan, slice, etc), currently reports contain only user file:line. If the line contains a complex expression, it's difficult to figure out where the race exactly. This change adds one more top frame with exact runtime function (e.g. runtime.chansend, runtime.mapaccess). R=golang-dev CC=golang-dev https://golang.org/cl/6851125
2012-11-08runtime: fix instrumentation of slice append for race detectionDmitriy Vyukov
R=golang-dev, iant CC=golang-dev https://golang.org/cl/6819107
2012-10-21runtime: store types of allocated objectsJan Ziak
R=rsc CC=golang-dev https://golang.org/cl/6569057
2012-10-07race: runtime changesDmitriy Vyukov
This is a part of a bigger change that adds data race detection feature: https://golang.org/cl/6456044 R=rsc CC=gobot, golang-dev https://golang.org/cl/6535050
2012-10-06runtime: fix a panic when growing zero-width-element slices.Rémy Oudompheng
Fixes #4197. R=golang-dev, r CC=golang-dev https://golang.org/cl/6611056
2012-09-24runtime: prepare for 64-bit intsRuss Cox
This CL makes the runtime understand that the type of the len or cap of a map, slice, or string is 'int', not 'int32', and it is also careful to distinguish between function arguments and results of type 'int' vs type 'int32'. In the runtime, the new typedefs 'intgo' and 'uintgo' refer to Go int and uint. The C types int and uint continue to be unavailable (cause intentional compile errors). This CL does not change the meaning of int, but it should make the eventual change of the meaning of int on amd64 a bit smoother. Update #2188. R=iant, r, dave, remyoudompheng CC=golang-dev https://golang.org/cl/6551067
2012-06-06runtime: move type kinds into a separate fileJan Ziak
R=rsc CC=golang-dev https://golang.org/cl/6285047
2012-06-02cmd/gc: inline slice[arr,str] in the frontend (mostly).Luuk van Dijk
R=rsc, ality, rogpeppe, minux.ma, dave CC=golang-dev https://golang.org/cl/5966075
2011-12-16runtime: make more build-friendlyRuss Cox
Collapse the arch,os-specific directories into the main directory by renaming xxx/foo.c to foo_xxx.c, and so on. There are no substantial edits here, except to the Makefile. The assumption is that the Go tool will #define GOOS_darwin and GOARCH_amd64 and will make any file named something like signals_darwin.h available as signals_GOOS.h during the build. This replaces what used to be done with -I$(GOOS). There is still work to be done to make runtime build with standard tools, but this is a big step. After this we will have to write a script to generate all the generated files so they can be checked in (instead of generated during the build). R=r, iant, r, lucio.dere CC=golang-dev https://golang.org/cl/5490053
2011-12-05runtime: prep for type-specific algorithmsRuss Cox
Equality on structs will require arbitrary code for type equality, so change algorithm in type data from uint8 to table pointer. In the process, trim top-level map structure from 104/80 bytes (64-bit/32-bit) to 24/12. Equality on structs will require being able to call code generated by the Go compiler, and C code has no way to access Go return values, so change the hash and equal algorithm functions to take a pointer to a result instead of returning the result. R=ken CC=golang-dev https://golang.org/cl/5453043
2011-11-15runtime: avoid allocation for make([]T, 0)Russ Cox
R=gri, iant, iant CC=golang-dev https://golang.org/cl/5375093
2011-10-12runtime: append([]byte, string...)Luuk van Dijk
Fixes #2274 R=rsc, gri, dsymonds, bradfitz, lvd CC=golang-dev https://golang.org/cl/5149045
2011-10-06runtime: faster finalizersDmitriy Vyukov
Linux/amd64, 2 x Intel Xeon E5620, 8 HT cores, 2.40GHz benchmark old ns/op new ns/op delta BenchmarkFinalizer 420.00 261.00 -37.86% BenchmarkFinalizer-2 985.00 201.00 -79.59% BenchmarkFinalizer-4 1077.00 244.00 -77.34% BenchmarkFinalizer-8 1155.00 180.00 -84.42% BenchmarkFinalizer-16 1182.00 184.00 -84.43% BenchmarkFinalizerRun 2128.00 1378.00 -35.24% BenchmarkFinalizerRun-2 1655.00 1418.00 -14.32% BenchmarkFinalizerRun-4 1634.00 1522.00 -6.85% BenchmarkFinalizerRun-8 2213.00 1581.00 -28.56% BenchmarkFinalizerRun-16 2424.00 1599.00 -34.03% Darwin/amd64, Intel L9600, 2 cores, 2.13GHz benchmark old ns/op new ns/op delta BenchmarkChanCreation 1451.00 926.00 -36.18% BenchmarkChanCreation-2 3124.00 1412.00 -54.80% BenchmarkChanCreation-4 6121.00 2628.00 -57.07% BenchmarkFinalizer 684.00 420.00 -38.60% BenchmarkFinalizer-2 11195.00 398.00 -96.44% BenchmarkFinalizer-4 15862.00 654.00 -95.88% BenchmarkFinalizerRun 2025.00 1397.00 -31.01% BenchmarkFinalizerRun-2 3920.00 1447.00 -63.09% BenchmarkFinalizerRun-4 9471.00 1545.00 -83.69% R=golang-dev, cw, rsc CC=golang-dev https://golang.org/cl/4963057
2011-07-27gc: zero-width struct, zero-length array fixesRuss Cox
Fixes #1774. Fixes #2095. Fixes #2097. R=ken2 CC=golang-dev https://golang.org/cl/4826046
2011-05-14gc: generalize dst = append(src,...) inlining to arbitrary src and dst ↵Luuk van Dijk
arguments. R=rsc CC=golang-dev https://golang.org/cl/4517057
2011-05-11gc: inline append when len<capLuuk van Dijk
issue 1604 R=rsc, bradfitz CC=golang-dev https://golang.org/cl/4313062
2011-02-02runtime: faster allocator, garbage collectorRuss Cox
GC is still single-threaded. Multiple threads will happen in another CL. Garbage collection pauses are typically about half as long as they were before this CL. R=brainman, iant, r CC=golang-dev https://golang.org/cl/3975046
2010-11-04runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almostRuss Cox
Prefix all external symbols in runtime by runtime·, to avoid conflicts with possible symbols of the same name in linked-in C libraries. The obvious conflicts are printf, malloc, and free, but hide everything to avoid future pain. The symbols left alone are: ** known to cgo ** _cgo_free _cgo_malloc libcgo_thread_start initcgo ncgocall ** known to linker ** _rt0_$GOARCH _rt0_$GOARCH_$GOOS text etext data end pclntab epclntab symtab esymtab ** known to C compiler ** _divv _modv _div64by32 etc (arch specific) Tested on darwin/386, darwin/amd64, linux/386, linux/amd64. Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386. R=r, PeterGo CC=golang-dev https://golang.org/cl/2899041
2010-10-27gc: implement appendRuss Cox
R=ken2 CC=golang-dev https://golang.org/cl/2757042
2010-10-26gc, runtime: copy([]byte, string)Russ Cox
R=ken2 CC=golang-dev https://golang.org/cl/2741041
2010-08-03gc: index bounds tests and fixesRuss Cox
move constant index checking to front end x[2:1] is a compile-time error now too R=ken2 CC=golang-dev https://golang.org/cl/1848056
2010-05-03runtime, strconv: tiny cleanupsRuss Cox
R=r CC=golang-dev https://golang.org/cl/1081042
2010-05-01gc: be pickier about slice, chan, array, and map sizesRuss Cox
Fixes #589. R=ken2 CC=golang-dev https://golang.org/cl/1032044
2010-04-09runtime: delete malx, skip_depth argument to mallocRuss Cox
remove internal functions from traces in gopprof instead. R=r CC=golang-dev https://golang.org/cl/855046
2010-04-01runtime: turn run time errors checks into panicsRuss Cox
R=ken2, r CC=golang-dev https://golang.org/cl/871042
2010-03-23runtime: add memory profiling, disabled.Russ Cox
no way to get the data out yet. add prototype for runtime.Callers, missing from last CL. R=r CC=golang-dev https://golang.org/cl/713041
2010-02-10runtime: garbage collection + malloc performanceRuss Cox
* add bit tracking finalizer status, avoiding getfinalizer lookup * add ability to allocate uncleared memory R=iant CC=golang-dev https://golang.org/cl/207044
2010-01-25in C and asm, replace pkg·name with ·nameRuss Cox
(eliminate assumption of package global name space, make code easier to move between packages). R=r CC=golang-dev https://golang.org/cl/194072
2009-12-07runtime: introduce unsafe.New and unsafe.NewArrayRuss Cox
to provide functionality previously hacked in to reflect and gob. R=r https://golang.org/cl/165076
2009-12-07pick off special one-byte case in copy. worth 2x in benchmarks (38ns->16ns).Rob Pike
the one-item case could be generalized easily with no cost. worth considering. R=rsc CC=golang-dev, cw https://golang.org/cl/167044
2009-12-06runtime: disable pointer scan optimizationRuss Cox
* broken by reflect, gob TBR=r https://golang.org/cl/166077
2009-12-04gc/runtime: pass type structure to makeslice.Russ Cox
* inform garbage collector about memory with no pointers in it 1.9s gcc reverse-complement.c reverse-complement.go 4.5s / 3.5s original, with/without bounds checks 3.5s / 3.3s bounds check reduction 3.3s / 2.8s smarter garbage collector 2.6s / 2.3s assembler bytes.IndexByte 2.5s / 2.1s even smarter garbage collector (this CL) R=r https://golang.org/cl/165064
2009-11-20x[lo:] - gc and runtime.Russ Cox
* add runtime sliceslice1 for x[lo:] * remove runtime arraytoslice, rewriting &arr into arr[0:len(arr)]. * port cgen_inline into 8g, 5g. * use native memmove in maps R=ken2 https://golang.org/cl/157106
2009-11-17bug in copyKen Thompson
R=rsc https://golang.org/cl/156056
2009-11-17install copy predefinedKen Thompson
did not test 386, but should work shouldnt matter if copy is not used R=rsc https://golang.org/cl/156055
2009-10-20bug162, over and overRuss Cox
R=ken OCL=35919 CL=35919