Skip to content

Commit 90230ce

Browse files
committed
Rollup merge of rust-lang#49050 - snf:fix_oom_asmjs, r=alexcrichton
setting ABORTING_MALLOC=0 for asmjs backend This changes the behaviour of the allocator for asmjs backend. It will return NULL on OOM instead of aborting and let Rust choose the behaviour. Fixes rust-lang#48968 and enables try_reserve (fallible allocation) in asmjs.
2 parents 55a0075 + 9e64946 commit 90230ce

File tree

5 files changed

+5
-23
lines changed

5 files changed

+5
-23
lines changed

src/liballoc/tests/string.rs

-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
// except according to those terms.
1010

1111
use std::borrow::Cow;
12-
#[cfg(not(target_arch = "asmjs"))]
1312
use std::collections::CollectionAllocErr::*;
14-
#[cfg(not(target_arch = "asmjs"))]
1513
use std::mem::size_of;
16-
#[cfg(not(target_arch = "asmjs"))]
1714
use std::{usize, isize};
1815

1916
pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
@@ -535,7 +532,6 @@ fn test_reserve_exact() {
535532
assert!(s.capacity() >= 33)
536533
}
537534

538-
#[cfg(not(target_arch = "asmjs"))]
539535
#[test]
540536
fn test_try_reserve() {
541537

@@ -613,7 +609,6 @@ fn test_try_reserve() {
613609

614610
}
615611

616-
#[cfg(not(target_arch = "asmjs"))]
617612
#[test]
618613
fn test_try_reserve_exact() {
619614

src/liballoc/tests/vec.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010

1111
use std::borrow::Cow;
1212
use std::mem::size_of;
13-
use std::{usize, panic};
14-
#[cfg(not(target_arch = "asmjs"))]
15-
use std::isize;
13+
use std::{usize, isize, panic};
1614
use std::vec::{Drain, IntoIter};
17-
#[cfg(not(target_arch = "asmjs"))]
1815
use std::collections::CollectionAllocErr::*;
1916

2017
struct DropCounter<'a> {
@@ -994,7 +991,6 @@ fn test_reserve_exact() {
994991
assert!(v.capacity() >= 33)
995992
}
996993

997-
#[cfg(not(target_arch = "asmjs"))]
998994
#[test]
999995
fn test_try_reserve() {
1000996

@@ -1097,7 +1093,6 @@ fn test_try_reserve() {
10971093

10981094
}
10991095

1100-
#[cfg(not(target_arch = "asmjs"))]
11011096
#[test]
11021097
fn test_try_reserve_exact() {
11031098

src/liballoc/tests/vec_deque.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@
1111
use std::collections::VecDeque;
1212
use std::fmt::Debug;
1313
use std::collections::vec_deque::{Drain};
14-
#[cfg(not(target_arch = "asmjs"))]
1514
use std::collections::CollectionAllocErr::*;
16-
#[cfg(not(target_arch = "asmjs"))]
1715
use std::mem::size_of;
18-
use std::isize;
19-
#[cfg(not(target_arch = "asmjs"))]
20-
use std::usize;
16+
use std::{usize, isize};
2117

2218
use self::Taggy::*;
2319
use self::Taggypar::*;
@@ -1053,7 +1049,6 @@ fn test_reserve_exact_2() {
10531049
assert!(v.capacity() >= 48)
10541050
}
10551051

1056-
#[cfg(not(target_arch = "asmjs"))]
10571052
#[test]
10581053
fn test_try_reserve() {
10591054

@@ -1155,7 +1150,6 @@ fn test_try_reserve() {
11551150

11561151
}
11571152

1158-
#[cfg(not(target_arch = "asmjs"))]
11591153
#[test]
11601154
fn test_try_reserve_exact() {
11611155

src/librustc_back/target/asmjs_unknown_emscripten.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ pub fn target() -> Result<Target, String> {
1515
let mut args = LinkArgs::new();
1616
args.insert(LinkerFlavor::Em,
1717
vec!["-s".to_string(),
18-
"ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()]);
18+
"ERROR_ON_UNDEFINED_SYMBOLS=1".to_string(),
19+
"-s".to_string(),
20+
"ABORTING_MALLOC=0".to_string()]);
1921

2022
let opts = TargetOptions {
2123
dynamic_linking: false,

src/libstd/collections/hash/map.rs

-4
Original file line numberDiff line numberDiff line change
@@ -2755,11 +2755,8 @@ mod test_map {
27552755
use cell::RefCell;
27562756
use rand::{thread_rng, Rng};
27572757
use panic;
2758-
#[cfg(not(target_arch = "asmjs"))]
27592758
use realstd::collections::CollectionAllocErr::*;
2760-
#[cfg(not(target_arch = "asmjs"))]
27612759
use realstd::mem::size_of;
2762-
#[cfg(not(target_arch = "asmjs"))]
27632760
use realstd::usize;
27642761

27652762
#[test]
@@ -3696,7 +3693,6 @@ mod test_map {
36963693
assert_eq!(hm.len(), 0);
36973694
}
36983695

3699-
#[cfg(not(target_arch = "asmjs"))]
37003696
#[test]
37013697
fn test_try_reserve() {
37023698

0 commit comments

Comments
 (0)