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

Issue 12210127: First stab at mixins in VM compiler (Closed)

Created:
7 years, 10 months ago by hausner
Modified:
7 years, 10 months ago
Reviewers:
kasperl, siva
CC:
reviews_dartlang.org, Ivan Posva
Visibility:
Public.

Description

First stab at mixins in VM compiler Things not yet supported: - Type parameters for super class and mixin class - super call limitation check Committed: https://code.google.com/p/dart/source/detail?r=18479

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Total comments: 14

Patch Set 4 : #

Patch Set 5 : #

Patch Set 6 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+412 lines, -77 lines) Patch
M runtime/vm/class_finalizer.h View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/class_finalizer.cc View 1 2 3 4 5 4 chunks +78 lines, -5 lines 0 comments Download
M runtime/vm/object.h View 1 2 3 4 5 8 chunks +18 lines, -3 lines 0 comments Download
M runtime/vm/object.cc View 1 2 3 4 5 6 chunks +79 lines, -0 lines 0 comments Download
M runtime/vm/parser.h View 1 2 3 4 5 5 chunks +8 lines, -2 lines 0 comments Download
M runtime/vm/parser.cc View 1 2 3 4 5 15 chunks +216 lines, -33 lines 0 comments Download
M runtime/vm/raw_object.h View 1 2 3 4 5 3 chunks +5 lines, -2 lines 0 comments Download
M runtime/vm/symbols.h View 1 2 3 4 5 1 chunk +3 lines, -0 lines 0 comments Download
M runtime/vm/token.h View 1 2 3 4 5 2 chunks +4 lines, -3 lines 0 comments Download
M tests/language/language.status View 1 2 3 4 5 2 chunks +0 lines, -29 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
hausner
7 years, 10 months ago (2013-02-12 01:17:49 UTC) #1
kasperl
If you have some (failing) tests for the field initialization across library boundaries, it would ...
7 years, 10 months ago (2013-02-12 19:32:45 UTC) #2
hausner
Found a simple way to implement the super call limitation check.
7 years, 10 months ago (2013-02-12 19:42:30 UTC) #3
hausner
7 years, 10 months ago (2013-02-12 23:11:45 UTC) #4
siva
LGTM with one question about whether 'S with M,M' is an error? https://codereview.chromium.org/12210127/diff/11001/runtime/vm/class_finalizer.cc File runtime/vm/class_finalizer.cc ...
7 years, 10 months ago (2013-02-13 01:34:37 UTC) #5
hausner
7 years, 10 months ago (2013-02-13 19:58:14 UTC) #6
Slight change in the class finalizer after discussing the process with Regis.

https://codereview.chromium.org/12210127/diff/11001/runtime/vm/class_finalize...
File runtime/vm/class_finalizer.cc (right):

https://codereview.chromium.org/12210127/diff/11001/runtime/vm/class_finalize...
runtime/vm/class_finalizer.cc:1259: ReportError(script, cls.token_pos(),
On 2013/02/13 01:34:37, siva wrote:
> I am wondering if it would be more helpful if you also reported the script and
> token position of the original mixin class here.

I thought it makes more sense to report it where the class is used as a mixin
(i.e. at the keyword "with"). Ideally we should have a way to report two
locations. Since we can only report one location, the user may have to search
for one or the other related location.

https://codereview.chromium.org/12210127/diff/11001/runtime/vm/class_finalize...
runtime/vm/class_finalizer.cc:1273: ReportError(script, cls.token_pos(),
On 2013/02/13 01:34:37, siva wrote:
> Ditto.
Ditto.

https://codereview.chromium.org/12210127/diff/11001/runtime/vm/class_finalize...
runtime/vm/class_finalizer.cc:1283: cls.AddFunction(func);
I agree with what you suggest, but let me check it in this way so Mixins get
picked up by M3. I will make this more efficient with a follow-up changelist.

On 2013/02/13 01:34:37, siva wrote:
> Our AddFunction implementation is very inefficient, In this case it might make
> sense to create a cloned_functions array (similar to cloned_fields below) and
> add the implicit constructor which should probably be the only function in cls
> to the list.

https://codereview.chromium.org/12210127/diff/11001/runtime/vm/class_finalize...
runtime/vm/class_finalizer.cc:1298: fields = Array::MakeArray(cloned_fields);
On 2013/02/13 01:34:37, siva wrote:
> Maybe we should assert here that
> ASSERT(cls.fields() == Array::null());

Done.

https://codereview.chromium.org/12210127/diff/11001/runtime/vm/object.h
File runtime/vm/object.h (right):

https://codereview.chromium.org/12210127/diff/11001/runtime/vm/object.h#newco...
runtime/vm/object.h:1203: RawClass* origin() const;
I noticed that too. Technically, according to our coding standards, it would
have to be Origin() and Script() since the methods are more than simple
accessors. I never got that rule, since all the advantages of hiding the
implementation details of an accessor are lost if you have to change the
accessor name when the implementation changes. I prefer the lower case versions.

On 2013/02/13 01:34:37, siva wrote:
> Our function naming style seems in consistent. I am wondering if origin and
> script need to be Origin and Script (I am not suggesting you rename them in
this
> CL just noting that we are already inconsistent).

https://codereview.chromium.org/12210127/diff/11001/runtime/vm/parser.cc
File runtime/vm/parser.cc (right):

https://codereview.chromium.org/12210127/diff/11001/runtime/vm/parser.cc#newc...
runtime/vm/parser.cc:3844: }
I discussed that with Gilad. He says it's perfectly legal to have a class in the
mixin chain more than once. The effect is that each time the class is mixed in
all its methods are overwritten again. It's basically a no-op that wastes
memory. OTOH, we explicitly forbid listing the same interface twice in the
implements clause... ;-)
On 2013/02/13 01:34:37, siva wrote:
> How do you handle 'S with M,N,M' or 'S with M,M' is it an error to repeat the
> mixins?

https://codereview.chromium.org/12210127/diff/11001/runtime/vm/parser.cc#newc...
runtime/vm/parser.cc:3851: String::Handle(String::New("&")));
I thought about this and didn't think this is used often enough where it makes
sense to pollute the symbol table. But .... Done. Looking at the symbol table
code I see that there is already a space for each one character string anyway.


On 2013/02/13 01:34:37, siva wrote:
> Maybe add a Symbols::Ampersand() method similar to Symbols::Dot() etc. and use
> that here instead of String::Handle(String::New("&"))

Powered by Google App Engine
This is Rietveld 408576698