Skip to content

Commit 495de1a

Browse files
committed
[1.8>1.9] [MERGE #4963 @rajatd] ChakraCore 2018-04 security updates
Merge pull request #4963 from rajatd:servicing/1804
2 parents 7f1ab68 + c259f22 commit 495de1a

26 files changed

+475
-245
lines changed

lib/Backend/GlobOpt.cpp

+35-4
Original file line numberDiff line numberDiff line change
@@ -14402,7 +14402,8 @@ GlobOpt::OptArraySrc(IR::Instr * *const instrRef)
1440214402
currentBlock->next,
1440314403
hoistBlock,
1440414404
hoistInfo.IndexSym(),
14405-
hoistInfo.IndexValueNumber());
14405+
hoistInfo.IndexValueNumber(),
14406+
true);
1440614407
it.IsValid();
1440714408
it.MoveNext())
1440814409
{
@@ -14670,7 +14671,7 @@ GlobOpt::OptArraySrc(IR::Instr * *const instrRef)
1467014671
Assert(!hoistInfo.Loop() || hoistBlock != currentBlock);
1467114672
if(hoistBlock != currentBlock)
1467214673
{
14673-
for(InvariantBlockBackwardIterator it(this, currentBlock->next, hoistBlock, nullptr);
14674+
for(InvariantBlockBackwardIterator it(this, currentBlock->next, hoistBlock, nullptr, InvalidValueNumber, true);
1467414675
it.IsValid();
1467514676
it.MoveNext())
1467614677
{
@@ -17116,12 +17117,15 @@ InvariantBlockBackwardIterator::InvariantBlockBackwardIterator(
1711617117
BasicBlock *const exclusiveBeginBlock,
1711717118
BasicBlock *const inclusiveEndBlock,
1711817119
StackSym *const invariantSym,
17119-
const ValueNumber invariantSymValueNumber)
17120+
const ValueNumber invariantSymValueNumber,
17121+
bool followFlow)
1712017122
: globOpt(globOpt),
1712117123
exclusiveEndBlock(inclusiveEndBlock->prev),
1712217124
invariantSym(invariantSym),
1712317125
invariantSymValueNumber(invariantSymValueNumber),
17124-
block(exclusiveBeginBlock)
17126+
block(exclusiveBeginBlock),
17127+
blockBV(globOpt->tempAlloc),
17128+
followFlow(followFlow)
1712517129
#if DBG
1712617130
,
1712717131
inclusiveEndBlock(inclusiveEndBlock)
@@ -17159,6 +17163,11 @@ InvariantBlockBackwardIterator::MoveNext()
1715917163
break;
1716017164
}
1716117165

17166+
if (!this->UpdatePredBlockBV())
17167+
{
17168+
continue;
17169+
}
17170+
1716217171
if(block->isDeleted)
1716317172
{
1716417173
continue;
@@ -17186,6 +17195,28 @@ InvariantBlockBackwardIterator::MoveNext()
1718617195
}
1718717196
}
1718817197

17198+
bool
17199+
InvariantBlockBackwardIterator::UpdatePredBlockBV()
17200+
{
17201+
if (!this->followFlow)
17202+
{
17203+
return true;
17204+
}
17205+
17206+
// Track blocks we've visited to ensure that we only iterate over predecessor blocks
17207+
if (!this->blockBV.IsEmpty() && !this->blockBV.Test(this->block->GetBlockNum()))
17208+
{
17209+
return false;
17210+
}
17211+
17212+
FOREACH_SLISTBASECOUNTED_ENTRY(FlowEdge*, edge, this->block->GetPredList())
17213+
{
17214+
this->blockBV.Set(edge->GetPred()->GetBlockNum());
17215+
} NEXT_SLISTBASECOUNTED_ENTRY;
17216+
17217+
return true;
17218+
}
17219+
1718917220
BasicBlock *
1719017221
InvariantBlockBackwardIterator::Block() const
1719117222
{

lib/Backend/GlobOpt.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,16 @@ class InvariantBlockBackwardIterator
364364
const ValueNumber invariantSymValueNumber;
365365
BasicBlock *block;
366366
Value *invariantSymValue;
367+
BVSparse<JitArenaAllocator> blockBV;
368+
bool followFlow;
367369

368370
#if DBG
369371
BasicBlock *const inclusiveEndBlock;
370372
#endif
371373

374+
bool UpdatePredBlockBV();
372375
public:
373-
InvariantBlockBackwardIterator(GlobOpt *const globOpt, BasicBlock *const exclusiveBeginBlock, BasicBlock *const inclusiveEndBlock, StackSym *const invariantSym, const ValueNumber invariantSymValueNumber = InvalidValueNumber);
376+
InvariantBlockBackwardIterator(GlobOpt *const globOpt, BasicBlock *const exclusiveBeginBlock, BasicBlock *const inclusiveEndBlock, StackSym *const invariantSym, const ValueNumber invariantSymValueNumber = InvalidValueNumber, bool followFlow = false);
374377

375378
public:
376379
bool IsValid() const;

lib/Runtime/Base/ThreadContext.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const Js::PropertyRecord * const ThreadContext::builtInPropertyRecords[] =
7272
};
7373

7474
ThreadContext::RecyclableData::RecyclableData(Recycler *const recycler) :
75+
pendingFinallyException(nullptr),
7576
soErrorObject(nullptr, nullptr, nullptr, true),
7677
oomErrorObject(nullptr, nullptr, nullptr, true),
7778
terminatedErrorObject(nullptr, nullptr, nullptr),
@@ -94,7 +95,6 @@ ThreadContext::ThreadContext(AllocationPolicyManager * allocationPolicyManager,
9495
isThreadBound(false),
9596
hasThrownPendingException(false),
9697
hasBailedOutBitPtr(nullptr),
97-
pendingFinallyException(nullptr),
9898
noScriptScope(false),
9999
heapEnum(nullptr),
100100
threadContextFlags(ThreadContextFlagNoFlag),

lib/Runtime/Base/ThreadContext.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,6 @@ class ThreadContext sealed :
443443

444444
private:
445445
const Js::PropertyRecord * emptyStringPropertyRecord;
446-
447-
Js::JavascriptExceptionObject * pendingFinallyException;
448446
bool noScriptScope;
449447

450448
#ifdef ENABLE_SCRIPT_DEBUGGING
@@ -559,6 +557,8 @@ class ThreadContext sealed :
559557
Field(Js::TempArenaAllocatorObject *) temporaryArenaAllocators[MaxTemporaryArenaAllocators];
560558
Field(Js::TempGuestArenaAllocatorObject *) temporaryGuestArenaAllocators[MaxTemporaryArenaAllocators];
561559

560+
Field(Js::JavascriptExceptionObject *) pendingFinallyException;
561+
562562
Field(Js::JavascriptExceptionObject *) exceptionObject;
563563
Field(bool) propagateException;
564564

@@ -1294,12 +1294,12 @@ class ThreadContext sealed :
12941294

12951295
void SetPendingFinallyException(Js::JavascriptExceptionObject * exceptionObj)
12961296
{
1297-
pendingFinallyException = exceptionObj;
1297+
recyclableData->pendingFinallyException = exceptionObj;
12981298
}
12991299

13001300
Js::JavascriptExceptionObject * GetPendingFinallyException()
13011301
{
1302-
return pendingFinallyException;
1302+
return recyclableData->pendingFinallyException;
13031303
}
13041304

13051305
Js::EntryPointInfo ** RegisterEquivalentTypeCacheEntryPoint(Js::EntryPointInfo * entryPoint);

0 commit comments

Comments
 (0)