Skip to content

Commit

Permalink
Merge branch 'master' into wasm.simd
Browse files Browse the repository at this point in the history
  • Loading branch information
arunetm-zz committed Nov 22, 2017
2 parents 7c94e25 + 23153e1 commit eebff83
Show file tree
Hide file tree
Showing 301 changed files with 6,776 additions and 4,143 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
test/**/*.js -crlf
test/es6/HTMLComments.js binary diff=cpp
*.wasm binary
*.cpp text eol=lf diff=cpp
*.h text eol=lf diff=cpp
*.inl text eol=lf diff=cpp
*.vcproj text eol=crlf diff=xml
*.vcxproj text eol=crlf diff=xml
*.sln text eol=crlf diff=xml
14 changes: 14 additions & 0 deletions Build/Common.Build.ProjectConfiguration.props
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,19 @@
<Platform>ARM64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|CHPE">
<Configuration>Debug</Configuration>
<Platform>CHPE</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Test|CHPE">
<Configuration>Test</Configuration>
<Platform>CHPE</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|CHPE">
<Configuration>Release</Configuration>
<Platform>CHPE</Platform>
</ProjectConfiguration>
</ItemGroup>
</Project>

10 changes: 5 additions & 5 deletions Build/Common.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<!-- ======== sources.inc ======== -->
<!-- generates SAL annotations for our interface -->
<AdditionalOptions>%(AdditionalOptions) -sal_local</AdditionalOptions>

<PreprocessorDefinitions>%(PreprocessorDefinitions);WINVER=$(Win32_WinNTVersion)</PreprocessorDefinitions>
</Midl>
<ClCompile>
Expand All @@ -54,11 +53,11 @@
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<!-- /Zi -->
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DebugInformationFormat Condition="'$(MultiProcessorCompilation)' == 'true'">OldStyle</DebugInformationFormat>
<DebugInformationFormat Condition="'%(MultiProcessorCompilation)' == 'true'">OldStyle</DebugInformationFormat>
<!-- /EHsc- -->
<ExceptionHandling>SyncCThrow</ExceptionHandling>
<!-- /Gz -->
<CallingConvention Condition="'$(Platform)'=='Win32'">StdCall</CallingConvention>
<CallingConvention Condition="'$(Platform)'=='Win32' or '$(Platform)'=='chpe'">StdCall</CallingConvention>
<!-- /Zp8 -->
<StructMemberAlignment>8Bytes</StructMemberAlignment>
<!-- /GS -->
Expand Down Expand Up @@ -132,7 +131,8 @@
<ItemDefinitionGroup Condition="'$(OptimizedBuild)'=='true' AND '$(ENABLE_CODECOVERAGE)'!='true'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<WholeProgramOptimization>true</WholeProgramOptimization>
<!-- HYB-TODO: When a CHPE toolchain arrives that supports LTCG, remove this condition. -->
<WholeProgramOptimization Condition="'$(Platform)' != 'chpe'">true</WholeProgramOptimization>
</ClCompile>
</ItemDefinitionGroup>

Expand Down Expand Up @@ -162,7 +162,7 @@
<LinkTimeCodeGeneration Condition="'$(PlatformToolset)'!='v120' AND '$(TF_BUILD)'==''">UseFastLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
<Lib>
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
<LinkTimeCodeGeneration Condition="'$(Platform)' != 'chpe'">true</LinkTimeCodeGeneration>
</Lib>
</ItemDefinitionGroup>
<ItemGroup Condition="'$(ConfigurationType)'=='DynamicLibrary' OR '$(ConfigurationType)'=='Application'">
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,12 @@ if(CLR_CMAKE_PLATFORM_XPLAT)
)

# Only disable RTTI in release builds so that TrackAlloc works for debug and test builds
# Also disable RTTI when building a shared library
# TODO: why does the shared library break with rtti disabled?
if(CMAKE_BUILD_TYPE STREQUAL Release)
add_compile_options(-fno-rtti)
if(STATIC_LIBRARY OR NOT ICU_INTL_ENABLED)
add_compile_options(-fno-rtti)
endif()
endif()

# Clang -fsanitize.
Expand Down
2 changes: 1 addition & 1 deletion bin/GCStress/GCStress.vcxproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Condition="'$(ChakraBuildPathImported)'!='true'" Project="$(SolutionDir)Chakra.Build.Paths.props" />
<Import Project="$(BuildConfigPropsPath)Chakra.Build.ProjectConfiguration.props" />
Expand Down
8 changes: 1 addition & 7 deletions bin/GCStress/StubExternalApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,4 @@ HRESULT MemProtectHeapSynchronizeWithCollector(void * heapHandle) { return E_NOT
void MemProtectHeapSetDisableConcurrentThreadExitedCheck(void * heapHandle) {};
#endif

#if DBG && defined(RECYCLER_VERIFY_MARK)
bool IsLikelyRuntimeFalseReference(char* objectStartAddress, size_t offset,
const char* typeName)
{
return false;
}
#endif
IMPLEMENT_STUB_IsLikelyRuntimeFalseReference()
27 changes: 27 additions & 0 deletions bin/NativeTests/JsRTApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2294,4 +2294,31 @@ namespace JsRTApiTest
{
JsRTApiTest::RunWithAttributes(JsRTApiTest::JsLessThanTest);
}

void JsCreateStringTest(JsRuntimeAttributes attributes, JsRuntimeHandle runtime)
{
// Passing in invalid utf8 sequences should result in the unicode replacement character
const char invalidUtf8[] = { -127 /* 0x80 */, '\0' };
JsValueRef result;
REQUIRE(JsCreateString(invalidUtf8, 1, &result) == JsNoError);
uint16_t utf16Result[2];
size_t written;
REQUIRE(JsCopyStringUtf16(result, 0, 1, utf16Result, &written) == JsNoError);
CHECK(written == 1);
CHECK(utf16Result[0] == 0xFFFD);

// Creating a utf8 string and then copying it back out should give an identical string
// Specifying -1 as the length should result in using strlen as the length
const char validUtf8Input[] = {'T', 'e', 's', 't', ' ', -30 /* 0xe2 */, -104 /* 0x98 */, -125 /* 0x83 */, 0};
REQUIRE(JsCreateString(validUtf8Input, static_cast<size_t>(-1), &result) == JsNoError);
char utf8Result[10];
REQUIRE(JsCopyString(result,utf8Result, 10, &written) == JsNoError);
CHECK(written == strlen(validUtf8Input));
CHECK(memcmp(utf8Result, validUtf8Input, written) == 0);
}

TEST_CASE("ApiTest_JsCreateStringTest", "[ApiTest]")
{
JsRTApiTest::RunWithAttributes(JsRTApiTest::JsCreateStringTest);
}
}
12 changes: 6 additions & 6 deletions bin/NativeTests/MemoryPolicyTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ namespace MemoryPolicyTests

TEST_CASE("MemoryPolicyTest_UnboundedMemory", "[MemoryPolicyTest]")
{
BasicTest(JsRuntimeAttributeNone, "UnboundedMemory.js");
BasicTest(JsRuntimeAttributeDisableBackgroundWork, "UnboundedMemory.js");
BasicTest(JsRuntimeAttributeDisableFatalOnOOM, "UnboundedMemory.js");
BasicTest((JsRuntimeAttributes)(JsRuntimeAttributeDisableBackgroundWork | JsRuntimeAttributeDisableFatalOnOOM), "UnboundedMemory.js");
}

TEST_CASE("MemoryPolicyTest_ArrayTest", "[MemoryPolicyTest]")
{
BasicTest(JsRuntimeAttributeNone, "arrayTest.js");
BasicTest(JsRuntimeAttributeDisableBackgroundWork, "arrayTest.js");
BasicTest(JsRuntimeAttributeDisableFatalOnOOM, "arrayTest.js");
BasicTest((JsRuntimeAttributes)(JsRuntimeAttributeDisableBackgroundWork | JsRuntimeAttributeDisableFatalOnOOM), "arrayTest.js");
}

TEST_CASE("MemoryPolicyTest_ArrayBuffer", "[MemoryPolicyTest]")
{
BasicTest(JsRuntimeAttributeNone, "arraybuffer.js");
BasicTest(JsRuntimeAttributeDisableBackgroundWork, "arraybuffer.js");
BasicTest(JsRuntimeAttributeDisableFatalOnOOM, "arraybuffer.js");
BasicTest((JsRuntimeAttributes)(JsRuntimeAttributeDisableBackgroundWork | JsRuntimeAttributeDisableFatalOnOOM), "arraybuffer.js");
}

void OOSTest(JsRuntimeAttributes attributes)
Expand Down
65 changes: 20 additions & 45 deletions bin/ch/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,41 @@
#include <sys/stat.h>

//TODO: x-plat definitions
#ifdef _WIN32
#define MAX_URI_LENGTH 512
#ifdef _WIN32
#define TTD_MAX_FILE_LENGTH MAX_PATH
#define TTD_HOST_PATH_SEP "\\"
#else
#define TTD_MAX_FILE_LENGTH MAX_URI_LENGTH
#define TTD_HOST_PATH_SEP "/"
#endif

void TTDHostBuildCurrentExeDirectory(char* path, size_t* pathLength, size_t bufferLength)
{
wchar exePath[MAX_PATH];
GetModuleFileName(NULL, exePath, MAX_PATH);
char exePath[TTD_MAX_FILE_LENGTH];
PlatformAgnostic::SystemInfo::GetBinaryLocation(exePath, TTD_MAX_FILE_LENGTH);

size_t i = wcslen(exePath) - 1;
while(exePath[i] != _u('\\'))
size_t i = strlen(exePath) - 1;
while (exePath[i] != TTD_HOST_PATH_SEP[0] && i != 0)
{
--i;
}

if(i * 3 > bufferLength)
if (i == 0)
{
wprintf(_u("Don't overflow path buffer during conversion"));
fwprintf(stderr, _u("Can't get current exe directory"));
exit(1);
}
*pathLength = utf8::EncodeInto((LPUTF8)path, exePath, (charcount_t)(i + 1));
if (i + 2 > bufferLength)
{
fwprintf(stderr, _u("Don't overflow path buffer during copy"));
exit(1);
}
memcpy_s(path, bufferLength, exePath, i + 1);
*pathLength = i + 1;
path[*pathLength] = '\0';
}

#ifdef _WIN32
int TTDHostMKDir(const char* path, size_t pathLength)
{
char16 cpath[MAX_PATH];
Expand Down Expand Up @@ -67,42 +78,6 @@ JsTTDStreamHandle TTDHostOpen(size_t pathLength, const char* path, bool isWrite)
#define TTDHostRead(buff, size, handle) fread_s(buff, size, 1, size, (FILE*)handle);
#define TTDHostWrite(buff, size, handle) fwrite(buff, 1, size, (FILE*)handle)
#else

#ifdef __APPLE__
#include <mach-o/dyld.h>
#else
#include <unistd.h>
#endif
#define MAX_URI_LENGTH 512
#define TTD_HOST_PATH_SEP "/"

void TTDHostBuildCurrentExeDirectory(char* path, size_t* pathLength, size_t bufferLength)
{
char exePath[MAX_URI_LENGTH];
//TODO: xplattodo move this logic to PAL
#ifdef __APPLE__
uint32_t tmpPathSize = sizeof(exePath);
_NSGetExecutablePath(exePath, &tmpPathSize);
size_t i = strlen(exePath) - 1;
#else
size_t i = readlink("/proc/self/exe", exePath, MAX_URI_LENGTH) - 1;
#endif

while(exePath[i] != '/')
{
--i;
}
*pathLength = i + 1;

if(*pathLength > bufferLength)
{
wprintf(_u("Don't overflow path buffer during copy."));
exit(1);
}

memcpy_s(path, bufferLength, exePath, *pathLength);
}

int TTDHostMKDir(const char* path, size_t pathLength)
{
return mkdir(path, 0700);
Expand Down
3 changes: 1 addition & 2 deletions bin/ch/ch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ void __stdcall PrintChakraCoreVersion()
char16 dir[_MAX_DIR];

LPCWSTR chakraDllName = GetChakraDllNameW();

char16 modulename[_MAX_PATH];
if (!GetModuleFileNameW(NULL, modulename, _MAX_PATH))
if (!PlatformAgnostic::SystemInfo::GetBinaryLocation(modulename, _MAX_PATH))
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion jenkins/check_eol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fi
ERRFILE=check_eol.sh.err
rm -f $ERRFILE

git diff --name-only `git merge-base origin/master HEAD` HEAD | grep -v -E "(test/.*\\.js|\\.cmd|\\.baseline|\\.wasm)" | xargs -I % ./jenkins/check_file_eol.sh %
git diff --name-only `git merge-base origin/master HEAD` HEAD | grep -v -E "(test/.*\\.js|\\.cmd|\\.baseline|\\.wasm|\\.vcxproj|\\.vcproj|\\.sln)" | xargs -I % ./jenkins/check_file_eol.sh %

if [ -e $ERRFILE ]; then # if error file exists then there were errors
>&2 echo "--------------" # leading >&2 means echo to stderr
Expand Down
1 change: 1 addition & 0 deletions lib/Backend/Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ enum IRDumpFlags
#include "SymTable.h"
#include "IR.h"
#include "Opnd.h"
#include "IntConstMath.h"
#include "IntOverflowDoesNotMatterRange.h"
#include "IntConstantBounds.h"
#include "ValueRelativeOffset.h"
Expand Down
9 changes: 7 additions & 2 deletions lib/Backend/BackendApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,13 @@ void CheckIsExecutable(Js::RecyclableObject * function, Js::JavascriptMethod ent
Js::ScriptContext * scriptContext = function->GetScriptContext();
// it's easy to call the default entry point from RecyclableObject.
AssertMsg((Js::JavascriptFunction::Is(function) && Js::JavascriptFunction::FromVar(function)->IsExternalFunction())
|| Js::CrossSite::IsThunk(entrypoint) || !scriptContext->IsActuallyClosed() ||
(scriptContext->GetThreadContext()->IsScriptActive() && !Js::JavascriptConversion::IsCallable(function)),
|| Js::CrossSite::IsThunk(entrypoint)
// External object with entrypoint
|| (!Js::JavascriptFunction::Is(function)
&& function->IsExternal()
&& Js::JavascriptConversion::IsCallable(function))
|| !scriptContext->IsActuallyClosed()
|| (scriptContext->GetThreadContext()->IsScriptActive() && !Js::JavascriptConversion::IsCallable(function)),
"Can't call function when the script context is closed");

if (scriptContext->GetThreadContext()->IsScriptActive())
Expand Down
28 changes: 26 additions & 2 deletions lib/Backend/BackwardPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2047,8 +2047,8 @@ BackwardPass::ProcessBailOutInfo(IR::Instr * instr)
bool
BackwardPass::IsImplicitCallBailOutCurrentlyNeeded(IR::Instr * instr, bool mayNeedImplicitCallBailOut, bool hasLiveFields)
{
return this->globOpt->IsImplicitCallBailOutCurrentlyNeeded(
instr, nullptr, nullptr, this->currentBlock, hasLiveFields, mayNeedImplicitCallBailOut, false);
return this->globOpt->IsImplicitCallBailOutCurrentlyNeeded(instr, nullptr, nullptr, this->currentBlock, hasLiveFields, mayNeedImplicitCallBailOut, false) ||
this->NeedBailOutOnImplicitCallsForTypedArrayStore(instr);
}

void
Expand Down Expand Up @@ -2235,6 +2235,30 @@ BackwardPass::DeadStoreImplicitCallBailOut(IR::Instr * instr, bool hasLiveFields
}
}

bool
BackwardPass::NeedBailOutOnImplicitCallsForTypedArrayStore(IR::Instr* instr)
{
if ((instr->m_opcode == Js::OpCode::StElemI_A || instr->m_opcode == Js::OpCode::StElemI_A_Strict) &&
instr->GetDst()->IsIndirOpnd() &&
instr->GetDst()->AsIndirOpnd()->GetBaseOpnd()->GetValueType().IsLikelyTypedArray())
{
IR::Opnd * opnd = instr->GetSrc1();
if (opnd->IsRegOpnd())
{
return !opnd->AsRegOpnd()->GetValueType().IsPrimitive() &&
!opnd->AsRegOpnd()->m_sym->IsInt32() &&
!opnd->AsRegOpnd()->m_sym->IsFloat64() &&
!opnd->AsRegOpnd()->m_sym->IsFloatConst() &&
!opnd->AsRegOpnd()->m_sym->IsIntConst();
}
else
{
Assert(opnd->IsIntConstOpnd() || opnd->IsInt64ConstOpnd() || opnd->IsFloat32ConstOpnd() || opnd->IsFloatConstOpnd() || opnd->IsAddrOpnd());
}
}
return false;
}

void
BackwardPass::ProcessPendingPreOpBailOutInfo(IR::Instr *const currentInstr)
{
Expand Down
1 change: 1 addition & 0 deletions lib/Backend/BackwardPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class BackwardPass
void DeadStoreImplicitCallBailOut(IR::Instr * instr, bool hasLiveFields);
void DeadStoreTypeCheckBailOut(IR::Instr * instr);
bool IsImplicitCallBailOutCurrentlyNeeded(IR::Instr * instr, bool mayNeedImplicitCallBailOut, bool hasLiveFields);
bool NeedBailOutOnImplicitCallsForTypedArrayStore(IR::Instr* instr);
bool TrackNoImplicitCallInlinees(IR::Instr *instr);
bool ProcessBailOnNoProfile(IR::Instr *instr, BasicBlock *block);

Expand Down
7 changes: 5 additions & 2 deletions lib/Backend/BailOut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,10 @@ BailOutRecord::BailOutFromLoopBodyInlinedCommon(Js::JavascriptCallStackLayout *
uint32 bailOutOffset, void * returnAddress, IR::BailOutKind bailOutKind, Js::Var branchValue)
{
Assert(bailOutRecord->parent != nullptr);
// This isn't strictly necessary if there's no allocations on this path, but because such an
// issue would be hard to notice and introduce some significant issues, we can do this copy.
// The problem from not doing this and then doing an allocation before RestoreValues is that
// the GC doesn't check the BailOutRegisterSaveSpace.
Js::Var registerSaves[BailOutRegisterSaveSlotCount];
js_memcpy_s(registerSaves, sizeof(registerSaves), (Js::Var *)layout->functionObject->GetScriptContext()->GetThreadContext()->GetBailOutRegisterSaveSpace(),
sizeof(registerSaves));
Expand Down Expand Up @@ -1610,7 +1614,7 @@ BailOutRecord::BailOutHelper(Js::JavascriptCallStackLayout * layout, Js::ScriptF
}
if (isInlinee)
{
newInstance->OrFlags(Js::InterpreterStackFrameFlags_FromInlineeCodeInEHBailOut);
newInstance->OrFlags(Js::InterpreterStackFrameFlags_FromBailOutInInlinee);
}

ThreadContext *threadContext = newInstance->GetScriptContext()->GetThreadContext();
Expand Down Expand Up @@ -2970,7 +2974,6 @@ void GlobalBailOutRecordDataTable::AddOrUpdateRow(JitArenaAllocator *allocator,
if(rowToUpdate->offset == offset &&
rowToUpdate->isInt == (unsigned)isInt &&
rowToUpdate->isFloat == (unsigned)isFloat &&

#ifdef ENABLE_SIMDJS
// SIMD_JS
rowToUpdate->isSimd128F4 == (unsigned) isSimd128F4 &&
Expand Down
1 change: 1 addition & 0 deletions lib/Backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ add_library (Chakra.Backend OBJECT
InliningDecider.cpp
InliningHeuristics.cpp
IntBounds.cpp
IntConstMath.cpp
InterpreterThunkEmitter.cpp
JavascriptNativeOperators.cpp
JITThunkEmitter.cpp
Expand Down
Loading

0 comments on commit eebff83

Please sign in to comment.