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

Issue 8486015: Adds support for indexing of JS files (Closed)

Created:
9 years, 1 month ago by mmendez
Modified:
9 years, 1 month ago
Reviewers:
zundel, codefu, fabiomfv
CC:
reviews_dartlang.org
Visibility:
Public.

Description

This is not meant to be a general purpose indexer, but it is meant to be sufficient for conservative tree shaking of dartc generated JS code and the native code of the various libraries. Committed: https://code.google.com/p/dart/source/detail?r=1656

Patch Set 1 #

Total comments: 16

Patch Set 2 : Updates based on zundel and codefu's feedback. #

Total comments: 2

Patch Set 3 : Added missing newline #

Total comments: 16

Patch Set 4 : Address fabiomfv's feedback #

Unified diffs Side-by-side diffs Delta from patch set Stats (+662 lines, -0 lines) Patch
A compiler/java/com/google/dart/compiler/backend/js/analysis/JavascriptElement.java View 1 2 3 1 chunk +130 lines, -0 lines 0 comments Download
A compiler/java/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexer.java View 1 2 3 1 chunk +283 lines, -0 lines 0 comments Download
A compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java View 1 2 1 chunk +249 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
mmendez
This is the first of several commits which will introduce tree shaking into the dartc ...
9 years, 1 month ago (2011-11-16 16:59:42 UTC) #1
codefu
Other than the one nit, LGTM http://codereview.chromium.org/8486015/diff/1/compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java File compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java (right): http://codereview.chromium.org/8486015/diff/1/compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java#newcode70 compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java:70: // A will ...
9 years, 1 month ago (2011-11-17 15:18:22 UTC) #2
zundel
LGTM, just nits http://codereview.chromium.org/8486015/diff/1/compiler/java/com/google/dart/compiler/backend/js/analysis/JavascriptElement.java File compiler/java/com/google/dart/compiler/backend/js/analysis/JavascriptElement.java (right): http://codereview.chromium.org/8486015/diff/1/compiler/java/com/google/dart/compiler/backend/js/analysis/JavascriptElement.java#newcode62 compiler/java/com/google/dart/compiler/backend/js/analysis/JavascriptElement.java:62: public int getLength() { Most of ...
9 years, 1 month ago (2011-11-17 18:20:32 UTC) #3
mmendez
Updated patch attached. http://codereview.chromium.org/8486015/diff/1/compiler/java/com/google/dart/compiler/backend/js/analysis/JavascriptElement.java File compiler/java/com/google/dart/compiler/backend/js/analysis/JavascriptElement.java (right): http://codereview.chromium.org/8486015/diff/1/compiler/java/com/google/dart/compiler/backend/js/analysis/JavascriptElement.java#newcode62 compiler/java/com/google/dart/compiler/backend/js/analysis/JavascriptElement.java:62: public int getLength() { Yeah, the ...
9 years, 1 month ago (2011-11-17 18:48:00 UTC) #4
zundel
still LGTM w/ nit http://codereview.chromium.org/8486015/diff/5001/compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java File compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java (right): http://codereview.chromium.org/8486015/diff/5001/compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java#newcode177 compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java:177: public void testTopLevelFunctions() { missing ...
9 years, 1 month ago (2011-11-17 18:54:18 UTC) #5
mmendez
Updated patch http://codereview.chromium.org/8486015/diff/5001/compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java File compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java (right): http://codereview.chromium.org/8486015/diff/5001/compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java#newcode177 compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java:177: public void testTopLevelFunctions() { On 2011/11/17 18:54:18, ...
9 years, 1 month ago (2011-11-17 19:38:59 UTC) #6
fabiomfv
LGTM! some nits. I would be nice if you could write in the CL description ...
9 years, 1 month ago (2011-11-17 20:41:27 UTC) #7
mmendez
9 years, 1 month ago (2011-11-17 21:44:25 UTC) #8
I still have 2 more CLs to land to enable the "incremental" tree shaking.  I'll
update that CL with the final code size reductions for incremental tree shaking.

http://codereview.chromium.org/8486015/diff/2003/compiler/java/com/google/dar...
File
compiler/java/com/google/dart/compiler/backend/js/analysis/JavascriptElement.java
(right):

http://codereview.chromium.org/8486015/diff/2003/compiler/java/com/google/dar...
compiler/java/com/google/dart/compiler/backend/js/analysis/JavascriptElement.java:96:
* expression is found "Array.prototype.XXX = function(){}".
This comment belongs on line 103.

We do need to know if a member was instantiated, used in a new expression and we
assume that "JS" native classes are always instantiated.
On 2011/11/17 20:41:27, fabiomfv wrote:
> why we need this again? should the example you mentioned in the comment be
> something else?

http://codereview.chromium.org/8486015/diff/2003/compiler/java/com/google/dar...
compiler/java/com/google/dart/compiler/backend/js/analysis/JavascriptElement.java:103:
public boolean isNative() {
On 2011/11/17 20:41:27, fabiomfv wrote:
> pls add a comment explaining what native means in this context (it has nothing
> to do with dart 'native' but with js 'built-in' types).

Done.

http://codereview.chromium.org/8486015/diff/2003/compiler/java/com/google/dar...
File
compiler/java/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexer.java
(right):

http://codereview.chromium.org/8486015/diff/2003/compiler/java/com/google/dar...
compiler/java/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexer.java:38:
private final LinkedList<String> identifiers = new LinkedList<String>();
Loosened to Deque.

On 2011/11/17 20:41:27, fabiomfv wrote:
> nit. List<String> on left side.

http://codereview.chromium.org/8486015/diff/2003/compiler/java/com/google/dar...
compiler/java/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexer.java:88:
public static void printGlobals(List<AstNode> globals) {
That is true.  On the other hand since it is a static method there is no harm in
leaving it in place since it does not introduce any warnings into the code.

We should discuss offline so we can approach consistency.
On 2011/11/17 20:41:27, fabiomfv wrote:
> nit. since this is debugging code, we could comment it out.

http://codereview.chromium.org/8486015/diff/2003/compiler/java/com/google/dar...
compiler/java/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexer.java:97:
public static void printNamesToElements(Map<String, List<JavascriptElement>>
namesToElements) {
See above.
On 2011/11/17 20:41:27, fabiomfv wrote:
> nit. same here.

http://codereview.chromium.org/8486015/diff/2003/compiler/java/com/google/dar...
compiler/java/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexer.java:176:
if ("RunEntry".equals(targetName.getIdentifier())) {
On 2011/11/17 20:41:27, fabiomfv wrote:
> nit. it would be nice to put "RunEntry" is in a class const instead of
> hardcoded.

Done.

http://codereview.chromium.org/8486015/diff/2003/compiler/java/com/google/dar...
compiler/java/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexer.java:192:
subtypeFunction.setInherits(namesToElements.get(supertype.getIdentifier()).get(0));
We treat missing supertypes as errors now.  So, I don't think this could happen.
 Even in the generate-code-in-the-presence-of-errors scenario.

On 2011/11/17 20:41:27, fabiomfv wrote:
> I wonder if 'shouldWarnOnNoSuchType' option is on if there may be a case where
> super type name is missing and cause a npe.could you double check?

http://codereview.chromium.org/8486015/diff/2003/compiler/javatests/com/googl...
File
compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java
(right):

http://codereview.chromium.org/8486015/diff/2003/compiler/javatests/com/googl...
compiler/javatests/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexerTest.java:235:
assertEquals(3, namesToElements.size());
We add entries into the map for Array, Array.prototype.foo and foo.  Array is an
implicit native object, and the remaining two entries deal with the static and
virtual references to foo.

On 2011/11/17 20:41:27, fabiomfv wrote:
> curiosity - why should it be 3?

Powered by Google App Engine
This is Rietveld 408576698