Forth like interpreter
Christian Tismer
tismer at tismer.com
Sun Mar 12 15:52:57 EST 2000
Darrell wrote:
>
> "Samuel A. Falvo II wrote:
> > For a detailed reason as to why this is/was, feel free to ask the
> > question in comp.lang.forth.
> >
> Went looking and found my self linked back to Python.
> http://starship.skyport.net/crew/vlad/archive/threaded_code/
Well, I looked into this technique a while before. It may help
for some compilers. On Windows with MSVC, the main switch
translates to
; 1115 : f->f_next_instr = next_instr;
; 1116 : f->f_stackpointer = stack_pointer;
; 1117 :
; 1118 : /* Main switch on opcode */
; 1119 :
; 1120 : switch (opcode) {
lea eax, DWORD PTR [ebx+7]
mov DWORD PTR [ebp+320], edi
cmp eax, 140 ; 0000008cH
mov DWORD PTR [ebp+324], esi
ja $L4460
xor edx, edx
mov dl, BYTE PTR $L6154[eax]
jmp DWORD PTR $L6155[edx*4]
The first two mov's are necessary for stackless and just
pipelined in.
The real "overhead" is the check on default (cmp eax, 140)
and in the double lookup. The "mov dl" maps to an index
into the address table.
It may count for Forth, but for Python this is very fast.
Note the "ebx+7" in the beginning. That's because I
added a few extra opcodes for error handling, which
are negative. The savings were great: Error variables
have so short lifetime that they never occupy registers.
ciao - chris (well this is nothing for C.L.P. I guess)
--
Christian Tismer :^) <mailto:tismer at appliedbiometrics.com>
Applied Biometrics GmbH : Have a break! Take a ride on Python's
Kaunstr. 26 : *Starship* http://starship.python.net
14163 Berlin : PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF
we're tired of banana software - shipped green, ripens at home
More information about the Python-list
mailing list