Skip to content

Commit

Permalink
Macro for cleaning up RBX_DTRACE_CONST char* usage
Browse files Browse the repository at this point in the history
This has been extracted from #3214
base on feedback from @brixen.
  • Loading branch information
Yorick Peterse committed Dec 15, 2014
1 parent ac50e75 commit 7da4c6d
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 58 deletions.
2 changes: 1 addition & 1 deletion vm/builtin/system.cpp
Expand Up @@ -1826,7 +1826,7 @@ namespace rubinius {
if(RUBINIUS_RUBY_PROBE_ENABLED()) {
char* bytes = reinterpret_cast<char*>(payload->byte_address());
RUBINIUS_RUBY_PROBE(
const_cast<RBX_DTRACE_CONST char*>(bytes),
const_cast<RBX_DTRACE_CHAR_P>(bytes),
payload->byte_size());
return cTrue;
}
Expand Down
4 changes: 2 additions & 2 deletions vm/builtin/thread.cpp
Expand Up @@ -257,7 +257,7 @@ namespace rubinius {
thread_name = tn.str();
}

RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CONST char*>(thread_name.c_str()),
RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CHAR_P>(thread_name.c_str()),
vm->thread_id(), 0);

if(cDebugThreading) {
Expand Down Expand Up @@ -316,7 +316,7 @@ namespace rubinius {
std::cerr << "[LOCK thread " << vm->thread_id() << " exited]\n";
}

RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CONST char*>(thread_name.c_str()),
RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CHAR_P>(thread_name.c_str()),
vm->thread_id(), 0);
shared.gc_independent();
return 0;
Expand Down
16 changes: 8 additions & 8 deletions vm/console.cpp
Expand Up @@ -294,11 +294,11 @@ namespace rubinius {

void Console::process_requests(STATE) {
GCTokenImpl gct;
RBX_DTRACE_CONST char* thread_name =
const_cast<RBX_DTRACE_CONST char*>("rbx.console.request");
RBX_DTRACE_CHAR_P thread_name =
const_cast<RBX_DTRACE_CHAR_P>("rbx.console.request");
request_vm_->set_name(thread_name);

RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CONST char*>(thread_name),
RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);

request_running_ = true;
Expand Down Expand Up @@ -330,7 +330,7 @@ namespace rubinius {

state->gc_dependent(gct, 0);

RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CONST char*>(thread_name),
RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);
}

Expand Down Expand Up @@ -360,11 +360,11 @@ namespace rubinius {

void Console::process_responses(STATE) {
GCTokenImpl gct;
RBX_DTRACE_CONST char* thread_name =
const_cast<RBX_DTRACE_CONST char*>("rbx.console.response");
RBX_DTRACE_CHAR_P thread_name =
const_cast<RBX_DTRACE_CHAR_P>("rbx.console.response");
response_vm_->set_name(thread_name);

RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CONST char*>(thread_name),
RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);

response_running_ = true;
Expand Down Expand Up @@ -414,7 +414,7 @@ namespace rubinius {

response_running_ = false;

RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CONST char*>(thread_name),
RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);
}
}
Expand Down
16 changes: 9 additions & 7 deletions vm/dtrace/dtrace.h
@@ -1,23 +1,25 @@
#ifndef RUBINIUS_DTRACE_H
#define RUBINIUS_DTRACE_H

#define RBX_DTRACE_CHAR_P RBX_DTRACE_CONST char*

#ifdef HAVE_DTRACE
#include "dtrace/probes.h"

#define RUBINIUS_METHOD_HOOK(probe, state, mod, method, previous) \
{ \
if(RUBINIUS_METHOD_##probe##_ENABLED()) { \
RBX_DTRACE_CONST char* module_name = \
const_cast<RBX_DTRACE_CONST char*>(mod->debug_str(state).c_str()); \
RBX_DTRACE_CONST char* code_name = \
const_cast<RBX_DTRACE_CONST char*>(method->debug_str(state).c_str()); \
RBX_DTRACE_CONST char* file_name = \
const_cast<RBX_DTRACE_CONST char*>("<unknown>"); \
RBX_DTRACE_CHAR_P module_name = \
const_cast<RBX_DTRACE_CHAR_P>(mod->debug_str(state).c_str()); \
RBX_DTRACE_CHAR_P code_name = \
const_cast<RBX_DTRACE_CHAR_P>(method->debug_str(state).c_str()); \
RBX_DTRACE_CHAR_P file_name = \
const_cast<RBX_DTRACE_CHAR_P>("<unknown>"); \
int line = 0; \
if(previous) { \
Symbol* file = previous->file(state); \
if(!file->nil_p()) { \
file_name = const_cast<RBX_DTRACE_CONST char*>(file->debug_str(state).c_str()); \
file_name = const_cast<RBX_DTRACE_CHAR_P>(file->debug_str(state).c_str()); \
} \
line = previous->line(state); \
} \
Expand Down
8 changes: 4 additions & 4 deletions vm/gc/finalize.cpp
Expand Up @@ -171,11 +171,11 @@ namespace rubinius {

void FinalizerHandler::perform(STATE) {
GCTokenImpl gct;
RBX_DTRACE_CONST char* thread_name =
const_cast<RBX_DTRACE_CONST char*>("rbx.finalizer");
RBX_DTRACE_CHAR_P thread_name =
const_cast<RBX_DTRACE_CHAR_P>("rbx.finalizer");
vm_->set_name(thread_name);

RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CONST char*>(thread_name),
RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);

state->vm()->thread->hard_unlock(state, gct, 0);
Expand Down Expand Up @@ -211,7 +211,7 @@ namespace rubinius {
finalize(state);
next_process_item();
}
RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CONST char*>(thread_name),
RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);
}

Expand Down
6 changes: 3 additions & 3 deletions vm/gc/immix_marker.cpp
Expand Up @@ -118,10 +118,10 @@ namespace rubinius {

void ImmixMarker::perform(STATE) {
GCTokenImpl gct;
RBX_DTRACE_CONST char* thread_name = const_cast<RBX_DTRACE_CONST char*>("rbx.immix");
RBX_DTRACE_CHAR_P thread_name = const_cast<RBX_DTRACE_CHAR_P>("rbx.immix");
vm_->set_name(thread_name);

RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CONST char*>(thread_name),
RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);

state->vm()->thread->hard_unlock(state, gct, 0);
Expand Down Expand Up @@ -184,7 +184,7 @@ namespace rubinius {
state->memory()->clear_mature_mark_in_progress();
running_ = false;

RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CONST char*>(thread_name),
RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);
}
}
48 changes: 24 additions & 24 deletions vm/llvm/jit_compiler.cpp
Expand Up @@ -179,13 +179,13 @@ namespace jit {

#ifdef HAVE_DTRACE
if(RUBINIUS_JIT_FUNCTION_BEGIN_ENABLED()) {
RBX_DTRACE_CONST char* class_name =
const_cast<RBX_DTRACE_CONST char*>(
RBX_DTRACE_CHAR_P class_name =
const_cast<RBX_DTRACE_CHAR_P>(
ctx_->llvm_state()->enclosure_name(code).c_str());
RBX_DTRACE_CONST char* method_name =
const_cast<RBX_DTRACE_CONST char*>("<block>");
RBX_DTRACE_CONST char* file_name =
const_cast<RBX_DTRACE_CONST char*>(
RBX_DTRACE_CHAR_P method_name =
const_cast<RBX_DTRACE_CHAR_P>("<block>");
RBX_DTRACE_CHAR_P file_name =
const_cast<RBX_DTRACE_CHAR_P>(
ctx_->llvm_state()->symbol_debug_str(code->file()).c_str());
int line = code->start_line();
RUBINIUS_JIT_FUNCTION_BEGIN(class_name, method_name, file_name, line);
Expand All @@ -210,13 +210,13 @@ namespace jit {

#ifdef HAVE_DTRACE
if(RUBINIUS_JIT_FUNCTION_END_ENABLED()) {
RBX_DTRACE_CONST char* class_name =
const_cast<RBX_DTRACE_CONST char*>(
RBX_DTRACE_CHAR_P class_name =
const_cast<RBX_DTRACE_CHAR_P>(
ctx_->llvm_state()->enclosure_name(code).c_str());
RBX_DTRACE_CONST char* method_name =
const_cast<RBX_DTRACE_CONST char*>("<block>");
RBX_DTRACE_CONST char* file_name =
const_cast<RBX_DTRACE_CONST char*>(
RBX_DTRACE_CHAR_P method_name =
const_cast<RBX_DTRACE_CHAR_P>("<block>");
RBX_DTRACE_CHAR_P file_name =
const_cast<RBX_DTRACE_CHAR_P>(
ctx_->llvm_state()->symbol_debug_str(code->file()).c_str());
int line = code->start_line();
RUBINIUS_JIT_FUNCTION_END(class_name, method_name, file_name, line);
Expand All @@ -240,14 +240,14 @@ namespace jit {

#ifdef HAVE_DTRACE
if(RUBINIUS_JIT_FUNCTION_BEGIN_ENABLED()) {
RBX_DTRACE_CONST char* class_name =
const_cast<RBX_DTRACE_CONST char*>(
RBX_DTRACE_CHAR_P class_name =
const_cast<RBX_DTRACE_CHAR_P>(
ctx_->llvm_state()->enclosure_name(code).c_str());
RBX_DTRACE_CONST char* method_name =
const_cast<RBX_DTRACE_CONST char*>(
RBX_DTRACE_CHAR_P method_name =
const_cast<RBX_DTRACE_CHAR_P>(
ctx_->llvm_state()->symbol_debug_str(code->name()).c_str());
RBX_DTRACE_CONST char* file_name =
const_cast<RBX_DTRACE_CONST char*>(
RBX_DTRACE_CHAR_P file_name =
const_cast<RBX_DTRACE_CHAR_P>(
ctx_->llvm_state()->symbol_debug_str(code->file()).c_str());
int line = code->start_line();
RUBINIUS_JIT_FUNCTION_BEGIN(class_name, method_name, file_name, line);
Expand All @@ -272,14 +272,14 @@ namespace jit {

#ifdef HAVE_DTRACE
if(RUBINIUS_JIT_FUNCTION_END_ENABLED()) {
RBX_DTRACE_CONST char* class_name =
const_cast<RBX_DTRACE_CONST char*>(
RBX_DTRACE_CHAR_P class_name =
const_cast<RBX_DTRACE_CHAR_P>(
ctx_->llvm_state()->enclosure_name(code).c_str());
RBX_DTRACE_CONST char* method_name =
const_cast<RBX_DTRACE_CONST char*>(
RBX_DTRACE_CHAR_P method_name =
const_cast<RBX_DTRACE_CHAR_P>(
ctx_->llvm_state()->symbol_debug_str(code->name()).c_str());
RBX_DTRACE_CONST char* file_name =
const_cast<RBX_DTRACE_CONST char*>(
RBX_DTRACE_CHAR_P file_name =
const_cast<RBX_DTRACE_CHAR_P>(
ctx_->llvm_state()->symbol_debug_str(code->file()).c_str());
int line = code->start_line();
RUBINIUS_JIT_FUNCTION_END(class_name, method_name, file_name, line);
Expand Down
4 changes: 2 additions & 2 deletions vm/llvm/state.cpp
Expand Up @@ -251,10 +251,10 @@ namespace rubinius {

void LLVMState::perform(STATE) {
GCTokenImpl gct;
RBX_DTRACE_CONST char* thread_name = const_cast<RBX_DTRACE_CONST char*>("rbx.jit");
RBX_DTRACE_CHAR_P thread_name = const_cast<RBX_DTRACE_CHAR_P>("rbx.jit");
vm_->set_name(thread_name);

RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CONST char*>(thread_name),
RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);

state->vm()->thread->hard_unlock(state, gct, 0);
Expand Down
8 changes: 4 additions & 4 deletions vm/metrics.cpp
Expand Up @@ -483,11 +483,11 @@ namespace rubinius {

void Metrics::process_metrics(STATE) {
GCTokenImpl gct;
RBX_DTRACE_CONST char* thread_name =
const_cast<RBX_DTRACE_CONST char*>("rbx.metrics");
RBX_DTRACE_CHAR_P thread_name =
const_cast<RBX_DTRACE_CHAR_P>("rbx.metrics");
vm_->set_name(thread_name);

RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CONST char*>(thread_name),
RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);

state->vm()->thread->hard_unlock(state, gct, 0);
Expand Down Expand Up @@ -545,7 +545,7 @@ namespace rubinius {

timer_->clear();

RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CONST char*>(thread_name),
RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);
}
}
Expand Down
6 changes: 3 additions & 3 deletions vm/signal.cpp
Expand Up @@ -149,10 +149,10 @@ namespace rubinius {
#endif

GCTokenImpl gct;
RBX_DTRACE_CONST char* thread_name = const_cast<RBX_DTRACE_CONST char*>("rbx.signal");
RBX_DTRACE_CHAR_P thread_name = const_cast<RBX_DTRACE_CHAR_P>("rbx.signal");
vm_->set_name(thread_name);

RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CONST char*>(thread_name),
RUBINIUS_THREAD_START(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);

state->vm()->thread->hard_unlock(state, gct, 0);
Expand All @@ -175,7 +175,7 @@ namespace rubinius {

target_->wakeup(state, gct, 0);
}
RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CONST char*>(thread_name),
RUBINIUS_THREAD_STOP(const_cast<RBX_DTRACE_CHAR_P>(thread_name),
state->vm()->thread_id(), 1);
}

Expand Down

0 comments on commit 7da4c6d

Please sign in to comment.