-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathInliningHeuristics.h
62 lines (52 loc) · 2.26 KB
/
InliningHeuristics.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
class InliningDecider;
struct InliningThreshold
{
uint nonLoadByteCodeCount;
bool forLoopBody;
bool asmjs;
int inlineThreshold;
int constructorInlineThreshold;
int outsideLoopInlineThreshold;
int leafInlineThreshold;
int loopInlineThreshold;
int polymorphicInlineThreshold;
int inlineCountMax;
int maxNumberOfInlineesWithLoop;
int constantArgumentInlineThreshold;
InliningThreshold(uint nonLoadByteCodeCount, bool forLoopBody, bool asmjs);
void SetHeuristics();
void SetAggressiveHeuristics();
void Reset();
};
class InliningHeuristics
{
friend class ::InliningDecider;
const FunctionJITTimeInfo * topFunc;
InliningThreshold threshold;
public:
public:
InliningHeuristics(const FunctionJITTimeInfo * topFunc, bool forLoopBody) :topFunc(topFunc), threshold(topFunc->GetBody()->GetNonLoadByteCodeCount(), forLoopBody, topFunc->GetBody()->IsAsmJsMode()) {};
bool BackendInlineIntoInliner(const FunctionJITTimeInfo * inlinee,
Func * inliner,
Func *topFunc,
Js::ProfileId,
bool isConstructorCall,
bool isFixedMethodCall,
bool isCallOutsideLoopInTopFunc,
bool isCallInsideLoop,
uint recursiveInlineDepth,
uint16 constantArguments
);
private:
static bool IsInlineeLeaf(const FunctionJITTimeInfo * inlinee)
{
return inlinee->GetBody()->HasProfileInfo()
&& (!PHASE_OFF(Js::InlineBuiltInCallerPhase, inlinee) ? !inlinee->GetBody()->HasNonBuiltInCallee() : inlinee->GetBody()->GetProfiledCallSiteCount() == 0)
&& !inlinee->GetBody()->GetReadOnlyProfileInfo()->HasLdFldCallSiteInfo();
}
};