Commit Graph

21 Commits

Author SHA1 Message Date
Ian Lance Taylor 033425d0ed re PR go/91781 (r275691 breaks go test "reflect")
PR go/91781
    reflect: promote integer closure return to full word
    
    The libffi library expects an integer return type to be promoted to a
    full word.  Implement that when returning from a closure written in Go.
    This only matters on big-endian systems when returning an integer smaller
    than the pointer size, which is why we didn't notice it until now.
    
    Fixes https://gcc.gnu.org/PR91781.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/195858

From-SVN: r275813
2019-09-17 20:24:00 +00:00
Ian Lance Taylor 4a14082645 compile, runtime: permit anonymous and empty fields in C header
Permit putting structs with anonymous and empty fields in the C header
    file runtime.inc that is used to build the C runtime code.  This is
    required for upcoming 1.13 support, as the m struct has picked up an
    anonymous field.
    
    Doing this lets the C header contain all the type descriptor structs,
    so start using those in the C code.  This cuts the number of copies of
    type descriptor definitions from 3 to 2.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/192343

From-SVN: r275227
2019-08-30 21:49:49 +00:00
Ian Lance Taylor 8a9f2a6bbd compiler, runtime: harmonize types referenced by both C and Go
Compiling with LTO revealed a number of cases in the runtime and
    standard library where C and Go disagreed about the type of an object or
    function (or where Go and code generated by the compiler disagreed). In
    all cases the underlying representation was the same (e.g., uintptr vs.
    void*), so this wasn't causing actual problems, but it did result in a
    number of annoying warnings when compiling with LTO.
    
    Reviewed-on: https://go-review.googlesource.com/c/160700

From-SVN: r268923
2019-02-15 01:57:51 +00:00
Ian Lance Taylor 0f2a6e84c6 runtime: remove __go_alloc and __go_free
Move allocg and handling of allgs slice from C to Go.
    
    Reviewed-on: https://go-review.googlesource.com/34797

From-SVN: r244036
2017-01-03 22:58:48 +00:00
Ian Lance Taylor 5302cd0250 runtime, reflect: rewrite Go to FFI type conversion in Go
As we move toward the Go 1.7 garbage collector, it's essential that all
    allocation of values that can contain Go pointers be done using the
    correct type descriptor.  That is simplest if we do all such allocation
    in Go code.  This rewrites the code that converts from a Go type to a
    libffi CIF into Go.
    
    Reviewed-on: https://go-review.googlesource.com/33353

From-SVN: r242578
2016-11-18 00:15:38 +00:00
Ian Lance Taylor 8c61286797 re PR go/68496 ([libgo] reflect test fails on Linux x86-64)
PR go/68496
    reflect: Allocate space for FFI functions returning a zero-sized type.
    
    The libffi library does not understand zero-sized types.  We represent
    them as a struct with a single field of type void.  If such a type is
    returned from a function, libffi will copy 1 byte of data.  Allocate
    space for that byte, although we won't use it.
    
    Fixes https://gcc.gnu.org/PR68496.

    Reviewed-on: https://go-review.googlesource.com/17175

From-SVN: r230776
2015-11-23 21:17:45 +00:00
Richard Henderson 38bf819a5f compiler, reflect, runtime: Use static chain for closures.
Change from using __go_set_closure to passing the closure
value in the static chain field.  Uses new backend support for
setting the closure chain in a call from C via
__builtin_call_with_static_chain.  Uses new support in libffi
for Go closures.

The old architecture specific support for reflect.MakeFunc is
removed, replaced by the libffi support.

All work done by Richard Henderson.

	* go-gcc.cc (Gcc_backend::call_expression): Add chain_expr argument.
	(Gcc_backend::static_chain_variable): New method.

From-SVN: r219776
2015-01-16 22:58:53 +00:00
Ian Lance Taylor dffa732835 reflect, runtime: Use libffi closures to implement reflect.MakeFunc.
Keep using the existing 386 and amd64 code on those archs,
since it is more efficient.

From-SVN: r212853
2014-07-19 21:36:26 +00:00
Ian Lance Taylor 41674b9fe4 reflect: Handle calls to functions that take or return empty structs
Fixes issue 6761

This simple change seems to work fine, slightly to my surprise.

This includes the tests I submitted to the main Go repository at
https://codereview.appspot.com/26570046

From-SVN: r205001
2013-11-19 02:30:03 +00:00
Ian Lance Taylor f038dae646 libgo: Update to October 24 version of master library.
From-SVN: r204466
2013-11-06 19:49:01 +00:00
Ian Lance Taylor 05a7d56678 compiler, runtime: Use runtime functions to pass closure value.
This changes the compiler and runtime to not pass a closure
value as the last argument, but to instead pass it via
__go_set_closure and retrieve it via __go_get_closure.  This
eliminates the need for function descriptor wrapper functions.
It will make it possible to retrieve the closure value in a
reflect.MakeFunc function.

From-SVN: r202233
2013-09-03 21:52:37 +00:00
Ian Lance Taylor fdbc38a6e8 compiler, runtime: Use function descriptors.
This changes the representation of a Go value of function type
from being a pointer to function code (like a C function
pointer) to being a pointer to a struct.  The first field of
the struct points to the function code.  The remaining fields,
if any, are the addresses of variables referenced in enclosing
functions.  For each call to a function, the address of the
function descriptor is passed as the last argument.

This lets us avoid generating trampolines, and removes the use
of writable/executable sections of the heap.

From-SVN: r200181
2013-06-18 23:49:49 +00:00
Ian Lance Taylor 73e0b984b3 runtime, testing/quick: libffi doesn't handle complex on Alpha.
From Uros Bizjak.

From-SVN: r196389
2013-03-01 19:26:43 +00:00
Ian Lance Taylor 556ea3915a runtime: Fix reflect.Call support for 64-bit ints.
From-SVN: r193110
2012-11-02 23:17:05 +00:00
Ian Lance Taylor 776f27a67f compiler, runtime: More steps toward separating int and intgo.
From-SVN: r193059
2012-11-01 03:02:13 +00:00
Ian Lance Taylor 35ea42ebad re PR go/48407 (libgo/configure --without-libffi doesn't work)
PR go/48407
runtime: Permit building libgo without libffi.

From-SVN: r184234
2012-02-14 20:47:35 +00:00
Ian Lance Taylor 83a5c149a6 runtime: Handle FFI promoting result types.
From-SVN: r184123
2012-02-11 07:08:13 +00:00
Ian Lance Taylor 3b8dffe701 Change builtin make to runtime call at lowering time.
Use kindNoPointers as 6g does.

	* Make-lang.in (go/expressions.o): Depend on $(GO_RUNTIME_H).

From-SVN: r175008
2011-06-14 05:53:10 +00:00
Ian Lance Taylor 9ff56c9570 Update to current version of Go library.
From-SVN: r173931
2011-05-20 00:18:15 +00:00
Ian Lance Taylor ff5f50c52c Remove the types float and complex.
Update to current version of Go library.

Update testsuite for removed types.

	* go-lang.c (go_langhook_init): Omit float_type_size when calling
	go_create_gogo.
	* go-c.h: Update declaration of go_create_gogo.

From-SVN: r169098
2011-01-21 18:19:03 +00:00
Ian Lance Taylor 7a9389330e Add Go frontend, libgo library, and Go testsuite.
gcc/:
	* gcc.c (default_compilers): Add entry for ".go".
	* common.opt: Add -static-libgo as a driver option.
	* doc/install.texi (Configuration): Mention libgo as an option for
	--enable-shared.  Mention go as an option for --enable-languages.
	* doc/invoke.texi (Overall Options): Mention .go as a file name
	suffix.  Mention go as a -x option.
	* doc/frontends.texi (G++ and GCC): Mention Go as a supported
	language.
	* doc/sourcebuild.texi (Top Level): Mention libgo.
	* doc/standards.texi (Standards): Add section on Go language.
	Move references for other languages into their own section.
	* doc/contrib.texi (Contributors): Mention that I contributed the
	Go frontend.
gcc/testsuite/:
	* lib/go.exp: New file.
	* lib/go-dg.exp: New file.
	* lib/go-torture.exp: New file.
	* lib/target-supports.exp (check_compile): Match // Go.

From-SVN: r167407
2010-12-03 04:34:57 +00:00