-
Notifications
You must be signed in to change notification settings - Fork 156
Major frontend refactor #313
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
Conversation
|
The initial result is benchmarked below, the memory overhead and minor performance overhead are expected to be the outcome of algorithm and data structure used in this patch:
The performance overhead is expected to be came from multiuple token stream traversal, as seen 3 times at least in lexer, preprocessor, and parser. performance benchmark (stage 0)Before
After
performance benchmark (stage 1)Before
After
|
|
There are still some improvements left to do, e.g.:
|
|
I seem to unable to reply to the latest review suggestion so I'll reply here:
Perhaps? The approach requires reorganization of token kind order, and I don't think it's necessary to just boost performance while debugging (I didn't encoutered significant performance overhead when calling it)? |
|
I'm thinking an approach to validate our compiler's expansion only compilation flag (aka
@jserv what do you think? |
Furthermore, we can adapt the preprocessor implementation from slimcc. |
51bd234 to
73552dd
Compare
|
#221 is related to this patch, as this patch also fixes error diagnostic context issue. We may also close it upon merged into master branch. |
73552dd to
49ccd49
Compare
49ccd49 to
3fa250a
Compare
|
It seems all static test stuite failed on stage 2 compilation after merge conflicts resolution and minor change introduced, which is weird. |
|
After adding the |
3fa250a to
8d4198d
Compare
DrXiao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following snapshots should be removed.
fib-arm.jsonfib-riscv.jsonhello-arm.jsonhello-riscv.json
64c71d9 to
3f915cd
Compare
|
Current |
b914e5b to
ee045f8
Compare
jserv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase latest master branch and resolve conflicts.
63d5e6b to
df3ce49
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the proposed changes look good. After addressing these comments, I think this pull request can be merged.
df3ce49 to
8267076
Compare
This patch completely separate the preprocessor functionality from scanner-less parser to indepadent units, which allows compiler to expand and parse nested function-like macro, multi-token object-like macro, and more. Furthermore, the error diagnostic is rewritten to better allow user to find out where and what lexeme causes compiler to panic.
8267076 to
0bb0033
Compare
|
Thank @ChAoSUnItY for contributing! |
This patch aims to resolve most current preprocessor issues seen in parser unit, including:
__LINE__,__FILE__.In this approach, we introduce a whole new phase dedicated to preprocessing (this practice can be seen in chibicc and other similar cc), instead of binding the preprocessing phase in few different places.
Current status
This draft is still in development, the below screenshot is comparison between result of
cpp -Eandout/shecc -E:comparison
test.c:a.c:Current major compilation workflow hasn't affected by the patch, which is expected to resolve in later commits.
Memory overhead
Memory usage increasement is expected since we now use
token_tstruct to track position, and token stream will be generated at once for preprocessor and parser to use with. Once parser finished, we expect to free all tokens.Summary by cubic
Introduces a dedicated preprocessing phase and rebuilds token handling to fix include guard behavior, add robust macro expansion, and improve error diagnostics. Adds an -E mode to output preprocessed code comparable to cpp -E.
New Features
Bug Fixes
Written for commit 0bb0033. Summary will update on new commits.