Browse Source

use/rename ForInCacheAllocator for assign cache

Michael Holman 8 years ago
parent
commit
eee63b88d7

+ 2 - 2
lib/Runtime/Base/FunctionBody.cpp

@@ -6032,7 +6032,7 @@ namespace Js
         {
             return;
         }
-        this->SetAuxPtr(AuxPointerType::ForInCacheArray, AllocatorNewArrayZ(CacheAllocator, this->GetScriptContext()->ForInCacheAllocator(), EnumeratorCache, profiledForInLoopCount));
+        this->SetAuxPtr(AuxPointerType::ForInCacheArray, AllocatorNewArrayZ(CacheAllocator, this->GetScriptContext()->GetEnumeratorAllocator(), EnumeratorCache, profiledForInLoopCount));
     }
 
     EnumeratorCache * FunctionBody::GetForInCache(uint index)
@@ -6062,7 +6062,7 @@ namespace Js
             }
             else
             {
-                AllocatorDeleteArray(CacheAllocator, this->GetScriptContext()->ForInCacheAllocator(), profiledForInLoopCount, forInCacheArray);
+                AllocatorDeleteArray(CacheAllocator, this->GetScriptContext()->GetEnumeratorAllocator(), profiledForInLoopCount, forInCacheArray);
                 this->SetAuxPtr(AuxPointerType::ForInCacheArray, nullptr);
             }
         }

+ 4 - 12
lib/Runtime/Base/ScriptContext.cpp

@@ -135,7 +135,7 @@ namespace Js
 #endif
         inlineCacheAllocator(_u("SC-InlineCache"), threadContext->GetPageAllocator(), Throw::OutOfMemory),
         isInstInlineCacheAllocator(_u("SC-IsInstInlineCache"), threadContext->GetPageAllocator(), Throw::OutOfMemory),
-        forInCacheAllocator(_u("SC-ForInCache"), threadContext->GetPageAllocator(), Throw::OutOfMemory),
+        enumeratorCacheAllocator(_u("SC-EnumeratorCache"), threadContext->GetPageAllocator(), Throw::OutOfMemory),
         hasUsedInlineCache(false),
         hasProtoOrStoreFieldInlineCache(false),
         hasIsInstInlineCache(false),
@@ -4726,18 +4726,10 @@ void ScriptContext::ClearIsInstInlineCaches()
     DebugOnly(isInstInlineCacheAllocator.CheckIsAllZero(true));
 }
 
-void ScriptContext::ClearForInCaches()
+void ScriptContext::ClearEnumeratorCaches()
 {
-    forInCacheAllocator.ZeroAll();
-    DebugOnly(forInCacheAllocator.CheckIsAllZero(false));
-}
-
-void ScriptContext::ClearAssignCache()
-{
-    if (Cache()->assignCache)
-    {
-        memset(Cache()->assignCache, 0, Js::Cache::AssignCacheSize);
-    }
+    enumeratorCacheAllocator.ZeroAll();
+    DebugOnly(enumeratorCacheAllocator.CheckIsAllZero(false));
 }
 
 #ifdef PERSISTENT_INLINE_CACHES

+ 3 - 4
lib/Runtime/Base/ScriptContext.h

@@ -570,7 +570,7 @@ namespace Js
         ArenaAllocator dynamicProfileInfoAllocator;
         InlineCacheAllocator inlineCacheAllocator;
         CacheAllocator isInstInlineCacheAllocator;
-        CacheAllocator forInCacheAllocator;
+        CacheAllocator enumeratorCacheAllocator;
 
         ArenaAllocator* interpreterArena;
         ArenaAllocator* guestArena;
@@ -1290,7 +1290,7 @@ private:
 #endif
         InlineCacheAllocator* GetInlineCacheAllocator() { return &inlineCacheAllocator; }
         CacheAllocator* GetIsInstInlineCacheAllocator() { return &isInstInlineCacheAllocator; }
-        CacheAllocator * ForInCacheAllocator() { return &forInCacheAllocator; }
+        CacheAllocator * GetEnumeratorAllocator() { return &enumeratorCacheAllocator; }
         ArenaAllocator* DynamicProfileInfoAllocator() { return &dynamicProfileInfoAllocator; }
 
 #ifdef ENABLE_SCRIPT_DEBUGGING
@@ -1480,8 +1480,7 @@ private:
 #endif
         void ClearInlineCaches();
         void ClearIsInstInlineCaches();
-        void ClearForInCaches();
-        void ClearAssignCache();
+        void ClearEnumeratorCaches();
 #ifdef PERSISTENT_INLINE_CACHES
         void ClearInlineCachesWithDeadWeakRefs();
 #endif

+ 1 - 2
lib/Runtime/Base/ThreadContext.cpp

@@ -3121,8 +3121,7 @@ ThreadContext::ClearEnumeratorCaches()
     Js::ScriptContext *scriptContext = this->scriptContextList;
     while (scriptContext != nullptr)
     {
-        scriptContext->ClearForInCaches();
-        scriptContext->ClearAssignCache();
+        scriptContext->ClearEnumeratorCaches();
         scriptContext = scriptContext->next;
     }
 }

+ 1 - 1
lib/Runtime/Library/JavascriptLibrary.cpp

@@ -6358,7 +6358,7 @@ namespace Js
     {
         if (this->cache.assignCache == nullptr)
         {
-            this->cache.assignCache = RecyclerNewArrayZ(scriptContext->GetRecycler(), EnumeratorCache, Cache::AssignCacheSize);
+            this->cache.assignCache = AllocatorNewArrayZ(CacheAllocator, scriptContext->GetEnumeratorAllocator(), EnumeratorCache, Cache::AssignCacheSize);
         }
 
         return &this->cache.assignCache[(((size_t)type) >> PolymorphicInlineCacheShift) & (Cache::AssignCacheSize - 1)];