]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: generate makemap calls with int arguments
authorMartin Möhrmann <moehrmann@google.com>
Mon, 14 Aug 2017 08:16:21 +0000 (10:16 +0200)
committerMartin Möhrmann <moehrmann@google.com>
Tue, 22 Aug 2017 20:28:21 +0000 (20:28 +0000)
commitcbc4e5d9c4f2444c5d40ae6333b4e1f4c9cfbd41
treeba4c93d8a8fef88cf61720332ab2426fd34c3d3f
parent0fb0f575bcd2dc3e00a370b325e7e6d020f226b8
cmd/compile: generate makemap calls with int arguments

Where possible generate calls to runtime makemap with int hint argument
during compile time instead of makemap with int64 hint argument.

This eliminates converting the hint argument for calls to makemap with
int64 hint argument for platforms where int64 values do not fit into
an argument of type int.

A similar optimization for makeslice was introduced in CL
golang.org/cl/27851.

386:
name         old time/op    new time/op    delta
NewEmptyMap    53.5ns ± 5%    41.9ns ± 5%  -21.56%  (p=0.000 n=10+10)
NewSmallMap     182ns ± 1%     165ns ± 1%   -8.92%  (p=0.000 n=10+10)

Change-Id: Ibd2b4c57b36f171b173bf7a0602b3a59771e6e44
Reviewed-on: https://go-review.googlesource.com/55142
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/builtin.go
src/cmd/compile/internal/gc/builtin/runtime.go
src/cmd/compile/internal/gc/walk.go
src/runtime/hashmap.go
src/runtime/hashmap_fast.go
test/makemap.go [new file with mode: 0644]