Commit Graph

17 Commits

Author SHA1 Message Date
Vyacheslav Egorov 8a179fb953 [VM, Compiler] Move compiler to a separate folder.
New folder structure (nested under vm/):

- compiler/
-   jit/         - JIT specific code
-   aot/         - AOT specific code
-   backend/     - all middle-end and back-end code (IL, flow graph)
-   assembler/   - assemblers and disassemblers
-   frontend/    - front ends (AST -> IL, Kernel -> IL)

compiler/README.md would be the documentation root for the compiler
pipeline

Bug: https://github.com/dart-lang/sdk/issues/30575
Change-Id: I2dfd9688793bff737f7632ddc77fca766875ce36
Reviewed-on: https://dart-review.googlesource.com/2940
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-09-04 15:15:18 +00:00
Kevin Millikin 2f49198520 Allow the VM to read Kernel files with external libraries
The meaning of a Kernel file with an external library is that the
library is one that is already known to be loaded in the VM.

Fixes issue #30111.

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

Review-Url: https://codereview.chromium.org/2995423002 .
2017-08-22 16:05:19 +02:00
Jens Johansen 6c2232cb60 [kernel] Insert kernel bodies into VM heap
This CL copies the kernel bodies for all functions and
fields into the VM heap. The function bodies in the VM
heap are then used when compiling the flowgraphs.
This theoretically means that the malloc'd data can be
freed and that snapshotting from kernel could possibly
work, though it hasn't been tested.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2972343002 .
2017-08-10 09:38:17 +02:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Jens Johansen bbb463ac20 [kernel] Delete most of the AST
Now basically only Program (with ~no children) persists.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2931773005 .
2017-06-30 07:55:08 +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
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 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 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
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