Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PolymorphicInlineCache for PropertyString #2883

Merged
merged 3 commits into from
May 10, 2017

Conversation

MikeHolman
Copy link
Contributor

@MikeHolman MikeHolman commented Apr 28, 2017

PropertyStrings were earlier using their own special kind of inline caches. I have changed for them to now use our PolymorphicInlineCache, which can improve cases where we have polymorphic types., and also take advantage of existing InlineCache optimizations that weren't present in the specialized PropertyString cache.

This gives about 8% improvement in react and 4% in angular.

@MikeHolman MikeHolman force-pushed the strpic_master branch 4 times, most recently from 28ff38f to 83d1fe5 Compare April 28, 2017 04:28
class FunctionBodyPolymorphicInlineCache sealed : public PolymorphicInlineCache
{
private:
Field(FunctionBody *) functionBody;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to annotate class that are allocated as leaf.

PropertyString * propertyString = (PropertyString *)Anew(arena, ArenaAllocPropertyString, type, propertyRecord);
propertyString->propCache = AllocatorNewStructZ(InlineCacheAllocator, type->GetScriptContext()->GetInlineCacheAllocator(), PropertyCache);
PropertyString * propertyString = RecyclerNewZ(recycler, PropertyString, type, propertyRecord);
propertyString->ldElemInlineCache = ScriptContextPolymorphicInlineCache::New(MinPropertyStringInlineCacheSize, type->GetScriptContext());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably can inline these into property string to avoid the extra allocation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right now PIC don't ever grow, we just replace with a new one when we want to grow, so all the paths that deal with growing PIC would need to be updated.

@@ -697,7 +674,7 @@ namespace Js
#endif
if (!PHASE_OFF1(Js::CloneCacheInCollisionPhase))
{
if (!inlineCaches[inlineCacheIndex].IsEmpty() && !inlineCaches[inlineCacheIndex].NeedsToBeRegisteredForStoreFieldInvalidation())
if (!inlineCaches[inlineCacheIndex].IsEmpty() && !inlineCaches[inlineCacheIndex].NeedsToBeRegisteredForStoreFieldInvalidation() && GetSize() != 1)
Copy link
Contributor

@rajatd rajatd May 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 [](start = 160, length = 1)

is this '1' representing MinPropertyStringInlineCacheSize? If yes, could you use MinPropertyStringInlineCacheSize instead? Same in CacheProto, CacheAccessor, and CopyTo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really about the specific size value 1 rather than the abstract variable. Point is if there is only 1 slot, we can't clone to empty slot.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, makes sense.


In reply to: 115339004 [](ancestors = 115339004)

else if (currentSize == MinPropertyStringInlineCacheSize)
{
CompileAssert(MinPropertyStringInlineCacheSize < MinPolymorphicInlineCacheSize);
return MinPolymorphicInlineCacheSize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MinPolymorphicInlineCacheSize [](start = 23, length = 29)

So, we're not gonna grow the cache?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this case will grow cache from 1 to 4.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, I misread MinPolymorphicInlineCacheSize and MinPropertyStringInlineCacheSize as the same


In reply to: 115339150 [](ancestors = 115339150)

cache->GetInlineCaches()[cache->GetInlineCacheIndexForType(type)].Clear();
}
cache = string->GetStElemInlineCache();
if (cache->PretendTryGetProperty(type, &info))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PretendTryGetProperty [](start = 27, length = 21)

Shouldn't this be a call to PretendTry-SET-Property ?

@MikeHolman
Copy link
Contributor Author

Can you guys take another look? I have more changes that I want to check in on top of this and don't have much time.

@rajatd
Copy link
Contributor

rajatd commented May 9, 2017

Looks good to me.

@chakrabot chakrabot merged commit 33c2931 into chakra-core:master May 10, 2017
chakrabot pushed a commit that referenced this pull request May 10, 2017
Merge pull request #2883 from MikeHolman:strpic_master

PropertyStrings were earlier using their own special kind of inline caches. I have changed for them to now use our PolymorphicInlineCache, which can improve cases where we have polymorphic types., and also take advantage of existing InlineCache optimizations that weren't present in the specialized PropertyString cache.

This gives about 8% improvement in react and 4% in angular.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants