Giving them specific types has the benefit that
binary.BigEndian.Uint32(b) is now a direct call, not an
indirect via a mutable interface value, so it can potentially
be inlined.
Recent changes to the spec relaxed the rules for comparison,
so this code is still valid:
func isLittle(o binary.ByteOrder) { return o == binary.LittleEndian }
The change does break this potential idiom:
o := binary.BigEndian
if foo {
o = binary.LittleEndian
}
That must rewrite to give o an explicit binary.ByteOrder type.
On balance I think the benefit from the direct call and inlining
outweigh the cost of breaking that idiom.
R=r, r2
CC=golang-dev
https://golang.org/cl/2427042
Just enough to make mov instructions work,
which in turn is enough to make strconv work
when it avoids any floating point calculations.
That makes a bunch of other packages pass
their tests.
Should suffice until hardware floating point
is available.
Enable package tests that now pass
(some due to earlier fixes).
Looks like there is a new integer math bug
exposed in the fmt and json tests.
R=ken2
CC=golang-dev
https://golang.org/cl/2638041
The frame that gets allocated is for both
the args and the autos. If together they
exceed the default frame size, we need to
tell morestack about both so that it allocates
a large enough frame.
Sanity check stack pointer in morestack
to catch similar bugs.
R=ken2
CC=golang-dev
https://golang.org/cl/2609041
value (through unsafe means) without having a reflect.Type
of type *interface{} (pointer to interface). This is needed to make
gob able to handle interface values by a method analogous to
the way it handles maps.
R=rsc
CC=golang-dev
https://golang.org/cl/2597041
That is, move the pc/ln table and the symbol table
into the read-only data segment. This eliminates
the need for a special load command to map the
symbol table into memory, which makes the
information available on systems that couldn't handle
the magic load to 0x99000000, like NaCl and ARM QEMU
and Linux without config_highmem=y. It also
eliminates an #ifdef and some clumsy code to
find the symbol table on Windows.
The bad news is that the binary appears to be bigger
than it used to be. This is not actually the case, though:
the same amount of data is being mapped into memory
as before, and the tables are still read-only, so they're
still shared across multiple instances of the binary as
they were before. The difference is just that the tables
aren't squirreled away in some section that "size" doesn't
know to look at.
This is a checkpoint.
It probably breaks Windows and breaks NaCl more
than it used to be broken, but those will be fixed.
The logic involving -s needs to be revisited too.
Fixes#871.
R=ken2
CC=golang-dev
https://golang.org/cl/2587041
No multiple processes/locks, managed to compile
and run a hello.go (with print not fmt). Also test/sieve.go
seems to run until 439 and stops with a
'throw: all goroutines are asleep - deadlock!'
- just like runtime/tiny.
based on Russ's suggestions at:
http://groups.google.com/group/comp.os.plan9/browse_thread/thread/cfda8b82535d2d68/243777a597ec1612
Build instructions:
cd src/pkg/runtime
make clean && GOOS=plan9 make install
this will build and install the runtime.
When linking with 8l, you should pass -s to suppress symbol
generation in the a.out, otherwise the generated executable will not run.
This is runtime only, the porting of the toolchain has already
been done: http://code.google.com/p/go-plan9/source/browse
in the plan9-quanstro branch.
R=rsc
CC=golang-dev
https://golang.org/cl/2273041
Because the SB is only good for 8k and Go programs
tend to have much more data than that, SB doesn't
save very much. A fmt.Printf-based hello world program
has 360 kB text segment. Removing SB makes the text
500 bytes (0.14%) longer.
R=ken2, r2, ken3
CC=golang-dev
https://golang.org/cl/2487042
Also change the span-dependent jump algorithm
to use fewer iterations:
* resolve forward jumps at their targets (comefrom list)
* mark jumps as small or big and only do small->big
* record whether a jump failed to be encodable
These changes mean that a function with only small
jumps can be laid out in a single iteration, and the
vast majority of functions take just two iterations.
I was seeing a maximum of 5 iterations before; the
max now is 3 and there are fewer that get even that far.
R=ken2
CC=golang-dev
https://golang.org/cl/2537041
The old code said
if(x) {
handle a
return
}
aa = *a
rewrite aa to make x true
recursivecall(&aa)
The new code says
params = copy out of a
if(!x) {
rewrite params to make x true
}
handle params
but it's hard to see that in the Rietveld diffs because
it gets confused by changes in indentation.
Avoiding the recursion makes other changes easier.
R=ken2
CC=golang-dev
https://golang.org/cl/2533041
Using explicit relocations internally, we can
represent the data for a particular symbol as
an initialized block of memory instead of a
linked list of ADATA instructions. The real
goal here is to be able to hand off some of the
relocations to the dynamic linker when interacting
with system libraries, but a pleasant side effect is
that the memory image is much more compact
than the ADATA list, so the linkers use less memory.
R=ken2
CC=golang-dev
https://golang.org/cl/2512041
After a fill(), there is nothing to back up. Make sure UnreadRune
recognizes the situation.
Fixes#1137.
(Stops the crash, but doesn't make UnreadRune usable after a Peek()).
R=rsc
CC=golang-dev
https://golang.org/cl/2498041
The Plan 9 tools assume that long is 32 bits.
We converted all instances of long to int32 when
importing the code but missed the print formats.
Because int32 is always int on the compilers we use,
it is never correct to use %lux, %ld, etc. Convert to %ux, %d, etc.
(It matters because on 64-bit gcc, long is 64 bits,
so we were printing 32-bit quantities with 64-bit formats.)
R=ken2
CC=golang-dev
https://golang.org/cl/2491041
* Maintain Sym* list for text with individual
prog lists instead of using one huge list and
overloading p->pcond.
* Comment what each file is for.
* Move some output code from span.c to asm.c.
* Move profiling into prof.c, symbol table into symtab.c.
* Move mkfwd to ld/lib.c.
* Throw away dhog dynamic loading code.
* Throw away Alef become.
* Fix printing of WORD instructions in 5l -a.
Goal here is to be able to handle each piece of text or data
as a separate piece, both to make it easier to load the
occasional .o file and also to make it possible to split the
work across multiple threads.
R=ken2, r, ken3
CC=golang-dev
https://golang.org/cl/2335043
This is entirely adding and removing tabs.
It looks weird but will make the diffs for the
next change easier to read.
R=ken2
CC=golang-dev
https://golang.org/cl/2490041
Use a bytes.Buffer in log writing instead of string concatenation.
Should reduce the number of allocations significantly.
R=rsc, r2
CC=golang-dev
https://golang.org/cl/2417042
6l was skipping emitting the (2 byte) symbol table if there were no imported or exported
symbols. You can't just drop the symbol table entirely - the linker dies if you have
a linkedit section but no table. You can omit the linkedit section or both the linkedit
and the dlyd parts in the right circumstances, but that seems much more risky to me.
R=rsc
CC=golang-dev
https://golang.org/cl/2421042
New logging interface simplifies and generalizes.
1) Loggers now have only one output.
2) log.Stdout, Stderr, Crash and friends are gone.
Logging is now always to standard error by default.
3) log.Panic* replaces log.Crash*.
4) Exiting and panicking are not part of the logger's state; instead
the functions Exit* and Panic* simply call Exit or panic after
printing.
5) There is now one 'standard logger'. Instead of calling Stderr,
use Print etc. There are now triples, by analogy with fmt:
Print, Println, Printf
What was log.Stderr is now best represented by log.Println,
since there are now separate Print and Println functions
(and methods).
6) New functions SetOutput, SetFlags, and SetPrefix allow global
editing of the standard logger's properties. This is new
functionality. For instance, one can call
log.SetFlags(log.Lshortfile|log.Ltime|log.Lmicroseconds)
to get all logging output to show file name, line number, and
time stamp.
In short, for most purposes
log.Stderr -> log.Println or log.Print
log.Stderrf -> log.Printf
log.Crash -> log.Panicln or log.Panic
log.Crashf -> log.Panicf
log.Exit -> log.Exitln or log.Exit
log.Exitf -> log.Exitf (no change)
This has a slight breakage: since loggers now write only to one
output, existing calls to log.New() need to delete the second argument.
Also, custom loggers with exit or panic properties will need to be
reworked.
All package code updated to new interface.
The test has been reworked somewhat.
The old interface will be removed after the new release.
For now, its elements are marked 'deprecated' in their comments.
Fixes#1184.
R=rsc
CC=golang-dev
https://golang.org/cl/2419042
Package iterable has outlived its utility.
It is an interesting demonstration, but it encourages
people to use iteration over channels where simple
iteration over array indices or a linked list would be
cheaper, simpler, and have fewer races.
R=dsymonds, r
CC=golang-dev
https://golang.org/cl/2436041
An exercise in reflection and an unusual tool.
From the usage message:
usage: gotry [packagedirectory] expression ...
Given one expression, gotry attempts to evaluate that expression.
Given multiple expressions, gotry treats them as a list of arguments
and result values and attempts to find a function in the package
that, given the first few expressions as arguments, evaluates to
the remaining expressions as results. If the first expression has
methods, it will also search for applicable methods.
If there are multiple expressions, a package directory must be
specified. If there is a package argument, the expressions are
evaluated in an environment that includes
import . "packagedirectory"
Examples:
gotry 3+4
# evaluates to 7
gotry strings '"abc"' '"c"' 7-5
# finds strings.Index etc.
gotry regexp 'MustCompile("^[0-9]+")' '"12345"' true
# finds Regexp.MatchString
R=rsc, PeterGo, r2
CC=golang-dev
https://golang.org/cl/2352043
Permits one to easily put a timeout in a select:
select {
case <-ch:
// foo
case <-time.After(1e6):
// bar
}
R=r, rog, rsc, sameer1, PeterGo, iant, nigeltao_gnome
CC=golang-dev
https://golang.org/cl/2321043
Auto-detect both if not set, and if GOARCH is not set use GOHOSTARCH.
GOHOSTARCH is used to set the -m32 or -m64 flags for gcc.
This is so that 64-bit can build binaries that run on 32-bit systems.
R=rsc, iant, brainman
CC=golang-dev
https://golang.org/cl/2342045
was
x.go:7: must call (&b).*Buffer·Write
now
x.go:7: method b.Write is not an expression, must be called
Fixes#1171.
R=ken2
CC=golang-dev
https://golang.org/cl/2384042
was
x.go:4: invalid operation: 1 <- "foo" (send to receive-only type int)
now
x.go:4: invalid operation: 1 <- "foo" (send to non-chan type int)
R=ken2
CC=golang-dev
https://golang.org/cl/2330042
On Linux, overwriting an mmap'ed file causes
all the MAP_PRIVATE pages to get refreshed
with the new content, even ones that have been
modified by the process that did the mmap.
One specific instance of this is that after the
dynamic linker has relocated a page from a .so,
overwriting the .so will un-relocate it, making
the next use of one of the no-longer-relocated
addresses incorrect and probably crash the
program.
Linux must go out of its way to break programs
in this way: the pages have already been copied
on write, so they're not shared with the file system
cache, and it trashes them anyway. The manual
says the behavior when the file gets overwritten
is "undefined". Removing before copy avoids the
undefined behavior.
R=iant
CC=golang-dev, msolo
https://golang.org/cl/2333045
This crops up in a lot of places.
It's just a one-liner, but doesn't add any dependancies.
Seems worth it.
R=r, r2
CC=golang-dev
https://golang.org/cl/2344041
On systems where the mmap succeeds
(e.g., sysctl -w vm.mmap_min_addr=0)
it changes the signal code delivered for a
nil fault from ``page not mapped'' to
``invalid permissions for page.''
TBR=r
CC=golang-dev
https://golang.org/cl/2294041
Was also recording for .dynstrtab which made the
table run out of space and would have caused confusion
if the ELF code tried to refer to any of the strings.
R=r
CC=golang-dev
https://golang.org/cl/2288041
There are a variety of token pairs that if printed
without separating blank may combine into a different
token sequence. Most of these (except for INT + .)
don't happen at the moment due to the spacing
introduced between expression operands. However, this
will prevent errors should the expression spacing
change.
R=rsc
CC=golang-dev
https://golang.org/cl/2207044
Not all OS make that the default.
Can finally do this now that the syscall package
has the right definitions.
Fixes#679.
R=r
CC=golang-dev
https://golang.org/cl/2204048
THIS WILL BREAK THE BUILD.
The z files have socketpair code in them that was
written by hand; breaking the build with this is the first
step in getting rid of that hand-written code.
R=adg
TBR=adg
CC=golang-dev
https://golang.org/cl/2197050
work on FreeBSD even without /usr/src/sys.
work on systems where gcc -static is broken.
TBR so I can test my semi-automated z builder.
TBR=adg
CC=golang-dev
https://golang.org/cl/2215046
Replace Marshal with MarshalToMemory
(no one was using old Marshal anyway).
Swap arguments to Unmarshal.
Fixes#1133.
R=agl1
CC=golang-dev
https://golang.org/cl/2249045