Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Issue 142193005: Fix JS-backend when MirrorsUsed target a static field, but there is no mirrors usage. (Closed)

Created:
6 years, 10 months ago by floitsch
Modified:
6 years, 9 months ago
Reviewers:
Johnni Winther, kasperl
CC:
reviews_dartlang.org, kasperl
Visibility:
Public.

Description

Fix JS-backend when MirrorsUsed target a static field, but there is no mirrors usage. r31964 (https://codereview.chromium.org/141753002) ensures that type-declarations are resolved, but that wasn't the case for static fields that weren't referenced except through "MirrorsUsed". Dart2Js didn't resolve or compile the static, but then tried to emit its getters/setters (which ended up calling the "_resolveTypeDeclaration" in members.dart). With this patch we always enqueue static variables that are referenced by MirrorsUsed. If the user doesn't use mirrors it will increase the code-size (slightly) but that should be a rare case. R=johnniwinther@google.com, kasperl@google.com Committed: https://code.google.com/p/dart/source/detail?r=32159

Patch Set 1 #

Patch Set 2 : Use more common variable names. #

Patch Set 3 : Deal with libraries and classes in MirrorsUsed. #

Patch Set 4 : One more test. #

Total comments: 1

Patch Set 5 : Fix testing framework. #

Total comments: 8

Patch Set 6 : Add another test. #

Patch Set 7 : Update copyright year. #

Total comments: 4

Patch Set 8 : Address comments. #

Total comments: 2

Patch Set 9 : Extract function that finds static field targets. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+261 lines, -13 lines) Patch
M sdk/lib/_internal/compiler/implementation/enqueue.dart View 3 chunks +13 lines, -3 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_backend/backend.dart View 1 2 3 4 5 6 7 8 1 chunk +35 lines, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart View 1 2 3 4 5 6 7 1 chunk +2 lines, -7 lines 0 comments Download
M tests/compiler/dart2js/mirror_tree_shaking_test.dart View 1 2 3 4 1 chunk +2 lines, -2 lines 0 comments Download
A tests/lib/mirrors/unused_mirrors2_test.dart View 1 2 3 4 5 6 1 chunk +23 lines, -0 lines 0 comments Download
A tests/lib/mirrors/unused_mirrors3_test.dart View 1 2 3 4 5 6 1 chunk +25 lines, -0 lines 0 comments Download
A tests/lib/mirrors/unused_mirrors4_test.dart View 1 2 3 4 5 6 1 chunk +21 lines, -0 lines 0 comments Download
A tests/lib/mirrors/unused_mirrors5_test.dart View 1 2 3 4 5 6 1 chunk +23 lines, -0 lines 0 comments Download
A tests/lib/mirrors/unused_mirrors6_test.dart View 1 2 3 4 5 6 1 chunk +25 lines, -0 lines 0 comments Download
A tests/lib/mirrors/unused_mirrors7_test.dart View 1 2 3 4 5 6 1 chunk +21 lines, -0 lines 0 comments Download
A tests/lib/mirrors/unused_mirrors8_test.dart View 1 2 3 4 5 6 1 chunk +25 lines, -0 lines 0 comments Download
A tests/lib/mirrors/unused_mirrors9_test.dart View 1 2 3 4 5 6 1 chunk +25 lines, -0 lines 0 comments Download
A tests/lib/mirrors/unused_mirrors_test.dart View 1 2 3 4 5 6 1 chunk +21 lines, -0 lines 0 comments Download

Messages

Total messages: 12 (0 generated)
floitsch
6 years, 10 months ago (2014-01-29 23:07:23 UTC) #1
floitsch
Forgot to take libraries and classes into account. Uploaded new patch set. https://codereview.chromium.org/142193005/diff/60001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart File sdk/lib/_internal/compiler/implementation/js_backend/backend.dart ...
6 years, 10 months ago (2014-01-29 23:32:13 UTC) #2
Johnni Winther
You talk about static fields but only test for top-level fields. https://codereview.chromium.org/142193005/diff/80001/tests/lib/mirrors/unused_mirrors5_test.dart File tests/lib/mirrors/unused_mirrors5_test.dart (right): ...
6 years, 10 months ago (2014-01-30 11:47:18 UTC) #3
floitsch
Static fields inside classes should work too. https://codereview.chromium.org/142193005/diff/80001/tests/lib/mirrors/unused_mirrors5_test.dart File tests/lib/mirrors/unused_mirrors5_test.dart (right): https://codereview.chromium.org/142193005/diff/80001/tests/lib/mirrors/unused_mirrors5_test.dart#newcode1 tests/lib/mirrors/unused_mirrors5_test.dart:1: // Copyright ...
6 years, 10 months ago (2014-01-30 12:27:22 UTC) #4
kasperl
https://codereview.chromium.org/142193005/diff/120001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart File sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (right): https://codereview.chromium.org/142193005/diff/120001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart#newcode1759 sdk/lib/_internal/compiler/implementation/js_backend/backend.dart:1759: List staticFields = []; If you only need them ...
6 years, 10 months ago (2014-01-30 13:37:14 UTC) #5
floitsch
PTAL. https://codereview.chromium.org/142193005/diff/120001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart File sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (right): https://codereview.chromium.org/142193005/diff/120001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart#newcode1759 sdk/lib/_internal/compiler/implementation/js_backend/backend.dart:1759: List staticFields = []; On 2014/01/30 13:37:15, kasperl ...
6 years, 10 months ago (2014-01-30 14:10:23 UTC) #6
kasperl
LGTM. https://codereview.chromium.org/142193005/diff/140001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart File sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (right): https://codereview.chromium.org/142193005/diff/140001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart#newcode1755 sdk/lib/_internal/compiler/implementation/js_backend/backend.dart:1755: } else if (!targetsUsed.isEmpty && enqueuer.isResolutionQueue) { I'd ...
6 years, 10 months ago (2014-01-30 14:14:47 UTC) #7
Johnni Winther
lgtm
6 years, 10 months ago (2014-01-30 14:34:18 UTC) #8
floitsch
https://codereview.chromium.org/142193005/diff/140001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart File sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (right): https://codereview.chromium.org/142193005/diff/140001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart#newcode1755 sdk/lib/_internal/compiler/implementation/js_backend/backend.dart:1755: } else if (!targetsUsed.isEmpty && enqueuer.isResolutionQueue) { On 2014/01/30 ...
6 years, 10 months ago (2014-01-30 15:03:45 UTC) #9
floitsch
Committed patchset #9 manually as r32159 (presubmit successful).
6 years, 10 months ago (2014-01-30 15:04:40 UTC) #10
floitsch
LGTM. minimal example: === @MirrorsUsed(targets: const ["foo"]) import 'dart:mirrors'; final foo = reflect(reflect(9)).getField(#getField); void main() ...
6 years, 9 months ago (2014-03-25 10:12:34 UTC) #11
floitsch
6 years, 9 months ago (2014-03-25 10:12:51 UTC) #12
Message was sent while issue was closed.
On 2014/03/25 10:12:34, floitsch wrote:
> LGTM.
> 
> minimal example:
> ===
> @MirrorsUsed(targets: const ["foo"])
> import 'dart:mirrors';
> 
> final foo = reflect(reflect(9)).getField(#getField);
> 
> void main() {}
> ===

never mind. wrong CL.

Powered by Google App Engine
This is Rietveld 408576698