dart-sdk/tools
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
..
bots [vm] Support RISC-V. 2022-01-20 00:57:57 +00:00
buildtools [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
dart2js Update File.openRead to return Stream<Uint8List> 2019-06-27 00:22:17 +00:00
dom dart:indexed_db: deprecate IdbFactory.supportsDatabaseNames 2022-01-03 23:45:15 +00:00
fuchsia [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
linux_dist_support [infra] Rely on the default ACL when uploading release artifacts. 2021-11-26 11:34:04 +00:00
package_deps [CFE] First stab at prototype for textually extracting outlines 2021-11-26 06:14:44 +00:00
patches [infra] Ensure that only git dependencies are pulled/updated via git. 2021-05-12 22:31:40 +00:00
sdks Remove references to dartfmt in various comments and docs. 2021-10-01 00:56:14 +00:00
spec_parser Add enhanced enums support to Dart.g 2021-10-11 14:08:55 +00:00
test_generators Change "dartfmt" -> "dart format" in test generator. 2021-10-04 17:11:27 +00:00
testing [infra] Remove obsolete webdriver/selenium support from testing 2019-06-18 06:59:09 +00:00
verify_docs Allow code samples to *continue* a prior sample. 2021-12-02 16:37:57 +00:00
.gitignore Reland https://dart-review.googlesource.com/c/sdk/+/96500 2019-03-13 21:03:01 +00:00
3xhead_flutter_hooks.sh [infra] Extend 3head patching to apply patches for flutter/flutter depending on pinned engine commit 2019-02-04 12:37:10 +00:00
addlatexhash.dart [tools] Fix addlatexhash.dart in NNBD mode 2020-03-23 19:47:52 +00:00
build.py [build] Check that a second Ninja invocation does nothing. 2021-05-26 17:48:30 +00:00
canary.dart
copy_dart.py [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
copy_tree.py [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
create_pkg_manifest.py [tools] Update all iteritems -> items 2021-05-20 11:36:52 +00:00
diff_results.dart [infra] Update checked-in SDKs to 2.12.0-0.0.dev 2020-11-05 07:53:22 +00:00
download_chromium_sysroot.sh [infra] Remove wheezy left overs from SDK 2020-06-04 18:32:29 +00:00
experimental_features.yaml Bump SDK version to 2.17 2022-01-10 11:05:10 +00:00
FAKE_COMMITS [co19] Roll co19_2 to a93f8484f7265f0849692d3b1208323393733f8d 2021-10-14 19:22:36 +00:00
find_depot_tools.py [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
gen_fuchsia_test_manifest.py [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
generate_buildfiles.py [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
generate_experimental_flags.dart [vm] Get experimental flag default values from YAML 2020-11-13 00:29:38 +00:00
generate_idefiles.py [tool] idefiles remove analysis_options.yaml generation 2021-07-15 10:53:29 +00:00
generate_package_config.dart [ package:vm_service ] Migrate Observatory service tests to package:vm_service (Pt 1) 2021-11-05 17:04:07 +00:00
get_dot_git_folder.py [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
git_cl_try.sh [Test tool] Remove -c dartkb configuration 2020-11-02 14:06:19 +00:00
gn.py [vm] Support RISC-V. 2022-01-20 00:57:57 +00:00
gn_helpers.py Mass format python with yapf 2019-08-05 20:34:31 +00:00
line_doc_comments.dart [infra] Update checked-in SDKs to 2.12.0-0.0.dev 2020-11-05 07:53:22 +00:00
list_dart_files.py [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
list_dart_files_as_depfile.py Reapply "[build] Track glob dependencies via depfiles, instead of always re-executing scripts at GN time." 2021-05-12 00:27:28 +00:00
make_version.py [vm] Rename clustered_snapshot.h/cc to app_snapshot.h/cc. 2021-09-16 00:13:34 +00:00
manage_deps.dart tools/manage_deps: use a more reliable way to check for a local branch 2021-10-08 10:12:33 +00:00
minidump.py [tool] Fixes crash in tools/minidump.py 2021-05-17 10:30:30 +00:00
opt_out_files.dart Add script to opt files out of null safety. 2020-10-17 01:28:53 +00:00
presubmit.sh
promote.py [infra] Rely on the default ACL when uploading release artifacts. 2021-11-26 11:34:04 +00:00
publish_pkg.py [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
run_offsets_extractor.sh [vm] Support RISC-V. 2022-01-20 00:57:57 +00:00
run_with_coredumps_enabled.py [gardening] Add coredump archiving support to iso-stress builder. 2021-10-04 08:49:28 +00:00
set_ia32_sysroot.sh [build] Move to Jessie sysroots from Wheezy sysroots. 2018-10-25 15:05:22 +00:00
set_x64_sysroot.sh [build] Move to Jessie sysroots from Wheezy sysroots. 2018-10-25 15:05:22 +00:00
spec_parse.py Migrate tools/spec_parse.py to use python3 2021-04-19 15:33:38 +00:00
task_kill.py [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
test.dart [infra] Update checked-in SDKs to 2.12.0-0.0.dev 2020-11-05 07:53:22 +00:00
test.py [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
utils.py [vm] Support RISC-V. 2022-01-20 00:57:57 +00:00
validate_test_matrix.dart [infra] Update checked-in SDKs to 2.12.0-0.0.dev 2020-11-05 07:53:22 +00:00
VERSION Bump SDK version to 2.17 2022-01-10 11:05:10 +00:00
write_dartdoc_options_file.py Update dartdoc to 1.0.0 and lock down dartdoc warnings. 2021-06-29 19:31:28 +00:00
write_revision_file.py [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
write_version_file.py [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00
yaml2json.dart Fix yaml2json for Windows 2022-01-13 09:18:34 +00:00