-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve handling of block bodies in parser
We now have a common helper function (visitBody) to process the body of various statements instead of repeating the same code fragment. Similarly, we now also have a common visitParameters function. Finally, this change also adds a test to make sure that we don't introduce additional block statements due to the way statement bodies are represented in the AST. See the comment in the test for more details. Change-Id: Id494669c02ec36132daf7327bf2654fc21e13e0e Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/7934187 Reviewed-by: Carl Smith <[email protected]> Commit-Queue: Samuel Groß <[email protected]>
- Loading branch information
Samuel Groß
authored and
V8-internal LUCI CQ
committed
Jan 7, 2025
1 parent
50d2fcc
commit 48cf047
Showing
3 changed files
with
104 additions
and
30 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
if (typeof output === 'undefined') output = console.log; | ||
|
||
// This tests makes sure that we don't create additional block statements during compilation. | ||
// For example, a typical AST for an if statement (ignoring the condition) would look like this: | ||
// | ||
// IfStatement | ||
// | | ||
// BlockStatement | ||
// / | \ | ||
// Foo Bar Baz | ||
// | ||
// In that case, we want to generate the following IL code: | ||
// | ||
// BeginIf | ||
// Foo | ||
// Bar | ||
// Baz | ||
// EndIf | ||
// | ||
// And not | ||
// | ||
// BeginIf | ||
// BeginBlock | ||
// Foo | ||
// Bar | ||
// Baz | ||
// EndBlock | ||
// EndIf | ||
// | ||
function test() { | ||
function f1() {} | ||
function* f2() {} | ||
async function f3() {} | ||
let f4 = () => {}; | ||
{} | ||
if (true) {} | ||
else {} | ||
for (let i = 0; i < 1; i++) {} | ||
for (let p of {}) {} | ||
for (let p in {}) {} | ||
while (false) {} | ||
do {} while (false); | ||
try {} catch (e) {} finally {} | ||
with ({}) {} | ||
let o = { | ||
m() {}, | ||
get a() {}, | ||
set a(v) {} | ||
}; | ||
class C { | ||
constructor() {} | ||
m() {} | ||
get a() {} | ||
set a(v) {} | ||
static n() {} | ||
static get b() {} | ||
static set b(v) {} | ||
static {} | ||
} | ||
} | ||
|
||
let source = test.toString(); | ||
let num_braces = source.split('{').length - 1; | ||
output(num_braces); |