Skip to content

Commit c259f22

Browse files
committed
[MERGE #4963 @rajatd] ChakraCore 2018-04 security updates
Merge pull request #4963 from rajatd:servicing/1804
2 parents 7254857 + e8a1e29 commit c259f22

28 files changed

+481
-251
lines changed

Build/NuGet/.pack-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.8.2
1+
1.8.3

lib/Backend/GlobOpt.cpp

Lines changed: 35 additions & 4 deletions
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

Lines changed: 4 additions & 1 deletion
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/Common/ChakraCoreVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// ChakraCore version number definitions (used in ChakraCore binary metadata)
1818
#define CHAKRA_CORE_MAJOR_VERSION 1
1919
#define CHAKRA_CORE_MINOR_VERSION 8
20-
#define CHAKRA_CORE_PATCH_VERSION 2
20+
#define CHAKRA_CORE_PATCH_VERSION 3
2121
#define CHAKRA_CORE_VERSION_RELEASE_QFE 0 // Redundant with PATCH_VERSION. Keep this value set to 0.
2222

2323
// -------------

lib/Runtime/Base/ThreadContext.cpp

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,6 @@ class ThreadContext sealed :
441441

442442
private:
443443
const Js::PropertyRecord * emptyStringPropertyRecord;
444-
445-
Js::JavascriptExceptionObject * pendingFinallyException;
446444
bool noScriptScope;
447445

448446
#ifdef ENABLE_SCRIPT_DEBUGGING
@@ -557,6 +555,8 @@ class ThreadContext sealed :
557555
Field(Js::TempArenaAllocatorObject *) temporaryArenaAllocators[MaxTemporaryArenaAllocators];
558556
Field(Js::TempGuestArenaAllocatorObject *) temporaryGuestArenaAllocators[MaxTemporaryArenaAllocators];
559557

558+
Field(Js::JavascriptExceptionObject *) pendingFinallyException;
559+
560560
Field(Js::JavascriptExceptionObject *) exceptionObject;
561561
Field(bool) propagateException;
562562

@@ -1292,12 +1292,12 @@ class ThreadContext sealed :
12921292

12931293
void SetPendingFinallyException(Js::JavascriptExceptionObject * exceptionObj)
12941294
{
1295-
pendingFinallyException = exceptionObj;
1295+
recyclableData->pendingFinallyException = exceptionObj;
12961296
}
12971297

12981298
Js::JavascriptExceptionObject * GetPendingFinallyException()
12991299
{
1300-
return pendingFinallyException;
1300+
return recyclableData->pendingFinallyException;
13011301
}
13021302

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

0 commit comments

Comments
 (0)