Commit Graph

11 Commits

Author SHA1 Message Date
Alexander Markov 84fd647969 [vm] Refactor access to Integer value
Add methods to provide uniform access to values of Dart integers:

  Integer::Value()
  Integer::Value(IntegerPtr)

  Smi::Value()
  Smi::Value(SmiPtr)

  Mint::Value()
  Mint::Value(MintPtr)

Remove

  AsInt64Value()
  AsTruncatedInt64Value()
  AsTruncatedUint32Value()
  GetInt64Value(IntegerPtr)

Also, rename AsDoubleValue() to ToDouble() and
remove unused (FitsIntoSmi, AsValidInteger) and
value-based methods (IsZero, IsNegative).

TEST=ci

Change-Id: I28786ec3a14703574b7a192ead42eeefdbd09106
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380586
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-08-19 21:46:26 +00:00
Jens Johansen 856139bfc3 [VM] Add RecordCoverage to InstanceCall and StaticCall
Before this CL, becase of optimizations, coverage of some of these goes
away, making coverage unreliable.

I believe this fixes the issues for "regular" runs (at least it seems to
be stable on the CFE coverage tests).

If setting `--optimization-counter-threshold=-1` there'll still be
trouble though and we would have to also insert these calls in the start
of FunctionBody and the start of FieldInitializer for it to produce the
same results.

TEST=pkg/vm_service/test/coverage_instance_call_after_optimization_test.dart,pkg/vm_service/test/coverage_static_call_after_optimization_test.dart

Bug: https://github.com/dart-lang/sdk/issues/42061
Bug: https://github.com/dart-lang/sdk/issues/55959
Bug: https://github.com/dart-lang/sdk/issues/56018

Change-Id: I34947f0d4b123e52ce67b71a195782d31e4bda16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370501
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-06-17 10:47:58 +00:00
Daco Harkes 77d10f2ed9 [vm] Split DartReturnInstr and NativeReturnInstr
Renames `ReturnInstr` to `DartReturnInstr`, and introduces a new
`ReturnBaseInstr` to be the common parent of `DartReturnInstr` and
`NativeReturnInstr`. (Before this CL, `NativeReturnInstr` was a
subtype of `ReturnInstr`.)

In a follow up CL, the `NativeReturnInstr` will get up to two inputs.
https://dart-review.googlesource.com/c/sdk/+/354226
Therefore, the `ReturnBaseInstr` does not inherit from `TemplateInstr`
with 1 input, but instead only inherits from `Instruction`.

TEST=SDK build
TEST=*_il_test.dart

Change-Id: I017eb7802ae6c902b64f1cda20edf4a11408dbe1
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358904
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-03-26 11:12:38 +00:00
Alexander Aprelev 435ebeb5a7 Fix MSVC build
- refactor designated initializers as they are c++20
- unwrap #if/#endif in macro arguments
- remove taking pointer on purely intrinsic function (setjmp_)
- use DART_WARN_UNUSED_RESULT which is msvc/clang friendly
- provide StringRAII copying constructor

Bug: https://github.com/dart-lang/sdk/issues/48544
TEST=ci,msvc build
Change-Id: I1049589c96dc0cdf49e1d31d320b6804bf6e4558
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237929
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-03-22 18:28:19 +00:00
Vyacheslav Egorov eaf7674f6d [vm] Fix TypedClosureCall test in PRODUCT
We don't emit RecordCoverage instruction in PRODUCT mode.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-product-x64-try
Change-Id: I794b4c08362fa7b84417923d80fbd246d5bb36be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218642
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-10-29 11:38:41 +00:00
Vyacheslav Egorov 8896894315 [vm] Record coverage for closure calls
Previously coverage was computed from the state of ICData at various
call-sites in the function. This ties coverage collection with the
implementation of various operations. This CL is the first step towards
decoupling coverage collection from how individual operations are implemented.

We introduce a separate coverage array storing token_pos -> coverage hit
mapping. This array is updated by a separate RecordCoverage IL instruction.

Fixes https://github.com/dart-lang/sdk/issues/47174
Fixes https://github.com/dart-lang/sdk/issues/47530
Fixes https://github.com/dart-lang/sdk/issues/37944

TEST=runtime/observatory/tests/service/coverage_closure_call_test.dart

Change-Id: I986d3462412870372ca6a9d72c050f0563b9b725
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218262
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-10-28 11:02:48 +00:00
Alexander Markov 30abce99f3 [vm] Treat static final fields with trivial initializers as const
When loading a value of a static final field with trivial initializer
generate a Constant instruction instead of LoadStaticField.

Initializer of a static field is considered trivial if it is null, int,
double, String or bool literal.

TEST=vm/cc/StreamingFlowGraphBuilder_StaticGetFinalFieldWithTrivialInitializer
Fixes https://github.com/dart-lang/sdk/issues/47120

Change-Id: Id2bfc3da8c14376f7f1ef829265cca29a018bad1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212873
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-09-13 16:51:59 +00:00
Vyacheslav Egorov f5326473c2 [vm/compiler] Remove StringInterpolate instruction
This instruction is essentially just a StaticCall to a fixed
target. Make this explicit by actually using StaticCall to
represent it.

TEST=existing tests

Change-Id: I50b8415ed917eb7c784170e4ee8836f1b99186b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205640
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-07-01 12:57:32 +00:00
Martin Kustermann bf77ce52db [vm] Take advantage of FunctionInvocation.kind to detect non-dynamic closure calls
The Incremental Kernel Compiler (IKG) will produce kernel files without
metadata.

Right now the VM will make all closure calls dynamic calls if the
call-site attribute metadata is not present. This causes closure code
to run significantly slower due to dyn:call forwarders and the type
checks it will perform.

This change takes - in addition to the metadata - the new
FunctionInvocation.kind into account - which also tells us whether a
function invocation is based on a real function type.

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

TEST=vm/cc/StreamingFlowGraphBuilder_TypedClosureCall

Change-Id: Ie1136c3727fc8b5e3e3b9822a1db9479fa9da689
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203302
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-06-14 13:42:23 +00:00
Alexander Markov 4a93b79ca6 [vm/compiler] Take MethodInvocation.FlagInvariant into account
Front-end marks certain calls (currently in collection literals) as
not requiring covariant parameter checks (invariant).

VM can use that flag to generate calls through unchecked entry point.

TEST=vm/cc/StreamingFlowGraphBuilder_InvariantFlagInListLiterals

Change-Id: I8d0dc09ea4867f41d20f6d7b6ba9e0940ff555dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175880
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-12-14 07:03:10 +00:00
Clement Skau 639de610e8 [Compiler] Adds const fold for StringIterpolate.
Bug: https://github.com/dart-lang/sdk/issues/43229
Change-Id: Ied6b59fdc91d9148b6c54a4a6a15f89e6d7e5a41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162500
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-09-18 09:35:22 +00:00