Skip to content

Commit

Permalink
use/rename ForInCacheAllocator for assign cache
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeHolman committed Mar 21, 2018
1 parent 355c325 commit 2b7744c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 21 deletions.
4 changes: 2 additions & 2 deletions lib/Runtime/Base/FunctionBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}
Expand Down
16 changes: 4 additions & 12 deletions lib/Runtime/Base/ScriptContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions lib/Runtime/Base/ScriptContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ namespace Js
ArenaAllocator dynamicProfileInfoAllocator;
InlineCacheAllocator inlineCacheAllocator;
CacheAllocator isInstInlineCacheAllocator;
CacheAllocator forInCacheAllocator;
CacheAllocator enumeratorCacheAllocator;

ArenaAllocator* interpreterArena;
ArenaAllocator* guestArena;
Expand Down Expand Up @@ -1289,7 +1289,7 @@ namespace Js
#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
Expand Down Expand Up @@ -1479,8 +1479,7 @@ namespace Js
#endif
void ClearInlineCaches();
void ClearIsInstInlineCaches();
void ClearForInCaches();
void ClearAssignCache();
void ClearEnumeratorCaches();
#ifdef PERSISTENT_INLINE_CACHES
void ClearInlineCachesWithDeadWeakRefs();
#endif
Expand Down
3 changes: 1 addition & 2 deletions lib/Runtime/Base/ThreadContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3121,8 +3121,7 @@ ThreadContext::ClearEnumeratorCaches()
Js::ScriptContext *scriptContext = this->scriptContextList;
while (scriptContext != nullptr)
{
scriptContext->ClearForInCaches();
scriptContext->ClearAssignCache();
scriptContext->ClearEnumeratorCaches();
scriptContext = scriptContext->next;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Runtime/Library/JavascriptLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
Expand Down

0 comments on commit 2b7744c

Please sign in to comment.