Added Violet - Python VM written in Swift #660
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Description
Adding Violet - Python VM written in Swift.
Acceptance Criteria
To be accepted into the Swift source compatibility test suite, a project must:
Be an Xcode or swift package manager project
Swift Package Manager
Target Linux, macOS, or iOS/tvOS/watchOS device
Tested on:
make test
andmake pytest
swift:latest
(5.6.0) - usemake docker-test
andmake docker-pytest
swift:5.3.2
- usemake docker-test-old
andmake docker-pytest-old
Support building on either Linux or macOS
Maintain a project branch that builds against Swift 4.0 and passes any unit tests
No Swift 4.0 support, although from what I see there are some other projects (like apple/swift-argument-parser) that only support 5+.
Our target in
project_precommit_check
:We could go as low as swift-argument-parser allows us (from my tests it is 5.3 - I had “SPM was unable to reserve dependency” / build failures on earlier versions). If we removed this dependency then I think that we could go to 5.0 (with some changes in our code).
Be contained in a publicly accessible git repository
github.com/LiarPrincess/Violet
Have maintainers who will commit to resolve issues in a timely manner
github.com/LiarPrincess. No guarantee of 10+ years of support.
Be compatible with the latest GM/Beta versions of Xcode and swiftpm
Not tested on beta. All of the tested configurations were mentioned previously.
Add value not already included in the suite
We have things like:
Unsafe[Raw/Mutable]Pointers
+ a lof of pointer arithmetic - most of the Swift projects try to stay away from anyUnsafe
things, we use them a lot. In Violet a single Python object is represented as anUnsafeRawPointer
with manually calculated offsets for fields.ManagedBufferPointer
+ tagged pointers - this one is not popular among Swift programmers (Array
is more common). Our customBigInt
implementation is an union (via tagged pointer) ofInt32
(calledSmi
, after V8) and a heap allocation (magnitude + sign representation) with ARC for garbage collection.UnicodeScalar
andString.UnicodeScalarView
(+SubSequence
) - most Swift programmers use defaultString
view (the one with on grapheme clusters).VioletCore
and check which modules have been recompiled (I think that @CodaFi worked in this area last year).be licensed with one of the following permissive licenses:
pass
./project_precommit_check
script runstdout - macOS 11.6.2 (BigSur) on Intel + Xcode 12.4 (Swift 5.3.2)
Other
Release vs debug
There are some differences between a
release
anddebug
configuration in Violet. In PR I submitted:My intention is:
command = [swift, 'build', '--package-path', path, '--verbose', '--configuration', configuration]
which is “ok”command = [swift, 'test', '-C', path, '--verbose']
which is “ok”Is my
project.json
configuration correct for this?Python tests
We have an additional test suite written in Python where our VM is executing those files. You can run it with
make pytest
(ormake pytest-r
for release mode). It returns:EXIT_SUCCESS
- all tests passedEXIT_FAILURE
- any of the tests failedNot sure if you want it, from what I see executables are not supported. Though it is a really good way of checking if Swift runtime is doing what it is supposed to do.