Skip to content

Commit

Permalink
[1.4>2.0] [MERGE #2697 @MikeHolman] 17-03 ChakraCore servicing release
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeHolman committed Mar 17, 2017
2 parents 8cb9bdc + 6c529db commit e5d4107
Show file tree
Hide file tree
Showing 50 changed files with 928 additions and 600 deletions.
2 changes: 2 additions & 0 deletions lib/Backend/BackwardPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2535,6 +2535,8 @@ BackwardPass::ProcessBlock(BasicBlock * block)
}
#endif

AssertOrFailFastMsg(!instr->IsLowered(), "Lowered instruction detected in pre-lower context!");

this->currentInstr = instr;
this->currentRegion = this->currentBlock->GetFirstInstr()->AsLabelInstr()->GetRegion();

Expand Down
2 changes: 0 additions & 2 deletions lib/Backend/GlobOptFields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3194,8 +3194,6 @@ GlobOpt::UpdateObjPtrValueType(IR::Opnd * opnd, IR::Instr * instr)
}
break;
case Js::TypeIds_Array:
case Js::TypeIds_NativeFloatArray:
case Js::TypeIds_NativeIntArray:
// Because array can change type id, we can only make it definite if we are doing array check hoist
// so that implicit call will be installed between the array checks.
if (!DoArrayCheckHoist() ||
Expand Down
1 change: 1 addition & 0 deletions lib/Backend/IR.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ class Instr
bool dstIsAlwaysConvertedToNumber : 1;
bool isCallInstrProtectedByNoProfileBailout : 1;
bool hasSideEffects : 1; // The instruction cannot be dead stored
bool isNonFastPathFrameDisplay : 1;
protected:
bool isCloned:1;
bool hasBailOutInfo:1;
Expand Down
24 changes: 9 additions & 15 deletions lib/Backend/IRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ IRBuilder::Build()
}
}
#endif
AssertMsg(Js::OpCodeUtil::IsValidByteCodeOpcode(newOpcode), "Error getting opcode from m_jnReader.Op()");
AssertOrFailFastMsg(Js::OpCodeUtil::IsValidByteCodeOpcode(newOpcode), "Error getting opcode from m_jnReader.Op()");

uint layoutAndSize = layoutSize * Js::OpLayoutType::Count + Js::OpCodeUtil::GetOpCodeLayout(newOpcode);
switch(layoutAndSize)
Expand Down Expand Up @@ -6824,22 +6824,16 @@ IRBuilder::BuildEmpty(Js::OpCode newOpcode, uint32 offset)
Js::Constants::NoByteCodeOffset);
}

IR::RegOpnd* tempRegOpnd = IR::RegOpnd::New(StackSym::New(this->m_func), TyVar, this->m_func);
IR::Instr* lfd = IR::Instr::New(
Js::OpCode::LdFrameDisplay,
this->BuildDstOpnd(this->m_func->GetJITFunctionBody()->GetLocalFrameDisplayReg()),
this->BuildDstOpnd(this->m_func->GetJITFunctionBody()->GetLocalClosureReg()),
this->BuildDstOpnd(this->m_func->GetJITFunctionBody()->GetLocalFrameDisplayReg()),
this->m_func);
this->AddInstr(
IR::Instr::New(
Js::OpCode::LdFrameDisplay,
tempRegOpnd,
this->BuildSrcOpnd(this->m_func->GetJITFunctionBody()->GetLocalClosureReg()),
this->BuildSrcOpnd(this->m_func->GetJITFunctionBody()->GetLocalFrameDisplayReg()),
this->m_func),
Js::Constants::NoByteCodeOffset);
this->AddInstr(
IR::Instr::New(
Js::OpCode::MOV,
this->BuildDstOpnd(this->m_func->GetJITFunctionBody()->GetLocalFrameDisplayReg()),
tempRegOpnd,
this->m_func),
lfd,
Js::Constants::NoByteCodeOffset);
lfd->isNonFastPathFrameDisplay = true;
}
break;

Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/IRBuilderAsmJs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ IRBuilderAsmJs::Build()
{
Assert(newOpcode != Js::OpCodeAsmJs::EndOfBlock);

AssertMsg(Js::OpCodeUtilAsmJs::IsValidByteCodeOpcode(newOpcode), "Error getting opcode from m_jnReader.Op()");
AssertOrFailFastMsg(Js::OpCodeUtilAsmJs::IsValidByteCodeOpcode(newOpcode), "Error getting opcode from m_jnReader.Op()");

uint layoutAndSize = layoutSize * Js::OpLayoutTypeAsmJs::Count + Js::OpCodeUtilAsmJs::GetOpCodeLayout(newOpcode);
switch (layoutAndSize)
Expand Down
9 changes: 5 additions & 4 deletions lib/Backend/Lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12884,13 +12884,13 @@ void Lowerer::LowerBoundCheck(IR::Instr *const instr)
// jo $bailOut
// $bailOut: (insertBeforeInstr)
Assert(!offsetOpnd || offsetOpnd->GetValue() == offset);
IR::RegOpnd *const addResultOpnd = IR::RegOpnd::New(TyMachReg, func);
IR::RegOpnd *const addResultOpnd = IR::RegOpnd::New(TyInt32, func);
autoReuseAddResultOpnd.Initialize(addResultOpnd, func);
InsertAdd(
true,
addResultOpnd,
rightOpnd,
offsetOpnd ? offsetOpnd->UseWithNewType(TyMachReg, func) : IR::IntConstOpnd::New(offset, TyMachReg, func, true),
offsetOpnd ? offsetOpnd->UseWithNewType(TyInt32, func) : IR::IntConstOpnd::New(offset, TyInt32, func, true),
insertBeforeInstr);
InsertBranch(LowererMD::MDOverflowBranchOpcode, bailOutLabel, insertBeforeInstr);

Expand Down Expand Up @@ -17114,7 +17114,8 @@ Lowerer::GenerateFastStElemI(IR::Instr *& stElem, bool *instrIsInHelperBlockRef)

// Convert reg to int32
// Note: ToUint32 is implemented as (uint32)ToInt32()
m_lowererMD.EmitLoadInt32(instr, true /*conversionFromObjectAllowed*/);
bool bailOutOnHelperCall = (stElem->HasBailOutInfo() && (stElem->GetBailOutKind() & IR::BailOutOnArrayAccessHelperCall));
m_lowererMD.EmitLoadInt32(instr, true /*conversionFromObjectAllowed*/, bailOutOnHelperCall, labelHelper);

// MOV indirOpnd, reg
InsertMove(indirOpnd, reg, stElem);
Expand Down Expand Up @@ -23522,7 +23523,7 @@ void Lowerer::LowerLdFrameDisplay(IR::Instr *instr, bool doStackFrameDisplay)
// If the dst opnd is a byte code temp, that indicates we're prepending a block scope or some such and
// shouldn't attempt to do this.
if (envDepth == (uint16)-1 ||
(!doStackFrameDisplay && instr->GetDst()->AsRegOpnd()->m_sym->IsTempReg(instr->m_func)) ||
(!doStackFrameDisplay && (instr->isNonFastPathFrameDisplay || instr->GetDst()->AsRegOpnd()->m_sym->IsTempReg(instr->m_func))) ||
PHASE_OFF(Js::FrameDisplayFastPathPhase, func))
{
if (isStrict)
Expand Down
4 changes: 2 additions & 2 deletions lib/Backend/LowerMDShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7999,9 +7999,9 @@ LowererMD::EmitLoadVar(IR::Instr *instrLoad, bool isFromUint32, bool isHelper)
}

bool
LowererMD::EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllowed)
LowererMD::EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllowed, bool bailOutOnHelper, IR::LabelInstr * labelBailOut)
{
return lowererMDArch.EmitLoadInt32(instrLoad, conversionFromObjectAllowed);
return lowererMDArch.EmitLoadInt32(instrLoad, conversionFromObjectAllowed, bailOutOnHelper, labelBailOut);
}

void
Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/LowerMDShared.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class LowererMD
static void EmitPtrInstr(IR::Instr *instr);
void EmitLoadVar(IR::Instr *instr, bool isFromUint32 = false, bool isHelper = false);
void EmitLoadVarNoCheck(IR::RegOpnd * dst, IR::RegOpnd * src, IR::Instr *instrLoad, bool isFromUint32, bool isHelper);
bool EmitLoadInt32(IR::Instr *instr, bool conversionFromObjectAllowed);
bool EmitLoadInt32(IR::Instr *instr, bool conversionFromObjectAllowed, bool bailOutOnHelper = false, IR::LabelInstr * labelBailOut = nullptr);
void EmitIntToFloat(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrInsert);
void EmitUIntToFloat(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrInsert);
void EmitIntToLong(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrInsert);
Expand Down
41 changes: 36 additions & 5 deletions lib/Backend/amd64/LowererMDArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,9 @@ LowererMDArch::LowerAsmJsLdElemHelper(IR::Instr * instr, bool isSimdLoad /*= fal
// MOV tmp, cmpOnd
Lowerer::InsertMove(tmp, cmpOpnd, helperLabel);
// ADD tmp, dataWidth
Lowerer::InsertAdd(false, tmp, tmp, IR::IntConstOpnd::New((uint32)dataWidth, tmp->GetType(), m_func, true), helperLabel);
Lowerer::InsertAdd(true, tmp, tmp, IR::IntConstOpnd::New((uint32)dataWidth, tmp->GetType(), m_func, true), helperLabel);
// JB helper
Lowerer::InsertBranch(Js::OpCode::JB, helperLabel, helperLabel);
// CMP tmp, size
// JG $helper
lowererMD->m_lowerer->InsertCompareBranch(tmp, instr->UnlinkSrc2(), Js::OpCode::BrGt_A, true, helperLabel, helperLabel);
Expand Down Expand Up @@ -1259,7 +1261,9 @@ LowererMDArch::LowerAsmJsStElemHelper(IR::Instr * instr, bool isSimdStore /*= fa
// MOV tmp, cmpOnd
Lowerer::InsertMove(tmp, cmpOpnd, helperLabel);
// ADD tmp, dataWidth
Lowerer::InsertAdd(false, tmp, tmp, IR::IntConstOpnd::New((uint32)dataWidth, tmp->GetType(), m_func, true), helperLabel);
Lowerer::InsertAdd(true, tmp, tmp, IR::IntConstOpnd::New((uint32)dataWidth, tmp->GetType(), m_func, true), helperLabel);
// JB helper
Lowerer::InsertBranch(Js::OpCode::JB, helperLabel, helperLabel);
// CMP tmp, size
// JG $helper
lowererMD->m_lowerer->InsertCompareBranch(tmp, instr->UnlinkSrc2(), Js::OpCode::BrGt_A, true, helperLabel, helperLabel);
Expand Down Expand Up @@ -2611,7 +2615,7 @@ LowererMDArch::EmitUIntToFloat(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrIns
}

bool
LowererMDArch::EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllowed)
LowererMDArch::EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllowed, bool bailOutOnHelper, IR::LabelInstr * labelBailOut)
{
//
// r1 = MOV src1
Expand Down Expand Up @@ -2664,8 +2668,29 @@ LowererMDArch::EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllo
(src1ValueType.IsLikelyFloat() || src1ValueType.IsLikelyUntaggedInt()) &&
!(instrLoad->HasBailOutInfo() && (instrLoad->GetBailOutKind() == IR::BailOutIntOnly || instrLoad->GetBailOutKind() == IR::BailOutExpectingInteger));

if (!isNotInt)
if (isNotInt)
{
// Known to be non-integer. If we are required to bail out on helper call, just re-jit.
if (!doFloatToIntFastPath && bailOutOnHelper)
{
if(!GlobOpt::DoAggressiveIntTypeSpec(this->m_func))
{
// Aggressive int type specialization is already off for some reason. Prevent trying to rejit again
// because it won't help and the same thing will happen again. Just abort jitting this function.
if(PHASE_TRACE(Js::BailOutPhase, this->m_func))
{
Output::Print(_u(" Aborting JIT because AggressiveIntTypeSpec is already off\n"));
Output::Flush();
}
throw Js::OperationAbortedException();
}

throw Js::RejitException(RejitReason::AggressiveIntTypeSpecDisabled);
}
}
else
{
// It could be an integer in this case.
if (!isInt)
{
if(doFloatToIntFastPath)
Expand Down Expand Up @@ -2753,7 +2778,13 @@ LowererMDArch::EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllo
return true;
}

if (conversionFromObjectAllowed)
if (bailOutOnHelper)
{
Assert(labelBailOut);
lowererMD->m_lowerer->InsertBranch(Js::OpCode::Br, labelBailOut, instrLoad);
instrLoad->Remove();
}
else if (conversionFromObjectAllowed)
{
lowererMD->m_lowerer->LowerUnaryHelperMem(instrLoad, IR::HelperConv_ToInt32);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/amd64/LowererMDArch.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class LowererMDArch
void EmitIntToLong(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrInsert);
void EmitUIntToLong(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrInsert);
void EmitLongToInt(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrInsert);
bool EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllowed);
bool EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllowed, bool bailOnHelperCall, IR::LabelInstr * labelBailOut);

IR::Instr * LoadCheckedFloat(IR::RegOpnd *opndOrig, IR::RegOpnd *opndFloat, IR::LabelInstr *labelInline, IR::LabelInstr *labelHelper, IR::Instr *instrInsert, const bool checkForNullInLoopBody = false);

Expand Down
33 changes: 30 additions & 3 deletions lib/Backend/arm/LowerMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7342,7 +7342,7 @@ LowererMD::EmitLoadVarNoCheck(IR::RegOpnd * dst, IR::RegOpnd * src, IR::Instr *i
}

bool
LowererMD::EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllowed)
LowererMD::EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllowed, bool bailOutOnHelper, IR::LabelInstr * labelBailOut)
{
// isInt:
// dst = ASR r1, AtomTag
Expand Down Expand Up @@ -7386,8 +7386,29 @@ LowererMD::EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllowed)
(src1ValueType.IsLikelyFloat() || src1ValueType.IsLikelyUntaggedInt()) &&
!(instrLoad->HasBailOutInfo() && (instrLoad->GetBailOutKind() == IR::BailOutIntOnly || instrLoad->GetBailOutKind() == IR::BailOutExpectingInteger));

if (!isNotInt)
if (isNotInt)
{
// Known to be non-integer. If we are required to bail out on helper call, just re-jit.
if (!doFloatToIntFastPath && bailOutOnHelper)
{
if(!GlobOpt::DoAggressiveIntTypeSpec(this->m_func))
{
// Aggressive int type specialization is already off for some reason. Prevent trying to rejit again
// because it won't help and the same thing will happen again. Just abort jitting this function.
if(PHASE_TRACE(Js::BailOutPhase, this->m_func))
{
Output::Print(_u(" Aborting JIT because AggressiveIntTypeSpec is already off\n"));
Output::Flush();
}
throw Js::OperationAbortedException();
}

throw Js::RejitException(RejitReason::AggressiveIntTypeSpecDisabled);
}
}
else
{
// Could be an integer in this case.
if (!isInt)
{
if(doFloatToIntFastPath)
Expand Down Expand Up @@ -7444,7 +7465,13 @@ LowererMD::EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllowed)
return true;
}

if (conversionFromObjectAllowed)
if (bailOutOnHelper)
{
Assert(labelBailOut);
this->m_lowerer->InsertBranch(Js::OpCode::Br, labelBailOut, instrLoad);
instrLoad->Remove();
}
else if (conversionFromObjectAllowed)
{
this->m_lowerer->LowerUnaryHelperMem(instrLoad, IR::HelperConv_ToInt32);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/arm/LowerMD.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class LowererMD
static void EmitInt4Instr(IR::Instr *instr);
static void EmitPtrInstr(IR::Instr *instr);
void EmitLoadVar(IR::Instr *instr, bool isFromUint32 = false, bool isHelper = false);
bool EmitLoadInt32(IR::Instr *instr, bool conversionFromObjectAllowed);
bool EmitLoadInt32(IR::Instr *instr, bool conversionFromObjectAllowed, bool bailOutOnHelper = false, IR::LabelInstr * labelBailOut = nullptr);
IR::Instr * LowerInt64Assign(IR::Instr * instr) { Assert(UNREACHED); return nullptr; }

static void LowerInt4NegWithBailOut(IR::Instr *const instr, const IR::BailOutKind bailOutKind, IR::LabelInstr *const bailOutLabel, IR::LabelInstr *const skipBailOutLabel);
Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/arm64/LowerMD.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class LowererMD
static void EmitInt4Instr(IR::Instr *instr) { __debugbreak(); }
static void EmitPtrInstr(IR::Instr *instr) { __debugbreak(); }
void EmitLoadVar(IR::Instr *instr, bool isFromUint32 = false, bool isHelper = false) { __debugbreak(); }
bool EmitLoadInt32(IR::Instr *instr, bool conversionFromObjectAllowed) { __debugbreak(); return 0; }
bool EmitLoadInt32(IR::Instr *instr, bool conversionFromObjectAllowed, bool bailOutOnHelper = false, IR::LabelInstr * labelBailOut = nullptr) { __debugbreak(); return 0; }
IR::Instr * LowerInt64Assign(IR::Instr * instr) { __debugbreak(); return nullptr; }

static void LowerInt4NegWithBailOut(IR::Instr *const instr, const IR::BailOutKind bailOutKind, IR::LabelInstr *const bailOutLabel, IR::LabelInstr *const skipBailOutLabel) { __debugbreak(); }
Expand Down
42 changes: 36 additions & 6 deletions lib/Backend/i386/LowererMDArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,9 @@ LowererMDArch::LowerAsmJsLdElemHelper(IR::Instr * instr, bool isSimdLoad /*= fal
// MOV tmp, cmpOnd
Lowerer::InsertMove(tmp, cmpOpnd, helperLabel);
// ADD tmp, dataWidth
Lowerer::InsertAdd(false, tmp, tmp, IR::IntConstOpnd::New((uint32)dataWidth, tmp->GetType(), m_func, true), helperLabel);
Lowerer::InsertAdd(true, tmp, tmp, IR::IntConstOpnd::New((uint32)dataWidth, tmp->GetType(), m_func, true), helperLabel);
// JB helper
Lowerer::InsertBranch(Js::OpCode::JB, helperLabel, helperLabel);
// CMP tmp, size
// JG $helper
lowererMD->m_lowerer->InsertCompareBranch(tmp, instr->UnlinkSrc2(), Js::OpCode::BrGt_A, true, helperLabel, helperLabel);
Expand Down Expand Up @@ -1087,7 +1089,9 @@ LowererMDArch::LowerAsmJsStElemHelper(IR::Instr * instr, bool isSimdStore /*= fa
// MOV tmp, cmpOnd
Lowerer::InsertMove(tmp, cmpOpnd, helperLabel);
// ADD tmp, dataWidth
Lowerer::InsertAdd(false, tmp, tmp, IR::IntConstOpnd::New((uint32)dataWidth, tmp->GetType(), m_func, true), helperLabel);
Lowerer::InsertAdd(true, tmp, tmp, IR::IntConstOpnd::New((uint32)dataWidth, tmp->GetType(), m_func, true), helperLabel);
// JB helper
Lowerer::InsertBranch(Js::OpCode::JB, helperLabel, helperLabel);
// CMP tmp, size
// JG $helper
lowererMD->m_lowerer->InsertCompareBranch(tmp, instr->UnlinkSrc2(), Js::OpCode::BrGt_A, true, helperLabel, helperLabel);
Expand Down Expand Up @@ -2605,7 +2609,7 @@ LowererMDArch::EmitLongToInt(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrInser
}

bool
LowererMDArch::EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllowed)
LowererMDArch::EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllowed, bool bailOutOnHelper, IR::LabelInstr * labelBailOut)
{
// if(doShiftFirst)
// {
Expand Down Expand Up @@ -2663,9 +2667,29 @@ LowererMDArch::EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllo
instrLoad->InsertBefore(instr);
}

// It could be an integer in this case
if (!isNotInt)
if (isNotInt)
{
// Known to be non-integer. If we are required to bail out on helper call, just re-jit.
if (!doFloatToIntFastPath && bailOutOnHelper)
{
if(!GlobOpt::DoAggressiveIntTypeSpec(this->m_func))
{
// Aggressive int type specialization is already off for some reason. Prevent trying to rejit again
// because it won't help and the same thing will happen again. Just abort jitting this function.
if(PHASE_TRACE(Js::BailOutPhase, this->m_func))
{
Output::Print(_u(" Aborting JIT because AggressiveIntTypeSpec is already off\n"));
Output::Flush();
}
throw Js::OperationAbortedException();
}

throw Js::RejitException(RejitReason::AggressiveIntTypeSpecDisabled);
}
}
else
{
// It could be an integer in this case
if(doShiftFirst)
{
// r1 = SAR r1, VarTag_Shift (move last-shifted bit into CF)
Expand Down Expand Up @@ -2781,7 +2805,13 @@ LowererMDArch::EmitLoadInt32(IR::Instr *instrLoad, bool conversionFromObjectAllo
return true;
}

if (conversionFromObjectAllowed)
if (bailOutOnHelper)
{
Assert(labelBailOut);
lowererMD->m_lowerer->InsertBranch(Js::OpCode::Br, labelBailOut, instrLoad);
instrLoad->Remove();
}
else if (conversionFromObjectAllowed)
{
lowererMD->m_lowerer->LowerUnaryHelperMem(instrLoad, IR::HelperConv_ToInt32);
}
Expand Down
Loading

0 comments on commit e5d4107

Please sign in to comment.