Skip to content

Commit 1f9ce95

Browse files
osa1Commit Queue
authored andcommitted
[dart2wasm] Simplify boxed Dart object marker allocation
Skip the `JSSymbol` indirection and use an `externref` for the `Symbol` object directly. With the `JSSymbol` the indirection cannot be eliminated by inlining, because we have to check whether the `JSSymbol` static object is allocated first, and then access its `externref` field. When using an `externref` directly we still check whether the static field is initialized, but if it is we directly access the `extenref`, without going through `JSSymbol`. Change-Id: I9feae319c34fc5a3f83c0f5ba3767454a1f94566 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445680 Reviewed-by: Srujan Gaddam <[email protected]> Commit-Queue: Ömer Ağacan <[email protected]>
1 parent fbf680e commit 1f9ce95

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

sdk/lib/_internal/wasm/lib/js_interop_patch.dart

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,8 @@ extension FunctionToJSExportedDartFunction on Function {
116116
// This is a Symbol so that different Dart applications don't share Dart
117117
// objects from different Dart runtimes. We expect all JSBoxedDartObjects to
118118
// have this Symbol.
119-
final JSSymbol _jsBoxedDartObjectProperty = JSSymbol._(
120-
JSValue(
121-
js_helper.JS<WasmExternRef?>('() => Symbol("jsBoxedDartObjectProperty")'),
122-
),
123-
);
119+
final WasmExternRef? _jsBoxedDartObjectPropertyExternRef = js_helper
120+
.JS<WasmExternRef?>('() => Symbol("jsBoxedDartObjectProperty")');
124121

125122
// -----------------------------------------------------------------------------
126123
// JSBoxedDartObject <-> Object
@@ -131,7 +128,7 @@ extension JSBoxedDartObjectToObject on JSBoxedDartObject {
131128
final val = js_helper.JS<WasmExternRef?>(
132129
'(o,s) => o[s]',
133130
this.toExternRef,
134-
_jsBoxedDartObjectProperty.toExternRef,
131+
_jsBoxedDartObjectPropertyExternRef,
135132
);
136133
if (isDartNull(val)) {
137134
throw 'Expected a wrapped Dart object, but got a JS object or a wrapped '
@@ -152,7 +149,7 @@ extension ObjectToJSBoxedDartObject on Object {
152149
js_helper.JS<WasmExternRef?>(
153150
'(o,s,v) => o[s] = v',
154151
box.toExternRef,
155-
_jsBoxedDartObjectProperty.toExternRef,
152+
_jsBoxedDartObjectPropertyExternRef,
156153
jsObjectFromDartObject(this),
157154
);
158155
return JSBoxedDartObject._(box._jsObject);

0 commit comments

Comments
 (0)