未验证 提交 c2249c8f 编写于 作者: A Adeel Mujahid 提交者: GitHub

Delete unused code (#75814)

* Delete unused code

* Fix casing of mscoree.idl

* Delete START/STOP_MD_PERF macros
上级 e1944f1f
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/*=============================================================================
**
** Interface: _Exception
**
**
** Purpose: COM backwards compatibility with v1 Exception
** object layout.
**
**
=============================================================================*/
namespace System.Runtime.InteropServices {
using System;
using System.Reflection;
using System.Runtime.Serialization;
[Guid("b36b5c63-42ef-38bc-a07e-0b34c98f164a")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[CLSCompliant(false)]
internal interface _Exception
{
//
// This method is intentionally included in CoreCLR to make Exception.get_InnerException "newslot virtual final".
// Some phone apps include MEF from desktop Silverlight. MEF's ComposablePartException depends on implicit interface
// implementations of get_InnerException to be provided by the base class. It works only if Exception.get_InnerException
// is virtual.
//
Exception? InnerException {
get;
}
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include <pal.h>
#include <pal_assert.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/stat.h>
#include "diagnosticsipc.h"
#include "processdescriptor.h"
#if __GNUC__
#include <poll.h>
#else
#include <sys/poll.h>
#endif // __GNUC__
IpcStream::DiagnosticsIpc::DiagnosticsIpc(const int serverSocket, sockaddr_un *const pServerAddress, ConnectionMode mode) :
mode(mode),
_serverSocket(serverSocket),
_pServerAddress(new sockaddr_un),
_isClosed(false),
_isListening(false)
{
_ASSERTE(_pServerAddress != nullptr);
_ASSERTE(pServerAddress != nullptr);
if (_pServerAddress == nullptr || pServerAddress == nullptr)
return;
memcpy(_pServerAddress, pServerAddress, sizeof(sockaddr_un));
}
IpcStream::DiagnosticsIpc::~DiagnosticsIpc()
{
Close();
delete _pServerAddress;
}
IpcStream::DiagnosticsIpc *IpcStream::DiagnosticsIpc::Create(const char *const pIpcName, ConnectionMode mode, ErrorCallback callback)
{
sockaddr_un serverAddress{};
serverAddress.sun_family = AF_UNIX;
if (pIpcName != nullptr)
{
int chars = snprintf(serverAddress.sun_path, sizeof(serverAddress.sun_path), "%s", pIpcName);
_ASSERTE(chars > 0 && (unsigned int)chars < sizeof(serverAddress.sun_path));
}
else
{
// generate the default socket name in TMP Path
const ProcessDescriptor pd = ProcessDescriptor::FromCurrentProcess();
PAL_GetTransportName(
sizeof(serverAddress.sun_path),
serverAddress.sun_path,
"dotnet-diagnostic",
pd.m_Pid,
pd.m_ApplicationGroupId,
"socket");
}
if (mode == ConnectionMode::CONNECT)
return new IpcStream::DiagnosticsIpc(-1, &serverAddress, ConnectionMode::CONNECT);
#if defined(__APPLE__) || defined(__FreeBSD__)
mode_t prev_mask = umask(~(S_IRUSR | S_IWUSR)); // This will set the default permission bit to 600
#endif // __APPLE__
const int serverSocket = ::socket(AF_UNIX, SOCK_STREAM, 0);
if (serverSocket == -1)
{
if (callback != nullptr)
callback(strerror(errno), errno);
#if defined(__APPLE__) || defined(__FreeBSD__)
umask(prev_mask);
#endif // __APPLE__
_ASSERTE(!"Failed to create diagnostics IPC socket.");
return nullptr;
}
#if !(defined(__APPLE__) || defined(__FreeBSD__))
if (fchmod(serverSocket, S_IRUSR | S_IWUSR) == -1)
{
if (callback != nullptr)
callback(strerror(errno), errno);
_ASSERTE(!"Failed to set permissions on diagnostics IPC socket.");
return nullptr;
}
#endif // __APPLE__
const int fSuccessBind = ::bind(serverSocket, (sockaddr *)&serverAddress, sizeof(serverAddress));
if (fSuccessBind == -1)
{
if (callback != nullptr)
callback(strerror(errno), errno);
_ASSERTE(fSuccessBind != -1);
const int fSuccessClose = ::close(serverSocket);
_ASSERTE(fSuccessClose != -1);
#if defined(__APPLE__) || defined(__FreeBSD__)
umask(prev_mask);
#endif // __APPLE__
return nullptr;
}
#if defined(__APPLE__) || defined(__FreeBSD__)
umask(prev_mask);
#endif // __APPLE__
return new IpcStream::DiagnosticsIpc(serverSocket, &serverAddress, mode);
}
bool IpcStream::DiagnosticsIpc::Listen(ErrorCallback callback)
{
_ASSERTE(mode == ConnectionMode::LISTEN);
if (mode != ConnectionMode::LISTEN)
{
if (callback != nullptr)
callback("Cannot call Listen on a client connection", -1);
return false;
}
if (_isListening)
return true;
const int fSuccessfulListen = ::listen(_serverSocket, /* backlog */ 255);
if (fSuccessfulListen == -1)
{
if (callback != nullptr)
callback(strerror(errno), errno);
_ASSERTE(fSuccessfulListen != -1);
const int fSuccessUnlink = ::unlink(_pServerAddress->sun_path);
_ASSERTE(fSuccessUnlink != -1);
const int fSuccessClose = ::close(_serverSocket);
_ASSERTE(fSuccessClose != -1);
return false;
}
else
{
_isListening = true;
return true;
}
}
IpcStream *IpcStream::DiagnosticsIpc::Accept(ErrorCallback callback)
{
_ASSERTE(mode == ConnectionMode::LISTEN);
_ASSERTE(_isListening);
sockaddr_un from;
socklen_t fromlen = sizeof(from);
const int clientSocket = ::accept(_serverSocket, (sockaddr *)&from, &fromlen);
if (clientSocket == -1)
{
if (callback != nullptr)
callback(strerror(errno), errno);
return nullptr;
}
return new IpcStream(clientSocket, mode);
}
IpcStream *IpcStream::DiagnosticsIpc::Connect(ErrorCallback callback)
{
_ASSERTE(mode == ConnectionMode::CONNECT);
sockaddr_un clientAddress{};
clientAddress.sun_family = AF_UNIX;
const int clientSocket = ::socket(AF_UNIX, SOCK_STREAM, 0);
if (clientSocket == -1)
{
if (callback != nullptr)
callback(strerror(errno), errno);
return nullptr;
}
// We don't expect this to block since this is a Unix Domain Socket. `connect` may block until the
// TCP handshake is complete for TCP/IP sockets, but UDS don't use TCP. `connect` will return even if
// the server hasn't called `accept`.
if (::connect(clientSocket, (struct sockaddr *)_pServerAddress, sizeof(*_pServerAddress)) < 0)
{
if (callback != nullptr)
callback(strerror(errno), errno);
const bool fCloseSuccess = ::close(clientSocket) == 0;
if (!fCloseSuccess && callback != nullptr)
callback(strerror(errno), errno);
return nullptr;
}
return new IpcStream(clientSocket, ConnectionMode::CONNECT);
}
int32_t IpcStream::DiagnosticsIpc::Poll(IpcPollHandle *rgIpcPollHandles, uint32_t nHandles, int32_t timeoutMs, ErrorCallback callback)
{
// prepare the pollfd structs
pollfd *pollfds = new pollfd[nHandles];
for (uint32_t i = 0; i < nHandles; i++)
{
rgIpcPollHandles[i].revents = 0; // ignore any values in revents
int fd = -1;
if (rgIpcPollHandles[i].pIpc != nullptr)
{
// SERVER
_ASSERTE(rgIpcPollHandles[i].pIpc->mode == ConnectionMode::LISTEN);
fd = rgIpcPollHandles[i].pIpc->_serverSocket;
}
else
{
// CLIENT
_ASSERTE(rgIpcPollHandles[i].pStream != nullptr);
fd = rgIpcPollHandles[i].pStream->_clientSocket;
}
pollfds[i].fd = fd;
pollfds[i].events = POLLIN;
}
int retval = poll(pollfds, nHandles, timeoutMs);
// Check results
if (retval < 0)
{
// If poll() returns with an error, including one due to an interrupted call, the fds
// array will be unmodified and the global variable errno will be set to indicate the error.
// - POLL(2)
if (callback != nullptr)
callback(strerror(errno), errno);
delete[] pollfds;
return -1;
}
else if (retval == 0)
{
// we timed out
delete[] pollfds;
return 0;
}
for (uint32_t i = 0; i < nHandles; i++)
{
if (pollfds[i].revents != 0)
{
if (callback != nullptr)
callback("IpcStream::DiagnosticsIpc::Poll - poll revents", (uint32_t)pollfds[i].revents);
// error check FIRST
if (pollfds[i].revents & POLLHUP)
{
// check for hangup first because a closed socket
// will technically meet the requirements for POLLIN
// i.e., a call to recv/read won't block
rgIpcPollHandles[i].revents = (uint8_t)PollEvents::HANGUP;
}
else if ((pollfds[i].revents & (POLLERR|POLLNVAL)))
{
if (callback != nullptr)
callback("Poll error", (uint32_t)pollfds[i].revents);
rgIpcPollHandles[i].revents = (uint8_t)PollEvents::ERR;
}
else if (pollfds[i].revents & (POLLIN|POLLPRI))
{
rgIpcPollHandles[i].revents = (uint8_t)PollEvents::SIGNALED;
}
else
{
rgIpcPollHandles[i].revents = (uint8_t)PollEvents::UNKNOWN;
if (callback != nullptr)
callback("unknown poll response", (uint32_t)pollfds[i].revents);
}
}
}
delete[] pollfds;
return 1;
}
void IpcStream::DiagnosticsIpc::Close(bool isShutdown, ErrorCallback callback)
{
if (_isClosed)
return;
_isClosed = true;
if (_serverSocket != -1)
{
// only close the socket if not shutting down, let the OS handle it in that case
if (!isShutdown && ::close(_serverSocket) == -1)
{
if (callback != nullptr)
callback(strerror(errno), errno);
_ASSERTE(!"Failed to close unix domain socket.");
}
// N.B. - it is safe to unlink the unix domain socket file while the server
// is still alive:
// "The usual UNIX close-behind semantics apply; the socket can be unlinked
// at any time and will be finally removed from the file system when the last
// reference to it is closed." - unix(7) man page
Unlink(callback);
}
}
// This helps remove the socket from the filesystem when the runtime exits.
// See: http://man7.org/linux/man-pages/man7/unix.7.html#NOTES
void IpcStream::DiagnosticsIpc::Unlink(ErrorCallback callback)
{
const int fSuccessUnlink = ::unlink(_pServerAddress->sun_path);
if (fSuccessUnlink == -1)
{
if (callback != nullptr)
callback(strerror(errno), errno);
_ASSERTE(!"Failed to unlink server address.");
}
}
IpcStream::~IpcStream()
{
Close();
}
void IpcStream::Close(ErrorCallback)
{
if (_clientSocket != -1)
{
Flush();
const int fSuccessClose = ::close(_clientSocket);
_ASSERTE(fSuccessClose != -1);
_clientSocket = -1;
}
}
bool IpcStream::Read(void *lpBuffer, const uint32_t nBytesToRead, uint32_t &nBytesRead, const int32_t timeoutMs)
{
_ASSERTE(lpBuffer != nullptr);
if (timeoutMs != InfiniteTimeout)
{
pollfd pfd;
pfd.fd = _clientSocket;
pfd.events = POLLIN;
int retval = poll(&pfd, 1, timeoutMs);
if (retval <= 0 || !(pfd.revents & POLLIN))
{
// timeout or error
return false;
}
// else fallthrough
}
uint8_t *lpBufferCursor = (uint8_t*)lpBuffer;
ssize_t currentBytesRead = 0;
ssize_t totalBytesRead = 0;
bool fSuccess = true;
while (fSuccess && nBytesToRead - totalBytesRead > 0)
{
currentBytesRead = ::recv(_clientSocket, lpBufferCursor, nBytesToRead - totalBytesRead, 0);
fSuccess = currentBytesRead != 0;
if (!fSuccess)
break;
totalBytesRead += currentBytesRead;
lpBufferCursor += currentBytesRead;
}
if (!fSuccess)
{
// TODO: Add error handling.
}
nBytesRead = static_cast<uint32_t>(totalBytesRead);
return fSuccess;
}
bool IpcStream::Write(const void *lpBuffer, const uint32_t nBytesToWrite, uint32_t &nBytesWritten, const int32_t timeoutMs)
{
_ASSERTE(lpBuffer != nullptr);
if (timeoutMs != InfiniteTimeout)
{
pollfd pfd;
pfd.fd = _clientSocket;
pfd.events = POLLOUT;
int retval = poll(&pfd, 1, timeoutMs);
if (retval <= 0 || !(pfd.revents & POLLOUT))
{
// timeout or error
return false;
}
// else fallthrough
}
uint8_t *lpBufferCursor = (uint8_t*)lpBuffer;
ssize_t currentBytesWritten = 0;
ssize_t totalBytesWritten = 0;
bool fSuccess = true;
while (fSuccess && nBytesToWrite - totalBytesWritten > 0)
{
currentBytesWritten = ::send(_clientSocket, lpBufferCursor, nBytesToWrite - totalBytesWritten, 0);
fSuccess = currentBytesWritten != -1;
if (!fSuccess)
break;
lpBufferCursor += currentBytesWritten;
totalBytesWritten += currentBytesWritten;
}
if (!fSuccess)
{
// TODO: Add error handling.
}
nBytesWritten = static_cast<uint32_t>(totalBytesWritten);
return fSuccess;
}
bool IpcStream::Flush() const
{
// fsync - http://man7.org/linux/man-pages/man2/fsync.2.html ???
return true;
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#ifndef __DIAGNOSTICS_IPC_H__
#define __DIAGNOSTICS_IPC_H__
#include <stdint.h>
#ifdef TARGET_UNIX
struct sockaddr_un;
#else
#include <Windows.h>
#endif /* TARGET_UNIX */
typedef void (*ErrorCallback)(const char *szMessage, uint32_t code);
class IpcStream final
{
friend class IpcStreamFactory;
public:
static constexpr int32_t InfiniteTimeout = -1;
~IpcStream();
bool Read(void *lpBuffer, const uint32_t nBytesToRead, uint32_t &nBytesRead, const int32_t timeoutMs = IpcStream::InfiniteTimeout);
bool Write(const void *lpBuffer, const uint32_t nBytesToWrite, uint32_t &nBytesWritten, const int32_t timeoutMs = IpcStream::InfiniteTimeout);
bool Flush() const;
void Close(ErrorCallback callback = nullptr);
class DiagnosticsIpc final
{
friend class IpcStreamFactory;
public:
enum ConnectionMode
{
CONNECT,
LISTEN
};
enum class PollEvents : uint8_t
{
NONE = 0x00, // no events
SIGNALED = 0x01, // ready for use
HANGUP = 0x02, // connection remotely closed
ERR = 0x04, // error
UNKNOWN = 0x80 // unknown state
};
// The bookkeeping struct used for polling on server and client structs
struct IpcPollHandle
{
// Only one of these will be non-null, treat as a union
DiagnosticsIpc *pIpc;
IpcStream *pStream;
// contains some set of PollEvents
// will be set by Poll
// Any values here are ignored by Poll
uint8_t revents;
// a cookie assignable by upstream users for additional bookkeeping
void *pUserData;
};
// Poll
// Parameters:
// - IpcPollHandle * rgpIpcPollHandles: Array of IpcPollHandles to poll
// - uint32_t nHandles: The number of handles to poll
// - int32_t timeoutMs: The timeout in milliseconds for the poll (-1 == infinite)
// Returns:
// int32_t: -1 on error, 0 on timeout, >0 on successful poll
// Remarks:
// Check the events returned in revents for each IpcPollHandle to find the signaled handle.
// Signaled DiagnosticsIpcs can call Accept() without blocking.
// Signaled IpcStreams can call Read(...) without blocking.
// The caller is responsible for cleaning up "hung up" connections.
static int32_t Poll(IpcPollHandle *rgIpcPollHandles, uint32_t nHandles, int32_t timeoutMs, ErrorCallback callback = nullptr);
ConnectionMode mode;
~DiagnosticsIpc();
// Creates an IPC object
static DiagnosticsIpc *Create(const char *const pIpcName, ConnectionMode mode, ErrorCallback callback = nullptr);
// puts the DiagnosticsIpc into Listening Mode
// Re-entrant safe
bool Listen(ErrorCallback callback = nullptr);
// produces a connected stream from a server-mode DiagnosticsIpc. Blocks until a connection is available.
IpcStream *Accept(ErrorCallback callback = nullptr);
// Connect to a server and returns a connected stream
IpcStream *Connect(ErrorCallback callback = nullptr);
// Closes an open IPC.
// Only attempts minimal cleanup if isShutdown==true, i.e., unlinks Unix Domain Socket on Linux, no-op on Windows
void Close(bool isShutdown = false, ErrorCallback callback = nullptr);
private:
#ifdef TARGET_UNIX
const int _serverSocket;
sockaddr_un *const _pServerAddress;
bool _isClosed;
DiagnosticsIpc(const int serverSocket, sockaddr_un *const pServerAddress, ConnectionMode mode = ConnectionMode::LISTEN);
// Used to unlink the socket so it can be removed from the filesystem
// when the last reference to it is closed.
void Unlink(ErrorCallback callback = nullptr);
#else
static const uint32_t MaxNamedPipeNameLength = 256;
char _pNamedPipeName[MaxNamedPipeNameLength]; // https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-createnamedpipea
HANDLE _hPipe = INVALID_HANDLE_VALUE;
OVERLAPPED _oOverlap = {};
DiagnosticsIpc(const char(&namedPipeName)[MaxNamedPipeNameLength], ConnectionMode mode = ConnectionMode::LISTEN);
#endif /* TARGET_UNIX */
bool _isListening;
DiagnosticsIpc() = delete;
DiagnosticsIpc(const DiagnosticsIpc &src) = delete;
DiagnosticsIpc(DiagnosticsIpc &&src) = delete;
DiagnosticsIpc &operator=(const DiagnosticsIpc &rhs) = delete;
DiagnosticsIpc &&operator=(DiagnosticsIpc &&rhs) = delete;
};
private:
#ifdef TARGET_UNIX
int _clientSocket = -1;
IpcStream(int clientSocket, DiagnosticsIpc::ConnectionMode mode = DiagnosticsIpc::ConnectionMode::LISTEN)
: _clientSocket(clientSocket), _mode(mode) {}
#else
HANDLE _hPipe = INVALID_HANDLE_VALUE;
OVERLAPPED _oOverlap = {};
BOOL _isTestReading = false; // used to check whether we are already doing a 0-byte read to test for data
IpcStream(HANDLE hPipe, DiagnosticsIpc::ConnectionMode mode = DiagnosticsIpc::ConnectionMode::LISTEN);
#endif /* TARGET_UNIX */
DiagnosticsIpc::ConnectionMode _mode;
IpcStream() = delete;
IpcStream(const IpcStream &src) = delete;
IpcStream(IpcStream &&src) = delete;
IpcStream &operator=(const IpcStream &rhs) = delete;
IpcStream &&operator=(IpcStream &&rhs) = delete;
};
#endif // __DIAGNOSTICS_IPC_H__
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
// GetProductVersionNumber.h
//
// Helper function to retrieve the file version number of a file.
//
// ======================================================================================
#ifndef __GetProductVersionNumber_h__
#define __GetProductVersionNumber_h__
#include "contract.h"
#include "sstring.h"
#include "holder.h"
#include "ex.h"
//---------------------------------------------------------------------------------------
//
// Given the full path to an image, return the product version number.
//
// Arguments:
// szFullPath - full path to the image
// pdwVersionMS - out parameter; return the most significant 4 bytes of the version number according to
// the VS_FIXEDFILEINFO convention
// pdwVersionLS - out parameter; return the least significant 4 bytes of the version number according to
// the VS_FIXEDFILEINFO convention
//
// Notes:
// Throws on error
void inline GetProductVersionNumber(SString &szFullPath, DWORD * pdwVersionMS, DWORD * pdwVersionLS)
{
WRAPPER_NO_CONTRACT;
#ifndef TARGET_UNIX
DWORD dwDummy = 0;
DWORD dwFileInfoSize = 0;
// Get the size of all of the file version information.
dwFileInfoSize = GetFileVersionInfoSize(szFullPath, &dwDummy);
if (dwFileInfoSize == 0)
{
ThrowLastError();
}
// Create the buffer to store the file information.
NewHolder<BYTE> pbFileInfo(new BYTE[dwFileInfoSize]);
// Actually retrieve the file version information.
if (!GetFileVersionInfo(szFullPath, NULL, dwFileInfoSize, pbFileInfo))
{
ThrowLastError();
}
// Now retrieve only the relevant version information, which will be returned in a VS_FIXEDFILEINFO.
UINT uVersionInfoSize = 0;
VS_FIXEDFILEINFO * pVersionInfo = NULL;
if (!VerQueryValue(pbFileInfo, W("\\"), reinterpret_cast<LPVOID *>(&pVersionInfo), &uVersionInfoSize))
{
ThrowLastError();
}
_ASSERTE(uVersionInfoSize == sizeof(VS_FIXEDFILEINFO));
*pdwVersionMS = pVersionInfo->dwProductVersionMS;
*pdwVersionLS = pVersionInfo->dwProductVersionLS;
#else
*pdwVersionMS = 0;
*pdwVersionLS = 0;
#endif // TARGET_UNIX
}
#endif // __GetProductVersionNumber_h__
......@@ -37,7 +37,6 @@ set(MDCOMPILER_HEADERS
disp.h
filtermanager.h
importhelper.h
mdperf.h
mdutil.h
regmeta.h
)
......
......@@ -44,7 +44,6 @@ STDMETHODIMP RegMeta::GetAssemblyProps( // S_OK or error.
mda, ppbPublicKey, pcbPublicKey, pulHashAlgId, szName, cchName, pchName, pMetaData,
pdwAssemblyFlags));
START_MD_PERF();
LOCKREAD();
_ASSERTE(TypeFromToken(mda) == mdtAssembly && RidFromToken(mda));
......@@ -83,7 +82,6 @@ STDMETHODIMP RegMeta::GetAssemblyProps( // S_OK or error.
IfFailGo(pMiniMd->getNameOfAssembly(pRecord, szName, cchName, pchName));
ErrExit:
STOP_MD_PERF(GetAssemblyProps);
END_ENTRYPOINT_NOTHROW;
......@@ -116,7 +114,6 @@ STDMETHODIMP RegMeta::GetAssemblyRefProps( // S_OK or error.
mdar, ppbPublicKeyOrToken, pcbPublicKeyOrToken, szName, cchName,
pchName, pMetaData, ppbHashValue, pdwAssemblyRefFlags));
START_MD_PERF();
LOCKREAD();
_ASSERTE(TypeFromToken(mdar) == mdtAssemblyRef && RidFromToken(mdar));
......@@ -148,7 +145,6 @@ STDMETHODIMP RegMeta::GetAssemblyRefProps( // S_OK or error.
IfFailGo(pMiniMd->getNameOfAssemblyRef(pRecord, szName, cchName, pchName));
ErrExit:
STOP_MD_PERF(GetAssemblyRefProps);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -176,7 +172,6 @@ STDMETHODIMP RegMeta::GetFileProps( // S_OK or error.
LOG((LOGMD, "RegMeta::GetFileProps(%#08x, %#08x, %#08x, %#08x, %#08x, %#08x, %#08x)\n",
mdf, szName, cchName, pchName, ppbHashValue, pcbHashValue, pdwFileFlags));
START_MD_PERF();
LOCKREAD();
_ASSERTE(TypeFromToken(mdf) == mdtFile && RidFromToken(mdf));
......@@ -195,7 +190,6 @@ STDMETHODIMP RegMeta::GetFileProps( // S_OK or error.
}
ErrExit:
STOP_MD_PERF(GetFileProps);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -225,7 +219,6 @@ STDMETHODIMP RegMeta::GetExportedTypeProps( // S_OK or error.
mdct, szName, cchName, pchName,
ptkImplementation, ptkTypeDef, pdwExportedTypeFlags));
START_MD_PERF();
LOCKREAD();
_ASSERTE(TypeFromToken(mdct) == mdtExportedType && RidFromToken(mdct));
......@@ -273,7 +266,6 @@ STDMETHODIMP RegMeta::GetExportedTypeProps( // S_OK or error.
}
ErrExit:
STOP_MD_PERF(GetExportedTypeProps);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -304,7 +296,6 @@ STDMETHODIMP RegMeta::GetManifestResourceProps( // S_OK or error.
ptkImplementation, pdwOffset,
pdwResourceFlags));
START_MD_PERF();
LOCKREAD();
_ASSERTE(TypeFromToken(mdmr) == mdtManifestResource && RidFromToken(mdmr));
......@@ -321,7 +312,6 @@ STDMETHODIMP RegMeta::GetManifestResourceProps( // S_OK or error.
IfFailGo(pMiniMd->getNameOfManifestResource(pRecord, szName, cchName, pchName));
ErrExit:
STOP_MD_PERF(GetManifestResourceProps);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -346,7 +336,6 @@ STDMETHODIMP RegMeta::EnumAssemblyRefs( // S_OK or error
LOG((LOGMD, "MD RegMeta::EnumAssemblyRefs(%#08x, %#08x, %#08x, %#08x)\n",
phEnum, rAssemblyRefs, cMax, pcTokens));
START_MD_PERF();
LOCKREAD();
......@@ -373,7 +362,6 @@ STDMETHODIMP RegMeta::EnumAssemblyRefs( // S_OK or error
ErrExit:
HENUMInternal::DestroyEnumIfEmpty(ppmdEnum);
STOP_MD_PERF(EnumAssemblyRefs);
END_ENTRYPOINT_NOTHROW;
......@@ -398,7 +386,6 @@ STDMETHODIMP RegMeta::EnumFiles( // S_OK or error
LOG((LOGMD, "MD RegMeta::EnumFiles(%#08x, %#08x, %#08x, %#08x)\n",
phEnum, rFiles, cMax, pcTokens));
START_MD_PERF();
LOCKREAD();
if (*ppmdEnum == 0)
......@@ -424,7 +411,6 @@ STDMETHODIMP RegMeta::EnumFiles( // S_OK or error
ErrExit:
HENUMInternal::DestroyEnumIfEmpty(ppmdEnum);
STOP_MD_PERF(EnumFiles);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -449,7 +435,6 @@ STDMETHODIMP RegMeta::EnumExportedTypes( // S_OK or error
LOG((LOGMD, "MD RegMeta::EnumExportedTypes(%#08x, %#08x, %#08x, %#08x)\n",
phEnum, rExportedTypes, cMax, pcTokens));
START_MD_PERF();
LOCKREAD();
if (*ppmdEnum == 0)
......@@ -497,7 +482,6 @@ ErrExit:
HENUMInternal::DestroyEnumIfEmpty(ppmdEnum);
HENUMInternal::DestroyEnum(pEnum);
STOP_MD_PERF(EnumExportedTypes);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -522,7 +506,6 @@ STDMETHODIMP RegMeta::EnumManifestResources( // S_OK or error
LOG((LOGMD, "MD RegMeta::EnumManifestResources(%#08x, %#08x, %#08x, %#08x)\n",
phEnum, rManifestResources, cMax, pcTokens));
START_MD_PERF();
LOCKREAD();
if (*ppmdEnum == 0)
......@@ -548,7 +531,6 @@ STDMETHODIMP RegMeta::EnumManifestResources( // S_OK or error
ErrExit:
HENUMInternal::DestroyEnumIfEmpty(ppmdEnum);
STOP_MD_PERF(EnumManifestResources);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -566,7 +548,6 @@ STDMETHODIMP RegMeta::GetAssemblyFromScope( // S_OK or error
BEGIN_ENTRYPOINT_NOTHROW;
LOG((LOGMD, "MD RegMeta::GetAssemblyFromScope(%#08x)\n", ptkAssembly));
START_MD_PERF();
LOCKREAD();
_ASSERTE(ptkAssembly);
......@@ -580,7 +561,6 @@ STDMETHODIMP RegMeta::GetAssemblyFromScope( // S_OK or error
IfFailGo( CLDB_E_RECORD_NOTFOUND );
}
ErrExit:
STOP_MD_PERF(GetAssemblyFromScope);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -604,7 +584,6 @@ STDMETHODIMP RegMeta::FindExportedTypeByName( // S_OK or error
LOG((LOGMD, "MD RegMeta::FindExportedTypeByName(%S, %#08x, %#08x)\n",
MDSTR(szName), tkEnclosingType, ptkExportedType));
START_MD_PERF();
LOCKREAD();
......@@ -627,7 +606,6 @@ STDMETHODIMP RegMeta::FindExportedTypeByName( // S_OK or error
tkEnclosingType,
ptkExportedType));
ErrExit:
STOP_MD_PERF(FindExportedTypeByName);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -650,7 +628,6 @@ STDMETHODIMP RegMeta::FindManifestResourceByName( // S_OK or error
LOG((LOGMD, "MD RegMeta::FindManifestResourceByName(%S, %#08x)\n",
MDSTR(szName), ptkManifestResource));
START_MD_PERF();
LOCKREAD();
......@@ -684,7 +661,6 @@ STDMETHODIMP RegMeta::FindManifestResourceByName( // S_OK or error
IfFailGo( CLDB_E_RECORD_NOTFOUND );
ErrExit:
STOP_MD_PERF(FindManifestResourceByName);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -708,14 +684,12 @@ STDMETHODIMP RegMeta::FindAssembliesByName( // S_OK or error
LOG((LOGMD, "RegMeta::FindAssembliesByName(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
szAppBase, szPrivateBin, szAssemblyName, ppIUnk, cMax, pcAssemblies));
START_MD_PERF();
// No need to lock this function. It is going through fusion to find the matching Assemblies by name
IfFailGo(COR_E_NOTSUPPORTED);
ErrExit:
STOP_MD_PERF(FindAssembliesByName);
END_ENTRYPOINT_NOTHROW;
return hr;
......
......@@ -47,7 +47,6 @@ STDMETHODIMP RegMeta::DefineAssembly( // S_OK or error.
pbPublicKey, cbPublicKey, ulHashAlgId, MDSTR(szName), pMetaData,
dwAssemblyFlags, pma));
START_MD_PERF();
LOCKWRITE();
_ASSERTE(szName && pMetaData && pma);
......@@ -95,7 +94,6 @@ STDMETHODIMP RegMeta::DefineAssembly( // S_OK or error.
ErrExit:
STOP_MD_PERF(DefineAssembly);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -128,7 +126,6 @@ STDMETHODIMP RegMeta::DefineAssemblyRef( // S_OK or error.
pbPublicKeyOrToken, cbPublicKeyOrToken, MDSTR(szName), pMetaData, pbHashValue,
cbHashValue, dwAssemblyRefFlags, pmar));
START_MD_PERF();
LOCKWRITE();
IfFailGo(m_pStgdb->m_MiniMd.PreUpdate());
......@@ -187,7 +184,6 @@ STDMETHODIMP RegMeta::DefineAssemblyRef( // S_OK or error.
ErrExit:
SetCallerExternal();
STOP_MD_PERF(DefineAssemblyRef);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -213,7 +209,6 @@ STDMETHODIMP RegMeta::DefineFile( // S_OK or error.
LOG((LOGMD, "RegMeta::DefineFile(%S, %#08x, %#08x, %#08x, %#08x)\n",
MDSTR(szName), pbHashValue, cbHashValue, dwFileFlags, pmf));
START_MD_PERF();
LOCKWRITE();
IfFailGo(m_pStgdb->m_MiniMd.PreUpdate());
......@@ -260,7 +255,6 @@ STDMETHODIMP RegMeta::DefineFile( // S_OK or error.
IfFailGo(_SetFileProps(*pmf, pbHashValue, cbHashValue, dwFileFlags));
ErrExit:
STOP_MD_PERF(DefineFile);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -290,7 +284,6 @@ STDMETHODIMP RegMeta::DefineExportedType( // S_OK or error.
MDSTR(szName), tkImplementation, tkTypeDef,
dwExportedTypeFlags, pmct));
START_MD_PERF();
LOCKWRITE();
// Validate name for prefix.
......@@ -360,7 +353,6 @@ STDMETHODIMP RegMeta::DefineExportedType( // S_OK or error.
dwExportedTypeFlags));
ErrExit:
STOP_MD_PERF(DefineExportedType);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -386,7 +378,6 @@ STDMETHODIMP RegMeta::DefineManifestResource( // S_OK or error.
LOG((LOGMD, "RegMeta::DefineManifestResource(%S, %#08x, %#08x, %#08x, %#08x)\n",
MDSTR(szName), tkImplementation, dwOffset, dwResourceFlags, pmmr));
START_MD_PERF();
LOCKWRITE();
IfFailGo(m_pStgdb->m_MiniMd.PreUpdate());
......@@ -439,7 +430,6 @@ STDMETHODIMP RegMeta::DefineManifestResource( // S_OK or error.
ErrExit:
STOP_MD_PERF(DefineManifestResource);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -466,7 +456,6 @@ STDMETHODIMP RegMeta::SetAssemblyProps( // S_OK or error.
LOG((LOGMD, "RegMeta::SetAssemblyProps(%#08x, %#08x, %#08x, %#08x %S, %#08x, %#08x)\n",
ma, pbPublicKey, cbPublicKey, ulHashAlgId, MDSTR(szName), pMetaData, dwAssemblyFlags));
START_MD_PERF();
LOCKWRITE();
IfFailGo(m_pStgdb->m_MiniMd.PreUpdate());
......@@ -474,7 +463,6 @@ STDMETHODIMP RegMeta::SetAssemblyProps( // S_OK or error.
IfFailGo(_SetAssemblyProps(ma, pbPublicKey, cbPublicKey, ulHashAlgId, szName, pMetaData, dwAssemblyFlags));
ErrExit:
STOP_MD_PERF(SetAssemblyProps);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -503,7 +491,6 @@ STDMETHODIMP RegMeta::SetAssemblyRefProps( // S_OK or error.
ar, pbPublicKeyOrToken, cbPublicKeyOrToken, MDSTR(szName), pMetaData, pbHashValue, cbHashValue,
dwAssemblyRefFlags));
START_MD_PERF();
LOCKWRITE();
IfFailGo(m_pStgdb->m_MiniMd.PreUpdate());
......@@ -519,7 +506,6 @@ STDMETHODIMP RegMeta::SetAssemblyRefProps( // S_OK or error.
dwAssemblyRefFlags));
ErrExit:
STOP_MD_PERF(SetAssemblyRefProps);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -543,7 +529,6 @@ STDMETHODIMP RegMeta::SetFileProps( // S_OK or error.
LOG((LOGMD, "RegMeta::SetFileProps(%#08x, %#08x, %#08x, %#08x)\n",
file, pbHashValue, cbHashValue, dwFileFlags));
START_MD_PERF();
LOCKWRITE();
IfFailGo(m_pStgdb->m_MiniMd.PreUpdate());
......@@ -552,7 +537,6 @@ STDMETHODIMP RegMeta::SetFileProps( // S_OK or error.
ErrExit:
STOP_MD_PERF(SetFileProps);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -575,14 +559,12 @@ STDMETHODIMP RegMeta::SetExportedTypeProps( // S_OK or error.
LOG((LOGMD, "RegMeta::SetExportedTypeProps(%#08x, %#08x, %#08x, %#08x)\n",
ct, tkImplementation, tkTypeDef, dwExportedTypeFlags));
START_MD_PERF();
LOCKWRITE();
IfFailGo( _SetExportedTypeProps( ct, tkImplementation, tkTypeDef, dwExportedTypeFlags) );
ErrExit:
STOP_MD_PERF(SetExportedTypeProps);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -609,14 +591,12 @@ STDMETHODIMP RegMeta::SetManifestResourceProps(// S_OK or error.
TypeFromToken(tkImplementation) == mdtAssemblyRef ||
tkImplementation == mdTokenNil);
START_MD_PERF();
LOCKWRITE();
IfFailGo( _SetManifestResourceProps( mr, tkImplementation, dwOffset, dwResourceFlags) );
ErrExit:
STOP_MD_PERF(SetManifestResourceProps);
END_ENTRYPOINT_NOTHROW;
return hr;
......
......@@ -16,7 +16,6 @@
#include "rwutil.h"
#include "mdlog.h"
#include "importhelper.h"
#include "mdperf.h"
#include "posterror.h"
#include "cahlprinternal.h"
#include "custattr.h"
......@@ -712,7 +711,6 @@ STDMETHODIMP RegMeta::DefineCustomAttribute(
LOG((LOGMD, "RegMeta::DefineCustomAttribute(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x)\n", tkOwner, tkCtor,
pCustomAttribute, cbCustomAttribute, pcv));
START_MD_PERF();
LOCKWRITE();
_ASSERTE(TypeFromToken(tkCtor) == mdtMethodDef || TypeFromToken(tkCtor) == mdtMemberRef);
......@@ -825,7 +823,6 @@ STDMETHODIMP RegMeta::DefineCustomAttribute(
IfFailGo(UpdateENCLog(TokenFromRid(iRecord, mdtCustomAttribute)));
ErrExit:
STOP_MD_PERF(DefineCustomAttribute);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -849,7 +846,6 @@ STDMETHODIMP RegMeta::SetCustomAttributeValue( // Return code.
CustomAttributeRec *pRecord = NULL;// Existing custom Attribute record.
START_MD_PERF();
LOCKWRITE();
IfFailGo(m_pStgdb->m_MiniMd.PreUpdate());
......@@ -863,7 +859,6 @@ STDMETHODIMP RegMeta::SetCustomAttributeValue( // Return code.
IfFailGo(UpdateENCLog(tkAttr));
ErrExit:
STOP_MD_PERF(SetCustomAttributeValue);
END_ENTRYPOINT_NOTHROW;
return hr;
......
......@@ -16,7 +16,6 @@
#include "rwutil.h"
#include "mdlog.h"
#include "importhelper.h"
#include "mdperf.h"
#include "posterror.h"
#include "cahlprinternal.h"
#include "custattr.h"
......@@ -71,7 +70,6 @@ STDMETHODIMP RegMeta::GetCustomAttributeByName( // S_OK or error.
int iLen; // A length.
CMiniMdRW *pMiniMd = NULL;
START_MD_PERF();
LOCKREAD();
pMiniMd = &(m_pStgdb->m_MiniMd);
......@@ -83,7 +81,6 @@ STDMETHODIMP RegMeta::GetCustomAttributeByName( // S_OK or error.
ErrExit:
STOP_MD_PERF(GetCustomAttributeByName);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -114,7 +111,6 @@ STDMETHODIMP RegMeta::EnumCustomAttributes(
LOG((LOGMD, "RegMeta::EnumCustomAttributes(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
phEnum, tk, tkType, rCustomAttributes, cMax, pcCustomAttributes));
START_MD_PERF();
LOCKREAD();
if ( *ppmdEnum == 0 )
......@@ -230,7 +226,6 @@ ErrExit:
HENUMInternal::DestroyEnumIfEmpty(ppmdEnum);
HENUMInternal::DestroyEnum(pEnum);
STOP_MD_PERF(EnumCustomAttributes);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -253,7 +248,6 @@ STDMETHODIMP RegMeta::GetCustomAttributeProps(
CMiniMdRW *pMiniMd;
START_MD_PERF();
LOCKREAD();
_ASSERTE(TypeFromToken(cv) == mdtCustomAttribute);
......@@ -276,7 +270,6 @@ STDMETHODIMP RegMeta::GetCustomAttributeProps(
ErrExit:
STOP_MD_PERF(GetCustomAttributeProps);
END_ENTRYPOINT_NOTHROW;
return hr;
......
此差异已折叠。
此差异已折叠。
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//*****************************************************************************
// MDperf.cpp
//
//
// This file provides Compiler Support functionality in metadata.
//*****************************************************************************
#include "stdafx.h"
#include "mdperf.h"
#ifdef FEATURE_METADATA_PERF_STATS
//-----------------------------------------------------------------------------
// Global array containing the name of the APIs. This is shared across
// all instances of MDCompilerPerf.
//-----------------------------------------------------------------------------
char g_szNameOfAPI[LAST_MD_API][API_NAME_STR_SIZE];
//-----------------------------------------------------------------------------
// Constructor. Initialize counters to 0. Initialize names of MD APIs.
//-----------------------------------------------------------------------------
MDCompilerPerf::MDCompilerPerf()
{
// Initialize counters
for (int idx=0; idx < LAST_MD_API; idx++)
{
MDPerfStats[idx].dwCalledNumTimes = 0;
MDPerfStats[idx].dwQueryPerfCycles = 0;
}
#undef MD_FUNC
#define MD_FUNC(MDTag)\
strncpy(g_szNameOfAPI[MDTag ## _ENUM], #MDTag, API_NAME_STR_SIZE-1);
MD_COMPILER_PERF_TABLE; // Relies on the MD_FUNC defined above.
}
MDCompilerPerf::~MDCompilerPerf()
{
// Output the stats and cleanup.
MetaDataPerfReport ();
}
//-----------------------------------------------------------------------------
// Output stats. <TODO>TODO: grow this into stats for per fautomation</TODO>
//-----------------------------------------------------------------------------
void MDCompilerPerf::MetaDataPerfReport ()
{
LARGE_INTEGER freqVal;
DWORD totalCalls=0, totalCycles=0;
if (!QueryPerformanceFrequency(&freqVal))
{
printf("Perf counters not supported\n");
return;
}
for (int idx=0; idx < LAST_MD_API; idx++)
{
totalCalls += MDPerfStats[idx].dwCalledNumTimes;
totalCycles += MDPerfStats[idx].dwQueryPerfCycles;
}
if (!(totalCalls && totalCycles && freqVal.QuadPart))
{
// if any of above is 0 then things don't look good.
printf("No data gathered ...\n");
return;
}
printf("\n%-32.32s %-16.16s %-16.16s %-16.16s\n", "API Name", "# Calls", "Cycles", "Time (msec)");
for (idx=0; idx < LAST_MD_API; idx++)
{
if(MDPerfStats[idx].dwCalledNumTimes != 0)
printf( "%-32.32s %-9d [%3.2d%%] %-16d %-8.2f [%3.2d%%]\n",
g_szNameOfAPI[idx],
MDPerfStats[idx].dwCalledNumTimes,
(MDPerfStats[idx].dwCalledNumTimes*100)/totalCalls,
MDPerfStats[idx].dwQueryPerfCycles,
((float)MDPerfStats[idx].dwQueryPerfCycles*1000)/(float)freqVal.QuadPart,
(MDPerfStats[idx].dwQueryPerfCycles*100)/totalCycles);
}
printf( "%-32.32s %-9d [100%%] %-16d %-8.2f [100%%]\n\n",
"Total Stats",
totalCalls,
totalCycles,
((float)totalCycles*1000)/(float)freqVal.QuadPart);
}
#endif //FEATURE_METADATA_PERF_STATS
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//*****************************************************************************
// Mdperf.h
//
//
//*****************************************************************************
#ifndef __MDCOMPILERPERF_H__
#define __MDCOMPILERPERF_H__
//#define FEATURE_METADATA_PERF_STATS
#ifdef FEATURE_METADATA_PERF_STATS
// Avoid dynamic allocs to display the API names.
#define API_NAME_STR_SIZE 80
//-----------------------------------------------------------------------------
// In order to add instrumentation for an API, two changes have to be made.
// One, add the API name in the table below (MD_TABLE).
// Second, add two lines of code (shown below) in the implementation
// of the API itself. e.g.
// RegMeta::MyNewMetataDataAPI(...)
// {
// LOG(...);
// START_MD_PERF(); // <------ add this line as is.
// ....
// // API implementation
// ErrExit:
// STOP_MD_PERF(RegMeta_MyNewMetaDataAPI); // <---------- add this line with the appropriate name
// return (hr);
// ]
//
//-----------------------------------------------------------------------------
#define MD_COMPILER_PERF_TABLE\
MD_FUNC(SaveToMemory)\
MD_FUNC(DefineMethod)\
MD_FUNC(DefineMethodImpl)\
MD_FUNC(SetRVA)\
MD_FUNC(DefineTypeRefByName)\
MD_FUNC(DefineImportType)\
MD_FUNC(DefineMemberRef)\
MD_FUNC(DefineImportMember)\
MD_FUNC(DefineEvent)\
MD_FUNC(SetClassLayout)\
MD_FUNC(DeleteClassLayout)\
MD_FUNC(SetFieldMarshal)\
MD_FUNC(DeleteFieldMarshal)\
MD_FUNC(DefinePermissionSet)\
MD_FUNC(SetMemberIndex)\
MD_FUNC(GetTokenFromSig)\
MD_FUNC(DefineModuleRef)\
MD_FUNC(SetParent)\
MD_FUNC(GetTokenFromTypeSpec)\
MD_FUNC(DefineUserString)\
MD_FUNC(DeleteToken)\
MD_FUNC(SetTypeDefProps)\
MD_FUNC(DefineNestedType)\
MD_FUNC(SetMethodProps)\
MD_FUNC(SetEventProps)\
MD_FUNC(SetPermissionSetProps)\
MD_FUNC(DefinePinvokeMap)\
MD_FUNC(SetPinvokeMap)\
MD_FUNC(DeletePinvokeMap)\
MD_FUNC(DefineField)\
MD_FUNC(DefineProperty)\
MD_FUNC(DefineParam)\
MD_FUNC(SetFieldProps)\
MD_FUNC(SetPropertyProps)\
MD_FUNC(SetParamProps)\
MD_FUNC(EnumMembers)\
MD_FUNC(EnumMembersWithName)\
MD_FUNC(EnumMethods)\
MD_FUNC(EnumMethodsWithName)\
MD_FUNC(EnumFields)\
MD_FUNC(EnumFieldsWithName)\
MD_FUNC(EnumParams)\
MD_FUNC(EnumMemberRefs)\
MD_FUNC(EnumMethodImpls)\
MD_FUNC(EnumPermissionSets)\
MD_FUNC(FindMember)\
MD_FUNC(FindMethod)\
MD_FUNC(FindField)\
MD_FUNC(FindMemberRef)\
MD_FUNC(GetMethodProps)\
MD_FUNC(GetMemberRefProps)\
MD_FUNC(EnumProperties)\
MD_FUNC(EnumEvents)\
MD_FUNC(GetEventProps)\
MD_FUNC(EnumMethodSemantics)\
MD_FUNC(GetMethodSemantics)\
MD_FUNC(GetClassLayout)\
MD_FUNC(GetFieldMarshal)\
MD_FUNC(GetRVA)\
MD_FUNC(GetPermissionSetProps)\
MD_FUNC(GetSigFromToken)\
MD_FUNC(GetModuleRefProps)\
MD_FUNC(EnumModuleRefs)\
MD_FUNC(GetTypeSpecFromToken)\
MD_FUNC(GetNameFromToken)\
MD_FUNC(EnumUnresolvedMethods)\
MD_FUNC(GetUserString)\
MD_FUNC(GetPinvokeMap)\
MD_FUNC(EnumSignatures)\
MD_FUNC(EnumTypeSpecs)\
MD_FUNC(EnumUserStrings)\
MD_FUNC(GetParamForMethodIndex)\
MD_FUNC(GetMemberProps)\
MD_FUNC(GetFieldProps)\
MD_FUNC(GetPropertyProps)\
MD_FUNC(GetParamProps)\
MD_FUNC(SetModuleProps)\
MD_FUNC(Save)\
MD_FUNC(SaveToStream)\
MD_FUNC(GetSaveSize)\
MD_FUNC(Merge)\
MD_FUNC(DefineCustomAttribute)\
MD_FUNC(SetCustomAttributeValue)\
MD_FUNC(DefineSecurityAttributeSet)\
MD_FUNC(UnmarkAll)\
MD_FUNC(MarkToken)\
MD_FUNC(IsTokenMarked)\
MD_FUNC(DefineTypeDef)\
MD_FUNC(SetHandler)\
MD_FUNC(CountEnum)\
MD_FUNC(ResetEnum)\
MD_FUNC(EnumTypeDefs)\
MD_FUNC(EnumInterfaceImpls)\
MD_FUNC(EnumTypeRefs)\
MD_FUNC(FindTypeDefByName)\
MD_FUNC(FindTypeDefByGUID)\
MD_FUNC(GetScopeProps)\
MD_FUNC(GetModuleFromScope)\
MD_FUNC(GetTypeDefProps)\
MD_FUNC(GetInterfaceImplProps)\
MD_FUNC(GetCustomAttributeByName)\
MD_FUNC(GetTypeRefProps)\
MD_FUNC(ResolveTypeRef)\
MD_FUNC(EnumCustomAttributes)\
MD_FUNC(GetCustomAttributeProps)\
MD_FUNC(FindTypeRef)\
MD_FUNC(RefToDefOptimization)\
MD_FUNC(DefineAssembly)\
MD_FUNC(DefineAssemblyRef)\
MD_FUNC(DefineFile)\
MD_FUNC(DefineExportedType)\
MD_FUNC(DefineManifestResource)\
MD_FUNC(DefineExecutionLocation)\
MD_FUNC(SetAssemblyProps)\
MD_FUNC(SetAssemblyRefProps)\
MD_FUNC(SetFileProps)\
MD_FUNC(SetExportedTypeProps)\
MD_FUNC(GetAssemblyProps)\
MD_FUNC(GetAssemblyRefProps)\
MD_FUNC(GetFileProps)\
MD_FUNC(GetExportedTypeProps)\
MD_FUNC(GetManifestResourceProps)\
MD_FUNC(EnumAssemblyRefs)\
MD_FUNC(EnumFiles)\
MD_FUNC(EnumExportedTypes)\
MD_FUNC(EnumManifestResources)\
MD_FUNC(EnumExecutionLocations)\
MD_FUNC(GetAssemblyFromScope)\
MD_FUNC(FindExportedTypeByName)\
MD_FUNC(FindManifestResourceByName)\
MD_FUNC(FindAssembliesByName)\
MD_FUNC(SetGenericPars)\
MD_FUNC(DefineGenericParam)\
MD_FUNC(SetGenericParamProps)\
MD_FUNC(EnumGenericParamConstraints)\
MD_FUNC(GetGenericParamProps)\
MD_FUNC(GetGenericParamConstraintProps)\
MD_FUNC(GetPEKind)\
MD_FUNC(GetVersionString)\
MD_FUNC(GetAssemblyUnification)
//-----------------------------------------------------------------------------
// Create an enum of all the API names. This is the index to access the APIs.
//-----------------------------------------------------------------------------
#undef MD_FUNC
#define MD_FUNC(MDTag)\
MDTag ## _ENUM,
typedef enum _MDAPIs
{
MD_COMPILER_PERF_TABLE
LAST_MD_API
} MDApis;
//-----------------------------------------------------------------------------
// Declare the struct which contais all the interesting stats for a particular
// API call.
//-----------------------------------------------------------------------------
typedef struct _MDAPIPerfData
{
DWORD dwQueryPerfCycles; // # of cycles spent in this call
DWORD dwCalledNumTimes; // # of times this API was called
} MDAPIPerfData;
//-----------------------------------------------------------------------------
// MDCompilerPerf
//-----------------------------------------------------------------------------
class MDCompilerPerf
{
public:
MDCompilerPerf();
~MDCompilerPerf();
private:
MDAPIPerfData MDPerfStats[LAST_MD_API];
void MetaDataPerfReport ();
};
// Note that this macro declares a local var.
#define START_MD_PERF()\
LARGE_INTEGER __startVal;\
QueryPerformanceCounter(&__startVal);
#undef MD_FUNC
#define MD_FUNC(MDTag)\
MDTag ## _ENUM
// Note that this macro uses the local var startVal declared in START_MD_PERF()
#define STOP_MD_PERF(MDTag)\
LARGE_INTEGER __stopVal;\
QueryPerformanceCounter(&__stopVal);\
m_MDCompilerPerf.MDPerfStats[MD_FUNC(MDTag)].dwCalledNumTimes++;\
m_MDCompilerPerf.MDPerfStats[MD_FUNC(MDTag)].dwQueryPerfCycles += (DWORD)(__stopVal.QuadPart - __startVal.QuadPart);
#else //!FEATURE_METADATA_PERF_STATS
#define START_MD_PERF()
#define STOP_MD_PERF(MDTag)
#endif //!FEATURE_METADATA_PERF_STATS
#endif // __MDCOMPILERPERF_H__
......@@ -17,7 +17,6 @@
#include "mdlog.h"
#include "importhelper.h"
#include "filtermanager.h"
#include "mdperf.h"
#include "switches.h"
#include "posterror.h"
#include "stgio.h"
......
......@@ -17,10 +17,7 @@
#include <metamodelrw.h>
#include "../inc/mdlog.h"
#include "utsem.h"
#include "rwutil.h"
#include "mdperf.h"
#include "sigparser.h"
class FilterManager;
......@@ -2037,10 +2034,6 @@ private:
LONG m_cRef; // Ref count.
IUnknown *m_pFreeThreadedMarshaler; // FreeThreadedMarshaler
#ifdef FEATURE_METADATA_PERF_STATS
MDCompilerPerf m_MDCompilerPerf; // Compiler perf object to store all stats.
#endif
// If true, cached in list of global scopes. This is very dangerous because it may allow
// unpredictable state sharing between seemingly unrelated dispensers.
bool m_bCached;
......
......@@ -17,7 +17,6 @@
#include "mdlog.h"
#include "importhelper.h"
#include "filtermanager.h"
#include "mdperf.h"
#include "switches.h"
#include "posterror.h"
#include "stgio.h"
......
......@@ -20,7 +20,6 @@
#include "mdlog.h"
#include "importhelper.h"
#include "filtermanager.h"
#include "mdperf.h"
#include "switches.h"
#include "posterror.h"
#include "stgio.h"
......@@ -58,7 +57,6 @@ STDMETHODIMP RegMeta::SetModuleProps( // S_OK or error.
LOG((LOGMD, "RegMeta::SetModuleProps(%S)\n", MDSTR(szName)));
START_MD_PERF()
LOCKWRITE();
IfFailGo(m_pStgdb->m_MiniMd.PreUpdate());
......@@ -77,7 +75,6 @@ STDMETHODIMP RegMeta::SetModuleProps( // S_OK or error.
ErrExit:
STOP_MD_PERF(SetModuleProps);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -95,7 +92,6 @@ STDMETHODIMP RegMeta::Save( // S_OK or error.
BEGIN_ENTRYPOINT_NOTHROW;
LOG((LOGMD, "RegMeta::Save(%S, 0x%08x)\n", MDSTR(szFile), dwSaveFlags));
START_MD_PERF()
LOCKWRITE();
// Check reserved param..
......@@ -119,7 +115,6 @@ STDMETHODIMP RegMeta::Save( // S_OK or error.
ErrExit:
STOP_MD_PERF(Save);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -139,13 +134,11 @@ STDMETHODIMP RegMeta::SaveToStream( // S_OK or error.
LOCKWRITE();
LOG((LOGMD, "RegMeta::SaveToStream(0x%08x, 0x%08x)\n", pIStream, dwSaveFlags));
START_MD_PERF()
IfFailGo(m_pStgdb->m_MiniMd.PreUpdate());
hr = _SaveToStream(pIStream, dwSaveFlags);
STOP_MD_PERF(SaveToStream);
#if defined(_DEBUG)
if (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_MD_RegMetaDump))
......@@ -200,7 +193,6 @@ STDMETHODIMP RegMeta::SaveToMemory( // S_OK or error.
LOG((LOGMD, "MD RegMeta::SaveToMemory(0x%08x, 0x%08x)\n",
pbData, cbData));
START_MD_PERF();
#ifdef _DEBUG
ULONG cbActual; // Size of the real data.
......@@ -219,7 +211,6 @@ STDMETHODIMP RegMeta::SaveToMemory( // S_OK or error.
ErrExit:
if (pStream)
pStream->Release();
STOP_MD_PERF(SaveToMemory);
END_ENTRYPOINT_NOTHROW;
return (hr);
......@@ -239,7 +230,6 @@ STDMETHODIMP RegMeta::GetSaveSize( // S_OK or error.
FilterTable *ft = NULL;
LOG((LOGMD, "RegMeta::GetSaveSize(0x%08x, 0x%08x)\n", fSave, pdwSaveSize));
START_MD_PERF();
LOCKWRITE();
ft = m_pStgdb->m_MiniMd.GetFilterTable();
......@@ -284,7 +274,6 @@ STDMETHODIMP RegMeta::GetSaveSize( // S_OK or error.
hr = m_pStgdb->GetSaveSize(fSave, (UINT32 *)pdwSaveSize, m_ReorderingOptions);
ErrExit:
STOP_MD_PERF(GetSaveSize);
END_ENTRYPOINT_NOTHROW;
......@@ -314,7 +303,6 @@ HRESULT RegMeta::UnmarkAll()
LOG((LOGMD, "RegMeta::UnmarkAll\n"));
START_MD_PERF();
LOCKWRITE();
#if 0
......@@ -429,7 +417,6 @@ HRESULT RegMeta::UnmarkAll()
}
ErrExit:
STOP_MD_PERF(UnmarkAll);
END_ENTRYPOINT_NOTHROW;
......@@ -475,7 +462,6 @@ STDMETHODIMP RegMeta::MarkToken( // Return code.
BEGIN_ENTRYPOINT_NOTHROW;
// LOG((LOGMD, "RegMeta::MarkToken(0x%08x)\n", tk));
START_MD_PERF();
LOCKWRITE();
if (m_pStgdb->m_MiniMd.GetFilterTable() == NULL || m_pFilterManager == NULL)
......@@ -551,7 +537,6 @@ STDMETHODIMP RegMeta::MarkToken( // Return code.
}
ErrExit:
STOP_MD_PERF(MarkToken);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -574,7 +559,6 @@ HRESULT RegMeta::IsTokenMarked(
FilterTable *pFilter = NULL;
LOG((LOGMD, "RegMeta::IsTokenMarked(0x%08x)\n", tk));
START_MD_PERF();
LOCKREAD();
pFilter = m_pStgdb->m_MiniMd.GetFilterTable();
......@@ -635,7 +619,6 @@ HRESULT RegMeta::IsTokenMarked(
}
ErrExit:
STOP_MD_PERF(IsTokenMarked);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -660,7 +643,6 @@ STDMETHODIMP RegMeta::DefineTypeDef( // S_OK or error.
LOG((LOGMD, "RegMeta::DefineTypeDef(%S, 0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
MDSTR(szTypeDef), dwTypeDefFlags, tkExtends,
rtkImplements, ptd));
START_MD_PERF();
LOCKWRITE();
IfFailGo(m_pStgdb->m_MiniMd.PreUpdate());
......@@ -670,7 +652,6 @@ STDMETHODIMP RegMeta::DefineTypeDef( // S_OK or error.
IfFailGo(_DefineTypeDef(szTypeDef, dwTypeDefFlags,
tkExtends, rtkImplements, mdTokenNil, ptd));
ErrExit:
STOP_MD_PERF(DefineTypeDef);
END_ENTRYPOINT_NOTHROW;
......@@ -691,7 +672,6 @@ STDMETHODIMP RegMeta::SetHandler( // S_OK.
IMapToken *pIMap = NULL;
LOG((LOGMD, "RegMeta::SetHandler(0x%08x)\n", pUnk));
START_MD_PERF();
LOCKWRITE();
m_pHandler = pUnk;
......@@ -708,7 +688,6 @@ STDMETHODIMP RegMeta::SetHandler( // S_OK.
ErrExit:
STOP_MD_PERF(SetHandler);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -817,7 +796,6 @@ HRESULT RegMeta::RefToDefOptimization()
START_MD_PERF();
// the Ref to Def map is still up-to-date
if (IsMemberDefDirty() == false && IsTypeDefDirty() == false && m_hasOptimizedRefToDef == true)
......@@ -960,7 +938,6 @@ HRESULT RegMeta::RefToDefOptimization()
SetTypeDefDirty(false);
m_hasOptimizedRefToDef = true;
ErrExit:
STOP_MD_PERF(RefToDefOptimization);
return hr;
} // RegMeta::RefToDefOptimization
......
......@@ -20,7 +20,6 @@
#include "mdlog.h"
#include "importhelper.h"
#include "filtermanager.h"
#include "mdperf.h"
#include "switches.h"
#include "posterror.h"
#include "stgio.h"
......@@ -96,7 +95,6 @@ HRESULT CountEnum(
// No need to lock this function.
LOG((LOGMD, "RegMeta::CountEnum(0x%08x, 0x%08x)\n", hEnum, pulCount));
START_MD_PERF();
_ASSERTE( pulCount );
......@@ -116,7 +114,6 @@ HRESULT CountEnum(
else
*pulCount = pmdEnum->m_ulCount;
ErrExit:
STOP_MD_PERF(CountEnum);
return hr;
} // ::CountEnum
......@@ -148,7 +145,6 @@ STDMETHODIMP RegMeta::ResetEnum(
// No need to lock this function.
LOG((LOGMD, "RegMeta::ResetEnum(0x%08x, 0x%08x)\n", hEnum, ulPos));
START_MD_PERF();
if (pmdEnum == NULL)
goto ErrExit;
......@@ -156,7 +152,6 @@ STDMETHODIMP RegMeta::ResetEnum(
pmdEnum->u.m_ulCur = pmdEnum->u.m_ulStart + ulPos;
ErrExit:
STOP_MD_PERF(ResetEnum);
END_ENTRYPOINT_NOTHROW;
return hr;
} // RegMeta::ResetEnum
......@@ -179,7 +174,6 @@ STDMETHODIMP RegMeta::EnumTypeDefs(
LOG((LOGMD, "RegMeta::EnumTypeDefs(0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
phEnum, rTypeDefs, cMax, pcTypeDefs));
START_MD_PERF();
LOCKREAD();
......@@ -229,7 +223,6 @@ ErrExit:
HENUMInternal::DestroyEnumIfEmpty(ppmdEnum);
HENUMInternal::DestroyEnum(pEnum);
STOP_MD_PERF(EnumTypeDefs);
END_ENTRYPOINT_NOTHROW;
......@@ -259,7 +252,6 @@ STDMETHODIMP RegMeta::EnumInterfaceImpls(
LOG((LOGMD, "RegMeta::EnumInterfaceImpls(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
phEnum, td, rImpls, cMax, pcImpls));
START_MD_PERF();
LOCKREAD();
_ASSERTE(TypeFromToken(td) == mdtTypeDef);
......@@ -306,7 +298,6 @@ ErrExit:
HENUMInternal::DestroyEnumIfEmpty(ppmdEnum);
HENUMInternal::DestroyEnum(pEnum);
STOP_MD_PERF(EnumInterfaceImpls);
END_ENTRYPOINT_NOTHROW;
......@@ -331,7 +322,6 @@ STDMETHODIMP RegMeta::EnumGenericParams(HCORENUM *phEnum, mdToken tkOwner,
LOG((LOGMD, "RegMeta::EnumGenericParams(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
phEnum, tkOwner, rTokens, cMaxTokens, pcTokens));
START_MD_PERF();
LOCKREAD();
pMiniMd = &(m_pStgdb->m_MiniMd);
......@@ -400,7 +390,6 @@ ErrExit:
HENUMInternal::DestroyEnumIfEmpty(ppmdEnum);
HENUMInternal::DestroyEnum(pEnum);
STOP_MD_PERF(EnumGenericPars);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -427,7 +416,6 @@ STDMETHODIMP RegMeta::EnumMethodSpecs(
LOG((LOGMD, "RegMeta::EnumMethodSpecs(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
phEnum, tkOwner, rTokens, cMaxTokens, pcTokens));
START_MD_PERF();
LOCKREAD();
pMiniMd = &(m_pStgdb->m_MiniMd);
......@@ -504,7 +492,6 @@ ErrExit:
HENUMInternal::DestroyEnumIfEmpty(ppmdEnum);
HENUMInternal::DestroyEnum(pEnum);
STOP_MD_PERF(EnumMethodSpecs);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -531,7 +518,6 @@ STDMETHODIMP RegMeta::EnumGenericParamConstraints(
LOG((LOGMD, "RegMeta::EnumGenericParamConstraints(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
phEnum, tkOwner, rTokens, cMaxTokens, pcTokens));
START_MD_PERF();
LOCKREAD();
pMiniMd = &(m_pStgdb->m_MiniMd);
......@@ -592,7 +578,6 @@ ErrExit:
HENUMInternal::DestroyEnumIfEmpty(ppmdEnum);
HENUMInternal::DestroyEnum(pEnum);
STOP_MD_PERF(EnumGenericParamConstraints);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -619,7 +604,6 @@ STDMETHODIMP RegMeta::EnumTypeRefs(
LOG((LOGMD, "RegMeta::EnumTypeRefs(0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
phEnum, rTypeRefs, cMax, pcTypeRefs));
START_MD_PERF();
LOCKREAD();
if ( pEnum == 0 )
......@@ -641,7 +625,6 @@ ErrExit:
HENUMInternal::DestroyEnumIfEmpty(ppmdEnum);
STOP_MD_PERF(EnumTypeRefs);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -660,7 +643,6 @@ STDMETHODIMP RegMeta::FindTypeDefByName(// S_OK or error.
LOG((LOGMD, "{%08x} RegMeta::FindTypeDefByName(%S, 0x%08x, 0x%08x)\n",
this, MDSTR(wzTypeDef), tkEnclosingClass, ptd));
START_MD_PERF();
LOCKREAD();
......@@ -688,7 +670,6 @@ STDMETHODIMP RegMeta::FindTypeDefByName(// S_OK or error.
ptd);
ErrExit:
STOP_MD_PERF(FindTypeDefByName);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -713,7 +694,6 @@ STDMETHODIMP RegMeta::GetScopeProps(
LOG((LOGMD, "RegMeta::GetScopeProps(%S, 0x%08x, 0x%08x, 0x%08x)\n",
MDSTR(szName), cchName, pchName, pmvid));
START_MD_PERF();
LOCKREAD();
// there is only one module record
......@@ -728,7 +708,6 @@ STDMETHODIMP RegMeta::GetScopeProps(
IfFailGo( pMiniMd->getNameOfModule(pModuleRec, szName, cchName, pchName) );
ErrExit:
STOP_MD_PERF(GetScopeProps);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -744,7 +723,6 @@ STDMETHODIMP RegMeta::GetModuleFromScope(// S_OK.
BEGIN_ENTRYPOINT_NOTHROW;
LOG((LOGMD, "RegMeta::GetModuleFromScope(0x%08x)\n", pmd));
START_MD_PERF();
_ASSERTE(pmd);
......@@ -752,7 +730,6 @@ STDMETHODIMP RegMeta::GetModuleFromScope(// S_OK.
*pmd = TokenFromRid(1, mdtModule);
STOP_MD_PERF(GetModuleFromScope);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -773,7 +750,6 @@ HRESULT RegMeta::IsGlobal( // S_OK ir error.
mdToken tkParent; // Parent of field or method.
LOG((LOGMD, "RegMeta::GetTokenForGlobalType(0x%08x, %08x)\n", tk, pbGlobal));
//START_MD_PERF();
// No need to lock this function.
......@@ -812,7 +788,6 @@ HRESULT RegMeta::IsGlobal( // S_OK ir error.
}
ErrExit:
//STOP_MD_PERF(GetModuleFromScope);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -841,7 +816,6 @@ RegMeta::GetTypeDefProps(
LOG((LOGMD, "{%08x} RegMeta::GetTypeDefProps(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
this, td, szTypeDef, cchTypeDef, pchTypeDef,
pdwTypeDefFlags, ptkExtends));
START_MD_PERF();
LOCKREAD();
if (TypeFromToken(td) != mdtTypeDef)
......@@ -922,7 +896,6 @@ RegMeta::GetTypeDefProps(
ErrExit:
END_ENTRYPOINT_NOTHROW;
STOP_MD_PERF(GetTypeDefProps);
return hr;
} // RegMeta::GetTypeDefProps
......@@ -946,7 +919,6 @@ STDMETHODIMP RegMeta::GetInterfaceImplProps( // S_OK or error.
LOG((LOGMD, "RegMeta::GetInterfaceImplProps(0x%08x, 0x%08x, 0x%08x)\n",
iiImpl, pClass, ptkIface));
START_MD_PERF();
LOCKREAD();
_ASSERTE(TypeFromToken(iiImpl) == mdtInterfaceImpl);
......@@ -964,7 +936,6 @@ STDMETHODIMP RegMeta::GetInterfaceImplProps( // S_OK or error.
}
ErrExit:
STOP_MD_PERF(GetInterfaceImplProps);
END_ENTRYPOINT_NOTHROW;
return hr;
......@@ -992,7 +963,6 @@ RegMeta::GetTypeRefProps(
LOG((LOGMD, "RegMeta::GetTypeRefProps(0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
tr, ptkResolutionScope, szTypeRef, cchTypeRef, pchTypeRef));
START_MD_PERF();
LOCKREAD();
if (TypeFromToken(tr) != mdtTypeRef)
......@@ -1060,7 +1030,6 @@ RegMeta::GetTypeRefProps(
}
ErrExit:
STOP_MD_PERF(GetTypeRefProps);
END_ENTRYPOINT_NOTHROW;
return hr;
} // RegMeta::GetTypeRefProps
......@@ -1088,7 +1057,6 @@ STDMETHODIMP RegMeta::FindTypeRef( // S_OK or error.
LOG((LOGMD, "RegMeta::FindTypeRef(0x%8x, %ls, 0x%08x)\n",
tkResolutionScope, MDSTR(wzTypeName), ptk));
START_MD_PERF();
LOCKREAD();
// Convert the name to UTF8.
......@@ -1103,7 +1071,6 @@ STDMETHODIMP RegMeta::FindTypeRef( // S_OK or error.
ptk);
ErrExit:
STOP_MD_PERF(FindTypeRef);
END_ENTRYPOINT_NOTHROW;
return hr;
......
......@@ -19,7 +19,6 @@
#include "mdlog.h"
#include "importhelper.h"
#include "filtermanager.h"
#include "mdperf.h"
#include "switches.h"
#include "posterror.h"
#include "stgio.h"
......@@ -166,7 +165,6 @@ RegMeta::ResolveTypeRef(
LOG((LOGMD, "{%08x} RegMeta::ResolveTypeRef(0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
this, tr, riid, ppIScope, ptd));
START_MD_PERF();
LOCKREAD();
pMiniMd = &(m_pStgdb->m_MiniMd);
......@@ -189,7 +187,6 @@ RegMeta::ResolveTypeRef(
*ppIScope = NULL;
}
STOP_MD_PERF(ResolveTypeRef);
hr = E_INVALIDARG;
goto ErrExit;
}
......@@ -198,7 +195,6 @@ RegMeta::ResolveTypeRef(
{
// Shortcut when we receive a TypeDef token
*ptd = tr;
STOP_MD_PERF(ResolveTypeRef);
hr = this->QueryInterface(riid, (void **)ppIScope);
goto ErrExit;
}
......@@ -233,7 +229,6 @@ RegMeta::ResolveTypeRef(
IfFailGo(META_E_CANNOTRESOLVETYPEREF);
ErrExit:
STOP_MD_PERF(ResolveTypeRef);
END_ENTRYPOINT_NOTHROW;
return hr;
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
// This file is here because we share some common code with the CLR and that platform uses common.h as a
// precompiled header. Due to limitations on precompilation (a precompiled header must be included first
// and must not be preceded by any other preprocessor directive) we cannot conditionally include common.h,
// so the simplest solution is to maintain this empty header under Redhawk.
//
//
// For our DAC build, we precompile gcrhenv.h because it is extremely large (~3MB of text). For non-DAC
// builds, we do not do this because the majority of the files have more constrained #includes.
//
#include "stdint.h"
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/*++
Module Name:
interlock.s
Abstract:
Implementation of Interlocked functions (32 and 64 bits) for the HPUX/Itanium
platform. These functions are processor dependent.
See the i386 implementations for more information.
--*/
.file "interlock.s"
.section .text, "ax", "progbits"
.align 16
.global InterlockedExchangeAdd#
.proc InterlockedExchangeAdd#
InterlockedExchangeAdd:
.body
ld4.nt1 r8 = [r32]
;;
Iea10:
mov ar.ccv = r8
add r15 = r33, r8
mov r14 = r8
;;
cmpxchg4.acq r8 = [r32], r15, ar.ccv
;;
cmp.ne p6,p7 = r8, r14 // check if the target changes?
(p6)br.cond.spnt.few Iea10 // if yes, go back to do it again
(p7)br.ret.sptk.clr b0
;;
.endp InterlockedExchangeAdd#
.align 16
.global InterlockedIncrement#
.proc InterlockedIncrement#
InterlockedIncrement:
.body
fetchadd4.acq r8 = [r32], 1
;;
adds r8 = 1, r8
br.ret.sptk b0
;;
.endp InterlockedIncrement#
.align 16
.global InterlockedIncrement64#
.proc InterlockedIncrement64#
InterlockedIncrement64:
.body
fetchadd8.acq r8 = [r32], 1
;;
adds r8 = 1, r8
br.ret.sptk b0
;;
.endp InterlockedIncrement64#
.align 16
.global InterlockedDecrement#
.proc InterlockedDecrement#
InterlockedDecrement:
.body
fetchadd4.acq r8 = [r32], -1
;;
adds r8 = -1, r8
br.ret.sptk b0
;;
.endp InterlockedDecrement#
.align 16
.global InterlockedDecrement64#
.proc InterlockedDecrement64#
InterlockedDecrement64:
.body
fetchadd8.acq r8 = [r32], -1
;;
adds r8 = -1, r8
br.ret.sptk b0
;;
.endp InterlockedDecrement64#
.align 16
.global InterlockedExchange#
.proc InterlockedExchange#
InterlockedExchange:
.body
mf
zxt4 r33 = r33 // sanitize the upper 32 bits
;;
xchg4 r8 = [r32], r33
br.ret.sptk b0
;;
.endp InterlockedExchange#
.align 16
.global InterlockedExchange64#
.proc InterlockedExchange64#
InterlockedExchange64:
.body
mf
xchg8 r8 = [r32], r33
br.ret.sptk b0
;;
.endp InterlockedExchange64#
.align 16
.global InterlockedCompareExchange#
.proc InterlockedCompareExchange#
InterlockedCompareExchange:
.body
mf
zxt4 r33 = r33 // sanitize the upper 32 bits
zxt4 r34 = r34 // sanitize the upper 32 bits
;;
mov ar.ccv = r34
;;
cmpxchg4.acq r8 = [r32], r33, ar.ccv
br.ret.sptk.clr b0
;;
.endp InterlockedCompareExchange#
.align 16
.global InterlockedCompareExchange64#
.proc InterlockedCompareExchange64#
InterlockedCompareExchange64:
.body
mf
mov ar.ccv = r34
;;
cmpxchg8.acq r8 = [r32], r33, ar.ccv
br.ret.sptk.clr b0
;;
.endp InterlockedCompareExchange64#
/*++
DBG_DebugBreak is extracted from DbgBreakPoint function
in debugstb.s from win64.
--*/
BREAKPOINT_STOP = 0x80016
.align 16
.global DBG_DebugBreak#
.proc DBG_DebugBreak#
DBG_DebugBreak:
.body
flushrs
;;
break.i BREAKPOINT_STOP
br.ret.sptk.clr b0
;;
.endp DBG_DebugBreak#
.align 16
.global MemoryBarrier#
.proc MemoryBarrier#
MemoryBarrier:
.body
mf
br.ret.sptk.clr b0
;;
.endp MemoryBarrier#
gcc -O2 -finline-functions -D_DEBUG -g -DFULL_CSIMPL -o ./obj/sun4u/critsecttest.o -c critsecttest.cpp
gcc -O2 -finline-functions -D_DEBUG -g -c -o ./obj/sun4u/cs.o cs.cpp
gcc -x assembler-with-cpp -c -Wa,-Av9 -o ./obj/sun4u/sparcinterloc.o sparcinterloc.s
gcc -lpthread -lrt -O2 -finline-functions -D_DEBUG -g -o ./obj/sun4u/critsecttest ./obj/sun4u/critsecttest.o ./obj/sun4u/cs.o ./obj/sun4u/sparcinterloc.o
gcc -O2 -finline-functions -D_DEBUG -g -DCXNG_CSIMPL -o ./obj/sun4u/cxngtest.o -c critsecttest.cpp
gcc -O2 -finline-functions -D_DEBUG -g -c -o ./obj/sun4u/cxng_critsect.o cxng_critsect.cpp
gcc -lpthread -lrt -O2 -finline-functions -D_DEBUG -g -o ./obj/sun4u/cxngtest ./obj/sun4u/cxngtest.o ./obj/sun4u/cxng_critsect.o ./obj/sun4u/sparcinterloc.o
gcc -O2 -finline-functions -D_DEBUG -g -DMTX_CSIMPL -o ./obj/sun4u/mtxtest.o -c critsecttest.cpp
gcc -O2 -finline-functions -D_DEBUG -g -c -o ./obj/sun4u/mtx_critsect.o mtx_critsect.cpp
gcc -lpthread -lrt -O2 -finline-functions -D_DEBUG -g -o ./obj/sun4u/mtxtest ./obj/sun4u/mtxtest.o ./obj/sun4u/mtx_critsect.o ./obj/sun4u/sparcinterloc.o
gcc -O2 -finline-functions -D_DEBUG -g -DRECMTX_CSIMPL -o ./obj/sun4u/recmtxtest.o -c critsecttest.cpp
gcc -O2 -finline-functions -D_DEBUG -g -c -o ./obj/sun4u/recmtx_critsect.o recmtx_critsect.cpp
gcc -lpthread -lrt -O2 -finline-functions -D_DEBUG -g -o ./obj/sun4u/recmtxtest ./obj/sun4u/recmtxtest.o ./obj/sun4u/recmtx_critsect.o ./obj/sun4u/sparcinterloc.o
gcc -O2 -finline-functions -D_DEBUG -g -DINLRECMTX_CSIMPL -o ./obj/sun4u/inlrecmtxtest.o -c critsecttest.cpp
gcc -lpthread -lrt -O2 -finline-functions -D_DEBUG -g -o ./obj/sun4u/inlrecmtxtest ./obj/sun4u/inlrecmtxtest.o ./obj/sun4u/sparcinterloc.o
To compile:
For FReeBSD Platform use the following to compile:
gcc -pthread -lm -lgcc -lstdc++ -xc++ -Di386 pal_composite_native_cs.c
--------------------------------------------------------
For Solaris Platform use the following to compile:
gcc -lpthread -lm -lgcc -lstdc++ -xc++ -D__sparc__ -mimpure-text -shared -o critsect.so mtx_critsect.cpp interlock.s
gcc -lpthread -lm -lgcc -lstdc++ -xc++ -D__sparc__ pal_composite_native_cs.c
setenv LD_LIBRARY_PATH /usr/lib/lwp:/usr/local/lib:/usr/lib:/opt/sfw/lib:.
gcc -lpthread -lm -lgcc -lstdc++ -lcritsect -xc++ -D__sparc__ pal_composite_native_cs.c
gcc -lpthread -lm -lgcc -lstdc++ -xc++ -D__sparc__ -mimpure-text -shared -o critsect.so mtx_critsect.cpp
(pts/2):{4}% ldd critsect.so
libpthread.so.1 => /usr/lib/libpthread.so.1
libm.so.1 => /usr/lib/libm.so.1
libstdc++.so.2.10.0 => /usr/local/lib/libstdc++.so.2.10.0
libc.so.1 => /usr/lib/libc.so.1
libdl.so.1 => /usr/lib/libdl.so.1
libthread.so.1 => /usr/lib/libthread.so.1
/usr/platform/SUNW,Serverblade1/lib/libc_psr.so.1
--------------------------------------------------------
For HPUX Platform use the following to compile:
gcc -lpthread -mlp64 -lm -lgcc -lstdc++ -xc++ -D_HPUX_ -D__ia64__ pal_composite_native_cs.c
--------------------------------------------------------
To execute:
./a.out [PROCESS_COUNT] [THREAD_COUNT] [REPEAT_COUNT]
./a.out 1 32 1000000 4102406
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/*++
Module Name:
interlock.s
Abstract:
Implementation of Interlocked functions for the SPARC
platform. These functions are processor dependent.
See the i386 implementations for more information.
--*/
// A handy macro for declaring a public function
// The first argument is the function name.
#define ASMFUNC(n,typename); \
.align 4 ; \
.global n ; \
.type n,typename ; \
n: ;
.text
ASMFUNC(InterlockedIncrement,#function)
ld [%o0], %o1
loopI:
mov %o1, %o2
add %o1, 1, %o1
cas [%o0], %o2, %o1
cmp %o2, %o1
bne loopI
nop
retl
add %o1, 1, %o0
ASMFUNC(InterlockedDecrement,#function)
ld [%o0], %o1
loopD:
mov %o1, %o2
sub %o1, 1, %o1
cas [%o0], %o2, %o1
cmp %o2, %o1
bne loopD
nop
retl
sub %o1, 1, %o0
ASMFUNC(InterlockedExchange,#function)
swap [%o0], %o1
retl
mov %o1, %o0
ASMFUNC(InterlockedCompareExchange,#function)
cas [%o0], %o2, %o1
retl
mov %o1, %o0
ASMFUNC(MemoryBarrier,#function)
// ROTORTODO: SPARC
retl
nop
ASMFUNC(YieldProcessor,#function)
retl
nop
......@@ -21,7 +21,6 @@
#include <metamodelrw.h>
#include "mdlog.h"
#include "mdperf.h"
#include "regmeta.h"
#include "ex.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册