[comp.arch] Self Modifying Code, was: m88200 cache flushes on DG Aviion

brett@cayman.amd.com (Brett Stewart) (12/15/90)

In article <PCG.90Dec13214759@odin.cs.aber.ac.uk> pcg@cs.aber.ac.uk (Piercarlo Grandi) writes:
>
>Oh yes, definitely. Self modifying code is of the essence. It is *vital*
>as a technique to support efficiently, especially on a RISC machine,
>many advanced programming language constructs. If you want to do just
>Fortran and C, no problem, but probably you don't want.
>
>Basically it is extremely important to be able to generate or modify
>small code sequences ("thunks") on the fly in many OO languages, and
>even in some older languages, and in many non OO languages as well, and
>in many other cases.
>
> [More justification for SMC omitted]

Or, consider the need for SMC implied by the following reference:
-----
MIMIC: A Fast System/370 Simulator,  May, C., IBM  Thomas J. 
Watson Research Center, Yorktown Heights, NY, USA

SIGPLAN Not.(USA) vol.22, no.7, pp.: 1-13, July 1987
(SIGPLAN'87 Symposium on Interpreters and Interpretive Techniques)

Abstract:  Software simulation of one computer on another tends 
to be slow.  Traditional simulators typically execute about 100 
instructions on the host machine per instruction simulated. Newer 
simulators reduce the expansion factor to about 10, by saving and 
reusing translations of individual instructions.  This paper 
describes an experimental simulator which takes the progression 
one step further, translating groups of instructions as a unit. 
This approach, combined with flow analysis, reduces the expansion 
factor to about 4. The new simulator simulates System/370 on a 
RISC, namely the IBM RT PC. 
-----
With these kinds of expansion factors, some RISC's can pretend to be
some CISC's fster than the real ones can actually be themselves.

At AMD we have run afoul of people who built systems with separate
I&D memories, who then got burned by a hidden need to do SMC in old
code.  Of course, there are also examples of people who didnt have
the concept of literal pool, who coded constants into their ROM in
I-space, and then discovered their system wouldnt work unless they
put buffers between I&D.

If you look at 500 different companies' historical code that Must
Work, you will find some strange stuff.
Brett Stewart
Advanced Micro Devices, Inc.           +1 512 462 5051 FAX
5900 E. Ben White Blvd MS561           +1 512 462 4336 Telephone
Austin, Texas 78741      USA           brett@cayman.amd.com