Skip to content

Commit

Permalink
Fix GC issue when profiling
Browse files Browse the repository at this point in the history
We need to guard these objects on the stack when we profile. This is
because the profiler should see them properly. When we GC in a
checkpoint we have to make sure to update the references for the
profiler.
  • Loading branch information
dbussink committed Feb 7, 2013
1 parent f76e79b commit b0beef5
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 15 deletions.
36 changes: 27 additions & 9 deletions vm/builtin/block_environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,6 @@ namespace rubinius {
}
}

// Check the stack and interrupts here rather than in the interpreter
// loop itself.

GCTokenImpl gct;

if(!state->check_interrupts(gct, frame, frame)) return NULL;

state->checkpoint(gct, frame);

#ifdef RBX_PROFILER
if(unlikely(state->vm()->tooling())) {
Module* mod = scope->module();
Expand All @@ -332,12 +323,39 @@ namespace rubinius {
}
}

OnStack<2> os(state, env, mod);

// Check the stack and interrupts here rather than in the interpreter
// loop itself.

GCTokenImpl gct;

if(!state->check_interrupts(gct, frame, frame)) return NULL;

state->checkpoint(gct, frame);

tooling::BlockEntry method(state, env, mod);
return (*mcode->run)(state, mcode, frame);
} else {
// Check the stack and interrupts here rather than in the interpreter
// loop itself.

GCTokenImpl gct;

if(!state->check_interrupts(gct, frame, frame)) return NULL;

state->checkpoint(gct, frame);
return (*mcode->run)(state, mcode, frame);
}
#else
// Check the stack and interrupts here rather than in the interpreter
// loop itself.

GCTokenImpl gct;

if(!state->check_interrupts(gct, frame, frame)) return NULL;

state->checkpoint(gct, frame);
return (*mcode->run)(state, mcode, frame);
#endif
}
Expand Down
1 change: 1 addition & 0 deletions vm/builtin/nativefunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ namespace rubinius {

#ifdef RBX_PROFILER
if(unlikely(state->vm()->tooling())) {
OnStack<2> os(state, exec, mod);
tooling::MethodEntry method(state, exec, mod, args);
return nfunc->call(state, args, call_frame);
} else {
Expand Down
1 change: 1 addition & 0 deletions vm/builtin/nativemethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ namespace rubinius {
// trying to de-dup it.

if(unlikely(state->vm()->tooling())) {
OnStack<2> os(state, exec, mod);
tooling::MethodEntry method(state, exec, mod, args);
PLACE_EXCEPTION_POINT(ep);

Expand Down
1 change: 1 addition & 0 deletions vm/codegen/field_extract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def output_call(str, call, args)
str << " try {\n"
str << "#ifdef RBX_PROFILER\n"
str << " if(unlikely(state->vm()->tooling())) {\n"
str << " OnStack<2> os(state, exec, mod);\n"
str << " tooling::MethodEntry method(state, exec, mod, args);\n"
str << " ret = #{call}(#{args.join(', ')});\n"
str << " } else {\n"
Expand Down
19 changes: 13 additions & 6 deletions vm/machine_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,20 +615,27 @@ namespace rubinius {
}
#endif

// Check the stack and interrupts here rather than in the interpreter
// loop itself.
if(!state->check_interrupts(gct, frame, frame)) return NULL;

state->checkpoint(gct, frame);

#ifdef RBX_PROFILER
if(unlikely(state->vm()->tooling())) {
OnStack<3> os(state, exec, mod, code);
// Check the stack and interrupts here rather than in the interpreter
// loop itself.
//if(!state->check_interrupts(gct, frame, frame)) return NULL;

//state->checkpoint(gct, frame);

tooling::MethodEntry method(state, exec, mod, args, code);
return (*mcode->run)(state, mcode, frame);
} else {
if(!state->check_interrupts(gct, frame, frame)) return NULL;

state->checkpoint(gct, frame);
return (*mcode->run)(state, mcode, frame);
}
#else
if(!state->check_interrupts(gct, frame, frame)) return NULL;

state->checkpoint(gct, frame);
return (*mcode->run)(state, mcode, frame);
#endif
}
Expand Down
1 change: 1 addition & 0 deletions vm/method_primitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "gen/includes.hpp"
#include "arguments.hpp"
#include "call_frame.hpp"
#include "on_stack.hpp"

#include "instruments/tooling.hpp"

Expand Down

0 comments on commit b0beef5

Please sign in to comment.