Skip to content

Commit

Permalink
Merge 40be96b into 657f8b2
Browse files Browse the repository at this point in the history
  • Loading branch information
kpp committed Aug 3, 2015
2 parents 657f8b2 + 40be96b commit 8529ab2
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 185 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ if (USE_LLVM)
endif()

add_executable(llst src/main.cpp src/vm.cpp)
target_link_libraries(llst standart_set memory_managers stapi ${READLINE_LIBS_TO_LINK} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
add_dependencies(llst image)

if (USE_LLVM)
target_link_libraries(llst jit ${LLVM_LIBS} ${LLVM_LD_FLAGS})
endif()
target_link_libraries(llst standart_set memory_managers stapi ${READLINE_LIBS_TO_LINK} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})

set(changelog_compressed "${CMAKE_CURRENT_BINARY_DIR}/changelog.gz")
gzip_compress("compress_changelog" "${CMAKE_CURRENT_SOURCE_DIR}/ChangeLog" ${changelog_compressed})
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ By default LLST is built without LLVM support. If you wish to enable it, you sho
~/llst/build $ make
```

You should have LLVM 3.1 installed and llvm-config or llvm-config-3.1 be accessible from your environment.
You should have LLVM 3.3 installed and llvm-config or llvm-config-3.3 be accessible from your environment.

Unit tests
====

```
~/llst/build $ cmake -DBUILD_TESTS=ON ..
~/llst/build $ make check
```

License
=======
Expand Down
4 changes: 4 additions & 0 deletions doc/llst.1.en.pod
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ FIXME: Provide imageBuilder with the package (you may find the binary in sources

Max size of the VM heap. VM will not increase the size of the heap if maximum size is reached.

=item B<--mm_type=>type

Choose memory manager. nc - NonCollect, copy - Stop-and-Copy. Default is copy.

=item B<--help>

Display short help and quit
Expand Down
74 changes: 38 additions & 36 deletions include/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <string>
#include <sstream>
#include <math.h>
#include <math.h>
using std::stringstream;
#include <time.h>
#include <iomanip>
Expand All @@ -17,7 +17,6 @@ using std::stringstream;
#endif



//analogue of c++11 ratio from chrono.h
template <int NUM, int DEN>
struct TRatio
Expand All @@ -40,77 +39,80 @@ enum SuffixMode {SNONE, SSHORT, SFULL};

//analogue of c++11 duration
template <typename RATIO>
class TDuration {
class TDuration
{
private:
double value;
public:
//argument: duration in target ratio value
TDuration(double duration){
value = duration;
}

TDuration() {value = 0;}

bool isEmpty() { return value == 0;}

template <typename RATIO2> TDuration<RATIO2> convertTo(){
TDuration() : value(0) { }
TDuration(double duration) : value(duration) { }

bool isEmpty() const { return value == 0;}

template <typename RATIO2> TDuration<RATIO2> convertTo() const {
return TDuration<RATIO2>(value * (RATIO::num * RATIO2::den) / (double)(RATIO::den * RATIO2::num));
}
int toInt(){
int toInt() const {
return floor(value);
}
double toDouble(){
double toDouble() const {
return value;
}
std::string toString(SuffixMode sMode = SNONE, int symbolsAfterPoint = 0,
const char* pointSymbol = ".", const char* spaceSymbol = " "){
stringstream ss;
std::string toString(
SuffixMode sMode = SNONE,
int symbolsAfterPoint = 0,
const char* pointSymbol = ".",
const char* spaceSymbol = " "
) const {
stringstream ss;
ss << floor(value);
if(symbolsAfterPoint)
ss << pointSymbol << std::setfill('0') << std::setw(symbolsAfterPoint)
if (symbolsAfterPoint)
ss << pointSymbol << std::setfill('0') << std::setw(symbolsAfterPoint)
<< floor((value - floor(value)) * pow(10.0, symbolsAfterPoint));
if(sMode != SNONE)
if (sMode != SNONE)
ss << spaceSymbol << getSuffix(sMode);
return ss.str();
}
std::string getSuffix(SuffixMode sMode);
std::ostream& operator<<(std::ostream& os){
os << toString();
std::string getSuffix(SuffixMode sMode) const;

std::ostream& operator<<(std::ostream& os) const {
os << this->toString();
return os;
}

bool operator< (const TDuration<RATIO>& rhs){
bool operator< (const TDuration& rhs) const {
return value < rhs.value;
}

TDuration<RATIO> operator+(const TDuration<RATIO>& rhs){
return TDuration<RATIO>(value + rhs.value);
TDuration operator+(const TDuration& rhs) const {
return TDuration(value + rhs.value);
}

TDuration<RATIO> operator-(const TDuration<RATIO>& rhs){
return TDuration<RATIO>(value - rhs.value);
TDuration operator-(const TDuration& rhs) const {
return TDuration(value - rhs.value);
}

bool operator> (const TDuration<RATIO>& rhs){return !(operator< (rhs));}
bool operator> (const TDuration& rhs) const {
return !(operator< (rhs)); // FIXME: it works as >=
}

friend class Timer;
};


class Timer {
private:
systemTimeValue timeCreate;
double getDiffSec();
systemTimeValue timeCreate;
double getDiffSec() const;
public:
//timer which count time from specified unix-time.
Timer(time_t time);
//default constructor is implicit Timer::now()
Timer(){ this->start();}
static Timer now() {Timer t; return t;}
Timer(){ this->start(); }
static Timer now() { return Timer(); }
void start();
template <typename RATIO>
TDuration<RATIO> get(){
TDuration<RATIO> get() const {
return TDuration<TSec>(getDiffSec()).convertTo<RATIO>();
}
};
Expand Down
1 change: 0 additions & 1 deletion include/jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ class MethodCompiler {
private:
JITRuntime& m_runtime;
llvm::Module* m_JITModule;
// std::map<uint32_t, llvm::BasicBlock*> m_targetToBlockMap;
void scanForBranches(TJITContext& jit, st::ParsedBytecode* source, uint32_t byteCount = 0);
bool scanForBlockReturn(TJITContext& jit, uint32_t byteCount = 0);

Expand Down
1 change: 0 additions & 1 deletion include/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,4 +523,3 @@ class Image::ImageWriter
};

#endif

1 change: 0 additions & 1 deletion src/BakerMemoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,4 +530,3 @@ TMemoryManagerInfo BakerMemoryManager::getStat()
{
return m_memoryInfo;
}

12 changes: 0 additions & 12 deletions src/ControlGraphVisualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,7 @@ ControlGraphVisualizer::ControlGraphVisualizer(st::ControlGraph* graph, const st
}

bool ControlGraphVisualizer::visitDomain(st::ControlDomain& /*domain*/) {
// if (!firstDomain)
// m_stream << "\t} \n" << std::endl; // closing subgraph

firstDomain = false;

// m_stream << "\n\tsubgraph cluster_" << domain.getBasicBlock()->getOffset() << " {\n";
// return st::NodeVisitor::visitDomain(domain);
return false;
}

Expand Down Expand Up @@ -113,9 +107,6 @@ bool ControlGraphVisualizer::visitNode(st::ControlNode& node) {

m_stream << "\t\t" << incoming.domain->getTerminator()->getIndex() << " -> " << phi->getIndex() << " ["
<< "style=\"invis\" constraint=true ];\n";

// m_stream << "\t\t" << node.getIndex() << " -> " << incoming.value->getIndex() << " ["
// << " labelfloat=true color=\"blue\" fontcolor=\"blue\" style=\"dashed\" constraint=false ];\n";
}
}

Expand Down Expand Up @@ -191,9 +182,6 @@ void ControlGraphVisualizer::markNode(st::ControlNode* node) {
}

void ControlGraphVisualizer::finish() {
// if (!firstDomain)
// m_stream << "\t} \n";

m_stream << "} \n";
m_stream.close();
}
20 changes: 11 additions & 9 deletions src/GCLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,37 @@ GCLogger::GCLogger(const char* fileName):
m_logFile(fileName, std::fstream::out)
{}

GCLogger::~GCLogger(){
GCLogger::~GCLogger() {
m_logFile.flush();
}

enum MeasuringConstants { bytes_in_kb = 1024 };


void GCLogger::writeLogLine(TMemoryManagerEvent event){
void GCLogger::writeLogLine(TMemoryManagerEvent event) {
m_logFile << event.begin.toString(SNONE, 3)
<< ": [" << event.eventName << " ";
if(!event.heapInfo.empty()){
if (!event.heapInfo.empty())
{
TMemoryManagerHeapInfo eh = event.heapInfo;
m_logFile << eh.usedHeapSizeBeforeCollect / bytes_in_kb << "K->"
<< eh.usedHeapSizeAfterCollect / bytes_in_kb << "K("
<< eh.totalHeapSize / bytes_in_kb << "K)";
for(std::list<TMemoryManagerHeapEvent>::iterator i = eh.heapEvents.begin(); i != eh.heapEvents.end(); i++){
for (std::list<TMemoryManagerHeapEvent>::iterator i = eh.heapEvents.begin(); i != eh.heapEvents.end(); i++) {
m_logFile << "[" << i->eventName << ": "
<< i->usedHeapSizeBeforeCollect / bytes_in_kb << "K->"
<< i->usedHeapSizeAfterCollect / bytes_in_kb << "K("
<< i->totalHeapSize / bytes_in_kb << "K)";
if(!i->timeDiff.isEmpty())
if ( !i->timeDiff.isEmpty() )
m_logFile << ", " << i->timeDiff.toString(SSHORT, 6);
m_logFile << "] ";
}
}
if(!event.timeDiff.isEmpty())
if(!event.timeDiff.isEmpty()) {
m_logFile << ", " << event.timeDiff.toString(SSHORT, 6);
//gc-viewer see error when no delay or delay is 0.0
else
m_logFile << ", 0.000001 secs";
} else {
// gc-viewer reports error when there is no delay or delay is 0.0
m_logFile << ", 0.000001 secs";
}
m_logFile << "]\n";
}
21 changes: 2 additions & 19 deletions src/JITRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,19 +310,14 @@ TObject* JITRuntime::invokeBlock(TBlock* block, TContext* callingContext, bool o
// If function was not found then the whole method needs compilation.

// Compiling function and storing it to the table for further use

// Function* methodFunction = m_methodCompiler->compileMethod(block->method);
// blockFunction = m_JITModule->getFunction(blockFunctionName);
blockFunction = m_methodCompiler->compileBlock(block);

if (/*!methodFunction ||*/ !blockFunction) {
if (!blockFunction) {
// Something is really wrong!
outs() << "JIT: Fatal error in invokeBlock for " << blockFunctionName << "\n";
std::exit(1);
}

// outs() << *blockFunction << "\n";

verifyModule(*m_JITModule, AbortProcessAction);

optimizeFunction(blockFunction, true);
Expand Down Expand Up @@ -380,8 +375,6 @@ TObject* JITRuntime::sendMessage(TContext* callingContext, TSymbol* message, TOb
// Compiling function and storing it to the table for further use
methodFunction = m_methodCompiler->compileMethod(method);

// outs() << *methodFunction << "\n";

verifyModule(*m_JITModule, AbortProcessAction);

optimizeFunction(methodFunction, true);
Expand Down Expand Up @@ -433,9 +426,6 @@ void JITRuntime::updateHotSites(TMethodFunction methodFunction, TContext* callin
if (!callSiteIndex)
return;

// if (callingContext->getClass() == globals.blockClass)
// static_cast<TBlock*>(callingContext)->;

TMethodFunction callerMethodFunction = lookupFunctionInCache(callingContext->method);
// TODO reload cache if callerMethodFunction was popped out

Expand Down Expand Up @@ -502,8 +492,6 @@ void JITRuntime::patchHotMethods()
++iSite;
}

// outs() << "Patched code: \n" << *hotMethod->methodFunction << "\n";

outs() << "done. Verifying ...";

verifyModule(*m_JITModule, AbortProcessAction);
Expand Down Expand Up @@ -532,8 +520,6 @@ void JITRuntime::patchHotMethods()

verifyModule(*m_JITModule, AbortProcessAction);

// outs() << "Optimized code: \n" << *hotMethod->methodFunction;

outs() << "done.\n";
}

Expand All @@ -557,9 +543,6 @@ void JITRuntime::patchHotMethods()
outs() << "Compiling machine code for " << hotMethod->methodFunction->getName().str() << " ...";
m_executionEngine->recompileAndRelinkFunction(hotMethod->methodFunction);


// outs() << "Final code: \n" << *hotMethod->methodFunction;

outs() << "done.\n";
}

Expand Down Expand Up @@ -965,7 +948,7 @@ void JITRuntime::initializePassManager() {
m_functionPassManager->add(createDeadStoreEliminationPass());

m_functionPassManager->add(createLLSTPass()); // FIXME direct calls break the logic
// //If llstPass removed GC roots, we may try DCE again
//If llstPass removed GC roots, we may try DCE again
m_functionPassManager->add(createDeadCodeEliminationPass());
m_functionPassManager->add(createDeadStoreEliminationPass());

Expand Down
Loading

0 comments on commit 8529ab2

Please sign in to comment.