3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

merge unstable into opt

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2014-09-26 12:12:24 -07:00
commit e6725b2344
78 changed files with 695 additions and 350 deletions

View file

@ -73,7 +73,7 @@ bool is_debug_enabled(const char * tag);
UNREACHABLE(); \
}
#else
#define VERIFY(_x_) (_x_)
#define VERIFY(_x_) (void)(_x_)
#endif
#define MAKE_NAME2(LINE) zofty_ ## LINE

View file

@ -35,6 +35,7 @@ static long long g_memory_max_used_size = 0;
static long long g_memory_watermark = 0;
static bool g_exit_when_out_of_memory = false;
static char const * g_out_of_memory_msg = "ERROR: out of memory";
static volatile bool g_memory_fully_initialized = false;
void memory::exit_when_out_of_memory(bool flag, char const * msg) {
g_exit_when_out_of_memory = flag;
@ -83,10 +84,18 @@ void memory::initialize(size_t max_size) {
initialize = true;
}
}
if (!initialize)
return;
g_memory_out_of_memory = false;
mem_initialize();
if (initialize) {
g_memory_out_of_memory = false;
mem_initialize();
g_memory_fully_initialized = true;
}
else {
// Delay the current thread until the DLL is fully initialized
// Without this, multiple threads can start to call API functions
// before memory::initialize(...) finishes.
while (!g_memory_fully_initialized)
/* wait */ ;
}
}
bool memory::is_out_of_memory() {
@ -98,9 +107,9 @@ bool memory::is_out_of_memory() {
return r;
}
void memory::set_high_watermark(size_t watermak) {
void memory::set_high_watermark(size_t watermark) {
// This method is only safe to invoke at initialization time, that is, before the threads are created.
g_memory_watermark = watermak;
g_memory_watermark = watermark;
}
bool memory::above_high_watermark() {

View file

@ -165,6 +165,14 @@ public:
SASSERT(e);
return e->get_data().m_value;
}
value const & operator[](key * k) const {
return find(k);
}
value & operator[](key * k) {
return find(k);
}
iterator find_iterator(Key * k) const {
return m_table.find(key_data(k));

View file

@ -24,6 +24,9 @@ Revision History:
#include<iostream>
#include<climits>
#include<limits>
#ifdef _MSC_VER
#include<intrin.h>
#endif
#ifndef SIZE_MAX
#define SIZE_MAX std::numeric_limits<std::size_t>::max()
@ -95,7 +98,12 @@ unsigned uint64_log2(uint64 v);
COMPILE_TIME_ASSERT(sizeof(unsigned) == 4);
// Return the number of 1 bits in v.
inline unsigned get_num_1bits(unsigned v) {
static inline unsigned get_num_1bits(unsigned v) {
#ifdef _MSC_VER
return __popcnt(v);
#elif defined(__GNUC__)
return __builtin_popcount(v);
#else
#ifdef Z3DEBUG
unsigned c;
unsigned v1 = v;
@ -108,15 +116,16 @@ inline unsigned get_num_1bits(unsigned v) {
unsigned r = (((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
SASSERT(c == r);
return r;
#endif
}
// Remark: on gcc, the operators << and >> do not produce zero when the second argument >= 64.
// So, I'm using the following two definitions to fix the problem
inline uint64 shift_right(uint64 x, uint64 y) {
static inline uint64 shift_right(uint64 x, uint64 y) {
return y < 64ull ? (x >> y) : 0ull;
}
inline uint64 shift_left(uint64 x, uint64 y) {
static inline uint64 shift_left(uint64 x, uint64 y) {
return y < 64ull ? (x << y) : 0ull;
}
@ -255,10 +264,6 @@ inline std::ostream & operator<<(std::ostream & out, std::pair<T1, T2> const & p
return out;
}
#ifndef _WINDOWS
#define __forceinline inline
#endif
template<typename IT>
bool has_duplicates(const IT & begin, const IT & end) {
for (IT it1 = begin; it1 != end; ++it1) {