[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/comp-static-data 821471c887: comp: Perma-mark all compiled const
From: |
Vibhav Pant |
Subject: |
scratch/comp-static-data 821471c887: comp: Perma-mark all compiled constants, declare them as const. |
Date: |
Wed, 16 Nov 2022 14:24:52 -0500 (EST) |
branch: scratch/comp-static-data
commit 821471c887e8bdcc2fe5d35a4e4c8a6ef1ce32de
Author: Vibhav Pant <vibhavp@gmail.com>
Commit: Vibhav Pant <vibhavp@gmail.com>
comp: Perma-mark all compiled constants, declare them as const.
* comp.c (emit_lisp_string_constructor_rval,
cons_block_emit_constructor, float_block_emit_constructor,
emit_comp_lisp_obj): Initialize objects generated with their mark
bit(s) set.
(comp_lisp_const_get_lisp_obj_rval): Declare constants as const
variables.
* alloc.c (pin_string): Don't set size_byte when it is already set to
-3, avoiding writing to read-only native compiled constants.
---
src/alloc.c | 3 ++-
src/comp.c | 37 ++++++++++++++++++++++++++-----------
2 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/src/alloc.c b/src/alloc.c
index 1911ac7763..69c5dba18c 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2527,7 +2527,8 @@ pin_string (Lisp_Object string)
old_sdata->string = NULL;
SDATA_NBYTES (old_sdata) = size;
}
- s->u.s.size_byte = -3;
+ if (s->u.s.size_byte != -3)
+ s->u.s.size_byte = -3;
}
diff --git a/src/comp.c b/src/comp.c
index c4c8cacf65..315ab4afff 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -2191,10 +2191,13 @@ emit_lisp_string_constructor_rval (Lisp_Object str)
// not attempt to modify them.
: gcc_jit_context_new_rvalue_from_int (comp.ctxt,
comp.ptrdiff_type, -3);
+ // Perma-mark all string constants, which lets us declare them as
+ // constants.
gcc_jit_rvalue *size
- = gcc_jit_context_new_rvalue_from_int (comp.ctxt,
- comp.ptrdiff_type,
- SCHARS (str));
+ = gcc_jit_context_new_rvalue_from_long (comp.ctxt,
+ comp.ptrdiff_type,
+ SCHARS (str)
+ | ARRAY_MARK_FLAG);
gcc_jit_field *u_s_fields[]
= { comp.lisp_string_u_s_size, comp.lisp_string_u_s_size_bytes,
comp.lisp_string_u_s_intervals, comp.lisp_string_u_s_data };
@@ -2563,10 +2566,12 @@ push_cons_block (void)
gcc_jit_lvalue *var
= gcc_jit_context_new_global (comp.ctxt, NULL,
GCC_JIT_GLOBAL_INTERNAL,
- comp.cons_block_aligned_type, name);
+ comp.cons_block_aligned_type,
+ name);
Lisp_Object entry
= CALLN (Fvector, make_mint_ptr (var), make_fixnum (-1),
- Fmake_vector (make_fixnum (cons_block_conses_length), Qnil));
+ Fmake_vector (make_fixnum (cons_block_conses_length),
+ Qnil));
comp.cons_block_list = Fcons (entry, comp.cons_block_list);
return entry;
}
@@ -2580,10 +2585,13 @@ push_float_block (void)
gcc_jit_lvalue *var
= gcc_jit_context_new_global (comp.ctxt, NULL,
GCC_JIT_GLOBAL_INTERNAL,
- comp.float_block_aligned_type, name);
+ gcc_jit_type_get_const (
+ comp.float_block_aligned_type),
+ name);
Lisp_Object entry
= CALLN (Fvector, make_mint_ptr (var), make_fixnum (-1),
- Fmake_vector (make_fixnum (float_block_floats_length), Qnil));
+ Fmake_vector (make_fixnum (float_block_floats_length),
+ Qnil));
comp.float_block_list = Fcons (entry, comp.float_block_list);
return entry;
}
@@ -2631,7 +2639,8 @@ cons_block_emit_constructor (Lisp_Object block)
SAFE_NALLOCA (gcmarkbits, 1, cons_block_gcmarkbits_length);
for (ptrdiff_t i = 0; i < cons_block_gcmarkbits_length; i++)
gcmarkbits[i]
- = gcc_jit_context_zero (comp.ctxt, comp.ptrdiff_type);
+ = gcc_jit_context_new_rvalue_from_int (comp.ctxt,
+ comp.ptrdiff_type, ~0u);
gcc_jit_field *fields[] = {
comp.cons_block_conses,
@@ -2681,7 +2690,8 @@ float_block_emit_constructor (Lisp_Object block)
SAFE_NALLOCA (gcmarkbits, 1, float_block_gcmarkbits_length);
for (ptrdiff_t i = 0; i < float_block_gcmarkbits_length; i++)
gcmarkbits[i]
- = gcc_jit_context_zero (comp.ctxt, comp.ptrdiff_type);
+ = gcc_jit_context_new_rvalue_from_int (comp.ctxt,
+ comp.ptrdiff_type, ~0u);
gcc_jit_field *fields[] = {
comp.float_block_floats,
@@ -2855,6 +2865,7 @@ comp_lisp_const_get_lisp_obj_rval (Lisp_Object lobj,
{
if (type_lisp_vector_p (type))
type = gcc_jit_type_get_aligned (type, GCALIGNMENT);
+ type = gcc_jit_type_get_const (type);
gcc_jit_lvalue *var
= emit_lisp_data_var (type, GCC_JIT_GLOBAL_INTERNAL);
@@ -2998,9 +3009,12 @@ emit_comp_lisp_obj (Lisp_Object obj,
expr.expr.with_type.init = lisp_float;
expr.expr.with_type.type = Lisp_Float;
}
- else if (VECTORP (obj))
+ else if (COMPILEDP (obj) || VECTORP (obj) || RECORDP (obj))
{
ptrdiff_t size = ASIZE (obj);
+ if (size & PSEUDOVECTOR_FLAG)
+ size &= PSEUDOVECTOR_SIZE_MASK;
+
ptrdiff_t i;
jit_vector_type_t vec_type
@@ -3058,7 +3072,8 @@ emit_comp_lisp_obj (Lisp_Object obj,
gcc_jit_rvalue *struct_values[] = {
gcc_jit_context_new_rvalue_from_int (comp.ctxt,
comp.ptrdiff_type,
- size),
+ ASIZE (obj)
+ | ARRAY_MARK_FLAG),
gcc_jit_context_new_array_constructor (comp.ctxt, NULL,
vec_type
.contents_type,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- scratch/comp-static-data 821471c887: comp: Perma-mark all compiled constants, declare them as const.,
Vibhav Pant <=