Coverage Report

Created: 2017-04-15 07:07

/home/travis/build/MoarVM/MoarVM/src/spesh/lookup.c
Line
Count
Source
1
/* This file contains a number of functions that do lookups of data held in
2
 * data structures outside of the realm of spesh. We need to be very careful
3
 * how we do these, in various cases. For example, in the past we had cases
4
 * where we tried to look up a method, which in turn triggered method cache
5
 * deserialization, which acquired a mutex, which would block for GC and so
6
 * could end up with a collection taking place while spesh was working. This
7
 * broke the "no GC during spesh" invariant. */
8
9
#include "moar.h"
10
11
/* Tries to get the HOW (meta-object) of an object - but only if it's already
12
 * available (e.g. deserialized). In the case it's not, returns NULL. */
13
837
MVMObject * MVM_spesh_try_get_how(MVMThreadContext *tc, MVMObject *obj) {
14
837
    return STABLE(obj)->HOW;
15
837
}
16
17
/* Tries to look up the method using the method cache, provided that the
18
 * method cache has already been deserialized. */
19
17.0k
MVMObject * MVM_spesh_try_find_method(MVMThreadContext *tc, MVMObject *obj, MVMString *name) {
20
17.0k
    return STABLE(obj)->method_cache
21
16.4k
        ? MVM_6model_find_method_cache_only(tc, obj, name)
22
17.0k
        : NULL;
23
17.0k
}
24
25
/* Tries to check if the method exists on the object using the method cache,
26
 * provided the method cache has already been deserialized. */
27
6.95k
MVMint64 MVM_spesh_try_can_method(MVMThreadContext *tc, MVMObject *obj, MVMString *name) {
28
6.95k
    return STABLE(obj)->method_cache
29
673
        ? MVM_6model_can_method_cache_only(tc, obj, name)
30
6.28k
        : -1;
31
6.95k
}