Left: | ||
Right: |
OLD | NEW |
---|---|
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 #include <u.h> | 5 #include <u.h> |
6 #include <libc.h> | 6 #include <libc.h> |
7 #include "gg.h" | 7 #include "gg.h" |
8 | 8 |
9 /* | 9 /* |
10 * generate: | 10 * generate: |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
693 break; | 693 break; |
694 | 694 |
695 case ODOTPTR: | 695 case ODOTPTR: |
696 cgen(nl, res); | 696 cgen(nl, res); |
697 if(n->xoffset != 0) { | 697 if(n->xoffset != 0) { |
698 // explicit check for nil if struct is large enough | 698 // explicit check for nil if struct is large enough |
699 // that we might derive too big a pointer. | 699 // that we might derive too big a pointer. |
700 if(nl->type->type->width >= unmappedzero) { | 700 if(nl->type->type->width >= unmappedzero) { |
701 regalloc(&n1, types[tptr], N); | 701 regalloc(&n1, types[tptr], N); |
702 gmove(res, &n1); | 702 gmove(res, &n1); |
703 p1 = gins(AMOVW, &n1, &n1); | 703 p1 = gins(AMOVW, &n1, &n1); |
minux1
2012/11/18 10:21:29
you also need to change here?
| |
704 p1->from.type = D_OREG; | 704 p1->from.type = D_OREG; |
705 p1->from.offset = 0; | 705 p1->from.offset = 0; |
706 regfree(&n1); | 706 regfree(&n1); |
707 } | 707 } |
708 nodconst(&n1, types[TINT32], n->xoffset); | 708 nodconst(&n1, types[TINT32], n->xoffset); |
709 regalloc(&n2, n1.type, N); | 709 regalloc(&n2, n1.type, N); |
710 regalloc(&n3, types[tptr], N); | 710 regalloc(&n3, types[tptr], N); |
711 gmove(&n1, &n2); | 711 gmove(&n1, &n2); |
712 gmove(res, &n3); | 712 gmove(res, &n3); |
713 gins(optoas(OADD, types[tptr]), &n2, &n3); | 713 gins(optoas(OADD, types[tptr]), &n2, &n3); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
774 } else { | 774 } else { |
775 regalloc(a, types[tptr], res); | 775 regalloc(a, types[tptr], res); |
776 cgen(n->left, a); | 776 cgen(n->left, a); |
777 } | 777 } |
778 if(n->xoffset != 0) { | 778 if(n->xoffset != 0) { |
779 // explicit check for nil if struct is large enough | 779 // explicit check for nil if struct is large enough |
780 // that we might derive too big a pointer. | 780 // that we might derive too big a pointer. |
781 if(n->left->type->type->width >= unmappedzero) { | 781 if(n->left->type->type->width >= unmappedzero) { |
782 regalloc(&n1, types[tptr], N); | 782 regalloc(&n1, types[tptr], N); |
783 gmove(a, &n1); | 783 gmove(a, &n1); |
784 p1 = gins(AMOVW, &n1, &n1); | 784 p1 = gins(AMOVW, &n1, &n1); |
minux1
2012/11/18 10:21:29
and here.
| |
785 p1->from.type = D_OREG; | 785 p1->from.type = D_OREG; |
786 p1->from.offset = 0; | 786 p1->from.offset = 0; |
787 regfree(&n1); | 787 regfree(&n1); |
788 } | 788 } |
789 } | 789 } |
790 a->op = OINDREG; | 790 a->op = OINDREG; |
791 a->xoffset = n->xoffset; | 791 a->xoffset = n->xoffset; |
792 a->type = n->type; | 792 a->type = n->type; |
793 return; | 793 return; |
794 | 794 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
943 } | 943 } |
944 | 944 |
945 // &a is in &n3 (allocated in res) | 945 // &a is in &n3 (allocated in res) |
946 // i is in &n1 (if not constant) | 946 // i is in &n1 (if not constant) |
947 // w is width | 947 // w is width |
948 | 948 |
949 // explicit check for nil if array is large enough | 949 // explicit check for nil if array is large enough |
950 // that we might derive too big a pointer. | 950 // that we might derive too big a pointer. |
951 if(isfixedarray(nl->type) && nl->type->width >= unmappedzero) { | 951 if(isfixedarray(nl->type) && nl->type->width >= unmappedzero) { |
952 regalloc(&n4, types[tptr], N); | 952 regalloc(&n4, types[tptr], N); |
953 gmove(&n3, &n4); | 953 gmove(&n3, &n4); |
minux1
2012/11/18 08:15:41
i think this suffices:
regalloc(&n4, types[TUI
dfc
2012/11/18 09:57:01
I do not think that is sufficient as it just compu
| |
954 » » » p1 = gins(AMOVW, &n4, &n4); | 954 » » » n4.op = OINDREG; |
955 » » » p1->from.type = D_OREG; | 955 » » » n4.type = types[TUINT8]; |
956 » » » p1->from.offset = 0; | 956 » » » n4.xoffset = 0; |
957 » » » regalloc(&tmp, types[TUINT8], N); | |
958 » » » gmove(&n4, &tmp); | |
957 regfree(&n4); | 959 regfree(&n4); |
960 regfree(&tmp); | |
958 } | 961 } |
959 | 962 |
960 // constant index | 963 // constant index |
961 if(isconst(nr, CTINT)) { | 964 if(isconst(nr, CTINT)) { |
962 if(isconst(nl, CTSTR)) | 965 if(isconst(nl, CTSTR)) |
963 fatal("constant string constant index"); | 966 fatal("constant string constant index"); |
964 v = mpgetfix(nr->val.u.xval); | 967 v = mpgetfix(nr->val.u.xval); |
965 if(isslice(nl->type) || nl->type->etype == TSTRING) { | 968 if(isslice(nl->type) || nl->type->etype == TSTRING) { |
966 if(!debug['B'] && !n->bounded) { | 969 if(!debug['B'] && !n->bounded) { |
967 n1 = n3; | 970 n1 = n3; |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1700 regfree(&nodl); | 1703 regfree(&nodl); |
1701 return 0; | 1704 return 0; |
1702 | 1705 |
1703 yes: | 1706 yes: |
1704 if(freer) | 1707 if(freer) |
1705 regfree(&nodr); | 1708 regfree(&nodr); |
1706 if(freel) | 1709 if(freel) |
1707 regfree(&nodl); | 1710 regfree(&nodl); |
1708 return 1; | 1711 return 1; |
1709 } | 1712 } |
OLD | NEW |