putMemoryShipInDispatchMode() now puts both out and inCBD in infinite-recieve mode
[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         int MAX_BAG_SIZE = (1<<7)-1;
44         if (instructions.length > MAX_BAG_SIZE)
45             throw new RuntimeException("warning: code bag size is "+instructions.length+
46                                        ", which exceeds maximum of "+MAX_BAG_SIZE+
47                                        "; breaking into multiple bags");
48         this.program = program;
49         this.instructions = instructions;
50         this.baseAddress = baseAddress;
51     }
52
53 }