perf(web): optimize single pass utf8 decoding#16593
perf(web): optimize single pass utf8 decoding#16593littledivy merged 6 commits intodenoland:mainfrom
Conversation
| let stream = false; | ||
| if (options !== undefined) { | ||
| options = webidl.converters.TextDecodeOptions(options, { | ||
| prefix, | ||
| context: "Argument 2", | ||
| }); | ||
| stream = options.stream; | ||
| } |
There was a problem hiding this comment.
We should come up with a general improvement in webidl for cases like this. I think the optimal way would require new Function codegen.
There was a problem hiding this comment.
For what it's worth, Evan (Discord) had been saying that for over a year. The entire WebIDL bindings setup should be via JiT-compiled codegen.
There was a problem hiding this comment.
yeah :(
never too late though
| input.buffer, | ||
| input.byteOffset, | ||
| input.byteLength, |
There was a problem hiding this comment.
Well... now these are all polymorphic...
There was a problem hiding this comment.
wasn't this already the case before this patch?
| ObjectPrototypeIsPrototypeOf( | ||
| SharedArrayBuffer.prototype, |
There was a problem hiding this comment.
| ObjectPrototypeIsPrototypeOf( | |
| SharedArrayBuffer.prototype, | |
| ObjectPrototypeIsPrototypeOf( | |
| SharedArrayBufferPrototype, |
There was a problem hiding this comment.
can we please defer these primordials changes? I don't want to make the code any slower
There was a problem hiding this comment.
Sure; I'll introduce these next month, myself.
There was a problem hiding this comment.
lets see what others think. i personally don't like primordials in fast paths for mitigating a hypothetical case. Node.js has also removed primoridals in hot paths previously nodejs/node#38248
| ObjectPrototypeIsPrototypeOf( | ||
| SharedArrayBuffer.prototype, | ||
| input.buffer, | ||
| input || input.buffer, |
- [x] Avoid copying buffers. https://encoding.spec.whatwg.org/#dom-textdecoder-decode > Implementations are strongly encouraged to use an implementation strategy that avoids this copy. When doing so they will have to make sure that changes to input do not affect future calls to [decode()](https://encoding.spec.whatwg.org/#dom-textdecoder-decode). - [x] Special op to avoid string label deserialization and parsing. (Ideally we should map labels to integers in JS) - [x] Avoid webidl `Object.assign` when options is undefined.
https://encoding.spec.whatwg.org/#dom-textdecoder-decode
Object.assignwhen options is undefined.