Skip to content

Commit

Permalink
Showing 3 changed files with 36 additions and 1 deletion.
31 changes: 31 additions & 0 deletions machine/machine_code.cpp
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ namespace rubinius {
, _constant_cache_count_(0)
, _references_count_(0)
, _references_(NULL)
, _description_(NULL)
, unspecialized(NULL)
, fallback(NULL)
, execute_status_(eInterpret)
@@ -105,6 +106,8 @@ namespace rubinius {
#endif
delete[] references();
}

if(description()) delete description();
}

int MachineCode::size() {
@@ -327,6 +330,34 @@ namespace rubinius {
state->memory()->write_barrier(code, constant_cache);
}

void MachineCode::set_description(STATE) {
if(description()) return;

CallFrame* call_frame = state->vm()->call_frame();

Class* klass = call_frame->self()->class_object(state);
Module* method_module = call_frame->module();

std::string* desc = new std::string();

if(kind_of<SingletonClass>(method_module)) {
desc->append(method_module->debug_str(state));
desc->append(".");
} else if(method_module != klass) {
desc->append(method_module->debug_str(state));
desc->append("(");
desc->append(klass->debug_str(state));
desc->append(")");
} else {
desc->append(klass->debug_str(state));
desc->append("#");
}

desc->append(name()->cpp_str(state));

description(desc);
}

// Argument handler implementations

// For when the method expects no arguments at all (no splat, nothing)
3 changes: 3 additions & 0 deletions machine/machine_code.hpp
Original file line number Diff line number Diff line change
@@ -77,6 +77,7 @@ namespace rubinius {
attr_field(constant_cache_count, size_t);
attr_field(references_count, size_t);
attr_field(references, size_t*);
attr_field(description, std::string*);

Specialization specializations[cMaxSpecializations];
executor unspecialized;
@@ -149,6 +150,8 @@ namespace rubinius {
void store_call_site(STATE, CompiledCode* code, int ip, CallSite* call_site);
void store_constant_cache(STATE, CompiledCode* code, int ip, ConstantCache* constant_cache);

void set_description(STATE);

void specialize(STATE, CompiledCode* original, TypeInfo* ti);
static Object* execute(STATE, Executable* exec, Module* mod, Arguments& args);

3 changes: 2 additions & 1 deletion machine/vm.cpp
Original file line number Diff line number Diff line change
@@ -311,6 +311,7 @@ namespace rubinius {
if(!pcode || (pcode &&
code->machine_code()->sample_count > pcode->machine_code()->sample_count))
{
code->machine_code()->set_description(state);
profile->put(state, 0, code);
min_profile_sample_count_ = code->machine_code()->sample_count;
}
@@ -350,7 +351,7 @@ namespace rubinius {
<< std::setw(10)
<< code->machine_code()->sample_count
<< " "
<< code->name()->debug_str(state)
<< *code->machine_code()->description()
<< std::endl;
}
}

0 comments on commit 929f8fa

Please sign in to comment.