Skip to content

Commit

Permalink
chakracore: Update chakracore release/2.0
Browse files Browse the repository at this point in the history
Sync to chakra-core/ChakraCore@c970d0f

PR-URL: nodejs#197
Reviewed-By: Hitesh Kanwathirtha <[email protected]>
  • Loading branch information
kunalspathak committed Mar 23, 2017
1 parent 87ce098 commit e170da8
Show file tree
Hide file tree
Showing 89 changed files with 1,356 additions and 1,928 deletions.
3 changes: 3 additions & 0 deletions deps/chakrashim/core/Build/compile_clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,8 @@ make -j4 install

if [ $? == 0 ]; then
echo -e "Done!\n./build.sh args are given below;\n\n"
# Create a local bfd-plugins and copy LLVMgold.so into there.
mkdir -p "${ROOT}/build/lib/bfd-plugins/"
cp "${ROOT}/build/lib/LLVMgold.so" "${ROOT}/build/lib/bfd-plugins/"
echo "--cxx=${ROOT}/build/bin/clang++ --cc=${ROOT}/build/bin/clang"
fi
10 changes: 7 additions & 3 deletions deps/chakrashim/core/Build/scripts/post_build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ param (
[string]$srcsrvcmdpath,

[string]$bvtcmdpath = "",
[string]$testparams = "",

[string]$repo = "core",
[string]$logFile = "",

Expand Down Expand Up @@ -71,8 +73,8 @@ if ($arch -eq "*") {

$buildName = ConstructBuildName -arch $arch -flavor $flavor -subtype $subtype

if (($logFile -eq "") -and (Test-Path Env:\TF_BUILD_BINARIESDIRECTORY)) {
$logFile = "${Env:TF_BUILD_BINARIESDIRECTORY}\logs\post_build.${buildName}.log"
if (($logFile -eq "") -and (Test-Path $buildRoot)) {
$logFile = "${buildRoot}\logs\post_build.${buildName}.log"
if (Test-Path -Path $logFile) {
Remove-Item $logFile -Force
}
Expand Down Expand Up @@ -114,7 +116,9 @@ if ($arch -eq "*") {

# run tests
if (-not $skipTests) {
ExecuteCommand("$bvtcmdpath -$arch$flavor")
# marshall environment var for cmd script
$Env:TF_BUILD_BINARIESDIRECTORY = $buildRoot
ExecuteCommand("$bvtcmdpath -$arch$flavor $testparams")
}
}

Expand Down
5 changes: 4 additions & 1 deletion deps/chakrashim/core/lib/Backend/BackendApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,8 @@ SetProfilerFromNativeCodeGen(NativeCodeGenerator * toNativeCodeGen, NativeCodeGe

void DeleteNativeCodeData(NativeCodeData * data)
{
delete data;
if (data)
{
HeapDelete(data);
}
}
2 changes: 2 additions & 0 deletions deps/chakrashim/core/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 deps/chakrashim/core/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 deps/chakrashim/core/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 deps/chakrashim/core/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 deps/chakrashim/core/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
2 changes: 1 addition & 1 deletion deps/chakrashim/core/lib/Backend/JITType.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class JITTypeHolderBase
JITTypeHolderBase(JITType * t);

template <class S>
JITTypeHolderBase(JITTypeHolderBase<S> other) : t(PointerValue(other.t)) {}
JITTypeHolderBase(const JITTypeHolderBase<S>& other) : t(PointerValue(other.t)) {}

template <class S>
void operator =(const JITTypeHolderBase<S> &other) { t = other.t; }
Expand Down
9 changes: 5 additions & 4 deletions deps/chakrashim/core/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 deps/chakrashim/core/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 deps/chakrashim/core/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
22 changes: 12 additions & 10 deletions deps/chakrashim/core/lib/Backend/NativeCodeData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//-------------------------------------------------------------------------------------------------------
#include "Backend.h"

NativeCodeData::NativeCodeData(DataChunk * chunkList)
NativeCodeData::NativeCodeData(DataChunk * chunkList)
: chunkList(chunkList)
{
#ifdef PERF_COUNTERS
Expand Down Expand Up @@ -169,7 +169,7 @@ NativeCodeData::VerifyExistFixupEntry(void* targetAddr, void* addrToFixup, void*
{
if (entry->addrOffset == offset)
{
// The following assertions can be false positive in case a data field happen to
// The following assertions can be false positive in case a data field happen to
// have value fall into NativeCodeData memory range
AssertMsg(entry->targetTotalOffset == targetChunk->offset, "Missing fixup");
return;
Expand All @@ -188,12 +188,14 @@ NativeCodeData::DeleteChunkList(DataChunkT * chunkList)
{
DataChunkT * current = next;
next = next->next;
delete current;

// TODO: Should be HeapDeletePlus, but we don't know plusSize
HeapDelete(current, AllocatorDeleteFlags::UnknownSize);
}
}

NativeCodeData::Allocator::Allocator()
: chunkList(nullptr),
NativeCodeData::Allocator::Allocator()
: chunkList(nullptr),
lastChunkList(nullptr),
isOOPJIT(JITManager::GetJITManager()->IsJITServer())
{
Expand Down Expand Up @@ -226,7 +228,7 @@ char *
NativeCodeData::Allocator::Alloc(DECLSPEC_GUARD_OVERFLOW size_t requestSize)
{
Assert(!finalized);
char * data = nullptr;
char * data = nullptr;
requestSize = Math::Align(requestSize, sizeof(void*));

if (isOOPJIT)
Expand All @@ -237,9 +239,9 @@ NativeCodeData::Allocator::Alloc(DECLSPEC_GUARD_OVERFLOW size_t requestSize)
// positive while verifying missing fixup entries
// Allocation without zeroing out, and with bool field in the structure
// will increase the chance of false positive because of reusing memory
// without zeroing, and the bool field is set to false, makes the garbage
// memory not changed, and the garbage memory might be just pointing to the
// same range of NativeCodeData memory, the checking tool will report false
// without zeroing, and the bool field is set to false, makes the garbage
// memory not changed, and the garbage memory might be just pointing to the
// same range of NativeCodeData memory, the checking tool will report false
// poisitive, see NativeCodeData::VerifyExistFixupEntry for more
DataChunk * newChunk = HeapNewStructPlusZ(requestSize, DataChunk);
#else
Expand Down Expand Up @@ -301,7 +303,7 @@ NativeCodeData::Allocator::AllocZero(DECLSPEC_GUARD_OVERFLOW size_t requestSize)
// Allocated with HeapNewStructPlusZ for chk build
memset(data, 0, requestSize);
#else
if (!isOOPJIT)
if (!isOOPJIT)
{
memset(data, 0, requestSize);
}
Expand Down
14 changes: 7 additions & 7 deletions deps/chakrashim/core/lib/Backend/NativeCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,13 +953,13 @@ NativeCodeGenerator::CodeGen(PageAllocator * pageAllocator, CodeGenWorkItem* wor
pNumberAllocator,
#endif
codeGenProfiler, !foreground);

if (!this->scriptContext->GetThreadContext()->GetPreReservedVirtualAllocator()->IsInRange((void*)jitWriteData.codeAddress))
{
this->scriptContext->GetJitFuncRangeCache()->AddFuncRange((void*)jitWriteData.codeAddress, jitWriteData.codeSize);
}
}

if (JITManager::GetJITManager()->IsOOPJITEnabled() && PHASE_VERBOSE_TRACE(Js::BackEndPhase, workItem->GetFunctionBody()))
{
LARGE_INTEGER freq;
Expand Down Expand Up @@ -1198,7 +1198,7 @@ void NativeCodeGenerator::LogCodeGenStart(CodeGenWorkItem * workItem, LARGE_INTE
size_t sizeInChars = workItem->GetDisplayName(displayName, 256);
if (sizeInChars > 256)
{
displayName = new WCHAR[sizeInChars];
displayName = HeapNewArray(WCHAR, sizeInChars);
workItem->GetDisplayName(displayName, 256);
}
JS_ETW(EventWriteJSCRIPT_FUNCTION_JIT_START(
Expand All @@ -1213,7 +1213,7 @@ void NativeCodeGenerator::LogCodeGenStart(CodeGenWorkItem * workItem, LARGE_INTE

if (displayName != displayNameBuffer)
{
delete[] displayName;
HeapDeleteArray(sizeInChars, displayName);
}
}
}
Expand Down Expand Up @@ -1315,7 +1315,7 @@ void NativeCodeGenerator::LogCodeGenDone(CodeGenWorkItem * workItem, LARGE_INTEG
size_t sizeInChars = workItem->GetDisplayName(displayName, 256);
if (sizeInChars > 256)
{
displayName = new WCHAR[sizeInChars];
displayName = HeapNewArray(WCHAR, sizeInChars);
workItem->GetDisplayName(displayName, 256);
}
void* entryPoint;
Expand All @@ -1331,7 +1331,7 @@ void NativeCodeGenerator::LogCodeGenDone(CodeGenWorkItem * workItem, LARGE_INTEG

if (displayName != displayNameBuffer)
{
delete[] displayName;
HeapDeleteArray(sizeInChars, displayName);
}
}
}
Expand Down Expand Up @@ -3194,7 +3194,7 @@ NativeCodeGenerator::QueueFreeNativeCodeGenAllocation(void* address)
//DeRegister Entry Point for CFG
ThreadContext::GetContextForCurrentThread()->SetValidCallTargetForCFG(address, false);
}

if ((!JITManager::GetJITManager()->IsOOPJITEnabled() && !this->scriptContext->GetThreadContext()->GetPreReservedVirtualAllocator()->IsInRange((void*)address)) ||
(JITManager::GetJITManager()->IsOOPJITEnabled() && !PreReservedVirtualAllocWrapper::IsInRange((void*)this->scriptContext->GetThreadContext()->GetPreReservedRegionAddr(), (void*)address)))
{
Expand Down
41 changes: 36 additions & 5 deletions deps/chakrashim/core/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
Loading

0 comments on commit e170da8

Please sign in to comment.