Commit b2337762 authored by marja's avatar marja Committed by Commit bot

PreParsing inner funcs: make scope analysis even more complete.

This adds tracking the following:
- Let / var declarations in for loops

BUG=v8:5501, v8:5516

Review-Url: https://codereview.chromium.org/2616393002
Cr-Commit-Position: refs/heads/master@{#42169}
parent af51befe
......@@ -1271,6 +1271,11 @@ class PreParser : public ParserBase<PreParser> {
V8_INLINE PreParserStatement
BuildInitializationBlock(DeclarationParsingResult* parsing_result,
ZoneList<const AstRawString*>* names, bool* ok) {
for (auto declaration : parsing_result->declarations) {
DeclareAndInitializeVariables(PreParserStatement::Default(),
&(parsing_result->descriptor), &declaration,
names, ok);
}
return PreParserStatement::Default();
}
......
......@@ -8865,16 +8865,22 @@ TEST(NoPessimisticContextAllocation) {
false},
{"function inner() { for (var {a, my_var} in {}) { } my_var; }", false},
{"function inner() { for (var {a, my_var} of []) { } my_var; }", false},
{"function inner() { class my_var {}; my_var }", false},
// In the following cases we still context allocate pessimistically:
{"function inner() { function my_var() {} my_var; }", true},
{"function inner() { if (true) { function my_var() {} } my_var; }",
true},
{"function inner() { for (let my_var = 0; my_var < 1; ++my_var) { my_var "
"} }",
true},
false},
{"function inner() { for (var my_var = 0; my_var < 1; ++my_var) { my_var "
"} }",
false},
{"function inner() { for (let a = 0, my_var = 0; my_var < 1; ++my_var) { "
"my_var } }",
false},
{"function inner() { for (var a = 0, my_var = 0; my_var < 1; ++my_var) { "
"my_var } }",
false},
{"function inner() { class my_var {}; my_var }", false},
// In the following cases we still context allocate pessimistically:
{"function inner() { function my_var() {} my_var; }", true},
{"function inner() { if (true) { function my_var() {} } my_var; }",
true},
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment