[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [epsilon-devel] How to write a simple code generation which is not t
From: |
Luca Saiu |
Subject: |
Re: [epsilon-devel] How to write a simple code generation which is not terrible |
Date: |
Sat, 02 Feb 2019 16:11:30 +0100 |
User-agent: |
Gnus (Gnus v5.13), GNU Emacs 25.1.50.2, x86_64-unknown-linux-gnu |
-- Sorry. This is the hand-optimized version (I wrote the unoptimized
version twice by mistake):
instruction push-variable (?n 0 1, ?n 0 1 2 3 4 5)
code
int i;
const int depth = JITTER_ARGN0;
const int index = JITTER_ARGN1;
jitter_int res;
JITTER_PUSH_UNSPECIFIED_MAINSTACK();
for (i = 0; i < depth; i ++)
JITTER_STATE_RUNTIME_FIELD(env) = JITTER_STATE_RUNTIME_FIELD(env)->upper;
res = jitter_state_runtime.env->values [index];
JITTER_TOP_MAINSTACK() = res;
end
end
And the specialized instruction disassembly is the three-instruction
sequence I copied:
0x00007f56eb77e5e1 48 89 75 08 movq %rsi,0x8(%rbp)
0x00007f56eb77e5e5 49 8b 71 10 movq 0x10(%r9),%rsi
0x00007f56eb77e5e9 48 83 c5 08 addq $0x8,%rbp
It's easy to see that this version closely matches what the behavior of
machine-generated code obtaining the the stack effect separately from
assigning results to the appropriate l-values.
Awesome.
--
Luca Saiu
* GNU epsilon: http://www.gnu.org/software/epsilon
* My personal web site: http://ageinghacker.net
I support everyone's freedom of mocking any opinion or belief, no
matter how deeply held, with open disrespect and the same unrelented
enthusiasm of a toddler who has just learned the word "poo".
signature.asc
Description: PGP signature