3 ms·
Supplement: paradoxically, by reducing the optimization level, we can get the string literals to be preserved in that eq expression, and get deduplicated: 1>
by kazinator 4y ago
Supplement: paradoxically, by reducing the optimization level, we can get the string literals to be preserved in that eq expression, and get deduplicated:
1> (let ((*opt-level* 0))
(compile-toplevel '(eq "foo" "foo")))
#<sys:vm-desc: 9e48fd0>
2> [*1]
t
3> (disassemble *1)
data:
0: "foo"
syms:
0: eq
code:
0: 20020002 gcall t2 0 d0 d0
1: 04000000
2: 00000400
3: 10000002 end t2
instruction count:
2
#<sys:vm-desc: 9e48fd0>
Now there is a call to eq in the compiled code (index 0 in the function symbol table). The string literal is deduplicated and lives in the data register d0, which appears as both arguments to the function. Register t2 receives the result of the call, and the end instruction indicates that register as the result.