[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
The mysterious ‘SCM_F_BYTEVECTOR_CONTIGUOUS’
From: |
Ludovic Courtès |
Subject: |
The mysterious ‘SCM_F_BYTEVECTOR_CONTIGUOUS’ |
Date: |
Wed, 11 Jan 2023 18:39:52 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Ludovic Courtès <ludo@gnu.org> skribis:
> This is an updated version of the ‘bytevector-slice’ primitive I used in
> the linker/assembler patch series¹ that I think is ready to go.
While working on this, I noticed I might have to pay attention to
‘SCM_F_BYTEVECTOR_CONTIGUOUS’, as noted in the patch.
But it turns out that flag isn’t really used. I found two places that
should add it and do not:
diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c
index 6b920c88a..fd7fdad0b 100644
--- a/libguile/bytevectors.c
+++ b/libguile/bytevectors.c
@@ -274,7 +274,8 @@ make_bytevector_from_buffer (size_t len, void *contents,
c_len = len * (scm_i_array_element_type_sizes[element_type] / 8);
- SCM_SET_BYTEVECTOR_FLAGS (ret, element_type);
+ SCM_SET_BYTEVECTOR_FLAGS (ret,
+ element_type | SCM_F_BYTEVECTOR_CONTIGUOUS);
SCM_BYTEVECTOR_SET_LENGTH (ret, c_len);
SCM_BYTEVECTOR_SET_CONTENTS (ret, contents);
SCM_BYTEVECTOR_SET_PARENT (ret, SCM_BOOL_F);
diff --git a/module/system/repl/debug.scm b/module/system/repl/debug.scm
diff --git a/module/system/vm/assembler.scm b/module/system/vm/assembler.scm
index 165976363..61e0460ff 100644
--- a/module/system/vm/assembler.scm
+++ b/module/system/vm/assembler.scm
@@ -1857,8 +1857,9 @@ should be .data or .rodata), and return the resulting
linker object.
(define tc7-program #x45)
(define tc7-bytevector #x4d)
- ;; This flag is intended to be left-shifted by 7 bits.
+ ;; These flags are intended to be left-shifted by 7 bits.
(define bytevector-immutable-flag #x200)
+ (define bytevector-contiguous-flag #x100)
(define tc7-array #x5d)
@@ -2026,6 +2027,7 @@ should be .data or .rodata), and return the resulting
linker object.
;; Bytevector immutable flag also shifted
;; left.
(ash (logior bytevector-immutable-flag
+ bytevector-contiguous-flag
(array-type-code obj))
7)))))
(case word-size
There are probably more.
Fundamentally, I’m not sure what this flag is supposed to mean. AFAICS,
there’s no way to create a non-contiguous bytevector (or SRFI-4 vector).
This flag was added in 7ed54fd36d2e381aa46ef8a7d2fc13a6776b573a. My
guess is that it was part of plan that wasn’t carried out in the end.
Andy, thoughts? :-)
Thanks,
Ludo’.
The mysterious ‘SCM_F_BYTEVECTOR_CONTIGUOUS’,
Ludovic Courtès <=
Re: [PATCH] Add 'bytevector-slice'., Maxime Devos, 2023/01/11
Re: [PATCH] Add 'bytevector-slice'., Ludovic Courtès, 2023/01/14