Reduce code size of Stack.Peek#12094
Conversation
|
Separating out the throw into its own method is fine, keeping it the same as queue. But we shouldn't add AggressiveInlining unless there's a strong performance-motivated scenario for doing so. Getting something to inline isn't a goal in and of itself. |
There was a problem hiding this comment.
Nit: Any reason for the naming inconsistency between ThrowForEmptyQueue in #12062 and ThrowInvalidOperationEmptyStack here? It'd be nice if both methods were named consistently. I like the naming you have chosen here, so ThrowInvalidOperationEmptyQueue and ThrowInvalidOperationEmptyStack.
There was a problem hiding this comment.
Actually, I'm partial to the one I had in the other PR. Although it's less descriptive, it's more terse. I'll remove the inconsistency if this will be merged.
|
@stephentoub OK, sounds reasonable. I'll remove the AggressiveInlining part of this PR tmrw and only include the part separating the throw logic into a new method. If I come up with a 'strong performance-motivated scenario' another day I'll resubmit the rest of the changes. |
Commit migrated from dotnet/corefx@a945cdd
Same as #12062, but for Stack. I had to add AggressiveInlining to get it to work, since it seems like the 1 extra byte from the
decin_size - 1was making it ineligible for inlining.Test code, before/after asm is available at the link. You can see inlining
Stack.Peekincreases the code size ofMainby 31 bytes, while inliningQueue.Peek(asm is in the previous PR) increases it by 30.cc @stephentoub, @ianhays