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

Delta Between Two Patch Sets: src/cmd/gc/typecheck.c

Issue 4634073: code review 4634073: gc: Escape analysis. (Closed)
Left Patch Set: diff -r 43a8f5250576 https://go.googlecode.com/hg/ Created 13 years, 7 months ago
Right Patch Set: diff -r adfa9f5cca40 https://go.googlecode.com/hg/ Created 13 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/cmd/gc/subr.c ('k') | test/escape2.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 /* 5 /*
6 * type check the whole tree of an expression. 6 * type check the whole tree of an expression.
7 * calculates expression types. 7 * calculates expression types.
8 * evaluates compile time constants. 8 * evaluates compile time constants.
9 * marks variables that escape the local frame. 9 * marks variables that escape the local frame.
10 * rewrites n->op to be more specific in some cases. 10 * rewrites n->op to be more specific in some cases.
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 n->type = types[TINT]; 1034 n->type = types[TINT];
1035 typecheck(&n->left, Erv); 1035 typecheck(&n->left, Erv);
1036 typecheck(&n->right, Erv); 1036 typecheck(&n->right, Erv);
1037 if(n->left->type == T || n->right->type == T) 1037 if(n->left->type == T || n->right->type == T)
1038 goto error; 1038 goto error;
1039 defaultlit(&n->left, T); 1039 defaultlit(&n->left, T);
1040 defaultlit(&n->right, T); 1040 defaultlit(&n->right, T);
1041 ················ 1041 ················
1042 // copy([]byte, string) 1042 // copy([]byte, string)
1043 if(isslice(n->left->type) && n->right->type->etype == TSTRING) { 1043 if(isslice(n->left->type) && n->right->type->etype == TSTRING) {
1044 » » » if (n->left->type->type == types[TUINT8]) 1044 » » » if(n->left->type->type == types[TUINT8])
1045 goto ret; 1045 goto ret;
1046 yyerror("arguments to copy have different element types: %lT and string", n->left->type); 1046 yyerror("arguments to copy have different element types: %lT and string", n->left->type);
1047 goto error; 1047 goto error;
1048 } 1048 }
1049 ······························· 1049 ·······························
1050 if(!isslice(n->left->type) || !isslice(n->right->type)) { 1050 if(!isslice(n->left->type) || !isslice(n->right->type)) {
1051 if(!isslice(n->left->type) && !isslice(n->right->type)) 1051 if(!isslice(n->left->type) && !isslice(n->right->type))
1052 yyerror("arguments to copy must be slices; have %lT, %lT", n->left->type, n->right->type); 1052 yyerror("arguments to copy must be slices; have %lT, %lT", n->left->type, n->right->type);
1053 else if(!isslice(n->left->type)) 1053 else if(!isslice(n->left->type))
1054 yyerror("first argument to copy should be slice; have %lT", n->left->type); 1054 yyerror("first argument to copy should be slice; have %lT", n->left->type);
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 return 1; 1598 return 1;
1599 } 1599 }
1600 1600
1601 if(f2 != T) { 1601 if(f2 != T) {
1602 tt = n->left->type; 1602 tt = n->left->type;
1603 dowidth(tt); 1603 dowidth(tt);
1604 rcvr = getthisx(f2->type)->type->type; 1604 rcvr = getthisx(f2->type)->type->type;
1605 if(!eqtype(rcvr, tt)) { 1605 if(!eqtype(rcvr, tt)) {
1606 if(rcvr->etype == tptr && eqtype(rcvr->type, tt)) { 1606 if(rcvr->etype == tptr && eqtype(rcvr->type, tt)) {
1607 checklvalue(n->left, "call pointer method on"); 1607 checklvalue(n->left, "call pointer method on");
1608 » » » » if (!debug['s']) 1608 » » » » if(!debug['s'])
rsc 2011/08/24 14:27:46 s/if (/if(/
lvd 2011/08/24 16:51:40 Done.
1609 addrescapes(n->left); 1609 addrescapes(n->left);
1610 n->left = nod(OADDR, n->left, N); 1610 n->left = nod(OADDR, n->left, N);
1611 n->left->implicit = 1; 1611 n->left->implicit = 1;
1612 typecheck(&n->left, Etype|Erv); 1612 typecheck(&n->left, Etype|Erv);
1613 } else if(tt->etype == tptr && eqtype(tt->type, rcvr)) { 1613 } else if(tt->etype == tptr && eqtype(tt->type, rcvr)) {
1614 n->left = nod(OIND, n->left, N); 1614 n->left = nod(OIND, n->left, N);
1615 n->left->implicit = 1; 1615 n->left->implicit = 1;
1616 typecheck(&n->left, Etype|Erv); 1616 typecheck(&n->left, Etype|Erv);
1617 } else { 1617 } else {
1618 // method is attached to wrong type? 1618 // method is attached to wrong type?
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2746 ret: 2746 ret:
2747 if(typecheckdefstack->n != n) 2747 if(typecheckdefstack->n != n)
2748 fatal("typecheckdefstack mismatch"); 2748 fatal("typecheckdefstack mismatch");
2749 l = typecheckdefstack; 2749 l = typecheckdefstack;
2750 typecheckdefstack = l->next; 2750 typecheckdefstack = l->next;
2751 2751
2752 lineno = lno; 2752 lineno = lno;
2753 n->walkdef = 1; 2753 n->walkdef = 1;
2754 return n; 2754 return n;
2755 } 2755 }
LEFTRIGHT

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