mirror of
https://github.com/Z3Prover/z3
synced 2025-06-29 09:28:45 +00:00
add string constant cache to theory_str and associated param
This commit is contained in:
parent
e5d3e425f1
commit
94762d276d
4 changed files with 32 additions and 19 deletions
|
@ -68,5 +68,6 @@ def_module_params(module_name='smt',
|
||||||
('str.aggressive_unroll_testing', BOOL, True, 'prioritize testing concrete regex unroll counts over generating more options'),
|
('str.aggressive_unroll_testing', BOOL, True, 'prioritize testing concrete regex unroll counts over generating more options'),
|
||||||
('str.fast_length_tester_cache', BOOL, False, 'cache length tester constants instead of regenerating them'),
|
('str.fast_length_tester_cache', BOOL, False, 'cache length tester constants instead of regenerating them'),
|
||||||
('str.fast_value_tester_cache', BOOL, True, 'cache value tester constants instead of regenerating them'),
|
('str.fast_value_tester_cache', BOOL, True, 'cache value tester constants instead of regenerating them'),
|
||||||
|
('str.string_constant_cache', BOOL, True, 'cache all generated string constants generated from anywhere in theory_str'),
|
||||||
('theory_case_split', BOOL, False, 'Allow the context to use heuristics involving theory case splits, which are a set of literals of which exactly one can be assigned True. If this option is false, the context will generate extra axioms to enforce this instead.')
|
('theory_case_split', BOOL, False, 'Allow the context to use heuristics involving theory case splits, which are a set of literals of which exactly one can be assigned True. If this option is false, the context will generate extra axioms to enforce this instead.')
|
||||||
))
|
))
|
||||||
|
|
|
@ -26,4 +26,5 @@ void theory_str_params::updt_params(params_ref const & _p) {
|
||||||
m_AggressiveUnrollTesting = p.str_aggressive_unroll_testing();
|
m_AggressiveUnrollTesting = p.str_aggressive_unroll_testing();
|
||||||
m_UseFastLengthTesterCache = p.str_fast_length_tester_cache();
|
m_UseFastLengthTesterCache = p.str_fast_length_tester_cache();
|
||||||
m_UseFastValueTesterCache = p.str_fast_value_tester_cache();
|
m_UseFastValueTesterCache = p.str_fast_value_tester_cache();
|
||||||
|
m_StringConstantCache = p.str_string_constant_cache();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,13 +62,20 @@ struct theory_str_params {
|
||||||
*/
|
*/
|
||||||
bool m_UseFastValueTesterCache;
|
bool m_UseFastValueTesterCache;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If StringConstantCache is set to true,
|
||||||
|
* all string constants in theory_str generated from anywhere will be cached and saved.
|
||||||
|
*/
|
||||||
|
bool m_StringConstantCache;
|
||||||
|
|
||||||
theory_str_params(params_ref const & p = params_ref()):
|
theory_str_params(params_ref const & p = params_ref()):
|
||||||
m_AssertStrongerArrangements(true),
|
m_AssertStrongerArrangements(true),
|
||||||
m_AggressiveLengthTesting(false),
|
m_AggressiveLengthTesting(false),
|
||||||
m_AggressiveValueTesting(false),
|
m_AggressiveValueTesting(false),
|
||||||
m_AggressiveUnrollTesting(true),
|
m_AggressiveUnrollTesting(true),
|
||||||
m_UseFastLengthTesterCache(false),
|
m_UseFastLengthTesterCache(false),
|
||||||
m_UseFastValueTesterCache(true)
|
m_UseFastValueTesterCache(true),
|
||||||
|
m_StringConstantCache(true)
|
||||||
{
|
{
|
||||||
updt_params(p);
|
updt_params(p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ theory_str::~theory_str() {
|
||||||
}
|
}
|
||||||
|
|
||||||
expr * theory_str::mk_string(std::string str) {
|
expr * theory_str::mk_string(std::string str) {
|
||||||
|
if (m_params.m_StringConstantCache) {
|
||||||
++totalCacheAccessCount;
|
++totalCacheAccessCount;
|
||||||
expr * val;
|
expr * val;
|
||||||
if (stringConstantCache.find(str, val)) {
|
if (stringConstantCache.find(str, val)) {
|
||||||
|
@ -90,6 +91,9 @@ expr * theory_str::mk_string(std::string str) {
|
||||||
stringConstantCache.insert(str, val);
|
stringConstantCache.insert(str, val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return m_strutil.mk_string(str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expr * theory_str::mk_string(const char * str) {
|
expr * theory_str::mk_string(const char * str) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue