diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-12-10 12:42:15 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-10 12:42:15 -0800 |
| commit | b2997170df7cc2703de714a946a38dc35058e7f8 (patch) | |
| tree | bbd19208ba07a2f45a2c25f28f6cf77be16f0b49 /tools | |
| parent | 32f57c30cfce1681f5fe617e4fe230e88eb7b840 (diff) | |
Remove the "VM" and "bytecode" features (#745)
* Remove the "VM" and "bytecode" features
The "bytecode" in `bc.{h,cpp}` was an initial attempt at a serialized encoding for the Slang IR, but we now have the `ir-serialize.{h,cpp}` approach which was has been kept up to date much better.
Similarly, the "VM" in `vm.{h,cpp}` was intended to be a system for interpreting Slang code in the bytecode format directly (so that you could load and evaluate code in a Slang module in a lightweight fashion). This never got used past a single test, which we eventually disabled.
There are good ideas in some of this code, but at this point the implementations have bit-rotted to a point where trying to maintain it is more costly than it would be to re-created it if/when we ever decide these features are important again.
* fixup: remove slang-eval-test from Makefile
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/slang-eval-test/main.cpp | 139 | ||||
| -rw-r--r-- | tools/slang-eval-test/slang-eval-test.vcxproj | 178 | ||||
| -rw-r--r-- | tools/slang-eval-test/slang-eval-test.vcxproj.filters | 13 | ||||
| -rw-r--r-- | tools/slang-test/main.cpp | 48 |
4 files changed, 0 insertions, 378 deletions
diff --git a/tools/slang-eval-test/main.cpp b/tools/slang-eval-test/main.cpp deleted file mode 100644 index ff2ebed34..000000000 --- a/tools/slang-eval-test/main.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// main.cpp - -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#include "../../source/core/secure-crt.h" -#include <slang.h> - -static SlangResult innerMain(int argc, char*const* argv) -{ - // TODO: parse arguments - - assert(argc >= 2); - char const* inputPath = argv[1]; - - // Slurp in the input file, so that we can compile and run it - FILE* inputFile; - fopen_s(&inputFile, inputPath, "rb"); - assert(inputFile); - - fseek(inputFile, 0, SEEK_END); - size_t inputSize = ftell(inputFile); - fseek(inputFile, 0, SEEK_SET); - - char* inputText = (char*)malloc(inputSize + 1); - fread(inputText, inputSize, 1, inputFile); - inputText[inputSize] = 0; - fclose(inputFile); - - // TODO: scan through the text to find comments, - // that instruct us how to generate input and - // consume output when running the test. - - // - - SlangSession* session = spCreateSession(nullptr); - SlangCompileRequest* request = spCreateCompileRequest(session); - - spSetOutputContainerFormat( - request, - SLANG_CONTAINER_FORMAT_SLANG_MODULE); - - int translationUnitIndex = spAddTranslationUnit( - request, - SLANG_SOURCE_LANGUAGE_SLANG, - nullptr); - - spAddTranslationUnitSourceString( - request, - translationUnitIndex, - inputPath, - inputText); - - int entryPointIndex = spAddEntryPoint( - request, - translationUnitIndex, - "main", - spFindProfile(session, "cs_5_0")); - - if (SLANG_FAILED(spCompile(request))) - { - char const* output = spGetDiagnosticOutput(request); - fputs(output, stderr); - return SLANG_FAIL; - } - - // Things compiled, so now we need to run them... - - // Extract the bytecode - size_t bytecodeSize = 0; - void const* bytecode = spGetCompileRequestCode(request, &bytecodeSize); - - // Now we need to create an execution context to go and run the bytecode we got - - SlangVM* vm = SlangVM_create(); - - SlangVMModule* vmModule = SlangVMModule_load( - vm, - bytecode, - bytecodeSize); - - SlangVMFunc* vmFunc = (SlangVMFunc*)SlangVMModule_findGlobalSymbolPtr( - vmModule, - "main"); - - int32_t*& inputArg = *(int32_t**)SlangVMModule_findGlobalSymbolPtr( - vmModule, - "input"); - - int32_t*& outputArg = *(int32_t**)SlangVMModule_findGlobalSymbolPtr( - vmModule, - "output"); - - SlangVMThread* vmThread = SlangVMThread_create( - vm); - - int32_t inputData[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; - int32_t outputData[8] = { 0 }; - - inputArg = inputData; - outputArg = outputData; - - // TODO: set arguments based on specification from the user... - for (uint32_t threadID = 0; threadID < 8; ++threadID) - { -#if 0 - fprintf(stderr, "\n\nthreadID = %u\n\n", threadID); - fflush(stderr); -#endif - - SlangVMThread_beginCall(vmThread, vmFunc); - - SlangVMThread_setArg( - vmThread, - 0, - &threadID, - sizeof(threadID)); - - SlangVMThread_resume(vmThread); - } - - for (uint32_t ii = 0; ii < 8; ++ii) - { - fprintf(stdout, "outputData[%u] = %d\n", ii, outputData[ii]); - } - - spDestroyCompileRequest(request); - spDestroySession(session); - - return SLANG_OK; -} - -int main( - int argc, - char** argv) -{ - SlangResult res = innerMain(argc, argv); - return SLANG_FAILED(res) ? 1 : 0; -} diff --git a/tools/slang-eval-test/slang-eval-test.vcxproj b/tools/slang-eval-test/slang-eval-test.vcxproj deleted file mode 100644 index c7b214d4a..000000000 --- a/tools/slang-eval-test/slang-eval-test.vcxproj +++ /dev/null @@ -1,178 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{205FCAB9-A13F-4980-86FA-F6221A7095EE}</ProjectGuid> - <IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename> - <Keyword>Win32Proj</Keyword> - <RootNamespace>slang-eval-test</RootNamespace> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <LinkIncremental>true</LinkIncremental> - <OutDir>..\..\bin\windows-x86\debug\</OutDir> - <IntDir>..\..\intermediate\windows-x86\debug\slang-eval-test\</IntDir> - <TargetName>slang-eval-test</TargetName> - <TargetExt>.exe</TargetExt> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <LinkIncremental>true</LinkIncremental> - <OutDir>..\..\bin\windows-x64\debug\</OutDir> - <IntDir>..\..\intermediate\windows-x64\debug\slang-eval-test\</IntDir> - <TargetName>slang-eval-test</TargetName> - <TargetExt>.exe</TargetExt> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <LinkIncremental>false</LinkIncremental> - <OutDir>..\..\bin\windows-x86\release\</OutDir> - <IntDir>..\..\intermediate\windows-x86\release\slang-eval-test\</IntDir> - <TargetName>slang-eval-test</TargetName> - <TargetExt>.exe</TargetExt> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <LinkIncremental>false</LinkIncremental> - <OutDir>..\..\bin\windows-x64\release\</OutDir> - <IntDir>..\..\intermediate\windows-x64\release\slang-eval-test\</IntDir> - <TargetName>slang-eval-test</TargetName> - <TargetExt>.exe</TargetExt> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <DebugInformationFormat>EditAndContinue</DebugInformationFormat> - <Optimization>Disabled</Optimization> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <ClCompile> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <DebugInformationFormat>EditAndContinue</DebugInformationFormat> - <Optimization>Disabled</Optimization> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <Optimization>Full</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <MinimalRebuild>false</MinimalRebuild> - <StringPooling>true</StringPooling> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <ClCompile> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <Optimization>Full</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <MinimalRebuild>false</MinimalRebuild> - <StringPooling>true</StringPooling> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - </Link> - </ItemDefinitionGroup> - <ItemGroup> - <ClCompile Include="main.cpp" /> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\..\source\core\core.vcxproj"> - <Project>{F9BE7957-8399-899E-0C49-E714FDDD4B65}</Project> - </ProjectReference> - <ProjectReference Include="..\..\source\slang\slang.vcxproj"> - <Project>{DB00DA62-0533-4AFD-B59F-A67D5B3A0808}</Project> - </ProjectReference> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project>
\ No newline at end of file diff --git a/tools/slang-eval-test/slang-eval-test.vcxproj.filters b/tools/slang-eval-test/slang-eval-test.vcxproj.filters deleted file mode 100644 index e9ae1c092..000000000 --- a/tools/slang-eval-test/slang-eval-test.vcxproj.filters +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="Source Files"> - <UniqueIdentifier>{E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6}</UniqueIdentifier> - </Filter> - </ItemGroup> - <ItemGroup> - <ClCompile Include="main.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/tools/slang-test/main.cpp b/tools/slang-test/main.cpp index f710d63f2..943e82cef 100644 --- a/tools/slang-test/main.cpp +++ b/tools/slang-test/main.cpp @@ -853,53 +853,6 @@ String getExpectedOutput(String const& outputStem) return expectedOutput; } -TestResult runEvalTest(TestContext* context, TestInput& input) -{ - // We are going to load and evaluate the code - - auto filePath = input.filePath; - auto outputStem = input.outputStem; - - OSProcessSpawner spawner; - - spawner.pushExecutablePath(String(g_options.binDir) + "slang-eval-test" + osGetExecutableSuffix()); - spawner.pushArgument(filePath); - - for( auto arg : input.testOptions->args ) - { - spawner.pushArgument(arg); - } - - if (spawnAndWait(context, outputStem, spawner) != kOSError_None) - { - return TestResult::Fail; - } - - String actualOutput = getOutput(spawner); - String expectedOutput = getExpectedOutput(outputStem); - - TestResult result = TestResult::Pass; - - // Otherwise we compare to the expected output - if (actualOutput != expectedOutput) - { - result = TestResult::Fail; - } - - // If the test failed, then we write the actual output to a file - // so that we can easily diff it from the command line and - // diagnose the problem. - if (result == TestResult::Fail) - { - String actualOutputPath = outputStem + ".actual"; - Slang::File::WriteAllText(actualOutputPath, actualOutput); - - context->dumpOutputDifference(expectedOutput, actualOutput); - } - - return result; -} - static SlangCompileTarget _getCompileTarget(const UnownedStringSlice& name) { #define CASE(NAME, TARGET) if(name == NAME) return SLANG_##TARGET; @@ -1706,7 +1659,6 @@ TestResult runTest( #endif { "COMPARE_GLSL", &runGLSLComparisonTest }, { "CROSS_COMPILE", &runCrossCompilerTest }, - { "EVAL", &runEvalTest }, { nullptr, nullptr }, }; |
