Skip to content

Commit 345831e

Browse files
committed
[MERGE #6132 @nhat-nguyen] Clean up Func's unused StackSyms and use getters/setters where appropriate
Merge pull request #6132 from nhat-nguyen:cleanupfunc
2 parents 773a879 + cd8a99e commit 345831e

File tree

8 files changed

+103
-116
lines changed

8 files changed

+103
-116
lines changed

lib/Backend/Func.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ Func::Func(JitArenaAllocator *alloc, JITTimeWorkItem * workItem,
5151
m_cloner(nullptr),
5252
m_cloneMap(nullptr),
5353
m_loopParamSym(nullptr),
54-
m_funcObjSym(nullptr),
5554
m_localClosureSym(nullptr),
5655
m_paramClosureSym(nullptr),
5756
m_localFrameDisplaySym(nullptr),
@@ -1361,6 +1360,30 @@ Func::EndPhase(Js::Phase tag, bool dump)
13611360
#endif
13621361
}
13631362

1363+
StackSym *
1364+
Func::EnsureBailoutReturnValueSym()
1365+
{
1366+
if (m_bailoutReturnValueSym == nullptr)
1367+
{
1368+
m_bailoutReturnValueSym = StackSym::New(TyVar, this);
1369+
StackAllocate(m_bailoutReturnValueSym, sizeof(Js::Var));
1370+
}
1371+
1372+
return m_bailoutReturnValueSym;
1373+
}
1374+
1375+
StackSym *
1376+
Func::EnsureHasBailedOutSym()
1377+
{
1378+
if (m_hasBailedOutSym == nullptr)
1379+
{
1380+
m_hasBailedOutSym = StackSym::New(TyUint32, this);
1381+
StackAllocate(m_hasBailedOutSym, MachRegInt);
1382+
}
1383+
1384+
return m_hasBailedOutSym;
1385+
}
1386+
13641387
StackSym *
13651388
Func::EnsureLoopParamSym()
13661389
{

lib/Backend/Func.h

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -416,32 +416,9 @@ static const unsigned __int64 c_debugFillPattern8 = 0xcececececececece;
416416
return !GetHasCalls() && !GetHasImplicitCalls();
417417
}
418418

419-
StackSym *EnsureLoopParamSym();
420-
421419
void UpdateForInLoopMaxDepth(uint forInLoopMaxDepth);
422420
int GetForInEnumeratorArrayOffset() const;
423421

424-
StackSym *GetFuncObjSym() const { return m_funcObjSym; }
425-
void SetFuncObjSym(StackSym *sym) { m_funcObjSym = sym; }
426-
427-
StackSym *GetJavascriptLibrarySym() const { return m_javascriptLibrarySym; }
428-
void SetJavascriptLibrarySym(StackSym *sym) { m_javascriptLibrarySym = sym; }
429-
430-
StackSym *GetScriptContextSym() const { return m_scriptContextSym; }
431-
void SetScriptContextSym(StackSym *sym) { m_scriptContextSym = sym; }
432-
433-
StackSym *GetFunctionBodySym() const { return m_functionBodySym; }
434-
void SetFunctionBodySym(StackSym *sym) { m_functionBodySym = sym; }
435-
436-
StackSym *GetLocalClosureSym() const { return m_localClosureSym; }
437-
void SetLocalClosureSym(StackSym *sym) { m_localClosureSym = sym; }
438-
439-
StackSym *GetParamClosureSym() const { return m_paramClosureSym; }
440-
void SetParamClosureSym(StackSym *sym) { m_paramClosureSym = sym; }
441-
442-
StackSym *GetLocalFrameDisplaySym() const { return m_localFrameDisplaySym; }
443-
void SetLocalFrameDisplaySym(StackSym *sym) { m_localFrameDisplaySym = sym; }
444-
445422
intptr_t GetJittedLoopIterationsSinceLastBailoutAddress() const;
446423
void EnsurePinnedTypeRefs();
447424
void PinTypeRef(void* typeRef);
@@ -511,12 +488,6 @@ static const unsigned __int64 c_debugFillPattern8 = 0xcececececececece;
511488
return m_inlineeFrameStartSym != nullptr;
512489
}
513490

514-
void SetInlineeFrameStartSym(StackSym *sym)
515-
{
516-
Assert(m_inlineeFrameStartSym == nullptr);
517-
m_inlineeFrameStartSym = sym;
518-
}
519-
520491
void SetInlineeStart(IR::Instr *inlineeStartInstr)
521492
{
522493
Assert(inlineeStart == nullptr);
@@ -678,16 +649,7 @@ static const unsigned __int64 c_debugFillPattern8 = 0xcececececececece;
678649
#endif
679650

680651
SymTable * m_symTable;
681-
StackSym * m_loopParamSym;
682-
StackSym * m_funcObjSym;
683-
StackSym * m_javascriptLibrarySym;
684-
StackSym * m_scriptContextSym;
685-
StackSym * m_functionBodySym;
686-
StackSym * m_localClosureSym;
687-
StackSym * m_paramClosureSym;
688-
StackSym * m_localFrameDisplaySym;
689-
StackSym * m_bailoutReturnValueSym;
690-
StackSym * m_hasBailedOutSym;
652+
691653
uint m_forInLoopMaxDepth;
692654
uint m_forInLoopBaseDepth;
693655
int32 m_forInEnumeratorArrayOffset;
@@ -721,8 +683,6 @@ static const unsigned __int64 c_debugFillPattern8 = 0xcececececececece;
721683
FlowGraph * m_fg;
722684
unsigned int m_labelCount;
723685
BitVector m_regsUsed;
724-
StackSym * tempSymDouble;
725-
StackSym * tempSymBool;
726686
uint32 loopCount;
727687
uint32 unoptimizableArgumentsObjReference;
728688
uint32 unoptimizableArgumentsObjReferenceInInlinees;
@@ -1005,8 +965,6 @@ static const unsigned __int64 c_debugFillPattern8 = 0xcececececececece;
1005965
StackSym* GetStackSymForFormal(Js::ArgSlot formalsIndex);
1006966
bool HasStackSymForFormal(Js::ArgSlot formalsIndex);
1007967

1008-
void SetScopeObjSym(StackSym * sym);
1009-
StackSym * GetScopeObjSym();
1010968
bool IsTrackCompoundedIntOverflowDisabled() const;
1011969
bool IsArrayCheckHoistDisabled() const;
1012970
bool IsStackArgOptDisabled() const;
@@ -1039,9 +997,6 @@ static const unsigned __int64 c_debugFillPattern8 = 0xcececececececece;
1039997

1040998
IR::LabelInstr * m_bailOutNoSaveLabel;
1041999

1042-
StackSym * GetNativeCodeDataSym() const;
1043-
void SetNativeCodeDataSym(StackSym * sym);
1044-
10451000
private:
10461001
Js::EntryPointInfo* m_entryPointInfo; // for in-proc JIT only
10471002

@@ -1051,7 +1006,6 @@ static const unsigned __int64 c_debugFillPattern8 = 0xcececececececece;
10511006
#endif
10521007
Func * const topFunc;
10531008
Func * const parentFunc;
1054-
StackSym * m_inlineeFrameStartSym;
10551009
IR::Instr * inlineeStart;
10561010
uint maxInlineeArgOutSize;
10571011
const bool m_isBackgroundJIT;
@@ -1078,11 +1032,9 @@ static const unsigned __int64 c_debugFillPattern8 = 0xcececececececece;
10781032
YieldOffsetResumeLabelList * m_yieldOffsetResumeLabelList;
10791033
StackArgWithFormalsTracker * stackArgWithFormalsTracker;
10801034
ObjTypeSpecFldInfo ** m_globalObjTypeSpecFldInfoArray;
1081-
StackSym *CreateInlineeStackSym();
10821035
IR::SymOpnd *GetInlineeOpndAtOffset(int32 offset);
10831036
bool HasLocalVarSlotCreated() const { return m_localVarSlotsOffset != Js::Constants::InvalidOffset; }
10841037
void EnsureLocalVarSlots();
1085-
StackSym * m_nativeCodeDataSym;
10861038
SList<IR::RegOpnd *> constantAddressRegOpnd;
10871039
IR::Instr * lastConstantAddressRegLoadInstr;
10881040
bool canHoistConstantAddressLoad;
@@ -1100,7 +1052,56 @@ static const unsigned __int64 c_debugFillPattern8 = 0xcececececececece;
11001052
Lowerer* m_lowerer;
11011053
#endif
11021054

1055+
private:
1056+
StackSym* m_localClosureSym;
1057+
StackSym* m_paramClosureSym;
1058+
StackSym* m_localFrameDisplaySym;
1059+
StackSym* m_nativeCodeDataSym;
1060+
StackSym* m_inlineeFrameStartSym;
1061+
StackSym* m_loopParamSym;
1062+
StackSym* m_bailoutReturnValueSym;
1063+
StackSym* m_hasBailedOutSym;
1064+
1065+
public:
1066+
StackSym* tempSymDouble;
1067+
StackSym* tempSymBool;
1068+
1069+
// StackSyms' corresponding getters/setters
1070+
void SetInlineeFrameStartSym(StackSym* sym)
1071+
{
1072+
Assert(m_inlineeFrameStartSym == nullptr);
1073+
m_inlineeFrameStartSym = sym;
1074+
}
1075+
1076+
StackSym* EnsureHasBailedOutSym();
1077+
StackSym* GetHasBailedOutSym() const { return m_hasBailedOutSym; }
1078+
1079+
StackSym* EnsureBailoutReturnValueSym();
1080+
StackSym* GetBailoutReturnValueSym() const { return m_bailoutReturnValueSym; }
1081+
1082+
StackSym* EnsureLoopParamSym();
1083+
StackSym* GetLoopParamSym() const { return m_loopParamSym; }
1084+
1085+
StackSym* GetLocalClosureSym() const { return m_localClosureSym; }
1086+
void SetLocalClosureSym(StackSym* sym) { m_localClosureSym = sym; }
1087+
1088+
StackSym* GetParamClosureSym() const { return m_paramClosureSym; }
1089+
void SetParamClosureSym(StackSym* sym) { m_paramClosureSym = sym; }
1090+
1091+
StackSym* GetLocalFrameDisplaySym() const { return m_localFrameDisplaySym; }
1092+
void SetLocalFrameDisplaySym(StackSym* sym) { m_localFrameDisplaySym = sym; }
1093+
1094+
void SetScopeObjSym(StackSym* sym);
1095+
StackSym* GetScopeObjSym();
1096+
1097+
StackSym* GetNativeCodeDataSym() const;
1098+
void SetNativeCodeDataSym(StackSym* sym);
1099+
1100+
StackSym* CreateInlineeStackSym();
1101+
11031102
// Lazy bailout
1103+
// The stack sym is used to store the pointer to
1104+
// the BailOutRecord associated with the lazy bailout point
11041105
private:
11051106
bool hasLazyBailOut : 1;
11061107
StackSym * m_lazyBailOutRecordSlot;

lib/Backend/Lower.cpp

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6823,7 +6823,7 @@ Lowerer::GenerateNewStackScFunc(IR::Instr * newScFuncInstr, IR::RegOpnd ** ppEnv
68236823
else
68246824
{
68256825
Assert(func->IsTopFunc());
6826-
Assert(func->m_loopParamSym);
6826+
Assert(func->GetLoopParamSym());
68276827

68286828
IR::Instr * envDefInstr = envOpnd->AsRegOpnd()->m_sym->m_instrDef;
68296829
Assert(envDefInstr && envDefInstr->m_opcode == Js::OpCode::NewScFuncData);
@@ -27923,10 +27923,10 @@ Lowerer::LowerTry(IR::Instr* instr, bool tryCatch)
2792327923
{
2792427924
if (this->m_func->hasBailout)
2792527925
{
27926-
this->EnsureBailoutReturnValueSym();
27926+
m_func->EnsureBailoutReturnValueSym();
2792727927
}
27928-
this->EnsureHasBailedOutSym();
27929-
IR::SymOpnd * hasBailedOutOpnd = IR::SymOpnd::New(this->m_func->m_hasBailedOutSym, TyUint32, this->m_func);
27928+
m_func->EnsureHasBailedOutSym();
27929+
IR::SymOpnd * hasBailedOutOpnd = IR::SymOpnd::New(this->m_func->GetHasBailedOutSym(), TyUint32, this->m_func);
2793027930
IR::Instr * setInstr = IR::Instr::New(LowererMD::GetStoreOp(TyUint32), hasBailedOutOpnd, IR::IntConstOpnd::New(0, TyUint32, this->m_func), this->m_func);
2793127931
instr->InsertBefore(setInstr);
2793227932
LowererMD::Legalize(setInstr);
@@ -27975,26 +27975,6 @@ Lowerer::LowerLeave(IR::Instr * leaveInstr, IR::LabelInstr * targetInstr, bool f
2797527975
return instrPrev;
2797627976
}
2797727977

27978-
void
27979-
Lowerer::EnsureBailoutReturnValueSym()
27980-
{
27981-
if (this->m_func->m_bailoutReturnValueSym == nullptr)
27982-
{
27983-
this->m_func->m_bailoutReturnValueSym = StackSym::New(TyVar, this->m_func);
27984-
this->m_func->StackAllocate(this->m_func->m_bailoutReturnValueSym, sizeof(Js::Var));
27985-
}
27986-
}
27987-
27988-
void
27989-
Lowerer::EnsureHasBailedOutSym()
27990-
{
27991-
if (this->m_func->m_hasBailedOutSym == nullptr)
27992-
{
27993-
this->m_func->m_hasBailedOutSym = StackSym::New(TyUint32, this->m_func);
27994-
this->m_func->StackAllocate(this->m_func->m_hasBailedOutSym, MachRegInt);
27995-
}
27996-
}
27997-
2799827978
void
2799927979
Lowerer::InsertReturnThunkForRegion(Region* region, IR::LabelInstr* restoreLabel)
2800027980
{
@@ -28072,7 +28052,7 @@ void
2807228052
Lowerer::SetHasBailedOut(IR::Instr * bailoutInstr)
2807328053
{
2807428054
Assert(this->m_func->isPostLayout);
28075-
IR::SymOpnd * hasBailedOutOpnd = IR::SymOpnd::New(this->m_func->m_hasBailedOutSym, TyUint32, this->m_func);
28055+
IR::SymOpnd * hasBailedOutOpnd = IR::SymOpnd::New(this->m_func->GetHasBailedOutSym(), TyUint32, this->m_func);
2807628056
IR::Instr * setInstr = IR::Instr::New(LowererMD::GetStoreOp(TyUint32), hasBailedOutOpnd, IR::IntConstOpnd::New(1, TyUint32, this->m_func), this->m_func);
2807728057
bailoutInstr->InsertBefore(setInstr);
2807828058
LowererMD::Legalize(setInstr);
@@ -28122,7 +28102,7 @@ Lowerer::EmitSaveEHBailoutReturnValueAndJumpToRetThunk(IR::Instr * insertAfterIn
2812228102
// MOV bailoutReturnValueSym, eax
2812328103
// JMP $currentRegion->bailoutReturnThunkLabel
2812428104

28125-
IR::SymOpnd * bailoutReturnValueSymOpnd = IR::SymOpnd::New(this->m_func->m_bailoutReturnValueSym, TyVar, this->m_func);
28105+
IR::SymOpnd * bailoutReturnValueSymOpnd = IR::SymOpnd::New(this->m_func->GetBailoutReturnValueSym(), TyVar, this->m_func);
2812628106
IR::RegOpnd *eaxOpnd = IR::RegOpnd::New(NULL, LowererMD::GetRegReturn(TyMachReg), TyMachReg, this->m_func);
2812728107
IR::Instr * movInstr = IR::Instr::New(LowererMD::GetStoreOp(TyVar), bailoutReturnValueSymOpnd, eaxOpnd, this->m_func);
2812828108
insertAfterInstr->InsertAfter(movInstr);
@@ -28141,7 +28121,7 @@ Lowerer::EmitRestoreReturnValueFromEHBailout(IR::LabelInstr * restoreLabel, IR::
2814128121
// MOV eax, bailoutReturnValueSym
2814228122
// $epilog:
2814328123

28144-
IR::SymOpnd * bailoutReturnValueSymOpnd = IR::SymOpnd::New(this->m_func->m_bailoutReturnValueSym, TyVar, this->m_func);
28124+
IR::SymOpnd * bailoutReturnValueSymOpnd = IR::SymOpnd::New(this->m_func->GetBailoutReturnValueSym(), TyVar, this->m_func);
2814528125
IR::RegOpnd * eaxOpnd = IR::RegOpnd::New(NULL, LowererMD::GetRegReturn(TyMachReg), TyMachReg, this->m_func);
2814628126

2814728127
IR::Instr * movInstr = IR::Instr::New(LowererMD::GetLoadOp(TyVar), eaxOpnd, bailoutReturnValueSymOpnd, this->m_func);

lib/Backend/Lower.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,6 @@ class Lowerer
785785
IR::Instr* LowerTry(IR::Instr* instr, bool tryCatch);
786786
IR::Instr * LowerCatch(IR::Instr *instr);
787787
IR::Instr * LowerLeave(IR::Instr *instr, IR::LabelInstr * targetInstr, bool fromFinalLower, bool isOrphanedLeave = false);
788-
void EnsureBailoutReturnValueSym();
789-
void EnsureHasBailedOutSym();
790788
void InsertReturnThunkForRegion(Region* region, IR::LabelInstr* restoreLabel);
791789
void SetHasBailedOut(IR::Instr * bailoutInstr);
792790
IR::Instr* EmitEHBailoutStackRestore(IR::Instr * bailoutInstr);

lib/Backend/LowerMDShared.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ LowererMD::LowerTry(IR::Instr *tryInstr, IR::JnHelperMethod helperMethod)
399399
if (tryInstr->m_opcode == Js::OpCode::TryCatch || (this->m_func->DoOptimizeTry() || (this->m_func->IsSimpleJit() && this->m_func->hasBailout)))
400400
{
401401
// Arg 4 : hasBailedOutOffset
402-
IR::Opnd * hasBailedOutOffset = IR::IntConstOpnd::New(this->m_func->m_hasBailedOutSym->m_offset, TyInt32, this->m_func);
402+
IR::Opnd * hasBailedOutOffset = IR::IntConstOpnd::New(this->m_func->GetHasBailedOutSym()->m_offset, TyInt32, this->m_func);
403403
this->LoadHelperArgument(tryAddr, hasBailedOutOffset);
404404
}
405405
#ifdef _M_X64
@@ -571,8 +571,8 @@ LowererMD::LoadStackArgPtr(IR::Instr * instr)
571571
// t1 = MOV [prm1 + m_inParams]
572572
// dst = LEA &[t1 + sizeof(var)]
573573

574-
Assert(this->m_func->m_loopParamSym);
575-
IR::RegOpnd *baseOpnd = IR::RegOpnd::New(this->m_func->m_loopParamSym, TyMachReg, this->m_func);
574+
Assert(this->m_func->GetLoopParamSym());
575+
IR::RegOpnd *baseOpnd = IR::RegOpnd::New(this->m_func->GetLoopParamSym(), TyMachReg, this->m_func);
576576
size_t offset = Js::InterpreterStackFrame::GetOffsetOfInParams();
577577
IR::IndirOpnd *indirOpnd = IR::IndirOpnd::New(baseOpnd, (int32)offset, TyMachReg, this->m_func);
578578
IR::RegOpnd *tmpOpnd = IR::RegOpnd::New(TyMachReg, this->m_func);
@@ -597,8 +597,8 @@ LowererMD::LoadArgumentsFromFrame(IR::Instr * instr)
597597
if (this->m_func->IsLoopBody())
598598
{
599599
// Get the arguments ptr from the interpreter frame instance that was passed in.
600-
Assert(this->m_func->m_loopParamSym);
601-
IR::RegOpnd *baseOpnd = IR::RegOpnd::New(this->m_func->m_loopParamSym, TyMachReg, this->m_func);
600+
Assert(this->m_func->GetLoopParamSym());
601+
IR::RegOpnd *baseOpnd = IR::RegOpnd::New(this->m_func->GetLoopParamSym(), TyMachReg, this->m_func);
602602
int32 offset = (int32)Js::InterpreterStackFrame::GetOffsetOfArguments();
603603
instr->SetSrc1(IR::IndirOpnd::New(baseOpnd, offset, TyMachReg, this->m_func));
604604
}
@@ -620,8 +620,8 @@ LowererMD::LoadArgumentCount(IR::Instr * instr)
620620
{
621621
// Pull the arg count from the interpreter frame instance that was passed in.
622622
// (The callinfo in the loop body's frame just shows the single parameter, the interpreter frame.)
623-
Assert(this->m_func->m_loopParamSym);
624-
IR::RegOpnd *baseOpnd = IR::RegOpnd::New(this->m_func->m_loopParamSym, TyMachReg, this->m_func);
623+
Assert(this->m_func->GetLoopParamSym());
624+
IR::RegOpnd *baseOpnd = IR::RegOpnd::New(this->m_func->GetLoopParamSym(), TyMachReg, this->m_func);
625625
size_t offset = Js::InterpreterStackFrame::GetOffsetOfInSlotsCount();
626626
instr->SetSrc1(IR::IndirOpnd::New(baseOpnd, (int32)offset, TyInt32, this->m_func));
627627
}

lib/Backend/Opnd.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3302,22 +3302,7 @@ Opnd::Dump(IRDumpFlags flags, Func *func)
33023302
{
33033303
Output::Print(_u("[isTempLastUse]"));
33043304
}
3305-
StackSym *sym = regOpnd->GetStackSym();
3306-
if (sym && func)
3307-
{
3308-
if (sym == func->GetScriptContextSym())
3309-
{
3310-
Output::Print(_u("[ScriptContext]"));
3311-
}
3312-
else if (sym == func->GetFuncObjSym())
3313-
{
3314-
Output::Print(_u("[FuncObj]"));
3315-
}
3316-
else if (sym == func->GetFunctionBodySym())
3317-
{
3318-
Output::Print(_u("[FunctionBody]"));
3319-
}
3320-
}
3305+
33213306
if(regOpnd->IsArrayRegOpnd())
33223307
{
33233308
if(dumpValueType)

0 commit comments

Comments
 (0)