Commit graph

12 commits

Author SHA1 Message Date
Ryan Macnak 04ba20aa98 [vm] Support RISC-V.
Implements a backend targeting RV32GC and RV64GC, based on Linux standardizing around GC. The assembler is written to make it easy to disable usage of C, but because the sizes of some instruction sequences are compile-time constants, an additional build configuration would need to be defined to make use of it.

The assembler and disassembler cover every RV32/64GC instruction. The simulator covers all instructions except accessing CSRs and the floating point state accessible through such, include accrued exceptions and dynamic rounding mode.

Quirks:
  - RISC-V is a compare-and-branch architecture, but some existing "architecture-independent" parts of the Dart compiler assume a condition code architecture. To avoid rewriting these parts, we use a peephole in the assembler to map to compare-and-branch. See Assembler::BranchIf. Luckily nothing depended on taking multiple branches on the same condition code set.
  - There are no hardware overflow checks, so we must use Hacker's Delight style software checks. Often these are very cheap: if the sign of one operand is known, a single branch is needed.
  - The ranges of RISC-V branches and jumps are such that we use 3 levels of generation for forward branches, instead of the 2 levels of near and far branches used on ARM[64]. Nearly all code is handled by the first two levels with 20-bits of range, with enormous regex matchers triggering the third level that uses aupic+jalr to get 32-bits of range.
  - For PC-relative calls in AOT, we always generate auipc+jalr pairs with 32-bits of range, so we never generate trampolines.
  - Only a subset of registers are available in some compressed instructions, so we assign the most popular uses to these registers. In particular, THR, TMP[2], CODE and PP. This has the effect of assigning CODE and PP to volatile registers in the C calling convention, whereas they are assigned preserved registers on the other architectures. As on ARM64, PP is untagged; this is so short indices can be accessed with a compressed instruction.
  - There are no push or pop instructions, so combining pushes and pops is preferred so we can update SP once.
  - The C calling convention has a strongly aligned stack, but unlike on ARM64 we don't need to use an alternate stack pointer. The author ensured language was added to the RISC-V psABI making the OS responsible for realigning the stack pointer for signal handlers, allowing Dart to leave the stack pointer misaligned from the C calling convention's point of view until a foreign call.
  - We don't bother with the link register tracking done on ARM[64]. Instead we make use of an alternate link register to avoid inline spilling in the write barrier.

Unimplemented:
 - non-trivial FFI cases
 - Compressed pointers - No intention to implement.
 - Unboxed SIMD - We might make use of the V extension registers when the V extension is ratified.
 - BigInt intrinsics

TEST=existing tests for IL level, new tests for assembler/disassembler/simulator
Bug: https://github.com/dart-lang/sdk/issues/38587
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: I991d1df4be5bf55efec5371b767b332d37dfa3e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217289
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-20 00:57:57 +00:00
Alexander Aprelev d33e51df3c [build] Support --clang when building dart sdk on Windows.
It relies on flutter copy of clang distribution, same one that is used to build flutter/engine.

It addressed several deprecated warnings from clang compiler for functions like strdup, unlink, etc.

It allows few warnings still since they are triggered in third_party sources.

Change-Id: Ieb13792c011438d46dbbc0fa030e1b5e4ea14315
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142704
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-06-25 03:36:41 +00:00
Ben Konyi 07852532e3 [ VM ] Additional cleanup in Dart_Initialize and Dart_Cleanup
Change-Id: I6dc02b3d9de16cc176eb97613bc0c7f0bb9b16eb
Reviewed-on: https://dart-review.googlesource.com/77013
Commit-Queue: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
2018-09-28 23:18:59 +00:00
Ryan Macnak a01c637522 Make arm32 cpu detection recognize the DragonBoard as arm64.
R=zra@google.com

Review URL: https://codereview.chromium.org/2497273003 .
2016-11-14 16:55:25 -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
Siva Annamalai 5792996130 1. Fix memory leaks reported by running a simple test using ASAN
2. Get rid of some methods in cpuninfo that are not being used anymore and make some methods private.

R=zra@google.com

Review URL: https://codereview.chromium.org/1677043003 .
2016-02-09 10:54:34 -08:00
Ryan Macnak 2ebe6f459e VM: Don't do free("") in shutdown when we can't find the cpu model field in /proc/cpuinfo.
Also fix field names of /proc/cpuinfo for Linux ARM64.

BUG=http://dartbug.com/25424
R=zra@google.com

Review URL: https://codereview.chromium.org/1586663005 .
2016-01-13 16:37:29 -08:00
zra@google.com 436a06a381 Fixes to run "Hello, world!" on arm64 hardware.
Primarily, in Dart code, instead of using R31 as our
stack pointer, on entry we copy it into a second
register (R18) and use that as our stack pointer after
moving R31 to the Dart stack limit. On calling back
into C++ from Dart code, R31 is restored, and R18 is
cached in the callee-saved register R26.

R=regis@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36930 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-03 18:38:28 +00:00
zra@google.com 7c91e88e6e Adds support for ARMv6.
When we detect ARMv6, instead of using movw and
movt, this change loads each individual byte.
Although this is not the best way to achieve this,
a modification to store large constants in the
object pool would be more invasive. Further,
this change will be easier to back-out once
ARMv6 is obsolete.

R=regis@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33442 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-07 19:17:36 +00:00
zra@google.com fd366da1cf Updates refactoring of CPU feature detection
with fix that uses cpuid for Intel/Linux.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32980 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-24 19:28:30 +00:00
zra@google.com 3693beeb6b Reverts refactoring of CPU feature detection for
assertion failure in Dartium.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32560 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-11 16:05:43 +00:00
zra@google.com 6f2096face Refactors some CPU feature detection into new class CpuInfo, and uses new information in VM service.
This change rewrites the code from the ARM assembler for parsing /proc/cpuinfo on Linux and Android, and collects it into a CpuInfo class that can be used for other architectures as well. This code is in cpuinfo_*.cc. /proc/cpuinfo equivalents are used for Mac and Windows. CpuInfo is used by the VM service to report on the hardware dart is running on. In the future CpuInfo can also be used here to provide more information.

R=iposva@google.com, johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32468 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-08 22:27:27 +00:00