Allocate more space for codegen buffers

This commit is contained in:
Fabian 2018-02-02 19:00:13 -05:00
parent 5ce0643197
commit 26bb7c2caa
7 changed files with 33 additions and 29 deletions

View file

@ -268,7 +268,7 @@ function V86Starter(options)
v86util.load_wasm(
wasm_file,
{ "env": wasm_shared_funcs, "global" : wasm_globals },
options["memory_size"] + INTERNAL_MEM_SIZE,
options["memory_size"] + GUEST_MEMORY_START,
WASM_TABLE_SIZE,
wm => {
wm.instance.exports["__post_instantiate"]();

View file

@ -17,8 +17,8 @@ Codegen.prototype.reset = function()
this.wm.exports["_gen_reset"]();
};
Codegen.OUTPUT_OFFSET = 2048;
Codegen.STR_INPUT_OFFSET = Codegen.OUTPUT_OFFSET + 1024 - 32;
Codegen.OUTPUT_OFFSET = 0x1000;
Codegen.STR_INPUT_OFFSET = 0x3000;
Codegen.prototype.str_input = function(str)
{

View file

@ -366,7 +366,7 @@ var WASM_TABLE_SIZE = 0x10000;
/** @const */
// The space we need for misc internal state before the beginning of mem8; see global_pointers.h
const INTERNAL_MEM_SIZE = 4096 + 0x100000 * 6;
const GUEST_MEMORY_START = 0x10000 + 0x100000 * 6;
/** @const */
const WASM_PAGE_SIZE = 64 * 1024;

View file

@ -41,7 +41,7 @@ function CPU(bus, wm, codegen, coverage_logger)
* Translation Lookaside Buffer
* @const
*/
this.tlb_data = new Int32Array(wm.memory.buffer, 4096 + 0x100000*2, 0x100000);
this.tlb_data = new Int32Array(wm.memory.buffer, 0x10000 + 0x100000*2, 0x100000);
/**
* Information about which pages are cached in the tlb.
@ -52,13 +52,13 @@ function CPU(bus, wm, codegen, coverage_logger)
* 3 user, write
* @const
*/
this.tlb_info = new Uint8Array(wm.memory.buffer, 4096, 0x100000);
this.tlb_info = new Uint8Array(wm.memory.buffer, 0x10000, 0x100000);
/**
* Same as tlb_info, except it only contains global pages
* @const
*/
this.tlb_info_global = new Uint8Array(wm.memory.buffer, 4096 + 0x100000, 0x100000);
this.tlb_info_global = new Uint8Array(wm.memory.buffer, 0x10000 + 0x100000, 0x100000);
/**
* Wheter or not in protected mode
@ -678,9 +678,9 @@ CPU.prototype.create_memory = function(size)
var buffer = this.wm.memory.buffer;
this.mem8 = new Uint8Array(buffer, INTERNAL_MEM_SIZE, size);
this.mem16 = new Uint16Array(buffer, INTERNAL_MEM_SIZE, size >> 1);
this.mem32s = new Int32Array(buffer, INTERNAL_MEM_SIZE, size >> 2);
this.mem8 = new Uint8Array(buffer, GUEST_MEMORY_START, size);
this.mem16 = new Uint16Array(buffer, GUEST_MEMORY_START, size >> 1);
this.mem32s = new Int32Array(buffer, GUEST_MEMORY_START, size >> 2);
};
CPU.prototype.init = function(settings, device_bus)

View file

@ -11,8 +11,8 @@
#include "module_init.h"
#include "../global_pointers.h"
static Buffer op = { .start = (uint8_t* const) 2048, .ptr = (uint8_t*) 2048, .len = 1024 };
static Buffer cs = { .start = (uint8_t* const) 3072, .ptr = (uint8_t*) 3072, .len = 1024 };
static Buffer op = { .start = codegen_buffer_op, .ptr = codegen_buffer_op, .len = 0x1000 };
static Buffer cs = { .start = codegen_buffer_cs, .ptr = codegen_buffer_cs, .len = 0x1000 };
// location in memory where we store the result of the computation for testing
#define RESULT_LOC 1600

View file

@ -71,17 +71,9 @@ static union reg128* const reg_xmm = (union reg128* const) 828; // length 128
static uint64_t* const current_tsc = (uint64_t* const) 956;
static uint8_t* const codegen_buffers = (uint8_t* const) 2048; // length 2048
static uint8_t* const tlb_info = (uint8_t* const) 4096; // length 0x100000
static uint8_t* const tlb_info_global = (uint8_t* const) (4096 + 0x100000); // length 0x100000
static int32_t* const tlb_data = (int32_t* const) (4096 + 0x100000 + 0x100000); // length 0x100000*4
static uint8_t* const mem8 = (uint8_t* const) (4096 + 0x100000 * 6);
static uint16_t* const mem16 = (uint16_t* const) (4096 + 0x100000 * 6);
static int32_t* const mem32s = (int32_t* const) (4096 + 0x100000 * 6);
// gap
static double_t* const fpu_st = (double_t* const) 968; // length 64
static uint8_t* const fpu_st8 = (uint8_t* const) 968;
static int32_t* const fpu_st32 = (int32_t* const) 968;
static uint32_t* const fpu_stack_ptr = (uint32_t* const) 1032;
static int32_t* const fpu_control_word = (int32_t* const) 1036;
@ -92,8 +84,20 @@ static int32_t* const fpu_ip_selector = (int32_t* const) 1052;
static int32_t* const fpu_dp = (int32_t* const) 1056;
static int32_t* const fpu_dp_selector = (int32_t* const) 1060;
static double_t* const fpu_st = (double_t* const) 968;
static uint8_t* const fpu_st8 = (uint8_t* const) 968;
static int32_t* const fpu_st32 = (int32_t* const) 968;
static union reg64* const reg_mmx = (union reg64* const) 1064; // length 64
// gap
static uint8_t* const codegen_buffer_op = (uint8_t* const) 0x1000; // length 0x1000
static uint8_t* const codegen_buffer_cs = (uint8_t* const) 0x2000; // length 0x1000
static uint8_t* const codegen_string_input = (uint8_t* const) 0x3000; // length 32
// gap
static uint8_t* const tlb_info = (uint8_t* const) 0x10000; // length 0x100000
static uint8_t* const tlb_info_global = (uint8_t* const) (0x10000 + 0x100000); // length 0x100000
static int32_t* const tlb_data = (int32_t* const) (0x10000 + 0x100000 + 0x100000); // length 0x100000*4
static uint8_t* const mem8 = (uint8_t* const) (0x10000 + 0x100000 * 6);
static uint16_t* const mem16 = (uint16_t* const) (0x10000 + 0x100000 * 6);
static int32_t* const mem32s = (int32_t* const) (0x10000 + 0x100000 * 6);

View file

@ -8,7 +8,7 @@ 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.INTERNAL_MEM_SIZE = 4096 + 0x100000 * 6;
global.GUEST_MEMORY_START = 0x10000 + 0x100000 * 6;
global.WASM_PAGE_SIZE = 64 * 1024;
global.dbg_assert = x => console.assert(x);
@ -51,7 +51,7 @@ const memory_size = 256 * 1024 * 1024;
v86util.load_wasm(
"build/codegen-test.wasm",
wasm_test_funcs,
memory_size + INTERNAL_MEM_SIZE,
memory_size + GUEST_MEMORY_START,
WASM_TABLE_SIZE,
wm => {
try {