From be6a02a446c7652751df4c8369261d46d4af7757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 29 Oct 2014 12:14:24 +0100 Subject: [PATCH] Use clog for JIT logs --- libevmjit/Compiler.cpp | 4 ++-- libevmjit/ExecutionEngine.cpp | 23 +++++++++++------------ libevmjit/Utils.h | 3 +++ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/libevmjit/Compiler.cpp b/libevmjit/Compiler.cpp index 02c8db715..2ee776387 100644 --- a/libevmjit/Compiler.cpp +++ b/libevmjit/Compiler.cpp @@ -153,8 +153,8 @@ void Compiler::createBasicBlocks(bytesConstRef bytecode) } else { - std::cerr << "Bad JUMP at PC " << it->first - << ": " << it->second << " is not a valid PC\n"; + clog(JIT) << "Bad JUMP at PC " << it->first + << ": " << it->second << " is not a valid PC"; m_directJumpTargets[it->first] = m_badJumpBlock->llvm(); } } diff --git a/libevmjit/ExecutionEngine.cpp b/libevmjit/ExecutionEngine.cpp index efa039f2b..c6e623d0e 100644 --- a/libevmjit/ExecutionEngine.cpp +++ b/libevmjit/ExecutionEngine.cpp @@ -75,9 +75,8 @@ int ExecutionEngine::run(std::unique_ptr _module, u256& _gas, ExtV auto finalizationStartTime = std::chrono::high_resolution_clock::now(); exec->finalizeObject(); auto finalizationEndTime = std::chrono::high_resolution_clock::now(); - std::cerr << "*** Module finalization time: " - << std::chrono::duration_cast(finalizationEndTime - finalizationStartTime).count() - << std::endl; + clog(JIT) << "Module finalization time: " + << std::chrono::duration_cast(finalizationEndTime - finalizationStartTime).count(); // Create fake ExtVM interface if (!_ext) @@ -117,9 +116,8 @@ int ExecutionEngine::run(std::unique_ptr _module, u256& _gas, ExtV returnCode = static_cast(result.IntVal.getZExtValue()); auto executionEndTime = std::chrono::high_resolution_clock::now(); - std::cerr << "*** Execution time: " - << std::chrono::duration_cast(executionEndTime - executionStartTime).count() - << std::endl; + clog(JIT) << "Execution time : " + << std::chrono::duration_cast(executionEndTime - executionStartTime).count(); } else @@ -128,19 +126,20 @@ int ExecutionEngine::run(std::unique_ptr _module, u256& _gas, ExtV // Return remaining gas _gas = returnCode == ReturnCode::OutOfGas ? 0 : runtime.getGas(); - std::cout << "Max stack size: " << Stack::maxStackSize << std::endl; + clog(JIT) << "Max stack size: " << Stack::maxStackSize; if (returnCode == ReturnCode::Return) { returnData = runtime.getReturnData().toVector(); // TODO: It might be better to place is in Runtime interface - std::cout << "RETURN [ "; + auto&& log = clog(JIT); + log << "RETURN [ "; for (auto it = returnData.begin(), end = returnData.end(); it != end; ++it) - std::cout << std::hex << std::setw(2) << std::setfill('0') << (int)*it << " "; - std::cout << "]\n"; + log << std::hex << std::setw(2) << std::setfill('0') << (int)*it << " "; + log << "]"; } - - std::cout << "RETURN CODE: " << (int)returnCode << std::endl; + else + cslog(JIT) << "RETURN " << (int)returnCode; return static_cast(returnCode); } diff --git a/libevmjit/Utils.h b/libevmjit/Utils.h index 1b146b3d2..7a3afda64 100644 --- a/libevmjit/Utils.h +++ b/libevmjit/Utils.h @@ -4,6 +4,7 @@ #include #include +#include namespace dev { @@ -12,6 +13,8 @@ namespace eth namespace jit { +struct JIT: public NoteChannel { static const char* name() { return "JIT"; } }; + /// Representation of 256-bit value binary compatible with LLVM i256 // TODO: Replace with h256 struct i256