Skip to content

Commit c1086a2

Browse files
committed
[1.9>master] [1.8>1.9] [MERGE #5116 @MSLaguana] ChakraCore 2018-05 security updates
Merge pull request #5116 from MSLaguana:servicing/1805
2 parents b4e98fa + 865f63b commit c1086a2

37 files changed

+512
-282
lines changed

lib/Backend/BackwardPass.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4141,8 +4141,9 @@ BackwardPass::UpdateArrayBailOutKind(IR::Instr *const instr)
41414141

41424142
IR::BailOutKind includeBailOutKinds = IR::BailOutInvalid;
41434143
if(!baseValueType.IsNotNativeArray() &&
4144-
(!baseValueType.IsLikelyNativeArray() || instr->GetSrc1()->IsVar()) &&
4145-
!currentBlock->noImplicitCallNativeArrayUses->IsEmpty())
4144+
(!baseValueType.IsLikelyNativeArray() || !instr->GetSrc1()->IsInt32()) &&
4145+
!currentBlock->noImplicitCallNativeArrayUses->IsEmpty() &&
4146+
!(instr->GetBailOutKind() & IR::BailOutOnArrayAccessHelperCall))
41464147
{
41474148
// There is an upwards-exposed use of a native array. Since the array referenced by this instruction can be aliased,
41484149
// this instruction needs to bail out if it converts the native array even if this array specifically is not
@@ -4248,6 +4249,11 @@ BackwardPass::ProcessStackSymUse(StackSym * stackSym, BOOLEAN isNonByteCodeUse)
42484249
return true;
42494250
}
42504251

4252+
if (this->DoMarkTempNumbers())
4253+
{
4254+
Assert((block->loop != nullptr) == block->tempNumberTracker->HasTempTransferDependencies());
4255+
block->tempNumberTracker->ProcessUse(stackSym, this);
4256+
}
42514257
if (this->DoMarkTempObjects())
42524258
{
42534259
Assert((block->loop != nullptr) == block->tempObjectTracker->HasTempTransferDependencies());
@@ -4301,17 +4307,7 @@ BackwardPass::ProcessSymUse(Sym * sym, bool isRegOpndUse, BOOLEAN isNonByteCodeU
43014307
}
43024308
}
43034309

4304-
StackSym * stackSym = sym->AsStackSym();
4305-
bool isUsed = ProcessStackSymUse(stackSym, isNonByteCodeUse);
4306-
4307-
if (!IsCollectionPass() && isRegOpndUse && this->DoMarkTempNumbers())
4308-
{
4309-
// Collect mark temp number information
4310-
Assert((block->loop != nullptr) == block->tempNumberTracker->HasTempTransferDependencies());
4311-
block->tempNumberTracker->ProcessUse(stackSym, this);
4312-
}
4313-
4314-
return isUsed;
4310+
return ProcessStackSymUse(sym->AsStackSym(), isNonByteCodeUse);
43154311
}
43164312

43174313
bool

lib/Backend/GlobOpt.cpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6333,6 +6333,8 @@ GlobOpt::OptConstPeep(IR::Instr *instr, IR::Opnd *constSrc, Value **pDstVal, Val
63336333

63346334
instr->m_opcode = Js::OpCode::Ld_A;
63356335

6336+
InvalidateInductionVariables(instr);
6337+
63366338
return true;
63376339
}
63386340

@@ -7010,16 +7012,7 @@ GlobOpt::OptConstFoldUnary(
70107012
}
70117013
}
70127014

7013-
// If this is an induction variable, then treat it the way the prepass would have if it had seen
7014-
// the assignment and the resulting change to the value number, and mark it as indeterminate.
7015-
for (Loop * loop = this->currentBlock->loop; loop; loop = loop->parent)
7016-
{
7017-
InductionVariable *iv = nullptr;
7018-
if (loop->inductionVariables && loop->inductionVariables->TryGetReference(dstSym->m_id, &iv))
7019-
{
7020-
iv->SetChangeIsIndeterminate();
7021-
}
7022-
}
7015+
InvalidateInductionVariables(instr);
70237016

70247017
return true;
70257018
}
@@ -12102,16 +12095,7 @@ GlobOpt::OptConstFoldBinary(
1210212095
this->ToInt32Dst(instr, dst->AsRegOpnd(), this->currentBlock);
1210312096
}
1210412097

12105-
// If this is an induction variable, then treat it the way the prepass would have if it had seen
12106-
// the assignment and the resulting change to the value number, and mark it as indeterminate.
12107-
for (Loop * loop = this->currentBlock->loop; loop; loop = loop->parent)
12108-
{
12109-
InductionVariable *iv = nullptr;
12110-
if (loop->inductionVariables && loop->inductionVariables->TryGetReference(dstSym->m_id, &iv))
12111-
{
12112-
iv->SetChangeIsIndeterminate();
12113-
}
12114-
}
12098+
InvalidateInductionVariables(instr);
1211512099

1211612100
return true;
1211712101
}

lib/Backend/GlobOpt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ class GlobOpt
699699
void DetectUnknownChangesToInductionVariables(GlobOptBlockData *const blockData);
700700
void SetInductionVariableValueNumbers(GlobOptBlockData *const blockData);
701701
void FinalizeInductionVariables(Loop *const loop, GlobOptBlockData *const headerData);
702+
void InvalidateInductionVariables(IR::Instr * instr);
702703
enum class SymBoundType {OFFSET, VALUE, UNKNOWN};
703704
SymBoundType DetermineSymBoundOffsetOrValueRelativeToLandingPad(StackSym *const sym, const bool landingPadValueIsLowerBound, ValueInfo *const valueInfo, const IntBounds *const bounds, GlobOptBlockData *const landingPadGlobOptBlockData, int *const boundOffsetOrValueRef);
704705

lib/Backend/GlobOptIntBounds.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,30 @@ void GlobOpt::FinalizeInductionVariables(Loop *const loop, GlobOptBlockData *con
12621262
}
12631263
}
12641264

1265+
void
1266+
GlobOpt::InvalidateInductionVariables(IR::Instr * instr)
1267+
{
1268+
Assert(instr->GetDst() != nullptr && instr->GetDst()->IsRegOpnd());
1269+
1270+
// Induction variables are always var syms.
1271+
StackSym * dstSym = instr->GetDst()->AsRegOpnd()->m_sym;
1272+
if (!dstSym->IsVar())
1273+
{
1274+
dstSym = dstSym->GetVarEquivSym(this->func);
1275+
}
1276+
1277+
// If this is an induction variable, then treat it the way the prepass would have if it had seen
1278+
// the assignment and the resulting change to the value number, and mark it as indeterminate.
1279+
for (Loop * loop = this->currentBlock->loop; loop; loop = loop->parent)
1280+
{
1281+
InductionVariable *iv = nullptr;
1282+
if (loop->inductionVariables && loop->inductionVariables->TryGetReference(dstSym->m_id, &iv))
1283+
{
1284+
iv->SetChangeIsIndeterminate();
1285+
}
1286+
}
1287+
}
1288+
12651289
GlobOpt::SymBoundType GlobOpt::DetermineSymBoundOffsetOrValueRelativeToLandingPad(
12661290
StackSym *const sym,
12671291
const bool landingPadValueIsLowerBound,

lib/Backend/Inline.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,11 +2199,11 @@ Inline::InlineBuiltInFunction(IR::Instr *callInstr, const FunctionJITTimeInfo *
21992199
callInstr->m_opcode = inlineCallOpCode;
22002200
SetupInlineInstrForCallDirect(builtInFunctionId, callInstr, argoutInstr);
22012201

2202+
WrapArgsOutWithCoerse(builtInFunctionId, callInstr);
2203+
22022204
// Generate ByteCodeArgOutCaptures and move the ArgOut_A/ArgOut_A_Inline close to the call instruction
22032205
callInstr->MoveArgs(/*generateByteCodeCapture*/ true);
22042206

2205-
WrapArgsOutWithCoerse(builtInFunctionId, callInstr);
2206-
22072207
inlineBuiltInEndInstr = callInstr;
22082208
}
22092209
else

0 commit comments

Comments
 (0)