From 3fd6fa4ff76263d772fcff8b6326364b81497a95 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Wed, 24 Apr 2019 23:12:45 +0000 Subject: [PATCH] [vm] Fix errors compiling with GCC. Change-Id: Ia3127ba9ef4ee1faf1f85a6eaa0dafd0cf187b2b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99376 Reviewed-by: Aart Bik Reviewed-by: Martin Kustermann Reviewed-by: Samir Jindel Commit-Queue: Ryan Macnak --- runtime/bin/ffi_test_functions.cc | 7 ++++--- runtime/vm/catch_entry_moves_test.cc | 1 + runtime/vm/compiler/backend/il.h | 8 ++++---- runtime/vm/compiler/jit/compiler.cc | 2 +- runtime/vm/compiler/relocation.h | 4 +++- runtime/vm/constants_arm.cc | 12 ++++++++++++ runtime/vm/constants_arm.h | 13 ++----------- runtime/vm/constants_arm64.cc | 12 ++++++++++++ runtime/vm/constants_arm64.h | 13 ++----------- runtime/vm/constants_dbc.cc | 25 +++++++++++++++++++++++++ runtime/vm/constants_dbc.h | 16 ++-------------- runtime/vm/constants_ia32.cc | 6 ++++++ runtime/vm/constants_ia32.h | 7 ++----- runtime/vm/constants_x64.cc | 8 ++++++++ runtime/vm/constants_x64.h | 9 ++------- runtime/vm/instructions_arm64.cc | 7 +++---- runtime/vm/snapshot.cc | 2 +- runtime/vm/vm_sources.gni | 1 + 18 files changed, 91 insertions(+), 62 deletions(-) create mode 100644 runtime/vm/constants_dbc.cc diff --git a/runtime/bin/ffi_test_functions.cc b/runtime/bin/ffi_test_functions.cc index 1f07257a13e..f1c418ce72f 100644 --- a/runtime/bin/ffi_test_functions.cc +++ b/runtime/bin/ffi_test_functions.cc @@ -85,7 +85,7 @@ DART_EXPORT intptr_t TakeMinInt16(int16_t x) { } DART_EXPORT intptr_t TakeMinInt32(int32_t x) { - const int64_t expected = -(int32_t)0x80000000; + const int64_t expected = kMinInt32; const int64_t received = x; return expected == received ? 1 : 0; } @@ -467,7 +467,7 @@ DART_EXPORT double SmallDouble() { // truncated. DART_EXPORT void* LargePointer() { uint64_t origin = 0x8100000082000000; - return *reinterpret_cast(&origin); + return reinterpret_cast(origin); } // Allocates 'count'-many Mint boxes, to stress-test GC during an FFI call. @@ -504,7 +504,8 @@ DART_EXPORT void AllocateThroughDart(uint64_t count) { DART_EXPORT int RedirectStderr() { char filename[256]; snprintf(filename, sizeof(filename), "/tmp/captured_stderr_%d", getpid()); - freopen(filename, "w", stderr); + FILE* f = freopen(filename, "w", stderr); + ASSERT(f); printf("Got file %s\n", filename); return getpid(); } diff --git a/runtime/vm/catch_entry_moves_test.cc b/runtime/vm/catch_entry_moves_test.cc index faa41f6c82b..7ca32efd445 100644 --- a/runtime/vm/catch_entry_moves_test.cc +++ b/runtime/vm/catch_entry_moves_test.cc @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. #include +#include #include #include "platform/assert.h" diff --git a/runtime/vm/compiler/backend/il.h b/runtime/vm/compiler/backend/il.h index 429ae4579df..4c22692810f 100644 --- a/runtime/vm/compiler/backend/il.h +++ b/runtime/vm/compiler/backend/il.h @@ -7665,10 +7665,10 @@ class BitCastInstr : public TemplateDefinition<1, NoThrow, Pure> { from_representation_(from), to_representation_(to) { ASSERT(from != to); - ASSERT(to == kUnboxedInt32 && from == kUnboxedFloat || - to == kUnboxedFloat && from == kUnboxedInt32 || - to == kUnboxedInt64 && from == kUnboxedDouble || - to == kUnboxedDouble && from == kUnboxedInt64); + ASSERT((to == kUnboxedInt32 && from == kUnboxedFloat) || + (to == kUnboxedFloat && from == kUnboxedInt32) || + (to == kUnboxedInt64 && from == kUnboxedDouble) || + (to == kUnboxedDouble && from == kUnboxedInt64)); SetInputAt(0, value); } diff --git a/runtime/vm/compiler/jit/compiler.cc b/runtime/vm/compiler/jit/compiler.cc index fa80ccdf44c..d3343307d0d 100644 --- a/runtime/vm/compiler/jit/compiler.cc +++ b/runtime/vm/compiler/jit/compiler.cc @@ -785,7 +785,7 @@ RawCode* CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { static RawObject* CompileFunctionHelper(CompilationPipeline* pipeline, const Function& function, - bool optimized, + volatile bool optimized, intptr_t osr_id) { ASSERT(!FLAG_precompiled_mode); ASSERT(!optimized || function.WasCompiled() || function.ForceOptimize()); diff --git a/runtime/vm/compiler/relocation.h b/runtime/vm/compiler/relocation.h index 80ca95ae288..91ed48c5bfb 100644 --- a/runtime/vm/compiler/relocation.h +++ b/runtime/vm/compiler/relocation.h @@ -34,7 +34,9 @@ class UnresolvedCall : public IntrusiveDListEntry, offset_into_target(offset_into_target) {} UnresolvedCall(const UnresolvedCall& other) - : caller(other.caller), + : IntrusiveDListEntry(), + IntrusiveDListEntry(), + caller(other.caller), call_offset(other.call_offset), text_offset(other.text_offset), callee(other.callee), diff --git a/runtime/vm/constants_arm.cc b/runtime/vm/constants_arm.cc index 0934c487f33..308ce00addd 100644 --- a/runtime/vm/constants_arm.cc +++ b/runtime/vm/constants_arm.cc @@ -7,6 +7,18 @@ namespace arch_arm { +const char* cpu_reg_names[kNumberOfCpuRegisters] = { + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "ctx", "pp", "fp", "ip", "sp", "lr", "pc", +}; + +const char* fpu_reg_names[kNumberOfFpuRegisters] = { + "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", +#if defined(VFPv3_D32) + "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15", +#endif +}; + const Register CallingConventions::ArgumentRegisters[] = {R0, R1, R2, R3}; // Although 'kFpuArgumentRegisters' is 0, we have to give this array at least diff --git a/runtime/vm/constants_arm.h b/runtime/vm/constants_arm.h index afbcb92f549..ff89001ac33 100644 --- a/runtime/vm/constants_arm.h +++ b/runtime/vm/constants_arm.h @@ -265,17 +265,8 @@ const FpuRegister FpuTMP = QTMP; const int kNumberOfFpuRegisters = kNumberOfQRegisters; const FpuRegister kNoFpuRegister = kNoQRegister; -static const char* cpu_reg_names[kNumberOfCpuRegisters] = { - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", - "r8", "ctx", "pp", "fp", "ip", "sp", "lr", "pc", -}; - -static const char* fpu_reg_names[kNumberOfFpuRegisters] = { - "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", -#if defined(VFPv3_D32) - "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15", -#endif -}; +extern const char* cpu_reg_names[kNumberOfCpuRegisters]; +extern const char* fpu_reg_names[kNumberOfFpuRegisters]; // Register aliases. const Register TMP = IP; // Used as scratch register by assembler. diff --git a/runtime/vm/constants_arm64.cc b/runtime/vm/constants_arm64.cc index 9938d7c8369..95a52c0c06d 100644 --- a/runtime/vm/constants_arm64.cc +++ b/runtime/vm/constants_arm64.cc @@ -7,6 +7,18 @@ namespace arch_arm64 { +const char* cpu_reg_names[kNumberOfCpuRegisters] = { + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", + "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", "r21", + "r22", "r23", "r24", "ip0", "ip1", "pp", "ctx", "fp", "lr", "r31", +}; + +const char* fpu_reg_names[kNumberOfFpuRegisters] = { + "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", + "v11", "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21", + "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", +}; + const Register CallingConventions::ArgumentRegisters[] = { R0, R1, R2, R3, R4, R5, R6, R7, }; diff --git a/runtime/vm/constants_arm64.h b/runtime/vm/constants_arm64.h index 9f3355aadfb..b84d41183ab 100644 --- a/runtime/vm/constants_arm64.h +++ b/runtime/vm/constants_arm64.h @@ -108,17 +108,8 @@ const FpuRegister FpuTMP = VTMP; const int kNumberOfFpuRegisters = kNumberOfVRegisters; const FpuRegister kNoFpuRegister = kNoVRegister; -static const char* cpu_reg_names[kNumberOfCpuRegisters] = { - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", - "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", "r21", - "r22", "r23", "r24", "ip0", "ip1", "pp", "ctx", "fp", "lr", "r31", -}; - -static const char* fpu_reg_names[kNumberOfFpuRegisters] = { - "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", - "v11", "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21", - "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", -}; +extern const char* cpu_reg_names[kNumberOfCpuRegisters]; +extern const char* fpu_reg_names[kNumberOfFpuRegisters]; // Register aliases. const Register TMP = R16; // Used as scratch register by assembler. diff --git a/runtime/vm/constants_dbc.cc b/runtime/vm/constants_dbc.cc new file mode 100644 index 00000000000..abad6e509ee --- /dev/null +++ b/runtime/vm/constants_dbc.cc @@ -0,0 +1,25 @@ +// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file +// 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. + +#define RUNTIME_VM_CONSTANTS_H_ // To work around include guard. +#include "vm/constants_dbc.h" + +namespace dart { + +const char* cpu_reg_names[kNumberOfCpuRegisters] = { + "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", + "R11", "R12", "R13", "R14", "R15", "R16", "R17", "R18", "R19", "R20", "R21", + "R22", "R23", "R24", "R25", "R26", "R27", "R28", "R29", "R30", "R31", +#if defined(ARCH_IS_64_BIT) + "R32", "R33", "R34", "R35", "R36", "R37", "R38", "R39", "R40", "R41", "R42", + "R43", "R44", "R45", "R46", "R47", "R48", "R49", "R50", "R51", "R52", "R53", + "R54", "R55", "R56", "R57", "R58", "R59", "R60", "R61", "R62", "R63", +#endif +}; + +const char* fpu_reg_names[kNumberOfFpuRegisters] = { + "F0", +}; + +} // namespace dart diff --git a/runtime/vm/constants_dbc.h b/runtime/vm/constants_dbc.h index 71caa790baa..5241759b6b0 100644 --- a/runtime/vm/constants_dbc.h +++ b/runtime/vm/constants_dbc.h @@ -1129,20 +1129,8 @@ enum FpuRegister { const FpuRegister FpuTMP = kFakeFpuRegister; const intptr_t kNumberOfFpuRegisters = 1; -static const char* cpu_reg_names[kNumberOfCpuRegisters] = { - "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", - "R11", "R12", "R13", "R14", "R15", "R16", "R17", "R18", "R19", "R20", "R21", - "R22", "R23", "R24", "R25", "R26", "R27", "R28", "R29", "R30", "R31", -#if defined(ARCH_IS_64_BIT) - "R32", "R33", "R34", "R35", "R36", "R37", "R38", "R39", "R40", "R41", "R42", - "R43", "R44", "R45", "R46", "R47", "R48", "R49", "R50", "R51", "R52", "R53", - "R54", "R55", "R56", "R57", "R58", "R59", "R60", "R61", "R62", "R63", -#endif -}; - -static const char* fpu_reg_names[kNumberOfFpuRegisters] = { - "F0", -}; +extern const char* cpu_reg_names[kNumberOfCpuRegisters]; +extern const char* fpu_reg_names[kNumberOfFpuRegisters]; // After a comparison, the condition NEXT_IS_TRUE means the following // instruction is executed if the comparison is true and skipped over overwise. diff --git a/runtime/vm/constants_ia32.cc b/runtime/vm/constants_ia32.cc index a12af8216a9..7b9124a338a 100644 --- a/runtime/vm/constants_ia32.cc +++ b/runtime/vm/constants_ia32.cc @@ -7,6 +7,12 @@ namespace arch_ia32 { +const char* cpu_reg_names[kNumberOfCpuRegisters] = {"eax", "ecx", "edx", "ebx", + "esp", "ebp", "esi", "edi"}; + +const char* fpu_reg_names[kNumberOfXmmRegisters] = { + "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"}; + // Although 'kArgumentRegisters' and 'kFpuArgumentRegisters' are both 0, we have // to give these arrays at least one element to appease MSVC. diff --git a/runtime/vm/constants_ia32.h b/runtime/vm/constants_ia32.h index db963a75132..8e8c3046b0c 100644 --- a/runtime/vm/constants_ia32.h +++ b/runtime/vm/constants_ia32.h @@ -57,11 +57,8 @@ const FpuRegister FpuTMP = XMM7; const int kNumberOfFpuRegisters = kNumberOfXmmRegisters; const FpuRegister kNoFpuRegister = kNoXmmRegister; -static const char* cpu_reg_names[kNumberOfCpuRegisters] = { - "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"}; - -static const char* fpu_reg_names[kNumberOfXmmRegisters] = { - "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"}; +extern const char* cpu_reg_names[kNumberOfCpuRegisters]; +extern const char* fpu_reg_names[kNumberOfXmmRegisters]; // Register aliases. const Register TMP = kNoRegister; // No scratch register used by assembler. diff --git a/runtime/vm/constants_x64.cc b/runtime/vm/constants_x64.cc index 8d80a334f85..71b43d60a11 100644 --- a/runtime/vm/constants_x64.cc +++ b/runtime/vm/constants_x64.cc @@ -7,6 +7,14 @@ namespace arch_x64 { +const char* cpu_reg_names[kNumberOfCpuRegisters] = { + "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", + "r8", "r9", "r10", "r11", "r12", "r13", "thr", "pp"}; + +const char* fpu_reg_names[kNumberOfXmmRegisters] = { + "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", + "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15"}; + #if defined(_WIN64) const Register CallingConventions::ArgumentRegisters[] = { CallingConventions::kArg1Reg, CallingConventions::kArg2Reg, diff --git a/runtime/vm/constants_x64.h b/runtime/vm/constants_x64.h index 2ce343007bb..f6eb4618372 100644 --- a/runtime/vm/constants_x64.h +++ b/runtime/vm/constants_x64.h @@ -94,13 +94,8 @@ const FpuRegister FpuTMP = XMM15; const int kNumberOfFpuRegisters = kNumberOfXmmRegisters; const FpuRegister kNoFpuRegister = kNoXmmRegister; -static const char* cpu_reg_names[kNumberOfCpuRegisters] = { - "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", - "r8", "r9", "r10", "r11", "r12", "r13", "thr", "pp"}; - -static const char* fpu_reg_names[kNumberOfXmmRegisters] = { - "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", - "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15"}; +extern const char* cpu_reg_names[kNumberOfCpuRegisters]; +extern const char* fpu_reg_names[kNumberOfXmmRegisters]; enum RexBits { REX_NONE = 0, diff --git a/runtime/vm/instructions_arm64.cc b/runtime/vm/instructions_arm64.cc index e960937829a..cc29bcd4059 100644 --- a/runtime/vm/instructions_arm64.cc +++ b/runtime/vm/instructions_arm64.cc @@ -512,10 +512,9 @@ bool PcRelativeTrampolineJumpPattern::IsValid() const { const uint32_t adr_mask = (3 << 29) | (((1 << 19) - 1) << 5); const uint32_t movz_mask = 0xffff << 5; uint32_t* pattern = reinterpret_cast(pattern_start_); - return (pattern[0] & ~adr_mask) == kAdrEncoding & - (pattern[1] & ~movz_mask) == kMovzEncoding & - pattern[2] == kAddTmpTmp2 && - pattern[3] == kJumpEncoding; + return ((pattern[0] & ~adr_mask) == kAdrEncoding) && + ((pattern[1] & ~movz_mask) == kMovzEncoding) && + (pattern[2] == kAddTmpTmp2) && (pattern[3] == kJumpEncoding); #else UNREACHABLE(); return false; diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc index c676560d691..3ad29842765 100644 --- a/runtime/vm/snapshot.cc +++ b/runtime/vm/snapshot.cc @@ -1469,7 +1469,7 @@ Message* MessageWriter::WriteMessage(const Object& obj, // Setup for long jump in case there is an exception while writing // the message. - bool has_exception = false; + volatile bool has_exception = false; { LongJumpScope jump; if (setjmp(*jump.Set()) == 0) { diff --git a/runtime/vm/vm_sources.gni b/runtime/vm/vm_sources.gni index 63a0e1861ac..cc283ee4a64 100644 --- a/runtime/vm/vm_sources.gni +++ b/runtime/vm/vm_sources.gni @@ -46,6 +46,7 @@ vm_sources = [ "constants_arm.h", "constants_arm64.cc", "constants_arm64.h", + "constants_dbc.cc", "constants_dbc.h", "constants_ia32.cc", "constants_ia32.h",