CL 14337 made SSA support fixedbugs/issue9604b.go.
That test contains > 40k blocks.
This made the O(n^2) dom algorithm fail to terminate
in a reasonable length of time, breaking the build.
For the moment, cap the number of blocks
to fix the build.
This will be reverted when a more efficient
dom algorithm is put in place,
which will be soon.
Keith Randall [Mon, 24 Aug 2015 09:16:19 +0000 (02:16 -0700)]
[dev.ssa] cmd/runtime: generate gc bitmaps for SSA-compiled code
This change is all about leveraging the gc bitmap generation
that is already done by the current compiler. We rearrange how
stack allocation is done so that we generate a variable declaration
for each spill. We also reorganize how args/locals are recorded
during SSA. Then we can use the existing allocauto/defframe to
allocate the stack frame and liveness to make the gc bitmaps.
With this change, stack copying works correctly and we no longer
need hacks in runtime/stack*.go to make tests work. GC is close
to working, it just needs write barriers.
David Chase [Tue, 1 Sep 2015 21:09:00 +0000 (17:09 -0400)]
[dev.ssa] cmd/compile: cleanup fp conversions in ssa.go
Change to table-driven instead of branchy code; leads to
net reduction in lines, easier to understand what happens,
easier to modify code if we want option to exclude generation
of branchy cases.
Doesn't appear to scale for 8x8 case of integer types.
Change-Id: Ib40104b149d30bb329c5782f6cac45c75743e768
Reviewed-on: https://go-review.googlesource.com/14163 Reviewed-by: Keith Randall <khr@golang.org>
Keith Randall [Thu, 3 Sep 2015 16:09:59 +0000 (09:09 -0700)]
[dev.ssa] cmd/compile/internal/ssa: distinguish exit and return blocks
It is confusing to have exceptional edges jump back into
real code. Distinguish return blocks, which execute acutal
code, and the exit block, which is a merge point for the regular
and exceptional return flow.
Prevent critical edge insertion from adding blocks on edges
into the exit block. These added blocks serve no purpose and
add a bunch of dead jumps to the assembly output. Furthermore,
live variable analysis is confused by these jumps.
Change-Id: Ifd69e6c00e90338ed147e7cb351b5100dc0364df
Reviewed-on: https://go-review.googlesource.com/14254 Reviewed-by: David Chase <drchase@google.com>
Todd Neal [Sat, 29 Aug 2015 20:41:57 +0000 (15:41 -0500)]
[dev.ssa] cmd/compile: fix rare issue caused by liblink rewrite
liblink rewrites MOV $0, reg into XOR reg, reg. Make MOVxconst clobber
flags so we don't generate invalid code in the unlikely case that it
matters. In testing, this change leads to no additional regenerated
flags due to a scheduling fix in CL14042.
Change-Id: I7bc1cfee94ef83beb2f97c31ec6a97e19872fb89
Reviewed-on: https://go-review.googlesource.com/14043 Reviewed-by: Keith Randall <khr@golang.org>
David Chase [Fri, 28 Aug 2015 18:24:10 +0000 (14:24 -0400)]
[dev.ssa] cmd/compile: add complex arithmetic
Still to do:
details, more testing corner cases. (e.g. negative zero)
Includes small cleanups for previous CL.
Note: complex division is currently done in the runtime,
so the division code here is apparently not yet necessary
and also not tested. Seems likely better to open code
division and expose the widening/narrowing to optimization.
Complex64 multiplication and division is done in wide
format to avoid cancellation errors; for division, this
also happens to be compatible with pre-SSA practice
(which uses a single complex128 division function).
It would-be-nice to widen for complex128 multiplication
intermediates as well, but that is trickier to implement
without a handy wider-precision format.
Change-Id: I595a4300f68868fb7641852a54674c6b2b78855e
Reviewed-on: https://go-review.googlesource.com/14028 Reviewed-by: Keith Randall <khr@golang.org>
Keith Randall [Tue, 1 Sep 2015 16:16:58 +0000 (09:16 -0700)]
[dev.ssa] cmd/compile/internal/ssa: allow ops to have a default type
Specifying types in rewrites for all subexpressions gets verbose
quickly. Allow opcodes to specify a default type which is used when
none is supplied explicitly.
Provide default types for a few easy opcodes. There are probably more
we can do, but this is a good start.
Keith Randall [Fri, 28 Aug 2015 23:45:17 +0000 (16:45 -0700)]
[dev.ssa] cmd/compile/internal/ssa: handle dead code a different way
Instead of trying to delete dead code as soon as we find it, just
mark it as dead using a PlainAndDead block kind. The deadcode pass
will do the real removal.
This way is somewhat more efficient because we don't need to mess
with successor and predecessor lists of all the dead blocks.
The old backend doesn't like ideal types,
and we want to reuse its stackmap generation.
OOROR and OANDAND expressions have ideal type.
The old backend didn't care,
because those expressions got rewritten away into
jumps before stackmap generation.
Keith Randall [Tue, 25 Aug 2015 21:02:30 +0000 (14:02 -0700)]
[dev.ssa] cmd/compile/internal/ssa: add more critical edges
Add blocks to remove critical edges, even when it looks like
there's no phi that requires it. Regalloc still likes to have
critical-edge-free graphs for other reasons.
Ulrich Kunitz [Thu, 20 Aug 2015 16:56:18 +0000 (18:56 +0200)]
cmd/compile: fix register allocation for == operator
The issue 12226 has been caused by the allocation of the same register
for the equality check of two byte values. The code in cgen.go freed the
register for the second operand before the allocation of the register
for the first operand.
Keith Randall [Tue, 25 Aug 2015 06:52:03 +0000 (23:52 -0700)]
[dev.ssa] cmd/compile: implement OSLICESTR
Add a new function and generic operation to handle
bounds checking for slices. Unlike the index
bounds checking the index can be equal to the upper
bound.
Do gc-friendly slicing that generates proper code for
0-length result slices.
This is a takeover of Alexandru's original change,
(https://go-review.googlesource.com/#/c/12764/)
submittable now that the decompose phase is in.
Change-Id: I17d164cf42ed7839f84ca949c6ad3289269c9160
Reviewed-on: https://go-review.googlesource.com/13903 Reviewed-by: David Chase <drchase@google.com>
Austin Clements [Mon, 24 Aug 2015 17:35:49 +0000 (13:35 -0400)]
cmd/compile: fix uninitialized memory in compare of interface value
A comparison of the form l == r where l is an interface and r is
concrete performs a type assertion on l to convert it to r's type.
However, the compiler fails to zero the temporary where the result of
the type assertion is written, so if the type is a pointer type and a
stack scan occurs while in the type assertion, it may see an invalid
pointer on the stack.
Fix this by zeroing the temporary. This is equivalent to the fix for
type switches from c4092ac.
Keith Randall [Mon, 24 Aug 2015 04:14:25 +0000 (21:14 -0700)]
[dev.ssa] cmd/compile: make sure to keep offset and sym of MOV opcodes.
MOVXload and MOVXstore opcodes have both an auxint offset
and an aux offset (a symbol name, like a local or arg or global).
Make sure we keep those values during rewrites.
Shenghou Ma [Tue, 25 Aug 2015 01:24:23 +0000 (21:24 -0400)]
runtime: add a missing hex conversion
gobuf.g is a guintptr, so without hex(), it will be printed as
a decimal, which is not very helpful and inconsistent with how
other pointers are printed.
Change-Id: I7c0432e9709e90a5c3b3e22ce799551a6242d017
Reviewed-on: https://go-review.googlesource.com/13879 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Didier Spezia [Sun, 23 Aug 2015 13:59:00 +0000 (13:59 +0000)]
debug/elf: map/slice literals janitoring
Simplify slice/map literal expressions.
Caught with gofmt -d -s, fixed with gofmt -w -s
Reformatted some expressions to improve readability.
Change-Id: Iaf123e6bd49162ec45c59297ad3b002ca59443bc
Reviewed-on: https://go-review.googlesource.com/13850 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Shenghou Ma [Tue, 25 Aug 2015 01:17:04 +0000 (21:17 -0400)]
cmd/go: skip test using external linking on linux/ppc64 too
While we're at it, also fix a typo.
Change-Id: Id436f33cffa5683e2a8450cce5b545960cf2877e
Reviewed-on: https://go-review.googlesource.com/13878 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This aids in making sense of the aggregate set of work outstanding.
Interest in the details of any particular implementation failure
is better handled locally anyway.
In my local tree, running make.bash after this CL yields:
14.85% 1811 SSA unimplemented: unhandled expr SLICEARR
13.84% 1687 SSA unimplemented: unhandled expr CALLINTER
11.84% 1444 SSA unimplemented: unhandled stmt RETJMP
10.24% 1249 SSA unimplemented: unhandled expr EFACE
8.52% 1039 SSA unimplemented: unhandled expr SLICE
4.92% 600 SSA unimplemented: local variable with class PAUTO,heap unimplemented
4.90% 598 SSA unimplemented: unhandled expr SLICESTR
3.91% 477 SSA unimplemented: local variable with class PFUNC unimplemented
3.45% 421 SSA unimplemented: not lowered: IMake INTER PTR64 PTR64
3.42% 417 SSA unimplemented: unhandled expr APPEND
3.21% 391 SSA unimplemented: unhandled expr CLOSUREVAR
3.06% 373 SSA unimplemented: unhandled stmt DEFER
3.04% 371 SSA unimplemented: unhandled stmt AS2DOTTYPE
1.61% 196 SSA unimplemented: unhandled expr DOTTYPE
1.56% 190 SSA unimplemented: not lowered: Load STRUCT PTR64 mem
0.79% 96 SSA unimplemented: not lowered: StringMake STRING PTR64 UINTPTR
0.69% 84 SSA unimplemented: unhandled binary op NE FLOAT64
0.53% 65 SSA unimplemented: unhandled expr STRUCTLIT
0.50% 61 SSA unimplemented: not lowered: SliceMake ARRAY PTR64 UINTPTR UINTPTR
0.45% 55 SSA unimplemented: zero for type float64 not implemented
0.44% 54 SSA unimplemented: unhandled addr CLOSUREVAR
0.38% 46 SSA unimplemented: unhandled binary op EQ FLOAT64
0.35% 43 SSA unimplemented: unhandled binary op LT FLOAT64
0.34% 42 SSA unimplemented: unhandled len(map)
0.33% 40 SSA unimplemented: unhandled stmt FALL
0.23% 28 SSA unimplemented: CONVNOP closure
0.21% 25 SSA unimplemented: local variable with class PPARAM,heap unimplemented
0.21% 25 SSA unimplemented: unhandled binary op GT FLOAT64
0.18% 22 SSA unimplemented: unhandled OCONV FLOAT32 -> FLOAT64
0.18% 22 SSA unimplemented: unhandled expr REAL
0.16% 20 SSA unimplemented: unhandled stmt PROC
0.16% 19 SSA unimplemented: unhandled closure arg
0.15% 18 SSA unimplemented: unhandled OCONV INT64 -> FLOAT64
0.12% 15 SSA unimplemented: unhandled expr CFUNC
0.10% 12 SSA unimplemented: unhandled OCONV UINT64 -> FLOAT64
0.09% 11 SSA unimplemented: unhandled OLITERAL 4
0.09% 11 SSA unimplemented: unhandled expr IMAG
0.07% 9 SSA unimplemented: unhandled binary op GE FLOAT64
0.07% 9 SSA unimplemented: unhandled binary op MINUS FLOAT64
0.06% 7 SSA unimplemented: unhandled OCONV FLOAT64 -> FLOAT32
0.06% 7 SSA unimplemented: unhandled binary op NE FLOAT32
0.06% 7 SSA unimplemented: variable address class 5 not implemented
0.05% 6 SSA unimplemented: not lowered: Load COMPLEX128 PTR64 mem
0.05% 6 SSA unimplemented: unhandled expr SLICE3ARR
0.04% 5 SSA unimplemented: unhandled binary op LE FLOAT64
0.03% 4 SSA unimplemented: unhandled OCONV UINTPTR -> FLOAT64
0.03% 4 SSA unimplemented: unhandled binary op EQ COMPLEX128
0.03% 4 SSA unimplemented: unhandled binary op EQ FLOAT32
0.03% 4 SSA unimplemented: unhandled expr COMPLEX
0.02% 3 SSA unimplemented: local variable with class PPARAMOUT,heap unimplemented
0.02% 3 SSA unimplemented: not lowered: Load ARRAY PTR64 mem
0.02% 3 SSA unimplemented: unhandled OCONV INT32 -> FLOAT64
0.02% 3 SSA unimplemented: unhandled OCONV INT64 -> FLOAT32
0.02% 3 SSA unimplemented: unhandled expr SLICE3
0.02% 2 SSA unimplemented: unhandled OCONV COMPLEX64 -> COMPLEX128
0.02% 2 SSA unimplemented: unhandled OCONV FLOAT64 -> INT64
0.02% 2 SSA unimplemented: unhandled OCONV FLOAT64 -> UINT64
0.02% 2 SSA unimplemented: unhandled OCONV INT -> FLOAT64
0.02% 2 SSA unimplemented: unhandled OCONV UINT64 -> FLOAT32
0.02% 2 SSA unimplemented: unhandled binary op EQ COMPLEX64
0.02% 2 SSA unimplemented: unhandled binary op MINUS FLOAT32
0.02% 2 SSA unimplemented: zero for type complex128 not implemented
0.02% 2 SSA unimplemented: zero for type complex64 not implemented
0.02% 2 SSA unimplemented: zero for type float32 not implemented
0.01% 1 SSA unimplemented: not lowered: EqFat BOOL INTER INTER
0.01% 1 SSA unimplemented: not lowered: Store mem UINTPTR COMPLEX128 mem
0.01% 1 SSA unimplemented: unhandled OCONV UINT32 -> FLOAT64
0.01% 1 SSA unimplemented: unhandled cap(chan)
0.01% 1 SSA unimplemented: unhandled expr ARRAYLIT
0.01% 1 SSA unimplemented: unhandled expr PLUS
0.01% 1 SSA unimplemented: unhandled stmt CHECKNIL
Change-Id: I43474fe6d6ec22a9f57239090136f6e97eebfdf2
Reviewed-on: https://go-review.googlesource.com/13848 Reviewed-by: Keith Randall <khr@golang.org>
[dev.ssa] cmd/compile: support spilling and loading flags
This CL takes a simple approach to spilling and loading flags.
We never spill. When a load is needed, we recalculate,
loading the arguments as needed.
This is simple and architecture-independent.
It is not very efficient, but as of this CL,
there are fewer than 200 flag spills during make.bash.
This was tested by manually reverting CLs 13813 and 13843,
causing SETcc, MOV, and LEA instructions to clobber flags,
which dramatically increases the number of flags spills.
With that done, all stdlib tests that used to pass
still pass.
For future reference, here are some other, more efficient
amd64-only schemes that we could adapt in the future if needed.
(1) Spill exactly the flags needed.
For example, if we know that the flags will be needed
by a SETcc or Jcc op later, we could use SETcc to
extract just the relevant flag. When needed,
we could use TESTB and change the op to JNE/SETNE.
(Alternatively, we could leave the op unaltered
and prepare an appropriate CMPB instruction
to produce the desired flag.)
However, this requires separate handling for every
instruction that uses the flags register,
including (say) SBBQcarrymask.
We could enable this on an ad hoc basis for common cases
and fall back to recalculation for other cases.
(2) Spill all flags with PUSHF and POPF
This modifies SP, which the runtime won't like.
It also requires coordination with stackalloc to
make sure that we have a stack slot ready for use.
(3) Spill almost all flags with LAHF, SETO, and SAHF
See http://blog.freearrow.com/archives/396
for details. This would handle all the flags we currently
use. However, LAHF and SAHF are not universally available
and it requires arranging for AX to be free.
Change-Id: Ie36600fd8e807ef2bee83e2e2ae3685112a7f276
Reviewed-on: https://go-review.googlesource.com/13844 Reviewed-by: Keith Randall <khr@golang.org>
Ingo Oeser [Sat, 9 May 2015 15:55:05 +0000 (17:55 +0200)]
html: speed up UnescapeString
Add benchmarks for for sparsely escaped and densely escaped strings.
Then speed up the sparse unescaping part heavily by using IndexByte and
copy to skip the parts containing no escaping very fast.
Unescaping densely escaped strings slower because of
the new function call overhead. But sparsely encoded strings are seen
more often in the utf8 enabled web.
We win part of the speed back by looking up entityName differently.
Justin Nuß [Sun, 31 May 2015 11:17:59 +0000 (13:17 +0200)]
time: Use AppendFormat in Marshal[Text|JSON]
The current implementations of MarshalJSON and MarshalText use
time.Format which returns a string (converted from a byte slice),
only to convert it back to a byte slice.
Avoid the conversion (and thus an allocation) by directly appending
the formatted time to a preallocated byte slice, using the new
AppendFormat function, introduced in golang.org/cl/1760.
This reduces the allocations done in Marshal[Text|JSON] by 50%.
benchmark old ns/op new ns/op delta
BenchmarkMarshalJSON 626 507 -19.01%
BenchmarkMarshalText 598 511 -14.55%
benchmark old allocs new allocs delta
BenchmarkMarshalJSON 2 1 -50.00%
BenchmarkMarshalText 2 1 -50.00%
benchmark old bytes new bytes delta
BenchmarkMarshalJSON 96 48 -50.00%
BenchmarkMarshalText 96 48 -50.00%
This updates the big package used by the compiler to match the
public big package which contains some updates and bug fixes.
Obtained by running vendor.bash in the internal/big directory.
No manual changes.
Change-Id: I299aecc6599d4a745a721ce48def32449640dbb2
Reviewed-on: https://go-review.googlesource.com/13815 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Robert Griesemer [Fri, 21 Aug 2015 18:30:19 +0000 (11:30 -0700)]
math/big: fix TestBytes test
Fixes #12231.
Change-Id: I1f07c444623cd864667e21b2fee534eacdc193bb
Reviewed-on: https://go-review.googlesource.com/13814 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alberto Donizetti [Fri, 21 Aug 2015 17:17:18 +0000 (19:17 +0200)]
math/big: correctly handle large exponent in SetString
Even though the umul/uquo functions expect two valid, finite big.Floats
arguments, SetString was calling them with possibly Inf values, which
resulted in bogus return values.
Replace umul and udiv calls with Mul and Quo calls to fix this. Also,
fix two wrong tests.
See relevant issue on issue tracker for a detailed explanation.
Fixes #11341
Change-Id: Ie35222763a57a2d712a5f5f7baec75cab8189a53
Reviewed-on: https://go-review.googlesource.com/13778 Reviewed-by: Robert Griesemer <gri@golang.org>