Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Switch sha512 to use fastpath with wasm #165

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/sha512.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'dart:convert';
import 'digest.dart';
import 'hash.dart';
// ignore: uri_does_not_exist
import 'sha512_fastsinks.dart' if (dart.library.js) 'sha512_slowsinks.dart';
import 'sha512_fastsinks.dart' if (dart.library.html) 'sha512_slowsinks.dart';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: surprised that the dart.library.js bit was still being chosen by wasm. Asking @srujzs about this now!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dart.library.js exists in libraries.json for dart2wasm. It was used to support allowInterop, but that method has since then moved out of that library, so we should delete it from libraries.json. You can't import it (you get a static error), but it exists.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

("Can't import" should match the value of platform.library.js, "being there" but not being able to import anyway isn't what a conditional import wants to know.)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW - the libraries.json format supports that middleground @lrhn is describing: where you can import a library unconditionally, but the dart.library.xyz returns false on conditional imports. This is true today for dart.library.io on the JS backends, for instance.

So if there is any need to still have a library, but denote it as excluded, we can do so with the same mechanism. (This is what ["supported: false"][1] is for)
[1]: https://github.com/dart-lang/sdk/blob/95cbc6a49724f9aaac6ba72fc69a14e9f9f53d70/sdk/lib/libraries.yaml#L269

That said, as mentioned in https://github.com/dart-lang/crypto/issues/180. I believe this specific case can be addressed for now using the dart.library.ffi condition.

import 'utils.dart';

/// An implementation of the [SHA-384][rfc] hash function.
Expand Down