leptris 1.9.380.1 → 1.9.380.2
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/CHANGELOG.md +7 -0
- data/ext/leptris/native/native.c +168 -7
- data/lib/leptris/vendor/x86_64-linux-musl/libleptris.so +0 -0
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/native_layer.rb +20 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 213b5096ca73813ee05e8816632f5f3f0e0cbae5744b477b5cecb7acae15ad2b
|
|
4
|
+
data.tar.gz: 23ea9d5f3ddb5f067e5bc90b29599e47df1418336bff8caa1b3fb139202079fe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ca38fd56c66cf502830190aed494c9371571477c2d4609d93dcc942ff98b7c34503ffe34f61dda5148aa63306f1386b4b99c022d587be5cb6b19e79e103ef8f2
|
|
7
|
+
data.tar.gz: 07ff974cc3fee133d576d76cbf205422235d6cc7656ade52f0d50453c8cc0232f6d648969e6aa2d3778f15e3417f1a30b75b07e93e8124054b75b47a0c876f62
|
data/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
model. Released 1.9.380.0 with the pin still at 1.9.379 (the
|
|
11
11
|
vendored dylib missed the fix); this pin bump is the real ride.
|
|
12
12
|
|
|
13
|
+
### Fixed — engine ride (1.9.380.2)
|
|
14
|
+
|
|
15
|
+
- **Bulk XPath priming face rides (leptris/leptris-ruby#537)**:
|
|
16
|
+
`xpath_result_rows_bulk` gains the mx_context/mx_adapter birth-prime
|
|
17
|
+
parameters and marks all-native results; 1.9.380.1 shipped before
|
|
18
|
+
the PR merged, so the face rides in 1.9.380.2.
|
|
19
|
+
|
|
13
20
|
## [1.9.379.3] - 2026-10-22
|
|
14
21
|
|
|
15
22
|
### Fixed
|
data/ext/leptris/native/native.c
CHANGED
|
@@ -203,6 +203,10 @@ static VALUE binding_klass_for(int kind);
|
|
|
203
203
|
static VALUE c_iteration_scope;
|
|
204
204
|
static VALUE c_leptris_error;
|
|
205
205
|
static VALUE c_b_document, c_b_freed, c_ffi_pointer;
|
|
206
|
+
/* BulkIdentityRows resolves lazily like the binding classes: the
|
|
207
|
+
* module lives in native_layer.rb, which optional consumers load. */
|
|
208
|
+
static VALUE c_bulk_rows_mark = Qundef;
|
|
209
|
+
static ID id_bulk_rows_mark;
|
|
206
210
|
static ID id_ptr_new, id_freed_new, id_alive;
|
|
207
211
|
static ID id_iv_c_address, id_iv_document, id_iv_parent;
|
|
208
212
|
static ID id_iv_mx_context, id_iv_mx_adapter, id_iv_mx_native;
|
|
@@ -221,8 +225,23 @@ struct native_node {
|
|
|
221
225
|
* Slot beats the hash memo on repeat reads of one name. */
|
|
222
226
|
VALUE attr_key, attr_val, attr_ver;
|
|
223
227
|
VALUE content_val, content_ver;
|
|
228
|
+
/* Walk-read memos (leptris-ruby#530): the element name and the
|
|
229
|
+
* children list, the two reads a tree walk pays per node. The
|
|
230
|
+
* children memo is what the subtree prime (#527 machinery)
|
|
231
|
+
* fills; the version stamp retires both on any mutation. The
|
|
232
|
+
* children list is SHARED with callers until the version moves
|
|
233
|
+
* (the mutation that would invalidate it also retires the
|
|
234
|
+
* memo) — treat it as read-only, like an interned String. */
|
|
235
|
+
VALUE name_val, name_ver;
|
|
236
|
+
VALUE children_val, children_ver;
|
|
224
237
|
};
|
|
225
238
|
|
|
239
|
+
static VALUE columnar_node_for(VALUE document, VALUE owner_klass,
|
|
240
|
+
void *ptr, int kind);
|
|
241
|
+
static VALUE doc_klass_for_kind(VALUE document, int kind);
|
|
242
|
+
static VALUE nn_prime_children_of(VALUE document, VALUE owner_klass,
|
|
243
|
+
void *node, VALUE ver);
|
|
244
|
+
|
|
226
245
|
static void nn_mark(void *p)
|
|
227
246
|
{
|
|
228
247
|
struct native_node *n = p;
|
|
@@ -234,6 +253,10 @@ static void nn_mark(void *p)
|
|
|
234
253
|
rb_gc_mark(n->attr_val);
|
|
235
254
|
if (n->content_val != Qnil)
|
|
236
255
|
rb_gc_mark(n->content_val);
|
|
256
|
+
if (n->name_val != Qnil)
|
|
257
|
+
rb_gc_mark(n->name_val);
|
|
258
|
+
if (n->children_val != Qnil)
|
|
259
|
+
rb_gc_mark(n->children_val);
|
|
237
260
|
}
|
|
238
261
|
|
|
239
262
|
static size_t nn_size(const void *p) { (void)p; return sizeof(struct native_node); }
|
|
@@ -367,7 +390,19 @@ static VALUE nn_name(VALUE self)
|
|
|
367
390
|
{
|
|
368
391
|
struct native_node *n;
|
|
369
392
|
const char *s;
|
|
393
|
+
VALUE doc, ver;
|
|
394
|
+
|
|
370
395
|
TypedData_Get_Struct(self, struct native_node, &nn_type, n);
|
|
396
|
+
/* Walk-memo hit (leptris-ruby#530): a repeat name read is two
|
|
397
|
+
* struct reads and a Fixnum compare — the subtree prime fills
|
|
398
|
+
* this slot ahead of the walk, so walked names never recompute
|
|
399
|
+
* (or re-intern) until the next mutation. */
|
|
400
|
+
doc = n->document;
|
|
401
|
+
if (doc != Qnil) {
|
|
402
|
+
ver = rb_ivar_get(doc, id_iv_version);
|
|
403
|
+
if (n->name_ver == ver)
|
|
404
|
+
return n->name_val;
|
|
405
|
+
}
|
|
371
406
|
s = f_elem_name(n->ptr);
|
|
372
407
|
/* Interned (shared, frozen) fstring: element names repeat
|
|
373
408
|
* massively across a document — one RString per distinct name
|
|
@@ -375,7 +410,13 @@ static VALUE nn_name(VALUE self)
|
|
|
375
410
|
* ~18% of consumer materialize allocations were fresh name
|
|
376
411
|
* strings). Names are identifiers; nothing downstream mutates
|
|
377
412
|
* them in place (renames mint new strings). */
|
|
378
|
-
|
|
413
|
+
VALUE name = s ? rb_enc_interned_str(s, strlen(s), rb_utf8_encoding())
|
|
414
|
+
: Qnil;
|
|
415
|
+
if (doc != Qnil) {
|
|
416
|
+
n->name_val = name;
|
|
417
|
+
n->name_ver = ver;
|
|
418
|
+
}
|
|
419
|
+
return name;
|
|
379
420
|
}
|
|
380
421
|
|
|
381
422
|
static VALUE nn_content(VALUE self)
|
|
@@ -563,14 +604,43 @@ static VALUE nn_children(VALUE self)
|
|
|
563
604
|
void **buf;
|
|
564
605
|
int *kinds;
|
|
565
606
|
int count, i;
|
|
566
|
-
VALUE cache, out, owner_klass;
|
|
607
|
+
VALUE cache, out, owner_klass, doc, ver;
|
|
567
608
|
|
|
568
609
|
TypedData_Get_Struct(self, struct native_node, &nn_type, n);
|
|
610
|
+
/* Walk-memo hit (leptris-ruby#530): the subtree prime (or an
|
|
611
|
+
* earlier read) filled this node's list against the current
|
|
612
|
+
* mutation version — serve it, engine walk skipped. */
|
|
613
|
+
doc = n->document;
|
|
614
|
+
if (doc != Qnil) {
|
|
615
|
+
ver = rb_ivar_get(doc, id_iv_version);
|
|
616
|
+
if (n->children_ver == ver)
|
|
617
|
+
return n->children_val;
|
|
618
|
+
/* Registered-consumer documents (#340 doc-klass map = the
|
|
619
|
+
* moxml mint registration) walk whole subtrees top-down:
|
|
620
|
+
* the FIRST cold children_read trades itself for ONE
|
|
621
|
+
* subtree crossing that fills every node's name + children
|
|
622
|
+
* memo (walk_columnar machinery, native-cache identity —
|
|
623
|
+
* the primed wrappers ARE the answers later reads give).
|
|
624
|
+
* Unregistered documents keep the per-node fetch; both
|
|
625
|
+
* paths memo-store below. */
|
|
626
|
+
if (!NIL_P(doc_klass_for_kind(doc, NT_ELEMENT))) {
|
|
627
|
+
out = nn_prime_children_of(doc, rb_obj_class(self), n->ptr,
|
|
628
|
+
ver);
|
|
629
|
+
n->children_val = out;
|
|
630
|
+
n->children_ver = ver;
|
|
631
|
+
return out;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
569
634
|
count = fetch_children_two_call(n->ptr, &buf, &kinds);
|
|
570
635
|
if (count <= 0) {
|
|
571
636
|
ruby_xfree(buf);
|
|
572
637
|
ruby_xfree(kinds);
|
|
573
|
-
|
|
638
|
+
out = rb_ary_new2(0);
|
|
639
|
+
if (doc != Qnil) {
|
|
640
|
+
n->children_val = out;
|
|
641
|
+
n->children_ver = ver;
|
|
642
|
+
}
|
|
643
|
+
return out;
|
|
574
644
|
}
|
|
575
645
|
|
|
576
646
|
cache = native_cache_of(n->document);
|
|
@@ -592,6 +662,10 @@ static VALUE nn_children(VALUE self)
|
|
|
592
662
|
}
|
|
593
663
|
ruby_xfree(buf);
|
|
594
664
|
ruby_xfree(kinds);
|
|
665
|
+
if (doc != Qnil) {
|
|
666
|
+
n->children_val = out;
|
|
667
|
+
n->children_ver = ver;
|
|
668
|
+
}
|
|
595
669
|
return out;
|
|
596
670
|
}
|
|
597
671
|
|
|
@@ -1940,18 +2014,28 @@ static VALUE nf_at_xpath_first(VALUE self, VALUE document,
|
|
|
1940
2014
|
* Nodesets free the handle here (TODO.perf/22 eager discipline);
|
|
1941
2015
|
* non-nodeset results return Qnil UNFREED — the caller keeps the
|
|
1942
2016
|
* scalar path, whose wrap owns the free. */
|
|
1943
|
-
static VALUE nf_xpath_result_rows_bulk(VALUE
|
|
1944
|
-
VALUE result_addr)
|
|
2017
|
+
static VALUE nf_xpath_result_rows_bulk(int argc, VALUE *argv, VALUE self)
|
|
1945
2018
|
{
|
|
1946
|
-
|
|
2019
|
+
VALUE document, result_addr, mx_context, mx_adapter;
|
|
2020
|
+
void *result;
|
|
1947
2021
|
void **buf;
|
|
1948
2022
|
int *kinds;
|
|
1949
2023
|
size_t scount;
|
|
1950
2024
|
long i, n;
|
|
1951
2025
|
VALUE cache, out;
|
|
2026
|
+
int all_native;
|
|
1952
2027
|
|
|
1953
2028
|
(void)self;
|
|
1954
2029
|
resolve_binding_classes();
|
|
2030
|
+
/* Optional (context, adapter): when the consumer passes its
|
|
2031
|
+
* contract state, every registered-klass row is born primed
|
|
2032
|
+
* (@native is the node itself, @context/@adapter written here)
|
|
2033
|
+
* and an all-native result extends with BulkIdentityRows —
|
|
2034
|
+
* the consumer's per-row wrap prime disappears from the
|
|
2035
|
+
* iterate-every-result lane (same triple as nn_create_element). */
|
|
2036
|
+
rb_scan_args(argc, argv, "22", &document, &result_addr,
|
|
2037
|
+
&mx_context, &mx_adapter);
|
|
2038
|
+
result = (void *)(uintptr_t)NUM2ULL(result_addr);
|
|
1955
2039
|
if (f_xp_type(result) != 0) /* XPATH_NODESET only */
|
|
1956
2040
|
return Qnil;
|
|
1957
2041
|
|
|
@@ -1969,6 +2053,7 @@ static VALUE nf_xpath_result_rows_bulk(VALUE self, VALUE document,
|
|
|
1969
2053
|
n = (long)scount;
|
|
1970
2054
|
out = rb_ary_new_capa(n);
|
|
1971
2055
|
cache = binding_cache_of(document);
|
|
2056
|
+
all_native = !NIL_P(mx_context);
|
|
1972
2057
|
for (i = 0; i < n; i++) {
|
|
1973
2058
|
void *ptr = buf[i];
|
|
1974
2059
|
int tag;
|
|
@@ -1988,10 +2073,17 @@ static VALUE nf_xpath_result_rows_bulk(VALUE self, VALUE document,
|
|
|
1988
2073
|
node = rb_hash_aref(native_cache_of(document), key);
|
|
1989
2074
|
if (NIL_P(node))
|
|
1990
2075
|
node = mint_consumer_node(mk, document, ptr);
|
|
2076
|
+
if (all_native &&
|
|
2077
|
+
!rb_ivar_defined(node, id_iv_mx_context)) {
|
|
2078
|
+
rb_ivar_set(node, id_iv_mx_native, node);
|
|
2079
|
+
rb_ivar_set(node, id_iv_mx_context, mx_context);
|
|
2080
|
+
rb_ivar_set(node, id_iv_mx_adapter, mx_adapter);
|
|
2081
|
+
}
|
|
1991
2082
|
rb_ary_push(out, node);
|
|
1992
2083
|
continue;
|
|
1993
2084
|
}
|
|
1994
2085
|
}
|
|
2086
|
+
all_native = 0;
|
|
1995
2087
|
node = materialize_xp_entry(document, cache, result, ptr,
|
|
1996
2088
|
kinds[i], (int)i);
|
|
1997
2089
|
if (node == m_native_sentinel) {
|
|
@@ -2005,6 +2097,22 @@ static VALUE nf_xpath_result_rows_bulk(VALUE self, VALUE document,
|
|
|
2005
2097
|
ruby_xfree(buf);
|
|
2006
2098
|
ruby_xfree(kinds);
|
|
2007
2099
|
f_xp_free(result);
|
|
2100
|
+
if (all_native) {
|
|
2101
|
+
/* Certificate for the consumer's fast row loop: every row
|
|
2102
|
+
* is a born-primed, registered-klass identity native. The
|
|
2103
|
+
* module lives in the Ruby layer (native_layer.rb) and may
|
|
2104
|
+
* not be loaded on faces used without it — an unresolved
|
|
2105
|
+
* mark degrades to the unmarked Array, never an error. */
|
|
2106
|
+
if (c_bulk_rows_mark == Qundef) {
|
|
2107
|
+
VALUE m_xml = rb_path2class("Leptris::XML");
|
|
2108
|
+
c_bulk_rows_mark =
|
|
2109
|
+
rb_const_defined_at(m_xml, id_bulk_rows_mark)
|
|
2110
|
+
? rb_const_get_at(m_xml, id_bulk_rows_mark)
|
|
2111
|
+
: Qnil;
|
|
2112
|
+
}
|
|
2113
|
+
if (c_bulk_rows_mark != Qnil)
|
|
2114
|
+
rb_extend_object(out, c_bulk_rows_mark);
|
|
2115
|
+
}
|
|
2008
2116
|
return out;
|
|
2009
2117
|
}
|
|
2010
2118
|
|
|
@@ -2599,6 +2707,58 @@ static void walk_columnar_impl(VALUE document, VALUE owner_klass,
|
|
|
2599
2707
|
}
|
|
2600
2708
|
}
|
|
2601
2709
|
|
|
2710
|
+
/* ---- Subtree memo priming (leptris-ruby#530) ---------------------
|
|
2711
|
+
* Registered-consumer documents (the #340 doc-klass map — moxml's
|
|
2712
|
+
* mint registration) walk whole subtrees top-down, so the FIRST
|
|
2713
|
+
* cold children_read fills every ELEMENT's name + children read
|
|
2714
|
+
* memos in ONE crossing, reusing the walk_columnar machinery and
|
|
2715
|
+
* minting through columnar_node_for (native-cache identity — the
|
|
2716
|
+
* primed wrappers ARE the answers later reads hand back). Memos
|
|
2717
|
+
* are version-stamped like the content memo: any mutation bumps
|
|
2718
|
+
* @version and retires them subtree-wide.
|
|
2719
|
+
*
|
|
2720
|
+
* Conservative by construction: only ELEMENT descendants get their
|
|
2721
|
+
* memos filled here (the one kind whose f_first_child chain IS its
|
|
2722
|
+
* children list, the #527 contract); leaf and shell kinds keep the
|
|
2723
|
+
* per-node fetch, which memo-stores the same way. The receiver's
|
|
2724
|
+
* own name memo is left to nn_name (one node, once). */
|
|
2725
|
+
static VALUE nn_prime_children_of(VALUE document, VALUE owner_klass,
|
|
2726
|
+
void *node, VALUE ver)
|
|
2727
|
+
{
|
|
2728
|
+
VALUE out = rb_ary_new();
|
|
2729
|
+
void *c;
|
|
2730
|
+
|
|
2731
|
+
for (c = f_first_child(node); c; c = f_next_sibling(c)) {
|
|
2732
|
+
int kind = f_node_type(c);
|
|
2733
|
+
VALUE wrapper = columnar_node_for(document, owner_klass, c, kind);
|
|
2734
|
+
struct native_node *nn;
|
|
2735
|
+
|
|
2736
|
+
TypedData_Get_Struct(wrapper, struct native_node, &nn_type, nn);
|
|
2737
|
+
if (kind == WS_NODE_ELEMENT) {
|
|
2738
|
+
const char *name = f_elem_name(c);
|
|
2739
|
+
nn->name_val = name ? rb_enc_interned_str(name, strlen(name),
|
|
2740
|
+
rb_utf8_encoding())
|
|
2741
|
+
: Qnil;
|
|
2742
|
+
nn->name_ver = ver;
|
|
2743
|
+
nn->children_val = nn_prime_children_of(document, owner_klass,
|
|
2744
|
+
c, ver);
|
|
2745
|
+
nn->children_ver = ver;
|
|
2746
|
+
} else if (kind != WS_NODE_DOCTYPE && kind != 9 /* DOCUMENT */) {
|
|
2747
|
+
/* leaf kinds: memo the name exactly as nn_name computes
|
|
2748
|
+
* it (f_elem_name answers "" for nameless kinds); their
|
|
2749
|
+
* (empty) children keep the fetch path, which
|
|
2750
|
+
* memo-stores the same way. */
|
|
2751
|
+
const char *name = f_elem_name(c);
|
|
2752
|
+
nn->name_val = name ? rb_enc_interned_str(name, strlen(name),
|
|
2753
|
+
rb_utf8_encoding())
|
|
2754
|
+
: Qnil;
|
|
2755
|
+
nn->name_ver = ver;
|
|
2756
|
+
}
|
|
2757
|
+
rb_ary_push(out, wrapper);
|
|
2758
|
+
}
|
|
2759
|
+
return out;
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2602
2762
|
static VALUE nf_walk_columnar(VALUE self, VALUE root)
|
|
2603
2763
|
{
|
|
2604
2764
|
struct native_node *n;
|
|
@@ -3715,6 +3875,7 @@ LEPTRIS_INIT_EXPORT void Init_native(void)
|
|
|
3715
3875
|
id_iv_mx_context = rb_intern("@context");
|
|
3716
3876
|
id_iv_mx_native = rb_intern("@native");
|
|
3717
3877
|
id_iv_mx_adapter = rb_intern("@adapter");
|
|
3878
|
+
id_bulk_rows_mark = rb_intern("BulkIdentityRows");
|
|
3718
3879
|
id_iv_parent = rb_intern("@parent");
|
|
3719
3880
|
id_iv_structure_memoizable = rb_intern("@structure_memoizable");
|
|
3720
3881
|
id_iv_native_fast = rb_intern("@native_fast");
|
|
@@ -3823,7 +3984,7 @@ LEPTRIS_INIT_EXPORT void Init_native(void)
|
|
|
3823
3984
|
rb_define_module_function(m_native, "materialize_xpath",
|
|
3824
3985
|
nf_materialize_xpath, 2);
|
|
3825
3986
|
rb_define_module_function(m_native, "xpath_result_rows_bulk",
|
|
3826
|
-
nf_xpath_result_rows_bulk,
|
|
3987
|
+
nf_xpath_result_rows_bulk, -1);
|
|
3827
3988
|
rb_define_module_function(m_native, "set_binding_name",
|
|
3828
3989
|
nf_set_binding_name, 3);
|
|
3829
3990
|
rb_define_module_function(m_native, "set_binding_text",
|
|
Binary file
|
data/lib/leptris/version.rb
CHANGED
|
@@ -59,6 +59,19 @@ rescue LoadError => e
|
|
|
59
59
|
MSG
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
# Certificate module for the bulk XPath rows face: an Array extended
|
|
63
|
+
# with this carries ONLY born-primed registered-klass identity natives
|
|
64
|
+
# (xpath_result_rows_bulk answered with a consumer context+adapter, so
|
|
65
|
+
# @native is the node itself and @context/@adapter are already set).
|
|
66
|
+
# Consumers with a per-row wrap in their result loop can key a fast
|
|
67
|
+
# path on it (moxml's NodeSet#each); one object per native address
|
|
68
|
+
# remains the binding's native-cache contract (#529) either way.
|
|
69
|
+
module Leptris::XML::BulkIdentityRows
|
|
70
|
+
def bulk_identity_rows?
|
|
71
|
+
true
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
62
75
|
module Leptris::XML::Native
|
|
63
76
|
# FFI.libleptris_candidates is the single source of truth — the
|
|
64
77
|
# native layer MUST dlsym the exact image the FFI layer loaded,
|
|
@@ -118,10 +131,15 @@ class Leptris::XML::Document
|
|
|
118
131
|
# (nodesets free the handle in C); a non-nodeset result answers
|
|
119
132
|
# nil and leaves the pointer with the caller — route it through
|
|
120
133
|
# Searchable.wrap_xpath_result for the scalar faces.
|
|
121
|
-
|
|
134
|
+
# Optional (context, adapter): when the consumer passes its
|
|
135
|
+
# contract state, every registered-klass row is born primed and an
|
|
136
|
+
# all-native result extends with BulkIdentityRows — the consumer's
|
|
137
|
+
# per-row wrap prime disappears from the iterate-every-result lane.
|
|
138
|
+
def xpath_result_rows_bulk(result_ptr, mx_context = nil, mx_adapter = nil)
|
|
122
139
|
Leptris::XML::Native.xpath_result_rows_bulk(
|
|
123
140
|
self, result_ptr.respond_to?(:address) ? result_ptr.address
|
|
124
|
-
: result_ptr
|
|
141
|
+
: result_ptr,
|
|
142
|
+
mx_context, mx_adapter)
|
|
125
143
|
end
|
|
126
144
|
|
|
127
145
|
# Builder factories that return NativeNodes (#149): one C call
|