-cf5a64066fa21b20beae0b895c05d26af53e13e0
+584fdecefce831c3471dbd4857ba0ce0be2b5212
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
Gogo* gogo = context->gogo();
Location loc = this->location();
- Node* n = Node::make_node(this);
- if (this->allocate_on_stack_
- || (n->encoding() & ESCAPE_MASK) == int(Node::ESCAPE_NONE))
+ if (this->allocate_on_stack_)
{
int64_t size;
bool ok = this->type_->backend_type_size(gogo, &size);
}
else
{
+ go_assert(this->storage_escapes_ || this->element_count() == 0);
space = Expression::make_heap_expression(this->array_val_, loc);
- Node* n = Node::make_node(this);
- if ((n->encoding() & ESCAPE_MASK) == int(Node::ESCAPE_NONE))
- {
- n = Node::make_node(space);
- n->set_encoding(Node::ESCAPE_NONE);
- }
}
// Build a constructor for the slice.
Btype* btype = this->type()->get_backend(gogo);
Expression* alloc = Expression::make_allocation(etype, loc);
- Node* n = Node::make_node(this);
- if ((n->encoding() & ESCAPE_MASK) == int(Node::ESCAPE_NONE))
+ if (this->allocate_on_stack_)
alloc->allocation_expression()->set_allocate_on_stack();
Bexpression* space = alloc->get_backend(context);
public:
Heap_expression(Expression* expr, Location location)
: Expression(EXPRESSION_HEAP, location),
- expr_(expr)
+ expr_(expr), allocate_on_stack_(false)
{ }
Expression*
expr() const
{ return this->expr_; }
+ void
+ set_allocate_on_stack()
+ { this->allocate_on_stack_ = true; }
+
protected:
int
do_traverse(Traverse* traverse)
private:
// The expression which is being put on the heap.
Expression* expr_;
+ // Whether or not this is a stack allocation.
+ bool allocate_on_stack_;
};
// A receive expression.
aie->array()->address_taken(escapes);
}
+ if (expr->allocation_expression() != NULL)
+ {
+ Node* n = Node::make_node(expr);
+ if ((n->encoding() & ESCAPE_MASK) == Node::ESCAPE_NONE)
+ expr->allocation_expression()->set_allocate_on_stack();
+ }
+ if (expr->heap_expression() != NULL)
+ {
+ Node* n = Node::make_node(expr);
+ if ((n->encoding() & ESCAPE_MASK) == Node::ESCAPE_NONE)
+ expr->heap_expression()->set_allocate_on_stack();
+ }
+ if (expr->slice_literal() != NULL)
+ {
+ Node* n = Node::make_node(expr);
+ if ((n->encoding() & ESCAPE_MASK) == Node::ESCAPE_NONE)
+ expr->slice_literal()->set_storage_does_not_escape();
+ }
+
// Rewrite non-escaping makeslice with constant size to stack allocation.
Unsafe_type_conversion_expression* uce =
expr->unsafe_conversion_expression();