Uh oh!
There was an error while loading. Please reload this page.
Refactor TranscodeUtf8 to allow trimming of Vector128<T> - #47928
Conversation
ghost
commented
Feb 5, 2021
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
TBH we should probably have a separate implementation of the UTF-8 logic for interpreted or wasm scenarios. The current validation and transcoding logic is heavily optimized to take into consideration things like branch prediction, cache locality, and efficient register utilization. This results in the methods being large and complex because they consist of a bunch of little worker loops that each work on one optimized scenario. A separate interpreted / wasm-specific implementation would be a straightforward "just do the simplest thing" loop. No cleverness, just a small simple loop that consists of easy instructions. Edit - an example of the "simple" validation and transcoding loops: // simplest validation loopintGetIndexOfFirstInvalidUtf8Byte(ROS<byte>input,outintutf16CharCount){intoriginalInputLength=input.Length;utf16CharCount=0;while(!input.IsEmpty){if(Rune.DecodeUtf8(input,outRunerune,outintbytesConsumed)!=OperationStatus.Done)break;input=input.Slice(bytesConsumed);utf16CharCount+=input.Utf16CodeUnitCount;}returnoriginalInputLength-input.Length;}// simplest transcoding loopOperationStatusTranscodeUtf8ToUtf16(ROS<byte>input,ROS<char>output,outintbytesConsumed,outintcharsWritten){intoriginalInputLength=input.Length;intoriginalOutputLength=output.Length;OperationStatusopStatus=OperationStatus.Done;while(!input.IsEmpty){opStatus=Rune.DecodeUtf8(input,outRunerune,outintbytesConsumedJustNow);if(opStatus!=OperationStatus.Done){break;}if(!rune.TryWriteUtf16(output,outintcharsWrittenJustNow)){opStatus=OperationStatus.DestinationTooSmall;break;}input=input.Slice(bytesConsumedJustNow);output=output.Slice(charsWrittenJustNow);}bytesConsumed=originalInputLength-input.Length;charsWritten=originalOutputLength-output.Length;returnopStatus;} |
ghost
commented
Feb 5, 2021
Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @tannergooding, @sbomer Issue DetailsThis resolves #47860 by moving where I logged dotnet/linker#1805 to track the linker not understanding things like CC. @eerhardt, @stephentoub
|
tannergooding
commented
Feb 8, 2021
@GrabYourPitchforks, could you log an "up-for-grabs" issue suggesting the above? |
ghost
commented
Feb 8, 2021
Hello @tannergooding! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me ( |
This resolves#47860 by moving where
Unsafe.SkipInitis called so we can trim outVector128<short>in the default blazor_wasm template.I logged dotnet/linker#1805 to track the linker not understanding things like
SkipInit(which areNonVersionable) and dotnet/linker#1808 to track the linker not trimming out a local when its only usage is it being initialized viainitobjCC. @eerhardt, @stephentoub