AsmJsModule.cpp 199 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft Corporation and contributors. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #include "RuntimeLanguagePch.h"
  6. #ifdef ASMJS_PLAT
  7. #include "ByteCode/Symbol.h"
  8. #include "ByteCode/FuncInfo.h"
  9. #include "ByteCode/ByteCodeApi.h"
  10. #include "ByteCode/ByteCodeWriter.h"
  11. #include "ByteCode/ByteCodeGenerator.h"
  12. #include "ByteCode/AsmJsByteCodeWriter.h"
  13. #include "Language/AsmJsByteCodeGenerator.h"
  14. #if DBG_DUMP
  15. #include "ByteCode/ByteCodeDumper.h"
  16. #include "ByteCode/AsmJsByteCodeDumper.h"
  17. #endif
  18. namespace Js
  19. {
  20. bool AsmJsModuleCompiler::CompileAllFunctions()
  21. {
  22. const int size = mFunctionArray.Count();
  23. for (int i = 0; i < size; i++)
  24. {
  25. AsmJsFunc* func = mFunctionArray.Item(i);
  26. if (!CompileFunction(func, i))
  27. {
  28. // an error occurred in the function, revert state on all asm.js functions
  29. for (int j = 0; j <= i; j++)
  30. {
  31. RevertFunction(j);
  32. }
  33. return false;
  34. }
  35. func->Finish();
  36. }
  37. return true;
  38. }
  39. void AsmJsModuleCompiler::RevertFunction(int funcIndex)
  40. {
  41. AsmJsFunc* func = mFunctionArray.Item(funcIndex);
  42. FunctionBody * funcBody = func->GetFuncBody();
  43. funcBody->ResetByteCodeGenState();
  44. funcBody->AddDeferParseAttribute();
  45. funcBody->SetFunctionParsed(false);
  46. funcBody->ResetEntryPoint();
  47. funcBody->SetEntryPoint(funcBody->GetDefaultEntryPointInfo(), GetScriptContext()->DeferredParsingThunk);
  48. funcBody->SetIsAsmjsMode(false);
  49. funcBody->SetIsAsmJsFunction(false);
  50. func->GetFncNode()->sxFnc.funcInfo->byteCodeFunction = func->GetFuncBody();
  51. }
  52. void AsmJsModuleCompiler::RevertAllFunctions()
  53. {
  54. for (int i = 0; i < mFunctionArray.Count(); i++)
  55. {
  56. RevertFunction(i);
  57. }
  58. }
  59. bool AsmJsModuleCompiler::CommitFunctions()
  60. {
  61. const int size = mFunctionArray.Count();
  62. // if changeHeap is defined, it must be first function, so we should skip it
  63. for (int i = 0; i < size; i++)
  64. {
  65. AsmJsFunc* func = mFunctionArray.Item(i);
  66. FunctionBody* functionBody = func->GetFuncBody();
  67. AsmJsFunctionInfo* asmInfo = functionBody->AllocateAsmJsFunctionInfo();
  68. if (!asmInfo->Init(func))
  69. {
  70. return false;
  71. }
  72. asmInfo->SetUsesHeapBuffer(mUsesHeapBuffer);
  73. functionBody->CheckAndSetOutParamMaxDepth(func->GetMaxArgOutDepth());
  74. // should be set in EmitOneFunction
  75. Assert(functionBody->GetIsAsmjsMode());
  76. Assert(functionBody->GetIsAsmJsFunction());
  77. ((EntryPointInfo*)functionBody->GetDefaultEntryPointInfo())->SetIsAsmJSFunction(true);
  78. #if DBG_DUMP && defined(ASMJS_PLAT)
  79. if (PHASE_DUMP(ByteCodePhase, functionBody))
  80. {
  81. AsmJsByteCodeDumper::Dump(functionBody, nullptr, func);
  82. }
  83. #endif
  84. #if _M_IX86
  85. if (PHASE_ON1(AsmJsJITTemplatePhase) && !Configuration::Global.flags.NoNative)
  86. {
  87. AsmJsCodeGenerator* generator = GetScriptContext()->GetAsmJsCodeGenerator();
  88. AccumulateCompileTime();
  89. if (!generator)
  90. {
  91. generator = GetScriptContext()->InitAsmJsCodeGenerator();
  92. }
  93. Assert(generator);
  94. generator->CodeGen(functionBody);
  95. AccumulateCompileTime(AsmJsCompilation::TemplateJIT);
  96. }
  97. #endif
  98. }
  99. return true;
  100. }
  101. bool AsmJsModuleCompiler::CommitModule()
  102. {
  103. FuncInfo* funcInfo = GetModuleFunctionNode()->sxFnc.funcInfo;
  104. FunctionBody* functionBody = funcInfo->GetParsedFunctionBody();
  105. AsmJsModuleInfo* asmInfo = functionBody->AllocateAsmJsModuleInfo();
  106. if (funcInfo->byteCodeFunction->GetIsNamedFunctionExpression())
  107. {
  108. Assert(GetModuleFunctionNode()->sxFnc.pnodeName);
  109. if (GetModuleFunctionNode()->sxFnc.pnodeName->sxVar.sym->IsInSlot(funcInfo))
  110. {
  111. ParseNodePtr nameNode = GetModuleFunctionNode()->sxFnc.pnodeName;
  112. GetByteCodeGenerator()->AssignPropertyId(nameNode->name());
  113. // if module is a named function expression, we may need to restore this for debugger
  114. AsmJsClosureFunction* closure = Anew(&mAllocator, AsmJsClosureFunction, nameNode->sxVar.pid, AsmJsSymbol::ClosureFunction, &mAllocator);
  115. DefineIdentifier(nameNode->sxVar.pid, closure);
  116. }
  117. }
  118. int argCount = 0;
  119. if (mBufferArgName)
  120. {
  121. argCount = 3;
  122. }
  123. else if (mForeignArgName)
  124. {
  125. argCount = 2;
  126. }
  127. else if (mStdLibArgName)
  128. {
  129. argCount = 1;
  130. }
  131. const int functionCount = mFunctionArray.Count();
  132. const int functionTableCount = mFunctionTableArray.Count();
  133. const int importFunctionCount = mImportFunctions.GetTotalVarCount();
  134. asmInfo->SetFunctionCount(functionCount);
  135. asmInfo->SetFunctionTableCount(functionTableCount);
  136. asmInfo->SetFunctionImportCount(importFunctionCount);
  137. asmInfo->SetVarCount(mVarCount);
  138. asmInfo->SetVarImportCount(mVarImportCount);
  139. asmInfo->SetArgInCount(argCount);
  140. asmInfo->SetModuleMemory(mModuleMemory);
  141. asmInfo->SetAsmMathBuiltinUsed(mAsmMathBuiltinUsedBV);
  142. asmInfo->SetAsmArrayBuiltinUsed(mAsmArrayBuiltinUsedBV);
  143. asmInfo->SetMaxHeapAccess(mMaxHeapAccess);
  144. #ifdef ENABLE_SIMDJS
  145. if (IsSimdjsEnabled())
  146. {
  147. asmInfo->SetAsmSimdBuiltinUsed(mAsmSimdBuiltinUsedBV);
  148. asmInfo->SetSimdRegCount(mSimdVarSpace.GetTotalVarCount());
  149. }
  150. #endif
  151. int varCount = 3; // 3 possible arguments
  152. functionBody->SetInParamsCount(4); // Always set 4 inParams so the memory space is the same (globalEnv,stdlib,foreign,buffer)
  153. functionBody->SetReportedInParamsCount(4);
  154. functionBody->CheckAndSetConstantCount(2); // Return register + Root
  155. functionBody->CreateConstantTable();
  156. functionBody->CheckAndSetVarCount(varCount);
  157. functionBody->SetIsAsmjsMode(true);
  158. functionBody->NewObjectLiteral(); // allocate one object literal for the export object
  159. AsmJSByteCodeGenerator::EmitEmptyByteCode(funcInfo, GetByteCodeGenerator(), GetModuleFunctionNode());
  160. // Create export module proxy
  161. asmInfo->SetExportFunctionIndex(mExportFuncIndex);
  162. asmInfo->SetExportsCount(mExports.Count());
  163. auto exportIter = mExports.GetIterator();
  164. for (int exportIndex = 0; exportIter.IsValid(); ++exportIndex)
  165. {
  166. const AsmJsModuleExport& exMod = exportIter.CurrentValue();
  167. auto ex = asmInfo->GetExport(exportIndex);
  168. *ex.id = exMod.id;
  169. *ex.location = exMod.location;
  170. exportIter.MoveNext();
  171. }
  172. int iVar = 0, iVarImp = 0, iFunc = 0, iFuncImp = 0;
  173. const int moduleEnvCount = mModuleEnvironment.Count();
  174. asmInfo->InitializeSlotMap(moduleEnvCount);
  175. auto slotMap = asmInfo->GetAsmJsSlotMap();
  176. for (int i = 0; i < moduleEnvCount; i++)
  177. {
  178. AsmJsSymbol* sym = mModuleEnvironment.GetValueAt(i);
  179. if (sym)
  180. {
  181. AsmJsSlot * slot = RecyclerNewLeaf(GetScriptContext()->GetRecycler(), AsmJsSlot);
  182. slot->symType = sym->GetSymbolType();
  183. slotMap->AddNew(sym->GetName()->GetPropertyId(), slot);
  184. switch (sym->GetSymbolType())
  185. {
  186. case AsmJsSymbol::Variable:
  187. {
  188. AsmJsVar* var = AsmJsVar::FromSymbol(sym);
  189. auto& modVar = asmInfo->GetVar(iVar++);
  190. modVar.location = var->GetLocation();
  191. modVar.type = var->GetVarType().which();
  192. if (var->GetVarType().isInt())
  193. {
  194. modVar.initialiser.intInit = var->GetIntInitialiser();
  195. }
  196. else if (var->GetVarType().isFloat())
  197. {
  198. modVar.initialiser.floatInit = var->GetFloatInitialiser();
  199. }
  200. else if (var->GetVarType().isDouble())
  201. {
  202. modVar.initialiser.doubleInit = var->GetDoubleInitialiser();
  203. }
  204. #ifdef ENABLE_SIMDJS
  205. else if (IsSimdjsEnabled() && var->GetVarType().isSIMD())
  206. {
  207. modVar.initialiser.simdInit = var->GetSimdConstInitialiser();
  208. }
  209. #endif
  210. else
  211. {
  212. Assert(UNREACHED);
  213. }
  214. modVar.isMutable = var->isMutable();
  215. slot->location = modVar.location;
  216. slot->varType = var->GetVarType().which();
  217. slot->isConstVar = !modVar.isMutable;
  218. break;
  219. }
  220. case AsmJsSymbol::ConstantImport:
  221. {
  222. AsmJsConstantImport* var = AsmJsConstantImport::FromSymbol(sym);
  223. auto& modVar = asmInfo->GetVarImport(iVarImp++);
  224. modVar.location = var->GetLocation();
  225. modVar.field = var->GetField()->GetPropertyId();
  226. modVar.type = var->GetVarType().which();
  227. slot->location = modVar.location;
  228. slot->varType = modVar.type;
  229. break;
  230. }
  231. case AsmJsSymbol::ImportFunction:
  232. {
  233. AsmJsImportFunction* func = AsmJsImportFunction::FromSymbol(sym);
  234. auto& modVar = asmInfo->GetFunctionImport(iFuncImp++);
  235. modVar.location = func->GetFunctionIndex();
  236. modVar.field = func->GetField()->GetPropertyId();
  237. slot->location = modVar.location;
  238. break;
  239. }
  240. case AsmJsSymbol::FuncPtrTable:
  241. {
  242. AsmJsFunctionTable* funcTable = AsmJsFunctionTable::FromSymbol(sym);
  243. const uint size = funcTable->GetSize();
  244. const RegSlot index = funcTable->GetFunctionIndex();
  245. asmInfo->SetFunctionTableSize(index, size);
  246. auto& modTable = asmInfo->GetFunctionTable(index);
  247. for (uint j = 0; j < size; j++)
  248. {
  249. modTable.moduleFunctionIndex[j] = funcTable->GetModuleFunctionIndex(j);
  250. }
  251. slot->funcTableSize = size;
  252. slot->location = index;
  253. break;
  254. }
  255. case AsmJsSymbol::ModuleFunction:
  256. {
  257. AsmJsFunc* func = AsmJsFunc::FromSymbol(sym);
  258. auto& modVar = asmInfo->GetFunction(iFunc++);
  259. modVar.location = func->GetFunctionIndex();
  260. slot->location = modVar.location;
  261. break;
  262. }
  263. case AsmJsSymbol::ArrayView:
  264. {
  265. AsmJsArrayView * var = AsmJsArrayView::FromSymbol(sym);
  266. slot->viewType = var->GetViewType();
  267. break;
  268. }
  269. case AsmJsSymbol::ModuleArgument:
  270. {
  271. AsmJsModuleArg * arg = AsmJsModuleArg::FromSymbol(sym);
  272. slot->argType = arg->GetArgType();
  273. break;
  274. }
  275. // used only for module validation
  276. case AsmJsSymbol::MathConstant:
  277. {
  278. AsmJsMathConst * constVar = AsmJsMathConst::FromSymbol(sym);
  279. slot->mathConstVal = *constVar->GetVal();
  280. break;
  281. }
  282. case AsmJsSymbol::MathBuiltinFunction:
  283. {
  284. AsmJsMathFunction * mathFunc = AsmJsMathFunction::FromSymbol(sym);
  285. slot->builtinMathFunc = mathFunc->GetMathBuiltInFunction();
  286. break;
  287. }
  288. case AsmJsSymbol::TypedArrayBuiltinFunction:
  289. {
  290. AsmJsTypedArrayFunction * mathFunc = AsmJsTypedArrayFunction::FromSymbol(sym);
  291. slot->builtinArrayFunc = mathFunc->GetArrayBuiltInFunction();
  292. break;
  293. }
  294. case AsmJsSymbol::SIMDBuiltinFunction:
  295. {
  296. AsmJsSIMDFunction * mathFunc = AsmJsSIMDFunction::FromSymbol(sym);
  297. slot->builtinSIMDFunc = mathFunc->GetSimdBuiltInFunction();
  298. break;
  299. }
  300. case AsmJsSymbol::ClosureFunction:
  301. // we don't need to store any additional info in this case
  302. break;
  303. default:
  304. Assume(UNREACHED);
  305. }
  306. }
  307. }
  308. return true;
  309. }
  310. void AsmJsModuleCompiler::ASTPrepass(ParseNodePtr pnode, AsmJsFunc * func)
  311. {
  312. ThreadContext::ProbeCurrentStackNoDispose(Js::Constants::MinStackByteCodeVisitor, GetByteCodeGenerator()->GetScriptContext());
  313. if (pnode == NULL)
  314. {
  315. return;
  316. }
  317. switch (pnode->nop) {
  318. // these first cases do the interesting work
  319. case knopBreak:
  320. case knopContinue:
  321. GetByteCodeGenerator()->AddTargetStmt(pnode->sxJump.pnodeTarget);
  322. break;
  323. case knopInt:
  324. func->AddConst<int>(pnode->sxInt.lw);
  325. break;
  326. case knopFlt:
  327. {
  328. const double d = pnode->sxFlt.dbl;
  329. if (ParserWrapper::IsMinInt(pnode))
  330. {
  331. func->AddConst<int>((int)d);
  332. }
  333. else if (ParserWrapper::IsUnsigned(pnode))
  334. {
  335. func->AddConst<int>((int)(uint32)d);
  336. }
  337. else
  338. {
  339. func->AddConst<double>(d);
  340. }
  341. break;
  342. }
  343. case knopName:
  344. {
  345. GetByteCodeGenerator()->AssignPropertyId(pnode->name());
  346. AsmJsSymbol * declSym = LookupIdentifier(pnode->name());
  347. if (declSym)
  348. {
  349. if (AsmJsMathConst::Is(declSym))
  350. {
  351. AsmJsMathConst * definition = AsmJsMathConst::FromSymbol(declSym);
  352. Assert(definition->GetType().isDouble());
  353. func->AddConst<double>(*definition->GetVal());
  354. }
  355. else if (AsmJsVar::Is(declSym) && !declSym->isMutable())
  356. {
  357. AsmJsVar * definition = AsmJsVar::FromSymbol(declSym);
  358. switch (definition->GetVarType().which())
  359. {
  360. case AsmJsVarType::Double:
  361. func->AddConst<double>(definition->GetDoubleInitialiser());
  362. break;
  363. case AsmJsVarType::Float:
  364. func->AddConst<float>(definition->GetFloatInitialiser());
  365. break;
  366. case AsmJsVarType::Int:
  367. func->AddConst<int>(definition->GetIntInitialiser());
  368. break;
  369. default:
  370. Assume(UNREACHED);
  371. }
  372. }
  373. }
  374. break;
  375. }
  376. case knopCall:
  377. {
  378. ASTPrepass(pnode->sxCall.pnodeTarget, func);
  379. bool evalArgs = true;
  380. if (pnode->sxCall.pnodeTarget->nop == knopName)
  381. {
  382. AsmJsFunctionDeclaration* funcDecl = this->LookupFunction(pnode->sxCall.pnodeTarget->name());
  383. if (AsmJsMathFunction::IsFround(funcDecl) && pnode->sxCall.argCount > 0)
  384. {
  385. switch (pnode->sxCall.pnodeArgs->nop)
  386. {
  387. case knopFlt:
  388. func->AddConst<float>((float)pnode->sxCall.pnodeArgs->sxFlt.dbl);
  389. evalArgs = false;
  390. break;
  391. case knopInt:
  392. func->AddConst<float>((float)pnode->sxCall.pnodeArgs->sxInt.lw);
  393. evalArgs = false;
  394. break;
  395. case knopNeg:
  396. if (pnode->sxCall.pnodeArgs->sxUni.pnode1->nop == knopInt && pnode->sxCall.pnodeArgs->sxUni.pnode1->sxInt.lw == 0)
  397. {
  398. func->AddConst<float>(-0.0f);
  399. evalArgs = false;
  400. break;
  401. }
  402. }
  403. }
  404. #ifdef ENABLE_SIMDJS
  405. else if (IsSimdjsEnabled())
  406. {
  407. /*
  408. Float32x4 operations work on Float reg space.
  409. If any of the args is a literal (DoubleLit), we need to have a copy of it in the Float reg space.
  410. Note that we may end up with redundant copies in the Double reg space, since we ASTPrepass the args (Fix later ?)
  411. */
  412. if (AsmJsSIMDFunction::Is(funcDecl))
  413. {
  414. AsmJsSIMDFunction* simdFunc = AsmJsSIMDFunction::FromVar(funcDecl);
  415. if (simdFunc->IsFloat32x4Func())
  416. {
  417. ParseNode *argNode, *arg;
  418. argNode = arg = pnode->sxCall.pnodeArgs;
  419. do
  420. {
  421. if (argNode->nop == knopList)
  422. {
  423. arg = ParserWrapper::GetBinaryLeft(argNode);
  424. argNode = ParserWrapper::GetBinaryRight(argNode);
  425. }
  426. if (arg->nop == knopFlt)
  427. {
  428. func->AddConst<float>((float)arg->sxFlt.dbl);
  429. }
  430. if (argNode != arg && argNode->nop == knopFlt)
  431. { // last arg
  432. func->AddConst<float>((float)argNode->sxFlt.dbl);
  433. }
  434. } while (argNode->nop == knopList);
  435. }
  436. }
  437. }
  438. #endif // #ifdef ENABLE_SIMDJS
  439. }
  440. if (evalArgs)
  441. {
  442. ASTPrepass(pnode->sxCall.pnodeArgs, func);
  443. }
  444. break;
  445. }
  446. case knopVarDecl:
  447. GetByteCodeGenerator()->AssignPropertyId(pnode->name());
  448. ASTPrepass(pnode->sxVar.pnodeInit, func);
  449. break;
  450. // all the rest of the cases simply walk the AST
  451. case knopQmark:
  452. ASTPrepass(pnode->sxTri.pnode1, func);
  453. ASTPrepass(pnode->sxTri.pnode2, func);
  454. ASTPrepass(pnode->sxTri.pnode3, func);
  455. break;
  456. case knopList:
  457. do
  458. {
  459. ParseNode * pnode1 = pnode->sxBin.pnode1;
  460. ASTPrepass(pnode1, func);
  461. pnode = pnode->sxBin.pnode2;
  462. } while (pnode->nop == knopList);
  463. ASTPrepass(pnode, func);
  464. break;
  465. case knopFor:
  466. ASTPrepass(pnode->sxFor.pnodeInit, func);
  467. ASTPrepass(pnode->sxFor.pnodeCond, func);
  468. ASTPrepass(pnode->sxFor.pnodeIncr, func);
  469. ASTPrepass(pnode->sxFor.pnodeBody, func);
  470. break;
  471. case knopIf:
  472. ASTPrepass(pnode->sxIf.pnodeCond, func);
  473. ASTPrepass(pnode->sxIf.pnodeTrue, func);
  474. ASTPrepass(pnode->sxIf.pnodeFalse, func);
  475. break;
  476. case knopDoWhile:
  477. case knopWhile:
  478. ASTPrepass(pnode->sxWhile.pnodeCond, func);
  479. ASTPrepass(pnode->sxWhile.pnodeBody, func);
  480. break;
  481. case knopReturn:
  482. ASTPrepass(pnode->sxReturn.pnodeExpr, func);
  483. break;
  484. case knopBlock:
  485. ASTPrepass(pnode->sxBlock.pnodeStmt, func);
  486. break;
  487. case knopSwitch:
  488. ASTPrepass(pnode->sxSwitch.pnodeVal, func);
  489. for (ParseNode *pnodeT = pnode->sxSwitch.pnodeCases; NULL != pnodeT; pnodeT = pnodeT->sxCase.pnodeNext)
  490. {
  491. ASTPrepass(pnodeT, func);
  492. }
  493. ASTPrepass(pnode->sxSwitch.pnodeBlock, func);
  494. break;
  495. case knopCase:
  496. ASTPrepass(pnode->sxCase.pnodeExpr, func);
  497. ASTPrepass(pnode->sxCase.pnodeBody, func);
  498. break;
  499. case knopComma:
  500. {
  501. ParseNode *pnode1 = pnode->sxBin.pnode1;
  502. if (pnode1->nop == knopComma)
  503. {
  504. // avoid recursion on very large comma expressions.
  505. ArenaAllocator *alloc = GetByteCodeGenerator()->GetAllocator();
  506. SList<ParseNode*> *rhsStack = Anew(alloc, SList<ParseNode*>, alloc);
  507. do {
  508. rhsStack->Push(pnode1->sxBin.pnode2);
  509. pnode1 = pnode1->sxBin.pnode1;
  510. } while (pnode1->nop == knopComma);
  511. ASTPrepass(pnode1, func);
  512. while (!rhsStack->Empty())
  513. {
  514. ParseNode *pnodeRhs = rhsStack->Pop();
  515. ASTPrepass(pnodeRhs, func);
  516. }
  517. Adelete(alloc, rhsStack);
  518. }
  519. else
  520. {
  521. ASTPrepass(pnode1, func);
  522. }
  523. ASTPrepass(pnode->sxBin.pnode2, func);
  524. break;
  525. }
  526. default:
  527. {
  528. uint flags = ParseNode::Grfnop(pnode->nop);
  529. if (flags&fnopUni)
  530. {
  531. ASTPrepass(pnode->sxUni.pnode1, func);
  532. }
  533. else if (flags&fnopBin)
  534. {
  535. ASTPrepass(pnode->sxBin.pnode1, func);
  536. ASTPrepass(pnode->sxBin.pnode2, func);
  537. }
  538. break;
  539. }
  540. }
  541. }
  542. void AsmJsModuleCompiler::BindArguments(ParseNode* argList)
  543. {
  544. for (ParseNode* pnode = argList; pnode; pnode = pnode->sxVar.pnodeNext)
  545. {
  546. GetByteCodeGenerator()->AssignPropertyId(pnode->name());
  547. }
  548. }
  549. bool AsmJsModuleCompiler::CompileFunction(AsmJsFunc * func, int funcIndex)
  550. {
  551. ParseNodePtr fncNode = func->GetFncNode();
  552. ParseNodePtr pnodeBody = nullptr;
  553. Assert(fncNode->nop == knopFncDecl && fncNode->sxFnc.funcInfo && fncNode->sxFnc.funcInfo->IsDeferred() && fncNode->sxFnc.pnodeBody == NULL);
  554. Js::ParseableFunctionInfo* deferParseFunction = fncNode->sxFnc.funcInfo->byteCodeFunction;
  555. Utf8SourceInfo * utf8SourceInfo = deferParseFunction->GetUtf8SourceInfo();
  556. ULONG grfscr = utf8SourceInfo->GetParseFlags();
  557. grfscr = grfscr & (~fscrGlobalCode);
  558. func->SetOrigParseFlags(grfscr);
  559. deferParseFunction->SetGrfscr(grfscr | (grfscr & ~fscrDeferredFncExpression));
  560. deferParseFunction->SetSourceInfo(GetByteCodeGenerator()->GetCurrentSourceIndex(),
  561. fncNode,
  562. !!(grfscr & fscrEvalCode),
  563. ((grfscr & fscrDynamicCode) && !(grfscr & fscrEvalCode)));
  564. deferParseFunction->SetInParamsCount(fncNode->sxFnc.funcInfo->inArgsCount);
  565. deferParseFunction->SetReportedInParamsCount(fncNode->sxFnc.funcInfo->inArgsCount);
  566. if (fncNode->sxFnc.pnodeBody == NULL)
  567. {
  568. if (!PHASE_OFF1(Js::SkipNestedDeferredPhase))
  569. {
  570. deferParseFunction->BuildDeferredStubs(fncNode);
  571. }
  572. }
  573. deferParseFunction->SetIsAsmjsMode(true);
  574. PageAllocator tempPageAlloc(NULL, Js::Configuration::Global.flags);
  575. Parser ps(GetScriptContext(), FALSE, &tempPageAlloc);
  576. FunctionBody * funcBody;
  577. ParseNodePtr parseTree;
  578. CompileScriptException se;
  579. funcBody = deferParseFunction->ParseAsmJs(&ps, &se, &parseTree);
  580. fncNode->sxFnc.funcInfo->byteCodeFunction = funcBody;
  581. TRACE_BYTECODE(_u("\nDeferred parse %s\n"), funcBody->GetDisplayName());
  582. if (parseTree && parseTree->nop == knopProg)
  583. {
  584. auto body = parseTree->sxProg.pnodeBody;
  585. if (body && body->nop == knopList)
  586. {
  587. auto fncDecl = body->sxBin.pnode1;
  588. if (fncDecl && fncDecl->nop == knopFncDecl)
  589. {
  590. pnodeBody = fncDecl->sxFnc.pnodeBody;
  591. func->SetFuncBody(funcBody);
  592. }
  593. }
  594. }
  595. GetByteCodeGenerator()->PushFuncInfo(_u("Start asm.js AST prepass"), fncNode->sxFnc.funcInfo);
  596. BindArguments(fncNode->sxFnc.pnodeParams);
  597. ASTPrepass(pnodeBody, func);
  598. GetByteCodeGenerator()->PopFuncInfo(_u("End asm.js AST prepass"));
  599. fncNode->sxFnc.pnodeBody = pnodeBody;
  600. if (!pnodeBody)
  601. {
  602. // body should never be null if parsing succeeded
  603. Assert(UNREACHED);
  604. return Fail(fncNode, _u("Function should always have parse nodes"));
  605. }
  606. // Check if this function requires a bigger Ast
  607. UpdateMaxAstSize(fncNode->sxFnc.astSize);
  608. if (!SetupFunctionArguments(func, pnodeBody))
  609. {
  610. // failure message will be printed by SetupFunctionArguments
  611. fncNode->sxFnc.pnodeBody = NULL;
  612. return false;
  613. }
  614. if (!SetupLocalVariables(func))
  615. {
  616. // failure message will be printed by SetupLocalVariables
  617. fncNode->sxFnc.pnodeBody = NULL;
  618. return false;
  619. }
  620. // now that we have setup the function, we can generate bytecode for it
  621. AsmJSByteCodeGenerator gen(func, this);
  622. bool wasEmit = gen.EmitOneFunction();
  623. fncNode->sxFnc.pnodeBody = NULL;
  624. return wasEmit;
  625. }
  626. bool AsmJsModuleCompiler::SetupFunctionArguments(AsmJsFunc * func, ParseNodePtr pnode)
  627. {
  628. // Check arguments
  629. ArgSlot numArguments = 0;
  630. ParseNode * fncNode = func->GetFncNode();
  631. ParseNode* argNode = ParserWrapper::FunctionArgsList(fncNode, numArguments);
  632. if (!func->EnsureArgCount(numArguments))
  633. {
  634. return Fail(argNode, _u("Cannot have variable number of arguments"));
  635. }
  636. ArgSlot index = 0;
  637. while (argNode)
  638. {
  639. if (pnode->nop != knopList)
  640. {
  641. return Fail(pnode, _u("Missing assignment statement for argument"));
  642. }
  643. if (!ParserWrapper::IsDefinition(argNode))
  644. {
  645. return Fail(argNode, _u("duplicate argument name not allowed"));
  646. }
  647. PropertyName argName = argNode->name();
  648. if (!AsmJSCompiler::CheckIdentifier(*this, argNode, argName))
  649. {
  650. return false;
  651. }
  652. // creates the variable
  653. AsmJsVarBase* var = func->DefineVar(argName, true);
  654. if (!var)
  655. {
  656. return Fail(argNode, _u("Failed to define var"));
  657. }
  658. ParseNode* argDefinition = ParserWrapper::GetBinaryLeft(pnode);
  659. if (argDefinition->nop != knopAsg)
  660. {
  661. return Fail(argDefinition, _u("Expecting an assignment"));
  662. }
  663. ParseNode* lhs = ParserWrapper::GetBinaryLeft(argDefinition);
  664. ParseNode* rhs = ParserWrapper::GetBinaryRight(argDefinition);
  665. #define NodeDefineThisArgument(n,var) (n->nop == knopName && ParserWrapper::VariableName(n)->GetPropertyId() == var->GetName()->GetPropertyId())
  666. if (!NodeDefineThisArgument(lhs, var))
  667. {
  668. return Fail(lhs, _u("Defining wrong argument"));
  669. }
  670. if (rhs->nop == knopPos)
  671. {
  672. // unary + => double
  673. var->SetVarType(AsmJsVarType::Double);
  674. var->SetLocation(func->AcquireRegister<double>());
  675. // validate stmt
  676. ParseNode* argSym = ParserWrapper::GetUnaryNode(rhs);
  677. if (!NodeDefineThisArgument(argSym, var))
  678. {
  679. return Fail(lhs, _u("Defining wrong argument"));
  680. }
  681. }
  682. else if (rhs->nop == knopOr)
  683. {
  684. var->SetVarType(AsmJsVarType::Int);
  685. var->SetLocation(func->AcquireRegister<int>());
  686. ParseNode* argSym = ParserWrapper::GetBinaryLeft(rhs);
  687. ParseNode* intSym = ParserWrapper::GetBinaryRight(rhs);
  688. // validate stmt
  689. if (!NodeDefineThisArgument(argSym, var))
  690. {
  691. return Fail(lhs, _u("Defining wrong argument"));
  692. }
  693. if (intSym->nop != knopInt || intSym->sxInt.lw != 0)
  694. {
  695. return Fail(lhs, _u("Or value must be 0 when defining arguments"));
  696. }
  697. }
  698. else if (rhs->nop == knopCall)
  699. {
  700. if (rhs->sxCall.pnodeTarget->nop != knopName)
  701. {
  702. return Fail(rhs, _u("call should be for fround"));
  703. }
  704. AsmJsFunctionDeclaration* funcDecl = this->LookupFunction(rhs->sxCall.pnodeTarget->name());
  705. if (!funcDecl)
  706. return Fail(rhs, _u("Cannot resolve function for argument definition, or wrong function"));
  707. if (AsmJsMathFunction::Is(funcDecl))
  708. {
  709. if (!AsmJsMathFunction::IsFround(funcDecl))
  710. {
  711. return Fail(rhs, _u("call should be for fround"));
  712. }
  713. var->SetVarType(AsmJsVarType::Float);
  714. var->SetLocation(func->AcquireRegister<float>());
  715. }
  716. #ifdef ENABLE_SIMDJS
  717. else if (IsSimdjsEnabled() && AsmJsSIMDFunction::Is(funcDecl))
  718. {
  719. AsmJsSIMDFunction* simdFunc = AsmJsSIMDFunction::FromSymbol(funcDecl);
  720. // x = f4check(x)
  721. if (!simdFunc->IsTypeCheck())
  722. {
  723. return Fail(rhs, _u("Invalid SIMD argument type check. E.g. expected x = f4check(x)"));
  724. }
  725. if (simdFunc->IsUnsignedTypeCheck())
  726. {
  727. return Fail(rhs, _u("Invalid SIMD argument type. Expecting Signed arguments."));
  728. }
  729. var->SetVarType(simdFunc->GetTypeCheckVarType());
  730. // We don't set SIMD args reg location here. We defer that after all function locals are processed.
  731. // This allows us to capture all SIMD constants from locals initializations, add them to the register space before we assign registers to args and locals.
  732. func->GetSimdVarsList().Add(var);
  733. }
  734. #endif
  735. else
  736. {
  737. return Fail(rhs, _u("Wrong function used for argument definition"));
  738. }
  739. if (!NodeDefineThisArgument(rhs->sxCall.pnodeArgs, var))
  740. {
  741. return Fail(lhs, _u("Defining wrong argument"));
  742. }
  743. }
  744. else
  745. {
  746. return Fail(rhs, _u("arguments are not casted as valid Asm.js type"));
  747. }
  748. if (PHASE_TRACE1(ByteCodePhase))
  749. {
  750. Output::Print(_u(" Argument [%s] Valid"), argName->Psz());
  751. }
  752. if (!func->EnsureArgType(var, index++))
  753. {
  754. return Fail(rhs, _u("Unexpected argument type"));
  755. }
  756. argNode = ParserWrapper::NextVar(argNode);
  757. pnode = ParserWrapper::GetBinaryRight(pnode);
  758. }
  759. func->SetBodyNode(pnode);
  760. return true;
  761. }
  762. bool AsmJsModuleCompiler::SetupLocalVariables(AsmJsFunc * func)
  763. {
  764. ParseNodePtr pnode = func->GetBodyNode();
  765. MathBuiltin mathBuiltin;
  766. AsmJsSIMDValue simdValue;
  767. simdValue.Zero();
  768. // define all variables
  769. BVSparse<ArenaAllocator> initializerBV(&mAllocator);
  770. while (pnode->nop == knopList)
  771. {
  772. ParseNode * varNode = ParserWrapper::GetBinaryLeft(pnode);
  773. while (varNode && varNode->nop != knopEndCode)
  774. {
  775. ParseNode * decl;
  776. if (varNode->nop == knopList)
  777. {
  778. decl = ParserWrapper::GetBinaryLeft(varNode);
  779. varNode = ParserWrapper::GetBinaryRight(varNode);
  780. }
  781. else
  782. {
  783. decl = varNode;
  784. varNode = nullptr;
  785. }
  786. // if we have hit a non-declaration, we are done processing the function header
  787. if (decl->nop != knopVarDecl)
  788. {
  789. goto varDeclEnd;
  790. }
  791. ParseNode* pnodeInit = decl->sxVar.pnodeInit;
  792. AsmJsSymbol * declSym = nullptr;
  793. bool isFroundInit = false;
  794. #ifdef ENABLE_SIMDJS
  795. AsmJsSIMDFunction* simdFunc = nullptr;
  796. #endif
  797. if (!pnodeInit)
  798. {
  799. return Fail(decl, _u("The righthand side of a var declaration missing an initialization (empty)"));
  800. }
  801. if (pnodeInit->nop == knopName)
  802. {
  803. declSym = LookupIdentifier(pnodeInit->name(), func);
  804. if ((!AsmJsVar::Is(declSym) && !AsmJsMathConst::Is(declSym)) || declSym->isMutable())
  805. {
  806. return Fail(decl, _u("Var declaration with non-constant"));
  807. }
  808. }
  809. else if (pnodeInit->nop == knopCall)
  810. {
  811. if (pnodeInit->sxCall.pnodeTarget->nop != knopName)
  812. {
  813. return Fail(decl, _u("Var declaration with something else than a literal value|fround call"));
  814. }
  815. AsmJsFunctionDeclaration* funcDecl = this->LookupFunction(pnodeInit->sxCall.pnodeTarget->name());
  816. if (!funcDecl)
  817. return Fail(pnodeInit, _u("Cannot resolve function name"));
  818. if (AsmJsMathFunction::Is(funcDecl))
  819. {
  820. if (!AsmJsMathFunction::IsFround(funcDecl) || !ParserWrapper::IsFroundNumericLiteral(pnodeInit->sxCall.pnodeArgs))
  821. {
  822. return Fail(decl, _u("Var declaration with something else than a literal value|fround call"));
  823. }
  824. isFroundInit = true;
  825. }
  826. #ifdef ENABLE_SIMDJS
  827. else if (IsSimdjsEnabled() && AsmJsSIMDFunction::Is(funcDecl))
  828. {
  829. // var x = f4(1.0, 2.0, 3.0, 4.0);
  830. simdFunc = AsmJsSIMDFunction::FromSymbol(funcDecl);
  831. if (!ValidateSimdConstructor(pnodeInit, simdFunc, simdValue))
  832. {
  833. return Fail(varNode, _u("Invalid SIMD local declaration"));
  834. }
  835. }
  836. #endif
  837. else
  838. {
  839. return Fail(varNode, _u("Unknown function call on var declaration"));
  840. }
  841. }
  842. else if (pnodeInit->nop != knopInt && pnodeInit->nop != knopFlt)
  843. {
  844. return Fail(decl, _u("Var declaration with something else than a literal value|fround call"));
  845. }
  846. if (!AsmJSCompiler::CheckIdentifier(*this, decl, decl->name()))
  847. {
  848. // CheckIdentifier will print failure message
  849. return false;
  850. }
  851. AsmJsVar* var = (AsmJsVar*)func->DefineVar(decl->name(), false);
  852. if (!var)
  853. {
  854. return Fail(decl, _u("Failed to define var"));
  855. }
  856. // If we are declaring a var that we previously used in an initializer, that value will be undefined
  857. // so we need to throw an error.
  858. if (initializerBV.Test(var->GetName()->GetPropertyId()))
  859. {
  860. return Fail(decl, _u("Cannot declare a var after using it in an initializer"));
  861. }
  862. RegSlot loc = Constants::NoRegister;
  863. if (pnodeInit->nop == knopInt)
  864. {
  865. var->SetVarType(AsmJsVarType::Int);
  866. var->SetLocation(func->AcquireRegister<int>());
  867. var->SetConstInitialiser(pnodeInit->sxInt.lw);
  868. loc = func->GetConstRegister<int>(pnodeInit->sxInt.lw);
  869. }
  870. else if (ParserWrapper::IsMinInt(pnodeInit))
  871. {
  872. var->SetVarType(AsmJsVarType::Int);
  873. var->SetLocation(func->AcquireRegister<int>());
  874. var->SetConstInitialiser(INT_MIN);
  875. loc = func->GetConstRegister<int>(INT_MIN);
  876. }
  877. else if (ParserWrapper::IsUnsigned(pnodeInit))
  878. {
  879. var->SetVarType(AsmJsVarType::Int);
  880. var->SetLocation(func->AcquireRegister<int>());
  881. var->SetConstInitialiser((int)((uint32)pnodeInit->sxFlt.dbl));
  882. loc = func->GetConstRegister<int>((uint32)pnodeInit->sxFlt.dbl);
  883. }
  884. else if (pnodeInit->nop == knopFlt)
  885. {
  886. if (pnodeInit->sxFlt.maybeInt)
  887. {
  888. return Fail(decl, _u("Var declaration with integer literal outside range [-2^31, 2^32)"));
  889. }
  890. var->SetVarType(AsmJsVarType::Double);
  891. var->SetLocation(func->AcquireRegister<double>());
  892. loc = func->GetConstRegister<double>(pnodeInit->sxFlt.dbl);
  893. var->SetConstInitialiser(pnodeInit->sxFlt.dbl);
  894. }
  895. else if (pnodeInit->nop == knopName)
  896. {
  897. if (AsmJsVar::Is(declSym))
  898. {
  899. AsmJsVar * definition = AsmJsVar::FromSymbol(declSym);
  900. initializerBV.Set(definition->GetName()->GetPropertyId());
  901. switch (definition->GetVarType().which())
  902. {
  903. case AsmJsVarType::Double:
  904. var->SetVarType(AsmJsVarType::Double);
  905. var->SetLocation(func->AcquireRegister<double>());
  906. var->SetConstInitialiser(definition->GetDoubleInitialiser());
  907. break;
  908. case AsmJsVarType::Float:
  909. var->SetVarType(AsmJsVarType::Float);
  910. var->SetLocation(func->AcquireRegister<float>());
  911. var->SetConstInitialiser(definition->GetFloatInitialiser());
  912. break;
  913. case AsmJsVarType::Int:
  914. var->SetVarType(AsmJsVarType::Int);
  915. var->SetLocation(func->AcquireRegister<int>());
  916. var->SetConstInitialiser(definition->GetIntInitialiser());
  917. break;
  918. default:
  919. Assume(UNREACHED);
  920. }
  921. }
  922. else
  923. {
  924. Assert(declSym->GetType() == AsmJsType::Double);
  925. AsmJsMathConst * definition = AsmJsMathConst::FromSymbol(declSym);
  926. var->SetVarType(AsmJsVarType::Double);
  927. var->SetLocation(func->AcquireRegister<double>());
  928. var->SetConstInitialiser(*definition->GetVal());
  929. }
  930. }
  931. else if (pnodeInit->nop == knopCall)
  932. {
  933. if (isFroundInit)
  934. {
  935. var->SetVarType(AsmJsVarType::Float);
  936. var->SetLocation(func->AcquireRegister<float>());
  937. if (pnodeInit->sxCall.pnodeArgs->nop == knopInt)
  938. {
  939. int iVal = pnodeInit->sxCall.pnodeArgs->sxInt.lw;
  940. var->SetConstInitialiser((float)iVal);
  941. loc = func->GetConstRegister<float>((float)iVal);
  942. }
  943. else if (ParserWrapper::IsNegativeZero(pnodeInit->sxCall.pnodeArgs))
  944. {
  945. var->SetConstInitialiser(-0.0f);
  946. loc = func->GetConstRegister<float>(-0.0f);
  947. }
  948. else
  949. {
  950. // note: fround((-)NumericLiteral) is explicitly allowed for any range, so we do not need to check for maybeInt
  951. Assert(pnodeInit->sxCall.pnodeArgs->nop == knopFlt);
  952. float fVal = (float)pnodeInit->sxCall.pnodeArgs->sxFlt.dbl;
  953. var->SetConstInitialiser((float)fVal);
  954. loc = func->GetConstRegister<float>(fVal);
  955. }
  956. }
  957. #ifdef ENABLE_SIMDJS
  958. else if (IsSimdjsEnabled() && simdFunc)
  959. {
  960. // simd constructor call
  961. // en-register the simdvalue constant first
  962. func->AddConst<AsmJsSIMDValue>(simdValue);
  963. loc = func->GetConstRegister<AsmJsSIMDValue>(simdValue);
  964. var->SetConstInitialiser(simdValue);
  965. var->SetVarType(simdFunc->GetConstructorVarType());
  966. // add to list. assign register after all constants.
  967. func->GetSimdVarsList().Add(var);
  968. }
  969. #endif
  970. else
  971. {
  972. Assert(UNREACHED);
  973. }
  974. }
  975. if (loc == Constants::NoRegister && pnodeInit->nop != knopName)
  976. {
  977. return Fail(decl, _u("Cannot find Register constant for var"));
  978. }
  979. }
  980. if (ParserWrapper::GetBinaryRight(pnode)->nop == knopEndCode)
  981. {
  982. break;
  983. }
  984. pnode = ParserWrapper::GetBinaryRight(pnode);
  985. }
  986. varDeclEnd:
  987. // this code has to be on all exit-path from the function
  988. #ifdef ENABLE_SIMDJS
  989. if (IsSimdjsEnabled())
  990. {
  991. // Now, assign registers to all SIMD vars after all constants are en-registered.
  992. for (int i = 0; i < func->GetSimdVarsList().Count(); i++)
  993. {
  994. AsmJsVarBase *var = func->GetSimdVarsList().Item(i);
  995. var->SetLocation(func->AcquireRegister<AsmJsSIMDValue>());
  996. }
  997. func->GetSimdVarsList().Reset(); // list not needed anymore
  998. }
  999. #endif
  1000. return true;
  1001. }
  1002. AsmJsFunc* AsmJsModuleCompiler::CreateNewFunctionEntry(ParseNode* pnodeFnc)
  1003. {
  1004. PropertyName name = ParserWrapper::FunctionName(pnodeFnc);
  1005. if (!name)
  1006. {
  1007. return nullptr;
  1008. }
  1009. GetByteCodeGenerator()->AssignPropertyId(name);
  1010. AsmJsFunc* func = Anew(&mAllocator, AsmJsFunc, name, pnodeFnc, &mAllocator, mCx->scriptContext);
  1011. if (func)
  1012. {
  1013. if (DefineIdentifier(name, func))
  1014. {
  1015. uint index = (uint)mFunctionArray.Count();
  1016. if (pnodeFnc->sxFnc.nestedIndex != index)
  1017. {
  1018. return nullptr;
  1019. }
  1020. func->SetFunctionIndex((RegSlot)index);
  1021. mFunctionArray.Add(func);
  1022. Assert(index + 1 == (uint)mFunctionArray.Count());
  1023. return func;
  1024. }
  1025. // Error adding function
  1026. mAllocator.Free(func, sizeof(AsmJsFunc));
  1027. }
  1028. // Error allocating a new function
  1029. return nullptr;
  1030. }
  1031. bool AsmJsModuleCompiler::CheckByteLengthCall(ParseNode * callNode, ParseNode * bufferDecl)
  1032. {
  1033. if (callNode->nop != knopCall || callNode->sxCall.pnodeTarget->nop != knopName)
  1034. {
  1035. return false;
  1036. }
  1037. AsmJsTypedArrayFunction* arrayFunc = LookupIdentifier<AsmJsTypedArrayFunction>(callNode->sxCall.pnodeTarget->name());
  1038. if (!arrayFunc)
  1039. {
  1040. return false;
  1041. }
  1042. return callNode->sxCall.argCount == 1 &&
  1043. !callNode->sxCall.isApplyCall &&
  1044. !callNode->sxCall.isEvalCall &&
  1045. callNode->sxCall.spreadArgCount == 0 &&
  1046. arrayFunc->GetArrayBuiltInFunction() == AsmJSTypedArrayBuiltin_byteLength &&
  1047. callNode->sxCall.pnodeArgs->nop == knopName &&
  1048. callNode->sxCall.pnodeArgs->name()->GetPropertyId() == bufferDecl->name()->GetPropertyId();
  1049. }
  1050. bool AsmJsModuleCompiler::Fail(ParseNode* usepn, const wchar *error)
  1051. {
  1052. AsmJSCompiler::OutputError(GetScriptContext(), error);
  1053. return false;
  1054. }
  1055. bool AsmJsModuleCompiler::FailName(ParseNode *usepn, const wchar *fmt, PropertyName name)
  1056. {
  1057. AsmJSCompiler::OutputError(GetScriptContext(), fmt, name->Psz());
  1058. return false;
  1059. }
  1060. bool AsmJsModuleCompiler::LookupStandardLibraryMathName(PropertyName name, MathBuiltin *mathBuiltin) const
  1061. {
  1062. return mStandardLibraryMathNames.TryGetValue(name->GetPropertyId(), mathBuiltin);
  1063. }
  1064. bool AsmJsModuleCompiler::LookupStandardLibraryArrayName(PropertyName name, TypedArrayBuiltin *builtin) const
  1065. {
  1066. return mStandardLibraryArrayNames.TryGetValue(name->GetPropertyId(), builtin);
  1067. }
  1068. void AsmJsModuleCompiler::InitBufferArgName(PropertyName n)
  1069. {
  1070. #if DBG
  1071. Assert(!mBufferArgNameInit);
  1072. mBufferArgNameInit = true;
  1073. #endif
  1074. mBufferArgName = n;
  1075. }
  1076. void AsmJsModuleCompiler::InitForeignArgName(PropertyName n)
  1077. {
  1078. #if DBG
  1079. Assert(!mForeignArgNameInit);
  1080. mForeignArgNameInit = true;
  1081. #endif
  1082. mForeignArgName = n;
  1083. }
  1084. void AsmJsModuleCompiler::InitStdLibArgName(PropertyName n)
  1085. {
  1086. #if DBG
  1087. Assert(!mStdLibArgNameInit);
  1088. mStdLibArgNameInit = true;
  1089. #endif
  1090. mStdLibArgName = n;
  1091. }
  1092. Js::PropertyName AsmJsModuleCompiler::GetStdLibArgName() const
  1093. {
  1094. #if DBG
  1095. Assert(mBufferArgNameInit);
  1096. #endif
  1097. return mStdLibArgName;
  1098. }
  1099. Js::PropertyName AsmJsModuleCompiler::GetForeignArgName() const
  1100. {
  1101. #if DBG
  1102. Assert(mForeignArgNameInit);
  1103. #endif
  1104. return mForeignArgName;
  1105. }
  1106. Js::PropertyName AsmJsModuleCompiler::GetBufferArgName() const
  1107. {
  1108. #if DBG
  1109. Assert(mStdLibArgNameInit);
  1110. #endif
  1111. return mBufferArgName;
  1112. }
  1113. bool AsmJsModuleCompiler::Init()
  1114. {
  1115. if (mInitialised)
  1116. {
  1117. return false;
  1118. }
  1119. mInitialised = true;
  1120. struct MathFunc
  1121. {
  1122. MathFunc(PropertyId id_ = 0, AsmJsMathFunction* val_ = nullptr) :
  1123. id(id_), val(val_)
  1124. {
  1125. }
  1126. PropertyId id;
  1127. AsmJsMathFunction* val;
  1128. };
  1129. MathFunc mathFunctions[AsmJSMathBuiltinFunction_COUNT];
  1130. // we could move the mathBuiltinFuncname to MathFunc struct
  1131. mathFunctions[AsmJSMathBuiltin_sin] = MathFunc(PropertyIds::sin, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_sin, OpCodeAsmJs::Sin_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble));
  1132. mathFunctions[AsmJSMathBuiltin_cos] = MathFunc(PropertyIds::cos, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_cos, OpCodeAsmJs::Cos_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble));
  1133. mathFunctions[AsmJSMathBuiltin_tan] = MathFunc(PropertyIds::tan, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_tan, OpCodeAsmJs::Tan_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble));
  1134. mathFunctions[AsmJSMathBuiltin_asin] = MathFunc(PropertyIds::asin, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_asin, OpCodeAsmJs::Asin_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble));
  1135. mathFunctions[AsmJSMathBuiltin_acos] = MathFunc(PropertyIds::acos, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_acos, OpCodeAsmJs::Acos_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble));
  1136. mathFunctions[AsmJSMathBuiltin_atan] = MathFunc(PropertyIds::atan, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_atan, OpCodeAsmJs::Atan_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble));
  1137. mathFunctions[AsmJSMathBuiltin_ceil] = MathFunc(PropertyIds::ceil, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_ceil, OpCodeAsmJs::Ceil_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble));
  1138. mathFunctions[AsmJSMathBuiltin_floor] = MathFunc(PropertyIds::floor, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_floor, OpCodeAsmJs::Floor_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble));
  1139. mathFunctions[AsmJSMathBuiltin_exp] = MathFunc(PropertyIds::exp, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_exp, OpCodeAsmJs::Exp_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble));
  1140. mathFunctions[AsmJSMathBuiltin_log] = MathFunc(PropertyIds::log, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_log, OpCodeAsmJs::Log_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble));
  1141. mathFunctions[AsmJSMathBuiltin_pow] = MathFunc(PropertyIds::pow, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 2, AsmJSMathBuiltin_pow, OpCodeAsmJs::Pow_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble, AsmJsType::MaybeDouble));
  1142. mathFunctions[AsmJSMathBuiltin_sqrt] = MathFunc(PropertyIds::sqrt, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_sqrt, OpCodeAsmJs::Sqrt_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble));
  1143. mathFunctions[AsmJSMathBuiltin_abs] = MathFunc(PropertyIds::abs, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_abs, OpCodeAsmJs::Abs_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble));
  1144. mathFunctions[AsmJSMathBuiltin_atan2] = MathFunc(PropertyIds::atan2, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 2, AsmJSMathBuiltin_atan2, OpCodeAsmJs::Atan2_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble, AsmJsType::MaybeDouble));
  1145. mathFunctions[AsmJSMathBuiltin_imul] = MathFunc(PropertyIds::imul, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 2, AsmJSMathBuiltin_imul, OpCodeAsmJs::Imul_Int, AsmJsRetType::Signed, AsmJsType::Intish, AsmJsType::Intish));
  1146. mathFunctions[AsmJSMathBuiltin_fround] = MathFunc(PropertyIds::fround, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_fround, OpCodeAsmJs::Fround_Flt, AsmJsRetType::Float, AsmJsType::Floatish));
  1147. mathFunctions[AsmJSMathBuiltin_min] = MathFunc(PropertyIds::min, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 2, AsmJSMathBuiltin_min, OpCodeAsmJs::Min_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble, AsmJsType::MaybeDouble));
  1148. mathFunctions[AsmJSMathBuiltin_max] = MathFunc(PropertyIds::max, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 2, AsmJSMathBuiltin_max, OpCodeAsmJs::Max_Db, AsmJsRetType::Double, AsmJsType::MaybeDouble, AsmJsType::MaybeDouble));
  1149. mathFunctions[AsmJSMathBuiltin_clz32] = MathFunc(PropertyIds::clz32, Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_clz32, OpCodeAsmJs::Clz32_Int, AsmJsRetType::Fixnum, AsmJsType::Intish));
  1150. mathFunctions[AsmJSMathBuiltin_abs].val->SetOverload(Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_abs, OpCodeAsmJs::Abs_Int, AsmJsRetType::Unsigned, AsmJsType::Signed));
  1151. mathFunctions[AsmJSMathBuiltin_min].val->SetOverload(Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 2, AsmJSMathBuiltin_min, OpCodeAsmJs::Min_Int, AsmJsRetType::Signed, AsmJsType::Signed, AsmJsType::Signed));
  1152. mathFunctions[AsmJSMathBuiltin_max].val->SetOverload(Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 2, AsmJSMathBuiltin_max, OpCodeAsmJs::Max_Int, AsmJsRetType::Signed, AsmJsType::Signed, AsmJsType::Signed));
  1153. //Float Overloads
  1154. mathFunctions[AsmJSMathBuiltin_fround].val->SetOverload(Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_fround, OpCodeAsmJs::Fround_Db, AsmJsRetType::Float, AsmJsType::MaybeDouble));
  1155. mathFunctions[AsmJSMathBuiltin_fround].val->SetOverload(Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_fround, OpCodeAsmJs::Fround_Int, AsmJsRetType::Float, AsmJsType::Int));// should we split this into signed and unsigned?
  1156. mathFunctions[AsmJSMathBuiltin_abs].val->SetOverload(Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_abs, OpCodeAsmJs::Abs_Flt, AsmJsRetType::Floatish, AsmJsType::MaybeFloat));
  1157. mathFunctions[AsmJSMathBuiltin_ceil].val->SetOverload(Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_ceil, OpCodeAsmJs::Ceil_Flt, AsmJsRetType::Floatish, AsmJsType::MaybeFloat));
  1158. mathFunctions[AsmJSMathBuiltin_floor].val->SetOverload(Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_floor, OpCodeAsmJs::Floor_Flt, AsmJsRetType::Floatish, AsmJsType::MaybeFloat));
  1159. mathFunctions[AsmJSMathBuiltin_sqrt].val->SetOverload(Anew(&mAllocator, AsmJsMathFunction, nullptr, &mAllocator, 1, AsmJSMathBuiltin_sqrt, OpCodeAsmJs::Sqrt_Flt, AsmJsRetType::Floatish, AsmJsType::MaybeFloat));
  1160. for (int i = 0; i < AsmJSMathBuiltinFunction_COUNT; i++)
  1161. {
  1162. if (!AddStandardLibraryMathName((PropertyId)mathFunctions[i].id, mathFunctions[i].val, mathFunctions[i].val->GetMathBuiltInFunction()))
  1163. {
  1164. return false;
  1165. }
  1166. }
  1167. struct ConstMath
  1168. {
  1169. ConstMath(PropertyId id_, const double* val_, AsmJSMathBuiltinFunction mathLibConstName_) :
  1170. id(id_), val(val_), mathLibConstName(mathLibConstName_) { }
  1171. PropertyId id;
  1172. AsmJSMathBuiltinFunction mathLibConstName;
  1173. const double* val;
  1174. };
  1175. ConstMath constMath[] = {
  1176. ConstMath(PropertyIds::E , &Math::E , AsmJSMathBuiltinFunction::AsmJSMathBuiltin_e),
  1177. ConstMath(PropertyIds::LN10 , &Math::LN10 , AsmJSMathBuiltinFunction::AsmJSMathBuiltin_ln10),
  1178. ConstMath(PropertyIds::LN2 , &Math::LN2 , AsmJSMathBuiltinFunction::AsmJSMathBuiltin_ln2),
  1179. ConstMath(PropertyIds::LOG2E , &Math::LOG2E , AsmJSMathBuiltinFunction::AsmJSMathBuiltin_log2e),
  1180. ConstMath(PropertyIds::LOG10E , &Math::LOG10E , AsmJSMathBuiltinFunction::AsmJSMathBuiltin_log10e),
  1181. ConstMath(PropertyIds::PI , &Math::PI , AsmJSMathBuiltinFunction::AsmJSMathBuiltin_pi),
  1182. ConstMath(PropertyIds::SQRT1_2 , &Math::SQRT1_2 , AsmJSMathBuiltinFunction::AsmJSMathBuiltin_sqrt1_2),
  1183. ConstMath(PropertyIds::SQRT2 , &Math::SQRT2 , AsmJSMathBuiltinFunction::AsmJSMathBuiltin_sqrt2),
  1184. ConstMath(PropertyIds::Infinity , &NumberConstants::POSITIVE_INFINITY, AsmJSMathBuiltinFunction::AsmJSMathBuiltin_infinity),
  1185. ConstMath(PropertyIds::NaN , &NumberConstants::NaN , AsmJSMathBuiltinFunction::AsmJSMathBuiltin_nan),
  1186. };
  1187. const int size = sizeof(constMath) / sizeof(ConstMath);
  1188. for (int i = 0; i < size; i++)
  1189. {
  1190. if (!AddStandardLibraryMathName(constMath[i].id, constMath[i].val, constMath[i].mathLibConstName))
  1191. {
  1192. return false;
  1193. }
  1194. }
  1195. struct ArrayFunc
  1196. {
  1197. ArrayFunc(PropertyId id_ = 0, AsmJsTypedArrayFunction* val_ = nullptr) :
  1198. id(id_), val(val_)
  1199. {
  1200. }
  1201. PropertyId id;
  1202. AsmJsTypedArrayFunction* val;
  1203. };
  1204. ArrayFunc arrayFunctions[AsmJSMathBuiltinFunction_COUNT];
  1205. arrayFunctions[AsmJSTypedArrayBuiltin_Int8Array] = ArrayFunc(PropertyIds::Int8Array, Anew(&mAllocator, AsmJsTypedArrayFunction, nullptr, &mAllocator, AsmJSTypedArrayBuiltin_Int8Array, ArrayBufferView::TYPE_INT8));
  1206. arrayFunctions[AsmJSTypedArrayBuiltin_Uint8Array] = ArrayFunc(PropertyIds::Uint8Array, Anew(&mAllocator, AsmJsTypedArrayFunction, nullptr, &mAllocator, AsmJSTypedArrayBuiltin_Uint8Array, ArrayBufferView::TYPE_UINT8));
  1207. arrayFunctions[AsmJSTypedArrayBuiltin_Int16Array] = ArrayFunc(PropertyIds::Int16Array, Anew(&mAllocator, AsmJsTypedArrayFunction, nullptr, &mAllocator, AsmJSTypedArrayBuiltin_Int16Array, ArrayBufferView::TYPE_INT16));
  1208. arrayFunctions[AsmJSTypedArrayBuiltin_Uint16Array] = ArrayFunc(PropertyIds::Uint16Array, Anew(&mAllocator, AsmJsTypedArrayFunction, nullptr, &mAllocator, AsmJSTypedArrayBuiltin_Uint16Array, ArrayBufferView::TYPE_UINT16));
  1209. arrayFunctions[AsmJSTypedArrayBuiltin_Int32Array] = ArrayFunc(PropertyIds::Int32Array, Anew(&mAllocator, AsmJsTypedArrayFunction, nullptr, &mAllocator, AsmJSTypedArrayBuiltin_Int32Array, ArrayBufferView::TYPE_INT32));
  1210. arrayFunctions[AsmJSTypedArrayBuiltin_Uint32Array] = ArrayFunc(PropertyIds::Uint32Array, Anew(&mAllocator, AsmJsTypedArrayFunction, nullptr, &mAllocator, AsmJSTypedArrayBuiltin_Uint32Array, ArrayBufferView::TYPE_UINT32));
  1211. arrayFunctions[AsmJSTypedArrayBuiltin_Float32Array] = ArrayFunc(PropertyIds::Float32Array, Anew(&mAllocator, AsmJsTypedArrayFunction, nullptr, &mAllocator, AsmJSTypedArrayBuiltin_Float32Array, ArrayBufferView::TYPE_FLOAT32));
  1212. arrayFunctions[AsmJSTypedArrayBuiltin_Float64Array] = ArrayFunc(PropertyIds::Float64Array, Anew(&mAllocator, AsmJsTypedArrayFunction, nullptr, &mAllocator, AsmJSTypedArrayBuiltin_Float64Array, ArrayBufferView::TYPE_FLOAT64));
  1213. arrayFunctions[AsmJSTypedArrayBuiltin_byteLength] = ArrayFunc(PropertyIds::byteLength, Anew(&mAllocator, AsmJsTypedArrayFunction, nullptr, &mAllocator, AsmJSTypedArrayBuiltin_byteLength, ArrayBufferView::TYPE_COUNT));
  1214. for (int i = 0; i < AsmJSTypedArrayBuiltin_COUNT; i++)
  1215. {
  1216. if (!AddStandardLibraryArrayName((PropertyId)arrayFunctions[i].id, arrayFunctions[i].val, arrayFunctions[i].val->GetArrayBuiltInFunction()))
  1217. {
  1218. return false;
  1219. }
  1220. }
  1221. #ifdef ENABLE_SIMDJS
  1222. // similar to math functions maps initialization.
  1223. if (IsSimdjsEnabled())
  1224. {
  1225. if (!InitSIMDBuiltins())
  1226. {
  1227. return false;
  1228. }
  1229. }
  1230. #endif
  1231. return true;
  1232. }
  1233. bool AsmJsModuleCompiler::InitSIMDBuiltins()
  1234. {
  1235. struct SIMDFunc
  1236. {
  1237. SIMDFunc(PropertyId id_ = 0, AsmJsSIMDFunction* val_ = nullptr) :
  1238. id(id_), val(val_)
  1239. {
  1240. }
  1241. PropertyId id;
  1242. AsmJsSIMDFunction* val;
  1243. };
  1244. SIMDFunc simdFunctions[AsmJsSIMDBuiltin_COUNT];
  1245. // !! NOTE: Keep these grouped by SIMD type
  1246. /* Int32x4 builtins*/
  1247. //-------------------
  1248. simdFunctions[AsmJsSIMDBuiltin_Int32x4] = SIMDFunc(PropertyIds::Int32x4, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 4, AsmJsSIMDBuiltin_Int32x4, OpCodeAsmJs::Simd128_IntsToI4, AsmJsRetType::Int32x4, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish));
  1249. simdFunctions[AsmJsSIMDBuiltin_int32x4_check] = SIMDFunc(PropertyIds::check, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int32x4_check, OpCodeAsmJs::Simd128_Ld_I4 /*no dynamic checks*/, AsmJsRetType::Int32x4, AsmJsType::Int32x4));
  1250. simdFunctions[AsmJsSIMDBuiltin_int32x4_splat] = SIMDFunc(PropertyIds::splat, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int32x4_splat, OpCodeAsmJs::Simd128_Splat_I4, AsmJsRetType::Int32x4, AsmJsType::Intish));
  1251. #if 0
  1252. simdFunctions[AsmJsSIMDBuiltin_int32x4_fromFloat64x2] = SIMDFunc(PropertyIds::fromFloat64x2, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int32x4_fromFloat64x2, OpCodeAsmJs::Simd128_FromFloat64x2_I4, AsmJsRetType::Int32x4, AsmJsType::Float64x2));
  1253. simdFunctions[AsmJsSIMDBuiltin_int32x4_fromFloat64x2Bits] = SIMDFunc(PropertyIds::fromFloat64x2Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int32x4_fromFloat64x2Bits, OpCodeAsmJs::Simd128_FromFloat64x2Bits_I4, AsmJsRetType::Int32x4, AsmJsType::Float64x2));
  1254. #endif
  1255. simdFunctions[AsmJsSIMDBuiltin_int32x4_fromFloat32x4] = SIMDFunc(PropertyIds::fromFloat32x4, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int32x4_fromFloat32x4, OpCodeAsmJs::Simd128_FromFloat32x4_I4, AsmJsRetType::Int32x4, AsmJsType::Float32x4));
  1256. simdFunctions[AsmJsSIMDBuiltin_int32x4_fromFloat32x4Bits] = SIMDFunc(PropertyIds::fromFloat32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int32x4_fromFloat32x4Bits, OpCodeAsmJs::Simd128_FromFloat32x4Bits_I4, AsmJsRetType::Int32x4, AsmJsType::Float32x4));
  1257. simdFunctions[AsmJsSIMDBuiltin_int32x4_fromInt16x8Bits] = SIMDFunc(PropertyIds::fromInt16x8Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int32x4_fromInt16x8Bits, OpCodeAsmJs::Simd128_FromInt16x8Bits_I4, AsmJsRetType::Int32x4, AsmJsType::Int16x8));
  1258. simdFunctions[AsmJsSIMDBuiltin_int32x4_fromInt8x16Bits] = SIMDFunc(PropertyIds::fromInt8x16Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int32x4_fromInt8x16Bits, OpCodeAsmJs::Simd128_FromInt8x16Bits_I4, AsmJsRetType::Int32x4, AsmJsType::Int8x16));
  1259. simdFunctions[AsmJsSIMDBuiltin_int32x4_fromUint32x4Bits] = SIMDFunc(PropertyIds::fromUint32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int32x4_fromUint32x4Bits, OpCodeAsmJs::Simd128_FromUint32x4Bits_I4, AsmJsRetType::Int32x4, AsmJsType::Uint32x4));
  1260. simdFunctions[AsmJsSIMDBuiltin_int32x4_fromUint16x8Bits] = SIMDFunc(PropertyIds::fromUint16x8Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int32x4_fromUint16x8Bits, OpCodeAsmJs::Simd128_FromUint16x8Bits_I4, AsmJsRetType::Int32x4, AsmJsType::Uint16x8));
  1261. simdFunctions[AsmJsSIMDBuiltin_int32x4_fromUint8x16Bits] = SIMDFunc(PropertyIds::fromUint8x16Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int32x4_fromUint8x16Bits, OpCodeAsmJs::Simd128_FromUint8x16Bits_I4, AsmJsRetType::Int32x4, AsmJsType::Uint8x16));
  1262. simdFunctions[AsmJsSIMDBuiltin_int32x4_neg] = SIMDFunc(PropertyIds::neg, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int32x4_neg, OpCodeAsmJs::Simd128_Neg_I4, AsmJsRetType::Int32x4, AsmJsType::Int32x4));
  1263. simdFunctions[AsmJsSIMDBuiltin_int32x4_add] = SIMDFunc(PropertyIds::add, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_add, OpCodeAsmJs::Simd128_Add_I4, AsmJsRetType::Int32x4, AsmJsType::Int32x4, AsmJsType::Int32x4));
  1264. simdFunctions[AsmJsSIMDBuiltin_int32x4_sub] = SIMDFunc(PropertyIds::sub, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_sub, OpCodeAsmJs::Simd128_Sub_I4, AsmJsRetType::Int32x4, AsmJsType::Int32x4, AsmJsType::Int32x4));
  1265. simdFunctions[AsmJsSIMDBuiltin_int32x4_mul] = SIMDFunc(PropertyIds::mul, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_mul, OpCodeAsmJs::Simd128_Mul_I4, AsmJsRetType::Int32x4, AsmJsType::Int32x4, AsmJsType::Int32x4));
  1266. simdFunctions[AsmJsSIMDBuiltin_int32x4_swizzle] = SIMDFunc(PropertyIds::swizzle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 5, AsmJsSIMDBuiltin_int32x4_swizzle, OpCodeAsmJs::Simd128_Swizzle_I4, AsmJsRetType::Int32x4, AsmJsType::Int32x4, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int));
  1267. simdFunctions[AsmJsSIMDBuiltin_int32x4_shuffle] = SIMDFunc(PropertyIds::shuffle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 6, AsmJsSIMDBuiltin_int32x4_shuffle, OpCodeAsmJs::Simd128_Shuffle_I4, AsmJsRetType::Int32x4, AsmJsType::Int32x4, AsmJsType::Int32x4, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int));
  1268. simdFunctions[AsmJsSIMDBuiltin_int32x4_extractLane] = SIMDFunc(PropertyIds::extractLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_extractLane, OpCodeAsmJs::Simd128_ExtractLane_I4, AsmJsRetType::Signed, AsmJsType::Int32x4, AsmJsType::Int));
  1269. simdFunctions[AsmJsSIMDBuiltin_int32x4_replaceLane] = SIMDFunc(PropertyIds::replaceLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_int32x4_replaceLane, OpCodeAsmJs::Simd128_ReplaceLane_I4, AsmJsRetType::Int32x4, AsmJsType::Int32x4, AsmJsType::Int, AsmJsType::Intish));
  1270. simdFunctions[AsmJsSIMDBuiltin_int32x4_lessThan] = SIMDFunc(PropertyIds::lessThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_lessThan, OpCodeAsmJs::Simd128_Lt_I4, AsmJsRetType::Bool32x4, AsmJsType::Int32x4, AsmJsType::Int32x4));
  1271. simdFunctions[AsmJsSIMDBuiltin_int32x4_lessThanOrEqual] = SIMDFunc(PropertyIds::lessThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_lessThanOrEqual, OpCodeAsmJs::Simd128_LtEq_I4, AsmJsRetType::Bool32x4, AsmJsType::Int32x4, AsmJsType::Int32x4));
  1272. simdFunctions[AsmJsSIMDBuiltin_int32x4_equal] = SIMDFunc(PropertyIds::equal, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_equal, OpCodeAsmJs::Simd128_Eq_I4, AsmJsRetType::Bool32x4, AsmJsType::Int32x4, AsmJsType::Int32x4));
  1273. simdFunctions[AsmJsSIMDBuiltin_int32x4_notEqual] = SIMDFunc(PropertyIds::notEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_notEqual, OpCodeAsmJs::Simd128_Neq_I4, AsmJsRetType::Bool32x4, AsmJsType::Int32x4, AsmJsType::Int32x4));
  1274. simdFunctions[AsmJsSIMDBuiltin_int32x4_greaterThan] = SIMDFunc(PropertyIds::greaterThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_greaterThan, OpCodeAsmJs::Simd128_Gt_I4, AsmJsRetType::Bool32x4, AsmJsType::Int32x4, AsmJsType::Int32x4));
  1275. simdFunctions[AsmJsSIMDBuiltin_int32x4_greaterThanOrEqual] = SIMDFunc(PropertyIds::greaterThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_greaterThanOrEqual, OpCodeAsmJs::Simd128_GtEq_I4, AsmJsRetType::Bool32x4, AsmJsType::Int32x4, AsmJsType::Int32x4));
  1276. simdFunctions[AsmJsSIMDBuiltin_int32x4_select] = SIMDFunc(PropertyIds::select, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_int32x4_select, OpCodeAsmJs::Simd128_Select_I4, AsmJsRetType::Int32x4, AsmJsType::Bool32x4, AsmJsType::Int32x4, AsmJsType::Int32x4));
  1277. simdFunctions[AsmJsSIMDBuiltin_int32x4_and] = SIMDFunc(PropertyIds::and_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_and, OpCodeAsmJs::Simd128_And_I4, AsmJsRetType::Int32x4, AsmJsType::Int32x4, AsmJsType::Int32x4));
  1278. simdFunctions[AsmJsSIMDBuiltin_int32x4_or] = SIMDFunc(PropertyIds::or_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_or, OpCodeAsmJs::Simd128_Or_I4, AsmJsRetType::Int32x4, AsmJsType::Int32x4, AsmJsType::Int32x4));
  1279. simdFunctions[AsmJsSIMDBuiltin_int32x4_xor] = SIMDFunc(PropertyIds::xor_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_xor, OpCodeAsmJs::Simd128_Xor_I4, AsmJsRetType::Int32x4, AsmJsType::Int32x4, AsmJsType::Int32x4));
  1280. simdFunctions[AsmJsSIMDBuiltin_int32x4_not] = SIMDFunc(PropertyIds::not_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int32x4_not, OpCodeAsmJs::Simd128_Not_I4, AsmJsRetType::Int32x4, AsmJsType::Int32x4));
  1281. simdFunctions[AsmJsSIMDBuiltin_int32x4_shiftLeftByScalar] = SIMDFunc(PropertyIds::shiftLeftByScalar, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_shiftLeftByScalar, OpCodeAsmJs::Simd128_ShLtByScalar_I4, AsmJsRetType::Int32x4, AsmJsType::Int32x4, AsmJsType::Int));
  1282. simdFunctions[AsmJsSIMDBuiltin_int32x4_shiftRightByScalar] = SIMDFunc(PropertyIds::shiftRightByScalar, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_shiftRightByScalar, OpCodeAsmJs::Simd128_ShRtByScalar_I4, AsmJsRetType::Int32x4, AsmJsType::Int32x4, AsmJsType::Int));
  1283. // Loads and Stores
  1284. // We fill Void for the tarray type. This is ok since we special handle these ops.
  1285. simdFunctions[AsmJsSIMDBuiltin_int32x4_load] = SIMDFunc(PropertyIds::load, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_load, OpCodeAsmJs::Simd128_LdArr_I4, AsmJsRetType::Int32x4, AsmJsType::Void, AsmJsType::Int));
  1286. simdFunctions[AsmJsSIMDBuiltin_int32x4_load1] = SIMDFunc(PropertyIds::load1, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_load1, OpCodeAsmJs::Simd128_LdArr_I4, AsmJsRetType::Int32x4, AsmJsType::Void, AsmJsType::Int));
  1287. simdFunctions[AsmJsSIMDBuiltin_int32x4_load2] = SIMDFunc(PropertyIds::load2, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_load2, OpCodeAsmJs::Simd128_LdArr_I4, AsmJsRetType::Int32x4, AsmJsType::Void, AsmJsType::Int));
  1288. simdFunctions[AsmJsSIMDBuiltin_int32x4_load3] = SIMDFunc(PropertyIds::load3, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int32x4_load3, OpCodeAsmJs::Simd128_LdArr_I4, AsmJsRetType::Int32x4, AsmJsType::Void, AsmJsType::Int));
  1289. simdFunctions[AsmJsSIMDBuiltin_int32x4_store] = SIMDFunc(PropertyIds::store, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_int32x4_store, OpCodeAsmJs::Simd128_StArr_I4, AsmJsRetType::Int32x4, AsmJsType::Void, AsmJsType::Int, AsmJsType::Int32x4));
  1290. simdFunctions[AsmJsSIMDBuiltin_int32x4_store1] = SIMDFunc(PropertyIds::store1, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_int32x4_store1, OpCodeAsmJs::Simd128_StArr_I4, AsmJsRetType::Int32x4, AsmJsType::Void, AsmJsType::Int, AsmJsType::Int32x4));
  1291. simdFunctions[AsmJsSIMDBuiltin_int32x4_store2] = SIMDFunc(PropertyIds::store2, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_int32x4_store2, OpCodeAsmJs::Simd128_StArr_I4, AsmJsRetType::Int32x4, AsmJsType::Void, AsmJsType::Int, AsmJsType::Int32x4));
  1292. simdFunctions[AsmJsSIMDBuiltin_int32x4_store3] = SIMDFunc(PropertyIds::store3, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_int32x4_store3, OpCodeAsmJs::Simd128_StArr_I4, AsmJsRetType::Int32x4, AsmJsType::Void, AsmJsType::Int, AsmJsType::Int32x4));
  1293. /* Float32x4 builtins*/
  1294. //-------------------
  1295. simdFunctions[AsmJsSIMDBuiltin_Float32x4] = SIMDFunc(PropertyIds::Float32x4, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 4, AsmJsSIMDBuiltin_Float32x4, OpCodeAsmJs::Simd128_FloatsToF4, AsmJsRetType::Float32x4, AsmJsType::FloatishDoubleLit, AsmJsType::FloatishDoubleLit, AsmJsType::FloatishDoubleLit, AsmJsType::FloatishDoubleLit));
  1296. simdFunctions[AsmJsSIMDBuiltin_float32x4_check] = SIMDFunc(PropertyIds::check, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_check, OpCodeAsmJs::Simd128_Ld_F4 /*no dynamic checks*/, AsmJsRetType::Float32x4, AsmJsType::Float32x4));
  1297. simdFunctions[AsmJsSIMDBuiltin_float32x4_splat] = SIMDFunc(PropertyIds::splat, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_splat, OpCodeAsmJs::Simd128_Splat_F4, AsmJsRetType::Float32x4, AsmJsType::FloatishDoubleLit));
  1298. #if 0
  1299. simdFunctions[AsmJsSIMDBuiltin_float32x4_fromFloat64x2] = SIMDFunc(PropertyIds::fromFloat64x2, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_fromFloat64x2, OpCodeAsmJs::Simd128_FromFloat64x2_F4, AsmJsRetType::Float32x4, AsmJsType::Float64x2));
  1300. simdFunctions[AsmJsSIMDBuiltin_float32x4_fromFloat64x2Bits] = SIMDFunc(PropertyIds::fromFloat64x2Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_fromFloat64x2Bits, OpCodeAsmJs::Simd128_FromFloat64x2Bits_F4, AsmJsRetType::Float32x4, AsmJsType::Float64x2));
  1301. #endif
  1302. simdFunctions[AsmJsSIMDBuiltin_float32x4_fromInt32x4] = SIMDFunc(PropertyIds::fromInt32x4, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_fromInt32x4, OpCodeAsmJs::Simd128_FromInt32x4_F4, AsmJsRetType::Float32x4, AsmJsType::Int32x4));
  1303. simdFunctions[AsmJsSIMDBuiltin_float32x4_fromUint32x4] = SIMDFunc(PropertyIds::fromUint32x4, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_fromUint32x4, OpCodeAsmJs::Simd128_FromUint32x4_F4, AsmJsRetType::Float32x4, AsmJsType::Uint32x4));
  1304. simdFunctions[AsmJsSIMDBuiltin_float32x4_fromInt32x4Bits] = SIMDFunc(PropertyIds::fromInt32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_fromInt32x4Bits, OpCodeAsmJs::Simd128_FromInt32x4Bits_F4, AsmJsRetType::Float32x4, AsmJsType::Int32x4));
  1305. simdFunctions[AsmJsSIMDBuiltin_float32x4_fromInt16x8Bits] = SIMDFunc(PropertyIds::fromInt16x8Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_fromInt16x8Bits, OpCodeAsmJs::Simd128_FromInt16x8Bits_F4, AsmJsRetType::Float32x4, AsmJsType::Int16x8));
  1306. simdFunctions[AsmJsSIMDBuiltin_float32x4_fromInt8x16Bits] = SIMDFunc(PropertyIds::fromInt8x16Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_fromInt8x16Bits, OpCodeAsmJs::Simd128_FromInt8x16Bits_F4, AsmJsRetType::Float32x4, AsmJsType::Int8x16));
  1307. simdFunctions[AsmJsSIMDBuiltin_float32x4_fromUint32x4Bits] = SIMDFunc(PropertyIds::fromUint32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_fromUint32x4Bits, OpCodeAsmJs::Simd128_FromUint32x4Bits_F4, AsmJsRetType::Float32x4, AsmJsType::Uint32x4));
  1308. simdFunctions[AsmJsSIMDBuiltin_float32x4_fromUint16x8Bits] = SIMDFunc(PropertyIds::fromUint16x8Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_fromUint16x8Bits, OpCodeAsmJs::Simd128_FromUint16x8Bits_F4, AsmJsRetType::Float32x4, AsmJsType::Uint16x8));
  1309. simdFunctions[AsmJsSIMDBuiltin_float32x4_fromUint8x16Bits] = SIMDFunc(PropertyIds::fromUint8x16Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_fromUint8x16Bits, OpCodeAsmJs::Simd128_FromUint8x16Bits_F4, AsmJsRetType::Float32x4, AsmJsType::Uint8x16));
  1310. simdFunctions[AsmJsSIMDBuiltin_float32x4_abs] = SIMDFunc(PropertyIds::abs, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_abs, OpCodeAsmJs::Simd128_Abs_F4, AsmJsRetType::Float32x4, AsmJsType::Float32x4));
  1311. simdFunctions[AsmJsSIMDBuiltin_float32x4_neg] = SIMDFunc(PropertyIds::neg, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_neg, OpCodeAsmJs::Simd128_Neg_F4, AsmJsRetType::Float32x4, AsmJsType::Float32x4));
  1312. simdFunctions[AsmJsSIMDBuiltin_float32x4_add] = SIMDFunc(PropertyIds::add, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_add, OpCodeAsmJs::Simd128_Add_F4, AsmJsRetType::Float32x4, AsmJsType::Float32x4, AsmJsType::Float32x4));
  1313. simdFunctions[AsmJsSIMDBuiltin_float32x4_sub] = SIMDFunc(PropertyIds::sub, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_sub, OpCodeAsmJs::Simd128_Sub_F4, AsmJsRetType::Float32x4, AsmJsType::Float32x4, AsmJsType::Float32x4));
  1314. simdFunctions[AsmJsSIMDBuiltin_float32x4_mul] = SIMDFunc(PropertyIds::mul, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_mul, OpCodeAsmJs::Simd128_Mul_F4, AsmJsRetType::Float32x4, AsmJsType::Float32x4, AsmJsType::Float32x4));
  1315. simdFunctions[AsmJsSIMDBuiltin_float32x4_div] = SIMDFunc(PropertyIds::div, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_div, OpCodeAsmJs::Simd128_Div_F4, AsmJsRetType::Float32x4, AsmJsType::Float32x4, AsmJsType::Float32x4));
  1316. simdFunctions[AsmJsSIMDBuiltin_float32x4_min] = SIMDFunc(PropertyIds::min, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_min, OpCodeAsmJs::Simd128_Min_F4, AsmJsRetType::Float32x4, AsmJsType::Float32x4, AsmJsType::Float32x4));
  1317. simdFunctions[AsmJsSIMDBuiltin_float32x4_max] = SIMDFunc(PropertyIds::max, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_max, OpCodeAsmJs::Simd128_Max_F4, AsmJsRetType::Float32x4, AsmJsType::Float32x4, AsmJsType::Float32x4));
  1318. simdFunctions[AsmJsSIMDBuiltin_float32x4_reciprocal] = SIMDFunc(PropertyIds::reciprocalApproximation, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_reciprocal, OpCodeAsmJs::Simd128_Rcp_F4, AsmJsRetType::Float32x4, AsmJsType::Float32x4));
  1319. simdFunctions[AsmJsSIMDBuiltin_float32x4_reciprocalSqrt] = SIMDFunc(PropertyIds::reciprocalSqrtApproximation, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_reciprocalSqrt, OpCodeAsmJs::Simd128_RcpSqrt_F4, AsmJsRetType::Float32x4, AsmJsType::Float32x4));
  1320. simdFunctions[AsmJsSIMDBuiltin_float32x4_sqrt] = SIMDFunc(PropertyIds::sqrt, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float32x4_sqrt, OpCodeAsmJs::Simd128_Sqrt_F4, AsmJsRetType::Float32x4, AsmJsType::Float32x4));
  1321. simdFunctions[AsmJsSIMDBuiltin_float32x4_swizzle] = SIMDFunc(PropertyIds::swizzle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 5, AsmJsSIMDBuiltin_float32x4_swizzle, OpCodeAsmJs::Simd128_Swizzle_F4, AsmJsRetType::Float32x4, AsmJsType::Float32x4, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int));
  1322. simdFunctions[AsmJsSIMDBuiltin_float32x4_shuffle] = SIMDFunc(PropertyIds::shuffle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 6, AsmJsSIMDBuiltin_float32x4_shuffle, OpCodeAsmJs::Simd128_Shuffle_F4, AsmJsRetType::Float32x4, AsmJsType::Float32x4, AsmJsType::Float32x4, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int));
  1323. simdFunctions[AsmJsSIMDBuiltin_float32x4_extractLane] = SIMDFunc(PropertyIds::extractLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_extractLane, OpCodeAsmJs::Simd128_ExtractLane_F4, AsmJsRetType::Float, AsmJsType::Float32x4, AsmJsType::Int));
  1324. simdFunctions[AsmJsSIMDBuiltin_float32x4_replaceLane] = SIMDFunc(PropertyIds::replaceLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_float32x4_replaceLane, OpCodeAsmJs::Simd128_ReplaceLane_F4, AsmJsRetType::Float32x4, AsmJsType::Float32x4, AsmJsType::Int, AsmJsType::FloatishDoubleLit));
  1325. simdFunctions[AsmJsSIMDBuiltin_float32x4_lessThan] = SIMDFunc(PropertyIds::lessThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_lessThan, OpCodeAsmJs::Simd128_Lt_F4, AsmJsRetType::Bool32x4, AsmJsType::Float32x4, AsmJsType::Float32x4));
  1326. simdFunctions[AsmJsSIMDBuiltin_float32x4_lessThanOrEqual] = SIMDFunc(PropertyIds::lessThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_lessThanOrEqual, OpCodeAsmJs::Simd128_LtEq_F4, AsmJsRetType::Bool32x4, AsmJsType::Float32x4, AsmJsType::Float32x4));
  1327. simdFunctions[AsmJsSIMDBuiltin_float32x4_equal] = SIMDFunc(PropertyIds::equal, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_equal, OpCodeAsmJs::Simd128_Eq_F4, AsmJsRetType::Bool32x4, AsmJsType::Float32x4, AsmJsType::Float32x4));
  1328. simdFunctions[AsmJsSIMDBuiltin_float32x4_notEqual] = SIMDFunc(PropertyIds::notEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_notEqual, OpCodeAsmJs::Simd128_Neq_F4, AsmJsRetType::Bool32x4, AsmJsType::Float32x4, AsmJsType::Float32x4));
  1329. simdFunctions[AsmJsSIMDBuiltin_float32x4_greaterThan] = SIMDFunc(PropertyIds::greaterThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_greaterThan, OpCodeAsmJs::Simd128_Gt_F4, AsmJsRetType::Bool32x4, AsmJsType::Float32x4, AsmJsType::Float32x4));
  1330. simdFunctions[AsmJsSIMDBuiltin_float32x4_greaterThanOrEqual] = SIMDFunc(PropertyIds::greaterThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_greaterThanOrEqual, OpCodeAsmJs::Simd128_GtEq_F4, AsmJsRetType::Bool32x4, AsmJsType::Float32x4, AsmJsType::Float32x4));
  1331. simdFunctions[AsmJsSIMDBuiltin_float32x4_select] = SIMDFunc(PropertyIds::select, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_float32x4_select, OpCodeAsmJs::Simd128_Select_F4, AsmJsRetType::Float32x4, AsmJsType::Bool32x4, AsmJsType::Float32x4, AsmJsType::Float32x4));
  1332. simdFunctions[AsmJsSIMDBuiltin_float32x4_load] = SIMDFunc(PropertyIds::load, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_load, OpCodeAsmJs::Simd128_LdArr_F4, AsmJsRetType::Float32x4, AsmJsType::Void, AsmJsType::Int));
  1333. simdFunctions[AsmJsSIMDBuiltin_float32x4_load1] = SIMDFunc(PropertyIds::load1, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_load1, OpCodeAsmJs::Simd128_LdArr_F4, AsmJsRetType::Float32x4, AsmJsType::Void, AsmJsType::Int));
  1334. simdFunctions[AsmJsSIMDBuiltin_float32x4_load2] = SIMDFunc(PropertyIds::load2, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_load2, OpCodeAsmJs::Simd128_LdArr_F4, AsmJsRetType::Float32x4, AsmJsType::Void, AsmJsType::Int));
  1335. simdFunctions[AsmJsSIMDBuiltin_float32x4_load3] = SIMDFunc(PropertyIds::load3, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float32x4_load3, OpCodeAsmJs::Simd128_LdArr_F4, AsmJsRetType::Float32x4, AsmJsType::Void, AsmJsType::Int));
  1336. simdFunctions[AsmJsSIMDBuiltin_float32x4_store] = SIMDFunc(PropertyIds::store, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_float32x4_store, OpCodeAsmJs::Simd128_StArr_F4, AsmJsRetType::Float32x4, AsmJsType::Void, AsmJsType::Int, AsmJsType::Float32x4));
  1337. simdFunctions[AsmJsSIMDBuiltin_float32x4_store1] = SIMDFunc(PropertyIds::store1, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_float32x4_store1, OpCodeAsmJs::Simd128_StArr_F4, AsmJsRetType::Float32x4, AsmJsType::Void, AsmJsType::Int, AsmJsType::Float32x4));
  1338. simdFunctions[AsmJsSIMDBuiltin_float32x4_store2] = SIMDFunc(PropertyIds::store2, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_float32x4_store2, OpCodeAsmJs::Simd128_StArr_F4, AsmJsRetType::Float32x4, AsmJsType::Void, AsmJsType::Int, AsmJsType::Float32x4));
  1339. simdFunctions[AsmJsSIMDBuiltin_float32x4_store3] = SIMDFunc(PropertyIds::store3, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_float32x4_store3, OpCodeAsmJs::Simd128_StArr_F4, AsmJsRetType::Float32x4, AsmJsType::Void, AsmJsType::Int, AsmJsType::Float32x4));
  1340. /* Float64x2 builtins*/
  1341. //-------------------
  1342. #if 0
  1343. simdFunctions[AsmJsSIMDBuiltin_Float64x2] = SIMDFunc(PropertyIds::Float64x2, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_Float64x2, OpCodeAsmJs::Simd128_DoublesToD2, AsmJsRetType::Float64x2, AsmJsType::MaybeDouble, AsmJsType::MaybeDouble));
  1344. simdFunctions[AsmJsSIMDBuiltin_float64x2_check] = SIMDFunc(PropertyIds::check, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float64x2_check, OpCodeAsmJs::Simd128_Ld_D2 /*no dynamic checks*/, AsmJsRetType::Float64x2, AsmJsType::Float64x2));
  1345. simdFunctions[AsmJsSIMDBuiltin_float64x2_splat] = SIMDFunc(PropertyIds::splat, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float64x2_splat, OpCodeAsmJs::Simd128_Splat_D2, AsmJsRetType::Float64x2, AsmJsType::Double));
  1346. simdFunctions[AsmJsSIMDBuiltin_float64x2_fromFloat32x4] = SIMDFunc(PropertyIds::fromFloat32x4, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float64x2_fromFloat32x4, OpCodeAsmJs::Simd128_FromFloat32x4_D2, AsmJsRetType::Float64x2, AsmJsType::Float32x4));
  1347. simdFunctions[AsmJsSIMDBuiltin_float64x2_fromFloat32x4Bits] = SIMDFunc(PropertyIds::fromFloat32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float64x2_fromFloat32x4Bits, OpCodeAsmJs::Simd128_FromFloat32x4Bits_D2, AsmJsRetType::Float64x2, AsmJsType::Float32x4));
  1348. simdFunctions[AsmJsSIMDBuiltin_float64x2_fromInt32x4] = SIMDFunc(PropertyIds::fromInt32x4, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float64x2_fromInt32x4, OpCodeAsmJs::Simd128_FromInt32x4_D2, AsmJsRetType::Float64x2, AsmJsType::Int32x4));
  1349. simdFunctions[AsmJsSIMDBuiltin_float64x2_fromInt32x4Bits] = SIMDFunc(PropertyIds::fromInt32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float64x2_fromInt32x4Bits, OpCodeAsmJs::Simd128_FromInt32x4Bits_D2, AsmJsRetType::Float64x2, AsmJsType::Int32x4));
  1350. simdFunctions[AsmJsSIMDBuiltin_float64x2_abs] = SIMDFunc(PropertyIds::abs, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float64x2_abs, OpCodeAsmJs::Simd128_Abs_D2, AsmJsRetType::Float64x2, AsmJsType::Float64x2));
  1351. simdFunctions[AsmJsSIMDBuiltin_float64x2_neg] = SIMDFunc(PropertyIds::neg, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float64x2_neg, OpCodeAsmJs::Simd128_Neg_D2, AsmJsRetType::Float64x2, AsmJsType::Float64x2));
  1352. simdFunctions[AsmJsSIMDBuiltin_float64x2_add] = SIMDFunc(PropertyIds::add, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float64x2_add, OpCodeAsmJs::Simd128_Add_D2, AsmJsRetType::Float64x2, AsmJsType::Float64x2, AsmJsType::Float64x2));
  1353. simdFunctions[AsmJsSIMDBuiltin_float64x2_sub] = SIMDFunc(PropertyIds::sub, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float64x2_sub, OpCodeAsmJs::Simd128_Sub_D2, AsmJsRetType::Float64x2, AsmJsType::Float64x2, AsmJsType::Float64x2));
  1354. simdFunctions[AsmJsSIMDBuiltin_float64x2_mul] = SIMDFunc(PropertyIds::mul, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float64x2_mul, OpCodeAsmJs::Simd128_Mul_D2, AsmJsRetType::Float64x2, AsmJsType::Float64x2, AsmJsType::Float64x2));
  1355. simdFunctions[AsmJsSIMDBuiltin_float64x2_div] = SIMDFunc(PropertyIds::div, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float64x2_div, OpCodeAsmJs::Simd128_Div_D2, AsmJsRetType::Float64x2, AsmJsType::Float64x2, AsmJsType::Float64x2));
  1356. simdFunctions[AsmJsSIMDBuiltin_float64x2_min] = SIMDFunc(PropertyIds::min, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float64x2_min, OpCodeAsmJs::Simd128_Min_D2, AsmJsRetType::Float64x2, AsmJsType::Float64x2, AsmJsType::Float64x2));
  1357. simdFunctions[AsmJsSIMDBuiltin_float64x2_max] = SIMDFunc(PropertyIds::max, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float64x2_max, OpCodeAsmJs::Simd128_Max_D2, AsmJsRetType::Float64x2, AsmJsType::Float64x2, AsmJsType::Float64x2));
  1358. simdFunctions[AsmJsSIMDBuiltin_float64x2_reciprocal] = SIMDFunc(PropertyIds::reciprocalApproximation, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float64x2_reciprocal, OpCodeAsmJs::Simd128_Rcp_D2, AsmJsRetType::Float64x2, AsmJsType::Float64x2));
  1359. simdFunctions[AsmJsSIMDBuiltin_float64x2_reciprocalSqrt] = SIMDFunc(PropertyIds::reciprocalSqrtApproximation, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float64x2_reciprocalSqrt, OpCodeAsmJs::Simd128_RcpSqrt_D2, AsmJsRetType::Float64x2, AsmJsType::Float64x2));
  1360. simdFunctions[AsmJsSIMDBuiltin_float64x2_sqrt] = SIMDFunc(PropertyIds::sqrt, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_float64x2_sqrt, OpCodeAsmJs::Simd128_Sqrt_D2, AsmJsRetType::Float64x2, AsmJsType::Float64x2));
  1361. simdFunctions[AsmJsSIMDBuiltin_float64x2_swizzle] = SIMDFunc(PropertyIds::swizzle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_float64x2_swizzle, OpCodeAsmJs::Simd128_Swizzle_D2, AsmJsRetType::Float64x2, AsmJsType::Float64x2, AsmJsType::Int, AsmJsType::Int));
  1362. simdFunctions[AsmJsSIMDBuiltin_float64x2_shuffle] = SIMDFunc(PropertyIds::shuffle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 4, AsmJsSIMDBuiltin_float64x2_shuffle, OpCodeAsmJs::Simd128_Shuffle_D2, AsmJsRetType::Float64x2, AsmJsType::Float64x2, AsmJsType::Float64x2, AsmJsType::Int, AsmJsType::Int));
  1363. simdFunctions[AsmJsSIMDBuiltin_float64x2_lessThan] = SIMDFunc(PropertyIds::lessThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float64x2_lessThan, OpCodeAsmJs::Simd128_Lt_D2, AsmJsRetType::Bool32x4, AsmJsType::Float64x2, AsmJsType::Float64x2));
  1364. simdFunctions[AsmJsSIMDBuiltin_float64x2_lessThanOrEqual] = SIMDFunc(PropertyIds::lessThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float64x2_lessThanOrEqual, OpCodeAsmJs::Simd128_LtEq_D2, AsmJsRetType::Bool32x4, AsmJsType::Float64x2, AsmJsType::Float64x2));
  1365. simdFunctions[AsmJsSIMDBuiltin_float64x2_equal] = SIMDFunc(PropertyIds::equal, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float64x2_equal, OpCodeAsmJs::Simd128_Eq_D2, AsmJsRetType::Bool32x4, AsmJsType::Float64x2, AsmJsType::Float64x2));
  1366. simdFunctions[AsmJsSIMDBuiltin_float64x2_notEqual] = SIMDFunc(PropertyIds::notEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float64x2_notEqual, OpCodeAsmJs::Simd128_Neq_D2, AsmJsRetType::Bool32x4, AsmJsType::Float64x2, AsmJsType::Float64x2));
  1367. simdFunctions[AsmJsSIMDBuiltin_float64x2_greaterThan] = SIMDFunc(PropertyIds::greaterThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float64x2_greaterThan, OpCodeAsmJs::Simd128_Gt_D2, AsmJsRetType::Bool32x4, AsmJsType::Float64x2, AsmJsType::Float64x2));
  1368. simdFunctions[AsmJsSIMDBuiltin_float64x2_greaterThanOrEqual] = SIMDFunc(PropertyIds::greaterThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float64x2_greaterThanOrEqual, OpCodeAsmJs::Simd128_GtEq_D2, AsmJsRetType::Bool32x4, AsmJsType::Float64x2, AsmJsType::Float64x2));
  1369. simdFunctions[AsmJsSIMDBuiltin_float64x2_select] = SIMDFunc(PropertyIds::select, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_float64x2_select, OpCodeAsmJs::Simd128_Select_D2, AsmJsRetType::Float64x2, AsmJsType::Bool32x4, AsmJsType::Float64x2, AsmJsType::Float64x2));
  1370. simdFunctions[AsmJsSIMDBuiltin_float64x2_load] = SIMDFunc(PropertyIds::load, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float64x2_load, OpCodeAsmJs::Simd128_LdArr_D2, AsmJsRetType::Float64x2, AsmJsType::Void, AsmJsType::Int));
  1371. simdFunctions[AsmJsSIMDBuiltin_float64x2_load1] = SIMDFunc(PropertyIds::load1, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_float64x2_load1, OpCodeAsmJs::Simd128_LdArr_D2, AsmJsRetType::Float64x2, AsmJsType::Void, AsmJsType::Int));
  1372. simdFunctions[AsmJsSIMDBuiltin_float64x2_store] = SIMDFunc(PropertyIds::store, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_float64x2_store, OpCodeAsmJs::Simd128_StArr_D2, AsmJsRetType::Float64x2, AsmJsType::Void, AsmJsType::Int, AsmJsType::Float64x2));
  1373. simdFunctions[AsmJsSIMDBuiltin_float64x2_store1] = SIMDFunc(PropertyIds::store1, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_float64x2_store1, OpCodeAsmJs::Simd128_StArr_D2, AsmJsRetType::Float64x2, AsmJsType::Void, AsmJsType::Int, AsmJsType::Float64x2));
  1374. #endif
  1375. /* Int16x8 */
  1376. simdFunctions[AsmJsSIMDBuiltin_Int16x8] = SIMDFunc(PropertyIds::Int16x8, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 8, AsmJsSIMDBuiltin_Int16x8, OpCodeAsmJs::Simd128_IntsToI8, AsmJsRetType::Int16x8,
  1377. AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish));
  1378. simdFunctions[AsmJsSIMDBuiltin_int16x8_check] = SIMDFunc(PropertyIds::check, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int16x8_check, OpCodeAsmJs::Simd128_Ld_I8 /*no dynamic checks*/, AsmJsRetType::Int16x8, AsmJsType::Int16x8));
  1379. simdFunctions[AsmJsSIMDBuiltin_int16x8_extractLane] = SIMDFunc(PropertyIds::extractLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_extractLane, OpCodeAsmJs::Simd128_ExtractLane_I8, AsmJsRetType::Signed, AsmJsType::Int16x8, AsmJsType::Int));
  1380. simdFunctions[AsmJsSIMDBuiltin_int16x8_swizzle] = SIMDFunc(PropertyIds::swizzle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 9, AsmJsSIMDBuiltin_int16x8_swizzle, OpCodeAsmJs::Simd128_Swizzle_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8, AsmJsType::Int,
  1381. AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int));
  1382. simdFunctions[AsmJsSIMDBuiltin_int16x8_shuffle] = SIMDFunc(PropertyIds::shuffle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 10, AsmJsSIMDBuiltin_int16x8_shuffle, OpCodeAsmJs::Simd128_Shuffle_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8, AsmJsType::Int16x8,
  1383. AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int));
  1384. simdFunctions[AsmJsSIMDBuiltin_int16x8_splat] = SIMDFunc(PropertyIds::splat, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int16x8_splat, OpCodeAsmJs::Simd128_Splat_I8, AsmJsRetType::Int16x8, AsmJsType::Intish));
  1385. simdFunctions[AsmJsSIMDBuiltin_int16x8_replaceLane] = SIMDFunc(PropertyIds::replaceLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_int16x8_replaceLane, OpCodeAsmJs::Simd128_ReplaceLane_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8, AsmJsType::Int, AsmJsType::Intish));
  1386. simdFunctions[AsmJsSIMDBuiltin_int16x8_and] = SIMDFunc(PropertyIds::and_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_and, OpCodeAsmJs::Simd128_And_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1387. simdFunctions[AsmJsSIMDBuiltin_int16x8_or] = SIMDFunc(PropertyIds::or_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_or, OpCodeAsmJs::Simd128_Or_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1388. simdFunctions[AsmJsSIMDBuiltin_int16x8_xor] = SIMDFunc(PropertyIds::xor_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_xor, OpCodeAsmJs::Simd128_Xor_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1389. simdFunctions[AsmJsSIMDBuiltin_int16x8_not] = SIMDFunc(PropertyIds::not_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int16x8_not, OpCodeAsmJs::Simd128_Not_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8));
  1390. simdFunctions[AsmJsSIMDBuiltin_int16x8_add] = SIMDFunc(PropertyIds::add, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_add, OpCodeAsmJs::Simd128_Add_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1391. simdFunctions[AsmJsSIMDBuiltin_int16x8_sub] = SIMDFunc(PropertyIds::sub, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_sub, OpCodeAsmJs::Simd128_Sub_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1392. simdFunctions[AsmJsSIMDBuiltin_int16x8_mul] = SIMDFunc(PropertyIds::mul, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_mul, OpCodeAsmJs::Simd128_Mul_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1393. simdFunctions[AsmJsSIMDBuiltin_int16x8_neg] = SIMDFunc(PropertyIds::neg, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int16x8_neg, OpCodeAsmJs::Simd128_Neg_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8));
  1394. simdFunctions[AsmJsSIMDBuiltin_int16x8_shiftLeftByScalar] = SIMDFunc(PropertyIds::shiftLeftByScalar, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_shiftLeftByScalar, OpCodeAsmJs::Simd128_ShLtByScalar_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8, AsmJsType::Int));
  1395. simdFunctions[AsmJsSIMDBuiltin_int16x8_shiftRightByScalar] = SIMDFunc(PropertyIds::shiftRightByScalar, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_shiftRightByScalar, OpCodeAsmJs::Simd128_ShRtByScalar_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8, AsmJsType::Int));
  1396. simdFunctions[AsmJsSIMDBuiltin_int16x8_lessThan] = SIMDFunc(PropertyIds::lessThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_lessThan, OpCodeAsmJs::Simd128_Lt_I8, AsmJsRetType::Bool16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1397. simdFunctions[AsmJsSIMDBuiltin_int16x8_lessThanOrEqual] = SIMDFunc(PropertyIds::lessThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_lessThanOrEqual, OpCodeAsmJs::Simd128_LtEq_I8, AsmJsRetType::Bool16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1398. simdFunctions[AsmJsSIMDBuiltin_int16x8_equal] = SIMDFunc(PropertyIds::equal, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_equal, OpCodeAsmJs::Simd128_Eq_I8, AsmJsRetType::Bool16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1399. simdFunctions[AsmJsSIMDBuiltin_int16x8_notEqual] = SIMDFunc(PropertyIds::notEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_notEqual, OpCodeAsmJs::Simd128_Neq_I8, AsmJsRetType::Bool16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1400. simdFunctions[AsmJsSIMDBuiltin_int16x8_greaterThan] = SIMDFunc(PropertyIds::greaterThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_greaterThan, OpCodeAsmJs::Simd128_Gt_I8, AsmJsRetType::Bool16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1401. simdFunctions[AsmJsSIMDBuiltin_int16x8_greaterThanOrEqual] = SIMDFunc(PropertyIds::greaterThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_greaterThanOrEqual, OpCodeAsmJs::Simd128_GtEq_I8, AsmJsRetType::Bool16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1402. simdFunctions[AsmJsSIMDBuiltin_int16x8_select] = SIMDFunc(PropertyIds::select, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_int16x8_select, OpCodeAsmJs::Simd128_Select_I8, AsmJsRetType::Int16x8, AsmJsType::Bool16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1403. simdFunctions[AsmJsSIMDBuiltin_int16x8_addSaturate] = SIMDFunc(PropertyIds::addSaturate, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_addSaturate, OpCodeAsmJs::Simd128_AddSaturate_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1404. simdFunctions[AsmJsSIMDBuiltin_int16x8_subSaturate] = SIMDFunc(PropertyIds::subSaturate, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_subSaturate, OpCodeAsmJs::Simd128_SubSaturate_I8, AsmJsRetType::Int16x8, AsmJsType::Int16x8, AsmJsType::Int16x8));
  1405. simdFunctions[AsmJsSIMDBuiltin_int16x8_load] = SIMDFunc(PropertyIds::load, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int16x8_load, OpCodeAsmJs::Simd128_LdArr_I8, AsmJsRetType::Int16x8, AsmJsType::Void, AsmJsType::Int));
  1406. simdFunctions[AsmJsSIMDBuiltin_int16x8_store] = SIMDFunc(PropertyIds::store, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_int16x8_store, OpCodeAsmJs::Simd128_StArr_I8, AsmJsRetType::Int16x8, AsmJsType::Void, AsmJsType::Int, AsmJsType::Int16x8));
  1407. simdFunctions[AsmJsSIMDBuiltin_int16x8_fromFloat32x4Bits] = SIMDFunc(PropertyIds::fromFloat32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int16x8_fromFloat32x4Bits, OpCodeAsmJs::Simd128_FromFloat32x4Bits_I8, AsmJsRetType::Int16x8, AsmJsType::Float32x4));
  1408. simdFunctions[AsmJsSIMDBuiltin_int16x8_fromInt32x4Bits] = SIMDFunc(PropertyIds::fromInt32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int16x8_fromInt32x4Bits, OpCodeAsmJs::Simd128_FromInt32x4Bits_I8, AsmJsRetType::Int16x8, AsmJsType::Int32x4));
  1409. simdFunctions[AsmJsSIMDBuiltin_int16x8_fromInt8x16Bits] = SIMDFunc(PropertyIds::fromInt8x16Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int16x8_fromInt8x16Bits, OpCodeAsmJs::Simd128_FromInt8x16Bits_I8, AsmJsRetType::Int16x8, AsmJsType::Int8x16));
  1410. simdFunctions[AsmJsSIMDBuiltin_int16x8_fromUint32x4Bits] = SIMDFunc(PropertyIds::fromUint32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int16x8_fromUint32x4Bits, OpCodeAsmJs::Simd128_FromUint32x4Bits_I8, AsmJsRetType::Int16x8, AsmJsType::Uint32x4));
  1411. simdFunctions[AsmJsSIMDBuiltin_int16x8_fromUint16x8Bits] = SIMDFunc(PropertyIds::fromUint16x8Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int16x8_fromUint16x8Bits, OpCodeAsmJs::Simd128_FromUint16x8Bits_I8, AsmJsRetType::Int16x8, AsmJsType::Uint16x8));
  1412. simdFunctions[AsmJsSIMDBuiltin_int16x8_fromUint8x16Bits] = SIMDFunc(PropertyIds::fromUint8x16Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int16x8_fromUint8x16Bits, OpCodeAsmJs::Simd128_FromUint8x16Bits_I8, AsmJsRetType::Int16x8, AsmJsType::Uint8x16));
  1413. /* Int8x16 builtins*/
  1414. //-------------------
  1415. simdFunctions[AsmJsSIMDBuiltin_Int8x16] = SIMDFunc(PropertyIds::Int8x16, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 16, AsmJsSIMDBuiltin_Int8x16, OpCodeAsmJs::Simd128_IntsToI16, AsmJsRetType::Int8x16, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish));
  1416. simdFunctions[AsmJsSIMDBuiltin_int8x16_check] = SIMDFunc(PropertyIds::check, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int8x16_check, OpCodeAsmJs::Simd128_Ld_I16 /*no dynamic checks*/, AsmJsRetType::Int8x16, AsmJsType::Int8x16));
  1417. simdFunctions[AsmJsSIMDBuiltin_int8x16_splat] = SIMDFunc(PropertyIds::splat, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int8x16_splat, OpCodeAsmJs::Simd128_Splat_I16, AsmJsRetType::Int8x16, AsmJsType::Intish));
  1418. simdFunctions[AsmJsSIMDBuiltin_int8x16_neg] = SIMDFunc(PropertyIds::neg, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int8x16_neg, OpCodeAsmJs::Simd128_Neg_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16));
  1419. simdFunctions[AsmJsSIMDBuiltin_int8x16_add] = SIMDFunc(PropertyIds::add, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_add, OpCodeAsmJs::Simd128_Add_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1420. simdFunctions[AsmJsSIMDBuiltin_int8x16_sub] = SIMDFunc(PropertyIds::sub, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_sub, OpCodeAsmJs::Simd128_Sub_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1421. simdFunctions[AsmJsSIMDBuiltin_int8x16_mul] = SIMDFunc(PropertyIds::mul, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_mul, OpCodeAsmJs::Simd128_Mul_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1422. simdFunctions[AsmJsSIMDBuiltin_int8x16_and] = SIMDFunc(PropertyIds::and_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_and, OpCodeAsmJs::Simd128_And_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1423. simdFunctions[AsmJsSIMDBuiltin_int8x16_or] = SIMDFunc(PropertyIds::or_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_or, OpCodeAsmJs::Simd128_Or_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1424. simdFunctions[AsmJsSIMDBuiltin_int8x16_xor] = SIMDFunc(PropertyIds::xor_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_xor, OpCodeAsmJs::Simd128_Xor_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1425. simdFunctions[AsmJsSIMDBuiltin_int8x16_not] = SIMDFunc(PropertyIds::not_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int8x16_not, OpCodeAsmJs::Simd128_Not_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16));
  1426. simdFunctions[AsmJsSIMDBuiltin_int8x16_shiftLeftByScalar] = SIMDFunc(PropertyIds::shiftLeftByScalar, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_shiftLeftByScalar, OpCodeAsmJs::Simd128_ShLtByScalar_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16, AsmJsType::Int));
  1427. simdFunctions[AsmJsSIMDBuiltin_int8x16_shiftRightByScalar] = SIMDFunc(PropertyIds::shiftRightByScalar, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_shiftRightByScalar, OpCodeAsmJs::Simd128_ShRtByScalar_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16, AsmJsType::Int));
  1428. simdFunctions[AsmJsSIMDBuiltin_int8x16_lessThan] = SIMDFunc(PropertyIds::lessThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_lessThan, OpCodeAsmJs::Simd128_Lt_I16, AsmJsRetType::Bool8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1429. simdFunctions[AsmJsSIMDBuiltin_int8x16_lessThanOrEqual] = SIMDFunc(PropertyIds::lessThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_lessThanOrEqual, OpCodeAsmJs::Simd128_LtEq_I16, AsmJsRetType::Bool8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1430. simdFunctions[AsmJsSIMDBuiltin_int8x16_equal] = SIMDFunc(PropertyIds::equal, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_equal, OpCodeAsmJs::Simd128_Eq_I16, AsmJsRetType::Bool8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1431. simdFunctions[AsmJsSIMDBuiltin_int8x16_notEqual] = SIMDFunc(PropertyIds::notEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_notEqual, OpCodeAsmJs::Simd128_Neq_I16, AsmJsRetType::Bool8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1432. simdFunctions[AsmJsSIMDBuiltin_int8x16_greaterThan] = SIMDFunc(PropertyIds::greaterThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_greaterThan, OpCodeAsmJs::Simd128_Gt_I16, AsmJsRetType::Bool8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1433. simdFunctions[AsmJsSIMDBuiltin_int8x16_greaterThanOrEqual] = SIMDFunc(PropertyIds::greaterThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_greaterThanOrEqual, OpCodeAsmJs::Simd128_GtEq_I16, AsmJsRetType::Bool8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1434. simdFunctions[AsmJsSIMDBuiltin_int8x16_select] = SIMDFunc(PropertyIds::select, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_int8x16_select, OpCodeAsmJs::Simd128_Select_I16, AsmJsRetType::Int8x16, AsmJsType::Bool8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1435. simdFunctions[AsmJsSIMDBuiltin_int8x16_addSaturate] = SIMDFunc(PropertyIds::addSaturate, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_addSaturate, OpCodeAsmJs::Simd128_AddSaturate_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1436. simdFunctions[AsmJsSIMDBuiltin_int8x16_subSaturate] = SIMDFunc(PropertyIds::subSaturate, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_subSaturate, OpCodeAsmJs::Simd128_SubSaturate_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16, AsmJsType::Int8x16));
  1437. simdFunctions[AsmJsSIMDBuiltin_int8x16_load] = SIMDFunc(PropertyIds::load, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_load, OpCodeAsmJs::Simd128_LdArr_I16, AsmJsRetType::Int8x16, AsmJsType::Void, AsmJsType::Int));
  1438. simdFunctions[AsmJsSIMDBuiltin_int8x16_store] = SIMDFunc(PropertyIds::store, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_int8x16_store, OpCodeAsmJs::Simd128_StArr_I16, AsmJsRetType::Int8x16, AsmJsType::Void, AsmJsType::Int, AsmJsType::Int8x16));
  1439. simdFunctions[AsmJsSIMDBuiltin_int8x16_extractLane] = SIMDFunc(PropertyIds::extractLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_int8x16_extractLane, OpCodeAsmJs::Simd128_ExtractLane_I16, AsmJsRetType::Signed, AsmJsType::Int8x16, AsmJsType::Int));
  1440. simdFunctions[AsmJsSIMDBuiltin_int8x16_replaceLane] = SIMDFunc(PropertyIds::replaceLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_int8x16_replaceLane, OpCodeAsmJs::Simd128_ReplaceLane_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16, AsmJsType::Int, AsmJsType::Intish));
  1441. simdFunctions[AsmJsSIMDBuiltin_int8x16_swizzle] = SIMDFunc(PropertyIds::swizzle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 17, AsmJsSIMDBuiltin_int8x16_swizzle, OpCodeAsmJs::Simd128_Swizzle_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16,
  1442. AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int,
  1443. AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int));
  1444. simdFunctions[AsmJsSIMDBuiltin_int8x16_shuffle] = SIMDFunc(PropertyIds::shuffle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 18, AsmJsSIMDBuiltin_int8x16_shuffle, OpCodeAsmJs::Simd128_Shuffle_I16, AsmJsRetType::Int8x16, AsmJsType::Int8x16, AsmJsType::Int8x16,
  1445. AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int,
  1446. AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int));
  1447. simdFunctions[AsmJsSIMDBuiltin_int8x16_fromFloat32x4Bits] = SIMDFunc(PropertyIds::fromFloat32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int8x16_fromFloat32x4Bits, OpCodeAsmJs::Simd128_FromFloat32x4Bits_I16, AsmJsRetType::Int8x16, AsmJsType::Float32x4));
  1448. simdFunctions[AsmJsSIMDBuiltin_int8x16_fromInt32x4Bits] = SIMDFunc(PropertyIds::fromInt32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int8x16_fromInt32x4Bits, OpCodeAsmJs::Simd128_FromInt32x4Bits_I16, AsmJsRetType::Int8x16, AsmJsType::Int32x4));
  1449. simdFunctions[AsmJsSIMDBuiltin_int8x16_fromInt16x8Bits] = SIMDFunc(PropertyIds::fromInt16x8Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int8x16_fromInt16x8Bits, OpCodeAsmJs::Simd128_FromInt16x8Bits_I16, AsmJsRetType::Int8x16, AsmJsType::Int16x8));
  1450. simdFunctions[AsmJsSIMDBuiltin_int8x16_fromUint32x4Bits] = SIMDFunc(PropertyIds::fromUint32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int8x16_fromUint32x4Bits, OpCodeAsmJs::Simd128_FromUint32x4Bits_I16, AsmJsRetType::Int8x16, AsmJsType::Uint32x4));
  1451. simdFunctions[AsmJsSIMDBuiltin_int8x16_fromUint16x8Bits] = SIMDFunc(PropertyIds::fromUint16x8Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int8x16_fromUint16x8Bits, OpCodeAsmJs::Simd128_FromUint16x8Bits_I16, AsmJsRetType::Int8x16, AsmJsType::Uint16x8));
  1452. simdFunctions[AsmJsSIMDBuiltin_int8x16_fromUint8x16Bits] = SIMDFunc(PropertyIds::fromUint8x16Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_int8x16_fromUint8x16Bits, OpCodeAsmJs::Simd128_FromUint8x16Bits_I16, AsmJsRetType::Int8x16, AsmJsType::Uint8x16));
  1453. /* Uint32x4 */
  1454. simdFunctions[AsmJsSIMDBuiltin_Uint32x4] = SIMDFunc(PropertyIds::Uint32x4, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 4, AsmJsSIMDBuiltin_Uint32x4, OpCodeAsmJs::Simd128_IntsToU4, AsmJsRetType::Uint32x4, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish));
  1455. simdFunctions[AsmJsSIMDBuiltin_uint32x4_check] = SIMDFunc(PropertyIds::check, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint32x4_check, OpCodeAsmJs::Simd128_Ld_U4 /*no dynamic checks*/, AsmJsRetType::Uint32x4, AsmJsType::Uint32x4));
  1456. simdFunctions[AsmJsSIMDBuiltin_uint32x4_extractLane] = SIMDFunc(PropertyIds::extractLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_extractLane, OpCodeAsmJs::Simd128_ExtractLane_U4, AsmJsRetType::Unsigned, AsmJsType::Uint32x4, AsmJsType::Int));
  1457. simdFunctions[AsmJsSIMDBuiltin_uint32x4_swizzle] = SIMDFunc(PropertyIds::swizzle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 5, AsmJsSIMDBuiltin_uint32x4_swizzle, OpCodeAsmJs::Simd128_Swizzle_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint32x4, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int));
  1458. simdFunctions[AsmJsSIMDBuiltin_uint32x4_shuffle] = SIMDFunc(PropertyIds::shuffle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 6, AsmJsSIMDBuiltin_uint32x4_shuffle, OpCodeAsmJs::Simd128_Shuffle_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint32x4, AsmJsType::Uint32x4, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int));
  1459. simdFunctions[AsmJsSIMDBuiltin_uint32x4_splat] = SIMDFunc(PropertyIds::splat, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint32x4_splat, OpCodeAsmJs::Simd128_Splat_U4, AsmJsRetType::Uint32x4, AsmJsType::Intish));
  1460. simdFunctions[AsmJsSIMDBuiltin_uint32x4_replaceLane] = SIMDFunc(PropertyIds::replaceLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_uint32x4_replaceLane, OpCodeAsmJs::Simd128_ReplaceLane_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint32x4, AsmJsType::Int, AsmJsType::Intish));
  1461. simdFunctions[AsmJsSIMDBuiltin_uint32x4_and] = SIMDFunc(PropertyIds::and_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_and, OpCodeAsmJs::Simd128_And_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint32x4, AsmJsType::Uint32x4));
  1462. simdFunctions[AsmJsSIMDBuiltin_uint32x4_or] = SIMDFunc(PropertyIds::or_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_or, OpCodeAsmJs::Simd128_Or_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint32x4, AsmJsType::Uint32x4));
  1463. simdFunctions[AsmJsSIMDBuiltin_uint32x4_xor] = SIMDFunc(PropertyIds::xor_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_xor, OpCodeAsmJs::Simd128_Xor_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint32x4, AsmJsType::Uint32x4));
  1464. simdFunctions[AsmJsSIMDBuiltin_uint32x4_not] = SIMDFunc(PropertyIds::not_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint32x4_not, OpCodeAsmJs::Simd128_Not_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint32x4));
  1465. simdFunctions[AsmJsSIMDBuiltin_uint32x4_neg] = SIMDFunc(PropertyIds::neg, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint32x4_neg, OpCodeAsmJs::Simd128_Neg_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint32x4));
  1466. simdFunctions[AsmJsSIMDBuiltin_uint32x4_add] = SIMDFunc(PropertyIds::add, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_add, OpCodeAsmJs::Simd128_Add_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint32x4, AsmJsType::Uint32x4));
  1467. simdFunctions[AsmJsSIMDBuiltin_uint32x4_sub] = SIMDFunc(PropertyIds::sub, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_sub, OpCodeAsmJs::Simd128_Sub_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint32x4, AsmJsType::Uint32x4));
  1468. simdFunctions[AsmJsSIMDBuiltin_uint32x4_mul] = SIMDFunc(PropertyIds::mul, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_mul, OpCodeAsmJs::Simd128_Mul_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint32x4, AsmJsType::Uint32x4));
  1469. simdFunctions[AsmJsSIMDBuiltin_uint32x4_shiftLeftByScalar] = SIMDFunc(PropertyIds::shiftLeftByScalar, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_shiftLeftByScalar, OpCodeAsmJs::Simd128_ShLtByScalar_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint32x4, AsmJsType::Int));
  1470. simdFunctions[AsmJsSIMDBuiltin_uint32x4_shiftRightByScalar] = SIMDFunc(PropertyIds::shiftRightByScalar, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_shiftRightByScalar, OpCodeAsmJs::Simd128_ShRtByScalar_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint32x4, AsmJsType::Int));
  1471. simdFunctions[AsmJsSIMDBuiltin_uint32x4_lessThan] = SIMDFunc(PropertyIds::lessThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_lessThan, OpCodeAsmJs::Simd128_Lt_U4, AsmJsRetType::Bool32x4, AsmJsType::Uint32x4, AsmJsType::Uint32x4));
  1472. simdFunctions[AsmJsSIMDBuiltin_uint32x4_lessThanOrEqual] = SIMDFunc(PropertyIds::lessThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_lessThanOrEqual, OpCodeAsmJs::Simd128_LtEq_U4, AsmJsRetType::Bool32x4, AsmJsType::Uint32x4, AsmJsType::Uint32x4));
  1473. simdFunctions[AsmJsSIMDBuiltin_uint32x4_equal] = SIMDFunc(PropertyIds::equal, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_equal, OpCodeAsmJs::Simd128_Eq_U4, AsmJsRetType::Bool32x4, AsmJsType::Uint32x4, AsmJsType::Uint32x4));
  1474. simdFunctions[AsmJsSIMDBuiltin_uint32x4_notEqual] = SIMDFunc(PropertyIds::notEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_notEqual, OpCodeAsmJs::Simd128_Neq_U4, AsmJsRetType::Bool32x4, AsmJsType::Uint32x4, AsmJsType::Uint32x4));
  1475. simdFunctions[AsmJsSIMDBuiltin_uint32x4_greaterThan] = SIMDFunc(PropertyIds::greaterThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_greaterThan, OpCodeAsmJs::Simd128_Gt_U4, AsmJsRetType::Bool32x4, AsmJsType::Uint32x4, AsmJsType::Uint32x4));
  1476. simdFunctions[AsmJsSIMDBuiltin_uint32x4_greaterThanOrEqual] = SIMDFunc(PropertyIds::greaterThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_greaterThanOrEqual, OpCodeAsmJs::Simd128_GtEq_U4, AsmJsRetType::Bool32x4, AsmJsType::Uint32x4, AsmJsType::Uint32x4));
  1477. simdFunctions[AsmJsSIMDBuiltin_uint32x4_select] = SIMDFunc(PropertyIds::select, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_uint32x4_select, OpCodeAsmJs::Simd128_Select_U4, AsmJsRetType::Uint32x4, AsmJsType::Bool32x4, AsmJsType::Uint32x4, AsmJsType::Uint32x4));
  1478. simdFunctions[AsmJsSIMDBuiltin_uint32x4_load] = SIMDFunc(PropertyIds::load, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_load, OpCodeAsmJs::Simd128_LdArr_U4, AsmJsRetType::Uint32x4, AsmJsType::Void, AsmJsType::Int));
  1479. simdFunctions[AsmJsSIMDBuiltin_uint32x4_load1] = SIMDFunc(PropertyIds::load1, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_load1, OpCodeAsmJs::Simd128_LdArr_U4, AsmJsRetType::Uint32x4, AsmJsType::Void, AsmJsType::Int));
  1480. simdFunctions[AsmJsSIMDBuiltin_uint32x4_load2] = SIMDFunc(PropertyIds::load2, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_load2, OpCodeAsmJs::Simd128_LdArr_U4, AsmJsRetType::Uint32x4, AsmJsType::Void, AsmJsType::Int));
  1481. simdFunctions[AsmJsSIMDBuiltin_uint32x4_load3] = SIMDFunc(PropertyIds::load3, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint32x4_load3, OpCodeAsmJs::Simd128_LdArr_U4, AsmJsRetType::Uint32x4, AsmJsType::Void, AsmJsType::Int));
  1482. simdFunctions[AsmJsSIMDBuiltin_uint32x4_store] = SIMDFunc(PropertyIds::store, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_uint32x4_store, OpCodeAsmJs::Simd128_StArr_U4, AsmJsRetType::Uint32x4, AsmJsType::Void, AsmJsType::Int, AsmJsType::Uint32x4));
  1483. simdFunctions[AsmJsSIMDBuiltin_uint32x4_store1] = SIMDFunc(PropertyIds::store1, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_uint32x4_store1, OpCodeAsmJs::Simd128_StArr_U4, AsmJsRetType::Uint32x4, AsmJsType::Void, AsmJsType::Int, AsmJsType::Uint32x4));
  1484. simdFunctions[AsmJsSIMDBuiltin_uint32x4_store2] = SIMDFunc(PropertyIds::store2, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_uint32x4_store2, OpCodeAsmJs::Simd128_StArr_U4, AsmJsRetType::Uint32x4, AsmJsType::Void, AsmJsType::Int, AsmJsType::Uint32x4));
  1485. simdFunctions[AsmJsSIMDBuiltin_uint32x4_store3] = SIMDFunc(PropertyIds::store3, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_uint32x4_store3, OpCodeAsmJs::Simd128_StArr_U4, AsmJsRetType::Uint32x4, AsmJsType::Void, AsmJsType::Int, AsmJsType::Uint32x4));
  1486. simdFunctions[AsmJsSIMDBuiltin_uint32x4_fromFloat32x4] = SIMDFunc(PropertyIds::fromFloat32x4, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint32x4_fromFloat32x4, OpCodeAsmJs::Simd128_FromFloat32x4_U4, AsmJsRetType::Uint32x4, AsmJsType::Float32x4));
  1487. simdFunctions[AsmJsSIMDBuiltin_uint32x4_fromFloat32x4Bits] = SIMDFunc(PropertyIds::fromFloat32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint32x4_fromFloat32x4Bits, OpCodeAsmJs::Simd128_FromFloat32x4Bits_U4, AsmJsRetType::Uint32x4, AsmJsType::Float32x4));
  1488. simdFunctions[AsmJsSIMDBuiltin_uint32x4_fromInt32x4Bits] = SIMDFunc(PropertyIds::fromInt32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint32x4_fromInt32x4Bits, OpCodeAsmJs::Simd128_FromInt32x4Bits_U4, AsmJsRetType::Uint32x4, AsmJsType::Int32x4));
  1489. simdFunctions[AsmJsSIMDBuiltin_uint32x4_fromInt16x8Bits] = SIMDFunc(PropertyIds::fromInt16x8Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint32x4_fromInt16x8Bits, OpCodeAsmJs::Simd128_FromInt16x8Bits_U4, AsmJsRetType::Uint32x4, AsmJsType::Int16x8));
  1490. simdFunctions[AsmJsSIMDBuiltin_uint32x4_fromInt8x16Bits] = SIMDFunc(PropertyIds::fromInt8x16Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint32x4_fromInt8x16Bits, OpCodeAsmJs::Simd128_FromInt8x16Bits_U4, AsmJsRetType::Uint32x4, AsmJsType::Int8x16));
  1491. simdFunctions[AsmJsSIMDBuiltin_uint32x4_fromUint16x8Bits] = SIMDFunc(PropertyIds::fromUint16x8Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint32x4_fromUint16x8Bits, OpCodeAsmJs::Simd128_FromUint16x8Bits_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint16x8));
  1492. simdFunctions[AsmJsSIMDBuiltin_uint32x4_fromUint8x16Bits] = SIMDFunc(PropertyIds::fromUint8x16Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint32x4_fromUint8x16Bits, OpCodeAsmJs::Simd128_FromUint8x16Bits_U4, AsmJsRetType::Uint32x4, AsmJsType::Uint8x16));
  1493. /* Uint16x8 */
  1494. simdFunctions[AsmJsSIMDBuiltin_Uint16x8] = SIMDFunc(PropertyIds::Uint16x8, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 8, AsmJsSIMDBuiltin_Uint16x8, OpCodeAsmJs::Simd128_IntsToU8, AsmJsRetType::Uint16x8,
  1495. AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish));
  1496. simdFunctions[AsmJsSIMDBuiltin_uint16x8_check] = SIMDFunc(PropertyIds::check, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint16x8_check, OpCodeAsmJs::Simd128_Ld_U8 /*no dynamic checks*/, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8));
  1497. simdFunctions[AsmJsSIMDBuiltin_uint16x8_extractLane] = SIMDFunc(PropertyIds::extractLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_extractLane, OpCodeAsmJs::Simd128_ExtractLane_U8, AsmJsRetType::Unsigned, AsmJsType::Uint16x8, AsmJsType::Int));
  1498. simdFunctions[AsmJsSIMDBuiltin_uint16x8_swizzle] = SIMDFunc(PropertyIds::swizzle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 9, AsmJsSIMDBuiltin_uint16x8_swizzle, OpCodeAsmJs::Simd128_Swizzle_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8,
  1499. AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int));
  1500. simdFunctions[AsmJsSIMDBuiltin_uint16x8_shuffle] = SIMDFunc(PropertyIds::shuffle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 10, AsmJsSIMDBuiltin_uint16x8_shuffle, OpCodeAsmJs::Simd128_Shuffle_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8,
  1501. AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int));
  1502. simdFunctions[AsmJsSIMDBuiltin_uint16x8_splat] = SIMDFunc(PropertyIds::splat, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint16x8_splat, OpCodeAsmJs::Simd128_Splat_U8, AsmJsRetType::Uint16x8, AsmJsType::Intish));
  1503. simdFunctions[AsmJsSIMDBuiltin_uint16x8_replaceLane] = SIMDFunc(PropertyIds::replaceLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_uint16x8_replaceLane, OpCodeAsmJs::Simd128_ReplaceLane_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8, AsmJsType::Int, AsmJsType::Intish));
  1504. simdFunctions[AsmJsSIMDBuiltin_uint16x8_and] = SIMDFunc(PropertyIds::and_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_and, OpCodeAsmJs::Simd128_And_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1505. simdFunctions[AsmJsSIMDBuiltin_uint16x8_or] = SIMDFunc(PropertyIds::or_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_or, OpCodeAsmJs::Simd128_Or_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1506. simdFunctions[AsmJsSIMDBuiltin_uint16x8_xor] = SIMDFunc(PropertyIds::xor_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_xor, OpCodeAsmJs::Simd128_Xor_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1507. simdFunctions[AsmJsSIMDBuiltin_uint16x8_not] = SIMDFunc(PropertyIds::not_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint16x8_not, OpCodeAsmJs::Simd128_Not_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8));
  1508. simdFunctions[AsmJsSIMDBuiltin_uint16x8_neg] = SIMDFunc(PropertyIds::neg, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint16x8_neg, OpCodeAsmJs::Simd128_Neg_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8));
  1509. simdFunctions[AsmJsSIMDBuiltin_uint16x8_add] = SIMDFunc(PropertyIds::add, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_add, OpCodeAsmJs::Simd128_Add_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1510. simdFunctions[AsmJsSIMDBuiltin_uint16x8_sub] = SIMDFunc(PropertyIds::sub, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_sub, OpCodeAsmJs::Simd128_Sub_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1511. simdFunctions[AsmJsSIMDBuiltin_uint16x8_mul] = SIMDFunc(PropertyIds::mul, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_mul, OpCodeAsmJs::Simd128_Mul_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1512. simdFunctions[AsmJsSIMDBuiltin_uint16x8_shiftLeftByScalar] = SIMDFunc(PropertyIds::shiftLeftByScalar, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_shiftLeftByScalar, OpCodeAsmJs::Simd128_ShLtByScalar_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8, AsmJsType::Int));
  1513. simdFunctions[AsmJsSIMDBuiltin_uint16x8_shiftRightByScalar] = SIMDFunc(PropertyIds::shiftRightByScalar, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_shiftRightByScalar, OpCodeAsmJs::Simd128_ShRtByScalar_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8, AsmJsType::Int));
  1514. simdFunctions[AsmJsSIMDBuiltin_uint16x8_lessThan] = SIMDFunc(PropertyIds::lessThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_lessThan, OpCodeAsmJs::Simd128_Lt_U8, AsmJsRetType::Bool16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1515. simdFunctions[AsmJsSIMDBuiltin_uint16x8_lessThanOrEqual] = SIMDFunc(PropertyIds::lessThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_lessThanOrEqual, OpCodeAsmJs::Simd128_LtEq_U8, AsmJsRetType::Bool16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1516. simdFunctions[AsmJsSIMDBuiltin_uint16x8_equal] = SIMDFunc(PropertyIds::equal, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_equal, OpCodeAsmJs::Simd128_Eq_U8, AsmJsRetType::Bool16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1517. simdFunctions[AsmJsSIMDBuiltin_uint16x8_notEqual] = SIMDFunc(PropertyIds::notEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_notEqual, OpCodeAsmJs::Simd128_Neq_U8, AsmJsRetType::Bool16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1518. simdFunctions[AsmJsSIMDBuiltin_uint16x8_greaterThan] = SIMDFunc(PropertyIds::greaterThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_greaterThan, OpCodeAsmJs::Simd128_Gt_U8, AsmJsRetType::Bool16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1519. simdFunctions[AsmJsSIMDBuiltin_uint16x8_greaterThanOrEqual] = SIMDFunc(PropertyIds::greaterThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_greaterThanOrEqual, OpCodeAsmJs::Simd128_GtEq_U8, AsmJsRetType::Bool16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1520. simdFunctions[AsmJsSIMDBuiltin_uint16x8_select] = SIMDFunc(PropertyIds::select, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_uint16x8_select, OpCodeAsmJs::Simd128_Select_U8, AsmJsRetType::Uint16x8, AsmJsType::Bool16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1521. simdFunctions[AsmJsSIMDBuiltin_uint16x8_addSaturate] = SIMDFunc(PropertyIds::addSaturate, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_addSaturate, OpCodeAsmJs::Simd128_AddSaturate_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1522. simdFunctions[AsmJsSIMDBuiltin_uint16x8_subSaturate] = SIMDFunc(PropertyIds::subSaturate, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_subSaturate, OpCodeAsmJs::Simd128_SubSaturate_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint16x8, AsmJsType::Uint16x8));
  1523. simdFunctions[AsmJsSIMDBuiltin_uint16x8_load] = SIMDFunc(PropertyIds::load, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint16x8_load, OpCodeAsmJs::Simd128_LdArr_U8, AsmJsRetType::Uint16x8, AsmJsType::Void, AsmJsType::Int));
  1524. simdFunctions[AsmJsSIMDBuiltin_uint16x8_store] = SIMDFunc(PropertyIds::store, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_uint16x8_store, OpCodeAsmJs::Simd128_StArr_U8, AsmJsRetType::Uint16x8, AsmJsType::Void, AsmJsType::Int, AsmJsType::Uint16x8));
  1525. simdFunctions[AsmJsSIMDBuiltin_uint16x8_fromFloat32x4Bits] = SIMDFunc(PropertyIds::fromFloat32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint16x8_fromFloat32x4Bits, OpCodeAsmJs::Simd128_FromFloat32x4Bits_U8, AsmJsRetType::Uint16x8, AsmJsType::Float32x4));
  1526. simdFunctions[AsmJsSIMDBuiltin_uint16x8_fromInt32x4Bits] = SIMDFunc(PropertyIds::fromInt32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint16x8_fromInt32x4Bits, OpCodeAsmJs::Simd128_FromInt32x4Bits_U8, AsmJsRetType::Uint16x8, AsmJsType::Int32x4));
  1527. simdFunctions[AsmJsSIMDBuiltin_uint16x8_fromInt16x8Bits] = SIMDFunc(PropertyIds::fromInt16x8Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint16x8_fromInt16x8Bits, OpCodeAsmJs::Simd128_FromInt16x8Bits_U8, AsmJsRetType::Uint16x8, AsmJsType::Int16x8));
  1528. simdFunctions[AsmJsSIMDBuiltin_uint16x8_fromInt8x16Bits] = SIMDFunc(PropertyIds::fromInt8x16Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint16x8_fromInt8x16Bits, OpCodeAsmJs::Simd128_FromInt8x16Bits_U8, AsmJsRetType::Uint16x8, AsmJsType::Int8x16));
  1529. simdFunctions[AsmJsSIMDBuiltin_uint16x8_fromUint32x4Bits] = SIMDFunc(PropertyIds::fromUint32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint16x8_fromUint32x4Bits, OpCodeAsmJs::Simd128_FromUint32x4Bits_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint32x4));
  1530. simdFunctions[AsmJsSIMDBuiltin_uint16x8_fromUint8x16Bits] = SIMDFunc(PropertyIds::fromUint8x16Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint16x8_fromUint8x16Bits, OpCodeAsmJs::Simd128_FromUint8x16Bits_U8, AsmJsRetType::Uint16x8, AsmJsType::Uint8x16));
  1531. /* Uint8x16 */
  1532. simdFunctions[AsmJsSIMDBuiltin_Uint8x16] = SIMDFunc(PropertyIds::Uint8x16, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 16, AsmJsSIMDBuiltin_Uint8x16, OpCodeAsmJs::Simd128_IntsToU16, AsmJsRetType::Uint8x16,
  1533. AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish,
  1534. AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish));
  1535. simdFunctions[AsmJsSIMDBuiltin_uint8x16_check] = SIMDFunc(PropertyIds::check, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint8x16_check, OpCodeAsmJs::Simd128_Ld_U16 /*no dynamic checks*/, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16));
  1536. simdFunctions[AsmJsSIMDBuiltin_uint8x16_extractLane] = SIMDFunc(PropertyIds::extractLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_extractLane, OpCodeAsmJs::Simd128_ExtractLane_U16, AsmJsRetType::Unsigned, AsmJsType::Uint8x16, AsmJsType::Int));
  1537. simdFunctions[AsmJsSIMDBuiltin_uint8x16_swizzle] = SIMDFunc(PropertyIds::swizzle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 17, AsmJsSIMDBuiltin_uint8x16_swizzle, OpCodeAsmJs::Simd128_Swizzle_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16,
  1538. AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int,
  1539. AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int));
  1540. simdFunctions[AsmJsSIMDBuiltin_uint8x16_shuffle] = SIMDFunc(PropertyIds::shuffle, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 18, AsmJsSIMDBuiltin_uint8x16_shuffle, OpCodeAsmJs::Simd128_Shuffle_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16,
  1541. AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int,
  1542. AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int, AsmJsType::Int));
  1543. simdFunctions[AsmJsSIMDBuiltin_uint8x16_splat] = SIMDFunc(PropertyIds::splat, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint8x16_splat, OpCodeAsmJs::Simd128_Splat_U16, AsmJsRetType::Uint8x16, AsmJsType::Intish));
  1544. simdFunctions[AsmJsSIMDBuiltin_uint8x16_replaceLane] = SIMDFunc(PropertyIds::replaceLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_uint8x16_replaceLane, OpCodeAsmJs::Simd128_ReplaceLane_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16, AsmJsType::Int, AsmJsType::Intish));
  1545. simdFunctions[AsmJsSIMDBuiltin_uint8x16_and] = SIMDFunc(PropertyIds::and_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_and, OpCodeAsmJs::Simd128_And_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1546. simdFunctions[AsmJsSIMDBuiltin_uint8x16_or] = SIMDFunc(PropertyIds::or_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_or, OpCodeAsmJs::Simd128_Or_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1547. simdFunctions[AsmJsSIMDBuiltin_uint8x16_xor] = SIMDFunc(PropertyIds::xor_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_xor, OpCodeAsmJs::Simd128_Xor_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1548. simdFunctions[AsmJsSIMDBuiltin_uint8x16_not] = SIMDFunc(PropertyIds::not_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint8x16_not, OpCodeAsmJs::Simd128_Not_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16));
  1549. simdFunctions[AsmJsSIMDBuiltin_uint8x16_neg] = SIMDFunc(PropertyIds::neg, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint8x16_neg, OpCodeAsmJs::Simd128_Neg_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16));
  1550. simdFunctions[AsmJsSIMDBuiltin_uint8x16_add] = SIMDFunc(PropertyIds::add, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_add, OpCodeAsmJs::Simd128_Add_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1551. simdFunctions[AsmJsSIMDBuiltin_uint8x16_sub] = SIMDFunc(PropertyIds::sub, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_sub, OpCodeAsmJs::Simd128_Sub_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1552. simdFunctions[AsmJsSIMDBuiltin_uint8x16_mul] = SIMDFunc(PropertyIds::mul, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_mul, OpCodeAsmJs::Simd128_Mul_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1553. simdFunctions[AsmJsSIMDBuiltin_uint8x16_shiftLeftByScalar] = SIMDFunc(PropertyIds::shiftLeftByScalar, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_shiftLeftByScalar, OpCodeAsmJs::Simd128_ShLtByScalar_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16, AsmJsType::Int));
  1554. simdFunctions[AsmJsSIMDBuiltin_uint8x16_shiftRightByScalar] = SIMDFunc(PropertyIds::shiftRightByScalar, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_shiftRightByScalar, OpCodeAsmJs::Simd128_ShRtByScalar_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16, AsmJsType::Int));
  1555. simdFunctions[AsmJsSIMDBuiltin_uint8x16_lessThan] = SIMDFunc(PropertyIds::lessThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_lessThan, OpCodeAsmJs::Simd128_Lt_U16, AsmJsRetType::Bool8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1556. simdFunctions[AsmJsSIMDBuiltin_uint8x16_lessThanOrEqual] = SIMDFunc(PropertyIds::lessThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_lessThanOrEqual, OpCodeAsmJs::Simd128_LtEq_U16, AsmJsRetType::Bool8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1557. simdFunctions[AsmJsSIMDBuiltin_uint8x16_equal] = SIMDFunc(PropertyIds::equal, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_equal, OpCodeAsmJs::Simd128_Eq_U16, AsmJsRetType::Bool8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1558. simdFunctions[AsmJsSIMDBuiltin_uint8x16_notEqual] = SIMDFunc(PropertyIds::notEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_notEqual, OpCodeAsmJs::Simd128_Neq_U16, AsmJsRetType::Bool8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1559. simdFunctions[AsmJsSIMDBuiltin_uint8x16_greaterThan] = SIMDFunc(PropertyIds::greaterThan, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_greaterThan, OpCodeAsmJs::Simd128_Gt_U16, AsmJsRetType::Bool8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1560. simdFunctions[AsmJsSIMDBuiltin_uint8x16_greaterThanOrEqual] = SIMDFunc(PropertyIds::greaterThanOrEqual, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_greaterThanOrEqual, OpCodeAsmJs::Simd128_GtEq_U16, AsmJsRetType::Bool8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1561. simdFunctions[AsmJsSIMDBuiltin_uint8x16_select] = SIMDFunc(PropertyIds::select, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_uint8x16_select, OpCodeAsmJs::Simd128_Select_U16, AsmJsRetType::Uint8x16, AsmJsType::Bool8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1562. simdFunctions[AsmJsSIMDBuiltin_uint8x16_addSaturate] = SIMDFunc(PropertyIds::addSaturate, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_addSaturate, OpCodeAsmJs::Simd128_AddSaturate_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1563. simdFunctions[AsmJsSIMDBuiltin_uint8x16_subSaturate] = SIMDFunc(PropertyIds::subSaturate, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_subSaturate, OpCodeAsmJs::Simd128_SubSaturate_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint8x16, AsmJsType::Uint8x16));
  1564. simdFunctions[AsmJsSIMDBuiltin_uint8x16_load] = SIMDFunc(PropertyIds::load, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_uint8x16_load, OpCodeAsmJs::Simd128_LdArr_U16, AsmJsRetType::Uint8x16, AsmJsType::Void, AsmJsType::Int));
  1565. simdFunctions[AsmJsSIMDBuiltin_uint8x16_store] = SIMDFunc(PropertyIds::store, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_uint8x16_store, OpCodeAsmJs::Simd128_StArr_U16, AsmJsRetType::Uint8x16, AsmJsType::Void, AsmJsType::Int, AsmJsType::Uint8x16));
  1566. simdFunctions[AsmJsSIMDBuiltin_uint8x16_fromFloat32x4Bits] = SIMDFunc(PropertyIds::fromFloat32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint8x16_fromFloat32x4Bits, OpCodeAsmJs::Simd128_FromFloat32x4Bits_U16, AsmJsRetType::Uint8x16, AsmJsType::Float32x4));
  1567. simdFunctions[AsmJsSIMDBuiltin_uint8x16_fromInt32x4Bits] = SIMDFunc(PropertyIds::fromInt32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint8x16_fromInt32x4Bits, OpCodeAsmJs::Simd128_FromInt32x4Bits_U16, AsmJsRetType::Uint8x16, AsmJsType::Int32x4));
  1568. simdFunctions[AsmJsSIMDBuiltin_uint8x16_fromInt16x8Bits] = SIMDFunc(PropertyIds::fromInt16x8Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint8x16_fromInt16x8Bits, OpCodeAsmJs::Simd128_FromInt16x8Bits_U16, AsmJsRetType::Uint8x16, AsmJsType::Int16x8));
  1569. simdFunctions[AsmJsSIMDBuiltin_uint8x16_fromInt8x16Bits] = SIMDFunc(PropertyIds::fromInt8x16Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint8x16_fromInt8x16Bits, OpCodeAsmJs::Simd128_FromInt8x16Bits_U16, AsmJsRetType::Uint8x16, AsmJsType::Int8x16));
  1570. simdFunctions[AsmJsSIMDBuiltin_uint8x16_fromUint32x4Bits] = SIMDFunc(PropertyIds::fromUint32x4Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint8x16_fromUint32x4Bits, OpCodeAsmJs::Simd128_FromUint32x4Bits_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint32x4));
  1571. simdFunctions[AsmJsSIMDBuiltin_uint8x16_fromUint16x8Bits] = SIMDFunc(PropertyIds::fromUint16x8Bits, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_uint8x16_fromUint16x8Bits, OpCodeAsmJs::Simd128_FromUint16x8Bits_U16, AsmJsRetType::Uint8x16, AsmJsType::Uint16x8));
  1572. /* Bool32x4 builtins*/
  1573. //-------------------
  1574. simdFunctions[AsmJsSIMDBuiltin_Bool32x4] = SIMDFunc(PropertyIds::Bool32x4, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 4, AsmJsSIMDBuiltin_Bool32x4, OpCodeAsmJs::Simd128_IntsToB4, AsmJsRetType::Bool32x4, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish));
  1575. simdFunctions[AsmJsSIMDBuiltin_bool32x4_check] = SIMDFunc(PropertyIds::check, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool32x4_check, OpCodeAsmJs::Simd128_Ld_B4 /*no dynamic checks*/, AsmJsRetType::Bool32x4, AsmJsType::Bool32x4));
  1576. simdFunctions[AsmJsSIMDBuiltin_bool32x4_splat] = SIMDFunc(PropertyIds::splat, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool32x4_splat, OpCodeAsmJs::Simd128_Splat_B4, AsmJsRetType::Bool32x4, AsmJsType::Intish));
  1577. simdFunctions[AsmJsSIMDBuiltin_bool32x4_extractLane] = SIMDFunc(PropertyIds::extractLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_bool32x4_extractLane, OpCodeAsmJs::Simd128_ExtractLane_B4, AsmJsRetType::Signed, AsmJsType::Bool32x4, AsmJsType::Int));
  1578. simdFunctions[AsmJsSIMDBuiltin_bool32x4_replaceLane] = SIMDFunc(PropertyIds::replaceLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_bool32x4_replaceLane, OpCodeAsmJs::Simd128_ReplaceLane_B4, AsmJsRetType::Bool32x4, AsmJsType::Bool32x4, AsmJsType::Int, AsmJsType::Intish));
  1579. simdFunctions[AsmJsSIMDBuiltin_bool32x4_and] = SIMDFunc(PropertyIds::and_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_bool32x4_and, OpCodeAsmJs::Simd128_And_B4, AsmJsRetType::Bool32x4, AsmJsType::Bool32x4, AsmJsType::Bool32x4));
  1580. simdFunctions[AsmJsSIMDBuiltin_bool32x4_or] = SIMDFunc(PropertyIds::or_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_bool32x4_or, OpCodeAsmJs::Simd128_Or_B4, AsmJsRetType::Bool32x4, AsmJsType::Bool32x4, AsmJsType::Bool32x4));
  1581. simdFunctions[AsmJsSIMDBuiltin_bool32x4_xor] = SIMDFunc(PropertyIds::xor_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_bool32x4_xor, OpCodeAsmJs::Simd128_Xor_B4, AsmJsRetType::Bool32x4, AsmJsType::Bool32x4, AsmJsType::Bool32x4));
  1582. simdFunctions[AsmJsSIMDBuiltin_bool32x4_not] = SIMDFunc(PropertyIds::not_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool32x4_not, OpCodeAsmJs::Simd128_Not_B4, AsmJsRetType::Bool32x4, AsmJsType::Bool32x4));
  1583. simdFunctions[AsmJsSIMDBuiltin_bool32x4_anyTrue] = SIMDFunc(PropertyIds::anyTrue, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool32x4_anyTrue, OpCodeAsmJs::Simd128_AnyTrue_B4, AsmJsRetType::Signed, AsmJsType::Bool32x4));
  1584. simdFunctions[AsmJsSIMDBuiltin_bool32x4_allTrue] = SIMDFunc(PropertyIds::allTrue, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool32x4_allTrue, OpCodeAsmJs::Simd128_AllTrue_B4, AsmJsRetType::Signed, AsmJsType::Bool32x4));
  1585. /* Bool16x8 builtins*/
  1586. //-------------------
  1587. simdFunctions[AsmJsSIMDBuiltin_Bool16x8] = SIMDFunc(PropertyIds::Bool16x8, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 8, AsmJsSIMDBuiltin_Bool16x8, OpCodeAsmJs::Simd128_IntsToB8, AsmJsRetType::Bool16x8, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish));
  1588. simdFunctions[AsmJsSIMDBuiltin_bool16x8_check] = SIMDFunc(PropertyIds::check, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool16x8_check, OpCodeAsmJs::Simd128_Ld_B8 /*no dynamic checks*/, AsmJsRetType::Bool16x8, AsmJsType::Bool16x8));
  1589. simdFunctions[AsmJsSIMDBuiltin_bool16x8_splat] = SIMDFunc(PropertyIds::splat, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool16x8_splat, OpCodeAsmJs::Simd128_Splat_B8, AsmJsRetType::Bool16x8, AsmJsType::Intish));
  1590. simdFunctions[AsmJsSIMDBuiltin_bool16x8_extractLane] = SIMDFunc(PropertyIds::extractLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_bool16x8_extractLane, OpCodeAsmJs::Simd128_ExtractLane_B8, AsmJsRetType::Signed, AsmJsType::Bool16x8, AsmJsType::Int));
  1591. simdFunctions[AsmJsSIMDBuiltin_bool16x8_replaceLane] = SIMDFunc(PropertyIds::replaceLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_bool16x8_replaceLane, OpCodeAsmJs::Simd128_ReplaceLane_B8, AsmJsRetType::Bool16x8, AsmJsType::Bool16x8, AsmJsType::Int, AsmJsType::Intish));
  1592. simdFunctions[AsmJsSIMDBuiltin_bool16x8_and] = SIMDFunc(PropertyIds::and_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_bool16x8_and, OpCodeAsmJs::Simd128_And_B8, AsmJsRetType::Bool16x8, AsmJsType::Bool16x8, AsmJsType::Bool16x8));
  1593. simdFunctions[AsmJsSIMDBuiltin_bool16x8_or] = SIMDFunc(PropertyIds::or_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_bool16x8_or, OpCodeAsmJs::Simd128_Or_B8, AsmJsRetType::Bool16x8, AsmJsType::Bool16x8, AsmJsType::Bool16x8));
  1594. simdFunctions[AsmJsSIMDBuiltin_bool16x8_xor] = SIMDFunc(PropertyIds::xor_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_bool16x8_xor, OpCodeAsmJs::Simd128_Xor_B8, AsmJsRetType::Bool16x8, AsmJsType::Bool16x8, AsmJsType::Bool16x8));
  1595. simdFunctions[AsmJsSIMDBuiltin_bool16x8_not] = SIMDFunc(PropertyIds::not_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool16x8_not, OpCodeAsmJs::Simd128_Not_B8, AsmJsRetType::Bool16x8, AsmJsType::Bool16x8));
  1596. simdFunctions[AsmJsSIMDBuiltin_bool16x8_anyTrue] = SIMDFunc(PropertyIds::anyTrue, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool16x8_anyTrue, OpCodeAsmJs::Simd128_AnyTrue_B8, AsmJsRetType::Signed, AsmJsType::Bool16x8));
  1597. simdFunctions[AsmJsSIMDBuiltin_bool16x8_allTrue] = SIMDFunc(PropertyIds::allTrue, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool16x8_allTrue, OpCodeAsmJs::Simd128_AllTrue_B8, AsmJsRetType::Signed, AsmJsType::Bool16x8));
  1598. /* Bool8x16 builtins*/
  1599. //-------------------
  1600. simdFunctions[AsmJsSIMDBuiltin_Bool8x16] = SIMDFunc(PropertyIds::Bool8x16, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 16, AsmJsSIMDBuiltin_Bool8x16, OpCodeAsmJs::Simd128_IntsToB16, AsmJsRetType::Bool8x16, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish, AsmJsType::Intish));
  1601. simdFunctions[AsmJsSIMDBuiltin_bool8x16_check] = SIMDFunc(PropertyIds::check, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool8x16_check, OpCodeAsmJs::Simd128_Ld_B16 /*no dynamic checks*/, AsmJsRetType::Bool8x16, AsmJsType::Bool8x16));
  1602. simdFunctions[AsmJsSIMDBuiltin_bool8x16_splat] = SIMDFunc(PropertyIds::splat, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool8x16_splat, OpCodeAsmJs::Simd128_Splat_B16, AsmJsRetType::Bool8x16, AsmJsType::Intish));
  1603. simdFunctions[AsmJsSIMDBuiltin_bool8x16_extractLane] = SIMDFunc(PropertyIds::extractLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_bool8x16_extractLane, OpCodeAsmJs::Simd128_ExtractLane_B16, AsmJsRetType::Signed, AsmJsType::Bool8x16, AsmJsType::Int));
  1604. simdFunctions[AsmJsSIMDBuiltin_bool8x16_replaceLane] = SIMDFunc(PropertyIds::replaceLane, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 3, AsmJsSIMDBuiltin_bool8x16_replaceLane, OpCodeAsmJs::Simd128_ReplaceLane_B16, AsmJsRetType::Bool8x16, AsmJsType::Bool8x16, AsmJsType::Int, AsmJsType::Intish));
  1605. simdFunctions[AsmJsSIMDBuiltin_bool8x16_and] = SIMDFunc(PropertyIds::and_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_bool8x16_and, OpCodeAsmJs::Simd128_And_B16, AsmJsRetType::Bool8x16, AsmJsType::Bool8x16, AsmJsType::Bool8x16));
  1606. simdFunctions[AsmJsSIMDBuiltin_bool8x16_or] = SIMDFunc(PropertyIds::or_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_bool8x16_or, OpCodeAsmJs::Simd128_Or_B16, AsmJsRetType::Bool8x16, AsmJsType::Bool8x16, AsmJsType::Bool8x16));
  1607. simdFunctions[AsmJsSIMDBuiltin_bool8x16_xor] = SIMDFunc(PropertyIds::xor_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 2, AsmJsSIMDBuiltin_bool8x16_xor, OpCodeAsmJs::Simd128_Xor_B16, AsmJsRetType::Bool8x16, AsmJsType::Bool8x16, AsmJsType::Bool8x16));
  1608. simdFunctions[AsmJsSIMDBuiltin_bool8x16_not] = SIMDFunc(PropertyIds::not_, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool8x16_not, OpCodeAsmJs::Simd128_Not_B16, AsmJsRetType::Bool8x16, AsmJsType::Bool8x16));
  1609. simdFunctions[AsmJsSIMDBuiltin_bool8x16_anyTrue] = SIMDFunc(PropertyIds::anyTrue, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool8x16_anyTrue, OpCodeAsmJs::Simd128_AnyTrue_B16, AsmJsRetType::Signed, AsmJsType::Bool8x16));
  1610. simdFunctions[AsmJsSIMDBuiltin_bool8x16_allTrue] = SIMDFunc(PropertyIds::allTrue, Anew(&mAllocator, AsmJsSIMDFunction, nullptr, &mAllocator, 1, AsmJsSIMDBuiltin_bool8x16_allTrue, OpCodeAsmJs::Simd128_AllTrue_B16, AsmJsRetType::Signed, AsmJsType::Bool8x16));
  1611. {
  1612. SIMDNameMap *map = &mStdLibSIMDInt32x4Map;
  1613. for (int i = 0; i < AsmJsSIMDBuiltin_COUNT; i++)
  1614. {
  1615. switch (i)
  1616. {
  1617. case AsmJsSIMDBuiltin_Float32x4:
  1618. map = &mStdLibSIMDFloat32x4Map;
  1619. break;
  1620. case AsmJsSIMDBuiltin_Float64x2:
  1621. map = &mStdLibSIMDFloat64x2Map;
  1622. break;
  1623. case AsmJsSIMDBuiltin_Int16x8:
  1624. map = &mStdLibSIMDInt16x8Map;
  1625. break;
  1626. case AsmJsSIMDBuiltin_Int8x16:
  1627. map = &mStdLibSIMDInt8x16Map;
  1628. break;
  1629. case AsmJsSIMDBuiltin_Uint32x4:
  1630. map = &mStdLibSIMDUint32x4Map;
  1631. break;
  1632. case AsmJsSIMDBuiltin_Uint16x8:
  1633. map = &mStdLibSIMDUint16x8Map;
  1634. break;
  1635. case AsmJsSIMDBuiltin_Uint8x16:
  1636. map = &mStdLibSIMDUint8x16Map;
  1637. break;
  1638. case AsmJsSIMDBuiltin_Bool32x4:
  1639. map = &mStdLibSIMDBool32x4Map;
  1640. break;
  1641. case AsmJsSIMDBuiltin_Bool16x8:
  1642. map = &mStdLibSIMDBool16x8Map;
  1643. break;
  1644. case AsmJsSIMDBuiltin_Bool8x16:
  1645. map = &mStdLibSIMDBool8x16Map;
  1646. break;
  1647. }
  1648. if (simdFunctions[i].id && simdFunctions[i].val)
  1649. {
  1650. if (!AddStandardLibrarySIMDNameInMap(simdFunctions[i].id, simdFunctions[i].val, map))
  1651. {
  1652. AsmJSCompiler::OutputError(GetScriptContext(), _u("Cannot initialize SIMD library"));
  1653. return false;
  1654. }
  1655. }
  1656. }
  1657. }
  1658. return true;
  1659. }
  1660. AsmJsModuleCompiler::AsmJsModuleCompiler(ExclusiveContext *cx, AsmJSParser &parser) :
  1661. mCx(cx)
  1662. , mCurrentParserNode(parser)
  1663. , mAllocator(_u("Asmjs"), cx->scriptContext->GetThreadContext()->GetPageAllocator(), Throw::OutOfMemory)
  1664. , mModuleFunctionName(nullptr)
  1665. , mStandardLibraryMathNames(&mAllocator)
  1666. , mStandardLibraryArrayNames(&mAllocator)
  1667. , mFunctionArray(&mAllocator)
  1668. , mModuleEnvironment(&mAllocator)
  1669. , mFunctionTableArray(&mAllocator)
  1670. , mInitialised(false)
  1671. , mIntVarSpace()
  1672. , mDoubleVarSpace()
  1673. , mExports(&mAllocator)
  1674. , mExportFuncIndex(Js::Constants::NoRegister)
  1675. , mVarImportCount(0)
  1676. , mVarCount(0)
  1677. , mFuncPtrTableCount(0)
  1678. , mCompileTime()
  1679. , mCompileTimeLastTick(GetTick())
  1680. , mMaxAstSize(0)
  1681. , mArrayViews(&mAllocator)
  1682. , mUsesHeapBuffer(false)
  1683. , mMaxHeapAccess(0)
  1684. #if DBG
  1685. , mStdLibArgNameInit(false)
  1686. , mForeignArgNameInit(false)
  1687. , mBufferArgNameInit(false)
  1688. #endif
  1689. , mStdLibSIMDInt32x4Map(&mAllocator)
  1690. , mStdLibSIMDInt16x8Map(&mAllocator)
  1691. , mStdLibSIMDInt8x16Map(&mAllocator)
  1692. , mStdLibSIMDUint32x4Map(&mAllocator)
  1693. , mStdLibSIMDUint16x8Map(&mAllocator)
  1694. , mStdLibSIMDUint8x16Map(&mAllocator)
  1695. , mStdLibSIMDBool32x4Map(&mAllocator)
  1696. , mStdLibSIMDBool16x8Map(&mAllocator)
  1697. , mStdLibSIMDBool8x16Map(&mAllocator)
  1698. , mStdLibSIMDFloat32x4Map(&mAllocator)
  1699. , mStdLibSIMDFloat64x2Map(&mAllocator)
  1700. {
  1701. InitModuleNode(parser);
  1702. }
  1703. bool AsmJsModuleCompiler::AddStandardLibraryMathName(PropertyId id, const double* cstAddr, AsmJSMathBuiltinFunction mathLibFunctionName)
  1704. {
  1705. // make sure this name is unique
  1706. if (mStandardLibraryMathNames.ContainsKey(id))
  1707. {
  1708. return false;
  1709. }
  1710. MathBuiltin mathBuiltin(mathLibFunctionName, cstAddr);
  1711. int addResult = mStandardLibraryMathNames.AddNew(id, mathBuiltin);
  1712. if (addResult == -1)
  1713. {
  1714. // Error adding the function
  1715. return false;
  1716. }
  1717. return true;
  1718. }
  1719. bool AsmJsModuleCompiler::AddStandardLibraryMathName(PropertyId id, AsmJsMathFunction* func, AsmJSMathBuiltinFunction mathLibFunctionName)
  1720. {
  1721. // make sure this name is unique
  1722. if (mStandardLibraryMathNames.ContainsKey(id))
  1723. {
  1724. return false;
  1725. }
  1726. MathBuiltin mathBuiltin(mathLibFunctionName, func);
  1727. int addResult = mStandardLibraryMathNames.AddNew(id, mathBuiltin);
  1728. if (addResult == -1)
  1729. {
  1730. // Error adding the function
  1731. return false;
  1732. }
  1733. return true;
  1734. }
  1735. bool AsmJsModuleCompiler::AddStandardLibraryArrayName(PropertyId id, AsmJsTypedArrayFunction* func, AsmJSTypedArrayBuiltinFunction arrayLibFunctionName)
  1736. {
  1737. // make sure this name is unique
  1738. if (mStandardLibraryArrayNames.ContainsKey(id))
  1739. {
  1740. return false;
  1741. }
  1742. TypedArrayBuiltin arrayBuiltin(arrayLibFunctionName, func);
  1743. int addResult = mStandardLibraryArrayNames.AddNew(id, arrayBuiltin);
  1744. if (addResult == -1)
  1745. {
  1746. // Error adding the function
  1747. return false;
  1748. }
  1749. return true;
  1750. }
  1751. Parser * AsmJsModuleCompiler::GetParser() const
  1752. {
  1753. return mCx->byteCodeGenerator->GetParser();
  1754. }
  1755. ByteCodeGenerator* AsmJsModuleCompiler::GetByteCodeGenerator() const
  1756. {
  1757. return mCx->byteCodeGenerator;
  1758. }
  1759. ScriptContext * AsmJsModuleCompiler::GetScriptContext() const
  1760. {
  1761. return mCx->scriptContext;
  1762. }
  1763. AsmJsSymbol* AsmJsModuleCompiler::LookupIdentifier(PropertyName name, AsmJsFunc* func /*= nullptr */, AsmJsLookupSource::Source* lookupSource /*= nullptr*/)
  1764. {
  1765. AsmJsSymbol* lookupResult = nullptr;
  1766. if (name)
  1767. {
  1768. if (func)
  1769. {
  1770. lookupResult = func->LookupIdentifier(name, lookupSource);
  1771. if (lookupResult)
  1772. {
  1773. return lookupResult;
  1774. }
  1775. }
  1776. lookupResult = mModuleEnvironment.LookupWithKey(name->GetPropertyId(), nullptr);
  1777. if (lookupSource)
  1778. {
  1779. *lookupSource = AsmJsLookupSource::AsmJsModule;
  1780. }
  1781. }
  1782. return lookupResult;
  1783. }
  1784. bool AsmJsModuleCompiler::DefineIdentifier(PropertyName name, AsmJsSymbol* symbol)
  1785. {
  1786. Assert(symbol);
  1787. if (symbol)
  1788. {
  1789. // make sure this identifier is unique
  1790. if (!LookupIdentifier(name))
  1791. {
  1792. int addResult = mModuleEnvironment.AddNew(name->GetPropertyId(), symbol);
  1793. return addResult != -1;
  1794. }
  1795. }
  1796. return false;
  1797. }
  1798. bool AsmJsModuleCompiler::AddNumericVar(PropertyName name, ParseNode* pnode, bool isFloat, bool isMutable /*= true*/)
  1799. {
  1800. Assert(ParserWrapper::IsNumericLiteral(pnode) || (isFloat && ParserWrapper::IsFroundNumericLiteral(pnode)));
  1801. AsmJsVar* var = Anew(&mAllocator, AsmJsVar, name, isMutable);
  1802. if (!var)
  1803. {
  1804. return false;
  1805. }
  1806. if (!DefineIdentifier(name, var))
  1807. {
  1808. return false;
  1809. }
  1810. ++mVarCount;
  1811. if (isFloat)
  1812. {
  1813. var->SetVarType(AsmJsVarType::Float);
  1814. var->SetLocation(mFloatVarSpace.AcquireRegister());
  1815. if (pnode->nop == knopInt)
  1816. {
  1817. var->SetConstInitialiser((float)pnode->sxInt.lw);
  1818. }
  1819. else if (ParserWrapper::IsNegativeZero(pnode))
  1820. {
  1821. var->SetConstInitialiser(-0.0f);
  1822. }
  1823. else
  1824. {
  1825. var->SetConstInitialiser((float)pnode->sxFlt.dbl);
  1826. }
  1827. }
  1828. else if (pnode->nop == knopInt)
  1829. {
  1830. var->SetVarType(AsmJsVarType::Int);
  1831. var->SetLocation(mIntVarSpace.AcquireRegister());
  1832. var->SetConstInitialiser(pnode->sxInt.lw);
  1833. }
  1834. else
  1835. {
  1836. if (ParserWrapper::IsMinInt(pnode))
  1837. {
  1838. var->SetVarType(AsmJsVarType::Int);
  1839. var->SetLocation(mIntVarSpace.AcquireRegister());
  1840. var->SetConstInitialiser(INT_MIN);
  1841. }
  1842. else if (ParserWrapper::IsUnsigned(pnode))
  1843. {
  1844. var->SetVarType(AsmJsVarType::Int);
  1845. var->SetLocation(mIntVarSpace.AcquireRegister());
  1846. var->SetConstInitialiser((int)((uint32)pnode->sxFlt.dbl));
  1847. }
  1848. else if (pnode->sxFlt.maybeInt)
  1849. {
  1850. // this means there was an int literal not in range [-2^31,3^32)
  1851. return false;
  1852. }
  1853. else
  1854. {
  1855. var->SetVarType(AsmJsVarType::Double);
  1856. var->SetLocation(mDoubleVarSpace.AcquireRegister());
  1857. var->SetConstInitialiser(pnode->sxFlt.dbl);
  1858. }
  1859. }
  1860. return true;
  1861. }
  1862. bool AsmJsModuleCompiler::AddGlobalVarImport(PropertyName name, PropertyName field, AsmJSCoercion coercion)
  1863. {
  1864. AsmJsConstantImport* var = Anew(&mAllocator, AsmJsConstantImport, name, field);
  1865. if (!var)
  1866. {
  1867. return false;
  1868. }
  1869. if (!DefineIdentifier(name, var))
  1870. {
  1871. return false;
  1872. }
  1873. ++mVarImportCount;
  1874. switch (coercion)
  1875. {
  1876. case Js::AsmJS_ToInt32:
  1877. var->SetVarType(AsmJsVarType::Int);
  1878. var->SetLocation(mIntVarSpace.AcquireRegister());
  1879. break;
  1880. case Js::AsmJS_ToNumber:
  1881. var->SetVarType(AsmJsVarType::Double);
  1882. var->SetLocation(mDoubleVarSpace.AcquireRegister());
  1883. break;
  1884. case Js::AsmJS_FRound:
  1885. var->SetVarType(AsmJsVarType::Float);
  1886. var->SetLocation(mFloatVarSpace.AcquireRegister());
  1887. break;
  1888. #ifdef ENABLE_SIMDJS
  1889. case Js::AsmJS_Int32x4:
  1890. if (IsSimdjsEnabled())
  1891. {
  1892. var->SetVarType(AsmJsVarType::Int32x4);
  1893. var->SetLocation(mSimdVarSpace.AcquireRegister());
  1894. break;
  1895. }
  1896. Assert(UNREACHED);
  1897. case Js::AsmJS_Bool32x4:
  1898. if (IsSimdjsEnabled())
  1899. {
  1900. var->SetVarType(AsmJsVarType::Bool32x4);
  1901. var->SetLocation(mSimdVarSpace.AcquireRegister());
  1902. break;
  1903. }
  1904. Assert(UNREACHED);
  1905. case Js::AsmJS_Bool16x8:
  1906. if (IsSimdjsEnabled())
  1907. {
  1908. var->SetVarType(AsmJsVarType::Bool16x8);
  1909. var->SetLocation(mSimdVarSpace.AcquireRegister());
  1910. break;
  1911. }
  1912. Assert(UNREACHED);
  1913. case Js::AsmJS_Bool8x16:
  1914. if (IsSimdjsEnabled())
  1915. {
  1916. var->SetVarType(AsmJsVarType::Bool8x16);
  1917. var->SetLocation(mSimdVarSpace.AcquireRegister());
  1918. break;
  1919. }
  1920. Assert(UNREACHED);
  1921. case AsmJS_Float32x4:
  1922. if (IsSimdjsEnabled())
  1923. {
  1924. var->SetVarType(AsmJsVarType::Float32x4);
  1925. var->SetLocation(mSimdVarSpace.AcquireRegister());
  1926. break;
  1927. }
  1928. Assert(UNREACHED);
  1929. case AsmJS_Float64x2:
  1930. if (IsSimdjsEnabled())
  1931. {
  1932. var->SetVarType(AsmJsVarType::Float64x2);
  1933. var->SetLocation(mSimdVarSpace.AcquireRegister());
  1934. break;
  1935. }
  1936. Assert(UNREACHED);
  1937. case Js::AsmJS_Int16x8:
  1938. if (IsSimdjsEnabled())
  1939. {
  1940. var->SetVarType(AsmJsVarType::Int16x8);
  1941. var->SetLocation(mSimdVarSpace.AcquireRegister());
  1942. break;
  1943. }
  1944. Assert(UNREACHED);
  1945. case Js::AsmJS_Int8x16:
  1946. if (IsSimdjsEnabled())
  1947. {
  1948. var->SetVarType(AsmJsVarType::Int8x16);
  1949. var->SetLocation(mSimdVarSpace.AcquireRegister());
  1950. break;
  1951. }
  1952. Assert(UNREACHED);
  1953. case Js::AsmJS_Uint32x4:
  1954. if (IsSimdjsEnabled())
  1955. {
  1956. var->SetVarType(AsmJsVarType::Uint32x4);
  1957. var->SetLocation(mSimdVarSpace.AcquireRegister());
  1958. break;
  1959. }
  1960. Assert(UNREACHED);
  1961. case Js::AsmJS_Uint16x8:
  1962. if (IsSimdjsEnabled())
  1963. {
  1964. var->SetVarType(AsmJsVarType::Uint16x8);
  1965. var->SetLocation(mSimdVarSpace.AcquireRegister());
  1966. break;
  1967. }
  1968. Assert(UNREACHED);
  1969. case Js::AsmJS_Uint8x16:
  1970. if (IsSimdjsEnabled())
  1971. {
  1972. var->SetVarType(AsmJsVarType::Uint8x16);
  1973. var->SetLocation(mSimdVarSpace.AcquireRegister());
  1974. break;
  1975. }
  1976. Assert(UNREACHED);
  1977. #endif // #ifdef ENABLE_SIMDJS
  1978. default:
  1979. break;
  1980. }
  1981. return true;
  1982. }
  1983. bool AsmJsModuleCompiler::AddModuleFunctionImport(PropertyName name, PropertyName field)
  1984. {
  1985. AsmJsImportFunction* var = Anew(&mAllocator, AsmJsImportFunction, name, field, &mAllocator);
  1986. if (!var)
  1987. {
  1988. return false;
  1989. }
  1990. if (!DefineIdentifier(name, var))
  1991. {
  1992. return false;
  1993. }
  1994. var->SetFunctionIndex(mImportFunctions.AcquireRegister());
  1995. return true;
  1996. }
  1997. bool AsmJsModuleCompiler::AddNumericConst(PropertyName name, const double* cst)
  1998. {
  1999. AsmJsMathConst* var = Anew(&mAllocator, AsmJsMathConst, name, cst);
  2000. if (!var)
  2001. {
  2002. return false;
  2003. }
  2004. if (!DefineIdentifier(name, var))
  2005. {
  2006. return false;
  2007. }
  2008. return true;
  2009. }
  2010. bool AsmJsModuleCompiler::AddArrayView(PropertyName name, ArrayBufferView::ViewType type)
  2011. {
  2012. AsmJsArrayView* view = Anew(&mAllocator, AsmJsArrayView, name, type);
  2013. if (!view)
  2014. {
  2015. return false;
  2016. }
  2017. if (!DefineIdentifier(name, view))
  2018. {
  2019. return false;
  2020. }
  2021. mArrayViews.Enqueue(view);
  2022. return true;
  2023. }
  2024. bool AsmJsModuleCompiler::AddFunctionTable(PropertyName name, const int size)
  2025. {
  2026. GetByteCodeGenerator()->AssignPropertyId(name);
  2027. AsmJsFunctionTable* funcTable = Anew(&mAllocator, AsmJsFunctionTable, name, &mAllocator);
  2028. if (!funcTable)
  2029. {
  2030. return false;
  2031. }
  2032. if (!DefineIdentifier(name, funcTable))
  2033. {
  2034. return false;
  2035. }
  2036. funcTable->SetSize(size);
  2037. int pos = mFunctionTableArray.Add(funcTable);
  2038. funcTable->SetFunctionIndex(pos);
  2039. return true;
  2040. }
  2041. bool AsmJsModuleCompiler::AddExport(PropertyName name, RegSlot location)
  2042. {
  2043. AsmJsModuleExport * foundExport;
  2044. if (mExports.TryGetReference(name->GetPropertyId(), &foundExport))
  2045. {
  2046. AsmJSCompiler::OutputMessage(GetScriptContext(), DEIT_GENERAL, _u("Warning: redefining export"));
  2047. foundExport->location = location;
  2048. return true;
  2049. }
  2050. else
  2051. {
  2052. AsmJsModuleExport ex;
  2053. ex.id = name->GetPropertyId();
  2054. ex.location = location;
  2055. return mExports.Add(ex.id, ex) >= 0;
  2056. // return is < 0 if count overflowed 31bits
  2057. }
  2058. }
  2059. bool AsmJsModuleCompiler::SetExportFunc(AsmJsFunc* func)
  2060. {
  2061. Assert(mExports.Count() == 0 && func);
  2062. mExportFuncIndex = func->GetFunctionIndex();
  2063. return mExports.Count() == 0 && (uint32)mExportFuncIndex < (uint32)mFunctionArray.Count();
  2064. }
  2065. AsmJsFunctionDeclaration* AsmJsModuleCompiler::LookupFunction(PropertyName name)
  2066. {
  2067. return LookupIdentifier<AsmJsFunctionDeclaration>(name);
  2068. }
  2069. bool AsmJsModuleCompiler::AreAllFuncTableDefined()
  2070. {
  2071. const int size = mFunctionTableArray.Count();
  2072. for (int i = 0; i < size; i++)
  2073. {
  2074. AsmJsFunctionTable* funcTable = mFunctionTableArray.Item(i);
  2075. if (!funcTable->IsDefined())
  2076. {
  2077. AsmJSCompiler::OutputError(GetScriptContext(), _u("Function table %s was used in a function but does not appear in the module"), funcTable->GetName()->Psz());
  2078. return false;
  2079. }
  2080. }
  2081. return true;
  2082. }
  2083. void AsmJsModuleCompiler::UpdateMaxHeapAccess(uint index)
  2084. {
  2085. if (mMaxHeapAccess < index)
  2086. {
  2087. mMaxHeapAccess = index;
  2088. }
  2089. }
  2090. void AsmJsModuleCompiler::InitMemoryOffsets()
  2091. {
  2092. mModuleMemory.mArrayBufferOffset = AsmJsModuleMemory::MemoryTableBeginOffset;
  2093. mModuleMemory.mStdLibOffset = mModuleMemory.mArrayBufferOffset + 1;
  2094. mModuleMemory.mDoubleOffset = mModuleMemory.mStdLibOffset + 1;
  2095. mModuleMemory.mFuncOffset = mModuleMemory.mDoubleOffset + (mDoubleVarSpace.GetTotalVarCount() * WAsmJs::DOUBLE_SLOTS_SPACE);
  2096. mModuleMemory.mFFIOffset = mModuleMemory.mFuncOffset + mFunctionArray.Count();
  2097. mModuleMemory.mFuncPtrOffset = mModuleMemory.mFFIOffset + mImportFunctions.GetTotalVarCount();
  2098. mModuleMemory.mFloatOffset = mModuleMemory.mFuncPtrOffset + GetFuncPtrTableCount();
  2099. mModuleMemory.mIntOffset = mModuleMemory.mFloatOffset + (int32)(mFloatVarSpace.GetTotalVarCount() * WAsmJs::FLOAT_SLOTS_SPACE + 0.5);
  2100. mModuleMemory.mMemorySize = mModuleMemory.mIntOffset + (int32)(mIntVarSpace.GetTotalVarCount() * WAsmJs::INT_SLOTS_SPACE + 0.5);
  2101. #ifdef ENABLE_SIMDJS
  2102. if (IsSimdjsEnabled())
  2103. {
  2104. // mSimdOffset is in SIMDValues, hence aligned
  2105. // mMemorySize is in Vars
  2106. mModuleMemory.mSimdOffset = (int) ::ceil(mModuleMemory.mMemorySize / WAsmJs::SIMD_SLOTS_SPACE);
  2107. if (mSimdVarSpace.GetTotalVarCount())
  2108. {
  2109. mModuleMemory.mMemorySize = (int)((mModuleMemory.mSimdOffset + mSimdVarSpace.GetTotalVarCount()) * WAsmJs::SIMD_SLOTS_SPACE);
  2110. }
  2111. }
  2112. else
  2113. #endif
  2114. {
  2115. mModuleMemory.mSimdOffset = 0; // initialize to avoid GC false reference
  2116. }
  2117. }
  2118. void AsmJsModuleCompiler::AccumulateCompileTime()
  2119. {
  2120. Js::TickDelta td;
  2121. AsmJsCompileTime curTime = GetTick();
  2122. td = curTime - mCompileTimeLastTick;
  2123. mCompileTime = mCompileTime + td;
  2124. mCompileTimeLastTick = curTime;
  2125. }
  2126. void AsmJsModuleCompiler::AccumulateCompileTime(AsmJsCompilation::Phases phase)
  2127. {
  2128. Js::TickDelta td;
  2129. AsmJsCompileTime curTime = GetTick();
  2130. td = curTime - mCompileTimeLastTick;
  2131. mCompileTime = mCompileTime + td;
  2132. mCompileTimeLastTick = curTime;
  2133. mPhaseCompileTime[phase] = mPhaseCompileTime[phase] + td;
  2134. }
  2135. Js::AsmJsCompileTime AsmJsModuleCompiler::GetTick()
  2136. {
  2137. return Js::Tick::Now();
  2138. }
  2139. uint64 AsmJsModuleCompiler::GetCompileTime() const
  2140. {
  2141. return mCompileTime.ToMicroseconds();
  2142. }
  2143. static const char16* AsmPhaseNames[AsmJsCompilation::Phases_COUNT] = {
  2144. _u("Module"),
  2145. _u("ByteCode"),
  2146. _u("TemplateJIT"),
  2147. };
  2148. void AsmJsModuleCompiler::PrintCompileTrace() const
  2149. {
  2150. // for testtrace, don't print time so that it can be used for baselines
  2151. if (PHASE_TESTTRACE1(AsmjsPhase))
  2152. {
  2153. AsmJSCompiler::OutputMessage(GetScriptContext(), DEIT_ASMJS_SUCCEEDED, _u("Successfully compiled asm.js code"));
  2154. }
  2155. else
  2156. {
  2157. uint64 us = GetCompileTime();
  2158. uint64 ms = us / 1000;
  2159. us = us % 1000;
  2160. AsmJSCompiler::OutputMessage(GetScriptContext(), DEIT_ASMJS_SUCCEEDED, _u("Successfully compiled asm.js code (total compilation time %llu.%llums)"), ms, us);
  2161. }
  2162. if (PHASE_TRACE1(AsmjsPhase))
  2163. {
  2164. for (int i = 0; i < AsmJsCompilation::Phases_COUNT; i++)
  2165. {
  2166. uint64 us = mPhaseCompileTime[i].ToMicroseconds();
  2167. uint64 ms = us / 1000;
  2168. us = us % 1000;
  2169. Output::Print(_u("%20s : %llu.%llums\n"), AsmPhaseNames[i], ms, us);
  2170. }
  2171. Output::Flush();
  2172. }
  2173. }
  2174. BVStatic<ASMMATH_BUILTIN_SIZE> AsmJsModuleCompiler::GetAsmMathBuiltinUsedBV()
  2175. {
  2176. return mAsmMathBuiltinUsedBV;
  2177. }
  2178. BVStatic<ASMARRAY_BUILTIN_SIZE> AsmJsModuleCompiler::GetAsmArrayBuiltinUsedBV()
  2179. {
  2180. return mAsmArrayBuiltinUsedBV;
  2181. }
  2182. void AsmJsModuleInfo::SetFunctionCount(int val)
  2183. {
  2184. Assert(mFunctions == nullptr);
  2185. mFunctionCount = val;
  2186. mFunctions = RecyclerNewArray(mRecycler, ModuleFunction, val);
  2187. }
  2188. void AsmJsModuleInfo::SetFunctionTableCount(int val)
  2189. {
  2190. Assert(mFunctionTables == nullptr);
  2191. mFunctionTableCount = val;
  2192. mFunctionTables = RecyclerNewArray(mRecycler, ModuleFunctionTable, val);
  2193. }
  2194. void AsmJsModuleInfo::SetFunctionImportCount(int val)
  2195. {
  2196. Assert(mFunctionImports == nullptr);
  2197. mFunctionImportCount = val;
  2198. mFunctionImports = RecyclerNewArray(mRecycler, ModuleFunctionImport, val);
  2199. }
  2200. void AsmJsModuleInfo::SetVarCount(int val)
  2201. {
  2202. Assert(mVars == nullptr);
  2203. mVarCount = val;
  2204. mVars = RecyclerNewArray(mRecycler, ModuleVar, val);
  2205. }
  2206. void AsmJsModuleInfo::SetVarImportCount(int val)
  2207. {
  2208. Assert(mVarImports == nullptr);
  2209. mVarImportCount = val;
  2210. mVarImports = RecyclerNewArray(mRecycler, ModuleVarImport, val);
  2211. }
  2212. void AsmJsModuleInfo::SetExportsCount(int count)
  2213. {
  2214. if (count)
  2215. {
  2216. mExports = RecyclerNewPlus(mRecycler, count * sizeof(PropertyId), PropertyIdArray, count, 0);
  2217. mExportsFunctionLocation = RecyclerNewArray(mRecycler, RegSlot, count);
  2218. }
  2219. mExportsCount = count;
  2220. }
  2221. void AsmJsModuleInfo::InitializeSlotMap(int val)
  2222. {
  2223. Assert(mSlotMap == nullptr);
  2224. mSlotsCount = val;
  2225. mSlotMap = RecyclerNew(mRecycler, AsmJsSlotMap, mRecycler);
  2226. }
  2227. void AsmJsModuleInfo::SetFunctionTableSize(int index, uint size)
  2228. {
  2229. Assert(mFunctionTables != nullptr);
  2230. Assert(index < mFunctionTableCount);
  2231. ModuleFunctionTable& table = mFunctionTables[index];
  2232. table.size = size;
  2233. table.moduleFunctionIndex = RecyclerNewArray(mRecycler, RegSlot, size);
  2234. }
  2235. void AsmJsModuleInfo::EnsureHeapAttached(ScriptFunction * func)
  2236. {
  2237. #ifdef ENABLE_WASM
  2238. if (WasmScriptFunction::Is(func))
  2239. {
  2240. WasmScriptFunction* wasmFunc = WasmScriptFunction::FromVar(func);
  2241. WebAssemblyMemory * wasmMem = wasmFunc->GetWebAssemblyMemory();
  2242. if (wasmMem && wasmMem->GetBuffer() && wasmMem->GetBuffer()->IsDetached())
  2243. {
  2244. Throw::OutOfMemory();
  2245. }
  2246. }
  2247. else
  2248. #endif
  2249. {
  2250. AsmJsScriptFunction* asmFunc = AsmJsScriptFunction::FromVar(func);
  2251. ArrayBuffer* moduleArrayBuffer = asmFunc->GetAsmJsArrayBuffer();
  2252. if (moduleArrayBuffer && moduleArrayBuffer->IsDetached())
  2253. {
  2254. Throw::OutOfMemory();
  2255. }
  2256. }
  2257. }
  2258. void * AsmJsModuleInfo::ConvertFrameForJavascript(void* env, AsmJsScriptFunction* func)
  2259. {
  2260. FunctionBody * body = func->GetFunctionBody();
  2261. AsmJsFunctionInfo * asmFuncInfo = body->GetAsmJsFunctionInfo();
  2262. FunctionBody * moduleBody = asmFuncInfo->GetModuleFunctionBody();
  2263. AsmJsModuleInfo * asmModuleInfo = moduleBody->GetAsmJsModuleInfo();
  2264. Assert(asmModuleInfo);
  2265. ScriptContext * scriptContext = func->GetScriptContext();
  2266. // AsmJsModuleEnvironment is all laid out here
  2267. Var * asmJsEnvironment = static_cast<Var*>(env);
  2268. Var * asmBufferPtr = asmJsEnvironment + asmModuleInfo->GetModuleMemory().mArrayBufferOffset;
  2269. ArrayBuffer * asmBuffer = *asmBufferPtr ? ArrayBuffer::FromVar(*asmBufferPtr) : nullptr;
  2270. Var stdLibObj = *(asmJsEnvironment + asmModuleInfo->GetModuleMemory().mStdLibOffset);
  2271. Var asmMathObject = stdLibObj ? JavascriptOperators::OP_GetProperty(stdLibObj, PropertyIds::Math, scriptContext) : nullptr;
  2272. Var * asmFFIs = asmJsEnvironment + asmModuleInfo->GetModuleMemory().mFFIOffset;
  2273. Var * asmFuncs = asmJsEnvironment + asmModuleInfo->GetModuleMemory().mFuncOffset;
  2274. Var ** asmFuncPtrs = reinterpret_cast<Var**>(asmJsEnvironment + asmModuleInfo->GetModuleMemory().mFuncPtrOffset);
  2275. double * asmDoubleVars = reinterpret_cast<double*>(asmJsEnvironment + asmModuleInfo->GetModuleMemory().mDoubleOffset);
  2276. int * asmIntVars = reinterpret_cast<int*>(asmJsEnvironment + asmModuleInfo->GetModuleMemory().mIntOffset);
  2277. float * asmFloatVars = reinterpret_cast<float*>(asmJsEnvironment + asmModuleInfo->GetModuleMemory().mFloatOffset);
  2278. #ifdef ENABLE_SIMDJS
  2279. AsmJsSIMDValue * asmSIMDVars = reinterpret_cast<AsmJsSIMDValue*>(asmJsEnvironment + asmModuleInfo->GetModuleMemory().mSimdOffset);
  2280. #endif
  2281. #if DEBUG
  2282. Field(Var) * slotArray = RecyclerNewArrayZ(scriptContext->GetRecycler(), Field(Var), moduleBody->scopeSlotArraySize + ScopeSlots::FirstSlotIndex);
  2283. #else
  2284. Field(Var) * slotArray = RecyclerNewArray(scriptContext->GetRecycler(), Field(Var), moduleBody->scopeSlotArraySize + ScopeSlots::FirstSlotIndex);
  2285. #endif
  2286. ScopeSlots scopeSlots(slotArray);
  2287. scopeSlots.SetCount(moduleBody->scopeSlotArraySize);
  2288. scopeSlots.SetScopeMetadata(moduleBody->GetFunctionInfo());
  2289. auto asmSlotMap = asmModuleInfo->GetAsmJsSlotMap();
  2290. Assert((uint)asmModuleInfo->GetSlotsCount() >= moduleBody->scopeSlotArraySize);
  2291. Js::ActivationObject* activeScopeObject = nullptr;
  2292. if (moduleBody->GetObjectRegister() != 0)
  2293. {
  2294. activeScopeObject = static_cast<ActivationObject*>(scriptContext->GetLibrary()->CreateActivationObject());
  2295. }
  2296. PropertyId* propertyIdArray = moduleBody->GetPropertyIdsForScopeSlotArray();
  2297. uint slotsCount = moduleBody->scopeSlotArraySize;
  2298. for (uint i = 0; i < slotsCount; ++i)
  2299. {
  2300. AsmJsSlot * asmSlot = nullptr;
  2301. bool found = asmSlotMap->TryGetValue(propertyIdArray[i], &asmSlot);
  2302. // we should have everything we need in the map
  2303. Assert(found);
  2304. Var value = nullptr;
  2305. switch (asmSlot->symType)
  2306. {
  2307. case AsmJsSymbol::ConstantImport:
  2308. case AsmJsSymbol::Variable:
  2309. {
  2310. switch (asmSlot->varType)
  2311. {
  2312. case AsmJsVarType::Double:
  2313. value = JavascriptNumber::NewWithCheck(asmDoubleVars[asmSlot->location], scriptContext);
  2314. break;
  2315. case AsmJsVarType::Float:
  2316. value = JavascriptNumber::NewWithCheck(asmFloatVars[asmSlot->location], scriptContext);
  2317. break;
  2318. case AsmJsVarType::Int:
  2319. value = JavascriptNumber::ToVar(asmIntVars[asmSlot->location], scriptContext);
  2320. break;
  2321. #ifdef ENABLE_SIMDJS
  2322. case AsmJsVarType::Float32x4:
  2323. value = JavascriptSIMDFloat32x4::New(&asmSIMDVars[asmSlot->location], scriptContext);
  2324. break;
  2325. case AsmJsVarType::Float64x2:
  2326. value = JavascriptSIMDFloat64x2::New(&asmSIMDVars[asmSlot->location], scriptContext);
  2327. break;
  2328. case AsmJsVarType::Int32x4:
  2329. value = JavascriptSIMDInt32x4::New(&asmSIMDVars[asmSlot->location], scriptContext);
  2330. break;
  2331. case AsmJsVarType::Int16x8:
  2332. value = JavascriptSIMDInt16x8::New(&asmSIMDVars[asmSlot->location], scriptContext);
  2333. break;
  2334. case AsmJsVarType::Int8x16:
  2335. value = JavascriptSIMDInt8x16::New(&asmSIMDVars[asmSlot->location], scriptContext);
  2336. break;
  2337. case AsmJsVarType::Uint32x4:
  2338. value = JavascriptSIMDUint32x4::New(&asmSIMDVars[asmSlot->location], scriptContext);
  2339. break;
  2340. case AsmJsVarType::Uint16x8:
  2341. value = JavascriptSIMDUint16x8::New(&asmSIMDVars[asmSlot->location], scriptContext);
  2342. break;
  2343. case AsmJsVarType::Uint8x16:
  2344. value = JavascriptSIMDUint8x16::New(&asmSIMDVars[asmSlot->location], scriptContext);
  2345. break;
  2346. case AsmJsVarType::Bool32x4:
  2347. value = JavascriptSIMDBool32x4::New(&asmSIMDVars[asmSlot->location], scriptContext);
  2348. break;
  2349. case AsmJsVarType::Bool16x8:
  2350. value = JavascriptSIMDBool16x8::New(&asmSIMDVars[asmSlot->location], scriptContext);
  2351. break;
  2352. case AsmJsVarType::Bool8x16:
  2353. value = JavascriptSIMDBool8x16::New(&asmSIMDVars[asmSlot->location], scriptContext);
  2354. break;
  2355. #endif // #ifdef ENABLE_SIMDJS
  2356. default:
  2357. Assume(UNREACHED);
  2358. }
  2359. break;
  2360. }
  2361. case AsmJsSymbol::ModuleArgument:
  2362. {
  2363. switch (asmSlot->argType)
  2364. {
  2365. case AsmJsModuleArg::ArgType::StdLib:
  2366. value = stdLibObj;
  2367. break;
  2368. case AsmJsModuleArg::ArgType::Import:
  2369. // we can't reference this inside functions (and don't hold onto it), but must set to something, so set it to be undefined
  2370. value = scriptContext->GetLibrary()->GetUndefined();
  2371. break;
  2372. case AsmJsModuleArg::ArgType::Heap:
  2373. value = asmBuffer;
  2374. break;
  2375. default:
  2376. Assume(UNREACHED);
  2377. }
  2378. break;
  2379. }
  2380. case AsmJsSymbol::ImportFunction:
  2381. value = asmFFIs[asmSlot->location];
  2382. break;
  2383. case AsmJsSymbol::FuncPtrTable:
  2384. value = JavascriptArray::OP_NewScArrayWithElements(asmSlot->funcTableSize, asmFuncPtrs[asmSlot->location], scriptContext);
  2385. break;
  2386. case AsmJsSymbol::ModuleFunction:
  2387. value = asmFuncs[asmSlot->location];
  2388. break;
  2389. case AsmJsSymbol::MathConstant:
  2390. value = JavascriptNumber::NewWithCheck(asmSlot->mathConstVal, scriptContext);
  2391. break;
  2392. case AsmJsSymbol::ClosureFunction:
  2393. // we can't reference this inside functions but must set to something, so set it to be undefined
  2394. value = scriptContext->GetLibrary()->GetUndefined();
  2395. break;
  2396. case AsmJsSymbol::ArrayView:
  2397. {
  2398. AnalysisAssert(asmBuffer);
  2399. #ifdef _M_X64
  2400. const bool isOptimizedBuffer = true;
  2401. #elif _M_IX86
  2402. const bool isOptimizedBuffer = false;
  2403. #else
  2404. Assert(UNREACHED);
  2405. const bool isOptimizedBuffer = false;
  2406. #endif
  2407. Assert(isOptimizedBuffer == asmBuffer->IsValidVirtualBufferLength(asmBuffer->GetByteLength()));
  2408. switch (asmSlot->viewType)
  2409. {
  2410. case ArrayBufferView::TYPE_FLOAT32:
  2411. value = TypedArray<float, false, isOptimizedBuffer>::Create(asmBuffer, 0, asmBuffer->GetByteLength() >> 2, scriptContext->GetLibrary());
  2412. break;
  2413. case ArrayBufferView::TYPE_FLOAT64:
  2414. value = TypedArray<double, false, isOptimizedBuffer>::Create(asmBuffer, 0, asmBuffer->GetByteLength() >> 3, scriptContext->GetLibrary());
  2415. break;
  2416. case ArrayBufferView::TYPE_INT8:
  2417. value = TypedArray<int8, false, isOptimizedBuffer>::Create(asmBuffer, 0, asmBuffer->GetByteLength(), scriptContext->GetLibrary());
  2418. break;
  2419. case ArrayBufferView::TYPE_INT16:
  2420. value = TypedArray<int16, false, isOptimizedBuffer>::Create(asmBuffer, 0, asmBuffer->GetByteLength() >> 1, scriptContext->GetLibrary());
  2421. break;
  2422. case ArrayBufferView::TYPE_INT32:
  2423. value = TypedArray<int32, false, isOptimizedBuffer>::Create(asmBuffer, 0, asmBuffer->GetByteLength() >> 2, scriptContext->GetLibrary());
  2424. break;
  2425. case ArrayBufferView::TYPE_UINT8:
  2426. value = TypedArray<uint8, false, isOptimizedBuffer>::Create(asmBuffer, 0, asmBuffer->GetByteLength(), scriptContext->GetLibrary());
  2427. break;
  2428. case ArrayBufferView::TYPE_UINT16:
  2429. value = TypedArray<uint16, false, isOptimizedBuffer>::Create(asmBuffer, 0, asmBuffer->GetByteLength() >> 1, scriptContext->GetLibrary());
  2430. break;
  2431. case ArrayBufferView::TYPE_UINT32:
  2432. value = TypedArray<uint32, false, isOptimizedBuffer>::Create(asmBuffer, 0, asmBuffer->GetByteLength() >> 2, scriptContext->GetLibrary());
  2433. break;
  2434. default:
  2435. Assume(UNREACHED);
  2436. }
  2437. break;
  2438. }
  2439. case AsmJsSymbol::MathBuiltinFunction:
  2440. {
  2441. switch (asmSlot->builtinMathFunc)
  2442. {
  2443. #define ASMJS_MATH_FUNC_NAMES(name, propertyName, funcInfo) \
  2444. case AsmJSMathBuiltin_##name: \
  2445. value = JavascriptOperators::OP_GetProperty(asmMathObject, PropertyIds::##propertyName, scriptContext); \
  2446. break;
  2447. #include "AsmJsBuiltInNames.h"
  2448. default:
  2449. Assume(UNREACHED);
  2450. }
  2451. break;
  2452. }
  2453. case AsmJsSymbol::TypedArrayBuiltinFunction:
  2454. switch (asmSlot->builtinArrayFunc)
  2455. {
  2456. #define ASMJS_ARRAY_NAMES(name, propertyName) \
  2457. case AsmJSTypedArrayBuiltin_##name: \
  2458. value = JavascriptOperators::OP_GetProperty(stdLibObj, PropertyIds::##propertyName, scriptContext); \
  2459. break;
  2460. #include "AsmJsBuiltInNames.h"
  2461. default:
  2462. Assume(UNREACHED);
  2463. }
  2464. break;
  2465. case AsmJsSymbol::SIMDBuiltinFunction:
  2466. switch (asmSlot->builtinSIMDFunc)
  2467. {
  2468. #define ASMJS_SIMD_NAMES(name, propertyName, libName, entryPoint) \
  2469. case AsmJsSIMDBuiltin_##name: \
  2470. value = JavascriptOperators::OP_GetProperty(stdLibObj, PropertyIds::##propertyName, scriptContext); \
  2471. break;
  2472. #include "AsmJsBuiltInNames.h"
  2473. default:
  2474. Assume(UNREACHED);
  2475. }
  2476. break;
  2477. default:
  2478. Assume(UNREACHED);
  2479. }
  2480. if (activeScopeObject != nullptr)
  2481. {
  2482. activeScopeObject->SetPropertyWithAttributes(
  2483. propertyIdArray[i],
  2484. value,
  2485. asmSlot->isConstVar ? PropertyConstDefaults : PropertyDynamicTypeDefaults,
  2486. nullptr);
  2487. }
  2488. else
  2489. {
  2490. // ensure we aren't multiply writing to a slot
  2491. Assert(scopeSlots.Get(i) == nullptr);
  2492. scopeSlots.Set(i, value);
  2493. }
  2494. }
  2495. if (activeScopeObject != nullptr)
  2496. {
  2497. return (void*)activeScopeObject;
  2498. }
  2499. else
  2500. {
  2501. return (void*)slotArray;
  2502. }
  2503. }
  2504. bool AsmJsModuleCompiler::LookupStdLibSIMDNameInMap(PropertyName name, AsmJsSIMDFunction **simdFunc, SIMDNameMap* map) const
  2505. {
  2506. return map->TryGetValue(name->GetPropertyId(), simdFunc);
  2507. }
  2508. bool AsmJsModuleCompiler::AddStandardLibrarySIMDNameInMap(PropertyId id, AsmJsSIMDFunction *simdFunc, SIMDNameMap* map)
  2509. {
  2510. //SimdBuiltin simdBuiltin(simdFunc->GetSimdBuiltInFunction(), simdFunc);
  2511. if (map->ContainsKey(id))
  2512. {
  2513. return nullptr;
  2514. }
  2515. return map->AddNew(id, simdFunc) == -1 ? false : true;
  2516. }
  2517. bool AsmJsModuleCompiler::LookupStdLibSIMDName(PropertyId baseId, PropertyName fieldName, AsmJsSIMDFunction **simdFunc)
  2518. {
  2519. switch (baseId)
  2520. {
  2521. case PropertyIds::Int32x4:
  2522. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDInt32x4Map);
  2523. case PropertyIds::Bool32x4:
  2524. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDBool32x4Map);
  2525. case PropertyIds::Bool16x8:
  2526. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDBool16x8Map);
  2527. case PropertyIds::Bool8x16:
  2528. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDBool8x16Map);
  2529. case PropertyIds::Float32x4:
  2530. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDFloat32x4Map);
  2531. case PropertyIds::Float64x2:
  2532. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDFloat64x2Map);
  2533. case PropertyIds::Int16x8:
  2534. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDInt16x8Map);
  2535. case PropertyIds::Int8x16:
  2536. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDInt8x16Map);
  2537. case PropertyIds::Uint32x4:
  2538. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDUint32x4Map);
  2539. case PropertyIds::Uint16x8:
  2540. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDUint16x8Map);
  2541. case PropertyIds::Uint8x16:
  2542. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDUint8x16Map);
  2543. default:
  2544. AssertMsg(false, "Invalid SIMD type");
  2545. return false;
  2546. }
  2547. }
  2548. bool AsmJsModuleCompiler::LookupStdLibSIMDName(AsmJsSIMDBuiltinFunction baseId, PropertyName fieldName, AsmJsSIMDFunction **simdFunc)
  2549. {
  2550. switch (baseId)
  2551. {
  2552. case AsmJsSIMDBuiltin_Int32x4:
  2553. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDInt32x4Map);
  2554. case AsmJsSIMDBuiltin_Bool32x4:
  2555. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDBool32x4Map);
  2556. case AsmJsSIMDBuiltin_Bool16x8:
  2557. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDBool16x8Map);
  2558. case AsmJsSIMDBuiltin_Bool8x16:
  2559. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDBool8x16Map);
  2560. case AsmJsSIMDBuiltin_Float32x4:
  2561. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDFloat32x4Map);
  2562. case AsmJsSIMDBuiltin_Float64x2:
  2563. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDFloat64x2Map);
  2564. case AsmJsSIMDBuiltin_Int16x8:
  2565. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDInt16x8Map);
  2566. case AsmJsSIMDBuiltin_Int8x16:
  2567. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDInt8x16Map);
  2568. case AsmJsSIMDBuiltin_Uint32x4:
  2569. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDUint32x4Map);
  2570. case AsmJsSIMDBuiltin_Uint16x8:
  2571. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDUint16x8Map);
  2572. case AsmJsSIMDBuiltin_Uint8x16:
  2573. return LookupStdLibSIMDNameInMap(fieldName, simdFunc, &mStdLibSIMDUint8x16Map);
  2574. default:
  2575. AssertMsg(false, "Invalid SIMD type");
  2576. return false;
  2577. }
  2578. }
  2579. AsmJsSIMDFunction* AsmJsModuleCompiler::LookupSimdConstructor(PropertyName name)
  2580. {
  2581. AsmJsSIMDFunction* simdFunc = LookupIdentifier<AsmJsSIMDFunction>(name);
  2582. if (simdFunc && simdFunc->IsConstructor())
  2583. {
  2584. return simdFunc;
  2585. }
  2586. return nullptr;
  2587. }
  2588. AsmJsSIMDFunction* AsmJsModuleCompiler::LookupSimdTypeCheck(PropertyName name)
  2589. {
  2590. AsmJsSIMDFunction* simdFunc = LookupIdentifier<AsmJsSIMDFunction>(name);
  2591. if (simdFunc && simdFunc->IsTypeCheck())
  2592. {
  2593. return simdFunc;
  2594. }
  2595. return nullptr;
  2596. }
  2597. AsmJsSIMDFunction* AsmJsModuleCompiler::LookupSimdOperation(PropertyName name)
  2598. {
  2599. AsmJsSIMDFunction* simdFunc = LookupIdentifier<AsmJsSIMDFunction>(name);
  2600. if (simdFunc &&
  2601. simdFunc->GetSimdBuiltInFunction() != AsmJsSIMDBuiltin_Int32x4 &&
  2602. simdFunc->GetSimdBuiltInFunction() != AsmJsSIMDBuiltin_Int16x8 &&
  2603. simdFunc->GetSimdBuiltInFunction() != AsmJsSIMDBuiltin_Int8x16 &&
  2604. simdFunc->GetSimdBuiltInFunction() != AsmJsSIMDBuiltin_Float32x4 &&
  2605. simdFunc->GetSimdBuiltInFunction() != AsmJsSIMDBuiltin_Float64x2 &&
  2606. simdFunc->GetSimdBuiltInFunction() != AsmJsSIMDBuiltin_Uint32x4 &&
  2607. simdFunc->GetSimdBuiltInFunction() != AsmJsSIMDBuiltin_Uint16x8 &&
  2608. simdFunc->GetSimdBuiltInFunction() != AsmJsSIMDBuiltin_Uint8x16 &&
  2609. simdFunc->GetSimdBuiltInFunction() != AsmJsSIMDBuiltin_Bool32x4 &&
  2610. simdFunc->GetSimdBuiltInFunction() != AsmJsSIMDBuiltin_Bool16x8 &&
  2611. simdFunc->GetSimdBuiltInFunction() != AsmJsSIMDBuiltin_Bool8x16
  2612. )
  2613. {
  2614. return simdFunc;
  2615. }
  2616. return nullptr;
  2617. }
  2618. bool AsmJsModuleCompiler::AddSimdValueVar(PropertyName name, ParseNode* pnode, AsmJsSIMDFunction* simdFunc)
  2619. {
  2620. AssertMsg(AsmJsSIMDFunction::Is(simdFunc), "Expecting SIMD builtin");
  2621. AssertMsg(simdFunc->IsConstructor(), "Expecting constructor function");
  2622. AsmJsSIMDValue value;
  2623. AsmJsVarType type = simdFunc->GetConstructorVarType();
  2624. // e.g. var g1 = f4(1.0, 2.0, 3.0, 4.0);
  2625. if (!ValidateSimdConstructor(pnode, simdFunc, value))
  2626. {
  2627. return false;
  2628. }
  2629. AsmJsVar* var = Anew(&mAllocator, AsmJsVar, name);
  2630. if (!var || !DefineIdentifier(name, var))
  2631. {
  2632. return false;
  2633. }
  2634. ++mVarCount;
  2635. var->SetVarType(type);
  2636. var->SetConstInitialiser(value);
  2637. // acquire register
  2638. var->SetLocation(mSimdVarSpace.AcquireRegister());
  2639. return true;
  2640. }
  2641. bool AsmJsModuleCompiler::ValidateSimdConstructor(ParseNode* pnode, AsmJsSIMDFunction* simdFunc, AsmJsSIMDValue& value)
  2642. {
  2643. Assert(pnode->nop == knopCall);
  2644. uint argCount = pnode->sxCall.argCount;
  2645. ParseNode* argNode = pnode->sxCall.pnodeArgs;
  2646. ParseNode *arg = argNode;
  2647. uint nop = 0;
  2648. AsmJsSIMDBuiltinFunction simdBuiltin = simdFunc->GetSimdBuiltInFunction();
  2649. if (!simdFunc->IsConstructor(argCount))
  2650. {
  2651. return Fail(pnode, _u("Invalid SIMD constructor or wrong number of arguments."));
  2652. }
  2653. switch (simdBuiltin)
  2654. {
  2655. case AsmJsSIMDBuiltin_Float64x2:
  2656. case AsmJsSIMDBuiltin_Float32x4:
  2657. nop = (uint)knopFlt;
  2658. break;
  2659. case AsmJsSIMDBuiltin_Int32x4:
  2660. case AsmJsSIMDBuiltin_Int16x8:
  2661. case AsmJsSIMDBuiltin_Int8x16:
  2662. case AsmJsSIMDBuiltin_Uint32x4:
  2663. case AsmJsSIMDBuiltin_Uint16x8:
  2664. case AsmJsSIMDBuiltin_Uint8x16:
  2665. case AsmJsSIMDBuiltin_Bool32x4:
  2666. case AsmJsSIMDBuiltin_Bool16x8:
  2667. case AsmJsSIMDBuiltin_Bool8x16:
  2668. nop = (uint)knopInt;
  2669. break;
  2670. default:
  2671. Assert(UNREACHED);
  2672. }
  2673. if (simdFunc->GetArgCount() != argCount)
  2674. {
  2675. return Fail(pnode, _u("Invalid number of arguments to SIMD constructor."));
  2676. }
  2677. for (uint i = 0; i < argCount; i++)
  2678. {
  2679. arg = argNode;
  2680. if (argNode->nop == knopList)
  2681. {
  2682. arg = ParserWrapper::GetBinaryLeft(argNode);
  2683. argNode = ParserWrapper::GetBinaryRight(argNode);
  2684. }
  2685. Assert(arg);
  2686. // store to SIMD Value
  2687. if (arg->nop == nop)
  2688. {
  2689. if (nop == (uint)knopInt)
  2690. {
  2691. switch (simdBuiltin)
  2692. {
  2693. case AsmJsSIMDBuiltin_Int32x4:
  2694. value.i32[i] = arg->sxInt.lw;
  2695. break;
  2696. case AsmJsSIMDBuiltin_Int16x8:
  2697. value.i16[i] = (int16)arg->sxInt.lw;
  2698. break;
  2699. case AsmJsSIMDBuiltin_Int8x16:
  2700. value.i8[i] = (int8)arg->sxInt.lw;
  2701. break;
  2702. case AsmJsSIMDBuiltin_Uint32x4:
  2703. value.u32[i] = (uint32)arg->sxInt.lw;
  2704. break;
  2705. case AsmJsSIMDBuiltin_Uint16x8:
  2706. value.u16[i] = (uint16)arg->sxInt.lw;
  2707. break;
  2708. case AsmJsSIMDBuiltin_Uint8x16:
  2709. value.u8[i] = (uint8)arg->sxInt.lw;
  2710. break;
  2711. case AsmJsSIMDBuiltin_Bool32x4:
  2712. value.i32[i] = (arg->sxInt.lw) ? -1 : 0;
  2713. break;
  2714. case AsmJsSIMDBuiltin_Bool16x8:
  2715. value.i16[i] = (arg->sxInt.lw) ? -1 : 0;
  2716. break;
  2717. case AsmJsSIMDBuiltin_Bool8x16:
  2718. value.i8[i] = (arg->sxInt.lw) ? -1 : 0;
  2719. break;
  2720. default:
  2721. Assert(UNREACHED);
  2722. }
  2723. }
  2724. else if (nop == (uint)knopFlt)
  2725. {
  2726. if (simdBuiltin == AsmJsSIMDBuiltin_Float32x4)
  2727. {
  2728. value.f32[i] = (float)arg->sxFlt.dbl;
  2729. }
  2730. else // float64x2
  2731. {
  2732. value.f64[i] = arg->sxFlt.dbl;
  2733. }
  2734. }
  2735. }
  2736. else
  2737. {
  2738. return Fail(pnode, _u("Invalid argument type to SIMD constructor."));
  2739. }
  2740. }
  2741. return true;
  2742. }
  2743. };
  2744. #endif