Some more changes and cleanup to reduce the startup time#8396
Merged
daxian-dbw merged 5 commits intoPowerShell:masterfrom Dec 6, 2018
Merged
Some more changes and cleanup to reduce the startup time#8396daxian-dbw merged 5 commits intoPowerShell:masterfrom
daxian-dbw merged 5 commits intoPowerShell:masterfrom
Conversation
…implify 'HelperSecurity.psm1'
…IoT' at startup time
…riptBlockInFactASafeHashtable' runs
9f718e0 to
d32458e
Compare
Collaborator
Currently runtime has |
iSazonov
approved these changes
Dec 5, 2018
PaulHigin
suggested changes
Dec 5, 2018
PaulHigin
suggested changes
Dec 5, 2018
Member
Author
@iSazonov I don't think |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
This PR includes some changes and cleanups that will reduce the startup time. Each commit is self-contained, and the commit message serves as a summary of the changes in the commit.
s_wasSystemPolicyDebugPolicytos_allowDebugOverridePolicyto make it less confusing. Also slightly refactorHelperSecurity.psm1andConstrainedLanguageDebugger.Tests.ps1to remove unneeded code. There is no functional change in this commit.IsInbox, as PowerShell Core won't be shipped in-box with Windows in the foreseeable feature. Even if we do in future, we won't be needing it because Windows PowerShell will probably be gone by that time.$env:PSModulePath, and it will in turn causeIsNanoServerandIsIoTto be evaluated, all of which will trigger access to the Registry. By removingIsInbox, that can be all avoided.BindRunspaceretrieves all available commands from the session state, but for the most common scenario of creating/opening a Runspace, the retrieved commands are never get used afterwards. The method is updated to avoid retrieving all commands unless it's necessary.ProcessXXXmethod, so that we can avoid some unneeded method calls.IsSafeValueVisitorevery time whenIsScriptBlockInFactASafeHashtableruns.IsSafeValueVisitor.IsAstSafecreates an instance ofIsSafeValueVisitorevery time it runs. Given thatIsScriptBlockInFactASafeHashtablegets called relatively frequently inPerformSecurityCheck, this will result in some GC pressure as it will generate transient objects. This is updated to reuse aIsSafeValueVisitorsingleton with the defaultSafeValueContext.Defaultand_safeValueContextfields are madereadonly, so it cannot be changed by reflection._visitCountis changed touinttype, so an attacker cannot change the value of it to a negative number in order to practically increase the max visit count limit.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests