Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

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

PR-URL: #203
Reviewed-By: Hitesh Kanwathirtha <[email protected]>
  • Loading branch information
kunalspathak committed Mar 30, 2017
1 parent b6f1dc4 commit 2f5ee39
Show file tree
Hide file tree
Showing 67 changed files with 11,876 additions and 2,661 deletions.
2 changes: 1 addition & 1 deletion deps/chakrashim/core/Build/NuGet/.pack-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1
1.4.2
25 changes: 20 additions & 5 deletions deps/chakrashim/core/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,13 @@ if [[ ${#_VERBOSE} > 0 ]]; then
echo ""
fi

ERROR_CLANG() {
echo "ERROR: clang++ not found."
echo -e "\nYou could use clang++ from a custom location.\n"
PRINT_USAGE
exit 1
}

CLANG_PATH=
if [[ ${#_CXX} > 0 || ${#_CC} > 0 ]]; then
if [[ ${#_CXX} == 0 || ${#_CC} == 0 ]]; then
Expand All @@ -377,11 +384,19 @@ else
_CC=/usr/bin/clang
CLANG_PATH=$_CXX
else
echo "ERROR: clang++ not found at /usr/bin/clang++"
echo ""
echo "You could use clang++ from a custom location."
PRINT_USAGE
exit 1
# try env CXX and CC
if [[ ! -f $CXX || ! -f $CC ]]; then
ERROR_CLANG
fi

_CXX=$CXX
_CC=$CC
CLANG_PATH=$CXX
VERSION=$($CXX --version)
if [[ ! $VERSION =~ "clang" ]]; then
ERROR_CLANG
fi
echo -e "Clang++ not found on PATH.\nTrying CCX -> ${CCX} and CC -> ${CC}"
fi
else
CLANG_PATH=c++
Expand Down
54 changes: 35 additions & 19 deletions deps/chakrashim/core/lib/Backend/IRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,16 @@ IRBuilder::BuildReg1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot R0)
newOpcode = Js::OpCode::Ld_A;
break;

case Js::OpCode::LdParamObj:
if (!m_func->GetJITFunctionBody()->HasScopeObject())
{
Js::Throw::FatalInternalError();
}
srcOpnd = BuildSrcOpnd(m_func->GetJITFunctionBody()->GetParamClosureReg());
isNotInt = true;
newOpcode = Js::OpCode::Ld_A;
break;

case Js::OpCode::Throw:
{
srcOpnd = this->BuildSrcOpnd(srcRegOpnd);
Expand Down Expand Up @@ -3504,9 +3514,9 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
IR::ByteCodeUsesInstr *byteCodeUse;
PropertySym *fieldSym = nullptr;
StackSym * stackFuncPtrSym = nullptr;
SymID symID;
SymID symID = m_func->GetJITFunctionBody()->GetLocalClosureReg();
bool isLdSlotThatWasNotProfiled = false;
uint scopeSlotSize = 0;
uint scopeSlotSize = m_func->GetJITFunctionBody()->GetScopeSlotArraySize();
StackSym* closureSym = m_func->GetLocalClosureSym();

switch (newOpcode)
Expand All @@ -3515,14 +3525,9 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
scopeSlotSize = m_func->GetJITFunctionBody()->GetParamScopeSlotArraySize();
closureSym = m_func->GetParamClosureSym();
symID = m_func->GetJITFunctionBody()->GetParamClosureReg();
fieldSym = PropertySym::New(closureSym, slotId, (uint32)-1, (uint)-1, PropertyKindSlots, m_func);
goto LdLocalSlot;
// Fall through

case Js::OpCode::LdLocalSlot:
scopeSlotSize = m_func->GetJITFunctionBody()->GetScopeSlotArraySize();
symID = m_func->GetJITFunctionBody()->GetLocalClosureReg();

LdLocalSlot:
if (PHASE_ON(Js::ClosureRangeCheckPhase, m_func))
{
if ((uint32)slotId >= scopeSlotSize + Js::ScopeSlots::FirstSlotIndex)
Expand Down Expand Up @@ -3562,7 +3567,7 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
this->EnsureLoopBodyLoadSlot(symID);
}

fieldSym = fieldSym ? fieldSym : PropertySym::FindOrCreate(symID, slotId, (uint32)-1, (uint)-1, PropertyKindSlots, m_func);
fieldSym = PropertySym::FindOrCreate(symID, slotId, (uint32)-1, (uint)-1, PropertyKindSlots, m_func);
fieldOpnd = IR::SymOpnd::New(fieldSym, TyVar, m_func);
regOpnd = this->BuildDstOpnd(regSlot);
instr = nullptr;
Expand All @@ -3587,12 +3592,9 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
closureSym = m_func->GetParamClosureSym();
symID = m_func->GetJITFunctionBody()->GetParamClosureReg();
newOpcode = Js::OpCode::LdLocalObjSlot;
goto LdLocalObjSlot;
// Fall through

case Js::OpCode::LdLocalObjSlot:
symID = m_func->GetJITFunctionBody()->GetLocalClosureReg();

LdLocalObjSlot:
if (closureSym->HasByteCodeRegSlot())
{
byteCodeUse = IR::ByteCodeUsesInstr::New(m_func, offset);
Expand Down Expand Up @@ -3622,12 +3624,19 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
this->AddInstr(instr, offset);
break;

case Js::OpCode::StParamSlot:
case Js::OpCode::StParamSlotChkUndecl:
scopeSlotSize = m_func->GetJITFunctionBody()->GetParamScopeSlotArraySize();
closureSym = m_func->GetParamClosureSym();
symID = m_func->GetJITFunctionBody()->GetParamClosureReg();
newOpcode = newOpcode == Js::OpCode::StParamSlot ? Js::OpCode::StLocalSlot : Js::OpCode::StLocalSlotChkUndecl;
// Fall through

case Js::OpCode::StLocalSlot:
case Js::OpCode::StLocalSlotChkUndecl:

if (PHASE_ON(Js::ClosureRangeCheckPhase, m_func))
{
if ((uint32)slotId >= m_func->GetJITFunctionBody()->GetScopeSlotArraySize() + Js::ScopeSlots::FirstSlotIndex)
if ((uint32)slotId >= scopeSlotSize + Js::ScopeSlots::FirstSlotIndex)
{
Js::Throw::FatalInternalError();
}
Expand Down Expand Up @@ -3660,7 +3669,6 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
}
else
{
symID = m_func->GetJITFunctionBody()->GetLocalClosureReg();
if (IsLoopBody())
{
this->EnsureLoopBodyLoadSlot(symID);
Expand All @@ -3683,9 +3691,15 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
}
break;

case Js::OpCode::StParamObjSlot:
case Js::OpCode::StParamObjSlotChkUndecl:
closureSym = m_func->GetParamClosureSym();
symID = m_func->GetJITFunctionBody()->GetParamClosureReg();
newOpcode = newOpcode == Js::OpCode::StParamObjSlot ? Js::OpCode::StLocalObjSlot : Js::OpCode::StLocalObjSlotChkUndecl;
// Fall through

case Js::OpCode::StLocalObjSlot:
case Js::OpCode::StLocalObjSlotChkUndecl:

if (closureSym->HasByteCodeRegSlot())
{
byteCodeUse = IR::ByteCodeUsesInstr::New(m_func, offset);
Expand All @@ -3694,7 +3708,7 @@ IRBuilder::BuildElementSlotI1(Js::OpCode newOpcode, uint32 offset, Js::RegSlot r
}

regOpnd = IR::RegOpnd::New(TyVar, m_func);
fieldOpnd = this->BuildFieldOpnd(Js::OpCode::LdSlotArr, m_func->GetJITFunctionBody()->GetLocalClosureReg(), (Js::DynamicObject::GetOffsetOfAuxSlots())/sizeof(Js::Var), (Js::PropertyIdIndexType)-1, PropertyKindSlotArray);
fieldOpnd = this->BuildFieldOpnd(Js::OpCode::LdSlotArr, symID, (Js::DynamicObject::GetOffsetOfAuxSlots())/sizeof(Js::Var), (Js::PropertyIdIndexType)-1, PropertyKindSlotArray);
instr = IR::Instr::New(Js::OpCode::LdSlotArr, regOpnd, fieldOpnd, m_func);
this->AddInstr(instr, offset);

Expand Down Expand Up @@ -6795,7 +6809,9 @@ IRBuilder::BuildEmpty(Js::OpCode newOpcode, uint32 offset)
this->m_func),
offset);

if (this->m_func->GetJITFunctionBody()->GetScopeSlotArraySize())
// Create a new local closure for the body when either body scope has scope slots allocated or
// eval is present which can leak declarations.
if (this->m_func->GetJITFunctionBody()->GetScopeSlotArraySize() > 0 || this->m_func->GetJITFunctionBody()->HasScopeObject())
{
if (this->m_func->GetJITFunctionBody()->HasScopeObject())
{
Expand Down
2 changes: 1 addition & 1 deletion deps/chakrashim/core/lib/Backend/InliningDecider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ uint InliningDecider::InlinePolymorphicCallSite(Js::FunctionBody *const inliner,
bool isConstructorCall;
if (!profileData->GetPolymorphicCallSiteInfo(inliner, profiledCallSiteId, &isConstructorCall, functionBodyArray, functionBodyArrayLength))
{
return false;
return 0;
}

uint inlineeCount = 0;
Expand Down
97 changes: 59 additions & 38 deletions deps/chakrashim/core/lib/Backend/amd64/LowererMDArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ LowererMDArch::LoadHeapArguments(IR::Instr *instrArgs)
// s2 = actual argument count (without counting "this")
instr = this->lowererMD->LoadInputParamCount(instrArgs, -1);
IR::Opnd * opndInputParamCount = instr->GetDst();

this->LoadHelperArgument(instrArgs, opndInputParamCount);

// s1 = current function
Expand Down Expand Up @@ -466,6 +466,40 @@ LowererMDArch::LoadNewScObjFirstArg(IR::Instr * instr, IR::Opnd * dst, ushort ex
return argInstr;
}

inline static RegNum GetRegFromArgPosition(const bool isFloatArg, const uint16 argPosition)
{
RegNum reg = RegNOREG;

if (!isFloatArg && argPosition <= IntArgRegsCount)
{
switch (argPosition)
{
#define REG_INT_ARG(Index, Name) \
case ((Index) + 1): \
reg = Reg ## Name; \
break;
#include "RegList.h"
default:
Assume(UNREACHED);
}
}
else if (isFloatArg && argPosition <= XmmArgRegsCount)
{
switch (argPosition)
{
#define REG_XMM_ARG(Index, Name) \
case ((Index) + 1): \
reg = Reg ## Name; \
break;
#include "RegList.h"
default:
Assume(UNREACHED);
}
}

return reg;
}

int32
LowererMDArch::LowerCallArgs(IR::Instr *callInstr, ushort callFlags, Js::ArgSlot extraParams, IR::IntConstOpnd **callInfoOpndRef /* = nullptr */)
{
Expand Down Expand Up @@ -957,23 +991,31 @@ LowererMDArch::LowerCall(IR::Instr * callInstr, uint32 argCount)
// Manually home args
if (shouldHomeParams)
{
static const RegNum s_argRegs[IntArgRegsCount] = {
#define REG_INT_ARG(Index, Name) Reg ## Name,
#include "RegList.h"
};

const int callArgCount = this->helperCallArgsCount + static_cast<int>(argCount);
const int argRegs = min(callArgCount, static_cast<int>(IntArgRegsCount));
for (int i = argRegs - 1; i >= 0; i--)

int argRegs = min(callArgCount, static_cast<int>(XmmArgRegsCount));

for (int i = argRegs; i > 0; i--)
{
StackSym * sym = this->m_func->m_symTable->GetArgSlotSym(static_cast<uint16>(i + 1));
IRType type = this->xplatCallArgs.args[i];
bool isFloatArg = this->xplatCallArgs.IsFloat(i);

if ( i > IntArgRegsCount && !isFloatArg ) continue;

StackSym * sym = this->m_func->m_symTable->GetArgSlotSym(static_cast<uint16>(i));
RegNum reg = GetRegFromArgPosition(isFloatArg, i);

IR::RegOpnd *regOpnd = IR::RegOpnd::New(nullptr, reg, type, this->m_func);
regOpnd->m_isCallArg = true;

Lowerer::InsertMove(
IR::SymOpnd::New(sym, TyMachReg, this->m_func),
IR::RegOpnd::New(nullptr, s_argRegs[i], TyMachReg, this->m_func),
IR::SymOpnd::New(sym, type, this->m_func),
regOpnd,
callInstr, false);
}
}
#endif
this->xplatCallArgs.Reset();
#endif // !_WIN32

//
// load the address into a register because we cannot directly access 64 bit constants
Expand Down Expand Up @@ -1036,34 +1078,13 @@ LowererMDArch::GetArgSlotOpnd(uint16 index, StackSym * argSym, bool isHelper /*=

IRType type = argSym ? argSym->GetType() : TyMachReg;
const bool isFloatArg = IRType_IsFloat(type) || IRType_IsSimd128(type);
RegNum reg = RegNOREG;

if (!isFloatArg && argPosition <= IntArgRegsCount)
{
switch (argPosition)
{
#define REG_INT_ARG(Index, Name) \
case ((Index) + 1): \
reg = Reg ## Name; \
break;
#include "RegList.h"
default:
Assume(UNREACHED);
}
}
else if (isFloatArg && argPosition <= XmmArgRegsCount)
RegNum reg = GetRegFromArgPosition(isFloatArg, argPosition);
#ifndef _WIN32
if (isFloatArg && argPosition <= XmmArgRegsCount)
{
switch (argPosition)
{
#define REG_XMM_ARG(Index, Name) \
case ((Index) + 1): \
reg = Reg ## Name; \
break;
#include "RegList.h"
default:
Assume(UNREACHED);
}
this->xplatCallArgs.SetFloat(argPosition);
}
#endif

if (reg != RegNOREG)
{
Expand Down
23 changes: 23 additions & 0 deletions deps/chakrashim/core/lib/Backend/amd64/LowererMDArch.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,30 @@ class LowererMDArch
int helperCallArgsCount;
IR::Opnd * helperCallArgs[MaxArgumentsToHelper];

#ifndef _WIN32
class XPlatRegArgList
{
public:
XPlatRegArgList() { Reset(); }
inline void Reset()
{
for (int i = 0; i <= XmmArgRegsCount; i++) args[i] = TyMachPtr;
}

inline bool IsFloat(uint16 position) { return args[position] == TyFloat64; }

void SetFloat(uint16 regPosition)
{
Assert(regPosition != 0 && regPosition <= XmmArgRegsCount);
args[regPosition] = TyFloat64;
}

static_assert(static_cast<int>(XmmArgRegsCount) >= static_cast<int>(IntArgRegsCount),
"Unexpected register count");
IRType args [XmmArgRegsCount + 1];
};
XPlatRegArgList xplatCallArgs;
#endif
public:

LowererMDArch(Func* function):
Expand Down
11 changes: 0 additions & 11 deletions deps/chakrashim/core/lib/Common/ConfigFlagsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -511,12 +511,6 @@ PHASE(All)
#define DEFAULT_CONFIG_ES6Classes (true)
#define DEFAULT_CONFIG_ES6DateParseFix (true)
#define DEFAULT_CONFIG_ES6DefaultArgs (true)
#ifdef COMPILE_DISABLE_ES6DefaultArgsSplitScope
// If ES6DefaultArgsSplitScope needs to be disabled by compile flag, COMPILE_DISABLE_ES6DefaultArgsSplitScope should be false
#define DEFAULT_CONFIG_ES6DefaultArgsSplitScope (false)
#else
#define DEFAULT_CONFIG_ES6DefaultArgsSplitScope (false)
#endif
#define DEFAULT_CONFIG_ES6Destructuring (true)
#define DEFAULT_CONFIG_ES6ForLoopSemantics (true)
#define DEFAULT_CONFIG_ES6FunctionName (true)
Expand Down Expand Up @@ -980,11 +974,6 @@ FLAGPR (Boolean, ES6, ES7AsyncAwait , "Enable ES7 'async' and
FLAGPR (Boolean, ES6, ES6Classes , "Enable ES6 'class' and 'extends' keywords" , DEFAULT_CONFIG_ES6Classes)
FLAGPR (Boolean, ES6, ES6DateParseFix , "Enable ES6 Date.parse fixes" , DEFAULT_CONFIG_ES6DateParseFix)
FLAGPR (Boolean, ES6, ES6DefaultArgs , "Enable ES6 Default Arguments" , DEFAULT_CONFIG_ES6DefaultArgs)

#ifndef COMPILE_DISABLE_ES6DefaultArgsSplitScope
#define COMPILE_DISABLE_ES6DefaultArgsSplitScope 0
#endif
FLAGPR_REGOVR_EXP(Boolean, ES6, ES6DefaultArgsSplitScope, "Enable ES6 Default Arguments to have its own scope" , DEFAULT_CONFIG_ES6DefaultArgsSplitScope)
FLAGPR (Boolean, ES6, ES6Destructuring , "Enable ES6 Destructuring" , DEFAULT_CONFIG_ES6Destructuring)
FLAGPR (Boolean, ES6, ES6ForLoopSemantics , "Enable ES6 for loop per iteration bindings" , DEFAULT_CONFIG_ES6ForLoopSemantics)
FLAGPR (Boolean, ES6, ES6FunctionName , "Enable ES6 function.name" , DEFAULT_CONFIG_ES6FunctionName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace DateTime

public:
double Now();
static double GetSystemTime();
double GetSystemTime();

void Reset() { data.Reset(); }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ namespace DateTime
class HiresTimerPlatformData
{
public:
double cacheSysTime;
ULONGLONG cacheTick;

HiresTimerPlatformData():cacheSysTime(0), cacheTick(-1) { }
void Reset() { /* dummy method for interface compatiblity */ }
};

Expand Down
Loading

0 comments on commit 2f5ee39

Please sign in to comment.