diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-03 21:52:37 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-03 21:52:37 +0000 |
commit | f8bdf81a026b110398982d31e55f3313ca2e4eb9 (patch) | |
tree | 5f956e4c89959ef335ef73b7ec6e00e4bc2c12d5 /libgo/runtime/go-reflect-call.c | |
parent | 631d940c80b318d435d498744950dc1eeacafeaa (diff) | |
download | gcc-f8bdf81a026b110398982d31e55f3313ca2e4eb9.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202233 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/runtime/go-reflect-call.c')
-rw-r--r-- | libgo/runtime/go-reflect-call.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/libgo/runtime/go-reflect-call.c b/libgo/runtime/go-reflect-call.c index 83b9eba0436..5cf370798bf 100644 --- a/libgo/runtime/go-reflect-call.c +++ b/libgo/runtime/go-reflect-call.c @@ -302,9 +302,7 @@ go_func_to_cif (const struct __go_func_type *func, _Bool is_interface, in_types = ((const struct __go_type_descriptor **) func->__in.__values); - num_args = (num_params - + (is_interface ? 1 : 0) - + (!is_interface && !is_method ? 1 : 0)); + num_args = num_params + (is_interface ? 1 : 0); args = (ffi_type **) __go_alloc (num_args * sizeof (ffi_type *)); i = 0; off = 0; @@ -321,12 +319,6 @@ go_func_to_cif (const struct __go_func_type *func, _Bool is_interface, for (; i < num_params; ++i) args[i + off] = go_type_to_ffi (in_types[i]); - if (!is_interface && !is_method) - { - // There is a closure argument, a pointer. - args[i + off] = &ffi_type_pointer; - } - rettype = go_func_return_ffi (func); status = ffi_prep_cif (cif, FFI_DEFAULT_ABI, num_args, rettype, args); @@ -511,9 +503,8 @@ go_set_results (const struct __go_func_type *func, unsigned char *call_result, regardless of FUNC_TYPE, it is passed as a pointer. If neither IS_INTERFACE nor IS_METHOD is true then we are calling a - function indirectly, and the caller is responsible for passing a - trailing closure argument, a pointer, which is not described in - FUNC_TYPE. */ + function indirectly, and we must pass a closure pointer via + __go_set_closure. The pointer to pass is simply FUNC_VAL. */ void reflect_call (const struct __go_func_type *func_type, FuncVal *func_val, @@ -528,6 +519,8 @@ reflect_call (const struct __go_func_type *func_type, FuncVal *func_val, call_result = (unsigned char *) malloc (go_results_size (func_type)); + if (!is_interface && !is_method) + __go_set_closure (func_val); ffi_call (&cif, func_val->fn, call_result, params); /* Some day we may need to free result values if RESULTS is |