module Bootsnap::CompileCache::Native
Public Class Methods
compile_option_crc32=(p1)
click to toggle source
Bootsnap's ruby code registers a hook that notifies us via this function when compile_option changes. These changes invalidate all existing caches.
Note that on 32-bit platforms, a CRC32 can't be represented in a Fixnum, but can be represented by a uint.
static VALUE
bs_compile_option_crc32_set(VALUE self, VALUE crc32_v)
{
if (!RB_TYPE_P(crc32_v, T_BIGNUM) && !RB_TYPE_P(crc32_v, T_FIXNUM)) {
Check_Type(crc32_v, T_FIXNUM);
}
current_compile_option_crc32 = NUM2UINT(crc32_v);
return Qnil;
}
coverage_running?()
click to toggle source
static VALUE
bs_rb_coverage_running(VALUE self)
{
VALUE cov = rb_get_coverages();
return RTEST(cov) ? Qtrue : Qfalse;
}
fetch(p1, p2, p3)
click to toggle source
Entrypoint for Bootsnap::CompileCache::Native.fetch. The real work is done in bs_fetch; this function just performs some basic typechecks and conversions on the ruby VALUE arguments before passing them along.
static VALUE
bs_rb_fetch(VALUE self, VALUE cachedir_v, VALUE path_v, VALUE handler)
{
FilePathValue(path_v);
Check_Type(cachedir_v, T_STRING);
Check_Type(path_v, T_STRING);
if (RSTRING_LEN(cachedir_v) > MAX_CACHEDIR_SIZE) {
rb_raise(rb_eArgError, "cachedir too long");
}
char * cachedir = RSTRING_PTR(cachedir_v);
char * path = RSTRING_PTR(path_v);
char cache_path[MAX_CACHEPATH_SIZE];
{ /* generate cache path to cache_path */
char * tmp = (char *)&cache_path;
bs_cache_path(cachedir, path, &tmp);
}
return bs_fetch(path, path_v, cache_path, handler);
}