@amritk/nish-x86_64-linux 0.37.0 → 0.38.0

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.
package/runtime/runtime.c CHANGED
@@ -1,17 +1,20 @@
1
- /* Nish runtime: arena + strings + cold paths. Layouts are ABI (runtime.ts, nish.h).
1
+ /* Nish runtime: arena + output + cold paths. Layouts are ABI (runtime.ts, nish.h).
2
2
  *
3
3
  * The half of the runtime every program touches whatever it does, which is why
4
- * it is also the half with the tighter size budget: the arena, strings, number
5
- * formatting, the array cold paths, `process.argv`, `Math.random`, and the two
6
- * panics. Files, directories, subprocesses, the environment and the clock are
4
+ * it is also the half with the tighter size budget: the arena, writing strings
5
+ * out, the array cold paths, `process.argv`, `Math.random`, and the two
6
+ * panics. Building, searching and formatting strings is runtime-text.c's, a
7
+ * unit with no libc beyond the mem* routines so that the freestanding wasm
8
+ * link takes the same code (WP50 stage 4). Files, directories, subprocesses, the environment and the clock are
7
9
  * in runtime-os.c — every one of those wraps a system call, so that surface
8
10
  * grows as the language reaches further into the operating system, and a
9
11
  * program that reaches nowhere should not pay for it or be measured with it.
10
12
  * runtime-os.c's header comment has the reasoning; tests/run.js gates the two
11
13
  * `.text*` budgets separately and docs/wp7-runtime.md records both.
12
14
  *
13
- * Nothing here calls into runtime-os.c, which is why an old link line that
14
- * names runtime.c alone still builds a program that uses none of that surface.
15
+ * Nothing here calls into runtime-os.c or runtime-text.c, which is why a link
16
+ * line that names runtime.c alone still builds a program that uses neither
17
+ * surface; one that builds a string names runtime-text.c beside it.
15
18
  * The other direction does happen: `nish_readdir` allocates through
16
19
  * `nish_alloc_struct` and `nish_str_new`, so those calls no longer inline into
17
20
  * it without LTO. Measured in docs/wp7-runtime.md; the speed and size profiles
@@ -95,6 +98,12 @@ _Static_assert(sizeof(nish_chunk) == 16, "runtime-cross.c's nish_xchunk: { next,
95
98
  _Static_assert(offsetof(nish_chunk, next) == 0, "runtime-cross.c's nish_xchunk: next first");
96
99
  _Static_assert(offsetof(nish_chunk, cap) == 8, "runtime-cross.c's nish_xchunk: cap second");
97
100
  struct nish_arena { char *buf; uint64_t off; uint64_t cap; nish_chunk *chunks; };
101
+ /* A chunk's usable bytes. Bit 0 of `cap` marks a *carved* chunk, one
102
+ `nish_region_adopt` (runtime-region.c) made in what an older chunk of the
103
+ same arena had left: no malloc of its own, so `nish_free_until` passes it
104
+ by. A malloc'd chunk's cap is a multiple of 8, so the bit is free. */
105
+ #define NISH_CHUNK_CARVED 1
106
+ #define NISH_CHUNK_CAP(c) ((c)->cap & ~(uint64_t)NISH_CHUNK_CARVED)
98
107
  /* One per thread under -DNISH_THREADS, one per process otherwise; the layout is
99
108
  the same either way, which is why nothing else in this file has to know. */
100
109
  NISH_TLS struct nish_arena nish_arena;
@@ -167,8 +176,10 @@ static NISH_COLD void nish_die(const char *msg) {
167
176
  nish_fatal_exit();
168
177
  }
169
178
  /* A function rather than a macro around `nish_die`: seven call sites each
170
- loading the message's address cost more than one more symbol does. */
171
- static NISH_COLD void nish_oom(void) { nish_die("nish: out of memory\n"); }
179
+ loading the message's address cost more than one more symbol does. External
180
+ because runtime-text.c's `nish_str_concat` fails through it too; a wasm link
181
+ has runtime-wasm.c's instead. */
182
+ NISH_COLD void nish_oom(void) { nish_die("nish: out of memory\n"); }
172
183
 
173
184
  /* The most elements an array and the most bytes a string may hold: see
174
185
  `nish_array_grow` and `nish_str_concat`. */
@@ -302,9 +313,7 @@ static void nish_grown_put(char *data, const void *owner, uint64_t native) {
302
313
  nish_grown_live++;
303
314
  }
304
315
  #endif
305
- #ifdef NISH_ASAN
306
316
  void nish_free_arena(void);
307
- #endif
308
317
  static void nish_free_until(nish_chunk *c, const nish_chunk *end) {
309
318
  #ifdef NISH_ASAN
310
319
  /* A freed block's address comes back from malloc: forget the grown ones. */
@@ -314,21 +323,38 @@ static void nish_free_until(nish_chunk *c, const nish_chunk *end) {
314
323
  nish_grown_leave();
315
324
  }
316
325
  #endif
317
- while (c != end) { nish_chunk *n = c->next; free(c); c = n; }
326
+ /* A carved chunk lies inside an older one, which a list is never cut
327
+ between: what frees the older chunk frees the memory under it. */
328
+ while (c != end) {
329
+ nish_chunk *n = c->next;
330
+ if (!(c->cap & NISH_CHUNK_CARVED)) free(c);
331
+ c = n;
332
+ }
318
333
  }
319
334
 
320
- /* O(1) recycle: keep the newest chunk, free the rest. */
321
335
  void nish_reset_arena(void) {
322
336
  #ifdef NISH_ASAN
323
337
  /* Free everything, so a value read after the reset is a use after free. */
324
338
  nish_free_arena();
325
339
  return;
326
340
  #endif
341
+ /* Keep the newest chunk malloc made: a carved one above it lives in a
342
+ chunk this frees, and always lies above the chunk it was carved from,
343
+ so the walk meets that chunk before the list ends. The walk is a
344
+ do-while from the head already loaded, not a while from
345
+ `nish_arena.chunks`: written that way, LLVM folds the first load into
346
+ the loop through a phi of `&nish_arena.chunks`, which takes the arena's
347
+ address, and with it taken LTO's GlobalsAA can no longer tell an array
348
+ store from an arena field in any program -- bench/sieve.ts reloaded
349
+ both in its hot loops, +60% instructions. */
327
350
  nish_chunk *keep = nish_arena.chunks;
328
351
  if (!keep) return;
352
+ if (keep->cap & NISH_CHUNK_CARVED) {
353
+ do keep = keep->next; while (keep->cap & NISH_CHUNK_CARVED);
354
+ }
329
355
  nish_free_until(keep->next, 0);
330
356
  keep->next = 0;
331
- nish_arena.off = 0;
357
+ nish_arena = (struct nish_arena){ (char *)(keep + 1), 0, keep->cap, keep };
332
358
  }
333
359
 
334
360
  void nish_free_arena(void) {
@@ -347,11 +373,11 @@ void nish_arena_release(uint64_t mark) {
347
373
  if (!mark) { nish_reset_arena(); return; }
348
374
  for (; c; c = c->next) {
349
375
  uintptr_t base = (uintptr_t)(c + 1);
350
- if (mark >= base && mark <= base + c->cap) break;
376
+ if (mark >= base && mark <= base + NISH_CHUNK_CAP(c)) break;
351
377
  }
352
378
  if (!c) return;
353
379
  nish_free_until(nish_arena.chunks, c);
354
- nish_arena = (struct nish_arena){ (char *)(c + 1), mark - (uintptr_t)(c + 1), c->cap, c };
380
+ nish_arena = (struct nish_arena){ (char *)(c + 1), mark - (uintptr_t)(c + 1), NISH_CHUNK_CAP(c), c };
355
381
  }
356
382
 
357
383
  /* Release back to `mark` while keeping the newest allocation; returns where it
@@ -374,102 +400,30 @@ void *nish_arena_keep(uint64_t mark, void *p) {
374
400
  nish_chunk *pc = nish_arena.chunks, *c = pc; /* pc holds `p`: it is the current chunk */
375
401
  for (; c; c = c->next) {
376
402
  uintptr_t cb = (uintptr_t)(c + 1);
377
- if (mark >= cb && mark <= cb + c->cap) break;
403
+ if (mark >= cb && mark <= cb + NISH_CHUNK_CAP(c)) break;
378
404
  }
379
405
  if (!c || (c == pc && mark > q)) return p;
380
406
  /* mark <= q inside one chunk implies mark + size <= q + size <= its end, so
381
407
  the second arm is only ever reached with `c` older than `pc`. */
382
- if (mark + size <= (uintptr_t)(c + 1) + c->cap) {
408
+ if (mark + size <= (uintptr_t)(c + 1) + NISH_CHUNK_CAP(c)) {
383
409
  memmove((void *)mark, p, size);
384
410
  nish_free_until(pc, c);
385
- nish_arena = (struct nish_arena){ (char *)(c + 1), mark + size - (uintptr_t)(c + 1), c->cap, c };
411
+ nish_arena = (struct nish_arena){ (char *)(c + 1), mark + size - (uintptr_t)(c + 1), NISH_CHUNK_CAP(c), c };
386
412
  return (void *)mark;
387
413
  }
414
+ /* Keeping a carved `pc` while the chunks under it go could free the one it
415
+ was carved from. */
416
+ if (pc->cap & NISH_CHUNK_CARVED) return p;
388
417
  nish_free_until(pc->next, c);
389
418
  pc->next = c;
390
419
  return p;
391
420
  }
392
421
 
393
- /* ---- Strings: { i64 len, bytes[len], '\0' }, immutable; 8 = the len header */
422
+ /* ---- Strings: { i64 len, bytes[len], '\0' }, immutable; 8 = the len header.
423
+ Building, comparing, searching and formatting them is runtime-text.c's; this
424
+ half writes them out and reads `process.argv` and `Number(s)` into them. */
394
425
  typedef struct { uint64_t len; char data[]; } nish_str;
395
426
 
396
- nish_str *nish_str_new(const char *bytes, uint64_t len) {
397
- nish_str *s = nish_alloc_struct(8 + len + 1);
398
- s->len = len;
399
- if (len) memcpy(s->data, bytes, len);
400
- s->data[len] = 0;
401
- return s;
402
- }
403
-
404
- /* A string never passes 2^31 - 1 bytes, for the reason an array never passes
405
- that many elements (`NISH_ARRAY_MAX`, below): under --number-mode i32 a
406
- longer one's `length` reads back negative and bounds-check elimination
407
- trusts it (docs/security/runtime.md, RT-2). `a + b` past it fails as an
408
- allocation does. */
409
- nish_str *nish_str_concat(const nish_str *a, const nish_str *b) {
410
- uint64_t len = a->len + b->len;
411
- if (len > NISH_ARRAY_MAX) nish_oom();
412
- nish_str *s = nish_alloc_struct(8 + len + 1);
413
- s->len = len;
414
- memcpy(s->data, a->data, a->len);
415
- memcpy(s->data + a->len, b->data, b->len);
416
- s->data[len] = 0;
417
- return s;
418
- }
419
-
420
- _Bool nish_str_eq(const nish_str *a, const nish_str *b) {
421
- return a == b || (a->len == b->len && memcmp(a->data, b->data, a->len) == 0);
422
- }
423
-
424
- uint64_t nish_str_len(const nish_str *s) { return s->len; }
425
-
426
- /* `s.startsWith(sub)` is at 0, `s.endsWith(sub)` at len - sub->len, which is
427
- negative when `sub` is the longer string. */
428
- _Bool nish_str_at(const nish_str *s, int64_t at, const nish_str *sub) {
429
- return at >= 0 && (uint64_t)at + sub->len <= s->len && !memcmp(s->data + at, sub->data, sub->len);
430
- }
431
- /* `s.indexOf(sub)`: the first byte offset where `sub` occurs, or -1. An empty
432
- needle answers 0 and a needle longer than the haystack -1, both of which are
433
- what JavaScript says and what the inline loop this replaces did.
434
-
435
- This was lowered inline, one `nish_str_at` per offset, to keep `runtime.c`
436
- small. That cost a byte-at-a-time scan — 53.7 ms over 52 MB of haystack —
437
- and WP15 section 7's rule is that the budget yields to a measured win, so the
438
- search moved here: `memchr` finds a candidate first byte and `memcmp`
439
- confirms it, both the libc's vectorised routines. 2.9 ms, or 3.1 ms when the
440
- needle starts with a byte the haystack is full of.
441
-
442
- `memmem` is deliberately not used, and costs little: 2.5 ms on the same two
443
- measurements. It is a GNU extension glibc hides behind `_GNU_SOURCE`, and
444
- defining that here makes `<string.h>` pull in `<strings.h>` — which any `-I`
445
- directory holding a file of that name then shadows. This project generates
446
- exactly such a header from `examples/strings.ts`, and the interop tests
447
- caught runtime.c picking it up and inheriting `nish.h` through it. A C host
448
- would hit the same. A fifth of the time is not worth making the runtime
449
- sensitive to its includer's `-I` paths.
450
-
451
- `s.indexOf(sub, from)` is the same search from byte `from`, and
452
- `s.indexOf(sub)` is it from 0: one loop, not two. The compiler clamps `from`
453
- into [0, s.length] first, as JavaScript does, with `llvm.smin`/`smax` where
454
- LLVM can fold them, so the clamp costs this file nothing; an empty needle
455
- answers that clamped `from`. The clamp is a precondition: a caller that
456
- skips it never reads outside the string, but gets -1 for a non-empty needle
457
- (a negative `from` reads as one past the end) and `from` itself, unchanged,
458
- for an empty one. */
459
- int64_t nish_str_index_of_from(const nish_str *s, const nish_str *sub, int64_t from) {
460
- uint64_t at = (uint64_t)from;
461
- if (sub->len == 0) return from;
462
- while (at <= s->len && sub->len <= s->len - at) {
463
- const char *c = memchr(s->data + at, sub->data[0], s->len - at - sub->len + 1);
464
- if (!c) break;
465
- at = (uint64_t)(c - s->data);
466
- if (memcmp(c + 1, sub->data + 1, sub->len - 1) == 0) return (int64_t)at;
467
- at++;
468
- }
469
- return -1;
470
- }
471
- int64_t nish_str_index_of(const nish_str *s, const nish_str *sub) { return nish_str_index_of_from(s, sub, 0); }
472
-
473
427
  /* `console.log` / `console.error` / `write` / `writeError` and the message of
474
428
  `panic`: fd 1 or 2, with or without the trailing newline.
475
429
 
@@ -511,871 +465,6 @@ __attribute__((noreturn)) void nish_panic(const nish_str *s) {
511
465
  exit(1);
512
466
  }
513
467
 
514
- /* Decimal digits of `u`, with a '-' in front when `neg`. 20 digits is the
515
- widest a uint64_t can be, plus the sign. */
516
- static nish_str *str_from_digits(uint64_t u, int neg) {
517
- char tmp[21], *p = tmp + 21;
518
- do { *--p = '0' + u % 10; u /= 10; } while (u);
519
- if (neg) *--p = '-';
520
- return nish_str_new(p, tmp + 21 - p);
521
- }
522
-
523
- nish_str *nish_str_from_i64(int64_t v) {
524
- return str_from_digits(v < 0 ? -(uint64_t)v : (uint64_t)v, v < 0);
525
- }
526
- nish_str *nish_str_from_i32(int32_t v) { return nish_str_from_i64(v); }
527
- /* The one unsigned formatter (WP15): u8/u16/u32 are zero-extended by the
528
- caller, so 0xFFFFFFFF prints as 4294967295 rather than -1. */
529
- nish_str *nish_str_from_u64(uint64_t v) { return str_from_digits(v, 0); }
530
-
531
-
532
- /* ---- Shortest round-trip digits (Zmij)
533
-
534
- Adapted from Zmij (https://github.com/vitaut/zmij), zmij.c. Copyright (c)
535
- 2025 - present, Victor Zverovich. Used under the Boost Software License,
536
- Version 1.0 (upstream offers MIT or BSL-1.0); see runtime/LICENSE-zmij. The
537
- code from here to the end of `nish_shortest_digits` follows upstream's
538
- `umul192_hi128`, `umul128_add_hi64`, `compute_dec_exp`, `compute_exp_shift`
539
- and the scalar `to_decimal_double`, which is why it keeps their constants;
540
- the table is regenerated by scripts/gen-pow10-table.py rather than copied.
541
- Only the digit computation is taken: no SIMD, and none of upstream's own
542
- formatting, since the layout below is ECMAScript's rather than printf's.
543
-
544
- `String(x)` in JavaScript prints the *fewest* digits that read back as the
545
- same double, and the language promises that spelling. Reaching it by asking
546
- snprintf for k digits and strtod whether they round-trip is both slow and,
547
- less obviously, *wrong*: printf can only hand back the correctly-rounded
548
- k-digit string, and for some values the shortest string that round-trips at
549
- that length is a different one (7.120236347223045e-307 is the pinned case).
550
-
551
- Zmij (a Schubfach descendant) gets there with one 64x128-bit multiply: it
552
- scales the value by a power of ten chosen so the integer part is the shorter
553
- of the two candidate lengths, decides from the fractional part whether that
554
- candidate already lies inside the rounding interval, and otherwise reads one
555
- more digit off the fraction. Ryu, which this replaced, needed three
556
- multiplies and a loop of divisions. Read upstream before touching the
557
- arithmetic: `315653 >> 20`, `217707 >> 16` and the `+6` bias are exact over
558
- the exponents a double can have and verified there, not in general. */
559
- /* Generated by scripts/gen-pow10-table.py; do not hand-edit. 10^-293 to 10^323. */
560
- #define NISH_POW10_MIN (-293)
561
- static const uint64_t NISH_POW10_SIG[617][2] = {
562
- { 0xcc5fc196fefd7d0cu, 0x1e53ed49a96272c8u },
563
- { 0xff77b1fcbebcdc4fu, 0x25e8e89c13bb0f7au },
564
- { 0x9faacf3df73609b1u, 0x77b191618c54e9acu },
565
- { 0xc795830d75038c1du, 0xd59df5b9ef6a2417u },
566
- { 0xf97ae3d0d2446f25u, 0x4b0573286b44ad1du },
567
- { 0x9becce62836ac577u, 0x4ee367f9430aec32u },
568
- { 0xc2e801fb244576d5u, 0x229c41f793cda73fu },
569
- { 0xf3a20279ed56d48au, 0x6b43527578c1110fu },
570
- { 0x9845418c345644d6u, 0x830a13896b78aaa9u },
571
- { 0xbe5691ef416bd60cu, 0x23cc986bc656d553u },
572
- { 0xedec366b11c6cb8fu, 0x2cbfbe86b7ec8aa8u },
573
- { 0x94b3a202eb1c3f39u, 0x7bf7d71432f3d6a9u },
574
- { 0xb9e08a83a5e34f07u, 0xdaf5ccd93fb0cc53u },
575
- { 0xe858ad248f5c22c9u, 0xd1b3400f8f9cff68u },
576
- { 0x91376c36d99995beu, 0x23100809b9c21fa1u },
577
- { 0xb58547448ffffb2du, 0xabd40a0c2832a78au },
578
- { 0xe2e69915b3fff9f9u, 0x16c90c8f323f516cu },
579
- { 0x8dd01fad907ffc3bu, 0xae3da7d97f6792e3u },
580
- { 0xb1442798f49ffb4au, 0x99cd11cfdf41779cu },
581
- { 0xdd95317f31c7fa1du, 0x40405643d711d583u },
582
- { 0x8a7d3eef7f1cfc52u, 0x482835ea666b2572u },
583
- { 0xad1c8eab5ee43b66u, 0xda3243650005eecfu },
584
- { 0xd863b256369d4a40u, 0x90bed43e40076a82u },
585
- { 0x873e4f75e2224e68u, 0x5a7744a6e804a291u },
586
- { 0xa90de3535aaae202u, 0x711515d0a205cb36u },
587
- { 0xd3515c2831559a83u, 0x0d5a5b44ca873e03u },
588
- { 0x8412d9991ed58091u, 0xe858790afe9486c2u },
589
- { 0xa5178fff668ae0b6u, 0x626e974dbe39a872u },
590
- { 0xce5d73ff402d98e3u, 0xfb0a3d212dc8128fu },
591
- { 0x80fa687f881c7f8eu, 0x7ce66634bc9d0b99u },
592
- { 0xa139029f6a239f72u, 0x1c1fffc1ebc44e80u },
593
- { 0xc987434744ac874eu, 0xa327ffb266b56220u },
594
- { 0xfbe9141915d7a922u, 0x4bf1ff9f0062baa8u },
595
- { 0x9d71ac8fada6c9b5u, 0x6f773fc3603db4a9u },
596
- { 0xc4ce17b399107c22u, 0xcb550fb4384d21d3u },
597
- { 0xf6019da07f549b2bu, 0x7e2a53a146606a48u },
598
- { 0x99c102844f94e0fbu, 0x2eda7444cbfc426du },
599
- { 0xc0314325637a1939u, 0xfa911155fefb5308u },
600
- { 0xf03d93eebc589f88u, 0x793555ab7eba27cau },
601
- { 0x96267c7535b763b5u, 0x4bc1558b2f3458deu },
602
- { 0xbbb01b9283253ca2u, 0x9eb1aaedfb016f16u },
603
- { 0xea9c227723ee8bcbu, 0x465e15a979c1cadcu },
604
- { 0x92a1958a7675175fu, 0x0bfacd89ec191ec9u },
605
- { 0xb749faed14125d36u, 0xcef980ec671f667bu },
606
- { 0xe51c79a85916f484u, 0x82b7e12780e7401au },
607
- { 0x8f31cc0937ae58d2u, 0xd1b2ecb8b0908810u },
608
- { 0xb2fe3f0b8599ef07u, 0x861fa7e6dcb4aa15u },
609
- { 0xdfbdcece67006ac9u, 0x67a791e093e1d49au },
610
- { 0x8bd6a141006042bdu, 0xe0c8bb2c5c6d24e0u },
611
- { 0xaecc49914078536du, 0x58fae9f773886e18u },
612
- { 0xda7f5bf590966848u, 0xaf39a475506a899eu },
613
- { 0x888f99797a5e012du, 0x6d8406c952429603u },
614
- { 0xaab37fd7d8f58178u, 0xc8e5087ba6d33b83u },
615
- { 0xd5605fcdcf32e1d6u, 0xfb1e4a9a90880a64u },
616
- { 0x855c3be0a17fcd26u, 0x5cf2eea09a55067fu },
617
- { 0xa6b34ad8c9dfc06fu, 0xf42faa48c0ea481eu },
618
- { 0xd0601d8efc57b08bu, 0xf13b94daf124da26u },
619
- { 0x823c12795db6ce57u, 0x76c53d08d6b70858u },
620
- { 0xa2cb1717b52481edu, 0x54768c4b0c64ca6eu },
621
- { 0xcb7ddcdda26da268u, 0xa9942f5dcf7dfd09u },
622
- { 0xfe5d54150b090b02u, 0xd3f93b35435d7c4cu },
623
- { 0x9efa548d26e5a6e1u, 0xc47bc5014a1a6dafu },
624
- { 0xc6b8e9b0709f109au, 0x359ab6419ca1091bu },
625
- { 0xf867241c8cc6d4c0u, 0xc30163d203c94b62u },
626
- { 0x9b407691d7fc44f8u, 0x79e0de63425dcf1du },
627
- { 0xc21094364dfb5636u, 0x985915fc12f542e4u },
628
- { 0xf294b943e17a2bc4u, 0x3e6f5b7b17b2939du },
629
- { 0x979cf3ca6cec5b5au, 0xa705992ceecf9c42u },
630
- { 0xbd8430bd08277231u, 0x50c6ff782a838353u },
631
- { 0xece53cec4a314ebdu, 0xa4f8bf5635246428u },
632
- { 0x940f4613ae5ed136u, 0x871b7795e136be99u },
633
- { 0xb913179899f68584u, 0x28e2557b59846e3fu },
634
- { 0xe757dd7ec07426e5u, 0x331aeada2fe589cfu },
635
- { 0x9096ea6f3848984fu, 0x3ff0d2c85def7621u },
636
- { 0xb4bca50b065abe63u, 0x0fed077a756b53a9u },
637
- { 0xe1ebce4dc7f16dfbu, 0xd3e8495912c62894u },
638
- { 0x8d3360f09cf6e4bdu, 0x64712dd7abbbd95cu },
639
- { 0xb080392cc4349decu, 0xbd8d794d96aacfb3u },
640
- { 0xdca04777f541c567u, 0xecf0d7a0fc5583a0u },
641
- { 0x89e42caaf9491b60u, 0xf41686c49db57244u },
642
- { 0xac5d37d5b79b6239u, 0x311c2875c522ced5u },
643
- { 0xd77485cb25823ac7u, 0x7d633293366b828bu },
644
- { 0x86a8d39ef77164bcu, 0xae5dff9c02033197u },
645
- { 0xa8530886b54dbdebu, 0xd9f57f830283fdfcu },
646
- { 0xd267caa862a12d66u, 0xd072df63c324fd7bu },
647
- { 0x8380dea93da4bc60u, 0x4247cb9e59f71e6du },
648
- { 0xa46116538d0deb78u, 0x52d9be85f074e608u },
649
- { 0xcd795be870516656u, 0x67902e276c921f8bu },
650
- { 0x806bd9714632dff6u, 0x00ba1cd8a3db53b6u },
651
- { 0xa086cfcd97bf97f3u, 0x80e8a40eccd228a4u },
652
- { 0xc8a883c0fdaf7df0u, 0x6122cd128006b2cdu },
653
- { 0xfad2a4b13d1b5d6cu, 0x796b805720085f81u },
654
- { 0x9cc3a6eec6311a63u, 0xcbe3303674053bb0u },
655
- { 0xc3f490aa77bd60fcu, 0xbedbfc4411068a9cu },
656
- { 0xf4f1b4d515acb93bu, 0xee92fb5515482d44u },
657
- { 0x991711052d8bf3c5u, 0x751bdd152d4d1c4au },
658
- { 0xbf5cd54678eef0b6u, 0xd262d45a78a0635du },
659
- { 0xef340a98172aace4u, 0x86fb897116c87c34u },
660
- { 0x9580869f0e7aac0eu, 0xd45d35e6ae3d4da0u },
661
- { 0xbae0a846d2195712u, 0x8974836059cca109u },
662
- { 0xe998d258869facd7u, 0x2bd1a438703fc94bu },
663
- { 0x91ff83775423cc06u, 0x7b6306a34627ddcfu },
664
- { 0xb67f6455292cbf08u, 0x1a3bc84c17b1d542u },
665
- { 0xe41f3d6a7377eecau, 0x20caba5f1d9e4a93u },
666
- { 0x8e938662882af53eu, 0x547eb47b7282ee9cu },
667
- { 0xb23867fb2a35b28du, 0xe99e619a4f23aa43u },
668
- { 0xdec681f9f4c31f31u, 0x6405fa00e2ec94d4u },
669
- { 0x8b3c113c38f9f37eu, 0xde83bc408dd3dd04u },
670
- { 0xae0b158b4738705eu, 0x9624ab50b148d445u },
671
- { 0xd98ddaee19068c76u, 0x3badd624dd9b0957u },
672
- { 0x87f8a8d4cfa417c9u, 0xe54ca5d70a80e5d6u },
673
- { 0xa9f6d30a038d1dbcu, 0x5e9fcf4ccd211f4cu },
674
- { 0xd47487cc8470652bu, 0x7647c3200069671fu },
675
- { 0x84c8d4dfd2c63f3bu, 0x29ecd9f40041e073u },
676
- { 0xa5fb0a17c777cf09u, 0xf468107100525890u },
677
- { 0xcf79cc9db955c2ccu, 0x7182148d4066eeb4u },
678
- { 0x81ac1fe293d599bfu, 0xc6f14cd848405530u },
679
- { 0xa21727db38cb002fu, 0xb8ada00e5a506a7cu },
680
- { 0xca9cf1d206fdc03bu, 0xa6d90811f0e4851cu },
681
- { 0xfd442e4688bd304au, 0x908f4a166d1da663u },
682
- { 0x9e4a9cec15763e2eu, 0x9a598e4e043287feu },
683
- { 0xc5dd44271ad3cdbau, 0x40eff1e1853f29fdu },
684
- { 0xf7549530e188c128u, 0xd12bee59e68ef47cu },
685
- { 0x9a94dd3e8cf578b9u, 0x82bb74f8301958ceu },
686
- { 0xc13a148e3032d6e7u, 0xe36a52363c1faf01u },
687
- { 0xf18899b1bc3f8ca1u, 0xdc44e6c3cb279ac1u },
688
- { 0x96f5600f15a7b7e5u, 0x29ab103a5ef8c0b9u },
689
- { 0xbcb2b812db11a5deu, 0x7415d448f6b6f0e7u },
690
- { 0xebdf661791d60f56u, 0x111b495b3464ad21u },
691
- { 0x936b9fcebb25c995u, 0xcab10dd900beec34u },
692
- { 0xb84687c269ef3bfbu, 0x3d5d514f40eea742u },
693
- { 0xe65829b3046b0afau, 0x0cb4a5a3112a5112u },
694
- { 0x8ff71a0fe2c2e6dcu, 0x47f0e785eaba72abu },
695
- { 0xb3f4e093db73a093u, 0x59ed216765690f56u },
696
- { 0xe0f218b8d25088b8u, 0x306869c13ec3532cu },
697
- { 0x8c974f7383725573u, 0x1e414218c73a13fbu },
698
- { 0xafbd2350644eeacfu, 0xe5d1929ef90898fau },
699
- { 0xdbac6c247d62a583u, 0xdf45f746b74abf39u },
700
- { 0x894bc396ce5da772u, 0x6b8bba8c328eb783u },
701
- { 0xab9eb47c81f5114fu, 0x066ea92f3f326564u },
702
- { 0xd686619ba27255a2u, 0xc80a537b0efefebdu },
703
- { 0x8613fd0145877585u, 0xbd06742ce95f5f36u },
704
- { 0xa798fc4196e952e7u, 0x2c48113823b73704u },
705
- { 0xd17f3b51fca3a7a0u, 0xf75a15862ca504c5u },
706
- { 0x82ef85133de648c4u, 0x9a984d73dbe722fbu },
707
- { 0xa3ab66580d5fdaf5u, 0xc13e60d0d2e0ebbau },
708
- { 0xcc963fee10b7d1b3u, 0x318df905079926a8u },
709
- { 0xffbbcfe994e5c61fu, 0xfdf17746497f7052u },
710
- { 0x9fd561f1fd0f9bd3u, 0xfeb6ea8bedefa633u },
711
- { 0xc7caba6e7c5382c8u, 0xfe64a52ee96b8fc0u },
712
- { 0xf9bd690a1b68637bu, 0x3dfdce7aa3c673b0u },
713
- { 0x9c1661a651213e2du, 0x06bea10ca65c084eu },
714
- { 0xc31bfa0fe5698db8u, 0x486e494fcff30a62u },
715
- { 0xf3e2f893dec3f126u, 0x5a89dba3c3efccfau },
716
- { 0x986ddb5c6b3a76b7u, 0xf89629465a75e01cu },
717
- { 0xbe89523386091465u, 0xf6bbb397f1135823u },
718
- { 0xee2ba6c0678b597fu, 0x746aa07ded582e2cu },
719
- { 0x94db483840b717efu, 0xa8c2a44eb4571cdcu },
720
- { 0xba121a4650e4ddebu, 0x92f34d62616ce413u },
721
- { 0xe896a0d7e51e1566u, 0x77b020baf9c81d17u },
722
- { 0x915e2486ef32cd60u, 0x0ace1474dc1d122eu },
723
- { 0xb5b5ada8aaff80b8u, 0x0d819992132456bau },
724
- { 0xe3231912d5bf60e6u, 0x10e1fff697ed6c69u },
725
- { 0x8df5efabc5979c8fu, 0xca8d3ffa1ef463c1u },
726
- { 0xb1736b96b6fd83b3u, 0xbd308ff8a6b17cb2u },
727
- { 0xddd0467c64bce4a0u, 0xac7cb3f6d05ddbdeu },
728
- { 0x8aa22c0dbef60ee4u, 0x6bcdf07a423aa96bu },
729
- { 0xad4ab7112eb3929du, 0x86c16c98d2c953c6u },
730
- { 0xd89d64d57a607744u, 0xe871c7bf077ba8b7u },
731
- { 0x87625f056c7c4a8bu, 0x11471cd764ad4972u },
732
- { 0xa93af6c6c79b5d2du, 0xd598e40d3dd89bcfu },
733
- { 0xd389b47879823479u, 0x4aff1d108d4ec2c3u },
734
- { 0x843610cb4bf160cbu, 0xcedf722a585139bau },
735
- { 0xa54394fe1eedb8feu, 0xc2974eb4ee658828u },
736
- { 0xce947a3da6a9273eu, 0x733d226229feea32u },
737
- { 0x811ccc668829b887u, 0x0806357d5a3f525fu },
738
- { 0xa163ff802a3426a8u, 0xca07c2dcb0cf26f7u },
739
- { 0xc9bcff6034c13052u, 0xfc89b393dd02f0b5u },
740
- { 0xfc2c3f3841f17c67u, 0xbbac2078d443ace2u },
741
- { 0x9d9ba7832936edc0u, 0xd54b944b84aa4c0du },
742
- { 0xc5029163f384a931u, 0x0a9e795e65d4df11u },
743
- { 0xf64335bcf065d37du, 0x4d4617b5ff4a16d5u },
744
- { 0x99ea0196163fa42eu, 0x504bced1bf8e4e45u },
745
- { 0xc06481fb9bcf8d39u, 0xe45ec2862f71e1d6u },
746
- { 0xf07da27a82c37088u, 0x5d767327bb4e5a4cu },
747
- { 0x964e858c91ba2655u, 0x3a6a07f8d510f86fu },
748
- { 0xbbe226efb628afeau, 0x890489f70a55368bu },
749
- { 0xeadab0aba3b2dbe5u, 0x2b45ac74ccea842eu },
750
- { 0x92c8ae6b464fc96fu, 0x3b0b8bc90012929du },
751
- { 0xb77ada0617e3bbcbu, 0x09ce6ebb40173744u },
752
- { 0xe55990879ddcaabdu, 0xcc420a6a101d0515u },
753
- { 0x8f57fa54c2a9eab6u, 0x9fa946824a12232du },
754
- { 0xb32df8e9f3546564u, 0x47939822dc96abf9u },
755
- { 0xdff9772470297ebdu, 0x59787e2b93bc56f7u },
756
- { 0x8bfbea76c619ef36u, 0x57eb4edb3c55b65au },
757
- { 0xaefae51477a06b03u, 0xede622920b6b23f1u },
758
- { 0xdab99e59958885c4u, 0xe95fab368e45ecedu },
759
- { 0x88b402f7fd75539bu, 0x11dbcb0218ebb414u },
760
- { 0xaae103b5fcd2a881u, 0xd652bdc29f26a119u },
761
- { 0xd59944a37c0752a2u, 0x4be76d3346f0495fu },
762
- { 0x857fcae62d8493a5u, 0x6f70a4400c562ddbu },
763
- { 0xa6dfbd9fb8e5b88eu, 0xcb4ccd500f6bb952u },
764
- { 0xd097ad07a71f26b2u, 0x7e2000a41346a7a7u },
765
- { 0x825ecc24c873782fu, 0x8ed400668c0c28c8u },
766
- { 0xa2f67f2dfa90563bu, 0x728900802f0f32fau },
767
- { 0xcbb41ef979346bcau, 0x4f2b40a03ad2ffb9u },
768
- { 0xfea126b7d78186bcu, 0xe2f610c84987bfa8u },
769
- { 0x9f24b832e6b0f436u, 0x0dd9ca7d2df4d7c9u },
770
- { 0xc6ede63fa05d3143u, 0x91503d1c79720dbbu },
771
- { 0xf8a95fcf88747d94u, 0x75a44c6397ce912au },
772
- { 0x9b69dbe1b548ce7cu, 0xc986afbe3ee11abau },
773
- { 0xc24452da229b021bu, 0xfbe85badce996168u },
774
- { 0xf2d56790ab41c2a2u, 0xfae27299423fb9c3u },
775
- { 0x97c560ba6b0919a5u, 0xdccd879fc967d41au },
776
- { 0xbdb6b8e905cb600fu, 0x5400e987bbc1c920u },
777
- { 0xed246723473e3813u, 0x290123e9aab23b68u },
778
- { 0x9436c0760c86e30bu, 0xf9a0b6720aaf6521u },
779
- { 0xb94470938fa89bceu, 0xf808e40e8d5b3e69u },
780
- { 0xe7958cb87392c2c2u, 0xb60b1d1230b20e04u },
781
- { 0x90bd77f3483bb9b9u, 0xb1c6f22b5e6f48c2u },
782
- { 0xb4ecd5f01a4aa828u, 0x1e38aeb6360b1af3u },
783
- { 0xe2280b6c20dd5232u, 0x25c6da63c38de1b0u },
784
- { 0x8d590723948a535fu, 0x579c487e5a38ad0eu },
785
- { 0xb0af48ec79ace837u, 0x2d835a9df0c6d851u },
786
- { 0xdcdb1b2798182244u, 0xf8e431456cf88e65u },
787
- { 0x8a08f0f8bf0f156bu, 0x1b8e9ecb641b58ffu },
788
- { 0xac8b2d36eed2dac5u, 0xe272467e3d222f3fu },
789
- { 0xd7adf884aa879177u, 0x5b0ed81dcc6abb0fu },
790
- { 0x86ccbb52ea94baeau, 0x98e947129fc2b4e9u },
791
- { 0xa87fea27a539e9a5u, 0x3f2398d747b36224u },
792
- { 0xd29fe4b18e88640eu, 0x8eec7f0d19a03aadu },
793
- { 0x83a3eeeef9153e89u, 0x1953cf68300424acu },
794
- { 0xa48ceaaab75a8e2bu, 0x5fa8c3423c052dd7u },
795
- { 0xcdb02555653131b6u, 0x3792f412cb06794du },
796
- { 0x808e17555f3ebf11u, 0xe2bbd88bbee40bd0u },
797
- { 0xa0b19d2ab70e6ed6u, 0x5b6aceaeae9d0ec4u },
798
- { 0xc8de047564d20a8bu, 0xf245825a5a445275u },
799
- { 0xfb158592be068d2eu, 0xeed6e2f0f0d56712u },
800
- { 0x9ced737bb6c4183du, 0x55464dd69685606bu },
801
- { 0xc428d05aa4751e4cu, 0xaa97e14c3c26b886u },
802
- { 0xf53304714d9265dfu, 0xd53dd99f4b3066a8u },
803
- { 0x993fe2c6d07b7fabu, 0xe546a8038efe4029u },
804
- { 0xbf8fdb78849a5f96u, 0xde98520472bdd033u },
805
- { 0xef73d256a5c0f77cu, 0x963e66858f6d4440u },
806
- { 0x95a8637627989aadu, 0xdde7001379a44aa8u },
807
- { 0xbb127c53b17ec159u, 0x5560c018580d5d52u },
808
- { 0xe9d71b689dde71afu, 0xaab8f01e6e10b4a6u },
809
- { 0x9226712162ab070du, 0xcab3961304ca70e8u },
810
- { 0xb6b00d69bb55c8d1u, 0x3d607b97c5fd0d22u },
811
- { 0xe45c10c42a2b3b05u, 0x8cb89a7db77c506au },
812
- { 0x8eb98a7a9a5b04e3u, 0x77f3608e92adb242u },
813
- { 0xb267ed1940f1c61cu, 0x55f038b237591ed3u },
814
- { 0xdf01e85f912e37a3u, 0x6b6c46dec52f6688u },
815
- { 0x8b61313bbabce2c6u, 0x2323ac4b3b3da015u },
816
- { 0xae397d8aa96c1b77u, 0xabec975e0a0d081au },
817
- { 0xd9c7dced53c72255u, 0x96e7bd358c904a21u },
818
- { 0x881cea14545c7575u, 0x7e50d64177da2e54u },
819
- { 0xaa242499697392d2u, 0xdde50bd1d5d0b9e9u },
820
- { 0xd4ad2dbfc3d07787u, 0x955e4ec64b44e864u },
821
- { 0x84ec3c97da624ab4u, 0xbd5af13bef0b113eu },
822
- { 0xa6274bbdd0fadd61u, 0xecb1ad8aeacdd58eu },
823
- { 0xcfb11ead453994bau, 0x67de18eda5814af2u },
824
- { 0x81ceb32c4b43fcf4u, 0x80eacf948770ced7u },
825
- { 0xa2425ff75e14fc31u, 0xa1258379a94d028du },
826
- { 0xcad2f7f5359a3b3eu, 0x096ee45813a04330u },
827
- { 0xfd87b5f28300ca0du, 0x8bca9d6e188853fcu },
828
- { 0x9e74d1b791e07e48u, 0x775ea264cf55347du },
829
- { 0xc612062576589ddau, 0x95364afe032a819du },
830
- { 0xf79687aed3eec551u, 0x3a83ddbd83f52204u },
831
- { 0x9abe14cd44753b52u, 0xc4926a9672793542u },
832
- { 0xc16d9a0095928a27u, 0x75b7053c0f178293u },
833
- { 0xf1c90080baf72cb1u, 0x5324c68b12dd6338u },
834
- { 0x971da05074da7beeu, 0xd3f6fc16ebca5e03u },
835
- { 0xbce5086492111aeau, 0x88f4bb1ca6bcf584u },
836
- { 0xec1e4a7db69561a5u, 0x2b31e9e3d06c32e5u },
837
- { 0x9392ee8e921d5d07u, 0x3aff322e62439fcfu },
838
- { 0xb877aa3236a4b449u, 0x09befeb9fad487c2u },
839
- { 0xe69594bec44de15bu, 0x4c2ebe687989a9b3u },
840
- { 0x901d7cf73ab0acd9u, 0x0f9d37014bf60a10u },
841
- { 0xb424dc35095cd80fu, 0x538484c19ef38c94u },
842
- { 0xe12e13424bb40e13u, 0x2865a5f206b06fb9u },
843
- { 0x8cbccc096f5088cbu, 0xf93f87b7442e45d3u },
844
- { 0xafebff0bcb24aafeu, 0xf78f69a51539d748u },
845
- { 0xdbe6fecebdedd5beu, 0xb573440e5a884d1bu },
846
- { 0x89705f4136b4a597u, 0x31680a88f8953030u },
847
- { 0xabcc77118461cefcu, 0xfdc20d2b36ba7c3du },
848
- { 0xd6bf94d5e57a42bcu, 0x3d32907604691b4cu },
849
- { 0x8637bd05af6c69b5u, 0xa63f9a49c2c1b10fu },
850
- { 0xa7c5ac471b478423u, 0x0fcf80dc33721d53u },
851
- { 0xd1b71758e219652bu, 0xd3c36113404ea4a8u },
852
- { 0x83126e978d4fdf3bu, 0x645a1cac083126e9u },
853
- { 0xa3d70a3d70a3d70au, 0x3d70a3d70a3d70a3u },
854
- { 0xccccccccccccccccu, 0xccccccccccccccccu },
855
- { 0x8000000000000000u, 0x0000000000000000u },
856
- { 0xa000000000000000u, 0x0000000000000000u },
857
- { 0xc800000000000000u, 0x0000000000000000u },
858
- { 0xfa00000000000000u, 0x0000000000000000u },
859
- { 0x9c40000000000000u, 0x0000000000000000u },
860
- { 0xc350000000000000u, 0x0000000000000000u },
861
- { 0xf424000000000000u, 0x0000000000000000u },
862
- { 0x9896800000000000u, 0x0000000000000000u },
863
- { 0xbebc200000000000u, 0x0000000000000000u },
864
- { 0xee6b280000000000u, 0x0000000000000000u },
865
- { 0x9502f90000000000u, 0x0000000000000000u },
866
- { 0xba43b74000000000u, 0x0000000000000000u },
867
- { 0xe8d4a51000000000u, 0x0000000000000000u },
868
- { 0x9184e72a00000000u, 0x0000000000000000u },
869
- { 0xb5e620f480000000u, 0x0000000000000000u },
870
- { 0xe35fa931a0000000u, 0x0000000000000000u },
871
- { 0x8e1bc9bf04000000u, 0x0000000000000000u },
872
- { 0xb1a2bc2ec5000000u, 0x0000000000000000u },
873
- { 0xde0b6b3a76400000u, 0x0000000000000000u },
874
- { 0x8ac7230489e80000u, 0x0000000000000000u },
875
- { 0xad78ebc5ac620000u, 0x0000000000000000u },
876
- { 0xd8d726b7177a8000u, 0x0000000000000000u },
877
- { 0x878678326eac9000u, 0x0000000000000000u },
878
- { 0xa968163f0a57b400u, 0x0000000000000000u },
879
- { 0xd3c21bcecceda100u, 0x0000000000000000u },
880
- { 0x84595161401484a0u, 0x0000000000000000u },
881
- { 0xa56fa5b99019a5c8u, 0x0000000000000000u },
882
- { 0xcecb8f27f4200f3au, 0x0000000000000000u },
883
- { 0x813f3978f8940984u, 0x4000000000000000u },
884
- { 0xa18f07d736b90be5u, 0x5000000000000000u },
885
- { 0xc9f2c9cd04674edeu, 0xa400000000000000u },
886
- { 0xfc6f7c4045812296u, 0x4d00000000000000u },
887
- { 0x9dc5ada82b70b59du, 0xf020000000000000u },
888
- { 0xc5371912364ce305u, 0x6c28000000000000u },
889
- { 0xf684df56c3e01bc6u, 0xc732000000000000u },
890
- { 0x9a130b963a6c115cu, 0x3c7f400000000000u },
891
- { 0xc097ce7bc90715b3u, 0x4b9f100000000000u },
892
- { 0xf0bdc21abb48db20u, 0x1e86d40000000000u },
893
- { 0x96769950b50d88f4u, 0x1314448000000000u },
894
- { 0xbc143fa4e250eb31u, 0x17d955a000000000u },
895
- { 0xeb194f8e1ae525fdu, 0x5dcfab0800000000u },
896
- { 0x92efd1b8d0cf37beu, 0x5aa1cae500000000u },
897
- { 0xb7abc627050305adu, 0xf14a3d9e40000000u },
898
- { 0xe596b7b0c643c719u, 0x6d9ccd05d0000000u },
899
- { 0x8f7e32ce7bea5c6fu, 0xe4820023a2000000u },
900
- { 0xb35dbf821ae4f38bu, 0xdda2802c8a800000u },
901
- { 0xe0352f62a19e306eu, 0xd50b2037ad200000u },
902
- { 0x8c213d9da502de45u, 0x4526f422cc340000u },
903
- { 0xaf298d050e4395d6u, 0x9670b12b7f410000u },
904
- { 0xdaf3f04651d47b4cu, 0x3c0cdd765f114000u },
905
- { 0x88d8762bf324cd0fu, 0xa5880a69fb6ac800u },
906
- { 0xab0e93b6efee0053u, 0x8eea0d047a457a00u },
907
- { 0xd5d238a4abe98068u, 0x72a4904598d6d880u },
908
- { 0x85a36366eb71f041u, 0x47a6da2b7f864750u },
909
- { 0xa70c3c40a64e6c51u, 0x999090b65f67d924u },
910
- { 0xd0cf4b50cfe20765u, 0xfff4b4e3f741cf6du },
911
- { 0x82818f1281ed449fu, 0xbff8f10e7a8921a4u },
912
- { 0xa321f2d7226895c7u, 0xaff72d52192b6a0du },
913
- { 0xcbea6f8ceb02bb39u, 0x9bf4f8a69f764490u },
914
- { 0xfee50b7025c36a08u, 0x02f236d04753d5b4u },
915
- { 0x9f4f2726179a2245u, 0x01d762422c946590u },
916
- { 0xc722f0ef9d80aad6u, 0x424d3ad2b7b97ef5u },
917
- { 0xf8ebad2b84e0d58bu, 0xd2e0898765a7deb2u },
918
- { 0x9b934c3b330c8577u, 0x63cc55f49f88eb2fu },
919
- { 0xc2781f49ffcfa6d5u, 0x3cbf6b71c76b25fbu },
920
- { 0xf316271c7fc3908au, 0x8bef464e3945ef7au },
921
- { 0x97edd871cfda3a56u, 0x97758bf0e3cbb5acu },
922
- { 0xbde94e8e43d0c8ecu, 0x3d52eeed1cbea317u },
923
- { 0xed63a231d4c4fb27u, 0x4ca7aaa863ee4bddu },
924
- { 0x945e455f24fb1cf8u, 0x8fe8caa93e74ef6au },
925
- { 0xb975d6b6ee39e436u, 0xb3e2fd538e122b44u },
926
- { 0xe7d34c64a9c85d44u, 0x60dbbca87196b616u },
927
- { 0x90e40fbeea1d3a4au, 0xbc8955e946fe31cdu },
928
- { 0xb51d13aea4a488ddu, 0x6babab6398bdbe41u },
929
- { 0xe264589a4dcdab14u, 0xc696963c7eed2dd1u },
930
- { 0x8d7eb76070a08aecu, 0xfc1e1de5cf543ca2u },
931
- { 0xb0de65388cc8ada8u, 0x3b25a55f43294bcbu },
932
- { 0xdd15fe86affad912u, 0x49ef0eb713f39ebeu },
933
- { 0x8a2dbf142dfcc7abu, 0x6e3569326c784337u },
934
- { 0xacb92ed9397bf996u, 0x49c2c37f07965404u },
935
- { 0xd7e77a8f87daf7fbu, 0xdc33745ec97be906u },
936
- { 0x86f0ac99b4e8dafdu, 0x69a028bb3ded71a3u },
937
- { 0xa8acd7c0222311bcu, 0xc40832ea0d68ce0cu },
938
- { 0xd2d80db02aabd62bu, 0xf50a3fa490c30190u },
939
- { 0x83c7088e1aab65dbu, 0x792667c6da79e0fau },
940
- { 0xa4b8cab1a1563f52u, 0x577001b891185938u },
941
- { 0xcde6fd5e09abcf26u, 0xed4c0226b55e6f86u },
942
- { 0x80b05e5ac60b6178u, 0x544f8158315b05b4u },
943
- { 0xa0dc75f1778e39d6u, 0x696361ae3db1c721u },
944
- { 0xc913936dd571c84cu, 0x03bc3a19cd1e38e9u },
945
- { 0xfb5878494ace3a5fu, 0x04ab48a04065c723u },
946
- { 0x9d174b2dcec0e47bu, 0x62eb0d64283f9c76u },
947
- { 0xc45d1df942711d9au, 0x3ba5d0bd324f8394u },
948
- { 0xf5746577930d6500u, 0xca8f44ec7ee36479u },
949
- { 0x9968bf6abbe85f20u, 0x7e998b13cf4e1ecbu },
950
- { 0xbfc2ef456ae276e8u, 0x9e3fedd8c321a67eu },
951
- { 0xefb3ab16c59b14a2u, 0xc5cfe94ef3ea101eu },
952
- { 0x95d04aee3b80ece5u, 0xbba1f1d158724a12u },
953
- { 0xbb445da9ca61281fu, 0x2a8a6e45ae8edc97u },
954
- { 0xea1575143cf97226u, 0xf52d09d71a3293bdu },
955
- { 0x924d692ca61be758u, 0x593c2626705f9c56u },
956
- { 0xb6e0c377cfa2e12eu, 0x6f8b2fb00c77836cu },
957
- { 0xe498f455c38b997au, 0x0b6dfb9c0f956447u },
958
- { 0x8edf98b59a373fecu, 0x4724bd4189bd5eacu },
959
- { 0xb2977ee300c50fe7u, 0x58edec91ec2cb657u },
960
- { 0xdf3d5e9bc0f653e1u, 0x2f2967b66737e3edu },
961
- { 0x8b865b215899f46cu, 0xbd79e0d20082ee74u },
962
- { 0xae67f1e9aec07187u, 0xecd8590680a3aa11u },
963
- { 0xda01ee641a708de9u, 0xe80e6f4820cc9495u },
964
- { 0x884134fe908658b2u, 0x3109058d147fdcddu },
965
- { 0xaa51823e34a7eedeu, 0xbd4b46f0599fd415u },
966
- { 0xd4e5e2cdc1d1ea96u, 0x6c9e18ac7007c91au },
967
- { 0x850fadc09923329eu, 0x03e2cf6bc604ddb0u },
968
- { 0xa6539930bf6bff45u, 0x84db8346b786151cu },
969
- { 0xcfe87f7cef46ff16u, 0xe612641865679a63u },
970
- { 0x81f14fae158c5f6eu, 0x4fcb7e8f3f60c07eu },
971
- { 0xa26da3999aef7749u, 0xe3be5e330f38f09du },
972
- { 0xcb090c8001ab551cu, 0x5cadf5bfd3072cc5u },
973
- { 0xfdcb4fa002162a63u, 0x73d9732fc7c8f7f6u },
974
- { 0x9e9f11c4014dda7eu, 0x2867e7fddcdd9afau },
975
- { 0xc646d63501a1511du, 0xb281e1fd541501b8u },
976
- { 0xf7d88bc24209a565u, 0x1f225a7ca91a4226u },
977
- { 0x9ae757596946075fu, 0x3375788de9b06958u },
978
- { 0xc1a12d2fc3978937u, 0x0052d6b1641c83aeu },
979
- { 0xf209787bb47d6b84u, 0xc0678c5dbd23a49au },
980
- { 0x9745eb4d50ce6332u, 0xf840b7ba963646e0u },
981
- { 0xbd176620a501fbffu, 0xb650e5a93bc3d898u },
982
- { 0xec5d3fa8ce427affu, 0xa3e51f138ab4cebeu },
983
- { 0x93ba47c980e98cdfu, 0xc66f336c36b10137u },
984
- { 0xb8a8d9bbe123f017u, 0xb80b0047445d4184u },
985
- { 0xe6d3102ad96cec1du, 0xa60dc059157491e5u },
986
- { 0x9043ea1ac7e41392u, 0x87c89837ad68db2fu },
987
- { 0xb454e4a179dd1877u, 0x29babe4598c311fbu },
988
- { 0xe16a1dc9d8545e94u, 0xf4296dd6fef3d67au },
989
- { 0x8ce2529e2734bb1du, 0x1899e4a65f58660cu },
990
- { 0xb01ae745b101e9e4u, 0x5ec05dcff72e7f8fu },
991
- { 0xdc21a1171d42645du, 0x76707543f4fa1f73u },
992
- { 0x899504ae72497ebau, 0x6a06494a791c53a8u },
993
- { 0xabfa45da0edbde69u, 0x0487db9d17636892u },
994
- { 0xd6f8d7509292d603u, 0x45a9d2845d3c42b6u },
995
- { 0x865b86925b9bc5c2u, 0x0b8a2392ba45a9b2u },
996
- { 0xa7f26836f282b732u, 0x8e6cac7768d7141eu },
997
- { 0xd1ef0244af2364ffu, 0x3207d795430cd926u },
998
- { 0x8335616aed761f1fu, 0x7f44e6bd49e807b8u },
999
- { 0xa402b9c5a8d3a6e7u, 0x5f16206c9c6209a6u },
1000
- { 0xcd036837130890a1u, 0x36dba887c37a8c0fu },
1001
- { 0x802221226be55a64u, 0xc2494954da2c9789u },
1002
- { 0xa02aa96b06deb0fdu, 0xf2db9baa10b7bd6cu },
1003
- { 0xc83553c5c8965d3du, 0x6f92829494e5acc7u },
1004
- { 0xfa42a8b73abbf48cu, 0xcb772339ba1f17f9u },
1005
- { 0x9c69a97284b578d7u, 0xff2a760414536efbu },
1006
- { 0xc38413cf25e2d70du, 0xfef5138519684abau },
1007
- { 0xf46518c2ef5b8cd1u, 0x7eb258665fc25d69u },
1008
- { 0x98bf2f79d5993802u, 0xef2f773ffbd97a61u },
1009
- { 0xbeeefb584aff8603u, 0xaafb550ffacfd8fau },
1010
- { 0xeeaaba2e5dbf6784u, 0x95ba2a53f983cf38u },
1011
- { 0x952ab45cfa97a0b2u, 0xdd945a747bf26183u },
1012
- { 0xba756174393d88dfu, 0x94f971119aeef9e4u },
1013
- { 0xe912b9d1478ceb17u, 0x7a37cd5601aab85du },
1014
- { 0x91abb422ccb812eeu, 0xac62e055c10ab33au },
1015
- { 0xb616a12b7fe617aau, 0x577b986b314d6009u },
1016
- { 0xe39c49765fdf9d94u, 0xed5a7e85fda0b80bu },
1017
- { 0x8e41ade9fbebc27du, 0x14588f13be847307u },
1018
- { 0xb1d219647ae6b31cu, 0x596eb2d8ae258fc8u },
1019
- { 0xde469fbd99a05fe3u, 0x6fca5f8ed9aef3bbu },
1020
- { 0x8aec23d680043beeu, 0x25de7bb9480d5854u },
1021
- { 0xada72ccc20054ae9u, 0xaf561aa79a10ae6au },
1022
- { 0xd910f7ff28069da4u, 0x1b2ba1518094da04u },
1023
- { 0x87aa9aff79042286u, 0x90fb44d2f05d0842u },
1024
- { 0xa99541bf57452b28u, 0x353a1607ac744a53u },
1025
- { 0xd3fa922f2d1675f2u, 0x42889b8997915ce8u },
1026
- { 0x847c9b5d7c2e09b7u, 0x69956135febada11u },
1027
- { 0xa59bc234db398c25u, 0x43fab9837e699095u },
1028
- { 0xcf02b2c21207ef2eu, 0x94f967e45e03f4bbu },
1029
- { 0x8161afb94b44f57du, 0x1d1be0eebac278f5u },
1030
- { 0xa1ba1ba79e1632dcu, 0x6462d92a69731732u },
1031
- { 0xca28a291859bbf93u, 0x7d7b8f7503cfdcfeu },
1032
- { 0xfcb2cb35e702af78u, 0x5cda735244c3d43eu },
1033
- { 0x9defbf01b061adabu, 0x3a0888136afa64a7u },
1034
- { 0xc56baec21c7a1916u, 0x088aaa1845b8fdd0u },
1035
- { 0xf6c69a72a3989f5bu, 0x8aad549e57273d45u },
1036
- { 0x9a3c2087a63f6399u, 0x36ac54e2f678864bu },
1037
- { 0xc0cb28a98fcf3c7fu, 0x84576a1bb416a7ddu },
1038
- { 0xf0fdf2d3f3c30b9fu, 0x656d44a2a11c51d5u },
1039
- { 0x969eb7c47859e743u, 0x9f644ae5a4b1b325u },
1040
- { 0xbc4665b596706114u, 0x873d5d9f0dde1feeu },
1041
- { 0xeb57ff22fc0c7959u, 0xa90cb506d155a7eau },
1042
- { 0x9316ff75dd87cbd8u, 0x09a7f12442d588f2u },
1043
- { 0xb7dcbf5354e9beceu, 0x0c11ed6d538aeb2fu },
1044
- { 0xe5d3ef282a242e81u, 0x8f1668c8a86da5fau },
1045
- { 0x8fa475791a569d10u, 0xf96e017d694487bcu },
1046
- { 0xb38d92d760ec4455u, 0x37c981dcc395a9acu },
1047
- { 0xe070f78d3927556au, 0x85bbe253f47b1417u },
1048
- { 0x8c469ab843b89562u, 0x93956d7478ccec8eu },
1049
- { 0xaf58416654a6babbu, 0x387ac8d1970027b2u },
1050
- { 0xdb2e51bfe9d0696au, 0x06997b05fcc0319eu },
1051
- { 0x88fcf317f22241e2u, 0x441fece3bdf81f03u },
1052
- { 0xab3c2fddeeaad25au, 0xd527e81cad7626c3u },
1053
- { 0xd60b3bd56a5586f1u, 0x8a71e223d8d3b074u },
1054
- { 0x85c7056562757456u, 0xf6872d5667844e49u },
1055
- { 0xa738c6bebb12d16cu, 0xb428f8ac016561dbu },
1056
- { 0xd106f86e69d785c7u, 0xe13336d701beba52u },
1057
- { 0x82a45b450226b39cu, 0xecc0024661173473u },
1058
- { 0xa34d721642b06084u, 0x27f002d7f95d0190u },
1059
- { 0xcc20ce9bd35c78a5u, 0x31ec038df7b441f4u },
1060
- { 0xff290242c83396ceu, 0x7e67047175a15271u },
1061
- { 0x9f79a169bd203e41u, 0x0f0062c6e984d386u },
1062
- { 0xc75809c42c684dd1u, 0x52c07b78a3e60868u },
1063
- { 0xf92e0c3537826145u, 0xa7709a56ccdf8a82u },
1064
- { 0x9bbcc7a142b17ccbu, 0x88a66076400bb691u },
1065
- { 0xc2abf989935ddbfeu, 0x6acff893d00ea435u },
1066
- { 0xf356f7ebf83552feu, 0x0583f6b8c4124d43u },
1067
- { 0x98165af37b2153deu, 0xc3727a337a8b704au },
1068
- { 0xbe1bf1b059e9a8d6u, 0x744f18c0592e4c5cu },
1069
- { 0xeda2ee1c7064130cu, 0x1162def06f79df73u },
1070
- { 0x9485d4d1c63e8be7u, 0x8addcb5645ac2ba8u },
1071
- { 0xb9a74a0637ce2ee1u, 0x6d953e2bd7173692u },
1072
- { 0xe8111c87c5c1ba99u, 0xc8fa8db6ccdd0437u },
1073
- { 0x910ab1d4db9914a0u, 0x1d9c9892400a22a2u },
1074
- { 0xb54d5e4a127f59c8u, 0x2503beb6d00cab4bu },
1075
- { 0xe2a0b5dc971f303au, 0x2e44ae64840fd61du },
1076
- { 0x8da471a9de737e24u, 0x5ceaecfed289e5d2u },
1077
- { 0xb10d8e1456105dadu, 0x7425a83e872c5f47u },
1078
- { 0xdd50f1996b947518u, 0xd12f124e28f77719u },
1079
- { 0x8a5296ffe33cc92fu, 0x82bd6b70d99aaa6fu },
1080
- { 0xace73cbfdc0bfb7bu, 0x636cc64d1001550bu },
1081
- { 0xd8210befd30efa5au, 0x3c47f7e05401aa4eu },
1082
- { 0x8714a775e3e95c78u, 0x65acfaec34810a71u },
1083
- { 0xa8d9d1535ce3b396u, 0x7f1839a741a14d0du },
1084
- { 0xd31045a8341ca07cu, 0x1ede48111209a050u },
1085
- { 0x83ea2b892091e44du, 0x934aed0aab460432u },
1086
- { 0xa4e4b66b68b65d60u, 0xf81da84d5617853fu },
1087
- { 0xce1de40642e3f4b9u, 0x36251260ab9d668eu },
1088
- { 0x80d2ae83e9ce78f3u, 0xc1d72b7c6b426019u },
1089
- { 0xa1075a24e4421730u, 0xb24cf65b8612f81fu },
1090
- { 0xc94930ae1d529cfcu, 0xdee033f26797b627u },
1091
- { 0xfb9b7cd9a4a7443cu, 0x169840ef017da3b1u },
1092
- { 0x9d412e0806e88aa5u, 0x8e1f289560ee864eu },
1093
- { 0xc491798a08a2ad4eu, 0xf1a6f2bab92a27e2u },
1094
- { 0xf5b5d7ec8acb58a2u, 0xae10af696774b1dbu },
1095
- { 0x9991a6f3d6bf1765u, 0xacca6da1e0a8ef29u },
1096
- { 0xbff610b0cc6edd3fu, 0x17fd090a58d32af3u },
1097
- { 0xeff394dcff8a948eu, 0xddfc4b4cef07f5b0u },
1098
- { 0x95f83d0a1fb69cd9u, 0x4abdaf101564f98eu },
1099
- { 0xbb764c4ca7a4440fu, 0x9d6d1ad41abe37f1u },
1100
- { 0xea53df5fd18d5513u, 0x84c86189216dc5edu },
1101
- { 0x92746b9be2f8552cu, 0x32fd3cf5b4e49bb4u },
1102
- { 0xb7118682dbb66a77u, 0x3fbc8c33221dc2a1u },
1103
- { 0xe4d5e82392a40515u, 0x0fabaf3feaa5334au },
1104
- { 0x8f05b1163ba6832du, 0x29cb4d87f2a7400eu },
1105
- { 0xb2c71d5bca9023f8u, 0x743e20e9ef511012u },
1106
- { 0xdf78e4b2bd342cf6u, 0x914da9246b255416u },
1107
- { 0x8bab8eefb6409c1au, 0x1ad089b6c2f7548eu },
1108
- { 0xae9672aba3d0c320u, 0xa184ac2473b529b1u },
1109
- { 0xda3c0f568cc4f3e8u, 0xc9e5d72d90a2741eu },
1110
- { 0x8865899617fb1871u, 0x7e2fa67c7a658892u },
1111
- { 0xaa7eebfb9df9de8du, 0xddbb901b98feeab7u },
1112
- { 0xd51ea6fa85785631u, 0x552a74227f3ea565u },
1113
- { 0x8533285c936b35deu, 0xd53a88958f87275fu },
1114
- { 0xa67ff273b8460356u, 0x8a892abaf368f137u },
1115
- { 0xd01fef10a657842cu, 0x2d2b7569b0432d85u },
1116
- { 0x8213f56a67f6b29bu, 0x9c3b29620e29fc73u },
1117
- { 0xa298f2c501f45f42u, 0x8349f3ba91b47b8fu },
1118
- { 0xcb3f2f7642717713u, 0x241c70a936219a73u },
1119
- { 0xfe0efb53d30dd4d7u, 0xed238cd383aa0110u },
1120
- { 0x9ec95d1463e8a506u, 0xf4363804324a40aau },
1121
- { 0xc67bb4597ce2ce48u, 0xb143c6053edcd0d5u },
1122
- { 0xf81aa16fdc1b81dau, 0xdd94b7868e94050au },
1123
- { 0x9b10a4e5e9913128u, 0xca7cf2b4191c8326u },
1124
- { 0xc1d4ce1f63f57d72u, 0xfd1c2f611f63a3f0u },
1125
- { 0xf24a01a73cf2dccfu, 0xbc633b39673c8cecu },
1126
- { 0x976e41088617ca01u, 0xd5be0503e085d813u },
1127
- { 0xbd49d14aa79dbc82u, 0x4b2d8644d8a74e18u },
1128
- { 0xec9c459d51852ba2u, 0xddf8e7d60ed1219eu },
1129
- { 0x93e1ab8252f33b45u, 0xcabb90e5c942b503u },
1130
- { 0xb8da1662e7b00a17u, 0x3d6a751f3b936243u },
1131
- { 0xe7109bfba19c0c9du, 0x0cc512670a783ad4u },
1132
- { 0x906a617d450187e2u, 0x27fb2b80668b24c5u },
1133
- { 0xb484f9dc9641e9dau, 0xb1f9f660802dedf6u },
1134
- { 0xe1a63853bbd26451u, 0x5e7873f8a0396973u },
1135
- { 0x8d07e33455637eb2u, 0xdb0b487b6423e1e8u },
1136
- { 0xb049dc016abc5e5fu, 0x91ce1a9a3d2cda62u },
1137
- { 0xdc5c5301c56b75f7u, 0x7641a140cc7810fbu },
1138
- { 0x89b9b3e11b6329bau, 0xa9e904c87fcb0a9du },
1139
- { 0xac2820d9623bf429u, 0x546345fa9fbdcd44u },
1140
- { 0xd732290fbacaf133u, 0xa97c177947ad4095u },
1141
- { 0x867f59a9d4bed6c0u, 0x49ed8eabcccc485du },
1142
- { 0xa81f301449ee8c70u, 0x5c68f256bfff5a74u },
1143
- { 0xd226fc195c6a2f8cu, 0x73832eec6fff3111u },
1144
- { 0x83585d8fd9c25db7u, 0xc831fd53c5ff7eabu },
1145
- { 0xa42e74f3d032f525u, 0xba3e7ca8b77f5e55u },
1146
- { 0xcd3a1230c43fb26fu, 0x28ce1bd2e55f35ebu },
1147
- { 0x80444b5e7aa7cf85u, 0x7980d163cf5b81b3u },
1148
- { 0xa0555e361951c366u, 0xd7e105bcc332621fu },
1149
- { 0xc86ab5c39fa63440u, 0x8dd9472bf3fefaa7u },
1150
- { 0xfa856334878fc150u, 0xb14f98f6f0feb951u },
1151
- { 0x9c935e00d4b9d8d2u, 0x6ed1bf9a569f33d3u },
1152
- { 0xc3b8358109e84f07u, 0x0a862f80ec4700c8u },
1153
- { 0xf4a642e14c6262c8u, 0xcd27bb612758c0fau },
1154
- { 0x98e7e9cccfbd7dbdu, 0x8038d51cb897789cu },
1155
- { 0xbf21e44003acdd2cu, 0xe0470a63e6bd56c3u },
1156
- { 0xeeea5d5004981478u, 0x1858ccfce06cac74u },
1157
- { 0x95527a5202df0ccbu, 0x0f37801e0c43ebc8u },
1158
- { 0xbaa718e68396cffdu, 0xd30560258f54e6bau },
1159
- { 0xe950df20247c83fdu, 0x47c6b82ef32a2069u },
1160
- { 0x91d28b7416cdd27eu, 0x4cdc331d57fa5441u },
1161
- { 0xb6472e511c81471du, 0xe0133fe4adf8e952u },
1162
- { 0xe3d8f9e563a198e5u, 0x58180fddd97723a6u },
1163
- { 0x8e679c2f5e44ff8fu, 0x570f09eaa7ea7648u },
1164
- { 0xb201833b35d63f73u, 0x2cd2cc6551e513dau },
1165
- { 0xde81e40a034bcf4fu, 0xf8077f7ea65e58d1u },
1166
- { 0x8b112e86420f6191u, 0xfb04afaf27faf782u },
1167
- { 0xadd57a27d29339f6u, 0x79c5db9af1f9b563u },
1168
- { 0xd94ad8b1c7380874u, 0x18375281ae7822bcu },
1169
- { 0x87cec76f1c830548u, 0x8f2293910d0b15b5u },
1170
- { 0xa9c2794ae3a3c69au, 0xb2eb3875504ddb22u },
1171
- { 0xd433179d9c8cb841u, 0x5fa60692a46151ebu },
1172
- { 0x849feec281d7f328u, 0xdbc7c41ba6bcd333u },
1173
- { 0xa5c7ea73224deff3u, 0x12b9b522906c0800u },
1174
- { 0xcf39e50feae16befu, 0xd768226b34870a00u },
1175
- { 0x81842f29f2cce375u, 0xe6a1158300d46640u },
1176
- { 0xa1e53af46f801c53u, 0x60495ae3c1097fd0u },
1177
- { 0xca5e89b18b602368u, 0x385bb19cb14bdfc4u },
1178
- { 0xfcf62c1dee382c42u, 0x46729e03dd9ed7b5u },
1179
- };
1180
-
1181
- /* The high 128 bits of the 192-bit product of `x_hi:x_lo` and `y`, dropping
1182
- the low word's carry exactly as upstream does: the table rounds down, and
1183
- the error that leaves is what the `+6` below absorbs. */
1184
- static void nish_umul192_hi128(uint64_t x_hi, uint64_t x_lo, uint64_t y,
1185
- uint64_t *hi, uint64_t *lo) {
1186
- __uint128_t p = (__uint128_t)x_hi * y;
1187
- uint64_t l = (uint64_t)p + (uint64_t)(((__uint128_t)x_lo * y) >> 64);
1188
- *hi = (uint64_t)(p >> 64) + (l < (uint64_t)p);
1189
- *lo = l;
1190
- }
1191
-
1192
- /* (x * y + c) >> 64: one decimal digit off a 64-bit fraction, biased by `c`. */
1193
- static uint64_t nish_umul128_add_hi64(uint64_t x, uint64_t y, uint64_t c) {
1194
- return (uint64_t)(((__uint128_t)x * y + c) >> 64);
1195
- }
1196
-
1197
- /* The shortest digits of a finite, positive double, given as its bits, as an
1198
- integer `sig` with no trailing zeros and `*exp10` set so the value is
1199
- `sig * 10^*exp10`. `sig` has 1 to 17 digits. */
1200
- static uint64_t nish_shortest_digits(uint64_t bits, int *exp10) {
1201
- uint64_t bin_sig = bits & ((1ull << 52) - 1);
1202
- int raw_exp = (int)(bits >> 52);
1203
- /* A power of two has a lower neighbour half as far away as its upper one,
1204
- so its rounding interval is lopsided ("irregular"). 2^-1022 is the one
1205
- power that is not: the largest subnormal sits a full ulp below it. V8 and
1206
- Ryu both treat it as regular, and so does this; upstream does not, which
1207
- would need one more table row and prints the same digits. */
1208
- int regular = bin_sig != 0 || raw_exp <= 1;
1209
- if (raw_exp == 0) raw_exp = 1; /* a subnormal has 2^-1022's spacing */
1210
- else bin_sig |= 1ull << 52;
1211
- int bin_exp = raw_exp - 1075;
1212
-
1213
- /* floor(log10(2^bin_exp)), or of 3/4 of it when irregular, and the shift
1214
- that puts every exponent's decimal point at the same bit. Scaling by
1215
- 10^(-dec_exp-1) rather than 10^-dec_exp lands on the shorter candidate
1216
- directly, so the extra digit comes off the fraction, not out of a div10. */
1217
- int dec_exp = (bin_exp * 315653 - (regular ? 0 : 131072)) >> 20;
1218
- int shift = bin_exp + ((-(dec_exp + 1) * 217707) >> 16) + 1 + 6;
1219
- const uint64_t *pow10 = NISH_POW10_SIG[-dec_exp - 1 - NISH_POW10_MIN];
1220
- uint64_t hi, lo;
1221
- nish_umul192_hi128(pow10[0], pow10[1], bin_sig << shift, &hi, &lo);
1222
- uint64_t integral = hi >> 6;
1223
- uint64_t fractional = (hi << 58) | (lo >> 6);
1224
-
1225
- /* Half the distance to each neighbour, in the fraction's units. An even
1226
- significand's interval is closed, which is the round-half-to-even tie
1227
- rule for reading the digits back. */
1228
- uint64_t half_ulp = pow10[0] >> (7 - shift);
1229
- int round_up, round_down;
1230
- uint64_t digit;
1231
- if (regular) {
1232
- half_ulp += 1 - (bin_sig & 1);
1233
- round_up = fractional + half_ulp < fractional;
1234
- round_down = half_ulp > fractional;
1235
- /* The nearest next digit, ties to even: 0.25 is the one fraction whose
1236
- tenfold is an exact .5 that rounds the wrong way. */
1237
- digit = nish_umul128_add_hi64(fractional, 10, (1ull << 63) + 6);
1238
- if (fractional == 1ull << 62) digit = 2;
1239
- } else {
1240
- round_up = half_ulp > ~0ull - fractional;
1241
- round_down = (half_ulp >> 1) > fractional;
1242
- /* The lower neighbour is closer, so the nearest digit may fall below the
1243
- interval: take the smallest one inside it instead. */
1244
- digit = nish_umul128_add_hi64(fractional, 10, (1ull << 63) - 1);
1245
- uint64_t least = nish_umul128_add_hi64(fractional - (half_ulp >> 1), 10, ~0ull);
1246
- if (digit < least) digit = least;
1247
- }
1248
-
1249
- /* When either end of the interval reaches past the shorter candidate, that
1250
- candidate (rounded toward the end that holds it) is the answer; otherwise
1251
- it takes one more digit. */
1252
- uint64_t sig = (integral + round_up) * 10 + (round_up | round_down ? 0 : digit);
1253
- int e = dec_exp;
1254
- /* At most 16 trailing zeros: `sig` is below 2^53 * 10 + 10 < 10^17. */
1255
- if (sig % 10 == 0) {
1256
- sig /= 10; e += 1;
1257
- if (sig % 100000000 == 0) { sig /= 100000000; e += 8; }
1258
- if (sig % 10000 == 0) { sig /= 10000; e += 4; }
1259
- if (sig % 100 == 0) { sig /= 100; e += 2; }
1260
- if (sig % 10 == 0) { sig /= 10; e += 1; }
1261
- }
1262
- *exp10 = e;
1263
- return sig;
1264
- }
1265
-
1266
- /* "00" to "99", so the digits go out two to a lookup and two to a store. */
1267
- static const char NISH_DIGITS2[200] =
1268
- "0001020304050607080910111213141516171819"
1269
- "2021222324252627282930313233343536373839"
1270
- "4041424344454647484950515253545556575859"
1271
- "6061626364656667686970717273747576777879"
1272
- "8081828384858687888990919293949596979899";
1273
-
1274
- static const uint64_t NISH_POW10_U64[18] = {
1275
- 1ull, 10ull, 100ull, 1000ull, 10000ull, 100000ull, 1000000ull, 10000000ull,
1276
- 100000000ull, 1000000000ull, 10000000000ull, 100000000000ull,
1277
- 1000000000000ull, 10000000000000ull, 100000000000000ull,
1278
- 1000000000000000ull, 10000000000000000ull, 100000000000000000ull,
1279
- };
1280
-
1281
- /* The decimal digits of `v` into the bytes just before `end`, as many as it
1282
- has, written backward a pair at a time. The caller knows the count. */
1283
- static void nish_put_digits(char *end, uint64_t v) {
1284
- while (v >= 100) {
1285
- uint64_t q = v / 100;
1286
- end -= 2;
1287
- memcpy(end, NISH_DIGITS2 + 2 * (v - q * 100), 2);
1288
- v = q;
1289
- }
1290
- if (v >= 10) memcpy(end - 2, NISH_DIGITS2 + 2 * v, 2);
1291
- else end[-1] = (char)('0' + v);
1292
- }
1293
-
1294
- /* runtime/nish.h and tests/runtime-test.c state the same size; tests/run.js
1295
- (`f64_format_oracle`) fails if the three disagree. */
1296
- #define NISH_F64_MAX 32
1297
-
1298
- /* JS Number#toString: shortest round-trip digits, e-form outside (-6, 21].
1299
- Writes no NUL and returns the length. The longest output is 25 bytes,
1300
- -0.0000012345678901234567: a sign, "0.", five zeros and seventeen digits.
1301
- Every other layout is shorter: 22 for a 21-digit integer and its sign, 24
1302
- for -1.2345678901234567e-308, 9 for -Infinity. No layout writes scratch
1303
- past its own final length. */
1304
- int nish_f64_format(double v, char out[NISH_F64_MAX]) {
1305
- uint64_t bits;
1306
- char *o = out;
1307
- memcpy(&bits, &v, 8);
1308
- if ((bits << 1) >> 53 == 0x7ff) {
1309
- if (bits << 12) { memcpy(o, "NaN", 3); return 3; }
1310
- if (bits >> 63) *o++ = '-';
1311
- memcpy(o, "Infinity", 8);
1312
- return (int)(o - out) + 8;
1313
- }
1314
- if ((bits << 1) == 0) { *o = '0'; return 1; } /* -0 prints as 0 */
1315
- if (bits >> 63) *o++ = '-';
1316
-
1317
- int e;
1318
- uint64_t sig = nish_shortest_digits(bits & ~(1ull << 63), &e);
1319
- /* The digit count: 1233 / 4096 is log10(2) from below, which can only be
1320
- one short, and the table settles it. */
1321
- int k = ((64 - __builtin_clzll(sig)) * 1233) >> 12;
1322
- k += sig >= NISH_POW10_U64[k];
1323
- int n = k + e; /* value = 0.<digits> * 10^n */
1324
-
1325
- if (n > 21 || n <= -6) {
1326
- /* d.ddde+x: the digits one byte right, then the first moved left past
1327
- where the point goes. */
1328
- nish_put_digits(o + 1 + k, sig);
1329
- o[0] = o[1];
1330
- if (k > 1) { o[1] = '.'; o += k + 1; }
1331
- else o += 1;
1332
- int x = n - 1;
1333
- *o++ = 'e';
1334
- *o++ = x < 0 ? '-' : '+';
1335
- if (x < 0) x = -x;
1336
- if (x >= 100) { *o++ = (char)('0' + x / 100); x %= 100; memcpy(o, NISH_DIGITS2 + 2 * x, 2); o += 2; }
1337
- else if (x >= 10) { memcpy(o, NISH_DIGITS2 + 2 * x, 2); o += 2; }
1338
- else *o++ = (char)('0' + x);
1339
- } else if (n <= 0) {
1340
- o[0] = '0'; o[1] = '.';
1341
- memset(o + 2, '0', (size_t)-n);
1342
- o += 2 - n;
1343
- nish_put_digits(o + k, sig);
1344
- o += k;
1345
- } else if (n >= k) {
1346
- nish_put_digits(o + k, sig);
1347
- memset(o + k, '0', (size_t)(n - k));
1348
- o += n;
1349
- } else {
1350
- /* The integer part shifts left one byte to open the point's slot. */
1351
- nish_put_digits(o + 1 + k, sig);
1352
- memmove(o, o + 1, (size_t)n);
1353
- o[n] = '.';
1354
- o += k + 1;
1355
- }
1356
- return (int)(o - out);
1357
- }
1358
-
1359
- nish_str *nish_str_from_f64(double v) {
1360
- char out[NISH_F64_MAX];
1361
- return nish_str_new(out, (uint64_t)nish_f64_format(v, out));
1362
- }
1363
-
1364
- /* `JsonWriter.f64`'s digits straight into the writer's buffer (std/json.ts,
1365
- `jsonPutF64Walk`; the emitter makes the call, src/kernels.ts): `v`'s
1366
- spelling at `buf[at]`, all of it or none. Answers the new end, or -1 when
1367
- `at` is negative or the bytes do not fit before `len`, and then writes
1368
- nothing, as `jsonWriterPutText` does. `len` is the array's length as the
1369
- Nish code's `toI32` reads it, which is never more than the array holds; the
1370
- comparison is in 64 bits, so no `len` or `at` wraps it. */
1371
- int32_t nish_json_put_f64(uint8_t *buf, int32_t len, int32_t at, double v) {
1372
- char out[NISH_F64_MAX];
1373
- int n = nish_f64_format(v, out);
1374
- if (at < 0 || (int64_t)at > (int64_t)len - n) return -1;
1375
- memcpy(buf + at, out, (size_t)n);
1376
- return at + n;
1377
- }
1378
-
1379
468
  /* ---- Math.random: xorshift64*, seeded lazily from time and pid. The shifts
1380
469
  and the multiplier are Marsaglia's and Vigna's published constants, which
1381
470
  are public domain.