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

Issue 969093002: dart2js: Allow to encode side-effects in the spec-string of JS and similar built-ins. (Closed)

Created:
5 years, 9 months ago by floitsch
Modified:
5 years, 8 months ago
Reviewers:
herhut, sra1
CC:
reviews_dartlang.org, Johnni Winther, zarah
Target Ref:
refs/remotes/git-svn
Visibility:
Public.

Description

dart2js: Allow to encode side-effects in the spec-string of JS and similar built-ins. This patch prepares a shift towards two builtins. We currently have ~20 foreign functions that must be caught by the resolver, type-inferrer, builder, ... In the future there will be only two: JS(...), and JS_BUILTIN(...) The JS_BUILTIN function would take a string or enum as second argument (after the spec-string) which would be shared between the runtime and the compiler. This makes it easier to ensure that no builtin is forgotten in the places where they need to be handled. This patch also gives more flexibility to the implementor. For example `JS('bool', 'typeof self["foo"] != "undefined"')` would currently trigger a "depends on index store". With this patch the developer could override the automatic side-effect analysis and force the dependency to be empty. Note: in theory we could make "JS" a BUILTIN itself, but, given its importance, I prefer to keep it separate. Note2: with the "ForceInline" CL [0] we can keep the old functions (like "JS_GET_FLAG") and just forward to JS_BUILTIN: @ForceInline() bool JS_GET_FLAG(String name) { // Given: a shared enum `Builtin`. return JS_BUILTIN('bool', Builtin.getFlag, name); } [0] https://chromiumcodereview.appspot.com/962703004/ R=herhut@google.com, sra@google.com Committed: https://code.google.com/p/dart/source/detail?r=44229

Patch Set 1 #

Patch Set 2 : Fix long lines. #

Total comments: 8

Patch Set 3 : Fix type annotations #

Total comments: 16

Patch Set 4 : Fix type-annotation (again). #

Patch Set 5 : Address comments. #

Patch Set 6 : Fix another bad type annotation. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+420 lines, -90 lines) Patch
M pkg/compiler/lib/src/native/behavior.dart View 1 2 3 4 5 12 chunks +130 lines, -18 lines 0 comments Download
M pkg/compiler/lib/src/universe/side_effects.dart View 2 chunks +45 lines, -24 lines 0 comments Download
M sdk/lib/_internal/compiler/js_lib/foreign_helper.dart View 1 2 3 4 2 chunks +69 lines, -35 lines 0 comments Download
M tests/compiler/dart2js/js_spec_string_test.dart View 1 2 3 4 3 chunks +176 lines, -13 lines 0 comments Download

Messages

Total messages: 10 (1 generated)
floitsch
5 years, 9 months ago (2015-03-02 20:48:47 UTC) #2
herhut
lgtm https://codereview.chromium.org/969093002/diff/20001/pkg/compiler/lib/src/native/behavior.dart File pkg/compiler/lib/src/native/behavior.dart (right): https://codereview.chromium.org/969093002/diff/20001/pkg/compiler/lib/src/native/behavior.dart#newcode86 pkg/compiler/lib/src/native/behavior.dart:86: /// used in unison (either both are present ...
5 years, 9 months ago (2015-03-02 21:34:51 UTC) #3
floitsch
First patch set had bad type-annotations. ('void' instead of 'DartType'). I will address the other ...
5 years, 9 months ago (2015-03-02 22:18:07 UTC) #4
floitsch
On 2015/03/02 22:18:07, floitsch wrote: > First patch set had bad type-annotations. ('void' instead of ...
5 years, 9 months ago (2015-03-02 22:18:19 UTC) #5
sra1
lgtm with comment on declaration of JS. https://codereview.chromium.org/969093002/diff/40001/pkg/compiler/lib/src/native/behavior.dart File pkg/compiler/lib/src/native/behavior.dart (right): https://codereview.chromium.org/969093002/diff/40001/pkg/compiler/lib/src/native/behavior.dart#newcode63 pkg/compiler/lib/src/native/behavior.dart:63: /// result ...
5 years, 9 months ago (2015-03-03 01:49:50 UTC) #6
floitsch
PTAL. (If there aren't any comments I will probably commit tomorrow, but then do follow-up ...
5 years, 9 months ago (2015-03-03 19:53:19 UTC) #7
sra1
LGTM! I'm excited to try it!
5 years, 9 months ago (2015-03-03 21:37:36 UTC) #8
floitsch
Committed patchset #6 (id:100001) manually as 44229 (presubmit successful).
5 years, 9 months ago (2015-03-04 13:21:03 UTC) #9
floitsch
5 years, 8 months ago (2015-03-31 05:01:41 UTC) #10
Message was sent while issue was closed.
Reviving this CL...

Lots of the runtime is too "low-level". I started refactoring it.
This approach also allows to add more builtins more easily (which is something I
need to give the lazy emitter behave differently on some things).

PTAL and tell me if I'm on the right track.

Powered by Google App Engine
This is Rietveld 408576698