<commit_before>#!/usr/bin/env node
"use strict";

const fs = require("fs");

global.v86util = {};

// copied from const.js
global.WASM_TABLE_SIZE = 0x10000;
// The space we need for misc internal state before the beginning of mem8; see global_pointers.h
global.GUEST_MEMORY_START = 0x10000 + 0x100000 * 6;
global.WASM_PAGE_SIZE = 64 * 1024;

global.dbg_assert = x => console.assert(x);

require("../../src/browser/lib.js");

const Codegen = require("../../src/codegen.js");

const codegen_module_buffer = fs.readFileSync(__dirname + "/../../build/codegen-test.wasm");

const vals = {
    imm8: 1,
    imm8s: 1,
    imm16: 2,
    imm32s: 3,
    asize_32: false,
    reg16: 4,
    reg32s: 4,
    instruction_pointer: 556,
    previous_ip: 560,
    prefixes: 0,
    timestamp_counter: 0,
};

const wasm_test_funcs = {
    env: {
        _read_imm8() { return vals.imm8; },
        _read_imm8s() { return vals.imm8s; },
        _read_imm16() { return vals.imm16; },
        _read_imm32s() { return vals.imm32s; },
        _is_asize_32() { return vals.asize_32; },
        _printf(...args) { console.log(...args); },
        ___assert_fail(...args) { console.error(...args); console.assert(false); },
        abort() { console.assert(false); },
    },
};

const memory_size = 256 * 1024 * 1024;

v86util.load_wasm(
    "build/codegen-test.wasm",
    wasm_test_funcs,
    memory_size + GUEST_MEMORY_START,
    WASM_TABLE_SIZE,
    wm => {
        try {<commit_msg>Fix codegen tests<commit_after>#!/usr/bin/env node
"use strict";

const fs = require("fs");

global.v86util = {};

// copied from const.js
global.WASM_TABLE_SIZE = 0x10000;
// The space we need for misc internal state before the beginning of mem8; see global_pointers.h
global.GUEST_MEMORY_START = 0x10000 + 0x100000 * 6;
global.WASM_PAGE_SIZE = 64 * 1024;

global.dbg_assert = x => console.assert(x);

require("../../src/browser/lib.js");

const Codegen = require("../../src/codegen.js");

const codegen_module_buffer = fs.readFileSync(__dirname + "/../../build/codegen-test.wasm");

const vals = {
    imm8: 1,
    imm8s: 1,
    imm16: 2,
    imm32s: 3,
    asize_32: false,
    reg16: 4,
    reg32s: 4,
    instruction_pointer: 556,
    previous_ip: 560,
    prefixes: 0,
    timestamp_counter: 0,
};

const wasm_test_funcs = {
    env: {
        _read_imm8() { return vals.imm8; },
        _read_imm8s() { return vals.imm8s; },
        _read_imm16() { return vals.imm16; },
        _read_imm32s() { return vals.imm32s; },
        _is_asize_32() { return vals.asize_32; },
        _has_flat_segmentation() { return false; },
        _printf(...args) { console.log(...args); },
        ___assert_fail(...args) { console.error(...args); console.assert(false); },
        abort() { console.assert(false); },
    },
};

const memory_size = 256 * 1024 * 1024;

v86util.load_wasm(
    "build/codegen-test.wasm",
    wasm_test_funcs,
    memory_size + GUEST_MEMORY_START,
    WASM_TABLE_SIZE,
    wm => {
        try {
{'fraction_non_alphanumeric': 0.15477792732166892, 'fraction_numerical': 0.05652759084791386, 'mean_word_length': 2.861038961038961, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2066847', 'n_tokens_mistral': 1221, 'n_tokens_neox': 1098, 'n_words': 221}