Skip to content

Commit 17ed3cb

Browse files
Anna Gringauzecommit-bot@chromium.org
authored andcommitted
[dart2js] Fix URI leak when using deferred load
Passed library name instead of URI to "checkDeferredLoad" in the generated JS. The URI was only used to report errors on library load at runtime - the user should be able to to find the URI in the dart import statemement instead. Closes #37623 Notes: - The URI is also stored in the deferred library's source map. If finding this information on load failure is too inconvenient, we might consider storing the URI in the main source map as well, and making sure that the URI is loaded from the source map on load failure at runtime, for better error reporting for users who have access to the source maps. - Not sure how much work is needed for this to be done, so leaving this until the need arises. Change-Id: I90caa560e7c57c61e810b9ca4cfc648cddba5905 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122200 Reviewed-by: Sigmund Cherem <sigmund@google.com> Commit-Queue: Anna Gringauze <annagrin@google.com>
1 parent 6ca96ac commit 17ed3cb

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

pkg/compiler/lib/src/ssa/builder_kernel.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,11 +1709,9 @@ class KernelSsaGraphBuilder extends ir.Visitor {
17091709
String loadId = closedWorld.outputUnitData.getImportDeferName(
17101710
_elementMap.getSpannable(targetElement, checkLoad), import);
17111711
HInstruction prefixConstant = graph.addConstantString(loadId, closedWorld);
1712-
HInstruction uriConstant =
1713-
graph.addConstantString('${import.uri}', closedWorld);
17141712
_pushStaticInvocation(
17151713
_commonElements.checkDeferredIsLoaded,
1716-
[prefixConstant, uriConstant],
1714+
[prefixConstant],
17171715
_typeInferenceMap
17181716
.getReturnTypeOf(_commonElements.checkDeferredIsLoaded),
17191717
const <DartType>[],

sdk/lib/_internal/js_runtime/lib/js_helper.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3074,9 +3074,9 @@ futureOrCheck(o, futureOrRti) => assertSubtypeOfRuntimeType(o, futureOrRti);
30743074
futureOrCast(o, futureOrRti) => subtypeOfRuntimeTypeCast(o, futureOrRti);
30753075

30763076
@pragma('dart2js:noInline')
3077-
void checkDeferredIsLoaded(String loadId, String uri) {
3077+
void checkDeferredIsLoaded(String loadId) {
30783078
if (!_loadedLibraries.contains(loadId)) {
3079-
throw new DeferredNotLoadedError(uri);
3079+
throw new DeferredNotLoadedError(loadId);
30803080
}
30813081
}
30823082

sdk_nnbd/lib/_internal/js_runtime/lib/js_helper.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,9 +3076,9 @@ futureOrCheck(o, futureOrRti) => assertSubtypeOfRuntimeType(o, futureOrRti);
30763076
futureOrCast(o, futureOrRti) => subtypeOfRuntimeTypeCast(o, futureOrRti);
30773077

30783078
@pragma('dart2js:noInline')
3079-
void checkDeferredIsLoaded(String loadId, String uri) {
3079+
void checkDeferredIsLoaded(String loadId) {
30803080
if (!_loadedLibraries.contains(loadId)) {
3081-
throw new DeferredNotLoadedError(uri);
3081+
throw new DeferredNotLoadedError(loadId);
30823082
}
30833083
}
30843084

0 commit comments

Comments
 (0)