Browse Source

Simplify JIT logs

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

4
libevmjit/Compiler.cpp

@ -2,6 +2,7 @@
#include "Compiler.h" #include "Compiler.h"
#include <fstream> #include <fstream>
#include <chrono>
#include <boost/dynamic_bitset.hpp> #include <boost/dynamic_bitset.hpp>
@ -152,6 +153,7 @@ void Compiler::createBasicBlocks(bytes const& _bytecode)
std::unique_ptr<llvm::Module> Compiler::compile(bytes const& _bytecode) std::unique_ptr<llvm::Module> Compiler::compile(bytes const& _bytecode)
{ {
auto compilationStartTime = std::chrono::high_resolution_clock::now();
auto module = std::unique_ptr<llvm::Module>(new llvm::Module("main", m_builder.getContext())); auto module = std::unique_ptr<llvm::Module>(new llvm::Module("main", m_builder.getContext()));
// Create main function // Create main function
@ -242,6 +244,8 @@ std::unique_ptr<llvm::Module> Compiler::compile(bytes const& _bytecode)
fpManager.run(*m_mainFunc); fpManager.run(*m_mainFunc);
} }
auto compilationEndTime = std::chrono::high_resolution_clock::now();
clog(JIT) << "JIT: " << std::chrono::duration_cast<std::chrono::milliseconds>(compilationEndTime - compilationStartTime).count();
return module; return module;
} }

21
libevmjit/ExecutionEngine.cpp

@ -69,11 +69,12 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, RuntimeData* _da
return -1; // FIXME: Handle internal errors return -1; // FIXME: Handle internal errors
_module.release(); // Successfully created llvm::ExecutionEngine takes ownership of the module _module.release(); // Successfully created llvm::ExecutionEngine takes ownership of the module
auto finalizationStartTime = std::chrono::high_resolution_clock::now(); auto finalizationStartTime = std::chrono::high_resolution_clock::now(); // FIXME: It's not compilation time
exec->finalizeObject(); exec->finalizeObject();
auto finalizationEndTime = std::chrono::high_resolution_clock::now(); auto finalizationEndTime = std::chrono::high_resolution_clock::now();
clog(JIT) << "Module finalization time: " clog(JIT) << " + " << std::chrono::duration_cast<std::chrono::milliseconds>(finalizationEndTime - finalizationStartTime).count();
<< std::chrono::duration_cast<std::chrono::microseconds>(finalizationEndTime - finalizationStartTime).count();
auto executionStartTime = std::chrono::high_resolution_clock::now();
auto entryFunc = module->getFunction("main"); auto entryFunc = module->getFunction("main");
if (!entryFunc) if (!entryFunc)
@ -85,21 +86,15 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, RuntimeData* _da
auto r = setjmp(buf); auto r = setjmp(buf);
if (r == 0) if (r == 0)
{ {
auto executionStartTime = std::chrono::high_resolution_clock::now();
auto result = exec->runFunction(entryFunc, {{}, llvm::GenericValue(&runtime)}); auto result = exec->runFunction(entryFunc, {{}, llvm::GenericValue(&runtime)});
returnCode = static_cast<ReturnCode>(result.IntVal.getZExtValue()); returnCode = static_cast<ReturnCode>(result.IntVal.getZExtValue());
auto executionEndTime = std::chrono::high_resolution_clock::now();
clog(JIT) << "Execution time : "
<< std::chrono::duration_cast<std::chrono::microseconds>(executionEndTime - executionStartTime).count();
} }
else else
returnCode = static_cast<ReturnCode>(r); returnCode = static_cast<ReturnCode>(r);
clog(JIT) << "Max stack size: " << Stack::maxStackSize; auto executionEndTime = std::chrono::high_resolution_clock::now();
clog(JIT) << " + " << std::chrono::duration_cast<std::chrono::milliseconds>(executionEndTime - executionStartTime).count() << " ms ";
//clog(JIT) << "Max stack size: " << Stack::maxStackSize;
if (returnCode == ReturnCode::Return) if (returnCode == ReturnCode::Return)
{ {
@ -114,6 +109,8 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, RuntimeData* _da
else else
clog(JIT) << "RETURN " << (int)returnCode; clog(JIT) << "RETURN " << (int)returnCode;
clog(JIT) << "\n";
return static_cast<int>(returnCode); return static_cast<int>(returnCode);
} }

2
libevmjit/Utils.h

@ -14,7 +14,7 @@ namespace jit
struct JIT: public NoteChannel { static const char* name() { return "JIT"; } }; struct JIT: public NoteChannel { static const char* name() { return "JIT"; } };
#define clog(CHANNEL) std::cerr << CHANNEL::name() << ": " #define clog(CHANNEL) std::cerr
/// 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

Loading…
Cancel
Save