Skip to content

Commit

Permalink
Remove -LetConst feature switch
Browse files Browse the repository at this point in the history
Re issue chakra-core#6
  • Loading branch information
Ian Halliday committed Feb 11, 2016
1 parent 70ede9a commit 94632ec
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 54 deletions.
30 changes: 6 additions & 24 deletions lib/Parser/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1796,12 +1796,6 @@ void Parser::PopBlockInfo()

void Parser::PushDynamicBlock()
{
if (!m_scriptContext->GetConfig()->IsLetAndConstEnabled())
{
// Shortcut: we only need to track dynamically-bound blocks for const reassignment.
return;
}

Assert(GetCurrentBlock());
int blockId = GetCurrentBlock()->sxBlock.blockId;
if (m_currentDynamicBlock && m_currentDynamicBlock->id == blockId)
Expand All @@ -1827,7 +1821,6 @@ void Parser::PopDynamicBlock()
return;
}
Assert(m_currentDynamicBlock);
AssertMsg(m_scriptContext->GetConfig()->IsLetAndConstEnabled(), "Should only do this if let/const is enabled since only needed for const reassignment error checking");
for (BlockInfoStack *blockInfo = m_currentBlockInfo; blockInfo; blockInfo = blockInfo->pBlockInfoOuter)
{
for (ParseNodePtr pnodeDecl = blockInfo->pnodeBlock->sxBlock.pnodeLexVars;
Expand Down Expand Up @@ -8524,7 +8517,7 @@ ParseNodePtr Parser::ParseStatement(bool isSourceElement/* = false*/)
break;

case tkID:
if (m_token.GetIdentifier(m_phtbl) == wellKnownPropertyPids.let && m_scriptContext->GetConfig()->IsLetAndConstEnabled())
if (m_token.GetIdentifier(m_phtbl) == wellKnownPropertyPids.let)
{
// We see "let" at the start of a statement. This could either be a declaration or an identifier
// reference. The next token determines which.
Expand Down Expand Up @@ -8559,18 +8552,11 @@ ParseNodePtr Parser::ParseStatement(bool isSourceElement/* = false*/)

case tkCONST:
case tkLET:
if (m_scriptContext->GetConfig()->IsLetAndConstEnabled())
{
ichMin = m_pscan->IchMinTok();
ichMin = m_pscan->IchMinTok();

m_pscan->Scan();
pnode = ParseVariableDeclaration<buildAST>(tok, ichMin);
goto LNeedTerminator;
}
else
{
goto LDefaultToken;
}
m_pscan->Scan();
pnode = ParseVariableDeclaration<buildAST>(tok, ichMin);
goto LNeedTerminator;

case tkVAR:
ichMin = m_pscan->IchMinTok();
Expand Down Expand Up @@ -8605,7 +8591,7 @@ ParseNodePtr Parser::ParseStatement(bool isSourceElement/* = false*/)
switch (tok)
{
case tkID:
if (m_token.GetIdentifier(m_phtbl) == wellKnownPropertyPids.let && m_scriptContext->GetConfig()->IsLetAndConstEnabled())
if (m_token.GetIdentifier(m_phtbl) == wellKnownPropertyPids.let)
{
// We see "let" in the init part of a for loop. This could either be a declaration or an identifier
// reference. The next token determines which.
Expand Down Expand Up @@ -8635,10 +8621,6 @@ ParseNodePtr Parser::ParseStatement(bool isSourceElement/* = false*/)
goto LDefaultTokenFor;
case tkLET:
case tkCONST:
if (!m_scriptContext->GetConfig()->IsLetAndConstEnabled())
{
goto LDefaultTokenFor;
}
case tkVAR:
{
auto ichMin = m_pscan->IchMinTok();
Expand Down
2 changes: 1 addition & 1 deletion lib/Runtime/Base/ScriptContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ namespace Js

bool SupportsCollectGarbage() const { return true; }
bool IsTypedArrayEnabled() const { return true; }
bool BindDeferredPidRefs() const { return IsLetAndConstEnabled(); }
bool BindDeferredPidRefs() const { return true; } // todo remove?

void ForceNoNative() { this->NoNative = true; }
void ForceNative() { this->NoNative = false; }
Expand Down
1 change: 0 additions & 1 deletion lib/Runtime/Base/ThreadConfigFlagsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Format: FLAG*(ThreadFlag, GlobalFlag)
FLAG(IsCollectGarbageEnabled, CollectGarbage)
FLAG(IsErrorStackTraceEnabled, errorStackTrace)
FLAG(IsLetAndConstEnabled, LetConst)
FLAG(IsES6UnicodeVerboseEnabled, ES6UnicodeVerbose)
FLAG_RELEASE(IsIntlEnabled, Intl)
FLAG_RELEASE(IsES6SpeciesEnabled, ES6Species)
Expand Down
7 changes: 2 additions & 5 deletions lib/Runtime/ByteCode/ByteCodeEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3107,7 +3107,7 @@ void ByteCodeGenerator::EmitOneFunction(ParseNode *pnode)
}
}

if (scriptContext->GetConfig()->IsLetAndConstEnabled() && funcInfo->IsGlobalFunction())
if (funcInfo->IsGlobalFunction())
{
EnsureNoRedeclarations(pnode->sxFnc.pnodeScopes, funcInfo);
}
Expand Down Expand Up @@ -6903,10 +6903,7 @@ void EmitCallTargetNoEvalComponents(
*thisLocation = funcInfo->undefinedConstantRegister;
}

if (byteCodeGenerator->GetScriptContext()->GetConfig()->IsLetAndConstEnabled())
{
EmitUseBeforeDeclaration(pnodeTarget, byteCodeGenerator, funcInfo);
}
EmitUseBeforeDeclaration(pnodeTarget, byteCodeGenerator, funcInfo);
break;

default:
Expand Down
22 changes: 9 additions & 13 deletions lib/Runtime/Language/JavascriptOperators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ namespace Js
}

Assert(scriptContext->IsUndeclBlockVar(value));
Assert(scriptContext->GetConfig()->IsLetAndConstEnabled());
JavascriptError::ThrowReferenceError(scriptContext, JSERR_UseBeforeDeclaration);
}

Expand Down Expand Up @@ -2699,22 +2698,19 @@ namespace Js
// with implicit calls disabled will always "succeed").
if (JavascriptOperators::HasProperty(object, propertyId))
{
if (scriptContext->GetConfig()->IsLetAndConstEnabled())
{
DisableImplicitFlags disableImplicitFlags =
scriptContext->GetThreadContext()->GetDisableImplicitFlags();
scriptContext->GetThreadContext()->SetDisableImplicitFlags(DisableImplicitCallAndExceptionFlag);
DisableImplicitFlags disableImplicitFlags = scriptContext->GetThreadContext()->GetDisableImplicitFlags();
scriptContext->GetThreadContext()->SetDisableImplicitFlags(DisableImplicitCallAndExceptionFlag);

Var value;
BOOL result = JavascriptOperators::GetProperty(object, propertyId, &value, scriptContext, nullptr);
Var value;
BOOL result = JavascriptOperators::GetProperty(object, propertyId, &value, scriptContext, nullptr);

scriptContext->GetThreadContext()->SetDisableImplicitFlags(disableImplicitFlags);
scriptContext->GetThreadContext()->SetDisableImplicitFlags(disableImplicitFlags);

if (result && scriptContext->IsUndeclBlockVar(value) && !allowUndecInConsoleScope && !isLexicalThisSlotSymbol)
{
JavascriptError::ThrowReferenceError(scriptContext, JSERR_UseBeforeDeclaration);
}
if (result && scriptContext->IsUndeclBlockVar(value) && !allowUndecInConsoleScope && !isLexicalThisSlotSymbol)
{
JavascriptError::ThrowReferenceError(scriptContext, JSERR_UseBeforeDeclaration);
}

PropertyValueInfo info;
PropertyValueInfo::SetCacheInfo(&info, functionBody, inlineCache, inlineCacheIndex, !IsFromFullJit);
PropertyOperationFlags setPropertyOpFlags = allowUndecInConsoleScope ? PropertyOperation_AllowUndeclInConsoleScope : PropertyOperation_None;
Expand Down
1 change: 0 additions & 1 deletion lib/Runtime/Language/JavascriptOperators.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ namespace Js
} \
if (scriptContext->IsUndeclBlockVar(var)) \
{ \
Assert(scriptContext->GetConfig()->IsLetAndConstEnabled()); \
JavascriptError::ThrowReferenceError(scriptContext, JSERR_UseBeforeDeclaration); \
}

Expand Down
1 change: 0 additions & 1 deletion lib/Runtime/Types/SimpleDictionaryTypeHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,6 @@ namespace Js
{
if ((descriptor->Attributes & PropertyNoRedecl) && !(flags & PropertyOperation_AllowUndecl))
{
Assert(scriptContext->GetConfig()->IsLetAndConstEnabled());
if (scriptContext->IsUndeclBlockVar(instance->GetSlot(descriptor->propertyIndex)) && !(flags & PropertyOperation_AllowUndeclInConsoleScope))
{
JavascriptError::ThrowReferenceError(scriptContext, JSERR_UseBeforeDeclaration);
Expand Down
4 changes: 0 additions & 4 deletions lib/common/ConfigFlagsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,6 @@ PHASE(All)
#define DEFAULT_CONFIG_MinProfileCacheSize (5) // Minimum number of functions before profile is saved.
#define DEFAULT_CONFIG_ProfileDifferencePercent (15) // If 15% of the functions have different profile we will trigger a save.

#define DEFAULT_CONFIG_LetConst (true)

#define DEFAULT_CONFIG_Intl (true)
#define DEFAULT_CONFIG_IntlBuiltIns (true)

Expand Down Expand Up @@ -837,8 +835,6 @@ FLAGR(Boolean, SkipSplitOnNoResult, "If the result of Regex split isn't used, sk
FLAGNR(String, TestEtwDll , "Path of the TestEtwEventSink DLL", nullptr)
#endif

FLAGNR(Boolean, LetConst , "Enable support of 'let' and 'const' keyword", DEFAULT_CONFIG_LetConst)

FLAGNR(Boolean, CollectGarbage , "Enable CollectGarbage API", DEFAULT_CONFIG_CollectGarbage)

FLAGR (Boolean, Intl , "Intl object support", DEFAULT_CONFIG_Intl)
Expand Down
8 changes: 4 additions & 4 deletions test/stackfunc/rlexe.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@
<default>
<files>let_stackfunc.js</files>
<baseline>let_stackfunc.baseline</baseline>
<compile-flags>-letconst -testtrace:stackfunc -off:simpleJit -off:deferparse -on:stackfunc</compile-flags>
<compile-flags>-testtrace:stackfunc -off:simpleJit -off:deferparse -on:stackfunc</compile-flags>
<tags>exclude_fre</tags>
</default>
</test>
<test>
<default>
<files>let_blockescape.js</files>
<baseline>let_blockescape.baseline</baseline>
<compile-flags>-letconst -testtrace:stackfunc -off:simpleJit -off:deferparse -on:stackfunc</compile-flags>
<compile-flags>-testtrace:stackfunc -off:simpleJit -off:deferparse -on:stackfunc</compile-flags>
<tags>exclude_fre</tags>
</default>
</test>
Expand Down Expand Up @@ -423,15 +423,15 @@
<default>
<files>let_stackfunc.js</files>
<baseline>let_stackfunc.deferparse.baseline</baseline>
<compile-flags>-letconst -testtrace:stackfunc -off:simpleJit -Force:Deferparse -on:stackfunc</compile-flags>
<compile-flags>-testtrace:stackfunc -off:simpleJit -Force:Deferparse -on:stackfunc</compile-flags>
<tags>exclude_fre,exclude_dynapogo</tags>
</default>
</test>
<test>
<default>
<files>let_blockescape.js</files>
<baseline>let_blockescape.deferparse.baseline</baseline>
<compile-flags>-letconst -testtrace:stackfunc -off:simpleJit -Force:Deferparse -on:stackfunc</compile-flags>
<compile-flags>-testtrace:stackfunc -off:simpleJit -Force:Deferparse -on:stackfunc</compile-flags>
<tags>exclude_fre,exclude_dynapogo</tags>
</default>
</test>
Expand Down

0 comments on commit 94632ec

Please sign in to comment.