-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add detector for type reflection #67
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright 2023 Google Inc. All Rights Reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
;; Name: Type Reflection | ||
;; Proposal: https://github.com/WebAssembly/js-types | ||
;; Features: type-reflection | ||
*/ | ||
|
||
export default async () => { | ||
return "Function" in WebAssembly; | ||
}; |
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.
I don’t think this is enough. IINM,
WebAssembly.Function
is also expose by the JSPI proposal.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.
Maybe something like this could work?
Doing some tests:
type()
method, but it does not haveWebAssembly.Function
and functions exported from aWebAssembly.Instance
do not have thetype()
methodThere 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.
Let me try it with d8 with various extra feature flags.
As I understand it, JSPI implies type reflection. E.g., passing
--experimental-wasm-stack-switching --experimental-type-reflection
is indistinguishable from just--experimental-wasm-stack-switching
. To test this I made a little Python script:I made
feature_detect.js
:and then tested with V8 version 11.5.69
For good measure I listed out all experimental flags with:
and checked that the script returns
true true
if either of these two flags is present andfalse false
with any other collection of experimental flags. (Well I picked the other flags at random so I only tested a random sample.)Test script
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.
So the moral of the story is that both approaches should do the same thing, at least on v8. Node is a similar story. I guess I should check also with firefox...
Anyways if you folks prefer, I am fine with switching to the more detailed check. I think we should add a comment though.
See also Emscripten's feature detection:
https://github.com/emscripten-core/emscripten/blob/main/src/library_addfunction.js#L98-L105
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.
@sbc100 do you have an opinion?
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.
Yeah I guess I may be overly focusing on v8 checks here...
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 think the check as written seems like it should be fine.
JSPI depends on the type reflection proposal, but I don' think that needs to effect this test. JSPI itself doesn't provide this symbol.
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.
Ahah: in firefox nightly v115.0a1 I get:
but if I fix:
to
then I get
true true
again.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.
In Safari Version 16.3 (18614.4.6.1.6),
gives
false false true true true
as @juancastillo0 said.In Safari Technology Preview Release 169 (Safari 16.4, WebKit 18616.1.12.2) I get the same thing.
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.
Thanks everyone! Sounds like we can leave this as is!