Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
[Merge chakra-core/ChakraCore@895f892129] [MERGE #3489 @obastemur] Co…
Browse files Browse the repository at this point in the history
…nvert internal static initializer (thread safe) to global

Merge pull request #3489 from obastemur:fix_br_tls

MSVC uses TLS for internal thread safe static initializers. Use static class constructor. Fixes build break with Full.
  • Loading branch information
chakrabot authored and kfarnung committed Aug 10, 2017
1 parent c2a86b6 commit 3ab059b
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions deps/chakrashim/core/lib/Runtime/Library/JSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,17 @@ namespace JSON

// -------- StringifySession implementation ------------//

static char16 gapStringBuffer[JSONspaceSize];
static char16* GetGapStringInternal()
class JSONSpace
{
wmemset(gapStringBuffer, _u(' '), JSONspaceSize);
return gapStringBuffer;
}
public:
static char16 Buffer[JSONspaceSize];
JSONSpace() { wmemset(Buffer, _u(' '), JSONspaceSize); }
};
char16 JSONSpace::Buffer[JSONspaceSize];
static JSONSpace jsonSpace;

void StringifySession::CompleteInit(Js::Var space, ArenaAllocator* tempAlloc)
{
//set the stack, gap
static const char16* spaceBuffer = GetGapStringInternal(); // multi threading safe

charcount_t len = 0;
switch (Js::JavascriptOperators::GetTypeId(space))
{
Expand All @@ -352,7 +351,7 @@ namespace JSON
len = max(0, min(JSONspaceSize, static_cast<int>(Js::TaggedInt::ToInt32(space))));
if (len)
{
gap = Js::JavascriptString::NewCopyBuffer(spaceBuffer, len, scriptContext);
gap = Js::JavascriptString::NewCopyBuffer(jsonSpace.Buffer, len, scriptContext);
}
break;
}
Expand All @@ -364,7 +363,7 @@ namespace JSON
len = max(0, static_cast<int>(min(static_cast<double>(JSONspaceSize), Js::JavascriptConversion::ToInteger(space, scriptContext))));
if (len)
{
gap = Js::JavascriptString::NewCopyBuffer(spaceBuffer, len, scriptContext);
gap = Js::JavascriptString::NewCopyBuffer(jsonSpace.Buffer, len, scriptContext);
}
break;
}
Expand Down

0 comments on commit 3ab059b

Please sign in to comment.