Skip to content

libhxcpp 6.0.0-rc.2

Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 14 Nov 05:48
  • Added adoptInstances to a loaded cppia module: called with the module it replaces, before that one is released, it moves the live instances of each of the old module's classes onto the new class of the same name when the two lay out their fields the same way, so code reloaded into a running process reaches objects made before the reload. Calls on them run the new code, through interfaces and dynamic calls too, and Type.getClass gives the new class. It returns a row for each old class with live instances: how many moved, and for a class whose fields changed, which field differs. Bound methods and closures made before keep the old code. See docs/CppiaModuleRelease.md (libhxcpp #265)
  • Fixed the incremental collector (HXCPP_GC_INCREMENTAL) freeing a thread object's arrays while the thread was being created, as the gc stress test's verifier caught on Windows. A slice could find the new object on the stack while its first array was being allocated, and the cycle could end before the constructor's barrier, with the arrays stored after that unscanned. The arrays are now made in a mutation scope, which the stop that finishes a cycle scans again
  • cpp.encoding.Utf8.decode replaces each malformed UTF-8 sequence with U+FFFD instead of throwing, with smart strings or without. Haxe 5's Bytes.toString and getString decode with it, so they threw for bytes that Haxe 4's, which go through String::create, decode with U+FFFD in the same places. Valid input still takes the decoder that counts first; only malformed input takes the replacing one. Utf8.codepoint still throws
  • Fixed String::utf8_str into a view, at API level 500, writing the bytes and then throwing when the view had room for them but not the terminator. It returns false before writing anything. It also stopped a UTF-16 string at its first NUL, which is a character, and reported that length (libhxcpp #408)
  • Fixed String::create from a UTF-16 view, at API level 500, completing a high surrogate at the end of the view with the unit after it. The view bounds it: a high surrogate the view does not complete throws Invalid UTF16, as a broken pair inside it did (libhxcpp #412)
  • Fixed cpp.encoding.Utf8.encode returning a null array for the empty string, at API level 500 (libhxcpp #406)
  • Fixed cpp.encoding.Utf8.encode writing bytes for a code point that is no Unicode scalar value, a surrogate or one past U+10FFFF, which UTF-8 cannot hold and the UTF-16 encoder refused. Both encoders, and both getByteCount, throw for one before writing anything, at API level 500 (libhxcpp #407)
  • Fixed Haxe 5's Bytes.ofString keeping an array of three bytes for each unit of a string that was not all ASCII: cpp.encoding.Utf8.encode allocated for the worst case and only shortened it, so a megabyte of ASCII with one other character held 3 MB. It counts the bytes and allocates them exactly (libhxcpp #405)
  • Fixed a malformed cppia file that calls a static function on a host interface crashing the loader: it looked the function up in the interface's script glue, which an interface does not have. The fuzz job found it
  • Sped up joining an Array, which made a String for each element and then joined those. The digits go straight into the result, so joining 8,192 integers 200 times takes 41 ms instead of 53 ms, what writing them with std::to_chars takes (libhxcpp #415)
  • Fixed Gc.memInfo64(Gc.MEM_INFO_CURRENT) leaving out most of what was allocated since the last collection: a block taken from the free list without the lock, which is the usual way, was not counted until the next collection. Retaining 2 MB of arrays showed 90 KB more (libhxcpp #414)
  • Fixed Date.now() on Windows going back to 1902 after January 2038, x64 builds too: the seconds since 1970 passed through a long, which is 32 bits on Windows (libhxcpp #413)
  • Added timedWait to hx::thread::ConditionVariable, which Haxe 5's sys.thread.Condition.timedWait calls: with the Haxe nightly, every program that used Condition failed to compile. It returns true once a signal or broadcast came and false when the time ran out, and it waits out the wakeups MSVC's timed waits give just before the deadline with nothing signalled
  • Fixed an exception from blit, setSize or resize under the cppia JIT ending the process instead of reaching the script's catch, on typed arrays and on Array: their native calls had no exception bridge. The script catches it, as it does interpreted and in compiled code (libhxcpp #404)
  • Fixed resize() and cpp.NativeArray.setSize() on an Array under the cppia JIT evaluating the array expression twice, so a call in it ran twice and the array it returned the second time was the one resized. The JIT evaluates it once (libhxcpp #411)
  • Fixed indexOf and lastIndexOf on an Array under the cppia JIT ignoring fromIndex: the JIT never generated it, so a call or exception in it was lost too. The search starts from it, as it does interpreted and in compiled code (libhxcpp #410)
  • Fixed reverse() and resize() on an Array in interpreted cppia doing nothing: the interpreter had no case for them, and resize never evaluated its argument. They reverse and resize the array, as they do under the JIT and in compiled code (libhxcpp #409)
  • Added HXCPP_PROGRESS_PERCENT, which shows a group's compile progress as a percentage of its files, [42.5% ], instead of a count, [425/1000]
  • Fixed a program on Linux with glibc staying as large as its largest burst of large allocations, such as the files a game reads while it loads: glibc keeps a freed buffer's memory in its heap unless it had mapped the buffer on its own, and once a buffer mapped on its own has been freed it stops mapping those of that size or less, up to 32 MB. The memory of the large buffers a collection freed then stayed the process's. The collector now trims the C heap once 16 MB has been freed to it, on the thread that frees the buffers. A program that dropped 384 MB of 4 MB buffers stayed at 396 MB resident and now returns to 12 MB
  • Fixed a native extension that includes hx/CFFI.h before hx/CFFIPrime.h, as SteamWrap does, failing to compile with hxs_encoding, hxs_utf16 and alloc_hxs_utf8 not declared: CFFI.h included first declares the CFFI API without HXCPP_PRIME, so without the Prime string functions that the ordinary wrapper of a DEFINE_PRIME function now uses. CFFIPrime.h declares them then
  • Made the collector's thread context on Linux a __thread pointer, read with one load from the thread pointer, instead of a call to pthread_getspecific each time an allocation leaves the inline path or a String or number is boxed. It was 3 to 4% of an OpenFL game's main thread. HXCPP_PTHREAD_FAST_TLS keeps pthread_getspecific (libhxcpp #429)
  • Fixed a call on a null Array in cppia ending the process under HXCPP_CHECK_POINTER: push, contains, remove, indexOf, lastIndexOf, join, toString, sort, insert and unshift used the array without checking it, interpreted and under the JIT. They throw Null Object Reference, as a typed array's calls and the other Array calls do
  • Fixed the 32-bit x86 collector missing live objects held only in EBP when frame pointers are omitted. It now captures EBP with the other callee-saved registers; the lost strings in the Linux 32 CFFI tests were one consequence (libhxcpp #430)
  • Fixed GCC TSan builds reporting allocator races because a Clang sanitizer annotation also disabled instrumentation of the block-claim atomics on newer GCC. GCC keeps those atomics instrumented, without adding suppressions, and the Linux 32 and TSan jobs run on ubuntu-latest again (libhxcpp #430)
  • Fixed the fuzz job failing to find libFuzzer on Ubuntu 26.04 with Clang 21, whose reported runtime directory differs from the compiler-rt package's lib/linux directory. Setup and the fuzz build now check both locations for the native archive
  • Haxe 5 preview tests run in their own workflow, so their failures remain visible separately from the stable Haxe 4 runtime checks
  • Added HXCPP_PGO, profile-guided optimisation with MSVC, GCC and Clang: -D HXCPP_PGO=generate builds a program that counts what it runs, and -D HXCPP_PGO=use builds it again from what a run counted, with link-time optimisation. On a replication benchmark it took a further 4 to 29% off with MSVC, 19 to 43% with GCC and 12 to 46% with Clang. See docs/ProfileGuidedOptimisation.md
  • Fixed HXCPP_OPTIMIZE_LINK builds with Clang on Linux failing to link ("file format not recognized"): objects were compiled with -flto and linked without it, which GCC's linker plugin covered for, on one thread, and Clang's bitcode objects did not. Programs and shared libraries now link with -flto
  • Fixed an MSVC build with HXCPP_OPTIMIZE_LINK failing after any change (C1382, then LNK1257) until its objects were deleted: a group's PCH is rebuilt whenever one of its files compiles, and the link checks each object against the PCH it was compiled with. When the PCH is rebuilt under link-time code generation, the rest of the group is compiled against it too
  • Fixed the incremental collector (HXCPP_GC_INCREMENTAL) freeing items still in a sys.thread.Deque of more than 256 items, as the gc stress test's verifier caught about once in 75 runs: a cycle scans a long array in chunks, and the runtime's Deque moves its items itself, when a pop compacts the queue and when a push at the front makes room, which could carry items no chunk had reached into chunks already scanned. Those moves now have the queue scanned again, as Array's own moves do (libhxcpp #424)
  • Fixed hxcpp.gc.Incremental.getStats() returning null for six of its twelve counters when read by name, such as active and requestedSlices: they were fixed fields out of hash order, which a read by name searches. Printing the object and Json showed them, as those use the field's own name (libhxcpp #372)
  • The incremental collector no longer stops for a full reclaim every 15 collections, which took 5 ms on a 120 MB heap and 17 ms on an 800 MB one. Slices sweep a share of the blocks each collection instead, a finished cycle counts rows and leaves the sweep to the zeroing thread and the allocator, and a slice looks at the clock after each large job (libhxcpp #372)
  • Fixed the incremental collector doing no incremental work for a program that allocates mostly array storage, such as Bytes: a slice was skipped inside a mutation scope and a cycle could not finish in one, so every collection was a full stop. Slices run there now, and the stop that finishes a cycle scans the holders of open scopes again (libhxcpp #372)
  • The incremental collector (HXCPP_GC_INCREMENTAL) costs far less and stops for less. Each cycle is paced from the last one, starts as late as it can finish inside the free space the stop-the-world collector would spend, and spaces its slices by allocation as well as time. The collecting thread marks too, a slice no longer waits for a marker the scheduler has not run or for the zeroing thread, and an array's chunks are marked in parallel. On gc_pauses it went from 78% slower than the default collector to 9%, and the slowest 0.1% of work units from 2.8 ms to 0.9 ms (libhxcpp #372)
  • Fixed a thread that throws while the process exits crashing it on musl, as one with a failing cpp.Lib.load did about once in 800 exits on Alpine: libgcc's unwinder frees the table it finds frames in when the library finalizers run, and other threads still ran Haxe code then. The exit now parks every other thread that runs Haxe code, at its next safe point or as it leaves a GC-free zone, waiting up to 100 ms for one in a loop that does not allocate. A thread let go during the exit stays parked instead of ending (libhxcpp #423)
  • Fixed push of an Array of a type parameter, taken as a value, in programs built with Haxe 5: the generated call to push_dyn() did not compile, as it named no element type, and the closure it makes did not mark its array, so the array could be collected while only the closure held it. push_dyn defaults to Dynamic, and its closure marks, visits, hands back and compares its array as the other closures of a cpp.VirtualArray do
  • Fixed weak references to a method closure, and to adapters around one, being cleared while the receiver lived in programs built with Haxe 5: Haxe 5 generates a member closure as a callable that holds its receiver but gives no handle, so the collector could not reach the receiver from it. A callable now hands back the one object it visits, as the closures of Haxe 4 handed back their receiver, and local functions still give none, so what they capture does not keep them
  • Fixed Lock.wait() returning false at once, without waiting, in programs built with Haxe 5: its Lock is a Semaphore, and wait() passes its default timeout of -1 to Semaphore.tryAcquire, which polled for a negative timeout since #122. A negative timeout now waits until the semaphore is released, as Lock.wait has always done; NaN still polls
  • Fixed an array drained by pop, shift, remove or splice keeping the storage it had grown to for as long as it lived. In programs built with Haxe 5, whose sys.thread.Deque is an Array that pop shifts, a thread mailbox that once held a million messages held 8 MB, as the runtime's own Deque did before 6.0.0. An array left under a quarter full now gives back half its storage or more, keeping 16,384 slots
  • Fixed cpp.encoding.Utf8.decode accepting malformed UTF-8 when strings are not smart strings (disable_unicode_strings): the bytes were copied without being read. They are still copied as they are, but malformed input throws, as it does with smart strings
  • Fixed Bytes.ofString throwing Invalid UTF16 for a string with a lone surrogate, such as half of a pair that substr split, in programs built with Haxe 5: its Bytes.ofString calls cpp.encoding.Utf8.encode, which read the string as UTF-16 bytes, where a surrogate must be paired. Utf8.encode and Utf8.getByteCount now take a lone surrogate in a string as U+FFFD, as Bytes.ofString, urlEncode and utf8_str() do with Haxe 4 since #110; Utf16.codepoint, which reads bytes, still throws
  • Fixed an extern function used as a value, such as cpp.NativeProcess.process_stdout_read in an array, becoming the Bool true: the generator names the C++ function, which converted to Dynamic through bool. Calling it returned null with Haxe 4 and threw Null Function Pointer with Haxe 5. Such a function is now a function value that calls it, and a Haxe 5 variable of the function's type takes it as well
  • Fixed programs that use sys.ssl without sockets failing to link on Linux with an undefined reference to hxcpp_alloc_kind: hxcpp_std, linked a second time after hxcpp_ssl, came after the runtime's second copy. The runtime is linked once more after all the libraries linked twice, which keep their order
  • Fixed closing, reading or polling a socket handle that a library made in stock hxcpp's layout, as CrossByte's accept does, reading past the handle: the runtime took its own wrapper's later fields from it, and a close wrote through what followed it in memory. Only the descriptor is read from such a handle, and the runtime's wrapper no longer shares its name, and with it its vtable, with a library's
  • Fixed cpp.net.Poll on Linux, macOS and the BSDs never reporting a socket ready when its handle was a library's, as CrossByte's accepted connections are, and it had the descriptor of one the poll had registered and that was since closed: such a handle has no serial to tell one socket from the next, so the registration was taken to carry over, where the kernel had dropped it at the close. CrossByte's HTTP/1, HTTP/2 and PHP servers stopped hearing from new connections. A library's handle is registered again at each prepare
  • Fixed a map that two marking threads marked at once being left unable to fold its buckets: the marker counted itself as a walk over the map without a lock, so the count could stay above zero. Marking no longer counts as a walk, as folding only happens after it (follow-up to libhxcpp #204)
  • Fixed the moving collector storing a moved object's new address as a pointer at an address only 4-byte aligned, which is undefined and which UBSan reported once string data stopped being 8-byte aligned. The address is copied in and out
  • Fixed generated field lookups, and the runtime's own, reading past the end of a field name shorter than the name they compared it with: HX_FIELD_EQ compared the whole literal, terminator included, without checking the length, which ASan reported once string data stopped being padded to 8 bytes. It compares the length first, as HX_QSTR_EQ does (libhxcpp #257)
  • Fixed a malformed cppia file with a local variable or a return outside any function, as a static var's initial value, crashing the loader, which read the function's frame layout through a null pointer, or, for a declaration, writing before the frame when it ran. It fails to load with "Local variable outside a function" or "Return outside a function". A class's __init__, which cppia runs as an expression rather than a function, now has a frame of its own, so locals declared in it get their own slots (libhxcpp #257)
  • Fixed a malformed binary cppia file with an op number past the last op being read as an op, which is undefined. It fails to load with "Unknown op" (libhxcpp #257)
  • Fixed a malformed cppia file whose function body was some other expression being run as a function. It fails to load with "Function body is not a function" (libhxcpp #257)
  • Fixed the fields and text of a Date whose time is not a number, or past what a year in a tm holds, converting the time to whole seconds, which is undefined. Such a time gives the fields of the epoch (libhxcpp #257)
  • Fixed the runtime not compiling at API level 500, which Haxe nightly builds use: a cppia module's release function defined only the __run that level 500 removed, and VirtualArray's closures compared arrays with a != that C++20 finds ambiguous
  • Fixed converting a weak map to another value type losing live keys, about one in five in a map whose keys had mostly died: a collection during the conversion folded the map's buckets (#204), moving entries into buckets the conversion had already passed. A collection now leaves the fold to a later one while anything walks the map, which keys(), values(), toString and conversion do (libhxcpp #204)
  • Fixed the moving collector (HXCPP_GC_MOVING) giving the whole heap back on Gc.run(true) and whenever the allocator's free list filled, as the other modes stopped doing in #230 and #231: a heap with a small live set stayed near 9 MB and collected far more often, and Gc.run(true) shrank it to 1 MB. Only Gc.compact() releases everything now; the collector still moves objects on those collections (libhxcpp #231)
  • Sped up converting a Float to a String, which rounded it with printf to 15, 16 and 17 digits and read each back with strtod to find the shortest digits that read back. Grisu3 finds them with integer arithmetic, and the old search does the doubles it cannot decide, about 0.5% in Loitsch's measurements. The text is the same for every value: Std.string on Floats went from 996k to 8.8M conversions a second (libhxcpp #390)
  • Fixed a thread whose cpp.Lib.load was failing crashing the process at exit on Windows, about once in a hundred exits: a failing load reads haxelib's files to look further, and exit frees the C runtime's table of open files while other threads still run. The loader reads them with Win32 calls instead (libhxcpp #371)
  • Fixed Gc.trace with path printing overflowing the native stack on a deep graph, as it marked by recursing all the way down: it now recurses 256 objects deep, and paths below that start with "... + higher". It also counts instances that are large allocations and instances with no object fields, which it missed, and prints paths through large objects from their root (libhxcpp #389)
  • Fixed val_buffer losing the text of a value after a NUL character: it measured the UTF-8 text with strlen. It now appends the text's full byte count (libhxcpp #393)
  • Fixed Date's local fields keeping the previous time zone after the zone changed: the last time converted is cached per thread, and the cache was keyed by the time alone, so a date read before the change read the old zone until another time was converted. The cache now also keys on the zone the C library has, and Sys.putEnv("TZ") applies the new zone at once, where localtime_r and the Windows CRT had kept the old one until something called tzset (libhxcpp #392)
  • Fixed cpp.NativeFile.file_open with an exclusive-create mode such as "wbx" truncating a file that exists on Linux, macOS and other POSIX systems: files are opened with open(2) to make them close-on-exec, and the mode was mapped without O_EXCL. Such a mode now fails on a file that exists and leaves it as it was, and x without w fails too (libhxcpp #391)
  • Sped up byte-wise reads from TCP sockets, such as Socket.input.readLine and readUntil, which called recv for every byte, in a GC-free zone of its own. Reading one byte now takes what else the kernel already holds, up to 4 KB, and every other read, select, fast select, both Poll calls and TLS take those bytes first, so blocking, timeouts, nonblocking reads, end of stream, shutdown and reads from several threads behave as they did. Reading 128 KiB of 128-byte lines with readLine went from 78 ms to 2.0 ms; through a 16 KiB BufferInput it takes 0.8 ms (libhxcpp #338)
  • cpp.net.Poll keeps its registrations in the kernel, with epoll on Linux and Android and kqueue on macOS, iOS and the BSDs, so an events call costs what is ready instead of every socket registered: poll() looked at all of them on every call, 0.3 ms a call for 4,096 idle sockets on Linux. prepare tells the kernel only what changed since the last one, and the results are as before, including a socket closed after prepare reported as ready to read and write. Where the kernel will not make a queue, and on Emscripten, Poll uses poll() as before. Windows keeps select, which WSAPoll did not beat: at 1,024 idle sockets it took 0.12 ms a call and WSAPoll 0.71 ms (libhxcpp #320)
  • Sorting an array of Ints, Floats or other plain values with a comparator no longer holds a box for every element for the whole sort. An array past 16,384 elements sorts runs of that size, each through boxes as before, and merges them, boxing each value as the merge reaches it, so the boxes alive at once are those of one run. Sorting 200,000 Ints (sort_int) peaks at 29.6 MB instead of 32.4 MB (stock hxcpp 4.3.53: 28.2 MB) and runs 1.19x faster (libhxcpp #256)
  • String data no longer starts 8-byte aligned. Objects and data that hold doubles or atomics need the alignment and text does not, and a short string could take 4 bytes of padding. map_string, which keeps 400,000 String keys built at runtime, peaks at 117 MB instead of 132 MB (stock hxcpp 4.3.53: 110 MB; what is left is the memoized hash slot and the bucket array, both kept for lookup speed), sort_string at 29.7 MB instead of 32.8 MB and gc_pauses at 132 MB instead of 135 MB. string_split peaks at 45 MB instead of 41 MB (stock: 73 MB): with fewer small bytes per split, collections come less often and more of its dead 16 KB result arrays wait for one. The generational collector's nursery, which finds objects by walking from header to header, now skips the zeroed word that pads an aligned allocation instead of assuming every allocation is padded (libhxcpp #370)
  • Fixed the collector freeing part of a GC block, which corrupts the heap: releasing a buffer of 4000 to 16380 bytes that sat in a block, as InternalNew makes of a 3997 to 3999-byte request, queued it as a large allocation to be freed. StringTools.urlEncode on a 3998-character string with non-ASCII text could do it. Only allocations on the large list are released early now (libhxcpp #257)
  • Fixed a malformed cppia file hanging its host: a class whose super class chain led back to itself made linking walk the chain forever. Such a file now fails to load with "Class extends itself" (libhxcpp #257)
  • Fixed a malformed cppia file ending its host with out-of-memory: the loader sized a function's argument list, and the lists of expressions, object fields, variables, switch cases, catches and interfaces, from counts it had not checked, so a 602-byte file asked for 31 GB. A count larger than the data left now fails the load with "Bad count", as the string and class counts already did (libhxcpp #257)
  • Fuzz targets in test/fuzz cover the cppia loader, UTF-8 and UTF-16 strings, Bytes, Serializer, Json, EReg, number parsing, URL decoding and zlib, and check what each must preserve, such as valid UTF-8 surviving a round trip. CI runs them under libFuzzer, ASan and UBSan for 30 seconds a target on each change and 10 minutes daily, and test/fuzz/run.sh runs them locally, with clang or MSVC (libhxcpp #257)
  • HXCPP_SANITIZE works with MSVC for address and fuzzer, so -D HXCPP_SANITIZE=address builds with cl.exe's AddressSanitizer. The collector's stack scan and ASan defaults had GCC-only attributes that stopped such a build compiling
  • The benchmarks run in CI for each change against its base commit on the same runner, and report throughput, tail pauses and peak memory separately, as warnings when they move past their run-to-run noise. A daily run compares main with itself to measure that noise, and runs on main keep their results on the bench-history branch. bench/Run.hx compares with another libhxcpp checkout with --base, and bench/Compare.hx reports the differences (libhxcpp #258)
  • On Windows, a build with cl.exe warns when a source, generated header or object path reaches 260 characters, which MSVC cannot open even with long paths enabled and reports as missing, and says how to build through a short junction instead. Object file names longer than 48 characters are cut and hashed, so a generic instance's object path no longer reaches the limit before its source. Shorter generated file names need a Haxe change; docs/WindowsLongPaths.md has the details (libhxcpp #356)
  • Fixed __hxcpp_get_proc_address crashing when asked to fail quietly for a primitive an ndll does not have: it called the primitive's query function though the library had no such symbol. It now gives null without a message, where the lookup that is not quiet gives null with one (libhxcpp #399)
  • Fixed CFFI ndlls under neko 2 reading a plain neko string or array as twice its length, so copying or walking one read past its end, and misreading Ints beyond 31 bits, which val_type gave as null: the neko glue read value tags as neko 1.8 lays them out, with 3 type bits where neko 2 has 4 and no values of its own for such Ints. It now reads the layout of the neko it runs in, and alloc_int makes neko 2's Ints beyond 31 bits instead of dropping the top bit. Haxe Strings and Arrays, which the glue reads through their length field, were not affected (libhxcpp #400)
  • Fixed alloc_null and alloc_bool in CFFI ndlls under neko giving C NULLs until the program called neko_init, as lime and cpp.Prime.nekoInit do and plain neko programs do not: neko raised such a result as an error, and crashed printing one held in an object. They are now neko's own null, true and false from the start, and val_bool reads true without neko_init too (HaxeFoundation/hxcpp#108) (libhxcpp #401)
  • Fixed a program ending on an uncaught throw null crashing in the handler that reports it, which read the custom stack field of the thrown value before checking it for null. It prints "Error : null" and exits with -1 again, as before custom stack traces (HaxeFoundation/hxcpp#1220) (libhxcpp #402)
  • Fixed a sys.thread.Deque keeping the storage a burst grew it to once it drained: a thread mailbox that once held a million messages held 8 MB for as long as it lived. A deque that drains now gives back storage above 16,384 messages (libhxcpp #316)
  • Sped up sys.thread.Deque.push, which adds at the front and moved every queued item for each push while holding the queue's lock, so filling a deque from the front was quadratic. 65,536 pushes and pops went from 489k to 4.73M messages a second, the rate of adding at the back (libhxcpp #317)
  • Sped up val_string on a boxed non-ASCII string, which converted the whole string to UTF-8 into a new buffer on every call. The box now keeps the first conversion: reading a boxed 65,536-character string 256 times went from 3.3k to 284M calls a second, and peak memory from 40 MB to 9 MB (libhxcpp #322)
  • Sped up val_callN and val_ocallN with up to five arguments, which built an argument array for every call. They now call the fixed-arity entry points, as val_call0 to val_call3 do: a three-argument callback through val_callN went from 31M to 62M calls a second (libhxcpp #324)
  • Sped up Std.string on deeply nested enums, which copied each parameter's text into its parent's, quadratic in the depth, and recursed once per level, so a chain a million deep overflowed the native stack. Enums are now formatted in one pass: a 2,048-deep enum formats 33x faster (libhxcpp #328)
  • Fixed formatting a map that holds itself, directly or through other maps, ending the program with a stack overflow. Past 5 nested maps a map now formats as "...", as arrays and anonymous objects already did (libhxcpp #343)
  • Map entries with Int values in StringMap, ObjectMap and Int64 maps take 8 bytes less on 64-bit: the hash sat after the key, leaving padding beside the value. A 200,000-entry StringMap holds 9.6 MB instead of 11.2 MB (libhxcpp #370)
  • Fixed process pipes reaching an unrelated child on Linux, macOS and other POSIX systems: they were created with pipe and marked close-on-exec afterwards, so a process another thread started in between kept them, and the first child's output could stay open until that process exited. They are now created close-on-exec with pipe2 where the system has it, and elsewhere no process the runtime starts can fork in between (libhxcpp #340)
  • TLS contexts count their native mbedTLS memory towards collection pressure: about 39 KB each after setup, mostly record buffers, and what handshakes and reads add, so contexts dropped without close are collected and freed sooner. The bundled mbedTLS is built with an allocator of hxcpp's that counts what the calls on a context allocate; with a provider's mbedTLS a context counts its record buffers (libhxcpp #325)
  • sys.db.Sqlite connections count their native page cache, schema and statements towards collection pressure, as SQLite measures them for the connection, so a connection dropped without close is collected and its memory freed sooner. An in-memory database holding a 16 MiB blob had 18 MB the collector never saw (libhxcpp #319)
  • EReg counts its native PCRE2 memory towards collection pressure: the compiled patterns of both string widths, their match data with the frames a match keeps there, and with HXCPP_PCRE_JIT the jitted code. 128 expressions of 10,000 literal characters held 6 MB the collector never saw, so abandoned expressions waited for an unrelated collection to be freed (libhxcpp #303)
  • Fixed HXCPP_GC_GENERATIONAL builds keeping released old large buffers while large allocations started collection after collection: with a small heap they were all minor, and only a full mark can free an old buffer. Once the large and native allocations since the last full mark add up to the heap it left, the next collection is full. Churning 256 MB through 1 MB buffers after releasing 64 old ones kept 91 MB and keeps 17 MB (libhxcpp #360)
  • A collection no longer frees the previous recycle cache of large buffers while every thread is stopped: a thread of its own frees it once they run again, and the bytes count as reserved until it has. A collection that dropped 16,384 cached 4 KB buffers took 8.1 ms and takes 0.06 ms. Gc.compact and other compacting collections still free them before they return (libhxcpp #332)
  • Large copies into a new buffer no longer clear it first: Bytes.sub, Array.copy, Array.slice and fromData on arrays without object pointers, strings made from bytes or other text, and NewGCBytes and NewGCPrivate with data. Copies of a 1 MB buffer run about 20% faster. Bytes.alloc and other allocations are zero-filled as before (libhxcpp #315)
  • Fixed Gc.memInfo(MEM_INFO_RESERVED) leaving out the dead large buffers a collection keeps for reuse: after a burst of large allocations it fell back to its baseline while the process still held them all. They are counted as reserved, not live, until reused or freed (libhxcpp #313)
  • A large allocation takes a recycled buffer of its size without looking at the other sizes cached: the recycle cache keeps a list for each size. 20,000 resizes from a cache holding 8,192 buffers of another size took 218 ms and take 13 ms (libhxcpp #300)
  • Releasing a large buffer, as an exact resize of an Array or BytesBuffer growth does, no longer searches every other large allocation for it: each allocation keeps its place in the allocator's list. 20,000 resizes of a buffer made before 8,192 others took 77 ms and take 12 ms (libhxcpp #298)
  • A chain of entries inside one weak map, each key's value leading to the next key, is marked in one pass over the map instead of one pass per link: a 4,096-link chain made a full collection take 73 ms, and takes 0.9 ms. The rest of the chain #203 left to the next pass for a single map (libhxcpp #378)
  • Full collections give back the object ID tables' storage once the IDs' objects have died: the unused IDs at the top of the range are dropped and storage far beyond what is left is freed. After a million IDs whose objects died, about 13 MB of vectors and a million hash buckets stayed allocated (libhxcpp #379)
  • The collector keeps 256 spare marking chunks and frees half of the rest in each full collection, at most 1,024, where it kept every chunk it ever made: after a million old objects each took a young child, about 9,600 chunks, 4.7 MB, stayed allocated for the rest of the process (libhxcpp #374)
  • A collection whose roots and stacks leave nothing to mark no longer wakes and joins every marking thread to find that out: an idle minor collection with HXCPP_GC_GENERATIONAL took about 0.02 ms, almost all of it the workers, and takes about 0.005 ms (libhxcpp #377)
  • A full or minor collection after many finalizers were registered no longer rebuilds each surviving registration's table entry to move it to the old table: the larger table keeps its entries and the smaller one is copied in. A full collection after 125,000 objects were given finalizers again took 34 to 42 ms, and takes 10 to 12 ms (libhxcpp #375)
  • Minor collections with HXCPP_GC_GENERATIONAL no longer walk every object given to Gc.doNotKill, only those given since the last collection: an old object cannot die in a minor collection. With 250,000 registered objects a minor collection took 9 to 15 ms, and takes under 0.1 ms (libhxcpp #383)
  • Fixed a thread that collects keeping an unreachable object alive through every later collection it made from the same place, on Windows x64 with MSVC: the collector took its fifth argument on the stack, in the range the thread's own stack scan covers, and MSVC stores a bool there as one byte over what the slot held, so a stale heap address with its low byte cleared could point at a dead object. The collector's own calls now pass their options in one register (libhxcpp #367)
  • A regular expression match over 1,024 characters or more no longer holds up collections that other threads start: the match runs in a GC-free zone, keeping its subject and expression alive and in place. While one thread matched a 64 MB subject, a collection on another waited about 80 ms for it, and now takes about 0.1 ms. Shorter matches run as before (libhxcpp #330)
  • Fixed the collector closing a file that was no longer reachable while every thread was stopped: the close flushes the file's buffer, so a pipe reader or slow storage that held the flush up held up every thread with it. Such a file is now closed by a background thread once the threads run again; a collection does not wait for it, and exit still flushes a file it has not closed yet (libhxcpp #331)
  • Full collections keep the sorted index of large allocations that the stack scan searches, dropping the freed ones and adding the new survivors, instead of sorting every base again once a few stack words fall among them: with 65,536 retained 4 KB buffers and stack pointers into them a full collection took 3.3 to 3.9 ms, and takes 1.5 to 2.1 ms. Minor collections kept it already (libhxcpp #365)
  • Minor collections with HXCPP_GC_GENERATIONAL no longer walk every object ID that __hxcpp_obj_id has given, as ObjectMap does for its keys with HXCPP_GC_MOVING, only those given since the last collection: an old object cannot die in a minor collection. With 500,000 registered IDs a minor collection took 37 to 59 ms, and takes about 0.03 ms (libhxcpp #357)
  • Minor collections with HXCPP_GC_GENERATIONAL no longer walk every entry of a weak map whose values are Ints, Floats or Int64s, twice, to mark values that hold nothing: with a million entries in an old WeakMap<K,Int> a minor collection took about 57 ms, and takes about 19 ms. A map that converts to object or String values still marks them through its live keys (libhxcpp #333)
  • Fixed the collector's elapsed-time stamps following the wall clock on Linux, Android, Emscripten and other POSIX systems, where gettimeofday came before the monotonic clock: a clock correction made HXCPP_GC_SUMMARY, PROFILE_COLLECT and telemetry times negative or a minute long, and threw off HXCPP_GC_DYNAMIC_SIZE's collection ratios. One of the uses HaxeFoundation/hxcpp#887 reports (libhxcpp #347)
  • Fixed __hxcpp_gc_census calls made at the same time counting too few objects, often none of a class that was held: each call published its counts through globals the other replaced or cleared, and one that found another collection running returned without its own. Calls now take turns, and each waits for a full collection to fill its counts (libhxcpp #363)
  • A cppia host can register other script formats with the loader: __scriptable_cppia_register_format(magic, translate) hands a script that starts with the magic to the translate function, as bytes, and loads the cppia it returns, text or binary, in its place. Module.fromData and fromString, and so Host.runFile and the Cppia host's command line, then load such scripts, interpreted or with the JIT, so a host compiled with a translator runs that format as it runs .cppia files. A script in no registered format still fails with "Bad magic" (libhxcpp #396)
  • Fixed a copy of an hx::Ref not keeping its object alive: copying one of the same type shared the original's GC root, so once the original went the collector could free the object the copy still held (libhxcpp #355)
  • Fixed hx::Ref::setPtr leaving its GC root at the old offset when it moved to another interface of the same object, so the collector could free the object while the reference still held it (libhxcpp #361)
  • Fixed an exception thrown by a finalizer leaving the collector paused: it unwound out of the collection with every other thread still stopped. The collection now finishes, running the other finalizers, and the first exception is thrown to the code that started it (libhxcpp #358)
  • Fixed Gc.trace missing old instances with HXCPP_GC_GENERATIONAL: it could run a minor collection, which does not mark them again, so a retained class could count none (libhxcpp #359)
  • Fixed GCChangeManagedMemory with a delta near the top of the Int range raising the large-allocation allowance to nearly the whole address space, so large allocations stopped starting collections long after the memory was released (libhxcpp #362)
  • Fixed weak references to a callback behind 16 or more adapters being cleared while the receiver lived: the walk to the receiver stopped after 16 hops. It now follows any chain, and still clears a cycle of dead adapters (libhxcpp #364)
  • Fixed a large object held only on the stack keeping itself alive but not what it held: the stack scan set its mark without marking its members, so they could be freed while it still referenced them. One of the conservative-scan misses of the kind HaxeFoundation/hxcpp#945 reports (libhxcpp #366)
  • Fixed cppia scripts with an array literal of objects failing to load with the JIT under HXCPP_GC_GENERATIONAL, with "Bad move target": the write barrier for each element was given a register with no type
  • Added __scriptable_cppia_retained(), which collects and then lists each released cppia module still loaded with what of it is live: the instances of its classes by class, with counts and bytes, and the bound methods and closures of its functions. It works in release builds, and docs/CppiaModuleRelease.md says what it counts and how to go on from it to what holds them (libhxcpp #264)
  • Added a host fingerprint that cppia scripts can require, described in docs/CppiaHostFingerprint.md. __scriptable_host_fingerprint() returns 16 hex digits standing for the classes, functions and fields a host gives scripts, and the Cppia host prints its own with -fingerprint. A script built with it as a resource named __cppia_host loads only into that host; any other refuses it before linking, with a message naming both fingerprints. Scripts without the resource load as before (libhxcpp #263)
  • The Cppia host that haxelib run hxcpp uses, built by project/compile-cppia.hxml, gives a script only the arguments after it in Sys.args(), as a compiled program has: Cppia script.cppia a b gives ["a", "b"] where it gave the script's own path first, and a -jit given to the host was in the list too. Host options go before the script (Cppia -jit script.cppia ...); a -jit after the script still turns the JIT on, as before, and the script sees it (HaxeFoundation/hxcpp#901, HaxeFoundation/hxcpp#1174)
  • Fixed a cppia script out of step with its host ending the process from jitted code instead of throwing. In a host built with HXCPP_CATCH_SEGV, as the Cppia host is, a null access in jitted code ended it, on macOS with "terminating due to uncaught exception of type Dynamic"; jitted code now checks for null there as it does with HXCPP_CHECK_POINTER. A const char * or std::exception thrown by native code that jitted code called ended it too, and is now a String the host can catch, as in the interpreter. A script calling a host function with the wrong number of arguments now fails to load with that function named, such as "Could not link Thing.add with 2 arguments: the host's takes 1", instead of "CallHaxe: Invalid arg count" (HaxeFoundation/hxcpp#1190, HaxeFoundation/hxcpp#358)
  • Fixed cppia script objects using more memory than in hxcpp 4.3. Since script fields are aligned to their types, an Int declared before an object field left a 4-byte gap, so the benchmark's object with an Int and an object field grew from 36 to 40 bytes, and its heap grew to 20 MB instead of 16 MB (27.5 MB peak against stock's 24.4 MB). Fields are now laid out from the widest alignment down, which leaves no gap (libhxcpp #369)
  • Fixed an hx::AutoGCFreeZone inside a GC-free zone its caller had already entered leaving that zone when it ended, so the caller went on outside the zone it expected to own and its own exit failed with "GCFree Zone mismatch". A guard now leaves only a zone it entered (libhxcpp #387)
  • Fixed _hx_gc_freeze turning a non-ASCII string into garbage: the copy kept the UTF-16 data but not the header flag that marks it UTF-16, so it compared, decoded and hashed as 8-bit text (libhxcpp #382)
  • Fixed an ObjectMap frozen by _hx_gc_freeze finding none of its keys: the keys were copied into new objects, but the map kept the hashes and buckets of the originals, whose identity is the hash. Freezing now rehashes each map after copying its keys (libhxcpp #381)
  • Fixed Gc.trace without path printing overflowing the native stack on a deep graph, such as a linked list of 100,000 nodes, in debug builds: it marked each object by recursing into it. Counting now marks from the mark stack, on one thread so each instance counts once; printing paths still recurses (libhxcpp #389)
  • Fixed a bound method or callback adapter held only by a WeakRef having its finalizer run while its receiver lived: the collection chose what to finalize before deciding that the weak reference keeps such a callback, so WeakRef.get still returned it afterwards. Callbacks a weak reference keeps are now marked before finalizers are chosen (libhxcpp #376)
  • Fixed a large object, of 4,000 bytes or more, held only by native code through the address of one of its fields being freed: the stack scan recognized a large allocation only by its exact start, while for a smaller object it already accepted a pointer up to 64 bytes in (32 on 32-bit). Large allocations now take the same allowance (libhxcpp #373)
  • Added an opt-in incremental marking collector for native Haxe 4 C++ builds (-lib hxcpp -D HXCPP_GC_INCREMENTAL), with automatic allocation pacing, optional hxcpp.gc.Incremental scheduling hooks, resumable array and map scans, an independent verifier and deterministic regression tests. The existing collector remains the default. Slice budgets are targets, and synchronous completion and memory pressure can still cause longer pauses; see docs/IncrementalGc.md
  • Emscripten programs let memory grow and get a 5 MB stack by default. They linked with Emscripten's fixed 16 MB of memory, which aborts with "Aborted(OOM)" as soon as a program holds more, and since Emscripten 3.1.27 a 64 KB stack, which Haxe recursion and the pointers that spill-pointers keeps on the stack soon overflow. HXCPP_LINK_NO_MEMORY_GROWTH and HXCPP_LINK_NO_STACK_SIZE restore Emscripten's settings, and HXCPP_LINK_STACK_SIZE sets another size
  • Fixed converting a long or a size_t to Dynamic failing to compile on Emscripten, where long is 32 bits but not int, as an Int default of -2147483648 does (HaxeFoundation/hxcpp#621)
  • Fixed cppia hosts built with HXCPP_DEBUGGER failing to compile on Emscripten, which has no cppia JIT: the debugger's frame reader asked whether a function was jitted through a field that only exists with the JIT
  • The regression tests run on Emscripten in CI, under node, except those in test/regression/emscripten-skip.txt, which need threads, processes, sockets or the desktop GC settings. HXCPP_LINK_NODERAWFS links a program that reaches the host's files under node, as the tests do
  • Fixed the Emscripten build failing to compile Socket.cpp, which called monotonicSeconds where it was not defined, and, on Windows, failing at the strip step, which passed emstrip.py to python with the quotes still around its path
  • Fixed Sys.programPath on Emscripten under node giving the path of node itself on Linux, so a cppia host that loads a script from beside itself looked for it next to node. It now gives the absolute path of the program's .js file, and null in a browser, where the program has no file path
  • Fixed a class with a cpp.Function field failing to compile with HXCPP_GC_GENERATIONAL: Haxe 4.3 write barriers the field's setter as if it held an object, and cpp::Function now has the null mPtr that barrier needs (HaxeFoundation/hxcpp#1425 by Tutez64)
  • Fixed the collector scanning a thread that had just entered a GC-free zone without seeing that thread's last writes, on ARM64 and other weakly ordered CPUs: it could read stale registers and miss an object held only there
  • Fixed the shared boxes for Ints and Int64s from -1 to 255 reaching another thread before they were built, on weakly ordered CPUs
  • Fixed haxe.io.Bytes and Memory reading and writing 16, 32 and 64-bit values through misaligned pointers at odd offsets, which is undefined and traps on CPUs without unaligned access
  • Fixed haxe.Timer.stamp when threads make the first call together: later stamps could move backwards, and on Apple platforms it could divide by a timebase not yet read
  • Fixed a cppia cast that compiles to nothing reading the expression it had just freed
  • __hxcpp_set_float_format accepts only a pattern with one floating-point conversion, such as %.6g, and throws otherwise: a pattern with %s or %n read or wrote memory through the double it was given
  • Fixed a collection waiting for a thread that loops on an uncontended Semaphore.acquire until the loop ended, on Linux, Windows and other POSIX systems: the fast path now stops at a pending collection, as Mutex.acquire and Semaphore.tryAcquire do
  • Fixed @:nativeGen interfaces on a class that implements more than one: converting an object, or a Dynamic, to the second interface gave the object's address instead of the interface's, so calls through it crashed, and the collector freed an object held only through such an interface. Classes with these interfaces also failed to compile with MSVC (HaxeFoundation/hxcpp#1380)
  • Fixed Std.isOfType(v, Class) and Std.isOfType(v, Enum) both being true for every class and every enum: a class is now only a Class and an enum only an Enum, as on the other targets, and haxe.Serializer writes an enum type as an enum (HaxeFoundation/hxcpp#1391)
  • Fixed cpp.marshal.View.slice(index, length) accepting a length so large that the bounds check overflowed, which gave a view larger than its buffer (API level 500)
  • Fixed cppia on 32-bit ARM and Emscripten storing only the high half of a Float in a frame, so Float arguments, locals and results lost their low bits
  • Fixed cppia script classes that implement a host interface with type parameters, such as a Map<String, Int>: calls through the interface passed the arguments as objects while the script function read them as typed values, so they read the wrong values and could crash. Such a call now goes through an adapter that converts the arguments and the result
  • Fixed Process.close, and the collector cleaning up a Process, leaving the child a zombie on Linux, macOS and other POSIX systems when it was still running: such a child is now reaped when it exits, by a thread that waits only for those children, without blocking close or killing the child, and without a SIGCHLD handler
  • The regression, std and GC stress suites run under UBSan, ASan and TSan in CI, and CodeQL analyzes the C++ sources
  • Fixed HXCPP_SANITIZE=address builds freeing live objects: ASan's use-after-return check, on by default with GCC 13 on Linux, moves locals into frames off the stack, where the collector does not look for them. The runtime now turns that check off by default; ASAN_OPTIONS can still turn it on
  • The build tool stops with a clear error when a file group lists files whose names differ only in case, such as the Texpr.cpp and TExpr.cpp that classes Texpr and TExpr generate: on Windows and macOS they are one file and one object file, and the build failed with unrelated errors (libhxcpp #70). Rename one of the classes
  • Fixed the heap not growing to its working target without the moving collector: when the allocator filled its free list it forced a compacting collection, and that released every empty block group, so the heap stayed near 5 MB and collected about four times as often as hxcpp 4.3 (3x slower small allocations). Only Gc.compact now gives all empty groups back (libhxcpp #230)
  • Fixed Gc.run(true) giving the whole heap back to the system like Gc.compact, so the next work had to commit and fault it in again; map lookups and iteration after a major collection were up to 2x slower than hxcpp 4.3. Gc.run(true) now keeps memory up to the normal working target, as in hxcpp 4.3, and only Gc.compact releases every empty group (libhxcpp #231, #233)
  • Fixed maps shrinking their bucket array as soon as they fell to half full, so a map that lost and regained keys around that size shrank and grew again on every swing; removing 100,000 of 200,000 Int keys took 1.9 ms against hxcpp 4.3's 0.26 ms. A map now shrinks once it is a quarter full, and removing those keys takes 0.9 ms (libhxcpp #225)
  • Fixed IntMap being up to 2.3x slower than hxcpp 4.3 on arithmetic keys (ids, offsets, i * odd constant). Every Int key went through a bit mix that guards against strided keys but scatters keys that the plain identity hash spreads with no collisions. Int maps now start on the identity hash, like hxcpp 4.3, and switch to the mix for good when an insert finds a chain of 16 or growth leaves more than 2 entries per used bucket, so strided keys stay 130x to 770x faster than in hxcpp 4.3 (libhxcpp #231)
  • ObjectMap is about 10x faster on 64-bit targets and its peak memory 40% lower on the map benchmark: keys hash by address, as they do on 32-bit, instead of taking a global lock to add every key to the object id table that each collection then walks. The moving collector, where objects change address, keeps the ids (libhxcpp #77)
  • Fixed ObjectMap being about 15% slower than hxcpp 4.3 on Windows, along with everything else that takes an object id: the locks around the object id table, finalizer and weak map registration, the large allocation list and CFFI field ids had become std::mutex, which with MSVC costs about 40 ns per uncontended lock and unlock where hxcpp 4.3's critical section cost about 10 ns. They now use a slim reader/writer lock on Windows (std::mutex elsewhere, and with HXCPP_WINXP_COMPAT); looking up 200,000 object ids takes 4.5 ms instead of 11.5 ms, against hxcpp 4.3's 5 ms (libhxcpp #232)
  • Fixed sys.net.Socket.accept failing with "EOF" on an IPv6 listener on Windows: the peer address was given room for an IPv4 one, which Windows refuses for an IPv6 peer (libhxcpp #309)
  • Fixed Host.toString giving null for an IPv6 address on Windows when threads formatted their first addresses together: a thread could find the lookup of inet_ntop begun but not finished and take the function as missing. Parsing an IPv6 address with inet_pton had the same race (libhxcpp #310)
  • Fixed cpp.net.Poll.events returning at once on Windows when no sockets were registered, before any prepare or after one removed the last socket, so an idle event loop spun at full CPU: Winsock's select fails with no sockets, which looked like a finished empty poll. It now waits out the timeout, and with a negative one waits for good, as on other systems (libhxcpp #311)
  • Fixed a large backward FileInput.seek with SeekCur, after readByte, moving the file about 2 GB forward instead of failing: taking back the bytes read ahead wrapped the int offset. The offset is now 64 bits, and a seek that fails leaves the position where it was, where it moved it to the end of the bytes read ahead (libhxcpp #349)
  • Fixed FileInput.tell after readByte on a file opened in text mode on Windows giving a position past unread text, so seeking back to it skipped some: the bytes read ahead had their CRLFs turned into LFs, and tell took back fewer bytes than the stream had moved over. Text-mode files no longer read ahead on Windows (libhxcpp #353)
  • Fixed FileSystem.readDirectory on Windows throwing "Invalid directory" for a path longer than MAX_PATH, such as an extended-length one starting with \?, before Windows saw it, though other file functions take such a path. The search pattern is now as long as the path needs, after a backslash, since \?\ paths take no forward slashes (libhxcpp #352, HaxeFoundation/hxcpp#1352)
  • Fixed Sys.programPath on Windows giving the first 259 characters of an executable path longer than MAX_PATH as if it were the whole path: the path is now read into a buffer that grows until it fits (libhxcpp #354, HaxeFoundation/hxcpp#1352)
  • Fixed FileSystem.readDirectory returning the entries read so far, as if they were all of them, when the directory failed to read part way through: readdir's NULL, and FindNextFileW failing on Windows, were taken as the end. It now throws "Error reading directory" unless errno, or GetLastError's ERROR_NO_MORE_FILES on Windows, says the end was reached, after closing the directory (libhxcpp #348)
  • Fixed a negative cpp.Random seed giving a different sequence on Linux, macOS and other LP64 platforms than on Windows once the state refreshed, after 25 draws: the state was unsigned long, 64 bits there, so the seed set high bits that the refresh shifted into the result. The state is now 32 bits wide everywhere, giving the sequence Windows always has (libhxcpp #386)
  • Fixed sys.ssl.Digest.make, sign and verify growing an empty Bytes to one byte: they took the first element through the accessor that resizes the array, so the digest of an empty input could include that byte, and repeated calls on it gave another result. Empty data given to the other SSL functions, such as a certificate or key in DER, is no longer grown either (libhxcpp #384)
  • Fixed SSL calls on a socket that has not connected, and native SSL calls on a closed context or configuration, crashing the process: sys.ssl.Socket.handshake before connect passed a null context, and closing a context or configuration left its handle with the native pointer cleared, which other calls used unchecked. Handles are now checked for their type and for being open, and these calls throw instead, peerCertificate returns null without a session, and closing again does nothing (libhxcpp #385)
  • Fixed a regex keeping the whole UTF-16 subject of its last match, and the copy made to replace lone surrogates, after the match failed, for as long as the regex lived: a long-lived validator held twice a large input it no longer needed. After a failed match the cache is dropped when it holds more than 1 MiB, so smaller subjects are still checked only once across calls (libhxcpp #388)
  • Fixed Host resolution and reverse lookups on Linux, and resolution on Android, reporting a host as unknown, or giving no name, when the resolver answer needed more than 1 KiB, as one with many aliases or addresses does: gethostbyname_r and gethostbyaddr_r got a fixed 1 KiB buffer and their ERANGE was taken as a failed lookup. The lookup is now tried again with twice the space, up to 1 MiB (libhxcpp #312)
  • Fixed an Int64-keyed map given Int64 values through its Dynamic setter, as generic code sets them, switching to boxed object storage at the second value, so every entry kept a box alive: 400,000 entries hold 22.8 MB of live heap instead of 30.8 MB (libhxcpp #278)
  • Fixed Int64-keyed maps walking long chains for packed pairs: the key's halves were xored before mixing, so every Int64.make(x, y) of a 256 x 256 grid shared 256 hashes and every key with equal halves hashed to 0. The high half is now multiplied in; building and reading 65,536 grid keys takes 1.1 ms instead of 88 ms, and 65,536 equal-halves keys 2.6 ms instead of 4.5 s (libhxcpp #289)
  • Array.push of an Int, Float, Bool, Int64 or String no longer boxes the value only to unbox it into the array's typed storage: it is stored as an indexed write stores it, and pushing Ints and Floats is 1.7x faster (libhxcpp #294)
  • Fixed cpp.NativeArray.reserve doing nothing on an empty Array, which has no storage until its first element: the capacity is now kept and given to that storage, and capacity() reports it meanwhile. Filling a reserved 1,000,000-element array is 1.2x faster and peaks at 25 MB instead of 45 MB (libhxcpp #297)
  • indexOf and lastIndexOf on typed arrays and Strings take an Int start position without boxing it, which allocated for every start past 255: searches that start each call from an offset are 2.9x faster (libhxcpp #307)
  • Fixed String.split and lastIndexOf, and indexOf between a byte and a wide string, comparing a long needle again at every position where its start matched, as indexOf on two strings of one encoding already no longer did: they now finish with a search that stays linear in the text. Splitting 1 MB of "a" on a near-miss 8,192-character delimiter takes 1.3 ms instead of 208 ms, and lastIndexOf 0.5 ms instead of 208 ms (libhxcpp #280)
  • Std.parseInt and Std.parseFloat no longer convert a whole UTF-16 string to UTF-8 to read the number at its start: only the ASCII before its first other character is copied, so a line of non-ASCII text after a number no longer costs its length. Parsing numbers at the start of such lines is 4.5x faster (libhxcpp #284)
  • Fixed Reflect.field, hasField, setField and deleteField with a string literal for the name scanning every field of an anonymous object before searching it by hash: the scan by address is now kept to objects of up to 40 fields, where it is faster. On a 256-field object those calls are 4.3x faster (libhxcpp #285)
  • SQLite rows keep Int, Float, Bool, Int64 and text values in their own fields instead of a box per cell: 100,000 retained rows of eight Int columns hold 35.8 MB of live heap instead of 51.8 MB, and a query that keeps its rows peaks at 86 MB instead of 127 MB (libhxcpp #308)
  • Fixed reading a whole stream from a socket or TLS connection, and building a CFFI buffer with buffer_append and buffer_append_sub, growing the result to the exact length at every chunk, which copied everything read so far each time: they now grow it as push does. Reading 2 MB from a loopback socket is 8.5x faster and peaks at 21 MB instead of 105 MB, and building 2 MB from 1 KB CFFI chunks takes 2.7 ms instead of 775 ms (libhxcpp #287)
  • Semaphore works in single-threaded Emscripten builds for what needs no other thread: it keeps its initial permits, tryAcquire and acquire take one that is there, and release adds one. It threw "Unsupported platform" for all of them. With no permit, tryAcquire with a timeout sleeps it out and returns false, and acquire throws, since nothing could release one while it waited (libhxcpp #334)
  • Fixed a Lock.wait with a timeout on an empty Lock never returning in single-threaded Emscripten builds, which also stopped haxe.Timer callbacks firing, since the event loop waits on a Lock for the next one. Emscripten's pthread_cond_timedwait returns at once without pthreads, and the wait took that as a wakeup for ever. It now sleeps until the timeout, as no other thread can release the Lock (libhxcpp #339)
  • Fixed constructing a sys.net.Socket on Emscripten throwing "Could not set socket timeout": it sets its timeout of zero, and Emscripten's sockets have no SO_SNDTIMEO or SO_RCVTIMEO, so setsockopt failed. Zero, or null, is the no timeout a socket starts with, so it is now accepted there. A positive timeout, which those sockets cannot keep, still throws (libhxcpp #344)
  • Fixed Socket.select on Emscripten giving sockets with a descriptor of 64 or more as ready when they were not: Emscripten's select reads and writes only the first 64 descriptors of each set, so a socket above that kept the bit it was given. select now runs through Emscripten's poll there, which takes any descriptor (libhxcpp #345)
  • JS Prime CFFI has the basic string functions, which a primitive such as an echo of alloc_string(val_string(v)) failed to link without: val_string, val_wstring, val_dup_string, val_dup_wstring, val_strlen, alloc_string_len and alloc_wstring_len. Strings are UTF-8, or UTF-32 for wchar_t, and val_strlen counts UTF-8 bytes. The strings given to a primitive are freed when it returns, a nested primitive freeing only its own (libhxcpp #346)
  • HXCPP_LINK_NO_EMBIND links an Emscripten executable without Embind, which every executable linked with through --bind. An application without JavaScript bindings saves about 11 KB of JavaScript. HXCPP_JS_PRIME keeps it, and the default is unchanged, for native code with EMSCRIPTEN_BINDINGS (libhxcpp #336)
  • The Emscripten CI job also runs an exception and GC test, built with native wasm exceptions and with HXCPP_NO_WASM_EXEPTIONS, and logs the Emscripten, node and Haxe versions it ran with (libhxcpp #337)
  • The stack each thread keeps cppia script frames on can be larger than the fixed 128 KB it was, which a script used up after a few hundred to a few thousand nested calls and then threw "Stack Overflow". HXCPP_CPPIA_STACK_SIZE sets its size in bytes, and __scriptable_cppia_set_stack_size changes it at run time, for threads that attach from then on and for the calling thread when no script is running on it. On Windows, Linux, Android and Apple platforms a stack reserves its size and commits memory as frames reach it, so a large size costs only address space until a script recurses that deep (docs/ThreadsAndStacks.md) (libhxcpp #394)
  • Fixed jitted cppia code that recursed past the script stack crashing on 32-bit Windows and Linux instead of throwing "Stack Overflow": the handler it calls there was not declared with the calling convention jitted code uses, fastcall on 32-bit x86, so it took its context from the wrong place (libhxcpp #394)
  • Fixed a null thrown under the cppia JIT, which keeps a pending exception where null means there is none: a null the script threw was lost once it left the function that threw it, so the caller carried on as if nothing had been thrown, and a null that host code threw into compiled script code became an empty String, which catch (s:String) caught. A thrown null now stays null through typed catches, rethrows and the way back to interpreted or host code, as it does interpreted and in compiled programs (libhxcpp #395)
  • Fixed sys.ssl.Digest.make, sign and verify, Key.readDER and Certificate.addDER growing an empty Bytes to one zero byte: the digest of an empty message was the digest of "\0" (MD5 93b885ad... instead of d41d8cd9...), and the caller's Bytes changed under it. Writing nothing to a sys.ssl.Socket grew the buffer the same way (libhxcpp #384)
  • Fixed a SQLite request refused for naming a column twice, such as SELECT * over two tables with an id column, leaving its statement open until the collector reached it: closing the connection meanwhile threw "Sqlite: could not close" and left it open. The statement is now finalized before the error is thrown, as neko does (libhxcpp #397)
  • Fixed haxe.zip.Uncompress.execute throwing "ZLib Error 2" on the call that reaches a stream's request for a preset dictionary, where neko and hxcpp 4.3 report what it read, not done and with nothing written. It now reports it the same way, and the stream's adler32 holds the dictionary's id. A later call, which can make no progress, still throws, so Uncompress.run on such a stream still ends with an error instead of looping (libhxcpp #398)
  • Added _hx_zip_get_adler32, _hx_zip_update_adler32 and _hx_zip_update_crc32 to hx/StdLibs.h, neko's zlib get_adler32, update_adler32 and update_crc32: a stream's adler32, and the adler32 or CRC32 of a range of bytes carried on from a previous value (libhxcpp #398)
  • The cppia JIT compiles each function when it is first called, rather than every function of a module when it loads, so a large script starts about as fast under the JIT as interpreted: haxelib's run.n, translated to cppia, loads in 69 ms where compiling all of it took 139 ms, and Haxe's unit tests in 0.62 s where they took 1.38 s. HXCPP_CPPIA_EAGER_JIT compiles each module when it loads, as before (libhxcpp #403)