Wasm: Allow environment to translate some global.set/get operations

Spidermonkey will need to emit pre/post barriers for global.set/get to a
reference type. #1176 and #1299 plan to add a template concept that could
be used to implement this. Once that has been stabilized, we should be able
to remove this code in favor of templates easily.
This commit is contained in:
Ryan Hunt
2020-01-06 15:41:02 -06:00
parent f41bf5ecca
commit 41f225804b
3 changed files with 50 additions and 1 deletions

View File

@@ -28,7 +28,7 @@ use crate::state::{ControlStackFrame, ElseData, FuncTranslationState, ModuleTran
use crate::translation_utils::{
blocktype_params_results, ebb_with_params, f32_translation, f64_translation,
};
use crate::translation_utils::{FuncIndex, MemoryIndex, SignatureIndex, TableIndex};
use crate::translation_utils::{FuncIndex, GlobalIndex, MemoryIndex, SignatureIndex, TableIndex};
use crate::wasm_unsupported;
use core::{i32, u32};
use cranelift_codegen::ir::condcodes::{FloatCC, IntCC};
@@ -95,6 +95,10 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
let flags = ir::MemFlags::trusted();
builder.ins().load(ty, flags, addr, offset)
}
GlobalVariable::Custom => environ.translate_custom_global_get(
builder.cursor(),
GlobalIndex::from_u32(*global_index),
)?,
};
state.push1(val);
}
@@ -108,6 +112,14 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
debug_assert_eq!(ty, builder.func.dfg.value_type(val));
builder.ins().store(flags, val, addr, offset);
}
GlobalVariable::Custom => {
let val = state.pop1();
environ.translate_custom_global_set(
builder.cursor(),
GlobalIndex::from_u32(*global_index),
val,
)?;
}
}
}
/********************************* Stack misc ***************************************