[vm] Fix gcc build.

Change-Id: I6634dc10fdc8d7523562c0fcc20e3561eb580acf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146023
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Ryan Macnak 2020-05-04 21:15:27 +00:00 committed by commit-bot@chromium.org
parent 767e78cb4d
commit 14dfa1b9ee
19 changed files with 62 additions and 52 deletions

View file

@ -538,6 +538,9 @@ if (is_win) {
if (is_clang) {
default_warning_flags += [ "-Wno-tautological-constant-compare" ]
} else {
default_warning_flags +=
[ "-Wno-ignored-qualifiers" ] # Warnings in BoringSSL headers
}
if (is_mac) {

View file

@ -453,7 +453,7 @@ bool AsyncDirectoryListing::AddFileSystemEntityToResponse(Response type,
size_t len = strlen(arg);
Dart_CObject* io_buffer = CObject::NewIOBuffer(len);
uint8_t* data = io_buffer->value.as_external_typed_data.data;
strncpy(reinterpret_cast<char*>(data), arg, len);
memmove(reinterpret_cast<char*>(data), arg, len);
CObjectExternalUint8Array* external_array =
new CObjectExternalUint8Array(io_buffer);

View file

@ -613,9 +613,8 @@ static inline void USE(T) {}
// type to another thus avoiding the warning.
template <class D, class S>
inline D bit_cast(const S& source) {
// Compile time assertion: sizeof(D) == sizeof(S). A compile error
// here means your D and S have different sizes.
DART_UNUSED typedef char VerifySizesAreEqual[sizeof(D) == sizeof(S) ? 1 : -1];
static_assert(sizeof(D) == sizeof(S),
"Source and destination must have the same size");
D destination;
// This use of memcpy is safe: source and destination cannot overlap.

View file

@ -178,7 +178,7 @@ namespace dart {
V(Object) \
CLASS_LIST_NO_OBJECT(V)
enum ClassId {
enum ClassId : intptr_t {
// Illegal class id.
kIllegalCid = 0,

View file

@ -121,11 +121,10 @@ void SerializationCluster::WriteAndMeasureAlloc(Serializer* serializer) {
intptr_t stop_data = serializer->GetDataSize();
intptr_t stop_objects = serializer->next_ref_index();
if (FLAG_print_cluster_information) {
const int hex_size = kWordSize * 2;
OS::PrintErr("Snapshot 0x%0*.*" Px " (%" Pd "), ", hex_size, hex_size,
start_size, stop_size - start_size);
OS::PrintErr("Data 0x%0*.*" Px " (%" Pd "): ", hex_size, hex_size,
start_data, stop_data - start_data);
OS::PrintErr("Snapshot 0x%" Pp " (%" Pd "), ", start_size,
stop_size - start_size);
OS::PrintErr("Data 0x%" Pp " (%" Pd "): ", start_data,
stop_data - start_data);
OS::PrintErr("Alloc %s (%" Pd ")\n", name(), stop_objects - start_objects);
}
size_ += (stop_size - start_size) + (stop_data - start_data);
@ -137,9 +136,8 @@ void SerializationCluster::WriteAndMeasureFill(Serializer* serializer) {
WriteFill(serializer);
intptr_t stop = serializer->bytes_written();
if (FLAG_print_cluster_information) {
const int hex_size = kWordSize * 2;
OS::PrintErr("Snapshot 0x%0*.*" Px " (%" Pd "): Fill %s\n", hex_size,
hex_size, start, stop - start, name());
OS::PrintErr("Snapshot 0x%" Pp " (%" Pd "): Fill %s\n", start, stop - start,
name());
}
size_ += (stop - start);
}

View file

@ -2551,7 +2551,8 @@ ASSEMBLER_TEST_GENERATE(LoadObjectNull, assembler) {
}
ASSEMBLER_TEST_RUN(LoadObjectNull, test) {
EXPECT_EQ(Object::null(), test->InvokeWithCodeAndThread<ObjectPtr>());
EXPECT_EQ(static_cast<uword>(Object::null()),
test->InvokeWithCodeAndThread<uword>());
}
// PushObject null.
@ -2566,7 +2567,8 @@ ASSEMBLER_TEST_GENERATE(PushObjectNull, assembler) {
}
ASSEMBLER_TEST_RUN(PushObjectNull, test) {
EXPECT_EQ(Object::null(), test->InvokeWithCodeAndThread<ObjectPtr>());
EXPECT_EQ(static_cast<uword>(Object::null()),
test->InvokeWithCodeAndThread<uword>());
}
// CompareObject null.
@ -2584,7 +2586,8 @@ ASSEMBLER_TEST_GENERATE(CompareObjectNull, assembler) {
}
ASSEMBLER_TEST_RUN(CompareObjectNull, test) {
EXPECT_EQ(Bool::True().raw(), test->InvokeWithCodeAndThread<ObjectPtr>());
EXPECT_EQ(static_cast<uword>(Bool::True().raw()),
test->InvokeWithCodeAndThread<uword>());
}
ASSEMBLER_TEST_GENERATE(LoadObjectTrue, assembler) {
@ -2597,7 +2600,8 @@ ASSEMBLER_TEST_GENERATE(LoadObjectTrue, assembler) {
}
ASSEMBLER_TEST_RUN(LoadObjectTrue, test) {
EXPECT_EQ(Bool::True().raw(), test->InvokeWithCodeAndThread<ObjectPtr>());
EXPECT_EQ(static_cast<uword>(Bool::True().raw()),
test->InvokeWithCodeAndThread<uword>());
}
ASSEMBLER_TEST_GENERATE(LoadObjectFalse, assembler) {
@ -2610,7 +2614,8 @@ ASSEMBLER_TEST_GENERATE(LoadObjectFalse, assembler) {
}
ASSEMBLER_TEST_RUN(LoadObjectFalse, test) {
EXPECT_EQ(Bool::False().raw(), test->InvokeWithCodeAndThread<ObjectPtr>());
EXPECT_EQ(static_cast<uword>(Bool::False().raw()),
test->InvokeWithCodeAndThread<uword>());
}
ASSEMBLER_TEST_GENERATE(CSelTrue, assembler) {

View file

@ -3726,15 +3726,7 @@ class TemplateDartCall : public Definition {
}
}
StringPtr Selector() {
if (auto static_call = this->AsStaticCall()) {
return static_call->function().name();
} else if (auto instance_call = this->AsInstanceCall()) {
return instance_call->function_name().raw();
} else {
UNREACHABLE();
}
}
inline StringPtr Selector();
virtual bool MayThrow() const { return true; }
virtual bool CanCallDart() const { return true; }
@ -9196,6 +9188,17 @@ class FlowGraphVisitor : public ValueObject {
} \
void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); }
template <intptr_t kExtraInputs>
StringPtr TemplateDartCall<kExtraInputs>::Selector() {
if (auto static_call = this->AsStaticCall()) {
return static_call->function().name();
} else if (auto instance_call = this->AsInstanceCall()) {
return instance_call->function_name().raw();
} else {
UNREACHABLE();
}
}
} // namespace dart
#endif // RUNTIME_VM_COMPILER_BACKEND_IL_H_

View file

@ -131,6 +131,7 @@ class ArgumentAllocator : public ValueObject {
}
Register AllocateCpuRegister() {
RELEASE_ASSERT(cpu_regs_used >= 0); // Avoids -Werror=array-bounds in GCC.
ASSERT(cpu_regs_used < CallingConventions::kNumArgRegs);
const auto result = CallingConventions::ArgumentRegisters[cpu_regs_used];

View file

@ -305,6 +305,7 @@ DRegister NativeFpuRegistersLocation::fpu_as_d_reg() const {
case kSingleFpuReg:
return DRegisterOf(fpu_s_reg());
}
UNREACHABLE();
}
SRegister NativeFpuRegistersLocation::fpu_as_s_reg() const {
@ -316,6 +317,7 @@ SRegister NativeFpuRegistersLocation::fpu_as_s_reg() const {
case kSingleFpuReg:
return fpu_s_reg();
}
UNREACHABLE();
}
bool NativeFpuRegistersLocation::IsLowestBits() const {

View file

@ -103,8 +103,9 @@ intptr_t NativeFundamentalType::AlignmentInBytesStack() const {
case kAlignedToValueSize:
// iOS on arm64 only aligns to size.
return SizeInBytes();
default:
UNREACHABLE();
}
UNREACHABLE();
}
intptr_t NativeFundamentalType::AlignmentInBytesField() const {
@ -120,8 +121,9 @@ intptr_t NativeFundamentalType::AlignmentInBytesField() const {
}
return SizeInBytes();
}
default:
UNREACHABLE();
}
UNREACHABLE();
}
#if !defined(DART_PRECOMPILED_RUNTIME)

View file

@ -375,7 +375,7 @@ static uword GetInstanceSizeImpl(const dart::Class& handle) {
}
}
FATAL3("Unsupported class for size translation: %s (id=%" Pd
", kNumPredefinedCids=%d)\n",
", kNumPredefinedCids=%" Pd ")\n",
handle.ToCString(), handle.id(), kNumPredefinedCids);
return -1;
}

View file

@ -3373,6 +3373,7 @@ TEST_CASE(DartAPI_WeakPersistentHandleExternalAllocationSize) {
weak2 = Dart_NewWeakPersistentHandle(obj, NULL, kWeak2ExternalSize,
NopCallback);
EXPECT_VALID(AsHandle(strong_ref));
EXPECT_VALID(AsHandle(weak2));
Dart_ExitScope();
}
{

View file

@ -82,12 +82,18 @@ void FieldTable::AllocateIndex(intptr_t index) {
void FieldTable::Grow(intptr_t new_capacity) {
ASSERT(new_capacity > capacity_);
auto old_table = table_;
auto new_table = static_cast<InstancePtr*>(
malloc(new_capacity * sizeof(InstancePtr))); // NOLINT
memmove(new_table, table_, top_ * sizeof(InstancePtr));
memset(new_table + top_, 0, (new_capacity - top_) * sizeof(InstancePtr));
intptr_t i;
for (i = 0; i < top_; i++) {
new_table[i] = old_table[i];
}
for (; i < new_capacity; i++) {
new_table[i] = InstancePtr();
}
capacity_ = new_capacity;
old_tables_->Add(table_);
old_tables_->Add(old_table);
// Ensure that new_table_ is populated before it is published
// via store to table_.
std::atomic_thread_fence(std::memory_order_release);

View file

@ -26,13 +26,6 @@ VM_UNIT_TEST_CASE(SNPrint) {
EXPECT_EQ(3, length);
}
// This test is expected to crash when it runs.
VM_UNIT_TEST_CASE_WITH_EXPECTATION(SNPrint_BadArgs, "Crash") {
int width = kMaxInt32;
int num = 7;
Utils::SNPrint(NULL, 0, "%*d%*d", width, num, width, num);
}
VM_UNIT_TEST_CASE(OsFuncs) {
EXPECT(Utils::IsPowerOfTwo(OS::ActivationFrameAlignment()));
int procs = OS::NumberOfAvailableProcessors();

View file

@ -1132,12 +1132,13 @@ void Profiler::DumpStackTrace(uword sp, uword fp, uword pc, bool for_crash) {
}
}
OS::PrintErr("version=%s\n", Version::String());
OSThread* os_thread = OSThread::Current();
ASSERT(os_thread != NULL);
Isolate* isolate = Isolate::Current();
const char* name = isolate == NULL ? NULL : isolate->name();
OS::PrintErr("version=%s\npid=%" Pd ", thread=%" Pd ", isolate=%s(%p)\n",
Version::String(), OS::ProcessId(),
const char* name = isolate == NULL ? "(nil)" : isolate->name();
OS::PrintErr("pid=%" Pd ", thread=%" Pd ", isolate=%s(%p)\n",
static_cast<intptr_t>(OS::ProcessId()),
OSThread::ThreadIdToIntPtr(os_thread->trace_id()), name,
isolate);
const IsolateGroupSource* source =

View file

@ -345,10 +345,9 @@ void ProfileCode::SetName(const char* name) {
if (name == NULL) {
name_ = NULL;
}
intptr_t len = strlen(name);
name_ = Thread::Current()->zone()->Alloc<char>(len + 1);
intptr_t len = strlen(name) + 1;
name_ = Thread::Current()->zone()->Alloc<char>(len);
strncpy(name_, name, len);
name_[len] = '\0';
}
void ProfileCode::GenerateAndSetSymbolName(const char* prefix) {

View file

@ -259,7 +259,7 @@ const Snapshot* Snapshot::SetupFromBuffer(const void* raw_memory) {
}
SmiPtr BaseReader::ReadAsSmi() {
SmiPtr value = Read<SmiPtr>();
SmiPtr value = static_cast<SmiPtr>(Read<intptr_t>());
ASSERT((static_cast<uword>(value) & kSmiTagMask) == kSmiTag);
return value;
}

View file

@ -369,10 +369,7 @@ static const char* MergePaths(const char* base_path, const char* ref_path) {
buffer[truncated_base_len] = '/';
// Copy the ref_path.
strncpy((buffer + truncated_base_len + 1), ref_path, ref_path_len);
// Add the trailing '\0'.
buffer[len] = '\0';
strncpy((buffer + truncated_base_len + 1), ref_path, ref_path_len + 1);
return buffer;
}

View file

@ -53,7 +53,7 @@ void V8SnapshotProfileWriter::SetObjectTypeAndName(ObjectId object_id,
info->name = EnsureString(name);
} else {
info->name =
EnsureString(OS::SCreate(zone_, "Unnamed [%s] %s", type, name));
EnsureString(OS::SCreate(zone_, "Unnamed [%s] %s", type, "(nil)"));
}
}