AsmJsModule.cpp 204 KB

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