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

Issue 25675002: Generative constructor factories for native objects (Closed)

Created:
7 years, 2 months ago by sra1
Modified:
7 years, 2 months ago
Reviewers:
ahe, ngeoffray, kasperl
CC:
reviews_dartlang.org, ahe, ngeoffray
Visibility:
Public.

Description

Generative constructor factories for native objects The generative constructor factory function 'upgrades' the pre-existing native object. Future improvements: 1. The lookup of the constructor function could be handled via some kind of reflection. When relection is finished, we should see if we can 'slice' it to provide the small footprint of the current table and lookup function. 2. Inlining of generative constructor bodies is disabled for native classes - it is broken and needs investigation. 3. dart2js should prevent 'new X.c()' where X.c is a native class generative constructor. 4. dart2js should warn on native class generative constructors that have arguments (the only scenario where arguments work is via superconstructor calls - this might be useful. I have not tested redirections.) R=kasperl@google.com Committed: https://code.google.com/p/dart/source/detail?r=28278

Patch Set 1 : #

Total comments: 3

Patch Set 2 : #

Total comments: 14

Patch Set 3 : #

Total comments: 19
Unified diffs Side-by-side diffs Delta from patch set Stats (+360 lines, -25 lines) Patch
M sdk/lib/_internal/compiler/implementation/elements/elements.dart View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/js_backend/backend.dart View 1 2 2 chunks +29 lines, -3 lines 2 comments Download
M sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart View 1 2 2 chunks +34 lines, -0 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/ssa/builder.dart View 1 2 12 chunks +75 lines, -13 lines 8 comments Download
M sdk/lib/_internal/compiler/implementation/ssa/codegen.dart View 1 2 chunks +11 lines, -1 line 4 comments Download
M sdk/lib/_internal/compiler/implementation/ssa/nodes.dart View 1 2 1 chunk +3 lines, -0 lines 0 comments Download
M sdk/lib/_internal/lib/interceptors.dart View 2 chunks +29 lines, -6 lines 5 comments Download
M tests/compiler/dart2js_native/oddly_named_fields_test.dart View 2 chunks +2 lines, -2 lines 0 comments Download
A tests/compiler/dart2js_native/subclassing_constructor_1_test.dart View 1 1 chunk +176 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
sra1
7 years, 2 months ago (2013-10-03 02:15:46 UTC) #1
ahe
Kasper, could you please take over this review? https://codereview.chromium.org/25675002/diff/13001/sdk/lib/_internal/compiler/implementation/enqueue.dart File sdk/lib/_internal/compiler/implementation/enqueue.dart (right): https://codereview.chromium.org/25675002/diff/13001/sdk/lib/_internal/compiler/implementation/enqueue.dart#newcode154 sdk/lib/_internal/compiler/implementation/enqueue.dart:154: registerStaticUse(member); ...
7 years, 2 months ago (2013-10-03 07:44:48 UTC) #2
sra1
https://codereview.chromium.org/25675002/diff/13001/sdk/lib/_internal/compiler/implementation/enqueue.dart File sdk/lib/_internal/compiler/implementation/enqueue.dart (right): https://codereview.chromium.org/25675002/diff/13001/sdk/lib/_internal/compiler/implementation/enqueue.dart#newcode154 sdk/lib/_internal/compiler/implementation/enqueue.dart:154: registerStaticUse(member); On 2013/10/03 07:44:49, ahe wrote: > This means ...
7 years, 2 months ago (2013-10-03 17:00:23 UTC) #3
sra1
Hi Kasper, PTAL. This is blocking and needs to land before the disruption of the ...
7 years, 2 months ago (2013-10-03 22:48:09 UTC) #4
kasperl
LGTM. So with this latest patch set we're only enqueuing generative constructors of native (or ...
7 years, 2 months ago (2013-10-04 11:08:42 UTC) #5
sra1
Committed patchset #3 manually as r28278 (presubmit successful).
7 years, 2 months ago (2013-10-04 20:21:08 UTC) #6
sra1
https://chromiumcodereview.appspot.com/25675002/diff/24001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart File sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (right): https://chromiumcodereview.appspot.com/25675002/diff/24001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart#newcode965 sdk/lib/_internal/compiler/implementation/js_backend/backend.dart:965: classElement.ensureResolved(compiler); On 2013/10/04 11:08:43, kasperl wrote: > You may ...
7 years, 2 months ago (2013-10-04 20:21:28 UTC) #7
ngeoffray
LGTM https://codereview.chromium.org/25675002/diff/37001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart File sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (right): https://codereview.chromium.org/25675002/diff/37001/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart#newcode965 sdk/lib/_internal/compiler/implementation/js_backend/backend.dart:965: // Web component classes have constructors that are ...
7 years, 2 months ago (2013-10-17 09:08:59 UTC) #8
sra1
7 years, 2 months ago (2013-10-18 04:09:31 UTC) #9
Message was sent while issue was closed.
https://chromiumcodereview.appspot.com/25675002/diff/37001/sdk/lib/_internal/...
File sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (right):

https://chromiumcodereview.appspot.com/25675002/diff/37001/sdk/lib/_internal/...
sdk/lib/_internal/compiler/implementation/js_backend/backend.dart:965: // Web
component classes have constructors that are escaped to the host
On 2013/10/17 09:08:59, ngeoffray wrote:
> Please define 'escape' here.

This code has been replaced.

https://chromiumcodereview.appspot.com/25675002/diff/37001/sdk/lib/_internal/...
File sdk/lib/_internal/compiler/implementation/ssa/builder.dart (right):

https://chromiumcodereview.appspot.com/25675002/diff/37001/sdk/lib/_internal/...
sdk/lib/_internal/compiler/implementation/ssa/builder.dart:278: bool
isNativeUpgradeFactory = element.isGenerativeConstructor()
On 2013/10/17 09:08:59, ngeoffray wrote:
> What is a native upgrade factory?

Added comment

https://chromiumcodereview.appspot.com/25675002/diff/37001/sdk/lib/_internal/...
sdk/lib/_internal/compiler/implementation/ssa/builder.dart:303:
value.instructionType = builder.getTypeOfThis();
On 2013/10/17 09:08:59, ngeoffray wrote:
> This seems very similar to the code line 281 to 295. What prevents the
sharing?
> Can't you just change line 291 to also check isNativeUpgradeFactory?

In the fixed version there are more differences, enough to make separate
branches no longer the the version you propose.

https://chromiumcodereview.appspot.com/25675002/diff/37001/sdk/lib/_internal/...
sdk/lib/_internal/compiler/implementation/ssa/builder.dart:1610: HInstruction
value = graph.addConstantNull(compiler);
On 2013/10/17 09:08:59, ngeoffray wrote:
> Avoid the temporary?

Done.

https://chromiumcodereview.appspot.com/25675002/diff/37001/sdk/lib/_internal/...
sdk/lib/_internal/compiler/implementation/ssa/builder.dart:1624:
fieldValues[member] = value;
On 2013/10/17 09:08:59, ngeoffray wrote:
> Avoid the temporary?

Done.

https://chromiumcodereview.appspot.com/25675002/diff/37001/sdk/lib/_internal/...
File sdk/lib/_internal/compiler/implementation/ssa/codegen.dart (right):

https://chromiumcodereview.appspot.com/25675002/diff/37001/sdk/lib/_internal/...
sdk/lib/_internal/compiler/implementation/ssa/codegen.dart:1799: js.Expression
constructor = new js.VariableUse(jsClassReference);
On 2013/10/17 09:08:59, ngeoffray wrote:
> Why this change?

It can be changed back.  Original formulation called the constructor instead of
new-ing it, but that had the bad effect of null-ing out native fields.

https://chromiumcodereview.appspot.com/25675002/diff/37001/sdk/lib/_internal/...
sdk/lib/_internal/compiler/implementation/ssa/codegen.dart:1825: // If the type
is a web component, we need to ensure the constructors are
On 2013/10/17 09:08:59, ngeoffray wrote:
> There's no check of 'web component' here. Maybe you should check it here and
> assert in 'regiterEscapingConstructorsOfClass'.

We now register the constant with the backend.

https://chromiumcodereview.appspot.com/25675002/diff/37001/sdk/lib/_internal/...
File sdk/lib/_internal/lib/interceptors.dart (right):

https://chromiumcodereview.appspot.com/25675002/diff/37001/sdk/lib/_internal/...
sdk/lib/_internal/lib/interceptors.dart:166: int
findIndexForWebComponentType(Type type) {
On 2013/10/17 09:08:59, ngeoffray wrote:
> I find the term web component too high level, and subject to change. Can't you
> just use Native or SubNative?

Done.

https://chromiumcodereview.appspot.com/25675002/diff/37001/sdk/lib/_internal/...
sdk/lib/_internal/lib/interceptors.dart:191:
findConstructorForWebComponentType(Type type, String name) {
On 2013/10/17 09:08:59, ngeoffray wrote:
> Same comment for web component.

Done.

Powered by Google App Engine
This is Rietveld 408576698