3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-23 14:23:40 +00:00

Refactor SLS engine and evaluator components for bit-vector specifics and adjust memory manager alignment

This commit is contained in:
Nikolaj Bjorner 2024-09-02 17:54:29 -07:00
parent 2d3f92a2e6
commit ffa53fee36
7 changed files with 20 additions and 18 deletions

View file

@ -5,13 +5,13 @@ z3_add_component(ast_sls
sls_arith_base.cpp sls_arith_base.cpp
sls_arith_plugin.cpp sls_arith_plugin.cpp
sls_basic_plugin.cpp sls_basic_plugin.cpp
sls_bv_engine.cpp
sls_bv_eval.cpp sls_bv_eval.cpp
sls_bv_fixed.cpp sls_bv_fixed.cpp
sls_bv_plugin.cpp sls_bv_plugin.cpp
sls_bv_terms.cpp sls_bv_terms.cpp
sls_bv_valuation.cpp sls_bv_valuation.cpp
sls_context.cpp sls_context.cpp
sls_engine.cpp
sls_euf_plugin.cpp sls_euf_plugin.cpp
sls_smt_solver.cpp sls_smt_solver.cpp
COMPONENT_DEPENDENCIES COMPONENT_DEPENDENCIES

View file

@ -18,7 +18,7 @@ Notes:
--*/ --*/
#pragma once #pragma once
#include "ast/sls/sls_engine.h" #include "ast/sls/sls_bv_engine.h"
class bvsls_opt_engine : public sls_engine { class bvsls_opt_engine : public sls_engine {
sls_tracker & m_hard_tracker; sls_tracker & m_hard_tracker;

View file

@ -26,7 +26,7 @@ Notes:
#include "util/luby.h" #include "util/luby.h"
#include "params/sls_params.hpp" #include "params/sls_params.hpp"
#include "ast/sls/sls_engine.h" #include "ast/sls/sls_bv_engine.h"
sls_engine::sls_engine(ast_manager & m, params_ref const & p) : sls_engine::sls_engine(ast_manager & m, params_ref const & p) :

View file

@ -23,8 +23,8 @@ Notes:
#include "ast/converters/model_converter.h" #include "ast/converters/model_converter.h"
#include "ast/sls/sls_stats.h" #include "ast/sls/sls_stats.h"
#include "ast/sls/sls_tracker.h" #include "ast/sls/sls_bv_tracker.h"
#include "ast/sls/sls_evaluator.h" #include "ast/sls/sls_bv_evaluator.h"
class sls_engine { class sls_engine {

View file

@ -22,7 +22,7 @@ Notes:
#include "model/model_evaluator.h" #include "model/model_evaluator.h"
#include "ast/sls/sls_powers.h" #include "ast/sls/sls_powers.h"
#include "ast/sls/sls_tracker.h" #include "ast/sls/sls_bv_tracker.h"
class sls_evaluator { class sls_evaluator {
ast_manager & m_manager; ast_manager & m_manager;

View file

@ -28,7 +28,7 @@ Notes:
#include "util/stopwatch.h" #include "util/stopwatch.h"
#include "tactic/sls/sls_tactic.h" #include "tactic/sls/sls_tactic.h"
#include "params/sls_params.hpp" #include "params/sls_params.hpp"
#include "ast/sls/sls_engine.h" #include "ast/sls/sls_bv_engine.h"
#include "ast/sls/sls_smt_solver.h" #include "ast/sls/sls_smt_solver.h"
class sls_smt_tactic : public tactic { class sls_smt_tactic : public tactic {

View file

@ -29,6 +29,8 @@ Copyright (c) 2015 Microsoft Corporation
# define malloc_usable_size _msize # define malloc_usable_size _msize
#endif #endif
#define SIZE_T_ALIGN 2
// The following two function are automatically generated by the mk_make.py script. // The following two function are automatically generated by the mk_make.py script.
// The script collects ADD_INITIALIZER and ADD_FINALIZER commands in the .h files. // The script collects ADD_INITIALIZER and ADD_FINALIZER commands in the .h files.
// For example, rational.h contains // For example, rational.h contains
@ -278,7 +280,7 @@ void memory::deallocate(void * p) {
size_t sz = malloc_usable_size(p); size_t sz = malloc_usable_size(p);
void * real_p = p; void * real_p = p;
#else #else
size_t * sz_p = reinterpret_cast<size_t*>(p) - 1; size_t * sz_p = reinterpret_cast<size_t*>(p) - SIZE_T_ALIGN;
size_t sz = *sz_p; size_t sz = *sz_p;
void * real_p = reinterpret_cast<void*>(sz_p); void * real_p = reinterpret_cast<void*>(sz_p);
#endif #endif
@ -291,7 +293,7 @@ void memory::deallocate(void * p) {
void * memory::allocate(size_t s) { void * memory::allocate(size_t s) {
#ifndef HAS_MALLOC_USABLE_SIZE #ifndef HAS_MALLOC_USABLE_SIZE
s = s + sizeof(size_t); // we allocate an extra field! s = s + SIZE_T_ALIGN * sizeof(size_t); // we allocate an extra field!
#endif #endif
g_memory_thread_alloc_size += s; g_memory_thread_alloc_size += s;
g_memory_thread_alloc_count += 1; g_memory_thread_alloc_count += 1;
@ -308,7 +310,7 @@ void * memory::allocate(size_t s) {
return r; return r;
#else #else
*(static_cast<size_t*>(r)) = s; *(static_cast<size_t*>(r)) = s;
return static_cast<size_t*>(r) + 1; // we return a pointer to the location after the extra field return static_cast<size_t*>(r) + SIZE_T_ALIGN; // we return a pointer to the location after the extra field
#endif #endif
} }
@ -323,7 +325,7 @@ void* memory::reallocate(void *p, size_t s) {
size_t *sz_p = reinterpret_cast<size_t*>(p)-1; size_t *sz_p = reinterpret_cast<size_t*>(p)-1;
size_t sz = *sz_p; size_t sz = *sz_p;
void *real_p = reinterpret_cast<void*>(sz_p); void *real_p = reinterpret_cast<void*>(sz_p);
s = s + sizeof(size_t); // we allocate an extra field! s = s + SIZE_T_ALIGN * sizeof(size_t); // we allocate an extra field!
#endif #endif
g_memory_thread_alloc_size += s - sz; g_memory_thread_alloc_size += s - sz;
g_memory_thread_alloc_count += 1; g_memory_thread_alloc_count += 1;
@ -341,7 +343,7 @@ void* memory::reallocate(void *p, size_t s) {
return r; return r;
#else #else
*(static_cast<size_t*>(r)) = s; *(static_cast<size_t*>(r)) = s;
return static_cast<size_t*>(r) + 1; // we return a pointer to the location after the extra field return static_cast<size_t*>(r) + SIZE_T_ALIGN; // we return a pointer to the location after the extra field
#endif #endif
} }
@ -358,7 +360,7 @@ void memory::deallocate(void * p) {
size_t sz = malloc_usable_size(p); size_t sz = malloc_usable_size(p);
void * real_p = p; void * real_p = p;
#else #else
size_t * sz_p = reinterpret_cast<size_t*>(p) - 1; size_t * sz_p = reinterpret_cast<size_t*>(p) - SIZE_T_ALIGN;
size_t sz = *sz_p; size_t sz = *sz_p;
void * real_p = reinterpret_cast<void*>(sz_p); void * real_p = reinterpret_cast<void*>(sz_p);
#endif #endif
@ -368,7 +370,7 @@ void memory::deallocate(void * p) {
void * memory::allocate(size_t s) { void * memory::allocate(size_t s) {
#ifndef HAS_MALLOC_USABLE_SIZE #ifndef HAS_MALLOC_USABLE_SIZE
s = s + sizeof(size_t); // we allocate an extra field! s = s + SIZE_T_ALIGN * sizeof(size_t); // we allocate an extra field!
#endif #endif
g_memory_alloc_size += s; g_memory_alloc_size += s;
g_memory_alloc_count += 1; g_memory_alloc_count += 1;
@ -389,7 +391,7 @@ void * memory::allocate(size_t s) {
return r; return r;
#else #else
*(static_cast<size_t*>(r)) = s; *(static_cast<size_t*>(r)) = s;
return static_cast<size_t*>(r) + 1; // we return a pointer to the location after the extra field return static_cast<size_t*>(r) + SIZE_T_ALIGN; // we return a pointer to the location after the extra field
#endif #endif
} }
@ -401,10 +403,10 @@ void* memory::reallocate(void *p, size_t s) {
if (sz >= s) if (sz >= s)
return p; return p;
#else #else
size_t * sz_p = reinterpret_cast<size_t*>(p) - 1; size_t * sz_p = reinterpret_cast<size_t*>(p) - SIZE_T_ALIGN;
size_t sz = *sz_p; size_t sz = *sz_p;
void * real_p = reinterpret_cast<void*>(sz_p); void * real_p = reinterpret_cast<void*>(sz_p);
s = s + sizeof(size_t); // we allocate an extra field! s = s + SIZE_T_ALIGN * sizeof(size_t); // we allocate an extra field!
#endif #endif
g_memory_alloc_size += s - sz; g_memory_alloc_size += s - sz;
g_memory_alloc_count += 1; g_memory_alloc_count += 1;
@ -425,7 +427,7 @@ void* memory::reallocate(void *p, size_t s) {
return r; return r;
#else #else
*(static_cast<size_t*>(r)) = s; *(static_cast<size_t*>(r)) = s;
return static_cast<size_t*>(r) + 1; // we return a pointer to the location after the extra field return static_cast<size_t*>(r) + SIZE_T_ALIGN; // we return a pointer to the location after the extra field
#endif #endif
} }