Skip to content

Commit ac3b457

Browse files
rakudramacommit-bot@chromium.org
authored andcommitted
[dart2js] Ensure native lookup always initialized
The initialization is needed if there are no native classes but there are JS-interop calls. Change-Id: I7a66f75087be0200dfcc4ea60aa9b629c446616b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127801 Commit-Queue: Stephen Adams <sra@google.com> Reviewed-by: Mayank Patke <fishythefish@google.com>
1 parent 922a74c commit ac3b457

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -711,9 +711,7 @@ class FragmentEmitter {
711711
'variances': emitVariances(fragment),
712712
'sharedTypeRtis':
713713
_options.experimentNewRti ? TypeReferenceResource() : [],
714-
'nativeSupport': program.needsNativeSupport
715-
? emitNativeSupport(fragment)
716-
: new js.EmptyStatement(),
714+
'nativeSupport': emitNativeSupport(fragment),
717715
'jsInteropSupport': jsInteropAnalysis.buildJsInteropBootstrap(
718716
_codegenWorld, _closedWorld.nativeData, _namer) ??
719717
new js.EmptyStatement(),
@@ -2163,12 +2161,16 @@ class FragmentEmitter {
21632161
}
21642162
}
21652163

2166-
if (interceptorsByTag.isNotEmpty) {
2164+
// Emit the empty objects for main fragment in case we emit
2165+
// getNativeInterceptor.
2166+
// TODO(sra): Refine the impacts to accuratley predict whether we need this
2167+
// at all, and delete 'setOrUpdateInterceptorsByTag' if it is not called.
2168+
if (fragment.isMainFragment || interceptorsByTag.isNotEmpty) {
21672169
statements.add(js.js.statement(
21682170
"hunkHelpers.setOrUpdateInterceptorsByTag(#);",
21692171
js.objectLiteral(interceptorsByTag)));
21702172
}
2171-
if (leafTags.isNotEmpty) {
2173+
if (fragment.isMainFragment || leafTags.isNotEmpty) {
21722174
statements.add(js.js.statement(
21732175
"hunkHelpers.setOrUpdateLeafTags(#);", js.objectLiteral(leafTags)));
21742176
}

0 commit comments

Comments
 (0)