cranelift-wasm: Retain both the Wasm and Cranelift types of tables
This commit is contained in:
@@ -108,6 +108,7 @@ pub fn parse_import_section<'data>(
|
|||||||
ImportSectionEntryType::Table(ref tab) => {
|
ImportSectionEntryType::Table(ref tab) => {
|
||||||
environ.declare_table_import(
|
environ.declare_table_import(
|
||||||
Table {
|
Table {
|
||||||
|
wasm_ty: tab.element_type,
|
||||||
ty: match tabletype_to_type(tab.element_type, environ)? {
|
ty: match tabletype_to_type(tab.element_type, environ)? {
|
||||||
Some(t) => TableElementType::Val(t),
|
Some(t) => TableElementType::Val(t),
|
||||||
None => TableElementType::Func,
|
None => TableElementType::Func,
|
||||||
@@ -157,6 +158,7 @@ pub fn parse_table_section(
|
|||||||
for entry in tables {
|
for entry in tables {
|
||||||
let table = entry?;
|
let table = entry?;
|
||||||
environ.declare_table(Table {
|
environ.declare_table(Table {
|
||||||
|
wasm_ty: table.element_type,
|
||||||
ty: match tabletype_to_type(table.element_type, environ)? {
|
ty: match tabletype_to_type(table.element_type, environ)? {
|
||||||
Some(t) => TableElementType::Val(t),
|
Some(t) => TableElementType::Val(t),
|
||||||
None => TableElementType::Func,
|
None => TableElementType::Func,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//! Helper functions and structures for the translation.
|
//! Helper functions and structures for the translation.
|
||||||
use crate::environ::{TargetEnvironment, WasmResult};
|
use crate::environ::{TargetEnvironment, WasmResult, WasmType};
|
||||||
use crate::state::ModuleTranslationState;
|
use crate::state::ModuleTranslationState;
|
||||||
use crate::wasm_unsupported;
|
use crate::wasm_unsupported;
|
||||||
use core::u32;
|
use core::u32;
|
||||||
@@ -104,7 +104,9 @@ pub enum GlobalInit {
|
|||||||
/// WebAssembly table.
|
/// WebAssembly table.
|
||||||
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
|
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
|
||||||
pub struct Table {
|
pub struct Table {
|
||||||
/// The type of data stored in elements of the table.
|
/// The table elements' Wasm type.
|
||||||
|
pub wasm_ty: WasmType,
|
||||||
|
/// The table elements' Cranelift type.
|
||||||
pub ty: TableElementType,
|
pub ty: TableElementType,
|
||||||
/// The minimum number of elements in the table.
|
/// The minimum number of elements in the table.
|
||||||
pub minimum: u32,
|
pub minimum: u32,
|
||||||
|
|||||||
@@ -201,6 +201,7 @@ fn is_table_compatible(exported: &TablePlan, imported: &TablePlan) -> bool {
|
|||||||
let TablePlan {
|
let TablePlan {
|
||||||
table:
|
table:
|
||||||
Table {
|
Table {
|
||||||
|
wasm_ty: exported_wasm_ty,
|
||||||
ty: exported_ty,
|
ty: exported_ty,
|
||||||
minimum: exported_minimum,
|
minimum: exported_minimum,
|
||||||
maximum: exported_maximum,
|
maximum: exported_maximum,
|
||||||
@@ -210,6 +211,7 @@ fn is_table_compatible(exported: &TablePlan, imported: &TablePlan) -> bool {
|
|||||||
let TablePlan {
|
let TablePlan {
|
||||||
table:
|
table:
|
||||||
Table {
|
Table {
|
||||||
|
wasm_ty: imported_wasm_ty,
|
||||||
ty: imported_ty,
|
ty: imported_ty,
|
||||||
minimum: imported_minimum,
|
minimum: imported_minimum,
|
||||||
maximum: imported_maximum,
|
maximum: imported_maximum,
|
||||||
@@ -217,7 +219,8 @@ fn is_table_compatible(exported: &TablePlan, imported: &TablePlan) -> bool {
|
|||||||
style: _imported_style,
|
style: _imported_style,
|
||||||
} = imported;
|
} = imported;
|
||||||
|
|
||||||
is_table_element_type_compatible(*exported_ty, *imported_ty)
|
exported_wasm_ty == imported_wasm_ty
|
||||||
|
&& is_table_element_type_compatible(*exported_ty, *imported_ty)
|
||||||
&& imported_minimum <= exported_minimum
|
&& imported_minimum <= exported_minimum
|
||||||
&& (imported_maximum.is_none()
|
&& (imported_maximum.is_none()
|
||||||
|| (!exported_maximum.is_none()
|
|| (!exported_maximum.is_none()
|
||||||
|
|||||||
Reference in New Issue
Block a user