Skip to content

Commit c8403e6

Browse files
Delete extra layers (#116405)
* Delete extra layer of metadata APIs * Delegate extra layer of coreclr directory caching Co-authored-by: Aaron Robinson <[email protected]>
1 parent 4878886 commit c8403e6

37 files changed

+65
-611
lines changed

src/coreclr/binder/utils.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include "clr/fs/path.h"
1919
using namespace clr::fs;
2020

21+
// Forward declaration - see src/vm/util.cpp
22+
BOOL RuntimeFileNotFound(HRESULT hr);
23+
2124
namespace BINDER_SPACE
2225
{
2326
namespace

src/coreclr/debug/daccess/daccess.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "peimagelayout.inl"
1818
#include "datatargetadapter.h"
1919
#include "readonlydatatargetfacade.h"
20-
#include "metadataexports.h"
2120
#include "excep.h"
2221
#include "debugger.h"
2322
#include "dwreport.h"

src/coreclr/debug/daccess/task.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,6 @@
1111

1212
#include "stdafx.h"
1313

14-
// XXX Microsoft - Why aren't these extra MD APIs in a header?
15-
STDAPI GetMDPublicInterfaceFromInternal(
16-
void *pIUnkPublic, // [IN] Given scope.
17-
REFIID riid, // [in] The interface desired.
18-
void **ppIUnkInternal); // [out] Return interface on success.
19-
20-
STDAPI GetMetaDataPublicInterfaceFromInternal(
21-
void *pv, // [IN] Given interface.
22-
REFIID riid, // [IN] desired interface.
23-
void **ppv) // [OUT] returned interface
24-
{
25-
return GetMDPublicInterfaceFromInternal(pv, riid, ppv);
26-
}
27-
2814
//----------------------------------------------------------------------------
2915
//
3016
// ClrDataTask.

src/coreclr/debug/di/cordb.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "classfactory.h"
1414
#include "corsym.h"
1515
#include "contract.h"
16-
#include "metadataexports.h"
1716
#if defined(FEATURE_DBGIPC_TRANSPORT_DI)
1817
#include "dbgtransportsession.h"
1918
#include "dbgtransportmanager.h"

src/coreclr/debug/di/module.cpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,13 @@
1010
#include "stdafx.h"
1111
#include "winbase.h"
1212

13-
#include "metadataexports.h"
14-
1513
#include "winbase.h"
1614
#include "corpriv.h"
1715
#include "corsym.h"
1816

1917
#include "pedecoder.h"
2018
#include "stgpool.h"
2119

22-
//---------------------------------------------------------------------------------------
23-
// Update an existing metadata importer with a buffer
24-
//
25-
// Arguments:
26-
// pUnk - IUnknoown of importer to update.
27-
// pData - local buffer containing new metadata
28-
// cbData - size of buffer in bytes.
29-
// dwReOpenFlags - metadata flags to pass for reopening.
30-
//
31-
// Returns:
32-
// S_OK on success. Else failure.
33-
//
34-
// Notes:
35-
// This will call code:MDReOpenMetaDataWithMemoryEx from the metadata engine.
36-
STDAPI ReOpenMetaDataWithMemoryEx(
37-
void *pUnk,
38-
LPCVOID pData,
39-
ULONG cbData,
40-
DWORD dwReOpenFlags)
41-
{
42-
HRESULT hr = MDReOpenMetaDataWithMemoryEx(pUnk,pData, cbData, dwReOpenFlags);
43-
return hr;
44-
}
45-
4620
//---------------------------------------------------------------------------------------
4721
// Initialize a new CordbModule around a Module in the target.
4822
//
@@ -1063,7 +1037,7 @@ void CordbModule::UpdatePublicMetaDataFromRemote(TargetBuffer bufferRemoteMetaDa
10631037
// Now tell our current IMetaDataImport object to re-initialize by swapping in the new memory block.
10641038
// This allows us to keep manipulating metadata objects on other threads without crashing.
10651039
// This will also invalidate an existing associated Internal MetaData.
1066-
hr = ReOpenMetaDataWithMemoryEx(m_pIMImport, pLocalMetaDataPtr, dwMetaDataSize, ofTakeOwnership );
1040+
hr = MDReOpenMetaDataWithMemory(m_pIMImport, pLocalMetaDataPtr, dwMetaDataSize, ofTakeOwnership );
10671041
IfFailThrow(hr);
10681042

10691043
// Success. MetaData now owns the metadata memory

src/coreclr/debug/di/process.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
// @dbgtodo shim: process has some private hooks into the shim.
2727
#include "shimpriv.h"
2828

29-
#include "metadataexports.h"
3029
#include "readonlydatatargetfacade.h"
3130
#include "metahost.h"
3231

src/coreclr/dlls/mscoree/mscoree.cpp

Lines changed: 2 additions & 218 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,7 @@
66
#include "stdafx.h" // Standard header.
77

88
#include <utilcode.h> // Utility helpers.
9-
#include <posterror.h> // Error handlers
10-
#define INIT_GUIDS
119
#include <corpriv.h>
12-
#include <winwrap.h>
13-
#include <mscoree.h>
14-
#include "shimload.h"
15-
#include "metadataexports.h"
16-
#include "ex.h"
17-
18-
#include <dbgenginemetrics.h>
1910

2011
#if !defined(CORECLR_EMBEDDED)
2112

@@ -45,18 +36,16 @@ BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
4536

4637
#endif // !defined(CORECLR_EMBEDDED)
4738

48-
extern void* GetClrModuleBase();
49-
5039
// ---------------------------------------------------------------------------
5140
// %%Function: MetaDataGetDispenser
5241
// This function gets the Dispenser interface given the CLSID and REFIID.
42+
// Exported from coreclr and used by external profilers.
5343
// ---------------------------------------------------------------------------
54-
STDAPI DLLEXPORT MetaDataGetDispenser( // Return HRESULT
44+
STDAPI DLLEXPORT MetaDataGetDispenser( // Return HRESULT
5545
REFCLSID rclsid, // The class to desired.
5646
REFIID riid, // Interface wanted on class factory.
5747
LPVOID FAR *ppv) // Return interface pointer here.
5848
{
59-
6049
CONTRACTL {
6150
NOTHROW;
6251
GC_NOTRIGGER;
@@ -69,208 +58,3 @@ STDAPI DLLEXPORT MetaDataGetDispenser( // Return HRESULT
6958

7059
return CreateMetaDataDispenser(riid, ppv);
7160
}
72-
73-
// ---------------------------------------------------------------------------
74-
// %%Function: GetMetaDataInternalInterface
75-
// This function gets the IMDInternalImport given the metadata on memory.
76-
// ---------------------------------------------------------------------------
77-
STDAPI DLLEXPORT GetMetaDataInternalInterface(
78-
LPVOID pData, // [IN] in memory metadata section
79-
ULONG cbData, // [IN] size of the metadata section
80-
DWORD flags, // [IN] MDInternal_OpenForRead or MDInternal_OpenForENC
81-
REFIID riid, // [IN] desired interface
82-
void **ppv) // [OUT] returned interface
83-
{
84-
CONTRACTL{
85-
NOTHROW;
86-
GC_NOTRIGGER;
87-
ENTRY_POINT;
88-
PRECONDITION(CheckPointer(pData));
89-
PRECONDITION(CheckPointer(ppv));
90-
} CONTRACTL_END;
91-
92-
return GetMDInternalInterface(pData, cbData, flags, riid, ppv);
93-
}
94-
95-
// ---------------------------------------------------------------------------
96-
// %%Function: GetMetaDataInternalInterfaceFromPublic
97-
// This function gets the internal scopeless interface given the public
98-
// scopeless interface.
99-
// ---------------------------------------------------------------------------
100-
STDAPI DLLEXPORT GetMetaDataInternalInterfaceFromPublic(
101-
IUnknown *pv, // [IN] Given interface.
102-
REFIID riid, // [IN] desired interface
103-
void **ppv) // [OUT] returned interface
104-
{
105-
CONTRACTL{
106-
NOTHROW;
107-
GC_NOTRIGGER;
108-
ENTRY_POINT;
109-
PRECONDITION(CheckPointer(pv));
110-
PRECONDITION(CheckPointer(ppv));
111-
} CONTRACTL_END;
112-
113-
return GetMDInternalInterfaceFromPublic(pv, riid, ppv);
114-
}
115-
116-
// ---------------------------------------------------------------------------
117-
// %%Function: GetMetaDataPublicInterfaceFromInternal
118-
// This function gets the public scopeless interface given the internal
119-
// scopeless interface.
120-
// ---------------------------------------------------------------------------
121-
STDAPI DLLEXPORT GetMetaDataPublicInterfaceFromInternal(
122-
void *pv, // [IN] Given interface.
123-
REFIID riid, // [IN] desired interface.
124-
void **ppv) // [OUT] returned interface
125-
{
126-
CONTRACTL{
127-
NOTHROW;
128-
GC_NOTRIGGER;
129-
PRECONDITION(CheckPointer(pv));
130-
PRECONDITION(CheckPointer(ppv));
131-
ENTRY_POINT;
132-
} CONTRACTL_END;
133-
134-
return GetMDPublicInterfaceFromInternal(pv, riid, ppv);
135-
}
136-
137-
138-
// ---------------------------------------------------------------------------
139-
// %%Function: ReopenMetaDataWithMemory
140-
// This function gets the public scopeless interface given the internal
141-
// scopeless interface.
142-
// ---------------------------------------------------------------------------
143-
STDAPI ReOpenMetaDataWithMemory(
144-
void *pUnk, // [IN] Given scope. public interfaces
145-
LPCVOID pData, // [in] Location of scope data.
146-
ULONG cbData) // [in] Size of the data pointed to by pData.
147-
{
148-
CONTRACTL{
149-
NOTHROW;
150-
GC_NOTRIGGER;
151-
ENTRY_POINT;
152-
PRECONDITION(CheckPointer(pUnk));
153-
PRECONDITION(CheckPointer(pData));
154-
} CONTRACTL_END;
155-
156-
return MDReOpenMetaDataWithMemory(pUnk, pData, cbData);
157-
}
158-
159-
// ---------------------------------------------------------------------------
160-
// %%Function: ReopenMetaDataWithMemoryEx
161-
// This function gets the public scopeless interface given the internal
162-
// scopeless interface.
163-
// ---------------------------------------------------------------------------
164-
STDAPI ReOpenMetaDataWithMemoryEx(
165-
void *pUnk, // [IN] Given scope. public interfaces
166-
LPCVOID pData, // [in] Location of scope data.
167-
ULONG cbData, // [in] Size of the data pointed to by pData.
168-
DWORD dwReOpenFlags) // [in] ReOpen flags
169-
{
170-
CONTRACTL{
171-
NOTHROW;
172-
GC_NOTRIGGER;
173-
ENTRY_POINT;
174-
PRECONDITION(CheckPointer(pUnk));
175-
PRECONDITION(CheckPointer(pData));
176-
} CONTRACTL_END;
177-
178-
return MDReOpenMetaDataWithMemoryEx(pUnk, pData, cbData, dwReOpenFlags);
179-
}
180-
181-
static DWORD g_dwSystemDirectory = 0;
182-
static WCHAR * g_pSystemDirectory = NULL;
183-
184-
HRESULT GetInternalSystemDirectory(_Out_writes_to_opt_(*pdwLength,*pdwLength) LPWSTR buffer, __inout DWORD* pdwLength)
185-
{
186-
CONTRACTL {
187-
NOTHROW;
188-
GC_NOTRIGGER;
189-
PRECONDITION(CheckPointer(buffer, NULL_OK));
190-
PRECONDITION(CheckPointer(pdwLength));
191-
} CONTRACTL_END;
192-
193-
if (g_dwSystemDirectory == 0)
194-
SetInternalSystemDirectory();
195-
196-
//
197-
// g_dwSystemDirectory includes the NULL in its count!
198-
//
199-
if(*pdwLength < g_dwSystemDirectory)
200-
{
201-
*pdwLength = g_dwSystemDirectory;
202-
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
203-
}
204-
205-
if (buffer != NULL)
206-
{
207-
//
208-
// wcsncpy_s will automatically append a null and g_dwSystemDirectory
209-
// includes the null in its count, so we have to subtract 1.
210-
//
211-
wcsncpy_s(buffer, *pdwLength, g_pSystemDirectory, g_dwSystemDirectory-1);
212-
}
213-
*pdwLength = g_dwSystemDirectory;
214-
return S_OK;
215-
}
216-
217-
218-
LPCWSTR GetInternalSystemDirectory(_Out_ DWORD* pdwLength)
219-
{
220-
LIMITED_METHOD_CONTRACT;
221-
222-
if (g_dwSystemDirectory == 0)
223-
{
224-
SetInternalSystemDirectory();
225-
}
226-
227-
if (pdwLength != NULL)
228-
{
229-
* pdwLength = g_dwSystemDirectory;
230-
}
231-
232-
return g_pSystemDirectory;
233-
}
234-
235-
236-
HRESULT SetInternalSystemDirectory()
237-
{
238-
CONTRACTL {
239-
NOTHROW;
240-
GC_NOTRIGGER;
241-
} CONTRACTL_END;
242-
243-
HRESULT hr = S_OK;
244-
if(g_dwSystemDirectory == 0) {
245-
246-
DWORD len = 0;
247-
NewArrayHolder<WCHAR> pSystemDirectory;
248-
EX_TRY{
249-
250-
// use local buffer for thread safety
251-
PathString wzSystemDirectory;
252-
hr = GetClrModuleDirectory(wzSystemDirectory);
253-
254-
if (FAILED(hr)) {
255-
wzSystemDirectory.Set(W('\0'));
256-
}
257-
258-
pSystemDirectory = wzSystemDirectory.GetCopyOfUnicodeString();
259-
if (pSystemDirectory == NULL)
260-
{
261-
hr = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
262-
}
263-
len = wzSystemDirectory.GetCount() + 1;
264-
265-
}
266-
EX_CATCH_HRESULT(hr);
267-
268-
// publish results idempotently with correct memory ordering
269-
g_pSystemDirectory = pSystemDirectory.Extract();
270-
271-
(void)InterlockedExchange((LONG *)&g_dwSystemDirectory, len);
272-
}
273-
274-
return hr;
275-
}
276-

src/coreclr/ilasm/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include "asmparse.h"
1111
#include "clrversion.h"
12-
#include "shimload.h"
1312

1413
#include "strsafe.h"
1514
#define ASSERTE_ALL_BUILDS(expr) _ASSERTE_ALL_BUILDS((expr))

src/coreclr/ilasm/writer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#include "ceefilegenwriter.h"
1212
#include "sha256.h"
1313

14-
#include "metadataexports.h"
15-
1614
#ifndef _MSC_VER
1715
//cloned definition from ntimage.h that is removed for non MSVC builds
1816
typedef VOID

src/coreclr/ildasm/dasm.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <metamodelpub.h>
1313
#include "formattype.h"
1414
#include "readytorun.h"
15-
#include "metadataexports.h"
1615

1716
#define DECLARE_DATA
1817
#include "dasmenum.hpp"

src/coreclr/ildasm/dman.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include "dynamicarray.h"
1717
#include "resource.h"
1818

19-
#include "metadataexports.h"
20-
2119
#ifndef MAX_LOCALE_NAME
2220
#define MAX_LOCALE_NAME (32)
2321
#endif

0 commit comments

Comments
 (0)