InliningHeuristics.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #pragma once
  6. class InliningDecider;
  7. struct InliningThreshold
  8. {
  9. uint nonLoadByteCodeCount;
  10. bool forLoopBody;
  11. bool asmjs;
  12. int inlineThreshold;
  13. int constructorInlineThreshold;
  14. int outsideLoopInlineThreshold;
  15. int leafInlineThreshold;
  16. int loopInlineThreshold;
  17. int polymorphicInlineThreshold;
  18. int inlineCountMax;
  19. int maxNumberOfInlineesWithLoop;
  20. int constantArgumentInlineThreshold;
  21. InliningThreshold(uint nonLoadByteCodeCount, bool forLoopBody, bool asmjs);
  22. void SetHeuristics();
  23. void SetAggressiveHeuristics();
  24. void Reset();
  25. };
  26. class InliningHeuristics
  27. {
  28. friend class ::InliningDecider;
  29. const FunctionJITTimeInfo * topFunc;
  30. InliningThreshold threshold;
  31. public:
  32. public:
  33. InliningHeuristics(const FunctionJITTimeInfo * topFunc, bool forLoopBody) :topFunc(topFunc), threshold(topFunc->GetBody()->GetNonLoadByteCodeCount(), forLoopBody, topFunc->GetBody()->IsAsmJsMode()) {};
  34. bool BackendInlineIntoInliner(const FunctionJITTimeInfo * inlinee,
  35. Func * inliner,
  36. Func *topFunc,
  37. Js::ProfileId,
  38. bool isConstructorCall,
  39. bool isFixedMethodCall,
  40. bool isCallOutsideLoopInTopFunc,
  41. bool isCallInsideLoop,
  42. uint recursiveInlineDepth,
  43. uint16 constantArguments
  44. );
  45. private:
  46. static bool IsInlineeLeaf(const FunctionJITTimeInfo * inlinee)
  47. {
  48. return inlinee->GetBody()->HasProfileInfo()
  49. && (!PHASE_OFF(Js::InlineBuiltInCallerPhase, inlinee) ? !inlinee->GetBody()->HasNonBuiltInCallee() : inlinee->GetBody()->GetProfiledCallSiteCount() == 0)
  50. && !inlinee->GetBody()->GetReadOnlyProfileInfo()->HasLdFldCallSiteInfo();
  51. }
  52. };