blob: 0e0bfca91fee86e5bd1cf89286e909a182943ad1 (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
#ifndef _FPTRSTUBS_H
#define _FPTRSTUBS_H
#include "common.h"
// FuncPtrStubs contains stubs that is used by GetMultiCallableAddrOfCode() if
// the function has not been jitted. Using a stub decouples ldftn from
// the prestub, so prestub does not need to be backpatched.
//
// This stub is also used in other places which need a function pointer
class FuncPtrStubs
{
public :
FuncPtrStubs();
Precode* Lookup(MethodDesc * pMD, PrecodeType type);
PCODE GetFuncPtrStub(MethodDesc * pMD, PrecodeType type);
Precode* Lookup(MethodDesc * pMD)
{
return Lookup(pMD, GetDefaultType(pMD));
}
PCODE GetFuncPtrStub(MethodDesc * pMD)
{
return GetFuncPtrStub(pMD, GetDefaultType(pMD));
}
static PrecodeType GetDefaultType(MethodDesc* pMD);
private:
Crst m_hashTableCrst;
struct PrecodeKey
{
PrecodeKey(MethodDesc* pMD, PrecodeType type)
: m_pMD(pMD), m_type(type)
{
}
MethodDesc* m_pMD;
PrecodeType m_type;
};
class PrecodeTraits : public NoRemoveSHashTraits< DefaultSHashTraits<Precode*> >
{
public:
typedef PrecodeKey key_t;
static key_t GetKey(element_t e)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
}
CONTRACTL_END;
return PrecodeKey(e->GetMethodDesc(), e->GetType());
}
static BOOL Equals(key_t k1, key_t k2)
{
LIMITED_METHOD_CONTRACT;
return (k1.m_pMD == k2.m_pMD) && (k1.m_type == k2.m_type);
}
static count_t Hash(key_t k)
{
LIMITED_METHOD_CONTRACT;
return (count_t)(size_t)k.m_pMD ^ k.m_type;
}
};
SHash<PrecodeTraits> m_hashTable; // To find a existing stub for a method
};
#endif // _FPTRSTUBS_H
|