forked from smarr/SOMpp
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Micro optimizations of interpreter loop (#47)
- make RemainingStackSize inlinable - mark an out-of-bounds check as unlikely - make ErrorExit and Quit non-inlinable This seem to give a surprising amount of speed: median -3% (min. -25%, max. 10%) https://rebench.dev/SOMpp/compare/4ba47cfe11c5e5b4d5379c36de923faf601ffc93..8866a58999526c54a50fc5d4e4c948ee94176a89
- Loading branch information
Showing
27 changed files
with
110 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,50 @@ | ||
#include "Print.h" | ||
|
||
#include <cstdlib> | ||
#include <iostream> | ||
#include <mutex> | ||
#include <string> | ||
|
||
#include "../misc/defs.h" | ||
#include "LogAllocation.h" | ||
#include "Universe.h" | ||
|
||
using namespace std; | ||
|
||
static mutex output_mutex; | ||
|
||
void Print(StdString str) { | ||
void Print(std::string str) { | ||
lock_guard<mutex> lock(output_mutex); | ||
cout << str << flush; | ||
} | ||
|
||
void ErrorPrint(StdString str) { | ||
void ErrorPrint(std::string str) { | ||
lock_guard<mutex> lock(output_mutex); | ||
cerr << str << flush; | ||
} | ||
|
||
void Print(const char* str) { | ||
lock_guard<mutex> lock(output_mutex); | ||
cout << str << flush; | ||
} | ||
|
||
void ErrorPrint(const char* str) { | ||
lock_guard<mutex> lock(output_mutex); | ||
cerr << str << flush; | ||
} | ||
|
||
__attribute__((noreturn)) __attribute__((noinline)) void ErrorExit( | ||
const char* err) { | ||
ErrorPrint("Runtime error: " + StdString(err) + "\n"); | ||
Quit(ERR_FAIL); | ||
} | ||
|
||
__attribute__((noreturn)) __attribute__((noinline)) void Quit(long err) { | ||
ErrorPrint("Time spent in GC: [" + | ||
to_string(Timer::GCTimer->GetTotalTime()) + "] msec\n"); | ||
|
||
Universe::Shutdown(); | ||
|
||
OutputAllocationLogFile(); | ||
exit((int)err); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
#pragma once | ||
|
||
#include "../misc/defs.h" | ||
#include <string> | ||
|
||
void Print(StdString str); | ||
void ErrorPrint(StdString str); | ||
void Print(std::string str); | ||
void Print(const char* str); | ||
void ErrorPrint(std::string str); | ||
void ErrorPrint(const char* str); | ||
|
||
__attribute__((noreturn)) __attribute__((noinline)) void Quit(long); | ||
__attribute__((noreturn)) __attribute__((noinline)) void ErrorExit(const char*); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.