Commit Graph

4173 Commits

Author SHA1 Message Date
Bennet Bleßmann
cbdd0fbf15 make Fixnum::build_with harder to accidentally misuse
change trait bound order for better
2025-07-07 22:39:34 -07:00
bakaq
87ca083cfa Align the heap to the size of heap cells 2025-07-07 22:38:12 -07:00
bakaq
d01557f3c1 Add scan_slice_to_str_from_start 2025-07-07 22:38:12 -07:00
Mark Thom
8b009448f4 correct threshold marking in copy_structure (#2920) 2025-07-07 22:38:12 -07:00
Markus Triska
709dc041eb FIXED: correct partial string tail calculation in arg/3
This addresses another aspect of #2924, found by @haijinSk.
Thank you again!

Example:

    ?- "aaaaaaa" = [_,_,_,_,_,_|T], arg(2, T, 2).
       false.
2025-07-07 22:38:12 -07:00
Markus Triska
8763a42c98 FIXED: arg/3 for partial strings
This address #2924, reported by @haijinSk. Thank you a lot!

Example:

    ?- arg(2, "a", A).
       A = [].

The fact that such a mistake in macro usage is even possible could be
a sign that the macro definition should be stricter.
2025-07-07 22:38:12 -07:00
Mark Thom
d6b6eda77d fix cont function crashes (#2920) 2025-07-07 22:38:12 -07:00
Mark Thom
4e0493474e replace deprecated unify_complete_string call with allocate_cstr 2025-07-07 22:38:12 -07:00
bakaq
a9847eef65 Migrate to strict and exposed provenance 2025-07-07 22:38:12 -07:00
Mark Thom
cb9b988905 allow unused_parens around let statement in functor! macro 2025-07-07 22:38:12 -07:00
Markus Triska
073ec4c1d0 FIXED: invoke correct predicate
Noted by Oleg Finkelstein. Many thanks!
2025-07-07 22:38:12 -07:00
Markus Triska
d51cbd67e0 ENHANCED: partial_string/3 no longer creates atoms
As a consequence, resulting strings are now quickly reclaimed on
backtracking.

This addresses #2912.

Test case:

    :- use_module(library(iso_ext)).
    :- use_module(library(lists)).

    ab(a).
    ab(b).

Sample query:

    ?- length(Ls, 1_000_000),
       maplist(ab, Ls),
       partial_string(Ls, Es0, []),
       Es0 == Ls.
       Ls = "aaaaaaaaaaaaaaaaaaa ...", Es0 = "aaaaaaaaaaaaaaaaaaa ..."
    ;  Ls = "aaaaaaaaaaaaaaaaaaa ...", Es0 = "aaaaaaaaaaaaaaaaaaa ..."
    ;  Ls = "aaaaaaaaaaaaaaaaaaa ...", Es0 = "aaaaaaaaaaaaaaaaaaa ..."
    ;  Ls = "aaaaaaaaaaaaaaaaaaa ...", Es0 = "aaaaaaaaaaaaaaaaaaa ..."
    ;  Ls = "aaaaaaaaaaaaaaaaaaa ...", Es0 = "aaaaaaaaaaaaaaaaaaa ..."
    ;  ... .

running in constant memory.
2025-07-07 22:38:12 -07:00
Markus Triska
e9bb41f0d6 ENHANCED: use a fast test for the expected case of chars in atom_chars/2 etc.
Suggested by Oleg Finkelstein, thank you a lot!

Example, before this change:

    ?- t+\(length(As, 1_000_000), maplist(=(a), As), time(atom_chars(A, As))).
       % CPU time: 0.693s, 7_000_041 inferences
       true.

Now:

    ?- t+\(length(As, 1_000_000), maplist(=(a), As), time(atom_chars(A, As))).
       % CPU time: 0.080s, 40 inferences
       true.

This also partially ameliorates #2907.
2025-07-07 22:38:12 -07:00
Mark Thom
b12d1ece17 correct heap-to-cell-index comparison in copy_slice_to_end (#2906) 2025-07-07 22:38:12 -07:00
Mark Thom
706ffe7ad9 fix functor! size calculations around indexing_code_ptr 2025-07-07 22:38:12 -07:00
Mark Thom
258244caf2 restore tab completion to REPL (#2575) 2025-07-07 22:38:12 -07:00
Mark Thom
39ea2d5899 make self.s_offset use bytes in case of HeapPtr::PStr in UnifyVoid (#2897) 2025-07-07 22:38:12 -07:00
Mark Thom
41b90c6e46 correct heap_print.rs for null characters being excluded from pstr regions of heap (#2890) 2025-07-07 22:38:12 -07:00
Mark Thom
6bcbb91e08 correctly increment s_offset for partial strings (#2897) 2025-07-07 22:38:12 -07:00
Mark Thom
e1e52338d6 fix typo in try_from_partial_string 2025-07-07 22:38:12 -07:00
Mark Thom
995a39419a fix read_s logic around HeapPtr::PStrLoc (#2894) 2025-07-07 22:38:12 -07:00
Mark Thom
4644ea2404 repair cyclic PStrLoc handling in heap_print.rs 2025-07-07 22:38:12 -07:00
Mark Thom
f3cd6326a3 remove compare_pstr_to_string and related result type 2025-07-07 22:38:12 -07:00
Markus Triska
bf31d3f9a9 ENHANCED: dedicated faster branches for repositionable streams
rebis-dev makes the speed difference especially apparent due to the
linear scan of strings on the heap in partial_string_tail/2 which is
now avoided for repositionable streams, notably files.

This addresses #2888 reported and analyzed by @haijinSk. Many thanks!
2025-07-07 22:38:12 -07:00
Mark Thom
4c46f0e54d correct GetPartialString (#2887) 2025-07-07 22:38:12 -07:00
Mark Thom
e563fd8e4f generalize compare_pstr_segments 2025-07-07 22:38:12 -07:00
Mark Thom
1297a24469 ensure '\0' atom is static & never inlined (#2880) 2025-07-07 22:38:12 -07:00
Mark Thom
907e64e185 fix root reading of complete strings (#2882) 2025-07-07 22:38:12 -07:00
Mark Thom
46f259bf7d some cosmetic tweaks 2025-07-07 22:38:12 -07:00
Markus Triska
634ccf22aa mark done item 2025-07-07 22:38:12 -07:00
Mark Thom
16b3bea48e correct and simplify compute_pstr_size 2025-07-07 22:38:12 -07:00
Mark Thom
e20363b462 correct create_partial_string (#2593) 2025-07-07 22:38:12 -07:00
Mark Thom
549a26dd03 restore more tabu_list use to compare_term_tests (#2633) 2025-07-07 22:38:12 -07:00
Mark Thom
8981ab72d1 restore tabu_list insertions to PStr-Lis comparisons (#2636) 2025-07-07 22:38:12 -07:00
Mark Thom
98dae9aecc do not allow strings containing null characters to be inlined (#2848) 2025-07-07 22:38:12 -07:00
Mark Thom
22080f3787 move CodeIndex to F64Table-like table 2025-07-07 22:38:12 -07:00
Mark Thom
9e1e99f961 Revert "remove Term"
This reverts commit 3b5879841aedecba5057c70c71da0ba23e5cd84a.
2025-07-07 22:38:10 -07:00
Mark Thom
eef7b06919 make write_with forward return values, use it to correct partial string handling 2025-07-07 22:02:27 -07:00
Mark Thom
2ad870c740 read Str focus properly in build_meta_predicate_clause 2025-07-07 22:02:27 -07:00
Mark Thom
3dee07f648 some fixes in response to miri 2025-07-07 22:02:27 -07:00
bakaq
9daf016d63 Fix parsing of \x0\ in partial strings 2025-07-07 22:02:27 -07:00
Mark Thom
fadcfb966e copy partial string blocks properly in all solutions predicates 2025-07-07 22:02:27 -07:00
Mark Thom
57f76169fd run cargo fmt 2025-07-07 22:02:27 -07:00
Mark Thom
ae4d12a123 remove pstr_vec 2025-07-07 22:02:27 -07:00
Mark Thom
3c85ef2724 globalize ALIGN_CELL/ALIGN, fix compute_pstr_size 2025-07-07 21:59:50 -07:00
Emilie Burgun
15f1320d05 Fix allocate_pstr randomly refusing to properly allocate memory
This one was a toughie: it turns out that using `ptr::align_of()`` was
a bad idea, since the buffer in `Heap` itself is not aligned to
`Heap::heap_cell_alignment()`, so `ptr::align_of()` would sometimes
return lower values than expected.

That made for an heisenbug: if the alignment of the heap happened to be 4,
then the bug wouldn't trigger.
2025-07-07 21:59:50 -07:00
Emilie Burgun
7b357ba84d Fix Heap::drop not accounting for null-initialized HeapInner 2025-07-07 21:59:50 -07:00
Mark Thom
c0cd371056 dereference clause_clause value, reserve more parser space (#2579) 2025-07-07 21:59:50 -07:00
Mark Thom
79be0c0625 unmark_cell_bits! in push_literal (#2645) 2025-07-07 21:59:50 -07:00
Mark Thom
c0f72704ec introduce bespoke Heap type for in-heap partial strings 2025-07-07 21:59:50 -07:00