Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Byte code size and serialized byte code size optimizations (15-20% serialized byte code size reduction) #3594

Merged
merged 1 commit into from
Sep 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 1 addition & 56 deletions lib/Backend/IRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1988,36 +1988,6 @@ IRBuilder::BuildReg2(Js::OpCode newOpcode, uint32 offset, Js::RegSlot R0, Js::Re
this->AddInstr(instr, offset);
}

template <typename SizePolicy>
void
IRBuilder::BuildReg2WithICIndex(Js::OpCode newOpcode, uint32 offset)
{
AssertMsg(false, "NYI");
}

template <typename SizePolicy>
void
IRBuilder::BuildProfiledReg2WithICIndex(Js::OpCode newOpcode, uint32 offset)
{
Assert(OpCodeAttr::IsProfiledOpWithICIndex(newOpcode));
Assert(OpCodeAttr::HasMultiSizeLayout(newOpcode));
auto layout = m_jnReader.GetLayout<Js::OpLayoutDynamicProfile<Js::OpLayoutT_Reg2WithICIndex<SizePolicy>>>();

if (!PHASE_OFF(Js::ClosureRegCheckPhase, m_func))
{
this->DoClosureRegCheck(layout->R0);
this->DoClosureRegCheck(layout->R1);
}

BuildProfiledReg2WithICIndex(newOpcode, offset, layout->R0, layout->R1, layout->profileId, layout->inlineCacheIndex);
}

void
IRBuilder::BuildProfiledReg2WithICIndex(Js::OpCode newOpcode, uint32 offset, Js::RegSlot dstRegSlot, Js::RegSlot srcRegSlot, Js::ProfileId profileId, Js::InlineCacheIndex inlineCacheIndex)
{
BuildProfiledReg2(newOpcode, offset, dstRegSlot, srcRegSlot, profileId, inlineCacheIndex);
}

///----------------------------------------------------------------------------
///
/// IRBuilder::BuildProfiledReg2
Expand All @@ -2043,7 +2013,7 @@ IRBuilder::BuildProfiledReg2(Js::OpCode newOpcode, uint32 offset)
}

void
IRBuilder::BuildProfiledReg2(Js::OpCode newOpcode, uint32 offset, Js::RegSlot dstRegSlot, Js::RegSlot srcRegSlot, Js::ProfileId profileId, Js::InlineCacheIndex inlineCacheIndex)
IRBuilder::BuildProfiledReg2(Js::OpCode newOpcode, uint32 offset, Js::RegSlot dstRegSlot, Js::RegSlot srcRegSlot, Js::ProfileId profileId)
{
bool switchFound = false;

Expand Down Expand Up @@ -2112,7 +2082,6 @@ IRBuilder::BuildProfiledReg2(Js::OpCode newOpcode, uint32 offset, Js::RegSlot ds
IR::JitProfilingInstr *profiledInstr = IR::JitProfilingInstr::New(newOpcode, dstOpnd, src1Opnd, m_func);
profiledInstr->profileId = profileId;
profiledInstr->isBeginSwitch = newOpcode == Js::OpCode::Ld_A;
profiledInstr->inlineCacheIndex = inlineCacheIndex;
instr = profiledInstr;
}
else if(isProfiled)
Expand Down Expand Up @@ -2834,30 +2803,6 @@ IRBuilder::BuildUnsigned1(Js::OpCode newOpcode, uint32 offset, uint32 num)
}
}

void
IRBuilder::BuildReg1Int2(Js::OpCode newOpcode, uint32 offset)
{
Assert(!OpCodeAttr::HasMultiSizeLayout(newOpcode));

const unaligned Js::OpLayoutReg1Int2 *regLayout = m_jnReader.Reg1Int2();
Js::RegSlot R0 = regLayout->R0;
int32 C1 = regLayout->C1;
int32 C2 = regLayout->C2;

if (!PHASE_OFF(Js::ClosureRegCheckPhase, m_func))
{
this->DoClosureRegCheck(R0);
}

IR::RegOpnd* dstOpnd = this->BuildDstOpnd(R0);

IR::IntConstOpnd * srcOpnd = IR::IntConstOpnd::New(C1, TyInt32, m_func);
IR::IntConstOpnd * src2Opnd = IR::IntConstOpnd::New(C2, TyInt32, m_func);
IR::Instr* instr = IR::Instr::New(newOpcode, dstOpnd, srcOpnd, src2Opnd, m_func);

this->AddInstr(instr, offset);
}

template <typename SizePolicy>
void
IRBuilder::BuildProfiledReg1Unsigned1(Js::OpCode newOpcode, uint32 offset)
Expand Down
3 changes: 1 addition & 2 deletions lib/Backend/IRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ class IRBuilder

void BuildReg1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot R0);
void BuildReg2(Js::OpCode newOpcode, uint32 offset, Js::RegSlot R0, Js::RegSlot R1, uint32 nextOffset);
void BuildProfiledReg2(Js::OpCode newOpcode, uint32 offset, Js::RegSlot dstRegSlot, Js::RegSlot srcRegSlot, Js::ProfileId profileId, Js::InlineCacheIndex inlineCacheIndex = Js::Constants::NoInlineCacheIndex);
void BuildProfiledReg2WithICIndex(Js::OpCode newOpcode, uint32 offset, Js::RegSlot dstRegSlot, Js::RegSlot srcRegSlot, Js::ProfileId profileId, Js::InlineCacheIndex inlineCacheIndex);
void BuildProfiledReg2(Js::OpCode newOpcode, uint32 offset, Js::RegSlot dstRegSlot, Js::RegSlot srcRegSlot, Js::ProfileId profileId);
void BuildReg3(Js::OpCode newOpcode, uint32 offset, Js::RegSlot dstRegSlot, Js::RegSlot src1RegSlot,
Js::RegSlot src2RegSlot, Js::ProfileId profileId);
void BuildReg3C(Js::OpCode newOpCode, uint32 offset, Js::RegSlot dstRegSlot, Js::RegSlot src1RegSlot,
Expand Down
4 changes: 1 addition & 3 deletions lib/Backend/Lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8130,7 +8130,7 @@ Lowerer::LowerUnaryHelperMemWithFuncBody(IR::Instr *instr, IR::JnHelperMethod he
IR::Instr *
Lowerer::LowerBinaryHelperMemWithFuncBody(IR::Instr *instr, IR::JnHelperMethod helperMethod)
{
AssertMsg(Js::OpCodeUtil::GetOpCodeLayout(instr->m_opcode) == Js::OpLayoutType::Reg1Int2, "Expected a binary instruction...");
AssertMsg(Js::OpCodeUtil::GetOpCodeLayout(instr->m_opcode) == Js::OpLayoutType::Reg3, "Expected a binary instruction...");

m_lowererMD.LoadHelperArgument(instr, this->LoadFunctionBodyOpnd(instr));
return this->LowerBinaryHelperMem(instr, helperMethod);
Expand Down Expand Up @@ -8217,7 +8217,6 @@ Lowerer::LowerBinaryHelper(IR::Instr *instr, IR::JnHelperMethod helperMethod)
AssertMsg((Js::OpCodeUtil::GetOpCodeLayout(instr->m_opcode) == Js::OpLayoutType::Reg1Unsigned1 && !instr->GetDst()) ||
Js::OpCodeUtil::GetOpCodeLayout(instr->m_opcode) == Js::OpLayoutType::Reg3 ||
Js::OpCodeUtil::GetOpCodeLayout(instr->m_opcode) == Js::OpLayoutType::Reg2Int1 ||
Js::OpCodeUtil::GetOpCodeLayout(instr->m_opcode) == Js::OpLayoutType::Reg1Int2 ||
Js::OpCodeUtil::GetOpCodeLayout(instr->m_opcode) == Js::OpLayoutType::ElementU ||
instr->m_opcode == Js::OpCode::InvalCachedScope, "Expected a binary instruction...");

Expand All @@ -8241,7 +8240,6 @@ Lowerer::LowerBinaryHelperMem(IR::Instr *instr, IR::JnHelperMethod helperMethod)

AssertMsg(Js::OpCodeUtil::GetOpCodeLayout(instr->m_opcode) == Js::OpLayoutType::Reg3 ||
Js::OpCodeUtil::GetOpCodeLayout(instr->m_opcode) == Js::OpLayoutType::Reg2Int1 ||
Js::OpCodeUtil::GetOpCodeLayout(instr->m_opcode) == Js::OpLayoutType::Reg1Int2 ||
Js::OpCodeUtil::GetOpCodeLayout(instr->m_opcode) == Js::OpLayoutType::Reg1Unsigned1, "Expected a binary instruction...");

instrPrev = LoadScriptContext(instr);
Expand Down
1 change: 0 additions & 1 deletion lib/Common/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ template<> struct IntMath<int64> { using Type = Int64Math; };
#include "DataStructures/GrowingArray.h"
#include "DataStructures/EvalMapString.h"
#include "DataStructures/RegexKey.h"
#include "DataStructures/LineOffsetCache.h"

#include "Core/ICustomConfigFlags.h"
#include "Core/CmdParser.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<ClInclude Include="GrowingArray.h" />
<ClInclude Include="ImmutableList.h" />
<ClInclude Include="Interval.h" />
<ClInclude Include="LineOffsetCache.h" />
<ClInclude Include="LeafValueDictionary.h" />
<ClInclude Include="MruDictionary.h" />
<ClInclude Include="PageStack.h" />
Expand Down
Loading