forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[web] Avoid using
js_util.{jsify,dartify}()
in dart2wasm for conver…
…ting to JS wrappers The `js_util.jsify()` related code shows up in CPU profile of wonderous. => Any `SkwasmObjectWrapper` object invokes this logic in the constructor and dispose method. This PR * makes `DomFinalizationRegistryExtension` accept JSAny types instead of Dart types and internally converting => Callsites can call more precise `<>.toJS*` extension methods => Avoids extra type checks on the objects * avoids making `toJSAnyShallow` delegate to `toJSAnyDeep` in wasm => `toJSAnyDeep` uses `js_util.jsify()` which is slow => We cannot use `Object.toJSBox` due to it being slower to create JS boxes as it semantically does something different atm (see issue below) => Instead use conditional import of `dart:_wasm` which provides the necessary primitives => Similar for going from JS to Dart. * Avoid calling converting from Dart object to JSAny more than needed (we did the operation twice for each registration and once for unregistration) Issue dart-lang/sdk#55183 change condition move
- Loading branch information
1 parent
638eddb
commit 58afe07
Showing
7 changed files
with
56 additions
and
30 deletions.
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
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
16 changes: 16 additions & 0 deletions
16
lib/web_ui/lib/src/engine/skwasm/skwasm_impl/dart_js_conversion.dart
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,16 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'dart:_wasm'; | ||
import 'dart:js_interop'; | ||
|
||
@pragma('wasm:prefer-inline') | ||
@pragma('dart2js:tryInline') | ||
JSAny dartToJsWrapper(Object object) => | ||
WasmAnyRef.fromObject(object).externalize().toJS; | ||
|
||
@pragma('wasm:prefer-inline') | ||
@pragma('dart2js:tryInline') | ||
Object jsWrapperToDart(JSAny jsWrapper) => | ||
externRefForJSAny(jsWrapper).internalize()!.toObject(); |
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
13 changes: 13 additions & 0 deletions
13
lib/web_ui/lib/src/engine/skwasm/skwasm_stub/dart_js_conversion.dart
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,13 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'dart:js_interop'; | ||
|
||
@pragma('wasm:prefer-inline') | ||
@pragma('dart2js:tryInline') | ||
JSAny dartToJsWrapper(Object object) => object as JSAny; | ||
|
||
@pragma('wasm:prefer-inline') | ||
@pragma('dart2js:tryInline') | ||
Object jsWrapperToDart(JSAny jsWrapper) => jsWrapper; |