Skip to content

[WIP] Enhance -assume-single-threaded option #7421

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

Closed
wants to merge 52 commits into from
Closed

[WIP] Enhance -assume-single-threaded option #7421

wants to merge 52 commits into from

Conversation

mtake
Copy link
Contributor

@mtake mtake commented Feb 13, 2017

(This PR was replaced with #7557)

This PR is part of SR-3945 which extends the scope of -assume-single-threaded option to value types.

This PR is not fully integrated with swift build system yet. The same environment variable SWIFT_ASSUME_SINGLE_THREADED is used at compile time to configure swift compiler to generate single threaded code and, as well as at runtime to configure swift native runtime for single threaded code.

To use this PR, set an arbitrary text to SWIFT_ASSUME_SINGLE_THREADED while running build-script as well as running your program. Without the variable defined, this PR should have no effect.

Chris Bieneman and others added 30 commits February 10, 2017 11:42
This change updates the branch mappings for the Swift-LLDB repository to match the LLVM & Clang model which LLDB is adopting.
The correct/canonical ConcreteType and ConcreteTypeSource are both
stored in the Representative, but previously only the getter for the
former was tranversing the chain.
This is the "canonical" representation of the type-level requirements of
a protocol, and we intend to use it pervasively in the compiler.
The requirement signature is far more compact than looking at all the members.
When using the requirement signature in the archetype builder, not all
nested types are resolved (i.e. added to their parent PA's NestedTypes
map) when a protocol conformance is added. Equating a PA to a concrete
type would previously rely on the NestedTypes map being complete, to
recursively equate those nested types to the type implied by their
parent being concrete. The lazier resolution now also includes resolving
nested PA's to concrete types, if their parents are concrete.
…ynthesized` again.

This reverts part of #4038 which made the compiler consider it to be an `Explicit` conformance, breaking source code that was accepted in Swift 3.0 which declared a raw type as well as explicit conformance to `RawRepresentable` (reported as rdar://problem/30386658). While I'm here, a couple of spot fixes:

- Ensure an enum's raw value exprs are type-checked before checking conformances of any of its extensions, since the RawRepresentable conformance derivation will blow up if the raw value exprs haven't been checked. Fixes an order dependency issue if `extension Foo: RawRepresentable {}` gets checked before `enum Foo: Int { ... }`.
- Don't display the custom `enum_declares_rawrep_with_raw_type` diagnostic if the source location for the enum's inheritance clause is invalid, so that we don't emit a dislocated diagnostic.
Previously, these were only diagnosed in some situations, but the
compiler is becoming more flexible about when things get fed into
different places, and so can crop up elsewhere.
Default this option to its previous value (whether libxml2 was found),
but allow us to independently turn it off.
This just moves a bunch of queries that used information on SILFunction to
determine this property to just call a helper on SILFunctionType itself.

Centralized logic is good.

rdar://29791263
This is just refactoring code from DiagnoseUnreachable into a centralized
location.

rdar://29791263
The requirement signature covers this functionality, when it matters.
…an a char pointer + length

This avoids doing a strlen in lldb when calling this function.

rdar://problem/30062026
Matching two dependent member types has nothing to do with matching
the bases; they're independent type parameters.
…nts.

Rather than using "isEqual" to match same-type constraints among
concrete types, use a full type matched to recursively decompose the
structure. This allows us to support same-type constraints that end up
being of the form X<T> == X<U>, where T and U are type parameters of
some sort.

Fixes rdar://problem/29333056.
@swiftix
Copy link
Contributor

swiftix commented Feb 15, 2017

@swift-ci please smoke test

1 similar comment
@swiftix
Copy link
Contributor

swiftix commented Feb 15, 2017

@swift-ci please smoke test

@swiftix
Copy link
Contributor

swiftix commented Feb 15, 2017

@mtake

  • The implementation with the environment variable seems interesting. We still need to check if it affects the performance of atomic cases too much due to the additional conditional branch instruction. If this is the case, we would need to go for the approach where we produce different binaries for the atomic and non-atomic runtime libraries.

  • BTW, we cannot easily test your PR on the CI bots, because it would require setting an environment variable, which is not currently possible using @swift-ci commands. But I'll try to test it locally on my machine till the end of the week. In general, we really need to have an option in the swift/util/build-script to enable the builds of non-atomic components (e.g. stdlib and runtime).

  • Could you locally rebase your PR to contain only your commits and then push force it using git push --force? Currently it contains about 35 commits from other people and those commits have nothing to do with your PR. Alternatively, you can submit a new PR, which would contain only your commits.

@swiftix swiftix self-assigned this Feb 15, 2017
@gottesmm
Copy link
Contributor

If you want to test on the PR bots, you can add in a commit on your branch a change to the preset that the bot will invoke or add an additional preset.

There is support in swift-ci for invoking arbitrary presets.

@swiftix swiftix requested review from gottesmm and swiftix February 16, 2017 01:06
@swiftix swiftix removed their assignment Feb 16, 2017
@gottesmm
Copy link
Contributor

You can add a preset by looking in ./utils/build-presets.ini. I would just copy the section under:

[preset: buildbot_incremental,tools=RA,stdlib=RD,smoketest=macosx]

And create a preset maybe with the name:

[preset: buildbot_incremental,tools=RA,stdlib=RD,smoketest=macosx,single-thread]

and add your flag to that after the em-dash to ensure that it is passed to build-script-impl if you need to do so.

@mtake
Copy link
Contributor Author

mtake commented Feb 16, 2017

I merged upstream into my fork, created a new topic branch, applied all my changes in a single commit, pushed the branch to my fork, and tried to create a new PR from it. However, I discarded the PR since it still included many commits from other people. I need help from github expert for solving the problem.

@swiftix
Copy link
Contributor

swiftix commented Feb 16, 2017

Here is what I usually do:

  • fork the original, i.e. apple/swift
  • clone my fork to my machine
  • Configure the upstream: https://help.github.com/articles/configuring-a-remote-for-a-fork/
  • create locally a branch for my feature
  • develop and commit on this branch
  • once I'm ready, I sync it with upstream like this (note that I do not merge!):
    • git fetch upstream master, which receives the latest changes from apple/swift master
    • git rebase upstream/master, which rebases your commits on top of those changes
  • push it to my branch on github using git push if it is a first time or eventually using git push --force if required
  • create a PR

Please let me know if it helps or if you need more help.

@slavapestov
Copy link
Contributor

Instead of merging upstream into your branch, rebase your branch on top of upstream:

git fetch origin
git rebase -i origin/master
git push -f mygithubrepo HEAD:refs/heads/remote-branch-name

@mtake
Copy link
Contributor Author

mtake commented Feb 17, 2017

@swiftix Your suggestion to create a clean PR worked perfectly. Thanks!

@mtake mtake closed this Feb 17, 2017
@mtake mtake changed the title [WIP] (Don't merge) Enhance -assume-single-threaded option [WIP] Enhance -assume-single-threaded option Feb 17, 2017
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.