mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-12 22:05:33 +00:00
Merge remote-tracking branch 'origin/master' into fix/imul-relax
This commit is contained in:
commit
f327feccef
25
Cargo.lock
generated
25
Cargo.lock
generated
@ -680,19 +680,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.13.0"
|
||||
version = "0.14.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1422,7 +1410,7 @@ dependencies = [
|
||||
"cranelift-native 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde-bench 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1514,7 +1502,7 @@ dependencies = [
|
||||
"inkwell 0.1.0 (git+https://github.com/wasmerio/inkwell?branch=llvm7-0)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1577,7 +1565,7 @@ dependencies = [
|
||||
"indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"page_size 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1601,7 +1589,7 @@ dependencies = [
|
||||
"hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmparser 0.32.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1806,8 +1794,7 @@ dependencies = [
|
||||
"checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff"
|
||||
"checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
|
||||
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
|
||||
"checksum nix 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "921f61dc817b379d0834e45d5ec45beaacfae97082090a49c2cf30dcbc30206f"
|
||||
"checksum nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46f0f3210768d796e8fa79ec70ee6af172dacbe7147f5e69be5240a47778302b"
|
||||
"checksum nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce"
|
||||
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
|
||||
"checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6"
|
||||
"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
|
||||
|
10
install.sh
10
install.sh
@ -365,10 +365,14 @@ wasmer_download() {
|
||||
|
||||
# determine install directory if required
|
||||
if [ -z "$INSTALL_DIRECTORY" ]; then
|
||||
# findWasmerBinDirectory INSTALL_DIRECTORY
|
||||
INSTALL_DIRECTORY="$HOME/.wasmer"
|
||||
if [ -z "$WASMER_DIR" ]; then
|
||||
# If WASMER_DIR is not present
|
||||
INSTALL_DIRECTORY="$HOME/.wasmer"
|
||||
else
|
||||
# If WASMER_DIR is present
|
||||
INSTALL_DIRECTORY="${WASMER_DIR}"
|
||||
fi
|
||||
fi
|
||||
WASMER=INSTALL_DIRECTORY
|
||||
|
||||
# assemble expected release artifact name
|
||||
BINARY="wasmer-${OS}-${ARCH}.tar.gz"
|
||||
|
@ -18,7 +18,7 @@ hashbrown = "0.1"
|
||||
target-lexicon = "0.4.0"
|
||||
wasmparser = "0.32.1"
|
||||
byteorder = "1"
|
||||
nix = "0.13.0"
|
||||
nix = "0.14.0"
|
||||
libc = "0.2.49"
|
||||
rayon = "1.0"
|
||||
|
||||
|
@ -12,7 +12,7 @@ hashbrown = "0.1.8"
|
||||
smallvec = "0.6.8"
|
||||
goblin = "0.0.20"
|
||||
libc = "0.2.49"
|
||||
nix = "0.13.0"
|
||||
nix = "0.14.0"
|
||||
capstone = { version = "0.5.0", optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
|
@ -60,102 +60,37 @@ fn type_to_llvm(intrinsics: &Intrinsics, ty: Type) -> BasicTypeEnum {
|
||||
}
|
||||
}
|
||||
|
||||
fn trap_if_not_representatable_as_int(
|
||||
fn trap_if_not_representable_as_int(
|
||||
builder: &Builder,
|
||||
intrinsics: &Intrinsics,
|
||||
context: &Context,
|
||||
function: &FunctionValue,
|
||||
lower_bounds: f64,
|
||||
lower_bound: f64,
|
||||
upper_bound: f64,
|
||||
value: FloatValue,
|
||||
) {
|
||||
enum FloatSize {
|
||||
Bits32,
|
||||
Bits64,
|
||||
}
|
||||
let float_ty = value.get_type();
|
||||
|
||||
let lower_bound = float_ty.const_float(lower_bound);
|
||||
let upper_bound = float_ty.const_float(upper_bound);
|
||||
|
||||
// The 'U' in the float predicate is short for "unordered" which means that
|
||||
// the comparison will compare true if either operand is a NaN. Thus, NaNs
|
||||
// are out of bounds.
|
||||
let above_upper_bound_cmp =
|
||||
builder.build_float_compare(FloatPredicate::UGT, value, upper_bound, "above_upper_bound");
|
||||
let below_lower_bound_cmp =
|
||||
builder.build_float_compare(FloatPredicate::ULT, value, lower_bound, "below_lower_bound");
|
||||
let out_of_bounds = builder.build_or(
|
||||
above_upper_bound_cmp,
|
||||
below_lower_bound_cmp,
|
||||
"out_of_bounds",
|
||||
);
|
||||
|
||||
let failure_block = context.append_basic_block(function, "conversion_failure_block");
|
||||
let continue_block = context.append_basic_block(function, "conversion_success_block");
|
||||
|
||||
let float_ty = value.get_type();
|
||||
let (int_ty, float_size) = if float_ty == intrinsics.f32_ty {
|
||||
(intrinsics.i32_ty, FloatSize::Bits32)
|
||||
} else if float_ty == intrinsics.f64_ty {
|
||||
(intrinsics.i64_ty, FloatSize::Bits64)
|
||||
} else {
|
||||
unreachable!()
|
||||
};
|
||||
|
||||
let (exponent, invalid_exponent) = {
|
||||
let float_bits = builder
|
||||
.build_bitcast(value, int_ty, "float_bits")
|
||||
.into_int_value();
|
||||
let (shift_amount, exponent_mask, invalid_exponent) = match float_size {
|
||||
FloatSize::Bits32 => (23, 0b01111111100000000000000000000000, 0b11111111),
|
||||
FloatSize::Bits64 => (
|
||||
52,
|
||||
0b0111111111110000000000000000000000000000000000000000000000000000,
|
||||
0b11111111111,
|
||||
),
|
||||
};
|
||||
|
||||
builder.build_and(
|
||||
float_bits,
|
||||
int_ty.const_int(exponent_mask, false),
|
||||
"masked_bits",
|
||||
);
|
||||
|
||||
(
|
||||
builder.build_right_shift(
|
||||
float_bits,
|
||||
int_ty.const_int(shift_amount, false),
|
||||
false,
|
||||
"exponent",
|
||||
),
|
||||
invalid_exponent,
|
||||
)
|
||||
};
|
||||
|
||||
let is_invalid_float = builder.build_or(
|
||||
builder.build_int_compare(
|
||||
IntPredicate::EQ,
|
||||
exponent,
|
||||
int_ty.const_int(invalid_exponent, false),
|
||||
"is_not_normal",
|
||||
),
|
||||
builder.build_or(
|
||||
builder.build_float_compare(
|
||||
FloatPredicate::ULT,
|
||||
value,
|
||||
float_ty.const_float(lower_bounds),
|
||||
"less_than_lower_bounds",
|
||||
),
|
||||
builder.build_float_compare(
|
||||
FloatPredicate::UGT,
|
||||
value,
|
||||
float_ty.const_float(upper_bound),
|
||||
"greater_than_upper_bounds",
|
||||
),
|
||||
"float_not_in_bounds",
|
||||
),
|
||||
"is_invalid_float",
|
||||
);
|
||||
|
||||
let is_invalid_float = builder
|
||||
.build_call(
|
||||
intrinsics.expect_i1,
|
||||
&[
|
||||
is_invalid_float.as_basic_value_enum(),
|
||||
intrinsics.i1_ty.const_int(0, false).as_basic_value_enum(),
|
||||
],
|
||||
"is_invalid_float_expect",
|
||||
)
|
||||
.try_as_basic_value()
|
||||
.left()
|
||||
.unwrap()
|
||||
.into_int_value();
|
||||
|
||||
builder.build_conditional_branch(is_invalid_float, &failure_block, &continue_block);
|
||||
builder.build_conditional_branch(out_of_bounds, &failure_block, &continue_block);
|
||||
builder.position_at_end(&failure_block);
|
||||
builder.build_call(
|
||||
intrinsics.throw_trap,
|
||||
@ -1722,7 +1657,7 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
||||
}
|
||||
Operator::I32TruncSF32 => {
|
||||
let v1 = state.pop1()?.into_float_value();
|
||||
trap_if_not_representatable_as_int(
|
||||
trap_if_not_representable_as_int(
|
||||
builder,
|
||||
intrinsics,
|
||||
context,
|
||||
@ -1737,7 +1672,7 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
||||
}
|
||||
Operator::I32TruncSF64 => {
|
||||
let v1 = state.pop1()?.into_float_value();
|
||||
trap_if_not_representatable_as_int(
|
||||
trap_if_not_representable_as_int(
|
||||
builder,
|
||||
intrinsics,
|
||||
context,
|
||||
@ -1758,7 +1693,7 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
||||
}
|
||||
Operator::I64TruncSF32 => {
|
||||
let v1 = state.pop1()?.into_float_value();
|
||||
trap_if_not_representatable_as_int(
|
||||
trap_if_not_representable_as_int(
|
||||
builder,
|
||||
intrinsics,
|
||||
context,
|
||||
@ -1773,7 +1708,7 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
||||
}
|
||||
Operator::I64TruncSF64 => {
|
||||
let v1 = state.pop1()?.into_float_value();
|
||||
trap_if_not_representatable_as_int(
|
||||
trap_if_not_representable_as_int(
|
||||
builder,
|
||||
intrinsics,
|
||||
context,
|
||||
@ -1794,7 +1729,7 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
||||
}
|
||||
Operator::I32TruncUF32 => {
|
||||
let v1 = state.pop1()?.into_float_value();
|
||||
trap_if_not_representatable_as_int(
|
||||
trap_if_not_representable_as_int(
|
||||
builder,
|
||||
intrinsics,
|
||||
context,
|
||||
@ -1809,7 +1744,7 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
||||
}
|
||||
Operator::I32TruncUF64 => {
|
||||
let v1 = state.pop1()?.into_float_value();
|
||||
trap_if_not_representatable_as_int(
|
||||
trap_if_not_representable_as_int(
|
||||
builder,
|
||||
intrinsics,
|
||||
context,
|
||||
@ -1830,7 +1765,7 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
||||
}
|
||||
Operator::I64TruncUF32 => {
|
||||
let v1 = state.pop1()?.into_float_value();
|
||||
trap_if_not_representatable_as_int(
|
||||
trap_if_not_representable_as_int(
|
||||
builder,
|
||||
intrinsics,
|
||||
context,
|
||||
@ -1845,7 +1780,7 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
||||
}
|
||||
Operator::I64TruncUF64 => {
|
||||
let v1 = state.pop1()?.into_float_value();
|
||||
trap_if_not_representatable_as_int(
|
||||
trap_if_not_representable_as_int(
|
||||
builder,
|
||||
intrinsics,
|
||||
context,
|
||||
@ -2583,13 +2518,19 @@ impl ModuleCodeGenerator<LLVMFunctionCodeGenerator, LLVMBackend, CodegenError>
|
||||
if cfg!(test) {
|
||||
pass_manager.add_verifier_pass();
|
||||
}
|
||||
pass_manager.add_function_inlining_pass();
|
||||
pass_manager.add_promote_memory_to_register_pass();
|
||||
pass_manager.add_lower_expect_intrinsic_pass();
|
||||
pass_manager.add_scalar_repl_aggregates_pass();
|
||||
pass_manager.add_instruction_combining_pass();
|
||||
pass_manager.add_cfg_simplification_pass();
|
||||
pass_manager.add_aggressive_inst_combiner_pass();
|
||||
pass_manager.add_merged_load_store_motion_pass();
|
||||
pass_manager.add_new_gvn_pass();
|
||||
pass_manager.add_aggressive_dce_pass();
|
||||
pass_manager.add_gvn_pass();
|
||||
pass_manager.add_jump_threading_pass();
|
||||
pass_manager.add_correlated_value_propagation_pass();
|
||||
pass_manager.add_sccp_pass();
|
||||
pass_manager.add_instruction_combining_pass();
|
||||
pass_manager.add_reassociate_pass();
|
||||
pass_manager.add_cfg_simplification_pass();
|
||||
pass_manager.add_bit_tracking_dce_pass();
|
||||
pass_manager.add_slp_vectorize_pass();
|
||||
pass_manager.run_on_module(&self.module);
|
||||
|
||||
// self.module.print_to_stderr();
|
||||
|
@ -8,7 +8,7 @@ repository = "https://github.com/wasmerio/wasmer"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
nix = "0.12.0"
|
||||
nix = "0.14.0"
|
||||
page_size = "0.4.1"
|
||||
wasmparser = "0.32.1"
|
||||
parking_lot = "0.7.1"
|
||||
|
@ -14,7 +14,7 @@ dynasm = "0.3.2"
|
||||
dynasmrt = "0.3.1"
|
||||
lazy_static = "1.2.0"
|
||||
byteorder = "1"
|
||||
nix = "0.13.0"
|
||||
nix = "0.14.0"
|
||||
libc = "0.2.49"
|
||||
smallvec = "0.6.9"
|
||||
hashbrown = "0.1"
|
||||
|
Loading…
Reference in New Issue
Block a user