[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How does runtime stack work?
From: |
Peng Yu |
Subject: |
Re: How does runtime stack work? |
Date: |
Sun, 23 May 2021 07:52:50 -0500 |
> If you have a portable (written in C, C++ or Java) translator T(L1,B) for a
> language L1 into some bytecode B and a portable interpreter I(B,*) for B on a
> machine M1, you can compile and execute L1 on M1.
In this case, the bytecode used by gawk does not have to be private to
gawk, but it can be a general bytecode?
I know that python and java use bytecode. But I am not aware that they
can easily be used out of their own respective contexts. Is there a
byte code implementation that is general enough to have a more
widespread use than their original design intent?
> To be able to do the same on machines M2, M3,..., you just compile T(L1,B)
> and I(B,*) for M2, M3,...
>
> If the bytecode B is well-designed, you can write another translator T(L2,B),
> which (given all the bytecode interpreters) will enable you to execute L2 on
> M1, M2, M3,... And so on for languages L3, L4,...
>
> There is a similar approach for compilers: if you divide a compiler in a
> frontend (parser) and a backend (code generator) designed to create and
> process respectively a syntax tree, you can write frontends for the languages
> and backends for the machines and combine them as required.
>
> For high-level languages, the execution time gap between interpretation and
> execution (compiled code) tends to be smaller than for a low-level language.
> Consider that a pattern matching operation will be compiled into a library
> routine call anyway, you just have a minimal overhead for a indirect
> (=interpreted) call.
There is still a difference between different bytecode choices. (My
recollection is that java bytecode is quite bloated, but I don't
remember python bytecode has such problems.) Is it so?
But python is still much slower than cython. So interpretation could
have a significant impact on performance.
> Much more computing time is wasted due to bad implementation decisions or
> poor algorithms, not due to the difference between interpretation and
> compilation.
For gawk, B is directly executed instead of translated to machine code
for execution? Therefore, the current gawk implementation is slower
than the case when there is a translation to machine code?
--
Regards,
Peng