Commit Graph

499 Commits

Author SHA1 Message Date
Régis Crelier 390c80234a [VM generic functions] Properly instantiate generic signatures by providing the
number of free function type parameters.
Add test and mark status files.

Change-Id: I081de7674693c5ac2071a33948d25aadfc65f4ae
Reviewed-on: https://dart-review.googlesource.com/13901
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2017-10-16 21:57:05 +00:00
Siva Chandra bf096c2bb4 Copy library specific kernel binary data to VM heap.
Before this change, each function and field had its own kernel data blob
in the VM heap. With this change, the entire kernel data of a library is
stored as one single blob in the VM heap. Functions and fields store an
offset which points to the kernel data, specific to them, in that single
blob.

The pointer to the kernel data for a library is saved in two places:
1. With the library objects themselves.
2. With all the patch classes of the library.
3. With the patch classes created during hot reload.

Change-Id: Ie03e738c4d20f16056a5ef04341b75506fda9c60
Bug:
Reviewed-on: https://dart-review.googlesource.com/6601
Commit-Queue: Siva Chandra <sivachandra@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2017-10-09 15:03:15 +00:00
Vyacheslav Egorov 7d5231796e [VM, Precompiler] Support obfuscation of the symbolic information in precompiler
Obfuscation is controlled by obfuscate flag in Dart_IsolateFlags.

Obfuscation of identifiers is performed during script tokenization - when TokenStream is generated from the source. All kIDENT and kINTERPOL_VAR tokens are renamed consistently using a persistent obfuscation map stored in ObjectStore::obfuscation_map.

Some identifiers (pseudo-keywords, arithmetic operators, builtin recognized methods and entry-points) are not renamed to keep name based lookups from breaking. All other identifiers are renamed.

Constant instances of Symbol-s (both created via literal syntax #ident and using constant constructor const Symbol("ident")) are renamed consistently with corresponding identifiers.

Script urls and Library urls and names are also obfuscated.

Obfuscation map can be dumped as a JSON array at the end of precompilation using Dart_GetObfuscationMap API.

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

Review-Url: https://codereview.chromium.org/3003583002 .
2017-08-25 09:48:23 +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
Ryan Macnak 466385ceb6 [vm, gc] Require a safepoint for heap iteration.
Assert a safepoint operation can only be started from a thread in the VM state. Fix several unit tests missing a native-to-vm transition.

R=asiva@google.com, danunez@google.com

Review-Url: https://codereview.chromium.org/2995543004 .
2017-08-07 17:51:25 -07:00
Régis Crelier cc81f38519 [VM generic functions] Disallow generic function types as type arguments or bounds.
Adjust existing test and status file.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2989513002 .
2017-07-21 15:08:00 -07:00
Régis Crelier c98989f0d7 [VM generic function types] Properly set the scope function after parsing a
result type that may contain a generic function type.
Add a regression test demonstrating the fixed problem.
Rename ResolveType to ResolveTypeParameters in the parser to clarify that only
type parameters get resolved.
Rename ResolveSignature to ResolveSignatureTypeParameters for the same reason.
Correctly propagate the finalization mode when finalizing signatures.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2979763002 .
2017-07-19 13:32:24 -07: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
Régis Crelier 164a602a80 [VM parser] Mark class as typedef class before parsing its function type when
using the new function type syntax.
This issue prevents committing of https://codereview.chromium.org/2893893002

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2966583002 .
2017-06-29 14:33:36 -07:00
Aske Simon Christensen cec963f028 The current growth strategy for growable arrays allocates a backing array of size 2 at (empty) creation and doubles the size whenever the capacity is insufficient while adding elements.
I collected statistics for the sizes and capacities of growable arrays which are promoted to old-space or survive an old-space gc when running dart2js and Fasta. For these applications, the vast majority of arrays stay empty. More than half of the total object size of promoted backing arrays is backing for empty growable arrays.

Furthermore, since the overhead for an array is 3 words (header, type parameters and length), and object sizes are rounded up to an even number of words, we waste one word for all even-sized arrays.

This CL changes the growth strategy so that empty growable arrays are created with a shared, zero-sized array as backing, avoiding the allocation of a backing array if no elements are added. When the array needs to grow, it starts out at 3 and grows to double size plus one each time: 7, 15, 31, ...

A few places in the VM code need to handle these shared, zero-sized arrays specially. In particular, the Array::MakeArray function needs to allocate a new, empty array if its result is to be returned to Dart code.

Benchmarks suggest that the change improves memory usage by a few percent overall and does not significantly affect run time.

BUG=
R=erikcorry@google.com

Review-Url: https://codereview.chromium.org/2949803002 .
2017-06-22 10:51:54 +02:00
Régis Crelier eabcc23b33 Fix type argument finalization of some recursive generic types (fixes #29949).
Add regression test.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2952743003 .
2017-06-21 14:54:12 -07:00
Régis Crelier 1f5f3ed79f Set and keep parent function of signature functions.
Fix function type parameter comparison in type tests.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2951803005 .
2017-06-21 13:16:23 -07:00
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
Ryan Macnak 8b96a31c7f Move runtime functions to the more logical runtime_entry.cc.
Make --trace-runtime-calls respect the isolate filter.

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2827873002 .
2017-04-19 10:22:04 -07:00
Régis Crelier 4dd686e9df More work on finalization of recursive types (fixes #29357).
Add regression test.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2822323002 .
2017-04-18 17:18:39 -07:00
Régis Crelier fd5089c9e8 Remove parent_level field of function type parameters.
Add function_type_arguments field in closure instances.
Lots of other smaller changes, also related to generic function semantics.
This is still work in progress, with a change of direction in the design:
The type argument vector of a generic function will be prepended with the type
arguments of enclosing generic functions. The re-allocation and concatenation
will be done in nested generic function's prolog. This will greatly simplify
instantiation of types at run time without having to search the context for
parent function's type arguments. However, a closure instance now requires an
additional field. On the other hand, type parameters do not require a
parent_level field anymore.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2818273002 .
2017-04-17 08:58:24 -07:00
Regis Crelier d0a7bad121 Pass a second type argument vector to all type instantiation calls in the VM.
With generic methods, uninstantiated types will require 2 instantiators, one
reflecting the class type arguments (as of today) and one reflecting the
function type arguments (new).
This is work in progress and the second instantiator is always null for now.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2799373002 .
2017-04-10 21:25:33 -07:00
Regis Crelier 820f8d74e6 Added missing canonicalization of typedef signature instantiated during
finalization (fixes #29300).

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2811643004 .
2017-04-10 15:15:31 -07:00
Regis Crelier 8ca244ba27 Make finalization of recursive function types more robust, especially since
the Kernel frontend may omit the information that a function type is a typedef.
Re-enable several previously failing tests for dartk.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2806893002 .
2017-04-10 11:06:14 -07:00
Regis Crelier 5f5a698100 Keep types in signatures of function types properly instantiated as the function
type itself gets instantiated.
Until now, the signature was kept unchanged and the instantiation was reflected
by the type arguments of the function type only. This delayed instantiation
would complicate the implementation of generic functions.
This cl actually removes type arguments for (non-typedef) function types. The
function type is now fully represented by the signature. When the function type
is instantiated, a new signature is allocated (instead of a new type argument
vector) to hold instantiated result type and formal parameter types.
The same applies in the case of typedef function types, however, the type
arguments of the typedef are kept as before. This allows for better printing
of typedef function types and for finalization of recursive type involving
typedefs as type arguments.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2793033005 .
2017-04-06 12:28:52 -07:00
Regis Crelier 5065c1c0c4 Clean up finalization of recursive types in the VM.
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2791393002 .
2017-04-03 14:28:01 -07:00
Jens Johansen 242be22300 Fix class finalization issues in kernel
Without this we'll get something like
```
../../runtime/vm/class_finalizer.cc: 2525: error: expected: cls.is_type_finalized()
Dumping native stack trace for thread 1b6fc
  [0x00000000009b6353] dart::Profiler::DumpStackTrace()
  [0x00000000009b6353] dart::Profiler::DumpStackTrace()
  [0x0000000000692a21] dart::DynamicAssertionHelper::Fail(char const*, ...)
  [0x0000000000698420] dart::ClassFinalizer::FinalizeClass(dart::Class const&)
[...]
```

when running via kernel with command line option --error_on_bad_override

This is caused by finalizing a class having a interface not yet type finalized.

This change makes sure types are finalized before the class using them is.

Fixes https://github.com/dart-lang/sdk/issues/29123

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2766173002 .
2017-03-22 12:32:30 +01:00
Regis Crelier bde22d2dee Cleanup change.
AssertAssignableInstr::Canonicalize was too restrictive: it can instantiate the
type even if the instantiator is null.
Do not allocate empty TypeArguments handles, but use the common one instead.

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2759393005 .
2017-03-21 13:55:39 -07:00
Regis Crelier 063dd6d03f Make sure the signature of the call method is finalized before involving it
in bound checkings of its owner class (fixes #29025).
Add regression test and mark as failing for the analyzer (issue filed).
Add missing trail argument in 2 locations (not related to the fixed issue).
Cleanup: Remove ClassFinalizer::kCanonicalizeWellFormed which is not treated
differently than ClassFinalizer::kCanonicalize anymore after earlier changes in
the spec on how to handle malformed types.

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

Review-Url: https://codereview.chromium.org/2755723003 .
2017-03-15 16:44:33 -07:00
Regis Crelier 09b5d6f619 Manage and capture class and function instantiators in the parser.
This is work in progress towards supporting generic function semantics.

R=hausner@google.com

Review-Url: https://codereview.chromium.org/2736733005 .
2017-03-08 08:55:30 -08:00
Erik Corry c6a199e40b Sort class IDs before training AppJIT snapshots
R=fschneider@google.com, rmacnak@google.com
BUG=

Review-Url: https://codereview.chromium.org/2699853002 .
2017-02-20 12:14:17 +01:00
Regis Crelier 2037e7e884 Properly resolve upper bounds of generic function's type parameters.
Various minor cleanup related to generic functions.
Add flag in preparation of future work to fully support generic methods.

R=hausner@google.com

Review-Url: https://codereview.chromium.org/2696783002 .
2017-02-14 01:50:02 -08:00
Regis Crelier 97f968de1c Implement generic function type syntax in the VM (fixes #27966).
The new function type syntax is allowed everywhere and not just in typedef.

R=hausner@google.com

Review-Url: https://codereview.chromium.org/2643523002 .
2017-01-27 08:45:03 -08:00
Regis Crelier 97c42acc30 Support FutureOr<T> in the VM (fixes #28010).
R=asiva@google.com, rmacnak@google.com

Review-Url: https://codereview.chromium.org/2642443002 .
2017-01-17 10:27:21 -08:00
Matthias Hausner 47a479741f Update assertion in finalizer
Kernel IR omits the implicit constructor when it is not needed,
e.g. in abstract classes. Update assertion in finalizer.

BUG=
R=regis@google.com

Review-Url: https://codereview.chromium.org/2624543002 .
2017-01-09 13:29:28 -08:00
Regis Crelier 98f28c1624 Always finalize the super class of a class before cloning the super class
constructor and cloning the mixin functions.
The fragile finalization order was disrupted by the use of the
--error-on-bad-override flag (fixes #28252).

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2609393005 .
2017-01-05 09:09:52 -08:00
Regis Crelier 3334c2402a Second try: Fix resolution and canonicalization of typedefs and function types
in preparation of the new typedef syntax.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2606993002 .
2016-12-28 14:53:23 -08:00
Regis Crelier 4980107a96 Revert "Fix resolution and canonicalization of typedefs and function types..."
Review-Url: https://codereview.chromium.org/2600313002 .
2016-12-27 17:54:00 -08:00
Regis Crelier 291ed0c545 Fix resolution and canonicalization of typedefs and function types in
preparation of the new typedef syntax.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2592263004 .
2016-12-27 16:55:21 -08:00
Regis Crelier 3276a2ea26 Decorate mixin application class name with private keys of libraries of super
type and mixin types if they are imported from a different library than the
library defining the mixin application class (fixes #27957).

R=hausner@google.com

Review URL: https://codereview.chromium.org/2540323005 .
2016-12-02 08:46:29 -08:00
Martin Kustermann 63af3f56ee VM: [Kernel] Cherry-pick from dart-lang/kernel_sdk
Fix a trio of issues in type finalization.

1. We were using is_type_finalized to detect classes that had already been
   initialized by DilReader::ReadPreliminaryClass.  This state is not
   guaranteed by this function, however is_cycle_free is.

2. In the VM, classes that were created type finalized were not marked as
   cycle free because finalization did not consider them so cycle-freeness
   didn't matter.  We would therefore try to initialize these classes with
   DilReader::ReadPreliminaryClass and mutate types in them.  This causes
   them to have unfinalized types but still have is_type_finalized true.

3. Types in top-level procedures were not necessarily finalized.  A simple
   way to achieve this is to finalize each library's top-level class.

Review URL: https://chromereviews.googleplex.com/520437013 .

R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2514373002 .
2016-11-21 16:38:30 +01:00
Florian Schneider 86d62d66f2 Allocate generic types in new-space before canonicalizing.
A previous CL missed the second allocation site (https://github.com/dart-lang/sdk/commit/6418f8f36caf4f6af2f575c2f1a7ca828d82ee00) in Instance::GetType.

Pass space used in GetType() explicitly to use old-space when invoked from the background compiler.

Fixes #27663.

R=regis@google.com

Review URL: https://codereview.chromium.org/2509013002 .
2016-11-16 12:41:32 -08:00
Vyacheslav Egorov 23fd1a184b VM: Support bootstrapping core libraries from Kernel binaries instead of source.
BUG=http://dartbug.com/27590
R=asiva@google.com

Review URL: https://codereview.chromium.org/2485993002 .
2016-11-16 13:56:20 +01:00
John McCutchan f0f32a0e29 Map deleted enum values to a sentinel value.
Fixes #27802

BUG=
R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/2498863002 .
2016-11-15 14:15:36 -08:00
Zachary Anderson a1bcf051d8 clang-format runtime/vm
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2481873005 .
2016-11-08 13:54:47 -08:00
Regis Crelier 11562f6874 Support generic method syntax (fixes #25869).
Function type parameters are parsed and resolved, but mapped to malformed types
(i.e. dynamic) until full support is implemented.

R=hausner@google.com

Review URL: https://codereview.chromium.org/2349593003 .
2016-09-19 15:17:33 -07:00
John McCutchan c692a64e5a Rework how enums are implemented and reloaded
- Enum instances now hold their index and their label. Before the labels were held in a static array to the side and the index was used to look up the label.

- Before and after reload enum instances are now paired (by label) and put into the 'become' table.

Fixes https://github.com/dart-lang/sdk/issues/26877

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2153143002 .
2016-07-15 10:52:20 -07:00
Ryan Macnak 5026d03a75 More live edit timeline events.
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2105023007 .
2016-06-30 10:59:54 -07:00
John McCutchan 48c8ffa7f3 Initial isolate reload support
This is a cut of the work that Todd and I collaborated on in the reload branch.

In this CL, we've dropped the loader port hacks, in other words, on stack reloading in the standalone embedder does not work yet.

- [x] Support for hot reloading of isolate source code
- [x] Unit test harness and many tests
- [x] Service protocol and Observatory support
- [x] Product build does not include support for hot reloading.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1965823002 .
2016-05-17 12:19:06 -07:00
Ryan Macnak f731dd0615 Reapply "- Use a hash table to canonicalize instances/arrays to avoid having to iterate over a linear list and search for canonical instances."
- Rehash constants table during tree-shaking.
 - Rehash constants table on snapshot load.

R=regis@google.com

Review URL: https://codereview.chromium.org/1900863002 .
2016-04-18 16:46:26 -07:00
Siva Annamalai 8ce7b6291a Revert "- Use a hash table to canonicalize instances/arrays to avoid having to iterate over a linear list and search for canonical instances."
This reverts commit 95a2b02a9e.

Once the tree shaker in precompiled code is fixed to treat the constants array in a class as a hash table this CL can be re-applied.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1888593003 .
2016-04-13 18:49:53 -07:00
Siva Annamalai 95a2b02a9e - Use a hash table to canonicalize instances/arrays to avoid having to iterate over a linear list and search for canonical instances.
- Some minor cleanups
  - Return an empty array right away in the parser instead of creating an
    empty array and canonicalizing it
  - The canonical bit was not being set for some of the singleton objects.

R=regis@google.com

Review URL: https://codereview.chromium.org/1873143003 .
2016-04-13 10:26:17 -07:00
Regis Crelier b8bcb5587b Properly handle unfinalized type parameters of generic mixins (fixes #26230).
Finalize upper bounds of unfinalized classes earlier in order to reduce the
number of BoundedType allocations.
Add regression test.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1886633002 .
2016-04-13 10:04:53 -07:00