Commit graph

20 commits

Author SHA1 Message Date
Ryan Macnak 2642c7c9ce [vm] Fix gcc build.
TEST=local build
Change-Id: I9503dfbb1b9ba6ef2b5fb8423c13d5066e5af98b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206140
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-07-13 01:55:45 +00:00
Vyacheslav Egorov ba5611a00b [vm/compiler] Do not mutate locs()->stack_bitmap() in RecordSafepoint
Instead create a copy of BitmapBuilder and mutate that. This
simplifies the logic, avoids unnecessary side-effects  and
allows us to delete some code which existed solely to validate
that two independent slow-path calls don't mutate the same
stack_bitmap in incompatible ways.

To make it cheap to copy BitmapBuilder we inline BitmapBuilder
backing storage into the object itself. Inlined capacity has
been chosen by looking at bitmap size distributions from large
Flutter applications.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: I62ecb4ead388a367ad6904471d5923f5d1f5e3f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205783
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-07-05 10:45:47 +00:00
Daco Harkes 096612ff46 [vm] Fix BitmapBuilder backing store growth
If the length was set longer than the backing store, on a call to
`Set(index, false)`, and subsequently a call `Set(index-1, true)` was
done, it would try to write outside the backing store.

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

TEST=runtime/vm/bitmap_test.cc
TEST=tests/ffi_2/function_structs_by_value_generated_test.dart/0

Change-Id: Ib636e90b0f6acace9ec8b71557370c281e9e4a99
Cq-Include-Trybots: luci.dart.try:app-kernel-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184423
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-02-11 16:14:13 +00:00
Tess Strickland 45a46ca2b8 [vm] Add (S)LEB128 encoding/decoding to BaseWriteStream.
Unlike cfc8e6de, this does _not_ replace the default variable length
encoding for {Read,Write}Streams, but insteads adds separate
{Read,Write}{S,}LEB128 methods to the appropriate classes. If we later
find the cause of the issues that led to the revert of cfc8e6de, it'll
be easy to switch over then.

Note that WriteLEB128 asserts that the value is non-negative if used
with a signed type (since negative values suggests that SLEB128 should
be used instead for minimal encoding).

Also removes the various other encoding and decoding methods for
(S)LEB128 across the codebase and changes those clients to use
{Read,Write}Streams instead.

Other cleanups:

* Various constant-related cleanups in datastream.h.

* Adds DART_FORCE_INLINE to ReadStream::ReadByte and uses it in the
  default variable length decoding methods for retrieving bytes
  from the stream instead of managing current_ by hand.

* Creates a canonical empty CompressedStackMaps instance and uses
  that instead of the null CompressedStackMaps instance in most cases.
  The only remaining (expected) use of the null CompressedStackMaps
  instance is for the global table in the object store when no global
  table exists (e.g., in JIT mode before any snapshotting).

* Moves CompressedStackMapsIterator from code_descriptors.h to an
  Iterator class within CompressedStackMaps in object.h (similar to
  PcDescriptors::Iterator), to limit friend declarations and because it
  conceptually makes more sense as part of CompressedStackMaps.

* Removed CompressedStackMaps::PayloadByte, since existing clients
  (CompressedStackMaps::Iterator, StackMapEntry in program_visitor.cc)
  are better served by just operating on the payload buffer directly
  (with appropriate NoSafepointScopes).

* WriteStreams no longer allocate their initial space on construction,
  but rather on the first write, so no allocation is performed by
  constructing a never-used WriteStream.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-mac-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-ubsan-linux-release-x64-try,vm-kernel-tsan-linux-release-x64-try,vm-kernel-precomp-ubsan-linux-release-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-asan-linux-release-x64-try
Change-Id: Ice63321abaa79157fbe9f230a864c8bba0e6dea9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166421
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2020-10-09 10:08:16 +00:00
Teagan Strickland c9f6e669f9 [vm/compiler] Reland "Further compress the information... in StackMaps."
Fixes an assumption that CompressedStackMapsIterator::Find() is never
passed a PC offset of 0. Adds back an ASSERT that was dropped which checks
for specific cases where a given PC offset does not have a stack map entry.

Original commit message:

Lifting the PC offset in a2bb730 was a small, lightweight change that
gave us big gains, at least on 32-bit architectures. Here, we make
much more invasive changes that will improve the amount of memory used
by the information previously stored in StackMap objects.

Instead of allocating separate objects for StackMaps, we instead compress
all StackMap information for a given Code object into a single object
(CompressedStackMaps, or CSM for short). This replaces the Array used to
store PC offsets (as Smis) and the individual StackMap objects.

While we lose all canonicalization for individual StackMap entries, the
drop in space required to store stack map information more than offsets that.

-----

The impact on AOT snapshot size when compiling the Flutter Gallery
in release mode:

   armv7: Total size -2.58% (Isolate RO: +14.46%, Isolate snapshot: -22.93%)
   armv8: Total size -1.85% (Isolate RO: +15.69%, Isolate snapshot: -22.97%)

The impact on in-memory, not on-disk, size for the Flutter Gallery as seen
in the Observatory while running a profile (not release) build:

   armv7: Drops from 7.1 MB to 6.2MB (-0.9 MB)
   armv8: Drops from 13.5MB to 11.7MB (-1.8 MB)

-----

Bug: https://github.com/dart-lang/sdk/issues/35274, https://github.com/dart-lang/sdk/issues/38873
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-mac-debug-simdbc64-try
Change-Id: I111b129b0ed64f03184370bceb7cda69d5d4b3c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121700
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-10-16 08:25:53 +00:00
Alexander Markov 017a7a6221 Revert "[vm/compiler] Further compress the information previously in StackMaps."
This reverts commit d77f4913a1.

Reason for revert: large number of flaky crashes on flakiness dashboard (https://github.com/dart-lang/sdk/issues/38873); crashes on vm-kernel-mac-debug-simdbc64 bot.

Original change's description:
> [vm/compiler] Further compress the information previously in StackMaps.
> 
> Lifting the PC offset in a2bb730 was a small, lightweight change that
> gave us big gains, at least on 32-bit architectures. Here, we make
> much more invasive changes that will improve the amount of memory used
> by the information previously stored in StackMap objects.
> 
> Instead of allocating separate objects for StackMaps, we instead compress
> all StackMap information for a given Code object into a single object
> (CompressedStackMaps, or CSM for short). This replaces the Array used to
> store PC offsets (as Smis) and the individual StackMap objects.
> 
> While we lose all canonicalization for individual StackMap entries, the
> drop in space required to store stack map information more than offsets that.
> 
> -----
> 
> The impact on AOT snapshot size when compiling the Flutter Gallery
> in release mode:
> 
>    armv7: Total size -2.58% (Isolate RO: +14.46%, Isolate snapshot: -22.93%)
>    armv8: Total size -1.85% (Isolate RO: +15.69%, Isolate snapshot: -22.97%)
> 
> The impact on in-memory, not on-disk, size for the Flutter Gallery as seen
> in the Observatory while running a profile (not release) build:
> 
>    armv7: Drops from 7.1 MB to 6.2MB (-0.9 MB)
>    armv8: Drops from 13.5MB to 11.7MB (-1.8 MB)
> 
> -----
> 
> Bug: https://github.com/dart-lang/sdk/issues/35274
> Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try
> Change-Id: Ie3bb898d557215146260a560423f5fa27bdff512
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119640
> Commit-Queue: Teagan Strickland <sstrickl@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

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

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

Bug: https://github.com/dart-lang/sdk/issues/35274
Change-Id: Ib844b4d52e3aa4aca62a896cfe349c680bda7461
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-debug-simarm_x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121642
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-14 20:20:58 +00:00
Teagan Strickland d77f4913a1 [vm/compiler] Further compress the information previously in StackMaps.
Lifting the PC offset in a2bb730 was a small, lightweight change that
gave us big gains, at least on 32-bit architectures. Here, we make
much more invasive changes that will improve the amount of memory used
by the information previously stored in StackMap objects.

Instead of allocating separate objects for StackMaps, we instead compress
all StackMap information for a given Code object into a single object
(CompressedStackMaps, or CSM for short). This replaces the Array used to
store PC offsets (as Smis) and the individual StackMap objects.

While we lose all canonicalization for individual StackMap entries, the
drop in space required to store stack map information more than offsets that.

-----

The impact on AOT snapshot size when compiling the Flutter Gallery
in release mode:

   armv7: Total size -2.58% (Isolate RO: +14.46%, Isolate snapshot: -22.93%)
   armv8: Total size -1.85% (Isolate RO: +15.69%, Isolate snapshot: -22.97%)

The impact on in-memory, not on-disk, size for the Flutter Gallery as seen
in the Observatory while running a profile (not release) build:

   armv7: Drops from 7.1 MB to 6.2MB (-0.9 MB)
   armv8: Drops from 13.5MB to 11.7MB (-1.8 MB)

-----

Bug: https://github.com/dart-lang/sdk/issues/35274
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try
Change-Id: Ie3bb898d557215146260a560423f5fa27bdff512
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119640
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-10-11 11:28:57 +00:00
Vyacheslav Egorov f496e538f4 [vm] Decouple assemblers 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. The goal of the refactoring to locate all places where compiler
accesses some runtime information and partion those accesses into two
categories:

- creating objects in the host runtime (e.g. allocating strings, numbers, etc)
during compilation;
- accessing properties of the target runtime (e.g. offsets of fields) to
embed those into the generated code;

This change introduces dart::compiler and dart::compiler::target namespaces.

All code in the compiler will gradually be moved into dart::compiler namespace.
One of the motivations for this change is to be able to prevent access to
globally defined host constants like kWordSize by shadowing them in the
dart::compiler namespace.

The nested namespace dart::compiler::target hosts all information about
target runtime that compiler could access, e.g. compiler::target::kWordSize
defines word size of the target which will eventually be made different
from the host kWordSize (defined by dart::kWordSize).

The API for compiler to runtime interaction is placed into compiler_api.h.

Note that we still permit runtime to access compiler internals directly -
this is not going to be decoupled as part of this work.

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

Change-Id: If4396d295879391becfa6c38d4802bbff81f5b20
Reviewed-on: https://dart-review.googlesource.com/c/90242
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-01-25 16:45:13 +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
John McCutchan f125cc7d0b Improve the casing of Stackmap and Stacktrace.
- [x] Stackmap -> StackMap
- [x] Stacktrace -> StackTrace

This makes us consistent with the Dart language (StackTrace) and
corrects the casing of StackMap.

BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2572563004 .
2016-12-12 14:51:30 -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
Daniel Andersson c089a152ac Migrate most uses of Isolate::current_zone to Thread::zone.
After https://codereview.chromium.org/1204303003/ is submitted, the last remaining uses can go.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//1220193009 .
2015-07-08 09:59:32 -07:00
johnmccutchan@google.com 8f4cbeaefa Use GPRs for mints.
Changes:

* Register allocator now allocates GPRs for kUnboxedMint.
* Register allocator supports for SameAsFirstInput for register pairs.
* Register allocator properly handles register pairs in environment uses and materialization uses.
* BoxInteger updated on IA32/ARM.
* UnboxInteger updated on IA32/ARM.
* BinaryMintOp updated on IA32/ARM.
* ShiftMintOp updated on IA32/ARM.
* UnaryMintOp updated on IA32/ARM.
* RelationalOp updated on IA32/ARM.
* EqualityCompare updated on IA32/ARM.
* LoadIndexed and StoreIndexed updated on IA32/ARM.
* New Deopt instructions added.
* Update live_registers when an instruction has a fixed register input and a call on the slow path.
* Improve printing of register pairs in flow graph.
* Do not assume live registers in slow paths contain tagged values.
* LiveRange pairs for kUnboxedMint definitions marked as kUntagged representation (reduces stack usage).
* Live register spilling on ARM uses same register order as stack map encoding.
* Spill slots containing tagged and untagged are segregated.
* Print stack maps when printing live ranges with safe points.
* Print allocated spill slot when printing live ranges.

Status:

* IA32 completed. All tests are passing.
* ARM completed. All tests passing.

R=fschneider@google.com, srdjan@google.com, zra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36468 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-22 06:30:51 +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 0a09482afd Fix for issue 4638 in bitmap builder.
- Check for maximum size of byte offset and fatal out if it is larger.
- Convert some of the InRange asserts to actual checks.

R=srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23637 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-05 16:42:38 +00:00
kmillikin@google.com 57f5dbafd6 Give a length field to stack bitmaps.
The bitmaps describing the stack have an explicit length field.  It is now
an assertion failure to read bits outside the length --- they are no longer
assumed to be false.

Also remove an unused method and simplify the implementation of
BitmapBuilder by removing an embedded member that was always referred to via
a pointer.

R=vegorov@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11138 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-22 12:42:54 +00:00
kmillikin@google.com 94a5b82f60 Make stackmaps store their actual length.
This allows stackmaps with varying lengths in the same function, necessary
for the way we plan to support bitmaps for saved live registers.

R=vegorov@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11019 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-21 08:43:32 +00:00
kmillikin@google.com f440cf8292 Fix an off-by-one error in the stack frame iteration.
When using a stackmap, we mapped stackmap index 0 to the code slot in the
frame.  This code is still unused, but judging from the test the intent is
to map index 0 to the first local slot in the frame.

R=vegorov@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10013 260f80e4-7a28-3924-810f-c04153c831b5
2012-07-30 13:36:58 +00:00
asiva@google.com f120af8463 First step towards implementing stack map descriptions for the optimizing compiler.
Add a RawBitmap object and a bitmap builder.
Review URL: https://chromiumcodereview.appspot.com//9701010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5502 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-15 00:18:05 +00:00