Skip to content

Commit

Permalink
Merge branch 'feature/call-function-at-index-on-just-ctx' of github.c…
Browse files Browse the repository at this point in the history
…om:wasmerio/wasmer into feature/call-function-at-index-on-just-ctx
  • Loading branch information
Mark McCaskey committed Sep 19, 2019
2 parents a090bec + a9d8b22 commit f709122
Show file tree
Hide file tree
Showing 14 changed files with 430 additions and 181 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
lib/emscripten/emtests/* linguist-vendored
lib/spectests/spectests/* linguist-vendored
CHANGELOG.md merge=union
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Blocks of changes will separated by version increments.
## **[Unreleased]**

- [#803](https://github.com/wasmerio/wasmer/issues/803) Add method to `Ctx` to invoke functions by their `TableIndex`
- [#790](https://github.com/wasmerio/wasmer/pull/790) Fix flaky test failure with LLVM, switch to large code model.
- [#788](https://github.com/wasmerio/wasmer/pull/788) Use union merge on the changelog file.
- [#785](https://github.com/wasmerio/wasmer/pull/785) Include Apache license file for spectests.
- [#786](https://github.com/wasmerio/wasmer/pull/786) In the LLVM backend, lower atomic wasm operations to atomic machine instructions.
- [#784](https://github.com/wasmerio/wasmer/pull/784) Fix help string for wasmer run.

## 0.7.0 - 2019-09-12

Expand Down
266 changes: 133 additions & 133 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ jobs:
- template: .azure/install-llvm.yml
- template: .azure/install-sccache.yml
- template: .azure/install-cmake.yml
- bash: |
hostname
uname -a
displayName: System info (*nix)
condition: and(succeeded(), not(eq(variables['Agent.OS'], 'Windows_NT')))
- bash: |
cat /proc/cpuinfo
cat /proc/meminfo
displayName: System info - Extended (Linux)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
- bash: make test
displayName: Tests (*nix)
condition: and(succeeded(), not(eq(variables['Agent.OS'], 'Windows_NT')))
Expand Down
4 changes: 2 additions & 2 deletions lib/llvm-backend/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ impl LLVMBackend {
&TargetMachine::get_host_cpu_name().to_string(),
&TargetMachine::get_host_cpu_features().to_string(),
OptimizationLevel::Aggressive,
RelocMode::PIC,
CodeModel::Default,
RelocMode::Static,
CodeModel::Large,
)
.unwrap();

Expand Down
82 changes: 53 additions & 29 deletions lib/llvm-backend/src/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4784,8 +4784,10 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
effective_address,
);
let result = builder.build_load(effective_address, &state.var_name());
// TODO: LLVMSetAlignment(result.as_value_ref(), 4);
// TODO: LLVMSetOrdering(result.as_value_ref(), LLVMAtomicOrderingSequentiallyConsistent);
let load = result.as_instruction_value().unwrap();
load.set_alignment(4).unwrap();
load.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
.unwrap();
state.push1(result);
}
Operator::I64AtomicLoad { ref memarg } => {
Expand All @@ -4809,8 +4811,10 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
effective_address,
);
let result = builder.build_load(effective_address, &state.var_name());
// TODO: LLVMSetAlignment(result.as_value_ref(), 8);
// TODO: LLVMSetOrdering(result.as_value_ref(), LLVMAtomicOrderingSequentiallyConsistent);
let load = result.as_instruction_value().unwrap();
load.set_alignment(8).unwrap();
load.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
.unwrap();
state.push1(result);
}
Operator::I32AtomicLoad8U { ref memarg } => {
Expand All @@ -4836,8 +4840,10 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
let narrow_result = builder
.build_load(effective_address, &state.var_name())
.into_int_value();
// TODO: LLVMSetAlignment(result.as_value_ref(), 1);
// TODO: LLVMSetOrdering(result.as_value_ref(), LLVMAtomicOrderingSequentiallyConsistent);
let load = narrow_result.as_instruction_value().unwrap();
load.set_alignment(1).unwrap();
load.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
.unwrap();
let result =
builder.build_int_z_extend(narrow_result, intrinsics.i32_ty, &state.var_name());
state.push1(result);
Expand Down Expand Up @@ -4865,8 +4871,10 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
let narrow_result = builder
.build_load(effective_address, &state.var_name())
.into_int_value();
// TODO: LLVMSetAlignment(result.as_value_ref(), 2);
// TODO: LLVMSetOrdering(result.as_value_ref(), LLVMAtomicOrderingSequentiallyConsistent);
let load = narrow_result.as_instruction_value().unwrap();
load.set_alignment(2).unwrap();
load.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
.unwrap();
let result =
builder.build_int_z_extend(narrow_result, intrinsics.i32_ty, &state.var_name());
state.push1(result);
Expand Down Expand Up @@ -4894,8 +4902,10 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
let narrow_result = builder
.build_load(effective_address, &state.var_name())
.into_int_value();
// TODO: LLVMSetAlignment(result.as_value_ref(), 1);
// TODO: LLVMSetOrdering(result.as_value_ref(), LLVMAtomicOrderingSequentiallyConsistent);
let load = narrow_result.as_instruction_value().unwrap();
load.set_alignment(1).unwrap();
load.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
.unwrap();
let result =
builder.build_int_z_extend(narrow_result, intrinsics.i64_ty, &state.var_name());
state.push1(result);
Expand Down Expand Up @@ -4923,8 +4933,10 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
let narrow_result = builder
.build_load(effective_address, &state.var_name())
.into_int_value();
// TODO: LLVMSetAlignment(result.as_value_ref(), 2);
// TODO: LLVMSetOrdering(result.as_value_ref(), LLVMAtomicOrderingSequentiallyConsistent);
let load = narrow_result.as_instruction_value().unwrap();
load.set_alignment(2).unwrap();
load.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
.unwrap();
let result =
builder.build_int_z_extend(narrow_result, intrinsics.i64_ty, &state.var_name());
state.push1(result);
Expand Down Expand Up @@ -4952,8 +4964,10 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
let narrow_result = builder
.build_load(effective_address, &state.var_name())
.into_int_value();
// TODO: LLVMSetAlignment(result.as_value_ref(), 4);
// TODO: LLVMSetOrdering(result.as_value_ref(), LLVMAtomicOrderingSequentiallyConsistent);
let load = narrow_result.as_instruction_value().unwrap();
load.set_alignment(4).unwrap();
load.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
.unwrap();
let result =
builder.build_int_z_extend(narrow_result, intrinsics.i64_ty, &state.var_name());
state.push1(result);
Expand All @@ -4979,9 +4993,11 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
memarg,
effective_address,
);
builder.build_store(effective_address, value);
// TODO: LLVMSetAlignment(result.as_value_ref(), 4);
// TODO: LLVMSetOrdering(result.as_value_ref(), LLVMAtomicOrderingSequentiallyConsistent);
let store = builder.build_store(effective_address, value);
store.set_alignment(4).unwrap();
store
.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
.unwrap();
}
Operator::I64AtomicStore { ref memarg } => {
let value = state.pop1()?;
Expand All @@ -5004,9 +5020,11 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
memarg,
effective_address,
);
builder.build_store(effective_address, value);
// TODO: LLVMSetAlignment(result.as_value_ref(), 8);
// TODO: LLVMSetOrdering(result.as_value_ref(), LLVMAtomicOrderingSequentiallyConsistent);
let store = builder.build_store(effective_address, value);
store.set_alignment(8).unwrap();
store
.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
.unwrap();
}
Operator::I32AtomicStore8 { ref memarg } | Operator::I64AtomicStore8 { ref memarg } => {
let value = state.pop1()?.into_int_value();
Expand All @@ -5031,9 +5049,11 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
);
let narrow_value =
builder.build_int_truncate(value, intrinsics.i8_ty, &state.var_name());
builder.build_store(effective_address, narrow_value);
// TODO: LLVMSetAlignment(result.as_value_ref(), 1);
// TODO: LLVMSetOrdering(result.as_value_ref(), LLVMAtomicOrderingSequentiallyConsistent);
let store = builder.build_store(effective_address, narrow_value);
store.set_alignment(1).unwrap();
store
.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
.unwrap();
}
Operator::I32AtomicStore16 { ref memarg }
| Operator::I64AtomicStore16 { ref memarg } => {
Expand All @@ -5059,9 +5079,11 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
);
let narrow_value =
builder.build_int_truncate(value, intrinsics.i16_ty, &state.var_name());
builder.build_store(effective_address, narrow_value);
// TODO: LLVMSetAlignment(result.as_value_ref(), 2);
// TODO: LLVMSetOrdering(result.as_value_ref(), LLVMAtomicOrderingSequentiallyConsistent);
let store = builder.build_store(effective_address, narrow_value);
store.set_alignment(2).unwrap();
store
.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
.unwrap();
}
Operator::I64AtomicStore32 { ref memarg } => {
let value = state.pop1()?.into_int_value();
Expand All @@ -5086,9 +5108,11 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
);
let narrow_value =
builder.build_int_truncate(value, intrinsics.i32_ty, &state.var_name());
builder.build_store(effective_address, narrow_value);
// TODO: LLVMSetAlignment(result.as_value_ref(), 4);
// TODO: LLVMSetOrdering(result.as_value_ref(), LLVMAtomicOrderingSequentiallyConsistent);
let store = builder.build_store(effective_address, narrow_value);
store.set_alignment(4).unwrap();
store
.set_atomic_ordering(AtomicOrdering::SequentiallyConsistent)
.unwrap();
}
Operator::I32AtomicRmw8UAdd { ref memarg } => {
let value = state.pop1()?.into_int_value();
Expand Down
28 changes: 21 additions & 7 deletions lib/singlepass-backend/src/codegen_x64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ impl RunnableModule for X64ExecutionContext {

#[derive(Debug)]
pub struct CodegenError {
pub message: &'static str,
pub message: String,
}

#[derive(Copy, Clone, Debug)]
Expand Down Expand Up @@ -474,15 +474,15 @@ impl ModuleCodeGenerator<X64FunctionCode, X64ExecutionContext, CodegenError>
Some(x) => x,
None => {
return Err(CodegenError {
message: "label not found",
message: format!("label not found"),
});
}
};
let offset = match offset {
Some(x) => x,
None => {
return Err(CodegenError {
message: "offset is none",
message: format!("offset is none"),
});
}
};
Expand Down Expand Up @@ -3873,7 +3873,11 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
returns: match ty {
WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![],
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
_ => panic!("multi-value returns not yet implemented"),
_ => {
return Err(CodegenError {
message: format!("multi-value returns not yet implemented"),
})
}
},
value_stack_depth: self.value_stack.len(),
state: self.machine.state.clone(),
Expand Down Expand Up @@ -3980,7 +3984,11 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
returns: match ty {
WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![],
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
_ => panic!("multi-value returns not yet implemented"),
_ => {
return Err(CodegenError {
message: format!("multi-value returns not yet implemented"),
})
}
},
value_stack_depth: self.value_stack.len(),
state: self.machine.state.clone(),
Expand All @@ -4005,7 +4013,11 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
returns: match ty {
WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![],
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
_ => panic!("multi-value returns not yet implemented"),
_ => {
return Err(CodegenError {
message: format!("multi-value returns not yet implemented"),
})
}
},
value_stack_depth: self.value_stack.len(),
state: self.machine.state.clone(),
Expand Down Expand Up @@ -4966,7 +4978,9 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
}
}
_ => {
panic!("not yet implemented: {:?}", op);
return Err(CodegenError {
message: format!("not yet implemented: {:?}", op),
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/singlepass-backend/src/emitter_x64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ impl Emitter for Assembler {
match loc {
Location::GPR(x) => dynasm!(self ; call Rq(x as u8)),
Location::Memory(base, disp) => dynasm!(self ; call QWORD [Rq(base as u8) + disp]),
_ => unreachable!(),
_ => panic!("CALL {:?}", loc),
}
}

Expand Down
Loading

0 comments on commit f709122

Please sign in to comment.