InliningDecider.cpp 39 KB

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