summaryrefslogtreecommitdiff
path: root/src/vm/domainfile.inl
blob: 1b9a057fe710eca20f33ad550db8a26200f13883 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

// 

inline Module* DomainFile::GetCurrentModule() 
{ 
    LIMITED_METHOD_CONTRACT;
    STATIC_CONTRACT_SO_TOLERANT;
    SUPPORTS_DAC;

    return m_pModule; 
}

inline Module* DomainFile::GetLoadedModule() 
{ 
    LIMITED_METHOD_CONTRACT;

    {
        // CheckLoaded() eventually calls PEFile::GetNativeImageWithRef(), which
        // takes a reader lock on the file's m_pMetadataLock.  However, this is
        // only done in debug for the consistency check, so we can accept the lock violation.
        CONTRACT_VIOLATION(TakesLockViolation);
        CONSISTENCY_CHECK(CheckLoaded());
    }

    return m_pModule;
}

inline Module* DomainFile::GetModule()
{ 
    LIMITED_METHOD_CONTRACT;
    SUPPORTS_DAC;

    {
        // While executing the consistency check, we will take a lock.
        // But since this is debug-only, we'll allow the lock violation so that
        // CANNOT_TAKE_LOCK callers aren't penalized
        CONTRACT_VIOLATION(TakesLockViolation);
        CONSISTENCY_CHECK(CheckLoadLevel(FILE_LOAD_ALLOCATE));
    }

    return m_pModule; 
}

inline Assembly* DomainAssembly::GetCurrentAssembly()
{
    LIMITED_METHOD_CONTRACT;
    STATIC_CONTRACT_SO_TOLERANT;

    return m_pAssembly;
}

inline Assembly* DomainAssembly::GetLoadedAssembly()
{
    LIMITED_METHOD_DAC_CONTRACT;

    {
        // CheckLoaded() eventually calls PEFile::GetNativeImageWithRef(), which
        // takes a reader lock on the file's m_pMetadataLock.  However, this is
        // only done in debug for the consistency check, so we can accept the lock violation.
        CONTRACT_VIOLATION(TakesLockViolation);
        CONSISTENCY_CHECK(CheckLoaded());
    }

    return m_pAssembly;
}

inline Assembly* DomainAssembly::GetAssembly()
{
    LIMITED_METHOD_CONTRACT;
    STATIC_CONTRACT_SO_TOLERANT;

    {
        // CheckLoadLevel() is SO_INTOLERANT.  However, this is only done in
        // debug for the consistency check, so we can accept the SO violation.
        CONTRACT_VIOLATION(SOToleranceViolation);
        CONSISTENCY_CHECK(CheckLoadLevel(FILE_LOAD_ALLOCATE));
    }
    return m_pAssembly;
}

#ifndef DACCESS_COMPILE
inline void DomainFile::UpdatePEFileWorker(PTR_PEFile pFile)
{
    LIMITED_METHOD_CONTRACT;
    CONSISTENCY_CHECK(CheckPointer(pFile));
    if (pFile==m_pFile)
        return;
    _ASSERTE(m_pOriginalFile==NULL);
    m_pOriginalFile=m_pFile;
    pFile->AddRef();
    m_pFile=pFile;
}

inline void DomainAssembly::UpdatePEFile(PTR_PEFile pFile)
{
    CONTRACTL
    {
        THROWS;
        GC_NOTRIGGER;
        MODE_ANY;
        CAN_TAKE_LOCK;
    }
    CONTRACTL_END;

#ifdef FEATURE_HOSTED_BINDER
    GetAppDomain()->UpdatePublishHostedAssembly(this, pFile);
#else
    this->UpdatePEFileWorker(pFile);
#endif
}

#ifdef FEATURE_MULTIMODULE_ASSEMBLIES
inline void DomainModule::UpdatePEFile(PTR_PEFile pFile)
{
    LIMITED_METHOD_CONTRACT;
    
    this->UpdatePEFileWorker(pFile);
}
#endif // FEATURE_MULTIMODULE_ASSEMBLIES
#endif // DACCESS_COMPILE

inline ULONG DomainAssembly::HashIdentity()
{
    WRAPPER_NO_CONTRACT;
    return GetFile()->HashIdentity();
}

inline BOOL DomainAssembly::IsCollectible()
{
    LIMITED_METHOD_CONTRACT;
    return m_fCollectible;
}