aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-05-25 21:14:40 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-05-25 21:14:40 +0000
commit40bb0243ec6f2831e6efb54e0f27f091075c6dac (patch)
tree564c9d279db8a9f4a46e0b3dd5146cf62b86af45 /gcc
parent31a18a7e231474e40309e930e8705d62a38ffdd5 (diff)
downloadgcc-40bb0243ec6f2831e6efb54e0f27f091075c6dac.zip
gcc-40bb0243ec6f2831e6efb54e0f27f091075c6dac.tar.gz
gcc-40bb0243ec6f2831e6efb54e0f27f091075c6dac.tar.bz2
compiler: Don't create a closure if not needed.
From-SVN: r187897
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/expressions.cc34
1 files changed, 11 insertions, 23 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 1585150..e609be9 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -1312,30 +1312,18 @@ Func_expression::do_get_tree(Translate_context* context)
&& TREE_CODE(TREE_OPERAND(fnaddr, 0)) == FUNCTION_DECL);
TREE_ADDRESSABLE(TREE_OPERAND(fnaddr, 0)) = 1;
- // For a normal non-nested function call, that is all we have to do.
- if (!this->function_->is_function()
- || this->function_->func_value()->enclosing() == NULL)
- {
- go_assert(this->closure_ == NULL);
- return fnaddr;
- }
+ // If there is no closure, that is all have to do.
+ if (this->closure_ == NULL)
+ return fnaddr;
- // For a nested function call, we have to always allocate a
- // trampoline. If we don't always allocate, then closures will not
- // be reliably distinct.
- Expression* closure = this->closure_;
- tree closure_tree;
- if (closure == NULL)
- closure_tree = null_pointer_node;
- else
- {
- // Get the value of the closure. This will be a pointer to
- // space allocated on the heap.
- closure_tree = closure->get_tree(context);
- if (closure_tree == error_mark_node)
- return error_mark_node;
- go_assert(POINTER_TYPE_P(TREE_TYPE(closure_tree)));
- }
+ go_assert(this->function_->func_value()->enclosing() != NULL);
+
+ // Get the value of the closure. This will be a pointer to space
+ // allocated on the heap.
+ tree closure_tree = this->closure_->get_tree(context);
+ if (closure_tree == error_mark_node)
+ return error_mark_node;
+ go_assert(POINTER_TYPE_P(TREE_TYPE(closure_tree)));
// Now we need to build some code on the heap. This code will load
// the static chain pointer with the closure and then jump to the