jaffer@zurich.ai.mit.edu (Aubrey Jaffer) (05/03/91)
Return-Path: <jclark!@bugs.specialix.co.uk.jjc> Date: Thu, 2 May 91 11:10:07 BST From: James Clark <jclark!jjc@uunet.UU.NET> To: jaffer@altdorf.ai.mit.edu In-Reply-To: Aubrey Jaffer's message of Wed, 1 May 91 14:44:57 edt <9105011846.AA27283@relay1.UU.NET> > Is there any prospect of scm supporting full continuations on the > Sun 4? I think it ought to be possible with a little bit of assembly. I think the problem is to flush all the register caches. I tried making lots of superflous calls bejore saving the stack but it did not work.... I've had a go at fixing it. It seems to be easier than I thought it would be. I modified sys.c like this: *** dist/sys.c Fri Apr 26 16:45:07 1991 --- sys.c Thu May 2 10:52:34 1991 *************** *** 1030,1035 **** --- 1031,1037 ---- register SCM *src,*dst; NEWCELL(cont); DEFER_SIGINT; + FLUSH_REGISTER_WINDOWS; SETLENGTH(cont,stack_size(stack_start_ptr),tc7_contin); SETJMPBUF(cont,must_malloc(sizeof(jmp_buf)+LENGTH(cont)*sizeof(SCM *) ,"continuation")); *************** *** 1057,1062 **** --- 1059,1065 ---- dst -= LENGTH(cont); if (dst <= (SCMPTR)&cont) grow_throw(cont,val); #endif + FLUSH_REGISTER_WINDOWS; src = (SCM *)(CHARS(cont)+sizeof(jmp_buf)); for (j = LENGTH(cont);0 <= --j;) *dst++ = *src++; #endif and config.h like this: *** dist/config.h Fri Apr 26 16:44:29 1991 --- config.h Thu May 2 10:52:12 1991 *************** *** 61,74 **** /* If you only need straight stack continuations CHEAP_CONTINUATIONS will run faster and use less storage than not having it. Machines ! with unusual stacks (such as vax and SUN-4) need this. */ /* #define CHEAP_CONTINUATIONS */ #ifdef vms #define CHEAP_CONTINUATIONS #endif #ifdef sparc ! #define CHEAP_CONTINUATIONS #endif /* LINE_INCREMENTORS are the characters which cause the line count to --- 61,79 ---- /* If you only need straight stack continuations CHEAP_CONTINUATIONS will run faster and use less storage than not having it. Machines ! with unusual stacks (such as vax) need this. */ /* #define CHEAP_CONTINUATIONS */ #ifdef vms #define CHEAP_CONTINUATIONS #endif + + /* Some magic needed for full continuations on the sparc. */ + #ifdef sparc ! #define FLUSH_REGISTER_WINDOWS asm("ta 3") ! #else ! #define FLUSH_REGISTER_WINDOWS /* empty */ #endif /* LINE_INCREMENTORS are the characters which cause the line count to I tested it out with (test-cont) in test.scm and I was amazed to find that it actually worked. An alternative approach that would be to have an assembly language file like this: .globl _flush_register_windows _flush_register_windows: ta 3 retl nop and then do #define FLUSH_REGISTER_WINDOWS flush_register_windows() in config.h. This would be less compiler dependent, but is a bit more hassle. I don't have any other code that uses non-stack continuations, so you might want to test it out some more (if you don't have access to a Sun 4, I'll be happy to run any tests you send me). I can't quite believe that it's this simple.