Branch Coverage

lib/XS/JIT/xs_jit.c
Criterion Covered Total %
branch 141 254 55.5


line true false branch
53 0 0 if (buf->data) {
62 26456 389 if (buf->capacity >= needed) return 1;
64 113 276 size_t new_cap = buf->capacity ? buf->capacity : BUFFER_CHUNK;
65 116 389 while (new_cap < needed) new_cap *= 2;
68 0 389 if (!new_data) return 0;
77 0 24525 if (!strbuf_ensure(buf, buf->len + slen + 1)) return 0;
91 0 2320 if (needed < 0) {
96 0 2320 if (!strbuf_ensure(buf, buf->len + needed + 1)) {
110 33768 1920 for (i = 0; name[i] && j < outlen - 1; i++) {
33768 0 for (i = 0; name[i] && j < outlen - 1; i++) {
112 1941 31827 if (c == ':') {
114 1941 0 if (name[i+1] == ':') i++;
115 23290 8537 } else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
0 23290 } else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
7505 1032 } else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
527 6978 } else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
1559 0 } else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
116 527 1032 (c >= '0' && c <= '9') || c == '_') {
527 0 (c >= '0' && c <= '9') || c == '_') {
133 11 0 SV **archname_sv = config ? hv_fetch(config, "archname", 8, 0) : NULL;
134 11 0 const char *archname = (archname_sv && *archname_sv) ? SvPV_nolen(*archname_sv) : "unknown";
11 0 const char *archname = (archname_sv && *archname_sv) ? SvPV_nolen(*archname_sv) : "unknown";
143 11 0 if (SvTRUE(ERRSV)) {
0 11 if (SvTRUE(ERRSV)) {
145 0 0 FREETMPS;
150 0 11 PUSHMARK(SP);
151 0 11 XPUSHs(input);
157 11 0 if (count == 1) {
162 11 0 if (result) {
169 11 0 FREETMPS;
178 286 0 return cache_dir ? cache_dir : "_CACHED_XS";
185 0 11 if (!key) return 0;
188 11 0 SV **dlext_sv = config ? hv_fetch(config, "dlext", 5, 0) : NULL;
189 11 0 const char *dlext = (dlext_sv && *dlext_sv) ? SvPV_nolen(*dlext_sv) : "so";
11 0 const char *dlext = (dlext_sv && *dlext_sv) ? SvPV_nolen(*dlext_sv) : "so";
207 0 11 if (!xs_jit_cache_path(aTHX_ code, name, cache_dir, path, sizeof(path))) {
221 471 71 if (is_xs_native) {
233 71 0 if (has_varargs) {
301 542 276 for (i = 0; i < num_funcs; i++) {
302 0 542 if (!functions[i].target) break;
520 542 276 for (i = 0; i < num_funcs; i++) {
521 0 542 if (!functions[i].target) break;
540 0 275 if (tmp[len - 1] == '/') tmp[len - 1] = 0;
542 10532 275 for (p = tmp + 1; *p; p++) {
543 1069 9463 if (*p == '/') {
549 1 274 return mkdir(tmp, 0755) == 0 || errno == EEXIST;
1 0 return mkdir(tmp, 0755) == 0 || errno == EEXIST;
562 0 549 if (!fp) {
569 3 549 while ((n = fread(buf, 1, sizeof(buf), fp)) > 0)
584 0 275 if (!config) {
599 275 0 const char *cc = (cc_sv && *cc_sv) ? SvPV_nolen(*cc_sv) : "cc";
275 0 const char *cc = (cc_sv && *cc_sv) ? SvPV_nolen(*cc_sv) : "cc";
600 275 0 const char *ccflags = (ccflags_sv && *ccflags_sv) ? SvPV_nolen(*ccflags_sv) : "";
275 0 const char *ccflags = (ccflags_sv && *ccflags_sv) ? SvPV_nolen(*ccflags_sv) : "";
601 275 0 const char *optimize = (optimize_sv && *optimize_sv) ? SvPV_nolen(*optimize_sv) : "-O2";
275 0 const char *optimize = (optimize_sv && *optimize_sv) ? SvPV_nolen(*optimize_sv) : "-O2";
602 275 0 const char *cccdlflags = (cccdlflags_sv && *cccdlflags_sv) ? SvPV_nolen(*cccdlflags_sv) : "";
275 0 const char *cccdlflags = (cccdlflags_sv && *cccdlflags_sv) ? SvPV_nolen(*cccdlflags_sv) : "";
603 275 0 const char *lddlflags = (lddlflags_sv && *lddlflags_sv) ? SvPV_nolen(*lddlflags_sv) : "";
275 0 const char *lddlflags = (lddlflags_sv && *lddlflags_sv) ? SvPV_nolen(*lddlflags_sv) : "";
604 275 0 const char *archlib = (archlib_sv && *archlib_sv) ? SvPV_nolen(*archlib_sv) : "";
275 0 const char *archlib = (archlib_sv && *archlib_sv) ? SvPV_nolen(*archlib_sv) : "";
607 275 0 if (!extra_cflags) extra_cflags = "";
608 275 0 if (!extra_ldflags) extra_ldflags = "";
623 275 0 const char *std_flag = (strstr(ccflags, "-std=") == NULL) ? "-std=gnu99" : "";
631 1 274 if (ret != 0) {
632 1 0 warn("XS::JIT: Compilation failed: %s\n--- compiler output ---\n%s",
682 0 274 if (ret != 0) {
683 0 0 warn("XS::JIT: Linking failed: %s\n--- linker output ---\n%s",
707 30 244 if (so_file[0] != '/') {
708 30 0 if (realpath(so_file, abs_so_file)) {
719 274 0 if (SvTRUE(ERRSV)) {
0 274 if (SvTRUE(ERRSV)) {
720 0 0 warn("XS::JIT: Cannot load DynaLoader: %s", SvPV_nolen(ERRSV));
721 0 0 FREETMPS;
727 0 274 PUSHMARK(SP);
728 0 274 XPUSHs(sv_2mortal(newSVpv(so_file, 0)));
729 0 274 XPUSHs(sv_2mortal(newSViv(0))); /* flags */
736 274 0 if (count == 1) {
742 274 0 if (!libref_sv || !SvOK(libref_sv)) {
0 274 if (!libref_sv || !SvOK(libref_sv)) {
744 0 0 PUSHMARK(SP);
751 0 0 FREETMPS;
760 0 274 PUSHMARK(SP);
761 0 274 XPUSHs(libref_sv);
762 0 274 XPUSHs(sv_2mortal(newSVpv(boot_name, 0)));
769 274 0 if (count == 1) {
775 274 0 if (!symref_sv || !SvOK(symref_sv)) {
0 274 if (!symref_sv || !SvOK(symref_sv)) {
776 0 0 PUSHMARK(SP);
784 0 0 FREETMPS;
793 0 274 PUSHMARK(SP);
794 0 274 XPUSHs(sv_2mortal(newSVpv(bootstrap_name, 0)));
795 0 274 XPUSHs(symref_sv);
796 0 274 XPUSHs(sv_2mortal(newSVpv(so_file, 0)));
803 274 0 if (count == 1) {
808 274 0 if (!xs_sv || !SvOK(xs_sv)) {
0 274 if (!xs_sv || !SvOK(xs_sv)) {
812 0 0 FREETMPS;
818 0 274 PUSHMARK(SP);
819 0 274 XPUSHs(sv_2mortal(newSVpv(module_name, 0)));
824 274 0 if (SvTRUE(ERRSV)) {
0 274 if (SvTRUE(ERRSV)) {
825 0 0 warn("XS::JIT: boot function failed: %s", SvPV_nolen(ERRSV));
828 0 0 FREETMPS;
835 274 0 FREETMPS;
844 543 274 for (i = 0; i < num_functions && functions[i].target; i++) {
543 0 for (i = 0; i < num_functions && functions[i].target; i++) {
848 543 0 if (last_colon && last_colon > target && *(last_colon - 1) == ':') {
543 0 if (last_colon && last_colon > target && *(last_colon - 1) == ':') {
543 0 if (last_colon && last_colon > target && *(last_colon - 1) == ':') {
852 0 543 if (pkg_len >= sizeof(pkg)) pkg_len = sizeof(pkg) - 1;
858 194 349 if (stash) {
861 111 83 if (gv && *(SV**)gv && GvCV(*(GV**)gv)) {
111 0 if (gv && *(SV**)gv && GvCV(*(GV**)gv)) {
3 108 if (gv && *(SV**)gv && GvCV(*(GV**)gv)) {
881 277 1 if (!force && functions_already_loaded(aTHX_ functions, num_functions)) {
3 274 if (!force && functions_already_loaded(aTHX_ functions, num_functions)) {
891 275 0 SV **dlext_sv = config ? hv_fetch(config, "dlext", 5, 0) : NULL;
892 275 0 const char *dlext = (dlext_sv && *dlext_sv) ? SvPV_nolen(*dlext_sv) : "so";
275 0 const char *dlext = (dlext_sv && *dlext_sv) ? SvPV_nolen(*dlext_sv) : "so";
899 274 1 if (!force) {
901 0 274 if (PerlLIO_stat(so_path, &st) == 0) {
909 0 275 if (!generated) {
915 0 275 if (!mkdir_p(dir_path)) {
923 0 275 if (!fp) {
933 1 274 if (!xs_jit_compile_file(aTHX_ c_path, so_path, extra_cflags, extra_ldflags)) {