From 827ebd578b47bf027a14ff61611692f3e240f2a2 Mon Sep 17 00:00:00 2001 From: Michael Holman Date: Wed, 3 May 2017 16:43:05 -0700 Subject: [PATCH] move propertyStrings cache to recyler --- lib/Runtime/Base/ScriptContext.cpp | 19 ++++++++++--------- lib/Runtime/Base/ScriptContext.h | 1 - lib/Runtime/Library/JavascriptLibrary.h | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/Runtime/Base/ScriptContext.cpp b/lib/Runtime/Base/ScriptContext.cpp index a408353f94d..f4cf86ff0b8 100644 --- a/lib/Runtime/Base/ScriptContext.cpp +++ b/lib/Runtime/Base/ScriptContext.cpp @@ -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(); @@ -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) @@ -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) @@ -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) diff --git a/lib/Runtime/Base/ScriptContext.h b/lib/Runtime/Base/ScriptContext.h index 83a49ecdbc8..ecf8b53b5ad 100644 --- a/lib/Runtime/Base/ScriptContext.h +++ b/lib/Runtime/Base/ScriptContext.h @@ -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); diff --git a/lib/Runtime/Library/JavascriptLibrary.h b/lib/Runtime/Library/JavascriptLibrary.h index dcf97d54f9d..825a694695e 100644 --- a/lib/Runtime/Library/JavascriptLibrary.h +++ b/lib/Runtime/Library/JavascriptLibrary.h @@ -54,6 +54,7 @@ namespace Js struct Cache { + Field(PropertyStringMap*) propertyStrings[80]; Field(ScriptContextPolymorphicInlineCache *) globalPICHead; Field(JavascriptString *) lastNumberToStringRadix10String; Field(EnumeratedObjectCache) enumObjCache;