[dart2wasm] Use identity hashmap for `allowInterop` closure map This significantly speeds up certain operations as it avoids calling complex closure equality logic in the hashmap operations. See also [0] regarding us leaking those closures. [0] https://github.com/dart-lang/sdk/issues/54908 Change-Id: I046063884b88fbe53bc3cb397b0087693c9b928a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352520 Reviewed-by: Srujan Gaddam <srujzs@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com>
diff --git a/sdk/lib/_internal/wasm/lib/js_helper.dart b/sdk/lib/_internal/wasm/lib/js_helper.dart index 8f27dee..d2c21b1 100644 --- a/sdk/lib/_internal/wasm/lib/js_helper.dart +++ b/sdk/lib/_internal/wasm/lib/js_helper.dart
@@ -340,7 +340,7 @@ // `allowInterop` and to replace them with the wrapped variant when they flow // to JS. // NOTE: We are not currently replacing functions returned from JS. -Map<Function, JSValue> functionToJSWrapper = {}; +final Map<Function, JSValue> functionToJSWrapper = Map.identity(); WasmExternRef? jsArrayBufferFromDartByteBuffer(ByteBuffer buffer) { ByteData byteData = ByteData.view(buffer);