Skip to content

Commit

Permalink
[MERGE #2729 @aneeshdk] Enabling eval in param scope
Browse files Browse the repository at this point in the history
Merge pull request #2729 from aneeshdk:DefParamEvalEnable

Enabling eval usage in param scope by default. Removed the duplicate
symbols from body scope. Also removed the work around used for special
symbols like this, super etc.
  • Loading branch information
aneeshdk committed Mar 23, 2017
2 parents 3c47fd9 + 08dc260 commit a8582a3
Show file tree
Hide file tree
Showing 45 changed files with 11,527 additions and 2,539 deletions.
54 changes: 35 additions & 19 deletions lib/Backend/IRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,16 @@ IRBuilder::BuildReg1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot R0)
newOpcode = Js::OpCode::Ld_A;
break;

case Js::OpCode::LdParamObj:
if (!m_func->GetJITFunctionBody()->HasScopeObject())
{
Js::Throw::FatalInternalError();
}
srcOpnd = BuildSrcOpnd(m_func->GetJITFunctionBody()->GetParamClosureReg());
isNotInt = true;
newOpcode = Js::OpCode::Ld_A;
break;

case Js::OpCode::Throw:
{
srcOpnd = this->BuildSrcOpnd(srcRegOpnd);
Expand Down Expand Up @@ -3504,9 +3514,9 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
IR::ByteCodeUsesInstr *byteCodeUse;
PropertySym *fieldSym = nullptr;
StackSym * stackFuncPtrSym = nullptr;
SymID symID;
SymID symID = m_func->GetJITFunctionBody()->GetLocalClosureReg();
bool isLdSlotThatWasNotProfiled = false;
uint scopeSlotSize = 0;
uint scopeSlotSize = m_func->GetJITFunctionBody()->GetScopeSlotArraySize();
StackSym* closureSym = m_func->GetLocalClosureSym();

switch (newOpcode)
Expand All @@ -3515,14 +3525,9 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
scopeSlotSize = m_func->GetJITFunctionBody()->GetParamScopeSlotArraySize();
closureSym = m_func->GetParamClosureSym();
symID = m_func->GetJITFunctionBody()->GetParamClosureReg();
fieldSym = PropertySym::New(closureSym, slotId, (uint32)-1, (uint)-1, PropertyKindSlots, m_func);
goto LdLocalSlot;
// Fall through

case Js::OpCode::LdLocalSlot:
scopeSlotSize = m_func->GetJITFunctionBody()->GetScopeSlotArraySize();
symID = m_func->GetJITFunctionBody()->GetLocalClosureReg();

LdLocalSlot:
if (PHASE_ON(Js::ClosureRangeCheckPhase, m_func))
{
if ((uint32)slotId >= scopeSlotSize + Js::ScopeSlots::FirstSlotIndex)
Expand Down Expand Up @@ -3562,7 +3567,7 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
this->EnsureLoopBodyLoadSlot(symID);
}

fieldSym = fieldSym ? fieldSym : PropertySym::FindOrCreate(symID, slotId, (uint32)-1, (uint)-1, PropertyKindSlots, m_func);
fieldSym = PropertySym::FindOrCreate(symID, slotId, (uint32)-1, (uint)-1, PropertyKindSlots, m_func);
fieldOpnd = IR::SymOpnd::New(fieldSym, TyVar, m_func);
regOpnd = this->BuildDstOpnd(regSlot);
instr = nullptr;
Expand All @@ -3587,12 +3592,9 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
closureSym = m_func->GetParamClosureSym();
symID = m_func->GetJITFunctionBody()->GetParamClosureReg();
newOpcode = Js::OpCode::LdLocalObjSlot;
goto LdLocalObjSlot;
// Fall through

case Js::OpCode::LdLocalObjSlot:
symID = m_func->GetJITFunctionBody()->GetLocalClosureReg();

LdLocalObjSlot:
if (closureSym->HasByteCodeRegSlot())
{
byteCodeUse = IR::ByteCodeUsesInstr::New(m_func, offset);
Expand Down Expand Up @@ -3622,12 +3624,19 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
this->AddInstr(instr, offset);
break;

case Js::OpCode::StParamSlot:
case Js::OpCode::StParamSlotChkUndecl:
scopeSlotSize = m_func->GetJITFunctionBody()->GetParamScopeSlotArraySize();
closureSym = m_func->GetParamClosureSym();
symID = m_func->GetJITFunctionBody()->GetParamClosureReg();
newOpcode = newOpcode == Js::OpCode::StParamSlot ? Js::OpCode::StLocalSlot : Js::OpCode::StLocalSlotChkUndecl;
// Fall through

case Js::OpCode::StLocalSlot:
case Js::OpCode::StLocalSlotChkUndecl:

if (PHASE_ON(Js::ClosureRangeCheckPhase, m_func))
{
if ((uint32)slotId >= m_func->GetJITFunctionBody()->GetScopeSlotArraySize() + Js::ScopeSlots::FirstSlotIndex)
if ((uint32)slotId >= scopeSlotSize + Js::ScopeSlots::FirstSlotIndex)
{
Js::Throw::FatalInternalError();
}
Expand Down Expand Up @@ -3660,7 +3669,6 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
}
else
{
symID = m_func->GetJITFunctionBody()->GetLocalClosureReg();
if (IsLoopBody())
{
this->EnsureLoopBodyLoadSlot(symID);
Expand All @@ -3683,9 +3691,15 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
}
break;

case Js::OpCode::StParamObjSlot:
case Js::OpCode::StParamObjSlotChkUndecl:
closureSym = m_func->GetParamClosureSym();
symID = m_func->GetJITFunctionBody()->GetParamClosureReg();
newOpcode = newOpcode == Js::OpCode::StParamObjSlot ? Js::OpCode::StLocalObjSlot : Js::OpCode::StLocalObjSlotChkUndecl;
// Fall through

case Js::OpCode::StLocalObjSlot:
case Js::OpCode::StLocalObjSlotChkUndecl:

if (closureSym->HasByteCodeRegSlot())
{
byteCodeUse = IR::ByteCodeUsesInstr::New(m_func, offset);
Expand All @@ -3694,7 +3708,7 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
}

regOpnd = IR::RegOpnd::New(TyVar, m_func);
fieldOpnd = this->BuildFieldOpnd(Js::OpCode::LdSlotArr, m_func->GetJITFunctionBody()->GetLocalClosureReg(), (Js::DynamicObject::GetOffsetOfAuxSlots())/sizeof(Js::Var), (Js::PropertyIdIndexType)-1, PropertyKindSlotArray);
fieldOpnd = this->BuildFieldOpnd(Js::OpCode::LdSlotArr, symID, (Js::DynamicObject::GetOffsetOfAuxSlots())/sizeof(Js::Var), (Js::PropertyIdIndexType)-1, PropertyKindSlotArray);
instr = IR::Instr::New(Js::OpCode::LdSlotArr, regOpnd, fieldOpnd, m_func);
this->AddInstr(instr, offset);

Expand Down Expand Up @@ -6795,7 +6809,9 @@ IRBuilder::BuildEmpty(Js::OpCode newOpcode, uint32 offset)
this->m_func),
offset);

if (this->m_func->GetJITFunctionBody()->GetScopeSlotArraySize())
// Create a new local closure for the body when either body scope has scope slots allocated or
// eval is present which can leak declarations.
if (this->m_func->GetJITFunctionBody()->GetScopeSlotArraySize() > 0 || this->m_func->GetJITFunctionBody()->HasScopeObject())
{
if (this->m_func->GetJITFunctionBody()->HasScopeObject())
{
Expand Down
11 changes: 0 additions & 11 deletions lib/Common/ConfigFlagsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,6 @@ PHASE(All)
#define DEFAULT_CONFIG_ES6Classes (true)
#define DEFAULT_CONFIG_ES6DateParseFix (true)
#define DEFAULT_CONFIG_ES6DefaultArgs (true)
#ifdef COMPILE_DISABLE_ES6DefaultArgsSplitScope
// If ES6DefaultArgsSplitScope needs to be disabled by compile flag, COMPILE_DISABLE_ES6DefaultArgsSplitScope should be false
#define DEFAULT_CONFIG_ES6DefaultArgsSplitScope (false)
#else
#define DEFAULT_CONFIG_ES6DefaultArgsSplitScope (false)
#endif
#define DEFAULT_CONFIG_ES6Destructuring (true)
#define DEFAULT_CONFIG_ES6ForLoopSemantics (true)
#define DEFAULT_CONFIG_ES6FunctionName (true)
Expand Down Expand Up @@ -956,11 +950,6 @@ FLAGPR (Boolean, ES6, ES7AsyncAwait , "Enable ES7 'async' and
FLAGPR (Boolean, ES6, ES6Classes , "Enable ES6 'class' and 'extends' keywords" , DEFAULT_CONFIG_ES6Classes)
FLAGPR (Boolean, ES6, ES6DateParseFix , "Enable ES6 Date.parse fixes" , DEFAULT_CONFIG_ES6DateParseFix)
FLAGPR (Boolean, ES6, ES6DefaultArgs , "Enable ES6 Default Arguments" , DEFAULT_CONFIG_ES6DefaultArgs)

#ifndef COMPILE_DISABLE_ES6DefaultArgsSplitScope
#define COMPILE_DISABLE_ES6DefaultArgsSplitScope 0
#endif
FLAGPR_REGOVR_EXP(Boolean, ES6, ES6DefaultArgsSplitScope, "Enable ES6 Default Arguments to have its own scope" , DEFAULT_CONFIG_ES6DefaultArgsSplitScope)
FLAGPR (Boolean, ES6, ES6Destructuring , "Enable ES6 Destructuring" , DEFAULT_CONFIG_ES6Destructuring)
FLAGPR (Boolean, ES6, ES6ForLoopSemantics , "Enable ES6 for loop per iteration bindings" , DEFAULT_CONFIG_ES6ForLoopSemantics)
FLAGPR (Boolean, ES6, ES6FunctionName , "Enable ES6 function.name" , DEFAULT_CONFIG_ES6FunctionName)
Expand Down

0 comments on commit a8582a3

Please sign in to comment.