Skip to content

Commit 1acc3d0

Browse files
committed
Clean up build error when SIMD is disabled with JIT enabled.
1 parent 864b121 commit 1acc3d0

15 files changed

+64
-11
lines changed

lib/Backend/GlobOpt.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5573,6 +5573,7 @@ GlobOpt::OptSrc(IR::Opnd *opnd, IR::Instr * *pInstr, Value **indirIndexValRef, I
55735573
}
55745574
}
55755575

5576+
#ifdef ENABLE_SIMDJS
55765577
// SIMD_JS
55775578
// For uses before defs, we set likelySimd128*SymsUsedBeforeDefined bits for syms that have landing pad value info that allow type-spec to happen in the loop body.
55785579
// The BV will be added to loop header if the backedge has a live matching type-spec value. We then compensate in the loop header to unbox the value.
@@ -5625,6 +5626,7 @@ GlobOpt::OptSrc(IR::Opnd *opnd, IR::Instr * *pInstr, Value **indirIndexValRef, I
56255626
rootLoopPrePass->likelySimd128I4SymsUsedBeforeDefined->Set(sym->m_id);
56265627
}
56275628
}
5629+
#endif
56285630
}
56295631
}
56305632
}
@@ -7598,13 +7600,15 @@ GlobOpt::ValueNumberDst(IR::Instr **pInstr, Value *src1Val, Value *src2Val)
75987600
break;
75997601
}
76007602

7603+
#ifdef ENABLE_SIMDJS
76017604
// SIMD_JS
76027605
if (Js::IsSimd128Opcode(instr->m_opcode) && !func->m_workItem->GetFunctionBody()->GetIsAsmjsMode())
76037606
{
76047607
ThreadContext::SimdFuncSignature simdFuncSignature;
76057608
instr->m_func->GetScriptContext()->GetThreadContext()->GetSimdFuncSignatureFromOpcode(instr->m_opcode, simdFuncSignature);
76067609
return this->NewGenericValue(simdFuncSignature.returnType, dst);
76077610
}
7611+
#endif
76087612

76097613
if (dstVal == nullptr)
76107614
{
@@ -8431,11 +8435,13 @@ GlobOpt::TypeSpecialization(
84318435
Value *const src1OriginalVal = src1Val;
84328436
Value *const src2OriginalVal = src2Val;
84338437

8438+
#ifdef ENABLE_SIMDJS
84348439
// SIMD_JS
84358440
if (TypeSpecializeSimd128(instr, pSrc1Val, pSrc2Val, pDstVal))
84368441
{
84378442
return instr;
84388443
}
8444+
#endif
84398445

84408446
if(!instr->ShouldCheckForIntOverflow())
84418447
{
@@ -16417,8 +16423,10 @@ GlobOpt::OptArraySrc(IR::Instr * *const instrRef)
1641716423
failedToUpdateCompatibleLowerBoundCheck,
1641816424
failedToUpdateCompatibleUpperBoundCheck);
1641916425

16426+
#ifdef ENABLE_SIMDJS
1642016427
// SIMD_JS
1642116428
UpdateBoundCheckHoistInfoForSimd(upperBoundCheckHoistInfo, newBaseValueType, instr);
16429+
#endif
1642216430
}
1642316431

1642416432
if(!eliminatedLowerBoundCheck)

lib/Backend/GlobOpt.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,21 +1382,22 @@ class GlobOpt
13821382
void SetValueToHashTable(GlobHashTable * valueNumberMap, Value *val, Sym *sym);
13831383
IR::Instr * TypeSpecialization(IR::Instr *instr, Value **pSrc1Val, Value **pSrc2Val, Value **pDstVal, bool *redoTypeSpecRef, bool *const forceInvariantHoistingRef);
13841384

1385+
#ifdef ENABLE_SIMDJS
13851386
// SIMD_JS
13861387
bool TypeSpecializeSimd128(IR::Instr *instr, Value **pSrc1Val, Value **pSrc2Val, Value **pDstVal);
13871388
bool Simd128DoTypeSpec(IR::Instr *instr, const Value *src1Val, const Value *src2Val, const Value *dstVal);
13881389
bool Simd128DoTypeSpecLoadStore(IR::Instr *instr, const Value *src1Val, const Value *src2Val, const Value *dstVal, const ThreadContext::SimdFuncSignature *simdFuncSignature);
13891390
bool Simd128CanTypeSpecOpnd(const ValueType opndType, const ValueType expectedType);
13901391
bool Simd128ValidateIfLaneIndex(const IR::Instr * instr, IR::Opnd * opnd, uint argPos);
1391-
1392+
void UpdateBoundCheckHoistInfoForSimd(ArrayUpperBoundCheckHoistInfo &upperHoistInfo, ValueType arrValueType, const IR::Instr *instr);
1393+
void Simd128SetIndirOpndType(IR::IndirOpnd *indirOpnd, Js::OpCode opcode);
1394+
#endif
1395+
13921396
IRType GetIRTypeFromValueType(const ValueType &valueType);
13931397
ValueType GetValueTypeFromIRType(const IRType &type);
13941398
IR::BailOutKind GetBailOutKindFromValueType(const ValueType &valueType);
13951399
IR::Instr * GetExtendedArg(IR::Instr *instr);
1396-
void UpdateBoundCheckHoistInfoForSimd(ArrayUpperBoundCheckHoistInfo &upperHoistInfo, ValueType arrValueType, const IR::Instr *instr);
13971400
int GetBoundCheckOffsetForSimd(ValueType arrValueType, const IR::Instr *instr, const int oldOffset = -1);
1398-
void Simd128SetIndirOpndType(IR::IndirOpnd *indirOpnd, Js::OpCode opcode);
1399-
14001401

14011402
IR::Instr * OptNewScObject(IR::Instr** instrPtr, Value* srcVal);
14021403
bool OptConstFoldBinary(IR::Instr * *pInstr, const IntConstantBounds &src1IntConstantBounds, const IntConstantBounds &src2IntConstantBounds, Value **pDstVal);

lib/Backend/GlobOptSimd128.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include "Backend.h"
99

10+
#ifdef ENABLE_SIMDJS
11+
1012
/*
1113
Handles all Simd128 type-spec of an instr, if possible.
1214
*/
@@ -461,6 +463,8 @@ IR::Instr * GlobOpt::GetExtendedArg(IR::Instr *instr)
461463
}
462464
}
463465

466+
#endif
467+
464468
IRType GlobOpt::GetIRTypeFromValueType(const ValueType &valueType)
465469
{
466470
if (valueType.IsFloat())
@@ -524,6 +528,7 @@ IR::BailOutKind GlobOpt::GetBailOutKindFromValueType(const ValueType &valueType)
524528
}
525529
}
526530

531+
#ifdef ENABLE_SIMDJS
527532
void
528533
GlobOpt::UpdateBoundCheckHoistInfoForSimd(ArrayUpperBoundCheckHoistInfo &upperHoistInfo, ValueType arrValueType, const IR::Instr *instr)
529534
{
@@ -535,10 +540,11 @@ GlobOpt::UpdateBoundCheckHoistInfoForSimd(ArrayUpperBoundCheckHoistInfo &upperHo
535540
int newOffset = GetBoundCheckOffsetForSimd(arrValueType, instr, upperHoistInfo.Offset());
536541
upperHoistInfo.UpdateOffset(newOffset);
537542
}
538-
543+
#endif
539544
int
540545
GlobOpt::GetBoundCheckOffsetForSimd(ValueType arrValueType, const IR::Instr *instr, const int oldOffset /* = -1 */)
541546
{
547+
#ifdef ENABLE_SIMDJS
542548
if (!(Js::IsSimd128LoadStore(instr->m_opcode)))
543549
{
544550
return oldOffset;
@@ -563,8 +569,12 @@ GlobOpt::GetBoundCheckOffsetForSimd(ValueType arrValueType, const IR::Instr *ins
563569
// we should always make an existing bound-check more conservative.
564570
Assert(offsetBias <= 0);
565571
return oldOffset + offsetBias;
572+
#else
573+
return oldOffset;
574+
#endif
566575
}
567576

577+
#ifdef ENABLE_SIMDJS
568578
void
569579
GlobOpt::Simd128SetIndirOpndType(IR::IndirOpnd *indirOpnd, Js::OpCode opcode)
570580
{
@@ -585,4 +595,4 @@ GlobOpt::Simd128SetIndirOpndType(IR::IndirOpnd *indirOpnd, Js::OpCode opcode)
585595
}
586596

587597
}
588-
598+
#endif

lib/Backend/Inline.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,7 +2034,8 @@ Inline::InlineBuiltInFunction(IR::Instr *callInstr, Js::FunctionInfo *funcInfo,
20342034
byteCodeUsesInstr->byteCodeUpwardExposedUsed = JitAnew(callInstr->m_func->m_alloc, BVSparse<JitArenaAllocator>, callInstr->m_func->m_alloc);
20352035
IR::Instr *argInsertInstr = inlineBuiltInStartInstr;
20362036

2037-
// SIMD_JS
2037+
#ifdef ENABLE_SIMDJS
2038+
// SIMD_JS
20382039
IR::Instr *eaInsertInstr = callInstr;
20392040
IR::Opnd *eaLinkOpnd = nullptr;
20402041
ThreadContext::SimdFuncSignature simdFuncSignature;
@@ -2046,7 +2047,8 @@ Inline::InlineBuiltInFunction(IR::Instr *callInstr, Js::FunctionInfo *funcInfo,
20462047
Assert(simdFuncSignature.argCount == (uint)inlineCallArgCount);
20472048
Assert(simdFuncSignature.argCount == (uint)requiredInlineCallArgCount);
20482049
}
2049-
//
2050+
#endif
2051+
20502052
inlineBuiltInEndInstr->IterateArgInstrs([&](IR::Instr* argInstr) {
20512053
StackSym *linkSym = linkOpnd->GetStackSym();
20522054
linkSym->m_isInlinedArgSlot = true;
@@ -2068,6 +2070,7 @@ Inline::InlineBuiltInFunction(IR::Instr *callInstr, Js::FunctionInfo *funcInfo,
20682070
// Convert the arg out to built in arg out, and get the src of the arg out
20692071
IR::Opnd * argOpnd = ConvertToInlineBuiltInArgOut(argInstr);
20702072

2073+
#ifdef ENABLE_SIMDJS
20712074
// SIMD_JS
20722075
if (inlineCallArgCount > 2 && argIndex != 0 /* don't include 'this' */)
20732076
{
@@ -2108,6 +2111,7 @@ Inline::InlineBuiltInFunction(IR::Instr *callInstr, Js::FunctionInfo *funcInfo,
21082111
eaInsertInstr = eaInstr;
21092112
}
21102113
else
2114+
#endif
21112115
{
21122116
// Use parameter to the inline call to tempDst.
21132117
if (argIndex == 2)
@@ -2135,8 +2139,10 @@ Inline::InlineBuiltInFunction(IR::Instr *callInstr, Js::FunctionInfo *funcInfo,
21352139
return false;
21362140
});
21372141

2142+
#ifdef ENABLE_SIMDJS
21382143
//SIMD_JS
21392144
Simd128FixLoadStoreInstr(builtInId, callInstr);
2145+
#endif
21402146

21412147
if(inlineCallOpCode == Js::OpCode::InlineMathImul || inlineCallOpCode == Js::OpCode::InlineMathClz32)
21422148
{
@@ -5255,6 +5261,7 @@ Inline::GetMethodLdOpndForCallInstr(IR::Instr* callInstr)
52555261
return nullptr;
52565262
}
52575263

5264+
#ifdef ENABLE_SIMDJS
52585265
// SIMD_JS
52595266
/*
52605267
Fixes the format of a SIMD load/store to match format expected by globOpt. Namely:
@@ -5369,3 +5376,4 @@ Inline::Simd128FixLoadStoreInstr(Js::BuiltinFunction builtInId, IR::Instr * call
53695376

53705377
}
53715378
}
5379+
#endif

lib/Backend/Inline.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ class Inline
9191
bool IsArgumentsOpnd(IR::Opnd* opnd,SymID argumentsSymId);
9292
void Cleanup(IR::Instr *callInstr);
9393
IR::PropertySymOpnd* GetMethodLdOpndForCallInstr(IR::Instr* callInstr);
94+
#ifdef ENABLE_SIMDJS
9495
void Simd128FixLoadStoreInstr(Js::BuiltinFunction builtInId, IR::Instr * callInstr);
96+
#endif
9597
IR::Instr* InsertInlineeBuiltInStartEndTags(IR::Instr* callInstr, uint actualcount, IR::Instr** builtinStartInstr = nullptr);
9698
bool IsInliningOutSideLoops(){return topFunc->GetJnFunction()->GetHasLoops() && isInLoop == 0; }
9799

lib/Backend/InliningDecider.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ bool InliningDecider::GetBuiltInInfo(
585585
break;
586586
#endif
587587

588+
#ifdef ENABLE_SIMDJS
588589
// SIMD_JS
589590
// we only inline, and hence type-spec on IA
590591
#if defined(_M_X64) || defined(_M_IX86)
@@ -601,6 +602,7 @@ bool InliningDecider::GetBuiltInInfo(
601602
}
602603
}
603604
#endif
605+
#endif // ENABLE_SIMDJS
604606
}
605607
return true;
606608
}

lib/Backend/Lower.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,7 @@ Lowerer::LowerRange(IR::Instr *instrStart, IR::Instr *instrEnd, bool defaultDoFa
17421742
m_lowererMD.EmitLoadFloatFromNumber(instr->GetDst(), instr->GetSrc1(), instr);
17431743
}
17441744
}
1745+
#ifdef ENABLE_SIMDJS
17451746
// Support on IA only
17461747
#if defined(_M_IX86) || defined(_M_X64)
17471748
else if (instr->GetDst()->IsSimd128())
@@ -1750,6 +1751,7 @@ Lowerer::LowerRange(IR::Instr *instrStart, IR::Instr *instrEnd, bool defaultDoFa
17501751
m_lowererMD.GenerateCheckedSimdLoad(instr);
17511752
}
17521753
#endif
1754+
#endif // ENABLE_SIMDJS
17531755
else
17541756
{
17551757
Assert(UNREACHED);
@@ -1796,11 +1798,13 @@ Lowerer::LowerRange(IR::Instr *instrStart, IR::Instr *instrEnd, bool defaultDoFa
17961798
instr->GetSrc1()->AsRegOpnd(), instr, instr);
17971799
instr->Remove();
17981800
}
1801+
#ifdef ENABLE_SIMDJS
17991802
#if defined(_M_IX86) || defined(_M_X64)
18001803
else if (IRType_IsSimd128(instr->GetSrc1()->GetType()))
18011804
{
18021805
m_lowererMD.GenerateSimdStore(instr);
18031806
}
1807+
#endif
18041808
#endif
18051809
else
18061810
{
@@ -2969,12 +2973,14 @@ Lowerer::LowerRange(IR::Instr *instrStart, IR::Instr *instrEnd, bool defaultDoFa
29692973
break;
29702974

29712975
default:
2976+
#ifdef ENABLE_SIMDJS
29722977
#if defined(_M_IX86) || defined(_M_X64)
29732978
if (IsSimd128Opcode(instr->m_opcode))
29742979
{
29752980
instrPrev = m_lowererMD.Simd128Instruction(instr);
29762981
break;
29772982
}
2983+
#endif
29782984
#endif
29792985
AssertMsg(instr->IsLowered(), "Unknown opcode");
29802986
if(!instr->IsLowered())

lib/Backend/LowerMDShared.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,9 @@ LowererMD::Init(Lowerer *lowerer)
494494
{
495495
m_lowerer = lowerer;
496496
this->lowererMDArch.Init(this);
497+
#ifdef ENABLE_SIMDJS
497498
Simd128InitOpcodeMap();
499+
#endif
498500
}
499501

500502
///----------------------------------------------------------------------------

lib/Backend/LowerMDShared.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ class LowererMD
307307
static void InsertIncUInt8PreventOverflow(IR::Opnd *const dst, IR::Opnd *const src, IR::Instr *const insertBeforeInstr, IR::Instr * *const onOverflowInsertBeforeInstrRef = nullptr);
308308
static void InsertDecUInt8PreventOverflow(IR::Opnd *const dst, IR::Opnd *const src, IR::Instr *const insertBeforeInstr, IR::Instr * *const onOverflowInsertBeforeInstrRef = nullptr);
309309

310+
#ifdef ENABLE_SIMDJS
310311
void Simd128InitOpcodeMap();
311312
IR::Instr* Simd128Instruction(IR::Instr* instr);
312313
IR::Instr* Simd128LoadConst(IR::Instr* instr);
@@ -359,6 +360,7 @@ class LowererMD
359360
void GenerateSimdStore(IR::Instr * instr);
360361
void CheckShuffleLanes_4(uint8 lanes[], uint8 lanesSrc[], uint *fromSrc1, uint *fromSrc2);
361362
void InsertShufps(uint8 lanes[], IR::Opnd *dst, IR::Opnd *src1, IR::Opnd *src2, IR::Instr *insertBeforeInstr);
363+
#endif
362364

363365
private:
364366

lib/Backend/LowerMDSharedSimd128.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include "Backend.h"
77

8+
#ifdef ENABLE_SIMDJS
9+
810
#define GET_SIMDOPCODE(irOpcode) m_simd128OpCodesMap[(uint32)(irOpcode - Js::OpCode::Simd128_Start)]
911

1012
#define SET_SIMDOPCODE(irOpcode, mdOpcode) \
@@ -3467,3 +3469,5 @@ BYTE LowererMD::Simd128GetTypedArrBytesPerElem(ValueType arrType)
34673469
{
34683470
return (1 << Lowerer::GetArrayIndirScale(arrType));
34693471
}
3472+
3473+
#endif

lib/Runtime/Base/ThreadContext.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ ThreadContext::ThreadContext(AllocationPolicyManager * allocationPolicyManager,
210210
this->bailOutRegisterSaveSpace = AnewArrayZ(this->GetThreadAlloc(), Js::Var, GetBailOutRegisterSaveSlotCount());
211211
#endif
212212

213+
#ifdef ENABLE_SIMDJS
213214
// SIMD_JS
214215
#if ENABLE_NATIVE_CODEGEN
215216
simdFuncInfoToOpcodeMap = Anew(this->GetThreadAlloc(), FuncInfoToOpcodeMap, this->GetThreadAlloc());
@@ -221,6 +222,7 @@ ThreadContext::ThreadContext(AllocationPolicyManager * allocationPolicyManager,
221222
#define MACRO_SIMD_EXTEND_WMS(op, LayoutAsmJs, OpCodeAttrAsmJs, OpCodeAttr, ...) MACRO_SIMD_WMS(op, LayoutAsmJs, OpCodeAttrAsmJs, OpCodeAttr, __VA_ARGS__)
222223

223224
#include "ByteCode/OpCodesSimd.h"
225+
#endif
224226
}
225227
#endif
226228

@@ -552,7 +554,7 @@ void ThreadContext::ValidateThreadContext()
552554
#endif
553555
}
554556

555-
#if ENABLE_NATIVE_CODEGEN
557+
#if ENABLE_NATIVE_CODEGEN && defined(ENABLE_SIMDJS)
556558
void ThreadContext::AddSimdFuncToMaps(Js::OpCode op, ...)
557559
{
558560
Assert(simdFuncInfoToOpcodeMap != nullptr);

lib/Runtime/Base/ThreadContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ class ThreadContext sealed :
440440
}
441441
#endif
442442

443-
#if ENABLE_NATIVE_CODEGEN
443+
#if ENABLE_NATIVE_CODEGEN && defined(ENABLE_SIMDJS)
444444
// used by inliner. Maps Simd FuncInfo (library func) to equivalent opcode.
445445
typedef JsUtil::BaseDictionary<Js::FunctionInfo *, Js::OpCode, ArenaAllocator> FuncInfoToOpcodeMap;
446446
FuncInfoToOpcodeMap * simdFuncInfoToOpcodeMap;

lib/Runtime/Language/AsmJsLink.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ namespace Js{
142142
}
143143
}
144144

145+
#ifdef ENABLE_SIMDJS
145146
Var asmSimdObject = JavascriptOperators::OP_GetProperty(stdlib, PropertyIds::SIMD, scriptContext);
146147
for (int i = 0; i < AsmJsSIMDBuiltinFunction::AsmJsSIMDBuiltin_COUNT; i++)
147148
{
@@ -156,6 +157,7 @@ namespace Js{
156157
return false;
157158
}
158159
}
160+
#endif
159161

160162
return true;
161163
}
@@ -567,6 +569,7 @@ namespace Js{
567569
return false;
568570
}
569571

572+
#ifdef ENABLE_SIMDJS
570573
bool ASMLink::CheckSimdLibraryMethod(ScriptContext* scriptContext, const Var asmSimdObject, const AsmJsSIMDBuiltinFunction simdLibMethod)
571574
{
572575
Var simdConstructorObj, simdFuncObj;
@@ -609,6 +612,7 @@ namespace Js{
609612
}
610613
return false;
611614
}
615+
#endif
612616

613617

614618

lib/Runtime/Language/AsmJsLink.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ namespace Js{
1616
static bool CheckFFI(ScriptContext* scriptContext, AsmJsModuleInfo* info, const Var foreign);
1717
static bool CheckArrayLibraryMethod(ScriptContext* scriptContext, const Var stdlib, const AsmJSTypedArrayBuiltinFunction arrayBuiltin);
1818
static bool CheckMathLibraryMethod(ScriptContext* scriptContext, const Var asmMathObject, const AsmJSMathBuiltinFunction mathBuiltin);
19+
#ifdef ENABLE_SIMDJS
1920
static bool CheckSimdLibraryMethod(ScriptContext* scriptContext, const Var asmSimdObject, const AsmJsSIMDBuiltinFunction simdBuiltin);
21+
#endif
2022
};
2123
}
2224
#endif

0 commit comments

Comments
 (0)