Browse Source

Use clog for JIT logs

cl-refactor
Paweł Bylica 10 years ago
parent
commit
887bac9524
  1. 4
      libevmjit/Compiler.cpp
  2. 23
      libevmjit/ExecutionEngine.cpp
  3. 3
      libevmjit/Utils.h

4
libevmjit/Compiler.cpp

@ -153,8 +153,8 @@ void Compiler::createBasicBlocks(bytesConstRef bytecode)
} }
else else
{ {
std::cerr << "Bad JUMP at PC " << it->first clog(JIT) << "Bad JUMP at PC " << it->first
<< ": " << it->second << " is not a valid PC\n"; << ": " << it->second << " is not a valid PC";
m_directJumpTargets[it->first] = m_badJumpBlock->llvm(); m_directJumpTargets[it->first] = m_badJumpBlock->llvm();
} }
} }

23
libevmjit/ExecutionEngine.cpp

@ -75,9 +75,8 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, u256& _gas, ExtV
auto finalizationStartTime = std::chrono::high_resolution_clock::now(); auto finalizationStartTime = std::chrono::high_resolution_clock::now();
exec->finalizeObject(); exec->finalizeObject();
auto finalizationEndTime = std::chrono::high_resolution_clock::now(); auto finalizationEndTime = std::chrono::high_resolution_clock::now();
std::cerr << "*** Module finalization time: " clog(JIT) << "Module finalization time: "
<< std::chrono::duration_cast<std::chrono::microseconds>(finalizationEndTime - finalizationStartTime).count() << std::chrono::duration_cast<std::chrono::microseconds>(finalizationEndTime - finalizationStartTime).count();
<< std::endl;
// Create fake ExtVM interface // Create fake ExtVM interface
if (!_ext) if (!_ext)
@ -117,9 +116,8 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, u256& _gas, ExtV
returnCode = static_cast<ReturnCode>(result.IntVal.getZExtValue()); returnCode = static_cast<ReturnCode>(result.IntVal.getZExtValue());
auto executionEndTime = std::chrono::high_resolution_clock::now(); auto executionEndTime = std::chrono::high_resolution_clock::now();
std::cerr << "*** Execution time: " clog(JIT) << "Execution time : "
<< std::chrono::duration_cast<std::chrono::microseconds>(executionEndTime - executionStartTime).count() << std::chrono::duration_cast<std::chrono::microseconds>(executionEndTime - executionStartTime).count();
<< std::endl;
} }
else else
@ -128,19 +126,20 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, u256& _gas, ExtV
// Return remaining gas // Return remaining gas
_gas = returnCode == ReturnCode::OutOfGas ? 0 : runtime.getGas(); _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) if (returnCode == ReturnCode::Return)
{ {
returnData = runtime.getReturnData().toVector(); // TODO: It might be better to place is in Runtime interface 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) for (auto it = returnData.begin(), end = returnData.end(); it != end; ++it)
std::cout << std::hex << std::setw(2) << std::setfill('0') << (int)*it << " "; log << std::hex << std::setw(2) << std::setfill('0') << (int)*it << " ";
std::cout << "]\n"; log << "]";
} }
else
std::cout << "RETURN CODE: " << (int)returnCode << std::endl; cslog(JIT) << "RETURN " << (int)returnCode;
return static_cast<int>(returnCode); return static_cast<int>(returnCode);
} }

3
libevmjit/Utils.h

@ -4,6 +4,7 @@
#include <llvm/IR/IRBuilder.h> #include <llvm/IR/IRBuilder.h>
#include <libdevcore/Common.h> #include <libdevcore/Common.h>
#include <libdevcore/Log.h>
namespace dev namespace dev
{ {
@ -12,6 +13,8 @@ namespace eth
namespace jit namespace jit
{ {
struct JIT: public NoteChannel { static const char* name() { return "JIT"; } };
/// Representation of 256-bit value binary compatible with LLVM i256 /// Representation of 256-bit value binary compatible with LLVM i256
// TODO: Replace with h256 // TODO: Replace with h256
struct i256 struct i256

Loading…
Cancel
Save