View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide


The message passing scheme created for the 16 bit Oliver processor doesn't scale to larger machines. A Squeak 3.8 image, for example, would require a table 760MB in size! So an alternative scheme called "PIC Mode" (where PIC means "Polymorphic Inline Cache") was created.

The processor has a normal execution mode and a PIC mode. During normal execution instructions are fetched from the location in the code cache pointed to by the program counter. It doesn't fetch instructions directly from methods - you have to copy the bytecodes (or translate, if the processor doesn't directly execute bytecodes) to the code cache and jump there. Inside the processor there normally is an instruction cache.

Some instructions (like "send") can switch the processor to PIC mode. In that case instructions are fetched from a PIC cache instead of the code cache. The instruction doing the switch must supply a "type" parameter and the PIC cache is accessed with a 64 bit address. The PC part is the address of the instruction which switched to PIC mode and the instructions are streamed from the PIC cache without changing the PC. If the whole cache line is used then execution goes back to the normal mode at PC+1. PIC mode is also exited if any branch or call instructions are executed (but something like the Skip instruction in RISC42 would allow conditional execution without ending PIC mode).

So if you execute a send instruction then the next instruction is determined by the receiver's class (type). Suppose that this send bytecode is at PC=16r213412 in the code cache and that the PIC cache has five entries tagged as <16r213412,X> with five different values of X. If the receiver type doesn't match any of them we call the copier (or translator) to create a new entry. If the receiver type is one of those five, then several instructions (up to the size of a cache line) are executed as if they were inlined between 16r213412 and 16r213413. A very common case is for these instructions to simply call a given method, but for simple and short methods they could be the body of the method itself.

Some software has to manage all the related entries in the PIC cache and this is the source of type information when a method is being recompiled to generate more optimized code.

The two most obvious instructions for invoking the PIC Mode are ones that fetch a precalculated type from a register and another that fetches it from an addressed object (faster for the common case than the first). Two less obvious instructions would be tagged add and subtraction. They would check that the tags for both operands are valid and that the result is valid (no overflows and stuff like that) before saving the result, otherwise they will behave exactly like the previous instructions but with the type hardwired to SmallInteger.

Links to this Page

  • RISC42 last edited on 22 August 2008 at 11:55:58 pm by
  • BCMode last edited on 25 November 2006 at 8:12:29 pm by