New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JavaScript runtime] Implementation of ArrayPredictionContext.prototype.equals is incorrect #2902
Comments
FYI, on my PC, the source code that took 10 seconds to parse was improved to less than 1 second after making this change. |
Sounds promising, I’ll look into this next week
… Le 8 sept. 2020 à 04:10, Yosuke Ota ***@***.***> a écrit :
FYI, on my PC, the source code that took 10 seconds to parse was improved to less than 1 second after making this change.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#2902 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAZNQJCCZ2LVTIM2MLQM64DSEWHBNANCNFSM4Q7GVF2Q>.
|
Thanks for your comment! I'm looking forward to the results you look into this. As additional information, I think that the cache existence judgment failed, the cache was not used, and it was always recalculated, but this change made it use the cache, so it was faster. |
parrt
added a commit
that referenced
this issue
Sep 15, 2020
ericvergnaud
added a commit
that referenced
this issue
Dec 6, 2020
…-incorrect-fix rollback partially incorrect fix for #2902
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I checked that the JavaScript runtime is very slow compared to the Java runtime.
And I noticed that
ArrayPredictionContext.prototype.equals
rarely returnstrue
.Looking at the Java and JavaScript implementations, the Java implementation is comparing the array elements correctly, while the JavaScript implementation is comparing the array instances.
antlr4/runtime/JavaScript/src/antlr4/PredictionContext.js
Lines 252 to 253 in a4c66dc
antlr4/runtime/Java/src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java
Lines 76 to 78 in be881fa
I think perhaps JS needs to be modified as follows:
We can also use
equalArrays
inUtils.js
, but we also need to changeequalArrays
inUtils.js
becauseequalArrays
inUtils.js
doesn't allow arrays of primitives.The text was updated successfully, but these errors were encountered: