🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #2975

Re: Self-modifying code

#2975
From: Bj|rn Lisper
Date: Mon, 13 Nov 1989 12:19
33 lines
2156 bytes
In article <1989Nov6.172043.10373@world.std.com> bzs@world.std.com (Barry
Shein) writes:
%A common, general usage of self-modifying code is seen in interpreter
%(not necessarily, but often, programming languages) loops. Suppose you
%have the ability to trace or otherwise flag certain events. This is
%typically done by a check at the top of the loop:

%	IF request_is_flagged THEN do_flag_action

%The check for "request_is_flagged" can be quite expensive (say,
%hashing into a symbol table to see if a bit is set) and interpreters
%might have to go through this loop for every minor operation (eg. add
%two numbers.) If there are no items flagged or only certain subsets
%need to be checked one way to speed up this loop is to simply modify
%the top-level code so the check isn't done or loops back to a
%different check. ...

Some time ago I made a posting about the connection between partial
evaluation and self-modifying code. (Partial evaluation is simplifying
functions, or code, when the input is partially known. Self-modifying code
can be seen as partial evaluation at runtime.) The above was an instance I
though of when writing that posting. The rule

IF true THEN S => S

is used to simplify conditionals where the condition is known. This can be
done either at compile-time, if the condition is known then, or at run-time,
when the condition becomes known (and we know it will not change value).

Actually, I think partial evaluation would provide a quite clean theory for
an interesting class of self-modifying programs.

Bjorn Lisper
Technical Details
Message-ID: <BJORNL.89Nov13131942@octopus.tds.kth.se>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!bloom-beacon!eru!luth!sunic!sics.se!sics!bjornl
References: <1080@mipos3.intel.com> <2630@gandalf.UUCP> <1989Nov6.172043.10373@world.std.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!bloom-beacon!eru!luth!sunic!sics.se!sics!bjornl
From: bjornl@tds.kth.se (Bj|rn Lisper)
Newsgroups: comp.arch
Subject: Re: Self-modifying code
Message-ID: <BJORNL.89Nov13131942@octopus.tds.kth.se>
Date: 13 Nov 89 12:19:42 GMT
References: <1080@mipos3.intel.com> <2630@gandalf.UUCP> <1989Nov6.172043.10373@world.std.com>
Sender: news@sics.se
Organization: The Royal Inst. of Technology (KTH), Stockholm, Sweden.
Lines: 33
In-Reply-To: bzs@world.std.com's message of 6 Nov 89 17:20:43 GMT