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

Issue 237583014: JS templates (Closed)

Created:
6 years, 8 months ago by sra1
Modified:
6 years, 7 months ago
Reviewers:
floitsch, kevmoo
CC:
reviews_dartlang.org, dart2js-team_google.com
Visibility:
Public.

Description

JS templates This CL mostly removes the 'fluent' API and replaces it with templates. The JS code is parsed and converted (compiled) into an instantiation function. The instantation function can be reused to stamp out similar copies. This has made the large helper functions more readable since they are now mostly real JavaScript code. Notes: 'if (#) stmt' adds a conditional statement if the argument is a Dart bool. It constructs the tree if the argument is a JS Expression. Fixed the statement template arguments so that '#;' is required. There is a template manager that reuses templates with the same source. This is persistent between compilation since the strings should be all 'constant'. I am currently hunting down the strings parsed by 'js(string)'. I have reduced it from 18k to O(500) for vampire. The blocker is the runtime type parameters system - it generates an AST, prints it, and reparses it, giving an unbounded number of small templates, mostly with no parameters. So these templates are not cached and pay the price of repeated compilation. R=floitsch@google.com Committed: https://code.google.com/p/dart/source/detail?r=35296

Patch Set 1 : mostly switched to templates #

Total comments: 3

Patch Set 2 : cleanup #

Total comments: 95

Patch Set 3 : add test file #

Total comments: 4

Patch Set 4 : Fix typos in comments and fix bug with native function #

Patch Set 5 : address code review #

Patch Set 6 : merge #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1949 lines, -1138 lines) Patch
M sdk/lib/_internal/compiler/implementation/js/builder.dart View 1 2 3 4 17 chunks +351 lines, -305 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js/js.dart View 1 chunk +1 line, -0 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js/nodes.dart View 1 2 3 4 4 chunks +49 lines, -95 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js/printer.dart View 1 2 3 4 2 chunks +20 lines, -7 lines 0 comments Download
A sdk/lib/_internal/compiler/implementation/js/template.dart View 1 2 3 4 1 chunk +676 lines, -0 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart View 1 2 3 4 5 chunks +14 lines, -18 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart View 1 2 3 4 4 chunks +8 lines, -11 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart View 1 2 3 4 7 chunks +48 lines, -30 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart View 1 2 3 4 13 chunks +309 lines, -338 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_emitter/container_builder.dart View 1 2 3 4 13 chunks +35 lines, -31 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_emitter/interceptor_emitter.dart View 11 chunks +80 lines, -120 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_emitter/metadata_emitter.dart View 3 chunks +5 lines, -5 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_emitter/nsm_emitter.dart View 1 2 3 4 4 chunks +117 lines, -102 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_emitter/reflection_data_parser.dart View 3 chunks +2 lines, -9 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_emitter/type_test_emitter.dart View 1 chunk +1 line, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/native_handler.dart View 1 2 3 4 chunks +14 lines, -7 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/ssa/builder.dart View 1 14 chunks +29 lines, -17 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/ssa/codegen.dart View 1 2 3 4 5 chunks +26 lines, -28 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/ssa/nodes.dart View 2 chunks +4 lines, -4 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/ssa/ssa_tracer.dart View 1 chunk +1 line, -1 line 0 comments Download
M sdk/lib/_internal/lib/isolate_helper.dart View 2 chunks +4 lines, -4 lines 0 comments Download
M sdk/lib/_internal/lib/js_helper.dart View 3 chunks +3 lines, -3 lines 0 comments Download
M sdk/lib/_internal/lib/js_mirrors.dart View 1 2 3 4 1 chunk +7 lines, -2 lines 0 comments Download
A tests/compiler/dart2js/js_parser_statements_test.dart View 1 2 3 1 chunk +145 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
sra1
I suggest starting with the documentation in js/builder.dart and the test file.
6 years, 8 months ago (2014-04-22 04:09:21 UTC) #1
floitsch
On 2014/04/22 04:09:21, sra1 wrote: > I suggest starting with the documentation in js/builder.dart > ...
6 years, 8 months ago (2014-04-22 13:07:49 UTC) #2
sra1
On 2014/04/22 13:07:49, floitsch wrote: > On 2014/04/22 04:09:21, sra1 wrote: > > I suggest ...
6 years, 8 months ago (2014-04-22 14:45:28 UTC) #3
floitsch
LGTM. https://codereview.chromium.org/237583014/diff/230001/sdk/lib/_internal/compiler/implementation/js/builder.dart File sdk/lib/_internal/compiler/implementation/js/builder.dart (right): https://codereview.chromium.org/237583014/diff/230001/sdk/lib/_internal/compiler/implementation/js/builder.dart#newcode16 sdk/lib/_internal/compiler/implementation/js/builder.dart:16: * TODO(sra): Find the remaining places where js('xxx') ...
6 years, 8 months ago (2014-04-22 16:11:17 UTC) #4
sra1
Thanks for the review. Now I try to land it :-) https://chromiumcodereview.appspot.com/237583014/diff/230001/sdk/lib/_internal/compiler/implementation/js/builder.dart File sdk/lib/_internal/compiler/implementation/js/builder.dart (right): ...
6 years, 8 months ago (2014-04-23 02:33:49 UTC) #5
sra1
Committed patchset #6 manually as r35296 (presubmit successful).
6 years, 8 months ago (2014-04-23 03:33:15 UTC) #6
floitsch
https://chromiumcodereview.appspot.com/237583014/diff/230001/sdk/lib/_internal/compiler/implementation/js/template.dart File sdk/lib/_internal/compiler/implementation/js/template.dart (right): https://chromiumcodereview.appspot.com/237583014/diff/230001/sdk/lib/_internal/compiler/implementation/js/template.dart#newcode610 sdk/lib/_internal/compiler/implementation/js/template.dart:610: throw 'Should not get here'; // Handled in visitArrayInitializer. ...
6 years, 8 months ago (2014-04-23 07:29:41 UTC) #7
ahe
https://chromiumcodereview.appspot.com/237583014/diff/230001/sdk/lib/_internal/compiler/implementation/js/template.dart File sdk/lib/_internal/compiler/implementation/js/template.dart (right): https://chromiumcodereview.appspot.com/237583014/diff/230001/sdk/lib/_internal/compiler/implementation/js/template.dart#newcode610 sdk/lib/_internal/compiler/implementation/js/template.dart:610: throw 'Should not get here'; // Handled in visitArrayInitializer. ...
6 years, 8 months ago (2014-04-23 08:38:14 UTC) #8
kevmoo
6 years, 7 months ago (2014-05-12 04:19:33 UTC) #9
Message was sent while issue was closed.
DBC

https://codereview.chromium.org/237583014/diff/210001/sdk/lib/_internal/compi...
File sdk/lib/_internal/compiler/implementation/js/builder.dart (right):

https://codereview.chromium.org/237583014/diff/210001/sdk/lib/_internal/compi...
sdk/lib/_internal/compiler/implementation/js/builder.dart:201: Expression
call(String source, [var arguments]) {
var is unneeded here

https://codereview.chromium.org/237583014/diff/210001/sdk/lib/_internal/compi...
sdk/lib/_internal/compiler/implementation/js/builder.dart:207: Statement
statement(String source, [var arguments]) {
var is unneeded here

https://codereview.chromium.org/237583014/diff/210001/sdk/lib/_internal/compi...
File sdk/lib/_internal/compiler/implementation/js/template.dart (right):

https://codereview.chromium.org/237583014/diff/210001/sdk/lib/_internal/compi...
sdk/lib/_internal/compiler/implementation/js/template.dart:33: var n =
((statementTemplates.length == prev) ? '-' : '${statementTemplates.length}')
long line

Powered by Google App Engine
This is Rietveld 408576698