Kaynağa Gözat

[1.4>master] [MERGE #2253 @Cellule] Fix library bytecode generation

Merge pull request #2253 from Cellule:users/micfer/bytecode

The return value of one of the jsrt call was inverted and thus failed when successful.
Propagate exit code to ch.exe instead of always returning 0.
Added a script to regenerate library bytecode.
Michael Ferris 9 yıl önce
ebeveyn
işleme
07f73827a5
2 değiştirilmiş dosya ile 73 ekleme ve 5 silme
  1. 66 0
      RegenAllByteCode.cmd
  2. 7 5
      bin/ch/ch.cpp

+ 66 - 0
RegenAllByteCode.cmd

@@ -0,0 +1,66 @@
+::-------------------------------------------------------------------------------------------------------
+:: Copyright (C) Microsoft. All rights reserved.
+:: Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+::-------------------------------------------------------------------------------------------------------
+
+:: Regenerate all bytecode.
+:: ch.exe is used to generate Intl bytecodes.
+:: ch.exe (NoJIT variety) is used to generate NoJIT Intl bytecodes.
+:: Each set of bytecode requires an x86_debug and x64_debug binary.
+::
+:: Thus we need to build the following:
+:: [Core]   ch.exe        x64_debug
+:: [Core]   ch.exe        x86_debug
+:: [Core]   ch.exe        x64_debug (NoJIT)
+:: [Core]   ch.exe        x86_debug (NoJIT)
+
+setlocal
+pushd %~dp0
+
+:: ch.exe        x64_debug
+:: ch.exe        x86_debug
+call jenkins\buildone.cmd x64 debug
+if %errorlevel% neq 0 (
+  echo There was a build error for x64 debug. Stopping bytecode generation.
+  exit /b 1
+)
+call jenkins\buildone.cmd x86 debug
+if %errorlevel% neq 0 (
+  echo There was a build error for x86 debug. Stopping bytecode generation.
+  exit /b 1
+)
+
+pushd lib\Runtime\Library\InJavascript
+call GenByteCode.cmd
+if %errorlevel% neq 0 (
+  echo There was an error when regenerating bytecode header.
+  exit /b 1
+)
+popd
+
+:: ch.exe        x64_debug (NoJIT)
+:: ch.exe        x86_debug (NoJIT)
+call jenkins\buildone.cmd x64 debug "/p:BuildJIT=false"
+if %errorlevel% neq 0 (
+  echo There was a build error for x64 debug NoJIT. Stopping bytecode generation.
+  exit /b 1
+)
+
+call jenkins\buildone.cmd x86 debug "/p:BuildJIT=false"
+if %errorlevel% neq 0 (
+  echo There was a build error for x86 debug NoJIT. Stopping bytecode generation.
+  exit /b 1
+)
+
+:: Generate Intl NoJIT Bytecodes using ch.exe (NoJIT)
+pushd lib\Runtime\Library\InJavascript
+call GenByteCode.cmd -nojit
+if %errorlevel% neq 0 (
+  echo There was an error when regenerating bytecode header for NoJIT.
+  exit /b 1
+)
+popd
+
+popd
+
+endlocal

+ 7 - 5
bin/ch/ch.cpp

@@ -113,8 +113,7 @@ HRESULT CreateLibraryByteCodeHeader(LPCSTR contentsRaw, DWORD lengthBytes, LPCWS
 
     if (FAILED(hr)) return hr;
 
-    IfFalseGo(ChakraRTInterface::JsGetArrayBufferStorage(bufferVal, &bcBuffer,
-        &bcBufferSize) != JsNoError);
+    IfJsrtErrorHR(ChakraRTInterface::JsGetArrayBufferStorage(bufferVal, &bcBuffer, &bcBufferSize));
 
     bcFileHandle = CreateFile(bcFullPath, GENERIC_WRITE, FILE_SHARE_DELETE,
         nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
@@ -838,6 +837,7 @@ int _cdecl wmain(int argc, __in_ecount(argc) LPWSTR argv[])
         WideStringToNarrowDynamic(argv[1], &argInfo.filename);
     }
 
+    HRESULT exitCode = E_FAIL;
     if (success)
     {
 #ifdef _WIN32
@@ -849,7 +849,6 @@ int _cdecl wmain(int argc, __in_ecount(argc) LPWSTR argv[])
             ChakraRTInterface::ConnectJITServer(JITProcessManager::GetRpcProccessHandle(), nullptr, JITProcessManager::GetRpcConnectionId());
         }
 #endif
-
         HANDLE threadHandle;
         threadHandle = reinterpret_cast<HANDLE>(_beginthreadex(0, 0, &StaticThreadProc, &argInfo, STACK_SIZE_PARAM_IS_A_RESERVATION, 0));
 
@@ -857,6 +856,9 @@ int _cdecl wmain(int argc, __in_ecount(argc) LPWSTR argv[])
         {
             DWORD waitResult = WaitForSingleObject(threadHandle, INFINITE);
             Assert(waitResult == WAIT_OBJECT_0);
+            DWORD threadExitCode;
+            GetExitCodeThread(threadHandle, &threadExitCode);
+            exitCode = (HRESULT)threadExitCode;
             CloseHandle(threadHandle);
         }
         else
@@ -866,7 +868,7 @@ int _cdecl wmain(int argc, __in_ecount(argc) LPWSTR argv[])
         }
 #else
         // On linux, execute on the same thread
-        ExecuteTestWithMemoryCheck(argInfo.filename);
+        exitCode = ExecuteTestWithMemoryCheck(argInfo.filename);
 #endif
 
 #if ENABLE_NATIVE_CODEGEN && defined(_WIN32)
@@ -882,5 +884,5 @@ int _cdecl wmain(int argc, __in_ecount(argc) LPWSTR argv[])
 #endif
 
     PAL_Shutdown();
-    return 0;
+    return (int)exitCode;
 }