Skip to content

Commit

Permalink
Allow a CM to have no StaticScope (alexsuraci)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Phoenix committed Feb 22, 2011
1 parent d2c2288 commit 9cb5c80
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 56 deletions.
11 changes: 6 additions & 5 deletions vm/llvm/inline.cpp
Expand Up @@ -88,7 +88,7 @@ namespace rubinius {
if(ops_.state()->config().jit_inline_debug) {

context_.inline_log("NOT inlining")
<< ops_.state()->symbol_cstr(cm->scope()->module()->name())
<< ops_.state()->enclosure_name(cm)
<< "#"
<< ops_.state()->symbol_cstr(cm->name())
<< " into "
Expand All @@ -114,13 +114,14 @@ namespace rubinius {

if(ops_.state()->config().jit_inline_debug) {
context_.inline_log("inlining")
<< ops_.state()->symbol_cstr(cm->scope()->module()->name())
<< ops_.state()->enclosure_name(cm)
<< "#"
<< ops_.state()->symbol_cstr(cm->name())
<< " into "
<< ops_.state()->symbol_cstr(ops_.method_name());

if(klass != cm->scope()->module() && !klass->name()->nil_p()) {
StaticScope* ss = cm->scope();
if(kind_of<StaticScope>(ss) && klass != ss->module() && !klass->name()->nil_p()) {
ops_.state()->log() << " ("
<< ops_.state()->symbol_cstr(klass->name()) << ")";
}
Expand All @@ -140,7 +141,7 @@ namespace rubinius {
} else {
if(ops_.state()->config().jit_inline_debug) {
context_.inline_log("NOT inlining")
<< ops_.state()->symbol_cstr(cm->scope()->module()->name())
<< ops_.state()->enclosure_name(cm)
<< "#"
<< ops_.state()->symbol_cstr(cm->name())
<< " into "
Expand Down Expand Up @@ -226,7 +227,7 @@ namespace rubinius {
void Inliner::inline_trivial_method(Class* klass, CompiledMethod* cm) {
if(ops_.state()->config().jit_inline_debug) {
context_.inline_log("inlining")
<< ops_.state()->symbol_cstr(cm->scope()->module()->name())
<< ops_.state()->enclosure_name(cm)
<< "#"
<< ops_.state()->symbol_cstr(cm->name())
<< " into "
Expand Down
8 changes: 4 additions & 4 deletions vm/llvm/inline_primitive.cpp
Expand Up @@ -637,7 +637,7 @@ namespace rubinius {

if(ops_.state()->config().jit_inline_debug) {
context_.inline_log("inlining")
<< ops_.state()->symbol_cstr(cm->scope()->module()->name())
<< ops_.state()->enclosure_name(cm)
<< "#"
<< ops_.state()->symbol_cstr(cm->name())
<< " into "
Expand All @@ -654,7 +654,7 @@ namespace rubinius {
if(inlined_prim) {
if(ops_.state()->config().jit_inline_debug) {
context_.inline_log("inlining")
<< ops_.state()->symbol_cstr(cm->scope()->module()->name())
<< ops_.state()->enclosure_name(cm)
<< "#"
<< ops_.state()->symbol_cstr(cm->name())
<< " into "
Expand All @@ -668,7 +668,7 @@ namespace rubinius {
// Add more primitive inlining!
if(ops_.state()->config().jit_inline_debug) {
context_.inline_log("NOT inlining")
<< ops_.state()->symbol_cstr(cm->scope()->module()->name())
<< ops_.state()->enclosure_name(cm)
<< "#"
<< ops_.state()->symbol_cstr(cm->name())
<< " into "
Expand Down Expand Up @@ -704,7 +704,7 @@ namespace rubinius {

if(ops_.state()->config().jit_inline_debug) {
context_.inline_log("inlining")
<< ops_.state()->symbol_cstr(cm->scope()->module()->name())
<< ops_.state()->enclosure_name(cm)
<< "#"
<< ops_.state()->symbol_cstr(cm->name())
<< " into "
Expand Down
47 changes: 9 additions & 38 deletions vm/llvm/jit.cpp
Expand Up @@ -561,6 +561,15 @@ namespace rubinius {
return symbols_.lookup_cstring(sym);
}

const char* LLVMState::enclosure_name(CompiledMethod* cm) {
StaticScope* ss = cm->scope();
if(!kind_of<StaticScope>(ss) || !kind_of<Module>(ss->module())) {
return "ANONYMOUS";
}

return symbol_cstr(ss->module()->name());
}

void LLVMState::compile_soon(STATE, CompiledMethod* cm, BlockEnvironment* block) {
Object* placement;
bool is_block = false;
Expand Down Expand Up @@ -645,44 +654,6 @@ namespace rubinius {

const static int cInlineMaxDepth = 4;

/*
static CallFrame* find_call_frame(CallFrame* frame, VMMethod* meth, int* dist) {
*dist = 0;
while(frame) {
if(frame->cm->backend_method() == meth) return frame;
frame = frame->previous;
dist++;
}
return 0;
}
*/

/*
static void show_method(LLVMState* ls, VMMethod* vmm, const char* extra = "") {
CompiledMethod* cm = vmm->original.get();
std::cerr << " "
<< ls->symbol_cstr(cm->scope()->module()->name())
<< "#"
<< ls->symbol_cstr(cm->name())
<< " (" << vmm->call_count << ") "
<< extra
<< "\n";
}
*/

/*
static CallFrame* validate_block_parent(CallFrame* cf, VMMethod* parent) {
if(cf->previous && cf->previous->previous) {
cf = cf->previous->previous;
if(cf->cm->backend_method() == parent) return cf;
}
return 0;
}
*/

void LLVMState::compile_callframe(STATE, CompiledMethod* start, CallFrame* call_frame,
int primitive) {
if(config().jit_inline_debug) {
Expand Down
2 changes: 2 additions & 0 deletions vm/llvm/jit.hpp
Expand Up @@ -567,6 +567,8 @@ namespace rubinius {
Symbol* symbol(const char* sym);
const char* symbol_cstr(const Symbol* sym);

const char* enclosure_name(CompiledMethod* cm);

void shutdown_i();
void on_fork_i();
void pause_i();
Expand Down
2 changes: 1 addition & 1 deletion vm/llvm/jit_block.cpp
Expand Up @@ -27,7 +27,7 @@ namespace jit {

std::stringstream ss;
ss << std::string("_X_")
<< ls_->symbol_cstr(info_.method()->scope()->module()->name())
<< ls_->enclosure_name(info_.method())
<< "#"
<< ls_->symbol_cstr(info_.method()->name())
<< "$block@" << ls_->add_jitted_method();
Expand Down
13 changes: 7 additions & 6 deletions vm/llvm/jit_builder.cpp
Expand Up @@ -124,12 +124,13 @@ namespace jit {

void Builder::check_self_type() {
int klass_id = 0;
{
if(Class* cls = try_as<Class>(info_.method()->scope()->module())) {
klass_id = cls->class_id();
} else {
return;
}

StaticScope* ss = info_.method()->scope();
if(!kind_of<StaticScope>(ss)) return;
if(Class* cls = try_as<Class>(ss->module())) {
klass_id = cls->class_id();
} else {
return;
}

// Now, validate class_id
Expand Down
2 changes: 1 addition & 1 deletion vm/llvm/jit_compiler.cpp
Expand Up @@ -102,7 +102,7 @@ namespace jit {
gettimeofday(&tv, NULL);

ls->log() << "JIT: compiling "
<< ls->symbol_cstr(cm->scope()->module()->name())
<< ls->enclosure_name(cm)
<< "#"
<< ls->symbol_cstr(cm->name())
<< " (" << tv.tv_sec << "." << tv.tv_usec << ")\n";
Expand Down
2 changes: 1 addition & 1 deletion vm/llvm/jit_method.cpp
Expand Up @@ -26,7 +26,7 @@ namespace jit {

std::stringstream ss;
ss << std::string("_X_")
<< ls_->symbol_cstr(info_.method()->scope()->module()->name())
<< ls_->enclosure_name(info_.method())
<< "#"
<< ls_->symbol_cstr(info_.method()->name())
<< "@" << ls_->add_jitted_method();
Expand Down

0 comments on commit 9cb5c80

Please sign in to comment.