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>
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/30524R=rmacnak@google.com
Review-Url: https://codereview.chromium.org/3003583002 .
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 .
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 .
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 .
- 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 .
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 .
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 .
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 .
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/29123R=kmillikin@google.com
Review-Url: https://codereview.chromium.org/2766173002 .
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 .
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 .
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 .
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 .
- 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 .