@@ -83,13 +83,15 @@ Parser::Parser(Js::ScriptContext* scriptContext, BOOL strictMode, PageAllocator
83
83
{
84
84
AssertMsg(size == sizeof(Parser), "verify conditionals affecting the size of Parser agree");
85
85
Assert(scriptContext != nullptr);
86
- m_isInBackground = isBackground;
87
86
m_phtbl = nullptr;
88
87
m_pscan = nullptr;
89
88
m_deferringAST = FALSE;
90
89
m_stoppedDeferredParse = FALSE;
90
+ #if ENABLE_BACKGROUND_PARSING
91
+ m_isInBackground = isBackground;
91
92
m_hasParallelJob = false;
92
93
m_doingFastScan = false;
94
+ #endif
93
95
m_scriptContext = scriptContext;
94
96
m_pCurrentAstSize = nullptr;
95
97
m_arrayDepth = 0;
@@ -113,8 +115,6 @@ Parser::Parser(Js::ScriptContext* scriptContext, BOOL strictMode, PageAllocator
113
115
m_length = 0;
114
116
m_originalLength = 0;
115
117
m_nextFunctionId = nullptr;
116
- m_errorCallback = nullptr;
117
- m_uncertainStructure = FALSE;
118
118
m_reparsingLambdaParams = false;
119
119
currBackgroundParseItem = nullptr;
120
120
backgroundParseItems = nullptr;
@@ -142,9 +142,9 @@ Parser::~Parser(void)
142
142
m_registeredRegexPatterns.Reset();
143
143
}
144
144
145
+ #if ENABLE_BACKGROUND_PARSING
145
146
if (this->m_hasParallelJob)
146
147
{
147
- #if ENABLE_BACKGROUND_PARSING
148
148
// Let the background threads know that they can decommit their arena pages.
149
149
BackgroundParser *bgp = m_scriptContext->GetBackgroundParser();
150
150
Assert(bgp);
@@ -158,8 +158,8 @@ Parser::~Parser(void)
158
158
});
159
159
Assert(result);
160
160
}
161
- #endif
162
161
}
162
+ #endif
163
163
164
164
Release();
165
165
@@ -409,9 +409,9 @@ HRESULT Parser::ParseSourceInternal(
409
409
hr = pse->ProcessError(m_pscan, hr, pnodeBase);
410
410
}
411
411
412
+ #if ENABLE_BACKGROUND_PARSING
412
413
if (this->m_hasParallelJob)
413
414
{
414
- #if ENABLE_BACKGROUND_PARSING
415
415
///// Wait here for remaining jobs to finish. Then look for errors, do final const bindings.
416
416
// pleath TODO: If there are remaining jobs, let the main thread help finish them.
417
417
BackgroundParser *bgp = m_scriptContext->GetBackgroundParser();
@@ -440,8 +440,8 @@ HRESULT Parser::ParseSourceInternal(
440
440
Parser *parser = item->GetParser();
441
441
parser->FinishBackgroundPidRefs(item, this != parser);
442
442
}
443
- #endif
444
443
}
444
+ #endif
445
445
446
446
// done with the scanner
447
447
RELEASEPTR(m_pscan);
@@ -2993,7 +2993,7 @@ ParseNodePtr Parser::ParseTerm(BOOL fAllowCall,
2993
2993
m_pscan->Scan();
2994
2994
2995
2995
// If the token after the right paren is not => or if there was a newline between () and => this is a syntax error
2996
- if (!m_doingFastScan && (m_token.tk != tkDArrow || m_pscan->FHadNewLine()))
2996
+ if (!IsDoingFastScan() && (m_token.tk != tkDArrow || m_pscan->FHadNewLine()))
2997
2997
{
2998
2998
Error(ERRsyntax);
2999
2999
}
@@ -3282,6 +3282,7 @@ LFunction :
3282
3282
}
3283
3283
break;
3284
3284
3285
+ #if ENABLE_BACKGROUND_PARSING
3285
3286
case tkCASE:
3286
3287
{
3287
3288
if (!m_doingFastScan)
@@ -3301,6 +3302,7 @@ LFunction :
3301
3302
m_pscan->Scan();
3302
3303
ParseStatement<buildAST>();
3303
3304
break;
3305
+ #endif
3304
3306
3305
3307
default:
3306
3308
LUnknown :
@@ -3341,17 +3343,20 @@ ParseNodePtr Parser::ParseRegExp()
3341
3343
{
3342
3344
ParseNodePtr pnode = nullptr;
3343
3345
3344
- if (buildAST || m_doingFastScan )
3346
+ if (buildAST || IsDoingFastScan() )
3345
3347
{
3346
3348
m_pscan->RescanRegExp();
3347
3349
3350
+ #if ENABLE_BACKGROUND_PARSING
3348
3351
BOOL saveDeferringAST = this->m_deferringAST;
3349
3352
if (m_doingFastScan)
3350
3353
{
3351
3354
this->m_deferringAST = false;
3352
3355
}
3356
+ #endif
3353
3357
pnode = CreateNodeWithScanner<knopRegExp>();
3354
3358
pnode->sxPid.regexPattern = m_token.GetRegex();
3359
+ #if ENABLE_BACKGROUND_PARSING
3355
3360
if (m_doingFastScan)
3356
3361
{
3357
3362
this->m_deferringAST = saveDeferringAST;
@@ -3361,7 +3366,6 @@ ParseNodePtr Parser::ParseRegExp()
3361
3366
pnode = nullptr;
3362
3367
}
3363
3368
}
3364
- #if ENABLE_BACKGROUND_PARSING
3365
3369
else if (this->IsBackgroundParser())
3366
3370
{
3367
3371
Assert(pnode->sxPid.regexPattern == nullptr);
@@ -5023,12 +5027,14 @@ bool Parser::ParseFncDeclHelper(ParseNodePtr pnodeFnc, LPCOLESTR pNameHint, usho
5023
5027
5024
5028
bool isTopLevelDeferredFunc = false;
5025
5029
5030
+ #if ENABLE_BACKGROUND_PARSING
5026
5031
struct AutoFastScanFlag {
5027
5032
bool savedDoingFastScan;
5028
5033
AutoFastScanFlag(Parser *parser) : m_parser(parser) { savedDoingFastScan = m_parser->m_doingFastScan; }
5029
5034
~AutoFastScanFlag() { m_parser->m_doingFastScan = savedDoingFastScan; }
5030
5035
Parser *m_parser;
5031
5036
} flag(this);
5037
+ #endif
5032
5038
5033
5039
bool doParallel = false;
5034
5040
bool parallelJobStarted = false;
@@ -5057,7 +5063,8 @@ bool Parser::ParseFncDeclHelper(ParseNodePtr pnodeFnc, LPCOLESTR pNameHint, usho
5057
5063
// These are heuristic conditions that prohibit upfront deferral but not redeferral.
5058
5064
isTopLevelDeferredFunc = isTopLevelDeferredFunc && !isDeferredFnc &&
5059
5065
(!isLikelyIIFE || !topLevelStmt || PHASE_FORCE_RAW(Js::DeferParsePhase, m_sourceContextInfo->sourceContextId, pnodeFnc->sxFnc.functionId));
5060
- ;
5066
+
5067
+ #if ENABLE_BACKGROUND_PARSING
5061
5068
if (!fLambda &&
5062
5069
!isDeferredFnc &&
5063
5070
!isLikelyIIFE &&
@@ -5067,7 +5074,7 @@ bool Parser::ParseFncDeclHelper(ParseNodePtr pnodeFnc, LPCOLESTR pNameHint, usho
5067
5074
!(this->m_parseType == ParseType_Deferred && this->m_functionBody && this->m_functionBody->GetScopeInfo() && !isTopLevelDeferredFunc))
5068
5075
{
5069
5076
doParallel = DoParallelParse(pnodeFnc);
5070
- #if ENABLE_BACKGROUND_PARSING
5077
+
5071
5078
if (doParallel)
5072
5079
{
5073
5080
BackgroundParser *bgp = m_scriptContext->GetBackgroundParser();
@@ -5093,8 +5100,8 @@ bool Parser::ParseFncDeclHelper(ParseNodePtr pnodeFnc, LPCOLESTR pNameHint, usho
5093
5100
}
5094
5101
}
5095
5102
}
5096
- #endif
5097
5103
}
5104
+ #endif
5098
5105
}
5099
5106
5100
5107
if (!doParallel)
@@ -10059,7 +10066,7 @@ ParseNodePtr Parser::ParseStatement()
10059
10066
{
10060
10067
// If we're doing a fast scan, we're not tracking labels, so we can't accurately do this analysis.
10061
10068
// Let the thread that's doing the full parse detect the error, if there is one.
10062
- if (!this->m_doingFastScan )
10069
+ if (!this->IsDoingFastScan() )
10063
10070
{
10064
10071
// Unlabeled break or continue.
10065
10072
if (buildAST)
@@ -11113,14 +11120,14 @@ ParseNodePtr Parser::Parse(LPCUTF8 pszSrc, size_t offset, size_t length, charcou
11113
11120
11114
11121
if (m_stoppedDeferredParse)
11115
11122
{
11123
+ #if ENABLE_BACKGROUND_PARSING
11116
11124
if (this->m_hasParallelJob)
11117
11125
{
11118
- #if ENABLE_BACKGROUND_PARSING
11119
11126
BackgroundParser *bgp = static_cast<BackgroundParser*>(m_scriptContext->GetBackgroundParser());
11120
11127
Assert(bgp);
11121
11128
this->WaitForBackgroundJobs(bgp, pse);
11122
- #endif
11123
11129
}
11130
+ #endif
11124
11131
11125
11132
// Do any remaining bindings of globals referenced in non-deferred functions.
11126
11133
if (pnodeGlobalEvalBlock)
@@ -11314,7 +11321,6 @@ void Parser::AddBackgroundParseItem(BackgroundParseItem *const item)
11314
11321
}
11315
11322
currBackgroundParseItem = item;
11316
11323
}
11317
- #endif
11318
11324
11319
11325
void Parser::AddFastScannedRegExpNode(ParseNodePtr const pnode)
11320
11326
{
@@ -11328,7 +11334,6 @@ void Parser::AddFastScannedRegExpNode(ParseNodePtr const pnode)
11328
11334
fastScannedRegExpNodes->Append(pnode);
11329
11335
}
11330
11336
11331
- #if ENABLE_BACKGROUND_PARSING
11332
11337
void Parser::AddBackgroundRegExpNode(ParseNodePtr const pnode)
11333
11338
{
11334
11339
Assert(IsBackgroundParser());
0 commit comments