Skip to content

Conversation

@leirocks
Copy link
Contributor

Use smaller data type to represent the counter fields of FunctionBody.

Most of the counters has value less than 256, use single byte to hold them. And can promote to short or full 32 bit integer when necessary.


// Signed integers need keep the sign when promoting
SignedFieldsStart = 26,
SerializationIndex = 26,
Copy link
Collaborator

Choose a reason for hiding this comment

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

These two are both 26

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SignedFieldsStart is a marker that from that point, it saves signed value. maybe I can remove this, instead, use a byte in the structure to save the position -- there're 3 bytes at the beginning is not used.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh gotcha, I missed that SignedFieldsStart was a label marking the beginning of special fields.

@ianwjhalliday
Copy link
Collaborator

With this and your previous change how much does this shrink FunctionBody down on x64?

@ianwjhalliday
Copy link
Collaborator

Ignoring the separately added data for the pointers and counters. I'm curious about sizeof(FunctionBody) for curiosity's sake.

@leirocks
Copy link
Contributor Author

@ianwjhalliday it reduced from 648 to 384 bytes

@leirocks
Copy link
Contributor Author

@dotnet-bot test this please

@leirocks leirocks force-pushed the fb_counters_pr branch 3 times, most recently from 92ce4fc to b19ae63 Compare February 13, 2016 06:51
@ianwjhalliday
Copy link
Collaborator

Nice, that is a significant reduction.

@leirocks leirocks force-pushed the fb_counters_pr branch 2 times, most recently from 49f445a to dbffdf4 Compare February 18, 2016 19:13
@leirocks
Copy link
Contributor Author

@dotnet-bot test EOL Check please

memset(this->m_inlineCaches[i], 0, sizeof(InlineCache));
}
else if(!scriptContext->IsClosed())
else if(scriptContext != nullptr && !scriptContext->IsClosed())
Copy link
Contributor

Choose a reason for hiding this comment

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

In what situation can the scriptContext be nullptr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, this is not intentional change. previously in order to solve the issue the when FunctionBody::Cleanup sometimes the scriptContext is already gone, I set this to null. So this is not needed any more because when cleaning up we should not be expanding the structure so should not need the recycler from scriptContext anymore.
let me remove the change. thanks.

@leirocks
Copy link
Contributor Author

@curtisman as discussed, moved following mutable fields out of the structure. and added Assert in case there's any other fields missed.

    uint32 interpretedCount;
    uint32 loopInterpreterLimit;
    uint32 debuggerScopeIndex;
    uint32 savedPolymorphicCacheState;

@curtisman
Copy link
Contributor

LGTM

@chakrabot chakrabot merged commit 0cdf521 into chakra-core:master Mar 1, 2016
chakrabot pushed a commit that referenced this pull request Mar 1, 2016
… FunctionBody.

Merge pull request #301 from leirocks:fb_counters_pr
Use smaller data type to represent the counter fields of FunctionBody.

Most of the counters has value less than 256, use single byte to hold them. And can promote to short or full 32 bit integer when necessary.
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