From ffca9bdc12e2a57611c59bf77a29c802662d6fe7 Mon Sep 17 00:00:00 2001 From: Evan Ovadia Date: Fri, 10 Dec 2021 15:27:14 -0500 Subject: [PATCH] Made scope tethers crash instead of using the undead cycle. --- Driver/src/build.vale | 6 + Driver/src/midas.vale | 6 +- Midas/src/builtins/genHeap.c | 191 ---- Midas/src/builtins/twinpages.c | 76 -- Midas/src/c-compiler/externs.cpp | 2 +- Midas/src/c-compiler/externs.h | 2 +- .../function/expressions/externs.cpp | 1 + Midas/src/c-compiler/globalstate.h | 2 +- Midas/src/c-compiler/region/common/common.cpp | 46 +- Midas/src/c-compiler/region/common/common.h | 3 + .../src/c-compiler/region/common/hgm/hgm.cpp | 439 +------- Midas/src/c-compiler/region/common/hgm/hgm.h | 35 - .../region/resilientv3/resilientv3.cpp | 4 +- .../region/resilientv4/resilientv4.cpp | 71 +- Midas/src/c-compiler/vale.cpp | 18 +- Midas/src/c-compiler/valeopts.cpp | 38 +- Midas/src/c-compiler/valeopts.h | 2 +- Midas/test.sh | 2 +- Midas/test/tether.vale | 10 - Midas/test/tethercrash.vale | 7 +- Midas/test/twinpages/test.c | 137 --- Midas/test/valetest.py | 937 ------------------ Tester/src/main.vale | 24 +- 23 files changed, 118 insertions(+), 1941 deletions(-) delete mode 100644 Midas/src/builtins/genHeap.c delete mode 100644 Midas/src/builtins/twinpages.c delete mode 100644 Midas/test/tether.vale delete mode 100644 Midas/test/twinpages/test.c delete mode 100644 Midas/test/valetest.py diff --git a/Driver/src/build.vale b/Driver/src/build.vale index 91a999227..b90ff428c 100644 --- a/Driver/src/build.vale +++ b/Driver/src/build.vale @@ -95,6 +95,12 @@ fn build_stuff(compiler_dir &Path, all_args &Array) { "Whether to output VPST.", "false", "Whether to output VPST, the code's parsed representation"), + Flag( + "--llvm_ir", + FLAG_BOOL(), + "Whether to output LLVM IR.", + "false", + "Whether to output LLVM IR."), Flag( "--reuse_vast", FLAG_BOOL(), diff --git a/Driver/src/midas.vale b/Driver/src/midas.vale index fef5e0397..60999fdc0 100644 --- a/Driver/src/midas.vale +++ b/Driver/src/midas.vale @@ -24,11 +24,11 @@ Subprocess { command_line_args = List(); command_line_args!.add("--verify"); - command_line_args!.add("--output-dir"); + command_line_args!.add("--output_dir"); command_line_args!.add(output_dir.str()); if (not maybe_region_override.isEmpty()) { - command_line_args!.add("--region-override"); + command_line_args!.add("--region_override"); command_line_args!.add(maybe_region_override.get()); } if (not maybe_cpu.isEmpty()) { @@ -48,7 +48,7 @@ Subprocess { command_line_args!.add("--verify"); } if (llvm_ir) { - command_line_args!.add("--llvm_ir"); + command_line_args!.add("--llvmir"); } if (print_mem_overhead) { command_line_args!.add("--print_mem_overhead"); diff --git a/Midas/src/builtins/genHeap.c b/Midas/src/builtins/genHeap.c deleted file mode 100644 index 636e3c4e4..000000000 --- a/Midas/src/builtins/genHeap.c +++ /dev/null @@ -1,191 +0,0 @@ -#include -#include -#include -#include -#include - -static int64_t __totalLiveSize = 0; -static int64_t __totalAllocatedSize = 0; - -typedef struct { - // Vale's control block should also have gen right here. - uint32_t generationOrRc; - // Just for now, for naive RC. After that, this is unused. - uint32_t allocationActualSizeBytes; - // Only used when free. - void* nextFree; -} __Heap_Entry; - -typedef struct { - int allocationActualSizeBytes; - __Heap_Entry** freeListHeadPtrPtr; -} GenHeap; - -static __Heap_Entry* __gen_16B_heap_free_head = NULL; -static __Heap_Entry* __gen_24B_heap_free_head = NULL; -static __Heap_Entry* __gen_32B_heap_free_head = NULL; -static __Heap_Entry* __gen_40B_heap_free_head = NULL; -static __Heap_Entry* __gen_48B_heap_free_head = NULL; -static __Heap_Entry* __gen_56B_heap_free_head = NULL; -static __Heap_Entry* __gen_64B_heap_free_head = NULL; -static __Heap_Entry* __gen_80B_heap_free_head = NULL; -static __Heap_Entry* __gen_96B_heap_free_head = NULL; -static __Heap_Entry* __gen_128B_heap_free_head = NULL; - -static GenHeap __gen_small_heaps_by_8b_multiple[] = { - { 16, &__gen_16B_heap_free_head }, // 0 - { 16, &__gen_16B_heap_free_head }, // 8 - { 16, &__gen_16B_heap_free_head }, // 16 - { 24, &__gen_24B_heap_free_head }, // 24 - { 32, &__gen_32B_heap_free_head }, // 32 - { 40, &__gen_40B_heap_free_head }, // 40 - { 48, &__gen_48B_heap_free_head }, // 48 - { 56, &__gen_56B_heap_free_head }, // 56 - { 64, &__gen_64B_heap_free_head }, // 64 - { 80, &__gen_80B_heap_free_head }, // 72 - { 80, &__gen_80B_heap_free_head }, // 80 - { 96, &__gen_96B_heap_free_head }, // 88 - { 96, &__gen_96B_heap_free_head }, // 96 - { 128, &__gen_128B_heap_free_head }, // 104 - { 128, &__gen_128B_heap_free_head }, // 112 - { 128, &__gen_128B_heap_free_head }, // 120 - { 128, &__gen_128B_heap_free_head }, // 128 -}; - -static __Heap_Entry* __gen_2_pow_8B_heap_free_head = NULL; -static GenHeap __gen_2_pow_8B_heap = { 2 << 8, &__gen_2_pow_8B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_9B_heap_free_head = NULL; -static GenHeap __gen_2_pow_9B_heap = { 2 << 9, &__gen_2_pow_9B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_10B_heap_free_head = NULL; -static GenHeap __gen_2_pow_10B_heap = { 2 << 10, &__gen_2_pow_10B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_11B_heap_free_head = NULL; -static GenHeap __gen_2_pow_11B_heap = { 2 << 11, &__gen_2_pow_11B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_12B_heap_free_head = NULL; -static GenHeap __gen_2_pow_12B_heap = { 2 << 12, &__gen_2_pow_12B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_13B_heap_free_head = NULL; -static GenHeap __gen_2_pow_13B_heap = { 2 << 13, &__gen_2_pow_13B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_14B_heap_free_head = NULL; -static GenHeap __gen_2_pow_14B_heap = { 2 << 14, &__gen_2_pow_14B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_15B_heap_free_head = NULL; -static GenHeap __gen_2_pow_15B_heap = { 2 << 15, &__gen_2_pow_15B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_16B_heap_free_head = NULL; -static GenHeap __gen_2_pow_16B_heap = { 2 << 16, &__gen_2_pow_16B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_17B_heap_free_head = NULL; -static GenHeap __gen_2_pow_17B_heap = { 2 << 17, &__gen_2_pow_17B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_18B_heap_free_head = NULL; -static GenHeap __gen_2_pow_18B_heap = { 2 << 18, &__gen_2_pow_18B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_19B_heap_free_head = NULL; -static GenHeap __gen_2_pow_19B_heap = { 2 << 19, &__gen_2_pow_19B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_20B_heap_free_head = NULL; -static GenHeap __gen_2_pow_20B_heap = { 2 << 20, &__gen_2_pow_20B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_21B_heap_free_head = NULL; -static GenHeap __gen_2_pow_21B_heap = { 2 << 21, &__gen_2_pow_21B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_22B_heap_free_head = NULL; -static GenHeap __gen_2_pow_22B_heap = { 2 << 22, &__gen_2_pow_22B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_23B_heap_free_head = NULL; -static GenHeap __gen_2_pow_23B_heap = { 2 << 23, &__gen_2_pow_23B_heap_free_head }; -static __Heap_Entry* __gen_2_pow_24B_heap_free_head = NULL; -static GenHeap __gen_2_pow_24B_heap = { 2 << 24, &__gen_2_pow_24B_heap_free_head }; - - -static inline void* mallocAndZeroGen(int allocationActualSizeBytes) { - __Heap_Entry* newAllocation = malloc(allocationActualSizeBytes); - newAllocation->generationOrRc = 0; - newAllocation->allocationActualSizeBytes = allocationActualSizeBytes; - __totalAllocatedSize += allocationActualSizeBytes; - return newAllocation; -} - -static inline void incrementGenAndAddToFreeList(__Heap_Entry* entry, __Heap_Entry** head) { - // This doesnt make much sense for RCs, but thats fine since itll be overwritten to zero when - // its allocated. - entry->generationOrRc++; - entry->allocationActualSizeBytes = 0; - entry->nextFree = *head; - *head = entry; -} - -static inline __Heap_Entry* popFromFreeList(__Heap_Entry** head) { - __Heap_Entry* entry = *head; - *head = entry->nextFree; - return entry; -} - -GenHeap* getGenHeapForDesiredSize(int desiredBytesNotMultipleOf8) { - // Bump it up to the next multiple of 8 - int desiredBytes = (desiredBytesNotMultipleOf8 + 7) / 8 * 8; - - if (desiredBytes <= 128) { - return &__gen_small_heaps_by_8b_multiple[desiredBytes / 8]; - } else if (desiredBytes <= (2 << 8)) { - return &__gen_2_pow_8B_heap; - } else if (desiredBytes <= (2 << 9)) { - return &__gen_2_pow_9B_heap; - } else if (desiredBytes <= (2 << 10)) { - return &__gen_2_pow_10B_heap; - } else if (desiredBytes <= (2 << 11)) { - return &__gen_2_pow_11B_heap; - } else if (desiredBytes <= (2 << 12)) { - return &__gen_2_pow_12B_heap; - } else if (desiredBytes <= (2 << 13)) { - return &__gen_2_pow_13B_heap; - } else if (desiredBytes <= (2 << 14)) { - return &__gen_2_pow_14B_heap; - } else if (desiredBytes <= (2 << 15)) { - return &__gen_2_pow_15B_heap; - } else if (desiredBytes <= (2 << 16)) { - return &__gen_2_pow_16B_heap; - } else if (desiredBytes <= (2 << 17)) { - return &__gen_2_pow_17B_heap; - } else if (desiredBytes <= (2 << 18)) { - return &__gen_2_pow_18B_heap; - } else if (desiredBytes <= (2 << 19)) { - return &__gen_2_pow_19B_heap; - } else if (desiredBytes <= (2 << 20)) { - return &__gen_2_pow_20B_heap; - } else if (desiredBytes <= (2 << 21)) { - return &__gen_2_pow_21B_heap; - } else if (desiredBytes <= (2 << 22)) { - return &__gen_2_pow_22B_heap; - } else if (desiredBytes <= (2 << 23)) { - return &__gen_2_pow_23B_heap; - } else if (desiredBytes <= (2 << 24)) { - return &__gen_2_pow_24B_heap; - } else { - fprintf(stderr, "Tried to allocate %d bytes!\n", desiredBytesNotMultipleOf8); - exit(1); - } -} - -// we assume bytes is a multiple of 8 -void* __genMalloc(int desiredBytes) { - GenHeap* genHeapForDesiredSize = getGenHeapForDesiredSize(desiredBytes); - int allocationActualSizeBytes = genHeapForDesiredSize->allocationActualSizeBytes; - __Heap_Entry** freeListHeadPtrPtr = genHeapForDesiredSize->freeListHeadPtrPtr; - - __totalLiveSize += allocationActualSizeBytes; - - __Heap_Entry* result = NULL; - if (*freeListHeadPtrPtr) { - result = popFromFreeList(freeListHeadPtrPtr); - //printf("genMalloc(%d) reused, total allocated %d, total live %d.\n", desiredBytes, __totalAllocatedSize, __totalLiveSize); - } else { - result = mallocAndZeroGen(allocationActualSizeBytes); - //printf("genMalloc(%d) allocated, now total allocated %d, total live %d.\n", desiredBytes, __totalAllocatedSize, __totalLiveSize); - } - // Dont change the generation - result->allocationActualSizeBytes = allocationActualSizeBytes; - - return result; -} - -// we assume bytes is a multiple of 8 -void __genFree(void* allocationVoidPtr) { - __Heap_Entry* allocation = (__Heap_Entry*)allocationVoidPtr; - - __totalLiveSize -= allocation->allocationActualSizeBytes; - //printf("genFree freeing %d, now total allocated %d, total live %d.\n", allocation->allocationActualSizeBytes, __totalAllocatedSize, __totalLiveSize); - - __Heap_Entry** freeListHeadPtrPtr = getGenHeapForDesiredSize(allocation->allocationActualSizeBytes)->freeListHeadPtrPtr; - incrementGenAndAddToFreeList((__Heap_Entry*)allocation, freeListHeadPtrPtr); -} diff --git a/Midas/src/builtins/twinpages.c b/Midas/src/builtins/twinpages.c deleted file mode 100644 index 6c1192f24..000000000 --- a/Midas/src/builtins/twinpages.c +++ /dev/null @@ -1,76 +0,0 @@ -#include -#include -#include -#include -#include - -#ifdef _WIN32 -#include -#include -#else -#include -#include -#endif - -void SignalHandler(int signal) { - printf("Memory violation! Signal %d\n", signal); - exit(11); -} - -int getOSPageSize() { -#ifdef _WIN32 - SYSTEM_INFO sSysInfo; // useful information about the system - GetSystemInfo(&sSysInfo); // initialize the structure - return sSysInfo.dwPageSize; -#else - return getpagesize(); -#endif -} - -char* __vale_initTwinPages() { - // Set up the signal to catch the seg fault. - // This is especially nice for windows, which otherwise just silently fails. - //typedef void (*SignalHandlerPointer)(int); - //SignalHandlerPointer previousSigsegvHandler = - signal(SIGSEGV, SignalHandler); - // Mac can have bus faults, not seg faults, when we do bad accesses -#ifndef _WIN32 - //SignalHandlerPointer previousBusErrorHandler = - signal(SIGBUS, SignalHandler); -#endif - - size_t pageSize = getOSPageSize(); - -#ifdef _WIN32 - char* allocationPtr = - VirtualAlloc( - NULL, pageSize * 2, MEM_RESERVE | MEM_COMMIT, PAGE_NOACCESS); - if(allocationPtr == NULL) { - _tprintf(TEXT("VirtualAlloc failed. Error: %ld\n"), GetLastError()); - exit(1); - } - DWORD oldFlags = 0; - int virtualProtectSuccess = - VirtualProtect( - allocationPtr, pageSize, PAGE_READWRITE, &oldFlags); - if (!virtualProtectSuccess) { - _tprintf(TEXT("VirtualProtect failed. Error: %ld\n"), GetLastError()); - exit(1); - } -#else - char *allocationPtr = mmap(0, pageSize * 2, 0, MAP_ANON | MAP_PRIVATE, 0, 0); - if (allocationPtr == MAP_FAILED) { - perror("Could not mmap twin pages!"); - exit(1); - } - if (mprotect(allocationPtr, pageSize, PROT_READ | PROT_WRITE)) { - perror("Could not mprotect twin pages!"); - exit(1); - } -#endif - // Do a write just to be sure. - *(long long*)&allocationPtr[pageSize - sizeof(long long)] = 42LL; -// long long result = -// *(long long*)&allocationPtr[pageSize - sizeof(long long)]; - return allocationPtr + pageSize; -} diff --git a/Midas/src/c-compiler/externs.cpp b/Midas/src/c-compiler/externs.cpp index 0bfb227c1..7722264a4 100644 --- a/Midas/src/c-compiler/externs.cpp +++ b/Midas/src/c-compiler/externs.cpp @@ -29,7 +29,7 @@ Externs::Externs(LLVMModuleRef mod, LLVMContextRef context) { memcpy = addExtern(mod, "memcpy", int8PtrLT, {int8PtrLT, int8PtrLT, int64LT}); memset = addExtern(mod, "memset", voidLT, {int8PtrLT, int8LT, int64LT}); - initTwinPages = addExtern(mod, "__vale_initTwinPages", int8PtrLT, {}); +// initTwinPages = addExtern(mod, "__vale_initTwinPages", int8PtrLT, {}); } bool hasEnding (std::string const &fullString, std::string const &ending) { diff --git a/Midas/src/c-compiler/externs.h b/Midas/src/c-compiler/externs.h index 682f81307..e364c5083 100644 --- a/Midas/src/c-compiler/externs.h +++ b/Midas/src/c-compiler/externs.h @@ -16,7 +16,7 @@ class Externs { LLVMValueRef strncpy = nullptr; LLVMValueRef memcpy = nullptr; - LLVMValueRef initTwinPages = nullptr; +// LLVMValueRef initTwinPages = nullptr; LLVMValueRef censusContains = nullptr; LLVMValueRef censusAdd = nullptr; LLVMValueRef censusRemove = nullptr; diff --git a/Midas/src/c-compiler/function/expressions/externs.cpp b/Midas/src/c-compiler/function/expressions/externs.cpp index 70e85dc3a..507ca2b6f 100644 --- a/Midas/src/c-compiler/function/expressions/externs.cpp +++ b/Midas/src/c-compiler/function/expressions/externs.cpp @@ -172,6 +172,7 @@ Ref buildExternCall( auto result = LLVMBuildFAdd(builder, leftLE, rightLE, "add"); return wrap(globalState->getRegion(globalState->metalCache->floatRef), globalState->metalCache->floatRef, result); } else if (prototype->name->name == "__vbi_panic") { + buildPrint(globalState, builder, "(panic)\n"); // See MPESC for status codes auto exitCodeLE = makeConstIntExpr(functionState, builder, LLVMInt64TypeInContext(globalState->context), 1); LLVMBuildCall(builder, globalState->externs->exit, &exitCodeLE, 1, ""); diff --git a/Midas/src/c-compiler/globalstate.h b/Midas/src/c-compiler/globalstate.h index d08c90ae2..a15c60fa9 100644 --- a/Midas/src/c-compiler/globalstate.h +++ b/Midas/src/c-compiler/globalstate.h @@ -65,7 +65,7 @@ class GlobalState { LLVMTypeRef lgtTableStructLT, lgtEntryStructLT = nullptr; // contains generation and next free LLVMValueRef expandLgt = nullptr, checkLgti = nullptr, getNumLiveLgtEntries = nullptr; - LLVMValueRef genMalloc = nullptr, genFree = nullptr; +// LLVMValueRef genMalloc = nullptr, genFree = nullptr; LLVMTypeRef concreteHandleLT = nullptr; // 24 bytes, for SSA, RSA, and structs LLVMTypeRef interfaceHandleLT = nullptr; // 32 bytes, for interfaces. concreteHandleLT plus 8b itable ptr. diff --git a/Midas/src/c-compiler/region/common/common.cpp b/Midas/src/c-compiler/region/common/common.cpp index bdc8440c2..b974ed2ff 100644 --- a/Midas/src/c-compiler/region/common/common.cpp +++ b/Midas/src/c-compiler/region/common/common.cpp @@ -276,23 +276,13 @@ void callFree( GlobalState* globalState, LLVMBuilderRef builder, LLVMValueRef ptrLE) { - if (globalState->opt->genHeap) { - auto concreteAsVoidPtrLE = - LLVMBuildBitCast( - builder, - ptrLE, - LLVMPointerType(LLVMInt8TypeInContext(globalState->context), 0), - "concreteVoidPtrForFree"); - LLVMBuildCall(builder, globalState->genFree, &concreteAsVoidPtrLE, 1, ""); - } else { - auto concreteAsCharPtrLE = - LLVMBuildBitCast( - builder, - ptrLE, - LLVMPointerType(LLVMInt8TypeInContext(globalState->context), 0), - "concreteCharPtrForFree"); - LLVMBuildCall(builder, globalState->externs->free, &concreteAsCharPtrLE, 1, ""); - } + auto concreteAsCharPtrLE = + LLVMBuildBitCast( + builder, + ptrLE, + LLVMPointerType(LLVMInt8TypeInContext(globalState->context), 0), + "concreteCharPtrForFree"); + LLVMBuildCall(builder, globalState->externs->free, &concreteAsCharPtrLE, 1, ""); } void innerDeallocateYonder( @@ -446,11 +436,7 @@ LLVMValueRef callMalloc( LLVMBuilderRef builder, LLVMValueRef sizeLE) { assert(LLVMTypeOf(sizeLE) == LLVMInt64TypeInContext(globalState->context)); - if (globalState->opt->genHeap) { - return LLVMBuildCall(builder, globalState->genMalloc, &sizeLE, 1, ""); - } else { - return LLVMBuildCall(builder, globalState->externs->malloc, &sizeLE, 1, ""); - } + return LLVMBuildCall(builder, globalState->externs->malloc, &sizeLE, 1, ""); } WrapperPtrLE mallocStr( @@ -2242,3 +2228,19 @@ std::string generateMutableInterfaceHandleDefC(Package* currentPackage, const st return std::string() + "typedef struct " + name + "Ref { uint64_t unused0; uint64_t unused1; uint64_t unused2; uint32_t unused3; uint32_t unused4; } " + name + "Ref;\n"; } + +void fastPanic(GlobalState* globalState, AreaAndFileAndLine from, LLVMBuilderRef builder) { + if (globalState->opt->fastCrash) { + auto ptrToWriteToLE = LLVMBuildLoad(builder, globalState->crashGlobal, + "crashGlobal"); + LLVMBuildStore(builder, constI64LE(globalState, 0), ptrToWriteToLE); + } else { + buildPrintAreaAndFileAndLine(globalState, builder, from); + buildPrint(globalState, builder, "Tried dereferencing dangling reference! "); + buildPrint(globalState, builder, "Exiting!\n"); + // See MPESC for status codes + auto exitCodeIntLE = LLVMConstInt(LLVMInt64TypeInContext(globalState->context), 14, false); + LLVMBuildCall(builder, globalState->externs->exit, &exitCodeIntLE, 1, ""); + } +} + diff --git a/Midas/src/c-compiler/region/common/common.h b/Midas/src/c-compiler/region/common/common.h index 64d35ff39..abc599224 100644 --- a/Midas/src/c-compiler/region/common/common.h +++ b/Midas/src/c-compiler/region/common/common.h @@ -693,4 +693,7 @@ std::string generateMutableInterfaceHandleDefC(Package* currentPackage, const st std::string generateMutableConcreteHandleDefC(Package* currentPackage, const std::string& name); + +void fastPanic(GlobalState* globalState, AreaAndFileAndLine from, LLVMBuilderRef builder); + #endif diff --git a/Midas/src/c-compiler/region/common/hgm/hgm.cpp b/Midas/src/c-compiler/region/common/hgm/hgm.cpp index 06244c24a..37350a7d4 100644 --- a/Midas/src/c-compiler/region/common/hgm/hgm.cpp +++ b/Midas/src/c-compiler/region/common/hgm/hgm.cpp @@ -25,357 +25,6 @@ HybridGenerationalMemory::HybridGenerationalMemory( globalNullPtrPtrByKind(0, globalState->makeAddressHasher()) { } -void HybridGenerationalMemory::mainSetup(FunctionState* functionState, LLVMBuilderRef builder) { - if (anyMT != globalState->metalCache->emptyTupleStruct) { - auto anyRefMT = globalState->metalCache->getReference(Ownership::OWN, Location::YONDER, anyMT); - auto anyInlRefMT = globalState->metalCache->getReference(Ownership::OWN, Location::INLINE, anyMT); - auto anyRefLT = globalState->getRegion(anyMT)->translateType(anyRefMT); - auto anyInlRefLT = globalState->getRegion(anyMT)->translateType(anyInlRefMT); - - undeadCycleNodeLT = LLVMStructCreateNamed(globalState->context, "__ValeHGM_UndeadCycleNode"); - std::vector undeadCycleNodeMembers = { - LLVMPointerType(undeadCycleNodeLT, 0), - anyRefLT, - }; - LLVMStructSetBody(undeadCycleNodeLT, undeadCycleNodeMembers.data(), undeadCycleNodeMembers.size(), false); - - undeadCycleHeadNodePtrPtrLE = - LLVMAddGlobal(globalState->mod, LLVMPointerType(undeadCycleNodeLT, 0), "__ValeHGM_undeadCycleCurrent"); - LLVMSetInitializer(undeadCycleHeadNodePtrPtrLE, LLVMConstNull(LLVMPointerType(undeadCycleNodeLT, 0))); - - halfProtectedI8PtrPtrLE = LLVMAddGlobal(globalState->mod, LLVMPointerType(LLVMInt8TypeInContext(globalState->context), 0), "halfProtectedI8Ptr"); - LLVMSetInitializer(halfProtectedI8PtrPtrLE, LLVMConstNull(LLVMPointerType(LLVMInt8TypeInContext(globalState->context), 0))); - - buildFlare(FL(), globalState, functionState, builder, "Half protected ptr: ", ptrToIntLE(globalState, builder, halfProtectedI8PtrPtrLE)); - - auto setupFuncProto = makeMainSetupFunction(); - auto setupFuncL = globalState->extraFunctions.find(setupFuncProto)->second; - LLVMBuildCall(builder, setupFuncL, nullptr, 0, ""); - - cleanupIterPrototype = makeCleanupIterFunction(); - } -} - -Prototype* HybridGenerationalMemory::makeMainSetupFunction() { - auto anyRefMT = globalState->metalCache->getReference(Ownership::OWN, Location::YONDER, anyMT); - auto anyInlRefMT = globalState->metalCache->getReference(Ownership::OWN, Location::INLINE, anyMT); - auto anyRefLT = globalState->getRegion(anyMT)->translateType(anyRefMT); - auto anyInlRefLT = globalState->getRegion(anyMT)->translateType(anyInlRefMT); - - auto setupFuncName = - globalState->metalCache->getName(globalState->metalCache->builtinPackageCoord, "__ValeHGM_mainSetup"); - auto setupFuncProto = - globalState->metalCache->getPrototype(setupFuncName, globalState->metalCache->i64Ref, {}); - declareAndDefineExtraFunction( - globalState, setupFuncProto, setupFuncName->name, - [this, anyRefMT, anyRefLT, anyInlRefLT](FunctionState *functionState, LLVMBuilderRef builder) { - - buildFlare(FL(), globalState, functionState, builder); - - auto protectedTwinPagePtrLE = - LLVMBuildCall(builder, globalState->externs->initTwinPages, nullptr, 0, "protectedTwinPagePtr"); - size_t numProtectedBytes = LLVMABISizeOfType(globalState->dataLayout, anyInlRefLT); - LLVMValueRef negativeNumProtectedBytesLE = constI64LE(globalState, -numProtectedBytes); - - buildFlare(FL(), globalState, functionState, builder); - - auto halfProtectedI8PtrLE = - LLVMBuildGEP(builder, protectedTwinPagePtrLE, &negativeNumProtectedBytesLE, 1, ""); - LLVMBuildStore(builder, halfProtectedI8PtrLE, halfProtectedI8PtrPtrLE); - - buildFlare(FL(), globalState, functionState, builder); - - if (globalState->opt->census) { - std::cerr << "HGM half-protected block has no census fields!" << std::endl; - LLVMBuildCall(builder, globalState->externs->censusAdd, &halfProtectedI8PtrLE, 1, ""); - } - - buildFlare(FL(), globalState, functionState, builder); - - auto halfProtectedAnyObjWrapperPtrLE = - kindStructs->makeWrapperPtr( - FL(), functionState, builder, anyRefMT, - LLVMBuildPointerCast(builder, halfProtectedI8PtrLE, anyRefLT, "halfProtectedAnyObjPtr")); - auto halfProtectedObjControlBlockPtrLE = - kindStructs->getConcreteControlBlockPtr( - FL(), functionState, builder, anyRefMT, halfProtectedAnyObjWrapperPtrLE); - - buildFlare(FL(), globalState, functionState, builder); - - auto controlBlock = kindStructs->getControlBlock(anyMT); - - auto genMemberIndex = controlBlock->getMemberIndex(ControlBlockMember::GENERATION_32B); - auto genPtrLE = - LLVMBuildStructGEP(builder, halfProtectedObjControlBlockPtrLE.refLE, genMemberIndex, "genPtr"); - auto genLT = LLVMIntTypeInContext(globalState->context, GENERATION_NUM_BITS); - auto intMaxLE = LLVMConstSExt(constI8LE(globalState, 0xFF), genLT); - LLVMBuildStore(builder, intMaxLE, genPtrLE); - - buildFlare(FL(), globalState, functionState, builder); - - auto tetherMemberIndex = controlBlock->getMemberIndex(ControlBlockMember::TETHER_32B); - auto tetheredPtrLE = LLVMBuildStructGEP( - builder, halfProtectedObjControlBlockPtrLE.refLE, tetherMemberIndex, "tetherPtr"); - auto isTetheredLE = constI32LE(globalState, 1); - LLVMBuildStore(builder, isTetheredLE, tetheredPtrLE); - - buildFlare(FL(), globalState, functionState, builder); - - auto undeadCycleHeadNodeI8PtrLE = - callMalloc( - globalState, - builder, - constI64LE(globalState, LLVMABISizeOfType(globalState->dataLayout, undeadCycleNodeLT))); - auto undeadCycleHeadNodePtrLE = - LLVMBuildPointerCast( - builder, undeadCycleHeadNodeI8PtrLE, LLVMPointerType(undeadCycleNodeLT, 0), - "undeadCycleHeadNodePtr"); - //buildFlare(FL(), globalState, functionState, builder, "head: ", ptrToIntLE(globalState, builder, undeadCycleHeadNodeI8PtrLE)); - // Make it point at itself for its next ptr - auto undeadCycleHeadNodeNextPtrPtrLE = - LLVMBuildStructGEP(builder, undeadCycleHeadNodePtrLE, 0, "nextPtrPtr"); - LLVMBuildStore(builder, undeadCycleHeadNodePtrLE, undeadCycleHeadNodeNextPtrPtrLE); - //buildFlare(FL(), globalState, functionState, builder, "next: ", ptrToIntLE(globalState, builder, undeadCycleHeadNodePtrLE)); - // Point it at the half protected global, arbitrarily. Could use something else if we wanted to, but might as well. - auto undeadCycleHeadNodeObjPtrPtrLE = - LLVMBuildStructGEP(builder, undeadCycleHeadNodePtrLE, 1, "objPtrPtr"); - LLVMBuildStore(builder, halfProtectedAnyObjWrapperPtrLE.refLE, undeadCycleHeadNodeObjPtrPtrLE); - //buildFlare(FL(), globalState, functionState, builder, "obj: ", ptrToIntLE(globalState, builder, halfProtectedAnyObjWrapperPtrLE.refLE)); - - LLVMBuildStore(builder, undeadCycleHeadNodePtrLE, undeadCycleHeadNodePtrPtrLE); - - // The caller is about to kill our builder, so we're making another one pointing at the same block. - setupBuilder = LLVMCreateBuilderInContext(globalState->context); - LLVMPositionBuilderAtEnd(setupBuilder, LLVMGetInsertBlock(builder)); - - buildFlare(FL(), globalState, functionState, builder); - }); - return setupFuncProto; -} - -void HybridGenerationalMemory::mainCleanup(FunctionState* functionState, LLVMBuilderRef builder) { - if (anyMT != globalState->metalCache->emptyTupleStruct) { - auto boolRefMT = globalState->metalCache->boolRef; - auto anyRefMT = globalState->metalCache->getReference(Ownership::OWN, Location::YONDER, anyMT); - - LLVMBuildRet(setupBuilder, constI64LE(globalState, 0)); - LLVMDisposeBuilder(setupBuilder); - - buildFlare(FL(), globalState, functionState, builder); - auto cleanupFuncProto = makeMainCleanupFunction(); - auto setupFuncL = globalState->extraFunctions.find(cleanupFuncProto)->second; - buildFlare(FL(), globalState, functionState, builder); - LLVMBuildCall(builder, setupFuncL, nullptr, 0, ""); - buildFlare(FL(), globalState, functionState, builder); - } -} - -// Attempts to clean up the head's next node. -// Returns 0 if there are none left, 1 if we cleaned one up, 2 if we couldn't clean one up. -Prototype* HybridGenerationalMemory::makeCleanupLoopFunction() { - auto cleanupLoopFuncName = - globalState->metalCache->getName(globalState->metalCache->builtinPackageCoord, "__ValeHGM_cleanupIter"); - auto cleanupLoopFuncProto = - globalState->metalCache->getPrototype(cleanupLoopFuncName, globalState->metalCache->i64Ref, {}); - declareAndDefineExtraFunction( - globalState, cleanupLoopFuncProto, cleanupLoopFuncName->name, - [this](FunctionState *functionState, LLVMBuilderRef builder) { - buildWhile(globalState, functionState, builder, - [this, functionState](LLVMBuilderRef conditionBuilder) { - buildFlare(FL(), globalState, functionState, conditionBuilder); - auto undeadCycleHeadNodePtrLE = - LLVMBuildLoad(conditionBuilder, undeadCycleHeadNodePtrPtrLE, "undeadCycleHeadNodePtr"); -// buildFlare(FL(), globalState, functionState, conditionBuilder, "head: ", -// ptrToIntLE(globalState, conditionBuilder, undeadCycleHeadNodePtrLE)); - auto undeadCycleHeadNodeNextPtrPtrLE = - LLVMBuildStructGEP( - conditionBuilder, undeadCycleHeadNodePtrLE, 0, "undeadCycleHeadNodeNextPtrPtr"); - //buildFlare(FL(), globalState, functionState, conditionBuilder); - auto undeadCycleHeadNodeNextPtrLE = - LLVMBuildLoad(conditionBuilder, undeadCycleHeadNodeNextPtrPtrLE, "undeadCycleHeadNodeNextPtr"); -// buildFlare(FL(), globalState, functionState, conditionBuilder, "next: ", -// ptrToIntLE(globalState, conditionBuilder, undeadCycleHeadNodeNextPtrLE)); - auto undeadCycleNonEmptyDiffLE = - LLVMBuildPtrDiff( - conditionBuilder, undeadCycleHeadNodeNextPtrLE, undeadCycleHeadNodePtrLE, "undeadCycleNonEmptyDiff"); -// buildFlare(FL(), globalState, functionState, conditionBuilder, "diff: ", undeadCycleNonEmptyDiffLE); - auto undeadCycleEmptyLE = - LLVMBuildICmp( - conditionBuilder, LLVMIntNE, undeadCycleNonEmptyDiffLE, constI64LE(globalState, 0), - "undeadCycleNonEmpty"); -// buildFlare(FL(), globalState, functionState, conditionBuilder); - auto undeadCycleNonEmptyRef = - wrap( - globalState->getRegion(globalState->metalCache->boolRef), globalState->metalCache->boolRef, - undeadCycleEmptyLE); - return undeadCycleNonEmptyRef; - }, - [this, functionState](LLVMBuilderRef bodyBuilder) { - buildCall(globalState, functionState, bodyBuilder, cleanupIterPrototype, {}); - }); - LLVMBuildRet(builder, constI64LE(globalState, 0)); - }); - return cleanupLoopFuncProto; -} - -// Attempts to clean up the head's next node. -// Returns 0 if there are none left, 1 if we cleaned one up, 2 if we couldn't clean one up. -Prototype* HybridGenerationalMemory::makeCleanupIterFunction() { - auto anyRefMT = globalState->metalCache->getReference(Ownership::OWN, Location::YONDER, anyMT); - - auto cleanupIterFuncName = - globalState->metalCache->getName(globalState->metalCache->builtinPackageCoord, "__ValeHGM_cleanupIter"); - auto cleanupIterFuncProto = - globalState->metalCache->getPrototype(cleanupIterFuncName, globalState->metalCache->i64Ref, {}); - declareAndDefineExtraFunction( - globalState, cleanupIterFuncProto, cleanupIterFuncName->name, - [this, anyRefMT](FunctionState *functionState, LLVMBuilderRef builder) { - buildFlare(FL(), globalState, functionState, builder, "In an iteration!"); - auto undeadCycleHeadNodePtrLE = - LLVMBuildLoad(builder, undeadCycleHeadNodePtrPtrLE, "undeadCycleHeadNodePtr"); -// buildFlare(FL(), globalState, functionState, builder, "cycle head: ", -// ptrToIntLE(globalState, builder, undeadCycleHeadNodePtrLE)); - - auto undeadCycleHeadNodeNextPtrPtrLE = - LLVMBuildStructGEP( - builder, undeadCycleHeadNodePtrLE, 0, "undeadCycleHeadNodeNextPtrPtr"); - // This is the node that we might be removing. - auto undeadCycleNextNodePtrLE = - LLVMBuildLoad(builder, undeadCycleHeadNodeNextPtrPtrLE, "undeadCycleNextNodePtr"); -// buildFlare(FL(), globalState, functionState, builder, "cycle head next: ", -// ptrToIntLE(globalState, builder, undeadCycleNextNodePtrLE)); - - auto undeadCycleNextNodeNextPtrPtrLE = - LLVMBuildStructGEP( - builder, undeadCycleNextNodePtrLE, 0, "undeadCycleNextNodeNextPtrPtr"); - auto undeadCycleNextNodeNextPtrLE = - LLVMBuildLoad(builder, undeadCycleNextNodeNextPtrPtrLE, "undeadCycleNextNodeNextPtr"); -// buildFlare(FL(), globalState, functionState, builder, "cycle head next next: ", -// ptrToIntLE(globalState, builder, undeadCycleNextNodeNextPtrLE)); - - // Now we'll get a pointer to its object. - auto undeadCycleNextNodeObjPtrPtrLE = - LLVMBuildStructGEP( - builder, undeadCycleNextNodePtrLE, 1, "undeadCycleNextNodeObjPtrPtr"); - auto undeadCycleNextNodeObjPtrLE = - LLVMBuildLoad(builder, undeadCycleNextNodeObjPtrPtrLE, "undeadCycleNextNodeObjPtr"); -// buildFlare(FL(), globalState, functionState, builder, "cycle head next obj: ", -// ptrToIntLE(globalState, builder, undeadCycleNextNodeObjPtrLE)); - - auto nextNodeObjWrapperPtrLE = - kindStructs->makeWrapperPtr(FL(), functionState, builder, anyRefMT, undeadCycleNextNodeObjPtrLE); - auto nextNodeObjRef = wrap(globalState->getRegion(anyMT), anyRefMT, nextNodeObjWrapperPtrLE); - - auto controlBlock = kindStructs->getControlBlock(anyMT); - auto tetherMemberIndex = controlBlock->getMemberIndex(ControlBlockMember::TETHER_32B); - auto controlBlockPtrLE = - kindStructs->getConcreteControlBlockPtr(FL(), functionState, builder, anyRefMT, - nextNodeObjWrapperPtrLE); - auto tetherPtrLE = LLVMBuildStructGEP(builder, controlBlockPtrLE.refLE, tetherMemberIndex, "tetherPtr"); - auto tetherI32LE = LLVMBuildLoad(builder, tetherPtrLE, "tetherI32"); - auto isTetheredLE = - LLVMBuildTrunc(builder, tetherI32LE, LLVMInt1TypeInContext(globalState->context), "wasAlive"); - auto isTetheredRef = wrap( - globalState->getRegion(globalState->metalCache->boolRef), globalState->metalCache->boolRef, isTetheredLE); - - buildFlare(FL(), globalState, functionState, builder, "is tethered: ", tetherI32LE); - - auto resultIntRef = - buildIfElse( - globalState, functionState, builder, - isTetheredRef, LLVMInt64TypeInContext(globalState->context), - globalState->metalCache->i64Ref, - globalState->metalCache->i64Ref, - [this, undeadCycleNextNodePtrLE](LLVMBuilderRef thenBuilder) { - // Make the next one the new head. - LLVMBuildStore(thenBuilder, undeadCycleNextNodePtrLE, undeadCycleHeadNodePtrPtrLE); - return globalState->constI64(0); - }, - [this, functionState, nextNodeObjRef, nextNodeObjWrapperPtrLE, undeadCycleNextNodePtrLE, - undeadCycleNextNodeNextPtrLE, undeadCycleHeadNodeNextPtrPtrLE, anyRefMT](LLVMBuilderRef elseBuilder) { - // It's not tethered, so nuke it! - buildFlare(FL(), globalState, functionState, elseBuilder, "deallocating! ", ptrToIntLE(globalState, elseBuilder, nextNodeObjWrapperPtrLE.refLE)); - innerDeallocate(FL(), globalState, functionState, kindStructs, elseBuilder, anyRefMT, nextNodeObjRef); - buildFlare(FL(), globalState, functionState, elseBuilder); - callFree(globalState, elseBuilder, undeadCycleNextNodePtrLE); -// buildFlare(FL(), globalState, functionState, elseBuilder); - // Make the head node point somewhere else - LLVMBuildStore(elseBuilder, undeadCycleNextNodeNextPtrLE, undeadCycleHeadNodeNextPtrPtrLE); -// buildFlare(FL(), globalState, functionState, elseBuilder); - return globalState->constI64(1); - }); - - auto resultIntLE = - globalState->getRegion(globalState->metalCache->i64Ref)->checkValidReference( - FL(), functionState, builder, globalState->metalCache->i64Ref, resultIntRef); - LLVMBuildRet(builder, resultIntLE); - }); - return cleanupIterFuncProto; -} - -Prototype* HybridGenerationalMemory::makeMainCleanupFunction() { - auto anyRefMT = globalState->metalCache->getReference(Ownership::OWN, Location::YONDER, anyMT); - auto anyInlRefMT = globalState->metalCache->getReference(Ownership::OWN, Location::INLINE, anyMT); - auto anyRefLT = globalState->getRegion(anyMT)->translateType(anyRefMT); - auto anyInlRefLT = globalState->getRegion(anyMT)->translateType(anyInlRefMT); - auto boolRefMT = globalState->metalCache->boolRef; - - auto cleanupFuncName = globalState->metalCache->getName(globalState->metalCache->builtinPackageCoord, "__ValeHGM_mainCleanup"); - auto cleanupFuncProto = - globalState->metalCache->getPrototype(cleanupFuncName, globalState->metalCache->i64Ref, {}); - declareAndDefineExtraFunction( - globalState, cleanupFuncProto, cleanupFuncName->name, - [this, boolRefMT, anyRefMT](FunctionState *functionState, LLVMBuilderRef builder) { - buildFlare(FL(), globalState, functionState, builder); - - buildCall(globalState, functionState, builder, makeCleanupLoopFunction(), {}); - LLVMBuildRet(builder, constI64LE(globalState, 0)); - -// buildWhile( -// globalState, functionState, builder, -// [this, boolRefMT, functionState](LLVMBuilderRef conditionBuilder) { -// buildFlare(FL(), globalState, functionState, conditionBuilder); -// auto undeadCycleNodePtrLE = -// LLVMBuildLoad(conditionBuilder, undeadCycleHeadNodePtrPtrLE, "undeadCycleNodePtr"); -// buildFlare(FL(), globalState, functionState, conditionBuilder, "head: ", ptrToIntLE(globalState, conditionBuilder, undeadCycleNodePtrLE)); -// auto undeadCycleNodeNextPtrPtrLE = -// LLVMBuildStructGEP( -// conditionBuilder, undeadCycleNodePtrLE, 0, "undeadCycleNodeNextPtrPtr"); -// buildFlare(FL(), globalState, functionState, conditionBuilder); -// auto undeadCycleNodeNextPtrLE = -// LLVMBuildLoad(conditionBuilder, undeadCycleNodeNextPtrPtrLE, "undeadCycleNodeNextPtr"); -// buildFlare(FL(), globalState, functionState, conditionBuilder, "next: ", ptrToIntLE(globalState, conditionBuilder, undeadCycleNodeNextPtrLE)); -// auto undeadCycleNonEmptyDiffLE = -// LLVMBuildPtrDiff( -// conditionBuilder, undeadCycleNodeNextPtrLE, undeadCycleNodePtrLE, "undeadCycleNonEmptyDiff"); -// buildFlare(FL(), globalState, functionState, conditionBuilder, "diff: ", undeadCycleNonEmptyDiffLE); -// auto undeadCycleNonEmptyLE = -// LLVMBuildICmp( -// conditionBuilder, LLVMIntNE, undeadCycleNonEmptyDiffLE, constI64LE(globalState, 0), -// "undeadCycleNonEmpty"); -// buildFlare(FL(), globalState, functionState, conditionBuilder); -// return wrap(globalState->getRegion(boolRefMT), boolRefMT, undeadCycleNonEmptyLE); -// }, -// [this, anyRefMT, functionState](LLVMBuilderRef bodyBuilder) { -// buildFlare(FL(), globalState, functionState, bodyBuilder); -// auto undeadCycleNodePtrLE = LLVMBuildLoad(bodyBuilder, undeadCycleHeadNodePtrPtrLE, "undeadCycleNodePtr"); -// auto undeadCycleNodeObjPtrPtrLE = -// LLVMBuildStructGEP( -// bodyBuilder, undeadCycleNodePtrLE, 1, "undeadCycleNodeObjPtrPtr"); -// auto undeadCycleNodeObjPtrLE = -// LLVMBuildLoad(bodyBuilder, undeadCycleNodeObjPtrPtrLE, "undeadCycleNodeObjPtr"); -// auto undeadCycleNodeObjRef = wrap(globalState->getRegion(anyMT), anyRefMT, undeadCycleNodeObjPtrLE); -// buildFlare(FL(), globalState, functionState, bodyBuilder); -// innerDeallocate(FL(), globalState, functionState, kindStructs, bodyBuilder, anyRefMT, -// undeadCycleNodeObjRef); -// buildFlare(FL(), globalState, functionState, bodyBuilder); -// }); -// buildFlare(FL(), globalState, functionState, builder); -// LLVMBuildRet(builder, constI64LE(globalState, 0)); - }); - return cleanupFuncProto; -} - LLVMValueRef HybridGenerationalMemory::getTargetGenFromWeakRef( LLVMBuilderRef builder, KindStructs* kindStructs, @@ -624,20 +273,8 @@ LLVMValueRef HybridGenerationalMemory::lockGenFatPtr( auto isAliveLE = getIsAliveFromWeakFatPtr(functionState, builder, refM, fatPtrLE, knownLive); buildIf( globalState, functionState, builder, isZeroLE(builder, isAliveLE), - [this, from, functionState, fatPtrLE](LLVMBuilderRef thenBuilder) { - if (globalState->opt->regionOverride == RegionOverride::RESILIENT_V3 || - globalState->opt->regionOverride == RegionOverride::RESILIENT_V4) { - auto ptrToWriteToLE = LLVMBuildLoad(thenBuilder, globalState->crashGlobal, - "crashGlobal"); - LLVMBuildStore(thenBuilder, constI64LE(globalState, 0), ptrToWriteToLE); - } else { - buildPrintAreaAndFileAndLine(globalState, thenBuilder, from); - buildPrint(globalState, thenBuilder, "Tried dereferencing dangling reference! "); - buildPrint(globalState, thenBuilder, "Exiting!\n"); - // See MPESC for status codes - auto exitCodeIntLE = LLVMConstInt(LLVMInt64TypeInContext(globalState->context), 14, false); - LLVMBuildCall(thenBuilder, globalState->externs->exit, &exitCodeIntLE, 1, ""); - } + [this, from](LLVMBuilderRef thenBuilder) { + fastPanic(globalState, from, thenBuilder); }); } return innerLE; @@ -864,78 +501,6 @@ LLVMTypeRef HybridGenerationalMemory::makeWeakRefHeaderStruct(GlobalState* globa return genRefStructL; } -WrapperPtrLE HybridGenerationalMemory::getHalfProtectedPtr( - FunctionState* functionState, LLVMBuilderRef builder, Reference* reference, LLVMTypeRef wrapperStructPtrLT) { - assert(LLVMGetTypeKind(wrapperStructPtrLT) == LLVMPointerTypeKind); - auto iter = globalNullPtrPtrByKind.find(reference->kind); - if (iter == globalNullPtrPtrByKind.end()) { - auto name = std::string("__ValeHGMNull__") + globalState->getKindName(reference->kind)->name; - auto globalPtrLE = LLVMAddGlobal(globalState->mod, wrapperStructPtrLT, name.c_str()); - // Should be overwritten just below - LLVMSetInitializer(globalPtrLE, LLVMConstNull(wrapperStructPtrLT)); - - auto castedNameL = std::string("castedHalfProtected_") + globalState->getKindName(reference->kind)->name; - auto halfProtectedI8PtrLE = LLVMBuildLoad(setupBuilder, halfProtectedI8PtrPtrLE, "halfProtectedI8Ptr"); - auto castedHalfProtectedPtrLE = - LLVMBuildPointerCast(setupBuilder, halfProtectedI8PtrLE, wrapperStructPtrLT, castedNameL.c_str()); - LLVMBuildStore(setupBuilder, castedHalfProtectedPtrLE, globalPtrLE); - - iter = globalNullPtrPtrByKind.emplace(reference->kind, globalPtrLE).first; - } - auto halfProtectedPtrLE = LLVMBuildLoad(builder, iter->second, "halfProtectedPtr"); - return kindStructs->makeWrapperPtr(FL(), functionState, builder, reference, halfProtectedPtrLE); -} - -void HybridGenerationalMemory::addToUndeadCycle( - FunctionState* functionState, - LLVMBuilderRef builder, - Reference* refMT, - WrapperPtrLE uncastedObjWrapperPtrLE) { - buildFlare(FL(), globalState, functionState, builder, "Adding to undead cycle!"); - - auto anyRefMT = globalState->metalCache->getReference(Ownership::OWN, Location::YONDER, anyMT); - auto anyRefLT = globalState->getRegion(anyMT)->translateType(anyRefMT); - - auto objAsAnyWrapperPtrLE = - kindStructs->makeWrapperPtr( - FL(), functionState, builder, anyRefMT, - LLVMBuildPointerCast(builder, uncastedObjWrapperPtrLE.refLE, anyRefLT, "objAsAnyWrapperPtr")); - - auto undeadCycleHeadNodePtrLE = - LLVMBuildLoad(builder, undeadCycleHeadNodePtrPtrLE, "undeadCycleHeadNodePtr"); -// buildFlare(FL(), globalState, functionState, builder, "cycle head: ", ptrToIntLE(globalState, builder, undeadCycleHeadNodePtrLE)); - auto undeadCycleHeadNodeNextPtrPtrLE = - LLVMBuildStructGEP(builder, undeadCycleHeadNodePtrLE, 0, "undeadCycleHeadNodeNextPtrPtr"); - auto undeadCycleHeadNodeNextPtrLE = - LLVMBuildLoad(builder, undeadCycleHeadNodeNextPtrPtrLE, "undeadCycleHeadNodeNextPtr"); -// buildFlare(FL(), globalState, functionState, builder, "cycle head next: ", ptrToIntLE(globalState, builder, undeadCycleHeadNodeNextPtrLE)); - - // First, make the new node. Point it at the existing head's next node. - auto newNodeI8PtrLE = - callMalloc( - globalState, - builder, - constI64LE(globalState, LLVMABISizeOfType(globalState->dataLayout, undeadCycleNodeLT))); - auto newNodePtrLE = - LLVMBuildPointerCast( - builder, newNodeI8PtrLE, LLVMPointerType(undeadCycleNodeLT, 0), - "newNodePtr"); -// buildFlare(FL(), globalState, functionState, builder, "new node: ", ptrToIntLE(globalState, builder, newNodePtrLE)); - // Make it point at the existing head's next node. - auto newNodeNextPtrPtrLE = - LLVMBuildStructGEP(builder, newNodePtrLE, 0, "newNodeNextPtrPtr"); - LLVMBuildStore(builder, undeadCycleHeadNodeNextPtrLE, newNodeNextPtrPtrLE); -// buildFlare(FL(), globalState, functionState, builder, "new node's next is now: ", ptrToIntLE(globalState, builder, undeadCycleHeadNodeNextPtrLE)); - // Point the obj field at the now undead object. - auto newNodeObjPtrPtrLE = - LLVMBuildStructGEP(builder, newNodePtrLE, 1, "newNodeObjPtrPtr"); - LLVMBuildStore(builder, objAsAnyWrapperPtrLE.refLE, newNodeObjPtrPtrLE); - - // The previous head will still be the head, but it will now point at our new node. - LLVMBuildStore(builder, newNodePtrLE, undeadCycleHeadNodeNextPtrPtrLE); -// buildFlare(FL(), globalState, functionState, builder, "cycle head's next is now: ", ptrToIntLE(globalState, builder, newNodePtrLE)); -} - LLVMValueRef HybridGenerationalMemory::implodeConcreteHandle( FunctionState* functionState, LLVMBuilderRef builder, diff --git a/Midas/src/c-compiler/region/common/hgm/hgm.h b/Midas/src/c-compiler/region/common/hgm/hgm.h index cbf845426..baac56b60 100644 --- a/Midas/src/c-compiler/region/common/hgm/hgm.h +++ b/Midas/src/c-compiler/region/common/hgm/hgm.h @@ -16,9 +16,6 @@ class HybridGenerationalMemory { bool limitMode_, StructKind* anyMT); - void mainSetup(FunctionState* functionState, LLVMBuilderRef builder); - void mainCleanup(FunctionState* functionState, LLVMBuilderRef builder); - Ref assembleWeakRef( FunctionState* functionState, LLVMBuilderRef builder, @@ -165,15 +162,6 @@ class HybridGenerationalMemory { static LLVMTypeRef makeWeakRefHeaderStruct(GlobalState* globalState, RegionId* regionId); - WrapperPtrLE getHalfProtectedPtr( - FunctionState* functionState, LLVMBuilderRef builder, Reference* reference, LLVMTypeRef wrapperStructPtrLT); - - void addToUndeadCycle( - FunctionState* functionState, - LLVMBuilderRef builder, - Reference* refMT, - WrapperPtrLE uncastedObjWrapperPtrLE); - LLVMValueRef implodeConcreteHandle( FunctionState* functionState, LLVMBuilderRef builder, @@ -193,38 +181,15 @@ class HybridGenerationalMemory { Kind* kind, WeakFatPtrLE weakRefLE); - Prototype* makeCleanupLoopFunction(); - Prototype* makeCleanupIterFunction(); - Prototype* makeMainSetupFunction(); - Prototype* makeMainCleanupFunction(); - - Prototype* cleanupIterPrototype = nullptr; - GlobalState* globalState = nullptr; // ControlBlock* controlBlock = nullptr; FatWeaks fatWeaks; KindStructs* kindStructs; // KindStructs* weakRefStructsSource; - LLVMBuilderRef setupBuilder = nullptr; - - LLVMTypeRef undeadCycleNodeLT = nullptr; - LLVMValueRef undeadCycleHeadNodePtrPtrLE = nullptr; - bool elideChecksForKnownLive = false; -// -// // If true, then pretend all references are known live, dont fill in any generations, basically -// // pretend to be unsafe mode as much as possible. -// // This is to see the theoretical maximum speed of HGM, and where its slowdowns are. -// bool limitMode = false; - - // Points to an object whose control block is in an unprotected page, and the contents of the object - // is in a protected page. - // (Well, actually, the object itself is an empty struct, so i guess it's all in the protected page.) - // This is so we have an object whose tethered bit we can modify but no other part of it. - LLVMValueRef halfProtectedI8PtrPtrLE = nullptr; StructKind* anyMT = nullptr; diff --git a/Midas/src/c-compiler/region/resilientv3/resilientv3.cpp b/Midas/src/c-compiler/region/resilientv3/resilientv3.cpp index 8e91d13c8..9b220ab9d 100644 --- a/Midas/src/c-compiler/region/resilientv3/resilientv3.cpp +++ b/Midas/src/c-compiler/region/resilientv3/resilientv3.cpp @@ -47,11 +47,11 @@ ResilientV3::ResilientV3(GlobalState *globalState_, RegionId *regionId_) : } void ResilientV3::mainSetup(FunctionState* functionState, LLVMBuilderRef builder) { - hgmWeaks.mainSetup(functionState, builder); +// hgmWeaks.mainSetup(functionState, builder); } void ResilientV3::mainCleanup(FunctionState* functionState, LLVMBuilderRef builder) { - hgmWeaks.mainCleanup(functionState, builder); +// hgmWeaks.mainCleanup(functionState, builder); } RegionId *ResilientV3::getRegionId() { diff --git a/Midas/src/c-compiler/region/resilientv4/resilientv4.cpp b/Midas/src/c-compiler/region/resilientv4/resilientv4.cpp index 8ec079f35..f816951a6 100644 --- a/Midas/src/c-compiler/region/resilientv4/resilientv4.cpp +++ b/Midas/src/c-compiler/region/resilientv4/resilientv4.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -57,11 +58,11 @@ ResilientV4::ResilientV4(GlobalState *globalState_, RegionId *regionId_) : } void ResilientV4::mainSetup(FunctionState* functionState, LLVMBuilderRef builder) { - hgmWeaks.mainSetup(functionState, builder); +// hgmWeaks.mainSetup(functionState, builder); } void ResilientV4::mainCleanup(FunctionState* functionState, LLVMBuilderRef builder) { - hgmWeaks.mainCleanup(functionState, builder); +// hgmWeaks.mainCleanup(functionState, builder); } RegionId *ResilientV4::getRegionId() { @@ -751,38 +752,10 @@ void ResilientV4::deallocate( buildVoidIfElse( globalState, functionState, builder, tetheredLE, [this, functionState, sourceContentsPtrLE, refMT, ref, sourceWrapperPtrLE](LLVMBuilderRef thenBuilder) { - buildFlare(FL(), globalState, functionState, thenBuilder, "still tethered, undeadifying!"); - auto sourceContentsI8PtrLE = LLVMBuildPointerCast(thenBuilder, sourceContentsPtrLE, LLVMPointerType(LLVMInt8TypeInContext(globalState->context), 0), "sourceContentsI8Ptr"); -// auto structKind = dynamic_cast(refMT->kind); -// assert(structKind); -// auto structLT = kindStructs.getInnerStruct(structKind); - - LLVMValueRef numElementsLE = nullptr; - if (auto rsaMT = dynamic_cast(refMT->kind)) { - buildFlare(FL(), globalState, functionState, thenBuilder); - auto lenRef = getRuntimeSizedArrayLength(functionState, thenBuilder, refMT, ref, true); - numElementsLE = - globalState->getRegion(globalState->metalCache->i32Ref) - ->checkValidReference(FL(), functionState, thenBuilder, globalState->metalCache->i32Ref, lenRef); - } else if (auto ssaMT = dynamic_cast(refMT->kind)) { - auto ssaDefM = globalState->program->getStaticSizedArray(ssaMT); - buildFlare(FL(), globalState, functionState, thenBuilder); - numElementsLE = constI32LE(globalState, ssaDefM->size); - } else if (dynamic_cast(refMT->kind)) { - buildFlare(FL(), globalState, functionState, thenBuilder); - numElementsLE = constI32LE(globalState, 0); - } else if (dynamic_cast(refMT->kind)) { - buildFlare(FL(), globalState, functionState, thenBuilder); - numElementsLE = constI32LE(globalState, 0); - } - auto sizeLE = predictShallowSize(functionState, thenBuilder, false, refMT->kind, numElementsLE); - buildFlare(FL(), globalState, functionState, thenBuilder, "size: ", sizeLE); - - std::vector argsLE = { sourceContentsI8PtrLE, constI8LE(globalState, 0), sizeLE }; - LLVMBuildCall(thenBuilder, globalState->externs->memset, argsLE.data(), argsLE.size(), ""); - buildFlare(FL(), globalState, functionState, thenBuilder, "done!"); - - hgmWeaks.addToUndeadCycle(functionState, thenBuilder, refMT, sourceWrapperPtrLE); + buildPrint(globalState, thenBuilder, "Tried to deallocate an object while borrowed!"); + // See MPESC for status codes + auto exitCodeIntLE = LLVMConstInt(LLVMInt64TypeInContext(globalState->context), 14, false); + LLVMBuildCall(thenBuilder, globalState->externs->exit, &exitCodeIntLE, 1, ""); }, [this, from, functionState, refMT, ref](LLVMBuilderRef elseBuilder) { buildFlare(FL(), globalState, functionState, elseBuilder); @@ -1103,28 +1076,26 @@ void ResilientV4::storeAndTether( auto innerRefLE = fatWeaks.getInnerRefFromWeakRef(functionState, builder, local->type, weakFatPtrLE); auto wrapperPtrLE = kindStructs.makeWrapperPtr(FL(), functionState, builder, local->type, innerRefLE); - auto halfProtectedWrapperPtrLE = - hgmWeaks.getHalfProtectedPtr(functionState, builder, local->type, wrapperStructPtrLT); - - auto isAliveLE = - hgmWeaks.getIsAliveFromWeakFatPtr(functionState, builder, local->type, weakFatPtrLE, knownLive); - // If it's alive, refLE will point to the object. Dereferencing it is fine. - // If it's dead, refLE will point to a half protected object. Can change its tether, but not dereference its contents. - assert(wrapperPtrLE.refM == halfProtectedWrapperPtrLE.refM); - assert(LLVMTypeOf(wrapperPtrLE.refLE) == LLVMTypeOf(halfProtectedWrapperPtrLE.refLE)); + hgmWeaks.lockGenFatPtr(FL(), functionState, builder, local->type, weakFatPtrLE, knownLive); +// auto isAliveLE = +// hgmWeaks.getIsAliveFromWeakFatPtr(functionState, builder, local->type, weakFatPtrLE, knownLive); +// // If it's alive, refLE will point to the object. Dereferencing it is fine. +// // If it's dead, refLE will point to a half protected object. Can change its tether, but not dereference its contents. +// assert(wrapperPtrLE.refM == halfProtectedWrapperPtrLE.refM); +// assert(LLVMTypeOf(wrapperPtrLE.refLE) == LLVMTypeOf(halfProtectedWrapperPtrLE.refLE)); auto newWrapperPtrLE = kindStructs.makeWrapperPtr( FL(), functionState, builder, local->type, - LLVMBuildSelect( - builder, isAliveLE, wrapperPtrLE.refLE, halfProtectedWrapperPtrLE.refLE, "clearableRef")); + wrapperPtrLE.refLE); +// LLVMBuildSelect( +// builder, isAliveLE, wrapperPtrLE.refLE, halfProtectedWrapperPtrLE.refLE, "clearableRef")); std::unique_ptr newWeakFatPtrU; if (auto structRKind = dynamic_cast(local->type->kind)) { newWeakFatPtrU = - std::unique_ptr{ - new WeakFatPtrLE( - hgmWeaks.assembleStructWeakRef( - functionState, builder, local->type, local->type, structRKind, newWrapperPtrLE))}; + std::make_unique( + hgmWeaks.assembleStructWeakRef( + functionState, builder, local->type, local->type, structRKind, newWrapperPtrLE)); } else if (auto rsaMT = dynamic_cast(local->type->kind)) { newWeakFatPtrU = std::unique_ptr{ @@ -1149,7 +1120,7 @@ void ResilientV4::storeAndTether( auto tetherI32LE = LLVMBuildLoad(builder, tetherPtrLE, "tetherI32"); auto wasTetheredLE = LLVMBuildTrunc(builder, tetherI32LE, LLVMInt1TypeInContext(globalState->context), "wasAlive"); - buildFlare(FL(), globalState, functionState, builder, "Tethering! Is alive: ", LLVMBuildZExt(builder, isAliveLE, LLVMInt64TypeInContext(globalState->context), ""), " resuting ptr: ", ptrToIntLE(globalState, builder, newWrapperPtrLE.refLE), " halfprotptr: ", ptrToIntLE(globalState, builder, halfProtectedWrapperPtrLE.refLE)); + buildFlare(FL(), globalState, functionState, builder, "Tethering!"); LLVMBuildStore(builder, constI32LE(globalState, 1), tetherPtrLE); auto refMemberPtrLE = LLVMBuildStructGEP(builder, localAddr, 0, "refMemberPtr"); diff --git a/Midas/src/c-compiler/vale.cpp b/Midas/src/c-compiler/vale.cpp index 9d0b4a558..82da02322 100644 --- a/Midas/src/c-compiler/vale.cpp +++ b/Midas/src/c-compiler/vale.cpp @@ -115,9 +115,6 @@ void initInternalExterns(GlobalState* globalState) { auto voidPtrLT = LLVMPointerType(int8LT, 0); auto int8PtrLT = LLVMPointerType(int8LT, 0); - globalState->genMalloc = addExtern(globalState->mod, "__genMalloc", voidPtrLT, {int64LT}); - globalState->genFree = addExtern(globalState->mod, "__genFree", LLVMVoidTypeInContext(globalState->context), {voidPtrLT}); - { globalState->wrcTableStructLT = LLVMStructCreateNamed(globalState->context, "__WRCTable"); std::vector memberTypesL; @@ -680,15 +677,6 @@ void compileValeCode(GlobalState* globalState, std::vector& inputFi assert(actualSize == 32); } - - if (globalState->opt->regionOverride == RegionOverride::RESILIENT_V3 || - globalState->opt->regionOverride == RegionOverride::RESILIENT_V4) { - if (!globalState->opt->genHeap) { - std::cerr << "Warning: using resilient without generational heap, overriding generational heap to true!" << std::endl; - globalState->opt->genHeap = true; - } - } - switch (globalState->opt->regionOverride) { case RegionOverride::ASSIST: std::cout << "Region override: assist" << std::endl; @@ -714,6 +702,9 @@ void compileValeCode(GlobalState* globalState, std::vector& inputFi if (!globalState->opt->census) { std::cout << "Warning: not using census when in assist mode!" << std::endl; } + if (globalState->opt->fastCrash) { + std::cout << "Warning: using fastCrash when in assist mode!" << std::endl; + } } else { if (globalState->opt->flares) { std::cout << "Warning: using flares outside of assist mode, will slow things down!" << std::endl; @@ -721,6 +712,9 @@ void compileValeCode(GlobalState* globalState, std::vector& inputFi if (globalState->opt->census) { std::cout << "Warning: using census outside of assist mode, will slow things down!" << std::endl; } + if (!globalState->opt->fastCrash) { + std::cout << "Warning: not using fashCrash, will slow things down!" << std::endl; + } } diff --git a/Midas/src/c-compiler/valeopts.cpp b/Midas/src/c-compiler/valeopts.cpp index 9524d0a4b..0cf4314dd 100644 --- a/Midas/src/c-compiler/valeopts.cpp +++ b/Midas/src/c-compiler/valeopts.cpp @@ -43,6 +43,7 @@ enum OPT_IMMERR, OPT_VERIFY, OPT_FLARES, + OPT_FAST_CRASH, OPT_GEN_HEAP, OPT_ELIDE_CHECKS_FOR_KNOWN_LIVE, OPT_OVERRIDE_KNOWN_LIVE_TRUE, @@ -68,13 +69,13 @@ static opt_arg_t args[] = { "define", 'D', OPT_ARG_REQUIRED, OPT_BUILDFLAG }, { "strip", 's', OPT_ARG_NONE, OPT_STRIP }, { "path", 'p', OPT_ARG_REQUIRED, OPT_PATHS }, - { "output-dir", '\0', OPT_ARG_REQUIRED, OPT_OUTPUT_DIR }, + { "output_dir", '\0', OPT_ARG_REQUIRED, OPT_OUTPUT_DIR }, { "library", 'l', OPT_ARG_NONE, OPT_LIBRARY }, { "runtimebc", '\0', OPT_ARG_NONE, OPT_RUNTIMEBC }, { "pic", '\0', OPT_ARG_NONE, OPT_PIC }, { "nopic", '\0', OPT_ARG_NONE, OPT_NOPIC }, { "docs", 'g', OPT_ARG_NONE, OPT_DOCS }, - { "docs-public", '\0', OPT_ARG_NONE, OPT_DOCS_PUBLIC }, + { "docs_public", '\0', OPT_ARG_NONE, OPT_DOCS_PUBLIC }, { "safe", '\0', OPT_ARG_OPTIONAL, OPT_SAFE }, { "cpu", '\0', OPT_ARG_REQUIRED, OPT_CPU }, @@ -82,20 +83,21 @@ static opt_arg_t args[] = { "wasm", '\0', OPT_ARG_NONE, OPT_WASM }, { "triple", '\0', OPT_ARG_REQUIRED, OPT_TRIPLE }, { "stats", '\0', OPT_ARG_NONE, OPT_STATS }, - { "link-arch", '\0', OPT_ARG_REQUIRED, OPT_LINK_ARCH }, + { "link_arch", '\0', OPT_ARG_REQUIRED, OPT_LINK_ARCH }, { "linker", '\0', OPT_ARG_REQUIRED, OPT_LINKER }, { "verbose", 'V', OPT_ARG_REQUIRED, OPT_VERBOSE }, { "flares", '\0', OPT_ARG_OPTIONAL, OPT_FLARES }, - { "gen-heap", '\0', OPT_ARG_OPTIONAL, OPT_GEN_HEAP }, + { "fast_crash", '\0', OPT_ARG_OPTIONAL, OPT_FLARES }, + { "gen_heap", '\0', OPT_ARG_OPTIONAL, OPT_GEN_HEAP }, { "elide_checks_for_known_live", '\0', OPT_ARG_OPTIONAL, OPT_ELIDE_CHECKS_FOR_KNOWN_LIVE }, { "override_known_live_true", '\0', OPT_ARG_NONE, OPT_OVERRIDE_KNOWN_LIVE_TRUE }, - { "print-mem-overhead", '\0', OPT_ARG_OPTIONAL, OPT_PRINT_MEM_OVERHEAD }, + { "print_mem_overhead", '\0', OPT_ARG_OPTIONAL, OPT_PRINT_MEM_OVERHEAD }, { "census", '\0', OPT_ARG_OPTIONAL, OPT_CENSUS }, - { "region-override", '\0', OPT_ARG_REQUIRED, OPT_REGION_OVERRIDE }, + { "region_override", '\0', OPT_ARG_REQUIRED, OPT_REGION_OVERRIDE }, { "ir", '\0', OPT_ARG_NONE, OPT_IR }, { "asm", '\0', OPT_ARG_NONE, OPT_ASM }, - { "llvmir", '\0', OPT_ARG_NONE, OPT_LLVMIR }, + { "llvm_ir", '\0', OPT_ARG_NONE, OPT_LLVMIR }, { "trace", 't', OPT_ARG_NONE, OPT_TRACE }, { "width", 'w', OPT_ARG_REQUIRED, OPT_WIDTH }, { "immerr", '\0', OPT_ARG_NONE, OPT_IMMERR }, @@ -104,7 +106,7 @@ static opt_arg_t args[] = { "checktree", '\0', OPT_ARG_NONE, OPT_CHECKTREE }, { "extfun", '\0', OPT_ARG_NONE, OPT_EXTFUN }, { "simplebuiltin", '\0', OPT_ARG_NONE, OPT_SIMPLEBUILTIN }, - { "lint-llvm", '\0', OPT_ARG_NONE, OPT_LINT_LLVM }, + { "lint_llvm", '\0', OPT_ARG_NONE, OPT_LINT_LLVM }, OPT_ARGS_FINISH }; @@ -126,7 +128,7 @@ static void usage() " --path, -p Add an additional search path.\n" " =path Used to find packages and libraries.\n" " --o Name the resulting executable.\n" - " --output-dir Write output to this directory.\n" + " --output_dir Write output to this directory.\n" " =path Defaults to the current directory.\n" " --library, -l Generate a C-API compatible static library.\n" " --runtimebc Compile with the LLVM bitcode file for the runtime.\n" @@ -134,7 +136,7 @@ static void usage() " --pic Compile using position independent code.\n" " --nopic Don't compile using position independent code.\n" " --docs, -g Generate code documentation.\n" - " --docs-public Generate code documentation for public types only.\n" + " --docs_public Generate code documentation for public types only.\n" , "Rarely needed options:\n" " --safe Allow only the listed packages to use C FFI.\n" @@ -147,7 +149,7 @@ static void usage() " --triple Set the target triple.\n" " =name Defaults to the host triple.\n" " --stats Print some compiler stats.\n" - " --link-arch Set the linking architecture.\n" + " --link_arch Set the linking architecture.\n" " =name Default is the host architecture.\n" " --linker Set the linker command to use.\n" " =name Default is the compiler.\n" @@ -161,7 +163,7 @@ static void usage() " =4 Very low-level detail.\n" " --ir Output an IR tree for the whole program.\n" " --asm Output an assembly file.\n" - " --llvmir Output an LLVM IR file.\n" + " --llvm_ir Output an LLVM IR file.\n" " --trace, -t Enable parse trace.\n" " --width, -w Width to target when printing the IR.\n" " =columns Defaults to the terminal width.\n" @@ -171,7 +173,7 @@ static void usage() " --extfun Set function default linkage to external.\n" " --simplebuiltin Use a minimal builtin package.\n" " --files Print source file names as each is processed.\n" - " --lint-llvm Run the LLVM linting pass on generated IR.\n" + " --lint_llvm Run the LLVM linting pass on generated IR.\n" , "" // "Runtime options for Vale programs (not for use with Vale compiler):\n" ); @@ -190,7 +192,7 @@ int valeOptSet(ValeOptions *opt, int *argc, char **argv) { optInit(args, &s, argc, argv); opt->release = 1; opt->flares = false; - opt->genHeap = false; + opt->fastCrash = false; opt->elideChecksForKnownLive = false; opt->overrideKnownLiveTrue = false; opt->census = false; @@ -233,13 +235,13 @@ int valeOptSet(ValeOptions *opt, int *argc, char **argv) { break; } - case OPT_GEN_HEAP: { + case OPT_FAST_CRASH: { if (!s.arg_val) { - opt->genHeap = true; + opt->fastCrash = true; } else if (s.arg_val == std::string("on")) { - opt->genHeap = true; + opt->fastCrash = true; } else if (s.arg_val == std::string("off")) { - opt->genHeap = false; + opt->fastCrash = false; } else assert(false); break; } diff --git a/Midas/src/c-compiler/valeopts.h b/Midas/src/c-compiler/valeopts.h index 0d2c0fb0b..f40ed0dbd 100644 --- a/Midas/src/c-compiler/valeopts.h +++ b/Midas/src/c-compiler/valeopts.h @@ -44,7 +44,7 @@ struct ValeOptions { bool docs = false; // Generate code documentation bool census = false; // Enable census checking bool flares = false; // Enable flare output - bool genHeap = false; // Enables generational heap + bool fastCrash = false; // Enable single-instruction crash, a bit faster bool elideChecksForKnownLive = false; // Enables generational heap bool overrideKnownLiveTrue = false; // Enables generational heap bool printMemOverhead = false; // Enables generational heap diff --git a/Midas/test.sh b/Midas/test.sh index 01faa6b28..57ab68d69 100755 --- a/Midas/test.sh +++ b/Midas/test.sh @@ -1 +1 @@ -../Tester/build/testvalec --valestrom_path ../Valestrom/Valestrom.jar --midas_path ./build/midas --builtins_dir ./src/builtins --valec_path ../Driver/build/valec --midas_tests_dir ./test --valestrom_tests_dir ../Valestrom --concurrent 6 +../Tester/build/testvalec --valestrom_path ../Valestrom/Valestrom.jar --midas_path ./build/midas --builtins_dir ./src/builtins --valec_path ../Driver/build/valec --midas_tests_dir ./test --valestrom_tests_dir ../Valestrom --concurrent 6 "$@" diff --git a/Midas/test/tether.vale b/Midas/test/tether.vale deleted file mode 100644 index daaf9a7e5..000000000 --- a/Midas/test/tether.vale +++ /dev/null @@ -1,10 +0,0 @@ - -struct Spaceship { - fuel int; -} -fn main() int export { - s = Spaceship(42); - s__tether = &s; - drop(s); - = s__tether.fuel; // should return 0 -} diff --git a/Midas/test/tethercrash.vale b/Midas/test/tethercrash.vale index 1339e3f2f..b9d777a33 100644 --- a/Midas/test/tethercrash.vale +++ b/Midas/test/tethercrash.vale @@ -1,11 +1,16 @@ +import stdlib.*; struct Spaceship { fuel int; } fn main() int export { - s = Spaceship(42); + print("Starting...\n"); + s = Spaceship(73); b = &s; + print("Dropping...\n"); drop(s); + print("Getting tether...\n"); s__tether = b; + print("Should have failed before here!\n"); = s__tether.fuel; } diff --git a/Midas/test/twinpages/test.c b/Midas/test/twinpages/test.c deleted file mode 100644 index 26fa21097..000000000 --- a/Midas/test/twinpages/test.c +++ /dev/null @@ -1,137 +0,0 @@ -#ifdef _WIN32 -#include -#include -#include -#include -#else -#include -#include -#include -#endif -#include -#include - - -int pageSize() { -#ifdef _WIN32 - DWORD dwPageSize; // amount of memory to allocate. - SYSTEM_INFO sSysInfo; // useful information about the system - GetSystemInfo(&sSysInfo); // initialize the structure - return sSysInfo.dwPageSize; -#else - return getpagesize(); -#endif -} - - -void SignalHandler(int signal) { - printf("Memory violation! Signal %d\n", signal); - exit(42); -} - - -const char attemptbadwritestr[] = "attemptbadwrite"; -const char noattemptbadwritestr[] = "noattemptbadwrite"; - -int main(int argc, char** argv) { - if (argc < 2) { - fprintf(stderr, "Must specify attemptbadwrite or noattemptbadwrite for first arg!\n"); - return 1; - } - if (strncmp(argv[1], attemptbadwritestr, strlen(attemptbadwritestr)) != 0 && - strncmp(argv[1], noattemptbadwritestr, strlen(noattemptbadwritestr)) != 0) { - fprintf(stderr, "Must specify attemptwrite or noattemptwrite for first arg!\n"); - return 1; - } - int attemptBadWrite = strncmp(argv[1], attemptbadwritestr, strlen(attemptbadwritestr)) == 0; - - size_t pagesize = pageSize(); - - printf("System page size: %zu bytes\n", pagesize); - -#ifdef _WIN32 - char* allocationPtr = - VirtualAlloc( - NULL, pagesize * 2, MEM_RESERVE | MEM_COMMIT, PAGE_NOACCESS); - if(allocationPtr == NULL) { - _tprintf(TEXT("VirtualAlloc failed. Error: %ld\n"), GetLastError()); - return 1; - } -#else - char *allocationPtr = - mmap(0, pagesize * 2, 0, MAP_ANON | MAP_PRIVATE, 0, 0); - if (allocationPtr == MAP_FAILED) { - perror("Could not mmap"); - return 1; - } -#endif - - printf("Successfully allocated two pages, starting at %p\n", allocationPtr); - -#ifdef _WIN32 - DWORD oldFlags = 0; - int virtualProtectSuccess = - VirtualProtect( - allocationPtr, pagesize, PAGE_READWRITE, &oldFlags); - if (!virtualProtectSuccess) { - _tprintf(TEXT("VirtualProtect failed. Error: %ld\n"), GetLastError()); - exit(1); - } -#else - if (mprotect(allocationPtr, pagesize, PROT_READ | PROT_WRITE)) { - perror("Could not mprotect"); - return 1; - } -#endif - - printf("Writing 42 to the end of the unprotected twin page!\n"); - *(long long*)&allocationPtr[pagesize - sizeof(long long)] = 42LL; - - printf("Reading from the end of the unprotected twin page!\n"); - long long result = *(long long*)&allocationPtr[pagesize - sizeof(long long)]; - printf("Got: %lld\n", result); - - if (attemptBadWrite) { - printf("Setting up signal handlers!\n"); - // Set up the signal to catch the seg fault. - // This is especially nice for windows, which otherwise just silently fails. - typedef void (*SignalHandlerPointer)(int); - SignalHandlerPointer previousSigsegvHandler = signal(SIGSEGV, SignalHandler); - if (previousSigsegvHandler == SIG_ERR) { - perror("Could not register segfault handler!"); - exit(1); - } - // Mac has bus faults, not seg faults, when we do the below access -#ifndef _WIN32 - SignalHandlerPointer previousBusErrorHandler = signal(SIGBUS, SignalHandler); - if (previousSigsegvHandler == SIG_ERR) { - perror("Could not register busfault handler!"); - exit(1); - } -#endif - - printf("Writing to the beginning of the protected twin page, should crash!\n"); - allocationPtr[pagesize] = 73LL; - } - -#ifdef _WIN32 - int virtualFreeSuccess = VirtualFree(allocationPtr, 0, MEM_RELEASE); - if (!virtualFreeSuccess) { - _tprintf(TEXT("VirtualFree failed. Error: %ld\n"), GetLastError()); - exit(1); - } -#else - int unmap_result = munmap(allocationPtr, pagesize * 2); - if (unmap_result != 0) { - perror("Could not munmap"); - return 1; - } -#endif - - if (result == 42LL) { - printf("Success!\n"); - return 0; - } else { - return 1; - } -} \ No newline at end of file diff --git a/Midas/test/valetest.py b/Midas/test/valetest.py deleted file mode 100644 index 9d3fa3a02..000000000 --- a/Midas/test/valetest.py +++ /dev/null @@ -1,937 +0,0 @@ -import unittest -import subprocess -import platform -import os.path -import os -import sys -import shutil -import glob - -from typing import Dict, Any, List, Callable - - -def procrun(args: List[str], **kwargs) -> subprocess.CompletedProcess: - # print("Running: " + " ".join(args)) - return subprocess.run(args, capture_output=True, text=True, **kwargs) - - -PATH_TO_SAMPLES = "../Valestrom/Tests/test/main/resources/" - -class ValeTest(unittest.TestCase): - GENPATH: str = os.environ.get('GENPATH', ".") - - def valec(self, - module_name: str, - in_filepaths: List[str], - o_files_dir: str, - exe_name: str, - region_override: str, - extra_flags: List[str]) -> subprocess.CompletedProcess: - assert self.GENPATH - python = "python" if self.windows else "python3" - return procrun( - [python, - f"{self.GENPATH}/valec.py", - "build", - module_name, - "--verify", - "--llvmir", - #"--census", - "--flares", - "--region-override", region_override, - "--output-dir", o_files_dir, - "-o", - exe_name] + extra_flags + in_filepaths) - - def exec(self, exe_file: str) -> subprocess.CompletedProcess: - return procrun([f"./{exe_file}"]) - - @classmethod - def setUpClass(cls) -> None: - print( - f"Using valec from {cls.GENPATH}. " + - "Set GENPATH env var if this is incorrect", - file=sys.stderr) - - def setUp(self) -> None: - self.GENPATH: str = type(self).GENPATH - self.windows = platform.system() == 'Windows' - - def compile_and_execute( - self, - in_filepaths: List[str], - region_override: str, - extra_flags: List[str]) -> subprocess.CompletedProcess: - first_vale_filepath = in_filepaths[0] - file_name_without_extension = os.path.splitext(os.path.basename(first_vale_filepath))[0] - test_dir_name = f"{file_name_without_extension}_{region_override}" - build_dir = f"test/test_build/{test_dir_name}_build" - - module_name = "tmod" - for i in range(0, len(in_filepaths)): - in_filepaths[i] = module_name + ":" + in_filepaths[i] - - proc = self.valec(module_name, in_filepaths, build_dir, file_name_without_extension, region_override, extra_flags) - self.assertEqual(proc.returncode, 0, - f"valec couldn't compile {in_filepaths}:\n" + - proc.stdout + "\n" + proc.stderr) - - exe_file = f"{build_dir}/{file_name_without_extension}" - - proc = self.exec(exe_file) - return proc - - def compile_and_execute_and_expect_return_code( - self, - vale_files: List[str], - region_override: str, - expected_return_code: int, - extra_flags: List[str] = None) -> None: - if extra_flags is None: - extra_flags = [] - proc = self.compile_and_execute(vale_files, region_override, extra_flags) - # print(proc.stdout) - # print(proc.stderr) - if proc.returncode != expected_return_code: - first_vale_filepath = vale_files[0] - file_name_without_extension = os.path.splitext(os.path.basename(first_vale_filepath))[0] - test_dir_name = f"{file_name_without_extension}_{region_override}" - build_dir = f"test/test_build/{test_dir_name}_build" - textfile = open(build_dir + "/stdout.txt", "w") - a = textfile.write(proc.stdout) - textfile.close() - textfile = open(build_dir + "/stderr.txt", "w") - a = textfile.write(proc.stderr) - textfile.close() - self.assertEqual(proc.returncode, expected_return_code, - f"Unexpected result: {proc.returncode}\n" + proc.stdout + proc.stderr) - - # Tests for immutables in exports/externs - def test_assist_strlenextern(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/strlenextern"], "assist", 11) - def test_assist_voidreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/voidreturnexport"], "assist", 42) - def test_assist_structimmparamextern(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structimmparamextern"], "assist", 42) - def test_assist_structimmparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structimmparamexport"], "assist", 42) - def test_assist_structimmparamdeepextern(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structimmparamdeepextern"], "assist", 42) - def test_assist_structimmparamdeepexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structimmparamdeepexport"], "assist", 42) - def test_assist_interfaceimmparamextern(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmparamextern"], "assist", 42) - def test_assist_interfaceimmparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmparamexport"], "assist", 42) - def test_assist_interfaceimmparamdeepextern(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmparamdeepextern"], "assist", 42) - def test_assist_interfaceimmparamdeepexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmparamdeepexport"], "assist", 42) - def test_assist_rsaimmreturnextern(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsaimmreturnextern"], "assist", 42) - def test_assist_rsaimmreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsaimmreturnexport"], "assist", 42) - def test_assist_rsaimmparamextern(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsaimmparamextern"], "assist", 10) - def test_assist_rsaimmparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsaimmparamexport"], "assist", 10) - def test_assist_rsaimmparamdeepextern(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsaimmparamdeepextern"], "assist", 20) - def test_assist_rsaimmparamdeepexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsaimmparamdeepexport"], "assist", 42) - def test_assist_ssaimmparamextern(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssaimmparamextern"], "assist", 42) - def test_assist_ssaimmparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssaimmparamexport"], "assist", 42) - def test_assist_ssaimmreturnextern(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssaimmreturnextern"], "assist", 42) - def test_assist_ssaimmreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssaimmreturnexport"], "assist", 42) - def test_assist_ssaimmparamdeepextern(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssaimmparamdeepextern"], "assist", 42) - def test_assist_ssaimmparamdeepexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssaimmparamdeepexport"], "assist", 42) - - def test_assist_voidreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/voidreturnexport"], "assist", 42) - def test_assist_strreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/strreturnexport"], "assist", 6) - def test_assist_structimmparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structimmparamexport"], "assist", 42) - def test_assist_structimmparamdeepexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structimmparamdeepexport"], "assist", 42) - def test_assist_interfaceimmparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmparamexport"], "assist", 42) - def test_assist_rsaimmparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsaimmparamexport"], "assist", 10) - def test_assist_smallstr(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/smallstr.vale"], "assist", 42) - def test_assist_immtupleaccess(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/tuples/immtupleaccess.vale"], "assist", 42) - def test_assist_ssaimmfromcallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssaimmfromcallable.vale"], "assist", 42) - def test_assist_ssaimmfromvalues(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssaimmfromvalues.vale"], "assist", 42) - - # kldc = known live double check - def test_resilientv3_kldc(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/deadmutstruct.vale"], "resilient-v3", 116, ["--override-known-live-true"]) - - def test_twinpages_noattemptbadwrite(self) -> None: - if platform.system() == 'Windows': - proc = procrun(["cl.exe", "test/twinpages/test.c", "-o", "test/test_build/testtwinpages.exe"]) - proc = procrun(["test/test_build/testtwinpages.exe", "noattemptbadwrite"]) - self.assertEqual(proc.returncode, 0, f"Twin pages test failed!") - else: - proc = procrun(["clang", "test/twinpages/test.c", "-o", "test/test_build/testtwinpages"]) - proc = procrun(["test/test_build/testtwinpages", "noattemptbadwrite"]) - self.assertEqual(proc.returncode, 0, f"Twin pages test failed!") - - def test_twinpages_attemptbadwrite(self) -> None: - if platform.system() == 'Windows': - proc = procrun(["cl.exe", "test/twinpages/test.c", "-o", "test/test_build/testtwinpages.exe"]) - proc = procrun(["test/test_build/testtwinpages.exe", "attemptbadwrite"]) - self.assertEqual(proc.returncode, 42, f"Twin pages test failed!") - else: - proc = procrun(["clang", "test/twinpages/test.c", "-o", "test/test_build/testtwinpages"]) - proc = procrun(["test/test_build/testtwinpages", "attemptbadwrite"]) - self.assertEqual(proc.returncode, 42, f"Twin pages test failed!") - - def test_assist_addret(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/addret.vale"], "assist", 7) - def test_assist_add64ret(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/add64ret.vale"], "assist", 42) - def test_assist_floatarithmetic(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/floatarithmetic.vale"], "assist", 42) - def test_assist_floateq(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/floateq.vale"], "assist", 42) - def test_assist_concatstrfloat(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/concatstrfloat.vale"], "assist", 42) - - def test_resilientv4_tether(self) -> None: - self.compile_and_execute_and_expect_return_code(["test/tether.vale"], "resilient-v4", 0) - def test_resilientv4_tethercrash(self) -> None: - self.compile_and_execute_and_expect_return_code(["test/tethercrash.vale"], "resilient-v4", 11) - - def test_assist_mutswaplocals(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/mutswaplocals.vale"], "assist", 42) - def test_unsafefast_mutswaplocals(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/mutswaplocals.vale"], "unsafe-fast", 42) - def test_resilientv4_mutswaplocals(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/mutswaplocals.vale"], "resilient-v4", 42) - def test_resilientv3_mutswaplocals(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/mutswaplocals.vale"], "resilient-v3", 42) - def test_naiverc_mutswaplocals(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/mutswaplocals.vale"], "naive-rc", 42) - - def test_assist_rsamutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsamutreturnexport"], "assist", 42) - def test_unsafefast_rsamutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsamutreturnexport"], "unsafe-fast", 42) - def test_resilientv4_rsamutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsamutreturnexport"], "resilient-v4", 42) - def test_resilientv3_rsamutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsamutreturnexport"], "resilient-v3", 42) - # def test_naiverc_rsamutreturnexport(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsamutreturnexport"], "naive-rc", 42) - - def test_assist_ssamutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssamutreturnexport"], "assist", 42) - def test_unsafefast_ssamutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssamutreturnexport"], "unsafe-fast", 42) - def test_resilientv4_ssamutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssamutreturnexport"], "resilient-v4", 42) - def test_resilientv3_ssamutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssamutreturnexport"], "resilient-v3", 42) - # def test_naiverc_ssamutreturnexport(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssamutreturnexport"], "naive-rc", 42) - - def test_assist_structimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structimm.vale"], "assist", 5) - def test_unsafefast_structimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structimm.vale"], "unsafe-fast", 5) - def test_resilientv4_structimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structimm.vale"], "resilient-v4", 5) - def test_resilientv3_structimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structimm.vale"], "resilient-v3", 5) - def test_naiverc_structimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structimm.vale"], "naive-rc", 5) - - def test_assist_memberrefcount(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/memberrefcount.vale"], "assist", 5) - def test_unsafefast_memberrefcount(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/memberrefcount.vale"], "unsafe-fast", 5) - def test_resilientv4_memberrefcount(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/memberrefcount.vale"], "resilient-v4", 5) - def test_resilientv3_memberrefcount(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/memberrefcount.vale"], "resilient-v3", 5) - def test_naiverc_memberrefcount(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/memberrefcount.vale"], "naive-rc", 5) - - def test_assist_bigstructimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/bigstructimm.vale"], "assist", 42) - def test_unsafefast_bigstructimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/bigstructimm.vale"], "unsafe-fast", 42) - def test_resilientv4_bigstructimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/bigstructimm.vale"], "resilient-v4", 42) - def test_resilientv3_bigstructimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/bigstructimm.vale"], "resilient-v3", 42) - def test_naiverc_bigstructimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/bigstructimm.vale"], "naive-rc", 42) - - def test_assist_structmut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmut.vale"], "assist", 8) - def test_unsafefast_structmut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmut.vale"], "unsafe-fast", 8) - def test_resilientv4_structmut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmut.vale"], "resilient-v4", 8) - def test_resilientv3_structmut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmut.vale"], "resilient-v3", 8) - def test_naiverc_structmut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmut.vale"], "naive-rc", 8) - - def test_assist_lambda(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/lambdas/lambda.vale"], "assist", 42) - def test_unsafefast_lambda(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/lambdas/lambda.vale"], "unsafe-fast", 42) - def test_resilientv4_lambda(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/lambdas/lambda.vale"], "resilient-v4", 42) - def test_resilientv3_lambda(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/lambdas/lambda.vale"], "resilient-v3", 42) - def test_naiverc_lambda(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/lambdas/lambda.vale"], "naive-rc", 42) - - def test_assist_if(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/if.vale"], "assist", 42) - def test_unsafefast_if(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/if.vale"], "unsafe-fast", 42) - def test_resilientv4_if(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/if.vale"], "resilient-v4", 42) - def test_resilientv3_if(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/if.vale"], "resilient-v3", 42) - def test_naiverc_if(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/if.vale"], "naive-rc", 42) - - def test_assist_upcastif(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/upcastif.vale"], "assist", 42) - def test_unsafefast_upcastif(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/upcastif.vale"], "unsafe-fast", 42) - def test_resilientv4_upcastif(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/upcastif.vale"], "resilient-v4", 42) - def test_resilientv3_upcastif(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/upcastif.vale"], "resilient-v3", 42) - def test_naiverc_upcastif(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/upcastif.vale"], "naive-rc", 42) - - def test_assist_ifnevers(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/ifnevers.vale"], "assist", 42) - def test_unsafefast_ifnevers(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/ifnevers.vale"], "unsafe-fast", 42) - def test_resilientv4_ifnevers(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/ifnevers.vale"], "resilient-v4", 42) - def test_resilientv3_ifnevers(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/ifnevers.vale"], "resilient-v3", 42) - def test_naiverc_ifnevers(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/ifnevers.vale"], "naive-rc", 42) - - def test_assist_mutlocal(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/mutlocal.vale"], "assist", 42) - def test_unsafefast_mutlocal(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/mutlocal.vale"], "unsafe-fast", 42) - def test_resilientv4_mutlocal(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/mutlocal.vale"], "resilient-v4", 42) - def test_resilientv3_mutlocal(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/mutlocal.vale"], "resilient-v3", 42) - def test_naiverc_mutlocal(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/mutlocal.vale"], "naive-rc", 42) - - def test_assist_while(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/while/while.vale"], "assist", 42) - def test_unsafefast_while(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/while/while.vale"], "unsafe-fast", 42) - def test_resilientv4_while(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/while/while.vale"], "resilient-v4", 42) - def test_resilientv3_while(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/while/while.vale"], "resilient-v3", 42) - def test_naiverc_while(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/while/while.vale"], "naive-rc", 42) - - def test_assist_constraintRef(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/constraintRef.vale"], "assist", 8) - def test_unsafefast_constraintRef(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/constraintRef.vale"], "unsafe-fast", 8) - def test_resilientv4_constraintRef(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/constraintRef.vale"], "resilient-v4", 8) - def test_resilientv3_constraintRef(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/constraintRef.vale"], "resilient-v3", 8) - def test_naiverc_constraintRef(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/constraintRef.vale"], "naive-rc", 8) - - def test_assist_ssamutfromcallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutfromcallable.vale"], "assist", 42) - def test_unsafefast_ssamutfromcallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutfromcallable.vale"], "unsafe-fast", 42) - def test_resilientv4_ssamutfromcallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutfromcallable.vale"], "resilient-v4", 42) - def test_resilientv3_ssamutfromcallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutfromcallable.vale"], "resilient-v3", 42) - def test_naiverc_ssamutfromcallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutfromcallable.vale"], "naive-rc", 42) - - def test_assist_ssamutfromvalues(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutfromvalues.vale"], "assist", 42) - def test_unsafefast_ssamutfromvalues(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutfromvalues.vale"], "unsafe-fast", 42) - def test_resilientv4_ssamutfromvalues(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutfromvalues.vale"], "resilient-v4", 42) - def test_resilientv3_ssamutfromvalues(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutfromvalues.vale"], "resilient-v3", 42) - def test_naiverc_ssamutfromvalues(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutfromvalues.vale"], "naive-rc", 42) - - def test_assist_interfaceimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/virtuals/interfaceimm.vale"], "assist", 42) - def test_unsafefast_interfaceimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/virtuals/interfaceimm.vale"], "unsafe-fast", 42) - def test_resilientv4_interfaceimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/virtuals/interfaceimm.vale"], "resilient-v4", 42) - def test_resilientv3_interfaceimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/virtuals/interfaceimm.vale"], "resilient-v3", 42) - def test_naiverc_interfaceimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/virtuals/interfaceimm.vale"], "naive-rc", 42) - - def test_assist_interfacemut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/virtuals/interfacemut.vale"], "assist", 42) - def test_unsafefast_interfacemut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/virtuals/interfacemut.vale"], "unsafe-fast", 42) - def test_resilientv4_interfacemut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/virtuals/interfacemut.vale"], "resilient-v4", 42) - def test_resilientv3_interfacemut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/virtuals/interfacemut.vale"], "resilient-v3", 42) - def test_naiverc_interfacemut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/virtuals/interfacemut.vale"], "naive-rc", 42) - - def test_assist_structmutstore(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmutstore.vale"], "assist", 42) - def test_unsafefast_structmutstore(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmutstore.vale"], "unsafe-fast", 42) - def test_resilientv4_structmutstore(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmutstore.vale"], "resilient-v4", 42) - def test_resilientv3_structmutstore(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmutstore.vale"], "resilient-v3", 42) - def test_naiverc_structmutstore(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmutstore.vale"], "naive-rc", 42) - - def test_assist_structmutstoreinner(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmutstoreinner.vale"], "assist", 42) - def test_unsafefast_structmutstoreinner(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmutstoreinner.vale"], "unsafe-fast", 42) - def test_resilientv4_structmutstoreinner(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmutstoreinner.vale"], "resilient-v4", 42) - def test_resilientv3_structmutstoreinner(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmutstoreinner.vale"], "resilient-v3", 42) - def test_naiverc_structmutstoreinner(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/structs/structmutstoreinner.vale"], "naive-rc", 42) - - def test_assist_rsaimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsaimm.vale"], "assist", 3) - def test_unsafefast_rsaimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsaimm.vale"], "unsafe-fast", 3) - def test_resilientv4_rsaimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsaimm.vale"], "resilient-v4", 3) - def test_resilientv3_rsaimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsaimm.vale"], "resilient-v3", 3) - def test_naiverc_rsaimm(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsaimm.vale"], "naive-rc", 3) - - def test_assist_rsamut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamut.vale"], "assist", 3) - def test_unsafefast_rsamut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamut.vale"], "unsafe-fast", 3) - def test_resilientv4_rsamut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamut.vale"], "resilient-v4", 3) - def test_resilientv3_rsamut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamut.vale"], "resilient-v3", 3) - def test_naiverc_rsamut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamut.vale"], "naive-rc", 3) - - def test_assist_rsamutdestroyintocallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamutdestroyintocallable.vale"], "assist", 42) - def test_unsafefast_rsamutdestroyintocallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamutdestroyintocallable.vale"], "unsafe-fast", 42) - def test_resilientv4_rsamutdestroyintocallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamutdestroyintocallable.vale"], "resilient-v4", 42) - def test_resilientv3_rsamutdestroyintocallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamutdestroyintocallable.vale"], "resilient-v3", 42) - def test_naiverc_rsamutdestroyintocallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamutdestroyintocallable.vale"], "naive-rc", 42) - - def test_assist_ssamutdestroyintocallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutdestroyintocallable.vale"], "assist", 42) - def test_unsafefast_ssamutdestroyintocallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutdestroyintocallable.vale"], "unsafe-fast", 42) - def test_resilientv4_ssamutdestroyintocallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutdestroyintocallable.vale"], "resilient-v4", 42) - def test_resilientv3_ssamutdestroyintocallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutdestroyintocallable.vale"], "resilient-v3", 42) - def test_naiverc_ssamutdestroyintocallable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/ssamutdestroyintocallable.vale"], "naive-rc", 42) - - def test_assist_interfacemutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfacemutreturnexport"], "assist", 42) - def test_unsafefast_interfacemutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfacemutreturnexport"], "unsafe-fast", 42) - def test_resilientv4_interfacemutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfacemutreturnexport"], "resilient-v4", 42) - def test_resilientv3_interfacemutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfacemutreturnexport"], "resilient-v3", 42) - # def test_naiverc_interfacemutreturnexport(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfacemutreturnexport"], "naive-rc", 42) - - def test_assist_interfacemutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfacemutparamexport"], "assist", 42) - def test_unsafefast_interfacemutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfacemutparamexport"], "unsafe-fast", 42) - def test_resilientv4_interfacemutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfacemutparamexport"], "resilient-v4", 42) - def test_resilientv3_interfacemutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfacemutparamexport"], "resilient-v3", 42) - # def test_naiverc_interfacemutparamexport(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfacemutparamexport"], "naive-rc", 42) - - def test_assist_structmutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structmutreturnexport"], "assist", 42) - def test_unsafefast_structmutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structmutreturnexport"], "unsafe-fast", 42) - def test_resilientv4_structmutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structmutreturnexport"], "resilient-v4", 42) - def test_resilientv3_structmutreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structmutreturnexport"], "resilient-v3", 42) - # def test_naiverc_structmutreturnexport(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structmutreturnexport"], "naive-rc", 42) - - def test_assist_structmutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structmutparamexport"], "assist", 42) - def test_unsafefast_structmutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structmutparamexport"], "unsafe-fast", 42) - def test_resilientv4_structmutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structmutparamexport"], "resilient-v4", 42) - def test_resilientv3_structmutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structmutparamexport"], "resilient-v3", 42) - # def test_naiverc_structmutparamexport(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/structmutparamexport"], "naive-rc", 42) - - def test_assist_rsamutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsamutparamexport"], "assist", 10) - def test_unsafefast_rsamutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsamutparamexport"], "unsafe-fast", 10) - def test_resilientv4_rsamutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsamutparamexport"], "resilient-v4", 10) - def test_resilientv3_rsamutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsamutparamexport"], "resilient-v3", 10) - # def test_naiverc_rsamutparamexport(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/rsamutparamexport"], "naive-rc", 10) - - def test_assist_ssamutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssamutparamexport"], "assist", 10) - def test_unsafefast_ssamutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssamutparamexport"], "unsafe-fast", 10) - def test_resilientv4_ssamutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssamutparamexport"], "resilient-v4", 10) - def test_resilientv3_ssamutparamexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssamutparamexport"], "resilient-v3", 10) - # def test_naiverc_ssamutparamexport(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/ssamutparamexport"], "naive-rc", 10) - - def test_assist_rsamutlen(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamutlen.vale"], "assist", 5) - def test_unsafefast_rsamutlen(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamutlen.vale"], "unsafe-fast", 5) - def test_resilientv4_rsamutlen(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamutlen.vale"], "resilient-v4", 5) - def test_resilientv3_rsamutlen(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamutlen.vale"], "resilient-v3", 5) - def test_naiverc_rsamutlen(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/rsamutlen.vale"], "naive-rc", 5) - - def test_assist_stradd(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/stradd.vale"], "assist", 42) - def test_unsafefast_stradd(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/stradd.vale"], "unsafe-fast", 42) - def test_resilientv4_stradd(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/stradd.vale"], "resilient-v4", 42) - def test_resilientv3_stradd(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/stradd.vale"], "resilient-v3", 42) - def test_naiverc_stradd(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/stradd.vale"], "naive-rc", 42) - - def test_assist_strneq(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strneq.vale"], "assist", 42) - def test_unsafefast_strneq(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strneq.vale"], "unsafe-fast", 42) - def test_resilientv4_strneq(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strneq.vale"], "resilient-v4", 42) - def test_resilientv3_strneq(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strneq.vale"], "resilient-v3", 42) - def test_naiverc_strneq(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strneq.vale"], "naive-rc", 42) - - def test_assist_lambdamut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/lambdas/lambdamut.vale"], "assist", 42) - def test_unsafefast_lambdamut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/lambdas/lambdamut.vale"], "unsafe-fast", 42) - def test_resilientv4_lambdamut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/lambdas/lambdamut.vale"], "resilient-v4", 42) - def test_resilientv3_lambdamut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/lambdas/lambdamut.vale"], "resilient-v3", 42) - def test_naiverc_lambdamut(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/lambdas/lambdamut.vale"], "naive-rc", 42) - - def test_assist_strprint(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strprint.vale"], "assist", 42) - def test_unsafefast_strprint(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strprint.vale"], "unsafe-fast", 42) - def test_resilientv4_strprint(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strprint.vale"], "resilient-v4", 42) - def test_resilientv3_strprint(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strprint.vale"], "resilient-v3", 42) - def test_naiverc_strprint(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strprint.vale"], "naive-rc", 42) - - def test_assist_inttostr(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/inttostr.vale"], "assist", 4) - def test_unsafefast_inttostr(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/inttostr.vale"], "unsafe-fast", 4) - def test_resilientv4_inttostr(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/inttostr.vale"], "resilient-v4", 4) - def test_resilientv3_inttostr(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/inttostr.vale"], "resilient-v3", 4) - def test_naiverc_inttostr(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/inttostr.vale"], "naive-rc", 4) - - def test_assist_nestedif(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/nestedif.vale"], "assist", 42) - def test_unsafefast_nestedif(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/nestedif.vale"], "unsafe-fast", 42) - def test_resilientv4_nestedif(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/nestedif.vale"], "resilient-v4", 42) - def test_resilientv3_nestedif(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/nestedif.vale"], "resilient-v3", 42) - def test_naiverc_nestedif(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/nestedif.vale"], "naive-rc", 42) - - def test_assist_unstackifyret(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/unstackifyret.vale"], "assist", 42) - def test_unsafefast_unstackifyret(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/unstackifyret.vale"], "unsafe-fast", 42) - def test_resilientv4_unstackifyret(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/unstackifyret.vale"], "resilient-v4", 42) - def test_resilientv3_unstackifyret(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/unstackifyret.vale"], "resilient-v3", 42) - def test_naiverc_unstackifyret(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/unstackifyret.vale"], "naive-rc", 42) - - def test_assist_swaprsamutdestroy(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/swaprsamutdestroy.vale"], "assist", 42) - def test_unsafefast_swaprsamutdestroy(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/swaprsamutdestroy.vale"], "unsafe-fast", 42) - def test_resilientv4_swaprsamutdestroy(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/swaprsamutdestroy.vale"], "resilient-v4", 42) - def test_resilientv3_swaprsamutdestroy(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/swaprsamutdestroy.vale"], "resilient-v3", 42) - def test_naiverc_swaprsamutdestroy(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/arrays/swaprsamutdestroy.vale"], "naive-rc", 42) - - def test_assist_downcastConstraintSuccessful(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastConstraintSuccessful.vale"], "assist", 42) - def test_unsafefast_downcastConstraintSuccessful(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastConstraintSuccessful.vale"], "unsafe-fast", 42) - def test_resilientv4_downcastConstraintSuccessful(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastConstraintSuccessful.vale"], "resilient-v4", 42) - def test_resilientv3_downcastConstraintSuccessful(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastConstraintSuccessful.vale"], "resilient-v3", 42) - def test_naiverc_downcastConstraintSuccessful(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastConstraintSuccessful.vale"], "naive-rc", 42) - - def test_assist_downcastConstraintFailed(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastConstraintFailed.vale"], "assist", 42) - def test_unsafefast_downcastConstraintFailed(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastConstraintFailed.vale"], "unsafe-fast", 42) - def test_resilientv4_downcastConstraintFailed(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastConstraintFailed.vale"], "resilient-v4", 42) - def test_resilientv3_downcastConstraintFailed(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastConstraintFailed.vale"], "resilient-v3", 42) - def test_naiverc_downcastConstraintFailed(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastConstraintFailed.vale"], "naive-rc", 42) - - def test_assist_downcastOwningSuccessful(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastOwningSuccessful.vale"], "assist", 42) - def test_unsafefast_downcastOwningSuccessful(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastOwningSuccessful.vale"], "unsafe-fast", 42) - def test_resilientv4_downcastOwningSuccessful(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastOwningSuccessful.vale"], "resilient-v4", 42) - def test_resilientv3_downcastOwningSuccessful(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastOwningSuccessful.vale"], "resilient-v3", 42) - def test_naiverc_downcastOwningSuccessful(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastOwningSuccessful.vale"], "naive-rc", 42) - - def test_assist_downcastOwningFailed(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastOwningFailed.vale"], "assist", 42) - def test_unsafefast_downcastOwningFailed(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastOwningFailed.vale"], "unsafe-fast", 42) - def test_resilientv4_downcastOwningFailed(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastOwningFailed.vale"], "resilient-v4", 42) - def test_resilientv3_downcastOwningFailed(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastOwningFailed.vale"], "resilient-v3", 42) - def test_naiverc_downcastOwningFailed(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/downcast/downcastOwningFailed.vale"], "naive-rc", 42) - - def test_assist_unreachablemoot(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/unreachablemoot.vale"], "assist", 42) - def test_unsafefast_unreachablemoot(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/unreachablemoot.vale"], "unsafe-fast", 42) - def test_resilientv4_unreachablemoot(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/unreachablemoot.vale"], "resilient-v4", 42) - def test_resilientv3_unreachablemoot(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/unreachablemoot.vale"], "resilient-v3", 42) - def test_naiverc_unreachablemoot(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/unreachablemoot.vale"], "naive-rc", 42) - - def test_assist_panic(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/panic.vale"], "assist", 1) - def test_unsafefast_panic(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/panic.vale"], "unsafe-fast", 1) - def test_resilientv4_panic(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/panic.vale"], "resilient-v4", 1) - def test_resilientv3_panic(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/panic.vale"], "resilient-v3", 1) - def test_naiverc_panic(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/panic.vale"], "naive-rc", 1) - - def test_assist_panicnot(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/panicnot.vale"], "assist", 42) - def test_unsafefast_panicnot(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/panicnot.vale"], "unsafe-fast", 42) - def test_resilientv4_panicnot(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/panicnot.vale"], "resilient-v4", 42) - def test_resilientv3_panicnot(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/panicnot.vale"], "resilient-v3", 42) - def test_naiverc_panicnot(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/panicnot.vale"], "naive-rc", 42) - - def test_assist_nestedblocks(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/nestedblocks.vale"], "assist", 42) - def test_unsafefast_nestedblocks(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/nestedblocks.vale"], "unsafe-fast", 42) - def test_resilientv4_nestedblocks(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/nestedblocks.vale"], "resilient-v4", 42) - def test_resilientv3_nestedblocks(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/nestedblocks.vale"], "resilient-v3", 42) - def test_naiverc_nestedblocks(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/nestedblocks.vale"], "naive-rc", 42) - - def test_assist_weakDropThenLockStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/dropThenLockStruct.vale"], "assist", 42) - def test_unsafefast_weakDropThenLockStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/dropThenLockStruct.vale"], "unsafe-fast", 42) - def test_resilientv4_weakDropThenLockStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/dropThenLockStruct.vale"], "resilient-v4", 42) - def test_resilientv3_weakDropThenLockStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/dropThenLockStruct.vale"], "resilient-v3", 42) - def test_naiverc_weakDropThenLockStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/dropThenLockStruct.vale"], "naive-rc", 42) - - def test_assist_weakLockWhileLiveStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/lockWhileLiveStruct.vale"], "assist", 7) - def test_unsafefast_weakLockWhileLiveStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/lockWhileLiveStruct.vale"], "unsafe-fast", 7) - def test_resilientv4_weakLockWhileLiveStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/lockWhileLiveStruct.vale"], "resilient-v4", 7) - def test_resilientv3_weakLockWhileLiveStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/lockWhileLiveStruct.vale"], "resilient-v3", 7) - def test_naiverc_weakLockWhileLiveStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/lockWhileLiveStruct.vale"], "naive-rc", 7) - - def test_assist_weakFromLocalCRefStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromLocalCRefStruct.vale"], "assist", 7) - def test_unsafefast_weakFromLocalCRefStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromLocalCRefStruct.vale"], "unsafe-fast", 7) - def test_resilientv4_weakFromLocalCRefStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromLocalCRefStruct.vale"], "resilient-v4", 7) - def test_resilientv3_weakFromLocalCRefStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromLocalCRefStruct.vale"], "resilient-v3", 7) - def test_naiverc_weakFromLocalCRefStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromLocalCRefStruct.vale"], "naive-rc", 7) - - def test_assist_weakFromCRefStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromCRefStruct.vale"], "assist", 7) - def test_unsafefast_weakFromCRefStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromCRefStruct.vale"], "unsafe-fast", 7) - def test_resilientv4_weakFromCRefStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromCRefStruct.vale"], "resilient-v4", 7) - def test_resilientv3_weakFromCRefStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromCRefStruct.vale"], "resilient-v3", 7) - def test_naiverc_weakFromCRefStruct(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromCRefStruct.vale"], "naive-rc", 7) - - def test_assist_loadFromWeakable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/loadFromWeakable.vale"], "assist", 7) - def test_unsafefast_loadFromWeakable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/loadFromWeakable.vale"], "unsafe-fast", 7) - def test_resilientv4_loadFromWeakable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/loadFromWeakable.vale"], "resilient-v4", 7) - def test_resilientv3_loadFromWeakable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/loadFromWeakable.vale"], "resilient-v3", 7) - def test_naiverc_loadFromWeakable(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/loadFromWeakable.vale"], "naive-rc", 7) - - def test_assist_weakDropThenLockInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/dropThenLockInterface.vale"], "assist", 42) - def test_unsafefast_weakDropThenLockInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/dropThenLockInterface.vale"], "unsafe-fast", 42) - def test_resilientv4_weakDropThenLockInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/dropThenLockInterface.vale"], "resilient-v4", 42) - def test_resilientv3_weakDropThenLockInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/dropThenLockInterface.vale"], "resilient-v3", 42) - def test_naiverc_weakDropThenLockInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/dropThenLockInterface.vale"], "naive-rc", 42) - - def test_assist_weakLockWhileLiveInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/lockWhileLiveInterface.vale"], "assist", 7) - def test_unsafefast_weakLockWhileLiveInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/lockWhileLiveInterface.vale"], "unsafe-fast", 7) - def test_resilientv4_weakLockWhileLiveInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/lockWhileLiveInterface.vale"], "resilient-v4", 7) - def test_resilientv3_weakLockWhileLiveInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/lockWhileLiveInterface.vale"], "resilient-v3", 7) - def test_naiverc_weakLockWhileLiveInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/lockWhileLiveInterface.vale"], "naive-rc", 7) - - def test_assist_weakFromLocalCRefInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromLocalCRefInterface.vale"], "assist", 7) - def test_unsafefast_weakFromLocalCRefInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromLocalCRefInterface.vale"], "unsafe-fast", 7) - def test_resilientv4_weakFromLocalCRefInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromLocalCRefInterface.vale"], "resilient-v4", 7) - def test_resilientv3_weakFromLocalCRefInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromLocalCRefInterface.vale"], "resilient-v3", 7) - def test_naiverc_weakFromLocalCRefInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromLocalCRefInterface.vale"], "naive-rc", 7) - - def test_assist_weakFromCRefInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromCRefInterface.vale"], "assist", 7) - def test_unsafefast_weakFromCRefInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromCRefInterface.vale"], "unsafe-fast", 7) - def test_resilientv4_weakFromCRefInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromCRefInterface.vale"], "resilient-v4", 7) - def test_resilientv3_weakFromCRefInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromCRefInterface.vale"], "resilient-v3", 7) - def test_naiverc_weakFromCRefInterface(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/weakFromCRefInterface.vale"], "naive-rc", 7) - - def test_assist_weakSelfMethodCallWhileLive(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/callWeakSelfMethodWhileLive.vale"], "assist", 42) - def test_unsafefast_weakSelfMethodCallWhileLive(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/callWeakSelfMethodWhileLive.vale"], "unsafe-fast", 42) - def test_resilientv4_weakSelfMethodCallWhileLive(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/callWeakSelfMethodWhileLive.vale"], "resilient-v4", 42) - def test_resilientv3_weakSelfMethodCallWhileLive(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/callWeakSelfMethodWhileLive.vale"], "resilient-v3", 42) - def test_naiverc_weakSelfMethodCallWhileLive(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/callWeakSelfMethodWhileLive.vale"], "naive-rc", 42) - - def test_assist_weakSelfMethodCallAfterDrop(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/callWeakSelfMethodAfterDrop.vale"], "assist", 0) - def test_unsafefast_weakSelfMethodCallAfterDrop(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/callWeakSelfMethodAfterDrop.vale"], "unsafe-fast", 0) - def test_resilientv4_weakSelfMethodCallAfterDrop(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/callWeakSelfMethodAfterDrop.vale"], "resilient-v4", 0) - def test_resilientv3_weakSelfMethodCallAfterDrop(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/callWeakSelfMethodAfterDrop.vale"], "resilient-v3", 0) - def test_naiverc_weakSelfMethodCallAfterDrop(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/weaks/callWeakSelfMethodAfterDrop.vale"], "naive-rc", 0) - - # def test_assist_tupleretextern(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/tupleretextern"], "assist", 42) - # def test_unsafefast_tupleretextern(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/tupleretextern"], "unsafe-fast", 42) - # def test_resilientv4_tupleretextern(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/tupleretextern"], "resilient-v4", 42) - # def test_resilientv3_tupleretextern(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/tupleretextern"], "resilient-v3", 42) - # def test_naiverc_tupleretextern(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/tupleretextern"], "naive-rc", 42) - - - - - - def test_assist_interfaceimmreturnextern(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmreturnextern"], "assist", 42) - # def test_unsafefast_interfaceimmreturnextern(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmreturnextern"], "unsafe-fast", 42) - def test_resilientv4_interfaceimmreturnextern(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmreturnextern"], "resilient-v4", 42) - def test_resilientv3_interfaceimmreturnextern(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmreturnextern"], "resilient-v3", 42) - # def test_naiverc_interfaceimmreturnextern(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmreturnextern"], "naive-rc", 42) - - def test_assist_interfaceimmreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmreturnexport"], "assist", 42) - # def test_unsafefast_interfaceimmreturnexport(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmreturnexport"], "unsafe-fast", 42) - def test_resilientv4_interfaceimmreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmreturnexport"], "resilient-v4", 42) - def test_resilientv3_interfaceimmreturnexport(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmreturnexport"], "resilient-v3", 42) - # def test_naiverc_interfaceimmreturnexport(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/interfaceimmreturnexport"], "naive-rc", 42) - - - - def test_assist_strlen(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strlen.vale"], "assist", 12) - def test_unsafefast_strlen(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strlen.vale"], "unsafe-fast", 12) - def test_resilientv4_strlen(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strlen.vale"], "resilient-v4", 12) - def test_resilientv3_strlen(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strlen.vale"], "resilient-v3", 12) - def test_naiverc_strlen(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/strings/strlen.vale"], "naive-rc", 12) - - # no assist test: Cant get an invalid access in assist mode, a constraint ref catches it first - # no unsafe test: It's undefined behavior, so we can't test it reliably - def test_resilientv4_invalidaccess(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/invalidaccess.vale"], "resilient-v4", 11) - def test_resilientv3_invalidaccess(self) -> None: - self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/invalidaccess.vale"], "resilient-v3", 11) - # def test_naiverc_invalidaccess(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/invalidaccess.vale"], "naive-rc", 255) - - # def test_assist_neverif(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/neverif.vale"], "assist", 42) - # def test_unsafefast_neverif(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/neverif.vale"], "unsafe-fast", 42) - # def test_resilientv4_neverif(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/neverif.vale"], "resilient-v4", 42) - # def test_resilientv3_neverif(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/neverif.vale"], "resilient-v3", 42) - # def test_naiverc_neverif(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/if/neverif.vale"], "naive-rc", 42) - - # def test_assist_tupleparamextern(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/tupleparamextern"], "assist", 42) - # def test_unsafefast_tupleparamextern(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/tupleparamextern"], "unsafe-fast", 42) - # def test_resilientv4_tupleparamextern(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/tupleparamextern"], "resilient-v4", 42) - # def test_resilientv3_tupleparamextern(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/tupleparamextern"], "resilient-v3", 42) - # def test_naiverc_tupleparamextern(self) -> None: - # self.compile_and_execute_and_expect_return_code([PATH_TO_SAMPLES + "programs/externs/tupleparamextern"], "naive-rc", 42) - - -if __name__ == '__main__': - unittest.main() diff --git a/Tester/src/main.vale b/Tester/src/main.vale index e0a024784..d92793ba9 100644 --- a/Tester/src/main.vale +++ b/Tester/src/main.vale @@ -223,8 +223,7 @@ fn main() int export { if (include_regions.exists({ _ == "resilient-v4" })) { region = "resilient-v4"; - suite!.StartTest(0, "tether", midas_tests_dir./("tether.vale"), &List(), region); - suite!.StartTest(11, "tethercrash", midas_tests_dir./("tethercrash.vale"), &List(), region); + suite!.StartTest(14, "tethercrash", midas_tests_dir./("tethercrash.vale"), &List(), region); } include_regions.each((region){ @@ -294,7 +293,7 @@ fn main() int export { }); if (include_regions.exists({ _ == "resilient-v3" }) or include_regions.exists({ _ == "resilient-v4" })) { - suite!.StartCTest("twinpages", &midas_tests_dir./("twinpages/test.c"), List([]["noattemptbadwrite"]), "resilient-v3"); + // suite!.StartCTest("twinpages", &midas_tests_dir./("twinpages/test.c"), List([]["noattemptbadwrite"]), "resilient-v3"); } suite!.FinishTests(0); @@ -326,7 +325,9 @@ fn StartCTest(suite &!TestSuite, test_name str, input_c &Path, flags List, "-o", test_build_dir./("main").str() ]))).expect(); - // println(process.command); + if (suite.verbose) { + println("Running command: " + process.command); + } suite.test_instances!.add( TestInstance(test_name, region, 0, test_build_dir, process, flags)); } else { @@ -345,10 +346,14 @@ fn FinishTests(suite &!TestSuite, until_this_many_left int) { if (build_result.stdout.len() > 0) { println("stdout:"); println(build_result.stdout); + } else { + println("(no stdout)"); } if (build_result.stderr.len() > 0) { println("stderr:"); println(build_result.stderr); + } else { + println("(no stderr)"); } set suite.num_failures = suite.num_failures + 1; } else { @@ -356,16 +361,23 @@ fn FinishTests(suite &!TestSuite, until_this_many_left int) { run_program = test_build_dir./(program_name).str(); run_process = (Subprocess(run_program, &run_args)).expect(); + if (suite.verbose) { + println("Running command: " + run_process.command); + } run_result = (run_process).capture_and_join(); if (run_result.return_code != expected_return_code) { println("Invalid result for test {test_name} (region {region}). Expected {expected_return_code} but got {run_result.return_code}."); if (run_result.stdout.len() > 0) { println("stdout:"); println(run_result.stdout); + } else { + println("(no stdout)"); } if (run_result.stderr.len() > 0) { println("stderr:"); println(run_result.stderr); + } else { + println("(no stderr)"); } set suite.num_failures = suite.num_failures + 1; } else { @@ -403,7 +415,9 @@ Subprocess { } build_process = (Subprocess(suite.valec_path, &build_args)).expect(); - //println("Build command: " + build_process.command); + if (suite.verbose) { + println("Build command: " + build_process.command); + } ret build_process; }