2012-01-06 11:28:21 +00:00
|
|
|
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
2011-10-05 05:20:07 +00:00
|
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
2016-10-26 07:26:03 +00:00
|
|
|
#ifndef RUNTIME_PLATFORM_GLOBALS_H_
|
|
|
|
#define RUNTIME_PLATFORM_GLOBALS_H_
|
2012-01-06 11:28:21 +00:00
|
|
|
|
2019-02-15 01:12:01 +00:00
|
|
|
#if __cplusplus >= 201703L // C++17
|
|
|
|
#define FALL_THROUGH [[fallthrough]] // NOLINT
|
|
|
|
#elif defined(__GNUC__) && __GNUC__ >= 7
|
|
|
|
#define FALL_THROUGH __attribute__((fallthrough));
|
|
|
|
#elif defined(__clang__)
|
|
|
|
#define FALL_THROUGH [[clang::fallthrough]] // NOLINT
|
|
|
|
#else
|
|
|
|
#define FALL_THROUGH ((void)0)
|
|
|
|
#endif
|
|
|
|
|
2021-06-10 02:25:49 +00:00
|
|
|
#if !defined(NDEBUG) && !defined(DEBUG)
|
2020-07-09 09:51:31 +00:00
|
|
|
#if defined(GOOGLE3)
|
|
|
|
// google3 builds use NDEBUG to indicate non-debug builds which is different
|
|
|
|
// from the way the Dart project expects it: DEBUG indicating a debug build.
|
|
|
|
#define DEBUG
|
2021-03-19 15:29:57 +00:00
|
|
|
#else
|
|
|
|
// Since <cassert> uses NDEBUG to signify that assert() macros should be turned
|
|
|
|
// off, we'll define it when DEBUG is _not_ set.
|
|
|
|
#define NDEBUG
|
2020-07-09 09:51:31 +00:00
|
|
|
#endif // GOOGLE3
|
2021-06-10 02:25:49 +00:00
|
|
|
#endif // !NDEBUG && !DEBUG
|
2020-07-09 09:51:31 +00:00
|
|
|
|
2012-08-06 10:50:38 +00:00
|
|
|
// __STDC_FORMAT_MACROS has to be defined before including <inttypes.h> to
|
|
|
|
// enable platform independent printf format specifiers.
|
2012-01-06 11:28:21 +00:00
|
|
|
#ifndef __STDC_FORMAT_MACROS
|
|
|
|
#define __STDC_FORMAT_MACROS
|
|
|
|
#endif
|
2011-10-05 05:20:07 +00:00
|
|
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
// Cut down on the amount of stuff that gets included via windows.h.
|
2014-09-22 20:30:27 +00:00
|
|
|
#if !defined(WIN32_LEAN_AND_MEAN)
|
2011-10-05 05:20:07 +00:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2014-09-22 20:30:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(NOMINMAX)
|
2011-10-05 05:20:07 +00:00
|
|
|
#define NOMINMAX
|
2014-09-22 20:30:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(NOKERNEL)
|
2011-10-05 05:20:07 +00:00
|
|
|
#define NOKERNEL
|
2014-09-22 20:30:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(NOSERVICE)
|
2011-10-05 05:20:07 +00:00
|
|
|
#define NOSERVICE
|
2014-09-22 20:30:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(NOSOUND)
|
2011-10-05 05:20:07 +00:00
|
|
|
#define NOSOUND
|
2014-09-22 20:30:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(NOMCX)
|
2011-10-05 05:20:07 +00:00
|
|
|
#define NOMCX
|
2014-09-22 20:30:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(UNICODE)
|
2012-12-13 15:51:48 +00:00
|
|
|
#define _UNICODE
|
|
|
|
#define UNICODE
|
2014-09-22 20:30:27 +00:00
|
|
|
#endif
|
|
|
|
|
2017-11-03 17:39:16 +00:00
|
|
|
#include <intrin.h>
|
[vm] Fix some cross compilation issues from Linux to Windows
Upstreamed changes from cl/579854752.
The cross-compiler checks some things that are check on Windows.
* Correct capitalization of filenames in includes.
* Field initialization order in constructors.
In the cross compilation process, some binaries are run on the host.
This unveiled missing `UnwindingRecords::GenerateRecordsInto`.
Finally, when emitting blob data with a symbol in assembly, the
`.type` directive is not supported but the format should still be
unix style assemble. So this CL introduces "win_gnu". This tool is
directly invoked from the build-rules in cl/579854752, and will not be
used until we address https://github.com/dart-lang/sdk/issues/28617.
TEST=windows bots
Change-Id: I94256589e8c231b45b8e14a63727c782416c2e98
Cq-Include-Trybots: luci.dart.try:vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,pkg-win-release-try,pkg-win-release-arm64-try,vm-win-debug-arm64-try,vm-win-debug-x64c-try,vm-win-debug-x64-try,vm-msvc-windows-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335520
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-11-13 14:25:28 +00:00
|
|
|
#include <rpc.h>
|
2017-07-13 15:08:33 +00:00
|
|
|
#include <shellapi.h>
|
[vm] Fix some cross compilation issues from Linux to Windows
Upstreamed changes from cl/579854752.
The cross-compiler checks some things that are check on Windows.
* Correct capitalization of filenames in includes.
* Field initialization order in constructors.
In the cross compilation process, some binaries are run on the host.
This unveiled missing `UnwindingRecords::GenerateRecordsInto`.
Finally, when emitting blob data with a symbol in assembly, the
`.type` directive is not supported but the format should still be
unix style assemble. So this CL introduces "win_gnu". This tool is
directly invoked from the build-rules in cl/579854752, and will not be
used until we address https://github.com/dart-lang/sdk/issues/28617.
TEST=windows bots
Change-Id: I94256589e8c231b45b8e14a63727c782416c2e98
Cq-Include-Trybots: luci.dart.try:vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,pkg-win-release-try,pkg-win-release-arm64-try,vm-win-debug-arm64-try,vm-win-debug-x64c-try,vm-win-debug-x64-try,vm-msvc-windows-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335520
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-11-13 14:25:28 +00:00
|
|
|
#include <versionhelpers.h>
|
2017-07-13 15:08:33 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <winsock2.h>
|
2015-05-29 21:35:29 +00:00
|
|
|
#endif // defined(_WIN32)
|
2011-10-05 05:20:07 +00:00
|
|
|
|
2012-01-06 11:28:21 +00:00
|
|
|
#if !defined(_WIN32)
|
2012-06-14 01:02:08 +00:00
|
|
|
#include <arpa/inet.h>
|
2012-01-11 15:22:43 +00:00
|
|
|
#include <unistd.h>
|
2016-02-20 01:48:08 +00:00
|
|
|
#endif // !defined(_WIN32)
|
2011-10-05 05:20:07 +00:00
|
|
|
|
2012-01-06 11:28:21 +00:00
|
|
|
#include <float.h>
|
2019-07-03 10:54:24 +00:00
|
|
|
#include <inttypes.h>
|
2012-01-06 11:28:21 +00:00
|
|
|
#include <limits.h>
|
2019-07-02 18:22:58 +00:00
|
|
|
#include <math.h>
|
2012-01-06 11:28:21 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
2019-07-03 10:54:24 +00:00
|
|
|
#include <stdint.h>
|
2012-01-06 11:28:21 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
2011-10-05 05:20:07 +00:00
|
|
|
|
2021-03-19 15:29:57 +00:00
|
|
|
#include <cassert> // For assert() in constant expressions.
|
|
|
|
|
2012-01-06 11:28:21 +00:00
|
|
|
#if defined(_WIN32)
|
2012-11-29 22:40:12 +00:00
|
|
|
#include "platform/floating_point_win.h"
|
2016-02-20 01:48:08 +00:00
|
|
|
#endif // defined(_WIN32)
|
2011-10-05 05:20:07 +00:00
|
|
|
|
2012-11-29 22:40:12 +00:00
|
|
|
#if !defined(_WIN32)
|
|
|
|
#include "platform/floating_point.h"
|
2016-02-20 01:48:08 +00:00
|
|
|
#endif // !defined(_WIN32)
|
2012-11-29 22:40:12 +00:00
|
|
|
|
2011-10-05 05:20:07 +00:00
|
|
|
// Target OS detection.
|
|
|
|
// for more information on predefined macros:
|
|
|
|
// - http://msdn.microsoft.com/en-us/library/b0084kay.aspx
|
|
|
|
// - with gcc, run: "echo | gcc -E -dM -"
|
2012-08-13 23:06:52 +00:00
|
|
|
#if defined(__ANDROID__)
|
2016-02-20 01:48:08 +00:00
|
|
|
|
|
|
|
// Check for Android first, to determine its difference from Linux.
|
2021-07-02 19:06:45 +00:00
|
|
|
#define DART_HOST_OS_ANDROID 1
|
2016-02-20 01:48:08 +00:00
|
|
|
|
2012-08-13 23:06:52 +00:00
|
|
|
#elif defined(__linux__) || defined(__FreeBSD__)
|
2016-02-20 01:48:08 +00:00
|
|
|
|
|
|
|
// Generic Linux.
|
2021-07-02 19:06:45 +00:00
|
|
|
#define DART_HOST_OS_LINUX 1
|
2016-02-20 01:48:08 +00:00
|
|
|
|
2011-10-05 05:20:07 +00:00
|
|
|
#elif defined(__APPLE__)
|
2016-02-20 01:48:08 +00:00
|
|
|
|
2015-05-29 21:35:29 +00:00
|
|
|
// Define the flavor of Mac OS we are running on.
|
|
|
|
#include <TargetConditionals.h>
|
2021-07-02 19:06:45 +00:00
|
|
|
#define DART_HOST_OS_MACOS 1
|
2021-07-02 14:02:02 +00:00
|
|
|
#if TARGET_OS_IPHONE
|
2021-07-02 19:06:45 +00:00
|
|
|
#define DART_HOST_OS_IOS 1
|
2015-05-29 21:35:29 +00:00
|
|
|
#endif
|
|
|
|
|
2011-10-05 05:20:07 +00:00
|
|
|
#elif defined(_WIN32)
|
2016-02-20 01:48:08 +00:00
|
|
|
|
|
|
|
// Windows, both 32- and 64-bit, regardless of the check for _WIN32.
|
2021-07-02 19:06:45 +00:00
|
|
|
#define DART_HOST_OS_WINDOWS 1
|
2016-02-20 01:48:08 +00:00
|
|
|
|
2016-07-14 22:01:30 +00:00
|
|
|
#elif defined(__Fuchsia__)
|
2021-07-02 19:06:45 +00:00
|
|
|
#define DART_HOST_OS_FUCHSIA
|
2016-07-14 22:01:30 +00:00
|
|
|
|
2021-07-02 19:06:45 +00:00
|
|
|
#elif !defined(DART_HOST_OS_FUCHSIA)
|
2011-10-05 05:20:07 +00:00
|
|
|
#error Automatic target os detection failed.
|
|
|
|
#endif
|
|
|
|
|
2016-02-20 01:48:08 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
#define DEBUG_ONLY(code) code
|
|
|
|
#else // defined(DEBUG)
|
|
|
|
#define DEBUG_ONLY(code)
|
|
|
|
#endif // defined(DEBUG)
|
|
|
|
|
2015-04-27 14:46:32 +00:00
|
|
|
namespace dart {
|
|
|
|
|
2013-03-20 20:29:00 +00:00
|
|
|
struct simd128_value_t {
|
2014-01-29 14:21:45 +00:00
|
|
|
union {
|
|
|
|
int32_t int_storage[4];
|
[vm] Remove dynamic field unboxing in JIT
Instead apply the same approach as we do in AOT: unbox based on the
static type information. There are no TFA results available in JIT,
but we could still unbox fields when running in sound null-safety.
TEST=ci
Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-linux-release-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-rollback-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-simarm64-try,vm-kernel-linux-debug-simriscv64-try,vm-kernel-precomp-linux-debug-simriscv64-try,vm-kernel-nnbd-linux-release-ia32-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-nnbd-linux-release-simarm64-try
Change-Id: Ide2e78c6659261ef8d245a4586cf699ea0fbb459
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256211
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-09-20 13:42:45 +00:00
|
|
|
int64_t int64_storage[2];
|
2014-11-06 20:16:34 +00:00
|
|
|
float float_storage[4];
|
2014-01-31 15:28:05 +00:00
|
|
|
double double_storage[2];
|
2014-01-29 14:21:45 +00:00
|
|
|
};
|
2013-03-20 20:29:00 +00:00
|
|
|
simd128_value_t& readFrom(const float* v) {
|
2014-01-29 14:21:45 +00:00
|
|
|
float_storage[0] = v[0];
|
|
|
|
float_storage[1] = v[1];
|
|
|
|
float_storage[2] = v[2];
|
|
|
|
float_storage[3] = v[3];
|
2013-03-20 20:29:00 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2013-11-04 21:56:59 +00:00
|
|
|
simd128_value_t& readFrom(const int32_t* v) {
|
2014-01-29 14:21:45 +00:00
|
|
|
int_storage[0] = v[0];
|
|
|
|
int_storage[1] = v[1];
|
|
|
|
int_storage[2] = v[2];
|
|
|
|
int_storage[3] = v[3];
|
2013-03-20 20:29:00 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2014-01-31 15:28:05 +00:00
|
|
|
simd128_value_t& readFrom(const double* v) {
|
|
|
|
double_storage[0] = v[0];
|
|
|
|
double_storage[1] = v[1];
|
|
|
|
return *this;
|
|
|
|
}
|
2013-03-20 20:29:00 +00:00
|
|
|
simd128_value_t& readFrom(const simd128_value_t* v) {
|
|
|
|
*this = *v;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
void writeTo(float* v) {
|
2014-01-29 14:21:45 +00:00
|
|
|
v[0] = float_storage[0];
|
|
|
|
v[1] = float_storage[1];
|
|
|
|
v[2] = float_storage[2];
|
|
|
|
v[3] = float_storage[3];
|
2013-03-20 20:29:00 +00:00
|
|
|
}
|
2013-11-04 21:56:59 +00:00
|
|
|
void writeTo(int32_t* v) {
|
2014-01-29 14:21:45 +00:00
|
|
|
v[0] = int_storage[0];
|
|
|
|
v[1] = int_storage[1];
|
|
|
|
v[2] = int_storage[2];
|
|
|
|
v[3] = int_storage[3];
|
2013-03-20 20:29:00 +00:00
|
|
|
}
|
2014-01-31 15:28:05 +00:00
|
|
|
void writeTo(double* v) {
|
|
|
|
v[0] = double_storage[0];
|
|
|
|
v[1] = double_storage[1];
|
|
|
|
}
|
2016-11-03 21:25:16 +00:00
|
|
|
void writeTo(simd128_value_t* v) { *v = *this; }
|
2013-03-20 20:29:00 +00:00
|
|
|
};
|
|
|
|
|
2012-01-16 13:23:40 +00:00
|
|
|
// Processor architecture detection. For more info on what's defined, see:
|
|
|
|
// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
|
|
|
|
// http://www.agner.org/optimize/calling_conventions.pdf
|
|
|
|
// or with gcc, run: "echo | gcc -E -dM -"
|
|
|
|
#if defined(_M_X64) || defined(__x86_64__)
|
|
|
|
#define HOST_ARCH_X64 1
|
|
|
|
#define ARCH_IS_64_BIT 1
|
|
|
|
#elif defined(_M_IX86) || defined(__i386__)
|
|
|
|
#define HOST_ARCH_IA32 1
|
|
|
|
#define ARCH_IS_32_BIT 1
|
2022-03-30 19:01:33 +00:00
|
|
|
#elif defined(_M_ARM) || defined(__ARMEL__)
|
2012-01-16 13:23:40 +00:00
|
|
|
#define HOST_ARCH_ARM 1
|
|
|
|
#define ARCH_IS_32_BIT 1
|
2022-03-30 19:01:33 +00:00
|
|
|
#elif defined(_M_ARM64) || defined(__aarch64__)
|
2014-05-27 18:05:20 +00:00
|
|
|
#define HOST_ARCH_ARM64 1
|
|
|
|
#define ARCH_IS_64_BIT 1
|
[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
|
|
|
#elif defined(__riscv)
|
|
|
|
#if __SIZEOF_POINTER__ == 4
|
|
|
|
#define HOST_ARCH_RISCV32 1
|
|
|
|
#define ARCH_IS_32_BIT 1
|
|
|
|
#elif __SIZEOF_POINTER__ == 8
|
|
|
|
#define HOST_ARCH_RISCV64 1
|
|
|
|
#define ARCH_IS_64_BIT 1
|
|
|
|
#else
|
|
|
|
#error Unknown XLEN
|
|
|
|
#endif
|
2012-01-16 13:23:40 +00:00
|
|
|
#else
|
|
|
|
#error Architecture was not detected as supported by Dart.
|
|
|
|
#endif
|
|
|
|
|
2013-02-27 15:21:12 +00:00
|
|
|
// DART_FORCE_INLINE strongly hints to the compiler that a function should
|
|
|
|
// be inlined. Your function is not guaranteed to be inlined but this is
|
|
|
|
// stronger than just using "inline".
|
|
|
|
// See: http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx for an
|
|
|
|
// explanation of some the cases when a function can never be inlined.
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define DART_FORCE_INLINE __forceinline
|
|
|
|
#elif __GNUC__
|
|
|
|
#define DART_FORCE_INLINE inline __attribute__((always_inline))
|
|
|
|
#else
|
|
|
|
#error Automatic compiler detection failed.
|
|
|
|
#endif
|
|
|
|
|
2016-04-18 21:02:01 +00:00
|
|
|
// DART_NOINLINE tells compiler to never inline a particular function.
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define DART_NOINLINE __declspec(noinline)
|
|
|
|
#elif __GNUC__
|
|
|
|
#define DART_NOINLINE __attribute__((noinline))
|
|
|
|
#else
|
2019-12-13 18:55:00 +00:00
|
|
|
#error Automatic compiler detection failed.
|
|
|
|
#endif
|
|
|
|
|
2018-11-26 18:20:27 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#elif __GNUC__
|
|
|
|
#define DART_HAS_COMPUTED_GOTO 1
|
|
|
|
#else
|
|
|
|
#error Automatic compiler detection failed.
|
|
|
|
#endif
|
|
|
|
|
2023-01-24 18:00:25 +00:00
|
|
|
// LIKELY/UNLIKELY give the compiler branch predictions that may affect block
|
2018-11-26 18:20:27 +00:00
|
|
|
// scheduling.
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define LIKELY(cond) __builtin_expect((cond), 1)
|
|
|
|
#define UNLIKELY(cond) __builtin_expect((cond), 0)
|
|
|
|
#else
|
|
|
|
#define LIKELY(cond) cond
|
|
|
|
#define UNLIKELY(cond) cond
|
|
|
|
#endif
|
|
|
|
|
2017-06-05 16:22:03 +00:00
|
|
|
// DART_UNUSED indicates to the compiler that a variable or typedef is expected
|
2013-10-09 19:43:41 +00:00
|
|
|
// to be unused and disables the related warning.
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define DART_UNUSED __attribute__((unused))
|
|
|
|
#else
|
|
|
|
#define DART_UNUSED
|
|
|
|
#endif
|
|
|
|
|
2017-06-05 16:22:03 +00:00
|
|
|
// DART_USED indicates to the compiler that a global variable or typedef is used
|
|
|
|
// disables e.g. the gcc warning "unused-variable"
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define DART_USED __attribute__((used))
|
|
|
|
#else
|
|
|
|
#define DART_USED
|
|
|
|
#endif
|
|
|
|
|
2017-05-01 06:28:01 +00:00
|
|
|
// DART_NORETURN indicates to the compiler that a function does not return.
|
2015-10-30 06:35:46 +00:00
|
|
|
// It should be used on functions that unconditionally call functions like
|
|
|
|
// exit(), which end the program. We use it to avoid compiler warnings in
|
|
|
|
// callers of DART_NORETURN functions.
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define DART_NORETURN __declspec(noreturn)
|
|
|
|
#elif __GNUC__
|
|
|
|
#define DART_NORETURN __attribute__((noreturn))
|
|
|
|
#else
|
|
|
|
#error Automatic compiler detection failed.
|
|
|
|
#endif
|
|
|
|
|
2016-10-17 19:58:24 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define DART_PRETTY_FUNCTION __FUNCSIG__
|
|
|
|
#elif __GNUC__
|
|
|
|
#define DART_PRETTY_FUNCTION __PRETTY_FUNCTION__
|
|
|
|
#else
|
|
|
|
#error Automatic compiler detection failed.
|
|
|
|
#endif
|
|
|
|
|
2017-06-22 15:49:19 +00:00
|
|
|
#if !defined(TARGET_ARCH_ARM) && !defined(TARGET_ARCH_X64) && \
|
[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
|
|
|
!defined(TARGET_ARCH_IA32) && !defined(TARGET_ARCH_ARM64) && \
|
|
|
|
!defined(TARGET_ARCH_RISCV32) && !defined(TARGET_ARCH_RISCV64)
|
2012-01-16 13:23:40 +00:00
|
|
|
// No target architecture specified pick the one matching the host architecture.
|
2017-06-22 15:49:19 +00:00
|
|
|
#if defined(HOST_ARCH_ARM)
|
2012-01-16 13:23:40 +00:00
|
|
|
#define TARGET_ARCH_ARM 1
|
|
|
|
#elif defined(HOST_ARCH_X64)
|
|
|
|
#define TARGET_ARCH_X64 1
|
|
|
|
#elif defined(HOST_ARCH_IA32)
|
|
|
|
#define TARGET_ARCH_IA32 1
|
2014-04-02 17:39:32 +00:00
|
|
|
#elif defined(HOST_ARCH_ARM64)
|
|
|
|
#define TARGET_ARCH_ARM64 1
|
[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
|
|
|
#elif defined(HOST_ARCH_RISCV32)
|
|
|
|
#define TARGET_ARCH_RISCV32 1
|
|
|
|
#elif defined(HOST_ARCH_RISCV64)
|
|
|
|
#define TARGET_ARCH_RISCV64 1
|
2012-01-16 13:23:40 +00:00
|
|
|
#else
|
|
|
|
#error Automatic target architecture detection failed.
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
[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
|
|
|
#if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM) || \
|
|
|
|
defined(TARGET_ARCH_RISCV32)
|
2019-05-29 23:59:12 +00:00
|
|
|
#define TARGET_ARCH_IS_32_BIT 1
|
[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
|
|
|
#elif defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_ARM64) || \
|
|
|
|
defined(TARGET_ARCH_RISCV64)
|
2019-05-29 23:59:12 +00:00
|
|
|
#define TARGET_ARCH_IS_64_BIT 1
|
|
|
|
#else
|
|
|
|
#error Automatic target architecture detection failed.
|
|
|
|
#endif
|
|
|
|
|
2021-08-03 13:19:01 +00:00
|
|
|
#if defined(TARGET_ARCH_IS_64_BIT) && !defined(DART_COMPRESSED_POINTERS)
|
|
|
|
#define HAS_SMI_63_BITS 1
|
|
|
|
#endif
|
|
|
|
|
2012-01-16 13:23:40 +00:00
|
|
|
// Verify that host and target architectures match, we cannot
|
|
|
|
// have a 64 bit Dart VM generating 32 bit code or vice-versa.
|
[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
|
|
|
#if defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_ARM64) || \
|
|
|
|
defined(TARGET_ARCH_RISCV64)
|
2020-11-16 16:10:55 +00:00
|
|
|
#if !defined(ARCH_IS_64_BIT) && !defined(FFI_UNIT_TESTS)
|
2012-01-16 13:23:40 +00:00
|
|
|
#error Mismatched Host/Target architectures.
|
2020-11-16 16:10:55 +00:00
|
|
|
#endif // !defined(ARCH_IS_64_BIT) && !defined(FFI_UNIT_TESTS)
|
[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
|
|
|
#elif defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM) || \
|
|
|
|
defined(TARGET_ARCH_RISCV32)
|
2022-05-10 16:11:53 +00:00
|
|
|
#if defined(ARCH_IS_64_BIT) && defined(TARGET_ARCH_ARM)
|
|
|
|
// This is simarm_x64 or simarm_arm64, which is the only case where host/target
|
|
|
|
// architecture mismatch is allowed. Unless, we're running FFI unit tests.
|
|
|
|
#define IS_SIMARM_HOST64 1
|
2020-11-16 16:10:55 +00:00
|
|
|
#elif !defined(ARCH_IS_32_BIT) && !defined(FFI_UNIT_TESTS)
|
2012-01-16 13:23:40 +00:00
|
|
|
#error Mismatched Host/Target architectures.
|
2020-11-16 16:10:55 +00:00
|
|
|
#endif // !defined(ARCH_IS_32_BIT) && !defined(FFI_UNIT_TESTS)
|
2019-06-21 04:00:35 +00:00
|
|
|
#endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM)
|
2012-01-16 13:23:40 +00:00
|
|
|
|
2015-05-29 21:35:29 +00:00
|
|
|
// Determine whether we will be using the simulator.
|
|
|
|
#if defined(TARGET_ARCH_IA32)
|
2021-09-27 23:45:45 +00:00
|
|
|
#if !defined(HOST_ARCH_IA32)
|
|
|
|
#define USING_SIMULATOR 1
|
|
|
|
#endif
|
2015-05-29 21:35:29 +00:00
|
|
|
#elif defined(TARGET_ARCH_X64)
|
2021-09-27 23:45:45 +00:00
|
|
|
#if !defined(HOST_ARCH_X64)
|
|
|
|
#define USING_SIMULATOR 1
|
|
|
|
#endif
|
2015-05-29 21:35:29 +00:00
|
|
|
#elif defined(TARGET_ARCH_ARM)
|
2015-10-22 19:26:41 +00:00
|
|
|
#if !defined(HOST_ARCH_ARM)
|
2019-06-21 04:00:35 +00:00
|
|
|
#define TARGET_HOST_MISMATCH 1
|
2022-05-10 16:11:53 +00:00
|
|
|
#if !defined(IS_SIMARM_HOST64)
|
2015-05-29 21:35:29 +00:00
|
|
|
#define USING_SIMULATOR 1
|
|
|
|
#endif
|
2019-06-21 04:00:35 +00:00
|
|
|
#endif
|
2015-05-29 21:35:29 +00:00
|
|
|
#elif defined(TARGET_ARCH_ARM64)
|
2015-10-22 19:26:41 +00:00
|
|
|
#if !defined(HOST_ARCH_ARM64)
|
2015-05-29 21:35:29 +00:00
|
|
|
#define USING_SIMULATOR 1
|
|
|
|
#endif
|
[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
|
|
|
#elif defined(TARGET_ARCH_RISCV32)
|
|
|
|
#if !defined(HOST_ARCH_RISCV32)
|
|
|
|
#define USING_SIMULATOR 1
|
|
|
|
#endif
|
|
|
|
#elif defined(TARGET_ARCH_RISCV64)
|
|
|
|
#if !defined(HOST_ARCH_RISCV64)
|
|
|
|
#define USING_SIMULATOR 1
|
|
|
|
#endif
|
2015-05-29 21:35:29 +00:00
|
|
|
#else
|
|
|
|
#error Unknown architecture.
|
|
|
|
#endif
|
|
|
|
|
2021-07-02 19:06:45 +00:00
|
|
|
#if !defined(DART_TARGET_OS_ANDROID) && !defined(DART_TARGET_OS_FUCHSIA) && \
|
|
|
|
!defined(DART_TARGET_OS_MACOS_IOS) && !defined(DART_TARGET_OS_LINUX) && \
|
|
|
|
!defined(DART_TARGET_OS_MACOS) && !defined(DART_TARGET_OS_WINDOWS)
|
2017-03-20 21:48:28 +00:00
|
|
|
// No target OS specified; pick the one matching the host OS.
|
2021-07-02 19:06:45 +00:00
|
|
|
#if defined(DART_HOST_OS_ANDROID)
|
|
|
|
#define DART_TARGET_OS_ANDROID 1
|
|
|
|
#elif defined(DART_HOST_OS_FUCHSIA)
|
|
|
|
#define DART_TARGET_OS_FUCHSIA 1
|
|
|
|
#elif defined(DART_HOST_OS_IOS)
|
|
|
|
#define DART_TARGET_OS_MACOS 1
|
|
|
|
#define DART_TARGET_OS_MACOS_IOS 1
|
|
|
|
#elif defined(DART_HOST_OS_LINUX)
|
|
|
|
#define DART_TARGET_OS_LINUX 1
|
|
|
|
#elif defined(DART_HOST_OS_MACOS)
|
|
|
|
#define DART_TARGET_OS_MACOS 1
|
|
|
|
#elif defined(DART_HOST_OS_WINDOWS)
|
|
|
|
#define DART_TARGET_OS_WINDOWS 1
|
2016-05-17 22:03:54 +00:00
|
|
|
#else
|
2017-03-20 21:48:28 +00:00
|
|
|
#error Automatic target OS detection failed.
|
2016-05-17 22:03:54 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2012-09-06 00:58:25 +00:00
|
|
|
// Short form printf format specifiers
|
|
|
|
#define Pd PRIdPTR
|
|
|
|
#define Pu PRIuPTR
|
|
|
|
#define Px PRIxPTR
|
2017-08-01 17:49:48 +00:00
|
|
|
#define PX PRIXPTR
|
2017-11-22 12:04:18 +00:00
|
|
|
#define Pd32 PRId32
|
|
|
|
#define Pu32 PRIu32
|
|
|
|
#define Px32 PRIx32
|
|
|
|
#define PX32 PRIX32
|
2012-09-06 00:58:25 +00:00
|
|
|
#define Pd64 PRId64
|
|
|
|
#define Pu64 PRIu64
|
|
|
|
#define Px64 PRIx64
|
2017-08-01 17:49:48 +00:00
|
|
|
#define PX64 PRIX64
|
2012-09-06 00:58:25 +00:00
|
|
|
|
2015-08-11 18:22:55 +00:00
|
|
|
// Zero-padded pointer
|
|
|
|
#if defined(ARCH_IS_32_BIT)
|
|
|
|
#define Pp "08" PRIxPTR
|
|
|
|
#else
|
|
|
|
#define Pp "016" PRIxPTR
|
|
|
|
#endif
|
|
|
|
|
2012-01-16 13:23:40 +00:00
|
|
|
// Suffixes for 64-bit integer literals.
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define DART_INT64_C(x) x##I64
|
|
|
|
#define DART_UINT64_C(x) x##UI64
|
|
|
|
#else
|
|
|
|
#define DART_INT64_C(x) x##LL
|
|
|
|
#define DART_UINT64_C(x) x##ULL
|
|
|
|
#endif
|
|
|
|
|
2014-03-13 21:00:44 +00:00
|
|
|
// Replace calls to strtoll with _strtoi64 on Windows.
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define strtoll _strtoi64
|
|
|
|
#endif
|
2012-01-16 13:23:40 +00:00
|
|
|
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
// Byte sizes.
|
2023-10-20 19:45:49 +00:00
|
|
|
constexpr intptr_t kInt8SizeLog2 = 0;
|
|
|
|
constexpr intptr_t kInt8Size = 1 << kInt8SizeLog2;
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
static_assert(kInt8Size == sizeof(int8_t), "Mismatched int8 size constant");
|
2023-10-20 19:45:49 +00:00
|
|
|
constexpr intptr_t kInt16SizeLog2 = 1;
|
|
|
|
constexpr intptr_t kInt16Size = 1 << kInt16SizeLog2;
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
static_assert(kInt16Size == sizeof(int16_t), "Mismatched int16 size constant");
|
2023-10-20 19:45:49 +00:00
|
|
|
constexpr intptr_t kInt32SizeLog2 = 2;
|
|
|
|
constexpr intptr_t kInt32Size = 1 << kInt32SizeLog2;
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
static_assert(kInt32Size == sizeof(int32_t), "Mismatched int32 size constant");
|
2023-10-20 19:45:49 +00:00
|
|
|
constexpr intptr_t kInt64SizeLog2 = 3;
|
|
|
|
constexpr intptr_t kInt64Size = 1 << kInt64SizeLog2;
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
static_assert(kInt64Size == sizeof(int64_t), "Mismatched int64 size constant");
|
|
|
|
|
2023-10-20 19:45:49 +00:00
|
|
|
constexpr intptr_t kDoubleSize = sizeof(double);
|
|
|
|
constexpr intptr_t kFloatSize = sizeof(float);
|
|
|
|
constexpr intptr_t kQuadSize = 4 * kFloatSize;
|
|
|
|
constexpr intptr_t kSimd128Size = sizeof(simd128_value_t);
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
|
|
|
|
// Bit sizes.
|
2023-10-20 19:45:49 +00:00
|
|
|
constexpr intptr_t kBitsPerByteLog2 = 3;
|
|
|
|
constexpr intptr_t kBitsPerByte = 1 << kBitsPerByteLog2;
|
|
|
|
constexpr intptr_t kBitsPerInt8 = kInt8Size * kBitsPerByte;
|
|
|
|
constexpr intptr_t kBitsPerInt16 = kInt16Size * kBitsPerByte;
|
|
|
|
constexpr intptr_t kBitsPerInt32 = kInt32Size * kBitsPerByte;
|
|
|
|
constexpr intptr_t kBitsPerInt64 = kInt64Size * kBitsPerByte;
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
|
2012-01-16 13:23:40 +00:00
|
|
|
// The following macro works on both 32 and 64-bit platforms.
|
2012-02-08 09:22:46 +00:00
|
|
|
// Usage: instead of writing 0x1234567890123456ULL
|
2012-01-16 13:23:40 +00:00
|
|
|
// write DART_2PART_UINT64_C(0x12345678,90123456);
|
|
|
|
#define DART_2PART_UINT64_C(a, b) \
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
(((static_cast<uint64_t>(a) << kBitsPerInt32) + 0x##b##u))
|
2012-01-16 13:23:40 +00:00
|
|
|
|
2012-02-08 09:22:46 +00:00
|
|
|
// Integer constants.
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
constexpr int8_t kMinInt8 = 0x80;
|
|
|
|
constexpr int8_t kMaxInt8 = 0x7F;
|
|
|
|
constexpr uint8_t kMaxUint8 = 0xFF;
|
|
|
|
constexpr int16_t kMinInt16 = 0x8000;
|
|
|
|
constexpr int16_t kMaxInt16 = 0x7FFF;
|
|
|
|
constexpr uint16_t kMaxUint16 = 0xFFFF;
|
|
|
|
constexpr int32_t kMinInt32 = 0x80000000;
|
|
|
|
constexpr int32_t kMaxInt32 = 0x7FFFFFFF;
|
|
|
|
constexpr uint32_t kMaxUint32 = 0xFFFFFFFF;
|
|
|
|
constexpr int64_t kMinInt64 = DART_INT64_C(0x8000000000000000);
|
|
|
|
constexpr int64_t kMaxInt64 = DART_INT64_C(0x7FFFFFFFFFFFFFFF);
|
|
|
|
constexpr uint64_t kMaxUint64 = DART_2PART_UINT64_C(0xFFFFFFFF, FFFFFFFF);
|
|
|
|
|
|
|
|
constexpr int kMinInt = INT_MIN;
|
|
|
|
constexpr int kMaxInt = INT_MAX;
|
|
|
|
constexpr int kMaxUint = UINT_MAX;
|
|
|
|
|
|
|
|
constexpr int64_t kMinInt64RepresentableAsDouble = kMinInt64;
|
|
|
|
constexpr int64_t kMaxInt64RepresentableAsDouble =
|
|
|
|
DART_INT64_C(0x7FFFFFFFFFFFFC00);
|
|
|
|
constexpr int64_t kSignBitDouble = DART_INT64_C(0x8000000000000000);
|
2012-01-16 13:23:40 +00:00
|
|
|
|
|
|
|
// Types for native machine words. Guaranteed to be able to hold pointers and
|
|
|
|
// integers.
|
|
|
|
typedef intptr_t word;
|
|
|
|
typedef uintptr_t uword;
|
|
|
|
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
// Byte sizes for native machine words.
|
2012-01-16 13:23:40 +00:00
|
|
|
#ifdef ARCH_IS_32_BIT
|
2023-10-20 19:45:49 +00:00
|
|
|
constexpr intptr_t kWordSizeLog2 = kInt32SizeLog2;
|
2012-01-16 13:23:40 +00:00
|
|
|
#else
|
2023-10-20 19:45:49 +00:00
|
|
|
constexpr intptr_t kWordSizeLog2 = kInt64SizeLog2;
|
2012-01-16 13:23:40 +00:00
|
|
|
#endif
|
2023-10-20 19:45:49 +00:00
|
|
|
constexpr intptr_t kWordSize = 1 << kWordSizeLog2;
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
static_assert(kWordSize == sizeof(word), "Mismatched word size constant");
|
2012-01-16 13:23:40 +00:00
|
|
|
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
// Bit sizes for native machine words.
|
2023-10-20 19:45:49 +00:00
|
|
|
constexpr intptr_t kBitsPerWordLog2 = kWordSizeLog2 + kBitsPerByteLog2;
|
|
|
|
constexpr intptr_t kBitsPerWord = 1 << kBitsPerWordLog2;
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
|
|
|
|
// Integer constants for native machine words.
|
|
|
|
constexpr word kWordMin = static_cast<uword>(1) << (kBitsPerWord - 1);
|
|
|
|
constexpr word kWordMax = (static_cast<uword>(1) << (kBitsPerWord - 1)) - 1;
|
|
|
|
constexpr uword kUwordMax = static_cast<uword>(-1);
|
|
|
|
|
|
|
|
// Size of a class id assigned to concrete, abstract and top-level classes.
|
|
|
|
//
|
|
|
|
// We use a signed integer type here to make it comparable with intptr_t.
|
|
|
|
typedef int32_t classid_t;
|
2012-01-16 13:23:40 +00:00
|
|
|
|
|
|
|
// System-wide named constants.
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
constexpr intptr_t KBLog2 = 10;
|
|
|
|
constexpr intptr_t KB = 1 << KBLog2;
|
|
|
|
constexpr intptr_t MBLog2 = KBLog2 + KBLog2;
|
|
|
|
constexpr intptr_t MB = 1 << MBLog2;
|
|
|
|
constexpr intptr_t GBLog2 = MBLog2 + KBLog2;
|
|
|
|
constexpr intptr_t GB = 1 << GBLog2;
|
|
|
|
|
|
|
|
constexpr intptr_t KBInWordsLog2 = KBLog2 - kWordSizeLog2;
|
|
|
|
constexpr intptr_t KBInWords = 1 << KBInWordsLog2;
|
|
|
|
constexpr intptr_t MBInWordsLog2 = KBLog2 + KBInWordsLog2;
|
|
|
|
constexpr intptr_t MBInWords = 1 << MBInWordsLog2;
|
|
|
|
constexpr intptr_t GBInWordsLog2 = MBLog2 + KBInWordsLog2;
|
|
|
|
constexpr intptr_t GBInWords = 1 << GBInWordsLog2;
|
2013-11-16 00:17:52 +00:00
|
|
|
|
|
|
|
// Helpers to round memory sizes to human readable values.
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
constexpr intptr_t RoundWordsToKB(intptr_t size_in_words) {
|
2013-11-16 00:17:52 +00:00
|
|
|
return (size_in_words + (KBInWords >> 1)) >> KBInWordsLog2;
|
|
|
|
}
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
constexpr intptr_t RoundWordsToMB(intptr_t size_in_words) {
|
2013-11-16 00:17:52 +00:00
|
|
|
return (size_in_words + (MBInWords >> 1)) >> MBInWordsLog2;
|
|
|
|
}
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
constexpr intptr_t RoundWordsToGB(intptr_t size_in_words) {
|
2013-11-16 00:17:52 +00:00
|
|
|
return (size_in_words + (GBInWords >> 1)) >> GBInWordsLog2;
|
|
|
|
}
|
2021-10-28 18:20:18 +00:00
|
|
|
constexpr double WordsToMB(intptr_t size_in_words) {
|
|
|
|
return static_cast<double>(size_in_words) / MBInWords;
|
|
|
|
}
|
2013-11-16 00:17:52 +00:00
|
|
|
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
constexpr intptr_t kIntptrOne = 1;
|
|
|
|
constexpr intptr_t kIntptrMin = (kIntptrOne << (kBitsPerWord - 1));
|
|
|
|
constexpr intptr_t kIntptrMax = ~kIntptrMin;
|
2012-01-16 13:23:40 +00:00
|
|
|
|
|
|
|
// Time constants.
|
2023-10-20 19:45:49 +00:00
|
|
|
constexpr intptr_t kMillisecondsPerSecond = 1000;
|
|
|
|
constexpr intptr_t kMicrosecondsPerMillisecond = 1000;
|
|
|
|
constexpr intptr_t kMicrosecondsPerSecond =
|
2016-11-03 21:25:16 +00:00
|
|
|
(kMicrosecondsPerMillisecond * kMillisecondsPerSecond);
|
2023-10-20 19:45:49 +00:00
|
|
|
constexpr intptr_t kNanosecondsPerMicrosecond = 1000;
|
|
|
|
constexpr intptr_t kNanosecondsPerMillisecond =
|
2016-11-03 21:25:16 +00:00
|
|
|
(kNanosecondsPerMicrosecond * kMicrosecondsPerMillisecond);
|
2023-10-20 19:45:49 +00:00
|
|
|
constexpr intptr_t kNanosecondsPerSecond =
|
2016-11-03 21:25:16 +00:00
|
|
|
(kNanosecondsPerMicrosecond * kMicrosecondsPerSecond);
|
2011-10-05 05:20:07 +00:00
|
|
|
|
2014-03-11 14:11:25 +00:00
|
|
|
// Helpers to scale micro second times to human understandable values.
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
constexpr double MicrosecondsToSeconds(int64_t micros) {
|
2014-03-11 14:11:25 +00:00
|
|
|
return static_cast<double>(micros) / kMicrosecondsPerSecond;
|
2013-11-16 00:17:52 +00:00
|
|
|
}
|
[vm] Merge ImageHeader into InstructionsSection.
Before, we only wrapped the Instructions payloads in an
InstructionsSection in precompiled snapshots with bare instructions mode
enabled. This CL changes that to always add an InstructionsSection
wrapper in precompiled snapshots, even when not in bare instructions
mode, and moves all the information from the old ImageHeader object into
the InstructionsSection object instead. Note that in non-bare mode, the
InstructionsSection has no payload, and the Instructions objects follow
the InstructionsSection object instead of being contained by it.
This CL also wraps all implementations of AssemblyImageWriter and
SnapshotTextObjectNamer methods in a single DART_PRECOMPILER ifdef
block, since we only generate assembly in precompiled mode. This
removes the need for the smaller DART_PRECOMPILER ifdef blocks scattered
across the AssemblyImageWriter method implementations.
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-precomp-win-release-x64-try
Change-Id: I3676fb5c6675845463707acbbb4759a465cfa342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-06 17:10:05 +00:00
|
|
|
constexpr double MicrosecondsToMilliseconds(int64_t micros) {
|
2014-03-11 14:11:25 +00:00
|
|
|
return static_cast<double>(micros) / kMicrosecondsPerMillisecond;
|
2013-11-16 00:17:52 +00:00
|
|
|
}
|
|
|
|
|
2011-10-05 05:20:07 +00:00
|
|
|
// A macro to disallow the copy constructor and operator= functions.
|
|
|
|
// This should be used in the private: declarations for a class.
|
2015-04-27 14:46:32 +00:00
|
|
|
#if !defined(DISALLOW_COPY_AND_ASSIGN)
|
2011-10-05 05:20:07 +00:00
|
|
|
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
2016-11-03 21:25:16 +00:00
|
|
|
private: \
|
2019-03-23 00:52:41 +00:00
|
|
|
TypeName(const TypeName&) = delete; \
|
|
|
|
void operator=(const TypeName&) = delete
|
2015-04-27 14:46:32 +00:00
|
|
|
#endif // !defined(DISALLOW_COPY_AND_ASSIGN)
|
2011-10-05 05:20:07 +00:00
|
|
|
|
|
|
|
// A macro to disallow all the implicit constructors, namely the default
|
|
|
|
// constructor, copy constructor and operator= functions. This should be
|
|
|
|
// used in the private: declarations for a class that wants to prevent
|
|
|
|
// anyone from instantiating it. This is especially useful for classes
|
|
|
|
// containing only static methods.
|
2015-04-27 14:46:32 +00:00
|
|
|
#if !defined(DISALLOW_IMPLICIT_CONSTRUCTORS)
|
2011-10-05 05:20:07 +00:00
|
|
|
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
|
2016-11-03 21:25:16 +00:00
|
|
|
private: \
|
2019-03-23 00:52:41 +00:00
|
|
|
TypeName() = delete; \
|
2011-10-05 05:20:07 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(TypeName)
|
2015-04-27 14:46:32 +00:00
|
|
|
#endif // !defined(DISALLOW_IMPLICIT_CONSTRUCTORS)
|
2011-10-05 05:20:07 +00:00
|
|
|
|
|
|
|
// Macro to disallow allocation in the C++ heap. This should be used
|
2012-01-17 10:10:05 +00:00
|
|
|
// in the private section for a class. Don't use UNREACHABLE here to
|
|
|
|
// avoid circular dependencies between platform/globals.h and
|
|
|
|
// platform/assert.h.
|
2015-04-27 14:46:32 +00:00
|
|
|
#if !defined(DISALLOW_ALLOCATION)
|
2011-10-05 05:20:07 +00:00
|
|
|
#define DISALLOW_ALLOCATION() \
|
2016-11-03 21:25:16 +00:00
|
|
|
public: \
|
2012-01-17 10:10:05 +00:00
|
|
|
void operator delete(void* pointer) { \
|
|
|
|
fprintf(stderr, "unreachable code\n"); \
|
2012-06-14 01:02:08 +00:00
|
|
|
abort(); \
|
2012-01-17 10:10:05 +00:00
|
|
|
} \
|
2016-11-03 21:25:16 +00:00
|
|
|
\
|
|
|
|
private: \
|
2011-10-05 05:20:07 +00:00
|
|
|
void* operator new(size_t size);
|
2015-04-27 14:46:32 +00:00
|
|
|
#endif // !defined(DISALLOW_ALLOCATION)
|
2011-10-05 05:20:07 +00:00
|
|
|
|
|
|
|
// The USE(x) template is used to silence C++ compiler warnings issued
|
|
|
|
// for unused variables.
|
|
|
|
template <typename T>
|
2020-09-15 09:50:02 +00:00
|
|
|
static inline void USE(T&&) {}
|
2011-10-05 05:20:07 +00:00
|
|
|
|
2012-01-16 13:23:40 +00:00
|
|
|
// The type-based aliasing rule allows the compiler to assume that
|
|
|
|
// pointers of different types (for some definition of different)
|
|
|
|
// never alias each other. Thus the following code does not work:
|
|
|
|
//
|
|
|
|
// float f = foo();
|
|
|
|
// int fbits = *(int*)(&f);
|
|
|
|
//
|
|
|
|
// The compiler 'knows' that the int pointer can't refer to f since
|
|
|
|
// the types don't match, so the compiler may cache f in a register,
|
|
|
|
// leaving random data in fbits. Using C++ style casts makes no
|
|
|
|
// difference, however a pointer to char data is assumed to alias any
|
|
|
|
// other pointer. This is the 'memcpy exception'.
|
|
|
|
//
|
|
|
|
// The bit_cast function uses the memcpy exception to move the bits
|
|
|
|
// from a variable of one type to a variable of another type. Of
|
|
|
|
// course the end result is likely to be implementation dependent.
|
|
|
|
// Most compilers (gcc-4.2 and MSVC 2005) will completely optimize
|
|
|
|
// bit_cast away.
|
|
|
|
//
|
|
|
|
// There is an additional use for bit_cast. Recent gccs will warn when
|
|
|
|
// they see casts that may result in breakage due to the type-based
|
|
|
|
// aliasing rule. If you have checked that there is no breakage you
|
|
|
|
// can use bit_cast to cast one pointer type to another. This confuses
|
|
|
|
// gcc enough that it can no longer see that you have cast one pointer
|
|
|
|
// type to another thus avoiding the warning.
|
|
|
|
template <class D, class S>
|
2022-01-04 08:33:15 +00:00
|
|
|
DART_FORCE_INLINE D bit_cast(const S& source) {
|
2020-05-04 21:15:27 +00:00
|
|
|
static_assert(sizeof(D) == sizeof(S),
|
|
|
|
"Source and destination must have the same size");
|
2012-01-16 13:23:40 +00:00
|
|
|
|
|
|
|
D destination;
|
|
|
|
// This use of memcpy is safe: source and destination cannot overlap.
|
|
|
|
memcpy(&destination, &source, sizeof(destination));
|
|
|
|
return destination;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Similar to bit_cast, but allows copying from types of unrelated
|
|
|
|
// sizes. This method was introduced to enable the strict aliasing
|
|
|
|
// optimizations of GCC 4.4. Basically, GCC mindlessly relies on
|
|
|
|
// obscure details in the C++ standard that make reinterpret_cast
|
|
|
|
// virtually useless.
|
2016-11-03 21:25:16 +00:00
|
|
|
template <class D, class S>
|
2022-01-04 08:33:15 +00:00
|
|
|
DART_FORCE_INLINE D bit_copy(const S& source) {
|
2012-01-16 13:23:40 +00:00
|
|
|
D destination;
|
|
|
|
// This use of memcpy is safe: source and destination cannot overlap.
|
2016-11-03 21:25:16 +00:00
|
|
|
memcpy(&destination, reinterpret_cast<const void*>(&source),
|
2012-01-16 13:23:40 +00:00
|
|
|
sizeof(destination));
|
|
|
|
return destination;
|
|
|
|
}
|
|
|
|
|
2023-01-19 16:24:29 +00:00
|
|
|
// On Windows the reentrant version of strtok is called
|
2011-10-05 05:20:07 +00:00
|
|
|
// strtok_s. Unify on the posix name strtok_r.
|
2021-07-02 19:06:45 +00:00
|
|
|
#if defined(DART_HOST_OS_WINDOWS)
|
2018-04-04 21:28:16 +00:00
|
|
|
#define snprintf _sprintf_p
|
2011-10-05 05:20:07 +00:00
|
|
|
#define strtok_r strtok_s
|
|
|
|
#endif
|
|
|
|
|
2021-07-02 19:06:45 +00:00
|
|
|
#if !defined(DART_HOST_OS_WINDOWS)
|
2014-03-17 13:51:11 +00:00
|
|
|
#if defined(TEMP_FAILURE_RETRY)
|
|
|
|
// TEMP_FAILURE_RETRY is defined in unistd.h on some platforms. We should
|
|
|
|
// not use that version, but instead the one in signal_blocker.h, to ensure
|
|
|
|
// we disable signal interrupts.
|
|
|
|
#undef TEMP_FAILURE_RETRY
|
|
|
|
#endif // defined(TEMP_FAILURE_RETRY)
|
2021-07-02 19:06:45 +00:00
|
|
|
#endif // !defined(DART_HOST_OS_WINDOWS)
|
2012-09-06 00:58:25 +00:00
|
|
|
|
2017-10-09 22:26:01 +00:00
|
|
|
#if __GNUC__
|
2012-09-06 00:58:25 +00:00
|
|
|
// Tell the compiler to do printf format string checking if the
|
|
|
|
// compiler supports it; see the 'format' attribute in
|
|
|
|
// <http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html>.
|
|
|
|
//
|
|
|
|
// N.B.: As the GCC manual states, "[s]ince non-static C++ methods
|
|
|
|
// have an implicit 'this' argument, the arguments of such methods
|
|
|
|
// should be counted from two, not one."
|
2016-11-03 21:25:16 +00:00
|
|
|
#define PRINTF_ATTRIBUTE(string_index, first_to_check) \
|
2012-09-06 00:58:25 +00:00
|
|
|
__attribute__((__format__(__printf__, string_index, first_to_check)))
|
|
|
|
#else
|
|
|
|
#define PRINTF_ATTRIBUTE(string_index, first_to_check)
|
|
|
|
#endif
|
|
|
|
|
2015-07-14 21:28:06 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
#define STDIN_FILENO 0
|
|
|
|
#define STDOUT_FILENO 1
|
|
|
|
#define STDERR_FILENO 2
|
|
|
|
#endif
|
|
|
|
|
2019-10-18 10:30:48 +00:00
|
|
|
#ifndef PATH_MAX
|
|
|
|
// Most platforms use PATH_MAX, but in Windows it's called MAX_PATH.
|
|
|
|
#define PATH_MAX MAX_PATH
|
|
|
|
#endif
|
|
|
|
|
2020-05-20 14:05:40 +00:00
|
|
|
// Undefine math.h definition which clashes with our condition names.
|
|
|
|
#undef OVERFLOW
|
|
|
|
|
2022-03-11 09:20:36 +00:00
|
|
|
// Include IL printer and disassembler functionality into non-PRODUCT builds,
|
|
|
|
// in all AOT compiler builds or when forced.
|
2021-02-02 11:35:00 +00:00
|
|
|
#if !defined(PRODUCT) || defined(DART_PRECOMPILER) || \
|
|
|
|
defined(FORCE_INCLUDE_DISASSEMBLER)
|
|
|
|
#if defined(DART_PRECOMPILED_RUNTIME) && defined(PRODUCT)
|
|
|
|
#error Requested to include IL printer into PRODUCT AOT runtime
|
|
|
|
#endif
|
|
|
|
#define INCLUDE_IL_PRINTER 1
|
2022-03-11 09:20:36 +00:00
|
|
|
#if !defined(FORCE_INCLUDE_DISASSEMBLER)
|
|
|
|
#define FORCE_INCLUDE_DISASSEMBLER 1
|
|
|
|
#endif
|
2021-02-02 11:35:00 +00:00
|
|
|
#endif
|
|
|
|
|
2022-12-01 14:38:44 +00:00
|
|
|
// Include HeapSnapshotWriter functionality if not in PRODUCT.
|
|
|
|
#if !defined(DART_ENABLE_HEAP_SNAPSHOT_WRITER) && !defined(PRODUCT)
|
|
|
|
#define DART_ENABLE_HEAP_SNAPSHOT_WRITER 1
|
|
|
|
#endif
|
|
|
|
|
[vm] Add OS and architecture to non-symbolic stack traces.
Examples of the new line added to non-symbolic stack traces:
os: linux arch: x64 comp: yes sim: no
(Running on linux-x64c)
os: macos arch: arm64 comp: no sim: yes
(Running on mac-simarm64)
This CL also abstracts out the separate hardcoded strings across
the codebase for host and target OS and architecture into
definitions in platform/globals.h to ensure that they stay
in sync across different uses.
TEST=vm/dart{,_2}/use_dwarf_stack_traces_flag
Issue: https://github.com/flutter/flutter/pull/101586
Change-Id: Ifdfea5138dd1003f561da0174e89aebc165bf9b0
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-mac-product-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-simarm_x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-ffi-android-release-arm-try,vm-ffi-android-release-arm64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253283
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2022-08-05 11:53:37 +00:00
|
|
|
#if defined(DART_HOST_OS_ANDROID)
|
|
|
|
#define kHostOperatingSystemName "android"
|
|
|
|
#elif defined(DART_HOST_OS_FUCHSIA)
|
|
|
|
#define kHostOperatingSystemName "fuchsia"
|
|
|
|
#elif defined(DART_HOST_OS_IOS)
|
|
|
|
#define kHostOperatingSystemName "ios"
|
|
|
|
#elif defined(DART_HOST_OS_LINUX)
|
|
|
|
#define kHostOperatingSystemName "linux"
|
|
|
|
#elif defined(DART_HOST_OS_MACOS)
|
|
|
|
#define kHostOperatingSystemName "macos"
|
|
|
|
#elif defined(DART_HOST_OS_WINDOWS)
|
|
|
|
#define kHostOperatingSystemName "windows"
|
|
|
|
#else
|
|
|
|
#error Host operating system detection failed.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HOST_ARCH_ARM)
|
|
|
|
#define kHostArchitectureName "arm"
|
|
|
|
#elif defined(HOST_ARCH_ARM64)
|
|
|
|
#define kHostArchitectureName "arm64"
|
|
|
|
#elif defined(HOST_ARCH_IA32)
|
|
|
|
#define kHostArchitectureName "ia32"
|
|
|
|
#elif defined(HOST_ARCH_RISCV32)
|
|
|
|
#define kHostArchitectureName "riscv32"
|
|
|
|
#elif defined(HOST_ARCH_RISCV64)
|
|
|
|
#define kHostArchitectureName "riscv64"
|
|
|
|
#elif defined(HOST_ARCH_X64)
|
|
|
|
#define kHostArchitectureName "x64"
|
|
|
|
#else
|
|
|
|
#error Host architecture detection failed.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TARGET_ARCH_ARM)
|
|
|
|
#define kTargetArchitectureName "arm"
|
|
|
|
#elif defined(TARGET_ARCH_ARM64)
|
|
|
|
#define kTargetArchitectureName "arm64"
|
|
|
|
#elif defined(TARGET_ARCH_IA32)
|
|
|
|
#define kTargetArchitectureName "ia32"
|
|
|
|
#elif defined(TARGET_ARCH_RISCV32)
|
|
|
|
#define kTargetArchitectureName "riscv32"
|
|
|
|
#elif defined(TARGET_ARCH_RISCV64)
|
|
|
|
#define kTargetArchitectureName "riscv64"
|
|
|
|
#elif defined(TARGET_ARCH_X64)
|
|
|
|
#define kTargetArchitectureName "x64"
|
|
|
|
#else
|
|
|
|
#error Target architecture detection failed.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// The ordering between DART_TARGET_OS_MACOS_IOS and DART_TARGET_OS_MACOS
|
|
|
|
// below is important, since the latter is sometimes defined when the former
|
|
|
|
// is, and sometimes not (e.g., ffi tests), so we need to test the former
|
|
|
|
// before the latter.
|
|
|
|
#if defined(DART_TARGET_OS_ANDROID)
|
|
|
|
#define kTargetOperatingSystemName "android"
|
|
|
|
#elif defined(DART_TARGET_OS_FUCHSIA)
|
|
|
|
#define kTargetOperatingSystemName "fuchsia"
|
|
|
|
#elif defined(DART_TARGET_OS_LINUX)
|
|
|
|
#define kTargetOperatingSystemName "linux"
|
|
|
|
#elif defined(DART_TARGET_OS_MACOS_IOS)
|
|
|
|
#define kTargetOperatingSystemName "ios"
|
|
|
|
#elif defined(DART_TARGET_OS_MACOS)
|
|
|
|
#define kTargetOperatingSystemName "macos"
|
|
|
|
#elif defined(DART_TARGET_OS_WINDOWS)
|
|
|
|
#define kTargetOperatingSystemName "windows"
|
|
|
|
#else
|
|
|
|
#error Target operating system detection failed.
|
|
|
|
#endif
|
|
|
|
|
2015-04-27 14:46:32 +00:00
|
|
|
} // namespace dart
|
|
|
|
|
2016-10-26 07:26:03 +00:00
|
|
|
#endif // RUNTIME_PLATFORM_GLOBALS_H_
|