static void emit_event_handler(void *emit, struct edp_event *ev){ struct edp_emit *ee = (struct edp_emit *)emit; int errcode; ASSERT((emit != NULL) && emit_check(ee)); ASSERT(ev != NULL); if((ev->ev_type < 0) || (ev->ev_type >= kEMIT_EVENT_TYPE_MAX)){ log_warn("event type overflow:%d!\n", ev->ev_type); edp_event_done(ev, -ERANGE); return ; } if(ee->ee_handler[ev->ev_type] == emit_default_handler){ log_warn("no handler for this event:%d!\n", ev->ev_type); edp_event_done(ev, -ENOENT); return ; } errcode = (ee->ee_handler[ev->ev_type])(ee, ev); // spi_spin_lock(&eu->ee_lock); // list_del(&ev->ev_edpu); // spi_spin_unlock(&eu->ee_lock); atomic_dec(&ee->ee_pendings); edp_event_done(ev, errcode); }
/* index: 0 = top of stack, 1 = item underneath, etc cache_entries: array of class/method pairs */ void inline_cache_jit::compile_inline_cache(fixnum index, cell generic_word_, cell methods_, cell cache_entries_, bool tail_call_p) { gc_root<word> generic_word(generic_word_,parent); gc_root<array> methods(methods_,parent); gc_root<array> cache_entries(cache_entries_,parent); cell inline_cache_type = parent->determine_inline_cache_type(cache_entries.untagged()); parent->update_pic_count(inline_cache_type); /* Generate machine code to determine the object's class. */ emit_class_lookup(index,inline_cache_type); /* Generate machine code to check, in turn, if the class is one of the cached entries. */ cell i; for(i = 0; i < array_capacity(cache_entries.untagged()); i += 2) { /* Class equal? */ cell klass = array_nth(cache_entries.untagged(),i); emit_check(klass); /* Yes? Jump to method */ cell method = array_nth(cache_entries.untagged(),i + 1); emit_with(parent->userenv[PIC_HIT],method); } /* Generate machine code to handle a cache miss, which ultimately results in this function being called again. The inline-cache-miss primitive call receives enough information to reconstruct the PIC. */ push(generic_word.value()); push(methods.value()); push(tag_fixnum(index)); push(cache_entries.value()); word_special(parent->userenv[tail_call_p ? PIC_MISS_TAIL_WORD : PIC_MISS_WORD]); }