Skip to content

Commit 0a238b3

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[vm] Update to C++20.
- There is no C20, so that stays at C17 - Math between different enum types disallowed, use explicit cast - operator++ removed from volatile types - stream print for wchar_t removed TEST=build Bug: #42074 Change-Id: Ie552b0bf24f8ac8991336c61fd4bd4913da42909 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393622 Commit-Queue: Ryan Macnak <[email protected]> Reviewed-by: Alexander Aprelev <[email protected]>
1 parent 01165df commit 0a238b3

File tree

15 files changed

+2990
-3564
lines changed

15 files changed

+2990
-3564
lines changed

build/config/compiler/BUILD.gn

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,10 @@ config("compiler") {
327327
cc_std = [
328328
# This option fixes the value of the __cplusplus macro when using MSVC.
329329
"/Zc:__cplusplus",
330-
"/std:c++17",
330+
"/std:c++20",
331331
]
332332
} else {
333-
cc_std = [ "-std=c++17" ]
333+
cc_std = [ "-std=c++20" ]
334334
}
335335
cflags_cc += cc_std
336336
cflags_objcc += cc_std
@@ -433,10 +433,10 @@ config("compiler") {
433433
config("cxx_version_default") {
434434
if (is_win) {
435435
cflags_c = [ "/std:c17" ]
436-
cc_std = [ "/std:c++17" ]
436+
cc_std = [ "/std:c++20" ]
437437
} else {
438438
cflags_c = [ "-std=c17" ]
439-
cc_std = [ "-std=c++17" ]
439+
cc_std = [ "-std=c++20" ]
440440
}
441441
cflags_cc = cc_std
442442
cflags_objcc = cc_std
@@ -480,10 +480,10 @@ config("cxx_version_17") {
480480

481481
config("cxx_version_20") {
482482
if (is_win) {
483-
cflags_c = [ "/std:c20" ]
483+
cflags_c = [ "/std:c17" ]
484484
cc_std = [ "/std:c++20" ]
485485
} else {
486-
cflags_c = [ "-std=c20" ]
486+
cflags_c = [ "-std=c17" ]
487487
cc_std = [ "-std=c++20" ]
488488
}
489489
cflags_cc = cc_std

runtime/bin/ffi_test/ffi_test_functions_generated.cc

Lines changed: 2892 additions & 3467 deletions
Large diffs are not rendered by default.

runtime/tools/run_clang_tidy.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ List<String> compilerFlagsForFile(String filepath) {
5252
'-Iout/DebugX64/gen/third_party/perfetto/build_config',
5353
'-DTARGET_ARCH_$arch',
5454
'-DTESTING',
55-
'-std=c++17',
55+
'-std=c++20',
5656
'-x',
5757
'c++',
5858
];

runtime/vm/compiler/aot/precompiler.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3663,7 +3663,7 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
36633663
// assembler. We try again (done = false) with far branches enabled.
36643664
done = false;
36653665
RELEASE_ASSERT(far_branch_level < 2);
3666-
far_branch_level++;
3666+
far_branch_level = far_branch_level + 1;
36673667
} else if (error.ptr() == Object::speculative_inlining_error().ptr()) {
36683668
// The return value of setjmp is the deopt id of the check instruction
36693669
// that caused the bailout.

runtime/vm/compiler/assembler/assembler_arm.h

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -59,48 +59,47 @@ class Immediate : public ValueObject {
5959
};
6060

6161
// Instruction encoding bits.
62-
enum {
63-
H = 1 << 5, // halfword (or byte)
64-
L = 1 << 20, // load (or store)
65-
S = 1 << 20, // set condition code (or leave unchanged)
66-
W = 1 << 21, // writeback base register (or leave unchanged)
67-
A = 1 << 21, // accumulate in multiply instruction (or not)
68-
B = 1 << 22, // unsigned byte (or word)
69-
D = 1 << 22, // high/lo bit of start of s/d register range
70-
N = 1 << 22, // long (or short)
71-
U = 1 << 23, // positive (or negative) offset/index
72-
P = 1 << 24, // offset/pre-indexed addressing (or post-indexed addressing)
73-
I = 1 << 25, // immediate shifter operand (or not)
74-
75-
B0 = 1,
76-
B1 = 1 << 1,
77-
B2 = 1 << 2,
78-
B3 = 1 << 3,
79-
B4 = 1 << 4,
80-
B5 = 1 << 5,
81-
B6 = 1 << 6,
82-
B7 = 1 << 7,
83-
B8 = 1 << 8,
84-
B9 = 1 << 9,
85-
B10 = 1 << 10,
86-
B11 = 1 << 11,
87-
B12 = 1 << 12,
88-
B13 = 1 << 13,
89-
B14 = 1 << 14,
90-
B15 = 1 << 15,
91-
B16 = 1 << 16,
92-
B17 = 1 << 17,
93-
B18 = 1 << 18,
94-
B19 = 1 << 19,
95-
B20 = 1 << 20,
96-
B21 = 1 << 21,
97-
B22 = 1 << 22,
98-
B23 = 1 << 23,
99-
B24 = 1 << 24,
100-
B25 = 1 << 25,
101-
B26 = 1 << 26,
102-
B27 = 1 << 27,
103-
};
62+
constexpr int32_t H = 1 << 5; // halfword (or byte)
63+
constexpr int32_t L = 1 << 20; // load (or store)
64+
constexpr int32_t S = 1 << 20; // set condition code (or leave unchanged)
65+
constexpr int32_t W = 1 << 21; // writeback base register (or leave unchanged)
66+
constexpr int32_t A = 1 << 21; // accumulate in multiply instruction (or not)
67+
constexpr int32_t B = 1 << 22; // unsigned byte (or word)
68+
constexpr int32_t D = 1 << 22; // high/lo bit of start of s/d register range
69+
constexpr int32_t N = 1 << 22; // long (or short)
70+
constexpr int32_t U = 1 << 23; // positive (or negative) offset/index
71+
constexpr int32_t P = 1 << 24; // offset/pre-indexed addressing
72+
// (or post-indexed addressing)
73+
constexpr int32_t I = 1 << 25; // immediate shifter operand (or not)
74+
75+
constexpr int32_t B0 = 1;
76+
constexpr int32_t B1 = 1 << 1;
77+
constexpr int32_t B2 = 1 << 2;
78+
constexpr int32_t B3 = 1 << 3;
79+
constexpr int32_t B4 = 1 << 4;
80+
constexpr int32_t B5 = 1 << 5;
81+
constexpr int32_t B6 = 1 << 6;
82+
constexpr int32_t B7 = 1 << 7;
83+
constexpr int32_t B8 = 1 << 8;
84+
constexpr int32_t B9 = 1 << 9;
85+
constexpr int32_t B10 = 1 << 10;
86+
constexpr int32_t B11 = 1 << 11;
87+
constexpr int32_t B12 = 1 << 12;
88+
constexpr int32_t B13 = 1 << 13;
89+
constexpr int32_t B14 = 1 << 14;
90+
constexpr int32_t B15 = 1 << 15;
91+
constexpr int32_t B16 = 1 << 16;
92+
constexpr int32_t B17 = 1 << 17;
93+
constexpr int32_t B18 = 1 << 18;
94+
constexpr int32_t B19 = 1 << 19;
95+
constexpr int32_t B20 = 1 << 20;
96+
constexpr int32_t B21 = 1 << 21;
97+
constexpr int32_t B22 = 1 << 22;
98+
constexpr int32_t B23 = 1 << 23;
99+
constexpr int32_t B24 = 1 << 24;
100+
constexpr int32_t B25 = 1 << 25;
101+
constexpr int32_t B26 = 1 << 26;
102+
constexpr int32_t B27 = 1 << 27;
104103

105104
class ArmEncode : public AllStatic {
106105
public:

runtime/vm/compiler/backend/code_statistics.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class CombinedCodeStatistics {
4747

4848
static EntryCounter SlowPathCounterFor(Instruction::Tag tag) {
4949
return static_cast<CombinedCodeStatistics::EntryCounter>(
50-
CombinedCodeStatistics::kTagGraphEntrySlowPath + tag);
50+
static_cast<uint32_t>(CombinedCodeStatistics::kTagGraphEntrySlowPath) +
51+
static_cast<uint32_t>(tag));
5152
}
5253

5354
private:

runtime/vm/compiler/jit/compiler.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ CodePtr CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
653653
// assembler. We try again (done = false) with far branches enabled.
654654
done = false;
655655
RELEASE_ASSERT(far_branch_level < 2);
656-
far_branch_level++;
656+
far_branch_level += 1;
657657
} else if (error.ptr() == Object::speculative_inlining_error().ptr()) {
658658
// Can only happen with precompilation.
659659
UNREACHABLE();
@@ -681,14 +681,13 @@ CodePtr CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
681681

682682
static ObjectPtr CompileFunctionHelper(CompilationPipeline* pipeline,
683683
const Function& function,
684-
volatile bool optimized,
684+
bool optimized,
685685
intptr_t osr_id) {
686686
Thread* const thread = Thread::Current();
687687
NoActiveIsolateScope no_active_isolate(thread);
688688

689689
ASSERT(!FLAG_precompiled_mode);
690690
ASSERT(!optimized || function.WasCompiled() || function.ForceOptimize());
691-
if (function.ForceOptimize()) optimized = true;
692691
LongJumpScope jump;
693692
if (setjmp(*jump.Set()) == 0) {
694693
StackZone stack_zone(thread);
@@ -863,9 +862,9 @@ ErrorPtr Compiler::EnsureUnoptimizedCode(Thread* thread,
863862
}
864863
CompilationPipeline* pipeline =
865864
CompilationPipeline::New(thread->zone(), function);
865+
const bool optimized = function.ForceOptimize();
866866
const Object& result = Object::Handle(
867-
CompileFunctionHelper(pipeline, function, false, /* not optimized */
868-
kNoOSRDeoptId));
867+
CompileFunctionHelper(pipeline, function, optimized, kNoOSRDeoptId));
869868
if (result.IsError()) {
870869
return Error::Cast(result).ptr();
871870
}

runtime/vm/constants_arm64.h

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -690,40 +690,38 @@ static inline Condition InvertCondition(Condition c) {
690690
return static_cast<Condition>(c ^ 1);
691691
}
692692

693-
enum Bits {
694-
B0 = (1 << 0),
695-
B1 = (1 << 1),
696-
B2 = (1 << 2),
697-
B3 = (1 << 3),
698-
B4 = (1 << 4),
699-
B5 = (1 << 5),
700-
B6 = (1 << 6),
701-
B7 = (1 << 7),
702-
B8 = (1 << 8),
703-
B9 = (1 << 9),
704-
B10 = (1 << 10),
705-
B11 = (1 << 11),
706-
B12 = (1 << 12),
707-
B13 = (1 << 13),
708-
B14 = (1 << 14),
709-
B15 = (1 << 15),
710-
B16 = (1 << 16),
711-
B17 = (1 << 17),
712-
B18 = (1 << 18),
713-
B19 = (1 << 19),
714-
B20 = (1 << 20),
715-
B21 = (1 << 21),
716-
B22 = (1 << 22),
717-
B23 = (1 << 23),
718-
B24 = (1 << 24),
719-
B25 = (1 << 25),
720-
B26 = (1 << 26),
721-
B27 = (1 << 27),
722-
B28 = (1 << 28),
723-
B29 = (1 << 29),
724-
B30 = (1 << 30),
725-
B31 = (1 << 31),
726-
};
693+
constexpr int32_t B0 = (1 << 0);
694+
constexpr int32_t B1 = (1 << 1);
695+
constexpr int32_t B2 = (1 << 2);
696+
constexpr int32_t B3 = (1 << 3);
697+
constexpr int32_t B4 = (1 << 4);
698+
constexpr int32_t B5 = (1 << 5);
699+
constexpr int32_t B6 = (1 << 6);
700+
constexpr int32_t B7 = (1 << 7);
701+
constexpr int32_t B8 = (1 << 8);
702+
constexpr int32_t B9 = (1 << 9);
703+
constexpr int32_t B10 = (1 << 10);
704+
constexpr int32_t B11 = (1 << 11);
705+
constexpr int32_t B12 = (1 << 12);
706+
constexpr int32_t B13 = (1 << 13);
707+
constexpr int32_t B14 = (1 << 14);
708+
constexpr int32_t B15 = (1 << 15);
709+
constexpr int32_t B16 = (1 << 16);
710+
constexpr int32_t B17 = (1 << 17);
711+
constexpr int32_t B18 = (1 << 18);
712+
constexpr int32_t B19 = (1 << 19);
713+
constexpr int32_t B20 = (1 << 20);
714+
constexpr int32_t B21 = (1 << 21);
715+
constexpr int32_t B22 = (1 << 22);
716+
constexpr int32_t B23 = (1 << 23);
717+
constexpr int32_t B24 = (1 << 24);
718+
constexpr int32_t B25 = (1 << 25);
719+
constexpr int32_t B26 = (1 << 26);
720+
constexpr int32_t B27 = (1 << 27);
721+
constexpr int32_t B28 = (1 << 28);
722+
constexpr int32_t B29 = (1 << 29);
723+
constexpr int32_t B30 = (1 << 30);
724+
constexpr int32_t B31 = (1 << 31);
727725

728726
// Opcodes from C3
729727
// C3.1.

runtime/vm/object.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,8 @@ void Object::Init(IsolateGroup* isolate_group) {
10391039
// at the start of the first entry.
10401040
{
10411041
const intptr_t array_size =
1042-
TypeArguments::Cache::kHeaderSize + TypeArguments::Cache::kEntrySize;
1042+
static_cast<intptr_t>(TypeArguments::Cache::kHeaderSize) +
1043+
static_cast<intptr_t>(TypeArguments::Cache::kEntrySize);
10431044
uword address =
10441045
heap->Allocate(thread, Array::InstanceSize(array_size), Heap::kOld);
10451046
InitializeObjectVariant<Array>(address, kImmutableArrayCid, array_size);

runtime/vm/object_graph.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,8 @@ void HeapSnapshotWriter::Write() {
17131713

17141714
// Smis.
17151715
for (SmiPtr smi : smis_) {
1716-
WriteUnsigned(kSmiCid + kNumExtraCids);
1716+
WriteUnsigned(static_cast<intptr_t>(kSmiCid) +
1717+
static_cast<intptr_t>(kNumExtraCids));
17171718
WriteUnsigned(0); // Heap size.
17181719
WriteUnsigned(kIntData);
17191720
WriteUnsigned(Smi::Value(smi));

0 commit comments

Comments
 (0)