Commit Graph

64 Commits

Author SHA1 Message Date
Jens Johansen 4bbda48a7c [kernel] Stream everything. Replace .kernel_function with .kernel_offset
- Put pointer to kernel data into Script.
- Replace function.kernel_function pointer to AstNode with
  kernel_offset():
- Replace field.kernel_field pointer to AstNode with kernel_offest().
- Stream the previously unstreamed AstNodes: FunctionDeclaration and
  FunctionExpression.
- Move special handling for _buildin.getMainClosure into the streaming
  flowgraph builder.
- Delete big parts of kernel_to_il.

R=kmillikin@google.com

Committed: https://github.com/dart-lang/sdk/commit/948e2f5d7916032ed6f0bfdc316ba4f577a5ea61
Review-Url: https://codereview.chromium.org/2901533002 .
2017-06-14 10:59:57 +02:00
Jens Johansen de5ebc5a4e Revert "[kernel] Stream everything. Replace .kernel_function with .kernel_offset"
The commit somehow made e.g. vm-linux-release-ia32-be turn red.

This reverts commit 948e2f5d79.

BUG=

Review-Url: https://codereview.chromium.org/2941483003 .
2017-06-14 09:12:38 +02:00
Jens Johansen 948e2f5d79 [kernel] Stream everything. Replace .kernel_function with .kernel_offset
- Put pointer to kernel data into Script.
- Replace function.kernel_function pointer to AstNode with
  kernel_offset():
- Replace field.kernel_field pointer to AstNode with kernel_offest().
- Stream the previously unstreamed AstNodes: FunctionDeclaration and
  FunctionExpression.
- Move special handling for _buildin.getMainClosure into the streaming
  flowgraph builder.
- Delete big parts of kernel_to_il.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2901533002 .
2017-06-14 08:27:21 +02:00
Jens Johansen 76336b225f [kernel] Streaming ScopeBuilder
The old ScopeBuilder is replaced with StreamingScopeBuilder
that does not use the Ast.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2886873008 .
2017-06-13 11:39:31 +02:00
Asger Feldthaus 1ea216e6de Add metadata annotations to library definitions.
BUG=
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2893803003 .
2017-05-19 11:35:26 +02:00
Asger Feldthaus 876db33bf4 Add import/export declaration AST node boilerplate to kernel.
Previously only deferred imports were represented. They have been
merged with the general form.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2852373002 .
2017-05-18 14:38:08 +02:00
Jens Johansen d26558b7be [kernel] [partial] Streaming of kernel binary without AST nodes
This CL allows for streaming big parts of the binary,
i.e. without using the AST nodes.
It is thus a stepping-stone in getting rid of the AST nodes in the VM.

Generally, all Expressions except "FunctionExpression",
and all Statements except "FunctionDeclaration" can be streamed.

There are currently not streamed because they create new functions,
which has a pointer to an AstNode (which we don't have when streaming).

Once we no longer need AstNodes at all these can be streamed as well.
This is, I think, mostly a matter of streaming the ScopeBuilder as well,
something that is not currently done.

The way the streaming is build, one has to stream an entire subtree.
That means, that if an expression (or statement), A, that is generally
streamable contains an expression or a statement, B, that is not streamable,
A cannot be streamed.
The way this is build is by marking AstNodes as streamable or not
("cannot_stream_" field). That way we know up front whether we can stream
a subtree or not.

The streaming is done via "kernel_binary_flowgraph".

In this file there are many obvious comments, e.g.
```
  TokenPosition position = ReadPosition();  // read position.
```
This has been done in an attempt to add a comment to everything that
reads from the binary to make it stand out more.

All changes from kernel_to_il up to and including May 2nd 2017
should be included.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2854393002 .
2017-05-15 09:01:22 +02:00
Kevin Millikin fbb6c121e6 Add an optional bound to type parameter references
This allows us to represent type parameters with promoted bounds which
are different from the bound at the declaration.  A missing promoted
bound indicates that the type parameter has the original bound at the
declaration.

This is a representation-only change, the optional bound is always
`null`.  Closes #29529.

BUG=https://github.com/dart-lang/sdk/issues/29529
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2866593003 .
2017-05-05 23:33:13 +02:00
Kevin Millikin 9935e86688 Introduce classes for string and name indexes
In the VM's Kernel representation, introduce wrapper classes for
string and name indexes so it is obvious which one is which.  For
convenience there is an implicit conversion so that they can each be
used where an int is allowed.  However, there is no implicit
conversion _to_ either of these types.

BUG=
R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2860823002 .
2017-05-04 00:43:19 +02:00
Kevin Millikin f13bcbcab6 Support BottomType in the VM Kernel reader
Implement the boilerplate necessary to support BottomType.  In the VM
we use the type Null.

BUG=
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2863493002 .
2017-05-03 23:17:33 +02:00
Kevin Millikin 514281b8a7 Move the Kernel canonical name table into the VM's heap
The canonical name table is copied into a typed data array in the VM's
heap.  The encoding is the same as in the binary except that the
integer indexes are fixed-size.

Canonical names are now integer indexes instead of objects allocated
in the C++ heap.

BUG=
R=jensj@google.com, vegorov@google.com

Review-Url: https://codereview.chromium.org/2853423002 .
2017-05-03 19:27:11 +02:00
Kevin Millikin 865e0669b2 Move the Kernel string offsets into the VM's heap.
Copy the Kernel string offsets into a uint32 array in the VM's heap.
This avoids allocating small string objects with new and avoids having
a table of the canonical strings.

Instead of an offset and a size, strings are now represented as
indexes into the string table in the heap.  The start offset of string
N is found at byte offset N*4 because it is a uint32, and the end
offset is found at byte offset (N+1)*4.  The strings themselves are
just integer indexes instead of pointers.

In the stream flow graph builder, string access is all random access.

R=jensj@google.com, vegorov@google.com

Review-Url: https://codereview.chromium.org/2852943003 .
2017-05-02 17:35:55 +02:00
Asger Feldthaus ac40d0bb8e Add typedef AST node boilerplate.
This adds the Typedef and TypedefType to the kernel AST,
with the relevant boilerplate.

Typedefs are not implemented in frontend or backend.

R=ahe@google.com, kmillikin@google.com

Committed: https://github.com/dart-lang/sdk/commit/d1c3ee4b35227cb6926f03479a34f82774523773
Review-Url: https://codereview.chromium.org/2825053002 .
2017-04-28 13:26:47 +02:00
Asger Feldthaus 3f1aa32183 Revert "Add typedef AST node boilerplate."
This reverts commit d1c3ee4b35.

TBR

BUG=

Review-Url: https://codereview.chromium.org/2849803002 .
2017-04-28 12:54:19 +02:00
Asger Feldthaus d1c3ee4b35 Add typedef AST node boilerplate.
This adds the Typedef and TypedefType to the kernel AST,
with the relevant boilerplate.

Typedefs are not implemented in frontend or backend.

R=ahe@google.com, kmillikin@google.com

Review-Url: https://codereview.chromium.org/2825053002 .
2017-04-28 12:39:21 +02:00
Kevin Millikin 385f8fb054 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

Review-Url: https://codereview.chromium.org/2786083002 .
2017-04-25 20:04:25 +02:00
Kevin Millikin 2e794c4e16 Move Kernel strings into the VM's heap.
- Instead of a pointer to new'd memory, Kernel strings now have an
  offset from the start of the string data.

- When the streaming reader encounters the string data it records the
  offset from the start of the binary.  This offset is stored in the
  Kernel Program and is used to compute the offset for strings.

- When a KernelReader is constructed, the string data is copied into a
  Uint8 array in the VM's heap.

- A pointer to the string data is put into every Kernel script so it
  can be used for constructing VM strings at compile time.

The source table does not use Kernel strings any more because those
strings are not found in the raw string data.  Instead, the source
table uses new'd buffers for strings (but this will be cleaned up
separately).

R=jensj@google.com

Review-Url: https://codereview.chromium.org/2820363002 .
2017-04-21 10:32:48 +02:00
Dmitry Stefantsov 95560cb02a Add Kernel AST nodes for Vector and Closure primitives in VM
Five Kernel AST nodes added: VectorCreation, VectorGet, VectorSet,
VectorCopy, and ClosureCreation.

R=asgerf@google.com, kmillikin@google.com

Review-Url: https://codereview.chromium.org/2792333002 .
2017-04-05 15:59:25 +02:00
Kevin Millikin 04cb9809d1 Restructure the Kernel string table.
Instead of a list of strings given by their length and UTF-8 encoding,
restructure the string table to consist of a list of string ending
offsets followed by a blob of UTF-8 encoded strings without lengths.

This is a step toward copying the string blob into the VM's heap and
building a heap-allocated structure to give random access to them.

BUG=
R=asgerf@google.com, jensj@google.com

Review-Url: https://codereview.chromium.org/2790073004 .
2017-04-04 13:04:25 +02:00
Jens Johansen fad8f80afd Add kernel_offset to all expressions; Make KernelConstMapKeyEqualsTraits use kernel_offset
BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2781313003 .
2017-04-03 12:10:31 +02:00
Jens Johansen 42c80b5906 Step #2 in streaming the kernel flowgraph
* Stream InvalidExpression
* Stream NullLiteral
* Stream BoolLiteral
* Stream IntLiteral
* Stream ThisExpression
* Stream StringLitereal

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2787463003 .
2017-04-03 12:04:08 +02:00
Jens Johansen 63f1de2068 Initial steps into streaming the kernel flowgraph
- Moved stuff into .h
- Leak kernel binary blob
- "Streaming" rethrow in FlowgraphBuilder

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2776373002 .
2017-04-03 11:40:37 +02:00
Kevin Millikin d562f7ced5 Remove definitions from Kernel canonical names.
Before: Canonical names contained pointers to the corresponding Kernel
tree which assumed that the whole tree was in memory whenever the
canonical names were.

Now: Canonical names do not contain these pointers.  They were only
really used to perform name-based lookup in the VM's heap so the
canonical name itself is enough.

If we later find that we need to get from a canonical name to its
Kernel tree we can add an offset in the binary (for instance) to the
canonical name or in a separate mapping on the side.

BUG=
R=asgerf@google.com, jensj@google.com, vegorov@google.com

Committed: https://github.com/dart-lang/sdk/commit/ed77783cd32d55fdad61bf9bc749030847ba9384
Review-Url: https://codereview.chromium.org/2781893004 .
2017-03-30 09:31:31 +02:00
Zach Anderson a7d1d99389 Revert "Remove definitions from Kernel canonical names."
This reverts commit ed77783cd3.

BUG=
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2782913003 .
2017-03-29 11:25:17 -07:00
Kevin Millikin ed77783cd3 Remove definitions from Kernel canonical names.
Before: Canonical names contained pointers to the corresponding Kernel
tree which assumed that the whole tree was in memory whenever the
canonical names were.

Now: Canonical names do not contain these pointers.  They were only
really used to perform name-based lookup in the VM's heap so the
canonical name itself is enough.

If we later find that we need to get from a canonical name to its
Kernel tree we can add an offset in the binary (for instance) to the
canonical name or in a separate mapping on the side.

BUG=
R=asgerf@google.com, vegorov@google.com

Review-Url: https://codereview.chromium.org/2781893004 .
2017-03-29 16:03:03 +02:00
Jens Johansen 00ef784f0c [kernel] Don't use kernel ast nodes as keys
ScopeBuildingResult now uses 'IntMap's instead, i.e. doesn't use kernel objects as key
function_scopes doesn't contain function but dill file offset

BUG=
R=kmillikin@google.com

Committed: https://github.com/dart-lang/sdk/commit/bc7200c392494a11f1df3f6b6df661d3fee27108
Review-Url: https://codereview.chromium.org/2778693002 .
2017-03-29 09:57:13 +02:00
Jens Johansen 1c47104695 Revert "[kernel] Don't use kernel ast nodes as keys"
Commit made everything go red.

This reverts commit bc7200c392.

BUG=

Review-Url: https://codereview.chromium.org/2778423002 .
2017-03-29 08:44:39 +02:00
Jens Johansen bc7200c392 [kernel] Don't use kernel ast nodes as keys
ScopeBuildingResult now uses 'IntMap's instead, i.e. doesn't use kernel objects as key
function_scopes doesn't contain function but dill file offset

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2778693002 .
2017-03-29 08:39:37 +02:00
Asger Feldthaus a3402df15c [Kernel] Remove code from the old type propagation.
BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2780513004 .
2017-03-28 12:43:22 +02:00
Jens Johansen a6ea038643 [kernel] offsets on direct property get/set
BUG=
R=ahe@google.com, kmillikin@google.com

Committed: https://github.com/dart-lang/sdk/commit/7577f6aaa052c9a1c309f13bf338b92bf4fb9fd0
Review-Url: https://codereview.chromium.org/2748333002 .
2017-03-21 14:43:45 +01:00
Jens Johansen a1a34a1c84 [kernel] Debugging of switch statement
BUG=
R=ahe@google.com, kmillikin@google.com

Review-Url: https://codereview.chromium.org/2750013002 .
2017-03-21 11:36:48 +01:00
Jens Johansen 9fa510ea38 Revert "[kernel] offsets on direct property get/set"
This commit wanted stuff from anther CL that haven't landed yet.

This reverts commit 7577f6aaa0.

BUG=

Review-Url: https://codereview.chromium.org/2751083002 .
2017-03-15 13:54:03 +01:00
Jens Johansen 7577f6aaa0 [kernel] offsets on direct property get/set
BUG=
R=ahe@google.com, kmillikin@google.com

Review-Url: https://codereview.chromium.org/2748333002 .
2017-03-15 13:26:45 +01:00
Jens Johansen 5e1ba94af4 [kernel] debugging for in statement
BUG=
R=ahe@google.com, kmillikin@google.com

Review-Url: https://codereview.chromium.org/2747813003 .
2017-03-15 13:22:58 +01:00
Jens Johansen 9837563cd1 Kernel debugging; service tests
- Offsets on more stuff
- Status file for kernel
 -> Testing with (before fasta)
    ```
    python tools/test.py -mrelease -cdartk --no-tree-shake --no-dfe service
    ```
    now shows everything as passing.
    Reload stuff, and evaluation stuff (e.g.) has been disabled though.
- Lots of new service tests that tests what positions we stop at when
  saying next.

As fasta has now landed debugging does not currently work, but this is still needed in order to both test better and allow for proper kernel debugging support.

R=hausner@google.com, kmillikin@google.com

Review-Url: https://codereview.chromium.org/2680303002 .
2017-03-07 09:43:59 +01:00
Kevin Millikin d921f94367 Change a C++ type to avoid triggering an ASSERT.
Malloc'd memory is uninitialized so C++ constructors are not run.  For
class Ref, operator= asserts (basically) that the constructor has been
run.

BUG=
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2723123002 .
2017-03-01 16:50:24 +01:00
Asger Feldthaus 8bfc4b47c0 Implement canonical name scheme in kernel.
This adds a class CanonicalName that can represent a library, class,
or member.  All references now go through a Reference object, which is
linked to both the AST node and its CanonicalName, so either can be
created first.

dartk now accepts multiple input files:
- If multiple dart files are given, they are all compiled.
- If multiple binaries are given, they are linked together.
Mixed dart and binary input is not supported by dartk.

dartk now has a flag --include-sdk which includes the entire SDK in
the output.  This is so the SDK can be compiled alone and then linked.

Example of compiling separately and then linking:
  dartk foo.dart -o foo.dill
  dartk main.dart -o main.dill
  dartk --include-sdk -o sdk.dill
  dartk main.dill foo.dill sdk.dill --target=vm --link -o program.dill

dartk still has incredibly slow cold start due to the analyzer loading
the dart sdk, so this does not actually speed things up at the moment.

BUG=
R=ahe@google.com, kmillikin@google.com, kustermann@google.com, sigmund@google.com

Review-Url: https://codereview.chromium.org/2665723002 .
2017-02-23 14:12:10 +01:00
Jens Johansen 86d788e699 [Kernel] replace function debuggable originalAsyncMarker
Previously a functions debuggable field was set to false in the async transformation (and because it wasn't done yet, not in async* and sync* transformation, though it should have been). Now instead, set the original async status and set debuggable on the c++ side equivalently.

Also, on the c++ side, set a functions modifier to async etc if they were originally async etc.

BUG=
R=asgerf@google.com, kmillikin@google.com, kustermann@google.com

Review-Url: https://codereview.chromium.org/2697193008 .
2017-02-22 12:12:54 +01:00
Asger Feldthaus fd6018d2ab Add IR nodes needed for deferred loading.
BUG=
R=sra@google.com

Review-Url: https://codereview.chromium.org/2659343002 .
2017-02-13 14:31:24 +01:00
Jens Johansen e7766c950e Debugging in kernel shaping up.
This introduces

- a list of valid token positions, so debugging actually
  starts to work, and the observatory can be loaded without crash.

- a list of valid yield positions, so stepping over await stuff
  works as expected.

- Adding "DebugStepCheckInstr" to the kernel generated il so stepping
  over await stuff works as expected, we can break in empty methods etc.

With this, approximately 80% of the service tests pass in kernel mode.

R=kmillikin@google.com

Committed: https://github.com/dart-lang/sdk/commit/2d5147be9d7435c06dd892d145d8717b6d1f62d5
Review-Url: https://codereview.chromium.org/2632183002 .
2017-01-31 11:59:06 +01:00
Jens Johansen d0e0ef52ef Revert "Debugging in kernel shaping up."
This reverts commit 2d5147be9d.

INTPTR_MAX doesn't exist on all builders.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2664143002 .
2017-01-31 11:26:46 +01:00
Jens Johansen 2d5147be9d Debugging in kernel shaping up.
This introduces

- a list of valid token positions, so debugging actually
  starts to work, and the observatory can be loaded without crash.

- a list of valid yield positions, so stepping over await stuff
  works as expected.

- Adding "DebugStepCheckInstr" to the kernel generated il so stepping
  over await stuff works as expected, we can break in empty methods etc.

With this, approximately 80% of the service tests pass in kernel mode.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2632183002 .
2017-01-31 11:01:29 +01:00
Ben Konyi 0d9a7970f5 Removed usage of std::map and std::vector from kernel code. Issue #28064.
BUG=
R=zra@google.com

Review-Url: https://codereview.chromium.org/2658693002 .
2017-01-25 14:53:33 -08:00
Ben Konyi 6c2e67e764 Revert "Switched from GrowableArray to MallocGrowableArray to fix crash caused"
This reverts commit ac2b995a9296a100b0385fe7f262ebefa1da30d8.

BUG=

Review-Url: https://codereview.chromium.org/2656693006 .
2017-01-25 13:59:46 -08:00
Ben Konyi 9956256223 Switched from GrowableArray to MallocGrowableArray to fix crash caused by no isolate/thread existing when called. Also created MallocMap for the same reason.
BUG=
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2655463005 .
2017-01-25 13:55:45 -08:00
Ben Konyi 57ff20f49e Revert "Revert "Revert "Removed usage of std::map and std::vector from kernel code. Issue #28064."""
This reverts commit e2bb8409ab.

BUG=

Review-Url: https://codereview.chromium.org/2654983002 .
2017-01-24 19:29:06 -08:00
Ben Konyi e2bb8409ab Revert "Revert "Removed usage of std::map and std::vector from kernel code. Issue #28064.""
This reverts commit ddc24380b1.

BUG=

Review-Url: https://codereview.chromium.org/2648233005 .
2017-01-24 15:58:59 -08:00
Ben Konyi ddc24380b1 Revert "Removed usage of std::map and std::vector from kernel code. Issue #28064."
This reverts commit b9035d949f.

BUG=

Review-Url: https://codereview.chromium.org/2650333002 .
2017-01-24 15:18:27 -08:00
Ben Konyi b9035d949f Removed usage of std::map and std::vector from kernel code. Issue #28064.
Added fix to hopefully fix build error.

BUG=
R=zra@google.com

Review-Url: https://codereview.chromium.org/2647633003 .
Review-Url: https://codereview.chromium.org/2641243002 .
2017-01-24 14:25:55 -08:00
Ben Konyi 536a177728 Revert "Removed usage of std::map and std::vector from kernel code. Issue #28064."
This reverts commit c49eaa19dc.

TBR=zra@google.com

BUG=

Review-Url: https://codereview.chromium.org/2644183002 .
2017-01-19 12:23:24 -08:00