Skip to content

Commit

Permalink
trying to get it to merge on ret from method
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewfl committed Aug 3, 2016
1 parent 0e5751b commit e5eadf8
Show file tree
Hide file tree
Showing 8 changed files with 442 additions and 47 deletions.
193 changes: 193 additions & 0 deletions crash.org

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion make
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def release():
RELEASE = True
C_FLAGS = C_FLAGS.replace('-O0', '-O2')
C_FLAGS = C_FLAGS.replace('-ggdb', '')
C_FLAGS += ' -DNDEBUG -fdata-sections -ffunction-sections -flto '
C_FLAGS += ' -DNDEBUG -DRED_RELEASE -fdata-sections -ffunction-sections -flto '
LD_FLAGS += '-flto ' #-Wl,--gc-sections -Wl,--print-gc-sections '
clean()
build()
Expand Down
19 changes: 14 additions & 5 deletions src/config.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#ifndef REDMAGIC_CONFIG_H_
#define REDMAGIC_CONFIG_H_

// configure the system to perform more traces to attempt to debug
#define CONF_DEBUG_BUILD

#ifndef CONF_DEBUG_BUILD
#ifdef RED_RELEASE
# define CONF_RELEASE_BUILD
#endif

#ifdef CONF_RELEASE_BUILD
# define
# define CONF_BUILD_TOGGLE(debug, release) release
#else
// configure the system to perform more traces to attempt to debug
# define CONF_DEBUG_BUILD
# define CONF_BUILD_TOGGLE(debug, release) debug
#endif


// the number of loops that are require to occure before it traces a loop
#define CONF_NUMBER_OF_JUMPS_BEFORE_TRACE CONF_BUILD_TOGGLE(10, 150)
#define CONF_NUMBER_OF_JUMPS_BEFORE_TRACE CONF_BUILD_TOGGLE(50, 150)

// redmagic will attempt inline forward jumps which is useful in cases like: `if(a || b || c...)` where many conditional jumps
// will merge to the same point, but it may require back tracking in a lot of cases which may be slower
Expand All @@ -26,7 +30,7 @@

// makes it print all the instructions processed and extra info
#ifdef CONF_DEBUG_BUILD
# define CONF_VERBOSE
//# define CONF_VERBOSE
#endif

// support aborting the system after some fixed number of instruction have been processed, see tools/bisect for debugging with this
Expand All @@ -38,6 +42,7 @@
// somehow python is not hitting the fellthrough trace for some traces that it starts
// unable to determine where it should actually be performing this, so we are just makeing the end of the branchable frame
// close out any traces that were created in this frame
// ^^^ this might have been a bug with the intergration, but now it is using this auto closing as a "feature"
#define CONF_ALLOW_UNCLOSED_TRACES


Expand All @@ -47,4 +52,8 @@

#define CONF_ESTIMATE_INSTRUCTIONS

// instead of taking a trace all the way to the bottom of the loop, attempt to merge back at the ret inside of a method
// the idea being that most of the branches that we can end up helping will be inside the main interpreter loop
#define CONF_MERGE_BACK_ON_RET

#endif // REDMAGIC_CONFIG_H_
5 changes: 3 additions & 2 deletions src/jit_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ namespace redmagic {
public:
struct branch_info {
int count = 0;
int count_fellthrough = 0;
Tracer *tracer = nullptr;
void *starting_point = nullptr;
bool disabled = false;
Expand All @@ -107,7 +108,7 @@ namespace redmagic {
uint64_t *trace_loop_counter = nullptr;

#ifdef CONF_USE_TIMERS
timespec first_observed_time;
timespec first_observed_time = {0,0};
#endif

#ifdef CONF_ESTIMATE_INSTRUCTIONS
Expand Down Expand Up @@ -322,7 +323,7 @@ namespace redmagic {
static inline uint64_t RDTSC() {
unsigned int hi, lo;
__asm__ volatile("rdtsc" : "=a" (lo), "=d" (hi));
return ((uint64_t)hi << 32) | lo;
return (((uint64_t)hi) << 32) | lo;
}

extern thread_local uint64_t last_thread_instructions;
Expand Down
Loading

0 comments on commit e5eadf8

Please sign in to comment.