for (std::vector<Named_object*>::iterator fn = stack.begin();
fn != stack.end();
++fn)
- this->tag_function(*fn);
+ this->tag_function(context, *fn);
if (this->debug_escape_level() != 0)
{
class Escape_analysis_assign : public Traverse
{
public:
- Escape_analysis_assign(Escape_context* context)
+ Escape_analysis_assign(Escape_context* context, Named_object* fn)
: Traverse(traverse_statements
| traverse_expressions),
- context_(context)
+ context_(context), fn_(fn)
{ }
// Model statements within a function as assignments and flows between nodes.
private:
// The escape context for this set of functions.
Escape_context* context_;
+ // The current function being analyzed.
+ Named_object* fn_;
};
// Helper function to detect self assignment like the following.
int save_depth = context->loop_depth();
context->set_loop_depth(1);
- Escape_analysis_assign ea(context);
+ Escape_analysis_assign ea(context, fn);
Function::Results* res = fn->func_value()->result_variables();
if (res != NULL)
{
class Escape_analysis_tag
{
public:
- Escape_analysis_tag()
+ Escape_analysis_tag(Escape_context* context)
+ : context_(context)
{ }
// Add notes to the function's type about the escape information of its
// input parameters.
void
tag(Named_object* fn);
+
+ private:
+ Escape_context* context_;
};
void
// retain analysis results across imports.
void
-Gogo::tag_function(Named_object* fn)
+Gogo::tag_function(Escape_context* context, Named_object* fn)
{
- Escape_analysis_tag eat;
+ Escape_analysis_tag eat(context);
eat.tag(fn);
}
// Add notes about the escape level of a function's input and output
// parameters for exporting and importing top level functions.
void
- tag_function(Named_object*);
+ tag_function(Escape_context*, Named_object*);
// Reclaim memory of escape analysis Nodes.
void
class Call_multiple_result_type : public Type
{
public:
- Call_multiple_result_type()
- : Type(TYPE_CALL_MULTIPLE_RESULT)
+ Call_multiple_result_type(Call_expression* call)
+ : Type(TYPE_CALL_MULTIPLE_RESULT),
+ call_(call)
{ }
protected:
void
do_mangled_name(Gogo*, std::string*) const
{ go_assert(saw_errors()); }
+
+ private:
+ // The expression being called.
+ Call_expression* call_;
};
// Make a call result type.
Type*
-Type::make_call_multiple_result_type()
+Type::make_call_multiple_result_type(Call_expression* call)
{
- return new Call_multiple_result_type();
+ return new Call_multiple_result_type(call);
}
// Class Struct_field.
class Check_escape : public Traverse
{
public:
- Check_escape()
- : Traverse(traverse_expressions | traverse_variables)
+ Check_escape(Gogo* gogo)
+ : Traverse(traverse_expressions | traverse_variables),
+ gogo_(gogo)
{ }
int
int
variable(Named_object*);
+
+ private:
+ Gogo* gogo_;
};
int
{
this->propagate_writebarrierrec();
- Check_escape chk;
+ Check_escape chk(this);
this->traverse(&chk);
}