yeptris 0.6.60.1 → 0.6.62.1
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.
- checksums.yaml +4 -4
- data/lib/yeptris/document.rb +4 -1
- data/lib/yeptris/psych.rb +9 -6
- data/lib/yeptris/yaml.rb +15 -3
- data/lib/yeptris.rb +1 -1
- data/vendor/libyeptris/CMakeLists.txt +1 -1
- data/vendor/libyeptris/src/include/yeptris/emit.h +24 -18
- data/vendor/libyeptris/src/include/yeptris/parse.h +21 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text.h +14 -1
- data/vendor/libyeptris/src/yeptris/common/simd_text_avx2.c +55 -2
- data/vendor/libyeptris/src/yeptris/common/simd_text_neon.c +59 -2
- data/vendor/libyeptris/src/yeptris/common/simd_text_scalar.c +24 -2
- data/vendor/libyeptris/src/yeptris/dom/dom.c +12 -1
- data/vendor/libyeptris/src/yeptris/dom/ytape.c +56 -7
- data/vendor/libyeptris/src/yeptris/emit/emit.c +44 -18
- data/vendor/libyeptris/src/yeptris/emit/writer.c +110 -19
- data/vendor/libyeptris/src/yeptris/emit/writer.h +10 -7
- data/vendor/libyeptris/src/yeptris/events/values.c +22 -0
- data/vendor/libyeptris/src/yeptris/parse/engine.c +490 -90
- data/vendor/libyeptris/src/yeptris/parse/engine.h +5 -0
- data/vendor/libyeptris/src/yeptris/parse/stream_iter.c +33 -1
- data/vendor/libyeptris/src/yeptris/parse.c +43 -1
- data/vendor/libyeptris/src/yeptris/resolve/compat11.c +2 -5
- data/vendor/libyeptris/src/yeptris/resolve/resolver.h +18 -0
- data/vendor/libyeptris/src/yeptris/resolve/tags.c +192 -0
- data/vendor/libyeptris/src/yeptris/scan/scan.c +87 -12
- data/vendor/libyeptris/src/yeptris/tape.c +24 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7103dd1c1b5a2ce267c30b44b6dc8449c8956df18a5027f4c54ad308ae53de17
|
|
4
|
+
data.tar.gz: 61e61bf7cbfa1afc2f45d7b1c2c5d524d19c5913e114afd757085f216d3992d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3de49191c0ff6efc0a919232ee9571df5d0c51bdbc8f5625601c968622eaf97e49aa4981f677d045a9557646f50eae8b9e1d1039c9fd76fc1bb138db80779b2a
|
|
7
|
+
data.tar.gz: 04ab85dd31d4dff82d3c393ce4d9b0685bbf9f4f99f77554613c32c42485cceb3c5535e824feef78b07d38a7c8a334f55412bfdd6b0f0ce6c4da2d60b915d6ff
|
data/lib/yeptris/document.rb
CHANGED
|
@@ -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.
|
|
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
|
|
428
|
-
#
|
|
429
|
-
#
|
|
430
|
-
#
|
|
431
|
-
#
|
|
432
|
-
#
|
|
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
|
|
298
|
-
# collections after a value
|
|
299
|
-
# the
|
|
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.
|
|
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
|
|
@@ -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; /*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
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:
|
|
58
|
-
* scalars in block
|
|
59
|
-
* best_width the way
|
|
60
|
-
* do — at an interior
|
|
61
|
-
*
|
|
62
|
-
* the
|
|
63
|
-
* parent_col + best_indent.
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
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
|
-
|
|
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
|
|
1646
|
-
*
|
|
1647
|
-
*
|
|
1648
|
-
*
|
|
1649
|
-
*
|
|
1650
|
-
*
|
|
1651
|
-
|
|
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 —
|