John writes:
::The UCSD
P-system was started by Dr. Ken Bowles, the director
::of the UCSD computer center. The p-code they developed has
::lived on, and remnants can be seen in the Java virtual machine!
Is there a description of the opcodes/bytecodes used in the p-code VM
anywhere?
I don't have one online. Really, there are several. P-code was
used in Wirth's early Pascal compilers, and it mutated with time
and improvements by others. UCSD made their own, but it too
changed with each major release.
IIRC, Wirth's original compiler was not p-code oriented, but emitted
machine code for whatever machine it was on. I recall the problems
that caused for Burroughs B6700 (MCP) machines, circa 1970-1972.
They relied 100% on compiler checking for security. Outside of array
bounds checking, there was literally no hardware security.
However, since no supported languages had pointers that were user
manipulatable, and there was no assembler (#1), this actually worked
(#2). (ALGOL's pointers weren't freely manipulatable).
When Pascal came along, I recall Jim Madden of UCSD Computer Center
adapting a very early version of Wirth's compiler it to emit
Burroughs machine code ... and then struggling
with how to prevent security problems because of the @#$% tagless
variant design.
I.e., because the Pascal standard failed to say something
robust like "compilers MUST have a secret tag to check the
value of tagless variants", people were able to implement peek/poke
with a tagless variant like:
type
foo_type = record
case integer of
0: (ip : ^ integer);
1: (i32 : integer);
{assumes pointers and integers are same size}
end;
var
foo : foo_type;
foo.i32 := some magic number
foo.ip^ := ... {poke!}
Note that if the type had been a tagged variant:
...
case foo_kind : integer of
then the compiler could (and should!) emit code to properly
secure the "ip" field of foo, based on the tag value.
In short, Pascal's refusal to implement type casting coupled with
a weak design for the case variant caused problems both for
code clarity and code security (on some machines).
In the UCSD case, I can't recall if Jim ever released the Pascal
compiler. (This is not the UCSD P system compiler, although
Jim worked for Dr. Bowles)
#1: At least two assemblers for B6500/B7700 MPE machines started
circulating "under the table" in the mid 1970s. One was from UC Davis,
and I can't recall the origin of the other one.
#2: If a user attempted to modify the code in a program file by
patching it, that changed the program file to a non-executable
data file.