-
Notifications
You must be signed in to change notification settings - Fork 49
Optimize matching to match on scalar values when possible #525
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
Merged
rctcwyvrn
merged 31 commits into
swiftlang:main
from
rctcwyvrn:scalar-optimizations-clean
Jul 12, 2022
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
e518bdf
Add unicode and dna benchmarks
rctcwyvrn eb64036
Fixup naming, turn off firstmatch, add benchmark filtering by regex
rctcwyvrn 1237f9a
Make --exclude-ns actually work correctly
rctcwyvrn fdf2c23
Add usage comment for generateFasta
rctcwyvrn eeb38e9
First ver
rctcwyvrn 6f76f36
Merge branch 'main' into match-scalar
rctcwyvrn 3a2b324
Remove matchseq entirely
rctcwyvrn df8919e
Merge branch 'just-one-more-benchmark-suite' into temp
rctcwyvrn c2ee8cc
Finish up matchScalar
rctcwyvrn 809b085
Factor out nextScalarIndex for matchBitsetScalar
rctcwyvrn 06c77c7
Add scalar mode support for matching bitsets + fix bug
rctcwyvrn e3d7ad7
Emit matchScalar in quotedLiteral when in unicode scalar mode
rctcwyvrn 3e1e088
Add tests
rctcwyvrn b4c7c8c
Cleanup
rctcwyvrn 5359e31
Revert "Merge branch 'just-one-more-benchmark-suite' into temp"
rctcwyvrn 6e4c2bd
Cleanup
rctcwyvrn 1a359b4
Add case-insensitive match instructions
rctcwyvrn 097ffeb
Remove extra instructions and use payload bits instead
rctcwyvrn 76667a2
Comment out compiletests for now
rctcwyvrn 6a1f6e9
Fix compile tests
rctcwyvrn fce8f9a
Merge branch 'main' into scalar-optimizations-clean
rctcwyvrn 0860368
Fix scalar matching in grapheme semantic mode
hamishknight c6bc811
Preserve scalar syntax in DSL conversion
hamishknight bca1d2b
Change scalar semantics to match #565
rctcwyvrn 79e60ac
Merge branch 'not-to-scale' into scalar-optimizations-clean
rctcwyvrn 22cc9d5
Add edge case test
rctcwyvrn 7a9923d
Always match .scalar under grapheme semantics
rctcwyvrn 47f8e66
Merge branch 'main' into scalar-optimizations-clean
rctcwyvrn 7aa98d1
Add new instructions to compile tests
rctcwyvrn 113cfe3
Add an XFAIL test for scalar coalescing
rctcwyvrn 9949b8e
Fix XCTExpectFailure for linux
rctcwyvrn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,6 +147,26 @@ extension Instruction.Payload { | |
var string: StringRegister { | ||
interpret() | ||
} | ||
|
||
init(scalar: Unicode.Scalar) { | ||
self.init(UInt64(scalar.value)) | ||
} | ||
var scalar: Unicode.Scalar { | ||
return Unicode.Scalar(_value: UInt32(self.rawValue)) | ||
} | ||
|
||
init(scalar: Unicode.Scalar, caseInsensitive: Bool, boundaryCheck: Bool) { | ||
let raw = UInt64(scalar.value) | ||
+ (caseInsensitive ? 1 << 55: 0) | ||
+ (boundaryCheck ? 1 << 54 : 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Future: we'll be redoing instruction encoding and can clean this up alongside other changes. |
||
self.init(raw) | ||
} | ||
var scalarPayload: (Unicode.Scalar, caseInsensitive: Bool, boundaryCheck: Bool) { | ||
let caseInsensitive = (self.rawValue >> 55) & 1 == 1 | ||
let boundaryCheck = (self.rawValue >> 54) & 1 == 1 | ||
let scalar = Unicode.Scalar(_value: UInt32(self.rawValue & 0xFFFF_FFFF)) | ||
return (scalar, caseInsensitive: caseInsensitive, boundaryCheck: boundaryCheck) | ||
} | ||
|
||
init(sequence: SequenceRegister) { | ||
self.init(sequence) | ||
|
@@ -190,18 +210,20 @@ extension Instruction.Payload { | |
interpret() | ||
} | ||
|
||
init(element: ElementRegister) { | ||
self.init(element) | ||
init(element: ElementRegister, isCaseInsensitive: Bool) { | ||
self.init(isCaseInsensitive ? 1 : 0, element) | ||
} | ||
var element: ElementRegister { | ||
interpret() | ||
var elementPayload: (isCaseInsensitive: Bool, ElementRegister) { | ||
let pair: (UInt64, ElementRegister) = interpretPair() | ||
return (isCaseInsensitive: pair.0 == 1, pair.1) | ||
} | ||
|
||
init(bitset: AsciiBitsetRegister) { | ||
self.init(bitset) | ||
init(bitset: AsciiBitsetRegister, isScalar: Bool) { | ||
self.init(isScalar ? 1 : 0, bitset) | ||
} | ||
var bitset: AsciiBitsetRegister { | ||
interpret() | ||
var bitsetPayload: (isScalar: Bool, AsciiBitsetRegister) { | ||
let pair: (UInt64, AsciiBitsetRegister) = interpretPair() | ||
return (isScalar: pair.0 == 1, pair.1) | ||
} | ||
|
||
init(consumer: ConsumeFunctionRegister) { | ||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should fail tests, and if it's not we may need to write the tests and XFAIL them. E.g.
/a\u{301}/
, IIUC, as written would try to make a proper Character from the combining scalar.