Commit 92bb0292 by Ian Lance Taylor

compiler: make non-escaping Bound_method_expression not heap allocate

    
    Bound_method_expression needs a closure. Stack allocate the
    closure when it does not escape.
    
    Reviewed-on: https://go-review.googlesource.com/85638

From-SVN: r256407
parent eb80a362
584fdecefce831c3471dbd4857ba0ce0be2b5212 d5774539b17112d9ce709a1fe722daf68eb8594f
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -7030,7 +7030,12 @@ Bound_method_expression::do_flatten(Gogo* gogo, Named_object*, ...@@ -7030,7 +7030,12 @@ Bound_method_expression::do_flatten(Gogo* gogo, Named_object*,
Expression* ret = Expression::make_struct_composite_literal(st, vals, loc); Expression* ret = Expression::make_struct_composite_literal(st, vals, loc);
if (!gogo->compiling_runtime() || gogo->package_name() != "runtime") if (!gogo->compiling_runtime() || gogo->package_name() != "runtime")
ret = Expression::make_heap_expression(ret, loc); {
ret = Expression::make_heap_expression(ret, loc);
Node* n = Node::make_node(this);
if ((n->encoding() & ESCAPE_MASK) == Node::ESCAPE_NONE)
ret->heap_expression()->set_allocate_on_stack();
}
else else
{ {
// When compiling the runtime, method closures do not escape. // When compiling the runtime, method closures do not escape.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment