diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h index 2573995c5..dada9dd5d 100644 --- a/libdevcore/CommonData.h +++ b/libdevcore/CommonData.h @@ -124,6 +124,10 @@ inline bytes toCompactBigEndian(_T _val, unsigned _min = 0) toBigEndian(_val, ret); return ret; } +inline bytes toCompactBigEndian(byte _val, unsigned _min = 0) +{ + return (_min || _val) ? bytes{ _val } : bytes{}; +} /// Convenience function for toBigEndian. /// @returns a string just big enough to represent @a _val. diff --git a/libethcore/Exceptions.cpp b/libethcore/Exceptions.cpp index b0aff4551..b5d01d3fc 100644 --- a/libethcore/Exceptions.cpp +++ b/libethcore/Exceptions.cpp @@ -27,16 +27,12 @@ using namespace std; using namespace dev; using namespace dev::eth; -#if ALL_COMPILERS_ARE_CPP11_COMPLIANT -#define ETH_RETURN_STRING(S) thread_local static string s_what; s_what = S; return s_what.c_str(); -#else -#define ETH_RETURN_STRING(S) \ - static boost::thread_specific_ptr s_what; \ - if (!s_what.get()) \ - s_what.reset(new string); \ - *s_what = S; return s_what->c_str(); +#if _MSC_VER +#define thread_local __declspec( thread ) #endif +#define ETH_RETURN_STRING(S) thread_local static string s_what; s_what = S; return s_what.c_str(); + const char* InvalidBlockFormat::what() const noexcept { ETH_RETURN_STRING("Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"); } const char* UncleInChain::what() const noexcept { ETH_RETURN_STRING("Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"); } const char* InvalidTransactionsHash::what() const noexcept { ETH_RETURN_STRING("Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref())); } diff --git a/libevm/VM.cpp b/libevm/VM.cpp index aa3caff44..45017db9c 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -38,10 +38,12 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) if (m_jumpDests.empty()) for (unsigned i = 0; i < _ext.code.size(); ++i) + { if (_ext.code[i] == (byte)Instruction::JUMPDEST) m_jumpDests.insert(i); else if (_ext.code[i] >= (byte)Instruction::PUSH1 && _ext.code[i] <= (byte)Instruction::PUSH32) i += _ext.code[i] - (unsigned)Instruction::PUSH1 + 1; + } u256 nextPC = m_curPC + 1; auto osteps = _steps; for (bool stopped = false; !stopped && _steps--; m_curPC = nextPC, nextPC = m_curPC + 1)