Skip to content

Commit 547e459

Browse files
committed
move propertyStrings cache to recyler
1 parent ebb5998 commit 547e459

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

lib/Runtime/Base/ScriptContext.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ namespace Js
256256
memset(byteCodeHistogram, 0, sizeof(byteCodeHistogram));
257257
#endif
258258

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

261261
#if DBG || defined(RUNTIME_DATA_COLLECTION)
262262
this->allocId = threadContext->GetScriptContextCount();
@@ -801,12 +801,12 @@ namespace Js
801801
return NULL;
802802
}
803803
const uint i = PropertyStringMap::PStrMapIndex(ch1);
804-
if (propertyStrings[i] == NULL)
804+
if (this->Cache()->propertyStrings[i] == NULL)
805805
{
806806
return NULL;
807807
}
808808
const uint j = PropertyStringMap::PStrMapIndex(ch2);
809-
return propertyStrings[i]->strLen2[j];
809+
return this->Cache()->propertyStrings[i]->strLen2[j];
810810
}
811811

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

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

15571557
void ScriptContext::TrackPid(const PropertyRecord* propertyRecord)
@@ -1597,17 +1597,18 @@ namespace Js
15971597
{
15981598
const char16* buf = propString->GetBuffer();
15991599
const uint i = PropertyStringMap::PStrMapIndex(buf[0]);
1600-
if (propertyStrings[i] == NULL)
1600+
PropertyStringMap* strMap = this->Cache()->propertyStrings[i];
1601+
if (strMap == NULL)
16011602
{
16021603
InitPropertyStringMap(i);
16031604
}
16041605
const uint j = PropertyStringMap::PStrMapIndex(buf[1]);
1605-
if (propertyStrings[i]->strLen2[j] == NULL && !isClosed)
1606+
if (strMap->strLen2[j] == NULL && !isClosed)
16061607
{
1607-
propertyStrings[i]->strLen2[j] = GetLibrary()->CreatePropertyString(propString);
1608+
strMap->strLen2[j] = GetLibrary()->CreatePropertyString(propString);
16081609
this->TrackPid(propString);
16091610
}
1610-
return propertyStrings[i]->strLen2[j];
1611+
return strMap->strLen2[j];
16111612
}
16121613

16131614
PropertyString* ScriptContext::CachePropertyString2(const PropertyRecord* propString)

lib/Runtime/Base/ScriptContext.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -371,18 +371,6 @@ namespace Js
371371
#endif
372372
};
373373

374-
struct PropertyStringMap
375-
{
376-
PropertyString* strLen2[80];
377-
378-
inline static uint PStrMapIndex(char16 ch)
379-
{
380-
Assert(ch >= '0' && ch <= 'z');
381-
return ch - '0';
382-
}
383-
};
384-
385-
386374
/*
387375
* This class caches jitted func address ranges.
388376
* This is to facilitate WER scenarios to use this cache for checking native addresses.
@@ -549,7 +537,6 @@ namespace Js
549537
void SetGlobalPICHead(ScriptContextPolymorphicInlineCache * cache) { this->Cache()->globalPICHead = cache; }
550538

551539
private:
552-
PropertyStringMap* propertyStrings[80];
553540

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

lib/Runtime/Library/JavascriptLibrary.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,20 @@ namespace Js
5252
Field(int) validPropStrings;
5353
};
5454

55+
struct PropertyStringMap
56+
{
57+
Field(PropertyString*) strLen2[80];
58+
59+
inline static uint PStrMapIndex(char16 ch)
60+
{
61+
Assert(ch >= '0' && ch <= 'z');
62+
return ch - '0';
63+
}
64+
};
65+
5566
struct Cache
5667
{
68+
Field(PropertyStringMap*) propertyStrings[80];
5769
Field(ScriptContextPolymorphicInlineCache *) globalPICHead;
5870
Field(JavascriptString *) lastNumberToStringRadix10String;
5971
Field(EnumeratedObjectCache) enumObjCache;

0 commit comments

Comments
 (0)