Backport: Make checking for liveness of global values more precise.

We can't just use a hash lookup because a global and a local reference
might refer to the same Lisp object.

* src/emacs-module.c (module_free_global_ref): More precise check for
global liveness.

(cherry picked from commit 9f01ce63)
1 job for emacs-27 in 69 minutes and 28 seconds (queued for 2 seconds)
Status Job ID Name Coverage
passed #6781