Skip to content

Commit

Permalink
Reduce binary size by moving data definitions out of headers. (#40254)
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinWise committed Aug 4, 2020
1 parent 5514082 commit 4c18fb2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
22 changes: 3 additions & 19 deletions src/coreclr/src/debug/inc/dbgipcevents.h
Original file line number Diff line number Diff line change
Expand Up @@ -984,25 +984,9 @@ struct MSLAYOUT IPCEventTypeNameMapping
const char * eventName;
};

#ifdef _MSC_VER
extern const __declspec(selectany)
#else
constexpr
#endif
IPCEventTypeNameMapping DbgIPCEventTypeNames[] =
{
#define IPC_EVENT_TYPE0(type, val) { type, #type },
#define IPC_EVENT_TYPE1(type, val) { type, #type },
#define IPC_EVENT_TYPE2(type, val) { type, #type },
#include "dbgipceventtypes.h"
#undef IPC_EVENT_TYPE2
#undef IPC_EVENT_TYPE1
#undef IPC_EVENT_TYPE0
{ DB_IPCE_INVALID_EVENT, "DB_IPCE_Error" }
};

const size_t nameCount = sizeof(DbgIPCEventTypeNames) / sizeof(DbgIPCEventTypeNames[0]);
extern const IPCEventTypeNameMapping DbgIPCEventTypeNames[];

extern const size_t nameCount;

struct MSLAYOUT IPCENames // We use a class/struct so that the function can remain in a shared header file
{
Expand Down Expand Up @@ -1033,7 +1017,7 @@ struct MSLAYOUT IPCENames // We use a class/struct so that the function can rema
#undef IPC_EVENT_TYPE0
};

unsigned int i, lim;
size_t i, lim;

if (eventType < DB_IPCE_DEBUGGER_FIRST)
{
Expand Down
14 changes: 14 additions & 0 deletions src/coreclr/src/debug/shared/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,17 @@ void ExportILToNativeMap(ULONG32 cMap, // [in] Min size of mapExt, m
#endif // _DEBUG
}
}

const IPCEventTypeNameMapping DbgIPCEventTypeNames[] =
{
#define IPC_EVENT_TYPE0(type, val) { type, #type },
#define IPC_EVENT_TYPE1(type, val) { type, #type },
#define IPC_EVENT_TYPE2(type, val) { type, #type },
#include "dbgipceventtypes.h"
#undef IPC_EVENT_TYPE2
#undef IPC_EVENT_TYPE1
#undef IPC_EVENT_TYPE0
{ DB_IPCE_INVALID_EVENT, "DB_IPCE_Error" }
};

const size_t nameCount = sizeof(DbgIPCEventTypeNames) / sizeof(DbgIPCEventTypeNames[0]);
2 changes: 1 addition & 1 deletion src/coreclr/src/inc/cor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2093,7 +2093,7 @@ inline ULONG CorSigUncompressData( // return number of bytes of that compre
}


constexpr mdToken g_tkCorEncodeToken[4] ={mdtTypeDef, mdtTypeRef, mdtTypeSpec, mdtBaseType};
extern const mdToken g_tkCorEncodeToken[];

// uncompress a token
inline mdToken CorSigUncompressToken( // return the token.
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/src/utilcode/sigbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "sigbuilder.h"
#include "ex.h"

const mdToken g_tkCorEncodeToken[4] ={mdtTypeDef, mdtTypeRef, mdtTypeSpec, mdtBaseType};

void SigBuilder::AppendByte(BYTE b)
{
STANDARD_VM_CONTRACT;
Expand Down

0 comments on commit 4c18fb2

Please sign in to comment.