<commit_before>#include <ghcjs/rts.h>

// #define GHCJS_TRACE_META 1

#ifdef GHCJS_TRACE_META
function h$logMeta(args) { h$log.apply(h$log,arguments); }
#define TRACE_META(args...) h$logMeta(args)
#else
#define TRACE_META(args...)
#endif
// memory management and pointer emulation

// static init, non-caf
#ifdef GHCJS_PROF
function h$sti(i,c,xs,ccs) {
#else
function h$sti(i,c,xs) {
#endif
    i.f = c;
#ifdef GHCJS_PROF
    i.cc = ccs;
#endif
    h$init_closure(i,xs);
}

// static init, caf
#ifdef GHCJS_PROF
function h$stc(i,c,xs,ccs) {
#else
function h$stc(i,c,xs) {
#endif
    i.f = c;
#ifdef GHCJS_PROF
    i.cc = ccs;
#endif
    h$init_closure(i,xs);
    h$addCAF(i);
}

#ifdef GHCJS_PROF
function h$stl(o, xs, t, ccs) {
#else
function h$stl(o, xs, t) {
#endif
    var r = t ? t : h$ghczmprimZCGHCziTypesziZMZN;
    var x;
    if(xs.length > 0) {
        for(var i=xs.length-1;i>=0;i--) {
            x = xs[i];
            if(!x && x !== false && x !== 0) throw "h$toHsList: invalid element";
            r = MK_CONS_CC(x, r, ccs);
        }
    }
    // fixme direct object manip
    o.f  = r.f;
    o.d1 = r.d1;
    o.d2 = r.d2;
    o.m  = r.m;
#ifdef GHCJS_PROF
    o.cc = ccs;
#endif
}

// some utilities for constructing common objects from JS in the RTS or foreign code.
// when profiling, the current ccs is assigned

// #ifdef GHCJS_PROF
// var h$nil = h$c(h$ghczmprimZCGHCziTypesziZMZN_con_e, h$CCS_SYSTEM);
// #else
// var h$nil = h$c(h$ghczmprimZCGHCziTypesziZMZN_con_e);
// #endif

// #ifdef GHCJS_PROF
// var h$nothing = h$c(h$baseZCGHCziBaseziNothing_con_e, h$CCS_SYSTEM);
// #else
//var h$nothing = h$c(h$baseZCGHCziBaseziNothing_con_e);
// #endif

// delayed init for top-level closures
var h$staticDelayed = [];
function h$d() {
#ifdef GHCJS_PROF
    // pass a temporary CCS that won't make assertions in h$cN family alert
    var c = h$c(null, h$CCS_SYSTEM);
#else
    var c = h$c(null);
#endif
    h$staticDelayed.push(c);
    return c;
}

var h$allocN = 0;
function h$traceAlloc(x) {
    h$log("allocating: " + (++h$allocN));
    x.alloc = h$allocN;
}

// fixme remove this when we have a better way to immediately init these things
function h$di(c) {
    h$staticDelayed.push(c);
}

// initialize global object to primitive value
function h$p(x) {
    h$staticDelayed.push(x);
    return x;
}

var h$entriesStack = [];
var h$staticsStack = [];
var h$labelsStack  = [];

function h$scheduleInit(entries, objs, lbls, infos, statics) {
    var d = h$entriesStack.length;
    h$entriesStack.push(entries);
    h$staticsStack.push(objs);
    h$labelsStack.push(lbls);
    h$initStatic.push(function() {
        h$initInfoTables(d, entries, objs, lbls, infos, statics);
    });
}

function h$runInitStatic() {
    if(h$initStatic.length > 0) {
        for(var i=h$initStatic.length - 1;i>=0;i--) {
            h$initStatic[i]();
        }
        h$initStatic = [];
    }
    // free the references to the temporary tables used for
    // initialising all our static data
    h$entriesStack = null;
    h$staticsStack = null;
}

// initialize packed info tables
// see Gen2.Compactor for how the data is encoded
function h$initInfoTables ( depth      // depth in the base chain
                          , funcs      // array with all entry functions
                          , objects    // array with all the global heap objects
                          , lbls       // array with non-haskell labels
                          , infoMeta   // packed info
                          , infoStatic
                          ) {
  TRACE_META("decoding info tables");
  var n, i, j, o, pos = 0, info;
  function code(c) {
    if(c < 34) return c - 32;
    if(c < 92) return c - 33;
    return c - 34;
  }
  function next() {
    var c = info.charCodeAt(pos);
    if(c < 124) {
      TRACE_META("pos: " + pos + " decoded: " + code(c));
      pos++;
      return code(c);
    }
    if(c === 124) {
      pos+=3;
      var r =  90 + 90 * code(info.charCodeAt(pos-2))
                  + code(info.charCodeAt(pos-1));
      TRACE_META("pos: " + (pos-3) + " decoded: " + r);<commit_msg>Eliminate redundant h$runInitStatic<commit_after>#include <ghcjs/rts.h>

// #define GHCJS_TRACE_META 1

#ifdef GHCJS_TRACE_META
function h$logMeta(args) { h$log.apply(h$log,arguments); }
#define TRACE_META(args...) h$logMeta(args)
#else
#define TRACE_META(args...)
#endif
// memory management and pointer emulation

// static init, non-caf
#ifdef GHCJS_PROF
function h$sti(i,c,xs,ccs) {
#else
function h$sti(i,c,xs) {
#endif
    i.f = c;
#ifdef GHCJS_PROF
    i.cc = ccs;
#endif
    h$init_closure(i,xs);
}

// static init, caf
#ifdef GHCJS_PROF
function h$stc(i,c,xs,ccs) {
#else
function h$stc(i,c,xs) {
#endif
    i.f = c;
#ifdef GHCJS_PROF
    i.cc = ccs;
#endif
    h$init_closure(i,xs);
    h$addCAF(i);
}

#ifdef GHCJS_PROF
function h$stl(o, xs, t, ccs) {
#else
function h$stl(o, xs, t) {
#endif
    var r = t ? t : h$ghczmprimZCGHCziTypesziZMZN;
    var x;
    if(xs.length > 0) {
        for(var i=xs.length-1;i>=0;i--) {
            x = xs[i];
            if(!x && x !== false && x !== 0) throw "h$toHsList: invalid element";
            r = MK_CONS_CC(x, r, ccs);
        }
    }
    // fixme direct object manip
    o.f  = r.f;
    o.d1 = r.d1;
    o.d2 = r.d2;
    o.m  = r.m;
#ifdef GHCJS_PROF
    o.cc = ccs;
#endif
}

// some utilities for constructing common objects from JS in the RTS or foreign code.
// when profiling, the current ccs is assigned

// #ifdef GHCJS_PROF
// var h$nil = h$c(h$ghczmprimZCGHCziTypesziZMZN_con_e, h$CCS_SYSTEM);
// #else
// var h$nil = h$c(h$ghczmprimZCGHCziTypesziZMZN_con_e);
// #endif

// #ifdef GHCJS_PROF
// var h$nothing = h$c(h$baseZCGHCziBaseziNothing_con_e, h$CCS_SYSTEM);
// #else
//var h$nothing = h$c(h$baseZCGHCziBaseziNothing_con_e);
// #endif

// delayed init for top-level closures
var h$staticDelayed = [];
function h$d() {
#ifdef GHCJS_PROF
    // pass a temporary CCS that won't make assertions in h$cN family alert
    var c = h$c(null, h$CCS_SYSTEM);
#else
    var c = h$c(null);
#endif
    h$staticDelayed.push(c);
    return c;
}

var h$allocN = 0;
function h$traceAlloc(x) {
    h$log("allocating: " + (++h$allocN));
    x.alloc = h$allocN;
}

// fixme remove this when we have a better way to immediately init these things
function h$di(c) {
    h$staticDelayed.push(c);
}

// initialize global object to primitive value
function h$p(x) {
    h$staticDelayed.push(x);
    return x;
}

var h$entriesStack = [];
var h$staticsStack = [];
var h$labelsStack  = [];

function h$scheduleInit(entries, objs, lbls, infos, statics) {
    var d = h$entriesStack.length;
    h$entriesStack.push(entries);
    h$staticsStack.push(objs);
    h$labelsStack.push(lbls);
    h$initStatic.push(function() {
        h$initInfoTables(d, entries, objs, lbls, infos, statics);
    });
}

// initialize packed info tables
// see Gen2.Compactor for how the data is encoded
function h$initInfoTables ( depth      // depth in the base chain
                          , funcs      // array with all entry functions
                          , objects    // array with all the global heap objects
                          , lbls       // array with non-haskell labels
                          , infoMeta   // packed info
                          , infoStatic
                          ) {
  TRACE_META("decoding info tables");
  var n, i, j, o, pos = 0, info;
  function code(c) {
    if(c < 34) return c - 32;
    if(c < 92) return c - 33;
    return c - 34;
  }
  function next() {
    var c = info.charCodeAt(pos);
    if(c < 124) {
      TRACE_META("pos: " + pos + " decoded: " + code(c));
      pos++;
      return code(c);
    }
    if(c === 124) {
      pos+=3;
      var r =  90 + 90 * code(info.charCodeAt(pos-2))
                  + code(info.charCodeAt(pos-1));
      TRACE_META("pos: " + (pos-3) + " decoded: " + r);
{'fraction_non_alphanumeric': 0.14496064991114496, 'fraction_numerical': 0.00952018278750952, 'mean_word_length': 2.4986678507992894, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7358937', 'n_tokens_mistral': 3116, 'n_tokens_neox': 3024, 'n_words': 734}