System.out.println("invoking...");
Context ctx = new Context(fleet);
LoopFactory lf;
- lf = new LoopFactory(ctx, memoryShip.getDock("inCBD"), 1);
- lf.literal( (run.baseAddress<<6) | run.instructions.length );
- lf.deliver();
- ctx.dispatch(fp);
+ fp.sendWord(memoryShip.getDock("inCBD").getDataDestination(),
+ new BitVector(fleet.getWordWidth()).set( (run.baseAddress<<6) | run.instructions.length ));
System.out.println("invoked.");
}
}
public CodeBag makeCodeBag(Context ctx) {
- Instruction[] instructions = ctx.emit();
- CodeBag codeBag = new CodeBag(this, instructions, leastUnallocatedAddress);
- System.out.println("instructions.length="+instructions.length);
- leastUnallocatedAddress += instructions.length;
- codeBags.add(codeBag);
- return codeBag;
+ return makeCodeBag(ctx.emit());
+ }
+
+ public CodeBag makeCodeBag(Instruction[] instructions) {
+ int MAX_BAG_SIZE = (1<<7)-1;
+ if (instructions.length > MAX_BAG_SIZE) {
+ System.out.println("warning: code bag size is "+instructions.length+
+ ", which exceeds maximum of "+MAX_BAG_SIZE+
+ "; breaking into multiple bags");
+ ArrayList<CodeBag> subBags = new ArrayList<CodeBag>();
+ for(int block=0; block<instructions.length; block+=MAX_BAG_SIZE) {
+ Instruction[] inst = new Instruction[Math.min(instructions.length-block, MAX_BAG_SIZE)];
+ System.arraycopy(instructions, block, inst, 0, inst.length);
+ subBags.add(makeCodeBag(inst));
+ }
+ throw new RuntimeException("FIXME: not done");
+
+ } else {
+ CodeBag codeBag = new CodeBag(this, instructions, leastUnallocatedAddress);
+ System.out.println("instructions.length="+instructions.length);
+ leastUnallocatedAddress += instructions.length;
+ codeBags.add(codeBag);
+ return codeBag;
+ }
}
}
\ No newline at end of file