Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Solidate callback signature
  • Loading branch information
ryoqun committed Oct 5, 2013
1 parent a970072 commit 3508c8b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
6 changes: 0 additions & 6 deletions vm/builtin/call_site.cpp
Expand Up @@ -92,12 +92,6 @@ namespace rubinius {
state->set_call_site_information(NULL);
return res;
} else {
if(handler)
{
printf("calling from callback!\n");
handler(meth);
printf("fallback: %p\n", meth);
}
return meth->execute(state, call_frame, meth, mod, args);
}
}
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/call_site.hpp
Expand Up @@ -9,7 +9,7 @@ namespace rubinius {

class Dispatch;

typedef void (CallbackHandlerFunc)(Executable*);
typedef Object* (CallbackHandlerFunc)(STATE, CallSite*, CallFrame*, Executable*, Module*, Arguments&);
typedef CallbackHandlerFunc* CallbackHandler;

typedef Object* (CacheExecuteFunc)(STATE, CallSite*, CallFrame*, Arguments&, CallbackHandler callback);
Expand Down
9 changes: 5 additions & 4 deletions vm/builtin/mono_inline_cache.cpp
Expand Up @@ -71,12 +71,13 @@ namespace rubinius {
//printf(".");
if(likely(cache->receiver_.raw == recv_data)) {
cache->hits_++;
if(handler)
{
if(handler) {
printf("calling\n");
handler(cache->method_);
return handler(state, call_site,
call_frame, cache->method_, cache->stored_module_, args);
} else {
return cache->method_->execute(state, call_frame, cache->method_, cache->stored_module_, args);
}
return cache->method_->execute(state, call_frame, cache->method_, cache->stored_module_, args);
}

return call_site->fallback(state, call_frame, args, handler);
Expand Down
12 changes: 9 additions & 3 deletions vm/builtin/optimized_call_site.cpp
Expand Up @@ -26,7 +26,7 @@ namespace rubinius {
Arguments& args, CallbackHandler handler)
{
OptimizedCallSite* optimized = reinterpret_cast<OptimizedCallSite*>(call_site);
handler = (handler) ? handler : on_executable_resolved;
handler = (handler) ? handler : on_resolved;
printf("%p\n", optimized->fallback_call_site_->executor_);
printf("aaa %p\n", handler);
Object* next = optimized->fallback_call_site_->executor_(state, optimized->fallback_call_site_, call_frame, args, handler);
Expand All @@ -43,8 +43,14 @@ namespace rubinius {
//}
}

void OptimizedCallSite::on_executable_resolved(Executable *executable) {
printf("YAAAAAAY!!! %p\n", executable);
Object* OptimizedCallSite::on_resolved(STATE,
CallSite* call_site,
CallFrame* frame,
Executable* resolved_method,
Module* mod,
Arguments& args) {
printf("YAAAAAAY!!! %p\n", mod);
return resolved_method->execute(state, frame, resolved_method, mod, args);
}

void OptimizedCallSite::Info::mark(Object* obj, ObjectMark& mark) {
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/optimized_call_site.hpp
Expand Up @@ -23,7 +23,7 @@ namespace rubinius {
static CacheExecuteFunc optimized_call_site_executor;
static CacheUpdateFunc optimized_call_site_updater;

static CallbackHandlerFunc on_executable_resolved;
static CallbackHandlerFunc on_resolved;

public: // Rubinius Type stuff
class Info : public CallSite::Info {
Expand Down

0 comments on commit 3508c8b

Please sign in to comment.