yeptris 0.6.60.1-arm-linux-eabihf → 0.6.62.1-arm-linux-eabihf

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/ext/yeptris_native/version.h +2 -2
  3. data/lib/yeptris/3.4/native.so +0 -0
  4. data/lib/yeptris/document.rb +4 -1
  5. data/lib/yeptris/psych.rb +9 -6
  6. data/lib/yeptris/yaml.rb +15 -3
  7. data/lib/yeptris.rb +1 -1
  8. data/libyeptris.so +0 -0
  9. data/vendor/libyeptris/CMakeLists.txt +1 -1
  10. data/vendor/libyeptris/src/include/yeptris/emit.h +24 -18
  11. data/vendor/libyeptris/src/include/yeptris/parse.h +21 -0
  12. data/vendor/libyeptris/src/yeptris/common/simd_text.h +14 -1
  13. data/vendor/libyeptris/src/yeptris/common/simd_text_avx2.c +55 -2
  14. data/vendor/libyeptris/src/yeptris/common/simd_text_neon.c +59 -2
  15. data/vendor/libyeptris/src/yeptris/common/simd_text_scalar.c +24 -2
  16. data/vendor/libyeptris/src/yeptris/dom/dom.c +12 -1
  17. data/vendor/libyeptris/src/yeptris/dom/ytape.c +56 -7
  18. data/vendor/libyeptris/src/yeptris/emit/emit.c +44 -18
  19. data/vendor/libyeptris/src/yeptris/emit/writer.c +110 -19
  20. data/vendor/libyeptris/src/yeptris/emit/writer.h +10 -7
  21. data/vendor/libyeptris/src/yeptris/events/values.c +22 -0
  22. data/vendor/libyeptris/src/yeptris/parse/engine.c +490 -90
  23. data/vendor/libyeptris/src/yeptris/parse/engine.h +5 -0
  24. data/vendor/libyeptris/src/yeptris/parse/stream_iter.c +33 -1
  25. data/vendor/libyeptris/src/yeptris/parse.c +43 -1
  26. data/vendor/libyeptris/src/yeptris/resolve/compat11.c +2 -5
  27. data/vendor/libyeptris/src/yeptris/resolve/resolver.h +18 -0
  28. data/vendor/libyeptris/src/yeptris/resolve/tags.c +192 -0
  29. data/vendor/libyeptris/src/yeptris/scan/scan.c +87 -12
  30. data/vendor/libyeptris/src/yeptris/tape.c +24 -5
  31. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e078deaa97a27d09dc305c57e5d879ec727b506c0edfd6c1ef27a3fa7bb8d98
4
- data.tar.gz: 9d3a325cba29a0c5c51f33be9c99ccca3ce4febdb46dd4595d2e7d3dbb73988e
3
+ metadata.gz: 523deb927da9f16f08eb52a855ecef522cb9da0e6256c5fb18ee800ed8ac56a7
4
+ data.tar.gz: f71562aa6658c5e63d5b39707261a4ffdcfea51309b61b3599c4c250c2ecc551
5
5
  SHA512:
6
- metadata.gz: fa97a7e1b0332bcd8106b1c244d5a1b11641ff28c5be0fba465a84095cfc120a87e469a23e32acd7e19c6f1dbddabb2ce0c6b7eb372e3848a0866140d0771670
7
- data.tar.gz: a54e2f72f58ef07db3ef50755aa03bfbc41381770f252387bc331e7c71ead5818bb8b352197960336f69056ebe04e25a3dc272ee43032645facddd7658239a30
6
+ metadata.gz: 01b1a7bbcc7c426dc690f457e7d8b8f7ed36e3f378eef6c50bac19e2e88d6a696d3454531cf4b65eee6804d3a84f1905756dc303a079eba85a6af6bac93634c2
7
+ data.tar.gz: 27384bf9d1466a468529e0d01200aa2b9fcab666f8e08d291ff22c5a8ca5dd5a5f1c4e7bee1481a68940033eabdaa64299bd618e8f0cb582a2ad3894a795ba10
@@ -11,8 +11,8 @@
11
11
 
12
12
  #define YEPTRIS_VERSION_MAJOR 0
13
13
  #define YEPTRIS_VERSION_MINOR 6
14
- #define YEPTRIS_VERSION_PATCH 60
15
- #define YEPTRIS_VERSION_STRING "0.6.60"
14
+ #define YEPTRIS_VERSION_PATCH 62
15
+ #define YEPTRIS_VERSION_STRING "0.6.62"
16
16
 
17
17
  #ifdef __cplusplus
18
18
  extern "C" {
Binary file
@@ -190,8 +190,11 @@ class Yeptris::Document
190
190
  def serialize(canonical: false, best_width: 0, explicit_doc_start: false)
191
191
  ensure_alive!
192
192
  len = ::FFI::MemoryPointer.new(:size_t)
193
+ # any non-zero width builds the opts — negative rides the engine's
194
+ # #1257 clamp (psych's line_width: -1 unwrap), 0/absent rides the
195
+ # engine default (80, folding)
193
196
  ptr =
194
- if canonical || best_width.positive? || explicit_doc_start
197
+ if canonical || !best_width.zero? || explicit_doc_start
195
198
  opts = Yeptris::FFI::EmitOptions.new
196
199
  opts[:size] = Yeptris::FFI::EmitOptions.size
197
200
  opts[:canonical] = canonical ? 1 : 0
data/lib/yeptris/psych.rb CHANGED
@@ -424,12 +424,15 @@ module Yeptris
424
424
 
425
425
  # Arbitrary object graphs through the YAMLTree visitor
426
426
  # (anchors, !ruby/ tags); plain data rides the fast builder.
427
- # options reach the engine's emitter: :line_width folds flow
428
- # collections past the width (the engine default is 80),
429
- # :canonical switches the fixed form; :indentation is accepted
430
- # for Psych parity (the engine's YAML emitter has no indentation
431
- # knob). The audit round-2 finding — width accepted and
432
- # discarded — is closed here and in YAMLTree.create.
427
+ # options reach the engine's emitter: :line_width is psych's
428
+ # fold-column knob — 0/nil rides the engine default (80; with the
429
+ # engine's #1257 flip, block plain/single-quoted scalars fold
430
+ # there too, matching stdlib Psych's stored-file bytes), a
431
+ # negative value is the unwrap (the engine clamps it to
432
+ # never-fold), :canonical switches the fixed form; :indentation
433
+ # is accepted for Psych parity (the engine's YAML emitter has no
434
+ # indentation knob). The audit round-2 finding — width accepted
435
+ # and discarded — is closed here and in YAMLTree.create.
433
436
  def dump(obj, io = nil, options = {})
434
437
  # stdlib's Object#to_yaml calls Psych.dump(self, options) —
435
438
  # the options hash lands in the io slot positionally; treat a
data/lib/yeptris/yaml.rb CHANGED
@@ -294,9 +294,11 @@ module Yeptris
294
294
  # (TODO.impl/11 phase 3). Strings are emitted plain only when the
295
295
  # resolver round-trips them as strings — everything else takes a
296
296
  # quoted style, so dump(load(x)) == x for the scalar types.
297
- # width: the emitter's best_width (the engine wraps flow
298
- # collections after a value when the line exceeds it; 0/nil rides
299
- # the engine default of 80 — emit.h 13B).
297
+ # width: the emitter's best_width. 0/nil rides the engine default
298
+ # (80, folding — flow collections after a value past the width, and
299
+ # with the #1257 flip also block plain/single-quoted scalars, the
300
+ # psych/libyaml stored-file behavior); a negative width is psych's
301
+ # line_width: -1 unwrap (the engine clamps it to never-fold).
300
302
  def dump(obj, canonical: false, header: false, width: nil)
301
303
  BulkBuilder.dump(obj, canonical: canonical, header: header, width: width)
302
304
  end
@@ -350,6 +352,16 @@ module Yeptris
350
352
  Yeptris::FFI::BUILD_END => END_ENTRY }.freeze
351
353
 
352
354
  def dump(obj, canonical: false, header: false, width: nil)
355
+ # The nil root rides the bare form (psych's dump(nil) == "\n",
356
+ # #290): the engine's r201 quoted-form law ("a document-root
357
+ # empty scalar rides the quoted form" -- the plain form does not
358
+ # re-parse, the roundtrip invariant) renders the built empty
359
+ # scalar as "" -- correct for the engine's generic serializer,
360
+ # wrong for the psych surface. The binding maps an empty stream
361
+ # back to nil on load (load\#docs.empty?\#nil), so the bare form
362
+ # round-trips THROUGH THE BINDING while keeping the engine's
363
+ # invariant untouched.
364
+ return header ? "--- \n" : "\n" if obj.nil? && !canonical
353
365
  parts = []
354
366
  blob = String.new(encoding: Encoding::BINARY)
355
367
  off = [0]
data/lib/yeptris.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Yeptris
4
4
  # The gem's version lives in the parent namespace's file — the last
5
5
  # internal require (yeptris/version) retired with it.
6
- VERSION = "0.6.60.1".freeze
6
+ VERSION = "0.6.62.1".freeze
7
7
 
8
8
  # Informational notices are OPT-IN (yeptris-ruby#217): consumers
9
9
  # embed yeptris inside CLIs that assert clean stderr, and a
data/libyeptris.so CHANGED
Binary file
@@ -3,7 +3,7 @@
3
3
  cmake_minimum_required(VERSION 3.20)
4
4
 
5
5
  project(yeptris
6
- VERSION 0.6.60
6
+ VERSION 0.6.62
7
7
  DESCRIPTION "Ultra-fast YAML 1.2 parser, emitter and streamer in C"
8
8
  LANGUAGES C CXX
9
9
  )
@@ -37,11 +37,16 @@ typedef struct yeptris_emit_options {
37
37
  int canonical; /* fixed form: flow collections, quoted strings,
38
38
  * typed words, shortest floats; a parse of the
39
39
  * output re-serializes byte-identically */
40
- int best_width; /* 0 = library default (80): flow collections
41
- * wrap after a value when the current line
42
- * exceeds the width (13B); with block_fold
43
- * it is also the fold column for block
44
- * scalars (#903) */
40
+ int best_width; /* (#1257) the fold/wrap column, clamped the
41
+ * way libyaml's emitter init does:
42
+ * `best_width < 0` NEVER wraps (Psych's
43
+ * `line_width: -1` unwrap); `0 <= width <=
44
+ * best_indent*2` snaps to 80; 0 or absent =
45
+ * the library default 80. Drives the flow
46
+ * wrap (13B) and — with folding on (the
47
+ * default, #1257) — the block scalar fold
48
+ * column (#903). Only read when the
49
+ * caller's struct is large enough. */
45
50
  int explicit_doc_start; /* nonzero: every document carries the
46
51
  * leading --- marker (Psych/libyaml's
47
52
  * implicit=false parity). Default 0: a
@@ -54,19 +59,20 @@ typedef struct yeptris_emit_options {
54
59
  * (< 2 or > 9, libyaml's clamp) or 0 = the
55
60
  * library default 2. Only read when the
56
61
  * caller's struct is large enough. */
57
- int block_fold; /* (#903) nonzero: plain and single-quoted
58
- * scalars in block context fold at
59
- * best_width the way libyaml/Psych/PyYAML
60
- * do — at an interior single space past the
61
- * width the break replaces the space and
62
- * the continuation re-indents to
63
- * parent_col + best_indent. Default 0:
64
- * block output is width-invariant (byte-
65
- * identical with releases before the
66
- * option). Keys and flow members never
67
- * fold; canonical/JSON keep their fixed
68
- * forms. Only read when the caller's
69
- * struct is large enough. */
62
+ int block_fold; /* (#903, the #1257 default flip) nonzero:
63
+ * plain and single-quoted scalars in block
64
+ * context fold at best_width the way
65
+ * libyaml/Psych/PyYAML do — at an interior
66
+ * single space past the width the break
67
+ * replaces the space and the continuation
68
+ * re-indents to parent_col + best_indent.
69
+ * DEFAULT ON (a fold default matches
70
+ * Psych's stored-file bytes; an explicit 0
71
+ * unwraps, as does best_width < 0). Keys
72
+ * and flow members never fold;
73
+ * canonical/JSON keep their fixed forms.
74
+ * Only read when the caller's struct is
75
+ * large enough. */
70
76
  } yeptris_emit_options;
71
77
 
72
78
  /* Options-aware entries; opts == NULL selects the fidelity mode
@@ -91,6 +91,27 @@ YEPTRIS_API YeptrisStatus yeptris_stream_iter_next(yeptris_stream_iter* it, Yept
91
91
  YEPTRIS_API YeptrisStatus yeptris_stream_iter_status(const yeptris_stream_iter* it, uint32_t* line,
92
92
  uint32_t* col);
93
93
 
94
+ /* The last successful step's document SLICE inside the iterator's
95
+ * buffer space (post-gate: BOM/transcode/normalization may have moved
96
+ * the buffer — the offsets are relative to the CURRENT buf the
97
+ * iterator holds, which is the space `yeptris_stream_iter_next`'s
98
+ * documents live in). Hosts that materialize through their own value
99
+ * route (the Python/Rust/TS drains) re-parse exactly these bytes and
100
+ * inherit the engine's framing without a DOM walk: one typing SSOT —
101
+ * the drain — and scanner-accurate frames. ARG on NULL; ARG when the
102
+ * last step was not a successful document. */
103
+ YEPTRIS_API YeptrisStatus yeptris_stream_iter_slice(const yeptris_stream_iter* it, size_t* off,
104
+ size_t* len);
105
+
106
+ /* The iterator's ACTIVE buffer (the caller's bytes, or the post-gate
107
+ * owned copy after a BOM strip / UTF-16-32 transcode / NEL-LS-PS
108
+ * normalization) and its length. `yeptris_stream_iter_slice`'s offsets
109
+ * index THIS buffer — hosts copy their frame bytes out of here
110
+ * (ctypes.string_at / Rust slice / TS Buffer) and re-parse them through
111
+ * their own drain. Borrowed: valid until yeptris_stream_iter_free. */
112
+ YEPTRIS_API YeptrisStatus yeptris_stream_iter_buffer(const yeptris_stream_iter* it,
113
+ const char** buf, size_t* len);
114
+
94
115
  YEPTRIS_API void yeptris_stream_iter_free(yeptris_stream_iter* it);
95
116
 
96
117
  #ifdef __cplusplus
@@ -76,12 +76,25 @@ static inline void yep_stopset_init(yep_stopset* ss, const unsigned char bitmap[
76
76
  * end is the first \n/\r at/after pos (or len); indent the first
77
77
  * byte != ' ' (spaces only — tabs are the caller's rule, as in
78
78
  * yep_scan_line); stop the first block-plain stop byte at/after the
79
- * indent and strictly before end, stop_set=0 when none exists. */
79
+ * indent and strictly before end, stop_set=0 when none exists.
80
+ * stop2 is the SECOND block-plain stop byte at/after indent (same
81
+ * class as stop: \n \r # :), stop2_set=0 when none exists — the
82
+ * value-side side output (TODO.max-perf/03): the pair arm's plain
83
+ * value starts past stop, so its first stop byte is stop2, computed
84
+ * over the same sweep instead of a second pass. flags bit0 mirrors
85
+ * stop2_set (uint32-packed so the struct stays sweep-width); bit1
86
+ * has_high marks any byte >= 0x80 in [pos, end) — the multibyte
87
+ * break-lead law needs the lead probe, so a facts consumer may take
88
+ * a zero-probe fast path only when the span is pure ASCII. */
89
+ #define YEP_FACTS_STOP2 0x1u
90
+ #define YEP_FACTS_HIGH 0x2u
80
91
  typedef struct yep_line_facts {
81
92
  uint32_t end;
82
93
  uint32_t indent;
83
94
  uint32_t stop;
84
95
  uint32_t stop_set;
96
+ uint32_t stop2;
97
+ uint32_t flags;
85
98
  } yep_line_facts;
86
99
 
87
100
  /* The flow-kernel chunk classifier's output (one <=32-byte chunk):
@@ -353,8 +353,8 @@ static void yep_avx2_line_facts(const char* s, size_t len, size_t pos, yep_line_
353
353
  ksp = _mm256_set1_epi8(' '), kco = _mm256_set1_epi8(':'),
354
354
  khash = _mm256_set1_epi8('#');
355
355
  size_t i = pos;
356
- int have_end = 0, have_indent = 0, have_stop = 0;
357
- uint32_t end = 0, indent = 0, stop = 0;
356
+ int have_end = 0, have_indent = 0, have_stop = 0, have_stop2 = 0, has_high = 0;
357
+ uint32_t end = 0, indent = 0, stop = 0, stop2 = 0;
358
358
  for (; i + 32 <= len; i += 32) {
359
359
  if (have_end) {
360
360
  break; /* indent <= end, stop < end: settled or absent */
@@ -374,6 +374,26 @@ static void yep_avx2_line_facts(const char* s, size_t len, size_t pos, yep_line_
374
374
  end = (uint32_t)(i + (size_t)yep_ctz32(br));
375
375
  have_end = 1;
376
376
  }
377
+ if (!has_high) {
378
+ /* any multibyte lead below the break (canon of the
379
+ * facts-consumer fast path: the lead probe rides only on
380
+ * non-ASCII lines). Full chunks test via movemask of the
381
+ * sign bits (the high bit IS the sign); the break chunk's
382
+ * tail (>= end) must not count. */
383
+ if (!have_end) {
384
+ if (_mm256_movemask_epi8(v)) {
385
+ has_high = 1;
386
+ }
387
+ } else {
388
+ uint32_t hlim = (uint32_t)(end - i);
389
+ for (uint32_t k = 0; k < hlim; k++) {
390
+ if ((uint8_t)s[i + k] & 0x80) {
391
+ has_high = 1;
392
+ break;
393
+ }
394
+ }
395
+ }
396
+ }
377
397
  if (!have_stop && have_indent) {
378
398
  uint32_t st = br;
379
399
  st |= (uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(v, kco));
@@ -387,6 +407,27 @@ static void yep_avx2_line_facts(const char* s, size_t len, size_t pos, yep_line_
387
407
  if (at >= from && (!have_end || (uint32_t)(i + at) < end)) {
388
408
  stop = (uint32_t)(i + at);
389
409
  have_stop = 1;
410
+ /* the value-side stop (TODO.max-perf/03): the next
411
+ * stop lane in the same chunk */
412
+ uint32_t rest = st & (st - 1);
413
+ if (rest) {
414
+ uint32_t at2 = (uint32_t)yep_ctz32(rest);
415
+ if (!have_end || (uint32_t)(i + at2) < end) {
416
+ stop2 = (uint32_t)(i + at2);
417
+ have_stop2 = 1;
418
+ }
419
+ }
420
+ }
421
+ }
422
+ } else if (have_stop && !have_stop2 && have_indent) {
423
+ uint32_t st = br;
424
+ st |= (uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(v, kco));
425
+ st |= (uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(v, khash));
426
+ if (st) {
427
+ uint32_t at = (uint32_t)yep_ctz32(st);
428
+ if (!have_end || (uint32_t)(i + at) < end) {
429
+ stop2 = (uint32_t)(i + at);
430
+ have_stop2 = 1;
390
431
  }
391
432
  }
392
433
  }
@@ -410,11 +451,23 @@ static void yep_avx2_line_facts(const char* s, size_t len, size_t pos, yep_line_
410
451
  stop_set = t.stop_set;
411
452
  }
412
453
  }
454
+ if (!have_stop2) {
455
+ if (!have_end && (t.flags & YEP_FACTS_STOP2)) {
456
+ stop2 = t.stop2;
457
+ have_stop2 = 1;
458
+ }
459
+ }
460
+ has_high |= (t.flags & YEP_FACTS_HIGH) != 0;
461
+ }
462
+ if (!have_stop2) {
463
+ stop2 = end; /* no second stop before the break */
413
464
  }
414
465
  out->end = end;
415
466
  out->indent = indent;
416
467
  out->stop = stop;
417
468
  out->stop_set = have_stop ? 1u : stop_set;
469
+ out->stop2 = stop2;
470
+ out->flags = (uint32_t)((have_stop2 ? YEP_FACTS_STOP2 : 0) | (has_high ? YEP_FACTS_HIGH : 0));
418
471
  }
419
472
 
420
473
  /* The flow-kernel chunk classifier: one 256-bit lane pass -> four
@@ -461,8 +461,8 @@ static void yep_neon_line_facts(const char* s, size_t len, size_t pos, yep_line_
461
461
  const uint8x16_t ksp = vdupq_n_u8(' '), knl = vdupq_n_u8('\n'), kcr = vdupq_n_u8('\r'),
462
462
  kco = vdupq_n_u8(':'), khash = vdupq_n_u8('#');
463
463
  size_t i = pos;
464
- int have_end = 0, have_indent = 0, have_stop = 0;
465
- uint32_t end = 0, indent = 0, stop = 0;
464
+ int have_end = 0, have_indent = 0, have_stop = 0, have_stop2 = 0, has_high = 0;
465
+ uint32_t end = 0, indent = 0, stop = 0, stop2 = 0;
466
466
  for (; i + 16 <= len; i += 16) {
467
467
  if (have_end) {
468
468
  break; /* indent <= end, stop < end: settled or absent */
@@ -490,6 +490,25 @@ static void yep_neon_line_facts(const char* s, size_t len, size_t pos, yep_line_
490
490
  }
491
491
  }
492
492
  }
493
+ if (!has_high) {
494
+ /* any multibyte lead below the break (canon of the
495
+ * facts-consumer fast path: the lead probe rides only on
496
+ * non-ASCII lines). Full chunks test in-vector; the break
497
+ * chunk's tail (>= end) must not count. */
498
+ if (!have_end) {
499
+ if (vmaxvq_u8(vandq_u8(v, vdupq_n_u8(0x80))) != 0) {
500
+ has_high = 1;
501
+ }
502
+ } else {
503
+ size_t hlim = (size_t)(end - i);
504
+ for (size_t k = 0; k < hlim; k++) {
505
+ if ((uint8_t)s[i + k] & 0x80) {
506
+ has_high = 1;
507
+ break;
508
+ }
509
+ }
510
+ }
511
+ }
493
512
  if (!have_stop && have_indent) {
494
513
  uint8x16_t st = vorrq_u8(br, vorrq_u8(vceqq_u8(v, kco), vceqq_u8(v, khash)));
495
514
  if (vmaxvq_u8(st) != 0) {
@@ -503,6 +522,32 @@ static void yep_neon_line_facts(const char* s, size_t len, size_t pos, yep_line_
503
522
  if (c == '\n' || c == '\r' || c == '#' || c == ':') {
504
523
  stop = (uint32_t)(i + k);
505
524
  have_stop = 1;
525
+ /* the value-side stop (TODO.max-perf/03): the
526
+ * next stop byte in the same chunk */
527
+ for (size_t k2 = k + 1; k2 < lim; k2++) {
528
+ char c2 = s[i + k2];
529
+ if (c2 == '\n' || c2 == '\r' || c2 == '#' || c2 == ':') {
530
+ stop2 = (uint32_t)(i + k2);
531
+ have_stop2 = 1;
532
+ break;
533
+ }
534
+ }
535
+ break;
536
+ }
537
+ }
538
+ }
539
+ } else if (have_stop && !have_stop2 && have_indent) {
540
+ uint8x16_t st = vorrq_u8(br, vorrq_u8(vceqq_u8(v, kco), vceqq_u8(v, khash)));
541
+ if (vmaxvq_u8(st) != 0) {
542
+ size_t lim = 16;
543
+ if (have_end && end < (uint32_t)(i + 16)) {
544
+ lim = (size_t)(end - i); /* stop is strictly before end */
545
+ }
546
+ for (size_t k = 0; k < lim; k++) {
547
+ char c = s[i + k];
548
+ if (c == '\n' || c == '\r' || c == '#' || c == ':') {
549
+ stop2 = (uint32_t)(i + k);
550
+ have_stop2 = 1;
506
551
  break;
507
552
  }
508
553
  }
@@ -532,11 +577,23 @@ static void yep_neon_line_facts(const char* s, size_t len, size_t pos, yep_line_
532
577
  stop_set = t.stop_set;
533
578
  }
534
579
  }
580
+ if (!have_stop2) {
581
+ if (!have_end && (t.flags & YEP_FACTS_STOP2)) {
582
+ stop2 = t.stop2;
583
+ have_stop2 = 1;
584
+ }
585
+ }
586
+ has_high |= (t.flags & YEP_FACTS_HIGH) != 0;
587
+ }
588
+ if (!have_stop2) {
589
+ stop2 = end; /* no second stop before the break */
535
590
  }
536
591
  out->end = end;
537
592
  out->indent = indent;
538
593
  out->stop = stop;
539
594
  out->stop_set = have_stop ? 1u : stop_set;
595
+ out->stop2 = stop2;
596
+ out->flags = (uint32_t)((have_stop2 ? YEP_FACTS_STOP2 : 0) | (has_high ? YEP_FACTS_HIGH : 0));
540
597
  }
541
598
 
542
599
  /* The flow-kernel chunk classifier: two 16-byte halves -> four
@@ -202,8 +202,8 @@ int yep_text_line_facts_capped(const char* s, size_t len, size_t pos, size_t cap
202
202
  k_ha = 0x2323232323232323ull;
203
203
  size_t whole = len - pos;
204
204
  size_t n = whole < cap ? whole : cap;
205
- size_t end = n, indent = n, stop = n;
206
- int have_indent = 0, stop_set = 0, have_end = 0;
205
+ size_t end = n, indent = n, stop = n, stop2 = n;
206
+ int have_indent = 0, stop_set = 0, have_end = 0, stop2_set = 0, has_high = 0;
207
207
  size_t i = 0;
208
208
  while (i < n) {
209
209
  size_t avail = n - i < 8 ? n - i : 8;
@@ -227,6 +227,9 @@ int yep_text_line_facts_capped(const char* s, size_t len, size_t pos, size_t cap
227
227
  have_indent = 1;
228
228
  }
229
229
  }
230
+ if (room & x & 0x8080808080808080ull) {
231
+ has_high = 1; /* a multibyte lead rides below the break */
232
+ }
230
233
  if (have_indent && !stop_set) {
231
234
  uint64_t stm = (yep_swar_eq8(x, k_co) | yep_swar_eq8(x, k_ha)) & room;
232
235
  if (stm) {
@@ -234,8 +237,22 @@ int yep_text_line_facts_capped(const char* s, size_t len, size_t pos, size_t cap
234
237
  if (cand >= indent) { /* a stop byte cannot precede the first non-space */
235
238
  stop = cand;
236
239
  stop_set = 1;
240
+ /* the value-side stop (TODO.max-perf/03): the next
241
+ * stop byte in the same chunk, over the same load */
242
+ uint64_t bit = (uint64_t)1 << ((cand - i) * 8);
243
+ uint64_t rest = stm & ~(bit | (bit - 1));
244
+ if (rest) {
245
+ stop2 = i + (size_t)(yep_ctz64(rest) >> 3);
246
+ stop2_set = 1;
247
+ }
237
248
  }
238
249
  }
250
+ } else if (have_indent && stop_set && !stop2_set) {
251
+ uint64_t stm = (yep_swar_eq8(x, k_co) | yep_swar_eq8(x, k_ha)) & room;
252
+ if (stm) {
253
+ stop2 = i + (size_t)(yep_ctz64(stm) >> 3);
254
+ stop2_set = 1;
255
+ }
239
256
  }
240
257
  if (br) {
241
258
  end = i + (size_t)(yep_ctz64(br) >> 3);
@@ -253,10 +270,15 @@ int yep_text_line_facts_capped(const char* s, size_t len, size_t pos, size_t cap
253
270
  if (!stop_set) {
254
271
  stop = end;
255
272
  }
273
+ if (!stop2_set) {
274
+ stop2 = end;
275
+ }
256
276
  out->end = (uint32_t)(pos + end);
257
277
  out->indent = (uint32_t)(pos + indent);
258
278
  out->stop = (uint32_t)(pos + stop);
259
279
  out->stop_set = stop_set;
280
+ out->stop2 = (uint32_t)(pos + stop2);
281
+ out->flags = (uint32_t)((stop2_set ? YEP_FACTS_STOP2 : 0) | (has_high ? YEP_FACTS_HIGH : 0));
260
282
  return 1;
261
283
  }
262
284
 
@@ -158,7 +158,18 @@ static yep_sview dom_str_in(yep_dom* d, const yep_view* v, int borrowed) {
158
158
  yep_sview sv = {0, 0};
159
159
  return sv;
160
160
  }
161
- if (borrowed && v->p != NULL && d->input_base != NULL && (const char*)v->p >= d->input_base) {
161
+ /* The zero-copy law: borrow ONLY a view demonstrably inside the
162
+ * recorded input window. The old heap-order probe (v->p >=
163
+ * input_base) misfiled every engine-owned buffer that happened to
164
+ * sit above the caller's input — the r171 normalizer copy path
165
+ * (norm_buf) hands exactly such views to the pair/event builders —
166
+ * and the resulting input-relative offset was then layout luck per
167
+ * platform/build (the ubuntu-gcc / MSVC-arm / TSan / UBSan CI
168
+ * divergences of PR #1042). The upper bound makes the decision a
169
+ * pure function of the view's location class: both engines of a
170
+ * differential run now store identically on every platform. */
171
+ if (borrowed && v->p != NULL && d->input_base != NULL &&
172
+ (size_t)((const char*)v->p - d->input_base) + v->len <= d->input_len) {
162
173
  return yep_sv_input(d, *v);
163
174
  }
164
175
  return yep_dom_str_put(d, (const char*)v->p, v->len);
@@ -1640,15 +1640,64 @@ static int yt_f_run(yt_fused* F) {
1640
1640
  col + 1 != st[depth].content_col && st[depth].phantom) {
1641
1641
  yt_f_close(F, st[depth].kind);
1642
1642
  st[depth].phantom = 0;
1643
+ st[depth].content_col =
1644
+ 0; /* the content map is gone:
1645
+ * its column must not greet later pairs (the
1646
+ * stale-frame law, run 38179552341) — after the
1647
+ * chained-pending arm resumes here, a stale
1648
+ * column rode yt_f_open_form's sibling test and
1649
+ * misfiled the next pending's container as a
1650
+ * key-SCALAR ("b:\n c: d\nq:\n b:\n c: d\n"
1651
+ * lost q's map; the nightly's run 42488986434) */
1643
1652
  }
1644
1653
  if (depth > 0 && st[depth].pending) {
1645
- /* chained same-column pending ("a:\na:"): resolving
1646
- * the first via yt_f_open corrupts the frame mapping
1647
- * when the second's container carries valued pairs —
1648
- * the OPEN'd map swallows the second key as the
1649
- * first pair's value (the nightly's run 38110714729
1650
- * tree corruption). The engine owns the shape */
1651
- return 1;
1654
+ /* a chained pending ("a:\na:", the deep-nesting
1655
+ * "k:\n k:\n k:" ladder): resolve the outer
1656
+ * one before the sibling's frame takes the slot.
1657
+ * A same-column sibling key (col == the pending's
1658
+ * own column) gives the pending a NULL value —
1659
+ * the null pair MUST land now, or the OPEN'd
1660
+ * container swallows the sibling key as its
1661
+ * first pair's value (the nightly's run
1662
+ * 38110714729 tree corruption: {a: a, ?{b: c}:
1663
+ * h} instead of {a: null, a: {b: c}, h: v}).
1664
+ * When the OPEN form fired, the null pairs
1665
+ * INSIDE the opened container (parent → {k:
1666
+ * null}); under the key-SCALAR form it completes
1667
+ * the key's pair in the parent's map. A deeper
1668
+ * line (col > indent) opens the pending's
1669
+ * container and the chain nests. Anchored
1670
+ * pendings keep the engine: their anchor rides
1671
+ * the event path (yt_f_open drops the name) */
1672
+ if (st[depth].aid != 0) {
1673
+ return 1;
1674
+ }
1675
+ uint8_t of = yt_f_open_form(&st[depth - 1], depth == 1, st[depth].indent);
1676
+ if (aid != 0 && of == 0) {
1677
+ /* the outer pending resolved as a SIBLING
1678
+ * key-SCALAR: its value container is "the pair's",
1679
+ * materialized by the next OPEN-class record — but
1680
+ * the anchored pending resolves through the event
1681
+ * path, which emits its KEY SCALAR *before* the
1682
+ * anchored MAP_START. That key pairs with the
1683
+ * stranded outer key (the pair's value slot) and
1684
+ * the anchored map strands as a sibling key of the
1685
+ * parent: "2: e\n4:\n 5: &5\n 5: e\n7: s"
1686
+ * built {2:e, 4:"5", {5:e}&5:"7", s:null} instead
1687
+ * of {2:e, 4:{5:{5:e}&5}, 7:s} (the nightly's
1688
+ * crash-d8e3b3f392c37a62257576ce20d5a19b351f66ad,
1689
+ * round 213 — the first shape where a completed
1690
+ * pair arms root_pair_col BEFORE the chain). The
1691
+ * engine resolves the composition. */
1692
+ return 1;
1693
+ }
1694
+ yt_f_open(F, &st[depth], of);
1695
+ root_open = 1;
1696
+ if (col == st[depth].indent) {
1697
+ (void)yt_put(t, yt_props(YTP_SCALAR, 0, 0x0904u));
1698
+ yt_f_empty_span(F);
1699
+ }
1700
+ st[depth].pending = 0;
1652
1701
  }
1653
1702
  /* a spent key-SCALAR frame (resolved, phantom closed,
1654
1703
  * no map of its own) gives its slot to the sibling —