From 317ebe1c58d108c5983defdaeb14538e6f3fab00 Mon Sep 17 00:00:00 2001 From: aarzilli Date: Tue, 13 Jun 2017 10:38:45 +0200 Subject: [PATCH] proc: auto-dereference local variables that escape to the heap The compiler a variable 'v' that escapes to the heap with a '&v' entry. Auto dereference those local variables. Fixe #871 --- pkg/proc/variables.go | 5 +++++ service/api/types.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/pkg/proc/variables.go b/pkg/proc/variables.go index 8a473810..1a9bc7ba 100644 --- a/pkg/proc/variables.go +++ b/pkg/proc/variables.go @@ -45,6 +45,11 @@ type VariableFlags uint16 const ( // VariableEscaped is set for local variables that escaped to the heap + // + // The compiler performs escape analysis on local variables, the variables + // that may outlive the stack frame are allocated on the heap instead and + // only the address is recorded on the stack. These variables will be + // marked with this flag. VariableEscaped VariableFlags = (1 << iota) // VariableShadowed is set for local variables that are shadowed by a // variable with the same name in another scope diff --git a/service/api/types.go b/service/api/types.go index 7181fd33..b39791eb 100644 --- a/service/api/types.go +++ b/service/api/types.go @@ -152,6 +152,11 @@ type VariableFlags uint16 const ( // VariableEscaped is set for local variables that escaped to the heap + // + // The compiler performs escape analysis on local variables, the variables + // that may outlive the stack frame are allocated on the heap instead and + // only the address is recorded on the stack. These variables will be + // marked with this flag. VariableEscaped = VariableFlags(proc.VariableEscaped) // VariableShadowed is set for local variables that are shadowed by a