updates to get some of the shutdown code to execute via Program
[fleet.git] / src / edu / berkeley / fleet / loops / CodeBag.java
1 package edu.berkeley.fleet.loops;
2 import edu.berkeley.fleet.api.*;
3 import java.util.*;
4 import java.net.*;
5
6 /**
7  *  A CodeBag represents the instructions of a Context along with
8  *  (compile-time) knowledge of where it resides.  Consequently, it is
9  *  meaningful to say "give me the sequence of instructions which will
10  *  invoke this CodeBag".
11  */
12 public class CodeBag {
13
14     /*
15      *                          SF         works       works @diff    ok for non   size    ships
16      * Dispatch Method       Crossings     @inbox?       docks?       tail call?   limit   consumed
17      * ------------------------------------------------------------------------------------------
18      * 
19      * Inline                    0           Y              N             N        Small  None
20      * 
21      * Inline literals           1           N              Y             Y        Tiny   None
22      *  w/ "dispatch"
23      * 
24      * Send CBD to               2+          N              Y             Y        None   None (mem ship)
25      * memory ship
26      * 
27      * Send token to             3+          Y              Y             Y        None   One Output Dock
28      * assistant outbox first
29      * 
30      * Release from FIFO         2           Y              Y             Y        Med    1x FIFO, but can be shared
31      * 
32      */
33
34     final Program program;
35     final Instruction[] instructions;
36     final long baseAddress;
37
38     /**
39      *  Given a Context, creates a CodeBag which will live in the
40      *  Memory ship memoryShip at the address given by baseAddress.
41      */
42     CodeBag(Program program, Instruction[] instructions, long baseAddress) {
43         this.program = program;
44         this.instructions = instructions;
45         this.baseAddress = baseAddress;
46
47         // FIXME
48         if (instructions.length >= (1<<7))
49             throw new RuntimeException("code bag size is "+instructions.length+", which exceeds maximum of "+((1<<7)-1));
50     }
51
52 }