react-nitro-hermes 0.0.1-alpha.8 → 0.0.1-alpha.9
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/hermes/CMakeLists.txt +874 -0
- package/hermes/android/HostObjectJniTest.cpp +178 -0
- package/hermes/android/build-logic/build.gradle.kts +31 -0
- package/hermes/android/build-logic/settings.gradle.kts +17 -0
- package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/helpers/internal/SerializeHermesCompilerPackageJson.kt +33 -0
- package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/plugins/internal/TestUtilsPlugin.kt +80 -0
- package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/tasks/internal/CustomExecTask.kt +46 -0
- package/hermes/android/build-logic/src/main/kotlin/publish.gradle.kts +82 -0
- package/hermes/android/build.gradle.kts +332 -0
- package/hermes/android/cppruntime/build.gradle +72 -0
- package/hermes/android/cppruntime/src/main/AndroidManifest.xml +2 -0
- package/hermes/android/cppruntime/src/main/cpp/CMakeLists.txt +8 -0
- package/hermes/android/cppruntime/src/main/cpp/stub.cpp +12 -0
- package/hermes/android/cross-compile/swift-libicu.patch +13 -0
- package/hermes/android/cross-compile/toolchain-android-arm-api13-gnustl.cmake +13 -0
- package/hermes/android/cross-compile/toolchain-android-arm-api15-gnustl.cmake +14 -0
- package/hermes/android/gradle/libs.versions.toml +30 -0
- package/hermes/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/hermes/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/hermes/android/gradle.properties +3 -0
- package/hermes/android/gradlew +248 -0
- package/hermes/android/gradlew.bat +93 -0
- package/hermes/android/intltest/build.gradle +147 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/CMakeLists.txt +45 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.cpp +68 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.h +44 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.java +45 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogueTestData.java +32 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesInstrumentationTest.java +150 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesIntlAndroidTest.java +147 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesIntlTest262.java +470 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesRuntimeFactory.cpp +73 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.cpp +90 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.h +62 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.java +155 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/MappedFileBuffer.cpp +48 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/MappedFileBuffer.h +36 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/OnLoad.cpp +13 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/OnLoadEpilogue.cpp +13 -0
- package/hermes/android/intltest/src/main/AndroidManifest.xml +2 -0
- package/hermes/android/ios-artifacts/build.gradle.kts +65 -0
- package/hermes/android/settings.gradle.kts +27 -0
- package/hermes/cmake/modules/Hermes.cmake +481 -0
- package/hermes/cmake/modules/Lit.cmake +96 -0
- package/hermes/doc/Branches.md +38 -0
- package/hermes/doc/BuildingAndRunning.md +121 -0
- package/hermes/doc/CodingStandards.md +112 -0
- package/hermes/doc/CrossCompilation.md +79 -0
- package/hermes/doc/Design.md +217 -0
- package/hermes/doc/Emscripten.md +156 -0
- package/hermes/doc/Features.md +143 -0
- package/hermes/doc/GCSafeCoding.md +563 -0
- package/hermes/doc/GenGC.md +300 -0
- package/hermes/doc/Hades.md +344 -0
- package/hermes/doc/HighLevelOptimizations.md +37 -0
- package/hermes/doc/IR.md +1306 -0
- package/hermes/doc/IntlAPIs.md +196 -0
- package/hermes/doc/JIT.md +999 -0
- package/hermes/doc/LazyEvalCompilation.md +84 -0
- package/hermes/doc/MemoryProfilers.md +316 -0
- package/hermes/doc/Modules.md +144 -0
- package/hermes/doc/Optimizer.md +83 -0
- package/hermes/doc/PerfProfiling.md +29 -0
- package/hermes/doc/ProhibitInvoke.md +329 -0
- package/hermes/doc/ReactNative.md +40 -0
- package/hermes/doc/ReactNativeIntegration.md +94 -0
- package/hermes/doc/RegExp.md +24 -0
- package/hermes/doc/SpecIncompat.md +85 -0
- package/hermes/doc/Strings.md +140 -0
- package/hermes/doc/TypedLanguage.md +432 -0
- package/hermes/doc/VM.md +174 -0
- package/hermes/doc/blog/2024-11-09-octane-benchmark-jit-progress.md +17 -0
- package/hermes/doc/blog/2024-12-19-static-hermes-update-dec-2024.md +47 -0
- package/hermes/doc/blog/2024-12-23-compiling-javascript-to-wasm.md +267 -0
- package/hermes/doc/blog/2025-06-09-jsi-runtime-data-apis.md +23 -0
- package/hermes/doc/blog/2025-07-15-static-h-performance-june-2025.md +18 -0
- package/hermes/doc/blog/2025-11-02-hermes-compilation-runtime-modes.md +23 -0
- package/hermes/doc/blog/2025-11-06-hermes-memory-modes.md +35 -0
- package/hermes/doc/blog/2025-11-24-json-parsing-performance.md +17 -0
- package/hermes/doc/blog/2025-12-02-iserialization.md +11 -0
- package/hermes/doc/blog/2025-12-12-new-way-to-contribute.md +68 -0
- package/hermes/doc/blog/2026-06-05-new-hermes-stable-release.md +51 -0
- package/hermes/doc/blog/README.md +25 -0
- package/hermes/doc/blog/images/2024-11-09-octane-pi3.jpeg +0 -0
- package/hermes/doc/blog/images/2024-11-09-octane-pi5.jpeg +0 -0
- package/hermes/doc/blog/images/2025-07-15-perf-hv32-interpreter.jpeg +0 -0
- package/hermes/doc/blog/images/2025-07-15-perf-hv32-jit.jpeg +0 -0
- package/hermes/doc/icu_license.txt +420 -0
- package/hermes/doc/img/heap_snapshot_retainers.png +0 -0
- package/hermes/doc/img/logo.svg +1 -0
- package/hermes/doc/img/object_captured_by_environment.png +0 -0
- package/hermes/doc/img/root_categories.png +0 -0
- package/hermes/doc/plans/ir-type/flow-type-system.md +324 -0
- package/hermes/doc/plans/ir-type/ir-type-system-v2-design.md +652 -0
- package/hermes/doc/plans/ir-type/ir-type-system.md +220 -0
- package/hermes/doc/plans/ir-type/ir-type-v2-implementation.md +1187 -0
- package/hermes/doc/plans/ir-type/memory.md +48 -0
- package/hermes/doc/plans/ir-type/phase1-steps.md +512 -0
- package/hermes/doc/plans/ir-type/progress.md +239 -0
- package/hermes/doc/plans/ir-type/typeinference-primitive-fastpath-design.md +203 -0
- package/hermes/doc/plans/ir-type/typeinference-primitive-fastpath-results.md +71 -0
- package/hermes/doc/superpowers/plans/2026-07-28-worker-arraybuffer-input.md +597 -0
- package/hermes/doc/superpowers/plans/2026-08-18-jitemitter-split.md +1149 -0
- package/hermes/doc/superpowers/plans/2026-08-20-jit-type-asserts.md +969 -0
- package/hermes/doc/superpowers/plans/2026-08-23-jit-shared-compiler-driver.md +478 -0
- package/hermes/doc/superpowers/plans/2026-08-23-x86-64-jit-skeleton.md +797 -0
- package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-arith.md +444 -0
- package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-calls.md +261 -0
- package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-props.md +240 -0
- package/hermes/doc/superpowers/plans/2026-10-26-regexp-bytecode-sharing.md +2197 -0
- package/hermes/doc/superpowers/plans/2026-10-28-regexp-start-filter-and-exec-fast-paths.md +3981 -0
- package/hermes/doc/superpowers/specs/2026-07-28-worker-arraybuffer-input-design.md +206 -0
- package/hermes/doc/superpowers/specs/2026-08-18-jitemitter-split-design.md +530 -0
- package/hermes/doc/superpowers/specs/2026-08-20-jit-type-asserts-design.md +360 -0
- package/hermes/doc/superpowers/specs/2026-08-23-x86-64-jit-design.md +246 -0
- package/hermes/doc/superpowers/specs/2026-08-26-icu-free-normalize-design.md +355 -0
- package/hermes/doc/superpowers/specs/2026-08-27-icu-free-convert-to-case-design.md +305 -0
- package/hermes/doc/superpowers/specs/2026-08-27-icu-free-locale-compare-design.md +429 -0
- package/hermes/doc/superpowers/specs/2026-08-29-icu-free-date-format-design.md +297 -0
- package/hermes/doc/superpowers/specs/2026-10-26-regexp-bytecode-sharing-design.md +605 -0
- package/hermes/doc/superpowers/specs/2026-10-28-regexp-start-filter-and-exec-fast-paths-design.md +551 -0
- package/hermes/doc/typescript-stripping.md +90 -0
- package/hermes/external/CMakeLists.txt +20 -0
- package/hermes/utils/IntlGen/IntlGen.java +531 -0
- package/hermes/utils/bench_with_stats.py +827 -0
- package/hermes/utils/build-apple-framework.sh +323 -0
- package/hermes/utils/chrome_snapshot_parser.py +210 -0
- package/hermes/utils/cmake-dev-build.sh +18 -0
- package/hermes/utils/commons.sh +55 -0
- package/hermes/utils/dump-cpp-funcs.sh +3 -0
- package/hermes/utils/es5objects.js +198 -0
- package/hermes/utils/format.sh +145 -0
- package/hermes/utils/gen-promise-internal-bc.sh +66 -0
- package/hermes/utils/genUnicodeTable.py +2503 -0
- package/hermes/utils/hermes-lit/CMakeLists.txt +22 -0
- package/hermes/utils/hermes-lit/hermes-lit.in +15 -0
- package/hermes/utils/jit/README.md +134 -0
- package/hermes/utils/jit/jit-diff.sh +160 -0
- package/hermes/utils/jit/jit-dump.sh +193 -0
- package/hermes/utils/lit-expect-gen/generate.py +217 -0
- package/hermes/utils/promise/index.js +15 -0
- package/hermes/utils/promise/package.json +13 -0
- package/hermes/utils/promise/rollup.config.js +19 -0
- package/hermes/utils/promise/yarn.lock +247 -0
- package/hermes/utils/scripts/hermes/consts.js +26 -0
- package/hermes/utils/scripts/hermes/create-tarball.js +75 -0
- package/hermes/utils/scripts/hermes/get-hermes-version.js +57 -0
- package/hermes/utils/scripts/hermes/hermes-utils.js +122 -0
- package/hermes/utils/scripts/hermes/package.json +6 -0
- package/hermes/utils/scripts/hermes/prepare-artifacts.js +113 -0
- package/hermes/utils/scripts/hermes/publish-artifacts.js +109 -0
- package/hermes/utils/scripts/hermes/publish-npm.js +96 -0
- package/hermes/utils/scripts/hermes/scm-utils.js +41 -0
- package/hermes/utils/scripts/hermes/set-artifacts-version.js +64 -0
- package/hermes/utils/scripts/hermes/version-utils.js +98 -0
- package/hermes/utils/scripts/hermes/yarn.lock +240 -0
- package/hermes/utils/summarize_sizes.py +184 -0
- package/hermes/utils/symbolicate-nativecall-stats.py +112 -0
- package/hermes/utils/test_runner.py +13 -0
- package/hermes/utils/testsuite/README.facebook +3 -0
- package/hermes/utils/testsuite/README.md +69 -0
- package/hermes/utils/testsuite/cli.py +547 -0
- package/hermes/utils/testsuite/es_ast.py +337 -0
- package/hermes/utils/testsuite/external/LICENSE +28 -0
- package/hermes/utils/testsuite/external/README.facebook +8 -0
- package/hermes/utils/testsuite/external/__init__.py +0 -0
- package/hermes/utils/testsuite/external/_monkeyYaml.py +164 -0
- package/hermes/utils/testsuite/external/parse_test262.py +141 -0
- package/hermes/utils/testsuite/hermes.py +522 -0
- package/hermes/utils/testsuite/preprocess.py +365 -0
- package/hermes/utils/testsuite/progress.py +377 -0
- package/hermes/utils/testsuite/skiplist.json +4356 -0
- package/hermes/utils/testsuite/skiplist.py +270 -0
- package/hermes/utils/testsuite/test_run_defs.py +435 -0
- package/hermes/utils/testsuite/typing_defs.py +52 -0
- package/hermes/utils/testsuite/utils.py +214 -0
- package/hermes/utils/tidy.sh +22 -0
- package/hermes/utils/update-fbcode-hermes.sh +53 -0
- package/hermes/utils/updateErrorTest.py +193 -0
- package/hermes/utils/wasm-compile.sh +65 -0
- package/package.json +1 -1
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# ICU-free `dateFormat`
|
|
2
|
+
|
|
3
|
+
Date: 2026-08-29
|
|
4
|
+
Status: approved, ready for implementation planning
|
|
5
|
+
|
|
6
|
+
Sub-project 4 of 4 in the ICU4C removal, and the last one. See
|
|
7
|
+
`doc/superpowers/specs/2026-08-26-icu-free-normalize-design.md` for the overall
|
|
8
|
+
decomposition and the shared conventions this follows.
|
|
9
|
+
|
|
10
|
+
## Context
|
|
11
|
+
|
|
12
|
+
`dateFormat` is the final function Hermes needs ICU for. It backs
|
|
13
|
+
`Date.prototype.toLocaleString`, `toLocaleDateString` and `toLocaleTimeString`
|
|
14
|
+
through three one-line wrappers at `lib/VM/JSLib/DateUtil.cpp:561-571`, whose
|
|
15
|
+
only caller is `datePrototypeToLocaleStringHelper` at
|
|
16
|
+
`lib/VM/JSLib/Date.cpp:588`.
|
|
17
|
+
|
|
18
|
+
When `HERMES_ENABLE_INTL` is on, that helper dispatches to `Intl.DateTimeFormat`
|
|
19
|
+
and `dateFormat` is never reached at all.
|
|
20
|
+
|
|
21
|
+
### This sub-project is not shaped like the other three
|
|
22
|
+
|
|
23
|
+
Normalize, casing and collation were each a Unicode algorithm with a normative
|
|
24
|
+
specification, a UCD data file, and a conformance suite that could prove the
|
|
25
|
+
implementation correct. `dateFormat` has none of those.
|
|
26
|
+
|
|
27
|
+
`PlatformUnicodeICU.cpp:81` calls `udat_open` at `UDAT_MEDIUM` against
|
|
28
|
+
`uloc_getDefault()`. Its output *is* CLDR locale data — month names, field
|
|
29
|
+
order, 12- versus 24-hour clock, the glue between date and time. There is no
|
|
30
|
+
algorithm to reimplement. Every option therefore gives something up, and the
|
|
31
|
+
design question is which.
|
|
32
|
+
|
|
33
|
+
ECMA-262 makes this easy to answer in principle: without ECMA-402 the result of
|
|
34
|
+
`toLocaleString` is implementation-defined, "a convenient, human-readable form".
|
|
35
|
+
|
|
36
|
+
### What the code does today, measured
|
|
37
|
+
|
|
38
|
+
Run against the current binary on this host, `TZ=EST+5`, `new Date(112)`:
|
|
39
|
+
|
|
40
|
+
| Locale | `toLocaleString()` |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| `en_US` | `Dec 31, 1969, 7:00:00 PM` |
|
|
43
|
+
| `tr_TR` | `31 Ara 1969 19:00:00` |
|
|
44
|
+
|
|
45
|
+
Note the Turkish output differs in month name, field order, clock, and the
|
|
46
|
+
date/time separator.
|
|
47
|
+
|
|
48
|
+
**ICU produced that Turkish output on a machine where `tr_TR` is not an
|
|
49
|
+
installed system locale.** This host has 38 locales, all English variants.
|
|
50
|
+
`strftime` under `LC_ALL=tr_TR` here prints `Dec`. ICU does not consult the
|
|
51
|
+
system locale archive; it parses the environment string against its own bundled
|
|
52
|
+
CLDR data, exactly as the convertToCase spec found for casing.
|
|
53
|
+
|
|
54
|
+
### Why not libc
|
|
55
|
+
|
|
56
|
+
`strftime_l` was the approach the normalize spec pencilled in. It is rejected:
|
|
57
|
+
|
|
58
|
+
- **It cannot reproduce the current output.** Turkish month names require the
|
|
59
|
+
locale to be installed. On this development host it is not, so the checked-in
|
|
60
|
+
Turkish expectations would fail immediately.
|
|
61
|
+
- **It does not match ICU even when the locale is present.** For `en_US` the
|
|
62
|
+
locale's own `%x` gives `12/31/1969` against ICU's `Dec 31, 1969`, and `%X`
|
|
63
|
+
gives `07:00:00 PM` against `7:00:00 PM`.
|
|
64
|
+
- **It is host-dependent.** Results vary with the installed locale archive and
|
|
65
|
+
degrade on musl and in minimal containers — the same objection this project
|
|
66
|
+
accepted when it rejected `strcoll_l` for collation.
|
|
67
|
+
|
|
68
|
+
A hybrid — fixed field order with locale-supplied month names — was also
|
|
69
|
+
rejected. It matches `en_US` exactly and yields `Ara` where Turkish is
|
|
70
|
+
installed, but produces `Ara 31, 1969` on a 12-hour clock: neither the ICU
|
|
71
|
+
output nor idiomatic Turkish, and still host-dependent.
|
|
72
|
+
|
|
73
|
+
### Existing coverage is thinner than it looks
|
|
74
|
+
|
|
75
|
+
`test/hermes/date-locale.js` is the only test that pins any output. It carries
|
|
76
|
+
`UNSUPPORTED: ubsan || intl || unicode_lite`, so it does not run in the
|
|
77
|
+
default asan-ubsan build. `utils/testsuite/skiplist.json` has no
|
|
78
|
+
`Date/prototype/toLocale` entries, and no C++ unit test touches this
|
|
79
|
+
function. Nothing in `doc/` documents the non-Intl path or the LITE stub.
|
|
80
|
+
|
|
81
|
+
So the entire user-visible contract is one lit test that the default build
|
|
82
|
+
skips.
|
|
83
|
+
|
|
84
|
+
## Scope
|
|
85
|
+
|
|
86
|
+
Replace `dateFormat` with a fixed, locale-independent English formatter on every
|
|
87
|
+
backend that lacks a platform implementation, and remove ICU from the
|
|
88
|
+
`platform_unicode` layer.
|
|
89
|
+
|
|
90
|
+
### Non-goals
|
|
91
|
+
|
|
92
|
+
- Changing the Apple (CoreFoundation) or Android (Java) backends.
|
|
93
|
+
- Implementing Intl or ECMA-402.
|
|
94
|
+
- Honoring the `locales` argument, or any host locale.
|
|
95
|
+
- Shipping CLDR data.
|
|
96
|
+
- Deleting the LITE backend. It is expected to go away now that the Hermes
|
|
97
|
+
backend exists, but that is its own change.
|
|
98
|
+
- Removing the ICU-backed Intl implementation. See below.
|
|
99
|
+
|
|
100
|
+
### Deliberate behavior changes
|
|
101
|
+
|
|
102
|
+
- **Output stops depending on the host locale on Linux and Windows.** A user
|
|
103
|
+
under `LANG=sv_SE` or `LC_ALL=tr_TR` gets English. This is the same trade
|
|
104
|
+
already accepted for root collation in sub-project 3.
|
|
105
|
+
- **LITE and Emscripten gain a working implementation.** Both return the literal
|
|
106
|
+
string `"dateFormat not implemented"` today
|
|
107
|
+
(`PlatformUnicodeLite.cpp:31`, `PlatformUnicodeEmscripten.cpp:43`), so this is
|
|
108
|
+
a substantial improvement rather than a regression.
|
|
109
|
+
- **The ICU `platform_unicode` backend is deleted.** Building with
|
|
110
|
+
`-c hermes.platform_unicode=ICU` stops being a valid configuration.
|
|
111
|
+
|
|
112
|
+
## Approach
|
|
113
|
+
|
|
114
|
+
A fixed English format, chosen to match what ICU emits for `en_US` today so the
|
|
115
|
+
existing expectations stay byte-identical:
|
|
116
|
+
|
|
117
|
+
| Call | Output |
|
|
118
|
+
| --- | --- |
|
|
119
|
+
| `toLocaleDateString()` | `Dec 31, 1969` |
|
|
120
|
+
| `toLocaleTimeString()` | `7:00:00 PM` |
|
|
121
|
+
| `toLocaleString()` | `Dec 31, 1969, 7:00:00 PM` |
|
|
122
|
+
|
|
123
|
+
Precisely: three-letter English month abbreviation; day of month with no
|
|
124
|
+
leading zero; four-digit year, widening for years outside 1000-9999; 12-hour
|
|
125
|
+
clock with no leading zero on the hour; two-digit minutes and seconds; a single
|
|
126
|
+
ASCII space before `AM`/`PM`; and `, ` joining date and time.
|
|
127
|
+
|
|
128
|
+
`Invalid Date` is produced by the caller at `Date.cpp:606-634` for non-finite
|
|
129
|
+
timestamps and never reaches the backend.
|
|
130
|
+
|
|
131
|
+
## Architecture
|
|
132
|
+
|
|
133
|
+
### Shared layer
|
|
134
|
+
|
|
135
|
+
`include/hermes/Platform/Unicode/PlatformDateFormat.h`:
|
|
136
|
+
|
|
137
|
+
```cpp
|
|
138
|
+
namespace hermes {
|
|
139
|
+
namespace platform_unicode {
|
|
140
|
+
|
|
141
|
+
/// Format \p unixtimeMs into \p buf in a fixed, locale-independent English
|
|
142
|
+
/// form, including the date when \p formatDate and the time when
|
|
143
|
+
/// \p formatTime. The timestamp is interpreted in the host's local timezone.
|
|
144
|
+
///
|
|
145
|
+
/// This is the fallback for platforms with no locale-aware date formatter of
|
|
146
|
+
/// their own. It deliberately ignores the host locale, so its output is
|
|
147
|
+
/// identical on every machine and in every container. Platforms that have a
|
|
148
|
+
/// real formatter -- Apple through CoreFoundation, Android through
|
|
149
|
+
/// java.text.DateFormat -- do not call it.
|
|
150
|
+
void formatDateTimeFixed(
|
|
151
|
+
double unixtimeMs,
|
|
152
|
+
bool formatDate,
|
|
153
|
+
bool formatTime,
|
|
154
|
+
llvh::SmallVectorImpl<char16_t> &buf);
|
|
155
|
+
|
|
156
|
+
} // namespace platform_unicode
|
|
157
|
+
} // namespace hermes
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Implementation in `lib/Platform/Unicode/PlatformDateFormat.cpp`, compiled for
|
|
161
|
+
the same backends as the other self-contained sources.
|
|
162
|
+
|
|
163
|
+
### Date arithmetic is self-contained
|
|
164
|
+
|
|
165
|
+
`include/hermes/VM/JSLib/DateUtil.h` already has every ECMA-262 helper this
|
|
166
|
+
needs -- `yearFromTime`, `monthFromTime`, `dateFromTime`, `hourFromTime`,
|
|
167
|
+
`weekDay`, `localTime`, `equivalentTime`. It is deliberately **not** used:
|
|
168
|
+
`lib/Platform` depending on `lib/VM` is a layering inversion, and its only
|
|
169
|
+
precedent is `lib/Platform/Intl/impl_icu/LocaleBCP47Object.h`, which is
|
|
170
|
+
deprecated code.
|
|
171
|
+
|
|
172
|
+
The formatter therefore does its own civil-from-days conversion. The local UTC
|
|
173
|
+
offset comes from `localtime_r`. Because `time_t` cannot represent the whole
|
|
174
|
+
±8.64e15 ms JavaScript date range, out-of-range timestamps are mapped to an
|
|
175
|
+
equivalent year with the same weekday and leap-year character before the offset
|
|
176
|
+
is queried, then the real year is substituted back — the technique
|
|
177
|
+
`DateUtil.h:117 equivalentTime` already uses for the same reason.
|
|
178
|
+
|
|
179
|
+
### Backends
|
|
180
|
+
|
|
181
|
+
- `PlatformUnicodeHermes.cpp`, `PlatformUnicodeLite.cpp` and
|
|
182
|
+
`PlatformUnicodeEmscripten.cpp` call `formatDateTimeFixed`.
|
|
183
|
+
- `PlatformUnicodeCF.cpp` and `PlatformUnicodeJava.cpp` are untouched.
|
|
184
|
+
|
|
185
|
+
### ICU comes out of the platform_unicode layer
|
|
186
|
+
|
|
187
|
+
Deleted: `lib/Platform/Unicode/PlatformUnicodeICU.cpp`,
|
|
188
|
+
`include/hermes/Platform/Unicode/PlatformUnicodeICUImpl.h`, the `icu_impl`
|
|
189
|
+
namespace, the `platform_unicode_icu` config in `BUCK`, the `USE_ICU` CMake
|
|
190
|
+
flag, and the `//third-party/icu` dependencies of the `platform_unicode`
|
|
191
|
+
target. Every remaining `TODO(icu-removal)` marker in that layer goes with them.
|
|
192
|
+
|
|
193
|
+
**`lib/Platform/Intl/impl_icu/` is out of scope.** Those four files
|
|
194
|
+
(`Collator.h`, `LocaleConverter.cpp`, `LocaleResolver.cpp`, and
|
|
195
|
+
`PlatformIntlICU.cpp`) are the only other ICU includers in the tree, and they
|
|
196
|
+
are compiled only in Intl builds. That implementation is deprecated and slated
|
|
197
|
+
for deletion on its own schedule. This sub-project must not break it, and must
|
|
198
|
+
not invest in it. Concretely: with Intl disabled — the default everywhere except
|
|
199
|
+
Android — nothing links ICU once this lands; with Intl enabled, ICU remains for
|
|
200
|
+
`Intl.Collator` and friends.
|
|
201
|
+
|
|
202
|
+
## Testing
|
|
203
|
+
|
|
204
|
+
### A lit feature for the unicode backend
|
|
205
|
+
|
|
206
|
+
`test/lit.cfg` gains a feature naming the resolved `platform_unicode` backend,
|
|
207
|
+
generalizing the `unicode_lite` feature that already exists. Today lit can
|
|
208
|
+
distinguish `apple`, `linux`, `windows` and `unicode_lite`, but cannot tell the
|
|
209
|
+
ICU backend from the Hermes backend on Linux — so gating by platform alone would
|
|
210
|
+
silently mis-fire for `-c hermes.platform_unicode=ICU`.
|
|
211
|
+
|
|
212
|
+
Both the ICU and LITE backends are expected to be deleted. The feature should
|
|
213
|
+
therefore be defined so their clauses can be removed alongside them without a
|
|
214
|
+
second rewrite of the tests: the split is between backends with a locale-aware
|
|
215
|
+
platform formatter and backends using the fixed one, and after both deletions
|
|
216
|
+
that reduces to Apple and Android versus everything else.
|
|
217
|
+
|
|
218
|
+
### Tests
|
|
219
|
+
|
|
220
|
+
- **A new lit test for the fixed format.** It runs the same script under
|
|
221
|
+
`LC_ALL=en_US` and `LC_ALL=tr_TR` and asserts **identical English output**
|
|
222
|
+
from
|
|
223
|
+
both. That converts the locale dimension from something ICU's data satisfied
|
|
224
|
+
into an active check that the host locale is ignored, which would catch a
|
|
225
|
+
`strftime_l` reintroduction.
|
|
226
|
+
- **`test/hermes/date-locale.js` is retained for the locale-aware backends**,
|
|
227
|
+
with its expectations unchanged, gated on the new feature.
|
|
228
|
+
- **C++ unit tests** for `formatDateTimeFixed`: the epoch; pre-1970 negative
|
|
229
|
+
timestamps; all twelve month abbreviations; the 12-hour boundaries at midnight
|
|
230
|
+
and noon, where a naive implementation prints `0:00:00 AM` or `12:00:00 PM`
|
|
231
|
+
incorrectly; the extremes of the JavaScript date range, where `time_t`
|
|
232
|
+
overflow
|
|
233
|
+
and the equivalent-year remapping are exercised; and each of the three
|
|
234
|
+
`formatDate`/`formatTime` flag combinations.
|
|
235
|
+
- **The stale `UNSUPPORTED: ubsan` marker is removed.** It is already liftable
|
|
236
|
+
before any change here: the test runs clean against the asan+ubsan binary
|
|
237
|
+
under
|
|
238
|
+
`UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=0`, in both the `en_US` and
|
|
239
|
+
`tr_TR` cases. `sl` history traces the exclusion to `32a1c90aa246`, the 2022
|
|
240
|
+
"Copy Hermes into xplat/static_h" import, so it is inherited upstream baggage
|
|
241
|
+
rather than anything this tree caused. Lifting it gains coverage in the build
|
|
242
|
+
developers actually run.
|
|
243
|
+
- **A `doc/SpecIncompat.md` entry**, recording that `toLocale*String` ignores
|
|
244
|
+
the
|
|
245
|
+
`locales` argument and the host locale and emits a fixed English format. That
|
|
246
|
+
file currently says nothing about `Date`.
|
|
247
|
+
|
|
248
|
+
### Mutation check
|
|
249
|
+
|
|
250
|
+
As with every suite in this stack, the new tests must be shown to fail against a
|
|
251
|
+
broken implementation rather than assumed to. The locale-independence assertion
|
|
252
|
+
in particular should be checked by making the formatter consult the host locale
|
|
253
|
+
and confirming the test catches it.
|
|
254
|
+
|
|
255
|
+
## Diff breakdown
|
|
256
|
+
|
|
257
|
+
1. `PlatformDateFormat.{h,cpp}` and its unit tests. Not wired to any backend, so
|
|
258
|
+
no behavior change.
|
|
259
|
+
2. The lit backend feature, and the test split. Still no behavior change: the
|
|
260
|
+
existing test keeps running against the existing backends.
|
|
261
|
+
3. Wire the Hermes, LITE and Emscripten backends to `formatDateTimeFixed`. This
|
|
262
|
+
is the behavior change; `lit` and `testsuite_tests` are the gate. Lift the
|
|
263
|
+
`ubsan` marker here, and add the `SpecIncompat.md` entry.
|
|
264
|
+
4. Delete the ICU backend and the `platform_unicode` layer's ICU dependencies.
|
|
265
|
+
|
|
266
|
+
## Risks
|
|
267
|
+
|
|
268
|
+
- **The Apple and Android paths cannot be exercised from this tree.** It is
|
|
269
|
+
Linux-only on EdenFS and builds with buck2. The Apple half of the test split
|
|
270
|
+
is
|
|
271
|
+
inherited unchanged and unverified. Mitigation: do not modify those backends
|
|
272
|
+
or
|
|
273
|
+
their expectations at all, so the risk is confined to the gating.
|
|
274
|
+
- **Hand-rolled civil-date conversion is where this will go wrong if it goes
|
|
275
|
+
wrong.** The JavaScript date range is far wider than `time_t`. Mitigation:
|
|
276
|
+
unit
|
|
277
|
+
tests aimed directly at the extremes and at the equivalent-year remapping.
|
|
278
|
+
- **Deleting the ICU backend removes a configuration in active use** — this
|
|
279
|
+
project's own stack has been building `-c hermes.platform_unicode=ICU` as a
|
|
280
|
+
smoke check throughout. Mitigation: it is deleted in its own diff, last, after
|
|
281
|
+
everything else is green.
|
|
282
|
+
- **Losing locale-sensitive dates may surprise someone.** Mitigation: Hermes on
|
|
283
|
+
Linux and Windows is largely a development and shermes surface; Android and
|
|
284
|
+
Apple keep real localization; Intl remains the supported answer. Documented in
|
|
285
|
+
`SpecIncompat.md` rather than only in this spec.
|
|
286
|
+
|
|
287
|
+
## Success criteria
|
|
288
|
+
|
|
289
|
+
- `toLocale{,Date,Time}String` produce the fixed format on the Hermes, LITE and
|
|
290
|
+
Emscripten backends, identically under any `LC_ALL`.
|
|
291
|
+
- The Apple and Android backends are byte-for-byte unchanged.
|
|
292
|
+
- No file under `lib/Platform/Unicode/` or `include/hermes/Platform/Unicode/`
|
|
293
|
+
references ICU, and the `platform_unicode` target has no ICU dependency.
|
|
294
|
+
- `lib/Platform/Intl/impl_icu/` still compiles and behaves as it does today.
|
|
295
|
+
- `buck2 test //xplat/static_h:HermesUnitTests`, `:lit` and `:testsuite_tests`
|
|
296
|
+
all pass, with `date-locale.js` no longer skipped under ubsan.
|
|
297
|
+
- The new tests are shown to fail against a broken implementation.
|