Remove math_pow, move declarations from shared.h to cpu.h
This commit is contained in:
parent
b8b5f78dba
commit
1faec0e669
|
@ -173,7 +173,6 @@ function V86Starter(options)
|
|||
"_mmap_write32": function(addr, value) { return cpu.mmap_write32(addr, value); },
|
||||
|
||||
"_int_log2": function(val) { return v86util.int_log2(val); },
|
||||
"_math_pow": function(x, y) { return Math.pow(x, y); },
|
||||
|
||||
"_popa16": function() { return cpu.popa16.apply(cpu, arguments); },
|
||||
"_popa32": function() { return cpu.popa32.apply(cpu, arguments); },
|
||||
|
@ -223,6 +222,7 @@ function V86Starter(options)
|
|||
|
||||
"_codegen_finalize": (cache_index, virt_start, start, end) => cpu.codegen_finalize(cache_index, virt_start, start, end),
|
||||
|
||||
// see https://github.com/kripken/emscripten/blob/incoming/src/library.js
|
||||
"_atan2": Math.atan2,
|
||||
"_sin": Math.sin,
|
||||
"_cos": Math.cos,
|
||||
|
@ -232,6 +232,9 @@ function V86Starter(options)
|
|||
"_llvm_exp2_f64": (x) => Math.pow(2, x),
|
||||
"_log": Math.log,
|
||||
"_round": Math.round,
|
||||
"_ldexp": function(x, exp) {
|
||||
return x * Math.pow(2, exp);
|
||||
},
|
||||
};
|
||||
|
||||
const wasm_globals = {
|
||||
|
|
|
@ -1,8 +1,59 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "shared.h"
|
||||
#include "const.h"
|
||||
|
||||
union reg128 {
|
||||
int8_t i8[16];
|
||||
int16_t i16[8];
|
||||
int32_t i32[4];
|
||||
int64_t i64[2];
|
||||
uint8_t u8[16];
|
||||
uint16_t u16[8];
|
||||
uint32_t u32[4];
|
||||
uint64_t u64[2];
|
||||
};
|
||||
typedef char assert_size_reg128[(sizeof(union reg128) == 16) * 2 - 1];
|
||||
|
||||
union reg64 {
|
||||
int8_t i8[8];
|
||||
int16_t i16[4];
|
||||
int32_t i32[2];
|
||||
int64_t i64[1];
|
||||
uint8_t u8[8];
|
||||
uint16_t u16[4];
|
||||
uint32_t u32[2];
|
||||
uint64_t u64[1];
|
||||
double f64[1];
|
||||
};
|
||||
typedef char assertion_size_reg64[(sizeof(union reg64) == 8) * 2 - 1];
|
||||
|
||||
struct code_cache {
|
||||
// Address of the start of the basic block
|
||||
uint32_t start_addr;
|
||||
uint32_t end_addr;
|
||||
// Address of the instruction immediately after the basic block ends
|
||||
int32_t opcode[1]; // TODO: Remove in debug mode
|
||||
int32_t len;
|
||||
int32_t is_32;
|
||||
// Cleanliness status of the entry's "group" (based on
|
||||
// DIRTY_ARR_SHIFT). Value only has meaning in relation with the
|
||||
// group_dirtiness value.
|
||||
uint32_t group_status;
|
||||
};
|
||||
struct code_cache jit_cache_arr[WASM_TABLE_SIZE];
|
||||
|
||||
// Flag indicating whether the instruction that just ran was a jump of some sort
|
||||
extern uint32_t jit_jump;
|
||||
|
||||
// Count of how many times prime_hash(address) has been called through a jump
|
||||
extern int32_t hot_code_addresses[HASH_PRIME];
|
||||
// An array indicating the current "initial group status" for entries that map
|
||||
// to the same group due to the shift
|
||||
extern uint32_t group_dirtiness[GROUP_DIRTINESS_LENGTH];
|
||||
|
||||
void after_jump(void);
|
||||
void diverged(void);
|
||||
|
|
|
@ -187,7 +187,7 @@ double_t fpu_load_m80(uint32_t addr)
|
|||
// An alternative write the mantissa, sign and exponent in the
|
||||
// float64_byte and return float64[0]
|
||||
|
||||
return mantissa * math_pow(2, exponent - 63);
|
||||
return mantissa * pow(2, exponent - 63);
|
||||
}
|
||||
|
||||
void fpu_stack_fault()
|
||||
|
|
|
@ -64,3 +64,8 @@ extern void io_port_write8(int32_t, int32_t);
|
|||
extern void io_port_write16(int32_t, int32_t);
|
||||
extern void io_port_write32(int32_t, int32_t);
|
||||
extern int32_t convert_f64_to_i32(double_t);
|
||||
extern void call_indirect(int32_t index);
|
||||
extern void jit_clear_func(int32_t index);
|
||||
extern void call_interrupt_vector(int32_t interrupt_nr, bool is_software_int, bool has_error_code, int32_t error_code);
|
||||
extern void throw_cpu_exception(void);
|
||||
extern double_t microtick(void);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "cpu.h"
|
||||
|
||||
bool in_mapped_range(uint32_t addr);
|
||||
void jit_dirty_cache(uint32_t start_addr, uint32_t end_addr);
|
||||
|
|
|
@ -1,63 +1 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "const.h"
|
||||
|
||||
union reg128 {
|
||||
int8_t i8[16];
|
||||
int16_t i16[8];
|
||||
int32_t i32[4];
|
||||
int64_t i64[2];
|
||||
uint8_t u8[16];
|
||||
uint16_t u16[8];
|
||||
uint32_t u32[4];
|
||||
uint64_t u64[2];
|
||||
};
|
||||
typedef char assert_size_reg128[(sizeof(union reg128) == 16) * 2 - 1];
|
||||
|
||||
union reg64 {
|
||||
int8_t i8[8];
|
||||
int16_t i16[4];
|
||||
int32_t i32[2];
|
||||
int64_t i64[1];
|
||||
uint8_t u8[8];
|
||||
uint16_t u16[4];
|
||||
uint32_t u32[2];
|
||||
uint64_t u64[1];
|
||||
double f64[1];
|
||||
};
|
||||
typedef char assertion_size_reg64[(sizeof(union reg64) == 8) * 2 - 1];
|
||||
|
||||
struct code_cache {
|
||||
// Address of the start of the basic block
|
||||
uint32_t start_addr;
|
||||
uint32_t end_addr;
|
||||
// Address of the instruction immediately after the basic block ends
|
||||
int32_t opcode[1]; // TODO: Remove in debug mode
|
||||
int32_t len;
|
||||
int32_t is_32;
|
||||
// Cleanliness status of the entry's "group" (based on
|
||||
// DIRTY_ARR_SHIFT). Value only has meaning in relation with the
|
||||
// group_dirtiness value.
|
||||
uint32_t group_status;
|
||||
};
|
||||
struct code_cache jit_cache_arr[WASM_TABLE_SIZE];
|
||||
|
||||
// Flag indicating whether the instruction that just ran was a jump of some sort
|
||||
extern uint32_t jit_jump;
|
||||
|
||||
// Count of how many times prime_hash(address) has been called through a jump
|
||||
extern int32_t hot_code_addresses[HASH_PRIME];
|
||||
// An array indicating the current "initial group status" for entries that map
|
||||
// to the same group due to the shift
|
||||
extern uint32_t group_dirtiness[GROUP_DIRTINESS_LENGTH];
|
||||
|
||||
extern void call_indirect(int32_t index);
|
||||
extern void jit_clear_func(int32_t index);
|
||||
extern void call_interrupt_vector(int32_t interrupt_nr, bool is_software_int, bool has_error_code, int32_t error_code);
|
||||
extern void throw_cpu_exception(void);
|
||||
extern double_t math_pow(double_t, double_t);
|
||||
extern double_t microtick(void);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "shared.h"
|
||||
#include "cpu.h"
|
||||
|
||||
void mov_r_m64(int32_t addr, int32_t r);
|
||||
void movl_r128_m64(int32_t addr, int32_t r);
|
||||
|
|
Loading…
Reference in a new issue