Use WasmError::Unsupported rather than panic for unsupported extensions.

This commit is contained in:
Dan Gohman
2018-06-15 08:38:40 -07:00
parent 1cab2f2d73
commit c506f4cf6b

View File

@@ -27,7 +27,7 @@ use cretonne_codegen::ir::types::*;
use cretonne_codegen::ir::{self, InstBuilder, JumpTableData, MemFlags}; use cretonne_codegen::ir::{self, InstBuilder, JumpTableData, MemFlags};
use cretonne_codegen::packed_option::ReservedValue; use cretonne_codegen::packed_option::ReservedValue;
use cretonne_frontend::{FunctionBuilder, Variable}; use cretonne_frontend::{FunctionBuilder, Variable};
use environ::{FuncEnvironment, GlobalValue, WasmResult}; use environ::{FuncEnvironment, GlobalValue, WasmError, WasmResult};
use state::{ControlStackFrame, TranslationState}; use state::{ControlStackFrame, TranslationState};
use std::collections::{hash_map, HashMap}; use std::collections::{hash_map, HashMap};
use std::vec::Vec; use std::vec::Vec;
@@ -636,7 +636,9 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
| Operator::I64TruncUSatF32 | Operator::I64TruncUSatF32
| Operator::I32TruncUSatF64 | Operator::I32TruncUSatF64
| Operator::I32TruncUSatF32 => { | Operator::I32TruncUSatF32 => {
panic!("proposed saturating conversion operators not yet supported"); return Err(WasmError::Unsupported(
"proposed saturating conversion operators",
));
} }
Operator::F32ReinterpretI32 => { Operator::F32ReinterpretI32 => {
let val = state.pop1(); let val = state.pop1();
@@ -881,7 +883,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
| Operator::I64AtomicRmw8UCmpxchg { .. } | Operator::I64AtomicRmw8UCmpxchg { .. }
| Operator::I64AtomicRmw16UCmpxchg { .. } | Operator::I64AtomicRmw16UCmpxchg { .. }
| Operator::I64AtomicRmw32UCmpxchg { .. } => { | Operator::I64AtomicRmw32UCmpxchg { .. } => {
panic!("proposed thread operators not yet supported"); return Err(WasmError::Unsupported("proposed thread operators"));
} }
}) })
} }