Revert "Auto merge of #63649 - tlively:emscripten-upstream-upgrade, r=alexcrichton"

This reverts commit 7870050796, reversing
changes made to 2e7244807a.
This commit is contained in:
Tyler Mandry
2019-10-05 21:38:45 -07:00
parent 7870050796
commit d16b7f705b
142 changed files with 537 additions and 377 deletions

View File

@@ -49,10 +49,8 @@ impl fmt::Debug for c_void {
/// Basic implementation of a `va_list`.
// The name is WIP, using `VaListImpl` for now.
#[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"),
not(target_arch = "x86_64")),
not(target_arch = "x86_64"), not(target_arch = "asmjs")),
all(target_arch = "aarch64", target_os = "ios"),
target_arch = "wasm32",
target_arch = "asmjs",
windows))]
#[repr(transparent)]
#[unstable(feature = "c_variadic",
@@ -69,10 +67,8 @@ pub struct VaListImpl<'f> {
}
#[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"),
not(target_arch = "x86_64")),
not(target_arch = "x86_64"), not(target_arch = "asmjs")),
all(target_arch = "aarch64", target_os = "ios"),
target_arch = "wasm32",
target_arch = "asmjs",
windows))]
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
@@ -141,6 +137,38 @@ pub struct VaListImpl<'f> {
_marker: PhantomData<&'f mut &'f c_void>,
}
/// asm.js ABI implementation of a `va_list`.
// asm.js uses the PNaCl ABI, which specifies that a `va_list` is
// an array of 4 32-bit integers, according to the old PNaCl docs at
// https://web.archive.org/web/20130518054430/https://www.chromium.org/nativeclient/pnacl/bitcode-abi#TOC-Derived-Types
// and clang does the same in `CreatePNaClABIBuiltinVaListDecl` from `lib/AST/ASTContext.cpp`
#[cfg(all(target_arch = "asmjs", not(windows)))]
#[repr(C)]
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "44930")]
#[lang = "va_list"]
pub struct VaListImpl<'f> {
inner: [crate::mem::MaybeUninit<i32>; 4],
_marker: PhantomData<&'f mut &'f c_void>,
}
#[cfg(all(target_arch = "asmjs", not(windows)))]
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "44930")]
impl<'f> fmt::Debug for VaListImpl<'f> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
unsafe {
write!(f, "va_list* [{:#x}, {:#x}, {:#x}, {:#x}]",
self.inner[0].read(), self.inner[1].read(),
self.inner[2].read(), self.inner[3].read())
}
}
}
/// A wrapper for a `va_list`
#[repr(transparent)]
#[derive(Debug)]
@@ -150,18 +178,14 @@ pub struct VaListImpl<'f> {
issue = "44930")]
pub struct VaList<'a, 'f: 'a> {
#[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"),
not(target_arch = "x86_64")),
not(target_arch = "x86_64"), not(target_arch = "asmjs")),
all(target_arch = "aarch64", target_os = "ios"),
target_arch = "wasm32",
target_arch = "asmjs",
windows))]
inner: VaListImpl<'f>,
#[cfg(all(any(target_arch = "aarch64", target_arch = "powerpc",
target_arch = "x86_64"),
target_arch = "x86_64", target_arch = "asmjs"),
any(not(target_arch = "aarch64"), not(target_os = "ios")),
not(target_arch = "wasm32"),
not(target_arch = "asmjs"),
not(windows)))]
inner: &'a mut VaListImpl<'f>,
@@ -169,10 +193,8 @@ pub struct VaList<'a, 'f: 'a> {
}
#[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"),
not(target_arch = "x86_64")),
not(target_arch = "x86_64"), not(target_arch = "asmjs")),
all(target_arch = "aarch64", target_os = "ios"),
target_arch = "wasm32",
target_arch = "asmjs",
windows))]
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
@@ -190,10 +212,8 @@ impl<'f> VaListImpl<'f> {
}
#[cfg(all(any(target_arch = "aarch64", target_arch = "powerpc",
target_arch = "x86_64"),
target_arch = "x86_64", target_arch = "asmjs"),
any(not(target_arch = "aarch64"), not(target_os = "ios")),
not(target_arch = "wasm32"),
not(target_arch = "asmjs"),
not(windows)))]
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \

View File

@@ -114,8 +114,24 @@ pub fn black_box<T>(dummy: T) -> T {
// this. LLVM's intepretation of inline assembly is that it's, well, a black
// box. This isn't the greatest implementation since it probably deoptimizes
// more than we want, but it's so far good enough.
#[cfg(not(any(
target_arch = "asmjs",
all(
target_arch = "wasm32",
target_os = "emscripten"
)
)))]
unsafe {
asm!("" : : "r"(&dummy));
return dummy;
}
// Not all platforms support inline assembly so try to do something without
// inline assembly which in theory still hinders at least some optimizations
// on those targets. This is the "best effort" scenario.
unsafe {
let ret = crate::ptr::read_volatile(&dummy);
crate::mem::forget(dummy);
ret
}
}