summaryrefslogtreecommitdiff
path: root/src/jit/stacklevelsetter.h
blob: 984cf5490d093514468bcc1c86297d44eb45b2d1 (plain)
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#pragma once

#include "compiler.h"
#include "phase.h"

class StackLevelSetter : public Phase
{
public:
    StackLevelSetter(Compiler* compiler);

    virtual void DoPhase() override;

private:
    void ProcessBlock(BasicBlock* block);

#if !FEATURE_FIXED_OUT_ARGS
    void SetThrowHelperBlocks(GenTree* node, BasicBlock* block);
    void SetThrowHelperBlock(SpecialCodeKind kind, BasicBlock* block);
#endif // !FEATURE_FIXED_OUT_ARGS

    unsigned PopArgumentsFromCall(GenTreeCall* call);
    void AddStackLevel(unsigned value);
    void SubStackLevel(unsigned value);

    void CheckArgCnt();
    void CheckAdditionalArgs();

private:
    unsigned currentStackLevel; // current number of stack slots used by arguments.
    unsigned maxStackLevel;     // max number of stack slots for arguments.

    CompAllocator memAllocator;

    typedef JitHashTable<GenTreePutArgStk*, JitPtrKeyFuncs<GenTreePutArgStk>, unsigned> PutArgNumSlotsMap;
    PutArgNumSlotsMap putArgNumSlots; // The hash table keeps stack slot sizes for active GT_PUTARG_STK nodes.

#if !FEATURE_FIXED_OUT_ARGS
    bool framePointerRequired;  // Is frame pointer required based on the analysis made by this phase.
    bool throwHelperBlocksUsed; // Were any throw helper blocks created for this method.
#endif                          // !FEATURE_FIXED_OUT_ARGS
};