The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[minor] More readable output from `gen_sizeclasses` (#13923)

* more readable output for tools/gen_sizeclasses

* gen_sizeclasses: document the less obvious definitions

authored by

Gabriel Scherer and committed by
GitHub
e23e32b7 90d45469

+73 -21
+48 -11
runtime/caml/sizeclasses.h
··· 3 3 #define POOL_HEADER_WSIZE 4 4 4 #define SIZECLASS_MAX 128 5 5 #define NUM_SIZECLASSES 32 6 + 7 + /* The largest size for this size class. 8 + (A gap is left after smaller objects) */ 6 9 static const unsigned int wsize_sizeclass[NUM_SIZECLASSES] = 7 - { 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 17, 19, 22, 25, 28, 32, 33, 37, 42, 8 - 47, 53, 59, 65, 73, 81, 89, 99, 108, 118, 128 }; 10 + { /* 0:*/ 1, 2, 3, 4, 5, 11 + /* 5:*/ 6, 7, 8, 10, 12, 12 + /* 10:*/ 14, 16, 17, 19, 22, 13 + /* 15:*/ 25, 28, 32, 33, 37, 14 + /* 20:*/ 42, 47, 53, 59, 65, 15 + /* 25:*/ 73, 81, 89, 99, 108, 16 + /* 30:*/ 118, 128 }; 17 + 18 + /* The number of padding words to use, at the beginning of a pool 19 + of this sizeclass, to reach exactly POOL_WSIZE words. */ 9 20 static const unsigned char wastage_sizeclass[NUM_SIZECLASSES] = 10 - { 0, 0, 0, 0, 2, 0, 4, 4, 2, 0, 4, 12, 12, 7, 0, 17, 4, 28, 0, 22, 18, 3, 11, 11 - 21, 62, 4, 42, 87, 33, 96, 80, 124 }; 21 + { /* 0:*/ 0, 0, 0, 0, 2, 22 + /* 5:*/ 0, 4, 4, 2, 0, 23 + /* 10:*/ 4, 12, 12, 7, 0, 24 + /* 15:*/ 17, 4, 28, 0, 22, 25 + /* 20:*/ 18, 3, 11, 21, 62, 26 + /* 25:*/ 4, 42, 87, 33, 96, 27 + /* 30:*/ 80, 124 }; 28 + 29 + /* Map from (positive) object sizes to size classes. */ 12 30 static const unsigned char sizeclass_wsize[SIZECLASS_MAX + 1] = 13 - { 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 13, 14, 14 - 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 17, 18, 19, 19, 19, 19, 20, 20, 15 - 20, 20, 20, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 16 - 23, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 17 - 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 18 - 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 30, 19 - 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }; 31 + { /* 0:*/ 255, 0, 1, 2, 3, 32 + /* 5:*/ 4, 5, 6, 7, 8, 33 + /* 10:*/ 8, 9, 9, 10, 10, 34 + /* 15:*/ 11, 11, 12, 13, 13, 35 + /* 20:*/ 14, 14, 14, 15, 15, 36 + /* 25:*/ 15, 16, 16, 16, 17, 37 + /* 30:*/ 17, 17, 17, 18, 19, 38 + /* 35:*/ 19, 19, 19, 20, 20, 39 + /* 40:*/ 20, 20, 20, 21, 21, 40 + /* 45:*/ 21, 21, 21, 22, 22, 41 + /* 50:*/ 22, 22, 22, 22, 23, 42 + /* 55:*/ 23, 23, 23, 23, 23, 43 + /* 60:*/ 24, 24, 24, 24, 24, 44 + /* 65:*/ 24, 25, 25, 25, 25, 45 + /* 70:*/ 25, 25, 25, 25, 26, 46 + /* 75:*/ 26, 26, 26, 26, 26, 47 + /* 80:*/ 26, 26, 27, 27, 27, 48 + /* 85:*/ 27, 27, 27, 27, 27, 49 + /* 90:*/ 28, 28, 28, 28, 28, 50 + /* 95:*/ 28, 28, 28, 28, 28, 51 + /*100:*/ 29, 29, 29, 29, 29, 52 + /*105:*/ 29, 29, 29, 29, 30, 53 + /*110:*/ 30, 30, 30, 30, 30, 54 + /*115:*/ 30, 30, 30, 30, 31, 55 + /*120:*/ 31, 31, 31, 31, 31, 56 + /*125:*/ 31, 31, 31, 31 };
+25 -10
tools/gen_sizeclasses.ml
··· 77 77 78 78 (* let () = print_overheads 1 sizes *) 79 79 80 - let rec print_list ppf = function 81 - | [] -> () 82 - | [x] -> fprintf ppf "%d" x 83 - | x :: xs -> fprintf ppf "%d,@ %a" x print_list xs 80 + let print_list ppf li = 81 + List.iteri (fun i x -> 82 + if i mod 5 > 0 then 83 + fprintf ppf ",@ %d" x 84 + else begin 85 + if i > 0 then fprintf ppf ",@\n"; 86 + fprintf ppf "/*%3d:*/ %d" i x 87 + end 88 + ) li 84 89 85 90 let _ = 86 91 printf "/* This file is generated by tools/gen_sizeclasses.ml */\n"; ··· 88 93 printf "#define POOL_HEADER_WSIZE %d\n" header_size; 89 94 printf "#define SIZECLASS_MAX %d\n" max_slot; 90 95 printf "#define NUM_SIZECLASSES %d\n" (List.length sizes); 91 - printf "static const unsigned int \ 92 - wsize_sizeclass[NUM_SIZECLASSES] =@[<2>{ %a };@]\n" print_list sizes; 93 - printf "static const unsigned char \ 94 - wastage_sizeclass[NUM_SIZECLASSES] =@[<2>{ %a };@]\n" print_list wastage; 95 - printf "static const unsigned char \ 96 - sizeclass_wsize[SIZECLASS_MAX + 1] =@[<2>{ %a };@]\n" 96 + printf {| 97 + /* The largest size for this size class. 98 + (A gap is left after smaller objects) */ 99 + static const unsigned int wsize_sizeclass[NUM_SIZECLASSES] =@[<2>{ %a };@] 100 + |} 101 + print_list sizes; 102 + printf {| 103 + /* The number of padding words to use, at the beginning of a pool 104 + of this sizeclass, to reach exactly POOL_WSIZE words. */ 105 + static const unsigned char wastage_sizeclass[NUM_SIZECLASSES] =@[<2>{ %a };@] 106 + |} 107 + print_list wastage; 108 + printf {| 109 + /* Map from (positive) object sizes to size classes. */ 110 + static const unsigned char sizeclass_wsize[SIZECLASS_MAX + 1] =@[<2>{ %a };@] 111 + |} 97 112 print_list (255 :: size_slots 1);