Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(120)

Unified Diff: src/cmd/gc/walk.c

Issue 891050: code review 891050: gc: zero unnamed return values on entry if func has defer (Closed)
Patch Set: code review 891050: gc: zero unnamed return values on entry if func has defer Created 14 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/fixedbugs/bug266.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/cmd/gc/walk.c
===================================================================
--- a/src/cmd/gc/walk.c
+++ b/src/cmd/gc/walk.c
@@ -2312,7 +2312,7 @@
* copies of escaped parameters to the heap.
*/
NodeList*
-paramstoheap(Type **argin)
+paramstoheap(Type **argin, int out)
{
Type *t;
Iter savet;
@@ -2322,6 +2322,12 @@
nn = nil;
for(t = structfirst(&savet, argin); t != T; t = structnext(&savet)) {
v = t->nname;
+ if(v == N && out && hasdefer) {
+ // Defer might stop a panic and show the
+ // return values as they exist at the time of panic.
+ // Make sure to zero them on entry to the function.
+ nn = list(nn, nod(OAS, nodarg(t, 1), N));
+ }
if(v == N || !(v->class & PHEAP))
continue;
@@ -2366,9 +2372,9 @@
{
NodeList *nn;
- nn = paramstoheap(getthis(curfn->type));
- nn = concat(nn, paramstoheap(getinarg(curfn->type)));
- nn = concat(nn, paramstoheap(getoutarg(curfn->type)));
+ nn = paramstoheap(getthis(curfn->type), 0);
+ nn = concat(nn, paramstoheap(getinarg(curfn->type), 0));
+ nn = concat(nn, paramstoheap(getoutarg(curfn->type), 1));
curfn->enter = concat(curfn->enter, nn);
curfn->exit = returnsfromheap(getoutarg(curfn->type));
}
« no previous file with comments | « no previous file | test/fixedbugs/bug266.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b