commit f794b978bf1f6d8a96e2be3697df984666ec44f5
Author: Haoxiang Fei <feihaoxiang@idea.edu.cn>
Date:
perf: read 16-bit trie entries in one load and cast enum ordinals
On wasm, wasm-gc and JS, General_Category was 3-8 times as slow as on
native. Two causes, both in generated code:
- write_value_trie stored 16-bit mid entries (and wide leaf values) as two
bytes, so each took two bounds-checked loads. Two entries are now packed
per Int in a ReadOnlyArray[Int], the same data size; one load and a
shift. ReadOnlyArray[UInt16] would need no shift, but moonc builds it on
wasm-gc with one array.set per element.
- The ordinal-to-enum converters were identity matches, which moonc
compiles to a br_table on wasm and wasm-gc and a switch on JS; only clang
folds them away. They are now "%identity", as a constructor without
arguments is its ordinal on every backend. write_enum loses its fallback
and the generators check that every ordinal names a constructor.
All value tries are regenerated, including the casefold tables.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>Changes
- M: tools/emitter/pkg.generated.mbti
- M: bidi/bidi_class.mbt
- M: bidi/internal/bidi/bracket.mbt
- M: casefold/case_folding_data.mbt
- M: casefold/nfkc_casefold_data.mbt
- M: idna/internal/idna/mapping.mbt
- M: segmentation/grapheme_break_property.mbt
- M: segmentation/sentence_break_property.mbt
- M: segmentation/word_break_property.mbt
- M: tools/bidi_data/bidi_data.mbt
- M: tools/bidi_data/bidi_data_wbtest.mbt
- M: tools/emitter/emitter.mbt
- M: tools/emitter/emitter_wbtest.mbt
- M: tools/emitter/enum.mbt
- M: tools/emitter/value_trie.mbt
- M: tools/idna_data/idna_data.mbt
- M: tools/idna_data/idna_data_wbtest.mbt
- M: tools/segmentation_data/segmentation_data_wbtest.mbt
- M: tools/ucd/enumerated_property.mbt
- M: tools/ucd/general_category.mbt
- M: tools/ucd/joining_group.mbt
- M: tools/ucd/line_break.mbt
- M: tools/ucd/ucd_wbtest.mbt
- M: ucd/east_asian_width.mbt
- M: ucd/east_asian_width/east_asian_width.mbt
- M: ucd/general_category.mbt
- M: ucd/general_category/general_category.mbt
- M: ucd/hangul_syllable_type.mbt
- M: ucd/hangul_syllable_type/hangul_syllable_type.mbt
- M: ucd/joining_group.mbt
- M: ucd/joining_group/joining_group.mbt
- M: ucd/joining_type.mbt
- M: ucd/joining_type/joining_type.mbt
- M: ucd/line_break.mbt
- M: ucd/line_break/line_break.mbt