Skip to content

Commit 58232f9

Browse files
committed
CR fixes
1 parent 2f2901f commit 58232f9

4 files changed

Lines changed: 17 additions & 5 deletions

File tree

lib/Common/ConfigFlagsList.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ PHASE(All)
539539
#else
540540
#define DEFAULT_CONFIG_JsBuiltIn (false)
541541
#endif
542-
542+
#define DEFAULT_CONFIG_JitRepro (false)
543543
#define DEFAULT_CONFIG_LdChakraLib (false)
544544

545545
// ES6 DEFAULT BEHAVIOR
@@ -1008,6 +1008,7 @@ FLAGR (Boolean, Intl , "Intl object support", DEFAULT_CONFIG_In
10081008
FLAGNR(Boolean, IntlBuiltIns , "Intl built-in function support", DEFAULT_CONFIG_IntlBuiltIns)
10091009

10101010
FLAGNR(Boolean, JsBuiltIn , "JS Built-in function support", DEFAULT_CONFIG_JsBuiltIn)
1011+
FLAGNR(Boolean, JitRepro , "Add Function.invokeJit to execute codegen on an encoded rpc buffer", DEFAULT_CONFIG_JitRepro)
10111012

10121013
FLAGNR(Boolean, LdChakraLib , "Access to the Chakra internal library with the __chakraLibrary keyword", DEFAULT_CONFIG_LdChakraLib)
10131014
// ES6 (BLUE+1) features/flags

lib/JITClient/JITManager.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,12 @@ JITManager::SerializeRPCData(_In_ CodeGenWorkItemIDL *workItemData, _Out_ size_t
758758
// Calculate how big we need to create the buffer
759759
size_t tmpBufSize = pCodeGenWorkItemIDL_AlignSize(marshalHandle, &workItemData);
760760
size_t alignedBufSize = Math::Align<size_t>(tmpBufSize, 16);
761-
data = new char[alignedBufSize];
761+
data = HeapNewNoThrowArray(char, alignedBufSize);
762+
if (!data)
763+
{
764+
// Ran out of memory
765+
return E_OUTOFMEMORY;
766+
}
762767

763768
// Reset the buffer handle to a fixed buffer
764769
status = MesBufferHandleReset(

lib/JITServer/JITServer.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,11 @@ ServerRemoteCodeGen(
764764
struct AutoFreeArray
765765
{
766766
const byte* arr = nullptr;
767-
~AutoFreeArray() { delete[] arr; }
768-
} autoFreeArray = { serializedRpcData };
767+
size_t bufferSize = 0;
768+
~AutoFreeArray() { HeapDeleteArray(bufferSize, arr); }
769+
} autoFreeArray;
770+
autoFreeArray.arr = serializedRpcData;
771+
autoFreeArray.bufferSize = serializedRpcDataSize;
769772
#endif
770773

771774
return ServerCallWrapper(scriptContextInfo, [&]() ->HRESULT

lib/Runtime/Library/JavascriptLibrary.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2758,7 +2758,10 @@ namespace Js
27582758
functionConstructor->SetHasNoEnumerableProperties(true);
27592759

27602760
#ifdef ALLOW_JIT_REPRO
2761-
library->AddFunctionToLibraryObject(functionConstructor, PropertyIds::invokeJit, &JavascriptFunction::EntryInfo::InvokeJit, 1);
2761+
if (CONFIG_FLAG(JitRepro))
2762+
{
2763+
library->AddFunctionToLibraryObject(functionConstructor, PropertyIds::invokeJit, &JavascriptFunction::EntryInfo::InvokeJit, 1);
2764+
}
27622765
#endif
27632766

27642767
return true;

0 commit comments

Comments
 (0)