Commit Graph

60 Commits

Author SHA1 Message Date
Aske Simon Christensen 1ab705f60c [vm] Require all recognized methods to be marked with pragma.
Adds a @pragma("vm:recognized", <kind>) to all recognized methods, where
<kind> is one of "intrinsic", "graph" or "other", corresponding to the
kind of recognized method.

When running in debug mode, it is checked that all recognized methods
are marked with the correct kind of pragma, and that all methods marked
with the pragma are in fact recognized.

This enables kernel-level analyses and optimizations to query whether
a method is recognized by the VM.

TEST=Asserts that check the correspondence both ways, covered by test
suite, in particular the various CompileAll tests that compile all code.
Change-Id: I12f3305c72a93ecb1aefae2d66e3d9a7dae23b44
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168951
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-11-16 13:49:50 +00:00
Alexander Markov 0162e7c1f8 [vm] Enable fingerprints checking of recognized methods
Fixes https://github.com/dart-lang/sdk/issues/36376

Change-Id: I470b95a1f854ef6e3798422508a89bc61f71cd0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153740
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-09 17:10:57 +00:00
Ryan Macnak 6fe15f6df9 [vm] Represent tagged pointers as C++ value types instead of C++ pointer types.
This works around bugs in UndefinedBehaviorSanitizer and Clang.

Bug: b/28638298
Change-Id: I6be595f9664516019d28017d24559583a1ae3a21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144354
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-04-25 05:21:27 +00:00
Vyacheslav Egorov beb7114861 [vm/compiler] Add check to prevent inclusion of compiler headers into AOT runtime
This relands commit b0a71d364c

Cq-Include-Trybots: dart/try:vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-linux-release-simarm-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: I1d32e5d0d44f4e422d188643b548ed81859f7d74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143807
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-04-17 13:11:08 +00:00
Alexander Aprelev c7861f309f Revert "[vm/compiler] Add check to prevent inclusion of compiler headers into AOT runtime"
This reverts commit b0a71d364c as it broke precomp builds.

Change-Id: Ieb776739b8d3e9ac74794e05fc20a793625e5f09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143865
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-04-16 23:51:09 +00:00
Vyacheslav Egorov b0a71d364c [vm/compiler] Add check to prevent inclusion of compiler headers into AOT runtime
#if defined(DART_PRECOMPILED_RUNTIME)
  #error "AOT runtime should not use compiler sources (including header files)"
  #endif  // defined(DART_PRECOMPILED_RUNTIME)

Remove #if defined(DART_PRECOMPILED_RUNTIME) from most compiler sources.

Change-Id: Id175c83fdbea38d9d5e1371ff433e3888f2afe8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143523
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-04-16 22:59:03 +00:00
Ryan Macnak b39ab2e6ac [vm] Don't unroll initialization code based on macro lists.
-47k (-0.20%) out/ProductX64/exe.stripped/dart
 -8k (-0.17%) out/ProductX64/exe.stripped/dart_precompiled_runtime

Change-Id: Id3f6c451acf69ba7965ae51a0a3c4a8aa9ab1d73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115775
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-11-14 19:11:38 +00:00
Teagan Strickland 4932ee6d80 Reland "[vm/compiler] Use pragmas instead of separately-maintained lists for inlining."
This closes https://github.com/dart-lang/sdk/issues/36571.

Change-Id: I14c623aba6b7183191ae93e294e26af9f4dcf34f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110441
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-07-30 13:14:57 +00:00
Alexander Markov d3a09dda15 [vm/bytecode] Recognize list factories and set result type for static calls
Sudoku +15.62%

Issue: https://github.com/dart-lang/sdk/issues/36429
Change-Id: I58cde03ffc9788b2eebe889fcc1a98a82698c39a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109887
Reviewed-by: Aart Bik <ajcbik@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-07-22 21:50:34 +00:00
Siva Annamalai 1eaaca642d Revert "[vm/compiler] Use pragmas instead of separately-maintained lists for inlining."
This reverts commit 33a757284b.

Reason for revert: This CL seems to depend on
@pragma('vm:never-inline')`
@pragma('vm:prefer-inline')`
being implemented which has been reverted.

Original change's description:
> [vm/compiler] Use pragmas instead of separately-maintained lists for inlining.
> 
> This closes https://github.com/dart-lang/sdk/issues/36571.
> 
> Change-Id: I4d77192f2c33dd4872d58ef07ccd32069b8b63df
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99154
> Commit-Queue: Teagan Strickland <sstrickl@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,sstrickl@google.com

Change-Id: Ied0686ad282f2ed772ff9adbc551f64ba8855aff
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109340
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2019-07-16 22:44:50 +00:00
Teagan Strickland 33a757284b [vm/compiler] Use pragmas instead of separately-maintained lists for inlining.
This closes https://github.com/dart-lang/sdk/issues/36571.

Change-Id: I4d77192f2c33dd4872d58ef07ccd32069b8b63df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99154
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-07-16 10:37:02 +00:00
Martin Kustermann 525b43d747 [vm] Decouple intrinsifier code from runtime
This is the next step towards preventing compiler from directly peeking
into runtime and instead interact with runtime through a well defined
surface.

This CL decouples the hand-written intrinsifier code from the runtime:

  * the intrinsifier is split up into a GraphIntrinsifier and AsmIntrinsifier
  * the recognized methods list is moved to a separate .h file
  * all intrinsifier code is moved into dart::compiler namespace
  * the AsmIntrinsifier is only interacting with RT through runtime_api.h

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

Change-Id: I0a73ad620e051dd49c9db7da3241212b3b74ccdd
Reviewed-on: https://dart-review.googlesource.com/c/92740
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
2019-02-13 17:22:56 +00:00
Aart Bik 6b5e8603d5 Reland "[vm/compiler] AOT inline heuristics improvements"
This reverts commit 43a96d49af.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> Revert "[vm/compiler] AOT inline heuristics improvements"
> 
> This reverts commit 2908e61f2a.
> 
> Reason for revert: regress_32322_test crashes
> 
> Original change's description:
> > [vm/compiler] AOT inline heuristics improvements
> > 
> > Rationale:
> > Yields substantial improvements on various benchmarks
> > (1.8x on HMAC stand-alone, around 5x on TypedData settters and getters),
> > with only moderate increase in code size (3.2% on Flutter gallery).
> > 
> > https://github.com/dart-lang/sdk/issues/34473
> > https://github.com/dart-lang/sdk/issues/32167
> > 
> > Change-Id: I0909efd7afc72229524ff8edb7322ce025a14af4
> > Reviewed-on: https://dart-review.googlesource.com/c/89162
> > Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
> > Reviewed-by: Alexander Markov <alexmarkov@google.com>
> > Commit-Queue: Aart Bik <ajcbik@google.com>
> 
> TBR=vegorov@google.com,alexmarkov@google.com,ajcbik@google.com
> 
> Change-Id: I9c7dadb18935ad32f4d4cd72872838e8ac9cc288
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://dart-review.googlesource.com/c/89740
> Reviewed-by: Aart Bik <ajcbik@google.com>
> Commit-Queue: Aart Bik <ajcbik@google.com>

TBR=vegorov@google.com,alexmarkov@google.com,ajcbik@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Iace9857654b63af2fbcd2808d19802fb60305973
Reviewed-on: https://dart-review.googlesource.com/c/90141
Reviewed-by: Aart Bik <ajcbik@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2019-01-18 00:20:35 +00:00
Aart Bik 43a96d49af Revert "[vm/compiler] AOT inline heuristics improvements"
This reverts commit 2908e61f2a.

Reason for revert: regress_32322_test crashes

Original change's description:
> [vm/compiler] AOT inline heuristics improvements
> 
> Rationale:
> Yields substantial improvements on various benchmarks
> (1.8x on HMAC stand-alone, around 5x on TypedData settters and getters),
> with only moderate increase in code size (3.2% on Flutter gallery).
> 
> https://github.com/dart-lang/sdk/issues/34473
> https://github.com/dart-lang/sdk/issues/32167
> 
> Change-Id: I0909efd7afc72229524ff8edb7322ce025a14af4
> Reviewed-on: https://dart-review.googlesource.com/c/89162
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Aart Bik <ajcbik@google.com>

TBR=vegorov@google.com,alexmarkov@google.com,ajcbik@google.com

Change-Id: I9c7dadb18935ad32f4d4cd72872838e8ac9cc288
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/89740
Reviewed-by: Aart Bik <ajcbik@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2019-01-15 21:08:00 +00:00
Aart Bik 2908e61f2a [vm/compiler] AOT inline heuristics improvements
Rationale:
Yields substantial improvements on various benchmarks
(1.8x on HMAC stand-alone, around 5x on TypedData settters and getters),
with only moderate increase in code size (3.2% on Flutter gallery).

https://github.com/dart-lang/sdk/issues/34473
https://github.com/dart-lang/sdk/issues/32167

Change-Id: I0909efd7afc72229524ff8edb7322ce025a14af4
Reviewed-on: https://dart-review.googlesource.com/c/89162
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2019-01-15 19:03:00 +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 0ef66e0f5c [VM] Add @pragma("vm:non-nullable-result-type") annotation
A field/function annotated with this pragma must be guaranteed to not
return `null` at runtime.

Make use of this non-nullable annotation in the VM's type propagator.

Annotates the "_TypedListView._typedData" field to ensure the VM knows it
returns a non-nullable _TypedListView.

Furthermore annotates methods on the integer implementation.  Those particular
methods are recognized methods with a "dynamic" return type.  This caused
the type propagator to use CompileType::Dynamic() as result type.  Since a
previous CL started to only utilize the annotated type if it is better than
"dynamic" more integer operations got handled in-line, though with null-checks.
Annotating those methods to return non-null improves the in-line handling of
integer operations.

This improves dart-aot

On arm7hf:
  SHA256: +5%, SHA: +6%, JsonObjectRoundTrip: +7%, ...

On arm8:
  SHA1: +28%, MD5: +25%, SHA256: +15%, TypedData.Int16ListViewBench: +18.5%, StringInterpolation: +18%, ...


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

Change-Id: Ia4263a37241a36c9dc35e8a48893297effa6f4b2
Reviewed-on: https://dart-review.googlesource.com/c/84421
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-11-22 16:18:27 +00:00
Martin Kustermann 08a4e020b3 [VM] Get rid of duplicate return-type-cid information from method recognizer
When @pragma('vm:exact-result-type') was introduced, the return types
specified in the recognized method lists were **duplicated** (they were
in the method recognizer macro lists as well as in the dart source code).

This CL removes this duplication by removing the result types from the
method recognizer lists.

Change-Id: I2082110cf77fc3b97d1a541cb153abb8c17990d0
Reviewed-on: https://dart-review.googlesource.com/c/84220
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-22 11:53:27 +00:00
Martin Kustermann 94c325a889 Reland "[VM] Make @pragma annotations work generally"
Currently the @pramga('vm:exact-result-type') annotation only works if
the function is a recognized method.  This change changes that to make
the VM just look if a function has the annotation (no matter if it's
also in the list of recognized methods or not).

Furthermore this CL lets the type propgagator use
@pragma('vm:exact-result-type') annotations to narrow the [CompileType]
set on [LoadFieldInstr]s.

Since the @pragma is a general feature, this CL moves the
`Function::FindPragma()` to `Library::FindPragma` (which is where any
other metadata lookup happens).  We also let the `FindPragma` accept any
of Class/Function/Field objects.

Furthermore the `FindPragma()` function is fixed to handle the case
when the evaluation of the metadata results in an error.
In this case we simply claim to not have found a pragma annotation.

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

Change-Id: If03f566e334cd53549985823ee3dd6b5e9672969
Reviewed-on: https://dart-review.googlesource.com/c/85163
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-22 10:54:44 +00:00
Martin Kustermann 845310302d Revert "[VM] Add @pragma annotations on Field, make @pragma annotations work generally"
This reverts commit 2de63ac01c.

Reason for revert: This triggers shutdown deadlocks for some reason:

#0  0xf7782cd9 __kernel_vsyscall
#1  0xf7753d0b pthread_cond_wait@@GLIBC_2.3.2
#2  0x0108a515 dart::Monitor::WaitMicros(long long)
#3  0x0108a467 dart::Monitor::Wait(long long)
#4  0x00fe9048 dart::KernelIsolate::Shutdown()
#5  0x00f99ae4 dart::Dart::Cleanup()
#6  0x01278fce Dart_Cleanup
#7  0x00dd347e dart::bin::main(int, char**)
#8  0x00dd3d64 main
#9  0xf745caf3 __libc_start_main
#10 0x00dd2021 _start
TID 30443:
#0  0xf7782cd9 __kernel_vsyscall
#1  0xf7531ee6 epoll_wait
#2  0x00ddab61 dart::bin::EventHandlerImplementation::Poll(unsigned int)
#3  0x00dfb2d4 dart::bin::ThreadStart(void*)
#4  0xf774ff72 start_thread
#5  0xf753143e __clone
TID 30444:
#0  0xf7782cd9 __kernel_vsyscall
#1  0xf7753d0b pthread_cond_wait@@GLIBC_2.3.2
#2  0x0108a515 dart::Monitor::WaitMicros(long long)
#3  0x0108a467 dart::Monitor::Wait(long long)
#4  0x012484d8 dart::BackgroundCompiler::Run()
#5  0x01248a37 dart::BackgroundCompilerTask::Run()
#6  0x0112203a dart::ThreadPool::Worker::Loop()
#7  0x01121efe dart::ThreadPool::Worker::Main(unsigned int)
#8  0x01089e73 dart::ThreadStart(void*)
#9  0xf774ff72 start_thread
#10 0xf753143e __clone

Original change's description:
> [VM] Add @pragma annotations on Field, make @pragma annotations work generally
> 
> Currently the @pramga('vm:exact-result-type') annotation only works if
> the function is a recognized method.  This change changes that to make
> the VM just look if a function has the annotation (no matter if it's
> also in the list of recognized methods or not).
> 
> Furthermore this CL adds a "has_pragma" bit to [Field] objects, similar
> to how we have it on [Function]/[Class]es.  This allows annotating
> fields with types, as we do with function return types.
> 
> Furthermore this CL lets the type propgagator use
> @pragma('vm:exact-result-type') annotations to narrow the [CompileType]
> set on [LoadFieldInstr]s.
> 
> Since the @pragma is a general feature, this CL moves the
> `Function::FindPragma()` to `Library::FindPragma` (which is where any
> other metadata lookup happens).  We also let the `FindPragma` accept any
> of Class/Function/Field objects.
> 
> Furthermore this CL adds a bailout if we try to evaluate metadata in
> the background compiler, since the background compiler is not allowed
> to execute generated code. The bailout should trigger a re-compilation
> on the mutator thread.
> 
> Furthermore the `FindPragma()` function is fixed to handle the case
> when the evaluation of the metadata results in e.g. a language error.
> In this case we simply claim to not have found a pragma annotation.
> 
> Issue https://github.com/dart-lang/sdk/issues/31954
> 
> Change-Id: I0900a80d5ae0f3e8d09baf13cba1b20dd974df31
> Reviewed-on: https://dart-review.googlesource.com/c/84037
> Commit-Queue: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>

TBR=vegorov@google.com,kustermann@google.com,alexmarkov@google.com,sjindel@google.com

Change-Id: Ic0d22d32b0eea3a76ec245cabab0006f97ca1b05
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/84622
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-11-16 14:50:32 +00:00
Martin Kustermann 2de63ac01c [VM] Add @pragma annotations on Field, make @pragma annotations work generally
Currently the @pramga('vm:exact-result-type') annotation only works if
the function is a recognized method.  This change changes that to make
the VM just look if a function has the annotation (no matter if it's
also in the list of recognized methods or not).

Furthermore this CL adds a "has_pragma" bit to [Field] objects, similar
to how we have it on [Function]/[Class]es.  This allows annotating
fields with types, as we do with function return types.

Furthermore this CL lets the type propgagator use
@pragma('vm:exact-result-type') annotations to narrow the [CompileType]
set on [LoadFieldInstr]s.

Since the @pragma is a general feature, this CL moves the
`Function::FindPragma()` to `Library::FindPragma` (which is where any
other metadata lookup happens).  We also let the `FindPragma` accept any
of Class/Function/Field objects.

Furthermore this CL adds a bailout if we try to evaluate metadata in
the background compiler, since the background compiler is not allowed
to execute generated code. The bailout should trigger a re-compilation
on the mutator thread.

Furthermore the `FindPragma()` function is fixed to handle the case
when the evaluation of the metadata results in e.g. a language error.
In this case we simply claim to not have found a pragma annotation.

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

Change-Id: I0900a80d5ae0f3e8d09baf13cba1b20dd974df31
Reviewed-on: https://dart-review.googlesource.com/c/84037
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-16 11:18:22 +00:00
Aart Bik 8ca05c506f [vm/compiler] Whitelist byteswap inlining
Rationale:
Always inlining byteswaps avoids calling into
the runtime when getInts remain.

https://github.com/dart-lang/sdk/issues/34473
https://github.com/dart-lang/sdk/issues/34969
https://github.com/dart-lang/sdk/issues/32167

Change-Id: I95c0348fa960e08f973a12a2c5304785e76289b3
Reviewed-on: https://dart-review.googlesource.com/c/83884
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-11-08 23:18:53 +00:00
Aart Bik 5cfffdbcca Revert "[vm/compiler] Tune AOT inline heuristics"
This reverts commit 74d2c6aa99.

Reason for revert: 

../../runtime/vm/compiler/backend/il.cc: 778: error: unreachable code

Original change's description:
> [vm/compiler] Tune AOT inline heuristics
> 
> Rationale:
> Last experiment left some performance at the table
> (but for an unacceptable 200% code size increase).
> This CL regains that performance for a much better
> trade-off of just 8%. Performance gains vary from
> 10% to 100%, with e.g. 27% for DeltaBlue, 30% for
> MD5 and 100% for SHA256). This is obtained by
> always inlining byteswaps (to avoid calling into
> the runtime when getInts remain) and a bit more
> specific tuning of loop based heuristics. This
> also fixes a bug in a list lookup.
> 
> https://github.com/dart-lang/sdk/issues/34473
> https://github.com/dart-lang/sdk/issues/34969
> https://github.com/dart-lang/sdk/issues/32167
> 
> Change-Id: Id1a64c3930c503546ae2d7f31ca3e597741022bb
> Reviewed-on: https://dart-review.googlesource.com/c/82942
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Aart Bik <ajcbik@google.com>

TBR=vegorov@google.com,kustermann@google.com,rmacnak@google.com,alexmarkov@google.com,ajcbik@google.com

Change-Id: Id0f30f4458a3548af2e573a737e441ca11ae3b11
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/83643
Reviewed-by: Aart Bik <ajcbik@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-11-08 08:51:20 +00:00
Aart Bik 74d2c6aa99 [vm/compiler] Tune AOT inline heuristics
Rationale:
Last experiment left some performance at the table
(but for an unacceptable 200% code size increase).
This CL regains that performance for a much better
trade-off of just 8%. Performance gains vary from
10% to 100%, with e.g. 27% for DeltaBlue, 30% for
MD5 and 100% for SHA256). This is obtained by
always inlining byteswaps (to avoid calling into
the runtime when getInts remain) and a bit more
specific tuning of loop based heuristics. This
also fixes a bug in a list lookup.

https://github.com/dart-lang/sdk/issues/34473
https://github.com/dart-lang/sdk/issues/34969
https://github.com/dart-lang/sdk/issues/32167

Change-Id: Id1a64c3930c503546ae2d7f31ca3e597741022bb
Reviewed-on: https://dart-review.googlesource.com/c/82942
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-11-08 01:04:55 +00:00
Ryan Macnak 97940e77a4 [vm, compiler] Remove use of StoreIntoObject for arrays from hand-written assembly.
- Convert _List.[]= and _List._setIndexed to graph intrinsics.
 - Remove _GrowableList.add intrinsics (dead since Dart 2).

Eliminates need to shuffle registers at the assembler level when introducing card-remembering.

Change-Id: Ia94ae3229a5eb90215ac74ab624db843a0cda01c
Reviewed-on: https://dart-review.googlesource.com/c/82380
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-11-01 16:30:28 +00:00
Martin Kustermann 16ddfc1565 [VM] Use assert assignable implementation for explicit downcasts
This makes explicit downcasts more efficient by re-using the
optimizations we already have for implicit downcasts.

For implicit/explicit as checks we use the symbol to distinguish which
exception to throw if the check fails.  So this does not actually
require unification of _CastError and _TypeError.

Issue https://github.com/dart-lang/sdk/issues/34582
Issue https://github.com/dart-lang/sdk/issues/30632
Issue https://github.com/dart-lang/sdk/issues/30571

Change-Id: I7b8818d2698e249c90a3e1b8790bad69ada649a9
Reviewed-on: https://dart-review.googlesource.com/c/78748
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-10-10 12:36:42 +00:00
Alexander Markov 741f662a60 [vm/kernel/bytecode] Fix number of checked arguments in bytecode calls
Number of checked arguments is corrected in ICData objects created when
reading bytecode, both for instance and static calls.

InstanceCall1 and InstanceCall2 bytecode instructions are replaced with
InstanceCall which works for any number of checked arguments. This makes
decision on number of checked arguments internal to VM and it is no longer
exposed to bytecode.

Change-Id: I0bba01eca6347336f3832de863b2ce4715fda04a
Reviewed-on: https://dart-review.googlesource.com/69421
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-13 17:50:21 +00:00
Vyacheslav Egorov c5f933fdf7 [vm/lib] String._identityHashCode should be the same as String.get:hashCode
On 64-bit platforms we use a field in the header to cache results of
Object.get:_identityHashCode. The very same field is also used to
cache String.get:hashCode result. Which means that their implementations
must be the same.

Fixes https://github.com/flutter/flutter/issues/20122

Change-Id: I98eef9eddf833c0d7c4c6f452728fe48e232efdc
Reviewed-on: https://dart-review.googlesource.com/68042
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-08-02 11:24:25 +00:00
Aart Bik c76e071b79 [vm/compiler] Improved integer power specialized inlining.
Rationale:
"Inlines" special cases of int pow() in strong mode
(viz. x^y for either small constant x or y).

History: revert^2 of
https://dart-review.googlesource.com/c/sdk/+/65576
https://dart-review.googlesource.com/c/sdk/+/66041

https://github.com/dart-lang/sdk/issues/33861

Change-Id: I779e18432a28e82db739cef77d6e6b82148eb70a
Reviewed-on: https://dart-review.googlesource.com/66120
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-07-22 20:59:48 +00:00
Aart Bik 9791508d90 Revert "[vm/compiler] Improved integer power specialized inlining."
This reverts commit cadc4c33ca.

Reason for revert: simarm is not happy with power, even without the opt

Original change's description:
> [vm/compiler] Improved integer power specialized inlining.
> 
> Rationale:
> "Inlines" special cases of int pow() in strong mode
> (viz. x^y for either small constant x or y).
> 
> https://github.com/dart-lang/sdk/issues/33861
> 
> Change-Id: I2e52784f82e39bb0ce33733aef70cbc56f27e451
> Reviewed-on: https://dart-review.googlesource.com/65576
> Commit-Queue: Aart Bik <ajcbik@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

TBR=vegorov@google.com,alexmarkov@google.com,asiva@google.com,ajcbik@google.com

Change-Id: I33daaf15fe7b7cac53ec5eeff76e867ee31d2451
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/66041
Reviewed-by: Aart Bik <ajcbik@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-07-20 23:24:46 +00:00
Aart Bik cadc4c33ca [vm/compiler] Improved integer power specialized inlining.
Rationale:
"Inlines" special cases of int pow() in strong mode
(viz. x^y for either small constant x or y).

https://github.com/dart-lang/sdk/issues/33861

Change-Id: I2e52784f82e39bb0ce33733aef70cbc56f27e451
Reviewed-on: https://dart-review.googlesource.com/65576
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-07-20 20:14:28 +00:00
Aart Bik 34fc26d4cd [vm/inliner] Inline 64-bit typed data.
Rationale:
This CL finalizes recent improvements by allowing
inlining 64-bit and double getter/setter operations.
The runtime over all data types (with and without
view) now no longer has outliers.

Note:
64-bit targets only, 32-bit targets still tbd.

Performance:
About 4x improvement on micro benchmarks.

https://github.com/dart-lang/sdk/issues/33205

Change-Id: Ic82fa24167a68e3c196edf4843f0829c7fbcf9e1
Reviewed-on: https://dart-review.googlesource.com/60451
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-07-02 17:41:43 +00:00
Alexander Markov 57c0fc9593 [vm/corelib] More cleanup in integer operations after _Bigint is removed
Change-Id: I41da6a37e554ffb8b77f51fda3fee5a15f2b8045
Reviewed-on: https://dart-review.googlesource.com/60441
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-18 18:16:51 +00:00
Aart Bik 2a396d5315 [vm/intrinsics] Intrinsify 64-bit int typed data.
Rationale:
With limited integers, signed/unsigned 64-bit int typed
data is just a bit pattern, no need to sign/zero extend
these into bigger ints on load. This enables more
intrinsification of indexed stores/loads.

Note:
Still TBD, inline these indexed operations too.

Performance:
About 10x improvement on micro benchmarks.

https://github.com/dart-lang/sdk/issues/33205


Change-Id: I640c324a7d91e57fb4edc025e0dd456ad34fe906
Reviewed-on: https://dart-review.googlesource.com/60403
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-06-15 18:09:40 +00:00
Aart Bik db72134f90 [vm/inliner] Add smi return type of clamped convertors.
Rationale:
Rather than forced inlining of clamped convertors
(the "saturated" method _toClampedUint8() from
dart:typed_data), exposing the fact that it always
returns smi values (since they check fail on null inputs)
yields much better Uint8ClampedListView performance
(it avoids re-compilation due to a speculative CheckSmi).

Note:
In the long run, we may still want them inlined
and improve range analysis to deal with clamping.

Performance:
About 2.8x faster than previous optimized version,
about 4.5x faster than original.

https://github.com/dart-lang/sdk/issues/33205

Change-Id: I86a06525d2f2ea0476effd3c3d856ff8d9ab1d87
Reviewed-on: https://dart-review.googlesource.com/60201
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-06-13 23:15:04 +00:00
Aart Bik b7493b663e [vm/inliner] Inline small int convertors.
Rationale:
Always inline int convertors that don't do
much more than testing and anding.
For example, force inline
  v26 <- StaticCall:66( _toUint8@6027147<0> v4 T{Type: class 'int'?}) T{Type: class 'int'?}
to
  v47 <- Constant(#255)
  ..
  CheckSmi:10(v4 T{Type: class 'int'?})
  v45 <- BinarySmiOp:10(&, v4 T{_Smi}, v47 T{_Smi}) T{_Smi}

https://github.com/dart-lang/sdk/issues/33205

Change-Id: I595d9a64365e16ae244480b5e27f8be23c43d164
Reviewed-on: https://dart-review.googlesource.com/58061
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-06-05 16:54:19 +00:00
Alexander Markov c3b5939965 [vm] Remove --limit-ints-to-64-bits option and old _Bigint class
Closes https://github.com/dart-lang/sdk/issues/33306

Change-Id: I7088d8b7143edbe24f5cefe4be037ad2006e0625
Reviewed-on: https://dart-review.googlesource.com/58101
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-06-04 20:10:40 +00:00
Vyacheslav Egorov 3b86f823d0 [vm/corelib] Remove GrowableArrayMarker hack.
GrowableArrayMarker was a class that implemented int and was used to
enable implementation of default List factory constructor in pure Dart:

  factory List([int length = GROWABLE_ARRAY_MARKER]) {
    return identical(length, GROWABLE_ARRAY_MARKER) ? new _GrowableList<E>(0)
                                                    : new _List<E>(length);
  }

Its existence complicated all kinds of things in the VM and it is finally
time to remove it.

Instead we build List factory body directly in IL.

This CL also provides inlining rule for `new List(n)` case.

Change-Id: I870751658a4ac17fce649c9ac70395ff88a5436c
Reviewed-on: https://dart-review.googlesource.com/57262
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-05-30 13:44:43 +00:00
Lasse R.H. Nielsen 973a1a0219 Remove uses of upper-case constants in remaining SDK code.
This includes Fasta, tools and observatory, so the checked-in SDK must
have the lower-case constants.

Change-Id: I8380ad041ad058f7d02ae19caccfecd434d13d75
Reviewed-on: https://dart-review.googlesource.com/50201
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2018-04-16 16:11:57 +00:00
Régis Crelier f2806ab624 [Corelib, VM runtime] Fix handling of zero operand in Bigint operations (fixes #32465).
Fix VM, dart2js, and dcc Bigint implementations.
Add shift tests.
Re-enable Bigint intrinsics on VM.

Change-Id: Iec19eac8069cf17783a5346289ea2745ffcc7c26
Reviewed-on: https://dart-review.googlesource.com/46570
Reviewed-by: Florian Loitsch <floitsch@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-03-21 21:44:10 +00:00
Zach Anderson 76b8e397ed Revert "Reland "[VM runtime] Switch intrinsics from old to new Bigint implementation.""
This reverts commit be62fff82f.

Reason for revert: See https://github.com/dart-lang/sdk/issues/32465

Original change's description:
> Reland "[VM runtime] Switch intrinsics from old to new Bigint implementation."
> 
> The change was reverted (thanks Slava) because gen_snapshot was failing to
> find the core lib class _BigIntImpl on flutter.
> The PR https://github.com/flutter/engine/pull/4735 fixed that issue on flutter.
> 
> Change-Id: Id6863d79f7fdb17f0076b63b0168394d5e95ec8d
> Reviewed-on: https://dart-review.googlesource.com/44660
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

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

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I412f5143442ca6ad43784b037c01fcf9bb42c348
Reviewed-on: https://dart-review.googlesource.com/45800
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-03-09 08:59:58 +00:00
Régis Crelier be62fff82f Reland "[VM runtime] Switch intrinsics from old to new Bigint implementation."
The change was reverted (thanks Slava) because gen_snapshot was failing to
find the core lib class _BigIntImpl on flutter.
The PR https://github.com/flutter/engine/pull/4735 fixed that issue on flutter.

Change-Id: Id6863d79f7fdb17f0076b63b0168394d5e95ec8d
Reviewed-on: https://dart-review.googlesource.com/44660
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-03-02 00:01:54 +00:00
Vyacheslav Egorov 4a11a27b53 Revert "[VM runtime] Switch intrinsics from old to new Bigint implementation."
This reverts commit 9ba8c08953.

Reason for revert: broke Flutter, to reproduce build Flutter engine with HEAD dart and try running animation benchmark in release or profile mode in --preview-dart-2, gen_snapshot would crash. Similarly this also breaks Flutter tests in --preview-dart-2 mode.

Original change's description:
> [VM runtime] Switch intrinsics from old to new Bigint implementation.
> 
> Change-Id: I43dfbdf76267bb96d1b1ce4aeb695d02bb18b7f8
> Reviewed-on: https://dart-review.googlesource.com/44025
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Régis Crelier <regis@google.com>

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

Change-Id: I926cc72e1ed89d8631e33ebcc8198853c05a08dc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/44065
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2018-02-28 11:27:45 +00:00
Régis Crelier 9ba8c08953 [VM runtime] Switch intrinsics from old to new Bigint implementation.
Change-Id: I43dfbdf76267bb96d1b1ce4aeb695d02bb18b7f8
Reviewed-on: https://dart-review.googlesource.com/44025
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-02-28 01:37:06 +00:00
Paul Berry ba2417fdc0 Fix SDK errors due to inconsistent inheritance of Operator==.
The informal spec for strong mode top level inference
(https://github.com/dart-lang/sdk/pull/28218) says "If there are
multiple overridden/implemented methods, and any two of them have
non-equal types (declared or inferred) for a parameter position which
is being inferred for the overriding method, it is an error."

This CL fixes several SDK errors that arise from this rule.  For
example, the classes _Closure, Function, and Object contained members
declared as follows:

    class _Closure implements Function {
      bool operator ==(other) ...
    }
    class Function {
      bool operator ==(Object other) ...
    }
    class Object {
      bool operator ==(other) ...
    }

The type of Object's operator == was (dynamic) -> bool; the type of
Function's operator == was (Object) -> bool; therefore the type of
_Closure's operator == (which overrides both, since _Closure extends
Object and implements Function) cannot be inferred and must be
specified.

A similar situation exists for _Double and _IntegerImplementation
(both implement num, which declares operator == to have type (Object)
-> bool), and _Uri (which implements Uri, which declares operator ==
to have type (Object) -> bool).

This CL fixes the error by specifying the type explicitly in the
classes _Closure, _Double, _IntegerImplementation, and _Uri.

Change-Id: I91f7ceef8549399d438ba4be8c408493b3f338db
Reviewed-on: https://dart-review.googlesource.com/28100
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-12-11 13:02:19 +00:00
Vyacheslav Egorov cc35ba4a1e [vm] Split _List&_GrowableList []= into checked and unchecked parts
This allows us to avoid going into runtime even if strong mode is
enabled: type checking is handled in the []= operator itself and
_setIndexed does not need to check types and thus can be intrinsified.

This CL also removes inline type checking done in ia32 version,
not other platform had it.

# Performance Impact

Mostly noticable on Dart v2 AOT configuration where AOT compiler
did not inline []=:

Richards  +26.27%
Meteor  +33.63%
BuildTableInterpolation +68.98%
DeltaBlueClosures +46.43%
StarryStrings +22.08%
NavierStokes  +94.81%
JsonParseCustomReviver  +45.22%
DeltaBlue +56.44%
BuildTableBufferWithCodes +84.40%
JsonParseDefaultReviver +46.13%
BuildTableBuffer  +125.8%
BuildTableIdiomatic +125.8%
StringBuffer  +127.3%
StringIdiomatic +127.2%
JsonObjectRoundTrip +95.42%
JsonStringifyFinancialOnce  +125.7%
JsonRoundTrip +96.01%

Bug:
Change-Id: Ie6d33ac55b5a0c0909ca06e0c88a60d8e0d2604e
Reviewed-on: https://dart-review.googlesource.com/26800
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2017-12-07 13:09:55 +00:00
Lasse R.H. Nielsen ad932a8c7a Fix fingerprints correctly
Change-Id: I5e1f443b1b6907953a9758abe15dcdd2d23289d6
Reviewed-on: https://dart-review.googlesource.com/20701
Reviewed-by: Erik Ernst <eernst@google.com>
2017-11-14 14:02:17 +00:00
Lasse R.H. Nielsen 0b58c4bd10 Change some constant declarations to lowerCase.
Retain the old values.

Reapply of https://dart-review.googlesource.com/c/sdk/+/20680 with fixes
for VM method fingerprints.

Change-Id: Ie14e7ccc3194d5561983348e6b6752728913ff4d
Reviewed-on: https://dart-review.googlesource.com/20664
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2017-11-14 12:59:14 +00:00
Régis Crelier f734e7ee38 [VM] Treat 'deferred' as a built-in identifier (fixes #31267 and #25732).
Reject built-in identifiers as prefix names (fixes #25733).
Update co19 status file.

Change-Id: I7fe5014d128bfdad442866e78196fb8dd2764dda
Reviewed-on: https://dart-review.googlesource.com/19860
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2017-11-09 23:29:52 +00:00
Alexander Markov 28793ea130 [VM] Add option to print precompiler entry points
Change-Id: Ieba8d086e34e669c0789db96ddbb00932a764cfa
Reviewed-on: https://dart-review.googlesource.com/18511
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-11-07 19:41:09 +00:00