Skip to content

Commit

Permalink
move propertyStrings cache to recyler
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeHolman committed May 3, 2017
1 parent ebb5998 commit 827ebd5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions lib/Runtime/Base/ScriptContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ namespace Js
memset(byteCodeHistogram, 0, sizeof(byteCodeHistogram));
#endif

memset(propertyStrings, 0, sizeof(PropertyStringMap*)* 80);
memset(this->Cache()->propertyStrings, 0, sizeof(PropertyStringMap*)* 80);

#if DBG || defined(RUNTIME_DATA_COLLECTION)
this->allocId = threadContext->GetScriptContextCount();
Expand Down Expand Up @@ -801,12 +801,12 @@ namespace Js
return NULL;
}
const uint i = PropertyStringMap::PStrMapIndex(ch1);
if (propertyStrings[i] == NULL)
if (this->Cache()->propertyStrings[i] == NULL)
{
return NULL;
}
const uint j = PropertyStringMap::PStrMapIndex(ch2);
return propertyStrings[i]->strLen2[j];
return this->Cache()->propertyStrings[i]->strLen2[j];
}

void ScriptContext::FindPropertyRecord(JavascriptString *pstName, PropertyRecord const ** propertyRecord)
Expand Down Expand Up @@ -1550,8 +1550,8 @@ namespace Js

void ScriptContext::InitPropertyStringMap(int i)
{
propertyStrings[i] = AnewStruct(GeneralAllocator(), PropertyStringMap);
memset(propertyStrings[i]->strLen2, 0, sizeof(PropertyString*)* 80);
this->Cache()->propertyStrings[i] = RecyclerNewStruct(GetRecycler(), PropertyStringMap);
memset(this->Cache()->propertyStrings[i]->strLen2, 0, sizeof(PropertyString*)* 80);
}

void ScriptContext::TrackPid(const PropertyRecord* propertyRecord)
Expand Down Expand Up @@ -1597,17 +1597,18 @@ namespace Js
{
const char16* buf = propString->GetBuffer();
const uint i = PropertyStringMap::PStrMapIndex(buf[0]);
if (propertyStrings[i] == NULL)
PropertyStringMap* strMap = this->Cache()->propertyStrings[i];
if (strMap == NULL)
{
InitPropertyStringMap(i);
}
const uint j = PropertyStringMap::PStrMapIndex(buf[1]);
if (propertyStrings[i]->strLen2[j] == NULL && !isClosed)
if (strMap->strLen2[j] == NULL && !isClosed)
{
propertyStrings[i]->strLen2[j] = GetLibrary()->CreatePropertyString(propString);
strMap->strLen2[j] = GetLibrary()->CreatePropertyString(propString);
this->TrackPid(propString);
}
return propertyStrings[i]->strLen2[j];
return strMap->strLen2[j];
}

PropertyString* ScriptContext::CachePropertyString2(const PropertyRecord* propString)
Expand Down
1 change: 0 additions & 1 deletion lib/Runtime/Base/ScriptContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,6 @@ namespace Js
void SetGlobalPICHead(ScriptContextPolymorphicInlineCache * cache) { this->Cache()->globalPICHead = cache; }

private:
PropertyStringMap* propertyStrings[80];

JavascriptFunction* GenerateRootFunction(ParseNodePtr parseTree, uint sourceIndex, Parser* parser, uint32 grfscr, CompileScriptException * pse, const char16 *rootDisplayName);

Expand Down
1 change: 1 addition & 0 deletions lib/Runtime/Library/JavascriptLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace Js

struct Cache
{
Field(PropertyStringMap*) propertyStrings[80];
Field(ScriptContextPolymorphicInlineCache *) globalPICHead;
Field(JavascriptString *) lastNumberToStringRadix10String;
Field(EnumeratedObjectCache) enumObjCache;
Expand Down

0 comments on commit 827ebd5

Please sign in to comment.