SourceText collection & toString() for fns and methods#4038
SourceText collection & toString() for fns and methods#4038jedel1043 merged 18 commits intoboa-dev:mainfrom
SourceText collection & toString() for fns and methods#4038Conversation
TODO: find out is `derive(arbitrary::Arbitrary)` in `core\ast\src\source.rs::Script` correct?
TODO: also find out correctness of `derive(arbitrary::Arbitrary)` for `LinearSpan`, `LinearPosition`
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4038 +/- ##
==========================================
+ Coverage 47.24% 54.55% +7.31%
==========================================
Files 476 490 +14
Lines 46892 49290 +2398
==========================================
+ Hits 22154 26892 +4738
+ Misses 24738 22398 -2340 ☔ View full report in Codecov by Sentry. |
|
I have not done an in depth review yet, just an initial question. As far as I see, the positions you used for the function start and end ( I think that would not work in cases where other stuff is in the same line, e.g.: let a = 1; function f() {return a + 1}; let b = 3;In this case |
|
@raskad in details: here is tests
|
|
also you can read the issue where it was accepted to collect the source code(it should slow down parse stage performance) |
raskad
left a comment
There was a problem hiding this comment.
Sorry for letting you wait so long for the full review. First of all thank you for the great contribution! Really nice work!
I added some specific comments, but I have one more general one. I would be in favor of Removing all the Options for the various SourceText fields. In principle, everytime we parse, compile and execute code, we must have the source text and a span. I did a quick check an I'm 99% sure the Options can be removed in all places.
In addition to the Script struct, the Module struct would also need the source text.
In some cases (e.g. the "dummy" use of the Bytecompiler for syntetic modules) there is really no source text, but there it is also never used. In those cases we can just use the default (empty vec).
Regarding Arbitrary, I think it should be a manual implementation that is just an empty source text. You can check here for en example of a manual impl:
boa/core/ast/src/expression/literal/mod.rs
Lines 121 to 137 in 517ad50
|
If remove |
I was mostly concerned with the code in the bytecompiler being a bit easier to work with. Like you mentioned, with the |
|
Seems like all done. We don't always have boa/core/engine/src/spanned_source_text.rs Lines 44 to 48 in cbb2d79 In all other places Option is removed.
|
|
Looks really nice! Thank you for the work! Could you do a rebase, best would be after #4117 is merged, because the CI is broken without that. One very minor nitpick: I would like to rename |
39e71a0 to
782a218
Compare
raskad
left a comment
There was a problem hiding this comment.
Thank you for the contribution. Great stuff. I'd be happy to merge this.
|
How much progress is this towards errors with backtraces? Haven't looked at it yet, I'm just curious if this would be another step forward or if we would have to essentially rewrite everything when we have nicer errors |
Sorry, I actually don't sure what is needed for backtraced errors. |
|
If we just need to increasingly add |
This Pull Request closes #3780
In current approach all
SourceTextcollected (because mostly a script consist of function codes and classes) andLinearSpanused to retrieve it when needed (to be fairtoString()not often called);Gc::<SourceText>used for storage and therefore it can be deallocated only when we have access to no function from a source anymore.It actually solve some tests from
test262, but there is implementation for checkingtoString()correctness that take any[native code]as correct, without regard to whether it should accept in concrete case or not (assertToStringOrNativeFunction).Also I don't sure about
derive(arbitrary::Arbitrary)forcore\ast\src\source.rs::Script&LinearSpan, just derive is ok here?