Esempio n. 1
0
  void test_mono_inline_cache_locate_succeeded() {
    Message msg(state);
    Symbol* sym = state->symbol("blah");
    SendSite* ss = SendSite::create(state, sym);
    Class* meta = G(object)->metaclass(state);
    CompiledMethod* cm = CompiledMethod::create(state);
    CompiledMethod* g_cm = CompiledMethod::create(state);

    TS_ASSERT_EQUALS(MonomorphicInlineCacheResolver::resolve, ss->resolver);

    ss->recv_class(state, meta);
    ss->module(state, G(object));
    ss->method(state, cm);
    ss->hits = 1U;

    msg.name = sym;
    msg.lookup_from = meta;
    msg.recv = G(object);
    msg.send_site = ss;
    msg.module = meta;
    msg.method = cm;

    state->global_cache->retain(state, meta, sym, meta, g_cm, false);

    TS_ASSERT(ss->locate(state, msg));
    TS_ASSERT_EQUALS(2U, ss->hits);
    TS_ASSERT_EQUALS(0U, ss->misses);
    TS_ASSERT_EQUALS(cm, msg.method);
    TS_ASSERT_EQUALS(G(object), msg.module);
  }
Esempio n. 2
0
  void test_mono_inline_cache_locate_failed() {
    Message msg(state);
    Symbol* sym = state->symbol("blah");
    SendSite* ss = SendSite::create(state, sym);
    Class* meta = G(object)->metaclass(state);
    CompiledMethod* cm = CompiledMethod::create(state);

    TS_ASSERT_EQUALS(MonomorphicInlineCacheResolver::resolve, ss->resolver);

    msg.name = sym;
    msg.lookup_from = meta;
    msg.recv = G(object);
    msg.send_site = ss;
    msg.module = (Module*)Qnil;
    msg.method = (Executable*)Qnil;

    state->global_cache->retain(state, meta, sym, meta, cm, false);

    TS_ASSERT(ss->locate(state, msg));
    TS_ASSERT_EQUALS(1U, ss->misses);
    TS_ASSERT_EQUALS(0U, ss->hits);
    TS_ASSERT_EQUALS(cm, msg.method);
    TS_ASSERT_EQUALS(meta, msg.module);
  }