Skip to content

Commit

Permalink
chore: Update wasmparser (#77)
Browse files Browse the repository at this point in the history
* chore: Update to wasmparser 0.40

* chore: Update to wasmparser 0.41

* chore: Update wasmparser to 0.42

* chore: Update wasmparser to 0.43

* chore: Update wasmparser to 0.44

* chore: Update wasmparser to 0.45

* chore: Update wasmparser to 0.46

* chore: Update wasmparser to 0.47

* chore: Update wasmparser to 0.48

* chore: cargo fmt fix

* chore: Update wasmparser to 0.49

* chore: Update wasmparser to 0.50

* chore: Update wasmparser to 0.51

* chore: Update wasmparser to 0.52

* chore: Update wasmparser to 0.53

* chore: Update wasmparser to 0.54

* chore: Update wasmparser to 0.55

* chore: Update wasmparser to 0.56

* chore: Update wasmparser to 0.57

* chore: Update wasmparser to 0.58

* chore: Make unimplemented panics more exhaustive

* refactor: make unwraps expect with logging
  • Loading branch information
bushidocodes authored Feb 18, 2022
1 parent 7aa4145 commit 7bfae9b
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 86 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ flexi_logger = "0.22.3"
llvm-alt = { git = "https://github.com/gwsystems/llvm-rs", branch = "sfbase"}
log = "0.4.14"
structopt = "0.3.26"
wasmparser = "0.39.2"
wasmparser = "0.58.0"

[profile.release]
debug = true
48 changes: 24 additions & 24 deletions src/codegen/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,24 +449,24 @@ pub fn compile_block<'a, 'b, 'c>(
stack.push(res);
}

Instruction::GetLocal { index } => {
Instruction::LocalGet { index } => {
stack.push(locals[index as usize]);
}
Instruction::SetLocal { index } => {
Instruction::LocalSet { index } => {
let v = stack.pop().unwrap();
locals[index as usize] = v;
}
Instruction::TeeLocal { index } => {
// Differs from `SetLocal` in that it doesn't pop it's operand off the stack
Instruction::LocalTee { index } => {
// Differs from `LocalSet` in that it doesn't pop it's operand off the stack
let v = *stack.last().unwrap();
locals[index as usize] = v;
}

Instruction::GetGlobal { index } => {
Instruction::GlobalGet { index } => {
let v = m_ctx.globals[index as usize].load(m_ctx, b);
stack.push(v);
}
Instruction::SetGlobal { index } => {
Instruction::GlobalSet { index } => {
let v = stack.pop().unwrap();
m_ctx.globals[index as usize].store(m_ctx, b, v);
}
Expand All @@ -490,7 +490,7 @@ pub fn compile_block<'a, 'b, 'c>(
stack.push(result);
}

Instruction::I32TruncSF32 => {
Instruction::I32TruncF32S => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::F32);
let result = if m_ctx.opt.use_fast_unsafe_implementations {
Expand All @@ -500,7 +500,7 @@ pub fn compile_block<'a, 'b, 'c>(
};
stack.push(result);
}
Instruction::I32TruncUF32 => {
Instruction::I32TruncF32U => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::F32);
let result = if m_ctx.opt.use_fast_unsafe_implementations {
Expand All @@ -510,7 +510,7 @@ pub fn compile_block<'a, 'b, 'c>(
};
stack.push(result);
}
Instruction::I32TruncSF64 => {
Instruction::I32TruncF64S => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::F64);
let result = if m_ctx.opt.use_fast_unsafe_implementations {
Expand All @@ -520,7 +520,7 @@ pub fn compile_block<'a, 'b, 'c>(
};
stack.push(result);
}
Instruction::I32TruncUF64 => {
Instruction::I32TruncF64U => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::F64);
let result = if m_ctx.opt.use_fast_unsafe_implementations {
Expand Down Expand Up @@ -689,13 +689,13 @@ pub fn compile_block<'a, 'b, 'c>(
stack.push(v);
}

Instruction::I64ExtendSI32 => {
Instruction::I64ExtendI32S => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::I32);
let result = b.build_sext(v, <i64>::get_type(m_ctx.llvm_ctx));
stack.push(result);
}
Instruction::I64ExtendUI32 => {
Instruction::I64ExtendI32U => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::I32);
let result = b.build_zext(v, <i64>::get_type(m_ctx.llvm_ctx));
Expand All @@ -709,25 +709,25 @@ pub fn compile_block<'a, 'b, 'c>(
stack.push(result);
}

Instruction::I64TruncSF32 => {
Instruction::I64TruncF32S => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::F32);
let result = b.build_call(get_stub_function(m_ctx, I64_TRUNC_F32), &[v]);
stack.push(result);
}
Instruction::I64TruncUF32 => {
Instruction::I64TruncF32U => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::F32);
let result = b.build_call(get_stub_function(m_ctx, U64_TRUNC_F32), &[v]);
stack.push(result);
}
Instruction::I64TruncSF64 => {
Instruction::I64TruncF64S => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::F64);
let result = b.build_call(get_stub_function(m_ctx, I64_TRUNC_F64), &[v]);
stack.push(result);
}
Instruction::I64TruncUF64 => {
Instruction::I64TruncF64U => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::F64);
let result = b.build_call(get_stub_function(m_ctx, U64_TRUNC_F64), &[v]);
Expand Down Expand Up @@ -906,25 +906,25 @@ pub fn compile_block<'a, 'b, 'c>(
stack.push(result);
}

Instruction::F32ConvertSI32 => {
Instruction::F32ConvertI32S => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::I32);
let result = b.build_sitofp(v, <f32>::get_type(m_ctx.llvm_ctx));
stack.push(result);
}
Instruction::F32ConvertUI32 => {
Instruction::F32ConvertI32U => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::I32);
let result = b.build_uitofp(v, <f32>::get_type(m_ctx.llvm_ctx));
stack.push(result);
}
Instruction::F32ConvertSI64 => {
Instruction::F32ConvertI64S => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::I64);
let result = b.build_sitofp(v, <f32>::get_type(m_ctx.llvm_ctx));
stack.push(result);
}
Instruction::F32ConvertUI64 => {
Instruction::F32ConvertI64U => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::I64);
let result = b.build_uitofp(v, <f32>::get_type(m_ctx.llvm_ctx));
Expand Down Expand Up @@ -1021,25 +1021,25 @@ pub fn compile_block<'a, 'b, 'c>(
stack.push(result);
}

Instruction::F64ConvertSI32 => {
Instruction::F64ConvertI32S => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::I32);
let result = b.build_sitofp(v, <f64>::get_type(m_ctx.llvm_ctx));
stack.push(result);
}
Instruction::F64ConvertUI32 => {
Instruction::F64ConvertI32U => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::I32);
let result = b.build_uitofp(v, <f64>::get_type(m_ctx.llvm_ctx));
stack.push(result);
}
Instruction::F64ConvertSI64 => {
Instruction::F64ConvertI64S => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::I64);
let result = b.build_sitofp(v, <f64>::get_type(m_ctx.llvm_ctx));
stack.push(result);
}
Instruction::F64ConvertUI64 => {
Instruction::F64ConvertI64U => {
let v = stack.pop().unwrap();
assert_type(m_ctx, v, Type::I64);
let result = b.build_uitofp(v, <f64>::get_type(m_ctx.llvm_ctx));
Expand Down
1 change: 0 additions & 1 deletion src/codegen/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ pub fn generate_offset_function<'a>(
) -> &'a llvm::Function {
let offset_func_name = format!("init_{}_offset_{}", prefix, n);
let offset_func_type = wasmparser::FuncType {
form: wasmparser::Type::Func,
params: Box::new([]),
returns: Box::new([wasmparser::Type::I32]),
};
Expand Down
Loading

0 comments on commit 7bfae9b

Please sign in to comment.