DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T f

⟦52b646b4f⟧ TextFile

    Length: 6524 (0x197c)
    Types: TextFile
    Names: »futures.h«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/gnu-31mar87/scheme/microcode/futures.h« 

TextFile

/*          Hey EMACS, this is -*- C -*- code!                 */

/****************************************************************
*                                                               *
*                         Copyright (c) 1985                    *
*               Massachusetts Institute of Technology           *
*                                                               *
* This material was developed by the Scheme project at the      *
* Massachusetts Institute of Technology, Department of          *
* Electrical Engineering and Computer Science.  Permission to   *
* copy this software, to redistribute it, and to use it for any *
* purpose is granted, subject to the following restrictions and *
* understandings.                                               *
*                                                               *
* 1. Any copy made of this software must include this copyright *
* notice in full.                                               *
*                                                               *
* 2. Users of this software agree to make their best efforts (a)*
* to return to the MIT Scheme project any improvements or       *
* extensions that they make, so that these may be included in   *
* future releases; and (b) to inform MIT of noteworthy uses of  *
* this software.                                                *
*                                                               *
* 3.  All materials developed as a consequence of the use of    *
* this software shall duly acknowledge such use, in accordance  *
* with the usual standards of acknowledging credit in academic  *
* research.                                                     *
*                                                               *
* 4. MIT has made no warrantee or representation that the       *
* operation of this software will be error-free, and MIT is     *
* under no obligation to provide any services, by way of        *
* maintenance, update, or otherwise.                            *
*                                                               *
* 5.  In conjunction with products arising from the use of this *
* material, there shall be no use of the name of the            *
* Massachusetts Institute of Technology nor of any adaptation   *
* thereof in any advertising, promotional, or sales literature  *
* without prior written consent from MIT in each case.          *
*                                                               *
****************************************************************/

/* File: FUTURES.H
 *
  * This file contains macros useful for dealing with futures
 */
\f


/* Data structure definition */

/* The IS_DETERMINED slot has one of the following type of values:
 *    #!FALSE if the value is not yet known
 *    #!TRUE  if the value is known and the garbage collector is free
 *            to remove the future object in favor of its value everywhere
 *    else    the value is known, but the GC must leave the future object
*/

#define FUTURE_VECTOR_HEADER	0
#define FUTURE_IS_DETERMINED	1
#define FUTURE_LOCK             2
#define FUTURE_VALUE		3	/* if known, else */
#define FUTURE_QUEUE		3	/* tasks waiting for value */
#define FUTURE_EXTRA_STUFF	4	/* rest for extensibility */

#define Future_Is_Locked(P)     \
	(Vector_Ref((P), FUTURE_LOCK) != NIL)
#define Future_Has_Value(P)	\
	(Vector_Ref((P), FUTURE_IS_DETERMINED) != NIL)
#define Future_Value(P)		\
	Vector_Ref((P), FUTURE_VALUE)
#define Future_Spliceable(P)	\
	((Vector_Ref((P), FUTURE_IS_DETERMINED) == TRUTH) &&	\
	 (Vector_Ref((P), FUTURE_LOCK) == NIL))

#ifdef COMPILE_FUTURES
/* Touch_In_Primitive is used by primitives which are not
 * strict in an    argument but which touch it none the less.
 */

#define Touch_In_Primitive(P, To_Where)				\
{ Pointer Value = (P);						\
  while (Type_Code(Value) == TC_FUTURE)				\
  { if Future_Has_Value(Value) Value = Future_Value(Value);     \
    else                                                        \
    { Back_Out_Of_Primitive();			       		\
     Will_Push(CONTINUATION_SIZE + (STACK_ENV_EXTRA_SLOTS+2));	\
      Save_Cont();						\
      Push(Value);						\
      Push(Get_Fixed_Obj_Slot(System_Scheduler));		\
      Push(STACK_FRAME_HEADER+1);				\
     Pushed();							\
      longjmp(*Back_To_Eval, PRIM_APPLY);			\
    }								\
  }								\
  To_Where = Value;				        	\
}
\f


/* NOTES ON FUTURES, derived from the rest of the interpreter code */

/* ASSUMPTION: The syntaxer is hereby assumed NEVER to generate primitive
   combinations unless the primitive itself is output in the code stream.
   Therefore, we don't have to explicitly check here that the expression
   register has a primitive in it.

   ASSUMPTION: The SYMBOL slot of a VARIABLE does NOT contain a future, nor
   do the cached lexical address slots.

   ASSUMPTION: Compiled code calls to the interpreter require the results
   be touched before returning to the compiled code.  This may be very wrong.

   ASSUMPTION: History objects are never created using futures.

   ASSUMPTION: State points, which are created only by the interpreter,
   never contain FUTUREs except possibly as the thunks (which are handled
   by the apply code).

*/

/* OPTIMIZATIONS (?):
   After a lot of discussion, we decided that variable reference will check
   whether a value stored in the environment is a determined future which
   is marked spliceable.  If so, it will splice out the future from the
   environment slot to speed up subsequent references.

   EQ? does a normal identity check and only if this fails does it touch the
   arguments.  The same thing does not speed up MEMQ or ASSQ in the normal
   case, so it is omitted there.

   The following are NOT done, but might be useful later
   (1) Splicing on SET! operations
   (2) Splicing at apply and/or primitive apply
   (3) Splicing all arguments when a primitive errors on any of them
   (4) Splicing within the Arg_n_Type macro rather than after longjmping
       to the error handler.
*/

/* KNOWN PROBLEMS:
   (1) Garbage collector should be modified to splice out futures.

   (2) Purify should be looked at and we should decide what to do about
       purifying an object with a reference to a future (it should probably
       become constant but not pure).

   (3) Look at Impurify and Side-Effect-Impurify to see if futures
       affect them in any way.
*/
\f


#else /* Futures not compiled */
#define Touch_In_Primitive(P, To_Where)		To_Where = (P)
#endif