[vm] Fix warnings in GCC 9.3.0 and XCode 12.0.

Bug: https://github.com/flutter/flutter/issues/66203
Change-Id: Ifff0c211e2ecdcb56d62c273a471fc05bbae9c37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161602
Reviewed-by: Chinmay Garde <chinmaygarde@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak
2020-09-21 22:02:32 +00:00
committed by commit-bot@chromium.org
parent 5a4402ac30
commit 30897929fc
11 changed files with 29 additions and 43 deletions
+3 -2
View File
@@ -487,7 +487,6 @@ int Options::ParseArguments(int argc,
bool implicitly_use_dart_dev = false;
bool run_script = false;
int script_or_cmd_index = -1;
// Get the script name.
if (i < argc) {
@@ -500,7 +499,6 @@ int Options::ParseArguments(int argc,
#else
bool is_potential_file_path = true;
#endif // !defined(DART_PRECOMPILED_RUNTIME)
script_or_cmd_index = i;
if (Options::disable_dart_dev() ||
(is_potential_file_path && !enable_vm_service_)) {
*script_name = Utils::StrDup(argv[i]);
@@ -549,6 +547,9 @@ int Options::ParseArguments(int argc,
else { // NOLINT
return -1;
}
USE(enable_dartdev_analytics);
USE(disable_dartdev_analytics);
const char** vm_argv = temp_vm_options.arguments();
int vm_argc = temp_vm_options.count();
+3 -3
View File
@@ -79,9 +79,9 @@ enum SnapshotKind {
kAppJIT,
};
static const char* DEFAULT_VM_SERVICE_SERVER_IP = "localhost";
static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181;
static const int INVALID_VM_SERVICE_SERVER_PORT = -1;
static constexpr const char* DEFAULT_VM_SERVICE_SERVER_IP = "localhost";
static constexpr int DEFAULT_VM_SERVICE_SERVER_PORT = 8181;
static constexpr int INVALID_VM_SERVICE_SERVER_PORT = -1;
class Options {
public:
+1 -1
View File
@@ -16,7 +16,7 @@ DART_API_ALL_DL_SYMBOLS(DART_API_DL_DEFINITIONS)
#undef DART_API_DL_DEFINITIONS
typedef void (*DartApiEntry_function)();
typedef void* DartApiEntry_function;
DartApiEntry_function FindFunctionPointer(const DartApiEntry* entries,
const char* name) {
+3 -3
View File
@@ -2206,14 +2206,14 @@ class WeakSerializationReferenceSerializationCluster
s->WriteUnsigned(WrittenCount());
// Set up references for those objects that will be written.
for (auto const ref : canonical_wsrs_) {
for (auto const& ref : canonical_wsrs_) {
s->AssignRef(ref);
}
// In precompiled mode, set the object ID of each non-canonical WSR to
// its canonical counterpart's object ID. This ensures that any reference to
// it is serialized as a reference to the canonicalized one.
for (auto const ref : objects_) {
for (auto const& ref : objects_) {
ASSERT(IsReachableReference(heap_->GetObjectId(ref)));
if (ShouldDrop(ref)) {
// For dropped references, reset their ID to be the unreachable
@@ -2238,7 +2238,7 @@ class WeakSerializationReferenceSerializationCluster
void WriteFill(Serializer* s) {
ASSERT(s->kind() == Snapshot::kFullAOT);
for (auto const ref : canonical_wsrs_) {
for (auto const& ref : canonical_wsrs_) {
AutoTraceObject(ref);
// In precompiled mode, we drop the reference to the target and only
@@ -1826,13 +1826,13 @@ void LoadingUnitsMetadataHelper::ReadMetadata(intptr_t node_offset) {
AlternativeReadingScopeWithNewData alt(&helper_->reader_,
&H.metadata_payloads(), md_offset);
Thread* T = Thread::Current();
Zone* Z = T->zone();
Thread* thread = Thread::Current();
Zone* zone = thread->zone();
intptr_t unit_count = helper_->ReadUInt();
Array& loading_units = Array::Handle(Z, Array::New(unit_count + 1));
LoadingUnit& unit = LoadingUnit::Handle(Z);
LoadingUnit& parent = LoadingUnit::Handle(Z);
Library& lib = Library::Handle(Z);
Array& loading_units = Array::Handle(zone, Array::New(unit_count + 1));
LoadingUnit& unit = LoadingUnit::Handle(zone);
LoadingUnit& parent = LoadingUnit::Handle(zone);
Library& lib = Library::Handle(zone);
for (int i = 0; i < unit_count; i++) {
intptr_t id = helper_->ReadUInt();
@@ -1849,7 +1849,7 @@ void LoadingUnitsMetadataHelper::ReadMetadata(intptr_t node_offset) {
for (intptr_t j = 0; j < library_count; j++) {
const String& uri =
translation_helper_.DartSymbolPlain(helper_->ReadStringReference());
lib = Library::LookupLibrary(T, uri);
lib = Library::LookupLibrary(thread, uri);
if (lib.IsNull()) {
FATAL1("Missing library: %s\n", uri.ToCString());
}
@@ -148,8 +148,8 @@ ScopeBuildingResult* ScopeBuilder::BuildScopes() {
(parent.num_fixed_parameters() != target.num_fixed_parameters())) {
needs_expr_temp_ = true;
}
FALL_THROUGH;
}
FALL_THROUGH;
case FunctionLayout::kClosureFunction:
case FunctionLayout::kRegularFunction:
case FunctionLayout::kGetterFunction:
@@ -442,8 +442,8 @@ ScopeBuildingResult* ScopeBuilder::BuildScopes() {
FOR_EACH_DYNAMIC_CLOSURE_CALL_VARIABLE(ADD_VAR);
#undef ADD_VAR
}
FALL_THROUGH;
}
FALL_THROUGH;
case FunctionLayout::kNoSuchMethodDispatcher: {
for (intptr_t i = 0; i < function.NumParameters(); ++i) {
LocalVariable* variable = MakeVariable(
+5 -15
View File
@@ -3528,14 +3528,12 @@ static void FinalizableHandlePeerFinalizer(void* isolate_callback_data,
}
TEST_CASE(DartAPI_FinalizableHandleCallback) {
Dart_FinalizableHandle weak_ref = nullptr;
int peer = 0;
{
Dart_EnterScope();
Dart_Handle obj = NewString("new string");
EXPECT_VALID(obj);
weak_ref = Dart_NewFinalizableHandle(obj, &peer, 0,
FinalizableHandlePeerFinalizer);
Dart_NewFinalizableHandle(obj, &peer, 0, FinalizableHandlePeerFinalizer);
EXPECT(peer == 0);
Dart_ExitScope();
}
@@ -3676,26 +3674,22 @@ TEST_CASE(DartAPI_FinalizableHandleExternalAllocationSize) {
Heap* heap = Isolate::Current()->heap();
EXPECT(heap->ExternalInWords(Heap::kNew) == 0);
EXPECT(heap->ExternalInWords(Heap::kOld) == 0);
Dart_FinalizableHandle weak1 = nullptr;
static const intptr_t kWeak1ExternalSize = 1 * KB;
{
Dart_EnterScope();
Dart_Handle obj = NewString("weakly referenced string");
EXPECT_VALID(obj);
weak1 = Dart_NewFinalizableHandle(obj, nullptr, kWeak1ExternalSize,
NopCallback);
Dart_NewFinalizableHandle(obj, nullptr, kWeak1ExternalSize, NopCallback);
Dart_ExitScope();
}
Dart_PersistentHandle strong_ref = nullptr;
Dart_FinalizableHandle weak2 = nullptr;
static const intptr_t kWeak2ExternalSize = 2 * KB;
{
Dart_EnterScope();
Dart_Handle obj = NewString("strongly referenced string");
EXPECT_VALID(obj);
strong_ref = Dart_NewPersistentHandle(obj);
weak2 = Dart_NewFinalizableHandle(obj, nullptr, kWeak2ExternalSize,
NopCallback);
Dart_NewFinalizableHandle(obj, nullptr, kWeak2ExternalSize, NopCallback);
EXPECT_VALID(AsHandle(strong_ref));
Dart_ExitScope();
}
@@ -3810,7 +3804,6 @@ TEST_CASE(DartAPI_WeakPersistentHandleExternalAllocationSizeOldspaceGC) {
Dart_Handle live = AllocateOldString("live");
EXPECT_VALID(live);
Dart_WeakPersistentHandle weak = NULL;
Dart_WeakPersistentHandle weak2 = NULL;
{
TransitionNativeToVM transition(thread);
GCTestHelper::WaitForGCTasks(); // Finalize GC for accurate live size.
@@ -3834,8 +3827,7 @@ TEST_CASE(DartAPI_WeakPersistentHandleExternalAllocationSizeOldspaceGC) {
}
// Large enough to trigger GC in old space. Not actually allocated.
const intptr_t kHugeExternalSize = (kWordSize == 4) ? 513 * MB : 1025 * MB;
weak2 =
Dart_NewWeakPersistentHandle(live, NULL, kHugeExternalSize, NopCallback);
Dart_NewWeakPersistentHandle(live, NULL, kHugeExternalSize, NopCallback);
{
TransitionNativeToVM transition(thread);
GCTestHelper::WaitForGCTasks(); // Finalize GC for accurate live size.
@@ -3852,7 +3844,6 @@ TEST_CASE(DartAPI_FinalizableHandleExternalAllocationSizeOldspaceGC) {
Dart_EnterScope();
Dart_Handle live = AllocateOldString("live");
EXPECT_VALID(live);
Dart_FinalizableHandle weak = NULL;
{
TransitionNativeToVM transition(thread);
GCTestHelper::WaitForGCTasks(); // Finalize GC for accurate live size.
@@ -3863,8 +3854,7 @@ TEST_CASE(DartAPI_FinalizableHandleExternalAllocationSizeOldspaceGC) {
Dart_EnterScope();
Dart_Handle dead = AllocateOldString("dead");
EXPECT_VALID(dead);
weak = Dart_NewFinalizableHandle(dead, nullptr, kSmallExternalSize,
NopCallback);
Dart_NewFinalizableHandle(dead, nullptr, kSmallExternalSize, NopCallback);
Dart_ExitScope();
}
{
+2 -1
View File
@@ -50,7 +50,8 @@ enum {
// If the forwarded bit and pointer tag bit are the same, we can avoid a few
// conversions.
COMPILE_ASSERT(kForwarded == kHeapObjectTag);
COMPILE_ASSERT(static_cast<uword>(kForwarded) ==
static_cast<uword>(kHeapObjectTag));
static inline bool IsForwarding(uword header) {
uword bits = header & kForwardingMask;
+1 -1
View File
@@ -259,7 +259,7 @@ void ImageWriter::GetTrampolineInfo(intptr_t* count, intptr_t* size) const {
ASSERT(count != nullptr && size != nullptr);
*count = 0;
*size = 0;
for (auto const data : instructions_) {
for (auto const& data : instructions_) {
if (data.trampoline_length != 0) {
*count += 1;
*size += data.trampoline_length;
-6
View File
@@ -1055,17 +1055,11 @@ bool KernelIsolate::DetectNullSafety(const char* script_uri,
const char* original_working_directory) {
// Start the kernel Isolate if it is not already running.
if (!Start()) {
Dart_KernelCompilationResult result = {};
result.status = Dart_KernelCompilationStatus_Unknown;
result.error = Utils::StrDup("Error while starting Kernel isolate task");
return false;
}
// Wait for Kernel isolate to finish initialization.
Dart_Port kernel_port = WaitForKernelPort();
if (kernel_port == ILLEGAL_PORT) {
Dart_KernelCompilationResult result = {};
result.status = Dart_KernelCompilationStatus_Unknown;
result.error = Utils::StrDup("Error while initializing Kernel isolate");
return false;
}
KernelCompilationRequest request;
+2 -2
View File
@@ -4923,8 +4923,8 @@ class Library : public Object {
intptr_t index() const { return raw_ptr()->index_; }
void set_index(intptr_t value) const {
ASSERT(value == -1 ||
value >= 0 && value < std::numeric_limits<classid_t>::max());
ASSERT((value == -1) ||
((value >= 0) && (value < std::numeric_limits<classid_t>::max())));
StoreNonPointer(&raw_ptr()->index_, value);
}