You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Underlined entries are the smallest (not counting C++, which beats them all). For antlr4ng, the times are split into lexing and parsing. Note the high lexer execution times, caused by the large number of predicates (126) + lexer actions (40) in the MySQL lexer.
155
155
@@ -205,6 +205,39 @@ Note: Some of the corpus sizes differ due to the restructuring of the test. Howe
205
205
206
206
## Release Notes
207
207
208
+
### 3.0.0
209
+
210
+
This release completes the conversion of the Java (and JavaScript) ANTRL4 runtime to TypeScript. It's a significant improvement over the existing TS (and JS) runtimes, as it includes now all relevant parts from the Java runtime and has been optimized for performance. It's now twice as fast for cold runs and 20% faster with a warm parser/lexer. See also the benchmark section below.
211
+
212
+
This makes it the fastest TypeScript (and JS) runtime currently available. The ANTLR4 JavaScript runtime still is slightly faster in short time tests (e.g. 228ms vs 223ms for the query collection test), where system load and other factors have however much more impact compared to tests that run around 10 seconds.
213
+
214
+
So, what has changed in this new major release? In detail:
215
+
216
+
- Everything that makes sense in the TypeScript environment has been converted (for example `ListTokenSource`, `RuntimeMetaData` and parse tree pattern matching, to name a few). That excludes things like the code point char streams, which directly deal with file and (Java) stream input - aspects that don't matter in TypeScript. Consequently the class `CharStreams` has been removed. Use `CharStream.fromString` to feed your lexer.
217
+
- Neither `BailErrorStrategy` nor `ParserRuleContext` track the original exception in error cases anymore. Instead it is wrapped in the exception thrown (for bailing out) or passed to the error listeners.
218
+
- The runtime has been profiled both with VS Code and Node.js directly, to identify bottlenecks. This showed excessive object creation and release, because of the way DFA generation is implemented. That led to big object initialization and garbage collection penalties. This has been improved and now most time is spent in generated code (which could be improved later). Several measures have been taken to improve speed:
219
+
- Method and constructor overloading in hot paths can be a performance killer, because of the frequent parameter checks. To counter that, class factories and individual method names have been introduced (e.g. `getTextFromContext` and `getTextFromRange` instead of a single `getText` method).
220
+
- Pure data holder classes have been converted to interfaces, which appear at runtime as plain objects and safe some of the initialization times.
221
+
- Some intermediate objects (like temporary `Interval` and `ATNState` instances) have been removed.
222
+
- Bitsets now use typed arrays instead of array of numbers.
223
+
- The hash implementation (MurmurHash) has been stripped down to the minimum required code to keep this hot path fast as well.
224
+
- Hash codes are now cached whereever possible.
225
+
- The `instanceof` operator is relatively expensive, so it was replaced with checks using a member discriminator in hot paths, where possible (e.g. transition and ATN state types).
226
+
-`Switch` statements in hot paths have been replaced by factory arrays that reduce determination what to create to a simple array value lookup.
227
+
- A number of public members have been renamed, to match common TypeScript code style (e.g. `INSTANCE` to `instance` or `_parseListener` to `parseListener`).
228
+
- Methods that can return null/undefined now explicitly say so (Java has no explicit type to mark possible null results and the ANTLR4 Java runtime is a bit lax in this regard). This requires now that users of the new runtime have to do more checks for undefined results.
229
+
- The lexer can now be configured at runtime to control what is cached in the DFA (in the Java runtime it's always only ASCII chars) and which code points are acceptable (in the Java runtime always the entire Unicode range).
230
+
- Separated enumeration values (e.g. ATN state types, transition types) have been moved back as public static constants to their respective classes.
231
+
- Accessibility of class members has been adjusted (strict public, protected and private visibility).
232
+
- Duplicated public members (as property and as getter/setter method) have been resolved in favor of the property variant.
233
+
- Most use of `null` has been converted to `undefined` (except in places where null marks special conditions) for a more natural handling in TypeScript.
234
+
- The JS doc in code has been reworked and all unsupported markup been removed.
235
+
- A lot of other code cleanup happened.
236
+
- Test improvements:
237
+
- Runtime tests have been ported to TypeScript, so they can be debugged and provide a much quicker turnaround.
238
+
- Benchmarks now take seperated measurements for lexer and parser runs, which much better shows how high the impact of predicates and actions in the lexer is (e.g. 2/3 of the time in the large inserts benchmark is used for lexing input).
239
+
- The release build is no longer minified (and hence larger than before) to avoid trouble with other build tools like terser or webpack.
240
+
208
241
### 2.0.11
209
242
210
243
- Fixed bug #30 ReferenceError: Super constructor may only be called once
0 commit comments