-
Notifications
You must be signed in to change notification settings - Fork 308
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
Feature/switch statement js compiler #440
Merged
saelo
merged 9 commits into
googleprojectzero:main
from
TobiasWienand:feature/switch-statement-JS-compiler
Aug 22, 2024
Merged
Feature/switch statement js compiler #440
saelo
merged 9 commits into
googleprojectzero:main
from
TobiasWienand:feature/switch-statement-JS-compiler
Aug 22, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
saelo
reviewed
Aug 8, 2024
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.
Great, thanks!
1. Shortens the map statement in JS parser 2. precomputedTests in the Compiler now only contains Variables, not nil 3. A TODO comment that proposes dynamic compilation of switch cases is added
This change ensures that when a break statement is encountered in the Compiler, the appropriate break type (LoopBreak or SwitchBreak) is emitted based on context. 3 out 4 cases are not a problem: - Case 1: If neither .loop nor .switchBlock is in context, an error is raised. - Case 2: If .loop is in context but not .switchBlock, emit LoopBreak. - Case 3: If .switchBlock is in context but not .loop, emit SwitchBreak. - Case 4 (problem): If both are in context, the innermost context needs to be determined. For Case 4, the existing contextStack doesn't track which context was opened most recently. A new breakContextStack is introduced to handle this. Minor modifications to the Instruction and Attributes classes were made to manage pushing and popping of break context information.
saelo
reviewed
Aug 13, 2024
These changes move the logic for break context identification out of the performance ciritical part of the Fuzzilli project and into the compiler. The idea is straight-forward: We fix the bug in the context analyzer that caused contexts to contain both .loop and .switchBlock by simply removing the loop context upon opening a switchBlock context and vice versa.
saelo
reviewed
Aug 20, 2024
saelo
pushed a commit
that referenced
this pull request
Aug 22, 2024
* Implements JS->FuzzIL translatability for switch statements * Implements compiler tests for the switch statement * Improves Compiler and JS Parser
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses #437
The code makes switch statements compilable from JS to FuzzIL.
The scoping is implemented as described in the comments.
A BreakStatement is processed as a SwitchBreak if it is found in a SwitchCase . Everywhere else, it is still a LoopBreak. (See here for the test to determine if the mapping break -> {Loop Break, Switch Break} functions properly.
Instead of calling compileStatement on the BreakStatement in the SwitchCase, we simply set the fallsThrough argument to true for the EndSwitchCase. This causes the SwitchBreak to be emitted outside of Compiler.swift