(COMPILED): Rename to CLOSURE

In preparation for the use of `PVEC_COMPILED` objects for
interpreted functions, rename them to use a more neutral name.

* src/lisp.h (enum pvec_type): Rename `PVEC_COMPILED` to `PVEC_CLOSURE`.
(enum Lisp_Compiled): Use `CLOSURE_` prefix i.s.o `COMPILED_`.
Also use `CODE` rather than `BYTECODE`.
(CLOSUREP): Rename from `COMPILEDP`.
(enum Lisp_Closure): Rename from `Lisp_Compiled`.

* src/alloc.c, src/bytecode.c, src/comp.c, src/data.c, src/eval.c,
* src/fns.c, src/lisp.h, src/lread.c, src/pdumper.c, src/print.c,
* src/profiler.c: Rename all uses accordingly.
* src/.gdbinit (xclosure): Rename from `xcompiled`.
(xcompiled): New obsolete alias.
(xpr): Adjust accordingly.  Also adjust to new PVEC_CLOSURE tag name.
This commit is contained in:
Stefan Monnier 2024-03-24 18:32:25 -04:00
parent 1e931f1c3d
commit 2fa839c188
13 changed files with 116 additions and 109 deletions

View file

@ -822,15 +822,22 @@ Print $ as a frame pointer.
This command assumes $ is an Emacs Lisp frame value.
end
define xcompiled
define xclosure
xgetptr $
print (struct Lisp_Vector *) $ptr
output ($->contents[0])@($->header.size & 0xff)
echo \n
end
document xclosure
Print $ as a function pointer.
This command assumes that $ is an Emacs Lisp byte-code or interpreted function value.
end
define xcompiled
xclosure
end
document xcompiled
Print $ as a compiled function pointer.
This command assumes that $ is an Emacs Lisp compiled value.
Obsolete alias for "xclosure".
end
define xwindow
@ -1038,8 +1045,8 @@ define xpr
if $vec == PVEC_FRAME
xframe
end
if $vec == PVEC_COMPILED
xcompiled
if $vec == PVEC_CLOSURE
xclosure
end
if $vec == PVEC_WINDOW
xwindow

View file

@ -3481,7 +3481,7 @@ cleanup_vector (struct Lisp_Vector *vector)
case PVEC_XWIDGET_VIEW:
case PVEC_TS_NODE:
case PVEC_SQLITE:
case PVEC_COMPILED:
case PVEC_CLOSURE:
case PVEC_CHAR_TABLE:
case PVEC_SUB_CHAR_TABLE:
case PVEC_RECORD:
@ -3813,17 +3813,17 @@ stack before executing the byte-code.
usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */)
(ptrdiff_t nargs, Lisp_Object *args)
{
if (! ((FIXNUMP (args[COMPILED_ARGLIST])
|| CONSP (args[COMPILED_ARGLIST])
|| NILP (args[COMPILED_ARGLIST]))
&& STRINGP (args[COMPILED_BYTECODE])
&& !STRING_MULTIBYTE (args[COMPILED_BYTECODE])
&& VECTORP (args[COMPILED_CONSTANTS])
&& FIXNATP (args[COMPILED_STACK_DEPTH])))
if (! ((FIXNUMP (args[CLOSURE_ARGLIST])
|| CONSP (args[CLOSURE_ARGLIST])
|| NILP (args[CLOSURE_ARGLIST]))
&& STRINGP (args[CLOSURE_CODE])
&& !STRING_MULTIBYTE (args[CLOSURE_CODE])
&& VECTORP (args[CLOSURE_CONSTANTS])
&& FIXNATP (args[CLOSURE_STACK_DEPTH])))
error ("Invalid byte-code object");
/* Bytecode must be immovable. */
pin_string (args[COMPILED_BYTECODE]);
pin_string (args[CLOSURE_CODE]);
/* We used to purecopy everything here, if purify-flag was set. This worked
OK for Emacs-23, but with Emacs-24's lexical binding code, it can be
@ -3833,7 +3833,7 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT
just wasteful and other times plainly wrong (e.g. those free vars may want
to be setcar'd). */
Lisp_Object val = Fvector (nargs, args);
XSETPVECTYPE (XVECTOR (val), PVEC_COMPILED);
XSETPVECTYPE (XVECTOR (val), PVEC_CLOSURE);
return val;
}
@ -3845,12 +3845,12 @@ usage: (make-closure PROTOTYPE &rest CLOSURE-VARS) */)
(ptrdiff_t nargs, Lisp_Object *args)
{
Lisp_Object protofun = args[0];
CHECK_TYPE (COMPILEDP (protofun), Qbyte_code_function_p, protofun);
CHECK_TYPE (CLOSUREP (protofun), Qbyte_code_function_p, protofun);
/* Create a copy of the constant vector, filling it with the closure
variables in the beginning. (The overwritten part should just
contain placeholder values.) */
Lisp_Object proto_constvec = AREF (protofun, COMPILED_CONSTANTS);
Lisp_Object proto_constvec = AREF (protofun, CLOSURE_CONSTANTS);
ptrdiff_t constsize = ASIZE (proto_constvec);
ptrdiff_t nvars = nargs - 1;
if (nvars > constsize)
@ -3866,7 +3866,7 @@ usage: (make-closure PROTOTYPE &rest CLOSURE-VARS) */)
struct Lisp_Vector *v = allocate_vectorlike (protosize, false);
v->header = XVECTOR (protofun)->header;
memcpy (v->contents, XVECTOR (protofun)->contents, protosize * word_size);
v->contents[COMPILED_CONSTANTS] = constvec;
v->contents[CLOSURE_CONSTANTS] = constvec;
return make_lisp_ptr (v, Lisp_Vectorlike);
}
@ -6046,7 +6046,7 @@ purecopy (Lisp_Object obj)
obj = make_lisp_hash_table (purecopy_hash_table (table));
}
else if (COMPILEDP (obj) || VECTORP (obj) || RECORDP (obj))
else if (CLOSUREP (obj) || VECTORP (obj) || RECORDP (obj))
{
struct Lisp_Vector *objp = XVECTOR (obj);
ptrdiff_t nbytes = vector_nbytes (objp);
@ -6059,7 +6059,7 @@ purecopy (Lisp_Object obj)
for (i = 0; i < size; i++)
vec->contents[i] = purecopy (vec->contents[i]);
/* Byte code strings must be pinned. */
if (COMPILEDP (obj) && size >= 2 && STRINGP (vec->contents[1])
if (CLOSUREP (obj) && size >= 2 && STRINGP (vec->contents[1])
&& !STRING_MULTIBYTE (vec->contents[1]))
pin_string (vec->contents[1]);
XSETVECTOR (obj, vec);
@ -8014,11 +8014,11 @@ symbol_uses_obj (Lisp_Object symbol, Lisp_Object obj)
return (EQ (val, obj)
|| EQ (sym->u.s.function, obj)
|| (!NILP (sym->u.s.function)
&& COMPILEDP (sym->u.s.function)
&& EQ (AREF (sym->u.s.function, COMPILED_BYTECODE), obj))
&& CLOSUREP (sym->u.s.function)
&& EQ (AREF (sym->u.s.function, CLOSURE_CODE), obj))
|| (!NILP (val)
&& COMPILEDP (val)
&& EQ (AREF (val, COMPILED_BYTECODE), obj)));
&& CLOSUREP (val)
&& EQ (AREF (val, CLOSURE_CODE), obj)));
}
/* Find at most FIND_MAX symbols which have OBJ as their value or
@ -8343,7 +8343,7 @@ union
enum CHECK_LISP_OBJECT_TYPE CHECK_LISP_OBJECT_TYPE;
enum DEFAULT_HASH_SIZE DEFAULT_HASH_SIZE;
enum Lisp_Bits Lisp_Bits;
enum Lisp_Compiled Lisp_Compiled;
enum Lisp_Closure Lisp_Closure;
enum maxargs maxargs;
enum MAX_ALLOCA MAX_ALLOCA;
enum More_Lisp_Bits More_Lisp_Bits;

View file

@ -479,7 +479,7 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
Lisp_Object *top = NULL;
unsigned char const *pc = NULL;
Lisp_Object bytestr = AREF (fun, COMPILED_BYTECODE);
Lisp_Object bytestr = AREF (fun, CLOSURE_CODE);
setup_frame: ;
eassert (!STRING_MULTIBYTE (bytestr));
@ -489,8 +489,8 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
when returning, to detect unwind imbalances. This would require adding
a field to the frame header. */
Lisp_Object vector = AREF (fun, COMPILED_CONSTANTS);
Lisp_Object maxdepth = AREF (fun, COMPILED_STACK_DEPTH);
Lisp_Object vector = AREF (fun, CLOSURE_CONSTANTS);
Lisp_Object maxdepth = AREF (fun, CLOSURE_STACK_DEPTH);
ptrdiff_t const_length = ASIZE (vector);
ptrdiff_t bytestr_length = SCHARS (bytestr);
Lisp_Object *vectorp = XVECTOR (vector)->contents;
@ -792,14 +792,14 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
/* Calls to symbols-with-pos don't need to be on the fast path. */
if (BARE_SYMBOL_P (call_fun))
call_fun = XBARE_SYMBOL (call_fun)->u.s.function;
if (COMPILEDP (call_fun))
if (CLOSUREP (call_fun))
{
Lisp_Object template = AREF (call_fun, COMPILED_ARGLIST);
Lisp_Object template = AREF (call_fun, CLOSURE_ARGLIST);
if (FIXNUMP (template))
{
/* Fast path for lexbound functions. */
fun = call_fun;
bytestr = AREF (call_fun, COMPILED_BYTECODE),
bytestr = AREF (call_fun, CLOSURE_CODE),
args_template = XFIXNUM (template);
nargs = call_nargs;
args = call_args;
@ -897,8 +897,8 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
bc->fp = fp;
Lisp_Object fun = fp->fun;
Lisp_Object bytestr = AREF (fun, COMPILED_BYTECODE);
Lisp_Object vector = AREF (fun, COMPILED_CONSTANTS);
Lisp_Object bytestr = AREF (fun, CLOSURE_CODE);
Lisp_Object vector = AREF (fun, CLOSURE_CONSTANTS);
bytestr_data = SDATA (bytestr);
vectorp = XVECTOR (vector)->contents;
if (BYTE_CODE_SAFE)
@ -974,8 +974,8 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
struct bc_frame *fp = bc->fp;
Lisp_Object fun = fp->fun;
Lisp_Object bytestr = AREF (fun, COMPILED_BYTECODE);
Lisp_Object vector = AREF (fun, COMPILED_CONSTANTS);
Lisp_Object bytestr = AREF (fun, CLOSURE_CODE);
Lisp_Object vector = AREF (fun, CLOSURE_CONSTANTS);
bytestr_data = SDATA (bytestr);
vectorp = XVECTOR (vector)->contents;
if (BYTE_CODE_SAFE)

View file

@ -5199,7 +5199,7 @@ maybe_defer_native_compilation (Lisp_Object function_name,
if (!native_comp_jit_compilation
|| noninteractive
|| !NILP (Vpurify_flag)
|| !COMPILEDP (definition)
|| !CLOSUREP (definition)
|| !STRINGP (Vload_true_file_name)
|| !suffix_p (Vload_true_file_name, ".elc")
|| !NILP (Fgethash (Vload_true_file_name, V_comp_no_native_file_h, Qnil)))

View file

@ -248,7 +248,7 @@ a fixed set of types. */)
return XSUBR (object)->max_args == UNEVALLED ? Qspecial_form
: SUBR_NATIVE_COMPILEDP (object) ? Qsubr_native_elisp
: Qprimitive_function;
case PVEC_COMPILED: return Qcompiled_function;
case PVEC_CLOSURE: return Qcompiled_function;
case PVEC_BUFFER: return Qbuffer;
case PVEC_CHAR_TABLE: return Qchar_table;
case PVEC_BOOL_VECTOR: return Qbool_vector;
@ -523,7 +523,7 @@ DEFUN ("byte-code-function-p", Fbyte_code_function_p, Sbyte_code_function_p,
doc: /* Return t if OBJECT is a byte-compiled function object. */)
(Lisp_Object object)
{
if (COMPILEDP (object))
if (CLOSUREP (object))
return Qt;
return Qnil;
}
@ -1143,19 +1143,19 @@ Value, if non-nil, is a list (interactive SPEC). */)
(*spec != '(') ? build_string (spec) :
Fcar (Fread_from_string (build_string (spec), Qnil, Qnil)));
}
else if (COMPILEDP (fun))
else if (CLOSUREP (fun))
{
if (PVSIZE (fun) > COMPILED_INTERACTIVE)
if (PVSIZE (fun) > CLOSURE_INTERACTIVE)
{
Lisp_Object form = AREF (fun, COMPILED_INTERACTIVE);
Lisp_Object form = AREF (fun, CLOSURE_INTERACTIVE);
/* The vector form is the new form, where the first
element is the interactive spec, and the second is the
command modes. */
return list2 (Qinteractive, VECTORP (form) ? AREF (form, 0) : form);
}
else if (PVSIZE (fun) > COMPILED_DOC_STRING)
else if (PVSIZE (fun) > CLOSURE_DOC_STRING)
{
Lisp_Object doc = AREF (fun, COMPILED_DOC_STRING);
Lisp_Object doc = AREF (fun, CLOSURE_DOC_STRING);
/* An invalid "docstring" is a sign that we have an OClosure. */
genfun = !(NILP (doc) || VALID_DOCSTRING_P (doc));
}
@ -1225,11 +1225,11 @@ The value, if non-nil, is a list of mode name symbols. */)
{
return XSUBR (fun)->command_modes;
}
else if (COMPILEDP (fun))
else if (CLOSUREP (fun))
{
if (PVSIZE (fun) <= COMPILED_INTERACTIVE)
if (PVSIZE (fun) <= CLOSURE_INTERACTIVE)
return Qnil;
Lisp_Object form = AREF (fun, COMPILED_INTERACTIVE);
Lisp_Object form = AREF (fun, CLOSURE_INTERACTIVE);
if (VECTORP (form))
/* New form -- the second element is the command modes. */
return AREF (form, 1);
@ -2546,7 +2546,7 @@ or a byte-code object. IDX starts at 0. */)
ptrdiff_t size = 0;
if (VECTORP (array))
size = ASIZE (array);
else if (COMPILEDP (array) || RECORDP (array))
else if (CLOSUREP (array) || RECORDP (array))
size = PVSIZE (array);
else
wrong_type_argument (Qarrayp, array);

View file

@ -519,15 +519,15 @@ store_function_docstring (Lisp_Object obj, EMACS_INT offset)
/* Lisp_Subrs have a slot for it. */
if (SUBRP (fun))
XSUBR (fun)->doc = offset;
else if (COMPILEDP (fun))
else if (CLOSUREP (fun))
{
/* This bytecode object must have a slot for the docstring, since
we've found a docstring for it. */
if (PVSIZE (fun) > COMPILED_DOC_STRING
if (PVSIZE (fun) > CLOSURE_DOC_STRING
/* Don't overwrite a non-docstring value placed there, such as
the symbols used for Oclosures. */
&& VALID_DOCSTRING_P (AREF (fun, COMPILED_DOC_STRING)))
ASET (fun, COMPILED_DOC_STRING, make_fixnum (offset));
&& VALID_DOCSTRING_P (AREF (fun, CLOSURE_DOC_STRING)))
ASET (fun, CLOSURE_DOC_STRING, make_fixnum (offset));
else
{
AUTO_STRING (format, "No doc string slot for compiled: %S");

View file

@ -2151,15 +2151,15 @@ then strings and vectors are not accepted. */)
return Qt;
}
/* Bytecode objects are interactive if they are long enough to
have an element whose index is COMPILED_INTERACTIVE, which is
have an element whose index is CLOSURE_INTERACTIVE, which is
where the interactive spec is stored. */
else if (COMPILEDP (fun))
else if (CLOSUREP (fun))
{
if (PVSIZE (fun) > COMPILED_INTERACTIVE)
if (PVSIZE (fun) > CLOSURE_INTERACTIVE)
return Qt;
else if (PVSIZE (fun) > COMPILED_DOC_STRING)
else if (PVSIZE (fun) > CLOSURE_DOC_STRING)
{
Lisp_Object doc = AREF (fun, COMPILED_DOC_STRING);
Lisp_Object doc = AREF (fun, CLOSURE_DOC_STRING);
/* An invalid "docstring" is a sign that we have an OClosure. */
genfun = !(NILP (doc) || VALID_DOCSTRING_P (doc));
}
@ -2567,7 +2567,7 @@ eval_sub (Lisp_Object form)
}
}
}
else if (COMPILEDP (fun)
else if (CLOSUREP (fun)
|| SUBR_NATIVE_COMPILED_DYNP (fun)
|| MODULE_FUNCTIONP (fun))
return apply_lambda (fun, original_args, count);
@ -2945,7 +2945,7 @@ FUNCTIONP (Lisp_Object object)
if (SUBRP (object))
return XSUBR (object)->max_args != UNEVALLED;
else if (COMPILEDP (object) || MODULE_FUNCTIONP (object))
else if (CLOSUREP (object) || MODULE_FUNCTIONP (object))
return true;
else if (CONSP (object))
{
@ -2967,7 +2967,7 @@ funcall_general (Lisp_Object fun, ptrdiff_t numargs, Lisp_Object *args)
if (SUBRP (fun) && !SUBR_NATIVE_COMPILED_DYNP (fun))
return funcall_subr (XSUBR (fun), numargs, args);
else if (COMPILEDP (fun)
else if (CLOSUREP (fun)
|| SUBR_NATIVE_COMPILED_DYNP (fun)
|| MODULE_FUNCTIONP (fun))
return funcall_lambda (fun, numargs, args);
@ -3181,9 +3181,9 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, Lisp_Object *arg_vector)
else
xsignal1 (Qinvalid_function, fun);
}
else if (COMPILEDP (fun))
else if (CLOSUREP (fun))
{
syms_left = AREF (fun, COMPILED_ARGLIST);
syms_left = AREF (fun, CLOSURE_ARGLIST);
/* Bytecode objects using lexical binding have an integral
ARGLIST slot value: pass the arguments to the byte-code
engine directly. */
@ -3315,7 +3315,7 @@ function with `&rest' args, or `unevalled' for a special form. */)
if (SUBRP (function))
result = Fsubr_arity (function);
else if (COMPILEDP (function))
else if (CLOSUREP (function))
result = lambda_arity (function);
#ifdef HAVE_MODULES
else if (MODULE_FUNCTIONP (function))
@ -3363,9 +3363,9 @@ lambda_arity (Lisp_Object fun)
else
xsignal1 (Qinvalid_function, fun);
}
else if (COMPILEDP (fun))
else if (CLOSUREP (fun))
{
syms_left = AREF (fun, COMPILED_ARGLIST);
syms_left = AREF (fun, CLOSURE_ARGLIST);
if (FIXNUMP (syms_left))
return get_byte_code_arity (syms_left);
}

View file

@ -152,7 +152,7 @@ efficient. */)
val = MAX_CHAR;
else if (BOOL_VECTOR_P (sequence))
val = bool_vector_size (sequence);
else if (COMPILEDP (sequence) || RECORDP (sequence))
else if (CLOSUREP (sequence) || RECORDP (sequence))
val = PVSIZE (sequence);
else
wrong_type_argument (Qsequencep, sequence);
@ -1054,7 +1054,7 @@ concat_to_list (ptrdiff_t nargs, Lisp_Object *args, Lisp_Object last_tail)
else if (NILP (arg))
;
else if (VECTORP (arg) || STRINGP (arg)
|| BOOL_VECTOR_P (arg) || COMPILEDP (arg))
|| BOOL_VECTOR_P (arg) || CLOSUREP (arg))
{
ptrdiff_t arglen = XFIXNUM (Flength (arg));
ptrdiff_t argindex_byte = 0;
@ -1114,7 +1114,7 @@ concat_to_vector (ptrdiff_t nargs, Lisp_Object *args)
{
Lisp_Object arg = args[i];
if (!(VECTORP (arg) || CONSP (arg) || NILP (arg) || STRINGP (arg)
|| BOOL_VECTOR_P (arg) || COMPILEDP (arg)))
|| BOOL_VECTOR_P (arg) || CLOSUREP (arg)))
wrong_type_argument (Qsequencep, arg);
EMACS_INT len = XFIXNAT (Flength (arg));
result_len += len;
@ -1170,7 +1170,7 @@ concat_to_vector (ptrdiff_t nargs, Lisp_Object *args)
}
else
{
eassert (COMPILEDP (arg));
eassert (CLOSUREP (arg));
ptrdiff_t size = PVSIZE (arg);
memcpy (dst, XVECTOR (arg)->contents, size * sizeof *dst);
dst += size;
@ -2949,7 +2949,7 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind,
if (size & PSEUDOVECTOR_FLAG)
{
if (((size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_AREA_BITS)
< PVEC_COMPILED)
< PVEC_CLOSURE)
return false;
size &= PSEUDOVECTOR_SIZE_MASK;
}
@ -3346,7 +3346,7 @@ mapcar1 (EMACS_INT leni, Lisp_Object *vals, Lisp_Object fn, Lisp_Object seq)
tail = XCDR (tail);
}
}
else if (VECTORP (seq) || COMPILEDP (seq))
else if (VECTORP (seq) || CLOSUREP (seq))
{
for (ptrdiff_t i = 0; i < leni; i++)
{
@ -5512,7 +5512,7 @@ sxhash_obj (Lisp_Object obj, int depth)
case Lisp_Vectorlike:
{
enum pvec_type pvec_type = PSEUDOVECTOR_TYPE (XVECTOR (obj));
if (! (PVEC_NORMAL_VECTOR < pvec_type && pvec_type < PVEC_COMPILED))
if (! (PVEC_NORMAL_VECTOR < pvec_type && pvec_type < PVEC_CLOSURE))
{
/* According to the CL HyperSpec, two arrays are equal only if
they are 'eq', except for strings and bit-vectors. In

View file

@ -1049,7 +1049,7 @@ enum pvec_type
PVEC_SQLITE,
/* These should be last, for internal_equal and sxhash_obj. */
PVEC_COMPILED,
PVEC_CLOSURE,
PVEC_CHAR_TABLE,
PVEC_SUB_CHAR_TABLE,
PVEC_RECORD,
@ -3223,16 +3223,16 @@ XFLOAT_DATA (Lisp_Object f)
#define IEEE_FLOATING_POINT (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
&& FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
/* Meanings of slots in a Lisp_Compiled: */
/* Meanings of slots in a Lisp_Closure: */
enum Lisp_Compiled
enum Lisp_Closure
{
COMPILED_ARGLIST = 0,
COMPILED_BYTECODE = 1,
COMPILED_CONSTANTS = 2,
COMPILED_STACK_DEPTH = 3,
COMPILED_DOC_STRING = 4,
COMPILED_INTERACTIVE = 5
CLOSURE_ARGLIST = 0,
CLOSURE_CODE = 1,
CLOSURE_CONSTANTS = 2,
CLOSURE_STACK_DEPTH = 3,
CLOSURE_DOC_STRING = 4,
CLOSURE_INTERACTIVE = 5
};
/* Flag bits in a character. These also get used in termhooks.h.
@ -3307,9 +3307,9 @@ WINDOW_CONFIGURATIONP (Lisp_Object a)
}
INLINE bool
COMPILEDP (Lisp_Object a)
CLOSUREP (Lisp_Object a)
{
return PSEUDOVECTORP (a, PVEC_COMPILED);
return PSEUDOVECTORP (a, PVEC_CLOSURE);
}
INLINE bool

View file

@ -3498,52 +3498,52 @@ bytecode_from_rev_list (Lisp_Object elems, Lisp_Object readcharfun)
Lisp_Object *vec = XVECTOR (obj)->contents;
ptrdiff_t size = ASIZE (obj);
if (infile && size >= COMPILED_CONSTANTS)
if (infile && size >= CLOSURE_CONSTANTS)
{
/* Always read 'lazily-loaded' bytecode (generated by the
`byte-compile-dynamic' feature prior to Emacs 30) eagerly, to
avoid code in the fast path during execution. */
if (CONSP (vec[COMPILED_BYTECODE])
&& FIXNUMP (XCDR (vec[COMPILED_BYTECODE])))
vec[COMPILED_BYTECODE] = get_lazy_string (vec[COMPILED_BYTECODE]);
if (CONSP (vec[CLOSURE_CODE])
&& FIXNUMP (XCDR (vec[CLOSURE_CODE])))
vec[CLOSURE_CODE] = get_lazy_string (vec[CLOSURE_CODE]);
/* Lazily-loaded bytecode is represented by the constant slot being nil
and the bytecode slot a (lazily loaded) string containing the
print representation of (BYTECODE . CONSTANTS). Unpack the
pieces by coerceing the string to unibyte and reading the result. */
if (NILP (vec[COMPILED_CONSTANTS]) && STRINGP (vec[COMPILED_BYTECODE]))
if (NILP (vec[CLOSURE_CONSTANTS]) && STRINGP (vec[CLOSURE_CODE]))
{
Lisp_Object enc = vec[COMPILED_BYTECODE];
Lisp_Object enc = vec[CLOSURE_CODE];
Lisp_Object pair = Fread (Fcons (enc, readcharfun));
if (!CONSP (pair))
invalid_syntax ("Invalid byte-code object", readcharfun);
vec[COMPILED_BYTECODE] = XCAR (pair);
vec[COMPILED_CONSTANTS] = XCDR (pair);
vec[CLOSURE_CODE] = XCAR (pair);
vec[CLOSURE_CONSTANTS] = XCDR (pair);
}
}
if (!(size >= COMPILED_STACK_DEPTH + 1 && size <= COMPILED_INTERACTIVE + 1
&& (FIXNUMP (vec[COMPILED_ARGLIST])
|| CONSP (vec[COMPILED_ARGLIST])
|| NILP (vec[COMPILED_ARGLIST]))
&& STRINGP (vec[COMPILED_BYTECODE])
&& VECTORP (vec[COMPILED_CONSTANTS])
&& FIXNATP (vec[COMPILED_STACK_DEPTH])))
if (!(size >= CLOSURE_STACK_DEPTH + 1 && size <= CLOSURE_INTERACTIVE + 1
&& (FIXNUMP (vec[CLOSURE_ARGLIST])
|| CONSP (vec[CLOSURE_ARGLIST])
|| NILP (vec[CLOSURE_ARGLIST]))
&& STRINGP (vec[CLOSURE_CODE])
&& VECTORP (vec[CLOSURE_CONSTANTS])
&& FIXNATP (vec[CLOSURE_STACK_DEPTH])))
invalid_syntax ("Invalid byte-code object", readcharfun);
if (STRING_MULTIBYTE (vec[COMPILED_BYTECODE]))
if (STRING_MULTIBYTE (vec[CLOSURE_CODE]))
/* BYTESTR must have been produced by Emacs 20.2 or earlier
because it produced a raw 8-bit string for byte-code and
now such a byte-code string is loaded as multibyte with
raw 8-bit characters converted to multibyte form.
Convert them back to the original unibyte form. */
vec[COMPILED_BYTECODE] = Fstring_as_unibyte (vec[COMPILED_BYTECODE]);
vec[CLOSURE_CODE] = Fstring_as_unibyte (vec[CLOSURE_CODE]);
/* Bytecode must be immovable. */
pin_string (vec[COMPILED_BYTECODE]);
pin_string (vec[CLOSURE_CODE]);
XSETPVECTYPE (XVECTOR (obj), PVEC_COMPILED);
XSETPVECTYPE (XVECTOR (obj), PVEC_CLOSURE);
return obj;
}
@ -4678,7 +4678,7 @@ substitute_object_recurse (struct subst *subst, Lisp_Object subtree)
if (BOOL_VECTOR_P (subtree))
return subtree; /* No sub-objects anyway. */
else if (CHAR_TABLE_P (subtree) || SUB_CHAR_TABLE_P (subtree)
|| COMPILEDP (subtree) || HASH_TABLE_P (subtree)
|| CLOSUREP (subtree) || HASH_TABLE_P (subtree)
|| RECORDP (subtree))
length = PVSIZE (subtree);
else if (VECTORP (subtree))

View file

@ -3068,7 +3068,7 @@ dump_vectorlike (struct dump_context *ctx,
error_unsupported_dump_object(ctx, lv, "font");
FALLTHROUGH;
case PVEC_NORMAL_VECTOR:
case PVEC_COMPILED:
case PVEC_CLOSURE:
case PVEC_CHAR_TABLE:
case PVEC_SUB_CHAR_TABLE:
case PVEC_RECORD:

View file

@ -1299,7 +1299,7 @@ print (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
(STRINGP (obj) \
|| CONSP (obj) \
|| (VECTORLIKEP (obj) \
&& (VECTORP (obj) || COMPILEDP (obj) \
&& (VECTORP (obj) || CLOSUREP (obj) \
|| CHAR_TABLE_P (obj) || SUB_CHAR_TABLE_P (obj) \
|| HASH_TABLE_P (obj) || FONTP (obj) \
|| RECORDP (obj))) \
@ -2091,7 +2091,7 @@ print_vectorlike_unreadable (Lisp_Object obj, Lisp_Object printcharfun,
/* Types handled earlier. */
case PVEC_NORMAL_VECTOR:
case PVEC_RECORD:
case PVEC_COMPILED:
case PVEC_CLOSURE:
case PVEC_CHAR_TABLE:
case PVEC_SUB_CHAR_TABLE:
case PVEC_HASH_TABLE:
@ -2559,7 +2559,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
print_stack_push_vector ("#s(", ")", obj, 0, PVSIZE (obj),
printcharfun);
goto next_obj;
case PVEC_COMPILED:
case PVEC_CLOSURE:
print_stack_push_vector ("#[", "]", obj, 0, PVSIZE (obj),
printcharfun);
goto next_obj;

View file

@ -170,7 +170,7 @@ trace_hash (Lisp_Object *trace, int depth)
{
Lisp_Object f = trace[i];
EMACS_UINT hash1
= (COMPILEDP (f) ? XHASH (AREF (f, COMPILED_BYTECODE))
= (CLOSUREP (f) ? XHASH (AREF (f, CLOSURE_CODE))
: (CONSP (f) && CONSP (XCDR (f)) && BASE_EQ (Qclosure, XCAR (f)))
? XHASH (XCDR (XCDR (f))) : XHASH (f));
hash = sxhash_combine (hash, hash1);
@ -675,8 +675,8 @@ the same lambda expression, or are really unrelated function. */)
bool res;
if (EQ (f1, f2))
res = true;
else if (COMPILEDP (f1) && COMPILEDP (f2))
res = EQ (AREF (f1, COMPILED_BYTECODE), AREF (f2, COMPILED_BYTECODE));
else if (CLOSUREP (f1) && CLOSUREP (f2))
res = EQ (AREF (f1, CLOSURE_CODE), AREF (f2, CLOSURE_CODE));
else if (CONSP (f1) && CONSP (f2) && CONSP (XCDR (f1)) && CONSP (XCDR (f2))
&& EQ (Qclosure, XCAR (f1))
&& EQ (Qclosure, XCAR (f2)))