Skip to content

Commit

Permalink
[MERGE chakra-core#5744 @nhat-nguyen] Remove unused parameter in DoSt…
Browse files Browse the repository at this point in the history
…ackArgsOpt

Merge pull request chakra-core#5744 from nhat-nguyen:stackargs

`DoStackArgsOpt` takes a `topFunc` parameter but doesn't use it.

It seems like the intention is to pass it to `IsStackArgsEnabled`, but `topFunc` is actually referenced inside `IsStackArgsEnabled` through a pointer in m_func, making passing in the argument unnecessary.
  • Loading branch information
nhat-nguyen committed Oct 4, 2018
2 parents 33c525c + 660e1d5 commit 9a951e2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions lib/Backend/BackwardPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ BackwardPass::MarkScopeObjSymUseForStackArgOpt()
IR::Instr * instr = this->currentInstr;
if (tag == Js::DeadStorePhase)
{
if (instr->DoStackArgsOpt(this->func) && instr->m_func->GetScopeObjSym() != nullptr && this->DoByteCodeUpwardExposedUsed())
if (instr->DoStackArgsOpt() && instr->m_func->GetScopeObjSym() != nullptr && this->DoByteCodeUpwardExposedUsed())
{
if (this->currentBlock->byteCodeUpwardExposedUsed == nullptr)
{
Expand All @@ -315,7 +315,7 @@ BackwardPass::ProcessBailOnStackArgsOutOfActualsRange()
(instr->m_opcode == Js::OpCode::LdElemI_A || instr->m_opcode == Js::OpCode::TypeofElem) &&
instr->HasBailOutInfo() && !IsPrePass())
{
if (instr->DoStackArgsOpt(this->func))
if (instr->DoStackArgsOpt())
{
AssertMsg(instr->GetBailOutKind() & IR::BailOnStackArgsOutOfActualsRange, "Stack args bail out is not set when the optimization is turned on? ");
if (instr->GetBailOutKind() & ~IR::BailOnStackArgsOutOfActualsRange)
Expand Down Expand Up @@ -3922,7 +3922,7 @@ IR::Instr *
BackwardPass::TryChangeInstrForStackArgOpt()
{
IR::Instr * instr = this->currentInstr;
if (tag == Js::DeadStorePhase && instr->DoStackArgsOpt(this->func))
if (tag == Js::DeadStorePhase && instr->DoStackArgsOpt())
{
switch (instr->m_opcode)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/FlowGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3421,7 +3421,7 @@ FlowGraph::RemoveInstr(IR::Instr *instr, GlobOpt * globOpt)
* - When we restore HeapArguments object in the bail out path, it expects the scope object also to be restored - if one was created.
*/
Js::OpCode opcode = instr->m_opcode;
if (opcode == Js::OpCode::LdElemI_A && instr->DoStackArgsOpt(this->func) &&
if (opcode == Js::OpCode::LdElemI_A && instr->DoStackArgsOpt() &&
globOpt->CurrentBlockData()->IsArgumentsOpnd(instr->GetSrc1()) && instr->m_func->GetScopeObjSym())
{
IR::ByteCodeUsesInstr * byteCodeUsesInstr = IR::ByteCodeUsesInstr::New(instr);
Expand Down
14 changes: 7 additions & 7 deletions lib/Backend/GlobOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2407,7 +2407,7 @@ GlobOpt::OptInstr(IR::Instr *&instr, bool* isInstrRemoved)

//StackArguments Optimization - We bail out if the index is out of range of actuals.
if ((instr->m_opcode == Js::OpCode::LdElemI_A || instr->m_opcode == Js::OpCode::TypeofElem) &&
instr->DoStackArgsOpt(this->func) && !this->IsLoopPrePass())
instr->DoStackArgsOpt() && !this->IsLoopPrePass())
{
GenerateBailAtOperation(&instr, IR::BailOnStackArgsOutOfActualsRange);
}
Expand Down Expand Up @@ -5179,7 +5179,7 @@ GlobOpt::ValueNumberLdElemDst(IR::Instr **pInstr, Value *srcVal)

IR::IndirOpnd *src = instr->GetSrc1()->AsIndirOpnd();
const ValueType baseValueType(src->GetBaseOpnd()->GetValueType());
if (instr->DoStackArgsOpt(this->func) ||
if (instr->DoStackArgsOpt() ||
!(
baseValueType.IsLikelyOptimizedTypedArray() ||
(baseValueType.IsLikelyNativeArray() && instr->IsProfiledInstr()) // Specialized native array lowering for LdElem requires that it is profiled.
Expand All @@ -5203,7 +5203,7 @@ GlobOpt::ValueNumberLdElemDst(IR::Instr **pInstr, Value *srcVal)
this->func->GetDebugNumberSet(debugStringBuffer),
Js::OpCodeUtil::GetOpCodeName(instr->m_opcode),
baseValueTypeStr,
instr->DoStackArgsOpt(this->func) ? _u("instruction uses the arguments object") :
instr->DoStackArgsOpt() ? _u("instruction uses the arguments object") :
baseValueType.IsLikelyOptimizedTypedArray() ? _u("index is negative or likely not int") : _u("of array type"));
Output::Flush();
}
Expand Down Expand Up @@ -10753,7 +10753,7 @@ GlobOpt::TypeSpecializeStElem(IR::Instr ** pInstr, Value *src1Val, Value **pDstV

IR::RegOpnd *baseOpnd = instr->GetDst()->AsIndirOpnd()->GetBaseOpnd();
ValueType baseValueType(baseOpnd->GetValueType());
if (instr->DoStackArgsOpt(this->func) ||
if (instr->DoStackArgsOpt() ||
(!this->DoTypedArrayTypeSpec() && baseValueType.IsLikelyOptimizedTypedArray()) ||
(!this->DoNativeArrayTypeSpec() && baseValueType.IsLikelyNativeArray()) ||
!(baseValueType.IsLikelyOptimizedTypedArray() || baseValueType.IsLikelyNativeArray()))
Expand All @@ -10769,7 +10769,7 @@ GlobOpt::TypeSpecializeStElem(IR::Instr ** pInstr, Value *src1Val, Value **pDstV
this->func->GetDebugNumberSet(debugStringBuffer),
Js::OpCodeUtil::GetOpCodeName(instr->m_opcode),
baseValueTypeStr,
instr->DoStackArgsOpt(this->func) ?
instr->DoStackArgsOpt() ?
_u("instruction uses the arguments object") :
_u("typed array type specialization is disabled, or base is not an optimized typed array"));
Output::Flush();
Expand Down Expand Up @@ -15625,7 +15625,7 @@ GlobOpt::DoArrayCheckHoist() const
bool
GlobOpt::DoArrayCheckHoist(const ValueType baseValueType, Loop* loop, IR::Instr const * const instr) const
{
if(!DoArrayCheckHoist() || (instr && !IsLoopPrePass() && instr->DoStackArgsOpt(func)))
if(!DoArrayCheckHoist() || (instr && !IsLoopPrePass() && instr->DoStackArgsOpt()))
{
return false;
}
Expand Down Expand Up @@ -15759,7 +15759,7 @@ GlobOpt::DoLdLenIntSpec(IR::Instr * const instr, const ValueType baseValueType)
if(PHASE_OFF(Js::LdLenIntSpecPhase, func) ||
IsTypeSpecPhaseOff(func) ||
(func->HasProfileInfo() && func->GetReadOnlyProfileInfo()->IsLdLenIntSpecDisabled()) ||
(instr && !IsLoopPrePass() && instr->DoStackArgsOpt(func)))
(instr && !IsLoopPrePass() && instr->DoStackArgsOpt()))
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/IR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Instr::IsPlainInstr() const
}

bool
Instr::DoStackArgsOpt(Func *topFunc) const
Instr::DoStackArgsOpt() const
{
return this->usesStackArgumentsObject && m_func->IsStackArgsEnabled();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/IR.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class Instr
bool StartsBasicBlock() const;
bool EndsBasicBlock() const;
bool HasFallThrough() const;
bool DoStackArgsOpt(Func *topFunc) const;
bool DoStackArgsOpt() const;
bool HasAnyLoadHeapArgsOpCode();
bool IsEqual(IR::Instr *instr) const;

Expand Down
16 changes: 8 additions & 8 deletions lib/Backend/Lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6022,7 +6022,7 @@ Lowerer::GenerateFastLdMethodFromFlags(IR::Instr * instrLdFld)

IR::PropertySymOpnd * propertySymOpnd = opndSrc->AsPropertySymOpnd();

Assert(!instrLdFld->DoStackArgsOpt(this->m_func));
Assert(!instrLdFld->DoStackArgsOpt());

if (propertySymOpnd->IsTypeCheckSeqCandidate())
{
Expand Down Expand Up @@ -9176,7 +9176,7 @@ Lowerer::LowerLdElemI(IR::Instr * instr, IR::JnHelperMethod helperMethod, bool i
return instrPrev;
}

if (!isHelper && instr->DoStackArgsOpt(this->m_func))
if (!isHelper && instr->DoStackArgsOpt())
{
IR::LabelInstr * labelLdElem = IR::LabelInstr::New(Js::OpCode::Label, instr->m_func);
// Pass in null for labelFallThru to only generate the LdHeapArgument call
Expand Down Expand Up @@ -17673,12 +17673,12 @@ Lowerer::GenerateFastLdElemI(IR::Instr *& ldElem, bool *instrIsInHelperBlockRef)
labelFallThru = ldElem->GetOrCreateContinueLabel();
labelHelper = IR::LabelInstr::New(Js::OpCode::Label, this->m_func, true);
// If we know for sure (based on flow graph) we're loading from the arguments object, then ignore the (path-based) profile info.
bool isNativeArrayLoad = !ldElem->DoStackArgsOpt(this->m_func) && indirOpnd->GetBaseOpnd()->GetValueType().IsLikelyNativeArray();
bool isNativeArrayLoad = !ldElem->DoStackArgsOpt() && indirOpnd->GetBaseOpnd()->GetValueType().IsLikelyNativeArray();
bool needMissingValueCheck = true;
bool emittedFastPath = false;
bool emitBailout = false;

if (ldElem->DoStackArgsOpt(this->m_func))
if (ldElem->DoStackArgsOpt())
{
emittedFastPath = GenerateFastArgumentsLdElemI(ldElem, labelFallThru);
emitBailout = true;
Expand Down Expand Up @@ -18969,7 +18969,7 @@ Lowerer::GenerateFastLdLen(IR::Instr *ldLen, bool *instrIsInHelperBlockRef)

IR::LabelInstr *const labelHelper = IR::LabelInstr::New(Js::OpCode::Label, this->m_func, true);

if (ldLen->DoStackArgsOpt(this->m_func))
if (ldLen->DoStackArgsOpt())
{
GenerateFastArgumentsLdLen(ldLen, ldLen->GetOrCreateContinueLabel());
ldLen->Remove();
Expand Down Expand Up @@ -21673,7 +21673,7 @@ Lowerer::GenerateFastArgumentsLdElemI(IR::Instr* ldElem, IR::LabelInstr *labelFa
//labelCreateHeapArgs:
// ---Bail out to create Heap Arguments object

Assert(ldElem->DoStackArgsOpt(this->m_func));
Assert(ldElem->DoStackArgsOpt());

IR::IndirOpnd *indirOpnd = ldElem->GetSrc1()->AsIndirOpnd();
bool isInlinee = ldElem->m_func->IsInlinee();
Expand Down Expand Up @@ -21804,7 +21804,7 @@ Lowerer::GenerateFastArgumentsLdLen(IR::Instr *ldLen, IR::LabelInstr* labelFallT
// JMP $fallthrough
//$helper:

Assert(ldLen->DoStackArgsOpt(this->m_func));
Assert(ldLen->DoStackArgsOpt());

if(ldLen->m_func->IsInlinee())
{
Expand Down Expand Up @@ -22005,7 +22005,7 @@ Lowerer::GenerateFastLdFld(IR::Instr * const instrLdFld, IR::JnHelperMethod help
IR::Opnd * opndSrc = instrLdFld->GetSrc1();
AssertMsg(opndSrc->IsSymOpnd() && opndSrc->AsSymOpnd()->IsPropertySymOpnd() && opndSrc->AsSymOpnd()->m_sym->IsPropertySym(), "Expected PropertySym as src of LdFld");

Assert(!instrLdFld->DoStackArgsOpt(this->m_func));
Assert(!instrLdFld->DoStackArgsOpt());

IR::PropertySymOpnd * propertySymOpnd = opndSrc->AsPropertySymOpnd();
PropertySym * propertySym = propertySymOpnd->m_sym->AsPropertySym();
Expand Down

0 comments on commit 9a951e2

Please sign in to comment.