edebug.el: Better strip instrumentation from backtraces
Rework the code that "cleans" the backtrace for `edebug-pop-to-backtrace`.
The main changes are the following:
- Strip instrumentation from "everywhere" rather than trying to limit the
effect to "code" and leave "data" untouched. This is a worthy
goal, but it is quite difficult to do since code contains data
(so we ended up touching data anyway) and data can also
contain code.
The risk of accidentally removing something because it happens
to look like instrumentation is very low, whereas it was very common
for instrumentation to remain in the backtrace.
- Use a global hash-table to remember the work done, instead of
using separate hash-table for each element. By using a weak
hash-table we avoid the risk of leaks, and save a lot of work
since there's often a lot of subexpressions that appear
several times in the backtrace.
* lisp/emacs-lisp/edebug.el (edebug-make-enter-wrapper): Tweak code
layout so the comments are more clear.
(edebug-unwrap): Remove redundant patterns for `closure` and `lambda`.
Add `:closure-dont-trim-context` to the `edebug-enter` pattern,
so it also gets removed (this should have been done in commit
750bc57cbb8d).
(edebug--unwrap-cache): New var.
(edebug-unwrap*): Use it.
(edebug--unwrap1): Delete function. Merged into `edebug-unwrap*`.
Also apply unwrapping to the contents of byte-code functions since they
can refer to lambda expressions captured by the closure.
(edebug--symbol-prefixed-p): Rename from
`edebug--symbol-not-prefixed-p` and adjust meaning accordingly.
(edebug--strip-instrumentation): Adjust accordingly and simplify
a bit by unifying the "lambda" case and the "everything else" case.
(edebug--unwrap-frame): Use `cl-callf` and unwrap arguments even if
they've already been evaluated.
(cherry picked from commit
ef859d8b1b285fd22b083955a0e878a74d72ff41)