Skip to content

[Runtime] Add a disabled workaround for protocol conformance checking to check conformances in reverse order. #35061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented Dec 11, 2020

rdar://problem/72049977

@mikeash mikeash requested review from tbkka and compnerd December 11, 2020 18:44
@mikeash
Copy link
Contributor Author

mikeash commented Dec 11, 2020

@swift-ci please test

@mikeash
Copy link
Contributor Author

mikeash commented Dec 11, 2020

@swift-ci please test windows platform

#include "swift/Runtime/Bincompat.h"

bool swift::runtime::bincompat::
workaroundProtocolConformanceReverseIteration() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to do the following for wrapping (or just clang-format it):

namespace swift {
namespace runtime {
namespace bincompat {
bool workaroundProtocolConformanceReverseIteraction() {
  return false;
}
}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clang-format gave me the version I had, but your version is still nicer. Updated.

ConformanceState() {
scanSectionsBackwards = swift::runtime::bincompat::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be able to get away with bincompat::workaroundProtocolConformanceReverseIteration().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost. runtime::bincompat::... works. Updated.

};

auto snapshot = C.SectionsToScan.snapshot();
if (C.scanSectionsBackwards) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to do something like:

if (C.scanSectionsBackwards)
  std::reverse(std::begin(snapshot), std::end(snapshot))
for (auto &section : snapshot)
  processSection(section);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, we can't mutate in place, but we settled on:

  auto snapshot = C.SectionsToScan.snapshot();
  if (C.scanSectionsBackwards) {
    for (auto &section : llvm::reverse(snapshot))
      processSection(section);
  } else {
    for (auto &section : snapshot)
      processSection(section);
  }

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 13ea40e20c3e83ced6c8dd8ef88db9194b71ebe3

@mikeash mikeash force-pushed the protocol-conformance-iteration-order-workaround branch from 13ea40e to 5303d4f Compare December 11, 2020 21:11
@mikeash
Copy link
Contributor Author

mikeash commented Dec 11, 2020

@swift-ci please test

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 5303d4fdcf7631ec21bf4432d74ea74182496e4a

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 5303d4fdcf7631ec21bf4432d74ea74182496e4a

… to check conformances in reverse order.

rdar://problem/72049977
@mikeash mikeash force-pushed the protocol-conformance-iteration-order-workaround branch from 5303d4f to 9ac3b0e Compare December 14, 2020 17:59
@mikeash
Copy link
Contributor Author

mikeash commented Dec 14, 2020

@swift-ci please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants