-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf(ext/web): optimize transferArrayBuffer #16294
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
966116e
perf(ext/web): optimize transferArrayBuffer
littledivy 7f9ac4a
fix
littledivy 2300a70
maybe fix
littledivy 51e726f
Merge branch 'main' into optimize_readablestream
littledivy b6e0056
wpt
littledivy dbf4faa
Merge branch 'optimize_readablestream' of github.com:littledivy/deno …
littledivy 1ec8608
Merge branch 'main' of github.com:denoland/deno into optimize_readabl…
littledivy 9d145fc
review
littledivy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ | |
WeakMapPrototypeSet, | ||
} = globalThis.__bootstrap.primordials; | ||
const consoleInternal = window.__bootstrap.console; | ||
const ops = core.ops; | ||
const { AssertionError, assert } = window.__bootstrap.infra; | ||
|
||
/** @template T */ | ||
|
@@ -218,15 +219,8 @@ | |
* @returns {ArrayBufferLike} | ||
*/ | ||
function transferArrayBuffer(O) { | ||
assert(!isDetachedBuffer(O)); | ||
const transferredIshVersion = O.slice(0); | ||
ObjectDefineProperty(O, "byteLength", { | ||
get() { | ||
return 0; | ||
}, | ||
}); | ||
O[isFakeDetached] = true; | ||
return transferredIshVersion; | ||
const v = ops.op_transfer_arraybuffer(O); | ||
v[isFakeDetached] = true; | ||
} | ||
|
||
/** | ||
|
@@ -4572,26 +4566,30 @@ | |
* @param {UnderlyingSource<R>=} underlyingSource | ||
* @param {QueuingStrategy<R>=} strategy | ||
*/ | ||
constructor(underlyingSource = undefined, strategy = {}) { | ||
constructor(underlyingSource = undefined, strategy = undefined) { | ||
const prefix = "Failed to construct 'ReadableStream'"; | ||
if (underlyingSource !== undefined) { | ||
underlyingSource = webidl.converters.object(underlyingSource, { | ||
prefix, | ||
context: "Argument 1", | ||
}); | ||
} | ||
strategy = webidl.converters.QueuingStrategy(strategy, { | ||
prefix, | ||
context: "Argument 2", | ||
}); | ||
if (strategy !== undefined) { | ||
strategy = webidl.converters.QueuingStrategy(strategy, { | ||
prefix, | ||
context: "Argument 2", | ||
}); | ||
} else { | ||
strategy = {}; | ||
} | ||
lucacasonato marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this[webidl.brand] = webidl.brand; | ||
if (underlyingSource === undefined) { | ||
underlyingSource = null; | ||
let underlyingSourceDict = {}; | ||
if (underlyingSource !== undefined) { | ||
underlyingSourceDict = webidl.converters.UnderlyingSource( | ||
underlyingSource, | ||
{ prefix, context: "underlyingSource" }, | ||
); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This check is now not present at all anymore. |
||
const underlyingSourceDict = webidl.converters.UnderlyingSource( | ||
underlyingSource, | ||
{ prefix, context: "underlyingSource" }, | ||
); | ||
initializeReadableStream(this); | ||
if (underlyingSourceDict.type === "bytes") { | ||
if (strategy.size !== undefined) { | ||
|
@@ -4652,13 +4650,17 @@ | |
* @param {ReadableStreamGetReaderOptions=} options | ||
* @returns {ReadableStreamDefaultReader<R> | ReadableStreamBYOBReader} | ||
*/ | ||
getReader(options = {}) { | ||
getReader(options = undefined) { | ||
webidl.assertBranded(this, ReadableStreamPrototype); | ||
const prefix = "Failed to execute 'getReader' on 'ReadableStream'"; | ||
options = webidl.converters.ReadableStreamGetReaderOptions(options, { | ||
prefix, | ||
context: "Argument 1", | ||
}); | ||
if (options !== undefined) { | ||
options = webidl.converters.ReadableStreamGetReaderOptions(options, { | ||
prefix, | ||
context: "Argument 1", | ||
}); | ||
} else { | ||
options = {}; | ||
} | ||
if (options.mode === undefined) { | ||
return acquireReadableStreamDefaultReader(this); | ||
} else { | ||
|
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is failing because
v
is not being returned.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deno/ext/web/06_streams.js
Lines 196 to 198 in 2300a70
And maybe we can now change that method to:
Although it may trigger some false positives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm keeping
isFakeDetached
to not touch a lot of code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you fix this properly rather than half fixing it just enough so that WPT passes? 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lucacasonato #16307 @marcosc90 opened a PR to do that as a follow up to this one.