Commit graph

50 commits

Author SHA1 Message Date
Ryan Macnak f124f0fcfc [vm, service] Add getProcessMemory, which reports a tree of major ownership of memory known to the VM.
Removes the private extension to heap snapshots, which did not represent nesting.

Change-Id: I62e60922f094db68cf63bac037140e1a8b2b9fd7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152424
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-06-25 19:51:12 +00:00
Ryan Macnak 75c65a4b39 [vm] Switch Zones from arithmetic to geometric growth when they become large.
Avoids failing on Linux from exhausting Page Table Entries before exhausting physical memory or address space.

Change-Id: Idffbd0a2eb8b030f2afabb4c31135fb75deca59f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144669
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-05-04 17:01:44 +00:00
Ryan Macnak ecd7977928 [vm] Fix gcc build.
Change-Id: I8a0a9a695403dc6d048dccb9f33642d70cc5d588
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121866
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-10-17 16:51:32 +00:00
Ryan Macnak 20dd7c88e9 [vm] Use VirtualMemory with a cache for small Zone::Segements.
tcmalloc and jemalloc have both been observed to hold onto lots of free'd zone segments (jemalloc to the point of causing OOM), so instead of using malloc to allocate segments, we allocate directly from mmap/zx_vmo_create/VirtualAlloc, and cache a small number of the normal sized segments.

flutter doctor at exit ("idle")
Process::MaxRSS()     261009408 -> 258756608 (-0.86%)
Process::CurrentRSS() 252932096 -> 205881344 (-18.6%)

Bug: https://github.com/dart-lang/sdk/issues/38820
Change-Id: I319069678b9d44383a9921ec03a963517991dd11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121264
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-10-11 22:25:23 +00:00
Aart Bik 8ee3f314cb [vm/gardening] clang tidy fixes
https://github.com/dart-lang/sdk/issues/38196

Change-Id: I0a61eae20d8cfc1c2ada8d6a607d437d02136d33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115609
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2019-09-05 17:00:33 +00:00
Ryan Macnak 36985859e4 [vm] Don't copy when reading typed data in messages sent to native ports.
Bug: https://github.com/dart-lang/sdk/issues/37833
Change-Id: Iac906e58320e003365c4c0624b4587579f352db1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114970
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-08-30 17:49:28 +00:00
Liam Appelbe 6e1f628f19 Outline the StackZone's Zone
Bug: https://github.com/dart-lang/sdk/issues/36100
Change-Id: I17cdf438c19fcc66ceb09c23348654eb752dd3cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103560
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-05-23 19:10:46 +00:00
Vyacheslav Egorov a9ce969e53 [vm] Decouple growable_array.h and zone.h from thread.h
- Introduce a slimmed down version of thread.h, which just depends on the
Zone and StackResource.
- Introduce a layering check that would prevent the coupling in the future.

This is the first step towards decoupling compiler from runtime.

There are multiple reasons to introduce the decoupling but the main
reason currently is to introduce a controlled surface through which
compiler reaches into runtime to catch any places where runtime word size
might influence the compiler and then enable building compiler that
targets 32-bit runtime but is embedded into a 64-bit runtime.

Issue https://github.com/dart-lang/sdk/issues/31709

Change-Id: Id63ebbaddca55dd097298e51c90d957a73fa476e
Reviewed-on: https://dart-review.googlesource.com/c/87182
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-01-11 20:47:10 +00:00
Martin Kustermann 3b414a277c Reland "[VM] Introduction of type testing stubs - Part 1-4"
Relands 165c583d57

    [VM] Introduction of type testing stubs - Part 1

    This CL:

      * Adds a field to [RawAbstractType] which will always hold a pointer
        to the entrypoint of a type testing stub

      * Makes this new field be initialized to a default stub whenever a
        instances are created (e.g. via Type::New(), snapshot reader, ...)

      * Makes the clustered snapshotter write a reference to the
        corresponding [RawInstructions] object when writing the field and do
        the reverse when reading it.

      * Makes us call the type testing stub for performing assert-assignable
        checks.

    To reduce unnecessary loads on callsites, we store the entrypoint of the
    type testing stubs directly in the type objects.  This means that the
    caller of type testing stubs can simply branch there without populating
    a code object first.  This also means that the type testing stubs
    themselves have no access to a pool and we therefore also don't hold on
    to the [Code] object, only the [Instruction] object is necessary.

    The type testing stubs do not setup a frame themselves and also have no
    safepoint.  In the case when the type testing stubs could not determine
    a positive answer they will tail-call a general-purpose stub.

    The general-purpose stub sets up a stub frame, tries to consult a
    [SubtypeTestCache] and bails out to runtime if this was unsuccessful.

    This CL is just the the first, for ease of reviewing.  The actual
    type-specialized type testing stubs will be generated in later CLs.

    Reviewed-on: https://dart-review.googlesource.com/44787

Relands f226c22424

    [VM] Introduction of type testing stubs - Part 2

    This CL starts building type testing stubs specialzed for [Type] objects
    we test against.

    More specifically, it adds support for:

      * Handling obvious fast cases on the call sites (while still having a
        call to stub for negative case)

      * Handling type tests against type parameters, by loading the value
        of the type parameter on the call sites and invoking it's type testing stub.

      * Specialzed type testing stubs for instantiated types where we can
        do [CidRange]-based subtype-checks.

        ==> e.g. String/List<dynamic>

      * Specialzed type testing stubs for instantiated types where we can
        do [CidRange]-based subclass-checks for the class and
        [CidRange]-based subtype-checks for the type arguments.

        ==> e.g. Widget<State>, where we know [Widget] is only extended and not
                 implemented.

      * Specialzed type testing stubs for certain non-instantiated types where we
        can do [CidRange]-based subclass-checks for the class and
        [CidRange]-based subtype-checks for the instantiated type arguments and
        cid based comparisons for type parameters.  (Note that this fast-case migth
        result in some false-negatives!)

        ==> e.g. _HashMapEntry<K, V>, where we know [_HashMapEntry] is only
                 extended and not implemented.

       This optimizes cases where the caller uses `new HashMap<A, B>()` and only
       uses `A` and `B` as key/values (and not subclasses of it).  The false-negative
       can occur when subtypes of A or B are used.  In such cases we fall back to the
       [SubtypeTestCache]-based imlementation.

    Reviewed-on: https://dart-review.googlesource.com/44788

Relands 25f98bcc75

    [VM] Introduction of type testing stubs - Part 3

    The changes include:

      * Make AssertAssignableInstr no longer have a call-summary, which
        helps methods with several parameter checks by not having to
        re-load/re-initialize type arguments registers

      * Lazily create SubtypeTestCaches: We already go to runtime to warm up
        the caches, so we now also create the caches on the first runtime
        call and patch the pool entries.

      * No longer load the destination name into a register: We only need
        the name when we throw an exception, so it is not on the hot path.
        Instead we let the runtime look at the call site, decoding a pool
        index from the instructions stream.  The destination name will be
        available in the pool, at a consecutive index to the subtype cache.

      * Remove the fall-through to N=1 case for probing subtypeing tests,
        since those will always be handled by the optimized stubs.

      * Do not generate optimized stubs for FutureOr<T> (so far it just
        falled-through to TTS).  We can make optimzed version of that later,
        but it requires special subtyping rules.

      * Local code quality improvement in the type-testing-stubs: Avoid
        extra jump at last case of cid-class-range checks.

    There are still a number of optimization opportunities we can do in
    future changes.

    Reviewed-on: https://dart-review.googlesource.com/46984

Relands 2c52480ec8

    [VM] Introduction of type testing stubs - Part 4

    In order to avoid generating type testing stubs for too many types in
    the system - and thereby potentially cause an increase in code size -
    this change introduces a smarter way to decide for which types we should
    generate optimized type testing stubs.

    The precompiler creates a [TypeUsageInfo] which we use to collect
    information.  More specifically:

       a) We collect the destination types for all type checks we emit
          (we do this inside AssertAssignableInstr::EmitNativeCode).

          -> These are types we might want to generate optimized type testing
             stubs for.

       b) We collect type argument vectors used in instance creations (we do
          this inside AllocateObjectInstr::EmitNativeCode) and keep a set of
          of used type argument vectors for each class.

    After the precompiler has finished compiling normal code we scan the set
    of destination types collected in a) for uninstantiated types (or more
    specifically, type parameter types).

    We then propagate the type argument vectors used on object allocation sites,
    which were collected in b), in order to find out what kind of types are flowing
    into those type parameters.

    This allows us to extend the set of types which we test against, by
    adding the types that flow into type parameters.

    We use this final augmented set of destination types as a "filter" when
    making the decision whether to generate an optimized type testing stub
    for a given type.

    Reviewed-on: https://dart-review.googlesource.com/48640

Issue https://github.com/dart-lang/sdk/issues/32603

Closes https://github.com/dart-lang/sdk/issues/32852

Change-Id: Ib79fbe7f043aa88f32bddad62d7656c638914b44
Reviewed-on: https://dart-review.googlesource.com/50944
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-04-13 09:06:56 +00:00
Ryan Macnak b3c94b5d52 Revert "Reland "[VM] Introduction of type testing stubs - Part 1-4""
This reverts commit 34763bc4c9.

Bug: https://github.com/dart-lang/sdk/issues/32852
Change-Id: I2131907d7036644707d5109a951969fc48dd74e1
Reviewed-on: https://dart-review.googlesource.com/50842
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-04-11 22:42:59 +00:00
Martin Kustermann 34763bc4c9 Reland "[VM] Introduction of type testing stubs - Part 1-4"
Relands 165c583d57

    [VM] Introduction of type testing stubs - Part 1

    This CL:

      * Adds a field to [RawAbstractType] which will always hold a pointer
        to the entrypoint of a type testing stub

      * Makes this new field be initialized to a default stub whenever a
        instances are created (e.g. via Type::New(), snapshot reader, ...)

      * Makes the clustered snapshotter write a reference to the
        corresponding [RawInstructions] object when writing the field and do
        the reverse when reading it.

      * Makes us call the type testing stub for performing assert-assignable
        checks.

    To reduce unnecessary loads on callsites, we store the entrypoint of the
    type testing stubs directly in the type objects.  This means that the
    caller of type testing stubs can simply branch there without populating
    a code object first.  This also means that the type testing stubs
    themselves have no access to a pool and we therefore also don't hold on
    to the [Code] object, only the [Instruction] object is necessary.

    The type testing stubs do not setup a frame themselves and also have no
    safepoint.  In the case when the type testing stubs could not determine
    a positive answer they will tail-call a general-purpose stub.

    The general-purpose stub sets up a stub frame, tries to consult a
    [SubtypeTestCache] and bails out to runtime if this was unsuccessful.

    This CL is just the the first, for ease of reviewing.  The actual
    type-specialized type testing stubs will be generated in later CLs.

    Reviewed-on: https://dart-review.googlesource.com/44787

Relands f226c22424

    [VM] Introduction of type testing stubs - Part 2

    This CL starts building type testing stubs specialzed for [Type] objects
    we test against.

    More specifically, it adds support for:

      * Handling obvious fast cases on the call sites (while still having a
        call to stub for negative case)

      * Handling type tests against type parameters, by loading the value
        of the type parameter on the call sites and invoking it's type testing stub.

      * Specialzed type testing stubs for instantiated types where we can
        do [CidRange]-based subtype-checks.

        ==> e.g. String/List<dynamic>

      * Specialzed type testing stubs for instantiated types where we can
        do [CidRange]-based subclass-checks for the class and
        [CidRange]-based subtype-checks for the type arguments.

        ==> e.g. Widget<State>, where we know [Widget] is only extended and not
                 implemented.

      * Specialzed type testing stubs for certain non-instantiated types where we
        can do [CidRange]-based subclass-checks for the class and
        [CidRange]-based subtype-checks for the instantiated type arguments and
        cid based comparisons for type parameters.  (Note that this fast-case migth
        result in some false-negatives!)

        ==> e.g. _HashMapEntry<K, V>, where we know [_HashMapEntry] is only
                 extended and not implemented.

       This optimizes cases where the caller uses `new HashMap<A, B>()` and only
       uses `A` and `B` as key/values (and not subclasses of it).  The false-negative
       can occur when subtypes of A or B are used.  In such cases we fall back to the
       [SubtypeTestCache]-based imlementation.

    Reviewed-on: https://dart-review.googlesource.com/44788

Relands 25f98bcc75

    [VM] Introduction of type testing stubs - Part 3

    The changes include:

      * Make AssertAssignableInstr no longer have a call-summary, which
        helps methods with several parameter checks by not having to
        re-load/re-initialize type arguments registers

      * Lazily create SubtypeTestCaches: We already go to runtime to warm up
        the caches, so we now also create the caches on the first runtime
        call and patch the pool entries.

      * No longer load the destination name into a register: We only need
        the name when we throw an exception, so it is not on the hot path.
        Instead we let the runtime look at the call site, decoding a pool
        index from the instructions stream.  The destination name will be
        available in the pool, at a consecutive index to the subtype cache.

      * Remove the fall-through to N=1 case for probing subtypeing tests,
        since those will always be handled by the optimized stubs.

      * Do not generate optimized stubs for FutureOr<T> (so far it just
        falled-through to TTS).  We can make optimzed version of that later,
        but it requires special subtyping rules.

      * Local code quality improvement in the type-testing-stubs: Avoid
        extra jump at last case of cid-class-range checks.

    There are still a number of optimization opportunities we can do in
    future changes.

    Reviewed-on: https://dart-review.googlesource.com/46984

Relands 2c52480ec8

    [VM] Introduction of type testing stubs - Part 4

    In order to avoid generating type testing stubs for too many types in
    the system - and thereby potentially cause an increase in code size -
    this change introduces a smarter way to decide for which types we should
    generate optimized type testing stubs.

    The precompiler creates a [TypeUsageInfo] which we use to collect
    information.  More specifically:

       a) We collect the destination types for all type checks we emit
          (we do this inside AssertAssignableInstr::EmitNativeCode).

          -> These are types we might want to generate optimized type testing
             stubs for.

       b) We collect type argument vectors used in instance creations (we do
          this inside AllocateObjectInstr::EmitNativeCode) and keep a set of
          of used type argument vectors for each class.

    After the precompiler has finished compiling normal code we scan the set
    of destination types collected in a) for uninstantiated types (or more
    specifically, type parameter types).

    We then propagate the type argument vectors used on object allocation sites,
    which were collected in b), in order to find out what kind of types are flowing
    into those type parameters.

    This allows us to extend the set of types which we test against, by
    adding the types that flow into type parameters.

    We use this final augmented set of destination types as a "filter" when
    making the decision whether to generate an optimized type testing stub
    for a given type.

    Reviewed-on: https://dart-review.googlesource.com/48640

Issue https://github.com/dart-lang/sdk/issues/32603

Change-Id: I6d33d4ca3d5187a1eb1664078c003061855f0160
Reviewed-on: https://dart-review.googlesource.com/50482
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-04-10 12:20:10 +00:00
Martin Kustermann 1e997ee6b7 Revert "Reland "[VM] Introduction of type testing stubs - Part 1-4""
This reverts commit 8054409a02.

Reason for revert: Potential cause of flakes, not entirely clear yet if it was caused by this CL.

Change-Id: Icb119a107f22245ba2f303c7f2ae11f061f605f5
Reviewed-on: https://dart-review.googlesource.com/50261
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-04-09 14:29:07 +00:00
Martin Kustermann 8054409a02 Reland "[VM] Introduction of type testing stubs - Part 1-4"
Relands 165c583d57

    [VM] Introduction of type testing stubs - Part 1

    This CL:

      * Adds a field to [RawAbstractType] which will always hold a pointer
        to the entrypoint of a type testing stub

      * Makes this new field be initialized to a default stub whenever a
        instances are created (e.g. via Type::New(), snapshot reader, ...)

      * Makes the clustered snapshotter write a reference to the
        corresponding [RawInstructions] object when writing the field and do
        the reverse when reading it.

      * Makes us call the type testing stub for performing assert-assignable
        checks.

    To reduce unnecessary loads on callsites, we store the entrypoint of the
    type testing stubs directly in the type objects.  This means that the
    caller of type testing stubs can simply branch there without populating
    a code object first.  This also means that the type testing stubs
    themselves have no access to a pool and we therefore also don't hold on
    to the [Code] object, only the [Instruction] object is necessary.

    The type testing stubs do not setup a frame themselves and also have no
    safepoint.  In the case when the type testing stubs could not determine
    a positive answer they will tail-call a general-purpose stub.

    The general-purpose stub sets up a stub frame, tries to consult a
    [SubtypeTestCache] and bails out to runtime if this was unsuccessful.

    This CL is just the the first, for ease of reviewing.  The actual
    type-specialized type testing stubs will be generated in later CLs.

    Reviewed-on: https://dart-review.googlesource.com/44787

Relands f226c22424

    [VM] Introduction of type testing stubs - Part 2

    This CL starts building type testing stubs specialzed for [Type] objects
    we test against.

    More specifically, it adds support for:

      * Handling obvious fast cases on the call sites (while still having a
        call to stub for negative case)

      * Handling type tests against type parameters, by loading the value
        of the type parameter on the call sites and invoking it's type testing stub.

      * Specialzed type testing stubs for instantiated types where we can
        do [CidRange]-based subtype-checks.

        ==> e.g. String/List<dynamic>

      * Specialzed type testing stubs for instantiated types where we can
        do [CidRange]-based subclass-checks for the class and
        [CidRange]-based subtype-checks for the type arguments.

        ==> e.g. Widget<State>, where we know [Widget] is only extended and not
                 implemented.

      * Specialzed type testing stubs for certain non-instantiated types where we
        can do [CidRange]-based subclass-checks for the class and
        [CidRange]-based subtype-checks for the instantiated type arguments and
        cid based comparisons for type parameters.  (Note that this fast-case migth
        result in some false-negatives!)

        ==> e.g. _HashMapEntry<K, V>, where we know [_HashMapEntry] is only
                 extended and not implemented.

       This optimizes cases where the caller uses `new HashMap<A, B>()` and only
       uses `A` and `B` as key/values (and not subclasses of it).  The false-negative
       can occur when subtypes of A or B are used.  In such cases we fall back to the
       [SubtypeTestCache]-based imlementation.

    Reviewed-on: https://dart-review.googlesource.com/44788

Relands 25f98bcc75

    [VM] Introduction of type testing stubs - Part 3

    The changes include:

      * Make AssertAssignableInstr no longer have a call-summary, which
        helps methods with several parameter checks by not having to
        re-load/re-initialize type arguments registers

      * Lazily create SubtypeTestCaches: We already go to runtime to warm up
        the caches, so we now also create the caches on the first runtime
        call and patch the pool entries.

      * No longer load the destination name into a register: We only need
        the name when we throw an exception, so it is not on the hot path.
        Instead we let the runtime look at the call site, decoding a pool
        index from the instructions stream.  The destination name will be
        available in the pool, at a consecutive index to the subtype cache.

      * Remove the fall-through to N=1 case for probing subtypeing tests,
        since those will always be handled by the optimized stubs.

      * Do not generate optimized stubs for FutureOr<T> (so far it just
        falled-through to TTS).  We can make optimzed version of that later,
        but it requires special subtyping rules.

      * Local code quality improvement in the type-testing-stubs: Avoid
        extra jump at last case of cid-class-range checks.

    There are still a number of optimization opportunities we can do in
    future changes.

    Reviewed-on: https://dart-review.googlesource.com/46984

Relands 2c52480ec8

    [VM] Introduction of type testing stubs - Part 4

    In order to avoid generating type testing stubs for too many types in
    the system - and thereby potentially cause an increase in code size -
    this change introduces a smarter way to decide for which types we should
    generate optimized type testing stubs.

    The precompiler creates a [TypeUsageInfo] which we use to collect
    information.  More specifically:

       a) We collect the destination types for all type checks we emit
          (we do this inside AssertAssignableInstr::EmitNativeCode).

          -> These are types we might want to generate optimized type testing
             stubs for.

       b) We collect type argument vectors used in instance creations (we do
          this inside AllocateObjectInstr::EmitNativeCode) and keep a set of
          of used type argument vectors for each class.

    After the precompiler has finished compiling normal code we scan the set
    of destination types collected in a) for uninstantiated types (or more
    specifically, type parameter types).

    We then propagate the type argument vectors used on object allocation sites,
    which were collected in b), in order to find out what kind of types are flowing
    into those type parameters.

    This allows us to extend the set of types which we test against, by
    adding the types that flow into type parameters.

    We use this final augmented set of destination types as a "filter" when
    making the decision whether to generate an optimized type testing stub
    for a given type.

    Reviewed-on: https://dart-review.googlesource.com/48640

Issue https://github.com/dart-lang/sdk/issues/32603

Change-Id: I44a1d5d4b27454ae026aef2a301aada3dd399ea0
Reviewed-on: https://dart-review.googlesource.com/49861
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-04-09 11:25:36 +00:00
Martin Kustermann dbb1d3d44f Revert "[VM] Introduction of type testing stubs - Part 1-4"
This reverts commit 2c52480ec8.
This reverts commit 25f98bcc75.
This reverts commit f226c22424.
This reverts commit 165c583d57.

Change-Id: I3892d672b9ca0b0acc0b9b83c32ecc92355839c2
Reviewed-on: https://dart-review.googlesource.com/49843
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-04-06 08:35:01 +00:00
Martin Kustermann 2c52480ec8 [VM] Introduction of type testing stubs - Part 4
In order to avoid generating type testing stubs for too many types in
the system - and thereby potentially cause an increase in code size -
this change introduces a smarter way to decide for which types we should
generate optimized type testing stubs.

The precompiler creates a [TypeUsageInfo] which we use to collect
information.  More specifically:

   a) We collect the destination types for all type checks we emit
      (we do this inside AssertAssignableInstr::EmitNativeCode).

      -> These are types we might want to generate optimized type testing
         stubs for.

   b) We collect type argument vectors used in instance creations (we do
      this inside AllocateObjectInstr::EmitNativeCode) and keep a set of
      of used type argument vectors for each class.

After the precompiler has finished compiling normal code we scan the set
of destination types collected in a) for uninstantiated types (or more
specifically, type parameter types).

We then propagate the type argument vectors used on object allocation sites,
which were collected in b), in order to find out what kind of types are flowing
into those type parameters.

This allows us to extend the set of types which we test against, by
adding the types that flow into type parameters.

We use this final augmented set of destination types as a "filter" when
making the decision whether to generate an optimized type testing stub
for a given type.

Issue https://github.com/dart-lang/sdk/issues/32603

Measured impact on flutter HEAD-HEAD-HEAD with TTS Part 1 - 4 applied (2018-04-03):

      * stock build benchmark: around 4% improvement
      * gallery app.so size: -2.68%  (13987348 -> 13612928)
      * gallery memory: no sigificant changes:
         - SubtypeTestCache: - 10kb
         - ObjectPool: + 6 kb
         - Type: no change (probably due to wasted alignment slot before)
         - TypeParameter: + 4 kb (can get rid of the field here later)
      * gallery AOT compile-time: measured +1.3%, inside flakiness range

Change-Id: I12a398d18f970ba2db741913bb47b0f36ae38d58
Reviewed-on: https://dart-review.googlesource.com/48640
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-04-06 07:00:50 +00: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
Ben Konyi c0511ad2ef Reimplemented zone memory tracking to avoid race conditions that were causing crashes in the previous implementation and made some minor name changes.
BUG=
R=asiva@google.com, johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2762323002 .
2017-03-23 09:03:08 -07:00
Ben Konyi a3ec04eb99 Fixed bad calculations for determining total allocated size of a zone.
BUG=
R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2570763002 .
2016-12-12 17:48:59 -08:00
Ben Konyi 35a49bc1ff Created methods to surface zone memory information for each isolate and thread in JSON.
BUG=
R=asiva@google.com, johnmccutchan@google.com, zra@google.com

Review URL: https://codereview.chromium.org/2554983002 .
2016-12-12 09:56:49 -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
Zachary Anderson 103881d01c Make header include guards great again
i.e. #ifndef VM_WHATEVER -> #ifndef RUNTIME_VM_WHATEVER

This lets us remove a hack from the PRESUBMIT.py script that existed
for reasons that are no longer valid, and sets us up to add some
presubmit checks for the GN build.

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

Review URL: https://codereview.chromium.org/2450713004 .
2016-10-26 00:26:03 -07:00
John McCutchan bc119f28bb Relax zone allocation assertion
- [x] Allow allocation in any zone that is owned by the current thread not just the top zone.

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2360963005 .
2016-09-23 13:06:14 -07:00
Ryan Macnak 326af5e9d7 Move Zone's destructor out of a header file.
This unburdens users of StackZone from needing to include handles_impl.h. A new use of StackZone was recently added to heap.cc without a include of handles_impl.h, and this caused link-time errors on some versions of gcc.

R=asiva@google.com

Review URL: https://codereview.chromium.org/2362573002 .
2016-09-22 13:16:36 -07:00
Zachary Anderson e933f28a18 Remove some uses of STL map.
This CL removes the use of STL map from freelist.cc by adding
MallocDirectChainedHashMap in hash_map.h and adding an iterator for
BaseDirectChainedHashMap there.

It also removes a use of STL map from hash_table.h that was dead code.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2083103002 .
2016-06-22 08:32:37 -07:00
Todd Turnidge a7d46eb5a6 Canonicalize uris in C++ instead of Dart for the standalone embedder.
Adds Dart_DefaultCanonicalizeUrl() to the dart embedding api.

Motivation:

As we try to get source reloading working for the standalone embedder, things get simpler if an isolate doesn't run Dart code while it is loading Dart code.  We intend to solve this by moving the embedder tag handler calls to the service isolate.  But making a blocking rpc into the service isolate whenever a url needs to be canonicalized during parsing seems like it would slow things down and make things complicated.  By moving canonicalization into C++, we avoid this.

R=ahe@google.com, fschneider@google.com, johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2011543002 .
2016-06-02 12:29:57 -07:00
Ivan Posva 9c0c6cb5c2 Add product mode:
- Add PRODUCT define and build mode to gyp configurations.
- Add product mode to test harness.
- Start to unify list of flags.
- Allow flags to be constant for particular build configurations.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1663863002 .
2016-02-03 21:10:30 -08:00
Srdjan Mitrovic 8c7a94e9f4 Preparation for moving reusable handles to thread and more cleanups: isolate -> thread based handle allocation.
BUG=
R=koda@google.com

Review URL: https://codereview.chromium.org/1384403002 .
2015-10-06 10:17:12 -07:00
John McCutchan 03b41129a2 Add Timeline to dart:developer
- This CL only adds support for synchronous blocks of time. A follow up CL will add asynchronous blocks of time.
- Reports true thread id to tracing system. This is an improvement over Mojo's tracing helper.
- Dart events are included in individual isolate traces and global traces obtained via the embedders API.
- Dart events are included in the write to disk path (--timeline_dir).

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1377663002 .
2015-10-01 09:30:47 -07:00
Zachary Anderson 16393ee9c6 Uses SNPRINT macro where possible. Otherwise uses #define for format.
I was able to convert 49 SNPrint(NULL, 0, ...) patterns to use the
macro. I had to use a #define for the format string 5 times due to
uses that didn't fit the macro.

2 occurences of SNPrint(NULL, 0, ...) had >=2 possibilities for the
format string based on runtime values, and I didn't try to convert
them.

Fixed ~10 format strings.

BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//1331623002 .
2015-09-11 00:18:14 -07:00
Ivan Posva 0a0b101fbd - Remove deprecated StackZone constructor with Isolate parameter.
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1312813006 .
2015-09-02 16:07:48 -07:00
John McCutchan 4511599443 Start TimelineAnalysis utility
- Add TimelineEventBlockIterator - iterate over TimelineEventBlocks.
- Add TimelineAnalysisThread - All events for a specific thread.
- Add TimelineAnalysis - Utility for analyzing timeline events.
- Add unit test for TimelineAnalysis thread discovery and block sorting.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1284263002 .
2015-08-12 13:31:31 -07:00
Daniel Andersson 7f890eeecf Support per-thread zones and stack resources.
This is needed to enable parallel marking/sweeping (and in the future, compilation) tasks to have their own zone allocations and to safely call code that relies on various scoped constructs (stack resources).

The next step is to migrate the scopes like NoSafepointScope, NoHandleScope, etc. from isolate- to thread-based interfaces.

NOTE: This is a copy of issue 1204303003.

BUG=

Review URL: https://codereview.chromium.org//1226403003 .
2015-07-09 11:22:26 -07:00
koda@google.com b14c05aa42 Fix build by silencing zero-length memset warning.
When the compiler figures out that a particular code path does not add any elements to a zone-allocated growable array, it will generate a warning for the debug-mode zapping code in Zone::Free:

/usr/include/bits/string3.h:82:32: error: call to ‘__warn_memset_zero_len’ declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror]

There are plenty of false positives, e.g., a struct member happens to be unpopulated at a particular use case.
Fix this by only calling memset for non-zero lengths.

TBR=asiva@google.com

Review URL: https://codereview.chromium.org//849873002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42825 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-13 17:34:09 +00:00
koda@google.com bf07d168c4 MallocGrowableArray
To be used where neither Dart nor zone allocation is suitable, such as ClassTable.

Also add ASSERT_NOTNULL convenience macro for use in initializer lists.

R=asiva@google.com

Review URL: https://codereview.chromium.org//850473002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42819 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-13 16:40:09 +00:00
koda@google.com 5d9e207c44 Double-align Zone allocations to fix MIPS issue.
Also ensure initial buffer is aligned.

~2% increase in total allocated zone memory on compile-heavy benchmarks.
No significant impact on speed for either ia32 or arm.

R=iposva@google.com

Review URL: https://codereview.chromium.org//832713006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42797 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-13 01:56:30 +00:00
koda@google.com 01dfb15825 Grow allocation in Zone::Realloc when possible.
Typical success rate is 30-40% of calls to Realloc, which is used by GrowableArray.

Typical total zone memory savings are ~3%.

Review URL: https://codereview.chromium.org//851513002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42788 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-12 22:00:27 +00:00
iposva@google.com 043c80e0a9 - Ensure that BaseIsolate is only used to break the header include cycles.
R=asiva@google.com

Review URL: https://codereview.chromium.org//269023005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35770 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-05 21:45:38 +00:00
jacobr@google.com 605b33c1bc fix cpp11 compile errors
R=asiva@google.com

Review URL: https://codereview.chromium.org//23072026

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26387 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-20 20:24:11 +00:00
asiva@google.com ed73754c3f Rearrange some methods so that they get inlined.
R=srdjan@google.com

Review URL: https://codereview.chromium.org//22307003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25843 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-06 22:58:53 +00:00
tball@google.com 2cd8436c5a Changed StackZone and ApiZone to be containers for Zone.
BUG=

Review URL: https://codereview.chromium.org//11028145

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@13707 260f80e4-7a28-3924-810f-c04153c831b5
2012-10-16 22:05:40 +00:00
tball@google.com 76d7c9b105 Renamed Zone->StackZone, BaseZone->Zone, in preparation for changing isolate->get_zone() to return what was called the BaseZone instead of its wrapper. The GetBaseZone() methods were not renamed, to help the next CL.
BUG=

Review URL: https://codereview.chromium.org//11040062

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@13314 260f80e4-7a28-3924-810f-c04153c831b5
2012-10-05 19:52:55 +00:00
cshapiro@google.com da14bf70a7 Add attributions so printf like functions can have their arguments checked.
This change also corrects some misuses of format strings and format
arguments that discovered by the compiler checks.

Review URL: https://chromiumcodereview.appspot.com//10869063

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11912 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-06 00:58:25 +00:00
turnidge@google.com 2803d78dfd Change the zone allocation api.
Instead of passing a size in bytes to the allocation function, we now
have a templatized Alloc function:

  zone->Alloc<Type>(len)

This is better for security, as we can check for integer overflow in
the size computation before performing the allocation.  Before, we
often failed to check this.
Review URL: https://chromiumcodereview.appspot.com//10836061

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10254 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-03 21:51:44 +00:00
turnidge@google.com 5f30febb45 Inline the StackResource constructor/destructor.
This yields a 29% improvement on the Benchmark_UseDartApi microbenchmark.

To do this, I had to split a few fields from Isolate into a
BaseIsolate class.  Sort of yucky.
Review URL: https://chromiumcodereview.appspot.com//10008030

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6288 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-06 18:00:51 +00:00
turnidge@google.com e61a02c10d Implement spawnFunction from the new isolate api.
Still need to implement spawnUri, which will be the more difficult one.
Review URL: https://chromiumcodereview.appspot.com//9691005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5441 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-13 22:05:08 +00:00
sgjesse@google.com 3481c5661a Decode the Dart message into a Dart_CMessage structure before calling the native port callback
The native port callback is now passed the message as a decodes
Dart_CMessage structure. The Dart_CMessage structure is allocated
in a zone and the callback receiving it should expect the
lifetime to be controlled by the caller.

Added support for zones which do not require a current
isolate. Changed the GrowableArray to support allocating in
aprovided zone instead of the zone for the current isolate.

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

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9325022

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4068 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-09 08:47:19 +00:00
sgjesse@google.com 65896148c9 Move utils.h and utils.cc from runtime/vm to runtime/platform
Moved additional parts of globals.h from vm/ to platform/ to support
types and constants used by utils.*.

R=ager@google.com, iposva@google.com

BUG=
TEST=

Review URL: http://codereview.chromium.org//9209001

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3337 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-16 13:23:40 +00:00
asiva@google.com 4aacd28754 Make the implicit constructor private for zone, handlescope and nohandlescope classes.
Review URL: http://codereview.chromium.org//8562008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1718 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-21 21:07:40 +00:00
asiva@google.com 5cf3ad018a Changes to pass the current isolate to all runtime and native calls.
Review URL: http://codereview.chromium.org//8528010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1499 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-12 05:55:22 +00:00
dgrove@google.com 4c0f559d23 Initial checkin.
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-05 05:20:07 +00:00