-
Notifications
You must be signed in to change notification settings - Fork 686
Optimize int-mask type handling with new TIntMaskVerifier to reduce memory usage #11543
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
Open
il-yb-ono
wants to merge
25
commits into
vimeo:master
Choose a base branch
from
il-yb-ono:bitmask-memory-optimization
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or 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
…ify isValidValue logic
…Verifier type checking.
…tion only if the masks are the same.
so expand it to TLiteralInt to allow multiple conditional expressions to be selected.
…tests accordingly
…rete ints from potential_ints
…e combining union types
…processing limits
…on bits in result
… with TIntMaskVerifier
…ds for TIntMaskVerifier
…is methods for TIntMaskVerifier" This reverts commit b821530.
…ierAnalyzer class
I found these snippets: https://psalm.dev/r/154cd2c5da<?php
final class C {
// const C0 = 1 << 0;
// const C1 = 1 << 1;
// const C2 = 1 << 2;
const C3 = 1 << 3;
const C4 = 1 << 4;
const C5 = 1 << 5;
const C6 = 1 << 6;
const C7 = 1 << 7;
const C8 = 1 << 8;
const C9 = 1 << 9;
const C10 = 1 << 10;
const C11 = 1 << 11;
const C12 = 1 << 12;
const C13 = 1 << 13;
const C14 = 1 << 14;
const C15 = 1 << 15;
const C16 = 1 << 16;
const C17 = 1 << 17;
const C18 = 1 << 18;
const C19 = 1 << 19;
}
/**
* @return int-mask-of<C::C*>
*/
function processFlags(): int {
$result = 0;
$result |= 1;
$result |= 2;
return $result;
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR addresses the memory usage issue that occurs when the number of bit flags in
int-mask-of
orint-mask
types grows. Currently, types with many bit flags cannot be properly validated, as demonstrated in this example.This change treats
TIntMask
andTIntMaskOf
as bit flags without decomposing them into individualTLiteralInt
types, significantly reducing memory consumption.#10440
Key Changes
TIntMaskVerifier
atomic type for efficient bit flag validationTypeExpander
andTypeParser
to returnTIntMaskVerifier
instead of expanding all combinationsTemplateInferredTypeReplacer
to properly handle conditional expressions withTIntMaskVerifier
typesTIntMaskVerifier
toTLiteralInt
for multi-pattern int-mask conditionsArithmeticOpAnalyzer
with support forTIntMaskVerifier
bitwise operations (AND, OR, XOR, SHIFT)maxIntMaskCombinations
configuration option to limit computation complexity when calculating all possible values