Skip to content

Commit 8245503

Browse files
committed
- Added needed types, opcodes, layouts for Int32x4/Float32x4 remaining ops.
- Added Int32x4 min/max, shiftRight/LeftByScalar - For Int16x8, Uint32x4, Uint16x8, Uint8x16: * Enabled constructor/check calls, argument passing, returns, globals import, passing values to modules, return value from module. * Added opcodes, layouts, IRBuilders, Bytecode dumps. Implemented interpreter handlers. - Fixes in lowerer and adding new IRTypes to RegAlloc, Bailout records ... - Relaxed shuffle constraint to accept arbitrary in-range lane indices - Added lowerer support for the following ops of Uint32x4, Uint16x8, Uint8x16, and Int16x8: Constructors, replace/extractLane - Added shuffle/swizzle, load/store operations for all types except Int8x16 - Uint32x4/16x8/8x16 and Int16x8 conversion ops in lowerer - Asmjs support for SIMD bool types - Disabling CSE for new opcodes to accomodate the present opcode space for global opt. - Enabled anyTrue/allTrue coercion check, comparison and select ops for all types. - Several bug fixes in arguments passing/return values, and register allocation for bool types. - Fixed Comparison/select tests for Int32x4 and Float32x4. - Removed Float64x2 support from Asm.js front-end. Fixed tests accordingly. - Added comparison unit-tests for new types: Int16x8, and all unsigned ints. Enable AsmJs Lower support - Changed SIMD object, constructors, and their properties to be Configurable and Writeable. - AsmJs linker does a run timecheck for used SIMD ops - Cleaned up obsolete ops: scale, zero, bool, withFlag* and others, modified UTs. - Changed line endings on JavascriptSIMD*.cpp files to CRLF Added Unit-tests, and fixes to ASMJS link. Added Min/MaxNum. Minor fixes to UTs New SIMD Bool opearions. 1. Adding Constructor, splat, Extract/Replace lane for all SIMD bools. 2. Cleaning up D2 opcodes to make space for the new opcodes. 3. Adding tests. Fix code analysis failure in release build CR Fixes #1 Adding Neg operation for Uint32x4, Uint16x8, Uint8x16. Neg operation for unsigned types in Library, Interpreter and JIT. CR Fixes #2: - Avoid pinning opnds to byte-addressable reg. Copy to new TyInt8 sym instead. - Removed ununsed IRBuilder/BytecodeDumper functions. - SccLiveness will process dst of SHUFPS/D as a src - Minor nit fixes in LowererMDSharedSimd128 Fix copyright headers
1 parent d404084 commit 8245503

File tree

367 files changed

+47510
-17852
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

367 files changed

+47510
-17852
lines changed

lib/Backend/BailOut.cpp

Lines changed: 143 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//-------------------------------------------------------------------------------------------------------
2-
// Copyright (C) Microsoft. All rights reserved.
2+
// Copyright (C) Microsoft Corporation and contributors. All rights reserved.
33
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
44
//-------------------------------------------------------------------------------------------------------
5+
56
#include "Backend.h"
67
#include "Debug/DebuggingFlags.h"
78
#include "Debug/DiagProbe.h"
@@ -395,6 +396,14 @@ void BailOutRecord::DumpArgOffsets(uint count, int* offsets, int argOutSlotStart
395396
// Simd128 reside in Float64 regs
396397
isFloat64 |= this->argOutOffsetInfo->argOutSimd128F4Syms->Test(argOutSlotStart + i) != 0;
397398
isFloat64 |= this->argOutOffsetInfo->argOutSimd128I4Syms->Test(argOutSlotStart + i) != 0;
399+
isFloat64 |= this->argOutOffsetInfo->argOutSimd128I8Syms->Test(argOutSlotStart + i) != 0;
400+
isFloat64 |= this->argOutOffsetInfo->argOutSimd128I16Syms->Test(argOutSlotStart + i) != 0;
401+
isFloat64 |= this->argOutOffsetInfo->argOutSimd128U4Syms->Test(argOutSlotStart + i) != 0;
402+
isFloat64 |= this->argOutOffsetInfo->argOutSimd128U8Syms->Test(argOutSlotStart + i) != 0;
403+
isFloat64 |= this->argOutOffsetInfo->argOutSimd128U16Syms->Test(argOutSlotStart + i) != 0;
404+
isFloat64 |= this->argOutOffsetInfo->argOutSimd128B4Syms->Test(argOutSlotStart + i) != 0;
405+
isFloat64 |= this->argOutOffsetInfo->argOutSimd128B8Syms->Test(argOutSlotStart + i) != 0;
406+
isFloat64 |= this->argOutOffsetInfo->argOutSimd128B16Syms->Test(argOutSlotStart + i) != 0;
398407

399408
Assert(!isFloat64 || !isInt32);
400409

@@ -418,6 +427,14 @@ void BailOutRecord::DumpLocalOffsets(uint count, int argOutSlotStart)
418427
// Simd values are in float64 regs
419428
isFloat64 = isFloat64 || row->isSimd128F4;
420429
isFloat64 = isFloat64 || row->isSimd128I4;
430+
isFloat64 = isFloat64 || row->isSimd128I8;
431+
isFloat64 = isFloat64 || row->isSimd128I16;
432+
isFloat64 = isFloat64 || row->isSimd128U4;
433+
isFloat64 = isFloat64 || row->isSimd128U8;
434+
isFloat64 = isFloat64 || row->isSimd128U16;
435+
isFloat64 = isFloat64 || row->isSimd128B4;
436+
isFloat64 = isFloat64 || row->isSimd128B8;
437+
isFloat64 = isFloat64 || row->isSimd128B16;
421438

422439
Assert(!isFloat64 || !isInt32);
423440

@@ -694,26 +711,48 @@ BailOutRecord::AdjustOffsetsForDiagMode(Js::JavascriptCallStackLayout * layout,
694711
}
695712

696713
void
697-
BailOutRecord::IsOffsetNativeIntOrFloat(uint offsetIndex, int argOutSlotStart, bool * pIsFloat64, bool * pIsInt32, bool * pIsSimd128F4, bool * pIsSimd128I4) const
714+
BailOutRecord::IsOffsetNativeIntOrFloat(uint offsetIndex, int argOutSlotStart, bool * pIsFloat64, bool * pIsInt32,
715+
bool * pIsSimd128F4, bool * pIsSimd128I4, bool * pIsSimd128I8, bool * pIsSimd128I16, bool * pIsSimd128U4,
716+
bool * pIsSimd128U8, bool * pIsSimd128U16, bool * pIsSimd128B4, bool * pIsSimd128B8, bool * pIsSimd128B16) const
698717
{
699718
bool isFloat64 = this->argOutOffsetInfo->argOutFloat64Syms->Test(argOutSlotStart + offsetIndex) != 0;
700719
bool isInt32 = this->argOutOffsetInfo->argOutLosslessInt32Syms->Test(argOutSlotStart + offsetIndex) != 0;
701720
// SIMD_JS
702-
bool isSimd128F4 = this->argOutOffsetInfo->argOutSimd128F4Syms->Test(argOutSlotStart + offsetIndex) != 0;
703-
bool isSimd128I4 = this->argOutOffsetInfo->argOutSimd128I4Syms->Test(argOutSlotStart + offsetIndex) != 0;
704-
705-
Assert(!isFloat64 || !isInt32 || !isSimd128F4 || !isSimd128I4);
721+
bool isSimd128F4 = this->argOutOffsetInfo->argOutSimd128F4Syms->Test(argOutSlotStart + offsetIndex) != 0;
722+
bool isSimd128I4 = this->argOutOffsetInfo->argOutSimd128I4Syms->Test(argOutSlotStart + offsetIndex) != 0;
723+
bool isSimd128I8 = this->argOutOffsetInfo->argOutSimd128I8Syms->Test(argOutSlotStart + offsetIndex) != 0;
724+
bool isSimd128I16 = this->argOutOffsetInfo->argOutSimd128I16Syms->Test(argOutSlotStart + offsetIndex) != 0;
725+
bool isSimd128U4 = this->argOutOffsetInfo->argOutSimd128U4Syms->Test(argOutSlotStart + offsetIndex) != 0;
726+
bool isSimd128U8 = this->argOutOffsetInfo->argOutSimd128U8Syms->Test(argOutSlotStart + offsetIndex) != 0;
727+
bool isSimd128U16 = this->argOutOffsetInfo->argOutSimd128U16Syms->Test(argOutSlotStart + offsetIndex) != 0;
728+
bool isSimd128B4 = this->argOutOffsetInfo->argOutSimd128B4Syms->Test(argOutSlotStart + offsetIndex) != 0;
729+
bool isSimd128B8 = this->argOutOffsetInfo->argOutSimd128B8Syms->Test(argOutSlotStart + offsetIndex) != 0;
730+
bool isSimd128B16 = this->argOutOffsetInfo->argOutSimd128B16Syms->Test(argOutSlotStart + offsetIndex) != 0;
731+
732+
Assert(!isFloat64 || !isInt32 ||
733+
!isSimd128F4 || !isSimd128I4 || !isSimd128I8 || !isSimd128I16 || !
734+
!isSimd128U4 || !isSimd128U8 || !isSimd128U16);
706735

707736
*pIsFloat64 = isFloat64;
708737
*pIsInt32 = isInt32;
709738
*pIsSimd128F4 = isSimd128F4;
710739
*pIsSimd128I4 = isSimd128I4;
740+
*pIsSimd128I8 = isSimd128I8;
741+
*pIsSimd128I16 = isSimd128I16;
742+
*pIsSimd128U4 = isSimd128U4;
743+
*pIsSimd128U8 = isSimd128U8;
744+
*pIsSimd128U16 = isSimd128U16;
745+
*pIsSimd128B4 = isSimd128B4;
746+
*pIsSimd128B8 = isSimd128B8;
747+
*pIsSimd128B16 = isSimd128B16;
711748
}
712749

713750
void
714751
BailOutRecord::RestoreValue(IR::BailOutKind bailOutKind, Js::JavascriptCallStackLayout * layout, Js::Var * values, Js::ScriptContext * scriptContext,
715752
bool fromLoopBody, Js::Var * registerSaves, Js::InterpreterStackFrame * newInstance, Js::Var* pArgumentsObject, void * argoutRestoreAddress,
716-
uint regSlot, int offset, bool isLocal, bool isFloat64, bool isInt32, bool isSimd128F4, bool isSimd128I4) const
753+
uint regSlot, int offset, bool isLocal, bool isFloat64, bool isInt32,
754+
bool isSimd128F4, bool isSimd128I4, bool isSimd128I8, bool isSimd128I16,
755+
bool isSimd128U4, bool isSimd128U8, bool isSimd128U16, bool isSimd128B4, bool isSimd128B8, bool isSimd128B16) const
717756
{
718757
bool boxStackInstance = true;
719758
Js::Var value = 0;
@@ -744,7 +783,11 @@ BailOutRecord::RestoreValue(IR::BailOutKind bailOutKind, Js::JavascriptCallStack
744783
{
745784
int32Value = layout->GetInt32AtOffset(offset);
746785
}
747-
else if (isSimd128F4 || isSimd128I4)
786+
else if (
787+
isSimd128F4 || isSimd128I4 || isSimd128I8 || isSimd128I16 ||
788+
isSimd128U4 || isSimd128U8 || isSimd128U16 || isSimd128B4 ||
789+
isSimd128B8 || isSimd128B16
790+
)
748791
{
749792
// SIMD_JS
750793
simdValue = layout->GetSimdValueAtOffset(offset);
@@ -766,7 +809,11 @@ BailOutRecord::RestoreValue(IR::BailOutKind bailOutKind, Js::JavascriptCallStack
766809
// } catch(..) {..}
767810
// and we bailout during bar args evaluation, we recover from args from argoutRestoreAddress, not from caller function frame.
768811
// This is because try-catch is implemented as a C wrapper, so args will be a different offset from rbp in that case.
769-
Assert(!isFloat64 && !isInt32 && !isSimd128F4 && !isSimd128I4);
812+
Assert(
813+
!isFloat64 && !isInt32 &&
814+
!isSimd128F4 && !isSimd128I4 && !isSimd128I8 && !isSimd128I16 && !isSimd128U4 &&
815+
!isSimd128U8 && !isSimd128U16 && !isSimd128B4 && !isSimd128B8 && !isSimd128B16
816+
);
770817

771818
value = *((Js::Var *)(((char *)argoutRestoreAddress) + regSlot * MachPtr));
772819
AssertMsg(!(newInstance->function->GetFunctionBody()->IsInDebugMode() &&
@@ -798,7 +845,11 @@ BailOutRecord::RestoreValue(IR::BailOutKind bailOutKind, Js::JavascriptCallStack
798845
}
799846
else
800847
{
801-
if (isSimd128F4 || isSimd128I4)
848+
if (
849+
isSimd128F4 || isSimd128I4 || isSimd128I8 || isSimd128I16 ||
850+
isSimd128U4 || isSimd128U8 || isSimd128U16 || isSimd128B4 ||
851+
isSimd128B8 || isSimd128B16
852+
)
802853
{
803854
simdValue = *((SIMDValue *)&(registerSaveSpace[offset - 1]));
804855
}
@@ -875,6 +926,46 @@ BailOutRecord::RestoreValue(IR::BailOutKind bailOutKind, Js::JavascriptCallStack
875926
Assert(!value);
876927
value = Js::JavascriptSIMDInt32x4::New(&simdValue, scriptContext);
877928
}
929+
else if (isSimd128I8)
930+
{
931+
Assert(!value);
932+
value = Js::JavascriptSIMDInt16x8::New(&simdValue, scriptContext);
933+
}
934+
else if (isSimd128I16)
935+
{
936+
Assert(!value);
937+
value = Js::JavascriptSIMDInt8x16::New(&simdValue, scriptContext);
938+
}
939+
else if (isSimd128U4)
940+
{
941+
Assert(!value);
942+
value = Js::JavascriptSIMDUint32x4::New(&simdValue, scriptContext);
943+
}
944+
else if (isSimd128U8)
945+
{
946+
Assert(!value);
947+
value = Js::JavascriptSIMDUint16x8::New(&simdValue, scriptContext);
948+
}
949+
else if (isSimd128U16)
950+
{
951+
Assert(!value);
952+
value = Js::JavascriptSIMDUint8x16::New(&simdValue, scriptContext);
953+
}
954+
else if (isSimd128B4)
955+
{
956+
Assert(!value);
957+
value = Js::JavascriptSIMDBool32x4::New(&simdValue, scriptContext);
958+
}
959+
else if (isSimd128B8)
960+
{
961+
Assert(!value);
962+
value = Js::JavascriptSIMDBool16x8::New(&simdValue, scriptContext);
963+
}
964+
else if (isSimd128B16)
965+
{
966+
Assert(!value);
967+
value = Js::JavascriptSIMDBool8x16::New(&simdValue, scriptContext);
968+
}
878969
else
879970
{
880971
BAILOUT_VERBOSE_TRACE(newInstance->function->GetFunctionBody(), bailOutKind, _u(", value: 0x%p"), value);
@@ -906,7 +997,9 @@ BailOutRecord::RestoreValues(IR::BailOutKind bailOutKind, Js::JavascriptCallStac
906997
globalBailOutRecordTable->IterateGlobalBailOutRecordTableRows(m_bailOutRecordId, [=](GlobalBailOutRecordDataRow *row) {
907998
Assert(row->offset != 0);
908999
RestoreValue(bailOutKind, layout, values, scriptContext, fromLoopBody, registerSaves, newInstance, pArgumentsObject,
909-
argoutRestoreAddress, row->regSlot, row->offset, true, row->isFloat, row->isInt, row->isSimd128F4, row->isSimd128I4);
1000+
argoutRestoreAddress, row->regSlot, row->offset, true, row->isFloat, row->isInt, row->isSimd128F4,
1001+
row->isSimd128I4, row->isSimd128I8, row->isSimd128I16, row->isSimd128U4, row->isSimd128U8, row->isSimd128U16,
1002+
row->isSimd128B4, row->isSimd128B8, row->isSimd128B16);
9101003
});
9111004
}
9121005
else
@@ -918,12 +1011,25 @@ BailOutRecord::RestoreValues(IR::BailOutKind bailOutKind, Js::JavascriptCallStac
9181011
// The variables below determine whether we have a Var or native float/int.
9191012
bool isFloat64;
9201013
bool isInt32;
921-
bool isSimd128F4, isSimd128I4;
1014+
bool isSimd128F4;
1015+
bool isSimd128I4;
1016+
bool isSimd128I8;
1017+
bool isSimd128I16;
1018+
bool isSimd128U4;
1019+
bool isSimd128U8;
1020+
bool isSimd128U16;
1021+
bool isSimd128B4;
1022+
bool isSimd128B8;
1023+
bool isSimd128B16;
9221024

9231025
offset = offsets[i];
924-
this->IsOffsetNativeIntOrFloat(i, argOutSlotStart, &isFloat64, &isInt32, &isSimd128F4, &isSimd128I4);
1026+
this->IsOffsetNativeIntOrFloat(i, argOutSlotStart, &isFloat64, &isInt32,
1027+
&isSimd128F4, &isSimd128I4, &isSimd128I8, &isSimd128I16,
1028+
&isSimd128U4, &isSimd128U8, &isSimd128U16, &isSimd128B4, &isSimd128B8, &isSimd128B16);
1029+
9251030
RestoreValue(bailOutKind, layout, values, scriptContext, fromLoopBody, registerSaves, newInstance, pArgumentsObject,
926-
argoutRestoreAddress, i, offset, false, isFloat64, isInt32, isSimd128F4, isSimd128I4);
1031+
argoutRestoreAddress, i, offset, false, isFloat64, isInt32, isSimd128F4, isSimd128I4, isSimd128I8,
1032+
isSimd128I16, isSimd128U4, isSimd128U8, isSimd128U16, isSimd128B4, isSimd128B8, isSimd128B16);
9271033
}
9281034
}
9291035
}
@@ -2549,7 +2655,9 @@ void GlobalBailOutRecordDataTable::Finalize(NativeCodeData::Allocator *allocator
25492655
#endif
25502656
}
25512657

2552-
void GlobalBailOutRecordDataTable::AddOrUpdateRow(JitArenaAllocator *allocator, uint32 bailOutRecordId, uint32 regSlot, bool isFloat, bool isInt, bool isSimd128F4, bool isSimd128I4, int32 offset, uint *lastUpdatedRowIndex)
2658+
void GlobalBailOutRecordDataTable::AddOrUpdateRow(JitArenaAllocator *allocator, uint32 bailOutRecordId, uint32 regSlot, bool isFloat, bool isInt,
2659+
bool isSimd128F4, bool isSimd128I4, bool isSimd128I8, bool isSimd128I16, bool isSimd128U4, bool isSimd128U8, bool isSimd128U16,
2660+
bool isSimd128B4, bool isSimd128B8, bool isSimd128B16, int32 offset, uint *lastUpdatedRowIndex)
25532661
{
25542662
Assert(offset != 0);
25552663
const int INITIAL_TABLE_SIZE = 64;
@@ -2569,8 +2677,16 @@ void GlobalBailOutRecordDataTable::AddOrUpdateRow(JitArenaAllocator *allocator,
25692677
rowToUpdate->isInt == (unsigned)isInt &&
25702678
rowToUpdate->isFloat == (unsigned)isFloat &&
25712679
// SIMD_JS
2572-
rowToUpdate->isSimd128F4 == (unsigned) isSimd128F4 &&
2573-
rowToUpdate->isSimd128I4 == (unsigned) isSimd128I4 &&
2680+
rowToUpdate->isSimd128F4 == (unsigned) isSimd128F4 &&
2681+
rowToUpdate->isSimd128I4 == (unsigned) isSimd128I4 &&
2682+
rowToUpdate->isSimd128I8 == (unsigned) isSimd128I8 &&
2683+
rowToUpdate->isSimd128I16 == (unsigned) isSimd128I16 &&
2684+
rowToUpdate->isSimd128U4 == (unsigned) isSimd128U4 &&
2685+
rowToUpdate->isSimd128U8 == (unsigned) isSimd128U8 &&
2686+
rowToUpdate->isSimd128U16 == (unsigned) isSimd128U16 &&
2687+
rowToUpdate->isSimd128B4 == (unsigned) isSimd128B4 &&
2688+
rowToUpdate->isSimd128B8 == (unsigned) isSimd128B8 &&
2689+
rowToUpdate->isSimd128B16 == (unsigned) isSimd128B16 &&
25742690

25752691
rowToUpdate->end + 1 == bailOutRecordId)
25762692
{
@@ -2592,8 +2708,16 @@ void GlobalBailOutRecordDataTable::AddOrUpdateRow(JitArenaAllocator *allocator,
25922708
rowToInsert->isFloat = isFloat;
25932709
rowToInsert->isInt = isInt;
25942710
// SIMD_JS
2595-
rowToInsert->isSimd128F4 = isSimd128F4;
2596-
rowToInsert->isSimd128I4 = isSimd128I4;
2711+
rowToInsert->isSimd128F4 = isSimd128F4;
2712+
rowToInsert->isSimd128I4 = isSimd128I4;
2713+
rowToInsert->isSimd128I8 = isSimd128I8 ;
2714+
rowToInsert->isSimd128I16 = isSimd128I16;
2715+
rowToInsert->isSimd128U4 = isSimd128U4 ;
2716+
rowToInsert->isSimd128U8 = isSimd128U8 ;
2717+
rowToInsert->isSimd128U16 = isSimd128U16;
2718+
rowToInsert->isSimd128B4 = isSimd128B4 ;
2719+
rowToInsert->isSimd128B8 = isSimd128B8 ;
2720+
rowToInsert->isSimd128B16 = isSimd128B16;
25972721
rowToInsert->regSlot = regSlot;
25982722
*lastUpdatedRowIndex = length++;
25992723
}

0 commit comments

Comments
 (0)