Mercurial > hg > CbC > old > device
changeset 580:31b736fb4516 environment-switch
*** empty log message ***
author | kono |
---|---|
date | Sun, 15 Jan 2006 22:32:17 +0900 |
parents | 74bea4129e15 |
children | ad9ef203f95b |
files | mc-codegen.c test/throw.c test/throw.code-out |
diffstat | 3 files changed, 130 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-codegen.c Sun Jan 15 19:48:43 2006 +0900 +++ b/mc-codegen.c Sun Jan 15 22:32:17 2006 +0900 @@ -932,7 +932,7 @@ /* source (after) list2(tag,disp) */ /* source list list3(e,cdr,sz) */ -#define DEBUG_PARALLEL_ASSIGN 0 +#define DEBUG_PARALLEL_ASSIGN 9 static int is_writable(int); @@ -1098,6 +1098,7 @@ #if DEBUG_PARALLEL_ASSIGN if (s1 && cadr(s1)==0) printf("## singleton %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz); + // this means singleton struct should be copied safely. else printf("## normal assign %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz); #endif @@ -1387,9 +1388,14 @@ target=list5(r, target,ty,e2,0); regs+=2; } else if (env) { while(car(e2)==RSTRUCT) e2=cadr(e2); + /* + envreg contains frame pointer, we need disp_offset. disp_offset + for code segment and function should be the same value. That is + fix_frame_pointer() is not allowed in this system. + */ g_expr_u(assign_expr0( list2(INDIRECT, - list3(ADD,rvalue_t(envreg,INT),list2(CONST,-arg_size-sz)) + list3(ADD,rvalue_t(envreg,INT),list2(CONST,-arg_size-sz+disp_offset)) ), e2,ty,ty)); } else { @@ -1622,7 +1628,7 @@ /* 一般的にはコピーのオーバラップの状況は実行時にしかわからない */ /* しかし、わかる場合もある */ if (is_same_type(e2,e4)) { - if(cadr(e2)<cadr(e4)) { offset=sz; sz=-sz;} + if(cadr(e2)>cadr(e4)) { offset=sz; sz=-sz;} else offset=0; det=1; } else {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/throw.c Sun Jan 15 22:32:17 2006 +0900 @@ -0,0 +1,114 @@ + +extern int printf(const char *,...); + +code (*ret)(); +void *env; + +#define ENVSIZE (1<<14) + +typedef +struct interface1 { + int a; + int b; + char c[100]; + int last; +} interface1; + +code +throw2(interface1 arg,int i,int j) +{ + goto ret(3),env; +} + +code +throw1(interface1 arg,int i,int j) +{ + printf("%d %d %d %d\n",arg.last,arg.a,arg.c[99],j); + arg.last=97; + goto throw2(arg,i,77); +} + +code +throw(interface1 arg,int i,int j) +{ + char *space = (char *)malloc(ENVSIZE)+ENVSIZE/2; + printf("%d %d %d %d\n",arg.last,arg.a,arg.c[99],j); + arg.last=98; + goto throw1(arg,i,77),space; +} + +void +setup(interface1 *arg) +{ + for(int i=0;i<100;i++) arg->c[i]=i; +} + +int +main0() +{ + interface1 arg; + + arg.a = 3; + arg.b = 55; + setup(&arg); + arg.c[99] = 66; + arg.last = 96; + + printf("main0\n"); + ret = return; + env = environment; + + goto throw(arg,1,0); +} + +int +main1() +{ + int dummy; + int dummy1; + interface1 arg; + char *space = (char *)malloc(ENVSIZE)+ENVSIZE/2; + + arg.a = 3; + arg.b = 55; + setup(&arg); + arg.c[99] = 66; + arg.last=99; + + printf("main1\n"); + ret = return; + env = environment; + + goto throw1(arg,1,0),space; +} + +int +main2() +{ + int dummy; + interface1 arg; + char *space = (char *)malloc(ENVSIZE)+ENVSIZE/2; + + arg.a = 3; + arg.b = 55; + setup(&arg); + arg.c[99] = 66; + arg.last=99; + + printf("main2\n"); + ret = return; + env = environment; + + goto throw1(arg,1,0); +} + +int +main() +{ + main0(); + main1(); + main2(); + return 0; +} + +/* end */