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

Issue 2786083002: Read platform.dill in the VM. (Closed)

Created:
3 years, 8 months ago by Kevin Millikin (Google)
Modified:
3 years, 8 months ago
CC:
reviews_dartlang.org, dart-fe-team+reviews_google.com, vm-dev_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Read platform.dill in the VM. 1. A --platform flag is added to dart to give a path to a Kernel binary for the platform libraries (as produced by building the runtime_kernel target). 2. This binary is used for bootstrapping. Since it contains libraries other then the VM's bootstrap libraries, they are also loaded. 3. The frontend does not send any library with a dart: import URI scheme. Note that it does not (yet) prune the canonical name table, which will contain a lot of unnecessary names used for internal linkages in the platform libraries. 4. There is a single dependency in the platform libraries on the script: _getMainClosure in dart:_builtin. This is patched after the script is loaded. BUG= R=ahe@google.com, kustermann@google.com, vegorov@google.com Committed: https://github.com/dart-lang/sdk/commit/385f8fb054e85d642d7570291ad02eef1af34b8f

Patch Set 1 #

Patch Set 2 : Allow main to be a field or getter. #

Total comments: 30

Patch Set 3 : Incorporate review comments and merge. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+198 lines, -34 lines) Patch
M pkg/front_end/lib/src/fasta/fasta.dart View 1 2 2 chunks +12 lines, -3 lines 0 comments Download
M pkg/front_end/lib/src/fasta/kernel/kernel_target.dart View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M pkg/kernel/lib/binary/ast_to_binary.dart View 1 2 1 chunk +25 lines, -0 lines 0 comments Download
M runtime/bin/main.cc View 1 2 9 chunks +58 lines, -21 lines 0 comments Download
M runtime/vm/bootstrap.cc View 1 2 2 chunks +12 lines, -0 lines 0 comments Download
M runtime/vm/bootstrap_nocore.cc View 1 2 2 chunks +12 lines, -0 lines 0 comments Download
M runtime/vm/dart_api_impl.cc View 1 2 1 chunk +4 lines, -0 lines 0 comments Download
M runtime/vm/kernel.h View 1 2 4 chunks +10 lines, -3 lines 0 comments Download
M runtime/vm/kernel.cc View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M runtime/vm/kernel_binary.cc View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M runtime/vm/kernel_reader.h View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M runtime/vm/kernel_reader.cc View 1 2 2 chunks +24 lines, -2 lines 0 comments Download
M runtime/vm/kernel_to_il.cc View 1 2 1 chunk +29 lines, -1 line 0 comments Download
M runtime/vm/object_store.h View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M tests/co19/co19-kernel.status View 1 2 2 chunks +1 line, -1 line 0 comments Download
M tools/testing/dart/compiler_configuration.dart View 1 2 2 chunks +2 lines, -0 lines 0 comments Download

Messages

Total messages: 11 (3 generated)
Kevin Millikin (Google)
https://codereview.chromium.org/2786083002/diff/20001/pkg/front_end/lib/src/fasta/fasta.dart File pkg/front_end/lib/src/fasta/fasta.dart (right): https://codereview.chromium.org/2786083002/diff/20001/pkg/front_end/lib/src/fasta/fasta.dart#newcode155 pkg/front_end/lib/src/fasta/fasta.dart:155: class FrontEndBinaryPrinter extends BinaryPrinter { This is hacky and ...
3 years, 8 months ago (2017-03-31 10:05:42 UTC) #2
ahe
lgtm https://codereview.chromium.org/2786083002/diff/20001/pkg/front_end/lib/src/fasta/fasta.dart File pkg/front_end/lib/src/fasta/fasta.dart (right): https://codereview.chromium.org/2786083002/diff/20001/pkg/front_end/lib/src/fasta/fasta.dart#newcode155 pkg/front_end/lib/src/fasta/fasta.dart:155: class FrontEndBinaryPrinter extends BinaryPrinter { I think this ...
3 years, 8 months ago (2017-03-31 10:13:10 UTC) #4
ahe
I pressed LGTM too quickly: I only looked at the Dart code. Someone else should ...
3 years, 8 months ago (2017-03-31 10:13:40 UTC) #5
Kevin Millikin (Google)
Slava or Martin, do you want to look at the VM changes here?
3 years, 8 months ago (2017-04-05 09:11:46 UTC) #6
kustermann
lgtm https://codereview.chromium.org/2786083002/diff/20001/runtime/bin/main.cc File runtime/bin/main.cc (right): https://codereview.chromium.org/2786083002/diff/20001/runtime/bin/main.cc#newcode892 runtime/bin/main.cc:892: return NULL; Maybe 'delete isolate_data' here. https://codereview.chromium.org/2786083002/diff/20001/runtime/bin/main.cc#newcode931 runtime/bin/main.cc:931: ...
3 years, 8 months ago (2017-04-05 11:47:07 UTC) #7
Vyacheslav Egorov (Google)
lgtm I think we need to rigorously document which combinations of --platform, --dfe and input ...
3 years, 8 months ago (2017-04-05 12:21:23 UTC) #8
Kevin Millikin (Google)
Committed patchset #3 (id:40001) manually as 385f8fb054e85d642d7570291ad02eef1af34b8f (presubmit successful).
3 years, 8 months ago (2017-04-25 18:04:33 UTC) #10
Kevin Millikin (Google)
3 years, 8 months ago (2017-04-25 18:20:30 UTC) #11
Message was sent while issue was closed.
https://codereview.chromium.org/2786083002/diff/20001/runtime/bin/main.cc
File runtime/bin/main.cc (right):

https://codereview.chromium.org/2786083002/diff/20001/runtime/bin/main.cc#new...
runtime/bin/main.cc:349: use_platform_binary = true;
On 2017/04/05 12:21:23, Vyacheslav Egorov (Google) wrote:
> Should not this platform binary be also passed down to DFE isolate and
> subsequently Fasta to ensure that we are compiling and bootstrapping against
the
> same SDK?

Yes, let's add that in a separate change.

https://codereview.chromium.org/2786083002/diff/20001/runtime/bin/main.cc#new...
runtime/bin/main.cc:876: IsolateData* isolate_data =
On 2017/04/05 12:21:23, Vyacheslav Egorov (Google) wrote:
> Was there any reason to move isolate_data creation up here? Moving it down to
> where it was declared before allows to avoid memory leak.

I used it earlier in an intermediate state, but you are right that I can and
should move it back where it was.  Done.

https://codereview.chromium.org/2786083002/diff/20001/runtime/bin/main.cc#new...
runtime/bin/main.cc:892: return NULL;
On 2017/04/05 11:47:07, kustermann wrote:
> Maybe 'delete isolate_data' here.

Thank you.  Well spotted.

https://codereview.chromium.org/2786083002/diff/20001/runtime/bin/main.cc#new...
runtime/bin/main.cc:912: return NULL;
On 2017/04/05 12:21:23, Vyacheslav Egorov (Google) wrote:
> This leaks isolate data and kernel_platform.

Thank you.  Well spotted.  I delete kernel_platform here now.

https://codereview.chromium.org/2786083002/diff/20001/runtime/bin/main.cc#new...
runtime/bin/main.cc:931: kernel_platform != NULL
On 2017/04/05 11:47:07, kustermann wrote:
> Consider adding another case for 'kernel_program != NULL': If it still works,
we
> might want to keep support for it and add a test. It's easy to remove the
> support if we have a reason to break it.

Good suggestion, left for a separate change.

https://codereview.chromium.org/2786083002/diff/20001/runtime/vm/kernel.h
File runtime/vm/kernel.h (right):

https://codereview.chromium.org/2786083002/diff/20001/runtime/vm/kernel.h#new...
runtime/vm/kernel.h:981: void set_body(Statement* body) { body_ = body; }
On 2017/04/05 11:47:07, kustermann wrote:
> This only works if body_ is NULL before (Child<Statement>::operator= will
assert
> it), I guess this is always the case?

Yes.  We could assert, but since operator= does it isn't necessary.

https://codereview.chromium.org/2786083002/diff/20001/runtime/vm/kernel_reade...
File runtime/vm/kernel_reader.cc (right):

https://codereview.chromium.org/2786083002/diff/20001/runtime/vm/kernel_reade...
runtime/vm/kernel_reader.cc:149: // There is a function _getMainClosure in
dart:_builtin that returns the
On 2017/04/05 12:21:23, Vyacheslav Egorov (Google) wrote:
> On 2017/03/31 10:05:42, Kevin Millikin (Google) wrote:
> > I'm aware that this is ugly.  It would be better to either get rid of
> > _getMainClosure and just look up main in the root library, or else make
> > _getMainClosure a native so it's OK to have a 'magical' implementation.
> 
> We would also need to come up with solution for the future in which the flow
> graph builder is streaming from Binary and AST nodes do not exist anymore.

I know, and those changes started landing before this one.  I've updated this to
work by special casing StaticGet what doesn't come from the binary.

Agreed we need a better solution for the long term.

https://codereview.chromium.org/2786083002/diff/20001/runtime/vm/kernel_reade...
runtime/vm/kernel_reader.cc:155:
Function::Handle(builtin_library.LookupFunctionAllowPrivate(
On 2017/04/05 11:47:07, kustermann wrote:
> Handle(Z, 

Done.

https://codereview.chromium.org/2786083002/diff/20001/runtime/vm/kernel_reade...
runtime/vm/kernel_reader.cc:161: main_library->name()->size()));
On 2017/04/05 11:47:07, kustermann wrote:
> This "new String()" will never be freed afaik! (also for the other cases
below).
> 
> Please add a comment about it.

Comment added that we are leaking the whole body.

https://codereview.chromium.org/2786083002/diff/20001/runtime/vm/kernel_reade...
runtime/vm/kernel_reader.cc:169: procedure->function()->set_body(new
ReturnStatement(new StaticGet(name)));
On 2017/04/05 11:47:07, kustermann wrote:
> I assume the function has already a body (like nsm call) and you replace it
with
> the static tearoff, right?
> 
> In that case: set_body() will hit an ASSERT because it uses "Child<Statement>
> body_" and
> 
>                                                     
>  138 template <typename T>
>  ...
>  139 class Child {
>  147   T*& operator=(T* value) {
>  148     ASSERT(pointer_ == NULL);
>  149     return pointer_ = value;
>  150   }
> 

It doesn't have a body, it's treated as if it were external by special casing in
the front end.

https://codereview.chromium.org/2786083002/diff/20001/tools/testing/dart/comp...
File tools/testing/dart/compiler_configuration.dart (right):

https://codereview.chromium.org/2786083002/diff/20001/tools/testing/dart/comp...
tools/testing/dart/compiler_configuration.dart:217:
args.add('--platform=${buildDir}/patched_sdk/platform.dill');
On 2017/03/31 10:13:09, ahe wrote:
> How about creating an outline of the platform file and passing that to Fasta?

That's an excellent suggestion.  Let's discuss how to do it.

https://codereview.chromium.org/2786083002/diff/20001/tools/testing/dart/comp...
tools/testing/dart/compiler_configuration.dart:631:
args.add('--dfe=utils/kernel-service/kernel-service.dart');
On 2017/04/05 12:21:23, Vyacheslav Egorov (Google) wrote:
> this needs to be modified as well.

Done.

Powered by Google App Engine
This is Rietveld 408576698