InliningDecider.cpp 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #include "Backend.h"
  6. InliningDecider::InliningDecider(Js::FunctionBody *const topFunc, bool isLoopBody, bool isInDebugMode, const ExecutionMode jitMode)
  7. : topFunc(topFunc), isLoopBody(isLoopBody), isInDebugMode(isInDebugMode), jitMode(jitMode), bytecodeInlinedCount(0), numberOfInlineesWithLoop (0), threshold(topFunc->GetByteCodeWithoutLDACount(), isLoopBody)
  8. {
  9. Assert(topFunc);
  10. }
  11. InliningDecider::~InliningDecider()
  12. {
  13. INLINE_FLUSH();
  14. }
  15. bool InliningDecider::InlineIntoTopFunc() const
  16. {
  17. if (this->jitMode == ExecutionMode::SimpleJit ||
  18. PHASE_OFF(Js::InlinePhase, this->topFunc) ||
  19. PHASE_OFF(Js::GlobOptPhase, this->topFunc))
  20. {
  21. return false;
  22. }
  23. if (this->topFunc->GetHasTry())
  24. {
  25. #if defined(DBG_DUMP) || defined(ENABLE_DEBUG_CONFIG_OPTIONS)
  26. char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  27. #endif
  28. INLINE_TESTTRACE(_u("INLINING: Skip Inline: Has try\tCaller: %s (%s)\n"), this->topFunc->GetDisplayName(),
  29. this->topFunc->GetDebugNumberSet(debugStringBuffer));
  30. // Glob opt doesn't run on function with try, so we can't generate bailout for it
  31. return false;
  32. }
  33. return InlineIntoInliner(topFunc);
  34. }
  35. bool InliningDecider::InlineIntoInliner(Js::FunctionBody *const inliner) const
  36. {
  37. Assert(inliner);
  38. Assert(this->jitMode == ExecutionMode::FullJit);
  39. #if defined(DBG_DUMP) || defined(ENABLE_DEBUG_CONFIG_OPTIONS)
  40. char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  41. #endif
  42. if (PHASE_OFF(Js::InlinePhase, inliner) ||
  43. PHASE_OFF(Js::GlobOptPhase, inliner))
  44. {
  45. return false;
  46. }
  47. if (!inliner->HasDynamicProfileInfo())
  48. {
  49. INLINE_TESTTRACE(_u("INLINING: Skip Inline: No dynamic profile info\tCaller: %s (%s)\n"), inliner->GetDisplayName(),
  50. inliner->GetDebugNumberSet(debugStringBuffer));
  51. return false;
  52. }
  53. if (inliner->GetProfiledCallSiteCount() == 0 && !inliner->GetAnyDynamicProfileInfo()->HasLdFldCallSiteInfo())
  54. {
  55. INLINE_TESTTRACE_VERBOSE(_u("INLINING: Skip Inline: Leaf function\tCaller: %s (%s)\n"), inliner->GetDisplayName(),
  56. inliner->GetDebugNumberSet(debugStringBuffer));
  57. // Nothing to do
  58. return false;
  59. }
  60. if (!inliner->GetAnyDynamicProfileInfo()->HasCallSiteInfo(inliner))
  61. {
  62. INLINE_TESTTRACE(_u("INLINING: Skip Inline: No call site info\tCaller: %s (#%d)\n"), inliner->GetDisplayName(),
  63. inliner->GetDebugNumberSet(debugStringBuffer));
  64. return false;
  65. }
  66. return true;
  67. }
  68. Js::FunctionInfo *InliningDecider::GetCallSiteFuncInfo(Js::FunctionBody *const inliner, const Js::ProfileId profiledCallSiteId, bool* isConstructorCall, bool* isPolymorphicCall)
  69. {
  70. Assert(inliner);
  71. Assert(profiledCallSiteId < inliner->GetProfiledCallSiteCount());
  72. const auto profileData = inliner->GetAnyDynamicProfileInfo();
  73. Assert(profileData);
  74. return profileData->GetCallSiteInfo(inliner, profiledCallSiteId, isConstructorCall, isPolymorphicCall);
  75. }
  76. uint16 InliningDecider::GetConstantArgInfo(Js::FunctionBody *const inliner, const Js::ProfileId profiledCallSiteId)
  77. {
  78. Assert(inliner);
  79. Assert(profiledCallSiteId < inliner->GetProfiledCallSiteCount());
  80. const auto profileData = inliner->GetAnyDynamicProfileInfo();
  81. Assert(profileData);
  82. return profileData->GetConstantArgInfo(profiledCallSiteId);
  83. }
  84. bool InliningDecider::HasCallSiteInfo(Js::FunctionBody *const inliner, const Js::ProfileId profiledCallSiteId)
  85. {
  86. Assert(inliner);
  87. Assert(profiledCallSiteId < inliner->GetProfiledCallSiteCount());
  88. const auto profileData = inliner->GetAnyDynamicProfileInfo();
  89. Assert(profileData);
  90. return profileData->HasCallSiteInfo(inliner, profiledCallSiteId);
  91. }
  92. Js::FunctionInfo *InliningDecider::InlineCallSite(Js::FunctionBody *const inliner, const Js::ProfileId profiledCallSiteId, uint recursiveInlineDepth)
  93. {
  94. bool isConstructorCall;
  95. bool isPolymorphicCall;
  96. Js::FunctionInfo *functionInfo = GetCallSiteFuncInfo(inliner, profiledCallSiteId, &isConstructorCall, &isPolymorphicCall);
  97. if (functionInfo)
  98. {
  99. return Inline(inliner, functionInfo, isConstructorCall, false, GetConstantArgInfo(inliner, profiledCallSiteId), profiledCallSiteId, recursiveInlineDepth, true);
  100. }
  101. return nullptr;
  102. }
  103. uint InliningDecider::InlinePolymorphicCallSite(Js::FunctionBody *const inliner, const Js::ProfileId profiledCallSiteId,
  104. Js::FunctionBody** functionBodyArray, uint functionBodyArrayLength, bool* canInlineArray, uint recursiveInlineDepth)
  105. {
  106. Assert(inliner);
  107. Assert(profiledCallSiteId < inliner->GetProfiledCallSiteCount());
  108. Assert(functionBodyArray);
  109. const auto profileData = inliner->GetAnyDynamicProfileInfo();
  110. Assert(profileData);
  111. bool isConstructorCall;
  112. if (!profileData->GetPolymorphicCallSiteInfo(inliner, profiledCallSiteId, &isConstructorCall, functionBodyArray, functionBodyArrayLength))
  113. {
  114. return 0;
  115. }
  116. uint inlineeCount = 0;
  117. uint actualInlineeCount = 0;
  118. for (inlineeCount = 0; inlineeCount < functionBodyArrayLength; inlineeCount++)
  119. {
  120. if (!functionBodyArray[inlineeCount])
  121. {
  122. AssertMsg(inlineeCount >= 2, "There are at least two polymorphic call site");
  123. break;
  124. }
  125. if (Inline(inliner, functionBodyArray[inlineeCount]->GetFunctionInfo(), isConstructorCall, true /*isPolymorphicCall*/, 0, profiledCallSiteId, recursiveInlineDepth, false))
  126. {
  127. canInlineArray[inlineeCount] = true;
  128. actualInlineeCount++;
  129. }
  130. }
  131. if (inlineeCount != actualInlineeCount)
  132. {
  133. // We generate polymorphic dispatch and call even if there are no inlinees as it's seen to provide a perf boost
  134. // Skip loop bodies for now as we do not handle re-jit scenarios for the bailouts from them
  135. if (!PHASE_OFF(Js::PartialPolymorphicInlinePhase, inliner) && !this->isLoopBody)
  136. {
  137. #if defined(DBG_DUMP) || defined(ENABLE_DEBUG_CONFIG_OPTIONS)
  138. char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  139. char16 debugStringBuffer2[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  140. #endif
  141. INLINE_TESTTRACE(_u("Partial inlining of polymorphic call: %s (%s)\tCaller: %s (%s)\n"),
  142. functionBodyArray[inlineeCount - 1]->GetDisplayName(), functionBodyArray[inlineeCount - 1]->GetDebugNumberSet(debugStringBuffer),
  143. inliner->GetDisplayName(),
  144. inliner->GetDebugNumberSet(debugStringBuffer2));
  145. }
  146. else
  147. {
  148. return 0;
  149. }
  150. }
  151. return inlineeCount;
  152. }
  153. Js::FunctionInfo *InliningDecider::Inline(Js::FunctionBody *const inliner, Js::FunctionInfo* functionInfo,
  154. bool isConstructorCall, bool isPolymorphicCall, uint16 constantArgInfo, Js::ProfileId callSiteId, uint recursiveInlineDepth, bool allowRecursiveInlining)
  155. {
  156. #if defined(DBG_DUMP) || defined(ENABLE_DEBUG_CONFIG_OPTIONS)
  157. char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  158. char16 debugStringBuffer2[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  159. #endif
  160. Js::FunctionProxy * proxy = functionInfo->GetFunctionProxy();
  161. if (proxy && proxy->IsFunctionBody())
  162. {
  163. if (isLoopBody && PHASE_OFF(Js::InlineInJitLoopBodyPhase, this->topFunc))
  164. {
  165. INLINE_TESTTRACE_VERBOSE(_u("INLINING: Skip Inline: Jit loop body: %s (%s)\n"), this->topFunc->GetDisplayName(),
  166. this->topFunc->GetDebugNumberSet(debugStringBuffer));
  167. return nullptr;
  168. }
  169. // Note: disable inline for debugger, as we can't bailout at return from function.
  170. // Alternative can be generate this bailout as part of inline, which can be done later as perf improvement.
  171. const auto inlinee = proxy->GetFunctionBody();
  172. Assert(this->jitMode == ExecutionMode::FullJit);
  173. if (PHASE_OFF(Js::InlinePhase, inlinee) ||
  174. PHASE_OFF(Js::GlobOptPhase, inlinee) ||
  175. !ContinueInliningUserDefinedFunctions(this->bytecodeInlinedCount) ||
  176. this->isInDebugMode)
  177. {
  178. return nullptr;
  179. }
  180. if (functionInfo->IsDeferred() || inlinee->GetByteCode() == nullptr)
  181. {
  182. // DeferredParse...
  183. INLINE_TESTTRACE(_u("INLINING: Skip Inline: No bytecode\tInlinee: %s (%s)\tCaller: %s (%s)\n"),
  184. inlinee->GetDisplayName(), inlinee->GetDebugNumberSet(debugStringBuffer), inliner->GetDisplayName(),
  185. inliner->GetDebugNumberSet(debugStringBuffer2));
  186. return nullptr;
  187. }
  188. if (inlinee->GetHasTry())
  189. {
  190. INLINE_TESTTRACE(_u("INLINING: Skip Inline: Has try\tInlinee: %s (%s)\tCaller: %s (%s)\n"),
  191. inlinee->GetDisplayName(), inlinee->GetDebugNumberSet(debugStringBuffer), inliner->GetDisplayName(),
  192. inliner->GetDebugNumberSet(debugStringBuffer2));
  193. return nullptr;
  194. }
  195. // This is a hard limit as the argOuts array is statically sized.
  196. if (inlinee->GetInParamsCount() > Js::InlineeCallInfo::MaxInlineeArgoutCount)
  197. {
  198. INLINE_TESTTRACE(_u("INLINING: Skip Inline: Params count greater then MaxInlineeArgoutCount\tInlinee: %s (%s)\tParamcount: %d\tMaxInlineeArgoutCount: %d\tCaller: %s (%s)\n"),
  199. inlinee->GetDisplayName(), inlinee->GetDebugNumberSet(debugStringBuffer), inlinee->GetInParamsCount(), Js::InlineeCallInfo::MaxInlineeArgoutCount,
  200. inliner->GetDisplayName(), inliner->GetDebugNumberSet(debugStringBuffer2));
  201. return nullptr;
  202. }
  203. if (inlinee->GetInParamsCount() == 0)
  204. {
  205. // Inline candidate has no params, not even a this pointer. This can only be the global function,
  206. // which we shouldn't inline.
  207. INLINE_TESTTRACE(_u("INLINING: Skip Inline: Params count is zero!\tInlinee: %s (%s)\tParamcount: %d\tCaller: %s (%s)\n"),
  208. inlinee->GetDisplayName(), inlinee->GetDebugNumberSet(debugStringBuffer), inlinee->GetInParamsCount(),
  209. inliner->GetDisplayName(), inliner->GetDebugNumberSet(debugStringBuffer2));
  210. return nullptr;
  211. }
  212. if (inlinee->GetDontInline())
  213. {
  214. INLINE_TESTTRACE(_u("INLINING: Skip Inline: Do not inline\tInlinee: %s (%s)\tCaller: %s (%s)\n"),
  215. inlinee->GetDisplayName(), inlinee->GetDebugNumberSet(debugStringBuffer), inliner->GetDisplayName(),
  216. inliner->GetDebugNumberSet(debugStringBuffer2));
  217. return nullptr;
  218. }
  219. // Do not inline a call to a class constructor if it isn't part of a new expression since the call will throw a TypeError anyway.
  220. if (inlinee->IsClassConstructor() && !isConstructorCall)
  221. {
  222. INLINE_TESTTRACE(_u("INLINING: Skip Inline: Class constructor without new keyword\tInlinee: %s (%s)\tCaller: %s (%s)\n"),
  223. inlinee->GetDisplayName(), inlinee->GetDebugNumberSet(debugStringBuffer), inliner->GetDisplayName(),
  224. inliner->GetDebugNumberSet(debugStringBuffer2));
  225. return nullptr;
  226. }
  227. if (!DeciderInlineIntoInliner(inlinee, inliner, isConstructorCall, isPolymorphicCall, constantArgInfo, recursiveInlineDepth, allowRecursiveInlining))
  228. {
  229. return nullptr;
  230. }
  231. #if defined(ENABLE_DEBUG_CONFIG_OPTIONS)
  232. TraceInlining(inliner, inlinee->GetDisplayName(), inlinee->GetDebugNumberSet(debugStringBuffer), inlinee->GetByteCodeCount(), this->topFunc, this->bytecodeInlinedCount, inlinee, callSiteId, this->isLoopBody);
  233. #endif
  234. this->bytecodeInlinedCount += inlinee->GetByteCodeCount();
  235. return inlinee->GetFunctionInfo();
  236. }
  237. Js::OpCode builtInInlineCandidateOpCode;
  238. ValueType builtInReturnType;
  239. GetBuiltInInfo(functionInfo, &builtInInlineCandidateOpCode, &builtInReturnType);
  240. if(builtInInlineCandidateOpCode == 0 && builtInReturnType.IsUninitialized())
  241. {
  242. return nullptr;
  243. }
  244. Assert(this->jitMode == ExecutionMode::FullJit);
  245. if (builtInInlineCandidateOpCode != 0 &&
  246. (
  247. PHASE_OFF(Js::InlinePhase, inliner) ||
  248. PHASE_OFF(Js::GlobOptPhase, inliner) ||
  249. isConstructorCall
  250. ))
  251. {
  252. return nullptr;
  253. }
  254. // Note: for built-ins at this time we don't have enough data (the instr) to decide whether it's going to be inlined.
  255. return functionInfo;
  256. }
  257. // TODO OOP JIT: add FunctionInfo interface so we can combine these?
  258. /* static */
  259. bool InliningDecider::GetBuiltInInfo(
  260. const FunctionJITTimeInfo *const funcInfo,
  261. Js::OpCode *const inlineCandidateOpCode,
  262. ValueType *const returnType
  263. )
  264. {
  265. Assert(funcInfo);
  266. Assert(inlineCandidateOpCode);
  267. Assert(returnType);
  268. *inlineCandidateOpCode = (Js::OpCode)0;
  269. *returnType = ValueType::Uninitialized;
  270. if (funcInfo->HasBody())
  271. {
  272. return false;
  273. }
  274. return InliningDecider::GetBuiltInInfoCommon(
  275. funcInfo->GetLocalFunctionId(),
  276. inlineCandidateOpCode,
  277. returnType);
  278. }
  279. /* static */
  280. bool InliningDecider::GetBuiltInInfo(
  281. Js::FunctionInfo *const funcInfo,
  282. Js::OpCode *const inlineCandidateOpCode,
  283. ValueType *const returnType
  284. )
  285. {
  286. Assert(funcInfo);
  287. Assert(inlineCandidateOpCode);
  288. Assert(returnType);
  289. *inlineCandidateOpCode = (Js::OpCode)0;
  290. *returnType = ValueType::Uninitialized;
  291. if (funcInfo->HasBody())
  292. {
  293. return false;
  294. }
  295. return InliningDecider::GetBuiltInInfoCommon(
  296. funcInfo->GetLocalFunctionId(),
  297. inlineCandidateOpCode,
  298. returnType);
  299. }
  300. bool InliningDecider::GetBuiltInInfoCommon(
  301. uint localFuncId,
  302. Js::OpCode *const inlineCandidateOpCode,
  303. ValueType *const returnType
  304. )
  305. {
  306. // TODO: consider adding another column to JavascriptBuiltInFunctionList.h/LibraryFunction.h
  307. // and getting helper method from there instead of multiple switch labels. And for return value types too.
  308. switch (localFuncId)
  309. {
  310. case Js::JavascriptBuiltInFunction::Math_Abs:
  311. *inlineCandidateOpCode = Js::OpCode::InlineMathAbs;
  312. break;
  313. case Js::JavascriptBuiltInFunction::Math_Acos:
  314. *inlineCandidateOpCode = Js::OpCode::InlineMathAcos;
  315. break;
  316. case Js::JavascriptBuiltInFunction::Math_Asin:
  317. *inlineCandidateOpCode = Js::OpCode::InlineMathAsin;
  318. break;
  319. case Js::JavascriptBuiltInFunction::Math_Atan:
  320. *inlineCandidateOpCode = Js::OpCode::InlineMathAtan;
  321. break;
  322. case Js::JavascriptBuiltInFunction::Math_Atan2:
  323. *inlineCandidateOpCode = Js::OpCode::InlineMathAtan2;
  324. break;
  325. case Js::JavascriptBuiltInFunction::Math_Cos:
  326. *inlineCandidateOpCode = Js::OpCode::InlineMathCos;
  327. break;
  328. case Js::JavascriptBuiltInFunction::Math_Exp:
  329. *inlineCandidateOpCode = Js::OpCode::InlineMathExp;
  330. break;
  331. case Js::JavascriptBuiltInFunction::Math_Log:
  332. *inlineCandidateOpCode = Js::OpCode::InlineMathLog;
  333. break;
  334. case Js::JavascriptBuiltInFunction::Math_Pow:
  335. *inlineCandidateOpCode = Js::OpCode::InlineMathPow;
  336. break;
  337. case Js::JavascriptBuiltInFunction::Math_Sin:
  338. *inlineCandidateOpCode = Js::OpCode::InlineMathSin;
  339. break;
  340. case Js::JavascriptBuiltInFunction::Math_Sqrt:
  341. *inlineCandidateOpCode = Js::OpCode::InlineMathSqrt;
  342. break;
  343. case Js::JavascriptBuiltInFunction::Math_Tan:
  344. *inlineCandidateOpCode = Js::OpCode::InlineMathTan;
  345. break;
  346. case Js::JavascriptBuiltInFunction::Math_Floor:
  347. *inlineCandidateOpCode = Js::OpCode::InlineMathFloor;
  348. break;
  349. case Js::JavascriptBuiltInFunction::Math_Ceil:
  350. *inlineCandidateOpCode = Js::OpCode::InlineMathCeil;
  351. break;
  352. case Js::JavascriptBuiltInFunction::Math_Round:
  353. *inlineCandidateOpCode = Js::OpCode::InlineMathRound;
  354. break;
  355. case Js::JavascriptBuiltInFunction::Math_Min:
  356. *inlineCandidateOpCode = Js::OpCode::InlineMathMin;
  357. break;
  358. case Js::JavascriptBuiltInFunction::Math_Max:
  359. *inlineCandidateOpCode = Js::OpCode::InlineMathMax;
  360. break;
  361. case Js::JavascriptBuiltInFunction::Math_Imul:
  362. *inlineCandidateOpCode = Js::OpCode::InlineMathImul;
  363. break;
  364. case Js::JavascriptBuiltInFunction::Math_Clz32:
  365. *inlineCandidateOpCode = Js::OpCode::InlineMathClz;
  366. break;
  367. case Js::JavascriptBuiltInFunction::Math_Random:
  368. *inlineCandidateOpCode = Js::OpCode::InlineMathRandom;
  369. break;
  370. case Js::JavascriptBuiltInFunction::Math_Fround:
  371. *inlineCandidateOpCode = Js::OpCode::InlineMathFround;
  372. *returnType = ValueType::Float;
  373. break;
  374. case Js::JavascriptBuiltInFunction::JavascriptArray_Push:
  375. *inlineCandidateOpCode = Js::OpCode::InlineArrayPush;
  376. break;
  377. case Js::JavascriptBuiltInFunction::JavascriptArray_Pop:
  378. *inlineCandidateOpCode = Js::OpCode::InlineArrayPop;
  379. break;
  380. case Js::JavascriptBuiltInFunction::JavascriptArray_Concat:
  381. case Js::JavascriptBuiltInFunction::JavascriptArray_Reverse:
  382. case Js::JavascriptBuiltInFunction::JavascriptArray_Shift:
  383. case Js::JavascriptBuiltInFunction::JavascriptArray_Slice:
  384. case Js::JavascriptBuiltInFunction::JavascriptArray_Splice:
  385. case Js::JavascriptBuiltInFunction::JavascriptString_Link:
  386. case Js::JavascriptBuiltInFunction::JavascriptString_LocaleCompare:
  387. goto CallDirectCommon;
  388. case Js::JavascriptBuiltInFunction::JavascriptArray_Join:
  389. case Js::JavascriptBuiltInFunction::JavascriptString_CharAt:
  390. case Js::JavascriptBuiltInFunction::JavascriptString_Concat:
  391. case Js::JavascriptBuiltInFunction::JavascriptString_FromCharCode:
  392. case Js::JavascriptBuiltInFunction::JavascriptString_FromCodePoint:
  393. case Js::JavascriptBuiltInFunction::JavascriptString_Replace:
  394. case Js::JavascriptBuiltInFunction::JavascriptString_Slice:
  395. case Js::JavascriptBuiltInFunction::JavascriptString_Substr:
  396. case Js::JavascriptBuiltInFunction::JavascriptString_Substring:
  397. case Js::JavascriptBuiltInFunction::JavascriptString_ToLocaleLowerCase:
  398. case Js::JavascriptBuiltInFunction::JavascriptString_ToLocaleUpperCase:
  399. case Js::JavascriptBuiltInFunction::JavascriptString_ToLowerCase:
  400. case Js::JavascriptBuiltInFunction::JavascriptString_ToUpperCase:
  401. case Js::JavascriptBuiltInFunction::JavascriptString_Trim:
  402. case Js::JavascriptBuiltInFunction::JavascriptString_TrimLeft:
  403. case Js::JavascriptBuiltInFunction::JavascriptString_TrimRight:
  404. case Js::JavascriptBuiltInFunction::JavascriptString_PadStart:
  405. case Js::JavascriptBuiltInFunction::JavascriptString_PadEnd:
  406. *returnType = ValueType::String;
  407. goto CallDirectCommon;
  408. case Js::JavascriptBuiltInFunction::JavascriptArray_Includes:
  409. *returnType = ValueType::Boolean;
  410. goto CallDirectCommon;
  411. case Js::JavascriptBuiltInFunction::JavascriptArray_IndexOf:
  412. case Js::JavascriptBuiltInFunction::JavascriptArray_LastIndexOf:
  413. case Js::JavascriptBuiltInFunction::JavascriptArray_Unshift:
  414. case Js::JavascriptBuiltInFunction::JavascriptString_CharCodeAt:
  415. case Js::JavascriptBuiltInFunction::JavascriptString_IndexOf:
  416. case Js::JavascriptBuiltInFunction::JavascriptString_LastIndexOf:
  417. case Js::JavascriptBuiltInFunction::JavascriptString_Search:
  418. case Js::JavascriptBuiltInFunction::JavascriptRegExp_SymbolSearch:
  419. case Js::JavascriptBuiltInFunction::GlobalObject_ParseInt:
  420. *returnType = ValueType::GetNumberAndLikelyInt(true);
  421. goto CallDirectCommon;
  422. case Js::JavascriptBuiltInFunction::JavascriptString_Split:
  423. *returnType = ValueType::GetObject(ObjectType::Array).SetHasNoMissingValues(true).SetArrayTypeId(Js::TypeIds_Array);
  424. goto CallDirectCommon;
  425. case Js::JavascriptBuiltInFunction::JavascriptString_Match:
  426. case Js::JavascriptBuiltInFunction::JavascriptRegExp_Exec:
  427. *returnType =
  428. ValueType::GetObject(ObjectType::Array).SetHasNoMissingValues(true).SetArrayTypeId(Js::TypeIds_Array)
  429. .Merge(ValueType::Null);
  430. goto CallDirectCommon;
  431. CallDirectCommon:
  432. *inlineCandidateOpCode = Js::OpCode::CallDirect;
  433. break;
  434. case Js::JavascriptBuiltInFunction::JavascriptFunction_Apply:
  435. *inlineCandidateOpCode = Js::OpCode::InlineFunctionApply;
  436. break;
  437. case Js::JavascriptBuiltInFunction::JavascriptFunction_Call:
  438. *inlineCandidateOpCode = Js::OpCode::InlineFunctionCall;
  439. break;
  440. // The following are not currently inlined, but are tracked for their return type
  441. // TODO: Add more built-ins that return objects. May consider tracking all built-ins.
  442. case Js::JavascriptBuiltInFunction::JavascriptArray_NewInstance:
  443. *returnType = ValueType::GetObject(ObjectType::Array).SetHasNoMissingValues(true).SetArrayTypeId(Js::TypeIds_Array);
  444. break;
  445. case Js::JavascriptBuiltInFunction::Int8Array_NewInstance:
  446. #ifdef _M_X64
  447. *returnType = (!PHASE_OFF1(Js::TypedArrayVirtualPhase)) ? ValueType::GetObject(ObjectType::Int8MixedArray) : ValueType::GetObject(ObjectType::Int8Array);
  448. #else
  449. *returnType = ValueType::GetObject(ObjectType::Int8Array);
  450. #endif
  451. break;
  452. case Js::JavascriptBuiltInFunction::Uint8Array_NewInstance:
  453. #ifdef _M_X64
  454. *returnType = (!PHASE_OFF1(Js::TypedArrayVirtualPhase)) ? ValueType::GetObject(ObjectType::Uint8MixedArray) : ValueType::GetObject(ObjectType::Uint8Array);
  455. #else
  456. *returnType = ValueType::GetObject(ObjectType::Uint8Array);
  457. #endif
  458. break;
  459. case Js::JavascriptBuiltInFunction::Uint8ClampedArray_NewInstance:
  460. #ifdef _M_X64
  461. *returnType = (!PHASE_OFF1(Js::TypedArrayVirtualPhase)) ? ValueType::GetObject(ObjectType::Uint8ClampedMixedArray) : ValueType::GetObject(ObjectType::Uint8ClampedArray);
  462. #else
  463. *returnType = ValueType::GetObject(ObjectType::Uint8ClampedArray);
  464. #endif
  465. break;
  466. case Js::JavascriptBuiltInFunction::Int16Array_NewInstance:
  467. #ifdef _M_X64
  468. *returnType = (!PHASE_OFF1(Js::TypedArrayVirtualPhase)) ? ValueType::GetObject(ObjectType::Int16MixedArray) : ValueType::GetObject(ObjectType::Int16Array);
  469. #else
  470. *returnType = ValueType::GetObject(ObjectType::Int16Array);
  471. #endif
  472. break;
  473. case Js::JavascriptBuiltInFunction::Uint16Array_NewInstance:
  474. #ifdef _M_X64
  475. *returnType = (!PHASE_OFF1(Js::TypedArrayVirtualPhase)) ? ValueType::GetObject(ObjectType::Uint16MixedArray) : ValueType::GetObject(ObjectType::Uint16Array);
  476. #else
  477. *returnType = ValueType::GetObject(ObjectType::Uint16Array);
  478. #endif
  479. break;
  480. case Js::JavascriptBuiltInFunction::Int32Array_NewInstance:
  481. #ifdef _M_X64
  482. *returnType = (!PHASE_OFF1(Js::TypedArrayVirtualPhase)) ? ValueType::GetObject(ObjectType::Int32MixedArray) : ValueType::GetObject(ObjectType::Int32Array);
  483. #else
  484. *returnType = ValueType::GetObject(ObjectType::Int32Array);
  485. #endif
  486. break;
  487. case Js::JavascriptBuiltInFunction::Uint32Array_NewInstance:
  488. #ifdef _M_X64
  489. *returnType = (!PHASE_OFF1(Js::TypedArrayVirtualPhase)) ? ValueType::GetObject(ObjectType::Uint32MixedArray) : ValueType::GetObject(ObjectType::Uint32Array);
  490. #else
  491. *returnType = ValueType::GetObject(ObjectType::Uint32Array);
  492. #endif
  493. break;
  494. case Js::JavascriptBuiltInFunction::Float32Array_NewInstance:
  495. #ifdef _M_X64
  496. *returnType = (!PHASE_OFF1(Js::TypedArrayVirtualPhase)) ? ValueType::GetObject(ObjectType::Float32MixedArray) : ValueType::GetObject(ObjectType::Float32Array);
  497. #else
  498. *returnType = ValueType::GetObject(ObjectType::Float32Array);
  499. #endif
  500. break;
  501. case Js::JavascriptBuiltInFunction::Float64Array_NewInstance:
  502. #ifdef _M_X64
  503. *returnType = (!PHASE_OFF1(Js::TypedArrayVirtualPhase)) ? ValueType::GetObject(ObjectType::Float64MixedArray) : ValueType::GetObject(ObjectType::Float64Array);
  504. #else
  505. *returnType = ValueType::GetObject(ObjectType::Float64Array);
  506. #endif
  507. break;
  508. case Js::JavascriptBuiltInFunction::Int64Array_NewInstance:
  509. *returnType = ValueType::GetObject(ObjectType::Int64Array);
  510. break;
  511. case Js::JavascriptBuiltInFunction::Uint64Array_NewInstance:
  512. *returnType = ValueType::GetObject(ObjectType::Uint64Array);
  513. break;
  514. case Js::JavascriptBuiltInFunction::BoolArray_NewInstance:
  515. *returnType = ValueType::GetObject(ObjectType::BoolArray);
  516. break;
  517. case Js::JavascriptBuiltInFunction::CharArray_NewInstance:
  518. *returnType = ValueType::GetObject(ObjectType::CharArray);
  519. break;
  520. #ifdef ENABLE_DOM_FAST_PATH
  521. case Js::JavascriptBuiltInFunction::DOMFastPathGetter:
  522. *inlineCandidateOpCode = Js::OpCode::DOMFastPathGetter;
  523. break;
  524. #endif
  525. #ifdef ENABLE_SIMDJS
  526. // SIMD_JS
  527. // we only inline, and hence type-spec on IA
  528. #if defined(_M_X64) || defined(_M_IX86)
  529. default:
  530. {
  531. #if 0 // TODO OOP JIT, inline SIMD
  532. // inline only if simdjs and simd128 type-spec is enabled.
  533. if (scriptContext->GetConfig()->IsSimdjsEnabled() && SIMD128_TYPE_SPEC_FLAG)
  534. {
  535. *inlineCandidateOpCode = scriptContext->GetThreadContext()->GetSimdOpcodeFromFuncInfo(funcInfo);
  536. }
  537. else
  538. #endif
  539. {
  540. return false;
  541. }
  542. }
  543. #endif
  544. #endif // ENABLE_SIMDJS
  545. }
  546. return true;
  547. }
  548. bool InliningDecider::CanRecursivelyInline(Js::FunctionBody * inlinee, Js::FunctionBody *inliner, bool allowRecursiveInlining, uint recursiveInlineDepth)
  549. {
  550. #if defined(DBG_DUMP) || defined(ENABLE_DEBUG_CONFIG_OPTIONS)
  551. char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  552. char16 debugStringBuffer2[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  553. #endif
  554. if (!PHASE_OFF(Js::InlineRecursivePhase, inliner)
  555. && allowRecursiveInlining
  556. && inlinee == inliner
  557. && inlinee->CanInlineRecursively(recursiveInlineDepth))
  558. {
  559. INLINE_TESTTRACE(_u("INLINING: Inlined recursively\tInlinee: %s (%s)\tCaller: %s (%s)\tDepth: %d\n"),
  560. inlinee->GetDisplayName(), inlinee->GetDebugNumberSet(debugStringBuffer),
  561. inliner->GetDisplayName(), inliner->GetDebugNumberSet(debugStringBuffer2), recursiveInlineDepth);
  562. return true;
  563. }
  564. if (!inlinee->CanInlineAgain())
  565. {
  566. INLINE_TESTTRACE(_u("INLINING: Skip Inline: Do not inline recursive functions\tInlinee: %s (%s)\tCaller: %s (%s)\n"),
  567. inlinee->GetDisplayName(), inlinee->GetDebugNumberSet(debugStringBuffer),
  568. inliner->GetDisplayName(), inliner->GetDebugNumberSet(debugStringBuffer2));
  569. return false;
  570. }
  571. return true;
  572. }
  573. // This only enables collection of the inlinee data, we are much more aggressive here.
  574. // Actual decision of whether something is inlined or not is taken in CommitInlineIntoInliner
  575. bool InliningDecider::DeciderInlineIntoInliner(Js::FunctionBody * inlinee, Js::FunctionBody * inliner, bool isConstructorCall, bool isPolymorphicCall, uint16 constantArgInfo, uint recursiveInlineDepth, bool allowRecursiveInlining)
  576. {
  577. if (!CanRecursivelyInline(inlinee, inliner, allowRecursiveInlining, recursiveInlineDepth))
  578. {
  579. return false;
  580. }
  581. if (inlinee->GetIsAsmjsMode() || inliner->GetIsAsmjsMode())
  582. {
  583. return false;
  584. }
  585. if (PHASE_FORCE(Js::InlinePhase, this->topFunc) ||
  586. PHASE_FORCE(Js::InlinePhase, inliner) ||
  587. PHASE_FORCE(Js::InlinePhase, inlinee))
  588. {
  589. return true;
  590. }
  591. if (PHASE_OFF(Js::InlinePhase, this->topFunc) ||
  592. PHASE_OFF(Js::InlinePhase, inliner) ||
  593. PHASE_OFF(Js::InlinePhase, inlinee))
  594. {
  595. return false;
  596. }
  597. if (PHASE_FORCE(Js::InlineTreePhase, this->topFunc) ||
  598. PHASE_FORCE(Js::InlineTreePhase, inliner))
  599. {
  600. return true;
  601. }
  602. if (PHASE_FORCE(Js::InlineAtEveryCallerPhase, inlinee))
  603. {
  604. return true;
  605. }
  606. uint inlineeByteCodeCount = inlinee->GetByteCodeWithoutLDACount();
  607. // Heuristics are hit in the following order (Note *order* is important)
  608. // 1. Leaf function: If the inlinee is a leaf (but not a constructor or a polymorphic call) inline threshold is LeafInlineThreshold (60). Also it can have max 1 loop
  609. // 2. Constant Function Argument: If the inlinee candidate has a constant argument and that argument is used for branching, then the inline threshold is ConstantArgumentInlineThreshold (157)
  610. // 3. InlineThreshold: If an inlinee candidate exceeds InlineThreshold just don't inline no matter what.
  611. // Following are additional constraint for an inlinee which meets InlineThreshold (Rule no 3)
  612. // 4. Rule for inlinee with loops:
  613. // 4a. Only single loop in inlinee is permitted.
  614. // 4b. Should not have polymorphic field access.
  615. // 4c. Should not be a constructor.
  616. // 4d. Should meet LoopInlineThreshold (25)
  617. // 5. Rule for polymorphic inlinee:
  618. // 4a. Should meet PolymorphicInlineThreshold (32)
  619. // 6. Rule for constructors:
  620. // 5a. Always inline if inlinee has polymorphic field access (as we have cloned runtime data).
  621. // 5b. If inlinee is monomorphic, inline only small constructors. They are governed by ConstructorInlineThreshold (21)
  622. // 7. Rule for inlinee which is not interpreted enough (as we might not have all the profile data):
  623. // 7a. As of now it is still governed by the InlineThreshold. Plan to play with this in future.
  624. // 8. Rest should be inlined.
  625. uint16 mask = constantArgInfo & inlinee->m_argUsedForBranch;
  626. if (mask && inlineeByteCodeCount < (uint)CONFIG_FLAG(ConstantArgumentInlineThreshold))
  627. {
  628. return true;
  629. }
  630. int inlineThreshold = threshold.inlineThreshold;
  631. if (!isPolymorphicCall && !isConstructorCall && IsInlineeLeaf(inlinee) && (inlinee->GetLoopCount() <= 2))
  632. {
  633. // Inlinee is a leaf function
  634. if (inlinee->GetLoopCount() == 0 || GetNumberOfInlineesWithLoop() <= (uint)threshold.maxNumberOfInlineesWithLoop) // Don't inlinee too many inlinees with loops.
  635. {
  636. // Negative LeafInlineThreshold disable the threshold
  637. if (threshold.leafInlineThreshold >= 0)
  638. {
  639. inlineThreshold += threshold.leafInlineThreshold - threshold.inlineThreshold;
  640. }
  641. }
  642. }
  643. #if ENABLE_DEBUG_CONFIG_OPTIONS
  644. char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  645. char16 debugStringBuffer2[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  646. char16 debugStringBuffer3[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  647. #endif
  648. if (inlinee->GetHasLoops())
  649. {
  650. if (threshold.loopInlineThreshold < 0 || // Negative LoopInlineThreshold disable inlining with loop
  651. GetNumberOfInlineesWithLoop() >(uint)threshold.maxNumberOfInlineesWithLoop || // See if we are inlining too many inlinees with loops.
  652. (inlinee->GetLoopCount() > 2) || // Allow at most 2 loops.
  653. inlinee->GetHasNestedLoop() || // Nested loops are not a good inlinee candidate
  654. isConstructorCall || // If the function is constructor with loops, don't inline.
  655. PHASE_OFF(Js::InlineFunctionsWithLoopsPhase, this->topFunc))
  656. {
  657. INLINE_TESTTRACE(_u("INLINING: Skip Inline: Has loops \tBytecode size: %d \tgetNumberOfInlineesWithLoop: %d\tloopCount: %d\thasNestedLoop: %B\tisConstructorCall:%B\tInlinee: %s (%s)\tCaller: %s (%s) \tRoot: %s (%s)\n"),
  658. inlinee->GetByteCodeCount(),
  659. GetNumberOfInlineesWithLoop(),
  660. inlinee->GetLoopCount(),
  661. inlinee->GetHasNestedLoop(),
  662. isConstructorCall,
  663. inlinee->GetDisplayName(), inlinee->GetDebugNumberSet(debugStringBuffer),
  664. inliner->GetDisplayName(), inliner->GetDebugNumberSet(debugStringBuffer2),
  665. topFunc->GetDisplayName(), topFunc->GetDebugNumberSet(debugStringBuffer3));
  666. // Don't inline function with loops
  667. return false;
  668. }
  669. else
  670. {
  671. inlineThreshold -= (threshold.inlineThreshold > threshold.loopInlineThreshold) ? threshold.inlineThreshold - threshold.loopInlineThreshold : 0;
  672. }
  673. }
  674. if (isPolymorphicCall)
  675. {
  676. if (threshold.polymorphicInlineThreshold < 0 || // Negative PolymorphicInlineThreshold disable inlining
  677. isConstructorCall)
  678. {
  679. INLINE_TESTTRACE(_u("INLINING: Skip Inline: Polymorphic call under PolymorphicInlineThreshold: %d \tBytecode size: %d\tInlinee: %s (%s)\tCaller: %s (%s) \tRoot: %s (%s)\n"),
  680. threshold.polymorphicInlineThreshold,
  681. inlinee->GetByteCodeCount(),
  682. inlinee->GetDisplayName(), inlinee->GetDebugNumberSet(debugStringBuffer),
  683. inliner->GetDisplayName(), inliner->GetDebugNumberSet(debugStringBuffer2),
  684. topFunc->GetDisplayName(), topFunc->GetDebugNumberSet(debugStringBuffer3));
  685. return false;
  686. }
  687. else
  688. {
  689. inlineThreshold -= (threshold.inlineThreshold > threshold.polymorphicInlineThreshold) ? threshold.inlineThreshold - threshold.polymorphicInlineThreshold : 0;
  690. }
  691. }
  692. if (isConstructorCall)
  693. {
  694. #pragma prefast(suppress: 6285, "logical-or of constants is by design")
  695. if (PHASE_OFF(Js::InlineConstructorsPhase, this->topFunc) ||
  696. PHASE_OFF(Js::InlineConstructorsPhase, inliner) ||
  697. PHASE_OFF(Js::InlineConstructorsPhase, inlinee) ||
  698. !CONFIG_FLAG(CloneInlinedPolymorphicCaches))
  699. {
  700. return false;
  701. }
  702. if (PHASE_FORCE(Js::InlineConstructorsPhase, this->topFunc) ||
  703. PHASE_FORCE(Js::InlineConstructorsPhase, inliner) ||
  704. PHASE_FORCE(Js::InlineConstructorsPhase, inlinee))
  705. {
  706. return true;
  707. }
  708. if (inlinee->HasDynamicProfileInfo() && inlinee->GetAnyDynamicProfileInfo()->HasPolymorphicFldAccess())
  709. {
  710. // As of now this is not dependent on bytecodeInlinedThreshold.
  711. return true;
  712. }
  713. // Negative ConstructorInlineThreshold always disable constructor inlining
  714. if (threshold.constructorInlineThreshold < 0)
  715. {
  716. INLINE_TESTTRACE(_u("INLINING: Skip Inline: Constructor with no polymorphic field access \tBytecode size: %d\tInlinee: %s (%s)\tCaller: %s (%s) \tRoot: %s (%s)\n"),
  717. inlinee->GetByteCodeCount(),
  718. inlinee->GetDisplayName(), inlinee->GetDebugNumberSet(debugStringBuffer),
  719. inliner->GetDisplayName(), inliner->GetDebugNumberSet(debugStringBuffer2),
  720. topFunc->GetDisplayName(), topFunc->GetDebugNumberSet(debugStringBuffer3));
  721. // Don't inline constructor that does not have a polymorphic field access, or if cloning polymorphic inline
  722. // caches is disabled
  723. return false;
  724. }
  725. else
  726. {
  727. inlineThreshold -= (threshold.inlineThreshold > threshold.constructorInlineThreshold) ? threshold.inlineThreshold - threshold.constructorInlineThreshold : 0;
  728. }
  729. }
  730. if (threshold.forLoopBody)
  731. {
  732. inlineThreshold /= CONFIG_FLAG(InlineInLoopBodyScaleDownFactor);
  733. }
  734. if (inlineThreshold > 0 && inlineeByteCodeCount <= (uint)inlineThreshold)
  735. {
  736. if (inlinee->GetLoopCount())
  737. {
  738. IncrementNumberOfInlineesWithLoop();
  739. }
  740. return true;
  741. }
  742. else
  743. {
  744. return false;
  745. }
  746. }
  747. bool InliningDecider::ContinueInliningUserDefinedFunctions(uint32 bytecodeInlinedCount) const
  748. {
  749. #if ENABLE_DEBUG_CONFIG_OPTIONS
  750. char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  751. #endif
  752. if (PHASE_FORCE(Js::InlinePhase, this->topFunc) || bytecodeInlinedCount <= (uint)this->threshold.inlineCountMax)
  753. {
  754. return true;
  755. }
  756. INLINE_TESTTRACE(_u("INLINING: Skip Inline: InlineCountMax threshold %d, reached: %s (#%s)\n"),
  757. (uint)this->threshold.inlineCountMax,
  758. this->topFunc->GetDisplayName(), this->topFunc->GetDebugNumberSet(debugStringBuffer));
  759. return false;
  760. }
  761. #if defined(ENABLE_DEBUG_CONFIG_OPTIONS)
  762. // static
  763. void InliningDecider::TraceInlining(Js::FunctionBody *const inliner, const char16* inlineeName, const char16* inlineeFunctionIdandNumberString, uint inlineeByteCodeCount,
  764. Js::FunctionBody* topFunc, uint inlinedByteCodeCount, Js::FunctionBody *const inlinee, uint callSiteId, bool inLoopBody, uint builtIn)
  765. {
  766. char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  767. char16 debugStringBuffer2[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  768. char16 debugStringBuffer3[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
  769. if (inlineeName == nullptr)
  770. {
  771. int len = swprintf_s(debugStringBuffer3, MAX_FUNCTION_BODY_DEBUG_STRING_SIZE, _u("built In Id: %u"), builtIn);
  772. Assert(len > 14);
  773. inlineeName = debugStringBuffer3;
  774. }
  775. INLINE_TESTTRACE(_u("INLINING %s: Inlinee: %s (%s)\tSize: %d\tCaller: %s (%s)\tSize: %d\tInlineCount: %d\tRoot: %s (%s)\tSize: %d\tCallSiteId: %d\n"),
  776. inLoopBody ? _u("IN LOOP BODY") : _u(""),
  777. inlineeName, inlineeFunctionIdandNumberString, inlineeByteCodeCount,
  778. inliner->GetDisplayName(), inliner->GetDebugNumberSet(debugStringBuffer), inliner->GetByteCodeCount(),
  779. inlinedByteCodeCount,
  780. topFunc->GetDisplayName(), topFunc->GetDebugNumberSet(debugStringBuffer2), topFunc->GetByteCodeCount(),
  781. callSiteId
  782. );
  783. INLINE_TRACE(_u("INLINING %s: Inlinee: %s(%s)\tSize : %d\tCaller : %s(%s)\tSize : %d\tInlineCount : %d\tRoot : %s(%s)\tSize : %d\tCallSiteId : %d\n"),
  784. inLoopBody ? _u("IN LOOP BODY") : _u(""),
  785. inlineeName, inlineeFunctionIdandNumberString, inlineeByteCodeCount,
  786. inliner->GetDisplayName(), inliner->GetDebugNumberSet(debugStringBuffer), inliner->GetByteCodeCount(),
  787. inlinedByteCodeCount,
  788. topFunc->GetDisplayName(), topFunc->GetDebugNumberSet(debugStringBuffer2), topFunc->GetByteCodeCount(),
  789. callSiteId
  790. );
  791. // Now Trace inlining across files cases
  792. if (builtIn != -1) // built-in functions
  793. {
  794. return;
  795. }
  796. Assert(inliner && inlinee);
  797. if (inliner->GetSourceContextId() != inlinee->GetSourceContextId())
  798. {
  799. INLINE_TESTTRACE(_u("INLINING_ACROSS_FILES: Inlinee: %s (%s)\tSize: %d\tCaller: %s (%s)\tSize: %d\tInlineCount: %d\tRoot: %s (%s)\tSize: %d\n"),
  800. inlinee->GetDisplayName(), inlinee->GetDebugNumberSet(debugStringBuffer), inlinee->GetByteCodeCount(),
  801. inliner->GetDisplayName(), inliner->GetDebugNumberSet(debugStringBuffer2), inliner->GetByteCodeCount(), inlinedByteCodeCount,
  802. topFunc->GetDisplayName(), topFunc->GetDebugNumberSet(debugStringBuffer3), topFunc->GetByteCodeCount()
  803. );
  804. INLINE_TRACE(_u("INLINING_ACROSS_FILES: Inlinee: %s (%s)\tSize: %d\tCaller: %s (%s)\tSize: %d\tInlineCount: %d\tRoot: %s (%s)\tSize: %d\n"),
  805. inlinee->GetDisplayName(), inlinee->GetDebugNumberSet(debugStringBuffer), inlinee->GetByteCodeCount(),
  806. inliner->GetDisplayName(), inliner->GetDebugNumberSet(debugStringBuffer2), inliner->GetByteCodeCount(), inlinedByteCodeCount,
  807. topFunc->GetDisplayName(), topFunc->GetDebugNumberSet(debugStringBuffer3), topFunc->GetByteCodeCount()
  808. );
  809. }
  810. }
  811. #endif