You've already forked linux-packaging-mono
Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
parent
1190d13a04
commit
6bdd276d05
13
external/corert/src/Native/Bootstrap/CMakeLists.txt
vendored
Normal file
13
external/corert/src/Native/Bootstrap/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
include_directories(../gc)
|
||||
include_directories(../gc/env)
|
||||
include_directories(../gc/sample)
|
||||
|
||||
if(CLR_CMAKE_PLATFORM_UNIX)
|
||||
add_compile_options(-Wno-format)
|
||||
add_compile_options(-Wno-unused-variable)
|
||||
add_compile_options(-Wno-unused-private-field)
|
||||
add_compile_options(-Wno-tautological-undefined-compare)
|
||||
endif()
|
||||
|
||||
add_subdirectory(base)
|
||||
add_subdirectory(cpp)
|
||||
44
external/corert/src/Native/Bootstrap/CppCodeGen.h
vendored
Normal file
44
external/corert/src/Native/Bootstrap/CppCodeGen.h
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
// CppCodeGen.h : Facilities for the C++ code generation backend
|
||||
|
||||
#ifndef __CPP_CODE_GEN_H
|
||||
#define __CPP_CODE_GEN_H
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Warnings disabled for generated cpp code
|
||||
#pragma warning(disable:4200) // zero-sized array
|
||||
#pragma warning(disable:4102) // unreferenced label
|
||||
#pragma warning(disable:4244) // possible loss of data
|
||||
#pragma warning(disable:4717) // recursive on all control paths
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define INT64VAL(x) (x##i64)
|
||||
#else
|
||||
#define INT64VAL(x) (x##LL)
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define CORERT_UNREACHABLE __assume(0)
|
||||
#else
|
||||
#define CORERT_UNREACHABLE __builtin_unreachable()
|
||||
#endif
|
||||
|
||||
// Use the bit representation of uint64_t `v` as the bit representation of a double.
|
||||
inline double __uint64_to_double(uint64_t v)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint64_t u64;
|
||||
double d;
|
||||
} val;
|
||||
val.u64 = v;
|
||||
return val.d;
|
||||
}
|
||||
|
||||
#endif // __CPP_CODE_GEN_H
|
||||
19
external/corert/src/Native/Bootstrap/base/CMakeLists.txt
vendored
Normal file
19
external/corert/src/Native/Bootstrap/base/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
project(bootstrapper)
|
||||
|
||||
set(SOURCES
|
||||
../main.cpp
|
||||
../common.cpp
|
||||
)
|
||||
|
||||
if(CLR_CMAKE_PLATFORM_UNIX)
|
||||
list(APPEND SOURCES
|
||||
../platform.unix.cpp)
|
||||
endif()
|
||||
|
||||
add_library(bootstrapper STATIC ${SOURCES})
|
||||
|
||||
# Install the static bootstrapper library
|
||||
install (TARGETS bootstrapper DESTINATION lib)
|
||||
if(WIN32)
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/bootstrapper.dir/$<CONFIG>/bootstrapper.pdb DESTINATION lib)
|
||||
endif()
|
||||
12
external/corert/src/Native/Bootstrap/common.cpp
vendored
Normal file
12
external/corert/src/Native/Bootstrap/common.cpp
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
// common.cpp : source file that includes just the standard includes
|
||||
// testNative.pch will be the pre-compiled header
|
||||
// common.obj will contain the pre-compiled type information
|
||||
|
||||
#include "common.h"
|
||||
|
||||
// TODO: reference any additional headers you need in common.H
|
||||
// and not in this file
|
||||
106
external/corert/src/Native/Bootstrap/common.h
vendored
Normal file
106
external/corert/src/Native/Bootstrap/common.h
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
// common.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#ifndef __COMMON_H
|
||||
#define __COMMON_H
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
class MethodTable;
|
||||
class Object;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define __NORETURN __declspec(noreturn)
|
||||
#else
|
||||
#define __NORETURN __attribute((noreturn))
|
||||
#endif
|
||||
|
||||
int __initialize_runtime();
|
||||
void __shutdown_runtime();
|
||||
|
||||
extern "C" Object * __allocate_object(MethodTable * pMT);
|
||||
extern "C" Object * __allocate_array(size_t elements, MethodTable * pMT);
|
||||
extern "C" Object * __castclass(void * obj, MethodTable * pMT);
|
||||
extern "C" Object * __isinst(void * obj, MethodTable * pMT);
|
||||
extern "C" __NORETURN void __throw_exception(void * pEx);
|
||||
|
||||
Object * __load_string_literal(const char * string);
|
||||
|
||||
extern "C" void __range_check_fail();
|
||||
|
||||
inline void __range_check(void * a, size_t elem)
|
||||
{
|
||||
if (elem >= *((size_t*)a + 1))
|
||||
__range_check_fail();
|
||||
}
|
||||
|
||||
Object * __get_commandline_args(int argc, char * argv[]);
|
||||
|
||||
// POD version of EEType to use for static initialization
|
||||
struct RawEEType
|
||||
{
|
||||
uint16_t m_componentSize;
|
||||
uint16_t m_flags;
|
||||
uint32_t m_baseSize;
|
||||
MethodTable * m_pBaseType;
|
||||
uint16_t m_usNumVtableSlots;
|
||||
uint16_t m_usNumInterfaces;
|
||||
uint32_t m_uHashCode;
|
||||
void* m_pIndirectionModule;
|
||||
};
|
||||
|
||||
struct ReversePInvokeFrame
|
||||
{
|
||||
void* m_savedPInvokeTransitionFrame;
|
||||
void* m_savedThread;
|
||||
};
|
||||
|
||||
void __reverse_pinvoke(ReversePInvokeFrame* pRevFrame);
|
||||
void __reverse_pinvoke_return(ReversePInvokeFrame* pRevFrame);
|
||||
|
||||
typedef size_t UIntNative;
|
||||
|
||||
inline bool IS_ALIGNED(UIntNative val, UIntNative alignment)
|
||||
{
|
||||
//ASSERT(0 == (alignment & (alignment - 1)));
|
||||
return 0 == (val & (alignment - 1));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool IS_ALIGNED(T* val, UIntNative alignment)
|
||||
{
|
||||
//ASSERT(0 == (alignment & (alignment - 1)));
|
||||
return IS_ALIGNED(reinterpret_cast<UIntNative>(val), alignment);
|
||||
}
|
||||
|
||||
#define RAW_MIN_OBJECT_SIZE (3*sizeof(void*))
|
||||
|
||||
#define AlignBaseSize(s) ((s < RAW_MIN_OBJECT_SIZE) ? RAW_MIN_OBJECT_SIZE : ((s + (sizeof(void*)-1) & ~(sizeof(void*)-1))))
|
||||
|
||||
#define ARRAY_BASE (2*sizeof(void*))
|
||||
|
||||
#endif // __COMMON_H
|
||||
21
external/corert/src/Native/Bootstrap/cpp/CMakeLists.txt
vendored
Normal file
21
external/corert/src/Native/Bootstrap/cpp/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
project(bootstrappercpp)
|
||||
|
||||
add_definitions(-DCPPCODEGEN)
|
||||
|
||||
set(SOURCES
|
||||
../main.cpp
|
||||
../common.cpp
|
||||
)
|
||||
|
||||
if(CLR_CMAKE_PLATFORM_UNIX)
|
||||
list(APPEND SOURCES
|
||||
../platform.unix.cpp)
|
||||
endif()
|
||||
|
||||
add_library(bootstrappercpp STATIC ${SOURCES})
|
||||
|
||||
# Install the static bootstrappercpp library
|
||||
install (TARGETS bootstrappercpp DESTINATION lib)
|
||||
if(WIN32)
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/bootstrappercpp.dir/$<CONFIG>/bootstrappercpp.pdb DESTINATION lib)
|
||||
endif()
|
||||
327
external/corert/src/Native/Bootstrap/main.cpp
vendored
Normal file
327
external/corert/src/Native/Bootstrap/main.cpp
vendored
Normal file
@@ -0,0 +1,327 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "sal.h"
|
||||
#include "gcenv.structs.h"
|
||||
#include "gcenv.base.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef CPPCODEGEN
|
||||
|
||||
//
|
||||
// This is the mechanism whereby multiple linked modules contribute their global data for initialization at
|
||||
// startup of the application.
|
||||
//
|
||||
// ILC creates sections in the output obj file to mark the beginning and end of merged global data.
|
||||
// It defines sentinel symbols that are used to get the addresses of the start and end of global data
|
||||
// at runtime. The section names are platform-specific to match platform-specific linker conventions.
|
||||
//
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
#pragma section(".modules$A", read)
|
||||
#pragma section(".modules$Z", read)
|
||||
extern "C" __declspec(allocate(".modules$A")) void * __modules_a[];
|
||||
extern "C" __declspec(allocate(".modules$Z")) void * __modules_z[];
|
||||
|
||||
__declspec(allocate(".modules$A")) void * __modules_a[] = { nullptr };
|
||||
__declspec(allocate(".modules$Z")) void * __modules_z[] = { nullptr };
|
||||
|
||||
//
|
||||
// Each obj file compiled from managed code has a .modules$I section containing a pointer to its ReadyToRun
|
||||
// data (which points at eager class constructors, frozen strings, etc).
|
||||
//
|
||||
// The #pragma ... /merge directive folds the book-end sections and all .modules$I sections from all input
|
||||
// obj files into .rdata in alphabetical order.
|
||||
//
|
||||
#pragma comment(linker, "/merge:.modules=.rdata")
|
||||
|
||||
extern "C" void __managedcode_a();
|
||||
extern "C" void __managedcode_z();
|
||||
|
||||
#else // _MSC_VER
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
||||
extern void * __modules_a[] __asm("section$start$__DATA$__modules");
|
||||
extern void * __modules_z[] __asm("section$end$__DATA$__modules");
|
||||
extern char __managedcode_a __asm("section$start$__TEXT$__managedcode");
|
||||
extern char __managedcode_z __asm("section$end$__TEXT$__managedcode");
|
||||
|
||||
#else // __APPLE__
|
||||
|
||||
extern "C" void * __start___modules[];
|
||||
extern "C" void * __stop___modules[];
|
||||
static void * (&__modules_a)[] = __start___modules;
|
||||
static void * (&__modules_z)[] = __stop___modules;
|
||||
|
||||
extern "C" char __start___managedcode;
|
||||
extern "C" char __stop___managedcode;
|
||||
static char& __managedcode_a = __start___managedcode;
|
||||
static char& __managedcode_z = __stop___managedcode;
|
||||
|
||||
#endif // __APPLE__
|
||||
|
||||
#endif // _MSC_VER
|
||||
|
||||
#endif // !CPPCODEGEN
|
||||
|
||||
|
||||
#ifdef CPPCODEGEN
|
||||
|
||||
#pragma warning(disable:4297)
|
||||
|
||||
extern "C" Object * RhNewObject(MethodTable * pMT);
|
||||
extern "C" Object * RhNewArray(MethodTable * pMT, int32_t elements);
|
||||
extern "C" void * RhTypeCast_IsInstanceOf(void * pObject, MethodTable * pMT);
|
||||
extern "C" void * RhTypeCast_CheckCast(void * pObject, MethodTable * pMT);
|
||||
extern "C" void RhpStelemRef(void * pArray, int index, void * pObj);
|
||||
extern "C" void * RhpLdelemaRef(void * pArray, int index, MethodTable * pMT);
|
||||
extern "C" __NORETURN void RhpThrowEx(void * pEx);
|
||||
|
||||
extern "C" Object * __allocate_object(MethodTable * pMT)
|
||||
{
|
||||
return RhNewObject(pMT);
|
||||
}
|
||||
|
||||
extern "C" Object * __allocate_array(size_t elements, MethodTable * pMT)
|
||||
{
|
||||
return RhNewArray(pMT, (int32_t)elements); // TODO: type mismatch
|
||||
}
|
||||
|
||||
extern "C" Object * __castclass(void * obj, MethodTable * pTargetMT)
|
||||
{
|
||||
return (Object *)RhTypeCast_CheckCast(obj, pTargetMT);
|
||||
}
|
||||
|
||||
extern "C" Object * __isinst(void * obj, MethodTable * pTargetMT)
|
||||
{
|
||||
return (Object *)RhTypeCast_IsInstanceOf(obj, pTargetMT);
|
||||
}
|
||||
|
||||
extern "C" void __stelem_ref(void * pArray, unsigned idx, void * obj)
|
||||
{
|
||||
RhpStelemRef(pArray, idx, obj);
|
||||
}
|
||||
|
||||
extern "C" void* __ldelema_ref(void * pArray, unsigned idx, MethodTable * type)
|
||||
{
|
||||
return RhpLdelemaRef(pArray, idx, type);
|
||||
}
|
||||
|
||||
extern "C" void __throw_exception(void * pEx)
|
||||
{
|
||||
RhpThrowEx(pEx);
|
||||
}
|
||||
|
||||
void __range_check_fail()
|
||||
{
|
||||
throw "ThrowRangeOverflowException";
|
||||
}
|
||||
|
||||
extern "C" void RhpReversePInvoke2(ReversePInvokeFrame* pRevFrame);
|
||||
extern "C" void RhpReversePInvokeReturn2(ReversePInvokeFrame* pRevFrame);
|
||||
|
||||
void __reverse_pinvoke(ReversePInvokeFrame* pRevFrame)
|
||||
{
|
||||
RhpReversePInvoke2(pRevFrame);
|
||||
}
|
||||
|
||||
void __reverse_pinvoke_return(ReversePInvokeFrame* pRevFrame)
|
||||
{
|
||||
RhpReversePInvokeReturn2(pRevFrame);
|
||||
}
|
||||
|
||||
namespace System_Private_CoreLib { namespace System {
|
||||
|
||||
class Object {
|
||||
public:
|
||||
MethodTable * get_EEType() { return *(MethodTable **)this; }
|
||||
};
|
||||
|
||||
class Array : public Object {
|
||||
public:
|
||||
int32_t GetArrayLength() {
|
||||
return *(int32_t *)((void **)this + 1);
|
||||
}
|
||||
void * GetArrayData() {
|
||||
return (void **)this + 2;
|
||||
}
|
||||
};
|
||||
|
||||
class String : public Object { public:
|
||||
static MethodTable * __getMethodTable();
|
||||
};
|
||||
|
||||
class String__Array : public Object { public:
|
||||
static MethodTable * __getMethodTable();
|
||||
};
|
||||
|
||||
class EETypePtr { public:
|
||||
intptr_t m_value;
|
||||
};
|
||||
|
||||
}; };
|
||||
|
||||
Object * __load_string_literal(const char * string)
|
||||
{
|
||||
// TODO: Cache/intern string literals
|
||||
// TODO: Unicode string literals
|
||||
|
||||
size_t len = strlen(string);
|
||||
|
||||
Object * pString = RhNewArray(System_Private_CoreLib::System::String::__getMethodTable(), (int32_t)len);
|
||||
|
||||
uint16_t * p = (uint16_t *)((char*)pString + sizeof(intptr_t) + sizeof(int32_t));
|
||||
for (size_t i = 0; i < len; i++)
|
||||
p[i] = string[i];
|
||||
return pString;
|
||||
}
|
||||
|
||||
extern "C" void RhpThrowEx(void * pEx)
|
||||
{
|
||||
throw "RhpThrowEx";
|
||||
}
|
||||
extern "C" void RhpThrowHwEx()
|
||||
{
|
||||
throw "RhpThrowHwEx";
|
||||
}
|
||||
extern "C" void RhpCallCatchFunclet()
|
||||
{
|
||||
throw "RhpCallCatchFunclet";
|
||||
}
|
||||
extern "C" void RhpCallFilterFunclet()
|
||||
{
|
||||
throw "RhpCallFilterFunclet";
|
||||
}
|
||||
extern "C" void RhpCallFinallyFunclet()
|
||||
{
|
||||
throw "RhpCallFinallyFunclet";
|
||||
}
|
||||
extern "C" void RhpUniversalTransition()
|
||||
{
|
||||
throw "RhpUniversalTransition";
|
||||
}
|
||||
extern "C" void RhpUniversalTransition_DebugStepTailCall()
|
||||
{
|
||||
throw "RhpUniversalTransition_DebugStepTailCall";
|
||||
}
|
||||
|
||||
void* RtRHeaderWrapper();
|
||||
|
||||
#endif // CPPCODEGEN
|
||||
|
||||
extern "C" void __fail_fast()
|
||||
{
|
||||
// TODO: FailFast
|
||||
printf("Call to an unimplemented runtime method; execution cannot continue.\n");
|
||||
printf("Method: __fail_fast\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
extern "C" bool REDHAWK_PALAPI PalInit();
|
||||
|
||||
#define DLL_PROCESS_ATTACH 1
|
||||
extern "C" BOOL WINAPI RtuDllMain(HANDLE hPalInstance, DWORD dwReason, void* pvReserved);
|
||||
|
||||
extern "C" int32_t RhpEnableConservativeStackReporting();
|
||||
|
||||
extern "C" void RhpShutdown();
|
||||
|
||||
#ifndef CPPCODEGEN
|
||||
|
||||
extern "C" bool RhpRegisterCoffModule(void * pModule,
|
||||
void * pvStartRange, uint32_t cbRange,
|
||||
void ** pClasslibFunctions, uint32_t nClasslibFunctions);
|
||||
|
||||
extern "C" bool RhpRegisterUnixModule(void * pModule,
|
||||
void * pvStartRange, uint32_t cbRange,
|
||||
void ** pClasslibFunctions, uint32_t nClasslibFunctions);
|
||||
|
||||
#ifdef _WIN32
|
||||
extern "C" void* WINAPI GetModuleHandleW(const wchar_t *);
|
||||
#else
|
||||
extern "C" void* WINAPI PalGetModuleHandleFromPointer(void* pointer);
|
||||
#endif
|
||||
|
||||
extern "C" void GetRuntimeException();
|
||||
extern "C" void FailFast();
|
||||
extern "C" void AppendExceptionStackFrame();
|
||||
|
||||
typedef void(*pfn)();
|
||||
|
||||
static const pfn c_classlibFunctions[] = {
|
||||
&GetRuntimeException,
|
||||
&FailFast,
|
||||
nullptr, // &UnhandledExceptionHandler,
|
||||
&AppendExceptionStackFrame,
|
||||
};
|
||||
|
||||
#endif // !CPPCODEGEN
|
||||
|
||||
extern "C" void InitializeModules(void ** modules, int count);
|
||||
|
||||
#if defined(_WIN32)
|
||||
extern "C" int __managed__Main(int argc, wchar_t* argv[]);
|
||||
int wmain(int argc, wchar_t* argv[])
|
||||
#else
|
||||
extern "C" int __managed__Main(int argc, char* argv[]);
|
||||
int main(int argc, char* argv[])
|
||||
#endif
|
||||
{
|
||||
if (!PalInit())
|
||||
return -1;
|
||||
|
||||
if (!RtuDllMain(NULL, DLL_PROCESS_ATTACH, NULL))
|
||||
return -1;
|
||||
|
||||
if (!RhpEnableConservativeStackReporting())
|
||||
return -1;
|
||||
|
||||
#ifndef CPPCODEGEN
|
||||
#if defined(_WIN32)
|
||||
if (!RhpRegisterCoffModule(GetModuleHandleW(NULL),
|
||||
#else // _WIN32
|
||||
if (!RhpRegisterUnixModule(PalGetModuleHandleFromPointer((void*)&main),
|
||||
#endif // _WIN32
|
||||
(void*)&__managedcode_a, (uint32_t)((char *)&__managedcode_z - (char*)&__managedcode_a),
|
||||
(void **)&c_classlibFunctions, _countof(c_classlibFunctions)))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif // !CPPCODEGEN
|
||||
|
||||
#ifdef CPPCODEGEN
|
||||
ReversePInvokeFrame frame;
|
||||
__reverse_pinvoke(&frame);
|
||||
#endif
|
||||
|
||||
#ifndef CPPCODEGEN
|
||||
InitializeModules(__modules_a, (int)((__modules_z - __modules_a)));
|
||||
#else // !CPPCODEGEN
|
||||
InitializeModules((void**)RtRHeaderWrapper(), 2);
|
||||
#endif // !CPPCODEGEN
|
||||
|
||||
int retval;
|
||||
try
|
||||
{
|
||||
retval = __managed__Main(argc, argv);
|
||||
}
|
||||
catch (const char* &e)
|
||||
{
|
||||
printf("Call to an unimplemented runtime method; execution cannot continue.\n");
|
||||
printf("Method: %s\n", e);
|
||||
retval = -1;
|
||||
}
|
||||
|
||||
#ifdef CPPCODEGEN
|
||||
__reverse_pinvoke_return(&frame);
|
||||
#endif
|
||||
|
||||
RhpShutdown();
|
||||
|
||||
return retval;
|
||||
}
|
||||
110
external/corert/src/Native/Bootstrap/platform.unix.cpp
vendored
Normal file
110
external/corert/src/Native/Bootstrap/platform.unix.cpp
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <stdint.h>
|
||||
|
||||
//
|
||||
// Temporary stubs for Windows PInvoke functions not ported to Unix yet
|
||||
//
|
||||
|
||||
// UNIXTODO: Port System.Private.Interop to Unix https://github.com/dotnet/corert/issues/669
|
||||
extern "C"
|
||||
{
|
||||
int32_t WideCharToMultiByte(uint32_t CodePage, uint32_t dwFlags, uint16_t* lpWideCharStr, int32_t cchWideChar, intptr_t lpMultiByteStr, int32_t cbMultiByte, intptr_t lpDefaultChar, intptr_t lpUsedDefaultChar)
|
||||
{
|
||||
throw "WideCharToMultiByte";
|
||||
}
|
||||
|
||||
int32_t MultiByteToWideChar(uint32_t CodePage, uint32_t dwFlags, const uint8_t * lpMultiByteStr, int32_t cbMultiByte, uint16_t* lpWideCharStr, int32_t cchWideChar)
|
||||
{
|
||||
throw "MultiByteToWideChar";
|
||||
}
|
||||
|
||||
void CoTaskMemFree(void* m)
|
||||
{
|
||||
free(m);
|
||||
}
|
||||
|
||||
intptr_t CoTaskMemAlloc(intptr_t size)
|
||||
{
|
||||
return (intptr_t)malloc(size);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// TODO: Remove this when when we replace the references of
|
||||
// Interop.mincore.GetLastError with Marsha.GetLastWin32Error
|
||||
// CoreLib System.Text and System.Threading in CoreLib
|
||||
uint32_t GetLastError()
|
||||
{
|
||||
throw "GetLastError";
|
||||
}
|
||||
|
||||
uint32_t WaitForMultipleObjectsEx(uint32_t, void*, uint32_t, uint32_t, uint32_t)
|
||||
{
|
||||
throw "WaitForMultipleObjectsEx";
|
||||
}
|
||||
|
||||
void CoCreateGuid()
|
||||
{
|
||||
throw "CoCreateGuid";
|
||||
}
|
||||
|
||||
void CoGetApartmentType()
|
||||
{
|
||||
throw "CoGetApartmentType";
|
||||
}
|
||||
|
||||
void CreateEventExW()
|
||||
{
|
||||
throw "CreateEventExW";
|
||||
}
|
||||
|
||||
void OutputDebugStringW()
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t GetCurrentThreadId()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
|
||||
uint32_t RhCompatibleReentrantWaitAny(uint32_t alertable, uint32_t timeout, uint32_t count, void* pHandles)
|
||||
{
|
||||
throw "RhCompatibleReentrantWaitAny";
|
||||
}
|
||||
|
||||
void EnumDynamicTimeZoneInformation()
|
||||
{
|
||||
throw "EnumDynamicTimeZoneInformation";
|
||||
}
|
||||
|
||||
void GetDynamicTimeZoneInformation()
|
||||
{
|
||||
throw "GetDynamicTimeZoneInformation";
|
||||
}
|
||||
|
||||
void GetDynamicTimeZoneInformationEffectiveYears()
|
||||
{
|
||||
throw "GetDynamicTimeZoneInformationEffectiveYears";
|
||||
}
|
||||
|
||||
void GetTimeZoneInformationForYear()
|
||||
{
|
||||
throw "GetTimeZoneInformationForYear";
|
||||
}
|
||||
|
||||
void GetCPInfo()
|
||||
{
|
||||
throw "GetCPInfo";
|
||||
}
|
||||
|
||||
void EventWriteTransfer()
|
||||
{
|
||||
throw "EventWriteTransfer";
|
||||
}
|
||||
}
|
||||
230
external/corert/src/Native/CMakeLists.txt
vendored
Normal file
230
external/corert/src/Native/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
project(CoreRT)
|
||||
|
||||
# Include cmake functions
|
||||
include(functions.cmake)
|
||||
|
||||
string(FIND ${CMAKE_GENERATOR} "Visual Studio 15 2017" VS2017_POS)
|
||||
if(VS2017_POS EQUAL 0 AND (CMAKE_VERSION VERSION_LESS 3.6.0))
|
||||
message(FATAL_ERROR "CMake version 3.6.0 or higher is required to compile targeting VS 2017")
|
||||
endif()
|
||||
|
||||
set(CMAKE_MACOSX_RPATH ON)
|
||||
set(CMAKE_INSTALL_PREFIX $ENV{__CMakeBinDir})
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
if(NOT WIN32)
|
||||
set(CMAKE_C_FLAGS "-std=c11")
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11")
|
||||
endif()
|
||||
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
||||
|
||||
function(clr_unknown_arch)
|
||||
if (WIN32)
|
||||
message(FATAL_ERROR "Only AMD64 and I386 are supported")
|
||||
else()
|
||||
message(FATAL_ERROR "Only AMD64, ARM64 and ARM are supported")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
|
||||
set(IS_64BIT_BUILD 1)
|
||||
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
|
||||
add_definitions(-DBIT32=1)
|
||||
# Because we don't use CMAKE_C_COMPILER/CMAKE_CXX_COMPILER to use clang
|
||||
# we have to set the triple by adding a compiler argument
|
||||
add_compile_options(-target armv7-linux-gnueabihf)
|
||||
add_compile_options(-mthumb)
|
||||
add_compile_options(-mfpu=vfpv3)
|
||||
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
|
||||
set(IS_64BIT_BUILD 1)
|
||||
# Because we don't use CMAKE_C_COMPILER/CMAKE_CXX_COMPILER to use clang
|
||||
# we have to set the triple by adding a compiler argument
|
||||
add_compile_options(-target aarch64-linux-gnu)
|
||||
endif ()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
set(CLR_CMAKE_PLATFORM_UNIX 1)
|
||||
set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1)
|
||||
set(CLR_CMAKE_PLATFORM_DARWIN 1)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.4.0")
|
||||
set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> -o <OBJECT> -c <SOURCE>")
|
||||
else()
|
||||
set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> <INCLUDES> -o <OBJECT> -c <SOURCE>")
|
||||
endif(CMAKE_VERSION VERSION_LESS "3.4.0")
|
||||
endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||
set(CLR_CMAKE_PLATFORM_UNIX 1)
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
|
||||
set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
|
||||
set(CLR_CMAKE_PLATFORM_UNIX_TARGET_ARM 1)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
|
||||
set(CLR_CMAKE_PLATFORM_UNIX_TARGET_ARM64 1)
|
||||
else()
|
||||
clr_unknown_arch()
|
||||
endif()
|
||||
set(CLR_CMAKE_PLATFORM_LINUX 1)
|
||||
endif(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
|
||||
set(CLR_CMAKE_PLATFORM_UNIX 1)
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
|
||||
set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
|
||||
set(CLR_CMAKE_PLATFORM_UNIX_TARGET_ARM 1)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
|
||||
set(CLR_CMAKE_PLATFORM_UNIX_TARGET_ARM64 1)
|
||||
else()
|
||||
clr_unknown_arch()
|
||||
endif()
|
||||
set(CLR_CMAKE_PLATFORM_NETBSD 1)
|
||||
endif(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
|
||||
|
||||
if (CLR_CMAKE_PLATFORM_UNIX)
|
||||
include_directories(inc/unix)
|
||||
|
||||
add_definitions(-DPLATFORM_UNIX=1)
|
||||
add_definitions(-DPAL_STDCPP_COMPAT)
|
||||
|
||||
# All warnings that are not explicitly disabled are reported as errors
|
||||
add_compile_options(-Wall)
|
||||
add_compile_options(-Werror)
|
||||
add_compile_options(-Wno-invalid-offsetof)
|
||||
add_compile_options(-Wno-null-arithmetic)
|
||||
add_compile_options(-Wno-null-conversion)
|
||||
|
||||
if (CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64)
|
||||
# Allow 16 byte compare-exchange
|
||||
add_compile_options(-mcx16)
|
||||
add_definitions(-DUNIX_AMD64_ABI)
|
||||
endif()
|
||||
|
||||
# Disable strict warning on unused functions.
|
||||
add_compile_options(-Wno-unused-function)
|
||||
|
||||
# The -fms-extensions enable the stuff like __if_exists, __declspec(uuid()), etc.
|
||||
add_compile_options(-fms-extensions)
|
||||
|
||||
add_compile_options(-fPIC)
|
||||
add_compile_options(-fvisibility=hidden)
|
||||
|
||||
if(CLR_CMAKE_PLATFORM_DARWIN)
|
||||
# We cannot enable "stack-protector-strong" on OS X due to a bug in clang compiler (current version 7.0.2)
|
||||
add_compile_options(-fstack-protector)
|
||||
else()
|
||||
add_compile_options(-fstack-protector-strong)
|
||||
endif(CLR_CMAKE_PLATFORM_DARWIN)
|
||||
|
||||
if(CLR_CMAKE_PLATFORM_LINUX)
|
||||
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack")
|
||||
endif(CLR_CMAKE_PLATFORM_LINUX)
|
||||
endif(CLR_CMAKE_PLATFORM_UNIX)
|
||||
|
||||
if(CLR_CMAKE_PLATFORM_UNIX_TARGET_ARM)
|
||||
set(CLR_CMAKE_PLATFORM_ARCH_ARM 1)
|
||||
elseif(CLR_CMAKE_PLATFORM_UNIX_TARGET_ARM64)
|
||||
set(CLR_CMAKE_PLATFORM_ARCH_ARM64 1)
|
||||
elseif(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64)
|
||||
set(CLR_CMAKE_PLATFORM_ARCH_AMD64 1)
|
||||
elseif(WIN32)
|
||||
if (CLR_CMAKE_TARGET_ARCH STREQUAL x64)
|
||||
set(CLR_CMAKE_PLATFORM_ARCH_AMD64 1)
|
||||
set(IS_64BIT_BUILD 1)
|
||||
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86)
|
||||
set(CLR_CMAKE_PLATFORM_ARCH_I386 1)
|
||||
set(IS_64BIT_BUILD 0)
|
||||
else()
|
||||
clr_unknown_arch()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(IS_64BIT_BUILD)
|
||||
add_definitions(-DBIT64=1)
|
||||
endif(IS_64BIT_BUILD)
|
||||
|
||||
if(WIN32)
|
||||
enable_language(ASM_MASM)
|
||||
else()
|
||||
enable_language(ASM)
|
||||
endif(WIN32)
|
||||
|
||||
# Build a list of compiler definitions by putting -D in front of each define.
|
||||
function(get_compile_definitions DefinitionName)
|
||||
# Get the current list of definitions
|
||||
get_directory_property(COMPILE_DEFINITIONS_LIST COMPILE_DEFINITIONS)
|
||||
|
||||
foreach(DEFINITION IN LISTS COMPILE_DEFINITIONS_LIST)
|
||||
if (${DEFINITION} MATCHES "^\\$<\\$<CONFIG:([^>]+)>:([^>]+)>$")
|
||||
# The entries that contain generator expressions must have the -D inside of the
|
||||
# expression. So we transform e.g. $<$<CONFIG:Debug>:_DEBUG> to $<$<CONFIG:Debug>:-D_DEBUG>
|
||||
set(DEFINITION "$<$<CONFIG:${CMAKE_MATCH_1}>:-D${CMAKE_MATCH_2}>")
|
||||
else()
|
||||
set(DEFINITION -D${DEFINITION})
|
||||
endif()
|
||||
list(APPEND DEFINITIONS ${DEFINITION})
|
||||
endforeach()
|
||||
set(${DefinitionName} ${DEFINITIONS} PARENT_SCOPE)
|
||||
endfunction(get_compile_definitions)
|
||||
|
||||
if(CLR_CMAKE_PLATFORM_ARCH_AMD64)
|
||||
add_definitions(-D_TARGET_AMD64_=1)
|
||||
add_definitions(-D_AMD64_)
|
||||
elseif(CLR_CMAKE_PLATFORM_ARCH_I386)
|
||||
add_definitions(-D_TARGET_X86_=1)
|
||||
add_definitions(-D_X86_)
|
||||
elseif(CLR_CMAKE_PLATFORM_ARCH_ARM)
|
||||
add_definitions(-D_TARGET_ARM_=1)
|
||||
add_definitions(-D_ARM_)
|
||||
elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
|
||||
add_definitions(-D_TARGET_ARM64_=1)
|
||||
add_definitions(-D_ARM64_)
|
||||
else()
|
||||
clr_unknown_arch()
|
||||
endif()
|
||||
|
||||
# Set the passed in RetSources variable to the list of sources with added current source directory
|
||||
# to form absolute paths.
|
||||
# The parameters after the RetSources are the input files.
|
||||
function(convert_to_absolute_path RetSources)
|
||||
set(Sources ${ARGN})
|
||||
foreach(Source IN LISTS Sources)
|
||||
list(APPEND AbsolutePathSources ${CMAKE_CURRENT_SOURCE_DIR}/${Source})
|
||||
endforeach()
|
||||
set(${RetSources} ${AbsolutePathSources} PARENT_SCOPE)
|
||||
endfunction(convert_to_absolute_path)
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-DUNICODE=1)
|
||||
add_compile_options($<$<CONFIG:Debug>:-DDEBUG>)
|
||||
add_compile_options($<$<CONFIG:Debug>:/MTd>)
|
||||
add_compile_options($<$<CONFIG:Release>:/MT>)
|
||||
add_compile_options(/Zi) # enable debugging information
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG")
|
||||
else(WIN32)
|
||||
string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_CMAKE_BUILD_TYPE)
|
||||
if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
|
||||
add_compile_options(-g -O0)
|
||||
add_definitions(-DDEBUG)
|
||||
add_definitions(-D_DEBUG)
|
||||
elseif (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE)
|
||||
add_compile_options (-O3)
|
||||
add_definitions(-DNDEBUG)
|
||||
else ()
|
||||
message(FATAL_ERROR "Unknown build type. Set CMAKE_BUILD_TYPE to DEBUG or RELEASE.")
|
||||
endif ()
|
||||
endif (WIN32)
|
||||
|
||||
include(configure.cmake)
|
||||
|
||||
if(WIN32)
|
||||
add_subdirectory(gc)
|
||||
endif()
|
||||
add_subdirectory(Runtime)
|
||||
add_subdirectory(Bootstrap)
|
||||
add_subdirectory(jitinterface)
|
||||
|
||||
# We don't need the PAL on Windows.
|
||||
if(CLR_CMAKE_PLATFORM_UNIX)
|
||||
add_subdirectory(System.Private.CoreLib.Native)
|
||||
endif()
|
||||
28
external/corert/src/Native/Common/pal_utilities.h
vendored
Normal file
28
external/corert/src/Native/Common/pal_utilities.h
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <type_traits>
|
||||
|
||||
/**
|
||||
* Cast a positive value typed as a signed integer to the
|
||||
* appropriately sized unsigned integer type.
|
||||
*
|
||||
* We use this when we've already ensured that the value is positive,
|
||||
* but we don't want to cast to a specific unsigned type as that could
|
||||
* inadvertently defeat the compiler's narrowing conversion warnings
|
||||
* (which we treat as error).
|
||||
*/
|
||||
template <typename T>
|
||||
inline typename std::make_unsigned<T>::type UnsignedCast(T value)
|
||||
{
|
||||
assert(value >= 0);
|
||||
return static_cast<typename std::make_unsigned<T>::type>(value);
|
||||
}
|
||||
|
||||
116
external/corert/src/Native/Runtime/AsmOffsets.h
vendored
Normal file
116
external/corert/src/Native/Runtime/AsmOffsets.h
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
//
|
||||
// This file is used by AsmOffsets.cpp to validate that our
|
||||
// assembly-code offsets always match their C++ counterparts.
|
||||
|
||||
// You must #define PLAT_ASM_OFFSET and PLAT_ASM_SIZEOF before you #include this file
|
||||
|
||||
#ifdef BIT64
|
||||
#define ASM_OFFSET(offset32, offset64, cls, member) PLAT_ASM_OFFSET(offset64, cls, member)
|
||||
#define ASM_SIZEOF(sizeof32, sizeof64, cls ) PLAT_ASM_SIZEOF(sizeof64, cls)
|
||||
#define ASM_CONST(const32, const64, expr) PLAT_ASM_CONST(const64, expr)
|
||||
#else
|
||||
#define ASM_OFFSET(offset32, offset64, cls, member) PLAT_ASM_OFFSET(offset32, cls, member)
|
||||
#define ASM_SIZEOF(sizeof32, sizeof64, cls ) PLAT_ASM_SIZEOF(sizeof32, cls)
|
||||
#define ASM_CONST(const32, const64, expr) PLAT_ASM_CONST(const32, expr)
|
||||
#endif
|
||||
|
||||
// NOTE: the values MUST be in hex notation WITHOUT the 0x prefix
|
||||
|
||||
// 32-bit,64-bit, constant symbol
|
||||
ASM_CONST( 14c08, 14c08, RH_LARGE_OBJECT_SIZE)
|
||||
ASM_CONST( 400, 800, CLUMP_SIZE)
|
||||
ASM_CONST( a, b, LOG2_CLUMP_SIZE)
|
||||
|
||||
// 32-bit,64-bit, class, member
|
||||
ASM_OFFSET( 0, 0, Object, m_pEEType)
|
||||
|
||||
ASM_OFFSET( 4, 8, Array, m_Length)
|
||||
|
||||
ASM_OFFSET( 0, 0, EEType, m_usComponentSize)
|
||||
ASM_OFFSET( 2, 2, EEType, m_usFlags)
|
||||
ASM_OFFSET( 4, 4, EEType, m_uBaseSize)
|
||||
#if defined(CORERT)
|
||||
// If this ever changes, you must update src\ILCompiler.Compiler\src\Compiler\DependencyAnalysis\EETypeNode.cs GetVTableOffset()
|
||||
// to reflect the updated VTable offset
|
||||
ASM_OFFSET( 18, 20, EEType, m_VTable)
|
||||
#else
|
||||
ASM_OFFSET( 14, 18, EEType, m_VTable)
|
||||
#endif
|
||||
|
||||
ASM_OFFSET( 0, 0, Thread, m_rgbAllocContextBuffer)
|
||||
ASM_OFFSET( 28, 38, Thread, m_ThreadStateFlags)
|
||||
ASM_OFFSET( 2c, 40, Thread, m_pTransitionFrame)
|
||||
ASM_OFFSET( 30, 48, Thread, m_pHackPInvokeTunnel)
|
||||
ASM_OFFSET( 40, 68, Thread, m_ppvHijackedReturnAddressLocation)
|
||||
ASM_OFFSET( 44, 70, Thread, m_pvHijackedReturnAddress)
|
||||
ASM_OFFSET( 48, 78, Thread, m_pExInfoStackHead)
|
||||
|
||||
ASM_SIZEOF( 14, 20, EHEnum)
|
||||
|
||||
ASM_OFFSET( 0, 0, gc_alloc_context, alloc_ptr)
|
||||
ASM_OFFSET( 4, 8, gc_alloc_context, alloc_limit)
|
||||
|
||||
ASM_OFFSET( 4, 8, RuntimeInstance, m_pThreadStore)
|
||||
|
||||
#ifdef FEATURE_CACHED_INTERFACE_DISPATCH
|
||||
ASM_OFFSET( 4, 8, InterfaceDispatchCell, m_pCache)
|
||||
#ifndef BIT64
|
||||
ASM_OFFSET( 8, 0, InterfaceDispatchCache, m_pCell)
|
||||
#endif
|
||||
ASM_OFFSET( 10, 20, InterfaceDispatchCache, m_rgEntries)
|
||||
ASM_SIZEOF( 8, 10, InterfaceDispatchCacheEntry)
|
||||
#endif
|
||||
|
||||
ASM_OFFSET( 4, 8, StaticClassConstructionContext, m_initialized)
|
||||
|
||||
#ifdef FEATURE_DYNAMIC_CODE
|
||||
ASM_OFFSET( 0, 0, CallDescrData, pSrc)
|
||||
ASM_OFFSET( 4, 8, CallDescrData, numStackSlots)
|
||||
ASM_OFFSET( 8, C, CallDescrData, fpReturnSize)
|
||||
ASM_OFFSET( C, 10, CallDescrData, pArgumentRegisters)
|
||||
ASM_OFFSET( 10, 18, CallDescrData, pFloatArgumentRegisters)
|
||||
ASM_OFFSET( 14, 20, CallDescrData, pTarget)
|
||||
ASM_OFFSET( 18, 28, CallDescrData, pReturnBuffer)
|
||||
#endif
|
||||
|
||||
// Undefine macros that are only used in this header for convenience.
|
||||
#undef ASM_OFFSET
|
||||
#undef ASM_SIZEOF
|
||||
#undef ASM_CONST
|
||||
|
||||
// Define platform specific offsets
|
||||
#include "AsmOffsetsCpu.h"
|
||||
|
||||
//#define USE_COMPILE_TIME_CONSTANT_FINDER // Uncomment this line to use the constant finder
|
||||
#if defined(__cplusplus) && defined(USE_COMPILE_TIME_CONSTANT_FINDER)
|
||||
// This class causes the compiler to emit an error with the constant we're interested in
|
||||
// in the error message. This is useful if a size or offset changes. To use, comment out
|
||||
// the compile-time assert that is firing, enable the constant finder, add the appropriate
|
||||
// constant to find to BogusFunction(), and build.
|
||||
//
|
||||
// Here's a sample compiler error:
|
||||
// In file included from corert/src/Native/Runtime/AsmOffsetsVerify.cpp:38:
|
||||
// corert/src/Native/Runtime/Full/../AsmOffsets.h:117:61: error: calling a private constructor of class
|
||||
// 'AsmOffsets::FindCompileTimeConstant<25>'
|
||||
// FindCompileTimeConstant<offsetof(ExInfo, m_passNumber)> bogus_variable;
|
||||
// ^
|
||||
// corert/src/Native/Runtime/Full/../AsmOffsets.h:111:5: note: declared private here
|
||||
// FindCompileTimeConstant();
|
||||
// ^
|
||||
template<size_t N>
|
||||
class FindCompileTimeConstant
|
||||
{
|
||||
private:
|
||||
FindCompileTimeConstant();
|
||||
};
|
||||
|
||||
void BogusFunction()
|
||||
{
|
||||
// Sample usage to generate the error
|
||||
FindCompileTimeConstant<offsetof(ExInfo, m_passNumber)> bogus_variable;
|
||||
}
|
||||
#endif // defined(__cplusplus) && defined(USE_COMPILE_TIME_CONSTANT_FINDER)
|
||||
42
external/corert/src/Native/Runtime/AsmOffsetsVerify.cpp
vendored
Normal file
42
external/corert/src/Native/Runtime/AsmOffsetsVerify.cpp
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
#include "common.h"
|
||||
#include "gcenv.h"
|
||||
#include "gcheaputilities.h"
|
||||
#include "rhassert.h"
|
||||
#include "RedhawkWarnings.h"
|
||||
#include "slist.h"
|
||||
#include "gcrhinterface.h"
|
||||
#include "varint.h"
|
||||
#include "regdisplay.h"
|
||||
#include "StackFrameIterator.h"
|
||||
#include "thread.h"
|
||||
#include "TargetPtrs.h"
|
||||
#include "rhbinder.h"
|
||||
#include "RWLock.h"
|
||||
#include "RuntimeInstance.h"
|
||||
#include "CachedInterfaceDispatch.h"
|
||||
#include "shash.h"
|
||||
#include "module.h"
|
||||
#include "CallDescr.h"
|
||||
|
||||
class AsmOffsets
|
||||
{
|
||||
static_assert(sizeof(Thread::m_rgbAllocContextBuffer) >= sizeof(gc_alloc_context), "Thread::m_rgbAllocContextBuffer is not big enough to hold a gc_alloc_context");
|
||||
|
||||
#define PLAT_ASM_OFFSET(offset, cls, member) \
|
||||
static_assert((offsetof(cls, member) == 0x##offset) || (offsetof(cls, member) > 0x##offset), "Bad asm offset for '" #cls "." #member "', the actual offset is smaller than 0x" #offset "."); \
|
||||
static_assert((offsetof(cls, member) == 0x##offset) || (offsetof(cls, member) < 0x##offset), "Bad asm offset for '" #cls "." #member "', the actual offset is larger than 0x" #offset ".");
|
||||
|
||||
#define PLAT_ASM_SIZEOF(size, cls ) \
|
||||
static_assert((sizeof(cls) == 0x##size) || (sizeof(cls) > 0x##size), "Bad asm size for '" #cls "', the actual size is smaller than 0x" #size "."); \
|
||||
static_assert((sizeof(cls) == 0x##size) || (sizeof(cls) < 0x##size), "Bad asm size for '" #cls "', the actual size is larger than 0x" #size ".");
|
||||
|
||||
#define PLAT_ASM_CONST(constant, expr) \
|
||||
static_assert(((expr) == 0x##constant) || ((expr) > 0x##constant), "Bad asm constant for '" #expr "', the actual value is smaller than 0x" #constant "."); \
|
||||
static_assert(((expr) == 0x##constant) || ((expr) < 0x##constant), "Bad asm constant for '" #expr "', the actual value is larger than 0x" #constant ".");
|
||||
|
||||
#include "AsmOffsets.h"
|
||||
|
||||
};
|
||||
204
external/corert/src/Native/Runtime/CMakeLists.txt
vendored
Normal file
204
external/corert/src/Native/Runtime/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
set(COMMON_RUNTIME_SOURCES
|
||||
allocheap.cpp
|
||||
rhassert.cpp
|
||||
CachedInterfaceDispatch.cpp
|
||||
Crst.cpp
|
||||
DebugEventSource.cpp
|
||||
dllmain.cpp
|
||||
eetype.cpp
|
||||
EHHelpers.cpp
|
||||
event.cpp
|
||||
FinalizerHelpers.cpp
|
||||
gcdump.cpp
|
||||
GCHelpers.cpp
|
||||
gcheaputilities.cpp
|
||||
GCMemoryHelpers.cpp
|
||||
gcrhenv.cpp
|
||||
gcrhscan.cpp
|
||||
GcStressControl.cpp
|
||||
GenericUnification.cpp
|
||||
HandleTableHelpers.cpp
|
||||
MathHelpers.cpp
|
||||
MiscHelpers.cpp
|
||||
module.cpp
|
||||
TypeManager.cpp
|
||||
ObjectLayout.cpp
|
||||
OptionalFieldsRuntime.cpp
|
||||
portable.cpp
|
||||
profheapwalkhelper.cpp
|
||||
RestrictedCallouts.cpp
|
||||
RHCodeMan.cpp
|
||||
RhConfig.cpp
|
||||
RuntimeInstance.cpp
|
||||
RWLock.cpp
|
||||
SectionMethodList.cpp
|
||||
sha1.cpp
|
||||
StackFrameIterator.cpp
|
||||
startup.cpp
|
||||
stressLog.cpp
|
||||
strongname.cpp
|
||||
SyncClean.cpp
|
||||
thread.cpp
|
||||
threadstore.cpp
|
||||
UniversalTransitionHelpers.cpp
|
||||
|
||||
../gc/gccommon.cpp
|
||||
../gc/gceewks.cpp
|
||||
../gc/gcwks.cpp
|
||||
../gc/gcscan.cpp
|
||||
../gc/handletable.cpp
|
||||
../gc/handletablecache.cpp
|
||||
../gc/handletablecore.cpp
|
||||
../gc/handletablescan.cpp
|
||||
../gc/objecthandle.cpp
|
||||
)
|
||||
|
||||
set(FULL_RUNTIME_SOURCES
|
||||
AsmOffsetsVerify.cpp
|
||||
ThunksMapping.cpp
|
||||
)
|
||||
|
||||
set(RUNTIME_SOURCES_ARCH_ASM
|
||||
)
|
||||
|
||||
set(PORTABLE_RUNTIME_SOURCES
|
||||
)
|
||||
|
||||
include_directories(inc)
|
||||
|
||||
if(WIN32)
|
||||
|
||||
include_directories(windows)
|
||||
|
||||
list(APPEND COMMON_RUNTIME_SOURCES
|
||||
windows/PalRedhawkCommon.cpp
|
||||
windows/PalRedhawkMinWin.cpp
|
||||
)
|
||||
|
||||
list(APPEND FULL_RUNTIME_SOURCES
|
||||
windows/CoffNativeCodeManager.cpp
|
||||
)
|
||||
|
||||
if(CLR_CMAKE_PLATFORM_ARCH_AMD64)
|
||||
set(ARCH_SOURCES_DIR amd64)
|
||||
set(ASM_SUFFIX asm)
|
||||
endif()
|
||||
|
||||
list(APPEND RUNTIME_SOURCES_ARCH_ASM
|
||||
${ARCH_SOURCES_DIR}/GC.${ASM_SUFFIX}
|
||||
)
|
||||
|
||||
else()
|
||||
|
||||
include_directories(unix)
|
||||
include_directories(../libunwind/include)
|
||||
|
||||
# Disable building _Unwind_XXX style APIs of libunwind, since we don't use them.
|
||||
add_definitions(-D_LIBUNWIND_DISABLE_ZERO_COST_APIS=1)
|
||||
|
||||
# Compile unwinding only for the current compilation target architecture
|
||||
add_definitions(-D_LIBUNWIND_IS_NATIVE_ONLY)
|
||||
|
||||
list(APPEND COMMON_RUNTIME_SOURCES
|
||||
unix/PalRedhawkUnix.cpp
|
||||
)
|
||||
|
||||
list(APPEND FULL_RUNTIME_SOURCES
|
||||
unix/HardwareExceptions.cpp
|
||||
unix/UnixContext.cpp
|
||||
unix/UnixNativeCodeManager.cpp
|
||||
../libunwind/src/Unwind-EHABI.cpp
|
||||
../libunwind/src/libunwind.cpp
|
||||
)
|
||||
|
||||
if(CLR_CMAKE_PLATFORM_DARWIN)
|
||||
list(APPEND FULL_RUNTIME_SOURCES
|
||||
../libunwind/src/Unwind_AppleExtras.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CLR_CMAKE_PLATFORM_ARCH_AMD64)
|
||||
set(ARCH_SOURCES_DIR amd64)
|
||||
set(ASM_SUFFIX S)
|
||||
elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
|
||||
set(ARCH_SOURCES_DIR arm64)
|
||||
set(ASM_SUFFIX S)
|
||||
elseif(CLR_CMAKE_PLATFORM_ARCH_ARM)
|
||||
set(ARCH_SOURCES_DIR arm)
|
||||
set(ASM_SUFFIX S)
|
||||
endif()
|
||||
|
||||
list(APPEND RUNTIME_SOURCES_ARCH_ASM
|
||||
../libunwind/src/UnwindRegistersRestore.S
|
||||
../libunwind/src/UnwindRegistersSave.S
|
||||
)
|
||||
endif()
|
||||
|
||||
list(APPEND RUNTIME_SOURCES_ARCH_ASM
|
||||
${ARCH_SOURCES_DIR}/AllocFast.${ASM_SUFFIX}
|
||||
${ARCH_SOURCES_DIR}/ExceptionHandling.${ASM_SUFFIX}
|
||||
${ARCH_SOURCES_DIR}/Interlocked.${ASM_SUFFIX}
|
||||
${ARCH_SOURCES_DIR}/PInvoke.${ASM_SUFFIX}
|
||||
${ARCH_SOURCES_DIR}/StubDispatch.${ASM_SUFFIX}
|
||||
${ARCH_SOURCES_DIR}/UniversalTransition.${ASM_SUFFIX}
|
||||
${ARCH_SOURCES_DIR}/WriteBarriers.${ASM_SUFFIX}
|
||||
)
|
||||
|
||||
# Add architecture specific folder for looking up headers.
|
||||
convert_to_absolute_path(ARCH_SOURCES_DIR ${ARCH_SOURCES_DIR})
|
||||
include_directories(${ARCH_SOURCES_DIR})
|
||||
|
||||
add_definitions(-DFEATURE_BACKGROUND_GC)
|
||||
add_definitions(-DFEATURE_BASICFREEZE)
|
||||
add_definitions(-DFEATURE_CONSERVATIVE_GC)
|
||||
add_definitions(-DFEATURE_CUSTOM_IMPORTS)
|
||||
add_definitions(-DFEATURE_DYNAMIC_CODE)
|
||||
add_compile_options($<$<CONFIG:Debug>:-DFEATURE_GC_STRESS>)
|
||||
add_definitions(-DFEATURE_REDHAWK)
|
||||
add_definitions(-DVERIFY_HEAP)
|
||||
add_definitions(-DCORERT)
|
||||
add_definitions(-DFEATURE_CACHED_INTERFACE_DISPATCH)
|
||||
add_definitions(-D_LIB)
|
||||
|
||||
if(WIN32)
|
||||
# There is a problem with undefined symbol g_pConfig, windows don't care since it is in template method, but clang does
|
||||
add_definitions(-DSTRESS_HEAP)
|
||||
add_compile_options(/GS)
|
||||
add_compile_options(/W1)
|
||||
add_compile_options(/Zc:wchar_t)
|
||||
add_compile_options($<$<CONFIG:Debug>:/Zi>)
|
||||
add_compile_options($<$<CONFIG:Debug>:/Od>)
|
||||
add_compile_options(/Zc:inline)
|
||||
add_compile_options(/fp:precise)
|
||||
add_compile_options(/EHsc)
|
||||
else()
|
||||
add_definitions(-DNO_UI_ASSERT)
|
||||
|
||||
add_compile_options(-Wno-format)
|
||||
add_compile_options(-Wno-ignored-attributes)
|
||||
add_compile_options(-Wno-self-assign)
|
||||
add_compile_options(-Wno-tautological-undefined-compare)
|
||||
add_compile_options(-Wno-undefined-inline)
|
||||
add_compile_options(-Wno-unknown-pragmas)
|
||||
add_compile_options(-Wno-unused-function)
|
||||
add_compile_options(-Wno-unused-private-field)
|
||||
add_compile_options(-Wno-unused-value)
|
||||
add_compile_options(-Wno-unused-variable)
|
||||
|
||||
add_compile_options(-Qunused-arguments)
|
||||
|
||||
include(unix/configure.cmake)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
set(RUNTIME_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
convert_to_absolute_path(COMMON_RUNTIME_SOURCES ${COMMON_RUNTIME_SOURCES})
|
||||
|
||||
convert_to_absolute_path(FULL_RUNTIME_SOURCES ${FULL_RUNTIME_SOURCES})
|
||||
convert_to_absolute_path(PORTABLE_RUNTIME_SOURCES ${PORTABLE_RUNTIME_SOURCES})
|
||||
|
||||
convert_to_absolute_path(RUNTIME_SOURCES_ARCH_ASM ${RUNTIME_SOURCES_ARCH_ASM})
|
||||
|
||||
add_subdirectory(Full)
|
||||
add_subdirectory(Portable)
|
||||
577
external/corert/src/Native/Runtime/CachedInterfaceDispatch.cpp
vendored
Normal file
577
external/corert/src/Native/Runtime/CachedInterfaceDispatch.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
47
external/corert/src/Native/Runtime/CachedInterfaceDispatch.h
vendored
Normal file
47
external/corert/src/Native/Runtime/CachedInterfaceDispatch.h
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
// ==--==
|
||||
//
|
||||
// Shared (non-architecture specific) portions of a mechanism to perform interface dispatch using an alternate
|
||||
// mechanism to VSD that does not require runtime generation of code.
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
#ifdef FEATURE_CACHED_INTERFACE_DISPATCH
|
||||
|
||||
bool InitializeInterfaceDispatch();
|
||||
void ReclaimUnusedInterfaceDispatchCaches();
|
||||
|
||||
// Interface dispatch caches contain an array of these entries. An instance of a cache is paired with a stub
|
||||
// that implicitly knows how many entries are contained. These entries must be aligned to twice the alignment
|
||||
// of a pointer due to the synchonization mechanism used to update them at runtime.
|
||||
struct InterfaceDispatchCacheEntry
|
||||
{
|
||||
EEType * m_pInstanceType; // Potential type of the object instance being dispatched on
|
||||
void * m_pTargetCode; // Method to dispatch to if the actual instance type matches the above
|
||||
};
|
||||
|
||||
// The interface dispatch cache itself. As well as the entries we include the cache size (since logic such as
|
||||
// cache miss processing needs to determine this value in a synchronized manner, so it can't be contained in
|
||||
// the owning interface dispatch indirection cell) and a list entry used to link the caches in one of a couple
|
||||
// of lists related to cache reclamation.
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4200) // nonstandard extension used: zero-sized array in struct/union
|
||||
struct InterfaceDispatchCell;
|
||||
struct InterfaceDispatchCache
|
||||
{
|
||||
InterfaceDispatchCacheHeader m_cacheHeader;
|
||||
union
|
||||
{
|
||||
InterfaceDispatchCache * m_pNextFree; // next in free list
|
||||
#ifndef _AMD64_
|
||||
InterfaceDispatchCell * m_pCell; // pointer back to interface dispatch cell - not used for AMD64
|
||||
#endif
|
||||
};
|
||||
UInt32 m_cEntries;
|
||||
InterfaceDispatchCacheEntry m_rgEntries[];
|
||||
};
|
||||
#pragma warning(pop)
|
||||
|
||||
#endif // FEATURE_CACHED_INTERFACE_DISPATCH
|
||||
14
external/corert/src/Native/Runtime/CallDescr.h
vendored
Normal file
14
external/corert/src/Native/Runtime/CallDescr.h
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
struct CallDescrData
|
||||
{
|
||||
uint8_t* pSrc;
|
||||
int numStackSlots;
|
||||
int fpReturnSize;
|
||||
uint8_t* pArgumentRegisters;
|
||||
uint8_t* pFloatArgumentRegisters;
|
||||
void* pTarget;
|
||||
void* pReturnBuffer;
|
||||
};
|
||||
231
external/corert/src/Native/Runtime/CommonMacros.h
vendored
Normal file
231
external/corert/src/Native/Runtime/CommonMacros.h
vendored
Normal file
@@ -0,0 +1,231 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
// Some of our header files are shared with the binder, which needs the _TARGET_* macros defined
|
||||
#if defined(_TARGET_AMD64_)
|
||||
#elif defined(_TARGET_X86_)
|
||||
#elif defined(_TARGET_ARM_)
|
||||
#elif defined(_TARGET_ARM64_)
|
||||
#else
|
||||
#error Unsupported architecture
|
||||
#endif
|
||||
|
||||
#define EXTERN_C extern "C"
|
||||
#define FASTCALL __fastcall
|
||||
#define STDCALL __stdcall
|
||||
#define REDHAWK_API
|
||||
#define REDHAWK_CALLCONV __fastcall
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#define MSVC_SAVE_WARNING_STATE() __pragma(warning(push))
|
||||
#define MSVC_DISABLE_WARNING(warn_num) __pragma(warning(disable: warn_num))
|
||||
#define MSVC_RESTORE_WARNING_STATE() __pragma(warning(pop))
|
||||
|
||||
#else
|
||||
|
||||
#define MSVC_SAVE_WARNING_STATE()
|
||||
#define MSVC_DISABLE_WARNING(warn_num)
|
||||
#define MSVC_RESTORE_WARNING_STATE()
|
||||
|
||||
#endif // _MSC_VER
|
||||
|
||||
#ifndef COUNTOF
|
||||
template <typename _CountofType, size_t _SizeOfArray>
|
||||
char (*COUNTOF_helper(_CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
|
||||
#define COUNTOF(_Array) sizeof(*COUNTOF_helper(_Array))
|
||||
#endif // COUNTOF
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(s,m) (UIntNative)( (IntNative)&reinterpret_cast<const volatile char&>((((s *)0)->m)) )
|
||||
#endif // offsetof
|
||||
|
||||
#ifndef FORCEINLINE
|
||||
#define FORCEINLINE __forceinline
|
||||
#endif
|
||||
|
||||
#ifndef NOINLINE
|
||||
#ifdef _MSC_VER
|
||||
#define NOINLINE __declspec(noinline)
|
||||
#else
|
||||
#define NOINLINE __attribute__((noinline))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
inline UIntNative ALIGN_UP(UIntNative val, UIntNative alignment);
|
||||
template <typename T>
|
||||
inline T* ALIGN_UP(T* val, UIntNative alignment);
|
||||
|
||||
inline UIntNative ALIGN_DOWN(UIntNative val, UIntNative alignment);
|
||||
template <typename T>
|
||||
inline T* ALIGN_DOWN(T* val, UIntNative alignment);
|
||||
|
||||
inline bool IS_ALIGNED(UIntNative val, UIntNative alignment);
|
||||
template <typename T>
|
||||
inline bool IS_ALIGNED(T* val, UIntNative alignment);
|
||||
|
||||
#ifndef DACCESS_COMPILE
|
||||
//
|
||||
// Basic memory copying/clearing functionality (rather than depend on the CRT). All our current compilers
|
||||
// actually provide these as intrinsics so use those for now (and provide non-CRT names for them as well).
|
||||
//
|
||||
|
||||
EXTERN_C void * __cdecl memcpy(void *, const void *, size_t);
|
||||
#pragma intrinsic(memcpy)
|
||||
#ifndef CopyMemory
|
||||
#define CopyMemory(_dst, _src, _size) memcpy((_dst), (_src), (_size))
|
||||
#endif
|
||||
|
||||
EXTERN_C void * __cdecl memset(void *, int, size_t);
|
||||
#pragma intrinsic(memset)
|
||||
#ifndef FillMemory
|
||||
#define FillMemory(_dst, _size, _fill) memset((_dst), (_fill), (_size))
|
||||
#endif
|
||||
#ifndef ZeroMemory
|
||||
#define ZeroMemory(_dst, _size) memset((_dst), 0, (_size))
|
||||
#endif
|
||||
|
||||
EXTERN_C int __cdecl memcmp(const void *,const void *,size_t);
|
||||
#pragma intrinsic(memcmp)
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// min/max
|
||||
|
||||
#ifndef min
|
||||
#define min(_a, _b) ((_a) < (_b) ? (_a) : (_b))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(_a, _b) ((_a) < (_b) ? (_b) : (_a))
|
||||
#endif
|
||||
|
||||
#endif // !DACCESS_COMPILE
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Platform-specific defines
|
||||
|
||||
#if defined(_AMD64_)
|
||||
|
||||
#define LOG2_PTRSIZE 3
|
||||
#define POINTER_SIZE 8
|
||||
|
||||
#elif defined(_X86_)
|
||||
|
||||
#define LOG2_PTRSIZE 2
|
||||
#define POINTER_SIZE 4
|
||||
|
||||
#elif defined(_ARM_)
|
||||
|
||||
#define LOG2_PTRSIZE 2
|
||||
#define POINTER_SIZE 4
|
||||
|
||||
#elif defined(_ARM64_)
|
||||
|
||||
#define LOG2_PTRSIZE 3
|
||||
#define POINTER_SIZE 8
|
||||
|
||||
#else
|
||||
#error Unsupported target architecture
|
||||
#endif
|
||||
|
||||
#ifndef GCENV_INCLUDED
|
||||
#if defined(_AMD64_)
|
||||
|
||||
#define DATA_ALIGNMENT 8
|
||||
#define OS_PAGE_SIZE 0x1000
|
||||
|
||||
#elif defined(_X86_)
|
||||
|
||||
#define DATA_ALIGNMENT 4
|
||||
#ifndef OS_PAGE_SIZE
|
||||
#define OS_PAGE_SIZE 0x1000
|
||||
#endif
|
||||
|
||||
#elif defined(_ARM_)
|
||||
|
||||
#define DATA_ALIGNMENT 4
|
||||
#ifndef OS_PAGE_SIZE
|
||||
#define OS_PAGE_SIZE 0x1000
|
||||
#endif
|
||||
|
||||
#elif defined(_ARM64_)
|
||||
|
||||
#define DATA_ALIGNMENT 8
|
||||
#ifndef OS_PAGE_SIZE
|
||||
#define OS_PAGE_SIZE 0x1000
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error Unsupported target architecture
|
||||
#endif
|
||||
#endif // GCENV_INCLUDED
|
||||
|
||||
//
|
||||
// Define an unmanaged function called from managed code that needs to execute in co-operative GC mode. (There
|
||||
// should be very few of these, most such functions will be simply p/invoked).
|
||||
//
|
||||
#define COOP_PINVOKE_HELPER(_rettype, _method, _args) EXTERN_C REDHAWK_API _rettype __fastcall _method _args
|
||||
#ifdef _X86_
|
||||
// We have helpers that act like memcpy and memset from the CRT, so they need to be __cdecl.
|
||||
#define COOP_PINVOKE_CDECL_HELPER(_rettype, _method, _args) EXTERN_C REDHAWK_API _rettype __cdecl _method _args
|
||||
#else
|
||||
#define COOP_PINVOKE_CDECL_HELPER COOP_PINVOKE_HELPER
|
||||
#endif
|
||||
|
||||
#ifndef DACCESS_COMPILE
|
||||
#define IN_DAC(x)
|
||||
#define NOT_IN_DAC(x) x
|
||||
#else
|
||||
#define IN_DAC(x) x
|
||||
#define NOT_IN_DAC(x)
|
||||
#endif
|
||||
|
||||
#define INLINE inline
|
||||
|
||||
enum STARTUP_TIMELINE_EVENT_ID
|
||||
{
|
||||
PROCESS_ATTACH_BEGIN = 0,
|
||||
NONGC_INIT_COMPLETE,
|
||||
GC_INIT_COMPLETE,
|
||||
PROCESS_ATTACH_COMPLETE,
|
||||
|
||||
NUM_STARTUP_TIMELINE_EVENTS
|
||||
};
|
||||
|
||||
#ifdef PROFILE_STARTUP
|
||||
extern unsigned __int64 g_startupTimelineEvents[NUM_STARTUP_TIMELINE_EVENTS];
|
||||
#define STARTUP_TIMELINE_EVENT(eventid) PalQueryPerformanceCounter((LARGE_INTEGER*)&g_startupTimelineEvents[eventid]);
|
||||
#else // PROFILE_STARTUP
|
||||
#define STARTUP_TIMELINE_EVENT(eventid)
|
||||
#endif // PROFILE_STARTUP
|
||||
|
||||
bool inline FitsInI4(__int64 val)
|
||||
{
|
||||
return val == (__int64)(__int32)val;
|
||||
}
|
||||
|
||||
#ifndef C_ASSERT
|
||||
#define C_ASSERT(e) static_assert(e, #e)
|
||||
#endif // C_ASSERT
|
||||
|
||||
#ifdef __llvm__
|
||||
#define DECLSPEC_THREAD __thread
|
||||
#else // __llvm__
|
||||
#define DECLSPEC_THREAD __declspec(thread)
|
||||
#endif // !__llvm__
|
||||
|
||||
#ifndef GCENV_INCLUDED
|
||||
#if !defined(_INC_WINDOWS) && !defined(BINDER)
|
||||
#ifdef _WIN32
|
||||
// this must exactly match the typedef used by windows.h
|
||||
typedef long HRESULT;
|
||||
#else
|
||||
typedef int32_t HRESULT;
|
||||
#endif
|
||||
|
||||
#define S_OK 0x0
|
||||
#define E_FAIL 0x80004005
|
||||
|
||||
#define UNREFERENCED_PARAMETER(P) (void)(P)
|
||||
#endif // !defined(_INC_WINDOWS) && !defined(BINDER)
|
||||
#endif // GCENV_INCLUDED
|
||||
47
external/corert/src/Native/Runtime/CommonMacros.inl
vendored
Normal file
47
external/corert/src/Native/Runtime/CommonMacros.inl
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
inline UIntNative ALIGN_UP( UIntNative val, UIntNative alignment )
|
||||
{
|
||||
// alignment must be a power of 2 for this implementation to work (need modulo otherwise)
|
||||
ASSERT( 0 == (alignment & (alignment - 1)) );
|
||||
UIntNative result = (val + (alignment - 1)) & ~(alignment - 1);
|
||||
ASSERT( result >= val ); // check for overflow
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T* ALIGN_UP(T* val, UIntNative alignment)
|
||||
{
|
||||
return reinterpret_cast<T*>(ALIGN_UP(reinterpret_cast<UIntNative>(val), alignment));
|
||||
}
|
||||
|
||||
inline UIntNative ALIGN_DOWN( UIntNative val, UIntNative alignment )
|
||||
{
|
||||
// alignment must be a power of 2 for this implementation to work (need modulo otherwise)
|
||||
ASSERT( 0 == (alignment & (alignment - 1)) );
|
||||
UIntNative result = val & ~(alignment - 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T* ALIGN_DOWN(T* val, UIntNative alignment)
|
||||
{
|
||||
return reinterpret_cast<T*>(ALIGN_DOWN(reinterpret_cast<UIntNative>(val), alignment));
|
||||
}
|
||||
|
||||
inline bool IS_ALIGNED(UIntNative val, UIntNative alignment)
|
||||
{
|
||||
ASSERT(0 == (alignment & (alignment - 1)));
|
||||
return 0 == (val & (alignment - 1));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool IS_ALIGNED(T* val, UIntNative alignment)
|
||||
{
|
||||
ASSERT(0 == (alignment & (alignment - 1)));
|
||||
return IS_ALIGNED(reinterpret_cast<UIntNative>(val), alignment);
|
||||
}
|
||||
|
||||
71
external/corert/src/Native/Runtime/Crst.cpp
vendored
Normal file
71
external/corert/src/Native/Runtime/Crst.cpp
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
#include "common.h"
|
||||
#include "CommonTypes.h"
|
||||
#include "CommonMacros.h"
|
||||
#include "PalRedhawkCommon.h"
|
||||
#include "PalRedhawk.h"
|
||||
#include "holder.h"
|
||||
#include "Crst.h"
|
||||
|
||||
void CrstStatic::Init(CrstType eType, CrstFlags eFlags)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(eType);
|
||||
UNREFERENCED_PARAMETER(eFlags);
|
||||
#ifndef DACCESS_COMPILE
|
||||
#if defined(_DEBUG)
|
||||
m_uiOwnerId.Clear();
|
||||
#endif // _DEBUG
|
||||
PalInitializeCriticalSectionEx(&m_sCritSec, 0, 0);
|
||||
#endif // !DACCESS_COMPILE
|
||||
}
|
||||
|
||||
void CrstStatic::Destroy()
|
||||
{
|
||||
#ifndef DACCESS_COMPILE
|
||||
PalDeleteCriticalSection(&m_sCritSec);
|
||||
#endif // !DACCESS_COMPILE
|
||||
}
|
||||
|
||||
// static
|
||||
void CrstStatic::Enter(CrstStatic *pCrst)
|
||||
{
|
||||
#ifndef DACCESS_COMPILE
|
||||
PalEnterCriticalSection(&pCrst->m_sCritSec);
|
||||
#if defined(_DEBUG)
|
||||
pCrst->m_uiOwnerId.SetToCurrentThread();
|
||||
#endif // _DEBUG
|
||||
#else
|
||||
UNREFERENCED_PARAMETER(pCrst);
|
||||
#endif // !DACCESS_COMPILE
|
||||
}
|
||||
|
||||
// static
|
||||
void CrstStatic::Leave(CrstStatic *pCrst)
|
||||
{
|
||||
#ifndef DACCESS_COMPILE
|
||||
#if defined(_DEBUG)
|
||||
pCrst->m_uiOwnerId.Clear();
|
||||
#endif // _DEBUG
|
||||
PalLeaveCriticalSection(&pCrst->m_sCritSec);
|
||||
#else
|
||||
UNREFERENCED_PARAMETER(pCrst);
|
||||
#endif // !DACCESS_COMPILE
|
||||
}
|
||||
|
||||
#if defined(_DEBUG)
|
||||
bool CrstStatic::OwnedByCurrentThread()
|
||||
{
|
||||
#ifndef DACCESS_COMPILE
|
||||
return m_uiOwnerId.IsCurrentThread();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
EEThreadId CrstStatic::GetHolderThreadId()
|
||||
{
|
||||
return m_uiOwnerId;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
127
external/corert/src/Native/Runtime/Crst.h
vendored
Normal file
127
external/corert/src/Native/Runtime/Crst.h
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
//
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Minimal Crst implementation based on CRITICAL_SECTION. Doesn't support much except for the basic locking
|
||||
// functionality (in particular there is no rank violation checking).
|
||||
//
|
||||
|
||||
enum CrstType
|
||||
{
|
||||
CrstHandleTable,
|
||||
CrstDispatchCache,
|
||||
CrstAllocHeap,
|
||||
CrstGenericInstHashtab,
|
||||
CrstMemAccessMgr,
|
||||
CrstInterfaceDispatchGlobalLists,
|
||||
CrstStressLog,
|
||||
CrstRestrictedCallouts,
|
||||
CrstGcStressControl,
|
||||
CrstSuspendEE,
|
||||
CrstCastCache,
|
||||
};
|
||||
|
||||
enum CrstFlags
|
||||
{
|
||||
CRST_DEFAULT = 0x0,
|
||||
CRST_REENTRANCY = 0x0,
|
||||
CRST_UNSAFE_SAMELEVEL = 0x0,
|
||||
CRST_UNSAFE_ANYMODE = 0x0,
|
||||
CRST_DEBUGGER_THREAD = 0x0,
|
||||
};
|
||||
|
||||
// Static version of Crst with no default constructor (user must call Init() before use).
|
||||
class CrstStatic
|
||||
{
|
||||
public:
|
||||
void Init(CrstType eType, CrstFlags eFlags = CRST_DEFAULT);
|
||||
bool InitNoThrow(CrstType eType, CrstFlags eFlags = CRST_DEFAULT) { Init(eType, eFlags); return true; }
|
||||
void Destroy();
|
||||
void Enter() { CrstStatic::Enter(this); }
|
||||
void Leave() { CrstStatic::Leave(this); }
|
||||
static void Enter(CrstStatic *pCrst);
|
||||
static void Leave(CrstStatic *pCrst);
|
||||
#if defined(_DEBUG)
|
||||
bool OwnedByCurrentThread();
|
||||
EEThreadId GetHolderThreadId();
|
||||
#endif // _DEBUG
|
||||
|
||||
private:
|
||||
CRITICAL_SECTION m_sCritSec;
|
||||
#if defined(_DEBUG)
|
||||
EEThreadId m_uiOwnerId;
|
||||
#endif // _DEBUG
|
||||
};
|
||||
|
||||
// Non-static version that will initialize itself during construction.
|
||||
class Crst : public CrstStatic
|
||||
{
|
||||
public:
|
||||
Crst(CrstType eType, CrstFlags eFlags = CRST_DEFAULT)
|
||||
: CrstStatic()
|
||||
{ Init(eType, eFlags); }
|
||||
};
|
||||
|
||||
// Holder for a Crst instance.
|
||||
class CrstHolder
|
||||
{
|
||||
CrstStatic * m_pLock;
|
||||
|
||||
public:
|
||||
CrstHolder(CrstStatic * pLock)
|
||||
: m_pLock(pLock)
|
||||
{
|
||||
m_pLock->Enter();
|
||||
}
|
||||
|
||||
~CrstHolder()
|
||||
{
|
||||
m_pLock->Leave();
|
||||
}
|
||||
};
|
||||
|
||||
class CrstHolderWithState
|
||||
{
|
||||
CrstStatic * m_pLock;
|
||||
bool m_fAcquired;
|
||||
|
||||
public:
|
||||
CrstHolderWithState(CrstStatic * pLock, bool fAcquire = true)
|
||||
: m_pLock(pLock), m_fAcquired(fAcquire)
|
||||
{
|
||||
if (fAcquire)
|
||||
m_pLock->Enter();
|
||||
}
|
||||
|
||||
~CrstHolderWithState()
|
||||
{
|
||||
if (m_fAcquired)
|
||||
m_pLock->Leave();
|
||||
}
|
||||
|
||||
void Acquire()
|
||||
{
|
||||
if (!m_fAcquired)
|
||||
{
|
||||
m_pLock->Enter();
|
||||
m_fAcquired = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Release()
|
||||
{
|
||||
if (m_fAcquired)
|
||||
{
|
||||
m_pLock->Leave();
|
||||
m_fAcquired = false;
|
||||
}
|
||||
}
|
||||
|
||||
CrstStatic * GetValue()
|
||||
{
|
||||
return m_pLock;
|
||||
}
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user