Commit graph

37 commits

Author SHA1 Message Date
Régis Crelier
a39833d957 Reland "Reland "[VM runtime] Dual mapping of executable pages.""
This is a reland of 6da340bf76

Original change's description:
> Reland "[VM runtime] Dual mapping of executable pages."
> 
> This is a reland of 44186dfdcd
> 
> Original change's description:
> > [VM runtime] Dual mapping of executable pages.
> > 
> > Change-Id: Iaad78d324e25462ce951f4df26974a6a368c50b7
> > Reviewed-on: https://dart-review.googlesource.com/c/93377
> > Commit-Queue: Régis Crelier <regis@google.com>
> > Reviewed-by: Ryan Macnak <rmacnak@google.com>
> 
> Change-Id: I7a0caa078950637d9fe831732577fd2467061099
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95263
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

Change-Id: I3a01f0e67d733c5db41618f691431e72c1e1cb2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96422
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-03-12 20:45:45 +00:00
Vyacheslav Egorov
9ff0a654ca Revert "Reland "[VM runtime] Dual mapping of executable pages.""
This reverts commit 6da340bf76.

Reason for revert: almost all benchmarks are now failing on Golem linux-x64 target. Flutter Golem build is broken 

Original change's description:
> Reland "[VM runtime] Dual mapping of executable pages."
> 
> This is a reland of 44186dfdcd
> 
> Original change's description:
> > [VM runtime] Dual mapping of executable pages.
> > 
> > Change-Id: Iaad78d324e25462ce951f4df26974a6a368c50b7
> > Reviewed-on: https://dart-review.googlesource.com/c/93377
> > Commit-Queue: Régis Crelier <regis@google.com>
> > Reviewed-by: Ryan Macnak <rmacnak@google.com>
> 
> Change-Id: I7a0caa078950637d9fe831732577fd2467061099
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95263
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

TBR=rmacnak@google.com,regis@google.com

Change-Id: I3342de2584537269ffe9a53946bef27cb25a69fc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96161
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2019-03-09 14:15:39 +00:00
Régis Crelier
6da340bf76 Reland "[VM runtime] Dual mapping of executable pages."
This is a reland of 44186dfdcd

Original change's description:
> [VM runtime] Dual mapping of executable pages.
> 
> Change-Id: Iaad78d324e25462ce951f4df26974a6a368c50b7
> Reviewed-on: https://dart-review.googlesource.com/c/93377
> Commit-Queue: Régis Crelier <regis@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

Change-Id: I7a0caa078950637d9fe831732577fd2467061099
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95263
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-03-08 18:33:02 +00:00
Régis Crelier
0491d5cde7 Revert "[VM runtime] Dual mapping of executable pages."
This reverts commit 44186dfdcd.

Reason for revert: not working on vm-kernel-precomp-android-release-arm

Original change's description:
> [VM runtime] Dual mapping of executable pages.
> 
> Change-Id: Iaad78d324e25462ce951f4df26974a6a368c50b7
> Reviewed-on: https://dart-review.googlesource.com/c/93377
> Commit-Queue: Régis Crelier <regis@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

TBR=rmacnak@google.com,regis@google.com

Change-Id: I793ceee6252111eafbcbfe6e28268f4f6f2d7215
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/94989
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-03-01 22:55:14 +00:00
Régis Crelier
44186dfdcd [VM runtime] Dual mapping of executable pages.
Change-Id: Iaad78d324e25462ce951f4df26974a6a368c50b7
Reviewed-on: https://dart-review.googlesource.com/c/93377
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-03-01 22:19:31 +00:00
Martin Kustermann
28f8c96abe [VM] Bare instructions - Part 5: Get rid of CODE_REG indirection in SwitchableCalls
If the --use-bare-instructions flag is enabled we will:

  * Make call sites load the target directly from the pool (instead of
    the code object) - this saves one instruction (and an indirect load)

  * Ensure the object pool will have direct entry addresses by:

     - Letting the clustered snapshot reader change any StubCode::UnlinkedCall()
       in the object pool by it's monomorphic entry
     - Change the code patcher to patch SwitchableCalls by writing the
       monomorphic entry into the pool (instead of the code object)

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

Change-Id: I4e41fc8e4461bde477cc559a6a4fccaaf3a350b5
Reviewed-on: https://dart-review.googlesource.com/c/86160
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-12-14 16:11:53 +00:00
Ryan Macnak
3e8b335af8 [vm] Adjust concurrent marker to re-enable code W^X.
Take 2: account for encountering Instructions in the write barrier.

Bug: https://github.com/dart-lang/sdk/issues/34002
Change-Id: I31a8fc8965042678a861a05b09070d52fa07e4a5
Reviewed-on: https://dart-review.googlesource.com/c/87082
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-12-14 02:02:54 +00:00
Ryan Macnak
e15e8609aa [vm, gc] Fix merge mistake from 04941b5507 that effectively disabled concurrent marking by setting the soft and hard allocation limits to be the same.
Revert 0b66d91cd4, which has issues unmasked by the above.

Bug: https://github.com/dart-lang/sdk/issues/30433
Bug: https://github.com/dart-lang/sdk/issues/34002
Change-Id: I95129dd2bbafa717989a57c5d62582fdb2e64ffe
Reviewed-on: https://dart-review.googlesource.com/c/87121
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-12-12 23:14:08 +00:00
Ryan Macnak
0b66d91cd4 [vm] Adjust concurrent marker to re-enable code W^X.
Bug: https://github.com/dart-lang/sdk/issues/34002
Change-Id: I53081e8a19b21804bee776ecab0779c723907008
Reviewed-on: https://dart-review.googlesource.com/c/85624
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-12-03 17:24:58 +00:00
Ryan Macnak
7f55e52888 [vm, x64] Use short forms for object pool loads.
We now patch object pool entries instead of pool load indices.

dart2js release
AOT X64 Instructions(CodeSize): 10171808 -> 9567168 (-5.94%)
JIT X64 Instructions(CodeSize): 14298624 -> 13163968 (-7.94%)

Bug: https://github.com/dart-lang/sdk/issues/29077
Change-Id: I84938a5717b79d65e941141539d7f82e02c89858
Reviewed-on: https://dart-review.googlesource.com/c/78185
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
2018-10-09 17:30:25 +00:00
Samir Jindel
6c5326ae80 [vm] Fix issue with debugging generated code within RR.
Change-Id: Ifa13d6695624158367b0aa1baadd6ca41e13197f
Reviewed-on: https://dart-review.googlesource.com/c/77880
Auto-Submit: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2018-10-03 14:09:17 +00:00
Ryan Macnak
93dcfaa289 [vm, gc] Concurrent marking.
Fall back to parallel marking
 - on IA32 (barrier unimplemented)
 - when write_protect_code is enabled (protection dependency on marking state unimplemented)

Bug: https://github.com/dart-lang/sdk/issues/34002
Change-Id: If093f24e4dc6bf29f407cc45e95bb2274fc53dcf
Reviewed-on: https://dart-review.googlesource.com/71389
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-09-21 21:30:33 +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
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.

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

Change-Id: I4dc5a8a49f939178fe74d44736ef69e4b9088e46
Reviewed-on: https://dart-review.googlesource.com/46984
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-04-06 07:00:50 +00:00
Ryan Macnak
e14b3a86f0 Report errno on mprotect failure.
Bug: b/70275153
Change-Id: I81b868b25428b39835935846ba2c9f9f67b3e84d
Reviewed-on: https://dart-review.googlesource.com/33665
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-01-10 01:37:49 +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
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
Srdjan Mitrovic
edccf3af0a Cleanup: we are not patching entries any longer
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1376963002 .
2015-09-30 10:22:59 -07:00
Florian Schneider
bac82e2592 VM: New calling convention for generated code.
Instead of calling code object directly, call indirectly and
pass the code object in a register. The object pool is then loaded from
the code object. This is another preparation step for making generated code
relocatable.

All non-ia32 platforms:
No entry patching.

ARM:
PC marker (now code object) moves to the same place as on x64 (below saved PP, above saved FP).
R9 is now used as PP, R10 as CODE_REG.

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

Committed: 1d343e5a7b

Review URL: https://codereview.chromium.org//1192103004 .
2015-09-19 13:21:09 +02:00
Florian Schneider
7af7a2db87 Revert "VM: New calling convention for generated code."
This reverts commit 1d343e5a7b.

Because of Windows test failures.

BUG=
TBR=whesse@google.com

Review URL: https://codereview.chromium.org//1343373003 .
2015-09-16 13:46:05 +02:00
Florian Schneider
1d343e5a7b VM: New calling convention for generated code.
Instead of calling code object directly, call indirectly and
pass the code object in a register. The object pool is then loaded from
the code object. This is another preparation step for making generated code
relocatable.

All non-ia32 platforms:
No entry patching.

ARM:
PC marker (now code object) moves to the same place as on x64 (below saved PP, above saved FP).
R9 is now used as PP, R10 as CODE_REG.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1192103004 .
2015-09-16 13:05:58 +02:00
fschneider@google.com
c2fad4230c VM: Enable collection of unoptimized code for optimized functions.
Until now, code GC was limited to function that have not been optimized.
With lazy generation of unoptimized code on deoptimization we can now
collect unoptimized code for optimized functions as well.

R=vegorov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45062 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-10 12:02:30 +00:00
fschneider@google.com
559e6410e2 First step in reducing the size of PC descriptors.
The descriptors used for patching just contain a pc offset
and can be stored with the code object instead of allocating
a full descriptor and linearly searching the list to retrieve
this information.

R=srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36989 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-04 11:02:34 +00:00
iposva@google.com
3878793b10 - Reduce the number of Isolate::Current() calls.
R=johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36564 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-23 12:07:33 +00:00
fschneider@google.com
4a26c88735 Fix crash bug in free list when allocating write protected memory.
Re-enable write protection of code pages.

I added cc tests that cover two corner conditions that caused the old code to crash.

TEST=vm/FreeList
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32647 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-13 11:59:22 +00:00
ricow@google.com
79eab5b7e0 Disable write protect mode temporarily until we have a fix for the random crashes
Review URL: https://codereview.chromium.org//156423004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32547 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-11 09:38:10 +00:00
fschneider@google.com
d6178535b2 Landing: Write protect executable pages in the VM.
Change executable pages to be read/execute but not writable by default.

All pages are made temporarily writable just before a full GC, because both
the mark and sweep phases write to the pages. When allocating in a page and
when patching code, the pages are made temporarily writable.

The order of allocation of Code and Instructions objects is changed so that
a GC will not occur after Instructions is allocated. (A full GC would
render the Instructions unwritable.) A scoped object is used to make memory
protection simpler.

Original CL: https://codereview.chromium.org/106593002/

I added a cc test that is expected to crash.

R=srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32493 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-10 12:18:06 +00:00
johnmccutchan@google.com
7da1f4f3ba Build map of code regions and address ticks for profile report.
Profile pauses should be less than 500 ms even when handling 120,000 samples (2 minutes @ 1000 hz).
Code objects are referenced by hex address: "code/cafebabe".
Test for retrieving code objects over the service.
Remove old profile tool scripts. Replaced by dprof (https://github.com/dart-lang/dprof) and Observatory UI for profiler.
Support for stable service refs to implicit closures and dispatcher functions.

R=srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31447 260f80e4-7a28-3924-810f-c04153c831b5
2014-01-03 19:55:50 +00:00
zra@google.com
df2054dae7 Sets a register aside on x64 for use as a pool-pointer. It is loaded and restored from the code object on Frame entry and exit. All LoadObject calls that can, and many calls and jumps through ExternalLabels now use the pool-pointer. The --compiler-stats flag when running dart2js indicates that code size is reduced ~13%, and more is probably possible.
R=fschneider@google.com, srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27295 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-09 15:39:26 +00:00
srdjan@google.com
a696cc5644 Add asserts to catch missing deoptimization info early.
Review URL: https://codereview.chromium.org//12806007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20299 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-20 23:26:07 +00:00
regis@google.com
7766ac76d4 Implement leaf runtime call stub on ARM and corresponding call redirection
in ARM simulator.
Implement jump patching on ARM.
Add missing ICache flush calls.
Review URL: https://codereview.chromium.org//12439005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19724 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-08 21:16:46 +00:00
srdjan@google.com
04fc29c7e1 Optimize function at its entry instead of at exit.
The code can be patched if it should not be executed any longer.
The code can be now patched at other location than at entry, the requirement is still that patching code does not overwrite an inlined object.
Intrinsic methods that do not have a fall through cannot be patched.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16897 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-10 00:28:57 +00:00