Commit graph

30 commits

Author SHA1 Message Date
Martin Kustermann 8156646b0c [vm] Fix constant in PcRelativeCall pattern on x64
This fixes windows build which has different integer size
so the literal constant makes a difference.

This is a follow-up to [0] which added a test that revealed this
issue.

[0] https://dart-review.googlesource.com/c/sdk/+/195682

TEST=Fixes vm/cc/PCRelativeCallPatterns on windows.

Change-Id: I82403753126e95b86ccca5de039fd703b61a119b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195921
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-19 14:11:38 +00:00
Martin Kustermann d41f9a738e [vm/compiler] Fix relocator to take out-of-range backwards calls into acount
There was a missing check for whether a backwards call is out-of-range.

The CL also removes leftover code related to [max_offset_into_target_] -
which wasn't used. The intended use is already over approximated via
[max_instructions_size_].

The CL makes the pc-relative call/tail-call distances pluggable so a
newly added test can modify them for testing in-range/out-of-range
forward/backwards calls.

TEST=vm/cc/CodeRelocator_*

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

Change-Id: Id4bdb7176108b61235dafb7ffc125da4a2bf07fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195682
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-19 09:42:00 +00:00
Ryan Macnak 2707880f1b [vm] Fix various UBSan failures.
Bug: https://github.com/dart-lang/sdk/issues/39427
Change-Id: I74e0eee623d88005fb2893d03e284a87daa09260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146696
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-05-07 19:40:18 +00:00
Martin Kustermann af4bd2719e [vm/compiler] Add support for PC-relative tail calls and use it in TailCallInstr
Flutter gallery total size:
  - armv7: -0.15%
  - armv8: -0.33%

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

Change-Id: I99959de45f43ca0c892cea6382ee7252e9c4f764
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142841
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2020-04-15 14:10:53 +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
Martin Kustermann cc9607b04c [VM/AOT] Make trampolines look like free list elements to enable heap walking
Issue https://github.com/dart-lang/sdk/issues/33274

Change-Id: Ib6afdbc80012326134d409c4065a680d67de3ed8
Reviewed-on: https://dart-review.googlesource.com/c/90064
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2019-01-19 13:37:09 +00:00
Martin Kustermann 16ddc23a57 [VM/Compiler/AOT] Bare instructions 7: Trampolines for out-of-range calls
This CL adds support to the ImageWriter to write opaque blocks of
trampoline bytes

The AOT code relocator is adapted to allow limited range calls and
inserts trampolines if need be. The algorithm tries to minimize the
number of trampolines added, which for small applications will be 0.

The unconditional pc-relative calls have limited range:
  * on ARM (+/-32 MB)
  * on ARM64 (+/-128 MB)

To avoid verbose code for doubly-linked list, this CL adds double_list.h

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

Change-Id: I0354cf4b2dd58ed5de25d67fc818f0603a2ec501
Reviewed-on: https://dart-review.googlesource.com/c/89283
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2019-01-17 12:32:38 +00:00
Martin Kustermann 9b9a035154 [VM] Add PcRelativeCall / PcRelativeJump patterns & assembler support
Issue https://github.com/dart-lang/sdk/issues/33274

Change-Id: I0297c4bb502a1af28e3cf16646eade49f4cd0676
Reviewed-on: https://dart-review.googlesource.com/c/81827
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-01 12:34:42 +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
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
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
Ryan Macnak 763daa9d06 Reapply "Lazy deopt without code patching."
When throwing to a frame scheduled for lazy deopt, update the continuation pc for that frame to be the catch handler.

Weaken new assert that the deopt pc belongs to the frame's code as the deopt pc for the last eager deopt in a function lies outside the code, after the call to the deopt stub.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2392613002 .
2016-10-03 11:31:48 -07:00
Ryan Macnak 4e9a473746 Revert "Lazy deopt without code patching."
This reverts commit 6cff17c59a.

Review URL: https://codereview.chromium.org/2382953004 .
2016-09-30 18:04:58 -07:00
Ryan Macnak 6cff17c59a Lazy deopt without code patching.
Keep a side table that maps a fp back to a deopt pc.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2380403003 .
2016-09-30 16:53:29 -07:00
Stephen Adams d57599e6d1 x64: Decode more objects for code view.
In particular, the cmpq for parsing named optional arguments has the
object recognized.

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

Review URL: https://codereview.chromium.org/1888353002 .
2016-04-15 12:19:10 -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
Florian Schneider b5966db69e VM: Clean up and fix bugs in instructions patterns
Fix bug in DecodeLoadWordFromPool: used Array::element_offset instead of ObjectPool::element_offset.
This only worked because they accidentally return the same value.

Remove virtual methods from InstructionsPatterns on ia32 and x64. Instead use a template for code reuse.
This avoids among others vtables for the *Pattern classes and saves >= 4K in VM binary code size.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1301963003 .
2015-08-21 09:31:36 +02:00
Florian Schneider 265a54411a Object pool with support for untagged entries.
This adds meta-information to object pool entries to allow storing
untagged immediates or code addresses (ExternalLabel) directly.

This eliminates the need to generate extra code to preserve the LSB
when storing immediates as smis (x64, arm64).

BUG=

Review URL: https://codereview.chromium.org//1175523002.
2015-06-10 11:41:22 +02:00
John McCutchan baa34257fc Track prologue offset of Code and use for more precise return addresses
- Remember the prologue offset in the Code object.
- Size of Code object does not change.
- Use the prologue offset to assist in locating the return address of the current frame.
- Prologue offset + instruction pattern matching will be accurate for all Dart code, most intrinsic prefixed Dart code, and some stub code.
- By default only collect Dart frames (normal Dart developers only care about Dart frames)

R=srdjan@google.com

Review URL: https://codereview.chromium.org//1150633002
2015-05-21 18:35:19 -07:00
johnmccutchan@google.com f2333f63a5 Add Function based profile tree
Profiler improvements:
- Track Functions in profile and build Function based trie
- Associate code objects with functions
- Created cpu_profile.dart library
- Major speed improvements for disassembly view
- Fix truncation of disassembly comments
- Ability to get code object ticks from disassembly view
- Inlining mini-map in disassembly view.
- Remove a bunch of unused data from profile service response
- In some cases a caller PC that is better than the PC marker is inserted into the stack trace
- Inlined functions are expanded
- Ability to clear profile
- New flag '--keep_code' which keeps deoptimized code around for use by the profiler.

General fixes:
- Fix caching in service library
- Remove pubspec.yaml before running pub get

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44067 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-26 18:48:55 +00:00
fschneider@google.com 340299bc13 VM: Emit compacter code for x64 branches to external labels.
Use jmp [PP + 0xiiii] instead of

movq TMP, [PP + 0xiiii]
jmp TMP

Also, remove some unused code from x64 assembler.

R=zra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43094 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-23 10:28:23 +00:00
hausner@google.com b4f0bf5998 Fix debugger stub patching on x64 architecture
Instead of patching the entry in the object pool, patch the offset
into the pool at the call site.

SIMARM and SIMMIPS will have to be fixed the same way in a later change.

R=iposva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31812 260f80e4-7a28-3924-810f-c04153c831b5
2014-01-14 23:27:13 +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 67871d3098 Finish implementing lazy deoptimization (ia32, x64). Ran tests with --deoptimize-alot.
Review URL: https://chromiumcodereview.appspot.com//10912146

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@12093 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-09 15:00:51 +00:00
srdjan@google.com 8dd46bccc7 Implement some intrinsics on x64, fix a bug in ia32 intrinciscs (must return false if there is a fall-through, so that slow path will be generated).
Review URL: https://chromiumcodereview.appspot.com//10450006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7951 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-24 16:15:09 +00:00
kmillikin@google.com 552825c221 Required rename on x64 platform.
Due to a name clash, rename class Instruction => InstructionPattern.

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4466 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-22 16:38:56 +00:00
regis@google.com 9aa346b921 Port jump and call instruction decoding and patching for x64.
Review URL: http://codereview.chromium.org//8896017

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@2327 260f80e4-7a28-3924-810f-c04153c831b5
2011-12-09 22:46:44 +00:00