2015: add Keeping up with the Gophers talk This talk was given at the GoSF meetup at segment.io on July 15th. Change-Id: I3f4e87d5da6755141b3379ce299f326c7b553c60 Reviewed-on: https://go-review.googlesource.com/12370 Reviewed-by: Andrew Gerrand <adg@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/2015/keeping-up.slide b/2015/keeping-up.slide new file mode 100644 index 0000000..26f0408 --- /dev/null +++ b/2015/keeping-up.slide
@@ -0,0 +1,104 @@ +Keeping up with the Gophers +A brief history of gccgo, improvements, and the future + +Chris Manghane +Google Gopher | Compilers and Toolchains +cmang@golang.org + +* gccgo: "The Other Go Compiler" + +- Written and maintained by Ian Lance Taylor (released November 2009) + + 2010-01-26 Ian Lance Taylor <iant@google.com> + + * MAINTAINERS: Add myself as Go frontend maintainer. + +- Compiler frontend for the Go language written in C++ + +.image keeping-up/gccgo_structure.png 320 _ + +* gccgo: The Go Team didn't know + +"Ian just showed up at our door with a fully working compiler" ~ probably Rob + +.html keeping-up/gource_explosion.html + +* Why write a Go compiler in C++? + +* rationale: architecture support + +- cmd/gc (2009) targets 4 major architectures: i386, amd64, ARM, and IBM POWER +- gcc (4.3, 2009) targets 45 architectures officially, 28 unofficially +- leveraging gcc => minimal work to support Go on existing architectures + +* rationale: code generation + +- gcc has ~30 years of work put into code analysis and optimization +- cmd/gc has only recently focused on code generation (khr's SSA work) +- leveraging gcc => minimal work to produce optimized binaries + +* rationale: technical honesty + +- "Keeping each other honest" +- Distinct implementations => Inconsistencies in specification and implementations +- Users have options when an implementation lacks features +- Compilers seek feature parity => Compilers learn from each other +- Compilers generate better binaries => Virtuous cycle + +* gccgo improvements through a telescope + +* gofrontend: no dependency on gcc + +- gcc implements gofrontend's backend interface + +gofrontend (gcc/go/gofrontend/expressions.cc) + +.code keeping-up/backend_interface.diff + +backend (gcc/go/go-gcc.cc) + +.code keeping-up/cst.gcc + +* gccgo: builds the `go` tool + +- One way to build code across multiple compilers + +.code keeping-up/go_build.log + +* gofrontend: basic escape analysis + +- Implementation of _Escape_analysis_for_Java_ by JD Choi + +escape.go + +.code keeping-up/escape.go + +Connection Graph + +.image keeping-up/escape.png + +* Keeping up + +* gccgo: runtime and garbage collector parity + +- gccgo runtime is a modified version of Go 1.3 runtime +- Go 1.4 runtime was rewritten in Go +- Go 1.4 changed GC type info + +* beyond gccgo: compiler stack maps + +- Stack map records locations of live values at a certain address +- Allows Garbage Collector to be precise about types on stack +- Enables contiguous stacks to readjust copied pointers +- Little support in C compilers: gcc has no support, LLVM support is WIP + +* llvmgo: another "other Go compiler" + +- gofrontend provides backend interface LLVM can implement +- LLVM byte code is trusted in secure environments such as PNaCl +- Run native Go in the web + +* OS support: OSX and Windows + +- gccgo support on not unixes +- Expert needed \ No newline at end of file
diff --git a/2015/keeping-up/backend_interface.diff b/2015/keeping-up/backend_interface.diff new file mode 100644 index 0000000..f844d34 --- /dev/null +++ b/2015/keeping-up/backend_interface.diff
@@ -0,0 +1,7 @@ +- tree val_type_tree = type_to_tree(this->type()->get_backend(gogo)); +- go_assert(val_type_tree != error_mark_node); +- return build_int_cstu(val_type_tree, val); ++ mpz_t cst; ++ mpz_init_set_ui(cst, val); ++ Btype* int_btype = this->type()->get_backend(gogo); ++ return gogo->backend()->integer_constant_expression(int_btype, cst);
diff --git a/2015/keeping-up/cst.gcc b/2015/keeping-up/cst.gcc new file mode 100644 index 0000000..9784bbb --- /dev/null +++ b/2015/keeping-up/cst.gcc
@@ -0,0 +1,7 @@ +Bexpression* +Gcc_backend::integer_constant_expression(Btype* btype, mpz_t val) +{ + tree t = btype->get_tree(); + tree ret = double_int_to_tree(t, mpz_get_double_int(t, val, true)); + return this->make_expression(ret); +}
diff --git a/2015/keeping-up/escape.go b/2015/keeping-up/escape.go new file mode 100644 index 0000000..3a76497 --- /dev/null +++ b/2015/keeping-up/escape.go
@@ -0,0 +1,10 @@ +package main + +var global *int + +func f(i *int) { global = i } + +func main() { + a := new(int) + f(a) +}
diff --git a/2015/keeping-up/escape.png b/2015/keeping-up/escape.png new file mode 100644 index 0000000..401b8f0 --- /dev/null +++ b/2015/keeping-up/escape.png Binary files differ
diff --git a/2015/keeping-up/gccgo_structure.png b/2015/keeping-up/gccgo_structure.png new file mode 100644 index 0000000..91bfbf6 --- /dev/null +++ b/2015/keeping-up/gccgo_structure.png Binary files differ
diff --git a/2015/keeping-up/go_build.log b/2015/keeping-up/go_build.log new file mode 100644 index 0000000..50353d8 --- /dev/null +++ b/2015/keeping-up/go_build.log
@@ -0,0 +1,14 @@ +$ cat hello.go +package main + +import "fmt" + +func main() { + fmt.Println("Hello World!") +} + +$ go run -gccgoflags="-fgo-optimize-allocs" hello.go +Hello World! + +$ go version +go version go1.4.2 gccgo (GCC) 6.0.0 20150714 (experimental) linux/amd64 \ No newline at end of file
diff --git a/2015/keeping-up/gource_explosion.html b/2015/keeping-up/gource_explosion.html new file mode 100644 index 0000000..10cc0ac --- /dev/null +++ b/2015/keeping-up/gource_explosion.html
@@ -0,0 +1,3 @@ +<video id="video" controls="" autoplay="" loop="" width="100%"> + <source src="http://webm.host/d764a/vid.webm" type="video/webm"> +</video>