AsmJsModule.cpp 210 KB

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